mtk camera调试

一、基本概念

1.Sensor成像原理

  • 景物通过镜头(LENS)生成的光学图像投射到图像传感器(Sensor)表面上,然后转为模 拟的电信号,经过 A/D(模数转换)转换后变为数字图像信号,再送到数字信号处理芯片 (DSP)中加工处理,再通过 IO 接口传输到 CPU 中处理,通过 LCD 就可以看到图像了。

  • 图像传感器(SENSOR)是一种半导体芯片,其表面包含有几十万到几百万的光电二极 管。光电二极管受到光照射时,就会产生电荷。

2.Sensor种类

1)CCD(Charge Couple Device), 电荷耦合器件,它是目前高像素类 sensor 中比较成熟 的成像器件,是以一行为单位的电流信号。 2)CMOS(Complementary Metal Oxide Semiconductor),互补金属氧化物半导体。CMOS 的信号是以点为单位的电荷信号,更为敏感,速度也更快,更为省电。

3.Sensor数据输出格式

  • RGB格式:采用这种编码方法,每种颜色都可用三个变量来表示红色、绿色以及蓝色 的强度。每一个像素有三原色R 红色、G绿色、B蓝色组成。

  • YUV格式:其中“Y”表示明亮度(Luminance 或 Luma),就是灰阶值;而“U”和“V”表示色度 (Chrominance 或 Chroma),是描述影像色彩及饱和度,用于指定像素的颜色。

  • RAW Data:sensor的每一像素对应一个彩色滤光片,滤光片按Bayer pattern分布。将每一个像素的数据直接输出,即RAW RGB data。

二、添加流程

参考平台:MT6762 android Q,以ov8856为例

1.定义SENSOR ID和NAME

kernel:

修改alps/kernel-4.9/drivers/misc/mediatek/imgsensor/inc/kd_imgsensor.h

#define OV8856_SENSOR_ID                        0x885A
#define SENSOR_DRVNAME_OV8856_MIPI_RAW          "ov8856_mipi_raw"

hal:

修改alps/device/mediatek/common/kernel-headers/kd_imgsensor.h

#define OV8856_SENSOR_ID                        0x885A
#define SENSOR_DRVNAME_OV8856_MIPI_RAW          "ov8856_mipi_raw"

2.添加驱动代码

3.添加hal层代码

4.引用sensor

kernel:

修改alps/kernel-4.9/drivers/misc/mediatek/imgsensor/src/common/v1/imgsensor_sensor_list.h

//对应驱动.c文件中的实现接口
UINT32 OV8856_MIPI_RAW_SensorInit(struct SENSOR_FUNCTION_STRUCT **pfFunc);

修改alps/kernel-4.9/drivers/misc/mediatek/imgsensor/src/common/v1/imgsensor_sensor_list.c

#if defined(OV8856_MIPI_RAW)
    {OV8856_SENSOR_ID,SENSOR_DRVNAME_OV8856_MIPI_RAW,OV8856_MIPI_RAW_SensorInit},
#endif

hal:

修改alps/vendor/mediatek/proprietary/custom/mt6765/hal/imgsensor_src/sensorlist.cpp

#if defined(OV8856_MIPI_RAW)
    RAW_INFO(OV8856_SENSOR_ID, SENSOR_DRVNAME_OV8856_MIPI_RAW, CAM_CALGetCalData),
#endif

5.修改上电时序

修改alps/kernel-4.9/drivers/misc/mediatek/imgsensor/src/mt6765/camera_hw/imgsensor_cfg_table.c:

#if defined(OV8856_MIPI_RAW)
    {SENSOR_DRVNAME_OV8856_MIPI_RAW,
        {   
            {SensorMCLK, Vol_High, 0}, 
            {DOVDD, Vol_1800, 0}, 
            {AVDD, Vol_2800, 0}, 
            {DVDD, Vol_1200, 0}, 
            {AFVDD, Vol_2800, 2}, 
            {PDN, Vol_Low, 0}, 
            {PDN, Vol_High, 0}, 
            {RST, Vol_Low, 0}, 
            {RST, Vol_High, 5}, 
        },  
    },  
#endif

6.修改dts

修改alps/kernel-4.9/arch/arm64/boot/dts/mediatek/cust_mt6765_camera.dtsi,根据实际连接的硬件引脚配置,参考如下:

/* CAMERA GPIO standardization */
&pio {
	camera_pins_cam0_rst0: cam0@0 {
		pins_cmd_dat {
			pinmux = ;
			slew-rate = <1>;
			output-low;
		};
	};
	camera_pins_cam0_rst1: cam0@1 {
		pins_cmd_dat {
			pinmux = ;
			slew-rate = <1>;
			output-high;
		};
	};
  

    /*此处省略一部分*/

	camera_pins_cam2_mclk_off: camera_pins_cam2_mclk_off {
		pins_cmd_dat {
			pinmux = ;
		};
	};

	camera_pins_default: camdefault {
	};

};

&kd_camera_hw1 {
	pinctrl-names = "default",
			"cam0_rst0",
			"cam0_rst1",
            /*此处省略一部分*/
			"cam2_mclk_off";

	pinctrl-0 = <&camera_pins_default>;
	pinctrl-1 = <&camera_pins_cam0_rst0>;
	pinctrl-2 = <&camera_pins_cam0_rst1>;
    /*此处省略一部分*/
	pinctrl-26 = <&camera_pins_cam2_mclk_off>;
	status = "okay";

};
/* CAMERA GPIO end */

7.修改dws

同样对应dts的修改,配置相关引脚的GPIO参数,以平台默认项目k62v1_64_bsp为例,有如下三个待修改的参考路径:

  • alps/kernel-4.9/drivers/misc/mediatek/dws/mt6765/k62v1_64_bsp.dws

  • alps/vendor/mediatek/proprietary/bootable/bootloader/lk/target/k62v1_64_bsp/dct/dct/codegen.dws

  • alps/vendor/mediatek/proprietary/bootable/bootloader/preloader/custom/k62v1_64_bsp/dct/dct/codegen.dws

8.配置camera

kernel修改:

alps/kernel-4.9/arch/arm64/configs/k62v1_64_bsp_debug_defconfig

alps/kernel-4.9/arch/arm64/configs/k62v1_64_bsp_defconfig

CONFIG_CUSTOM_KERNEL_IMGSENSOR="ov8856_mipi_raw"

device修改:

alps/device/mediateksample/k62v1_64_bsp/ProjectConfig.mk

CUSTOM_HAL_IMGSENSOR = ov8856_mipi_raw
CUSTOM_HAL_MAIN_IMGSENSOR = ov8856_mipi_raw
CUSTOM_KERNEL_IMGSENSOR = ov8856_mipi_raw
CUSTOM_KERNEL_MAIN_IMGSENSOR = ov8856_mipi_raw

三、调试FAQ

待补充

你可能感兴趣的:(android)