diff options
author | Dmytro Laktyushkin <Dmytro.Laktyushkin@amd.com> | 2017-11-29 00:20:45 +0300 |
---|---|---|
committer | Alex Deucher <alexander.deucher@amd.com> | 2017-12-14 19:00:53 +0300 |
commit | 78b56c52349596374dd47584d1f1db4d08609b7b (patch) | |
tree | 46ab247d6c38b42fa0ffbb02189159eaa61bb663 /drivers/gpu/drm/amd/display/dc/basics | |
parent | 51ca0b036223660e0db10e2bf6097a0689f5fa44 (diff) | |
download | linux-78b56c52349596374dd47584d1f1db4d08609b7b.tar.xz |
drm/amd/display: use clamping rather than truncation for CM fp conversions
Signed-off-by: Dmytro Laktyushkin <Dmytro.Laktyushkin@amd.com>
Reviewed-by: Tony Cheng <Tony.Cheng@amd.com>
Acked-by: Harry Wentland <harry.wentland@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
Diffstat (limited to 'drivers/gpu/drm/amd/display/dc/basics')
-rw-r--r-- | drivers/gpu/drm/amd/display/dc/basics/fixpt31_32.c | 24 |
1 files changed, 20 insertions, 4 deletions
diff --git a/drivers/gpu/drm/amd/display/dc/basics/fixpt31_32.c b/drivers/gpu/drm/amd/display/dc/basics/fixpt31_32.c index 13f8b8c02212..011a97f82fb6 100644 --- a/drivers/gpu/drm/amd/display/dc/basics/fixpt31_32.c +++ b/drivers/gpu/drm/amd/display/dc/basics/fixpt31_32.c @@ -554,6 +554,22 @@ static inline uint32_t ux_dy( return result | fractional_part; } +static inline uint32_t clamp_ux_dy( + int64_t value, + uint32_t integer_bits, + uint32_t fractional_bits, + uint32_t min_clamp) +{ + uint32_t truncated_val = ux_dy(value, integer_bits, fractional_bits); + + if (value >= (1LL << (integer_bits + FIXED31_32_BITS_PER_FRACTIONAL_PART))) + return (1 << (integer_bits + fractional_bits)) - 1; + else if (truncated_val > min_clamp) + return truncated_val; + else + return min_clamp; +} + uint32_t dal_fixed31_32_u2d19( struct fixed31_32 arg) { @@ -566,14 +582,14 @@ uint32_t dal_fixed31_32_u0d19( return ux_dy(arg.value, 0, 19); } -uint32_t dal_fixed31_32_u0d14( +uint32_t dal_fixed31_32_clamp_u0d14( struct fixed31_32 arg) { - return ux_dy(arg.value, 1, 14); + return clamp_ux_dy(arg.value, 0, 14, 1); } -uint32_t dal_fixed31_32_u0d10( +uint32_t dal_fixed31_32_clamp_u0d10( struct fixed31_32 arg) { - return ux_dy(arg.value, 1, 10); + return clamp_ux_dy(arg.value, 0, 10, 1); } |