Lines Matching +full:y +full:- +full:offset
1 // SPDX-License-Identifier: MIT
16 #define check_array_bounds(i915, a, i) drm_WARN_ON(&(i915)->drm, (i) >= ARRAY_SIZE(a))
21 * the cache-line pairs. The compression state of the cache-line pair
22 * is specified by 2 bits in the CCS. Each CCS cache-line represents
23 * an area on the main surface of 16 x16 sets of 128 byte Y-tiled
24 * cache-line-pairs. CCS is always Y tiled."
44 * Gen-12 compression uses 4 bits of CCS data for each cache line pair in the
45 * main surface. And each 64B CCS cache line represents an area of 4x1 Y-tiles
46 * in the main surface. With 4 byte pixels and each Y-tile having dimensions of
132 #define DISPLAY_VER_ALL { 0, -1 }
203 .display_ver = { 13, -1 },
305 * Returns the format information for @cmd->pixel_format specific to @cmd->modifier[0],
311 const struct intel_modifier_desc *md = lookup_modifier_or_null(cmd->modifier[0]); in intel_fb_get_format_info()
313 if (!md || !md->formats) in intel_fb_get_format_info()
316 return lookup_format_info(md->formats, md->format_count, cmd->pixel_format); in intel_fb_get_format_info()
338 return plane_caps_contain_any(lookup_modifier(modifier)->plane_caps, in intel_fb_is_tiled_modifier()
352 return plane_caps_contain_any(lookup_modifier(modifier)->plane_caps, in intel_fb_is_ccs_modifier()
365 return plane_caps_contain_any(lookup_modifier(modifier)->plane_caps, in intel_fb_is_rc_ccs_cc_modifier()
378 return plane_caps_contain_any(lookup_modifier(modifier)->plane_caps, in intel_fb_is_mc_ccs_modifier()
385 return md->display_ver.from <= display_ver_until && in check_modifier_display_ver_range()
386 display_ver_from <= md->display_ver.until; in check_modifier_display_ver_range()
393 if (!IS_DISPLAY_VER(i915, md->display_ver.from, md->display_ver.until)) in plane_has_modifier()
396 if (!plane_caps_contain_all(plane_caps, md->plane_caps)) in plane_has_modifier()
403 if (intel_fb_is_ccs_modifier(md->modifier) && in plane_has_modifier()
404 HAS_FLAT_CCS(i915) != !md->ccs.packed_aux_planes) in plane_has_modifier()
432 if (drm_WARN_ON(&i915->drm, !list)) in intel_fb_plane_get_modifiers()
457 for (i = 0; i < plane->base.modifier_count; i++) in intel_fb_plane_supports_modifier()
458 if (plane->base.modifiers[i] == modifier) in intel_fb_plane_supports_modifier()
467 if (!info->is_yuv) in format_is_yuv_semiplanar()
470 if (hweight8(md->ccs.planar_aux_planes) == 2) in format_is_yuv_semiplanar()
471 return info->num_planes == 4; in format_is_yuv_semiplanar()
473 return info->num_planes == 2; in format_is_yuv_semiplanar()
494 return md->ccs.planar_aux_planes; in ccs_aux_plane_mask()
496 return md->ccs.packed_aux_planes; in ccs_aux_plane_mask()
509 const struct intel_modifier_desc *md = lookup_modifier(fb->modifier); in intel_fb_is_ccs_aux_plane()
511 return ccs_aux_plane_mask(md, fb->format) & BIT(color_plane); in intel_fb_is_ccs_aux_plane()
524 const struct intel_modifier_desc *md = lookup_modifier(fb->modifier); in intel_fb_is_gen12_ccs_aux_plane()
527 ccs_aux_plane_mask(md, fb->format) & BIT(color_plane); in intel_fb_is_gen12_ccs_aux_plane()
535 * Returns the index of the color clear plane for @fb, or -1 if @fb is not a
540 const struct intel_modifier_desc *md = lookup_modifier(fb->modifier); in intel_fb_rc_ccs_cc_plane()
542 if (!md->ccs.cc_planes) in intel_fb_rc_ccs_cc_plane()
543 return -1; in intel_fb_rc_ccs_cc_plane()
545 drm_WARN_ON_ONCE(fb->dev, hweight8(md->ccs.cc_planes) > 1); in intel_fb_rc_ccs_cc_plane()
547 return ilog2((int)md->ccs.cc_planes); in intel_fb_rc_ccs_cc_plane()
557 return intel_format_info_is_yuv_semiplanar(fb->format, fb->modifier) && in is_semiplanar_uv_plane()
563 return fb->modifier == DRM_FORMAT_MOD_LINEAR || in is_surface_linear()
570 drm_WARN_ON(fb->dev, !intel_fb_is_ccs_modifier(fb->modifier) || in main_to_ccs_plane()
571 (main_plane && main_plane >= fb->format->num_planes / 2)); in main_to_ccs_plane()
573 return fb->format->num_planes / 2 + main_plane; in main_to_ccs_plane()
578 drm_WARN_ON(fb->dev, !intel_fb_is_ccs_modifier(fb->modifier) || in skl_ccs_to_main_plane()
579 ccs_plane < fb->format->num_planes / 2); in skl_ccs_to_main_plane()
584 return ccs_plane - fb->format->num_planes / 2; in skl_ccs_to_main_plane()
589 int main_plane = skl_ccs_to_main_plane(&fb->base, ccs_plane); in gen12_ccs_aux_stride()
590 unsigned int main_stride = fb->base.pitches[main_plane]; in gen12_ccs_aux_stride()
591 unsigned int main_tile_width = intel_tile_width_bytes(&fb->base, main_plane); in gen12_ccs_aux_stride()
598 const struct intel_modifier_desc *md = lookup_modifier(fb->modifier); in skl_main_to_aux_plane()
599 struct drm_i915_private *i915 = to_i915(fb->dev); in skl_main_to_aux_plane()
601 if (md->ccs.packed_aux_planes | md->ccs.planar_aux_planes) in skl_main_to_aux_plane()
604 format_is_yuv_semiplanar(md, fb->format)) in skl_main_to_aux_plane()
618 struct drm_i915_private *dev_priv = to_i915(fb->dev); in intel_tile_width_bytes()
619 unsigned int cpp = fb->format->cpp[color_plane]; in intel_tile_width_bytes()
621 switch (fb->modifier) { in intel_tile_width_bytes()
635 * same shape as Y Tile(i.e 4*16B OWords) in intel_tile_width_bytes()
677 MISSING_CASE(fb->modifier); in intel_tile_width_bytes()
684 return intel_tile_size(to_i915(fb->dev)) / in intel_tile_height()
697 unsigned int cpp = fb->format->cpp[color_plane]; in intel_tile_dims()
724 return fb->pitches[color_plane] * tile_height; in intel_tile_row_size()
738 u8 tiling_caps = lookup_modifier(fb_modifier)->plane_caps & in intel_fb_modifier_to_tiling()
763 return fb && to_i915(fb->dev)->params.enable_dpt && in intel_fb_uses_dpt()
764 intel_fb_modifier_uses_dpt(to_i915(fb->dev), fb->modifier); in intel_fb_uses_dpt()
795 struct drm_i915_private *dev_priv = to_i915(fb->dev); in intel_surf_alignment()
806 * TODO: cross-check wrt. the bspec stride in bytes * 64 bytes in intel_surf_alignment()
810 if (fb->modifier == DRM_FORMAT_MOD_LINEAR) in intel_surf_alignment()
819 drm_WARN_ON(&dev_priv->drm, color_plane != 0); in intel_surf_alignment()
821 switch (fb->modifier) { in intel_surf_alignment()
846 MISSING_CASE(fb->modifier); in intel_surf_alignment()
869 *hsub = fb->format->hsub; in intel_fb_plane_get_subsampling()
870 *vsub = fb->format->vsub; in intel_fb_plane_get_subsampling()
876 *hsub = drm_format_info_block_width(fb->format, color_plane) / in intel_fb_plane_get_subsampling()
877 drm_format_info_block_width(fb->format, main_plane); in intel_fb_plane_get_subsampling()
881 * assumes that format->hsub applies to every plane except for the in intel_fb_plane_get_subsampling()
888 *hsub *= fb->format->hsub; in intel_fb_plane_get_subsampling()
895 int main_plane = intel_fb_is_ccs_aux_plane(&fb->base, color_plane) ? in intel_fb_plane_dims()
896 skl_ccs_to_main_plane(&fb->base, color_plane) : 0; in intel_fb_plane_dims()
897 unsigned int main_width = fb->base.width; in intel_fb_plane_dims()
898 unsigned int main_height = fb->base.height; in intel_fb_plane_dims()
902 intel_fb_plane_get_subsampling(&main_hsub, &main_vsub, &fb->base, main_plane); in intel_fb_plane_dims()
903 intel_fb_plane_get_subsampling(&hsub, &vsub, &fb->base, color_plane); in intel_fb_plane_dims()
909 static u32 intel_adjust_tile_offset(int *x, int *y, in intel_adjust_tile_offset() argument
920 WARN_ON(old_offset & (tile_size - 1)); in intel_adjust_tile_offset()
921 WARN_ON(new_offset & (tile_size - 1)); in intel_adjust_tile_offset()
924 tiles = (old_offset - new_offset) / tile_size; in intel_adjust_tile_offset()
926 *y += tiles / pitch_tiles * tile_height; in intel_adjust_tile_offset()
930 *y += *x / pitch_pixels * tile_height; in intel_adjust_tile_offset()
936 static u32 intel_adjust_linear_offset(int *x, int *y, in intel_adjust_linear_offset() argument
942 old_offset += *y * pitch + *x * cpp; in intel_adjust_linear_offset()
944 *y = (old_offset - new_offset) / pitch; in intel_adjust_linear_offset()
945 *x = ((old_offset - new_offset) - *y * pitch) / cpp; in intel_adjust_linear_offset()
950 static u32 intel_adjust_aligned_offset(int *x, int *y, in intel_adjust_aligned_offset() argument
957 struct drm_i915_private *i915 = to_i915(fb->dev); in intel_adjust_aligned_offset()
958 unsigned int cpp = fb->format->cpp[color_plane]; in intel_adjust_aligned_offset()
960 drm_WARN_ON(&i915->drm, new_offset > old_offset); in intel_adjust_aligned_offset()
976 intel_adjust_tile_offset(x, y, tile_width, tile_height, in intel_adjust_aligned_offset()
980 intel_adjust_linear_offset(x, y, cpp, pitch, in intel_adjust_aligned_offset()
988 * Adjust the tile offset by moving the difference into
989 * the x/y offsets.
991 u32 intel_plane_adjust_aligned_offset(int *x, int *y, in intel_plane_adjust_aligned_offset() argument
996 return intel_adjust_aligned_offset(x, y, state->hw.fb, color_plane, in intel_plane_adjust_aligned_offset()
997 state->hw.rotation, in intel_plane_adjust_aligned_offset()
998 state->view.color_plane[color_plane].mapping_stride, in intel_plane_adjust_aligned_offset()
1003 * Computes the aligned offset to the base tile and adjusts
1004 * x, y. bytes per pixel is assumed to be a power-of-two.
1006 * In the 90/270 rotated case, x and y are assumed
1017 int *x, int *y, in intel_compute_aligned_offset() argument
1024 unsigned int cpp = fb->format->cpp[color_plane]; in intel_compute_aligned_offset()
1025 u32 offset, offset_aligned; in intel_compute_aligned_offset() local
1041 tile_rows = *y / tile_height; in intel_compute_aligned_offset()
1042 *y %= tile_height; in intel_compute_aligned_offset()
1047 offset = (tile_rows * pitch_tiles + tiles) * tile_size; in intel_compute_aligned_offset()
1049 offset_aligned = offset; in intel_compute_aligned_offset()
1053 intel_adjust_tile_offset(x, y, tile_width, tile_height, in intel_compute_aligned_offset()
1055 offset, offset_aligned); in intel_compute_aligned_offset()
1057 offset = *y * pitch + *x * cpp; in intel_compute_aligned_offset()
1058 offset_aligned = offset; in intel_compute_aligned_offset()
1061 *y = (offset % alignment) / pitch; in intel_compute_aligned_offset()
1062 *x = ((offset % alignment) - *y * pitch) / cpp; in intel_compute_aligned_offset()
1064 *y = *x = 0; in intel_compute_aligned_offset()
1071 u32 intel_plane_compute_aligned_offset(int *x, int *y, in intel_plane_compute_aligned_offset() argument
1075 struct intel_plane *intel_plane = to_intel_plane(state->uapi.plane); in intel_plane_compute_aligned_offset()
1076 struct drm_i915_private *i915 = to_i915(intel_plane->base.dev); in intel_plane_compute_aligned_offset()
1077 const struct drm_framebuffer *fb = state->hw.fb; in intel_plane_compute_aligned_offset()
1078 unsigned int rotation = state->hw.rotation; in intel_plane_compute_aligned_offset()
1079 int pitch = state->view.color_plane[color_plane].mapping_stride; in intel_plane_compute_aligned_offset()
1082 if (intel_plane->id == PLANE_CURSOR) in intel_plane_compute_aligned_offset()
1087 return intel_compute_aligned_offset(i915, x, y, fb, color_plane, in intel_plane_compute_aligned_offset()
1091 /* Convert the fb->offset[] into x/y offsets */
1092 static int intel_fb_offset_to_xy(int *x, int *y, in intel_fb_offset_to_xy() argument
1096 struct drm_i915_private *i915 = to_i915(fb->dev); in intel_fb_offset_to_xy()
1104 else if (fb->modifier != DRM_FORMAT_MOD_LINEAR) in intel_fb_offset_to_xy()
1109 if (alignment != 0 && fb->offsets[color_plane] % alignment) { in intel_fb_offset_to_xy()
1110 drm_dbg_kms(&i915->drm, in intel_fb_offset_to_xy()
1111 "Misaligned offset 0x%08x for color plane %d\n", in intel_fb_offset_to_xy()
1112 fb->offsets[color_plane], color_plane); in intel_fb_offset_to_xy()
1113 return -EINVAL; in intel_fb_offset_to_xy()
1116 height = drm_framebuffer_plane_height(fb->height, fb, color_plane); in intel_fb_offset_to_xy()
1120 if (add_overflows_t(u32, mul_u32_u32(height, fb->pitches[color_plane]), in intel_fb_offset_to_xy()
1121 fb->offsets[color_plane])) { in intel_fb_offset_to_xy()
1122 drm_dbg_kms(&i915->drm, in intel_fb_offset_to_xy()
1123 "Bad offset 0x%08x or pitch %d for color plane %d\n", in intel_fb_offset_to_xy()
1124 fb->offsets[color_plane], fb->pitches[color_plane], in intel_fb_offset_to_xy()
1126 return -ERANGE; in intel_fb_offset_to_xy()
1130 *y = 0; in intel_fb_offset_to_xy()
1132 intel_adjust_aligned_offset(x, y, in intel_fb_offset_to_xy()
1134 fb->pitches[color_plane], in intel_fb_offset_to_xy()
1135 fb->offsets[color_plane], 0); in intel_fb_offset_to_xy()
1140 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
1142 struct drm_i915_private *i915 = to_i915(fb->dev); in intel_fb_check_ccs_xy()
1165 ccs_y = (y * vsub) % tile_height; in intel_fb_check_ccs_xy()
1168 main_x = intel_fb->normal_view.color_plane[main_plane].x % tile_width; in intel_fb_check_ccs_xy()
1169 main_y = intel_fb->normal_view.color_plane[main_plane].y % tile_height; in intel_fb_check_ccs_xy()
1172 * CCS doesn't have its own x/y offset register, so the intra CCS tile in intel_fb_check_ccs_xy()
1173 * x/y offsets must match between CCS and the main surface. in intel_fb_check_ccs_xy()
1176 drm_dbg_kms(&i915->drm, in intel_fb_check_ccs_xy()
1177 "Bad CCS x/y (main %d,%d ccs %d,%d) full (main %d,%d ccs %d,%d)\n", in intel_fb_check_ccs_xy()
1180 intel_fb->normal_view.color_plane[main_plane].x, in intel_fb_check_ccs_xy()
1181 intel_fb->normal_view.color_plane[main_plane].y, in intel_fb_check_ccs_xy()
1182 x, y); in intel_fb_check_ccs_xy()
1183 return -EINVAL; in intel_fb_check_ccs_xy()
1191 struct intel_plane *plane = to_intel_plane(plane_state->uapi.plane); in intel_plane_can_remap()
1192 struct drm_i915_private *i915 = to_i915(plane->base.dev); in intel_plane_can_remap()
1193 const struct drm_framebuffer *fb = plane_state->hw.fb; in intel_plane_can_remap()
1197 if (plane->id == PLANE_CURSOR) in intel_plane_can_remap()
1213 if (intel_fb_is_ccs_modifier(fb->modifier)) in intel_plane_can_remap()
1217 if (fb->modifier == DRM_FORMAT_MOD_LINEAR) { in intel_plane_can_remap()
1218 unsigned int alignment = intel_tile_size(i915) - 1; in intel_plane_can_remap()
1220 for (i = 0; i < fb->format->num_planes; i++) { in intel_plane_can_remap()
1221 if (fb->pitches[i] & alignment) in intel_plane_can_remap()
1231 struct drm_i915_private *i915 = to_i915(fb->base.dev); in intel_fb_needs_pot_stride_remap()
1234 intel_fb_uses_dpt(&fb->base); in intel_fb_needs_pot_stride_remap()
1240 return fb->rotated_view.color_plane[color_plane].mapping_stride; in intel_fb_pitch()
1242 return fb->remapped_view.color_plane[color_plane].mapping_stride; in intel_fb_pitch()
1244 return fb->normal_view.color_plane[color_plane].mapping_stride; in intel_fb_pitch()
1249 struct intel_plane *plane = to_intel_plane(plane_state->uapi.plane); in intel_plane_needs_remap()
1250 const struct intel_framebuffer *fb = to_intel_framebuffer(plane_state->hw.fb); in intel_plane_needs_remap()
1251 unsigned int rotation = plane_state->hw.rotation; in intel_plane_needs_remap()
1258 if (!plane_state->uapi.visible) in intel_plane_needs_remap()
1269 max_stride = plane->max_stride(plane, fb->base.format->format, in intel_plane_needs_remap()
1270 fb->base.modifier, rotation); in intel_plane_needs_remap()
1276 int plane_width, int *x, int *y) in convert_plane_offset_to_xy() argument
1278 struct drm_i915_gem_object *obj = intel_fb_obj(&fb->base); in convert_plane_offset_to_xy()
1281 ret = intel_fb_offset_to_xy(x, y, &fb->base, color_plane); in convert_plane_offset_to_xy()
1283 drm_dbg_kms(fb->base.dev, in convert_plane_offset_to_xy()
1284 "bad fb plane %d offset: 0x%x\n", in convert_plane_offset_to_xy()
1285 color_plane, fb->base.offsets[color_plane]); in convert_plane_offset_to_xy()
1289 ret = intel_fb_check_ccs_xy(&fb->base, color_plane, *x, *y); in convert_plane_offset_to_xy()
1297 * the fence start offset within the object (nor could we probably in convert_plane_offset_to_xy()
1303 (*x + plane_width) * fb->base.format->cpp[color_plane] > fb->base.pitches[color_plane]) { in convert_plane_offset_to_xy()
1304 drm_dbg_kms(fb->base.dev, in convert_plane_offset_to_xy()
1305 "bad fb plane %d offset: 0x%x\n", in convert_plane_offset_to_xy()
1306 color_plane, fb->base.offsets[color_plane]); in convert_plane_offset_to_xy()
1307 return -EINVAL; in convert_plane_offset_to_xy()
1313 … u32 calc_plane_aligned_offset(const struct intel_framebuffer *fb, int color_plane, int *x, int *y) in calc_plane_aligned_offset() argument
1315 struct drm_i915_private *i915 = to_i915(fb->base.dev); in calc_plane_aligned_offset()
1317 u32 offset; in calc_plane_aligned_offset() local
1319 offset = intel_compute_aligned_offset(i915, x, y, &fb->base, color_plane, in calc_plane_aligned_offset()
1320 fb->base.pitches[color_plane], in calc_plane_aligned_offset()
1324 return offset / tile_size; in calc_plane_aligned_offset()
1336 dims->width = width; in init_plane_view_dims()
1337 dims->height = height; in init_plane_view_dims()
1339 intel_tile_dims(&fb->base, color_plane, &dims->tile_width, &dims->tile_height); in init_plane_view_dims()
1346 return DIV_ROUND_UP(fb->base.pitches[color_plane], in plane_view_src_stride_tiles()
1347 dims->tile_width * fb->base.format->cpp[color_plane]); in plane_view_src_stride_tiles()
1370 struct drm_i915_private *i915 = to_i915(fb->base.dev); in plane_view_scanout_stride()
1378 return stride_tiles * tile_width * fb->base.format->cpp[color_plane]; in plane_view_scanout_stride()
1386 return DIV_ROUND_UP(x + dims->width, dims->tile_width); in plane_view_width_tiles()
1392 int y) in plane_view_height_tiles() argument
1394 return DIV_ROUND_UP(y + dims->height, dims->tile_height); in plane_view_height_tiles()
1400 int x, int y) in plane_view_linear_tiles() argument
1402 struct drm_i915_private *i915 = to_i915(fb->base.dev); in plane_view_linear_tiles()
1405 size = (y + dims->height) * fb->base.pitches[color_plane] + in plane_view_linear_tiles()
1406 x * fb->base.format->cpp[color_plane]; in plane_view_linear_tiles()
1412 drm_WARN_ON(&(i915)->drm, overflows_type(val, var)); \
1418 drm_WARN_ON(&(i915)->drm, (var) != (val)); \
1424 u32 obj_offset, u32 gtt_offset, int x, int y, in calc_plane_remap_info() argument
1427 struct drm_i915_private *i915 = to_i915(fb->base.dev); in calc_plane_remap_info()
1428 struct intel_remapped_plane_info *remap_info = &view->gtt.remapped.plane[color_plane]; in calc_plane_remap_info()
1429 struct i915_color_plane_view *color_plane_info = &view->color_plane[color_plane]; in calc_plane_remap_info()
1430 unsigned int tile_width = dims->tile_width; in calc_plane_remap_info()
1431 unsigned int tile_height = dims->tile_height; in calc_plane_remap_info()
1436 assign_bfld_chk_ovf(i915, remap_info->offset, obj_offset); in calc_plane_remap_info()
1438 if (intel_fb_is_gen12_ccs_aux_plane(&fb->base, color_plane)) { in calc_plane_remap_info()
1439 remap_info->linear = 1; in calc_plane_remap_info()
1441 assign_chk_ovf(i915, remap_info->size, in calc_plane_remap_info()
1442 plane_view_linear_tiles(fb, color_plane, dims, x, y)); in calc_plane_remap_info()
1444 remap_info->linear = 0; in calc_plane_remap_info()
1446 assign_chk_ovf(i915, remap_info->src_stride, in calc_plane_remap_info()
1448 assign_chk_ovf(i915, remap_info->width, in calc_plane_remap_info()
1450 assign_chk_ovf(i915, remap_info->height, in calc_plane_remap_info()
1451 plane_view_height_tiles(fb, color_plane, dims, y)); in calc_plane_remap_info()
1454 if (view->gtt.type == I915_GTT_VIEW_ROTATED) { in calc_plane_remap_info()
1455 drm_WARN_ON(&i915->drm, remap_info->linear); in calc_plane_remap_info()
1456 check_array_bounds(i915, view->gtt.rotated.plane, color_plane); in calc_plane_remap_info()
1458 assign_chk_ovf(i915, remap_info->dst_stride, in calc_plane_remap_info()
1459 plane_view_dst_stride_tiles(fb, color_plane, remap_info->height)); in calc_plane_remap_info()
1461 /* rotate the x/y offsets to match the GTT view */ in calc_plane_remap_info()
1462 drm_rect_init(&r, x, y, dims->width, dims->height); in calc_plane_remap_info()
1464 remap_info->width * tile_width, in calc_plane_remap_info()
1465 remap_info->height * tile_height, in calc_plane_remap_info()
1468 color_plane_info->x = r.x1; in calc_plane_remap_info()
1469 color_plane_info->y = r.y1; in calc_plane_remap_info()
1471 color_plane_info->mapping_stride = remap_info->dst_stride * tile_height; in calc_plane_remap_info()
1472 color_plane_info->scanout_stride = color_plane_info->mapping_stride; in calc_plane_remap_info()
1474 size += remap_info->dst_stride * remap_info->width; in calc_plane_remap_info()
1479 drm_WARN_ON(&i915->drm, view->gtt.type != I915_GTT_VIEW_REMAPPED); in calc_plane_remap_info()
1481 check_array_bounds(i915, view->gtt.remapped.plane, color_plane); in calc_plane_remap_info()
1483 if (view->gtt.remapped.plane_alignment) { in calc_plane_remap_info()
1485 view->gtt.remapped.plane_alignment); in calc_plane_remap_info()
1487 size += aligned_offset - gtt_offset; in calc_plane_remap_info()
1491 color_plane_info->x = x; in calc_plane_remap_info()
1492 color_plane_info->y = y; in calc_plane_remap_info()
1494 if (remap_info->linear) { in calc_plane_remap_info()
1495 color_plane_info->mapping_stride = fb->base.pitches[color_plane]; in calc_plane_remap_info()
1496 color_plane_info->scanout_stride = color_plane_info->mapping_stride; in calc_plane_remap_info()
1498 size += remap_info->size; in calc_plane_remap_info()
1501 remap_info->width); in calc_plane_remap_info()
1503 assign_chk_ovf(i915, remap_info->dst_stride, dst_stride); in calc_plane_remap_info()
1504 color_plane_info->mapping_stride = dst_stride * in calc_plane_remap_info()
1506 fb->base.format->cpp[color_plane]; in calc_plane_remap_info()
1507 color_plane_info->scanout_stride = in calc_plane_remap_info()
1509 remap_info->src_stride, in calc_plane_remap_info()
1512 size += dst_stride * remap_info->height; in calc_plane_remap_info()
1517 * We only keep the x/y offsets, so push all of the gtt offset into in calc_plane_remap_info()
1518 * the x/y offsets. x,y will hold the first pixel of the framebuffer in calc_plane_remap_info()
1521 if (remap_info->linear) in calc_plane_remap_info()
1522 intel_adjust_linear_offset(&color_plane_info->x, &color_plane_info->y, in calc_plane_remap_info()
1523 fb->base.format->cpp[color_plane], in calc_plane_remap_info()
1524 color_plane_info->mapping_stride, in calc_plane_remap_info()
1527 intel_adjust_tile_offset(&color_plane_info->x, &color_plane_info->y, in calc_plane_remap_info()
1529 tile_size, remap_info->dst_stride, in calc_plane_remap_info()
1541 int x, int y) in calc_plane_normal_size() argument
1545 if (is_surface_linear(&fb->base, color_plane)) { in calc_plane_normal_size()
1546 tiles = plane_view_linear_tiles(fb, color_plane, dims, x, y); in calc_plane_normal_size()
1549 plane_view_height_tiles(fb, color_plane, dims, y); in calc_plane_normal_size()
1565 view->gtt.type = view_type; in intel_fb_view_init()
1569 view->gtt.remapped.plane_alignment = SZ_2M / PAGE_SIZE; in intel_fb_view_init()
1574 if (DISPLAY_VER(to_i915(fb->base.dev)) >= 13) in intel_fb_supports_90_270_rotation()
1577 return fb->base.modifier == I915_FORMAT_MOD_Y_TILED || in intel_fb_supports_90_270_rotation()
1578 fb->base.modifier == I915_FORMAT_MOD_Yf_TILED; in intel_fb_supports_90_270_rotation()
1583 struct drm_i915_gem_object *obj = intel_fb_obj(&fb->base); in intel_fill_fb_info()
1587 int i, num_planes = fb->base.format->num_planes; in intel_fill_fb_info()
1590 intel_fb_view_init(i915, &fb->normal_view, I915_GTT_VIEW_NORMAL); in intel_fill_fb_info()
1592 drm_WARN_ON(&i915->drm, in intel_fill_fb_info()
1597 intel_fb_view_init(i915, &fb->rotated_view, I915_GTT_VIEW_ROTATED); in intel_fill_fb_info()
1599 intel_fb_view_init(i915, &fb->remapped_view, I915_GTT_VIEW_REMAPPED); in intel_fill_fb_info()
1605 u32 offset; in intel_fill_fb_info() local
1606 int x, y; in intel_fill_fb_info() local
1612 * arithmetic related to alignment and offset calculation. in intel_fill_fb_info()
1614 if (is_gen12_ccs_cc_plane(&fb->base, i)) { in intel_fill_fb_info()
1615 if (IS_ALIGNED(fb->base.offsets[i], PAGE_SIZE)) in intel_fill_fb_info()
1618 return -EINVAL; in intel_fill_fb_info()
1623 ret = convert_plane_offset_to_xy(fb, i, width, &x, &y); in intel_fill_fb_info()
1633 fb->normal_view.color_plane[i].x = x; in intel_fill_fb_info()
1634 fb->normal_view.color_plane[i].y = y; in intel_fill_fb_info()
1635 fb->normal_view.color_plane[i].mapping_stride = fb->base.pitches[i]; in intel_fill_fb_info()
1636 fb->normal_view.color_plane[i].scanout_stride = in intel_fill_fb_info()
1637 fb->normal_view.color_plane[i].mapping_stride; in intel_fill_fb_info()
1639 offset = calc_plane_aligned_offset(fb, i, &x, &y); in intel_fill_fb_info()
1643 offset, gtt_offset_rotated, x, y, in intel_fill_fb_info()
1644 &fb->rotated_view); in intel_fill_fb_info()
1648 offset, gtt_offset_remapped, x, y, in intel_fill_fb_info()
1649 &fb->remapped_view); in intel_fill_fb_info()
1651 size = calc_plane_normal_size(fb, i, &view_dims, x, y); in intel_fill_fb_info()
1653 max_size = max(max_size, offset + size); in intel_fill_fb_info()
1656 if (mul_u32_u32(max_size, tile_size) > obj->base.size) { in intel_fill_fb_info()
1657 drm_dbg_kms(&i915->drm, in intel_fill_fb_info()
1659 mul_u32_u32(max_size, tile_size), obj->base.size); in intel_fill_fb_info()
1660 return -EINVAL; in intel_fill_fb_info()
1669 to_i915(plane_state->uapi.plane->dev); in intel_plane_remap_gtt()
1670 struct drm_framebuffer *fb = plane_state->hw.fb; in intel_plane_remap_gtt()
1672 unsigned int rotation = plane_state->hw.rotation; in intel_plane_remap_gtt()
1673 int i, num_planes = fb->format->num_planes; in intel_plane_remap_gtt()
1678 intel_fb_view_init(i915, &plane_state->view, in intel_plane_remap_gtt()
1682 src_x = plane_state->uapi.src.x1 >> 16; in intel_plane_remap_gtt()
1683 src_y = plane_state->uapi.src.y1 >> 16; in intel_plane_remap_gtt()
1684 src_w = drm_rect_width(&plane_state->uapi.src) >> 16; in intel_plane_remap_gtt()
1685 src_h = drm_rect_height(&plane_state->uapi.src) >> 16; in intel_plane_remap_gtt()
1687 drm_WARN_ON(&i915->drm, intel_fb_is_ccs_modifier(fb->modifier)); in intel_plane_remap_gtt()
1690 drm_rect_translate(&plane_state->uapi.src, in intel_plane_remap_gtt()
1691 -(src_x << 16), -(src_y << 16)); in intel_plane_remap_gtt()
1695 drm_rect_rotate(&plane_state->uapi.src, in intel_plane_remap_gtt()
1700 unsigned int hsub = i ? fb->format->hsub : 1; in intel_plane_remap_gtt()
1701 unsigned int vsub = i ? fb->format->vsub : 1; in intel_plane_remap_gtt()
1704 unsigned int x, y; in intel_plane_remap_gtt() local
1705 u32 offset; in intel_plane_remap_gtt() local
1708 y = src_y / vsub; in intel_plane_remap_gtt()
1718 x += intel_fb->normal_view.color_plane[i].x; in intel_plane_remap_gtt()
1719 y += intel_fb->normal_view.color_plane[i].y; in intel_plane_remap_gtt()
1721 offset = calc_plane_aligned_offset(intel_fb, i, &x, &y); in intel_plane_remap_gtt()
1724 offset, gtt_offset, x, y, in intel_plane_remap_gtt()
1725 &plane_state->view); in intel_plane_remap_gtt()
1733 *view = fb->rotated_view; in intel_fb_fill_view()
1735 *view = fb->remapped_view; in intel_fb_fill_view()
1737 *view = fb->normal_view; in intel_fb_fill_view()
1762 struct drm_i915_private *dev_priv = to_i915(fb->dev); in intel_fb_stride_alignment()
1767 fb->format->format, in intel_fb_stride_alignment()
1768 fb->modifier); in intel_fb_stride_alignment()
1774 if (fb->pitches[color_plane] > max_stride && in intel_fb_stride_alignment()
1775 !intel_fb_is_ccs_modifier(fb->modifier)) in intel_fb_stride_alignment()
1782 if (intel_fb_is_ccs_modifier(fb->modifier)) { in intel_fb_stride_alignment()
1799 color_plane == 0 && fb->width > 3840) in intel_fb_stride_alignment()
1807 struct intel_plane *plane = to_intel_plane(plane_state->uapi.plane); in intel_plane_check_stride()
1808 const struct drm_framebuffer *fb = plane_state->hw.fb; in intel_plane_check_stride()
1809 unsigned int rotation = plane_state->hw.rotation; in intel_plane_check_stride()
1819 !plane_state->uapi.visible) in intel_plane_check_stride()
1823 stride = plane_state->view.color_plane[0].mapping_stride; in intel_plane_check_stride()
1824 max_stride = plane->max_stride(plane, fb->format->format, in intel_plane_check_stride()
1825 fb->modifier, rotation); in intel_plane_check_stride()
1829 fb->base.id, stride, in intel_plane_check_stride()
1830 plane->base.base.id, plane->base.name, max_stride); in intel_plane_check_stride()
1831 return -EINVAL; in intel_plane_check_stride()
1840 to_intel_framebuffer(plane_state->hw.fb); in intel_plane_compute_gtt()
1841 unsigned int rotation = plane_state->hw.rotation; in intel_plane_compute_gtt()
1858 intel_fb_fill_view(fb, rotation, &plane_state->view); in intel_plane_compute_gtt()
1862 drm_rect_rotate(&plane_state->uapi.src, in intel_plane_compute_gtt()
1863 fb->base.width << 16, fb->base.height << 16, in intel_plane_compute_gtt()
1876 intel_dpt_destroy(intel_fb->dpt_vm); in intel_user_framebuffer_destroy()
1878 intel_frontbuffer_put(intel_fb->frontbuffer); in intel_user_framebuffer_destroy()
1888 struct drm_i915_private *i915 = to_i915(obj->base.dev); in intel_user_framebuffer_create_handle()
1891 drm_dbg(&i915->drm, in intel_user_framebuffer_create_handle()
1893 return -EINVAL; in intel_user_framebuffer_create_handle()
1896 return drm_gem_handle_create(file, &obj->base, handle); in intel_user_framebuffer_create_handle()
1923 struct drm_i915_private *dev_priv = to_i915(obj->base.dev); in intel_framebuffer_init()
1924 struct drm_framebuffer *fb = &intel_fb->base; in intel_framebuffer_init()
1927 int ret = -EINVAL; in intel_framebuffer_init()
1930 intel_fb->frontbuffer = intel_frontbuffer_get(obj); in intel_framebuffer_init()
1931 if (!intel_fb->frontbuffer) in intel_framebuffer_init()
1932 return -ENOMEM; in intel_framebuffer_init()
1939 if (mode_cmd->flags & DRM_MODE_FB_MODIFIERS) { in intel_framebuffer_init()
1945 tiling != intel_fb_modifier_to_tiling(mode_cmd->modifier[0])) { in intel_framebuffer_init()
1946 drm_dbg_kms(&dev_priv->drm, in intel_framebuffer_init()
1952 mode_cmd->modifier[0] = I915_FORMAT_MOD_X_TILED; in intel_framebuffer_init()
1954 drm_dbg_kms(&dev_priv->drm, in intel_framebuffer_init()
1955 "No Y tiling for legacy addfb\n"); in intel_framebuffer_init()
1960 if (!drm_any_plane_has_format(&dev_priv->drm, in intel_framebuffer_init()
1961 mode_cmd->pixel_format, in intel_framebuffer_init()
1962 mode_cmd->modifier[0])) { in intel_framebuffer_init()
1963 drm_dbg_kms(&dev_priv->drm, in intel_framebuffer_init()
1965 &mode_cmd->pixel_format, mode_cmd->modifier[0]); in intel_framebuffer_init()
1974 tiling != intel_fb_modifier_to_tiling(mode_cmd->modifier[0])) { in intel_framebuffer_init()
1975 drm_dbg_kms(&dev_priv->drm, in intel_framebuffer_init()
1980 max_stride = intel_fb_max_stride(dev_priv, mode_cmd->pixel_format, in intel_framebuffer_init()
1981 mode_cmd->modifier[0]); in intel_framebuffer_init()
1982 if (mode_cmd->pitches[0] > max_stride) { in intel_framebuffer_init()
1983 drm_dbg_kms(&dev_priv->drm, in intel_framebuffer_init()
1985 mode_cmd->modifier[0] != DRM_FORMAT_MOD_LINEAR ? in intel_framebuffer_init()
1987 mode_cmd->pitches[0], max_stride); in intel_framebuffer_init()
1995 if (tiling != I915_TILING_NONE && mode_cmd->pitches[0] != stride) { in intel_framebuffer_init()
1996 drm_dbg_kms(&dev_priv->drm, in intel_framebuffer_init()
1998 mode_cmd->pitches[0], stride); in intel_framebuffer_init()
2003 if (mode_cmd->offsets[0] != 0) { in intel_framebuffer_init()
2004 drm_dbg_kms(&dev_priv->drm, in intel_framebuffer_init()
2005 "plane 0 offset (0x%08x) must be 0\n", in intel_framebuffer_init()
2006 mode_cmd->offsets[0]); in intel_framebuffer_init()
2010 drm_helper_mode_fill_fb_struct(&dev_priv->drm, fb, mode_cmd); in intel_framebuffer_init()
2012 for (i = 0; i < fb->format->num_planes; i++) { in intel_framebuffer_init()
2015 if (mode_cmd->handles[i] != mode_cmd->handles[0]) { in intel_framebuffer_init()
2016 drm_dbg_kms(&dev_priv->drm, "bad plane %d handle\n", in intel_framebuffer_init()
2022 if (fb->pitches[i] & (stride_alignment - 1)) { in intel_framebuffer_init()
2023 drm_dbg_kms(&dev_priv->drm, in intel_framebuffer_init()
2025 i, fb->pitches[i], stride_alignment); in intel_framebuffer_init()
2032 if (fb->pitches[i] != ccs_aux_stride) { in intel_framebuffer_init()
2033 drm_dbg_kms(&dev_priv->drm, in intel_framebuffer_init()
2036 fb->pitches[i], ccs_aux_stride); in intel_framebuffer_init()
2041 fb->obj[i] = &obj->base; in intel_framebuffer_init()
2053 drm_dbg_kms(&dev_priv->drm, "failed to create DPT\n"); in intel_framebuffer_init()
2058 intel_fb->dpt_vm = vm; in intel_framebuffer_init()
2061 ret = drm_framebuffer_init(&dev_priv->drm, fb, &intel_fb_funcs); in intel_framebuffer_init()
2063 drm_err(&dev_priv->drm, "framebuffer init failed %d\n", ret); in intel_framebuffer_init()
2071 intel_dpt_destroy(intel_fb->dpt_vm); in intel_framebuffer_init()
2073 intel_frontbuffer_put(intel_fb->frontbuffer); in intel_framebuffer_init()
2089 return ERR_PTR(-ENOENT); in intel_user_framebuffer_create()
2092 i915 = to_i915(obj->base.dev); in intel_user_framebuffer_create()
2096 drm_dbg_kms(&i915->drm, "framebuffer must reside in local memory\n"); in intel_user_framebuffer_create()
2097 return ERR_PTR(-EREMOTE); in intel_user_framebuffer_create()
2115 return ERR_PTR(-ENOMEM); in intel_framebuffer_create()
2121 return &intel_fb->base; in intel_framebuffer_create()