Skip to contentSkip to conversation

Plane Color Pipeline support for Intel platforms

PATCH Superseded Uma Shankar 7 participants 52 messages Feb 13, 2024 – Feb 19, 2024

Subsystems (6)

v1 of 8 Superseded Latest is v8 →

lore
Share & tools
lore
#0 lore raw

cover Plane Color Pipeline support for Intel platforms

This series intends to add support for Plane Color Management for Intel platforms. This is based on the design which has been agreed upon by the community. Series implementing the design for generic DRM core has been sent out by Harry Wentland and is under review below:
https://patchwork.freedesktop.org/series/123446/

The base work of above series is squashed under 1 patch and support for Intel platform is added on top of it.
Any reviews on the original core design is expected to be done in Harry's series to avoid any forking of the discussion.

We have added some changes/fixes to the Harry's core DRM changes, being put up as separate patches on top of squashed patch. These are expected to get included in the main series from Harry once agreed upon.

Changes added on core design:
1. Below patches implement some fixes on original series
drm: Add missing function declarations
drm: handle NULL next colorop in drm_colorop_set_next_property
drm: Fix error logging in set Color Pipeline

2. Implemented a HW capability property to expose segmented luts.
drm: Add Color lut range attributes
drm: Add Color ops capability property
drm: Define helper to create color ops capability property
drm: Define helper for adding capability property for 1D LUT

This helps in generically defining the hardware lut capabilities, lut distribution, precision, segmented or PWL LUTS.

3. Added support for enhanced prescision, 3x3 matrix and 1d LUT:
drm: Add Enhanced LUT precision structure
drm: Add support for 3x3 CTM
drm: Add 1D LUT color op

On top of this base work for DRM core plane color pipeline design, implementation is done for Intel hardware platforms. Below patches include the same:

drm/i915: Add identifiers for intel color blocks
drm/i915: Add intel_color_op
drm/i915/color: Add helper to allocate intel colorop drm/i915/color: Add helper to create intel colorop drm/i915/color: Create a transfer function color pipeline drm/i915/color: Add and attach COLORPIPELINE plane property drm/i915/color: Add framework to set colorop drm/i915/color: Add callbacks to set plane CTM drm/i915/color: Add framework to program PRE/POST CSC LUT
FIXME: force disable legacy plane color properties for TGL and beyond drm/i915/color: Enable Plane Color Pipelines
drm/i915: Define segmented Lut and add capabilities to colorop drm/i915/color: Add plane CTM callback for TGL and beyond drm/i915: Add register definitions for Plane Degamma drm/i915: Add register definitions for Plane Post CSC drm/i915/color: Program Pre-CSC registers
drm/i915/xelpd: Program Plane Post CSC Registers

Bhanu from Intel will be sending out the igt changes to help test the color pipeline implementation based on the current igt changes sent out by Harry.
https://patchwork.freedesktop.org/series/123448/

Planned Next Steps:
1. Work with Harry and community and get DRM core changes for color pipeline merged.
2. Implement pipe color management (post blending) based on the current color pipeline design.
3. Work with compositor maintainers to get color processing implemented using display hardware, thereby avoid any GL or GPU shaders.

Thanks to all the community maintainers and contributors who have helped to get this support in upstream Linux. Looking forward to collaborate, work together and get this merged.

Cc Ville Syrjala <[email protected]>
Cc Pekka Paalanen <[email protected]>
Cc Simon Ser <[email protected]>
Cc Harry Wentland <[email protected]>
Cc Melissa Wen <[email protected]>
Cc Jonas Ådahl <[email protected]>
Cc Sebastian Wick <[email protected]>
Cc Shashank Sharma <[email protected]>
Cc Alexander Goins <[email protected]>
Cc Joshua Ashton <[email protected]>
Cc Michel Dänzer <[email protected]>
Cc Aleix Pol <[email protected]>
Cc Xaver Hugl <[email protected]>
Cc Victoria Brekenfeld <[email protected]>
Cc Naseer Ahmed <[email protected]>
Cc Christopher Braga <[email protected]>
Cc Abhinav Kumar <[email protected]>
Cc Arthur Grillo <[email protected]>
Cc Hector Martin <[email protected]>
Cc Liviu Dudau <[email protected]>
Cc Sasha McIntosh <[email protected]>
Cc Chaitanya Kumar Borah <[email protected]>

Chaitanya Kumar Borah (16):
drm: Add missing function declarations
drm: handle NULL next colorop in drm_colorop_set_next_property
drm: Fix error logging in set Color Pipeline
drm: Add support for 3x3 CTM
drm: Add 1D LUT color op
drm/i915: Add identifiers for intel color blocks
drm/i915: Add intel_color_op
drm/i915/color: Add helper to allocate intel colorop drm/i915/color: Add helper to create intel colorop drm/i915/color: Create a transfer function color pipeline drm/i915/color: Add and attach COLORPIPELINE plane property drm/i915/color: Add framework to set colorop drm/i915/color: Add callbacks to set plane CTM drm/i915/color: Add framework to program PRE/POST CSC LUT
FIXME: force disable legacy plane color properties for TGL and beyond drm/i915/color: Enable Plane Color Pipelines

Harry Wentland (1):
[NOT FOR REVIEW] drm: color pipeline base work

Uma Shankar (11):
drm: Add Enhanced LUT precision structure
drm: Add Color lut range attributes
drm: Add Color ops capability property
drm: Define helper to create color ops capability property
drm: Define helper for adding capability property for 1D LUT drm/i915: Define segmented Lut and add capabilities to colorop drm/i915/color: Add plane CTM callback for TGL and beyond drm/i915: Add register definitions for Plane Degamma drm/i915: Add register definitions for Plane Post CSC drm/i915/color: Program Pre-CSC registers drm/i915/xelpd: Program Plane Post CSC Registers

 Documentation/gpu/rfc/color_pipeline.rst      | 352 ++++++++
 drivers/gpu/drm/Makefile                      |   1 +
 drivers/gpu/drm/drm_atomic.c                  | 147 ++++
 drivers/gpu/drm/drm_atomic_helper.c           |  12 +
 drivers/gpu/drm/drm_atomic_state_helper.c     |   5 +
 drivers/gpu/drm/drm_atomic_uapi.c             | 170 ++++
 drivers/gpu/drm/drm_colorop.c                 | 335 ++++++++
 drivers/gpu/drm/drm_ioctl.c                   |   7 +
 drivers/gpu/drm/drm_mode_config.c             |   7 +
 drivers/gpu/drm/i915/display/intel_color.c    | 562 ++++++++++++
 drivers/gpu/drm/i915/display/intel_color.h    |  16 +
 .../drm/i915/display/intel_display_limits.h   |  13 +
 .../drm/i915/display/intel_display_types.h    |  17 +
 .../drm/i915/display/skl_universal_plane.c    |  19 +-
 drivers/gpu/drm/i915/i915_reg.h               | 124 +++
 drivers/gpu/drm/tests/Makefile                |   4 +-
 drivers/gpu/drm/tests/drm_fixp_test.c         |  69 ++
 drivers/gpu/drm/vkms/Kconfig                  |   5 +
 drivers/gpu/drm/vkms/Makefile                 |   4 +-
 drivers/gpu/drm/vkms/tests/.kunitconfig       |   4 +
 drivers/gpu/drm/vkms/tests/vkms_color_tests.c | 355 ++++++++
 drivers/gpu/drm/vkms/vkms_colorop.c           | 115 +++
 drivers/gpu/drm/vkms/vkms_composer.c          | 117 ++-
 drivers/gpu/drm/vkms/vkms_drv.h               |   8 +
 drivers/gpu/drm/vkms/vkms_luts.c              | 802 ++++++++++++++++++
 drivers/gpu/drm/vkms/vkms_luts.h              |  12 +
 drivers/gpu/drm/vkms/vkms_plane.c             |   2 +
 include/drm/drm_atomic.h                      |  87 ++
 include/drm/drm_atomic_uapi.h                 |   3 +
 include/drm/drm_color_mgmt.h                  |  23 +
 include/drm/drm_colorop.h                     | 274 ++++++
 include/drm/drm_file.h                        |   7 +
 include/drm/drm_fixed.h                       |  18 +
 include/drm/drm_mode_config.h                 |  18 +
 include/drm/drm_plane.h                       |  10 +
 include/uapi/drm/drm.h                        |  18 +
 include/uapi/drm/drm_mode.h                   |  83 ++
 37 files changed, 3815 insertions(+), 10 deletions(-)
 create mode 100644 Documentation/gpu/rfc/color_pipeline.rst
 create mode 100644 drivers/gpu/drm/drm_colorop.c
 create mode 100644 drivers/gpu/drm/tests/drm_fixp_test.c
 create mode 100644 drivers/gpu/drm/vkms/tests/.kunitconfig
 create mode 100644 drivers/gpu/drm/vkms/tests/vkms_color_tests.c
 create mode 100644 drivers/gpu/drm/vkms/vkms_colorop.c
 create mode 100644 drivers/gpu/drm/vkms/vkms_luts.c
 create mode 100644 drivers/gpu/drm/vkms/vkms_luts.h
 create mode 100644 include/drm/drm_colorop.h
Signature · 1 line
2.42.0
#1 lore raw

PATCH 1/28 drm: color pipeline base work

From: Harry Wentland <[email protected]>

This is a squashed patch based on a series sent out by Harry wentland. It contains all the changes in the series(v3) currently under review below.

https://patchwork.freedesktop.org/patch/566614/?series=123446&rev=3

This patch lays the ground work for incremental changes and Intel specific pipeline changes.

NOTE: This patch is not meant for review. Any review related to this patch should be done on the original series. In order not to diverge the discussion from the main series.

---
 Documentation/gpu/rfc/color_pipeline.rst      | 352 ++++++++
 drivers/gpu/drm/Makefile                      |   1 +
 drivers/gpu/drm/drm_atomic.c                  | 147 ++++
 drivers/gpu/drm/drm_atomic_helper.c           |  12 +
 drivers/gpu/drm/drm_atomic_state_helper.c     |   5 +
 drivers/gpu/drm/drm_atomic_uapi.c             | 161 ++++
 drivers/gpu/drm/drm_colorop.c                 | 292 +++++++
 drivers/gpu/drm/drm_ioctl.c                   |   7 +
 drivers/gpu/drm/drm_mode_config.c             |   7 +
 drivers/gpu/drm/tests/Makefile                |   4 +-
 drivers/gpu/drm/tests/drm_fixp_test.c         |  69 ++
 drivers/gpu/drm/vkms/Kconfig                  |   5 +
 drivers/gpu/drm/vkms/Makefile                 |   4 +-
 drivers/gpu/drm/vkms/tests/.kunitconfig       |   4 +
 drivers/gpu/drm/vkms/tests/vkms_color_tests.c | 355 ++++++++
 drivers/gpu/drm/vkms/vkms_colorop.c           | 115 +++
 drivers/gpu/drm/vkms/vkms_composer.c          | 117 ++-
 drivers/gpu/drm/vkms/vkms_drv.h               |   8 +
 drivers/gpu/drm/vkms/vkms_luts.c              | 802 ++++++++++++++++++
 drivers/gpu/drm/vkms/vkms_luts.h              |  12 +
 drivers/gpu/drm/vkms/vkms_plane.c             |   2 +
 include/drm/drm_atomic.h                      |  84 ++
 include/drm/drm_atomic_uapi.h                 |   3 +
 include/drm/drm_colorop.h                     | 258 ++++++
 include/drm/drm_file.h                        |   7 +
 include/drm/drm_fixed.h                       |  18 +
 include/drm/drm_mode_config.h                 |  18 +
 include/drm/drm_plane.h                       |  10 +
 include/uapi/drm/drm.h                        |  18 +
 include/uapi/drm/drm_mode.h                   |   6 +
 30 files changed, 2899 insertions(+), 4 deletions(-)
 create mode 100644 Documentation/gpu/rfc/color_pipeline.rst
 create mode 100644 drivers/gpu/drm/drm_colorop.c
 create mode 100644 drivers/gpu/drm/tests/drm_fixp_test.c
 create mode 100644 drivers/gpu/drm/vkms/tests/.kunitconfig
 create mode 100644 drivers/gpu/drm/vkms/tests/vkms_color_tests.c
 create mode 100644 drivers/gpu/drm/vkms/vkms_colorop.c
 create mode 100644 drivers/gpu/drm/vkms/vkms_luts.c
 create mode 100644 drivers/gpu/drm/vkms/vkms_luts.h
 create mode 100644 include/drm/drm_colorop.h
Documentation/gpu/rfc/color_pipeline.rst new file +352 -0
new file mode 100644
index 000000000000..efc70570a592
@@ -0,0 +1,352 @@
+========================
+Linux Color Pipeline API
+========================
+
+What problem are we solving?
+============================
+
+We would like to support pre-, and post-blending complex color
+transformations in display controller hardware in order to allow for
+HW-supported HDR use-cases, as well as to provide support to
+color-managed applications, such as video or image editors.
+
+It is possible to support an HDR output on HW supporting the Colorspace
+and HDR Metadata drm_connector properties, but that requires the
+compositor or application to render and compose the content into one
+final buffer intended for display. Doing so is costly.
+
+Most modern display HW offers various 1D LUTs, 3D LUTs, matrices, and other
+operations to support color transformations. These operations are often
+implemented in fixed-function HW and therefore much more power efficient than
+performing similar operations via shaders or CPU.
+
+We would like to make use of this HW functionality to support complex color
+transformations with no, or minimal CPU or shader load.
+
+
+How are other OSes solving this problem?
+========================================
+
+The most widely supported use-cases regard HDR content, whether video or
+gaming.
+
+Most OSes will specify the source content format (color gamut, encoding transfer
+function, and other metadata, such as max and average light levels) to a driver.
+Drivers will then program their fixed-function HW accordingly to map from a
+source content buffer's space to a display's space.
+
+When fixed-function HW is not available the compositor will assemble a shader to
+ask the GPU to perform the transformation from the source content format to the
+display's format.
+
+A compositor's mapping function and a driver's mapping function are usually
+entirely separate concepts. On OSes where a HW vendor has no insight into
+closed-source compositor code such a vendor will tune their color management
+code to visually match the compositor's. On other OSes, where both mapping
+functions are open to an implementer they will ensure both mappings match.
+
+This results in mapping algorithm lock-in, meaning that no-one alone can
+experiment with or introduce new mapping algorithms and achieve
+consistent results regardless of which implementation path is taken.
+
+Why is Linux different?
+=======================
+
+Unlike other OSes, where there is one compositor for one or more drivers, on
+Linux we have a many-to-many relationship. Many compositors; many drivers.
+In addition each compositor vendor or community has their own view of how
+color management should be done. This is what makes Linux so beautiful.
+
+This means that a HW vendor can now no longer tune their driver to one
+compositor, as tuning it to one could make it look fairly different from
+another compositor's color mapping.
+
+We need a better solution.
+
+
+Descriptive API
+===============
+
+An API that describes the source and destination colorspaces is a descriptive
+API. It describes the input and output color spaces but does not describe
+how precisely they should be mapped. Such a mapping includes many minute
+design decision that can greatly affect the look of the final result.
+
+It is not feasible to describe such mapping with enough detail to ensure the
+same result from each implementation. In fact, these mappings are a very active
+research area.
+
+
+Prescriptive API
+================
+
+A prescriptive API describes not the source and destination colorspaces. It
+instead prescribes a recipe for how to manipulate pixel values to arrive at the
+desired outcome.
+
+This recipe is generally an ordered list of straight-forward operations,
+with clear mathematical definitions, such as 1D LUTs, 3D LUTs, matrices,
+or other operations that can be described in a precise manner.
+
+
+The Color Pipeline API
+======================
+
+HW color management pipelines can significantly differ between HW
+vendors in terms of availability, ordering, and capabilities of HW
+blocks. This makes a common definition of color management blocks and
+their ordering nigh impossible. Instead we are defining an API that
+allows user space to discover the HW capabilities in a generic manner,
+agnostic of specific drivers and hardware.
+
+
+drm_colorop Object & IOCTLs
+===========================
+
+To support the definition of color pipelines we define the DRM core
+object type drm_colorop. Individual drm_colorop objects will be chained
+via the NEXT property of a drm_colorop to constitute a color pipeline.
+Each drm_colorop object is unique, i.e., even if multiple color
+pipelines have the same operation they won't share the same drm_colorop
+object to describe that operation.
+
+Note that drivers are not expected to map drm_colorop objects statically
+to specific HW blocks. The mapping of drm_colorop objects is entirely a
+driver-internal detail and can be as dynamic or static as a driver needs
+it to be. See more in the Driver Implementation Guide section below.
+
+Just like other DRM objects the drm_colorop objects are discovered via
+IOCTLs:
+
+DRM_IOCTL_MODE_GETCOLOROPRESOURCES: This IOCTL is used to retrieve the
+number of all drm_colorop objects.
+
+DRM_IOCTL_MODE_GETCOLOROP: This IOCTL is used to read one drm_colorop.
+It includes the ID for the colorop object, as well as the plane_id of
+the associated plane. All other values should be registered as
+properties.
+
+Each drm_colorop has three core properties:
+
+TYPE: The type of transformation, such as
+* enumerated curve
+* custom (uniform) 1D LUT
+* 3x3 matrix
+* 3x4 matrix
+* 3D LUT
+* etc.
+
+Depending on the type of transformation other properties will describe
+more details.
+
+BYPASS: A boolean property that can be used to easily put a block into
+bypass mode. While setting other properties might fail atomic check,
+setting the BYPASS property to true should never fail. The BYPASS
+property is not mandatory for a colorop, as long as the entire pipeline
+can get bypassed by setting the COLOR_PIPELINE on a plane to '0'.
+
+NEXT: The ID of the next drm_colorop in a color pipeline, or 0 if this
+drm_colorop is the last in the chain.
+
+An example of a drm_colorop object might look like one of these::
+
+    /* 1D enumerated curve */
+    Color operation 42
+    ├─ "TYPE": immutable enum {1D enumerated curve, 1D LUT, 3x3 matrix, 3x4 matrix, 3D LUT, etc.} = 1D enumerated curve
+    ├─ "BYPASS": bool {true, false}
+    ├─ "CURVE_1D_TYPE": enum {sRGB EOTF, sRGB inverse EOTF, PQ EOTF, PQ inverse EOTF, …}
+    └─ "NEXT": immutable color operation ID = 43
+
+    /* custom 4k entry 1D LUT */
+    Color operation 52
+    ├─ "TYPE": immutable enum {1D enumerated curve, 1D LUT, 3x3 matrix, 3x4 matrix, 3D LUT, etc.} = 1D LUT
+    ├─ "BYPASS": bool {true, false}
+    ├─ "LUT_1D_SIZE": immutable range = 4096
+    ├─ "LUT_1D": blob
+    └─ "NEXT": immutable color operation ID = 0
+
+    /* 17^3 3D LUT */
+    Color operation 72
+    ├─ "TYPE": immutable enum {1D enumerated curve, 1D LUT, 3x3 matrix, 3x4 matrix, 3D LUT, etc.} = 3D LUT
+    ├─ "BYPASS": bool {true, false}
+    ├─ "LUT_3D_SIZE": immutable range = 17
+    ├─ "LUT_3D": blob
+    └─ "NEXT": immutable color operation ID = 73
+
+
+COLOR_PIPELINE Plane Property
+=============================
+
+Color Pipelines are created by a driver and advertised via a new
+COLOR_PIPELINE enum property on each plane. Values of the property
+always include '0', which is the default and means all color processing
+is disabled. Additional values will be the object IDs of the first
+drm_colorop in a pipeline. A driver can create and advertise none, one,
+or more possible color pipelines. A DRM client will select a color
+pipeline by setting the COLOR PIPELINE to the respective value.
+
+The COLOR_PIPELINE property is only exposed when the
+DRM_CLIENT_CAP_PLANE_COLOR_PIPELINE is set. Drivers are expected to
+reject setting any existing pre-blend color operations when this cap is
+set, such as COLOR_RANGE or COLOR_ENCODING. If drivers want to support
+COLOR_RANGE or COLOR_ENCODING functionality when the color pipeline
+client cap is set, they are expected to expose colorops in the pipeline
+to allow for the appropriate color transformation.
+
+An example of a COLOR_PIPELINE property on a plane might look like this::
+
+    Plane 10
+    ├─ "type": immutable enum {Overlay, Primary, Cursor} = Primary
+    ├─ …
+    └─ "color_pipeline": enum {0, 42, 52} = 0
+
+
+Color Pipeline Discovery
+========================
+
+A DRM client wanting color management on a drm_plane will:
+
+1. Read all drm_colorop objects
+2. Get the COLOR_PIPELINE property of the plane
+3. iterate all COLOR_PIPELINE enum values
+4. for each enum value walk the color pipeline (via the NEXT pointers)
+   and see if the available color operations are suitable for the
+   desired color management operations
+
+An example of chained properties to define an AMD pre-blending color
+pipeline might look like this::
+
+    Plane 10
+    ├─ "TYPE" (immutable) = Primary
+    └─ "COLOR_PIPELINE": enum {0, 44} = 0
+
+    Color operation 44
+    ├─ "TYPE" (immutable) = 1D enumerated curve
+    ├─ "BYPASS": bool
+    ├─ "CURVE_1D_TYPE": enum {sRGB EOTF, PQ EOTF} = sRGB EOTF
+    └─ "NEXT" (immutable) = 45
+
+    Color operation 45
+    ├─ "TYPE" (immutable) = 3x4 Matrix
+    ├─ "BYPASS": bool
+    ├─ "MATRIX_3_4": blob
+    └─ "NEXT" (immutable) = 46
+
+    Color operation 46
+    ├─ "TYPE" (immutable) = 1D enumerated curve
+    ├─ "BYPASS": bool
+    ├─ "CURVE_1D_TYPE": enum {sRGB Inverse EOTF, PQ Inverse EOTF} = sRGB EOTF
+    └─ "NEXT" (immutable) = 47
+
+    Color operation 47
+    ├─ "TYPE" (immutable) = 1D LUT
+    ├─ "LUT_1D_SIZE": immutable range = 4096
+    ├─ "LUT_1D_DATA": blob
+    └─ "NEXT" (immutable) = 48
+
+    Color operation 48
+    ├─ "TYPE" (immutable) = 3D LUT
+    ├─ "LUT_3D_SIZE" (immutable) = 17
+    ├─ "LUT_3D_DATA": blob
+    └─ "NEXT" (immutable) = 49
+
+    Color operation 49
+    ├─ "TYPE" (immutable) = 1D enumerated curve
+    ├─ "BYPASS": bool
+    ├─ "CURVE_1D_TYPE": enum {sRGB EOTF, PQ EOTF} = sRGB EOTF
+    └─ "NEXT" (immutable) = 0
+
+
+Color Pipeline Programming
+==========================
+
+Once a DRM client has found a suitable pipeline it will:
+
+1. Set the COLOR_PIPELINE enum value to the one pointing at the first
+   drm_colorop object of the desired pipeline
+2. Set the properties for all drm_colorop objects in the pipeline to the
+   desired values, setting BYPASS to true for unused drm_colorop blocks,
+   and false for enabled drm_colorop blocks
+3. Perform atomic_check/commit as desired
+
+To configure the pipeline for an HDR10 PQ plane and blending in linear
+space, a compositor might perform an atomic commit with the following
+property values::
+
+    Plane 10
+    └─ "COLOR_PIPELINE" = 42
+
+    Color operation 42 (input CSC)
+    └─ "BYPASS" = true
+
+    Color operation 44 (DeGamma)
+    └─ "BYPASS" = true
+
+    Color operation 45 (gamut remap)
+    └─ "BYPASS" = true
+
+    Color operation 46 (shaper LUT RAM)
+    └─ "BYPASS" = true
+
+    Color operation 47 (3D LUT RAM)
+    └─ "LUT_3D_DATA" = Gamut mapping + tone mapping + night mode
+
+    Color operation 48 (blend gamma)
+    └─ "CURVE_1D_TYPE" = PQ EOTF
+
+
+Driver Implementer's Guide
+==========================
+
+What does this all mean for driver implementations? As noted above the
+colorops can map to HW directly but don't need to do so. Here are some
+suggestions on how to think about creating your color pipelines:
+
+- Try to expose pipelines that use already defined colorops, even if
+  your hardware pipeline is split differently. This allows existing
+  userspace to immediately take advantage of the hardware.
+
+- Additionally, try to expose your actual hardware blocks as colorops.
+  Define new colorop types where you believe it can offer significant
+  benefits if userspace learns to program them.
+
+- Avoid defining new colorops for compound operations with very narrow
+  scope. If you have a hardware block for a special operation that
+  cannot be split further, you can expose that as a new colorop type.
+  However, try to not define colorops for "use cases", especially if
+  they require you to combine multiple hardware blocks.
+
+- Design new colorops as prescriptive, not descriptive; by the
+  mathematical formula, not by the assumed input and output.
+
+A defined colorop type must be deterministic. The exact behavior of the
+colorop must be documented entirely, whether via a mathematical formula
+or some other description. Its operation can depend only on its
+properties and input and nothing else, allowed error tolerance
+notwithstanding.
+
+
+Driver Forward/Backward Compatibility
+=====================================
+
+As this is uAPI drivers can't regress color pipelines that have been
+introduced for a given HW generation. New HW generations are free to
+abandon color pipelines advertised for previous generations.
+Nevertheless, it can be beneficial to carry support for existing color
+pipelines forward as those will likely already have support in DRM
+clients.
+
+Introducing new colorops to a pipeline is fine, as long as they can be
+disabled or are purely informational. DRM clients implementing support
+for the pipeline can always skip unknown properties as long as they can
+be confident that doing so will not cause unexpected results.
+
+If a new colorop doesn't fall into one of the above categories
+(bypassable or informational) the modified pipeline would be unusable
+for user space. In this case a new pipeline should be defined.
+
+
+References
+==========
+
+1. https://lore.kernel.org/dri-devel/QMers3awXvNCQlyhWdTtsPwkp5ie9bze_hD5nAccFW7a_RXlWjYB7MoUW_8CKLT2bSQwIXVi5H6VULYIxCdgvryZoAoJnC5lZgyK1QWn488=@emersion.fr/
\ No newline at end of file
drivers/gpu/drm/Makefile +1 -0
index 104b42df2e95..4b14dcbb6117 100644
@@ -16,6 +16,7 @@ drm-y := \
 	drm_client.o \
 	drm_client_modeset.o \
 	drm_color_mgmt.o \
+	drm_colorop.o \
 	drm_connector.o \
 	drm_crtc.o \
 	drm_displayid.o \
drivers/gpu/drm/drm_atomic.c +147 -0

207 lines not on this page · raw message

drivers/gpu/drm/drm_atomic_helper.c +12 -0
index 39ef0a6addeb..282aa1f7b9a6 100644
@@ -3022,6 +3022,8 @@ int drm_atomic_helper_swap_state(struct drm_atomic_state *state,
 	struct drm_crtc_state *old_crtc_state, *new_crtc_state;
 	struct drm_plane *plane;
 	struct drm_plane_state *old_plane_state, *new_plane_state;
+	struct drm_colorop *colorop;
+	struct drm_colorop_state *old_colorop_state, *new_colorop_state;
 	struct drm_crtc_commit *commit;
 	struct drm_private_obj *obj;
 	struct drm_private_state *old_obj_state, *new_obj_state;
@@ -3099,6 +3101,16 @@ int drm_atomic_helper_swap_state(struct drm_atomic_state *state,
 		}
 	}
 
