All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Ville Syrjälä" <ville.syrjala@linux.intel.com>
To: "Sharma, Swati2" <swati2.sharma@intel.com>
Cc: intel-gfx@lists.freedesktop.org
Subject: Re: [v7][PATCH 03/12] drm/i915: Add func to compare hw/sw gamma lut
Date: Mon, 10 Jun 2019 20:03:46 +0300	[thread overview]
Message-ID: <20190610170346.GC5942@intel.com> (raw)
In-Reply-To: <cdf14984-9165-3f05-e6f9-78289ec5ac50@intel.com>

On Mon, Jun 10, 2019 at 04:24:54PM +0530, Sharma, Swati2 wrote:
> On 31-May-19 8:58 PM, Ville Syrjälä wrote:
> 
> > On Wed, May 29, 2019 at 03:20:53PM +0530, Swati Sharma 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]
> >> v5: -Added condition (!blob1 && !blob2) return true [Jani]
> >>      -Called PIPE_CONF_CHECK_COLOR_LUT inside if (!adjust) [Jani]
> >>      -Added #undef PIPE_CONF_CHECK_COLOR_LUT [Jani]
> >> v6: -Added func intel_color_get_bit_precision() to get bit precision for
> >>       gamma and degamma lut readout depending upon platform and
> >>       corresponding to load_luts() [Ankit]
> >>      -Added debug log for color para in intel_dump_pipe_config [Jani]
> >>      -Made patch11 as patch3 [Jani]
> >> v7: -Renamed func intel_color_get_bit_precision() to
> >>       intel_color_get_gamma_bit_precision()
> >>      -Added separate function/platform for gamma bit precision [Ville]
> >>      -Corrected checkpatch warnings
> >>
> >> Signed-off-by: Swati Sharma <swati2.sharma@intel.com>
> >> ---
> >>   drivers/gpu/drm/i915/intel_color.c   | 166 +++++++++++++++++++++++++++++++++++
> >>   drivers/gpu/drm/i915/intel_color.h   |   7 ++
> >>   drivers/gpu/drm/i915/intel_display.c |  24 +++++
> >>   3 files changed, 197 insertions(+)
> >>
> >> diff --git a/drivers/gpu/drm/i915/intel_color.c b/drivers/gpu/drm/i915/intel_color.c
> >> index 50b98ee..b20a2c6 100644
> >> --- a/drivers/gpu/drm/i915/intel_color.c
> >> +++ b/drivers/gpu/drm/i915/intel_color.c
> >> @@ -1251,6 +1251,172 @@ static int icl_color_check(struct intel_crtc_state *crtc_state)
> >>   	return 0;
> >>   }
> >>   
> >> +static int i9xx_gamma_precision(struct intel_crtc_state *crtc_state)
> >> +{
> >> +	if (!crtc_state->gamma_enable)
> >> +		return 0;
> >> +
> >> +	switch (crtc_state->gamma_mode) {
> >> +	case GAMMA_MODE_MODE_8BIT:
> >> +		return 8;
> >> +	case GAMMA_MODE_MODE_10BIT:
> >> +		return 16;
> >> +	default:
> >> +		MISSING_CASE(crtc_state->gamma_mode);
> >> +		return 0;
> >> +	}
> >> +}
> >> +
> >> +static int chv_gamma_precision(struct intel_crtc_state *crtc_state)
> >> +{
> >> +	if (crtc_state->cgm_mode & CGM_PIPE_MODE_GAMMA)
> >> +		return 10;
> >> +	else
> >> +		return i9xx_gamma_precision(crtc_state);
> >> +}
> >> +
> >> +static int ilk_gamma_precision(struct intel_crtc_state *crtc_state)
> >> +{
> >> +	if (!crtc_state->gamma_enable)
> >> +		return 0;
> >> +
> >> +	if ((crtc_state->csc_mode & CSC_POSITION_BEFORE_GAMMA) == 0)
> >> +		return 0;
> >> +
> >> +	switch (crtc_state->gamma_mode) {
> >> +	case GAMMA_MODE_MODE_8BIT:
> >> +		return 8;
> >> +	case GAMMA_MODE_MODE_10BIT:
> >> +		return 10;
> >> +	default:
> >> +		MISSING_CASE(crtc_state->gamma_mode);
> >> +		return 0;
> >> +	}
> >> +}
> >> +
> >> +static int ivb_gamma_precision(struct intel_crtc_state *crtc_state)
> >> +{
> >> +	if (!crtc_state->gamma_enable)
> >> +		return 0;
> >> +
> >> +	if ((crtc_state->csc_mode & CSC_POSITION_BEFORE_GAMMA) == 0)
> >> +		return 0;
> >> +
> >> +	switch (crtc_state->gamma_mode) {
> >> +	case GAMMA_MODE_MODE_8BIT:
> >> +		return 8;
> >> +	case GAMMA_MODE_MODE_SPLIT:
> >> +	case GAMMA_MODE_MODE_10BIT:
> >> +		return 10;
> >> +	default:
> >> +		MISSING_CASE(crtc_state->gamma_mode);
> >> +		return 0;
> >> +	}
> >> +}
> >> +
> >> +static int glk_gamma_precision(struct intel_crtc_state *crtc_state)
> >> +{
> >> +	if (!crtc_state->gamma_enable)
> >> +		return 0;
> >> +
> >> +	if ((crtc_state->csc_mode & CSC_POSITION_BEFORE_GAMMA) == 0)
> >> +		return 0;
> > glk doens't have that bit.
> >
> >> +
> >> +	switch (crtc_state->gamma_mode) {
> >> +	case GAMMA_MODE_MODE_8BIT:
> >> +		return 8;
> >> +	case GAMMA_MODE_MODE_10BIT:
> >> +		return 10;
> >> +	default:
> >> +		MISSING_CASE(crtc_state->gamma_mode);
> >> +		return 0;
> >> +	}
> >> +}
> >> +
> >> +static int icl_gamma_precision(struct intel_crtc_state *crtc_state)
> >> +{
> >> +	if ((crtc_state->gamma_mode & PRE_CSC_GAMMA_ENABLE) == 0)
> >> +		return 0;
> > POST_CSC_GAMMA
> >
> >> +
> >> +	switch (crtc_state->gamma_mode & GAMMA_MODE_MODE_MASK) {
> >> +	case GAMMA_MODE_MODE_8BIT:
> >> +		return 8;
> >> +	case GAMMA_MODE_MODE_10BIT:
> >> +		return 10;
> >> +	default:
> >> +		MISSING_CASE(crtc_state->gamma_mode);
> >> +		return 0;
> >> +	}
> >> +}
> >> +
> >> +int intel_color_get_gamma_bit_precision(struct intel_crtc_state *crtc_state)
> >> +{
> >> +	struct intel_crtc *crtc = to_intel_crtc(crtc_state->base.crtc);
> >> +	struct drm_i915_private *dev_priv = to_i915(crtc->base.dev);
> >> +
> >> +	if (HAS_GMCH(dev_priv)) {
> >> +		if (IS_CHERRYVIEW(dev_priv))
> >> +			return chv_gamma_precision(crtc_state);
> >> +		else
> >> +			return i9xx_gamma_precision(crtc_state);
> >> +	} else {
> >> +		if (INTEL_GEN(dev_priv) >= 11)
> >> +			return icl_gamma_precision(crtc_state);
> >> +		else if (IS_CANNONLAKE(dev_priv) || IS_GEMINILAKE(dev_priv))
> >> +			return glk_gamma_precision(crtc_state);
> >> +		else if (INTEL_GEN(dev_priv) >= 7)
> >> +			return ivb_gamma_precision(crtc_state);
> >> +		else
> >> +			return ilk_gamma_precision(crtc_state);
> >> +	}
> >> +
> >> +	return 0;
> >> +}
> >> +
> >> +static inline bool 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 bit_precision)
> >> +{
> >> +	struct drm_color_lut *sw_lut, *hw_lut;
> >> +	int sw_lut_size, hw_lut_size, i;
> >> +	u32 err;
> >> +
> >> +	if (!blob1 && !blob2)
> >> +		return true;
> >> +
> >> +	if (!blob1)
> >> +		return true;
> >> +
> >> +	if (!blob2)
> >> +		return false;
> > What is this logic trying to do?
> >
> > Something like?
> >
> > if (!blob1 != !blob2)
> > 	return false;
> > if (!blob1)
> > 	return true;
> >
> >
> >> +
> >> +	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;
> > This is going to trigger with the split gamma mode. We'll need to be
> > more clever when comparing the two.
> 
> So, we need check for gamma_mode here as-well?

Maybe. We're going to have to make the exception somewhere,
and then we need to pick the LUT entries to compare similarly
as how the relevanty load_lut() function picks them.


> 
> >
> >> +
> >> +	sw_lut = blob1->data;
> >> +	hw_lut = blob2->data;
> >> +
> >> +	err = 0xffff >> bit_precision;
> >> +
> >> +	for (i = 0; i < sw_lut_size; i++) {
> >> +		if (!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..02ea1bc 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 bit_precision);
> >> +int intel_color_get_gamma_bit_precision(struct intel_crtc_state *crtc_state);
> >>   
> >>   #endif /* __INTEL_COLOR_H__ */
> >> diff --git a/drivers/gpu/drm/i915/intel_display.c b/drivers/gpu/drm/i915/intel_display.c
> >> index 3e01028..b8ff3f4 100644
> >> --- a/drivers/gpu/drm/i915/intel_display.c
> >> +++ b/drivers/gpu/drm/i915/intel_display.c
> >> @@ -11570,6 +11570,15 @@ static void intel_dump_pipe_config(struct intel_crtc *crtc,
> >>   				      drm_rect_width(&state->base.dst),
> >>   				      drm_rect_height(&state->base.dst));
> >>   	}
> >> +
> >> +	if (IS_CHERRYVIEW(dev_priv))
> >> +		DRM_DEBUG_KMS("cgm_mode:%d gamma_mode:%d gamma_enable:%d csc_enable:%d\n",
> >> +			       pipe_config->cgm_mode, pipe_config->gamma_mode,
> >> +			       pipe_config->gamma_enable, pipe_config->csc_enable);
> >> +	else
> >> +		DRM_DEBUG_KMS("csc_mode:%d gamma_mode:%d gamma_enable:%d csc_enable:%d\n",
> >> +			       pipe_config->csc_mode, pipe_config->gamma_mode,
> >> +			       pipe_config->gamma_enable, pipe_config->csc_enable);
> >>   }
> >>   
> >>   static bool check_digital_port_conflicts(struct drm_atomic_state *state)
> >> @@ -11947,6 +11956,7 @@ static bool fastboot_enabled(struct drm_i915_private *dev_priv)
> >>   			  bool adjust)
> >>   {
> >>   	bool ret = true;
> >> +	u32 bp_gamma = 0;
> >>   	bool fixup_inherited = adjust &&
> >>   		(current_config->base.mode.private_flags & I915_MODE_FLAG_INHERITED) &&
> >>   		!(pipe_config->base.mode.private_flags & I915_MODE_FLAG_INHERITED);
> >> @@ -12098,6 +12108,15 @@ static bool fastboot_enabled(struct drm_i915_private *dev_priv)
> >>   	} \
> >>   } while (0)
> >>   
> >> +#define PIPE_CONF_CHECK_COLOR_LUT(name, bit_precision) do { \
> >> +	if (!intel_color_lut_equal(current_config->name, \
> >> +				   pipe_config->name, bit_precision)) { \
> >> +		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))
> >>   
> >> @@ -12193,6 +12212,10 @@ static bool fastboot_enabled(struct drm_i915_private *dev_priv)
> >>   			PIPE_CONF_CHECK_X(csc_mode);
> >>   		PIPE_CONF_CHECK_BOOL(gamma_enable);
> >>   		PIPE_CONF_CHECK_BOOL(csc_enable);
> >> +
> >> +		bp_gamma = intel_color_get_gamma_bit_precision(pipe_config);
> >> +		if (bp_gamma)
> >> +			PIPE_CONF_CHECK_COLOR_LUT(base.gamma_lut, bp_gamma);
> > Sometimes the sw gamma gets programmed in the hw degamma, so we do need
> > degamma readout, and we'll need to somehow figure out which hw thing
> > is which sw thing.
> 
> Can you please little bit elaborate on this? What's the usecase?

Any time gamma+ycbcr/limited range rgb output is used.
See ivb_csc_mode().


> 
> >
> > I'm thinking the following sort of logic should work since so
> > far it should be just the the sw.gamma that can end up in
> > hw.degamma:
> >
> > if (sw.gamma && !hw.gamma) {
> > 	CHECK(sw.gamma, hw.degamma);
> > 	CHECK(sw.degamma, hw.gamma);
> > } else {
> > 	CHECK(sw.gamma, hw.gamma);
> > 	CHECK(sw.degamma, hw.degamma);
> > }
> >
> >>   	}
> >>   
> >>   	PIPE_CONF_CHECK_BOOL(double_wide);
> >> @@ -12255,6 +12278,7 @@ static bool fastboot_enabled(struct drm_i915_private *dev_priv)
> >>   #undef PIPE_CONF_CHECK_FLAGS
> >>   #undef PIPE_CONF_CHECK_CLOCK_FUZZY
> >>   #undef PIPE_CONF_QUIRK
> >> +#undef PIPE_CONF_CHECK_COLOR_LUT
> >>   
> >>   	return ret;
> >>   }
> >> -- 
> >> 1.9.1
> >>
> >> _______________________________________________
> >> Intel-gfx mailing list
> >> Intel-gfx@lists.freedesktop.org
> >> https://lists.freedesktop.org/mailman/listinfo/intel-gfx
> 
> 
> -- 
> ~Swati Sharma
> 

-- 
Ville Syrjälä
Intel
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

  reply	other threads:[~2019-06-10 17:03 UTC|newest]

Thread overview: 28+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-05-29  9:50 [v7][PATCH 00/12] drm/i915: adding state checker for gamma lut values Swati Sharma
2019-05-29  9:50 ` [v7][PATCH 01/12] drm/i915: Introduce vfunc read_luts() to create hw lut Swati Sharma
2019-05-29  9:50 ` [v7][PATCH 02/12] drm/i915: Enable intel_color_get_config() Swati Sharma
2019-06-05 10:08   ` Jani Nikula
2019-05-29  9:50 ` [v7][PATCH 03/12] drm/i915: Add func to compare hw/sw gamma lut Swati Sharma
2019-05-31 15:28   ` Ville Syrjälä
2019-06-10 10:54     ` Sharma, Swati2
2019-06-10 17:03       ` Ville Syrjälä [this message]
2019-06-05 10:07   ` Jani Nikula
2019-06-12 11:38     ` Sharma, Swati2
2019-05-29  9:50 ` [v7][PATCH 04/12] drm/i915: Extract i9xx_read_luts() Swati Sharma
2019-05-29  9:50 ` [v7][PATCH 05/12] drm/i915: Extract chv_read_luts() Swati Sharma
2019-05-29  9:50 ` [v7][PATCH 06/12] drm/i915: Extract i965_read_luts() Swati Sharma
2019-05-31 15:33   ` Ville Syrjälä
2019-05-29  9:50 ` [v7][PATCH 07/12] drm/i915: Extract icl_read_luts() Swati Sharma
2019-05-29  9:50 ` [v7][PATCH 08/12] drm/i915: Extract glk_read_luts() Swati Sharma
2019-05-29  9:50 ` [v7][PATCH 09/12] drm/i915: Extract bdw_read_luts() Swati Sharma
2019-05-29  9:51 ` [v7][PATCH 10/12] drm/i915: Extract ivb_read_luts() Swati Sharma
2019-05-29  9:51 ` [v7][PATCH 11/12] drm/i915: Extract ilk_read_luts() Swati Sharma
2019-05-31 15:33   ` Ville Syrjälä
2019-05-29  9:51 ` [v7][PATCH 12/12] FOR_TESTING_ONLY: Print rgb values of hw and sw blobs Swati Sharma
2019-05-29 16:49 ` ✗ Fi.CI.CHECKPATCH: warning for drm/i915: adding state checker for gamma lut values (rev12) Patchwork
2019-05-29 16:54 ` ✗ Fi.CI.SPARSE: " Patchwork
2019-05-29 17:12 ` ✗ Fi.CI.BAT: failure " Patchwork
2019-05-31  8:17 ` ✓ Fi.CI.BAT: success " Patchwork
2019-05-31 17:47 ` ✓ Fi.CI.IGT: " Patchwork
2019-08-15  8:14 ` [v7][PATCH 00/12] drm/i915: adding state checker for gamma lut values Jani Nikula
2019-08-16  5:47   ` Sharma, Swati2

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=20190610170346.GC5942@intel.com \
    --to=ville.syrjala@linux.intel.com \
    --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.