AnsweredAssumed Answered

Custom camera driver adaptation on iMX8M Mini

Question asked by Khang Le Truong on Jul 11, 2020
Latest reply on Jul 22, 2020 by Khang Le Truong

Dear experts,

 

I'm in the process of porting a custom camera to iMX8M Mini from its original driver dedicated to Nvidia Jetson platforms.

I've finished the control part via I2C bus. However, I've got following errors from the V4L2 compliance test :

 

# v4l2-compliance -s
[  409.499911] mxc_mipi-csi 32e30000.mipi_csi: format not match
[  409.505648] unknown pixelformat:'    '
[  409.509419] mx6s-csi 32e20000.csi1_bridge: Fourcc format (0x00000000) invalid.
[  409.516674] unknown pixelformat:'����'
[  409.520493] mx6s-csi 32e20000.csi1_bridge: Fourcc format (0xffffffff) invalid.
[  409.527756] unknown pixelformat:'    '
[  409.531517] mx6s-csi 32e20000.csi1_bridge: Fourcc format (0x00000000) invalid.
[  409.538806] unknown pixelformat:'    '
[  409.542568] mx6s-csi 32e20000.csi1_bridge: Fourcc format (0x00000000) invalid.
[  409.549811] unknown pixelformat:'    '
[  409.553574] mx6s-csi 32e20000.csi1_bridge: Fourcc format (0x00000000) invalid.
[  409.560929] mx6s-csi 32e20000.csi1_bridge: dma_alloc_coherent of size 0 failed
[  409.568389] unknown pixelformat:'    '
[  409.572162] mx6s-csi 32e20000.csi1_bridge: Fourcc format (0x00000000) invalid.
[  409.581812]  mcu_stream_config(1839) ISP Status = 0x0000 , Ret code = 0x02
[  409.588794]  ISP is Unintialized or Busy STATUS = 0x0000 Errcode = 0x02 !!
[  409.595780] ov2311 2-004a: ov2311_s_parm: Failed stream_config

 

By digging into the source code of original driver, I found  :

...

struct ecam_ov2311_colorfmt {
    unsigned int            code;
    enum v4l2_colorspace        colorspace;
    int                pix_fmt;
    enum v4l2_xfer_func        xfer_func;
    enum v4l2_ycbcr_encoding    ycbcr_enc;
    enum v4l2_quantization        quantization;
};

 

static const struct ecam_ov2311_colorfmt ecam_ov23111_color_fmts[] = {
    {
        MEDIA_BUS_FMT_SRGGB12_1X12,
        V4L2_COLORSPACE_SRGB,
        V4L2_PIX_FMT_SRGGB12,
    },
    {
        MEDIA_BUS_FMT_SGRBG12_1X12,
        V4L2_COLORSPACE_SRGB,
        V4L2_PIX_FMT_SGRBG12,
    },
    {
        MEDIA_BUS_FMT_SRGGB10_1X10,
        V4L2_COLORSPACE_SRGB,
        V4L2_PIX_FMT_SRGGB10,
    },
    {
        MEDIA_BUS_FMT_SGRBG10_1X10,
        V4L2_COLORSPACE_SRGB,
        V4L2_PIX_FMT_SGRBG10,
    },
    {
        MEDIA_BUS_FMT_SBGGR10_1X10,
        V4L2_COLORSPACE_SRGB,
        V4L2_PIX_FMT_SBGGR10,
    },
    {
        MEDIA_BUS_FMT_SRGGB8_1X8,
        V4L2_COLORSPACE_SRGB,
        V4L2_PIX_FMT_SRGGB8,
    },
    {
        MEDIA_BUS_FMT_YUYV8_1X16,
        V4L2_COLORSPACE_SRGB,
        V4L2_PIX_FMT_YUYV,
    },
    {
        MEDIA_BUS_FMT_YVYU8_1X16,
        V4L2_COLORSPACE_SRGB,
        V4L2_PIX_FMT_YVYU,
    },
    {
        MEDIA_BUS_FMT_UYVY8_1X16,
        V4L2_COLORSPACE_SRGB,
        V4L2_PIX_FMT_UYVY,
    },
    {
        MEDIA_BUS_FMT_VYUY8_1X16,
        V4L2_COLORSPACE_SRGB,
        V4L2_PIX_FMT_VYUY,
    },
    {
        MEDIA_BUS_FMT_YUYV8_2X8,
        V4L2_COLORSPACE_SRGB,
        V4L2_PIX_FMT_YUYV,
    },
    {
        MEDIA_BUS_FMT_YVYU8_2X8,
        V4L2_COLORSPACE_SRGB,
        V4L2_PIX_FMT_YVYU,
    },
    {
        MEDIA_BUS_FMT_UYVY8_2X8,
        V4L2_COLORSPACE_SRGB,
        V4L2_PIX_FMT_UYVY,
    },
    {
        MEDIA_BUS_FMT_VYUY8_2X8,
        V4L2_COLORSPACE_SRGB,
        V4L2_PIX_FMT_VYUY,
    },
    /*
     * The below two formats are not supported by VI4,
     * keep them at the last to ensure they get discarded
     */
    {
        MEDIA_BUS_FMT_XRGGB10P_3X10,
        V4L2_COLORSPACE_SRGB,
        V4L2_PIX_FMT_XRGGB10P,
    },
    {
        MEDIA_BUS_FMT_XBGGR10P_3X10,
        V4L2_COLORSPACE_SRGB,
        V4L2_PIX_FMT_XRGGB10P,
    },
#if defined(CONFIG_MXC_CAMERA_ECAM_OV2311_MIPI_V2)
    /* e-con: extending support for GREY format */
    {
               MEDIA_BUS_FMT_Y8_1X8,
               V4L2_COLORSPACE_SRGB,
               V4L2_PIX_FMT_GREY,
    },
#endif
};

 

