mbox series

[0/9] Enhance pipe color support for multi segmented luts

Message ID 20210601104135.29020-1-uma.shankar@intel.com (mailing list archive)
Headers show
Series Enhance pipe color support for multi segmented luts | expand

Message

Shankar, Uma June 1, 2021, 10:41 a.m. UTC
Modern hardwares have multi segmented lut approach to prioritize
the darker regions of the spectrum. This series introduces a new
UAPI to define the lut ranges supported by the respective hardware.

This also enables Pipe Color Management Support for Intel's XE_LPD hw.
Enable Support for Pipe Degamma with the increased lut samples
supported by hardware. This also adds support for newly introduced
Logarithmic Gamma for XE_LPD. Also added the gamma readout support.

The Logarithmic gamma implementation on XE_LPD is non linear and adds 25
segments with non linear lut samples in each segment. The expectation
is userspace will create the luts as per this distribution and pass
the final samples to driver to be programmed in hardware.

+-----+------------------------------+
| x   |  2 pow x segment|No of Entries
|     |  0              | 1          |
| 0   |  1              | 1          |
| 1   |  2              | 2          |
| 2   |  4              | 2          |
| 3   |  8              | 2          |
| 4   |  16             | 2          |
| 5   |  32             | 4          |
| 6   |  64             | 4          |
| 7   |  128            | 4          |
| 8   |  256            | 8          |
| 9   |  512            | 8          |
| 10  |  1024           | 8          |
| 11  |  2048           | 16         |
| 12  |  4096           | 16         |
| 13  |  8192           | 16         |
| 14  |  16384          | 32         |
| 15  |  32768          | 32         |
| 16  |  65536          | 64         |
| 17  |  131072         | 64         |
| 18  |  262144         | 64         |
| 19  |  524288         | 32         |
| 20  |  1048576        | 32         |
| 21  |  2097152        | 32         |
| 22  |  4194304        | 32         |
| 23  |  8388608        | 32         |
| 24  |  16777216       | 1          |
|     | Total Entries   | 511        |
 -----+-----------------+------------+

Credits: Special mention and credits to Ville Syrjala for coming up
with a design for this feature and inputs. This series is based on
his original design.

Note: Userspace support for this new UAPI will be done on Chrome and
plan is to get this supported on mutter as well. We will notify the
list once we have that ready for review.

Uma Shankar (9):
  drm: Add gamma mode property
  drm/i915/xelpd: Define color lut range structure
  drm/i915/xelpd: Add support for Logarithmic gamma mode
  drm/i915/xelpd: Attach gamma mode property
  drm: Add Client Cap for advance gamma mode
  drm/i915/xelpd: logarithmic gamma enabled only with advance gamma mode
  drm/i915/xelpd: Enable Pipe Degamma
  drm/i915/xelpd: Add Pipe Color Lut caps to platform config
  drm/i915/xelpd: Enable XE_LPD Gamma Lut readout

 drivers/gpu/drm/drm_atomic_uapi.c          |   8 +
 drivers/gpu/drm/drm_color_mgmt.c           |  75 ++++
 drivers/gpu/drm/drm_ioctl.c                |   5 +
 drivers/gpu/drm/i915/display/intel_color.c | 454 ++++++++++++++++++++-
 drivers/gpu/drm/i915/i915_pci.c            |   3 +-
 drivers/gpu/drm/i915/i915_reg.h            |   7 +
 include/drm/drm_atomic.h                   |   1 +
 include/drm/drm_color_mgmt.h               |   8 +
 include/drm/drm_crtc.h                     |  25 ++
 include/drm/drm_file.h                     |   8 +
 include/uapi/drm/drm.h                     |   8 +
 include/uapi/drm/drm_mode.h                |  43 ++
 12 files changed, 630 insertions(+), 15 deletions(-)

Comments

Harry Wentland June 4, 2021, 6:51 p.m. UTC | #1
On 2021-06-01 6:41 a.m., Uma Shankar wrote:
> Modern hardwares have multi segmented lut approach to prioritize
> the darker regions of the spectrum. This series introduces a new
> UAPI to define the lut ranges supported by the respective hardware.
> 
> This also enables Pipe Color Management Support for Intel's XE_LPD hw.
> Enable Support for Pipe Degamma with the increased lut samples
> supported by hardware. This also adds support for newly introduced
> Logarithmic Gamma for XE_LPD. Also added the gamma readout support.
> 
> The Logarithmic gamma implementation on XE_LPD is non linear and adds 25
> segments with non linear lut samples in each segment. The expectation
> is userspace will create the luts as per this distribution and pass
> the final samples to driver to be programmed in hardware.
> 

Is this design targetting Intel XE_LPD HW in particular or is it intended
to be generic?

If this is intended to be generic I think it would benefit from a lot more
documentation. At this point it's difficult for me to see how to adapt this
to AMD HW. It would take me a while to be comfortable to make a call on whether
we can use it or not. And what about other vendors?

I think we need to be cautious in directly exposing HW functionality through
UAPI. The CM parts of AMD HW seem to be changing in some way each generation
and it looks like the same is true for Intel. The trouble we have with adapting
the old gamma/degamma properties to modern HW is some indication to me that
this approach is somewhat problematic.

