drm/msm/dsi: improve/fix dsc pclk calculation
PATCH v2 1/2 drm/msm/dsi: improve/fix dsc pclk calculation
drm_mode_vrefresh() can introduce a large rounding error, avoid it.
--- drivers/gpu/drm/msm/dsi/dsi_host.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/msm/dsi/dsi_host.c +1 -1
@@ -542,7 +542,7 @@ static unsigned long dsi_adjust_pclk_for_compression(const struct drm_display_moint new_htotal = mode->htotal - mode->hdisplay + new_hdisplay; -return new_htotal * mode->vtotal *drm_mode_vrefresh (mode); +return mult_frac (mode->clock *1000u , new_htotal, mode->htotal); } static unsigned long dsi_get_pclk_rate(const struct drm_display_mode *mode,
Signature · 1 line
2.45.1
PATCH v2 2/2 drm/msm/dsi: fix 32-bit signed integer extension in pclk_rate calculation
When (mode->clock * 1000) is larger than (1<<31), int to unsigned long conversion will sign extend the int to 64 bits and the pclk_rate value will be incorrect.
Fix this by making the result of the multiplication unsigned.
Note that above (1<<32) would still be broken and require more changes, but its unlikely anyone will need that anytime soon.
--- drivers/gpu/drm/msm/dsi/dsi_host.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/msm/dsi/dsi_host.c +1 -1
@@ -550,7 +550,7 @@ static unsigned long dsi_get_pclk_rate(const struct drm_display_mode *mode, {unsigned long pclk_rate; - pclk_rate = mode->clock *1000 ; + pclk_rate = mode->clock *1000u ;if (dsc) pclk_rate =dsi_adjust_pclk_for_compression (mode, dsc);
Signature · 1 line
2.45.1
Re: [PATCH v2 2/2] drm/msm/dsi: fix 32-bit signed integer extension in pclk_rate calculation
Quoted 6 lines · Jonathan Marek
When (
mode->clock* 1000) is larger than (1<<31), int to unsigned long conversion will sign extend the int to 64 bits and thepclk_ratevalue will be incorrect.Fix this by making the result of the multiplication unsigned.
Quoted 9 lines
Note that above (1<<32) would still be broken and require more changes, but its unlikely anyone will need that anytime soon.
Fixes c4d8cfe516dc ("drm/msm/dsi: add implementation for helper functions")Signed-off-by Jonathan Marek <[email protected]>--- drivers/gpu/drm/msm/dsi/dsi_host.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
Signature · 2 lines
With best wishes Dmitry
Re: [PATCH v2 2/2] drm/msm/dsi: fix 32-bit signed integer extension in pclk_rate calculation
In reply to Jonathan MarekQuoted 6 lines · Jonathan Marek
When (
mode->clock* 1000) is larger than (1<<31), int to unsigned long conversion will sign extend the int to 64 bits and thepclk_ratevalue will be incorrect.Fix this by making the result of the multiplication unsigned.
Quoted 9 lines
Note that above (1<<32) would still be broken and require more changes, but its unlikely anyone will need that anytime soon.
Fixes c4d8cfe516dc ("drm/msm/dsi: add implementation for helper functions")Signed-off-by Jonathan Marek <[email protected]>--- drivers/gpu/drm/msm/dsi/dsi_host.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
Quoted 8 lines · Jonathan Marek
drm_mode_vrefresh()can introduce a large rounding error, avoid it.Fixes 7c9e4a554d4a ("drm/msm/dsi: Reduce pclk rate for compression")Signed-off-by Jonathan Marek <[email protected]>--- drivers/gpu/drm/msm/dsi/dsi_host.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
Signature · 2 lines
With best wishes Dmitry
Quoted 8 lines · Jonathan Marek
drm_mode_vrefresh()can introduce a large rounding error, avoid it.Fixes 7c9e4a554d4a ("drm/msm/dsi: Reduce pclk rate for compression")Signed-off-by Jonathan Marek <[email protected]>--- drivers/gpu/drm/msm/dsi/dsi_host.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)