* [RFC PATCH v1] media: rcar-vin: Use V4L2_COLORSPACE_RAW for raw formats
@ 2026-11-27 10:29 Barnabás Pőcze
2026-11-30 16:29 ` Niklas Söderlund
0 siblings, 1 reply; 2+ messages in thread
From: Barnabás Pőcze @ 2026-11-27 10:29 UTC (permalink / raw)
To: Niklas Söderlund, Mauro Carvalho Chehab, Geert Uytterhoeven,
Magnus Damm, Hans Verkuil, Lad Prabhakar
Cc: linux-media, linux-renesas-soc, linux-kernel, Barnabás Pőcze
In `rvin_mc_try_format()`, `RVIN_DEFAULT_COLORSPACE` is used unconditionally.
That corresponds to the SRGB color space. However, this is reported even for
raw formats, where `V4L2_COLORSPACE_RAW` would be a better fit.
So check if the adjusted pixel format has bayer encoding and if so, report
the raw color space, otherwise fall back to `RVIN_DEFAULT_COLORSPACE`.
Fixes: e87c1a81f158d ("media: rcar-vin: Add support for MEDIA_BUS_FMT_SRGGB8_1X8 format")
Signed-off-by: Barnabás Pőcze <barnabas.pocze+renesas@ideasonboard.com>
---
This is an RFC because this approach feels a bit ad-hoc, and while it solves the
issue at hand, maybe there is a better solution.
---
drivers/media/platform/renesas/rcar-vin/rcar-v4l2.c | 10 +++++++---
1 file changed, 7 insertions(+), 3 deletions(-)
diff --git a/drivers/media/platform/renesas/rcar-vin/rcar-v4l2.c b/drivers/media/platform/renesas/rcar-vin/rcar-v4l2.c
index 4961d28f42c78..28573c0bde863 100644
--- a/drivers/media/platform/renesas/rcar-vin/rcar-v4l2.c
+++ b/drivers/media/platform/renesas/rcar-vin/rcar-v4l2.c
@@ -543,19 +543,23 @@ static int rvin_subscribe_event(struct v4l2_fh *fh,
static void rvin_mc_try_format(struct rvin_dev *vin,
struct v4l2_pix_format *pix)
{
+ rvin_format_align(vin, pix);
+
/*
* The V4L2 specification clearly documents the colorspace fields
* as being set by drivers for capture devices. Using the values
* supplied by userspace thus wouldn't comply with the API. Until
* the API is updated force fixed values.
*/
- pix->colorspace = RVIN_DEFAULT_COLORSPACE;
+ if (v4l2_is_format_bayer(v4l2_format_info(pix->pixelformat)))
+ pix->colorspace = V4L2_COLORSPACE_RAW;
+ else
+ pix->colorspace = RVIN_DEFAULT_COLORSPACE;
+
pix->xfer_func = V4L2_MAP_XFER_FUNC_DEFAULT(pix->colorspace);
pix->ycbcr_enc = V4L2_MAP_YCBCR_ENC_DEFAULT(pix->colorspace);
pix->quantization = V4L2_MAP_QUANTIZATION_DEFAULT(true, pix->colorspace,
pix->ycbcr_enc);
-
- rvin_format_align(vin, pix);
}
static int rvin_mc_try_fmt_vid_cap(struct file *file, void *priv,
--
2.56.1
^ permalink raw reply [flat|nested] 2+ messages in thread* Re: [RFC PATCH v1] media: rcar-vin: Use V4L2_COLORSPACE_RAW for raw formats
2026-11-27 10:29 [RFC PATCH v1] media: rcar-vin: Use V4L2_COLORSPACE_RAW for raw formats Barnabás Pőcze
@ 2026-11-30 16:29 ` Niklas Söderlund
0 siblings, 0 replies; 2+ messages in thread
From: Niklas Söderlund @ 2026-11-30 16:29 UTC (permalink / raw)
To: Barnabás Pőcze
Cc: Mauro Carvalho Chehab, Geert Uytterhoeven, Magnus Damm,
Hans Verkuil, Lad Prabhakar, linux-media, linux-renesas-soc,
linux-kernel
Hi Barnabás,
Thanks for your work.
On 2026-11-27 11:29:42 +0100, Barnabás Pőcze wrote:
> In `rvin_mc_try_format()`, `RVIN_DEFAULT_COLORSPACE` is used unconditionally.
> That corresponds to the SRGB color space. However, this is reported even for
> raw formats, where `V4L2_COLORSPACE_RAW` would be a better fit.
>
> So check if the adjusted pixel format has bayer encoding and if so, report
> the raw color space, otherwise fall back to `RVIN_DEFAULT_COLORSPACE`.
>
> Fixes: e87c1a81f158d ("media: rcar-vin: Add support for MEDIA_BUS_FMT_SRGGB8_1X8 format")
> Signed-off-by: Barnabás Pőcze <barnabas.pocze+renesas@ideasonboard.com>
> ---
>
> This is an RFC because this approach feels a bit ad-hoc, and while it solves the
> issue at hand, maybe there is a better solution.
I thin this works and it solves the issue,
Reviewed-by: Niklas Söderlund <niklas.soderlund+renesas@ragnatech.se>
>
> ---
> drivers/media/platform/renesas/rcar-vin/rcar-v4l2.c | 10 +++++++---
> 1 file changed, 7 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/media/platform/renesas/rcar-vin/rcar-v4l2.c b/drivers/media/platform/renesas/rcar-vin/rcar-v4l2.c
> index 4961d28f42c78..28573c0bde863 100644
> --- a/drivers/media/platform/renesas/rcar-vin/rcar-v4l2.c
> +++ b/drivers/media/platform/renesas/rcar-vin/rcar-v4l2.c
> @@ -543,19 +543,23 @@ static int rvin_subscribe_event(struct v4l2_fh *fh,
> static void rvin_mc_try_format(struct rvin_dev *vin,
> struct v4l2_pix_format *pix)
> {
> + rvin_format_align(vin, pix);
> +
> /*
> * The V4L2 specification clearly documents the colorspace fields
> * as being set by drivers for capture devices. Using the values
> * supplied by userspace thus wouldn't comply with the API. Until
> * the API is updated force fixed values.
> */
> - pix->colorspace = RVIN_DEFAULT_COLORSPACE;
> + if (v4l2_is_format_bayer(v4l2_format_info(pix->pixelformat)))
> + pix->colorspace = V4L2_COLORSPACE_RAW;
> + else
> + pix->colorspace = RVIN_DEFAULT_COLORSPACE;
> +
> pix->xfer_func = V4L2_MAP_XFER_FUNC_DEFAULT(pix->colorspace);
> pix->ycbcr_enc = V4L2_MAP_YCBCR_ENC_DEFAULT(pix->colorspace);
> pix->quantization = V4L2_MAP_QUANTIZATION_DEFAULT(true, pix->colorspace,
> pix->ycbcr_enc);
> -
> - rvin_format_align(vin, pix);
> }
>
> static int rvin_mc_try_fmt_vid_cap(struct file *file, void *priv,
> --
> 2.56.1
>
--
Kind Regards,
Niklas Söderlund
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2026-11-30 16:29 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-11-27 10:29 [RFC PATCH v1] media: rcar-vin: Use V4L2_COLORSPACE_RAW for raw formats Barnabás Pőcze
2026-11-30 16:29 ` Niklas Söderlund
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®