Skip to content

Commit 0c8025e

Browse files
Alex Hungemersion
authored andcommitted
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
1 parent d1aa2a2 commit 0c8025e

2 files changed

Lines changed: 78 additions & 71 deletions

File tree

drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_color.c

Lines changed: 25 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1868,6 +1868,7 @@ amdgpu_dm_plane_set_colorop_properties(struct drm_plane_state *plane_state,
18681868
{
18691869
struct drm_colorop *colorop = plane_state->color_pipeline;
18701870
struct drm_device *dev = plane_state->plane->dev;
1871+
struct amdgpu_device *adev = drm_to_adev(dev);
18711872
int ret;
18721873

18731874
/* 1D Curve - DEGAM TF */
@@ -1900,32 +1901,34 @@ amdgpu_dm_plane_set_colorop_properties(struct drm_plane_state *plane_state,
19001901
if (ret)
19011902
return ret;
19021903

1903-
/* 1D Curve & LUT - SHAPER TF & LUT */
1904-
colorop = colorop->next;
1905-
if (!colorop) {
1906-
drm_dbg(dev, "no Shaper TF colorop found\n");
1907-
return -EINVAL;
1908-
}
1904+
if (adev->dm.dc->caps.color.dpp.hw_3d_lut) {
1905+
/* 1D Curve & LUT - SHAPER TF & LUT */
1906+
colorop = colorop->next;
1907+
if (!colorop) {
1908+
drm_dbg(dev, "no Shaper TF colorop found\n");
1909+
return -EINVAL;
1910+
}
19091911

1910-
ret = __set_dm_plane_colorop_shaper(plane_state, dc_plane_state, colorop);
1911-
if (ret)
1912-
return ret;
1912+
ret = __set_dm_plane_colorop_shaper(plane_state, dc_plane_state, colorop);
1913+
if (ret)
1914+
return ret;
19131915

1914-
/* Shaper LUT colorop is already handled, just skip here */
1915-
colorop = colorop->next;
1916-
if (!colorop)
1917-
return -EINVAL;
1916+
/* Shaper LUT colorop is already handled, just skip here */
1917+
colorop = colorop->next;
1918+
if (!colorop)
1919+
return -EINVAL;
19181920

1919-
/* 3D LUT */
1920-
colorop = colorop->next;
1921-
if (!colorop) {
1922-
drm_dbg(dev, "no 3D LUT colorop found\n");
1923-
return -EINVAL;
1924-
}
1921+
/* 3D LUT */
1922+
colorop = colorop->next;
1923+
if (!colorop) {
1924+
drm_dbg(dev, "no 3D LUT colorop found\n");
1925+
return -EINVAL;
1926+
}
19251927

1926-
ret = __set_dm_plane_colorop_3dlut(plane_state, dc_plane_state, colorop);
1927-
if (ret)
1928-
return ret;
1928+
ret = __set_dm_plane_colorop_3dlut(plane_state, dc_plane_state, colorop);
1929+
if (ret)
1930+
return ret;
1931+
}
19291932

19301933
/* 1D Curve & LUT - BLND TF & LUT */
19311934
colorop = colorop->next;

drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_colorop.c

Lines changed: 53 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131

3232
#include "amdgpu.h"
3333
#include "amdgpu_dm_colorop.h"
34+
#include "dc.h"
3435

3536
const u64 amdgpu_dm_supported_degam_tfs =
3637
BIT(DRM_COLOROP_1D_CURVE_SRGB_EOTF) |
@@ -55,6 +56,7 @@ int amdgpu_dm_initialize_default_pipeline(struct drm_plane *plane, struct drm_pr
5556
{
5657
struct drm_colorop *ops[MAX_COLOR_PIPELINE_OPS];
5758
struct drm_device *dev = plane->dev;
59+
struct amdgpu_device *adev = drm_to_adev(dev);
5860
int ret;
5961
int i = 0;
6062

@@ -108,57 +110,59 @@ int amdgpu_dm_initialize_default_pipeline(struct drm_plane *plane, struct drm_pr
108110

109111
i++;
110112

111-
/* 1D curve - SHAPER TF */
112-
ops[i] = kzalloc(sizeof(*ops[0]), GFP_KERNEL);
113-
if (!ops[i]) {
114-
ret = -ENOMEM;
115-
goto cleanup;
116-
}
117-
118-
ret = drm_plane_colorop_curve_1d_init(dev, ops[i], plane,
119-
amdgpu_dm_supported_shaper_tfs,
120-
DRM_COLOROP_FLAG_ALLOW_BYPASS);
121-
if (ret)
122-
goto cleanup;
123-
124-
drm_colorop_set_next_property(ops[i - 1], ops[i]);
125-
126-
i++;
127-
128-
/* 1D LUT - SHAPER LUT */
129-
ops[i] = kzalloc(sizeof(struct drm_colorop), GFP_KERNEL);
130-
if (!ops[i]) {
131-
ret = -ENOMEM;
132-
goto cleanup;
133-
}
134-
135-
ret = drm_plane_colorop_curve_1d_lut_init(dev, ops[i], plane, MAX_COLOR_LUT_ENTRIES,
136-
DRM_COLOROP_LUT1D_INTERPOLATION_LINEAR,
137-
DRM_COLOROP_FLAG_ALLOW_BYPASS);
138-
if (ret)
139-
goto cleanup;
140-
141-
drm_colorop_set_next_property(ops[i-1], ops[i]);
142-
143-
i++;
144-
145-
/* 3D LUT */
146-
ops[i] = kzalloc(sizeof(struct drm_colorop), GFP_KERNEL);
147-
if (!ops[i]) {
148-
ret = -ENOMEM;
149-
goto cleanup;
113+
if (adev->dm.dc->caps.color.dpp.hw_3d_lut) {
114+
/* 1D curve - SHAPER TF */
115+
ops[i] = kzalloc(sizeof(*ops[0]), GFP_KERNEL);
116+
if (!ops[i]) {
117+
ret = -ENOMEM;
118+
goto cleanup;
119+
}
120+
121+
ret = drm_plane_colorop_curve_1d_init(dev, ops[i], plane,
122+
amdgpu_dm_supported_shaper_tfs,
123+
DRM_COLOROP_FLAG_ALLOW_BYPASS);
124+
if (ret)
125+
goto cleanup;
126+
127+
drm_colorop_set_next_property(ops[i-1], ops[i]);
128+
129+
i++;
130+
131+
/* 1D LUT - SHAPER LUT */
132+
ops[i] = kzalloc(sizeof(*ops[0]), GFP_KERNEL);
133+
if (!ops[i]) {
134+
ret = -ENOMEM;
135+
goto cleanup;
136+
}
137+
138+
ret = drm_plane_colorop_curve_1d_lut_init(dev, ops[i], plane, MAX_COLOR_LUT_ENTRIES,
139+
DRM_COLOROP_LUT1D_INTERPOLATION_LINEAR,
140+
DRM_COLOROP_FLAG_ALLOW_BYPASS);
141+
if (ret)
142+
goto cleanup;
143+
144+
drm_colorop_set_next_property(ops[i-1], ops[i]);
145+
146+
i++;
147+
148+
/* 3D LUT */
149+
ops[i] = kzalloc(sizeof(*ops[0]), GFP_KERNEL);
150+
if (!ops[i]) {
151+
ret = -ENOMEM;
152+
goto cleanup;
153+
}
154+
155+
ret = drm_plane_colorop_3dlut_init(dev, ops[i], plane, LUT3D_SIZE,
156+
DRM_COLOROP_LUT3D_INTERPOLATION_TETRAHEDRAL,
157+
DRM_COLOROP_FLAG_ALLOW_BYPASS);
158+
if (ret)
159+
goto cleanup;
160+
161+
drm_colorop_set_next_property(ops[i-1], ops[i]);
162+
163+
i++;
150164
}
151165

152-
ret = drm_plane_colorop_3dlut_init(dev, ops[i], plane, LUT3D_SIZE,
153-
DRM_COLOROP_LUT3D_INTERPOLATION_TETRAHEDRAL,
154-
DRM_COLOROP_FLAG_ALLOW_BYPASS);
155-
if (ret)
156-
goto cleanup;
157-
158-
drm_colorop_set_next_property(ops[i-1], ops[i]);
159-
160-
i++;
161-
162166
/* 1D curve - BLND TF */
163167
ops[i] = kzalloc(sizeof(*ops[0]), GFP_KERNEL);
164168
if (!ops[i]) {

0 commit comments

Comments
 (0)