From: Arun Iyengar Date: Thu, 19 Nov 2026 05:21:49 +0000 Subject: [PATCH v4 8/8] drm/rockchip: vop2: Fix the AFBC offsets of a source that starts inside a superblock MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Message-Id: <20261119-vop2-fixes-v4-8-4b8f5e7148c9@gmail.com> References: <20261119-vop2-fixes-v4-0-4b8f5e7148c9@gmail.com> In-Reply-To: <20261119-vop2-fixes-v4-0-4b8f5e7148c9@gmail.com> To: Sandy Huang , =?utf-8?q?Heiko_St=C3=BCbner?= , Andy Yan , Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , David Airlie , Simona Vetter , Sascha Hauer Cc: Piotr Zalewski , Chaoyi Chen , Damon Ding , dri-devel@lists.freedesktop.org, linux-rockchip@lists.infradead.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, Arun Iyengar X-Mailer: b4 0.15.2 X-Developer-Signature: v=1; a=ed25519-sha256; t=1795065702; l=2614; i=aiyengar1990@gmail.com; s=20261110; h=from:subject:message-id; bh=TKQv8lkwPZ5sd2Rf6HL/JUQwo4LrM3O2/MLRjh5P0BY=; b=0RocM37D4tuZkn5YHqDXNLASsCJnLv1FeBe5RjnGkveNcmJuCUEFSyZl14kNI6qdbCf3FdTRp tbYH9mxdJm2CU51hDwljYI9GElyxzG1ItdAUD9oZGCtxNJjoMKT4faU X-Developer-Key: i=aiyengar1990@gmail.com; a=ed25519; pk=zXpRgUTrhaFe6jLyPqbBy3ccfkj04w0g2690Wv3mg+0= X-Endpoint-Received: by B4 Relay for aiyengar1990@gmail.com/20261110 with auth_id=1480 List-Id: B4 Relay Submissions For an AFBC source that starts inside a superblock, AFBC_TILE_NUM misses the first, partial superblock column, and the transform offset is the whole x position (truncated to 8 bits) instead of the offset inside the superblock. Count the columns from the first one the source touches and take the x offset modulo the superblock width, as the vendor kernel does. Fixes: 604be85547ce ("drm/rockchip: Add VOP2 driver") Signed-off-by: Arun Iyengar --- drivers/gpu/drm/rockchip/rockchip_drm_vop2.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/drivers/gpu/drm/rockchip/rockchip_drm_vop2.c b/drivers/gpu/drm/rockchip/rockchip_drm_vop2.c index d4103e02f37f..670875ade4c4 100644 --- a/drivers/gpu/drm/rockchip/rockchip_drm_vop2.c +++ b/drivers/gpu/drm/rockchip/rockchip_drm_vop2.c @@ -435,7 +435,7 @@ static bool vop2_half_block_enable(struct drm_plane_state *pstate) } static u32 vop2_afbc_transform_offset(struct drm_plane_state *pstate, - bool afbc_half_block_en) + bool afbc_half_block_en, u32 block_w) { struct drm_rect *src = &pstate->src; struct drm_framebuffer *fb = pstate->fb; @@ -483,7 +483,7 @@ static u32 vop2_afbc_transform_offset(struct drm_plane_state *pstate, ty = act_yoffset; break; case DRM_MODE_REFLECT_Y: - tx = act_xoffset; + tx = act_xoffset % block_w; ty = bottom_crop_line_num - act_yoffset; break; case DRM_MODE_ROTATE_90: @@ -495,7 +495,7 @@ static u32 vop2_afbc_transform_offset(struct drm_plane_state *pstate, ty = vir_width - width - act_xoffset; break; case 0: - tx = act_xoffset; + tx = act_xoffset % block_w; ty = act_yoffset; break; } @@ -1437,7 +1437,7 @@ static void vop2_plane_atomic_update(struct drm_plane *plane, if (fb->modifier & AFBC_FORMAT_MOD_YTR) afbc_format |= (1 << 4); - afbc_tile_num = ALIGN(src_w, block_w) / block_w; + afbc_tile_num = ALIGN(src_w + (src->x1 >> 16) % block_w, block_w) / block_w; /* * AFBC pic_vir_width is count by pixel, this is different @@ -1488,7 +1488,7 @@ static void vop2_plane_atomic_update(struct drm_plane *plane, vop2_win_write(win, VOP2_WIN_AFBC_PLD_OFFSET, yrgb_mst); } - transform_offset = vop2_afbc_transform_offset(pstate, half_block_en); + transform_offset = vop2_afbc_transform_offset(pstate, half_block_en, block_w); vop2_win_write(win, VOP2_WIN_AFBC_HDR_PTR, yrgb_mst); vop2_win_write(win, VOP2_WIN_AFBC_PIC_SIZE, act_info); vop2_win_write(win, VOP2_WIN_TRANSFORM_OFFSET, transform_offset); -- 2.55.0