注: 1. 37m androidM/N/O 驱动及hal代码一样,可以公用
2. 37m 与37t 驱动代码一样,hal层代码格式不一样
3. 37m 与39 驱动代码一样,只有头文件#include "kd_camera_hw.h" --> #include "kd_camera_typedef.h"
hal 层代码camera_isp_pca_gc8024mipi_raw.h、camera_isp_regs_gc8024mipi_raw.h、camera_tuning_para_gc8024mipi_raw.cpp三个格式不一样,需要参考39平台原生的imx219修改
其余一样
零、点亮新camera
1. 修改device\lentek\len6737m_35_m0\ProjectConfig.mk
CUSTOM_HAL_IMGSENSOR =gc8024_mipi_raw gc5005_mipi_raw gc2365_mipi_raw
CUSTOM_HAL_MAIN_IMGSENSOR =gc8024_mipi_raw
CUSTOM_KERNEL_IMGSENSOR =gc8024_mipi_raw gc5005_mipi_raw gc2365_mipi_raw
CUSTOM_KERNEL_MAIN_IMGSENSOR =gc8024_mipi_raw
2. 修改kernel-3.18\arch\arm\configs\len6737m_35_m0_debug_defconfig、len6737m_35_m0_defconfig
CONFIG_CUSTOM_KERNEL_IMGSENSOR="gc5005_mipi_raw gc2365_mipi_raw"(添加指定摄像头)
3. 修改device\mediatek\common\kernel-headers\kd_imgsensor.h
#define GC8024MIPI_SENSOR_ID 0x8024
#define SENSOR_DRVNAME_GC8024MIPI_RAW "gc8024mipiraw"
4. 修改kernel-3.18\drivers\misc\mediatek\imgsensor\inc\kd_imgsensor.h
#define GC8024MIPI_SENSOR_ID 0x8024
#define SENSOR_DRVNAME_GC8024MIPI_RAW "gc8024mipiraw"
5. 添加驱动代码,放到kernel-3.18\drivers\misc\mediatek\imgsensor\src\mt6735m\
创建文件夹gc8024_mipi_raw文件夹中包含gc8024mipi_Sensor.c、gc8024mipi_Sensor.h、Makefile
6. 修改kernel-3.18\drivers\misc\mediatek\imgsensor\src\mt6735m\camera_hw\kd_camera_hw.c
6.1 上电时序
//POWER ON
if (On) {
if ((currSensorName && (0 == strcmp(SENSOR_DRVNAME_GC8024MIPI_RAW, currSensorName))) ||
(currSensorName && (0 == strcmp(SENSOR_DRVNAME_GC5005MIPI_RAW, currSensorName))))
{
// VCM_D
if((currSensorName && (0 == strcmp(SENSOR_DRVNAME_GC8024MIPI_RAW, currSensorName))) ||
(currSensorName && (0 == strcmp(SENSOR_DRVNAME_GC5005MIPI_RAW, currSensorName))))
{}
}
}
6.2 掉电时序(三个相同)
//POWER OFF
else{
if((currSensorName && (0 == strcmp(SENSOR_DRVNAME_GC8024MIPI_RAW, currSensorName))) ||
(currSensorName && (0 == strcmp(SENSOR_DRVNAME_GC5005MIPI_RAW, currSensorName))) ||
(currSensorName && (0 == strcmp(SENSOR_DRVNAME_GC2365MIPI_RAW, currSensorName))))
{}
}
7. 修改kernel-3.18\drivers\misc\mediatek\imgsensor\src\mt6735m\kd_sensorlist.h
UINT32 GC8024MIPI_RAW_SensorInit(PSENSOR_FUNCTION_STRUCT *pfFunc);
#if defined(GC8024_MIPI_RAW)
{GC8024MIPI_SENSOR_ID, SENSOR_DRVNAME_GC8024MIPI_RAW,GC8024MIPI_RAW_SensorInit},
#endif
====================================以下是HAL层====================================
8. 添加HAL层代码vendor\mediatek\proprietary\custom\mt6735\hal\D2\imgsensor
创建文件夹gc8024_mipi_raw文件夹中包含camera_flicker_para_gc8024mipi_raw.cpp等文件
9. 修改vendor\mediatek\proprietary\custom\mt6735\hal\D2\imgsensor_src\sensorlist.cpp
注意:此处camera IC的顺序应该跟kd_sensorlist.h中的顺序一致
#if defined(GC8024_MIPI_RAW)
RAW_INFO(GC8024MIPI_SENSOR_ID, SENSOR_DRVNAME_GC8024MIPI_RAW,NULL),
#endif
10. 添加cameraHAL层插值文件vendor\mediatek\proprietary\custom\mt6735\hal\D2\sendepfeature
添加文件夹gc8024_mipi_raw,里面添加文件config.ftbl.gc8024mipi_raw.h
注意:第十步,可不要,有默认配置可用
零一、mt6739平台(kernel-4.4 以vd6955cm_mipi_raw为例):
1. device/mediatek/common/kernel-headers/kd_imgsensor.h
+ #define VD6955CMMIPI_SENSOR_ID 0x07A3
+ #define SENSOR_DRVNAME_VD6955CMMIPI_RAW "vd6955cm_mipi_raw"
2. kernel-4.4/drivers/misc/mediatek/imgsensor/inc/kd_imgsensor.h
+ #define SENSOR_DRVNAME_VD6955CMMIPI_RAW "vd6955cm_mipi_raw"
3. 【这一步有的camera不需要,还是搞明白】kernel-4.4/drivers/misc/mediatek/imgsensor/src/common/v1/imgsensor_hw.c
+ if(curr_sensor_name&&(0 == strcmp(SENSOR_DRVNAME_VD6955CMMIPI_RAW, curr_sensor_name))){
+ if(sensor_idx == 1){
+ return IMGSENSOR_RETURN_ERROR;
+ }
+ }
imgsensor_hw_power_sequence(); // 在这个函数之前
4. kernel-4.4/drivers/misc/mediatek/imgsensor/src/common/v1/imgsensor_sensor_list.c
+ #if defined(VD6955CM_MIPI_RAW)
+ {VD6955CMMIPI_SENSOR_ID, SENSOR_DRVNAME_VD6955CMMIPI_RAW, VD6955CMMIPI_RAW_SensorInit},
+ #endif
5. kernel-4.4/drivers/misc/mediatek/imgsensor/src/common/v1/imgsensor_sensor_list.h
+ UINT32 VD6955CMMIPI_RAW_SensorInit(PSENSOR_FUNCTION_STRUCT *pfFunc);
6. kernel-4.4/drivers/misc/mediatek/imgsensor/src/mt6739/camera_hw/imgsensor_cfg_table.c
+ #if defined(VD6955CM_MIPI_RAW)
+ {
+ SENSOR_DRVNAME_VD6955CMMIPI_RAW,
+ {
+ {SensorMCLK, Vol_High, 0},
+ {AVDD, Vol_2800, 10},
+ {DOVDD, Vol_1800, 10},
+ {DVDD, Vol_1500, 10},
+ {AFVDD, Vol_2800, 5},
+ {PDN, Vol_Low, 0},
+ {PDN, Vol_High, 0},
+ {RST, Vol_Low, 0},
+ {RST, Vol_High, 0}
+ },
+ },
+ #endif
7. kernel-4.4/drivers/misc/mediatek/imgsensor/src/mt6739/目录下新建文件夹: vd6955cm_mipi_raw
包含5个文件
Makefile
vd6955cmmipiraw_CameraCustomized.h
vd6955cmmipiraw_Camera_Sensor_para.h
vd6955cmmipiraw_Sensor.c
vd6955cmmipiraw_Sensor.h
8. vendor/mediatek/proprietary/custom/mt6739/hal/imgsensor/目录下新建文件夹: vd6955cm_mipi_raw
包含11个文件
camera_AE_PLineTable_vd6955cmmipiraw.h
camera_feature_para_vd6955cmmipiraw.h
camera_flash_awb_para_vd6955cmmipiraw.h
camera_flicker_para_vd6955cmmipiraw.cpp
camera_info_vd6955cmmipiraw.h
camera_isp_lsc_vd6955cmmipiraw.h
camera_isp_pca_vd6955cmmipiraw.h
camera_isp_regs_vd6955cmmipiraw.h
camera_tsf_data_vd6955cmmipiraw.h
camera_tsf_para_vd6955cmmipiraw.h
camera_tuning_para_vd6955cmmipiraw.cpp
9. vendor/mediatek/proprietary/custom/mt6739/hal/imgsensor_src/sensorlist.cpp
+ #if defined(VD6955CM_MIPI_RAW)
+ RAW_INFO(VD6955CMMIPI_SENSOR_ID, SENSOR_DRVNAME_VD6955CMMIPI_RAW, NULL),
+ #endif
10. vendor/mediatek/proprietary/custom/mt6739/hal/lens/src/lenslist.cpp
MSDK_LENS_INIT_FUNCTION_STRUCT LensList_main[MAX_NUM_OF_SUPPORT_LENS] =
{
{DUMMY_SENSOR_ID, DUMMY_LENS_ID, "Dummy", pDummy_getDefaultData},
#if defined(FM50AF)
+ {VD6955CMMIPI_SENSOR_ID, FM50AF_LENS_ID, "FM50AF", pFM50AF_getDefaultData},
11. vendor/mediatek/proprietary/custom/mt6739/hal/sendepfeature/目录下新建文件夹: vd6955cm_mipi_raw
包含1个文件
config.ftbl.vd6955cm_mipi_raw.h
追加、关于上电:
1. 关于Camera 上电
AVDD = 2.8V (依据芯片规格,目前为止调试的芯片均为2.8V)
AFVDD = 2.8V (自动对焦马达电压,目前为止调试的芯片均为2.8V)
IOVDD = 1.8V (MTK 平台IO即I2C 电压均为1.8V)
DVDD = 1.8V (依据芯片不同进行定义如IMX219 DVDD=1.2V)// DVDD 若软件配置不匹配会导致读不到ID, I2C不通
MT6735/37等4G平台只能支持到1.5V DVDD
MT6580/70/72等可以支持到1.8V DVDD
一、摄像头上下左右颠倒
1. 格科的GC系列: 驱动中都有相关的宏可以控制 - 开关就行(四选一)
#define IMAGE_NO_MIRROR
//#define IMAGE_H_MIRROR
//#define IMAGE_V_MIRROR
//#define IMAGE_HV_MIRROR
2. 思比科的sp系列 与 ov公司的ov系列 与 sony 的imx系列 :
2.1 可以直接修改驱动中的寄存器,各个ic的寄存器不一
2.2 用以下方式实现,本质也是修改寄存器,只是封装成了一个函数:
static imgsensor_struct imgsensor = {
.mirror = IMAGE_HV_MIRROR, // 跟格科的一样有四种
static void set_mirror_flip(kal_uint8 image_mirror) // 在以下四个地方需要调用这个函数
preview(){
set_mirror_flip(IMAGE_HV_MIRROR);
return ERROR_NONE;
}
capture(){
set_mirror_flip(IMAGE_HV_MIRROR);
return ERROR_NONE;
}
normal_video(){
set_mirror_flip(IMAGE_HV_MIRROR);
return ERROR_NONE;
}
hs_video(){
set_mirror_flip(IMAGE_HV_MIRROR);
return ERROR_NONE;
}
3. hal层还有一个地方可以改,作用与所有摄像头
vendor/mediatek/proprietary/custom/mt6735/hal/D2/imgsensor_src/cfg_setting_imgsensor.cpp
static SensorOrientation_T const inst = {
u4Degree_0 : 90, // main sensor in degree (0, 90, 180, 270)
u4Degree_1 : 270, // sub sensor in degree (0, 90, 180, 270)
u4Degree_2 : 90, // main2 sensor in degree (0, 90, 180, 270)
};
二、后副摄
1.测试后副摄是否调通[微掌]
1.1 cat /proc/driver/dualcam_brightness // 1 -- 光线强 0 -- 光线弱 有变化说明驱动通了,但是没有虚化效果,是因为上层的宏没配
1.2 上层的宏,临时开关,不能提交:
Z:\code5_37_n_base_oule_user\update\alps\system_conf.sh
KST_BeautySnap=4
GANGYUN_BOKEH_SUPPORT=yes
KST_GANGYUN_BOKEH_SUPPORT=1
KST_OPEN_DOUBLE_CAMERA=yes
1.3 cat /sys/bus/platform/drivers/image_sensor/yuv_shutter // 可以获得亮度值
1.4 查看是否读到id(这里看不到后副摄)
cat /proc/driver/camera_info
三、调试方法
1.查看硬件原理图连接--MCLK
经查看v661_bst_k1项目,前后摄连接在同一个MCLK上
2.查看硬件原理图连接--i2c_num
经查看v661_bst_k1项目,前摄连接在i2c总线2上
i2c_num 写在dws中 - 没有写错
四、AF(len)调试
1.对焦框不能变绿(变绿代表对焦ok)
修改alps/vendor/mediatek/proprietary/custom/mt6735/hal/D1/lens/fm50af/lens_para_FM50AF.cpp
- 2, // i4AFC_FAIL_CNT
+ 5, // i4AFC_FAIL_CNT 增大循环次数,改善概率性马达对焦时间长的问题。(四个地方都改)
四一、“自动闪光”亮处也闪 - 减小参数
修改alps\vendor\mediatek\proprietary\custom\mt6735\hal\D2\imgsensor\imx219_mipi_raw\camera_AE_PLineTable_imx219mipiraw.h
- 3, //u4StrobeTrigerBV
+ -10, //u4StrobeTrigerBV -- 共有20多处,全部改过来
五、FlashLight调试
1.hal层代码合入(根据FAE提供),只需要修改engTab[],其余不动
alps\vendor\mediatek\proprietary\custom\mt6735\hal\D2\flashlight\flash_tuning_custom_cct.cpp
int cust_fillDefaultStrobeNVRam_main (void* data)
{
int i;
NVRAM_CAMERA_STROBE_STRUCT* p;
p = (NVRAM_CAMERA_STROBE_STRUCT*)data;
static short engTab[]=
- {1339,1940,2505,3586,4562,5486,6348,7168,7943,8665,9349,9999};
+ #if defined(KST_V618_P300) // 添加宏控,在mk文件中配上:KST_MISC_CUSTOM= KST_V618_P300
+ {9633,9872,9999,9292,9450,9815,9757,9282,9667,8884,8969,8962}; // 这一串数组来自FAE提供
+ #else
+ {1339,1940,2505,3586,4562,5486,6348,7168,7943,8665,9349,9999};
+ #endif
六、TSF - 需要先由项目经理联系mtk,mtk处理后返回代码,由驱动工程师合入
1.邮件联系mtk:
欧乐V618-P300后摄GC8024需要做TSF 具体信息如下:
1.公司备案项目名: V618
2.模组具体型号: GC8024
3.OB值: 0
4.是否带OTP: 否
5.符合命名规则的raw文件:http://pan.baidu.com/s/1dFOnZX3 // 几十张RAW图像
2.mtk返回代码:
camera_tsf_data.h
camera_tsf_para.h
3.合入到hal层效果代码:
alps\vendor\mediatek\proprietary\custom\mt6735\hal\D2\imgsensor\gc8024mipi_raw\camera_tsf_data_gc8024mipi_raw.h
alps\vendor\mediatek\proprietary\custom\mt6735\hal\D2\imgsensor\gc8024mipi_raw\camera_tsf_para_gc8024mipi_raw.h
4.使能TSF,并#include两个TSF.h文件
修改alps\vendor\mediatek\proprietary\custom\mt6735\hal\D2\imgsensor\gc8024mipi_raw\camera_tuning_para_gc8024mipi_raw.cpp
const CAMERA_TSF_TBL_STRUCT CAMERA_TSF_DEFAULT_VALUE =
{
{
1, // isTsfEn // 1 - 使能TSF 0 - 失能TSF
2, // tsfCtIdx
{20, 2000, -110, -110, 512, 512, 512, 0} // rAWBInput[8]
},
#include INCLUDE_FILENAME_TSF_PARA // #define INCLUDE_FILENAME_TSF_PARA "camera_tsf_para_gc8024mipi_raw.h"
#include INCLUDE_FILENAME_TSF_DATA // #define INCLUDE_FILENAME_TSF_DATA "camera_tsf_data_gc8024mipi_raw.h"
};
4. camera调试日志
最新推荐文章于 2024-08-15 14:24:53 发布
本文详细记录了在Android MTK平台(如MT6735、MT6739)上调试摄像头驱动的过程,包括如何修改Kernel和HAL层的配置,如添加传感器驱动、调整电源时序、解决读取ID失败等问题,以及如何处理摄像头翻转、对焦、EIS等技术细节。此外,还列举了多个实际遇到的案例,如不同摄像头型号的适配问题和解决方法。
摘要由CSDN通过智能技术生成