Skip to contentSkip to conversation

Add DRM pixel blend mode support to R-Car DU

PATCH In review Takanari Hayama 4 participants 13 messages Aug 10, 2022 – Sep 6, 2022

Subsystems (5)
lore
Share & tools
lore
#0 lore raw

v2 cover Add DRM pixel blend mode support to R-Car DU

The series of patches adds support for DRM pixel blend mode to R-Car DU driver. The current R-Car DU implicitly supports "Coverage" only.

Unfortunately, this changes the default blending mode of R-Car DU to "Pre-multiplied" which is the default when pixel blend mode is supported.

v2:
vsp1:
- Add a premult flag instead of blend mode enum rcar-du:
- Support DRM_MODE_BLEND_PREMULTI via the premult flag
- Support DRM_MODE_BLEND_PIXEL_NONE via format override [1]

[1] https://lore.kernel.org/linux-renesas-soc/[email protected]/T/#m3351cb5965cd5bf2d416fa5ca5007773260205bd

Takanari Hayama (3):
media: vsp1: add premultiplied alpha support
drm: rcar-du: Add DRM_MODE_BLEND_PREMULTI support
drm: rcar-du: Add DRM_MODE_BLEND_PIXEL_NONE support

 drivers/gpu/drm/rcar-du/rcar_du_vsp.c         | 26 ++++++++++++++++++-
 .../media/platform/renesas/vsp1/vsp1_drm.c    |  2 ++
 include/media/vsp1.h                          |  2 ++
 3 files changed, 29 insertions(+), 1 deletion(-)
Signature · 1 line
2.25.1
#1 lore raw

PATCH v2 1/3 media: vsp1: add premultiplied alpha support

To support DRM blend mode in R-Car DU driver, we must be able to pass a plane with the premultiplied alpha. Adding a new property to vsp1_du_atomic_config allows the R-Car DU driver to pass the premultiplied alpha plane.

---
 drivers/media/platform/renesas/vsp1/vsp1_drm.c | 2 ++
 include/media/vsp1.h                           | 2 ++
 2 files changed, 4 insertions(+)
