diff mbox series

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

Message ID 20220810083711.219642-2-taki@igel.co.jp (mailing list archive)
State New, archived
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
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.

Signed-off-by: Takanari Hayama <taki@igel.co.jp>
---
 drivers/media/platform/renesas/vsp1/vsp1_drm.c | 2 ++
 include/media/vsp1.h                           | 2 ++
 2 files changed, 4 insertions(+)

Comments

Sergey Shtylyov Aug. 10, 2022, 5:41 p.m. UTC | #1
Hello!

On 8/10/22 11:37 AM, Takanari Hayama wrote:

> 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.
> 
> Signed-off-by: Takanari Hayama <taki@igel.co.jp>
> ---
>  drivers/media/platform/renesas/vsp1/vsp1_drm.c | 2 ++
>  include/media/vsp1.h                           | 2 ++
>  2 files changed, 4 insertions(+)
> 
> diff --git a/drivers/media/platform/renesas/vsp1/vsp1_drm.c b/drivers/media/platform/renesas/vsp1/vsp1_drm.c
> index 0c2507dc03d6..019e18976bd8 100644
> --- a/drivers/media/platform/renesas/vsp1/vsp1_drm.c
> +++ b/drivers/media/platform/renesas/vsp1/vsp1_drm.c
> @@ -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
Takanari Hayama Aug. 16, 2022, 6:01 a.m. UTC | #2
Hi,

> 2022/08/11 2:41、Sergey Shtylyov <s.shtylyov@omp.ru>のメール:
> 
> Hello!
> 
> On 8/10/22 11:37 AM, Takanari Hayama wrote:
> 
>> 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.
>> 
>> Signed-off-by: Takanari Hayama <taki@igel.co.jp>
>> ---
>> drivers/media/platform/renesas/vsp1/vsp1_drm.c | 2 ++
>> include/media/vsp1.h                           | 2 ++
>> 2 files changed, 4 insertions(+)
>> 
>> diff --git a/drivers/media/platform/renesas/vsp1/vsp1_drm.c b/drivers/media/platform/renesas/vsp1/vsp1_drm.c
>> index 0c2507dc03d6..019e18976bd8 100644
>> --- a/drivers/media/platform/renesas/vsp1/vsp1_drm.c
>> +++ b/drivers/media/platform/renesas/vsp1/vsp1_drm.c
>> @@ -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... :-)

True. :) Thank you.

Cheers,
Takanari Hayama, Ph.D. <taki@igel.co.jp>
IGEL Co., Ltd.
https://www.igel.co.jp/
Laurent Pinchart Aug. 19, 2022, 2:01 a.m. UTC | #3
Hi Hayama-san,

Thank you for the patch.

On Wed, Aug 10, 2022 at 05:37:09PM +0900, Takanari Hayama wrote:
> 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.
> 
> Signed-off-by: Takanari Hayama <taki@igel.co.jp>
> ---
>  drivers/media/platform/renesas/vsp1/vsp1_drm.c | 2 ++
>  include/media/vsp1.h                           | 2 ++
>  2 files changed, 4 insertions(+)
> 
> diff --git a/drivers/media/platform/renesas/vsp1/vsp1_drm.c b/drivers/media/platform/renesas/vsp1/vsp1_drm.c
> index 0c2507dc03d6..019e18976bd8 100644
> --- a/drivers/media/platform/renesas/vsp1/vsp1_drm.c
> +++ b/drivers/media/platform/renesas/vsp1/vsp1_drm.c
> @@ -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.

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

> +
>  	vsp1->drm->inputs[rpf_index].crop = cfg->src;
>  	vsp1->drm->inputs[rpf_index].compose = cfg->dst;
>  	vsp1->drm->inputs[rpf_index].zpos = cfg->zpos;
> diff --git a/include/media/vsp1.h b/include/media/vsp1.h
> index cc1b0d42ce95..48f4a5023d81 100644
> --- a/include/media/vsp1.h
> +++ b/include/media/vsp1.h
> @@ -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;
>  };
>  
>  /**
Takanari Hayama Aug. 19, 2022, 2:04 a.m. UTC | #4
Hi Laurent,

> 2022/08/19 11:01、Laurent Pinchart <laurent.pinchart@ideasonboard.com>のメール:
> 
> Hi Hayama-san,
> 
> Thank you for the patch.
> 
> On Wed, Aug 10, 2022 at 05:37:09PM +0900, Takanari Hayama wrote:
>> 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.
>> 
>> Signed-off-by: Takanari Hayama <taki@igel.co.jp>
>> ---
>> drivers/media/platform/renesas/vsp1/vsp1_drm.c | 2 ++
>> include/media/vsp1.h                           | 2 ++
>> 2 files changed, 4 insertions(+)
>> 
>> diff --git a/drivers/media/platform/renesas/vsp1/vsp1_drm.c b/drivers/media/platform/renesas/vsp1/vsp1_drm.c
>> index 0c2507dc03d6..019e18976bd8 100644
>> --- a/drivers/media/platform/renesas/vsp1/vsp1_drm.c
>> +++ b/drivers/media/platform/renesas/vsp1/vsp1_drm.c
>> @@ -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.

Thank you!

> 
> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
> 
>> +
>> 	vsp1->drm->inputs[rpf_index].crop = cfg->src;
>> 	vsp1->drm->inputs[rpf_index].compose = cfg->dst;
>> 	vsp1->drm->inputs[rpf_index].zpos = cfg->zpos;
>> diff --git a/include/media/vsp1.h b/include/media/vsp1.h
>> index cc1b0d42ce95..48f4a5023d81 100644
>> --- a/include/media/vsp1.h
>> +++ b/include/media/vsp1.h
>> @@ -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;
>> };
>> 
>> /**
> 
> -- 
> Regards,
> 
> Laurent Pinchart

Cheers,
Takanari Hayama, Ph.D. <taki@igel.co.jp>
IGEL Co., Ltd.
https://www.igel.co.jp/
Laurent Pinchart Aug. 19, 2022, 2:38 a.m. UTC | #5
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.

On Fri, Aug 19, 2022 at 05:01:10AM +0300, Laurent Pinchart wrote:
> Hi Hayama-san,
> 
> Thank you for the patch.
> 
> On Wed, Aug 10, 2022 at 05:37:09PM +0900, Takanari Hayama wrote:
> > 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.
> > 
> > Signed-off-by: Takanari Hayama <taki@igel.co.jp>
> > ---
> >  drivers/media/platform/renesas/vsp1/vsp1_drm.c | 2 ++
> >  include/media/vsp1.h                           | 2 ++
> >  2 files changed, 4 insertions(+)
> > 
> > diff --git a/drivers/media/platform/renesas/vsp1/vsp1_drm.c b/drivers/media/platform/renesas/vsp1/vsp1_drm.c
> > index 0c2507dc03d6..019e18976bd8 100644
> > --- a/drivers/media/platform/renesas/vsp1/vsp1_drm.c
> > +++ b/drivers/media/platform/renesas/vsp1/vsp1_drm.c
> > @@ -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.
> 
> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
> 
> > +
> >  	vsp1->drm->inputs[rpf_index].crop = cfg->src;
> >  	vsp1->drm->inputs[rpf_index].compose = cfg->dst;
> >  	vsp1->drm->inputs[rpf_index].zpos = cfg->zpos;
> > diff --git a/include/media/vsp1.h b/include/media/vsp1.h
> > index cc1b0d42ce95..48f4a5023d81 100644
> > --- a/include/media/vsp1.h
> > +++ b/include/media/vsp1.h
> > @@ -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;
> >  };
> >  
> >  /**
Mauro Carvalho Chehab Sept. 6, 2022, 11:10 a.m. UTC | #6
Em Fri, 19 Aug 2022 05:38:28 +0300
Laurent Pinchart <laurent.pinchart@ideasonboard.com> escreveu:

> 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.
> 
> On Fri, Aug 19, 2022 at 05:01:10AM +0300, Laurent Pinchart wrote:
> > Hi Hayama-san,
> > 
> > Thank you for the patch.
> > 
> > On Wed, Aug 10, 2022 at 05:37:09PM +0900, Takanari Hayama wrote:  
> > > 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.
> > > 
> > > Signed-off-by: Takanari Hayama <taki@igel.co.jp>

Sure, this can be merged via DRM tree.


> > > ---
> > >  drivers/media/platform/renesas/vsp1/vsp1_drm.c | 2 ++
> > >  include/media/vsp1.h                           | 2 ++
> > >  2 files changed, 4 insertions(+)
> > > 
> > > diff --git a/drivers/media/platform/renesas/vsp1/vsp1_drm.c b/drivers/media/platform/renesas/vsp1/vsp1_drm.c
> > > index 0c2507dc03d6..019e18976bd8 100644
> > > --- a/drivers/media/platform/renesas/vsp1/vsp1_drm.c
> > > +++ b/drivers/media/platform/renesas/vsp1/vsp1_drm.c
> > > @@ -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.
> > 
> > Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>

With this change:

Reviewed-by: Mauro Carvalho Chehab <mchehab@kernel.org>

Regards,
Mauro
diff mbox series

Patch

diff --git a/drivers/media/platform/renesas/vsp1/vsp1_drm.c b/drivers/media/platform/renesas/vsp1/vsp1_drm.c
index 0c2507dc03d6..019e18976bd8 100644
--- a/drivers/media/platform/renesas/vsp1/vsp1_drm.c
+++ b/drivers/media/platform/renesas/vsp1/vsp1_drm.c
@@ -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;
diff --git a/include/media/vsp1.h b/include/media/vsp1.h
index cc1b0d42ce95..48f4a5023d81 100644
--- a/include/media/vsp1.h
+++ b/include/media/vsp1.h
@@ -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;
 };
 
 /**