Lines Matching full:fb
14 bool is_ccs_plane(const struct drm_framebuffer *fb, int plane) in is_ccs_plane() argument
16 if (!is_ccs_modifier(fb->modifier)) in is_ccs_plane()
19 return plane >= fb->format->num_planes / 2; in is_ccs_plane()
22 bool is_gen12_ccs_plane(const struct drm_framebuffer *fb, int plane) in is_gen12_ccs_plane() argument
24 return is_gen12_ccs_modifier(fb->modifier) && is_ccs_plane(fb, plane); in is_gen12_ccs_plane()
27 bool is_gen12_ccs_cc_plane(const struct drm_framebuffer *fb, int plane) in is_gen12_ccs_cc_plane() argument
29 return fb->modifier == I915_FORMAT_MOD_Y_TILED_GEN12_RC_CCS_CC && in is_gen12_ccs_cc_plane()
33 bool is_semiplanar_uv_plane(const struct drm_framebuffer *fb, int color_plane) in is_semiplanar_uv_plane() argument
35 return intel_format_info_is_yuv_semiplanar(fb->format, fb->modifier) && in is_semiplanar_uv_plane()
39 bool is_surface_linear(const struct drm_framebuffer *fb, int color_plane) in is_surface_linear() argument
41 return fb->modifier == DRM_FORMAT_MOD_LINEAR || in is_surface_linear()
42 is_gen12_ccs_plane(fb, color_plane); in is_surface_linear()
45 int main_to_ccs_plane(const struct drm_framebuffer *fb, int main_plane) in main_to_ccs_plane() argument
47 drm_WARN_ON(fb->dev, !is_ccs_modifier(fb->modifier) || in main_to_ccs_plane()
48 (main_plane && main_plane >= fb->format->num_planes / 2)); in main_to_ccs_plane()
50 return fb->format->num_planes / 2 + main_plane; in main_to_ccs_plane()
53 int skl_ccs_to_main_plane(const struct drm_framebuffer *fb, int ccs_plane) in skl_ccs_to_main_plane() argument
55 drm_WARN_ON(fb->dev, !is_ccs_modifier(fb->modifier) || in skl_ccs_to_main_plane()
56 ccs_plane < fb->format->num_planes / 2); in skl_ccs_to_main_plane()
58 if (is_gen12_ccs_cc_plane(fb, ccs_plane)) in skl_ccs_to_main_plane()
61 return ccs_plane - fb->format->num_planes / 2; in skl_ccs_to_main_plane()
64 int skl_main_to_aux_plane(const struct drm_framebuffer *fb, int main_plane) in skl_main_to_aux_plane() argument
66 struct drm_i915_private *i915 = to_i915(fb->dev); in skl_main_to_aux_plane()
68 if (is_ccs_modifier(fb->modifier)) in skl_main_to_aux_plane()
69 return main_to_ccs_plane(fb, main_plane); in skl_main_to_aux_plane()
71 intel_format_info_is_yuv_semiplanar(fb->format, fb->modifier)) in skl_main_to_aux_plane()
82 unsigned int intel_tile_height(const struct drm_framebuffer *fb, int color_plane) in intel_tile_height() argument
84 if (is_gen12_ccs_plane(fb, color_plane)) in intel_tile_height()
87 return intel_tile_size(to_i915(fb->dev)) / in intel_tile_height()
88 intel_tile_width_bytes(fb, color_plane); in intel_tile_height()
92 static void intel_tile_dims(const struct drm_framebuffer *fb, int color_plane, in intel_tile_dims() argument
96 unsigned int tile_width_bytes = intel_tile_width_bytes(fb, color_plane); in intel_tile_dims()
97 unsigned int cpp = fb->format->cpp[color_plane]; in intel_tile_dims()
100 *tile_height = intel_tile_height(fb, color_plane); in intel_tile_dims()
103 unsigned int intel_tile_row_size(const struct drm_framebuffer *fb, int color_plane) in intel_tile_row_size() argument
107 intel_tile_dims(fb, color_plane, &tile_width, &tile_height); in intel_tile_row_size()
109 return fb->pitches[color_plane] * tile_height; in intel_tile_row_size()
125 const struct drm_framebuffer *fb, in intel_fb_plane_get_subsampling() argument
141 if (!is_gen12_ccs_plane(fb, color_plane)) { in intel_fb_plane_get_subsampling()
142 *hsub = fb->format->hsub; in intel_fb_plane_get_subsampling()
143 *vsub = fb->format->vsub; in intel_fb_plane_get_subsampling()
148 main_plane = skl_ccs_to_main_plane(fb, color_plane); in intel_fb_plane_get_subsampling()
149 *hsub = drm_format_info_block_width(fb->format, color_plane) / in intel_fb_plane_get_subsampling()
150 drm_format_info_block_width(fb->format, main_plane); in intel_fb_plane_get_subsampling()
161 *hsub *= fb->format->hsub; in intel_fb_plane_get_subsampling()
166 static void intel_fb_plane_dims(const struct intel_framebuffer *fb, int color_plane, int *w, int *h) in intel_fb_plane_dims() argument
168 int main_plane = is_ccs_plane(&fb->base, color_plane) ? in intel_fb_plane_dims()
169 skl_ccs_to_main_plane(&fb->base, color_plane) : 0; in intel_fb_plane_dims()
173 intel_fb_plane_get_subsampling(&main_hsub, &main_vsub, &fb->base, main_plane); in intel_fb_plane_dims()
174 intel_fb_plane_get_subsampling(&hsub, &vsub, &fb->base, color_plane); in intel_fb_plane_dims()
175 *w = fb->base.width / main_hsub / hsub; in intel_fb_plane_dims()
176 *h = fb->base.height / main_vsub / vsub; in intel_fb_plane_dims()
207 const struct drm_framebuffer *fb, in intel_adjust_aligned_offset() argument
213 struct drm_i915_private *i915 = to_i915(fb->dev); in intel_adjust_aligned_offset()
214 unsigned int cpp = fb->format->cpp[color_plane]; in intel_adjust_aligned_offset()
218 if (!is_surface_linear(fb, color_plane)) { in intel_adjust_aligned_offset()
223 intel_tile_dims(fb, color_plane, &tile_width, &tile_height); in intel_adjust_aligned_offset()
254 return intel_adjust_aligned_offset(x, y, state->hw.fb, color_plane, in intel_plane_adjust_aligned_offset()
276 const struct drm_framebuffer *fb, in intel_compute_aligned_offset() argument
282 unsigned int cpp = fb->format->cpp[color_plane]; in intel_compute_aligned_offset()
285 if (!is_surface_linear(fb, color_plane)) { in intel_compute_aligned_offset()
290 intel_tile_dims(fb, color_plane, &tile_width, &tile_height); in intel_compute_aligned_offset()
335 const struct drm_framebuffer *fb = state->hw.fb; in intel_plane_compute_aligned_offset() local
343 alignment = intel_surf_alignment(fb, color_plane); in intel_plane_compute_aligned_offset()
345 return intel_compute_aligned_offset(i915, x, y, fb, color_plane, in intel_plane_compute_aligned_offset()
349 /* Convert the fb->offset[] into x/y offsets */
351 const struct drm_framebuffer *fb, in intel_fb_offset_to_xy() argument
354 struct drm_i915_private *i915 = to_i915(fb->dev); in intel_fb_offset_to_xy()
365 if (IS_ALDERLAKE_P(i915) && is_ccs_modifier(fb->modifier)) in intel_fb_offset_to_xy()
368 is_semiplanar_uv_plane(fb, color_plane)) in intel_fb_offset_to_xy()
369 alignment = intel_tile_row_size(fb, color_plane); in intel_fb_offset_to_xy()
370 else if (fb->modifier != DRM_FORMAT_MOD_LINEAR) in intel_fb_offset_to_xy()
375 if (alignment != 0 && fb->offsets[color_plane] % alignment) { in intel_fb_offset_to_xy()
378 fb->offsets[color_plane], color_plane); in intel_fb_offset_to_xy()
382 height = drm_framebuffer_plane_height(fb->height, fb, color_plane); in intel_fb_offset_to_xy()
383 height = ALIGN(height, intel_tile_height(fb, color_plane)); in intel_fb_offset_to_xy()
386 if (add_overflows_t(u32, mul_u32_u32(height, fb->pitches[color_plane]), in intel_fb_offset_to_xy()
387 fb->offsets[color_plane])) { in intel_fb_offset_to_xy()
390 fb->offsets[color_plane], fb->pitches[color_plane], in intel_fb_offset_to_xy()
399 fb, color_plane, DRM_MODE_ROTATE_0, in intel_fb_offset_to_xy()
400 fb->pitches[color_plane], in intel_fb_offset_to_xy()
401 fb->offsets[color_plane], 0); in intel_fb_offset_to_xy()
406 static int intel_fb_check_ccs_xy(const struct drm_framebuffer *fb, int ccs_plane, int x, int y) in intel_fb_check_ccs_xy() argument
408 struct drm_i915_private *i915 = to_i915(fb->dev); in intel_fb_check_ccs_xy()
409 const struct intel_framebuffer *intel_fb = to_intel_framebuffer(fb); in intel_fb_check_ccs_xy()
416 if (!is_ccs_plane(fb, ccs_plane) || is_gen12_ccs_cc_plane(fb, ccs_plane)) in intel_fb_check_ccs_xy()
419 intel_tile_dims(fb, ccs_plane, &tile_width, &tile_height); in intel_fb_check_ccs_xy()
420 intel_fb_plane_get_subsampling(&hsub, &vsub, fb, ccs_plane); in intel_fb_check_ccs_xy()
428 main_plane = skl_ccs_to_main_plane(fb, ccs_plane); in intel_fb_check_ccs_xy()
454 const struct drm_framebuffer *fb = plane_state->hw.fb; in intel_plane_can_remap() local
474 if (is_ccs_modifier(fb->modifier)) in intel_plane_can_remap()
478 if (fb->modifier == DRM_FORMAT_MOD_LINEAR) { in intel_plane_can_remap()
481 for (i = 0; i < fb->format->num_planes; i++) { in intel_plane_can_remap()
482 if (fb->pitches[i] & alignment) in intel_plane_can_remap()
490 bool intel_fb_needs_pot_stride_remap(const struct intel_framebuffer *fb) in intel_fb_needs_pot_stride_remap() argument
492 struct drm_i915_private *i915 = to_i915(fb->base.dev); in intel_fb_needs_pot_stride_remap()
494 return IS_ALDERLAKE_P(i915) && fb->base.modifier != DRM_FORMAT_MOD_LINEAR && in intel_fb_needs_pot_stride_remap()
495 !is_ccs_modifier(fb->base.modifier); in intel_fb_needs_pot_stride_remap()
498 static int intel_fb_pitch(const struct intel_framebuffer *fb, int color_plane, unsigned int rotatio… in intel_fb_pitch() argument
501 return fb->rotated_view.color_plane[color_plane].stride; in intel_fb_pitch()
502 else if (intel_fb_needs_pot_stride_remap(fb)) in intel_fb_pitch()
503 return fb->remapped_view.color_plane[color_plane].stride; in intel_fb_pitch()
505 return fb->normal_view.color_plane[color_plane].stride; in intel_fb_pitch()
511 const struct intel_framebuffer *fb = to_intel_framebuffer(plane_state->hw.fb); in intel_plane_needs_remap() local
529 stride = intel_fb_pitch(fb, 0, rotation); in intel_plane_needs_remap()
530 max_stride = plane->max_stride(plane, fb->base.format->format, in intel_plane_needs_remap()
531 fb->base.modifier, rotation); in intel_plane_needs_remap()
536 static int convert_plane_offset_to_xy(const struct intel_framebuffer *fb, int color_plane, in convert_plane_offset_to_xy() argument
539 struct drm_i915_gem_object *obj = intel_fb_obj(&fb->base); in convert_plane_offset_to_xy()
542 ret = intel_fb_offset_to_xy(x, y, &fb->base, color_plane); in convert_plane_offset_to_xy()
544 drm_dbg_kms(fb->base.dev, in convert_plane_offset_to_xy()
545 "bad fb plane %d offset: 0x%x\n", in convert_plane_offset_to_xy()
546 color_plane, fb->base.offsets[color_plane]); in convert_plane_offset_to_xy()
550 ret = intel_fb_check_ccs_xy(&fb->base, color_plane, *x, *y); in convert_plane_offset_to_xy()
560 * fb layout agrees with the fence layout. We already check that the in convert_plane_offset_to_xy()
561 * fb stride matches the fence stride elsewhere. in convert_plane_offset_to_xy()
564 (*x + plane_width) * fb->base.format->cpp[color_plane] > fb->base.pitches[color_plane]) { in convert_plane_offset_to_xy()
565 drm_dbg_kms(fb->base.dev, in convert_plane_offset_to_xy()
566 "bad fb plane %d offset: 0x%x\n", in convert_plane_offset_to_xy()
567 color_plane, fb->base.offsets[color_plane]); in convert_plane_offset_to_xy()
574 static u32 calc_plane_aligned_offset(const struct intel_framebuffer *fb, int color_plane, int *x, i… in calc_plane_aligned_offset() argument
576 struct drm_i915_private *i915 = to_i915(fb->base.dev); in calc_plane_aligned_offset()
580 offset = intel_compute_aligned_offset(i915, x, y, &fb->base, color_plane, in calc_plane_aligned_offset()
581 fb->base.pitches[color_plane], in calc_plane_aligned_offset()
593 static void init_plane_view_dims(const struct intel_framebuffer *fb, int color_plane, in init_plane_view_dims() argument
600 intel_tile_dims(&fb->base, color_plane, &dims->tile_width, &dims->tile_height); in init_plane_view_dims()
604 plane_view_src_stride_tiles(const struct intel_framebuffer *fb, int color_plane, in plane_view_src_stride_tiles() argument
607 return DIV_ROUND_UP(fb->base.pitches[color_plane], in plane_view_src_stride_tiles()
608 dims->tile_width * fb->base.format->cpp[color_plane]); in plane_view_src_stride_tiles()
612 plane_view_dst_stride_tiles(const struct intel_framebuffer *fb, int color_plane, in plane_view_dst_stride_tiles() argument
615 if (intel_fb_needs_pot_stride_remap(fb)) in plane_view_dst_stride_tiles()
626 plane_view_width_tiles(const struct intel_framebuffer *fb, int color_plane, in plane_view_width_tiles() argument
634 plane_view_height_tiles(const struct intel_framebuffer *fb, int color_plane, in plane_view_height_tiles() argument
646 static u32 calc_plane_remap_info(const struct intel_framebuffer *fb, int color_plane, in calc_plane_remap_info() argument
651 struct drm_i915_private *i915 = to_i915(fb->base.dev); in calc_plane_remap_info()
661 assign_chk_ovf(i915, remap_info->src_stride, plane_view_src_stride_tiles(fb, color_plane, dims)); in calc_plane_remap_info()
662 assign_chk_ovf(i915, remap_info->width, plane_view_width_tiles(fb, color_plane, dims, x)); in calc_plane_remap_info()
663 assign_chk_ovf(i915, remap_info->height, plane_view_height_tiles(fb, color_plane, dims, y)); in calc_plane_remap_info()
669 plane_view_dst_stride_tiles(fb, color_plane, remap_info->height)); in calc_plane_remap_info()
693 plane_view_dst_stride_tiles(fb, color_plane, remap_info->width)); in calc_plane_remap_info()
699 fb->base.format->cpp[color_plane]; in calc_plane_remap_info()
721 calc_plane_normal_size(const struct intel_framebuffer *fb, int color_plane, in calc_plane_normal_size() argument
725 struct drm_i915_private *i915 = to_i915(fb->base.dev); in calc_plane_normal_size()
728 if (is_surface_linear(&fb->base, color_plane)) { in calc_plane_normal_size()
731 size = (y + dims->height) * fb->base.pitches[color_plane] + in calc_plane_normal_size()
732 x * fb->base.format->cpp[color_plane]; in calc_plane_normal_size()
735 tiles = plane_view_src_stride_tiles(fb, color_plane, dims) * in calc_plane_normal_size()
736 plane_view_height_tiles(fb, color_plane, dims, y); in calc_plane_normal_size()
754 bool intel_fb_supports_90_270_rotation(const struct intel_framebuffer *fb) in intel_fb_supports_90_270_rotation() argument
756 if (DISPLAY_VER(to_i915(fb->base.dev)) >= 13) in intel_fb_supports_90_270_rotation()
759 return fb->base.modifier == I915_FORMAT_MOD_Y_TILED || in intel_fb_supports_90_270_rotation()
760 fb->base.modifier == I915_FORMAT_MOD_Yf_TILED; in intel_fb_supports_90_270_rotation()
763 int intel_fill_fb_info(struct drm_i915_private *i915, struct intel_framebuffer *fb) in intel_fill_fb_info() argument
765 struct drm_i915_gem_object *obj = intel_fb_obj(&fb->base); in intel_fill_fb_info()
769 int i, num_planes = fb->base.format->num_planes; in intel_fill_fb_info()
772 intel_fb_view_init(&fb->normal_view, I915_GGTT_VIEW_NORMAL); in intel_fill_fb_info()
775 intel_fb_supports_90_270_rotation(fb) && in intel_fill_fb_info()
776 intel_fb_needs_pot_stride_remap(fb)); in intel_fill_fb_info()
778 if (intel_fb_supports_90_270_rotation(fb)) in intel_fill_fb_info()
779 intel_fb_view_init(&fb->rotated_view, I915_GGTT_VIEW_ROTATED); in intel_fill_fb_info()
780 if (intel_fb_needs_pot_stride_remap(fb)) in intel_fill_fb_info()
781 intel_fb_view_init(&fb->remapped_view, I915_GGTT_VIEW_REMAPPED); in intel_fill_fb_info()
792 * Plane 2 of Render Compression with Clear Color fb modifier in intel_fill_fb_info()
796 if (is_gen12_ccs_cc_plane(&fb->base, i)) { in intel_fill_fb_info()
797 if (IS_ALIGNED(fb->base.offsets[i], PAGE_SIZE)) in intel_fill_fb_info()
803 cpp = fb->base.format->cpp[i]; in intel_fill_fb_info()
804 intel_fb_plane_dims(fb, i, &width, &height); in intel_fill_fb_info()
806 ret = convert_plane_offset_to_xy(fb, i, width, &x, &y); in intel_fill_fb_info()
810 init_plane_view_dims(fb, i, width, height, &view_dims); in intel_fill_fb_info()
816 fb->normal_view.color_plane[i].x = x; in intel_fill_fb_info()
817 fb->normal_view.color_plane[i].y = y; in intel_fill_fb_info()
818 fb->normal_view.color_plane[i].stride = fb->base.pitches[i]; in intel_fill_fb_info()
820 offset = calc_plane_aligned_offset(fb, i, &x, &y); in intel_fill_fb_info()
822 if (intel_fb_supports_90_270_rotation(fb)) in intel_fill_fb_info()
823 gtt_offset_rotated += calc_plane_remap_info(fb, i, &view_dims, in intel_fill_fb_info()
825 &fb->rotated_view); in intel_fill_fb_info()
827 if (intel_fb_needs_pot_stride_remap(fb)) in intel_fill_fb_info()
828 gtt_offset_remapped += calc_plane_remap_info(fb, i, &view_dims, in intel_fill_fb_info()
830 &fb->remapped_view); in intel_fill_fb_info()
832 size = calc_plane_normal_size(fb, i, &view_dims, x, y); in intel_fill_fb_info()
839 "fb too big for bo (need %llu bytes, have %zu bytes)\n", in intel_fill_fb_info()
851 struct drm_framebuffer *fb = plane_state->hw.fb; in intel_plane_remap_gtt() local
852 struct intel_framebuffer *intel_fb = to_intel_framebuffer(fb); in intel_plane_remap_gtt()
854 int i, num_planes = fb->format->num_planes; in intel_plane_remap_gtt()
868 drm_WARN_ON(&i915->drm, is_ccs_modifier(fb->modifier)); in intel_plane_remap_gtt()
881 unsigned int hsub = i ? fb->format->hsub : 1; in intel_plane_remap_gtt()
882 unsigned int vsub = i ? fb->format->vsub : 1; in intel_plane_remap_gtt()
910 void intel_fb_fill_view(const struct intel_framebuffer *fb, unsigned int rotation, in intel_fb_fill_view() argument
914 *view = fb->rotated_view; in intel_fb_fill_view()
915 else if (intel_fb_needs_pot_stride_remap(fb)) in intel_fb_fill_view()
916 *view = fb->remapped_view; in intel_fb_fill_view()
918 *view = fb->normal_view; in intel_fb_fill_view()
924 const struct drm_framebuffer *fb = plane_state->hw.fb; in intel_plane_check_stride() local
940 max_stride = plane->max_stride(plane, fb->format->format, in intel_plane_check_stride()
941 fb->modifier, rotation); in intel_plane_check_stride()
944 DRM_DEBUG_KMS("[FB:%d] stride (%d) exceeds [PLANE:%d:%s] max stride (%d)\n", in intel_plane_check_stride()
945 fb->base.id, stride, in intel_plane_check_stride()
955 const struct intel_framebuffer *fb = in intel_plane_compute_gtt() local
956 to_intel_framebuffer(plane_state->hw.fb); in intel_plane_compute_gtt()
959 if (!fb) in intel_plane_compute_gtt()
974 intel_fb_fill_view(fb, rotation, &plane_state->view); in intel_plane_compute_gtt()
979 fb->base.width << 16, fb->base.height << 16, in intel_plane_compute_gtt()