Draft: migrate color mgmt from AMD driver specific properties to new KMS color API#2113
Draft: migrate color mgmt from AMD driver specific properties to new KMS color API#2113melissawen wants to merge 21 commits into
Conversation
d1e4e71 to
1a56328
Compare
|
@melissawen feel free to just squash this into one of your existing commits or replace it with your own version, but I was getting what appeared to be a "deep-fried" image when testing this on Steam Deck OLED with a kernel built from the branch you linked plus the fixes that have been sent out on amd-gfx while compositing an image. it looked like color management was being applied twice even though scanout was fine. this fixed the issue on my end after digging into why it was only occurring with the color pipeline path: matte-schwartz@e097b54 |
|
Hi @matte-schwartz, thanks for testing and debugging. I'll add your commit to this branch. Indeed, your fix is aligned with the AMD driver-specific-prop path. |
|
Thanks a lot for pushing this forward! I won't have time to review sadly. |
|
lgtm |
| DRM_COLOROP_1D_CURVE_SRGB_EOTF, | ||
| DRM_COLOROP_1D_CURVE_SRGB_INV_EOTF, | ||
| DRM_COLOROP_1D_CURVE_PQ_125_EOTF, | ||
| DRM_COLOROP_1D_CURVE_PQ_125_INV_EOTF, | ||
| DRM_COLOROP_1D_CURVE_BT2020_INV_OETF, | ||
| DRM_COLOROP_1D_CURVE_BT2020_OETF, | ||
| DRM_COLOROP_1D_CURVE_GAMMA22, | ||
| DRM_COLOROP_1D_CURVE_GAMMA22_INV, | ||
| DRM_COLOROP_1D_CURVE_COUNT |
There was a problem hiding this comment.
| DRM_COLOROP_1D_CURVE_SRGB_EOTF, | |
| DRM_COLOROP_1D_CURVE_SRGB_INV_EOTF, | |
| DRM_COLOROP_1D_CURVE_PQ_125_EOTF, | |
| DRM_COLOROP_1D_CURVE_PQ_125_INV_EOTF, | |
| DRM_COLOROP_1D_CURVE_BT2020_INV_OETF, | |
| DRM_COLOROP_1D_CURVE_BT2020_OETF, | |
| DRM_COLOROP_1D_CURVE_GAMMA22, | |
| DRM_COLOROP_1D_CURVE_GAMMA22_INV, | |
| DRM_COLOROP_1D_CURVE_COUNT | |
| DRM_COLOROP_1D_CURVE_SRGB_EOTF, | |
| DRM_COLOROP_1D_CURVE_SRGB_INV_EOTF, | |
| DRM_COLOROP_1D_CURVE_PQ_125_EOTF, | |
| DRM_COLOROP_1D_CURVE_PQ_125_INV_EOTF, | |
| DRM_COLOROP_1D_CURVE_BT2020_INV_OETF, | |
| DRM_COLOROP_1D_CURVE_BT2020_OETF, | |
| DRM_COLOROP_1D_CURVE_GAMMA22, | |
| DRM_COLOROP_1D_CURVE_GAMMA22_INV, | |
| DRM_COLOROP_1D_CURVE_COUNT |
|
It looks like Intel DRM plane color support landed in v6.19, right? I'd like to double check that this doesn't regress anything on Xe before we merge this. I should have time early next week to confirm. |
|
NV 610 also appears to have added this, haven't had a chance to test yet: |
|
I can try checking NV610 as well, but we already have so many other existing nvidia-drm bugs that it's a lower priority than i915/Xe imo |
|
this MR seems to just coredump on Xe with a kernel that supports the color pipeline so I'm glad I checked... will see if i can figure out why. |
|
HI @matte-schwartz, |
Signed-off-by: Melissa Wen <mwen@igalia.com>
Signed-off-by: Melissa Wen <mwen@igalia.com>
Signed-off-by: Melissa Wen <mwen@igalia.com>
Store the value of the color pipeline enum for a given plane that fits color pipeline needs. So that we can set plane COLOR_PIPELINE property with this value. Signed-off-by: Melissa Wen <mwen@igalia.com>
Check if there is any color pipeline with the properties needed for plane color mgmt. Signed-off-by: Melissa Wen <mwen@igalia.com>
Add CURVE_1D_TYPE property to colorop, helper for degamma curve using DRM_COLOROP_* predefined curve instead of AMD_TRANSFER_FUNCTIONs, add set degamma 1D curve accordingly Signed-off-by: Melissa Wen <mwen@igalia.com>
Create helper to use DRM_COLOROP curves instead of AMD_TRANSFER_FUNCTIONs and set properties accordingly Signed-off-by: Melissa Wen <mwen@igalia.com>
Create a helper to translate output tf of AMD_TRANSFER_FUNCTION enum type to DRM_COLOROP type Signed-off-by: Melissa Wen <mwen@igalia.com>
Gamescope already use 3x4 matrix, so doesn't needed additional helper. Signed-off-by: Melissa Wen <mwen@igalia.com>
Signed-off-by: Melissa Wen <mwen@igalia.com>
Instead of struct drm_color_lut, shaper and 3D LUTs follow struct drm_color_lut32, which means 32-bit for each channel, not 16-bit anymore. Create a helper to make possible reuse LUTs already created for AMD driver-specific color properties. Signed-off-by: Melissa Wen <mwen@igalia.com>
Signed-off-by: Melissa Wen <mwen@igalia.com>
Match the existing behavior of the legacy AMD plane properties, which reset layers to DEFAULT without color management applied to them. Otherwise, stale color pipeline state from the previous scanout frame persists during composition, resulting in double color management and an overly-saturated output image. Signed-off-by: Matthew Schwartz <matthew.schwartz@linux.dev>
Those properties are deprecated when using KMS colorop API Signed-off-by: Melissa Wen <mwen@igalia.com>
Signed-off-by: Melissa Wen <mwen@igalia.com>
Signed-off-by: Melissa Wen <mwen@igalia.com>
Follow similar approach of plane color pipelines. For AMD, the expected CRTC color pipeline comprises of CTM, regamma/out 1D Curve (regamma TF) and regamma LUT. Signed-off-by: Melissa Wen <mwen@igalia.com>
Signed-off-by: Melissa Wen <mwen@igalia.com>
If post-blend colorop API is supported, set post-blend 1D Curve with regamma TF values and bypass CTM and regamma LUT. Same as what is done with AMD driver specific props. Signed-off-by: Melissa Wen <mwen@igalia.com>
|
FWIW, I updated this branch to include plane Fixed Matrix colorop and post-blend/CRTC colorops. So that gamescope fully migrates from AMD private props to KMS genereic color API. A custom kernel is needed for this full migration since some patches weren't merged upstream yet. You can find a kernel with full colorop pipeline support for AMD here: https://gitlab.freedesktop.org/mwen/drm-misc/-/commits/gamescope_pipeline_w_colorop |
With the new KMS color API for plane color mgmt, we can replace most of AMD driver-specific color properties by plane color pipeline and its colorops, except CRTC regamma TF [1] and color_range/color_encoding (bypass on kernel) [2]. As libliftoff doesn't support the colorop objs yet, I'm not sure if what I did is acceptable: to program colorops only after libliftoff has mapped layers-planes. Besides those comments, I'd like to mention that I used Claude code to debug a problem with blobs and figure out that shaper and 3D LUTs use a larger LUT struct with 32-bits per channel (drm_color_lut32 instead of drm_color_lut) and to create a helper that maps uint16 to uint32 values when creating LUTs for a given colorspace.
My main goal is validating and exercising KMS colorop code.
This branch is based on @emersion work at: #1309
Lemme know your thoughts.
[1] custom kernel that still exposes regamma TF: https://gitlab.freedesktop.org/mwen/drm-misc/-/commit/428cc3331d678d8e6ce6de5322a8be62ca2ff08b
[2] https://gitlab.freedesktop.org/agd5f/linux/-/commit/e0edb5809f1ec477b7b969200dc89bc171944ad4