From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from bali.collaboradmins.com (bali.collaboradmins.com [148.251.105.195]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 89A7F3D903C for ; Fri, 24 Apr 2026 14:35:30 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=148.251.105.195 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1777041332; cv=none; b=KCHoR7GA1u34axPhM0zNR63AYeqdLnGyy4cyGUIeHl3qsXmJ0hD20KDwgyglWPuj9j6l5OPuv9Lv7WYur1cOUQhvhNgwUanKuwZNVcNKdX3jXuBAj+v9h6EOlcL6VPlFcxvu0naSqlW3s3mlWC2oLb19d3uYVYkXVZV2wx2PHUQ= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1777041332; c=relaxed/simple; bh=NbpmYKGZw/Pqew/el3dH36fIk2h0sO59mM8ho7ndNVI=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=G+MVcvZgO7rG5gGgQS4wUINmXFdsAm66TEBWPnVsecSpnNGNg7CtZybw6oeeIRPmO9YXirZhnsq2FfZ3C24BWKOzN7iPp0nWI/qo1y5O4eDGVLdQYfTtGpqGMH8rLz7gQrmQkyh82BECAZaP4zRqxExIOa4j8wHw0Nejia0p8CI= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=collabora.com; spf=pass smtp.mailfrom=collabora.com; dkim=pass (2048-bit key) header.d=collabora.com header.i=@collabora.com header.b=CauJ++dS; arc=none smtp.client-ip=148.251.105.195 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=collabora.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=collabora.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=collabora.com header.i=@collabora.com header.b="CauJ++dS" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1777041328; bh=NbpmYKGZw/Pqew/el3dH36fIk2h0sO59mM8ho7ndNVI=; h=From:To:Cc:Subject:Date:From; b=CauJ++dSYJ0cSVdWKay4DGecrAb9W8iiXsUXYAYw6kWNN55R1/69B/aCm9TayPUC9 3F1l8p/9hD5DszH/SvFWofBRvlaKX6I2qIPa8hAEmJUhLkpQIP7GiLj5OGedRoBZ+w VE+pz1lN1jaxIxGV241/T3C7urQ2cupK4FYXWQGWeUchn9oWn1Lg8Rh89Zd8QFRv89 w4Xa4obe5U720O9QZ1alkrVMk4H/Aj37Yk3mrj4Os6FIueblKR6ICq15NQdJYUaTX3 tE5b4naFYNgkn+Tf6JDw13MX+rX0X011WooJvbsr5iZ9b6EEpp0lFQFjJl1yOX1ArK 0wjM10jS4fEgQ== Received: from archlinux (unknown [100.64.1.80]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) (Authenticated sender: leandrohrb) by bali.collaboradmins.com (Postfix) with ESMTPSA id DF00317E1321; Fri, 24 Apr 2026 16:35:24 +0200 (CEST) From: Leandro Ribeiro To: dri-devel@lists.freedesktop.org Cc: airlied@gmail.com, daniels@collabora.com, maarten.lankhorst@linux.intel.com, mripard@kernel.org, pekka.paalanen@collabora.com, simona@ffwll.ch, tzimmermann@suse.de, ville.syrjala@linux.intel.com, linux-kernel@vger.kernel.org, Leandro Ribeiro Subject: [PATCH] drm/drm_blend: allow blend mode property without PREMULTI Date: Fri, 24 Apr 2026 11:35:13 -0300 Message-ID: <20260424143513.13004-1-leandro.ribeiro@collabora.com> X-Mailer: git-send-email 2.54.0 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Some hardware only supports the COVERAGE blend mode and lacks PREMULTI support entirely. DRM currently requires that PREMULTI is present when creating a blend mode property, which prevents such drivers from being properly upstreamed. Remove this restriction and allow drivers to create a blend mode property without PREMULTI, enabling support for hardware that implements only COVERAGE blend mode. This does not introduce a regression, as no existing upstream drivers expose only COVERAGE. However, userspace that wants to support such kind of hardware in the future will have to check the supported blend modes instead of assuming PREMULTI is always supported. If the driver does not support the blend mode property, userspace must assume that only PREMULTI is supported (as was the case before this patch). Signed-off-by: Leandro Ribeiro --- drivers/gpu/drm/drm_blend.c | 24 +++++++++++++++++------- 1 file changed, 17 insertions(+), 7 deletions(-) diff --git a/drivers/gpu/drm/drm_blend.c b/drivers/gpu/drm/drm_blend.c index 1f3af27d2418..e5015d0fb219 100644 --- a/drivers/gpu/drm/drm_blend.c +++ b/drivers/gpu/drm/drm_blend.c @@ -563,10 +563,10 @@ EXPORT_SYMBOL(drm_atomic_normalize_zpos); /** * drm_plane_create_blend_mode_property - create a new blend mode property * @plane: drm plane - * @supported_modes: bitmask of supported modes, must include - * BIT(DRM_MODE_BLEND_PREMULTI). Current DRM assumption is - * that alpha is premultiplied, and old userspace can break if - * the property defaults to anything else. + * @supported_modes: bitmask of supported modes. When + * BIT(DRM_MODE_BLEND_PREMULTI) is included, it will be used + * as the default. Otherwise, the default will fallback to one + * of the supported modes. * * This creates a new property describing the blend mode. * @@ -586,6 +586,9 @@ EXPORT_SYMBOL(drm_atomic_normalize_zpos); * pre-multiplied and will do so when blending them to the background color * values. * + * Note: if the blend mode property is not present, userspace must assume that + * the driver supports only "Pre-multiplied". + * * RETURNS: * Zero for success or -errno */ @@ -599,13 +602,13 @@ int drm_plane_create_blend_mode_property(struct drm_plane *plane, { DRM_MODE_BLEND_PREMULTI, "Pre-multiplied" }, { DRM_MODE_BLEND_COVERAGE, "Coverage" }, }; + unsigned int default_mode; unsigned int valid_mode_mask = BIT(DRM_MODE_BLEND_PIXEL_NONE) | BIT(DRM_MODE_BLEND_PREMULTI) | BIT(DRM_MODE_BLEND_COVERAGE); int i; - if (WARN_ON((supported_modes & ~valid_mode_mask) || - ((supported_modes & BIT(DRM_MODE_BLEND_PREMULTI)) == 0))) + if (WARN_ON((supported_modes & ~valid_mode_mask))) return -EINVAL; prop = drm_property_create(dev, DRM_MODE_PROP_ENUM, @@ -630,7 +633,14 @@ int drm_plane_create_blend_mode_property(struct drm_plane *plane, } } - drm_object_attach_property(&plane->base, prop, DRM_MODE_BLEND_PREMULTI); + if (supported_modes & BIT(DRM_MODE_BLEND_PREMULTI)) + default_mode = DRM_MODE_BLEND_PREMULTI; + else if (supported_modes & BIT(DRM_MODE_BLEND_COVERAGE)) + default_mode = DRM_MODE_BLEND_COVERAGE; + else + default_mode = DRM_MODE_BLEND_PIXEL_NONE; + + drm_object_attach_property(&plane->base, prop, default_mode); plane->blend_mode_property = prop; return 0; -- 2.54.0