* [PATCH] rcar-vin: Limit NV12 availability to supported VIN channels only
@ 2019-11-06 23:23 Niklas Söderlund
2019-11-07 7:41 ` Geert Uytterhoeven
0 siblings, 1 reply; 4+ messages in thread
From: Niklas Söderlund @ 2019-11-06 23:23 UTC (permalink / raw)
To: Laurent Pinchart, linux-media; +Cc: linux-renesas-soc, Niklas Söderlund
When adding support for NV12 it was overlooked that the pixel format is
only supported on some VIN channels. Fix this by adding a check to only
accept NV12 on the supported channels (0, 1, 4, 5, 8, 9, 12 and 13).
Signed-off-by: Niklas Söderlund <niklas.soderlund+renesas@ragnatech.se>
---
drivers/media/platform/rcar-vin/rcar-v4l2.c | 7 ++++++-
1 file changed, 6 insertions(+), 1 deletion(-)
diff --git a/drivers/media/platform/rcar-vin/rcar-v4l2.c b/drivers/media/platform/rcar-vin/rcar-v4l2.c
index 9e2e63ffcc47acad..62d308a4ddaee82e 100644
--- a/drivers/media/platform/rcar-vin/rcar-v4l2.c
+++ b/drivers/media/platform/rcar-vin/rcar-v4l2.c
@@ -76,7 +76,12 @@ const struct rvin_video_format *rvin_format_from_pixel(struct rvin_dev *vin,
if (vin->info->model == RCAR_M1 && pixelformat == V4L2_PIX_FMT_XBGR32)
return NULL;
- if (pixelformat == V4L2_PIX_FMT_NV12 && !vin->info->nv12)
+ /*
+ * If NV12 is supported it's only supported on some channels (0, 1, 4,
+ * 5, 8, 9, 12 and 13).
+ */
+ if (pixelformat == V4L2_PIX_FMT_NV12 &&
+ (!vin->info->nv12 || BIT(vin->id) & 0xcccc))
return NULL;
for (i = 0; i < ARRAY_SIZE(rvin_formats); i++)
--
2.23.0
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH] rcar-vin: Limit NV12 availability to supported VIN channels only
2019-11-06 23:23 [PATCH] rcar-vin: Limit NV12 availability to supported VIN channels only Niklas Söderlund
@ 2019-11-07 7:41 ` Geert Uytterhoeven
2019-11-07 7:47 ` Niklas Söderlund
0 siblings, 1 reply; 4+ messages in thread
From: Geert Uytterhoeven @ 2019-11-07 7:41 UTC (permalink / raw)
To: Niklas Söderlund
Cc: Laurent Pinchart, Linux Media Mailing List, Linux-Renesas
Hi Niklas,
On Thu, Nov 7, 2019 at 12:25 AM Niklas Söderlund
<niklas.soderlund+renesas@ragnatech.se> wrote:
> When adding support for NV12 it was overlooked that the pixel format is
> only supported on some VIN channels. Fix this by adding a check to only
> accept NV12 on the supported channels (0, 1, 4, 5, 8, 9, 12 and 13).
>
> Signed-off-by: Niklas Söderlund <niklas.soderlund+renesas@ragnatech.se>
Thanks for your patch!
> --- a/drivers/media/platform/rcar-vin/rcar-v4l2.c
> +++ b/drivers/media/platform/rcar-vin/rcar-v4l2.c
> @@ -76,7 +76,12 @@ const struct rvin_video_format *rvin_format_from_pixel(struct rvin_dev *vin,
> if (vin->info->model == RCAR_M1 && pixelformat == V4L2_PIX_FMT_XBGR32)
> return NULL;
>
> - if (pixelformat == V4L2_PIX_FMT_NV12 && !vin->info->nv12)
> + /*
> + * If NV12 is supported it's only supported on some channels (0, 1, 4,
> + * 5, 8, 9, 12 and 13).
Is this true for all SoCs, or do you need a vin->info->model == RCAR_GEN3
check?
> + */
> + if (pixelformat == V4L2_PIX_FMT_NV12 &&
> + (!vin->info->nv12 || BIT(vin->id) & 0xcccc))
> return NULL;
So 0xcccc = ~(BIT(0) | BIT(1) | BIT(4) | ...)?
What if you ever have an id larger than 15?
Wouldn't it be safer to check for !(BIT(vin->id) & 0x3333)?
Gr{oetje,eeting}s,
Geert
--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org
In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
-- Linus Torvalds
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] rcar-vin: Limit NV12 availability to supported VIN channels only
2019-11-07 7:41 ` Geert Uytterhoeven
@ 2019-11-07 7:47 ` Niklas Söderlund
2019-11-07 8:13 ` Geert Uytterhoeven
0 siblings, 1 reply; 4+ messages in thread
From: Niklas Söderlund @ 2019-11-07 7:47 UTC (permalink / raw)
To: Geert Uytterhoeven
Cc: Laurent Pinchart, Linux Media Mailing List, Linux-Renesas
Hi Geert,
Thanks for your feedback.
On 2019-11-07 08:41:11 +0100, Geert Uytterhoeven wrote:
> Hi Niklas,
>
> On Thu, Nov 7, 2019 at 12:25 AM Niklas Söderlund
> <niklas.soderlund+renesas@ragnatech.se> wrote:
> > When adding support for NV12 it was overlooked that the pixel format is
> > only supported on some VIN channels. Fix this by adding a check to only
> > accept NV12 on the supported channels (0, 1, 4, 5, 8, 9, 12 and 13).
> >
> > Signed-off-by: Niklas Söderlund <niklas.soderlund+renesas@ragnatech.se>
>
> Thanks for your patch!
>
> > --- a/drivers/media/platform/rcar-vin/rcar-v4l2.c
> > +++ b/drivers/media/platform/rcar-vin/rcar-v4l2.c
> > @@ -76,7 +76,12 @@ const struct rvin_video_format *rvin_format_from_pixel(struct rvin_dev *vin,
> > if (vin->info->model == RCAR_M1 && pixelformat == V4L2_PIX_FMT_XBGR32)
> > return NULL;
> >
> > - if (pixelformat == V4L2_PIX_FMT_NV12 && !vin->info->nv12)
> > + /*
> > + * If NV12 is supported it's only supported on some channels (0, 1, 4,
> > + * 5, 8, 9, 12 and 13).
>
> Is this true for all SoCs, or do you need a vin->info->model == RCAR_GEN3
> check?
NV12 is only supported by most Gen3 SoCs, but no extra check is needed
as vin->info->nv12 is only set for the Gen3 SoCs that can support NV12.
>
> > + */
> > + if (pixelformat == V4L2_PIX_FMT_NV12 &&
> > + (!vin->info->nv12 || BIT(vin->id) & 0xcccc))
> > return NULL;
>
> So 0xcccc = ~(BIT(0) | BIT(1) | BIT(4) | ...)?
Yes.
> What if you ever have an id larger than 15?
> Wouldn't it be safer to check for !(BIT(vin->id) & 0x3333)?
There is no SoC with more then 16 VIN instances, today... Maybe your
suggestion of the inverted check makes more sens. Will respin a v2.
>
> Gr{oetje,eeting}s,
>
> Geert
>
> --
> Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org
>
> In personal conversations with technical people, I call myself a hacker. But
> when I'm talking to journalists I just say "programmer" or something like that.
> -- Linus Torvalds
--
Regards,
Niklas Söderlund
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] rcar-vin: Limit NV12 availability to supported VIN channels only
2019-11-07 7:47 ` Niklas Söderlund
@ 2019-11-07 8:13 ` Geert Uytterhoeven
0 siblings, 0 replies; 4+ messages in thread
From: Geert Uytterhoeven @ 2019-11-07 8:13 UTC (permalink / raw)
To: Niklas Söderlund
Cc: Laurent Pinchart, Linux Media Mailing List, Linux-Renesas
Hi Niklas,
On Thu, Nov 7, 2019 at 8:47 AM Niklas Söderlund
<niklas.soderlund+renesas@ragnatech.se> wrote:
> On 2019-11-07 08:41:11 +0100, Geert Uytterhoeven wrote:
> > On Thu, Nov 7, 2019 at 12:25 AM Niklas Söderlund
> > <niklas.soderlund+renesas@ragnatech.se> wrote:
> > > When adding support for NV12 it was overlooked that the pixel format is
> > > only supported on some VIN channels. Fix this by adding a check to only
> > > accept NV12 on the supported channels (0, 1, 4, 5, 8, 9, 12 and 13).
> > >
> > > Signed-off-by: Niklas Söderlund <niklas.soderlund+renesas@ragnatech.se>
> >
> > Thanks for your patch!
> >
> > > --- a/drivers/media/platform/rcar-vin/rcar-v4l2.c
> > > +++ b/drivers/media/platform/rcar-vin/rcar-v4l2.c
> > > @@ -76,7 +76,12 @@ const struct rvin_video_format *rvin_format_from_pixel(struct rvin_dev *vin,
> > > if (vin->info->model == RCAR_M1 && pixelformat == V4L2_PIX_FMT_XBGR32)
> > > return NULL;
> > >
> > > - if (pixelformat == V4L2_PIX_FMT_NV12 && !vin->info->nv12)
> > > + /*
> > > + * If NV12 is supported it's only supported on some channels (0, 1, 4,
> > > + * 5, 8, 9, 12 and 13).
> >
> > Is this true for all SoCs, or do you need a vin->info->model == RCAR_GEN3
> > check?
>
> NV12 is only supported by most Gen3 SoCs, but no extra check is needed
> as vin->info->nv12 is only set for the Gen3 SoCs that can support NV12.
Thanks, had missed the meaning of the vin->info->nv12 check.
> > > + */
> > > + if (pixelformat == V4L2_PIX_FMT_NV12 &&
> > > + (!vin->info->nv12 || BIT(vin->id) & 0xcccc))
> > > return NULL;
> >
> > So 0xcccc = ~(BIT(0) | BIT(1) | BIT(4) | ...)?
>
> Yes.
>
> > What if you ever have an id larger than 15?
> > Wouldn't it be safer to check for !(BIT(vin->id) & 0x3333)?
>
> There is no SoC with more then 16 VIN instances, today... Maybe your
> suggestion of the inverted check makes more sens. Will respin a v2.
OK. BTW, the code may look nicer if you start using a
"switch (pixelformat) { ... }" block to handle all special cases.
Gr{oetje,eeting}s,
Geert
--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org
In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
-- Linus Torvalds
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2019-11-07 8:13 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-11-06 23:23 [PATCH] rcar-vin: Limit NV12 availability to supported VIN channels only Niklas Söderlund
2019-11-07 7:41 ` Geert Uytterhoeven
2019-11-07 7:47 ` Niklas Söderlund
2019-11-07 8:13 ` Geert Uytterhoeven
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).