Skip to content

Commit 16e0f78

Browse files
Alex Hungemersion
authored andcommitted
drm/amd/display: add 3x4 matrix colorop
This 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 Signed-off-by: Alex Hung <alex.hung@amd.com> Signed-off-by: Harry Wentland <harry.wentland@amd.com> Reviewed-by: Daniel Stone <daniels@collabora.com> Reviewed-by: Melissa Wen <mwen@igalia.com> Signed-off-by: Simon Ser <contact@emersion.fr> Link: https://patch.msgid.link/20251115000237.3561250-40-alex.hung@amd.com
1 parent 5ed78b4 commit 16e0f78

2 files changed

Lines changed: 67 additions & 0 deletions

File tree

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

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1378,6 +1378,47 @@ __set_dm_plane_colorop_degamma(struct drm_plane_state *plane_state,
13781378
return __set_colorop_in_tf_1d_curve(dc_plane_state, colorop_state);
13791379
}
13801380

1381+
static int
1382+
__set_dm_plane_colorop_3x4_matrix(struct drm_plane_state *plane_state,
1383+
struct dc_plane_state *dc_plane_state,
1384+
struct drm_colorop *colorop)
1385+
{
1386+
struct drm_colorop *old_colorop;
1387+
struct drm_colorop_state *colorop_state = NULL, *new_colorop_state;
1388+
struct drm_atomic_state *state = plane_state->state;
1389+
const struct drm_device *dev = colorop->dev;
1390+
const struct drm_property_blob *blob;
1391+
struct drm_color_ctm_3x4 *ctm = NULL;
1392+
int i = 0;
1393+
1394+
/* 3x4 matrix */
1395+
old_colorop = colorop;
1396+
for_each_new_colorop_in_state(state, colorop, new_colorop_state, i) {
1397+
if (new_colorop_state->colorop == old_colorop &&
1398+
new_colorop_state->colorop->type == DRM_COLOROP_CTM_3X4) {
1399+
colorop_state = new_colorop_state;
1400+
break;
1401+
}
1402+
}
1403+
1404+
if (colorop_state && !colorop_state->bypass && colorop->type == DRM_COLOROP_CTM_3X4) {
1405+
drm_dbg(dev, "3x4 matrix colorop with ID: %d\n", colorop->base.id);
1406+
blob = colorop_state->data;
1407+
if (blob->length == sizeof(struct drm_color_ctm_3x4)) {
1408+
ctm = (struct drm_color_ctm_3x4 *) blob->data;
1409+
__drm_ctm_3x4_to_dc_matrix(ctm, dc_plane_state->gamut_remap_matrix.matrix);
1410+
dc_plane_state->gamut_remap_matrix.enable_remap = true;
1411+
dc_plane_state->input_csc_color_matrix.enable_adjustment = false;
1412+
} else {
1413+
drm_warn(dev, "blob->length (%zu) isn't equal to drm_color_ctm_3x4 (%zu)\n",
1414+
blob->length, sizeof(struct drm_color_ctm_3x4));
1415+
return -EINVAL;
1416+
}
1417+
}
1418+
1419+
return 0;
1420+
}
1421+
13811422
static int
13821423
__set_dm_plane_colorop_shaper(struct drm_plane_state *plane_state,
13831424
struct dc_plane_state *dc_plane_state,
@@ -1581,6 +1622,17 @@ amdgpu_dm_plane_set_colorop_properties(struct drm_plane_state *plane_state,
15811622
if (ret)
15821623
return ret;
15831624

1625+
/* 3x4 matrix */
1626+
colorop = colorop->next;
1627+
if (!colorop) {
1628+
drm_dbg(dev, "no 3x4 matrix colorop found\n");
1629+
return -EINVAL;
1630+
}
1631+
1632+
ret = __set_dm_plane_colorop_3x4_matrix(plane_state, dc_plane_state, colorop);
1633+
if (ret)
1634+
return ret;
1635+
15841636
/* 1D Curve & LUT - SHAPER TF & LUT */
15851637
colorop = colorop->next;
15861638
if (!colorop) {

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

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,21 @@ int amdgpu_dm_initialize_default_pipeline(struct drm_plane *plane, struct drm_pr
7474

7575
i++;
7676

77+
/* 3x4 matrix */
78+
ops[i] = kzalloc(sizeof(struct drm_colorop), GFP_KERNEL);
79+
if (!ops[i]) {
80+
ret = -ENOMEM;
81+
goto cleanup;
82+
}
83+
84+
ret = drm_plane_colorop_ctm_3x4_init(dev, ops[i], plane);
85+
if (ret)
86+
goto cleanup;
87+
88+
drm_colorop_set_next_property(ops[i-1], ops[i]);
89+
90+
i++;
91+
7792
/* 1D curve - SHAPER TF */
7893
ops[i] = kzalloc(sizeof(*ops[0]), GFP_KERNEL);
7994
if (!ops[i]) {

0 commit comments

Comments
 (0)