Confirmed support for RAW12 through 4-lane CSI-2 sensor on i.MX8M?

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Confirmed support for RAW12 through 4-lane CSI-2 sensor on i.MX8M?

7,562 Views
phahn
Contributor II

I've found a few forum posts describing attempts to bring up support for RAW12 on a 4-lane CSI2 sensor, has anyone had success in receiving 12-bit RAW data through 4-lane CSI2 sensor?

Comment regarding inability to bring up RAW12 in 4-lane configuration on i.MX8M : iMX8M MIPI-CSI 4-lane configuration  

Comment regarding lack of support for RAW12 on i.MX7D https://community.nxp.com/thread/474668#comment-1081971 

Comment regarding difficulty bringing up RAW12 on i.MX6D Mipi Csi-2: Capturing RAW12 Data correctly into Memory 

Comment showing some success in getting RAW12 working on i.MX6 i.MX6Q MIPI CSI2: Capturing RAW12 generic data 

Labels (1)
Tags (1)
8 Replies

4,972 Views
james_kim
Contributor II

This was one of the best tip from this forum. I have been able to receive RAW10/12/14 data.

Thanks

James

0 Kudos

4,972 Views
joanxie
NXP TechSupport
NXP TechSupport

MIPI CSI couldn't support raw data directly, you need to convert the raw data to RGB or YUV by SW, what bayer data you need? we don't have such sample code or guide for cutomer, but you can set the CSI register, for more detailed information, pls refer to the Reference Manual.

4,972 Views
phahn
Contributor II

I process bayer data using a separate SW pipeline.  My goal is only to capture and save 12-bit bayer data using i.MX8M.  There are forum posts confirming support for receiving 10-bit bayer but it seems so far no one has confirmed success with receiving 12-bit bayer through 4-lane CSI sensor on i.MX8M (referred to as RAW12 in Reference Manual).  My main concern is this post here : https://community.nxp.com/thread/498568 in which the user was unable to successfully receive 12-bit data in a 2- or 4-lane CSI configuration. 

Could you confirm that RAW12 format is indeed supported in the latest i.MX8M firmware release for a 4-lane CSI sensor, and that the following source code changes are all that is required (based on 4.14.98_2.0.0 linux release):

diff --git a/drivers/media/platform/mxc/capture/mx6s_capture.c b/drivers/media/platform/mxc/capture/mx6s_capture.c

index 9cfdbdc..99534ae 100644

--- a/drivers/media/platform/mxc/capture/mx6s_capture.c

+++ b/drivers/media/platform/mxc/capture/mx6s_capture.c

@@ -138,6 +138,7 @@

#define BIT_CSI_ENABLE                 (0x1 << 31)

#define BIT_MIPI_DATA_FORMAT_RAW8              (0x2a << 25)

#define BIT_MIPI_DATA_FORMAT_RAW10             (0x2b << 25)

+#define BIT_MIPI_DATA_FORMAT_RAW12             (0x2c << 25)

#define BIT_MIPI_DATA_FORMAT_YUV422_8B (0x1e << 25)

#define BIT_MIPI_DATA_FORMAT_MASK      (0x3F << 25)

#define BIT_MIPI_DATA_FORMAT_OFFSET    25

@@ -279,6 +280,18 @@ static struct mx6s_fmt formats[] = {

                .pixelformat    = V4L2_PIX_FMT_SBGGR8,

                .mbus_code      = MEDIA_BUS_FMT_SBGGR8_1X8,

                .bpp            = 1,

+       }, {

+               .name           = "RAWRGB10 (SRGGB10)",

+               .fourcc         = V4L2_PIX_FMT_SRGGB10,

+               .pixelformat    = V4L2_PIX_FMT_SRGGB10,

+               .mbus_code      = MEDIA_BUS_FMT_SRGGB10_1X10,

+               .bpp            = 2,

+       }, {

+               .name           = "RAWRGB12 (SRGGB12)",

+               .fourcc         = V4L2_PIX_FMT_SRGGB12,

+               .pixelformat    = V4L2_PIX_FMT_SRGGB12,

+               .mbus_code      = MEDIA_BUS_FMT_SRGGB12_1X12,

+               .bpp            = 2,

        }

};

@@ -861,6 +874,10 @@ static int mx6s_configure_csi(struct mx6s_csi_dev *csi_dev)

                        /* For parallel 8-bit sensor input */

                        width = pix->width * 2;

                break;

+       case V4L2_PIX_FMT_SRGGB10:

+       case V4L2_PIX_FMT_SRGGB12:

+        width = pix->width * 2;

+        break;

        default:

                pr_debug("   case not supported\n");

                return -EINVAL;

@@ -885,6 +902,12 @@ static int mx6s_configure_csi(struct mx6s_csi_dev *csi_dev)

                case V4L2_PIX_FMT_SBGGR8:

                        cr18 |= BIT_MIPI_DATA_FORMAT_RAW8;

                        break;

+        case V4L2_PIX_FMT_SRGGB10:

+            cr18 |= BIT_MIPI_DATA_FORMAT_RAW10;

+            break;

+        case V4L2_PIX_FMT_SRGGB12:

+            cr18 |= BIT_MIPI_DATA_FORMAT_RAW12;

+            break;

                default:

                        pr_debug("   fmt not supported\n");

                        return -EINVAL;

Thank you for your time

0 Kudos

4,972 Views
t_spil
Contributor III

I got RAW12 working using this (with width = pix->width) plus enabling the fsl,two-8bit-sensor-mode in the device tree. Two 8 bit sensor mode is an awkward name for something that enables 16 bit data, which you need for RAW12. You'll get out 16 bit data padded with 4 zeroes.

4,972 Views
joanxie
NXP TechSupport
NXP TechSupport

i.mx8M can support it, pls refer to the source code as below:

+  .name  = "RAWRGB12 (SGRBG12)",
+  .fourcc  = V4L2_PIX_FMT_SGRBG12,
+  .pixelformat = V4L2_PIX_FMT_SGRBG12,
+  .mbus_code = MEDIA_BUS_FMT_SRGGB12_1X12,
+  .bpp  = 1,

 switch (csi_dev->fmt->pixelformat) {
  case V4L2_PIX_FMT_YUV32:
  case V4L2_PIX_FMT_SBGGR8:
+ case V4L2_PIX_FMT_SGRBG12:
   width = pix->width;
   break;

0 Kudos

4,972 Views
felix_ye
Contributor II

Hi Joan,

Could you please tell me if "bpp" means "bytes per pixel" in this data structure?

    struct mx6s_fmt {
        char name[32];
        u32 fourcc; /* v4l2 format id */
        u32 pixelformat;
        u32 mbus_code;
        int bpp;

    };

In the CSI driver mx6s_capture.c, "bpp" is used to calculate size of image:

    pix->sizeimage = fmt->bpp * pix->height * pix->width;

And if "bpp" means bytes per pixel, then doesn't RAWRGB12 use 2 bytes to represent a pixel ?

Why "bpp  = 1" in the code you had showed?

Hope for your reply.

Thanks

0 Kudos

4,974 Views
phahn
Contributor II

based on testing I've done I found it was necessary to set

+  .bpp  = 1,

otherwise v4l2 will not output the expected image size, which makes sense given that we are expecting a 16bpp image at the output for RAW10 and RAW12 format. 

The note about setting 

width = pix->width;

seems to be correct based on i.MX8M Reference Manual but didn't make a difference in my output

0 Kudos

4,974 Views
joanxie
NXP TechSupport
NXP TechSupport

do you mean that whatever patch you use, you still get the same wrong video?

0 Kudos