It would be useful to understand and document the specific use-cases we want to
provide to userspace implementers with this functionality. Do we want to support
modern transfer functions such as PQ or HLG? If so, it might be beneficial to
have an API to explicitly specify that, and then use LUT tables in drivers that
are optimized for the implementing HW. Or is the use case tone mapping? If so,
would a parametric definition of tone mapping be easier to manage?

> +-----+------------------------------+
> | x   |  2 pow x segment|No of Entries
> |     |  0              | 1          |
> | 0   |  1              | 1          |
> | 1   |  2              | 2          |
> | 2   |  4              | 2          |
> | 3   |  8              | 2          |
> | 4   |  16             | 2          |
> | 5   |  32             | 4          |
> | 6   |  64             | 4          |
> | 7   |  128            | 4          |
> | 8   |  256            | 8          |
> | 9   |  512            | 8          |
> | 10  |  1024           | 8          |
> | 11  |  2048           | 16         |
> | 12  |  4096           | 16         |
> | 13  |  8192           | 16         |
> | 14  |  16384          | 32         |
> | 15  |  32768          | 32         |
> | 16  |  65536          | 64         |
> | 17  |  131072         | 64         |
> | 18  |  262144         | 64         |
> | 19  |  524288         | 32         |
> | 20  |  1048576        | 32         |
> | 21  |  2097152        | 32         |
> | 22  |  4194304        | 32         |
> | 23  |  8388608        | 32         |
> | 24  |  16777216       | 1          |
> |     | Total Entries   | 511        |
>  -----+-----------------+------------+
> 
> Credits: Special mention and credits to Ville Syrjala for coming up
> with a design for this feature and inputs. This series is based on
> his original design.
> 
> Note: Userspace support for this new UAPI will be done on Chrome and
> plan is to get this supported on mutter as well. We will notify the
> list once we have that ready for review.
> 

Is this an RFC? If so it would be good to mark it as such.

Harry

> Uma Shankar (9):
>   drm: Add gamma mode property
>   drm/i915/xelpd: Define color lut range structure
>   drm/i915/xelpd: Add support for Logarithmic gamma mode
>   drm/i915/xelpd: Attach gamma mode property
>   drm: Add Client Cap for advance gamma mode
>   drm/i915/xelpd: logarithmic gamma enabled only with advance gamma mode
>   drm/i915/xelpd: Enable Pipe Degamma
>   drm/i915/xelpd: Add Pipe Color Lut caps to platform config
>   drm/i915/xelpd: Enable XE_LPD Gamma Lut readout
> 
>  drivers/gpu/drm/drm_atomic_uapi.c          |   8 +
>  drivers/gpu/drm/drm_color_mgmt.c           |  75 ++++
>  drivers/gpu/drm/drm_ioctl.c                |   5 +
>  drivers/gpu/drm/i915/display/intel_color.c | 454 ++++++++++++++++++++-
>  drivers/gpu/drm/i915/i915_pci.c            |   3 +-
>  drivers/gpu/drm/i915/i915_reg.h            |   7 +
>  include/drm/drm_atomic.h                   |   1 +
>  include/drm/drm_color_mgmt.h               |   8 +
>  include/drm/drm_crtc.h                     |  25 ++
>  include/drm/drm_file.h                     |   8 +
>  include/uapi/drm/drm.h                     |   8 +
>  include/uapi/drm/drm_mode.h                |  43 ++
>  12 files changed, 630 insertions(+), 15 deletions(-)
>
Pekka Paalanen June 7, 2021, 7:29 a.m. UTC | #2
On Fri, 4 Jun 2021 14:51:25 -0400
Harry Wentland <harry.wentland@amd.com> wrote:

> On 2021-06-01 6:41 a.m., Uma Shankar wrote:
> > Modern hardwares have multi segmented lut approach to prioritize
> > the darker regions of the spectrum. This series introduces a new
> > UAPI to define the lut ranges supported by the respective hardware.
> > 
> > This also enables Pipe Color Management Support for Intel's XE_LPD hw.
> > Enable Support for Pipe Degamma with the increased lut samples
> > supported by hardware. This also adds support for newly introduced
> > Logarithmic Gamma for XE_LPD. Also added the gamma readout support.
> > 
> > The Logarithmic gamma implementation on XE_LPD is non linear and adds 25
> > segments with non linear lut samples in each segment. The expectation
> > is userspace will create the luts as per this distribution and pass
> > the final samples to driver to be programmed in hardware.
> >   
> 
> Is this design targetting Intel XE_LPD HW in particular or is it intended
> to be generic?
> 
> If this is intended to be generic I think it would benefit from a lot more
> documentation. At this point it's difficult for me to see how to adapt this
> to AMD HW. It would take me a while to be comfortable to make a call on whether
> we can use it or not. And what about other vendors?
> 
> I think we need to be cautious in directly exposing HW functionality through
> UAPI. The CM parts of AMD HW seem to be changing in some way each generation
> and it looks like the same is true for Intel. The trouble we have with adapting
> the old gamma/degamma properties to modern HW is some indication to me that
> this approach is somewhat problematic.
> 
> It would be useful to understand and document the specific use-cases we want to
> provide to userspace implementers with this functionality. Do we want to support
> modern transfer functions such as PQ or HLG? If so, it might be beneficial to
> have an API to explicitly specify that, and then use LUT tables in drivers that
> are optimized for the implementing HW.

