All of lore.kernel.org
 help / color / mirror / Atom feed
From: abhinavk@codeaurora.org
To: Dmitry Baryshkov <dmitry.baryshkov@linaro.org>
Cc: Bjorn Andersson <bjorn.andersson@linaro.org>,
	Rob Clark <robdclark@gmail.com>, Sean Paul <sean@poorly.run>,
	Jonathan Marek <jonathan@marek.ca>,
	Stephen Boyd <sboyd@kernel.org>,
	linux-arm-msm@vger.kernel.org, dri-devel@lists.freedesktop.org,
	David Airlie <airlied@linux.ie>, Daniel Vetter <daniel@ffwll.ch>,
	freedreno@lists.freedesktop.org
Subject: Re: [Freedreno] [PATCH] drm/msm/dpu: add support for alpha blending properties
Date: Tue, 17 Aug 2021 10:48:30 -0700	[thread overview]
Message-ID: <34ee522aa37172099dac9f686f0196ec@codeaurora.org> (raw)
In-Reply-To: <20210628191958.2754731-1-dmitry.baryshkov@linaro.org>

On 2021-06-28 12:19, Dmitry Baryshkov wrote:
> Add support for alpha blending properties. Setup the plane blend state
> according to those properties.
> 
> Signed-off-by: Dmitry Baryshkov <dmitry.baryshkov@linaro.org>

I think this has already been picked up by Rob but just had a couple of 
comments
below.

Also, how has this been validated? On RB boards i dont think all the 
paths get
executed.

