【展锐】PDAF调试

驱动修改点

A:sensor_xxxx_mipi_raw.c
1.获取PD信息函数
static const cmr_u16 xxxx_pd_is_right[] = PD点位置信息,遮住右半边表示右点,用1表示,遮住左半边表示左点,用0表示;具体需要看sensor
static const cmr_u16 xxxx_pd_row[] =PD位置行坐标
static const cmr_u16 xxxx_pd_col[] = PD位置列坐标
static const struct pd_pos_info _xxxx_pd_pos_l[] = 左PD点坐标
static const struct pd_pos_info _xxxx_pd_pos_r[] = 右PD点坐标
static const cmr_u32 xxxx_pd_sns_mode[] =未配置PDAF填写0,配置PDAF填写1
static cmr_int xxxx_drv_get_pdaf_info(cmr_handle handle, cmr_u32 *param) {
    cmr_int rtn = SENSOR_SUCCESS;
    struct sensor_pdaf_info *pdaf_info = NULL;
    cmr_u16 i = 0;
    cmr_u16 pd_pos_row_size = 0;
    cmr_u16 pd_pos_col_size = 0;
    cmr_u16 pd_pos_is_right_size = 0;
    SENSOR_IC_CHECK_PTR(param);
    pdaf_info = (struct sensor_pdaf_info *)param;
    pd_pos_is_right_size = NUMBER_OF_ARRAY(xxxx_pd_is_right);
    pd_pos_row_size = NUMBER_OF_ARRAY(xxxx_pd_row);
    pd_pos_col_size = NUMBER_OF_ARRAY(xxxx_pd_col);
    if ((pd_pos_row_size != pd_pos_col_size) ||
        (pd_pos_row_size != pd_pos_is_right_size) ||
        (pd_pos_is_right_size != pd_pos_col_size)) {
        SENSOR_LOGE("pd_pos_row size and pd_pos_is_right size are not match");
        return -1;
    }
    pdaf_info->pd_offset_x =PD起始点坐标
    pdaf_info->pd_offset_y =
    pdaf_info->pd_end_x =PD结束点坐标
    pdaf_info->pd_end_y =
    pdaf_info->pd_block_w = width of basic pd pattern:0:8 ;1:16;2:32;3:64;max :3
    pdaf_info->pd_block_h =
    pdaf_info->pd_block_num_x = horizontal number of basic pd pattern
    pdaf_info->pd_block_num_y =
//
计算公式:
pd_end_x = pd_offset_x + pd_block_num_x * pd_block_w * pd_density_x
以上都可以在sensor spec中找到或者找sensor FAE要
/
    pdaf_info->pd_is_right = (cmr_u16 *)xxxx_pd_is_right;
    pdaf_info->pd_pos_row = (cmr_u16 *)xxxx_pd_row;
    pdaf_info->pd_pos_col = (cmr_u16 *)xxxx_pd_col;
    cmr_u16 pd_pos_r_size = NUMBER_OF_ARRAY(_xxxx_pd_pos_r);
    cmr_u16 pd_pos_l_size = NUMBER_OF_ARRAY(_xxxx_pd_pos_l);
    if (pd_pos_r_size != pd_pos_l_size) {
        SENSOR_LOGE("pd_pos_r size not match pd_pos_l");
        return -1;
    }
    pdaf_info->pd_pitch_x = 32;
    pdaf_info->pd_pitch_y = 32;
    pdaf_info->pd_density_x = 16;//distance between PD pairs
    pdaf_info->pd_density_y = 8;
    pdaf_info->pd_pos_size = pd_pos_r_size;
    pdaf_info->pd_pos_r = (struct pd_pos_info *)_xxxx_pd_pos_r;
    pdaf_info->pd_pos_l = (struct pd_pos_info *)_xxxx_pd_pos_l;
    pdaf_info->vendor_type = SENSOR_VENDOR_xxxx;
    pdaf_info->sns_orientation = 0; /*0 Normal, 1 mirror+flip*/
    pdaf_info->vch2_info.bypass = 0;
    pdaf_info->vch2_info.vch2_vc = 0;//VC( virtual channel mode)及DT(different data type mode)开关
    pdaf_info->vch2_info.vch2_data_type = 0; //sensor spec查找
    pdaf_info->vch2_info.vch2_mode = 0x03;  //0x01 type2 ; 0x02 virtual_channel;0x03 type3
    //type1:    只有对焦计算由平台来做,其他由sensor完成。(比如说BPC、PD检测等)
    //type2:    PD检测、对焦计算由平台来做。
    //type3:    所有的工作都由平台来做,ISP必须支持BPC校正、PD解析、对焦计算等功能。
    pdaf_info->sns_mode = xxxx_pd_sns_mode;
    return rtn;
}
以上需要填写的值可以直接找sensor FAE索要ini文件即可,也可以自己计算和查找

