All of lore.kernel.org
 help / color / mirror / Atom feed
From: Rob Bradford <robert.bradford@intel.com>
To: Shashank Sharma <shashank.sharma@intel.com>,
	dri-devel@lists.freedesktop.org, matthew.d.roper@intel.com,
	thierry.reding@gmail.com, gary.k.smith@intel.com,
	hverkuil@xs4all.nl, jim.bish@intel.com,
	intel-gfx@lists.freedesktop.org
Cc: annie.j.matheson@intel.com, vijay.a.purushothaman@intel.com,
	kausalmalladi@gmail.com, jesse.barnes@intel.com,
	daniel.vetter@intel.com, susanta.bhattacharjee@intel.com
Subject: Re: [PATCH 18/18] drm/i915: Add CSC correction for BDW/SKL/BXT
Date: Wed, 30 Sep 2015 18:49:36 +0100	[thread overview]
Message-ID: <1443635376.16462.35.camel@intel.com> (raw)
In-Reply-To: <1438879107-22819-19-git-send-email-shashank.sharma@intel.com>

Hi Shashank, some feedback on the CSC code below.


On Thu, 2015-08-06 at 22:08 +0530, Shashank Sharma wrote:
> From: Kausal Malladi <kausalmalladi@gmail.com>
> 
> BDW/SKL/BXT support Color Space Conversion (CSC) using a 3x3 matrix
> that needs to be programmed into respective CSC registers.
> 
> This patch does the following:
> 1. Adds the core function to program CSC correction values for
>    BDW/SKL/BXT platform
> 2. Adds CSC correction macros/defines
> 

*snip* 

> +s16 get_csc_s2_7_format(s64 csc_value)
> +{
> +	s32 csc_int_value;
> +	u32 csc_fract_value;
> +	s16 csc_s2_7_format;
> +
> +	if (csc_value >= 0) {
> +		csc_value += GEN9_CSC_FRACT_ROUNDOFF;
> +		if (csc_value > GEN9_CSC_COEFF_MAX)
> +			csc_value = GEN9_CSC_COEFF_MAX;
> +	} else {
> +		csc_value = -csc_value;
> +		csc_value += GEN9_CSC_FRACT_ROUNDOFF;
> +		if (csc_value > GEN9_CSC_COEFF_MAX + 1)
> +			csc_value = GEN9_CSC_COEFF_MAX + 1;
> +		csc_value = -csc_value;
> +	}
> +
> +	csc_int_value = csc_value >> GEN9_CSC_COEFF_SHIFT;
> +	csc_int_value <<= GEN9_CSC_COEFF_INT_SHIFT;
> +	if (csc_value < 0)
> +		csc_int_value |= CSC_COEFF_SIGN;
> +	csc_fract_value = csc_value;
> +	csc_fract_value >>= GEN9_CSC_COEFF_FRACT_SHIFT;
> +	csc_s2_7_format = csc_int_value | csc_fract_value;
> +
> +	return csc_s2_7_format;
> +}

I'm afraid this isn't the right way to calculate the coefficients for
BDW. It doesn't use a fixed s2.7 format rather a limited floating point
(according to the BSpec.) 

I think it's perfectly reasonable to make the decision only to support
the values in that range but then you still need to modify the above
code to set the exponent part to 110b and also shift for the reserved
bits.

