[PATCH 1/3] drm/rockchip: vop2: Use drm_format_info_min_pitch() for plane offsets
From: Chaoyi Chen
Date: Thu Oct 22 2026 - 03:22:26 EST
From: Chaoyi Chen <chaoyi.chen@xxxxxxxxxxxxxx>
Use the block aware helper instead of cpp[], the latter aliases
char_per_block and is wrong for packed 10-bit formats like NV15,
NV20 and NV30.
Tested with modetest[0]:
```
modetest -s 86:3840x2160 -P \
59@83:3940x2160~96,0,3840,2160+0+0@NV20 -a
```
fb size (3940x2160), src at (96, 0) with size (3840x2160),
dst at (0, 0) with size (3840x2160)
[0]: https://github.com/windowsair/libdrm/tree/src-pos-support
Assisted-by: LLM
Signed-off-by: Chaoyi Chen <chaoyi.chen@xxxxxxxxxxxxxx>
---
drivers/gpu/drm/rockchip/rockchip_drm_vop2.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/drivers/gpu/drm/rockchip/rockchip_drm_vop2.c b/drivers/gpu/drm/rockchip/rockchip_drm_vop2.c
index 4cce3e336f5b..480aa8c8a8d2 100644
--- a/drivers/gpu/drm/rockchip/rockchip_drm_vop2.c
+++ b/drivers/gpu/drm/rockchip/rockchip_drm_vop2.c
@@ -1290,7 +1290,7 @@ static void vop2_plane_atomic_update(struct drm_plane *plane,
afbc_en = drm_is_afbc(fb->modifier);
- offset = (src->x1 >> 16) * fb->format->cpp[0];
+ offset = drm_format_info_min_pitch(fb->format, 0, src->x1 >> 16);
/*
* AFBC HDR_PTR must set to the zero offset of the framebuffer.
@@ -1309,6 +1309,7 @@ static void vop2_plane_atomic_update(struct drm_plane *plane,
int hsub = fb->format->hsub;
int vsub = fb->format->vsub;
+ offset = drm_format_info_min_pitch(fb->format, 1, src->x1 >> 16) / hsub;
offset = (src->x1 >> 16) * fb->format->cpp[1] / hsub;
offset += (src->y1 >> 16) * fb->pitches[1] / vsub;
--
2.53.0