1 #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 36 #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 47 #define MAX_EEPROM_NAME 32 48 49 enum msm_camera_i2c_reg_addr_type { 50 MSM_CAMERA_I2C_BYTE_ADDR = 1, 51 MSM_CAMERA_I2C_WORD_ADDR, 52 MSM_CAMERA_I2C_3B_ADDR, 53 }; 54 55 enum 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 65 enum msm_sensor_power_seq_type_t { 66 SENSOR_CLK, 67 SENSOR_GPIO, 68 SENSOR_VREG, 69 SENSOR_I2C_MUX, 70 }; 71 72 enum msm_sensor_clk_type_t { 73 SENSOR_CAM_MCLK, 74 SENSOR_CAM_CLK, 75 SENSOR_CAM_CLK_MAX, 76 }; 77 78 enum msm_sensor_power_seq_gpio_t { 79 SENSOR_GPIO_RESET, 80 SENSOR_GPIO_STANDBY, 81 SENSOR_GPIO_VANA, 82 SENSOR_GPIO_VDIG, 83 SENSOR_GPIO_VIO, 84 SENSOR_GPIO_VCM, 85 SENSOR_GPIO_OIS_LDO_EN, 86 SENSOR_GPIO_OIS_RESET, 87 SENSOR_GPIO_MAX, 88 }; 89 90 enum msm_camera_vreg_name_t { 91 CAM_VDIG, 92 CAM_VIO, 93 CAM_VANA, 94 CAM_VAF, 95 CAM_VREG_MAX, 96 }; 97 98 enum msm_sensor_resolution_t { 99 MSM_SENSOR_RES_FULL, 100 MSM_SENSOR_RES_QTR, 101 MSM_SENSOR_RES_2, 102 MSM_SENSOR_RES_3, 103 MSM_SENSOR_RES_4, 104 MSM_SENSOR_RES_5, 105 MSM_SENSOR_RES_6, 106 MSM_SENSOR_RES_7, 107 MSM_SENSOR_INVALID_RES, 108 }; 109 110 enum sensor_sub_module_t { 111 SUB_MODULE_SENSOR, 112 SUB_MODULE_CHROMATIX, 113 SUB_MODULE_ACTUATOR, 114 SUB_MODULE_EEPROM, 115 SUB_MODULE_LED_FLASH, 116 SUB_MODULE_STROBE_FLASH, 117 SUB_MODULE_CSID, 118 SUB_MODULE_CSID_3D, 119 SUB_MODULE_CSIPHY, 120 SUB_MODULE_CSIPHY_3D, 121 SUB_MODULE_MAX, 122 }; 123 124 enum csid_cfg_type_t { 125 CSID_INIT, 126 CSID_CFG, 127 CSID_RELEASE, 128 }; 129 130 enum csiphy_cfg_type_t { 131 CSIPHY_INIT, 132 CSIPHY_CFG, 133 CSIPHY_RELEASE, 134 }; 135 136 enum camera_vreg_type { 137 REG_LDO, 138 REG_VS, 139 REG_GPIO, 140 }; 141 142 struct msm_sensor_power_setting { 143 enum msm_sensor_power_seq_type_t seq_type; 144 uint16_t seq_val; 145 long config_val; 146 uint16_t delay; 147 void *data[10]; 148 }; 149 150 struct msm_sensor_power_setting_array { 151 struct msm_sensor_power_setting *power_setting; 152 uint16_t size; 153 }; 154 155 struct msm_sensor_id_info_t { 156 uint16_t sensor_id_reg_addr; 157 uint16_t sensor_id; 158 }; 159 160 struct msm_camera_sensor_slave_info { 161 uint16_t slave_addr; 162 enum msm_camera_i2c_reg_addr_type addr_type; 163 struct msm_sensor_id_info_t sensor_id_info; 164 struct msm_sensor_power_setting_array power_setting_array; 165 }; 166 167 struct msm_camera_i2c_reg_array { 168 uint16_t reg_addr; 169 uint16_t reg_data; 170 uint32_t delay; 171 }; 172 173 struct msm_camera_i2c_reg_setting { 174 struct msm_camera_i2c_reg_array *reg_setting; 175 uint16_t size; 176 enum msm_camera_i2c_reg_addr_type addr_type; 177 enum msm_camera_i2c_data_type data_type; 178 uint16_t delay; 179 }; 180 181 struct msm_camera_i2c_seq_reg_array { 182 uint16_t reg_addr; 183 uint8_t reg_data[I2C_SEQ_REG_DATA_MAX]; 184 uint16_t reg_data_size; 185 }; 186 187 struct msm_camera_i2c_seq_reg_setting { 188 struct msm_camera_i2c_seq_reg_array *reg_setting; 189 uint16_t size; 190 enum msm_camera_i2c_reg_addr_type addr_type; 191 uint16_t delay; 192 }; 193 194 struct msm_camera_i2c_array_write_config { 195 struct msm_camera_i2c_reg_setting conf_array; 196 uint16_t slave_addr; 197 }; 198 199 struct msm_camera_i2c_read_config { 200 uint16_t slave_addr; 201 uint16_t reg_addr; 202 enum msm_camera_i2c_data_type data_type; 203 uint16_t *data; 204 }; 205 206 struct msm_camera_csid_vc_cfg { 207 uint8_t cid; 208 uint8_t dt; 209 uint8_t decode_format; 210 }; 211 212 struct msm_camera_csid_lut_params { 213 uint8_t num_cid; 214 struct msm_camera_csid_vc_cfg *vc_cfg[MAX_CID]; 215 uint32_t vc_cfg_size; 216 }; 217 218 struct msm_camera_csid_params { 219 uint8_t lane_cnt; 220 uint16_t lane_assign; 221 uint8_t phy_sel; 222 struct msm_camera_csid_lut_params lut_params; 223 }; 224 225 struct msm_camera_csiphy_params { 226 uint8_t lane_cnt; 227 uint8_t settle_cnt; 228 uint16_t lane_mask; 229 uint8_t combo_mode; 230 uint8_t csid_core; 231 }; 232 233 struct msm_camera_csi2_params { 234 struct msm_camera_csid_params csid_params; 235 struct msm_camera_csiphy_params csiphy_params; 236 }; 237 238 struct msm_camera_csi_lane_params { 239 uint16_t csi_lane_assign; 240 uint16_t csi_lane_mask; 241 }; 242 243 struct csi_lane_params_t { 244 uint16_t csi_lane_assign; 245 uint8_t csi_lane_mask; 246 uint8_t csi_if; 247 uint8_t csid_core[2]; 248 uint8_t csi_phy_sel; 249 }; 250 251 struct msm_sensor_info_t { 252 char sensor_name[MAX_SENSOR_NAME]; 253 int32_t session_id; 254 int32_t subdev_id[SUB_MODULE_MAX]; 255 }; 256 257 struct msm_sensor_ois_info_t { 258 char ois_provider[MAX_SENSOR_NAME]; 259 int16_t gyro[2]; 260 int16_t target[2]; 261 int16_t hall[2]; 262 uint8_t is_stable; 263 }; 264 265 enum ois_mode_t { 266 OIS_MODE_PREVIEW_CAPTURE, 267 OIS_MODE_VIDEO, 268 OIS_MODE_CAPTURE, 269 OIS_MODE_CENTERING_ONLY, 270 OIS_MODE_CENTERING_OFF 271 }; 272 273 enum ois_ver_t { 274 OIS_VER_RELEASE, 275 OIS_VER_CALIBRATION, 276 OIS_VER_DEBUG 277 }; 278 279 struct camera_vreg_t { 280 const char *reg_name; 281 enum camera_vreg_type type; 282 int min_voltage; 283 int max_voltage; 284 int op_mode; 285 uint32_t delay; 286 }; 287 288 enum camb_position_t { 289 BACK_CAMERA_B, 290 FRONT_CAMERA_B, 291 }; 292 293 enum camerab_mode_t { 294 CAMERA_MODE_2D_B = (1<<0), 295 CAMERA_MODE_3D_B = (1<<1) 296 }; 297 298 struct msm_sensor_init_params { 299 /* mask of modes supported: 2D, 3D */ 300 int modes_supported; 301 /* sensor position: front, back */ 302 enum camb_position_t position; 303 /* sensor mount angle */ 304 uint32_t sensor_mount_angle; 305 int ois_supported; 306 }; 307 308 struct sensorb_cfg_data { 309 int cfgtype; 310 union { 311 struct msm_sensor_info_t sensor_info; 312 struct msm_sensor_init_params sensor_init_params; 313 struct msm_sensor_ois_info_t ois_info; 314 void *setting; 315 } cfg; 316 uint32_t setting_size; 317 }; 318 319 struct msm_sensor_csid_cfg_params { 320 struct msm_camera_csid_params *csid_params; 321 uint32_t csid_params_size; 322 }; 323 324 struct csid_cfg_data { 325 enum csid_cfg_type_t cfgtype; 326 union { 327 uint32_t csid_version; 328 struct msm_sensor_csid_cfg_params csid_cfg_params; 329 } cfg; 330 }; 331 332 struct csiphy_cfg_data { 333 enum csiphy_cfg_type_t cfgtype; 334 union { 335 struct msm_camera_csiphy_params *csiphy_params; 336 struct msm_camera_csi_lane_params *csi_lane_params; 337 } cfg; 338 uint32_t cfg_params_size; 339 }; 340 341 enum eeprom_cfg_type_t { 342 CFG_EEPROM_GET_INFO, 343 CFG_EEPROM_GET_CAL_DATA, 344 CFG_EEPROM_READ_CAL_DATA, 345 CFG_EEPROM_WRITE_DATA, 346 }; 347 struct eeprom_get_t { 348 uint16_t num_bytes; 349 }; 350 351 struct eeprom_read_t { 352 uint8_t *dbuffer; 353 uint16_t num_bytes; 354 }; 355 356 struct eeprom_write_t { 357 uint8_t *dbuffer; 358 uint16_t num_bytes; 359 }; 360 361 struct msm_eeprom_cfg_data { 362 enum eeprom_cfg_type_t cfgtype; 363 uint8_t is_supported; 364 union { 365 char eeprom_name[MAX_SENSOR_NAME]; 366 struct eeprom_get_t get_data; 367 struct eeprom_read_t read_data; 368 struct eeprom_write_t write_data; 369 } cfg; 370 }; 371 372 enum msm_sensor_cfg_type_t { 373 CFG_SET_SLAVE_INFO, 374 CFG_SLAVE_READ_I2C, 375 CFG_WRITE_I2C_ARRAY, 376 CFG_SLAVE_WRITE_I2C_ARRAY, 377 CFG_WRITE_I2C_SEQ_ARRAY, 378 CFG_POWER_UP, 379 CFG_POWER_DOWN, 380 CFG_SET_STOP_STREAM_SETTING, 381 CFG_GET_SENSOR_INFO, 382 CFG_GET_SENSOR_INIT_PARAMS, 383 CFG_SET_INIT_SETTING, 384 CFG_SET_RESOLUTION, 385 CFG_SET_STOP_STREAM, 386 CFG_SET_START_STREAM, 387 CFG_OIS_ON, 388 CFG_OIS_OFF, 389 CFG_GET_OIS_INFO, 390 CFG_SET_OIS_MODE, 391 CFG_OIS_MOVE_LENS 392 }; 393 394 enum msm_actuator_cfg_type_t { 395 CFG_GET_ACTUATOR_INFO, 396 CFG_SET_ACTUATOR_INFO, 397 CFG_SET_DEFAULT_FOCUS, 398 CFG_MOVE_FOCUS, 399 }; 400 401 enum actuator_type { 402 ACTUATOR_VCM, 403 ACTUATOR_PIEZO, 404 }; 405 406 enum msm_actuator_data_type { 407 MSM_ACTUATOR_BYTE_DATA = 1, 408 MSM_ACTUATOR_WORD_DATA, 409 }; 410 411 enum msm_actuator_addr_type { 412 MSM_ACTUATOR_BYTE_ADDR = 1, 413 MSM_ACTUATOR_WORD_ADDR, 414 }; 415 416 struct reg_settings_t { 417 uint16_t reg_addr; 418 uint16_t reg_data; 419 }; 420 421 struct region_params_t { 422 /* [0] = ForwardDirection Macro boundary 423 [1] = ReverseDirection Inf boundary 424 */ 425 uint16_t step_bound[2]; 426 uint16_t code_per_step; 427 }; 428 429 struct damping_params_t { 430 uint32_t damping_step; 431 uint32_t damping_delay; 432 uint32_t hw_params; 433 }; 434 435 struct msm_actuator_move_params_t { 436 int8_t dir; 437 int8_t sign_dir; 438 int16_t dest_step_pos; 439 int32_t num_steps; 440 int32_t num_steps_inf_pos; 441 struct damping_params_t *ringing_params; 442 }; 443 444 struct msm_actuator_tuning_params_t { 445 int16_t initial_code; 446 uint16_t pwd_step; 447 uint16_t region_size; 448 uint32_t total_steps; 449 struct region_params_t *region_params; 450 }; 451 452 struct msm_actuator_params_t { 453 enum actuator_type act_type; 454 uint8_t reg_tbl_size; 455 uint16_t data_size; 456 uint16_t init_setting_size; 457 uint32_t i2c_addr; 458 enum msm_actuator_addr_type i2c_addr_type; 459 enum msm_actuator_data_type i2c_data_type; 460 struct msm_actuator_reg_params_t *reg_tbl_params; 461 struct reg_settings_t *init_settings; 462 }; 463 464 struct msm_actuator_set_info_t { 465 struct msm_actuator_params_t actuator_params; 466 struct msm_actuator_tuning_params_t af_tuning_params; 467 }; 468 469 struct msm_actuator_get_info_t { 470 uint32_t focal_length_num; 471 uint32_t focal_length_den; 472 uint32_t f_number_num; 473 uint32_t f_number_den; 474 uint32_t f_pix_num; 475 uint32_t f_pix_den; 476 uint32_t total_f_dist_num; 477 uint32_t total_f_dist_den; 478 uint32_t hor_view_angle_num; 479 uint32_t hor_view_angle_den; 480 uint32_t ver_view_angle_num; 481 uint32_t ver_view_angle_den; 482 }; 483 484 enum af_camera_name { 485 ACTUATOR_MAIN_CAM_0, 486 ACTUATOR_MAIN_CAM_1, 487 ACTUATOR_MAIN_CAM_2, 488 ACTUATOR_MAIN_CAM_3, 489 ACTUATOR_MAIN_CAM_4, 490 ACTUATOR_MAIN_CAM_5, 491 ACTUATOR_WEB_CAM_0, 492 ACTUATOR_WEB_CAM_1, 493 ACTUATOR_WEB_CAM_2, 494 }; 495 496 struct msm_actuator_cfg_data { 497 int cfgtype; 498 uint8_t is_af_supported; 499 union { 500 struct msm_actuator_move_params_t move; 501 struct msm_actuator_set_info_t set_info; 502 struct msm_actuator_get_info_t get_info; 503 enum af_camera_name cam_name; 504 } cfg; 505 }; 506 507 enum msm_actuator_write_type { 508 MSM_ACTUATOR_WRITE_HW_DAMP, 509 MSM_ACTUATOR_WRITE_DAC, 510 }; 511 512 struct msm_actuator_reg_params_t { 513 enum msm_actuator_write_type reg_write_type; 514 uint32_t hw_mask; 515 uint16_t reg_addr; 516 uint16_t hw_shift; 517 uint16_t data_shift; 518 }; 519 520 enum msm_camera_led_config_t { 521 MSM_CAMERA_LED_OFF, 522 MSM_CAMERA_LED_LOW, 523 MSM_CAMERA_LED_HIGH, 524 MSM_CAMERA_LED_INIT, 525 MSM_CAMERA_LED_RELEASE, 526 }; 527 528 struct msm_camera_led_cfg_t { 529 enum msm_camera_led_config_t cfgtype; 530 }; 531 532 #define VIDIOC_MSM_SENSOR_CFG \ 533 _IOWR('V', BASE_VIDIOC_PRIVATE + 1, struct sensorb_cfg_data) 534 535 #define VIDIOC_MSM_SENSOR_RELEASE \ 536 _IO('V', BASE_VIDIOC_PRIVATE + 2) 537 538 #define VIDIOC_MSM_SENSOR_GET_SUBDEV_ID \ 539 _IOWR('V', BASE_VIDIOC_PRIVATE + 3, uint32_t) 540 541 #define VIDIOC_MSM_CSIPHY_IO_CFG \ 542 _IOWR('V', BASE_VIDIOC_PRIVATE + 4, struct csiphy_cfg_data) 543 544 #define VIDIOC_MSM_CSID_IO_CFG \ 545 _IOWR('V', BASE_VIDIOC_PRIVATE + 5, struct csid_cfg_data) 546 547 #define VIDIOC_MSM_ACTUATOR_CFG \ 548 _IOWR('V', BASE_VIDIOC_PRIVATE + 6, struct msm_actuator_cfg_data) 549 550 #define VIDIOC_MSM_FLASH_LED_DATA_CFG \ 551 _IOWR('V', BASE_VIDIOC_PRIVATE + 7, struct msm_camera_led_cfg_t) 552 553 #define VIDIOC_MSM_EEPROM_CFG \ 554 _IOWR('V', BASE_VIDIOC_PRIVATE + 8, struct msm_eeprom_cfg_data) 555 556 #define MSM_V4L2_PIX_FMT_META v4l2_fourcc('M', 'E', 'T', 'A') /* META */ 557 558 #endif /* __LINUX_MSM_CAM_SENSOR_H */ 559