drm: split colorop_program()

Enforcing the colorop, that is, ensuring it is not bypassed, is common
to all colorops, so we can pull it into front.

The aim is to get rid of colorop_program(), because it assumes that
every colorop has only one property to program. This makes using
colorop_add_prop_enum() difficult.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
This commit is contained in:
Pekka Paalanen 2026-06-04 16:08:51 +03:00 committed by Leandro Ribeiro
parent e84fa5fd86
commit 374649cd8d

View file

@ -1599,6 +1599,24 @@ drm_plane_set_color_range(struct drm_plane *plane,
color_range);
}
static bool
colorop_enforce(drmModeAtomicReq *req, const struct drm_colorop *colorop,
char **err_msg)
{
int ret;
if (!colorop->can_bypass)
return true;
ret = colorop_add_prop(req, colorop, WDRM_COLOROP_BYPASS, 0);
if (ret == 0)
return true;
str_printf(err_msg, "failed to set colorop id %u bypass to false",
colorop->id);
return false;
}
static bool
colorop_program(drmModeAtomicReq *req, const struct drm_colorop *colorop,
enum wdrm_colorop_property colorop_prop,
@ -1606,15 +1624,6 @@ colorop_program(drmModeAtomicReq *req, const struct drm_colorop *colorop,
{
int ret;
if (colorop->can_bypass) {
ret = colorop_add_prop(req, colorop, WDRM_COLOROP_BYPASS, 0);
if (ret < 0) {
str_printf(err_msg, "failed to set colorop id %u bypass == false",
colorop->id);
return false;
}
}
ret = colorop_add_prop(req, colorop, colorop_prop, prop_val);
if (ret < 0) {
str_printf(err_msg, "failed to program colorop id %u type %s",
@ -1636,6 +1645,9 @@ drm_colorop_program(drmModeAtomicReq *req, struct drm_colorop_state *colorop_sta
enum wdrm_colorop_property colorop_prop;
uint64_t prop_val;
if (!colorop_enforce(req, colorop, err_msg))
return false;
switch (colorop_state->object.type) {
case COLOROP_OBJECT_TYPE_CURVE:
colorop_prop = WDRM_COLOROP_CURVE_1D;