From 22f51a690cff85c9d26a5d9bd028b25bbdba7e45 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ma=C3=ADra=20Canal?= <maira.canal@usp.br> Date: Tue, 7 Jun 2022 20:35:07 -0300 Subject: [PATCH] drm/amd/display: Move bw_fixed macros to header file MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The macros defined at bw_fixed are important mathematical definitions, specifying masks to get the fractional part and the maximum and minimum values of I64. In order to enable unit tests for bw_fixed, it is relevant to have access to those macros. This commit moves the macros to the header file, making it accessible to future unit tests. Co-developed-by: Magali Lemes <magalilemes00@gmail.com> Signed-off-by: Magali Lemes <magalilemes00@gmail.com> Signed-off-by: MaÃra Canal <maira.canal@usp.br> Co-developed-by: Tales Aparecida <tales.aparecida@gmail.com> Signed-off-by: Tales Aparecida <tales.aparecida@gmail.com> --- .../gpu/drm/amd/display/dc/dml/calcs/bw_fixed.c | 14 +------------- drivers/gpu/drm/amd/display/dc/inc/bw_fixed.h | 14 ++++++++++++++ 2 files changed, 15 insertions(+), 13 deletions(-) diff --git a/drivers/gpu/drm/amd/display/dc/dml/calcs/bw_fixed.c b/drivers/gpu/drm/amd/display/dc/dml/calcs/bw_fixed.c index 6ca288fb5fb9e..d944570e56956 100644 --- a/drivers/gpu/drm/amd/display/dc/dml/calcs/bw_fixed.c +++ b/drivers/gpu/drm/amd/display/dc/dml/calcs/bw_fixed.c @@ -26,19 +26,7 @@ #include "bw_fixed.h" -#define MIN_I64 \ - (int64_t)(-(1LL << 63)) - -#define MAX_I64 \ - (int64_t)((1ULL << 63) - 1) - -#define FRACTIONAL_PART_MASK \ - ((1ULL << BW_FIXED_BITS_PER_FRACTIONAL_PART) - 1) - -#define GET_FRACTIONAL_PART(x) \ - (FRACTIONAL_PART_MASK & (x)) - -static uint64_t abs_i64(int64_t arg) +uint64_t abs_i64(int64_t arg) { if (arg >= 0) return (uint64_t)(arg); diff --git a/drivers/gpu/drm/amd/display/dc/inc/bw_fixed.h b/drivers/gpu/drm/amd/display/dc/inc/bw_fixed.h index d1656c9d50dfe..064839425b968 100644 --- a/drivers/gpu/drm/amd/display/dc/inc/bw_fixed.h +++ b/drivers/gpu/drm/amd/display/dc/inc/bw_fixed.h @@ -33,12 +33,26 @@ struct bw_fixed { int64_t value; }; +#define MIN_I64 \ + (int64_t)(-(1ULL << 63)) + +#define MAX_I64 \ + (int64_t)((1ULL << 63) - 1) + +#define FRACTIONAL_PART_MASK \ + ((1ULL << BW_FIXED_BITS_PER_FRACTIONAL_PART) - 1) + +#define GET_FRACTIONAL_PART(x) \ + (FRACTIONAL_PART_MASK & (x)) + #define BW_FIXED_MIN_I32 \ (int64_t)(-(1LL << (63 - BW_FIXED_BITS_PER_FRACTIONAL_PART))) #define BW_FIXED_MAX_I32 \ (int64_t)((1ULL << (63 - BW_FIXED_BITS_PER_FRACTIONAL_PART)) - 1) +uint64_t abs_i64(int64_t arg); + static inline struct bw_fixed bw_min2(const struct bw_fixed arg1, const struct bw_fixed arg2) { -- GitLab