* [PATCH] drm/color: un-inline drm_color_lut_extract() @ 2017-01-23 9:42 Jani Nikula 2017-01-23 10:15 ` [Intel-gfx] " Daniel Vetter 2017-01-27 9:49 ` Lionel Landwerlin 0 siblings, 2 replies; 8+ messages in thread From: Jani Nikula @ 2017-01-23 9:42 UTC (permalink / raw) To: dri-devel; +Cc: jani.nikula, intel-gfx 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 <lionel.g.landwerlin@intel.com> Signed-off-by: Jani Nikula <jani.nikula@intel.com> --- drivers/gpu/drm/drm_color_mgmt.c | 24 ++++++++++++++++++++++++ include/drm/drm_color_mgmt.h | 27 ++------------------------- 2 files changed, 26 insertions(+), 25 deletions(-) diff --git a/drivers/gpu/drm/drm_color_mgmt.c b/drivers/gpu/drm/drm_color_mgmt.c index 789b4c65cd69..5618f60c7690 100644 --- a/drivers/gpu/drm/drm_color_mgmt.c +++ b/drivers/gpu/drm/drm_color_mgmt.c @@ -88,6 +88,30 @@ */ /** + * drm_color_lut_extract - clamp&round LUT entries + * @user_input: input value + * @bit_precision: number of bits the hw LUT supports + * + * Extract a degamma/gamma LUT value provided by user (in the form of + * &drm_color_lut entries) and round it to the precision supported by the + * hardware. + */ +uint32_t drm_color_lut_extract(uint32_t user_input, uint32_t bit_precision) +{ + uint32_t val = user_input; + uint32_t max = 0xffff >> (16 - bit_precision); + + /* Round only if we're not using full precision. */ + if (bit_precision < 16) { + val += 1UL << (16 - bit_precision - 1); + val >>= 16 - bit_precision; + } + + return clamp_val(val, 0, max); +} +EXPORT_SYMBOL(drm_color_lut_extract); + +/** * drm_crtc_enable_color_mgmt - enable color management properties * @crtc: DRM CRTC * @degamma_lut_size: the size of the degamma lut (before CSC) diff --git a/include/drm/drm_color_mgmt.h b/include/drm/drm_color_mgmt.h index c767238ac9d5..bce4a532836d 100644 --- a/include/drm/drm_color_mgmt.h +++ b/include/drm/drm_color_mgmt.h @@ -25,6 +25,8 @@ #include <linux/ctype.h> +uint32_t drm_color_lut_extract(uint32_t user_input, uint32_t bit_precision); + void drm_crtc_enable_color_mgmt(struct drm_crtc *crtc, uint degamma_lut_size, bool has_ctm, @@ -33,29 +35,4 @@ void drm_crtc_enable_color_mgmt(struct drm_crtc *crtc, int drm_mode_crtc_set_gamma_size(struct drm_crtc *crtc, int gamma_size); -/** - * drm_color_lut_extract - clamp&round LUT entries - * @user_input: input value - * @bit_precision: number of bits the hw LUT supports - * - * Extract a degamma/gamma LUT value provided by user (in the form of - * &drm_color_lut entries) and round it to the precision supported by the - * hardware. - */ -static inline uint32_t drm_color_lut_extract(uint32_t user_input, - uint32_t bit_precision) -{ - uint32_t val = user_input; - uint32_t max = 0xffff >> (16 - bit_precision); - - /* Round only if we're not using full precision. */ - if (bit_precision < 16) { - val += 1UL << (16 - bit_precision - 1); - val >>= 16 - bit_precision; - } - - return clamp_val(val, 0, max); -} - - #endif -- 2.1.4 _______________________________________________ dri-devel mailing list dri-devel@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/dri-devel ^ permalink raw reply related [flat|nested] 8+ messages in thread
* Re: [Intel-gfx] [PATCH] drm/color: un-inline drm_color_lut_extract() 2017-01-23 9:42 [PATCH] drm/color: un-inline drm_color_lut_extract() Jani Nikula @ 2017-01-23 10:15 ` Daniel Vetter 2017-01-23 11:18 ` Jani Nikula 2017-01-27 9:49 ` Lionel Landwerlin 1 sibling, 1 reply; 8+ messages in thread From: Daniel Vetter @ 2017-01-23 10:15 UTC (permalink / raw) To: Jani Nikula; +Cc: intel-gfx, dri-devel On Mon, Jan 23, 2017 at 11:42:59AM +0200, Jani Nikula wrote: > 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) Not really clear to me what's going on, but if it helps ... > Cc: Lionel Landwerlin <lionel.g.landwerlin@intel.com> > Signed-off-by: Jani Nikula <jani.nikula@intel.com> Reviewed-by: Daniel Vetter <daniel.vetter@ffwll.ch> > --- > drivers/gpu/drm/drm_color_mgmt.c | 24 ++++++++++++++++++++++++ > include/drm/drm_color_mgmt.h | 27 ++------------------------- > 2 files changed, 26 insertions(+), 25 deletions(-) > > diff --git a/drivers/gpu/drm/drm_color_mgmt.c b/drivers/gpu/drm/drm_color_mgmt.c > index 789b4c65cd69..5618f60c7690 100644 > --- a/drivers/gpu/drm/drm_color_mgmt.c > +++ b/drivers/gpu/drm/drm_color_mgmt.c > @@ -88,6 +88,30 @@ > */ > > /** > + * drm_color_lut_extract - clamp&round LUT entries > + * @user_input: input value > + * @bit_precision: number of bits the hw LUT supports > + * > + * Extract a degamma/gamma LUT value provided by user (in the form of > + * &drm_color_lut entries) and round it to the precision supported by the > + * hardware. > + */ > +uint32_t drm_color_lut_extract(uint32_t user_input, uint32_t bit_precision) > +{ > + uint32_t val = user_input; > + uint32_t max = 0xffff >> (16 - bit_precision); > + > + /* Round only if we're not using full precision. */ > + if (bit_precision < 16) { > + val += 1UL << (16 - bit_precision - 1); > + val >>= 16 - bit_precision; > + } > + > + return clamp_val(val, 0, max); > +} > +EXPORT_SYMBOL(drm_color_lut_extract); > + > +/** > * drm_crtc_enable_color_mgmt - enable color management properties > * @crtc: DRM CRTC > * @degamma_lut_size: the size of the degamma lut (before CSC) > diff --git a/include/drm/drm_color_mgmt.h b/include/drm/drm_color_mgmt.h > index c767238ac9d5..bce4a532836d 100644 > --- a/include/drm/drm_color_mgmt.h > +++ b/include/drm/drm_color_mgmt.h > @@ -25,6 +25,8 @@ > > #include <linux/ctype.h> > > +uint32_t drm_color_lut_extract(uint32_t user_input, uint32_t bit_precision); > + > void drm_crtc_enable_color_mgmt(struct drm_crtc *crtc, > uint degamma_lut_size, > bool has_ctm, > @@ -33,29 +35,4 @@ void drm_crtc_enable_color_mgmt(struct drm_crtc *crtc, > int drm_mode_crtc_set_gamma_size(struct drm_crtc *crtc, > int gamma_size); > > -/** > - * drm_color_lut_extract - clamp&round LUT entries > - * @user_input: input value > - * @bit_precision: number of bits the hw LUT supports > - * > - * Extract a degamma/gamma LUT value provided by user (in the form of > - * &drm_color_lut entries) and round it to the precision supported by the > - * hardware. > - */ > -static inline uint32_t drm_color_lut_extract(uint32_t user_input, > - uint32_t bit_precision) > -{ > - uint32_t val = user_input; > - uint32_t max = 0xffff >> (16 - bit_precision); > - > - /* Round only if we're not using full precision. */ > - if (bit_precision < 16) { > - val += 1UL << (16 - bit_precision - 1); > - val >>= 16 - bit_precision; > - } > - > - return clamp_val(val, 0, max); > -} > - > - > #endif > -- > 2.1.4 > > _______________________________________________ > Intel-gfx mailing list > Intel-gfx@lists.freedesktop.org > https://lists.freedesktop.org/mailman/listinfo/intel-gfx -- Daniel Vetter Software Engineer, Intel Corporation http://blog.ffwll.ch _______________________________________________ dri-devel mailing list dri-devel@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/dri-devel ^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH] drm/color: un-inline drm_color_lut_extract() 2017-01-23 10:15 ` [Intel-gfx] " Daniel Vetter @ 2017-01-23 11:18 ` Jani Nikula 0 siblings, 0 replies; 8+ messages in thread From: Jani Nikula @ 2017-01-23 11:18 UTC (permalink / raw) To: Daniel Vetter; +Cc: intel-gfx, dri-devel On Mon, 23 Jan 2017, Daniel Vetter <daniel@ffwll.ch> wrote: > On Mon, Jan 23, 2017 at 11:42:59AM +0200, Jani Nikula wrote: >> 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) > > Not really clear to me what's going on, but if it helps ... Apparently sparse is clever enough to notice bit_precision < 16 when this is a regular function, but not when it's an inline function. The second warning we could get rid of just by changing s/1UL/1U/. BR, Jani. > >> Cc: Lionel Landwerlin <lionel.g.landwerlin@intel.com> >> Signed-off-by: Jani Nikula <jani.nikula@intel.com> > > Reviewed-by: Daniel Vetter <daniel.vetter@ffwll.ch> > >> --- >> drivers/gpu/drm/drm_color_mgmt.c | 24 ++++++++++++++++++++++++ >> include/drm/drm_color_mgmt.h | 27 ++------------------------- >> 2 files changed, 26 insertions(+), 25 deletions(-) >> >> diff --git a/drivers/gpu/drm/drm_color_mgmt.c b/drivers/gpu/drm/drm_color_mgmt.c >> index 789b4c65cd69..5618f60c7690 100644 >> --- a/drivers/gpu/drm/drm_color_mgmt.c >> +++ b/drivers/gpu/drm/drm_color_mgmt.c >> @@ -88,6 +88,30 @@ >> */ >> >> /** >> + * drm_color_lut_extract - clamp&round LUT entries >> + * @user_input: input value >> + * @bit_precision: number of bits the hw LUT supports >> + * >> + * Extract a degamma/gamma LUT value provided by user (in the form of >> + * &drm_color_lut entries) and round it to the precision supported by the >> + * hardware. >> + */ >> +uint32_t drm_color_lut_extract(uint32_t user_input, uint32_t bit_precision) >> +{ >> + uint32_t val = user_input; >> + uint32_t max = 0xffff >> (16 - bit_precision); >> + >> + /* Round only if we're not using full precision. */ >> + if (bit_precision < 16) { >> + val += 1UL << (16 - bit_precision - 1); >> + val >>= 16 - bit_precision; >> + } >> + >> + return clamp_val(val, 0, max); >> +} >> +EXPORT_SYMBOL(drm_color_lut_extract); >> + >> +/** >> * drm_crtc_enable_color_mgmt - enable color management properties >> * @crtc: DRM CRTC >> * @degamma_lut_size: the size of the degamma lut (before CSC) >> diff --git a/include/drm/drm_color_mgmt.h b/include/drm/drm_color_mgmt.h >> index c767238ac9d5..bce4a532836d 100644 >> --- a/include/drm/drm_color_mgmt.h >> +++ b/include/drm/drm_color_mgmt.h >> @@ -25,6 +25,8 @@ >> >> #include <linux/ctype.h> >> >> +uint32_t drm_color_lut_extract(uint32_t user_input, uint32_t bit_precision); >> + >> void drm_crtc_enable_color_mgmt(struct drm_crtc *crtc, >> uint degamma_lut_size, >> bool has_ctm, >> @@ -33,29 +35,4 @@ void drm_crtc_enable_color_mgmt(struct drm_crtc *crtc, >> int drm_mode_crtc_set_gamma_size(struct drm_crtc *crtc, >> int gamma_size); >> >> -/** >> - * drm_color_lut_extract - clamp&round LUT entries >> - * @user_input: input value >> - * @bit_precision: number of bits the hw LUT supports >> - * >> - * Extract a degamma/gamma LUT value provided by user (in the form of >> - * &drm_color_lut entries) and round it to the precision supported by the >> - * hardware. >> - */ >> -static inline uint32_t drm_color_lut_extract(uint32_t user_input, >> - uint32_t bit_precision) >> -{ >> - uint32_t val = user_input; >> - uint32_t max = 0xffff >> (16 - bit_precision); >> - >> - /* Round only if we're not using full precision. */ >> - if (bit_precision < 16) { >> - val += 1UL << (16 - bit_precision - 1); >> - val >>= 16 - bit_precision; >> - } >> - >> - return clamp_val(val, 0, max); >> -} >> - >> - >> #endif >> -- >> 2.1.4 >> >> _______________________________________________ >> Intel-gfx mailing list >> Intel-gfx@lists.freedesktop.org >> https://lists.freedesktop.org/mailman/listinfo/intel-gfx -- Jani Nikula, Intel Open Source Technology Center _______________________________________________ Intel-gfx mailing list Intel-gfx@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/intel-gfx ^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH] drm/color: un-inline drm_color_lut_extract() 2017-01-23 9:42 [PATCH] drm/color: un-inline drm_color_lut_extract() Jani Nikula 2017-01-23 10:15 ` [Intel-gfx] " Daniel Vetter @ 2017-01-27 9:49 ` Lionel Landwerlin 2017-01-27 11:02 ` Jani Nikula 1 sibling, 1 reply; 8+ messages in thread From: Lionel Landwerlin @ 2017-01-27 9:49 UTC (permalink / raw) To: Jani Nikula, dri-devel; +Cc: intel-gfx Hi Jani, Looks good to me : Reviewed-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com> On 23/01/17 09:42, Jani Nikula wrote: > 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 <lionel.g.landwerlin@intel.com> > Signed-off-by: Jani Nikula <jani.nikula@intel.com> > --- > drivers/gpu/drm/drm_color_mgmt.c | 24 ++++++++++++++++++++++++ > include/drm/drm_color_mgmt.h | 27 ++------------------------- > 2 files changed, 26 insertions(+), 25 deletions(-) > > diff --git a/drivers/gpu/drm/drm_color_mgmt.c b/drivers/gpu/drm/drm_color_mgmt.c > index 789b4c65cd69..5618f60c7690 100644 > --- a/drivers/gpu/drm/drm_color_mgmt.c > +++ b/drivers/gpu/drm/drm_color_mgmt.c > @@ -88,6 +88,30 @@ > */ > > /** > + * drm_color_lut_extract - clamp&round LUT entries > + * @user_input: input value > + * @bit_precision: number of bits the hw LUT supports > + * > + * Extract a degamma/gamma LUT value provided by user (in the form of > + * &drm_color_lut entries) and round it to the precision supported by the > + * hardware. > + */ > +uint32_t drm_color_lut_extract(uint32_t user_input, uint32_t bit_precision) > +{ > + uint32_t val = user_input; > + uint32_t max = 0xffff >> (16 - bit_precision); > + > + /* Round only if we're not using full precision. */ > + if (bit_precision < 16) { > + val += 1UL << (16 - bit_precision - 1); > + val >>= 16 - bit_precision; > + } > + > + return clamp_val(val, 0, max); > +} > +EXPORT_SYMBOL(drm_color_lut_extract); > + > +/** > * drm_crtc_enable_color_mgmt - enable color management properties > * @crtc: DRM CRTC > * @degamma_lut_size: the size of the degamma lut (before CSC) > diff --git a/include/drm/drm_color_mgmt.h b/include/drm/drm_color_mgmt.h > index c767238ac9d5..bce4a532836d 100644 > --- a/include/drm/drm_color_mgmt.h > +++ b/include/drm/drm_color_mgmt.h > @@ -25,6 +25,8 @@ > > #include <linux/ctype.h> > > +uint32_t drm_color_lut_extract(uint32_t user_input, uint32_t bit_precision); > + > void drm_crtc_enable_color_mgmt(struct drm_crtc *crtc, > uint degamma_lut_size, > bool has_ctm, > @@ -33,29 +35,4 @@ void drm_crtc_enable_color_mgmt(struct drm_crtc *crtc, > int drm_mode_crtc_set_gamma_size(struct drm_crtc *crtc, > int gamma_size); > > -/** > - * drm_color_lut_extract - clamp&round LUT entries > - * @user_input: input value > - * @bit_precision: number of bits the hw LUT supports > - * > - * Extract a degamma/gamma LUT value provided by user (in the form of > - * &drm_color_lut entries) and round it to the precision supported by the > - * hardware. > - */ > -static inline uint32_t drm_color_lut_extract(uint32_t user_input, > - uint32_t bit_precision) > -{ > - uint32_t val = user_input; > - uint32_t max = 0xffff >> (16 - bit_precision); > - > - /* Round only if we're not using full precision. */ > - if (bit_precision < 16) { > - val += 1UL << (16 - bit_precision - 1); > - val >>= 16 - bit_precision; > - } > - > - return clamp_val(val, 0, max); > -} > - > - > #endif _______________________________________________ dri-devel mailing list dri-devel@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/dri-devel ^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH] drm/color: un-inline drm_color_lut_extract() 2017-01-27 9:49 ` Lionel Landwerlin @ 2017-01-27 11:02 ` Jani Nikula 2017-01-27 14:36 ` Jani Nikula 0 siblings, 1 reply; 8+ messages in thread From: Jani Nikula @ 2017-01-27 11:02 UTC (permalink / raw) To: Lionel Landwerlin, dri-devel; +Cc: Daniel Vetter, intel-gfx On Fri, 27 Jan 2017, Lionel Landwerlin <lionel.g.landwerlin@intel.com> wrote: > Hi Jani, > > Looks good to me : > > Reviewed-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com> Thanks for the reviews, pushed... to drm-intel-next-queued instead of drm-misc-next. /o\ Dave, Daniel, please advise, shall I revert or shall we let this flow in via drm-intel? Sorry for the mess. BR, Jani. > > On 23/01/17 09:42, Jani Nikula wrote: >> 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 <lionel.g.landwerlin@intel.com> >> Signed-off-by: Jani Nikula <jani.nikula@intel.com> >> --- >> drivers/gpu/drm/drm_color_mgmt.c | 24 ++++++++++++++++++++++++ >> include/drm/drm_color_mgmt.h | 27 ++------------------------- >> 2 files changed, 26 insertions(+), 25 deletions(-) >> >> diff --git a/drivers/gpu/drm/drm_color_mgmt.c b/drivers/gpu/drm/drm_color_mgmt.c >> index 789b4c65cd69..5618f60c7690 100644 >> --- a/drivers/gpu/drm/drm_color_mgmt.c >> +++ b/drivers/gpu/drm/drm_color_mgmt.c >> @@ -88,6 +88,30 @@ >> */ >> >> /** >> + * drm_color_lut_extract - clamp&round LUT entries >> + * @user_input: input value >> + * @bit_precision: number of bits the hw LUT supports >> + * >> + * Extract a degamma/gamma LUT value provided by user (in the form of >> + * &drm_color_lut entries) and round it to the precision supported by the >> + * hardware. >> + */ >> +uint32_t drm_color_lut_extract(uint32_t user_input, uint32_t bit_precision) >> +{ >> + uint32_t val = user_input; >> + uint32_t max = 0xffff >> (16 - bit_precision); >> + >> + /* Round only if we're not using full precision. */ >> + if (bit_precision < 16) { >> + val += 1UL << (16 - bit_precision - 1); >> + val >>= 16 - bit_precision; >> + } >> + >> + return clamp_val(val, 0, max); >> +} >> +EXPORT_SYMBOL(drm_color_lut_extract); >> + >> +/** >> * drm_crtc_enable_color_mgmt - enable color management properties >> * @crtc: DRM CRTC >> * @degamma_lut_size: the size of the degamma lut (before CSC) >> diff --git a/include/drm/drm_color_mgmt.h b/include/drm/drm_color_mgmt.h >> index c767238ac9d5..bce4a532836d 100644 >> --- a/include/drm/drm_color_mgmt.h >> +++ b/include/drm/drm_color_mgmt.h >> @@ -25,6 +25,8 @@ >> >> #include <linux/ctype.h> >> >> +uint32_t drm_color_lut_extract(uint32_t user_input, uint32_t bit_precision); >> + >> void drm_crtc_enable_color_mgmt(struct drm_crtc *crtc, >> uint degamma_lut_size, >> bool has_ctm, >> @@ -33,29 +35,4 @@ void drm_crtc_enable_color_mgmt(struct drm_crtc *crtc, >> int drm_mode_crtc_set_gamma_size(struct drm_crtc *crtc, >> int gamma_size); >> >> -/** >> - * drm_color_lut_extract - clamp&round LUT entries >> - * @user_input: input value >> - * @bit_precision: number of bits the hw LUT supports >> - * >> - * Extract a degamma/gamma LUT value provided by user (in the form of >> - * &drm_color_lut entries) and round it to the precision supported by the >> - * hardware. >> - */ >> -static inline uint32_t drm_color_lut_extract(uint32_t user_input, >> - uint32_t bit_precision) >> -{ >> - uint32_t val = user_input; >> - uint32_t max = 0xffff >> (16 - bit_precision); >> - >> - /* Round only if we're not using full precision. */ >> - if (bit_precision < 16) { >> - val += 1UL << (16 - bit_precision - 1); >> - val >>= 16 - bit_precision; >> - } >> - >> - return clamp_val(val, 0, max); >> -} >> - >> - >> #endif > > -- Jani Nikula, Intel Open Source Technology Center _______________________________________________ Intel-gfx mailing list Intel-gfx@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/intel-gfx ^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH] drm/color: un-inline drm_color_lut_extract() 2017-01-27 11:02 ` Jani Nikula @ 2017-01-27 14:36 ` Jani Nikula 2017-01-27 15:34 ` [PATCH v2] " Jani Nikula 0 siblings, 1 reply; 8+ messages in thread From: Jani Nikula @ 2017-01-27 14:36 UTC (permalink / raw) To: Lionel Landwerlin, dri-devel; +Cc: Daniel Vetter, intel-gfx On Fri, 27 Jan 2017, Jani Nikula <jani.nikula@intel.com> wrote: > On Fri, 27 Jan 2017, Lionel Landwerlin <lionel.g.landwerlin@intel.com> wrote: >> Hi Jani, >> >> Looks good to me : >> >> Reviewed-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com> > > Thanks for the reviews, pushed... to drm-intel-next-queued instead of > drm-misc-next. /o\ > > Dave, Daniel, please advise, shall I revert or shall we let this flow in > via drm-intel? > > Sorry for the mess. Reverted, there was a conflict in the docs updates as well so this is easier. I'll post a rebase version of the patch. BR, Jani. > > BR, > Jani. > > > >> >> On 23/01/17 09:42, Jani Nikula wrote: >>> 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 <lionel.g.landwerlin@intel.com> >>> Signed-off-by: Jani Nikula <jani.nikula@intel.com> >>> --- >>> drivers/gpu/drm/drm_color_mgmt.c | 24 ++++++++++++++++++++++++ >>> include/drm/drm_color_mgmt.h | 27 ++------------------------- >>> 2 files changed, 26 insertions(+), 25 deletions(-) >>> >>> diff --git a/drivers/gpu/drm/drm_color_mgmt.c b/drivers/gpu/drm/drm_color_mgmt.c >>> index 789b4c65cd69..5618f60c7690 100644 >>> --- a/drivers/gpu/drm/drm_color_mgmt.c >>> +++ b/drivers/gpu/drm/drm_color_mgmt.c >>> @@ -88,6 +88,30 @@ >>> */ >>> >>> /** >>> + * drm_color_lut_extract - clamp&round LUT entries >>> + * @user_input: input value >>> + * @bit_precision: number of bits the hw LUT supports >>> + * >>> + * Extract a degamma/gamma LUT value provided by user (in the form of >>> + * &drm_color_lut entries) and round it to the precision supported by the >>> + * hardware. >>> + */ >>> +uint32_t drm_color_lut_extract(uint32_t user_input, uint32_t bit_precision) >>> +{ >>> + uint32_t val = user_input; >>> + uint32_t max = 0xffff >> (16 - bit_precision); >>> + >>> + /* Round only if we're not using full precision. */ >>> + if (bit_precision < 16) { >>> + val += 1UL << (16 - bit_precision - 1); >>> + val >>= 16 - bit_precision; >>> + } >>> + >>> + return clamp_val(val, 0, max); >>> +} >>> +EXPORT_SYMBOL(drm_color_lut_extract); >>> + >>> +/** >>> * drm_crtc_enable_color_mgmt - enable color management properties >>> * @crtc: DRM CRTC >>> * @degamma_lut_size: the size of the degamma lut (before CSC) >>> diff --git a/include/drm/drm_color_mgmt.h b/include/drm/drm_color_mgmt.h >>> index c767238ac9d5..bce4a532836d 100644 >>> --- a/include/drm/drm_color_mgmt.h >>> +++ b/include/drm/drm_color_mgmt.h >>> @@ -25,6 +25,8 @@ >>> >>> #include <linux/ctype.h> >>> >>> +uint32_t drm_color_lut_extract(uint32_t user_input, uint32_t bit_precision); >>> + >>> void drm_crtc_enable_color_mgmt(struct drm_crtc *crtc, >>> uint degamma_lut_size, >>> bool has_ctm, >>> @@ -33,29 +35,4 @@ void drm_crtc_enable_color_mgmt(struct drm_crtc *crtc, >>> int drm_mode_crtc_set_gamma_size(struct drm_crtc *crtc, >>> int gamma_size); >>> >>> -/** >>> - * drm_color_lut_extract - clamp&round LUT entries >>> - * @user_input: input value >>> - * @bit_precision: number of bits the hw LUT supports >>> - * >>> - * Extract a degamma/gamma LUT value provided by user (in the form of >>> - * &drm_color_lut entries) and round it to the precision supported by the >>> - * hardware. >>> - */ >>> -static inline uint32_t drm_color_lut_extract(uint32_t user_input, >>> - uint32_t bit_precision) >>> -{ >>> - uint32_t val = user_input; >>> - uint32_t max = 0xffff >> (16 - bit_precision); >>> - >>> - /* Round only if we're not using full precision. */ >>> - if (bit_precision < 16) { >>> - val += 1UL << (16 - bit_precision - 1); >>> - val >>= 16 - bit_precision; >>> - } >>> - >>> - return clamp_val(val, 0, max); >>> -} >>> - >>> - >>> #endif >> >> -- Jani Nikula, Intel Open Source Technology Center _______________________________________________ Intel-gfx mailing list Intel-gfx@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/intel-gfx ^ permalink raw reply [flat|nested] 8+ messages in thread
* [PATCH v2] drm/color: un-inline drm_color_lut_extract() 2017-01-27 14:36 ` Jani Nikula @ 2017-01-27 15:34 ` Jani Nikula 2017-01-31 13:39 ` Jani Nikula 0 siblings, 1 reply; 8+ messages in thread From: Jani Nikula @ 2017-01-27 15:34 UTC (permalink / raw) To: Jani Nikula, Lionel Landwerlin, dri-devel; +Cc: Daniel Vetter, intel-gfx 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) v2: rebased Cc: Lionel Landwerlin <lionel.g.landwerlin@intel.com> Reviewed-by: Daniel Vetter <daniel.vetter@ffwll.ch> Reviewed-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com> Signed-off-by: Jani Nikula <jani.nikula@intel.com> --- drivers/gpu/drm/drm_color_mgmt.c | 24 ++++++++++++++++++++++++ include/drm/drm_color_mgmt.h | 27 ++------------------------- 2 files changed, 26 insertions(+), 25 deletions(-) diff --git a/drivers/gpu/drm/drm_color_mgmt.c b/drivers/gpu/drm/drm_color_mgmt.c index 789b4c65cd69..cc23b9a505c0 100644 --- a/drivers/gpu/drm/drm_color_mgmt.c +++ b/drivers/gpu/drm/drm_color_mgmt.c @@ -88,6 +88,30 @@ */ /** + * drm_color_lut_extract - clamp and round LUT entries + * @user_input: input value + * @bit_precision: number of bits the hw LUT supports + * + * Extract a degamma/gamma LUT value provided by user (in the form of + * &drm_color_lut entries) and round it to the precision supported by the + * hardware. + */ +uint32_t drm_color_lut_extract(uint32_t user_input, uint32_t bit_precision) +{ + uint32_t val = user_input; + uint32_t max = 0xffff >> (16 - bit_precision); + + /* Round only if we're not using full precision. */ + if (bit_precision < 16) { + val += 1UL << (16 - bit_precision - 1); + val >>= 16 - bit_precision; + } + + return clamp_val(val, 0, max); +} +EXPORT_SYMBOL(drm_color_lut_extract); + +/** * drm_crtc_enable_color_mgmt - enable color management properties * @crtc: DRM CRTC * @degamma_lut_size: the size of the degamma lut (before CSC) diff --git a/include/drm/drm_color_mgmt.h b/include/drm/drm_color_mgmt.h index d9c2f680f5ae..bce4a532836d 100644 --- a/include/drm/drm_color_mgmt.h +++ b/include/drm/drm_color_mgmt.h @@ -25,6 +25,8 @@ #include <linux/ctype.h> +uint32_t drm_color_lut_extract(uint32_t user_input, uint32_t bit_precision); + void drm_crtc_enable_color_mgmt(struct drm_crtc *crtc, uint degamma_lut_size, bool has_ctm, @@ -33,29 +35,4 @@ void drm_crtc_enable_color_mgmt(struct drm_crtc *crtc, int drm_mode_crtc_set_gamma_size(struct drm_crtc *crtc, int gamma_size); -/** - * drm_color_lut_extract - clamp and round LUT entries - * @user_input: input value - * @bit_precision: number of bits the hw LUT supports - * - * Extract a degamma/gamma LUT value provided by user (in the form of - * &drm_color_lut entries) and round it to the precision supported by the - * hardware. - */ -static inline uint32_t drm_color_lut_extract(uint32_t user_input, - uint32_t bit_precision) -{ - uint32_t val = user_input; - uint32_t max = 0xffff >> (16 - bit_precision); - - /* Round only if we're not using full precision. */ - if (bit_precision < 16) { - val += 1UL << (16 - bit_precision - 1); - val >>= 16 - bit_precision; - } - - return clamp_val(val, 0, max); -} - - #endif -- 2.1.4 _______________________________________________ dri-devel mailing list dri-devel@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/dri-devel ^ permalink raw reply related [flat|nested] 8+ messages in thread
* Re: [PATCH v2] drm/color: un-inline drm_color_lut_extract() 2017-01-27 15:34 ` [PATCH v2] " Jani Nikula @ 2017-01-31 13:39 ` Jani Nikula 0 siblings, 0 replies; 8+ messages in thread From: Jani Nikula @ 2017-01-31 13:39 UTC (permalink / raw) To: Lionel Landwerlin, dri-devel; +Cc: Daniel Vetter, intel-gfx On Fri, 27 Jan 2017, Jani Nikula <jani.nikula@intel.com> wrote: > 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) > > v2: rebased > > Cc: Lionel Landwerlin <lionel.g.landwerlin@intel.com> > Reviewed-by: Daniel Vetter <daniel.vetter@ffwll.ch> > Reviewed-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com> > Signed-off-by: Jani Nikula <jani.nikula@intel.com> This time, pushed to drm-misc-next. Thanks for the review. BR, Jani. > --- > drivers/gpu/drm/drm_color_mgmt.c | 24 ++++++++++++++++++++++++ > include/drm/drm_color_mgmt.h | 27 ++------------------------- > 2 files changed, 26 insertions(+), 25 deletions(-) > > diff --git a/drivers/gpu/drm/drm_color_mgmt.c b/drivers/gpu/drm/drm_color_mgmt.c > index 789b4c65cd69..cc23b9a505c0 100644 > --- a/drivers/gpu/drm/drm_color_mgmt.c > +++ b/drivers/gpu/drm/drm_color_mgmt.c > @@ -88,6 +88,30 @@ > */ > > /** > + * drm_color_lut_extract - clamp and round LUT entries > + * @user_input: input value > + * @bit_precision: number of bits the hw LUT supports > + * > + * Extract a degamma/gamma LUT value provided by user (in the form of > + * &drm_color_lut entries) and round it to the precision supported by the > + * hardware. > + */ > +uint32_t drm_color_lut_extract(uint32_t user_input, uint32_t bit_precision) > +{ > + uint32_t val = user_input; > + uint32_t max = 0xffff >> (16 - bit_precision); > + > + /* Round only if we're not using full precision. */ > + if (bit_precision < 16) { > + val += 1UL << (16 - bit_precision - 1); > + val >>= 16 - bit_precision; > + } > + > + return clamp_val(val, 0, max); > +} > +EXPORT_SYMBOL(drm_color_lut_extract); > + > +/** > * drm_crtc_enable_color_mgmt - enable color management properties > * @crtc: DRM CRTC > * @degamma_lut_size: the size of the degamma lut (before CSC) > diff --git a/include/drm/drm_color_mgmt.h b/include/drm/drm_color_mgmt.h > index d9c2f680f5ae..bce4a532836d 100644 > --- a/include/drm/drm_color_mgmt.h > +++ b/include/drm/drm_color_mgmt.h > @@ -25,6 +25,8 @@ > > #include <linux/ctype.h> > > +uint32_t drm_color_lut_extract(uint32_t user_input, uint32_t bit_precision); > + > void drm_crtc_enable_color_mgmt(struct drm_crtc *crtc, > uint degamma_lut_size, > bool has_ctm, > @@ -33,29 +35,4 @@ void drm_crtc_enable_color_mgmt(struct drm_crtc *crtc, > int drm_mode_crtc_set_gamma_size(struct drm_crtc *crtc, > int gamma_size); > > -/** > - * drm_color_lut_extract - clamp and round LUT entries > - * @user_input: input value > - * @bit_precision: number of bits the hw LUT supports > - * > - * Extract a degamma/gamma LUT value provided by user (in the form of > - * &drm_color_lut entries) and round it to the precision supported by the > - * hardware. > - */ > -static inline uint32_t drm_color_lut_extract(uint32_t user_input, > - uint32_t bit_precision) > -{ > - uint32_t val = user_input; > - uint32_t max = 0xffff >> (16 - bit_precision); > - > - /* Round only if we're not using full precision. */ > - if (bit_precision < 16) { > - val += 1UL << (16 - bit_precision - 1); > - val >>= 16 - bit_precision; > - } > - > - return clamp_val(val, 0, max); > -} > - > - > #endif -- Jani Nikula, Intel Open Source Technology Center _______________________________________________ Intel-gfx mailing list Intel-gfx@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/intel-gfx ^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2017-01-31 13:39 UTC | newest] Thread overview: 8+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2017-01-23 9:42 [PATCH] drm/color: un-inline drm_color_lut_extract() Jani Nikula 2017-01-23 10:15 ` [Intel-gfx] " Daniel Vetter 2017-01-23 11:18 ` Jani Nikula 2017-01-27 9:49 ` Lionel Landwerlin 2017-01-27 11:02 ` Jani Nikula 2017-01-27 14:36 ` Jani Nikula 2017-01-27 15:34 ` [PATCH v2] " Jani Nikula 2017-01-31 13:39 ` Jani Nikula
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for NNTP newsgroup(s).