Color Pipeline API w/ VKMS
Subsystems (6)
v11 cover Color Pipeline API w/ VKMS
This is an RFC set for a color pipeline API, along with implementations in VKMS and amdgpu. It is tested with a set of IGT tests that can be found at [1]. The IGT tests run a pixel-by-pixel comparison with an allowable delta variation as the goal for these transformations is perceptual correctness, not complete pixel accuracy.
v5 of this patchset fleshed out documentation for colorops and the various defines that are being introduced.
v6 addresses a few comments from various reviewers.
v7 simplifies 3D LUT and addresses more comments from various reviewers.
v8 fixes typo and errors and address comments from reviewers.
v9 refactors cleanup functions, fixes typo and errors, and addresses
comments from reviewers.
v10 add 32BIT RGB (drm_color_lut_32) to 1D & 3D LUTs, addresses comments
from reviewers, and fixes typo and errors.
v11 change names from *_lut_32_* to *_lut32_* and fix RGB 32bit
extractions.
VKMS supports two named transfer function colorops and two matrix colorops.
Amdgpu advertises the following pipeline for GPUs with DCN 3 or newer:
1. 1D Curve EOTF
2. 3x4 CTM
3. Multiplier
4. 1D Curve Inverse EOTF
5. 1D LUT
6. 3D LUT
7. 1D Curve EOTF
8. 1D LUT
The supported curves for the 1D Curve type are:
- sRGB EOTF and its inverse
- PQ EOTF, scaled to [0.0, 125.0] and its inverse
- BT.2020/BT.709 OETF and its inverse
Note that the 1st and 5th colorops take the EOTF or Inverse OETF while the 3rd colorop takes the Inverse EOTF or OETF.
The 3D LUT is a 17^3 tetrahedrally interpolated LUT but the mechanism exists for other drivers to describe their own 3D LUT capability.
This mirrors the color pipeline used by gamescope and presented by Melissa Wen, with the exception of the DEGAM LUT, which is not currently used. See [1]
https://indico.freedesktop.org/event/4/contributions/186/attachments/138/218/xdc2023-TheRainbowTreasureMap-MelissaWen.pdf
At this point we're hoping to see gamescope, kwin and weston implementations take shape. The existing pipeline should be enough to satisfy the gamescope use-cases on the drm_plane.
In order to support YUV we'll need to add COLOR_ENCODING and COLOR_RANGE support to the color pipeline. I have sketched these out already but don't have it all hooked up yet. This should not hinder adoption of this API for gaming use-cases.
We'll also want to advertise IN_FORMATS on a color pipeline as some color pipelines won't be able to work for all IN_FORMATS on a plane. Again, I have a sketch but no full implementation yet. This is not currently required by the AMD color pipeline and could be added after the merge of this set.
VKMS patches could still be improved in a few ways, though the payoff might be limited and I would rather focus on other work at the moment. The most obvious thing to improve would be to eliminate the hard-coded LUTs for identity, and sRGB, and replace them with fixed-point math instead.
There are plenty of things that I would like to see, but they could be added after the merge of this patchset:
- COLOR_ENCODING and COLOR_RANGE
- IN_FORMATS for a color pipeline
- Is it possible to support HW which can't bypass entire pipeline?
- Can we do a LOAD / COMMIT model for LUTs (and other properties)?
- read-only scaling colorop which defines scaling taps and position
- named matrices, for things like converting YUV to RGB
- Add custom LUT colorops to VKMS
IGT tests can be found at [1] or on the igt-dev mailing list. There have been no updates since v5 and rebase on latest main is straight- forward.
A kernel branch can be found at [2].
[1] https://gitlab.freedesktop.org/alex.hung/igt-gpu-tools/-/tree/amd-color-pipeline-v10
[2] https://gitlab.freedesktop.org/alex.hung/linux/-/tree/amd-color-pipeline-v11
v11:
- Refactor vkms_color_test_lerp() to parametized tests (Maíra Canal)
- Sort include file alphabetically (Maíra Canal)
- Skip color_encoding/range_property in drm_mode_object_get_properties when plane_color_pipeline is present (Harry Wentland)
- destroy function takes drm_device *dev instead of drm_plane *plane (Nícolas Prado)
- Fix undefined errors by EXPORT_SYMBOL symbols (kernel test robot)
- Fix comments to "2nd op 3x4 matrix" (Nícolas Prado)
- Update outdated "drm_rect_test_suite" to "drm_fixp_test_suite" (Maíra Canal)
- Update outdated MODULE_LICENSE to Dual MIT/GPL (Maíra Canal)
- Create color pipeline on supported hardware only (Melissa Wen)
- Update names from *_lut_32_* to *_lut32_* (Simon Ser)
- Include help function drm_color_lut32_extract (Uma Shankar)
- Remove redundant is_legacy from __drm_lut_32_to_dc_gamma (kernel bot)
- Fix RGB 32bit extraction from LUT (Xaver Hugl)
- Handle errors in __set_colorop_3dlut (Nícolas Prado)
- Merged enable condition for drm_crtc_enable_color_mgmt (Melissa Wen)
v10:
- remove duplicated "is useful" in comments (Melissa Wen)
- guard "dm_plane_init_colorops" function when !AMD_PRIVATE_COLOR (Melissa Wen)
- Replace DRM_ERROR by drm_err
- Creaet color pipeline when >= DCN_VERSION_3_0 (Melissa Wen)
- Relocate amdgpu_dm_supported_*_tfs check (Melissa Wen)
- Support 32BIT RGB for 1D LUTs (Uma Shankar)
- Support 32BIT RGB for 3D LUTs (Harry Wentland)
- Fix typo mutliplier to multiplier in subject (Melissa Wen)
- 1D & 3D LUTs are no longer immutable ((Xaver Hugl)
- Fix 3D LUT kernel doc (Leandro Ribeiro)
- Check dpp.hw_3d_lut before creating shaper tf/lut and 3dlut colorops (Melissa Wen)
- Disable CRTC degamma when color pipeline is enabled (Melissa Wen)
v9:
- Update RFC documents for 3DLUT and fallback behaviours (Simon Ser)
- Specify colorop function names by _plane_ (Chaitanya Kumar Borah)
- Remove redundant comments (Simon Ser)
- Fix typo in commit description (Shengyu Qu)
- Move destroy and cleanup functions earlier (Simon Ser)
- Move DRM_COLOROP_1D_CURVE_BT2020_* from middle to end (Simon Ser)
- Chagne "bool allow_bypass" to "uint32_t flags" for better extensibility (Simon Ser)
- Return a value in __set_dm_plane_colorop_3dlut
v8:
- Change VKMS config names (Louis Chauvet)
- Remove deprecated function "drm_atomic_get_existing_colorop_state" (Louis Chauvet)
- Remove null check in drm_colorop_set_next_property (Simon Ser)
- Remove MAX_COLOR_PIPELINES in drm (Simon Ser)
- Update kernel docs and documents for DRM_COLOROP_3D_LUT (Simon Ser)
- Add comments for dmr_color_lut (Louis Chauvet)
- Fix typos and replace DRM_ERROR and DRM_WARN_ONCE by drm_err drm_WARN_ONCE (Louis Chauvet)
- Fix incorrect conditions in __set_colorop_in_tf_1d_curve (Leo Li)
- Add DRM_MODE_PROP_ATOMIC to drm_property_create_range (Simon Ser)
- Change "1D Curve Custom LUT" to "1D LUT" (Simon Ser)
- Return error when __set_output_tf fails (Leo Li)
- Return -EINVAL when drm_color_ctm_3x4's size mismatches (Leo Li)
- Set initialized to 0 and return when drm_lut3d_size is 0 (Harry Wentland)
- Rework tf->type = TF_TYPE_BYPASS for shaper (Harry Wentland & Leo Li)
v7:
- Simplify 3D LUT by removing lut_3d_modes and update doc accordingly (Simon Ser)
- Add destroy / cleanup functions when color pipeline initialization fails (Louis Chauvet)
- Fix checkpatch errors and warning (spaces, long lines, {}, and etc)
- Change lut's size from drm_colorop_state->size to drm_colorop->lut_size and from size_property to lut_size_property
- Update some kernel updates and commit messagesa (Louis Chauvet)
- Squash "drm/colorop: Add atomic state print for drm_colorop" and "drm/colorop: Add NEXT to colorop state print" (Simon Ser)
- Add missing MODULE_DESCRIPTION (Jeff Johnson)
v6:
- Eliminate need to include test as .c file (Louis Chauvet)
- some doc updates
- cleanup if colorop alloc or init fails in VKMS and amdgpu (Louis Chauvet)
- couple other small improvements in VKMS, such as rounding (Louis Chauvet)
- take ref for DATA blob in duplicate_state func & fix refcount issues (Xaver Hugl)
v5:
- amdgpu 3D LUT
- Don't require BYPASS
- update RFC docs and add to TOC tree
- add drm_colorop and COLOR_PIPELINE kernel docs (non-RFC)
- add amdgpu color pipeline doc
- define SIZE property similar to drm_crtc's GAMMA_SIZE
- various minor fixes and cleanups
v4:
- Add amdgpu color pipeline (WIP)
- Don't block setting of deprecated properties, instead pass client cap to atomic check so drivers can ignore these props
- Drop IOCTL definitions (Pekka)
- Use enum property for colorop TYPE (Pekka)
- A few cleanups to the docs (Pekka)
- Rework the TYPE enum to name relation to avoid code duplication (Pekka)
- Add missing function declarations (Chaitanya Kumar Borah)
- Allow setting of NEXT property to NULL in _set_ function (Chaitanya Kumar Borah)
- Add helper for creation of pipeline drm_plane property (Pekka)
- Always create Bypass pipeline (Pekka)
- A bunch of changes to VKMS kunit tests (Pekka)
- Fix index in CTM doc (Pekka)
v3:
- Abandon IOCTLs and discover colorops as clients iterate the pipeline
- Remove need for libdrm
- Add color_pipeline client cap and make mutually exclusive with COLOR_RANGE and COLOR_ENCODING properties
- add CTM colorop to VKMS
- Use include way for kunit testing static functions (Arthur)
- Make TYPE a range property
- Move enum drm_colorop_type to uapi header
- and a bunch of smaller bits that are highlighted in the relevant commit description
v2:
- Rebased on drm-misc-next
- Introduce a VKMS Kunit so we can test LUT functionality in vkms_composer
- Incorporate feedback in color_pipeline.rst doc
- Add support for sRGB inverse EOTF
- Add 2nd enumerated TF colorop to VKMS
- Fix LUTs and some issues with applying LUTs in VKMS
Alex Hung (16):
drm/colorop: Add destroy functions for color pipeline drm/colorop: define a new macro for_each_new_colorop_in_state drm/amd/display: Skip color pipeline initialization for cursor plane drm/amd/display: Add support for sRGB EOTF in DEGAM block drm/amd/display: Add support for sRGB Inverse EOTF in SHAPER block drm/amd/display: Add support for sRGB EOTF in BLND block drm/colorop: Add 1D Curve Custom LUT type
drm/amd/display: add shaper and blend colorops for 1D Curve Custom LUT drm/amd/display: add 3x4 matrix colorop
drm/colorop: Add multiplier type
drm/amd/display: add multiplier colorop
drm/amd/display: Swap matrix and multiplier
drm/colorop: Add 3D LUT support to color pipeline drm/amd/display: add 3D LUT colorop
drm/amd/display: Ensure 3D LUT for color pipeline drm/amd/display: Disable CRTC degamma when color pipeline is enabled
Chaitanya Kumar Borah (1):
drm: Add helper to extract lut from struct drm_color_lut32
Harry Wentland (29):
drm: Add helper for conversion from signed-magnitude drm/vkms: Add kunit tests for VKMS LUT handling drm/doc/rfc: Describe why prescriptive color pipeline is needed drm/colorop: Introduce new drm_colorop mode object drm/colorop: Add TYPE property
drm/colorop: Add 1D Curve subtype
drm/colorop: Add BYPASS property
drm/colorop: Add NEXT property
drm/colorop: Add atomic state print for drm_colorop drm/plane: Add COLOR PIPELINE property
drm/colorop: Introduce DRM_CLIENT_CAP_PLANE_COLOR_PIPELINE Documentation/gpu: document drm_colorop
drm/vkms: Add enumerated 1D curve colorop
drm/vkms: Add kunit tests for linear and sRGB LUTs drm/colorop: Add 3x4 CTM type
drm/vkms: Use s32 for internal color pipeline precision drm/vkms: add 3x4 matrix in color pipeline
drm/tests: Add a few tests around drm_fixed.h
drm/vkms: Add tests for CTM handling
drm/colorop: pass plane_color_pipeline client cap to atomic check drm/amd/display: Ignore deprecated props when plane_color_pipeline set drm/amd/display: Add bypass COLOR PIPELINE
drm/colorop: Add PQ 125 EOTF and its inverse drm/amd/display: Enable support for PQ 125 EOTF and Inverse drm/colorop: add BT2020/BT709 OETF and Inverse OETF drm/amd/display: Add support for BT.709 and BT.2020 TFs drm/colorop: Define LUT_1D interpolation
drm/colorop: allow non-bypass colorops
drm/amd/display: Add AMD color pipeline doc
Uma Shankar (1):
drm: Add Enhanced LUT precision structure
Documentation/gpu/drm-kms.rst | 15 + Documentation/gpu/rfc/color_pipeline.rst | 378 ++++++++ Documentation/gpu/rfc/index.rst | 3 + drivers/gpu/drm/Makefile | 1 + .../gpu/drm/amd/display/amdgpu_dm/Makefile | 3 +- .../gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c | 4 + .../amd/display/amdgpu_dm/amdgpu_dm_color.c | 765 ++++++++++++++++- .../amd/display/amdgpu_dm/amdgpu_dm_colorop.c | 205 +++++ .../amd/display/amdgpu_dm/amdgpu_dm_colorop.h | 36 + .../amd/display/amdgpu_dm/amdgpu_dm_crtc.c | 26 +- .../amd/display/amdgpu_dm/amdgpu_dm_plane.c | 39 + drivers/gpu/drm/drm_atomic.c | 170 +++- drivers/gpu/drm/drm_atomic_helper.c | 12 + drivers/gpu/drm/drm_atomic_state_helper.c | 5 + drivers/gpu/drm/drm_atomic_uapi.c | 159 ++++ drivers/gpu/drm/drm_color_mgmt.c | 43 + drivers/gpu/drm/drm_colorop.c | 597 +++++++++++++ drivers/gpu/drm/drm_connector.c | 1 + drivers/gpu/drm/drm_crtc_internal.h | 1 + drivers/gpu/drm/drm_ioctl.c | 7 + drivers/gpu/drm/drm_mode_config.c | 7 + drivers/gpu/drm/drm_mode_object.c | 18 + drivers/gpu/drm/drm_plane.c | 59 ++ drivers/gpu/drm/tests/Makefile | 3 +- drivers/gpu/drm/tests/drm_fixp_test.c | 71 ++ drivers/gpu/drm/vkms/Makefile | 4 +- drivers/gpu/drm/vkms/tests/Makefile | 2 +- drivers/gpu/drm/vkms/tests/vkms_color_test.c | 417 +++++++++ drivers/gpu/drm/vkms/vkms_colorop.c | 115 +++ drivers/gpu/drm/vkms/vkms_composer.c | 134 ++- drivers/gpu/drm/vkms/vkms_composer.h | 27 + drivers/gpu/drm/vkms/vkms_drv.h | 7 + drivers/gpu/drm/vkms/vkms_luts.c | 811 ++++++++++++++++++ drivers/gpu/drm/vkms/vkms_luts.h | 12 + drivers/gpu/drm/vkms/vkms_plane.c | 2 + include/drm/drm_atomic.h | 111 +++ include/drm/drm_atomic_uapi.h | 3 + include/drm/drm_color_mgmt.h | 29 + include/drm/drm_colorop.h | 442 ++++++++++ include/drm/drm_file.h | 7 + include/drm/drm_fixed.h | 18 + include/drm/drm_mode_config.h | 18 + include/drm/drm_plane.h | 19 + include/uapi/drm/amdgpu_drm.h | 9 - include/uapi/drm/drm.h | 15 + include/uapi/drm/drm_mode.h | 134 +++ 46 files changed, 4900 insertions(+), 64 deletions(-) create mode 100644 Documentation/gpu/rfc/color_pipeline.rst create mode 100644 drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_colorop.c create mode 100644 drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_colorop.h 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/vkms_color_test.c create mode 100644 drivers/gpu/drm/vkms/vkms_colorop.c create mode 100644 drivers/gpu/drm/vkms/vkms_composer.h 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.43.0
PATCH v11 1/47 drm: Add helper for conversion from signed-magnitude
From: Harry Wentland <[email protected]>
CTM values are defined as signed-magnitude values. Add a helper that converts from CTM signed-magnitude fixed point value to the twos-complement value used by drm_fixed.
--- include/drm/drm_fixed.h | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+)
include/drm/drm_fixed.h +18 -0
@@ -78,6 +78,24 @@ static inline u32 dfixed_div(fixed20_12 A, fixed20_12 B)#define DRM_FIXED_EPSILON 1LL#define DRM_FIXED_ALMOST_ONE (DRM_FIXED_ONE - DRM_FIXED_EPSILON) +/** +* @drm_sm2fixp +* +* Convert a 1.31.32 signed-magnitude fixed point to 32.32 +* 2s-complement fixed point +* +* @return s64 2s-complement fixed point +*/ +static inline s64 drm_sm2fixp (__u64 a) +{ +if ((a & (1LL <<63 ))) { +return -(a &0x7fffffffffffffffll ); + }else { +return a; + } + +} +static inline s64 drm_int2fixp (int a) {return ((s64 )a) <<DRM_FIXED_POINT ;
Signature · 1 line
2.43.0
PATCH v11 2/47 drm/vkms: Add kunit tests for VKMS LUT handling
In reply to Alex HungFrom: Harry Wentland <[email protected]>
Debugging LUT math is much easier when we can unit test it. Add kunit functionality to VKMS and add tests for
- get_lut_index
- lerp_u16
---
v11:
- Refactor vkms_color_test_lerp() to parametized tests (Maíra Canal)
- Sort include file alphabetically (Maíra Canal)
v8:
- Update config names (Louis Chauvet)
v7:
- Fix checkpatch warnings and errors (Louis Chauvet)
- Change SPDX-License-Identifier: GPL-2.0+ from /* */ to //
- Fix checkpatch errors and warnings (new line at EOF, redundant spaces, and long lines)
- Add static to const struct vkms_color_lut test_linear_lut
- Add "MODULE_DESCRIPTION" (Jeff Johnson)
v6:
- Eliminate need to include test as .c file (Louis Chauvet)
v5:
- Bring back static for lerp_u16 and get_lut_index (Arthur)
v4:
- Test the critical points of the lerp function (Pekka)
v3:
- Use include way of testing static functions (Arthur)
drivers/gpu/drm/vkms/tests/Makefile | 2 +- drivers/gpu/drm/vkms/tests/vkms_color_test.c | 130 +++++++++++++++++++ drivers/gpu/drm/vkms/vkms_composer.c | 8 +- drivers/gpu/drm/vkms/vkms_composer.h | 13 ++ 4 files changed, 150 insertions(+), 3 deletions(-) create mode 100644 drivers/gpu/drm/vkms/tests/vkms_color_test.c create mode 100644 drivers/gpu/drm/vkms/vkms_composer.h
drivers/gpu/drm/vkms/tests/Makefile +1 -1
@@ -4,4 +4,4 @@ vkms-kunit-tests-y := \ vkms_config_test.o \ vkms_format_test.o -obj-$(CONFIG_DRM_VKMS_KUNIT_TEST) += vkms-kunit-tests.o +obj-$(CONFIG_DRM_VKMS_KUNIT_TEST) += vkms-kunit-tests.o vkms_config_test.o vkms_color_test.o
drivers/gpu/drm/vkms/tests/vkms_color_test.c new file +130 -0
130 lines not on this page · raw message
drivers/gpu/drm/vkms/vkms_composer.c +6 -2
@@ -10,7 +10,9 @@#include <drm/drm_gem_framebuffer_helper.h> #include <drm/drm_vblank.h> #include <linux/minmax.h> +#include <kunit/visibility.h> +#include "vkms_composer.h" #include "vkms_drv.h" static u16 pre_mul_blend_channel (u16 src,u16 dst,u16 alpha)
@@ -60,7 +62,7 @@ static void fill_background(const struct pixel_argb_u16 *background_color, }// lerp(a, b, t) = a + (b - a) * t -static u16 lerp_u16 (u16 a,u16 b,s64 t) +VISIBLE_IF_KUNIT u16 lerp_u16(u16 a, u16 b, s64 t) {s64 a_fp =drm_int2fixp (a);s64 b_fp =drm_int2fixp (b);
@@ -69,13 +71,15 @@ static u16 lerp_u16(u16 a, u16 b, s64 t)return drm_fixp2int_round (a_fp + delta); } +EXPORT_SYMBOL_IF_KUNIT (lerp_u16); -static s64 get_lut_index (const struct vkms_color_lut *lut,u16 channel_value) +VISIBLE_IF_KUNIT s64 get_lut_index(const struct vkms_color_lut *lut, u16 channel_value) {s64 color_channel_fp =drm_int2fixp (channel_value);return drm_fixp_mul (color_channel_fp, lut->channel_value2index_ratio); } +EXPORT_SYMBOL_IF_KUNIT (get_lut_index);/* * This enum is related to the positions of the variables inside
drivers/gpu/drm/vkms/vkms_composer.h new file +13 -0
@@ -0,0 +1,13 @@ +/* SPDX-License-Identifier: GPL-2.0+ */ + +#ifndef _VKMS_COMPOSER_H_ +#define _VKMS_COMPOSER_H_ + +#include <kunit/visibility.h> + +#if IS_ENABLED (CONFIG_KUNIT ) +u16 lerp_u16 (u16 a,u16 b,s64 t); +s64 get_lut_index (const struct vkms_color_lut *lut,u16 channel_value); +#endif + +#endif /* _VKMS_COMPOSER_H_ */
Signature · 1 line
2.43.0
kernel test robot
build botRe: [PATCH V11 02/47] drm/vkms: Add kunit tests for VKMS LUT handling
kernel test robot noticed the following build errors:
Hi Alex,
kernel test robot noticed the following build errors:
[auto build test ERROR on drm-exynos/exynos-drm-next]
[also build test ERROR on linus/master v6.17-rc1 next-20250815] [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/Alex-Hung/drm-Add-helper-for-conversion-from-signed-magnitude/20250815-120435 base: https://git.kernel.org/pub/scm/linux/kernel/git/daeinki/drm-exynos.git exynos-drm-next patch link: https://lore.kernel.org/r/20250815035047.3319284-3-alex.hung%40amd.com patch subject: [PATCH V11 02/47] drm/vkms: Add kunit tests for VKMS LUT handling config: arc-randconfig-001-20250816 (https://download.01.org/0day-ci/archive/20250816/[email protected]/config) compiler: arc-linux-gcc (GCC) 8.5.0 reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20250816/[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 error/warnings (new ones prefixed by >>):
In file included from drivers/gpu/drm/vkms/vkms_composer.c:15:
>> drivers/gpu/drm/vkms/vkms_composer.h:10:32: warning: 'struct vkms_color_lut' declared inside parameter list will not be visible outside of this definition or declaration
s64 get_lut_index(const struct vkms_color_lut *lut, u16 channel_value);
^~~~~~~~~~~~~~
>> drivers/gpu/drm/vkms/vkms_composer.c:76:22: error: conflicting types for 'get_lut_index'
VISIBLE_IF_KUNIT s64 get_lut_index(const struct vkms_color_lut *lut, u16 channel_value)
^~~~~~~~~~~~~
In file included from drivers/gpu/drm/vkms/vkms_composer.c:15:
drivers/gpu/drm/vkms/vkms_composer.h:10:5: note: previous declaration of 'get_lut_index' was here
s64 get_lut_index(const struct vkms_color_lut *lut, u16 channel_value);
^~~~~~~~~~~~~
In file included from include/linux/linkage.h:7,
from include/linux/preempt.h:10,
from include/linux/spinlock.h:56,
from include/drm/drm_crtc.h:28,
from include/drm/drm_atomic.h:31,
from drivers/gpu/drm/vkms/vkms_composer.c:5:
drivers/gpu/drm/vkms/vkms_composer.c:82:24: error: conflicting types for 'get_lut_index'
EXPORT_SYMBOL_IF_KUNIT(get_lut_index);
^~~~~~~~~~~~~
include/linux/export.h:76:21: note: in definition of macro '__EXPORT_SYMBOL'
extern typeof(sym) sym; \
^~~
include/kunit/visibility.h:27:44: note: in expansion of macro 'EXPORT_SYMBOL_NS'
#define EXPORT_SYMBOL_IF_KUNIT(symbol) EXPORT_SYMBOL_NS(symbol, "EXPORTED_FOR_KUNIT_TESTING")
^~~~~~~~~~~~~~~~
drivers/gpu/drm/vkms/vkms_composer.c:82:1: note: in expansion of macro 'EXPORT_SYMBOL_IF_KUNIT'
EXPORT_SYMBOL_IF_KUNIT(get_lut_index);
^~~~~~~~~~~~~~~~~~~~~~
In file included from drivers/gpu/drm/vkms/vkms_composer.c:15:
drivers/gpu/drm/vkms/vkms_composer.h:10:5: note: previous declaration of 'get_lut_index' was here
s64 get_lut_index(const struct vkms_color_lut *lut, u16 channel_value);
^~~~~~~~~~~~~vim +/get_lut_index +76 drivers/gpu/drm/vkms/vkms_composer.c
14
> 15 #include "vkms_composer.h"
16 #include "vkms_drv.h"
17
18 static u16 pre_mul_blend_channel(u16 src, u16 dst, u16 alpha)
19 {
20 u32 new_color;
21
22 new_color = (src * 0xffff + dst * (0xffff - alpha));
23
24 return DIV_ROUND_CLOSEST(new_color, 0xffff);
25 }
26
27 /**
28 * pre_mul_alpha_blend - alpha blending equation
29 * @stage_buffer: The line with the pixels from src_plane
30 * @output_buffer: A line buffer that receives all the blends output
31 * @x_start: The start offset
32 * @pixel_count: The number of pixels to blend
33 *
34 * The pixels [@x_start;@x_start+@pixel_count) in stage_buffer are blended at
35 * [@x_start;@x_start+@pixel_count) in output_buffer.
36 *
37 * The current DRM assumption is that pixel color values have been already
38 * pre-multiplied with the alpha channel values. See more
39 * drm_plane_create_blend_mode_property(). Also, this formula assumes a
40 * completely opaque background.
41 */
42 static void pre_mul_alpha_blend(const struct line_buffer *stage_buffer,
43 struct line_buffer *output_buffer, int x_start, int pixel_count)
44 {
45 struct pixel_argb_u16 *out = &output_buffer->pixels[x_start];
46 const struct pixel_argb_u16 *in = &stage_buffer->pixels[x_start];
47
48 for (int i = 0; i < pixel_count; i++) {
49 out[i].a = (u16)0xffff;
50 out[i].r = pre_mul_blend_channel(in[i].r, out[i].r, in[i].a);
51 out[i].g = pre_mul_blend_channel(in[i].g, out[i].g, in[i].a);
52 out[i].b = pre_mul_blend_channel(in[i].b, out[i].b, in[i].a);
53 }
54 }
55
56
57 static void fill_background(const struct pixel_argb_u16 *background_color,
58 struct line_buffer *output_buffer)
59 {
60 for (size_t i = 0; i < output_buffer->n_pixels; i++)
61 output_buffer->pixels[i] = *background_color;
62 }
63
64 // lerp(a, b, t) = a + (b - a) * t
65 VISIBLE_IF_KUNIT u16 lerp_u16(u16 a, u16 b, s64 t)
66 {
67 s64 a_fp = drm_int2fixp(a);
68 s64 b_fp = drm_int2fixp(b);
69
70 s64 delta = drm_fixp_mul(b_fp - a_fp, t);
71
72 return drm_fixp2int_round(a_fp + delta);
73 }
74 EXPORT_SYMBOL_IF_KUNIT(lerp_u16);
75
> 76 VISIBLE_IF_KUNIT s64 get_lut_index(const struct vkms_color_lut *lut, u16 channel_value)
77 {
78 s64 color_channel_fp = drm_int2fixp(channel_value);
79
80 return drm_fixp_mul(color_channel_fp, lut->channel_value2index_ratio);
81 }
82 EXPORT_SYMBOL_IF_KUNIT(get_lut_index);
83 Signature · 2 lines
0-DAY CI Kernel Test Service https://github.com/intel/lkp-tests/wiki
kernel test robot
build botRe: [PATCH V11 02/47] drm/vkms: Add kunit tests for VKMS LUT handling
In reply to Alex Hungkernel test robot noticed the following build warnings:
Hi Alex,
kernel test robot noticed the following build warnings:
[auto build test WARNING on drm-exynos/exynos-drm-next] [also build test WARNING on linus/master v6.17-rc1 next-20250815] [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/Alex-Hung/drm-Add-helper-for-conversion-from-signed-magnitude/20250815-120435 base: https://git.kernel.org/pub/scm/linux/kernel/git/daeinki/drm-exynos.git exynos-drm-next patch link: https://lore.kernel.org/r/20250815035047.3319284-3-alex.hung%40amd.com patch subject: [PATCH V11 02/47] drm/vkms: Add kunit tests for VKMS LUT handling config: x86_64-randconfig-074-20250816 (https://download.01.org/0day-ci/archive/20250816/[email protected]/config) compiler: gcc-12 (Debian 12.2.0-14+deb12u1) 12.2.0 reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20250816/[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/vkms/tests/vkms-kunit-tests.o: warning: objtool: file already has .orc_unwind section, skipping
Signature · 2 lines
0-DAY CI Kernel Test Service https://github.com/intel/lkp-tests/wiki
Louis Chauvet
maintainerRe: [PATCH V11 02/47] drm/vkms: Add kunit tests for VKMS LUT handling
In reply to Alex HungWith this modification it builds:
drivers/gpu/drm/vkms/vkms_composer.c +0 -1
@@ -13,7 +13,6 @@#include <kunit/visibility.h> #include "vkms_composer.h" -#include "vkms_drv.h" static u16 pre_mul_blend_channel (u16 src,u16 dst,u16 alpha) {
drivers/gpu/drm/vkms/vkms_composer.h +2 -0
@@ -5,6 +5,8 @@#include <kunit/visibility.h> +#include "vkms_drv.h" +#if IS_ENABLED (CONFIG_KUNIT )u16 lerp_u16 (u16 a,u16 b,s64 t);s64 get_lut_index (const struct vkms_color_lut *lut,u16 channel_value);
Le 15/08/2025 à 05:49, Alex Hung a écrit :
Quoted 12 lines
From: Harry Wentland <[email protected]>
Debugging LUT math is much easier when we can unit test it. Add kunit functionality to VKMS and add tests for
-get_lut_index
-lerp_u16Reviewed-by Louis Chauvet <[email protected]>Signed-off-by Alex Hung <[email protected]>Signed-off-by Harry Wentland <[email protected]>Cc Arthur Grillo <[email protected]>Reviewed-by Daniel Stone <[email protected]>
Quoted 4 lines
---
v11:
- Refactorvkms_color_test_lerp()to parametized tests (Maíra Canal)
- Sort include file alphabetically (Maíra Canal)
I think you forgot to re-order vkms_color_test.c includes (drv > composer)
Quoted 236 lines
v8:
- Update config names (Louis Chauvet)v7:
- Fix checkpatch warnings and errors (Louis Chauvet)
- Change SPDX-License-Identifier: GPL-2.0+ from /* */ to //
- Fix checkpatch errors and warnings (new line at EOF, redundant spaces, and long lines)
- Add static to const structvkms_color_luttest_linear_lut
- Add "MODULE_DESCRIPTION" (Jeff Johnson)v6:
- Eliminate need to include test as .c file (Louis Chauvet)v5:
- Bring back static forlerp_u16andget_lut_index(Arthur)v4:
- Test the critical points of the lerp function (Pekka)v3:
- Use include way of testing static functions (Arthur)drivers/gpu/drm/vkms/tests/Makefile | 2 +- drivers/gpu/drm/vkms/tests/vkms_color_test.c | 130 +++++++++++++++++++ drivers/gpu/drm/vkms/vkms_composer.c | 8 +- drivers/gpu/drm/vkms/vkms_composer.h | 13 ++ 4 files changed, 150 insertions(+), 3 deletions(-)create mode 100644
drivers/gpu/drm/vkms/tests/vkms_color_test.ccreate mode 100644drivers/gpu/drm/vkms/vkms_composer.hdrivers/gpu/drm/vkms/tests/Makefile +1
-1@@ -4,4 +4,4 @@ vkms-kunit-tests-y := \ vkms_config_test.o \ vkms_format_test.o -obj-$(CONFIG_DRM_VKMS_KUNIT_TEST) += vkms-kunit-tests.o +obj-$(CONFIG_DRM_VKMS_KUNIT_TEST) += vkms-kunit-tests.o vkms_config_test.o vkms_color_test.odrivers/gpu/drm/vkms/tests/vkms_color_test.c new file +130
-0@@ -0,0 +1,130 @@ +// SPDX-License-Identifier: GPL-2.0+ + +#include <kunit/test.h> + +#include <drm/drm_fixed.h> +#include <drm/drm_mode.h> +#include "../vkms_drv.h" +#include "../vkms_composer.h" + +#define TEST_LUT_SIZE 16 + +MODULE_IMPORT_NS ("EXPORTED_FOR_KUNIT_TESTING" ); + +static struct drm_color_lut test_linear_array[TEST_LUT_SIZE ] = { + {0x0 ,0x0 ,0x0 ,0 }, + {0x1111 ,0x1111 ,0x1111 ,0 }, + {0x2222 ,0x2222 ,0x2222 ,0 }, + {0x3333 ,0x3333 ,0x3333 ,0 }, + {0x4444 ,0x4444 ,0x4444 ,0 }, + {0x5555 ,0x5555 ,0x5555 ,0 }, + {0x6666 ,0x6666 ,0x6666 ,0 }, + {0x7777 ,0x7777 ,0x7777 ,0 }, + {0x8888 ,0x8888 ,0x8888 ,0 }, + {0x9999 ,0x9999 ,0x9999 ,0 }, + {0xaaaa ,0xaaaa ,0xaaaa ,0 }, + {0xbbbb ,0xbbbb ,0xbbbb ,0 }, + {0xcccc ,0xcccc ,0xcccc ,0 }, + {0xdddd ,0xdddd ,0xdddd ,0 }, + {0xeeee ,0xeeee ,0xeeee ,0 }, + {0xffff ,0xffff ,0xffff ,0 }, +}; + +/* lerp test parameters */ +struct vkms_color_test_lerp_params { +s64 t; +__u16 a; +__u16 b; +__u16 expected; +}; + +/* lerp test cases */ +static const struct vkms_color_test_lerp_params color_test_lerp_cases[] = { +/* Half-way round down */ + {0x80000000 -1 ,0x0 ,0x10 ,0x8 }, + {0x80000000 -1 ,0x1 ,0x10 ,0x8 },/* Odd a */ + {0x80000000 -1 ,0x1 ,0xf ,0x8 },/* Odd b */ + {0x80000000 -1 ,0x10 ,0x10 ,0x10 },/* b = a */ + {0x80000000 -1 ,0x10 ,0x11 ,0x10 },/* b = a + 1*/ +/* Half-way round up */ + {0x80000000 ,0x0 ,0x10 ,0x8 }, + {0x80000000 ,0x1 ,0x10 ,0x9 },/* Odd a */ + {0x80000000 ,0x1 ,0xf ,0x8 },/* Odd b */ + {0x80000000 ,0x10 ,0x10 ,0x10 },/* b = a */ + {0x80000000 ,0x10 ,0x11 ,0x11 },/* b = a + 1*/ +/* t = 0.0 */ + {0x0 ,0x0 ,0x10 ,0x0 }, + {0x0 ,0x1 ,0x10 ,0x1 },/* Odd a */ + {0x0 ,0x1 ,0xf ,0x1 },/* Odd b */ + {0x0 ,0x10 ,0x10 ,0x10 },/* b = a */ + {0x0 ,0x10 ,0x11 ,0x10 },/* b = a + 1*/ +/* t = 1.0 */ + {0x100000000 ,0x0 ,0x10 ,0x10 }, + {0x100000000 ,0x1 ,0x10 ,0x10 },/* Odd a */ + {0x100000000 ,0x1 ,0xf ,0xf },/* Odd b */ + {0x100000000 ,0x10 ,0x10 ,0x10 },/* b = a */ + {0x100000000 ,0x10 ,0x11 ,0x11 },/* b = a + 1*/ +/* t = 0.0 + 1 */ + {0x0 +1 ,0x0 ,0x10 ,0x0 }, + {0x0 +1 ,0x1 ,0x10 ,0x1 },/* Odd a */ + {0x0 +1 ,0x1 ,0xf ,0x1 },/* Odd b */ + {0x0 +1 ,0x10 ,0x10 ,0x10 },/* b = a */ + {0x0 +1 ,0x10 ,0x11 ,0x10 },/* b = a + 1*/ +/* t = 1.0 - 1 */ + {0x100000000 -1 ,0x0 ,0x10 ,0x10 }, + {0x100000000 -1 ,0x1 ,0x10 ,0x10 },/* Odd a */ + {0x100000000 -1 ,0x1 ,0xf ,0xf },/* Odd b */ + {0x100000000 -1 ,0x10 ,0x10 ,0x10 },/* b = a */ + {0x100000000 -1 ,0x10 ,0x11 ,0x11 },/* b = a + 1*/ +/* t chosen to verify the flipping point of result a (or b) to a+1 (or b-1) */ + {0x80000000 -1 ,0x0 ,0x1 ,0x0 }, + {0x80000000 ,0x0 ,0x1 ,0x1 }, +}; + +static const struct vkms_color_lut test_linear_lut = { + .base = test_linear_array, + .lut_length =TEST_LUT_SIZE , + .channel_value2index_ratio =0xf000fll +}; + + +static void vkms_color_test_get_lut_index (struct kunit *test) +{ +s64 lut_index; +int i; + + lut_index =get_lut_index (&test_linear_lut, test_linear_array[0 ].red); +KUNIT_EXPECT_EQ (test,drm_fixp2int (lut_index),0 ); + +for (i =0 ; i <TEST_LUT_SIZE ; i++) { + lut_index =get_lut_index (&test_linear_lut, test_linear_array[i].red); +KUNIT_EXPECT_EQ (test,drm_fixp2int_ceil (lut_index), i); + } +} + +static void vkms_color_test_lerp (struct kunit *test) +{ +int i; + +for (i =0 ; i <ARRAY_SIZE (color_test_lerp_cases); i++) { +const struct vkms_color_test_lerp_params *params = &color_test_lerp_cases[i]; + +KUNIT_EXPECT_EQ (test,lerp_u16 (params->a, params->b, params->t), params->expected); + } +} + +static struct kunit_case vkms_color_test_cases[] = { +KUNIT_CASE (vkms_color_test_get_lut_index), +KUNIT_CASE (vkms_color_test_lerp), + {} +}; + +static struct kunit_suite vkms_color_test_suite = { + .name ="vkms-color" , + .test_cases = vkms_color_test_cases, +}; + +kunit_test_suite (vkms_color_test_suite); + +MODULE_DESCRIPTION ("Kunit test for VKMS LUT handling" ); +MODULE_LICENSE ("GPL" );drivers/gpu/drm/vkms/vkms_composer.c +6
-2@@ -10,7 +10,9 @@#include <drm/drm_gem_framebuffer_helper.h> #include <drm/drm_vblank.h> #include <linux/minmax.h> +#include <kunit/visibility.h> +#include "vkms_composer.h" #include "vkms_drv.h" static u16 pre_mul_blend_channel (u16 src,u16 dst,u16 alpha)@@ -60,7 +62,7 @@ static void fill_background(const struct pixel_argb_u16 *background_color, }// lerp(a, b, t) = a + (b - a) * t -static u16 lerp_u16 (u16 a,u16 b,s64 t) +VISIBLE_IF_KUNIT u16 lerp_u16(u16 a, u16 b, s64 t) {s64 a_fp =drm_int2fixp (a);s64 b_fp =drm_int2fixp (b);@@ -69,13 +71,15 @@ static u16 lerp_u16(u16 a, u16 b, s64 t)return drm_fixp2int_round (a_fp + delta); } +EXPORT_SYMBOL_IF_KUNIT (lerp_u16); -static s64 get_lut_index (const struct vkms_color_lut *lut,u16 channel_value) +VISIBLE_IF_KUNIT s64 get_lut_index(const struct vkms_color_lut *lut, u16 channel_value) {s64 color_channel_fp =drm_int2fixp (channel_value);return drm_fixp_mul (color_channel_fp, lut->channel_value2index_ratio); } +EXPORT_SYMBOL_IF_KUNIT (get_lut_index);/* * This enum is related to the positions of the variables inside drivers/gpu/drm/vkms/vkms_composer.h new file +13
-0@@ -0,0 +1,13 @@ +/* SPDX-License-Identifier: GPL-2.0+ */ + +#ifndef _VKMS_COMPOSER_H_ +#define _VKMS_COMPOSER_H_ + +#include <kunit/visibility.h> + +#if IS_ENABLED (CONFIG_KUNIT ) +u16 lerp_u16 (u16 a,u16 b,s64 t); +s64 get_lut_index (const struct vkms_color_lut *lut,u16 channel_value); +#endif + +#endif /* _VKMS_COMPOSER_H_ */
Signature · 4 lines
-- Louis Chauvet, Bootlin Embedded Linux and Kernel engineering https://bootlin.com
PATCH v11 3/47 drm/doc/rfc: Describe why prescriptive color pipeline is needed
In reply to Alex HungFrom: Harry Wentland <[email protected]>
Add documentation for color pipeline API.
---
V9:
- Update documents according to new 3DLUT changes (Simon Ser)
- Spell out the behaviours when fallback to shaders/CPU (Simon Ser)
v8:
- Fix typo "definint" -> "defining"
v7:
- Add a commit messages
v5:
- Don't require BYPASS to succeed (Sebastian)
- use DATA for 1D and 3D LUT types (Sebastian)
- update 3DLUT ops to use 3DLUT_MODES and 3DLUT_MODE_INDEX
- Add section on drm_colorop extensibility
- Add color_pipeline.rst to RFC toc tree
v4:
- Drop IOCTL docs since we dropped the IOCTLs (Pekka)
- Clarify reading and setting of COLOR_PIPELINE prop (Pekka)
- Add blurb about not requiring to reject a pipeline due to incompatible ops, as long as op can be bypassed (Pekka)
- Dropped informational strings (such as input CSC) as they're not actually intended to be advertised (Pekka)
v3:
- Describe DRM_CLIENT_CAP_PLANE_COLOR_PIPELINE (Sebastian)
- Ask for clear documentation of colorop behavior (Sebastian)
v2:
- Update colorop visualizations to match reality (Sebastian, Alex Hung)
- Updated wording (Pekka)
- Change BYPASS wording to make it non-mandatory (Sebastian)
- Drop cover-letter-like paragraph from COLOR_PIPELINE Plane Property section (Pekka)
- Use PQ EOTF instead of its inverse in Pipeline Programming example (Melissa)
- Add "Driver Implementer's Guide" section (Pekka)
- Add "Driver Forward/Backward Compatibility" section (Sebastian, Pekka)
Documentation/gpu/rfc/color_pipeline.rst | 378 +++++++++++++++++++++++ Documentation/gpu/rfc/index.rst | 3 + 2 files changed, 381 insertions(+) create mode 100644 Documentation/gpu/rfc/color_pipeline.rst
Documentation/gpu/rfc/color_pipeline.rst new file +378 -0
@@ -0,0 +1,378 @@ +.. SPDX-License-Identifier: GPL-2.0 + +======================== +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. The switch between HW +fixed-function blocks and shaders/CPU must be seamless with no visible +difference when fallback to shaders/CPU is neceesary at any time. + + +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 +================== + +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. + +Each drm_colorop has three core properties: + +TYPE: An enumeration property, defining 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. 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} + ├─ "SIZE": immutable range = 4096 + ├─ "DATA": 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} + ├─ "SIZE": immutable range = 17 + ├─ "DATA": blob + └─ "NEXT": immutable color operation ID = 73 + +drm_colorop extensibility +------------------------- + +Unlike existing DRM core objects, like &drm_plane, drm_colorop is not +extensible. This simplifies implementations and keeps all functionality +for managing &drm_colorop objects in the DRM core. + +If there is a need one may introduce a simple &drm_colorop_funcs +function table in the future, for example to support an IN_FORMATS +property on a &drm_colorop. + +If a driver requires the ability to create a driver-specific colorop +object they will need to add &drm_colorop func table support with +support for the usual functions, like destroy, atomic_duplicate_state, +and atomic_destroy_state. + + +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 object id 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. + +NOTE: Many DRM clients will set enumeration properties via the string +value, often hard-coding it. Since this enumeration is generated based +on the colorop object IDs it is important to perform the Color Pipeline +Discovery, described below, instead of hard-coding color pipeline +assignment. Drivers might generate the enum strings dynamically. +Hard-coded strings might only work for specific drivers on a specific +pieces of HW. Color Pipeline Discovery can work universally, as long as +drivers implement the required color operations. + +The COLOR_PIPELINE property is only exposed when the +DRM_CLIENT_CAP_PLANE_COLOR_PIPELINE is set. Drivers shall ignore any +existing pre-blend color operations when this cap is set, such as +COLOR_RANGE and 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. + +Setting of the COLOR_PIPELINE plane property or drm_colorop properties +is only allowed for userspace that sets this client cap. + +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. Get the COLOR_PIPELINE property of the plane +2. iterate all COLOR_PIPELINE enum values +3. 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 + +If userspace encounters an unknown or unsuitable color operation during +discovery it does not need to reject the entire color pipeline outright, +as long as the unknown or unsuitable colorop has a "BYPASS" property. +Drivers will ensure that a bypassed block does not have any effect. + +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 + ├─ "DATA": 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 + ├─ "SIZE": immutable range = 4096 + ├─ "DATA": blob + └─ "NEXT" (immutable) = 48 + + Color operation 48 + ├─ "TYPE" (immutable) = 3D LUT + ├─ "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 (TEST_ONLY or not) atomic commit with all the other KMS + states it wishes to change + +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 + └─ "BYPASS" = true + + Color operation 44 + └─ "BYPASS" = true + + Color operation 45 + └─ "BYPASS" = true + + Color operation 46 + └─ "BYPASS" = true + + Color operation 47 + ├─ "DATA" = Gamut mapping + tone mapping + night mode + └─ "BYPASS" = false + + Color operation 48 + ├─ "CURVE_1D_TYPE" = PQ EOTF + └─ "BYPASS" = false + + +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 +bypassed 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/
Documentation/gpu/rfc/index.rst +3 -0
@@ -35,3 +35,6 @@ host such documentation: .. toctree:: i915_vm_bind.rst + +.. toctree:: + color_pipeline.rst
Signature · 1 line
2.43.0
PATCH v11 4/47 drm/colorop: Introduce new drm_colorop mode object
In reply to Alex HungFrom: Harry Wentland <[email protected]>
This patches introduces a new drm_colorop mode object. This object represents color transformations and can be used to define color pipelines.
We also introduce the drm_colorop_state here, as well as various helpers and state tracking bits.
---
v8:
- Remove drm_atomic_get_existing_colorop_state (Louis Chauvet)
v7:
- Fix checkpatch warnings and errors
- Add a tab to for_each_oldnew_colorop_in_state definition
- Change unsigned index to unsigned int index
- Fix a checkpatch warning - a new line after variable declaration
v6:
- Comment that properties validity depends on type (Louis Chauvet)
v5:
- Add comment to drm_atomic_state.colorops
- Replace a misplaced 'plane' with 'colorop' in comment
- Fix colorop_list kernel doc
- Add kernel doc for color_pipeline
- drop unused drm_colorop_destroy_state
- drop drm_colorop_init, to be introduced in later patch when used
- Add kernel docs
- Drop TODOs
v4:
- Drop IOCTL definitions (Pekka)
- add missing declaration (Chaitanya Kumar Borah)
v3:
- Drop TODO for lock (it's handled in drm_modeset_drop_locks) (Melissa)
- Don't get plane state when getting colorop state
- Make some functions static (kernel test robot)
drivers/gpu/drm/Makefile | 1 + drivers/gpu/drm/drm_atomic.c | 70 ++++++++++++ drivers/gpu/drm/drm_atomic_helper.c | 12 ++ drivers/gpu/drm/drm_atomic_uapi.c | 47 ++++++++ drivers/gpu/drm/drm_colorop.c | 104 +++++++++++++++++ drivers/gpu/drm/drm_mode_config.c | 7 ++ include/drm/drm_atomic.h | 70 ++++++++++++ include/drm/drm_atomic_uapi.h | 1 + include/drm/drm_colorop.h | 171 ++++++++++++++++++++++++++++ include/drm/drm_mode_config.h | 18 +++ include/drm/drm_plane.h | 8 ++ include/uapi/drm/drm_mode.h | 1 + 12 files changed, 510 insertions(+) create mode 100644 drivers/gpu/drm/drm_colorop.c create mode 100644 include/drm/drm_colorop.h
drivers/gpu/drm/Makefile +1 -0
@@ -41,6 +41,7 @@ drm-y := \ drm_bridge.o \ drm_cache.o \ drm_color_mgmt.o \ + drm_colorop.o \ drm_connector.o \ drm_crtc.o \ drm_displayid.o \
drivers/gpu/drm/drm_atomic.c +70 -0
100 lines not on this page · raw message
drivers/gpu/drm/drm_atomic_helper.c +12 -0
@@ -3182,6 +3182,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;
@@ -3259,6 +3261,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; + } +drm_panic_lock (state->dev, flags);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_uapi.c +47 -0
71 lines not on this page · raw message
drivers/gpu/drm/drm_colorop.c new file +104 -0
104 lines not on this page · raw message
drivers/gpu/drm/drm_mode_config.c +7 -0
@@ -30,6 +30,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"
@@ -192,11 +193,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);
@@ -437,6 +442,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 );
@@ -458,6 +464,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;
include/drm/drm_atomic.h +70 -0
106 lines not on this page · raw message
include/drm/drm_atomic_uapi.h +1 -0
@@ -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,
include/drm/drm_colorop.h new file +171 -0
171 lines not on this page · raw message
include/drm/drm_mode_config.h +18 -0
@@ -500,6 +500,24 @@ struct drm_mode_config {*/ struct raw_spinlock panic_lock; +/** +* @num_colorop: +* +* Number of colorop objects on this device. +* This is invariant over the lifetime of a device and hence doesn't +* need any locks. +*/ +int num_colorop; + +/** +* @colorop_list: +* +* List of colorop objects linked with &drm_colorop.head. This is +* invariant over the lifetime of a device and hence doesn't need any +* locks. +*/ +struct list_head colorop_list; +/** * @num_crtc: *
include/drm/drm_plane.h +8 -0
@@ -243,6 +243,14 @@ struct drm_plane_state {*/ enum drm_scaling_filter scaling_filter; +/** +* @color_pipeline: +* +* The first colorop of the active color pipeline, or NULL, if no +* color pipeline is active. +*/ +struct drm_colorop *color_pipeline; +/** * @commit: Tracks the pending commit to prevent use-after-free conditions, * and for async plane updates.
include/uapi/drm/drm_mode.h +1 -0
@@ -629,6 +629,7 @@ struct drm_mode_connector_set_property {#define DRM_MODE_OBJECT_FB 0xfbfbfbfb#define DRM_MODE_OBJECT_BLOB 0xbbbbbbbb#define DRM_MODE_OBJECT_PLANE 0xeeeeeeee +#define DRM_MODE_OBJECT_COLOROP 0xfafafafa#define DRM_MODE_OBJECT_ANY 0struct drm_mode_obj_get_properties {
Signature · 1 line
2.43.0
PATCH v11 5/47 drm/colorop: Add TYPE property
In reply to Alex HungFrom: Harry Wentland <[email protected]>
Add a read-only TYPE property. The TYPE specifies the colorop type, such as enumerated curve, 1D LUT, CTM, 3D LUT, PWL LUT, etc.
For now we're only introducing an enumerated 1D LUT type to illustrate the concept.
---
v6:
- fix doc typo (Alex Hung)
v5:
- Add drm_get_colorop_type_name in header
- Add kernel docs
v4:
- Use enum property for TYPE (Pekka)
v3:
- Make TYPE a range property
- Move enum drm_colorop_type to uapi header
- Fix drm_get_colorop_type_name description
drivers/gpu/drm/drm_atomic.c | 4 ++-- drivers/gpu/drm/drm_atomic_uapi.c | 8 +++++++- drivers/gpu/drm/drm_colorop.c | 12 ++++++++++++ include/drm/drm_colorop.h | 23 +++++++++++++++++++++++ include/uapi/drm/drm_mode.h | 19 +++++++++++++++++++ 5 files changed, 63 insertions(+), 3 deletions(-)
drivers/gpu/drm/drm_atomic.c +2 -2
@@ -631,8 +631,8 @@ drm_atomic_get_colorop_state(struct drm_atomic_state *state, state->colorops[index].new_state = colorop_state; colorop_state->state = state; -drm_dbg_atomic (colorop->dev,"Added [COLOROP:%d] %p state to %p\n" , - colorop->base.id, colorop_state, state); +drm_dbg_atomic (colorop->dev,"Added [COLOROP:%d:%d] %p state to %p\n" , + colorop->base.id, colorop->type, colorop_state, state);return colorop_state; }
drivers/gpu/drm/drm_atomic_uapi.c +7 -1
@@ -662,7 +662,13 @@ drm_atomic_colorop_get_property(struct drm_colorop *colorop,const struct drm_colorop_state *state, struct drm_property *property, uint64_t *val) { - return -EINVAL; + if (property == colorop->type_property) { + *val = colorop->type; + } else { +return -EINVAL ; + } + +return 0 ; } static int drm_atomic_set_writeback_fb_for_connector(
drivers/gpu/drm/drm_colorop.c +12 -0
@@ -102,3 +102,15 @@ void drm_colorop_reset(struct drm_colorop *colorop)if (colorop->state)__drm_colorop_reset (colorop, colorop->state); } + +static const char *const colorop_type_name[] = { + [DRM_COLOROP_1D_CURVE ] ="1D Curve" , +}; + +const char *drm_get_colorop_type_name (enum drm_colorop_type type) +{ +if (WARN_ON (type >=ARRAY_SIZE (colorop_type_name))) +return "unknown" ; + +return colorop_type_name[type]; +}
include/drm/drm_colorop.h +23 -0
@@ -112,6 +112,21 @@ struct drm_colorop {/** @properties: property tracking for this colorop */ struct drm_object_properties properties; +/** +* @type: +* +* Read-only +* Type of color operation +*/ +enum drm_colorop_type type; + +/** +* @type_property: +* +* Read-only "TYPE" property for specifying the type of +* this color operation. The type is enum drm_colorop_type. +*/ +struct drm_property *type_property; };#define obj_to_colorop (x) container_of(x, struct drm_colorop, base)
@@ -167,5 +182,13 @@ static inline unsigned int drm_colorop_index(const struct drm_colorop *colorop)#define drm_for_each_colorop (colorop, dev) \ list_for_each_entry(colorop, &(dev)->mode_config.colorop_list, head) +/** +* drm_get_colorop_type_name - return a string for colorop type +* @type: colorop type to compute name of +* +* In contrast to the other drm_get_*_name functions this one here returns a +* const pointer and hence is threadsafe. +*/ +const char *drm_get_colorop_type_name (enum drm_colorop_type type);#endif /* __DRM_COLOROP_H__ */
include/uapi/drm/drm_mode.h +19 -0
@@ -858,6 +858,25 @@ struct drm_color_lut {__u16 reserved; }; +/** +* enum drm_colorop_type - Type of color operation +* +* drm_colorops can be of many different types. Each type behaves differently +* and defines a different set of properties. This enum defines all types and +* gives a high-level description. +*/ +enum drm_colorop_type { +/** +* @DRM_COLOROP_1D_CURVE: +* +* enum string "1D Curve" +* +* A 1D curve that is being applied to all color channels. The +* curve is specified via the CURVE_1D_TYPE colorop property. +*/ +DRM_COLOROP_1D_CURVE +}; +/** * struct drm_plane_size_hint - Plane size hints * @width: The width of the plane in pixel
Signature · 1 line
2.43.0
PATCH v11 6/47 drm/colorop: Add 1D Curve subtype
In reply to Alex HungFrom: Harry Wentland <[email protected]>
Add a new drm_colorop with DRM_COLOROP_1D_CURVE with two subtypes:DRM_COLOROP_1D_CURVE_SRGB_EOTF and DRM_COLOROP_1D_CURVE_SRGB_INV_EOTF.
---
V9: Specify function names by _plane_ (Chaitanya Kumar Borah)
v5:
- Add drm_get_colorop_curve_1d_type_name in header
- Add drm_colorop_init
- Set default curve
- Add kernel docs
v4:
- Use drm_colorop_curve_1d_type_enum_list to get name (Pekka)
- Create separate init function for 1D curve
- Pass supported TFs into 1D curve init function
drivers/gpu/drm/drm_atomic_uapi.c | 18 ++-- drivers/gpu/drm/drm_colorop.c | 134 ++++++++++++++++++++++++++++++ include/drm/drm_colorop.h | 63 ++++++++++++++ 3 files changed, 210 insertions(+), 5 deletions(-)
drivers/gpu/drm/drm_atomic_uapi.c +13 -5
@@ -650,11 +650,17 @@ static int drm_atomic_colorop_set_property(struct drm_colorop *colorop, struct drm_colorop_state *state, struct drm_file *file_priv, struct drm_property *property, uint64_t val) { - drm_dbg_atomic(colorop->dev, -"[COLOROP:%d] unknown property [PROP:%d:%s]]\n" , - colorop->base.id, - property->base.id, property->name); -return -EINVAL ; + if (property == colorop->curve_1d_type_property) { + state->curve_1d_type = val; + } else { +drm_dbg_atomic (colorop->dev, +"[COLOROP:%d:%d] unknown property [PROP:%d:%s]]\n" , + colorop->base.id, colorop->type, + property->base.id, property->name); +return -EINVAL ; + } + +return 0 ; } static int
@@ -664,6 +670,8 @@ drm_atomic_colorop_get_property(struct drm_colorop *colorop, {if (property == colorop->type_property) { *val = colorop->type; + }else if (property == colorop->curve_1d_type_property) { + *val = state->curve_1d_type; }else {return -EINVAL ; }
drivers/gpu/drm/drm_colorop.c +134 -0
150 lines not on this page · raw message
include/drm/drm_colorop.h +63 -0
91 lines not on this page · raw message
Signature · 1 line
2.43.0
Re: [PATCH V11 06/47] drm/colorop: Add 1D Curve subtype
Quoted 239 lines · Alex Hung
From: Harry Wentland <[email protected]>
Add a new
drm_coloropwithDRM_COLOROP_1D_CURVEwith two subtypes:DRM_COLOROP_1D_CURVE_SRGB_EOTFandDRM_COLOROP_1D_CURVE_SRGB_INV_EOTF.Reviewed-by Simon Ser <[email protected]>Reviewed-by Louis Chauvet <[email protected]>Signed-off-by Harry Wentland <[email protected]>Co-developed-by Alex Hung <[email protected]>Signed-off-by Alex Hung <[email protected]>Reviewed-by Daniel Stone <[email protected]>Reviewed-by Melissa Wen <[email protected]>---
V9: Specify function names by _plane_ (Chaitanya Kumar Borah)v5:
- Adddrm_get_colorop_curve_1d_type_namein header
- Adddrm_colorop_init
- Set default curve
- Add kernel docsv4:
- Usedrm_colorop_curve_1d_type_enum_listto get name (Pekka)
- Create separate init function for 1D curve
- Pass supported TFs into 1D curve init functiondrivers/gpu/drm/drm_atomic_uapi.c | 18 ++-- drivers/gpu/drm/drm_colorop.c | 134 ++++++++++++++++++++++++++++++ include/drm/drm_colorop.h | 63 ++++++++++++++ 3 files changed, 210 insertions(+), 5 deletions(-)drivers/gpu/drm/drm_atomic_uapi.c +13
-5@@ -650,11 +650,17 @@ static int drm_atomic_colorop_set_property(struct drm_colorop *colorop, struct drm_colorop_state *state, struct drm_file *file_priv, struct drm_property *property, uint64_t val) { - drm_dbg_atomic(colorop->dev, -"[COLOROP:%d] unknown property [PROP:%d:%s]]\n" , - colorop->base.id, - property->base.id, property->name); -return -EINVAL ; + if (property == colorop->curve_1d_type_property) { + state->curve_1d_type = val; + } else { +drm_dbg_atomic (colorop->dev, +"[COLOROP:%d:%d] unknown property [PROP:%d:%s]]\n" , + colorop->base.id, colorop->type, + property->base.id, property->name); +return -EINVAL ; + } + +return 0 ; } static int@@ -664,6 +670,8 @@ drm_atomic_colorop_get_property(struct drm_colorop *colorop, {if (property == colorop->type_property) { *val = colorop->type; + }else if (property == colorop->curve_1d_type_property) { + *val = state->curve_1d_type; }else {return -EINVAL ; }drivers/gpu/drm/drm_colorop.c +134
-0@@ -31,6 +31,123 @@#include "drm_crtc_internal.h" +static const struct drm_prop_enum_list drm_colorop_type_enum_list[] = { + {DRM_COLOROP_1D_CURVE ,"1D Curve" }, +}; + +static const char *const colorop_curve_1d_type_names[] = { + [DRM_COLOROP_1D_CURVE_SRGB_EOTF ] ="sRGB EOTF" , + [DRM_COLOROP_1D_CURVE_SRGB_INV_EOTF ] ="sRGB Inverse EOTF" , +}; + + +/* Init Helpers */ + +static int drm_plane_colorop_init (struct drm_device *dev,struct drm_colorop *colorop, +struct drm_plane *plane,enum drm_colorop_type type) +{ +struct drm_mode_config *config = &dev->mode_config; +struct drm_property *prop; +int ret =0 ; + + ret =drm_mode_object_add (dev, &colorop->base,DRM_MODE_OBJECT_COLOROP ); +if (ret) +return ret; + + colorop->base.properties = &colorop->properties; + colorop->dev = dev; + colorop->type = type; + colorop->plane = plane; + +list_add_tail (&colorop->head, &config->colorop_list); + colorop->index = config->num_colorop++; + +/* add properties */ + +/* type */ + prop =drm_property_create_enum (dev, +DRM_MODE_PROP_IMMUTABLE , +"TYPE" , drm_colorop_type_enum_list, +ARRAY_SIZE (drm_colorop_type_enum_list)); + +if (!prop) +return -ENOMEM ; + + colorop->type_property = prop; + +drm_object_attach_property (&colorop->base, + colorop->type_property, + colorop->type); + +return ret; +} + +/** +* drm_plane_colorop_curve_1d_init - Initialize a DRM_COLOROP_1D_CURVE +* +* @dev: DRM device +* @colorop: The drm_colorop object to initialize +* @plane: The associated drm_plane +* @supported_tfs: A bitfield of supported drm_plane_colorop_curve_1d_init enum values, +* created using BIT(curve_type) and combined with the OR '|' +* operator. +* @return zero on success, -E value on failure +*/ +int drm_plane_colorop_curve_1d_init (struct drm_device *dev,struct drm_colorop *colorop, +struct drm_plane *plane,u64 supported_tfs) +{ +struct drm_prop_enum_list enum_list[DRM_COLOROP_1D_CURVE_COUNT ]; +int i, len; + +struct drm_property *prop; +int ret; + +if (!supported_tfs) { +drm_err (dev, +"No supported TFs for new 1D curve colorop on [PLANE:%d:%s]\n" , + plane->base.id, plane->name); +return -EINVAL ; + } + +if ((supported_tfs & -BIT (DRM_COLOROP_1D_CURVE_COUNT )) !=0 ) { +drm_err (dev,"Unknown TF provided on [PLANE:%d:%s]\n" , + plane->base.id, plane->name); +return -EINVAL ; + } + + ret =drm_plane_colorop_init (dev, colorop, plane,DRM_COLOROP_1D_CURVE ); +if (ret) +return ret; + + len =0 ; +for (i =0 ; i <DRM_COLOROP_1D_CURVE_COUNT ; i++) { +if ((supported_tfs &BIT (i)) ==0 ) +continue ; + + enum_list[len].type = i; + enum_list[len].name = colorop_curve_1d_type_names[i]; + len++; + } + +if (WARN_ON (len <=0 )) +return -EINVAL ; + + +/* initialize 1D curve only attribute */ + prop =drm_property_create_enum (dev,DRM_MODE_PROP_ATOMIC ,"CURVE_1D_TYPE" , + enum_list, len); +if (!prop) +return -ENOMEM ; + + colorop->curve_1d_type_property = prop; +drm_object_attach_property (&colorop->base, colorop->curve_1d_type_property, + enum_list[0 ].type); +drm_colorop_reset (colorop); + +return 0 ; +} +EXPORT_SYMBOL (drm_plane_colorop_curve_1d_init); +static void __drm_atomic_helper_colorop_duplicate_state (struct drm_colorop *colorop,struct drm_colorop_state *state) {@@ -70,7 +187,16 @@ void drm_colorop_atomic_destroy_state(struct drm_colorop *colorop,static void __drm_colorop_state_reset (struct drm_colorop_state *colorop_state,struct drm_colorop *colorop) { +u64 val; + colorop_state->colorop = colorop; + +if (colorop->curve_1d_type_property) { +drm_object_property_get_default_value (&colorop->base, + colorop->curve_1d_type_property, + &val); + colorop_state->curve_1d_type = val; + } }/** @@ -114,3 +240,11 @@ const char *drm_get_colorop_type_name(enum drm_colorop_type type)return colorop_type_name[type]; } + +const char *drm_get_colorop_curve_1d_type_name (enum drm_colorop_curve_1d_type type) +{ +if (WARN_ON (type >=ARRAY_SIZE (colorop_curve_1d_type_names))) +return "unknown" ; + +return colorop_curve_1d_type_names[type]; +}include/drm/drm_colorop.h +7
-0@@ -31,6 +31,42 @@#include <drm/drm_mode.h> #include <drm/drm_property.h> + +/** +* enum drm_colorop_curve_1d_type - type of 1D curve +* +* Describes a 1D curve to be applied by the DRM_COLOROP_1D_CURVE colorop. +*/ +enum drm_colorop_curve_1d_type {
include/drm/drm_colorop.h line 50
Quoted 10 lines
include/drm/drm_colorop.h +10
-0+/** +* @DRM_COLOROP_1D_CURVE_SRGB_EOTF: +* +* enum string "sRGB EOTF" +* +* sRGB piece-wise electro-optical transfer function. Transfer +* characteristics as defined by IEC 61966-2-1 sRGB. Equivalent +* to H.273 TransferCharacteristics code point 13 with +* MatrixCoefficients set to 0. +*/
We user space folks have been convinced at this point that the sRGB EOTF is actually gamma 2.2, and not the piece-wise function. Now, if the hardware is actually the piece-wise, then that's what should be exposed, but I'm a bit unsure if we should do that under the name sRGB EOTF.
Maybe any other alternative is even worse. At least this is clearly documented to be the piece-wise function, so it's only about the naming.
Quoted 75 lines
include/drm/drm_colorop.h +46
-0+DRM_COLOROP_1D_CURVE_SRGB_EOTF , + +/** +* @DRM_COLOROP_1D_CURVE_SRGB_INV_EOTF: +* +* enum string "sRGB Inverse EOTF" +* +* The inverse of &DRM_COLOROP_1D_CURVE_SRGB_EOTF +*/ +DRM_COLOROP_1D_CURVE_SRGB_INV_EOTF , + +/** +* @DRM_COLOROP_1D_CURVE_COUNT: +* +* enum value denoting the size of the enum +*/ + DRM_COLOROP_1D_CURVE_COUNT +}; +/** * struct drm_colorop_state - mutable colorop state */ @@ -46,6 +82,13 @@ struct drm_colorop_state {* information. */ +/** +* @curve_1d_type: +* +* Type of 1D curve. +*/ +enum drm_colorop_curve_1d_type curve_1d_type; +/** @state: backpointer to global drm_atomic_state */ struct drm_atomic_state *state; };@@ -127,6 +170,14 @@ struct drm_colorop {* this color operation. The type is enum drm_colorop_type. */ struct drm_property *type_property; + +/** +* @curve_1d_type_property: +* +* Sub-type for DRM_COLOROP_1D_CURVE type. +*/ +struct drm_property *curve_1d_type_property; + };#define obj_to_colorop (x) container_of(x, struct drm_colorop, base)@@ -151,6 +202,9 @@ static inline struct drm_colorop *drm_colorop_find(struct drm_device *dev,return mo ?obj_to_colorop (mo) :NULL ; } +int drm_plane_colorop_curve_1d_init (struct drm_device *dev,struct drm_colorop *colorop, +struct drm_plane *plane,u64 supported_tfs); +struct drm_colorop_state *drm_atomic_helper_colorop_duplicate_state (struct drm_colorop *colorop);@@ -191,4 +245,13 @@ static inline unsigned int drm_colorop_index(const struct drm_colorop *colorop)*/ const char *drm_get_colorop_type_name (enum drm_colorop_type type); +/** +* drm_get_colorop_curve_1d_type_name - return a string for 1D curve type +* @type: 1d curve type to compute name of +* +* In contrast to the other drm_get_*_name functions this one here returns a +* const pointer and hence is threadsafe. +*/ +const char *drm_get_colorop_curve_1d_type_name (enum drm_colorop_curve_1d_type type); +#endif /* __DRM_COLOROP_H__ */
Re: [PATCH V11 06/47] drm/colorop: Add 1D Curve subtype
Quoted 4 lines
We user space folks have been convinced at this point that the sRGB EOTF is actually gamma 2.2, and not the piece-wise function. Now, if the hardware is actually the piece-wise, then that's what should be exposed, but I'm a bit unsure if we should do that under the name sRGB EOTF.
Maybe simply rename the enum string to "sRGB piece-wise EOTF"? In hindsight, the naming of "srgb" in the Wayland protocol caused a lot of confusion, it's better to be explicit about it where possible.
Re: [PATCH V11 06/47] drm/colorop: Add 1D Curve subtype
Quoted 7 lines · Xaver Hugl
Quoted 4 lines
We user space folks have been convinced at this point that the sRGB EOTF is actually gamma 2.2, and not the piece-wise function. Now, if the hardware is actually the piece-wise, then that's what should be exposed, but I'm a bit unsure if we should do that under the name sRGB EOTF.
Maybe simply rename the enum string to "sRGB piece-wise EOTF"? In hindsight, the naming of "srgb" in the Wayland protocol caused a lot of confusion, it's better to be explicit about it where possible.
I will leave this to Harry to comment. He is taking a few days off so I will check with him later.
Re: [PATCH V11 06/47] drm/colorop: Add 1D Curve subtype
Quoted 5 lines · On Thu, 21 Aug 2025 11:54:32 -0600 Alex Hung <[email protected]> wrote:
Quoted 4 lines · Xaver Hugl
Quoted 4 lines
We user space folks have been convinced at this point that the sRGB EOTF is actually gamma 2.2, and not the piece-wise function. Now, if the hardware is actually the piece-wise, then that's what should be exposed, but I'm a bit unsure if we should do that under the name sRGB EOTF.
Quoted 7 lines
Quoted 3 lines
Maybe simply rename the enum string to "sRGB piece-wise EOTF"? In hindsight, the naming of "srgb" in the Wayland protocol caused a lot of confusion, it's better to be explicit about it where possible.
I will leave this to Harry to comment. He is taking a few days off so I will check with him later.
"sRGB inverse OETF"?
Strictly speaking "sRGB piece-wise EOTF" is not a thing AFAIU.
Thanks,
pq
Re: [PATCH V11 06/47] drm/colorop: Add 1D Curve subtype
Quoted 16 lines · Pekka Paalanen
Quoted 5 lines · On Thu, 21 Aug 2025 11:54:32 -0600 Alex Hung <[email protected]> wrote:
Quoted 4 lines · Xaver Hugl
Quoted 4 lines
We user space folks have been convinced at this point that the sRGB EOTF is actually gamma 2.2, and not the piece-wise function. Now, if the hardware is actually the piece-wise, then that's what should be exposed, but I'm a bit unsure if we should do that under the name sRGB EOTF.
Quoted 7 lines
Quoted 3 lines
Maybe simply rename the enum string to "sRGB piece-wise EOTF"? In hindsight, the naming of "srgb" in the Wayland protocol caused a lot of confusion, it's better to be explicit about it where possible.
I will leave this to Harry to comment. He is taking a few days off so I will check with him later.
Quoted 7 lines
"sRGB inverse OETF"?
Strictly speaking "sRGB piece-wise EOTF" is not a thing AFAIU.
Thanks,
pq
If an extension in future after this proposal is merged, can it be GAMMA 2.2 to be [DRM_COLOROP_1D_CURVE_GAMMA22] = "GAMMA 2.2" so it won't conflict with current name?
Meanwhile, do we agree to change "sRGB EOTF" as "sRGB Inverse OETF" as the following? or do we still want to add "piece-wise"?
drivers/gpu/drm/drm_colorop.c +1 -1
@@ -71,7 +71,7 @@ static const struct drm_prop_enum_list drm_colorop_type_enum_list[] = { };static const char *const colorop_curve_1d_type_names[] = { - [DRM_COLOROP_1D_CURVE_SRGB_EOTF ] ="sRGB EOTF" , + [DRM_COLOROP_1D_CURVE_SRGB_EOTF ] ="sRGB Inverse OETF" , [DRM_COLOROP_1D_CURVE_SRGB_INV_EOTF ] ="sRGB Inverse EOTF" , [DRM_COLOROP_1D_CURVE_PQ_125_EOTF ] ="PQ 125 EOTF" , [DRM_COLOROP_1D_CURVE_PQ_125_INV_EOTF ] ="PQ 125 Inverse EOTF" ,
include/drm/drm_colorop.h +1 -1
@@ -43,7 +43,7 @@ enum drm_colorop_curve_1d_type {/** * @DRM_COLOROP_1D_CURVE_SRGB_EOTF: * -* enum string "sRGB EOTF" +* enum string "sRGB Inverse OETF" * * sRGB piece-wise electro-optical transfer function. Transfer * characteristics as defined by IEC 61966-2-1 sRGB. Equivalent
Re: [PATCH V11 06/47] drm/colorop: Add 1D Curve subtype
Quoted 25 lines · On Tue, 16 Sep 2025 17:01:07 -0600 Alex Hung <[email protected]> wrote:
Quoted 16 lines · Pekka Paalanen
Quoted 5 lines · On Thu, 21 Aug 2025 11:54:32 -0600 Alex Hung <[email protected]> wrote:
Quoted 4 lines · Xaver Hugl
Quoted 4 lines
We user space folks have been convinced at this point that the sRGB EOTF is actually gamma 2.2, and not the piece-wise function. Now, if the hardware is actually the piece-wise, then that's what should be exposed, but I'm a bit unsure if we should do that under the name sRGB EOTF.
Quoted 7 lines
Quoted 3 lines
Maybe simply rename the enum string to "sRGB piece-wise EOTF"? In hindsight, the naming of "srgb" in the Wayland protocol caused a lot of confusion, it's better to be explicit about it where possible.
I will leave this to Harry to comment. He is taking a few days off so I will check with him later.
Quoted 7 lines
"sRGB inverse OETF"?
Strictly speaking "sRGB piece-wise EOTF" is not a thing AFAIU.
Thanks,
pq
Quoted 6 lines
If an extension in future after this proposal is merged, can it be GAMMA 2.2 to be [
DRM_COLOROP_1D_CURVE_GAMMA22] = "GAMMA 2.2" so it won't conflict with current name?Meanwhile, do we agree to change "sRGB EOTF" as "sRGB Inverse OETF" as the following? or do we still want to add "piece-wise"?
Hi Alex,
since my previous comment, things have muddied further again. FWIW, we intend to remove the use of the name "srgb" transfer function completely from the Wayland protocol as confusing:
https://gitlab.freedesktop.org/wayland/wayland-protocols/-/merge_requests/442
I would recommend the KMS UAPI to similarly avoid the term. I would recommend "gamma 2.2" or even "power 2.2" and "compound power 2.4" or such. These names would hopefully not trigger intuition and make people look at the definition harder. Or any other name you can come up with.
I agree that "piece-wise sRGB EOTF" would be intuitively clear, but it may provoke people debating what does IEC 61966-2-1 actually define. We've had these kind of discussions for Wayland already, and it was suggested that it is better to define the actual mathematical function in our specification that to leave it for interpretation from standards.
For KMS, this should be even easier than for Wayland, because the hardware implements a specific mathematical function regardless of where it might have originated or what it is being used for.
Thanks,
pq
Quoted 28 lines
drivers/gpu/drm/drm_colorop.c +1
-1@@ -71,7 +71,7 @@ static const struct drm_prop_enum_list drm_colorop_type_enum_list[] = { };static const char *const colorop_curve_1d_type_names[] = { - [DRM_COLOROP_1D_CURVE_SRGB_EOTF ] ="sRGB EOTF" , + [DRM_COLOROP_1D_CURVE_SRGB_EOTF ] ="sRGB Inverse OETF" , [DRM_COLOROP_1D_CURVE_SRGB_INV_EOTF ] ="sRGB Inverse EOTF" , [DRM_COLOROP_1D_CURVE_PQ_125_EOTF ] ="PQ 125 EOTF" ,[
DRM_COLOROP_1D_CURVE_PQ_125_INV_EOTF] = "PQ 125 Inverse EOTF",include/drm/drm_colorop.h +1
-1@@ -43,7 +43,7 @@ enum drm_colorop_curve_1d_type {/** * @DRM_COLOROP_1D_CURVE_SRGB_EOTF: * -* enum string "sRGB EOTF" +* enum string "sRGB Inverse OETF" * * sRGB piece-wise electro-optical transfer function. Transfer * characteristics as defined by IEC 61966-2-1 sRGB. Equivalent
Re: [PATCH V11 06/47] drm/colorop: Add 1D Curve subtype
Quoted 54 lines · Pekka Paalanen
Quoted 25 lines · On Tue, 16 Sep 2025 17:01:07 -0600 Alex Hung <[email protected]> wrote:
Quoted 16 lines · Pekka Paalanen
Quoted 5 lines · On Thu, 21 Aug 2025 11:54:32 -0600 Alex Hung <[email protected]> wrote:
Quoted 4 lines · Xaver Hugl
Quoted 4 lines
We user space folks have been convinced at this point that the sRGB EOTF is actually gamma 2.2, and not the piece-wise function. Now, if the hardware is actually the piece-wise, then that's what should be exposed, but I'm a bit unsure if we should do that under the name sRGB EOTF.
Quoted 7 lines
Quoted 3 lines
Maybe simply rename the enum string to "sRGB piece-wise EOTF"? In hindsight, the naming of "srgb" in the Wayland protocol caused a lot of confusion, it's better to be explicit about it where possible.
I will leave this to Harry to comment. He is taking a few days off so I will check with him later.
Quoted 7 lines
"sRGB inverse OETF"?
Strictly speaking "sRGB piece-wise EOTF" is not a thing AFAIU.
Thanks,
pqQuoted 6 lines
If an extension in future after this proposal is merged, can it be GAMMA 2.2 to be [
DRM_COLOROP_1D_CURVE_GAMMA22] = "GAMMA 2.2" so it won't conflict with current name?Meanwhile, do we agree to change "sRGB EOTF" as "sRGB Inverse OETF" as the following? or do we still want to add "piece-wise"?
Hi Alex,
since my previous comment, things have muddied further again. FWIW, we intend to remove the use of the name "srgb" transfer function completely from the Wayland protocol as confusing:
https://gitlab.freedesktop.org/wayland/wayland-protocols/-/merge_requests/442
I would recommend the KMS UAPI to similarly avoid the term. I would recommend "gamma 2.2" or even "power 2.2" and "compound power 2.4" or such. These names would hopefully not trigger intuition and make people look at the definition harder. Or any other name you can come up with.
I agree that "piece-wise sRGB EOTF" would be intuitively clear, but it may provoke people debating what does IEC 61966-2-1 actually define. We've had these kind of discussions for Wayland already, and it was suggested that it is better to define the actual mathematical function in our specification that to leave it for interpretation from standards.
Quoted 4 lines
For KMS, this should be even easier than for Wayland, because the hardware implements a specific mathematical function regardless of where it might have originated or what it is being used for.
Do you mean the following changes? Userspace use Gamma 2.2, and display driver can decide to use either sRGB piece-wise EOTF or Gamma 2.2 itself.
drivers/gpu/drm/drm_colorop.c +1 -1
@@ -71,7 +71,7 @@ static const struct drm_prop_enum_list drm_colorop_type_enum_list[] = { };static const char *const colorop_curve_1d_type_names[] = { - [DRM_COLOROP_1D_CURVE_SRGB_EOTF ] ="sRGB EOTF" , + [DRM_COLOROP_1D_CURVE_SRGB_EOTF ] ="Gamma 2.2" , [DRM_COLOROP_1D_CURVE_SRGB_INV_EOTF ] ="sRGB Inverse EOTF" , [DRM_COLOROP_1D_CURVE_PQ_125_EOTF ] ="PQ 125 EOTF" , [DRM_COLOROP_1D_CURVE_PQ_125_INV_EOTF ] ="PQ 125 Inverse EOTF" ,
include/drm/drm_colorop.h +2 -1
@@ -48,7 +48,8 @@ enum drm_colorop_curve_1d_type {* sRGB piece-wise electro-optical transfer function. Transfer * characteristics as defined by IEC 61966-2-1 sRGB. Equivalent * to H.273 TransferCharacteristics code point 13 with -* MatrixCoefficients set to 0. +* MatrixCoefficients set to 0. This can also be approximated as +* Gamma 2.2. */ DRM_COLOROP_1D_CURVE_SRGB_EOTF,
It is also possible to add GAMMA 2.2 in addition to sRGB piece-wise EOTF. But if I understand correctly, DRM_COLOROP_1D_CURVE_SRGB_EOTF may not be used at all, right?
drivers/gpu/drm/drm_colorop.c +1 -0
@@ -77,6 +77,7 @@ static const char * const colorop_curve_1d_type_names[] = { [DRM_COLOROP_1D_CURVE_SRGB_EOTF] = "sRGB EOTF", [DRM_COLOROP_1D_CURVE_PQ_125_INV_EOTF] = "PQ 125 Inverse EOTF", [DRM_COLOROP_1D_CURVE_BT2020_INV_OETF] = "BT.2020 Inverse OETF", [DRM_COLOROP_1D_CURVE_BT2020_OETF] = "BT.2020 OETF", + [DRM_COLOROP_1D_CURVE_GAMMA22] = "Gamma 2.2", };
Does anyone have comments or concerns if we use the first option?
Alex H.
Quoted 33 lines
Thanks,
pqQuoted 28 lines
drivers/gpu/drm/drm_colorop.c +1
-1@@ -71,7 +71,7 @@ static const struct drm_prop_enum_list drm_colorop_type_enum_list[] = { };static const char *const colorop_curve_1d_type_names[] = { - [DRM_COLOROP_1D_CURVE_SRGB_EOTF ] ="sRGB EOTF" , + [DRM_COLOROP_1D_CURVE_SRGB_EOTF ] ="sRGB Inverse OETF" , [DRM_COLOROP_1D_CURVE_SRGB_INV_EOTF ] ="sRGB Inverse EOTF" , [DRM_COLOROP_1D_CURVE_PQ_125_EOTF ] ="PQ 125 EOTF" ,[DRM_COLOROP_1D_CURVE_PQ_125_INV_EOTF] = "PQ 125 Inverse EOTF",include/drm/drm_colorop.h +1
-1@@ -43,7 +43,7 @@ enum drm_colorop_curve_1d_type {/** * @DRM_COLOROP_1D_CURVE_SRGB_EOTF: * -* enum string "sRGB EOTF" +* enum string "sRGB Inverse OETF" * * sRGB piece-wise electro-optical transfer function. Transfer * characteristics as defined by IEC 61966-2-1 sRGB. Equivalent
Re: [PATCH V11 06/47] drm/colorop: Add 1D Curve subtype
Quoted 55 lines · On Mon, 22 Sep 2025 21:16:45 -0600 Alex Hung <[email protected]> wrote:
Quoted 54 lines · Pekka Paalanen
Quoted 25 lines · On Tue, 16 Sep 2025 17:01:07 -0600 Alex Hung <[email protected]> wrote:
Quoted 16 lines · Pekka Paalanen
Quoted 5 lines · On Thu, 21 Aug 2025 11:54:32 -0600 Alex Hung <[email protected]> wrote:
Quoted 4 lines · Xaver Hugl
Quoted 4 lines
We user space folks have been convinced at this point that the sRGB EOTF is actually gamma 2.2, and not the piece-wise function. Now, if the hardware is actually the piece-wise, then that's what should be exposed, but I'm a bit unsure if we should do that under the name sRGB EOTF.
Quoted 7 lines
Quoted 3 lines
Maybe simply rename the enum string to "sRGB piece-wise EOTF"? In hindsight, the naming of "srgb" in the Wayland protocol caused a lot of confusion, it's better to be explicit about it where possible.
I will leave this to Harry to comment. He is taking a few days off so I will check with him later.
Quoted 7 lines
"sRGB inverse OETF"?
Strictly speaking "sRGB piece-wise EOTF" is not a thing AFAIU.
Thanks,
pqQuoted 6 lines
If an extension in future after this proposal is merged, can it be GAMMA 2.2 to be [
DRM_COLOROP_1D_CURVE_GAMMA22] = "GAMMA 2.2" so it won't conflict with current name?Meanwhile, do we agree to change "sRGB EOTF" as "sRGB Inverse OETF" as the following? or do we still want to add "piece-wise"?
Hi Alex,
since my previous comment, things have muddied further again. FWIW, we intend to remove the use of the name "srgb" transfer function completely from the Wayland protocol as confusing:
https://gitlab.freedesktop.org/wayland/wayland-protocols/-/merge_requests/442
I would recommend the KMS UAPI to similarly avoid the term. I would recommend "gamma 2.2" or even "power 2.2" and "compound power 2.4" or such. These names would hopefully not trigger intuition and make people look at the definition harder. Or any other name you can come up with.
I agree that "piece-wise sRGB EOTF" would be intuitively clear, but it may provoke people debating what does IEC 61966-2-1 actually define. We've had these kind of discussions for Wayland already, and it was suggested that it is better to define the actual mathematical function in our specification that to leave it for interpretation from standards.
Quoted 7 lines
Quoted 4 lines
For KMS, this should be even easier than for Wayland, because the hardware implements a specific mathematical function regardless of where it might have originated or what it is being used for.
Do you mean the following changes? Userspace use Gamma 2.2, and display driver can decide to use either sRGB piece-wise EOTF or Gamma 2.2 itself.
Sorry, the driver cannot choose. The UAPI needs to define the curves explicitly, and the drivers need to implement those curves exactly(*) or not at all. What I propose is, let's not use "sRGB" in any of the names for the curves, because that name triggers different assumptions in different people.
(*) "Exactly" is a little vague here. I assume some error tolerance needs to be allowed, e.g 1 bit on the electrical value. The maximum difference between the two-piece and power-2.2 curves is several code points for 8-bit electrical quantization, and that's too much error.
Quoted 19 lines
drivers/gpu/drm/drm_colorop.c +1
-1@@ -71,7 +71,7 @@ static const struct drm_prop_enum_list drm_colorop_type_enum_list[] = { };static const char *const colorop_curve_1d_type_names[] = { - [DRM_COLOROP_1D_CURVE_SRGB_EOTF ] ="sRGB EOTF" , + [DRM_COLOROP_1D_CURVE_SRGB_EOTF ] ="Gamma 2.2" , [DRM_COLOROP_1D_CURVE_SRGB_INV_EOTF ] ="sRGB Inverse EOTF" , [DRM_COLOROP_1D_CURVE_PQ_125_EOTF ] ="PQ 125 EOTF" ,[DRM_COLOROP_1D_CURVE_PQ_125_INV_EOTF] = "PQ 125 Inverse EOTF",include/drm/drm_colorop.h +0
-0
include/drm/drm_colorop.h enum drm_colorop_curve_1d_type { · line 52
Quoted 6 lines
include/drm/drm_colorop.h +2
-1@@ -48,7 +48,8 @@ enum drm_colorop_curve_1d_type {* sRGB piece-wise electro-optical transfer function. Transfer * characteristics as defined by IEC 61966-2-1 sRGB. Equivalent * to H.273 TransferCharacteristics code point 13 with -* MatrixCoefficients set to 0. +* MatrixCoefficients set to 0. This can also be approximated as +* Gamma 2.2.
The problem is that "H.273 TransferCharacteristics code point 13" a.k.a the sRGB curve means different things for different people (two-piece vs. power-2.2).
The difference is minor but visible, and therefore I would not make two-piece and power-2.2 equivalent nor have one approximated by the other.
They both need their own entries in the enum. Let's leave any decision about whether substituting one for the other is ok to the userspace.
Quoted 7 lines
include/drm/drm_colorop.h +0
-0*/ DRM_COLOROP_1D_CURVE_SRGB_EOTF,It is also possible to add GAMMA 2.2 in addition to sRGB piece-wise EOTF. But if I understand correctly,
DRM_COLOROP_1D_CURVE_SRGB_EOTFmay not be used at all, right?
If hardware implements the two-piece curve, then there is reason to expose it, especially when it does not implement power-2.2. Userspace can choose to use it as an approximation when that is appropriate.
Thanks,
pq
Quoted 49 lines
drivers/gpu/drm/drm_colorop.c +1
-0@@ -77,6 +77,7 @@ static const char * const colorop_curve_1d_type_names[] = { [DRM_COLOROP_1D_CURVE_SRGB_EOTF ] ="sRGB EOTF" , [DRM_COLOROP_1D_CURVE_PQ_125_INV_EOTF ] ="PQ 125 Inverse EOTF" , [DRM_COLOROP_1D_CURVE_BT2020_INV_OETF ] ="BT.2020 Inverse OETF" , [DRM_COLOROP_1D_CURVE_BT2020_OETF ] ="BT.2020 OETF" , + [DRM_COLOROP_1D_CURVE_GAMMA22 ] ="Gamma 2.2" , };Does anyone have comments or concerns if we use the first option?
Alex H.
Quoted 33 lines
Thanks,
pqQuoted 28 lines
drivers/gpu/drm/drm_colorop.c +1
-1@@ -71,7 +71,7 @@ static const struct drm_prop_enum_list drm_colorop_type_enum_list[] = { };static const char *const colorop_curve_1d_type_names[] = { - [DRM_COLOROP_1D_CURVE_SRGB_EOTF ] ="sRGB EOTF" , + [DRM_COLOROP_1D_CURVE_SRGB_EOTF ] ="sRGB Inverse OETF" , [DRM_COLOROP_1D_CURVE_SRGB_INV_EOTF ] ="sRGB Inverse EOTF" , [DRM_COLOROP_1D_CURVE_PQ_125_EOTF ] ="PQ 125 EOTF" ,[DRM_COLOROP_1D_CURVE_PQ_125_INV_EOTF] = "PQ 125 Inverse EOTF",include/drm/drm_colorop.h +1
-1@@ -43,7 +43,7 @@ enum drm_colorop_curve_1d_type {/** * @DRM_COLOROP_1D_CURVE_SRGB_EOTF: * -* enum string "sRGB EOTF" +* enum string "sRGB Inverse OETF" * * sRGB piece-wise electro-optical transfer function. Transfer * characteristics as defined by IEC 61966-2-1 sRGB. Equivalent
Re: [PATCH V11 06/47] drm/colorop: Add 1D Curve subtype
Quoted 118 lines · Pekka Paalanen
Quoted 55 lines · On Mon, 22 Sep 2025 21:16:45 -0600 Alex Hung <[email protected]> wrote:
Quoted 54 lines · Pekka Paalanen
Quoted 25 lines · On Tue, 16 Sep 2025 17:01:07 -0600 Alex Hung <[email protected]> wrote:
Quoted 16 lines · Pekka Paalanen
Quoted 5 lines · On Thu, 21 Aug 2025 11:54:32 -0600 Alex Hung <[email protected]> wrote:
Quoted 4 lines · Xaver Hugl
Quoted 4 lines
We user space folks have been convinced at this point that the sRGB EOTF is actually gamma 2.2, and not the piece-wise function. Now, if the hardware is actually the piece-wise, then that's what should be exposed, but I'm a bit unsure if we should do that under the name sRGB EOTF.
Quoted 7 lines
Quoted 3 lines
Maybe simply rename the enum string to "sRGB piece-wise EOTF"? In hindsight, the naming of "srgb" in the Wayland protocol caused a lot of confusion, it's better to be explicit about it where possible.
I will leave this to Harry to comment. He is taking a few days off so I will check with him later.
Quoted 7 lines
"sRGB inverse OETF"?
Strictly speaking "sRGB piece-wise EOTF" is not a thing AFAIU.
Thanks,
pqQuoted 6 lines
If an extension in future after this proposal is merged, can it be GAMMA 2.2 to be [
DRM_COLOROP_1D_CURVE_GAMMA22] = "GAMMA 2.2" so it won't conflict with current name?Meanwhile, do we agree to change "sRGB EOTF" as "sRGB Inverse OETF" as the following? or do we still want to add "piece-wise"?
Hi Alex,
since my previous comment, things have muddied further again. FWIW, we intend to remove the use of the name "srgb" transfer function completely from the Wayland protocol as confusing:
https://gitlab.freedesktop.org/wayland/wayland-protocols/-/merge_requests/442
I would recommend the KMS UAPI to similarly avoid the term. I would recommend "gamma 2.2" or even "power 2.2" and "compound power 2.4" or such. These names would hopefully not trigger intuition and make people look at the definition harder. Or any other name you can come up with.
I agree that "piece-wise sRGB EOTF" would be intuitively clear, but it may provoke people debating what does IEC 61966-2-1 actually define. We've had these kind of discussions for Wayland already, and it was suggested that it is better to define the actual mathematical function in our specification that to leave it for interpretation from standards.
Quoted 7 lines
Quoted 4 lines
For KMS, this should be even easier than for Wayland, because the hardware implements a specific mathematical function regardless of where it might have originated or what it is being used for.
Do you mean the following changes? Userspace use Gamma 2.2, and display driver can decide to use either sRGB piece-wise EOTF or Gamma 2.2 itself.
Sorry, the driver cannot choose. The UAPI needs to define the curves explicitly, and the drivers need to implement those curves
exactly(*)or not at all. What I propose is, let's not use "sRGB" in any of the names for the curves, because that name triggers different assumptions in different people.(*) "Exactly" is a little vague here. I assume some error tolerance needs to be allowed, e.g 1 bit on the electrical value. The maximum difference between the two-piece and power-2.2 curves is several code points for 8-bit electrical quantization, and that's too much error.
Quoted 19 lines
drivers/gpu/drm/drm_colorop.c +1
-1@@ -71,7 +71,7 @@ static const struct drm_prop_enum_list drm_colorop_type_enum_list[] = { };static const char *const colorop_curve_1d_type_names[] = { - [DRM_COLOROP_1D_CURVE_SRGB_EOTF ] ="sRGB EOTF" , + [DRM_COLOROP_1D_CURVE_SRGB_EOTF ] ="Gamma 2.2" , [DRM_COLOROP_1D_CURVE_SRGB_INV_EOTF ] ="sRGB Inverse EOTF" , [DRM_COLOROP_1D_CURVE_PQ_125_EOTF ] ="PQ 125 EOTF" ,[DRM_COLOROP_1D_CURVE_PQ_125_INV_EOTF] = "PQ 125 Inverse EOTF",include/drm/drm_colorop.h +0
-0include/drm/drm_colorop.h enum drm_colorop_curve_1d_type { · line 52
Quoted 6 lines
include/drm/drm_colorop.h +2
-1@@ -48,7 +48,8 @@ enum drm_colorop_curve_1d_type {* sRGB piece-wise electro-optical transfer function. Transfer * characteristics as defined by IEC 61966-2-1 sRGB. Equivalent * to H.273 TransferCharacteristics code point 13 with -* MatrixCoefficients set to 0. +* MatrixCoefficients set to 0. This can also be approximated as +* Gamma 2.2. The problem is that "H.273 TransferCharacteristics code point 13" a.k.a the sRGB curve means different things for different people (two-piece vs. power-2.2).
The difference is minor but visible, and therefore I would not make two-piece and power-2.2 equivalent nor have one approximated by the other.
They both need their own entries in the enum. Let's leave any decision about whether substituting one for the other is ok to the userspace.
Quoted 4 lines
include/drm/drm_colorop.h +0
-0*/ DRM_COLOROP_1D_CURVE_SRGB_EOTF,
Quoted 7 lines
Quoted 3 lines
It is also possible to add GAMMA 2.2 in addition to sRGB piece-wise EOTF. But if I understand correctly,
DRM_COLOROP_1D_CURVE_SRGB_EOTFmay not be used at all, right?If hardware implements the two-piece curve, then there is reason to expose it, especially when it does not implement power-2.2. Userspace can choose to use it as an approximation when that is appropriate.
Thanks for the clarification. Let me create another enum for Gamma 2.2.
Quoted 55 lines
Thanks,
pqQuoted 49 lines
drivers/gpu/drm/drm_colorop.c +1
-0@@ -77,6 +77,7 @@ static const char * const colorop_curve_1d_type_names[] = { [DRM_COLOROP_1D_CURVE_SRGB_EOTF ] ="sRGB EOTF" , [DRM_COLOROP_1D_CURVE_PQ_125_INV_EOTF ] ="PQ 125 Inverse EOTF" , [DRM_COLOROP_1D_CURVE_BT2020_INV_OETF ] ="BT.2020 Inverse OETF" , [DRM_COLOROP_1D_CURVE_BT2020_OETF ] ="BT.2020 OETF" , + [DRM_COLOROP_1D_CURVE_GAMMA22 ] ="Gamma 2.2" , };Does anyone have comments or concerns if we use the first option?
Alex H.
Quoted 33 lines
Thanks,
pqQuoted 28 lines
drivers/gpu/drm/drm_colorop.c +1
-1@@ -71,7 +71,7 @@ static const struct drm_prop_enum_list drm_colorop_type_enum_list[] = { };static const char *const colorop_curve_1d_type_names[] = { - [DRM_COLOROP_1D_CURVE_SRGB_EOTF ] ="sRGB EOTF" , + [DRM_COLOROP_1D_CURVE_SRGB_EOTF ] ="sRGB Inverse OETF" , [DRM_COLOROP_1D_CURVE_SRGB_INV_EOTF ] ="sRGB Inverse EOTF" , [DRM_COLOROP_1D_CURVE_PQ_125_EOTF ] ="PQ 125 EOTF" ,[DRM_COLOROP_1D_CURVE_PQ_125_INV_EOTF] = "PQ 125 Inverse EOTF",include/drm/drm_colorop.h +1
-1@@ -43,7 +43,7 @@ enum drm_colorop_curve_1d_type {/** * @DRM_COLOROP_1D_CURVE_SRGB_EOTF: * -* enum string "sRGB EOTF" +* enum string "sRGB Inverse OETF" * * sRGB piece-wise electro-optical transfer function. Transfer * characteristics as defined by IEC 61966-2-1 sRGB. Equivalent
Re: [PATCH V11 06/47] drm/colorop: Add 1D Curve subtype
In reply to Pekka PaalanenQuoted 122 lines · Pekka Paalanen
Quoted 55 lines · On Mon, 22 Sep 2025 21:16:45 -0600 Alex Hung <[email protected]> wrote:
Quoted 54 lines · Pekka Paalanen
Quoted 25 lines · On Tue, 16 Sep 2025 17:01:07 -0600 Alex Hung <[email protected]> wrote:
Quoted 16 lines · Pekka Paalanen
Quoted 5 lines · On Thu, 21 Aug 2025 11:54:32 -0600 Alex Hung <[email protected]> wrote:
Quoted 4 lines · Xaver Hugl
Quoted 4 lines
We user space folks have been convinced at this point that the sRGB EOTF is actually gamma 2.2, and not the piece-wise function. Now, if the hardware is actually the piece-wise, then that's what should be exposed, but I'm a bit unsure if we should do that under the name sRGB EOTF.
Quoted 7 lines
Quoted 3 lines
Maybe simply rename the enum string to "sRGB piece-wise EOTF"? In hindsight, the naming of "srgb" in the Wayland protocol caused a lot of confusion, it's better to be explicit about it where possible.
I will leave this to Harry to comment. He is taking a few days off so I will check with him later.
Quoted 7 lines
"sRGB inverse OETF"?
Strictly speaking "sRGB piece-wise EOTF" is not a thing AFAIU.
Thanks,
pqQuoted 6 lines
If an extension in future after this proposal is merged, can it be GAMMA 2.2 to be [
DRM_COLOROP_1D_CURVE_GAMMA22] = "GAMMA 2.2" so it won't conflict with current name?Meanwhile, do we agree to change "sRGB EOTF" as "sRGB Inverse OETF" as the following? or do we still want to add "piece-wise"?
Hi Alex,
since my previous comment, things have muddied further again. FWIW, we intend to remove the use of the name "srgb" transfer function completely from the Wayland protocol as confusing:
https://gitlab.freedesktop.org/wayland/wayland-protocols/-/merge_requests/442
I would recommend the KMS UAPI to similarly avoid the term. I would recommend "gamma 2.2" or even "power 2.2" and "compound power 2.4" or such. These names would hopefully not trigger intuition and make people look at the definition harder. Or any other name you can come up with.
I agree that "piece-wise sRGB EOTF" would be intuitively clear, but it may provoke people debating what does IEC 61966-2-1 actually define. We've had these kind of discussions for Wayland already, and it was suggested that it is better to define the actual mathematical function in our specification that to leave it for interpretation from standards.
Quoted 7 lines
Quoted 4 lines
For KMS, this should be even easier than for Wayland, because the hardware implements a specific mathematical function regardless of where it might have originated or what it is being used for.
Do you mean the following changes? Userspace use Gamma 2.2, and display driver can decide to use either sRGB piece-wise EOTF or Gamma 2.2 itself.
Sorry, the driver cannot choose. The UAPI needs to define the curves explicitly, and the drivers need to implement those curves
exactly(*)or not at all. What I propose is, let's not use "sRGB" in any of the names for the curves, because that name triggers different assumptions in different people.(*) "Exactly" is a little vague here. I assume some error tolerance needs to be allowed, e.g 1 bit on the electrical value. The maximum difference between the two-piece and power-2.2 curves is several code points for 8-bit electrical quantization, and that's too much error.
Quoted 19 lines
drivers/gpu/drm/drm_colorop.c +1
-1@@ -71,7 +71,7 @@ static const struct drm_prop_enum_list drm_colorop_type_enum_list[] = { };static const char *const colorop_curve_1d_type_names[] = { - [DRM_COLOROP_1D_CURVE_SRGB_EOTF ] ="sRGB EOTF" , + [DRM_COLOROP_1D_CURVE_SRGB_EOTF ] ="Gamma 2.2" , [DRM_COLOROP_1D_CURVE_SRGB_INV_EOTF ] ="sRGB Inverse EOTF" , [DRM_COLOROP_1D_CURVE_PQ_125_EOTF ] ="PQ 125 EOTF" ,[DRM_COLOROP_1D_CURVE_PQ_125_INV_EOTF] = "PQ 125 Inverse EOTF",include/drm/drm_colorop.h +0
-0include/drm/drm_colorop.h enum drm_colorop_curve_1d_type { · line 52
Quoted 6 lines
include/drm/drm_colorop.h +2
-1@@ -48,7 +48,8 @@ enum drm_colorop_curve_1d_type {* sRGB piece-wise electro-optical transfer function. Transfer * characteristics as defined by IEC 61966-2-1 sRGB. Equivalent * to H.273 TransferCharacteristics code point 13 with -* MatrixCoefficients set to 0. +* MatrixCoefficients set to 0. This can also be approximated as +* Gamma 2.2. The problem is that "H.273 TransferCharacteristics code point 13" a.k.a the sRGB curve means different things for different people (two-piece vs. power-2.2).
The difference is minor but visible, and therefore I would not make two-piece and power-2.2 equivalent nor have one approximated by the other.
They both need their own entries in the enum. Let's leave any decision about whether substituting one for the other is ok to the userspace.
Quoted 7 lines
include/drm/drm_colorop.h +0
-0*/ DRM_COLOROP_1D_CURVE_SRGB_EOTF,It is also possible to add GAMMA 2.2 in addition to sRGB piece-wise EOTF. But if I understand correctly,
DRM_COLOROP_1D_CURVE_SRGB_EOTFmay not be used at all, right?
Quoted 8 lines
If hardware implements the two-piece curve, then there is reason to expose it, especially when it does not implement power-2.2. Userspace can choose to use it as an approximation when that is appropriate.
Thanks,
pq
Does the following diff make sense?
1. Change "sRGB EOTF" -> "Piece-wise EOTF"
2. Add "Gamma 2.2"
drivers/gpu/drm/drm_colorop.c +2 -1
@@ -71,12 +71,13 @@ static const struct drm_prop_enum_list drm_colorop_type_enum_list[] = { };static const char *const colorop_curve_1d_type_names[] = { - [DRM_COLOROP_1D_CURVE_SRGB_EOTF ] ="sRGB EOTF" , + [DRM_COLOROP_1D_CURVE_SRGB_EOTF ] ="Piece-wise EOTF" , [DRM_COLOROP_1D_CURVE_SRGB_INV_EOTF ] ="sRGB Inverse EOTF" , [DRM_COLOROP_1D_CURVE_PQ_125_EOTF ] ="PQ 125 EOTF" , [DRM_COLOROP_1D_CURVE_PQ_125_INV_EOTF ] ="PQ 125 Inverse EOTF" , [DRM_COLOROP_1D_CURVE_BT2020_INV_OETF ] ="BT.2020 Inverse OETF" , [DRM_COLOROP_1D_CURVE_BT2020_OETF ] ="BT.2020 OETF" , + [DRM_COLOROP_1D_CURVE_GAMMA22 ] ="Gamma 2.2" , }; static const struct drm_prop_enum_list
drm_colorop_lut1d_interpolation_list[] = {
include/drm/drm_colorop.h +12 -5
@@ -43,12 +43,9 @@ enum drm_colorop_curve_1d_type {/** * @DRM_COLOROP_1D_CURVE_SRGB_EOTF: * -* enum string "sRGB EOTF" +* enum string "Piece-wise EOTF" * -* sRGB piece-wise electro-optical transfer function. Transfer -* characteristics as defined by IEC 61966-2-1 sRGB. Equivalent -* to H.273 TransferCharacteristics code point 13 with -* MatrixCoefficients set to 0. +* sRGB piece-wise electro-optical transfer function. */ DRM_COLOROP_1D_CURVE_SRGB_EOTF,
@@ -108,6 +105,16 @@ enum drm_colorop_curve_1d_type {*/ DRM_COLOROP_1D_CURVE_BT2020_OETF , +/** +* @DRM_COLOROP_1D_CURVE_GAMMA22: +* +* enum string "Gamma 2.2" +* +* A gamma 2.2 power function. This applies a power curve with +* gamma value of 2.2 to the input values. +*/ + DRM_COLOROP_1D_CURVE_GAMMA22, +/** * @DRM_COLOROP_1D_CURVE_COUNT: *
Quoted 50 lines
Quoted 49 lines
drivers/gpu/drm/drm_colorop.c +1
-0@@ -77,6 +77,7 @@ static const char * const colorop_curve_1d_type_names[] = { [DRM_COLOROP_1D_CURVE_SRGB_EOTF ] ="sRGB EOTF" , [DRM_COLOROP_1D_CURVE_PQ_125_INV_EOTF ] ="PQ 125 Inverse EOTF" , [DRM_COLOROP_1D_CURVE_BT2020_INV_OETF ] ="BT.2020 Inverse OETF" , [DRM_COLOROP_1D_CURVE_BT2020_OETF ] ="BT.2020 OETF" , + [DRM_COLOROP_1D_CURVE_GAMMA22 ] ="Gamma 2.2" , };Does anyone have comments or concerns if we use the first option?
Alex H.
Quoted 33 lines
Thanks,
pqQuoted 28 lines
drivers/gpu/drm/drm_colorop.c +1
-1@@ -71,7 +71,7 @@ static const struct drm_prop_enum_list drm_colorop_type_enum_list[] = { };static const char *const colorop_curve_1d_type_names[] = { - [DRM_COLOROP_1D_CURVE_SRGB_EOTF ] ="sRGB EOTF" , + [DRM_COLOROP_1D_CURVE_SRGB_EOTF ] ="sRGB Inverse OETF" , [DRM_COLOROP_1D_CURVE_SRGB_INV_EOTF ] ="sRGB Inverse EOTF" , [DRM_COLOROP_1D_CURVE_PQ_125_EOTF ] ="PQ 125 EOTF" ,[DRM_COLOROP_1D_CURVE_PQ_125_INV_EOTF] = "PQ 125 Inverse EOTF",include/drm/drm_colorop.h +1
-1@@ -43,7 +43,7 @@ enum drm_colorop_curve_1d_type {/** * @DRM_COLOROP_1D_CURVE_SRGB_EOTF: * -* enum string "sRGB EOTF" +* enum string "sRGB Inverse OETF" * * sRGB piece-wise electro-optical transfer function. Transfer * characteristics as defined by IEC 61966-2-1 sRGB. Equivalent
Re: [PATCH V11 06/47] drm/colorop: Add 1D Curve subtype
Quoted 183 lines · Alex Hung
Quoted 118 lines · Pekka Paalanen
Quoted 52 lines · On Mon, 22 Sep 2025 21:16:45 -0600 Alex Hung <[email protected]> wrote:
Quoted 51 lines · Pekka Paalanen
Quoted 23 lines · On Tue, 16 Sep 2025 17:01:07 -0600 Alex Hung <[email protected]> wrote:
Quoted 14 lines · Pekka Paalanen
Quoted 11 lines · On Thu, 21 Aug 2025 11:54:32 -0600 Alex Hung <[email protected]> wrote:
Quoted 7 lines · Xaver Hugl
Quoted 4 lines
We user space folks have been convinced at this point that the sRGB EOTF is actually gamma 2.2, and not the piece-wise function. Now, if the hardware is actually the piece-wise, then that's what should be exposed, but I'm a bit unsure if we should do that under the name sRGB EOTF.
Maybe simply rename the enum string to "sRGB piece-wise EOTF"? In hindsight, the naming of "srgb" in the Wayland protocol caused a lot of confusion, it's better to be explicit about it where possible.
I will leave this to Harry to comment. He is taking a few days off so I will check with him later.
Quoted 7 lines
"sRGB inverse OETF"?
Strictly speaking "sRGB piece-wise EOTF" is not a thing AFAIU.
Thanks,
pqQuoted 6 lines
If an extension in future after this proposal is merged, can it be GAMMA 2.2 to be [
DRM_COLOROP_1D_CURVE_GAMMA22] = "GAMMA 2.2" so it won't conflict with current name?Meanwhile, do we agree to change "sRGB EOTF" as "sRGB Inverse OETF" as the following? or do we still want to add "piece-wise"?
Hi Alex,
since my previous comment, things have muddied further again. FWIW, we intend to remove the use of the name "srgb" transfer function completely from the Wayland protocol as confusing:
https://gitlab.freedesktop.org/wayland/wayland-protocols/-/ merge_requests/442
I would recommend the KMS UAPI to similarly avoid the term. I would recommend "gamma 2.2" or even "power 2.2" and "compound power 2.4" or such. These names would hopefully not trigger intuition and make people look at the definition harder. Or any other name you can come up with.
I agree that "piece-wise sRGB EOTF" would be intuitively clear, but it may provoke people debating what does IEC 61966-2-1 actually define. We've had these kind of discussions for Wayland already, and it was suggested that it is better to define the actual mathematical function in our specification that to leave it for interpretation from standards.
Quoted 6 lines
Quoted 3 lines
For KMS, this should be even easier than for Wayland, because the hardware implements a specific mathematical function regardless of where it might have originated or what it is being used for.
Do you mean the following changes? Userspace use Gamma 2.2, and display driver can decide to use either sRGB piece-wise EOTF or Gamma 2.2 itself.
Sorry, the driver cannot choose. The UAPI needs to define the curves explicitly, and the drivers need to implement those curves
exactly(*)or not at all. What I propose is, let's not use "sRGB" in any of the names for the curves, because that name triggers different assumptions in different people.(*) "Exactly" is a little vague here. I assume some error tolerance needs to be allowed, e.g 1 bit on the electrical value. The maximum difference between the two-piece and power-2.2 curves is several code points for 8-bit electrical quantization, and that's too much error.
Quoted 19 lines
drivers/gpu/drm/drm_colorop.c +1
-1@@ -71,7 +71,7 @@ static const struct drm_prop_enum_list drm_colorop_type_enum_list[] = { }; static const char * const colorop_curve_1d_type_names[] = { - [DRM_COLOROP_1D_CURVE_SRGB_EOTF] = "sRGB EOTF", + [DRM_COLOROP_1D_CURVE_SRGB_EOTF] = "Gamma 2.2", [DRM_COLOROP_1D_CURVE_SRGB_INV_EOTF] = "sRGB Inverse EOTF", [DRM_COLOROP_1D_CURVE_PQ_125_EOTF] = "PQ 125 EOTF",[
DRM_COLOROP_1D_CURVE_PQ_125_INV_EOTF] = "PQ 125 Inverse EOTF",include/drm/drm_colorop.h +0
-0include/drm/drm_colorop.h enum drm_colorop_curve_1d_type { · line 52
Quoted 6 lines
include/drm/drm_colorop.h +2
-1@@ -48,7 +48,8 @@ enum drm_colorop_curve_1d_type { * sRGB piece-wise electro-optical transfer function. Transfer * characteristics as defined by IEC 61966-2-1 sRGB. Equivalent * to H.273 TransferCharacteristics code point 13 with - * MatrixCoefficients set to 0. + * MatrixCoefficients set to 0. This can also be approximated as + * Gamma 2.2.The problem is that "H.273 TransferCharacteristics code point 13" a.k.a the sRGB curve means different things for different people (two-piece vs. power-2.2).
The difference is minor but visible, and therefore I would not make two-piece and power-2.2 equivalent nor have one approximated by the other.
They both need their own entries in the enum. Let's leave any decision about whether substituting one for the other is ok to the userspace.
Quoted 7 lines
include/drm/drm_colorop.h +0
-0*/ DRM_COLOROP_1D_CURVE_SRGB_EOTF,It is also possible to add GAMMA 2.2 in addition to sRGB piece-wise EOTF. But if I understand correctly,
DRM_COLOROP_1D_CURVE_SRGB_EOTFmay not be used at all, right?Quoted 8 lines
If hardware implements the two-piece curve, then there is reason to expose it, especially when it does not implement power-2.2. Userspace can choose to use it as an approximation when that is appropriate.
Thanks,
pqDoes the following diff make sense?
1. Change "sRGB EOTF" -> "Piece-wise EOTF"
2. Add "Gamma 2.2"drivers/gpu/drm/drm_colorop.c +2
-1@@ -71,12 +71,13 @@ static const struct drm_prop_enum_list drm_colorop_type_enum_list[] = { }; static const char * const colorop_curve_1d_type_names[] = { - [DRM_COLOROP_1D_CURVE_SRGB_EOTF] = "sRGB EOTF", + [DRM_COLOROP_1D_CURVE_SRGB_EOTF] = "Piece-wise EOTF", [DRM_COLOROP_1D_CURVE_SRGB_INV_EOTF] = "sRGB Inverse EOTF", [DRM_COLOROP_1D_CURVE_PQ_125_EOTF] = "PQ 125 EOTF", [DRM_COLOROP_1D_CURVE_PQ_125_INV_EOTF] = "PQ 125 Inverse EOTF", [DRM_COLOROP_1D_CURVE_BT2020_INV_OETF] = "BT.2020 Inverse OETF", [DRM_COLOROP_1D_CURVE_BT2020_OETF] = "BT.2020 OETF", + [DRM_COLOROP_1D_CURVE_GAMMA22] = "Gamma 2.2", };static const struct
drm_prop_enum_list
drm_colorop_lut1d_interpolation_list[] = {include/drm/drm_colorop.hsRGB EOTF renamed from include/drm/drm_colorop.h +5
-5@@ -43,12 +43,9 @@ enum drm_colorop_curve_1d_type { /** * @DRM_COLOROP_1D_CURVE_SRGB_EOTF: * - * enum string "sRGB EOTF" + * enum string "Piece-wise EOTF" * - * sRGB piece-wise electro-optical transfer function. Transfer - * characteristics as defined by IEC 61966-2-1 sRGB. Equivalent - * to H.273 TransferCharacteristics code point 13 with - * MatrixCoefficients set to 0. + * sRGB piece-wise electro-optical transfer function. */ DRM_COLOROP_1D_CURVE_SRGB_EOTF,@@ -108,6 +105,16 @@ enum drm_colorop_curve_1d_type { */ DRM_COLOROP_1D_CURVE_BT2020_OETF, + /** + * @DRM_COLOROP_1D_CURVE_GAMMA22: + *
include/drm/drm_colorop.hsRGB EOTF enum drm_colorop_curve_1d_type { · line 120
Quoted 10 lines
include/drm/drm_colorop.hsRGB EOTF renamed from include/drm/drm_colorop.h +7
-0+ * enum string "Gamma 2.2" + * + * A gamma 2.2 power function. This applies a power curve with + * gamma value of 2.2 to the input values. + */ + DRM_COLOROP_1D_CURVE_GAMMA22, + /** * @DRM_COLOROP_1D_CURVE_COUNT: *
Both DRM_COLOROP_1D_CURVE_SRGB_EOTF and DRM_COLOROP_1D_CURVE_GAMMA22 are defined and it should be clear that sRGB EOTF are piece-wise TF and Gamma 2.2 is for power 2.2. Is it still a concern of using "sRGB" for as the original patch?
More precisely, adding DRM_COLOROP_1D_CURVE_GAMMA22 with "Gamma 2.2" string without touching "sRGB EOTF" should be sufficient. If a userspace need to choose one or another it can precisely do so.
Quoted 49 lines
Quoted 48 lines
Quoted 47 lines
drivers/gpu/drm/drm_colorop.c +1
-0@@ -77,6 +77,7 @@ static const char * const colorop_curve_1d_type_names[] = { [DRM_COLOROP_1D_CURVE_SRGB_EOTF] = "sRGB EOTF", [DRM_COLOROP_1D_CURVE_PQ_125_INV_EOTF] = "PQ 125 Inverse EOTF", [DRM_COLOROP_1D_CURVE_BT2020_INV_OETF] = "BT.2020 Inverse OETF", [DRM_COLOROP_1D_CURVE_BT2020_OETF] = "BT.2020 OETF", + [DRM_COLOROP_1D_CURVE_GAMMA22] = "Gamma 2.2", };Does anyone have comments or concerns if we use the first option?
Alex H.
Quoted 30 lines
Thanks,
pqQuoted 27 lines
drivers/gpu/drm/drm_colorop.c +1
-1@@ -71,7 +71,7 @@ static const struct drm_prop_enum_list drm_colorop_type_enum_list[] = { }; static const char * const colorop_curve_1d_type_names[] = { - [DRM_COLOROP_1D_CURVE_SRGB_EOTF] = "sRGB EOTF", + [DRM_COLOROP_1D_CURVE_SRGB_EOTF] = "sRGB Inverse OETF", [DRM_COLOROP_1D_CURVE_SRGB_INV_EOTF] = "sRGB Inverse EOTF", [DRM_COLOROP_1D_CURVE_PQ_125_EOTF] = "PQ 125 EOTF",[
DRM_COLOROP_1D_CURVE_PQ_125_INV_EOTF] = "PQ 125 Inverse EOTF",include/drm/drm_colorop.h +1
-1@@ -43,7 +43,7 @@ enum drm_colorop_curve_1d_type { /*** @DRM_COLOROP_1D_CURVE_SRGB_EOTF: * -* enum string "sRGB EOTF" +* enum string "sRGB Inverse OETF" * * sRGB piece-wise electro-optical transfer function. Transfer * characteristics as defined by IEC 61966-2-1 sRGB. Equivalent
Re: [PATCH V11 06/47] drm/colorop: Add 1D Curve subtype
Quoted 8 lines · On Tue, 23 Sep 2025 11:41:24 -0600 Alex Hung <[email protected]> wrote:
Quoted 7 lines · Alex Hung
Quoted 4 lines · Pekka Paalanen
Quoted 1 line · On Mon, 22 Sep 2025 21:16:45 -0600 Alex Hung <[email protected]> wrote:
On 9/18/25 02:40, Pekka Paalanen wrote:
...
Quoted 24 lines
Quoted 24 lines
Quoted 24 lines
The problem is that "H.273 TransferCharacteristics code point 13" a.k.a the sRGB curve means different things for different people (two-piece vs. power-2.2).
The difference is minor but visible, and therefore I would not make two-piece and power-2.2 equivalent nor have one approximated by the other.
They both need their own entries in the enum. Let's leave any decision about whether substituting one for the other is ok to the userspace.
Quoted 7 lines
*/
DRM_COLOROP_1D_CURVE_SRGB_EOTF,It is also possible to add GAMMA 2.2 in addition to sRGB piece-wise EOTF. But if I understand correctly,
DRM_COLOROP_1D_CURVE_SRGB_EOTFmay not be used at all, right?If hardware implements the two-piece curve, then there is reason to expose it, especially when it does not implement power-2.2. Userspace can choose to use it as an approximation when that is appropriate.
Quoted 5 lines
Quoted 5 lines
Quoted 3 lines
Thanks,
pqDoes the following diff make sense?
Yes.
Quoted 12 lines
Quoted 12 lines
1. Change "sRGB EOTF" -> "Piece-wise EOTF"
2. Add "Gamma 2.2"drivers/gpu/drm/drm_colorop.c +0
-0@@ -71,12 +71,13 @@ static const struct drm_prop_enum_list drm_colorop_type_enum_list[] = { };
Quoted 9 lines
drivers/gpu/drm/drm_colorop.c static const struct drm_prop_enum_list drm_colorop_type_enum_list[] = { · line 80
Quoted 9 lines
drivers/gpu/drm/drm_colorop.c +2
-1static const char * const colorop_curve_1d_type_names[] = { - [DRM_COLOROP_1D_CURVE_SRGB_EOTF] = "sRGB EOTF", + [DRM_COLOROP_1D_CURVE_SRGB_EOTF] = "Piece-wise EOTF", [DRM_COLOROP_1D_CURVE_SRGB_INV_EOTF] = "sRGB Inverse EOTF", [DRM_COLOROP_1D_CURVE_PQ_125_EOTF] = "PQ 125 EOTF", [DRM_COLOROP_1D_CURVE_PQ_125_INV_EOTF] = "PQ 125 Inverse EOTF", [DRM_COLOROP_1D_CURVE_BT2020_INV_OETF] = "BT.2020 Inverse OETF", [DRM_COLOROP_1D_CURVE_BT2020_OETF] = "BT.2020 OETF", + [DRM_COLOROP_1D_CURVE_GAMMA22] = "Gamma 2.2",
If I wanted to really nitpick, I'd propose "Power 2.2" instead of "Gamma 2.2", but I suppose it's clear anyway. And Wayland already went with GAMMA22.
Quoted 27 lines
Quoted 27 lines
drivers/gpu/drm/drm_colorop.c +0
-0};static const struct
drm_prop_enum_list
drm_colorop_lut1d_interpolation_list[] = {include/drm/drm_colorop.hsRGB EOTF renamed from include/drm/drm_colorop.h +2
-5@@ -43,12 +43,9 @@ enum drm_colorop_curve_1d_type { /** * @DRM_COLOROP_1D_CURVE_SRGB_EOTF: * - * enum string "sRGB EOTF" + * enum string "Piece-wise EOTF" * - * sRGB piece-wise electro-optical transfer function. Transfer - * characteristics as defined by IEC 61966-2-1 sRGB. Equivalent - * to H.273 TransferCharacteristics code point 13 with - * MatrixCoefficients set to 0. + * sRGB piece-wise electro-optical transfer function. */ DRM_COLOROP_1D_CURVE_SRGB_EOTF,@@ -108,6 +105,16 @@ enum drm_colorop_curve_1d_type { */ DRM_COLOROP_1D_CURVE_BT2020_OETF,
Quoted 7 lines
include/drm/drm_colorop.hsRGB EOTF enum drm_colorop_curve_1d_type { · line 114
Quoted 7 lines
include/drm/drm_colorop.hsRGB EOTF renamed from include/drm/drm_colorop.h +7
-0+ /** + * @DRM_COLOROP_1D_CURVE_GAMMA22: + * + * enum string "Gamma 2.2" + * + * A gamma 2.2 power function. This applies a power curve with + * gamma value of 2.2 to the input values.
I'd prefer "exponent" rather than "gamma value" to be more explicit. Just in case. There is quite some confusion around the term "gamma". I've used to call this function a "pure power-low with exponent 2.2" to explain that there are no offsets or multipliers or anything else.
For documentation it would best to write down the mathematical formula rather than describe it in words. I understand that may be problematic in kerneldoc, and we didn't do it in Wayland XML either but in a proposed Gitlab-Markdown appendix.
Quoted 8 lines
include/drm/drm_colorop.hsRGB EOTF enum drm_colorop_curve_1d_type { · line 120
Quoted 7 lines
include/drm/drm_colorop.hsRGB EOTF renamed from include/drm/drm_colorop.h +3
-0+ */ + DRM_COLOROP_1D_CURVE_GAMMA22, + /** * @DRM_COLOROP_1D_CURVE_COUNT: *
Quoted 4 lines
Both
DRM_COLOROP_1D_CURVE_SRGB_EOTFandDRM_COLOROP_1D_CURVE_GAMMA22are defined and it should be clear that sRGB EOTF are piece-wise TF and Gamma 2.2 is for power 2.2. Is it still a concern of using "sRGB" for as the original patch?
Not enough of a concern for me to continue nagging about it. :-)
Quoted 4 lines
More precisely, adding
DRM_COLOROP_1D_CURVE_GAMMA22with "Gamma 2.2" string without touching "sRGB EOTF" should be sufficient. If a userspace need to choose one or another it can precisely do so.
As long as everyone reads the documentation, and the documentation is clear. I failed at clarity in Wayland, so I'm perhaps a bit paranoid here.
Thanks,
pq
Harry Wentland
maintainerRe: [PATCH V11 06/47] drm/colorop: Add 1D Curve subtype
Quoted 38 lines · Pekka Paalanen
Quoted 8 lines · On Tue, 23 Sep 2025 11:41:24 -0600 Alex Hung <[email protected]> wrote:
Quoted 7 lines · Alex Hung
Quoted 4 lines · Pekka Paalanen
Quoted 1 line · On Mon, 22 Sep 2025 21:16:45 -0600 Alex Hung <[email protected]> wrote:
On 9/18/25 02:40, Pekka Paalanen wrote:
...
Quoted 24 lines
Quoted 24 lines
Quoted 24 lines
The problem is that "H.273 TransferCharacteristics code point 13" a.k.a the sRGB curve means different things for different people (two-piece vs. power-2.2).
The difference is minor but visible, and therefore I would not make two-piece and power-2.2 equivalent nor have one approximated by the other.
They both need their own entries in the enum. Let's leave any decision about whether substituting one for the other is ok to the userspace.
Quoted 7 lines
*/
DRM_COLOROP_1D_CURVE_SRGB_EOTF,It is also possible to add GAMMA 2.2 in addition to sRGB piece-wise EOTF. But if I understand correctly,
DRM_COLOROP_1D_CURVE_SRGB_EOTFmay not be used at all, right?If hardware implements the two-piece curve, then there is reason to expose it, especially when it does not implement power-2.2. Userspace can choose to use it as an approximation when that is appropriate.
Quoted 11 lines
Quoted 5 lines
Quoted 5 lines
Quoted 3 lines
Thanks,
pqDoes the following diff make sense?
Yes.
Quoted 2 lines
Quoted 2 lines
1. Change "sRGB EOTF" -> "Piece-wise EOTF"
I think simply naming it "Piece-wise EOTF" is problematic as it doesn't say anything about the curve. It's one of the curves that are used for sRGB (the other being the gamma/power 2.2 curve). I'd suggest we keep sRGB in the name.
Otherwise I agree with advertising both the piece-wise sRGB curve, as well as the Gamma (or Power) 2.2 curve.
A mathematical description of the curves would be good but not a blocker to merge this, IMO.
Harry
Quoted 97 lines
Quoted 10 lines
Quoted 10 lines
2. Add "Gamma 2.2"
drivers/gpu/drm/drm_colorop.c +0
-0@@ -71,12 +71,13 @@ static const struct drm_prop_enum_list drm_colorop_type_enum_list[] = { };Quoted 9 lines
drivers/gpu/drm/drm_colorop.c static const struct drm_prop_enum_list drm_colorop_type_enum_list[] = { · line 80
Quoted 9 lines
drivers/gpu/drm/drm_colorop.c +2
-1static const char * const colorop_curve_1d_type_names[] = { - [DRM_COLOROP_1D_CURVE_SRGB_EOTF] = "sRGB EOTF", + [DRM_COLOROP_1D_CURVE_SRGB_EOTF] = "Piece-wise EOTF", [DRM_COLOROP_1D_CURVE_SRGB_INV_EOTF] = "sRGB Inverse EOTF", [DRM_COLOROP_1D_CURVE_PQ_125_EOTF] = "PQ 125 EOTF", [DRM_COLOROP_1D_CURVE_PQ_125_INV_EOTF] = "PQ 125 Inverse EOTF", [DRM_COLOROP_1D_CURVE_BT2020_INV_OETF] = "BT.2020 Inverse OETF", [DRM_COLOROP_1D_CURVE_BT2020_OETF] = "BT.2020 OETF", + [DRM_COLOROP_1D_CURVE_GAMMA22] = "Gamma 2.2",If I wanted to really nitpick, I'd propose "Power 2.2" instead of "Gamma 2.2", but I suppose it's clear anyway. And Wayland already went with GAMMA22.
Quoted 27 lines
Quoted 27 lines
drivers/gpu/drm/drm_colorop.c +0
-0};static const struct
drm_prop_enum_list
drm_colorop_lut1d_interpolation_list[] = {include/drm/drm_colorop.hsRGB EOTF renamed from include/drm/drm_colorop.h +2
-5@@ -43,12 +43,9 @@ enum drm_colorop_curve_1d_type { /** * @DRM_COLOROP_1D_CURVE_SRGB_EOTF: * - * enum string "sRGB EOTF" + * enum string "Piece-wise EOTF" * - * sRGB piece-wise electro-optical transfer function. Transfer - * characteristics as defined by IEC 61966-2-1 sRGB. Equivalent - * to H.273 TransferCharacteristics code point 13 with - * MatrixCoefficients set to 0. + * sRGB piece-wise electro-optical transfer function. */ DRM_COLOROP_1D_CURVE_SRGB_EOTF,@@ -108,6 +105,16 @@ enum drm_colorop_curve_1d_type { */ DRM_COLOROP_1D_CURVE_BT2020_OETF,Quoted 7 lines
include/drm/drm_colorop.hsRGB EOTF enum drm_colorop_curve_1d_type { · line 114
Quoted 7 lines
include/drm/drm_colorop.hsRGB EOTF renamed from include/drm/drm_colorop.h +7
-0+ /** + * @DRM_COLOROP_1D_CURVE_GAMMA22: + * + * enum string "Gamma 2.2" + * + * A gamma 2.2 power function. This applies a power curve with + * gamma value of 2.2 to the input values.I'd prefer "exponent" rather than "gamma value" to be more explicit. Just in case. There is quite some confusion around the term "gamma". I've used to call this function a "pure power-low with exponent 2.2" to explain that there are no offsets or multipliers or anything else.
For documentation it would best to write down the mathematical formula rather than describe it in words. I understand that may be problematic in kerneldoc, and we didn't do it in Wayland XML either but in a proposed Gitlab-Markdown appendix.
Quoted 8 lines
include/drm/drm_colorop.hsRGB EOTF enum drm_colorop_curve_1d_type { · line 120
Quoted 7 lines
include/drm/drm_colorop.hsRGB EOTF renamed from include/drm/drm_colorop.h +3
-0+ */ + DRM_COLOROP_1D_CURVE_GAMMA22, + /** * @DRM_COLOROP_1D_CURVE_COUNT: *Quoted 4 lines
Both
DRM_COLOROP_1D_CURVE_SRGB_EOTFandDRM_COLOROP_1D_CURVE_GAMMA22are defined and it should be clear that sRGB EOTF are piece-wise TF and Gamma 2.2 is for power 2.2. Is it still a concern of using "sRGB" for as the original patch?Not enough of a concern for me to continue nagging about it. :-)
Quoted 4 lines
More precisely, adding
DRM_COLOROP_1D_CURVE_GAMMA22with "Gamma 2.2" string without touching "sRGB EOTF" should be sufficient. If a userspace need to choose one or another it can precisely do so.As long as everyone reads the documentation, and the documentation is clear. I failed at clarity in Wayland, so I'm perhaps a bit paranoid here.
Thanks,
pq
Re: [PATCH V11 06/47] drm/colorop: Add 1D Curve subtype
Quoted 56 lines · Harry Wentland
Quoted 36 lines · Pekka Paalanen
Quoted 7 lines · On Tue, 23 Sep 2025 11:41:24 -0600 Alex Hung <[email protected]> wrote:
Quoted 6 lines · Alex Hung
Quoted 3 lines · Pekka Paalanen
Quoted 1 line · On Mon, 22 Sep 2025 21:16:45 -0600 Alex Hung <[email protected]> wrote:
On 9/18/25 02:40, Pekka Paalanen wrote:
...
Quoted 23 lines
Quoted 23 lines
Quoted 23 lines
The problem is that "H.273 TransferCharacteristics code point 13" a.k.a the sRGB curve means different things for different people (two-piece vs. power-2.2).
The difference is minor but visible, and therefore I would not make two-piece and power-2.2 equivalent nor have one approximated by the other.
They both need their own entries in the enum. Let's leave any decision about whether substituting one for the other is ok to the userspace.
Quoted 7 lines
*/
DRM_COLOROP_1D_CURVE_SRGB_EOTF,It is also possible to add GAMMA 2.2 in addition to sRGB piece-wise EOTF. But if I understand correctly,
DRM_COLOROP_1D_CURVE_SRGB_EOTFmay not be used at all, right?If hardware implements the two-piece curve, then there is reason to expose it, especially when it does not implement power-2.2. Userspace can choose to use it as an approximation when that is appropriate.
Quoted 10 lines
Quoted 4 lines
Quoted 4 lines
Quoted 2 lines
Thanks,
pqDoes the following diff make sense?
Yes.
Quoted 2 lines
Quoted 2 lines
1. Change "sRGB EOTF" -> "Piece-wise EOTF"
I think simply naming it "Piece-wise EOTF" is problematic as it doesn't say anything about the curve. It's one of the curves that are used for sRGB (the other being the gamma/power 2.2 curve). I'd suggest we keep sRGB in the name.
Quoted 7 lines
Otherwise I agree with advertising both the piece-wise sRGB curve, as well as the Gamma (or Power) 2.2 curve.
A mathematical description of the curves would be good but not a blocker to merge this, IMO.
Harry
I also agree that we need to keep sRGB in the name, since BT.709 has a slightly different piece-wise curve.
Shengyu
Quoted 98 lines
Quoted 97 lines
Quoted 11 lines
Quoted 11 lines
2. Add "Gamma 2.2"
drivers/gpu/drm/drm_colorop.c +0
-0@@ -71,12 +71,13 @@ static const struct drm_prop_enum_list drm_colorop_type_enum_list[] = { };Quoted 9 lines
drivers/gpu/drm/drm_colorop.c static const struct drm_prop_enum_list drm_colorop_type_enum_list[] = { · line 80
Quoted 9 lines
drivers/gpu/drm/drm_colorop.c +2
-1static const char * const colorop_curve_1d_type_names[] = { - [DRM_COLOROP_1D_CURVE_SRGB_EOTF] = "sRGB EOTF", + [DRM_COLOROP_1D_CURVE_SRGB_EOTF] = "Piece-wise EOTF", [DRM_COLOROP_1D_CURVE_SRGB_INV_EOTF] = "sRGB Inverse EOTF", [DRM_COLOROP_1D_CURVE_PQ_125_EOTF] = "PQ 125 EOTF", [DRM_COLOROP_1D_CURVE_PQ_125_INV_EOTF] = "PQ 125 Inverse EOTF", [DRM_COLOROP_1D_CURVE_BT2020_INV_OETF] = "BT.2020 Inverse OETF", [DRM_COLOROP_1D_CURVE_BT2020_OETF] = "BT.2020 OETF", + [DRM_COLOROP_1D_CURVE_GAMMA22] = "Gamma 2.2",If I wanted to really nitpick, I'd propose "Power 2.2" instead of "Gamma 2.2", but I suppose it's clear anyway. And Wayland already went with GAMMA22.
Quoted 27 lines
Quoted 27 lines
drivers/gpu/drm/drm_colorop.c +0
-0};static const struct
drm_prop_enum_list
drm_colorop_lut1d_interpolation_list[] = {include/drm/drm_colorop.hsRGB EOTF renamed from include/drm/drm_colorop.h +2
-5@@ -43,12 +43,9 @@ enum drm_colorop_curve_1d_type { /** * @DRM_COLOROP_1D_CURVE_SRGB_EOTF: * - * enum string "sRGB EOTF" + * enum string "Piece-wise EOTF" * - * sRGB piece-wise electro-optical transfer function. Transfer - * characteristics as defined by IEC 61966-2-1 sRGB. Equivalent - * to H.273 TransferCharacteristics code point 13 with - * MatrixCoefficients set to 0. + * sRGB piece-wise electro-optical transfer function. */ DRM_COLOROP_1D_CURVE_SRGB_EOTF,@@ -108,6 +105,16 @@ enum drm_colorop_curve_1d_type { */ DRM_COLOROP_1D_CURVE_BT2020_OETF,Quoted 7 lines
include/drm/drm_colorop.hsRGB EOTF enum drm_colorop_curve_1d_type { · line 114
Quoted 7 lines
include/drm/drm_colorop.hsRGB EOTF renamed from include/drm/drm_colorop.h +7
-0+ /** + * @DRM_COLOROP_1D_CURVE_GAMMA22: + * + * enum string "Gamma 2.2" + * + * A gamma 2.2 power function. This applies a power curve with + * gamma value of 2.2 to the input values.I'd prefer "exponent" rather than "gamma value" to be more explicit. Just in case. There is quite some confusion around the term "gamma". I've used to call this function a "pure power-low with exponent 2.2" to explain that there are no offsets or multipliers or anything else.
For documentation it would best to write down the mathematical formula rather than describe it in words. I understand that may be problematic in kerneldoc, and we didn't do it in Wayland XML either but in a proposed Gitlab-Markdown appendix.
Quoted 11 lines
include/drm/drm_colorop.hsRGB EOTF enum drm_colorop_curve_1d_type { · line 120
Quoted 6 lines
include/drm/drm_colorop.hsRGB EOTF renamed from include/drm/drm_colorop.h +3
-0+ */ + DRM_COLOROP_1D_CURVE_GAMMA22, + /** * @DRM_COLOROP_1D_CURVE_COUNT: *Both
DRM_COLOROP_1D_CURVE_SRGB_EOTFandDRM_COLOROP_1D_CURVE_GAMMA22are defined and it should be clear that sRGB EOTF are piece-wise TF and Gamma 2.2 is for power 2.2. Is it still a concern of using "sRGB" for as the original patch?Not enough of a concern for me to continue nagging about it. :-)
Quoted 4 lines
More precisely, adding
DRM_COLOROP_1D_CURVE_GAMMA22with "Gamma 2.2" string without touching "sRGB EOTF" should be sufficient. If a userspace need to choose one or another it can precisely do so.As long as everyone reads the documentation, and the documentation is clear. I failed at clarity in Wayland, so I'm perhaps a bit paranoid here.
Thanks,
pq
PATCH v11 7/47 drm/colorop: Add BYPASS property
In reply to Alex HungFrom: Harry Wentland <[email protected]>
We want to be able to bypass each colorop at all times. Introduce a new BYPASS boolean property for this.
---
v6:
- clarify that bypass is only valid if BYPASS prop exists (Louis Chauvet)
drivers/gpu/drm/drm_atomic_uapi.c | 6 +++++- drivers/gpu/drm/drm_colorop.c | 15 +++++++++++++++ include/drm/drm_colorop.h | 22 ++++++++++++++++++++++ 3 files changed, 42 insertions(+), 1 deletion(-)
drivers/gpu/drm/drm_atomic_uapi.c +5 -1
@@ -650,7 +650,9 @@ static int drm_atomic_colorop_set_property(struct drm_colorop *colorop, struct drm_colorop_state *state, struct drm_file *file_priv, struct drm_property *property, uint64_t val) { - if (property == colorop->curve_1d_type_property) { + if (property == colorop->bypass_property) { + state->bypass = val; + } else if (property == colorop->curve_1d_type_property) { state->curve_1d_type = val; }else { drm_dbg_atomic(colorop->dev,
@@ -670,6 +672,8 @@ drm_atomic_colorop_get_property(struct drm_colorop *colorop, {if (property == colorop->type_property) { *val = colorop->type; + }else if (property == colorop->bypass_property) { + *val = state->bypass; }else if (property == colorop->curve_1d_type_property) { *val = state->curve_1d_type; }else {
drivers/gpu/drm/drm_colorop.c +15 -0
@@ -79,6 +79,17 @@ static int drm_plane_colorop_init(struct drm_device *dev, struct drm_colorop *co colorop->type_property, colorop->type); +/* bypass */ + prop =drm_property_create_bool (dev,DRM_MODE_PROP_ATOMIC , +"BYPASS" ); +if (!prop) +return -ENOMEM ; + + colorop->bypass_property = prop; +drm_object_attach_property (&colorop->base, + colorop->bypass_property, +1 ); +return ret; }
@@ -136,6 +147,7 @@ int drm_plane_colorop_curve_1d_init(struct drm_device *dev, struct drm_colorop */* initialize 1D curve only attribute */ prop =drm_property_create_enum (dev,DRM_MODE_PROP_ATOMIC ,"CURVE_1D_TYPE" , enum_list, len); +if (!prop)return -ENOMEM ;
@@ -152,6 +164,8 @@ static void __drm_atomic_helper_colorop_duplicate_state(struct drm_colorop *colo struct drm_colorop_state *state) {memcpy (state, colorop->state,sizeof (*state)); + + state->bypass = true; } struct drm_colorop_state *
@@ -190,6 +204,7 @@ static void __drm_colorop_state_reset(struct drm_colorop_state *colorop_state,u64 val; colorop_state->colorop = colorop; + colorop_state->bypass = true;if (colorop->curve_1d_type_property) { drm_object_property_get_default_value(&colorop->base,
include/drm/drm_colorop.h +22 -0
@@ -82,6 +82,16 @@ struct drm_colorop_state {* information. */ + +/** +* @bypass: +* +* When the property BYPASS exists on this colorop, this stores +* the requested bypass state: true if colorop shall be bypassed, +* false if colorop is enabled. +*/ +bool bypass; +/** * @curve_1d_type: *
@@ -171,6 +181,18 @@ struct drm_colorop {*/ struct drm_property *type_property; +/** +* @bypass_property: +* +* Boolean property to control enablement of the color +* operation. Setting bypass to "true" shall always be supported +* in order to allow compositors to quickly fall back to +* alternate methods of color processing. This is important +* since setting color operations can fail due to unique +* HW constraints. +*/ +struct drm_property *bypass_property; +/** * @curve_1d_type_property: *
Signature · 1 line
2.43.0
Re: [PATCH V11 07/47] drm/colorop: Add BYPASS property
Quoted 113 lines · Alex Hung
From: Harry Wentland <[email protected]>
We want to be able to bypass each colorop at all times. Introduce a new BYPASS boolean property for this.
Reviewed-by Simon Ser <[email protected]>Reviewed-by Louis Chauvet <[email protected]>Signed-off-by Alex Hung <[email protected]>Signed-off-by Harry Wentland <[email protected]>Reviewed-by Daniel Stone <[email protected]>Reviewed-by Melissa Wen <[email protected]>---
v6:
- clarify that bypass is only valid if BYPASS prop exists (Louis Chauvet)drivers/gpu/drm/drm_atomic_uapi.c | 6 +++++- drivers/gpu/drm/drm_colorop.c | 15 +++++++++++++++ include/drm/drm_colorop.h | 22 ++++++++++++++++++++++ 3 files changed, 42 insertions(+), 1 deletion(-)drivers/gpu/drm/drm_atomic_uapi.c +5
-1@@ -650,7 +650,9 @@ static int drm_atomic_colorop_set_property(struct drm_colorop *colorop, struct drm_colorop_state *state, struct drm_file *file_priv, struct drm_property *property, uint64_t val) { - if (property == colorop->curve_1d_type_property) { + if (property == colorop->bypass_property) { + state->bypass = val; + } else if (property == colorop->curve_1d_type_property) { state->curve_1d_type = val; }else { drm_dbg_atomic(colorop->dev,@@ -670,6 +672,8 @@ drm_atomic_colorop_get_property(struct drm_colorop *colorop, {if (property == colorop->type_property) { *val = colorop->type; + }else if (property == colorop->bypass_property) { + *val = state->bypass; }else if (property == colorop->curve_1d_type_property) { *val = state->curve_1d_type; }else {drivers/gpu/drm/drm_colorop.c +15
-0@@ -79,6 +79,17 @@ static int drm_plane_colorop_init(struct drm_device *dev, struct drm_colorop *co colorop->type_property, colorop->type); +/* bypass */ + prop =drm_property_create_bool (dev,DRM_MODE_PROP_ATOMIC , +"BYPASS" ); +if (!prop) +return -ENOMEM ; + + colorop->bypass_property = prop; +drm_object_attach_property (&colorop->base, + colorop->bypass_property, +1 ); +return ret; }@@ -136,6 +147,7 @@ int drm_plane_colorop_curve_1d_init(struct drm_device *dev, struct drm_colorop */* initialize 1D curve only attribute */ prop =drm_property_create_enum (dev,DRM_MODE_PROP_ATOMIC ,"CURVE_1D_TYPE" , enum_list, len); +if (!prop)return -ENOMEM ;@@ -152,6 +164,8 @@ static void __drm_atomic_helper_colorop_duplicate_state(struct drm_colorop *colo struct drm_colorop_state *state) {memcpy (state, colorop->state,sizeof (*state)); + + state->bypass = true; } struct drm_colorop_state *@@ -190,6 +204,7 @@ static void __drm_colorop_state_reset(struct drm_colorop_state *colorop_state,u64 val; colorop_state->colorop = colorop; + colorop_state->bypass = true;if (colorop->curve_1d_type_property) { drm_object_property_get_default_value(&colorop->base,include/drm/drm_colorop.h +10
-0@@ -82,6 +82,16 @@ struct drm_colorop_state {* information. */ + +/** +* @bypass: +* +* When the property BYPASS exists on this colorop, this stores +* the requested bypass state: true if colorop shall be bypassed, +* false if colorop is enabled. +*/ +bool bypass; +/** * @curve_1d_type: *
include/drm/drm_colorop.h struct drm_colorop { · line 188
Quoted 8 lines
include/drm/drm_colorop.h +5
-0@@ -171,6 +181,18 @@ struct drm_colorop {*/ struct drm_property *type_property; +/** +* @bypass_property: +* +* Boolean property to control enablement of the color +* operation. Setting bypass to "true" shall always be supported
This doesn't actually seem to be the case when the patches later in the series are to be believed.
Somewhere else it says
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'.
and later there is a "drm/colorop: allow non-bypass colorops" patch.
So I'm pretty sure this instance here should be adjusted.
Quoted 10 lines
include/drm/drm_colorop.h +7
-0+* in order to allow compositors to quickly fall back to +* alternate methods of color processing. This is important +* since setting color operations can fail due to unique +* HW constraints. +*/ +struct drm_property *bypass_property; +/** * @curve_1d_type_property: *
Re: [PATCH V11 07/47] drm/colorop: Add BYPASS property
Quoted 10 lines · Sebastian Wick
include/drm/drm_colorop.h struct drm_colorop { · line 188
Quoted 5 lines
include/drm/drm_colorop.h +5
-0+/** +* @bypass_property: +* +* Boolean property to control enablement of the color +* operation. Setting bypass to "true" shall always be supported This doesn't actually seem to be the case when the patches later in the series are to be believed.
Somewhere else it says
Quoted 7 lines
The BYPASS property is not mandatory for a colorop, as long as the entire pipeline can get bypassed by setting the
COLOR_PIPELINEon a plane to '0'.and later there is a "drm/colorop: allow non-bypass colorops" patch.
So I'm pretty sure this instance here should be adjusted.
Thanks for pointing this out. I will add "Only present if DRM_COLOROP_FLAG_ALLOW_BYPASS flag is set" to patch "drm/colorop: allow non-bypass colorops" to clarify the impact of new flag.
PATCH v11 8/47 drm/colorop: Add NEXT property
In reply to Alex HungFrom: Harry Wentland <[email protected]>
We'll construct color pipelines out of drm_colorop by chaining them via the NEXT pointer. NEXT will point to the next drm_colorop in the pipeline, or by 0 if we're at the end of the pipeline.
---
v8:
- Remove null check "colorop->next_property" in drm_colorop_set_next_property
v5:
- move next comment here from Add 3x4 CTM patch (Sebastian)
- Add kernel doc
v4:
- Allow setting of NEXT property to NULL (Chaitanya Kumar Borah)
v3:
- Add next pointer to colorop to be used by drivers and in DRM core
drivers/gpu/drm/drm_colorop.c | 27 +++++++++++++++++++++++++++ include/drm/drm_colorop.h | 17 +++++++++++++++++ 2 files changed, 44 insertions(+)
drivers/gpu/drm/drm_colorop.c +27 -0
@@ -58,6 +58,7 @@ static int drm_plane_colorop_init(struct drm_device *dev, struct drm_colorop *co colorop->dev = dev; colorop->type = type; colorop->plane = plane; + colorop->next =NULL ;list_add_tail (&colorop->head, &config->colorop_list); colorop->index = config->num_colorop++;
@@ -90,6 +91,16 @@ static int drm_plane_colorop_init(struct drm_device *dev, struct drm_colorop *co colorop->bypass_property, 1); +/* next */ + prop =drm_property_create_object (dev,DRM_MODE_PROP_IMMUTABLE |DRM_MODE_PROP_ATOMIC , +"NEXT" ,DRM_MODE_OBJECT_COLOROP ); +if (!prop) +return -ENOMEM ; + colorop->next_property = prop; +drm_object_attach_property (&colorop->base, + colorop->next_property, +0 ); +return ret; }
@@ -263,3 +274,19 @@ const char *drm_get_colorop_curve_1d_type_name(enum drm_colorop_curve_1d_type tyreturn colorop_curve_1d_type_names[type]; } + +/** +* drm_colorop_set_next_property - sets the next pointer +* @colorop: drm colorop +* @next: next colorop +* +* Should be used when constructing the color pipeline +*/ +void drm_colorop_set_next_property (struct drm_colorop *colorop,struct drm_colorop *next) +{ +drm_object_property_set_value (&colorop->base, + colorop->next_property, + next ? next->base.id :0 ); + colorop->next = next; +} +EXPORT_SYMBOL (drm_colorop_set_next_property);
include/drm/drm_colorop.h +17 -0
@@ -173,6 +173,14 @@ struct drm_colorop {*/ enum drm_colorop_type type; +/** +* @next: +* +* Read-only +* Pointer to next drm_colorop in pipeline +*/ +struct drm_colorop *next; +/** * @type_property: *
@@ -200,6 +208,13 @@ struct drm_colorop {*/ struct drm_property *curve_1d_type_property; +/** +* @next_property: +* +* Read-only property to next colorop in the pipeline +*/ +struct drm_property *next_property; + };#define obj_to_colorop (x) container_of(x, struct drm_colorop, base)
@@ -276,4 +291,6 @@ 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_set_next_property (struct drm_colorop *colorop,struct drm_colorop *next); +#endif /* __DRM_COLOROP_H__ */
Signature · 1 line
2.43.0
PATCH v11 9/47 drm/colorop: Add atomic state print for drm_colorop
In reply to Alex HungFrom: Harry Wentland <[email protected]>
Print atomic state for drm_colorop in debugfs
---
v8:
- Add switch statement to print colorop type (Simon Ser)
v7:
- Add a commit messages
- Squash "drm/colorop: Add NEXT to colorop state print" (Simon Ser)
drivers/gpu/drm/drm_atomic.c | 35 ++++++++++++++++++++++++++++++++++- 1 file changed, 34 insertions(+), 1 deletion(-)
drivers/gpu/drm/drm_atomic.c +34 -1
@@ -777,6 +777,29 @@ static int drm_atomic_plane_check(const struct drm_plane_state *old_plane_state,return 0 ; } + + +static void drm_atomic_colorop_print_state (struct drm_printer *p, +const struct drm_colorop_state *state) +{ +struct drm_colorop *colorop = state->colorop; + +drm_printf (p,"colorop[%u]:\n" , colorop->base.id); +drm_printf (p,"\ttype=%s\n" ,drm_get_colorop_type_name (colorop->type)); +drm_printf (p,"\tbypass=%u\n" , state->bypass); + +switch (colorop->type) { +case DRM_COLOROP_1D_CURVE : +drm_printf (p,"\tcurve_1d_type=%s\n" , +drm_get_colorop_curve_1d_type_name (state->curve_1d_type)); +break ; +default : +break ; + } + +drm_printf (p,"\tnext=%d\n" , colorop->next ? colorop->next->base.id :0 ); +} +static void drm_atomic_plane_print_state (struct drm_printer *p,const struct drm_plane_state *state) {
@@ -798,7 +821,8 @@ static void drm_atomic_plane_print_state(struct drm_printer *p,drm_printf (p,"\tcolor-range=%s\n" ,drm_get_color_range_name (state->color_range));drm_printf (p,"\tcolor_mgmt_changed=%d\n" , state->color_mgmt_changed); - +drm_printf (p,"\tcolor-pipeline=%d\n" , + state->color_pipeline ? state->color_pipeline->base.id :0 );if (plane->funcs->atomic_print_state) plane->funcs->atomic_print_state (p, state); }
@@ -1903,6 +1927,7 @@ static void __drm_state_dump(struct drm_device *dev, struct drm_printer *p, bool take_locks) {struct drm_mode_config *config = &dev->mode_config; +struct drm_colorop *colorop;struct drm_plane *plane;struct drm_crtc *crtc;struct drm_connector *connector;
@@ -1912,6 +1937,14 @@ static void __drm_state_dump(struct drm_device *dev, struct drm_printer *p,if (!drm_drv_uses_atomic_modeset (dev))return ; +list_for_each_entry (colorop, &config->colorop_list, head) { +if (take_locks) +drm_modeset_lock (&colorop->plane->mutex,NULL ); +drm_atomic_colorop_print_state (p, colorop->state); +if (take_locks) +drm_modeset_unlock (&colorop->plane->mutex); + } +list_for_each_entry (plane, &config->plane_list, head) {if (take_locks)drm_modeset_lock (&plane->mutex,NULL );
Signature · 1 line
2.43.0
PATCH v11 10/47 drm/plane: Add COLOR PIPELINE property
In reply to Alex HungFrom: Harry Wentland <[email protected]>
We're adding a new enum COLOR PIPELINE property. This property will have entries for each COLOR PIPELINE by referencing the DRM object ID of the first drm_colorop of the pipeline. 0 disables the entire COLOR PIPELINE.
Userspace can use this to discover the available color pipelines, as well as set the desired one. The color pipelines are programmed via properties on the actual drm_colorop objects.
---
V9:
- Remove redundant comments (Simon Ser)
v8:
- Use upper case in drm_dbg_atomic (Simon Ser)
- Remove MAX_COLOR_PIPELINES (Simon Ser)
- Make pipelines const in drm_plane_create_color_pipeline_property (Simon Ser)
v7:
- Fix a checkpatch warning - a new line after variable declaration
v4:
- Add pipeline property creation helper (Pekka)
- Fix function comment for drm_atomic_set_colorop_for_plane (Pekka)
- Always create Bypass pipeline (Pekka)
- Add missing function declaration (Chaitanya Kumar Borah)
drivers/gpu/drm/drm_atomic.c | 46 ++++++++++++++++++ drivers/gpu/drm/drm_atomic_state_helper.c | 5 ++ drivers/gpu/drm/drm_atomic_uapi.c | 42 ++++++++++++++++ drivers/gpu/drm/drm_plane.c | 59 +++++++++++++++++++++++ include/drm/drm_atomic.h | 3 ++ include/drm/drm_atomic_uapi.h | 2 + include/drm/drm_plane.h | 11 +++++ 7 files changed, 168 insertions(+)
drivers/gpu/drm/drm_atomic.c +46 -0
@@ -1531,6 +1531,52 @@ drm_atomic_add_affected_planes(struct drm_atomic_state *state, }EXPORT_SYMBOL (drm_atomic_add_affected_planes); +/** +* drm_atomic_add_affected_colorops - add colorops for plane +* @state: atomic state +* @plane: DRM plane +* +* This function walks the current configuration and adds all colorops +* currently used by @plane to the atomic configuration @state. This is useful +* when an atomic commit also needs to check all currently enabled colorop on +* @plane, e.g. when changing the mode. It's also useful when re-enabling a plane +* to avoid special code to force-enable all colorops. +* +* Since acquiring a colorop state will always also acquire the w/w mutex of the +* current plane for that colorop (if there is any) adding all the colorop states for +* a plane will not reduce parallelism of atomic updates. +* +* Returns: +* 0 on success or can fail with -EDEADLK or -ENOMEM. When the error is EDEADLK +* then the w/w mutex code has detected a deadlock and the entire atomic +* sequence must be restarted. All other errors are fatal. +*/ +int +drm_atomic_add_affected_colorops (struct drm_atomic_state *state, +struct drm_plane *plane) +{ +struct drm_colorop *colorop; +struct drm_colorop_state *colorop_state; + +WARN_ON (!drm_atomic_get_new_plane_state (state, plane)); + +drm_dbg_atomic (plane->dev, +"Adding all current colorops for [PLANE:%d:%s] to %p\n" , + plane->base.id, plane->name, state); + +drm_for_each_colorop (colorop, plane->dev) { +if (colorop->plane != plane) +continue ; + + colorop_state =drm_atomic_get_colorop_state (state, colorop); +if (IS_ERR (colorop_state)) +return PTR_ERR (colorop_state); + } + +return 0 ; +} +EXPORT_SYMBOL (drm_atomic_add_affected_colorops); +/** * drm_atomic_check_only - check whether a given config would work * @state: atomic configuration to check
drivers/gpu/drm/drm_atomic_state_helper.c +5 -0
@@ -268,6 +268,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 +42 -0
60 lines not on this page · raw message
drivers/gpu/drm/drm_plane.c +59 -0
62 lines not on this page · raw message
include/drm/drm_atomic.h +3 -0
@@ -886,6 +886,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_atomic_uapi.h +2 -0
@@ -50,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_plane.h +11 -0
@@ -791,6 +791,14 @@ struct drm_plane {*/ struct drm_property *color_range_property; +/** +* @color_pipeline_property: +* +* Optional "COLOR_PIPELINE" enum property for specifying +* a color pipeline to use on the plane. +*/ +struct drm_property *color_pipeline_property; +/** * @scaling_filter_property: property to apply a particular filter while * scaling.
@@ -1014,4 +1022,7 @@ int drm_plane_add_size_hints_property(struct drm_plane *plane,const struct drm_plane_size_hint *hints, int num_hints); +int drm_plane_create_color_pipeline_property (struct drm_plane *plane, +const struct drm_prop_enum_list *pipelines, +int num_pipelines);#endif
Signature · 1 line
2.43.0
PATCH v11 11/47 drm/colorop: Introduce DRM_CLIENT_CAP_PLANE_COLOR_PIPELINE
In reply to Alex HungFrom: Harry Wentland <[email protected]>
With the introduction of the pre-blending color pipeline we can no longer have color operations that don't have a clear position in the color pipeline. We deprecate all existing plane properties. For upstream drivers those are:
- COLOR_ENCODING
- COLOR_RANGE
Drivers are expected to ignore these properties when programming the HW. DRM clients that register with DRM_CLIENT_CAP_PLANE_COLOR_PIPELINE will not be allowed to set the COLOR_ENCODING and COLOR_RANGE properties.
Setting of the COLOR_PIPELINE plane property or drm_colorop properties is only allowed for userspace that sets this client cap.
---
v11
- Skip color_encoding/range_property in drm_mode_object_get_properties when plane_color_pipeline is present (Harry Wentland)
V9:
- Fix typo in commit description (Shengyu Qu)
v8:
- Disallow setting of COLOR_RANGE and COLOR_ENCODING when DRM_CLIENT_CAP_PLANE_COLOR_PIPELINE is set
v5:
- Fix kernel docs
v4:
- Don't block setting of COLOR_RANGE and COLOR_ENCODING when client cap is set
drivers/gpu/drm/drm_connector.c | 1 + drivers/gpu/drm/drm_crtc_internal.h | 1 + drivers/gpu/drm/drm_ioctl.c | 7 +++++++ drivers/gpu/drm/drm_mode_object.c | 18 ++++++++++++++++++ include/drm/drm_file.h | 7 +++++++ include/uapi/drm/drm.h | 15 +++++++++++++++ 6 files changed, 49 insertions(+)
drivers/gpu/drm/drm_connector.c +1 -0
@@ -3439,6 +3439,7 @@ int drm_mode_getconnector(struct drm_device *dev, void *data,* properties reflect the latest status. */ ret =drm_mode_object_get_properties (&connector->base, file_priv->atomic, + file_priv->plane_color_pipeline, (uint32_t __user *)(unsigned long )(out_resp->props_ptr), (uint64_t __user *)(unsigned long )(out_resp->prop_values_ptr), &out_resp->count_props);
drivers/gpu/drm/drm_crtc_internal.h +1 -0
@@ -163,6 +163,7 @@ struct drm_mode_object *__drm_mode_object_find(struct drm_device *dev,void drm_mode_object_unregister (struct drm_device *dev,struct drm_mode_object *object);int drm_mode_object_get_properties (struct drm_mode_object *obj,bool atomic, +bool plane_color_pipeline,uint32_t __user *prop_ptr,uint64_t __user *prop_values,uint32_t *arg_count_props);
drivers/gpu/drm/drm_ioctl.c +7 -0
@@ -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_object.c +18 -0
@@ -28,6 +28,7 @@#include <drm/drm_device.h> #include <drm/drm_file.h> #include <drm/drm_mode_object.h> +#include <drm/drm_plane.h> #include <drm/drm_print.h> #include "drm_crtc_internal.h"
@@ -386,6 +387,7 @@ EXPORT_SYMBOL(drm_object_property_get_default_value);/* helper for getconnector and getproperties ioctls */ int drm_mode_object_get_properties (struct drm_mode_object *obj,bool atomic, +bool plane_color_pipeline,uint32_t __user *prop_ptr,uint64_t __user *prop_values,uint32_t *arg_count_props)
@@ -399,6 +401,21 @@ int drm_mode_object_get_properties(struct drm_mode_object *obj, bool atomic,if ((prop->flags &DRM_MODE_PROP_ATOMIC ) && !atomic)continue ; +if (plane_color_pipeline && obj->type ==DRM_MODE_OBJECT_PLANE ) { +struct drm_plane *plane =obj_to_plane (obj); + +if (prop == plane->color_encoding_property || + prop == plane->color_range_property) +continue ; + } + +if (!plane_color_pipeline && obj->type ==DRM_MODE_OBJECT_PLANE ) { +struct drm_plane *plane =obj_to_plane (obj); + +if (prop == plane->color_pipeline_property) +continue ; + } +if (*arg_count_props > count) { ret =__drm_object_property_get_value (obj, prop, &val);if (ret)
@@ -457,6 +474,7 @@ int drm_mode_obj_get_properties_ioctl(struct drm_device *dev, void *data, } ret =drm_mode_object_get_properties (obj, file_priv->atomic, + file_priv->plane_color_pipeline, (uint32_t __user *)(unsigned long )(arg->props_ptr), (uint64_t __user *)(unsigned long )(arg->prop_values_ptr), &arg->count_props);
include/drm/drm_file.h +7 -0
@@ -206,6 +206,13 @@ struct drm_file {*/ bool writeback_connectors; +/** +* @plane_color_pipeline: +* +* True if client understands plane color pipelines +*/ +bool plane_color_pipeline; +/** * @was_master: *
include/uapi/drm/drm.h +15 -0
@@ -906,6 +906,21 @@ struct drm_get_cap {*/ #define DRM_CLIENT_CAP_CURSOR_PLANE_HOTSPOT 6 +/** +* DRM_CLIENT_CAP_PLANE_COLOR_PIPELINE +* +* If set to 1 the DRM core will allow setting the COLOR_PIPELINE +* property on a &drm_plane, as well as drm_colorop properties. +* +* Setting of these plane properties will be rejected when this client +* cap is set: +* - COLOR_ENCODING +* - COLOR_RANGE +* +* The client must enable &DRM_CLIENT_CAP_ATOMIC first. +*/ +#define DRM_CLIENT_CAP_PLANE_COLOR_PIPELINE 7 +/* DRM_IOCTL_SET_CLIENT_CAP ioctl argument type */ struct drm_set_client_cap {__u64 capability;
Signature · 1 line
2.43.0
Re: [PATCH V11 11/47] drm/colorop: Introduce DRM_CLIENT_CAP_PLANE_COLOR_PIPELINE
Quoted 50 lines · Alex Hung
From: Harry Wentland <[email protected]>
With the introduction of the pre-blending color pipeline we can no longer have color operations that don't have a clear position in the color pipeline. We deprecate all existing plane properties. For upstream drivers those are:
-COLOR_ENCODING
-COLOR_RANGEDrivers are expected to ignore these properties when programming the HW. DRM clients that register with
DRM_CLIENT_CAP_PLANE_COLOR_PIPELINEwill not be allowed to set theCOLOR_ENCODINGandCOLOR_RANGEproperties.Setting of the
COLOR_PIPELINEplane property ordrm_coloropproperties is only allowed for userspace that sets this client cap.Reviewed-by Simon Ser <[email protected]>Signed-off-by Alex Hung <[email protected]>Signed-off-by Harry Wentland <[email protected]>Reviewed-by Daniel Stone <[email protected]>Reviewed-by Melissa Wen <[email protected]>---
v11
- Skip color_encoding/range_property indrm_mode_object_get_properties
whenplane_color_pipelineis present (Harry Wentland)V9:
- Fix typo in commit description (Shengyu Qu)v8:
- Disallow setting ofCOLOR_RANGEandCOLOR_ENCODINGwhenDRM_CLIENT_CAP_PLANE_COLOR_PIPELINEis setv5:
- Fix kernel docsv4:
- Don't block setting ofCOLOR_RANGEandCOLOR_ENCODINGwhen client cap is setdrivers/gpu/drm/drm_connector.c | 1 +
drivers/gpu/drm/drm_crtc_internal.h| 1 + drivers/gpu/drm/drm_ioctl.c | 7 +++++++ drivers/gpu/drm/drm_mode_object.c | 18 ++++++++++++++++++ include/drm/drm_file.h | 7 +++++++ include/uapi/drm/drm.h | 15 +++++++++++++++6 files changed, 49 insertions(+)
[..]
Quoted 11 lines
drivers/gpu/drm/drm_mode_object.c +0
-0@@ -399,6 +401,21 @@ int drm_mode_object_get_properties(struct drm_mode_object *obj, bool atomic, if ((prop->flags & DRM_MODE_PROP_ATOMIC) && !atomic) continue;(quoted diff) +1
-0+ if (plane_color_pipeline && obj->type ==
DRM_MODE_OBJECT_PLANE) {drivers/gpu/drm/drm_mode_object.c +3
-0+struct drm_plane *plane =obj_to_plane (obj); + + if (prop == plane->color_encoding_property||
drivers/gpu/drm/drm_mode_object.c int drm_mode_object_get_properties(struct drm_mode_object *obj, bool atomic, · line 410
Quoted 3 lines
drivers/gpu/drm/drm_mode_object.c +3
-0+ prop == plane->color_range_property) +continue ; + }
A feedback that came up when discussing post-blend colorops [1] which is also applicable here, is that there should be a driver cap in addition to the client cap, and that the client cap should only be possible to set if the driver cap is set. Without that, if the driver doesn't support color pipelines, the client will effectively and unintentionally disable color operations without any replacement when setting the client cap.
Another suggestion was to keep the deprecated properties (in this case COLOR_RANGE and COLOR_ENCODING) available but read-only so that drm_info can display them and so that graceful handover from colorop- unaware to colorop-aware clients can happen.
Quoted 14 lines
(quoted diff) +2
-0+ + if (!plane_color_pipeline && obj->type ==
DRM_MODE_OBJECT_PLANE) {drivers/gpu/drm/drm_mode_object.c +6
-0+struct drm_plane *plane =obj_to_plane (obj); + +if (prop == plane->color_pipeline_property) +continue ; + } +if (
*arg_count_props> count) {
ret =__drm_object_property_get_value(obj, prop, &val);
if (ret)
[..]
Quoted 24 lines
include/uapi/drm/drm.h +0
-0@@ -906,6 +906,21 @@ struct drm_get_cap {*/ #define DRM_CLIENT_CAP_CURSOR_PLANE_HOTSPOT 6
+/**
+ *DRM_CLIENT_CAP_PLANE_COLOR_PIPELINE
+ *
+ * If set to 1 the DRM core will allow setting theCOLOR_PIPELINE
+ * property on a&drm_plane, as well asdrm_coloropproperties.
+ *
+ * Setting of these plane properties will be rejected when this client
+ * cap is set:
+ * -COLOR_ENCODING
+ * -COLOR_RANGE
+ *
+ * The client must enable&DRM_CLIENT_CAP_ATOMICfirst.
+ */include/uapi/drm/drm.h +2
-0+#define DRM_CLIENT_CAP_PLANE_COLOR_PIPELINE 7 +
Quoted 3 lines
/*
DRM_IOCTL_SET_CLIENT_CAPioctl argument type */ structdrm_set_client_cap{
__u64capability;
One other thing pointed out was that these deprecated properties are not actually rejected, but simply unlisted in the current implementation, contrary to the documentation above. But if we do make them read-only we'll need to revert back to the implementation on the previous version, and then the documentation can stay as is.
Signature · 3 lines
Thanks, Nícolas
Re: [PATCH V11 11/47] drm/colorop: Introduce DRM_CLIENT_CAP_PLANE_COLOR_PIPELINE
Quoted 76 lines · Nícolas F. R. A. Prado
Quoted 50 lines · Alex Hung
From: Harry Wentland <[email protected]>
With the introduction of the pre-blending color pipeline we can no longer have color operations that don't have a clear position in the color pipeline. We deprecate all existing plane properties. For upstream drivers those are:
-COLOR_ENCODING
-COLOR_RANGEDrivers are expected to ignore these properties when programming the HW. DRM clients that register with
DRM_CLIENT_CAP_PLANE_COLOR_PIPELINEwill not be allowed to set theCOLOR_ENCODINGandCOLOR_RANGEproperties.Setting of the
COLOR_PIPELINEplane property ordrm_coloropproperties is only allowed for userspace that sets this client cap.Reviewed-by Simon Ser <[email protected]>Signed-off-by Alex Hung <[email protected]>Signed-off-by Harry Wentland <[email protected]>Reviewed-by Daniel Stone <[email protected]>Reviewed-by Melissa Wen <[email protected]>---
v11
- Skip color_encoding/range_property indrm_mode_object_get_properties
whenplane_color_pipelineis present (Harry Wentland)V9:
- Fix typo in commit description (Shengyu Qu)v8:
- Disallow setting ofCOLOR_RANGEandCOLOR_ENCODINGwhenDRM_CLIENT_CAP_PLANE_COLOR_PIPELINEis setv5:
- Fix kernel docsv4:
- Don't block setting ofCOLOR_RANGEandCOLOR_ENCODINGwhen client cap is setdrivers/gpu/drm/drm_connector.c | 1 + drivers/gpu/drm/drm_crtc_internal.h | 1 + drivers/gpu/drm/drm_ioctl.c | 7 +++++++ drivers/gpu/drm/drm_mode_object.c | 18 ++++++++++++++++++ include/drm/drm_file.h | 7 +++++++ include/uapi/drm/drm.h | 15 +++++++++++++++ 6 files changed, 49 insertions(+)[..]
Quoted 11 lines
drivers/gpu/drm/drm_mode_object.c +4
-0@@ -399,6 +401,21 @@ int drm_mode_object_get_properties(struct drm_mode_object *obj, bool atomic, if ((prop->flags & DRM_MODE_PROP_ATOMIC) && !atomic) continue; +if (plane_color_pipeline && obj->type ==DRM_MODE_OBJECT_PLANE ) { +struct drm_plane *plane =obj_to_plane (obj); + + if (prop == plane->color_encoding_property||
drivers/gpu/drm/drm_mode_object.c int drm_mode_object_get_properties(struct drm_mode_object *obj, bool atomic, · line 410
Quoted 3 lines
drivers/gpu/drm/drm_mode_object.c +3
-0+ prop == plane->color_range_property) +continue ; + }A feedback that came up when discussing post-blend colorops [1] which is also applicable here, is that there should be a driver cap in addition to the client cap, and that the client cap should only be possible to set if the driver cap is set. Without that, if the driver doesn't support color pipelines, the client will effectively and unintentionally disable color operations without any replacement when setting the client cap.
Quoted 7 lines
Another suggestion was to keep the deprecated properties (in this case
COLOR_RANGEandCOLOR_ENCODING) available but read-only so thatdrm_infocan display them and so that graceful handover from colorop- unaware to colorop-aware clients can happen.
Thanks for this. Let me go through the thread and come back.
Quoted 51 lines
Quoted 16 lines
(quoted diff) +2
-0+ + if (!plane_color_pipeline && obj->type ==
DRM_MODE_OBJECT_PLANE) {drivers/gpu/drm/drm_mode_object.c +6
-0+struct drm_plane *plane =obj_to_plane (obj); + +if (prop == plane->color_pipeline_property) +continue ; + } + if (*arg_count_props > count) { ret = __drm_object_property_get_value(obj,prop, &val);
if (ret)[..]
Quoted 22 lines
include/uapi/drm/drm.h +7
-0@@ -906,6 +906,21 @@ struct drm_get_cap {*/ #define DRM_CLIENT_CAP_CURSOR_PLANE_HOTSPOT 6 +/** +* DRM_CLIENT_CAP_PLANE_COLOR_PIPELINE +* +* If set to 1 the DRM core will allow setting the COLOR_PIPELINE +* property on a &drm_plane, as well as drm_colorop properties. +* +* Setting of these plane properties will be rejected when this client
+ * cap is set:
+ * -COLOR_ENCODING
+ * -COLOR_RANGE
+ *
+ * The client must enable&DRM_CLIENT_CAP_ATOMICfirst.
+ */include/uapi/drm/drm.h struct drm_get_cap { · line 926
Quoted 5 lines
include/uapi/drm/drm.h +2
-0+#define DRM_CLIENT_CAP_PLANE_COLOR_PIPELINE 7 + /* DRM_IOCTL_SET_CLIENT_CAP ioctl argument type */ struct drm_set_client_cap { __u64 capability;One other thing pointed out was that these deprecated properties are not actually rejected, but simply unlisted in the current implementation, contrary to the documentation above. But if we do make them read-only we'll need to revert back to the implementation on the previous version, and then the documentation can stay as is.
PATCH v11 12/47 Documentation/gpu: document drm_colorop
In reply to Alex HungFrom: Harry Wentland <[email protected]>
Add kernel doc for drm_colorop objects.
---
v8:
- Move this after "drm/colorop: Introduce DRM_CLIENT_CAP_PLANE_COLOR_PIPELINE" (Simon Ser)
- Update DOC overview (Simon Ser)
v7:
- Add a commit messages
v5:
- Drop TODO
Documentation/gpu/drm-kms.rst | 15 +++++++++++++++ drivers/gpu/drm/drm_colorop.c | 31 +++++++++++++++++++++++++++++++ 2 files changed, 46 insertions(+)
Documentation/gpu/drm-kms.rst +15 -0
@@ -413,6 +413,21 @@ Plane Panic Functions Reference .. kernel-doc:: drivers/gpu/drm/drm_panic.c :export: +Colorop Abstraction +=================== + +.. kernel-doc:: drivers/gpu/drm/drm_colorop.c + :doc: overview + +Colorop Functions Reference +--------------------------- + +.. kernel-doc:: include/drm/drm_colorop.h + :internal: + +.. kernel-doc:: drivers/gpu/drm/drm_colorop.c + :export: + Display Modes Function Reference ================================
drivers/gpu/drm/drm_colorop.c +31 -0
@@ -31,6 +31,37 @@#include "drm_crtc_internal.h" +/** +* DOC: overview +* +* When userspace signals the &DRM_CLIENT_CAP_PLANE_COLOR_PIPELINE it +* should use the COLOR_PIPELINE plane property and associated colorops +* for any color operation on the &drm_plane. Setting of all old color +* properties, such as COLOR_ENCODING and COLOR_RANGE, will be rejected +* and the values of the properties will be ignored. +* +* Colorops are only advertised and valid for atomic drivers and atomic +* userspace that signals the &DRM_CLIENT_CAP_PLANE_COLOR_PIPELINE +* client cap. +* +* A colorop represents a single color operation. Colorops are chained +* via the NEXT property and make up color pipelines. Color pipelines +* are advertised and selected via the COLOR_PIPELINE &drm_plane +* property. +* +* A colorop will be of a certain type, advertised by the read-only TYPE +* property. Each type of colorop will advertise a different set of +* properties and is programmed in a different manner. Types can be +* enumerated 1D curves, 1D LUTs, 3D LUTs, matrices, etc. See the +* &drm_colorop_type documentation for information on each type. +* +* If a colorop advertises the BYPASS property it can be bypassed. +* +* Information about colorop and color pipeline design decisions can be +* found at rfc/color_pipeline.rst, but note that this document will +* grow stale over time. +*/ +static const struct drm_prop_enum_list drm_colorop_type_enum_list[] = { {DRM_COLOROP_1D_CURVE ,"1D Curve" }, };
Signature · 1 line
2.43.0
PATCH v11 13/47 drm/colorop: Add destroy functions for color pipeline
In reply to Alex HungThe functions are to clean up color pipeline when a device driver fails to create its color pipeline.
---
v11:
- destroy function takes drm_device *dev instead of drm_plane *plane (Nícolas Prado)
v9:
- Move from from latest commit to here, and drm_colorop_pipeline_destroy is called in respective commits.
drivers/gpu/drm/drm_colorop.c | 35 +++++++++++++++++++++++++++++++++++ include/drm/drm_colorop.h | 2 ++ 2 files changed, 37 insertions(+)
drivers/gpu/drm/drm_colorop.c +35 -0
@@ -135,6 +135,41 @@ static int drm_plane_colorop_init(struct drm_device *dev, struct drm_colorop *coreturn ret; } +/** +* drm_colorop_cleanup - Cleanup a drm_colorop object in color_pipeline +* +* @colorop: The drm_colorop object to be cleaned +*/ +static void drm_colorop_cleanup (struct drm_colorop *colorop) +{ +struct drm_device *dev = colorop->dev; +struct drm_mode_config *config = &dev->mode_config; + +list_del (&colorop->head); + config->num_colorop--; + +kfree (colorop->state); +} + +/** +* drm_colorop_pipeline_destroy - Helper for color pipeline destruction +* +* @dev: - The drm_device containing the drm_planes with the color_pipelines +* +* Provides a default color pipeline destroy handler for drm_device. +*/ +void drm_colorop_pipeline_destroy (struct drm_device *dev) +{ +struct drm_mode_config *config = &dev->mode_config; +struct drm_colorop *colorop, *next; + +list_for_each_entry_safe (colorop, next, &config->colorop_list, head) { +drm_colorop_cleanup (colorop); +kfree (colorop); + } +} +EXPORT_SYMBOL (drm_colorop_pipeline_destroy); +/** * drm_plane_colorop_curve_1d_init - Initialize a DRM_COLOROP_1D_CURVE *
include/drm/drm_colorop.h +2 -0
@@ -239,6 +239,8 @@ static inline struct drm_colorop *drm_colorop_find(struct drm_device *dev,return mo ?obj_to_colorop (mo) :NULL ; } +void drm_colorop_pipeline_destroy (struct drm_device *dev); +int drm_plane_colorop_curve_1d_init (struct drm_device *dev,struct drm_colorop *colorop,struct drm_plane *plane,u64 supported_tfs);
Signature · 1 line
2.43.0
Louis Chauvet
maintainerRe: [PATCH V11 13/47] drm/colorop: Add destroy functions for color pipeline
Le 15/08/2025 à 05:50, Alex Hung a écrit :
Quoted 49 lines
The functions are to clean up color pipeline when a device driver fails to create its color pipeline.
Signed-off-by Alex Hung <[email protected]>Reviewed-by Daniel Stone <[email protected]>Reviewed-by Simon Ser <[email protected]>Reviewed-by Melissa Wen <[email protected]>---
v11:
- destroy function takesdrm_device*dev instead ofdrm_plane*plane (Nícolas Prado)v9:
- Move from from latest commit to here, anddrm_colorop_pipeline_destroyis called in respective commits.drivers/gpu/drm/drm_colorop.c | 35 +++++++++++++++++++++++++++++++++++ include/drm/drm_colorop.h | 2 ++ 2 files changed, 37 insertions(+)drivers/gpu/drm/drm_colorop.c +21
-0@@ -135,6 +135,41 @@ static int drm_plane_colorop_init(struct drm_device *dev, struct drm_colorop *coreturn ret; } +/** +* drm_colorop_cleanup - Cleanup a drm_colorop object in color_pipeline +* +* @colorop: The drm_colorop object to be cleaned +*/ +static void drm_colorop_cleanup (struct drm_colorop *colorop) +{ +struct drm_device *dev = colorop->dev; +struct drm_mode_config *config = &dev->mode_config; + +list_del (&colorop->head); + config->num_colorop--; + +kfree (colorop->state); +} + +/** +* drm_colorop_pipeline_destroy - Helper for color pipeline destruction +* +* @dev: - The drm_device containing the drm_planes with the color_pipelines +*
drivers/gpu/drm/drm_colorop.c static int drm_plane_colorop_init(struct drm_device *dev, struct drm_colorop *co · line 168
Quoted 10 lines
drivers/gpu/drm/drm_colorop.c +10
-0+* Provides a default color pipeline destroy handler for drm_device. +*/ +void drm_colorop_pipeline_destroy (struct drm_device *dev) +{ +struct drm_mode_config *config = &dev->mode_config; +struct drm_colorop *colorop, *next; + +list_for_each_entry_safe (colorop, next, &config->colorop_list, head) { +drm_colorop_cleanup (colorop); +kfree (colorop);
This free here seems a bit strange. I don't see any requirement on the colorop pointer in the init function, so we can expect it to be embedded in a bigger structure, so this kfree may affect a non-allocated pointer.
I would expect one of:
- a clear documentation in drm_plane_colorop_*_init documentation that explicitly says that you need to pass a kzalloc pointer => very error prone, if the user don't read carefully the documentation it may lead to undefined behavior
- that drm_plane_colorop_*_init will do the kzalloc itself (so we garantee that the pointer is always a kzalloc pointer) => it will forbid to embed colorop structure in bigger structure. I don't think this is the case today, but I don't know if this can become a limitation for other drivers.
- that drm_colorop_pipeline_destroy does not free anything, this must be done by the driver itself => "more flexible" solution, but also require that you can attach a destroy function to each drm_colorop structure (like drm_crtc_funcs->destroy) or postpone it to complete device removal (using drmm_kzalloc or manually in device destroy)
In addition this function leave config->colorop_list in an uncertain state, I would be nice to add call list_del(colorop->head) just to avoid dangling pointers.
Quoted 20 lines
drivers/gpu/drm/drm_colorop.c +4
-0+ } +} +EXPORT_SYMBOL (drm_colorop_pipeline_destroy); +/** * drm_plane_colorop_curve_1d_init - Initialize a DRM_COLOROP_1D_CURVE * include/drm/drm_colorop.h +2
-0@@ -239,6 +239,8 @@ static inline struct drm_colorop *drm_colorop_find(struct drm_device *dev,return mo ?obj_to_colorop (mo) :NULL ; } +void drm_colorop_pipeline_destroy (struct drm_device *dev); +int drm_plane_colorop_curve_1d_init (struct drm_device *dev,struct drm_colorop *colorop,struct drm_plane *plane,u64 supported_tfs);
Signature · 3 lines
Louis Chauvet, Bootlin Embedded Linux and Kernel engineering https://bootlin.com
Re: [PATCH V11 13/47] drm/colorop: Add destroy functions for color pipeline
Quoted 67 lines · Louis Chauvet
Le 15/08/2025 à 05:50, Alex Hung a écrit :
Quoted 58 lines
The functions are to clean up color pipeline when a device driver fails to create its color pipeline.
Signed-off-by Alex Hung <[email protected]>Reviewed-by Daniel Stone <[email protected]>Reviewed-by Simon Ser <[email protected]>Reviewed-by Melissa Wen <[email protected]>---
v11:
- destroy function takesdrm_device*dev instead ofdrm_plane*plane (Nícolas Prado)v9:
- Move from from latest commit to here, anddrm_colorop_pipeline_destroyis called in respective commits.
drivers/gpu/drm/drm_colorop.c| 35 +++++++++++++++++++++++++++++++++++ include/drm/drm_colorop.h | 2 ++2 files changed, 37 insertions(+)drivers/gpu/drm/drm_colorop.c +0
-0@@ -135,6 +135,41 @@ static int drm_plane_colorop_init(struct
drm_device*dev, structdrm_colorop*co
return ret;
}drivers/gpu/drm/drm_colorop.c +20
-0+/** +* drm_colorop_cleanup - Cleanup a drm_colorop object in color_pipeline +* +* @colorop: The drm_colorop object to be cleaned +*/ +static void drm_colorop_cleanup (struct drm_colorop *colorop) +{ + struct drm_device *dev = colorop->dev; + struct drm_mode_config *config = &dev->mode_config; + + list_del(&colorop->head); + config->num_colorop--; + + kfree(colorop->state); +} + +/** +* drm_colorop_pipeline_destroy - Helper for color pipeline destruction +* +* @dev: - The drm_device containing the drm_planes with the
color_pipelines
+ *
+ * Provides a default color pipeline destroy handler fordrm_device.
+ */drivers/gpu/drm/drm_colorop.c +6
-0+void drm_colorop_pipeline_destroy (struct drm_device *dev) +{ + struct drm_mode_config *config = &dev->mode_config; + struct drm_colorop *colorop, *next; + + list_for_each_entry_safe(colorop, next, &config->colorop_list,Quoted 3 lines
head) {
+drm_colorop_cleanup(colorop);
+ kfree(colorop);This free here seems a bit strange. I don't see any requirement on the colorop pointer in the init function, so we can expect it to be embedded in a bigger structure, so this kfree may affect a non-allocated pointer.
Quoted 7 lines
I would expect one of:
- a clear documentation in drm_plane_colorop_*_init documentation that
explicitly says that you need to pass a kzalloc pointer => very error prone, if the user don't read carefully the documentation it may lead to undefined behavior- that drm_plane_colorop_*_init will do the kzalloc itself (so we
garantee that the pointer is always a kzalloc pointer) => it will forbid to embed colorop structure in bigger structure. I don't think this is the case today, but I don't know if this can become a limitation for other drivers.
Yes it makes to have kzalloc and kfree done both in vkms/amdgpu or both in drm_*.
Does the following change make sense to you?
drivers/gpu/drm/drm_colorop.c +0 -0
@@ -214,6 +216,13 @@ int drm_plane_colorop_curve_1d_init(struct drm_device *dev, struct drm_colorop *
struct drm_property *prop;
int ret;
+ colorop = kzalloc(sizeof(struct drm_colorop), GFP_KERNEL);
+ if (!colorop) {
+ drm_err(dev, "KMS: Failed to allocate colorop\n");
+ ret = -ENOMEM;
+ goto cleanup;
+ }
+
if (!supported_tfs) {
drm_err(dev,
"No supported TFs for new 1D curve colorop on [PLANE:%d:%s]\n",
drivers/gpu/drm/vkms/vkms_colorop.c +0 -6
@@ -24,12 +24,6 @@ static int vkms_initialize_color_pipeline(struct drm_plane *plane, struct drm_prmemset (ops,0 ,sizeof (ops));/* 1st op: 1d curve */ - ops[i] =kzalloc (sizeof (*ops[i]),GFP_KERNEL ); -if (!ops[i]) { -drm_err (dev,"KMS: Failed to allocate colorop\n" ); - ret = -ENOMEM ; - goto cleanup; - } ret =drm_plane_colorop_curve_1d_init (dev, ops[i], plane, supported_tfs,DRM_COLOROP_FLAG_ALLOW_BYPASS );
Quoted 26 lines
- that
drm_colorop_pipeline_destroydoes not free anything, this must be
done by the driver itself => "more flexible" solution, but also require that you can attach a destroy function to eachdrm_coloropstructure (likedrm_crtc_funcs->destroy) or postpone it to complete device removal (usingdrmm_kzallocor manually in device destroy)In addition this function leave
config->colorop_listin an uncertain state, I would be nice to add calllist_del(colorop->head)just to avoid dangling pointers.Quoted 19 lines
+ }
drivers/gpu/drm/drm_colorop.c +3
-0+} +EXPORT_SYMBOL (drm_colorop_pipeline_destroy); +/**
*drm_plane_colorop_curve_1d_init- Initialize aDRM_COLOROP_1D_CURVE*include/drm/drm_colorop.h +2
-0@@ -239,6 +239,8 @@ static inline struct drm_colorop *drm_colorop_find(struct drm_device *dev, return mo ? obj_to_colorop(mo) : NULL; } +void drm_colorop_pipeline_destroy(struct drm_device *dev); + int drm_plane_colorop_curve_1d_init(struct drm_device *dev, struct drm_colorop *colorop, struct drm_plane *plane, u64 supported_tfs);
Re: [PATCH V11 13/47] drm/colorop: Add destroy functions for color pipeline
Quoted 147 lines · Alex Hung
Quoted 90 lines · Louis Chauvet
Le 15/08/2025 à 05:50, Alex Hung a écrit :
Quoted 66 lines
The functions are to clean up color pipeline when a device driver fails to create its color pipeline.
Signed-off-by Alex Hung <[email protected]>Reviewed-by Daniel Stone <[email protected]>Reviewed-by Simon Ser <[email protected]>Reviewed-by Melissa Wen <[email protected]>---
v11:
- destroy function takesdrm_device*dev instead ofdrm_plane*plane
(Nícolas Prado)v9:
- Move from from latest commit to here, anddrm_colorop_pipeline_destroy
is called in respective commits.
drivers/gpu/drm/drm_colorop.c| 35
+++++++++++++++++++++++++++++++++++
include/drm/drm_colorop.h | 2 ++2 files changed, 37 insertions(+)drivers/gpu/drm/ renamed from drivers/gpu/drm/drm_colorop.c +0
-0
drm_colorop.c
index7b3ecf7ddd11..6930d39c8ad3100644drivers/gpu/drm/drm_colorop.c +0
-0@@ -135,6 +135,41 @@ static int drm_plane_colorop_init(struct
drm_device*dev, structdrm_colorop*co
return ret;
}
+/**
+ *drm_colorop_cleanup- Cleanup adrm_coloropobject incolor_pipeline
+ *
+ * @colorop: Thedrm_coloropobject to be cleaned
+ */drivers/gpu/drm/drm_colorop.c +13
-0+static void drm_colorop_cleanup (struct drm_colorop *colorop) +{ + struct drm_device *dev = colorop->dev; + struct drm_mode_config *config = &dev->mode_config; + + list_del(&colorop->head); + config->num_colorop--; + + kfree(colorop->state); +} + +/** +* drm_colorop_pipeline_destroy - Helper for color pipeline destruction
+ *
+ * @dev: - Thedrm_devicecontaining thedrm_planeswith thecolor_pipelines
+ *
+ * Provides a default color pipeline destroy handler fordrm_device.
+ */drivers/gpu/drm/drm_colorop.c +6
-0+void drm_colorop_pipeline_destroy (struct drm_device *dev) +{ + struct drm_mode_config *config = &dev->mode_config; + struct drm_colorop *colorop, *next; + + list_for_each_entry_safe(colorop, next, &config-Quoted 1 line
colorop_list,Quoted 3 lines
head) {
+drm_colorop_cleanup(colorop);
+ kfree(colorop);This free here seems a bit strange. I don't see any requirement on the
colorop pointer in the init function, so we can expect it to be embedded
in a bigger structure, so this kfree may affect a non-allocated pointer.I would expect one of:
- a clear documentation in drm_plane_colorop_*_init documentation that
explicitly says that you need to pass a kzalloc pointer => very error
prone, if the user don't read carefully the documentation it may lead to
undefined behaviorQuoted 8 lines
- that drm_plane_colorop_*_init will do the kzalloc itself (so we garantee that the pointer is always a kzalloc pointer) => it will forbid
to embed colorop structure in bigger structure. I don't think this is
the case today, but I don't know if this can become a limitation for
other drivers.Yes it makes to have kzalloc and kfree done both in vkms/amdgpu or both
in drm_*.Does the following change make sense to you?
drivers/gpu/drm/drm_colorop.c +0
-0@@ -214,6 +216,13 @@ int drm_plane_colorop_curve_1d_init(struct
drm_device*dev, structdrm_colorop*
structdrm_property*prop;
int ret;drivers/gpu/drm/drm_colorop.c +7
-0+ colorop =kzalloc (sizeof (struct drm_colorop ),GFP_KERNEL ); +if (!colorop) { +drm_err (dev,"KMS: Failed to allocate colorop\n" ); + ret = -ENOMEM ; + goto cleanup; + } +if (!supported_tfs) {
drm_err(dev,
"No supported TFs for new 1D curve colorop on [PLANE:%d:%s]\n",drivers/gpu/drm/vkms/vkms_colorop.c +0
-0@@ -24,12 +24,6 @@ static int vkms_initialize_color_pipeline(struct
drm_plane*plane, structdrm_pr
memset(ops, 0, sizeof(ops));/* 1st op: 1d curve */
drivers/gpu/drm/vkms/vkms_colorop.c +0
-6- ops[i] =kzalloc (sizeof (*ops[i]),GFP_KERNEL ); -if (!ops[i]) { -drm_err (dev,"KMS: Failed to allocate colorop\n" ); - ret = -ENOMEM ; - goto cleanup; - }
Quoted 6 lines
ret = drm_plane_colorop_curve_1d_init(dev, ops[i], plane,
supported_tfs,DRM_COLOROP_FLAG_ALLOW_BYPASS);
Well, as Louis mentions, this doesn't play well with embedding a colorop into a larger struct, which is something I'm relying on to track additional bits for post-blend colorops in the MediaTek driver in [1].
I don't see an issue with the existing solution. From the function's
documentation: "Provides a default color pipeline destroy handler for drm_device.", "default" is the key word here, each driver is currently responsible for allocating every colorop and cleaning it up, and this function is a helper for the common case where a drm_colorop is not embedded into another struct. For the cases where it is, the driver should create its own destroy() that properly frees the pointer for the container struct, which is exactly what I'm doing in [1]. Perhaps we should just add to the destroy() documentation that it frees the pointer and so drivers embedding the struct should implement their own helper.
On that train of thought, I think it would make sense to make drm_colorop_cleanup() public [2] as part of this series so that those drivers can reuse it.
[1]
https://lore.kernel.org/dri-devel/20250822-mtk-post-blend-color-pipeline-v1-0-a9446d4aca82@collabora.com/T/#ma6b44d451ed84c9c6b32d26e6192ad951612444d
[2]
https://lore.kernel.org/dri-devel/20250822-mtk-post-blend-color-pipeline-v1-0-a9446d4aca82@collabora.com/T/#m15e8f52a03d711a4d3ab9cecc7b9cafb2954c489
Quoted 1 line
Signature · 3 lines
Thanks, Nícolas
Re: [PATCH V11 13/47] drm/colorop: Add destroy functions for color pipeline
Quoted 160 lines · Nícolas F. R. A. Prado
Quoted 150 lines · Alex Hung
Quoted 90 lines · Louis Chauvet
Le 15/08/2025 à 05:50, Alex Hung a écrit :
Quoted 66 lines
The functions are to clean up color pipeline when a device driver fails to create its color pipeline.
Signed-off-by Alex Hung <[email protected]>Reviewed-by Daniel Stone <[email protected]>Reviewed-by Simon Ser <[email protected]>Reviewed-by Melissa Wen <[email protected]>---
v11:
- destroy function takesdrm_device*dev instead ofdrm_plane
*plane
(Nícolas Prado)v9:
- Move from from latest commit to here, anddrm_colorop_pipeline_destroy
is called in respective commits.drivers/gpu/drm/drm_colorop.c | 35 +++++++++++++++++++++++++++++++++++ include/drm/drm_colorop.h | 2 ++ 2 files changed, 37 insertions(+)drivers/gpu/drm/ renamed from drivers/gpu/drm/drm_colorop.c +0
-0
drm_colorop.c
index7b3ecf7ddd11..6930d39c8ad3100644drivers/gpu/drm/drm_colorop.c +0
-0@@ -135,6 +135,41 @@ static int drm_plane_colorop_init(struct
drm_device*dev, structdrm_colorop*co
return ret;
}
+/**
+ *drm_colorop_cleanup- Cleanup adrm_coloropobject incolor_pipeline
+ *
+ * @colorop: Thedrm_coloropobject to be cleaned
+ */drivers/gpu/drm/drm_colorop.c +13
-0+static void drm_colorop_cleanup (struct drm_colorop *colorop) +{ + struct drm_device *dev = colorop->dev; + struct drm_mode_config *config = &dev->mode_config; + + list_del(&colorop->head); + config->num_colorop--; + + kfree(colorop->state); +} + +/** +* drm_colorop_pipeline_destroy - Helper for color pipeline destruction
+ *
+ * @dev: - Thedrm_devicecontaining thedrm_planeswith thecolor_pipelines
+ *
+ * Provides a default color pipeline destroy handler fordrm_device.
+ */drivers/gpu/drm/drm_colorop.c +6
-0+void drm_colorop_pipeline_destroy (struct drm_device *dev) +{ + struct drm_mode_config *config = &dev->mode_config; + struct drm_colorop *colorop, *next; + + list_for_each_entry_safe(colorop, next, &config-Quoted 1 line
colorop_list,Quoted 3 lines
head) {
+drm_colorop_cleanup(colorop);
+ kfree(colorop);This free here seems a bit strange. I don't see any requirement on the
colorop pointer in the init function, so we can expect it to be embedded
in a bigger structure, so this kfree may affect a non-allocated pointer.I would expect one of:
- a clear documentation in drm_plane_colorop_*_init documentation that
explicitly says that you need to pass a kzalloc pointer => very error
prone, if the user don't read carefully the documentation it may lead to
undefined behaviorQuoted 8 lines
- that drm_plane_colorop_*_init will do the kzalloc itself (so we garantee that the pointer is always a kzalloc pointer) => it will forbid
to embed colorop structure in bigger structure. I don't think this is
the case today, but I don't know if this can become a limitation for
other drivers.Yes it makes to have kzalloc and kfree done both in vkms/amdgpu or both
in drm_*.Does the following change make sense to you?
drivers/gpu/drm/drm_colorop.c +0
-0@@ -214,6 +216,13 @@ int drm_plane_colorop_curve_1d_init(struct
drm_device*dev, structdrm_colorop*
structdrm_property*prop;
int ret;drivers/gpu/drm/drm_colorop.c +7
-0+ colorop =kzalloc (sizeof (struct drm_colorop ),GFP_KERNEL ); +if (!colorop) { +drm_err (dev,"KMS: Failed to allocate colorop\n" ); + ret = -ENOMEM ; + goto cleanup; + } + if (!supported_tfs) { drm_err(dev, "No supported TFs for new 1D curve coloropon [PLANE:%d:%s]\n",
drivers/gpu/drm/vkms/vkms_colorop.c +0
-0@@ -24,12 +24,6 @@ static int vkms_initialize_color_pipeline(struct
drm_plane*plane, structdrm_pr
memset(ops, 0, sizeof(ops));/* 1st op: 1d curve */
drivers/gpu/drm/vkms/vkms_colorop.c +0
-6- ops[i] =kzalloc (sizeof (*ops[i]),GFP_KERNEL ); -if (!ops[i]) { -drm_err (dev,"KMS: Failed to allocate colorop\n" ); - ret = -ENOMEM ; - goto cleanup; - } ret = drm_plane_colorop_curve_1d_init(dev, ops[i], plane,
supported_tfs,Quoted 3 lines
DRM_COLOROP_FLAG_ALLOW_BYPASS);Well, as Louis mentions, this doesn't play well with embedding a colorop into a larger struct, which is something I'm relying on to track additional bits for post-blend colorops in the MediaTek driver in [1].
Quoted 11 lines
I don't see an issue with the existing solution. From the function's
documentation: "Provides a default color pipeline destroy handler fordrm_device.", "default" is the key word here, each driver is currently responsible for allocating every colorop and cleaning it up, and this function is a helper for the common case where adrm_coloropis not embedded into another struct. For the cases where it is, the driver should create its owndestroy()that properly frees the pointer for the container struct, which is exactly what I'm doing in [1]. Perhaps we should just add to thedestroy()documentation that it frees the pointer and so drivers embedding the struct should implement their own helper.
We can go to option 1 of clear documentation in drm_plane_colorop_*_init. This doesn't seem to impact the API itself and improvement in future extension can include this.
Does anyone have concerns?
Quoted 4 lines
On that train of thought, I think it would make sense to make
drm_colorop_cleanup()public [2] as part of this series so that those drivers can reuse it.
Yeah making drm_colorop_cleanup public is probably a good idea.
Quoted 7 lines
[1]
https://lore.kernel.org/dri-devel/20250822-mtk-post-blend-color-pipeline-v1-0-a9446d4aca82@collabora.com/T/#ma6b44d451ed84c9c6b32d26e6192ad951612444d
[2]
https://lore.kernel.org/dri-devel/20250822-mtk-post-blend-color-pipeline-v1-0-a9446d4aca82@collabora.com/T/#m15e8f52a03d711a4d3ab9cecc7b9cafb2954c489Quoted 1 line
PATCH v11 14/47 drm/vkms: Add enumerated 1D curve colorop
In reply to Alex HungFrom: Harry Wentland <[email protected]>
This patch introduces a VKMS color pipeline that includes two drm_colorops for named transfer functions. For now the only ones supported are sRGB EOTF, sRGB Inverse EOTF, and a Linear TF. We will expand this in the future but I don't want to do so without accompanying IGT tests.
We introduce a new vkms_luts.c file that hard-codes sRGB EOTF, sRGB Inverse EOTF, and a linear EOTF LUT. These have been generated with 256 entries each as IGT is currently testing only 8 bpc surfaces. We will likely need higher precision but I'm reluctant to make that change without clear indication that we need it. We'll revisit and, if necessary, regenerate the LUTs when we have IGT tests for higher precision buffers.
---
v11:
- Update drm_colorop_pipeline_destroy from plane to dev (Nícolas Prado)
- Fix undefined errors by EXPORT_SYMBOL symbols (kernel test robot)
v9:
- Replace cleanup code by drm_colorop_pipeline_destroy (Simon Ser)
- Update function names by _plane_ (Chaitanya Kumar Borah)
v8:
- Replace DRM_ERROR by drm_err (Louis Chauvet)
- Replace DRM_WARN_ONCE by drm_WARN_ONCE (Louis Chauvet)
- Fix conflicts with upstream VKMS (Louis Chauvet)
- Add comments for drm_color_lut linear_array (Louis Chauvet)
v7:
- Fix checkpatch warnings (Louis Chauvet)
- Change kzalloc(sizeof(struct drm_colorop) ...) to kzalloc(sizeof(*ops[i]) ...)
- Remove if (ops[i]) before kfree(ops[i])
- Fix styles by adding and removing spaces (new lines, tabs and so on)
v6:
- drop 'len' var (Louis Chauvet)
- cleanup if colorop alloc or init fails (Louis Chauvet)
- switch loop in pre_blend_transform (Louis Chauvet)
- drop extraneous if (colorop) inside while (colorop) (Louis Chauvet)
v5:
- Squash with "Pull apply_colorop out of pre_blend_color_transform" (Sebastian)
- Fix warnings
- Fix include
- Drop TODOs
v4:
- Drop _tf_ from color_pipeline init function
- Pass supported TFs into colorop init
- Create bypass pipeline in DRM helper (Pekka)
v2:
- Add commit description
- Fix sRGB EOTF LUT definition
- Add linear and sRGB inverse EOTF LUTs
drivers/gpu/drm/vkms/Makefile | 4 +- drivers/gpu/drm/vkms/vkms_colorop.c | 81 +++ drivers/gpu/drm/vkms/vkms_composer.c | 51 +- drivers/gpu/drm/vkms/vkms_drv.h | 3 + drivers/gpu/drm/vkms/vkms_luts.c | 811 +++++++++++++++++++++++++++ drivers/gpu/drm/vkms/vkms_luts.h | 12 + drivers/gpu/drm/vkms/vkms_plane.c | 2 + 7 files changed, 962 insertions(+), 2 deletions(-) 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
drivers/gpu/drm/vkms/Makefile +3 -1
@@ -8,7 +8,9 @@ vkms-y := \ vkms_composer.o \ vkms_writeback.o \ vkms_connector.o \ - vkms_config.o + vkms_config.o \ + vkms_colorop.o \ + vkms_luts.o obj-$(CONFIG_DRM_VKMS) += vkms.o obj-$(CONFIG_DRM_VKMS_KUNIT_TEST) += tests/
drivers/gpu/drm/vkms/vkms_colorop.c new file +81 -0
81 lines not on this page · raw message
drivers/gpu/drm/vkms/vkms_composer.c +50 -1
69 lines not on this page · raw message
drivers/gpu/drm/vkms/vkms_drv.h +3 -0
@@ -300,4 +300,7 @@ void vkms_writeback_row(struct vkms_writeback_job *wb, const struct line_buffer/* Writeback */ int vkms_enable_writeback_connector (struct vkms_device *vkmsdev,struct vkms_output *vkms_out); +/* Colorops */ +int vkms_initialize_colorops (struct drm_plane *plane); +#endif /* _VKMS_DRV_H_ */
drivers/gpu/drm/vkms/vkms_luts.c new file +811 -0
811 lines not on this page · raw message
drivers/gpu/drm/vkms/vkms_luts.h new file +12 -0
@@ -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_ */
drivers/gpu/drm/vkms/vkms_plane.c +2 -0
@@ -232,5 +232,7 @@ struct vkms_plane *vkms_plane_init(struct vkms_device *vkmsdev,DRM_COLOR_YCBCR_BT601 , DRM_COLOR_YCBCR_FULL_RANGE); +vkms_initialize_colorops (&plane->base); +return plane; }
Signature · 1 line
2.43.0
Louis Chauvet
maintainerRe: [PATCH V11 14/47] drm/vkms: Add enumerated 1D curve colorop
Le 15/08/2025 à 05:50, Alex Hung a écrit :
Quoted 146 lines
From: Harry Wentland <[email protected]>
This patch introduces a VKMS color pipeline that includes two
drm_coloropsfor named transfer functions. For now the only ones supported are sRGB EOTF, sRGB Inverse EOTF, and a Linear TF. We will expand this in the future but I don't want to do so without accompanying IGT tests.We introduce a new
vkms_luts.cfile that hard-codes sRGB EOTF, sRGB Inverse EOTF, and a linear EOTF LUT. These have been generated with 256 entries each as IGT is currently testing only 8 bpc surfaces. We will likely need higher precision but I'm reluctant to make that change without clear indication that we need it. We'll revisit and, if necessary, regenerate the LUTs when we have IGT tests for higher precision buffers.Signed-off-by Harry Wentland <[email protected]>Signed-off-by Alex Hung <[email protected]>Reviewed-by Daniel Stone <[email protected]>---
v11:
- Updatedrm_colorop_pipeline_destroyfrom plane to dev (Nícolas Prado)
- Fix undefined errors byEXPORT_SYMBOLsymbols (kernel test robot)v9:
- Replace cleanup code bydrm_colorop_pipeline_destroy(Simon Ser)
- Update function names by _plane_ (Chaitanya Kumar Borah)v8:
- ReplaceDRM_ERRORbydrm_err(Louis Chauvet)
- ReplaceDRM_WARN_ONCEbydrm_WARN_ONCE(Louis Chauvet)
- Fix conflicts with upstream VKMS (Louis Chauvet)
- Add comments fordrm_color_lutlinear_array(Louis Chauvet)v7:
- Fix checkpatch warnings (Louis Chauvet)
- Changekzalloc(sizeof(struct drm_colorop) ...)tokzalloc(sizeof(*ops[i]) ...)
- Remove if (ops[i]) beforekfree(ops[i])
- Fix styles by adding and removing spaces (new lines, tabs and so on)v6:
- drop 'len' var (Louis Chauvet)
- cleanup if colorop alloc or init fails (Louis Chauvet)
- switch loop inpre_blend_transform(Louis Chauvet)
- drop extraneous if (colorop) inside while (colorop) (Louis Chauvet)v5:
- Squash with "Pullapply_coloropout ofpre_blend_color_transform" (Sebastian)
- Fix warnings
- Fix include
- Drop TODOsv4:
- Drop _tf_ fromcolor_pipelineinit function
- Pass supported TFs into colorop init
- Create bypass pipeline in DRM helper (Pekka)v2:
- Add commit description
- Fix sRGB EOTF LUT definition
- Add linear and sRGB inverse EOTF LUTsdrivers/gpu/drm/vkms/Makefile | 4 +- drivers/gpu/drm/vkms/vkms_colorop.c | 81 +++ drivers/gpu/drm/vkms/vkms_composer.c | 51 +- drivers/gpu/drm/vkms/vkms_drv.h | 3 + drivers/gpu/drm/vkms/vkms_luts.c | 811 +++++++++++++++++++++++++++ drivers/gpu/drm/vkms/vkms_luts.h | 12 + drivers/gpu/drm/vkms/vkms_plane.c | 2 + 7 files changed, 962 insertions(+), 2 deletions(-)create mode 100644
drivers/gpu/drm/vkms/vkms_colorop.ccreate mode 100644drivers/gpu/drm/vkms/vkms_luts.ccreate mode 100644drivers/gpu/drm/vkms/vkms_luts.hdrivers/gpu/drm/vkms/Makefile +3
-1@@ -8,7 +8,9 @@ vkms-y := \ vkms_composer.o \ vkms_writeback.o \ vkms_connector.o \ - vkms_config.o + vkms_config.o \ + vkms_colorop.o \ + vkms_luts.o obj-$(CONFIG_DRM_VKMS) += vkms.o obj-$(CONFIG_DRM_VKMS_KUNIT_TEST) += tests/drivers/gpu/drm/vkms/vkms_colorop.c new file +50
-0@@ -0,0 +1,81 @@ +// SPDX-License-Identifier: GPL-2.0+ + +#include <linux/slab.h> +#include <drm/drm_colorop.h> +#include <drm/drm_print.h> +#include <drm/drm_property.h> +#include <drm/drm_plane.h> + +#include "vkms_drv.h" + +static const u64 supported_tfs = +BIT (DRM_COLOROP_1D_CURVE_SRGB_EOTF ) | +BIT (DRM_COLOROP_1D_CURVE_SRGB_INV_EOTF ); + +#define MAX_COLOR_PIPELINE_OPS 2 + +static int vkms_initialize_color_pipeline (struct drm_plane *plane,struct drm_prop_enum_list *list) +{ +struct drm_colorop *ops[MAX_COLOR_PIPELINE_OPS ]; +struct drm_device *dev = plane->dev; +int ret; +int i =0 ; + +memset (ops,0 ,sizeof (ops)); + +/* 1st op: 1d curve */ + ops[i] =kzalloc (sizeof (*ops[i]),GFP_KERNEL ); +if (!ops[i]) { +drm_err (dev,"KMS: Failed to allocate colorop\n" ); + ret = -ENOMEM ; + goto cleanup; + } + + ret =drm_plane_colorop_curve_1d_init (dev, ops[i], plane, supported_tfs); +if (ret) + goto cleanup; + + list->type = ops[i]->base.id; + list->name =kasprintf (GFP_KERNEL ,"Color Pipeline %d" , ops[i]->base.id); + + i++; + +/* 2nd op: 1d curve */ + ops[i] =kzalloc (sizeof (*ops[i]),GFP_KERNEL ); +if (!ops[i]) { +drm_err (dev,"KMS: Failed to allocate colorop\n" ); + ret = -ENOMEM ; + goto cleanup; + } +
drivers/gpu/drm/vkms/vkms_colorop.c line 60
Quoted 10 lines
drivers/gpu/drm/vkms/vkms_colorop.c new file +10
-0+ ret =drm_plane_colorop_curve_1d_init (dev, ops[i], plane, supported_tfs); +if (ret) + goto cleanup; + +drm_colorop_set_next_property (ops[i -1 ], ops[i]); + +return 0 ; + +cleanup: +drm_colorop_pipeline_destroy (dev);
If it take a device, it means that it deletes everything, which is not what I would expect here: you are curently allocating a specific plane pipeline, and deleting all colorop for other planes because of one failure is counterintuitive.
In this situation I would expect either:
- error propagation to vkms_create or vkms_output_init (it is already the case) and "device-wide" cleanup in vkms_create/vkms_output_init;
- "local" cleanup (i.e only this specific pipeline)
If you go for the route "error propagation", you can also create drmm_ variants of drm_plane_colorop_*_init to automagically call drm_colorop_cleanup on device removal (+ it will allow using drmm_kzalloc to also free ops[i] automatically and partially solve)
Quoted 956 lines
drivers/gpu/drm/vkms/vkms_colorop.c new file +21
-0+ +return ret; +} + +int vkms_initialize_colorops (struct drm_plane *plane) +{ +struct drm_prop_enum_list pipeline; +int ret; + +/* Add color pipeline */ + ret =vkms_initialize_color_pipeline (plane, &pipeline); +if (ret) +return ret; + +/* Create COLOR_PIPELINE property and attach */ + ret =drm_plane_create_color_pipeline_property (plane, &pipeline,1 ); +if (ret) +return ret; + +return 0 ; +}drivers/gpu/drm/vkms/vkms_composer.c +50
-1@@ -14,6 +14,7 @@#include "vkms_composer.h" #include "vkms_drv.h" +#include "vkms_luts.h" static u16 pre_mul_blend_channel (u16 src,u16 dst,u16 alpha) {@@ -136,6 +137,54 @@ static void apply_lut(const struct vkms_crtc_state *crtc_state, struct line_buff } } +static void apply_colorop (struct pixel_argb_u16 *pixel,struct drm_colorop *colorop) +{ +struct drm_colorop_state *colorop_state = colorop->state; +struct drm_device *dev = colorop->dev; + +if (colorop->type ==DRM_COLOROP_1D_CURVE ) { +switch (colorop_state->curve_1d_type) { +case DRM_COLOROP_1D_CURVE_SRGB_INV_EOTF : + pixel->r =apply_lut_to_channel_value (&srgb_inv_eotf, pixel->r,LUT_RED ); + pixel->g =apply_lut_to_channel_value (&srgb_inv_eotf, pixel->g,LUT_GREEN ); + pixel->b =apply_lut_to_channel_value (&srgb_inv_eotf, pixel->b,LUT_BLUE ); +break ; +case DRM_COLOROP_1D_CURVE_SRGB_EOTF : + pixel->r =apply_lut_to_channel_value (&srgb_eotf, pixel->r,LUT_RED ); + pixel->g =apply_lut_to_channel_value (&srgb_eotf, pixel->g,LUT_GREEN ); + pixel->b =apply_lut_to_channel_value (&srgb_eotf, pixel->b,LUT_BLUE ); +break ; +default : +drm_WARN_ONCE (dev, true, +"unknown colorop 1D curve type %d\n" , + colorop_state->curve_1d_type); +break ; + } + } +} + +static void pre_blend_color_transform (const struct vkms_plane_state *plane_state, +struct line_buffer *output_buffer) +{ +for (size_t x =0 ; x < output_buffer->n_pixels; x++) { +struct drm_colorop *colorop = plane_state->base.base.color_pipeline; + +while (colorop) { +struct drm_colorop_state *colorop_state; + + colorop_state = colorop->state; + +if (!colorop_state) +return ; + +if (!colorop_state->bypass) +apply_colorop (&output_buffer->pixels[x], colorop); + + colorop = colorop->next; + } + } +} +/** * direction_for_rotation() - Get the correct reading direction for a given rotation * @@ -351,7 +400,7 @@ static void blend_line(struct vkms_plane_state *current_plane, int y,*/ current_plane->pixel_read_line (current_plane, src_x_start, src_y_start, direction, pixel_count, &stage_buffer->pixels[dst_x_start]); - +pre_blend_color_transform (current_plane, stage_buffer);pre_mul_alpha_blend (stage_buffer, output_buffer, dst_x_start, pixel_count); }drivers/gpu/drm/vkms/vkms_drv.h +3
-0@@ -300,4 +300,7 @@ void vkms_writeback_row(struct vkms_writeback_job *wb, const struct line_buffer/* Writeback */ int vkms_enable_writeback_connector (struct vkms_device *vkmsdev,struct vkms_output *vkms_out); +/* Colorops */ +int vkms_initialize_colorops (struct drm_plane *plane); +#endif /* _VKMS_DRV_H_ */ drivers/gpu/drm/vkms/vkms_luts.c new file +811
-0@@ -0,0 +1,811 @@ +// SPDX-License-Identifier: GPL-2.0+ + +#include <drm/drm_mode.h> + +#include "vkms_drv.h" +#include "vkms_luts.h" + +/* +* These luts were generated with a LUT generated based on +* skia's transfer function code. The LUT generator can be +* found at +* https://gitlab.freedesktop.org/hwentland/lutgen +*/ + +static struct drm_color_lut linear_array[LUT_SIZE ] = { + {0x0 ,0x0 ,0x0 ,0 }, + {0x101 ,0x101 ,0x101 ,0 }, + {0x202 ,0x202 ,0x202 ,0 }, + {0x303 ,0x303 ,0x303 ,0 }, + {0x404 ,0x404 ,0x404 ,0 }, + {0x505 ,0x505 ,0x505 ,0 }, + {0x606 ,0x606 ,0x606 ,0 }, + {0x707 ,0x707 ,0x707 ,0 }, + {0x808 ,0x808 ,0x808 ,0 }, + {0x909 ,0x909 ,0x909 ,0 }, + {0xa0a ,0xa0a ,0xa0a ,0 }, + {0xb0b ,0xb0b ,0xb0b ,0 }, + {0xc0c ,0xc0c ,0xc0c ,0 }, + {0xd0d ,0xd0d ,0xd0d ,0 }, + {0xe0e ,0xe0e ,0xe0e ,0 }, + {0xf0f ,0xf0f ,0xf0f ,0 }, + {0x1010 ,0x1010 ,0x1010 ,0 }, + {0x1111 ,0x1111 ,0x1111 ,0 }, + {0x1212 ,0x1212 ,0x1212 ,0 }, + {0x1313 ,0x1313 ,0x1313 ,0 }, + {0x1414 ,0x1414 ,0x1414 ,0 }, + {0x1515 ,0x1515 ,0x1515 ,0 }, + {0x1616 ,0x1616 ,0x1616 ,0 }, + {0x1717 ,0x1717 ,0x1717 ,0 }, + {0x1818 ,0x1818 ,0x1818 ,0 }, + {0x1919 ,0x1919 ,0x1919 ,0 }, + {0x1a1a ,0x1a1a ,0x1a1a ,0 }, + {0x1b1b ,0x1b1b ,0x1b1b ,0 }, + {0x1c1c ,0x1c1c ,0x1c1c ,0 }, + {0x1d1d ,0x1d1d ,0x1d1d ,0 }, + {0x1e1e ,0x1e1e ,0x1e1e ,0 }, + {0x1f1f ,0x1f1f ,0x1f1f ,0 }, + {0x2020 ,0x2020 ,0x2020 ,0 }, + {0x2121 ,0x2121 ,0x2121 ,0 }, + {0x2222 ,0x2222 ,0x2222 ,0 }, + {0x2323 ,0x2323 ,0x2323 ,0 }, + {0x2424 ,0x2424 ,0x2424 ,0 }, + {0x2525 ,0x2525 ,0x2525 ,0 }, + {0x2626 ,0x2626 ,0x2626 ,0 }, + {0x2727 ,0x2727 ,0x2727 ,0 }, + {0x2828 ,0x2828 ,0x2828 ,0 }, + {0x2929 ,0x2929 ,0x2929 ,0 }, + {0x2a2a ,0x2a2a ,0x2a2a ,0 }, + {0x2b2b ,0x2b2b ,0x2b2b ,0 }, + {0x2c2c ,0x2c2c ,0x2c2c ,0 }, + {0x2d2d ,0x2d2d ,0x2d2d ,0 }, + {0x2e2e ,0x2e2e ,0x2e2e ,0 }, + {0x2f2f ,0x2f2f ,0x2f2f ,0 }, + {0x3030 ,0x3030 ,0x3030 ,0 }, + {0x3131 ,0x3131 ,0x3131 ,0 }, + {0x3232 ,0x3232 ,0x3232 ,0 }, + {0x3333 ,0x3333 ,0x3333 ,0 }, + {0x3434 ,0x3434 ,0x3434 ,0 }, + {0x3535 ,0x3535 ,0x3535 ,0 }, + {0x3636 ,0x3636 ,0x3636 ,0 }, + {0x3737 ,0x3737 ,0x3737 ,0 }, + {0x3838 ,0x3838 ,0x3838 ,0 }, + {0x3939 ,0x3939 ,0x3939 ,0 }, + {0x3a3a ,0x3a3a ,0x3a3a ,0 }, + {0x3b3b ,0x3b3b ,0x3b3b ,0 }, + {0x3c3c ,0x3c3c ,0x3c3c ,0 }, + {0x3d3d ,0x3d3d ,0x3d3d ,0 }, + {0x3e3e ,0x3e3e ,0x3e3e ,0 }, + {0x3f3f ,0x3f3f ,0x3f3f ,0 }, + {0x4040 ,0x4040 ,0x4040 ,0 }, + {0x4141 ,0x4141 ,0x4141 ,0 }, + {0x4242 ,0x4242 ,0x4242 ,0 }, + {0x4343 ,0x4343 ,0x4343 ,0 }, + {0x4444 ,0x4444 ,0x4444 ,0 }, + {0x4545 ,0x4545 ,0x4545 ,0 }, + {0x4646 ,0x4646 ,0x4646 ,0 }, + {0x4747 ,0x4747 ,0x4747 ,0 }, + {0x4848 ,0x4848 ,0x4848 ,0 }, + {0x4949 ,0x4949 ,0x4949 ,0 }, + {0x4a4a ,0x4a4a ,0x4a4a ,0 }, + {0x4b4b ,0x4b4b ,0x4b4b ,0 }, + {0x4c4c ,0x4c4c ,0x4c4c ,0 }, + {0x4d4d ,0x4d4d ,0x4d4d ,0 }, + {0x4e4e ,0x4e4e ,0x4e4e ,0 }, + {0x4f4f ,0x4f4f ,0x4f4f ,0 }, + {0x5050 ,0x5050 ,0x5050 ,0 }, + {0x5151 ,0x5151 ,0x5151 ,0 }, + {0x5252 ,0x5252 ,0x5252 ,0 }, + {0x5353 ,0x5353 ,0x5353 ,0 }, + {0x5454 ,0x5454 ,0x5454 ,0 }, + {0x5555 ,0x5555 ,0x5555 ,0 }, + {0x5656 ,0x5656 ,0x5656 ,0 }, + {0x5757 ,0x5757 ,0x5757 ,0 }, + {0x5858 ,0x5858 ,0x5858 ,0 }, + {0x5959 ,0x5959 ,0x5959 ,0 }, + {0x5a5a ,0x5a5a ,0x5a5a ,0 }, + {0x5b5b ,0x5b5b ,0x5b5b ,0 }, + {0x5c5c ,0x5c5c ,0x5c5c ,0 }, + {0x5d5d ,0x5d5d ,0x5d5d ,0 }, + {0x5e5e ,0x5e5e ,0x5e5e ,0 }, + {0x5f5f ,0x5f5f ,0x5f5f ,0 }, + {0x6060 ,0x6060 ,0x6060 ,0 }, + {0x6161 ,0x6161 ,0x6161 ,0 }, + {0x6262 ,0x6262 ,0x6262 ,0 }, + {0x6363 ,0x6363 ,0x6363 ,0 }, + {0x6464 ,0x6464 ,0x6464 ,0 }, + {0x6565 ,0x6565 ,0x6565 ,0 }, + {0x6666 ,0x6666 ,0x6666 ,0 }, + {0x6767 ,0x6767 ,0x6767 ,0 }, + {0x6868 ,0x6868 ,0x6868 ,0 }, + {0x6969 ,0x6969 ,0x6969 ,0 }, + {0x6a6a ,0x6a6a ,0x6a6a ,0 }, + {0x6b6b ,0x6b6b ,0x6b6b ,0 }, + {0x6c6c ,0x6c6c ,0x6c6c ,0 }, + {0x6d6d ,0x6d6d ,0x6d6d ,0 }, + {0x6e6e ,0x6e6e ,0x6e6e ,0 }, + {0x6f6f ,0x6f6f ,0x6f6f ,0 }, + {0x7070 ,0x7070 ,0x7070 ,0 }, + {0x7171 ,0x7171 ,0x7171 ,0 }, + {0x7272 ,0x7272 ,0x7272 ,0 }, + {0x7373 ,0x7373 ,0x7373 ,0 }, + {0x7474 ,0x7474 ,0x7474 ,0 }, + {0x7575 ,0x7575 ,0x7575 ,0 }, + {0x7676 ,0x7676 ,0x7676 ,0 }, + {0x7777 ,0x7777 ,0x7777 ,0 }, + {0x7878 ,0x7878 ,0x7878 ,0 }, + {0x7979 ,0x7979 ,0x7979 ,0 }, + {0x7a7a ,0x7a7a ,0x7a7a ,0 }, + {0x7b7b ,0x7b7b ,0x7b7b ,0 }, + {0x7c7c ,0x7c7c ,0x7c7c ,0 }, + {0x7d7d ,0x7d7d ,0x7d7d ,0 }, + {0x7e7e ,0x7e7e ,0x7e7e ,0 }, + {0x7f7f ,0x7f7f ,0x7f7f ,0 }, + {0x8080 ,0x8080 ,0x8080 ,0 }, + {0x8181 ,0x8181 ,0x8181 ,0 }, + {0x8282 ,0x8282 ,0x8282 ,0 }, + {0x8383 ,0x8383 ,0x8383 ,0 }, + {0x8484 ,0x8484 ,0x8484 ,0 }, + {0x8585 ,0x8585 ,0x8585 ,0 }, + {0x8686 ,0x8686 ,0x8686 ,0 }, + {0x8787 ,0x8787 ,0x8787 ,0 }, + {0x8888 ,0x8888 ,0x8888 ,0 }, + {0x8989 ,0x8989 ,0x8989 ,0 }, + {0x8a8a ,0x8a8a ,0x8a8a ,0 }, + {0x8b8b ,0x8b8b ,0x8b8b ,0 }, + {0x8c8c ,0x8c8c ,0x8c8c ,0 }, + {0x8d8d ,0x8d8d ,0x8d8d ,0 }, + {0x8e8e ,0x8e8e ,0x8e8e ,0 }, + {0x8f8f ,0x8f8f ,0x8f8f ,0 }, + {0x9090 ,0x9090 ,0x9090 ,0 }, + {0x9191 ,0x9191 ,0x9191 ,0 }, + {0x9292 ,0x9292 ,0x9292 ,0 }, + {0x9393 ,0x9393 ,0x9393 ,0 }, + {0x9494 ,0x9494 ,0x9494 ,0 }, + {0x9595 ,0x9595 ,0x9595 ,0 }, + {0x9696 ,0x9696 ,0x9696 ,0 }, + {0x9797 ,0x9797 ,0x9797 ,0 }, + {0x9898 ,0x9898 ,0x9898 ,0 }, + {0x9999 ,0x9999 ,0x9999 ,0 }, + {0x9a9a ,0x9a9a ,0x9a9a ,0 }, + {0x9b9b ,0x9b9b ,0x9b9b ,0 }, + {0x9c9c ,0x9c9c ,0x9c9c ,0 }, + {0x9d9d ,0x9d9d ,0x9d9d ,0 }, + {0x9e9e ,0x9e9e ,0x9e9e ,0 }, + {0x9f9f ,0x9f9f ,0x9f9f ,0 }, + {0xa0a0 ,0xa0a0 ,0xa0a0 ,0 }, + {0xa1a1 ,0xa1a1 ,0xa1a1 ,0 }, + {0xa2a2 ,0xa2a2 ,0xa2a2 ,0 }, + {0xa3a3 ,0xa3a3 ,0xa3a3 ,0 }, + {0xa4a4 ,0xa4a4 ,0xa4a4 ,0 }, + {0xa5a5 ,0xa5a5 ,0xa5a5 ,0 }, + {0xa6a6 ,0xa6a6 ,0xa6a6 ,0 }, + {0xa7a7 ,0xa7a7 ,0xa7a7 ,0 }, + {0xa8a8 ,0xa8a8 ,0xa8a8 ,0 }, + {0xa9a9 ,0xa9a9 ,0xa9a9 ,0 }, + {0xaaaa ,0xaaaa ,0xaaaa ,0 }, + {0xabab ,0xabab ,0xabab ,0 }, + {0xacac ,0xacac ,0xacac ,0 }, + {0xadad ,0xadad ,0xadad ,0 }, + {0xaeae ,0xaeae ,0xaeae ,0 }, + {0xafaf ,0xafaf ,0xafaf ,0 }, + {0xb0b0 ,0xb0b0 ,0xb0b0 ,0 }, + {0xb1b1 ,0xb1b1 ,0xb1b1 ,0 }, + {0xb2b2 ,0xb2b2 ,0xb2b2 ,0 }, + {0xb3b3 ,0xb3b3 ,0xb3b3 ,0 }, + {0xb4b4 ,0xb4b4 ,0xb4b4 ,0 }, + {0xb5b5 ,0xb5b5 ,0xb5b5 ,0 }, + {0xb6b6 ,0xb6b6 ,0xb6b6 ,0 }, + {0xb7b7 ,0xb7b7 ,0xb7b7 ,0 }, + {0xb8b8 ,0xb8b8 ,0xb8b8 ,0 }, + {0xb9b9 ,0xb9b9 ,0xb9b9 ,0 }, + {0xbaba ,0xbaba ,0xbaba ,0 }, + {0xbbbb ,0xbbbb ,0xbbbb ,0 }, + {0xbcbc ,0xbcbc ,0xbcbc ,0 }, + {0xbdbd ,0xbdbd ,0xbdbd ,0 }, + {0xbebe ,0xbebe ,0xbebe ,0 }, + {0xbfbf ,0xbfbf ,0xbfbf ,0 }, + {0xc0c0 ,0xc0c0 ,0xc0c0 ,0 }, + {0xc1c1 ,0xc1c1 ,0xc1c1 ,0 }, + {0xc2c2 ,0xc2c2 ,0xc2c2 ,0 }, + {0xc3c3 ,0xc3c3 ,0xc3c3 ,0 }, + {0xc4c4 ,0xc4c4 ,0xc4c4 ,0 }, + {0xc5c5 ,0xc5c5 ,0xc5c5 ,0 }, + {0xc6c6 ,0xc6c6 ,0xc6c6 ,0 }, + {0xc7c7 ,0xc7c7 ,0xc7c7 ,0 }, + {0xc8c8 ,0xc8c8 ,0xc8c8 ,0 }, + {0xc9c9 ,0xc9c9 ,0xc9c9 ,0 }, + {0xcaca ,0xcaca ,0xcaca ,0 }, + {0xcbcb ,0xcbcb ,0xcbcb ,0 }, + {0xcccc ,0xcccc ,0xcccc ,0 }, + {0xcdcd ,0xcdcd ,0xcdcd ,0 }, + {0xcece ,0xcece ,0xcece ,0 }, + {0xcfcf ,0xcfcf ,0xcfcf ,0 }, + {0xd0d0 ,0xd0d0 ,0xd0d0 ,0 }, + {0xd1d1 ,0xd1d1 ,0xd1d1 ,0 }, + {0xd2d2 ,0xd2d2 ,0xd2d2 ,0 }, + {0xd3d3 ,0xd3d3 ,0xd3d3 ,0 }, + {0xd4d4 ,0xd4d4 ,0xd4d4 ,0 }, + {0xd5d5 ,0xd5d5 ,0xd5d5 ,0 }, + {0xd6d6 ,0xd6d6 ,0xd6d6 ,0 }, + {0xd7d7 ,0xd7d7 ,0xd7d7 ,0 }, + {0xd8d8 ,0xd8d8 ,0xd8d8 ,0 }, + {0xd9d9 ,0xd9d9 ,0xd9d9 ,0 }, + {0xdada ,0xdada ,0xdada ,0 }, + {0xdbdb ,0xdbdb ,0xdbdb ,0 }, + {0xdcdc ,0xdcdc ,0xdcdc ,0 }, + {0xdddd ,0xdddd ,0xdddd ,0 }, + {0xdede ,0xdede ,0xdede ,0 }, + {0xdfdf ,0xdfdf ,0xdfdf ,0 }, + {0xe0e0 ,0xe0e0 ,0xe0e0 ,0 }, + {0xe1e1 ,0xe1e1 ,0xe1e1 ,0 }, + {0xe2e2 ,0xe2e2 ,0xe2e2 ,0 }, + {0xe3e3 ,0xe3e3 ,0xe3e3 ,0 }, + {0xe4e4 ,0xe4e4 ,0xe4e4 ,0 }, + {0xe5e5 ,0xe5e5 ,0xe5e5 ,0 }, + {0xe6e6 ,0xe6e6 ,0xe6e6 ,0 }, + {0xe7e7 ,0xe7e7 ,0xe7e7 ,0 }, + {0xe8e8 ,0xe8e8 ,0xe8e8 ,0 }, + {0xe9e9 ,0xe9e9 ,0xe9e9 ,0 }, + {0xeaea ,0xeaea ,0xeaea ,0 }, + {0xebeb ,0xebeb ,0xebeb ,0 }, + {0xecec ,0xecec ,0xecec ,0 }, + {0xeded ,0xeded ,0xeded ,0 }, + {0xeeee ,0xeeee ,0xeeee ,0 }, + {0xefef ,0xefef ,0xefef ,0 }, + {0xf0f0 ,0xf0f0 ,0xf0f0 ,0 }, + {0xf1f1 ,0xf1f1 ,0xf1f1 ,0 }, + {0xf2f2 ,0xf2f2 ,0xf2f2 ,0 }, + {0xf3f3 ,0xf3f3 ,0xf3f3 ,0 }, + {0xf4f4 ,0xf4f4 ,0xf4f4 ,0 }, + {0xf5f5 ,0xf5f5 ,0xf5f5 ,0 }, + {0xf6f6 ,0xf6f6 ,0xf6f6 ,0 }, + {0xf7f7 ,0xf7f7 ,0xf7f7 ,0 }, + {0xf8f8 ,0xf8f8 ,0xf8f8 ,0 }, + {0xf9f9 ,0xf9f9 ,0xf9f9 ,0 }, + {0xfafa ,0xfafa ,0xfafa ,0 }, + {0xfbfb ,0xfbfb ,0xfbfb ,0 }, + {0xfcfc ,0xfcfc ,0xfcfc ,0 }, + {0xfdfd ,0xfdfd ,0xfdfd ,0 }, + {0xfefe ,0xfefe ,0xfefe ,0 }, + {0xffff ,0xffff ,0xffff ,0 }, +}; + +const struct vkms_color_lut linear_eotf = { + .base = linear_array, + .lut_length =LUT_SIZE , + .channel_value2index_ratio =0xff00ffll +}; +EXPORT_SYMBOL (linear_eotf); + +static struct drm_color_lut srgb_array[LUT_SIZE ] = { + {0x0 ,0x0 ,0x0 ,0 }, + {0x13 ,0x13 ,0x13 ,0 }, + {0x27 ,0x27 ,0x27 ,0 }, + {0x3b ,0x3b ,0x3b ,0 }, + {0x4f ,0x4f ,0x4f ,0 }, + {0x63 ,0x63 ,0x63 ,0 }, + {0x77 ,0x77 ,0x77 ,0 }, + {0x8b ,0x8b ,0x8b ,0 }, + {0x9f ,0x9f ,0x9f ,0 }, + {0xb3 ,0xb3 ,0xb3 ,0 }, + {0xc6 ,0xc6 ,0xc6 ,0 }, + {0xdb ,0xdb ,0xdb ,0 }, + {0xf0 ,0xf0 ,0xf0 ,0 }, + {0x107 ,0x107 ,0x107 ,0 }, + {0x11f ,0x11f ,0x11f ,0 }, + {0x139 ,0x139 ,0x139 ,0 }, + {0x153 ,0x153 ,0x153 ,0 }, + {0x16f ,0x16f ,0x16f ,0 }, + {0x18c ,0x18c ,0x18c ,0 }, + {0x1aa ,0x1aa ,0x1aa ,0 }, + {0x1ca ,0x1ca ,0x1ca ,0 }, + {0x1eb ,0x1eb ,0x1eb ,0 }, + {0x20d ,0x20d ,0x20d ,0 }, + {0x231 ,0x231 ,0x231 ,0 }, + {0x256 ,0x256 ,0x256 ,0 }, + {0x27d ,0x27d ,0x27d ,0 }, + {0x2a4 ,0x2a4 ,0x2a4 ,0 }, + {0x2ce ,0x2ce ,0x2ce ,0 }, + {0x2f9 ,0x2f9 ,0x2f9 ,0 }, + {0x325 ,0x325 ,0x325 ,0 }, + {0x352 ,0x352 ,0x352 ,0 }, + {0x381 ,0x381 ,0x381 ,0 }, + {0x3b2 ,0x3b2 ,0x3b2 ,0 }, + {0x3e4 ,0x3e4 ,0x3e4 ,0 }, + {0x418 ,0x418 ,0x418 ,0 }, + {0x44d ,0x44d ,0x44d ,0 }, + {0x484 ,0x484 ,0x484 ,0 }, + {0x4bc ,0x4bc ,0x4bc ,0 }, + {0x4f6 ,0x4f6 ,0x4f6 ,0 }, + {0x531 ,0x531 ,0x531 ,0 }, + {0x56e ,0x56e ,0x56e ,0 }, + {0x5ad ,0x5ad ,0x5ad ,0 }, + {0x5ed ,0x5ed ,0x5ed ,0 }, + {0x62f ,0x62f ,0x62f ,0 }, + {0x672 ,0x672 ,0x672 ,0 }, + {0x6b7 ,0x6b7 ,0x6b7 ,0 }, + {0x6fe ,0x6fe ,0x6fe ,0 }, + {0x746 ,0x746 ,0x746 ,0 }, + {0x791 ,0x791 ,0x791 ,0 }, + {0x7dc ,0x7dc ,0x7dc ,0 }, + {0x82a ,0x82a ,0x82a ,0 }, + {0x879 ,0x879 ,0x879 ,0 }, + {0x8ca ,0x8ca ,0x8ca ,0 }, + {0x91d ,0x91d ,0x91d ,0 }, + {0x971 ,0x971 ,0x971 ,0 }, + {0x9c7 ,0x9c7 ,0x9c7 ,0 }, + {0xa1f ,0xa1f ,0xa1f ,0 }, + {0xa79 ,0xa79 ,0xa79 ,0 }, + {0xad4 ,0xad4 ,0xad4 ,0 }, + {0xb32 ,0xb32 ,0xb32 ,0 }, + {0xb91 ,0xb91 ,0xb91 ,0 }, + {0xbf2 ,0xbf2 ,0xbf2 ,0 }, + {0xc54 ,0xc54 ,0xc54 ,0 }, + {0xcb9 ,0xcb9 ,0xcb9 ,0 }, + {0xd1f ,0xd1f ,0xd1f ,0 }, + {0xd88 ,0xd88 ,0xd88 ,0 }, + {0xdf2 ,0xdf2 ,0xdf2 ,0 }, + {0xe5e ,0xe5e ,0xe5e ,0 }, + {0xecc ,0xecc ,0xecc ,0 }, + {0xf3c ,0xf3c ,0xf3c ,0 }, + {0xfad ,0xfad ,0xfad ,0 }, + {0x1021 ,0x1021 ,0x1021 ,0 }, + {0x1096 ,0x1096 ,0x1096 ,0 }, + {0x110e ,0x110e ,0x110e ,0 }, + {0x1187 ,0x1187 ,0x1187 ,0 }, + {0x1203 ,0x1203 ,0x1203 ,0 }, + {0x1280 ,0x1280 ,0x1280 ,0 }, + {0x12ff ,0x12ff ,0x12ff ,0 }, + {0x1380 ,0x1380 ,0x1380 ,0 }, + {0x1404 ,0x1404 ,0x1404 ,0 }, + {0x1489 ,0x1489 ,0x1489 ,0 }, + {0x1510 ,0x1510 ,0x1510 ,0 }, + {0x1599 ,0x1599 ,0x1599 ,0 }, + {0x1624 ,0x1624 ,0x1624 ,0 }, + {0x16b2 ,0x16b2 ,0x16b2 ,0 }, + {0x1741 ,0x1741 ,0x1741 ,0 }, + {0x17d2 ,0x17d2 ,0x17d2 ,0 }, + {0x1865 ,0x1865 ,0x1865 ,0 }, + {0x18fb ,0x18fb ,0x18fb ,0 }, + {0x1992 ,0x1992 ,0x1992 ,0 }, + {0x1a2c ,0x1a2c ,0x1a2c ,0 }, + {0x1ac8 ,0x1ac8 ,0x1ac8 ,0 }, + {0x1b65 ,0x1b65 ,0x1b65 ,0 }, + {0x1c05 ,0x1c05 ,0x1c05 ,0 }, + {0x1ca7 ,0x1ca7 ,0x1ca7 ,0 }, + {0x1d4b ,0x1d4b ,0x1d4b ,0 }, + {0x1df1 ,0x1df1 ,0x1df1 ,0 }, + {0x1e99 ,0x1e99 ,0x1e99 ,0 }, + {0x1f44 ,0x1f44 ,0x1f44 ,0 }, + {0x1ff0 ,0x1ff0 ,0x1ff0 ,0 }, + {0x209f ,0x209f ,0x209f ,0 }, + {0x2150 ,0x2150 ,0x2150 ,0 }, + {0x2203 ,0x2203 ,0x2203 ,0 }, + {0x22b8 ,0x22b8 ,0x22b8 ,0 }, + {0x2370 ,0x2370 ,0x2370 ,0 }, + {0x2429 ,0x2429 ,0x2429 ,0 }, + {0x24e5 ,0x24e5 ,0x24e5 ,0 }, + {0x25a3 ,0x25a3 ,0x25a3 ,0 }, + {0x2663 ,0x2663 ,0x2663 ,0 }, + {0x2726 ,0x2726 ,0x2726 ,0 }, + {0x27ea ,0x27ea ,0x27ea ,0 }, + {0x28b1 ,0x28b1 ,0x28b1 ,0 }, + {0x297a ,0x297a ,0x297a ,0 }, + {0x2a45 ,0x2a45 ,0x2a45 ,0 }, + {0x2b13 ,0x2b13 ,0x2b13 ,0 }, + {0x2be3 ,0x2be3 ,0x2be3 ,0 }, + {0x2cb5 ,0x2cb5 ,0x2cb5 ,0 }, + {0x2d89 ,0x2d89 ,0x2d89 ,0 }, + {0x2e60 ,0x2e60 ,0x2e60 ,0 }, + {0x2f39 ,0x2f39 ,0x2f39 ,0 }, + {0x3014 ,0x3014 ,0x3014 ,0 }, + {0x30f2 ,0x30f2 ,0x30f2 ,0 }, + {0x31d2 ,0x31d2 ,0x31d2 ,0 }, + {0x32b4 ,0x32b4 ,0x32b4 ,0 }, + {0x3398 ,0x3398 ,0x3398 ,0 }, + {0x347f ,0x347f ,0x347f ,0 }, + {0x3569 ,0x3569 ,0x3569 ,0 }, + {0x3654 ,0x3654 ,0x3654 ,0 }, + {0x3742 ,0x3742 ,0x3742 ,0 }, + {0x3832 ,0x3832 ,0x3832 ,0 }, + {0x3925 ,0x3925 ,0x3925 ,0 }, + {0x3a1a ,0x3a1a ,0x3a1a ,0 }, + {0x3b11 ,0x3b11 ,0x3b11 ,0 }, + {0x3c0b ,0x3c0b ,0x3c0b ,0 }, + {0x3d07 ,0x3d07 ,0x3d07 ,0 }, + {0x3e05 ,0x3e05 ,0x3e05 ,0 }, + {0x3f06 ,0x3f06 ,0x3f06 ,0 }, + {0x400a ,0x400a ,0x400a ,0 }, + {0x410f ,0x410f ,0x410f ,0 }, + {0x4218 ,0x4218 ,0x4218 ,0 }, + {0x4322 ,0x4322 ,0x4322 ,0 }, + {0x442f ,0x442f ,0x442f ,0 }, + {0x453f ,0x453f ,0x453f ,0 }, + {0x4650 ,0x4650 ,0x4650 ,0 }, + {0x4765 ,0x4765 ,0x4765 ,0 }, + {0x487c ,0x487c ,0x487c ,0 }, + {0x4995 ,0x4995 ,0x4995 ,0 }, + {0x4ab1 ,0x4ab1 ,0x4ab1 ,0 }, + {0x4bcf ,0x4bcf ,0x4bcf ,0 }, + {0x4cf0 ,0x4cf0 ,0x4cf0 ,0 }, + {0x4e13 ,0x4e13 ,0x4e13 ,0 }, + {0x4f39 ,0x4f39 ,0x4f39 ,0 }, + {0x5061 ,0x5061 ,0x5061 ,0 }, + {0x518b ,0x518b ,0x518b ,0 }, + {0x52b9 ,0x52b9 ,0x52b9 ,0 }, + {0x53e8 ,0x53e8 ,0x53e8 ,0 }, + {0x551b ,0x551b ,0x551b ,0 }, + {0x5650 ,0x5650 ,0x5650 ,0 }, + {0x5787 ,0x5787 ,0x5787 ,0 }, + {0x58c1 ,0x58c1 ,0x58c1 ,0 }, + {0x59fd ,0x59fd ,0x59fd ,0 }, + {0x5b3c ,0x5b3c ,0x5b3c ,0 }, + {0x5c7e ,0x5c7e ,0x5c7e ,0 }, + {0x5dc2 ,0x5dc2 ,0x5dc2 ,0 }, + {0x5f09 ,0x5f09 ,0x5f09 ,0 }, + {0x6052 ,0x6052 ,0x6052 ,0 }, + {0x619e ,0x619e ,0x619e ,0 }, + {0x62ec ,0x62ec ,0x62ec ,0 }, + {0x643d ,0x643d ,0x643d ,0 }, + {0x6591 ,0x6591 ,0x6591 ,0 }, + {0x66e7 ,0x66e7 ,0x66e7 ,0 }, + {0x6840 ,0x6840 ,0x6840 ,0 }, + {0x699b ,0x699b ,0x699b ,0 }, + {0x6afa ,0x6afa ,0x6afa ,0 }, + {0x6c5a ,0x6c5a ,0x6c5a ,0 }, + {0x6dbe ,0x6dbe ,0x6dbe ,0 }, + {0x6f24 ,0x6f24 ,0x6f24 ,0 }, + {0x708c ,0x708c ,0x708c ,0 }, + {0x71f8 ,0x71f8 ,0x71f8 ,0 }, + {0x7366 ,0x7366 ,0x7366 ,0 }, + {0x74d6 ,0x74d6 ,0x74d6 ,0 }, + {0x764a ,0x764a ,0x764a ,0 }, + {0x77c0 ,0x77c0 ,0x77c0 ,0 }, + {0x7938 ,0x7938 ,0x7938 ,0 }, + {0x7ab4 ,0x7ab4 ,0x7ab4 ,0 }, + {0x7c32 ,0x7c32 ,0x7c32 ,0 }, + {0x7db3 ,0x7db3 ,0x7db3 ,0 }, + {0x7f36 ,0x7f36 ,0x7f36 ,0 }, + {0x80bc ,0x80bc ,0x80bc ,0 }, + {0x8245 ,0x8245 ,0x8245 ,0 }, + {0x83d1 ,0x83d1 ,0x83d1 ,0 }, + {0x855f ,0x855f ,0x855f ,0 }, + {0x86f0 ,0x86f0 ,0x86f0 ,0 }, + {0x8884 ,0x8884 ,0x8884 ,0 }, + {0x8a1a ,0x8a1a ,0x8a1a ,0 }, + {0x8bb4 ,0x8bb4 ,0x8bb4 ,0 }, + {0x8d50 ,0x8d50 ,0x8d50 ,0 }, + {0x8eee ,0x8eee ,0x8eee ,0 }, + {0x9090 ,0x9090 ,0x9090 ,0 }, + {0x9234 ,0x9234 ,0x9234 ,0 }, + {0x93db ,0x93db ,0x93db ,0 }, + {0x9585 ,0x9585 ,0x9585 ,0 }, + {0x9732 ,0x9732 ,0x9732 ,0 }, + {0x98e1 ,0x98e1 ,0x98e1 ,0 }, + {0x9a93 ,0x9a93 ,0x9a93 ,0 }, + {0x9c48 ,0x9c48 ,0x9c48 ,0 }, + {0x9e00 ,0x9e00 ,0x9e00 ,0 }, + {0x9fbb ,0x9fbb ,0x9fbb ,0 }, + {0xa178 ,0xa178 ,0xa178 ,0 }, + {0xa338 ,0xa338 ,0xa338 ,0 }, + {0xa4fb ,0xa4fb ,0xa4fb ,0 }, + {0xa6c1 ,0xa6c1 ,0xa6c1 ,0 }, + {0xa88a ,0xa88a ,0xa88a ,0 }, + {0xaa56 ,0xaa56 ,0xaa56 ,0 }, + {0xac24 ,0xac24 ,0xac24 ,0 }, + {0xadf5 ,0xadf5 ,0xadf5 ,0 }, + {0xafc9 ,0xafc9 ,0xafc9 ,0 }, + {0xb1a0 ,0xb1a0 ,0xb1a0 ,0 }, + {0xb37a ,0xb37a ,0xb37a ,0 }, + {0xb557 ,0xb557 ,0xb557 ,0 }, + {0xb736 ,0xb736 ,0xb736 ,0 }, + {0xb919 ,0xb919 ,0xb919 ,0 }, + {0xbafe ,0xbafe ,0xbafe ,0 }, + {0xbce6 ,0xbce6 ,0xbce6 ,0 }, + {0xbed2 ,0xbed2 ,0xbed2 ,0 }, + {0xc0c0 ,0xc0c0 ,0xc0c0 ,0 }, + {0xc2b0 ,0xc2b0 ,0xc2b0 ,0 }, + {0xc4a4 ,0xc4a4 ,0xc4a4 ,0 }, + {0xc69b ,0xc69b ,0xc69b ,0 }, + {0xc895 ,0xc895 ,0xc895 ,0 }, + {0xca91 ,0xca91 ,0xca91 ,0 }, + {0xcc91 ,0xcc91 ,0xcc91 ,0 }, + {0xce93 ,0xce93 ,0xce93 ,0 }, + {0xd098 ,0xd098 ,0xd098 ,0 }, + {0xd2a1 ,0xd2a1 ,0xd2a1 ,0 }, + {0xd4ac ,0xd4ac ,0xd4ac ,0 }, + {0xd6ba ,0xd6ba ,0xd6ba ,0 }, + {0xd8cb ,0xd8cb ,0xd8cb ,0 }, + {0xdadf ,0xdadf ,0xdadf ,0 }, + {0xdcf7 ,0xdcf7 ,0xdcf7 ,0 }, + {0xdf11 ,0xdf11 ,0xdf11 ,0 }, + {0xe12e ,0xe12e ,0xe12e ,0 }, + {0xe34e ,0xe34e ,0xe34e ,0 }, + {0xe571 ,0xe571 ,0xe571 ,0 }, + {0xe796 ,0xe796 ,0xe796 ,0 }, + {0xe9bf ,0xe9bf ,0xe9bf ,0 }, + {0xebeb ,0xebeb ,0xebeb ,0 }, + {0xee1a ,0xee1a ,0xee1a ,0 }, + {0xf04c ,0xf04c ,0xf04c ,0 }, + {0xf281 ,0xf281 ,0xf281 ,0 }, + {0xf4b9 ,0xf4b9 ,0xf4b9 ,0 }, + {0xf6f4 ,0xf6f4 ,0xf6f4 ,0 }, + {0xf932 ,0xf932 ,0xf932 ,0 }, + {0xfb73 ,0xfb73 ,0xfb73 ,0 }, + {0xfdb7 ,0xfdb7 ,0xfdb7 ,0 }, + {0xffff ,0xffff ,0xffff ,0 }, +}; + +const struct vkms_color_lut srgb_eotf = { + .base = srgb_array, + .lut_length =LUT_SIZE , + .channel_value2index_ratio =0xff00ffll +}; +EXPORT_SYMBOL (srgb_eotf); + +static struct drm_color_lut srgb_inv_array[LUT_SIZE ] = { + {0x0 ,0x0 ,0x0 ,0 }, + {0xcc2 ,0xcc2 ,0xcc2 ,0 }, + {0x15be ,0x15be ,0x15be ,0 }, + {0x1c56 ,0x1c56 ,0x1c56 ,0 }, + {0x21bd ,0x21bd ,0x21bd ,0 }, + {0x2666 ,0x2666 ,0x2666 ,0 }, + {0x2a8a ,0x2a8a ,0x2a8a ,0 }, + {0x2e4c ,0x2e4c ,0x2e4c ,0 }, + {0x31c0 ,0x31c0 ,0x31c0 ,0 }, + {0x34f6 ,0x34f6 ,0x34f6 ,0 }, + {0x37f9 ,0x37f9 ,0x37f9 ,0 }, + {0x3acf ,0x3acf ,0x3acf ,0 }, + {0x3d80 ,0x3d80 ,0x3d80 ,0 }, + {0x4010 ,0x4010 ,0x4010 ,0 }, + {0x4284 ,0x4284 ,0x4284 ,0 }, + {0x44dd ,0x44dd ,0x44dd ,0 }, + {0x4720 ,0x4720 ,0x4720 ,0 }, + {0x494e ,0x494e ,0x494e ,0 }, + {0x4b69 ,0x4b69 ,0x4b69 ,0 }, + {0x4d73 ,0x4d73 ,0x4d73 ,0 }, + {0x4f6e ,0x4f6e ,0x4f6e ,0 }, + {0x5159 ,0x5159 ,0x5159 ,0 }, + {0x5337 ,0x5337 ,0x5337 ,0 }, + {0x5509 ,0x5509 ,0x5509 ,0 }, + {0x56cf ,0x56cf ,0x56cf ,0 }, + {0x588a ,0x588a ,0x588a ,0 }, + {0x5a3b ,0x5a3b ,0x5a3b ,0 }, + {0x5be2 ,0x5be2 ,0x5be2 ,0 }, + {0x5d80 ,0x5d80 ,0x5d80 ,0 }, + {0x5f16 ,0x5f16 ,0x5f16 ,0 }, + {0x60a4 ,0x60a4 ,0x60a4 ,0 }, + {0x6229 ,0x6229 ,0x6229 ,0 }, + {0x63a8 ,0x63a8 ,0x63a8 ,0 }, + {0x6520 ,0x6520 ,0x6520 ,0 }, + {0x6691 ,0x6691 ,0x6691 ,0 }, + {0x67fc ,0x67fc ,0x67fc ,0 }, + {0x6961 ,0x6961 ,0x6961 ,0 }, + {0x6ac0 ,0x6ac0 ,0x6ac0 ,0 }, + {0x6c19 ,0x6c19 ,0x6c19 ,0 }, + {0x6d6e ,0x6d6e ,0x6d6e ,0 }, + {0x6ebd ,0x6ebd ,0x6ebd ,0 }, + {0x7008 ,0x7008 ,0x7008 ,0 }, + {0x714d ,0x714d ,0x714d ,0 }, + {0x728f ,0x728f ,0x728f ,0 }, + {0x73cc ,0x73cc ,0x73cc ,0 }, + {0x7504 ,0x7504 ,0x7504 ,0 }, + {0x7639 ,0x7639 ,0x7639 ,0 }, + {0x776a ,0x776a ,0x776a ,0 }, + {0x7897 ,0x7897 ,0x7897 ,0 }, + {0x79c1 ,0x79c1 ,0x79c1 ,0 }, + {0x7ae7 ,0x7ae7 ,0x7ae7 ,0 }, + {0x7c09 ,0x7c09 ,0x7c09 ,0 }, + {0x7d28 ,0x7d28 ,0x7d28 ,0 }, + {0x7e44 ,0x7e44 ,0x7e44 ,0 }, + {0x7f5d ,0x7f5d ,0x7f5d ,0 }, + {0x8073 ,0x8073 ,0x8073 ,0 }, + {0x8186 ,0x8186 ,0x8186 ,0 }, + {0x8296 ,0x8296 ,0x8296 ,0 }, + {0x83a4 ,0x83a4 ,0x83a4 ,0 }, + {0x84ae ,0x84ae ,0x84ae ,0 }, + {0x85b6 ,0x85b6 ,0x85b6 ,0 }, + {0x86bc ,0x86bc ,0x86bc ,0 }, + {0x87bf ,0x87bf ,0x87bf ,0 }, + {0x88bf ,0x88bf ,0x88bf ,0 }, + {0x89be ,0x89be ,0x89be ,0 }, + {0x8ab9 ,0x8ab9 ,0x8ab9 ,0 }, + {0x8bb3 ,0x8bb3 ,0x8bb3 ,0 }, + {0x8cab ,0x8cab ,0x8cab ,0 }, + {0x8da0 ,0x8da0 ,0x8da0 ,0 }, + {0x8e93 ,0x8e93 ,0x8e93 ,0 }, + {0x8f84 ,0x8f84 ,0x8f84 ,0 }, + {0x9073 ,0x9073 ,0x9073 ,0 }, + {0x9161 ,0x9161 ,0x9161 ,0 }, + {0x924c ,0x924c ,0x924c ,0 }, + {0x9335 ,0x9335 ,0x9335 ,0 }, + {0x941d ,0x941d ,0x941d ,0 }, + {0x9503 ,0x9503 ,0x9503 ,0 }, + {0x95e7 ,0x95e7 ,0x95e7 ,0 }, + {0x96c9 ,0x96c9 ,0x96c9 ,0 }, + {0x97aa ,0x97aa ,0x97aa ,0 }, + {0x9889 ,0x9889 ,0x9889 ,0 }, + {0x9966 ,0x9966 ,0x9966 ,0 }, + {0x9a42 ,0x9a42 ,0x9a42 ,0 }, + {0x9b1c ,0x9b1c ,0x9b1c ,0 }, + {0x9bf5 ,0x9bf5 ,0x9bf5 ,0 }, + {0x9ccc ,0x9ccc ,0x9ccc ,0 }, + {0x9da1 ,0x9da1 ,0x9da1 ,0 }, + {0x9e76 ,0x9e76 ,0x9e76 ,0 }, + {0x9f49 ,0x9f49 ,0x9f49 ,0 }, + {0xa01a ,0xa01a ,0xa01a ,0 }, + {0xa0ea ,0xa0ea ,0xa0ea ,0 }, + {0xa1b9 ,0xa1b9 ,0xa1b9 ,0 }, + {0xa286 ,0xa286 ,0xa286 ,0 }, + {0xa352 ,0xa352 ,0xa352 ,0 }, + {0xa41d ,0xa41d ,0xa41d ,0 }, + {0xa4e7 ,0xa4e7 ,0xa4e7 ,0 }, + {0xa5af ,0xa5af ,0xa5af ,0 }, + {0xa676 ,0xa676 ,0xa676 ,0 }, + {0xa73c ,0xa73c ,0xa73c ,0 }, + {0xa801 ,0xa801 ,0xa801 ,0 }, + {0xa8c5 ,0xa8c5 ,0xa8c5 ,0 }, + {0xa987 ,0xa987 ,0xa987 ,0 }, + {0xaa48 ,0xaa48 ,0xaa48 ,0 }, + {0xab09 ,0xab09 ,0xab09 ,0 }, + {0xabc8 ,0xabc8 ,0xabc8 ,0 }, + {0xac86 ,0xac86 ,0xac86 ,0 }, + {0xad43 ,0xad43 ,0xad43 ,0 }, + {0xadff ,0xadff ,0xadff ,0 }, + {0xaeba ,0xaeba ,0xaeba ,0 }, + {0xaf74 ,0xaf74 ,0xaf74 ,0 }, + {0xb02d ,0xb02d ,0xb02d ,0 }, + {0xb0e5 ,0xb0e5 ,0xb0e5 ,0 }, + {0xb19c ,0xb19c ,0xb19c ,0 }, + {0xb252 ,0xb252 ,0xb252 ,0 }, + {0xb307 ,0xb307 ,0xb307 ,0 }, + {0xb3bb ,0xb3bb ,0xb3bb ,0 }, + {0xb46f ,0xb46f ,0xb46f ,0 }, + {0xb521 ,0xb521 ,0xb521 ,0 }, + {0xb5d3 ,0xb5d3 ,0xb5d3 ,0 }, + {0xb683 ,0xb683 ,0xb683 ,0 }, + {0xb733 ,0xb733 ,0xb733 ,0 }, + {0xb7e2 ,0xb7e2 ,0xb7e2 ,0 }, + {0xb890 ,0xb890 ,0xb890 ,0 }, + {0xb93d ,0xb93d ,0xb93d ,0 }, + {0xb9ea ,0xb9ea ,0xb9ea ,0 }, + {0xba96 ,0xba96 ,0xba96 ,0 }, + {0xbb40 ,0xbb40 ,0xbb40 ,0 }, + {0xbbea ,0xbbea ,0xbbea ,0 }, + {0xbc94 ,0xbc94 ,0xbc94 ,0 }, + {0xbd3c ,0xbd3c ,0xbd3c ,0 }, + {0xbde4 ,0xbde4 ,0xbde4 ,0 }, + {0xbe8b ,0xbe8b ,0xbe8b ,0 }, + {0xbf31 ,0xbf31 ,0xbf31 ,0 }, + {0xbfd7 ,0xbfd7 ,0xbfd7 ,0 }, + {0xc07b ,0xc07b ,0xc07b ,0 }, + {0xc120 ,0xc120 ,0xc120 ,0 }, + {0xc1c3 ,0xc1c3 ,0xc1c3 ,0 }, + {0xc266 ,0xc266 ,0xc266 ,0 }, + {0xc308 ,0xc308 ,0xc308 ,0 }, + {0xc3a9 ,0xc3a9 ,0xc3a9 ,0 }, + {0xc449 ,0xc449 ,0xc449 ,0 }, + {0xc4e9 ,0xc4e9 ,0xc4e9 ,0 }, + {0xc589 ,0xc589 ,0xc589 ,0 }, + {0xc627 ,0xc627 ,0xc627 ,0 }, + {0xc6c5 ,0xc6c5 ,0xc6c5 ,0 }, + {0xc763 ,0xc763 ,0xc763 ,0 }, + {0xc7ff ,0xc7ff ,0xc7ff ,0 }, + {0xc89b ,0xc89b ,0xc89b ,0 }, + {0xc937 ,0xc937 ,0xc937 ,0 }, + {0xc9d2 ,0xc9d2 ,0xc9d2 ,0 }, + {0xca6c ,0xca6c ,0xca6c ,0 }, + {0xcb06 ,0xcb06 ,0xcb06 ,0 }, + {0xcb9f ,0xcb9f ,0xcb9f ,0 }, + {0xcc37 ,0xcc37 ,0xcc37 ,0 }, + {0xcccf ,0xcccf ,0xcccf ,0 }, + {0xcd66 ,0xcd66 ,0xcd66 ,0 }, + {0xcdfd ,0xcdfd ,0xcdfd ,0 }, + {0xce93 ,0xce93 ,0xce93 ,0 }, + {0xcf29 ,0xcf29 ,0xcf29 ,0 }, + {0xcfbe ,0xcfbe ,0xcfbe ,0 }, + {0xd053 ,0xd053 ,0xd053 ,0 }, + {0xd0e7 ,0xd0e7 ,0xd0e7 ,0 }, + {0xd17a ,0xd17a ,0xd17a ,0 }, + {0xd20d ,0xd20d ,0xd20d ,0 }, + {0xd2a0 ,0xd2a0 ,0xd2a0 ,0 }, + {0xd331 ,0xd331 ,0xd331 ,0 }, + {0xd3c3 ,0xd3c3 ,0xd3c3 ,0 }, + {0xd454 ,0xd454 ,0xd454 ,0 }, + {0xd4e4 ,0xd4e4 ,0xd4e4 ,0 }, + {0xd574 ,0xd574 ,0xd574 ,0 }, + {0xd603 ,0xd603 ,0xd603 ,0 }, + {0xd692 ,0xd692 ,0xd692 ,0 }, + {0xd720 ,0xd720 ,0xd720 ,0 }, + {0xd7ae ,0xd7ae ,0xd7ae ,0 }, + {0xd83c ,0xd83c ,0xd83c ,0 }, + {0xd8c9 ,0xd8c9 ,0xd8c9 ,0 }, + {0xd955 ,0xd955 ,0xd955 ,0 }, + {0xd9e1 ,0xd9e1 ,0xd9e1 ,0 }, + {0xda6d ,0xda6d ,0xda6d ,0 }, + {0xdaf8 ,0xdaf8 ,0xdaf8 ,0 }, + {0xdb83 ,0xdb83 ,0xdb83 ,0 }, + {0xdc0d ,0xdc0d ,0xdc0d ,0 }, + {0xdc97 ,0xdc97 ,0xdc97 ,0 }, + {0xdd20 ,0xdd20 ,0xdd20 ,0 }, + {0xdda9 ,0xdda9 ,0xdda9 ,0 }, + {0xde31 ,0xde31 ,0xde31 ,0 }, + {0xdeb9 ,0xdeb9 ,0xdeb9 ,0 }, + {0xdf41 ,0xdf41 ,0xdf41 ,0 }, + {0xdfc8 ,0xdfc8 ,0xdfc8 ,0 }, + {0xe04f ,0xe04f ,0xe04f ,0 }, + {0xe0d5 ,0xe0d5 ,0xe0d5 ,0 }, + {0xe15b ,0xe15b ,0xe15b ,0 }, + {0xe1e0 ,0xe1e0 ,0xe1e0 ,0 }, + {0xe266 ,0xe266 ,0xe266 ,0 }, + {0xe2ea ,0xe2ea ,0xe2ea ,0 }, + {0xe36f ,0xe36f ,0xe36f ,0 }, + {0xe3f3 ,0xe3f3 ,0xe3f3 ,0 }, + {0xe476 ,0xe476 ,0xe476 ,0 }, + {0xe4f9 ,0xe4f9 ,0xe4f9 ,0 }, + {0xe57c ,0xe57c ,0xe57c ,0 }, + {0xe5fe ,0xe5fe ,0xe5fe ,0 }, + {0xe680 ,0xe680 ,0xe680 ,0 }, + {0xe702 ,0xe702 ,0xe702 ,0 }, + {0xe783 ,0xe783 ,0xe783 ,0 }, + {0xe804 ,0xe804 ,0xe804 ,0 }, + {0xe884 ,0xe884 ,0xe884 ,0 }, + {0xe905 ,0xe905 ,0xe905 ,0 }, + {0xe984 ,0xe984 ,0xe984 ,0 }, + {0xea04 ,0xea04 ,0xea04 ,0 }, + {0xea83 ,0xea83 ,0xea83 ,0 }, + {0xeb02 ,0xeb02 ,0xeb02 ,0 }, + {0xeb80 ,0xeb80 ,0xeb80 ,0 }, + {0xebfe ,0xebfe ,0xebfe ,0 }, + {0xec7b ,0xec7b ,0xec7b ,0 }, + {0xecf9 ,0xecf9 ,0xecf9 ,0 }, + {0xed76 ,0xed76 ,0xed76 ,0 }, + {0xedf2 ,0xedf2 ,0xedf2 ,0 }, + {0xee6f ,0xee6f ,0xee6f ,0 }, + {0xeeeb ,0xeeeb ,0xeeeb ,0 }, + {0xef66 ,0xef66 ,0xef66 ,0 }, + {0xefe2 ,0xefe2 ,0xefe2 ,0 }, + {0xf05d ,0xf05d ,0xf05d ,0 }, + {0xf0d7 ,0xf0d7 ,0xf0d7 ,0 }, + {0xf152 ,0xf152 ,0xf152 ,0 }, + {0xf1cc ,0xf1cc ,0xf1cc ,0 }, + {0xf245 ,0xf245 ,0xf245 ,0 }, + {0xf2bf ,0xf2bf ,0xf2bf ,0 }, + {0xf338 ,0xf338 ,0xf338 ,0 }, + {0xf3b0 ,0xf3b0 ,0xf3b0 ,0 }, + {0xf429 ,0xf429 ,0xf429 ,0 }, + {0xf4a1 ,0xf4a1 ,0xf4a1 ,0 }, + {0xf519 ,0xf519 ,0xf519 ,0 }, + {0xf590 ,0xf590 ,0xf590 ,0 }, + {0xf608 ,0xf608 ,0xf608 ,0 }, + {0xf67e ,0xf67e ,0xf67e ,0 }, + {0xf6f5 ,0xf6f5 ,0xf6f5 ,0 }, + {0xf76b ,0xf76b ,0xf76b ,0 }, + {0xf7e1 ,0xf7e1 ,0xf7e1 ,0 }, + {0xf857 ,0xf857 ,0xf857 ,0 }, + {0xf8cd ,0xf8cd ,0xf8cd ,0 }, + {0xf942 ,0xf942 ,0xf942 ,0 }, + {0xf9b7 ,0xf9b7 ,0xf9b7 ,0 }, + {0xfa2b ,0xfa2b ,0xfa2b ,0 }, + {0xfaa0 ,0xfaa0 ,0xfaa0 ,0 }, + {0xfb14 ,0xfb14 ,0xfb14 ,0 }, + {0xfb88 ,0xfb88 ,0xfb88 ,0 }, + {0xfbfb ,0xfbfb ,0xfbfb ,0 }, + {0xfc6e ,0xfc6e ,0xfc6e ,0 }, + {0xfce1 ,0xfce1 ,0xfce1 ,0 }, + {0xfd54 ,0xfd54 ,0xfd54 ,0 }, + {0xfdc6 ,0xfdc6 ,0xfdc6 ,0 }, + {0xfe39 ,0xfe39 ,0xfe39 ,0 }, + {0xfeaa ,0xfeaa ,0xfeaa ,0 }, + {0xff1c ,0xff1c ,0xff1c ,0 }, + {0xff8d ,0xff8d ,0xff8d ,0 }, + {0xffff ,0xffff ,0xffff ,0 }, +}; + +const struct vkms_color_lut srgb_inv_eotf = { + .base = srgb_inv_array, + .lut_length =LUT_SIZE , + .channel_value2index_ratio =0xff00ffll +}; +EXPORT_SYMBOL (srgb_inv_eotf);drivers/gpu/drm/vkms/vkms_luts.h new file +12
-0@@ -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_ */ drivers/gpu/drm/vkms/vkms_plane.c +2
-0@@ -232,5 +232,7 @@ struct vkms_plane *vkms_plane_init(struct vkms_device *vkmsdev,DRM_COLOR_YCBCR_BT601 , DRM_COLOR_YCBCR_FULL_RANGE); +vkms_initialize_colorops (&plane->base); +return plane; }
Signature · 3 lines
Louis Chauvet, Bootlin Embedded Linux and Kernel engineering https://bootlin.com
Re: [PATCH V11 14/47] drm/vkms: Add enumerated 1D curve colorop
Quoted 160 lines · Louis Chauvet
Le 15/08/2025 à 05:50, Alex Hung a écrit :
Quoted 157 lines
From: Harry Wentland <[email protected]>
This patch introduces a VKMS color pipeline that includes two
drm_coloropsfor named transfer functions. For now the only ones supported are sRGB EOTF, sRGB Inverse EOTF, and a Linear TF. We will expand this in the future but I don't want to do so without accompanying IGT tests.We introduce a new
vkms_luts.cfile that hard-codes sRGB EOTF, sRGB Inverse EOTF, and a linear EOTF LUT. These have been generated with 256 entries each as IGT is currently testing only 8 bpc surfaces. We will likely need higher precision but I'm reluctant to make that change without clear indication that we need it. We'll revisit and, if necessary, regenerate the LUTs when we have IGT tests for higher precision buffers.Signed-off-by Harry Wentland <[email protected]>Signed-off-by Alex Hung <[email protected]>Reviewed-by Daniel Stone <[email protected]>---
v11:
- Updatedrm_colorop_pipeline_destroyfrom plane to dev (Nícolas Prado)
- Fix undefined errors byEXPORT_SYMBOLsymbols (kernel test robot)v9:
- Replace cleanup code bydrm_colorop_pipeline_destroy(Simon Ser)
- Update function names by _plane_ (Chaitanya Kumar Borah)v8:
- ReplaceDRM_ERRORbydrm_err(Louis Chauvet)
- ReplaceDRM_WARN_ONCEbydrm_WARN_ONCE(Louis Chauvet)
- Fix conflicts with upstream VKMS (Louis Chauvet)
- Add comments fordrm_color_lutlinear_array(Louis Chauvet)v7:
- Fix checkpatch warnings (Louis Chauvet)
- Changekzalloc(sizeof(struct drm_colorop) ...)tokzalloc(sizeof(*ops[i]) ...)
- Remove if (ops[i]) beforekfree(ops[i])
- Fix styles by adding and removing spaces (new lines, tabs and so on)v6:
- drop 'len' var (Louis Chauvet)
- cleanup if colorop alloc or init fails (Louis Chauvet)
- switch loop inpre_blend_transform(Louis Chauvet)
- drop extraneous if (colorop) inside while (colorop) (Louis Chauvet)v5:
- Squash with "Pullapply_coloropout ofpre_blend_color_transform" (Sebastian)
- Fix warnings
- Fix include
- Drop TODOsv4:
- Drop _tf_ fromcolor_pipelineinit function
- Pass supported TFs into colorop init
- Create bypass pipeline in DRM helper (Pekka)v2:
- Add commit description
- Fix sRGB EOTF LUT definition
- Add linear and sRGB inverse EOTF LUTsdrivers/gpu/drm/vkms/Makefile | 4 +- drivers/gpu/drm/vkms/vkms_colorop.c | 81 +++
drivers/gpu/drm/vkms/vkms_composer.c| 51 +- drivers/gpu/drm/vkms/vkms_drv.h | 3 + drivers/gpu/drm/vkms/vkms_luts.c | 811 +++++++++++++++++++++++++++ drivers/gpu/drm/vkms/vkms_luts.h | 12 + drivers/gpu/drm/vkms/vkms_plane.c | 2 +7 files changed, 962 insertions(+), 2 deletions(-)create mode 100644
drivers/gpu/drm/vkms/vkms_colorop.ccreate mode 100644drivers/gpu/drm/vkms/vkms_luts.ccreate mode 100644drivers/gpu/drm/vkms/vkms_luts.hdrivers/gpu/drm/vkms/Makefile +3
-1@@ -8,7 +8,9 @@ vkms-y := \ vkms_composer.o \ vkms_writeback.o \ vkms_connector.o \ - vkms_config.o + vkms_config.o \ + vkms_colorop.o \ + vkms_luts.oobj-$(CONFIG_DRM_VKMS) += vkms.o
obj-$(CONFIG_DRM_VKMS_KUNIT_TEST) += tests/drivers/gpu/drm/vkms/vkms_colorop.c new file +17
-0@@ -0,0 +1,81 @@ +// SPDX-License-Identifier: GPL-2.0+ + +#include <linux/slab.h> +#include <drm/drm_colorop.h> +#include <drm/drm_print.h> +#include <drm/drm_property.h> +#include <drm/drm_plane.h> + +#include "vkms_drv.h" + +static const u64 supported_tfs = + BIT(DRM_COLOROP_1D_CURVE_SRGB_EOTF) | + BIT(DRM_COLOROP_1D_CURVE_SRGB_INV_EOTF); + +#define MAX_COLOR_PIPELINE_OPS 2 + +static int vkms_initialize_color_pipeline(struct drm_plane *plane,struct
drm_prop_enum_list*list)drivers/gpu/drm/vkms/vkms_colorop.c new file +17
-0+{ + struct drm_colorop *ops[MAX_COLOR_PIPELINE_OPS]; + struct drm_device *dev = plane->dev; + int ret; + int i = 0; + + memset(ops, 0, sizeof(ops)); + + /* 1st op: 1d curve */ + ops[i] = kzalloc(sizeof(*ops[i]), GFP_KERNEL); + if (!ops[i]) { + drm_err(dev, "KMS: Failed to allocate colorop\n"); + ret = -ENOMEM; + goto cleanup; + } + + ret = drm_plane_colorop_curve_1d_init(dev, ops[i], plane,
supported_tfs);
+ if (ret)
+ goto cleanup;
+
+list->type= ops[i]->base.id;
+list->name= kasprintf(GFP_KERNEL, "Color Pipeline %d", ops[i]-Quoted 1 line
base.id);
drivers/gpu/drm/vkms/vkms_colorop.c new file +12
-0+ + i++; + + /* 2nd op: 1d curve */ + ops[i] = kzalloc(sizeof(*ops[i]), GFP_KERNEL); + if (!ops[i]) { + drm_err(dev, "KMS: Failed to allocate colorop\n"); + ret = -ENOMEM; + goto cleanup; + } + + ret = drm_plane_colorop_curve_1d_init(dev, ops[i], plane,
supported_tfs);
+ if (ret)
+ goto cleanup;drivers/gpu/drm/vkms/vkms_colorop.c new file +5
-0+ + drm_colorop_set_next_property(ops[i - 1], ops[i]); + + return 0; +
Quoted 8 lines
Quoted 2 lines
+cleanup:
+drm_colorop_pipeline_destroy(dev);If it take a device, it means that it deletes everything, which is not what I would expect here: you are curently allocating a specific plane pipeline, and deleting all colorop for other planes because of one failure is counterintuitive. In this situation I would expect either:
- error propagation tovkms_createorvkms_output_init(it is already
the case) and "device-wide" cleanup in vkms_create/vkms_output_init;
- "local" cleanup (i.e only this specific pipeline)
Hi Louis,
Does it make sense to make drm_colorop_pipeline_destroy(drm_plane), i.e. in PATCH 13 as in previously V10?
and then drm_colorop_pipeline_destroy should limit to the pipeline in a drm_plane and should do something like
drm_colorop_cleanup(colorop); free(colorop) drm_plane->colorop = NULL;
We can have same behaviours accross device drivers like amdgpu too.
Hi Simon and Nicolas,
Do you have comments on above proposal?
Quoted 969 lines
If you go for the route "error propagation", you can also create
drmm_variants of drm_plane_colorop_*_init to automagically calldrm_colorop_cleanupon device removal (+ it will allow usingdrmm_kzallocto also free ops[i] automatically and partially solve)Quoted 965 lines
drivers/gpu/drm/vkms/vkms_colorop.c new file +21
-0+ + return ret; +} + +int vkms_initialize_colorops (struct drm_plane *plane) +{ + struct drm_prop_enum_list pipeline; + int ret; + + /* Add color pipeline */ + ret = vkms_initialize_color_pipeline(plane, &pipeline); + if (ret) + return ret; + + /* Create COLOR_PIPELINE property and attach */ + ret = drm_plane_create_color_pipeline_property(plane, &pipeline, 1); + if (ret) + return ret; + + return 0; +}drivers/gpu/drm/vkms/vkms_composer.c +1
-0@@ -14,6 +14,7 @@ #include "vkms_composer.h" #include "vkms_drv.h" +#include "vkms_luts.h" static u16 pre_mul_blend_channel(u16 src, u16 dst, u16 alpha) {@@ -136,6 +137,54 @@ static void apply_lut(const struct
vkms_crtc_state*crtc_state, structline_buff
}
}
+static voidapply_colorop(struct pixel_argb_u16 *pixel, struct drm_colorop *colorop)drivers/gpu/drm/vkms/vkms_composer.c +8
-0+{ + struct drm_colorop_state *colorop_state = colorop->state; + struct drm_device *dev = colorop->dev; + + if (colorop->type == DRM_COLOROP_1D_CURVE) { + switch (colorop_state->curve_1d_type) { + case DRM_COLOROP_1D_CURVE_SRGB_INV_EOTF: + pixel->r = apply_lut_to_channel_value(&srgb_inv_eotf,
pixel->r,LUT_RED);
+pixel->g=apply_lut_to_channel_value(&srgb_inv_eotf, pixel->g, LUT_GREEN);
+pixel->b=apply_lut_to_channel_value(&srgb_inv_eotf, pixel->b, LUT_BLUE);
+ break;
+ caseDRM_COLOROP_1D_CURVE_SRGB_EOTF:
+pixel->r= apply_lut_to_channel_value(&srgb_eotf, pixel-Quoted 1 line
r,
LUT_RED);+
pixel->g= apply_lut_to_channel_value(&srgb_eotf, pixel-Quoted 1 line
g,
LUT_GREEN);+
pixel->b= apply_lut_to_channel_value(&srgb_eotf, pixel-Quoted 1 line
b,
LUT_BLUE);+ break;
+ default:
+ drm_WARN_ONCE(dev, true,
+ "unknown colorop 1D curve type %d\n", +colorop_state->curve_1d_type); + break;
+ }
+ }drivers/gpu/drm/vkms/vkms_composer.c +3
-0+} + +static void pre_blend_color_transform(const struct vkms_plane_state
*plane_state,
+ structline_buffer*output_buffer) +{
+ for (size_tx = 0; x <output_buffer->n_pixels; x++) { + structdrm_colorop*colorop = plane_state-Quoted 1 line
base.base.color_pipeline;
drivers/gpu/drm/vkms/vkms_composer.c +17
-0+ + while (colorop) { + struct drm_colorop_state *colorop_state; + + colorop_state = colorop->state; + + if (!colorop_state) + return; + + if (!colorop_state->bypass) + apply_colorop(&output_buffer->pixels[x], colorop); + + colorop = colorop->next; + } + } +} +/**
*direction_for_rotation()- Get the correct reading direction for a given rotation *drivers/gpu/drm/vkms/vkms_composer.c +0
-0@@ -351,7 +400,7 @@ static void blend_line(struct vkms_plane_state*current_plane, int y, */ current_plane->pixel_read_line(current_plane, src_x_start, src_y_start, direction,
pixel_count, &stage_buffer-Quoted 1 line
pixels[dst_x_start]);
-
+pre_blend_color_transform(current_plane, stage_buffer);pre_mul_alpha_blend(stage_buffer, output_buffer, dst_x_start, pixel_count);
}drivers/gpu/drm/vkms/vkms_drv.h +3
-0@@ -300,4 +300,7 @@ void vkms_writeback_row(struct vkms_writeback_job *wb, const struct line_buffer /* Writeback */ int vkms_enable_writeback_connector(struct vkms_device *vkmsdev, struct vkms_output *vkms_out); +/* Colorops */ +int vkms_initialize_colorops (struct drm_plane *plane); + #endif /* _VKMS_DRV_H_ */drivers/gpu/drm/vkms/vkms_luts.c new file +811
-0@@ -0,0 +1,811 @@ +// SPDX-License-Identifier: GPL-2.0+ + +#include <drm/drm_mode.h> + +#include "vkms_drv.h" +#include "vkms_luts.h" + +/* +* These luts were generated with a LUT generated based on +* skia's transfer function code. The LUT generator can be +* found at +* https://gitlab.freedesktop.org/hwentland/lutgen +*/ + +static struct drm_color_lut linear_array[LUT_SIZE ] = { + { 0x0, 0x0, 0x0, 0 }, + { 0x101, 0x101, 0x101, 0 }, + { 0x202, 0x202, 0x202, 0 }, + { 0x303, 0x303, 0x303, 0 }, + { 0x404, 0x404, 0x404, 0 }, + { 0x505, 0x505, 0x505, 0 }, + { 0x606, 0x606, 0x606, 0 }, + { 0x707, 0x707, 0x707, 0 }, + { 0x808, 0x808, 0x808, 0 }, + { 0x909, 0x909, 0x909, 0 }, + { 0xa0a, 0xa0a, 0xa0a, 0 }, + { 0xb0b, 0xb0b, 0xb0b, 0 }, + { 0xc0c, 0xc0c, 0xc0c, 0 }, + { 0xd0d, 0xd0d, 0xd0d, 0 }, + { 0xe0e, 0xe0e, 0xe0e, 0 }, + { 0xf0f, 0xf0f, 0xf0f, 0 }, + { 0x1010, 0x1010, 0x1010, 0 }, + { 0x1111, 0x1111, 0x1111, 0 }, + { 0x1212, 0x1212, 0x1212, 0 }, + { 0x1313, 0x1313, 0x1313, 0 }, + { 0x1414, 0x1414, 0x1414, 0 }, + { 0x1515, 0x1515, 0x1515, 0 }, + { 0x1616, 0x1616, 0x1616, 0 }, + { 0x1717, 0x1717, 0x1717, 0 }, + { 0x1818, 0x1818, 0x1818, 0 }, + { 0x1919, 0x1919, 0x1919, 0 }, + { 0x1a1a, 0x1a1a, 0x1a1a, 0 }, + { 0x1b1b, 0x1b1b, 0x1b1b, 0 }, + { 0x1c1c, 0x1c1c, 0x1c1c, 0 }, + { 0x1d1d, 0x1d1d, 0x1d1d, 0 }, + { 0x1e1e, 0x1e1e, 0x1e1e, 0 }, + { 0x1f1f, 0x1f1f, 0x1f1f, 0 }, + { 0x2020, 0x2020, 0x2020, 0 }, + { 0x2121, 0x2121, 0x2121, 0 }, + { 0x2222, 0x2222, 0x2222, 0 }, + { 0x2323, 0x2323, 0x2323, 0 }, + { 0x2424, 0x2424, 0x2424, 0 }, + { 0x2525, 0x2525, 0x2525, 0 }, + { 0x2626, 0x2626, 0x2626, 0 }, + { 0x2727, 0x2727, 0x2727, 0 }, + { 0x2828, 0x2828, 0x2828, 0 }, + { 0x2929, 0x2929, 0x2929, 0 }, + { 0x2a2a, 0x2a2a, 0x2a2a, 0 }, + { 0x2b2b, 0x2b2b, 0x2b2b, 0 }, + { 0x2c2c, 0x2c2c, 0x2c2c, 0 }, + { 0x2d2d, 0x2d2d, 0x2d2d, 0 }, + { 0x2e2e, 0x2e2e, 0x2e2e, 0 }, + { 0x2f2f, 0x2f2f, 0x2f2f, 0 }, + { 0x3030, 0x3030, 0x3030, 0 }, + { 0x3131, 0x3131, 0x3131, 0 }, + { 0x3232, 0x3232, 0x3232, 0 }, + { 0x3333, 0x3333, 0x3333, 0 }, + { 0x3434, 0x3434, 0x3434, 0 }, + { 0x3535, 0x3535, 0x3535, 0 }, + { 0x3636, 0x3636, 0x3636, 0 }, + { 0x3737, 0x3737, 0x3737, 0 }, + { 0x3838, 0x3838, 0x3838, 0 }, + { 0x3939, 0x3939, 0x3939, 0 }, + { 0x3a3a, 0x3a3a, 0x3a3a, 0 }, + { 0x3b3b, 0x3b3b, 0x3b3b, 0 }, + { 0x3c3c, 0x3c3c, 0x3c3c, 0 }, + { 0x3d3d, 0x3d3d, 0x3d3d, 0 }, + { 0x3e3e, 0x3e3e, 0x3e3e, 0 }, + { 0x3f3f, 0x3f3f, 0x3f3f, 0 }, + { 0x4040, 0x4040, 0x4040, 0 }, + { 0x4141, 0x4141, 0x4141, 0 }, + { 0x4242, 0x4242, 0x4242, 0 }, + { 0x4343, 0x4343, 0x4343, 0 }, + { 0x4444, 0x4444, 0x4444, 0 }, + { 0x4545, 0x4545, 0x4545, 0 }, + { 0x4646, 0x4646, 0x4646, 0 }, + { 0x4747, 0x4747, 0x4747, 0 }, + { 0x4848, 0x4848, 0x4848, 0 }, + { 0x4949, 0x4949, 0x4949, 0 }, + { 0x4a4a, 0x4a4a, 0x4a4a, 0 }, + { 0x4b4b, 0x4b4b, 0x4b4b, 0 }, + { 0x4c4c, 0x4c4c, 0x4c4c, 0 }, + { 0x4d4d, 0x4d4d, 0x4d4d, 0 }, + { 0x4e4e, 0x4e4e, 0x4e4e, 0 }, + { 0x4f4f, 0x4f4f, 0x4f4f, 0 }, + { 0x5050, 0x5050, 0x5050, 0 }, + { 0x5151, 0x5151, 0x5151, 0 }, + { 0x5252, 0x5252, 0x5252, 0 }, + { 0x5353, 0x5353, 0x5353, 0 }, + { 0x5454, 0x5454, 0x5454, 0 }, + { 0x5555, 0x5555, 0x5555, 0 }, + { 0x5656, 0x5656, 0x5656, 0 }, + { 0x5757, 0x5757, 0x5757, 0 }, + { 0x5858, 0x5858, 0x5858, 0 }, + { 0x5959, 0x5959, 0x5959, 0 }, + { 0x5a5a, 0x5a5a, 0x5a5a, 0 }, + { 0x5b5b, 0x5b5b, 0x5b5b, 0 }, + { 0x5c5c, 0x5c5c, 0x5c5c, 0 }, + { 0x5d5d, 0x5d5d, 0x5d5d, 0 }, + { 0x5e5e, 0x5e5e, 0x5e5e, 0 }, + { 0x5f5f, 0x5f5f, 0x5f5f, 0 }, + { 0x6060, 0x6060, 0x6060, 0 }, + { 0x6161, 0x6161, 0x6161, 0 }, + { 0x6262, 0x6262, 0x6262, 0 }, + { 0x6363, 0x6363, 0x6363, 0 }, + { 0x6464, 0x6464, 0x6464, 0 }, + { 0x6565, 0x6565, 0x6565, 0 }, + { 0x6666, 0x6666, 0x6666, 0 }, + { 0x6767, 0x6767, 0x6767, 0 }, + { 0x6868, 0x6868, 0x6868, 0 }, + { 0x6969, 0x6969, 0x6969, 0 }, + { 0x6a6a, 0x6a6a, 0x6a6a, 0 }, + { 0x6b6b, 0x6b6b, 0x6b6b, 0 }, + { 0x6c6c, 0x6c6c, 0x6c6c, 0 }, + { 0x6d6d, 0x6d6d, 0x6d6d, 0 }, + { 0x6e6e, 0x6e6e, 0x6e6e, 0 }, + { 0x6f6f, 0x6f6f, 0x6f6f, 0 }, + { 0x7070, 0x7070, 0x7070, 0 }, + { 0x7171, 0x7171, 0x7171, 0 }, + { 0x7272, 0x7272, 0x7272, 0 }, + { 0x7373, 0x7373, 0x7373, 0 }, + { 0x7474, 0x7474, 0x7474, 0 }, + { 0x7575, 0x7575, 0x7575, 0 }, + { 0x7676, 0x7676, 0x7676, 0 }, + { 0x7777, 0x7777, 0x7777, 0 }, + { 0x7878, 0x7878, 0x7878, 0 }, + { 0x7979, 0x7979, 0x7979, 0 }, + { 0x7a7a, 0x7a7a, 0x7a7a, 0 }, + { 0x7b7b, 0x7b7b, 0x7b7b, 0 }, + { 0x7c7c, 0x7c7c, 0x7c7c, 0 }, + { 0x7d7d, 0x7d7d, 0x7d7d, 0 }, + { 0x7e7e, 0x7e7e, 0x7e7e, 0 }, + { 0x7f7f, 0x7f7f, 0x7f7f, 0 }, + { 0x8080, 0x8080, 0x8080, 0 }, + { 0x8181, 0x8181, 0x8181, 0 }, + { 0x8282, 0x8282, 0x8282, 0 }, + { 0x8383, 0x8383, 0x8383, 0 }, + { 0x8484, 0x8484, 0x8484, 0 }, + { 0x8585, 0x8585, 0x8585, 0 }, + { 0x8686, 0x8686, 0x8686, 0 }, + { 0x8787, 0x8787, 0x8787, 0 }, + { 0x8888, 0x8888, 0x8888, 0 }, + { 0x8989, 0x8989, 0x8989, 0 }, + { 0x8a8a, 0x8a8a, 0x8a8a, 0 }, + { 0x8b8b, 0x8b8b, 0x8b8b, 0 }, + { 0x8c8c, 0x8c8c, 0x8c8c, 0 }, + { 0x8d8d, 0x8d8d, 0x8d8d, 0 }, + { 0x8e8e, 0x8e8e, 0x8e8e, 0 }, + { 0x8f8f, 0x8f8f, 0x8f8f, 0 }, + { 0x9090, 0x9090, 0x9090, 0 }, + { 0x9191, 0x9191, 0x9191, 0 }, + { 0x9292, 0x9292, 0x9292, 0 }, + { 0x9393, 0x9393, 0x9393, 0 }, + { 0x9494, 0x9494, 0x9494, 0 }, + { 0x9595, 0x9595, 0x9595, 0 }, + { 0x9696, 0x9696, 0x9696, 0 }, + { 0x9797, 0x9797, 0x9797, 0 }, + { 0x9898, 0x9898, 0x9898, 0 }, + { 0x9999, 0x9999, 0x9999, 0 }, + { 0x9a9a, 0x9a9a, 0x9a9a, 0 }, + { 0x9b9b, 0x9b9b, 0x9b9b, 0 }, + { 0x9c9c, 0x9c9c, 0x9c9c, 0 }, + { 0x9d9d, 0x9d9d, 0x9d9d, 0 }, + { 0x9e9e, 0x9e9e, 0x9e9e, 0 }, + { 0x9f9f, 0x9f9f, 0x9f9f, 0 }, + { 0xa0a0, 0xa0a0, 0xa0a0, 0 }, + { 0xa1a1, 0xa1a1, 0xa1a1, 0 }, + { 0xa2a2, 0xa2a2, 0xa2a2, 0 }, + { 0xa3a3, 0xa3a3, 0xa3a3, 0 }, + { 0xa4a4, 0xa4a4, 0xa4a4, 0 }, + { 0xa5a5, 0xa5a5, 0xa5a5, 0 }, + { 0xa6a6, 0xa6a6, 0xa6a6, 0 }, + { 0xa7a7, 0xa7a7, 0xa7a7, 0 }, + { 0xa8a8, 0xa8a8, 0xa8a8, 0 }, + { 0xa9a9, 0xa9a9, 0xa9a9, 0 }, + { 0xaaaa, 0xaaaa, 0xaaaa, 0 }, + { 0xabab, 0xabab, 0xabab, 0 }, + { 0xacac, 0xacac, 0xacac, 0 }, + { 0xadad, 0xadad, 0xadad, 0 }, + { 0xaeae, 0xaeae, 0xaeae, 0 }, + { 0xafaf, 0xafaf, 0xafaf, 0 }, + { 0xb0b0, 0xb0b0, 0xb0b0, 0 }, + { 0xb1b1, 0xb1b1, 0xb1b1, 0 }, + { 0xb2b2, 0xb2b2, 0xb2b2, 0 }, + { 0xb3b3, 0xb3b3, 0xb3b3, 0 }, + { 0xb4b4, 0xb4b4, 0xb4b4, 0 }, + { 0xb5b5, 0xb5b5, 0xb5b5, 0 }, + { 0xb6b6, 0xb6b6, 0xb6b6, 0 }, + { 0xb7b7, 0xb7b7, 0xb7b7, 0 }, + { 0xb8b8, 0xb8b8, 0xb8b8, 0 }, + { 0xb9b9, 0xb9b9, 0xb9b9, 0 }, + { 0xbaba, 0xbaba, 0xbaba, 0 }, + { 0xbbbb, 0xbbbb, 0xbbbb, 0 }, + { 0xbcbc, 0xbcbc, 0xbcbc, 0 }, + { 0xbdbd, 0xbdbd, 0xbdbd, 0 }, + { 0xbebe, 0xbebe, 0xbebe, 0 }, + { 0xbfbf, 0xbfbf, 0xbfbf, 0 }, + { 0xc0c0, 0xc0c0, 0xc0c0, 0 }, + { 0xc1c1, 0xc1c1, 0xc1c1, 0 }, + { 0xc2c2, 0xc2c2, 0xc2c2, 0 }, + { 0xc3c3, 0xc3c3, 0xc3c3, 0 }, + { 0xc4c4, 0xc4c4, 0xc4c4, 0 }, + { 0xc5c5, 0xc5c5, 0xc5c5, 0 }, + { 0xc6c6, 0xc6c6, 0xc6c6, 0 }, + { 0xc7c7, 0xc7c7, 0xc7c7, 0 }, + { 0xc8c8, 0xc8c8, 0xc8c8, 0 }, + { 0xc9c9, 0xc9c9, 0xc9c9, 0 }, + { 0xcaca, 0xcaca, 0xcaca, 0 }, + { 0xcbcb, 0xcbcb, 0xcbcb, 0 }, + { 0xcccc, 0xcccc, 0xcccc, 0 }, + { 0xcdcd, 0xcdcd, 0xcdcd, 0 }, + { 0xcece, 0xcece, 0xcece, 0 }, + { 0xcfcf, 0xcfcf, 0xcfcf, 0 }, + { 0xd0d0, 0xd0d0, 0xd0d0, 0 }, + { 0xd1d1, 0xd1d1, 0xd1d1, 0 }, + { 0xd2d2, 0xd2d2, 0xd2d2, 0 }, + { 0xd3d3, 0xd3d3, 0xd3d3, 0 }, + { 0xd4d4, 0xd4d4, 0xd4d4, 0 }, + { 0xd5d5, 0xd5d5, 0xd5d5, 0 }, + { 0xd6d6, 0xd6d6, 0xd6d6, 0 }, + { 0xd7d7, 0xd7d7, 0xd7d7, 0 }, + { 0xd8d8, 0xd8d8, 0xd8d8, 0 }, + { 0xd9d9, 0xd9d9, 0xd9d9, 0 }, + { 0xdada, 0xdada, 0xdada, 0 }, + { 0xdbdb, 0xdbdb, 0xdbdb, 0 }, + { 0xdcdc, 0xdcdc, 0xdcdc, 0 }, + { 0xdddd, 0xdddd, 0xdddd, 0 }, + { 0xdede, 0xdede, 0xdede, 0 }, + { 0xdfdf, 0xdfdf, 0xdfdf, 0 }, + { 0xe0e0, 0xe0e0, 0xe0e0, 0 }, + { 0xe1e1, 0xe1e1, 0xe1e1, 0 }, + { 0xe2e2, 0xe2e2, 0xe2e2, 0 }, + { 0xe3e3, 0xe3e3, 0xe3e3, 0 }, + { 0xe4e4, 0xe4e4, 0xe4e4, 0 }, + { 0xe5e5, 0xe5e5, 0xe5e5, 0 }, + { 0xe6e6, 0xe6e6, 0xe6e6, 0 }, + { 0xe7e7, 0xe7e7, 0xe7e7, 0 }, + { 0xe8e8, 0xe8e8, 0xe8e8, 0 }, + { 0xe9e9, 0xe9e9, 0xe9e9, 0 }, + { 0xeaea, 0xeaea, 0xeaea, 0 }, + { 0xebeb, 0xebeb, 0xebeb, 0 }, + { 0xecec, 0xecec, 0xecec, 0 }, + { 0xeded, 0xeded, 0xeded, 0 }, + { 0xeeee, 0xeeee, 0xeeee, 0 }, + { 0xefef, 0xefef, 0xefef, 0 }, + { 0xf0f0, 0xf0f0, 0xf0f0, 0 }, + { 0xf1f1, 0xf1f1, 0xf1f1, 0 }, + { 0xf2f2, 0xf2f2, 0xf2f2, 0 }, + { 0xf3f3, 0xf3f3, 0xf3f3, 0 }, + { 0xf4f4, 0xf4f4, 0xf4f4, 0 }, + { 0xf5f5, 0xf5f5, 0xf5f5, 0 }, + { 0xf6f6, 0xf6f6, 0xf6f6, 0 }, + { 0xf7f7, 0xf7f7, 0xf7f7, 0 }, + { 0xf8f8, 0xf8f8, 0xf8f8, 0 }, + { 0xf9f9, 0xf9f9, 0xf9f9, 0 }, + { 0xfafa, 0xfafa, 0xfafa, 0 }, + { 0xfbfb, 0xfbfb, 0xfbfb, 0 }, + { 0xfcfc, 0xfcfc, 0xfcfc, 0 }, + { 0xfdfd, 0xfdfd, 0xfdfd, 0 }, + { 0xfefe, 0xfefe, 0xfefe, 0 }, + { 0xffff, 0xffff, 0xffff, 0 }, +}; + +const struct vkms_color_lut linear_eotf = { + .base = linear_array, + .lut_length = LUT_SIZE, + .channel_value2index_ratio = 0xff00ffll +}; +EXPORT_SYMBOL (linear_eotf); + +static struct drm_color_lut srgb_array[LUT_SIZE ] = { + { 0x0, 0x0, 0x0, 0 }, + { 0x13, 0x13, 0x13, 0 }, + { 0x27, 0x27, 0x27, 0 }, + { 0x3b, 0x3b, 0x3b, 0 }, + { 0x4f, 0x4f, 0x4f, 0 }, + { 0x63, 0x63, 0x63, 0 }, + { 0x77, 0x77, 0x77, 0 }, + { 0x8b, 0x8b, 0x8b, 0 }, + { 0x9f, 0x9f, 0x9f, 0 }, + { 0xb3, 0xb3, 0xb3, 0 }, + { 0xc6, 0xc6, 0xc6, 0 }, + { 0xdb, 0xdb, 0xdb, 0 }, + { 0xf0, 0xf0, 0xf0, 0 }, + { 0x107, 0x107, 0x107, 0 }, + { 0x11f, 0x11f, 0x11f, 0 }, + { 0x139, 0x139, 0x139, 0 }, + { 0x153, 0x153, 0x153, 0 }, + { 0x16f, 0x16f, 0x16f, 0 }, + { 0x18c, 0x18c, 0x18c, 0 }, + { 0x1aa, 0x1aa, 0x1aa, 0 }, + { 0x1ca, 0x1ca, 0x1ca, 0 }, + { 0x1eb, 0x1eb, 0x1eb, 0 }, + { 0x20d, 0x20d, 0x20d, 0 }, + { 0x231, 0x231, 0x231, 0 }, + { 0x256, 0x256, 0x256, 0 }, + { 0x27d, 0x27d, 0x27d, 0 }, + { 0x2a4, 0x2a4, 0x2a4, 0 }, + { 0x2ce, 0x2ce, 0x2ce, 0 }, + { 0x2f9, 0x2f9, 0x2f9, 0 }, + { 0x325, 0x325, 0x325, 0 }, + { 0x352, 0x352, 0x352, 0 }, + { 0x381, 0x381, 0x381, 0 }, + { 0x3b2, 0x3b2, 0x3b2, 0 }, + { 0x3e4, 0x3e4, 0x3e4, 0 }, + { 0x418, 0x418, 0x418, 0 }, + { 0x44d, 0x44d, 0x44d, 0 }, + { 0x484, 0x484, 0x484, 0 }, + { 0x4bc, 0x4bc, 0x4bc, 0 }, + { 0x4f6, 0x4f6, 0x4f6, 0 }, + { 0x531, 0x531, 0x531, 0 }, + { 0x56e, 0x56e, 0x56e, 0 }, + { 0x5ad, 0x5ad, 0x5ad, 0 }, + { 0x5ed, 0x5ed, 0x5ed, 0 }, + { 0x62f, 0x62f, 0x62f, 0 }, + { 0x672, 0x672, 0x672, 0 }, + { 0x6b7, 0x6b7, 0x6b7, 0 }, + { 0x6fe, 0x6fe, 0x6fe, 0 }, + { 0x746, 0x746, 0x746, 0 }, + { 0x791, 0x791, 0x791, 0 }, + { 0x7dc, 0x7dc, 0x7dc, 0 }, + { 0x82a, 0x82a, 0x82a, 0 }, + { 0x879, 0x879, 0x879, 0 }, + { 0x8ca, 0x8ca, 0x8ca, 0 }, + { 0x91d, 0x91d, 0x91d, 0 }, + { 0x971, 0x971, 0x971, 0 }, + { 0x9c7, 0x9c7, 0x9c7, 0 }, + { 0xa1f, 0xa1f, 0xa1f, 0 }, + { 0xa79, 0xa79, 0xa79, 0 }, + { 0xad4, 0xad4, 0xad4, 0 }, + { 0xb32, 0xb32, 0xb32, 0 }, + { 0xb91, 0xb91, 0xb91, 0 }, + { 0xbf2, 0xbf2, 0xbf2, 0 }, + { 0xc54, 0xc54, 0xc54, 0 }, + { 0xcb9, 0xcb9, 0xcb9, 0 }, + { 0xd1f, 0xd1f, 0xd1f, 0 }, + { 0xd88, 0xd88, 0xd88, 0 }, + { 0xdf2, 0xdf2, 0xdf2, 0 }, + { 0xe5e, 0xe5e, 0xe5e, 0 }, + { 0xecc, 0xecc, 0xecc, 0 }, + { 0xf3c, 0xf3c, 0xf3c, 0 }, + { 0xfad, 0xfad, 0xfad, 0 }, + { 0x1021, 0x1021, 0x1021, 0 }, + { 0x1096, 0x1096, 0x1096, 0 }, + { 0x110e, 0x110e, 0x110e, 0 }, + { 0x1187, 0x1187, 0x1187, 0 }, + { 0x1203, 0x1203, 0x1203, 0 }, + { 0x1280, 0x1280, 0x1280, 0 }, + { 0x12ff, 0x12ff, 0x12ff, 0 }, + { 0x1380, 0x1380, 0x1380, 0 }, + { 0x1404, 0x1404, 0x1404, 0 }, + { 0x1489, 0x1489, 0x1489, 0 }, + { 0x1510, 0x1510, 0x1510, 0 }, + { 0x1599, 0x1599, 0x1599, 0 }, + { 0x1624, 0x1624, 0x1624, 0 }, + { 0x16b2, 0x16b2, 0x16b2, 0 }, + { 0x1741, 0x1741, 0x1741, 0 }, + { 0x17d2, 0x17d2, 0x17d2, 0 }, + { 0x1865, 0x1865, 0x1865, 0 }, + { 0x18fb, 0x18fb, 0x18fb, 0 }, + { 0x1992, 0x1992, 0x1992, 0 }, + { 0x1a2c, 0x1a2c, 0x1a2c, 0 }, + { 0x1ac8, 0x1ac8, 0x1ac8, 0 }, + { 0x1b65, 0x1b65, 0x1b65, 0 }, + { 0x1c05, 0x1c05, 0x1c05, 0 }, + { 0x1ca7, 0x1ca7, 0x1ca7, 0 }, + { 0x1d4b, 0x1d4b, 0x1d4b, 0 }, + { 0x1df1, 0x1df1, 0x1df1, 0 }, + { 0x1e99, 0x1e99, 0x1e99, 0 }, + { 0x1f44, 0x1f44, 0x1f44, 0 }, + { 0x1ff0, 0x1ff0, 0x1ff0, 0 }, + { 0x209f, 0x209f, 0x209f, 0 }, + { 0x2150, 0x2150, 0x2150, 0 }, + { 0x2203, 0x2203, 0x2203, 0 }, + { 0x22b8, 0x22b8, 0x22b8, 0 }, + { 0x2370, 0x2370, 0x2370, 0 }, + { 0x2429, 0x2429, 0x2429, 0 }, + { 0x24e5, 0x24e5, 0x24e5, 0 }, + { 0x25a3, 0x25a3, 0x25a3, 0 }, + { 0x2663, 0x2663, 0x2663, 0 }, + { 0x2726, 0x2726, 0x2726, 0 }, + { 0x27ea, 0x27ea, 0x27ea, 0 }, + { 0x28b1, 0x28b1, 0x28b1, 0 }, + { 0x297a, 0x297a, 0x297a, 0 }, + { 0x2a45, 0x2a45, 0x2a45, 0 }, + { 0x2b13, 0x2b13, 0x2b13, 0 }, + { 0x2be3, 0x2be3, 0x2be3, 0 }, + { 0x2cb5, 0x2cb5, 0x2cb5, 0 }, + { 0x2d89, 0x2d89, 0x2d89, 0 }, + { 0x2e60, 0x2e60, 0x2e60, 0 }, + { 0x2f39, 0x2f39, 0x2f39, 0 }, + { 0x3014, 0x3014, 0x3014, 0 }, + { 0x30f2, 0x30f2, 0x30f2, 0 }, + { 0x31d2, 0x31d2, 0x31d2, 0 }, + { 0x32b4, 0x32b4, 0x32b4, 0 }, + { 0x3398, 0x3398, 0x3398, 0 }, + { 0x347f, 0x347f, 0x347f, 0 }, + { 0x3569, 0x3569, 0x3569, 0 }, + { 0x3654, 0x3654, 0x3654, 0 }, + { 0x3742, 0x3742, 0x3742, 0 }, + { 0x3832, 0x3832, 0x3832, 0 }, + { 0x3925, 0x3925, 0x3925, 0 }, + { 0x3a1a, 0x3a1a, 0x3a1a, 0 }, + { 0x3b11, 0x3b11, 0x3b11, 0 }, + { 0x3c0b, 0x3c0b, 0x3c0b, 0 }, + { 0x3d07, 0x3d07, 0x3d07, 0 }, + { 0x3e05, 0x3e05, 0x3e05, 0 }, + { 0x3f06, 0x3f06, 0x3f06, 0 }, + { 0x400a, 0x400a, 0x400a, 0 }, + { 0x410f, 0x410f, 0x410f, 0 }, + { 0x4218, 0x4218, 0x4218, 0 }, + { 0x4322, 0x4322, 0x4322, 0 }, + { 0x442f, 0x442f, 0x442f, 0 }, + { 0x453f, 0x453f, 0x453f, 0 }, + { 0x4650, 0x4650, 0x4650, 0 }, + { 0x4765, 0x4765, 0x4765, 0 }, + { 0x487c, 0x487c, 0x487c, 0 }, + { 0x4995, 0x4995, 0x4995, 0 }, + { 0x4ab1, 0x4ab1, 0x4ab1, 0 }, + { 0x4bcf, 0x4bcf, 0x4bcf, 0 }, + { 0x4cf0, 0x4cf0, 0x4cf0, 0 }, + { 0x4e13, 0x4e13, 0x4e13, 0 }, + { 0x4f39, 0x4f39, 0x4f39, 0 }, + { 0x5061, 0x5061, 0x5061, 0 }, + { 0x518b, 0x518b, 0x518b, 0 }, + { 0x52b9, 0x52b9, 0x52b9, 0 }, + { 0x53e8, 0x53e8, 0x53e8, 0 }, + { 0x551b, 0x551b, 0x551b, 0 }, + { 0x5650, 0x5650, 0x5650, 0 }, + { 0x5787, 0x5787, 0x5787, 0 }, + { 0x58c1, 0x58c1, 0x58c1, 0 }, + { 0x59fd, 0x59fd, 0x59fd, 0 }, + { 0x5b3c, 0x5b3c, 0x5b3c, 0 }, + { 0x5c7e, 0x5c7e, 0x5c7e, 0 }, + { 0x5dc2, 0x5dc2, 0x5dc2, 0 }, + { 0x5f09, 0x5f09, 0x5f09, 0 }, + { 0x6052, 0x6052, 0x6052, 0 }, + { 0x619e, 0x619e, 0x619e, 0 }, + { 0x62ec, 0x62ec, 0x62ec, 0 }, + { 0x643d, 0x643d, 0x643d, 0 }, + { 0x6591, 0x6591, 0x6591, 0 }, + { 0x66e7, 0x66e7, 0x66e7, 0 }, + { 0x6840, 0x6840, 0x6840, 0 }, + { 0x699b, 0x699b, 0x699b, 0 }, + { 0x6afa, 0x6afa, 0x6afa, 0 }, + { 0x6c5a, 0x6c5a, 0x6c5a, 0 }, + { 0x6dbe, 0x6dbe, 0x6dbe, 0 }, + { 0x6f24, 0x6f24, 0x6f24, 0 }, + { 0x708c, 0x708c, 0x708c, 0 }, + { 0x71f8, 0x71f8, 0x71f8, 0 }, + { 0x7366, 0x7366, 0x7366, 0 }, + { 0x74d6, 0x74d6, 0x74d6, 0 }, + { 0x764a, 0x764a, 0x764a, 0 }, + { 0x77c0, 0x77c0, 0x77c0, 0 }, + { 0x7938, 0x7938, 0x7938, 0 }, + { 0x7ab4, 0x7ab4, 0x7ab4, 0 }, + { 0x7c32, 0x7c32, 0x7c32, 0 }, + { 0x7db3, 0x7db3, 0x7db3, 0 }, + { 0x7f36, 0x7f36, 0x7f36, 0 }, + { 0x80bc, 0x80bc, 0x80bc, 0 }, + { 0x8245, 0x8245, 0x8245, 0 }, + { 0x83d1, 0x83d1, 0x83d1, 0 }, + { 0x855f, 0x855f, 0x855f, 0 }, + { 0x86f0, 0x86f0, 0x86f0, 0 }, + { 0x8884, 0x8884, 0x8884, 0 }, + { 0x8a1a, 0x8a1a, 0x8a1a, 0 }, + { 0x8bb4, 0x8bb4, 0x8bb4, 0 }, + { 0x8d50, 0x8d50, 0x8d50, 0 }, + { 0x8eee, 0x8eee, 0x8eee, 0 }, + { 0x9090, 0x9090, 0x9090, 0 }, + { 0x9234, 0x9234, 0x9234, 0 }, + { 0x93db, 0x93db, 0x93db, 0 }, + { 0x9585, 0x9585, 0x9585, 0 }, + { 0x9732, 0x9732, 0x9732, 0 }, + { 0x98e1, 0x98e1, 0x98e1, 0 }, + { 0x9a93, 0x9a93, 0x9a93, 0 }, + { 0x9c48, 0x9c48, 0x9c48, 0 }, + { 0x9e00, 0x9e00, 0x9e00, 0 }, + { 0x9fbb, 0x9fbb, 0x9fbb, 0 }, + { 0xa178, 0xa178, 0xa178, 0 }, + { 0xa338, 0xa338, 0xa338, 0 }, + { 0xa4fb, 0xa4fb, 0xa4fb, 0 }, + { 0xa6c1, 0xa6c1, 0xa6c1, 0 }, + { 0xa88a, 0xa88a, 0xa88a, 0 }, + { 0xaa56, 0xaa56, 0xaa56, 0 }, + { 0xac24, 0xac24, 0xac24, 0 }, + { 0xadf5, 0xadf5, 0xadf5, 0 }, + { 0xafc9, 0xafc9, 0xafc9, 0 }, + { 0xb1a0, 0xb1a0, 0xb1a0, 0 }, + { 0xb37a, 0xb37a, 0xb37a, 0 }, + { 0xb557, 0xb557, 0xb557, 0 }, + { 0xb736, 0xb736, 0xb736, 0 }, + { 0xb919, 0xb919, 0xb919, 0 }, + { 0xbafe, 0xbafe, 0xbafe, 0 }, + { 0xbce6, 0xbce6, 0xbce6, 0 }, + { 0xbed2, 0xbed2, 0xbed2, 0 }, + { 0xc0c0, 0xc0c0, 0xc0c0, 0 }, + { 0xc2b0, 0xc2b0, 0xc2b0, 0 }, + { 0xc4a4, 0xc4a4, 0xc4a4, 0 }, + { 0xc69b, 0xc69b, 0xc69b, 0 }, + { 0xc895, 0xc895, 0xc895, 0 }, + { 0xca91, 0xca91, 0xca91, 0 }, + { 0xcc91, 0xcc91, 0xcc91, 0 }, + { 0xce93, 0xce93, 0xce93, 0 }, + { 0xd098, 0xd098, 0xd098, 0 }, + { 0xd2a1, 0xd2a1, 0xd2a1, 0 }, + { 0xd4ac, 0xd4ac, 0xd4ac, 0 }, + { 0xd6ba, 0xd6ba, 0xd6ba, 0 }, + { 0xd8cb, 0xd8cb, 0xd8cb, 0 }, + { 0xdadf, 0xdadf, 0xdadf, 0 }, + { 0xdcf7, 0xdcf7, 0xdcf7, 0 }, + { 0xdf11, 0xdf11, 0xdf11, 0 }, + { 0xe12e, 0xe12e, 0xe12e, 0 }, + { 0xe34e, 0xe34e, 0xe34e, 0 }, + { 0xe571, 0xe571, 0xe571, 0 }, + { 0xe796, 0xe796, 0xe796, 0 }, + { 0xe9bf, 0xe9bf, 0xe9bf, 0 }, + { 0xebeb, 0xebeb, 0xebeb, 0 }, + { 0xee1a, 0xee1a, 0xee1a, 0 }, + { 0xf04c, 0xf04c, 0xf04c, 0 }, + { 0xf281, 0xf281, 0xf281, 0 }, + { 0xf4b9, 0xf4b9, 0xf4b9, 0 }, + { 0xf6f4, 0xf6f4, 0xf6f4, 0 }, + { 0xf932, 0xf932, 0xf932, 0 }, + { 0xfb73, 0xfb73, 0xfb73, 0 }, + { 0xfdb7, 0xfdb7, 0xfdb7, 0 }, + { 0xffff, 0xffff, 0xffff, 0 }, +}; + +const struct vkms_color_lut srgb_eotf = { + .base = srgb_array, + .lut_length = LUT_SIZE, + .channel_value2index_ratio = 0xff00ffll +}; +EXPORT_SYMBOL (srgb_eotf); + +static struct drm_color_lut srgb_inv_array[LUT_SIZE ] = { + { 0x0, 0x0, 0x0, 0 }, + { 0xcc2, 0xcc2, 0xcc2, 0 }, + { 0x15be, 0x15be, 0x15be, 0 }, + { 0x1c56, 0x1c56, 0x1c56, 0 }, + { 0x21bd, 0x21bd, 0x21bd, 0 }, + { 0x2666, 0x2666, 0x2666, 0 }, + { 0x2a8a, 0x2a8a, 0x2a8a, 0 }, + { 0x2e4c, 0x2e4c, 0x2e4c, 0 }, + { 0x31c0, 0x31c0, 0x31c0, 0 }, + { 0x34f6, 0x34f6, 0x34f6, 0 }, + { 0x37f9, 0x37f9, 0x37f9, 0 }, + { 0x3acf, 0x3acf, 0x3acf, 0 }, + { 0x3d80, 0x3d80, 0x3d80, 0 }, + { 0x4010, 0x4010, 0x4010, 0 }, + { 0x4284, 0x4284, 0x4284, 0 }, + { 0x44dd, 0x44dd, 0x44dd, 0 }, + { 0x4720, 0x4720, 0x4720, 0 }, + { 0x494e, 0x494e, 0x494e, 0 }, + { 0x4b69, 0x4b69, 0x4b69, 0 }, + { 0x4d73, 0x4d73, 0x4d73, 0 }, + { 0x4f6e, 0x4f6e, 0x4f6e, 0 }, + { 0x5159, 0x5159, 0x5159, 0 }, + { 0x5337, 0x5337, 0x5337, 0 }, + { 0x5509, 0x5509, 0x5509, 0 }, + { 0x56cf, 0x56cf, 0x56cf, 0 }, + { 0x588a, 0x588a, 0x588a, 0 }, + { 0x5a3b, 0x5a3b, 0x5a3b, 0 }, + { 0x5be2, 0x5be2, 0x5be2, 0 }, + { 0x5d80, 0x5d80, 0x5d80, 0 }, + { 0x5f16, 0x5f16, 0x5f16, 0 }, + { 0x60a4, 0x60a4, 0x60a4, 0 }, + { 0x6229, 0x6229, 0x6229, 0 }, + { 0x63a8, 0x63a8, 0x63a8, 0 }, + { 0x6520, 0x6520, 0x6520, 0 }, + { 0x6691, 0x6691, 0x6691, 0 }, + { 0x67fc, 0x67fc, 0x67fc, 0 }, + { 0x6961, 0x6961, 0x6961, 0 }, + { 0x6ac0, 0x6ac0, 0x6ac0, 0 }, + { 0x6c19, 0x6c19, 0x6c19, 0 }, + { 0x6d6e, 0x6d6e, 0x6d6e, 0 }, + { 0x6ebd, 0x6ebd, 0x6ebd, 0 }, + { 0x7008, 0x7008, 0x7008, 0 }, + { 0x714d, 0x714d, 0x714d, 0 }, + { 0x728f, 0x728f, 0x728f, 0 }, + { 0x73cc, 0x73cc, 0x73cc, 0 }, + { 0x7504, 0x7504, 0x7504, 0 }, + { 0x7639, 0x7639, 0x7639, 0 }, + { 0x776a, 0x776a, 0x776a, 0 }, + { 0x7897, 0x7897, 0x7897, 0 }, + { 0x79c1, 0x79c1, 0x79c1, 0 }, + { 0x7ae7, 0x7ae7, 0x7ae7, 0 }, + { 0x7c09, 0x7c09, 0x7c09, 0 }, + { 0x7d28, 0x7d28, 0x7d28, 0 }, + { 0x7e44, 0x7e44, 0x7e44, 0 }, + { 0x7f5d, 0x7f5d, 0x7f5d, 0 }, + { 0x8073, 0x8073, 0x8073, 0 }, + { 0x8186, 0x8186, 0x8186, 0 }, + { 0x8296, 0x8296, 0x8296, 0 }, + { 0x83a4, 0x83a4, 0x83a4, 0 }, + { 0x84ae, 0x84ae, 0x84ae, 0 }, + { 0x85b6, 0x85b6, 0x85b6, 0 }, + { 0x86bc, 0x86bc, 0x86bc, 0 }, + { 0x87bf, 0x87bf, 0x87bf, 0 }, + { 0x88bf, 0x88bf, 0x88bf, 0 }, + { 0x89be, 0x89be, 0x89be, 0 }, + { 0x8ab9, 0x8ab9, 0x8ab9, 0 }, + { 0x8bb3, 0x8bb3, 0x8bb3, 0 }, + { 0x8cab, 0x8cab, 0x8cab, 0 }, + { 0x8da0, 0x8da0, 0x8da0, 0 }, + { 0x8e93, 0x8e93, 0x8e93, 0 }, + { 0x8f84, 0x8f84, 0x8f84, 0 }, + { 0x9073, 0x9073, 0x9073, 0 }, + { 0x9161, 0x9161, 0x9161, 0 }, + { 0x924c, 0x924c, 0x924c, 0 }, + { 0x9335, 0x9335, 0x9335, 0 }, + { 0x941d, 0x941d, 0x941d, 0 }, + { 0x9503, 0x9503, 0x9503, 0 }, + { 0x95e7, 0x95e7, 0x95e7, 0 }, + { 0x96c9, 0x96c9, 0x96c9, 0 }, + { 0x97aa, 0x97aa, 0x97aa, 0 }, + { 0x9889, 0x9889, 0x9889, 0 }, + { 0x9966, 0x9966, 0x9966, 0 }, + { 0x9a42, 0x9a42, 0x9a42, 0 }, + { 0x9b1c, 0x9b1c, 0x9b1c, 0 }, + { 0x9bf5, 0x9bf5, 0x9bf5, 0 }, + { 0x9ccc, 0x9ccc, 0x9ccc, 0 }, + { 0x9da1, 0x9da1, 0x9da1, 0 }, + { 0x9e76, 0x9e76, 0x9e76, 0 }, + { 0x9f49, 0x9f49, 0x9f49, 0 }, + { 0xa01a, 0xa01a, 0xa01a, 0 }, + { 0xa0ea, 0xa0ea, 0xa0ea, 0 }, + { 0xa1b9, 0xa1b9, 0xa1b9, 0 }, + { 0xa286, 0xa286, 0xa286, 0 }, + { 0xa352, 0xa352, 0xa352, 0 }, + { 0xa41d, 0xa41d, 0xa41d, 0 }, + { 0xa4e7, 0xa4e7, 0xa4e7, 0 }, + { 0xa5af, 0xa5af, 0xa5af, 0 }, + { 0xa676, 0xa676, 0xa676, 0 }, + { 0xa73c, 0xa73c, 0xa73c, 0 }, + { 0xa801, 0xa801, 0xa801, 0 }, + { 0xa8c5, 0xa8c5, 0xa8c5, 0 }, + { 0xa987, 0xa987, 0xa987, 0 }, + { 0xaa48, 0xaa48, 0xaa48, 0 }, + { 0xab09, 0xab09, 0xab09, 0 }, + { 0xabc8, 0xabc8, 0xabc8, 0 }, + { 0xac86, 0xac86, 0xac86, 0 }, + { 0xad43, 0xad43, 0xad43, 0 }, + { 0xadff, 0xadff, 0xadff, 0 }, + { 0xaeba, 0xaeba, 0xaeba, 0 }, + { 0xaf74, 0xaf74, 0xaf74, 0 }, + { 0xb02d, 0xb02d, 0xb02d, 0 }, + { 0xb0e5, 0xb0e5, 0xb0e5, 0 }, + { 0xb19c, 0xb19c, 0xb19c, 0 }, + { 0xb252, 0xb252, 0xb252, 0 }, + { 0xb307, 0xb307, 0xb307, 0 }, + { 0xb3bb, 0xb3bb, 0xb3bb, 0 }, + { 0xb46f, 0xb46f, 0xb46f, 0 }, + { 0xb521, 0xb521, 0xb521, 0 }, + { 0xb5d3, 0xb5d3, 0xb5d3, 0 }, + { 0xb683, 0xb683, 0xb683, 0 }, + { 0xb733, 0xb733, 0xb733, 0 }, + { 0xb7e2, 0xb7e2, 0xb7e2, 0 }, + { 0xb890, 0xb890, 0xb890, 0 }, + { 0xb93d, 0xb93d, 0xb93d, 0 }, + { 0xb9ea, 0xb9ea, 0xb9ea, 0 }, + { 0xba96, 0xba96, 0xba96, 0 }, + { 0xbb40, 0xbb40, 0xbb40, 0 }, + { 0xbbea, 0xbbea, 0xbbea, 0 }, + { 0xbc94, 0xbc94, 0xbc94, 0 }, + { 0xbd3c, 0xbd3c, 0xbd3c, 0 }, + { 0xbde4, 0xbde4, 0xbde4, 0 }, + { 0xbe8b, 0xbe8b, 0xbe8b, 0 }, + { 0xbf31, 0xbf31, 0xbf31, 0 }, + { 0xbfd7, 0xbfd7, 0xbfd7, 0 }, + { 0xc07b, 0xc07b, 0xc07b, 0 }, + { 0xc120, 0xc120, 0xc120, 0 }, + { 0xc1c3, 0xc1c3, 0xc1c3, 0 }, + { 0xc266, 0xc266, 0xc266, 0 }, + { 0xc308, 0xc308, 0xc308, 0 }, + { 0xc3a9, 0xc3a9, 0xc3a9, 0 }, + { 0xc449, 0xc449, 0xc449, 0 }, + { 0xc4e9, 0xc4e9, 0xc4e9, 0 }, + { 0xc589, 0xc589, 0xc589, 0 }, + { 0xc627, 0xc627, 0xc627, 0 }, + { 0xc6c5, 0xc6c5, 0xc6c5, 0 }, + { 0xc763, 0xc763, 0xc763, 0 }, + { 0xc7ff, 0xc7ff, 0xc7ff, 0 }, + { 0xc89b, 0xc89b, 0xc89b, 0 }, + { 0xc937, 0xc937, 0xc937, 0 }, + { 0xc9d2, 0xc9d2, 0xc9d2, 0 }, + { 0xca6c, 0xca6c, 0xca6c, 0 }, + { 0xcb06, 0xcb06, 0xcb06, 0 }, + { 0xcb9f, 0xcb9f, 0xcb9f, 0 }, + { 0xcc37, 0xcc37, 0xcc37, 0 }, + { 0xcccf, 0xcccf, 0xcccf, 0 }, + { 0xcd66, 0xcd66, 0xcd66, 0 }, + { 0xcdfd, 0xcdfd, 0xcdfd, 0 }, + { 0xce93, 0xce93, 0xce93, 0 }, + { 0xcf29, 0xcf29, 0xcf29, 0 }, + { 0xcfbe, 0xcfbe, 0xcfbe, 0 }, + { 0xd053, 0xd053, 0xd053, 0 }, + { 0xd0e7, 0xd0e7, 0xd0e7, 0 }, + { 0xd17a, 0xd17a, 0xd17a, 0 }, + { 0xd20d, 0xd20d, 0xd20d, 0 }, + { 0xd2a0, 0xd2a0, 0xd2a0, 0 }, + { 0xd331, 0xd331, 0xd331, 0 }, + { 0xd3c3, 0xd3c3, 0xd3c3, 0 }, + { 0xd454, 0xd454, 0xd454, 0 }, + { 0xd4e4, 0xd4e4, 0xd4e4, 0 }, + { 0xd574, 0xd574, 0xd574, 0 }, + { 0xd603, 0xd603, 0xd603, 0 }, + { 0xd692, 0xd692, 0xd692, 0 }, + { 0xd720, 0xd720, 0xd720, 0 }, + { 0xd7ae, 0xd7ae, 0xd7ae, 0 }, + { 0xd83c, 0xd83c, 0xd83c, 0 }, + { 0xd8c9, 0xd8c9, 0xd8c9, 0 }, + { 0xd955, 0xd955, 0xd955, 0 }, + { 0xd9e1, 0xd9e1, 0xd9e1, 0 }, + { 0xda6d, 0xda6d, 0xda6d, 0 }, + { 0xdaf8, 0xdaf8, 0xdaf8, 0 }, + { 0xdb83, 0xdb83, 0xdb83, 0 }, + { 0xdc0d, 0xdc0d, 0xdc0d, 0 }, + { 0xdc97, 0xdc97, 0xdc97, 0 }, + { 0xdd20, 0xdd20, 0xdd20, 0 }, + { 0xdda9, 0xdda9, 0xdda9, 0 }, + { 0xde31, 0xde31, 0xde31, 0 }, + { 0xdeb9, 0xdeb9, 0xdeb9, 0 }, + { 0xdf41, 0xdf41, 0xdf41, 0 }, + { 0xdfc8, 0xdfc8, 0xdfc8, 0 }, + { 0xe04f, 0xe04f, 0xe04f, 0 }, + { 0xe0d5, 0xe0d5, 0xe0d5, 0 }, + { 0xe15b, 0xe15b, 0xe15b, 0 }, + { 0xe1e0, 0xe1e0, 0xe1e0, 0 }, + { 0xe266, 0xe266, 0xe266, 0 }, + { 0xe2ea, 0xe2ea, 0xe2ea, 0 }, + { 0xe36f, 0xe36f, 0xe36f, 0 }, + { 0xe3f3, 0xe3f3, 0xe3f3, 0 }, + { 0xe476, 0xe476, 0xe476, 0 }, + { 0xe4f9, 0xe4f9, 0xe4f9, 0 }, + { 0xe57c, 0xe57c, 0xe57c, 0 }, + { 0xe5fe, 0xe5fe, 0xe5fe, 0 }, + { 0xe680, 0xe680, 0xe680, 0 }, + { 0xe702, 0xe702, 0xe702, 0 }, + { 0xe783, 0xe783, 0xe783, 0 }, + { 0xe804, 0xe804, 0xe804, 0 }, + { 0xe884, 0xe884, 0xe884, 0 }, + { 0xe905, 0xe905, 0xe905, 0 }, + { 0xe984, 0xe984, 0xe984, 0 }, + { 0xea04, 0xea04, 0xea04, 0 }, + { 0xea83, 0xea83, 0xea83, 0 }, + { 0xeb02, 0xeb02, 0xeb02, 0 }, + { 0xeb80, 0xeb80, 0xeb80, 0 }, + { 0xebfe, 0xebfe, 0xebfe, 0 }, + { 0xec7b, 0xec7b, 0xec7b, 0 }, + { 0xecf9, 0xecf9, 0xecf9, 0 }, + { 0xed76, 0xed76, 0xed76, 0 }, + { 0xedf2, 0xedf2, 0xedf2, 0 }, + { 0xee6f, 0xee6f, 0xee6f, 0 }, + { 0xeeeb, 0xeeeb, 0xeeeb, 0 }, + { 0xef66, 0xef66, 0xef66, 0 }, + { 0xefe2, 0xefe2, 0xefe2, 0 }, + { 0xf05d, 0xf05d, 0xf05d, 0 }, + { 0xf0d7, 0xf0d7, 0xf0d7, 0 }, + { 0xf152, 0xf152, 0xf152, 0 }, + { 0xf1cc, 0xf1cc, 0xf1cc, 0 }, + { 0xf245, 0xf245, 0xf245, 0 }, + { 0xf2bf, 0xf2bf, 0xf2bf, 0 }, + { 0xf338, 0xf338, 0xf338, 0 }, + { 0xf3b0, 0xf3b0, 0xf3b0, 0 }, + { 0xf429, 0xf429, 0xf429, 0 }, + { 0xf4a1, 0xf4a1, 0xf4a1, 0 }, + { 0xf519, 0xf519, 0xf519, 0 }, + { 0xf590, 0xf590, 0xf590, 0 }, + { 0xf608, 0xf608, 0xf608, 0 }, + { 0xf67e, 0xf67e, 0xf67e, 0 }, + { 0xf6f5, 0xf6f5, 0xf6f5, 0 }, + { 0xf76b, 0xf76b, 0xf76b, 0 }, + { 0xf7e1, 0xf7e1, 0xf7e1, 0 }, + { 0xf857, 0xf857, 0xf857, 0 }, + { 0xf8cd, 0xf8cd, 0xf8cd, 0 }, + { 0xf942, 0xf942, 0xf942, 0 }, + { 0xf9b7, 0xf9b7, 0xf9b7, 0 }, + { 0xfa2b, 0xfa2b, 0xfa2b, 0 }, + { 0xfaa0, 0xfaa0, 0xfaa0, 0 }, + { 0xfb14, 0xfb14, 0xfb14, 0 }, + { 0xfb88, 0xfb88, 0xfb88, 0 }, + { 0xfbfb, 0xfbfb, 0xfbfb, 0 }, + { 0xfc6e, 0xfc6e, 0xfc6e, 0 }, + { 0xfce1, 0xfce1, 0xfce1, 0 }, + { 0xfd54, 0xfd54, 0xfd54, 0 }, + { 0xfdc6, 0xfdc6, 0xfdc6, 0 }, + { 0xfe39, 0xfe39, 0xfe39, 0 }, + { 0xfeaa, 0xfeaa, 0xfeaa, 0 }, + { 0xff1c, 0xff1c, 0xff1c, 0 }, + { 0xff8d, 0xff8d, 0xff8d, 0 }, + { 0xffff, 0xffff, 0xffff, 0 }, +}; + +const struct vkms_color_lut srgb_inv_eotf = { + .base = srgb_inv_array, + .lut_length = LUT_SIZE, + .channel_value2index_ratio = 0xff00ffll +}; +EXPORT_SYMBOL (srgb_inv_eotf);drivers/gpu/drm/vkms/vkms_luts.h new file +12
-0@@ -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_ */ drivers/gpu/drm/vkms/vkms_plane.c +2
-0@@ -232,5 +232,7 @@ struct vkms_plane *vkms_plane_init(structvkms_device *vkmsdev, DRM_COLOR_YCBCR_BT601, DRM_COLOR_YCBCR_FULL_RANGE); + vkms_initialize_colorops(&plane->base); + return plane; }
Re: [PATCH V11 14/47] drm/vkms: Add enumerated 1D curve colorop
Quoted 207 lines · Alex Hung
Quoted 181 lines · Louis Chauvet
Le 15/08/2025 à 05:50, Alex Hung a écrit :
Quoted 166 lines
From: Harry Wentland <[email protected]>
This patch introduces a VKMS color pipeline that includes two
drm_coloropsfor named transfer functions. For now the only ones supported are sRGB EOTF, sRGB Inverse EOTF, and a Linear TF. We will expand this in the future but I don't want to do so without accompanying IGT tests.We introduce a new
vkms_luts.cfile that hard-codes sRGB EOTF, sRGB Inverse EOTF, and a linear EOTF LUT. These have been generated with 256 entries each as IGT is currently testing only 8 bpc surfaces. We will likely need higher precision but I'm reluctant to make that change without clear indication that we need it. We'll revisit and, if necessary, regenerate the LUTs when we have IGT tests for higher precision buffers.Signed-off-by Harry Wentland <[email protected]>Signed-off-by Alex Hung <[email protected]>Reviewed-by Daniel Stone <[email protected]>---
v11:
- Updatedrm_colorop_pipeline_destroyfrom plane to dev (Nícolas Prado)
- Fix undefined errors byEXPORT_SYMBOLsymbols (kernel test robot)v9:
- Replace cleanup code bydrm_colorop_pipeline_destroy(Simon Ser)
- Update function names by _plane_ (Chaitanya Kumar Borah)v8:
- ReplaceDRM_ERRORbydrm_err(Louis Chauvet)
- ReplaceDRM_WARN_ONCEbydrm_WARN_ONCE(Louis Chauvet)
- Fix conflicts with upstream VKMS (Louis Chauvet)
- Add comments fordrm_color_lutlinear_array(Louis Chauvet)v7:
- Fix checkpatch warnings (Louis Chauvet)
- Changekzalloc(sizeof(struct drm_colorop) ...)tokzalloc(sizeof(*ops[i]) ...)
- Remove if (ops[i]) beforekfree(ops[i])
- Fix styles by adding and removing spaces (new lines, tabs and so on)v6:
- drop 'len' var (Louis Chauvet)
- cleanup if colorop alloc or init fails (Louis Chauvet)
- switch loop inpre_blend_transform(Louis Chauvet)
- drop extraneous if (colorop) inside while (colorop) (Louis Chauvet)v5:
- Squash with "Pullapply_coloropout ofpre_blend_color_transform"
(Sebastian)
- Fix warnings
- Fix include
- Drop TODOsv4:
- Drop _tf_ fromcolor_pipelineinit function
- Pass supported TFs into colorop init
- Create bypass pipeline in DRM helper (Pekka)v2:
- Add commit description
- Fix sRGB EOTF LUT definition
- Add linear and sRGB inverse EOTF LUTsdrivers/gpu/drm/vkms/Makefile | 4 +-
drivers/gpu/drm/vkms/vkms_colorop.c | 81 +++
drivers/gpu/drm/vkms/vkms_composer.c| 51 +-
drivers/gpu/drm/vkms/vkms_drv.h | 3 +
drivers/gpu/drm/vkms/vkms_luts.c | 811
+++++++++++++++++++++++++++
drivers/gpu/drm/vkms/vkms_luts.h | 12 +
drivers/gpu/drm/vkms/vkms_plane.c | 2 +7 files changed, 962 insertions(+), 2 deletions(-)create mode 100644
drivers/gpu/drm/vkms/vkms_colorop.ccreate mode 100644drivers/gpu/drm/vkms/vkms_luts.ccreate mode 100644drivers/gpu/drm/vkms/vkms_luts.hdrivers/gpu/drm/vkms/ renamed from drivers/gpu/drm/vkms/Makefile +0
-0
Makefile
indexd657865e573f..0b8936674f69100644drivers/gpu/drm/vkms/Makefile +3
-1@@ -8,7 +8,9 @@ vkms-y := \ vkms_composer.o \ vkms_writeback.o \ vkms_connector.o \ - vkms_config.o + vkms_config.o \ + vkms_colorop.o \ + vkms_luts.oobj-$(CONFIG_DRM_VKMS) += vkms.o
obj-$(CONFIG_DRM_VKMS_KUNIT_TEST) += tests/drivers/gpu/drm/ renamed from drivers/gpu/drm/vkms/vkms_colorop.c +0
-0
vkms/vkms_colorop.c
new file mode 100644
index 000000000000..f955ffb0ac84drivers/gpu/drm/vkms/vkms_colorop.c new file +17
-0@@ -0,0 +1,81 @@ +// SPDX-License-Identifier: GPL-2.0+ + +#include <linux/slab.h> +#include <drm/drm_colorop.h> +#include <drm/drm_print.h> +#include <drm/drm_property.h> +#include <drm/drm_plane.h> + +#include "vkms_drv.h" + +static const u64 supported_tfs = + BIT(DRM_COLOROP_1D_CURVE_SRGB_EOTF) | + BIT(DRM_COLOROP_1D_CURVE_SRGB_INV_EOTF); + +#define MAX_COLOR_PIPELINE_OPS 2 + +static int vkms_initialize_color_pipeline(struct drm_plane*plane,
structdrm_prop_enum_list*list)drivers/gpu/drm/vkms/vkms_colorop.c new file +17
-0+{ + struct drm_colorop *ops[MAX_COLOR_PIPELINE_OPS]; + struct drm_device *dev = plane->dev; + int ret; + int i = 0; + + memset(ops, 0, sizeof(ops)); + + /* 1st op: 1d curve */ + ops[i] = kzalloc(sizeof(*ops[i]), GFP_KERNEL); + if (!ops[i]) { + drm_err(dev, "KMS: Failed to allocate colorop\n"); + ret = -ENOMEM; + goto cleanup; + } + + ret = drm_plane_colorop_curve_1d_init(dev, ops[i], plane,
supported_tfs);
+ if (ret)
+ goto cleanup;
+
+list->type= ops[i]->base.id;
+list->name= kasprintf(GFP_KERNEL, "Color Pipeline %d", ops[i]-Quoted 1 line
base.id);
drivers/gpu/drm/vkms/vkms_colorop.c new file +12
-0+ + i++; + + /* 2nd op: 1d curve */ + ops[i] = kzalloc(sizeof(*ops[i]), GFP_KERNEL); + if (!ops[i]) { + drm_err(dev, "KMS: Failed to allocate colorop\n"); + ret = -ENOMEM; + goto cleanup; + } + + ret = drm_plane_colorop_curve_1d_init(dev, ops[i], plane,
supported_tfs);
+ if (ret)
+ goto cleanup;drivers/gpu/drm/vkms/vkms_colorop.c line 60
Quoted 7 lines
drivers/gpu/drm/vkms/vkms_colorop.c new file +7
-0+ + drm_colorop_set_next_property(ops[i - 1], ops[i]); + + return 0; + +cleanup: + drm_colorop_pipeline_destroy(dev);If it take a device, it means that it deletes everything, which is not
what I would expect here: you are curently allocating a specific planeQuoted 8 lines
pipeline, and deleting all colorop for other planes because of one failure is counterintuitive.
In this situation I would expect either:
- error propagation tovkms_createorvkms_output_init(it is already
the case) and "device-wide" cleanup in vkms_create/vkms_output_init;
- "local" cleanup (i.e only this specific pipeline)Hi Louis,
Does it make sense to make
drm_colorop_pipeline_destroy(drm_plane), i.e.
in PATCH 13 as in previously V10?and then
drm_colorop_pipeline_destroyshould limit to the pipeline in adrm_planeand should do something like
drm_colorop_cleanup(colorop);
free(colorop)
drm_plane->colorop= NULL;
Quoted 5 lines
We can have same behaviours accross device drivers like amdgpu too.
Hi Simon and Nicolas,
Do you have comments on above proposal?
Hi,
indeed that would make more sense to me.
Signature · 3 lines
Thanks, Nícolas
Re: [PATCH V11 14/47] drm/vkms: Add enumerated 1D curve colorop
Quoted 185 lines · Nícolas F. R. A. Prado
Quoted 184 lines · Alex Hung
Quoted 181 lines · Louis Chauvet
Le 15/08/2025 à 05:50, Alex Hung a écrit :
Quoted 166 lines
From: Harry Wentland <[email protected]>
This patch introduces a VKMS color pipeline that includes two
drm_coloropsfor named transfer functions. For now the only ones supported are sRGB EOTF, sRGB Inverse EOTF, and a Linear TF. We will expand this in the future but I don't want to do so without accompanying IGT tests.We introduce a new
vkms_luts.cfile that hard-codes sRGB EOTF, sRGB Inverse EOTF, and a linear EOTF LUT. These have been generated with 256 entries each as IGT is currently testing only 8 bpc surfaces. We will likely need higher precision but I'm reluctant to make that change without clear indication that we need it. We'll revisit and, if necessary, regenerate the LUTs when we have IGT tests for higher precision buffers.Signed-off-by Harry Wentland <[email protected]>Signed-off-by Alex Hung <[email protected]>Reviewed-by Daniel Stone <[email protected]>---
v11:
- Updatedrm_colorop_pipeline_destroyfrom plane to dev
(Nícolas Prado)
- Fix undefined errors byEXPORT_SYMBOLsymbols (kernel test
robot)v9:
- Replace cleanup code bydrm_colorop_pipeline_destroy(Simon
Ser)
- Update function names by _plane_ (Chaitanya Kumar Borah)v8:
- ReplaceDRM_ERRORbydrm_err(Louis Chauvet)
- ReplaceDRM_WARN_ONCEbydrm_WARN_ONCE(Louis Chauvet)
- Fix conflicts with upstream VKMS (Louis Chauvet)
- Add comments fordrm_color_lutlinear_array(Louis Chauvet)v7:
- Fix checkpatch warnings (Louis Chauvet)
- Changekzalloc(sizeof(struct drm_colorop) ...)tokzalloc(sizeof(*ops[i]) ...)
- Remove if (ops[i]) beforekfree(ops[i])
- Fix styles by adding and removing spaces (new lines, tabs
and so on)v6:
- drop 'len' var (Louis Chauvet)
- cleanup if colorop alloc or init fails (Louis Chauvet)
- switch loop inpre_blend_transform(Louis Chauvet)
- drop extraneous if (colorop) inside while (colorop) (Louis
Chauvet)v5:
- Squash with "Pullapply_coloropout ofpre_blend_color_transform"
(Sebastian)
- Fix warnings
- Fix include
- Drop TODOsv4:
- Drop _tf_ fromcolor_pipelineinit function
- Pass supported TFs into colorop init
- Create bypass pipeline in DRM helper (Pekka)v2:
- Add commit description
- Fix sRGB EOTF LUT definition
- Add linear and sRGB inverse EOTF LUTsdrivers/gpu/drm/vkms/Makefile | 4 +- drivers/gpu/drm/vkms/vkms_colorop.c | 81 +++ drivers/gpu/drm/vkms/vkms_composer.c | 51 +- drivers/gpu/drm/vkms/vkms_drv.h | 3 + drivers/gpu/drm/vkms/vkms_luts.c | 811 +++++++++++++++++++++++++++ drivers/gpu/drm/vkms/vkms_luts.h | 12 + drivers/gpu/drm/vkms/vkms_plane.c | 2 + 7 files changed, 962 insertions(+), 2 deletions(-)create mode 100644
drivers/gpu/drm/vkms/vkms_colorop.ccreate mode 100644drivers/gpu/drm/vkms/vkms_luts.ccreate mode 100644drivers/gpu/drm/vkms/vkms_luts.hdrivers/gpu/drm/vkms/ renamed from drivers/gpu/drm/vkms/Makefile +0
-0
Makefile
indexd657865e573f..0b8936674f69100644drivers/gpu/drm/vkms/Makefile +3
-1@@ -8,7 +8,9 @@ vkms-y := \ vkms_composer.o \ vkms_writeback.o \ vkms_connector.o \ - vkms_config.o + vkms_config.o \ + vkms_colorop.o \ + vkms_luts.o obj-$(CONFIG_DRM_VKMS) += vkms.o obj-$(CONFIG_DRM_VKMS_KUNIT_TEST) += tests/drivers/gpu/drm/ renamed from drivers/gpu/drm/vkms/vkms_colorop.c +0
-0
vkms/vkms_colorop.c
new file mode 100644
index 000000000000..f955ffb0ac84drivers/gpu/drm/vkms/vkms_colorop.c new file +17
-0@@ -0,0 +1,81 @@ +// SPDX-License-Identifier: GPL-2.0+ + +#include <linux/slab.h> +#include <drm/drm_colorop.h> +#include <drm/drm_print.h> +#include <drm/drm_property.h> +#include <drm/drm_plane.h> + +#include "vkms_drv.h" + +static const u64 supported_tfs = + BIT(DRM_COLOROP_1D_CURVE_SRGB_EOTF) | + BIT(DRM_COLOROP_1D_CURVE_SRGB_INV_EOTF); + +#define MAX_COLOR_PIPELINE_OPS 2 + +static int vkms_initialize_color_pipeline(struct drm_plane*plane,
structdrm_prop_enum_list*list)drivers/gpu/drm/vkms/vkms_colorop.c new file +17
-0+{ + struct drm_colorop *ops[MAX_COLOR_PIPELINE_OPS]; + struct drm_device *dev = plane->dev; + int ret; + int i = 0; + + memset(ops, 0, sizeof(ops)); + + /* 1st op: 1d curve */ + ops[i] = kzalloc(sizeof(*ops[i]), GFP_KERNEL); + if (!ops[i]) { + drm_err(dev, "KMS: Failed to allocate colorop\n"); + ret = -ENOMEM; + goto cleanup; + } + + ret = drm_plane_colorop_curve_1d_init(dev, ops[i], plane,
supported_tfs);
+ if (ret)
+ goto cleanup;
+
+list->type= ops[i]->base.id;
+list->name= kasprintf(GFP_KERNEL, "Color Pipeline %d", ops[i]-Quoted 1 line
base.id);
drivers/gpu/drm/vkms/vkms_colorop.c new file +12
-0+ + i++; + + /* 2nd op: 1d curve */ + ops[i] = kzalloc(sizeof(*ops[i]), GFP_KERNEL); + if (!ops[i]) { + drm_err(dev, "KMS: Failed to allocate colorop\n"); + ret = -ENOMEM; + goto cleanup; + } + + ret = drm_plane_colorop_curve_1d_init(dev, ops[i], plane,
supported_tfs);
+ if (ret)
+ goto cleanup;drivers/gpu/drm/vkms/vkms_colorop.c
Quoted 7 lines
drivers/gpu/drm/vkms/vkms_colorop.c new file +7
-0+ + drm_colorop_set_next_property(ops[i - 1], ops[i]); + + return 0; + +cleanup: + drm_colorop_pipeline_destroy(dev);If it take a device, it means that it deletes everything, which is not
what I would expect here: you are curently allocating a specific plane
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
pipeline, and deleting all colorop for other planes because of one failure is counterintuitive.
In this situation I would expect either:
- error propagation tovkms_createorvkms_output_init(it is already
the case) and "device-wide" cleanup in vkms_create/vkms_output_init;
- "local" cleanup (i.e only this specific pipeline)
the colorop are now in dev->mode_config->colorop_list, so we can use "drm_colorop_cleanup" (assuming it is changed to be available here) for cleanup if removing entire colorop_list by drm_colorop_pipeline_destroy(dev) is not desireable in vkms. Does the following code make sense?
drivers/gpu/drm/vkms/vkms_colorop.c +5 -2
@@ -19,7 +19,7 @@ static int vkms_initialize_color_pipeline(struct drm_plane *plane, struct drm_prstruct drm_colorop *ops[MAX_COLOR_PIPELINE_OPS ];struct drm_device *dev = plane->dev;int ret; -int i =0 ; +int i =0 , j =0 ;memset (ops,0 ,sizeof (ops));
@@ -91,7 +91,10 @@ static int vkms_initialize_color_pipeline(struct drm_plane *plane, struct drm_prreturn 0 ; cleanup: -drm_colorop_pipeline_destroy (dev); +for (j =0 ; j < i; j++) { +if (ops[j]) +drm_colorop_cleanup (ops[j]); + }return ret; }
Quoted 7 lines
Quoted 7 lines
Hi Louis,
Does it make sense to make
drm_colorop_pipeline_destroy(drm_plane), i.e.
in PATCH 13 as in previously V10?
Quoted 8 lines
Quoted 8 lines
and then
drm_colorop_pipeline_destroyshould limit to the pipeline in adrm_planeand should do something like
drm_colorop_cleanup(colorop);
free(colorop)
drm_plane->colorop= NULL;
This doesn't seem right after digging into it.
Quoted 10 lines
Quoted 5 lines
We can have same behaviours accross device drivers like amdgpu too.
Hi Simon and Nicolas,
Do you have comments on above proposal?
Hi,
indeed that would make more sense to me.
Louis Chauvet
maintainerRe: [PATCH V11 14/47] drm/vkms: Add enumerated 1D curve colorop
Le 18/09/2025 à 02:45, Alex Hung a écrit :
Quoted 223 lines · Nícolas F. R. A. Prado
Quoted 185 lines · Alex Hung
Quoted 184 lines · Louis Chauvet
Quoted 181 lines
Le 15/08/2025 à 05:50, Alex Hung a écrit :
Quoted 166 lines
From: Harry Wentland <[email protected]>
This patch introduces a VKMS color pipeline that includes two
drm_coloropsfor named transfer functions. For now the only ones supported are sRGB EOTF, sRGB Inverse EOTF, and a Linear TF. We will expand this in the future but I don't want to do so without accompanying IGT tests.We introduce a new
vkms_luts.cfile that hard-codes sRGB EOTF, sRGB Inverse EOTF, and a linear EOTF LUT. These have been generated with 256 entries each as IGT is currently testing only 8 bpc surfaces. We will likely need higher precision but I'm reluctant to make that change without clear indication that we need it. We'll revisit and, if necessary, regenerate the LUTs when we have IGT tests for higher precision buffers.Signed-off-by Harry Wentland <[email protected]>Signed-off-by Alex Hung <[email protected]>Reviewed-by Daniel Stone <[email protected]>---
v11:
- Updatedrm_colorop_pipeline_destroyfrom plane to dev
(Nícolas Prado)
- Fix undefined errors byEXPORT_SYMBOLsymbols (kernel test
robot)v9:
- Replace cleanup code bydrm_colorop_pipeline_destroy(Simon
Ser)
- Update function names by _plane_ (Chaitanya Kumar Borah)v8:
- ReplaceDRM_ERRORbydrm_err(Louis Chauvet)
- ReplaceDRM_WARN_ONCEbydrm_WARN_ONCE(Louis Chauvet)
- Fix conflicts with upstream VKMS (Louis Chauvet)
- Add comments fordrm_color_lutlinear_array(Louis Chauvet)v7:
- Fix checkpatch warnings (Louis Chauvet)
- Changekzalloc(sizeof(struct drm_colorop) ...)tokzalloc(sizeof(*ops[i]) ...)
- Remove if (ops[i]) beforekfree(ops[i])
- Fix styles by adding and removing spaces (new lines, tabs
and so on)v6:
- drop 'len' var (Louis Chauvet)
- cleanup if colorop alloc or init fails (Louis Chauvet)
- switch loop inpre_blend_transform(Louis Chauvet)
- drop extraneous if (colorop) inside while (colorop) (Louis
Chauvet)v5:
- Squash with "Pullapply_coloropout ofpre_blend_color_transform"
(Sebastian)
- Fix warnings
- Fix include
- Drop TODOsv4:
- Drop _tf_ fromcolor_pipelineinit function
- Pass supported TFs into colorop init
- Create bypass pipeline in DRM helper (Pekka)v2:
- Add commit description
- Fix sRGB EOTF LUT definition
- Add linear and sRGB inverse EOTF LUTsdrivers/gpu/drm/vkms/Makefile | 4 +- drivers/gpu/drm/vkms/vkms_colorop.c | 81 +++ drivers/gpu/drm/vkms/vkms_composer.c | 51 +- drivers/gpu/drm/vkms/vkms_drv.h | 3 + drivers/gpu/drm/vkms/vkms_luts.c | 811 +++++++++++++++++++++++++++ drivers/gpu/drm/vkms/vkms_luts.h | 12 + drivers/gpu/drm/vkms/vkms_plane.c | 2 + 7 files changed, 962 insertions(+), 2 deletions(-)create mode 100644
drivers/gpu/drm/vkms/vkms_colorop.ccreate mode 100644drivers/gpu/drm/vkms/vkms_luts.ccreate mode 100644drivers/gpu/drm/vkms/vkms_luts.hdrivers/gpu/drm/vkms/ renamed from drivers/gpu/drm/vkms/Makefile +0
-0
Makefile
indexd657865e573f..0b8936674f69100644drivers/gpu/drm/vkms/Makefile +3
-1@@ -8,7 +8,9 @@ vkms-y := \ vkms_composer.o \ vkms_writeback.o \ vkms_connector.o \ - vkms_config.o + vkms_config.o \ + vkms_colorop.o \ + vkms_luts.o obj-$(CONFIG_DRM_VKMS) += vkms.o obj-$(CONFIG_DRM_VKMS_KUNIT_TEST) += tests/drivers/gpu/drm/ renamed from drivers/gpu/drm/vkms/vkms_colorop.c +0
-0
vkms/vkms_colorop.c
new file mode 100644
index 000000000000..f955ffb0ac84drivers/gpu/drm/vkms/vkms_colorop.c new file +17
-0@@ -0,0 +1,81 @@ +// SPDX-License-Identifier: GPL-2.0+ + +#include <linux/slab.h> +#include <drm/drm_colorop.h> +#include <drm/drm_print.h> +#include <drm/drm_property.h> +#include <drm/drm_plane.h> + +#include "vkms_drv.h" + +static const u64 supported_tfs = + BIT(DRM_COLOROP_1D_CURVE_SRGB_EOTF) | + BIT(DRM_COLOROP_1D_CURVE_SRGB_INV_EOTF); + +#define MAX_COLOR_PIPELINE_OPS 2 + +static int vkms_initialize_color_pipeline(struct drm_plane*plane,
structdrm_prop_enum_list*list)drivers/gpu/drm/vkms/vkms_colorop.c new file +17
-0+{ + struct drm_colorop *ops[MAX_COLOR_PIPELINE_OPS]; + struct drm_device *dev = plane->dev; + int ret; + int i = 0; + + memset(ops, 0, sizeof(ops)); + + /* 1st op: 1d curve */ + ops[i] = kzalloc(sizeof(*ops[i]), GFP_KERNEL); + if (!ops[i]) { + drm_err(dev, "KMS: Failed to allocate colorop\n"); + ret = -ENOMEM; + goto cleanup; + } + + ret = drm_plane_colorop_curve_1d_init(dev, ops[i], plane,
supported_tfs);
+ if (ret)
+ goto cleanup;
+
+list->type= ops[i]->base.id;
+list->name= kasprintf(GFP_KERNEL, "Color Pipeline %d", ops[i]-Quoted 1 line
base.id);
drivers/gpu/drm/vkms/vkms_colorop.c new file +12
-0+ + i++; + + /* 2nd op: 1d curve */ + ops[i] = kzalloc(sizeof(*ops[i]), GFP_KERNEL); + if (!ops[i]) { + drm_err(dev, "KMS: Failed to allocate colorop\n"); + ret = -ENOMEM; + goto cleanup; + } + + ret = drm_plane_colorop_curve_1d_init(dev, ops[i], plane,
supported_tfs);
+ if (ret)
+ goto cleanup;drivers/gpu/drm/vkms/vkms_colorop.c
Quoted 7 lines
drivers/gpu/drm/vkms/vkms_colorop.c new file +7
-0+ + drm_colorop_set_next_property(ops[i - 1], ops[i]); + + return 0; + +cleanup: + drm_colorop_pipeline_destroy(dev);If it take a device, it means that it deletes everything, which is not
what I would expect here: you are curently allocating a specific planeQuoted 8 lines
Quoted 8 lines
Quoted 8 lines
pipeline, and deleting all colorop for other planes because of one failure is counterintuitive.
In this situation I would expect either:
- error propagation tovkms_createorvkms_output_init(it is already
the case) and "device-wide" cleanup in vkms_create/vkms_output_init;
- "local" cleanup (i.e only this specific pipeline)the colorop are now in
dev->mode_config->colorop_list, so we can use "drm_colorop_cleanup" (assuming it is changed to be available here) for cleanup if removing entirecolorop_listbydrm_colorop_pipeline_destroy(dev)is not desireable in vkms. Does the following code make sense?drivers/gpu/drm/vkms/vkms_colorop.c +0
-0@@ -19,7 +19,7 @@ static int vkms_initialize_color_pipeline(struct
drm_plane*plane, structdrm_prstruct drm_colorop *ops[MAX_COLOR_PIPELINE_OPS]; struct drm_device *dev = plane->dev; int ret;drivers/gpu/drm/vkms/vkms_colorop.c +1
-1-int i =0 ; +int i =0 , j =0 ;memset (ops,0 ,sizeof (ops));@@ -91,7 +91,10 @@ static int vkms_initialize_color_pipeline(struct
drm_plane*plane, structdrm_pr
return 0;cleanup:
drivers/gpu/drm/vkms/vkms_colorop.c static int vkms_initialize_color_pipeline(struct drm_plane *plane, struct drm_pr · line 100
Quoted 8 lines
drivers/gpu/drm/vkms/vkms_colorop.c +4
-1-drm_colorop_pipeline_destroy (dev); +for (j =0 ; j < i; j++) { +if (ops[j]) +drm_colorop_cleanup (ops[j]); + }return ret; }
Yes, that could work!
I think you need to add a kfree for ops[j], but this code is better: it only destroy what was allocated in this function, no more.
BTW, while reviewing this series + post_blend, I noticed that the pipeline is never freed on device destruction. Did I miss something in the colorop core? If no, I think it should be added in vkms_destroy or using automagic drmm_add_action_or_reset in vkms_output_init.
Quoted 29 lines
Quoted 7 lines
Quoted 7 lines
Hi Louis,
Does it make sense to make
drm_colorop_pipeline_destroy(drm_plane), i.e.
in PATCH 13 as in previously V10?Quoted 8 lines
Quoted 8 lines
and then
drm_colorop_pipeline_destroyshould limit to the pipeline in adrm_planeand should do something likedrm_colorop_cleanup(colorop); free(colorop) drm_plane->colorop = NULL;This doesn't seem right after digging into it.
Quoted 10 lines
Quoted 5 lines
We can have same behaviours accross device drivers like amdgpu too.
Hi Simon and Nicolas,
Do you have comments on above proposal?
Hi,
indeed that would make more sense to me.
Signature · 4 lines
-- Louis Chauvet, Bootlin Embedded Linux and Kernel engineering https://bootlin.com
Re: [PATCH V11 14/47] drm/vkms: Add enumerated 1D curve colorop
Quoted 232 lines · Louis Chauvet
Le 18/09/2025 à 02:45, Alex Hung a écrit :
Quoted 229 lines · Nícolas F. R. A. Prado
Quoted 185 lines · Alex Hung
Quoted 184 lines · Louis Chauvet
Quoted 181 lines
Le 15/08/2025 à 05:50, Alex Hung a écrit :
Quoted 166 lines
From: Harry Wentland <[email protected]>
This patch introduces a VKMS color pipeline that includes two
drm_coloropsfor named transfer functions. For now the only ones supported are sRGB EOTF, sRGB Inverse EOTF, and a Linear TF. We will expand this in the future but I don't want to do so without accompanying IGT tests.We introduce a new
vkms_luts.cfile that hard-codes sRGB EOTF, sRGB Inverse EOTF, and a linear EOTF LUT. These have been generated with 256 entries each as IGT is currently testing only 8 bpc surfaces. We will likely need higher precision but I'm reluctant to make that change without clear indication that we need it. We'll revisit and, if necessary, regenerate the LUTs when we have IGT tests for higher precision buffers.Signed-off-by Harry Wentland <[email protected]>Signed-off-by Alex Hung <[email protected]>Reviewed-by Daniel Stone <[email protected]>---
v11:
- Updatedrm_colorop_pipeline_destroyfrom plane to dev (Nícolas Prado)
- Fix undefined errors byEXPORT_SYMBOLsymbols (kernel test robot)v9:
- Replace cleanup code bydrm_colorop_pipeline_destroy(Simon Ser)
- Update function names by _plane_ (Chaitanya Kumar Borah)v8:
- ReplaceDRM_ERRORbydrm_err(Louis Chauvet)
- ReplaceDRM_WARN_ONCEbydrm_WARN_ONCE(Louis Chauvet)
- Fix conflicts with upstream VKMS (Louis Chauvet)
- Add comments fordrm_color_lutlinear_array(Louis Chauvet)v7:
- Fix checkpatch warnings (Louis Chauvet)
- Changekzalloc(sizeof(struct drm_colorop) ...)tokzalloc(sizeof(*ops[i]) ...)
- Remove if (ops[i]) beforekfree(ops[i])
- Fix styles by adding and removing spaces (new lines, tabs and so on)v6:
- drop 'len' var (Louis Chauvet)
- cleanup if colorop alloc or init fails (Louis Chauvet)
- switch loop inpre_blend_transform(Louis Chauvet)
- drop extraneous if (colorop) inside while (colorop) (Louis Chauvet)v5:
- Squash with "Pullapply_coloropout ofpre_blend_color_transform"
(Sebastian)
- Fix warnings
- Fix include
- Drop TODOsv4:
- Drop _tf_ fromcolor_pipelineinit function
- Pass supported TFs into colorop init
- Create bypass pipeline in DRM helper (Pekka)v2:
- Add commit description
- Fix sRGB EOTF LUT definition
- Add linear and sRGB inverse EOTF LUTsdrivers/gpu/drm/vkms/Makefile | 4 +- drivers/gpu/drm/vkms/vkms_colorop.c | 81 +++
drivers/gpu/drm/vkms/vkms_composer.c| 51 +- drivers/gpu/drm/vkms/vkms_drv.h | 3 + drivers/gpu/drm/vkms/vkms_luts.c | 811
+++++++++++++++++++++++++++
drivers/gpu/drm/vkms/vkms_luts.h | 12 + drivers/gpu/drm/vkms/vkms_plane.c | 2 +7 files changed, 962 insertions(+), 2 deletions(-)create mode 100644
drivers/gpu/drm/vkms/vkms_colorop.ccreate mode 100644drivers/gpu/drm/vkms/vkms_luts.ccreate mode 100644drivers/gpu/drm/vkms/vkms_luts.hdrivers/gpu/drm/vkms/ renamed from drivers/gpu/drm/vkms/Makefile +0
-0
Makefile
indexd657865e573f..0b8936674f69100644drivers/gpu/drm/vkms/Makefile +3
-1@@ -8,7 +8,9 @@ vkms-y := \ vkms_composer.o \ vkms_writeback.o \ vkms_connector.o \ - vkms_config.o + vkms_config.o \ + vkms_colorop.o \ + vkms_luts.oobj-$(CONFIG_DRM_VKMS) += vkms.o
obj-$(CONFIG_DRM_VKMS_KUNIT_TEST) += tests/drivers/gpu/drm/ renamed from drivers/gpu/drm/vkms/vkms_colorop.c +0
-0
vkms/vkms_colorop.c
new file mode 100644
index 000000000000..f955ffb0ac84drivers/gpu/drm/vkms/vkms_colorop.c new file +17
-0@@ -0,0 +1,81 @@ +// SPDX-License-Identifier: GPL-2.0+ + +#include <linux/slab.h> +#include <drm/drm_colorop.h> +#include <drm/drm_print.h> +#include <drm/drm_property.h> +#include <drm/drm_plane.h> + +#include "vkms_drv.h" + +static const u64 supported_tfs = + BIT(DRM_COLOROP_1D_CURVE_SRGB_EOTF) | + BIT(DRM_COLOROP_1D_CURVE_SRGB_INV_EOTF); + +#define MAX_COLOR_PIPELINE_OPS 2 + +static int vkms_initialize_color_pipeline(struct drm_plane*plane,
structdrm_prop_enum_list*list)drivers/gpu/drm/vkms/vkms_colorop.c new file +17
-0+{ + struct drm_colorop *ops[MAX_COLOR_PIPELINE_OPS]; + struct drm_device *dev = plane->dev; + int ret; + int i = 0; + + memset(ops, 0, sizeof(ops)); + + /* 1st op: 1d curve */ + ops[i] = kzalloc(sizeof(*ops[i]), GFP_KERNEL); + if (!ops[i]) { + drm_err(dev, "KMS: Failed to allocate colorop\n"); + ret = -ENOMEM; + goto cleanup; + } + + ret = drm_plane_colorop_curve_1d_init(dev, ops[i], plane,
supported_tfs);
+ if (ret)
+ goto cleanup;
+
+list->type= ops[i]->base.id;
+list->name= kasprintf(GFP_KERNEL, "Color Pipeline %d", ops[i]-Quoted 1 line
base.id);
drivers/gpu/drm/vkms/vkms_colorop.c new file +12
-0+ + i++; + + /* 2nd op: 1d curve */ + ops[i] = kzalloc(sizeof(*ops[i]), GFP_KERNEL); + if (!ops[i]) { + drm_err(dev, "KMS: Failed to allocate colorop\n"); + ret = -ENOMEM; + goto cleanup; + } + + ret = drm_plane_colorop_curve_1d_init(dev, ops[i], plane,
supported_tfs);
+ if (ret)
+ goto cleanup;drivers/gpu/drm/vkms/vkms_colorop.c
Quoted 7 lines
drivers/gpu/drm/vkms/vkms_colorop.c new file +7
-0+ + drm_colorop_set_next_property(ops[i - 1], ops[i]); + + return 0; + +cleanup: + drm_colorop_pipeline_destroy(dev);If it take a device, it means that it deletes everything, which is not
what I would expect here: you are curently allocating a specific planeQuoted 8 lines
Quoted 8 lines
Quoted 8 lines
pipeline, and deleting all colorop for other planes because of one failure is counterintuitive.
In this situation I would expect either:
- error propagation tovkms_createorvkms_output_init(it is already
the case) and "device-wide" cleanup in vkms_create/vkms_output_init;
- "local" cleanup (i.e only this specific pipeline)the colorop are now in
dev->mode_config->colorop_list, so we can use "drm_colorop_cleanup" (assuming it is changed to be available here) for cleanup if removing entirecolorop_listbydrm_colorop_pipeline_destroy(dev)is not desireable in vkms. Does the following code make sense?drivers/gpu/drm/vkms/vkms_colorop.c +0
-0@@ -19,7 +19,7 @@ static int vkms_initialize_color_pipeline(struct
drm_plane*plane, structdrm_pr
structdrm_colorop*ops[MAX_COLOR_PIPELINE_OPS]; structdrm_device*dev =plane->dev; int ret;
- int i = 0;
+ int i = 0, j = 0;
memset(ops, 0, sizeof(ops));drivers/gpu/drm/vkms/vkms_colorop.c +0
-0@@ -91,7 +91,10 @@ static int vkms_initialize_color_pipeline(struct
drm_plane*plane, structdrm_pr
return 0;cleanup:
-drm_colorop_pipeline_destroy(dev);
+ for (j = 0; j < i; j++) {
+ if (ops[j])
+drm_colorop_cleanup(ops[j]);
+ }
Quoted 8 lines
Quoted 2 lines
return ret;
}Yes, that could work!
I think you need to add a kfree for ops[j], but this code is better: it only destroy what was allocated in this function, no more.
BTW, while reviewing this series +
post_blend, I noticed that the pipeline is never freed on device destruction. Did I miss something in the colorop core? If no, I think it should be added invkms_destroyor using automagicdrmm_add_action_or_resetinvkms_output_init.
drm_colorop_pipeline_destroy cal be called in vkms_destroy.
@@ -240,6 +240,7 @@ static void vkms_destroy(struct vkms_config *config)
fdev = config->dev->faux_dev;
+ drm_colorop_pipeline_destroy(&config->dev->drm);
drm_dev_unregister(&config->dev->drm);
drm_atomic_helper_shutdown(&config->dev->drm);
devres_release_group(&fdev->dev, NULL);Quoted 31 lines
Quoted 30 lines
Quoted 8 lines
Quoted 8 lines
Hi Louis,
Does it make sense to make
drm_colorop_pipeline_destroy(drm_plane), i.e.
in PATCH 13 as in previously V10?Quoted 8 lines
Quoted 8 lines
and then
drm_colorop_pipeline_destroyshould limit to the pipeline in adrm_planeand should do something like
drm_colorop_cleanup(colorop);
free(colorop)
drm_plane->colorop= NULL;This doesn't seem right after digging into it.
Quoted 10 lines
Quoted 5 lines
We can have same behaviours accross device drivers like amdgpu too.
Hi Simon and Nicolas,
Do you have comments on above proposal?
Hi,
indeed that would make more sense to me.
Louis Chauvet
maintainerRe: [PATCH V11 14/47] drm/vkms: Add enumerated 1D curve colorop
Le 20/09/2025 à 05:31, Alex Hung a écrit :
Quoted 252 lines · Louis Chauvet
Quoted 237 lines
Le 18/09/2025 à 02:45, Alex Hung a écrit :
Quoted 229 lines · Nícolas F. R. A. Prado
Quoted 185 lines · Alex Hung
Quoted 184 lines · Louis Chauvet
Quoted 181 lines
Le 15/08/2025 à 05:50, Alex Hung a écrit :
Quoted 166 lines
From: Harry Wentland <[email protected]>
This patch introduces a VKMS color pipeline that includes two
drm_coloropsfor named transfer functions. For now the only ones supported are sRGB EOTF, sRGB Inverse EOTF, and a Linear TF. We will expand this in the future but I don't want to do so without accompanying IGT tests.We introduce a new
vkms_luts.cfile that hard-codes sRGB EOTF, sRGB Inverse EOTF, and a linear EOTF LUT. These have been generated with 256 entries each as IGT is currently testing only 8 bpc surfaces. We will likely need higher precision but I'm reluctant to make that change without clear indication that we need it. We'll revisit and, if necessary, regenerate the LUTs when we have IGT tests for higher precision buffers.Signed-off-by Harry Wentland <[email protected]>Signed-off-by Alex Hung <[email protected]>Reviewed-by Daniel Stone <[email protected]>---
v11:
- Updatedrm_colorop_pipeline_destroyfrom plane to dev
(Nícolas Prado)
- Fix undefined errors byEXPORT_SYMBOLsymbols (kernel test
robot)v9:
- Replace cleanup code bydrm_colorop_pipeline_destroy(Simon
Ser)
- Update function names by _plane_ (Chaitanya Kumar Borah)v8:
- ReplaceDRM_ERRORbydrm_err(Louis Chauvet)
- ReplaceDRM_WARN_ONCEbydrm_WARN_ONCE(Louis Chauvet)
- Fix conflicts with upstream VKMS (Louis Chauvet)
- Add comments fordrm_color_lutlinear_array(Louis Chauvet)v7:
- Fix checkpatch warnings (Louis Chauvet)
- Changekzalloc(sizeof(struct drm_colorop) ...)tokzalloc(sizeof(*ops[i]) ...)
- Remove if (ops[i]) beforekfree(ops[i])
- Fix styles by adding and removing spaces (new lines, tabs
and so on)v6:
- drop 'len' var (Louis Chauvet)
- cleanup if colorop alloc or init fails (Louis Chauvet)
- switch loop inpre_blend_transform(Louis Chauvet)
- drop extraneous if (colorop) inside while (colorop) (Louis
Chauvet)v5:
- Squash with "Pullapply_coloropout ofpre_blend_color_transform"
(Sebastian)
- Fix warnings
- Fix include
- Drop TODOsv4:
- Drop _tf_ fromcolor_pipelineinit function
- Pass supported TFs into colorop init
- Create bypass pipeline in DRM helper (Pekka)v2:
- Add commit description
- Fix sRGB EOTF LUT definition
- Add linear and sRGB inverse EOTF LUTsdrivers/gpu/drm/vkms/Makefile | 4 +- drivers/gpu/drm/vkms/vkms_colorop.c | 81 +++ drivers/gpu/drm/vkms/vkms_composer.c | 51 +- drivers/gpu/drm/vkms/vkms_drv.h | 3 + drivers/gpu/drm/vkms/vkms_luts.c | 811 +++++++++++++++++++++++++++ drivers/gpu/drm/vkms/vkms_luts.h | 12 + drivers/gpu/drm/vkms/vkms_plane.c | 2 + 7 files changed, 962 insertions(+), 2 deletions(-)create mode 100644
drivers/gpu/drm/vkms/vkms_colorop.ccreate mode 100644drivers/gpu/drm/vkms/vkms_luts.ccreate mode 100644drivers/gpu/drm/vkms/vkms_luts.hdrivers/gpu/drm/vkms/ renamed from drivers/gpu/drm/vkms/Makefile +0
-0
Makefile
indexd657865e573f..0b8936674f69100644drivers/gpu/drm/vkms/Makefile +3
-1@@ -8,7 +8,9 @@ vkms-y := \ vkms_composer.o \ vkms_writeback.o \ vkms_connector.o \ - vkms_config.o + vkms_config.o \ + vkms_colorop.o \ + vkms_luts.o obj-$(CONFIG_DRM_VKMS) += vkms.o obj-$(CONFIG_DRM_VKMS_KUNIT_TEST) += tests/drivers/gpu/drm/ renamed from drivers/gpu/drm/vkms/vkms_colorop.c +0
-0
vkms/vkms_colorop.c
new file mode 100644
index 000000000000..f955ffb0ac84drivers/gpu/drm/vkms/vkms_colorop.c new file +17
-0@@ -0,0 +1,81 @@ +// SPDX-License-Identifier: GPL-2.0+ + +#include <linux/slab.h> +#include <drm/drm_colorop.h> +#include <drm/drm_print.h> +#include <drm/drm_property.h> +#include <drm/drm_plane.h> + +#include "vkms_drv.h" + +static const u64 supported_tfs = + BIT(DRM_COLOROP_1D_CURVE_SRGB_EOTF) | + BIT(DRM_COLOROP_1D_CURVE_SRGB_INV_EOTF); + +#define MAX_COLOR_PIPELINE_OPS 2 + +static int vkms_initialize_color_pipeline(struct drm_plane*plane,
structdrm_prop_enum_list*list)drivers/gpu/drm/vkms/vkms_colorop.c new file +17
-0+{ + struct drm_colorop *ops[MAX_COLOR_PIPELINE_OPS]; + struct drm_device *dev = plane->dev; + int ret; + int i = 0; + + memset(ops, 0, sizeof(ops)); + + /* 1st op: 1d curve */ + ops[i] = kzalloc(sizeof(*ops[i]), GFP_KERNEL); + if (!ops[i]) { + drm_err(dev, "KMS: Failed to allocate colorop\n"); + ret = -ENOMEM; + goto cleanup; + } + + ret = drm_plane_colorop_curve_1d_init(dev, ops[i], plane,
supported_tfs);
+ if (ret)
+ goto cleanup;
+
+list->type= ops[i]->base.id;
+list->name= kasprintf(GFP_KERNEL, "Color Pipeline %d", ops[i]-Quoted 1 line
base.id);
drivers/gpu/drm/vkms/vkms_colorop.c new file +12
-0+ + i++; + + /* 2nd op: 1d curve */ + ops[i] = kzalloc(sizeof(*ops[i]), GFP_KERNEL); + if (!ops[i]) { + drm_err(dev, "KMS: Failed to allocate colorop\n"); + ret = -ENOMEM; + goto cleanup; + } + + ret = drm_plane_colorop_curve_1d_init(dev, ops[i], plane,
supported_tfs);
+ if (ret)
+ goto cleanup;drivers/gpu/drm/vkms/vkms_colorop.c
Quoted 7 lines
drivers/gpu/drm/vkms/vkms_colorop.c new file +7
-0+ + drm_colorop_set_next_property(ops[i - 1], ops[i]); + + return 0; + +cleanup: + drm_colorop_pipeline_destroy(dev);If it take a device, it means that it deletes everything, which is not
what I would expect here: you are curently allocating a specific planeQuoted 8 lines
Quoted 8 lines
Quoted 8 lines
pipeline, and deleting all colorop for other planes because of one failure is counterintuitive.
In this situation I would expect either:
- error propagation tovkms_createorvkms_output_init(it is already
the case) and "device-wide" cleanup in vkms_create/vkms_output_init;
- "local" cleanup (i.e only this specific pipeline)the colorop are now in
dev->mode_config->colorop_list, so we can use "drm_colorop_cleanup" (assuming it is changed to be available here) for cleanup if removing entirecolorop_listbydrm_colorop_pipeline_destroy(dev)is not desireable in vkms. Does the following code make sense?drivers/gpu/drm/vkms/vkms_colorop.c +0
-0@@ -19,7 +19,7 @@ static int vkms_initialize_color_pipeline(struct
drm_plane*plane, structdrm_pr
structdrm_colorop*ops[MAX_COLOR_PIPELINE_OPS]; structdrm_device*dev =plane->dev; int ret;
- int i = 0;
+ int i = 0, j = 0;
memset(ops, 0, sizeof(ops));drivers/gpu/drm/vkms/vkms_colorop.c +0
-0@@ -91,7 +91,10 @@ static int vkms_initialize_color_pipeline(struct
drm_plane*plane, structdrm_pr
return 0;cleanup:
-drm_colorop_pipeline_destroy(dev);
+ for (j = 0; j < i; j++) {
+ if (ops[j])
+drm_colorop_cleanup(ops[j]);
+ }Quoted 2 lines
return ret;
}Yes, that could work!
Quoted 7 lines
I think you need to add a kfree for ops[j], but this code is better: it only destroy what was allocated in this function, no more.
BTW, while reviewing this series +
post_blend, I noticed that the pipeline is never freed on device destruction. Did I miss something in the colorop core? If no, I think it should be added invkms_destroyor using automagicdrmm_add_action_or_resetinvkms_output_init.
drm_colorop_pipeline_destroycal be called invkms_destroy.
Review static void vkms_destroy(struct vkms_config *config) · line 246
Quoted 7 lines
(quoted diff) +1
-0@@ -240,6 +240,7 @@ static void vkms_destroy(struct vkms_config *config) fdev = config->dev->faux_dev; + drm_colorop_pipeline_destroy(&config->dev->drm); drm_dev_unregister(&config->dev->drm); drm_atomic_helper_shutdown(&config->dev->drm); devres_release_group(&fdev->dev, NULL);
Seems ok!
Quoted 32 lines
Quoted 31 lines
Quoted 30 lines
Quoted 8 lines
Quoted 8 lines
Hi Louis,
Does it make sense to make
drm_colorop_pipeline_destroy(drm_plane), i.e.
in PATCH 13 as in previously V10?Quoted 8 lines
Quoted 8 lines
and then
drm_colorop_pipeline_destroyshould limit to the pipeline in adrm_planeand should do something like
drm_colorop_cleanup(colorop);
free(colorop)
drm_plane->colorop= NULL;This doesn't seem right after digging into it.
Quoted 10 lines
Quoted 5 lines
We can have same behaviours accross device drivers like amdgpu too.
Hi Simon and Nicolas,
Do you have comments on above proposal?
Hi,
indeed that would make more sense to me.
Signature · 4 lines
-- Louis Chauvet, Bootlin Embedded Linux and Kernel engineering https://bootlin.com
PATCH v11 15/47 drm/vkms: Add kunit tests for linear and sRGB LUTs
In reply to Alex HungFrom: Harry Wentland <[email protected]>
Two tests are added to VKMS LUT handling:
- linear
- inv_srgb
---
v7:
- Fix checkpatch warnings (Louis Chauvet)
- Adde a commit messages
- Fix code styles by adding and removing spaces (new lines, tabs and so on)
drivers/gpu/drm/vkms/tests/vkms_color_test.c | 39 +++++++++++++++++++- drivers/gpu/drm/vkms/vkms_composer.c | 17 ++------- drivers/gpu/drm/vkms/vkms_composer.h | 13 +++++++ 3 files changed, 55 insertions(+), 14 deletions(-)
drivers/gpu/drm/vkms/tests/vkms_color_test.c +38 -1
@@ -6,6 +6,7 @@#include <drm/drm_mode.h> #include "../vkms_drv.h" #include "../vkms_composer.h" +#include "../vkms_luts.h" #define TEST_LUT_SIZE 16
@@ -87,7 +88,6 @@ static const struct vkms_color_lut test_linear_lut = { .channel_value2index_ratio = 0xf000fll }; -static void vkms_color_test_get_lut_index (struct kunit *test) {s64 lut_index;
@@ -100,6 +100,19 @@ static void vkms_color_test_get_lut_index(struct kunit *test) lut_index =get_lut_index (&test_linear_lut, test_linear_array[i].red);KUNIT_EXPECT_EQ (test,drm_fixp2int_ceil (lut_index), i); } + +KUNIT_EXPECT_EQ (test,drm_fixp2int (get_lut_index (&srgb_eotf,0x0 )),0x0 ); +KUNIT_EXPECT_EQ (test,drm_fixp2int_ceil (get_lut_index (&srgb_eotf,0x0 )),0x0 ); +KUNIT_EXPECT_EQ (test,drm_fixp2int_ceil (get_lut_index (&srgb_eotf,0x101 )),0x1 ); +KUNIT_EXPECT_EQ (test,drm_fixp2int_ceil (get_lut_index (&srgb_eotf,0x202 )),0x2 ); + +KUNIT_EXPECT_EQ (test,drm_fixp2int (get_lut_index (&srgb_inv_eotf,0x0 )),0x0 ); +KUNIT_EXPECT_EQ (test,drm_fixp2int_ceil (get_lut_index (&srgb_inv_eotf,0x0 )),0x0 ); +KUNIT_EXPECT_EQ (test,drm_fixp2int_ceil (get_lut_index (&srgb_inv_eotf,0x101 )),0x1 ); +KUNIT_EXPECT_EQ (test,drm_fixp2int_ceil (get_lut_index (&srgb_inv_eotf,0x202 )),0x2 ); + +KUNIT_EXPECT_EQ (test,drm_fixp2int_ceil (get_lut_index (&srgb_eotf,0xfefe )),0xfe ); +KUNIT_EXPECT_EQ (test,drm_fixp2int_ceil (get_lut_index (&srgb_eotf,0xffff )),0xff ); }static void vkms_color_test_lerp (struct kunit *test)
@@ -113,9 +126,33 @@ static void vkms_color_test_lerp(struct kunit *test) } } +static void vkms_color_test_linear (struct kunit *test) +{ +for (int i =0 ; i <LUT_SIZE ; i++) { +int linear =apply_lut_to_channel_value (&linear_eotf, i *0x101 ,LUT_RED ); + +KUNIT_EXPECT_EQ (test,DIV_ROUND_CLOSEST (linear,0x101 ), i); + } +} + +static void vkms_color_srgb_inv_srgb (struct kunit *test) +{ +u16 srgb, final; + +for (int i =0 ; i <LUT_SIZE ; i++) { + srgb =apply_lut_to_channel_value (&srgb_eotf, i *0x101 ,LUT_RED ); + final =apply_lut_to_channel_value (&srgb_inv_eotf, srgb,LUT_RED ); + +KUNIT_EXPECT_GE (test, final /0x101 , i -1 ); +KUNIT_EXPECT_LE (test, final /0x101 , i +1 ); + } +} +static struct kunit_case vkms_color_test_cases[] = {KUNIT_CASE (vkms_color_test_get_lut_index),KUNIT_CASE (vkms_color_test_lerp), +KUNIT_CASE (vkms_color_test_linear), +KUNIT_CASE (vkms_color_srgb_inv_srgb), {} };
drivers/gpu/drm/vkms/vkms_composer.c +4 -13
@@ -82,19 +82,8 @@ VISIBLE_IF_KUNIT s64 get_lut_index(const struct vkms_color_lut *lut, u16 channel }EXPORT_SYMBOL_IF_KUNIT (get_lut_index); -/* -* This enum is related to the positions of the variables inside -* `struct drm_color_lut`, so the order of both needs to be the same. -*/ -enum lut_channel { -LUT_RED =0 , -LUT_GREEN , -LUT_BLUE , -LUT_RESERVED -}; - -static u16 apply_lut_to_channel_value (const struct vkms_color_lut *lut,u16 channel_value, -enum lut_channel channel) +VISIBLE_IF_KUNIT u16 apply_lut_to_channel_value(const struct vkms_color_lut *lut, u16 channel_value, +enum lut_channel channel) {s64 lut_index =get_lut_index (lut, channel_value);u16 *floor_lut_value, *ceil_lut_value;
@@ -119,6 +108,8 @@ static u16 apply_lut_to_channel_value(const struct vkms_color_lut *lut, u16 chanreturn lerp_u16 (floor_channel_value, ceil_channel_value, lut_index &DRM_FIXED_DECIMAL_MASK ); } +EXPORT_SYMBOL_IF_KUNIT (apply_lut_to_channel_value); +static void apply_lut (const struct vkms_crtc_state *crtc_state,struct line_buffer *output_buffer) {
drivers/gpu/drm/vkms/vkms_composer.h +13 -0
@@ -5,9 +5,22 @@#include <kunit/visibility.h> +/* +* This enum is related to the positions of the variables inside +* `struct drm_color_lut`, so the order of both needs to be the same. +*/ +enum lut_channel { +LUT_RED =0 , +LUT_GREEN , +LUT_BLUE , +LUT_RESERVED +}; +#if IS_ENABLED (CONFIG_KUNIT )u16 lerp_u16 (u16 a,u16 b,s64 t);s64 get_lut_index (const struct vkms_color_lut *lut,u16 channel_value); +u16 apply_lut_to_channel_value (const struct vkms_color_lut *lut,u16 channel_value, +enum lut_channel channel);#endif #endif /* _VKMS_COMPOSER_H_ */
Signature · 1 line
2.43.0
kernel test robot
build botRe: [PATCH V11 15/47] drm/vkms: Add kunit tests for linear and sRGB LUTs
kernel test robot noticed the following build errors:
Hi Alex,
kernel test robot noticed the following build errors:
[auto build test ERROR on drm-exynos/exynos-drm-next]
[also build test ERROR on linus/master v6.17-rc1 next-20250815] [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/Alex-Hung/drm-Add-helper-for-conversion-from-signed-magnitude/20250815-120435 base: https://git.kernel.org/pub/scm/linux/kernel/git/daeinki/drm-exynos.git exynos-drm-next patch link: https://lore.kernel.org/r/20250815035047.3319284-16-alex.hung%40amd.com patch subject: [PATCH V11 15/47] drm/vkms: Add kunit tests for linear and sRGB LUTs config: arc-randconfig-001-20250816 (https://download.01.org/0day-ci/archive/20250816/[email protected]/config) compiler: arc-linux-gcc (GCC) 8.5.0 reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20250816/[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 errors (new ones prefixed by >>):
In file included from drivers/gpu/drm/vkms/vkms_composer.c:15:
drivers/gpu/drm/vkms/vkms_composer.h:21:32: warning: 'struct vkms_color_lut' declared inside parameter list will not be visible outside of this definition or declaration
s64 get_lut_index(const struct vkms_color_lut *lut, u16 channel_value);
^~~~~~~~~~~~~~
drivers/gpu/drm/vkms/vkms_composer.h:22:45: warning: 'struct vkms_color_lut' declared inside parameter list will not be visible outside of this definition or declaration
u16 apply_lut_to_channel_value(const struct vkms_color_lut *lut, u16 channel_value,
^~~~~~~~~~~~~~
drivers/gpu/drm/vkms/vkms_composer.c:77:22: error: conflicting types for 'get_lut_index'
VISIBLE_IF_KUNIT s64 get_lut_index(const struct vkms_color_lut *lut, u16 channel_value)
^~~~~~~~~~~~~
In file included from drivers/gpu/drm/vkms/vkms_composer.c:15:
drivers/gpu/drm/vkms/vkms_composer.h:21:5: note: previous declaration of 'get_lut_index' was here
s64 get_lut_index(const struct vkms_color_lut *lut, u16 channel_value);
^~~~~~~~~~~~~
In file included from include/linux/linkage.h:7,
from include/linux/preempt.h:10,
from include/linux/spinlock.h:56,
from include/drm/drm_crtc.h:28,
from include/drm/drm_atomic.h:31,
from drivers/gpu/drm/vkms/vkms_composer.c:5:
drivers/gpu/drm/vkms/vkms_composer.c:83:24: error: conflicting types for 'get_lut_index'
EXPORT_SYMBOL_IF_KUNIT(get_lut_index);
^~~~~~~~~~~~~
include/linux/export.h:76:21: note: in definition of macro '__EXPORT_SYMBOL'
extern typeof(sym) sym; \
^~~
include/kunit/visibility.h:27:44: note: in expansion of macro 'EXPORT_SYMBOL_NS'
#define EXPORT_SYMBOL_IF_KUNIT(symbol) EXPORT_SYMBOL_NS(symbol, "EXPORTED_FOR_KUNIT_TESTING")
^~~~~~~~~~~~~~~~
drivers/gpu/drm/vkms/vkms_composer.c:83:1: note: in expansion of macro 'EXPORT_SYMBOL_IF_KUNIT'
EXPORT_SYMBOL_IF_KUNIT(get_lut_index);
^~~~~~~~~~~~~~~~~~~~~~
In file included from drivers/gpu/drm/vkms/vkms_composer.c:15:
drivers/gpu/drm/vkms/vkms_composer.h:21:5: note: previous declaration of 'get_lut_index' was here
s64 get_lut_index(const struct vkms_color_lut *lut, u16 channel_value);
^~~~~~~~~~~~~
>> drivers/gpu/drm/vkms/vkms_composer.c:85:22: error: conflicting types for 'apply_lut_to_channel_value'
VISIBLE_IF_KUNIT u16 apply_lut_to_channel_value(const struct vkms_color_lut *lut, u16 channel_value,
^~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from drivers/gpu/drm/vkms/vkms_composer.c:15:
drivers/gpu/drm/vkms/vkms_composer.h:22:5: note: previous declaration of 'apply_lut_to_channel_value' was here
u16 apply_lut_to_channel_value(const struct vkms_color_lut *lut, u16 channel_value,
^~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from include/linux/linkage.h:7,
from include/linux/preempt.h:10,
from include/linux/spinlock.h:56,
from include/drm/drm_crtc.h:28,
from include/drm/drm_atomic.h:31,
from drivers/gpu/drm/vkms/vkms_composer.c:5:
drivers/gpu/drm/vkms/vkms_composer.c:111:24: error: conflicting types for 'apply_lut_to_channel_value'
EXPORT_SYMBOL_IF_KUNIT(apply_lut_to_channel_value);
^~~~~~~~~~~~~~~~~~~~~~~~~~
include/linux/export.h:76:21: note: in definition of macro '__EXPORT_SYMBOL'
extern typeof(sym) sym; \
^~~
include/kunit/visibility.h:27:44: note: in expansion of macro 'EXPORT_SYMBOL_NS'
#define EXPORT_SYMBOL_IF_KUNIT(symbol) EXPORT_SYMBOL_NS(symbol, "EXPORTED_FOR_KUNIT_TESTING")
^~~~~~~~~~~~~~~~
drivers/gpu/drm/vkms/vkms_composer.c:111:1: note: in expansion of macro 'EXPORT_SYMBOL_IF_KUNIT'
EXPORT_SYMBOL_IF_KUNIT(apply_lut_to_channel_value);
^~~~~~~~~~~~~~~~~~~~~~ In file included from drivers/gpu/drm/vkms/vkms_composer.c:15:
drivers/gpu/drm/vkms/vkms_composer.h:22:5: note: previous declaration of 'apply_lut_to_channel_value' was here
u16 apply_lut_to_channel_value(const struct vkms_color_lut *lut, u16 channel_value,
^~~~~~~~~~~~~~~~~~~~~~~~~~
vim +/apply_lut_to_channel_value +85 drivers/gpu/drm/vkms/vkms_composer.c
76
77 VISIBLE_IF_KUNIT s64 get_lut_index(const struct vkms_color_lut *lut, u16 channel_value)
78 {
79 s64 color_channel_fp = drm_int2fixp(channel_value);
80
81 return drm_fixp_mul(color_channel_fp, lut->channel_value2index_ratio);
82 }
> 83 EXPORT_SYMBOL_IF_KUNIT(get_lut_index);
84
> 85 VISIBLE_IF_KUNIT u16 apply_lut_to_channel_value(const struct vkms_color_lut *lut, u16 channel_value,
86 enum lut_channel channel)
87 {
88 s64 lut_index = get_lut_index(lut, channel_value);
89 u16 *floor_lut_value, *ceil_lut_value;
90 u16 floor_channel_value, ceil_channel_value;
91
92 /*
93 * This checks if `struct drm_color_lut` has any gap added by the compiler
94 * between the struct fields.
95 */
96 static_assert(sizeof(struct drm_color_lut) == sizeof(__u16) * 4);
97
98 floor_lut_value = (__u16 *)&lut->base[drm_fixp2int(lut_index)];
99 if (drm_fixp2int(lut_index) == (lut->lut_length - 1)) 100 /* We're at the end of the LUT array, use same value for ceil and floor */
101 ceil_lut_value = floor_lut_value;
102 else
103 ceil_lut_value = (__u16 *)&lut->base[drm_fixp2int_ceil(lut_index)];
104
105 floor_channel_value = floor_lut_value[channel];
106 ceil_channel_value = ceil_lut_value[channel];
107
108 return lerp_u16(floor_channel_value, ceil_channel_value,
109 lut_index & DRM_FIXED_DECIMAL_MASK);
110 }
111 EXPORT_SYMBOL_IF_KUNIT(apply_lut_to_channel_value);
112
113
Signature · 2 lines
0-DAY CI Kernel Test Service https://github.com/intel/lkp-tests/wiki
PATCH v11 16/47 drm/colorop: Add 3x4 CTM type
In reply to Alex HungFrom: Harry Wentland <[email protected]>
This type is used to support a 3x4 matrix in colorops. A 3x4 matrix uses the last column as a "bias" column. Some HW exposes support for 3x4. The calculation looks like:
out matrix in
|R| |0 1 2 3 | | R |
|G| = |4 5 6 7 | x | G |
|B| |8 9 10 11| | B |
|1.0|This is also the first colorop where we need a blob property to program the property. For that we'll introduce a new DATA property that can be used by all colorop TYPEs requiring a blob. The way a DATA blob is read depends on the TYPE of the colorop.
We only create the DATA property for property types that need it.
---
v9:
- Merge cleanup code for colorop->state->data in drm_colorop_cleanup (Simon Ser)
- Update function names by _plane_ (Chaitanya Kumar Borah)
v6:
- take ref for DATA blob in duplicate_state func (Xaver Hugl)
v5:
- Add function signature for init (Sebastian)
- Fix kernel-doc
v4:
- Create helper function for creating 3x4 CTM colorop
- Fix CTM indexes in comment (Pekka)
drivers/gpu/drm/drm_atomic.c | 3 ++ drivers/gpu/drm/drm_atomic_uapi.c | 30 ++++++++++++++++++++ drivers/gpu/drm/drm_colorop.c | 47 +++++++++++++++++++++++++++++++ include/drm/drm_colorop.h | 24 ++++++++++++++++ include/uapi/drm/amdgpu_drm.h | 9 ------ include/uapi/drm/drm_mode.h | 32 ++++++++++++++++++++- 6 files changed, 135 insertions(+), 10 deletions(-)
drivers/gpu/drm/drm_atomic.c +3 -0
@@ -793,6 +793,9 @@ static void drm_atomic_colorop_print_state(struct drm_printer *p,drm_printf (p,"\tcurve_1d_type=%s\n" ,drm_get_colorop_curve_1d_type_name (state->curve_1d_type));break ; +case DRM_COLOROP_CTM_3X4 : +drm_printf (p,"\tdata blob id=%d\n" , state->data ? state->data->base.id :0 ); +break ;default :break ; }
drivers/gpu/drm/drm_atomic_uapi.c +30 -0
@@ -687,6 +687,31 @@ drm_atomic_plane_get_property(struct drm_plane *plane,return 0 ; } +static int drm_atomic_color_set_data_property (struct drm_colorop *colorop, +struct drm_colorop_state *state, +struct drm_property *property, +uint64_t val) +{ +ssize_t elem_size =-1 ; +ssize_t size =-1 ; +bool replaced = false; + +switch (colorop->type) { +case DRM_COLOROP_CTM_3X4 : + size =sizeof (struct drm_color_ctm_3x4 ); +break ; +default : +/* should never get here */ +return -EINVAL ; + } + +return drm_property_replace_blob_from_id (colorop->dev, + &state->data, + val, + size, + elem_size, + &replaced); +} static int drm_atomic_colorop_set_property(struct drm_colorop *colorop, struct drm_colorop_state *state, struct drm_file *file_priv,
@@ -696,6 +721,9 @@ static int drm_atomic_colorop_set_property(struct drm_colorop *colorop, state->bypass = val; }else if (property == colorop->curve_1d_type_property) { state->curve_1d_type = val; + }else if (property == colorop->data_property) { +return drm_atomic_color_set_data_property (colorop, state, + property, val); }else { drm_dbg_atomic(colorop->dev, "[COLOROP:%d:%d] unknown property [PROP:%d:%s]]\n",
@@ -718,6 +746,8 @@ drm_atomic_colorop_get_property(struct drm_colorop *colorop, *val = state->bypass; }else if (property == colorop->curve_1d_type_property) { *val = state->curve_1d_type; + }else if (property == colorop->data_property) { + *val = (state->data) ? state->data->base.id :0 ; }else {return -EINVAL ; }
drivers/gpu/drm/drm_colorop.c +47 -0
76 lines not on this page · raw message
include/drm/drm_colorop.h +24 -0
@@ -99,6 +99,17 @@ struct drm_colorop_state {*/ enum drm_colorop_curve_1d_type curve_1d_type; +/** +* @data: +* +* Data blob for any TYPE that requires such a blob. The +* interpretation of the blob is TYPE-specific. +* +* See the &drm_colorop_type documentation for how blob is laid +* out. +*/ +struct drm_property_blob *data; +/** @state: backpointer to global drm_atomic_state */ struct drm_atomic_state *state; };
@@ -208,6 +219,17 @@ struct drm_colorop {*/ struct drm_property *curve_1d_type_property; +/** +* @data_property: +* +* blob property for any TYPE that requires a blob of data, +* such as 1DLUT, CTM, 3DLUT, etc. +* +* The way this blob is interpreted depends on the TYPE of +* this +*/ +struct drm_property *data_property; +/** * @next_property: *
@@ -243,6 +265,8 @@ void drm_colorop_pipeline_destroy(struct drm_device *dev);int drm_plane_colorop_curve_1d_init (struct drm_device *dev,struct drm_colorop *colorop,struct drm_plane *plane,u64 supported_tfs); +int drm_plane_colorop_ctm_3x4_init (struct drm_device *dev,struct drm_colorop *colorop, +struct drm_plane *plane);struct drm_colorop_state *drm_atomic_helper_colorop_duplicate_state (struct drm_colorop *colorop);
include/uapi/drm/amdgpu_drm.h +0 -9
@@ -1619,15 +1619,6 @@ struct drm_amdgpu_info_uq_metadata {#define AMDGPU_FAMILY_GC_11_5_0 150/* GC 11.5.0 */ #define AMDGPU_FAMILY_GC_12_0_0 152/* GC 12.0.0 */ -/* FIXME wrong namespace! */ -struct drm_color_ctm_3x4 { -/* -* Conversion matrix with 3x4 dimensions in S31.32 sign-magnitude -* (not two's complement!) format. -*/ -__u64 matrix[12 ]; -}; -#if defined(__cplusplus) }#endif
include/uapi/drm/drm_mode.h +31 -1
@@ -847,6 +847,20 @@ struct drm_color_ctm {__u64 matrix[9 ]; }; +struct drm_color_ctm_3x4 { +/* +* Conversion matrix with 3x4 dimensions in S31.32 sign-magnitude +* (not two's complement!) format. +* +* out matrix in +* |R| |0 1 2 3 | | R | +* |G| = |4 5 6 7 | x | G | +* |B| |8 9 10 11| | B | +* |1.0| +*/ +__u64 matrix[12 ]; +}; +struct drm_color_lut {/* * Values are mapped linearly to 0.0 - 1.0 range, with 0x0 == 0.0 and
@@ -874,7 +888,23 @@ enum drm_colorop_type {* A 1D curve that is being applied to all color channels. The * curve is specified via the CURVE_1D_TYPE colorop property. */ - DRM_COLOROP_1D_CURVE +DRM_COLOROP_1D_CURVE , + +/** +* @DRM_COLOROP_CTM_3X4: +* +* enum string "3x4 Matrix" +* +* A 3x4 matrix. Its values are specified via the +* &drm_color_ctm_3x4 struct provided via the DATA property. +* +* The DATA blob is a float[12]: +* out matrix in +* | R | | 0 1 2 3 | | R | +* | G | = | 4 5 6 7 | x | G | +* | B | | 8 9 10 12 | | B | +*/ + DRM_COLOROP_CTM_3X4, };/**
Signature · 1 line
2.43.0
PATCH v11 17/47 drm/vkms: Use s32 for internal color pipeline precision
In reply to Alex HungFrom: Harry Wentland <[email protected]>
Certain operations require us to preserve values below 0.0 and above 1.0 (0x0 and 0xffff respectively in 16 bpc unorm). One such operation is a BT709 encoding operation followed by its decoding operation, or the reverse.
We'll use s32 values as intermediate in and outputs of our color operations, for the operations where it matters.
For now this won't apply to LUT operations. We might want to update those to work on s32 as well, but it's unclear how that should work for unorm LUT definitions. We'll revisit that once we add LUT + CTM tests.
In order to allow for this we'll also invert the nesting of our colorop processing loops. We now use the pixel iteration loop on the outside and the colorop iteration on the inside.
---
v7:
- Fix checkpatch warnings
- Add a commit messages
- Fix code styles by adding and removing spaces (new lines, tabs and so on)
v6:
- use clamp_val instead of manual clamping (Louis Chauvet)
v4:
- Clarify that we're packing 16-bit UNORM into s32, not converting values to a different representation (Pekka)
v3:
- Use new colorop->next pointer
drivers/gpu/drm/vkms/vkms_composer.c | 27 +++++++++++++++++++++++++-- drivers/gpu/drm/vkms/vkms_drv.h | 4 ++++ 2 files changed, 29 insertions(+), 2 deletions(-)
drivers/gpu/drm/vkms/vkms_composer.c +25 -2
@@ -128,7 +128,7 @@ static void apply_lut(const struct vkms_crtc_state *crtc_state, struct line_buff } } -static void apply_colorop (struct pixel_argb_u16 *pixel,struct drm_colorop *colorop) +static void apply_colorop (struct pixel_argb_s32 *pixel,struct drm_colorop *colorop) {struct drm_colorop_state *colorop_state = colorop->state;struct drm_device *dev = colorop->dev;
@@ -157,9 +157,26 @@ static void apply_colorop(struct pixel_argb_u16 *pixel, struct drm_colorop *colostatic void pre_blend_color_transform (const struct vkms_plane_state *plane_state,struct line_buffer *output_buffer) { +struct pixel_argb_s32 pixel; +for (size_t x =0 ; x < output_buffer->n_pixels; x++) {struct drm_colorop *colorop = plane_state->base.base.color_pipeline; +/* +* Some operations, such as applying a BT709 encoding matrix, +* followed by a decoding matrix, require that we preserve +* values above 1.0 and below 0.0 until the end of the pipeline. +* +* Pack the 16-bit UNORM values into s32 to give us head-room to +* avoid clipping until we're at the end of the pipeline. Clip +* intentionally at the end of the pipeline before packing +* UNORM values back into u16. +*/ + pixel.a = output_buffer->pixels[x].a; + pixel.r = output_buffer->pixels[x].r; + pixel.g = output_buffer->pixels[x].g; + pixel.b = output_buffer->pixels[x].b; +while (colorop) {struct drm_colorop_state *colorop_state;
@@ -169,10 +186,16 @@ static void pre_blend_color_transform(const struct vkms_plane_state *plane_statereturn ;if (!colorop_state->bypass) -apply_colorop (&output_buffer->pixels[x], colorop); +apply_colorop (&pixel, colorop); colorop = colorop->next; } + +/* clamp values */ + output_buffer->pixels[x].a =clamp_val (pixel.a,0 ,0xffff ); + output_buffer->pixels[x].r =clamp_val (pixel.r,0 ,0xffff ); + output_buffer->pixels[x].g =clamp_val (pixel.g,0 ,0xffff ); + output_buffer->pixels[x].b =clamp_val (pixel.b,0 ,0xffff ); } }
drivers/gpu/drm/vkms/vkms_drv.h +4 -0
@@ -45,6 +45,10 @@ struct vkms_frame_info {unsigned int rotation; }; +struct pixel_argb_s32 { +s32 a, r, g, b; +}; +/** * struct pixel_argb_u16 - Internal representation of a pixel color. * @a: Alpha component value, stored in 16 bits, without padding, using
Signature · 1 line
2.43.0
Re: [PATCH V11 17/47] drm/vkms: Use s32 for internal color pipeline precision
Quoted 10 lines · On Thu, 14 Aug 2025 21:50:06 -0600 Alex Hung <[email protected]> wrote:
From: Harry Wentland <[email protected]>
Certain operations require us to preserve values below 0.0 and above 1.0 (
0x0and0xffffrespectively in 16 bpc unorm). One such operation is a BT709 encoding operation followed by its decoding operation, or the reverse.We'll use s32 values as intermediate in and outputs of our color operations, for the operations where it matters.
Quoted 8 lines
For now this won't apply to LUT operations. We might want to update those to work on s32 as well, but it's unclear how that should work for unorm LUT definitions. We'll revisit that once we add LUT + CTM tests.
In order to allow for this we'll also invert the nesting of our colorop processing loops. We now use the pixel iteration loop on the outside and the colorop iteration on the inside.
Hi Alex,
is this an out-dated paragraph in the commit message?
I don't see the patch inverting the nesting of loops.
That statement worried me, because changing the loop structures has tanked the performance before.
Thanks,
pq
Quoted 98 lines
Reviewed-by Louis Chauvet <[email protected]>Signed-off-by Alex Hung <[email protected]>Signed-off-by Harry Wentland <[email protected]>Reviewed-by Daniel Stone <[email protected]>---
v7:
- Fix checkpatch warnings
- Add a commit messages
- Fix code styles by adding and removing spaces (new lines, tabs and so on)v6:
- useclamp_valinstead of manual clamping (Louis Chauvet)v4:
- Clarify that we're packing 16-bit UNORM into s32, not converting values to a different representation (Pekka)v3:
- Use newcolorop->nextpointerdrivers/gpu/drm/vkms/vkms_composer.c | 27 +++++++++++++++++++++++++-- drivers/gpu/drm/vkms/vkms_drv.h | 4 ++++ 2 files changed, 29 insertions(+), 2 deletions(-)drivers/gpu/drm/vkms/vkms_composer.c +25
-2@@ -128,7 +128,7 @@ static void apply_lut(const struct vkms_crtc_state *crtc_state, struct line_buff } } -static void apply_colorop (struct pixel_argb_u16 *pixel,struct drm_colorop *colorop) +static void apply_colorop (struct pixel_argb_s32 *pixel,struct drm_colorop *colorop) {struct drm_colorop_state *colorop_state = colorop->state;struct drm_device *dev = colorop->dev;@@ -157,9 +157,26 @@ static void apply_colorop(struct pixel_argb_u16 *pixel, struct drm_colorop *colostatic void pre_blend_color_transform (const struct vkms_plane_state *plane_state,struct line_buffer *output_buffer) { +struct pixel_argb_s32 pixel; +for (size_t x =0 ; x < output_buffer->n_pixels; x++) {struct drm_colorop *colorop = plane_state->base.base.color_pipeline; +/* +* Some operations, such as applying a BT709 encoding matrix, +* followed by a decoding matrix, require that we preserve +* values above 1.0 and below 0.0 until the end of the pipeline. +* +* Pack the 16-bit UNORM values into s32 to give us head-room to +* avoid clipping until we're at the end of the pipeline. Clip +* intentionally at the end of the pipeline before packing +* UNORM values back into u16. +*/ + pixel.a = output_buffer->pixels[x].a; + pixel.r = output_buffer->pixels[x].r; + pixel.g = output_buffer->pixels[x].g; + pixel.b = output_buffer->pixels[x].b; +while (colorop) {struct drm_colorop_state *colorop_state;@@ -169,10 +186,16 @@ static void pre_blend_color_transform(const struct vkms_plane_state *plane_statereturn ;if (!colorop_state->bypass) -apply_colorop (&output_buffer->pixels[x], colorop); +apply_colorop (&pixel, colorop); colorop = colorop->next; } + +/* clamp values */ + output_buffer->pixels[x].a =clamp_val (pixel.a,0 ,0xffff ); + output_buffer->pixels[x].r =clamp_val (pixel.r,0 ,0xffff ); + output_buffer->pixels[x].g =clamp_val (pixel.g,0 ,0xffff ); + output_buffer->pixels[x].b =clamp_val (pixel.b,0 ,0xffff ); } }drivers/gpu/drm/vkms/vkms_drv.h +4
-0@@ -45,6 +45,10 @@ struct vkms_frame_info {unsigned int rotation; }; +struct pixel_argb_s32 { +s32 a, r, g, b; +}; +/** * struct pixel_argb_u16 - Internal representation of a pixel color. * @a: Alpha component value, stored in 16 bits, without padding, using
Harry Wentland
maintainerRe: [PATCH V11 17/47] drm/vkms: Use s32 for internal color pipeline precision
Quoted 22 lines · Pekka Paalanen
Quoted 10 lines · On Thu, 14 Aug 2025 21:50:06 -0600 Alex Hung <[email protected]> wrote:
From: Harry Wentland <[email protected]>
Certain operations require us to preserve values below 0.0 and above 1.0 (
0x0and0xffffrespectively in 16 bpc unorm). One such operation is a BT709 encoding operation followed by its decoding operation, or the reverse.We'll use s32 values as intermediate in and outputs of our color operations, for the operations where it matters.
Quoted 8 lines
For now this won't apply to LUT operations. We might want to update those to work on s32 as well, but it's unclear how that should work for unorm LUT definitions. We'll revisit that once we add LUT + CTM tests.
In order to allow for this we'll also invert the nesting of our colorop processing loops. We now use the pixel iteration loop on the outside and the colorop iteration on the inside.
Quoted 9 lines
Hi Alex,
is this an out-dated paragraph in the commit message?
I don't see the patch inverting the nesting of loops.
That statement worried me, because changing the loop structures has tanked the performance before.
I think this is an outdated message. I changed this in an earlier version a long time ago, after we had a discussion on loop structure and performance.
Harry
Quoted 103 lines
Thanks,
pqQuoted 98 lines
Reviewed-by Louis Chauvet <[email protected]>Signed-off-by Alex Hung <[email protected]>Signed-off-by Harry Wentland <[email protected]>Reviewed-by Daniel Stone <[email protected]>---
v7:
- Fix checkpatch warnings
- Add a commit messages
- Fix code styles by adding and removing spaces (new lines, tabs and so on)v6:
- useclamp_valinstead of manual clamping (Louis Chauvet)v4:
- Clarify that we're packing 16-bit UNORM into s32, not converting values to a different representation (Pekka)v3:
- Use newcolorop->nextpointerdrivers/gpu/drm/vkms/vkms_composer.c | 27 +++++++++++++++++++++++++-- drivers/gpu/drm/vkms/vkms_drv.h | 4 ++++ 2 files changed, 29 insertions(+), 2 deletions(-)drivers/gpu/drm/vkms/vkms_composer.c +25
-2@@ -128,7 +128,7 @@ static void apply_lut(const struct vkms_crtc_state *crtc_state, struct line_buff } } -static void apply_colorop (struct pixel_argb_u16 *pixel,struct drm_colorop *colorop) +static void apply_colorop (struct pixel_argb_s32 *pixel,struct drm_colorop *colorop) {struct drm_colorop_state *colorop_state = colorop->state;struct drm_device *dev = colorop->dev;@@ -157,9 +157,26 @@ static void apply_colorop(struct pixel_argb_u16 *pixel, struct drm_colorop *colostatic void pre_blend_color_transform (const struct vkms_plane_state *plane_state,struct line_buffer *output_buffer) { +struct pixel_argb_s32 pixel; +for (size_t x =0 ; x < output_buffer->n_pixels; x++) {struct drm_colorop *colorop = plane_state->base.base.color_pipeline; +/* +* Some operations, such as applying a BT709 encoding matrix, +* followed by a decoding matrix, require that we preserve +* values above 1.0 and below 0.0 until the end of the pipeline. +* +* Pack the 16-bit UNORM values into s32 to give us head-room to +* avoid clipping until we're at the end of the pipeline. Clip +* intentionally at the end of the pipeline before packing +* UNORM values back into u16. +*/ + pixel.a = output_buffer->pixels[x].a; + pixel.r = output_buffer->pixels[x].r; + pixel.g = output_buffer->pixels[x].g; + pixel.b = output_buffer->pixels[x].b; +while (colorop) {struct drm_colorop_state *colorop_state;@@ -169,10 +186,16 @@ static void pre_blend_color_transform(const struct vkms_plane_state *plane_statereturn ;if (!colorop_state->bypass) -apply_colorop (&output_buffer->pixels[x], colorop); +apply_colorop (&pixel, colorop); colorop = colorop->next; } + +/* clamp values */ + output_buffer->pixels[x].a =clamp_val (pixel.a,0 ,0xffff ); + output_buffer->pixels[x].r =clamp_val (pixel.r,0 ,0xffff ); + output_buffer->pixels[x].g =clamp_val (pixel.g,0 ,0xffff ); + output_buffer->pixels[x].b =clamp_val (pixel.b,0 ,0xffff ); } }drivers/gpu/drm/vkms/vkms_drv.h +4
-0@@ -45,6 +45,10 @@ struct vkms_frame_info {unsigned int rotation; }; +struct pixel_argb_s32 { +s32 a, r, g, b; +}; +/** * struct pixel_argb_u16 - Internal representation of a pixel color. * @a: Alpha component value, stored in 16 bits, without padding, using
PATCH v11 18/47 drm/vkms: add 3x4 matrix in color pipeline
In reply to Alex HungFrom: Harry Wentland <[email protected]>
We add two 3x4 matrices into the VKMS color pipeline. The reason we're adding matrices is so that we can test that application of a matrix and its inverse yields an output equal to the input image.
One complication with the matrix implementation has to do with the fact that the matrix entries are in signed-magnitude fixed point, whereas the drm_fixed.h implementation uses 2s-complement. The latter one is the one that we want for easy addition and subtraction, so we convert all entries to 2s-complement.
---
v11:
- Fix comments to "2nd op 3x4 matrix" (Nícolas Prado)
v9:
- Update function names by _plane_ (Chaitanya Kumar Borah)
v8:
- Replace DRM_ERROR with drm_err (Louis Chauvet)
v7:
- Fix checkpatch warnings
- Change kzalloc(sizeof(struct drm_colorop) ...) to kzalloc(sizeof(*ops[i]) ...)
- Change i-1to i - 1
- Add a new line at EOF
v6:
- pre-compute colors (Louis Chauvet)
- round matrix output (Louis Chauvet)
drivers/gpu/drm/vkms/vkms_colorop.c | 36 ++++++++++++++++++++++++++-- drivers/gpu/drm/vkms/vkms_composer.c | 33 +++++++++++++++++++++++++ 2 files changed, 67 insertions(+), 2 deletions(-)
drivers/gpu/drm/vkms/vkms_colorop.c +34 -2
@@ -12,7 +12,7 @@ static const u64 supported_tfs =BIT (DRM_COLOROP_1D_CURVE_SRGB_EOTF ) |BIT (DRM_COLOROP_1D_CURVE_SRGB_INV_EOTF ); -#define MAX_COLOR_PIPELINE_OPS 2 +#define MAX_COLOR_PIPELINE_OPS 4static int vkms_initialize_color_pipeline (struct drm_plane *plane,struct drm_prop_enum_list *list) {
@@ -40,7 +40,39 @@ static int vkms_initialize_color_pipeline(struct drm_plane *plane, struct drm_pr i++; -/* 2nd op: 1d curve */ +/* 2nd op: 3x4 matrix */ + ops[i] =kzalloc (sizeof (*ops[i]),GFP_KERNEL ); +if (!ops[i]) { +drm_err (dev,"KMS: Failed to allocate colorop\n" ); + ret = -ENOMEM ; + goto cleanup; + } + + ret =drm_plane_colorop_ctm_3x4_init (dev, ops[i], plane); +if (ret) + goto cleanup; + +drm_colorop_set_next_property (ops[i -1 ], ops[i]); + + i++; + +/* 3rd op: 3x4 matrix */ + ops[i] =kzalloc (sizeof (*ops[i]),GFP_KERNEL ); +if (!ops[i]) { +drm_err (dev,"KMS: Failed to allocate colorop\n" ); + ret = -ENOMEM ; + goto cleanup; + } + + ret =drm_plane_colorop_ctm_3x4_init (dev, ops[i], plane); +if (ret) + goto cleanup; + +drm_colorop_set_next_property (ops[i -1 ], ops[i]); + + i++; + +/* 4th op: 1d curve */ ops[i] =kzalloc (sizeof (*ops[i]),GFP_KERNEL );if (!ops[i]) {drm_err (dev,"KMS: Failed to allocate colorop\n" );
drivers/gpu/drm/vkms/vkms_composer.c +33 -0
@@ -128,6 +128,35 @@ static void apply_lut(const struct vkms_crtc_state *crtc_state, struct line_buff } } +static void apply_3x4_matrix (struct pixel_argb_s32 *pixel,const struct drm_color_ctm_3x4 *matrix) +{ +s64 rf, gf, bf; +s64 r, g, b; + + r =drm_int2fixp (pixel->r); + g =drm_int2fixp (pixel->g); + b =drm_int2fixp (pixel->b); + + rf =drm_fixp_mul (drm_sm2fixp (matrix->matrix[0 ]), r) + +drm_fixp_mul (drm_sm2fixp (matrix->matrix[1 ]), g) + +drm_fixp_mul (drm_sm2fixp (matrix->matrix[2 ]), b) + +drm_sm2fixp (matrix->matrix[3 ]); + + gf =drm_fixp_mul (drm_sm2fixp (matrix->matrix[4 ]), r) + +drm_fixp_mul (drm_sm2fixp (matrix->matrix[5 ]), g) + +drm_fixp_mul (drm_sm2fixp (matrix->matrix[6 ]), b) + +drm_sm2fixp (matrix->matrix[7 ]); + + bf =drm_fixp_mul (drm_sm2fixp (matrix->matrix[8 ]), r) + +drm_fixp_mul (drm_sm2fixp (matrix->matrix[9 ]), g) + +drm_fixp_mul (drm_sm2fixp (matrix->matrix[10 ]), b) + +drm_sm2fixp (matrix->matrix[11 ]); + + pixel->r =drm_fixp2int_round (rf); + pixel->g =drm_fixp2int_round (gf); + pixel->b =drm_fixp2int_round (bf); +} +static void apply_colorop (struct pixel_argb_s32 *pixel,struct drm_colorop *colorop) {struct drm_colorop_state *colorop_state = colorop->state;
@@ -151,6 +180,10 @@ static void apply_colorop(struct pixel_argb_s32 *pixel, struct drm_colorop *colo colorop_state->curve_1d_type);break ; } + }else if (colorop->type ==DRM_COLOROP_CTM_3X4 ) { +if (colorop_state->data) +apply_3x4_matrix (pixel, + (struct drm_color_ctm_3x4 *) colorop_state->data->data); } }
Signature · 1 line
2.43.0
PATCH v11 19/47 drm/tests: Add a few tests around drm_fixed.h
In reply to Alex HungFrom: Harry Wentland <[email protected]>
While working on the CTM implementation of VKMS I had to ascertain myself of a few assumptions. One of those is whether drm_fixed.h treats its numbers using signed-magnitude or twos-complement. It is twos-complement.
In order to make someone else's day easier I am adding the drm_test_int2fixp test that validates the above assumption.
I am also adding a test for the new sm2fixp function that converts from a signed-magnitude fixed point to the twos-complement fixed point.
---
v11:
- Update outdated "drm_rect_test_suite" to "drm_fixp_test_suite" (Maíra Canal)
- Update outdated MODULE_LICENSE to Dual MIT/GPL (Maíra Canal)
v7:
- Fix checkpatch warnings (Louis Chauvet)
v6:
- add missing MODULE_DESCRIPTION (Jeff Johnson)
- fix buffer overflow
drivers/gpu/drm/tests/Makefile | 3 +- drivers/gpu/drm/tests/drm_fixp_test.c | 71 +++++++++++++++++++++++++++ 2 files changed, 73 insertions(+), 1 deletion(-) create mode 100644 drivers/gpu/drm/tests/drm_fixp_test.c
drivers/gpu/drm/tests/Makefile +2 -1
@@ -24,6 +24,7 @@ obj-$(CONFIG_DRM_KUNIT_TEST) += \ drm_plane_helper_test.o \ drm_probe_helper_test.o \ drm_rect_test.o \ - drm_sysfb_modeset_test.o + drm_sysfb_modeset_test.o \ + drm_fixp_test.o CFLAGS_drm_mm_test.o := $(DISABLE_STRUCTLEAK_PLUGIN)
drivers/gpu/drm/tests/drm_fixp_test.c new file +71 -0
71 lines not on this page · raw message
Signature · 1 line
2.43.0
PATCH v11 20/47 drm/vkms: Add tests for CTM handling
In reply to Alex HungFrom: Harry Wentland <[email protected]>
A whole slew of tests for CTM handling that greatly helped in debugging the CTM code. The extent of tests might seem a bit silly but they're fast and might someday help save someone else's day when debugging this.
---
v7:
- Fix a checkpatch a long-line warning (Louis Chauvet)
v6:
- update reference values since we're now rounding
v5:
- Make apply_3x4_matrix static
v4:
- Comment on origin of bt709_enc matrix (Pekka)
- Use full opaque alpha (Pekka)
- Add additional check for Y < 0xffff (Pekka)
- Remove unused code (Pekka)
drivers/gpu/drm/vkms/tests/vkms_color_test.c | 250 +++++++++++++++++++ drivers/gpu/drm/vkms/vkms_composer.c | 4 +- drivers/gpu/drm/vkms/vkms_composer.h | 1 + 3 files changed, 254 insertions(+), 1 deletion(-)
drivers/gpu/drm/vkms/tests/vkms_color_test.c +250 -0
@@ -148,11 +148,261 @@ static void vkms_color_srgb_inv_srgb(struct kunit *test) } } +#define FIXPT_HALF (DRM_FIXED_ONE >> 1) +#define FIXPT_QUARTER (DRM_FIXED_ONE >> 2) + +static const struct drm_color_ctm_3x4 test_matrix_3x4_50_desat = { { +FIXPT_HALF ,FIXPT_QUARTER ,FIXPT_QUARTER ,0 , +FIXPT_QUARTER ,FIXPT_HALF ,FIXPT_QUARTER ,0 , +FIXPT_QUARTER ,FIXPT_QUARTER ,FIXPT_HALF ,0 +} }; + +static void vkms_color_ctm_3x4_50_desat (struct kunit *test) +{ +struct pixel_argb_s32 ref, out; + +/* full white */ + ref.a =0xffff ; + ref.r =0xffff ; + ref.g =0xffff ; + ref.b =0xffff ; + +memcpy (&out, &ref,sizeof (out)); +apply_3x4_matrix (&out, &test_matrix_3x4_50_desat); + +KUNIT_EXPECT_MEMEQ (test, &ref, &out,sizeof (out)); + +/* full black */ + ref.a =0xffff ; + ref.r =0x0 ; + ref.g =0x0 ; + ref.b =0x0 ; + +memcpy (&out, &ref,sizeof (out)); +apply_3x4_matrix (&out, &test_matrix_3x4_50_desat); + +KUNIT_EXPECT_MEMEQ (test, &ref, &out,sizeof (out)); + +/* 50% grey */ + ref.a =0xffff ; + ref.r =0x8000 ; + ref.g =0x8000 ; + ref.b =0x8000 ; + +memcpy (&out, &ref,sizeof (out)); +apply_3x4_matrix (&out, &test_matrix_3x4_50_desat); + +KUNIT_EXPECT_MEMEQ (test, &ref, &out,sizeof (out)); + +/* full red to 50% desat */ + ref.a =0xffff ; + ref.r =0x8000 ; + ref.g =0x4000 ; + ref.b =0x4000 ; + + out.a =0xffff ; + out.r =0xffff ; + out.g =0x0 ; + out.b =0x0 ; + +apply_3x4_matrix (&out, &test_matrix_3x4_50_desat); + +KUNIT_EXPECT_MEMEQ (test, &ref, &out,sizeof (out)); +} + +/* +* BT.709 encoding matrix +* +* Values printed from within IGT when converting +* igt_matrix_3x4_bt709_enc to the fixed-point format expected +* by DRM/KMS. +*/ +static const struct drm_color_ctm_3x4 test_matrix_3x4_bt709_enc = { { +0x00000000366cf400ull ,0x00000000b7175900ull ,0x0000000127bb300ull ,0 , +0x800000001993b3a0ull ,0x800000005609fe80ull ,0x000000006f9db200ull ,0 , +0x000000009d70a400ull ,0x800000008f011100ull ,0x800000000e6f9330ull ,0 +} }; + +static void vkms_color_ctm_3x4_bt709 (struct kunit *test) +{ +struct pixel_argb_s32 out; + +/* full white to bt709 */ + out.a =0xffff ; + out.r =0xffff ; + out.g =0xffff ; + out.b =0xffff ; + +apply_3x4_matrix (&out, &test_matrix_3x4_bt709_enc); + +/* Y 255 */ +KUNIT_EXPECT_GT (test, out.r,0xfe00 ); +KUNIT_EXPECT_LT (test, out.r,0x10000 ); + +/* U 0 */ +KUNIT_EXPECT_LT (test, out.g,0x0100 ); + +/* V 0 */ +KUNIT_EXPECT_LT (test, out.b,0x0100 ); + +/* full black to bt709 */ + out.a =0xffff ; + out.r =0x0 ; + out.g =0x0 ; + out.b =0x0 ; + +apply_3x4_matrix (&out, &test_matrix_3x4_bt709_enc); + +/* Y 0 */ +KUNIT_EXPECT_LT (test, out.r,0x100 ); + +/* U 0 */ +KUNIT_EXPECT_LT (test, out.g,0x0100 ); + +/* V 0 */ +KUNIT_EXPECT_LT (test, out.b,0x0100 ); + +/* gray to bt709 */ + out.a =0xffff ; + out.r =0x7fff ; + out.g =0x7fff ; + out.b =0x7fff ; + +apply_3x4_matrix (&out, &test_matrix_3x4_bt709_enc); + +/* Y 127 */ +KUNIT_EXPECT_GT (test, out.r,0x7e00 ); +KUNIT_EXPECT_LT (test, out.r,0x8000 ); + +/* U 0 */ +KUNIT_EXPECT_LT (test, out.g,0x0100 ); + +/* V 0 */ +KUNIT_EXPECT_LT (test, out.b,0x0100 ); + +/* == red 255 - bt709 enc == */ + out.a =0xffff ; + out.r =0xffff ; + out.g =0x0 ; + out.b =0x0 ; + +apply_3x4_matrix (&out, &test_matrix_3x4_bt709_enc); + +/* Y 54 */ +KUNIT_EXPECT_GT (test, out.r,0x3500 ); +KUNIT_EXPECT_LT (test, out.r,0x3700 ); + +/* U 0 */ +KUNIT_EXPECT_LT (test, out.g,0x0100 ); + +/* V 157 */ +KUNIT_EXPECT_GT (test, out.b,0x9C00 ); +KUNIT_EXPECT_LT (test, out.b,0x9E00 ); + + +/* == green 255 - bt709 enc == */ + out.a =0xffff ; + out.r =0x0 ; + out.g =0xffff ; + out.b =0x0 ; + +apply_3x4_matrix (&out, &test_matrix_3x4_bt709_enc); + +/* Y 182 */ +KUNIT_EXPECT_GT (test, out.r,0xB500 ); +KUNIT_EXPECT_LT (test, out.r,0xB780 );/* laxed by half*/ + +/* U 0 */ +KUNIT_EXPECT_LT (test, out.g,0x0100 ); + +/* V 0 */ +KUNIT_EXPECT_LT (test, out.b,0x0100 ); + +/* == blue 255 - bt709 enc == */ + out.a =0xffff ; + out.r =0x0 ; + out.g =0x0 ; + out.b =0xffff ; + +apply_3x4_matrix (&out, &test_matrix_3x4_bt709_enc); + +/* Y 18 */ +KUNIT_EXPECT_GT (test, out.r,0x1100 ); +KUNIT_EXPECT_LT (test, out.r,0x1300 ); + +/* U 111 */ +KUNIT_EXPECT_GT (test, out.g,0x6E00 ); +KUNIT_EXPECT_LT (test, out.g,0x7000 ); + +/* V 0 */ +KUNIT_EXPECT_LT (test, out.b,0x0100 ); + +/* == red 140 - bt709 enc == */ + out.a =0xffff ; + out.r =0x8c8c ; + out.g =0x0 ; + out.b =0x0 ; + +apply_3x4_matrix (&out, &test_matrix_3x4_bt709_enc); + +/* Y 30 */ +KUNIT_EXPECT_GT (test, out.r,0x1D00 ); +KUNIT_EXPECT_LT (test, out.r,0x1F00 ); + +/* U 0 */ +KUNIT_EXPECT_LT (test, out.g,0x100 ); + +/* V 87 */ +KUNIT_EXPECT_GT (test, out.b,0x5600 ); +KUNIT_EXPECT_LT (test, out.b,0x5800 ); + +/* == green 140 - bt709 enc == */ + out.a =0xffff ; + out.r =0x0 ; + out.g =0x8c8c ; + out.b =0x0 ; + +apply_3x4_matrix (&out, &test_matrix_3x4_bt709_enc); + +/* Y 30 */ +KUNIT_EXPECT_GT (test, out.r,0x6400 ); +KUNIT_EXPECT_LT (test, out.r,0x6600 ); + +/* U 0 */ +KUNIT_EXPECT_LT (test, out.g,0x100 ); + +/* V 0 */ +KUNIT_EXPECT_LT (test, out.b,0x100 ); + + +/* == blue 140 - bt709 enc == */ + out.a =0xffff ; + out.r =0x0 ; + out.g =0x0 ; + out.b =0x8c8c ; + +apply_3x4_matrix (&out, &test_matrix_3x4_bt709_enc); + +/* Y 30 */ +KUNIT_EXPECT_GT (test, out.r,0x900 ); +KUNIT_EXPECT_LT (test, out.r,0xB00 ); + +/* U 61 */ +KUNIT_EXPECT_GT (test, out.g,0x3C00 ); +KUNIT_EXPECT_LT (test, out.g,0x3E00 ); + +/* V 0 */ +KUNIT_EXPECT_LT (test, out.b,0x100 ); + +} +static struct kunit_case vkms_color_test_cases[] = {KUNIT_CASE (vkms_color_test_get_lut_index),KUNIT_CASE (vkms_color_test_lerp),KUNIT_CASE (vkms_color_test_linear),KUNIT_CASE (vkms_color_srgb_inv_srgb), +KUNIT_CASE (vkms_color_ctm_3x4_50_desat), +KUNIT_CASE (vkms_color_ctm_3x4_bt709), {} };
drivers/gpu/drm/vkms/vkms_composer.c +3 -1
@@ -128,7 +128,8 @@ static void apply_lut(const struct vkms_crtc_state *crtc_state, struct line_buff } } -static void apply_3x4_matrix (struct pixel_argb_s32 *pixel,const struct drm_color_ctm_3x4 *matrix) +VISIBLE_IF_KUNIT void apply_3x4_matrix(struct pixel_argb_s32 *pixel, +const struct drm_color_ctm_3x4 *matrix) {s64 rf, gf, bf;s64 r, g, b;
@@ -156,6 +157,7 @@ static void apply_3x4_matrix(struct pixel_argb_s32 *pixel, const struct drm_colo pixel->g =drm_fixp2int_round (gf); pixel->b =drm_fixp2int_round (bf); } +EXPORT_SYMBOL_IF_KUNIT (apply_3x4_matrix);static void apply_colorop (struct pixel_argb_s32 *pixel,struct drm_colorop *colorop) {
drivers/gpu/drm/vkms/vkms_composer.h +1 -0
@@ -21,6 +21,7 @@ u16 lerp_u16(u16 a, u16 b, s64 t);s64 get_lut_index (const struct vkms_color_lut *lut,u16 channel_value);u16 apply_lut_to_channel_value (const struct vkms_color_lut *lut,u16 channel_value,enum lut_channel channel); +void apply_3x4_matrix (struct pixel_argb_s32 *pixel,const struct drm_color_ctm_3x4 *matrix);#endif #endif /* _VKMS_COMPOSER_H_ */
Signature · 1 line
2.43.0
PATCH v11 21/47 drm/colorop: pass plane_color_pipeline client cap to atomic check
In reply to Alex HungFrom: Harry Wentland <[email protected]>
Drivers will need to know whether an atomic check/commit originated from a client with DRM_CLIENT_CAP_PLANE_COLOR_PIPELINE so they can ignore deprecated properties, like COLOR_ENCODING and COLOR_RANGE.
Pass the plane_color_pipeline bit to drm_atomic_state.
---
v5:
- Fix kernel docs
drivers/gpu/drm/drm_atomic_uapi.c | 1 + include/drm/drm_atomic.h | 18 ++++++++++++++++++ 2 files changed, 19 insertions(+)
drivers/gpu/drm/drm_atomic_uapi.c +1 -0
@@ -1582,6 +1582,7 @@ int drm_mode_atomic_ioctl(struct drm_device *dev,drm_modeset_acquire_init (&ctx,DRM_MODESET_ACQUIRE_INTERRUPTIBLE ); state->acquire_ctx = &ctx; state->allow_modeset = !!(arg->flags &DRM_MODE_ATOMIC_ALLOW_MODESET ); + state->plane_color_pipeline = file_priv->plane_color_pipeline; retry: copied_objs =0 ;
include/drm/drm_atomic.h +18 -0
@@ -464,6 +464,24 @@ struct drm_atomic_state {*/ bool duplicated : 1; +/** +* @plane_color_pipeline: +* +* Indicates whether this atomic state originated with a client that +* set the DRM_CLIENT_CAP_PLANE_COLOR_PIPELINE. +* +* Drivers and helper functions should use this to ignore legacy +* properties that are incompatible with the drm_plane COLOR_PIPELINE +* behavior, such as: +* +* - COLOR_RANGE +* - COLOR_ENCODING +* +* or any other driver-specific properties that might affect pixel +* values. +*/ + bool plane_color_pipeline : 1; +/** * @colorops: *
Signature · 1 line
2.43.0
PATCH v11 22/47 drm/colorop: define a new macro for_each_new_colorop_in_state
In reply to Alex HungCreate a new macro for_each_new_colorop_in_state to access new drm_colorop_state updated from uapi.
---
v10:
- remove duplicated "is useful" in comments
include/drm/drm_atomic.h | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+)
include/drm/drm_atomic.h +20 -0
@@ -1069,6 +1069,26 @@ void drm_state_dump(struct drm_device *dev, struct drm_printer *p); (new_colorop_state) = (__state)->colorops[__i].new_state, 1)) +/** +* for_each_new_colorop_in_state - iterate over all colorops in an atomic update +* @__state: &struct drm_atomic_state pointer +* @colorop: &struct drm_colorop iteration cursor +* @new_colorop_state: &struct drm_colorop_state iteration cursor for the new state +* @__i: int iteration cursor, for macro-internal use +* +* This iterates over all colorops in an atomic update, tracking new state. This is +* useful in places where the state delta needs to be considered, for example in +* atomic check functions. +*/ +#define for_each_new_colorop_in_state(__state, colorop, 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 */, \ + (new_colorop_state) = (__state)->colorops[__i].new_state, 1)) +/** * for_each_oldnew_plane_in_state - iterate over all planes in an atomic update * @__state: &struct drm_atomic_state pointer
Signature · 1 line
2.43.0
PATCH v11 23/47 drm/amd/display: Ignore deprecated props when plane_color_pipeline set
In reply to Alex HungFrom: Harry Wentland <[email protected]>
When the plane_color_pipeline bit is set we should ignore deprecated properties, such as COLOR_RANGE and COLOR_ENCODING.
--- drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c | 4 ++++ 1 file changed, 4 insertions(+)
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c +4 -0
@@ -5718,6 +5718,10 @@ fill_plane_color_attributes(const struct drm_plane_state *plane_state, *color_space =COLOR_SPACE_SRGB ; +/* Ignore properties when DRM_CLIENT_CAP_PLANE_COLOR_PIPELINE is set */ +if (plane_state->state && plane_state->state->plane_color_pipeline) +return 0 ; +/* DRM color properties only affect non-RGB formats. */ if (format <SURFACE_PIXEL_FORMAT_VIDEO_BEGIN )return 0 ;
Signature · 1 line
2.43.0
PATCH v11 24/47 drm/amd/display: Add bypass COLOR PIPELINE
In reply to Alex HungFrom: Harry Wentland <[email protected]>
Add the default Bypass pipeline and ensure it passes the kms_colorop test plane-XR30-XR30-bypass.
---
v10:
- guard "dm_plane_init_colorops" function when !AMD_PRIVATE_COLOR (Melissa Wen)
.../amd/display/amdgpu_dm/amdgpu_dm_plane.c | 20 +++++++++++++++++++ 1 file changed, 20 insertions(+)
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_plane.c +20 -0
@@ -1782,6 +1782,21 @@ dm_atomic_plane_get_property(struct drm_plane *plane,return 0 ; } +#else + +#define MAX_COLOR_PIPELINES 5 + +static int +dm_plane_init_colorops (struct drm_plane *plane) +{ +struct drm_prop_enum_list pipelines[MAX_COLOR_PIPELINES ]; +int len =0 ; + +/* Create COLOR_PIPELINE property and attach */ +drm_plane_create_color_pipeline_property (plane, pipelines, len); + +return 0 ; +}#endif static const struct drm_plane_funcs dm_plane_funcs = {
@@ -1890,7 +1905,12 @@ int amdgpu_dm_plane_init(struct amdgpu_display_manager *dm,#ifdef AMD_PRIVATE_COLOR dm_atomic_plane_attach_color_mgmt_properties (dm, plane); +#else + res =dm_plane_init_colorops (plane); +if (res) +return res;#endif +/* Create (reset) the plane state */ if (plane->funcs->reset) plane->funcs->reset (plane);
Signature · 1 line
2.43.0
PATCH v11 25/47 drm/amd/display: Skip color pipeline initialization for cursor plane
In reply to Alex Hungcursor plane does not need to have color pipeline.
---
v7:
- Add a commit messages
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_plane.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_plane.c +3 -0
@@ -1792,6 +1792,9 @@ dm_plane_init_colorops(struct drm_plane *plane)struct drm_prop_enum_list pipelines[MAX_COLOR_PIPELINES ];int len =0 ; +if (plane->type ==DRM_PLANE_TYPE_CURSOR ) +return 0 ; +/* Create COLOR_PIPELINE property and attach */ drm_plane_create_color_pipeline_property (plane, pipelines, len);
Signature · 1 line
2.43.0
PATCH v11 26/47 drm/amd/display: Add support for sRGB EOTF in DEGAM block
In reply to Alex HungExpose one 1D curve colorop with support for DRM_COLOROP_1D_CURVE_SRGB_EOTF and program HW to perform the sRGB transform when the colorop is not in bypass.
With this change the following IGT test passes:kms_colorop --run plane-XR30-XR30-srgb_eotf
The color pipeline now consists of a single colorop:
1. 1D curve colorop w/ sRGB EOTF
---
v11:
- Create color pipeline on supported hardware only (Melissa Wen)
v10:
- Replace DRM_ERROR by drm_err
- Creaet color pipeline when >= DCN_VERSION_3_0
v9:
- Update function names by _plane_ (Chaitanya Kumar Borah)
- Update replace cleanup code by drm_colorop_pipeline_destroy (Simon Ser)
v8:
- Fix incorrect && by || in __set_colorop_in_tf_1d_curve (Leo Li)
v7:
- Fix checkpatch warnings
- Change switch "{ }" position
- Delete double ";"
- Delete "{ }" for single-line if-statement
- Add a new line at EOF
- Change SPDX-License-Identifier: GPL-2.0+ from // to /* */
v6:
- cleanup if colorop alloc or init fails
.../gpu/drm/amd/display/amdgpu_dm/Makefile | 3 +- .../amd/display/amdgpu_dm/amdgpu_dm_color.c | 86 +++++++++++++++++++ .../amd/display/amdgpu_dm/amdgpu_dm_colorop.c | 71 +++++++++++++++ .../amd/display/amdgpu_dm/amdgpu_dm_colorop.h | 34 ++++++++ .../amd/display/amdgpu_dm/amdgpu_dm_plane.c | 20 ++++- 5 files changed, 211 insertions(+), 3 deletions(-) create mode 100644 drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_colorop.c create mode 100644 drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_colorop.h
drivers/gpu/drm/amd/display/amdgpu_dm/Makefile +2 -1
@@ -39,7 +39,8 @@ AMDGPUDM = \ amdgpu_dm_psr.o \ amdgpu_dm_replay.o \ amdgpu_dm_quirks.o \ - amdgpu_dm_wb.o + amdgpu_dm_wb.o \ + amdgpu_dm_colorop.o ifdef CONFIG_DRM_AMD_DC_FP AMDGPUDM += dc_fpu.o
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_color.c +86 -0
109 lines not on this page · raw message
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_colorop.c new file +71 -0
71 lines not on this page · raw message
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_colorop.h new file +34 -0
@@ -0,0 +1,34 @@ +/* SPDX-License-Identifier: MIT */ +/* +* Copyright 2023 Advanced Micro Devices, Inc. +* +* Permission is hereby granted, free of charge, to any person obtaining a +* copy of this software and associated documentation files (the "Software"), +* to deal in the Software without restriction, including without limitation +* the rights to use, copy, modify, merge, publish, distribute, sublicense, +* and/or sell copies of the Software, and to permit persons to whom the +* Software is furnished to do so, subject to the following conditions: +* +* The above copyright notice and this permission notice shall be included in +* all copies or substantial portions of the Software. +* +* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL +* THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR +* OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, +* ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR +* OTHER DEALINGS IN THE SOFTWARE. +* +* Authors: AMD +* +*/ + +#ifndef __AMDGPU_DM_COLOROP_H__ +#define __AMDGPU_DM_COLOROP_H__ + +extern const u64 amdgpu_dm_supported_degam_tfs; + +int amdgpu_dm_initialize_default_pipeline (struct drm_plane *plane,struct drm_prop_enum_list *list); + +#endif /* __AMDGPU_DM_COLOROP_H__*/
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_plane.c +18 -2
@@ -37,6 +37,7 @@#include "amdgpu_display.h" #include "amdgpu_dm_trace.h" #include "amdgpu_dm_plane.h" +#include "amdgpu_dm_colorop.h" #include "gc/gc_11_0_0_offset.h" #include "gc/gc_11_0_0_sh_mask.h"
@@ -1790,13 +1791,28 @@ static int dm_plane_init_colorops(struct drm_plane *plane) {struct drm_prop_enum_list pipelines[MAX_COLOR_PIPELINES ]; +struct drm_device *dev = plane->dev; +struct amdgpu_device *adev =drm_to_adev (dev); +struct dc *dc = adev->dm.dc;int len =0 ; +int ret;if (plane->type ==DRM_PLANE_TYPE_CURSOR )return 0 ; -/* Create COLOR_PIPELINE property and attach */ -drm_plane_create_color_pipeline_property (plane, pipelines, len); +/* initialize pipeline */ +if (dc->ctx->dce_version >=DCN_VERSION_3_0 ) { + ret =amdgpu_dm_initialize_default_pipeline (plane, &(pipelines[len])); +if (ret) { +drm_err (plane->dev,"Failed to create color pipeline for plane %d: %d\n" , + plane->base.id, ret); +return ret; + } + len++; + +/* Create COLOR_PIPELINE property and attach */ +drm_plane_create_color_pipeline_property (plane, pipelines, len); + }return 0 ; }
Signature · 1 line
2.43.0
PATCH v11 27/47 drm/amd/display: Add support for sRGB Inverse EOTF in SHAPER block
In reply to Alex HungExpose a 2nd curve colorop with support for DRM_COLOROP_1D_CURVE_SRGB_INV_EOTF and program HW to perform the sRGB Inverse EOTF on the shaper block when the colorop is not in bypass.
With this change the follow IGT tests pass:kms_colorop --run plane-XR30-XR30-srgb_inv_eotf kms_colorop --run plane-XR30-XR30-srgb_eotf-srgb_inv_eotf
The color pipeline now consists of the following colorops:
1. 1D curve colorop w/ sRGB EOTF support
2. 1D curve colorop w/ sRGB Inverse EOTF support
---
v10:
- Remove redundant DRM_ERROR (checkpatch)
v9:
- Update function names by _plane_ (Chaitanya Kumar Borah)
v6:
- don't pass uninitialized variable into __set_output_tf
.../amd/display/amdgpu_dm/amdgpu_dm_color.c | 74 +++++++++++++++++++ .../amd/display/amdgpu_dm/amdgpu_dm_colorop.c | 18 +++++ .../amd/display/amdgpu_dm/amdgpu_dm_colorop.h | 1 + 3 files changed, 93 insertions(+)
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_color.c +74 -0
@@ -1202,6 +1202,68 @@ __set_dm_plane_colorop_degamma(struct drm_plane_state *plane_state,return __set_colorop_in_tf_1d_curve (dc_plane_state, colorop_state); } +static int +__set_colorop_in_shaper_1d_curve (struct dc_plane_state *dc_plane_state, +struct drm_colorop_state *colorop_state) +{ +struct dc_transfer_func *tf = &dc_plane_state->in_shaper_func; +struct drm_colorop *colorop = colorop_state->colorop; +struct drm_device *drm = colorop->dev; + +if (colorop->type !=DRM_COLOROP_1D_CURVE && + colorop_state->curve_1d_type !=DRM_COLOROP_1D_CURVE_SRGB_INV_EOTF ) +return -EINVAL ; + +if (colorop_state->bypass) { + tf->type =TF_TYPE_BYPASS ; + tf->tf =TRANSFER_FUNCTION_LINEAR ; +return 0 ; + } + +drm_dbg (drm,"Shaper colorop with ID: %d\n" , colorop->base.id); + +if (colorop->type ==DRM_COLOROP_1D_CURVE ) { + tf->type =TF_TYPE_DISTRIBUTED_POINTS ; + tf->tf =amdgpu_colorop_tf_to_dc_tf (colorop_state->curve_1d_type); + tf->sdr_ref_white_level =SDR_WHITE_LEVEL_INIT_VALUE ; +return __set_output_tf (tf,0 ,0 , false); + } + +return -EINVAL ; +} + +static int +__set_dm_plane_colorop_shaper (struct drm_plane_state *plane_state, +struct dc_plane_state *dc_plane_state, +struct drm_colorop *colorop) +{ +struct drm_colorop *old_colorop; +struct drm_colorop_state *colorop_state =NULL , *new_colorop_state; +struct drm_atomic_state *state = plane_state->state; +int i =0 ; + + old_colorop = colorop; + +/* 2nd op: 1d curve - shaper */ +for_each_new_colorop_in_state (state, colorop, new_colorop_state, i) { +if (new_colorop_state->colorop == old_colorop && + new_colorop_state->curve_1d_type ==DRM_COLOROP_1D_CURVE_SRGB_INV_EOTF ) { + colorop_state = new_colorop_state; +break ; + } + +if (new_colorop_state->colorop == old_colorop) { + colorop_state = new_colorop_state; +break ; + } + } + +if (!colorop_state) +return -EINVAL ; + +return __set_colorop_in_shaper_1d_curve (dc_plane_state, colorop_state); +} +static int amdgpu_dm_plane_set_color_properties (struct drm_plane_state *plane_state,struct dc_plane_state *dc_plane_state)
@@ -1257,6 +1319,7 @@ amdgpu_dm_plane_set_colorop_properties(struct drm_plane_state *plane_state, struct dc_plane_state *dc_plane_state) {struct drm_colorop *colorop = plane_state->color_pipeline; +struct drm_device *dev = plane_state->plane->dev;int ret;/* 1D Curve - DEGAM TF */
@@ -1267,6 +1330,17 @@ amdgpu_dm_plane_set_colorop_properties(struct drm_plane_state *plane_state,if (ret)return ret; +/* 1D Curve - SHAPER TF */ + colorop = colorop->next; +if (!colorop) { +drm_dbg (dev,"no Shaper TF colorop found\n" ); +return -EINVAL ; + } + + ret =__set_dm_plane_colorop_shaper (plane_state, dc_plane_state, colorop); +if (ret) +return ret; +return 0 ; }
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_colorop.c +18 -0
@@ -34,6 +34,9 @@const u64 amdgpu_dm_supported_degam_tfs =BIT (DRM_COLOROP_1D_CURVE_SRGB_EOTF ); +const u64 amdgpu_dm_supported_shaper_tfs = +BIT (DRM_COLOROP_1D_CURVE_SRGB_INV_EOTF ); +#define MAX_COLOR_PIPELINE_OPS 10int amdgpu_dm_initialize_default_pipeline (struct drm_plane *plane,struct drm_prop_enum_list *list)
@@ -59,6 +62,21 @@ int amdgpu_dm_initialize_default_pipeline(struct drm_plane *plane, struct drm_pr list->type = ops[i]->base.id; list->name =kasprintf (GFP_KERNEL ,"Color Pipeline %d" , ops[i]->base.id); + i++; + +/* 1D curve - SHAPER TF */ + ops[i] =kzalloc (sizeof (struct drm_colorop ),GFP_KERNEL ); +if (!ops[i]) { + ret = -ENOMEM ; + goto cleanup; + } + + ret =drm_plane_colorop_curve_1d_init (dev, ops[i], plane, amdgpu_dm_supported_shaper_tfs); +if (ret) + goto cleanup; + +drm_colorop_set_next_property (ops[i-1 ], ops[i]); +return 0 ; cleanup:
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_colorop.h +1 -0
@@ -28,6 +28,7 @@#define __AMDGPU_DM_COLOROP_H__extern const u64 amdgpu_dm_supported_degam_tfs; +extern const u64 amdgpu_dm_supported_shaper_tfs;int amdgpu_dm_initialize_default_pipeline (struct drm_plane *plane,struct drm_prop_enum_list *list);
Signature · 1 line
2.43.0
PATCH v11 28/47 drm/amd/display: Add support for sRGB EOTF in BLND block
In reply to Alex HungExpose a 3rd 1D curve colorop, with support for DRM_COLOROP_1D_CURVE_SRGB_EOTF and program the BLND block to perform the sRGB transform when the colorop is not in bypass
With this change the following IGT test passes:kms_colorop --run plane-XR30-XR30-srgb_eotf-srgb_inv_eotf-srgb_eotf
The color pipeline now consists of the following colorops:
1. 1D curve colorop w/ sRGB EOTF support
2. 1D curve colorop w/ sRGB Inverse EOTF support
3. 1D curve colorop w/ sRGB EOTF support
---
v10:
- Remove redundant DRM_ERROR (checkpatch)
v9:
- Update function names by _plane_ (Chaitanya Kumar Borah)
v7:
- Initialized uint32_t blend_size = 0 by default (kernel test robot)
.../amd/display/amdgpu_dm/amdgpu_dm_color.c | 77 +++++++++++++++++++ .../amd/display/amdgpu_dm/amdgpu_dm_colorop.c | 18 +++++ .../amd/display/amdgpu_dm/amdgpu_dm_colorop.h | 1 + 3 files changed, 96 insertions(+)
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_color.c +77 -0
@@ -1264,6 +1264,72 @@ __set_dm_plane_colorop_shaper(struct drm_plane_state *plane_state,return __set_colorop_in_shaper_1d_curve (dc_plane_state, colorop_state); } + +static int +__set_colorop_1d_curve_blend_tf_lut (struct dc_plane_state *dc_plane_state, +struct drm_colorop_state *colorop_state) +{ + +struct dc_transfer_func *tf = &dc_plane_state->blend_tf; +struct drm_colorop *colorop = colorop_state->colorop; +struct drm_device *drm = colorop->dev; +const struct drm_color_lut *blend_lut; +uint32_t blend_size =0 ; + +if (colorop->type !=DRM_COLOROP_1D_CURVE && + colorop_state->curve_1d_type !=DRM_COLOROP_1D_CURVE_SRGB_EOTF ) +return -EINVAL ; + +if (colorop_state->bypass) { + tf->type =TF_TYPE_BYPASS ; + tf->tf =TRANSFER_FUNCTION_LINEAR ; +return 0 ; + } + +drm_dbg (drm,"Blend colorop with ID: %d\n" , colorop->base.id); + +if (colorop->type ==DRM_COLOROP_1D_CURVE ) { + tf->type =TF_TYPE_DISTRIBUTED_POINTS ; + tf->tf =amdgpu_colorop_tf_to_dc_tf (colorop_state->curve_1d_type); + tf->sdr_ref_white_level =SDR_WHITE_LEVEL_INIT_VALUE ; +return __set_input_tf (NULL , tf, blend_lut, blend_size); + } + +return -EINVAL ; +} + +static int +__set_dm_plane_colorop_blend (struct drm_plane_state *plane_state, +struct dc_plane_state *dc_plane_state, +struct drm_colorop *colorop) +{ +struct drm_colorop *old_colorop; +struct drm_colorop_state *colorop_state =NULL , *new_colorop_state; +struct drm_atomic_state *state = plane_state->state; +int i =0 ; + + old_colorop = colorop; + +/* 3nd op: 1d curve - blend */ +for_each_new_colorop_in_state (state, colorop, new_colorop_state, i) { +if (new_colorop_state->colorop == old_colorop && + new_colorop_state->curve_1d_type ==DRM_COLOROP_1D_CURVE_SRGB_EOTF ) { + colorop_state = new_colorop_state; +break ; + } + +if (new_colorop_state->colorop == old_colorop) { + colorop_state = new_colorop_state; +break ; + } + } + +if (!colorop_state) +return -EINVAL ; + +return __set_colorop_1d_curve_blend_tf_lut (dc_plane_state, colorop_state); +} +static int amdgpu_dm_plane_set_color_properties (struct drm_plane_state *plane_state,struct dc_plane_state *dc_plane_state)
@@ -1341,6 +1407,17 @@ amdgpu_dm_plane_set_colorop_properties(struct drm_plane_state *plane_state,if (ret)return ret; +/* 1D Curve - BLND TF */ + colorop = colorop->next; +if (!colorop) { +drm_dbg (dev,"no Blend TF colorop found\n" ); +return -EINVAL ; + } + + ret =__set_dm_plane_colorop_blend (plane_state, dc_plane_state, colorop); +if (ret) +return ret; +return 0 ; }
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_colorop.c +18 -0
@@ -37,6 +37,9 @@ const u64 amdgpu_dm_supported_degam_tfs =const u64 amdgpu_dm_supported_shaper_tfs =BIT (DRM_COLOROP_1D_CURVE_SRGB_INV_EOTF ); +const u64 amdgpu_dm_supported_blnd_tfs = +BIT (DRM_COLOROP_1D_CURVE_SRGB_EOTF ); +#define MAX_COLOR_PIPELINE_OPS 10int amdgpu_dm_initialize_default_pipeline (struct drm_plane *plane,struct drm_prop_enum_list *list)
@@ -77,6 +80,21 @@ int amdgpu_dm_initialize_default_pipeline(struct drm_plane *plane, struct drm_prdrm_colorop_set_next_property (ops[i-1 ], ops[i]); + i++; + +/* 1D curve - BLND TF */ + ops[i] =kzalloc (sizeof (struct drm_colorop ),GFP_KERNEL ); +if (!ops[i]) { + ret = -ENOMEM ; + goto cleanup; + } + + ret =drm_plane_colorop_curve_1d_init (dev, ops[i], plane, amdgpu_dm_supported_blnd_tfs); +if (ret) + goto cleanup; + +drm_colorop_set_next_property (ops[i-1 ], ops[i]); +return 0 ; cleanup:
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_colorop.h +1 -0
@@ -29,6 +29,7 @@extern const u64 amdgpu_dm_supported_degam_tfs;extern const u64 amdgpu_dm_supported_shaper_tfs; +extern const u64 amdgpu_dm_supported_blnd_tfs;int amdgpu_dm_initialize_default_pipeline (struct drm_plane *plane,struct drm_prop_enum_list *list);
Signature · 1 line
2.43.0
kernel test robot
build botRe: [PATCH V11 28/47] drm/amd/display: Add support for sRGB EOTF in BLND block
kernel test robot noticed the following build warnings:
Hi Alex,
kernel test robot noticed the following build warnings:
[auto build test WARNING on drm-exynos/exynos-drm-next] [also build test WARNING on linus/master v6.17-rc1 next-20250815] [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/Alex-Hung/drm-Add-helper-for-conversion-from-signed-magnitude/20250815-120435 base: https://git.kernel.org/pub/scm/linux/kernel/git/daeinki/drm-exynos.git exynos-drm-next patch link: https://lore.kernel.org/r/20250815035047.3319284-29-alex.hung%40amd.com patch subject: [PATCH V11 28/47] drm/amd/display: Add support for sRGB EOTF in BLND block config: arm64-randconfig-002-20250816 (https://download.01.org/0day-ci/archive/20250816/[email protected]/config) compiler: clang version 22.0.0git (https://github.com/llvm/llvm-project 93d24b6b7b148c47a2fa228a4ef31524fa1d9f3f) reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20250816/[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/amd/amdgpu/../display/amdgpu_dm/amdgpu_dm_color.c:1295:35: warning: variable 'blend_lut' is uninitialized when used here [-Wuninitialized]
1295 | return __set_input_tf(NULL, tf, blend_lut, blend_size);
| ^~~~~~~~~
drivers/gpu/drm/amd/amdgpu/../display/amdgpu_dm/amdgpu_dm_color.c:1276:39: note: initialize the variable 'blend_lut' to silence this warning
1276 | const struct drm_color_lut *blend_lut;
| ^
| = NULL1 warning generated.
vim +/blend_lut +1295 drivers/gpu/drm/amd/amdgpu/../display/amdgpu_dm/amdgpu_dm_color.c
1272
1273 struct dc_transfer_func *tf = &dc_plane_state->blend_tf;
1274 struct drm_colorop *colorop = colorop_state->colorop;
1275 struct drm_device *drm = colorop->dev;
1276 const struct drm_color_lut *blend_lut;
1277 uint32_t blend_size = 0;
1278
1279 if (colorop->type != DRM_COLOROP_1D_CURVE &&
1280 colorop_state->curve_1d_type != DRM_COLOROP_1D_CURVE_SRGB_EOTF)
1281 return -EINVAL;
1282
1283 if (colorop_state->bypass) {
1284 tf->type = TF_TYPE_BYPASS;
1285 tf->tf = TRANSFER_FUNCTION_LINEAR;
1286 return 0;
1287 }
1288
1289 drm_dbg(drm, "Blend colorop with ID: %d\n", colorop->base.id);
1290
1291 if (colorop->type == DRM_COLOROP_1D_CURVE) {
1292 tf->type = TF_TYPE_DISTRIBUTED_POINTS;
1293 tf->tf = amdgpu_colorop_tf_to_dc_tf(colorop_state->curve_1d_type);
1294 tf->sdr_ref_white_level = SDR_WHITE_LEVEL_INIT_VALUE;
> 1295 return __set_input_tf(NULL, tf, blend_lut, blend_size);
1296 }
1297
1298 return -EINVAL;
1299 }
1300
Signature · 2 lines
0-DAY CI Kernel Test Service https://github.com/intel/lkp-tests/wiki
PATCH v11 29/47 drm/colorop: Add PQ 125 EOTF and its inverse
In reply to Alex HungFrom: Harry Wentland <[email protected]>
The PQ function defines a mapping of code values to nits (cd/m^2). The max code value maps to 10,000 nits.
Windows DWM's canonical composition color space (CCCS) defaults to composing SDR contents to 80 nits and uses a float value of 1.0 to represent this. For this reason AMD HW hard-codes a PQ function that is scaled by 125, yielding 80 nit PQ values for 1.0 and 10,000 nits at 125.0.
This patch introduces this scaled PQ EOTF and its inverse as 1D curve types.
--- drivers/gpu/drm/drm_colorop.c | 2 ++ include/drm/drm_colorop.h | 24 ++++++++++++++++++++++++ 2 files changed, 26 insertions(+)
drivers/gpu/drm/drm_colorop.c +2 -0
@@ -70,6 +70,8 @@ static const struct drm_prop_enum_list drm_colorop_type_enum_list[] = {static const char *const colorop_curve_1d_type_names[] = { [DRM_COLOROP_1D_CURVE_SRGB_EOTF ] ="sRGB EOTF" , [DRM_COLOROP_1D_CURVE_SRGB_INV_EOTF ] ="sRGB Inverse EOTF" , + [DRM_COLOROP_1D_CURVE_PQ_125_EOTF ] ="PQ 125 EOTF" , + [DRM_COLOROP_1D_CURVE_PQ_125_INV_EOTF ] ="PQ 125 Inverse EOTF" , };
include/drm/drm_colorop.h +24 -0
@@ -59,6 +59,30 @@ enum drm_colorop_curve_1d_type {*/ DRM_COLOROP_1D_CURVE_SRGB_INV_EOTF , +/** +* @DRM_COLOROP_1D_CURVE_PQ_125_EOTF: +* +* enum string "PQ 125 EOTF" +* +* The PQ transfer function, scaled by 125.0f, so that 10,000 +* nits correspond to 125.0f. +* +* Transfer characteristics of the PQ function as defined by +* SMPTE ST 2084 (2014) for 10-, 12-, 14-, and 16-bit systems +* and Rec. ITU-R BT.2100-2 perceptual quantization (PQ) system, +* represented by H.273 TransferCharacteristics code point 16. +*/ +DRM_COLOROP_1D_CURVE_PQ_125_EOTF , + +/** +* @DRM_COLOROP_1D_CURVE_PQ_125_INV_EOTF: +* +* enum string "PQ 125 Inverse EOTF" +* +* The inverse of DRM_COLOROP_1D_CURVE_PQ_125_EOTF. +*/ + DRM_COLOROP_1D_CURVE_PQ_125_INV_EOTF, +/** * @DRM_COLOROP_1D_CURVE_COUNT: *
Signature · 1 line
2.43.0
PATCH v11 30/47 drm/amd/display: Enable support for PQ 125 EOTF and Inverse
In reply to Alex HungFrom: Harry Wentland <[email protected]>
This patchset enables support for the PQ_125 EOTF and its inverse on all existing plane 1D curve colorops, i.e., on DEGAM, SHAPER, and BLND blocks.
With this patchset the following IGT subtests are passing:kms_colorop --run plane-XR30-XR30-pq_125_eotfkms_colorop --run plane-XR30-XR30-pq_125_inv_eotfkms_colorop --run plane-XR30-XR30-pq_125_eotf-pq_125_inv_eotf kms_colorop --run plane-XR30-XR30-pq_125_eotf-pq_125_inv_eotf-pq_125_eotf
---
v10:
- Move amdgpu_dm_supported_*_tfs check here from Patch 32 (Melissa Wen)
v8:
- Move BIT(DRM_COLOROP_1D_CURVE_PQ_125_EOTF) in amdgpu_dm_supported_blnd_tfs from "drm/amd/display: Add support for BT.709 and BT.2020 TFs" (Leo Li)
.../amd/display/amdgpu_dm/amdgpu_dm_color.c | 28 +++++++++++++------ .../amd/display/amdgpu_dm/amdgpu_dm_colorop.c | 9 ++++-- 2 files changed, 25 insertions(+), 12 deletions(-)
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_color.c +19 -9
@@ -25,6 +25,7 @@#include "amdgpu.h" #include "amdgpu_mode.h" #include "amdgpu_dm.h" +#include "amdgpu_dm_colorop.h" #include "dc.h" #include "modules/color/color_gamma.h" #include "basics/conversion.h"
@@ -675,6 +676,9 @@ amdgpu_colorop_tf_to_dc_tf(enum drm_colorop_curve_1d_type tf)case DRM_COLOROP_1D_CURVE_SRGB_EOTF :case DRM_COLOROP_1D_CURVE_SRGB_INV_EOTF :return TRANSFER_FUNCTION_SRGB ; +case DRM_COLOROP_1D_CURVE_PQ_125_EOTF : +case DRM_COLOROP_1D_CURVE_PQ_125_INV_EOTF : +return TRANSFER_FUNCTION_PQ ;default :return TRANSFER_FUNCTION_LINEAR ; }
@@ -1157,8 +1161,10 @@ __set_colorop_in_tf_1d_curve(struct dc_plane_state *dc_plane_state,struct drm_colorop *colorop = colorop_state->colorop;struct drm_device *drm = colorop->dev; -if (colorop->type !=DRM_COLOROP_1D_CURVE || - colorop_state->curve_1d_type !=DRM_COLOROP_1D_CURVE_SRGB_EOTF ) +if (colorop->type !=DRM_COLOROP_1D_CURVE ) +return -EINVAL ; + +if (!(BIT (colorop_state->curve_1d_type) & amdgpu_dm_supported_degam_tfs))return -EINVAL ;if (colorop_state->bypass) {
@@ -1190,7 +1196,7 @@ __set_dm_plane_colorop_degamma(struct drm_plane_state *plane_state,/* 1st op: 1d curve - degamma */ for_each_new_colorop_in_state (state, colorop, new_colorop_state, i) {if (new_colorop_state->colorop == old_colorop && - new_colorop_state->curve_1d_type ==DRM_COLOROP_1D_CURVE_SRGB_EOTF ) { + (BIT (new_colorop_state->curve_1d_type) & amdgpu_dm_supported_degam_tfs)) { colorop_state = new_colorop_state;break ; }
@@ -1210,8 +1216,10 @@ __set_colorop_in_shaper_1d_curve(struct dc_plane_state *dc_plane_state,struct drm_colorop *colorop = colorop_state->colorop;struct drm_device *drm = colorop->dev; -if (colorop->type !=DRM_COLOROP_1D_CURVE && - colorop_state->curve_1d_type !=DRM_COLOROP_1D_CURVE_SRGB_INV_EOTF ) +if (colorop->type !=DRM_COLOROP_1D_CURVE ) +return -EINVAL ; + +if (!(BIT (colorop_state->curve_1d_type) & amdgpu_dm_supported_shaper_tfs))return -EINVAL ;if (colorop_state->bypass) {
@@ -1247,7 +1255,7 @@ __set_dm_plane_colorop_shaper(struct drm_plane_state *plane_state,/* 2nd op: 1d curve - shaper */ for_each_new_colorop_in_state (state, colorop, new_colorop_state, i) {if (new_colorop_state->colorop == old_colorop && - new_colorop_state->curve_1d_type ==DRM_COLOROP_1D_CURVE_SRGB_INV_EOTF ) { + (BIT (new_colorop_state->curve_1d_type) & amdgpu_dm_supported_shaper_tfs)) { colorop_state = new_colorop_state;break ; }
@@ -1276,8 +1284,10 @@ __set_colorop_1d_curve_blend_tf_lut(struct dc_plane_state *dc_plane_state,const struct drm_color_lut *blend_lut;uint32_t blend_size =0 ; -if (colorop->type !=DRM_COLOROP_1D_CURVE && - colorop_state->curve_1d_type !=DRM_COLOROP_1D_CURVE_SRGB_EOTF ) +if (colorop->type !=DRM_COLOROP_1D_CURVE ) +return -EINVAL ; + +if (!(BIT (colorop_state->curve_1d_type) & amdgpu_dm_supported_blnd_tfs))return -EINVAL ;if (colorop_state->bypass) {
@@ -1313,7 +1323,7 @@ __set_dm_plane_colorop_blend(struct drm_plane_state *plane_state,/* 3nd op: 1d curve - blend */ for_each_new_colorop_in_state (state, colorop, new_colorop_state, i) {if (new_colorop_state->colorop == old_colorop && - new_colorop_state->curve_1d_type ==DRM_COLOROP_1D_CURVE_SRGB_EOTF ) { + (BIT (new_colorop_state->curve_1d_type) & amdgpu_dm_supported_blnd_tfs)) { colorop_state = new_colorop_state;break ; }
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_colorop.c +6 -3
@@ -32,13 +32,16 @@#include "amdgpu_dm_colorop.h" const u64 amdgpu_dm_supported_degam_tfs = -BIT (DRM_COLOROP_1D_CURVE_SRGB_EOTF ); +BIT (DRM_COLOROP_1D_CURVE_SRGB_EOTF ) | +BIT (DRM_COLOROP_1D_CURVE_PQ_125_EOTF );const u64 amdgpu_dm_supported_shaper_tfs = -BIT (DRM_COLOROP_1D_CURVE_SRGB_INV_EOTF ); +BIT (DRM_COLOROP_1D_CURVE_SRGB_INV_EOTF ) | +BIT (DRM_COLOROP_1D_CURVE_PQ_125_INV_EOTF );const u64 amdgpu_dm_supported_blnd_tfs = -BIT (DRM_COLOROP_1D_CURVE_SRGB_EOTF ); +BIT (DRM_COLOROP_1D_CURVE_SRGB_EOTF ) | +BIT (DRM_COLOROP_1D_CURVE_PQ_125_EOTF );#define MAX_COLOR_PIPELINE_OPS 10
Signature · 1 line
2.43.0
PATCH v11 31/47 drm/colorop: add BT2020/BT709 OETF and Inverse OETF
In reply to Alex HungFrom: Harry Wentland <[email protected]>
The BT.709 and BT.2020 OETFs are the same, the only difference being that the BT.2020 variant is defined with more precision for 10 and 12-bit per color encodings.
Both are used as encoding functions for video content, and are therefore defined as OETF (opto-electronic transfer function) instead of as EOTF (electro-optical transfer function).
---
v9:
- Move DRM_COLOROP_1D_CURVE_BT2020_* from middle to end (Simon Ser)
drivers/gpu/drm/drm_colorop.c | 2 ++ include/drm/drm_colorop.h | 23 +++++++++++++++++++++++ 2 files changed, 25 insertions(+)
drivers/gpu/drm/drm_colorop.c +2 -0
@@ -72,6 +72,8 @@ static const char * const colorop_curve_1d_type_names[] = { [DRM_COLOROP_1D_CURVE_SRGB_INV_EOTF] = "sRGB Inverse EOTF", [DRM_COLOROP_1D_CURVE_PQ_125_EOTF] = "PQ 125 EOTF", [DRM_COLOROP_1D_CURVE_PQ_125_INV_EOTF] = "PQ 125 Inverse EOTF", + [DRM_COLOROP_1D_CURVE_BT2020_INV_OETF] = "BT.2020 Inverse OETF", + [DRM_COLOROP_1D_CURVE_BT2020_OETF] = "BT.2020 OETF", };
include/drm/drm_colorop.h +23 -0
@@ -83,6 +83,29 @@ enum drm_colorop_curve_1d_type {*/ DRM_COLOROP_1D_CURVE_PQ_125_INV_EOTF , +/** +* @DRM_COLOROP_1D_CURVE_BT2020_INV_OETF: +* +* enum string "BT.2020 Inverse OETF" +* +* The inverse of &DRM_COLOROP_1D_CURVE_BT2020_OETF +*/ +DRM_COLOROP_1D_CURVE_BT2020_INV_OETF , + +/** +* @DRM_COLOROP_1D_CURVE_BT2020_OETF: +* +* enum string "BT.2020 OETF" +* +* The BT.2020/BT.709 transfer function. The BT.709 and BT.2020 +* transfer functions are the same, the only difference is that +* BT.2020 is defined with more precision for 10 and 12-bit +* encodings. +* +* +*/ + DRM_COLOROP_1D_CURVE_BT2020_OETF, +/** * @DRM_COLOROP_1D_CURVE_COUNT: *
Signature · 1 line
2.43.0
Re: [PATCH V11 31/47] drm/colorop: add BT2020/BT709 OETF and Inverse OETF
Hello,
What actually is this OETF? Is it power 1/2.4? Or reversed BT.1886?
Best regards,
Shengyu
________________________________
发件人: amd-gfx <[email protected]> 代表 Alex Hung <[email protected]>
发送时间: Friday, August 15, 2025 11:50:20 AM
收件人: [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]>; [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]>; [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]>; Daniel Stone <[email protected]> 主题: [PATCH V11 31/47] drm/colorop: add BT2020/BT709 OETF and Inverse OETF
From: Harry Wentland <[email protected]>
The BT.709 and BT.2020 OETFs are the same, the only difference being that the BT.2020 variant is defined with more precision for 10 and 12-bit per color encodings.
Both are used as encoding functions for video content, and are therefore defined as OETF (opto-electronic transfer function) instead of as EOTF (electro-optical transfer function).
---
v9:
- Move DRM_COLOROP_1D_CURVE_BT2020_* from middle to end (Simon Ser)
drivers/gpu/drm/drm_colorop.c | 2 ++ include/drm/drm_colorop.h | 23 +++++++++++++++++++++++ 2 files changed, 25 insertions(+)
drivers/gpu/drm/drm_colorop.c +2 -0
@@ -72,6 +72,8 @@ static const char * const colorop_curve_1d_type_names[] = { [DRM_COLOROP_1D_CURVE_SRGB_INV_EOTF] = "sRGB Inverse EOTF", [DRM_COLOROP_1D_CURVE_PQ_125_EOTF] = "PQ 125 EOTF", [DRM_COLOROP_1D_CURVE_PQ_125_INV_EOTF] = "PQ 125 Inverse EOTF", + [DRM_COLOROP_1D_CURVE_BT2020_INV_OETF] = "BT.2020 Inverse OETF", + [DRM_COLOROP_1D_CURVE_BT2020_OETF] = "BT.2020 OETF", };
include/drm/drm_colorop.h +23 -0
@@ -83,6 +83,29 @@ enum drm_colorop_curve_1d_type {*/ DRM_COLOROP_1D_CURVE_PQ_125_INV_EOTF , +/** +* @DRM_COLOROP_1D_CURVE_BT2020_INV_OETF: +* +* enum string "BT.2020 Inverse OETF" +* +* The inverse of &DRM_COLOROP_1D_CURVE_BT2020_OETF +*/ +DRM_COLOROP_1D_CURVE_BT2020_INV_OETF , + +/** +* @DRM_COLOROP_1D_CURVE_BT2020_OETF: +* +* enum string "BT.2020 OETF" +* +* The BT.2020/BT.709 transfer function. The BT.709 and BT.2020 +* transfer functions are the same, the only difference is that +* BT.2020 is defined with more precision for 10 and 12-bit +* encodings. +* +* +*/ + DRM_COLOROP_1D_CURVE_BT2020_OETF, +/** * @DRM_COLOROP_1D_CURVE_COUNT: *
--
2.43.0
Re: [PATCH V11 31/47] drm/colorop: add BT2020/BT709 OETF and Inverse OETF
Quoted 3 lines · Qu Shengyu
Hello,
What actually is this OETF? Is it power 1/2.4? Or reversed BT.1886?
https://www.itu.int/dms_pubrec/itu-r/rec/bt/R-REC-BT.2020-2-201510-I!!PDF-E.pdf (Table 4?)
Quoted 3 lines
Best regards,
Shengyu
Re: [PATCH V11 31/47] drm/colorop: add BT2020/BT709 OETF and Inverse OETF
Hi,
Thanks for reply. I guess we need to point this out in documentation or code comment? As I can see different definition somewhere like this[1].
Best regards,
Shengyu
[1] https://color.org/chardata/rgb/BT2020.xalter
Quoted 13 lines · Alex Hung
Quoted 3 lines · Qu Shengyu
Hello,
What actually is this OETF? Is it power 1/2.4? Or reversed BT.1886?
https://www.itu.int/dms_pubrec/itu-r/rec/bt/R-REC-BT.2020-2-201510-I!! PDF-E.pdf (Table 4?)
Quoted 3 lines
Best regards,
Shengyu
Re: [PATCH V11 31/47] drm/colorop: add BT2020/BT709 OETF and Inverse OETF
Quoted 8 lines · Shengyu Qu
Hi,
Thanks for reply. I guess we need to point this out in documentation or code comment? As I can see different definition somewhere like this[1].
Best regards,
Shengyu
It's the same one. You can find the ITU document in "Documentation source" in above link.
Quoted 16 lines · Alex Hung
Quoted 13 lines · Qu Shengyu
Quoted 3 lines
Hello,
What actually is this OETF? Is it power 1/2.4? Or reversed BT.1886?
https://www.itu.int/dms_pubrec/itu-r/rec/bt/R-REC-BT.2020-2-201510-I!! PDF-E.pdf (Table 4?)
Quoted 3 lines
Best regards,
Shengyu
Re: [PATCH V11 31/47] drm/colorop: add BT2020/BT709 OETF and Inverse OETF
Quoted 6 lines · On Fri, 15 Aug 2025 21:28:47 -0600 Alex Hung <[email protected]> wrote:
Quoted 5 lines · Shengyu Qu
Hi,
Thanks for reply. I guess we need to point this out in documentation or code comment? As I can see different definition somewhere like this[1].
Quoted 7 lines
Quoted 4 lines
Best regards,
ShengyuIt's the same one. You can find the ITU document in "Documentation source" in above link.
Hi,
I sense confusion, because color.org quotes BT.1886 explicitly in
Quoted 1 line
Color component transfer function: C'= C^1/2.4
which is not the BT.2020 OETF (nor it's inverse, nor approximation).
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
https://www.itu.int/dms_pubrec/itu-r/rec/bt/R-REC-BT.2020-2-201510-I!!
PDF-E.pdf (Table 4?)
says
E' = 4.5 * E, for 0 <= E < β
E' = α * E^0.45 - (α - 1), for β <= E <= 1
with
α = 1.09929682680944... and
β = 0.018053968510807..
The footnote for that table:
Quoted 5 lines
(4) In typical production practice the encoding function of image sources is adjusted so that the final picture has the desired look, as viewed on a reference monitor having the reference decoding function of Recommendation ITU-R BT.1886, in the reference viewing environment defined in Recommendation ITU-R BT.2035.
In other words, the common practice is to not use the specified curve.
As we can see in
https://www.desmos.com/calculator/gqjuzqsebg
the two curves do not even approximate each other.
However, for someone familiar with the specifications BT.2020 and BT.1886, the two curves are distinctly named. BT.2020 defines the OETF, and BT.1886 defines the EOTF. Inverse of one does not match the other deliberately. The mismatch between the camera curve and the display curve is required to make the picture look better.
When someone says "BT.2020 OETF", it is unambiguous. It's the only curve actually specified in BT.2020.
Thanks,
pq
PATCH v11 32/47 drm/amd/display: Add support for BT.709 and BT.2020 TFs
In reply to Alex HungFrom: Harry Wentland <[email protected]>
This adds support for the BT.709/BT.2020 transfer functions on all current 1D curve plane colorops, i.e., on DEGAM, SHAPER, and BLND blocks.
With this change the following IGT subtests pass:kms_colorop --run plane-XR30-XR30-bt2020_inv_oetf kms_colorop --run plane-XR30-XR30-bt2020_oetf
---
v10:
- Move amdgpu_dm_supported_*_tfs check to Patch 32 (Melissa Wen)
v9:
- Move DRM_COLOROP_1D_CURVE_BT2020_* from middle to end
v8:
- Move BIT(DRM_COLOROP_1D_CURVE_PQ_125_EOTF) in amdgpu_dm_supported_blnd_tfs to "drm/amd/display: Enable support for PQ 125 EOTF and Inverse" (Leo Li)
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_color.c | 3 +++ .../gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_colorop.c | 9 ++++++--- 2 files changed, 9 insertions(+), 3 deletions(-)
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_color.c +3 -0
@@ -679,6 +679,9 @@ amdgpu_colorop_tf_to_dc_tf(enum drm_colorop_curve_1d_type tf)case DRM_COLOROP_1D_CURVE_PQ_125_EOTF :case DRM_COLOROP_1D_CURVE_PQ_125_INV_EOTF :return TRANSFER_FUNCTION_PQ ; +case DRM_COLOROP_1D_CURVE_BT2020_INV_OETF : +case DRM_COLOROP_1D_CURVE_BT2020_OETF : +return TRANSFER_FUNCTION_BT709 ;default :return TRANSFER_FUNCTION_LINEAR ; }
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_colorop.c +6 -3
@@ -33,15 +33,18 @@const u64 amdgpu_dm_supported_degam_tfs =BIT (DRM_COLOROP_1D_CURVE_SRGB_EOTF ) | -BIT (DRM_COLOROP_1D_CURVE_PQ_125_EOTF ); +BIT (DRM_COLOROP_1D_CURVE_PQ_125_EOTF ) | +BIT (DRM_COLOROP_1D_CURVE_BT2020_INV_OETF );const u64 amdgpu_dm_supported_shaper_tfs =BIT (DRM_COLOROP_1D_CURVE_SRGB_INV_EOTF ) | -BIT (DRM_COLOROP_1D_CURVE_PQ_125_INV_EOTF ); +BIT (DRM_COLOROP_1D_CURVE_PQ_125_INV_EOTF ) | +BIT (DRM_COLOROP_1D_CURVE_BT2020_OETF );const u64 amdgpu_dm_supported_blnd_tfs =BIT (DRM_COLOROP_1D_CURVE_SRGB_EOTF ) | -BIT (DRM_COLOROP_1D_CURVE_PQ_125_EOTF ); +BIT (DRM_COLOROP_1D_CURVE_PQ_125_EOTF ) | +BIT (DRM_COLOROP_1D_CURVE_BT2020_INV_OETF );#define MAX_COLOR_PIPELINE_OPS 10
Signature · 1 line
2.43.0
PATCH v11 33/47 drm: Add Enhanced LUT precision structure
In reply to Alex HungFrom: Uma Shankar <[email protected]>
Existing LUT precision structure drm_color_lut has 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.
---
v11:
- Update names from *_lut_32_* to *_lut32_* (Simon Ser)
v10:
- Include drm_color_lut_32 from Intel to support 32BIT RGB in 1D & 3D LUTs (Uma Shankar)
drivers/gpu/drm/drm_color_mgmt.c | 43 ++++++++++++++++++++++++++++++++ include/drm/drm_color_mgmt.h | 13 ++++++++++ include/uapi/drm/drm_mode.h | 12 +++++++++ 3 files changed, 68 insertions(+)
drivers/gpu/drm/drm_color_mgmt.c +43 -0
@@ -840,3 +840,46 @@ void drm_crtc_fill_palette_8(struct drm_crtc *crtc, drm_crtc_set_lut_func set_pafill_palette_8 (crtc, i, set_palette); }EXPORT_SYMBOL (drm_crtc_fill_palette_8); + +/** +* drm_color_lut32_check - check validity of extended lookup table +* @lut: property blob containing extended LUT to check +* @tests: bitmask of tests to run +* +* Helper to check whether a userspace-provided extended lookup table is valid and +* satisfies hardware requirements. Drivers pass a bitmask indicating which of +* the tests in &drm_color_lut_tests should be performed. +* +* Returns 0 on success, -EINVAL on failure. +*/ +int drm_color_lut32_check (const struct drm_property_blob *lut,u32 tests) +{ +const struct drm_color_lut32 *entry; +int i; + +if (!lut || !tests) +return 0 ; + + entry = lut->data; +for (i =0 ; i <drm_color_lut32_size (lut); i++) { +if (tests &DRM_COLOR_LUT_EQUAL_CHANNELS ) { +if (entry[i].red != entry[i].blue || + entry[i].red != entry[i].green) { +DRM_DEBUG_KMS ("All LUT entries must have equal r/g/b\n" ); +return -EINVAL ; + } + } + +if (i >0 && tests &DRM_COLOR_LUT_NON_DECREASING ) { +if (entry[i].red < entry[i -1 ].red || + entry[i].green < entry[i -1 ].green || + entry[i].blue < entry[i -1 ].blue) { +DRM_DEBUG_KMS ("LUT entries must never decrease.\n" ); +return -EINVAL ; + } + } + } + +return 0 ; +} +EXPORT_SYMBOL (drm_color_lut32_check);
include/drm/drm_color_mgmt.h +13 -0
@@ -72,6 +72,18 @@ static inline int drm_color_lut_size(const struct drm_property_blob *blob)return blob->length /sizeof (struct drm_color_lut ); } +/** +* drm_color_lut32_size - calculate the number of entries in the extended LUT +* @blob: blob containing the LUT +* +* Returns: +* The number of entries in the color LUT stored in @blob. +*/ +static inline int drm_color_lut32_size (const struct drm_property_blob *blob) +{ +return blob->length /sizeof (struct drm_color_lut32 ); +} +enum drm_color_encoding {DRM_COLOR_YCBCR_BT601 ,DRM_COLOR_YCBCR_BT709 ,
@@ -145,4 +157,5 @@ void drm_crtc_load_palette_8(struct drm_crtc *crtc, const struct drm_color_lut *void drm_crtc_fill_palette_8 (struct drm_crtc *crtc,drm_crtc_set_lut_func set_palette); +int drm_color_lut32_check (const struct drm_property_blob *lut,u32 tests);#endif
include/uapi/drm/drm_mode.h +12 -0
@@ -872,6 +872,18 @@ struct drm_color_lut {__u16 reserved; }; +/* +* struct drm_color_lut32 +* +* 32-bit per channel color LUT entry, similar to drm_color_lut. +*/ +struct drm_color_lut32 { +__u32 red; +__u32 green; +__u32 blue; +__u32 reserved; +}; +/** * enum drm_colorop_type - Type of color operation *
Signature · 1 line
2.43.0
PATCH v11 34/47 drm: Add helper to extract lut from struct drm_color_lut32
In reply to Alex HungFrom: Chaitanya Kumar Borah <[email protected]>
Add helper to extract lut values in 32-bit precision needed by hardware.
---
v11:
- Include help function drm_color_lut32_extract (Uma Shankar)
include/drm/drm_color_mgmt.h | 16 ++++++++++++++++ 1 file changed, 16 insertions(+)
include/drm/drm_color_mgmt.h +16 -0
@@ -50,6 +50,22 @@ static inline u32 drm_color_lut_extract(u32 user_input, int bit_precision) (1 << 16) - 1); } +/** +* drm_color_lut32_extract - clamp and round LUT entries +* @user_input: input value +* @bit_precision: number of bits the hw LUT supports +* +* Extract U0.bit_precision from a U0.32 LUT value. +* +*/ +static inline u32 drm_color_lut32_extract (u32 user_input,int bit_precision) +{ +u64 max = (bit_precision >=64 ) ? ~0ULL : (1ULL << bit_precision) -1 ; + +return DIV_ROUND_CLOSEST_ULL ((u64 )user_input * max, + (1ULL <<32 ) -1 ); +} +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,
Signature · 1 line
2.43.0
PATCH v11 35/47 drm/colorop: Add 1D Curve Custom LUT type
In reply to Alex HungWe've previously introduced DRM_COLOROP_1D_CURVE for pre-defined 1D curves. But we also have HW that supports custom curves and userspace needs the ability to pass custom curves, aka LUTs.
This patch introduces a new colorop type, called DRM_COLOROP_1D_LUT that provides a SIZE property which is used by a driver to advertise the supported SIZE of the LUT, as well as a DATA property which userspace uses to set the LUT.
DATA and size function in the same way as current drm_crtc GAMMA and DEGAMMA LUTs.
---
v11:
- Update names from *_lut_32_* to *_lut32_* (Simon Ser)
v10:
- 1D LUT API is now using 32BIT RGB with drm_color_lut_32 (Uma Shankar)
v9:
- Update function names by _plane_ (Chaitanya Kumar Borah)
v8:
- Add DRM_MODE_PROP_ATOMIC to drm_property_create_range (Simon Ser)
- Change "1D Curve Custom LUT" to "1D LUT" (Simon Ser)
v7:
- Change "size" to "lut_size" (this affects multiple following commits)
- Move "lut_size" from drm_colorop_state to drm_colorop
- Modify other files accordingly (i.e. from drm_colorop_state->size to drm_colorop->lut_size)
v5:
- Add kernel doc
- Define SIZE in similar manner to GAMMA_SIZE on drm_crtc (Melissa)
drivers/gpu/drm/drm_atomic.c | 4 +++ drivers/gpu/drm/drm_atomic_uapi.c | 5 ++++ drivers/gpu/drm/drm_colorop.c | 43 +++++++++++++++++++++++++++++++ include/drm/drm_colorop.h | 16 ++++++++++++ include/uapi/drm/drm_mode.h | 14 ++++++++++ 5 files changed, 82 insertions(+)
drivers/gpu/drm/drm_atomic.c +4 -0
@@ -793,6 +793,10 @@ static void drm_atomic_colorop_print_state(struct drm_printer *p,drm_printf (p,"\tcurve_1d_type=%s\n" ,drm_get_colorop_curve_1d_type_name (state->curve_1d_type));break ; +case DRM_COLOROP_1D_LUT : +drm_printf (p,"\tsize=%d\n" , colorop->lut_size); +drm_printf (p,"\tdata blob id=%d\n" , state->data ? state->data->base.id :0 ); +break ;case DRM_COLOROP_CTM_3X4 :drm_printf (p,"\tdata blob id=%d\n" , state->data ? state->data->base.id :0 );break ;
drivers/gpu/drm/drm_atomic_uapi.c +5 -0
@@ -697,6 +697,9 @@ static int drm_atomic_color_set_data_property(struct drm_colorop *colorop,bool replaced = false;switch (colorop->type) { +case DRM_COLOROP_1D_LUT : + size = colorop->lut_size *sizeof (struct drm_color_lut32 ); +break ;case DRM_COLOROP_CTM_3X4 : size =sizeof (struct drm_color_ctm_3x4 );break ;
@@ -746,6 +749,8 @@ drm_atomic_colorop_get_property(struct drm_colorop *colorop, *val = state->bypass; }else if (property == colorop->curve_1d_type_property) { *val = state->curve_1d_type; + }else if (property == colorop->lut_size_property) { + *val = colorop->lut_size; }else if (property == colorop->data_property) { *val = (state->data) ? state->data->base.id :0 ; }else {
drivers/gpu/drm/drm_colorop.c +43 -0
61 lines not on this page · raw message
include/drm/drm_colorop.h +16 -0
@@ -259,6 +259,13 @@ struct drm_colorop {*/ struct drm_property *bypass_property; +/** +* @lut_size: +* +* Number of entries of the custom LUT. This should be read-only. +*/ +uint32_t lut_size; +/** * @curve_1d_type_property: *
@@ -266,6 +273,13 @@ struct drm_colorop {*/ struct drm_property *curve_1d_type_property; +/** +* @lut_size_property: +* +* Size property for custom LUT from userspace. +*/ +struct drm_property *lut_size_property; +/** * @data_property: *
@@ -312,6 +326,8 @@ void drm_colorop_pipeline_destroy(struct drm_device *dev);int drm_plane_colorop_curve_1d_init (struct drm_device *dev,struct drm_colorop *colorop,struct drm_plane *plane,u64 supported_tfs); +int drm_plane_colorop_curve_1d_lut_init (struct drm_device *dev,struct drm_colorop *colorop, +struct drm_plane *plane,uint32_t lut_size);int drm_plane_colorop_ctm_3x4_init (struct drm_device *dev,struct drm_colorop *colorop,struct drm_plane *plane);
include/uapi/drm/drm_mode.h +14 -0
@@ -902,6 +902,20 @@ enum drm_colorop_type {*/ DRM_COLOROP_1D_CURVE , +/** +* @DRM_COLOROP_1D_LUT: +* +* enum string "1D LUT" +* +* A simple 1D LUT of uniformly spaced &drm_color_lut32 entries, +* packed into a blob via the DATA property. The driver's +* expected LUT size is advertised via the SIZE property. +* +* The DATA blob is an array of struct drm_color_lut32 with size +* of "lut_size". +*/ + DRM_COLOROP_1D_LUT, +/** * @DRM_COLOROP_CTM_3X4: *
Signature · 1 line
2.43.0
Re: [PATCH V11 35/47] drm/colorop: Add 1D Curve Custom LUT type
Quoted 121 lines · Alex Hung
We've previously introduced
DRM_COLOROP_1D_CURVEfor pre-defined 1D curves. But we also have HW that supports custom curves and userspace needs the ability to pass custom curves, aka LUTs.This patch introduces a new colorop type, called
DRM_COLOROP_1D_LUTthat provides a SIZE property which is used by a driver to advertise the supported SIZE of the LUT, as well as a DATA property which userspace uses to set the LUT.DATA and size function in the same way as current
drm_crtcGAMMA and DEGAMMA LUTs.Reviewed-by Simon Ser <[email protected]>Signed-off-by Alex Hung <[email protected]>Co-developed-by Harry Wentland <[email protected]>Signed-off-by Harry Wentland <[email protected]>Reviewed-by Daniel Stone <[email protected]>---
v11:
- Update names from *_lut_32_* to *_lut32_* (Simon Ser)v10:
- 1D LUT API is now using 32BIT RGB withdrm_color_lut_32(Uma Shankar)v9:
- Update function names by _plane_ (Chaitanya Kumar Borah)v8:
- AddDRM_MODE_PROP_ATOMICtodrm_property_create_range(Simon Ser)
- Change "1D Curve Custom LUT" to "1D LUT" (Simon Ser)v7:
- Change "size" to "lut_size" (this affects multiple following commits)
- Move "lut_size" fromdrm_colorop_statetodrm_colorop
- Modify other files accordingly (i.e. fromdrm_colorop_state->sizetodrm_colorop->lut_size)v5:
- Add kernel doc
- Define SIZE in similar manner toGAMMA_SIZEondrm_crtc(Melissa)drivers/gpu/drm/drm_atomic.c | 4 +++ drivers/gpu/drm/drm_atomic_uapi.c | 5 ++++ drivers/gpu/drm/drm_colorop.c | 43 +++++++++++++++++++++++++++++++ include/drm/drm_colorop.h | 16 ++++++++++++ include/uapi/drm/drm_mode.h | 14 ++++++++++ 5 files changed, 82 insertions(+)drivers/gpu/drm/drm_atomic.c +4
-0@@ -793,6 +793,10 @@ static void drm_atomic_colorop_print_state(struct drm_printer *p,drm_printf (p,"\tcurve_1d_type=%s\n" ,drm_get_colorop_curve_1d_type_name (state->curve_1d_type));break ; +case DRM_COLOROP_1D_LUT : +drm_printf (p,"\tsize=%d\n" , colorop->lut_size); +drm_printf (p,"\tdata blob id=%d\n" , state->data ? state->data->base.id :0 ); +break ;case DRM_COLOROP_CTM_3X4 :drm_printf (p,"\tdata blob id=%d\n" , state->data ? state->data->base.id :0 );break ;drivers/gpu/drm/drm_atomic_uapi.c +5
-0@@ -697,6 +697,9 @@ static int drm_atomic_color_set_data_property(struct drm_colorop *colorop,bool replaced = false;switch (colorop->type) { +case DRM_COLOROP_1D_LUT : + size = colorop->lut_size *sizeof (struct drm_color_lut32 ); +break ;case DRM_COLOROP_CTM_3X4 : size =sizeof (struct drm_color_ctm_3x4 );break ;@@ -746,6 +749,8 @@ drm_atomic_colorop_get_property(struct drm_colorop *colorop, *val = state->bypass; }else if (property == colorop->curve_1d_type_property) { *val = state->curve_1d_type; + }else if (property == colorop->lut_size_property) { + *val = colorop->lut_size; }else if (property == colorop->data_property) { *val = (state->data) ? state->data->base.id :0 ; }else {drivers/gpu/drm/drm_colorop.c +18
-0@@ -64,6 +64,7 @@static const struct drm_prop_enum_list drm_colorop_type_enum_list[] = { {DRM_COLOROP_1D_CURVE ,"1D Curve" }, + {DRM_COLOROP_1D_LUT ,"1D LUT" }, {DRM_COLOROP_CTM_3X4 ,"3x4 Matrix" }, };@@ -265,6 +266,47 @@ static int drm_colorop_create_data_prop(struct drm_device *dev, struct drm_colorreturn 0 ; } +/** +* drm_plane_colorop_curve_1d_lut_init - Initialize a DRM_COLOROP_1D_LUT +* +* @dev: DRM device +* @colorop: The drm_colorop object to initialize +* @plane: The associated drm_plane +* @lut_size: LUT size supported by driver +* @return zero on success, -E value on failure +*/ +int drm_plane_colorop_curve_1d_lut_init (struct drm_device *dev,struct drm_colorop *colorop, +struct drm_plane *plane,uint32_t lut_size) +{ +struct drm_property *prop; +int ret; + + ret =drm_plane_colorop_init (dev, colorop, plane,DRM_COLOROP_1D_LUT ); +if (ret)
drivers/gpu/drm/drm_colorop.c static int drm_colorop_create_data_prop(struct drm_device *dev, struct drm_color · line 295
Quoted 10 lines
drivers/gpu/drm/drm_colorop.c +10
-0+return ret; + +/* initialize 1D LUT only attribute */ +/* LUT size */ + prop =drm_property_create_range (dev,DRM_MODE_PROP_IMMUTABLE |DRM_MODE_PROP_ATOMIC , +"SIZE" ,0 ,UINT_MAX ); +if (!prop) +return -ENOMEM ; + + colorop->lut_size_property = prop;
I'm a bit confused here. The property itself is just called "SIZE" which looks very similar to the generic "DATA" property. However, it is assigned to lut_size_property.
Is this meant to be to be a generic property where the exact usage depends on the type of the color op (like "DATA"), or is this meant to be specific to LUTs (in which case the generic name is misleading)?
I also tried to find the user space documentation for all the properties but could not find them. The only thing I could find was the kernel documentation of
struct drm_property *lut_size_property;
Which says "Size property for custom LUT from userspace."
Quoted 91 lines
drivers/gpu/drm/drm_colorop.c +15
-0+drm_object_attach_property (&colorop->base, colorop->lut_size_property, lut_size); + colorop->lut_size = lut_size; + +/* data */ + ret =drm_colorop_create_data_prop (dev, colorop); +if (ret) +return ret; + +drm_colorop_reset (colorop); + +return 0 ; +} +EXPORT_SYMBOL (drm_plane_colorop_curve_1d_lut_init); +int drm_plane_colorop_ctm_3x4_init (struct drm_device *dev,struct drm_colorop *colorop,struct drm_plane *plane) {@@ -373,6 +415,7 @@ void drm_colorop_reset(struct drm_colorop *colorop)static const char *const colorop_type_name[] = { [DRM_COLOROP_1D_CURVE ] ="1D Curve" , + [DRM_COLOROP_1D_LUT ] ="1D LUT" , [DRM_COLOROP_CTM_3X4 ] ="3x4 Matrix" , };include/drm/drm_colorop.h +16
-0@@ -259,6 +259,13 @@ struct drm_colorop {*/ struct drm_property *bypass_property; +/** +* @lut_size: +* +* Number of entries of the custom LUT. This should be read-only. +*/ +uint32_t lut_size; +/** * @curve_1d_type_property: * @@ -266,6 +273,13 @@ struct drm_colorop {*/ struct drm_property *curve_1d_type_property; +/** +* @lut_size_property: +* +* Size property for custom LUT from userspace. +*/ +struct drm_property *lut_size_property; +/** * @data_property: * @@ -312,6 +326,8 @@ void drm_colorop_pipeline_destroy(struct drm_device *dev);int drm_plane_colorop_curve_1d_init (struct drm_device *dev,struct drm_colorop *colorop,struct drm_plane *plane,u64 supported_tfs); +int drm_plane_colorop_curve_1d_lut_init (struct drm_device *dev,struct drm_colorop *colorop, +struct drm_plane *plane,uint32_t lut_size);int drm_plane_colorop_ctm_3x4_init (struct drm_device *dev,struct drm_colorop *colorop,struct drm_plane *plane);include/uapi/drm/drm_mode.h +14
-0@@ -902,6 +902,20 @@ enum drm_colorop_type {*/ DRM_COLOROP_1D_CURVE , +/** +* @DRM_COLOROP_1D_LUT: +* +* enum string "1D LUT" +* +* A simple 1D LUT of uniformly spaced &drm_color_lut32 entries, +* packed into a blob via the DATA property. The driver's +* expected LUT size is advertised via the SIZE property. +* +* The DATA blob is an array of struct drm_color_lut32 with size +* of "lut_size". +*/ + DRM_COLOROP_1D_LUT, +/** * @DRM_COLOROP_CTM_3X4: *
Re: [PATCH V11 35/47] drm/colorop: Add 1D Curve Custom LUT type
Quoted 35 lines · Sebastian Wick
Quoted 17 lines
drivers/gpu/drm/drm_colorop.c +17
-0+/** +* drm_plane_colorop_curve_1d_lut_init - Initialize a DRM_COLOROP_1D_LUT +* +* @dev: DRM device +* @colorop: The drm_colorop object to initialize +* @plane: The associated drm_plane +* @lut_size: LUT size supported by driver +* @return zero on success, -E value on failure +*/ +int drm_plane_colorop_curve_1d_lut_init (struct drm_device *dev,struct drm_colorop *colorop, +struct drm_plane *plane,uint32_t lut_size) +{ +struct drm_property *prop; +int ret; + + ret =drm_plane_colorop_init (dev, colorop, plane,DRM_COLOROP_1D_LUT ); +if (ret)drivers/gpu/drm/drm_colorop.c static int drm_colorop_create_data_prop(struct drm_device *dev, struct drm_color · line 295
Quoted 10 lines
drivers/gpu/drm/drm_colorop.c +10
-0+return ret; + +/* initialize 1D LUT only attribute */ +/* LUT size */ + prop =drm_property_create_range (dev,DRM_MODE_PROP_IMMUTABLE |DRM_MODE_PROP_ATOMIC , +"SIZE" ,0 ,UINT_MAX ); +if (!prop) +return -ENOMEM ; + + colorop->lut_size_property = prop;I'm a bit confused here. The property itself is just called "SIZE" which looks very similar to the generic "DATA" property. However, it is assigned to
lut_size_property.Is this meant to be to be a generic property where the exact usage depends on the type of the color op (like "DATA"), or is this meant to be specific to LUTs (in which case the generic name is misleading)?
Quoted 7 lines
I also tried to find the user space documentation for all the properties but could not find them. The only thing I could find was the kernel documentation of
struct drm_property *lut_size_property;Which says "Size property for custom LUT from userspace."
In earlier version, this lut_size was specific to 1D LUT and 3D LUT has a dedicate lut size field in another struct, and lut_size_property is now used for both 1D and 3D LUTs.
Do you mean we clarify by making either changes?
1) "SIZE" to "LUT_SIZE"
-> specific to LUTs
2) "lut_size" and "lut_size_property" "size" and "size_property", respectively -> Can be reused in the future, if any.
Re: [PATCH V11 35/47] drm/colorop: Add 1D Curve Custom LUT type
Quoted 50 lines · Alex Hung
Quoted 35 lines · Sebastian Wick
Quoted 17 lines
drivers/gpu/drm/drm_colorop.c +17
-0+/** +* drm_plane_colorop_curve_1d_lut_init - Initialize a DRM_COLOROP_1D_LUT +* +* @dev: DRM device +* @colorop: The drm_colorop object to initialize +* @plane: The associated drm_plane +* @lut_size: LUT size supported by driver +* @return zero on success, -E value on failure +*/ +int drm_plane_colorop_curve_1d_lut_init (struct drm_device *dev,struct drm_colorop *colorop, +struct drm_plane *plane,uint32_t lut_size) +{ +struct drm_property *prop; +int ret; + + ret =drm_plane_colorop_init (dev, colorop, plane,DRM_COLOROP_1D_LUT ); +if (ret)drivers/gpu/drm/drm_colorop.c static int drm_colorop_create_data_prop(struct drm_device *dev, struct drm_color · line 295
Quoted 10 lines
drivers/gpu/drm/drm_colorop.c +10
-0+return ret; + +/* initialize 1D LUT only attribute */ +/* LUT size */ + prop =drm_property_create_range (dev,DRM_MODE_PROP_IMMUTABLE |DRM_MODE_PROP_ATOMIC , +"SIZE" ,0 ,UINT_MAX ); +if (!prop) +return -ENOMEM ; + + colorop->lut_size_property = prop;I'm a bit confused here. The property itself is just called "SIZE" which looks very similar to the generic "DATA" property. However, it is assigned to
lut_size_property.Is this meant to be to be a generic property where the exact usage depends on the type of the color op (like "DATA"), or is this meant to be specific to LUTs (in which case the generic name is misleading)?
Quoted 7 lines
I also tried to find the user space documentation for all the properties but could not find them. The only thing I could find was the kernel documentation of
struct drm_property *lut_size_property;Which says "Size property for custom LUT from userspace."
In earlier version, this
lut_sizewas specific to 1D LUT and 3D LUT has a dedicate lut size field in another struct, andlut_size_propertyis now used for both 1D and 3D LUTs.
Quoted 6 lines
Do you mean we clarify by making either changes?
1) "SIZE" to "LUT_SIZE"-> specific to LUTs 2) "lut_size" and "lut_size_property" "size" and "size_property", respectively -> Can be reused in the future, if any.
Yes! I would prefer "SIZE" as I can see other color op types which use the "DATA" prop to require this as well.
The documentation should also be adjusted to say that the meaning of the "SIZE" property depends on the color op type (same as with "DATA").
Re: [PATCH V11 35/47] drm/colorop: Add 1D Curve Custom LUT type
Quoted 2 lines
Yes! I would prefer "SIZE" as I can see other color op types which use the "DATA" prop to require this as well.
+1, no need to make it specific to luts.
PATCH v11 36/47 drm/amd/display: add shaper and blend colorops for 1D Curve Custom LUT
In reply to Alex HungThis patch adds colorops for custom 1D LUTs in the SHAPER and BLND HW blocks.
With this change the following IGT tests pass:kms_colorop --run plane-XR30-XR30-srgb_inv_eotf_lut kms_colorop --run plane-XR30-XR30-srgb_inv_eotf_lut-srgb_eotf_lut
The color pipeline now consists of the following colorops:
1. 1D curve colorop
2. 1D curve colorop
3. 1D LUT
4. 1D curve colorop
5. 1D LUT
The 1D curve colorops support sRGB, BT2020, and PQ scaled to 125.0.
---
v11:
- Update names from *_lut_32_* to *_lut32_* (Simon Ser)
- Remove redundant is_legacy from __drm_lut_32_to_dc_gamma
- Fix RGB 32bit extraction from LUT (Xaver Hugl)
v10:
- Support 32BIT RGB in 1D LUT with drm_color_lut_32 (Uma Shankar)
- Remove redundant DRM_ERROR(...)
v9:
- Update function names by _plane_ (Chaitanya Kumar Borah)
v8:
- Return error when __set_output_tf fails (Leo Li) -
v7:
- Initialize uint32_t blend_size = 0 by default (kernel test robot)
- Modify state->size to colorop->lut_size
.../amd/display/amdgpu_dm/amdgpu_dm_color.c | 300 +++++++++++++----- .../amd/display/amdgpu_dm/amdgpu_dm_colorop.c | 30 ++ 2 files changed, 251 insertions(+), 79 deletions(-)
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_color.c +221 -79
@@ -73,6 +73,7 @@*/ #define MAX_DRM_LUT_VALUE 0xFFFF +#define MAX_DRM_LUT32_VALUE 0xFFFFFFFF#define SDR_WHITE_LEVEL_INIT_VALUE 80/**
@@ -342,6 +343,21 @@ __extract_blob_lut(const struct drm_property_blob *blob, uint32_t *size)return blob ? (struct drm_color_lut *)blob->data :NULL ; } +/** +* __extract_blob_lut32 - Extracts the DRM lut and lut size from a blob. +* @blob: DRM color mgmt property blob +* @size: lut size +* +* Returns: +* DRM LUT or NULL +*/ +static const struct drm_color_lut32 * +__extract_blob_lut32 (const struct drm_property_blob *blob,uint32_t *size) +{ + *size = blob ?drm_color_lut32_size (blob) :0 ; +return blob ? (struct drm_color_lut32 *)blob->data :NULL ; +} +/** * __is_lut_linear - check if the given lut is a linear mapping of values * @lut: given lut to check values
@@ -415,6 +431,24 @@ static void __drm_lut_to_dc_gamma(const struct drm_color_lut *lut, } } +/** +* __drm_lut32_to_dc_gamma - convert the drm_color_lut to dc_gamma. +* @lut: DRM lookup table for color conversion +* @gamma: DC gamma to set entries +* +* The conversion depends on the size of the lut - whether or not it's legacy. +*/ +static void __drm_lut32_to_dc_gamma (const struct drm_color_lut32 *lut,struct dc_gamma *gamma) +{ +int i; + +for (i =0 ; i <MAX_COLOR_LUT_ENTRIES ; i++) { + gamma->entries.red[i] =dc_fixpt_from_fraction (lut[i].red,MAX_DRM_LUT32_VALUE ); + gamma->entries.green[i] =dc_fixpt_from_fraction (lut[i].green,MAX_DRM_LUT32_VALUE ); + gamma->entries.blue[i] =dc_fixpt_from_fraction (lut[i].blue,MAX_DRM_LUT32_VALUE ); + } +} +/** * __drm_ctm_to_dc_matrix - converts a DRM CTM to a DC CSC float matrix * @ctm: DRM color transformation matrix
@@ -567,6 +601,63 @@ static int __set_output_tf(struct dc_transfer_func *func,return res ?0 : -ENOMEM ; } +/** +* __set_output_tf_32 - calculates the output transfer function based on expected input space. +* @func: transfer function +* @lut: lookup table that defines the color space +* @lut_size: size of respective lut +* @has_rom: if ROM can be used for hardcoded curve +* +* Returns: +* 0 in case of success. -ENOMEM if fails. +*/ +static int __set_output_tf_32 (struct dc_transfer_func *func, +const struct drm_color_lut32 *lut,uint32_t lut_size, +bool has_rom) +{ +struct dc_gamma *gamma =NULL ; +struct calculate_buffer cal_buffer = {0 }; +bool res; + + cal_buffer.buffer_index =-1 ; + +if (lut_size) { + gamma =dc_create_gamma (); +if (!gamma) +return -ENOMEM ; + + gamma->num_entries = lut_size; +__drm_lut32_to_dc_gamma (lut, gamma); + } + +if (func->tf ==TRANSFER_FUNCTION_LINEAR ) { +/* +* Color module doesn't like calculating regamma params +* on top of a linear input. But degamma params can be used +* instead to simulate this. +*/ +if (gamma) + gamma->type =GAMMA_CUSTOM ; + res =mod_color_calculate_degamma_params (NULL , func, + gamma, gamma !=NULL ); + }else { +/* +* Assume sRGB. The actual mapping will depend on whether the +* input was legacy or not. +*/ +if (gamma) + gamma->type =GAMMA_CS_TFM_1D ; + res =mod_color_calculate_regamma_params (func, gamma, gamma !=NULL , + has_rom,NULL , &cal_buffer); + } + +if (gamma) +dc_gamma_release (&gamma); + +return res ?0 : -ENOMEM ; +} + + static int amdgpu_dm_set_atomic_regamma(struct dc_stream_state *stream, const struct drm_color_lut *regamma_lut, uint32_t regamma_size, bool has_rom,
@@ -640,6 +731,42 @@ static int __set_input_tf(struct dc_color_caps *caps, struct dc_transfer_func *freturn res ?0 : -ENOMEM ; } +/** +* __set_input_tf_32 - calculates the input transfer function based on expected +* input space. +* @caps: dc color capabilities +* @func: transfer function +* @lut: lookup table that defines the color space +* @lut_size: size of respective lut. +* +* Returns: +* 0 in case of success. -ENOMEM if fails. +*/ +static int __set_input_tf_32 (struct dc_color_caps *caps,struct dc_transfer_func *func, +const struct drm_color_lut32 *lut,uint32_t lut_size) +{ +struct dc_gamma *gamma =NULL ; +bool res; + +if (lut_size) { + gamma =dc_create_gamma (); +if (!gamma) +return -ENOMEM ; + + gamma->type =GAMMA_CUSTOM ; + gamma->num_entries = lut_size; + +__drm_lut32_to_dc_gamma (lut, gamma); + } + + res =mod_color_calculate_degamma_params (caps, func, gamma, gamma !=NULL ); + +if (gamma) +dc_gamma_release (&gamma); + +return res ?0 : -ENOMEM ; +} +static enum dc_transfer_func_predefined amdgpu_tf_to_dc_tf (enum amdgpu_transfer_function tf) {
@@ -1211,38 +1338,6 @@ __set_dm_plane_colorop_degamma(struct drm_plane_state *plane_state,return __set_colorop_in_tf_1d_curve (dc_plane_state, colorop_state); } -static int -__set_colorop_in_shaper_1d_curve (struct dc_plane_state *dc_plane_state, -struct drm_colorop_state *colorop_state) -{ -struct dc_transfer_func *tf = &dc_plane_state->in_shaper_func; -struct drm_colorop *colorop = colorop_state->colorop; -struct drm_device *drm = colorop->dev; - -if (colorop->type !=DRM_COLOROP_1D_CURVE ) -return -EINVAL ; - -if (!(BIT (colorop_state->curve_1d_type) & amdgpu_dm_supported_shaper_tfs)) -return -EINVAL ; - -if (colorop_state->bypass) { - tf->type =TF_TYPE_BYPASS ; - tf->tf =TRANSFER_FUNCTION_LINEAR ; -return 0 ; - } - -drm_dbg (drm,"Shaper colorop with ID: %d\n" , colorop->base.id); - -if (colorop->type ==DRM_COLOROP_1D_CURVE ) { - tf->type =TF_TYPE_DISTRIBUTED_POINTS ; - tf->tf =amdgpu_colorop_tf_to_dc_tf (colorop_state->curve_1d_type); - tf->sdr_ref_white_level =SDR_WHITE_LEVEL_INIT_VALUE ; -return __set_output_tf (tf,0 ,0 , false); - } - -return -EINVAL ; -} - static int __set_dm_plane_colorop_shaper(struct drm_plane_state *plane_state, struct dc_plane_state *dc_plane_state,
@@ -1251,64 +1346,66 @@ __set_dm_plane_colorop_shaper(struct drm_plane_state *plane_state,struct drm_colorop *old_colorop;struct drm_colorop_state *colorop_state =NULL , *new_colorop_state;struct drm_atomic_state *state = plane_state->state; -int i =0 ; +enum dc_transfer_func_predefined default_tf =TRANSFER_FUNCTION_LINEAR ; +struct dc_transfer_func *tf = &dc_plane_state->in_shaper_func; +const struct drm_color_lut32 *shaper_lut; +struct drm_device *dev = colorop->dev; +uint32_t shaper_size; +int i =0 , ret =0 ; +/* 1D Curve - SHAPER TF */ old_colorop = colorop; - -/* 2nd op: 1d curve - shaper */ for_each_new_colorop_in_state (state, colorop, new_colorop_state, i) {if (new_colorop_state->colorop == old_colorop && (BIT (new_colorop_state->curve_1d_type) & amdgpu_dm_supported_shaper_tfs)) { colorop_state = new_colorop_state;break ; } - -if (new_colorop_state->colorop == old_colorop) { - colorop_state = new_colorop_state; -break ; - } } -if (!colorop_state) -return -EINVAL ; - -return __set_colorop_in_shaper_1d_curve (dc_plane_state, colorop_state); -} - - -static int -__set_colorop_1d_curve_blend_tf_lut (struct dc_plane_state *dc_plane_state, -struct drm_colorop_state *colorop_state) -{ - -struct dc_transfer_func *tf = &dc_plane_state->blend_tf; -struct drm_colorop *colorop = colorop_state->colorop; -struct drm_device *drm = colorop->dev; -const struct drm_color_lut *blend_lut; -uint32_t blend_size =0 ; - -if (colorop->type !=DRM_COLOROP_1D_CURVE ) -return -EINVAL ; +if (colorop_state && !colorop_state->bypass && colorop->type ==DRM_COLOROP_1D_CURVE ) { +drm_dbg (dev,"Shaper TF colorop with ID: %d\n" , colorop->base.id); + tf->type =TF_TYPE_DISTRIBUTED_POINTS ; + tf->tf = default_tf =amdgpu_colorop_tf_to_dc_tf (colorop_state->curve_1d_type); + tf->sdr_ref_white_level =SDR_WHITE_LEVEL_INIT_VALUE ; + ret =__set_output_tf (tf,0 ,0 , false); +if (ret) +return ret; + } -if (!(BIT (colorop_state->curve_1d_type) & amdgpu_dm_supported_blnd_tfs)) +/* 1D LUT - SHAPER LUT */ + colorop = old_colorop->next; +if (!colorop) { +drm_dbg (dev,"no Shaper LUT colorop found\n" );return -EINVAL ; - -if (colorop_state->bypass) { - tf->type =TF_TYPE_BYPASS ; - tf->tf =TRANSFER_FUNCTION_LINEAR ; -return 0 ; } -drm_dbg (drm,"Blend colorop with ID: %d\n" , colorop->base.id); + old_colorop = colorop; +for_each_new_colorop_in_state (state, colorop, new_colorop_state, i) { +if (new_colorop_state->colorop == old_colorop && + new_colorop_state->colorop->type ==DRM_COLOROP_1D_LUT ) { + colorop_state = new_colorop_state; +break ; + } + } -if (colorop->type ==DRM_COLOROP_1D_CURVE ) { +if (colorop_state && !colorop_state->bypass && colorop->type ==DRM_COLOROP_1D_LUT ) { +drm_dbg (dev,"Shaper LUT colorop with ID: %d\n" , colorop->base.id); tf->type =TF_TYPE_DISTRIBUTED_POINTS ; - tf->tf =amdgpu_colorop_tf_to_dc_tf (colorop_state->curve_1d_type); + tf->tf = default_tf; tf->sdr_ref_white_level =SDR_WHITE_LEVEL_INIT_VALUE ; -return __set_input_tf (NULL , tf, blend_lut, blend_size); + shaper_lut =__extract_blob_lut32 (colorop_state->data, &shaper_size); + shaper_size = shaper_lut !=NULL ? shaper_size :0 ; + +/* Custom LUT size must be the same as supported size */ +if (shaper_size == colorop->lut_size) { + ret =__set_output_tf_32 (tf, shaper_lut, shaper_size, false); +if (ret) +return ret; + } } -return -EINVAL ; +return 0 ; } static int
@@ -1319,28 +1416,63 @@ __set_dm_plane_colorop_blend(struct drm_plane_state *plane_state,struct drm_colorop *old_colorop;struct drm_colorop_state *colorop_state =NULL , *new_colorop_state;struct drm_atomic_state *state = plane_state->state; +enum dc_transfer_func_predefined default_tf =TRANSFER_FUNCTION_LINEAR ; +struct dc_transfer_func *tf = &dc_plane_state->blend_tf; +const struct drm_color_lut32 *blend_lut; +struct drm_device *dev = colorop->dev; +uint32_t blend_size;int i =0 ; +/* 1D Curve - BLND TF */ old_colorop = colorop; - -/* 3nd op: 1d curve - blend */ for_each_new_colorop_in_state (state, colorop, new_colorop_state, i) {if (new_colorop_state->colorop == old_colorop && (BIT (new_colorop_state->curve_1d_type) & amdgpu_dm_supported_blnd_tfs)) { colorop_state = new_colorop_state;break ; } + } -if (new_colorop_state->colorop == old_colorop) { +if (colorop_state && !colorop_state->bypass && colorop->type ==DRM_COLOROP_1D_CURVE && + (BIT (colorop_state->curve_1d_type) & amdgpu_dm_supported_blnd_tfs)) { +drm_dbg (dev,"Blend TF colorop with ID: %d\n" , colorop->base.id); + tf->type =TF_TYPE_DISTRIBUTED_POINTS ; + tf->tf = default_tf =amdgpu_colorop_tf_to_dc_tf (colorop_state->curve_1d_type); + tf->sdr_ref_white_level =SDR_WHITE_LEVEL_INIT_VALUE ; +__set_input_tf_32 (NULL , tf, blend_lut, blend_size); + } + +/* 1D Curve - BLND LUT */ + colorop = old_colorop->next; +if (!colorop) { +drm_dbg (dev,"no Blend LUT colorop found\n" ); +return -EINVAL ; + } + + old_colorop = colorop; +for_each_new_colorop_in_state (state, colorop, new_colorop_state, i) { +if (new_colorop_state->colorop == old_colorop && + new_colorop_state->colorop->type ==DRM_COLOROP_1D_LUT ) { colorop_state = new_colorop_state;break ; } } -if (!colorop_state) -return -EINVAL ; +if (colorop_state && !colorop_state->bypass && colorop->type ==DRM_COLOROP_1D_LUT && + (BIT (colorop_state->curve_1d_type) & amdgpu_dm_supported_blnd_tfs)) { +drm_dbg (dev,"Blend LUT colorop with ID: %d\n" , colorop->base.id); + tf->type =TF_TYPE_DISTRIBUTED_POINTS ; + tf->tf = default_tf; + tf->sdr_ref_white_level =SDR_WHITE_LEVEL_INIT_VALUE ; + blend_lut =__extract_blob_lut32 (colorop_state->data, &blend_size); + blend_size = blend_lut !=NULL ? blend_size :0 ; -return __set_colorop_1d_curve_blend_tf_lut (dc_plane_state, colorop_state); +/* Custom LUT size must be the same as supported size */ +if (blend_size == colorop->lut_size) +__set_input_tf_32 (NULL , tf, blend_lut, blend_size); + } + +return 0 ; } static int
@@ -1409,7 +1541,7 @@ amdgpu_dm_plane_set_colorop_properties(struct drm_plane_state *plane_state,if (ret)return ret; -/* 1D Curve - SHAPER TF */ +/* 1D Curve & LUT - SHAPER TF & LUT */ colorop = colorop->next;if (!colorop) {drm_dbg (dev,"no Shaper TF colorop found\n" );
@@ -1420,7 +1552,12 @@ amdgpu_dm_plane_set_colorop_properties(struct drm_plane_state *plane_state,if (ret)return ret; -/* 1D Curve - BLND TF */ +/* Shaper LUT colorop is already handled, just skip here */ + colorop = colorop->next; +if (!colorop) +return -EINVAL ; + +/* 1D Curve & LUT - BLND TF & LUT */ colorop = colorop->next;if (!colorop) {drm_dbg (dev,"no Blend TF colorop found\n" );
@@ -1431,6 +1568,11 @@ amdgpu_dm_plane_set_colorop_properties(struct drm_plane_state *plane_state,if (ret)return ret; +/* BLND LUT colorop is already handled, just skip here */ + colorop = colorop->next; +if (!colorop) +return -EINVAL ; +return 0 ; }
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_colorop.c +30 -0
@@ -29,6 +29,7 @@#include <drm/drm_property.h> #include <drm/drm_colorop.h> +#include "amdgpu.h" #include "amdgpu_dm_colorop.h" const u64 amdgpu_dm_supported_degam_tfs =
@@ -88,6 +89,21 @@ int amdgpu_dm_initialize_default_pipeline(struct drm_plane *plane, struct drm_pr i++; +/* 1D LUT - SHAPER LUT */ + ops[i] =kzalloc (sizeof (struct drm_colorop ),GFP_KERNEL ); +if (!ops[i]) { + ret = -ENOMEM ; + goto cleanup; + } + + ret =drm_plane_colorop_curve_1d_lut_init (dev, ops[i], plane,MAX_COLOR_LUT_ENTRIES ); +if (ret) + goto cleanup; + +drm_colorop_set_next_property (ops[i-1 ], ops[i]); + + i++; +/* 1D curve - BLND TF */ ops[i] =kzalloc (sizeof (struct drm_colorop ),GFP_KERNEL );if (!ops[i]) {
@@ -101,6 +117,20 @@ int amdgpu_dm_initialize_default_pipeline(struct drm_plane *plane, struct drm_prdrm_colorop_set_next_property (ops[i-1 ], ops[i]); + i++; + +/* 1D LUT - BLND LUT */ + ops[i] =kzalloc (sizeof (struct drm_colorop ),GFP_KERNEL ); +if (!ops[i]) { + ret = -ENOMEM ; + goto cleanup; + } + + ret =drm_plane_colorop_curve_1d_lut_init (dev, ops[i], plane,MAX_COLOR_LUT_ENTRIES ); +if (ret) + goto cleanup; + +drm_colorop_set_next_property (ops[i-1 ], ops[i]);return 0 ; cleanup:
Signature · 1 line
2.43.0
PATCH v11 37/47 drm/amd/display: add 3x4 matrix colorop
In reply to Alex HungThis adds support for a 3x4 color transformation matrix.
With this change the following IGT tests pass:kms_colorop --run plane-XR30-XR30-ctm_3x4_50_desat kms_colorop --run plane-XR30-XR30-ctm_3x4_overdrive kms_colorop --run plane-XR30-XR30-ctm_3x4_oversaturate kms_colorop --run plane-XR30-XR30-ctm_3x4_bt709_enc kms_colorop --run plane-XR30-XR30-ctm_3x4_bt709_dec
The color pipeline now consists of the following colorops:
1. 1D curve colorop
2. 3x4 CTM
3. 1D curve colorop
4. 1D LUT
5. 1D curve colorop
6. 1D LUT
---
V10:
- Change %lu to %zu for sizeof() in drm_warn (kernel test robot)
- Remove redundant DRM_ERROR(...)
V9:
- Update function names by _plane_ (Chaitanya Kumar Borah)
v8:
- Return -EINVAL when drm_color_ctm_3x4's size mismatches (Leo Li)
v7:
- Change %lu to %zu for sizeof() in drm_warn
v6:
- fix warnings in dbg prints
.../amd/display/amdgpu_dm/amdgpu_dm_color.c | 52 +++++++++++++++++++ .../amd/display/amdgpu_dm/amdgpu_dm_colorop.c | 15 ++++++ 2 files changed, 67 insertions(+)
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_color.c +52 -0
@@ -1338,6 +1338,47 @@ __set_dm_plane_colorop_degamma(struct drm_plane_state *plane_state,return __set_colorop_in_tf_1d_curve (dc_plane_state, colorop_state); } +static int +__set_dm_plane_colorop_3x4_matrix (struct drm_plane_state *plane_state, +struct dc_plane_state *dc_plane_state, +struct drm_colorop *colorop) +{ +struct drm_colorop *old_colorop; +struct drm_colorop_state *colorop_state =NULL , *new_colorop_state; +struct drm_atomic_state *state = plane_state->state; +const struct drm_device *dev = colorop->dev; +const struct drm_property_blob *blob; +struct drm_color_ctm_3x4 *ctm =NULL ; +int i =0 ; + +/* 3x4 matrix */ + old_colorop = colorop; +for_each_new_colorop_in_state (state, colorop, new_colorop_state, i) { +if (new_colorop_state->colorop == old_colorop && + new_colorop_state->colorop->type ==DRM_COLOROP_CTM_3X4 ) { + colorop_state = new_colorop_state; +break ; + } + } + +if (colorop_state && !colorop_state->bypass && colorop->type ==DRM_COLOROP_CTM_3X4 ) { +drm_dbg (dev,"3x4 matrix colorop with ID: %d\n" , colorop->base.id); + blob = colorop_state->data; +if (blob->length ==sizeof (struct drm_color_ctm_3x4 )) { + ctm = blob ? (struct drm_color_ctm_3x4 *) blob->data :NULL ; +__drm_ctm_3x4_to_dc_matrix (ctm, dc_plane_state->gamut_remap_matrix.matrix); + dc_plane_state->gamut_remap_matrix.enable_remap = true; + dc_plane_state->input_csc_color_matrix.enable_adjustment = false; + }else { +drm_warn (dev,"blob->length (%zu) isn't equal to drm_color_ctm_3x4 (%zu)\n" , + blob->length,sizeof (struct drm_color_ctm_3x4 )); +return -EINVAL ; + } + } + +return 0 ; +} + static int __set_dm_plane_colorop_shaper(struct drm_plane_state *plane_state, struct dc_plane_state *dc_plane_state,
@@ -1541,6 +1582,17 @@ amdgpu_dm_plane_set_colorop_properties(struct drm_plane_state *plane_state,if (ret)return ret; +/* 3x4 matrix */ + colorop = colorop->next; +if (!colorop) { +drm_dbg (dev,"no 3x4 matrix colorop found\n" ); +return -EINVAL ; + } + + ret =__set_dm_plane_colorop_3x4_matrix (plane_state, dc_plane_state, colorop); +if (ret) +return ret; +/* 1D Curve & LUT - SHAPER TF & LUT */ colorop = colorop->next;if (!colorop) {
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_colorop.c +15 -0
@@ -74,6 +74,21 @@ int amdgpu_dm_initialize_default_pipeline(struct drm_plane *plane, struct drm_pr i++; +/* 3x4 matrix */ + ops[i] =kzalloc (sizeof (struct drm_colorop ),GFP_KERNEL ); +if (!ops[i]) { + ret = -ENOMEM ; + goto cleanup; + } + + ret =drm_plane_colorop_ctm_3x4_init (dev, ops[i], plane); +if (ret) + goto cleanup; + +drm_colorop_set_next_property (ops[i-1 ], ops[i]); + + i++; +/* 1D curve - SHAPER TF */ ops[i] =kzalloc (sizeof (struct drm_colorop ),GFP_KERNEL );if (!ops[i]) {
Signature · 1 line
2.43.0
PATCH v11 38/47 drm/colorop: Add multiplier type
In reply to Alex HungThis introduces a new drm_colorop_type: DRM_COLOROP_MULTIPLIER.
It's a simple multiplier to all pixel values. The value is specified via a S31.32 fixed point provided via the "MULTIPLIER" property.
---
v10:
- Fix typo of mutliplier to multiplier in subject (Melissa Wen)
V9:
- Update function names by _plane_ (Chaitanya Kumar Borah)
v7:
- Modify size_property to lut_size_property
drivers/gpu/drm/drm_atomic.c | 3 +++ drivers/gpu/drm/drm_atomic_uapi.c | 4 ++++ drivers/gpu/drm/drm_colorop.c | 33 +++++++++++++++++++++++++++++++ include/drm/drm_colorop.h | 16 +++++++++++++++ include/uapi/drm/drm_mode.h | 11 +++++++++++ 5 files changed, 67 insertions(+)
drivers/gpu/drm/drm_atomic.c +3 -0
@@ -800,6 +800,9 @@ static void drm_atomic_colorop_print_state(struct drm_printer *p,case DRM_COLOROP_CTM_3X4 :drm_printf (p,"\tdata blob id=%d\n" , state->data ? state->data->base.id :0 );break ; +case DRM_COLOROP_MULTIPLIER : +drm_printf (p,"\tmultiplier=%llu\n" , state->multiplier); +break ;default :break ; }
drivers/gpu/drm/drm_atomic_uapi.c +4 -0
@@ -724,6 +724,8 @@ static int drm_atomic_colorop_set_property(struct drm_colorop *colorop, state->bypass = val; }else if (property == colorop->curve_1d_type_property) { state->curve_1d_type = val; + }else if (property == colorop->multiplier_property) { + state->multiplier = val; }else if (property == colorop->data_property) {return drm_atomic_color_set_data_property (colorop, state, property, val);
@@ -749,6 +751,8 @@ drm_atomic_colorop_get_property(struct drm_colorop *colorop, *val = state->bypass; }else if (property == colorop->curve_1d_type_property) { *val = state->curve_1d_type; + }else if (property == colorop->multiplier_property) { + *val = state->multiplier; }else if (property == colorop->lut_size_property) { *val = colorop->lut_size; }else if (property == colorop->data_property) {
drivers/gpu/drm/drm_colorop.c +33 -0
@@ -66,6 +66,7 @@ static const struct drm_prop_enum_list drm_colorop_type_enum_list[] = { { DRM_COLOROP_1D_CURVE, "1D Curve" }, { DRM_COLOROP_1D_LUT, "1D LUT" }, { DRM_COLOROP_CTM_3X4, "3x4 Matrix"}, + { DRM_COLOROP_MULTIPLIER, "Multiplier"}, }; static const char * const colorop_curve_1d_type_names[] = {
@@ -326,6 +327,37 @@ int drm_plane_colorop_ctm_3x4_init(struct drm_device *dev, struct drm_colorop *c }EXPORT_SYMBOL (drm_plane_colorop_ctm_3x4_init); +/** +* drm_plane_colorop_mult_init - Initialize a DRM_COLOROP_MULTIPLIER +* +* @dev: DRM device +* @colorop: The drm_colorop object to initialize +* @plane: The associated drm_plane +* @return zero on success, -E value on failure +*/ +int drm_plane_colorop_mult_init (struct drm_device *dev,struct drm_colorop *colorop, +struct drm_plane *plane) +{ +struct drm_property *prop; +int ret; + + ret =drm_plane_colorop_init (dev, colorop, plane,DRM_COLOROP_MULTIPLIER ); +if (ret) +return ret; + + prop =drm_property_create_range (dev,DRM_MODE_PROP_ATOMIC ,"MULTIPLIER" ,0 ,U64_MAX ); +if (!prop) +return -ENOMEM ; + + colorop->multiplier_property = prop; +drm_object_attach_property (&colorop->base, colorop->multiplier_property,0 ); + +drm_colorop_reset (colorop); + +return 0 ; +} +EXPORT_SYMBOL (drm_plane_colorop_mult_init); +static void __drm_atomic_helper_colorop_duplicate_state (struct drm_colorop *colorop,struct drm_colorop_state *state) {
@@ -417,6 +449,7 @@ static const char * const colorop_type_name[] = { [DRM_COLOROP_1D_CURVE] = "1D Curve", [DRM_COLOROP_1D_LUT] = "1D LUT", [DRM_COLOROP_CTM_3X4] = "3x4 Matrix", + [DRM_COLOROP_MULTIPLIER] = "Multiplier", };const char *drm_get_colorop_type_name (enum drm_colorop_type type)
include/drm/drm_colorop.h +16 -0
@@ -146,6 +146,13 @@ struct drm_colorop_state {*/ enum drm_colorop_curve_1d_type curve_1d_type; +/** +* @multiplier: +* +* Multiplier to 'gain' the plane. Format is S31.32 sign-magnitude. +*/ +uint64_t multiplier; +/** * @data: *
@@ -273,6 +280,13 @@ struct drm_colorop {*/ struct drm_property *curve_1d_type_property; +/** +* @multiplier_property: +* +* Multiplier property for plane gain +*/ +struct drm_property *multiplier_property; +/** * @lut_size_property: *
@@ -330,6 +344,8 @@ int drm_plane_colorop_curve_1d_lut_init(struct drm_device *dev, struct drm_color struct drm_plane *plane, uint32_t lut_size);int drm_plane_colorop_ctm_3x4_init (struct drm_device *dev,struct drm_colorop *colorop,struct drm_plane *plane); +int drm_plane_colorop_mult_init (struct drm_device *dev,struct drm_colorop *colorop, +struct drm_plane *plane);struct drm_colorop_state *drm_atomic_helper_colorop_duplicate_state (struct drm_colorop *colorop);
include/uapi/drm/drm_mode.h +11 -0
@@ -931,6 +931,17 @@ enum drm_colorop_type {* | B | | 8 9 10 12 | | B | */ DRM_COLOROP_CTM_3X4 , + +/** +* @DRM_COLOROP_MULTIPLIER: +* +* enum string "Multiplier" +* +* A simple multiplier, applied to all color values. The +* multiplier is specified as a S31.32 via the MULTIPLIER +* property. +*/ + DRM_COLOROP_MULTIPLIER, };/**
Signature · 1 line
2.43.0
PATCH v11 39/47 drm/amd/display: add multiplier colorop
In reply to Alex HungThis adds support for a multiplier. This multiplier is programmed via the HDR Multiplier in DCN.
With this change the following IGT tests pass:kms_colorop --run plane-XR30-XR30-multiply_125 kms_colorop --run plane-XR30-XR30-multiply_inv_125
The color pipeline now consists of the following colorops:
1. 1D curve colorop
2. 3x4 CTM
3. Multiplier
4. 1D curve colorop
5. 1D LUT
6. 1D curve colorop
7. 1D LUT
---
v10:
- Remove redundant DRM_ERROR(...)
v9:
- Update function names by _plane_ (Chaitanya Kumar Borah)
.../amd/display/amdgpu_dm/amdgpu_dm_color.c | 40 +++++++++++++++++++ .../amd/display/amdgpu_dm/amdgpu_dm_colorop.c | 15 +++++++ 2 files changed, 55 insertions(+)
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_color.c +40 -0
@@ -1379,6 +1379,35 @@ __set_dm_plane_colorop_3x4_matrix(struct drm_plane_state *plane_state,return 0 ; } +static int +__set_dm_plane_colorop_multiplier (struct drm_plane_state *plane_state, +struct dc_plane_state *dc_plane_state, +struct drm_colorop *colorop) +{ +struct drm_colorop *old_colorop; +struct drm_colorop_state *colorop_state =NULL , *new_colorop_state; +struct drm_atomic_state *state = plane_state->state; +const struct drm_device *dev = colorop->dev; +int i =0 ; + +/* Multiplier */ + old_colorop = colorop; +for_each_new_colorop_in_state (state, colorop, new_colorop_state, i) { +if (new_colorop_state->colorop == old_colorop && + new_colorop_state->colorop->type ==DRM_COLOROP_MULTIPLIER ) { + colorop_state = new_colorop_state; +break ; + } + } + +if (colorop_state && !colorop_state->bypass && colorop->type ==DRM_COLOROP_MULTIPLIER ) { +drm_dbg (dev,"Multiplier colorop with ID: %d\n" , colorop->base.id); + dc_plane_state->hdr_mult =amdgpu_dm_fixpt_from_s3132 (colorop_state->multiplier); + } + +return 0 ; +} + static int __set_dm_plane_colorop_shaper(struct drm_plane_state *plane_state, struct dc_plane_state *dc_plane_state,
@@ -1593,6 +1622,17 @@ amdgpu_dm_plane_set_colorop_properties(struct drm_plane_state *plane_state,if (ret)return ret; +/* Multiplier */ + colorop = colorop->next; +if (!colorop) { +drm_dbg (dev,"no multiplier colorop found\n" ); +return -EINVAL ; + } + + ret =__set_dm_plane_colorop_multiplier (plane_state, dc_plane_state, colorop); +if (ret) +return ret; +/* 1D Curve & LUT - SHAPER TF & LUT */ colorop = colorop->next;if (!colorop) {
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_colorop.c +15 -0
@@ -89,6 +89,21 @@ int amdgpu_dm_initialize_default_pipeline(struct drm_plane *plane, struct drm_pr i++; +/* Multiplier */ + ops[i] =kzalloc (sizeof (struct drm_colorop ),GFP_KERNEL ); +if (!ops[i]) { + ret = -ENOMEM ; + goto cleanup; + } + + ret =drm_plane_colorop_mult_init (dev, ops[i], plane); +if (ret) + goto cleanup; + +drm_colorop_set_next_property (ops[i-1 ], ops[i]); + + i++; +/* 1D curve - SHAPER TF */ ops[i] =kzalloc (sizeof (struct drm_colorop ),GFP_KERNEL );if (!ops[i]) {
Signature · 1 line
2.43.0
PATCH v11 40/47 drm/amd/display: Swap matrix and multiplier
In reply to Alex HungSwap the order of matrix and multiplier as designed in hardware.
---
v9:
- Update function names by _plane_ (Chaitanya Kumar Borah)
.../gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_color.c | 12 ++++++------ .../drm/amd/display/amdgpu_dm/amdgpu_dm_colorop.c | 8 ++++---- 2 files changed, 10 insertions(+), 10 deletions(-)
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_color.c +6 -6
@@ -1611,25 +1611,25 @@ amdgpu_dm_plane_set_colorop_properties(struct drm_plane_state *plane_state,if (ret)return ret; -/* 3x4 matrix */ +/* Multiplier */ colorop = colorop->next;if (!colorop) { -drm_dbg (dev,"no 3x4 matrix colorop found\n" ); +drm_dbg (dev,"no multiplier colorop found\n" );return -EINVAL ; } - ret =__set_dm_plane_colorop_3x4_matrix (plane_state, dc_plane_state, colorop); + ret =__set_dm_plane_colorop_multiplier (plane_state, dc_plane_state, colorop);if (ret)return ret; -/* Multiplier */ +/* 3x4 matrix */ colorop = colorop->next;if (!colorop) { -drm_dbg (dev,"no multiplier colorop found\n" ); +drm_dbg (dev,"no 3x4 matrix colorop found\n" );return -EINVAL ; } - ret =__set_dm_plane_colorop_multiplier (plane_state, dc_plane_state, colorop); + ret =__set_dm_plane_colorop_3x4_matrix (plane_state, dc_plane_state, colorop);if (ret)return ret;
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_colorop.c +4 -4
@@ -74,14 +74,14 @@ int amdgpu_dm_initialize_default_pipeline(struct drm_plane *plane, struct drm_pr i++; -/* 3x4 matrix */ +/* Multiplier */ ops[i] =kzalloc (sizeof (struct drm_colorop ),GFP_KERNEL );if (!ops[i]) { ret = -ENOMEM ; goto cleanup; } - ret =drm_plane_colorop_ctm_3x4_init (dev, ops[i], plane); + ret =drm_plane_colorop_mult_init (dev, ops[i], plane);if (ret) goto cleanup;
@@ -89,14 +89,14 @@ int amdgpu_dm_initialize_default_pipeline(struct drm_plane *plane, struct drm_pr i++; -/* Multiplier */ +/* 3x4 matrix */ ops[i] =kzalloc (sizeof (struct drm_colorop ),GFP_KERNEL );if (!ops[i]) { ret = -ENOMEM ; goto cleanup; } - ret =drm_plane_colorop_mult_init (dev, ops[i], plane); + ret =drm_plane_colorop_ctm_3x4_init (dev, ops[i], plane);if (ret) goto cleanup;
Signature · 1 line
2.43.0