However, in the current BSP of iMX8M Mini (imx-yocto-L4.9.88_2.0.0), and based on the error messages, I also found :

====  drivers/media/platform/mxc/capture/mx6s_capture.c ====

...

static struct mx6s_fmt formats[] = {
    {
        .name        = "UYVY-16",
        .fourcc        = V4L2_PIX_FMT_UYVY,
        .pixelformat    = V4L2_PIX_FMT_UYVY,
        .mbus_code    = MEDIA_BUS_FMT_UYVY8_2X8,
        .bpp        = 2,
    }, {
        .name        = "YUYV-16",
        .fourcc        = V4L2_PIX_FMT_YUYV,
        .pixelformat    = V4L2_PIX_FMT_YUYV,
        .mbus_code    = MEDIA_BUS_FMT_YUYV8_2X8,
        .bpp        = 2,
    }, {
        .name        = "YUV32 (X-Y-U-V)",
        .fourcc        = V4L2_PIX_FMT_YUV32,
        .pixelformat    = V4L2_PIX_FMT_YUV32,
        .mbus_code    = MEDIA_BUS_FMT_AYUV8_1X32,
        .bpp        = 4,
    }, {
        .name        = "RAWRGB8 (SBGGR8)",
        .fourcc        = V4L2_PIX_FMT_SBGGR8,
        .pixelformat    = V4L2_PIX_FMT_SBGGR8,
        .mbus_code    = MEDIA_BUS_FMT_SBGGR8_1X8,
        .bpp        = 1,
    }
};

 

====  drivers/media/platform/mxc/capture/mxc_mipi_csi.c ====

static const struct csis_pix_format mipi_csis_formats[] = {
    {
        .code = MEDIA_BUS_FMT_YUYV8_2X8,
        .fmt_reg = MIPI_CSIS_ISPCFG_FMT_YCBCR422_8BIT,
        .data_alignment = 16,
    }, {
        .code = MEDIA_BUS_FMT_VYUY8_2X8,
        .fmt_reg = MIPI_CSIS_ISPCFG_FMT_YCBCR422_8BIT,
        .data_alignment = 16,
    }, {
        .code = MEDIA_BUS_FMT_SBGGR8_1X8,
        .fmt_reg = MIPI_CSIS_ISPCFG_FMT_RAW8,
        .data_alignment = 8,
    }
};

 

Could someone give me an idea how to extend the mx6s_fmt as well as mipi_csis_formats tables in order to take into account the custom camera's formats, please ?

 

Thanks very much in advance,

Khang

Outcomes