public inbox for linux-arm-kernel@lists.infradead.org 
 help / color / mirror / Atom feed
* [PATCH] media: bcm2835-unicam: Fix pipeline wrong validation for unpacked formats
@ 2026-05-20 15:37 Eugen Hristev
  2026-05-22  9:54 ` Dave Stevenson
  2026-06-03  6:48 ` Jai Luthra
  0 siblings, 2 replies; 3+ messages in thread
From: Eugen Hristev @ 2026-05-20 15:37 UTC (permalink / raw)
  To: Raspberry Pi Kernel Maintenance, Mauro Carvalho Chehab,
	Florian Fainelli, Ray Jui, Scott Branden,
	Broadcom internal kernel review list, Hans Verkuil,
	Laurent Pinchart, Maxime Ripard, Sakari Ailus
  Cc: linux-media, linux-rpi-kernel, linux-arm-kernel, linux-kernel,
	Eugen Hristev

The commit
08f9794d9b79 ("media: bcm2835-unicam: Fix RGB format / mbus code association")
introduced a check to see whether the format requested is the same as the
fourcc in the format list.

However, this breaks the case when userspace requested an unpacked fourcc,
e.g. RG10.

Unicam can work with or without unpacking pixels, e.g. pRAA or RG10, depending
on what userspace requests.
In the unpacking case, a dedicated register is being set.

If the userspace requests pRAA, this works, because the check validates the
pipeline:

v4l2-ctl -d /dev/video0 --set-fmt-video=width=3280,height=2464,pixelformat=pRAA \
 --stream-mmap --stream-count=1 --stream-to=frame.raw

but, with
v4l2-ctl -d /dev/video0 --set-fmt-video=width=3280,height=2464,pixelformat=RG10 \
--stream-mmap --stream-count=1 --stream-to=frame.raw

unicam complains at validation level:

image: format mismatch: 0x300f <=> RG10 little-endian (0x30314752)

This should work, because MEDIA_BUS_FMT_SRGGB10_1X10 can be packed into either
RG10 or pRAA depending on the packing register.

To fix this, modified the condition check to also allow in the case when
requested format (fmt->pixelformat) is equal to fmtinfo->unpacked_fourcc.

Fixes: 08f9794d9b79 ("media: bcm2835-unicam: Fix RGB format / mbus code association")
Signed-off-by: Eugen Hristev <ehristev@kernel•org>
---
 drivers/media/platform/broadcom/bcm2835-unicam.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/media/platform/broadcom/bcm2835-unicam.c b/drivers/media/platform/broadcom/bcm2835-unicam.c
index 8d28ba0b59a3..cc7627e9a51a 100644
--- a/drivers/media/platform/broadcom/bcm2835-unicam.c
+++ b/drivers/media/platform/broadcom/bcm2835-unicam.c
@@ -2158,7 +2158,8 @@ static int unicam_video_link_validate(struct media_link *link)
 		 * In order to allow the applications using the old behaviour to
 		 * run, let's accept the old combination, but warn about it.
 		 */
