From 374649cd8df83d71be78905c07c0068ddddc3cc2 Mon Sep 17 00:00:00 2001 From: Pekka Paalanen Date: Thu, 4 Jun 2026 16:08:51 +0300 Subject: [PATCH] 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 --- libweston/backend-drm/kms.c | 30 +++++++++++++++++++++--------- 1 file changed, 21 insertions(+), 9 deletions(-) diff --git a/libweston/backend-drm/kms.c b/libweston/backend-drm/kms.c index 0c13dec82..321454de6 100644 --- a/libweston/backend-drm/kms.c +++ b/libweston/backend-drm/kms.c @@ -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;