Camera 配置 关键结构体

static struct msm_sensor_power_setting power_setting[] = {//上电序列

{
	.seq_type = SENSOR_GPIO, //来源,分为GPIO和VERG
	.seq_val = SENSOR_GPIO_STANDBY,//电压类型
	.config_val = GPIO_OUT_LOW,// 上电/下电 高/低
	.delay = 10, //上电时间
}

};

static struct msm_camera_sensor_slave_info sensor_slave_info = { //sensor基础信息
/* Camera slot where this camera is mounted /
.camera_id = CAMERA_0, // camera id号
/
sensor slave address /
.slave_addr = 0x6e, //从地址
/sensor i2c frequency/
.i2c_freq_mode = I2C_FAST_MODE,
/
sensor address type /
.addr_type = MSM_CAMERA_I2C_BYTE_ADDR, //camera i2c寄存器地址类型
/
sensor id info*/
.sensor_id_info = { //sensorid 信息
/* sensor id register address /
.sensor_id_reg_addr = 0xf0, //sensorid寄存器地址
/
sensor id /
.sensor_id = 0x5025, //sensorid
},
/
power up / down setting */
.power_setting_array = { //上电序列数组
.power_setting = power_setting, //上电序列
.size = ARRAY_SIZE(power_setting), //上电序列大小
},
};

static struct msm_sensor_init_params sensor_init_params = { // sensor初始化参数
.modes_supported = 0, //支持的camera类型
.position = 0, //sensor位置
.sensor_mount_angle = 90, //sensor安装角度
};

static sensor_output_t sensor_output = { //sensor输出格式设备
.output_format = SENSOR_BAYER, //输出格式
.connection_mode = SENSOR_MIPI_CSI, //连接模式,传输数据
.raw_output = SENSOR_10_BIT_DIRECT, //raw输出模式
};
static struct msm_sensor_output_reg_addr_t output_reg_addr = { //sensor输出地址设置
.x_output = 0xff, // 寄存器x_out_size的地址
.y_output = 0xff, // 寄存器y_out_size的地址
.line_length_pclk = 0xff, //寄存器 line_length_pclk 的地址
.frame_length_lines = 0xff, //寄存器 frame_length_lines 的地址
};
static struct msm_sensor_exp_gain_info_t exp_gain_info = { //曝光寄存器的地址
.coarse_int_time_addr = 0x03, //粗曝光时间寄存地址
//粗曝光 单位是lines,用来计算曝光时间,细曝光单位是 pixels,定值 不可以改变
.global_gain_addr = 0xb2, //模拟增益器寄存地址
.vert_offset = 0, //曝光行偏置
};
static sensor_aec_data_t aec_info = { //自动曝光设置参数
.max_gain = 8.0, //最大增益数
.max_linecount = 8000, //4x2000 最大曝光行数
};
static sensor_lens_info_t default_lens_info = { //镜头参数设置
.focal_length = 3.5, //焦距
.pix_size = 1.12,//像素大小
.f_number = 2.2,//光圈越小,f值越大
.total_f_dist = 1.2,
.hor_view_angle = 54.8, //水平视角
.ver_view_angle = 42.5, //垂直视角
};

static struct csi_lane_params_t csi_lane_params = {// CSI lane参数配置
.csi_lane_assign = 0xE4, //端口映射配置
.csi_lane_mask = 0x7, //标记哪一个lane被使用
.csi_if = 1, //未使用
.csid_core = {0}, //csid的硬件选择,两个并发的sensor不能使用同一个csid
.csi_phy_sel = 0,// 1:front //csi的phy设备选择,标记哪一个csi-phy设备被sensor使用,对每一个sensor来说都是独一无二的,除非有
//mipi桥接口将两个sensor连接到同一个phy.
};

static struct msm_camera_i2c_reg_setting init_reg_setting[] = {//寄存器初始化设置
{
.reg_setting = init_reg_array0, //结构体指针
.size = ARRAY_SIZE(init_reg_array0), // 结构体指针的长度
.addr_type = MSM_CAMERA_I2C_BYTE_ADDR, // 地址类型
.data_type = MSM_CAMERA_I2C_BYTE_DATA, // 数据类型
.delay = 1,//50, 延时
},
};

//group on、group off机制保护gain和shutter同时生效,gain、shutter不同时生效,会导致AE震荡。
static struct msm_camera_i2c_reg_setting groupon_settings = {
.reg_setting = groupon_reg_array,
.size = ARRAY_SIZE(groupon_reg_array),
.addr_type = MSM_CAMERA_I2C_BYTE_ADDR,
.data_type = MSM_CAMERA_I2C_BYTE_DATA,
.delay = 0,
};

static struct msm_camera_i2c_reg_setting groupoff_settings = {
.reg_setting = groupoff_reg_array,
.size = ARRAY_SIZE(groupoff_reg_array),
.addr_type = MSM_CAMERA_I2C_BYTE_ADDR,
.data_type = MSM_CAMERA_I2C_BYTE_DATA,
.delay = 0,
};
static struct msm_camera_csid_vc_cfg gc5025_cid_cfg[] = {//虚拟通道设置
{0, CSI_RAW10, CSI_DECODE_10BIT}, //通道号,数据类型,解码格式
{1, CSI_EMBED_DATA, CSI_DECODE_10BIT},
};

static struct msm_camera_csi2_params gc5025_csi_params = {// i2c的参数
.csid_params = {// csid的参数
.lane_cnt = 2, //设置lane的数目,该数目必须在sensor最大范围之内,sensor寄存器的设置必须与lane数目相同。
.lut_params = {
.num_cid = ARRAY_SIZE(gc5025_cid_cfg), //虚拟通道的个数
.vc_cfg = { //虚拟通道的参数
&gc5025_cid_cfg[0],
&gc5025_cid_cfg[1],
},
},
},
.csiphy_params = { // csiphy参数
.lane_cnt = 2, //设置lane的数目,该数目必须在sensor最大范围之内,sensor寄存器的设置必须与lane数目相同。
.settle_cnt = 0x14,//120ns 这个值要与sensor的特性匹配,保证 sensor的mipi传输和 msm的mipi传输可以同步。
},
};

static sensor_stream_info_t gc5025_stream_info[] = {//sensor数据流信息
{1, &gc5025_cid_cfg[0], rgb10}, //lane的数目、虚拟通道的参数、像素格式
{1, &gc5025_cid_cfg[1], meta},
};
static struct sensor_lib_crop_params_array crop_params_array = { //图像裁剪
.crop_params = crop_params, //裁剪参数
.size = ARRAY_SIZE(crop_params), //裁剪大小
};

static struct sensor_lib_out_info_t sensor_out_info[] = { //sensor输出尺寸
{
/* For SNAPSHOT 快照*/
.x_output = 2592, //输出给app实际宽度
.y_output = 1944, //输出给app实际高度
.line_length_pclk = 2400,//906, //原始每一帧的每一行有多少像素
.frame_length_lines = 1000,//1984 2017.2.22 //原始每一帧有多少行
.vt_pixel_clk = 72000000,//108M//54000000, //sensor扫描率
.op_pixel_clk = 216000000,//216 //sensor实际输出速率 op_pixel_clk = (sensor 输出实际比特率)/bits-per-pixel.
.binning_factor = 1, // 平均值为1,取和》1,有binning情况
.max_fps = 30.0, //最大帧率
.min_fps = 8, // 最小帧率
.mode = SENSOR_DEFAULT_MODE, //sensor分辨率对应的模式
},
static struct sensor_lib_out_info_array out_info_array = {
.out_info = sensor_out_info, //指向sensor_lib_out_info_t(Sensor输出尺寸设置)结构体的指针
.size = ARRAY_SIZE(sensor_out_info), //sensor_lib_out_info_t结构体数组长度
};

static sensor_res_cfg_type_t gc5025_res_cfg[] = {//分辨率切换设置
SENSOR_SET_STOP_STREAM, //停止传输数据
SENSOR_SET_NEW_RESOLUTION, /* set stream config 设置新的分辨率*/
SENSOR_SET_CSIPHY_CFG,//csiphy参数设置
SENSOR_SET_CSID_CFG, //csid参数设置
SENSOR_LOAD_CHROMATIX, /* set chromatix prt 加载chromatix参数 /
SENSOR_SEND_EVENT, /
send event 发送事件*/
SENSOR_SET_START_STREAM, //开始传输数据
};

static struct sensor_lib_chromatix_t gc5025_chromatix[] = {//Chromatix参数 每一种分辨率对应 的是Chromatix库文件。这里对应的是两种分辨率,设置的是相应的库文件名称。
{
.common_chromatix = GC5025_LOAD_CHROMATIX(common), //公共的
.camera_preview_chromatix = GC5025_LOAD_CHROMATIX(preview), /* RES0 预览*/
.camera_snapshot_chromatix = GC5025_LOAD_CHROMATIX(preview), /* RES0 捕获*/
.camcorder_chromatix = GC5025_LOAD_CHROMATIX(preview), /* RES0 摄像机*/
}
};

static uint16_t gc5025_real_to_register_gain(float gain)
{//注册模拟gain,返回16位无符号整型。uint16_t
uint16_t reg_gain;
if (gain < 1.0)
gain = 1.0;
if (gain > 8.0)
gain = 8.0;
// ALOGE(“gc5025_PETER,real_gain=%f” , gain);
reg_gain = (uint16_t)(gain * 64.0f);
return reg_gain;
}

/*
sensor_exposure_info_t //曝光增益gain值设置
reg_gain // 寄存器gain值
line_count //曝光行数
digital_gain //数字增益
sensor_real_gain //sensor模拟gain值
sensor_digital_gain; //sensor的数字gain值

*/
static int32_t gc5025_calculate_exposure(float real_gain,
uint16_t line_count, sensor_exposure_info_t *exp_info)
{// 获取数字gain 和 曝光行数
if (!exp_info) {
return -1;
}
exp_info->reg_gain = gc5025_real_to_register_gain(real_gain); //通过计算模拟gain值得出一个值,将他赋值给寄存器gain。
float sensor_real_gain = gc5025_register_to_real_gain(exp_info->reg_gain); //通过reg_gain得出一个值,赋值给sensor模拟gain
exp_info->digital_gain = real_gain / sensor_real_gain; // 模拟gain/sensor模拟gain 得出 数字gain
exp_info->line_count = line_count;
return 0;
}

static sensor_exposure_table_t gc5025_expsoure_tbl = {
.sensor_calculate_exposure = gc5025_calculate_exposure, // 获取数字gain 和 曝光行数
.sensor_fill_exposure_array = gc5025_fill_exposure_array,
};

//最后将所有的参数设置都放入sensor_lib_t类型的结构体sensor_lib_pt定义函数gc5025_open_lib()来返回sensor_lib_ptr的地址,供外界调用

static sensor_lib_t sensor_lib_ptr = {
/* sensor slave info sensor基础信息*/
.sensor_slave_info = &sensor_slave_info,
/* sensor init params sensor初始化参数*/
.sensor_init_params = &sensor_init_params,
/* sensor actuator name sensor名称*/
.actuator_name = “dw9714”,
/* sensor output settings sensor输出格式设备 /
.sensor_output = &sensor_output,
/
sensor output register address sensor输出地址设置注册*/
.output_reg_addr = &output_reg_addr,
/* sensor exposure gain register address 曝光时间gain注册地址*/
.exp_gain_info = &exp_gain_info,
/* sensor aec info 自动曝光信息*/
.aec_info = &aec_info,
/* sensor snapshot exposure wait frames info 传感器快照曝光等待帧信息*/
.snapshot_exp_wait_frames = 1,
/* number of frames to skip after start stream 开启流后要跳过的帧数*/
.sensor_num_frame_skip = 1, // 1 peter
/* number of frames to skip after start HDR stream 启动HDR流后要跳过的帧数*/
.sensor_num_HDR_frame_skip = 2, //add 20170103
/* sensor exposure table size 传感器曝光表尺寸 /
.exposure_table_size = 20,
/
sensor lens info 默认lens信息 /
.default_lens_info = &default_lens_info,
/
csi lane params /
.csi_lane_params = &csi_lane_params,
/
csi cid params /
.csi_cid_params = gc5025_cid_cfg,
/
csi csid params array size /
.csi_cid_params_size = ARRAY_SIZE(gc5025_cid_cfg),
/
init settings i2c的寄存器设备*/
.init_settings_array = &init_settings_array,

/* start settings 开始寄存器初始化设置、数组大小、地址类型、数据类型、延时 /
.start_settings = &start_settings,
/
stop settings 设置成功之后,停止设置*/
.stop_settings = &stop_settings,
/* group on settings 按设置分组 /
.groupon_settings = &groupon_settings,
/
group off settings 设置分组关闭*/
.groupoff_settings = &groupoff_settings,
/* resolution cfg table 分辨率cfg表*/
.sensor_res_cfg_table = &gc5025_res_table,
/* res settings 图像捕获和预览设置*/
.res_settings_array = &res_settings_array,
/* out info array sensor输出尺寸设置*/
.out_info_array = &out_info_array,
/* crop params array裁剪参数数组 /
.crop_params_array = &crop_params_array,
/
csi params array csi参数数组*/
.csi_params_array = &csi_params_array,
/* sensor port info array sensor数据流数组信息*/
.sensor_stream_info_array = &gc5025_stream_info_array,
/* exposure funtion table 获取gain曝光行数 /
.exposure_func_table = &gc5025_expsoure_tbl,
/
chromatix array //Chromatix参数*/
.chromatix_array = &gc5025_lib_chromatix_array,
};

注::
公式必记

  1. frame rate = vt_pixel_clk/(line_length_pclk*frame_length_lines)。
  2. op_pixel_clk = (sensor输出实际比特率)/ bits-per-pixel

配置参数时你需要向FE提出哪些要求?

  1. 输出拍照、预览的尺寸大小和分辨率多少
  2. fpx帧率多少,小于30会引起水波纹
  3. mipi需要几lane
  4. vblank的平台要求
  5. i2c地址,7位还是8位
  6. mipi速率多大,拍照、预览、录像的速率
上一篇:VirtualBox安装64位系统


下一篇:用SEO优化技术霸屏搜索信息的方法