Skip to content

Commit 167c3a6

Browse files
Alex Hungemersion
authored andcommitted
drm/amd/display: Add support for sRGB Inverse EOTF in SHAPER block
Expose a 2nd curve colorop with support for DRM_COLOROP_1D_CURVE_SRGB_INV_EOTF and program HW to perform the sRGB Inverse EOTF on the shaper block when the colorop is not in bypass. With this change the follow IGT tests pass: kms_colorop --run plane-XR30-XR30-srgb_inv_eotf kms_colorop --run plane-XR30-XR30-srgb_eotf-srgb_inv_eotf The color pipeline now consists of the following colorops: 1. 1D curve colorop w/ sRGB EOTF support 2. 1D curve colorop w/ sRGB Inverse EOTF support Signed-off-by: Alex Hung <alex.hung@amd.com> Co-developed-by: Harry Wentland <harry.wentland@amd.com> Signed-off-by: Harry Wentland <harry.wentland@amd.com> Reviewed-by: Daniel Stone <daniels@collabora.com> Signed-off-by: Simon Ser <contact@emersion.fr> Link: https://patch.msgid.link/20251115000237.3561250-30-alex.hung@amd.com
1 parent 9ba2591 commit 167c3a6

3 files changed

Lines changed: 93 additions & 0 deletions

File tree

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

Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1242,6 +1242,68 @@ __set_dm_plane_colorop_degamma(struct drm_plane_state *plane_state,
12421242
return __set_colorop_in_tf_1d_curve(dc_plane_state, colorop_state);
12431243
}
12441244

1245+
static int
1246+
__set_colorop_in_shaper_1d_curve(struct dc_plane_state *dc_plane_state,
1247+
struct drm_colorop_state *colorop_state)
1248+
{
1249+
struct dc_transfer_func *tf = &dc_plane_state->in_shaper_func;
1250+
struct drm_colorop *colorop = colorop_state->colorop;
1251+
struct drm_device *drm = colorop->dev;
1252+
1253+
if (colorop->type != DRM_COLOROP_1D_CURVE &&
1254+
colorop_state->curve_1d_type != DRM_COLOROP_1D_CURVE_SRGB_INV_EOTF)
1255+
return -EINVAL;
1256+
1257+
if (colorop_state->bypass) {
1258+
tf->type = TF_TYPE_BYPASS;
1259+
tf->tf = TRANSFER_FUNCTION_LINEAR;
1260+
return 0;
1261+
}
1262+
1263+
drm_dbg(drm, "Shaper colorop with ID: %d\n", colorop->base.id);
1264+
1265+
if (colorop->type == DRM_COLOROP_1D_CURVE) {
1266+
tf->type = TF_TYPE_DISTRIBUTED_POINTS;
1267+
tf->tf = amdgpu_colorop_tf_to_dc_tf(colorop_state->curve_1d_type);
1268+
tf->sdr_ref_white_level = SDR_WHITE_LEVEL_INIT_VALUE;
1269+
return __set_output_tf(tf, 0, 0, false);
1270+
}
1271+
1272+
return -EINVAL;
1273+
}
1274+
1275+
static int
1276+
__set_dm_plane_colorop_shaper(struct drm_plane_state *plane_state,
1277+
struct dc_plane_state *dc_plane_state,
1278+
struct drm_colorop *colorop)
1279+
{
1280+
struct drm_colorop *old_colorop;
1281+
struct drm_colorop_state *colorop_state = NULL, *new_colorop_state;
1282+
struct drm_atomic_state *state = plane_state->state;
1283+
int i = 0;
1284+
1285+
old_colorop = colorop;
1286+
1287+
/* 2nd op: 1d curve - shaper */
1288+
for_each_new_colorop_in_state(state, colorop, new_colorop_state, i) {
1289+
if (new_colorop_state->colorop == old_colorop &&
1290+
new_colorop_state->curve_1d_type == DRM_COLOROP_1D_CURVE_SRGB_INV_EOTF) {
1291+
colorop_state = new_colorop_state;
1292+
break;
1293+
}
1294+
1295+
if (new_colorop_state->colorop == old_colorop) {
1296+
colorop_state = new_colorop_state;
1297+
break;
1298+
}
1299+
}
1300+
1301+
if (!colorop_state)
1302+
return -EINVAL;
1303+
1304+
return __set_colorop_in_shaper_1d_curve(dc_plane_state, colorop_state);
1305+
}
1306+
12451307
static int
12461308
amdgpu_dm_plane_set_color_properties(struct drm_plane_state *plane_state,
12471309
struct dc_plane_state *dc_plane_state)
@@ -1297,6 +1359,7 @@ amdgpu_dm_plane_set_colorop_properties(struct drm_plane_state *plane_state,
12971359
struct dc_plane_state *dc_plane_state)
12981360
{
12991361
struct drm_colorop *colorop = plane_state->color_pipeline;
1362+
struct drm_device *dev = plane_state->plane->dev;
13001363
int ret;
13011364

13021365
/* 1D Curve - DEGAM TF */
@@ -1307,6 +1370,17 @@ amdgpu_dm_plane_set_colorop_properties(struct drm_plane_state *plane_state,
13071370
if (ret)
13081371
return ret;
13091372

1373+
/* 1D Curve - SHAPER TF */
1374+
colorop = colorop->next;
1375+
if (!colorop) {
1376+
drm_dbg(dev, "no Shaper TF colorop found\n");
1377+
return -EINVAL;
1378+
}
1379+
1380+
ret = __set_dm_plane_colorop_shaper(plane_state, dc_plane_state, colorop);
1381+
if (ret)
1382+
return ret;
1383+
13101384
return 0;
13111385
}
13121386

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

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,9 @@
3434
const u64 amdgpu_dm_supported_degam_tfs =
3535
BIT(DRM_COLOROP_1D_CURVE_SRGB_EOTF);
3636

37+
const u64 amdgpu_dm_supported_shaper_tfs =
38+
BIT(DRM_COLOROP_1D_CURVE_SRGB_INV_EOTF);
39+
3740
#define MAX_COLOR_PIPELINE_OPS 10
3841

3942
int amdgpu_dm_initialize_default_pipeline(struct drm_plane *plane, struct drm_prop_enum_list *list)
@@ -59,6 +62,21 @@ int amdgpu_dm_initialize_default_pipeline(struct drm_plane *plane, struct drm_pr
5962
list->type = ops[i]->base.id;
6063
list->name = kasprintf(GFP_KERNEL, "Color Pipeline %d", ops[i]->base.id);
6164

65+
i++;
66+
67+
/* 1D curve - SHAPER TF */
68+
ops[i] = kzalloc(sizeof(*ops[0]), GFP_KERNEL);
69+
if (!ops[i]) {
70+
ret = -ENOMEM;
71+
goto cleanup;
72+
}
73+
74+
ret = drm_plane_colorop_curve_1d_init(dev, ops[i], plane, amdgpu_dm_supported_shaper_tfs);
75+
if (ret)
76+
goto cleanup;
77+
78+
drm_colorop_set_next_property(ops[i - 1], ops[i]);
79+
6280
return 0;
6381

6482
cleanup:

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
#define __AMDGPU_DM_COLOROP_H__
2929

3030
extern const u64 amdgpu_dm_supported_degam_tfs;
31+
extern const u64 amdgpu_dm_supported_shaper_tfs;
3132

3233
int amdgpu_dm_initialize_default_pipeline(struct drm_plane *plane, struct drm_prop_enum_list *list);
3334

0 commit comments

Comments
 (0)