public inbox for intel-gfx@lists.freedesktop.org
 help / color / mirror / Atom feed
From: Rob Bradford <robert.bradford@intel.com>
To: Shashank Sharma <shashank.sharma@intel.com>,
	matthew.d.roper@intel.com, jim.bish@intel.com,
	gary.k.smith@intel.com, dri-devel@lists.freedesktop.org,
	intel-gfx@lists.freedesktop.org
Cc: daniel.vetter@intel.com, kausalmalladi@gmail.com,
	annie.j.matheson@intel.com
Subject: Re: [PATCH 21/23] drm/i915: BDW: Pipe level Gamma correction
Date: Wed, 30 Sep 2015 15:31:34 +0100	[thread overview]
Message-ID: <1443623494.16462.19.camel@intel.com> (raw)
In-Reply-To: <1442425040-32185-22-git-send-email-shashank.sharma@intel.com>

Hi Shashank, some feedback below that you would be great to get
addressed before your next version.

On Wed, 2015-09-16 at 23:07 +0530, Shashank Sharma wrote:
> BDW/SKL/BXT platforms support various Gamma correction modes
> which are:
> 1. Legacy 8-bit mode
> 2. 10-bit mode
> 3. 10-bit Split Gamma mode
> 4. 12-bit mode
> 
> This patch does the following:
> 1. Adds the core function to program Gamma correction values
>    for BDW/SKL/BXT platforms
> 2. Adds Gamma correction macros/defines
> 
> Signed-off-by: Shashank Sharma <shashank.sharma@intel.com>
> Signed-off-by: Kausal Malladi <kausalmalladi@gmail.com>
> ---
>  drivers/gpu/drm/i915/i915_reg.h            |  17 +-
>  drivers/gpu/drm/i915/intel_color_manager.c | 270
> +++++++++++++++++++++++++++++

*snip*

> +static u32 bdw_write_10bit_gamma_precision(u32 red, u32 green, u32
> blue)
> +{
> +	u32 word;
> +	u8 blue_int, green_int, red_int;
> +	u16 blue_fract, green_fract, red_fract;
> +
> +	blue_int = _GAMMA_INT_PART(blue);
> +	if (blue_int > GAMMA_INT_MAX)
> +		blue = BDW_MAX_GAMMA;
> +
> +	green_int = _GAMMA_INT_PART(green);
> +	if (green_int > GAMMA_INT_MAX)
> +		green = BDW_MAX_GAMMA;
> +
> +	red_int = _GAMMA_INT_PART(red);
> +	if (red_int > GAMMA_INT_MAX)
> +		red = BDW_MAX_GAMMA;
> +
> +	blue_fract = _GAMMA_FRACT_PART(blue);
> +	green_fract = _GAMMA_FRACT_PART(green);
> +	red_fract = _GAMMA_FRACT_PART(red);
> +
> +	blue_fract >>= BDW_10BIT_GAMMA_MSB_SHIFT;
> +	green_fract >>= BDW_10BIT_GAMMA_MSB_SHIFT;
> +	red_fract >>= BDW_10BIT_GAMMA_MSB_SHIFT;
> +
> +	/* Red (29:20) Green (19:10) and Blue (9:0) */
> +	word = red_fract;
> +	word <<= BDW_GAMMA_SHIFT;
> +	word = word | green_fract;
> +	word <<= BDW_GAMMA_SHIFT;
> +	word = word | blue_fract;
> +
> +	return word;
> +}
> +

I think the above function, and perhaps others in this series have the
same flaw with respect to maximum colour value.

In our discussions we agreed that we would follow the "GL style" where
maximum colour (i.e. 255 in 8-bit) would be represented by 1.0f. 1.0f
when converted to fixed point 8.24 notation is 1 << 24.

I observed that with my test code that a linear ramp (where the last
entry is set to 1.0) gives me black for white. I tracked it down to
this function.

In order to map 1.0 to the maximum value for the table entry in the
hardware this function needs to be changed. One way to achieve this
would be change the test "blue_int > GAMMA_INT_MAX" to be "blue_int >=
GAMMA_INT_MAX" but since GAMMA_INT_MAX = 1 then it might be clearer to
say blue_int > 0.

BDW_MAX_GAMMA also looks wrong. I think it should be (1 << 24) - 1 not
the 0x10000 (see below). As well as correct clamping it is also
necessary to scale as Daniel suggested on IRC:

"
13:54 < danvet> robster, so we'd need to rescale in the kernel from 1.0
to 0.1111111111b ?
13:55 < danvet> well substract 0.0000000001b for all values > 0.5
probably since float math in the kernel is evil
13:56 < danvet> also this probably needs an igt - check that all black
with an all 1.0 gamma table is the same as 
                all white with a linear one
"

You won't see this with your test program (color-correction.c) as the
largest value you program in appears to be 0.ff

*snip*

> +/* Gen 9 */
> +#define BDW_MAX_GAMMA				0x10000
> 

*snip*

I look forward to testing against your next version.

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

  reply	other threads:[~2015-09-30 14:31 UTC|newest]

