Skip to contentSkip to conversation

media: i2c: imx258: correct mode to GBGB/RGRG

PATCH In review Krzysztof Kozlowski 2 participants 7 messages Oct 28, 2020 – Oct 30, 2020 3 messages not in the archive

Subsystems (4)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 media: i2c: imx258: correct mode to GBGB/RGRG

The IMX258 sensor outputs pixels in GBGB/RGRG mode. This is described explicitly in datasheet and was actually mentioned in a comment inside the driver. Using other - wrong mode - leads to pinkish pictures.

Fixes e4802cb00bfe ("media: imx258: Add imx258 camera sensor driver")
---
 drivers/media/i2c/imx258.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)
drivers/media/i2c/imx258.c +5 -5
index ef069333a969..bf75d4e597af 100644
@@ -715,7 +715,7 @@ static int imx258_open(struct v4l2_subdev *sd, struct v4l2_subdev_fh *fh)
 	/* Initialize try_fmt */
 	try_fmt->width = supported_modes[0].width;
 	try_fmt->height = supported_modes[0].height;
-	try_fmt->code = MEDIA_BUS_FMT_SGRBG10_1X10;
+	try_fmt->code = MEDIA_BUS_FMT_SGBRG10_1X10;
 	try_fmt->field = V4L2_FIELD_NONE;
 
 	return 0;
@@ -827,7 +827,7 @@ static int imx258_enum_mbus_code(struct v4l2_subdev *sd,
 	if (code->index > 0)
 		return -EINVAL;
 
-	code->code = MEDIA_BUS_FMT_SGRBG10_1X10;
+	code->code = MEDIA_BUS_FMT_SGBRG10_1X10;
 
 	return 0;
 }