+	for_each_oldnew_colorop_in_state(state, colorop, old_colorop_state, new_colorop_state, i) {
+		WARN_ON(colorop->state != old_colorop_state);
+
+		old_colorop_state->state = state;
+		new_colorop_state->state = NULL;
+
+		state->colorops[i].state = old_colorop_state;
+		colorop->state = new_colorop_state;
+	}
+
 	for_each_oldnew_plane_in_state(state, plane, old_plane_state, new_plane_state, i) {
 		WARN_ON(plane->state != old_plane_state);
 
drivers/gpu/drm/drm_atomic_state_helper.c +5 -0
index 519228eb1095..d1dd082b1286 100644
@@ -267,6 +267,11 @@ void __drm_atomic_helper_plane_state_reset(struct drm_plane_state *plane_state,
 			plane_state->color_range = val;
 	}
 
+	if (plane->color_pipeline_property) {
+		/* default is always NULL, i.e., bypass */
+		plane_state->color_pipeline = NULL;
+	}
+
 	if (plane->zpos_property) {
 		if (!drm_object_property_get_default_value(&plane->base,
 							   plane->zpos_property,
drivers/gpu/drm/drm_atomic_uapi.c +161 -0

206 lines not on this page · raw message

drivers/gpu/drm/drm_colorop.c new file +292 -0

292 lines not on this page · raw message

drivers/gpu/drm/drm_ioctl.c +7 -0
index e368fc084c77..da59e37ae228 100644
@@ -373,6 +373,13 @@ drm_setclientcap(struct drm_device *dev, void *data, struct drm_file *file_priv)
 			return -EINVAL;
 		file_priv->supports_virtualized_cursor_plane = req->value;
 		break;
+	case DRM_CLIENT_CAP_PLANE_COLOR_PIPELINE:
+		if (!file_priv->atomic)
+			return -EINVAL;
+		if (req->value > 1)
+			return -EINVAL;
+		file_priv->plane_color_pipeline = req->value;
+		break;
 	default:
 		return -EINVAL;
 	}
drivers/gpu/drm/drm_mode_config.c +7 -0
index 48fd2d67f352..e9253f401239 100644
@@ -29,6 +29,7 @@
 #include <drm/drm_managed.h>
 #include <drm/drm_mode_config.h>
 #include <drm/drm_print.h>
+#include <drm/drm_colorop.h>
 #include <linux/dma-resv.h>
 
 #include "drm_crtc_internal.h"
@@ -182,11 +183,15 @@ int drm_mode_getresources(struct drm_device *dev, void *data,
 void drm_mode_config_reset(struct drm_device *dev)
 {
 	struct drm_crtc *crtc;
+	struct drm_colorop *colorop;
 	struct drm_plane *plane;
 	struct drm_encoder *encoder;
 	struct drm_connector *connector;
 	struct drm_connector_list_iter conn_iter;
 
+	drm_for_each_colorop(colorop, dev)
+		drm_colorop_reset(colorop);
+
 	drm_for_each_plane(plane, dev)
 		if (plane->funcs->reset)
 			plane->funcs->reset(plane);
@@ -413,6 +418,7 @@ int drmm_mode_config_init(struct drm_device *dev)
 	INIT_LIST_HEAD(&dev->mode_config.property_list);
 	INIT_LIST_HEAD(&dev->mode_config.property_blob_list);
 	INIT_LIST_HEAD(&dev->mode_config.plane_list);
+	INIT_LIST_HEAD(&dev->mode_config.colorop_list);
 	INIT_LIST_HEAD(&dev->mode_config.privobj_list);
 	idr_init_base(&dev->mode_config.object_idr, 1);
 	idr_init_base(&dev->mode_config.tile_idr, 1);
@@ -434,6 +440,7 @@ int drmm_mode_config_init(struct drm_device *dev)
 	dev->mode_config.num_crtc = 0;
 	dev->mode_config.num_encoder = 0;
 	dev->mode_config.num_total_plane = 0;
+	dev->mode_config.num_colorop = 0;
 
 	if (IS_ENABLED(CONFIG_LOCKDEP)) {
 		struct drm_modeset_acquire_ctx modeset_ctx;
drivers/gpu/drm/tests/Makefile +3 -1
index d6183b3d7688..010c338f9c19 100644
@@ -19,6 +19,8 @@ obj-$(CONFIG_DRM_KUNIT_TEST) += \
 	drm_modes_test.o \
 	drm_plane_helper_test.o \
 	drm_probe_helper_test.o \
-	drm_rect_test.o
+	drm_rect_test.o	\
+	drm_exec_test.o \
+	drm_fixp_test.o
 
 CFLAGS_drm_mm_test.o := $(DISABLE_STRUCTLEAK_PLUGIN)
drivers/gpu/drm/tests/drm_fixp_test.c new file +69 -0

70 lines not on this page · raw message

drivers/gpu/drm/vkms/Kconfig +5 -0
index b9ecdebecb0b..c1f8b343ff0e 100644
@@ -13,3 +13,8 @@ config DRM_VKMS
 	  a VKMS.
 
 	  If M is selected the module will be called vkms.
+
+config DRM_VKMS_KUNIT_TESTS
+	tristate "Tests for VKMS" if !KUNIT_ALL_TESTS
+	depends on DRM_VKMS && KUNIT
+	default KUNIT_ALL_TESTS
drivers/gpu/drm/vkms/Makefile +3 -1
index 1b28a6a32948..c38455c46be4 100644
@@ -6,6 +6,8 @@ vkms-y := \
 	vkms_formats.o \
 	vkms_crtc.o \
 	vkms_composer.o \
-	vkms_writeback.o
+	vkms_writeback.o \
+	vkms_colorop.o \
+	vkms_luts.o
 
 obj-$(CONFIG_DRM_VKMS) += vkms.o
drivers/gpu/drm/vkms/tests/.kunitconfig new file +4 -0
new file mode 100644
index 000000000000..70e378228cbd
@@ -0,0 +1,4 @@
+CONFIG_KUNIT=y
+CONFIG_DRM=y
+CONFIG_DRM_VKMS=y
+CONFIG_DRM_VKMS_KUNIT_TESTS=y
drivers/gpu/drm/vkms/tests/vkms_color_tests.c new file +355 -0

356 lines not on this page · raw message

drivers/gpu/drm/vkms/vkms_colorop.c new file +115 -0

115 lines not on this page · raw message

drivers/gpu/drm/vkms/vkms_composer.c +115 -2

150 lines not on this page · raw message

drivers/gpu/drm/vkms/vkms_drv.h +8 -0
index 8f5710debb1e..fadb7685a360 100644
@@ -36,6 +36,10 @@ struct vkms_frame_info {
 	unsigned int cpp;
 };
 
+struct pixel_argb_s32 {
+	s32 a, r, g, b;
+};
+
 struct pixel_argb_u16 {
 	u16 a, r, g, b;
 };
@@ -170,4 +174,8 @@ void vkms_writeback_row(struct vkms_writeback_job *wb, const struct line_buffer
 /* Writeback */
 int vkms_enable_writeback_connector(struct vkms_device *vkmsdev);
 
+/* Colorops */
+int vkms_initialize_colorops(struct drm_plane *plane);
+
+
 #endif /* _VKMS_DRV_H_ */
drivers/gpu/drm/vkms/vkms_luts.c new file +802 -0

802 lines not on this page · raw message

drivers/gpu/drm/vkms/vkms_luts.h new file +12 -0
new file mode 100644
index 000000000000..053512a643f7
@@ -0,0 +1,12 @@
+/* SPDX-License-Identifier: GPL-2.0+ */
+
+#ifndef _VKMS_LUTS_H_
+#define _VKMS_LUTS_H_
+
+#define LUT_SIZE 256
+
+extern const struct vkms_color_lut linear_eotf;
+extern const struct vkms_color_lut srgb_eotf;
+extern const struct vkms_color_lut srgb_inv_eotf;
+
+#endif /* _VKMS_LUTS_H_ */
\ No newline at end of file
drivers/gpu/drm/vkms/vkms_plane.c +2 -0
index e5c625ab8e3e..8520ee0534d1 100644
@@ -215,5 +215,7 @@ struct vkms_plane *vkms_plane_init(struct vkms_device *vkmsdev,
 	drm_plane_create_rotation_property(&plane->base, DRM_MODE_ROTATE_0,
 					   DRM_MODE_ROTATE_MASK | DRM_MODE_REFLECT_MASK);
 
+	vkms_initialize_colorops(&plane->base);
+
 	return plane;
 }
include/drm/drm_atomic.h +84 -0

120 lines not on this page · raw message

include/drm/drm_atomic_uapi.h +3 -0
index 4c6d39d7bdb2..436315523326 100644
@@ -37,6 +37,7 @@ struct drm_crtc;
 struct drm_connector_state;
 struct dma_fence;
 struct drm_framebuffer;
+struct drm_colorop;
 
 int __must_check
 drm_atomic_set_mode_for_crtc(struct drm_crtc_state *state,
@@ -49,6 +50,8 @@ drm_atomic_set_crtc_for_plane(struct drm_plane_state *plane_state,
 			      struct drm_crtc *crtc);
 void drm_atomic_set_fb_for_plane(struct drm_plane_state *plane_state,
 				 struct drm_framebuffer *fb);
+void drm_atomic_set_colorop_for_plane(struct drm_plane_state *plane_state,
+				      struct drm_colorop *colorop);
 int __must_check
 drm_atomic_set_crtc_for_connector(struct drm_connector_state *conn_state,
 				  struct drm_crtc *crtc);
include/drm/drm_colorop.h new file +258 -0

155 lines not on this page · raw message

include/drm/drm_file.h +7 -0
index ab230d3af138..63c1d29b8520 100644

Lines of this file are not shown. View the raw message.

include/drm/drm_fixed.h +18 -0
index 0c9f917a4d4b..cb842ba80ddd 100644

Lines of this file are not shown. View the raw message.

include/drm/drm_mode_config.h +18 -0
index 973119a9176b..492b8c120c80 100644

Lines of this file are not shown. View the raw message.

include/drm/drm_plane.h +10 -0
index 641fe298052d..0a124e44c3f2 100644

Lines of this file are not shown. View the raw message.

include/uapi/drm/drm.h +18 -0
index 16122819edfe..94a0fab3f35e 100644

Lines of this file are not shown. View the raw message.

include/uapi/drm/drm_mode.h +6 -0
index 7040e7ea80c7..f16318f1785f 100644

Lines of this file are not shown. View the raw message.

The rest of this diff is not shown. View the raw message.

Signature · 1 line
2.42.0

Part of the diff is not shown here. View the raw message.

#2 lore raw

Re: [PATCH 01/28] [NOT FOR REVIEW] drm: color pipeline base work

kernel test robot noticed the following build warnings:

Hi Uma,

kernel test robot noticed the following build warnings:

[auto build test WARNING on drm-misc/drm-misc-next]
[also build test WARNING on drm/drm-next next-20240213]
[cannot apply to drm-intel/for-linux-next drm-intel/for-linux-next-fixes linus/master v6.8-rc4] [If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]

url:    https://github.com/intel-lab-lkp/linux/commits/Uma-Shankar/drm-color-pipeline-base-work/20240213-144544
base:   git://anongit.freedesktop.org/drm/drm-misc drm-misc-next
patch link:    https://lore.kernel.org/r/20240213064835.139464-2-uma.shankar%40intel.com
patch subject: [PATCH 01/28] [NOT FOR REVIEW] drm: color pipeline base work
config: x86_64-defconfig (https://download.01.org/0day-ci/archive/20240214/[email protected]/config)
compiler: gcc-11 (Debian 11.3.0-12) 11.3.0
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20240214/[email protected]/reproduce)

If you fix the issue in a separate patch/commit (i.e. not just a new version of the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <[email protected]>
| Closes: https://lore.kernel.org/oe-kbuild-all/[email protected]/

All warnings (new ones prefixed by >>):

>> drivers/gpu/drm/drm_colorop.c:268: warning: Function parameter or struct member 'type' not described in 'drm_get_colorop_curve_1d_type_name'

drivers/gpu/drm/drm_colorop.c:268: warning: Excess function parameter 'range' description in 'drm_get_colorop_curve_1d_type_name'

vim +268 drivers/gpu/drm/drm_colorop.c

259
260 /**
261 * drm_get_colorop_curve_1d_type_name - return a string for 1D curve type
262 * @range: 1d curve type to compute name of
263 *
264 * In contrast to the other drm_get_*_name functions this one here returns a
265 * const pointer and hence is threadsafe.
266 */
267 const char *drm_get_colorop_curve_1d_type_name(enum drm_colorop_curve_1d_type type)

 > 268	{

269 if (WARN_ON(type >= ARRAY_SIZE(colorop_curve_1d_type_name)))
270 return "unknown";
271
272 return colorop_curve_1d_type_name[type];
273 }
274

Signature · 2 lines
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki
#3 lore raw

Re: [PATCH 01/28] [NOT FOR REVIEW] drm: color pipeline base work

In reply to Uma Shankar
kernel test robot noticed the following build warnings:

Hi Uma,

kernel test robot noticed the following build warnings:

[auto build test WARNING on drm-misc/drm-misc-next]
[also build test WARNING on drm/drm-next next-20240213]
[cannot apply to drm-intel/for-linux-next drm-intel/for-linux-next-fixes linus/master v6.8-rc4] [If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]

url:    https://github.com/intel-lab-lkp/linux/commits/Uma-Shankar/drm-color-pipeline-base-work/20240213-144544
base:   git://anongit.freedesktop.org/drm/drm-misc drm-misc-next
patch link:    https://lore.kernel.org/r/20240213064835.139464-2-uma.shankar%40intel.com
patch subject: [PATCH 01/28] [NOT FOR REVIEW] drm: color pipeline base work
config: x86_64-allyesconfig (https://download.01.org/0day-ci/archive/20240214/[email protected]/config)
compiler: clang version 17.0.6 (https://github.com/llvm/llvm-project 6009708b4367171ccdbf4b5905cb6a803753fe18)
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20240214/[email protected]/reproduce)

If you fix the issue in a separate patch/commit (i.e. not just a new version of the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <[email protected]>
| Closes: https://lore.kernel.org/oe-kbuild-all/[email protected]/

All warnings (new ones prefixed by >>):

>> drivers/gpu/drm/tests/drm_fixp_test.c:11:59: warning: overflow in expression; result is 9223372036854775807 with type 'long long' [-Winteger-overflow]
      11 |         KUNIT_EXPECT_EQ(test, 0x7fffffffffffffffll, ((1LL << 63) - 1));
         |                                                                  ^
   1 warning generated.
--
>> drivers/gpu/drm/vkms/vkms_composer.c:95:5: warning: no previous prototype for function 'lerp_u16' [-Wmissing-prototypes]
      95 | u16 lerp_u16(u16 a, u16 b, s64 t)
         |     ^
   drivers/gpu/drm/vkms/vkms_composer.c:95:1: note: declare 'static' if the function is not intended to be used outside of this translation unit
      95 | u16 lerp_u16(u16 a, u16 b, s64 t)
         | ^
         | static 
>> drivers/gpu/drm/vkms/vkms_composer.c:105:5: warning: no previous prototype for function 'get_lut_index' [-Wmissing-prototypes]
     105 | s64 get_lut_index(const struct vkms_color_lut *lut, u16 channel_value)
         |     ^
   drivers/gpu/drm/vkms/vkms_composer.c:105:1: note: declare 'static' if the function is not intended to be used outside of this translation unit
     105 | s64 get_lut_index(const struct vkms_color_lut *lut, u16 channel_value)
         | ^
         | static 
>> drivers/gpu/drm/vkms/vkms_composer.c:167:6: warning: no previous prototype for function 'apply_3x4_matrix' [-Wmissing-prototypes]
     167 | void apply_3x4_matrix(struct pixel_argb_s32 *pixel, const struct drm_color_ctm_3x4 *matrix)
         |      ^
   drivers/gpu/drm/vkms/vkms_composer.c:167:1: note: declare 'static' if the function is not intended to be used outside of this translation unit
     167 | void apply_3x4_matrix(struct pixel_argb_s32 *pixel, const struct drm_color_ctm_3x4 *matrix)
         | ^
         | static 
   3 warnings generated.
--
>> drivers/gpu/drm/vkms/vkms_colorop.c:11:1: warning: 'const' type qualifier on return type has no effect [-Wignored-qualifiers]
      11 | const int vkms_initialize_tf_pipeline(struct drm_plane *plane, struct drm_prop_enum_list *list)
         | ^~~~~
>> drivers/gpu/drm/vkms/vkms_colorop.c:11:11: warning: no previous prototype for function 'vkms_initialize_tf_pipeline' [-Wmissing-prototypes]
      11 | const int vkms_initialize_tf_pipeline(struct drm_plane *plane, struct drm_prop_enum_list *list)
         |           ^
   drivers/gpu/drm/vkms/vkms_colorop.c:11:7: note: declare 'static' if the function is not intended to be used outside of this translation unit
      11 | const int vkms_initialize_tf_pipeline(struct drm_plane *plane, struct drm_prop_enum_list *list)
         |       ^
         | static 
>> drivers/gpu/drm/vkms/vkms_colorop.c:80:5: warning: no previous prototype for function 'vkms_initialize_colorops' [-Wmissing-prototypes]
      80 | int vkms_initialize_colorops(struct drm_plane *plane)
         |     ^
   drivers/gpu/drm/vkms/vkms_colorop.c:80:1: note: declare 'static' if the function is not intended to be used outside of this translation unit
      80 | int vkms_initialize_colorops(struct drm_plane *plane)
         | ^
         | static 

3 warnings generated.

vim +11 drivers/gpu/drm/tests/drm_fixp_test.c

     8	
     9	static void drm_test_sm2fixp(struct kunit *test)
    10	{
  > 11		KUNIT_EXPECT_EQ(test, 0x7fffffffffffffffll, ((1LL << 63) - 1));
    12	
    13		/* 1 */
    14		KUNIT_EXPECT_EQ(test, drm_int2fixp(1), drm_sm2fixp(1ull << DRM_FIXED_POINT));
    15	
    16		/* -1 */
    17		KUNIT_EXPECT_EQ(test, drm_int2fixp(-1), drm_sm2fixp((1ull << 63) | (1ull << DRM_FIXED_POINT)));
    18	
    19		/* 0.5 */
    20		KUNIT_EXPECT_EQ(test, drm_fixp_from_fraction(1, 2), drm_sm2fixp(1ull << (DRM_FIXED_POINT - 1)));
    21	
    22		/* -0.5 */
    23		KUNIT_EXPECT_EQ(test, drm_fixp_from_fraction(-1, 2), drm_sm2fixp((1ull << 63) | (1ull << (DRM_FIXED_POINT - 1))));
    24	
Signature · 2 lines
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki
#4 lore raw

Re: [PATCH 01/28] [NOT FOR REVIEW] drm: color pipeline base work

In reply to Uma Shankar
kernel test robot noticed the following build warnings:

Hi Uma,

kernel test robot noticed the following build warnings:

[auto build test WARNING on drm-misc/drm-misc-next]
[also build test WARNING on drm/drm-next next-20240216]
[cannot apply to drm-intel/for-linux-next drm-intel/for-linux-next-fixes linus/master v6.8-rc4] [If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]

url:    https://github.com/intel-lab-lkp/linux/commits/Uma-Shankar/drm-color-pipeline-base-work/20240213-144544
base:   git://anongit.freedesktop.org/drm/drm-misc drm-misc-next
patch link:    https://lore.kernel.org/r/20240213064835.139464-2-uma.shankar%40intel.com
patch subject: [PATCH 01/28] [NOT FOR REVIEW] drm: color pipeline base work
config: x86_64-randconfig-121-20240214 (https://download.01.org/0day-ci/archive/20240216/[email protected]/config)
compiler: gcc-12 (Debian 12.2.0-14) 12.2.0
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20240216/[email protected]/reproduce)

If you fix the issue in a separate patch/commit (i.e. not just a new version of the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <[email protected]>
| Closes: https://lore.kernel.org/oe-kbuild-all/[email protected]/

sparse warnings: (new ones prefixed by >>)

>> drivers/gpu/drm/vkms/vkms_colorop.c:11:11: sparse: sparse: symbol 'vkms_initialize_tf_pipeline' was not declared. Should it be static?
--
   drivers/gpu/drm/vkms/vkms_composer.c: note: in included file:
>> drivers/gpu/drm/vkms/tests/vkms_color_tests.c:29:29: sparse: sparse: symbol 'test_linear_lut' was not declared. Should it be static?
>> drivers/gpu/drm/vkms/tests/vkms_color_tests.c:87:32: sparse: sparse: symbol 'test_matrix_3x4_50_desat' was not declared. Should it be static?
>> drivers/gpu/drm/vkms/tests/vkms_color_tests.c:146:32: sparse: sparse: symbol 'test_matrix_3x4_bt709_enc' was not declared. Should it be static?

vim +/vkms_initialize_tf_pipeline +11 drivers/gpu/drm/vkms/vkms_colorop.c

    10	
  > 11	const int vkms_initialize_tf_pipeline(struct drm_plane *plane, struct drm_prop_enum_list *list)
    12	{
    13	
    14		struct drm_colorop *op, *prev_op;
    15		struct drm_device *dev = plane->dev;
    16		int ret;
    17	
    18		/* 1st op: 1d curve */
    19		op = kzalloc(sizeof(struct drm_colorop), GFP_KERNEL);
    20		if (!op) {
    21			DRM_ERROR("KMS: Failed to allocate colorop\n");
    22			return -ENOMEM;
    23		}
    24	
    25		ret = drm_colorop_init(dev, op, plane, DRM_COLOROP_1D_CURVE);
    26		if (ret)
    27			return ret;
    28	
    29		list->type = op->base.id;
    30		list->name = kasprintf(GFP_KERNEL, "Color Pipeline %d", op->base.id);
    31	
    32		prev_op = op;
    33	
    34		/* 2nd op: 3x4 matrix */
    35		op = kzalloc(sizeof(struct drm_colorop), GFP_KERNEL);
    36		if (!op) {
    37			DRM_ERROR("KMS: Failed to allocate colorop\n");
    38			return -ENOMEM;
    39		}
    40	
    41		ret = drm_colorop_init(dev, op, plane, DRM_COLOROP_CTM_3X4);
    42		if (ret)
    43			return ret;
    44	
    45		drm_colorop_set_next_property(prev_op, op);
    46	
    47		prev_op = op;
    48	
    49		/* 3rd op: 3x4 matrix */
    50		op = kzalloc(sizeof(struct drm_colorop), GFP_KERNEL);
    51		if (!op) {
    52			DRM_ERROR("KMS: Failed to allocate colorop\n");
    53			return -ENOMEM;
    54		}
    55	
    56		ret = drm_colorop_init(dev, op, plane, DRM_COLOROP_CTM_3X4);
    57		if (ret)
    58			return ret;
    59	
    60		drm_colorop_set_next_property(prev_op, op);
    61	
    62		prev_op = op;
    63	
    64		/* 4th op: 1d curve */
    65		op = kzalloc(sizeof(struct drm_colorop), GFP_KERNEL);
    66		if (!op) {
    67			DRM_ERROR("KMS: Failed to allocate colorop\n");
    68			return -ENOMEM;
    69		}
    70	
    71		ret = drm_colorop_init(dev, op, plane, DRM_COLOROP_1D_CURVE);
    72		if (ret)
    73			return ret;
    74	
    75		drm_colorop_set_next_property(prev_op, op);
    76	
    77		return 0;
    78	}
    79	
Signature · 2 lines
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki
#5 lore raw

Re: [PATCH 01/28] [NOT FOR REVIEW] drm: color pipeline base work

In reply to Uma Shankar
kernel test robot noticed the following build warnings:

Hi Uma,

kernel test robot noticed the following build warnings:

[auto build test WARNING on drm-misc/drm-misc-next]
[also build test WARNING on drm/drm-next next-20240216]
[cannot apply to drm-intel/for-linux-next drm-intel/for-linux-next-fixes linus/master v6.8-rc4] [If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]

url:    https://github.com/intel-lab-lkp/linux/commits/Uma-Shankar/drm-color-pipeline-base-work/20240213-144544
base:   git://anongit.freedesktop.org/drm/drm-misc drm-misc-next
patch link:    https://lore.kernel.org/r/20240213064835.139464-2-uma.shankar%40intel.com
patch subject: [PATCH 01/28] [NOT FOR REVIEW] drm: color pipeline base work
config: x86_64-randconfig-161-20240213 (https://download.01.org/0day-ci/archive/20240218/[email protected]/config)
compiler: gcc-12 (Debian 12.2.0-14) 12.2.0

If you fix the issue in a separate patch/commit (i.e. not just a new version of the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <[email protected]>
| Closes: https://lore.kernel.org/oe-kbuild-all/[email protected]/

smatch warnings:
drivers/gpu/drm/drm_atomic.c:825 drm_atomic_plane_print_state() warn: inconsistent indenting

vim +825 drivers/gpu/drm/drm_atomic.c

799
800 static void drm_atomic_plane_print_state(struct drm_printer *p,
801 const struct drm_plane_state *state)
802 {
803 struct drm_plane *plane = state->plane;
804 struct drm_rect src = drm_plane_state_src(state);
805 struct drm_rect dest = drm_plane_state_dest(state);
806
807 drm_printf(p, "plane[%u]: %s\n", plane->base.id, plane->name);
808 drm_printf(p, "\tcrtc=%s\n", state->crtc ? state->crtc->name : "(null)");
809 drm_printf(p, "\tfb=%u\n", state->fb ? state->fb->base.id : 0);
810 if (state->fb)
811 drm_framebuffer_print_info(p, 2, state->fb);
812 drm_printf(p, "\tcrtc-pos=" DRM_RECT_FMT "\n", DRM_RECT_ARG(&dest));
813 drm_printf(p, "\tsrc-pos=" DRM_RECT_FP_FMT "\n", DRM_RECT_FP_ARG(&src));
814 drm_printf(p, "\trotation=%x\n", state->rotation);
815 drm_printf(p, "\tnormalized-zpos=%x\n", state->normalized_zpos);
816 drm_printf(p, "\tcolor-encoding=%s\n",
817 drm_get_color_encoding_name(state->color_encoding));
818 drm_printf(p, "\tcolor-range=%s\n",
819 drm_get_color_range_name(state->color_range));
820 drm_printf(p, "\tcolor_mgmt_changed=%d\n", state->color_mgmt_changed);
821 #if 0
822 drm_printf(p, "\tcolor-pipeline=%s\n",
823 drm_get_color_pipeline_name(state->color_pipeline));
824 #else

 > 825	       drm_printf(p, "\tcolor-pipeline=%d\n",

826 state->color_pipeline ? state->color_pipeline->base.id : 0);
827 #endif
828
829
830 if (plane->funcs->atomic_print_state)
831 plane->funcs->atomic_print_state(p, state);
832 }
833

Signature · 2 lines
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki
#6 lore raw

PATCH 2/28 drm: Add missing function declarations

In reply to Uma Shankar

From: Chaitanya Kumar Borah <[email protected]>

add missing declarations to avoid warnings.

Note: This patch should be squashed with patches it fixes in the colorop series by Harry [1]

("drm/colorop: Introduce new drm_colorop mode object") [2] ("drm/plane: Add COLOR PIPELINE property") [3]

[1] https://patchwork.freedesktop.org/series/123446/
[2] https://patchwork.freedesktop.org/patch/566617/?series=123446&rev=3
[3] https://patchwork.freedesktop.org/patch/566616/?series=123446&rev=3

---
 include/drm/drm_atomic.h  | 3 +++
 include/drm/drm_colorop.h | 3 ++-
 2 files changed, 5 insertions(+), 1 deletion(-)
include/drm/drm_atomic.h +3 -0
index 898b02689d6d..5cf025895baf 100644
@@ -847,6 +847,9 @@ drm_atomic_add_affected_connectors(struct drm_atomic_state *state,
 int __must_check
 drm_atomic_add_affected_planes(struct drm_atomic_state *state,
 			       struct drm_crtc *crtc);
+int __must_check
+drm_atomic_add_affected_colorops(struct drm_atomic_state *state,
+				 struct drm_plane *plane);
 
 int __must_check drm_atomic_check_only(struct drm_atomic_state *state);
 int __must_check drm_atomic_commit(struct drm_atomic_state *state);
include/drm/drm_colorop.h +2 -1
index faca6eba10e1..5b8c36538491 100644
@@ -249,7 +249,8 @@ const char *drm_get_color_pipeline_name(struct drm_colorop *colorop);
 
 const char *drm_get_colorop_type_name(enum drm_colorop_type type);
 const char *drm_get_colorop_curve_1d_type_name(enum drm_colorop_curve_1d_type type);
-
+void drm_colorop_destroy_state(struct drm_colorop *colorop,
+			       struct drm_colorop_state *state);
 void drm_colorop_set_next_property(struct drm_colorop *colorop, struct drm_colorop *next);
 uint32_t drm_colorop_get_next_property(struct drm_colorop *colorop);
 struct drm_colorop *drm_colorop_get_next(struct drm_colorop *colorop);
Signature · 1 line
2.42.0
#7 lore raw

PATCH 3/28 drm: handle NULL next colorop in drm_colorop_set_next_property

In reply to Uma Shankar

From: Chaitanya Kumar Borah <[email protected]>

In scenarios, where there is only one colorop in a colorpipeline, the user of the helper drm_colorop_set_next_property could use it to set the next colorop as NULL explicitly. Make the helper handle this case.

Note: This patch can be squashed with following patch

("drm/colorop: Add NEXT property") [1]

[1] https://patchwork.freedesktop.org/patch/566588/?series=123446&rev=3

---
 drivers/gpu/drm/drm_colorop.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/drm_colorop.c +1 -1
index 67e6efc90803..462ffec42cdf 100644
@@ -286,7 +286,7 @@ void drm_colorop_set_next_property(struct drm_colorop *colorop, struct drm_color
 
 	drm_object_property_set_value(&colorop->base,
 				      colorop->next_property,
-				      next->base.id);
+				      next ? next->base.id : 0);
 	colorop->next = next;
 }
 EXPORT_SYMBOL(drm_colorop_set_next_property);
Signature · 1 line
2.42.0
#8 lore raw

PATCH 4/28 drm: Fix error logging in set Color Pipeline

In reply to Uma Shankar

From: Chaitanya Kumar Borah <[email protected]>

Fix error logging in set Color Pipeline

Note: This patch can be squashed with the following patch

("drm/colorop: Introduce DRM_CLIENT_CAP_PLANE_COLOR_PIPELINE") [1]

[1] https://patchwork.freedesktop.org/patch/566623/?series=123446&rev=3

---
 drivers/gpu/drm/drm_atomic_uapi.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/gpu/drm/drm_atomic_uapi.c +2 -2
index 64657d961755..e7bf1fb054af 100644
@@ -570,14 +570,14 @@ static int drm_atomic_plane_set_property(struct drm_plane *plane,
 	} else if (property == plane->color_encoding_property) {
 		if (file_priv->plane_color_pipeline) {
 			drm_dbg_atomic(dev,
-				       "Setting COLOR_PIPELINE plane property not permitted when DRM_CLIENT_CAP_PLANE_COLOR_PIPELINE is set\n");
+				       "Setting COLOR_ENCODING plane property not permitted when DRM_CLIENT_CAP_PLANE_COLOR_PIPELINE is set\n");
 			return -EINVAL;
 		}
 		state->color_encoding = val;
 	} else if (property == plane->color_range_property) {
 		if (file_priv->plane_color_pipeline) {
 			drm_dbg_atomic(dev,
-				       "Setting COLOR_PIPELINE plane property not permitted when DRM_CLIENT_CAP_PLANE_COLOR_PIPELINE is set\n");
+				       "Setting COLOR_RANGE plane property not permitted when DRM_CLIENT_CAP_PLANE_COLOR_PIPELINE is set\n");
 			return -EINVAL;
 		}
 		state->color_range = val;
Signature · 1 line
2.42.0
#9 lore raw

PATCH 5/28 drm: Add support for 3x3 CTM

In reply to Uma Shankar

From: Chaitanya Kumar Borah <[email protected]>

Add support for 3x3 Color Transformation Matrices in Color Pipeline.

---
 drivers/gpu/drm/drm_atomic_uapi.c | 3 +++
 drivers/gpu/drm/drm_colorop.c     | 2 +-
 include/uapi/drm/drm_mode.h       | 1 +
 3 files changed, 5 insertions(+), 1 deletion(-)
drivers/gpu/drm/drm_atomic_uapi.c +3 -0
index e7bf1fb054af..c54b0d6c133e 100644
@@ -716,6 +716,9 @@ static int drm_atomic_color_set_data_property(struct drm_colorop *colorop,
 	case DRM_COLOROP_CTM_3X4:
 		size = sizeof(struct drm_color_ctm_3x4);
 		break;
+	case DRM_COLOROP_CTM_3X3:
+		size = sizeof(struct drm_color_ctm);
+		break;
 	default:
 		/* should never get here */
 		return -EINVAL;
drivers/gpu/drm/drm_colorop.c +1 -1
index 462ffec42cdf..6bae6dc8e54b 100644
@@ -107,7 +107,7 @@ int drm_colorop_init(struct drm_device *dev, struct drm_colorop *colorop,
 				   0);
 
 	/* data */
-	if (type == DRM_COLOROP_CTM_3X4) {
+	if (type == DRM_COLOROP_CTM_3X4 || type == DRM_COLOROP_CTM_3X3) {
 		prop = drm_property_create(dev, DRM_MODE_PROP_ATOMIC | DRM_MODE_PROP_BLOB,
 					   "DATA", 0);
 		if (!prop)
include/uapi/drm/drm_mode.h +1 -0
index f16318f1785f..68696253867e 100644
@@ -868,6 +868,7 @@ struct drm_color_lut {
 
 enum drm_colorop_type {
 	DRM_COLOROP_1D_CURVE,
+	DRM_COLOROP_CTM_3X3,
 	DRM_COLOROP_CTM_3X4,
 };
 
Signature · 1 line
2.42.0
#10 lore raw

Re: [PATCH 05/28] drm: Add support for 3x3 CTM

Quoted 44 lines · On Tue, 13 Feb 2024 12:18:12 +0530 Uma Shankar <[email protected]> wrote:

From: Chaitanya Kumar Borah <[email protected]>

Add support for 3x3 Color Transformation Matrices in Color Pipeline.

---
 drivers/gpu/drm/drm_atomic_uapi.c | 3 +++
 drivers/gpu/drm/drm_colorop.c     | 2 +-
 include/uapi/drm/drm_mode.h       | 1 +
 3 files changed, 5 insertions(+), 1 deletion(-)
drivers/gpu/drm/drm_atomic_uapi.c +3 -0
index e7bf1fb054af..c54b0d6c133e 100644
@@ -716,6 +716,9 @@ static int drm_atomic_color_set_data_property(struct drm_colorop *colorop,
 	case DRM_COLOROP_CTM_3X4:
 		size = sizeof(struct drm_color_ctm_3x4);
 		break;
+	case DRM_COLOROP_CTM_3X3:
+		size = sizeof(struct drm_color_ctm);
+		break;
 	default:
 		/* should never get here */
 		return -EINVAL;
drivers/gpu/drm/drm_colorop.c +1 -1
index 462ffec42cdf..6bae6dc8e54b 100644
@@ -107,7 +107,7 @@ int drm_colorop_init(struct drm_device *dev, struct drm_colorop *colorop,
 				   0);
 
 	/* data */
-	if (type == DRM_COLOROP_CTM_3X4) {
+	if (type == DRM_COLOROP_CTM_3X4 || type == DRM_COLOROP_CTM_3X3) {
 		prop = drm_property_create(dev, DRM_MODE_PROP_ATOMIC | DRM_MODE_PROP_BLOB,
 					   "DATA", 0);
 		if (!prop)
include/uapi/drm/drm_mode.h +0 -0
index f16318f1785f..68696253867e 100644

include/uapi/drm/drm_mode.h struct drm_color_lut { · line 874

Quoted 7 lines
include/uapi/drm/drm_mode.h +1 -0
@@ -868,6 +868,7 @@ struct drm_color_lut {
 
 enum drm_colorop_type {
 	DRM_COLOROP_1D_CURVE,
+	DRM_COLOROP_CTM_3X3,
 	DRM_COLOROP_CTM_3X4,
 };
 

Hi,

where are the docs for DRM_COLOROP_CTM_3X3?

Thanks,
pq

#11 lore raw

RE: [PATCH 05/28] drm: Add support for 3x3 CTM

Quoted 80 lines

-----Original Message-----
From: Pekka Paalanen <[email protected]>
Sent: Tuesday, February 13, 2024 2:45 PM
To: Shankar, Uma <[email protected]>
Cc: [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; Borah, Chaitanya Kumar <[email protected]>
Subject: Re: [PATCH 05/28] drm: Add support for 3x3 CTM

drivers/gpu/drm/drm_atomic_uapi.c static int drm_atomic_color_set_data_property(struct

Quoted 18 lines · On Tue, 13 Feb 2024 12:18:12 +0530 Uma Shankar <[email protected]> wrote:

From: Chaitanya Kumar Borah <[email protected]>

Add support for 3x3 Color Transformation Matrices in Color Pipeline.

---
 drivers/gpu/drm/drm_atomic_uapi.c | 3 +++
 drivers/gpu/drm/drm_colorop.c     | 2 +-
 include/uapi/drm/drm_mode.h       | 1 +
 3 files changed, 5 insertions(+), 1 deletion(-)
drivers/gpu/drm/drm_atomic_uapi.c +0 -0
index e7bf1fb054af..c54b0d6c133e 100644
@@ -716,6 +716,9 @@ static int drm_atomic_color_set_data_property(struct

drm_colorop *colorop,

drivers/gpu/drm/drm_colorop.c int drm_colorop_init(struct drm_device *dev, struct

Quoted 15 lines
drivers/gpu/drm/drm_atomic_uapi.c +3 -0
 	case DRM_COLOROP_CTM_3X4:
 		size = sizeof(struct drm_color_ctm_3x4);
 		break;
+	case DRM_COLOROP_CTM_3X3:
+		size = sizeof(struct drm_color_ctm);
+		break;
 	default:
 		/* should never get here */
 		return -EINVAL;
(quoted diff) +0 -0

b/drivers/gpu/drm/drm_colorop.c index 462ffec42cdf..6bae6dc8e54b 100644

drivers/gpu/drm/drm_colorop.c +0 -0
@@ -107,7 +107,7 @@ int drm_colorop_init(struct drm_device *dev, struct

drm_colorop *colorop,

drivers/gpu/drm/drm_colorop.c int drm_colorop_init(struct drm_device *dev, struct drm_colorop *colorop,

Quoted 5 lines
drivers/gpu/drm/drm_colorop.c +1 -1
 				   0);
 
 	/* data */
-	if (type == DRM_COLOROP_CTM_3X4) {
+	if (type == DRM_COLOROP_CTM_3X4 || type ==

DRM_COLOROP_CTM_3X3) {

drivers/gpu/drm/drm_colorop.c int drm_colorop_init(struct drm_device *dev, struct · line 111

Quoted 1 line
drivers/gpu/drm/drm_colorop.c +0 -0
 		prop = drm_property_create(dev, DRM_MODE_PROP_ATOMIC |

DRM_MODE_PROP_BLOB,

Quoted 7 lines
drivers/gpu/drm/drm_colorop.c +0 -0
 					   "DATA", 0);
 		if (!prop)
include/uapi/drm/drm_mode.h +0 -0
index f16318f1785f..68696253867e 100644

include/uapi/drm/drm_mode.h struct drm_color_lut { · line 874

Quoted 7 lines
include/uapi/drm/drm_mode.h +1 -0
@@ -868,6 +868,7 @@ struct drm_color_lut {
 
 enum drm_colorop_type {
 	DRM_COLOROP_1D_CURVE,
+	DRM_COLOROP_CTM_3X3,
 	DRM_COLOROP_CTM_3X4,
 };
 

Hi,

Quoted 1 line

where are the docs for DRM_COLOROP_CTM_3X3?

Hi Pekka,
Sorry, we missed this in the current version. Will update the same in next revision.

Regards,
Uma Shankar

Quoted 3 lines

Thanks,
pq

#12 lore raw

PATCH 6/28 drm: Add Enhanced LUT precision structure

In reply to Uma Shankar

Existing LUT precision structure is having only 16 bit precision. This is not enough for upcoming enhanced hardwares and advance usecases like HDR processing. Hence added a new structure with 32 bit precision values.

---
 include/drm/drm_color_mgmt.h | 23 +++++++++++++++++++++++
 include/uapi/drm/drm_mode.h  | 17 +++++++++++++++++
 2 files changed, 40 insertions(+)
include/drm/drm_color_mgmt.h +23 -0
index ed81741036d7..72a08b5f7d14 100644
@@ -50,6 +50,29 @@ static inline u32 drm_color_lut_extract(u32 user_input, int bit_precision)
 					 (1 << 16) - 1);
 }
 
+/* TODO: Add uapi documentation
+ * Added to accommodate enhanced LUT precision.
+ * Max LUT precision is 32 bits.
+ */
+static inline u64 drm_color_lut_extract_ext(u64 user_input, u32 bit_precision)
+{
+	u64 val = user_input & 0xffffffff;
+	u32 max;
+
+	if (bit_precision > 32)
+		return 0;
+
+	max = 0xffffffff >> (32 - bit_precision);
+	/* Round only if we're not using full precision. */
+	if (bit_precision < 32) {
+		val += 1UL << (32 - bit_precision - 1);
+		val >>= 32 - bit_precision;
+	}
+
+	return ((user_input & 0xffffffff00000000) |
+		clamp_val(val, 0, max));
+}
+
 u64 drm_color_ctm_s31_32_to_qm_n(u64 user_input, u32 m, u32 n);
 
 void drm_crtc_enable_color_mgmt(struct drm_crtc *crtc,
include/uapi/drm/drm_mode.h +17 -0
index 68696253867e..bbc5be97c80f 100644
@@ -866,6 +866,23 @@ struct drm_color_lut {
 	__u16 reserved;
 };
 
+/**
+ * struct drm_color_lut_ext - Represents high precision lut values
+ *
+ * Creating 64 bit palette entries for better data
+ * precision. This will be required for HDR and
+ * similar color processing usecases.
+ */
+struct drm_color_lut_ext {
+	/*
+	 * Data is U32.32 fixed point format.
+	 */
+	__u64 red;
+	__u64 green;
+	__u64 blue;
+	__u64 reserved;
+};
+
 enum drm_colorop_type {
 	DRM_COLOROP_1D_CURVE,
 	DRM_COLOROP_CTM_3X3,
Signature · 1 line
2.42.0
#13 lore raw

PATCH 7/28 drm: Add 1D LUT color op

In reply to Uma Shankar

From: Chaitanya Kumar Borah <[email protected]>

Add support for color ops that can be programmed
by 1 dimensional Look Up Tables.

---
 drivers/gpu/drm/drm_atomic_uapi.c | 3 +++
 drivers/gpu/drm/drm_colorop.c     | 2 +-
 include/uapi/drm/drm_mode.h       | 1 +
 3 files changed, 5 insertions(+), 1 deletion(-)
drivers/gpu/drm/drm_atomic_uapi.c +3 -0
index c54b0d6c133e..9f6a3a1c8020 100644
@@ -719,6 +719,9 @@ static int drm_atomic_color_set_data_property(struct drm_colorop *colorop,
 	case DRM_COLOROP_CTM_3X3:
 		size = sizeof(struct drm_color_ctm);
 		break;
+	case DRM_COLOROP_1D_LUT:
+		elem_size = sizeof(struct drm_color_lut_ext);
+		break;
 	default:
 		/* should never get here */
 		return -EINVAL;
drivers/gpu/drm/drm_colorop.c +1 -1
index 6bae6dc8e54b..4d57eaef04aa 100644
@@ -107,7 +107,7 @@ int drm_colorop_init(struct drm_device *dev, struct drm_colorop *colorop,
 				   0);
 
 	/* data */
-	if (type == DRM_COLOROP_CTM_3X4 || type == DRM_COLOROP_CTM_3X3) {
+	if (type == DRM_COLOROP_CTM_3X4 || type == DRM_COLOROP_CTM_3X3 || DRM_COLOROP_1D_LUT) {
 		prop = drm_property_create(dev, DRM_MODE_PROP_ATOMIC | DRM_MODE_PROP_BLOB,
 					   "DATA", 0);
 		if (!prop)
include/uapi/drm/drm_mode.h +1 -0
index bbc5be97c80f..af67f32e0087 100644
@@ -885,6 +885,7 @@ struct drm_color_lut_ext {
 
 enum drm_colorop_type {
 	DRM_COLOROP_1D_CURVE,
+	DRM_COLOROP_1D_LUT,
 	DRM_COLOROP_CTM_3X3,
 	DRM_COLOROP_CTM_3X4,
 };
Signature · 1 line
2.42.0
#14 lore raw

PATCH 8/28 drm: Add Color lut range attributes

In reply to Uma Shankar

This defines a new structure to define color lut ranges, along with related macro definitions and enums. This will help describe segmented lut ranges/PWL LUTs in the hardware.

---
 include/uapi/drm/drm_mode.h | 58 +++++++++++++++++++++++++++++++++++++
 1 file changed, 58 insertions(+)
include/uapi/drm/drm_mode.h +58 -0
index af67f32e0087..376498715d0e 100644
@@ -1014,6 +1014,64 @@ struct hdr_output_metadata {
 				  DRM_MODE_PAGE_FLIP_ASYNC | \
 				  DRM_MODE_PAGE_FLIP_TARGET)
 
+/**
+ * DRM_MODE_LUT_INTERPOLATE
+ *
+ * linearly interpolate between the points
+ */
+#define DRM_MODE_LUT_INTERPOLATE BIT(0)
+
+/**
+ * DRM_MODE_LUT_REUSE_LAST
+ *
+ * the last value of the previous range is the
+ * first value of the current range.
+ */
+#define DRM_MODE_LUT_REUSE_LAST BIT(1)
+
+/**
+ * DRM_MODE_LUT_NON_DECREASING
+ *
+ * the curve must be non-decreasing
+ */
+#define DRM_MODE_LUT_NON_DECREASING BIT(2)
+
+/**
+ * DRM_MODE_LUT_REFLECT_NEGATIVE
+ *
+ *  the curve is reflected across origin for negative inputs
+ */
+#define DRM_MODE_LUT_REFLECT_NEGATIVE BIT(3)
+
+/**
+ * DRM_MODE_LUT_SINGLE_CHANNEL
+ *
+ * the same curve (red) is used for blue and green channels as well
+ */
+#define DRM_MODE_LUT_SINGLE_CHANNEL BIT(4)
+
+/**
+ * struct drm_color_lut_range
+ *
+ * structure to advertise capability of a color hardware
+ * block that accepts LUT values.  It can represent LUTs with
+ * varied number of entries and distributions
+ * (Multi segmented, Logarithmic etc).
+ */
+
+struct drm_color_lut_range {
+	/* DRM_MODE_LUT_* */
+	__u32 flags;
+	/* number of points on the curve */
+	__u16 count;
+	/* input/output bits per component */
+	__u8 input_bpc, output_bpc;
+	/* input start/end values */
+	__s32 start, end;
+	/* output min/max values */
+	__s32 min, max;
+};
+
 /*
  * Request a page flip on the specified crtc.
  *
Signature · 1 line
2.42.0
#15 lore raw

Re: [PATCH 08/28] drm: Add Color lut range attributes

Quoted 15 lines · Uma Shankar

This defines a new structure to define color lut ranges, along with related macro definitions and enums. This will help describe segmented lut ranges/PWL LUTs in the hardware.

---
 include/uapi/drm/drm_mode.h | 58 +++++++++++++++++++++++++++++++++++++
 1 file changed, 58 insertions(+)
include/uapi/drm/drm_mode.h +0 -0
index af67f32e0087..376498715d0e 100644

include/uapi/drm/drm_mode.h struct hdr_output_metadata { · line 1016

Quoted 3 lines
include/uapi/drm/drm_mode.h +0 -0
@@ -1014,6 +1014,64 @@ struct hdr_output_metadata {
 				  DRM_MODE_PAGE_FLIP_ASYNC | \
 				  DRM_MODE_PAGE_FLIP_TARGET)
 

All of this uses DRM_MODE_LUT namespace but it seems specifically for the drm colorop of type DRM_COLOROP_1D_LUT. Let's be consistent with the naming.

Quoted 64 lines
include/uapi/drm/drm_mode.h +58 -0
+/**
+ * DRM_MODE_LUT_INTERPOLATE
+ *
+ * linearly interpolate between the points
+ */
+#define DRM_MODE_LUT_INTERPOLATE BIT(0)
+
+/**
+ * DRM_MODE_LUT_REUSE_LAST
+ *
+ * the last value of the previous range is the
+ * first value of the current range.
+ */
+#define DRM_MODE_LUT_REUSE_LAST BIT(1)
+
+/**
+ * DRM_MODE_LUT_NON_DECREASING
+ *
+ * the curve must be non-decreasing
+ */
+#define DRM_MODE_LUT_NON_DECREASING BIT(2)
+
+/**
+ * DRM_MODE_LUT_REFLECT_NEGATIVE
+ *
+ *  the curve is reflected across origin for negative inputs
+ */
+#define DRM_MODE_LUT_REFLECT_NEGATIVE BIT(3)
+
+/**
+ * DRM_MODE_LUT_SINGLE_CHANNEL
+ *
+ * the same curve (red) is used for blue and green channels as well
+ */
+#define DRM_MODE_LUT_SINGLE_CHANNEL BIT(4)
+
+/**
+ * struct drm_color_lut_range
+ *
+ * structure to advertise capability of a color hardware
+ * block that accepts LUT values.  It can represent LUTs with
+ * varied number of entries and distributions
+ * (Multi segmented, Logarithmic etc).
+ */
+
+struct drm_color_lut_range {
+	/* DRM_MODE_LUT_* */
+	__u32 flags;
+	/* number of points on the curve */
+	__u16 count;
+	/* input/output bits per component */
+	__u8 input_bpc, output_bpc;
+	/* input start/end values */
+	__s32 start, end;
+	/* output min/max values */
+	__s32 min, max;
+};
+
 /*
  * Request a page flip on the specified crtc.
  *
Signature · 1 line
2.42.0
#16 lore raw

RE: [PATCH 08/28] drm: Add Color lut range attributes

Quoted 29 lines

-----Original Message-----
From: Sebastian Wick <[email protected]>
Sent: Tuesday, February 13, 2024 5:34 PM
To: Shankar, Uma <[email protected]>
Cc: [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]
Subject: Re: [PATCH 08/28] drm: Add Color lut range attributes

Quoted 11 lines · Uma Shankar

This defines a new structure to define color lut ranges, along with related macro definitions and enums. This will help describe segmented lut ranges/PWL LUTs in the hardware.

---
 include/uapi/drm/drm_mode.h | 58
+++++++++++++++++++++++++++++++++++++
 1 file changed, 58 insertions(+)
Quoted 11 lines

include/uapi/drm/drm_mode.h struct hdr_output_metadata { · line 1016

Quoted 8 lines
include/uapi/drm/drm_mode.h +0 -0
index af67f32e0087..376498715d0e 100644
@@ -1014,6 +1014,64 @@ struct hdr_output_metadata {
 				  DRM_MODE_PAGE_FLIP_ASYNC | \
 				  DRM_MODE_PAGE_FLIP_TARGET)
 

All of this uses DRM_MODE_LUT namespace but it seems specifically for the drm colorop of type DRM_COLOROP_1D_LUT. Let's be consistent with the naming.

Yeah Sebastian, we will update this and get it aligned. Thanks for pointing out.

Regards,
Uma Shankar

Quoted 61 lines
Quoted 61 lines
include/uapi/drm/drm_mode.h +55 -1
+/**
+ * DRM_MODE_LUT_INTERPOLATE
+ *
+ * linearly interpolate between the points  */ #define
+DRM_MODE_LUT_INTERPOLATE BIT(0)
+
+/**
+ * DRM_MODE_LUT_REUSE_LAST
+ *
+ * the last value of the previous range is the
+ * first value of the current range.
+ */
+#define DRM_MODE_LUT_REUSE_LAST BIT(1)
+
+/**
+ * DRM_MODE_LUT_NON_DECREASING
+ *
+ * the curve must be non-decreasing
+ */
+#define DRM_MODE_LUT_NON_DECREASING BIT(2)
+
+/**
+ * DRM_MODE_LUT_REFLECT_NEGATIVE
+ *
+ *  the curve is reflected across origin for negative inputs  */
+#define DRM_MODE_LUT_REFLECT_NEGATIVE BIT(3)
+
+/**
+ * DRM_MODE_LUT_SINGLE_CHANNEL
+ *
+ * the same curve (red) is used for blue and green channels as well
+*/ #define DRM_MODE_LUT_SINGLE_CHANNEL BIT(4)
+
+/**
+ * struct drm_color_lut_range
+ *
+ * structure to advertise capability of a color hardware
+ * block that accepts LUT values.  It can represent LUTs with
+ * varied number of entries and distributions
+ * (Multi segmented, Logarithmic etc).
+ */
+
+struct drm_color_lut_range {
+	/* DRM_MODE_LUT_* */
+	__u32 flags;
+	/* number of points on the curve */
+	__u16 count;
+	/* input/output bits per component */
+	__u8 input_bpc, output_bpc;
+	/* input start/end values */
+	__s32 start, end;
+	/* output min/max values */
+	__s32 min, max;
+};
+
 /*
  * Request a page flip on the specified crtc.
  *
--

2.42.0

#17 lore raw

PATCH 9/28 drm: Add Color ops capability property

In reply to Uma Shankar

Add capability property which a colorop can expose it's hardware's abilities. It's a blob property that can be filled with respective data structures depending on the colorop. The user space is expected to read this property and program the colorop accordingly.

---
 drivers/gpu/drm/drm_atomic_uapi.c |  3 +++
 include/drm/drm_colorop.h         | 13 +++++++++++++
 2 files changed, 16 insertions(+)
drivers/gpu/drm/drm_atomic_uapi.c +3 -0
index 9f6a3a1c8020..95f1df73209c 100644
@@ -770,6 +770,9 @@ drm_atomic_colorop_get_property(struct drm_colorop *colorop,
 		*val = state->curve_1d_type;
 	} else if (property == colorop->data_property) {
 		*val = (state->data) ? state->data->base.id : 0;
+	} else if (property == colorop->hw_caps_property) {
+		*val = state->hw_caps ?
+			state->hw_caps->base.id : 0;
 	} else {
 		return -EINVAL;
 	}
include/drm/drm_colorop.h +13 -0
index 5b8c36538491..f417e109c40a 100644
@@ -59,6 +59,12 @@ struct drm_colorop_state {
 	 */
 	enum drm_colorop_curve_1d_type curve_1d_type;
 
+	/**
+	 * @hw_caps:
+	 *
+	 */
+	struct drm_property_blob *hw_caps;
+
 	/**
 	 * @data:
 	 *
@@ -167,6 +173,13 @@ struct drm_colorop {
 	 */
 	struct drm_property *bypass_property;
 
+	/**
+	 * @hwlut_caps_property:
+	 *
+	 * Property to expose hardware lut capbilities.
+	 */
+	struct drm_property *hw_caps_property;
+
 	/**
 	 * @curve_1d_type:
 	 *
Signature · 1 line
2.42.0
#18 lore raw

Re: [PATCH 09/28] drm: Add Color ops capability property

Quoted 32 lines · Uma Shankar

Add capability property which a colorop can expose it's hardware's abilities. It's a blob property that can be filled with respective data structures depending on the colorop. The user space is expected to read this property and program the colorop accordingly.

---
 drivers/gpu/drm/drm_atomic_uapi.c |  3 +++
 include/drm/drm_colorop.h         | 13 +++++++++++++
 2 files changed, 16 insertions(+)
drivers/gpu/drm/drm_atomic_uapi.c +3 -0
index 9f6a3a1c8020..95f1df73209c 100644
@@ -770,6 +770,9 @@ drm_atomic_colorop_get_property(struct drm_colorop *colorop,
 		*val = state->curve_1d_type;
 	} else if (property == colorop->data_property) {
 		*val = (state->data) ? state->data->base.id : 0;
+	} else if (property == colorop->hw_caps_property) {
+		*val = state->hw_caps ?
+			state->hw_caps->base.id : 0;
 	} else {
 		return -EINVAL;
 	}
include/drm/drm_colorop.h +0 -0
index 5b8c36538491..f417e109c40a 100644

include/drm/drm_colorop.h struct drm_colorop_state { · line 67

Quoted 9 lines
include/drm/drm_colorop.h +6 -0
@@ -59,6 +59,12 @@ struct drm_colorop_state {
 	 */
 	enum drm_colorop_curve_1d_type curve_1d_type;
 
+	/**
+	 * @hw_caps:
+	 *
+	 */
+	struct drm_property_blob *hw_caps;
+

Is this supposed to be generic for any colorop or specifically for DRM_COLOROP_1D_LUT?

Quoted 20 lines
include/drm/drm_colorop.h +7 -0
 	/**
 	 * @data:
 	 *
@@ -167,6 +173,13 @@ struct drm_colorop {
 	 */
 	struct drm_property *bypass_property;
 
+	/**
+	 * @hwlut_caps_property:
+	 *
+	 * Property to expose hardware lut capbilities.
+	 */
+	struct drm_property *hw_caps_property;
+
 	/**
 	 * @curve_1d_type:
 	 *
Signature · 1 line
2.42.0
#19 lore raw

RE: [PATCH 09/28] drm: Add Color ops capability property

Quoted 54 lines

-----Original Message-----
From: Sebastian Wick <[email protected]>
Sent: Tuesday, February 13, 2024 5:35 PM
To: Shankar, Uma <[email protected]>
Cc: [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]
Subject: Re: [PATCH 09/28] drm: Add Color ops capability property

drivers/gpu/drm/drm_atomic_uapi.c drm_atomic_colorop_get_property(struct drm_colorop

Quoted 18 lines · Uma Shankar

Add capability property which a colorop can expose it's hardware's abilities. It's a blob property that can be filled with respective data structures depending on the colorop. The user space is expected to read this property and program the colorop accordingly.

---
 drivers/gpu/drm/drm_atomic_uapi.c |  3 +++
 include/drm/drm_colorop.h         | 13 +++++++++++++
 2 files changed, 16 insertions(+)
drivers/gpu/drm/drm_atomic_uapi.c +0 -0
index 9f6a3a1c8020..95f1df73209c 100644
@@ -770,6 +770,9 @@ drm_atomic_colorop_get_property(struct drm_colorop

*colorop,

Quoted 17 lines
drivers/gpu/drm/drm_atomic_uapi.c +3 -0
 		*val = state->curve_1d_type;
 	} else if (property == colorop->data_property) {
 		*val = (state->data) ? state->data->base.id : 0;
+	} else if (property == colorop->hw_caps_property) {
+		*val = state->hw_caps ?
+			state->hw_caps->base.id : 0;
 	} else {
 		return -EINVAL;
 	}
include/drm/drm_colorop.h +0 -0
index 5b8c36538491..f417e109c40a 100644
@@ -59,6 +59,12 @@ struct drm_colorop_state {
 	 */
 	enum drm_colorop_curve_1d_type curve_1d_type;
 
Quoted 9 lines

include/drm/drm_colorop.h struct drm_colorop_state { · line 67

Quoted 6 lines
include/drm/drm_colorop.h +6 -0
+	/**
+	 * @hw_caps:
+	 *
+	 */
+	struct drm_property_blob *hw_caps;
+

Is this supposed to be generic for any colorop or specifically for DRM_COLOROP_1D_LUT?

We have intentionally kept it generic so that it can be used for any kind of hardware color block (1D LUT, 3D LUT etc.). Differentiation can be done by using the Color op type.

Regards,
Uma Shankar

Quoted 20 lines
Quoted 20 lines
include/drm/drm_colorop.h +7 -1
 	/**
 	 * @data:
 	 *
@@ -167,6 +173,13 @@ struct drm_colorop {
 	 */
 	struct drm_property *bypass_property;
 
+	/**
+	 * @hwlut_caps_property:
+	 *
+	 * Property to expose hardware lut capbilities.
+	 */
+	struct drm_property *hw_caps_property;
+
 	/**
 	 * @curve_1d_type:
 	 *
--

2.42.0

#20 lore raw

PATCH 10/28 drm: Define helper to create color ops capability property

In reply to Uma Shankar

Add a helper to create capability property for a colorop

---
 drivers/gpu/drm/drm_colorop.c | 21 +++++++++++++++++++++
 1 file changed, 21 insertions(+)
drivers/gpu/drm/drm_colorop.c +21 -0
index 4d57eaef04aa..cfdc8e751012 100644
@@ -43,6 +43,27 @@ static const struct drm_prop_enum_list drm_colorop_curve_1d_type_enum_list[] = {
 };
 
 /* Init Helpers */
+__maybe_unused
+static int drm_create_colorop_capability_prop(struct drm_device *dev,
+					      struct drm_colorop *colorop,
+					      struct drm_property_blob *blob)
+{
+	struct drm_property *prop = NULL;
+
+	prop = drm_property_create(dev, DRM_MODE_PROP_BLOB |
+				   DRM_MODE_PROP_ATOMIC |
+				   DRM_MODE_PROP_IMMUTABLE,
+				   "HW_CAPS", 1);
+	if (!prop)
+		return -ENOMEM;
+
+	colorop->hw_caps_property = prop;
+	drm_object_attach_property(&colorop->base,
+				   colorop->hw_caps_property,
+				   blob->base.id);
+
+	return 0;
+}
 
 int drm_colorop_init(struct drm_device *dev, struct drm_colorop *colorop,
 		     struct drm_plane *plane, enum drm_colorop_type type)
Signature · 1 line
2.42.0
#21 lore raw

PATCH 11/28 drm: Define helper for adding capability property for 1D LUT

In reply to Uma Shankar

This adds helper functions to create 1D Lut color block capabilities. It exposes the hardware block as segments which are converted to blob and passed in the property.

---
 drivers/gpu/drm/drm_colorop.c | 24 +++++++++++++++++++++++-
 include/drm/drm_colorop.h     |  4 +++-
 2 files changed, 26 insertions(+), 2 deletions(-)
drivers/gpu/drm/drm_colorop.c +23 -1
index cfdc8e751012..98aef26c0c55 100644
@@ -43,7 +43,6 @@ static const struct drm_prop_enum_list drm_colorop_curve_1d_type_enum_list[] = {
 };
 
 /* Init Helpers */
-__maybe_unused
 static int drm_create_colorop_capability_prop(struct drm_device *dev,
 					      struct drm_colorop *colorop,
 					      struct drm_property_blob *blob)
@@ -65,6 +64,29 @@ static int drm_create_colorop_capability_prop(struct drm_device *dev,
 	return 0;
 }
 
+int drm_colorop_lutcaps_init(struct drm_colorop *colorop,
+			     struct drm_plane *plane,
+			     const struct drm_color_lut_range *ranges,
+			     size_t length)
+{
+	struct drm_device *dev = plane->dev;
+	struct drm_property_blob *blob;
+
+	/* Create Color Caps property for 1D LUT */
+	if (colorop->type != DRM_COLOROP_1D_LUT)
+		return -EINVAL;
+
+	if (WARN_ON(length == 0 || length % sizeof(ranges[0]) != 0))
+		return -EINVAL;
+
+	blob = drm_property_create_blob(plane->dev, length, ranges);
+	if (IS_ERR(blob))
+		return PTR_ERR(blob);
+
+	return drm_create_colorop_capability_prop(dev, colorop, blob);
+}
+EXPORT_SYMBOL(drm_colorop_lutcaps_init);
+
 int drm_colorop_init(struct drm_device *dev, struct drm_colorop *colorop,
 		     struct drm_plane *plane, enum drm_colorop_type type)
 {
include/drm/drm_colorop.h +3 -1
index f417e109c40a..d15d5b489401 100644
@@ -233,7 +233,9 @@ static inline struct drm_colorop *drm_colorop_find(struct drm_device *dev,
 
 int drm_colorop_init(struct drm_device *dev, struct drm_colorop *colorop,
 		     struct drm_plane *plane, enum drm_colorop_type type);
-
+int drm_colorop_lutcaps_init(struct drm_colorop *colorop, struct drm_plane *plane,
+			     const struct drm_color_lut_range *ranges,
+			     size_t length);
 struct drm_colorop_state *
 drm_atomic_helper_colorop_duplicate_state(struct drm_colorop *colorop);
 
Signature · 1 line
2.42.0
#22 lore raw

PATCH 12/28 drm/i915: Add identifiers for intel color blocks

In reply to Uma Shankar

From: Chaitanya Kumar Borah <[email protected]>

Add macros to identify intel color blocks. It will help in mapping drm_color_ops to intel color HW blocks

---
 drivers/gpu/drm/i915/display/intel_display_limits.h | 13 +++++++++++++
 1 file changed, 13 insertions(+)
drivers/gpu/drm/i915/display/intel_display_limits.h +13 -0
index 5126d0b5ae5d..67ceb79309f2 100644
@@ -121,4 +121,17 @@ enum hpd_pin {
 	HPD_NUM_PINS
 };
 
+/*
+ * Intel Color Blocks
+ *
+ */
+
+enum intel_color_block {
+	CB_PLANE_PRE_CSC_LUT,
+	CB_PLANE_CSC,
+	CB_PLANE_POST_CSC_LUT,
+
+	I915_MAX_CB
+};
+
 #endif /* __INTEL_DISPLAY_LIMITS_H__ */
Signature · 1 line
2.42.0
#23 lore raw

PATCH 13/28 drm/i915: Add intel_color_op

In reply to Uma Shankar

From: Chaitanya Kumar Borah <[email protected]>

Add data structure to store intel specific details of colorop

---
 .../gpu/drm/i915/display/intel_display_types.h  | 17 +++++++++++++++++
 1 file changed, 17 insertions(+)
drivers/gpu/drm/i915/display/intel_display_types.h +17 -0
index 01eb6e4e6049..edc61ea0fe29 100644
@@ -1606,6 +1606,8 @@ struct intel_watermark_params {
 #define to_intel_plane(x) container_of(x, struct intel_plane, base)
 #define to_intel_plane_state(x) container_of(x, struct intel_plane_state, uapi)
 #define intel_fb_obj(x) ((x) ? to_intel_bo((x)->obj[0]) : NULL)
+#define to_intel_plane_colorop(x) container_of(x, struct intel_plane_colorop, base)
+#define to_intel_colorop_state(x) container_of(x, struct intel_plane_colorop_state, uapi)
 
 struct intel_hdmi {
 	i915_reg_t hdmi_reg;
@@ -1915,6 +1917,21 @@ struct intel_dp_mst_encoder {
 	struct intel_connector *connector;
 };
 
+struct intel_plane_colorop {
+	struct drm_colorop base;
+	enum intel_color_block id;
+};
+
+struct intel_plane_colorop_state {
+	struct drm_colorop_state uapi;
+
+	/* TODO: Add hw implementation */
+	struct {
+		bool active, enable;
+		struct drm_property_blob *data;
+	} hw;
+};
+
 static inline struct intel_encoder *
 intel_attached_encoder(struct intel_connector *connector)
 {
Signature · 1 line
2.42.0
#24 lore raw

PATCH 14/28 drm/i915/color: Add helper to allocate intel colorop

In reply to Uma Shankar

From: Chaitanya Kumar Borah <[email protected]>

Add helper to allocate memory for intel colorop

---
 drivers/gpu/drm/i915/display/intel_color.c | 25 ++++++++++++++++++++++
 drivers/gpu/drm/i915/display/intel_color.h |  1 +
 2 files changed, 26 insertions(+)
drivers/gpu/drm/i915/display/intel_color.c +25 -0
index ca7112b32cb3..949c2efe105f 100644
@@ -3810,6 +3810,31 @@ static const struct intel_color_funcs ilk_color_funcs = {
 	.get_config = ilk_get_config,
 };
 
+/* TODO: Move to another file */
+struct intel_plane_colorop *intel_colorop_alloc(void)
+{
+	struct intel_plane_colorop *colorop;
+	struct intel_plane_colorop_state *colorop_state;
+
+	colorop = kzalloc(sizeof(*colorop), GFP_KERNEL);
+	if (!colorop)
+		return ERR_PTR(-ENOMEM);
+
+	colorop_state = kzalloc(sizeof(*colorop_state), GFP_KERNEL);
+	if (!colorop_state) {
+		kfree(colorop);
+		return ERR_PTR(-ENOMEM);
+	}
+
+	/* TODO: Add color op reset
+	 * intel_colorop_state_reset(plane_state, plane);
+	 */
+
+	colorop->base.state = &colorop_state->uapi;
+
+	return colorop;
+}
+
 void intel_color_crtc_init(struct intel_crtc *crtc)
 {
 	struct drm_i915_private *i915 = to_i915(crtc->base.dev);
drivers/gpu/drm/i915/display/intel_color.h +1 -0
index 8ecd36149def..e111d115724c 100644
@@ -31,5 +31,6 @@ bool intel_color_lut_equal(const struct intel_crtc_state *crtc_state,
 			   const struct drm_property_blob *blob2,
 			   bool is_pre_csc_lut);
 void intel_color_assert_luts(const struct intel_crtc_state *crtc_state);
+struct intel_plane_colorop *intel_colorop_alloc(void);
 
 #endif /* __INTEL_COLOR_H__ */
Signature · 1 line
2.42.0
#25 lore raw

PATCH 15/28 drm/i915/color: Add helper to create intel colorop

In reply to Uma Shankar

From: Chaitanya Kumar Borah <[email protected]>

Add intel colorop create helper

---
 drivers/gpu/drm/i915/display/intel_color.c | 14 ++++++++++++++
 drivers/gpu/drm/i915/display/intel_color.h |  2 ++
 2 files changed, 16 insertions(+)
drivers/gpu/drm/i915/display/intel_color.c +14 -0
index 949c2efe105f..e187135d4363 100644
@@ -3835,6 +3835,20 @@ struct intel_plane_colorop *intel_colorop_alloc(void)
 	return colorop;
 }
 
+struct intel_plane_colorop *intel_plane_colorop_create(enum intel_color_block id)
+{
+	struct intel_plane_colorop *colorop;
+
+	colorop = intel_colorop_alloc();
+
+	if (IS_ERR(colorop))
+		return colorop;
+
+	colorop->id = id;
+
+	return colorop;
+}
+
 void intel_color_crtc_init(struct intel_crtc *crtc)
 {
 	struct drm_i915_private *i915 = to_i915(crtc->base.dev);
drivers/gpu/drm/i915/display/intel_color.h +2 -0
index e111d115724c..d03dad425671 100644
@@ -12,6 +12,7 @@ struct intel_crtc_state;
 struct intel_crtc;
 struct drm_i915_private;
 struct drm_property_blob;
+enum intel_color_block;
 
 void intel_color_init_hooks(struct drm_i915_private *i915);
 int intel_color_init(struct drm_i915_private *i915);
@@ -32,5 +33,6 @@ bool intel_color_lut_equal(const struct intel_crtc_state *crtc_state,
 			   bool is_pre_csc_lut);
 void intel_color_assert_luts(const struct intel_crtc_state *crtc_state);
 struct intel_plane_colorop *intel_colorop_alloc(void);
+struct intel_plane_colorop *intel_plane_colorop_create(enum intel_color_block id);
 
 #endif /* __INTEL_COLOR_H__ */
Signature · 1 line
2.42.0
#26 lore raw

PATCH 16/28 drm/i915/color: Create a transfer function color pipeline

In reply to Uma Shankar

From: Chaitanya Kumar Borah <[email protected]>

Add a color pipeline with three colorops in the sequence

1D LUT - CTM - 1D LUT

This pipeline can be used to do any color space conversion or HDR tone mapping

---
 drivers/gpu/drm/i915/display/intel_color.c | 42 ++++++++++++++++++++++
 drivers/gpu/drm/i915/display/intel_color.h |  3 ++
 2 files changed, 45 insertions(+)
drivers/gpu/drm/i915/display/intel_color.c +42 -0
index e187135d4363..e223edbe4c13 100644
@@ -28,6 +28,7 @@
 #include "intel_de.h"
 #include "intel_display_types.h"
 #include "intel_dsb.h"
+#include "skl_universal_plane.h"
 
 struct intel_color_funcs {
 	int (*color_check)(struct intel_crtc_state *crtc_state);
@@ -3849,6 +3850,47 @@ struct intel_plane_colorop *intel_plane_colorop_create(enum intel_color_block id
 	return colorop;
 }
 
+int intel_plane_tf_pipeline_init(struct drm_plane *plane, struct drm_prop_enum_list *list)
+{
+	struct intel_plane *intel_plane = to_intel_plane(plane);
+	struct intel_plane_colorop *colorop;
+	struct drm_device *dev = plane->dev;
+	struct drm_i915_private *i915 = to_i915(dev);
+	int ret;
+	struct drm_colorop *prev_op;
+
+	colorop = intel_plane_colorop_create(CB_PLANE_PRE_CSC_LUT);
+
+	ret = drm_colorop_init(dev, &colorop->base, plane, DRM_COLOROP_1D_LUT);
+	if (ret)
+		return ret;
+
+	list->type = colorop->base.base.id;
+	list->name = kasprintf(GFP_KERNEL, "Color Pipeline %d", colorop->base.base.id);
+
+	/* TODO: handle failures and clean up*/
+	prev_op = &colorop->base;
+
+	if (icl_is_hdr_plane(i915, intel_plane->id)) {
+		colorop = intel_plane_colorop_create(CB_PLANE_CSC);
+		ret = drm_colorop_init(dev, &colorop->base, plane, DRM_COLOROP_CTM_3X3);
+		if (ret)
+			return ret;
+
+		drm_colorop_set_next_property(prev_op, &colorop->base);
+		prev_op = &colorop->base;
+	}
+
+	colorop = intel_plane_colorop_create(CB_PLANE_POST_CSC_LUT);
+	ret = drm_colorop_init(dev, &colorop->base, plane, DRM_COLOROP_1D_LUT);
+	if (ret)
+		return ret;
+
+	drm_colorop_set_next_property(prev_op, &colorop->base);
+
+	return 0;
+}
+
 void intel_color_crtc_init(struct intel_crtc *crtc)
 {
 	struct drm_i915_private *i915 = to_i915(crtc->base.dev);
drivers/gpu/drm/i915/display/intel_color.h +3 -0
index d03dad425671..e0b75dcb1b65 100644
@@ -12,6 +12,8 @@ struct intel_crtc_state;
 struct intel_crtc;
 struct drm_i915_private;
 struct drm_property_blob;
+struct drm_plane;
+struct drm_prop_enum_list;
 enum intel_color_block;
 
 void intel_color_init_hooks(struct drm_i915_private *i915);
@@ -34,5 +36,6 @@ bool intel_color_lut_equal(const struct intel_crtc_state *crtc_state,
 void intel_color_assert_luts(const struct intel_crtc_state *crtc_state);
 struct intel_plane_colorop *intel_colorop_alloc(void);
 struct intel_plane_colorop *intel_plane_colorop_create(enum intel_color_block id);
+int intel_plane_tf_pipeline_init(struct drm_plane *plane, struct drm_prop_enum_list *list);
 
 #endif /* __INTEL_COLOR_H__ */
Signature · 1 line
2.42.0
#27 lore raw

Re: [PATCH 16/28] drm/i915/color: Create a transfer function color pipeline

Hi Uma,

kernel test robot noticed the following build warnings:

https://git-scm.com/docs/git-format-patch#_base_tree_information]

url:    https://github.com/intel-lab-lkp/linux/commits/Uma-Shankar/drm-color-pipeline-base-work/20240213-144544
base:   git://anongit.freedesktop.org/drm/drm-misc drm-misc-next
patch link:    https://lore.kernel.org/r/20240213064835.139464-17-uma.shankar%40intel.com
patch subject: [PATCH 16/28] drm/i915/color: Create a transfer function color pipeline
config: i386-randconfig-141-20240217 (https://download.01.org/0day-ci/archive/20240218/[email protected]/config)
compiler: clang version 17.0.6 (https://github.com/llvm/llvm-project 6009708b4367171ccdbf4b5905cb6a803753fe18)

If you fix the issue in a separate patch/commit (i.e. not just a new version of the same patch/commit), kindly add following tags

| Reported-by: kernel test robot <[email protected]>
| Reported-by: Dan Carpenter <[email protected]>
| Closes: https://lore.kernel.org/r/[email protected]/

New smatch warnings:
drivers/gpu/drm/i915/display/intel_color.c:3867 intel_plane_tf_pipeline_init() error: 'colorop' dereferencing possible ERR_PTR()

vim +/colorop +3867 drivers/gpu/drm/i915/display/intel_color.c

5e1e0f87c9bcae Chaitanya Kumar Borah 2024-02-13  3852  int intel_plane_tf_pipeline_init(struct drm_plane *plane, struct drm_prop_enum_list *list)
5e1e0f87c9bcae Chaitanya Kumar Borah 2024-02-13  3853  {
5e1e0f87c9bcae Chaitanya Kumar Borah 2024-02-13  3854  	struct intel_plane *intel_plane = to_intel_plane(plane);
5e1e0f87c9bcae Chaitanya Kumar Borah 2024-02-13  3855  	struct intel_plane_colorop *colorop;
5e1e0f87c9bcae Chaitanya Kumar Borah 2024-02-13  3856  	struct drm_device *dev = plane->dev;
5e1e0f87c9bcae Chaitanya Kumar Borah 2024-02-13  3857  	struct drm_i915_private *i915 = to_i915(dev);
5e1e0f87c9bcae Chaitanya Kumar Borah 2024-02-13  3858  	int ret;
5e1e0f87c9bcae Chaitanya Kumar Borah 2024-02-13  3859  	struct drm_colorop *prev_op;
5e1e0f87c9bcae Chaitanya Kumar Borah 2024-02-13  3860  
5e1e0f87c9bcae Chaitanya Kumar Borah 2024-02-13  3861  	colorop = intel_plane_colorop_create(CB_PLANE_PRE_CSC_LUT);

No error checking

5e1e0f87c9bcae Chaitanya Kumar Borah 2024-02-13  3862  
5e1e0f87c9bcae Chaitanya Kumar Borah 2024-02-13  3863  	ret = drm_colorop_init(dev, &colorop->base, plane, DRM_COLOROP_1D_LUT);
5e1e0f87c9bcae Chaitanya Kumar Borah 2024-02-13  3864  	if (ret)
5e1e0f87c9bcae Chaitanya Kumar Borah 2024-02-13  3865  		return ret;
5e1e0f87c9bcae Chaitanya Kumar Borah 2024-02-13  3866  
5e1e0f87c9bcae Chaitanya Kumar Borah 2024-02-13 @3867  	list->type = colorop->base.base.id;
5e1e0f87c9bcae Chaitanya Kumar Borah 2024-02-13  3868  	list->name = kasprintf(GFP_KERNEL, "Color Pipeline %d", colorop->base.base.id);
5e1e0f87c9bcae Chaitanya Kumar Borah 2024-02-13  3869  
5e1e0f87c9bcae Chaitanya Kumar Borah 2024-02-13  3870  	/* TODO: handle failures and clean up*/
5e1e0f87c9bcae Chaitanya Kumar Borah 2024-02-13  3871  	prev_op = &colorop->base;
Signature · 2 lines
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki
#28 lore raw

PATCH 17/28 drm/i915: Define segmented Lut and add capabilities to colorop

In reply to Uma Shankar

This defines the lut segments and create the color pipeline

---
 drivers/gpu/drm/i915/display/intel_color.c | 109 +++++++++++++++++++++
 1 file changed, 109 insertions(+)
drivers/gpu/drm/i915/display/intel_color.c +109 -0
index e223edbe4c13..223cd1ff7291 100644
@@ -3811,6 +3811,105 @@ static const struct intel_color_funcs ilk_color_funcs = {
 	.get_config = ilk_get_config,
 };
 
+static const struct drm_color_lut_range xelpd_degamma_hdr[] = {
+	/* segment 1 */
+	{
+		.flags = (DRM_MODE_LUT_REFLECT_NEGATIVE |
+				DRM_MODE_LUT_INTERPOLATE |
+				DRM_MODE_LUT_NON_DECREASING),
+		.count = 128,
+		.input_bpc = 24, .output_bpc = 16,
+		.start = 0, .end = (1 << 24) - 1,
+		.min = 0, .max = (1 << 24) - 1,
+	},
+	/* segment 2 */
+	{
+		.flags = (DRM_MODE_LUT_REFLECT_NEGATIVE |
+				DRM_MODE_LUT_INTERPOLATE |
+				DRM_MODE_LUT_REUSE_LAST |
+				DRM_MODE_LUT_NON_DECREASING),
+		.count = 1,
+		.input_bpc = 24, .output_bpc = 16,
+		.start = (1 << 24) - 1, .end = 1 << 24,
+		.min = 0, .max = (1 << 27) - 1,
+	},
+	/* Segment 3 */
+	{
+		.flags = (DRM_MODE_LUT_REFLECT_NEGATIVE |
+				DRM_MODE_LUT_INTERPOLATE |
+				DRM_MODE_LUT_REUSE_LAST |
+				DRM_MODE_LUT_NON_DECREASING),
+		.count = 1,
+		.input_bpc = 24, .output_bpc = 16,
+		.start = 1 << 24, .end = 3 << 24,
+		.min = 0, .max = (1 << 27) - 1,
+	},
+	/* Segment 4 */
+	{
+		.flags = (DRM_MODE_LUT_REFLECT_NEGATIVE |
+				DRM_MODE_LUT_INTERPOLATE |
+				DRM_MODE_LUT_REUSE_LAST |
+				DRM_MODE_LUT_NON_DECREASING),
+		.count = 1,
+		.input_bpc = 24, .output_bpc = 16,
+		.start = 3 << 24, .end = 7 << 24,
+		.min = 0, .max = (1 << 27) - 1,
+	}
+};
+
+/* FIXME input bpc? */
+static const struct drm_color_lut_range xelpd_gamma_hdr[] = {
+	/*
+	 * ToDo: Add Segment 1
+	 * There is an optional fine segment added with 9 lut values
+	 * Will be added later
+	 */
+
+	/* segment 2 */
+	{
+		.flags = (DRM_MODE_LUT_REFLECT_NEGATIVE |
+				DRM_MODE_LUT_INTERPOLATE |
+				DRM_MODE_LUT_NON_DECREASING),
+		.count = 32,
+		.input_bpc = 24, .output_bpc = 16,
+		.start = 0, .end = (1 << 24) - 1,
+		.min = 0, .max = (1 << 24) - 1,
+	},
+	/* segment 3 */
+	{
+		.flags = (DRM_MODE_LUT_REFLECT_NEGATIVE |
+				DRM_MODE_LUT_INTERPOLATE |
+				DRM_MODE_LUT_REUSE_LAST |
+				DRM_MODE_LUT_NON_DECREASING),
+		.count = 1,
+		.input_bpc = 24, .output_bpc = 16,
+		.start = (1 << 24) - 1, .end = 1 << 24,
+		.min = 0, .max = 1 << 24,
+	},
+	/* Segment 4 */
+	{
+		.flags = (DRM_MODE_LUT_REFLECT_NEGATIVE |
+				DRM_MODE_LUT_INTERPOLATE |
+				DRM_MODE_LUT_REUSE_LAST |
+				DRM_MODE_LUT_NON_DECREASING),
+		.count = 1,
+		.input_bpc = 24, .output_bpc = 16,
+		.start = 1 << 24, .end = 3 << 24,
+		.min = 0, .max = (3 << 24),
+	},
+	/* Segment 5 */
+	{
+		.flags = (DRM_MODE_LUT_REFLECT_NEGATIVE |
+				DRM_MODE_LUT_INTERPOLATE |
+				DRM_MODE_LUT_REUSE_LAST |
+				DRM_MODE_LUT_NON_DECREASING),
+		.count = 1,
+		.input_bpc = 24, .output_bpc = 16,
+		.start = 3 << 24, .end = 7 << 24,
+		.min = 0, .max = (7 << 24),
+	},
+};
+
 /* TODO: Move to another file */
 struct intel_plane_colorop *intel_colorop_alloc(void)
 {
@@ -3865,6 +3964,11 @@ int intel_plane_tf_pipeline_init(struct drm_plane *plane, struct drm_prop_enum_l
 	if (ret)
 		return ret;
 
+	if (icl_is_hdr_plane(i915, to_intel_plane(plane)->id)) {
+		drm_colorop_lutcaps_init(&colorop->base, plane, xelpd_degamma_hdr,
+					 sizeof(xelpd_degamma_hdr));
+	}
+
 	list->type = colorop->base.base.id;
 	list->name = kasprintf(GFP_KERNEL, "Color Pipeline %d", colorop->base.base.id);
 
@@ -3886,6 +3990,11 @@ int intel_plane_tf_pipeline_init(struct drm_plane *plane, struct drm_prop_enum_l
 	if (ret)
 		return ret;
 
+	if (icl_is_hdr_plane(i915, to_intel_plane(plane)->id)) {
+		drm_colorop_lutcaps_init(&colorop->base, plane, xelpd_gamma_hdr,
+					 sizeof(xelpd_gamma_hdr));
+	}
+
 	drm_colorop_set_next_property(prev_op, &colorop->base);
 
 	return 0;
Signature · 1 line
2.42.0
#29 lore raw

Re: [PATCH 17/28] drm/i915: Define segmented Lut and add capabilities to colorop

Quoted 13 lines · On Tue, 13 Feb 2024 12:18:24 +0530 Uma Shankar <[email protected]> wrote:

This defines the lut segments and create the color pipeline

---
 drivers/gpu/drm/i915/display/intel_color.c | 109 +++++++++++++++++++++
 1 file changed, 109 insertions(+)
drivers/gpu/drm/i915/display/intel_color.c +0 -0
index e223edbe4c13..223cd1ff7291 100644

drivers/gpu/drm/i915/display/intel_color.c static const struct intel_color_funcs ilk_color_funcs = { · line 3819

Quoted 9 lines
drivers/gpu/drm/i915/display/intel_color.c +6 -0
@@ -3811,6 +3811,105 @@ static const struct intel_color_funcs ilk_color_funcs = {
 	.get_config = ilk_get_config,
 };
 
+static const struct drm_color_lut_range xelpd_degamma_hdr[] = {
+	/* segment 1 */
+	{
+		.flags = (DRM_MODE_LUT_REFLECT_NEGATIVE |
+				DRM_MODE_LUT_INTERPOLATE |
+				DRM_MODE_LUT_NON_DECREASING),

Hi Uma,

is it a good idea to have these flags per-segment?

I would find it very strange, unusable really, if REFLECT_NEGATIVE applied on some but not all segments, for example. Is such flexibility really necessary in the hardware description?

drivers/gpu/drm/i915/display/intel_color.c static const struct intel_color_funcs ilk_color_funcs = { · line 3821

Quoted 2 lines
drivers/gpu/drm/i915/display/intel_color.c +2 -0
+		.count = 128,
+		.input_bpc = 24, .output_bpc = 16,

The same question about input_bpc and output_bpc.

drivers/gpu/drm/i915/display/intel_color.c static const struct intel_color_funcs ilk_color_funcs = { · line 3833

Quoted 12 lines
drivers/gpu/drm/i915/display/intel_color.c +12 -0
+		.start = 0, .end = (1 << 24) - 1,
+		.min = 0, .max = (1 << 24) - 1,
+	},
+	/* segment 2 */
+	{
+		.flags = (DRM_MODE_LUT_REFLECT_NEGATIVE |
+				DRM_MODE_LUT_INTERPOLATE |
+				DRM_MODE_LUT_REUSE_LAST |
+				DRM_MODE_LUT_NON_DECREASING),
+		.count = 1,
+		.input_bpc = 24, .output_bpc = 16,
+		.start = (1 << 24) - 1, .end = 1 << 24,

What if there is a gap or overlap between the previous segment .end and the next segment .start? Is it forbidden? Will the kernel common code verify that drivers don't make mistakes? Or IGT?

Thanks,
pq

Quoted 106 lines
drivers/gpu/drm/i915/display/intel_color.c +89 -0
+		.min = 0, .max = (1 << 27) - 1,
+	},
+	/* Segment 3 */
+	{
+		.flags = (DRM_MODE_LUT_REFLECT_NEGATIVE |
+				DRM_MODE_LUT_INTERPOLATE |
+				DRM_MODE_LUT_REUSE_LAST |
+				DRM_MODE_LUT_NON_DECREASING),
+		.count = 1,
+		.input_bpc = 24, .output_bpc = 16,
+		.start = 1 << 24, .end = 3 << 24,
+		.min = 0, .max = (1 << 27) - 1,
+	},
+	/* Segment 4 */
+	{
+		.flags = (DRM_MODE_LUT_REFLECT_NEGATIVE |
+				DRM_MODE_LUT_INTERPOLATE |
+				DRM_MODE_LUT_REUSE_LAST |
+				DRM_MODE_LUT_NON_DECREASING),
+		.count = 1,
+		.input_bpc = 24, .output_bpc = 16,
+		.start = 3 << 24, .end = 7 << 24,
+		.min = 0, .max = (1 << 27) - 1,
+	}
+};
+
+/* FIXME input bpc? */
+static const struct drm_color_lut_range xelpd_gamma_hdr[] = {
+	/*
+	 * ToDo: Add Segment 1
+	 * There is an optional fine segment added with 9 lut values
+	 * Will be added later
+	 */
+
+	/* segment 2 */
+	{
+		.flags = (DRM_MODE_LUT_REFLECT_NEGATIVE |
+				DRM_MODE_LUT_INTERPOLATE |
+				DRM_MODE_LUT_NON_DECREASING),
+		.count = 32,
+		.input_bpc = 24, .output_bpc = 16,
+		.start = 0, .end = (1 << 24) - 1,
+		.min = 0, .max = (1 << 24) - 1,
+	},
+	/* segment 3 */
+	{
+		.flags = (DRM_MODE_LUT_REFLECT_NEGATIVE |
+				DRM_MODE_LUT_INTERPOLATE |
+				DRM_MODE_LUT_REUSE_LAST |
+				DRM_MODE_LUT_NON_DECREASING),
+		.count = 1,
+		.input_bpc = 24, .output_bpc = 16,
+		.start = (1 << 24) - 1, .end = 1 << 24,
+		.min = 0, .max = 1 << 24,
+	},
+	/* Segment 4 */
+	{
+		.flags = (DRM_MODE_LUT_REFLECT_NEGATIVE |
+				DRM_MODE_LUT_INTERPOLATE |
+				DRM_MODE_LUT_REUSE_LAST |
+				DRM_MODE_LUT_NON_DECREASING),
+		.count = 1,
+		.input_bpc = 24, .output_bpc = 16,
+		.start = 1 << 24, .end = 3 << 24,
+		.min = 0, .max = (3 << 24),
+	},
+	/* Segment 5 */
+	{
+		.flags = (DRM_MODE_LUT_REFLECT_NEGATIVE |
+				DRM_MODE_LUT_INTERPOLATE |
+				DRM_MODE_LUT_REUSE_LAST |
+				DRM_MODE_LUT_NON_DECREASING),
+		.count = 1,
+		.input_bpc = 24, .output_bpc = 16,
+		.start = 3 << 24, .end = 7 << 24,
+		.min = 0, .max = (7 << 24),
+	},
+};
+
 /* TODO: Move to another file */
 struct intel_plane_colorop *intel_colorop_alloc(void)
 {
@@ -3865,6 +3964,11 @@ int intel_plane_tf_pipeline_init(struct drm_plane *plane, struct drm_prop_enum_l
 	if (ret)
 		return ret;
 
+	if (icl_is_hdr_plane(i915, to_intel_plane(plane)->id)) {
+		drm_colorop_lutcaps_init(&colorop->base, plane, xelpd_degamma_hdr,
+					 sizeof(xelpd_degamma_hdr));
+	}
+
 	list->type = colorop->base.base.id;
 	list->name = kasprintf(GFP_KERNEL, "Color Pipeline %d", colorop->base.base.id);
 
@@ -3886,6 +3990,11 @@ int intel_plane_tf_pipeline_init(struct drm_plane *plane, struct drm_prop_enum_l
 	if (ret)
 		return ret;
 
+	if (icl_is_hdr_plane(i915, to_intel_plane(plane)->id)) {
+		drm_colorop_lutcaps_init(&colorop->base, plane, xelpd_gamma_hdr,
+					 sizeof(xelpd_gamma_hdr));
+	}
+
 	drm_colorop_set_next_property(prev_op, &colorop->base);
 
 	return 0;
#30 lore raw

RE: [PATCH 17/28] drm/i915: Define segmented Lut and add capabilities to colorop

Quoted 50 lines

-----Original Message-----
From: dri-devel <[email protected]> On Behalf Of Pekka Paalanen
Sent: Tuesday, February 13, 2024 3:07 PM
To: Shankar, Uma <[email protected]>
Cc: [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]
Subject: Re: [PATCH 17/28] drm/i915: Define segmented Lut and add capabilities to colorop

drivers/gpu/drm/i915/display/intel_color.c static const struct intel_color_funcs

Quoted 15 lines · On Tue, 13 Feb 2024 12:18:24 +0530 Uma Shankar <[email protected]> wrote:

This defines the lut segments and create the color pipeline

---
 drivers/gpu/drm/i915/display/intel_color.c | 109
+++++++++++++++++++++
 1 file changed, 109 insertions(+)
drivers/gpu/drm/i915/display/intel_color.c +0 -0
index e223edbe4c13..223cd1ff7291 100644
@@ -3811,6 +3811,105 @@ static const struct intel_color_funcs

ilk_color_funcs = {

drivers/gpu/drm/i915/display/intel_color.c static const struct intel_color_funcs ilk_color_funcs = { · line 3819

Quoted 9 lines
drivers/gpu/drm/i915/display/intel_color.c +6 -0
 	.get_config = ilk_get_config,
 };
 
+static const struct drm_color_lut_range xelpd_degamma_hdr[] = {
+	/* segment 1 */
+	{
+		.flags = (DRM_MODE_LUT_REFLECT_NEGATIVE |
+				DRM_MODE_LUT_INTERPOLATE |
+				DRM_MODE_LUT_NON_DECREASING),

Hi Uma,

Quoted 5 lines

is it a good idea to have these flags per-segment?

I would find it very strange, unusable really, if REFLECT_NEGATIVE applied on some but not all segments, for example. Is such flexibility really necessary in the hardware description?

Hi Pekka,
Idea to have these flags is to just have some option in case there are some differences across segments. Most cases this should not be the case, just helps to future proof the implementation.

Based on how the community feels on the usability of it, we can take a call on the flags and the expected interpretation for the same. We are open for suggestions on the same.

Quoted 5 lines

drivers/gpu/drm/i915/display/intel_color.c static const struct intel_color_funcs · line 3821

Quoted 3 lines
drivers/gpu/drm/i915/display/intel_color.c +2 -0
+		.count = 128,
+		.input_bpc = 24, .output_bpc = 16,

The same question about input_bpc and output_bpc.

Same for these as well, userspace can just ignore these if no usage. However, for some clients it may help in Lut computations.
The original idea for the structure came from Ville (missed to mention that in cover letter, will get that updated in next version).

@[email protected] Please share your inputs on the usability of these attributes.

Quoted 8 lines
Quoted 8 lines
drivers/gpu/drm/i915/display/intel_color.c +8 -0
+		.start = 0, .end = (1 << 24) - 1,
+		.min = 0, .max = (1 << 24) - 1,
+	},
+	/* segment 2 */
+	{
+		.flags = (DRM_MODE_LUT_REFLECT_NEGATIVE |
+				DRM_MODE_LUT_INTERPOLATE |
+				DRM_MODE_LUT_REUSE_LAST |
Quoted 8 lines

drivers/gpu/drm/i915/display/intel_color.c static const struct intel_color_funcs ilk_color_funcs = { · line 3833

Quoted 4 lines
drivers/gpu/drm/i915/display/intel_color.c +4 -0
+				DRM_MODE_LUT_NON_DECREASING),
+		.count = 1,
+		.input_bpc = 24, .output_bpc = 16,
+		.start = (1 << 24) - 1, .end = 1 << 24,

What if there is a gap or overlap between the previous segment .end and the next segment .start? Is it forbidden? Will the kernel common code verify that drivers don't make mistakes? Or IGT?

This is just to help give some reference to userspace. As of now, driver trusts the values coming from userspace if it sends wrong values its on him and driver can't help much. However, we surely can have some sanity check like non decreasing luts etc. to driver.

Ideally LUT values should not overlap, but we can indicate this explicitly with flag to hint the userspace (for overlap or otherwise) and also get a check in driver for the same.

Regards,
Uma Shankar

Quoted 114 lines

Thanks,
pq

Quoted 72 lines
drivers/gpu/drm/i915/display/intel_color.c +72 -0
+		.min = 0, .max = (1 << 27) - 1,
+	},
+	/* Segment 3 */
+	{
+		.flags = (DRM_MODE_LUT_REFLECT_NEGATIVE |
+				DRM_MODE_LUT_INTERPOLATE |
+				DRM_MODE_LUT_REUSE_LAST |
+				DRM_MODE_LUT_NON_DECREASING),
+		.count = 1,
+		.input_bpc = 24, .output_bpc = 16,
+		.start = 1 << 24, .end = 3 << 24,
+		.min = 0, .max = (1 << 27) - 1,
+	},
+	/* Segment 4 */
+	{
+		.flags = (DRM_MODE_LUT_REFLECT_NEGATIVE |
+				DRM_MODE_LUT_INTERPOLATE |
+				DRM_MODE_LUT_REUSE_LAST |
+				DRM_MODE_LUT_NON_DECREASING),
+		.count = 1,
+		.input_bpc = 24, .output_bpc = 16,
+		.start = 3 << 24, .end = 7 << 24,
+		.min = 0, .max = (1 << 27) - 1,
+	}
+};
+
+/* FIXME input bpc? */
+static const struct drm_color_lut_range xelpd_gamma_hdr[] = {
+	/*
+	 * ToDo: Add Segment 1
+	 * There is an optional fine segment added with 9 lut values
+	 * Will be added later
+	 */
+
+	/* segment 2 */
+	{
+		.flags = (DRM_MODE_LUT_REFLECT_NEGATIVE |
+				DRM_MODE_LUT_INTERPOLATE |
+				DRM_MODE_LUT_NON_DECREASING),
+		.count = 32,
+		.input_bpc = 24, .output_bpc = 16,
+		.start = 0, .end = (1 << 24) - 1,
+		.min = 0, .max = (1 << 24) - 1,
+	},
+	/* segment 3 */
+	{
+		.flags = (DRM_MODE_LUT_REFLECT_NEGATIVE |
+				DRM_MODE_LUT_INTERPOLATE |
+				DRM_MODE_LUT_REUSE_LAST |
+				DRM_MODE_LUT_NON_DECREASING),
+		.count = 1,
+		.input_bpc = 24, .output_bpc = 16,
+		.start = (1 << 24) - 1, .end = 1 << 24,
+		.min = 0, .max = 1 << 24,
+	},
+	/* Segment 4 */
+	{
+		.flags = (DRM_MODE_LUT_REFLECT_NEGATIVE |
+				DRM_MODE_LUT_INTERPOLATE |
+				DRM_MODE_LUT_REUSE_LAST |
+				DRM_MODE_LUT_NON_DECREASING),
+		.count = 1,
+		.input_bpc = 24, .output_bpc = 16,
+		.start = 1 << 24, .end = 3 << 24,
+		.min = 0, .max = (3 << 24),
+	},
+	/* Segment 5 */
+	{
+		.flags = (DRM_MODE_LUT_REFLECT_NEGATIVE |
+				DRM_MODE_LUT_INTERPOLATE |
+				DRM_MODE_LUT_REUSE_LAST |
+				DRM_MODE_LUT_NON_DECREASING),

drivers/gpu/drm/i915/display/intel_color.c static const struct intel_color_funcs ilk_color_funcs = {

Quoted 10 lines
drivers/gpu/drm/i915/display/intel_color.c +8 -0
+		.count = 1,
+		.input_bpc = 24, .output_bpc = 16,
+		.start = 3 << 24, .end = 7 << 24,
+		.min = 0, .max = (7 << 24),
+	},
+};
+
 /* TODO: Move to another file */
 struct intel_plane_colorop *intel_colorop_alloc(void)  { @@ -3865,6
+3964,11 @@ int intel_plane_tf_pipeline_init(struct drm_plane *plane, struct

drm_prop_enum_l

drivers/gpu/drm/i915/display/intel_color.c int intel_plane_tf_pipeline_init(struct drm_plane *plane, struct drm_prop_enum_l

Quoted 5 lines
drivers/gpu/drm/i915/display/intel_color.c +2 -0
 	if (ret)
 		return ret;
 
+	if (icl_is_hdr_plane(i915, to_intel_plane(plane)->id)) {
+		drm_colorop_lutcaps_init(&colorop->base, plane,

xelpd_degamma_hdr,

drivers/gpu/drm/i915/display/intel_color.c int intel_plane_tf_pipeline_init(struct drm_plane

Quoted 8 lines
drivers/gpu/drm/i915/display/intel_color.c +3 -0
+					 sizeof(xelpd_degamma_hdr));
+	}
+
 	list->type = colorop->base.base.id;
 	list->name = kasprintf(GFP_KERNEL, "Color Pipeline %d",

colorop->base.base.id);

drivers/gpu/drm/i915/display/intel_color.c +0 -0
@@ -3886,6 +3990,11 @@ int intel_plane_tf_pipeline_init(struct drm_plane

*plane, struct drm_prop_enum_l

drivers/gpu/drm/i915/display/intel_color.c int intel_plane_tf_pipeline_init(struct drm_plane *plane, struct drm_prop_enum_l

Quoted 5 lines
drivers/gpu/drm/i915/display/intel_color.c +2 -0
 	if (ret)
 		return ret;
 
+	if (icl_is_hdr_plane(i915, to_intel_plane(plane)->id)) {
+		drm_colorop_lutcaps_init(&colorop->base, plane,

xelpd_gamma_hdr,

Quoted 6 lines
drivers/gpu/drm/i915/display/intel_color.c +3 -0
+					 sizeof(xelpd_gamma_hdr));
+	}
+
 	drm_colorop_set_next_property(prev_op, &colorop->base);
 
 	return 0;
#31 lore raw

Re: [PATCH 17/28] drm/i915: Define segmented Lut and add capabilities to colorop

Quoted 68 lines · Uma
Quoted 48 lines

-----Original Message-----
From: dri-devel <[email protected]> On Behalf Of Pekka Paalanen
Sent: Tuesday, February 13, 2024 3:07 PM
To: Shankar, Uma <[email protected]>
Cc: [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]
Subject: Re: [PATCH 17/28] drm/i915: Define segmented Lut and add capabilities to colorop

drivers/gpu/drm/i915/display/intel_color.c static const struct intel_color_funcs

Quoted 15 lines · On Tue, 13 Feb 2024 12:18:24 +0530 Uma Shankar <[email protected]> wrote:

This defines the lut segments and create the color pipeline

---
 drivers/gpu/drm/i915/display/intel_color.c | 109
+++++++++++++++++++++
 1 file changed, 109 insertions(+)
drivers/gpu/drm/i915/display/intel_color.c +0 -0
index e223edbe4c13..223cd1ff7291 100644
@@ -3811,6 +3811,105 @@ static const struct intel_color_funcs  

ilk_color_funcs = {

drivers/gpu/drm/i915/display/intel_color.c static const struct intel_color_funcs ilk_color_funcs = { · line 3819

Quoted 9 lines
drivers/gpu/drm/i915/display/intel_color.c +6 -0
 	.get_config = ilk_get_config,
 };
 
+static const struct drm_color_lut_range xelpd_degamma_hdr[] = {
+	/* segment 1 */
+	{
+		.flags = (DRM_MODE_LUT_REFLECT_NEGATIVE |
+				DRM_MODE_LUT_INTERPOLATE |
+				DRM_MODE_LUT_NON_DECREASING),  

Hi Uma,

Quoted 5 lines

is it a good idea to have these flags per-segment?

I would find it very strange, unusable really, if REFLECT_NEGATIVE applied on some but not all segments, for example. Is such flexibility really necessary in the hardware description?

Hi Pekka,
Idea to have these flags is to just have some option in case there are some differences across segments. Most cases this should not be the case, just helps to future proof the implementation.

Based on how the community feels on the usability of it, we can take a call on the flags and the expected interpretation for the same. We are open for suggestions on the same.

Quoted 5 lines

drivers/gpu/drm/i915/display/intel_color.c static const struct intel_color_funcs · line 3821

Quoted 3 lines
drivers/gpu/drm/i915/display/intel_color.c +2 -0
+		.count = 128,
+		.input_bpc = 24, .output_bpc = 16,  

The same question about input_bpc and output_bpc.

Quoted 6 lines

Same for these as well, userspace can just ignore these if no usage. However, for some clients it may help in Lut computations.
The original idea for the structure came from Ville (missed to mention that in cover letter, will get that updated in next version).

@[email protected] Please share your inputs on the usability of these attributes.

Userspace will always need to evaluate whether each segment is good enough individually, so maybe it's not that big deal.

Ignoring these is not an option for userspace, because that would mean userspace does not know what it is getting. If UAPI contains a parameter, then the onus is on userspace to ensure the value is acceptable.

Quoted 17 lines
Quoted 8 lines
Quoted 8 lines
drivers/gpu/drm/i915/display/intel_color.c +8 -0
+		.start = 0, .end = (1 << 24) - 1,
+		.min = 0, .max = (1 << 24) - 1,
+	},
+	/* segment 2 */
+	{
+		.flags = (DRM_MODE_LUT_REFLECT_NEGATIVE |
+				DRM_MODE_LUT_INTERPOLATE |
+				DRM_MODE_LUT_REUSE_LAST |
Quoted 8 lines

drivers/gpu/drm/i915/display/intel_color.c static const struct intel_color_funcs ilk_color_funcs = { · line 3833

Quoted 4 lines
drivers/gpu/drm/i915/display/intel_color.c +4 -0
+				DRM_MODE_LUT_NON_DECREASING),
+		.count = 1,
+		.input_bpc = 24, .output_bpc = 16,
+		.start = (1 << 24) - 1, .end = 1 << 24,  

What if there is a gap or overlap between the previous segment .end and the next segment .start? Is it forbidden? Will the kernel common code verify that drivers don't make mistakes? Or IGT?

Quoted 3 lines

This is just to help give some reference to userspace. As of now, driver trusts the values coming from userspace if it sends wrong values its on him and driver can't help much. However, we surely can have some sanity check like non decreasing luts etc. to driver.

But what will guarantee that the driver provided values are consistent? That they actually describe a template of a well-formed sampled curve? If they are not consistent, userspace cannot use the colorop. Whose responsibility is it to ensure the consistency?

We have a few examples of drivers getting descriptive values like these simply wrong until DRM common code started sanity-checking them, the bitmasks of possible_clones and possible_crtcs for example.

There should also be DRM common code to verify that userspace provided data matches the segmented LUT description rather than drivers just trusting it. If it doesn't match, the atomic commit must fail rather than silently malfunction. The same with programming hardware: if hardware does not produce the intended result from a given segmented LUT configuration, the atomic commit must fail instead of malfunction.

Quoted 3 lines

Ideally LUT values should not overlap, but we can indicate this explicitly with flag to hint the userspace (for overlap or otherwise) and also get a check in driver for the same.

Sorry? How could overlapping segments ever work? Or segments with a gap between them?

If segments overlap, what's the rule for choosing which segment to use for an input value hitting both? The segments can disagree on the result.

If there are gaps, what is the rule how to handle an input value hitting a gap?

Thanks,
pq

Quoted 119 lines

Regards,
Uma Shankar

Quoted 114 lines

Thanks,
pq

Quoted 72 lines
drivers/gpu/drm/i915/display/intel_color.c +72 -0
+		.min = 0, .max = (1 << 27) - 1,
+	},
+	/* Segment 3 */
+	{
+		.flags = (DRM_MODE_LUT_REFLECT_NEGATIVE |
+				DRM_MODE_LUT_INTERPOLATE |
+				DRM_MODE_LUT_REUSE_LAST |
+				DRM_MODE_LUT_NON_DECREASING),
+		.count = 1,
+		.input_bpc = 24, .output_bpc = 16,
+		.start = 1 << 24, .end = 3 << 24,
+		.min = 0, .max = (1 << 27) - 1,
+	},
+	/* Segment 4 */
+	{
+		.flags = (DRM_MODE_LUT_REFLECT_NEGATIVE |
+				DRM_MODE_LUT_INTERPOLATE |
+				DRM_MODE_LUT_REUSE_LAST |
+				DRM_MODE_LUT_NON_DECREASING),
+		.count = 1,
+		.input_bpc = 24, .output_bpc = 16,
+		.start = 3 << 24, .end = 7 << 24,
+		.min = 0, .max = (1 << 27) - 1,
+	}
+};
+
+/* FIXME input bpc? */
+static const struct drm_color_lut_range xelpd_gamma_hdr[] = {
+	/*
+	 * ToDo: Add Segment 1
+	 * There is an optional fine segment added with 9 lut values
+	 * Will be added later
+	 */
+
+	/* segment 2 */
+	{
+		.flags = (DRM_MODE_LUT_REFLECT_NEGATIVE |
+				DRM_MODE_LUT_INTERPOLATE |
+				DRM_MODE_LUT_NON_DECREASING),
+		.count = 32,
+		.input_bpc = 24, .output_bpc = 16,
+		.start = 0, .end = (1 << 24) - 1,
+		.min = 0, .max = (1 << 24) - 1,
+	},
+	/* segment 3 */
+	{
+		.flags = (DRM_MODE_LUT_REFLECT_NEGATIVE |
+				DRM_MODE_LUT_INTERPOLATE |
+				DRM_MODE_LUT_REUSE_LAST |
+				DRM_MODE_LUT_NON_DECREASING),
+		.count = 1,
+		.input_bpc = 24, .output_bpc = 16,
+		.start = (1 << 24) - 1, .end = 1 << 24,
+		.min = 0, .max = 1 << 24,
+	},
+	/* Segment 4 */
+	{
+		.flags = (DRM_MODE_LUT_REFLECT_NEGATIVE |
+				DRM_MODE_LUT_INTERPOLATE |
+				DRM_MODE_LUT_REUSE_LAST |
+				DRM_MODE_LUT_NON_DECREASING),
+		.count = 1,
+		.input_bpc = 24, .output_bpc = 16,
+		.start = 1 << 24, .end = 3 << 24,
+		.min = 0, .max = (3 << 24),
+	},
+	/* Segment 5 */
+	{
+		.flags = (DRM_MODE_LUT_REFLECT_NEGATIVE |
+				DRM_MODE_LUT_INTERPOLATE |
+				DRM_MODE_LUT_REUSE_LAST |
+				DRM_MODE_LUT_NON_DECREASING),

drivers/gpu/drm/i915/display/intel_color.c static const struct intel_color_funcs ilk_color_funcs = {

Quoted 10 lines
drivers/gpu/drm/i915/display/intel_color.c +8 -0
+		.count = 1,
+		.input_bpc = 24, .output_bpc = 16,
+		.start = 3 << 24, .end = 7 << 24,
+		.min = 0, .max = (7 << 24),
+	},
+};
+
 /* TODO: Move to another file */
 struct intel_plane_colorop *intel_colorop_alloc(void)  { @@ -3865,6
+3964,11 @@ int intel_plane_tf_pipeline_init(struct drm_plane *plane, struct  

drm_prop_enum_l

drivers/gpu/drm/i915/display/intel_color.c int intel_plane_tf_pipeline_init(struct drm_plane *plane, struct drm_prop_enum_l

Quoted 5 lines
drivers/gpu/drm/i915/display/intel_color.c +2 -0
 	if (ret)
 		return ret;
 
+	if (icl_is_hdr_plane(i915, to_intel_plane(plane)->id)) {
+		drm_colorop_lutcaps_init(&colorop->base, plane,  

xelpd_degamma_hdr,

drivers/gpu/drm/i915/display/intel_color.c int intel_plane_tf_pipeline_init(struct drm_plane

Quoted 8 lines
drivers/gpu/drm/i915/display/intel_color.c +3 -0
+					 sizeof(xelpd_degamma_hdr));
+	}
+
 	list->type = colorop->base.base.id;
 	list->name = kasprintf(GFP_KERNEL, "Color Pipeline %d",

colorop->base.base.id);

drivers/gpu/drm/i915/display/intel_color.c +0 -0
@@ -3886,6 +3990,11 @@ int intel_plane_tf_pipeline_init(struct drm_plane  

*plane, struct drm_prop_enum_l

drivers/gpu/drm/i915/display/intel_color.c int intel_plane_tf_pipeline_init(struct drm_plane *plane, struct drm_prop_enum_l

Quoted 5 lines
drivers/gpu/drm/i915/display/intel_color.c +2 -0
 	if (ret)
 		return ret;
 
+	if (icl_is_hdr_plane(i915, to_intel_plane(plane)->id)) {
+		drm_colorop_lutcaps_init(&colorop->base, plane,  

xelpd_gamma_hdr,

Quoted 6 lines
drivers/gpu/drm/i915/display/intel_color.c +3 -0
+					 sizeof(xelpd_gamma_hdr));
+	}
+
 	drm_colorop_set_next_property(prev_op, &colorop->base);
 
 	return 0;  
#32 lore raw

RE: [PATCH 17/28] drm/i915: Define segmented Lut and add capabilities to colorop

Quoted 98 lines

-----Original Message-----
From: Pekka Paalanen <[email protected]>
Sent: Wednesday, February 14, 2024 2:34 PM
To: Shankar, Uma <[email protected]>
Cc: [email protected]; [email protected]; dri- [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]
Subject: Re: [PATCH 17/28] drm/i915: Define segmented Lut and add capabilities to colorop

Quoted 56 lines · Uma
Quoted 50 lines

-----Original Message-----
From: dri-devel <[email protected]> On Behalf Of Pekka Paalanen
Sent: Tuesday, February 13, 2024 3:07 PM
To: Shankar, Uma <[email protected]>
Cc: [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]
Subject: Re: [PATCH 17/28] drm/i915: Define segmented Lut and add capabilities to colorop

drivers/gpu/drm/i915/display/intel_color.c static const struct intel_color_funcs

Quoted 16 lines · On Tue, 13 Feb 2024 12:18:24 +0530 Uma Shankar <[email protected]> wrote:

This defines the lut segments and create the color pipeline

Signed-off-by Chaitanya Kumar Borah

<[email protected]>

---
 drivers/gpu/drm/i915/display/intel_color.c | 109
+++++++++++++++++++++
 1 file changed, 109 insertions(+)
drivers/gpu/drm/i915/display/intel_color.c +0 -0
index e223edbe4c13..223cd1ff7291 100644
@@ -3811,6 +3811,105 @@ static const struct intel_color_funcs

ilk_color_funcs = {

drivers/gpu/drm/i915/display/intel_color.c static const struct intel_color_funcs ilk_color_funcs = { · line 3819

Quoted 9 lines
drivers/gpu/drm/i915/display/intel_color.c +6 -0
 	.get_config = ilk_get_config,
 };
 
+static const struct drm_color_lut_range xelpd_degamma_hdr[] = {
+	/* segment 1 */
+	{
+		.flags = (DRM_MODE_LUT_REFLECT_NEGATIVE |
+				DRM_MODE_LUT_INTERPOLATE |
+				DRM_MODE_LUT_NON_DECREASING),

Hi Uma,

Quoted 5 lines

is it a good idea to have these flags per-segment?

I would find it very strange, unusable really, if REFLECT_NEGATIVE applied on some but not all segments, for example. Is such flexibility really necessary in the hardware description?

Quoted 7 lines

Hi Pekka,
Idea to have these flags is to just have some option in case there are some differences across segments. Most cases this should not be the case, just helps to future proof the implementation.

Based on how the community feels on the usability of it, we can take a call on the flags and the expected interpretation for the same. We are open for

suggestions on the same.

Quoted 7 lines
Quoted 6 lines

drivers/gpu/drm/i915/display/intel_color.c static const struct intel_color_funcs · line 3821

Quoted 4 lines
drivers/gpu/drm/i915/display/intel_color.c +2 -0
+		.count = 128,
+		.input_bpc = 24, .output_bpc = 16,

The same question about input_bpc and output_bpc.

Quoted 6 lines

Same for these as well, userspace can just ignore these if no usage. However, for some clients it may help in Lut computations. The original idea for the structure came from Ville (missed to mention that in cover letter, will get that updated in next version).

@[email protected] Please share your inputs on the usability of these

Quoted 8 lines

attributes.

Userspace will always need to evaluate whether each segment is good enough individually, so maybe it's not that big deal.

Ignoring these is not an option for userspace, because that would mean userspace does not know what it is getting. If UAPI contains a parameter, then the onus is on userspace to ensure the value is acceptable.

Got your point, the parameters, and expectations with it should be clearly defined. Here it just means what is the bpc which is fed to the color block and at what bpc results come out after rounding and truncation. This information may help in computing the LUT co-efficients and get better accuracy.

Having said that, we are not using it as of now in the IGT tests. We can discuss the usability and usefulness of this attribute for userspace, based on recommendation we can adopt or drop this.

Quoted 19 lines
Quoted 17 lines
Quoted 8 lines
Quoted 8 lines
drivers/gpu/drm/i915/display/intel_color.c +8 -0
+		.start = 0, .end = (1 << 24) - 1,
+		.min = 0, .max = (1 << 24) - 1,
+	},
+	/* segment 2 */
+	{
+		.flags = (DRM_MODE_LUT_REFLECT_NEGATIVE |
+				DRM_MODE_LUT_INTERPOLATE |
+				DRM_MODE_LUT_REUSE_LAST |
Quoted 8 lines

drivers/gpu/drm/i915/display/intel_color.c static const struct intel_color_funcs ilk_color_funcs = { · line 3833

Quoted 4 lines
drivers/gpu/drm/i915/display/intel_color.c +4 -0
+				DRM_MODE_LUT_NON_DECREASING),
+		.count = 1,
+		.input_bpc = 24, .output_bpc = 16,
+		.start = (1 << 24) - 1, .end = 1 << 24,

What if there is a gap or overlap between the previous segment .end and the next segment .start? Is it forbidden? Will the kernel common code verify that drivers don't make mistakes? Or IGT?

Quoted 2 lines

This is just to help give some reference to userspace. As of now, driver trusts the values coming from userspace if it sends wrong values its on

Quoted 8 lines

him and driver can't help much.

Quoted 1 line

However, we surely can have some sanity check like non decreasing luts etc. to

driver.

But what will guarantee that the driver provided values are consistent? That they actually describe a template of a well-formed sampled curve? If they are not consistent, userspace cannot use the colorop.
Whose responsibility is it to ensure the consistency?

Since the driver will be privileged, I guess userspace should believe the values are sane as reported by the properties. This is as for any other hardware capabilities. Also, its immutable so userspace will not be able to tweak it making it safe.

Quoted 3 lines

We have a few examples of drivers getting descriptive values like these simply wrong until DRM common code started sanity-checking them, the bitmasks of possible_clones and possible_crtcs for example.

We can implement some helpers to catch basic abnormalities with LUT reporting while property creation itself. Like decreasing luts, not matching the reported flags etc.

Quoted 6 lines

There should also be DRM common code to verify that userspace provided data matches the segmented LUT description rather than drivers just trusting it. If it doesn't match, the atomic commit must fail rather than silently malfunction. The same with programming hardware: if hardware does not produce the intended result from a given segmented LUT configuration, the atomic commit must fail instead of malfunction.

Yes, we can have some checks in driver for sanity of userspace provided values. Things like LUTs not following the flags and capabilities reported, going beyond the range etc. However the actual values and computation of the same has to be userspace responsibility, if the co-efficients go wrong then responsibility of the artifact should be on the client/compositor who is controlling it (permission can be controlled so that only allowed userspace can be able to change color setttings)

Quoted 7 lines
Quoted 3 lines

Ideally LUT values should not overlap, but we can indicate this explicitly with flag to hint the userspace (for overlap or otherwise) and also get

a check in driver for the same.

Sorry? How could overlapping segments ever work? Or segments with a gap between them?

I have not seen overlapping luts in segments, we can take a call if all vendors align.

Quoted 4 lines

If segments overlap, what's the rule for choosing which segment to use for an input value hitting both? The segments can disagree on the result.

If there are gaps, what is the rule how to handle an input value hitting a gap?

This can be brainstormed, if any usescase like this exists.

Regards,
Uma Shankar

Quoted 126 lines

Thanks,
pq

Quoted 122 lines

Regards,
Uma Shankar

Quoted 117 lines

Thanks,
pq

Quoted 74 lines
drivers/gpu/drm/i915/display/intel_color.c +74 -0
+		.min = 0, .max = (1 << 27) - 1,
+	},
+	/* Segment 3 */
+	{
+		.flags = (DRM_MODE_LUT_REFLECT_NEGATIVE |
+				DRM_MODE_LUT_INTERPOLATE |
+				DRM_MODE_LUT_REUSE_LAST |
+				DRM_MODE_LUT_NON_DECREASING),
+		.count = 1,
+		.input_bpc = 24, .output_bpc = 16,
+		.start = 1 << 24, .end = 3 << 24,
+		.min = 0, .max = (1 << 27) - 1,
+	},
+	/* Segment 4 */
+	{
+		.flags = (DRM_MODE_LUT_REFLECT_NEGATIVE |
+				DRM_MODE_LUT_INTERPOLATE |
+				DRM_MODE_LUT_REUSE_LAST |
+				DRM_MODE_LUT_NON_DECREASING),
+		.count = 1,
+		.input_bpc = 24, .output_bpc = 16,
+		.start = 3 << 24, .end = 7 << 24,
+		.min = 0, .max = (1 << 27) - 1,
+	}
+};
+
+/* FIXME input bpc? */
+static const struct drm_color_lut_range xelpd_gamma_hdr[] = {
+	/*
+	 * ToDo: Add Segment 1
+	 * There is an optional fine segment added with 9 lut values
+	 * Will be added later
+	 */
+
+	/* segment 2 */
+	{
+		.flags = (DRM_MODE_LUT_REFLECT_NEGATIVE |
+				DRM_MODE_LUT_INTERPOLATE |
+				DRM_MODE_LUT_NON_DECREASING),
+		.count = 32,
+		.input_bpc = 24, .output_bpc = 16,
+		.start = 0, .end = (1 << 24) - 1,
+		.min = 0, .max = (1 << 24) - 1,
+	},
+	/* segment 3 */
+	{
+		.flags = (DRM_MODE_LUT_REFLECT_NEGATIVE |
+				DRM_MODE_LUT_INTERPOLATE |
+				DRM_MODE_LUT_REUSE_LAST |
+				DRM_MODE_LUT_NON_DECREASING),
+		.count = 1,
+		.input_bpc = 24, .output_bpc = 16,
+		.start = (1 << 24) - 1, .end = 1 << 24,
+		.min = 0, .max = 1 << 24,
+	},
+	/* Segment 4 */
+	{
+		.flags = (DRM_MODE_LUT_REFLECT_NEGATIVE |
+				DRM_MODE_LUT_INTERPOLATE |
+				DRM_MODE_LUT_REUSE_LAST |
+				DRM_MODE_LUT_NON_DECREASING),
+		.count = 1,
+		.input_bpc = 24, .output_bpc = 16,
+		.start = 1 << 24, .end = 3 << 24,
+		.min = 0, .max = (3 << 24),
+	},
+	/* Segment 5 */
+	{
+		.flags = (DRM_MODE_LUT_REFLECT_NEGATIVE |
+				DRM_MODE_LUT_INTERPOLATE |
+				DRM_MODE_LUT_REUSE_LAST |
+				DRM_MODE_LUT_NON_DECREASING),
+		.count = 1,
+		.input_bpc = 24, .output_bpc = 16,

drivers/gpu/drm/i915/display/intel_color.c static const struct intel_color_funcs ilk_color_funcs = {

Quoted 10 lines
drivers/gpu/drm/i915/display/intel_color.c +7 -1
+		.start = 3 << 24, .end = 7 << 24,
+		.min = 0, .max = (7 << 24),
+	},
+};
+
 /* TODO: Move to another file */
 struct intel_plane_colorop *intel_colorop_alloc(void)  { @@
-3865,6
+3964,11 @@ int intel_plane_tf_pipeline_init(struct drm_plane
+*plane, struct

drm_prop_enum_l

drivers/gpu/drm/i915/display/intel_color.c int intel_plane_tf_pipeline_init(struct drm_plane *plane, struct drm_prop_enum_l

Quoted 5 lines
drivers/gpu/drm/i915/display/intel_color.c +2 -0
 	if (ret)
 		return ret;
 
+	if (icl_is_hdr_plane(i915, to_intel_plane(plane)->id)) {
+		drm_colorop_lutcaps_init(&colorop->base, plane,

xelpd_degamma_hdr,

Quoted 9 lines
drivers/gpu/drm/i915/display/intel_color.c +3 -0
+					 sizeof(xelpd_degamma_hdr));
+	}
+
 	list->type = colorop->base.base.id;
 	list->name = kasprintf(GFP_KERNEL, "Color Pipeline %d",

colorop->base.base.id);

drivers/gpu/drm/i915/display/intel_color.c +0 -0
@@ -3886,6 +3990,11 @@ int intel_plane_tf_pipeline_init(struct

drm_plane

*plane, struct drm_prop_enum_l

drivers/gpu/drm/i915/display/intel_color.c int intel_plane_tf_pipeline_init(struct drm_plane *plane, struct drm_prop_enum_l

Quoted 5 lines
drivers/gpu/drm/i915/display/intel_color.c +2 -0
 	if (ret)
 		return ret;
 
+	if (icl_is_hdr_plane(i915, to_intel_plane(plane)->id)) {
+		drm_colorop_lutcaps_init(&colorop->base, plane,

xelpd_gamma_hdr,

Quoted 6 lines
drivers/gpu/drm/i915/display/intel_color.c +3 -0
+					 sizeof(xelpd_gamma_hdr));
+	}
+
 	drm_colorop_set_next_property(prev_op, &colorop->base);
 
 	return 0;
#33 lore raw

Re: [PATCH 17/28] drm/i915: Define segmented Lut and add capabilities to colorop

Quoted 105 lines · Uma
Quoted 96 lines

-----Original Message-----
From: Pekka Paalanen <[email protected]>
Sent: Wednesday, February 14, 2024 2:34 PM
To: Shankar, Uma <[email protected]>
Cc: [email protected]; [email protected]; dri- [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]
Subject: Re: [PATCH 17/28] drm/i915: Define segmented Lut and add capabilities to colorop

Quoted 56 lines · Uma
Quoted 50 lines

-----Original Message-----
From: dri-devel <[email protected]> On Behalf Of Pekka Paalanen
Sent: Tuesday, February 13, 2024 3:07 PM
To: Shankar, Uma <[email protected]>
Cc: [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]
Subject: Re: [PATCH 17/28] drm/i915: Define segmented Lut and add capabilities to colorop

drivers/gpu/drm/i915/display/intel_color.c static const struct intel_color_funcs

Quoted 16 lines · On Tue, 13 Feb 2024 12:18:24 +0530 Uma Shankar <[email protected]> wrote:

This defines the lut segments and create the color pipeline

Signed-off-by Chaitanya Kumar Borah

<[email protected]>

---
 drivers/gpu/drm/i915/display/intel_color.c | 109
+++++++++++++++++++++
 1 file changed, 109 insertions(+)
drivers/gpu/drm/i915/display/intel_color.c +0 -0
index e223edbe4c13..223cd1ff7291 100644
@@ -3811,6 +3811,105 @@ static const struct intel_color_funcs  

ilk_color_funcs = {

drivers/gpu/drm/i915/display/intel_color.c static const struct intel_color_funcs ilk_color_funcs = { · line 3819

Quoted 9 lines
drivers/gpu/drm/i915/display/intel_color.c +6 -0
 	.get_config = ilk_get_config,
 };
 
+static const struct drm_color_lut_range xelpd_degamma_hdr[] = {
+	/* segment 1 */
+	{
+		.flags = (DRM_MODE_LUT_REFLECT_NEGATIVE |
+				DRM_MODE_LUT_INTERPOLATE |
+				DRM_MODE_LUT_NON_DECREASING),  

Hi Uma,

Quoted 5 lines

is it a good idea to have these flags per-segment?

I would find it very strange, unusable really, if REFLECT_NEGATIVE applied on some but not all segments, for example. Is such flexibility really necessary in the hardware description?

Quoted 7 lines

Hi Pekka,
Idea to have these flags is to just have some option in case there are some differences across segments. Most cases this should not be the case, just helps to future proof the implementation.

Based on how the community feels on the usability of it, we can take a call on the flags and the expected interpretation for the same. We are open for

suggestions on the same.

Quoted 7 lines
Quoted 6 lines

drivers/gpu/drm/i915/display/intel_color.c static const struct intel_color_funcs · line 3821

Quoted 4 lines
drivers/gpu/drm/i915/display/intel_color.c +2 -0
+		.count = 128,
+		.input_bpc = 24, .output_bpc = 16,  

The same question about input_bpc and output_bpc.

Quoted 6 lines

Same for these as well, userspace can just ignore these if no usage. However, for some clients it may help in Lut computations. The original idea for the structure came from Ville (missed to mention that in cover letter, will get that updated in next version).

@[email protected] Please share your inputs on the usability of these

Quoted 8 lines

attributes.

Userspace will always need to evaluate whether each segment is good enough individually, so maybe it's not that big deal.

Ignoring these is not an option for userspace, because that would mean userspace does not know what it is getting. If UAPI contains a parameter, then the onus is on userspace to ensure the value is acceptable.

Quoted 8 lines

Got your point, the parameters, and expectations with it should be clearly defined. Here it just means what is the bpc which is fed to the color block and at what bpc results come out after rounding and truncation. This information may help in computing the LUT co-efficients and get better accuracy.

Having said that, we are not using it as of now in the IGT tests. We can discuss the usability and usefulness of this attribute for userspace, based on recommendation we can adopt or drop this.

Hi Uma,

this discussion applies much more to the flags than bpc.

Bpc is interesting to userspace, so I do think it should be kept, and extended to all colorops as possible.

Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines

drivers/gpu/drm/i915/display/intel_color.c static const struct intel_color_funcs ilk_color_funcs = { · line 3823

Quoted 3 lines
drivers/gpu/drm/i915/display/intel_color.c +3 -0
+		.input_bpc = 24, .output_bpc = 16,  
+		.start = 0, .end = (1 << 24) - 1,
+		.min = 0, .max = (1 << 24) - 1,

Btw. does this say, that normalized input value range is [0.0, 1.0], and output values must be in [0.0, 256.0]?

That the divisor is (1 << bpc) - 1, and not (1 << bpc)?

Quoted 21 lines
Quoted 21 lines
Quoted 15 lines
Quoted 6 lines
Quoted 6 lines
drivers/gpu/drm/i915/display/intel_color.c +6 -0
+	},
+	/* segment 2 */
+	{
+		.flags = (DRM_MODE_LUT_REFLECT_NEGATIVE |
+				DRM_MODE_LUT_INTERPOLATE |
+				DRM_MODE_LUT_REUSE_LAST |
Quoted 8 lines

drivers/gpu/drm/i915/display/intel_color.c static const struct intel_color_funcs ilk_color_funcs = { · line 3833

Quoted 4 lines
drivers/gpu/drm/i915/display/intel_color.c +4 -0
+				DRM_MODE_LUT_NON_DECREASING),
+		.count = 1,
+		.input_bpc = 24, .output_bpc = 16,
+		.start = (1 << 24) - 1, .end = 1 << 24,  

What if there is a gap or overlap between the previous segment .end and the next segment .start? Is it forbidden? Will the kernel common code verify that drivers don't make mistakes? Or IGT?

Quoted 2 lines

This is just to help give some reference to userspace. As of now, driver trusts the values coming from userspace if it sends wrong values its on

him and driver can't help much.

Quoted 1 line

However, we surely can have some sanity check like non decreasing luts etc. to

driver.

Quoted 8 lines
Quoted 4 lines

But what will guarantee that the driver provided values are consistent? That they actually describe a template of a well-formed sampled curve? If they are not consistent, userspace cannot use the colorop.
Whose responsibility is it to ensure the consistency?

Since the driver will be privileged, I guess userspace should believe the values are sane as reported by the properties. This is as for any other hardware capabilities. Also, its immutable so userspace will not be able to tweak it making it safe.

It is still possible for the driver to give an utter nonsense blob. Where should be the tests to prevent that, in IGT or DRM core?

Quoted 6 lines
Quoted 3 lines

We have a few examples of drivers getting descriptive values like these simply wrong until DRM common code started sanity-checking them, the bitmasks of possible_clones and possible_crtcs for example.

We can implement some helpers to catch basic abnormalities with LUT reporting while property creation itself. Like decreasing luts, not matching the reported flags etc.

I really meant *drivers* getting the *advertisement* values wrong. Claiming that a connector/encoder is compatible with CRTC index 17 when such CRTC does not exist is a real example. Or that all connectors can be clones with all other connectors, even those that do not exist.

In the case of segmented LUTs, there could be these mistakes for a two-segment { A, B } description:
- segment A has REFLECT_NEGATIVE, but segment B does not
- segment B normalised start is smaller than segment A normalised end
- there is a gap between segment A normalised end and segment B normalised start
- segment A normalised max is smaller than segment B normalised min
- segment sample count is zero (or negative)
- segment max is smaller than segment min

And so on. Something needs to check for these and catch these, before a driver with them is released or even merged.

Think of it as reversed checks at UAPI boundary where a common component is checking that drivers get it right.

Quoted 8 lines
Quoted 7 lines

There should also be DRM common code to verify that userspace provided data matches the segmented LUT description rather than drivers just trusting it. If it doesn't match, the atomic commit must fail rather than silently malfunction. The same with programming hardware: if hardware does not produce the intended result from a given segmented LUT configuration, the atomic commit must fail instead of malfunction.

Quoted 6 lines

Yes, we can have some checks in driver for sanity of userspace provided values. Things like LUTs not following the flags and capabilities reported, going beyond the range etc. However the actual values and computation of the same has to be userspace responsibility, if the co-efficients go wrong then responsibility of the artifact should be on the client/compositor who is controlling it (permission can be controlled so that only allowed userspace can be able to change color setttings)

Naturally. A driver cannot know if the values are correct for what userspace intends to do, but the DRM core can check that the values fit the segmented LUT description that the driver advertised.

Permission? Permissions are already controlled by the DRM master mechanic.

Quoted 8 lines
Quoted 7 lines
Quoted 3 lines

Ideally LUT values should not overlap, but we can indicate this explicitly with flag to hint the userspace (for overlap or otherwise) and also get

a check in driver for the same.

Sorry? How could overlapping segments ever work? Or segments with a gap between them?

Quoted 8 lines

I have not seen overlapping luts in segments, we can take a call if all vendors align.

Quoted 4 lines

If segments overlap, what's the rule for choosing which segment to use for an input value hitting both? The segments can disagree on the result.

If there are gaps, what is the rule how to handle an input value hitting a gap?

This can be brainstormed, if any usescase like this exists.

These questions were supposed to make you think and realise that overlapping/gapped segments make absolutely no sense at all by pointing out the problems they would cause as an interface description.

Even if hardware had literally overlapping segments, then the driver should advertise non-overlapping segments that match what the hardware will achieve.

If hardware had literally gaps between segments, then... either the hardware cannot be fully used, or the driver will manufacture a description without gaps that matches hardware behaviour.

Thanks,
pq

#34 lore raw

PATCH 18/28 drm/i915/color: Add and attach COLORPIPELINE plane property

In reply to Uma Shankar

From: Chaitanya Kumar Borah <[email protected]>

Add supported color pipelines and attach it to plane.

---
 drivers/gpu/drm/i915/display/intel_color.c | 37 ++++++++++++++++++++++
 drivers/gpu/drm/i915/display/intel_color.h |  3 ++
 2 files changed, 40 insertions(+)
drivers/gpu/drm/i915/display/intel_color.c +37 -0
index 223cd1ff7291..d6d5e56b4f2c 100644
@@ -4000,6 +4000,43 @@ int intel_plane_tf_pipeline_init(struct drm_plane *plane, struct drm_prop_enum_l
 	return 0;
 }
 
+int intel_plane_color_init(struct drm_plane *plane)
+{
+	struct drm_device *dev = plane->dev;
+	struct drm_property *prop;
+	struct drm_prop_enum_list pipelines[MAX_COLOR_PIPELINES];
+	int len = 0;
+	int ret;
+
+	/* Add "Bypass" (i.e. NULL) pipeline */
+	pipelines[len].type = 0;
+	pipelines[len].name = "Bypass";
+	len++;
+
+	/* Add pipeline consisting of transfer functions */
+	ret = intel_plane_tf_pipeline_init(plane, &pipelines[len]);
+	if (ret)
+		return ret;
+	len++;
+
+	/* Create COLOR_PIPELINE property and attach */
+	prop = drm_property_create_enum(dev, DRM_MODE_PROP_ATOMIC,
+					"COLOR_PIPELINE",
+					pipelines, len);
+	if (!prop)
+		return -ENOMEM;
+
+	plane->color_pipeline_property = prop;
+
+	drm_object_attach_property(&plane->base, prop, 0);
+
+	/* TODO check if needed */
+	if (plane->state)
+		plane->state->color_pipeline = NULL;
+
+	return 0;
+}
+
 void intel_color_crtc_init(struct intel_crtc *crtc)
 {
 	struct drm_i915_private *i915 = to_i915(crtc->base.dev);
drivers/gpu/drm/i915/display/intel_color.h +3 -0
index e0b75dcb1b65..df0e1f6be067 100644
@@ -16,6 +16,8 @@ struct drm_plane;
 struct drm_prop_enum_list;
 enum intel_color_block;
 
+#define MAX_COLOR_PIPELINES 5
+
 void intel_color_init_hooks(struct drm_i915_private *i915);
 int intel_color_init(struct drm_i915_private *i915);
 void intel_color_crtc_init(struct intel_crtc *crtc);
@@ -37,5 +39,6 @@ void intel_color_assert_luts(const struct intel_crtc_state *crtc_state);
 struct intel_plane_colorop *intel_colorop_alloc(void);
 struct intel_plane_colorop *intel_plane_colorop_create(enum intel_color_block id);
 int intel_plane_tf_pipeline_init(struct drm_plane *plane, struct drm_prop_enum_list *list);
+int intel_plane_color_init(struct drm_plane *plane);
 
 #endif /* __INTEL_COLOR_H__ */
Signature · 1 line
2.42.0
#35 lore raw

PATCH 19/28 drm/i915/color: Add framework to set colorop

In reply to Uma Shankar

From: Chaitanya Kumar Borah <[email protected]>

Add infrastructure to set colorop. We iterate through all the color ops in a selected COLOR PIPELINE and set them one by one.

---
 drivers/gpu/drm/i915/display/intel_color.c | 31 ++++++++++++++++++++++
 drivers/gpu/drm/i915/display/intel_color.h |  3 +++
 2 files changed, 34 insertions(+)
drivers/gpu/drm/i915/display/intel_color.c +31 -0
index d6d5e56b4f2c..06268e89125e 100644
@@ -3949,6 +3949,37 @@ struct intel_plane_colorop *intel_plane_colorop_create(enum intel_color_block id
 	return colorop;
 }
 
+static void apply_colorop(const struct drm_plane_state *plane_state,
+			  struct drm_colorop *colorop,
+			  u32 *plane_color_ctl)
+{
+}
+
+void intel_program_pipeline(const struct drm_plane_state *plane_state, u32 *plane_color_ctl)
+{
+	struct drm_colorop *colorop;
+
+	colorop = plane_state->color_pipeline;
+
+	while (colorop) {
+		struct drm_colorop_state *colorop_state;
+
+		if (!colorop)
+			return;
+
+		/* TODO this is probably wrong */
+		colorop_state = colorop->state;
+
+		if (!colorop_state)
+			return;
+
+		if (!colorop_state->bypass)
+			apply_colorop(plane_state, colorop, plane_color_ctl);
+
+		colorop = colorop->next;
+	}
+}
+
 int intel_plane_tf_pipeline_init(struct drm_plane *plane, struct drm_prop_enum_list *list)
 {
 	struct intel_plane *intel_plane = to_intel_plane(plane);
drivers/gpu/drm/i915/display/intel_color.h +3 -0
index df0e1f6be067..bde880370ecc 100644
@@ -13,6 +13,7 @@ struct intel_crtc;
 struct drm_i915_private;
 struct drm_property_blob;
 struct drm_plane;
+struct drm_plane_state;
 struct drm_prop_enum_list;
 enum intel_color_block;
 
@@ -40,5 +41,7 @@ struct intel_plane_colorop *intel_colorop_alloc(void);
 struct intel_plane_colorop *intel_plane_colorop_create(enum intel_color_block id);
 int intel_plane_tf_pipeline_init(struct drm_plane *plane, struct drm_prop_enum_list *list);
 int intel_plane_color_init(struct drm_plane *plane);
+void intel_program_pipeline(const struct drm_plane_state *plane_state,
+			    u32 *plane_color_ctl);
 
 #endif /* __INTEL_COLOR_H__ */
Signature · 1 line
2.42.0
#36 lore raw

PATCH 20/28 drm/i915/color: Add callbacks to set plane CTM

In reply to Uma Shankar

From: Chaitanya Kumar Borah <[email protected]>

Add callback to intel color functions for setting plane CTM.

---
 drivers/gpu/drm/i915/display/intel_color.c | 22 ++++++++++++++++++++++
 drivers/gpu/drm/i915/display/intel_color.h |  2 ++
 2 files changed, 24 insertions(+)
drivers/gpu/drm/i915/display/intel_color.c +22 -0
index 06268e89125e..8dc72ad25700 100644
@@ -81,6 +81,10 @@ struct intel_color_funcs {
 	 * Read config other than LUTs and CSCs, before them. Optional.
 	 */
 	void (*get_config)(struct intel_crtc_state *crtc_state);
+
+	/* Plane CSC*/
+	void (*load_plane_csc_matrix)(const struct drm_plane_state *plane_state,
+				      const struct drm_property_blob *blob);
 };
 
 #define CTM_COEFF_SIGN	(1ULL << 63)
@@ -3684,6 +3688,15 @@ static void icl_read_luts(struct intel_crtc_state *crtc_state)
 	}
 }
 
+void intel_color_load_plane_csc_matrix(const struct drm_plane_state *plane_state,
+				       const struct drm_property_blob *blob)
+{
+	struct drm_i915_private *i915 = to_i915(plane_state->plane->dev);
+
+	if (i915->display.funcs.color->load_plane_csc_matrix)
+		i915->display.funcs.color->load_plane_csc_matrix(plane_state, blob);
+}
+
 static const struct intel_color_funcs chv_color_funcs = {
 	.color_check = chv_color_check,
 	.color_commit_arm = i9xx_color_commit_arm,
@@ -3953,6 +3966,15 @@ static void apply_colorop(const struct drm_plane_state *plane_state,
 			  struct drm_colorop *colorop,
 			  u32 *plane_color_ctl)
 {
+	struct drm_colorop_state *state = colorop->state;
+	struct intel_plane_colorop *intel_colorop = to_intel_plane_colorop(colorop);
+
+	if (colorop->type == DRM_COLOROP_CTM_3X3) {
+		/* TODO: use intel_color_op state data */
+		(*plane_color_ctl) |= PLANE_COLOR_PLANE_CSC_ENABLE;
+		if (state->data && intel_colorop->id == CB_PLANE_CSC)
+			intel_color_load_plane_csc_matrix(plane_state, state->data);
+	}
 }
 
 void intel_program_pipeline(const struct drm_plane_state *plane_state, u32 *plane_color_ctl)
drivers/gpu/drm/i915/display/intel_color.h +2 -0
index bde880370ecc..3f1466f88c11 100644
@@ -43,5 +43,7 @@ int intel_plane_tf_pipeline_init(struct drm_plane *plane, struct drm_prop_enum_l
 int intel_plane_color_init(struct drm_plane *plane);
 void intel_program_pipeline(const struct drm_plane_state *plane_state,
 			    u32 *plane_color_ctl);
+void intel_color_load_plane_csc_matrix(const struct drm_plane_state *plane_state,
+				       const struct drm_property_blob *blob);
 
 #endif /* __INTEL_COLOR_H__ */
Signature · 1 line
2.42.0
#37 lore raw

PATCH 21/28 drm/i915/color: Add plane CTM callback for TGL and beyond

In reply to Uma Shankar

Add callback for setting CTM block in platforms TGL and beyond

---
 drivers/gpu/drm/i915/display/intel_color.c | 79 ++++++++++++++++++++++
 1 file changed, 79 insertions(+)
drivers/gpu/drm/i915/display/intel_color.c +79 -0
index 8dc72ad25700..85c4b6a9d5f9 100644
@@ -3688,6 +3688,84 @@ static void icl_read_luts(struct intel_crtc_state *crtc_state)
 	}
 }
 
+static void xelpd_load_plane_csc_matrix(const struct drm_plane_state *state,
+					const struct drm_property_blob *blob)
+{
+	struct drm_i915_private *dev_priv = to_i915(state->plane->dev);
+	enum pipe pipe = to_intel_plane(state->plane)->pipe;
+	enum plane_id plane = to_intel_plane(state->plane)->id;
+	struct drm_color_ctm *ctm;
+	const u64 *input;
+	u16 coeffs[9] = {};
+	u16 postoff = 0;
+	int i;
+
+	if (!icl_is_hdr_plane(dev_priv, plane) || !blob)
+		return;
+
+	ctm = blob->data;
+	input = ctm->matrix;
+
+	/*
+	 * Convert fixed point S31.32 input to format supported by the
+	 * hardware.
+	 */
+	for (i = 0; i < ARRAY_SIZE(coeffs); i++) {
+		u64 abs_coeff = ((1ULL << 63) - 1) & input[i];
+
+		/*
+		 * Clamp input value to min/max supported by
+		 * hardware.
+		 */
+		abs_coeff = clamp_val(abs_coeff, 0, CTM_COEFF_4_0 - 1);
+
+		/* sign bit */
+		if (CTM_COEFF_NEGATIVE(input[i]))
+			coeffs[i] |= 1 << 15;
+
+		if (abs_coeff < CTM_COEFF_0_125)
+			coeffs[i] |= (3 << 12) |
+				ILK_CSC_COEFF_FP(abs_coeff, 12);
+		else if (abs_coeff < CTM_COEFF_0_25)
+			coeffs[i] |= (2 << 12) |
+				ILK_CSC_COEFF_FP(abs_coeff, 11);
+		else if (abs_coeff < CTM_COEFF_0_5)
+			coeffs[i] |= (1 << 12) |
+				ILK_CSC_COEFF_FP(abs_coeff, 10);
+		else if (abs_coeff < CTM_COEFF_1_0)
+			coeffs[i] |= ILK_CSC_COEFF_FP(abs_coeff, 9);
+		else if (abs_coeff < CTM_COEFF_2_0)
+			coeffs[i] |= (7 << 12) |
+				ILK_CSC_COEFF_FP(abs_coeff, 8);
+		else
+			coeffs[i] |= (6 << 12) |
+				ILK_CSC_COEFF_FP(abs_coeff, 7);
+	}
+
+	intel_de_write_fw(dev_priv, PLANE_CSC_COEFF(pipe, plane, 0),
+			  coeffs[0] << 16 | coeffs[1]);
+	intel_de_write_fw(dev_priv, PLANE_CSC_COEFF(pipe, plane, 1),
+			  coeffs[2] << 16);
+
+	intel_de_write_fw(dev_priv, PLANE_CSC_COEFF(pipe, plane, 2),
+			  coeffs[3] << 16 | coeffs[4]);
+	intel_de_write_fw(dev_priv, PLANE_CSC_COEFF(pipe, plane, 3),
+			  coeffs[5] << 16);
+
+	intel_de_write_fw(dev_priv, PLANE_CSC_COEFF(pipe, plane, 4),
+			  coeffs[6] << 16 | coeffs[7]);
+	intel_de_write_fw(dev_priv, PLANE_CSC_COEFF(pipe, plane, 5),
+			  coeffs[8] << 16);
+
+	intel_de_write_fw(dev_priv, PLANE_CSC_PREOFF(pipe, plane, 0), 0);
+	intel_de_write_fw(dev_priv, PLANE_CSC_PREOFF(pipe, plane, 1), 0);
+	intel_de_write_fw(dev_priv, PLANE_CSC_PREOFF(pipe, plane, 2), 0);
+
+	intel_de_write_fw(dev_priv, PLANE_CSC_POSTOFF(pipe, plane, 0), postoff);
+	intel_de_write_fw(dev_priv, PLANE_CSC_POSTOFF(pipe, plane, 1), postoff);
+	intel_de_write_fw(dev_priv, PLANE_CSC_POSTOFF(pipe, plane, 2), postoff);
+}
+
 void intel_color_load_plane_csc_matrix(const struct drm_plane_state *plane_state,
 				       const struct drm_property_blob *blob)
 {
@@ -3744,6 +3822,7 @@ static const struct intel_color_funcs tgl_color_funcs = {
 	.lut_equal = icl_lut_equal,
 	.read_csc = icl_read_csc,
 	.get_config = skl_get_config,
+	.load_plane_csc_matrix = xelpd_load_plane_csc_matrix,
 };
 
 static const struct intel_color_funcs icl_color_funcs = {
Signature · 1 line
2.42.0
#38 lore raw

PATCH 22/28 drm/i915: Add register definitions for Plane Degamma

In reply to Uma Shankar

Add macros to define Plane Degamma registers

---
 drivers/gpu/drm/i915/i915_reg.h | 51 +++++++++++++++++++++++++++++++++
 1 file changed, 51 insertions(+)
drivers/gpu/drm/i915/i915_reg.h +51 -0
index e00557e1a57f..633c0d0cb8f4 100644
@@ -3732,6 +3732,7 @@
 #define   PLANE_COLOR_CSC_MODE_YUV709_TO_RGB709		REG_FIELD_PREP(PLANE_COLOR_CSC_MODE_MASK, 2)
 #define   PLANE_COLOR_CSC_MODE_YUV2020_TO_RGB2020	REG_FIELD_PREP(PLANE_COLOR_CSC_MODE_MASK, 3)
 #define   PLANE_COLOR_CSC_MODE_RGB709_TO_RGB2020	REG_FIELD_PREP(PLANE_COLOR_CSC_MODE_MASK, 4)
+#define   PLANE_COLOR_PRE_CSC_GAMMA_ENABLE		REG_BIT(14)
 #define   PLANE_COLOR_PLANE_GAMMA_DISABLE		REG_BIT(13)
 #define   PLANE_COLOR_ALPHA_MASK			REG_GENMASK(5, 4)
 #define   PLANE_COLOR_ALPHA_DISABLE			REG_FIELD_PREP(PLANE_COLOR_ALPHA_MASK, 0)
@@ -6243,6 +6244,56 @@ enum skl_power_gate {
 
 #define _MMIO_PLANE_GAMC(plane, i, a, b)  _MMIO(_PIPE(plane, a, b) + (i) * 4)
 
+/* Display13 Plane Degmma Reg */
+#define _PLANE_PRE_CSC_GAMC_INDEX_ENH_1_A	0x701d0
+#define _PLANE_PRE_CSC_GAMC_INDEX_ENH_1_B	0x711d0
+#define _PLANE_PRE_CSC_GAMC_INDEX_ENH_2_A	0x702d0
+#define _PLANE_PRE_CSC_GAMC_INDEX_ENH_2_B	0x712d0
+#define _PLANE_PRE_CSC_GAMC_INDEX_ENH_1(pipe)	_PIPE(pipe, _PLANE_PRE_CSC_GAMC_INDEX_ENH_1_A, \
+						_PLANE_PRE_CSC_GAMC_INDEX_ENH_1_B)
+#define _PLANE_PRE_CSC_GAMC_INDEX_ENH_2(pipe)	_PIPE(pipe, _PLANE_PRE_CSC_GAMC_INDEX_ENH_2_A, \
+						_PLANE_PRE_CSC_GAMC_INDEX_ENH_2_B)
+#define PLANE_PRE_CSC_GAMC_INDEX_ENH(pipe, plane, i)	\
+		_MMIO_PLANE_GAMC(plane, i, _PLANE_PRE_CSC_GAMC_INDEX_ENH_1(pipe), \
+		_PLANE_PRE_CSC_GAMC_INDEX_ENH_2(pipe))
+#define	 PLANE_PAL_PREC_AUTO_INCREMENT		REG_BIT(10)
+
+#define _PLANE_PRE_CSC_GAMC_DATA_ENH_1_A	0x701d4
+#define _PLANE_PRE_CSC_GAMC_DATA_ENH_1_B	0x711d4
+#define _PLANE_PRE_CSC_GAMC_DATA_ENH_2_A	0x702d4
+#define _PLANE_PRE_CSC_GAMC_DATA_ENH_2_B	0x712d4
+#define _PLANE_PRE_CSC_GAMC_DATA_ENH_1(pipe)	_PIPE(pipe, _PLANE_PRE_CSC_GAMC_DATA_ENH_1_A, \
+						_PLANE_PRE_CSC_GAMC_DATA_ENH_1_B)
+#define _PLANE_PRE_CSC_GAMC_DATA_ENH_2(pipe)	_PIPE(pipe, _PLANE_PRE_CSC_GAMC_DATA_ENH_2_A, \
+						_PLANE_PRE_CSC_GAMC_DATA_ENH_2_B)
+#define PLANE_PRE_CSC_GAMC_DATA_ENH(pipe, plane, i)	\
+		_MMIO_PLANE_GAMC(plane, i, _PLANE_PRE_CSC_GAMC_DATA_ENH_1(pipe), \
+		_PLANE_PRE_CSC_GAMC_DATA_ENH_2(pipe))
+
+#define _PLANE_PRE_CSC_GAMC_INDEX_1_A	0x704d0
+#define _PLANE_PRE_CSC_GAMC_INDEX_1_B	0x714d0
+#define _PLANE_PRE_CSC_GAMC_INDEX_2_A	0x705d0
+#define _PLANE_PRE_CSC_GAMC_INDEX_2_B	0x715d0
+#define _PLANE_PRE_CSC_GAMC_INDEX_1(pipe)	_PIPE(pipe, _PLANE_PRE_CSC_GAMC_INDEX_1_A, \
+						_PLANE_PRE_CSC_GAMC_INDEX_1_B)
+#define _PLANE_PRE_CSC_GAMC_INDEX_2(pipe)	_PIPE(pipe, _PLANE_PRE_CSC_GAMC_INDEX_2_A, \
+						_PLANE_PRE_CSC_GAMC_INDEX_2_B)
+#define PLANE_PRE_CSC_GAMC_INDEX(pipe, plane, i)	\
+		_MMIO_PLANE_GAMC(plane, i, _PLANE_PRE_CSC_GAMC_INDEX_1(pipe), \
+		_PLANE_PRE_CSC_GAMC_INDEX_2(pipe))
+
+#define _PLANE_PRE_CSC_GAMC_DATA_1_A	0x704d4
+#define _PLANE_PRE_CSC_GAMC_DATA_1_B	0x714d4
+#define _PLANE_PRE_CSC_GAMC_DATA_2_A	0x705d4
+#define _PLANE_PRE_CSC_GAMC_DATA_2_B	0x715d4
+#define _PLANE_PRE_CSC_GAMC_DATA_1(pipe)	_PIPE(pipe, _PLANE_PRE_CSC_GAMC_DATA_1_A, \
+						_PLANE_PRE_CSC_GAMC_DATA_1_B)
+#define _PLANE_PRE_CSC_GAMC_DATA_2(pipe)	_PIPE(pipe, _PLANE_PRE_CSC_GAMC_DATA_2_A, \
+						_PLANE_PRE_CSC_GAMC_DATA_2_B)
+#define PLANE_PRE_CSC_GAMC_DATA(pipe, plane, i)	\
+		_MMIO_PLANE_GAMC(plane, i, _PLANE_PRE_CSC_GAMC_DATA_1(pipe), \
+		_PLANE_PRE_CSC_GAMC_DATA_2(pipe))
+
 /* Plane CSC Registers */
 #define _PLANE_CSC_RY_GY_1_A	0x70210
 #define _PLANE_CSC_RY_GY_2_A	0x70310
Signature · 1 line
2.42.0
#39 lore raw

PATCH 23/28 drm/i915/color: Add framework to program PRE/POST CSC LUT

In reply to Uma Shankar

From: Chaitanya Kumar Borah <[email protected]>

Add framework that will help in loading LUT to Pre/Post CSC color blocks.

---
 drivers/gpu/drm/i915/display/intel_color.c | 27 ++++++++++++++++++++++
 drivers/gpu/drm/i915/display/intel_color.h |  2 ++
 2 files changed, 29 insertions(+)
drivers/gpu/drm/i915/display/intel_color.c +27 -0
index 85c4b6a9d5f9..0d68f8303502 100644
@@ -85,6 +85,10 @@ struct intel_color_funcs {
 	/* Plane CSC*/
 	void (*load_plane_csc_matrix)(const struct drm_plane_state *plane_state,
 				      const struct drm_property_blob *blob);
+
+	/* Plane Pre/Post CSC */
+	void (*load_plane_luts)(const struct drm_plane_state *plane_state,
+				const struct drm_property_blob *blob, bool is_pre_csc);
 };
 
 #define CTM_COEFF_SIGN	(1ULL << 63)
@@ -3775,6 +3779,20 @@ void intel_color_load_plane_csc_matrix(const struct drm_plane_state *plane_state
 		i915->display.funcs.color->load_plane_csc_matrix(plane_state, blob);
 }
 
+static void xelpd_plane_load_luts(const struct drm_plane_state *plane_state,
+				  const struct drm_property_blob *blob, bool is_pre_csc)
+{
+}
+
+void intel_color_load_plane_luts(const struct drm_plane_state *plane_state,
+				 const struct drm_property_blob *blob, bool is_pre_csc)
+{
+	struct drm_i915_private *i915 = to_i915(plane_state->plane->dev);
+
+	if (i915->display.funcs.color->load_plane_luts)
+		i915->display.funcs.color->load_plane_luts(plane_state, blob, is_pre_csc);
+}
+
 static const struct intel_color_funcs chv_color_funcs = {
 	.color_check = chv_color_check,
 	.color_commit_arm = i9xx_color_commit_arm,
@@ -3823,6 +3841,7 @@ static const struct intel_color_funcs tgl_color_funcs = {
 	.read_csc = icl_read_csc,
 	.get_config = skl_get_config,
 	.load_plane_csc_matrix = xelpd_load_plane_csc_matrix,
+	.load_plane_luts = xelpd_plane_load_luts,
 };
 
 static const struct intel_color_funcs icl_color_funcs = {
@@ -4053,6 +4072,14 @@ static void apply_colorop(const struct drm_plane_state *plane_state,
 		(*plane_color_ctl) |= PLANE_COLOR_PLANE_CSC_ENABLE;
 		if (state->data && intel_colorop->id == CB_PLANE_CSC)
 			intel_color_load_plane_csc_matrix(plane_state, state->data);
+	} else if (colorop->type == DRM_COLOROP_1D_LUT) {
+		if (state->data && intel_colorop->id == CB_PLANE_PRE_CSC_LUT) {
+			(*plane_color_ctl) |= PLANE_COLOR_PRE_CSC_GAMMA_ENABLE;
+			intel_color_load_plane_luts(plane_state, state->data, true);
+		} else if (state->data && intel_colorop->id == CB_PLANE_POST_CSC_LUT) {
+			(*plane_color_ctl) &= ~PLANE_COLOR_PLANE_GAMMA_DISABLE;
+			intel_color_load_plane_luts(plane_state, state->data, false);
+		}
 	}
 }
 
drivers/gpu/drm/i915/display/intel_color.h +2 -0
index 3f1466f88c11..1830a85a696b 100644
@@ -45,5 +45,7 @@ void intel_program_pipeline(const struct drm_plane_state *plane_state,
 			    u32 *plane_color_ctl);
 void intel_color_load_plane_csc_matrix(const struct drm_plane_state *plane_state,
 				       const struct drm_property_blob *blob);
+void intel_color_load_plane_luts(const struct drm_plane_state *plane_state,
+				 const struct drm_property_blob *blob, bool is_pre_csc);
 
 #endif /* __INTEL_COLOR_H__ */
Signature · 1 line
2.42.0
#40 lore raw

PATCH 24/28 drm/i915: Add register definitions for Plane Post CSC

In reply to Uma Shankar

Add macros to define Plane Post CSC registers

---
 drivers/gpu/drm/i915/i915_reg.h | 73 +++++++++++++++++++++++++++++++++
 1 file changed, 73 insertions(+)
drivers/gpu/drm/i915/i915_reg.h +73 -0
index 633c0d0cb8f4..ea711be031e7 100644
@@ -6244,6 +6244,79 @@ enum skl_power_gate {
 
 #define _MMIO_PLANE_GAMC(plane, i, a, b)  _MMIO(_PIPE(plane, a, b) + (i) * 4)
 
+/* Display13 Plane Gamma Reg */
+#define _PLANE_POST_CSC_GAMC_SEG0_INDEX_ENH_1_A	0x70160
+#define _PLANE_POST_CSC_GAMC_SEG0_INDEX_ENH_1_B	0x71160
+#define _PLANE_POST_CSC_GAMC_SEG0_INDEX_ENH_2_A	0x70260
+#define _PLANE_POST_CSC_GAMC_SEG0_INDEX_ENH_2_B	0x71260
+#define _PLANE_POST_CSC_GAMC_SEG0_INDEX_ENH_1(pipe)	_PIPE(pipe, _PLANE_POST_CSC_GAMC_SEG0_INDEX_ENH_1_A, \
+							_PLANE_POST_CSC_GAMC_SEG0_INDEX_ENH_1_B)
+#define _PLANE_POST_CSC_GAMC_SEG0_INDEX_ENH_2(pipe)	_PIPE(pipe, _PLANE_POST_CSC_GAMC_SEG0_INDEX_ENH_2_A, \
+							_PLANE_POST_CSC_GAMC_SEG0_INDEX_ENH_2_B)
+#define PLANE_POST_CSC_GAMC_SEG0_INDEX_ENH(pipe, plane, i)	\
+		_MMIO_PLANE_GAMC(plane, i, _PLANE_POST_CSC_GAMC_SEG0_INDEX_ENH_1(pipe), \
+		_PLANE_POST_CSC_GAMC_SEG0_INDEX_ENH_2(pipe))
+
+#define _PLANE_POST_CSC_GAMC_SEG0_DATA_ENH_1_A	0x70164
+#define _PLANE_POST_CSC_GAMC_SEG0_DATA_ENH_1_B	0x71164
+#define _PLANE_POST_CSC_GAMC_SEG0_DATA_ENH_2_A	0x70264
+#define _PLANE_POST_CSC_GAMC_SEG0_DATA_ENH_2_B	0x71264
+#define _PLANE_POST_CSC_GAMC_SEG0_DATA_ENH_1(pipe)	_PIPE(pipe, _PLANE_POST_CSC_GAMC_SEG0_DATA_ENH_1_A, \
+							_PLANE_POST_CSC_GAMC_SEG0_DATA_ENH_1_B)
+#define _PLANE_POST_CSC_GAMC_SEG0_DATA_ENH_2(pipe)	_PIPE(pipe, _PLANE_POST_CSC_GAMC_SEG0_DATA_ENH_2_A, \
+							_PLANE_POST_CSC_GAMC_SEG0_DATA_ENH_2_B)
+#define PLANE_POST_CSC_GAMC_SEG0_DATA_ENH(pipe, plane, i)	\
+		_MMIO_PLANE_GAMC(plane, i, _PLANE_POST_CSC_GAMC_SEG0_DATA_ENH_1(pipe), \
+		_PLANE_POST_CSC_GAMC_SEG0_DATA_ENH_2(pipe))
+
+#define _PLANE_POST_CSC_GAMC_INDEX_ENH_1_A	0x701d8
+#define _PLANE_POST_CSC_GAMC_INDEX_ENH_1_B	0x711d8
+#define _PLANE_POST_CSC_GAMC_INDEX_ENH_2_A	0x702d8
+#define _PLANE_POST_CSC_GAMC_INDEX_ENH_2_B	0x712d8
+#define _PLANE_POST_CSC_GAMC_INDEX_ENH_1(pipe)	_PIPE(pipe, _PLANE_POST_CSC_GAMC_INDEX_ENH_1_A, \
+						_PLANE_POST_CSC_GAMC_INDEX_ENH_1_B)
+#define _PLANE_POST_CSC_GAMC_INDEX_ENH_2(pipe)	_PIPE(pipe, _PLANE_POST_CSC_GAMC_INDEX_ENH_2_A, \
+						_PLANE_POST_CSC_GAMC_INDEX_ENH_2_B)
+#define PLANE_POST_CSC_GAMC_INDEX_ENH(pipe, plane, i)	\
+		_MMIO_PLANE_GAMC(plane, i, _PLANE_POST_CSC_GAMC_INDEX_ENH_1(pipe), \
+		_PLANE_POST_CSC_GAMC_INDEX_ENH_2(pipe))
+
+#define _PLANE_POST_CSC_GAMC_DATA_ENH_1_A	0x701dc
+#define _PLANE_POST_CSC_GAMC_DATA_ENH_1_B	0x711dc
+#define _PLANE_POST_CSC_GAMC_DATA_ENH_2_A	0x702dc
+#define _PLANE_POST_CSC_GAMC_DATA_ENH_2_B	0x712dc
+#define _PLANE_POST_CSC_GAMC_DATA_ENH_1(pipe)	_PIPE(pipe, _PLANE_POST_CSC_GAMC_DATA_ENH_1_A, \
+						_PLANE_POST_CSC_GAMC_DATA_ENH_1_B)
+#define _PLANE_POST_CSC_GAMC_DATA_ENH_2(pipe)	_PIPE(pipe, _PLANE_POST_CSC_GAMC_DATA_ENH_2_A, \
+						_PLANE_POST_CSC_GAMC_DATA_ENH_2_B)
+#define PLANE_POST_CSC_GAMC_DATA_ENH(pipe, plane, i)	\
+		_MMIO_PLANE_GAMC(plane, i, _PLANE_POST_CSC_GAMC_DATA_ENH_1(pipe), \
+		_PLANE_POST_CSC_GAMC_DATA_ENH_2(pipe))
+
+#define _PLANE_POST_CSC_GAMC_INDEX_1_A	0x704d8
+#define _PLANE_POST_CSC_GAMC_INDEX_1_B	0x714d8
+#define _PLANE_POST_CSC_GAMC_INDEX_2_A	0x705d8
+#define _PLANE_POST_CSC_GAMC_INDEX_2_B	0x715d8
+#define _PLANE_POST_CSC_GAMC_INDEX_1(pipe)	_PIPE(pipe, _PLANE_POST_CSC_GAMC_INDEX_1_A, \
+						_PLANE_POST_CSC_GAMC_INDEX_1_B)
+#define _PLANE_POST_CSC_GAMC_INDEX_2(pipe)	_PIPE(pipe, _PLANE_POST_CSC_GAMC_INDEX_2_A, \
+						_PLANE_POST_CSC_GAMC_INDEX_2_B)
+#define PLANE_POST_CSC_GAMC_INDEX(pipe, plane, i)	\
+		_MMIO_PLANE_GAMC(plane, i, _PLANE_POST_CSC_GAMC_INDEX_1(pipe), \
+		_PLANE_POST_CSC_GAMC_INDEX_2(pipe))
+
+#define _PLANE_POST_CSC_GAMC_DATA_1_A	0x704dc
+#define _PLANE_POST_CSC_GAMC_DATA_1_B	0x714dc
+#define _PLANE_POST_CSC_GAMC_DATA_2_A	0x705dc
+#define _PLANE_POST_CSC_GAMC_DATA_2_B	0x715dc
+#define _PLANE_POST_CSC_GAMC_DATA_1(pipe)	_PIPE(pipe, _PLANE_POST_CSC_GAMC_DATA_1_A, \
+						_PLANE_POST_CSC_GAMC_DATA_1_B)
+#define _PLANE_POST_CSC_GAMC_DATA_2(pipe)	_PIPE(pipe, _PLANE_POST_CSC_GAMC_DATA_2_A, \
+						_PLANE_POST_CSC_GAMC_DATA_2_B)
+#define PLANE_POST_CSC_GAMC_DATA(pipe, plane, i)	\
+		_MMIO_PLANE_GAMC(plane, i, _PLANE_POST_CSC_GAMC_DATA_1(pipe), \
+		_PLANE_POST_CSC_GAMC_DATA_2(pipe))
+
 /* Display13 Plane Degmma Reg */
 #define _PLANE_PRE_CSC_GAMC_INDEX_ENH_1_A	0x701d0
 #define _PLANE_PRE_CSC_GAMC_INDEX_ENH_1_B	0x711d0
Signature · 1 line
2.42.0
#41 lore raw

PATCH 25/28 drm/i915/color: Program Pre-CSC registers

In reply to Uma Shankar

Add callback for programming Pre-CSC LUT for TGL and beyond

---
 drivers/gpu/drm/i915/display/intel_color.c | 88 ++++++++++++++++++++++
 1 file changed, 88 insertions(+)
drivers/gpu/drm/i915/display/intel_color.c +88 -0
index 0d68f8303502..6dd9b8e43352 100644
@@ -3779,9 +3779,97 @@ void intel_color_load_plane_csc_matrix(const struct drm_plane_state *plane_state
 		i915->display.funcs.color->load_plane_csc_matrix(plane_state, blob);
 }
 
+static void xelpd_program_plane_pre_csc_lut(const struct drm_plane_state *state,
+					    const struct drm_color_lut_ext *pre_csc_lut,
+					    u32 offset)
+{
+	struct drm_i915_private *dev_priv = to_i915(state->plane->dev);
+	enum pipe pipe = to_intel_plane(state->plane)->pipe;
+	enum plane_id plane = to_intel_plane(state->plane)->id;
+	u32 i, lut_size;
+
+	if (icl_is_hdr_plane(dev_priv, plane)) {
+		lut_size = 128;
+
+		intel_de_write_fw(dev_priv, PLANE_PRE_CSC_GAMC_INDEX_ENH(pipe, plane, 0),
+				  offset | PLANE_PAL_PREC_AUTO_INCREMENT);
+
+		if (pre_csc_lut) {
+			for (i = 0; i < lut_size; i++) {
+				u64 word = drm_color_lut_extract_ext(pre_csc_lut[i].green, 24);
+				u32 lut_val = (word & 0xffffff);
+
+				intel_de_write_fw(dev_priv,
+						  PLANE_PRE_CSC_GAMC_DATA_ENH(pipe, plane, 0),
+						  lut_val);
+			}
+
+			/* Program the max register to clamp values > 1.0. */
+			while (i < 131)
+				intel_de_write_fw(dev_priv,
+						  PLANE_PRE_CSC_GAMC_DATA_ENH(pipe, plane, 0),
+						  pre_csc_lut[i++].green);
+		} else {
+			for (i = 0; i < lut_size; i++) {
+				u32 v = (i * ((1 << 24) - 1)) / (lut_size - 1);
+
+				intel_de_write_fw(dev_priv,
+						  PLANE_PRE_CSC_GAMC_DATA_ENH(pipe, plane, 0), v);
+			}
+
+			do {
+				intel_de_write_fw(dev_priv,
+						  PLANE_PRE_CSC_GAMC_DATA_ENH(pipe, plane, 0),
+						  1 << 24);
+			} while (i++ < 130);
+		}
+
+		intel_de_write_fw(dev_priv, PLANE_PRE_CSC_GAMC_INDEX_ENH(pipe, plane, 0), 0);
+	} else {
+		lut_size = 32;
+
+		/*
+		 * First 3 planes are HDR, so reduce by 3 to get to the right
+		 * SDR plane offset
+		 */
+		plane = plane - 3;
+
+		intel_de_write_fw(dev_priv, PLANE_PRE_CSC_GAMC_INDEX(pipe, plane, 0),
+				  offset | PLANE_PAL_PREC_AUTO_INCREMENT);
+
+		if (pre_csc_lut) {
+			for (i = 0; i < lut_size; i++)
+				intel_de_write_fw(dev_priv, PLANE_PRE_CSC_GAMC_DATA(pipe, plane, 0),
+						  pre_csc_lut[i].green);
+			/* Program the max register to clamp values > 1.0. */
+			while (i < 35)
+				intel_de_write_fw(dev_priv, PLANE_PRE_CSC_GAMC_DATA(pipe, plane, 0),
+						  pre_csc_lut[i++].green);
+		} else {
+			for (i = 0; i < lut_size; i++) {
+				u32 v = (i * ((1 << 16) - 1)) / (lut_size - 1);
+
+				intel_de_write_fw(dev_priv,
+						  PLANE_PRE_CSC_GAMC_DATA(pipe, plane, 0), v);
+			}
+
+			do {
+				intel_de_write_fw(dev_priv, PLANE_PRE_CSC_GAMC_DATA(pipe, plane, 0),
+						  1 << 16);
+			} while (i++ < 34);
+		}
+
+		intel_de_write_fw(dev_priv, PLANE_PRE_CSC_GAMC_INDEX(pipe, plane, 0), 0);
+	}
+}
+
 static void xelpd_plane_load_luts(const struct drm_plane_state *plane_state,
 				  const struct drm_property_blob *blob, bool is_pre_csc)
 {
+	struct drm_color_lut_ext *lut = blob->data;
+
+	if (is_pre_csc)
+		xelpd_program_plane_pre_csc_lut(plane_state, lut, 0);
 }
 
 void intel_color_load_plane_luts(const struct drm_plane_state *plane_state,
Signature · 1 line
2.42.0
#42 lore raw

PATCH 26/28 drm/i915/xelpd: Program Plane Post CSC Registers

In reply to Uma Shankar

Extract the LUT and program plane post csc registers.

---
 drivers/gpu/drm/i915/display/intel_color.c | 88 ++++++++++++++++++++++
 1 file changed, 88 insertions(+)
drivers/gpu/drm/i915/display/intel_color.c +88 -0
index 6dd9b8e43352..68e1c91a2b39 100644
@@ -3863,6 +3863,92 @@ static void xelpd_program_plane_pre_csc_lut(const struct drm_plane_state *state,
 	}
 }
 
+static void xelpd_program_plane_post_csc_lut(const struct drm_plane_state *state,
+					     const struct drm_color_lut_ext *post_csc_lut,
+					     u32 offset)
+{
+	struct drm_i915_private *dev_priv = to_i915(state->plane->dev);
+	enum pipe pipe = to_intel_plane(state->plane)->pipe;
+	enum plane_id plane = to_intel_plane(state->plane)->id;
+	u32 i, lut_size;
+
+	if (icl_is_hdr_plane(dev_priv, plane)) {
+		intel_de_write_fw(dev_priv, PLANE_POST_CSC_GAMC_INDEX_ENH(pipe, plane, 0),
+				  offset | PLANE_PAL_PREC_AUTO_INCREMENT);
+		if (post_csc_lut) {
+			lut_size = 32;
+			for (i = 0; i < lut_size; i++) {
+				u64 word = drm_color_lut_extract_ext(post_csc_lut[i].green, 24);
+				u32 lut_val = (word & 0xffffff);
+
+				intel_de_write_fw(dev_priv,
+						  PLANE_POST_CSC_GAMC_DATA_ENH(pipe, plane, 0),
+						  lut_val);
+			}
+
+			do {
+				/* Program the max register to clamp values > 1.0. */
+				intel_de_write_fw(dev_priv,
+						  PLANE_POST_CSC_GAMC_DATA_ENH(pipe, plane, 0),
+						  post_csc_lut[i].green);
+			} while (i++ < 34);
+		} else {
+			lut_size = 32;
+			for (i = 0; i < lut_size; i++) {
+				u32 v = (i * ((1 << 24) - 1)) / (lut_size - 1);
+
+				intel_de_write_fw(dev_priv,
+						  PLANE_POST_CSC_GAMC_DATA_ENH(pipe, plane, 0), v);
+			}
+
+			do {
+				intel_de_write_fw(dev_priv,
+						  PLANE_POST_CSC_GAMC_DATA_ENH(pipe, plane, 0),
+						  1 << 24);
+			} while (i++ < 34);
+		}
+
+		intel_de_write_fw(dev_priv, PLANE_POST_CSC_GAMC_INDEX_ENH(pipe, plane, 0), 0);
+	} else {
+		lut_size = 32;
+		/*
+		 * First 3 planes are HDR, so reduce by 3 to get to the right
+		 * SDR plane offset
+		 */
+		plane = plane - 3;
+
+		intel_de_write_fw(dev_priv, PLANE_POST_CSC_GAMC_INDEX(pipe, plane, 0),
+				  offset | PLANE_PAL_PREC_AUTO_INCREMENT);
+
+		if (post_csc_lut) {
+			for (i = 0; i < lut_size; i++)
+				intel_de_write_fw(dev_priv,
+						  PLANE_POST_CSC_GAMC_DATA(pipe, plane, 0),
+						  post_csc_lut[i].green & 0xffff);
+			/* Program the max register to clamp values > 1.0. */
+			while (i < 35)
+				intel_de_write_fw(dev_priv,
+						  PLANE_POST_CSC_GAMC_DATA(pipe, plane, 0),
+						  post_csc_lut[i++].green & 0x3ffff);
+		} else {
+			for (i = 0; i < lut_size; i++) {
+				u32 v = (i * ((1 << 16) - 1)) / (lut_size - 1);
+
+				intel_de_write_fw(dev_priv,
+						  PLANE_POST_CSC_GAMC_DATA(pipe, plane, 0), v);
+			}
+
+			do {
+				intel_de_write_fw(dev_priv,
+						  PLANE_POST_CSC_GAMC_DATA(pipe, plane, 0),
+						  (1 << 16));
+			} while (i++ < 34);
+		}
+
+		intel_de_write_fw(dev_priv, PLANE_POST_CSC_GAMC_INDEX(pipe, plane, 0), 0);
+	}
+}
+
 static void xelpd_plane_load_luts(const struct drm_plane_state *plane_state,
 				  const struct drm_property_blob *blob, bool is_pre_csc)
 {
@@ -3870,6 +3956,8 @@ static void xelpd_plane_load_luts(const struct drm_plane_state *plane_state,
 
 	if (is_pre_csc)
 		xelpd_program_plane_pre_csc_lut(plane_state, lut, 0);
+	else
+		xelpd_program_plane_post_csc_lut(plane_state, lut, 0);
 }
 
 void intel_color_load_plane_luts(const struct drm_plane_state *plane_state,
Signature · 1 line
2.42.0
#43 lore raw

PATCH 27/28 FIXME: force disable legacy plane color properties for TGL and beyond

In reply to Uma Shankar

From: Chaitanya Kumar Borah <[email protected]>

The decision should be made based on the DRM_CLIENT_CAP_PLANE_COLOR_PIPELINE.
Right now the value of this cap is not passed on to the driver.

---
 drivers/gpu/drm/i915/display/skl_universal_plane.c | 14 ++++++++------
 1 file changed, 8 insertions(+), 6 deletions(-)
drivers/gpu/drm/i915/display/skl_universal_plane.c +8 -6
index e941e2e4fd14..7096ea8a3454 100644
@@ -2424,12 +2424,14 @@ skl_universal_plane_create(struct drm_i915_private *dev_priv,
 	if (DISPLAY_VER(dev_priv) >= 10)
 		supported_csc |= BIT(DRM_COLOR_YCBCR_BT2020);
 
-	drm_plane_create_color_properties(&plane->base,
-					  supported_csc,
-					  BIT(DRM_COLOR_YCBCR_LIMITED_RANGE) |
-					  BIT(DRM_COLOR_YCBCR_FULL_RANGE),
-					  DRM_COLOR_YCBCR_BT709,
-					  DRM_COLOR_YCBCR_LIMITED_RANGE);
+	/* TODO: Make it based on client cap */
+	if (DISPLAY_VER(dev_priv) <= 11)
+		drm_plane_create_color_properties(&plane->base,
+						  supported_csc,
+						  BIT(DRM_COLOR_YCBCR_LIMITED_RANGE) |
+						  BIT(DRM_COLOR_YCBCR_FULL_RANGE),
+						  DRM_COLOR_YCBCR_BT709,
+						  DRM_COLOR_YCBCR_LIMITED_RANGE);
 
 	drm_plane_create_alpha_property(&plane->base);
 	drm_plane_create_blend_mode_property(&plane->base,
Signature · 1 line
2.42.0
#44 lore raw

PATCH 28/28 drm/i915/color: Enable Plane Color Pipelines

In reply to Uma Shankar

From: Chaitanya Kumar Borah <[email protected]>

Expose color pipeline and add capability to program it.

---
 drivers/gpu/drm/i915/display/skl_universal_plane.c | 5 +++++
 1 file changed, 5 insertions(+)
drivers/gpu/drm/i915/display/skl_universal_plane.c +5 -0
index 7096ea8a3454..64e70cc34ddb 100644
@@ -11,6 +11,7 @@
 #include "i915_drv.h"
 #include "i915_reg.h"
 #include "intel_atomic_plane.h"
+#include "intel_color.h"
 #include "intel_de.h"
 #include "intel_display_irq.h"
 #include "intel_display_types.h"
@@ -1279,6 +1280,8 @@ icl_plane_update_noarm(struct intel_plane *plane,
 	plane_color_ctl = plane_state->color_ctl |
 		glk_plane_color_ctl_crtc(crtc_state);
 
+	intel_program_pipeline(&plane_state->uapi, &plane_color_ctl);
+
 	/* The scaler will handle the output position */
 	if (plane_state->scaler_id >= 0) {
 		crtc_x = 0;
@@ -2432,6 +2435,8 @@ skl_universal_plane_create(struct drm_i915_private *dev_priv,
 						  BIT(DRM_COLOR_YCBCR_FULL_RANGE),
 						  DRM_COLOR_YCBCR_BT709,
 						  DRM_COLOR_YCBCR_LIMITED_RANGE);
+	else
+		intel_plane_color_init(&plane->base);
 
 	drm_plane_create_alpha_property(&plane->base);
 	drm_plane_create_blend_mode_property(&plane->base,
Signature · 1 line
2.42.0
#45 lore raw

✗ Fi.CI.CHECKPATCH: warning for Plane Color Pipeline support for Intel platforms

In reply to Uma Shankar
== Series Details ==

== Series Details ==

Series: Plane Color Pipeline support for Intel platforms
URL : https://patchwork.freedesktop.org/series/129811/
State : warning

== Summary ==

Error: dim checkpatch failed
8c131441495a drm: color pipeline base work
Traceback (most recent call last):
File "scripts/spdxcheck.py", line 6, in <module>
from ply import lex, yacc
ModuleNotFoundError: No module named 'ply'
Traceback (most recent call last):
File "scripts/spdxcheck.py", line 6, in <module>
from ply import lex, yacc
ModuleNotFoundError: No module named 'ply'
-:24: WARNING:FILE_PATH_CHANGES: added, moved or deleted file(s), does MAINTAINERS need updating? #24:
new file mode 100644

-:29: WARNING:SPDX_LICENSE_TAG: Missing or malformed SPDX-License-Identifier tag in line 1 #29: FILE: Documentation/gpu/rfc/color_pipeline.rst:1:
+========================

-:450: CHECK:LINE_SPACING: Please don't use multiple blank lines #450: FILE: drivers/gpu/drm/drm_atomic.c:594:

+

-:507: CHECK:LINE_SPACING: Please don't use multiple blank lines #507: FILE: drivers/gpu/drm/drm_atomic.c:786:

+

-:510: CHECK:PARENTHESIS_ALIGNMENT: Alignment should match open parenthesis #510: FILE: drivers/gpu/drm/drm_atomic.c:789:
+static void drm_atomic_colorop_print_state(struct drm_printer *p,
+ const struct drm_colorop_state *state)

-:517: WARNING:LONG_LINE: line length of 104 exceeds 100 columns #517: FILE: drivers/gpu/drm/drm_atomic.c:796:
+ drm_printf(p, "\tcurve_1d_type=%s\n", drm_get_colorop_curve_1d_type_name(state->curve_1d_type));

-:528: WARNING:IF_0: Consider removing the code enclosed by this #if 0 and its #endif #528: FILE: drivers/gpu/drm/drm_atomic.c:821:
+#if 0

-:529: WARNING:LEADING_SPACE: please, no spaces at the start of a line #529: FILE: drivers/gpu/drm/drm_atomic.c:822:
+ drm_printf(p, "\tcolor-pipeline=%s\n",$

-:530: ERROR:CODE_INDENT: code indent should use tabs where possible #530: FILE: drivers/gpu/drm/drm_atomic.c:823:
+ drm_get_color_pipeline_name(state->color_pipeline));$

-:530: WARNING:LEADING_SPACE: please, no spaces at the start of a line #530: FILE: drivers/gpu/drm/drm_atomic.c:823:
+ drm_get_color_pipeline_name(state->color_pipeline));$

-:532: WARNING:LEADING_SPACE: please, no spaces at the start of a line #532: FILE: drivers/gpu/drm/drm_atomic.c:825:
+ drm_printf(p, "\tcolor-pipeline=%d\n",$

-:533: ERROR:CODE_INDENT: code indent should use tabs where possible #533: FILE: drivers/gpu/drm/drm_atomic.c:826:
+ state->color_pipeline ? state->color_pipeline->base.id : 0);$

-:533: WARNING:LEADING_SPACE: please, no spaces at the start of a line #533: FILE: drivers/gpu/drm/drm_atomic.c:826:
+ state->color_pipeline ? state->color_pipeline->base.id : 0);$

-:677: CHECK:LINE_SPACING: Please don't use multiple blank lines #677: FILE: drivers/gpu/drm/drm_atomic_uapi.c:259:

+

-:708: CHECK:LINE_SPACING: Please don't use multiple blank lines #708: FILE: drivers/gpu/drm/drm_atomic_uapi.c:290:
+
+

-:738: WARNING:LINE_SPACING: Missing a blank line after declarations #738: FILE: drivers/gpu/drm/drm_atomic_uapi.c:593:
+ struct drm_colorop *colorop = NULL;
+ colorop = drm_colorop_find(dev, file_priv, val);

-:762: CHECK:PARENTHESIS_ALIGNMENT: Alignment should match open parenthesis #762: FILE: drivers/gpu/drm/drm_atomic_uapi.c:707:
+static int drm_atomic_color_set_data_property(struct drm_colorop *colorop,
+ struct drm_colorop_state *state,

-:769: CHECK:LINE_SPACING: Please don't use multiple blank lines #769: FILE: drivers/gpu/drm/drm_atomic_uapi.c:714:
+
+

-:788: CHECK:PARENTHESIS_ALIGNMENT: Alignment should match open parenthesis #788: FILE: drivers/gpu/drm/drm_atomic_uapi.c:733:
+static int drm_atomic_colorop_set_property(struct drm_colorop *colorop,
+ struct drm_colorop_state *state, struct drm_file *file_priv,

-:811: CHECK:PARENTHESIS_ALIGNMENT: Alignment should match open parenthesis #811: FILE: drivers/gpu/drm/drm_atomic_uapi.c:756:
+drm_atomic_colorop_get_property(struct drm_colorop *colorop,
+ const struct drm_colorop_state *state,

-:814: WARNING:BRACES: braces {} are not necessary for any arm of this statement #814: FILE: drivers/gpu/drm/drm_atomic_uapi.c:759:
+ if (property == colorop->type_property) {
[...]
+ } else if (property == colorop->bypass_property) {
[...]
+ } else if (property == colorop->curve_1d_type_property) {
[...]
+ } else if (property == colorop->data_property) {
[...]
+ } else {
[...]

-:843: CHECK:PARENTHESIS_ALIGNMENT: Alignment should match open parenthesis #843: FILE: drivers/gpu/drm/drm_atomic_uapi.c:1043:
+ ret = drm_atomic_colorop_get_property(colorop,
+ colorop->state, property, val);

-:873: CHECK:PARENTHESIS_ALIGNMENT: Alignment should match open parenthesis #873: FILE: drivers/gpu/drm/drm_atomic_uapi.c:1246:
+ ret = drm_atomic_colorop_set_property(colorop,
+ colorop_state, file_priv,

-:884: WARNING:SPDX_LICENSE_TAG: Missing or malformed SPDX-License-Identifier tag in line 1 #884: FILE: drivers/gpu/drm/drm_colorop.c:1:
+/*

-:954: CHECK:PARENTHESIS_ALIGNMENT: Alignment should match open parenthesis #954: FILE: drivers/gpu/drm/drm_colorop.c:71:
+ prop = drm_property_create_range(dev,
+ DRM_MODE_PROP_IMMUTABLE,

-:1007: CHECK:PARENTHESIS_ALIGNMENT: Alignment should match open parenthesis #1007: FILE: drivers/gpu/drm/drm_colorop.c:124:
+ prop = drm_property_create_object(dev, DRM_MODE_PROP_IMMUTABLE | DRM_MODE_PROP_ATOMIC,
+ "NEXT", DRM_MODE_OBJECT_COLOROP);

-:1042: CHECK:LINE_SPACING: Please don't use multiple blank lines #1042: FILE: drivers/gpu/drm/drm_colorop.c:159:
+
+

-:1117: CHECK:LINE_SPACING: Please don't use multiple blank lines #1117: FILE: drivers/gpu/drm/drm_colorop.c:234:
+
+

-:1274: WARNING:LONG_LINE: line length of 103 exceeds 100 columns #1274: FILE: drivers/gpu/drm/tests/drm_fixp_test.c:17:
+ KUNIT_EXPECT_EQ(test, drm_int2fixp(-1), drm_sm2fixp((1ull << 63) | (1ull << DRM_FIXED_POINT)));

-:1277: WARNING:LONG_LINE: line length of 104 exceeds 100 columns #1277: FILE: drivers/gpu/drm/tests/drm_fixp_test.c:20:
+ KUNIT_EXPECT_EQ(test, drm_fixp_from_fraction(1, 2), drm_sm2fixp(1ull << (DRM_FIXED_POINT - 1)));

-:1280: WARNING:LONG_LINE: line length of 122 exceeds 100 columns #1280: FILE: drivers/gpu/drm/tests/drm_fixp_test.c:23:
+ KUNIT_EXPECT_EQ(test, drm_fixp_from_fraction(-1, 2), drm_sm2fixp((1ull << 63) | (1ull << (DRM_FIXED_POINT - 1))));

-:1282: CHECK:BRACES: Blank lines aren't necessary before a close brace '}' #1282: FILE: drivers/gpu/drm/tests/drm_fixp_test.c:25:
+
+}

-:1310: CHECK:BRACES: Blank lines aren't necessary before a close brace '}' #1310: FILE: drivers/gpu/drm/tests/drm_fixp_test.c:53:
+
+}

-:1326: WARNING:MISSING_EOF_NEWLINE: adding a line without newline at end of file #1326: FILE: drivers/gpu/drm/tests/drm_fixp_test.c:69:
+MODULE_LICENSE("GPL and additional rights");

-:1337: WARNING:CONFIG_DESCRIPTION: please write a help paragraph that fully describes the config symbol #1337: FILE: drivers/gpu/drm/vkms/Kconfig:17:
+config DRM_VKMS_KUNIT_TESTS
+ tristate "Tests for VKMS" if !KUNIT_ALL_TESTS
+ depends on DRM_VKMS && KUNIT
+ default KUNIT_ALL_TESTS

-:1371: WARNING:SPDX_LICENSE_TAG: Improper SPDX comment style for 'drivers/gpu/drm/vkms/tests/vkms_color_tests.c', please use '//' instead #1371: FILE: drivers/gpu/drm/vkms/tests/vkms_color_tests.c:1:
+/* SPDX-License-Identifier: GPL-2.0+ */

-:1371: WARNING:SPDX_LICENSE_TAG: Missing or malformed SPDX-License-Identifier tag in line 1 #1371: FILE: drivers/gpu/drm/vkms/tests/vkms_color_tests.c:1:
+/* SPDX-License-Identifier: GPL-2.0+ */

-:1409: WARNING:LONG_LINE: line length of 106 exceeds 100 columns #1409: FILE: drivers/gpu/drm/vkms/tests/vkms_color_tests.c:39:
+ KUNIT_EXPECT_EQ(test, drm_fixp2int(get_lut_index(&test_linear_lut, test_linear_array[0].red)), 0);

-:1412: WARNING:LONG_LINE: line length of 119 exceeds 100 columns #1412: FILE: drivers/gpu/drm/vkms/tests/vkms_color_tests.c:42:
+ KUNIT_EXPECT_EQ(test, drm_fixp2int_ceil(get_lut_index(&test_linear_lut, test_linear_array[i].red)), i);

-:1437: WARNING:LINE_SPACING: Missing a blank line after declarations #1437: FILE: drivers/gpu/drm/vkms/tests/vkms_color_tests.c:67:
+ int linear = apply_lut_to_channel_value(&linear_eotf, i * 0x101, LUT_RED);
+ KUNIT_EXPECT_EQ(test, DIV_ROUND_CLOSEST(linear, 0x101), i);

-:1449: CHECK:SPACING: spaces preferred around that '-' (ctx:VxV) #1449: FILE: drivers/gpu/drm/vkms/tests/vkms_color_tests.c:79:
+ KUNIT_EXPECT_GE(test, final / 0x101, i-1);
^

-:1450: CHECK:SPACING: spaces preferred around that '+' (ctx:VxV) #1450: FILE: drivers/gpu/drm/vkms/tests/vkms_color_tests.c:80:
+ KUNIT_EXPECT_LE(test, final / 0x101, i+1);
^

-:1612: CHECK:LINE_SPACING: Please don't use multiple blank lines #1612: FILE: drivers/gpu/drm/vkms/tests/vkms_color_tests.c:242:
+
+

-:1687: CHECK:LINE_SPACING: Please don't use multiple blank lines #1687: FILE: drivers/gpu/drm/vkms/tests/vkms_color_tests.c:317:
+
+

-:1707: CHECK:BRACES: Blank lines aren't necessary before a close brace '}' #1707: FILE: drivers/gpu/drm/vkms/tests/vkms_color_tests.c:337:
+
+}

-:1723: CHECK:LINE_SPACING: Please use a blank line after function/struct/union/enum declarations #1723: FILE: drivers/gpu/drm/vkms/tests/vkms_color_tests.c:353:
+};
+kunit_test_suite(vkms_color_test_suite);

-:1725: WARNING:MISSING_EOF_NEWLINE: adding a line without newline at end of file #1725: FILE: drivers/gpu/drm/vkms/tests/vkms_color_tests.c:355:
+MODULE_LICENSE("GPL");

-:1733: WARNING:SPDX_LICENSE_TAG: Improper SPDX comment style for 'drivers/gpu/drm/vkms/vkms_colorop.c', please use '//' instead #1733: FILE: drivers/gpu/drm/vkms/vkms_colorop.c:1:
+/* SPDX-License-Identifier: GPL-2.0+ */

-:1733: WARNING:SPDX_LICENSE_TAG: Missing or malformed SPDX-License-Identifier tag in line 1 #1733: FILE: drivers/gpu/drm/vkms/vkms_colorop.c:1:
+/* SPDX-License-Identifier: GPL-2.0+ */

-:1745: CHECK:BRACES: Blank lines aren't necessary after an open brace '{' #1745: FILE: drivers/gpu/drm/vkms/vkms_colorop.c:13:
+{
+

-:1751: CHECK:ALLOC_SIZEOF_STRUCT: Prefer kzalloc(sizeof(*op)...) over kzalloc(sizeof(struct drm_colorop)...) #1751: FILE: drivers/gpu/drm/vkms/vkms_colorop.c:19:
+ op = kzalloc(sizeof(struct drm_colorop), GFP_KERNEL);

-:1767: CHECK:ALLOC_SIZEOF_STRUCT: Prefer kzalloc(sizeof(*op)...) over kzalloc(sizeof(struct drm_colorop)...) #1767: FILE: drivers/gpu/drm/vkms/vkms_colorop.c:35:
+ op = kzalloc(sizeof(struct drm_colorop), GFP_KERNEL);

-:1782: CHECK:ALLOC_SIZEOF_STRUCT: Prefer kzalloc(sizeof(*op)...) over kzalloc(sizeof(struct drm_colorop)...) #1782: FILE: drivers/gpu/drm/vkms/vkms_colorop.c:50:
+ op = kzalloc(sizeof(struct drm_colorop), GFP_KERNEL);

-:1797: CHECK:ALLOC_SIZEOF_STRUCT: Prefer kzalloc(sizeof(*op)...) over kzalloc(sizeof(struct drm_colorop)...) #1797: FILE: drivers/gpu/drm/vkms/vkms_colorop.c:65:
+ op = kzalloc(sizeof(struct drm_colorop), GFP_KERNEL);

-:1826: CHECK:UNNECESSARY_PARENTHESES: Unnecessary parentheses around pipelines[len] #1826: FILE: drivers/gpu/drm/vkms/vkms_colorop.c:94:
+ ret = vkms_initialize_tf_pipeline(plane, &(pipelines[len]));

-:1912: ERROR:SWITCH_CASE_INDENT_LEVEL: switch and case should be at the same indent #1912: FILE: drivers/gpu/drm/vkms/vkms_composer.c:197:
+ switch (colorop_state->curve_1d_type) {
+ case DRM_COLOROP_1D_CURVE_SRGB_INV_EOTF:
[...]
+ case DRM_COLOROP_1D_CURVE_SRGB_EOTF:
[...]
+ default:

-:1914: WARNING:LONG_LINE: line length of 105 exceeds 100 columns #1914: FILE: drivers/gpu/drm/vkms/vkms_composer.c:199:
+ pixel->r = apply_lut_to_channel_value(&srgb_inv_eotf, pixel->r, LUT_RED);

-:1915: WARNING:LONG_LINE: line length of 107 exceeds 100 columns #1915: FILE: drivers/gpu/drm/vkms/vkms_composer.c:200:
+ pixel->g = apply_lut_to_channel_value(&srgb_inv_eotf, pixel->g, LUT_GREEN);

-:1916: WARNING:LONG_LINE: line length of 106 exceeds 100 columns #1916: FILE: drivers/gpu/drm/vkms/vkms_composer.c:201:
+ pixel->b = apply_lut_to_channel_value(&srgb_inv_eotf, pixel->b, LUT_BLUE);

-:1919: WARNING:LONG_LINE: line length of 101 exceeds 100 columns #1919: FILE: drivers/gpu/drm/vkms/vkms_composer.c:204:
+ pixel->r = apply_lut_to_channel_value(&srgb_eotf, pixel->r, LUT_RED);

-:1920: WARNING:LONG_LINE: line length of 103 exceeds 100 columns #1920: FILE: drivers/gpu/drm/vkms/vkms_composer.c:205:
+ pixel->g = apply_lut_to_channel_value(&srgb_eotf, pixel->g, LUT_GREEN);

-:1921: WARNING:LONG_LINE: line length of 102 exceeds 100 columns #1921: FILE: drivers/gpu/drm/vkms/vkms_composer.c:206:
+ pixel->b = apply_lut_to_channel_value(&srgb_eotf, pixel->b, LUT_BLUE);

-:1924: WARNING:TYPO_SPELLING: 'unkown' may be misspelled - perhaps 'unknown'? #1924: FILE: drivers/gpu/drm/vkms/vkms_composer.c:209:
+ DRM_DEBUG_DRIVER("unkown colorop 1D curve type %d\n", colorop_state->curve_1d_type);
^^^^^^

-:1924: WARNING:LONG_LINE: line length of 116 exceeds 100 columns #1924: FILE: drivers/gpu/drm/vkms/vkms_composer.c:209:
+ DRM_DEBUG_DRIVER("unkown colorop 1D curve type %d\n", colorop_state->curve_1d_type);

-:1929: WARNING:LONG_LINE: line length of 104 exceeds 100 columns #1929: FILE: drivers/gpu/drm/vkms/vkms_composer.c:214:
+ apply_3x4_matrix(pixel, (struct drm_color_ctm_3x4 *) colorop_state->data->data);

-:1929: CHECK:SPACING: No space is necessary after a cast #1929: FILE: drivers/gpu/drm/vkms/vkms_composer.c:214:
+ apply_3x4_matrix(pixel, (struct drm_color_ctm_3x4 *) colorop_state->data->data);

-:1932: CHECK:BRACES: Blank lines aren't necessary before a close brace '}' #1932: FILE: drivers/gpu/drm/vkms/vkms_composer.c:217:
+
+}

-:1934: WARNING:LONG_LINE: line length of 116 exceeds 100 columns
#1934: FILE: drivers/gpu/drm/vkms/vkms_composer.c:219:
+static void pre_blend_color_transform(const struct vkms_plane_state *plane_state, struct line_buffer *output_buffer)

-:1940: CHECK:BRACES: Blank lines aren't necessary after an open brace '{' #1940: FILE: drivers/gpu/drm/vkms/vkms_composer.c:225:
+ for (size_t x = 0; x < output_buffer->n_pixels; x++) {
+

-:2030: CHECK:LINE_SPACING: Please don't use multiple blank lines #2030: FILE: drivers/gpu/drm/vkms/vkms_drv.h:180:
+
+

-:2038: WARNING:SPDX_LICENSE_TAG: Improper SPDX comment style for 'drivers/gpu/drm/vkms/vkms_luts.c', please use '//' instead #2038: FILE: drivers/gpu/drm/vkms/vkms_luts.c:1:
+/* SPDX-License-Identifier: GPL-2.0+ */

-:2038: WARNING:SPDX_LICENSE_TAG: Missing or malformed SPDX-License-Identifier tag in line 1 #2038: FILE: drivers/gpu/drm/vkms/vkms_luts.c:1:
+/* SPDX-License-Identifier: GPL-2.0+ */

-:2310: CHECK:LINE_SPACING: Please don't use multiple blank lines #2310: FILE: drivers/gpu/drm/vkms/vkms_luts.c:273:
+
+

-:2857: WARNING:MISSING_EOF_NEWLINE: adding a line without newline at end of file #2857: FILE: drivers/gpu/drm/vkms/vkms_luts.h:12:
+#endif /* _VKMS_LUTS_H_ */

-:2919: CHECK:LINE_SPACING: Please don't use multiple blank lines #2919: FILE: include/drm/drm_atomic.h:693:

+

-:2933: CHECK:PARENTHESIS_ALIGNMENT: Alignment should match open parenthesis #2933: FILE: include/drm/drm_atomic.h:707:
+drm_atomic_get_existing_colorop_state(struct drm_atomic_state *state,
+ struct drm_colorop *colorop)

-:2948: CHECK:PARENTHESIS_ALIGNMENT: Alignment should match open parenthesis #2948: FILE: include/drm/drm_atomic.h:722:
+drm_atomic_get_old_colorop_state(struct drm_atomic_state *state,
+ struct drm_colorop *colorop)

-:2963: CHECK:PARENTHESIS_ALIGNMENT: Alignment should match open parenthesis #2963: FILE: include/drm/drm_atomic.h:737:
+drm_atomic_get_new_colorop_state(struct drm_atomic_state *state,
+ struct drm_colorop *colorop)

-:2987: WARNING:LONG_LINE: line length of 103 exceeds 100 columns
#2987: FILE: include/drm/drm_atomic.h:1001:
+#define for_each_oldnew_colorop_in_state(__state, colorop, old_colorop_state, new_colorop_state, __i) \

-:2987: ERROR:COMPLEX_MACRO: Macros with complex values should be enclosed in parentheses #2987: FILE: include/drm/drm_atomic.h:1001:
+#define for_each_oldnew_colorop_in_state(__state, colorop, old_colorop_state, new_colorop_state, __i) \
+ for ((__i) = 0; \
+ (__i) < (__state)->dev->mode_config.num_colorop; \
+ (__i)++) \
+ for_each_if ((__state)->colorops[__i].ptr && \
+ ((colorop) = (__state)->colorops[__i].ptr, \

+			      (void)(colorop) /* Only to avoid unused-but-set-variable warning */, \
+			      (old_colorop_state) = (__state)->colorops[__i].old_state,\
+			      (new_colorop_state) = (__state)->colorops[__i].new_state, 1))

-:2987: CHECK:MACRO_ARG_REUSE: Macro argument reuse '__state' - possible side-effects? #2987: FILE: include/drm/drm_atomic.h:1001:
+#define for_each_oldnew_colorop_in_state(__state, colorop, old_colorop_state, new_colorop_state, __i) \
+ for ((__i) = 0; \
+ (__i) < (__state)->dev->mode_config.num_colorop; \
+ (__i)++) \
+ for_each_if ((__state)->colorops[__i].ptr && \
+ ((colorop) = (__state)->colorops[__i].ptr, \

+			      (void)(colorop) /* Only to avoid unused-but-set-variable warning */, \
+			      (old_colorop_state) = (__state)->colorops[__i].old_state,\
+			      (new_colorop_state) = (__state)->colorops[__i].new_state, 1))

-:2987: CHECK:MACRO_ARG_REUSE: Macro argument reuse 'colorop' - possible side-effects? #2987: FILE: include/drm/drm_atomic.h:1001:
+#define for_each_oldnew_colorop_in_state(__state, colorop, old_colorop_state, new_colorop_state, __i) \
+ for ((__i) = 0; \
+ (__i) < (__state)->dev->mode_config.num_colorop; \
+ (__i)++) \
+ for_each_if ((__state)->colorops[__i].ptr && \
+ ((colorop) = (__state)->colorops[__i].ptr, \

+			      (void)(colorop) /* Only to avoid unused-but-set-variable warning */, \
+			      (old_colorop_state) = (__state)->colorops[__i].old_state,\
+			      (new_colorop_state) = (__state)->colorops[__i].new_state, 1))

-:2987: CHECK:MACRO_ARG_REUSE: Macro argument reuse '__i' - possible side-effects? #2987: FILE: include/drm/drm_atomic.h:1001:
+#define for_each_oldnew_colorop_in_state(__state, colorop, old_colorop_state, new_colorop_state, __i) \
+ for ((__i) = 0; \
+ (__i) < (__state)->dev->mode_config.num_colorop; \
+ (__i)++) \
+ for_each_if ((__state)->colorops[__i].ptr && \
+ ((colorop) = (__state)->colorops[__i].ptr, \

+			      (void)(colorop) /* Only to avoid unused-but-set-variable warning */, \
+			      (old_colorop_state) = (__state)->colorops[__i].old_state,\
+			      (new_colorop_state) = (__state)->colorops[__i].new_state, 1))

-:2991: WARNING:SPACING: space prohibited between function name and open parenthesis '(' #2991: FILE: include/drm/drm_atomic.h:1005:
+ for_each_if ((__state)->colorops[__i].ptr && \

-:2997: CHECK:LINE_SPACING: Please don't use multiple blank lines #2997: FILE: include/drm/drm_atomic.h:1011:
+
+

-:3028: WARNING:SPDX_LICENSE_TAG: Missing or malformed SPDX-License-Identifier tag in line 1 #3028: FILE: include/drm/drm_colorop.h:1:
+/*

-:3124: WARNING:UNSPECIFIED_INT: Prefer 'unsigned int' to bare use of 'unsigned' #3124: FILE: include/drm/drm_colorop.h:97:
+ unsigned index;

-:3226: CHECK:LINE_SPACING: Please don't use multiple blank lines #3226: FILE: include/drm/drm_colorop.h:199:
+
+

-:3228: CHECK:LINE_SPACING: Please don't use multiple blank lines #3228: FILE: include/drm/drm_colorop.h:201:
+
+

-:3240: CHECK:PARENTHESIS_ALIGNMENT: Alignment should match open parenthesis #3240: FILE: include/drm/drm_colorop.h:213:
+static inline struct drm_colorop *drm_colorop_find(struct drm_device *dev,
+ struct drm_file *file_priv,

-:3244: WARNING:LINE_SPACING: Missing a blank line after declarations #3244: FILE: include/drm/drm_colorop.h:217:
+ struct drm_mode_object *mo;
+ mo = drm_mode_object_find(dev, file_priv, id, DRM_MODE_OBJECT_COLOROP);

-:3271: CHECK:LINE_SPACING: Please don't use multiple blank lines #3271: FILE: include/drm/drm_colorop.h:244:
+
+

-:3284: CHECK:LINE_SPACING: Please don't use multiple blank lines #3284: FILE: include/drm/drm_colorop.h:257:
+
+

-:3328: CHECK:BRACES: Blank lines aren't necessary before a close brace '}' #3328: FILE: include/drm/drm_fixed.h:97:
+
+}

total: 4 errors, 42 warnings, 48 checks, 3230 lines checked ecbcbbcf5594 drm: Add missing function declarations
07461ab41921 drm: handle NULL next colorop in drm_colorop_set_next_property e6791343a988 drm: Fix error logging in set Color Pipeline 48e84823e698 drm: Add support for 3x3 CTM
661b9e551542 drm: Add Enhanced LUT precision structure
0991aee6f774 drm: Add 1D LUT color op
f26cd3353ff6 drm: Add Color lut range attributes
123349a6093b drm: Add Color ops capability property
dd0d7aceca23 drm: Define helper to create color ops capability property eef35f80c4ef drm: Define helper for adding capability property for 1D LUT 3cef6fb4f715 drm/i915: Add identifiers for intel color blocks 38e4dc2117d0 drm/i915: Add intel_color_op
b9ef4da15192 drm/i915/color: Add helper to allocate intel colorop d1b973de6844 drm/i915/color: Add helper to create intel colorop 930f2ac88eb7 drm/i915/color: Create a transfer function color pipeline 227471ff2a5c drm/i915: Define segmented Lut and add capabilities to colorop 328e84d3792e drm/i915/color: Add and attach COLORPIPELINE plane property 302d5bb7593a drm/i915/color: Add framework to set colorop 574662acdf50 drm/i915/color: Add callbacks to set plane CTM 988152760490 drm/i915/color: Add plane CTM callback for TGL and beyond c28fd208f633 drm/i915: Add register definitions for Plane Degamma -:36: CHECK:MACRO_ARG_REUSE: Macro argument reuse 'pipe' - possible side-effects? #36: FILE: drivers/gpu/drm/i915/i915_reg.h:6256:
+#define PLANE_PRE_CSC_GAMC_INDEX_ENH(pipe, plane, i) \
+ _MMIO_PLANE_GAMC(plane, i, _PLANE_PRE_CSC_GAMC_INDEX_ENH_1(pipe), \
+ _PLANE_PRE_CSC_GAMC_INDEX_ENH_2(pipe))

-:49: CHECK:MACRO_ARG_REUSE: Macro argument reuse 'pipe' - possible side-effects? #49: FILE: drivers/gpu/drm/i915/i915_reg.h:6269:
+#define PLANE_PRE_CSC_GAMC_DATA_ENH(pipe, plane, i) \
+ _MMIO_PLANE_GAMC(plane, i, _PLANE_PRE_CSC_GAMC_DATA_ENH_1(pipe), \
+ _PLANE_PRE_CSC_GAMC_DATA_ENH_2(pipe))

-:61: CHECK:MACRO_ARG_REUSE: Macro argument reuse 'pipe' - possible side-effects? #61: FILE: drivers/gpu/drm/i915/i915_reg.h:6281:
+#define PLANE_PRE_CSC_GAMC_INDEX(pipe, plane, i) \
+ _MMIO_PLANE_GAMC(plane, i, _PLANE_PRE_CSC_GAMC_INDEX_1(pipe), \
+ _PLANE_PRE_CSC_GAMC_INDEX_2(pipe))

-:73: CHECK:MACRO_ARG_REUSE: Macro argument reuse 'pipe' - possible side-effects? #73: FILE: drivers/gpu/drm/i915/i915_reg.h:6293:
+#define PLANE_PRE_CSC_GAMC_DATA(pipe, plane, i) \
+ _MMIO_PLANE_GAMC(plane, i, _PLANE_PRE_CSC_GAMC_DATA_1(pipe), \
+ _PLANE_PRE_CSC_GAMC_DATA_2(pipe))

total: 0 errors, 0 warnings, 4 checks, 63 lines checked a3ec1abc0036 drm/i915/color: Add framework to program PRE/POST CSC LUT 4bc8e7fa9b0d drm/i915: Add register definitions for Plane Post CSC -:24: WARNING:LONG_LINE: line length of 110 exceeds 100 columns #24: FILE: drivers/gpu/drm/i915/i915_reg.h:6252:
+#define _PLANE_POST_CSC_GAMC_SEG0_INDEX_ENH_1(pipe) _PIPE(pipe, _PLANE_POST_CSC_GAMC_SEG0_INDEX_ENH_1_A, \

-:26: WARNING:LONG_LINE: line length of 110 exceeds 100 columns #26: FILE: drivers/gpu/drm/i915/i915_reg.h:6254:
+#define _PLANE_POST_CSC_GAMC_SEG0_INDEX_ENH_2(pipe) _PIPE(pipe, _PLANE_POST_CSC_GAMC_SEG0_INDEX_ENH_2_A, \

-:28: CHECK:MACRO_ARG_REUSE: Macro argument reuse 'pipe' - possible side-effects? #28: FILE: drivers/gpu/drm/i915/i915_reg.h:6256:
+#define PLANE_POST_CSC_GAMC_SEG0_INDEX_ENH(pipe, plane, i) \
+ _MMIO_PLANE_GAMC(plane, i, _PLANE_POST_CSC_GAMC_SEG0_INDEX_ENH_1(pipe), \
+ _PLANE_POST_CSC_GAMC_SEG0_INDEX_ENH_2(pipe))

-:36: WARNING:LONG_LINE: line length of 109 exceeds 100 columns #36: FILE: drivers/gpu/drm/i915/i915_reg.h:6264:
+#define _PLANE_POST_CSC_GAMC_SEG0_DATA_ENH_1(pipe) _PIPE(pipe, _PLANE_POST_CSC_GAMC_SEG0_DATA_ENH_1_A, \

-:38: WARNING:LONG_LINE: line length of 109 exceeds 100 columns #38: FILE: drivers/gpu/drm/i915/i915_reg.h:6266:
+#define _PLANE_POST_CSC_GAMC_SEG0_DATA_ENH_2(pipe) _PIPE(pipe, _PLANE_POST_CSC_GAMC_SEG0_DATA_ENH_2_A, \

-:40: CHECK:MACRO_ARG_REUSE: Macro argument reuse 'pipe' - possible side-effects? #40: FILE: drivers/gpu/drm/i915/i915_reg.h:6268:
+#define PLANE_POST_CSC_GAMC_SEG0_DATA_ENH(pipe, plane, i) \
+ _MMIO_PLANE_GAMC(plane, i, _PLANE_POST_CSC_GAMC_SEG0_DATA_ENH_1(pipe), \
+ _PLANE_POST_CSC_GAMC_SEG0_DATA_ENH_2(pipe))

-:52: CHECK:MACRO_ARG_REUSE: Macro argument reuse 'pipe' - possible side-effects? #52: FILE: drivers/gpu/drm/i915/i915_reg.h:6280:
+#define PLANE_POST_CSC_GAMC_INDEX_ENH(pipe, plane, i) \
+ _MMIO_PLANE_GAMC(plane, i, _PLANE_POST_CSC_GAMC_INDEX_ENH_1(pipe), \
+ _PLANE_POST_CSC_GAMC_INDEX_ENH_2(pipe))

-:64: CHECK:MACRO_ARG_REUSE: Macro argument reuse 'pipe' - possible side-effects? #64: FILE: drivers/gpu/drm/i915/i915_reg.h:6292:
+#define PLANE_POST_CSC_GAMC_DATA_ENH(pipe, plane, i) \
+ _MMIO_PLANE_GAMC(plane, i, _PLANE_POST_CSC_GAMC_DATA_ENH_1(pipe), \
+ _PLANE_POST_CSC_GAMC_DATA_ENH_2(pipe))

-:76: CHECK:MACRO_ARG_REUSE: Macro argument reuse 'pipe' - possible side-effects? #76: FILE: drivers/gpu/drm/i915/i915_reg.h:6304:
+#define PLANE_POST_CSC_GAMC_INDEX(pipe, plane, i) \
+ _MMIO_PLANE_GAMC(plane, i, _PLANE_POST_CSC_GAMC_INDEX_1(pipe), \
+ _PLANE_POST_CSC_GAMC_INDEX_2(pipe))

-:88: CHECK:MACRO_ARG_REUSE: Macro argument reuse 'pipe' - possible side-effects? #88: FILE: drivers/gpu/drm/i915/i915_reg.h:6316:
+#define PLANE_POST_CSC_GAMC_DATA(pipe, plane, i) \
+ _MMIO_PLANE_GAMC(plane, i, _PLANE_POST_CSC_GAMC_DATA_1(pipe), \
+ _PLANE_POST_CSC_GAMC_DATA_2(pipe))

total: 0 errors, 4 warnings, 6 checks, 79 lines checked
bbc7184dc987 drm/i915/color: Program Pre-CSC registers
5fa8a6b271d9 drm/i915/xelpd: Program Plane Post CSC Registers 06e2f7349885 FIXME: force disable legacy plane color properties for TGL and beyond cbc4a0915bd3 drm/i915/color: Enable Plane Color Pipelines

#47 lore raw

✗ Fi.CI.BAT: failure for Plane Color Pipeline support for Intel platforms

In reply to Uma Shankar
== Series Details ==

== Series Details ==

Series: Plane Color Pipeline support for Intel platforms
URL : https://patchwork.freedesktop.org/series/129811/
State : failure

== Summary ==

CI Bug Log - changes from CI_DRM_14259 -> Patchwork_129811v1
====================================================

Summary
-------

**FAILURE**

Serious unknown changes coming with Patchwork_129811v1 absolutely need to be verified manually.

If you think the reported changes have nothing to do with the changes
introduced in Patchwork_129811v1, please notify your bug team ([email protected]) to allow them to document this new failure mode, which will reduce false positives in CI.

External URL: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_129811v1/index.html

Participating hosts (37 -> 37)
------------------------------

Additional (2): bat-kbl-2 fi-bsw-n3050
Missing (2): bat-atsm-1 fi-snb-2520m

Possible new issues
-------------------

Here are the unknown changes that may have been introduced in Patchwork_129811v1:

### IGT changes ###

#### Possible regressions ####

* igt@debugfs_test@read_all_entries:
- bat-adln-1: [PASS][1] -> [ABORT][2]
[1]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_14259/bat-adln-1/igt@debugfs_test@read_all_entries.html
[2]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_129811v1/bat-adln-1/igt@debugfs_test@read_all_entries.html
- bat-mtlp-8: [PASS][3] -> [ABORT][4]
[3]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_14259/bat-mtlp-8/igt@debugfs_test@read_all_entries.html
[4]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_129811v1/bat-mtlp-8/igt@debugfs_test@read_all_entries.html
- bat-dg2-8: [PASS][5] -> [ABORT][6]
[5]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_14259/bat-dg2-8/igt@debugfs_test@read_all_entries.html
[6]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_129811v1/bat-dg2-8/igt@debugfs_test@read_all_entries.html
- bat-adlm-1: [PASS][7] -> [ABORT][8]
[7]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_14259/bat-adlm-1/igt@debugfs_test@read_all_entries.html
[8]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_129811v1/bat-adlm-1/igt@debugfs_test@read_all_entries.html
- fi-tgl-1115g4: [PASS][9] -> [ABORT][10]
[9]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_14259/fi-tgl-1115g4/igt@debugfs_test@read_all_entries.html
[10]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_129811v1/fi-tgl-1115g4/igt@debugfs_test@read_all_entries.html
- bat-mtlp-6: [PASS][11] -> [ABORT][12]
[11]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_14259/bat-mtlp-6/igt@debugfs_test@read_all_entries.html
[12]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_129811v1/bat-mtlp-6/igt@debugfs_test@read_all_entries.html
- bat-dg1-7: [PASS][13] -> [ABORT][14]
[13]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_14259/bat-dg1-7/igt@debugfs_test@read_all_entries.html
[14]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_129811v1/bat-dg1-7/igt@debugfs_test@read_all_entries.html
- bat-adlp-9: [PASS][15] -> [ABORT][16]
[15]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_14259/bat-adlp-9/igt@debugfs_test@read_all_entries.html
[16]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_129811v1/bat-adlp-9/igt@debugfs_test@read_all_entries.html
- bat-adlp-6: [PASS][17] -> [ABORT][18]
[17]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_14259/bat-adlp-6/igt@debugfs_test@read_all_entries.html
[18]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_129811v1/bat-adlp-6/igt@debugfs_test@read_all_entries.html
- bat-rplp-1: [PASS][19] -> [ABORT][20]
[19]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_14259/bat-rplp-1/igt@debugfs_test@read_all_entries.html
[20]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_129811v1/bat-rplp-1/igt@debugfs_test@read_all_entries.html
- fi-rkl-11600: [PASS][21] -> [ABORT][22]
[21]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_14259/fi-rkl-11600/igt@debugfs_test@read_all_entries.html
[22]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_129811v1/fi-rkl-11600/igt@debugfs_test@read_all_entries.html
- bat-dg2-9: [PASS][23] -> [ABORT][24]
[23]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_14259/bat-dg2-9/igt@debugfs_test@read_all_entries.html
[24]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_129811v1/bat-dg2-9/igt@debugfs_test@read_all_entries.html
- bat-dg2-11: [PASS][25] -> [ABORT][26]
[25]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_14259/bat-dg2-11/igt@debugfs_test@read_all_entries.html
[26]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_129811v1/bat-dg2-11/igt@debugfs_test@read_all_entries.html

#### Suppressed ####

The following results come from untrusted machines, tests, or statuses. They do not affect the overall result.

* igt@debugfs_test@read_all_entries:
- {bat-arls-2}: [PASS][27] -> [ABORT][28]
[27]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_14259/bat-arls-2/igt@debugfs_test@read_all_entries.html
[28]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_129811v1/bat-arls-2/igt@debugfs_test@read_all_entries.html
- {bat-arls-1}: [PASS][29] -> [ABORT][30]
[29]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_14259/bat-arls-1/igt@debugfs_test@read_all_entries.html
[30]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_129811v1/bat-arls-1/igt@debugfs_test@read_all_entries.html
- {bat-dg2-14}: [PASS][31] -> [ABORT][32]
[31]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_14259/bat-dg2-14/igt@debugfs_test@read_all_entries.html
[32]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_129811v1/bat-dg2-14/igt@debugfs_test@read_all_entries.html

Known issues
------------

Here are the changes found in Patchwork_129811v1 that come from known issues:

### IGT changes ###

#### Issues hit ####

* igt@fbdev@info:
- bat-kbl-2: NOTRUN -> [SKIP][33] ([fdo#109271] / [i915#1849])
[33]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_129811v1/bat-kbl-2/igt@[email protected]

* igt@gem_lmem_swapping@parallel-random-engines:
- bat-kbl-2: NOTRUN -> [SKIP][34] ([fdo#109271]) +35 other tests skip
[34]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_129811v1/bat-kbl-2/igt@[email protected]

* igt@gem_lmem_swapping@random-engines:
- fi-bsw-n3050: NOTRUN -> [SKIP][35] ([fdo#109271]) +15 other tests skip
[35]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_129811v1/fi-bsw-n3050/igt@[email protected]

{name}: This element is suppressed. This means it is ignored when computing
the status of the difference (SUCCESS, WARNING, or FAILURE).

[fdo#109271]: https://bugs.freedesktop.org/show_bug.cgi?id=109271
[i915#1849]: https://gitlab.freedesktop.org/drm/intel/issues/1849

Build changes
-------------

* Linux: CI_DRM_14259 -> Patchwork_129811v1

CI-20190529: 20190529
CI_DRM_14259: e370df7a4fb4125cb8eee1b00ff1592808ed9786 @ git://anongit.freedesktop.org/gfx-ci/linux
IGT_7710: d87a5d85a60fba1283821d5212c3aece64cb36ba @ https://gitlab.freedesktop.org/drm/igt-gpu-tools.git
Patchwork_129811v1: e370df7a4fb4125cb8eee1b00ff1592808ed9786 @ git://anongit.freedesktop.org/gfx-ci/linux

### Linux commits

09bd0b77bbd7 drm/i915/color: Enable Plane Color Pipelines 017a6635e63a FIXME: force disable legacy plane color properties for TGL and beyond 0d31f207960c drm/i915/xelpd: Program Plane Post CSC Registers d334578ae216 drm/i915/color: Program Pre-CSC registers
4baac93472a4 drm/i915: Add register definitions for Plane Post CSC 0278b84fcddd drm/i915/color: Add framework to program PRE/POST CSC LUT 4adf845ffb39 drm/i915: Add register definitions for Plane Degamma e4e0ee51eb73 drm/i915/color: Add plane CTM callback for TGL and beyond 5b1e0ec4963a drm/i915/color: Add callbacks to set plane CTM 8bdc395f0722 drm/i915/color: Add framework to set colorop 84c0e602ec40 drm/i915/color: Add and attach COLORPIPELINE plane property dc4540d37dec drm/i915: Define segmented Lut and add capabilities to colorop 8e30794ef70e drm/i915/color: Create a transfer function color pipeline 38931bf215bf drm/i915/color: Add helper to create intel colorop 56c614667088 drm/i915/color: Add helper to allocate intel colorop ceccf2cc437e drm/i915: Add intel_color_op
915e9ad737a5 drm/i915: Add identifiers for intel color blocks 865ac81cf446 drm: Define helper for adding capability property for 1D LUT 15156b036a92 drm: Define helper to create color ops capability property 8735e9731b82 drm: Add Color ops capability property
3b9b4ac47724 drm: Add Color lut range attributes
02fa32164448 drm: Add 1D LUT color op
d1cc9fb15eb7 drm: Add Enhanced LUT precision structure
34744a006463 drm: Add support for 3x3 CTM
9dd4d733ccb9 drm: Fix error logging in set Color Pipeline eafdf30a77ef drm: handle NULL next colorop in drm_colorop_set_next_property dff6c0feb8bf drm: Add missing function declarations
3e7c4452d7f8 drm: color pipeline base work

== Logs ==

For more details see: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_129811v1/index.html

#48 lore raw
In reply to Uma Shankar
Quoted 75 lines · On Tue, 13 Feb 2024 12:18:07 +0530 Uma Shankar <[email protected]> wrote:

This series intends to add support for Plane Color Management for Intel platforms. This is based on the design which has been agreed upon by the community. Series implementing the design for generic DRM core has been sent out by Harry Wentland and is under review below:
https://patchwork.freedesktop.org/series/123446/

The base work of above series is squashed under 1 patch and support for Intel platform is added on top of it.
Any reviews on the original core design is expected to be done in Harry's series to avoid any forking of the discussion.

We have added some changes/fixes to the Harry's core DRM changes, being put up as separate patches on top of squashed patch. These are expected to get included in the main series from Harry once agreed upon.

Changes added on core design:
1. Below patches implement some fixes on original series
drm: Add missing function declarations
drm: handle NULL next colorop in drm_colorop_set_next_property
drm: Fix error logging in set Color Pipeline

2. Implemented a HW capability property to expose segmented luts.
drm: Add Color lut range attributes
drm: Add Color ops capability property
drm: Define helper to create color ops capability property
drm: Define helper for adding capability property for 1D LUT

This helps in generically defining the hardware lut capabilities, lut distribution, precision, segmented or PWL LUTS.

3. Added support for enhanced prescision, 3x3 matrix and 1d LUT:
drm: Add Enhanced LUT precision structure
drm: Add support for 3x3 CTM
drm: Add 1D LUT color op

On top of this base work for DRM core plane color pipeline design, implementation is done for Intel hardware platforms. Below patches include the same:

drm/i915: Add identifiers for intel color blocks
drm/i915: Add intel_color_op
drm/i915/color: Add helper to allocate intel colorop drm/i915/color: Add helper to create intel colorop drm/i915/color: Create a transfer function color pipeline drm/i915/color: Add and attach COLORPIPELINE plane property drm/i915/color: Add framework to set colorop drm/i915/color: Add callbacks to set plane CTM drm/i915/color: Add framework to program PRE/POST CSC LUT
FIXME: force disable legacy plane color properties for TGL and beyond drm/i915/color: Enable Plane Color Pipelines
drm/i915: Define segmented Lut and add capabilities to colorop drm/i915/color: Add plane CTM callback for TGL and beyond drm/i915: Add register definitions for Plane Degamma drm/i915: Add register definitions for Plane Post CSC drm/i915/color: Program Pre-CSC registers
drm/i915/xelpd: Program Plane Post CSC Registers

Bhanu from Intel will be sending out the igt changes to help test the color pipeline implementation based on the current igt changes sent out by Harry.
https://patchwork.freedesktop.org/series/123448/

Planned Next Steps:
1. Work with Harry and community and get DRM core changes for color pipeline merged.
2. Implement pipe color management (post blending) based on the current color pipeline design.
3. Work with compositor maintainers to get color processing implemented using display hardware, thereby avoid any GL or GPU shaders.

Thanks to all the community maintainers and contributors who have helped to get this support in upstream Linux. Looking forward to collaborate, work together and get this merged.

...

Quoted 21 lines

Chaitanya Kumar Borah (16):
drm: Add missing function declarations
drm: handle NULL next colorop in drm_colorop_set_next_property
drm: Fix error logging in set Color Pipeline
drm: Add support for 3x3 CTM
drm: Add 1D LUT color op
drm/i915: Add identifiers for intel color blocks
drm/i915: Add intel_color_op
drm/i915/color: Add helper to allocate intel colorop drm/i915/color: Add helper to create intel colorop drm/i915/color: Create a transfer function color pipeline drm/i915/color: Add and attach COLORPIPELINE plane property drm/i915/color: Add framework to set colorop drm/i915/color: Add callbacks to set plane CTM drm/i915/color: Add framework to program PRE/POST CSC LUT
FIXME: force disable legacy plane color properties for TGL and beyond drm/i915/color: Enable Plane Color Pipelines

Harry Wentland (1):
[NOT FOR REVIEW] drm: color pipeline base work

Quoted 12 lines

Uma Shankar (11):
drm: Add Enhanced LUT precision structure
drm: Add Color lut range attributes
drm: Add Color ops capability property
drm: Define helper to create color ops capability property
drm: Define helper for adding capability property for 1D LUT drm/i915: Define segmented Lut and add capabilities to colorop drm/i915/color: Add plane CTM callback for TGL and beyond drm/i915: Add register definitions for Plane Degamma drm/i915: Add register definitions for Plane Post CSC drm/i915/color: Program Pre-CSC registers drm/i915/xelpd: Program Plane Post CSC Registers

Hi Uma,

it is really hard for me to get a good picture of what this would result in from userspace perspective, which properties will exist with what values, but I didn't spot any fundamental UAPI design problems so far.

Thanks,
pq

#49 lore raw
Quoted 133 lines

-----Original Message-----
From: Pekka Paalanen <[email protected]>
Sent: Tuesday, February 13, 2024 4:32 PM
To: Shankar, Uma <[email protected]>
Cc: [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; Borah, Chaitanya Kumar <[email protected]>
Subject: Re: [PATCH 00/28] Plane Color Pipeline support for Intel platforms

Quoted 75 lines · On Tue, 13 Feb 2024 12:18:07 +0530 Uma Shankar <[email protected]> wrote:

This series intends to add support for Plane Color Management for Intel platforms. This is based on the design which has been agreed upon by the community. Series implementing the design for generic DRM core has been sent out by Harry Wentland and is under review below:
https://patchwork.freedesktop.org/series/123446/

The base work of above series is squashed under 1 patch and support for Intel platform is added on top of it.
Any reviews on the original core design is expected to be done in Harry's series to avoid any forking of the discussion.

We have added some changes/fixes to the Harry's core DRM changes, being put up as separate patches on top of squashed patch. These are expected to get included in the main series from Harry once agreed upon.

Changes added on core design:
1. Below patches implement some fixes on original series
drm: Add missing function declarations
drm: handle NULL next colorop in drm_colorop_set_next_property
drm: Fix error logging in set Color Pipeline

2. Implemented a HW capability property to expose segmented luts.
drm: Add Color lut range attributes
drm: Add Color ops capability property
drm: Define helper to create color ops capability property
drm: Define helper for adding capability property for 1D LUT

This helps in generically defining the hardware lut capabilities, lut distribution, precision, segmented or PWL LUTS.

3. Added support for enhanced prescision, 3x3 matrix and 1d LUT:
drm: Add Enhanced LUT precision structure
drm: Add support for 3x3 CTM
drm: Add 1D LUT color op

On top of this base work for DRM core plane color pipeline design, implementation is done for Intel hardware platforms. Below patches include the same:

drm/i915: Add identifiers for intel color blocks
drm/i915: Add intel_color_op
drm/i915/color: Add helper to allocate intel colorop drm/i915/color: Add helper to create intel colorop drm/i915/color: Create a transfer function color pipeline drm/i915/color: Add and attach COLORPIPELINE plane property drm/i915/color: Add framework to set colorop drm/i915/color: Add callbacks to set plane CTM drm/i915/color: Add framework to program PRE/POST CSC LUT
FIXME: force disable legacy plane color properties for TGL and beyond drm/i915/color: Enable Plane Color Pipelines
drm/i915: Define segmented Lut and add capabilities to colorop drm/i915/color: Add plane CTM callback for TGL and beyond drm/i915: Add register definitions for Plane Degamma drm/i915: Add register definitions for Plane Post CSC drm/i915/color: Program Pre-CSC registers
drm/i915/xelpd: Program Plane Post CSC Registers

Bhanu from Intel will be sending out the igt changes to help test the color pipeline implementation based on the current igt changes sent out by Harry.
https://patchwork.freedesktop.org/series/123448/

Planned Next Steps:
1. Work with Harry and community and get DRM core changes for color pipeline merged.
2. Implement pipe color management (post blending) based on the current color pipeline design.
3. Work with compositor maintainers to get color processing implemented using display hardware, thereby avoid any GL or GPU shaders.

Thanks to all the community maintainers and contributors who have helped to get this support in upstream Linux. Looking forward to collaborate, work together and get this merged.

...

Quoted 21 lines

Chaitanya Kumar Borah (16):
drm: Add missing function declarations
drm: handle NULL next colorop in drm_colorop_set_next_property
drm: Fix error logging in set Color Pipeline
drm: Add support for 3x3 CTM
drm: Add 1D LUT color op
drm/i915: Add identifiers for intel color blocks
drm/i915: Add intel_color_op
drm/i915/color: Add helper to allocate intel colorop drm/i915/color: Add helper to create intel colorop drm/i915/color: Create a transfer function color pipeline drm/i915/color: Add and attach COLORPIPELINE plane property drm/i915/color: Add framework to set colorop drm/i915/color: Add callbacks to set plane CTM drm/i915/color: Add framework to program PRE/POST CSC LUT
FIXME: force disable legacy plane color properties for TGL and beyond drm/i915/color: Enable Plane Color Pipelines

Harry Wentland (1):
[NOT FOR REVIEW] drm: color pipeline base work

Quoted 12 lines

Uma Shankar (11):
drm: Add Enhanced LUT precision structure
drm: Add Color lut range attributes
drm: Add Color ops capability property
drm: Define helper to create color ops capability property
drm: Define helper for adding capability property for 1D LUT drm/i915: Define segmented Lut and add capabilities to colorop drm/i915/color: Add plane CTM callback for TGL and beyond drm/i915: Add register definitions for Plane Degamma drm/i915: Add register definitions for Plane Post CSC drm/i915/color: Program Pre-CSC registers drm/i915/xelpd: Program Plane Post CSC Registers

Quoted 5 lines

Hi Uma,

it is really hard for me to get a good picture of what this would result in from userspace perspective, which properties will exist with what values, but I didn't spot any fundamental UAPI design problems so far.

Hi Pekka,
Original idea remains same from Harry's series, we just added 1 more property for advertising hw caps and added 2 additional color op types. Will update the documentation as well to make this clear and readable. We missed to add in this version.

Thanks for looking into the series and your valuable inputs.

Regards,
Uma Shankar

Quoted 3 lines

Thanks,
pq

#50 lore raw
In reply to Uma Shankar
Quoted 58 lines · Uma Shankar

This series intends to add support for Plane Color Management for Intel platforms. This is based on the design which has been agreed upon by the community. Series implementing the design for generic DRM core has been sent out by Harry Wentland and is under review below:
https://patchwork.freedesktop.org/series/123446/

The base work of above series is squashed under 1 patch and support for Intel platform is added on top of it.
Any reviews on the original core design is expected to be done in Harry's series to avoid any forking of the discussion.

We have added some changes/fixes to the Harry's core DRM changes, being put up as separate patches on top of squashed patch. These are expected to get included in the main series from Harry once agreed upon.

Changes added on core design:
1. Below patches implement some fixes on original series
drm: Add missing function declarations
drm: handle NULL next colorop in drm_colorop_set_next_property
drm: Fix error logging in set Color Pipeline

2. Implemented a HW capability property to expose segmented luts.
drm: Add Color lut range attributes
drm: Add Color ops capability property
drm: Define helper to create color ops capability property
drm: Define helper for adding capability property for 1D LUT

This helps in generically defining the hardware lut capabilities, lut distribution, precision, segmented or PWL LUTS.

3. Added support for enhanced prescision, 3x3 matrix and 1d LUT:
drm: Add Enhanced LUT precision structure
drm: Add support for 3x3 CTM
drm: Add 1D LUT color op

On top of this base work for DRM core plane color pipeline design, implementation is done for Intel hardware platforms. Below patches include the same:

drm/i915: Add identifiers for intel color blocks
drm/i915: Add intel_color_op
drm/i915/color: Add helper to allocate intel colorop drm/i915/color: Add helper to create intel colorop drm/i915/color: Create a transfer function color pipeline drm/i915/color: Add and attach COLORPIPELINE plane property drm/i915/color: Add framework to set colorop drm/i915/color: Add callbacks to set plane CTM drm/i915/color: Add framework to program PRE/POST CSC LUT
FIXME: force disable legacy plane color properties for TGL and beyond drm/i915/color: Enable Plane Color Pipelines
drm/i915: Define segmented Lut and add capabilities to colorop drm/i915/color: Add plane CTM callback for TGL and beyond drm/i915: Add register definitions for Plane Degamma drm/i915: Add register definitions for Plane Post CSC drm/i915/color: Program Pre-CSC registers
drm/i915/xelpd: Program Plane Post CSC Registers

Quoted 8 lines

Bhanu from Intel will be sending out the igt changes to help test the color pipeline implementation based on the current igt changes sent out by Harry.
https://patchwork.freedesktop.org/series/123448/

Planned Next Steps:
1. Work with Harry and community and get DRM core changes for color pipeline merged.

We'll need a userspace to implement support before merging, but we're working to enabling all color properties gamescope currently uses for the SteamDeck color management to the Color Pipeline API, which should help us get there. It's still a journey but I think the path is clear.

I'll send a new version of my patch series next week, including some AMD implementation (not the entire AMD pipeline yet).

We're also adding a 1D_LUT type that's much simpler, basically a copy of what the drm_crtc currently uses. One option is to keep both types, another is to see if AMD's LUT can be expressed using the caps that you define. I think it should be possible to express it as a single segment.

There might be another few changes in the core that might help you. Like seeing the value of the client cap in the driver.

It's really good to see your work. With that we'll have three driver
implementations: VKMS, Intel, AMD,, which shows broad usability of this approach.

Harry

Quoted 115 lines

2. Implement pipe color management (post blending) based on the current color pipeline design.
3. Work with compositor maintainers to get color processing implemented using display hardware, thereby avoid any GL or GPU shaders.

Thanks to all the community maintainers and contributors who have helped to get this support in upstream Linux. Looking forward to collaborate, work together and get this merged.

Cc Ville Syrjala <[email protected]>
Cc Pekka Paalanen <[email protected]>
Cc Simon Ser <[email protected]>
Cc Harry Wentland <[email protected]>
Cc Melissa Wen <[email protected]>
Cc Jonas Ådahl <[email protected]>
Cc Sebastian Wick <[email protected]>
Cc Shashank Sharma <[email protected]>
Cc Alexander Goins <[email protected]>
Cc Joshua Ashton <[email protected]>
Cc Michel Dänzer <[email protected]>
Cc Aleix Pol <[email protected]>
Cc Xaver Hugl <[email protected]>
Cc Victoria Brekenfeld <[email protected]>
Cc Naseer Ahmed <[email protected]>
Cc Christopher Braga <[email protected]>
Cc Abhinav Kumar <[email protected]>
Cc Arthur Grillo <[email protected]>
Cc Hector Martin <[email protected]>
Cc Liviu Dudau <[email protected]>
Cc Sasha McIntosh <[email protected]>
Cc Chaitanya Kumar Borah <[email protected]>

Chaitanya Kumar Borah (16):
drm: Add missing function declarations
drm: handle NULL next colorop in drm_colorop_set_next_property
drm: Fix error logging in set Color Pipeline
drm: Add support for 3x3 CTM
drm: Add 1D LUT color op
drm/i915: Add identifiers for intel color blocks
drm/i915: Add intel_color_op
drm/i915/color: Add helper to allocate intel colorop drm/i915/color: Add helper to create intel colorop drm/i915/color: Create a transfer function color pipeline drm/i915/color: Add and attach COLORPIPELINE plane property drm/i915/color: Add framework to set colorop drm/i915/color: Add callbacks to set plane CTM drm/i915/color: Add framework to program PRE/POST CSC LUT
FIXME: force disable legacy plane color properties for TGL and beyond drm/i915/color: Enable Plane Color Pipelines

Harry Wentland (1):
[NOT FOR REVIEW] drm: color pipeline base work

Uma Shankar (11):
drm: Add Enhanced LUT precision structure
drm: Add Color lut range attributes
drm: Add Color ops capability property
drm: Define helper to create color ops capability property
drm: Define helper for adding capability property for 1D LUT drm/i915: Define segmented Lut and add capabilities to colorop drm/i915/color: Add plane CTM callback for TGL and beyond drm/i915: Add register definitions for Plane Degamma drm/i915: Add register definitions for Plane Post CSC drm/i915/color: Program Pre-CSC registers drm/i915/xelpd: Program Plane Post CSC Registers

 Documentation/gpu/rfc/color_pipeline.rst      | 352 ++++++++
 drivers/gpu/drm/Makefile                      |   1 +
 drivers/gpu/drm/drm_atomic.c                  | 147 ++++
 drivers/gpu/drm/drm_atomic_helper.c           |  12 +
 drivers/gpu/drm/drm_atomic_state_helper.c     |   5 +
 drivers/gpu/drm/drm_atomic_uapi.c             | 170 ++++
 drivers/gpu/drm/drm_colorop.c                 | 335 ++++++++
 drivers/gpu/drm/drm_ioctl.c                   |   7 +
 drivers/gpu/drm/drm_mode_config.c             |   7 +
 drivers/gpu/drm/i915/display/intel_color.c    | 562 ++++++++++++
 drivers/gpu/drm/i915/display/intel_color.h    |  16 +
 .../drm/i915/display/intel_display_limits.h   |  13 +
 .../drm/i915/display/intel_display_types.h    |  17 +
 .../drm/i915/display/skl_universal_plane.c    |  19 +-
 drivers/gpu/drm/i915/i915_reg.h               | 124 +++
 drivers/gpu/drm/tests/Makefile                |   4 +-
 drivers/gpu/drm/tests/drm_fixp_test.c         |  69 ++
 drivers/gpu/drm/vkms/Kconfig                  |   5 +
 drivers/gpu/drm/vkms/Makefile                 |   4 +-
 drivers/gpu/drm/vkms/tests/.kunitconfig       |   4 +
 drivers/gpu/drm/vkms/tests/vkms_color_tests.c | 355 ++++++++
 drivers/gpu/drm/vkms/vkms_colorop.c           | 115 +++
 drivers/gpu/drm/vkms/vkms_composer.c          | 117 ++-
 drivers/gpu/drm/vkms/vkms_drv.h               |   8 +
 drivers/gpu/drm/vkms/vkms_luts.c              | 802 ++++++++++++++++++
 drivers/gpu/drm/vkms/vkms_luts.h              |  12 +
 drivers/gpu/drm/vkms/vkms_plane.c             |   2 +
 include/drm/drm_atomic.h                      |  87 ++
 include/drm/drm_atomic_uapi.h                 |   3 +
 include/drm/drm_color_mgmt.h                  |  23 +
 include/drm/drm_colorop.h                     | 274 ++++++
 include/drm/drm_file.h                        |   7 +
 include/drm/drm_fixed.h                       |  18 +
 include/drm/drm_mode_config.h                 |  18 +
 include/drm/drm_plane.h                       |  10 +
 include/uapi/drm/drm.h                        |  18 +
 include/uapi/drm/drm_mode.h                   |  83 ++
 37 files changed, 3815 insertions(+), 10 deletions(-)
 create mode 100644 Documentation/gpu/rfc/color_pipeline.rst
 create mode 100644 drivers/gpu/drm/drm_colorop.c
 create mode 100644 drivers/gpu/drm/tests/drm_fixp_test.c
 create mode 100644 drivers/gpu/drm/vkms/tests/.kunitconfig
 create mode 100644 drivers/gpu/drm/vkms/tests/vkms_color_tests.c
 create mode 100644 drivers/gpu/drm/vkms/vkms_colorop.c
 create mode 100644 drivers/gpu/drm/vkms/vkms_luts.c
 create mode 100644 drivers/gpu/drm/vkms/vkms_luts.h
 create mode 100644 include/drm/drm_colorop.h
#51 lore raw
Quoted 84 lines

-----Original Message-----
From: Harry Wentland <[email protected]>
Sent: Saturday, February 17, 2024 3:17 AM
To: Shankar, Uma <[email protected]>; [email protected]; dri- [email protected]
Cc: [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; Borah, Chaitanya Kumar <[email protected]>
Subject: Re: [PATCH 00/28] Plane Color Pipeline support for Intel platforms

Quoted 63 lines · Uma Shankar

This series intends to add support for Plane Color Management for Intel platforms. This is based on the design which has been agreed upon by the community. Series implementing the design for generic DRM core has been sent out by Harry Wentland and is under review below:
https://patchwork.freedesktop.org/series/123446/

The base work of above series is squashed under 1 patch and support for Intel platform is added on top of it.
Any reviews on the original core design is expected to be done in Harry's series to avoid any forking of the discussion.

We have added some changes/fixes to the Harry's core DRM changes, being put up as separate patches on top of squashed patch. These are expected to get included in the main series from Harry once agreed upon.

Changes added on core design:
1. Below patches implement some fixes on original series
drm: Add missing function declarations
drm: handle NULL next colorop in drm_colorop_set_next_property
drm: Fix error logging in set Color Pipeline

2. Implemented a HW capability property to expose segmented luts.
drm: Add Color lut range attributes
drm: Add Color ops capability property
drm: Define helper to create color ops capability property
drm: Define helper for adding capability property for 1D LUT

This helps in generically defining the hardware lut capabilities, lut distribution, precision, segmented or PWL LUTS.

3. Added support for enhanced prescision, 3x3 matrix and 1d LUT:
drm: Add Enhanced LUT precision structure
drm: Add support for 3x3 CTM
drm: Add 1D LUT color op

On top of this base work for DRM core plane color pipeline design, implementation is done for Intel hardware platforms. Below patches include the same:

drm/i915: Add identifiers for intel color blocks
drm/i915: Add intel_color_op
drm/i915/color: Add helper to allocate intel colorop drm/i915/color: Add helper to create intel colorop drm/i915/color: Create a transfer function color pipeline drm/i915/color: Add and attach COLORPIPELINE plane property drm/i915/color: Add framework to set colorop drm/i915/color: Add callbacks to set plane CTM drm/i915/color: Add framework to program PRE/POST CSC LUT
FIXME: force disable legacy plane color properties for TGL and beyond drm/i915/color: Enable Plane Color Pipelines
drm/i915: Define segmented Lut and add capabilities to colorop drm/i915/color: Add plane CTM callback for TGL and beyond drm/i915: Add register definitions for Plane Degamma drm/i915: Add register definitions for Plane Post CSC drm/i915/color: Program Pre-CSC registers
drm/i915/xelpd: Program Plane Post CSC Registers

Bhanu from Intel will be sending out the igt changes to help test the color pipeline implementation based on the current igt changes sent out by Harry.
https://patchwork.freedesktop.org/series/123448/

Quoted 8 lines
Quoted 3 lines

Planned Next Steps:
1. Work with Harry and community and get DRM core changes for color pipeline merged.

We'll need a userspace to implement support before merging, but we're working to enabling all color properties gamescope currently uses for the SteamDeck color management to the Color Pipeline API, which should help us get there. It's still a journey but I think the path is clear.

Yeah, thanks Harry for driving it.

Quoted 2 lines

I'll send a new version of my patch series next week, including some AMD implementation (not the entire AMD pipeline yet).

Oh ok, Nice.

One more input which can be considered:
Currently this is plane level color management (pre blending), can we make names of function also like that ? We can later work on pipe level color (post blending) on top of it without any major rework. Eventually this support will be needed for post blending as well (current properties will fall short on modern hardware).

Quoted 4 lines

We're also adding a 1D_LUT type that's much simpler, basically a copy of what the drm_crtc currently uses. One option is to keep both types, another is to see if AMD's LUT can be expressed using the caps that you define. I think it should be possible to express it as a single segment.

Yes, I believe it will be simple on AMD h/w to just add 1 segment with number of luts. This way we can generalize it for all multi segmented LUT usecases (like on Intel), this anyways will be needed as we currently don't have any way to expose these to userspace.

Quoted 2 lines

There might be another few changes in the core that might help you. Like seeing the value of the client cap in the driver.

Sure, we were also thinking that client caps may be useful. Will check your changes.

Quoted 3 lines

It's really good to see your work. With that we'll have three driver
implementations: VKMS, Intel, AMD,, which shows broad usability of this approach.

Surely this is a good step. We are step by step reaching there. Thanks Harry and all others who have helped to get this far.

Regards,
Uma Shankar

Quoted 117 lines

Harry

Quoted 115 lines

2. Implement pipe color management (post blending) based on the current color pipeline design.
3. Work with compositor maintainers to get color processing implemented using display hardware, thereby avoid any GL or GPU shaders.

Thanks to all the community maintainers and contributors who have helped to get this support in upstream Linux. Looking forward to collaborate, work together and get this merged.

Cc Ville Syrjala <[email protected]>
Cc Pekka Paalanen <[email protected]>
Cc Simon Ser <[email protected]>
Cc Harry Wentland <[email protected]>
Cc Melissa Wen <[email protected]>
Cc Jonas Ådahl <[email protected]>
Cc Sebastian Wick <[email protected]>
Cc Shashank Sharma <[email protected]>
Cc Alexander Goins <[email protected]>
Cc Joshua Ashton <[email protected]>
Cc Michel Dänzer <[email protected]>
Cc Aleix Pol <[email protected]>
Cc Xaver Hugl <[email protected]>
Cc Victoria Brekenfeld <[email protected]>
Cc Naseer Ahmed <[email protected]>
Cc Christopher Braga <[email protected]>
Cc Abhinav Kumar <[email protected]>
Cc Arthur Grillo <[email protected]>
Cc Hector Martin <[email protected]>
Cc Liviu Dudau <[email protected]>
Cc Sasha McIntosh <[email protected]>
Cc Chaitanya Kumar Borah <[email protected]>

Chaitanya Kumar Borah (16):
drm: Add missing function declarations
drm: handle NULL next colorop in drm_colorop_set_next_property
drm: Fix error logging in set Color Pipeline
drm: Add support for 3x3 CTM
drm: Add 1D LUT color op
drm/i915: Add identifiers for intel color blocks
drm/i915: Add intel_color_op
drm/i915/color: Add helper to allocate intel colorop drm/i915/color: Add helper to create intel colorop drm/i915/color: Create a transfer function color pipeline drm/i915/color: Add and attach COLORPIPELINE plane property drm/i915/color: Add framework to set colorop drm/i915/color: Add callbacks to set plane CTM drm/i915/color: Add framework to program PRE/POST CSC LUT
FIXME: force disable legacy plane color properties for TGL and beyond drm/i915/color: Enable Plane Color Pipelines

Harry Wentland (1):
[NOT FOR REVIEW] drm: color pipeline base work

Uma Shankar (11):
drm: Add Enhanced LUT precision structure
drm: Add Color lut range attributes
drm: Add Color ops capability property
drm: Define helper to create color ops capability property
drm: Define helper for adding capability property for 1D LUT drm/i915: Define segmented Lut and add capabilities to colorop drm/i915/color: Add plane CTM callback for TGL and beyond drm/i915: Add register definitions for Plane Degamma drm/i915: Add register definitions for Plane Post CSC drm/i915/color: Program Pre-CSC registers drm/i915/xelpd: Program Plane Post CSC Registers

 Documentation/gpu/rfc/color_pipeline.rst      | 352 ++++++++
 drivers/gpu/drm/Makefile                      |   1 +
 drivers/gpu/drm/drm_atomic.c                  | 147 ++++
 drivers/gpu/drm/drm_atomic_helper.c           |  12 +
 drivers/gpu/drm/drm_atomic_state_helper.c     |   5 +
 drivers/gpu/drm/drm_atomic_uapi.c             | 170 ++++
 drivers/gpu/drm/drm_colorop.c                 | 335 ++++++++
 drivers/gpu/drm/drm_ioctl.c                   |   7 +
 drivers/gpu/drm/drm_mode_config.c             |   7 +
 drivers/gpu/drm/i915/display/intel_color.c    | 562 ++++++++++++
 drivers/gpu/drm/i915/display/intel_color.h    |  16 +
 .../drm/i915/display/intel_display_limits.h   |  13 +
 .../drm/i915/display/intel_display_types.h    |  17 +
 .../drm/i915/display/skl_universal_plane.c    |  19 +-
 drivers/gpu/drm/i915/i915_reg.h               | 124 +++
 drivers/gpu/drm/tests/Makefile                |   4 +-
 drivers/gpu/drm/tests/drm_fixp_test.c         |  69 ++
 drivers/gpu/drm/vkms/Kconfig                  |   5 +
 drivers/gpu/drm/vkms/Makefile                 |   4 +-
 drivers/gpu/drm/vkms/tests/.kunitconfig       |   4 +
 drivers/gpu/drm/vkms/tests/vkms_color_tests.c | 355 ++++++++
 drivers/gpu/drm/vkms/vkms_colorop.c           | 115 +++
 drivers/gpu/drm/vkms/vkms_composer.c          | 117 ++-
 drivers/gpu/drm/vkms/vkms_drv.h               |   8 +
 drivers/gpu/drm/vkms/vkms_luts.c              | 802 ++++++++++++++++++
 drivers/gpu/drm/vkms/vkms_luts.h              |  12 +
 drivers/gpu/drm/vkms/vkms_plane.c             |   2 +
 include/drm/drm_atomic.h                      |  87 ++
 include/drm/drm_atomic_uapi.h                 |   3 +
 include/drm/drm_color_mgmt.h                  |  23 +
 include/drm/drm_colorop.h                     | 274 ++++++
 include/drm/drm_file.h                        |   7 +
 include/drm/drm_fixed.h                       |  18 +
 include/drm/drm_mode_config.h                 |  18 +
 include/drm/drm_plane.h                       |  10 +
 include/uapi/drm/drm.h                        |  18 +
 include/uapi/drm/drm_mode.h                   |  83 ++
 37 files changed, 3815 insertions(+), 10 deletions(-)  create mode
100644 Documentation/gpu/rfc/color_pipeline.rst
 create mode 100644 drivers/gpu/drm/drm_colorop.c  create mode 100644
drivers/gpu/drm/tests/drm_fixp_test.c
 create mode 100644 drivers/gpu/drm/vkms/tests/.kunitconfig
 create mode 100644 drivers/gpu/drm/vkms/tests/vkms_color_tests.c
 create mode 100644 drivers/gpu/drm/vkms/vkms_colorop.c
 create mode 100644 drivers/gpu/drm/vkms/vkms_luts.c  create mode

100644 drivers/gpu/drm/vkms/vkms_luts.h create mode 100644 include/drm/drm_colorop.h