Skip to content

Commit 7fa3ee8

Browse files
Harry Wentlandemersion
authored andcommitted
drm/colorop: Define LUT_1D interpolation
We want to make sure userspace is aware of the 1D LUT interpolation. While linear interpolation is common it might not be supported on all HW. Give driver implementers a way to specify their interpolation. Reviewed-by: Simon Ser <contact@emersion.fr> 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> Reviewed-by: Sebastian Wick <sebastian.wick@redhat.com> Signed-off-by: Simon Ser <contact@emersion.fr> Link: https://patch.msgid.link/20251115000237.3561250-44-alex.hung@amd.com
1 parent 68186c7 commit 7fa3ee8

6 files changed

Lines changed: 79 additions & 4 deletions

File tree

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

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,8 @@ int amdgpu_dm_initialize_default_pipeline(struct drm_plane *plane, struct drm_pr
126126
goto cleanup;
127127
}
128128

129-
ret = drm_plane_colorop_curve_1d_lut_init(dev, ops[i], plane, MAX_COLOR_LUT_ENTRIES);
129+
ret = drm_plane_colorop_curve_1d_lut_init(dev, ops[i], plane, MAX_COLOR_LUT_ENTRIES,
130+
DRM_COLOROP_LUT1D_INTERPOLATION_LINEAR);
130131
if (ret)
131132
goto cleanup;
132133

@@ -156,7 +157,8 @@ int amdgpu_dm_initialize_default_pipeline(struct drm_plane *plane, struct drm_pr
156157
goto cleanup;
157158
}
158159

159-
ret = drm_plane_colorop_curve_1d_lut_init(dev, ops[i], plane, MAX_COLOR_LUT_ENTRIES);
160+
ret = drm_plane_colorop_curve_1d_lut_init(dev, ops[i], plane, MAX_COLOR_LUT_ENTRIES,
161+
DRM_COLOROP_LUT1D_INTERPOLATION_LINEAR);
160162
if (ret)
161163
goto cleanup;
162164

