1 #ifndef __UAPI_LINUX_MSM_CAM_SENSOR_H 2 #define __UAPI_LINUX_MSM_CAM_SENSOR_H 3 4 #include <linux/v4l2-mediabus.h> 5 #include <media/msm_camsensor_sdk.h> 6 7 #include <linux/types.h> 8 #include <linux/i2c.h> 9 10 #define I2C_SEQ_REG_SETTING_MAX 5 11 12 #define MSM_SENSOR_MCLK_8HZ 8000000 13 #define MSM_SENSOR_MCLK_16HZ 16000000 14 #define MSM_SENSOR_MCLK_24HZ 24000000 15 16 #define MAX_SENSOR_NAME 32 17 #define MAX_ACTUATOR_AF_TOTAL_STEPS 1024 18 19 #define MAX_OIS_MOD_NAME_SIZE 32 20 #define MAX_OIS_NAME_SIZE 32 21 #define MAX_OIS_REG_SETTINGS 800 22 23 #define MOVE_NEAR 0 24 #define MOVE_FAR 1 25 26 #define MSM_ACTUATOR_MOVE_SIGNED_FAR -1 27 #define MSM_ACTUATOR_MOVE_SIGNED_NEAR 1 28 29 #define MAX_ACTUATOR_REGION 5 30 31 #define MAX_EEPROM_NAME 32 32 33 #define MAX_AF_ITERATIONS 3 34 #define MAX_NUMBER_OF_STEPS 47 35 #define MAX_REGULATOR 5 36 37 #define MSM_V4L2_PIX_FMT_META v4l2_fourcc('M', 'E', 'T', 'A') /* META */ 38 #define MSM_V4L2_PIX_FMT_SBGGR14 v4l2_fourcc('B', 'G', '1', '4') 39 /* 14 BGBG.. GRGR.. */ 40 #define MSM_V4L2_PIX_FMT_SGBRG14 v4l2_fourcc('G', 'B', '1', '4') 41 /* 14 GBGB.. RGRG.. */ 42 #define MSM_V4L2_PIX_FMT_SGRBG14 v4l2_fourcc('B', 'A', '1', '4') 43 /* 14 GRGR.. BGBG.. */ 44 #define MSM_V4L2_PIX_FMT_SRGGB14 v4l2_fourcc('R', 'G', '1', '4') 45 /* 14 RGRG.. GBGB.. */ 46 47 enum flash_type { 48 LED_FLASH = 1, 49 STROBE_FLASH, 50 GPIO_FLASH 51 }; 52 53 enum msm_sensor_resolution_t { 54 MSM_SENSOR_RES_FULL, 55 MSM_SENSOR_RES_QTR, 56 MSM_SENSOR_RES_2, 57 MSM_SENSOR_RES_3, 58 MSM_SENSOR_RES_4, 59 MSM_SENSOR_RES_5, 60 MSM_SENSOR_RES_6, 61 MSM_SENSOR_RES_7, 62 MSM_SENSOR_INVALID_RES, 63 }; 64 65 enum msm_camera_stream_type_t { 66 MSM_CAMERA_STREAM_PREVIEW, 67 MSM_CAMERA_STREAM_SNAPSHOT, 68 MSM_CAMERA_STREAM_VIDEO, 69 MSM_CAMERA_STREAM_INVALID, 70 }; 71 72 enum sensor_sub_module_t { 73 SUB_MODULE_SENSOR, 74 SUB_MODULE_CHROMATIX, 75 SUB_MODULE_ACTUATOR, 76 SUB_MODULE_EEPROM, 77 SUB_MODULE_LED_FLASH, 78 SUB_MODULE_STROBE_FLASH, 79 SUB_MODULE_CSID, 80 SUB_MODULE_CSID_3D, 81 SUB_MODULE_CSIPHY, 82 SUB_MODULE_CSIPHY_3D, 83 SUB_MODULE_OIS, 84 SUB_MODULE_EXT, 85 SUB_MODULE_MAX, 86 }; 87 88 enum { 89 MSM_CAMERA_EFFECT_MODE_OFF, 90 MSM_CAMERA_EFFECT_MODE_MONO, 91 MSM_CAMERA_EFFECT_MODE_NEGATIVE, 92 MSM_CAMERA_EFFECT_MODE_SOLARIZE, 93 MSM_CAMERA_EFFECT_MODE_SEPIA, 94 MSM_CAMERA_EFFECT_MODE_POSTERIZE, 95 MSM_CAMERA_EFFECT_MODE_WHITEBOARD, 96 MSM_CAMERA_EFFECT_MODE_BLACKBOARD, 97 MSM_CAMERA_EFFECT_MODE_AQUA, 98 MSM_CAMERA_EFFECT_MODE_EMBOSS, 99 MSM_CAMERA_EFFECT_MODE_SKETCH, 100 MSM_CAMERA_EFFECT_MODE_NEON, 101 MSM_CAMERA_EFFECT_MODE_MAX 102 }; 103 104 enum { 105 MSM_CAMERA_WB_MODE_AUTO, 106 MSM_CAMERA_WB_MODE_CUSTOM, 107 MSM_CAMERA_WB_MODE_INCANDESCENT, 108 MSM_CAMERA_WB_MODE_FLUORESCENT, 109 MSM_CAMERA_WB_MODE_WARM_FLUORESCENT, 110 MSM_CAMERA_WB_MODE_DAYLIGHT, 111 MSM_CAMERA_WB_MODE_CLOUDY_DAYLIGHT, 112 MSM_CAMERA_WB_MODE_TWILIGHT, 113 MSM_CAMERA_WB_MODE_SHADE, 114 MSM_CAMERA_WB_MODE_OFF, 115 MSM_CAMERA_WB_MODE_MAX 116 }; 117 118 enum { 119 MSM_CAMERA_SCENE_MODE_OFF, 120 MSM_CAMERA_SCENE_MODE_AUTO, 121 MSM_CAMERA_SCENE_MODE_LANDSCAPE, 122 MSM_CAMERA_SCENE_MODE_SNOW, 123 MSM_CAMERA_SCENE_MODE_BEACH, 124 MSM_CAMERA_SCENE_MODE_SUNSET, 125 MSM_CAMERA_SCENE_MODE_NIGHT, 126 MSM_CAMERA_SCENE_MODE_PORTRAIT, 127 MSM_CAMERA_SCENE_MODE_BACKLIGHT, 128 MSM_CAMERA_SCENE_MODE_SPORTS, 129 MSM_CAMERA_SCENE_MODE_ANTISHAKE, 130 MSM_CAMERA_SCENE_MODE_FLOWERS, 131 MSM_CAMERA_SCENE_MODE_CANDLELIGHT, 132 MSM_CAMERA_SCENE_MODE_FIREWORKS, 133 MSM_CAMERA_SCENE_MODE_PARTY, 134 MSM_CAMERA_SCENE_MODE_NIGHT_PORTRAIT, 135 MSM_CAMERA_SCENE_MODE_THEATRE, 136 MSM_CAMERA_SCENE_MODE_ACTION, 137 MSM_CAMERA_SCENE_MODE_AR, 138 MSM_CAMERA_SCENE_MODE_FACE_PRIORITY, 139 MSM_CAMERA_SCENE_MODE_BARCODE, 140 MSM_CAMERA_SCENE_MODE_HDR, 141 MSM_CAMERA_SCENE_MODE_MAX 142 }; 143 144 enum csid_cfg_type_t { 145 CSID_INIT, 146 CSID_CFG, 147 CSID_TESTMODE_CFG, 148 CSID_RELEASE, 149 }; 150 151 enum csiphy_cfg_type_t { 152 CSIPHY_INIT, 153 CSIPHY_CFG, 154 CSIPHY_RELEASE, 155 }; 156 157 enum camera_vreg_type { 158 VREG_TYPE_DEFAULT, 159 VREG_TYPE_CUSTOM, 160 }; 161 162 enum sensor_af_t { 163 SENSOR_AF_FOCUSSED, 164 SENSOR_AF_NOT_FOCUSSED, 165 }; 166 167 enum cci_i2c_master_t { 168 MASTER_0, 169 MASTER_1, 170 MASTER_MAX, 171 }; 172 173 struct msm_camera_i2c_array_write_config { 174 struct msm_camera_i2c_reg_setting conf_array; 175 uint16_t slave_addr; 176 }; 177 178 struct msm_camera_i2c_read_config { 179 uint16_t slave_addr; 180 uint16_t reg_addr; 181 enum msm_camera_i2c_reg_addr_type addr_type; 182 enum msm_camera_i2c_data_type data_type; 183 uint16_t data; 184 }; 185 186 struct msm_camera_csi2_params { 187 struct msm_camera_csid_params csid_params; 188 struct msm_camera_csiphy_params csiphy_params; 189 uint8_t csi_clk_scale_enable; 190 }; 191 192 struct msm_camera_csi_lane_params { 193 uint16_t csi_lane_assign; 194 uint16_t csi_lane_mask; 195 }; 196 197 struct csi_lane_params_t { 198 uint16_t csi_lane_assign; 199 uint8_t csi_lane_mask; 200 uint8_t csi_if; 201 int8_t csid_core[2]; 202 uint8_t csi_phy_sel; 203 }; 204 205 struct msm_sensor_info_t { 206 char sensor_name[MAX_SENSOR_NAME]; 207 uint32_t session_id; 208 int32_t subdev_id[SUB_MODULE_MAX]; 209 int32_t subdev_intf[SUB_MODULE_MAX]; 210 uint8_t is_mount_angle_valid; 211 uint32_t sensor_mount_angle; 212 int modes_supported; 213 enum camb_position_t position; 214 }; 215 216 struct camera_vreg_t { 217 const char *reg_name; 218 int min_voltage; 219 int max_voltage; 220 int op_mode; 221 uint32_t delay; 222 const char *custom_vreg_name; 223 enum camera_vreg_type type; 224 }; 225 226 struct sensorb_cfg_data { 227 int cfgtype; 228 union { 229 struct msm_sensor_info_t sensor_info; 230 struct msm_sensor_init_params sensor_init_params; 231 void *setting; 232 struct msm_sensor_i2c_sync_params sensor_i2c_sync_params; 233 } cfg; 234 }; 235 236 struct csid_cfg_data { 237 enum csid_cfg_type_t cfgtype; 238 union { 239 uint32_t csid_version; 240 struct msm_camera_csid_params *csid_params; 241 struct msm_camera_csid_testmode_parms *csid_testmode_params; 242 } cfg; 243 }; 244 245 struct csiphy_cfg_data { 246 enum csiphy_cfg_type_t cfgtype; 247 union { 248 struct msm_camera_csiphy_params *csiphy_params; 249 struct msm_camera_csi_lane_params *csi_lane_params; 250 } cfg; 251 }; 252 253 enum eeprom_cfg_type_t { 254 CFG_EEPROM_GET_INFO, 255 CFG_EEPROM_GET_CAL_DATA, 256 CFG_EEPROM_READ_CAL_DATA, 257 CFG_EEPROM_WRITE_DATA, 258 CFG_EEPROM_GET_MM_INFO, 259 CFG_EEPROM_INIT, 260 }; 261 262 struct eeprom_get_t { 263 uint32_t num_bytes; 264 }; 265 266 struct eeprom_read_t { 267 uint8_t *dbuffer; 268 uint32_t num_bytes; 269 }; 270 271 struct eeprom_write_t { 272 uint8_t *dbuffer; 273 uint32_t num_bytes; 274 }; 275 276 struct eeprom_get_cmm_t { 277 uint32_t cmm_support; 278 uint32_t cmm_compression; 279 uint32_t cmm_size; 280 }; 281 282 struct msm_eeprom_info_t { 283 struct msm_sensor_power_setting_array *power_setting_array; 284 enum i2c_freq_mode_t i2c_freq_mode; 285 struct msm_eeprom_memory_map_array *mem_map_array; 286 }; 287 288 struct msm_eeprom_cfg_data { 289 enum eeprom_cfg_type_t cfgtype; 290 uint8_t is_supported; 291 union { 292 char eeprom_name[MAX_SENSOR_NAME]; 293 struct eeprom_get_t get_data; 294 struct eeprom_read_t read_data; 295 struct eeprom_write_t write_data; 296 struct eeprom_get_cmm_t get_cmm_data; 297 struct msm_eeprom_info_t eeprom_info; 298 } cfg; 299 }; 300 301 enum msm_sensor_cfg_type_t { 302 CFG_SET_SLAVE_INFO, 303 CFG_SLAVE_READ_I2C, 304 CFG_WRITE_I2C_ARRAY, 305 CFG_SLAVE_WRITE_I2C_ARRAY, 306 CFG_WRITE_I2C_SEQ_ARRAY, 307 CFG_POWER_UP, 308 CFG_POWER_DOWN, 309 CFG_SET_STOP_STREAM_SETTING, 310 CFG_GET_SENSOR_INFO, 311 CFG_GET_SENSOR_INIT_PARAMS, 312 CFG_SET_INIT_SETTING, 313 CFG_SET_RESOLUTION, 314 CFG_SET_STOP_STREAM, 315 CFG_SET_START_STREAM, 316 CFG_SET_SATURATION, 317 CFG_SET_CONTRAST, 318 CFG_SET_SHARPNESS, 319 CFG_SET_ISO, 320 CFG_SET_EXPOSURE_COMPENSATION, 321 CFG_SET_ANTIBANDING, 322 CFG_SET_BESTSHOT_MODE, 323 CFG_SET_EFFECT, 324 CFG_SET_WHITE_BALANCE, 325 CFG_SET_AUTOFOCUS, 326 CFG_CANCEL_AUTOFOCUS, 327 CFG_SET_STREAM_TYPE, 328 CFG_SET_I2C_SYNC_PARAM, 329 CFG_WRITE_I2C_ARRAY_ASYNC, 330 CFG_WRITE_I2C_ARRAY_SYNC, 331 CFG_WRITE_I2C_ARRAY_SYNC_BLOCK, 332 }; 333 334 enum msm_actuator_cfg_type_t { 335 CFG_GET_ACTUATOR_INFO, 336 CFG_SET_ACTUATOR_INFO, 337 CFG_SET_DEFAULT_FOCUS, 338 CFG_MOVE_FOCUS, 339 CFG_SET_POSITION, 340 CFG_ACTUATOR_POWERDOWN, 341 CFG_ACTUATOR_POWERUP, 342 CFG_ACTUATOR_INIT, 343 }; 344 345 enum msm_ois_cfg_type_t { 346 CFG_OIS_INIT, 347 CFG_OIS_POWERDOWN, 348 CFG_OIS_POWERUP, 349 CFG_OIS_CONTROL, 350 CFG_OIS_I2C_WRITE_SEQ_TABLE, 351 }; 352 353 enum msm_ois_i2c_operation { 354 MSM_OIS_WRITE = 0, 355 MSM_OIS_POLL, 356 }; 357 358 struct reg_settings_ois_t { 359 uint16_t reg_addr; 360 enum msm_camera_i2c_reg_addr_type addr_type; 361 uint32_t reg_data; 362 enum msm_camera_i2c_data_type data_type; 363 enum msm_ois_i2c_operation i2c_operation; 364 uint32_t delay; 365 }; 366 367 struct msm_ois_params_t { 368 uint16_t data_size; 369 uint16_t setting_size; 370 uint32_t i2c_addr; 371 enum i2c_freq_mode_t i2c_freq_mode; 372 enum msm_camera_i2c_reg_addr_type i2c_addr_type; 373 enum msm_camera_i2c_data_type i2c_data_type; 374 struct reg_settings_ois_t *settings; 375 }; 376 377 struct msm_ois_set_info_t { 378 struct msm_ois_params_t ois_params; 379 }; 380 381 struct msm_actuator_move_params_t { 382 int8_t dir; 383 int8_t sign_dir; 384 int16_t dest_step_pos; 385 int32_t num_steps; 386 uint16_t curr_lens_pos; 387 struct damping_params_t *ringing_params; 388 }; 389 390 struct msm_actuator_tuning_params_t { 391 int16_t initial_code; 392 uint16_t pwd_step; 393 uint16_t region_size; 394 uint32_t total_steps; 395 struct region_params_t *region_params; 396 }; 397 398 struct park_lens_data_t { 399 uint32_t damping_step; 400 uint32_t damping_delay; 401 uint32_t hw_params; 402 uint32_t max_step; 403 }; 404 405 struct msm_actuator_params_t { 406 enum actuator_type act_type; 407 uint8_t reg_tbl_size; 408 uint16_t data_size; 409 uint16_t init_setting_size; 410 uint32_t i2c_addr; 411 enum i2c_freq_mode_t i2c_freq_mode; 412 enum msm_camera_i2c_reg_addr_type i2c_addr_type; 413 enum msm_camera_i2c_data_type i2c_data_type; 414 struct msm_actuator_reg_params_t *reg_tbl_params; 415 struct reg_settings_t *init_settings; 416 struct park_lens_data_t park_lens; 417 }; 418 419 struct msm_actuator_set_info_t { 420 struct msm_actuator_params_t actuator_params; 421 struct msm_actuator_tuning_params_t af_tuning_params; 422 }; 423 424 struct msm_actuator_get_info_t { 425 uint32_t focal_length_num; 426 uint32_t focal_length_den; 427 uint32_t f_number_num; 428 uint32_t f_number_den; 429 uint32_t f_pix_num; 430 uint32_t f_pix_den; 431 uint32_t total_f_dist_num; 432 uint32_t total_f_dist_den; 433 uint32_t hor_view_angle_num; 434 uint32_t hor_view_angle_den; 435 uint32_t ver_view_angle_num; 436 uint32_t ver_view_angle_den; 437 }; 438 439 enum af_camera_name { 440 ACTUATOR_MAIN_CAM_0, 441 ACTUATOR_MAIN_CAM_1, 442 ACTUATOR_MAIN_CAM_2, 443 ACTUATOR_MAIN_CAM_3, 444 ACTUATOR_MAIN_CAM_4, 445 ACTUATOR_MAIN_CAM_5, 446 ACTUATOR_WEB_CAM_0, 447 ACTUATOR_WEB_CAM_1, 448 ACTUATOR_WEB_CAM_2, 449 }; 450 451 struct msm_ois_cfg_data { 452 int cfgtype; 453 union { 454 struct msm_ois_set_info_t set_info; 455 struct msm_camera_i2c_seq_reg_setting *settings; 456 } cfg; 457 }; 458 459 struct msm_actuator_set_position_t { 460 uint16_t number_of_steps; 461 uint32_t hw_params; 462 uint16_t pos[MAX_NUMBER_OF_STEPS]; 463 uint16_t delay[MAX_NUMBER_OF_STEPS]; 464 }; 465 466 struct msm_actuator_cfg_data { 467 int cfgtype; 468 uint8_t is_af_supported; 469 union { 470 struct msm_actuator_move_params_t move; 471 struct msm_actuator_set_info_t set_info; 472 struct msm_actuator_get_info_t get_info; 473 struct msm_actuator_set_position_t setpos; 474 enum af_camera_name cam_name; 475 } cfg; 476 }; 477 478 enum msm_camera_led_config_t { 479 MSM_CAMERA_LED_OFF, 480 MSM_CAMERA_LED_LOW, 481 MSM_CAMERA_LED_HIGH, 482 MSM_CAMERA_LED_INIT, 483 MSM_CAMERA_LED_RELEASE, 484 }; 485 486 struct msm_camera_led_cfg_t { 487 enum msm_camera_led_config_t cfgtype; 488 int32_t torch_current[MAX_LED_TRIGGERS]; 489 int32_t flash_current[MAX_LED_TRIGGERS]; 490 int32_t flash_duration[MAX_LED_TRIGGERS]; 491 }; 492 493 struct msm_flash_init_info_t { 494 enum msm_flash_driver_type flash_driver_type; 495 uint32_t slave_addr; 496 enum i2c_freq_mode_t i2c_freq_mode; 497 struct msm_sensor_power_setting_array *power_setting_array; 498 struct msm_camera_i2c_reg_setting_array *settings; 499 }; 500 501 struct msm_flash_cfg_data_t { 502 enum msm_flash_cfg_type_t cfg_type; 503 int32_t flash_current[MAX_LED_TRIGGERS]; 504 int32_t flash_duration[MAX_LED_TRIGGERS]; 505 union { 506 struct msm_flash_init_info_t *flash_init_info; 507 struct msm_camera_i2c_reg_setting_array *settings; 508 } cfg; 509 }; 510 511 /* sensor init structures and enums */ 512 enum msm_sensor_init_cfg_type_t { 513 CFG_SINIT_PROBE, 514 CFG_SINIT_PROBE_DONE, 515 CFG_SINIT_PROBE_WAIT_DONE, 516 }; 517 518 struct sensor_init_cfg_data { 519 enum msm_sensor_init_cfg_type_t cfgtype; 520 struct msm_sensor_info_t probed_info; 521 char entity_name[MAX_SENSOR_NAME]; 522 union { 523 void *setting; 524 } cfg; 525 }; 526 527 #define VIDIOC_MSM_SENSOR_CFG \ 528 _IOWR('V', BASE_VIDIOC_PRIVATE + 1, struct sensorb_cfg_data) 529 530 #define VIDIOC_MSM_SENSOR_RELEASE \ 531 _IO('V', BASE_VIDIOC_PRIVATE + 2) 532 533 #define VIDIOC_MSM_SENSOR_GET_SUBDEV_ID \ 534 _IOWR('V', BASE_VIDIOC_PRIVATE + 3, uint32_t) 535 536 #define VIDIOC_MSM_CSIPHY_IO_CFG \ 537 _IOWR('V', BASE_VIDIOC_PRIVATE + 4, struct csiphy_cfg_data) 538 539 #define VIDIOC_MSM_CSID_IO_CFG \ 540 _IOWR('V', BASE_VIDIOC_PRIVATE + 5, struct csid_cfg_data) 541 542 #define VIDIOC_MSM_ACTUATOR_CFG \ 543 _IOWR('V', BASE_VIDIOC_PRIVATE + 6, struct msm_actuator_cfg_data) 544 545 #define VIDIOC_MSM_FLASH_LED_DATA_CFG \ 546 _IOWR('V', BASE_VIDIOC_PRIVATE + 7, struct msm_camera_led_cfg_t) 547 548 #define VIDIOC_MSM_EEPROM_CFG \ 549 _IOWR('V', BASE_VIDIOC_PRIVATE + 8, struct msm_eeprom_cfg_data) 550 551 #define VIDIOC_MSM_SENSOR_GET_AF_STATUS \ 552 _IOWR('V', BASE_VIDIOC_PRIVATE + 9, uint32_t) 553 554 #define VIDIOC_MSM_SENSOR_INIT_CFG \ 555 _IOWR('V', BASE_VIDIOC_PRIVATE + 10, struct sensor_init_cfg_data) 556 557 #define VIDIOC_MSM_OIS_CFG \ 558 _IOWR('V', BASE_VIDIOC_PRIVATE + 11, struct msm_ois_cfg_data) 559 560 #define VIDIOC_MSM_FLASH_CFG \ 561 _IOWR('V', BASE_VIDIOC_PRIVATE + 13, struct msm_flash_cfg_data_t) 562 563 #endif 564 565