Skip to contentSkip to conversation

media: imx: utils: Default colorspace to SRGB

PATCH Superseded Steve Longerbeam 2 participants 4 messages Mar 25, 2020 – Apr 17, 2020

Subsystems (4)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore

Steve Longerbeam

author maintainer
#0 lore raw

PATCH 1/1 media: imx: utils: Default colorspace to SRGB

The function init_mbus_colorimetry() is used to initialize the imx subdevice mbus colorimetry to some sane defaults when the subdevice is registered. Currently it guesses at a colorspace based on the passed mbus pixel format. If the format is RGB, it chooses colorspace V4L2_COLORSPACE_SRGB, and if the format is YUV, it chooses V4L2_COLORSPACE_SMPTE170M.

While that might be a good guess, it's not necessarily true that a RGB pixel format encoding uses a SRGB colorspace, or that a YUV encoding uses a SMPTE170M colorspace. Instead of making this dubious guess, just default the colorspace to SRGB.

---
 drivers/staging/media/imx/imx-media-utils.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/staging/media/imx/imx-media-utils.c +1 -2
index fae981698c49..8344675bfd05 100644
@@ -236,8 +236,7 @@ static const struct imx_media_pixfmt ipu_rgb_formats[] = {
 static void init_mbus_colorimetry(struct v4l2_mbus_framefmt *mbus,
 				  const struct imx_media_pixfmt *fmt)
 {
-	mbus->colorspace = (fmt->cs == IPUV3_COLORSPACE_RGB) ?
-		V4L2_COLORSPACE_SRGB : V4L2_COLORSPACE_SMPTE170M;
+	mbus->colorspace = V4L2_COLORSPACE_SRGB;
 	mbus->xfer_func = V4L2_MAP_XFER_FUNC_DEFAULT(mbus->colorspace);
 	mbus->ycbcr_enc = V4L2_MAP_YCBCR_ENC_DEFAULT(mbus->colorspace);
 	mbus->quantization =
Signature · 1 line
2.17.1
#1 lore raw

Hi Steve,

Quoted 23 lines · Steve Longerbeam

The function init_mbus_colorimetry() is used to initialize the imx subdevice mbus colorimetry to some sane defaults when the subdevice is registered. Currently it guesses at a colorspace based on the passed mbus pixel format. If the format is RGB, it chooses colorspace V4L2_COLORSPACE_SRGB, and if the format is YUV, it chooses V4L2_COLORSPACE_SMPTE170M.

While that might be a good guess, it's not necessarily true that a RGB pixel format encoding uses a SRGB colorspace, or that a YUV encoding uses a SMPTE170M colorspace. Instead of making this dubious guess, just default the colorspace to SRGB.

---
 drivers/staging/media/imx/imx-media-utils.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/staging/media/imx/imx-media-utils.c +0 -0
index fae981698c49..8344675bfd05 100644

drivers/staging/media/imx/imx-media-utils.c static const struct imx_media_pixfmt ipu_rgb_formats[] = { · line 242

Quoted 9 lines
drivers/staging/media/imx/imx-media-utils.c +1 -2
@@ -236,8 +236,7 @@ static const struct imx_media_pixfmt ipu_rgb_formats[] = {
 static void init_mbus_colorimetry(struct v4l2_mbus_framefmt *mbus,
 				  const struct imx_media_pixfmt *fmt)
 {
-	mbus->colorspace = (fmt->cs == IPUV3_COLORSPACE_RGB) ?
-		V4L2_COLORSPACE_SRGB : V4L2_COLORSPACE_SMPTE170M;
+	mbus->colorspace = V4L2_COLORSPACE_SRGB;
 	mbus->xfer_func = V4L2_MAP_XFER_FUNC_DEFAULT(mbus->colorspace);
 	mbus->ycbcr_enc = V4L2_MAP_YCBCR_ENC_DEFAULT(mbus->colorspace);
 	mbus->quantization =

The quantization is probably wrong as well since it checks fmt->cs. The first argument should just be 'true'.

Quoted 1 line

In any case, this patch no longer applies after the imx utils patch series.

Regards,

Hans

author maintainer
#2 lore raw

Hi Hans,

Quoted 21 lines · Hans Verkuil

Hi Steve,

Quoted 18 lines · Steve Longerbeam

The function init_mbus_colorimetry() is used to initialize the imx subdevice mbus colorimetry to some sane defaults when the subdevice is registered. Currently it guesses at a colorspace based on the passed mbus pixel format. If the format is RGB, it chooses colorspace V4L2_COLORSPACE_SRGB, and if the format is YUV, it chooses V4L2_COLORSPACE_SMPTE170M.

While that might be a good guess, it's not necessarily true that a RGB pixel format encoding uses a SRGB colorspace, or that a YUV encoding uses a SMPTE170M colorspace. Instead of making this dubious guess, just default the colorspace to SRGB.

---
  drivers/staging/media/imx/imx-media-utils.c | 3 +--
  1 file changed, 1 insertion(+), 2 deletions(-)
Quoted 16 lines
Quoted 5 lines
drivers/staging/media/imx/imx-media-utils.c +0 -0
index fae981698c49..8344675bfd05 100644

drivers/staging/media/imx/imx-media-utils.c static const struct imx_media_pixfmt ipu_rgb_formats[] = { · line 242

Quoted 9 lines
drivers/staging/media/imx/imx-media-utils.c +1 -2
@@ -236,8 +236,7 @@ static const struct imx_media_pixfmt ipu_rgb_formats[] = {
  static void init_mbus_colorimetry(struct v4l2_mbus_framefmt *mbus,
  				  const struct imx_media_pixfmt *fmt)
  {
-	mbus->colorspace = (fmt->cs == IPUV3_COLORSPACE_RGB) ?
-		V4L2_COLORSPACE_SRGB : V4L2_COLORSPACE_SMPTE170M;
+	mbus->colorspace = V4L2_COLORSPACE_SRGB;
  	mbus->xfer_func = V4L2_MAP_XFER_FUNC_DEFAULT(mbus->colorspace);
  	mbus->ycbcr_enc = V4L2_MAP_YCBCR_ENC_DEFAULT(mbus->colorspace);
  	mbus->quantization =

The quantization is probably wrong as well since it checks fmt->cs. The first argument should just be 'true'.

I don't think so. The default quantization depends in part on whether the pixel format is RGB or YUV, which is the reason for passing boolean (fmt->cs == IPUV3_COLORSPACE_RGB) as the first argument.

I realize "fmt->cs" is a misnomer, but it is borrowing from earlier misnomers, i.e. the 'enum ipu_color_space' enumerations. Fixing those names would touch lots of imx driver code.

Quoted 2 lines

In any case, this patch no longer applies after the imx utils patch series.

Ok, I'll re-submit after the utils patch series is merged.

Steve

#3 lore raw
Quoted 41 lines · Steve Longerbeam

Hi Hans,

Quoted 21 lines · Hans Verkuil

Hi Steve,

Quoted 18 lines · Steve Longerbeam

The function init_mbus_colorimetry() is used to initialize the imx subdevice mbus colorimetry to some sane defaults when the subdevice is registered. Currently it guesses at a colorspace based on the passed mbus pixel format. If the format is RGB, it chooses colorspace V4L2_COLORSPACE_SRGB, and if the format is YUV, it chooses V4L2_COLORSPACE_SMPTE170M.

While that might be a good guess, it's not necessarily true that a RGB pixel format encoding uses a SRGB colorspace, or that a YUV encoding uses a SMPTE170M colorspace. Instead of making this dubious guess, just default the colorspace to SRGB.

---
  drivers/staging/media/imx/imx-media-utils.c | 3 +--
  1 file changed, 1 insertion(+), 2 deletions(-)
Quoted 16 lines
Quoted 5 lines
drivers/staging/media/imx/imx-media-utils.c +0 -0
index fae981698c49..8344675bfd05 100644

drivers/staging/media/imx/imx-media-utils.c static const struct imx_media_pixfmt ipu_rgb_formats[] = { · line 242

Quoted 9 lines
drivers/staging/media/imx/imx-media-utils.c +1 -2
@@ -236,8 +236,7 @@ static const struct imx_media_pixfmt ipu_rgb_formats[] = {
  static void init_mbus_colorimetry(struct v4l2_mbus_framefmt *mbus,
  				  const struct imx_media_pixfmt *fmt)
  {
-	mbus->colorspace = (fmt->cs == IPUV3_COLORSPACE_RGB) ?
-		V4L2_COLORSPACE_SRGB : V4L2_COLORSPACE_SMPTE170M;
+	mbus->colorspace = V4L2_COLORSPACE_SRGB;
  	mbus->xfer_func = V4L2_MAP_XFER_FUNC_DEFAULT(mbus->colorspace);
  	mbus->ycbcr_enc = V4L2_MAP_YCBCR_ENC_DEFAULT(mbus->colorspace);
  	mbus->quantization =

The quantization is probably wrong as well since it checks fmt->cs. The first argument should just be 'true'.

Quoted 3 lines

I don't think so. The default quantization depends in part on whether the pixel format is RGB or YUV, which is the reason for passing boolean (fmt->cs == IPUV3_COLORSPACE_RGB) as the first argument.

Ah yes, that's true. Sorry for the noise.

Regards,

Hans

Quoted 13 lines

I realize "fmt->cs" is a misnomer, but it is borrowing from earlier misnomers, i.e. the 'enum ipu_color_space' enumerations. Fixing those names would touch lots of imx driver code.

Quoted 2 lines

In any case, this patch no longer applies after the imx utils patch series.

Ok, I'll re-submit after the utils patch series is merged.

Steve