devicetree.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Neil Armstrong <neil.armstrong@linaro.org>
To: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>,
	Abhinav Kumar <quic_abhinavk@quicinc.com>,
	Sean Paul <sean@poorly.run>,
	Marijn Suijten <marijn.suijten@somainline.org>,
	David Airlie <airlied@gmail.com>, Simona Vetter <simona@ffwll.ch>,
	Maarten Lankhorst <maarten.lankhorst@linux.intel.com>,
	Maxime Ripard <mripard@kernel.org>,
	Thomas Zimmermann <tzimmermann@suse.de>,
	Rob Herring <robh@kernel.org>,
	Krzysztof Kozlowski <krzk+dt@kernel.org>,
	Conor Dooley <conor+dt@kernel.org>,
	Krishna Manikandan <quic_mkrishn@quicinc.com>,
	Jonathan Marek <jonathan@marek.ca>,
	Kuogee Hsieh <quic_khsieh@quicinc.com>,
	Dmitry Baryshkov <lumag@kernel.org>,
	Bjorn Andersson <andersson@kernel.org>,
	Michael Turquette <mturquette@baylibre.com>,
	Stephen Boyd <sboyd@kernel.org>,
	Rob Clark <robin.clark@oss.qualcomm.com>
Cc: linux-arm-msm@vger.kernel.org, dri-devel@lists.freedesktop.org,
	freedreno@lists.freedesktop.org, devicetree@vger.kernel.org,
	linux-kernel@vger.kernel.org, linux-clk@vger.kernel.org,
	Abel Vesa <abel.vesa@linaro.org>,
	Srinivas Kandagatla <srini@kernel.org>,
	Dmitry Baryshkov <dmitry.baryshkov@oss.qualcomm.com>
Subject: Re: [PATCH v6 14/17] drm/msm/dpu: Implement 10-bit color alpha for v12.0 DPU
Date: Tue, 10 Jun 2025 16:10:49 +0200	[thread overview]
Message-ID: <3d576c19-6f68-4f04-b89a-e269c438b339@linaro.org> (raw)
In-Reply-To: <20250610-b4-sm8750-display-v6-14-ee633e3ddbff@linaro.org>

On 10/06/2025 16:05, Krzysztof Kozlowski wrote:
> v12.0 DPU on SM8750 comes with 10-bit color alpha.  Add register
> differences and new implementations of setup_alpha_out(),
> setup_border_color() and setup_blend_config().
> 
> Notable changes in v6:
> Correct fg_alpha shift on new DPU, pointed out by Abel Vesas.

-------------------------------------------------------- Vesa

Not sure this should be in the commit message.

