drm/amd/display: Ensure 3D LUT for color pipeline

Check dpp.hw_3d_lut before creating shaper tf/lut and 3dlut colorops in
colorpipeline and handling these colorops.

Reviewed-by: Harry Wentland <harry.wentland@amd.com>
Signed-off-by: Alex Hung <alex.hung@amd.com>
Signed-off-by: Simon Ser <contact@emersion.fr>
Link: https://patch.msgid.link/20251115000237.3561250-49-alex.hung@amd.com
This commit is contained in:
Alex Hung 2025-11-14 17:02:13 -07:00 committed by Simon Ser
parent d1aa2a2696
commit 0c8025e6ae
2 changed files with 81 additions and 74 deletions

View File

@ -1868,6 +1868,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;
struct amdgpu_device *adev = drm_to_adev(dev);
int ret;
/* 1D Curve - DEGAM TF */
@ -1900,33 +1901,35 @@ amdgpu_dm_plane_set_colorop_properties(struct drm_plane_state *plane_state,
if (ret)
return ret;
/* 1D Curve & LUT - SHAPER TF & LUT */
colorop = colorop->next;
if (!colorop) {
drm_dbg(dev, "no Shaper TF colorop found\n");
return -EINVAL;
if (adev->dm.dc->caps.color.dpp.hw_3d_lut) {
/* 1D Curve & LUT - SHAPER TF & LUT */
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;
/* Shaper LUT colorop is already handled, just skip here */
colorop = colorop->next;
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);
if (ret)
return ret;
}
ret = __set_dm_plane_colorop_shaper(plane_state, dc_plane_state, colorop);
if (ret)
return ret;
/* Shaper LUT colorop is already handled, just skip here */
colorop = colorop->next;
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);
if (ret)
return ret;
/* 1D Curve & LUT - BLND TF & LUT */
colorop = colorop->next;
if (!colorop) {

View File

@ -31,6 +31,7 @@
#include "amdgpu.h"
#include "amdgpu_dm_colorop.h"
#include "dc.h"
const u64 amdgpu_dm_supported_degam_tfs =
BIT(DRM_COLOROP_1D_CURVE_SRGB_EOTF) |
@ -55,6 +56,7 @@ int amdgpu_dm_initialize_default_pipeline(struct drm_plane *plane, struct drm_pr
{
struct drm_colorop *ops[MAX_COLOR_PIPELINE_OPS];
struct drm_device *dev = plane->dev;
struct amdgpu_device *adev = drm_to_adev(dev);
int ret;
int i = 0;
@ -108,57 +110,59 @@ int amdgpu_dm_initialize_default_pipeline(struct drm_plane *plane, struct drm_pr
i++;
/* 1D curve - SHAPER TF */
ops[i] = kzalloc(sizeof(*ops[0]), GFP_KERNEL);
if (!ops[i]) {
ret = -ENOMEM;
goto cleanup;
if (adev->dm.dc->caps.color.dpp.hw_3d_lut) {
/* 1D curve - SHAPER TF */
ops[i] = kzalloc(sizeof(*ops[0]), 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,
DRM_COLOROP_FLAG_ALLOW_BYPASS);
if (ret)
goto cleanup;
drm_colorop_set_next_property(ops[i-1], ops[i]);
i++;
/* 1D LUT - SHAPER LUT */
ops[i] = kzalloc(sizeof(*ops[0]), 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,
DRM_COLOROP_LUT1D_INTERPOLATION_LINEAR,
DRM_COLOROP_FLAG_ALLOW_BYPASS);
if (ret)
goto cleanup;
drm_colorop_set_next_property(ops[i-1], ops[i]);
i++;
/* 3D LUT */
ops[i] = kzalloc(sizeof(*ops[0]), GFP_KERNEL);
if (!ops[i]) {
ret = -ENOMEM;
goto cleanup;
}
ret = drm_plane_colorop_3dlut_init(dev, ops[i], plane, LUT3D_SIZE,
DRM_COLOROP_LUT3D_INTERPOLATION_TETRAHEDRAL,
DRM_COLOROP_FLAG_ALLOW_BYPASS);
if (ret)
goto cleanup;
drm_colorop_set_next_property(ops[i-1], ops[i]);
i++;
}
ret = drm_plane_colorop_curve_1d_init(dev, ops[i], plane,
amdgpu_dm_supported_shaper_tfs,
DRM_COLOROP_FLAG_ALLOW_BYPASS);
if (ret)
goto cleanup;
drm_colorop_set_next_property(ops[i - 1], ops[i]);
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,
DRM_COLOROP_LUT1D_INTERPOLATION_LINEAR,
DRM_COLOROP_FLAG_ALLOW_BYPASS);
if (ret)
goto cleanup;
drm_colorop_set_next_property(ops[i-1], ops[i]);
i++;
/* 3D LUT */
ops[i] = kzalloc(sizeof(struct drm_colorop), GFP_KERNEL);
if (!ops[i]) {
ret = -ENOMEM;
goto cleanup;
}
ret = drm_plane_colorop_3dlut_init(dev, ops[i], plane, LUT3D_SIZE,
DRM_COLOROP_LUT3D_INTERPOLATION_TETRAHEDRAL,
DRM_COLOROP_FLAG_ALLOW_BYPASS);
if (ret)
goto cleanup;
drm_colorop_set_next_property(ops[i-1], ops[i]);
i++;
/* 1D curve - BLND TF */
ops[i] = kzalloc(sizeof(*ops[0]), GFP_KERNEL);
if (!ops[i]) {