Thread overview: 65+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-09-16 17:36 [PATCH 00/23] Color Management for DRM Shashank Sharma
2015-09-16 17:36 ` [PATCH 01/23] drm: Create Color Management DRM properties Shashank Sharma
2015-09-16 17:51   ` Matt Roper
2015-09-23  8:51     ` Sharma, Shashank
2015-09-16 17:36 ` [PATCH 02/23] drm: Add structure for querying palette color capabilities Shashank Sharma
2015-09-16 17:51   ` Matt Roper
2015-09-22 13:02     ` Daniel Vetter
2015-09-23  8:10       ` Sharma, Shashank
2015-09-23  9:47         ` Smith, Gary K
2015-09-23 11:57           ` Sharma, Shashank
2015-09-23 13:26             ` Daniel Vetter
2015-09-16 17:37 ` [PATCH 03/23] drm: Add color correction blobs in CRTC state Shashank Sharma
2015-09-16 17:37 ` [PATCH 04/23] drm: Add drm structures for palette color property Shashank Sharma
2015-09-21 16:46   ` Ville Syrjälä
2015-09-22  7:57     ` Sharma, Shashank
2015-09-22 13:08   ` Daniel Vetter
2015-09-22 13:53     ` Emil Velikov
2015-09-22 15:00       ` Ville Syrjälä
2015-09-22 16:51         ` Emil Velikov
2015-09-23  8:15     ` Sharma, Shashank
2015-09-23 12:49       ` Daniel Vetter
2015-09-23 12:59         ` Sharma, Shashank
2015-09-23 13:30           ` Daniel Vetter
2015-09-16 17:37 ` [PATCH 05/23] drm: Add structure to set/get a CTM " Shashank Sharma
2015-09-22 13:08   ` Daniel Vetter
2015-09-23  8:16     ` Sharma, Shashank
2015-09-22 15:22   ` Ville Syrjälä
2015-09-16 17:37 ` [PATCH 06/23] drm/i915: Add atomic set property interface for CRTC Shashank Sharma
2015-09-16 17:37 ` [PATCH 07/23] drm/i915: Add atomic get " Shashank Sharma
2015-09-16 17:37 ` [PATCH 08/23] drm/i915: Create color management files Shashank Sharma
2015-09-16 17:37 ` [PATCH 09/23] drm/i915: Register pipe color capabilities Shashank Sharma
2015-09-22 13:24   ` Daniel Vetter
2015-09-23  8:35     ` Sharma, Shashank
2015-09-23 12:52       ` [Intel-gfx] " Daniel Vetter
2015-09-16 17:37 ` [PATCH 10/23] drm/i915: Add gamma correction handlers Shashank Sharma
2015-09-22 13:15   ` [Intel-gfx] " Daniel Vetter
2015-09-22 13:19     ` Daniel Vetter
2015-09-23  8:22     ` [Intel-gfx] " Sharma, Shashank
2015-09-23 13:02       ` Daniel Vetter
2015-09-26 15:48       ` Sharma, Shashank
2015-09-28  6:43         ` [Intel-gfx] " Daniel Vetter
2015-09-28  8:19           ` Sharma, Shashank
2015-09-28 21:42             ` Matt Roper
2015-09-29  4:29               ` Sharma, Shashank
2015-09-29  4:29                 ` Matheson, Annie J
2015-09-16 17:37 ` [PATCH 11/23] drm/i915: Add pipe deGamma " Shashank Sharma
2015-09-16 17:37 ` [PATCH 12/23] drm/i915: Add pipe CSC " Shashank Sharma
2015-09-16 17:37 ` [PATCH 13/23] drm/i915: CHV: Load gamma color correction values Shashank Sharma
2015-09-16 17:37 ` [PATCH 14/23] drm/i915: CHV: Load degamma " Shashank Sharma
2015-09-16 17:37 ` [PATCH 15/23] drm/i915: CHV: Pipe level Gamma correction Shashank Sharma
2015-09-16 17:37 ` [PATCH 16/23] drm/i915: CHV: Pipe level degamma correction Shashank Sharma
2015-09-16 17:37 ` [PATCH 17/23] drm/i915: CHV: Pipe level CSC correction Shashank Sharma
2015-09-16 17:37 ` [PATCH 18/23] drm/i915: Commit color changes to CRTC Shashank Sharma
2015-09-16 17:37 ` [PATCH 19/23] drm/i915: Attach color properties " Shashank Sharma
2015-09-16 17:37 ` [PATCH 20/23] drm/i915: BDW: Load gamma correction values Shashank Sharma
2015-09-16 17:37 ` [PATCH 21/23] drm/i915: BDW: Pipe level Gamma correction Shashank Sharma
2015-09-30 14:31   ` Rob Bradford [this message]
2015-09-30 16:25     ` Sharma, Shashank
2015-09-30 16:31       ` Matheson, Annie J
2015-09-30 17:15         ` Sharma, Shashank
2015-09-30 16:44     ` Ville Syrjälä
2015-09-16 17:37 ` [PATCH 22/23] drm/i915: BDW: Load degamma correction values Shashank Sharma
2015-09-16 17:37 ` [PATCH 23/23] drm/i915: BDW: Pipe level degamma correction Shashank Sharma
2015-09-22 13:27 ` [Intel-gfx] [PATCH 00/23] Color Management for DRM Daniel Vetter
2015-09-23  8:38   ` 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=1443623494.16462.19.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=intel-gfx@lists.freedesktop.org \
    --cc=jim.bish@intel.com \
    --cc=kausalmalladi@gmail.com \
    --cc=matthew.d.roper@intel.com \
    --cc=shashank.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