blob: 47cf1848b3607b85e4c325940b492a3d43aa6b88 [file] [log] [blame]
Shuzhen Wangb4f4c922013-01-08 14:32:08 -08001#ifndef __LINUX_MSM_CAM_SENSOR_H
2#define __LINUX_MSM_CAM_SENSOR_H
3
4#ifdef MSM_CAMERA_BIONIC
5#include <sys/types.h>
6#endif
7#include <linux/types.h>
8#include <linux/v4l2-mediabus.h>
9#include <linux/i2c.h>
10
11#define I2C_SEQ_REG_SETTING_MAX 5
12#define I2C_SEQ_REG_DATA_MAX 20
13#define MAX_CID 16
14
15#define MSM_SENSOR_MCLK_8HZ 8000000
16#define MSM_SENSOR_MCLK_16HZ 16000000
17#define MSM_SENSOR_MCLK_24HZ 24000000
18
19#define GPIO_OUT_LOW (0 << 1)
20#define GPIO_OUT_HIGH (1 << 1)
21
22#define CSI_EMBED_DATA 0x12
23#define CSI_RESERVED_DATA_0 0x13
24#define CSI_YUV422_8 0x1E
25#define CSI_RAW8 0x2A
26#define CSI_RAW10 0x2B
27#define CSI_RAW12 0x2C
28
29#define CSI_DECODE_6BIT 0
30#define CSI_DECODE_8BIT 1
31#define CSI_DECODE_10BIT 2
32#define CSI_DECODE_DPCM_10_8_10 5
33
34#define MAX_SENSOR_NAME 32
35
Sreesudhan Ramakrish Ramkumar6acf6252013-01-26 21:26:13 -080036#define MAX_ACT_MOD_NAME_SIZE 32
37#define MAX_ACT_NAME_SIZE 32
38#define NUM_ACTUATOR_DIR 2
39#define MAX_ACTUATOR_SCENARIO 8
40#define MAX_ACTUATOR_REGION 5
41#define MAX_ACTUATOR_INIT_SET 12
42#define MAX_ACTUATOR_REG_TBL_SIZE 8
43
44#define MOVE_NEAR 0
45#define MOVE_FAR 1
46
Jeyaprakash Soundrapandian651d64e2013-03-11 12:04:55 -070047#define MAX_EEPROM_NAME 32
48
Shuzhen Wangb4f4c922013-01-08 14:32:08 -080049enum msm_camera_i2c_reg_addr_type {
50 MSM_CAMERA_I2C_BYTE_ADDR = 1,
51 MSM_CAMERA_I2C_WORD_ADDR,
Junjie Wu1d4e60d2013-03-13 20:17:15 -070052 MSM_CAMERA_I2C_3B_ADDR,
Shuzhen Wangb4f4c922013-01-08 14:32:08 -080053};
54
55enum msm_camera_i2c_data_type {
56 MSM_CAMERA_I2C_BYTE_DATA = 1,
57 MSM_CAMERA_I2C_WORD_DATA,
58 MSM_CAMERA_I2C_SET_BYTE_MASK,
59 MSM_CAMERA_I2C_UNSET_BYTE_MASK,
60 MSM_CAMERA_I2C_SET_WORD_MASK,
61 MSM_CAMERA_I2C_UNSET_WORD_MASK,
62 MSM_CAMERA_I2C_SET_BYTE_WRITE_MASK_DATA,
63};
64
65enum msm_sensor_power_seq_type_t {
66 SENSOR_CLK,
67 SENSOR_GPIO,
68 SENSOR_VREG,
69 SENSOR_I2C_MUX,
70};
71
72enum msm_sensor_clk_type_t {
73 SENSOR_CAM_MCLK,
74 SENSOR_CAM_CLK,
75 SENSOR_CAM_CLK_MAX,
76};
77
78enum msm_sensor_power_seq_gpio_t {
79 SENSOR_GPIO_RESET,
80 SENSOR_GPIO_STANDBY,
81 SENSOR_GPIO_MAX,
82};
83
84enum msm_camera_vreg_name_t {
85 CAM_VDIG,
86 CAM_VIO,
87 CAM_VANA,
88 CAM_VAF,
89 CAM_VREG_MAX,
90};
91
92enum msm_sensor_resolution_t {
93 MSM_SENSOR_RES_FULL,
94 MSM_SENSOR_RES_QTR,
95 MSM_SENSOR_RES_2,
96 MSM_SENSOR_RES_3,
97 MSM_SENSOR_RES_4,
98 MSM_SENSOR_RES_5,
99 MSM_SENSOR_RES_6,
100 MSM_SENSOR_RES_7,
101 MSM_SENSOR_INVALID_RES,
102};
103
104enum sensor_sub_module_t {
105 SUB_MODULE_SENSOR,
106 SUB_MODULE_CHROMATIX,
107 SUB_MODULE_ACTUATOR,
108 SUB_MODULE_EEPROM,
109 SUB_MODULE_LED_FLASH,
110 SUB_MODULE_STROBE_FLASH,
Shuzhen Wangb4f4c922013-01-08 14:32:08 -0800111 SUB_MODULE_CSID,
112 SUB_MODULE_CSID_3D,
Evgeniy Borisov92cd5702013-04-19 13:06:16 -0700113 SUB_MODULE_CSIPHY,
114 SUB_MODULE_CSIPHY_3D,
Shuzhen Wangb4f4c922013-01-08 14:32:08 -0800115 SUB_MODULE_MAX,
116};
117
118enum csid_cfg_type_t {
119 CSID_INIT,
120 CSID_CFG,
121 CSID_RELEASE,
122};
123
124enum csiphy_cfg_type_t {
125 CSIPHY_INIT,
126 CSIPHY_CFG,
127 CSIPHY_RELEASE,
128};
129
130enum camera_vreg_type {
131 REG_LDO,
132 REG_VS,
133 REG_GPIO,
134};
135
136struct msm_sensor_power_setting {
137 enum msm_sensor_power_seq_type_t seq_type;
138 uint16_t seq_val;
139 long config_val;
140 uint16_t delay;
141 void *data[10];
142};
143
144struct msm_sensor_power_setting_array {
145 struct msm_sensor_power_setting *power_setting;
146 uint16_t size;
147};
148
149struct msm_sensor_id_info_t {
150 uint16_t sensor_id_reg_addr;
151 uint16_t sensor_id;
152};
153
154struct msm_camera_sensor_slave_info {
155 uint16_t slave_addr;
156 enum msm_camera_i2c_reg_addr_type addr_type;
157 struct msm_sensor_id_info_t sensor_id_info;
158 struct msm_sensor_power_setting_array power_setting_array;
159};
160
161struct msm_camera_i2c_reg_array {
162 uint16_t reg_addr;
163 uint16_t reg_data;
164};
165
166struct msm_camera_i2c_reg_setting {
167 struct msm_camera_i2c_reg_array *reg_setting;
168 uint16_t size;
169 enum msm_camera_i2c_reg_addr_type addr_type;
170 enum msm_camera_i2c_data_type data_type;
171 uint16_t delay;
172};
173
174struct msm_camera_i2c_seq_reg_array {
175 uint16_t reg_addr;
176 uint8_t reg_data[I2C_SEQ_REG_DATA_MAX];
177 uint16_t reg_data_size;
178};
179
180struct msm_camera_i2c_seq_reg_setting {
181 struct msm_camera_i2c_seq_reg_array *reg_setting;
182 uint16_t size;
183 enum msm_camera_i2c_reg_addr_type addr_type;
184 uint16_t delay;
185};
186
187struct msm_camera_csid_vc_cfg {
188 uint8_t cid;
189 uint8_t dt;
190 uint8_t decode_format;
191};
192
193struct msm_camera_csid_lut_params {
194 uint8_t num_cid;
195 struct msm_camera_csid_vc_cfg *vc_cfg[MAX_CID];
196};
197
198struct msm_camera_csid_params {
199 uint8_t lane_cnt;
200 uint16_t lane_assign;
201 uint8_t phy_sel;
202 struct msm_camera_csid_lut_params lut_params;
203};
204
205struct msm_camera_csiphy_params {
206 uint8_t lane_cnt;
207 uint8_t settle_cnt;
208 uint16_t lane_mask;
209 uint8_t combo_mode;
Evgeniy Borisov4de53312013-03-27 05:14:41 -0700210 uint8_t csid_core;
Shuzhen Wangb4f4c922013-01-08 14:32:08 -0800211};
212
213struct msm_camera_csi2_params {
214 struct msm_camera_csid_params csid_params;
215 struct msm_camera_csiphy_params csiphy_params;
216};
217
218struct msm_camera_csi_lane_params {
219 uint16_t csi_lane_assign;
220 uint16_t csi_lane_mask;
221};
222
223struct csi_lane_params_t {
224 uint16_t csi_lane_assign;
225 uint8_t csi_lane_mask;
226 uint8_t csi_if;
227 uint8_t csid_core[2];
228 uint8_t csi_phy_sel;
229};
230
231struct msm_sensor_info_t {
232 char sensor_name[MAX_SENSOR_NAME];
233 int32_t session_id;
234 int32_t subdev_id[SUB_MODULE_MAX];
235};
236
237struct camera_vreg_t {
238 const char *reg_name;
239 enum camera_vreg_type type;
240 int min_voltage;
241 int max_voltage;
242 int op_mode;
243 uint32_t delay;
244};
245
246enum camb_position_t {
247 BACK_CAMERA_B,
248 FRONT_CAMERA_B,
249};
250
251enum camerab_mode_t {
252 CAMERA_MODE_2D_B = (1<<0),
253 CAMERA_MODE_3D_B = (1<<1)
254};
255
256struct msm_sensor_init_params {
257 /* mask of modes supported: 2D, 3D */
258 int modes_supported;
259 /* sensor position: front, back */
260 enum camb_position_t position;
261 /* sensor mount angle */
262 uint32_t sensor_mount_angle;
263};
264
265struct sensorb_cfg_data {
266 int cfgtype;
267 union {
268 struct msm_sensor_info_t sensor_info;
269 struct msm_sensor_init_params sensor_init_params;
270 void *setting;
271 } cfg;
272};
273
274struct csid_cfg_data {
275 enum csid_cfg_type_t cfgtype;
276 union {
277 uint32_t csid_version;
278 struct msm_camera_csid_params *csid_params;
279 } cfg;
280};
281
282struct csiphy_cfg_data {
283 enum csiphy_cfg_type_t cfgtype;
284 union {
285 struct msm_camera_csiphy_params *csiphy_params;
286 struct msm_camera_csi_lane_params *csi_lane_params;
287 } cfg;
288};
289
Jeyaprakash Soundrapandian651d64e2013-03-11 12:04:55 -0700290enum eeprom_cfg_type_t {
291 CFG_EEPROM_GET_INFO,
Junjie Wu59986c72013-05-02 13:39:15 -0700292 CFG_EEPROM_GET_CAL_DATA,
293 CFG_EEPROM_READ_CAL_DATA,
Jeyaprakash Soundrapandian651d64e2013-03-11 12:04:55 -0700294 CFG_EEPROM_WRITE_DATA,
295};
296struct eeprom_get_t {
297 uint16_t num_bytes;
298};
299
300struct eeprom_read_t {
301 uint8_t *dbuffer;
302 uint16_t num_bytes;
303};
304
305struct eeprom_write_t {
306 uint8_t *dbuffer;
307 uint16_t num_bytes;
308};
309
310struct msm_eeprom_cfg_data {
311 enum eeprom_cfg_type_t cfgtype;
312 uint8_t is_supported;
313 union {
314 char eeprom_name[MAX_SENSOR_NAME];
315 struct eeprom_get_t get_data;
316 struct eeprom_read_t read_data;
317 struct eeprom_write_t write_data;
318 } cfg;
319};
320
Shuzhen Wangb4f4c922013-01-08 14:32:08 -0800321enum msm_sensor_cfg_type_t {
322 CFG_SET_SLAVE_INFO,
323 CFG_WRITE_I2C_ARRAY,
324 CFG_WRITE_I2C_SEQ_ARRAY,
325 CFG_POWER_UP,
326 CFG_POWER_DOWN,
327 CFG_SET_STOP_STREAM_SETTING,
328 CFG_GET_SENSOR_INFO,
329 CFG_GET_SENSOR_INIT_PARAMS,
Rajakumar Govindaram6ad72872013-01-29 18:36:13 -0800330 CFG_SET_INIT_SETTING,
331 CFG_SET_RESOLUTION,
332 CFG_SET_STOP_STREAM,
333 CFG_SET_START_STREAM,
Shuzhen Wangb4f4c922013-01-08 14:32:08 -0800334};
335
Sreesudhan Ramakrish Ramkumar6acf6252013-01-26 21:26:13 -0800336enum msm_actuator_cfg_type_t {
337 CFG_GET_ACTUATOR_INFO,
338 CFG_SET_ACTUATOR_INFO,
339 CFG_SET_DEFAULT_FOCUS,
340 CFG_MOVE_FOCUS,
341};
342
343enum actuator_type {
344 ACTUATOR_VCM,
345 ACTUATOR_PIEZO,
346};
347
348enum msm_actuator_data_type {
349 MSM_ACTUATOR_BYTE_DATA = 1,
350 MSM_ACTUATOR_WORD_DATA,
351};
352
353enum msm_actuator_addr_type {
354 MSM_ACTUATOR_BYTE_ADDR = 1,
355 MSM_ACTUATOR_WORD_ADDR,
356};
357
358struct reg_settings_t {
359 uint16_t reg_addr;
360 uint16_t reg_data;
361};
362
363struct region_params_t {
364 /* [0] = ForwardDirection Macro boundary
365 [1] = ReverseDirection Inf boundary
366 */
367 uint16_t step_bound[2];
368 uint16_t code_per_step;
369};
370
371struct damping_params_t {
372 uint32_t damping_step;
373 uint32_t damping_delay;
374 uint32_t hw_params;
375};
376
377struct msm_actuator_move_params_t {
378 int8_t dir;
379 int8_t sign_dir;
380 int16_t dest_step_pos;
381 int32_t num_steps;
382 struct damping_params_t *ringing_params;
383};
384
385struct msm_actuator_tuning_params_t {
386 int16_t initial_code;
387 uint16_t pwd_step;
388 uint16_t region_size;
389 uint32_t total_steps;
390 struct region_params_t *region_params;
391};
392
393struct msm_actuator_params_t {
394 enum actuator_type act_type;
395 uint8_t reg_tbl_size;
396 uint16_t data_size;
397 uint16_t init_setting_size;
398 uint32_t i2c_addr;
399 enum msm_actuator_addr_type i2c_addr_type;
400 enum msm_actuator_data_type i2c_data_type;
401 struct msm_actuator_reg_params_t *reg_tbl_params;
402 struct reg_settings_t *init_settings;
403};
404
405struct msm_actuator_set_info_t {
406 struct msm_actuator_params_t actuator_params;
407 struct msm_actuator_tuning_params_t af_tuning_params;
408};
409
410struct msm_actuator_get_info_t {
411 uint32_t focal_length_num;
412 uint32_t focal_length_den;
413 uint32_t f_number_num;
414 uint32_t f_number_den;
415 uint32_t f_pix_num;
416 uint32_t f_pix_den;
417 uint32_t total_f_dist_num;
418 uint32_t total_f_dist_den;
419 uint32_t hor_view_angle_num;
420 uint32_t hor_view_angle_den;
421 uint32_t ver_view_angle_num;
422 uint32_t ver_view_angle_den;
423};
424
425enum af_camera_name {
426 ACTUATOR_MAIN_CAM_0,
427 ACTUATOR_MAIN_CAM_1,
428 ACTUATOR_MAIN_CAM_2,
429 ACTUATOR_MAIN_CAM_3,
430 ACTUATOR_MAIN_CAM_4,
431 ACTUATOR_MAIN_CAM_5,
432 ACTUATOR_WEB_CAM_0,
433 ACTUATOR_WEB_CAM_1,
434 ACTUATOR_WEB_CAM_2,
435};
436
437struct msm_actuator_cfg_data {
438 int cfgtype;
439 uint8_t is_af_supported;
440 union {
441 struct msm_actuator_move_params_t move;
442 struct msm_actuator_set_info_t set_info;
443 struct msm_actuator_get_info_t get_info;
444 enum af_camera_name cam_name;
445 } cfg;
446};
447
448enum msm_actuator_write_type {
449 MSM_ACTUATOR_WRITE_HW_DAMP,
450 MSM_ACTUATOR_WRITE_DAC,
451};
452
453struct msm_actuator_reg_params_t {
454 enum msm_actuator_write_type reg_write_type;
455 uint32_t hw_mask;
456 uint16_t reg_addr;
457 uint16_t hw_shift;
458 uint16_t data_shift;
459};
460
Sreesudhan Ramakrish Ramkumard78de4f2013-02-05 02:25:59 -0800461enum msm_camera_led_config_t {
462 MSM_CAMERA_LED_OFF,
463 MSM_CAMERA_LED_LOW,
464 MSM_CAMERA_LED_HIGH,
465 MSM_CAMERA_LED_INIT,
466 MSM_CAMERA_LED_RELEASE,
467};
468
469struct msm_camera_led_cfg_t {
470 enum msm_camera_led_config_t cfgtype;
471};
472
Shuzhen Wangb4f4c922013-01-08 14:32:08 -0800473#define VIDIOC_MSM_SENSOR_CFG \
474 _IOWR('V', BASE_VIDIOC_PRIVATE + 1, struct sensorb_cfg_data)
475
476#define VIDIOC_MSM_SENSOR_RELEASE \
477 _IO('V', BASE_VIDIOC_PRIVATE + 2)
478
479#define VIDIOC_MSM_SENSOR_GET_SUBDEV_ID \
480 _IOWR('V', BASE_VIDIOC_PRIVATE + 3, uint32_t)
481
482#define VIDIOC_MSM_CSIPHY_IO_CFG \
483 _IOWR('V', BASE_VIDIOC_PRIVATE + 4, struct csid_cfg_data)
484
485#define VIDIOC_MSM_CSID_IO_CFG \
486 _IOWR('V', BASE_VIDIOC_PRIVATE + 5, struct csiphy_cfg_data)
487
Sreesudhan Ramakrish Ramkumar6acf6252013-01-26 21:26:13 -0800488#define VIDIOC_MSM_ACTUATOR_CFG \
489 _IOWR('V', BASE_VIDIOC_PRIVATE + 6, struct msm_actuator_cfg_data)
490
Sreesudhan Ramakrish Ramkumard78de4f2013-02-05 02:25:59 -0800491#define VIDIOC_MSM_FLASH_LED_DATA_CFG \
492 _IOWR('V', BASE_VIDIOC_PRIVATE + 7, struct msm_camera_led_cfg_t)
493
Jeyaprakash Soundrapandian651d64e2013-03-11 12:04:55 -0700494#define VIDIOC_MSM_EEPROM_CFG \
495 _IOWR('V', BASE_VIDIOC_PRIVATE + 8, struct msm_eeprom_cfg_data)
496
Shuzhen Wangb4f4c922013-01-08 14:32:08 -0800497#define MSM_V4L2_PIX_FMT_META v4l2_fourcc('M', 'E', 'T', 'A') /* META */
498
499#endif /* __LINUX_MSM_CAM_SENSOR_H */