From 5d03a62934d2948de2cc653d5b54f2ef19098468 Mon Sep 17 00:00:00 2001 From: David Plowman Date: Thu, 21 Oct 2021 14:41:55 +0100 Subject: [PATCH 1/7] media: i2c: imx219: Sensor should report RAW color space Tested on Raspberry Pi running libcamera. Signed-off-by: David Plowman --- drivers/media/i2c/imx219.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/media/i2c/imx219.c b/drivers/media/i2c/imx219.c index 79faa8cce94eac..6aed851865ecbf 100644 --- a/drivers/media/i2c/imx219.c +++ b/drivers/media/i2c/imx219.c @@ -681,7 +681,7 @@ static void imx219_set_default_format(struct imx219 *imx219) fmt = &imx219->fmt; fmt->code = MEDIA_BUS_FMT_SRGGB10_1X10; - fmt->colorspace = V4L2_COLORSPACE_SRGB; + fmt->colorspace = V4L2_COLORSPACE_RAW; fmt->ycbcr_enc = V4L2_MAP_YCBCR_ENC_DEFAULT(fmt->colorspace); fmt->quantization = V4L2_MAP_QUANTIZATION_DEFAULT(true, fmt->colorspace, @@ -877,7 +877,7 @@ static int imx219_enum_frame_size(struct v4l2_subdev *sd, static void imx219_reset_colorspace(struct v4l2_mbus_framefmt *fmt) { - fmt->colorspace = V4L2_COLORSPACE_SRGB; + fmt->colorspace = V4L2_COLORSPACE_RAW; fmt->ycbcr_enc = V4L2_MAP_YCBCR_ENC_DEFAULT(fmt->colorspace); fmt->quantization = V4L2_MAP_QUANTIZATION_DEFAULT(true, fmt->colorspace, From d617faec88172e66b1db11eb81ca34e1a39df5bb Mon Sep 17 00:00:00 2001 From: David Plowman Date: Thu, 21 Oct 2021 14:44:01 +0100 Subject: [PATCH 2/7] media: i2c: imx290: Sensor should report RAW color space Tested on Raspberry Pi running libcamera. Signed-off-by: David Plowman --- drivers/media/i2c/imx290.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/media/i2c/imx290.c b/drivers/media/i2c/imx290.c index a26106c41cc679..def912308daa4e 100644 --- a/drivers/media/i2c/imx290.c +++ b/drivers/media/i2c/imx290.c @@ -885,7 +885,7 @@ static int imx290_set_fmt(struct v4l2_subdev *sd, fmt->format.code = imx290->formats[i].code; fmt->format.field = V4L2_FIELD_NONE; - fmt->format.colorspace = V4L2_COLORSPACE_SRGB; + fmt->format.colorspace = V4L2_COLORSPACE_RAW; fmt->format.ycbcr_enc = V4L2_MAP_YCBCR_ENC_DEFAULT(fmt->format.colorspace); fmt->format.quantization = From bed146dc5f3811ee7976666d9a86d7d4f7435d3f Mon Sep 17 00:00:00 2001 From: David Plowman Date: Thu, 21 Oct 2021 14:44:43 +0100 Subject: [PATCH 3/7] media: i2c: imx477: Sensor should report RAW color space Tested on Raspberry Pi running libcamera. Signed-off-by: David Plowman --- drivers/media/i2c/imx477.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/media/i2c/imx477.c b/drivers/media/i2c/imx477.c index 05cb530d331eb3..cd3296f8ab41ff 100644 --- a/drivers/media/i2c/imx477.c +++ b/drivers/media/i2c/imx477.c @@ -1471,7 +1471,7 @@ static int imx477_enum_frame_size(struct v4l2_subdev *sd, static void imx477_reset_colorspace(struct v4l2_mbus_framefmt *fmt) { - fmt->colorspace = V4L2_COLORSPACE_SRGB; + fmt->colorspace = V4L2_COLORSPACE_RAW; fmt->ycbcr_enc = V4L2_MAP_YCBCR_ENC_DEFAULT(fmt->colorspace); fmt->quantization = V4L2_MAP_QUANTIZATION_DEFAULT(true, fmt->colorspace, From c41e2c2b32a8530b33dc4752be0dc33994af1739 Mon Sep 17 00:00:00 2001 From: David Plowman Date: Thu, 21 Oct 2021 14:45:07 +0100 Subject: [PATCH 4/7] media: i2c: imx519: Sensor should report RAW color space Tested on Raspberry Pi running libcamera. Signed-off-by: David Plowman --- drivers/media/i2c/imx519.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/media/i2c/imx519.c b/drivers/media/i2c/imx519.c index 4e98704a683418..675b4a94e0655a 100644 --- a/drivers/media/i2c/imx519.c +++ b/drivers/media/i2c/imx519.c @@ -1317,7 +1317,7 @@ static int imx519_enum_frame_size(struct v4l2_subdev *sd, static void imx519_reset_colorspace(struct v4l2_mbus_framefmt *fmt) { - fmt->colorspace = V4L2_COLORSPACE_SRGB; + fmt->colorspace = V4L2_COLORSPACE_RAW; fmt->ycbcr_enc = V4L2_MAP_YCBCR_ENC_DEFAULT(fmt->colorspace); fmt->quantization = V4L2_MAP_QUANTIZATION_DEFAULT(true, fmt->colorspace, From 9d05193b4ffeb3e18343cb6ab10067a6ee5d8a81 Mon Sep 17 00:00:00 2001 From: David Plowman Date: Thu, 21 Oct 2021 14:47:00 +0100 Subject: [PATCH 5/7] media: i2c: ov5647: Sensor should report RAW color space Tested on Raspberry Pi running libcamera. Signed-off-by: David Plowman --- drivers/media/i2c/ov5647.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/drivers/media/i2c/ov5647.c b/drivers/media/i2c/ov5647.c index 98a5329d68fbb1..03c92e419806c9 100644 --- a/drivers/media/i2c/ov5647.c +++ b/drivers/media/i2c/ov5647.c @@ -601,7 +601,7 @@ static struct ov5647_mode supported_modes_8bit[] = { { .format = { .code = MEDIA_BUS_FMT_SBGGR8_1X8, - .colorspace = V4L2_COLORSPACE_SRGB, + .colorspace = V4L2_COLORSPACE_RAW, .field = V4L2_FIELD_NONE, .width = 640, .height = 480 @@ -627,7 +627,7 @@ static struct ov5647_mode supported_modes_10bit[] = { { .format = { .code = MEDIA_BUS_FMT_SBGGR10_1X10, - .colorspace = V4L2_COLORSPACE_SRGB, + .colorspace = V4L2_COLORSPACE_RAW, .field = V4L2_FIELD_NONE, .width = 2592, .height = 1944 @@ -651,7 +651,7 @@ static struct ov5647_mode supported_modes_10bit[] = { { .format = { .code = MEDIA_BUS_FMT_SBGGR10_1X10, - .colorspace = V4L2_COLORSPACE_SRGB, + .colorspace = V4L2_COLORSPACE_RAW, .field = V4L2_FIELD_NONE, .width = 1920, .height = 1080 @@ -674,7 +674,7 @@ static struct ov5647_mode supported_modes_10bit[] = { { .format = { .code = MEDIA_BUS_FMT_SBGGR10_1X10, - .colorspace = V4L2_COLORSPACE_SRGB, + .colorspace = V4L2_COLORSPACE_RAW, .field = V4L2_FIELD_NONE, .width = 1296, .height = 972 @@ -698,7 +698,7 @@ static struct ov5647_mode supported_modes_10bit[] = { { .format = { .code = MEDIA_BUS_FMT_SBGGR10_1X10, - .colorspace = V4L2_COLORSPACE_SRGB, + .colorspace = V4L2_COLORSPACE_RAW, .field = V4L2_FIELD_NONE, .width = 640, .height = 480 From 2f82ec9017323834d587f32e5a1857540cf8a0da Mon Sep 17 00:00:00 2001 From: David Plowman Date: Thu, 21 Oct 2021 14:47:20 +0100 Subject: [PATCH 6/7] media: i2c: ov9281: Sensor should report RAW color space Tested on Raspberry Pi running libcamera. Signed-off-by: David Plowman --- drivers/media/i2c/ov9281.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/media/i2c/ov9281.c b/drivers/media/i2c/ov9281.c index a6ffcdd47b215b..f7ec4470d3566a 100644 --- a/drivers/media/i2c/ov9281.c +++ b/drivers/media/i2c/ov9281.c @@ -507,7 +507,7 @@ static int ov9281_set_fmt(struct v4l2_subdev *sd, fmt->format.width = mode->width; fmt->format.height = mode->height; fmt->format.field = V4L2_FIELD_NONE; - fmt->format.colorspace = V4L2_COLORSPACE_SRGB; + fmt->format.colorspace = V4L2_COLORSPACE_RAW; fmt->format.ycbcr_enc = V4L2_MAP_YCBCR_ENC_DEFAULT(fmt->format.colorspace); fmt->format.quantization = @@ -557,7 +557,7 @@ static int ov9281_get_fmt(struct v4l2_subdev *sd, fmt->format.height = mode->height; fmt->format.code = ov9281->code; fmt->format.field = V4L2_FIELD_NONE; - fmt->format.colorspace = V4L2_COLORSPACE_SRGB; + fmt->format.colorspace = V4L2_COLORSPACE_RAW; fmt->format.ycbcr_enc = V4L2_MAP_YCBCR_ENC_DEFAULT(fmt->format.colorspace); fmt->format.quantization = @@ -908,7 +908,7 @@ static int ov9281_open(struct v4l2_subdev *sd, struct v4l2_subdev_fh *fh) try_fmt->height = def_mode->height; try_fmt->code = MEDIA_BUS_FMT_Y10_1X10; try_fmt->field = V4L2_FIELD_NONE; - try_fmt->colorspace = V4L2_COLORSPACE_SRGB; + try_fmt->colorspace = V4L2_COLORSPACE_RAW; try_fmt->ycbcr_enc = V4L2_MAP_YCBCR_ENC_DEFAULT(try_fmt->colorspace); try_fmt->quantization = V4L2_MAP_QUANTIZATION_DEFAULT(true, try_fmt->colorspace, From 705febaf76dbec0c898d6d1d0940d22c03940517 Mon Sep 17 00:00:00 2001 From: David Plowman Date: Thu, 21 Oct 2021 14:49:15 +0100 Subject: [PATCH 7/7] vc04_services: isp: Report input node as wanting full range RAW color space RAW color spaces are more usually reported as having full range quantization. Tested using libcamera. Signed-off-by: David Plowman --- drivers/staging/vc04_services/bcm2835-isp/bcm2835-v4l2-isp.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/drivers/staging/vc04_services/bcm2835-isp/bcm2835-v4l2-isp.c b/drivers/staging/vc04_services/bcm2835-isp/bcm2835-v4l2-isp.c index 08dce8bba9bb04..df57c2f74a03dd 100644 --- a/drivers/staging/vc04_services/bcm2835-isp/bcm2835-v4l2-isp.c +++ b/drivers/staging/vc04_services/bcm2835-isp/bcm2835-v4l2-isp.c @@ -1032,7 +1032,9 @@ static int bcm2835_isp_node_try_fmt(struct file *file, void *priv, /* In all cases, we only support the defaults for these: */ f->fmt.pix.ycbcr_enc = V4L2_MAP_YCBCR_ENC_DEFAULT(f->fmt.pix.colorspace); f->fmt.pix.xfer_func = V4L2_MAP_XFER_FUNC_DEFAULT(f->fmt.pix.colorspace); - is_rgb = f->fmt.pix.colorspace == V4L2_COLORSPACE_SRGB; + /* RAW counts as sRGB here so that we get full range. */ + is_rgb = f->fmt.pix.colorspace == V4L2_COLORSPACE_SRGB || + f->fmt.pix.colorspace == V4L2_COLORSPACE_RAW; f->fmt.pix.quantization = V4L2_MAP_QUANTIZATION_DEFAULT(is_rgb, f->fmt.pix.colorspace, f->fmt.pix.ycbcr_enc);