From: Vitaly Prosyak <vitaly.prosyak@xxxxxxx> Signed-off-by: Vitaly Prosyak <vitaly.prosyak at amd.com> Reviewed-by: Tony Cheng <Tony.Cheng at amd.com> Acked-by: Harry Wentland <harry.wentland at amd.com> --- drivers/gpu/drm/amd/display/dc/basics/fixpt31_32.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 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..169fe42f29cd 100644 --- a/drivers/gpu/drm/amd/display/dc/basics/fixpt31_32.c +++ b/drivers/gpu/drm/amd/display/dc/basics/fixpt31_32.c @@ -550,6 +550,9 @@ static inline uint32_t ux_dy( result <<= fractional_bits; /* 5. shrink fixed point fractional part to of fractional_bits width*/ fractional_part >>= FIXED31_32_BITS_PER_FRACTIONAL_PART - fractional_bits; + /*handle the case when overflow, for example 1.0 in u14 is 0x3fff*/ + if (value > 0 && result == 0 && integer_bits == 0 && fractional_part == 0) + fractional_part = (1<<fractional_bits) - 1; /* 6. merge the result */ return result | fractional_part; } @@ -569,11 +572,11 @@ uint32_t dal_fixed31_32_u0d19( uint32_t dal_fixed31_32_u0d14( struct fixed31_32 arg) { - return ux_dy(arg.value, 1, 14); + return ux_dy(arg.value, 0, 14); } uint32_t dal_fixed31_32_u0d10( struct fixed31_32 arg) { - return ux_dy(arg.value, 1, 10); + return ux_dy(arg.value, 0, 10); } -- 2.14.1