From 7f357f18dcf4910dd5b224696fa776d3329eafaa Mon Sep 17 00:00:00 2001 From: jsg Date: Thu, 20 Jul 2023 08:33:02 +0000 Subject: [PATCH] drm: Add fixed-point helper to get rounded integer values From Maira Canal 048b7168acf85cb856b0db1d0483584cfff3498f in linux-6.1.y/6.1.39 8b25320887d7feac98875546ea0f521628b745bb in mainline linux --- sys/dev/pci/drm/include/drm/drm_fixed.h | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/sys/dev/pci/drm/include/drm/drm_fixed.h b/sys/dev/pci/drm/include/drm/drm_fixed.h index 553210c02ee..03cb890690e 100644 --- a/sys/dev/pci/drm/include/drm/drm_fixed.h +++ b/sys/dev/pci/drm/include/drm/drm_fixed.h @@ -70,6 +70,7 @@ static inline u32 dfixed_div(fixed20_12 A, fixed20_12 B) } #define DRM_FIXED_POINT 32 +#define DRM_FIXED_POINT_HALF 16 #define DRM_FIXED_ONE (1ULL << DRM_FIXED_POINT) #define DRM_FIXED_DECIMAL_MASK (DRM_FIXED_ONE - 1) #define DRM_FIXED_DIGITS_MASK (~DRM_FIXED_DECIMAL_MASK) @@ -86,6 +87,11 @@ static inline int drm_fixp2int(s64 a) return ((s64)a) >> DRM_FIXED_POINT; } +static inline int drm_fixp2int_round(s64 a) +{ + return drm_fixp2int(a + (1 << (DRM_FIXED_POINT_HALF - 1))); +} + static inline int drm_fixp2int_ceil(s64 a) { if (a > 0) -- 2.20.1