diff options
author | Lionel Landwerlin <[email protected]> | 2016-03-22 14:10:33 +0000 |
---|---|---|
committer | Daniel Vetter <[email protected]> | 2016-04-20 12:52:05 +0200 |
commit | 644a80508f918e488aad70814b65b7007438ef4c (patch) | |
tree | 56508eb632c9a3bb81b2db222e9c59466f7690c3 | |
parent | 8d4d0d700dda04c5095a08e91f59f537995aa024 (diff) |
drm: fix lut value extraction function
When extracting the value at full precision (16 bits), no need to
round the value.
This was spotted by Jani when running sparse. Unfortunately this fix
doesn't get rid of the warning.
Signed-off-by: Lionel Landwerlin <[email protected]>
Reported-by: Jani Nikula <[email protected]>
Cc: Daniel Stone <[email protected]>
Cc: Daniel Vetter <[email protected]>
Cc: Matt Roper <[email protected]>
Cc: [email protected]
Fixes: 5488dc16fde7 ("drm: introduce pipe color correction properties")
Reviewed-by: Emil Velikov <[email protected]>
Signed-off-by: Daniel Vetter <[email protected]>
Link: http://patchwork.freedesktop.org/patch/msgid/[email protected]
-rw-r--r-- | include/drm/drm_crtc.h | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/include/drm/drm_crtc.h b/include/drm/drm_crtc.h index 6d4684242a00..a6fbc9e5e896 100644 --- a/include/drm/drm_crtc.h +++ b/include/drm/drm_crtc.h @@ -2592,10 +2592,14 @@ static inline struct drm_property *drm_property_find(struct drm_device *dev, static inline uint32_t drm_color_lut_extract(uint32_t user_input, uint32_t bit_precision) { - uint32_t val = user_input + (1 << (16 - bit_precision - 1)); + uint32_t val = user_input; uint32_t max = 0xffff >> (16 - bit_precision); - val >>= 16 - bit_precision; + /* Round only if we're not using full precision. */ + if (bit_precision < 16) { + val += 1UL << (16 - bit_precision - 1); + val >>= 16 - bit_precision; + } return clamp_val(val, 0, max); } |