Skip to content

Commit 2eebe4f

Browse files
committed
drm/color: un-inline drm_color_lut_extract()
The function is not that big, but it's also not used for anything performance critical. Make it a normal function. As a side effect, this apparently makes sparse smarter about what it's doing, and gets rid of the warning: ./include/drm/drm_color_mgmt.h:53:28: warning: shift too big (4294967295) for type unsigned long ./include/drm/drm_color_mgmt.h:53:28: warning: cast truncates bits from constant value (8000000000000000 becomes 0) Cc: Lionel Landwerlin <[email protected]> Reviewed-by: Daniel Vetter <[email protected]> Reviewed-by: Lionel Landwerlin <[email protected]> Signed-off-by: Jani Nikula <[email protected]> Link: http://patchwork.freedesktop.org/patch/msgid/[email protected]
1 parent bc384c7 commit 2eebe4f

File tree

2 files changed

+26
-25
lines changed

2 files changed

+26
-25
lines changed

drivers/gpu/drm/drm_color_mgmt.c

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,30 @@
8787
* "GAMMA_LUT" property above.
8888
*/
8989

90+
/**
91+
* drm_color_lut_extract - clamp&round LUT entries
92+
* @user_input: input value
93+
* @bit_precision: number of bits the hw LUT supports
94+
*
95+
* Extract a degamma/gamma LUT value provided by user (in the form of
96+
* &drm_color_lut entries) and round it to the precision supported by the
97+
* hardware.
98+
*/
99+
uint32_t drm_color_lut_extract(uint32_t user_input, uint32_t bit_precision)
100+
{
101+
uint32_t val = user_input;
102+
uint32_t max = 0xffff >> (16 - bit_precision);
103+
104+
/* Round only if we're not using full precision. */
105+
if (bit_precision < 16) {
106+
val += 1UL << (16 - bit_precision - 1);
107+
val >>= 16 - bit_precision;
108+
}
109+
110+
return clamp_val(val, 0, max);
111+
}
112+
EXPORT_SYMBOL(drm_color_lut_extract);
113+
90114
/**
91115
* drm_crtc_enable_color_mgmt - enable color management properties
92116
* @crtc: DRM CRTC

include/drm/drm_color_mgmt.h

Lines changed: 2 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@
2525

2626
#include <linux/ctype.h>
2727

28+
uint32_t drm_color_lut_extract(uint32_t user_input, uint32_t bit_precision);
29+
2830
void drm_crtc_enable_color_mgmt(struct drm_crtc *crtc,
2931
uint degamma_lut_size,
3032
bool has_ctm,
@@ -33,29 +35,4 @@ void drm_crtc_enable_color_mgmt(struct drm_crtc *crtc,
3335
int drm_mode_crtc_set_gamma_size(struct drm_crtc *crtc,
3436
int gamma_size);
3537

36-
/**
37-
* drm_color_lut_extract - clamp&round LUT entries
38-
* @user_input: input value
39-
* @bit_precision: number of bits the hw LUT supports
40-
*
41-
* Extract a degamma/gamma LUT value provided by user (in the form of
42-
* &drm_color_lut entries) and round it to the precision supported by the
43-
* hardware.
44-
*/
45-
static inline uint32_t drm_color_lut_extract(uint32_t user_input,
46-
uint32_t bit_precision)
47-
{
48-
uint32_t val = user_input;
49-
uint32_t max = 0xffff >> (16 - bit_precision);
50-
51-
/* Round only if we're not using full precision. */
52-
if (bit_precision < 16) {
53-
val += 1UL << (16 - bit_precision - 1);
54-
val >>= 16 - bit_precision;
55-
}
56-
57-
return clamp_val(val, 0, max);
58-
}
59-
60-
6138
#endif

0 commit comments

Comments
 (0)