mtk6580o1平台 后摄:bf2507 前摄:sp0a09
1
device/mediatek/common/kernel-headers/kd_imgsensor.h
kernel-3.18/drivers/misc/mediatek/imgsensor/inc/kd_imgsensor.h
这两个文件必须一致
#define BF2507MIPI_SENSOR_ID 0xa507
#define SP0A09MIPI_SENSOR_ID 0x0a09
#define SENSOR_DRVNAME_BF2507_MIPI_RAW "bf2507mipiraw"
#define SENSOR_DRVNAME_SP0A09_MIPI_RAW "sp0a09mipiraw"
2
device/mediateksample/k80hd_bsp_fwv_512m/ProjectConfig.mk
CUSTOM_HAL_IMGSENSOR = bf2507_mipi_raw sp0a09_mipi_raw
CUSTOM_HAL_MAIN_IMGSENSOR = bf2507_mipi_raw
CUSTOM_HAL_SUB_IMGSENSOR = sp0a09_mipi_raw
CUSTOM_KERNEL_IMGSENSOR = bf2507_mipi_raw sp0a09_mipi_raw
CUSTOM_KERNEL_MAIN_IMGSENSOR = raw bf2507_mipi_raw
CUSTOM_KERNEL_SUB_IMGSENSOR = sp0a09_mipi_raw
3
kernel-3.18/arch/arm/configs/k80hd_bsp_fwv_512m_debug_defconfig
kernel-3.18/arch/arm/configs/k80hd_bsp_fwv_512m_defconfig
CONFIG_CUSTOM_KERNEL_IMGSENSOR="bf2507_mipi_raw sp0a09_mipi_raw"
4
kernel-3.18/drivers/misc/mediatek/imgsensor/src/mt6580/kd_sensorlist.h
UINT32 BF2507_MIPI_RAW_SensorInit( PSENSOR_FUNCTION_STRUCT *pfFunc);
UINT32 SP0A09MIPI_RAW_SensorInit(PSENSOR_FUNCTION_STRUCT *pfFunc);
#if defined(BF2507_MIPI_RAW)
{BF2507MIPI_SENSOR_ID, SENSOR_DRVNAME_BF2507_MIPI_RAW,BF2507_MIPI_RAW_SensorInit},
#endif
#if defined(SP0A09_MIPI_RAW)
{SP0A09MIPI_SENSOR_ID, SENSOR_DRVNAME_SP0A09_MIPI_RAW, SP0A09MIPI_RAW_SensorInit},
#endif
5.上电下电
kernel-3.18/drivers/misc/mediatek/imgsensor/src/mt6580/camera_hw/kd_camera_hw.c
//bf2507 poweron
} else if (currSensorName && (0 == strcmp(SENSOR_DRVNAME_BF2507_MIPI_RAW, currSensorName)))
{
//First Power Pin low and Reset Pin Low
if (GPIO_CAMERA_INVALID != pinSet[pinSetIdx][IDX_PS_CMPDN])
{
mtkcam_gpio_set(pinSetIdx, CAMPDN, pinSet[pinSetIdx][IDX_PS_CMPDN + IDX_PS_ON]);
}
if (GPIO_CAMERA_INVALID != pinSet[pinSetIdx][IDX_PS_CMRST])
{
mtkcam_gpio_set(pinSetIdx, CAMRST, pinSet[pinSetIdx][IDX_PS_CMRST + IDX_PS_OFF]);
}
mdelay(10);
/* VCAM_IO */
if (TRUE != _hwPowerOnCnt(VCAMIO, VOL_1800))
{
PK_DBG("[CAMERA SENSOR] Fail to enable IO power (VCAM_IO),power id = %d\n", VCAMIO);
goto _kdCISModulePowerOn_exit_;
}
mdelay(10);
/* VCAM_A */
if (TRUE != _hwPowerOnCnt(VCAMA, VOL_2800))
{
PK_DBG("[CAMERA SENSOR] Fail to enable analog power (VCAM_A),power id = %d\n", VCAMA);
goto _kdCISModulePowerOn_exit_;
}
mdelay(10);
/* AF_VCC */
if (TRUE != _hwPowerOnCnt(VCAMAF, VOL_2800))
{
PK_DBG("[CAMERA SENSOR] Fail to enable analog power (VCAM_AF), power id = %d \n", VCAMAF);
goto _kdCISModulePowerOn_exit_;
}
mdelay(10);
if (GPIO_CAMERA_INVALID != pinSet[pinSetIdx][IDX_PS_CMPDN])
{
mtkcam_gpio_set(pinSetIdx, CAMPDN, pinSet[pinSetIdx][IDX_PS_CMPDN + IDX_PS_OFF]);
}
//enable active sensor
mdelay(5);
if (GPIO_CAMERA_INVALID != pinSet[pinSetIdx][IDX_PS_CMRST])
{
mtkcam_gpio_set(pinSetIdx, CAMRST, pinSet[pinSetIdx][IDX_PS_CMRST + IDX_PS_ON]);
}
//disable inactive sensor
if (pinSetIdx == 0)
{ //disable sub
if (GPIO_CAMERA_INVALID != pinSet[1][IDX_PS_CMPDN])
{
mtkcam_gpio_set(1, CAMPDN, pinSet[1][IDX_PS_CMPDN + IDX_PS_ON]);
}
if (GPIO_CAMERA_INVALID != pinSet[1][IDX_PS_CMRST])
{
mtkcam_gpio_set(1, CAMRST, pinSet[1][IDX_PS_CMRST + IDX_PS_OFF]);
}
}
else
{
if (GPIO_CAMERA_INVALID != pinSet[0][IDX_PS_CMPDN])
{
mtkcam_gpio_set(0, CAMPDN, pinSet[0][IDX_PS_CMPDN + IDX_PS_ON]);
}
if (GPIO_CAMERA_INVALID != pinSet[0][IDX_PS_CMRST])
{
mtkcam_gpio_set(0, CAMRST, pinSet[0][IDX_PS_CMRST + IDX_PS_OFF]);
}
}
}
//sp0a09 poweron
else if (currSensorName &&
(currSensorName && (0 == strcmp(SENSOR_DRVNAME_SP0A09_MIPI_RAW, currSensorName))))
{
//First Power Pin low and Reset Pin Low
if (GPIO_CAMERA_INVALID != pinSet[pinSetIdx][IDX_PS_CMPDN])
{
mtkcam_gpio_set(pinSetIdx, CAMPDN, pinSet[pinSetIdx][IDX_PS_CMPDN + IDX_PS_ON]);
}
if (GPIO_CAMERA_INVALID != pinSet[pinSetIdx][IDX_PS_CMRST])
{
mtkcam_gpio_set(pinSetIdx, CAMRST, pinSet[pinSetIdx][IDX_PS_CMRST + IDX_PS_OFF]);
}
mdelay(50);
//DVDD
if (TRUE != _hwPowerOnCnt(VCAMD, VOL_1500))
{
PK_DBG("[CAMERA SENSOR] Fail to enable digital power (VCAM_D), power id = %d \n", SUB_VCAMD);
goto _kdCISModulePowerOn_exit_;
}
mdelay(10);
/* VCAM_IO */
if (TRUE != _hwPowerOnCnt(VCAMIO, VOL_1800))
{
PK_DBG("[CAMERA SENSOR] Fail to enable IO power (VCAM_IO),power id = %d\n", VCAMIO);
goto _kdCISModulePowerOn_exit_;
}
//IOVDD
mdelay(10);
/* VCAM_A */
if (TRUE != _hwPowerOnCnt(VCAMA, VOL_2800))
{
PK_DBG("[CAMERA SENSOR] Fail to enable analog power (VCAM_A),power id = %d\n", VCAMA);
goto _kdCISModulePowerOn_exit_;
}
mdelay(10);
/* AF_VCC */
if (TRUE != _hwPowerOnCnt(VCAMAF, VOL_2800))
{
PK_DBG("[CAMERA SENSOR] Fail to enable analog power (VCAM_AF), power id = %d \n", VCAMAF);
goto _kdCISModulePowerOn_exit_;
}
mdelay(50);
if (GPIO_CAMERA_INVALID != pinSet[pinSetIdx][IDX_PS_CMPDN])
{
mtkcam_gpio_set(pinSetIdx, CAMPDN, pinSet[pinSetIdx][IDX_PS_CMPDN + IDX_PS_ON]);
mdelay(20);
mtkcam_gpio_set(pinSetIdx, CAMPDN, pinSet[pinSetIdx][IDX_PS_CMPDN + IDX_PS_OFF]);
}
//enable active sensor
mdelay(10);
if (GPIO_CAMERA_INVALID != pinSet[pinSetIdx][IDX_PS_CMRST])
{
mtkcam_gpio_set(pinSetIdx, CAMRST, pinSet[pinSetIdx][IDX_PS_CMRST + IDX_PS_OFF]);
mdelay(5);
mtkcam_gpio_set(pinSetIdx, CAMRST, pinSet[pinSetIdx][IDX_PS_CMRST + IDX_PS_ON]);
}
#if 1
//disable inactive sensor
if (pinSetIdx == 0)
{ //disable sub
if (GPIO_CAMERA_INVALID != pinSet[1][IDX_PS_CMRST])
{
mtkcam_gpio_set(1, CAMRST, pinSet[1][IDX_PS_CMRST + IDX_PS_ON]);
}
if (GPIO_CAMERA_INVALID != pinSet[1][IDX_PS_CMPDN])
{
mtkcam_gpio_set(1, CAMPDN, pinSet[1][IDX_PS_CMPDN + IDX_PS_ON]);
}
}
else
{
if (GPIO_CAMERA_INVALID != pinSet[0][IDX_PS_CMRST])
{
mtkcam_gpio_set(0, CAMRST, pinSet[0][IDX_PS_CMRST + IDX_PS_ON]);
}
if (GPIO_CAMERA_INVALID != pinSet[0][IDX_PS_CMPDN])
{
mtkcam_gpio_set(0, CAMPDN, pinSet[0][IDX_PS_CMPDN + IDX_PS_ON]);
}
}
#endif
//bf2507 power down
} else if (currSensorName && (0 == strcmp(SENSOR_DRVNAME_BF2507_MIPI_RAW, currSensorName)))
{
/* Set Power Pin low and Reset Pin Low */
if (GPIO_CAMERA_INVALID != pinSet[pinSetIdx][IDX_PS_CMPDN])
{
mtkcam_gpio_set(pinSetIdx, CAMPDN, pinSet[pinSetIdx][IDX_PS_CMPDN + IDX_PS_ON]);
}
/* Set Reset Pin Low */
if (GPIO_CAMERA_INVALID != pinSet[pinSetIdx][IDX_PS_CMRST])
{
mtkcam_gpio_set(pinSetIdx, CAMRST, pinSet[pinSetIdx][IDX_PS_CMRST + IDX_PS_OFF]);
}
/* AF_VCC */
if (TRUE != _hwPowerDownCnt(VCAMAF))
{
PK_DBG("[CAMERA SENSOR] Fail to OFF AF power (VCAM_AF), power id = %d\n", VCAMAF);
goto _kdCISModulePowerOn_exit_;
}
/* VCAM_IO */
if (TRUE != _hwPowerDownCnt(VCAMIO))
{
PK_DBG("[CAMERA SENSOR] Fail to OFF digital power (VCAM_IO), power id = %d\n", VCAMIO);
goto _kdCISModulePowerOn_exit_;
}
/* VCAM_A */
if (TRUE != _hwPowerDownCnt(VCAMA))
{
PK_DBG("[CAMERA SENSOR] Fail to OFF analog power (VCAM_A), power id= (%d)\n", VCAMA);
goto _kdCISModulePowerOn_exit_;
}
}
//sp0a09 power down
else if (currSensorName &&
(currSensorName && (0 == strcmp(SENSOR_DRVNAME_SP0A09_MIPI_RAW, currSensorName))))
{
/* Set Reset Pin Low */
if (GPIO_CAMERA_INVALID != pinSet[pinSetIdx][IDX_PS_CMRST])
{
mtkcam_gpio_set(pinSetIdx, CAMRST, pinSet[pinSetIdx][IDX_PS_CMRST + IDX_PS_OFF]);
}
/* Set Power Pin low and Reset Pin Low */
if (GPIO_CAMERA_INVALID != pinSet[pinSetIdx][IDX_PS_CMPDN])
{
mtkcam_gpio_set(pinSetIdx, CAMPDN, pinSet[pinSetIdx][IDX_PS_CMPDN + IDX_PS_ON]);
}
/* VCAM_A */
if (TRUE != _hwPowerDownCnt(VCAMA))
{
PK_DBG("[CAMERA SENSOR] Fail to OFF analog power (VCAM_A), power id= (%d)\n", VCAMA);
goto _kdCISModulePowerOn_exit_;
}
if (TRUE != _hwPowerDownCnt(VCAMD))
{
PK_DBG("[CAMERA SENSOR] Fail to OFF core power (VCAM_D), power id = %d\n", VCAMD);
goto _kdCISModulePowerOn_exit_;
}
if (TRUE != _hwPowerDownCnt(VCAMIO))
{
PK_DBG("[CAMERA SENSOR] Fail to OFF digital power (VCAM_IO), power id = %d\n", VCAMIO);
goto _kdCISModulePowerOn_exit_;
}
if (TRUE != _hwPowerDownCnt(VCAMAF))
{
PK_DBG("[CAMERA SENSOR] Fail to OFF AF power (VCAM_AF), power id = %d\n", VCAMAF);
goto _kdCISModulePowerOn_exit_;
}
}
6.kernel层驱动代码
kernel-3.18/drivers/misc/mediatek/imgsensor/src/mt6580/bf2507_mipi_raw
kernel-3.18/drivers/misc/mediatek/imgsensor/src/mt6580/sp0a09_mipi_raw
7
vendor/mediatek/proprietary/custom/mt6580/hal/imgsensor_src/sensorlist.cpp
#if defined(BF2507_MIPI_RAW)
RAW_INFO(BF2507MIPI_SENSOR_ID, SENSOR_DRVNAME_BF2507_MIPI_RAW,NULL),
#endif
#if defined(SP0A09_MIPI_RAW)
RAW_INFO(SP0A09MIPI_SENSOR_ID, SENSOR_DRVNAME_SP0A09_MIPI_RAW, NULL),
#endif
8.hal层代码
vendor/mediatek/proprietary/custom/mt6580/hal/imgsensor/bf2507_mipi_raw
vendor/mediatek/proprietary/custom/mt6580/hal/imgsensor/sp0a09_mipi_raw
9.hal层效果代码
vendor/mediatek/proprietary/custom/mt6580/hal/sendepfeature/bf2507_mipi_raw
vendor/mediatek/proprietary/custom/mt6580/hal/sendepfeature/sp0a09_mipi_raw
10.hal层镜头自动对焦列表(只有主摄bf2507才带有自动对焦)
vendor/mediatek/proprietary/custom/mt6580/hal/lens/lenslist.cpp
MSDK_LENS_INIT_FUNCTION_STRUCT LensList_main[MAX_NUM_OF_SUPPORT_LENS] =
{
...
#if defined(DW9714AF)
{BF2507MIPI_SENSOR_ID, DW9714AF_LENS_ID, "DW9714AF", pDW9714AF_getDefaultData},
#endif
...
}
11.防止摄像头重复检测
vendor/mediatek/proprietary/hardware/mtkcam/legacy/platform/mt6580/hal/sensor/imgsensor_drv.cpp
for (i = 0; i < MAX_NUM_OF_SUPPORT_SENSOR; i++) {
...
if (SensorEnum == DUAL_CAMERA_MAIN_SENSOR &&
m_pstSensorInitFunc[i].SensorId == SP0A09MIPI_SENSOR_ID)
break;
if (SensorEnum == DUAL_CAMERA_SUB_SENSOR &&
m_pstSensorInitFunc[i].SensorId == BF2507MIPI_SENSOR_ID)
break;
...
}
12.camera cfg配置文件
customize/cfg/f1721/SJHM/main_cam/bf2507.config
customize/cfg/f1721/SJHM/sub_cam/sp0a09.config
# test pattern crc checksum value
checksum_value=0xd00d //adb shell logcat | grep crc查询crc值填写
# current sensor name
sensor_name="bf2507mipiraw"
# debug timestamp
timestamp="2018-05-05"
# sensor id should match the combined results of the read-id sequence
sensor_id=0xa507
#sensor type, RAW = 1 or SOC = 0
sensor_type=1
# slave address
sensor_i2c_write_addr=0x60
sensor_i2c_read_addr=0x61 //读比写+1
# i2c address table, maximum size of 5, must end with 0xff
i2c_addr_table=0x60,0x68,0xff
13.dts配置信息
kernel-3.18/arch/arm/boot/dts/cust_i2c.dtsi
&i2c0 {
camera_main@10 {
compatible = "mediatek,camera_main";
reg = <0x10>;
};
camera_main_af@0c {
compatible = "mediatek,camera_main_af";
reg = <0x0c>;
};
camera_sub@3c {
compatible = "mediatek,camera_sub";
reg = <0x3c>;
};
};
kernel-3.18/arch/arm/boot/dts/mt6580.dts
kd_camera_hw1:kd_camera_hw1@15008000 {
compatible = "mediatek,camera_hw";
reg = <0x15008000 0x1000>; /* SENINF_ADDR */
vcama-supply = <&mt_pmic_vcama_ldo_reg>;
vcamd-supply = <&mt_pmic_vcamd_ldo_reg>;
vcamaf-supply = <&mt_pmic_vcamaf_ldo_reg>;
vcamio-supply = <&mt_pmic_vcamio_ldo_reg>;
};
kd_camera_hw2:kd_camera_hw2@15008000 {
compatible = "mediatek,camera_hw2";
reg = <0x15008000 0x1000>; /* SENINF_ADDR */
};
kernel-3.18/arch/arm/boot/dts/k80hd_bsp_fwv_512m.dts
/* CAMERA GPIO standardization */
&pio {
camera_pins_cam0_rst0: cam0@0 {
pins_cmd_dat {
pins = ;/*GPIO_CAMERA_CMRST_PIN*/
slew-rate = <1>; /*direction 0:in, 1:out*/
output-low;/*direction out used only. output_low or high*/
};
};
camera_pins_cam0_rst1: cam0@1 {
pins_cmd_dat {
pins = ;/*GPIO_CAMERA_CMRST_PIN*/
slew-rate = <1>;
output-high;
};
};
camera_pins_cam0_pnd0: cam0@2 {
pins_cmd_dat {
pins = ;/*GPIO_CAMERA_CMPDN_PIN*/
slew-rate = <1>;
output-low;
};
};
camera_pins_cam0_pnd1: cam0@3 {
pins_cmd_dat {
pins = ;/*GPIO_CAMERA_CMPDN_PIN*/
slew-rate = <1>;
output-high;
};
};
camera_pins_cam1_rst0: cam1@0 {
pins_cmd_dat {
pins = ;/*GPIO_CAMERA_CMRST1_PIN*/
slew-rate = <1>; /*direction 0:in, 1:out*/
output-low;/*direction out used only. output_low or high*/
};
};
camera_pins_cam1_rst1: cam1@1 {
pins_cmd_dat {
pins = ;/*GPIO_CAMERA_CMRST1_PIN*/
slew-rate = <1>;
output-high;
};
};
camera_pins_cam1_pnd0: cam1@2 {
pins_cmd_dat {
pins = ;/*GPIO_CAMERA_CMPDN1_PIN*/
slew-rate = <1>;
output-low;
};
};
camera_pins_cam1_pnd1: cam1@3 {
pins_cmd_dat {
pins = ;/*GPIO_CAMERA_CMPDN1_PIN*/
slew-rate = <1>;
output-high;
};
};
camera_pins_cam_ldo0_0: cam@0 {
};
camera_pins_cam_ldo0_1: cam@1 {
};
camera_pins_default: camdefault {
};
camera_pins_cam1_gpio_serial: cam1serial@0{
pins_cmd_dat {
pins = ;
};
pins_cmd_dat1 {
pins = ;
};
pins_cmd_dat2 {
pins = ;
};
pins_cmd_dat3 {
pins = ;
};
pins_cmd_dat4 {
pins = ;
};
};
camera_pins_cam1_gpio_mipi: cam1mipi@0{
pins_cmd_dat {
pins = ;
};
pins_cmd_dat1 {
pins = ;
};
pins_cmd_dat2 {
pins = ;
};
pins_cmd_dat3 {
pins = ;
};
pins_cmd_dat4 {
pins = ;
};
pins_cmd_dat5 {
pins = ;
};
};
camera_pins_cam_mclk1_enable: mclk1enable@0{
pins_cmd_dat {
pins = ;
};
};
camera_pins_cam_mclk1_disable: mclk1disable@0{
pins_cmd_dat {
pins = ;
};
};
camera_pins_cam_mclk2_enable: mclk2enable@0{
pins_cmd_dat {
pins = ;
};
};
camera_pins_cam_mclk2_disable: mclk2disable@0{
pins_cmd_dat {
pins = ;
};
};
};
&kd_camera_hw1 {
pinctrl-names = "default", "cam0_rst0", "cam0_rst1", "cam0_pnd0", "cam0_pnd1",
"cam1_rst0", "cam1_rst1", "cam1_pnd0", "cam1_pnd1",
"cam_ldo0_0", "cam_ldo0_1", "cam1_gpio_serial", "cam1_gpio_mipi",
"cam_mclk1_enable","cam_mclk1_disable",
"cam_mclk2_enable","cam_mclk2_disable";
pinctrl-0 = <&camera_pins_default>;
pinctrl-1 = <&camera_pins_cam0_rst0>;
pinctrl-2 = <&camera_pins_cam0_rst1>;
pinctrl-3 = <&camera_pins_cam0_pnd0>;
pinctrl-4 = <&camera_pins_cam0_pnd1>;
pinctrl-5 = <&camera_pins_cam1_rst0>;
pinctrl-6 = <&camera_pins_cam1_rst1>;
pinctrl-7 = <&camera_pins_cam1_pnd0>;
pinctrl-8 = <&camera_pins_cam1_pnd1>;
pinctrl-9 = <&camera_pins_cam_ldo0_0>;
pinctrl-10 = <&camera_pins_cam_ldo0_1>;
pinctrl-11 = <&camera_pins_cam1_gpio_serial>;
pinctrl-12 = <&camera_pins_cam1_gpio_mipi>;
pinctrl-13 = <&camera_pins_cam_mclk1_enable>;
pinctrl-14 = <&camera_pins_cam_mclk1_disable>;
pinctrl-15 = <&camera_pins_cam_mclk2_enable>;
pinctrl-16 = <&camera_pins_cam_mclk2_disable>;
status = "okay";
};
/* CAMERA GPIO end */