diff mbox series

[v2,2/3] drm: rcar-du: Add DRM_MODE_BLEND_PREMULTI support

Message ID 20220810083711.219642-3-taki@igel.co.jp (mailing list archive)
State New
Delegated to: Kieran Bingham
Headers show
Series Add DRM pixel blend mode support to R-Car DU | expand

Commit Message

Takanari Hayama Aug. 10, 2022, 8:37 a.m. UTC
R-Car DU driver implicitly supports DRM_MODE_BLEND_COVERAGE only.
This adds a support for DRM_MODE_BLEND_PREMULTI. As a consequence,
DRM_MODE_BLEND_PREMULTI becomes the default. If DRM_MODE_BLEND_COVERAGE
is desired, it should be set explicitly.

This behavior comes from how DRM blend mode is supported.
drm_plane_create_blend_mode_property() creates the blend mode property
with the default value of DRM_MODE_BLEND_PREMULTI. This default value
cannot be modified from the atomic driver.

Signed-off-by: Takanari Hayama <taki@igel.co.jp>
---
 drivers/gpu/drm/rcar-du/rcar_du_vsp.c | 6 ++++++
 1 file changed, 6 insertions(+)

Comments

Laurent Pinchart Aug. 19, 2022, 2:08 a.m. UTC | #1
Hello Hayama-san,

Thank you for the patch.

On Wed, Aug 10, 2022 at 05:37:10PM +0900, Takanari Hayama wrote:
> R-Car DU driver implicitly supports DRM_MODE_BLEND_COVERAGE only.
> This adds a support for DRM_MODE_BLEND_PREMULTI. As a consequence,
> DRM_MODE_BLEND_PREMULTI becomes the default. If DRM_MODE_BLEND_COVERAGE
> is desired, it should be set explicitly.
> 
> This behavior comes from how DRM blend mode is supported.
> drm_plane_create_blend_mode_property() creates the blend mode property
> with the default value of DRM_MODE_BLEND_PREMULTI. This default value
> cannot be modified from the atomic driver.
> 
> Signed-off-by: Takanari Hayama <taki@igel.co.jp>
> ---
>  drivers/gpu/drm/rcar-du/rcar_du_vsp.c | 6 ++++++
>  1 file changed, 6 insertions(+)
> 
> diff --git a/drivers/gpu/drm/rcar-du/rcar_du_vsp.c b/drivers/gpu/drm/rcar-du/rcar_du_vsp.c
> index 8eb9b2b097ae..b9580fcfec7a 100644
> --- a/drivers/gpu/drm/rcar-du/rcar_du_vsp.c
> +++ b/drivers/gpu/drm/rcar-du/rcar_du_vsp.c
> @@ -167,6 +167,8 @@ static void rcar_du_vsp_plane_setup(struct rcar_du_vsp_plane *plane)
>  		cfg.mem[i] = sg_dma_address(state->sg_tables[i].sgl)
>  			   + fb->offsets[i];
>  
> +	cfg.premult = (state->state.pixel_blend_mode == DRM_MODE_BLEND_PREMULTI);

I'll drop the parentheses here too, and if you don't mind, I'll move
this down after setting cfg.pixelformat, as premult qualifies the format
so it's more logical in that reading order (no change on the behaviour
of course).

Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>

> +
>  	format = rcar_du_format_info(state->format->fourcc);
>  	cfg.pixelformat = format->v4l2;
>  
> @@ -444,6 +446,10 @@ int rcar_du_vsp_init(struct rcar_du_vsp *vsp, struct device_node *np,
>  						       num_planes - 1);
>  		}
>  
> +		drm_plane_create_blend_mode_property(&plane->plane,
> +					BIT(DRM_MODE_BLEND_PREMULTI) |
> +					BIT(DRM_MODE_BLEND_COVERAGE));
> +
>  		vsp->num_planes++;
>  	}
>
Takanari Hayama Aug. 19, 2022, 3:05 a.m. UTC | #2
Hi Laurent,

