[PATCH 1/5] drm: Add drm_fixed_16_16 helper

From: Alyssa Rosenzweig
Date: Wed Sep 01 2021 - 13:54:50 EST


This constructs a fixed 16.16 rational, useful to specify the minimum
and maximum scaling in drm_atomic_helper_check_plane_state. It is
open-coded as a macro in multiple drivers, so let's share the helper.

Signed-off-by: Alyssa Rosenzweig <alyssa@xxxxxxxxxxxxx>
---
include/drm/drm_fixed.h | 5 +++++
1 file changed, 5 insertions(+)

diff --git a/include/drm/drm_fixed.h b/include/drm/drm_fixed.h
index 553210c02ee0..df1f369b4918 100644
--- a/include/drm/drm_fixed.h
+++ b/include/drm/drm_fixed.h
@@ -208,4 +208,9 @@ static inline s64 drm_fixp_exp(s64 x)
return sum;
}

+static inline int drm_fixed_16_16(s32 mult, s32 div)
+{
+ return (mult << 16) / div;
+}
+
#endif
--
2.30.2