From: "Niklas Söderlund" <niklas.soderlund@ragnatech.se>
To: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Cc: linux-media@vger.kernel.org, linux-renesas-soc@vger.kernel.org
Subject: Re: [PATCH 3/3] rcar-vin: Add support for RGB formats with alpha component
Date: Thu, 16 May 2019 15:00:57 +0200 [thread overview]
Message-ID: <20190516130057.GC31788@bigcity.dyn.berto.se> (raw)
In-Reply-To: <20190516100822.GC4995@pendragon.ideasonboard.com>
Hi Laurent,
Thanks for your feedback.
On 2019-05-16 13:08:22 +0300, Laurent Pinchart wrote:
> Hi Niklas,
>
> Thank you for the patch.
>
> On Thu, May 16, 2019 at 02:47:46AM +0200, Niklas Söderlund wrote:
> > The R-Car VIN module supports V4L2_PIX_FMT_ARGB555 and
> > V4L2_PIX_FMT_ABGR32 pixel formats. Add the hardware register setup and
> > allow the alpha component to be changed while streaming using the
> > V4L2_CID_ALPHA_COMPONENT control.
> >
> > Signed-off-by: Niklas Söderlund <niklas.soderlund+renesas@ragnatech.se>
> > ---
> > drivers/media/platform/rcar-vin/rcar-dma.c | 30 +++++++++++++++++++++
> > drivers/media/platform/rcar-vin/rcar-v4l2.c | 8 ++++++
> > 2 files changed, 38 insertions(+)
> >
> > diff --git a/drivers/media/platform/rcar-vin/rcar-dma.c b/drivers/media/platform/rcar-vin/rcar-dma.c
> > index 4e991cce5fb56a90..5c0ed27c5d05dd45 100644
> > --- a/drivers/media/platform/rcar-vin/rcar-dma.c
> > +++ b/drivers/media/platform/rcar-vin/rcar-dma.c
> > @@ -111,8 +111,11 @@
> > #define VNIE_EFE (1 << 1)
> >
> > /* Video n Data Mode Register bits */
> > +#define VNDMR_A8BIT(n) ((n & 0xff) << 24)
> > +#define VNDMR_A8BIT_MASK (0xff << 24)
> > #define VNDMR_EXRGB (1 << 8)
> > #define VNDMR_BPSM (1 << 4)
> > +#define VNDMR_ABIT (1 << 2)
> > #define VNDMR_DTMD_YCSEP (1 << 1)
> > #define VNDMR_DTMD_ARGB (1 << 0)
> >
> > @@ -730,6 +733,12 @@ static int rvin_setup(struct rvin_dev *vin)
> > /* Note: not supported on M1 */
> > dmr = VNDMR_EXRGB;
> > break;
> > + case V4L2_PIX_FMT_ARGB555:
> > + dmr = (vin->alpha ? VNDMR_ABIT : 0) | VNDMR_DTMD_ARGB;
> > + break;
> > + case V4L2_PIX_FMT_ABGR32:
> > + dmr = VNDMR_A8BIT(vin->alpha) | VNDMR_EXRGB | VNDMR_DTMD_ARGB;
> > + break;
> > default:
> > vin_err(vin, "Invalid pixelformat (0x%x)\n",
> > vin->format.pixelformat);
> > @@ -1346,5 +1355,26 @@ int rvin_set_channel_routing(struct rvin_dev *vin, u8 chsel)
> >
> > void rvin_set_alpha(struct rvin_dev *vin, unsigned int alpha)
>
> OK, I now see why you added a rvin_set_alpha() function. It makes sense,
> but I think you need to protect this with a lock to avoid races between
> stream start and control set. Or are we already protected by a lock the
> serialises all V4L2 ioctls for the VIN video node ?
Yes we are protected by the ioctls lock in __video_do_ioctl(), at least
that is my interpretation of the code I have not tried to force a race.
>
> > {
> > + u32 dmr;
> > +
> > vin->alpha = alpha;
> > +
> > + if (vin->state == STOPPED)
> > + return;
> > +
> > + switch (vin->format.pixelformat) {
> > + case V4L2_PIX_FMT_ARGB555:
> > + dmr = rvin_read(vin, VNDMR_REG) & ~VNDMR_ABIT;
> > + if (vin->alpha)
> > + dmr |= VNDMR_ABIT;
> > + break;
>
> Should you cache the DNDMR valid to avoid a hardware read ?
It is one possibility, as VNDMR is written to at other locations I would
feel better to to this at a later point in time.
I'm currently trying to clean up the rcar-vin driver with regard to how
it handles formats a bit different in the devnode and media centric code
paths. Once that work is complete a generic way to cache register values
could be added on top. I suspect there are other registers then VNDMR
which could benefit from such a solution.
>
> > + case V4L2_PIX_FMT_ABGR32:
> > + dmr = rvin_read(vin, VNDMR_REG) & ~VNDMR_A8BIT_MASK;
> > + dmr |= VNDMR_A8BIT(vin->alpha);
> > + break;
> > + default:
> > + return;
> > + }
> > +
> > + rvin_write(vin, dmr, VNDMR_REG);
> > }
> > diff --git a/drivers/media/platform/rcar-vin/rcar-v4l2.c b/drivers/media/platform/rcar-vin/rcar-v4l2.c
> > index 7cbdcbf9b090c638..bb2900f5d000f9a6 100644
> > --- a/drivers/media/platform/rcar-vin/rcar-v4l2.c
> > +++ b/drivers/media/platform/rcar-vin/rcar-v4l2.c
> > @@ -54,6 +54,14 @@ static const struct rvin_video_format rvin_formats[] = {
> > .fourcc = V4L2_PIX_FMT_XBGR32,
> > .bpp = 4,
> > },
> > + {
> > + .fourcc = V4L2_PIX_FMT_ARGB555,
> > + .bpp = 2,
> > + },
> > + {
> > + .fourcc = V4L2_PIX_FMT_ABGR32,
> > + .bpp = 4,
> > + },
> > };
> >
> > const struct rvin_video_format *rvin_format_from_pixel(u32 pixelformat)
>
> --
> Regards,
>
> Laurent Pinchart
--
Regards,
Niklas Söderlund
prev parent reply other threads:[~2019-05-16 13:01 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-05-16 0:47 [PATCH 0/3] rcar-vin: Add support for RGB formats with alpha component Niklas Söderlund
2019-05-16 0:47 ` [PATCH 1/3] rcar-vin: Rename VNDMR_DTMD_ARGB1555 to VNDMR_DTMD_ARGB Niklas Söderlund
2019-05-16 9:57 ` Ulrich Hecht
2019-05-16 9:58 ` Laurent Pinchart
2019-05-16 0:47 ` [PATCH 2/3] rcar-vin: Add control for alpha component Niklas Söderlund
2019-05-16 10:01 ` Laurent Pinchart
2019-05-16 13:04 ` Niklas Söderlund
2019-05-16 0:47 ` [PATCH 3/3] rcar-vin: Add support for RGB formats with " Niklas Söderlund
2019-05-16 10:08 ` Laurent Pinchart
2019-05-16 13:00 ` Niklas Söderlund [this message]
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=20190516130057.GC31788@bigcity.dyn.berto.se \
--to=niklas.soderlund@ragnatech.se \
--cc=laurent.pinchart@ideasonboard.com \
--cc=linux-media@vger.kernel.org \
--cc=linux-renesas-soc@vger.kernel.org \
/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;
as well as URLs for NNTP newsgroup(s).