[RFC PATCH v1] media: rcar-vin: Use V4L2_COLORSPACE_RAW for raw formats
From: Barnabás Pőcze
Date: Fri Nov 27 2026 - 05:30:03 EST
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@xxxxxxxxxxxxxxxx>
---
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