Hi Harry,

from my very limited understanding so far, enum might be fine for PQ,
but HLG is not just one transfer function, although it may often be
confused as one. PQ and HLG are fundamentally different designs to HDR
broadcasting I believe. It would be unfortunate to make a mistake here,
engraving it into UAPI.

> Or is the use case tone mapping? If so,
> would a parametric definition of tone mapping be easier to manage?

A very good question at least I have no idea about.


Thanks,
pq

> > +-----+------------------------------+
> > | x   |  2 pow x segment|No of Entries
> > |     |  0              | 1          |
> > | 0   |  1              | 1          |
> > | 1   |  2              | 2          |
> > | 2   |  4              | 2          |
> > | 3   |  8              | 2          |
> > | 4   |  16             | 2          |
> > | 5   |  32             | 4          |
> > | 6   |  64             | 4          |
> > | 7   |  128            | 4          |
> > | 8   |  256            | 8          |
> > | 9   |  512            | 8          |
> > | 10  |  1024           | 8          |
> > | 11  |  2048           | 16         |
> > | 12  |  4096           | 16         |
> > | 13  |  8192           | 16         |
> > | 14  |  16384          | 32         |
> > | 15  |  32768          | 32         |
> > | 16  |  65536          | 64         |
> > | 17  |  131072         | 64         |
> > | 18  |  262144         | 64         |
> > | 19  |  524288         | 32         |
> > | 20  |  1048576        | 32         |
> > | 21  |  2097152        | 32         |
> > | 22  |  4194304        | 32         |
> > | 23  |  8388608        | 32         |
> > | 24  |  16777216       | 1          |
> > |     | Total Entries   | 511        |
> >  -----+-----------------+------------+
> > 
> > Credits: Special mention and credits to Ville Syrjala for coming up
> > with a design for this feature and inputs. This series is based on
> > his original design.
> > 
> > Note: Userspace support for this new UAPI will be done on Chrome and
> > plan is to get this supported on mutter as well. We will notify the
> > list once we have that ready for review.
> >   
> 
> Is this an RFC? If so it would be good to mark it as such.
> 
> Harry
> 
> > Uma Shankar (9):
> >   drm: Add gamma mode property
> >   drm/i915/xelpd: Define color lut range structure
> >   drm/i915/xelpd: Add support for Logarithmic gamma mode
> >   drm/i915/xelpd: Attach gamma mode property
> >   drm: Add Client Cap for advance gamma mode
> >   drm/i915/xelpd: logarithmic gamma enabled only with advance gamma mode
> >   drm/i915/xelpd: Enable Pipe Degamma
> >   drm/i915/xelpd: Add Pipe Color Lut caps to platform config
> >   drm/i915/xelpd: Enable XE_LPD Gamma Lut readout
> > 
> >  drivers/gpu/drm/drm_atomic_uapi.c          |   8 +
> >  drivers/gpu/drm/drm_color_mgmt.c           |  75 ++++
> >  drivers/gpu/drm/drm_ioctl.c                |   5 +
> >  drivers/gpu/drm/i915/display/intel_color.c | 454 ++++++++++++++++++++-
> >  drivers/gpu/drm/i915/i915_pci.c            |   3 +-
> >  drivers/gpu/drm/i915/i915_reg.h            |   7 +
> >  include/drm/drm_atomic.h                   |   1 +
> >  include/drm/drm_color_mgmt.h               |   8 +
> >  include/drm/drm_crtc.h                     |  25 ++
> >  include/drm/drm_file.h                     |   8 +
> >  include/uapi/drm/drm.h                     |   8 +
> >  include/uapi/drm/drm_mode.h                |  43 ++
> >  12 files changed, 630 insertions(+), 15 deletions(-)
> >   
>
Shankar, Uma June 7, 2021, 6:01 p.m. UTC | #3
> -----Original Message-----
> From: Harry Wentland <harry.wentland@amd.com>
> Sent: Saturday, June 5, 2021 12:21 AM
> To: Shankar, Uma <uma.shankar@intel.com>; intel-gfx@lists.freedesktop.org; dri-
> devel@lists.freedesktop.org
> Cc: Modem, Bhanuprakash <bhanuprakash.modem@intel.com>; Cyr, Aric
> <Aric.Cyr@amd.com>
> Subject: Re: [PATCH 0/9] Enhance pipe color support for multi segmented luts
> 
> On 2021-06-01 6:41 a.m., Uma Shankar wrote:
> > Modern hardwares have multi segmented lut approach to prioritize the
> > darker regions of the spectrum. This series introduces a new UAPI to
> > define the lut ranges supported by the respective hardware.
> >
> > This also enables Pipe Color Management Support for Intel's XE_LPD hw.
> > Enable Support for Pipe Degamma with the increased lut samples
> > supported by hardware. This also adds support for newly introduced
> > Logarithmic Gamma for XE_LPD. Also added the gamma readout support.
> >
> > The Logarithmic gamma implementation on XE_LPD is non linear and adds
> > 25 segments with non linear lut samples in each segment. The
> > expectation is userspace will create the luts as per this distribution
> > and pass the final samples to driver to be programmed in hardware.
> >
> 
> Is this design targetting Intel XE_LPD HW in particular or is it intended to be generic?
> 
> If this is intended to be generic I think it would benefit from a lot more
> documentation. At this point it's difficult for me to see how to adapt this to AMD
> HW. It would take me a while to be comfortable to make a call on whether we can
> use it or not. And what about other vendors?