drivers/gpu/drm/drm_atomic.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -796,6 +796,8 @@ static void drm_atomic_colorop_print_state(struct drm_printer *p,
796796
break;
797797
case DRM_COLOROP_1D_LUT:
798798
drm_printf(p, "\tsize=%d\n", colorop->size);
799+
drm_printf(p, "\tinterpolation=%s\n",
800+
drm_get_colorop_lut1d_interpolation_name(colorop->lut1d_interpolation));
799801
drm_printf(p, "\tdata blob id=%d\n", state->data ? state->data->base.id : 0);
800802
break;
801803
case DRM_COLOROP_CTM_3X4:

drivers/gpu/drm/drm_atomic_uapi.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -726,6 +726,8 @@ static int drm_atomic_colorop_set_property(struct drm_colorop *colorop,
726726
{
727727
if (property == colorop->bypass_property) {
728728
state->bypass = val;
729+
} else if (property == colorop->lut1d_interpolation_property) {
730+
colorop->lut1d_interpolation = val;
729731
} else if (property == colorop->curve_1d_type_property) {
730732
state->curve_1d_type = val;
731733
} else if (property == colorop->multiplier_property) {
@@ -753,6 +755,8 @@ drm_atomic_colorop_get_property(struct drm_colorop *colorop,
753755
*val = colorop->type;
754756
else if (property == colorop->bypass_property)
755757
*val = state->bypass;
758+
else if (property == colorop->lut1d_interpolation_property)
759+
*val = colorop->lut1d_interpolation;
756760
else if (property == colorop->curve_1d_type_property)
757761
*val = state->curve_1d_type;
758762
else if (property == colorop->multiplier_property)

drivers/gpu/drm/drm_colorop.c

Lines changed: 36 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,10 @@ static const char * const colorop_curve_1d_type_names[] = {
7878
[DRM_COLOROP_1D_CURVE_BT2020_OETF] = "BT.2020 OETF",
7979
};
8080

81+
static const struct drm_prop_enum_list drm_colorop_lut1d_interpolation_list[] = {
82+
{ DRM_COLOROP_LUT1D_INTERPOLATION_LINEAR, "Linear" },
83+
};
84+
8185
/* Init Helpers */
8286

8387
static int drm_plane_colorop_init(struct drm_device *dev, struct drm_colorop *colorop,
@@ -273,10 +277,12 @@ static int drm_colorop_create_data_prop(struct drm_device *dev, struct drm_color
273277
* @colorop: The drm_colorop object to initialize
274278
* @plane: The associated drm_plane
275279
* @lut_size: LUT size supported by driver
280+
* @interpolation: 1D LUT interpolation type
276281
* @return zero on success, -E value on failure
277282
*/
278283
int drm_plane_colorop_curve_1d_lut_init(struct drm_device *dev, struct drm_colorop *colorop,
279-
struct drm_plane *plane, uint32_t lut_size)
284+
struct drm_plane *plane, uint32_t lut_size,
285+
enum drm_colorop_lut1d_interpolation_type interpolation)
280286
{
281287
struct drm_property *prop;
282288
int ret;
@@ -296,6 +302,17 @@ int drm_plane_colorop_curve_1d_lut_init(struct drm_device *dev, struct drm_color
296302
drm_object_attach_property(&colorop->base, colorop->size_property, lut_size);
297303
colorop->size = lut_size;
298304

305+
/* interpolation */
306+
prop = drm_property_create_enum(dev, 0, "LUT1D_INTERPOLATION",
307+
drm_colorop_lut1d_interpolation_list,
308+
ARRAY_SIZE(drm_colorop_lut1d_interpolation_list));
309+
if (!prop)
310+
return -ENOMEM;
311+
312+
colorop->lut1d_interpolation_property = prop;
313+
drm_object_attach_property(&colorop->base, prop, interpolation);
314+
colorop->lut1d_interpolation = interpolation;
315+
299316
/* data */
300317
ret = drm_colorop_create_data_prop(dev, colorop);
301318
if (ret)
@@ -449,6 +466,9 @@ static const char * const colorop_type_name[] = {
449466
[DRM_COLOROP_CTM_3X4] = "3x4 Matrix",
450467
[DRM_COLOROP_MULTIPLIER] = "Multiplier",
451468
};
469+
static const char * const colorop_lut1d_interpolation_name[] = {
470+
[DRM_COLOROP_LUT1D_INTERPOLATION_LINEAR] = "Linear",
471+
};
452472

453473
const char *drm_get_colorop_type_name(enum drm_colorop_type type)
454474
{
@@ -466,6 +486,21 @@ const char *drm_get_colorop_curve_1d_type_name(enum drm_colorop_curve_1d_type ty
466486
return colorop_curve_1d_type_names[type];
467487
}
468488

489+
/**
490+
* drm_get_colorop_lut1d_interpolation_name: return a string for interpolation type
491+
* @type: interpolation type to compute name of
492+
*
493+
* In contrast to the other drm_get_*_name functions this one here returns a
494+
* const pointer and hence is threadsafe.
495+
*/
496+
const char *drm_get_colorop_lut1d_interpolation_name(enum drm_colorop_lut1d_interpolation_type type)
497+
{
498+
if (WARN_ON(type >= ARRAY_SIZE(colorop_lut1d_interpolation_name)))
499+
return "unknown";
500+
501+
return colorop_lut1d_interpolation_name[type];
502+
}
503+
469504
/**
470505
* drm_colorop_set_next_property - sets the next pointer
471506
* @colorop: drm colorop

include/drm/drm_colorop.h

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -271,6 +271,21 @@ struct drm_colorop {
271271
*/
272272
uint32_t size;
273273

274+
/**
275+
* @lut1d_interpolation:
276+
*
277+
* Read-only
278+
* Interpolation for DRM_COLOROP_1D_LUT
279+
*/
280+
enum drm_colorop_lut1d_interpolation_type lut1d_interpolation;
281+
282+
/**
283+
* @lut1d_interpolation_property:
284+
*
285+
* Read-only property for DRM_COLOROP_1D_LUT interpolation
286+
*/
287+
struct drm_property *lut1d_interpolation_property;
288+
274289
/**
275290
* @curve_1d_type_property:
276291
*
@@ -340,7 +355,8 @@ void drm_colorop_cleanup(struct drm_colorop *colorop);
340355
int drm_plane_colorop_curve_1d_init(struct drm_device *dev, struct drm_colorop *colorop,
341356
struct drm_plane *plane, u64 supported_tfs);
342357
int drm_plane_colorop_curve_1d_lut_init(struct drm_device *dev, struct drm_colorop *colorop,
343-
struct drm_plane *plane, uint32_t lut_size);
358+
struct drm_plane *plane, uint32_t lut_size,
359+
enum drm_colorop_lut1d_interpolation_type interpolation);
344360
int drm_plane_colorop_ctm_3x4_init(struct drm_device *dev, struct drm_colorop *colorop,
345361
struct drm_plane *plane);
346362
int drm_plane_colorop_mult_init(struct drm_device *dev, struct drm_colorop *colorop,
@@ -394,6 +410,9 @@ const char *drm_get_colorop_type_name(enum drm_colorop_type type);
394410
*/
395411
const char *drm_get_colorop_curve_1d_type_name(enum drm_colorop_curve_1d_type type);
396412

413+
const char *
414+
drm_get_colorop_lut1d_interpolation_name(enum drm_colorop_lut1d_interpolation_type type);
415+
397416
void drm_colorop_set_next_property(struct drm_colorop *colorop, struct drm_colorop *next);
398417

399418
#endif /* __DRM_COLOROP_H__ */

include/uapi/drm/drm_mode.h

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -944,6 +944,19 @@ enum drm_colorop_type {
944944
DRM_COLOROP_MULTIPLIER,
945945
};
946946

947+
/**
948+
* enum drm_colorop_lut1d_interpolation_type - type of interpolation for 1D LUTs
949+
*/
950+
enum drm_colorop_lut1d_interpolation_type {
951+
/**
952+
* @DRM_COLOROP_LUT1D_INTERPOLATION_LINEAR:
953+
*
954+
* Linear interpolation. Values between points of the LUT will be
955+
* linearly interpolated.
956+
*/
957+
DRM_COLOROP_LUT1D_INTERPOLATION_LINEAR,
958+
};
959+
947960
/**
948961
* struct drm_plane_size_hint - Plane size hints
949962
* @width: The width of the plane in pixel

0 commit comments

Comments
 (0)