Commit 6f96f200 authored by Maarten Lankhorst's avatar Maarten Lankhorst

drm/rect: Round above 1 << 16 upwards to correct scale calculation functions.

When calculating limits we want to be as pessimistic as possible,
so we have to explicitly say whether we want to round up or down
to accurately calculate whether we are below min_scale or above
max_scale.
Signed-off-by: default avatarMaarten Lankhorst <maarten.lankhorst@linux.intel.com>
[mlankhorst: Fix wording in documentation. (Ville)]
Reviewed-by: default avatarVille Syrjälä <ville.syrjala@linux.intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20180503112217.37292-2-maarten.lankhorst@linux.intel.com
parent 5f273141
...@@ -106,7 +106,10 @@ static int drm_calc_scale(int src, int dst) ...@@ -106,7 +106,10 @@ static int drm_calc_scale(int src, int dst)
if (dst == 0) if (dst == 0)
return 0; return 0;
scale = src / dst; if (src > (dst << 16))
return DIV_ROUND_UP(src, dst);
else
scale = src / dst;
return scale; return scale;
} }
...@@ -121,6 +124,10 @@ static int drm_calc_scale(int src, int dst) ...@@ -121,6 +124,10 @@ static int drm_calc_scale(int src, int dst)
* Calculate the horizontal scaling factor as * Calculate the horizontal scaling factor as
* (@src width) / (@dst width). * (@src width) / (@dst width).
* *
* If the scale is below 1 << 16, round down. If the scale is above
* 1 << 16, round up. This will calculate the scale with the most
* pessimistic limit calculation.
*
* RETURNS: * RETURNS:
* The horizontal scaling factor, or errno of out of limits. * The horizontal scaling factor, or errno of out of limits.
*/ */
...@@ -152,6 +159,10 @@ EXPORT_SYMBOL(drm_rect_calc_hscale); ...@@ -152,6 +159,10 @@ EXPORT_SYMBOL(drm_rect_calc_hscale);
* Calculate the vertical scaling factor as * Calculate the vertical scaling factor as
* (@src height) / (@dst height). * (@src height) / (@dst height).
* *
* If the scale is below 1 << 16, round down. If the scale is above
* 1 << 16, round up. This will calculate the scale with the most
* pessimistic limit calculation.
*
* RETURNS: * RETURNS:
* The vertical scaling factor, or errno of out of limits. * The vertical scaling factor, or errno of out of limits.
*/ */
...@@ -189,6 +200,10 @@ EXPORT_SYMBOL(drm_rect_calc_vscale); ...@@ -189,6 +200,10 @@ EXPORT_SYMBOL(drm_rect_calc_vscale);
* If the calculated scaling factor is above @max_vscale, * If the calculated scaling factor is above @max_vscale,
* decrease the height of rectangle @src to compensate. * decrease the height of rectangle @src to compensate.
* *
* If the scale is below 1 << 16, round down. If the scale is above
* 1 << 16, round up. This will calculate the scale with the most
* pessimistic limit calculation.
*
* RETURNS: * RETURNS:
* The horizontal scaling factor. * The horizontal scaling factor.
*/ */
...@@ -239,6 +254,10 @@ EXPORT_SYMBOL(drm_rect_calc_hscale_relaxed); ...@@ -239,6 +254,10 @@ EXPORT_SYMBOL(drm_rect_calc_hscale_relaxed);
* If the calculated scaling factor is above @max_vscale, * If the calculated scaling factor is above @max_vscale,
* decrease the height of rectangle @src to compensate. * decrease the height of rectangle @src to compensate.
* *
* If the scale is below 1 << 16, round down. If the scale is above
* 1 << 16, round up. This will calculate the scale with the most
* pessimistic limit calculation.
*
* RETURNS: * RETURNS:
* The vertical scaling factor. * The vertical scaling factor.
*/ */
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment