MIPI CSI Use Onboard resources The Firefly-RK3288 development board has the MIPI camera interface. The camera’s image processing capability reaches 4416x3312 pixels and supports 4K video recording. In addition, the development board also supports a USB camera. This article takes the OV13850 camera as an example to explain the configuration process of the MIPI camera on the development board. Related code catalog The code catalog related to camera is as follows: Android: `- hardware/rockchip/camera |- Config | `- cam_board.xml // parameter setting of camera |- CameraHal // HAL source code of camera `- SiliconImage // ISP library, including all drivers source codes supporting module `- isi/drv/OV13850 // Driver source code of OV13850 module `- calib/OV13850.xml // Adjustment parameters of OV13850 module Kernel: |- kernel/drivers/media/video/rk_camsys // CamSys driver source code `- kernel/include/media/camsys_head.h Configuration principles Set camera-related pin and clock to complete the configuration process. According to the schematic diagram of camera port below, the pins to be configured include: AF_VDD28、DOVDD18、AVDD28、DVDD12、PWDN1、RST 和 MCLK. AF_VDD28 is provided by hardware connection. No configuration is needed. The DOVDD18 and AVDD28 are controlled by DVP_PWR: DVP_PWR is connected to GPIO0_B3: DVDD12 is controlled by CIF_PWER: CIF_PWER is connected to GPIO7_B4: PWDN1 and RST are connected to GPIO2_B6 and GPIO2_B7 respectively: All the pins are configured in cam_board.xml, with the exception of DVDD12 (CIF_POWER), which is configured in DTS and driver. Configuration steps Configure Android Modify "hardware/rockchip/camera/Config/cam_board.xml" to register camera: The main modified contents are as follows: Sensor name This name must coincide to the name of Sensor driver, and the format of Sensor driver currently provided is as follows: libisp_isi_drv_OV13850.so The user can find the driver file of this camera under the catalog "out/target/product/rk3288_aio_3288j_box/system/lib/hw/" after completing Android compilation. Sensor software identification Any inconsistent registration identification is okay, the following value can be filled in: CAMSYS_DEVID_SENSOR_1A CAMSYS_DEVID_SENSOR_1B CAMSYS_DEVID_SENSOR_2 Name of acquisition controller At present, it only supports: CAMSYS_DEVID_MARVIN Number of I2C channel connected to master control of Sensor For the specific channel number, please refer to the number of I2C channel connected to master control on the schematic diagram of camera. Sensor register address size, unit: bytes I2C frequency of Sensor, unit: Hz, which is used for setting I2C frequency. Sensor input clock frequency, unit: Hz, which is used for setting camera clock. PMU LDO name of Sensor AVDD. If it cannot be connected to PMU, fill in NC only. PMU LDO name of Sensor DOVDD. If it is not connected to PMU, fill in NC only. The values of min and max must be filled in, which decide the IO voltages of Sensor. PMU LDO name of Sensor DVDD. If it is not connected to PMU, fill in NC only. Sensor PowerDown pin. Directly fill in the name, and fill in the active level of sleep in active field. Sensor Reset pin. Directly fill in the name, and fill in the active level of reset in active field. Sensor Power pin. Directly fill in the name, and fill in the active level of power in active field. Select front or back for the Sensor. "Front" or "back" can be filled in. Sensor interface mode The following value can be filled in: CCIR601 CCIR656 MIPI SMIA Sensor image mode Do not support at present. Sensor angle information Physical interface settings MIPI phyMode: Sensor port hardware connection mode, for MIPI Sensor, this value shall take "CamSys_Phy_Mipi" lane: number of data channels in Sensor mipi interface phyIndex: mipi phy number of master control connected to Sensor mipi sensorFmt: Sensor output data format, which only supports CamSys_Fmt_Raw_10b at present Configuration kernel The configuration principles mention that GPIO7_B4 should be configured in DTS and driver. The configuration methods are as follows: (1). Add GPIO7_B4 configuration properties in DTS file Add gpios-cifpower property in "kernel/arch/arm/boot/dts/rk3288.dtsi" file, as shown below: isp: isp@ff910000{ compatible = "firefly,isp"; ... gpios-cifpower = ; ... status = "okay"; }; (2). Configure CIF_POWER in driver Read gpios-cifpower in "kernel/drivers/media/video/rk_camsys/camsys_drv.c", set this pin, enable CIF_POWER, and add in probe function camsys_platform_probe(), as shown below: enum of_gpio_flags flags; int cifpower_io; int io_ret; cifpower_io = of_get_named_gpio_flags(dev->of_node, "gpios-cifpower", 0, &flags); camsys_trace(1, "1-gpios-cifpower: gpio=%d", cifpower_io); if(gpio_is_valid(cifpower_io)){ cifpower_io = of_get_named_gpio_flags(dev->of_node, "gpios-cifpower", 0, &flags); camsys_trace(1, "gpios-cifpower: gpio_request"); io_ret = gpio_request(cifpower_io,"cifpower"); camsys_trace(1, "1-gpios-cifpower: gpio_request=%d", io_ret); if(io_ret < 0){ camsys_err("Request %s(%d) failed","cifpower", cifpower_io); } else{ gpio_direction_output(cifpower_io, 1); gpio_set_value(cifpower_io, 1); camsys_trace(1, "gpios-cifpower: %d high", cifpower_io); } } (3). Compile kernel Compile the driver source code "drivers/media/video/rk_camsys" into the kernel; its configuration methods are as follows: Execute command under kernel source code catalog: make menuconfig Then, open the following configuration item: Device Drivers ---> Multimedia support ---> camsys driver RockChip camera system driver ---> camsys driver for marvin isp camsys driver for cif Finally, execute: make firefly-rk3288.img The compilation of kernel is completed.