This is expected to be generic for all vendors.  XE_LPD is just a reference implementation.
It's basically an extension of what we have for crtc color but designing the UAPI to have it
more scalable for future hardware. The legacy hardware implementation which we have in
crtc properties can easily fit in this new UAPI and this can help represent hardware better
with more precision and scalability. Credits to Ville as to this is his idea of how we can represent
hardware generically and advertise to userspace.

Sure, I will add more documentation to make this clearer. 

> I think we need to be cautious in directly exposing HW functionality through UAPI.
> The CM parts of AMD HW seem to be changing in some way each generation and it
> looks like the same is true for Intel. The trouble we have with adapting the old
> gamma/degamma properties to modern HW is some indication to me that this
> approach is somewhat problematic.
> 

The advantage of having flexibility in userspace is that we give access of hardware to
userspace.It can then control things based on various usecases and not limited by just
a subset of operations what we define (in the lack of such an implementation).

> It would be useful to understand and document the specific use-cases we want to
> provide to userspace implementers with this functionality. Do we want to support
> modern transfer functions such as PQ or HLG? If so, it might be beneficial to have an
> API to explicitly specify that, and then use LUT tables in drivers that are optimized for
> the implementing HW. Or is the use case tone mapping? If so, would a parametric
> definition of tone mapping be easier to manage?
> 

Yes right, ideally this is what intend to achieve here. We cant have fixed tables for operations
like Tone mapping as it will depend on mastering luminance values which can vary along with
other attributes of metadata. Eventually this operation would be done by the gamma block
(non linear luts), the values for which would be calculated and send by userspace. Thus making
all this very generic. Also we can't do any color math in driver as it has lot of floating operations.

So here the trade-off is between having a UAPI where userspace controls hw, computes and sends
values vs having just a fixed function operations with hard coded lut tables in driver.

Maybe we can have both the options in order to give flexibility to hardware vendors. We can
document the usage of the UAPI we create which can help things co-exist. Userspace can query
the supported properties and implement based on the properties exposed by the respective
vendor driver implementation. 

My personal preference would be to go with generic option (expose hardware to userspace) which
will make life easier for userspace developers. This will help use hardware for any color operation not
just limited to linearization, CSC conversions and tone mapping. Also this is already done for crtc, so it just
need to be extended to planes.

> > +-----+------------------------------+
> > | x   |  2 pow x segment|No of Entries
> > |     |  0              | 1          |
> > | 0   |  1              | 1          |
> > | 1   |  2              | 2          |
> > | 2   |  4              | 2          |
> > | 3   |  8              | 2          |
> > | 4   |  16             | 2          |
> > | 5   |  32             | 4          |
> > | 6   |  64             | 4          |
> > | 7   |  128            | 4          |
> > | 8   |  256            | 8          |
> > | 9   |  512            | 8          |
> > | 10  |  1024           | 8          |
> > | 11  |  2048           | 16         |
> > | 12  |  4096           | 16         |
> > | 13  |  8192           | 16         |
> > | 14  |  16384          | 32         |
> > | 15  |  32768          | 32         |
> > | 16  |  65536          | 64         |
> > | 17  |  131072         | 64         |
> > | 18  |  262144         | 64         |
> > | 19  |  524288         | 32         |
> > | 20  |  1048576        | 32         |
> > | 21  |  2097152        | 32         |
> > | 22  |  4194304        | 32         |
> > | 23  |  8388608        | 32         |
> > | 24  |  16777216       | 1          |
> > |     | Total Entries   | 511        |
> >  -----+-----------------+------------+
> >
> > Credits: Special mention and credits to Ville Syrjala for coming up
> > with a design for this feature and inputs. This series is based on his
> > original design.
> >
> > Note: Userspace support for this new UAPI will be done on Chrome and
> > plan is to get this supported on mutter as well. We will notify the
> > list once we have that ready for review.
> >
> 
> Is this an RFC? If so it would be good to mark it as such.

Yes, sure will update the tag.

Thanks Harry for the feedback.

Regards,
Uma Shankar

