public inbox for igt-dev@lists.freedesktop.org
 help / color / mirror / Atom feed
From: Daniel Vetter <daniel@ffwll.ch>
To: "Shankar, Uma" <uma.shankar@intel.com>
Cc: "igt-dev@lists.freedesktop.org" <igt-dev@lists.freedesktop.org>,
	"Syrjala, Ville" <ville.syrjala@intel.com>,
	Daniel Vetter <daniel@ffwll.ch>,
	"Lankhorst, Maarten" <maarten.lankhorst@intel.com>
Subject: Re: [igt-dev] [v4] tests/kms_color: Fix CRC mismatch issues with ctm test
Date: Wed, 3 Apr 2019 10:32:50 +0200	[thread overview]
Message-ID: <20190403083250.GQ2665@phenom.ffwll.local> (raw)
In-Reply-To: <E7C9878FBA1C6D42A1CA3F62AEB6945F81F93DD1@BGSMSX104.gar.corp.intel.com>

On Tue, Apr 02, 2019 at 12:54:26PM +0000, Shankar, Uma wrote:
> 
> 
> >-----Original Message-----
> >From: Daniel Vetter [mailto:daniel.vetter@ffwll.ch] On Behalf Of Daniel Vetter
> >Sent: Tuesday, April 2, 2019 2:23 PM
> >To: Ville Syrjälä <ville.syrjala@linux.intel.com>
> >Cc: Daniel Vetter <daniel@ffwll.ch>; Shankar, Uma <uma.shankar@intel.com>; igt-
> >dev@lists.freedesktop.org; Syrjala, Ville <ville.syrjala@intel.com>; Lankhorst,
> >Maarten <maarten.lankhorst@intel.com>
> >Subject: Re: [igt-dev] [v4] tests/kms_color: Fix CRC mismatch issues with ctm test
> >
> >On Mon, Apr 01, 2019 at 08:51:02PM +0300, Ville Syrjälä wrote:
> >> On Mon, Apr 01, 2019 at 09:26:33AM +0200, Daniel Vetter wrote:
> >> > On Fri, Mar 29, 2019 at 12:38:55PM +0200, Ville Syrjälä wrote:
> >> > > On Fri, Mar 29, 2019 at 10:05:14AM +0100, Daniel Vetter wrote:
> >> > > > On Fri, Mar 29, 2019 at 10:00:59AM +0100, Daniel Vetter wrote:
> >> > > > > On Fri, Mar 29, 2019 at 02:49:15AM +0530, Uma Shankar wrote:
> >> > > > > > Due to Gamma/Degamma limitation with precision (lack of
> >> > > > > > exact 1.0 representation) due to ABI restriction, applying
> >> > > > >
> >> > > > > Huh, why? That sounds like a conversion bug in our gamma table handler.
> >> > > > > 0xffff == 1.0 if we don't treat it like that that's a driver
> >> > > > > bug. The gamma table is _not_ fixed point, but linear range
> >> > > > > from 0-0xffff. Which is unlike the ctm (which due to an uapi
> >> > > > > accident has a really hilarious fixed point with sign bit format).
> >> > > > >
> >> > > > > Please don't paper over driver bugs :-)
> >> > > >
> >> > > > Can you pls also review existing gamma igt coverage to make sure
> >> > > > we're catching this? Or maybe it's just the testcase that fills
> >> > > > the gamma table the wrong way.
> >> > >
> >> > > I've been pondering if we should just do value+1 in the kernel for
> >> > > the last LUT entry when using the interpolated modes.
> >> >
> >> > See my doc patch, imo we should do that. We even should have done
> >> > that with the old documentation, since 0.16 ff rounded to any LUT
> >> > with less precision measn 0.0xffff should round up to 1.0. If we do
> >> > correct rounding.
> >> >
> >> > That's always been the intention really, the docs just clarify that
> >> > yes you should round correctly even if you happen to have a 16bit LUT.
> >> >
> >> > > For userspace we could probably use the odd LUT size as a hint to
> >> > > indicate that the hardware will interpolate. So userspace could
> >> > > just do something like "if (size & 1) max = 1<<16; else max = (1<<16)-1;"
> >> > > when generating the curve (+ clamp to 0xffff). Looks like there's
> >> > > some kind of kludge for CHV in kms_color atm, but maybe we can
> >> > > just replace that with the generic logic above.
> >> >
> >> > Hm I didn't look at details, but clamp to 0xffff sounds still wrong,
> >> > we should correctly convert from 0.0-1.0 to 0-0xffff. Not that
> >> > there's going to be a huge difference except for 1.0 (if we haven't
> >> > rounded correctly thus far).
> >>
> >> Not sure what is correct rounding anyway. Userspace not knowing the
> >> precision of the LUT entries does lead to some issues.
> >>
> >> Eg. if we have a 4 entry non-interpolated LUT with 8bit precision and
> >> we want a linear ramp the correct values would be 0x00,0x55,0xaa,0xff,
> >> but with userspace filling in the full 16bits values, rounding will
> >> get us 0x00,0x55,0xab,0x100. So not quite right. OTOH if we had 16bit
> >> precision I think currently we wouldn't round at all and we'd get the
> >> correct answer.
> >>
> >> For the interpolated 5 entry LUT it would actually work out if
> >> userspace fills in 0x0000,0x3ffff.7xfff,0xbfff,0xffff so we get
> >> 0x00,0x40,0x80,0xc0,0x100 after rounding. Which is correct. But if we
> >> used the full 16bit precision then with no rounding we'd get the wrong
> >> answer.
> >
> >Hm, awkward. I guess if we need a linear map, then we need to disable the LUT. And
> >if there's a LUT the only things we can guarantee is that 0.0 and
> >1.0 get through unscated, and everything else might have tiny rounding issues. I guess
> >that means the patch is still good, but needs an improved commit message.
> 
> For legacy this will be the problem as we can't avoid this rounding and fit all values accurately.
> Our hardware has 17 bits to represent 1.0, and 0xffff and 0x10000 should be represented as
> distinct entities.

