diff options
author | Dave Airlie <airlied@redhat.com> | 2017-09-29 17:13:26 +1000 |
---|---|---|
committer | Alex Deucher <alexander.deucher@amd.com> | 2017-09-29 13:03:43 -0400 |
commit | c233e91b0f3f7c9abc80eae491fa6507a24a8a32 (patch) | |
tree | 0d3caca7e98f32c8844e80d511f70324dca295b3 /drivers/gpu/drm/amd/display/include | |
parent | dfd1e5ce673b8b2557d622dc99735e2d7ad5ba5b (diff) |
amdgpu/dc: use the builtin constant p trick on the 31/32 fixed point.
This only gets us 100 bytes, but may as well be consistent.
Signed-off-by: Dave Airlie <airlied@redhat.com>
Reviewed-by: Harry Wentland <harry.wentland@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
Diffstat (limited to 'drivers/gpu/drm/amd/display/include')
-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 |