How to Support RGB565 Gated Mode Input to i.MX6 CSI

Document created by Jun Zhu Employee on Oct 31, 2013Last modified by ebiz_ws_prod on Dec 13, 2017
Version 3Show Document
  • View in full screen mode

These days I supported a customer to enable LVDS in function. The data format between external LVDS in chip and i.MX6 CSI is RGB565, with HSYNC and VSYNC signals available. So we take gated mode configuration for i.MX6 CSI.


Customer environment:  i.MX6 D  + Linux LTIB 4.0.0 BSP


By default,  RGB565 gated mode is not supported by Linux LTIB 4.0.0 V4L2 capture driver, here is a summary for what we need to change for the driver to support RGB565 gated mode.


  • Please apply the attached patch "0001-ENGR00262270-IPU3-Basic-16-bit-generic-data-support.patch". By this patch, IPU_PIX_FMT_GENERIC_16 can be supported by ipu3 driver.
  • For V4L2 capture setup, file linux-3.0.35/drivers/media/video/mxc/capture/mxc_v4l2_capture.c,  function mxc_v4l2_s_fmt(), add code segment like this:

                 switch(f->fmt.pix.pixelformat) {


                 case V4L2_PIX_FMT_SGRBG8:

                          size = f->fmt.pix.width * f->fmt.pix.height * 2;

                          bytesperline = f->fmt.pix.width * 2;






          Also for file linux-3.0.35/drivers/media/video/mxc/capture/ipu_csi_enc.c,  function csi_enc_setup(), please add code segment:

                 else if (cam->v2f.fmt.pix.pixelformat == V4L2_PIX_FMT_SGRBG8)

                           pixel_fmt = IPU_PIX_FMT_GENERIC_16;


          By the modifications above, IPU_PIX_FMT_GENERIC_16 can be set for the CSI IDMAC channel.


  • For sensor driver, please set pixel format to IPU_PIX_FMT_GENERIC_16
  • Don't forget to set GATED MODE and data with to 16 bits for CSI param in file linux-3.0.35/drivers/media/video/capture/mxc_v4l2_capture.c, function mxc_v4l2_s_param


                csi_param.clk_mode = IPU_CSI_CLK_MODE_GATED_CLK;

                csi_param.data_width = IPU_CSI_DATA_WIDTH_16;


  • Please ensure CSI->MEM IDMAC channel should be choosed


     The key point is that for CSI RGB565 gated mode support, the pixel format for IDMAC channel should be set to GENERIC 16, and for CSI port configuration, the pixel format is BAYER mode.

Original Attachment has been moved to:

5 people found this helpful