Lines Matching +full:offset +full:- +full:y
1 // SPDX-License-Identifier: MIT
9 #include <linux/dma-fence.h>
10 #include <linux/dma-resv.h>
22 #define check_array_bounds(i915, a, i) drm_WARN_ON(&(i915)->drm, (i) >= ARRAY_SIZE(a))
27 * the cache-line pairs. The compression state of the cache-line pair
28 * is specified by 2 bits in the CCS. Each CCS cache-line represents
29 * an area on the main surface of 16 x16 sets of 128 byte Y-tiled
30 * cache-line-pairs. CCS is always Y tiled."
50 * Gen-12 compression uses 4 bits of CCS data for each cache line pair in the
51 * main surface. And each 64B CCS cache line represents an area of 4x1 Y-tiles
52 * in the main surface. With 4 byte pixels and each Y-tile having dimensions of
138 #define DISPLAY_VER_ALL { 0, -1 }
167 .display_ver = { 20, -1 },
171 .display_ver = { 14, -1 },
217 .display_ver = { 13, -1 },
323 tiling_caps = lookup_modifier_or_null(fb_modifier)->plane_caps & in intel_fb_modifier_to_tiling()
346 * Returns the format information for @cmd->pixel_format specific to @cmd->modifier[0],
352 const struct intel_modifier_desc *md = lookup_modifier_or_null(cmd->modifier[0]); in intel_fb_get_format_info()
354 if (!md || !md->formats) in intel_fb_get_format_info()
357 return lookup_format_info(md->formats, md->format_count, cmd->pixel_format); in intel_fb_get_format_info()
379 return plane_caps_contain_any(lookup_modifier(modifier)->plane_caps, in intel_fb_is_tiled_modifier()
393 return plane_caps_contain_any(lookup_modifier(modifier)->plane_caps, in intel_fb_is_ccs_modifier()
406 return plane_caps_contain_any(lookup_modifier(modifier)->plane_caps, in intel_fb_is_rc_ccs_cc_modifier()
419 return plane_caps_contain_any(lookup_modifier(modifier)->plane_caps, in intel_fb_is_mc_ccs_modifier()
437 return plane_caps_contain_any(md->plane_caps, in intel_fb_needs_64k_phys()
450 return plane_caps_contain_any(lookup_modifier(modifier)->plane_caps, in intel_fb_is_tile4_modifier()
457 return md->display_ver.from <= display_ver_until && in check_modifier_display_ver_range()
458 display_ver_from <= md->display_ver.until; in check_modifier_display_ver_range()
465 if (!IS_DISPLAY_VER(i915, md->display_ver.from, md->display_ver.until)) in plane_has_modifier()
468 if (!plane_caps_contain_all(plane_caps, md->plane_caps)) in plane_has_modifier()
475 if (intel_fb_is_ccs_modifier(md->modifier) && in plane_has_modifier()
476 HAS_FLAT_CCS(i915) != !md->ccs.packed_aux_planes) in plane_has_modifier()
479 if (md->modifier == I915_FORMAT_MOD_4_TILED_BMG_CCS && in plane_has_modifier()
483 if (md->modifier == I915_FORMAT_MOD_4_TILED_LNL_CCS && in plane_has_modifier()
512 if (drm_WARN_ON(&i915->drm, !list)) in intel_fb_plane_get_modifiers()
537 for (i = 0; i < plane->base.modifier_count; i++) in intel_fb_plane_supports_modifier()
538 if (plane->base.modifiers[i] == modifier) in intel_fb_plane_supports_modifier()
547 if (!info->is_yuv) in format_is_yuv_semiplanar()
550 if (hweight8(md->ccs.planar_aux_planes) == 2) in format_is_yuv_semiplanar()
551 return info->num_planes == 4; in format_is_yuv_semiplanar()
553 return info->num_planes == 2; in format_is_yuv_semiplanar()
574 return md->ccs.planar_aux_planes; in ccs_aux_plane_mask()
576 return md->ccs.packed_aux_planes; in ccs_aux_plane_mask()
589 const struct intel_modifier_desc *md = lookup_modifier(fb->modifier); in intel_fb_is_ccs_aux_plane()
591 return ccs_aux_plane_mask(md, fb->format) & BIT(color_plane); in intel_fb_is_ccs_aux_plane()
604 const struct intel_modifier_desc *md = lookup_modifier(fb->modifier); in intel_fb_is_gen12_ccs_aux_plane()
607 ccs_aux_plane_mask(md, fb->format) & BIT(color_plane); in intel_fb_is_gen12_ccs_aux_plane()
615 * Returns the index of the color clear plane for @fb, or -1 if @fb is not a
620 const struct intel_modifier_desc *md = lookup_modifier(fb->modifier); in intel_fb_rc_ccs_cc_plane()
622 if (!md->ccs.cc_planes) in intel_fb_rc_ccs_cc_plane()
623 return -1; in intel_fb_rc_ccs_cc_plane()
625 drm_WARN_ON_ONCE(fb->dev, hweight8(md->ccs.cc_planes) > 1); in intel_fb_rc_ccs_cc_plane()
627 return ilog2((int)md->ccs.cc_planes); in intel_fb_rc_ccs_cc_plane()
637 return fb->modifier == DRM_FORMAT_MOD_LINEAR || in is_surface_linear()
644 drm_WARN_ON(fb->dev, !intel_fb_is_ccs_modifier(fb->modifier) || in main_to_ccs_plane()
645 (main_plane && main_plane >= fb->format->num_planes / 2)); in main_to_ccs_plane()
647 return fb->format->num_planes / 2 + main_plane; in main_to_ccs_plane()
652 drm_WARN_ON(fb->dev, !intel_fb_is_ccs_modifier(fb->modifier) || in skl_ccs_to_main_plane()
653 ccs_plane < fb->format->num_planes / 2); in skl_ccs_to_main_plane()
658 return ccs_plane - fb->format->num_planes / 2; in skl_ccs_to_main_plane()
663 int main_plane = skl_ccs_to_main_plane(&fb->base, ccs_plane); in gen12_ccs_aux_stride()
664 unsigned int main_stride = fb->base.pitches[main_plane]; in gen12_ccs_aux_stride()
665 unsigned int main_tile_width = intel_tile_width_bytes(&fb->base, main_plane); in gen12_ccs_aux_stride()
672 const struct intel_modifier_desc *md = lookup_modifier(fb->modifier); in skl_main_to_aux_plane()
673 struct drm_i915_private *i915 = to_i915(fb->dev); in skl_main_to_aux_plane()
675 if (md->ccs.packed_aux_planes | md->ccs.planar_aux_planes) in skl_main_to_aux_plane()
678 format_is_yuv_semiplanar(md, fb->format)) in skl_main_to_aux_plane()
692 struct drm_i915_private *dev_priv = to_i915(fb->dev); in intel_tile_width_bytes()
693 unsigned int cpp = fb->format->cpp[color_plane]; in intel_tile_width_bytes()
695 switch (fb->modifier) { in intel_tile_width_bytes()
711 * same shape as Y Tile(i.e 4*16B OWords) in intel_tile_width_bytes()
753 MISSING_CASE(fb->modifier); in intel_tile_width_bytes()
760 return intel_tile_size(to_i915(fb->dev)) / in intel_tile_height()
773 unsigned int cpp = fb->format->cpp[color_plane]; in intel_tile_dims()
800 return fb->pitches[color_plane] * tile_height; in intel_tile_row_size()
819 return to_i915(fb->dev)->display.params.enable_dpt && in intel_fb_uses_dpt()
820 intel_fb_modifier_uses_dpt(to_i915(fb->dev), fb->modifier); in intel_fb_uses_dpt()
841 *hsub = fb->format->hsub; in intel_fb_plane_get_subsampling()
842 *vsub = fb->format->vsub; in intel_fb_plane_get_subsampling()
848 *hsub = drm_format_info_block_width(fb->format, color_plane) / in intel_fb_plane_get_subsampling()
849 drm_format_info_block_width(fb->format, main_plane); in intel_fb_plane_get_subsampling()
853 * assumes that format->hsub applies to every plane except for the in intel_fb_plane_get_subsampling()
860 *hsub *= fb->format->hsub; in intel_fb_plane_get_subsampling()
867 int main_plane = intel_fb_is_ccs_aux_plane(&fb->base, color_plane) ? in intel_fb_plane_dims()
868 skl_ccs_to_main_plane(&fb->base, color_plane) : 0; in intel_fb_plane_dims()
869 unsigned int main_width = fb->base.width; in intel_fb_plane_dims()
870 unsigned int main_height = fb->base.height; in intel_fb_plane_dims()
874 intel_fb_plane_get_subsampling(&main_hsub, &main_vsub, &fb->base, main_plane); in intel_fb_plane_dims()
875 intel_fb_plane_get_subsampling(&hsub, &vsub, &fb->base, color_plane); in intel_fb_plane_dims()
881 static u32 intel_adjust_tile_offset(int *x, int *y, in intel_adjust_tile_offset() argument
892 WARN_ON(old_offset & (tile_size - 1)); in intel_adjust_tile_offset()
893 WARN_ON(new_offset & (tile_size - 1)); in intel_adjust_tile_offset()
896 tiles = (old_offset - new_offset) / tile_size; in intel_adjust_tile_offset()
898 *y += tiles / pitch_tiles * tile_height; in intel_adjust_tile_offset()
902 *y += *x / pitch_pixels * tile_height; in intel_adjust_tile_offset()
908 static u32 intel_adjust_linear_offset(int *x, int *y, in intel_adjust_linear_offset() argument
914 old_offset += *y * pitch + *x * cpp; in intel_adjust_linear_offset()
916 *y = (old_offset - new_offset) / pitch; in intel_adjust_linear_offset()
917 *x = ((old_offset - new_offset) - *y * pitch) / cpp; in intel_adjust_linear_offset()
922 static u32 intel_adjust_aligned_offset(int *x, int *y, in intel_adjust_aligned_offset() argument
929 struct drm_i915_private *i915 = to_i915(fb->dev); in intel_adjust_aligned_offset()
930 unsigned int cpp = fb->format->cpp[color_plane]; in intel_adjust_aligned_offset()
932 drm_WARN_ON(&i915->drm, new_offset > old_offset); in intel_adjust_aligned_offset()
948 intel_adjust_tile_offset(x, y, tile_width, tile_height, in intel_adjust_aligned_offset()
952 intel_adjust_linear_offset(x, y, cpp, pitch, in intel_adjust_aligned_offset()
960 * Adjust the tile offset by moving the difference into
961 * the x/y offsets.
963 u32 intel_plane_adjust_aligned_offset(int *x, int *y, in intel_plane_adjust_aligned_offset() argument
968 return intel_adjust_aligned_offset(x, y, state->hw.fb, color_plane, in intel_plane_adjust_aligned_offset()
969 state->hw.rotation, in intel_plane_adjust_aligned_offset()
970 state->view.color_plane[color_plane].mapping_stride, in intel_plane_adjust_aligned_offset()
975 * Computes the aligned offset to the base tile and adjusts
976 * x, y. bytes per pixel is assumed to be a power-of-two.
978 * In the 90/270 rotated case, x and y are assumed
989 int *x, int *y, in intel_compute_aligned_offset() argument
996 unsigned int cpp = fb->format->cpp[color_plane]; in intel_compute_aligned_offset()
997 u32 offset, offset_aligned; in intel_compute_aligned_offset() local
1013 tile_rows = *y / tile_height; in intel_compute_aligned_offset()
1014 *y %= tile_height; in intel_compute_aligned_offset()
1019 offset = (tile_rows * pitch_tiles + tiles) * tile_size; in intel_compute_aligned_offset()
1021 offset_aligned = offset; in intel_compute_aligned_offset()
1025 intel_adjust_tile_offset(x, y, tile_width, tile_height, in intel_compute_aligned_offset()
1027 offset, offset_aligned); in intel_compute_aligned_offset()
1029 offset = *y * pitch + *x * cpp; in intel_compute_aligned_offset()
1030 offset_aligned = offset; in intel_compute_aligned_offset()
1033 *y = (offset % alignment) / pitch; in intel_compute_aligned_offset()
1034 *x = ((offset % alignment) - *y * pitch) / cpp; in intel_compute_aligned_offset()
1036 *y = *x = 0; in intel_compute_aligned_offset()
1043 u32 intel_plane_compute_aligned_offset(int *x, int *y, in intel_plane_compute_aligned_offset() argument
1047 struct intel_plane *plane = to_intel_plane(state->uapi.plane); in intel_plane_compute_aligned_offset()
1048 struct drm_i915_private *i915 = to_i915(plane->base.dev); in intel_plane_compute_aligned_offset()
1049 const struct drm_framebuffer *fb = state->hw.fb; in intel_plane_compute_aligned_offset()
1050 unsigned int rotation = state->hw.rotation; in intel_plane_compute_aligned_offset()
1051 unsigned int pitch = state->view.color_plane[color_plane].mapping_stride; in intel_plane_compute_aligned_offset()
1052 unsigned int alignment = plane->min_alignment(plane, fb, color_plane); in intel_plane_compute_aligned_offset()
1054 return intel_compute_aligned_offset(i915, x, y, fb, color_plane, in intel_plane_compute_aligned_offset()
1058 /* Convert the fb->offset[] into x/y offsets */
1059 static int intel_fb_offset_to_xy(int *x, int *y, in intel_fb_offset_to_xy() argument
1063 struct drm_i915_private *i915 = to_i915(fb->dev); in intel_fb_offset_to_xy()
1066 if (fb->modifier != DRM_FORMAT_MOD_LINEAR) in intel_fb_offset_to_xy()
1071 if (alignment != 0 && fb->offsets[color_plane] % alignment) { in intel_fb_offset_to_xy()
1072 drm_dbg_kms(&i915->drm, in intel_fb_offset_to_xy()
1073 "Misaligned offset 0x%08x for color plane %d\n", in intel_fb_offset_to_xy()
1074 fb->offsets[color_plane], color_plane); in intel_fb_offset_to_xy()
1075 return -EINVAL; in intel_fb_offset_to_xy()
1078 height = drm_format_info_plane_height(fb->format, fb->height, color_plane); in intel_fb_offset_to_xy()
1082 if (check_add_overflow(mul_u32_u32(height, fb->pitches[color_plane]), in intel_fb_offset_to_xy()
1083 fb->offsets[color_plane], &unused)) { in intel_fb_offset_to_xy()
1084 drm_dbg_kms(&i915->drm, in intel_fb_offset_to_xy()
1085 "Bad offset 0x%08x or pitch %d for color plane %d\n", in intel_fb_offset_to_xy()
1086 fb->offsets[color_plane], fb->pitches[color_plane], in intel_fb_offset_to_xy()
1088 return -ERANGE; in intel_fb_offset_to_xy()
1092 *y = 0; in intel_fb_offset_to_xy()
1094 intel_adjust_aligned_offset(x, y, in intel_fb_offset_to_xy()
1096 fb->pitches[color_plane], in intel_fb_offset_to_xy()
1097 fb->offsets[color_plane], 0); in intel_fb_offset_to_xy()
1102 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
1104 struct drm_i915_private *i915 = to_i915(fb->dev); in intel_fb_check_ccs_xy()
1127 ccs_y = (y * vsub) % tile_height; in intel_fb_check_ccs_xy()
1130 main_x = intel_fb->normal_view.color_plane[main_plane].x % tile_width; in intel_fb_check_ccs_xy()
1131 main_y = intel_fb->normal_view.color_plane[main_plane].y % tile_height; in intel_fb_check_ccs_xy()
1134 * CCS doesn't have its own x/y offset register, so the intra CCS tile in intel_fb_check_ccs_xy()
1135 * x/y offsets must match between CCS and the main surface. in intel_fb_check_ccs_xy()
1138 drm_dbg_kms(&i915->drm, in intel_fb_check_ccs_xy()
1139 "Bad CCS x/y (main %d,%d ccs %d,%d) full (main %d,%d ccs %d,%d)\n", in intel_fb_check_ccs_xy()
1142 intel_fb->normal_view.color_plane[main_plane].x, in intel_fb_check_ccs_xy()
1143 intel_fb->normal_view.color_plane[main_plane].y, in intel_fb_check_ccs_xy()
1144 x, y); in intel_fb_check_ccs_xy()
1145 return -EINVAL; in intel_fb_check_ccs_xy()
1153 struct intel_plane *plane = to_intel_plane(plane_state->uapi.plane); in intel_plane_can_remap()
1154 struct drm_i915_private *i915 = to_i915(plane->base.dev); in intel_plane_can_remap()
1155 const struct drm_framebuffer *fb = plane_state->hw.fb; in intel_plane_can_remap()
1159 if (plane->id == PLANE_CURSOR) in intel_plane_can_remap()
1175 if (intel_fb_is_ccs_modifier(fb->modifier)) in intel_plane_can_remap()
1179 if (fb->modifier == DRM_FORMAT_MOD_LINEAR) { in intel_plane_can_remap()
1180 unsigned int alignment = intel_tile_size(i915) - 1; in intel_plane_can_remap()
1182 for (i = 0; i < fb->format->num_planes; i++) { in intel_plane_can_remap()
1183 if (fb->pitches[i] & alignment) in intel_plane_can_remap()
1193 struct drm_i915_private *i915 = to_i915(fb->base.dev); in intel_fb_needs_pot_stride_remap()
1196 intel_fb_uses_dpt(&fb->base); in intel_fb_needs_pot_stride_remap()
1202 return fb->rotated_view.color_plane[color_plane].mapping_stride; in intel_fb_pitch()
1204 return fb->remapped_view.color_plane[color_plane].mapping_stride; in intel_fb_pitch()
1206 return fb->normal_view.color_plane[color_plane].mapping_stride; in intel_fb_pitch()
1211 struct intel_plane *plane = to_intel_plane(plane_state->uapi.plane); in intel_plane_needs_remap()
1212 const struct intel_framebuffer *fb = to_intel_framebuffer(plane_state->hw.fb); in intel_plane_needs_remap()
1213 unsigned int rotation = plane_state->hw.rotation; in intel_plane_needs_remap()
1220 if (!plane_state->uapi.visible) in intel_plane_needs_remap()
1231 max_stride = plane->max_stride(plane, fb->base.format->format, in intel_plane_needs_remap()
1232 fb->base.modifier, rotation); in intel_plane_needs_remap()
1238 int plane_width, int *x, int *y) in convert_plane_offset_to_xy() argument
1240 struct drm_i915_gem_object *obj = intel_fb_obj(&fb->base); in convert_plane_offset_to_xy()
1243 ret = intel_fb_offset_to_xy(x, y, &fb->base, color_plane); in convert_plane_offset_to_xy()
1245 drm_dbg_kms(fb->base.dev, in convert_plane_offset_to_xy()
1246 "bad fb plane %d offset: 0x%x\n", in convert_plane_offset_to_xy()
1247 color_plane, fb->base.offsets[color_plane]); in convert_plane_offset_to_xy()
1251 ret = intel_fb_check_ccs_xy(&fb->base, color_plane, *x, *y); in convert_plane_offset_to_xy()
1259 * the fence start offset within the object (nor could we probably in convert_plane_offset_to_xy()
1265 (*x + plane_width) * fb->base.format->cpp[color_plane] > fb->base.pitches[color_plane]) { in convert_plane_offset_to_xy()
1266 drm_dbg_kms(fb->base.dev, in convert_plane_offset_to_xy()
1267 "bad fb plane %d offset: 0x%x\n", in convert_plane_offset_to_xy()
1268 color_plane, fb->base.offsets[color_plane]); in convert_plane_offset_to_xy()
1269 return -EINVAL; in convert_plane_offset_to_xy()
1275 … u32 calc_plane_aligned_offset(const struct intel_framebuffer *fb, int color_plane, int *x, int *y) in calc_plane_aligned_offset() argument
1277 struct drm_i915_private *i915 = to_i915(fb->base.dev); in calc_plane_aligned_offset()
1279 u32 offset; in calc_plane_aligned_offset() local
1281 offset = intel_compute_aligned_offset(i915, x, y, &fb->base, color_plane, in calc_plane_aligned_offset()
1282 fb->base.pitches[color_plane], in calc_plane_aligned_offset()
1286 return offset / tile_size; in calc_plane_aligned_offset()
1298 dims->width = width; in init_plane_view_dims()
1299 dims->height = height; in init_plane_view_dims()
1301 intel_tile_dims(&fb->base, color_plane, &dims->tile_width, &dims->tile_height); in init_plane_view_dims()
1308 return DIV_ROUND_UP(fb->base.pitches[color_plane], in plane_view_src_stride_tiles()
1309 dims->tile_width * fb->base.format->cpp[color_plane]); in plane_view_src_stride_tiles()
1332 struct drm_i915_private *i915 = to_i915(fb->base.dev); in plane_view_scanout_stride()
1341 return stride_tiles * tile_width * fb->base.format->cpp[color_plane]; in plane_view_scanout_stride()
1349 return DIV_ROUND_UP(x + dims->width, dims->tile_width); in plane_view_width_tiles()
1355 int y) in plane_view_height_tiles() argument
1357 return DIV_ROUND_UP(y + dims->height, dims->tile_height); in plane_view_height_tiles()
1363 int x, int y) in plane_view_linear_tiles() argument
1365 struct drm_i915_private *i915 = to_i915(fb->base.dev); in plane_view_linear_tiles()
1368 size = (y + dims->height) * fb->base.pitches[color_plane] + in plane_view_linear_tiles()
1369 x * fb->base.format->cpp[color_plane]; in plane_view_linear_tiles()
1375 drm_WARN_ON(&(i915)->drm, overflows_type(val, var)); \
1381 drm_WARN_ON(&(i915)->drm, (var) != (val)); \
1387 u32 obj_offset, u32 gtt_offset, int x, int y, in calc_plane_remap_info() argument
1390 struct drm_i915_private *i915 = to_i915(fb->base.dev); in calc_plane_remap_info()
1391 struct intel_remapped_plane_info *remap_info = &view->gtt.remapped.plane[color_plane]; in calc_plane_remap_info()
1392 struct i915_color_plane_view *color_plane_info = &view->color_plane[color_plane]; in calc_plane_remap_info()
1393 unsigned int tile_width = dims->tile_width; in calc_plane_remap_info()
1394 unsigned int tile_height = dims->tile_height; in calc_plane_remap_info()
1399 assign_bfld_chk_ovf(i915, remap_info->offset, obj_offset); in calc_plane_remap_info()
1401 if (intel_fb_is_gen12_ccs_aux_plane(&fb->base, color_plane)) { in calc_plane_remap_info()
1402 remap_info->linear = 1; in calc_plane_remap_info()
1404 assign_chk_ovf(i915, remap_info->size, in calc_plane_remap_info()
1405 plane_view_linear_tiles(fb, color_plane, dims, x, y)); in calc_plane_remap_info()
1407 remap_info->linear = 0; in calc_plane_remap_info()
1409 assign_chk_ovf(i915, remap_info->src_stride, in calc_plane_remap_info()
1411 assign_chk_ovf(i915, remap_info->width, in calc_plane_remap_info()
1413 assign_chk_ovf(i915, remap_info->height, in calc_plane_remap_info()
1414 plane_view_height_tiles(fb, color_plane, dims, y)); in calc_plane_remap_info()
1417 if (view->gtt.type == I915_GTT_VIEW_ROTATED) { in calc_plane_remap_info()
1418 drm_WARN_ON(&i915->drm, remap_info->linear); in calc_plane_remap_info()
1419 check_array_bounds(i915, view->gtt.rotated.plane, color_plane); in calc_plane_remap_info()
1421 assign_chk_ovf(i915, remap_info->dst_stride, in calc_plane_remap_info()
1422 plane_view_dst_stride_tiles(fb, color_plane, remap_info->height)); in calc_plane_remap_info()
1424 /* rotate the x/y offsets to match the GTT view */ in calc_plane_remap_info()
1425 drm_rect_init(&r, x, y, dims->width, dims->height); in calc_plane_remap_info()
1427 remap_info->width * tile_width, in calc_plane_remap_info()
1428 remap_info->height * tile_height, in calc_plane_remap_info()
1431 color_plane_info->x = r.x1; in calc_plane_remap_info()
1432 color_plane_info->y = r.y1; in calc_plane_remap_info()
1434 color_plane_info->mapping_stride = remap_info->dst_stride * tile_height; in calc_plane_remap_info()
1435 color_plane_info->scanout_stride = color_plane_info->mapping_stride; in calc_plane_remap_info()
1437 size += remap_info->dst_stride * remap_info->width; in calc_plane_remap_info()
1442 drm_WARN_ON(&i915->drm, view->gtt.type != I915_GTT_VIEW_REMAPPED); in calc_plane_remap_info()
1444 check_array_bounds(i915, view->gtt.remapped.plane, color_plane); in calc_plane_remap_info()
1446 if (view->gtt.remapped.plane_alignment) { in calc_plane_remap_info()
1448 view->gtt.remapped.plane_alignment); in calc_plane_remap_info()
1450 size += aligned_offset - gtt_offset; in calc_plane_remap_info()
1454 color_plane_info->x = x; in calc_plane_remap_info()
1455 color_plane_info->y = y; in calc_plane_remap_info()
1457 if (remap_info->linear) { in calc_plane_remap_info()
1458 color_plane_info->mapping_stride = fb->base.pitches[color_plane]; in calc_plane_remap_info()
1459 color_plane_info->scanout_stride = color_plane_info->mapping_stride; in calc_plane_remap_info()
1461 size += remap_info->size; in calc_plane_remap_info()
1471 intel_fb_is_ccs_modifier(fb->base.modifier)) in calc_plane_remap_info()
1472 dst_stride = remap_info->src_stride; in calc_plane_remap_info()
1474 dst_stride = remap_info->width; in calc_plane_remap_info()
1478 assign_chk_ovf(i915, remap_info->dst_stride, dst_stride); in calc_plane_remap_info()
1479 color_plane_info->mapping_stride = dst_stride * in calc_plane_remap_info()
1481 fb->base.format->cpp[color_plane]; in calc_plane_remap_info()
1482 color_plane_info->scanout_stride = in calc_plane_remap_info()
1484 remap_info->src_stride, in calc_plane_remap_info()
1487 size += dst_stride * remap_info->height; in calc_plane_remap_info()
1492 * We only keep the x/y offsets, so push all of the gtt offset into in calc_plane_remap_info()
1493 * the x/y offsets. x,y will hold the first pixel of the framebuffer in calc_plane_remap_info()
1496 if (remap_info->linear) in calc_plane_remap_info()
1497 intel_adjust_linear_offset(&color_plane_info->x, &color_plane_info->y, in calc_plane_remap_info()
1498 fb->base.format->cpp[color_plane], in calc_plane_remap_info()
1499 color_plane_info->mapping_stride, in calc_plane_remap_info()
1502 intel_adjust_tile_offset(&color_plane_info->x, &color_plane_info->y, in calc_plane_remap_info()
1504 tile_size, remap_info->dst_stride, in calc_plane_remap_info()
1516 int x, int y) in calc_plane_normal_size() argument
1520 if (is_surface_linear(&fb->base, color_plane)) { in calc_plane_normal_size()
1521 tiles = plane_view_linear_tiles(fb, color_plane, dims, x, y); in calc_plane_normal_size()
1524 plane_view_height_tiles(fb, color_plane, dims, y); in calc_plane_normal_size()
1540 view->gtt.type = view_type; in intel_fb_view_init()
1544 view->gtt.remapped.plane_alignment = SZ_2M / PAGE_SIZE; in intel_fb_view_init()
1549 if (DISPLAY_VER(to_i915(fb->base.dev)) >= 13) in intel_fb_supports_90_270_rotation()
1552 return fb->base.modifier == I915_FORMAT_MOD_Y_TILED || in intel_fb_supports_90_270_rotation()
1553 fb->base.modifier == I915_FORMAT_MOD_Yf_TILED; in intel_fb_supports_90_270_rotation()
1558 struct drm_i915_private *i915 = to_i915(fb->dev); in intel_fb_min_alignment()
1562 for_each_intel_plane(&i915->drm, plane) { in intel_fb_min_alignment()
1565 if (!drm_plane_has_format(&plane->base, fb->format->format, fb->modifier)) in intel_fb_min_alignment()
1568 plane_min_alignment = plane->min_alignment(plane, fb, 0); in intel_fb_min_alignment()
1570 drm_WARN_ON(&i915->drm, plane_min_alignment && in intel_fb_min_alignment()
1584 struct drm_i915_gem_object *obj = intel_fb_obj(&fb->base); in intel_fill_fb_info()
1588 int i, num_planes = fb->base.format->num_planes; in intel_fill_fb_info()
1591 intel_fb_view_init(i915, &fb->normal_view, I915_GTT_VIEW_NORMAL); in intel_fill_fb_info()
1593 drm_WARN_ON(&i915->drm, in intel_fill_fb_info()
1598 intel_fb_view_init(i915, &fb->rotated_view, I915_GTT_VIEW_ROTATED); in intel_fill_fb_info()
1600 intel_fb_view_init(i915, &fb->remapped_view, I915_GTT_VIEW_REMAPPED); in intel_fill_fb_info()
1606 u32 offset; in intel_fill_fb_info() local
1607 int x, y; in intel_fill_fb_info() local
1613 * arithmetic related to alignment and offset calculation. in intel_fill_fb_info()
1615 if (is_gen12_ccs_cc_plane(&fb->base, i)) { in intel_fill_fb_info()
1616 if (IS_ALIGNED(fb->base.offsets[i], PAGE_SIZE)) in intel_fill_fb_info()
1619 return -EINVAL; in intel_fill_fb_info()
1624 ret = convert_plane_offset_to_xy(fb, i, width, &x, &y); in intel_fill_fb_info()
1634 fb->normal_view.color_plane[i].x = x; in intel_fill_fb_info()
1635 fb->normal_view.color_plane[i].y = y; in intel_fill_fb_info()
1636 fb->normal_view.color_plane[i].mapping_stride = fb->base.pitches[i]; in intel_fill_fb_info()
1637 fb->normal_view.color_plane[i].scanout_stride = in intel_fill_fb_info()
1638 fb->normal_view.color_plane[i].mapping_stride; in intel_fill_fb_info()
1640 offset = calc_plane_aligned_offset(fb, i, &x, &y); in intel_fill_fb_info()
1644 offset, gtt_offset_rotated, x, y, in intel_fill_fb_info()
1645 &fb->rotated_view); in intel_fill_fb_info()
1649 offset, gtt_offset_remapped, x, y, in intel_fill_fb_info()
1650 &fb->remapped_view); in intel_fill_fb_info()
1652 size = calc_plane_normal_size(fb, i, &view_dims, x, y); in intel_fill_fb_info()
1654 max_size = max(max_size, offset + size); in intel_fill_fb_info()
1657 if (mul_u32_u32(max_size, tile_size) > intel_bo_to_drm_bo(obj)->size) { in intel_fill_fb_info()
1658 drm_dbg_kms(&i915->drm, in intel_fill_fb_info()
1660 mul_u32_u32(max_size, tile_size), intel_bo_to_drm_bo(obj)->size); in intel_fill_fb_info()
1661 return -EINVAL; in intel_fill_fb_info()
1664 fb->min_alignment = intel_fb_min_alignment(&fb->base); in intel_fill_fb_info()
1672 to_i915(plane_state->uapi.plane->dev); in intel_plane_remap_gtt()
1673 struct drm_framebuffer *fb = plane_state->hw.fb; in intel_plane_remap_gtt()
1675 unsigned int rotation = plane_state->hw.rotation; in intel_plane_remap_gtt()
1676 int i, num_planes = fb->format->num_planes; in intel_plane_remap_gtt()
1681 intel_fb_view_init(i915, &plane_state->view, in intel_plane_remap_gtt()
1685 src_x = plane_state->uapi.src.x1 >> 16; in intel_plane_remap_gtt()
1686 src_y = plane_state->uapi.src.y1 >> 16; in intel_plane_remap_gtt()
1687 src_w = drm_rect_width(&plane_state->uapi.src) >> 16; in intel_plane_remap_gtt()
1688 src_h = drm_rect_height(&plane_state->uapi.src) >> 16; in intel_plane_remap_gtt()
1690 drm_WARN_ON(&i915->drm, intel_fb_is_ccs_modifier(fb->modifier)); in intel_plane_remap_gtt()
1693 drm_rect_translate(&plane_state->uapi.src, in intel_plane_remap_gtt()
1694 -(src_x << 16), -(src_y << 16)); in intel_plane_remap_gtt()
1698 drm_rect_rotate(&plane_state->uapi.src, in intel_plane_remap_gtt()
1703 unsigned int hsub = i ? fb->format->hsub : 1; in intel_plane_remap_gtt()
1704 unsigned int vsub = i ? fb->format->vsub : 1; in intel_plane_remap_gtt()
1707 unsigned int x, y; in intel_plane_remap_gtt() local
1708 u32 offset; in intel_plane_remap_gtt() local
1711 y = src_y / vsub; in intel_plane_remap_gtt()
1721 x += intel_fb->normal_view.color_plane[i].x; in intel_plane_remap_gtt()
1722 y += intel_fb->normal_view.color_plane[i].y; in intel_plane_remap_gtt()
1724 offset = calc_plane_aligned_offset(intel_fb, i, &x, &y); in intel_plane_remap_gtt()
1727 offset, gtt_offset, x, y, in intel_plane_remap_gtt()
1728 &plane_state->view); in intel_plane_remap_gtt()
1736 *view = fb->rotated_view; in intel_fb_fill_view()
1738 *view = fb->remapped_view; in intel_fb_fill_view()
1740 *view = fb->normal_view; in intel_fb_fill_view()
1765 struct drm_i915_private *dev_priv = to_i915(fb->dev); in intel_fb_stride_alignment()
1770 fb->format->format, in intel_fb_stride_alignment()
1771 fb->modifier); in intel_fb_stride_alignment()
1777 if (fb->pitches[color_plane] > max_stride && in intel_fb_stride_alignment()
1778 !intel_fb_is_ccs_modifier(fb->modifier)) in intel_fb_stride_alignment()
1785 if (intel_fb_is_ccs_modifier(fb->modifier)) { in intel_fb_stride_alignment()
1802 color_plane == 0 && fb->width > 3840) in intel_fb_stride_alignment()
1810 struct intel_plane *plane = to_intel_plane(plane_state->uapi.plane); in intel_plane_check_stride()
1811 const struct drm_framebuffer *fb = plane_state->hw.fb; in intel_plane_check_stride()
1812 unsigned int rotation = plane_state->hw.rotation; in intel_plane_check_stride()
1822 !plane_state->uapi.visible) in intel_plane_check_stride()
1826 stride = plane_state->view.color_plane[0].mapping_stride; in intel_plane_check_stride()
1827 max_stride = plane->max_stride(plane, fb->format->format, in intel_plane_check_stride()
1828 fb->modifier, rotation); in intel_plane_check_stride()
1831 drm_dbg_kms(plane->base.dev, in intel_plane_check_stride()
1833 fb->base.id, stride, in intel_plane_check_stride()
1834 plane->base.base.id, plane->base.name, max_stride); in intel_plane_check_stride()
1835 return -EINVAL; in intel_plane_check_stride()
1844 to_intel_framebuffer(plane_state->hw.fb); in intel_plane_compute_gtt()
1845 unsigned int rotation = plane_state->hw.rotation; in intel_plane_compute_gtt()
1862 intel_fb_fill_view(fb, rotation, &plane_state->view); in intel_plane_compute_gtt()
1866 drm_rect_rotate(&plane_state->uapi.src, in intel_plane_compute_gtt()
1867 fb->base.width << 16, fb->base.height << 16, in intel_plane_compute_gtt()
1880 intel_dpt_destroy(intel_fb->dpt_vm); in intel_user_framebuffer_destroy()
1882 intel_frontbuffer_put(intel_fb->frontbuffer); in intel_user_framebuffer_destroy()
1894 struct drm_i915_private *i915 = to_i915(intel_bo_to_drm_bo(obj)->dev); in intel_user_framebuffer_create_handle()
1897 drm_dbg(&i915->drm, in intel_user_framebuffer_create_handle()
1899 return -EINVAL; in intel_user_framebuffer_create_handle()
1915 intel_frontbuffer_queue_flush(cb->front); in intel_user_framebuffer_fence_wake()
1932 if (!atomic_read(&front->bits)) in intel_user_framebuffer_dirty()
1935 if (dma_resv_test_signaled(intel_bo_to_drm_bo(obj)->resv, dma_resv_usage_rw(false))) in intel_user_framebuffer_dirty()
1938 ret = dma_resv_get_singleton(intel_bo_to_drm_bo(obj)->resv, dma_resv_usage_rw(false), in intel_user_framebuffer_dirty()
1946 ret = -ENOMEM; in intel_user_framebuffer_dirty()
1950 cb->front = front; in intel_user_framebuffer_dirty()
1954 ret = dma_fence_add_callback(fence, &cb->base, in intel_user_framebuffer_dirty()
1957 intel_user_framebuffer_fence_wake(fence, &cb->base); in intel_user_framebuffer_dirty()
1958 if (ret == -ENOENT) in intel_user_framebuffer_dirty()
1980 struct drm_i915_private *dev_priv = to_i915(intel_bo_to_drm_bo(obj)->dev); in intel_framebuffer_init()
1981 struct drm_framebuffer *fb = &intel_fb->base; in intel_framebuffer_init()
1983 int ret = -EINVAL; in intel_framebuffer_init()
1990 intel_fb->frontbuffer = intel_frontbuffer_get(obj); in intel_framebuffer_init()
1991 if (!intel_fb->frontbuffer) { in intel_framebuffer_init()
1992 ret = -ENOMEM; in intel_framebuffer_init()
1996 ret = -EINVAL; in intel_framebuffer_init()
1997 if (!drm_any_plane_has_format(&dev_priv->drm, in intel_framebuffer_init()
1998 mode_cmd->pixel_format, in intel_framebuffer_init()
1999 mode_cmd->modifier[0])) { in intel_framebuffer_init()
2000 drm_dbg_kms(&dev_priv->drm, in intel_framebuffer_init()
2002 &mode_cmd->pixel_format, mode_cmd->modifier[0]); in intel_framebuffer_init()
2006 max_stride = intel_fb_max_stride(dev_priv, mode_cmd->pixel_format, in intel_framebuffer_init()
2007 mode_cmd->modifier[0]); in intel_framebuffer_init()
2008 if (mode_cmd->pitches[0] > max_stride) { in intel_framebuffer_init()
2009 drm_dbg_kms(&dev_priv->drm, in intel_framebuffer_init()
2011 mode_cmd->modifier[0] != DRM_FORMAT_MOD_LINEAR ? in intel_framebuffer_init()
2013 mode_cmd->pitches[0], max_stride); in intel_framebuffer_init()
2018 if (mode_cmd->offsets[0] != 0) { in intel_framebuffer_init()
2019 drm_dbg_kms(&dev_priv->drm, in intel_framebuffer_init()
2020 "plane 0 offset (0x%08x) must be 0\n", in intel_framebuffer_init()
2021 mode_cmd->offsets[0]); in intel_framebuffer_init()
2025 drm_helper_mode_fill_fb_struct(&dev_priv->drm, fb, mode_cmd); in intel_framebuffer_init()
2027 for (i = 0; i < fb->format->num_planes; i++) { in intel_framebuffer_init()
2030 if (mode_cmd->handles[i] != mode_cmd->handles[0]) { in intel_framebuffer_init()
2031 drm_dbg_kms(&dev_priv->drm, "bad plane %d handle\n", in intel_framebuffer_init()
2037 if (fb->pitches[i] & (stride_alignment - 1)) { in intel_framebuffer_init()
2038 drm_dbg_kms(&dev_priv->drm, in intel_framebuffer_init()
2040 i, fb->pitches[i], stride_alignment); in intel_framebuffer_init()
2047 if (fb->pitches[i] != ccs_aux_stride) { in intel_framebuffer_init()
2048 drm_dbg_kms(&dev_priv->drm, in intel_framebuffer_init()
2051 fb->pitches[i], ccs_aux_stride); in intel_framebuffer_init()
2056 fb->obj[i] = intel_bo_to_drm_bo(obj); in intel_framebuffer_init()
2068 drm_dbg_kms(&dev_priv->drm, "failed to create DPT\n"); in intel_framebuffer_init()
2073 intel_fb->dpt_vm = vm; in intel_framebuffer_init()
2076 ret = drm_framebuffer_init(&dev_priv->drm, fb, &intel_fb_funcs); in intel_framebuffer_init()
2078 drm_err(&dev_priv->drm, "framebuffer init failed %d\n", ret); in intel_framebuffer_init()
2086 intel_dpt_destroy(intel_fb->dpt_vm); in intel_framebuffer_init()
2088 intel_frontbuffer_put(intel_fb->frontbuffer); in intel_framebuffer_init()
2123 return ERR_PTR(-ENOMEM); in intel_framebuffer_create()
2129 return &intel_fb->base; in intel_framebuffer_create()