[lvc-project] [PATCH RFT] drm/rockchip: vop: fix simple case of window scaling

Sergey Shtylyov s.shtylyov at omp.ru
Tue Nov 11 23:56:19 MSK 2025


In scl_cal_scale2(), if the dst parameter equals to 1, then division by
0 will happen. Actually, the whole {src,dst} - 1 thing is caused by what
seems to be an error in the Rockchip manuals which say that the window's
width/height fields of the VOP_WIN<n>_{ACT,DSP}_INFO registers should be
used for the division verbatim -- and those are actually 1 less than the
window's real width/height; so scl_cal_scale2() returns expected result
(0x1000) only when src equals dst...

Found by Linux Verification Center (linuxtesting.org) with the Svace static
analysis tool.

Fixes: 1194fffbb102 ("drm/rockchip: vop: spilt scale regsters")
Signed-off-by: Sergey Shtylyov <s.shtylyov at omp.ru>

---
The patch is against the drm-misc-fixes branch of the DRM kernel.git repo
on gitlab.freedesktop.org.

Note that scl_cal_scale() does look buggy as well, but I can't figure out
(even having the RK3288 manual) how to properly fix that (it's only clear
that -1 should be removed; perhaps Mark Yao can help there...

 drivers/gpu/drm/rockchip/rockchip_drm_vop.h |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Index: kernel/drivers/gpu/drm/rockchip/rockchip_drm_vop.h
===================================================================
--- kernel.orig/drivers/gpu/drm/rockchip/rockchip_drm_vop.h
+++ kernel/drivers/gpu/drm/rockchip/rockchip_drm_vop.h
@@ -360,7 +360,7 @@ static inline uint16_t scl_cal_scale(int
 
 static inline uint16_t scl_cal_scale2(int src, int dst)
 {
-	return ((src - 1) << 12) / (dst - 1);
+	return (src << 12) / dst;
 }
 
 #define GET_SCL_FT_BILI_DN(src, dst)	scl_cal_scale(src, dst, 12)



More information about the lvc-project mailing list