media: vimc: cap: Report a colorspace
authorNiklas Söderlund <niklas.soderlund+renesas@ragnatech.se>
Fri, 17 Apr 2020 15:09:29 +0000 (17:09 +0200)
committerMauro Carvalho Chehab <mchehab+huawei@kernel.org>
Wed, 29 Apr 2020 10:02:30 +0000 (12:02 +0200)
The colorspace reported by a video nodes should not be
V4L2_COLORSPACE_DEFAULT. Instead a default colorspace should be picked
by the driver if V4L2_COLORSPACE_DEFAULT is given by userspace to
{G,S,TRY}_FMT.

The colorspace V4L2_COLORSPACE_SRGB is arbitrary chosen as the vimc
default format to report as it's used for most webcams.

Signed-off-by: Niklas Söderlund <niklas.soderlund+renesas@ragnatech.se>
Acked-by: Helen Koike <helen.koike@collabora.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
drivers/media/test-drivers/vimc/vimc-capture.c
drivers/media/test-drivers/vimc/vimc-debayer.c
drivers/media/test-drivers/vimc/vimc-scaler.c
drivers/media/test-drivers/vimc/vimc-sensor.c

index 5315c201314c9cc42cc1866430c52aa01ae2af71..20c2f5e281bc44ed2062f19e631284ba63ac8591 100644 (file)
@@ -37,7 +37,7 @@ static const struct v4l2_pix_format fmt_default = {
        .height = 480,
        .pixelformat = V4L2_PIX_FMT_RGB24,
        .field = V4L2_FIELD_NONE,
-       .colorspace = V4L2_COLORSPACE_DEFAULT,
+       .colorspace = V4L2_COLORSPACE_SRGB,
 };
 
 struct vimc_cap_buffer {
@@ -107,6 +107,9 @@ static int vimc_cap_try_fmt_vid_cap(struct file *file, void *priv,
 
        vimc_colorimetry_clamp(format);
 
+       if (format->colorspace == V4L2_COLORSPACE_DEFAULT)
+               format->colorspace = fmt_default.colorspace;
+
        return 0;
 }
 
index d10aee9f84c4459f0510b7e162e7935c1c92df07..c4765ebaeec28e3d896e04d4c94a9f9b6b6ec735 100644 (file)
@@ -48,7 +48,7 @@ static const struct v4l2_mbus_framefmt sink_fmt_default = {
        .height = 480,
        .code = MEDIA_BUS_FMT_SRGGB8_1X8,
        .field = V4L2_FIELD_NONE,
-       .colorspace = V4L2_COLORSPACE_DEFAULT,
+       .colorspace = V4L2_COLORSPACE_SRGB,
 };
 
 static const struct vimc_deb_pix_map vimc_deb_pix_map_list[] = {
index 465b906b749771c844daf4f26959fb220468f614..2231e72b24e2e3c9ee404dba33adf145639ca4f5 100644 (file)
@@ -42,7 +42,7 @@ static const struct v4l2_mbus_framefmt sink_fmt_default = {
        .height = VIMC_SCA_FMT_HEIGHT_DEFAULT,
        .code = MEDIA_BUS_FMT_RGB888_1X24,
        .field = V4L2_FIELD_NONE,
-       .colorspace = V4L2_COLORSPACE_DEFAULT,
+       .colorspace = V4L2_COLORSPACE_SRGB,
 };
 
 static const struct v4l2_rect crop_rect_default = {
index 228120b3a6ddca0141134d3c6a4f4a1f05d63768..56e8ec14be464ca81216e2f9b1ea77fe9df47e2e 100644 (file)
@@ -30,7 +30,7 @@ static const struct v4l2_mbus_framefmt fmt_default = {
        .height = 480,
        .code = MEDIA_BUS_FMT_RGB888_1X24,
        .field = V4L2_FIELD_NONE,
-       .colorspace = V4L2_COLORSPACE_DEFAULT,
+       .colorspace = V4L2_COLORSPACE_SRGB,
 };
 
 static int vimc_sen_init_cfg(struct v4l2_subdev *sd,