1 /* SPDX-License-Identifier: MIT */
2 /*
3  * Copyright © 2020-2021 Intel Corporation
4  */
5 
6 #ifndef __INTEL_FB_H__
7 #define __INTEL_FB_H__
8 
9 #include <linux/types.h>
10 
11 struct drm_device;
12 struct drm_file;
13 struct drm_framebuffer;
14 struct drm_i915_gem_object;
15 struct drm_i915_private;
16 struct drm_mode_fb_cmd2;
17 struct intel_fb_view;
18 struct intel_framebuffer;
19 struct intel_plane_state;
20 
21 bool is_ccs_plane(const struct drm_framebuffer *fb, int plane);
22 bool is_gen12_ccs_plane(const struct drm_framebuffer *fb, int plane);
23 bool is_gen12_ccs_cc_plane(const struct drm_framebuffer *fb, int plane);
24 bool is_semiplanar_uv_plane(const struct drm_framebuffer *fb, int color_plane);
25 
26 bool is_surface_linear(const struct drm_framebuffer *fb, int color_plane);
27 
28 int main_to_ccs_plane(const struct drm_framebuffer *fb, int main_plane);
29 int skl_ccs_to_main_plane(const struct drm_framebuffer *fb, int ccs_plane);
30 int skl_main_to_aux_plane(const struct drm_framebuffer *fb, int main_plane);
31 
32 unsigned int intel_tile_size(const struct drm_i915_private *i915);
33 unsigned int intel_tile_width_bytes(const struct drm_framebuffer *fb, int color_plane);
34 unsigned int intel_tile_height(const struct drm_framebuffer *fb, int color_plane);
35 unsigned int intel_tile_row_size(const struct drm_framebuffer *fb, int color_plane);
36 unsigned int intel_fb_align_height(const struct drm_framebuffer *fb,
37 				   int color_plane, unsigned int height);
38 unsigned int intel_cursor_alignment(const struct drm_i915_private *i915);
39 unsigned int intel_surf_alignment(const struct drm_framebuffer *fb,
40 				  int color_plane);
41 
42 void intel_fb_plane_get_subsampling(int *hsub, int *vsub,
43 				    const struct drm_framebuffer *fb,
44 				    int color_plane);
45 
46 u32 intel_plane_adjust_aligned_offset(int *x, int *y,
47 				      const struct intel_plane_state *state,
48 				      int color_plane,
49 				      u32 old_offset, u32 new_offset);
50 u32 intel_plane_compute_aligned_offset(int *x, int *y,
51 				       const struct intel_plane_state *state,
52 				       int color_plane);
53 
54 bool intel_fb_needs_pot_stride_remap(const struct intel_framebuffer *fb);
55 bool intel_fb_supports_90_270_rotation(const struct intel_framebuffer *fb);
56 
57 int intel_fill_fb_info(struct drm_i915_private *i915, struct intel_framebuffer *fb);
58 void intel_fb_fill_view(const struct intel_framebuffer *fb, unsigned int rotation,
59 			struct intel_fb_view *view);
60 int intel_plane_compute_gtt(struct intel_plane_state *plane_state);
61 
62 int intel_framebuffer_init(struct intel_framebuffer *ifb,
63 			   struct drm_i915_gem_object *obj,
64 			   struct drm_mode_fb_cmd2 *mode_cmd);
65 struct drm_framebuffer *
66 intel_user_framebuffer_create(struct drm_device *dev,
67 			      struct drm_file *filp,
68 			      const struct drm_mode_fb_cmd2 *user_mode_cmd);
69 
70 #endif /* __INTEL_FB_H__ */
71