Skip to content

Commit

Permalink
drm: fix lut value extraction function
Browse files Browse the repository at this point in the history
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 <lionel.g.landwerlin@intel.com>
Reported-by: Jani Nikula <jani.nikula@intel.com>
Cc: Daniel Stone <daniels@collabora.com>
Cc: Daniel Vetter <daniel.vetter@ffwll.ch>
Cc: Matt Roper <matthew.d.roper@intel.com>
Cc: dri-devel@lists.freedesktop.org
Fixes: 5488dc1 ("drm: introduce pipe color correction properties")
Reviewed-by: Emil Velikov <emil.velikov@collabora.com>
Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
Link: http://patchwork.freedesktop.org/patch/msgid/1458655833-19547-1-git-send-email-lionel.g.landwerlin@intel.com
  • Loading branch information
Lionel Landwerlin authored and Daniel Vetter committed Apr 20, 2016
1 parent 8d4d0d7 commit 644a805
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions include/drm/drm_crtc.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down

0 comments on commit 644a805

Please sign in to comment.