Skip to content

Commit 2468963

Browse files
Harry Wentlandemersion
authored andcommitted
drm/colorop: allow non-bypass colorops
Not all HW will be able to do bypass on all color operations. Introduce an 32 bits 'flags' for all colorop init functions and DRM_COLOROP_FLAG_ALLOW_BYPASS for creating the BYPASS property when it's true. 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: Simon Ser <contact@emersion.fr> 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-45-alex.hung@amd.com
1 parent 7fa3ee8 commit 2468963

5 files changed

Lines changed: 63 additions & 40 deletions

File tree

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

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,9 @@ int amdgpu_dm_initialize_default_pipeline(struct drm_plane *plane, struct drm_pr
6565
goto cleanup;
6666
}
6767

68-
ret = drm_plane_colorop_curve_1d_init(dev, ops[i], plane, amdgpu_dm_supported_degam_tfs);
68+
ret = drm_plane_colorop_curve_1d_init(dev, ops[i], plane,
69+
amdgpu_dm_supported_degam_tfs,
70+
DRM_COLOROP_FLAG_ALLOW_BYPASS);
6971
if (ret)
7072
goto cleanup;
7173

@@ -81,7 +83,7 @@ int amdgpu_dm_initialize_default_pipeline(struct drm_plane *plane, struct drm_pr
8183
goto cleanup;
8284
}
8385

84-
ret = drm_plane_colorop_mult_init(dev, ops[i], plane);
86+
ret = drm_plane_colorop_mult_init(dev, ops[i], plane, DRM_COLOROP_FLAG_ALLOW_BYPASS);
8587
if (ret)
8688
goto cleanup;
8789

@@ -96,7 +98,7 @@ int amdgpu_dm_initialize_default_pipeline(struct drm_plane *plane, struct drm_pr
9698
goto cleanup;
9799
}
98100

99-
ret = drm_plane_colorop_ctm_3x4_init(dev, ops[i], plane);
101+
ret = drm_plane_colorop_ctm_3x4_init(dev, ops[i], plane, DRM_COLOROP_FLAG_ALLOW_BYPASS);
100102
if (ret)
101103
goto cleanup;
102104

@@ -111,7 +113,9 @@ int amdgpu_dm_initialize_default_pipeline(struct drm_plane *plane, struct drm_pr
111113
goto cleanup;
112114
}
113115

114-
ret = drm_plane_colorop_curve_1d_init(dev, ops[i], plane, amdgpu_dm_supported_shaper_tfs);
116+
ret = drm_plane_colorop_curve_1d_init(dev, ops[i], plane,
117+
amdgpu_dm_supported_shaper_tfs,
118+
DRM_COLOROP_FLAG_ALLOW_BYPASS);
115119
if (ret)
116120
goto cleanup;
117121

@@ -127,7 +131,8 @@ int amdgpu_dm_initialize_default_pipeline(struct drm_plane *plane, struct drm_pr
127131
}
128132

129133
ret = drm_plane_colorop_curve_1d_lut_init(dev, ops[i], plane, MAX_COLOR_LUT_ENTRIES,
130-
DRM_COLOROP_LUT1D_INTERPOLATION_LINEAR);
134+
DRM_COLOROP_LUT1D_INTERPOLATION_LINEAR,
135+
DRM_COLOROP_FLAG_ALLOW_BYPASS);
131136
if (ret)
132137
goto cleanup;
133138

@@ -142,7 +147,9 @@ int amdgpu_dm_initialize_default_pipeline(struct drm_plane *plane, struct drm_pr
142147
goto cleanup;
143148
}
144149

145-
ret = drm_plane_colorop_curve_1d_init(dev, ops[i], plane, amdgpu_dm_supported_blnd_tfs);
150+
ret = drm_plane_colorop_curve_1d_init(dev, ops[i], plane,
151+
amdgpu_dm_supported_blnd_tfs,
152+
DRM_COLOROP_FLAG_ALLOW_BYPASS);
146153
if (ret)
147154
goto cleanup;
148155