> +int gen9_set_csc(struct drm_device *dev, struct drm_property_blob
> *blob,
> +		struct drm_crtc *crtc)
> +{

*snip*

> +	/* Write csc coeff to csc regs */
> +	for (i = 0, j = 0; i < CSC_MAX_VALS; i++) {
> +		word = get_csc_s2_7_format(csc_data->ctm_coeff[i]);
> +		word = word << GEN9_CSC_SHIFT;
> +		if (i % 3 != 2)
> +			word = word |
> +				get_csc_s2_7_format(csc_data
> ->ctm_coeff[i]);
> +
> +		I915_WRITE(reg + j, word);
> +		j = j + 4;
> +	}

*snip*

I'm not sure the above loop is great style, vs explicitly describing
each of the register updates. But for the above code to come close to
working you need to increment i before ORing the second packed value.

Rob
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/intel-gfx

  parent reply	other threads:[~2015-09-30 17:49 UTC|newest]

Thread overview: 37+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-08-06 16:38 [PATCH 00/18] Color Management for DRM Shashank Sharma
2015-08-06 16:38 ` [PATCH 01/18] drm: Create Color Management DRM properties Shashank Sharma
2015-08-06 16:38 ` [PATCH 02/18] drm/i915: Add atomic set property interface for CRTC Shashank Sharma
2015-08-06 16:38 ` [PATCH 03/18] drm/i915: Add atomic get " Shashank Sharma
2015-08-21 22:40   ` Matt Roper
2015-08-22  6:00     ` Sharma, Shashank
2015-08-25  7:16       ` Daniel Vetter
2015-08-06 16:38 ` [PATCH 04/18] drm: Add structure for querying palette color capabilities Shashank Sharma
2015-08-06 16:38 ` [PATCH 05/18] drm/i915: Initialize color manager and add gamma correction Shashank Sharma
2015-08-21 22:40   ` Matt Roper
2015-08-22  6:08     ` Sharma, Shashank
2015-08-06 16:38 ` [PATCH 06/18] drm: Add color correction blobs in CRTC state Shashank Sharma
2015-08-21 22:40   ` Matt Roper
2015-08-22  6:09     ` Sharma, Shashank
2015-08-06 16:38 ` [PATCH 07/18] drm: Add drm structures for palette color property Shashank Sharma
2015-08-06 16:38 ` [PATCH 08/18] drm/i915: Add pipe gamma correction handlers Shashank Sharma
2015-08-21 22:40   ` Matt Roper
2015-08-22  6:11     ` Sharma, Shashank
2015-08-25  7:18       ` Daniel Vetter
2015-08-06 16:38 ` [PATCH 09/18] drm/i915: Pipe level Gamma correction for CHV/BSW Shashank Sharma
2015-08-21 22:41   ` Matt Roper
2015-08-22  6:18     ` Sharma, Shashank
2015-08-06 16:38 ` [PATCH 10/18] drm/i915: Add pipe deGamma correction handlers Shashank Sharma
2015-08-06 16:38 ` [PATCH 11/18] drm/i915: Add DeGamma correction for CHV/BSW Shashank Sharma
2015-08-06 16:38 ` [PATCH 12/18] drm: Add structure for set/get a CTM color property Shashank Sharma
2015-08-06 16:38 ` [PATCH 13/18] drm/i915: Add set/get property handlers for CSC correction Shashank Sharma
2015-08-06 16:38 ` [PATCH 14/18] drm/i915: Add CSC correction for CHV/BSW Shashank Sharma
2015-08-06 16:38 ` [PATCH 15/18] drm/i915: Initialize Gen8 pipe gamma correction Shashank Sharma
2015-08-21 22:41   ` Matt Roper
2015-08-22  6:31     ` Sharma, Shashank
2015-08-06 16:38 ` [PATCH 16/18] drm/i915: Gen8 pipe level Gamma correction Shashank Sharma
2015-08-06 16:38 ` [PATCH 17/18] drm/i915: Add DeGamma correction for BDW/SKL/BXT Shashank Sharma
2015-08-06 16:38 ` [PATCH 18/18] drm/i915: Add CSC " Shashank Sharma
2015-08-13  0:28   ` shuang.he
2015-09-30 17:49   ` Rob Bradford [this message]
2015-09-08 10:49 ` [PATCH 00/18] Color Management for DRM Rob Bradford
2015-09-08 11:10   ` Sharma, Shashank

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=1443635376.16462.35.camel@intel.com \
    --to=robert.bradford@intel.com \
    --cc=annie.j.matheson@intel.com \
    --cc=daniel.vetter@intel.com \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=gary.k.smith@intel.com \
    --cc=hverkuil@xs4all.nl \
    --cc=intel-gfx@lists.freedesktop.org \
    --cc=jesse.barnes@intel.com \
    --cc=jim.bish@intel.com \
    --cc=kausalmalladi@gmail.com \
    --cc=matthew.d.roper@intel.com \
    --cc=shashank.sharma@intel.com \
    --cc=susanta.bhattacharjee@intel.com \
    --cc=thierry.reding@gmail.com \
    --cc=vijay.a.purushothaman@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.