> 2022/08/19 11:08、Laurent Pinchart <laurent.pinchart@ideasonboard.com>のメール:
> 
> Hello Hayama-san,
> 
> Thank you for the patch.
> 
> On Wed, Aug 10, 2022 at 05:37:10PM +0900, Takanari Hayama wrote:
>> R-Car DU driver implicitly supports DRM_MODE_BLEND_COVERAGE only.
>> This adds a support for DRM_MODE_BLEND_PREMULTI. As a consequence,
>> DRM_MODE_BLEND_PREMULTI becomes the default. If DRM_MODE_BLEND_COVERAGE
>> is desired, it should be set explicitly.
>> 
>> This behavior comes from how DRM blend mode is supported.
>> drm_plane_create_blend_mode_property() creates the blend mode property
>> with the default value of DRM_MODE_BLEND_PREMULTI. This default value
>> cannot be modified from the atomic driver.
>> 
>> Signed-off-by: Takanari Hayama <taki@igel.co.jp>
>> ---
>> drivers/gpu/drm/rcar-du/rcar_du_vsp.c | 6 ++++++
>> 1 file changed, 6 insertions(+)
>> 
>> diff --git a/drivers/gpu/drm/rcar-du/rcar_du_vsp.c b/drivers/gpu/drm/rcar-du/rcar_du_vsp.c
>> index 8eb9b2b097ae..b9580fcfec7a 100644
>> --- a/drivers/gpu/drm/rcar-du/rcar_du_vsp.c
>> +++ b/drivers/gpu/drm/rcar-du/rcar_du_vsp.c
>> @@ -167,6 +167,8 @@ static void rcar_du_vsp_plane_setup(struct rcar_du_vsp_plane *plane)
>> 		cfg.mem[i] = sg_dma_address(state->sg_tables[i].sgl)
>> 			   + fb->offsets[i];
>> 
>> +	cfg.premult = (state->state.pixel_blend_mode == DRM_MODE_BLEND_PREMULTI);
> 
> I'll drop the parentheses here too, and if you don't mind, I'll move
> this down after setting cfg.pixelformat, as premult qualifies the format
> so it's more logical in that reading order (no change on the behaviour
> of course).

Thank you. I also agree with the proposed change in order.

> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
> 
>> +
>> 	format = rcar_du_format_info(state->format->fourcc);
>> 	cfg.pixelformat = format->v4l2;
>> 
>> @@ -444,6 +446,10 @@ int rcar_du_vsp_init(struct rcar_du_vsp *vsp, struct device_node *np,
>> 						       num_planes - 1);
>> 		}
>> 
>> +		drm_plane_create_blend_mode_property(&plane->plane,
>> +					BIT(DRM_MODE_BLEND_PREMULTI) |
>> +					BIT(DRM_MODE_BLEND_COVERAGE));
>> +
>> 		vsp->num_planes++;
>> 	}
>> 
> 
> -- 
> Regards,
> 
> Laurent Pinchart

Cheers,
Takanari Hayama, Ph.D. <taki@igel.co.jp>
IGEL Co., Ltd.
https://www.igel.co.jp/
diff mbox series

Patch

diff --git a/drivers/gpu/drm/rcar-du/rcar_du_vsp.c b/drivers/gpu/drm/rcar-du/rcar_du_vsp.c
index 8eb9b2b097ae..b9580fcfec7a 100644
--- a/drivers/gpu/drm/rcar-du/rcar_du_vsp.c
+++ b/drivers/gpu/drm/rcar-du/rcar_du_vsp.c
@@ -167,6 +167,8 @@  static void rcar_du_vsp_plane_setup(struct rcar_du_vsp_plane *plane)
 		cfg.mem[i] = sg_dma_address(state->sg_tables[i].sgl)
 			   + fb->offsets[i];
 
+	cfg.premult = (state->state.pixel_blend_mode == DRM_MODE_BLEND_PREMULTI);
+
 	format = rcar_du_format_info(state->format->fourcc);
 	cfg.pixelformat = format->v4l2;
 
@@ -444,6 +446,10 @@  int rcar_du_vsp_init(struct rcar_du_vsp *vsp, struct device_node *np,
 						       num_planes - 1);
 		}
 
+		drm_plane_create_blend_mode_property(&plane->plane,
+					BIT(DRM_MODE_BLEND_PREMULTI) |
+					BIT(DRM_MODE_BLEND_COVERAGE));
+
 		vsp->num_planes++;
 	}