2.上传PD数据
    case SENSOR_VAL_TYPE_GET_PDAF_INFO:
        rtn = xxxx_drv_get_pdaf_info(handle, param_ptr->pval);

B:sensor_xxxx_mipi_raw.h
.pdaf_supported = SENSOR_PDAF_TYPEx_ENABLE

上述 pdaf_info->vendor_type = SENSOR_VENDOR_xxxx;
流程 SENSOR_VENDOR_xxxx 添加

1.cmr_sensor_info.h
SENSOR_VENDOR_xxxx 

2.pdaf_sprd_adpt.h
#define SENSOR_ID_num

3.pdaf_sprd_adpt.c
 else if (SENSOR_VENDOR_xxxx == in_p->pd_info->vendor_type) {
		cxt->pd_gobal_setting.dSensorMode = SENSOR_ID_num;
	} else {
		cxt->pd_gobal_setting.dSensorMode = SENSOR_ID_1024;
	}

确认PDAF导通debug

  1. 确认功能打开
 ispalg_bypass_init: pdaf sw bypass: 0
 pdaf_ctrl: 519, pdaf_ctrl_ioctrl: sensor don't support PDAF

2.确认PDAF type是否正确

sprd_afv1_init: is_multi_mode 0, cameraid 0, sensor_role 0, pdaf_type 0

3.确认OTP数据

PDAF OTP 无数据,异常
D PDAlgo : Calibration[1]: OTP Buffer is NULL!
PDAF OTP 有数据
D PDAlgo: SPRD OTP Data Init Start!
D PDAlgo: SPRD OTP Data Init Done!
  1. 确认软件导通
PDAlgo: PDResult: One Center Area[0] PD[-10.563253] Conf[107277] DCC[22] MAXSAD[762362] MINSAD[655085] 
有对应的PD值和 conf值 ,相位差范围:[-16,+16] , 出现上面两个值一直是0 , 则需要找算法确认原因。

5.展锐PDAF触发是通过效果调参来触发,底层驱动只负责导通和确认正常即可,如OTP的正确性

OTP dump之后通ISP工具打开确认spc和dcc数据
adb shell setprop debug.camera.save.otp.raw.data 1
data/vendor/cameraserver路径下
其实直接看Log就可以看出来,如第四步中DCC中log的数值就可以看出来,如果PD点填反了,DCC的值就是负值

1.af_sprd_adpt_v1: 1521, af_init: PDAF Tuning NULL! ——》未添加PDAF模块

调试的时候adb设置打开log,如果设置之后搜不到相关的log,那就是使能开关suppport.pd.data_support没有打开

//
adb shell setprop debug.isp.aft.mlog save //打开aft相关log
adb shell getprop debug.isp.aft.mlog //检查是否成功打开aft log
//

2.添加调整效果参数
按照文档将使能开关suppport.pd.data_support打开,之后调整下列参数
修改其中一组之后,其他组发生改变是正常的,参数设置需要满足以下条件:

pd_value_abs_trig:相位差均值*1000大于此参数设置值,才满足触发,[0][1][2]分别表示室内、室外、低亮。
越小越容易触发PD,但容易失焦,最好不小于1000。
pd_value_stable:相位差方差*1000小于此参数设置值,才满足触发。判断相位差是否稳定,越小越容易触发。
(这个值对PD触发率的影响不太大)
pd_stable_cnt:当满足其余触发条件下,有此参数设置值相应帧数都满足,才满足触发。
pd_bv_thr:控制触发的亮度条件,当BV值大于此参数设置值,才满足触发。
pd_conf_th_table:[0]-[32]表示相位差-16-16,相位差对应的信心度大于此参数设置值,才满足触发。

PDAF触发是需要下列参数都满足才会触发:

pd_data_support:设置1才能打开PDAF功能。
pd_value_abs_trig:相位差均值*1000大于此参数设置值,才满足触发。
pd_value_stable: 相位差方差*1000小于此参数设置值,才满足触发。
pd_conf_th_table:相位差对应的信心度大于此参数设置值,才满足触发。
pd_bv_thr:控制触发的亮度条件, 当BV值大于此参数设置值, 才满足触发。
pd_stable_cnt:连续N帧满足其余触发参数设定条件,才可触发。例如,pd_stable_cnt=6,
那么需要连续6帧都满足其余触发参数条件设定,才可以触发,否则不触发。

你可能感兴趣的:(camera,android)