@@ -839,7 +839,7 @@ static int imx258_enum_frame_size(struct v4l2_subdev *sd,
 	if (fse->index >= ARRAY_SIZE(supported_modes))
 		return -EINVAL;
 
-	if (fse->code != MEDIA_BUS_FMT_SGRBG10_1X10)
+	if (fse->code != MEDIA_BUS_FMT_SGBRG10_1X10)
 		return -EINVAL;
 
 	fse->min_width = supported_modes[fse->index].width;
@@ -855,7 +855,7 @@ static void imx258_update_pad_format(const struct imx258_mode *mode,
 {
 	fmt->format.width = mode->width;
 	fmt->format.height = mode->height;
-	fmt->format.code = MEDIA_BUS_FMT_SGRBG10_1X10;
+	fmt->format.code = MEDIA_BUS_FMT_SGBRG10_1X10;
 	fmt->format.field = V4L2_FIELD_NONE;
 }
 
@@ -902,7 +902,7 @@ static int imx258_set_pad_format(struct v4l2_subdev *sd,
 	mutex_lock(&imx258->mutex);
 
 	/* Only one raw bayer(GBRG) order is supported */
-	fmt->format.code = MEDIA_BUS_FMT_SGRBG10_1X10;
+	fmt->format.code = MEDIA_BUS_FMT_SGBRG10_1X10;
 
 	mode = v4l2_find_nearest_size(supported_modes,
 		ARRAY_SIZE(supported_modes), width, height,
Signature · 1 line
2.25.1
#5 lore raw
In reply to a message not in the archive
Quoted 21 lines · Sakari Ailus
Quoted 14 lines · Krzysztof Kozlowski
Quoted 5 lines · Krzysztof Kozlowski
Quoted 3 lines · Andy

But the sensor settings for the original submission is to output GRBG Bayer RAW.

Quoted 7 lines
Quoted 1 line

Regards, Andy

No, not to my knowledge. There are no settings for color output because it is fixed to GBGB/RGRG. I was looking a lot into this driver (I have few other problems with it, already few other patches posted) and I could not find a setting for this in datasheet. If you know the setting for the other color - can you point me to it?

Quoted 4 lines

And except the datasheet which mentions the specific format, the testing confirms it. With original color the pictures are pink/purple. With proper color, the pictures are correct (with more green color as expected for bayer).

Quoted 5 lines

Quoting the driver's start_streaming function:

        /* Set Orientation be 180 degree */
        ret = imx258_write_reg(imx258, REG_MIRROR_FLIP_CONTROL,
                               IMX258_REG_VALUE_08BIT, REG_CONFIG_MIRROR_FLIP);

I understand that you think it will replace the lines and columns and the first line will be RG, instead of GB.... or actually BG because it flips horizontal and vertical? So why does it not work?

BTW, this nicely points that the comment around device_property_read_u32() for rotation is a little bit misleading :)

Quoted 7 lines
        if (ret) {
                dev_err(&client->dev, "%s failed to set orientation\n",
                        __func__);
                return ret;
        }

Could it be you're taking pictures of pink objects? ;-)

I can send a few sample pictures taken with GStreamer (RAW8, not original RAW10)...

Best regards,
Krzysztof

#6 lore raw
Quoted 25 lines · Krzysztof Kozlowski
Quoted 23 lines · Sakari Ailus
Quoted 14 lines · Krzysztof Kozlowski
Quoted 5 lines · Krzysztof Kozlowski
Quoted 3 lines · Andy

But the sensor settings for the original submission is to output GRBG Bayer RAW.

Quoted 7 lines
Quoted 1 line

Regards, Andy

No, not to my knowledge. There are no settings for color output because it is fixed to GBGB/RGRG. I was looking a lot into this driver (I have few other problems with it, already few other patches posted) and I could not find a setting for this in datasheet. If you know the setting for the other color - can you point me to it?

Quoted 4 lines

And except the datasheet which mentions the specific format, the testing confirms it. With original color the pictures are pink/purple. With proper color, the pictures are correct (with more green color as expected for bayer).

Quoting the driver's start_streaming function:

Quoted 7 lines
Quoted 3 lines
        /* Set Orientation be 180 degree */
        ret = imx258_write_reg(imx258, REG_MIRROR_FLIP_CONTROL,
                               IMX258_REG_VALUE_08BIT, REG_CONFIG_MIRROR_FLIP);

I understand that you think it will replace the lines and columns and the first line will be RG, instead of GB.... or actually BG because it flips horizontal and vertical? So why does it not work?

Any chance your SoC capture interface performs this flipping on its own as well?

Quoted 4 lines

BTW, this nicely points that the comment around device_property_read_u32() for rotation is a little bit misleading :)

Are you referring to the comment below?

/*
* Check that the device is mounted upside down. The driver only
* supports a single pixel order right now.
*/
ret = device_property_read_u32(&client->dev, "rotation", &val); if (ret || val != 180)

    return -EINVAL;

What's misleading about it?

Quoted 13 lines
Quoted 7 lines
        if (ret) {
                dev_err(&client->dev, "%s failed to set orientation\n",
                        __func__);
                return ret;
        }

Could it be you're taking pictures of pink objects? ;-)

I can send a few sample pictures taken with GStreamer (RAW8, not original RAW10)...

Best regards,
Krzysztof

#2 lore raw
In reply to a message not in the archive
Quoted 4 lines · Andy

But the sensor settings for the original submission is to output GRBG Bayer RAW.

Regards, Andy

No, not to my knowledge. There are no settings for color output because it is fixed to GBGB/RGRG. I was looking a lot into this driver (I have few other problems with it, already few other patches posted) and I could not find a setting for this in datasheet. If you know the setting for the other color - can you point me to it?

Best regards,
Krzysztof

Quoted 78 lines
Quoted 77 lines

-----Original Message-----
From: Krzysztof Kozlowski <[email protected]>
Sent: Wednesday, October 28, 2020 5:20 PM
To: Sakari Ailus <[email protected]>; Mauro Carvalho Chehab <[email protected]>; Tomasz Figa <[email protected]>; Jason Chen <[email protected]>; Yeh, Andy <[email protected]>; Alan Chiang <[email protected]>; [email protected]; linux- [email protected]
Cc: Krzysztof Kozlowski <[email protected]>; [email protected]
Subject: [PATCH] media: i2c: imx258: correct mode to GBGB/RGRG

The IMX258 sensor outputs pixels in GBGB/RGRG mode. This is described explicitly in datasheet and was actually mentioned in a comment inside the driver. Using other - wrong mode - leads to pinkish pictures.

Fixes e4802cb00bfe ("media: imx258: Add imx258 camera sensor driver")

---
drivers/media/i2c/imx258.c | 10 +++++-----

1 file changed, 5 insertions(+), 5 deletions(-)
drivers/media/i2c/imx258.c index renamed from drivers/media/i2c/imx258.c +0 -0

ef069333a969..bf75d4e597af 100644

drivers/media/i2c/imx258.c +1 -1
@@ -715,7 +715,7 @@ static int imx258_open(struct v4l2_subdev *sd, struct
 v4l2_subdev_fh *fh)
      /* Initialize try_fmt */
      try_fmt->width = supported_modes[0].width;
      try_fmt->height = supported_modes[0].height;
-      try_fmt->code = MEDIA_BUS_FMT_SGRBG10_1X10;
+      try_fmt->code = MEDIA_BUS_FMT_SGBRG10_1X10;
      try_fmt->field = V4L2_FIELD_NONE;
 
      return 0;
drivers/media/i2c/imx258.c +1 -1
@@ -827,7 +827,7 @@ static int imx258_enum_mbus_code(struct
 v4l2_subdev *sd,
      if (code->index > 0)
              return -EINVAL;
 
-      code->code = MEDIA_BUS_FMT_SGRBG10_1X10;
+      code->code = MEDIA_BUS_FMT_SGBRG10_1X10;
 
      return 0;

}

drivers/media/i2c/imx258.c +1 -1
@@ -839,7 +839,7 @@ static int imx258_enum_frame_size(struct
 v4l2_subdev *sd,
      if (fse->index >= ARRAY_SIZE(supported_modes))
              return -EINVAL;
 
-      if (fse->code != MEDIA_BUS_FMT_SGRBG10_1X10)
+      if (fse->code != MEDIA_BUS_FMT_SGBRG10_1X10)
              return -EINVAL;
 
      fse->min_width = supported_modes[fse->index].width;
drivers/media/i2c/imx258.c +2 -2
@@ -855,7 +855,7 @@ static void imx258_update_pad_format(const struct
 imx258_mode *mode,  {
      fmt->format.width = mode->width;
      fmt->format.height = mode->height;
-      fmt->format.code = MEDIA_BUS_FMT_SGRBG10_1X10;
+      fmt->format.code = MEDIA_BUS_FMT_SGBRG10_1X10;
      fmt->format.field = V4L2_FIELD_NONE;
 }
 
@@ -902,7 +902,7 @@ static int imx258_set_pad_format(struct v4l2_subdev
 *sd,
      mutex_lock(&imx258->mutex);
 
      /* Only one raw bayer(GBRG) order is supported */
-      fmt->format.code = MEDIA_BUS_FMT_SGRBG10_1X10;
+      fmt->format.code = MEDIA_BUS_FMT_SGBRG10_1X10;
 
      mode = v4l2_find_nearest_size(supported_modes,

ARRAY_SIZE(supported_modes), width, height,
--
2.25.1

#3 lore raw
Quoted 5 lines · Krzysztof Kozlowski
Quoted 3 lines · Andy

But the sensor settings for the original submission is to output GRBG Bayer RAW.

Quoted 7 lines
Quoted 1 line

Regards, Andy

No, not to my knowledge. There are no settings for color output because it is fixed to GBGB/RGRG. I was looking a lot into this driver (I have few other problems with it, already few other patches posted) and I could not find a setting for this in datasheet. If you know the setting for the other color - can you point me to it?

And except the datasheet which mentions the specific format, the testing confirms it. With original color the pictures are pink/purple. With proper color, the pictures are correct (with more green color as expected for bayer).

Best regards,
Krzysztof

#9 lore raw
In reply to a message not in the archive
Quoted 44 lines · Andy
Quoted 44 lines

-----Original Message-----
From: Sakari Ailus <[email protected]>
Sent: Wednesday, October 28, 2020 6:03 PM
To: Krzysztof Kozlowski <[email protected]>
Cc: Yeh, Andy <[email protected]>; Mauro Carvalho Chehab <[email protected]>; Tomasz Figa <[email protected]>; Jason Chen <[email protected]>; Alan Chiang <[email protected]>; linux- [email protected]; [email protected]; [email protected]
Subject: Re: [PATCH] media: i2c: imx258: correct mode to GBGB/RGRG

Quoted 1 line · Krzysztof Kozlowski

On Wed, 28 Oct 2020 at 10:45, Krzysztof Kozlowski <[email protected]>

Quoted 4 lines · wrote:
Quoted 4 lines · Andy
Quoted 2 lines

But the sensor settings for the original submission is to output GRBG

Bayer RAW.

Quoted 9 lines
Quoted 8 lines
Quoted 2 lines

Regards, Andy

No, not to my knowledge. There are no settings for color output because it is fixed to GBGB/RGRG. I was looking a lot into this driver (I have few other problems with it, already few other patches posted) and I could not find a setting for this in datasheet. If you know the setting for the other color - can you point me to it?

Quoted 4 lines

And except the datasheet which mentions the specific format, the testing confirms it. With original color the pictures are pink/purple. With proper color, the pictures are correct (with more green color as expected for bayer).

Quoting the driver's start_streaming function:

       /* Set Orientation be 180 degree */
       ret = imx258_write_reg(imx258, REG_MIRROR_FLIP_CONTROL,
                              IMX258_REG_VALUE_08BIT, REG_CONFIG_MIRROR_FLIP);
       if (ret) {
               dev_err(&client->dev, "%s failed to set orientation\n",
                       __func__);
               return ret;
       }
Quoted 6 lines
Quoted 4 lines

Could it be you're taking pictures of pink objects? ;-)

--
Sakari Ailus

Sakari is right. IIRC since the default sensor settings outputs in GBRG, and after mirro/flip (it is the original application when submit the driver) the bayer order will be GRBG.

Yes, you are all right. It seems I was using wrong color mode for Gstreamer, or I messed up something more.

Thanks for help everyone!

The patch can be dropped.

Best regards,
Krzysztof

#7 lore raw
In reply to Tomasz Figa
Quoted 30 lines · Tomasz Figa
Quoted 29 lines · Krzysztof Kozlowski
Quoted 26 lines · Sakari Ailus
Quoted 14 lines · Krzysztof Kozlowski
Quoted 5 lines · Krzysztof Kozlowski
Quoted 3 lines · Andy

But the sensor settings for the original submission is to output GRBG Bayer RAW.

Quoted 7 lines
Quoted 1 line

Regards, Andy

No, not to my knowledge. There are no settings for color output because it is fixed to GBGB/RGRG. I was looking a lot into this driver (I have few other problems with it, already few other patches posted) and I could not find a setting for this in datasheet. If you know the setting for the other color - can you point me to it?

Quoted 4 lines

And except the datasheet which mentions the specific format, the testing confirms it. With original color the pictures are pink/purple. With proper color, the pictures are correct (with more green color as expected for bayer).

Quoting the driver's start_streaming function:

        /* Set Orientation be 180 degree */
        ret = imx258_write_reg(imx258, REG_MIRROR_FLIP_CONTROL,
                               IMX258_REG_VALUE_08BIT, REG_CONFIG_MIRROR_FLIP);
Quoted 5 lines
Quoted 3 lines

I understand that you think it will replace the lines and columns and the first line will be RG, instead of GB.... or actually BG because it flips horizontal and vertical? So why does it not work?

Any chance your SoC capture interface performs this flipping on its own as well?

I messed up GStreamer as well. The color mode is correct in the driver.

Quoted 14 lines
Quoted 5 lines

BTW, this nicely points that the comment around device_property_read_u32() for rotation is a little bit misleading :)

Are you referring to the comment below?

/*
* Check that the device is mounted upside down. The driver only
* supports a single pixel order right now.
*/
ret = device_property_read_u32(&client->dev, "rotation", &val); if (ret || val != 180)

Quoted 3 lines
    return -EINVAL;

What's misleading about it?

It's interpretation. To me the comment does not say that device *have to* be mounted upside down. To me, it says that from all rotations (90, -90, 180), it supports only upside down, except of course normal mounting (no rotation).

Best regards,
Krzysztof