-		if (fmtinfo->fourcc != fmt->pixelformat) {
+		if (fmt->pixelformat != fmtinfo->fourcc &&
+		    fmt->pixelformat != fmtinfo->unpacked_fourcc) {
 			if ((fmt->pixelformat == V4L2_PIX_FMT_BGR24 &&
 			     format->code == MEDIA_BUS_FMT_BGR888_1X24) ||
 			    (fmt->pixelformat == V4L2_PIX_FMT_RGB24 &&

---
base-commit: e98d21c170b01ddef366f023bbfcf6b31509fa83
change-id: 20260520-bcmpi-2c4850314e21

Best regards,
--  
Eugen Hristev <ehristev@kernel•org>



^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] media: bcm2835-unicam: Fix pipeline wrong validation for unpacked formats
  2026-05-20 15:37 [PATCH] media: bcm2835-unicam: Fix pipeline wrong validation for unpacked formats Eugen Hristev
@ 2026-05-22  9:54 ` Dave Stevenson
  2026-06-03  6:48 ` Jai Luthra
  1 sibling, 0 replies; 3+ messages in thread
From: Dave Stevenson @ 2026-05-22  9:54 UTC (permalink / raw)
  To: Eugen Hristev
  Cc: Raspberry Pi Kernel Maintenance, Mauro Carvalho Chehab,
	Florian Fainelli, Ray Jui, Scott Branden,
	Broadcom internal kernel review list, Hans Verkuil,
	Laurent Pinchart, Maxime Ripard, Sakari Ailus, linux-media,
	linux-rpi-kernel, linux-arm-kernel, linux-kernel

Hi Eugen

Thanks for the patch.

On Wed, 20 May 2026 at 16:37, 'Eugen Hristev' via kernel-list
<kernel-list@raspberrypi•com> wrote:
>
> The commit
> 08f9794d9b79 ("media: bcm2835-unicam: Fix RGB format / mbus code association")
> introduced a check to see whether the format requested is the same as the
> fourcc in the format list.
>
> However, this breaks the case when userspace requested an unpacked fourcc,
> e.g. RG10.
>
> Unicam can work with or without unpacking pixels, e.g. pRAA or RG10, depending
> on what userspace requests.
> In the unpacking case, a dedicated register is being set.
>
> If the userspace requests pRAA, this works, because the check validates the
> pipeline:
>
> v4l2-ctl -d /dev/video0 --set-fmt-video=width=3280,height=2464,pixelformat=pRAA \
>  --stream-mmap --stream-count=1 --stream-to=frame.raw
>
> but, with
> v4l2-ctl -d /dev/video0 --set-fmt-video=width=3280,height=2464,pixelformat=RG10 \
> --stream-mmap --stream-count=1 --stream-to=frame.raw
>
> unicam complains at validation level:
>
> image: format mismatch: 0x300f <=> RG10 little-endian (0x30314752)
>
> This should work, because MEDIA_BUS_FMT_SRGGB10_1X10 can be packed into either
> RG10 or pRAA depending on the packing register.
>
> To fix this, modified the condition check to also allow in the case when
> requested format (fmt->pixelformat) is equal to fmtinfo->unpacked_fourcc.
>
> Fixes: 08f9794d9b79 ("media: bcm2835-unicam: Fix RGB format / mbus code association")
> Signed-off-by: Eugen Hristev <ehristev@kernel•org>

Reviewed-by: Dave Stevenson <dave.stevenson@raspberrypi•com>

> ---
>  drivers/media/platform/broadcom/bcm2835-unicam.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/media/platform/broadcom/bcm2835-unicam.c b/drivers/media/platform/broadcom/bcm2835-unicam.c
> index 8d28ba0b59a3..cc7627e9a51a 100644
> --- a/drivers/media/platform/broadcom/bcm2835-unicam.c
> +++ b/drivers/media/platform/broadcom/bcm2835-unicam.c
> @@ -2158,7 +2158,8 @@ static int unicam_video_link_validate(struct media_link *link)
>                  * In order to allow the applications using the old behaviour to
>                  * run, let's accept the old combination, but warn about it.
>                  */
> -               if (fmtinfo->fourcc != fmt->pixelformat) {
> +               if (fmt->pixelformat != fmtinfo->fourcc &&
> +                   fmt->pixelformat != fmtinfo->unpacked_fourcc) {
>                         if ((fmt->pixelformat == V4L2_PIX_FMT_BGR24 &&
>                              format->code == MEDIA_BUS_FMT_BGR888_1X24) ||
>                             (fmt->pixelformat == V4L2_PIX_FMT_RGB24 &&
>
> ---
> base-commit: e98d21c170b01ddef366f023bbfcf6b31509fa83
> change-id: 20260520-bcmpi-2c4850314e21
>
> Best regards,
> --
> Eugen Hristev <ehristev@kernel•org>
>


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] media: bcm2835-unicam: Fix pipeline wrong validation for unpacked formats
  2026-05-20 15:37 [PATCH] media: bcm2835-unicam: Fix pipeline wrong validation for unpacked formats Eugen Hristev
  2026-05-22  9:54 ` Dave Stevenson
@ 2026-06-03  6:48 ` Jai Luthra
  1 sibling, 0 replies; 3+ messages in thread
From: Jai Luthra @ 2026-06-03  6:48 UTC (permalink / raw)
  To: Broadcom internal kernel review list, Eugen Hristev,
	Florian Fainelli, Hans Verkuil, Laurent Pinchart,
	Mauro Carvalho Chehab, Maxime Ripard,
	Raspberry Pi Kernel Maintenance, Ray Jui, Sakari Ailus,
	Scott Branden
  Cc: linux-media, linux-rpi-kernel, linux-arm-kernel, linux-kernel,
	Eugen Hristev

Hi Eugen,

Quoting Eugen Hristev (2026-05-20 21:07:00)
> The commit
> 08f9794d9b79 ("media: bcm2835-unicam: Fix RGB format / mbus code association")
> introduced a check to see whether the format requested is the same as the
> fourcc in the format list.
> 
> However, this breaks the case when userspace requested an unpacked fourcc,
> e.g. RG10.
> 
> Unicam can work with or without unpacking pixels, e.g. pRAA or RG10, depending
> on what userspace requests.
> In the unpacking case, a dedicated register is being set.
> 
> If the userspace requests pRAA, this works, because the check validates the
> pipeline:
> 
> v4l2-ctl -d /dev/video0 --set-fmt-video=width=3280,height=2464,pixelformat=pRAA \
>  --stream-mmap --stream-count=1 --stream-to=frame.raw
> 
> but, with
> v4l2-ctl -d /dev/video0 --set-fmt-video=width=3280,height=2464,pixelformat=RG10 \
> --stream-mmap --stream-count=1 --stream-to=frame.raw
> 
> unicam complains at validation level:
> 
> image: format mismatch: 0x300f <=> RG10 little-endian (0x30314752)
> 
> This should work, because MEDIA_BUS_FMT_SRGGB10_1X10 can be packed into either
> RG10 or pRAA depending on the packing register.
> 
> To fix this, modified the condition check to also allow in the case when
> requested format (fmt->pixelformat) is equal to fmtinfo->unpacked_fourcc.
> 
> Fixes: 08f9794d9b79 ("media: bcm2835-unicam: Fix RGB format / mbus code association")
> Signed-off-by: Eugen Hristev <ehristev@kernel•org>
> ---
>  drivers/media/platform/broadcom/bcm2835-unicam.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/media/platform/broadcom/bcm2835-unicam.c b/drivers/media/platform/broadcom/bcm2835-unicam.c
> index 8d28ba0b59a3..cc7627e9a51a 100644
> --- a/drivers/media/platform/broadcom/bcm2835-unicam.c
> +++ b/drivers/media/platform/broadcom/bcm2835-unicam.c
> @@ -2158,7 +2158,8 @@ static int unicam_video_link_validate(struct media_link *link)
>                  * In order to allow the applications using the old behaviour to
>                  * run, let's accept the old combination, but warn about it.
>                  */
> -               if (fmtinfo->fourcc != fmt->pixelformat) {
> +               if (fmt->pixelformat != fmtinfo->fourcc &&
> +                   fmt->pixelformat != fmtinfo->unpacked_fourcc) {
>                         if ((fmt->pixelformat == V4L2_PIX_FMT_BGR24 &&
>                              format->code == MEDIA_BUS_FMT_BGR888_1X24) ||
>                             (fmt->pixelformat == V4L2_PIX_FMT_RGB24 &&
> 

Reviewed-by: Jai Luthra <jai.luthra@ideasonboard•com>

Thanks,
Jai

> ---
> base-commit: e98d21c170b01ddef366f023bbfcf6b31509fa83
> change-id: 20260520-bcmpi-2c4850314e21
> 
> Best regards,
> --  
> Eugen Hristev <ehristev@kernel•org>
> 
>


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2026-06-03  6:57 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-05-20 15:37 [PATCH] media: bcm2835-unicam: Fix pipeline wrong validation for unpacked formats Eugen Hristev
2026-05-22  9:54 ` Dave Stevenson
2026-06-03  6:48 ` Jai Luthra

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox