Skip to content

Commit 52da832

Browse files
Alex Hungemersion
authored andcommitted
drm/amd/display: Add support for sRGB EOTF in BLND block
Expose a 3rd 1D curve colorop, with support for DRM_COLOROP_1D_CURVE_SRGB_EOTF and program the BLND block to perform the sRGB transform when the colorop is not in bypass With this change the following IGT test passes: kms_colorop --run plane-XR30-XR30-srgb_eotf-srgb_inv_eotf-srgb_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 3. 1D curve colorop w/ sRGB 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-31-alex.hung@amd.com
1 parent 167c3a6 commit 52da832

3 files changed

Lines changed: 94 additions & 0 deletions

File tree

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

Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1304,6 +1304,70 @@ __set_dm_plane_colorop_shaper(struct drm_plane_state *plane_state,
13041304
return __set_colorop_in_shaper_1d_curve(dc_plane_state, colorop_state);
13051305
}
13061306

1307+
static int
1308+
__set_colorop_1d_curve_blend_tf_lut(struct dc_plane_state *dc_plane_state,
1309+
struct drm_colorop_state *colorop_state)
1310+
{
1311+
struct dc_transfer_func *tf = &dc_plane_state->blend_tf;
1312+
struct drm_colorop *colorop = colorop_state->colorop;
1313+
struct drm_device *drm = colorop->dev;
1314+
const struct drm_color_lut *blend_lut = NULL;
1315+
u32 blend_size = 0;
1316+
1317+
if (colorop->type != DRM_COLOROP_1D_CURVE &&
1318+
colorop_state->curve_1d_type != DRM_COLOROP_1D_CURVE_SRGB_EOTF)
1319+
return -EINVAL;
1320+
1321+
if (colorop_state->bypass) {
1322+
tf->type = TF_TYPE_BYPASS;
1323+
tf->tf = TRANSFER_FUNCTION_LINEAR;
1324+
return 0;
1325+
}
1326+
1327+
drm_dbg(drm, "Blend colorop with ID: %d\n", colorop->base.id);
1328+
1329+
if (colorop->type == DRM_COLOROP_1D_CURVE) {
1330+
tf->type = TF_TYPE_DISTRIBUTED_POINTS;
1331+
tf->tf = amdgpu_colorop_tf_to_dc_tf(colorop_state->curve_1d_type);
1332+
tf->sdr_ref_white_level = SDR_WHITE_LEVEL_INIT_VALUE;
1333+
return __set_input_tf(NULL, tf, blend_lut, blend_size);
1334+
}
1335+
1336+
return -EINVAL;
1337+
}
1338+
1339+
static int
1340+
__set_dm_plane_colorop_blend(struct drm_plane_state *plane_state,
1341+
struct dc_plane_state *dc_plane_state,
1342+
struct drm_colorop *colorop)
1343+
{
1344+
struct drm_colorop *old_colorop;
1345+
struct drm_colorop_state *colorop_state = NULL, *new_colorop_state;
1346+
struct drm_atomic_state *state = plane_state->state;
1347+
int i = 0;
1348+
1349+
old_colorop = colorop;
1350+
1351+
/* 3nd op: 1d curve - blend */
1352+
for_each_new_colorop_in_state(state, colorop, new_colorop_state, i) {
1353+
if (new_colorop_state->colorop == old_colorop &&
1354+
new_colorop_state->curve_1d_type == DRM_COLOROP_1D_CURVE_SRGB_EOTF) {
1355+
colorop_state = new_colorop_state;
1356+
break;
1357+
}
1358+
1359+
if (new_colorop_state->colorop == old_colorop) {
1360+
colorop_state = new_colorop_state;
1361+
break;
1362+
}
1363+
}
1364+
1365+
if (!colorop_state)
1366+
return -EINVAL;
1367+
1368+
return __set_colorop_1d_curve_blend_tf_lut(dc_plane_state, colorop_state);
1369+
}
1370+
13071371
static int
13081372
amdgpu_dm_plane_set_color_properties(struct drm_plane_state *plane_state,
13091373
struct dc_plane_state *dc_plane_state)
@@ -1381,6 +1445,17 @@ amdgpu_dm_plane_set_colorop_properties(struct drm_plane_state *plane_state,
13811445
if (ret)
13821446
return ret;
13831447

1448+
/* 1D Curve - BLND TF */
1449+
colorop = colorop->next;
1450+
if (!colorop) {
1451+
drm_dbg(dev, "no Blend TF colorop found\n");
1452+
return -EINVAL;
1453+
}
1454+
1455+
ret = __set_dm_plane_colorop_blend(plane_state, dc_plane_state, colorop);
1456+
if (ret)
1457+
return ret;
1458+
13841459
return 0;
13851460
}
13861461

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
@@ -37,6 +37,9 @@ const u64 amdgpu_dm_supported_degam_tfs =
3737
const u64 amdgpu_dm_supported_shaper_tfs =
3838
BIT(DRM_COLOROP_1D_CURVE_SRGB_INV_EOTF);
3939

40+
const u64 amdgpu_dm_supported_blnd_tfs =
41+
BIT(DRM_COLOROP_1D_CURVE_SRGB_EOTF);
42+
4043
#define MAX_COLOR_PIPELINE_OPS 10
4144

4245
int amdgpu_dm_initialize_default_pipeline(struct drm_plane *plane, struct drm_prop_enum_list *list)
@@ -77,6 +80,21 @@ int amdgpu_dm_initialize_default_pipeline(struct drm_plane *plane, struct drm_pr
7780

7881
drm_colorop_set_next_property(ops[i - 1], ops[i]);
7982

83+
i++;
84+
85+
/* 1D curve - BLND TF */
86+
ops[i] = kzalloc(sizeof(*ops[0]), GFP_KERNEL);
87+
if (!ops[i]) {
88+
ret = -ENOMEM;
89+
goto cleanup;
90+
}
91+
92+
ret = drm_plane_colorop_curve_1d_init(dev, ops[i], plane, amdgpu_dm_supported_blnd_tfs);
93+
if (ret)
94+
goto cleanup;
95+
96+
drm_colorop_set_next_property(ops[i - 1], ops[i]);
97+
8098
return 0;
8199

82100
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
@@ -29,6 +29,7 @@
2929

3030
extern const u64 amdgpu_dm_supported_degam_tfs;
3131
extern const u64 amdgpu_dm_supported_shaper_tfs;
32+
extern const u64 amdgpu_dm_supported_blnd_tfs;
3233

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

0 commit comments

Comments
 (0)