> 
> Reviewed-by: Dmitry Baryshkov <dmitry.baryshkov@oss.qualcomm.com>
> Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
> 
> ---
> 
> Changes in v6:
> 1. Checkpatch: CHECK: Prefer kernel type 'u32' over 'uint32_t'
> 2. Fix for fg_alpha shift (Abel Vesa).
> 
> Changes in v4:
> 1. Lowercase hex, use spaces for define indentation
> 2. _dpu_crtc_setup_blend_cfg(): pass mdss_ver instead of ctl
> 
> Changes in v3:
> 1. New patch, split from previous big DPU v12.0.
> ---
>   drivers/gpu/drm/msm/disp/dpu1/dpu_crtc.c  | 23 ++++++---
>   drivers/gpu/drm/msm/disp/dpu1/dpu_hw_lm.c | 84 +++++++++++++++++++++++++++++--
>   2 files changed, 97 insertions(+), 10 deletions(-)
> 
> diff --git a/drivers/gpu/drm/msm/disp/dpu1/dpu_crtc.c b/drivers/gpu/drm/msm/disp/dpu1/dpu_crtc.c
> index 92f6c39eee3dc090bd957239e58793e5b0437548..5e986640c8ce5b49d0ce2f91cc47f677a2e3f061 100644
> --- a/drivers/gpu/drm/msm/disp/dpu1/dpu_crtc.c
> +++ b/drivers/gpu/drm/msm/disp/dpu1/dpu_crtc.c
> @@ -320,14 +320,22 @@ static bool dpu_crtc_get_scanout_position(struct drm_crtc *crtc,
>   }
>   
>   static void _dpu_crtc_setup_blend_cfg(struct dpu_crtc_mixer *mixer,
> -		struct dpu_plane_state *pstate, const struct msm_format *format)
> +				      struct dpu_plane_state *pstate,
> +				      const struct msm_format *format,
> +				      const struct dpu_mdss_version *mdss_ver)
>   {
>   	struct dpu_hw_mixer *lm = mixer->hw_lm;
>   	u32 blend_op;
> -	u32 fg_alpha, bg_alpha;
> +	u32 fg_alpha, bg_alpha, max_alpha;
>   
> -	fg_alpha = pstate->base.alpha >> 8;
> -	bg_alpha = 0xff - fg_alpha;
> +	if (mdss_ver->core_major_ver < 12) {
> +		max_alpha = 0xff;
> +		fg_alpha = pstate->base.alpha >> 8;
> +	} else {
> +		max_alpha = 0x3ff;
> +		fg_alpha = pstate->base.alpha >> 6;
> +	}
> +	bg_alpha = max_alpha - fg_alpha;
>   
>   	/* default to opaque blending */
>   	if (pstate->base.pixel_blend_mode == DRM_MODE_BLEND_PIXEL_NONE ||
> @@ -337,7 +345,7 @@ static void _dpu_crtc_setup_blend_cfg(struct dpu_crtc_mixer *mixer,
>   	} 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) {
> +		if (fg_alpha != max_alpha) {
>   			bg_alpha = fg_alpha;
>   			blend_op |= DPU_BLEND_BG_MOD_ALPHA |
>   				    DPU_BLEND_BG_INV_MOD_ALPHA;
> @@ -348,7 +356,7 @@ static void _dpu_crtc_setup_blend_cfg(struct dpu_crtc_mixer *mixer,
>   		/* coverage blending */
>   		blend_op = DPU_BLEND_FG_ALPHA_FG_PIXEL |
>   			DPU_BLEND_BG_ALPHA_FG_PIXEL;
> -		if (fg_alpha != 0xff) {
> +		if (fg_alpha != max_alpha) {
>   			bg_alpha = fg_alpha;
>   			blend_op |= DPU_BLEND_FG_MOD_ALPHA |
>   				    DPU_BLEND_FG_INV_MOD_ALPHA |
> @@ -481,7 +489,8 @@ static void _dpu_crtc_blend_setup_mixer(struct drm_crtc *crtc,
>   
>   		/* blend config update */
>   		for (lm_idx = 0; lm_idx < cstate->num_mixers; lm_idx++) {
> -			_dpu_crtc_setup_blend_cfg(mixer + lm_idx, pstate, format);
> +			_dpu_crtc_setup_blend_cfg(mixer + lm_idx, pstate, format,
> +						  ctl->mdss_ver);
>   
>   			if (bg_alpha_enable && !format->alpha_enable)
>   				mixer[lm_idx].mixer_op_mode = 0;
> diff --git a/drivers/gpu/drm/msm/disp/dpu1/dpu_hw_lm.c b/drivers/gpu/drm/msm/disp/dpu1/dpu_hw_lm.c
> index 3bfb61cb83672dca4236bdbbbfb1e442223576d2..f220a68e138cb9e7c88194e53e47391de7ed04f7 100644
> --- a/drivers/gpu/drm/msm/disp/dpu1/dpu_hw_lm.c
> +++ b/drivers/gpu/drm/msm/disp/dpu1/dpu_hw_lm.c
> @@ -19,12 +19,20 @@
>   
>   /* These register are offset to mixer base + stage base */
>   #define LM_BLEND0_OP                     0x00
> +
> +/* <v12 DPU with offset to mixer base + stage base */
>   #define LM_BLEND0_CONST_ALPHA            0x04
>   #define LM_FG_COLOR_FILL_COLOR_0         0x08
>   #define LM_FG_COLOR_FILL_COLOR_1         0x0C
>   #define LM_FG_COLOR_FILL_SIZE            0x10
>   #define LM_FG_COLOR_FILL_XY              0x14
>   
> +/* >= v12 DPU */
> +#define LM_BORDER_COLOR_0_V12            0x1c
> +#define LM_BORDER_COLOR_1_V12            0x20
> +
> +/* >= v12 DPU with offset to mixer base + stage base */
> +#define LM_BLEND0_CONST_ALPHA_V12        0x08
>   #define LM_BLEND0_FG_ALPHA               0x04
>   #define LM_BLEND0_BG_ALPHA               0x08
>   
> @@ -83,6 +91,22 @@ static void dpu_hw_lm_setup_border_color(struct dpu_hw_mixer *ctx,
>   	}
>   }
>   
> +static void dpu_hw_lm_setup_border_color_v12(struct dpu_hw_mixer *ctx,
> +					     struct dpu_mdss_color *color,
> +					     u8 border_en)
> +{
> +	struct dpu_hw_blk_reg_map *c = &ctx->hw;
> +
> +	if (border_en) {
> +		DPU_REG_WRITE(c, LM_BORDER_COLOR_0_V12,
> +			      (color->color_0 & 0x3ff) |
> +			      ((color->color_1 & 0x3ff) << 16));
> +		DPU_REG_WRITE(c, LM_BORDER_COLOR_1_V12,
> +			      (color->color_2 & 0x3ff) |
> +			      ((color->color_3 & 0x3ff) << 16));
> +	}
> +}
> +
>   static void dpu_hw_lm_setup_misr(struct dpu_hw_mixer *ctx)
>   {
>   	dpu_hw_setup_misr(&ctx->hw, LM_MISR_CTRL, 0x0);
> @@ -112,6 +136,27 @@ static void dpu_hw_lm_setup_blend_config_combined_alpha(struct dpu_hw_mixer *ctx
>   	DPU_REG_WRITE(c, LM_BLEND0_OP + stage_off, blend_op);
>   }
>   
> +static void
> +dpu_hw_lm_setup_blend_config_combined_alpha_v12(struct dpu_hw_mixer *ctx,
> +						u32 stage, u32 fg_alpha,
> +						u32 bg_alpha, u32 blend_op)
> +{
> +	struct dpu_hw_blk_reg_map *c = &ctx->hw;
> +	int stage_off;
> +	u32 const_alpha;
> +
> +	if (stage == DPU_STAGE_BASE)
> +		return;
> +
> +	stage_off = _stage_offset(ctx, stage);
> +	if (WARN_ON(stage_off < 0))
> +		return;
> +
> +	const_alpha = (bg_alpha & 0x3ff) | ((fg_alpha & 0x3ff) << 16);
> +	DPU_REG_WRITE(c, LM_BLEND0_CONST_ALPHA_V12 + stage_off, const_alpha);
> +	DPU_REG_WRITE(c, LM_BLEND0_OP + stage_off, blend_op);
> +}
> +
>   static void dpu_hw_lm_setup_blend_config(struct dpu_hw_mixer *ctx,
>   	u32 stage, u32 fg_alpha, u32 bg_alpha, u32 blend_op)
>   {
> @@ -144,6 +189,32 @@ static void dpu_hw_lm_setup_color3(struct dpu_hw_mixer *ctx,
>   	DPU_REG_WRITE(c, LM_OP_MODE, op_mode);
>   }
>   
> +static void dpu_hw_lm_setup_color3_v12(struct dpu_hw_mixer *ctx,
> +				       uint32_t mixer_op_mode)
> +{
> +	struct dpu_hw_blk_reg_map *c = &ctx->hw;
> +	int op_mode, stages, stage_off, i;
> +
> +	stages = ctx->cap->sblk->maxblendstages;
> +	if (stages <= 0)
> +		return;
> +
> +	for (i = DPU_STAGE_0; i <= stages; i++) {
> +		stage_off = _stage_offset(ctx, i);
> +		if (WARN_ON(stage_off < 0))
> +			return;
> +
> +		/* set color_out3 bit in blend0_op when enabled in mixer_op_mode */
> +		op_mode = DPU_REG_READ(c, LM_BLEND0_OP + stage_off);
> +		if (mixer_op_mode & BIT(i))
> +			op_mode |= BIT(30);
> +		else
> +			op_mode &= ~BIT(30);
> +
> +		DPU_REG_WRITE(c, LM_BLEND0_OP + stage_off, op_mode);
> +	}
> +}
> +
>   /**
>    * dpu_hw_lm_init() - Initializes the mixer hw driver object.
>    * should be called once before accessing every mixer.
> @@ -175,12 +246,19 @@ struct dpu_hw_mixer *dpu_hw_lm_init(struct drm_device *dev,
>   	c->idx = cfg->id;
>   	c->cap = cfg;
>   	c->ops.setup_mixer_out = dpu_hw_lm_setup_out;
> -	if (mdss_ver->core_major_ver >= 4)
> +	if (mdss_ver->core_major_ver >= 12)
> +		c->ops.setup_blend_config = dpu_hw_lm_setup_blend_config_combined_alpha_v12;
> +	else if (mdss_ver->core_major_ver >= 4)
>   		c->ops.setup_blend_config = dpu_hw_lm_setup_blend_config_combined_alpha;
>   	else
>   		c->ops.setup_blend_config = dpu_hw_lm_setup_blend_config;
> -	c->ops.setup_alpha_out = dpu_hw_lm_setup_color3;
> -	c->ops.setup_border_color = dpu_hw_lm_setup_border_color;
> +	if (mdss_ver->core_major_ver < 12) {
> +		c->ops.setup_alpha_out = dpu_hw_lm_setup_color3;
> +		c->ops.setup_border_color = dpu_hw_lm_setup_border_color;
> +	} else {
> +		c->ops.setup_alpha_out = dpu_hw_lm_setup_color3_v12;
> +		c->ops.setup_border_color = dpu_hw_lm_setup_border_color_v12;
> +	}
>   	c->ops.setup_misr = dpu_hw_lm_setup_misr;
>   	c->ops.collect_misr = dpu_hw_lm_collect_misr;
>   
> 


  reply	other threads:[~2025-06-10 14:10 UTC|newest]

Thread overview: 36+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-06-10 14:05 [PATCH v6 00/17] drm/msm: Add support for SM8750 Krzysztof Kozlowski
2025-06-10 14:05 ` [PATCH v6 01/17] dt-bindings: display/msm: dsi-phy-7nm: Add SM8750 Krzysztof Kozlowski
2025-06-10 14:05 ` [PATCH v6 02/17] dt-bindings: display/msm: dsi-controller-main: " Krzysztof Kozlowski
2025-06-10 14:05 ` [PATCH v6 03/17] dt-bindings: display/msm: dp-controller: " Krzysztof Kozlowski
2025-06-10 14:05 ` [PATCH v6 04/17] dt-bindings: display/msm: qcom,sm8650-dpu: " Krzysztof Kozlowski
2025-06-10 14:05 ` [PATCH v6 05/17] dt-bindings: display/msm: qcom,sm8750-mdss: " Krzysztof Kozlowski
2025-06-10 14:05 ` [PATCH v6 06/17] drm/msm/dsi/phy: Toggle back buffer resync after preparing PLL Krzysztof Kozlowski
2025-08-13 18:25   ` Krzysztof Kozlowski
2025-06-10 14:05 ` [PATCH v6 07/17] drm/msm/dsi/phy: Define PHY_CMN_CTRL_0 bitfields Krzysztof Kozlowski
2025-06-10 22:23   ` Dmitry Baryshkov
2025-06-10 14:05 ` [PATCH v6 08/17] drm/msm/dsi/phy: Fix reading zero as PLL rates when unprepared Krzysztof Kozlowski
2025-06-13 13:55   ` Dmitry Baryshkov
2025-06-13 14:02     ` Krzysztof Kozlowski
2025-06-13 14:04       ` Dmitry Baryshkov
2025-06-18  8:28         ` Krzysztof Kozlowski
2025-06-18 13:07           ` Dmitry Baryshkov
2025-06-18 13:34             ` Krzysztof Kozlowski
2025-06-18 13:35               ` Krzysztof Kozlowski
2025-06-18 13:39               ` Dmitry Baryshkov
2025-06-18 13:54                 ` Krzysztof Kozlowski
2025-06-18 13:58                   ` Dmitry Baryshkov
2025-06-18 14:01                     ` Krzysztof Kozlowski
2025-06-10 14:05 ` [PATCH v6 09/17] drm/msm/dsi/phy_7nm: Fix missing initial VCO rate Krzysztof Kozlowski
2025-06-10 14:05 ` [PATCH v6 10/17] drm/msm/dsi/phy: Add support for SM8750 Krzysztof Kozlowski
2025-06-10 14:05 ` [PATCH v6 11/17] drm/msm/dsi: " Krzysztof Kozlowski
2025-06-10 22:25   ` Dmitry Baryshkov
2025-06-10 14:05 ` [PATCH v6 12/17] drm/msm/dpu: " Krzysztof Kozlowski
2025-06-10 14:05 ` [PATCH v6 13/17] drm/msm/dpu: Consistently use u32 instead of uint32_t Krzysztof Kozlowski
2025-06-10 14:10   ` Neil Armstrong
2025-06-10 22:25   ` Dmitry Baryshkov
2025-06-10 14:05 ` [PATCH v6 14/17] drm/msm/dpu: Implement 10-bit color alpha for v12.0 DPU Krzysztof Kozlowski
2025-06-10 14:10   ` Neil Armstrong [this message]
2025-06-11  6:21     ` Krzysztof Kozlowski
2025-06-10 14:05 ` [PATCH v6 15/17] drm/msm/dpu: Implement CTL_PIPE_ACTIVE " Krzysztof Kozlowski
2025-06-10 14:05 ` [PATCH v6 16/17] drm/msm/dpu: Implement LM crossbar " Krzysztof Kozlowski
2025-06-10 14:05 ` [PATCH v6 17/17] drm/msm/mdss: Add support for SM8750 Krzysztof Kozlowski

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=3d576c19-6f68-4f04-b89a-e269c438b339@linaro.org \
    --to=neil.armstrong@linaro.org \
    --cc=abel.vesa@linaro.org \
    --cc=airlied@gmail.com \
    --cc=andersson@kernel.org \
    --cc=conor+dt@kernel.org \
    --cc=devicetree@vger.kernel.org \
    --cc=dmitry.baryshkov@oss.qualcomm.com \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=freedreno@lists.freedesktop.org \
    --cc=jonathan@marek.ca \
    --cc=krzk+dt@kernel.org \
    --cc=krzysztof.kozlowski@linaro.org \
    --cc=linux-arm-msm@vger.kernel.org \
    --cc=linux-clk@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=lumag@kernel.org \
    --cc=maarten.lankhorst@linux.intel.com \
    --cc=marijn.suijten@somainline.org \
    --cc=mripard@kernel.org \
    --cc=mturquette@baylibre.com \
    --cc=quic_abhinavk@quicinc.com \
    --cc=quic_khsieh@quicinc.com \
    --cc=quic_mkrishn@quicinc.com \
    --cc=robh@kernel.org \
    --cc=robin.clark@oss.qualcomm.com \
    --cc=sboyd@kernel.org \
    --cc=sean@poorly.run \
    --cc=simona@ffwll.ch \
    --cc=srini@kernel.org \
    --cc=tzimmermann@suse.de \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).