drm/rockchip: vop: fix simple case of window scaling
Subsystems (4)
PATCH 1/1 drm/rockchip: vop: fix simple case of window scaling
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.
---
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(-)
drivers/gpu/drm/rockchip/rockchip_drm_vop.h +1 -1
@@ -360,7 +360,7 @@ static inline uint16_t scl_cal_scale(intstatic 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)
_______________________________________________
Linux-rockchip mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-rockchip