From: Charlene Liu <charlene.liu@xxxxxxx> Implement floor, ceil, and fabs Signed-off-by: Charlene Liu <charlene.liu@xxxxxxx> Reviewed-by: Charlene Liu <Charlene.Liu@xxxxxxx> Acked-by: Bhawanpreet Lakha <Bhawanpreet.Lakha@xxxxxxx> --- .../drm/amd/display/dc/calcs/dcn_calc_math.c | 20 +++++++++++++++++++ .../drm/amd/display/dc/calcs/dcn_calc_math.h | 3 +++ .../drm/amd/display/dc/dml/dml_inline_defs.h | 8 ++++++++ 3 files changed, 31 insertions(+) diff --git a/drivers/gpu/drm/amd/display/dc/calcs/dcn_calc_math.c b/drivers/gpu/drm/amd/display/dc/calcs/dcn_calc_math.c index 7600a4a4abc7..07d18e78de49 100644 --- a/drivers/gpu/drm/amd/display/dc/calcs/dcn_calc_math.c +++ b/drivers/gpu/drm/amd/display/dc/calcs/dcn_calc_math.c @@ -73,6 +73,17 @@ float dcn_bw_floor2(const float arg, const float significance) return 0; 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) { @@ -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) { int * const exp_ptr = (int *)(&a); diff --git a/drivers/gpu/drm/amd/display/dc/calcs/dcn_calc_math.h b/drivers/gpu/drm/amd/display/dc/calcs/dcn_calc_math.h index f46ab0e24ca1..45a07eeffbb6 100644 --- a/drivers/gpu/drm/amd/display/dc/calcs/dcn_calc_math.h +++ b/drivers/gpu/drm/amd/display/dc/calcs/dcn_calc_math.h @@ -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); float dcn_bw_max2(const float arg1, const float arg2); 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_ceil(const float arg); 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_pow(float a, float exp); float dcn_bw_log(float a, float b); +double dcn_bw_fabs(double a); #endif /* _DCN_CALC_MATH_H_ */ diff --git a/drivers/gpu/drm/amd/display/dc/dml/dml_inline_defs.h b/drivers/gpu/drm/amd/display/dc/dml/dml_inline_defs.h index e8ce08567cd8..eca140da13d8 100644 --- a/drivers/gpu/drm/amd/display/dc/dml/dml_inline_defs.h +++ b/drivers/gpu/drm/amd/display/dc/dml/dml_inline_defs.h @@ -129,4 +129,12 @@ static inline unsigned int dml_round_to_multiple(unsigned int num, else return (num - remainder); } +static inline double dml_abs(double a) +{ + if (a > 0) + return a; + else + return (a*(-1)); +} + #endif -- 2.17.1 _______________________________________________ amd-gfx mailing list amd-gfx@xxxxxxxxxxxxxxxxxxxxx https://lists.freedesktop.org/mailman/listinfo/amd-gfx