intel-gfx.lists.freedesktop.org archive mirror
 help / color / mirror / Atom feed
From: "Ville Syrjälä" <ville.syrjala@linux.intel.com>
To: Swati Sharma <swati2.sharma@intel.com>
Cc: jani.nikula@intel.com, daniel.vetter@ffwll.ch,
	intel-gfx@lists.freedesktop.org, ankit.k.nautiyal@intel.com
Subject: Re: [PATCH 03/11] [v4] drm/i915: Extract i9xx_get_color_config()
Date: Tue, 23 Apr 2019 19:13:58 +0300	[thread overview]
Message-ID: <20190423161358.GX1747@intel.com> (raw)
In-Reply-To: <1555509813-9021-4-git-send-email-swati2.sharma@intel.com>

On Wed, Apr 17, 2019 at 07:33:25PM +0530, Swati Sharma wrote:
> v4: -No need to initialize *blob [Jani]
>     -Removed right shifts [Jani]
>     -Dropped dev local var [Jani]
> 
> Signed-off-by: Swati Sharma <swati2.sharma@intel.com>
> ---
>  drivers/gpu/drm/i915/i915_reg.h    |  3 +++
>  drivers/gpu/drm/i915/intel_color.c | 50 ++++++++++++++++++++++++++++++++++++++
>  2 files changed, 53 insertions(+)
> 
> diff --git a/drivers/gpu/drm/i915/i915_reg.h b/drivers/gpu/drm/i915/i915_reg.h
> index 9c206e8..8f2ae8a 100644
> --- a/drivers/gpu/drm/i915/i915_reg.h
> +++ b/drivers/gpu/drm/i915/i915_reg.h
> @@ -7175,6 +7175,9 @@ enum {
>  /* legacy palette */
>  #define _LGC_PALETTE_A           0x4a000
>  #define _LGC_PALETTE_B           0x4a800
> +#define LGC_PALETTE_RED_MASK     REG_GENMASK(23, 16)
> +#define LGC_PALETTE_GREEN_MASK   REG_GENMASK(15, 8)
> +#define LGC_PALETTE_BLUE_MASK    REG_GENMASK(7, 0)
>  #define LGC_PALETTE(pipe, i) _MMIO(_PIPE(pipe, _LGC_PALETTE_A, _LGC_PALETTE_B) + (i) * 4)
>  
>  /* ilk/snb precision palette */
> diff --git a/drivers/gpu/drm/i915/intel_color.c b/drivers/gpu/drm/i915/intel_color.c
> index 309f714..33223e0 100644
> --- a/drivers/gpu/drm/i915/intel_color.c
> +++ b/drivers/gpu/drm/i915/intel_color.c
> @@ -1229,6 +1229,55 @@ static int icl_color_check(struct intel_crtc_state *crtc_state)
>  	return 0;
>  }
>  
> +/* convert hw value with given bit_precision to lut property val */
> +static u32 intel_color_lut_pack(u32 val, u32 bit_precision)
> +{
> +	u32 max = 0xffff >> (16 - bit_precision);
> +
> +	val = clamp_val(val, 0, max);
> +
> +	if (bit_precision < 16)
> +		val <<= 16 - bit_precision;
> +
> +	return val;
> +}
> +
> +static void i9xx_get_config_internal(struct intel_crtc_state *crtc_state)

The naming of these functions isn't particularly descriptive. I would
probably go for eg. i9xx_read_lut_8(), chv_read_cgm_gamma_lut(), etc.
AFAICS the series is also missing readout for degamma LUTs entirely.

We could also make these functions just return the blob instead of
assigning it internally. That way we can have the higher level
.get_color_config() implementation assign each gamma/degamma lut
apporpriately. Eg. might looks something like this for bdw:

bdw_get_color_config()
{
	if (gamma_mode == 8bit) {
		crtc_state->gamma_lut = i9xx_read_lut_8();
	} else if (gamma_mode == split) {
		crtc_state->degamma_lut = bdw_read_lut_10(SPLIT | 0);
		crtc_state->gamma_lut = bdw_read_lut_10(SPLIT | 512);
	} else if (csc_mode == gamma_before_csc) {
		crtc_state->degamma_lut = bdw_read_lut_10(0);
	} else {
		crtc_state->gamma_lut = bdw_read_lut_10(0);
	}
}

The tricky part will be to figure out how the gamma vs. degamma gets
assigned and/or checked since the choice depends on the presence of
the ctm, rgb limit range, and rgb->ycbcr conversion.

Oh, and most (all maybe?) patches seem to be missing a proper commit
message.

> +{
> +	struct intel_crtc *crtc = to_intel_crtc(crtc_state->base.crtc);
> +	struct drm_i915_private *dev_priv = to_i915(crtc->base.dev);
> +	enum pipe pipe = crtc->pipe;
> +	struct drm_property_blob *blob;
> +	struct drm_color_lut *blob_data;
> +	u32 i, val;
> +
> +	blob = drm_property_create_blob(&dev_priv->drm,
> +					sizeof(struct drm_color_lut) * 256,
> +					NULL);
> +	if (IS_ERR(blob))
> +		return;
> +
> +	blob_data = blob->data;
> +
> +	for (i = 0; i < 256; i++) {
> +		if (HAS_GMCH(dev_priv))
> +			val = I915_READ(PALETTE(pipe, i));
> +		else
> +			val = I915_READ(LGC_PALETTE(pipe, i));
> +
> +		blob_data[i].red = intel_color_lut_pack(REG_FIELD_GET(LGC_PALETTE_RED_MASK, val), 8);
> +		blob_data[i].green = intel_color_lut_pack(REG_FIELD_GET(LGC_PALETTE_GREEN_MASK, val), 8);
> +		blob_data[i].blue = intel_color_lut_pack(REG_FIELD_GET(LGC_PALETTE_BLUE_MASK, val), 8);
> +	}
> +
> +	crtc_state->base.gamma_lut = blob;
> +}
> +
> +static void i9xx_get_color_config(struct intel_crtc_state *crtc_state)
> +{
> +	i9xx_get_config_internal(crtc_state);
> +}
> +
>  void intel_color_init(struct intel_crtc *crtc)
>  {
>  	struct drm_i915_private *dev_priv = to_i915(crtc->base.dev);
> @@ -1249,6 +1298,7 @@ void intel_color_init(struct intel_crtc *crtc)
>  			dev_priv->display.color_check = i9xx_color_check;
>  			dev_priv->display.color_commit = i9xx_color_commit;
>  			dev_priv->display.load_luts = i9xx_load_luts;
> +			dev_priv->display.get_color_config = i9xx_get_color_config;
>  		}
>  	} else {
>  		if (INTEL_GEN(dev_priv) >= 11)
> -- 
> 1.9.1

-- 
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-04-23 16:14 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ä [this message]
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
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=20190423161358.GX1747@intel.com \
    --to=ville.syrjala@linux.intel.com \
    --cc=ankit.k.nautiyal@intel.com \
    --cc=daniel.vetter@ffwll.ch \
    --cc=intel-gfx@lists.freedesktop.org \
    --cc=jani.nikula@intel.com \
    --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 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).