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 enum intel_plane_caps { 24 PLANE_HAS_NO_CAPS = 0, 25 PLANE_HAS_TILING = BIT(0), 26 PLANE_HAS_CCS_RC = BIT(1), 27 PLANE_HAS_CCS_MC = BIT(2), 28 }; 29 30 bool is_ccs_plane(const struct drm_framebuffer *fb, int plane); 31 bool is_gen12_ccs_plane(const struct drm_framebuffer *fb, int plane); 32 bool is_gen12_ccs_cc_plane(const struct drm_framebuffer *fb, int plane); 33 34 u64 *intel_fb_plane_get_modifiers(struct drm_i915_private *i915, 35 enum intel_plane_caps plane_caps); 36 bool intel_fb_plane_supports_modifier(struct intel_plane *plane, u64 modifier); 37 38 const struct drm_format_info * 39 intel_fb_get_format_info(const struct drm_mode_fb_cmd2 *cmd); 40 41 bool 42 intel_format_info_is_yuv_semiplanar(const struct drm_format_info *info, 43 u64 modifier); 44 45 bool is_surface_linear(const struct drm_framebuffer *fb, int color_plane); 46 47 int main_to_ccs_plane(const struct drm_framebuffer *fb, int main_plane); 48 int skl_ccs_to_main_plane(const struct drm_framebuffer *fb, int ccs_plane); 49 int skl_main_to_aux_plane(const struct drm_framebuffer *fb, int main_plane); 50 51 unsigned int intel_tile_size(const struct drm_i915_private *i915); 52 unsigned int intel_tile_width_bytes(const struct drm_framebuffer *fb, int color_plane); 53 unsigned int intel_tile_height(const struct drm_framebuffer *fb, int color_plane); 54 unsigned int intel_tile_row_size(const struct drm_framebuffer *fb, int color_plane); 55 unsigned int intel_fb_align_height(const struct drm_framebuffer *fb, 56 int color_plane, unsigned int height); 57 unsigned int intel_cursor_alignment(const struct drm_i915_private *i915); 58 unsigned int intel_surf_alignment(const struct drm_framebuffer *fb, 59 int color_plane); 60 61 void intel_fb_plane_get_subsampling(int *hsub, int *vsub, 62 const struct drm_framebuffer *fb, 63 int color_plane); 64 65 u32 intel_plane_adjust_aligned_offset(int *x, int *y, 66 const struct intel_plane_state *state, 67 int color_plane, 68 u32 old_offset, u32 new_offset); 69 u32 intel_plane_compute_aligned_offset(int *x, int *y, 70 const struct intel_plane_state *state, 71 int color_plane); 72 73 bool intel_fb_needs_pot_stride_remap(const struct intel_framebuffer *fb); 74 bool intel_fb_supports_90_270_rotation(const struct intel_framebuffer *fb); 75 76 int intel_fill_fb_info(struct drm_i915_private *i915, struct intel_framebuffer *fb); 77 void intel_fb_fill_view(const struct intel_framebuffer *fb, unsigned int rotation, 78 struct intel_fb_view *view); 79 int intel_plane_compute_gtt(struct intel_plane_state *plane_state); 80 81 int intel_framebuffer_init(struct intel_framebuffer *ifb, 82 struct drm_i915_gem_object *obj, 83 struct drm_mode_fb_cmd2 *mode_cmd); 84 struct drm_framebuffer * 85 intel_user_framebuffer_create(struct drm_device *dev, 86 struct drm_file *filp, 87 const struct drm_mode_fb_cmd2 *user_mode_cmd); 88 89 #endif /* __INTEL_FB_H__ */ 90