@@ -158,7 +165,8 @@ int amdgpu_dm_initialize_default_pipeline(struct drm_plane *plane, struct drm_pr
158165
}
159166

160167
ret = drm_plane_colorop_curve_1d_lut_init(dev, ops[i], plane, MAX_COLOR_LUT_ENTRIES,
161-
DRM_COLOROP_LUT1D_INTERPOLATION_LINEAR);
168+
DRM_COLOROP_LUT1D_INTERPOLATION_LINEAR,
169+
DRM_COLOROP_FLAG_ALLOW_BYPASS);
162170
if (ret)
163171
goto cleanup;
164172

drivers/gpu/drm/drm_atomic.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -787,7 +787,8 @@ static void drm_atomic_colorop_print_state(struct drm_printer *p,
787787

788788
drm_printf(p, "colorop[%u]:\n", colorop->base.id);
789789
drm_printf(p, "\ttype=%s\n", drm_get_colorop_type_name(colorop->type));
790-
drm_printf(p, "\tbypass=%u\n", state->bypass);
790+
if (colorop->bypass_property)
791+
drm_printf(p, "\tbypass=%u\n", state->bypass);
791792

792793
switch (colorop->type) {
793794
case DRM_COLOROP_1D_CURVE:

drivers/gpu/drm/drm_colorop.c

Lines changed: 26 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,8 @@ static const struct drm_prop_enum_list drm_colorop_lut1d_interpolation_list[] =
8585
/* Init Helpers */
8686

8787
static int drm_plane_colorop_init(struct drm_device *dev, struct drm_colorop *colorop,
88-
struct drm_plane *plane, enum drm_colorop_type type)
88+
struct drm_plane *plane, enum drm_colorop_type type,
89+
uint32_t flags)
8990
{
9091
struct drm_mode_config *config = &dev->mode_config;
9192
struct drm_property *prop;
@@ -121,16 +122,18 @@ static int drm_plane_colorop_init(struct drm_device *dev, struct drm_colorop *co
121122
colorop->type_property,
122123
colorop->type);
123124

124-
/* bypass */
125-
prop = drm_property_create_bool(dev, DRM_MODE_PROP_ATOMIC,
126-
"BYPASS");
127-
if (!prop)
128-
return -ENOMEM;
129-
130-
colorop->bypass_property = prop;
131-
drm_object_attach_property(&colorop->base,
132-
colorop->bypass_property,
133-
1);
125+
if (flags & DRM_COLOROP_FLAG_ALLOW_BYPASS) {
126+
/* bypass */
127+
prop = drm_property_create_bool(dev, DRM_MODE_PROP_ATOMIC,
128+
"BYPASS");
129+
if (!prop)
130+
return -ENOMEM;
131+
132+
colorop->bypass_property = prop;
133+
drm_object_attach_property(&colorop->base,
134+
colorop->bypass_property,
135+
1);
136+
}
134137

135138
/* next */
136139
prop = drm_property_create_object(dev, DRM_MODE_PROP_IMMUTABLE | DRM_MODE_PROP_ATOMIC,
@@ -195,10 +198,11 @@ EXPORT_SYMBOL(drm_colorop_pipeline_destroy);
195198
* @supported_tfs: A bitfield of supported drm_plane_colorop_curve_1d_init enum values,
196199
* created using BIT(curve_type) and combined with the OR '|'
197200
* operator.
201+
* @flags: bitmask of misc, see DRM_COLOROP_FLAG_* defines.
198202
* @return zero on success, -E value on failure
199203
*/
200204
int drm_plane_colorop_curve_1d_init(struct drm_device *dev, struct drm_colorop *colorop,
201-
struct drm_plane *plane, u64 supported_tfs)
205+
struct drm_plane *plane, u64 supported_tfs, uint32_t flags)
202206
{
203207
struct drm_prop_enum_list enum_list[DRM_COLOROP_1D_CURVE_COUNT];
204208
int i, len;
@@ -219,7 +223,7 @@ int drm_plane_colorop_curve_1d_init(struct drm_device *dev, struct drm_colorop *
219223
return -EINVAL;
220224
}
221225

222-
ret = drm_plane_colorop_init(dev, colorop, plane, DRM_COLOROP_1D_CURVE);
226+
ret = drm_plane_colorop_init(dev, colorop, plane, DRM_COLOROP_1D_CURVE, flags);
223227
if (ret)
224228
return ret;
225229

@@ -278,16 +282,18 @@ static int drm_colorop_create_data_prop(struct drm_device *dev, struct drm_color
278282
* @plane: The associated drm_plane
279283
* @lut_size: LUT size supported by driver
280284
* @interpolation: 1D LUT interpolation type
285+
* @flags: bitmask of misc, see DRM_COLOROP_FLAG_* defines.
281286
* @return zero on success, -E value on failure
282287
*/
283288
int drm_plane_colorop_curve_1d_lut_init(struct drm_device *dev, struct drm_colorop *colorop,
284289
struct drm_plane *plane, uint32_t lut_size,
285-
enum drm_colorop_lut1d_interpolation_type interpolation)
290+
enum drm_colorop_lut1d_interpolation_type interpolation,
291+
uint32_t flags)
286292
{
287293
struct drm_property *prop;
288294
int ret;
289295

290-
ret = drm_plane_colorop_init(dev, colorop, plane, DRM_COLOROP_1D_LUT);
296+
ret = drm_plane_colorop_init(dev, colorop, plane, DRM_COLOROP_1D_LUT, flags);
291297
if (ret)
292298
return ret;
293299

@@ -325,11 +331,11 @@ int drm_plane_colorop_curve_1d_lut_init(struct drm_device *dev, struct drm_color
325331
EXPORT_SYMBOL(drm_plane_colorop_curve_1d_lut_init);
326332

327333
int drm_plane_colorop_ctm_3x4_init(struct drm_device *dev, struct drm_colorop *colorop,
328-
struct drm_plane *plane)
334+
struct drm_plane *plane, uint32_t flags)
329335
{
330336
int ret;
331337

332-
ret = drm_plane_colorop_init(dev, colorop, plane, DRM_COLOROP_CTM_3X4);
338+
ret = drm_plane_colorop_init(dev, colorop, plane, DRM_COLOROP_CTM_3X4, flags);
333339
if (ret)
334340
return ret;
335341

@@ -349,15 +355,16 @@ EXPORT_SYMBOL(drm_plane_colorop_ctm_3x4_init);
349355
* @dev: DRM device
350356
* @colorop: The drm_colorop object to initialize
351357
* @plane: The associated drm_plane
358+
* @flags: bitmask of misc, see DRM_COLOROP_FLAG_* defines.
352359
* @return zero on success, -E value on failure
353360
*/
354361
int drm_plane_colorop_mult_init(struct drm_device *dev, struct drm_colorop *colorop,
355-
struct drm_plane *plane)
362+
struct drm_plane *plane, uint32_t flags)
356363
{
357364
struct drm_property *prop;
358365
int ret;
359366

360-
ret = drm_plane_colorop_init(dev, colorop, plane, DRM_COLOROP_MULTIPLIER);
367+
ret = drm_plane_colorop_init(dev, colorop, plane, DRM_COLOROP_MULTIPLIER, flags);
361368
if (ret)
362369
return ret;
363370

drivers/gpu/drm/vkms/vkms_colorop.c

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,8 @@ static int vkms_initialize_color_pipeline(struct drm_plane *plane, struct drm_pr
3131
goto cleanup;
3232
}
3333

34-
ret = drm_plane_colorop_curve_1d_init(dev, ops[i], plane, supported_tfs);
34+
ret = drm_plane_colorop_curve_1d_init(dev, ops[i], plane, supported_tfs,
35+
DRM_COLOROP_FLAG_ALLOW_BYPASS);
3536
if (ret)
3637
goto cleanup;
3738

@@ -48,7 +49,7 @@ static int vkms_initialize_color_pipeline(struct drm_plane *plane, struct drm_pr
4849
goto cleanup;
4950
}
5051

51-
ret = drm_plane_colorop_ctm_3x4_init(dev, ops[i], plane);
52+
ret = drm_plane_colorop_ctm_3x4_init(dev, ops[i], plane, DRM_COLOROP_FLAG_ALLOW_BYPASS);
5253
if (ret)
5354
goto cleanup;
5455

@@ -64,7 +65,7 @@ static int vkms_initialize_color_pipeline(struct drm_plane *plane, struct drm_pr
6465
goto cleanup;
6566
}
6667

67-
ret = drm_plane_colorop_ctm_3x4_init(dev, ops[i], plane);
68+
ret = drm_plane_colorop_ctm_3x4_init(dev, ops[i], plane, DRM_COLOROP_FLAG_ALLOW_BYPASS);
6869
if (ret)
6970
goto cleanup;
7071

@@ -80,7 +81,8 @@ static int vkms_initialize_color_pipeline(struct drm_plane *plane, struct drm_pr
8081
goto cleanup;
8182
}
8283

83-
ret = drm_plane_colorop_curve_1d_init(dev, ops[i], plane, supported_tfs);
84+
ret = drm_plane_colorop_curve_1d_init(dev, ops[i], plane, supported_tfs,
85+
DRM_COLOROP_FLAG_ALLOW_BYPASS);
8486
if (ret)
8587
goto cleanup;
8688

include/drm/drm_colorop.h

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,9 @@
3131
#include <drm/drm_mode.h>
3232
#include <drm/drm_property.h>
3333

34+
/* DRM colorop flags */
35+
#define DRM_COLOROP_FLAG_ALLOW_BYPASS (1<<0) /* Allow bypass on the drm_colorop */
36+
3437
/**
3538
* enum drm_colorop_curve_1d_type - type of 1D curve
3639
*
@@ -256,11 +259,12 @@ struct drm_colorop {
256259
* @bypass_property:
257260
*
258261
* Boolean property to control enablement of the color
259-
* operation. Setting bypass to "true" shall always be supported
260-
* in order to allow compositors to quickly fall back to
261-
* alternate methods of color processing. This is important
262-
* since setting color operations can fail due to unique
263-
* HW constraints.
262+
* operation. Only present if DRM_COLOROP_FLAG_ALLOW_BYPASS
263+
* flag is set. When present, setting bypass to "true" shall
264+
* always be supported to allow compositors to quickly fall
265+
* back to alternate methods of color processing. This is
266+
* important since setting color operations can fail due to
267+
* unique HW constraints.
264268
*/
265269
struct drm_property *bypass_property;
266270

@@ -353,14 +357,15 @@ void drm_colorop_pipeline_destroy(struct drm_device *dev);
353357
void drm_colorop_cleanup(struct drm_colorop *colorop);
354358

355359
int drm_plane_colorop_curve_1d_init(struct drm_device *dev, struct drm_colorop *colorop,
356-
struct drm_plane *plane, u64 supported_tfs);
360+
struct drm_plane *plane, u64 supported_tfs, uint32_t flags);
357361
int drm_plane_colorop_curve_1d_lut_init(struct drm_device *dev, struct drm_colorop *colorop,
358362
struct drm_plane *plane, uint32_t lut_size,
359-
enum drm_colorop_lut1d_interpolation_type interpolation);
363+
enum drm_colorop_lut1d_interpolation_type interpolation,
364+
uint32_t flags);
360365
int drm_plane_colorop_ctm_3x4_init(struct drm_device *dev, struct drm_colorop *colorop,
361-
struct drm_plane *plane);
366+
struct drm_plane *plane, uint32_t flags);
362367
int drm_plane_colorop_mult_init(struct drm_device *dev, struct drm_colorop *colorop,
363-
struct drm_plane *plane);
368+
struct drm_plane *plane, uint32_t flags);
364369

365370
struct drm_colorop_state *
366371
drm_atomic_helper_colorop_duplicate_state(struct drm_colorop *colorop);

0 commit comments

Comments
 (0)