Commit 327e4f12 authored by Charlene Liu's avatar Charlene Liu Committed by Alex Deucher

drm/amd/display: add some math functions for dcn_calc_math

Implement floor, ceil, and fabs
Signed-off-by: default avatarCharlene Liu <charlene.liu@amd.com>
Reviewed-by: default avatarCharlene Liu <Charlene.Liu@amd.com>
Acked-by: default avatarBhawanpreet Lakha <Bhawanpreet.Lakha@amd.com>
Signed-off-by: default avatarAlex Deucher <alexander.deucher@amd.com>
parent 6e5155ae
...@@ -73,6 +73,17 @@ float dcn_bw_floor2(const float arg, const float significance) ...@@ -73,6 +73,17 @@ float dcn_bw_floor2(const float arg, const float significance)
return 0; return 0;
return ((int) (arg / significance)) * significance; return ((int) (arg / significance)) * significance;
} }
float dcn_bw_floor(const float arg)
{
return ((int) (arg));
}
float dcn_bw_ceil(const float arg)
{
float flr = dcn_bw_floor2(arg, 1);
return flr + 0.00001 >= arg ? arg : flr + 1;
}
float dcn_bw_ceil2(const float arg, const float significance) float dcn_bw_ceil2(const float arg, const float significance)
{ {
...@@ -109,6 +120,15 @@ float dcn_bw_pow(float a, float exp) ...@@ -109,6 +120,15 @@ float dcn_bw_pow(float a, float exp)
} }
} }
double dcn_bw_fabs(double a)
{
if (a > 0)
return (a);
else
return (-a);
}
float dcn_bw_log(float a, float b) float dcn_bw_log(float a, float b)
{ {
int * const exp_ptr = (int *)(&a); int * const exp_ptr = (int *)(&a);
......
...@@ -31,10 +31,13 @@ float dcn_bw_min2(const float arg1, const float arg2); ...@@ -31,10 +31,13 @@ float dcn_bw_min2(const float arg1, const float arg2);
unsigned int dcn_bw_max(const unsigned int arg1, const unsigned int arg2); unsigned int dcn_bw_max(const unsigned int arg1, const unsigned int arg2);
float dcn_bw_max2(const float arg1, const float arg2); float dcn_bw_max2(const float arg1, const float arg2);
float dcn_bw_floor2(const float arg, const float significance); float dcn_bw_floor2(const float arg, const float significance);
float dcn_bw_floor(const float arg);
float dcn_bw_ceil2(const float arg, const float significance); float dcn_bw_ceil2(const float arg, const float significance);
float dcn_bw_ceil(const float arg);
float dcn_bw_max3(float v1, float v2, float v3); float dcn_bw_max3(float v1, float v2, float v3);
float dcn_bw_max5(float v1, float v2, float v3, float v4, float v5); float dcn_bw_max5(float v1, float v2, float v3, float v4, float v5);
float dcn_bw_pow(float a, float exp); float dcn_bw_pow(float a, float exp);
float dcn_bw_log(float a, float b); float dcn_bw_log(float a, float b);
double dcn_bw_fabs(double a);
#endif /* _DCN_CALC_MATH_H_ */ #endif /* _DCN_CALC_MATH_H_ */
...@@ -129,4 +129,12 @@ static inline unsigned int dml_round_to_multiple(unsigned int num, ...@@ -129,4 +129,12 @@ static inline unsigned int dml_round_to_multiple(unsigned int num,
else else
return (num - remainder); return (num - remainder);
} }
static inline double dml_abs(double a)
{
if (a > 0)
return a;
else
return (a*(-1));
}
#endif #endif
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