Skip to content

Commit edc2b74

Browse files
committed
drm/i915: Adjust LUT rounding rules
drm_color_lut_extract() rounding was changed to follow the OpenGL int<->float conversion rules. Adjust intel_color_lut_pack() to match. Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com> Link: https://patchwork.freedesktop.org/patch/msgid/20231013131402.24072-3-ville.syrjala@linux.intel.com Reviewed-by: Chaitanya Kumar Borah <chaitanya.kumar.borah@intel.com> Reviewed-by: Jani Nikula <jani.nikula@intel.com>
1 parent c6fbb6b commit edc2b74

1 file changed

Lines changed: 6 additions & 8 deletions

File tree

drivers/gpu/drm/i915/display/intel_color.c

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -785,14 +785,12 @@ static void chv_assign_csc(struct intel_crtc_state *crtc_state)
785785
/* convert hw value with given bit_precision to lut property val */
786786
static u32 intel_color_lut_pack(u32 val, int bit_precision)
787787
{
788-
u32 max = 0xffff >> (16 - bit_precision);
789-
790-
val = clamp_val(val, 0, max);
791-
792-
if (bit_precision < 16)
793-
val <<= 16 - bit_precision;
794-
795-
return val;
788+
if (bit_precision > 16)
789+
return DIV_ROUND_CLOSEST_ULL(mul_u32_u32(val, (1 << 16) - 1),
790+
(1 << bit_precision) - 1);
791+
else
792+
return DIV_ROUND_CLOSEST(val * ((1 << 16) - 1),
793+
(1 << bit_precision) - 1);
796794
}
797795

798796
static u32 i9xx_lut_8(const struct drm_color_lut *color)

0 commit comments

Comments
 (0)