Received: by 2002:ac0:a5b6:0:0:0:0:0 with SMTP id m51-v6csp3626260imm; Mon, 4 Jun 2018 06:50:35 -0700 (PDT) X-Google-Smtp-Source: ADUXVKK/RzZO8O4hlUU3UbriW2Je82trEdkCkJqREzpdD0mnaAAsSEVqFaiCLD3wTAR6J+ccrz0y X-Received: by 2002:a17:902:9004:: with SMTP id a4-v6mr21720233plp.143.1528120235489; Mon, 04 Jun 2018 06:50:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1528120235; cv=none; d=google.com; s=arc-20160816; b=u7h4B7+0pBXwVC4D6ex12FwgMEpKgICK+f9sclNVsnkMB1L9XA9LH8MTT3F7pZh/8R f8chvGKu3aJrHT740wIWWXFp//q4FxTwfugecT/GfxWWZW2KhBtbF9D6V/bLOOeUA1yc rMoO9C3Vw14hSUrn5TVMPjHA3BHjVWvB5qNFLtL3Vjkni5gbxTkXjOnUAmkgQB5ePsoM b7s+57JvdFbtYSNANIoIpZaxI8d6N9jMLOIVk0+25WNi9aGyPuGlNqIT4sqFyuf5csB2 FKPymp1fLdBmT9Y8E1nh8/t/kAgduxPkRoQpDs6G6q5El+0tKdEQqp01zkLShVK9VXEG 8DAQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :references:in-reply-to:mime-version:dkim-signature :arc-authentication-results; bh=qa5AEHCSPB/piFpOD374b2DBnqh0iy3LWdnlqqQGDfM=; b=SxZ44MnqSzsPCj9PuVGJ6LlXFWnajD44+S3AQXTj+D0F16pqn/fdOJuEGCo60NB2qX jQE6AikjGrsfZbVS2z97K338SChIBqjKOcqtwMrw5njmfnyaQ8xr9jbrWYYOYP4OHgiS gS4/b92SUnA0cQYgYAgELxx5mp61nm6Cv66I4cZscIGbdw0WM/9Sdc352cVNgizUOPzM 5MKYErmZ2xb21gQeAyT3IH25/vtvF4KkEBcnLo3TfIDok7Wt4U+D2uSRPRdI9Lg/rlxl j9KN3ObZDXO5V5+sptH5mrYQXSC5rPnKc2EXumzNyF045O2/9cHNbqXHcO3dygcwPk1i ixTw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=sZLbm6Qw; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id e8-v6si5182281pgq.333.2018.06.04.06.50.21; Mon, 04 Jun 2018 06:50:35 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=sZLbm6Qw; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753385AbeFDNte (ORCPT + 99 others); Mon, 4 Jun 2018 09:49:34 -0400 Received: from mail-wr0-f196.google.com ([209.85.128.196]:42738 "EHLO mail-wr0-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753063AbeFDNt2 (ORCPT ); Mon, 4 Jun 2018 09:49:28 -0400 Received: by mail-wr0-f196.google.com with SMTP id w10-v6so43673068wrk.9 for ; Mon, 04 Jun 2018 06:49:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc; bh=qa5AEHCSPB/piFpOD374b2DBnqh0iy3LWdnlqqQGDfM=; b=sZLbm6Qwb4z/hjW2e0U2O5L887BN+itxeg1uOMpl5OD9X6Amg44DOSdiKOMQNdQJXf 8WMpfFx/lcrava+rdnMGB8a/Ef3xFkhFG4MudKmqU+1eg/flYrmpSMxUfOed3JwzSs4G +5GJtCJBL5PxL/phH77B5DPJRTBwy4w18p23e8kaYafo2EhgAAbV+9Xt8ZlCmd66zVGq BnmKpncO3B8DDbKeypDM65534pdUpbdijnCV/KVZIgWr1e7fdal0VEuTQLRsigpHKj4z bYGsrXWQiyX5wbH+EBaDufAsC4lj4MJewxLZwlj45CDU7Dg57nLjwKlxU8Rg1BkSnjvs twJw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc; bh=qa5AEHCSPB/piFpOD374b2DBnqh0iy3LWdnlqqQGDfM=; b=Rforll/4UHkhtw1B2x8udo/PlkvthEDleJfltZMRezitovcUWCeBafbu4LMdaS4Aw9 /b1jFQfjM+H8OEWTv3gHCf14DZx6h/oVOCMV+N61XDJnclkQRxBe9qBx9JsZQpyhVA08 ASOPkTOb4I5MhNMXKD5GOtcfb5QOggc5qZ4rONCLvx9twV5ZyOdpyPxJ5bPi4+AHwT3F gP64uq2j42uUL2LZ2Y+TijAf8A/f3Jqa6gWok95RnyopNm0Er1LYI5LPRwgL4wFHfBX4 k02l+NQtEfU17SLhqP8vzD/Diavc1lbMAJQIz1y9f4R12PFVEgB6RIAdCKhHcrFcPGKK neBQ== X-Gm-Message-State: ALKqPwcXq0SWMrIe5AEcvElily6KJn6MKqDHofsLSunUGVikf24j2i2U Va8RDHMCzq2xsDPJi37FIhnXC+7SrhvBor6IC9I= X-Received: by 2002:adf:f6c9:: with SMTP id y9-v6mr17426520wrp.4.1528120167376; Mon, 04 Jun 2018 06:49:27 -0700 (PDT) MIME-Version: 1.0 Received: by 2002:a1c:afcc:0:0:0:0:0 with HTTP; Mon, 4 Jun 2018 06:49:26 -0700 (PDT) In-Reply-To: <1527856871-3007-2-git-send-email-lowry.li@arm.com> References: <1527856871-3007-1-git-send-email-lowry.li@arm.com> <1527856871-3007-2-git-send-email-lowry.li@arm.com> From: Emil Velikov Date: Mon, 4 Jun 2018 14:49:26 +0100 Message-ID: Subject: Re: [PATCH v3 1/2] drm: Add per-plane pixel blend mode property To: Lowry Li Cc: Liviu Dudau , Gustavo Padovan , Maarten Lankhorst , "Vetter, Daniel" , Sean Paul , David Airlie , =?UTF-8?B?VmlsbGUgU3lyasOkbMOk?= , ML dri-devel , "Linux-Kernel@Vger. Kernel. Org" , Brian Starkey , Mali DP Maintainers , nd@arm.com Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 1 June 2018 at 13:41, Lowry Li wrote: > Pixel blend modes represent the alpha blending equation > selection, describing how the pixels from the current > plane are composited with the background. > > Add a pixel_blend_mode to drm_plane_state and a > blend_mode_property to drm_plane, and related support > functions. > > Defines three blend modes in drm_blend.h. > > Signed-off-by: Lowry Li > --- > drivers/gpu/drm/drm_atomic.c | 4 ++ > drivers/gpu/drm/drm_atomic_helper.c | 1 + > drivers/gpu/drm/drm_blend.c | 126 ++++++++++++++++++++++++++++++++++++ > include/drm/drm_blend.h | 6 ++ > include/drm/drm_plane.h | 5 ++ > 5 files changed, 142 insertions(+) > > diff --git a/drivers/gpu/drm/drm_atomic.c b/drivers/gpu/drm/drm_atomic.c > index 07fef42..1d18389 100644 > --- a/drivers/gpu/drm/drm_atomic.c > +++ b/drivers/gpu/drm/drm_atomic.c > @@ -785,6 +785,8 @@ static int drm_atomic_plane_set_property(struct drm_plane *plane, > state->src_h = val; > } else if (property == plane->alpha_property) { > state->alpha = val; > + } else if (property == plane->blend_mode_property) { > + state->pixel_blend_mode = val; > } else if (property == plane->rotation_property) { > if (!is_power_of_2(val & DRM_MODE_ROTATE_MASK)) > return -EINVAL; > @@ -852,6 +854,8 @@ static int drm_atomic_plane_set_property(struct drm_plane *plane, > *val = state->src_h; > } else if (property == plane->alpha_property) { > *val = state->alpha; > + } else if (property == plane->blend_mode_property) { > + *val = state->pixel_blend_mode; > } else if (property == plane->rotation_property) { > *val = state->rotation; > } else if (property == plane->zpos_property) { > diff --git a/drivers/gpu/drm/drm_atomic_helper.c b/drivers/gpu/drm/drm_atomic_helper.c > index 130da51..7f5d463 100644 > --- a/drivers/gpu/drm/drm_atomic_helper.c > +++ b/drivers/gpu/drm/drm_atomic_helper.c > @@ -3515,6 +3515,7 @@ void drm_atomic_helper_plane_reset(struct drm_plane *plane) > /* Reset the alpha value to fully opaque if it matters */ > if (plane->alpha_property) > plane->state->alpha = plane->alpha_property->values[1]; > + plane->state->pixel_blend_mode = DRM_MODE_BLEND_PREMULTI; > } > } > EXPORT_SYMBOL(drm_atomic_helper_plane_reset); > diff --git a/drivers/gpu/drm/drm_blend.c b/drivers/gpu/drm/drm_blend.c > index a16a74d..ac6f19c 100644 > --- a/drivers/gpu/drm/drm_blend.c > +++ b/drivers/gpu/drm/drm_blend.c > @@ -107,6 +107,52 @@ > * planes. Without this property the primary plane is always below the cursor > * plane, and ordering between all other planes is undefined. > * > + * pixel blend mode: > + * Pixel blend mode is set up with drm_plane_create_blend_mode_property(). > + * It adds a blend mode for alpha blending equation selection, describing > + * how the pixels from the current plane are composited with the > + * background. > + * > + * Three alpha blending equations are defined: > + * > + * "None": > + * Blend formula that ignores the pixel alpha:: > + * > + * out.rgb = plane_alpha * fg.rgb + > + * (1 - plane_alpha) * bg.rgb > + * > + * "Pre-multiplied": > + * Blend formula that assumes the pixel color values > + * have been already pre-multiplied with the alpha > + * channel values:: > + * > + * out.rgb = plane_alpha * fg.rgb + > + * (1 - (plane_alpha * fg.alpha)) * bg.rgb > + * > + * "Coverage": > + * Blend formula that assumes the pixel color values have not > + * been pre-multiplied and will do so when blending them to the > + * background color values:: > + * > + * out.rgb = plane_alpha * fg.alpha * fg.rgb + > + * (1 - (plane_alpha * fg.alpha)) * bg.rgb > + * > + * Using the following symbols: > + * > + * ``fg.rgb``: > + * Each of the RGB component values from the plane's pixel > + * ``fg.alpha``: > + * Alpha component value from the plane's pixel. If the plane's > + * pixel format has no alpha component, then this is assumed to be > + * 1.0. In these cases, this property has no effect, as all three > + * equations become equivalent. > + * ``bg.rgb``: > + * Each of the RGB component values from the background > + * ``plane_alpha``: > + * Plane alpha value set by the plane "alpha" property. If the > + * plane does not expose the "alpha" property, then this is > + * assumed to be 1.0 > + * > * Note that all the property extensions described here apply either to the > * plane or the CRTC (e.g. for the background color, which currently is not > * exposed and assumed to be black). > @@ -448,3 +494,83 @@ int drm_atomic_normalize_zpos(struct drm_device *dev, > return 0; > } > 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 coverage. > + * Thanks for the explanation Lowry. Sigh, old userspace :-\ One pedantic suggestion s/defaults to coverage/defaults to anything else/ Since defaulting to "none" or any future blend mode is also a no-go. I wouldn't bother resending solely for ^^. Perhaps squash locally before merging? With that, the patch is Reviewed-by: Emil Velikov -Emil