From: Leo Li <sunpeng.li@amd.com>
To: Alex Hung <alex.hung@amd.com>,
dri-devel@lists.freedesktop.org, amd-gfx@lists.freedesktop.org
Cc: wayland-devel@lists.freedesktop.org, harry.wentland@amd.com
Subject: Re: [V7 42/45] drm/amd/display: add 3D LUT colorop
Date: Thu, 13 Feb 2025 13:21:04 -0500 [thread overview]
Message-ID: <44edbdfb-5e23-4c19-8c80-e7acb8b4930f@amd.com> (raw)
In-Reply-To: <20241220043410.416867-43-alex.hung@amd.com>
On 2024-12-19 23:33, Alex Hung wrote:
> This adds support for a 3D LUT.
>
> The color pipeline now consists of the following colorops:
> 1. 1D curve colorop
> 2. Multiplier
> 3. 3x4 CTM
> 4. 1D curve colorop
> 5. 1D LUT
> 6. 3D LUT
> 7. 1D curve colorop
> 8. 1D LUT
>
> Signed-off-by: Alex Hung <alex.hung@amd.com>
> ---
> v7:
> - Simplify 3D LUT according to drm_colorop changes (Simon Ser)
>
> .../amd/display/amdgpu_dm/amdgpu_dm_color.c | 100 +++++++++++++++++-
> .../amd/display/amdgpu_dm/amdgpu_dm_colorop.c | 19 ++++
> 2 files changed, 116 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_color.c b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_color.c
> index 54ec12c1352f..5e8c5c0657c4 100644
> --- a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_color.c
> +++ b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_color.c
> @@ -1282,7 +1282,8 @@ __set_dm_plane_colorop_multiplier(struct drm_plane_state *plane_state,
> 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 *colorop,
> + bool *enabled)
> {
> struct drm_colorop *old_colorop;
> struct drm_colorop_state *colorop_state = NULL, *new_colorop_state;
> @@ -1310,6 +1311,7 @@ __set_dm_plane_colorop_shaper(struct drm_plane_state *plane_state,
> 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_output_tf(tf, 0, 0, false);
> + *enabled = true;
> }
>
> /* 1D LUT - SHAPER LUT */
> @@ -1337,8 +1339,88 @@ __set_dm_plane_colorop_shaper(struct drm_plane_state *plane_state,
> shaper_size = shaper_lut != NULL ? shaper_size : 0;
>
> /* Custom LUT size must be the same as supported size */
> - if (shaper_size == colorop->lut_size)
> + if (shaper_size == colorop->lut_size) {
> __set_output_tf(tf, shaper_lut, shaper_size, false);
> + *enabled = true;
> + }
> + }
> +
> + return 0;
> +}
> +
> +/* __set_colorop_3dlut - set DRM 3D LUT to DC stream
> + * @drm_lut3d: user 3D LUT
> + * @drm_lut3d_size: size of 3D LUT
> + * @lut3d: DC 3D LUT
> + *
> + * Map user 3D LUT data to DC 3D LUT and all necessary bits to program it
> + * on DCN accordingly.
> + */
> +static void __set_colorop_3dlut(const struct drm_color_lut *drm_lut3d,
> + uint32_t drm_lut3d_size,
> + struct dc_3dlut *lut)
> +{
> + if (!drm_lut3d_size)
> + return;
> +
> + lut->state.bits.initialized = 0;
> +
> + /* Only supports 17x17x17 3D LUT (12-bit) now */
> + lut->lut_3d.use_12bits = true;
> + lut->lut_3d.use_tetrahedral_9 = false;
> +
> + lut->state.bits.initialized = 1;
> + __drm_3dlut_to_dc_3dlut(drm_lut3d, drm_lut3d_size, &lut->lut_3d,
> + lut->lut_3d.use_tetrahedral_9, 12);
> +
> +}
> +
> +static int
> +__set_dm_plane_colorop_3dlut(struct drm_plane_state *plane_state,
> + struct dc_plane_state *dc_plane_state,
> + struct drm_colorop *colorop,
> + bool shaper_enabled)
> +{
> + struct drm_colorop *old_colorop;
> + struct drm_colorop_state *colorop_state = NULL, *new_colorop_state;
> + struct dc_transfer_func *tf = &dc_plane_state->in_shaper_func;
> + struct drm_atomic_state *state = plane_state->state;
> + const struct amdgpu_device *adev = drm_to_adev(colorop->dev);
> + const struct drm_device *dev = colorop->dev;
> + const struct drm_color_lut *lut3d;
> + uint32_t lut3d_size;
> + int i = 0;
> +
> + /* 3D LUT */
> + 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_3D_LUT) {
> + colorop_state = new_colorop_state;
> + break;
> + }
> + }
> +
> + if (colorop_state && !colorop_state->bypass && colorop->type == DRM_COLOROP_3D_LUT) {
> + if (!adev->dm.dc->caps.color.dpp.hw_3d_lut) {
> + drm_dbg(dev, "3D LUT is not supported by hardware\n");
> + return 0;
Should an error be returned instead?
-Leo
> + }
> +
> + drm_dbg(dev, "3D LUT colorop with ID: %d\n", colorop->base.id);
> + lut3d = __extract_blob_lut(colorop_state->data, &lut3d_size);
> + lut3d_size = lut3d != NULL ? lut3d_size : 0;
> + __set_colorop_3dlut(lut3d, lut3d_size, &dc_plane_state->lut3d_func);
> +
> + /* 3D LUT requires shaper. If shaper colorop is bypassed, enable shaper curve
> + * with TRANSFER_FUNCTION_LINEAR
> + */
> + if (!shaper_enabled) {
> + tf->type = TF_TYPE_DISTRIBUTED_POINTS;
> + tf->tf = TRANSFER_FUNCTION_LINEAR;
> + tf->sdr_ref_white_level = SDR_WHITE_LEVEL_INIT_VALUE;
> + __set_output_tf(tf, NULL, 0, false);
> + }
Is it possible for an atomic state to have a 3DLUT colorop_state, but not any
shaper colorop_states? For example, say a previous commit enabled the shaper,
and the current commit enables the 3DLUT without any shaper updates?
If so, `shaper_enabled` may not get set to 'true' by
`__set_dm_plane_colorop_shaper` for the current commit, and the previously
programmed shaper would get overwritten by this logic here.
If this is actually an issue, inspect the current shaper state -- if a new one
isn't there -- should work.
- Leo
> }
>
> return 0;
> @@ -1467,6 +1549,7 @@ amdgpu_dm_plane_set_colorop_properties(struct drm_plane_state *plane_state,
> {
> struct drm_colorop *colorop = plane_state->color_pipeline;
> struct drm_device *dev = plane_state->plane->dev;
> + bool shaper_enabled = false;
> int ret;
>
> /* 1D Curve - DEGAM TF */
> @@ -1506,7 +1589,7 @@ amdgpu_dm_plane_set_colorop_properties(struct drm_plane_state *plane_state,
> return -EINVAL;
> }
>
> - ret = __set_dm_plane_colorop_shaper(plane_state, dc_plane_state, colorop);
> + ret = __set_dm_plane_colorop_shaper(plane_state, dc_plane_state, colorop, &shaper_enabled);
> if (ret)
> return ret;
>
> @@ -1515,6 +1598,17 @@ amdgpu_dm_plane_set_colorop_properties(struct drm_plane_state *plane_state,
> if (!colorop)
> return -EINVAL;
>
> + /* 3D LUT */
> + colorop = colorop->next;
> + if (!colorop) {
> + drm_dbg(dev, "no 3D LUT colorop found\n");
> + return -EINVAL;
> + }
> +
> + ret = __set_dm_plane_colorop_3dlut(plane_state, dc_plane_state, colorop, shaper_enabled);
> + if (ret)
> + return ret;
> +
> /* 1D Curve & LUT - BLND TF & LUT */
> colorop = colorop->next;
> if (!colorop) {
> diff --git a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_colorop.c b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_colorop.c
> index ec94ff887886..e03e6044f937 100644
> --- a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_colorop.c
> +++ b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_colorop.c
> @@ -49,6 +49,8 @@ const u64 amdgpu_dm_supported_blnd_tfs =
>
> #define MAX_COLOR_PIPELINE_OPS 10
>
> +#define LUT3D_SIZE 17
> +
> int amdgpu_dm_initialize_default_pipeline(struct drm_plane *plane, struct drm_prop_enum_list *list)
> {
> struct drm_colorop *ops[MAX_COLOR_PIPELINE_OPS];
> @@ -145,6 +147,23 @@ int amdgpu_dm_initialize_default_pipeline(struct drm_plane *plane, struct drm_pr
>
> i++;
>
> + /* 3D LUT */
> + ops[i] = kzalloc(sizeof(struct drm_colorop), GFP_KERNEL);
> + if (!ops[i]) {
> + DRM_ERROR("KMS: Failed to allocate colorop\n");
> + ret = -ENOMEM;
> + goto cleanup;
> + }
> +
> + ret = drm_colorop_3dlut_init(dev, ops[i], plane, LUT3D_SIZE,
> + DRM_COLOROP_LUT3D_INTERPOLATION_TETRAHEDRAL, true);
> + 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]) {
next prev parent reply other threads:[~2025-02-13 18:21 UTC|newest]
Thread overview: 127+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-12-20 4:33 [V7 00/45] Color Pipeline API w/ VKMS Alex Hung
2024-12-20 4:33 ` [V7 01/45] drm: Add helper for conversion from signed-magnitude Alex Hung
2025-02-24 16:07 ` Louis Chauvet
2025-02-24 18:50 ` Alex Hung
2025-02-25 9:35 ` Louis Chauvet
2024-12-20 4:33 ` [V7 02/45] drm/vkms: Round fixp2int conversion in lerp_u16 Alex Hung
2025-02-24 16:07 ` Louis Chauvet
2025-02-25 9:37 ` Louis Chauvet
2025-02-25 11:28 ` Simon Ser
2025-02-25 14:05 ` Louis Chauvet
2025-02-25 14:43 ` Harry Wentland
2025-02-25 14:45 ` Simon Ser
2025-02-25 16:00 ` Louis Chauvet
2024-12-20 4:33 ` [V7 03/45] drm/vkms: Add kunit tests for VKMS LUT handling Alex Hung
2025-02-24 16:07 ` Louis Chauvet
2025-02-25 9:51 ` Louis Chauvet
2025-02-25 14:45 ` Harry Wentland
2024-12-20 4:33 ` [V7 04/45] drm/doc/rfc: Describe why prescriptive color pipeline is needed Alex Hung
2024-12-20 4:33 ` [V7 05/45] drm/colorop: Introduce new drm_colorop mode object Alex Hung
2025-01-13 8:04 ` Simon Ser
2025-02-24 16:07 ` Louis Chauvet
2025-02-25 10:05 ` Louis Chauvet
2025-02-28 15:55 ` Harry Wentland
2024-12-20 4:33 ` [V7 06/45] drm/colorop: Add TYPE property Alex Hung
2025-01-13 8:05 ` Simon Ser
2025-02-24 16:07 ` Louis Chauvet
2025-02-25 10:07 ` Louis Chauvet
2024-12-20 4:33 ` [V7 07/45] drm/colorop: Add 1D Curve subtype Alex Hung
2025-01-13 8:07 ` Simon Ser
2025-02-24 16:07 ` Louis Chauvet
2025-02-25 10:13 ` Louis Chauvet
2025-02-28 1:07 ` Alex Hung
2025-02-28 9:24 ` Louis Chauvet
2024-12-20 4:33 ` [V7 08/45] Documentation/gpu: document drm_colorop Alex Hung
2025-01-13 8:18 ` Simon Ser
2025-02-10 22:03 ` Harry Wentland
2025-02-15 14:40 ` Simon Ser
2025-02-21 16:18 ` Harry Wentland
2025-02-21 16:42 ` Simon Ser
2025-02-21 18:41 ` Harry Wentland
2025-02-21 18:48 ` Simon Ser
2024-12-20 4:33 ` [V7 09/45] drm/colorop: Add BYPASS property Alex Hung
2025-01-13 17:49 ` Simon Ser
2025-02-24 16:07 ` Louis Chauvet
2025-02-25 10:15 ` Louis Chauvet
2024-12-20 4:33 ` [V7 10/45] drm/colorop: Add NEXT property Alex Hung
2025-01-13 17:54 ` Simon Ser
2025-02-24 16:07 ` Louis Chauvet
2025-02-25 10:21 ` Louis Chauvet
2024-12-20 4:33 ` [V7 11/45] drm/colorop: Add atomic state print for drm_colorop Alex Hung
2025-01-13 17:55 ` Simon Ser
2024-12-20 4:33 ` [V7 12/45] drm/plane: Add COLOR PIPELINE property Alex Hung
2025-01-13 18:08 ` Simon Ser
2024-12-20 4:33 ` [V7 13/45] drm/colorop: Introduce DRM_CLIENT_CAP_PLANE_COLOR_PIPELINE Alex Hung
2025-01-13 18:23 ` Simon Ser
2025-01-22 19:48 ` Harry Wentland
2025-01-22 20:05 ` Simon Ser
2024-12-20 4:33 ` [V7 14/45] drm/vkms: Add enumerated 1D curve colorop Alex Hung
2025-02-25 11:18 ` Louis Chauvet
2025-03-10 19:43 ` Harry Wentland
2024-12-20 4:33 ` [V7 15/45] drm/vkms: Add kunit tests for linear and sRGB LUTs Alex Hung
2025-02-25 11:19 ` Louis Chauvet
2025-03-10 15:09 ` Harry Wentland
2024-12-20 4:33 ` [V7 16/45] drm/colorop: Add 3x4 CTM type Alex Hung
2025-01-13 18:19 ` Simon Ser
2025-02-25 11:20 ` Louis Chauvet
2024-12-20 4:33 ` [V7 17/45] drm/vkms: Use s32 for internal color pipeline precision Alex Hung
2024-12-20 4:33 ` [V7 18/45] drm/vkms: add 3x4 matrix in color pipeline Alex Hung
2025-02-25 11:21 ` Louis Chauvet
2024-12-20 4:33 ` [V7 19/45] drm/tests: Add a few tests around drm_fixed.h Alex Hung
2024-12-20 4:33 ` [V7 20/45] drm/vkms: Add tests for CTM handling Alex Hung
2024-12-20 4:33 ` [V7 21/45] drm/colorop: pass plane_color_pipeline client cap to atomic check Alex Hung
2024-12-20 4:33 ` [V7 22/45] drm/colorop: define a new macro for_each_new_colorop_in_state Alex Hung
2025-01-15 7:48 ` Simon Ser
2024-12-20 4:33 ` [V7 23/45] drm/amd/display: Ignore deprecated props when plane_color_pipeline set Alex Hung
2025-01-15 7:56 ` Simon Ser
2025-01-22 21:05 ` Harry Wentland
2025-01-23 20:29 ` Simon Ser
2024-12-20 4:33 ` [V7 24/45] drm/amd/display: Add bypass COLOR PIPELINE Alex Hung
2024-12-20 4:33 ` [V7 25/45] drm/amd/display: Skip color pipeline initialization for cursor plane Alex Hung
2024-12-20 4:33 ` [V7 26/45] drm/amd/display: Add support for sRGB EOTF in DEGAM block Alex Hung
2025-02-13 15:35 ` Leo Li
2024-12-20 4:33 ` [V7 27/45] drm/amd/display: Add support for sRGB Inverse EOTF in SHAPER block Alex Hung
2024-12-20 4:33 ` [V7 28/45] drm/amd/display: Add support for sRGB EOTF in BLND block Alex Hung
2024-12-20 4:33 ` [V7 29/45] drm/colorop: Add PQ 125 EOTF and its inverse Alex Hung
2025-01-15 8:00 ` Simon Ser
2025-01-23 20:06 ` Harry Wentland
2025-01-23 20:33 ` Simon Ser
2025-01-17 9:04 ` Pekka Paalanen
2025-01-23 20:09 ` Harry Wentland
2024-12-20 4:33 ` [V7 30/45] drm/amd/display: Enable support for PQ 125 EOTF and Inverse Alex Hung
2024-12-20 4:33 ` [V7 31/45] drm/colorop: add BT2020/BT709 OETF and Inverse OETF Alex Hung
2025-01-15 8:04 ` Simon Ser
2025-01-23 20:13 ` Harry Wentland
2025-01-16 8:56 ` Pekka Paalanen
2025-01-17 9:06 ` Pekka Paalanen
2025-01-23 20:16 ` Harry Wentland
2025-01-27 12:05 ` Pekka Paalanen
2024-12-20 4:33 ` [V7 32/45] drm/amd/display: Add support for BT.709 and BT.2020 TFs Alex Hung
2025-02-12 23:03 ` Leo Li
2024-12-20 4:33 ` [V7 33/45] drm/colorop: Add 1D Curve Custom LUT type Alex Hung
2025-01-15 8:14 ` Simon Ser
2025-01-16 23:33 ` Alex Hung
2025-01-18 13:54 ` Simon Ser
2025-01-15 15:48 ` Simon Ser
2024-12-20 4:33 ` [V7 34/45] drm/amd/display: add shaper and blend colorops for 1D Curve Custom LUT Alex Hung
2025-02-12 23:44 ` Leo Li
2025-02-21 16:28 ` Harry Wentland
2024-12-20 4:33 ` [V7 35/45] drm/amd/display: add 3x4 matrix colorop Alex Hung
2025-02-13 17:16 ` Leo Li
2024-12-20 4:33 ` [V7 36/45] drm/colorop: Add mutliplier type Alex Hung
2025-01-15 15:54 ` Simon Ser
2024-12-20 4:33 ` [V7 37/45] drm/amd/display: add multiplier colorop Alex Hung
2024-12-20 4:33 ` [V7 38/45] drm/amd/display: Swap matrix and multiplier Alex Hung
2024-12-20 4:33 ` [V7 39/45] drm/colorop: Define LUT_1D interpolation Alex Hung
2025-01-20 7:48 ` Simon Ser
2024-12-20 4:33 ` [V7 40/45] drm/colorop: allow non-bypass colorops Alex Hung
2024-12-20 4:33 ` [V7 41/45] drm/colorop: Add 3D LUT supports to color pipeline Alex Hung
2025-01-20 21:16 ` Simon Ser
2024-12-20 4:33 ` [V7 42/45] drm/amd/display: add 3D LUT colorop Alex Hung
2025-02-13 18:21 ` Leo Li [this message]
2025-02-21 21:05 ` Harry Wentland
2024-12-20 4:33 ` [V7 43/45] drm/amd/display: Add AMD color pipeline doc Alex Hung
2025-01-17 9:19 ` Pekka Paalanen
2025-01-23 20:52 ` Harry Wentland
2024-12-20 4:33 ` [V7 44/45] drm/colorop: Add kernel doc for data blob Alex Hung
2024-12-20 4:33 ` [V7 45/45] drm/colorop: Add destroy functions for color pipeline Alex Hung
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=44edbdfb-5e23-4c19-8c80-e7acb8b4930f@amd.com \
--to=sunpeng.li@amd.com \
--cc=alex.hung@amd.com \
--cc=amd-gfx@lists.freedesktop.org \
--cc=dri-devel@lists.freedesktop.org \
--cc=harry.wentland@amd.com \
--cc=wayland-devel@lists.freedesktop.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.