Commit 3f4e3a28 authored by Harry Wentland's avatar Harry Wentland Committed by Alex Deucher

drm/amd/display: Use macro for isnan check

In code provided by HW teams we do a NaN check on floats
by comparing the number against itself. This confuses most
people including myself. Macro it out to make it self-explanatory.

Don't do a NaN check for int.

v2: parantheses around 'number' expression
Signed-off-by: default avatarHarry Wentland <harry.wentland@amd.com>
Reviewed-by: default avatarAlex Deucher <alexander.deucher@amd.com>
Signed-off-by: default avatarAlex Deucher <alexander.deucher@amd.com>
parent fdc72e7d
......@@ -25,37 +25,35 @@
#include "dcn_calc_math.h"
#define isNaN(number) ((number) != (number))
float dcn_bw_mod(const float arg1, const float arg2)
{
if (arg1 != arg1)
if (isNaN(arg1))
return arg2;
if (arg2 != arg2)
if (isNaN(arg2))
return arg1;
return arg1 - arg1 * ((int) (arg1 / arg2));
}
float dcn_bw_min2(const float arg1, const float arg2)
{
if (arg1 != arg1)
if (isNaN(arg1))
return arg2;
if (arg2 != arg2)
if (isNaN(arg2))
return arg1;
return arg1 < arg2 ? arg1 : arg2;
}
unsigned int dcn_bw_max(const unsigned int arg1, const unsigned int arg2)
{
if (arg1 != arg1)
return arg2;
if (arg2 != arg2)
return arg1;
return arg1 > arg2 ? arg1 : arg2;
}
float dcn_bw_max2(const float arg1, const float arg2)
{
if (arg1 != arg1)
if (isNaN(arg1))
return arg2;
if (arg2 != arg2)
if (isNaN(arg2))
return arg1;
return arg1 > arg2 ? arg1 : arg2;
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment