Android:展锐T760平台camera驱动调试

一、模块平台框架

平台介绍

基于UMS9620x平台集成Camera时,共有四类信号需要了解:

1、MIPI CSI信号:该平台有DPHY和CPHY两种MIPI信号。

   DPHY配置:包括数对差分数据信号DP/N,和一对差分时钟信号CKP/N。

   CPHY配置:最多有3lane,每lane由ABC三条数据组成。

   Camera的连接方式受限于UMS9620x内部的CSI PHY、CSI Controller和DCAM模块。

2、I2C信号:UMS9620x作为Controller,通过I2C总线对Camera进行配置或者对Camera状态进行读取。

3、控制信号:控制信号通常有PWDN、RST、MCLK信号;双摄模式下还有FS_DUALCAM(V_SNYC)信号

用于多个Camera之间同步抓帧。

4、四组电源:

   Sensor模拟电源:AVDD

   核心数字部分电源:DVDD

   IO接口电源:IOVDD

   对焦马达电源:AFVDD

Camera功能框图

Android:展锐T760平台camera驱动调试_第1张图片

二、适配流程介绍

下面T760平台项目前后摄为例介绍,如前摄ov02b10,后摄ov16885。

camera相关目录

device/sprd/mpool/product/unisoc/usvi/violators/camera/msoc/qogirn6pro/qogirn6pro.mk

device/sprd/qogirn6pro/ums9620_nb10/module/camera/md.mk

device/sprd/qogirn6pro/ums9620_nb10/module/camera/sensor_config.xml

bsp/kernel5.4/kernel5.4/arch/arm64/boot/dts/sprd/ums9620-nb10-overlay.dts

vendor/sprd/modules/libcamera/libcam_device.mk

vendor/sprd/modules/libcamera/sensor/af_drv/vcm_lib_cfg.mk

vendor/sprd/modules/libcamera/sensor/its_param/qogirn6pro/OmniVision/ov02b10

vendor/sprd/modules/libcamera/sensor/its_param/qogirn6pro/OmniVision/ov16885

vendor/sprd/modules/libcamera/sensor/sensor_cfg.c

vendor/sprd/modules/libcamera/sensor/sensor_drv/classic/OmniVision/ov02b10

vendor/sprd/modules/libcamera/sensor/sensor_drv/classic/OmniVision/ov16885

vendor/sprd/modules/libcamera/sensor/sensor_drv/sensor_lib_cfg.mk

vendor/sprd/modules/libcamera/kernel_module/flash/sc2703s

其中tuning参数,使用工具自动生成,具体在tuning文档中介绍。

图例:

Android:展锐T760平台camera驱动调试_第2张图片

1、修改device配置

device/sprd/mpool/product/unisoc/usvi/violators/camera/msoc/qogirn6pro/qogirn6pro.mk

device/sprd/qogirn6pro/ums9620_nb10/module/camera/md.mk

device/sprd/qogirn6pro/ums9620_nb10/module/camera/sensor_config.xml

修改参考方法如下:

device/sprd/mpool/product/unisoc/usvi/violators/camera/msoc/qogirn6pro/qogirn6pro.mk

TUNING_PARAM_LIST := "ov16885,ov02b10"

device/sprd/qogirn6pro/ums9620_nb10/module/camera/md.mk

CAMERA_SUPPORT_SIZE := s16

FRONT_CAMERA_SUPPORT_SIZE := s2

#BACK_EXT_CAMERA_SUPPORT_SIZE := s2

#FRONT_EXT_CAMERA_SUPPORT_SIZE := s8

#BACK_EXT2_CAMERA_SUPPORT_SIZE := s8

TARGET_BOARD_SW_GTM_SUPPORT := true

TARGET_BOARD_CAMERA_DUAL_SENSOR_MODULE := false

CAMERA_SENSOR_TYPE_BACK := ov16885

CAMERA_SENSOR_TYPE_FRONT := ov02b10

#CAMERA_SENSOR_TYPE_BACK_EXT := ov16885

#CAMERA_SENSOR_TYPE_FRONT_EXT := ov02b10

SENSOR_OV8856_TELE := false

TARGET_BOARD_CAMERA_DUAL_SENSOR_MODULE := false

TUNING_PARAM_LIST := "ov16885,ov02b10"

TARGET_BOARD_CAMERA_4IN1 := false

#TARGET_BOARD_SENSOR_OV4C := false

TARGET_BOARD_SENSOR_SS4C := false

TARGET_BOARD_CAMERA_FLASH_LED_0 := false # flash led0 config

TARGET_BOARD_CAMERA_FLASH_LED_1 := false # flash led1 config

#TARGET_BOARD_CAMERA_FLASH_TYPE := ocp8137

TARGET_BOARD_MULTICAMERA_SUPPORT := false

