Toybrick EN

中文 / EN
Toybrick EN Wiki TB-RK3399ProD How to attach a camera sensor to the TB-RK3399ProD
How to attach a camera sensor to the TB-RK3399ProD

For Android

There are two MIPI DSI-2 PHYs and connectors at toybrick devboard. You can use two MIPI cameras here.

A sample of device tree

1. Enabling the ISPs for the camera sensors

  1. &isp0 {
        status = "okay";
    };
    &isp1 {
        status = "okay";
    };
    &isp0_mmu {
        status = "okay";
    };
    &isp1_mmu {
        status = "okay";
    };

2. Enabling the I2C bus for controlling those sensors

  1. &i2c1 {
        status = "okay";
    };

camera drive(OV9750 here)

1. You can find its driver files at Android SDK:

hardware/rockchip/camera/SiliconImage/isi/drv/OV9750_A

2、The built libisp_isi_drv_OV9750_A.so would be installed into /vendor/lib/hw

3、Installing OV9750_A.xml  from hardware/rockchip/camera/SiliconImage/isi/drv/OV9750_A/calib/  to   /vendor/etc/

4、Installing hardware/rockchip/camera/Config/cam_board_rk3399.xml as /vendor/etc/cam_board.xml

The detail of the XML files

It would complete the power sequence of a camera module, e.g. assign rst and pdn pins for it. Also it would contain the information of the I2C bus and MIPI phy used for this sensor.

You may check the datasheet of the OV9750 for future information.

For GNU Linux

You can both MIPI DSI-2 sensor and DVP sensor here. We can use two MIPI sensors simultaneously. The ISP can capture image up to 4K resolution and video recording can work up to 30 frame rate at 1920 x 1080 resolution.


Still I would use OV9750 as example here.

Connection

We would know that two MIPI sensors would be connected to different MIPI DSI-2 and I2C bus from schematic.

MIPI0 connector: connected to ISP0 and I2C1,pins MIPI_MCLK0, MIPI_PDN, MIPI_RST would be assigned with the sensor

MIPI1connector: connected to ISP1 and I2C2,pins MIPI_MCLK_T2JMIPI_PDN2JMIPI_RST2 would be assigned with the sensor

1.png

A sample of device tree

Enabling the ISPs node

  1. cif_isp0: cif_isp@ff910000 {
                compatible = "rockchip,rk3399-cif-isp";
                rockchip,grf = <&grf>;
                reg = <0x0 0xff910000 0x0 0x4000>, <0x0 0xff968000 0x0 0x8000>;
                reg-names = "register", "dsihost-register";
                clocks =
                    <&cru ACLK_ISP0_NOC>, <&cru ACLK_ISP0_WRAPPER>,
                    <&cru HCLK_ISP0_NOC>, <&cru HCLK_ISP0_WRAPPER>,
                    <&cru SCLK_ISP0>, <&cru SCLK_DPHY_RX0_CFG>,
                    <&cru SCLK_CIF_OUT>, <&cru SCLK_CIF_OUT>,
                    <&cru SCLK_MIPIDPHY_REF>;
                clock-names =
                    "aclk_isp0_noc", "aclk_isp0_wrapper",
                    "hclk_isp0_noc", "hclk_isp0_wrapper",
                    "clk_isp0", "pclk_dphyrx",
                    "clk_cif_out", "clk_cif_pll",
                    "pclk_dphy_ref";
                interrupts = <GIC_SPI 43 IRQ_TYPE_LEVEL_HIGH 0>;
                interrupt-names = "cif_isp10_irq";
                power-domains = <&power RK3399_PD_ISP0>;
                rockchip,isp,iommu-enable = <1>;
                iommus = <&isp0_mmu>;
                status = "disabled";
                      };
    &isp0 {
       status = "okay";
           };
     
    &isp0_mmu {
        status = "okay";
               };

    &cif_isp0 {
    rockchip,camera-modules-attached = <&camera0>;
    status = "okay";
    };

Assignment a pin for the camera MCLK signal

  1. &pinctrl {
    /* */
         cam_mclk {
              cam_default_pins: cam-default-pins {
                                rockchip,pins = <2 11 RK_FUNC_3 &pcfg_pull_none>;
                                          };
                };
              };

Enabling the I2C busses for camera controlling

  1. &i2c1 {
             status = "okay";
             /*
             * Usually written as:cameraX:camera-module@ID,X :Sequence Number,ID:camera's 7bit I2C address
                      * camera0 is node name,when binding the isp node,attach camera0 to isp
                      */
        camera0: camera-module@10 {
           status = "okay";
           compatible = "omnivision,ov9750-v4l2-i2c-subdev";
           reg = <0x10>;             /* I2C address */
           device_type = "v4l2-i2c-subdev";    /* Keep the same value here */
           clocks = <&cru SCLK_CIF_OUT>;     /* The clock source here, keep the same value here */
           clock-names = "clk_cif_out";      /* The name of the clock source, keep the same value here */
     
           pinctrl-names = "default";       /* Keep the same value here  */
           pinctrl-0 = <&cam_default_pins>;      /* Keep the same value here  */
     
           rockchip,pd-gpio = <&gpio4 RK_PD1 GPIO_ACTIVE_LOW>;  /* PD pin and its active state */
           rockchip,rst-gpio = <&gpio4 RK_PD2 GPIO_ACTIVE_LOW>; /* RST pin and its active state */
     
           rockchip,camera-module-mclk-name = "clk_cif_out";   /* Keep the same value here */
           rockchip,camera-module-facing = "back";       /* The front or back camera */
           rockchip,camera-module-name = "MDG001";       /* The product name of this camera module */
           rockchip,camera-module-len-name = "NONE";      /* The len for this camera module */
           rockchip,camera-module-fov-= "80";         /*  horizontal field of view */
           rockchip,camera-module-fov-= "65";         /* vertical field of view */
           rockchip,camera-module-orientation = <0>;      / orientation */
           rockchip,camera-module-iq-flip = <0>;        /* flip in IQ setting */
           rockchip,camera-module-iq-mirror = <0>;       /* flop(mirror) in IQ setting */
           /* The above two options  should be zero at the most time. But if you meet a problem likes color contrast with half above part and below part, you may try to set their values to one */
           rockchip,camera-module-mirror = <1>;
           /* The above two options would affect the image input */
           rockchip,camera-module-defrect0 = <1280 960 0 0 1280 960>; /* The pixel resolution of this camera */
     
           rockchip,camera-module-flash-support = <0>;        /* Whether there is flash light in this camera module */
           rockchip,camera-module-mipi-dphy-index = <0>;       /* The index of MIPI DSI-2 phy used for this device */
           as-master = <0>;
      };
    };

Driver

You can find driver files here:

  1. drivers/media/i2c/soc_camera/rockchip
    |-- ov9750_v4l2-i2c-subdev.c    /* The specific part for ov9750 */
    |-- ov_camera_module.c       /* The common functions for OV serial */
    |-- ov_camera_module.h
    |-- rk_camera_mclk.c        /* The clock management of mclk */
    |-- rk_camera_mclk.h
    |-- rk_camera_module.c       /* The common functions of the RK camera support */
    `-- rk_camera_module_version.h   /* module version */








Products Store Community Wiki Download About TB


To Top