> ---
>  drivers/gpu/drm/msm/disp/dpu1/dpu_crtc.c  | 43 ++++++++++++++++-------
>  drivers/gpu/drm/msm/disp/dpu1/dpu_plane.c | 10 ++++--
>  2 files changed, 37 insertions(+), 16 deletions(-)
> 
> diff --git a/drivers/gpu/drm/msm/disp/dpu1/dpu_crtc.c
> b/drivers/gpu/drm/msm/disp/dpu1/dpu_crtc.c
> index 9a5c70c87cc8..768012243b44 100644
> --- a/drivers/gpu/drm/msm/disp/dpu1/dpu_crtc.c
> +++ b/drivers/gpu/drm/msm/disp/dpu1/dpu_crtc.c
> @@ -30,12 +30,6 @@
>  #include "dpu_core_perf.h"
>  #include "dpu_trace.h"
> 
> -#define DPU_DRM_BLEND_OP_NOT_DEFINED    0
> -#define DPU_DRM_BLEND_OP_OPAQUE         1
> -#define DPU_DRM_BLEND_OP_PREMULTIPLIED  2
> -#define DPU_DRM_BLEND_OP_COVERAGE       3
> -#define DPU_DRM_BLEND_OP_MAX            4
> -
>  /* layer mixer index on dpu_crtc */
>  #define LEFT_MIXER 0
>  #define RIGHT_MIXER 1
> @@ -146,20 +140,43 @@ static void _dpu_crtc_setup_blend_cfg(struct
> dpu_crtc_mixer *mixer,
>  {
>  	struct dpu_hw_mixer *lm = mixer->hw_lm;
>  	uint32_t blend_op;
> +	uint32_t fg_alpha, bg_alpha;
> 
> -	/* default to opaque blending */
> -	blend_op = DPU_BLEND_FG_ALPHA_FG_CONST |
> -		DPU_BLEND_BG_ALPHA_BG_CONST;
> +	fg_alpha = pstate->base.alpha >> 8;
> +	bg_alpha = 0xff - fg_alpha;
> 
> -	if (format->alpha_enable) {
> +	/* default to opaque blending */
> +	if (pstate->base.pixel_blend_mode == DRM_MODE_BLEND_PIXEL_NONE ||
> +	    !format->alpha_enable) {
> +		blend_op = DPU_BLEND_FG_ALPHA_FG_CONST |
> +			DPU_BLEND_BG_ALPHA_BG_CONST;
> +	} else if (pstate->base.pixel_blend_mode == DRM_MODE_BLEND_PREMULTI) 
> {
> +		blend_op = DPU_BLEND_FG_ALPHA_FG_CONST |
> +			DPU_BLEND_BG_ALPHA_FG_PIXEL;
> +		if (fg_alpha != 0xff) {
> +			bg_alpha = fg_alpha;
> +			blend_op |= DPU_BLEND_BG_MOD_ALPHA |
> +				    DPU_BLEND_BG_INV_MOD_ALPHA;
> +		} else {
> +			blend_op |= DPU_BLEND_BG_INV_ALPHA;
> +		}
> +	} else {
>  		/* coverage blending */
>  		blend_op = DPU_BLEND_FG_ALPHA_FG_PIXEL |
> -			DPU_BLEND_BG_ALPHA_FG_PIXEL |
> -			DPU_BLEND_BG_INV_ALPHA;
> +			DPU_BLEND_BG_ALPHA_FG_PIXEL;
> +		if (fg_alpha != 0xff) {
> +			bg_alpha = fg_alpha;
> +			blend_op |= DPU_BLEND_FG_MOD_ALPHA |
> +				    DPU_BLEND_FG_INV_MOD_ALPHA |
comparing this with the blend rule downstream, is this inversion 
necessary?
I only see below rule downstream:

628 			if (fg_alpha != 0xff) {
629 				bg_alpha = fg_alpha;
630 				blend_op |= SDE_BLEND_FG_MOD_ALPHA |
631 					SDE_BLEND_BG_MOD_ALPHA |
632 					SDE_BLEND_BG_INV_MOD_ALPHA;

> +				    DPU_BLEND_BG_MOD_ALPHA |
> +				    DPU_BLEND_BG_INV_MOD_ALPHA;
> +		} else {
> +			blend_op |= DPU_BLEND_BG_INV_ALPHA;
> +		}
>  	}
> 
>  	lm->ops.setup_blend_config(lm, pstate->stage,
> -				0xFF, 0, blend_op);
> +				fg_alpha, bg_alpha, blend_op);
> 
>  	DRM_DEBUG_ATOMIC("format:%p4cc, alpha_en:%u blend_op:0x%x\n",
>  		  &format->base.pixel_format, format->alpha_enable, blend_op);
> diff --git a/drivers/gpu/drm/msm/disp/dpu1/dpu_plane.c
> b/drivers/gpu/drm/msm/disp/dpu1/dpu_plane.c
> index ec4a6f04394a..c989621209aa 100644
> --- a/drivers/gpu/drm/msm/disp/dpu1/dpu_plane.c
> +++ b/drivers/gpu/drm/msm/disp/dpu1/dpu_plane.c
> @@ -1339,9 +1339,7 @@ static void dpu_plane_reset(struct drm_plane 
> *plane)
>  		return;
>  	}
> 
> -	pstate->base.plane = plane;
> -
> -	plane->state = &pstate->base;
> +	__drm_atomic_helper_plane_reset(plane, &pstate->base);
>  }
> 
>  #ifdef CONFIG_DEBUG_FS
> @@ -1647,6 +1645,12 @@ struct drm_plane *dpu_plane_init(struct 
> drm_device *dev,
>  	if (ret)
>  		DPU_ERROR("failed to install zpos property, rc = %d\n", ret);
> 
> +	drm_plane_create_alpha_property(plane);
> +	drm_plane_create_blend_mode_property(plane,
> +			BIT(DRM_MODE_BLEND_PIXEL_NONE) |
> +			BIT(DRM_MODE_BLEND_PREMULTI) |
> +			BIT(DRM_MODE_BLEND_COVERAGE));
> +
>  	drm_plane_create_rotation_property(plane,
>  			DRM_MODE_ROTATE_0,
>  			DRM_MODE_ROTATE_0 |

  reply	other threads:[~2021-08-17 17:48 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-06-28 19:19 [PATCH] drm/msm/dpu: add support for alpha blending properties Dmitry Baryshkov
2021-06-28 19:19 ` Dmitry Baryshkov
2021-08-17 17:48 ` abhinavk [this message]
2021-08-18 19:34   ` [Freedreno] " Dmitry Baryshkov

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=34ee522aa37172099dac9f686f0196ec@codeaurora.org \
    --to=abhinavk@codeaurora.org \
    --cc=airlied@linux.ie \
    --cc=bjorn.andersson@linaro.org \
    --cc=daniel@ffwll.ch \
    --cc=dmitry.baryshkov@linaro.org \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=freedreno@lists.freedesktop.org \
    --cc=jonathan@marek.ca \
    --cc=linux-arm-msm@vger.kernel.org \
    --cc=robdclark@gmail.com \
    --cc=sboyd@kernel.org \
    --cc=sean@poorly.run \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.