> Harry
> 
> > Uma Shankar (9):
> >   drm: Add gamma mode property
> >   drm/i915/xelpd: Define color lut range structure
> >   drm/i915/xelpd: Add support for Logarithmic gamma mode
> >   drm/i915/xelpd: Attach gamma mode property
> >   drm: Add Client Cap for advance gamma mode
> >   drm/i915/xelpd: logarithmic gamma enabled only with advance gamma mode
> >   drm/i915/xelpd: Enable Pipe Degamma
> >   drm/i915/xelpd: Add Pipe Color Lut caps to platform config
> >   drm/i915/xelpd: Enable XE_LPD Gamma Lut readout
> >
> >  drivers/gpu/drm/drm_atomic_uapi.c          |   8 +
> >  drivers/gpu/drm/drm_color_mgmt.c           |  75 ++++
> >  drivers/gpu/drm/drm_ioctl.c                |   5 +
> >  drivers/gpu/drm/i915/display/intel_color.c | 454 ++++++++++++++++++++-
> >  drivers/gpu/drm/i915/i915_pci.c            |   3 +-
> >  drivers/gpu/drm/i915/i915_reg.h            |   7 +
> >  include/drm/drm_atomic.h                   |   1 +
> >  include/drm/drm_color_mgmt.h               |   8 +
> >  include/drm/drm_crtc.h                     |  25 ++
> >  include/drm/drm_file.h                     |   8 +
> >  include/uapi/drm/drm.h                     |   8 +
> >  include/uapi/drm/drm_mode.h                |  43 ++
> >  12 files changed, 630 insertions(+), 15 deletions(-)
> >
Shankar, Uma June 7, 2021, 6:07 p.m. UTC | #4
> -----Original Message-----
> From: dri-devel <dri-devel-bounces@lists.freedesktop.org> On Behalf Of Pekka
> Paalanen
> Sent: Monday, June 7, 2021 1:00 PM
> To: Harry Wentland <harry.wentland@amd.com>
> Cc: intel-gfx@lists.freedesktop.org; Shankar, Uma <uma.shankar@intel.com>;
> Sebastian Wick <sebastian@sebastianwick.net>; dri-devel@lists.freedesktop.org;
> Modem, Bhanuprakash <bhanuprakash.modem@intel.com>
> Subject: Re: [PATCH 0/9] Enhance pipe color support for multi segmented luts
> 
> On Fri, 4 Jun 2021 14:51:25 -0400
> Harry Wentland <harry.wentland@amd.com> wrote:
> 
> > On 2021-06-01 6:41 a.m., Uma Shankar wrote:
> > > Modern hardwares have multi segmented lut approach to prioritize the
> > > darker regions of the spectrum. This series introduces a new UAPI to
> > > define the lut ranges supported by the respective hardware.
> > >
> > > This also enables Pipe Color Management Support for Intel's XE_LPD hw.
> > > Enable Support for Pipe Degamma with the increased lut samples
> > > supported by hardware. This also adds support for newly introduced
> > > Logarithmic Gamma for XE_LPD. Also added the gamma readout support.
> > >
> > > The Logarithmic gamma implementation on XE_LPD is non linear and
> > > adds 25 segments with non linear lut samples in each segment. The
> > > expectation is userspace will create the luts as per this
> > > distribution and pass the final samples to driver to be programmed in hardware.
> > >
> >
> > Is this design targetting Intel XE_LPD HW in particular or is it
> > intended to be generic?
> >
> > If this is intended to be generic I think it would benefit from a lot
> > more documentation. At this point it's difficult for me to see how to
> > adapt this to AMD HW. It would take me a while to be comfortable to
> > make a call on whether we can use it or not. And what about other vendors?
> >
> > I think we need to be cautious in directly exposing HW functionality
> > through UAPI. The CM parts of AMD HW seem to be changing in some way
> > each generation and it looks like the same is true for Intel. The
> > trouble we have with adapting the old gamma/degamma properties to
> > modern HW is some indication to me that this approach is somewhat problematic.
> >
> > It would be useful to understand and document the specific use-cases
> > we want to provide to userspace implementers with this functionality.
> > Do we want to support modern transfer functions such as PQ or HLG? If
> > so, it might be beneficial to have an API to explicitly specify that,
> > and then use LUT tables in drivers that are optimized for the implementing HW.
> 
> Hi Harry,
> 
> from my very limited understanding so far, enum might be fine for PQ, but HLG is not
> just one transfer function, although it may often be confused as one. PQ and HLG
> are fundamentally different designs to HDR broadcasting I believe. It would be
> unfortunate to make a mistake here, engraving it into UAPI.

Yes Pekka, putting this in UAPI may limit us.

> > Or is the use case tone mapping? If so, would a parametric definition
> > of tone mapping be easier to manage?
> 
> A very good question at least I have no idea about.

Responded on earlier mail in thread. For non linear lut (gamma block), usecase is primarily tone
mapping but there are implementations where non linear blending is seeked (AFAIR Android does that),
so it leaves room for those usecases as well.

