以 fm50afsub (前摄OV5648的AF)和 fm50af(后摄OV8858的AF) 兼容为例,兼容时保持 fm50af driver不变,添加fm50afsub lens driver
1:首先修改配置projectConfig.mk,把sub camera使用的lens driver配置进去
例如sub camera使用lens driver为fm50afsub
CUSTOM_HAL_LENS = fm50af fm50afsub dummy_lens //dummy_lens一定要
CUSTOM_HAL_MAIN_BACKUP_LENS =
CUSTOM_HAL_MAIN_LENS = fm50af
CUSTOM_HAL_SUB_BACKUP_LENS =
CUSTOM_HAL_SUB_LENS = fm50afsub
CUSTOM_KERNEL_LENS = fm50af fm50afsub dummy_lens
CUSTOM_KERNEL_MAIN_BACKUP_LENS =
CUSTOM_KERNEL_MAIN_LENS = fm50af
CUSTOM_KERNEL_SUB_BACKUP_LENS =
CUSTOM_KERNEL_SUB_LENS = fm50afsub
2:修改lenslist.cpp 文件,在其中把sub camera sensor id 和lens driver关联起来
MSDK_LENS_INIT_FUNCTION_STRUCT LensList[MAX_NUM_OF_SUPPORT_LENS] =
{
{DUMMY_SENSOR_ID, DUMMY_LENS_ID, "Dummy", pDummy_getDefaultData},
#if defined(SENSORDRIVE)
{DUMMY_SENSOR_ID, SENSOR_DRIVE_LENS_ID, "kd_camera_hw", pSensorDrive_getDefaultData},
// for backup lens, need assign correct SensorID
//{OV5642_SENSOR_ID, SENSOR_DRIVE_LENS_ID, "kd_camera_hw", pSensorDrive_getDefaultData},
#endif
#if defined(OV8825AF)
{OV8825_SENSOR_ID, OV8825AF_LENS_ID, "OV8825AF", pOV8825AF_getDefaultData},
#endif
#if defined(AD5823AF)
{AR0833_SENSOR_ID, AD5823AF_LENS_ID, "AD5823AF", pAD5823AF_getDefaultData},
#endif
#if defined(FM50AF)||defined(FM50AF_OV8858_HV1A_715_LG)||defined(FM50AF_GS8604_HT1_107A_LG)
{DUMMY_SENSOR_ID, FM50AF_LENS_ID, "FM50AF", pFM50AF_getDefaultData},
#endif
#if defined(FM50AFSUB)
{DUMMY_SENSOR_ID, FM50AFSUB_LENS_ID, "FM50AFSUB", pFM50AFSUB_getDefaultData},
#endif
// for new added lens, need assign correct SensorID
#if defined(MT9P017AF)
{MT9P017MIPI_SENSOR_ID, MT9P017AF_LENS_ID, "MT9P017AF", pMT9P017AF_getDefaultData},
#endif
};
第一个ID即Sensor ID,配制成DUMMY_SENSOR_ID表示这个lens driver不会只配给某个sensor
第二个Lens ID是lens driver的唯一标识,在如下文件中配置
#define MAX_NUM_OF_SUPPORT_LENS 16
#define DUMMY_SENSOR_ID 0xFFFF
/* LENS ID */
#define DUMMY_LENS_ID 0xFFFF
#define FM50AF_LENS_ID 0x0001
#define MT9P017AF_LENS_ID 0x0002
#define SENSOR_DRIVE_LENS_ID 0x1000
#define OV8825AF_LENS_ID 0x0003
#define BU6429AF_LENS_ID 0x0004
#define BU6424AF_LENS_ID 0x0005
#define FM50AFSUB_LENS_ID 0x0006//add by ccl
#define AD5823AF_LENS_ID 0x5823
#define DW9718AF_LENS_ID 0x9718
第三个参数是Lens driver name 会生成一个设备驱动节点 如/dev/FM50AFSUB
第四个参数是指向AF tuning参数文件中的一个函数指针
3:修改文件
alps\mediatek\platform\mt65xx\hardware\camera\core\featureio\drv\lens\mcu_drv.cpp
中的lensSearch 函数
// force assign LensIdx if SensorId != DUMMY_SENSOR_ID (to support backup lens/new lens driver)
for (i=0; i
4:需要修改文件 alps\mediatek\platform\mt6592\kernel\core\mt_dev.c
修改后如下
//添加了一部分代码,注意字符串变化
//
/*=======================================================================*/
/* Lens actuator */
/*=======================================================================*/
static struct platform_device actuator_dev = {
.name = "lens_actuator",
.id = -1,
};
static struct platform_device actuator_dev1 = {
.name = "lens_actuator1",
.id = -1,
};
//
//=======================================================================
// Lens motor
//=======================================================================
#if 1 //defined(CONFIG_ACTUATOR)
retval = platform_device_register(&actuator_dev);
if (retval != 0){
return retval;
}
retval = platform_device_register(&actuator_dev1);
if (retval != 0){
return retval;
}
#endif
5:添加文件 alps\mediatek\custom\common\kernel\lens\fm50afsub\FM50AFSUB.c 和.h文件 (可以拷贝一份FM50AF.c,FM50AF.h,把所有的FM50AF换成FM50AFSUB)
修改以下几点
a):static struct i2c_board_info __initdata kd_lens_dev={ I2C_BOARD_INFO("FM50AFSUB", 0x19)}; //0x18 --> 0x19
b):#define FM50AFSUB_VCM_WRITE_ID 0x18// 改成正确的i2c write id,如果是内置的vcm ic,写成ov5648 sensor的write id,如果是外置的 vcm ic,按VCM ic的DataSheet 写
c):修改函数 Register_FM50AFSUB_CharDrv
actuator_class = class_create(THIS_MODULE, "actuatordrv1"); // actuatordrv --> actuatordrv1
d):修改函数 FM50AFSUB_i2c_probe
/* Kirby: add new-style driver { */
g_pstFM50AFSUB_I2Cclient = client;
g_pstFM50AFSUB_I2Cclient->addr = FM50AFSUB_VCM_WRITE_ID; // add
g_pstFM50AFSUB_I2Cclient->addr = g_pstFM50AFSUB_I2Cclient->addr >> 1; //打开代码
//Register char driver
i4RetValue = Register_FM50AFSUB_CharDrv();
e):g_stFM50AFSUB_Driver 变量的修改
// platform structure
static struct platform_driver g_stFM50AFSUB_Driver = {
.probe = FM50AFSUB_probe,
.remove = FM50AFSUB_remove,
.suspend = FM50AFSUB_suspend,
.resume = FM50AFSUB_resume,
.driver = {
.name = "lens_actuator1", // 这儿把 “lens_actuator” 改成 “lens_actuator1”,这里需要保持和文件mt_devs.c增加的 name一致
.owner = THIS_MODULE,
}
};
chown system camera /dev/camera-sysram
chown system camera /dev/camera-isp
chown system camera /dev/camera-pipemgr
chown system camera /dev/kd_camera_hw
chown system camera /dev/kd_camera_flashlight
chown system camera /dev/kd_camera_hw_bus2
chown system camera /dev/FM50AF
chown system camera /dev/FM50AFSUB
chown system camera /dev/DW9718AF
chown system camera /dev/OV8825AF
chown system camera /dev/CAM_CAL_DRV
FTABLE_SCENE_DEP()
//==========================================================================
#if 1
/*if(facing == 1) //front sensor
{
// Focus Mode
FTABLE_CONFIG_AS_TYPE_OF_DEFAULT_VALUES(
KEY_AS_(MtkCameraParameters::KEY_FOCUS_MODE),
SCENE_AS_DEFAULT_SCENE(
ITEM_AS_DEFAULT_(MtkCameraParameters::FOCUS_MODE_INFINITY),
ITEM_AS_VALUES_(
MtkCameraParameters::FOCUS_MODE_INFINITY,
)
),
)
}
else
{*/
// Focus Mode
FTABLE_CONFIG_AS_TYPE_OF_DEFAULT_VALUES(
KEY_AS_(MtkCameraParameters::KEY_FOCUS_MODE),
SCENE_AS_DEFAULT_SCENE(
ITEM_AS_DEFAULT_(MtkCameraParameters::FOCUS_MODE_AUTO),
ITEM_AS_VALUES_(
MtkCameraParameters::FOCUS_MODE_AUTO,
MtkCameraParameters::FOCUS_MODE_MACRO,
MtkCameraParameters::FOCUS_MODE_INFINITY,
MtkCameraParameters::FOCUS_MODE_CONTINUOUS_PICTURE,
MtkCameraParameters::FOCUS_MODE_CONTINUOUS_VIDEO,
"manual", "fullscan",
)
),
//......................................................................
)
//}
#endif