[PATCH 2/2] drm/xe/display: Simplify DPT handling

Juha-Pekka Heikkila juhapekka.heikkila at gmail.com
Tue Mar 19 17:07:34 UTC 2024


Don't undo structures on higher level but pass them all the way
to mapping functions.

Signed-off-by: Juha-Pekka Heikkila <juhapekka.heikkila at gmail.com>
---
 drivers/gpu/drm/xe/display/xe_fb_pin.c | 69 ++++++++++++--------------
 1 file changed, 31 insertions(+), 38 deletions(-)

diff --git a/drivers/gpu/drm/xe/display/xe_fb_pin.c b/drivers/gpu/drm/xe/display/xe_fb_pin.c
index 2d1259a884d6..71860198bf20 100644
--- a/drivers/gpu/drm/xe/display/xe_fb_pin.c
+++ b/drivers/gpu/drm/xe/display/xe_fb_pin.c
@@ -23,32 +23,32 @@ static void encode_and_write_pte(struct xe_bo *bo, struct iosys_map *map,
 	*ofs += 8;
 }
 
-static u32 calc_src_idx_rotated(u32 base, u32 offset, u32 stride, u32 width,
-				u32 height, u32 row, u32 column)
+static u32 calc_src_idx_rotated(const struct intel_remapped_plane_info *plane,
+				u32 row, u32 column)
 {
-	return base + stride * (height - 1 - row) + column;
+	return plane->offset + plane->src_stride * (plane->height - 1 - row)
+		+ column;
 }
 
-static u32 calc_src_idx_remapped(u32 base, u32 offset, u32 src_stride,
-				 u32 width, u32 height, u32 row, u32 column)
+static u32 calc_src_idx_remapped(const struct intel_remapped_plane_info *plane,
+				 u32 row, u32 column)
 {
-	return base + offset + row * src_stride + column;
+	return plane->offset + row * plane->src_stride + column;
 }
 
 static void write_dpt(struct xe_bo *bo, struct iosys_map *map, u32 *dpt_ofs,
-		      u32 bo_ofs, u32 width, u32 height, u32 src_stride,
-		      u32 dst_stride,
-		      u32 (*calc_src_idx)(u32, u32, u32, u32, u32, u32, u32))
+		      const struct intel_remapped_plane_info *plane,
+		      u32 (*calc_src_idx)(const struct intel_remapped_plane_info*,
+		      u32, u32))
 {
 	struct xe_device *xe = xe_bo_device(bo);
-	for (u32 row = 0; row < height; ++row) {
-		for (u32 column = 0; column < width; ++column) {
-			u32 src_idx = calc_src_idx(bo_ofs, 0, src_stride,
-						   width, height, row, column);
+	for (u32 row = 0; row < plane->height; ++row) {
+		for (u32 column = 0; column < plane->width; ++column) {
+			u32 src_idx = calc_src_idx(plane, row, column);
 			encode_and_write_pte(bo, map, dpt_ofs, src_idx, xe);
 		}
-		*dpt_ofs += (dst_stride - (calc_src_idx == calc_src_idx_rotated
-			     ? height : width)) * 8;
+		*dpt_ofs += (plane->dst_stride - (calc_src_idx == calc_src_idx_rotated
+			     ? plane->height : plane->width)) * 8;
 	}
 	*dpt_ofs = ALIGN(*dpt_ofs, 4096);
 }
@@ -103,30 +103,23 @@ static int __xe_pin_fb_vma_dpt(struct intel_framebuffer *fb,
 
 			iosys_map_wr(&dpt->vmap, x * 8, u64, pte);
 		}
-	} else if (view->type == I915_GTT_VIEW_REMAPPED) {
-		const struct intel_remapped_info *remap_info = &view->remapped;
-		u32 i, dpt_ofs = 0;
-
-		for (i = 0; i < ARRAY_SIZE(remap_info->plane); i++)
-			write_dpt(bo, &dpt->vmap, &dpt_ofs,
-				  remap_info->plane[i].offset,
-				  remap_info->plane[i].width,
-				  remap_info->plane[i].height,
-				  remap_info->plane[i].src_stride,
-				  remap_info->plane[i].dst_stride,
-				  calc_src_idx_remapped);
-	} else {
-		const struct intel_rotation_info *rot_info = &view->rotated;
-		u32 i, dpt_ofs = 0;
+	} else  {
+		const struct intel_remapped_plane_info *plane;
+		u32 i, plane_count, dpt_ofs = 0;
+		u32 (*src_idx)(const struct intel_remapped_plane_info*, u32, u32);
+
+		if (view->type == I915_GTT_VIEW_REMAPPED) {
+			plane = view->remapped.plane;
+			plane_count = ARRAY_SIZE(view->remapped.plane);
+			src_idx = calc_src_idx_remapped;
+		} else {
+			plane = view->rotated.plane;
+			plane_count = ARRAY_SIZE(view->rotated.plane);
+			src_idx = calc_src_idx_rotated;
+		}
 
-		for (i = 0; i < ARRAY_SIZE(rot_info->plane); i++)
-			write_dpt(bo, &dpt->vmap, &dpt_ofs,
-				  rot_info->plane[i].offset,
-				  rot_info->plane[i].width,
-				  rot_info->plane[i].height,
-				  rot_info->plane[i].src_stride,
-				  rot_info->plane[i].dst_stride,
-				  calc_src_idx_rotated);
+		for (i = 0; i < plane_count; i++)
+			write_dpt(bo, &dpt->vmap, &dpt_ofs, &plane[i], src_idx);
 	}
 
 	vma->dpt = dpt;
-- 
2.25.1



More information about the Intel-xe mailing list