Regards,
Uma Shankar
> 
> Thanks,
> pq
> 
> > > +-----+------------------------------+
> > > | x   |  2 pow x segment|No of Entries
> > > |     |  0              | 1          |
> > > | 0   |  1              | 1          |
> > > | 1   |  2              | 2          |
> > > | 2   |  4              | 2          |
> > > | 3   |  8              | 2          |
> > > | 4   |  16             | 2          |
> > > | 5   |  32             | 4          |
> > > | 6   |  64             | 4          |
> > > | 7   |  128            | 4          |
> > > | 8   |  256            | 8          |
> > > | 9   |  512            | 8          |
> > > | 10  |  1024           | 8          |
> > > | 11  |  2048           | 16         |
> > > | 12  |  4096           | 16         |
> > > | 13  |  8192           | 16         |
> > > | 14  |  16384          | 32         |
> > > | 15  |  32768          | 32         |
> > > | 16  |  65536          | 64         |
> > > | 17  |  131072         | 64         |
> > > | 18  |  262144         | 64         |
> > > | 19  |  524288         | 32         |
> > > | 20  |  1048576        | 32         |
> > > | 21  |  2097152        | 32         |
> > > | 22  |  4194304        | 32         |
> > > | 23  |  8388608        | 32         |
> > > | 24  |  16777216       | 1          |
> > > |     | Total Entries   | 511        |
> > >  -----+-----------------+------------+
> > >
> > > Credits: Special mention and credits to Ville Syrjala for coming up
> > > with a design for this feature and inputs. This series is based on
> > > his original design.
> > >
> > > Note: Userspace support for this new UAPI will be done on Chrome and
> > > plan is to get this supported on mutter as well. We will notify the
> > > list once we have that ready for review.
> > >
> >
> > Is this an RFC? If so it would be good to mark it as such.
> >
> > Harry
> >
> > > Uma Shankar (9):
> > >   drm: Add gamma mode property
> > >   drm/i915/xelpd: Define color lut range structure
> > >   drm/i915/xelpd: Add support for Logarithmic gamma mode
> > >   drm/i915/xelpd: Attach gamma mode property
> > >   drm: Add Client Cap for advance gamma mode
> > >   drm/i915/xelpd: logarithmic gamma enabled only with advance gamma mode
> > >   drm/i915/xelpd: Enable Pipe Degamma
> > >   drm/i915/xelpd: Add Pipe Color Lut caps to platform config
> > >   drm/i915/xelpd: Enable XE_LPD Gamma Lut readout
> > >
> > >  drivers/gpu/drm/drm_atomic_uapi.c          |   8 +
> > >  drivers/gpu/drm/drm_color_mgmt.c           |  75 ++++
> > >  drivers/gpu/drm/drm_ioctl.c                |   5 +
> > >  drivers/gpu/drm/i915/display/intel_color.c | 454 ++++++++++++++++++++-
> > >  drivers/gpu/drm/i915/i915_pci.c            |   3 +-
> > >  drivers/gpu/drm/i915/i915_reg.h            |   7 +
> > >  include/drm/drm_atomic.h                   |   1 +
> > >  include/drm/drm_color_mgmt.h               |   8 +
> > >  include/drm/drm_crtc.h                     |  25 ++
> > >  include/drm/drm_file.h                     |   8 +
> > >  include/uapi/drm/drm.h                     |   8 +
> > >  include/uapi/drm/drm_mode.h                |  43 ++
> > >  12 files changed, 630 insertions(+), 15 deletions(-)
> > >
> >
Harry Wentland June 7, 2021, 9 p.m. UTC | #5
On 2021-06-07 2:01 p.m., Shankar, Uma wrote:
> 
> 
>> -----Original Message-----
>> From: Harry Wentland <harry.wentland@amd.com>
>> Sent: Saturday, June 5, 2021 12:21 AM
>> To: Shankar, Uma <uma.shankar@intel.com>; intel-gfx@lists.freedesktop.org; dri-
>> devel@lists.freedesktop.org
>> Cc: Modem, Bhanuprakash <bhanuprakash.modem@intel.com>; Cyr, Aric
>> <Aric.Cyr@amd.com>
>> Subject: Re: [PATCH 0/9] Enhance pipe color support for multi segmented luts
>>
>> On 2021-06-01 6:41 a.m., Uma Shankar wrote:
>>> Modern hardwares have multi segmented lut approach to prioritize the
>>> darker regions of the spectrum. This series introduces a new UAPI to
>>> define the lut ranges supported by the respective hardware.
>>>
>>> This also enables Pipe Color Management Support for Intel's XE_LPD hw.
>>> Enable Support for Pipe Degamma with the increased lut samples
>>> supported by hardware. This also adds support for newly introduced
>>> Logarithmic Gamma for XE_LPD. Also added the gamma readout support.
>>>
>>> The Logarithmic gamma implementation on XE_LPD is non linear and adds
>>> 25 segments with non linear lut samples in each segment. The
>>> expectation is userspace will create the luts as per this distribution
>>> and pass the final samples to driver to be programmed in hardware.
>>>
>>
>> Is this design targetting Intel XE_LPD HW in particular or is it intended to be generic?
>>
>> If this is intended to be generic I think it would benefit from a lot more
>> documentation. At this point it's difficult for me to see how to adapt this to AMD
>> HW. It would take me a while to be comfortable to make a call on whether we can
>> use it or not. And what about other vendors?
> 
> This is expected to be generic for all vendors.  XE_LPD is just a reference implementation.
> It's basically an extension of what we have for crtc color but designing the UAPI to have it
> more scalable for future hardware. The legacy hardware implementation which we have in
> crtc properties can easily fit in this new UAPI and this can help represent hardware better
> with more precision and scalability. Credits to Ville as to this is his idea of how we can represent
> hardware generically and advertise to userspace.
> 
> Sure, I will add more documentation to make this clearer. 
> 
>> I think we need to be cautious in directly exposing HW functionality through UAPI.
>> The CM parts of AMD HW seem to be changing in some way each generation and it
>> looks like the same is true for Intel. The trouble we have with adapting the old
>> gamma/degamma properties to modern HW is some indication to me that this
>> approach is somewhat problematic.
>>
> 
> The advantage of having flexibility in userspace is that we give access of hardware to
> userspace.It can then control things based on various usecases and not limited by just
> a subset of operations what we define (in the lack of such an implementation).
> 
>> It would be useful to understand and document the specific use-cases we want to
>> provide to userspace implementers with this functionality. Do we want to support
>> modern transfer functions such as PQ or HLG? If so, it might be beneficial to have an
>> API to explicitly specify that, and then use LUT tables in drivers that are optimized for
>> the implementing HW. Or is the use case tone mapping? If so, would a parametric
>> definition of tone mapping be easier to manage?
>>
> 
> Yes right, ideally this is what intend to achieve here. We cant have fixed tables for operations
> like Tone mapping as it will depend on mastering luminance values which can vary along with
> other attributes of metadata. Eventually this operation would be done by the gamma block
> (non linear luts), the values for which would be calculated and send by userspace. Thus making
> all this very generic. Also we can't do any color math in driver as it has lot of floating operations.
> 
> So here the trade-off is between having a UAPI where userspace controls hw, computes and sends
> values vs having just a fixed function operations with hard coded lut tables in driver.
> 
> Maybe we can have both the options in order to give flexibility to hardware vendors. We can
> document the usage of the UAPI we create which can help things co-exist. Userspace can query
> the supported properties and implement based on the properties exposed by the respective
> vendor driver implementation. 
> 
> My personal preference would be to go with generic option (expose hardware to userspace) which
> will make life easier for userspace developers. This will help use hardware for any color operation not
> just limited to linearization, CSC conversions and tone mapping. Also this is already done for crtc, so it just
> need to be extended to planes.
> 