device/sprd/qogirn6pro/ums9620_nb10/module/camera/sensor_config.xml

 

 

  sensor id 1

  <-->

     

        1

        ov16885

        FRONT

        270

        55

        1

       

            dw9714v

            2

       

       

           

                general

                0xa4

                0

                8192

           

       

       

            ov16885

       

     

 

  sensor id 0

  <-->

     

        0

        ov02b10

        BACK

        90

        100

       

            ov02b10

       

     

 

2、修改驱动

添加驱动文件目录:

vendor/sprd/modules/libcamera/sensor/sensor_drv/classic/OmniVision/ov02b10

vendor/sprd/modules/libcamera/sensor/sensor_drv/classic/OmniVision/ov16885

调试时,需要注意i2c地址,打开驱动头文件,修改i2c地址,比如:

sprd/modules/libcamera/sensor/sensor_drv/classic/OmniVision/ov02b10/sensor_ov02b10_mipi_raw.h

sprd/modules/libcamera/sensor/sensor_drv/classic/OmniVision/ov16885/sensor_ov16885_mipi_raw.h

#define I2C_SLAVE_ADDR 0x20 /* 8bit slave address*/

sprd/modules/libcamera/sensor/sensor_drv/sensor_lib_cfg.mk

PRODUCT_PACKAGES += libsensor_imx351 \

    libsensor_ov5675_dual \

    libsensor_ov7251 \

    libsensor_ov8856_shine \

    libsensor_ov8856_shine_front \

    libsensor_ov02b10 \

    libsensor_ov16885

3、配置设备树

设备树路径:根据原理图,sensor datasheet等配置。

bsp/kernel5.4/kernel5.4/arch/arm64/boot/dts/sprd/ums9620-nb10-overlay.dts

&i2c0 {

        status = "okay";

        clock-frequency = <400000>;

        #address-cells = <1>;

        #size-cells = <0>;

        sensor_main: sensor-main@20 {

                 compatible = "sprd,sensor-main";

                 reg = <0x20>;

                 clock-names = "clk_src","sensor_eb",

                         "clk_96m","clk_64m",

                         "clk_51m2","clk_48m","clk_26m";

                 clocks = <&mm_clk CLK_SENSOR0>,<&mm_gate CLK_SENSOR0_EN>,

                                  <&g5l_pll CLK_TGPLL_96M>,<&g5l_pll CLK_TGPLL_64M>,

                                  <&g5l_pll CLK_TGPLL_51M2>,<&g5l_pll CLK_TGPLL_48M>,<&ext_26m>;

                 vddio-supply = <&vddcamio>;

                 vddcama-supply = <&vddcama0>;

                 vddcamd-supply = <&vddcamd0>;

                 vddcammot-supply = <&vddcammot0>;

                 reset-gpios = <&ap_gpio 39 0>;

                 power-down-gpios = <&ap_gpio 45 0>;

                 sprd,phyid = <0>;

                 csi = <&csi0>;

                 power-domains = <&mm_domain>;

        };

};

&i2c1 {

        status = "okay";

        clock-frequency = <400000>;

        #address-cells = <1>;

        #size-cells = <0>;

        sensor_sub: sensor-sensor_sub@78 {

                 compatible = "sprd,sensor-sub";

                 reg = <0x78>;

                 clock-names = "clk_src","sensor_eb",

                         "clk_96m","clk_64m",

                         "clk_51m2","clk_48m","clk_26m";

                 clocks = <&mm_clk CLK_SENSOR1>,<&mm_gate CLK_SENSOR1_EN>,

                         <&g5l_pll CLK_TGPLL_96M>,<&g5l_pll CLK_TGPLL_64M>,

                         <&g5l_pll CLK_TGPLL_51M2>,<&g5l_pll CLK_TGPLL_48M>,<&ext_26m>;

                 vddio-supply = <&vddcamio>;

                 vddcama-supply = <&vddcama1>;

                 vddcamd-supply = <&vddcamio>;

                 reset-gpios = <&ap_gpio 40 0>;

                 power-down-gpios = <&ap_gpio 46 0>;

                 sprd,phyid = <1>;

                 csi = <&csi1>;

                 power-domains = <&mm_domain>;

        };

};

修改方法参考如下:

根据硬件原理图配置,i2c总线、供电、GPIO、PHY、CSI等等。

Android:展锐T760平台camera驱动调试_第3张图片

Android:展锐T760平台camera驱动调试_第4张图片

Android:展锐T760平台camera驱动调试_第5张图片

4、OTP驱动配置

vendor/sprd/modules/libcamera/sensor/otp_drv/driver/

展锐OTP方案:按照展锐平台OTP烧录规范,数据存储在E2prom中,建议使用general驱动。

个性化OTP方案:需另行编写OTP驱动xxx_yyy,并将OtpName配置为xxx_yyy。

NB1.0项目采用展锐的OTP方案,注意i2c地址,大小即可。

device/sprd/qogirn6pro/ums9620_nb10/module/camera/sensor_config.xml

     

        1

        ov16885

        FRONT

        270

        55

        1

       

            dw9714v

            2

        

       

           

                general

                0xa4

                0

                8192

           

       

        

            ov16885

       

     

