From: Jani Nikula <jani.nikula@intel.com>
To: Swati Sharma <swati2.sharma@intel.com>, intel-gfx@lists.freedesktop.org
Cc: daniel.vetter@ffwll.ch, ankit.k.nautiyal@intel.com
Subject: Re: [PATCH 11/11] [v4] drm/i915: Add intel_color_lut_equal() to compare hw and sw gamma lut values
Date: Thu, 25 Apr 2019 15:35:35 +0300 [thread overview]
Message-ID: <87zhoes1ns.fsf@intel.com> (raw)
In-Reply-To: <1555509813-9021-12-git-send-email-swati2.sharma@intel.com>
On Wed, 17 Apr 2019, Swati Sharma <swati2.sharma@intel.com> wrote:
> v3: Rebase
> v4: -Renamed intel_compare_color_lut() to intel_color_lut_equal() (Jani)
> -Added the default label above the correct label (Jani)
> -Corrected smatch warn "variable dereferenced before check" (Dan Carpenter)
>
> Signed-off-by: Swati Sharma <swati2.sharma@intel.com>
> ---
> drivers/gpu/drm/i915/intel_color.c | 50 ++++++++++++++++++++++++++++++++++++
> drivers/gpu/drm/i915/intel_color.h | 7 +++++
> drivers/gpu/drm/i915/intel_display.c | 10 ++++++++
> 3 files changed, 67 insertions(+)
>
> diff --git a/drivers/gpu/drm/i915/intel_color.c b/drivers/gpu/drm/i915/intel_color.c
> index 731cb97..592c328 100644
> --- a/drivers/gpu/drm/i915/intel_color.c
> +++ b/drivers/gpu/drm/i915/intel_color.c
> @@ -1495,6 +1495,56 @@ static void ilk_get_color_config(struct intel_crtc_state *crtc_state)
> ilk_get_gamma_config(crtc_state);
> }
>
> +static inline bool gamma_err_check(struct drm_color_lut *sw_lut, struct drm_color_lut *hw_lut, u32 err)
> +{
> + return ((abs((long)hw_lut->red - sw_lut->red)) >= err) ||
> + ((abs((long)hw_lut->blue - sw_lut->blue)) >= err) ||
> + ((abs((long)hw_lut->green - sw_lut->green)) >= err);
> +}
> +
> +bool intel_color_lut_equal(struct drm_property_blob *blob1,
> + struct drm_property_blob *blob2,
> + u32 gamma_mode)
> +{
> + struct drm_color_lut *sw_lut, *hw_lut;
> + int sw_lut_size, hw_lut_size, i;
> + u32 bit_precision, err;
> +
> + if (!blob1 || !blob2)
> + return false;
(!blob1 && !blob2) must return true, right?
> +
> + sw_lut = blob1->data;
> + hw_lut = blob2->data;
> +
> + switch(gamma_mode) {
> + default:
> + case GAMMA_MODE_MODE_8BIT:
> + bit_precision = 8;
> + break;
> + case GAMMA_MODE_MODE_10BIT:
> + bit_precision = 10;
> + break;
> + case GAMMA_MODE_MODE_12BIT:
> + bit_precision = 12;
> + break;
> + }
> +
> + err = 0xffff >> bit_precision;
> +
> + sw_lut_size = drm_color_lut_size(blob1);
> + hw_lut_size = drm_color_lut_size(blob2);
> +
> + if (sw_lut_size != hw_lut_size)
> + return false;
> +
> + for (i = 0; i < sw_lut_size; i++) {
> + if (!gamma_err_check(&hw_lut[i], &sw_lut[i], err))
> + return false;
> + }
> +
> + return true;
> +}
> +
> void intel_color_init(struct intel_crtc *crtc)
> {
> struct drm_i915_private *dev_priv = to_i915(crtc->base.dev);
> diff --git a/drivers/gpu/drm/i915/intel_color.h b/drivers/gpu/drm/i915/intel_color.h
> index 057e8ac..2ae615e 100644
> --- a/drivers/gpu/drm/i915/intel_color.h
> +++ b/drivers/gpu/drm/i915/intel_color.h
> @@ -6,13 +6,20 @@
> #ifndef __INTEL_COLOR_H__
> #define __INTEL_COLOR_H__
>
> +
> +#include <linux/types.h>
> +
> struct intel_crtc_state;
> struct intel_crtc;
> +struct drm_property_blob;
>
> void intel_color_init(struct intel_crtc *crtc);
> int intel_color_check(struct intel_crtc_state *crtc_state);
> void intel_color_commit(const struct intel_crtc_state *crtc_state);
> void intel_color_load_luts(const struct intel_crtc_state *crtc_state);
> void intel_color_get_config(struct intel_crtc_state *crtc_state);
> +bool intel_color_lut_equal(struct drm_property_blob *blob1,
> + struct drm_property_blob *blob2,
> + u32 gamma_mode);
>
> #endif /* __INTEL_COLOR_H__ */
> diff --git a/drivers/gpu/drm/i915/intel_display.c b/drivers/gpu/drm/i915/intel_display.c
> index 0715b4e..bb1ccd7 100644
> --- a/drivers/gpu/drm/i915/intel_display.c
> +++ b/drivers/gpu/drm/i915/intel_display.c
> @@ -12236,6 +12236,14 @@ static bool fastboot_enabled(struct drm_i915_private *dev_priv)
> } \
> } while (0)
>
> +#define PIPE_CONF_CHECK_COLOR_LUT(name, gamma_mode) do { \
> + if (!intel_color_lut_equal(current_config->name, pipe_config->name, gamma_mode)) { \
> + pipe_config_err(adjust, __stringify(name), \
> + "hw_state doesn't match sw_state\n"); \
> + ret = false; \
> + } \
> +} while (0)
> +
> #define PIPE_CONF_QUIRK(quirk) \
> ((current_config->quirks | pipe_config->quirks) & (quirk))
>
> @@ -12379,6 +12387,8 @@ static bool fastboot_enabled(struct drm_i915_private *dev_priv)
> PIPE_CONF_CHECK_INFOFRAME(spd);
> PIPE_CONF_CHECK_INFOFRAME(hdmi);
>
> + PIPE_CONF_CHECK_COLOR_LUT(base.gamma_lut, pipe_config->gamma_mode);
> +
Hmm, we check gamma_mode and gamma_enable within if (!adjust), I suppose
this should be there too.
> #undef PIPE_CONF_CHECK_X
> #undef PIPE_CONF_CHECK_I
> #undef PIPE_CONF_CHECK_BOOL
Please add
#undef PIPE_CONF_CHECK_COLOR_LUT
--
Jani Nikula, Intel Open Source Graphics Center
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
next prev parent reply other threads:[~2019-04-25 12:33 UTC|newest]
Thread overview: 23+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-04-17 14:03 [PATCH 00/11] drm/i915: adding state checker for gamma lut values Swati Sharma
2019-04-17 14:03 ` [PATCH 01/11] [v4] drm/i915: Introduce vfunc intel_get_color_config to create hw lut Swati Sharma
2019-04-17 14:03 ` [PATCH 02/11] [v4] drm/i915: Enable intel_color_get_config() Swati Sharma
2019-04-23 15:57 ` Ville Syrjälä
2019-04-17 14:03 ` [PATCH 03/11] [v4] drm/i915: Extract i9xx_get_color_config() Swati Sharma
2019-04-23 16:13 ` Ville Syrjälä
2019-04-17 14:03 ` [PATCH 04/11] [v4] drm/i915: Extract cherryview_get_color_config() Swati Sharma
2019-04-17 14:03 ` [PATCH 05/11] [v4] drm/i915: Extract i965_get_color_config() Swati Sharma
2019-04-17 14:03 ` [PATCH 06/11] [v4] drm/i915: Extract icl_get_color_config() Swati Sharma
2019-04-17 14:03 ` [PATCH 07/11] [v4] drm/i915: Extract glk_get_color_config() Swati Sharma
2019-04-17 14:03 ` [PATCH 08/11] [v4] drm/i915: Extract bdw_get_color_config() Swati Sharma
2019-04-17 14:03 ` [PATCH 09/11] [v4] drm/i915: Extract ivb_get_color_config() Swati Sharma
2019-04-17 14:03 ` [PATCH 10/11] [v4] drm/i915: Extract ilk_get_color_config() Swati Sharma
2019-04-17 14:03 ` [PATCH 11/11] [v4] drm/i915: Add intel_color_lut_equal() to compare hw and sw gamma lut values Swati Sharma
2019-04-25 12:35 ` Jani Nikula [this message]
2019-04-17 14:23 ` ✗ Fi.CI.CHECKPATCH: warning for drm/i915: adding state checker for gamma lut values (rev5) Patchwork
2019-04-17 14:28 ` ✗ Fi.CI.SPARSE: " Patchwork
2019-04-17 14:37 ` ✗ Fi.CI.BAT: failure " Patchwork
2019-04-18 10:03 ` ✗ Fi.CI.CHECKPATCH: warning for drm/i915: adding state checker for gamma lut values (rev6) Patchwork
2019-04-18 10:08 ` ✗ Fi.CI.SPARSE: " Patchwork
2019-04-18 10:31 ` ✗ Fi.CI.BAT: failure " Patchwork
2019-04-23 10:59 ` Arkadiusz Hiler
2019-04-25 12:26 ` [PATCH 00/11] drm/i915: adding state checker for gamma lut values Jani Nikula
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87zhoes1ns.fsf@intel.com \
--to=jani.nikula@intel.com \
--cc=ankit.k.nautiyal@intel.com \
--cc=daniel.vetter@ffwll.ch \
--cc=intel-gfx@lists.freedesktop.org \
--cc=swati2.sharma@intel.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.