Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 51644606A687 for ; Tue, 24 Nov 2026 18:18:24 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=igalia.com header.i=@igalia.com header.a=rsa-sha256 header.s=20170329 header.b=juILuik8 Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 54BDD10F042; Tue, 24 Nov 2026 18:18:16 +0000 (UTC) Received: from fanzine2.igalia.com (fanzine2.igalia.com [213.97.179.56]) by gabe.freedesktop.org (Postfix) with ESMTPS id C0C0B10F038; Tue, 24 Nov 2026 18:18:09 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=igalia.com; s=20170329; h=Content-Transfer-Encoding:Content-Type:MIME-Version:Message-ID: Date:Subject:Cc:To:From:From:Reply-To; bh=8eTv6DrTYcgKuw+S+/GZbZv5CyQtk23mPZERJ+IZ+y0=; t=1795544289; x=2110904289; b=juILuik8CMczE8dlNP+Mn/BBAGRnb9aOGTJcZoHB8Ny4KqX/ZliYQqGvjzOFJ2CcLx6/UqvmDbQ ZKFdqfRZiZuXjhI7zvcmF3if4d8mDE6O4CWsUddGStYi28WfsP33PFNxEGEZVHWd7xPM5Of+OkBlk Vd/1iLBPHDUqPFy2L0t6EFa5ZGVlGgUM8B5yTf04QazSDgdx/LmocpIUnBXwVh6d3HSW0zQU/GBIm iy6/j+Fd1nsfhyiRPZp199oXntQPXDQC9sTFfH2VAby2ioQSN+s4upixon36WWjhH2kPvqtXADjJ6 9j2wzvEMGreVSa8ZGCmIz6i/kJuBOwMhmbZA==; Received: from 84.125.127.4.dyn.user.ono.com ([84.125.127.4] helo=killbill) by fanzine2.igalia.com with esmtpsa (Cipher TLS1.3:ECDHE_X25519__RSA_PSS_RSAE_SHA256__AES_256_GCM:256) (Exim) id 1xVv5b-00000003axM-2rHx; Tue, 24 Nov 2026 19:17:59 +0100 From: Melissa Wen To: airlied@gmail.com, alexander.deucher@amd.com, christian.koenig@amd.com, harry.wentland@amd.com, maarten.lankhorst@linux.intel.com, mripard@kernel.org, simona@ffwll.ch, siqueira@igalia.com, sunpeng.li@amd.com, tzimmermann@suse.de Cc: Ariel DAlessandro , nfraprado@collabora.com, Alex Hung , Simon Ser , Uma Shankar , Chaitanya Kumar Borah , Robert Mader , Xaver Hugl , Pekka Paalanen , John Harrison , Matthew Schwartz , Daniel Stone , kernel-dev@igalia.com, amd-gfx@lists.freedesktop.org, dri-devel@lists.freedesktop.org, Leandro Ribeiro , Louis Chauvet , Melissa Wen Subject: [PATCH v3 02/19] drm/colorop: Allow parenting colorop to CRTC Date: Tue, 24 Nov 2026 19:03:19 +0100 Message-ID: <20261124181652.1333986-3-mwen@igalia.com> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20261124181652.1333986-1-mwen@igalia.com> References: <20261124181652.1333986-1-mwen@igalia.com> X-Archived-By: MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "dri-devel" X-Spam-Status: No, score=-18.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER,INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE, SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=4.0.1 X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-26) on aws-us-west-2-korg-listserv-alma10-1 From: NĂ­colas F. R. A. Prado In order to allow for post-blend color pipelines, colorops need to be assigned to a crtc rather than a plane. Add a crtc to the colorop struct to enable this. Either the plane or the crtc will be set for any given colorop depending on whether it is part of a pre- or post-blend color pipeline. Signed-off-by: NĂ­colas F. R. A. Prado Co-developed-by: Ariel D'Alessandro Signed-off-by: Ariel D'Alessandro Reviewed-by: Louis Chauvet Reviewed-by: Harry Wentland Signed-off-by: Melissa Wen --- v3: - minor fix of trailing whitespace - rebase on drm-misc-next --- drivers/gpu/drm/drm_atomic.c | 6 +++--- drivers/gpu/drm/drm_colorop.c | 25 +++++++++++++++++++++++++ include/drm/drm_colorop.h | 18 ++++++++++++++++-- 3 files changed, 44 insertions(+), 5 deletions(-) diff --git a/drivers/gpu/drm/drm_atomic.c b/drivers/gpu/drm/drm_atomic.c index 324e79152e17..e72e5e7ee76b 100644 --- a/drivers/gpu/drm/drm_atomic.c +++ b/drivers/gpu/drm/drm_atomic.c @@ -748,7 +748,7 @@ drm_atomic_get_colorop_state(struct drm_atomic_commit *state, if (colorop_state) return colorop_state; - ret = drm_modeset_lock(&colorop->plane->mutex, state->acquire_ctx); + ret = drm_colorop_modeset_lock(colorop, state->acquire_ctx); if (ret) return ERR_PTR(ret); @@ -2213,10 +2213,10 @@ static void __drm_state_dump(struct drm_device *dev, struct drm_printer *p, list_for_each_entry(colorop, &config->colorop_list, head) { if (take_locks) - drm_modeset_lock(&colorop->plane->mutex, NULL); + drm_colorop_modeset_lock(colorop, NULL); drm_atomic_colorop_print_state(p, colorop->state); if (take_locks) - drm_modeset_unlock(&colorop->plane->mutex); + drm_colorop_modeset_unlock(colorop); } list_for_each_entry(plane, &config->plane_list, head) { diff --git a/drivers/gpu/drm/drm_colorop.c b/drivers/gpu/drm/drm_colorop.c index 95da03d6c65c..6b15df55c84f 100644 --- a/drivers/gpu/drm/drm_colorop.c +++ b/drivers/gpu/drm/drm_colorop.c @@ -24,6 +24,7 @@ * */ +#include #include #include #include @@ -774,3 +775,27 @@ void drm_colorop_set_next_property(struct drm_colorop *colorop, struct drm_color colorop->next = next; } EXPORT_SYMBOL(drm_colorop_set_next_property); + +int drm_colorop_modeset_lock(struct drm_colorop *colorop, struct drm_modeset_acquire_ctx *ctx) +{ + if (colorop->plane) + return drm_modeset_lock(&colorop->plane->mutex, ctx); + + if (colorop->crtc) + return drm_modeset_lock(&colorop->crtc->mutex, ctx); + + drm_err(colorop->dev, "Dangling colorop, it must be attached to a plane or a CRTC\n"); + return -EINVAL; +} +EXPORT_SYMBOL(drm_colorop_modeset_lock); + +void drm_colorop_modeset_unlock(struct drm_colorop *colorop) +{ + if (colorop->plane) + drm_modeset_unlock(&colorop->plane->mutex); + else if (colorop->crtc) + drm_modeset_unlock(&colorop->crtc->mutex); + else + drm_err(colorop->dev, "Dangling colorop, it must be attached to a plane or a CRTC\n"); +} +EXPORT_SYMBOL(drm_colorop_modeset_unlock); diff --git a/include/drm/drm_colorop.h b/include/drm/drm_colorop.h index 26ef67c835e2..3a71cecd8273 100644 --- a/include/drm/drm_colorop.h +++ b/include/drm/drm_colorop.h @@ -29,6 +29,7 @@ #include #include +#include #include /* DRM colorop flags */ @@ -365,11 +366,21 @@ struct drm_colorop { /** * @plane: * - * The plane on which the colorop sits. A drm_colorop is always unique - * to a plane. + * The plane on which the colorop sits if it is a pre-blend colorop. + * In this case it is unique to the plane. + * NOTE: plane and crtc are mutually exclusive. */ struct drm_plane *plane; + /** + * @crtc: + * + * The CRTC on which the colorop sits if it is a post-blend colorop. + * In this case it is unique to the CRTC. + * NOTE: plane and crtc are mutually exclusive. + */ + struct drm_crtc *crtc; + /** * @state: * @@ -610,4 +621,7 @@ const char *drm_get_colorop_fixed_matrix_type_name(enum drm_colorop_fixed_matrix void drm_colorop_set_next_property(struct drm_colorop *colorop, struct drm_colorop *next); +int drm_colorop_modeset_lock(struct drm_colorop *colorop, struct drm_modeset_acquire_ctx *ctx); +void drm_colorop_modeset_unlock(struct drm_colorop *colorop); + #endif /* __DRM_COLOROP_H__ */ -- 2.53.0