5、AF驱动配置

vendor/sprd/modules/libcamera/sensor/af_drv/vcm_lib_cfg.mk

vendor/sprd/modules/libcamera/sensor/af_drv/dw9714/

vendor/sprd/modules/libcamera/sensor/af_drv/vcm_lib_cfg.mk

PRODUCT_PACKAGES += libvcm_dw9714p \

                    libvcm_dw9714v \

                    libvcm_lc898213 \

                    libvcm_dw9768v \

                    libvcm_dw9800 \

                    libvcm_dw9825a \

                    libvcm_dw9714 \

Android:展锐T760平台camera驱动调试_第6张图片

6、Flash驱动配置

vendor/sprd/modules/libcamera/kernel_module/flash/sc2703s/

本项目用的默认驱动,不需要额外的配置,用默认的即可。

7、配置otp

和马达驱动一样,otp可以使用展锐的平台otp驱动,在sensor_cfg.c中添加。

8、Tuning参数配置

vendor/sprd/modules/libcamera/libcam_device.mk

vendor/sprd/modules/libcamera/sensor/its_param/qogirn6pro/OmniVision/ov02b10

vendor/sprd/modules/libcamera/sensor/its_param/qogirn6pro/OmniVision/ov16885

vendor/sprd/modules/libcamera/libcam_device.mk

ifneq ($(filter $(TARGET_BOARD_PLATFORM), ums9620), )

PRODUCT_COPY_FILES += $(call find-copy-subdir-files,*,vendor/sprd/modules/libcamera/sensor/its_param/qogirn6pro/OmniVision/ov16885,vendor/firmware/ov16885) \

                      $(call find-copy-subdir-files,*,vendor/sprd/modules/libcamera/sensor/its_param/qogirn6pro/OmniVision/ov02b10,vendor/firmware/ov02b10)

endif

Android:展锐T760平台camera驱动调试_第7张图片

其中tuning参数,使用工具自动生成,具体在tuning文档中介绍。

9、编译

1、整编

source build/envsetup.sh

lunch

kheader

进入BSP目录,设置BSP环境变量和编译选项

source build/envsetup.sh

lunch

编译整个工程,返回根目录执行:

Make

   

    2、单独编译Camera模块

source build/envsetup.sh

lunch

kheader

进入vendor/sprd/modules/libcamera目录:

mm或mma

   

    3、单独编译Flash ko

source build/envsetup.sh

lunch

编译通用Flash驱动ko,在BSP下执行:

make modules -m sprd_flash_drv.ko

编译具体Flash驱动ko,在BSP下执行:

make modules -m flash_ic_ocp8137.ko

make modules -m flash_ic_sc2703.ko

   

    4、编译DTS

source build/envsetup.sh

lunch

编译boot.img:

make bootimage

编译dtbo.img:

make dtboimage

10、下载

1、下载Sensor/AF/OTP驱动

out/target/product/ums9620_nb10/odm/lib/

Android:展锐T760平台camera驱动调试_第8张图片

2、下载sensor_config.xml

adb root

adb remount

adb push sensor_config.xml odm/etc

adb reboot

3、下载Sensor Tuning参数

adb root

adb remount

adb push ov16885 vendor/firmware/ov16885

adb reboot

也可使用IspTool工具下载参数,具体请参考IspTool工具包中的使用指导手册。

4、下载Flash驱动

bsp/out/androidt/ums512_1h10_Natv/dist/modules/archive/

Android:展锐T760平台camera驱动调试_第9张图片

5、下载DTS

修改DTS后,编译生成的image文件输出目录:

out/target/product/ums9620_nb10。

将DTS下载到设备:boot.img和dtbo.img存放在电脑本地。

adb reboot bootloader

fastboot flash boot boot.img

fastboot flash dtbo dtbo.img

fastboot reboot

也可使用展锐pac下载工具ResearchDownload下载image,具体请参考ResearchDownload工具包中的使用指导手册。

三、常见问题

1、互换前后摄ID

device/sprd/qogirn6pro/ums9620_nb10/module/camera/sensor_config.xml

把sensor id前后摄内容互换,如SlotId、Facing等选项内容,具体以实际为准。

bsp/kernel5.4/kernel5.4/arch/arm64/boot/dts/sprd/ums9620-nb10-overlay.dts

主要是红框内容互换:

&i2c0 {

    status = "okay";

    sensor_sub: sensor-sub@78 {

        compatible = "sprd,sensor-sub";

        reg = <0x78>;

        ... ...

        status = "okay";

    };

};

&i2c1 {

    status = "okay";

    sensor_main: sensor-main@20 {

        compatible = "sprd,sensor-main";

        reg = <0x20>;

        ... ...

        status = "okay";

    };

};

你可能感兴趣的:(展锐,android,Android,展锐)