* [PATCH 0/3] Add DRM pixel blend mode support to R-Car DU
@ 2022-07-04 2:52 Takanari Hayama
2022-07-04 2:52 ` [PATCH 1/3] media: vsp1: save pixel alpha info in vsp1_rwpf Takanari Hayama
` (2 more replies)
0 siblings, 3 replies; 8+ messages in thread
From: Takanari Hayama @ 2022-07-04 2:52 UTC (permalink / raw)
To: dri-devel; +Cc: linux-renesas-soc, laurent.pinchart, kieran.bingham+renesas
The series of patches adds support for DRM pixel blend mode to R-Car DU.
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.
Takanari Hayama (3):
media: vsp1: save pixel alpha info in vsp1_rwpf
media: vsp1: add blend mode support
drm: rcar-du: Add DRM blend mode support
drivers/gpu/drm/rcar-du/rcar_du_vsp.c | 17 +++++++++++++++++
drivers/media/platform/renesas/vsp1/vsp1_drm.c | 12 ++++++++++++
drivers/media/platform/renesas/vsp1/vsp1_rpf.c | 6 +++---
drivers/media/platform/renesas/vsp1/vsp1_rwpf.h | 2 ++
include/media/vsp1.h | 14 ++++++++++++++
5 files changed, 48 insertions(+), 3 deletions(-)
--
2.25.1
^ permalink raw reply [flat|nested] 8+ messages in thread* [PATCH 1/3] media: vsp1: save pixel alpha info in vsp1_rwpf 2022-07-04 2:52 [PATCH 0/3] Add DRM pixel blend mode support to R-Car DU Takanari Hayama @ 2022-07-04 2:52 ` Takanari Hayama 2022-07-30 21:10 ` Laurent Pinchart 2022-07-04 2:52 ` [PATCH 2/3] media: vsp1: add blend mode support Takanari Hayama 2022-07-04 2:52 ` [PATCH 3/3] drm: rcar-du: Add DRM " Takanari Hayama 2 siblings, 1 reply; 8+ messages in thread From: Takanari Hayama @ 2022-07-04 2:52 UTC (permalink / raw) To: dri-devel; +Cc: linux-renesas-soc, laurent.pinchart, kieran.bingham+renesas In order to support DRM blend mode, we need to able to override pixel alpha flag. When DRM_MODE_BLEND_PIXEL_NONE is desired, we'd like to let VSP1 to ignore the pixel alpha by overriding the flag. Signed-off-by: Takanari Hayama <taki@igel.co.jp> --- drivers/media/platform/renesas/vsp1/vsp1_drm.c | 1 + drivers/media/platform/renesas/vsp1/vsp1_rpf.c | 6 +++--- drivers/media/platform/renesas/vsp1/vsp1_rwpf.h | 2 ++ 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/drivers/media/platform/renesas/vsp1/vsp1_drm.c b/drivers/media/platform/renesas/vsp1/vsp1_drm.c index 0c2507dc03d6..9ec3ac835987 100644 --- a/drivers/media/platform/renesas/vsp1/vsp1_drm.c +++ b/drivers/media/platform/renesas/vsp1/vsp1_drm.c @@ -600,6 +600,7 @@ static int vsp1_du_pipeline_set_rwpf_format(struct vsp1_device *vsp1, rwpf->format.num_planes = fmtinfo->planes; rwpf->format.plane_fmt[0].bytesperline = pitch; rwpf->format.plane_fmt[1].bytesperline = pitch / chroma_hsub; + rwpf->pixel_alpha = fmtinfo->alpha; return 0; } diff --git a/drivers/media/platform/renesas/vsp1/vsp1_rpf.c b/drivers/media/platform/renesas/vsp1/vsp1_rpf.c index 75083cb234fe..e6bd813dc68c 100644 --- a/drivers/media/platform/renesas/vsp1/vsp1_rpf.c +++ b/drivers/media/platform/renesas/vsp1/vsp1_rpf.c @@ -152,13 +152,13 @@ static void rpf_configure_stream(struct vsp1_entity *entity, * In all cases, disable color keying. */ vsp1_rpf_write(rpf, dlb, VI6_RPF_ALPH_SEL, VI6_RPF_ALPH_SEL_AEXT_EXT | - (fmtinfo->alpha ? VI6_RPF_ALPH_SEL_ASEL_PACKED - : VI6_RPF_ALPH_SEL_ASEL_FIXED)); + (rpf->pixel_alpha ? VI6_RPF_ALPH_SEL_ASEL_PACKED + : VI6_RPF_ALPH_SEL_ASEL_FIXED)); if (entity->vsp1->info->gen == 3) { u32 mult; - if (fmtinfo->alpha) { + if (rpf->pixel_alpha) { /* * When the input contains an alpha channel enable the * alpha multiplier. If the input is premultiplied we diff --git a/drivers/media/platform/renesas/vsp1/vsp1_rwpf.h b/drivers/media/platform/renesas/vsp1/vsp1_rwpf.h index eac5c04c2239..07ddebb78dfa 100644 --- a/drivers/media/platform/renesas/vsp1/vsp1_rwpf.h +++ b/drivers/media/platform/renesas/vsp1/vsp1_rwpf.h @@ -43,6 +43,8 @@ struct vsp1_rwpf { const struct vsp1_format_info *fmtinfo; unsigned int brx_input; + bool pixel_alpha; + unsigned int alpha; u32 mult_alpha; -- 2.25.1 ^ permalink raw reply related [flat|nested] 8+ messages in thread
* Re: [PATCH 1/3] media: vsp1: save pixel alpha info in vsp1_rwpf 2022-07-04 2:52 ` [PATCH 1/3] media: vsp1: save pixel alpha info in vsp1_rwpf Takanari Hayama @ 2022-07-30 21:10 ` Laurent Pinchart 0 siblings, 0 replies; 8+ messages in thread From: Laurent Pinchart @ 2022-07-30 21:10 UTC (permalink / raw) To: Takanari Hayama; +Cc: dri-devel, linux-renesas-soc, kieran.bingham+renesas Hello Hayama-san, Thank you for the patch (and sorry for the long delay). On Mon, Jul 04, 2022 at 11:52:29AM +0900, Takanari Hayama wrote: > In order to support DRM blend mode, we need to able to override pixel > alpha flag. When DRM_MODE_BLEND_PIXEL_NONE is desired, we'd like to let > VSP1 to ignore the pixel alpha by overriding the flag. > > Signed-off-by: Takanari Hayama <taki@igel.co.jp> > --- > drivers/media/platform/renesas/vsp1/vsp1_drm.c | 1 + > drivers/media/platform/renesas/vsp1/vsp1_rpf.c | 6 +++--- > drivers/media/platform/renesas/vsp1/vsp1_rwpf.h | 2 ++ > 3 files changed, 6 insertions(+), 3 deletions(-) > > diff --git a/drivers/media/platform/renesas/vsp1/vsp1_drm.c b/drivers/media/platform/renesas/vsp1/vsp1_drm.c > index 0c2507dc03d6..9ec3ac835987 100644 > --- a/drivers/media/platform/renesas/vsp1/vsp1_drm.c > +++ b/drivers/media/platform/renesas/vsp1/vsp1_drm.c > @@ -600,6 +600,7 @@ static int vsp1_du_pipeline_set_rwpf_format(struct vsp1_device *vsp1, > rwpf->format.num_planes = fmtinfo->planes; > rwpf->format.plane_fmt[0].bytesperline = pitch; > rwpf->format.plane_fmt[1].bytesperline = pitch / chroma_hsub; > + rwpf->pixel_alpha = fmtinfo->alpha; > > return 0; > } > diff --git a/drivers/media/platform/renesas/vsp1/vsp1_rpf.c b/drivers/media/platform/renesas/vsp1/vsp1_rpf.c > index 75083cb234fe..e6bd813dc68c 100644 > --- a/drivers/media/platform/renesas/vsp1/vsp1_rpf.c > +++ b/drivers/media/platform/renesas/vsp1/vsp1_rpf.c > @@ -152,13 +152,13 @@ static void rpf_configure_stream(struct vsp1_entity *entity, > * In all cases, disable color keying. > */ > vsp1_rpf_write(rpf, dlb, VI6_RPF_ALPH_SEL, VI6_RPF_ALPH_SEL_AEXT_EXT | > - (fmtinfo->alpha ? VI6_RPF_ALPH_SEL_ASEL_PACKED > - : VI6_RPF_ALPH_SEL_ASEL_FIXED)); > + (rpf->pixel_alpha ? VI6_RPF_ALPH_SEL_ASEL_PACKED > + : VI6_RPF_ALPH_SEL_ASEL_FIXED)); > > if (entity->vsp1->info->gen == 3) { > u32 mult; > > - if (fmtinfo->alpha) { > + if (rpf->pixel_alpha) { > /* > * When the input contains an alpha channel enable the > * alpha multiplier. If the input is premultiplied we From a DRM point of view this looks fine. vsp1_du_pipeline_set_rwpf_format() is called upon .atomic_update(), and rpf_configure_stream() upon .atomic_flush(), and every update is guaranteed to be followed by a flush (through code paths that are way too convoluted, but that's a story for a different day). However, VSP instances that are exposed through V4L2 will see a regression with this patch. rwpf->pixel_alpha will never be set, so alpha-enabled formats will break. Several test case from https://git.ideasonboard.com/renesas/vsp-tests.git report failures, for instance # ./vsp-unit-test-0001.sh Testing WPF packing in RGB332: pass Testing WPF packing in ARGB555: pass Testing WPF packing in XRGB555: pass Testing WPF packing in RGB565: pass Testing WPF packing in BGR24: pass Testing WPF packing in RGB24: pass Testing WPF packing in ABGR32: fail Testing WPF packing in ARGB32: fail Testing WPF packing in XBGR32: pass Testing WPF packing in XRGB32: pass It seems that this could be fixed fairly easily by setting rpf->pixel_alpha in vsp1_video_set_format(): diff --git a/drivers/media/platform/renesas/vsp1/vsp1_video.c b/drivers/media/platform/renesas/vsp1/vsp1_video.c index 51219b1b6ea9..b518873d3280 100644 --- a/drivers/media/platform/renesas/vsp1/vsp1_video.c +++ b/drivers/media/platform/renesas/vsp1/vsp1_video.c @@ -1015,6 +1015,7 @@ vsp1_video_set_format(struct file *file, void *fh, struct v4l2_format *format) video->rwpf->format = format->fmt.pix_mp; video->rwpf->fmtinfo = info; + video->rwpf->pixel_alpha = info->alpha; done: mutex_unlock(&video->lock); I've tested that and it fixes the tests, so with this change, Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> No need to submit a v2 if no other changes are needed in subsequent patches, I can apply this change when merging the patches. > diff --git a/drivers/media/platform/renesas/vsp1/vsp1_rwpf.h b/drivers/media/platform/renesas/vsp1/vsp1_rwpf.h > index eac5c04c2239..07ddebb78dfa 100644 > --- a/drivers/media/platform/renesas/vsp1/vsp1_rwpf.h > +++ b/drivers/media/platform/renesas/vsp1/vsp1_rwpf.h > @@ -43,6 +43,8 @@ struct vsp1_rwpf { > const struct vsp1_format_info *fmtinfo; > unsigned int brx_input; > > + bool pixel_alpha; > + > unsigned int alpha; > > u32 mult_alpha; -- Regards, Laurent Pinchart ^ permalink raw reply related [flat|nested] 8+ messages in thread
* [PATCH 2/3] media: vsp1: add blend mode support 2022-07-04 2:52 [PATCH 0/3] Add DRM pixel blend mode support to R-Car DU Takanari Hayama 2022-07-04 2:52 ` [PATCH 1/3] media: vsp1: save pixel alpha info in vsp1_rwpf Takanari Hayama @ 2022-07-04 2:52 ` Takanari Hayama 2022-07-30 22:36 ` Laurent Pinchart 2022-07-04 2:52 ` [PATCH 3/3] drm: rcar-du: Add DRM " Takanari Hayama 2 siblings, 1 reply; 8+ messages in thread From: Takanari Hayama @ 2022-07-04 2:52 UTC (permalink / raw) To: dri-devel; +Cc: linux-renesas-soc, laurent.pinchart, kieran.bingham+renesas To support DRM blend mode in R-Car DU driver, we must add blend mode support in VSP1. Although VSP1 hardware is capable to support all blend mode defined in DRM, the current R-Car DU driver implicitly supports DRM_MODE_BLEND_COVERAGE only. We add a new property to vsp1_du_atomic_config, so that R-Car DU driver can pass the desired blend mode. Signed-off-by: Takanari Hayama <taki@igel.co.jp> --- drivers/media/platform/renesas/vsp1/vsp1_drm.c | 11 +++++++++++ include/media/vsp1.h | 14 ++++++++++++++ 2 files changed, 25 insertions(+) diff --git a/drivers/media/platform/renesas/vsp1/vsp1_drm.c b/drivers/media/platform/renesas/vsp1/vsp1_drm.c index 9ec3ac835987..ed0cf552fce2 100644 --- a/drivers/media/platform/renesas/vsp1/vsp1_drm.c +++ b/drivers/media/platform/renesas/vsp1/vsp1_drm.c @@ -861,6 +861,17 @@ int vsp1_du_atomic_update(struct device *dev, unsigned int pipe_index, vsp1->drm->inputs[rpf_index].compose = cfg->dst; vsp1->drm->inputs[rpf_index].zpos = cfg->zpos; + switch (cfg->blend_mode) { + case VSP1_DU_BLEND_MODE_PREMULTI: + rpf->format.flags = V4L2_PIX_FMT_FLAG_PREMUL_ALPHA; + break; + case VSP1_DU_BLEND_MODE_PIXEL_NONE: + rpf->pixel_alpha = false; + fallthrough; + case VSP1_DU_BLEND_MODE_COVERAGE: + rpf->format.flags = 0; + } + drm_pipe->pipe.inputs[rpf_index] = rpf; return 0; diff --git a/include/media/vsp1.h b/include/media/vsp1.h index cc1b0d42ce95..1ba7459b7a06 100644 --- a/include/media/vsp1.h +++ b/include/media/vsp1.h @@ -42,6 +42,18 @@ struct vsp1_du_lif_config { int vsp1_du_setup_lif(struct device *dev, unsigned int pipe_index, const struct vsp1_du_lif_config *cfg); +/** + * enum vsp1_du_blend_mode - Pixel blend mode + * @VSP1_DU_BLEND_MODE_PREMULTI: Pixel alpha is pre-mutiplied + * @VSP1_DU_BLEND_MODE_COVERAGE: Pixel alpha is not pre-mutiplied + * @VSP1_DU_BLEND_MODE_PIXEL_NONE: Ignores the pixel alpha + */ +enum vsp1_du_blend_mode { + VSP1_DU_BLEND_MODE_PREMULTI, + VSP1_DU_BLEND_MODE_COVERAGE, + VSP1_DU_BLEND_MODE_PIXEL_NONE, +}; + /** * struct vsp1_du_atomic_config - VSP atomic configuration parameters * @pixelformat: plane pixel format (V4L2 4CC) @@ -51,6 +63,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) + * @blend_mode: Pixel blend mode of the plane */ struct vsp1_du_atomic_config { u32 pixelformat; @@ -60,6 +73,7 @@ struct vsp1_du_atomic_config { struct v4l2_rect dst; unsigned int alpha; unsigned int zpos; + enum vsp1_du_blend_mode blend_mode; }; /** -- 2.25.1 ^ permalink raw reply related [flat|nested] 8+ messages in thread
* Re: [PATCH 2/3] media: vsp1: add blend mode support 2022-07-04 2:52 ` [PATCH 2/3] media: vsp1: add blend mode support Takanari Hayama @ 2022-07-30 22:36 ` Laurent Pinchart 2022-08-01 8:37 ` Takanari Hayama 0 siblings, 1 reply; 8+ messages in thread From: Laurent Pinchart @ 2022-07-30 22:36 UTC (permalink / raw) To: Takanari Hayama; +Cc: dri-devel, linux-renesas-soc, kieran.bingham+renesas Hi Hayama-san, Thank you for the patch. On Mon, Jul 04, 2022 at 11:52:30AM +0900, Takanari Hayama wrote: > To support DRM blend mode in R-Car DU driver, we must add blend mode > support in VSP1. Although VSP1 hardware is capable to support all blend > mode defined in DRM, the current R-Car DU driver implicitly supports > DRM_MODE_BLEND_COVERAGE only. > > We add a new property to vsp1_du_atomic_config, so that R-Car DU driver > can pass the desired blend mode. > > Signed-off-by: Takanari Hayama <taki@igel.co.jp> > --- > drivers/media/platform/renesas/vsp1/vsp1_drm.c | 11 +++++++++++ > include/media/vsp1.h | 14 ++++++++++++++ > 2 files changed, 25 insertions(+) > > diff --git a/drivers/media/platform/renesas/vsp1/vsp1_drm.c b/drivers/media/platform/renesas/vsp1/vsp1_drm.c > index 9ec3ac835987..ed0cf552fce2 100644 > --- a/drivers/media/platform/renesas/vsp1/vsp1_drm.c > +++ b/drivers/media/platform/renesas/vsp1/vsp1_drm.c > @@ -861,6 +861,17 @@ int vsp1_du_atomic_update(struct device *dev, unsigned int pipe_index, > vsp1->drm->inputs[rpf_index].compose = cfg->dst; > vsp1->drm->inputs[rpf_index].zpos = cfg->zpos; > > + switch (cfg->blend_mode) { > + case VSP1_DU_BLEND_MODE_PREMULTI: > + rpf->format.flags = V4L2_PIX_FMT_FLAG_PREMUL_ALPHA; > + break; > + case VSP1_DU_BLEND_MODE_PIXEL_NONE: > + rpf->pixel_alpha = false; > + fallthrough; > + case VSP1_DU_BLEND_MODE_COVERAGE: > + rpf->format.flags = 0; > + } This should work, but wouldn't it be simpler to override the format passed in cfg->pixelformat in rcar_du_vsp_plane_setup() with the non-alpha variant when state->state.pixel_blend_mode is set to DRM_MODE_BLEND_PIXEL_NONE ? That way you could drop rpf->pixel_alpha, turn cfg->blend_mode into a premult bool flag, and drop the vsp1_du_blend_mode enum. There's only three formats with an alpha channel that the rcar-du driver supports (DRM_FORMAT_ARGB4444, DRM_FORMAT_ARGB1555 and DRM_FORMAT_ARGB8888), so the override could be as simple as a switch (state->format->fourcc) when the blend mode is NONE. > + > drm_pipe->pipe.inputs[rpf_index] = rpf; > > return 0; > diff --git a/include/media/vsp1.h b/include/media/vsp1.h > index cc1b0d42ce95..1ba7459b7a06 100644 > --- a/include/media/vsp1.h > +++ b/include/media/vsp1.h > @@ -42,6 +42,18 @@ struct vsp1_du_lif_config { > int vsp1_du_setup_lif(struct device *dev, unsigned int pipe_index, > const struct vsp1_du_lif_config *cfg); > > +/** > + * enum vsp1_du_blend_mode - Pixel blend mode > + * @VSP1_DU_BLEND_MODE_PREMULTI: Pixel alpha is pre-mutiplied > + * @VSP1_DU_BLEND_MODE_COVERAGE: Pixel alpha is not pre-mutiplied > + * @VSP1_DU_BLEND_MODE_PIXEL_NONE: Ignores the pixel alpha > + */ > +enum vsp1_du_blend_mode { > + VSP1_DU_BLEND_MODE_PREMULTI, > + VSP1_DU_BLEND_MODE_COVERAGE, > + VSP1_DU_BLEND_MODE_PIXEL_NONE, > +}; > + > /** > * struct vsp1_du_atomic_config - VSP atomic configuration parameters > * @pixelformat: plane pixel format (V4L2 4CC) > @@ -51,6 +63,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) > + * @blend_mode: Pixel blend mode of the plane > */ > struct vsp1_du_atomic_config { > u32 pixelformat; > @@ -60,6 +73,7 @@ struct vsp1_du_atomic_config { > struct v4l2_rect dst; > unsigned int alpha; > unsigned int zpos; > + enum vsp1_du_blend_mode blend_mode; > }; > > /** -- Regards, Laurent Pinchart ^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH 2/3] media: vsp1: add blend mode support 2022-07-30 22:36 ` Laurent Pinchart @ 2022-08-01 8:37 ` Takanari Hayama 0 siblings, 0 replies; 8+ messages in thread From: Takanari Hayama @ 2022-08-01 8:37 UTC (permalink / raw) To: Laurent Pinchart; +Cc: dri-devel, linux-renesas-soc, kieran.bingham+renesas Hi Laurent, Thank you for reviewing the patch. > 2022/07/31 7:36、Laurent Pinchart <laurent.pinchart@ideasonboard.com>のメール: > > Hi Hayama-san, > > Thank you for the patch. > > On Mon, Jul 04, 2022 at 11:52:30AM +0900, Takanari Hayama wrote: >> To support DRM blend mode in R-Car DU driver, we must add blend mode >> support in VSP1. Although VSP1 hardware is capable to support all blend >> mode defined in DRM, the current R-Car DU driver implicitly supports >> DRM_MODE_BLEND_COVERAGE only. >> >> We add a new property to vsp1_du_atomic_config, so that R-Car DU driver >> can pass the desired blend mode. >> >> Signed-off-by: Takanari Hayama <taki@igel.co.jp> >> --- >> drivers/media/platform/renesas/vsp1/vsp1_drm.c | 11 +++++++++++ >> include/media/vsp1.h | 14 ++++++++++++++ >> 2 files changed, 25 insertions(+) >> >> diff --git a/drivers/media/platform/renesas/vsp1/vsp1_drm.c b/drivers/media/platform/renesas/vsp1/vsp1_drm.c >> index 9ec3ac835987..ed0cf552fce2 100644 >> --- a/drivers/media/platform/renesas/vsp1/vsp1_drm.c >> +++ b/drivers/media/platform/renesas/vsp1/vsp1_drm.c >> @@ -861,6 +861,17 @@ int vsp1_du_atomic_update(struct device *dev, unsigned int pipe_index, >> vsp1->drm->inputs[rpf_index].compose = cfg->dst; >> vsp1->drm->inputs[rpf_index].zpos = cfg->zpos; >> >> + switch (cfg->blend_mode) { >> + case VSP1_DU_BLEND_MODE_PREMULTI: >> + rpf->format.flags = V4L2_PIX_FMT_FLAG_PREMUL_ALPHA; >> + break; >> + case VSP1_DU_BLEND_MODE_PIXEL_NONE: >> + rpf->pixel_alpha = false; >> + fallthrough; >> + case VSP1_DU_BLEND_MODE_COVERAGE: >> + rpf->format.flags = 0; >> + } > > This should work, but wouldn't it be simpler to override the format > passed in cfg->pixelformat in rcar_du_vsp_plane_setup() with the > non-alpha variant when state->state.pixel_blend_mode is set to > DRM_MODE_BLEND_PIXEL_NONE ? That way you could drop rpf->pixel_alpha, > turn cfg->blend_mode into a premult bool flag, and drop the > vsp1_du_blend_mode enum. There's only three formats with an alpha > channel that the rcar-du driver supports (DRM_FORMAT_ARGB4444, > DRM_FORMAT_ARGB1555 and DRM_FORMAT_ARGB8888), so the override could be > as simple as a switch (state->format->fourcc) when the blend mode is > NONE. You’re right. I’ll make the suggested changes and submit V2. > >> + >> drm_pipe->pipe.inputs[rpf_index] = rpf; >> >> return 0; >> diff --git a/include/media/vsp1.h b/include/media/vsp1.h >> index cc1b0d42ce95..1ba7459b7a06 100644 >> --- a/include/media/vsp1.h >> +++ b/include/media/vsp1.h >> @@ -42,6 +42,18 @@ struct vsp1_du_lif_config { >> int vsp1_du_setup_lif(struct device *dev, unsigned int pipe_index, >> const struct vsp1_du_lif_config *cfg); >> >> +/** >> + * enum vsp1_du_blend_mode - Pixel blend mode >> + * @VSP1_DU_BLEND_MODE_PREMULTI: Pixel alpha is pre-mutiplied >> + * @VSP1_DU_BLEND_MODE_COVERAGE: Pixel alpha is not pre-mutiplied >> + * @VSP1_DU_BLEND_MODE_PIXEL_NONE: Ignores the pixel alpha >> + */ >> +enum vsp1_du_blend_mode { >> + VSP1_DU_BLEND_MODE_PREMULTI, >> + VSP1_DU_BLEND_MODE_COVERAGE, >> + VSP1_DU_BLEND_MODE_PIXEL_NONE, >> +}; >> + >> /** >> * struct vsp1_du_atomic_config - VSP atomic configuration parameters >> * @pixelformat: plane pixel format (V4L2 4CC) >> @@ -51,6 +63,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) >> + * @blend_mode: Pixel blend mode of the plane >> */ >> struct vsp1_du_atomic_config { >> u32 pixelformat; >> @@ -60,6 +73,7 @@ struct vsp1_du_atomic_config { >> struct v4l2_rect dst; >> unsigned int alpha; >> unsigned int zpos; >> + enum vsp1_du_blend_mode blend_mode; >> }; >> >> /** > > -- > Regards, > > Laurent Pinchart Cheers, Takanari Hayama, Ph.D. <taki@igel.co.jp> IGEL Co., Ltd. https://www.igel.co.jp/ ^ permalink raw reply [flat|nested] 8+ messages in thread
* [PATCH 3/3] drm: rcar-du: Add DRM blend mode support 2022-07-04 2:52 [PATCH 0/3] Add DRM pixel blend mode support to R-Car DU Takanari Hayama 2022-07-04 2:52 ` [PATCH 1/3] media: vsp1: save pixel alpha info in vsp1_rwpf Takanari Hayama 2022-07-04 2:52 ` [PATCH 2/3] media: vsp1: add blend mode support Takanari Hayama @ 2022-07-04 2:52 ` Takanari Hayama 2022-07-30 22:38 ` Laurent Pinchart 2 siblings, 1 reply; 8+ messages in thread From: Takanari Hayama @ 2022-07-04 2:52 UTC (permalink / raw) To: dri-devel; +Cc: linux-renesas-soc, laurent.pinchart, kieran.bingham+renesas R-Car DU supports different blend modes via VSP1. Add DRM blend mode supports to make it configurable. As drm_plane_create_blend_mode_property() creates the blend mode property with the default value of DRM_MODE_BLEND_PREMULTI, it changes the default blending behavior on R-Car DU. The rcar-du's blend mode was same as DRM_MODE_BLEND_COVERAGE, i.e., pixel color values have not been pre-multitplied. Signed-off-by: Takanari Hayama <taki@igel.co.jp> --- drivers/gpu/drm/rcar-du/rcar_du_vsp.c | 17 +++++++++++++++++ 1 file changed, 17 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..283327046aa5 100644 --- a/drivers/gpu/drm/rcar-du/rcar_du_vsp.c +++ b/drivers/gpu/drm/rcar-du/rcar_du_vsp.c @@ -170,6 +170,18 @@ static void rcar_du_vsp_plane_setup(struct rcar_du_vsp_plane *plane) format = rcar_du_format_info(state->format->fourcc); cfg.pixelformat = format->v4l2; + switch (state->state.pixel_blend_mode) { + case DRM_MODE_BLEND_PREMULTI: + cfg.blend_mode = VSP1_DU_BLEND_MODE_PREMULTI; + break; + case DRM_MODE_BLEND_COVERAGE: + cfg.blend_mode = VSP1_DU_BLEND_MODE_COVERAGE; + break; + case DRM_MODE_BLEND_PIXEL_NONE: + cfg.blend_mode = VSP1_DU_BLEND_MODE_PIXEL_NONE; + break; + } + vsp1_du_atomic_update(plane->vsp->vsp, crtc->vsp_pipe, plane->index, &cfg); } @@ -444,6 +456,11 @@ 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_PIXEL_NONE) | + BIT(DRM_MODE_BLEND_PREMULTI) | + BIT(DRM_MODE_BLEND_COVERAGE)); + vsp->num_planes++; } -- 2.25.1 ^ permalink raw reply related [flat|nested] 8+ messages in thread
* Re: [PATCH 3/3] drm: rcar-du: Add DRM blend mode support 2022-07-04 2:52 ` [PATCH 3/3] drm: rcar-du: Add DRM " Takanari Hayama @ 2022-07-30 22:38 ` Laurent Pinchart 0 siblings, 0 replies; 8+ messages in thread From: Laurent Pinchart @ 2022-07-30 22:38 UTC (permalink / raw) To: Takanari Hayama; +Cc: dri-devel, linux-renesas-soc, kieran.bingham+renesas Hi Hayama-san, Thank you for the patch. On Mon, Jul 04, 2022 at 11:52:31AM +0900, Takanari Hayama wrote: > R-Car DU supports different blend modes via VSP1. Add DRM blend mode > supports to make it configurable. > > As drm_plane_create_blend_mode_property() creates the blend mode > property with the default value of DRM_MODE_BLEND_PREMULTI, it changes > the default blending behavior on R-Car DU. The rcar-du's blend mode was > same as DRM_MODE_BLEND_COVERAGE, i.e., pixel color values have not been > pre-multitplied. If that's what KMS userspace requires I'm fine with it. > Signed-off-by: Takanari Hayama <taki@igel.co.jp> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> but I expect this patch to change based on my suggestions for 2/3. > --- > drivers/gpu/drm/rcar-du/rcar_du_vsp.c | 17 +++++++++++++++++ > 1 file changed, 17 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..283327046aa5 100644 > --- a/drivers/gpu/drm/rcar-du/rcar_du_vsp.c > +++ b/drivers/gpu/drm/rcar-du/rcar_du_vsp.c > @@ -170,6 +170,18 @@ static void rcar_du_vsp_plane_setup(struct rcar_du_vsp_plane *plane) > format = rcar_du_format_info(state->format->fourcc); > cfg.pixelformat = format->v4l2; > > + switch (state->state.pixel_blend_mode) { > + case DRM_MODE_BLEND_PREMULTI: > + cfg.blend_mode = VSP1_DU_BLEND_MODE_PREMULTI; > + break; > + case DRM_MODE_BLEND_COVERAGE: > + cfg.blend_mode = VSP1_DU_BLEND_MODE_COVERAGE; > + break; > + case DRM_MODE_BLEND_PIXEL_NONE: > + cfg.blend_mode = VSP1_DU_BLEND_MODE_PIXEL_NONE; > + break; > + } > + > vsp1_du_atomic_update(plane->vsp->vsp, crtc->vsp_pipe, > plane->index, &cfg); > } > @@ -444,6 +456,11 @@ 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_PIXEL_NONE) | > + BIT(DRM_MODE_BLEND_PREMULTI) | > + BIT(DRM_MODE_BLEND_COVERAGE)); > + > vsp->num_planes++; > } > -- Regards, Laurent Pinchart ^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2022-08-01 8:37 UTC | newest] Thread overview: 8+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2022-07-04 2:52 [PATCH 0/3] Add DRM pixel blend mode support to R-Car DU Takanari Hayama 2022-07-04 2:52 ` [PATCH 1/3] media: vsp1: save pixel alpha info in vsp1_rwpf Takanari Hayama 2022-07-30 21:10 ` Laurent Pinchart 2022-07-04 2:52 ` [PATCH 2/3] media: vsp1: add blend mode support Takanari Hayama 2022-07-30 22:36 ` Laurent Pinchart 2022-08-01 8:37 ` Takanari Hayama 2022-07-04 2:52 ` [PATCH 3/3] drm: rcar-du: Add DRM " Takanari Hayama 2022-07-30 22:38 ` Laurent Pinchart
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox