From: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
To: Takanari Hayama <taki@igel.co.jp>
Cc: dri-devel@lists.freedesktop.org,
linux-renesas-soc@vger.kernel.org,
kieran.bingham+renesas@ideasonboard.com
Subject: Re: [PATCH 2/3] media: vsp1: add blend mode support
Date: Sun, 31 Jul 2022 01:36:39 +0300 [thread overview]
Message-ID: <YuWyd2YGLx1J5vPW@pendragon.ideasonboard.com> (raw)
In-Reply-To: <20220704025231.3911138-3-taki@igel.co.jp>
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
next prev parent reply other threads:[~2022-07-30 22:36 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
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 [this message]
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
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=YuWyd2YGLx1J5vPW@pendragon.ideasonboard.com \
--to=laurent.pinchart@ideasonboard.com \
--cc=dri-devel@lists.freedesktop.org \
--cc=kieran.bingham+renesas@ideasonboard.com \
--cc=linux-renesas-soc@vger.kernel.org \
--cc=taki@igel.co.jp \
/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