diff options
Diffstat (limited to 'drivers/gpu/drm/amd/display/include/fixed31_32.h')
-rw-r--r-- | drivers/gpu/drm/amd/display/include/fixed31_32.h | 15 |
1 files changed, 13 insertions, 2 deletions
diff --git a/drivers/gpu/drm/amd/display/include/fixed31_32.h b/drivers/gpu/drm/amd/display/include/fixed31_32.h index f0bc3c4afe02..2c9e2231ef06 100644 --- a/drivers/gpu/drm/amd/display/include/fixed31_32.h +++ b/drivers/gpu/drm/amd/display/include/fixed31_32.h @@ -28,6 +28,8 @@ #include "os_types.h" +#define FIXED31_32_BITS_PER_FRACTIONAL_PART 32 + /* * @brief * Arithmetic operations on real numbers @@ -78,8 +80,17 @@ struct fixed31_32 dal_fixed31_32_from_fraction( * @brief * result = arg */ -struct fixed31_32 dal_fixed31_32_from_int( - int64_t arg); +struct fixed31_32 dal_fixed31_32_from_int_nonconst(int64_t arg); +static inline struct fixed31_32 dal_fixed31_32_from_int(int64_t arg) +{ + if (__builtin_constant_p(arg)) { + struct fixed31_32 res; + BUILD_BUG_ON((LONG_MIN > arg) || (arg > LONG_MAX)); + res.value = arg << FIXED31_32_BITS_PER_FRACTIONAL_PART; + return res; + } else + return dal_fixed31_32_from_int_nonconst(arg); +} /* * @brief |