本文转载自:http://blog.csdn.net/liwei16611/article/details/53955711
1、Sensor slave配置
结构体msm_camera_sensor_slave_info定义在media/msm_cam_sensor.h中:
struct msm_camera_sensor_slave_info {
char sensor_name[32]; //sensor名称
char eeprom_name[32]; //eeprom名称
char actuator_name[32]; //actuator名称
enum msm_sensor_camera_id_t camera_id; //camera id号
uint16_t slave_addr; //从地址
enum msm_camera_i2c_reg_addr_type addr_type; //camera i2c寄存器地址类型
struct msm_sensor_id_info_t sensor_id_info; //sensor 芯片id信息
struct msm_sensor_power_setting_array power_setting_array; //上电序列
uint8_t is_init_params_vaild; //初始化参数是否有效
struct msm_sensor_init_params sensor_init_params; //sensor初始化参数
};
1.1、枚举类型msm_sensor_camera_id_t的定义如下:
enum msm_sensor_camera_id_t {
CAMERA_0, //camera id 号0
CAMERA_1, //camera id 号1
CAMERA_2, //camera id 号2
CAMERA_3, //camera id 号3
MAX_CAMERAS, //支持的最大id号
};
1.2、枚举类型msm_camera_i2c_reg_addr_type的定义如下:
enum msm_camera_i2c_reg_addr_type{
MSM_CAMERA_I2C_BYTE_ADDR = 1, //1字节型
MSM_CAMERA_I2C_WORD_ADDR, //2字型
MSM_CAMERA_I2C_3B_ADDR, //3字节型
};
1.3、结构体msm_sensor_id_info_t的定义如下:
struct msm_sensor_id_info_t{
uint16_t sensor_id_reg_addr; //对应sensor id号的寄存器地址
uint16_t sensor_id; //sensor id号
};
1.4、结构体 msm_sensor_power_setting_array的定义如下:
enum msm_sensor_power_seq_type_t{
SENSOR_CLK,
SENSOR_GPIO,
SENSOR_VREG,
SENSOR_I2C_MUX,
};
struct msm_sensor_power_setting{ //上电序列
enum msm_sensor_power_seq_type seq_type;
uint16_t seq_val;
long config_val;
uint16_t delay;
void *data[10];
};
struct msm_sensor_power_setting_array{
struct msm_sensor_power_setting *power_setting;
uint16_t size;
struct msm_sensor_power_setting *power_down_setting;
uint16_t size_down;
};
1.5、结构体msm_sensor_init_params的定义如下:
enum camb_position_t{
BACK_CAMERA_B, //后摄
FRONT_CAMERA_B, //前摄
INVALID_CAMERA_B, //非法
}
struct msm_sensor_init_params{
/* mask of modes supported: 2D, 3D */
int modes_supported; //支持camera的模式
/* sensor position: front, back */
enum camb_position_t position; //sensor的位置
/* sensor mount angle */
uint32_t sensor_mount_angle; //sensor安装的角度
};
举例:
以下是imx230_lib.c中对sensor初始化参数的设置。
支持模式的值是在枚举类型camerab_mode_t中:
enum camerab_mode_t{
CAMERA_MODE_2D_B = (1<<0), //2D
CAMERA_MODE_3D_B = (1<<1), //3D
CAMERA_MODE_INVALID = (1<<2), //非法
};
2D模式:平面图像模式。
3D模式:拍照出使裸眼观看就具有立体感的图像的模式,需要使用双摄像头。
sensor安装角度的值是宏定义,在sensor_lib.h中:
/*MOUNT ANGLE >= to this value is considered invalid in sensor lib */
#define SENSOR_MOUNTANGLE_360 360 //360度
/* Sensor mount angle. */
#define SENSOR_MOUNTANGLE_0 0 //0度
#define SENSOR_MOUNTANGLE_90 90 //90度
#define SENSOR_MOUNTANGLE_180 180 //180度
#define SENSOR_MOUNTANGLE_270 270 //270度
2.、Sensor 输出设置
2.1 、Sensor输出格式设置
输出格式:Bayer/YUV.
连接模式:parallel/MIPI. msm8974只支持MIPI.
Raw图格式:8/10/12 bits.
imx230分别设置为Bayer、MIPI、10bit。
结构体sensor_output_t 定义在sensor_lib.h中:
typedef struct{
sensor_output_format_t output_format; //输出格式
sensor_connection_mode_t connection_mode; //连接模式
sensor_raw_output_t raw_output; //raw图格式
}sensor_output_t;
其中sensor_output_format_t, sensor_connection_mode_t, sensor_raw_output_t为枚举类型,定义如下:
typedef enum{
SENSOR_BAYER, //Bayer格式
SENSOR_YCBCR //YUV格式(Y,Cb,Cr)
}sensor_output_format_t;
typedef enum{
SENSOR_PARALLEL, //并行
SENSOR_MIPI_CSI, //MIPI CSI
SENSOR_MIPI_CSI_1, //CSI1
SENSOR_MIPI_CSI_2, //CSI2
}sensor_connection_mode_t;
typedef enum{
SENSOR_8_BIT_DIRECT, //8-bit
SENSOR_10_BIT_DIRECT, //10-bit
SENSOR_12_B