drivers/media/platform/renesas/vsp1/vsp1_drm.c +2 -0
index 0c2507dc03d6..019e18976bd8 100644
@@ -856,6 +856,8 @@ int vsp1_du_atomic_update(struct device *dev, unsigned int pipe_index,
 	rpf->mem.addr[1] = cfg->mem[1];
 	rpf->mem.addr[2] = cfg->mem[2];
 
+	rpf->format.flags = (cfg->premult) ? V4L2_PIX_FMT_FLAG_PREMUL_ALPHA : 0;
+
 	vsp1->drm->inputs[rpf_index].crop = cfg->src;
 	vsp1->drm->inputs[rpf_index].compose = cfg->dst;
 	vsp1->drm->inputs[rpf_index].zpos = cfg->zpos;
include/media/vsp1.h +2 -0
index cc1b0d42ce95..48f4a5023d81 100644
@@ -51,6 +51,7 @@ int vsp1_du_setup_lif(struct device *dev, unsigned int pipe_index,
  * @dst: destination rectangle on the display (integer coordinates)
  * @alpha: alpha value (0: fully transparent, 255: fully opaque)
  * @zpos: Z position of the plane (from 0 to number of planes minus 1)
+ * @premult: true for premultiplied alpha
  */
 struct vsp1_du_atomic_config {
 	u32 pixelformat;
@@ -60,6 +61,7 @@ struct vsp1_du_atomic_config {
 	struct v4l2_rect dst;
 	unsigned int alpha;
 	unsigned int zpos;
+	bool premult;
 };
 
 /**
Signature · 1 line
2.25.1
#2 lore raw

Re: [PATCH v2 1/3] media: vsp1: add premultiplied alpha support

Hello!

Quoted 16 lines · Takanari Hayama

To support DRM blend mode in R-Car DU driver, we must be able to pass a plane with the premultiplied alpha. Adding a new property to vsp1_du_atomic_config allows the R-Car DU driver to pass the premultiplied alpha plane.

---
 drivers/media/platform/renesas/vsp1/vsp1_drm.c | 2 ++
 include/media/vsp1.h                           | 2 ++
 2 files changed, 4 insertions(+)
drivers/media/platform/renesas/vsp1/vsp1_drm.c +0 -0
index 0c2507dc03d6..019e18976bd8 100644

drivers/media/platform/renesas/vsp1/vsp1_drm.c int vsp1_du_atomic_update(struct device *dev, unsigned int pipe_index, · line 860

Quoted 5 lines
drivers/media/platform/renesas/vsp1/vsp1_drm.c +2 -0
@@ -856,6 +856,8 @@ int vsp1_du_atomic_update(struct device *dev, unsigned int pipe_index,
 	rpf->mem.addr[1] = cfg->mem[1];
 	rpf->mem.addr[2] = cfg->mem[2];
 
+	rpf->format.flags = (cfg->premult) ? V4L2_PIX_FMT_FLAG_PREMUL_ALPHA : 0;
+

Parens are hardly needed here... :-)

[...]

MBR, Sergey

#3 lore raw

Re: [PATCH v2 1/3] media: vsp1: add premultiplied alpha support

Hi,

Quoted 25 lines

2022/08/11 2:41、Sergey Shtylyov <[email protected]>のメール:

Hello!

Quoted 19 lines · Takanari Hayama

To support DRM blend mode in R-Car DU driver, we must be able to pass a plane with the premultiplied alpha. Adding a new property to vsp1_du_atomic_config allows the R-Car DU driver to pass the premultiplied alpha plane.

---
drivers/media/platform/renesas/vsp1/vsp1_drm.c | 2 ++
include/media/vsp1.h | 2 ++

2 files changed, 4 insertions(+)
drivers/media/platform/renesas/vsp1/vsp1_drm.c +0 -0
index 0c2507dc03d6..019e18976bd8 100644
@@ -856,6 +856,8 @@ int vsp1_du_atomic_update(struct device *dev, unsigned int pipe_index,
 	rpf->mem.addr[1] = cfg->mem[1];
 	rpf->mem.addr[2] = cfg->mem[2];
 
Quoted 4 lines

drivers/media/platform/renesas/vsp1/vsp1_drm.c int vsp1_du_atomic_update(struct device *dev, unsigned int pipe_index, · line 860

Quoted 2 lines
drivers/media/platform/renesas/vsp1/vsp1_drm.c +2 -0
+	rpf->format.flags = (cfg->premult) ? V4L2_PIX_FMT_FLAG_PREMUL_ALPHA : 0;
+

Parens are hardly needed here... :-)

True. :) Thank you.

Cheers,
Takanari Hayama, Ph.D. <[email protected]>
IGEL Co., Ltd.
https://www.igel.co.jp/

maintainer Reviewed-by on v2 1/3
#4 lore raw

Re: [PATCH v2 1/3] media: vsp1: add premultiplied alpha support

In reply to Takanari Hayama

Hi Hayama-san,

Thank you for the patch.

Quoted 16 lines · Takanari Hayama

To support DRM blend mode in R-Car DU driver, we must be able to pass a plane with the premultiplied alpha. Adding a new property to vsp1_du_atomic_config allows the R-Car DU driver to pass the premultiplied alpha plane.

---
 drivers/media/platform/renesas/vsp1/vsp1_drm.c | 2 ++
 include/media/vsp1.h                           | 2 ++
 2 files changed, 4 insertions(+)
drivers/media/platform/renesas/vsp1/vsp1_drm.c +0 -0
index 0c2507dc03d6..019e18976bd8 100644

drivers/media/platform/renesas/vsp1/vsp1_drm.c int vsp1_du_atomic_update(struct device *dev, unsigned int pipe_index, · line 859

Quoted 4 lines
drivers/media/platform/renesas/vsp1/vsp1_drm.c +1 -0
@@ -856,6 +856,8 @@ int vsp1_du_atomic_update(struct device *dev, unsigned int pipe_index,
 	rpf->mem.addr[1] = cfg->mem[1];
 	rpf->mem.addr[2] = cfg->mem[2];
 
+	rpf->format.flags = (cfg->premult) ? V4L2_PIX_FMT_FLAG_PREMUL_ALPHA : 0;

I'll drop the parentheses when applying.

Quoted 24 lines
drivers/media/platform/renesas/vsp1/vsp1_drm.c +1 -0
+
 	vsp1->drm->inputs[rpf_index].crop = cfg->src;
 	vsp1->drm->inputs[rpf_index].compose = cfg->dst;
 	vsp1->drm->inputs[rpf_index].zpos = cfg->zpos;
include/media/vsp1.h +2 -0
index cc1b0d42ce95..48f4a5023d81 100644
@@ -51,6 +51,7 @@ int vsp1_du_setup_lif(struct device *dev, unsigned int pipe_index,
  * @dst: destination rectangle on the display (integer coordinates)
  * @alpha: alpha value (0: fully transparent, 255: fully opaque)
  * @zpos: Z position of the plane (from 0 to number of planes minus 1)
+ * @premult: true for premultiplied alpha
  */
 struct vsp1_du_atomic_config {
 	u32 pixelformat;
@@ -60,6 +61,7 @@ struct vsp1_du_atomic_config {
 	struct v4l2_rect dst;
 	unsigned int alpha;
 	unsigned int zpos;
+	bool premult;
 };
 
 /**
Signature · 3 lines
Regards,

Laurent Pinchart
#5 lore raw

Re: [PATCH v2 1/3] media: vsp1: add premultiplied alpha support

Hi Laurent,

Quoted 26 lines

2022/08/19 11:01、Laurent Pinchart <[email protected]>のメール:

Hi Hayama-san,

Thank you for the patch.

Quoted 19 lines · Takanari Hayama

To support DRM blend mode in R-Car DU driver, we must be able to pass a plane with the premultiplied alpha. Adding a new property to vsp1_du_atomic_config allows the R-Car DU driver to pass the premultiplied alpha plane.

---
drivers/media/platform/renesas/vsp1/vsp1_drm.c | 2 ++
include/media/vsp1.h | 2 ++

2 files changed, 4 insertions(+)
drivers/media/platform/renesas/vsp1/vsp1_drm.c +0 -0
index 0c2507dc03d6..019e18976bd8 100644
@@ -856,6 +856,8 @@ int vsp1_du_atomic_update(struct device *dev, unsigned int pipe_index,
 	rpf->mem.addr[1] = cfg->mem[1];
 	rpf->mem.addr[2] = cfg->mem[2];
 
Quoted 3 lines

drivers/media/platform/renesas/vsp1/vsp1_drm.c int vsp1_du_atomic_update(struct device *dev, unsigned int pipe_index, · line 859

Quoted 1 line
drivers/media/platform/renesas/vsp1/vsp1_drm.c +1 -0
+	rpf->format.flags = (cfg->premult) ? V4L2_PIX_FMT_FLAG_PREMUL_ALPHA : 0;

I'll drop the parentheses when applying.

Thank you!

Quoted 26 lines
Quoted 23 lines
drivers/media/platform/renesas/vsp1/vsp1_drm.c +1 -0
+
 	vsp1->drm->inputs[rpf_index].crop = cfg->src;
 	vsp1->drm->inputs[rpf_index].compose = cfg->dst;
 	vsp1->drm->inputs[rpf_index].zpos = cfg->zpos;
include/media/vsp1.h +2 -0
index cc1b0d42ce95..48f4a5023d81 100644
@@ -51,6 +51,7 @@ int vsp1_du_setup_lif(struct device *dev, unsigned int pipe_index,
 * @dst: destination rectangle on the display (integer coordinates)
 * @alpha: alpha value (0: fully transparent, 255: fully opaque)
 * @zpos: Z position of the plane (from 0 to number of planes minus 1)
+ * @premult: true for premultiplied alpha
 */
 struct vsp1_du_atomic_config {
 	u32 pixelformat;
@@ -60,6 +61,7 @@ struct vsp1_du_atomic_config {
 	struct v4l2_rect dst;
 	unsigned int alpha;
 	unsigned int zpos;
+	bool premult;
 };
 
Quoted 6 lines
Quoted 1 line
include/media/vsp1.h +0 -0
 /**
Signature · 3 lines
Regards,

Laurent Pinchart

Cheers,
Takanari Hayama, Ph.D. <[email protected]>
IGEL Co., Ltd.
https://www.igel.co.jp/

maintainer
#6 lore raw

Re: [PATCH v2 1/3] media: vsp1: add premultiplied alpha support

In reply to Laurent Pinchart

Mauro, would you be fine with this patch going through the DRM tree for v6.1 ? I don't foresee any risk of conflict with other changes to the VSP driver scheduled for the next kernel version. If that's fine with you, could you give an Acked-by ? Otherwise I can send you a pull request to create an immutable branch and base the rest on it in my pull request for DRM, but given how small this change is, it seems a bit overkill.

Quoted 54 lines · Laurent Pinchart

Hi Hayama-san,

Thank you for the patch.

Quoted 16 lines · Takanari Hayama

To support DRM blend mode in R-Car DU driver, we must be able to pass a plane with the premultiplied alpha. Adding a new property to vsp1_du_atomic_config allows the R-Car DU driver to pass the premultiplied alpha plane.

---
 drivers/media/platform/renesas/vsp1/vsp1_drm.c | 2 ++
 include/media/vsp1.h                           | 2 ++
 2 files changed, 4 insertions(+)
drivers/media/platform/renesas/vsp1/vsp1_drm.c +0 -0
index 0c2507dc03d6..019e18976bd8 100644

drivers/media/platform/renesas/vsp1/vsp1_drm.c int vsp1_du_atomic_update(struct device *dev, unsigned int pipe_index, · line 859

Quoted 4 lines
drivers/media/platform/renesas/vsp1/vsp1_drm.c +1 -0
@@ -856,6 +856,8 @@ int vsp1_du_atomic_update(struct device *dev, unsigned int pipe_index,
 	rpf->mem.addr[1] = cfg->mem[1];
 	rpf->mem.addr[2] = cfg->mem[2];
 
+	rpf->format.flags = (cfg->premult) ? V4L2_PIX_FMT_FLAG_PREMUL_ALPHA : 0;

I'll drop the parentheses when applying.

Quoted 24 lines
drivers/media/platform/renesas/vsp1/vsp1_drm.c +1 -0
+
 	vsp1->drm->inputs[rpf_index].crop = cfg->src;
 	vsp1->drm->inputs[rpf_index].compose = cfg->dst;
 	vsp1->drm->inputs[rpf_index].zpos = cfg->zpos;
include/media/vsp1.h +2 -0
index cc1b0d42ce95..48f4a5023d81 100644
@@ -51,6 +51,7 @@ int vsp1_du_setup_lif(struct device *dev, unsigned int pipe_index,
  * @dst: destination rectangle on the display (integer coordinates)
  * @alpha: alpha value (0: fully transparent, 255: fully opaque)
  * @zpos: Z position of the plane (from 0 to number of planes minus 1)
+ * @premult: true for premultiplied alpha
  */
 struct vsp1_du_atomic_config {
 	u32 pixelformat;
@@ -60,6 +61,7 @@ struct vsp1_du_atomic_config {
 	struct v4l2_rect dst;
 	unsigned int alpha;
 	unsigned int zpos;
+	bool premult;
 };
 
 /**
Signature · 3 lines
Regards,

Laurent Pinchart
maintainer Reviewed-by
#7 lore raw

Re: [PATCH v2 1/3] media: vsp1: add premultiplied alpha support

Em Fri, 19 Aug 2022 05:38:28 +0300
Laurent Pinchart <[email protected]> escreveu:

Quoted 7 lines

Mauro, would you be fine with this patch going through the DRM tree for v6.1 ? I don't foresee any risk of conflict with other changes to the VSP driver scheduled for the next kernel version. If that's fine with you, could you give an Acked-by ? Otherwise I can send you a pull request to create an immutable branch and base the rest on it in my pull request for DRM, but given how small this change is, it seems a bit overkill.

Please, don't top-post.

Quoted 6 lines · Laurent Pinchart
Quoted 4 lines

Hi Hayama-san,

Thank you for the patch.

Quoted 7 lines
Quoted 7 lines · Takanari Hayama
Quoted 6 lines

To support DRM blend mode in R-Car DU driver, we must be able to pass a plane with the premultiplied alpha. Adding a new property to vsp1_du_atomic_config allows the R-Car DU driver to pass the premultiplied alpha plane.

Sure, this can be merged via DRM tree.

Quoted 13 lines
Quoted 13 lines
Quoted 13 lines
---
 drivers/media/platform/renesas/vsp1/vsp1_drm.c | 2 ++
 include/media/vsp1.h                           | 2 ++
 2 files changed, 4 insertions(+)
drivers/media/platform/renesas/vsp1/vsp1_drm.c +0 -0
index 0c2507dc03d6..019e18976bd8 100644
@@ -856,6 +856,8 @@ int vsp1_du_atomic_update(struct device *dev, unsigned int pipe_index,
 	rpf->mem.addr[1] = cfg->mem[1];
 	rpf->mem.addr[2] = cfg->mem[2];
 
Quoted 5 lines
Quoted 5 lines

drivers/media/platform/renesas/vsp1/vsp1_drm.c int vsp1_du_atomic_update(struct device *dev, unsigned int pipe_index, · line 859

Quoted 1 line
drivers/media/platform/renesas/vsp1/vsp1_drm.c +1 -0
+	rpf->format.flags = (cfg->premult) ? V4L2_PIX_FMT_FLAG_PREMUL_ALPHA : 0;  

I'll drop the parentheses when applying.

With this change:

Regards,
Mauro

#8 lore raw

PATCH v2 2/3 drm: rcar-du: Add DRM_MODE_BLEND_PREMULTI support

In reply to Takanari Hayama

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.

---
 drivers/gpu/drm/rcar-du/rcar_du_vsp.c | 6 ++++++
 1 file changed, 6 insertions(+)
drivers/gpu/drm/rcar-du/rcar_du_vsp.c +6 -0
index 8eb9b2b097ae..b9580fcfec7a 100644
@@ -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++;
 	}
 
Signature · 1 line
2.25.1
maintainer Reviewed-by on v2 2/3
#9 lore raw

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

Hello Hayama-san,

Thank you for the patch.

Quoted 20 lines · Takanari Hayama

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.

---
 drivers/gpu/drm/rcar-du/rcar_du_vsp.c | 6 ++++++
 1 file changed, 6 insertions(+)
drivers/gpu/drm/rcar-du/rcar_du_vsp.c +0 -0
index 8eb9b2b097ae..b9580fcfec7a 100644

drivers/gpu/drm/rcar-du/rcar_du_vsp.c static void rcar_du_vsp_plane_setup(struct rcar_du_vsp_plane *plane) · line 170

Quoted 4 lines
drivers/gpu/drm/rcar-du/rcar_du_vsp.c +1 -0
@@ -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).

Quoted 15 lines
drivers/gpu/drm/rcar-du/rcar_du_vsp.c +5 -0
+
 	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++;
 	}
 
Signature · 3 lines
Regards,

Laurent Pinchart
#10 lore raw

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

Hi Laurent,

Quoted 30 lines

2022/08/19 11:08、Laurent Pinchart <[email protected]>のメール:

Hello Hayama-san,

Thank you for the patch.

Quoted 23 lines · Takanari Hayama

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.

---
drivers/gpu/drm/rcar-du/rcar_du_vsp.c | 6 ++++++

1 file changed, 6 insertions(+)
drivers/gpu/drm/rcar-du/rcar_du_vsp.c +0 -0
index 8eb9b2b097ae..b9580fcfec7a 100644
@@ -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];
 
Quoted 6 lines

drivers/gpu/drm/rcar-du/rcar_du_vsp.c static void rcar_du_vsp_plane_setup(struct rcar_du_vsp_plane *plane) · line 170

Quoted 1 line
drivers/gpu/drm/rcar-du/rcar_du_vsp.c +1 -0
+	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.

Quoted 10 lines
Quoted 8 lines
drivers/gpu/drm/rcar-du/rcar_du_vsp.c +1 -0
+
 	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);
 		}
 
Quoted 12 lines
Quoted 7 lines
drivers/gpu/drm/rcar-du/rcar_du_vsp.c +4 -0
+		drm_plane_create_blend_mode_property(&plane->plane,
+					BIT(DRM_MODE_BLEND_PREMULTI) |
+					BIT(DRM_MODE_BLEND_COVERAGE));
+
 		vsp->num_planes++;
 	}
 
Signature · 3 lines
Regards,

Laurent Pinchart

Cheers,
Takanari Hayama, Ph.D. <[email protected]>
IGEL Co., Ltd.
https://www.igel.co.jp/

#11 lore raw

PATCH v2 3/3 drm: rcar-du: Add DRM_MODE_BLEND_PIXEL_NONE support

In reply to Takanari Hayama

DRM_MODE_BLEND_PIXEL_NONE ignores an alpha channel.

Rcar-du driver supports only 3 formats with an alpha channel (DRM_FORMAT_ARGB1555, DRM_FORMAT_ARGB8888 and DRM_FORMAT_ARGB4444). We simply override the format passed to VSP1 for blending with the pixel format without alpha channel.

---
 drivers/gpu/drm/rcar-du/rcar_du_vsp.c | 20 +++++++++++++++++++-
 1 file changed, 19 insertions(+), 1 deletion(-)
drivers/gpu/drm/rcar-du/rcar_du_vsp.c +19 -1
index b9580fcfec7a..7cce2d414ced 100644
@@ -151,6 +151,7 @@ static void rcar_du_vsp_plane_setup(struct rcar_du_vsp_plane *plane)
 		.alpha = state->state.alpha >> 8,
 		.zpos = state->state.zpos,
 	};
+	u32 fourcc = state->format->fourcc;
 	unsigned int i;
 
 	cfg.src.left = state->state.src.x1 >> 16;
@@ -169,7 +170,23 @@ static void rcar_du_vsp_plane_setup(struct rcar_du_vsp_plane *plane)
 
 	cfg.premult = (state->state.pixel_blend_mode == DRM_MODE_BLEND_PREMULTI);
 
-	format = rcar_du_format_info(state->format->fourcc);
+	if (state->state.pixel_blend_mode == DRM_MODE_BLEND_PIXEL_NONE) {
+		switch (fourcc) {
+		case DRM_FORMAT_ARGB1555:
+			fourcc = DRM_FORMAT_XRGB1555;
+			break;
+
+		case DRM_FORMAT_ARGB4444:
+			fourcc = DRM_FORMAT_XRGB4444;
+			break;
+
+		case DRM_FORMAT_ARGB8888:
+			fourcc = DRM_FORMAT_XRGB8888;
+			break;
+		}
+	}
+
+	format = rcar_du_format_info(fourcc);
 	cfg.pixelformat = format->v4l2;
 
 	vsp1_du_atomic_update(plane->vsp->vsp, crtc->vsp_pipe,
@@ -447,6 +464,7 @@ int rcar_du_vsp_init(struct rcar_du_vsp *vsp, struct device_node *np,
 		}
 
 		drm_plane_create_blend_mode_property(&plane->plane,
+					BIT(DRM_MODE_BLEND_PIXEL_NONE) |
 					BIT(DRM_MODE_BLEND_PREMULTI) |
 					BIT(DRM_MODE_BLEND_COVERAGE));
 
Signature · 1 line
2.25.1
maintainer Reviewed-by on v2 3/3
#12 lore raw

Re: [PATCH v2 3/3] drm: rcar-du: Add DRM_MODE_BLEND_PIXEL_NONE support

Hello Hayama-san,

Thank you for the patch.

Quoted 9 lines · Takanari Hayama

DRM_MODE_BLEND_PIXEL_NONE ignores an alpha channel.

Rcar-du driver supports only 3 formats with an alpha channel (DRM_FORMAT_ARGB1555, DRM_FORMAT_ARGB8888 and DRM_FORMAT_ARGB4444). We simply override the format passed to VSP1 for blending with the pixel format without alpha channel.

Quoted 49 lines
---
 drivers/gpu/drm/rcar-du/rcar_du_vsp.c | 20 +++++++++++++++++++-
 1 file changed, 19 insertions(+), 1 deletion(-)
drivers/gpu/drm/rcar-du/rcar_du_vsp.c +19 -1
index b9580fcfec7a..7cce2d414ced 100644
@@ -151,6 +151,7 @@ static void rcar_du_vsp_plane_setup(struct rcar_du_vsp_plane *plane)
 		.alpha = state->state.alpha >> 8,
 		.zpos = state->state.zpos,
 	};
+	u32 fourcc = state->format->fourcc;
 	unsigned int i;
 
 	cfg.src.left = state->state.src.x1 >> 16;
@@ -169,7 +170,23 @@ static void rcar_du_vsp_plane_setup(struct rcar_du_vsp_plane *plane)
 
 	cfg.premult = (state->state.pixel_blend_mode == DRM_MODE_BLEND_PREMULTI);
 
-	format = rcar_du_format_info(state->format->fourcc);
+	if (state->state.pixel_blend_mode == DRM_MODE_BLEND_PIXEL_NONE) {
+		switch (fourcc) {
+		case DRM_FORMAT_ARGB1555:
+			fourcc = DRM_FORMAT_XRGB1555;
+			break;
+
+		case DRM_FORMAT_ARGB4444:
+			fourcc = DRM_FORMAT_XRGB4444;
+			break;
+
+		case DRM_FORMAT_ARGB8888:
+			fourcc = DRM_FORMAT_XRGB8888;
+			break;
+		}
+	}
+
+	format = rcar_du_format_info(fourcc);
 	cfg.pixelformat = format->v4l2;
 
 	vsp1_du_atomic_update(plane->vsp->vsp, crtc->vsp_pipe,
@@ -447,6 +464,7 @@ int rcar_du_vsp_init(struct rcar_du_vsp *vsp, struct device_node *np,
 		}
 
 		drm_plane_create_blend_mode_property(&plane->plane,
+					BIT(DRM_MODE_BLEND_PIXEL_NONE) |
 					BIT(DRM_MODE_BLEND_PREMULTI) |
 					BIT(DRM_MODE_BLEND_COVERAGE));
 
Signature · 3 lines
Regards,

Laurent Pinchart