Logo Search packages:      
Sourcecode: linux-fsl-imx51 version File versions  Download package

int32_t ipu_csi_init_interface ( uint16_t  width,
uint16_t  height,
uint32_t  pixel_fmt,
ipu_csi_signal_cfg_t  sig 
)

ipu_csi_init_interface Sets initial values for the CSI registers. The width and height of the sensor and the actual frame size will be set to the same values.

Parameters:
width Sensor width
height Sensor height
pixel_fmt pixel format
sig ipu_csi_signal_cfg_t structure
Returns:
0 for success, -EINVAL for error

Definition at line 50 of file ipu_csi.c.

References ipu_csi_signal_cfg_t::clk_mode, ipu_csi_signal_cfg_t::data_pol, ipu_csi_signal_cfg_t::data_width, ipu_csi_signal_cfg_t::ext_vsync, ipu_csi_signal_cfg_t::Hsync_pol, ipu_csi_signal_cfg_t::pixclk_pol, ipu_csi_signal_cfg_t::sens_clksrc, and ipu_csi_signal_cfg_t::Vsync_pol.

Referenced by mxc_v4l2_s_param(), and mxc_v4l_open().

{
      uint32_t data = 0;

      /* Set SENS_DATA_FORMAT bits (8 and 9)
         RGB or YUV444 is 0 which is current value in data so not set explicitly
         This is also the default value if attempts are made to set it to
         something invalid. */
      switch (pixel_fmt) {
      case IPU_PIX_FMT_UYVY:
            data = CSI_SENS_CONF_DATA_FMT_YUV422;
            break;
      case IPU_PIX_FMT_RGB24:
      case IPU_PIX_FMT_BGR24:
            data = CSI_SENS_CONF_DATA_FMT_RGB_YUV444;
            break;
      case IPU_PIX_FMT_GENERIC:
            data = CSI_SENS_CONF_DATA_FMT_BAYER;
            break;
      default:
            return -EINVAL;
      }

      /* Set the CSI_SENS_CONF register remaining fields */
      data |= sig.data_width << CSI_SENS_CONF_DATA_WIDTH_SHIFT |
          sig.data_pol << CSI_SENS_CONF_DATA_POL_SHIFT |
          sig.Vsync_pol << CSI_SENS_CONF_VSYNC_POL_SHIFT |
          sig.Hsync_pol << CSI_SENS_CONF_HSYNC_POL_SHIFT |
          sig.pixclk_pol << CSI_SENS_CONF_PIX_CLK_POL_SHIFT |
          sig.ext_vsync << CSI_SENS_CONF_EXT_VSYNC_SHIFT |
          sig.clk_mode << CSI_SENS_CONF_SENS_PRTCL_SHIFT |
          sig.sens_clksrc << CSI_SENS_CONF_SENS_CLKSRC_SHIFT;

      __raw_writel(data, CSI_SENS_CONF);

      /* Setup frame size     */
      __raw_writel(width | height << 16, CSI_SENS_FRM_SIZE);

      __raw_writel(width << 16, CSI_FLASH_STROBE_1);
      __raw_writel(height << 16 | 0x22, CSI_FLASH_STROBE_2);

      /* Set CCIR registers */
      if ((sig.clk_mode == IPU_CSI_CLK_MODE_CCIR656_PROGRESSIVE) ||
          (sig.clk_mode == IPU_CSI_CLK_MODE_CCIR656_INTERLACED)) {
            __raw_writel(0x40030, CSI_CCIR_CODE_1);
            __raw_writel(0xFF0000, CSI_CCIR_CODE_3);
      }

      dev_dbg(g_ipu_dev, "CSI_SENS_CONF = 0x%08X\n",
            __raw_readl(CSI_SENS_CONF));
      dev_dbg(g_ipu_dev, "CSI_ACT_FRM_SIZE = 0x%08X\n",
            __raw_readl(CSI_ACT_FRM_SIZE));

      return 0;
}


Generated by  Doxygen 1.6.0   Back to index