There is no 0x10000 in the current uapi. And 0xffff == 1.0, as per the
uapi clarification patch I've just merged.

Wrt 17 bits ... how does that work? I've never even seen a real world
display with more than 12 bits of depth. What do we need the additional 5
bits on top? Is that just because we operate in linear space for the CTM?

> I feel if we get the ABI extended to use u32.32, we may well be able to solve for upcoming
> new platforms and HDR type usescases were Lut precision is 24 bits. Attempted in this patch:
> https://patchwork.freedesktop.org/patch/294732/?series=30875&rev=7

Or is HDR using massive non-linear representation of bit depth?

> So for now, we may disable linear gamma programming to avoid these crc errors. I hope this is ok.

Yeah, that part makes sense. But we need to update the commit message,
because atm it's just wrong: 1.0 is the one value we can (and should,
under all conditions) represent perfectly accurately. It's the
intermediate values which cause rounding issues and inaccurancies.
-Daniel
-- 
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch
_______________________________________________
igt-dev mailing list
igt-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/igt-dev

  reply	other threads:[~2019-04-03  8:32 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-03-28 21:19 [igt-dev] [v4] tests/kms_color: Fix CRC mismatch issues with ctm test Uma Shankar
2019-03-28 20:56 ` Ville Syrjälä
2019-03-28 21:31   ` Shankar, Uma
2019-03-28 21:41   ` Shankar, Uma
2019-03-28 21:17 ` [igt-dev] ✓ Fi.CI.BAT: success for tests/kms_color: Fix CRC mismatch issues with ctm test (rev7) Patchwork
2019-03-29  7:46 ` [igt-dev] ✓ Fi.CI.IGT: " Patchwork
2019-03-29  9:00 ` [igt-dev] [v4] tests/kms_color: Fix CRC mismatch issues with ctm test Daniel Vetter
2019-03-29  9:05   ` Daniel Vetter
2019-03-29 10:38     ` Ville Syrjälä
2019-04-01  7:26       ` Daniel Vetter
2019-04-01 17:51         ` Ville Syrjälä
2019-04-02  8:52           ` Daniel Vetter
2019-04-02 12:54             ` Shankar, Uma
2019-04-03  8:32               ` Daniel Vetter [this message]
2019-04-03  9:29                 ` Shankar, Uma
  -- strict thread matches above, loose matches on Subject: below --
2019-03-28 21:59 Uma Shankar

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=20190403083250.GQ2665@phenom.ffwll.local \
    --to=daniel@ffwll.ch \
    --cc=igt-dev@lists.freedesktop.org \
    --cc=maarten.lankhorst@intel.com \
    --cc=uma.shankar@intel.com \
    --cc=ville.syrjala@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