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/bits.h>
10 #include <linux/types.h>
11 
12 struct drm_device;
13 struct drm_file;
14 struct drm_framebuffer;
15 struct drm_i915_gem_object;
16 struct drm_i915_private;
17 struct drm_mode_fb_cmd2;
18 struct intel_fb_view;
19 struct intel_framebuffer;
20 struct intel_plane;
21 struct intel_plane_state;
22 
23 #define INTEL_PLANE_CAP_NONE		0
24 #define INTEL_PLANE_CAP_CCS_RC		BIT(0)
25 #define INTEL_PLANE_CAP_CCS_RC_CC	BIT(1)
26 #define INTEL_PLANE_CAP_CCS_MC		BIT(2)
27 #define INTEL_PLANE_CAP_TILING_X	BIT(3)
28 #define INTEL_PLANE_CAP_TILING_Y	BIT(4)
29 #define INTEL_PLANE_CAP_TILING_Yf	BIT(5)
30 #define INTEL_PLANE_CAP_TILING_4	BIT(6)
31 
32 bool intel_fb_is_tiled_modifier(u64 modifier);
33 bool intel_fb_is_ccs_modifier(u64 modifier);
34 bool intel_fb_is_rc_ccs_cc_modifier(u64 modifier);
35 bool intel_fb_is_mc_ccs_modifier(u64 modifier);
36 
37 bool intel_fb_is_ccs_aux_plane(const struct drm_framebuffer *fb, int color_plane);
38 int intel_fb_rc_ccs_cc_plane(const struct drm_framebuffer *fb);
39 
40 u64 *intel_fb_plane_get_modifiers(struct drm_i915_private *i915,
41 				  u8 plane_caps);
42 bool intel_fb_plane_supports_modifier(struct intel_plane *plane, u64 modifier);
43 
44 const struct drm_format_info *
45 intel_fb_get_format_info(const struct drm_mode_fb_cmd2 *cmd);
46 
47 bool
48 intel_format_info_is_yuv_semiplanar(const struct drm_format_info *info,
49 				    u64 modifier);
50 
51 bool is_surface_linear(const struct drm_framebuffer *fb, int color_plane);
52 
53 int main_to_ccs_plane(const struct drm_framebuffer *fb, int main_plane);
54 int skl_ccs_to_main_plane(const struct drm_framebuffer *fb, int ccs_plane);
55 int skl_main_to_aux_plane(const struct drm_framebuffer *fb, int main_plane);
56 
57 unsigned int intel_tile_size(const struct drm_i915_private *i915);
58 unsigned int intel_tile_width_bytes(const struct drm_framebuffer *fb, int color_plane);
59 unsigned int intel_tile_height(const struct drm_framebuffer *fb, int color_plane);
60 unsigned int intel_tile_row_size(const struct drm_framebuffer *fb, int color_plane);
61 unsigned int intel_fb_align_height(const struct drm_framebuffer *fb,
62 				   int color_plane, unsigned int height);
63 unsigned int intel_cursor_alignment(const struct drm_i915_private *i915);
64 unsigned int intel_surf_alignment(const struct drm_framebuffer *fb,
65 				  int color_plane);
66 
67 void intel_fb_plane_get_subsampling(int *hsub, int *vsub,
68 				    const struct drm_framebuffer *fb,
69 				    int color_plane);
70 
71 u32 intel_plane_adjust_aligned_offset(int *x, int *y,
72 				      const struct intel_plane_state *state,
73 				      int color_plane,
74 				      u32 old_offset, u32 new_offset);
75 u32 intel_plane_compute_aligned_offset(int *x, int *y,
76 				       const struct intel_plane_state *state,
77 				       int color_plane);
78 
79 bool intel_fb_needs_pot_stride_remap(const struct intel_framebuffer *fb);
80 bool intel_fb_supports_90_270_rotation(const struct intel_framebuffer *fb);
81 
82 int intel_fill_fb_info(struct drm_i915_private *i915, struct intel_framebuffer *fb);
83 void intel_fb_fill_view(const struct intel_framebuffer *fb, unsigned int rotation,
84 			struct intel_fb_view *view);
85 int intel_plane_compute_gtt(struct intel_plane_state *plane_state);
86 
87 int intel_framebuffer_init(struct intel_framebuffer *ifb,
88 			   struct drm_i915_gem_object *obj,
89 			   struct drm_mode_fb_cmd2 *mode_cmd);
90 struct drm_framebuffer *
91 intel_user_framebuffer_create(struct drm_device *dev,
92 			      struct drm_file *filp,
93 			      const struct drm_mode_fb_cmd2 *user_mode_cmd);
94 
95 bool intel_fb_uses_dpt(const struct drm_framebuffer *fb);
96 
97 #endif /* __INTEL_FB_H__ */
98