I'm preparing to integrate a new CMOS sensor on the IMX7SABRESD board. I have studied the reference manual (IMX7DRM rev.01) and the relevant kernel drivers (drivers/media/platform/mxc/subdev/mx6s_capture.c and ./drivers/media/platform/mxc/subdev/mxc_mipi_csi.c). The OV5640 works on this board/kernel.
The new sensor is CSI2 / DPHY compliant, is monochrome, and outputs RAW10/RAW12 (configurable). I'am experimenting with the mx6s_capture kernel driver to investigate the CSI IP behavior when setting different formats.
Most generally, how to get a CSI2 RAW10 or RAW12 monochrome mode working properly? How to configure the CSI2 and CSI peripherals for RAW12 mode, exactly?
Looking at the datasheet, many things are unclear or simply inconsistent:
- MIPI-CSI2 connects via internal mux to CSI (Figure 13-1), and CSI outputs to DRAM. MIPI-CSI2 is advertised to support RAW6/7/8/10/12/14 (DRM 220.127.116.11) . However, the DRM mentions that the CSI, which the CSI2 connects to, supports (only?) Bayer(RAW?) 8/10/16 bit. So is it possible to use RAW12 mode? How?
- CSI_CSICR18 register has MIPI_DATA_FORMAT field (30:25), using the exact same modes as MIPI-CSI2. The DRM says MIPI_DATA_FORMAT is read-only (blanked out - 18.104.22.168). Yet it is writable, and the mx6s_capture writes the mode to this field. Simply a DRM issue? Playing around with the values definitely changes the behavior of the output pixels.
- The MIPI-CSI2 output signals ("ISP CAM I/F") format (Table 13-19) appear MSB, starting at bit 23, with filled dummy 0's from bits 0. But the CSI periperal input pins/format (Table 13-5, 13-7, 13.3.2) start from bit #0, i.e. ipp_csi_d. For example, in RAW10 mode, CSI2 output bit 23 should internally connect to ipp_csi_d. DRM doesn't tell. See 22.214.171.124.2.2.2 "Normal Data alignment in output Data bus". It looks inverted from the CSI data input bus.
- What kind of transformation does CSI do on its input data depending on the CSI_CSICR18.MIPI_DATA_FORMAT field? How can CSI receive "generic data"?
- How are CSI_CSICR18.MIPI_DATA_FORMAT and MIPI_CSI2_ISP_CONFIG_CH0.DATAFORMAT related with each other?
Finally, playing around with the settings in mx6s_capture and the OV5640 sensor:
- Setting CSI_CSICR18.MIPI_DATA_FORMAT to RAW8 instead of YUV8 and the frame looks OK, except half of it is missing. Setting to RAW10 gives a correct image. Setting to RAW12 gives unrecognizable garbage (i.e. even looking at bit slicing / padding, makes little sense). Setting to RGB888 and enable 24-bit input also scrambles.
- Can only set CSI_CSICR18.MIPI_DATA_FORMAT once. The next call to configuration and the DATA_FORMAT reads back 0x3e - which is invalid / non-existant. Only power-cycling works to reset the peripheral.
Hope someone can answer these questions!