Thanks for providing more background.

How would a driver handle this segmented LUT when the implementing HW
doesn't have 512 points, but uses more, or less, or differently
distributed points?

What about HW that doesn't support RAM LUTs and only supports ROMs?
Obviously such HW would likely not be able to do tone mapping in HW
but could still linearize the content.

Harry

>>> +-----+------------------------------+
>>> | x   |  2 pow x segment|No of Entries
>>> |     |  0              | 1          |
>>> | 0   |  1              | 1          |
>>> | 1   |  2              | 2          |
>>> | 2   |  4              | 2          |
>>> | 3   |  8              | 2          |
>>> | 4   |  16             | 2          |
>>> | 5   |  32             | 4          |
>>> | 6   |  64             | 4          |
>>> | 7   |  128            | 4          |
>>> | 8   |  256            | 8          |
>>> | 9   |  512            | 8          |
>>> | 10  |  1024           | 8          |
>>> | 11  |  2048           | 16         |
>>> | 12  |  4096           | 16         |
>>> | 13  |  8192           | 16         |
>>> | 14  |  16384          | 32         |
>>> | 15  |  32768          | 32         |
>>> | 16  |  65536          | 64         |
>>> | 17  |  131072         | 64         |
>>> | 18  |  262144         | 64         |
>>> | 19  |  524288         | 32         |
>>> | 20  |  1048576        | 32         |
>>> | 21  |  2097152        | 32         |
>>> | 22  |  4194304        | 32         |
>>> | 23  |  8388608        | 32         |
>>> | 24  |  16777216       | 1          |
>>> |     | Total Entries   | 511        |
>>>  -----+-----------------+------------+
>>>
>>> Credits: Special mention and credits to Ville Syrjala for coming up
>>> with a design for this feature and inputs. This series is based on his
>>> original design.
>>>
>>> Note: Userspace support for this new UAPI will be done on Chrome and
>>> plan is to get this supported on mutter as well. We will notify the
>>> list once we have that ready for review.
>>>
>>
>> Is this an RFC? If so it would be good to mark it as such.
> 
> Yes, sure will update the tag.
> 
> Thanks Harry for the feedback.
> 
> Regards,
> Uma Shankar
> 
>> Harry
>>
>>> Uma Shankar (9):
>>>   drm: Add gamma mode property
>>>   drm/i915/xelpd: Define color lut range structure
>>>   drm/i915/xelpd: Add support for Logarithmic gamma mode
>>>   drm/i915/xelpd: Attach gamma mode property
>>>   drm: Add Client Cap for advance gamma mode
>>>   drm/i915/xelpd: logarithmic gamma enabled only with advance gamma mode
>>>   drm/i915/xelpd: Enable Pipe Degamma
>>>   drm/i915/xelpd: Add Pipe Color Lut caps to platform config
>>>   drm/i915/xelpd: Enable XE_LPD Gamma Lut readout
>>>
>>>  drivers/gpu/drm/drm_atomic_uapi.c          |   8 +
>>>  drivers/gpu/drm/drm_color_mgmt.c           |  75 ++++
>>>  drivers/gpu/drm/drm_ioctl.c                |   5 +
>>>  drivers/gpu/drm/i915/display/intel_color.c | 454 ++++++++++++++++++++-
>>>  drivers/gpu/drm/i915/i915_pci.c            |   3 +-
>>>  drivers/gpu/drm/i915/i915_reg.h            |   7 +
>>>  include/drm/drm_atomic.h                   |   1 +
>>>  include/drm/drm_color_mgmt.h               |   8 +
>>>  include/drm/drm_crtc.h                     |  25 ++
>>>  include/drm/drm_file.h                     |   8 +
>>>  include/uapi/drm/drm.h                     |   8 +
>>>  include/uapi/drm/drm_mode.h                |  43 ++
>>>  12 files changed, 630 insertions(+), 15 deletions(-)
>>>
>
Pekka Paalanen June 8, 2021, 7:59 a.m. UTC | #6
On Mon, 7 Jun 2021 18:07:23 +0000
"Shankar, Uma" <uma.shankar@intel.com> wrote:

> > -----Original Message-----
> > From: dri-devel <dri-devel-bounces@lists.freedesktop.org> On Behalf Of Pekka
> > Paalanen
> > Sent: Monday, June 7, 2021 1:00 PM
> > To: Harry Wentland <harry.wentland@amd.com>
> > Cc: intel-gfx@lists.freedesktop.org; Shankar, Uma <uma.shankar@intel.com>;
> > Sebastian Wick <sebastian@sebastianwick.net>; dri-devel@lists.freedesktop.org;
> > Modem, Bhanuprakash <bhanuprakash.modem@intel.com>
> > Subject: Re: [PATCH 0/9] Enhance pipe color support for multi segmented luts
> > 
> > On Fri, 4 Jun 2021 14:51:25 -0400
> > Harry Wentland <harry.wentland@amd.com> wrote:
> >   
> > > On 2021-06-01 6:41 a.m., Uma Shankar wrote:  
> > > > Modern hardwares have multi segmented lut approach to prioritize the
> > > > darker regions of the spectrum. This series introduces a new UAPI to
> > > > define the lut ranges supported by the respective hardware.
> > > >
> > > > This also enables Pipe Color Management Support for Intel's XE_LPD hw.
> > > > Enable Support for Pipe Degamma with the increased lut samples
> > > > supported by hardware. This also adds support for newly introduced
> > > > Logarithmic Gamma for XE_LPD. Also added the gamma readout support.
> > > >
> > > > The Logarithmic gamma implementation on XE_LPD is non linear and
> > > > adds 25 segments with non linear lut samples in each segment. The
> > > > expectation is userspace will create the luts as per this
> > > > distribution and pass the final samples to driver to be programmed in hardware.
> > > >  
> > >
> > > Is this design targetting Intel XE_LPD HW in particular or is it
> > > intended to be generic?
> > >
> > > If this is intended to be generic I think it would benefit from a lot
> > > more documentation. At this point it's difficult for me to see how to
> > > adapt this to AMD HW. It would take me a while to be comfortable to
> > > make a call on whether we can use it or not. And what about other vendors?
> > >
> > > I think we need to be cautious in directly exposing HW functionality
> > > through UAPI. The CM parts of AMD HW seem to be changing in some way
> > > each generation and it looks like the same is true for Intel. The
> > > trouble we have with adapting the old gamma/degamma properties to
> > > modern HW is some indication to me that this approach is somewhat problematic.
> > >
> > > It would be useful to understand and document the specific use-cases
> > > we want to provide to userspace implementers with this functionality.
> > > Do we want to support modern transfer functions such as PQ or HLG? If
> > > so, it might be beneficial to have an API to explicitly specify that,
> > > and then use LUT tables in drivers that are optimized for the implementing HW.  
> > 
> > Hi Harry,
> > 
> > from my very limited understanding so far, enum might be fine for PQ, but HLG is not
> > just one transfer function, although it may often be confused as one. PQ and HLG
> > are fundamentally different designs to HDR broadcasting I believe. It would be
> > unfortunate to make a mistake here, engraving it into UAPI.  
> 
> Yes Pekka, putting this in UAPI may limit us.
> 
> > > Or is the use case tone mapping? If so, would a parametric definition
> > > of tone mapping be easier to manage?  
> > 
> > A very good question at least I have no idea about.  
> 
> Responded on earlier mail in thread. For non linear lut (gamma
> block), usecase is primarily tone mapping but there are
> implementations where non linear blending is seeked (AFAIR Android
> does that), so it leaves room for those usecases as well.

Yes, non-linear blending is a thing, unfortunately. Developers do not
usually understand what could be wrong with simply blending "RGBA
values", so most software just does that. It produces *a* result, and
if all you use it for is shades of black (shadows) or rounded window
corners, you never even see anything wrong with it. So the world has
accustomed to seeing "incorrect blending" so much that they think doing
anything else is wrong and complain if you try to move to physically
correct blending, because it changes the strength of shadows. Hence
any software migrating to a more correct blending formula may be met
with bug reports.

What's worse, pre-multiplied alpha is used as an optimization, as
implemented everywhere including Wayland, in a way that is actually a
step *away* from correct blending. If one wants to do correct blending,
you first need to divide out the pre-multiplied alpha, then linearize,
then blend.

Luckily(?), non-linear blending of HDR content will probably look a lot
worse than the same mistake on SDR content.


Thanks,
pq