1 #ifndef __UAPI_CAM_SENSOR_H__ 2 #define __UAPI_CAM_SENSOR_H__ 3 4 #include <linux/types.h> 5 #include <linux/ioctl.h> 6 #include <media/cam_defs.h> 7 8 #define CAM_SENSOR_PROBE_CMD (CAM_COMMON_OPCODE_MAX + 1) 9 #define CAM_FLASH_MAX_LED_TRIGGERS 3 10 #define MAX_OIS_NAME_SIZE 32 11 #define CAM_CSIPHY_SECURE_MODE_ENABLED 1 12 13 #ifdef CONFIG_BOARD_SUNFISH 14 #define CAM_IR_LED_SUPPORTED 15 #endif /*CONFIG_BOARD_SUNFISH*/ 16 17 #ifdef CONFIG_BOARD_FLORAL 18 #define MAX_RAINBOW_CONFIG_SIZE 32 19 20 enum rainbow_op_type { 21 RAINBOW_SEQ_READ, 22 RAINBOW_RANDOM_READ, 23 RAINBOW_SEQ_WRITE, 24 RAINBOW_RANDOM_WRITE 25 }; 26 27 enum strobe_type { 28 STROBE_ALTERNATIVE, 29 STROBE_SYNCHRONIZE, 30 STROBE_NONE 31 }; 32 33 enum silego_self_test_result_type { 34 SILEGO_TEST_FAILED, 35 SILEGO_TEST_PASS, 36 SILEGO_TEST_BYPASS 37 }; 38 39 struct rainbow_config { 40 enum rainbow_op_type operation; 41 uint32_t size; 42 uint32_t reg_addr[MAX_RAINBOW_CONFIG_SIZE]; 43 uint32_t reg_data[MAX_RAINBOW_CONFIG_SIZE]; 44 } __attribute__((packed)); 45 46 struct silego_self_test_result { 47 enum silego_self_test_result_type result; 48 bool is_cracked; 49 } __attribute__((packed)); 50 51 #define RAINBOW_CONFIG \ 52 _IOWR('R', 1, struct rainbow_config) 53 54 #define LM36011_SET_CERTIFICATION_STATUS \ 55 _IOWR('R', 1, bool) 56 57 #define LM36011_SILEGO_SELF_TEST \ 58 _IOWR('R', 1, struct silego_self_test_result) 59 60 #endif /*CONFIG_BOARD_FLORAL*/ 61 62 /** 63 * struct cam_sensor_query_cap - capabilities info for sensor 64 * 65 * @slot_info : Indicates about the slotId or cell Index 66 * @secure_camera : Camera is in secure/Non-secure mode 67 * @pos_pitch : Sensor position pitch 68 * @pos_roll : Sensor position roll 69 * @pos_yaw : Sensor position yaw 70 * @actuator_slot_id : Actuator slot id which connected to sensor 71 * @eeprom_slot_id : EEPROM slot id which connected to sensor 72 * @ois_slot_id : OIS slot id which connected to sensor 73 * @flash_slot_id : Flash slot id which connected to sensor 74 * @csiphy_slot_id : CSIphy slot id which connected to sensor 75 * @irled_slot_id : IRLED slot id which connected to sensor 76 * 77 */ 78 struct cam_sensor_query_cap { 79 uint32_t slot_info; 80 uint32_t secure_camera; 81 uint32_t pos_pitch; 82 uint32_t pos_roll; 83 uint32_t pos_yaw; 84 uint32_t actuator_slot_id; 85 uint32_t eeprom_slot_id; 86 uint32_t ois_slot_id; 87 uint32_t flash_slot_id; 88 uint32_t csiphy_slot_id; 89 #ifdef CONFIG_BOARD_SUNFISH 90 int32_t ir_led_slot_id; 91 #endif /*CONFIG_BOARD_SUNFISH*/ 92 } __attribute__((packed)); 93 94 /** 95 * struct cam_csiphy_query_cap - capabilities info for csiphy 96 * 97 * @slot_info : Indicates about the slotId or cell Index 98 * @version : CSIphy version 99 * @clk lane : Of the 5 lanes, informs lane configured 100 * as clock lane 101 * @reserved 102 */ 103 struct cam_csiphy_query_cap { 104 uint32_t slot_info; 105 uint32_t version; 106 uint32_t clk_lane; 107 uint32_t reserved; 108 } __attribute__((packed)); 109 110 /** 111 * struct cam_actuator_query_cap - capabilities info for actuator 112 * 113 * @slot_info : Indicates about the slotId or cell Index 114 * @reserved 115 */ 116 struct cam_actuator_query_cap { 117 uint32_t slot_info; 118 uint32_t reserved; 119 } __attribute__((packed)); 120 121 /** 122 * struct cam_eeprom_query_cap_t - capabilities info for eeprom 123 * 124 * @slot_info : Indicates about the slotId or cell Index 125 * @eeprom_kernel_probe : Indicates about the kernel or userspace probe 126 */ 127 struct cam_eeprom_query_cap_t { 128 uint32_t slot_info; 129 uint16_t eeprom_kernel_probe; 130 uint16_t reserved; 131 } __attribute__((packed)); 132 133 /** 134 * struct cam_ois_query_cap_t - capabilities info for ois 135 * 136 * @slot_info : Indicates about the slotId or cell Index 137 */ 138 struct cam_ois_query_cap_t { 139 uint32_t slot_info; 140 uint16_t reserved; 141 } __attribute__((packed)); 142 143 /** 144 * struct cam_cmd_i2c_info - Contains slave I2C related info 145 * 146 * @slave_addr : Slave address 147 * @i2c_freq_mode : 4 bits are used for I2c freq mode 148 * @cmd_type : Explains type of command 149 */ 150 struct cam_cmd_i2c_info { 151 uint16_t slave_addr; 152 uint8_t i2c_freq_mode; 153 uint8_t cmd_type; 154 } __attribute__((packed)); 155 156 /** 157 * struct cam_cmd_get_ois_data - Contains OIS data read cmd 158 * 159 * @reg_addr : register addr to read data from 160 * @reg_data : number of bytes to read 161 * @query_size_handle : handle to user space query_size address 162 * @query_data_handle : handle to user space query_data address 163 */ 164 struct cam_cmd_get_ois_data { 165 uint32_t reg_addr; 166 uint32_t reg_data; 167 uint64_t query_size_handle; 168 uint64_t query_data_handle; 169 } __attribute__((packed)); 170 171 /** 172 * struct cam_ois_shift - Contains OIS shift data 173 * 174 * @ois_shift_x : shift in x dim 175 * @ois_shift_y : shift in y dim 176 * @af_lop1 : shift in z dim (0x764) 177 * @time_readout : time that the shift is read out 178 */ 179 struct cam_ois_shift { 180 int16_t ois_shift_x; 181 int16_t ois_shift_y; 182 int16_t af_lop1; 183 int64_t time_readout; 184 } __attribute__((packed)); 185 186 /** 187 * struct cam_ois_opcode - Contains OIS opcode 188 * 189 * @prog : OIS FW prog register address 190 * @coeff : OIS FW coeff register address 191 * @pheripheral : OIS pheripheral 192 * @memory : OIS memory 193 */ 194 struct cam_ois_opcode { 195 uint32_t prog; 196 uint32_t coeff; 197 uint32_t pheripheral; 198 uint32_t memory; 199 } __attribute__((packed)); 200 201 /** 202 * struct cam_cmd_ois_info - Contains OIS slave info 203 * 204 * @slave_addr : OIS i2c slave address 205 * @i2c_freq_mode : i2c frequency mode 206 * @cmd_type : Explains type of command 207 * @ois_fw_flag : indicates if fw is present or not 208 * @is_ois_calib : indicates the calibration data is available 209 * @ois_name : OIS name 210 * @opcode : opcode 211 */ 212 struct cam_cmd_ois_info { 213 uint16_t slave_addr; 214 uint8_t i2c_freq_mode; 215 uint8_t cmd_type; 216 uint8_t ois_fw_flag; 217 uint8_t is_ois_calib; 218 char ois_name[MAX_OIS_NAME_SIZE]; 219 struct cam_ois_opcode opcode; 220 } __attribute__((packed)); 221 222 /** 223 * struct cam_cmd_probe - Contains sensor slave info 224 * 225 * @data_type : Slave register data type 226 * @addr_type : Slave register address type 227 * @op_code : Don't Care 228 * @cmd_type : Explains type of command 229 * @reg_addr : Slave register address 230 * @expected_data : Data expected at slave register address 231 * @data_mask : Data mask if only few bits are valid 232 * @camera_id : Indicates the slot to which camera 233 * needs to be probed 234 * @fw_update_flag : Update OIS firmware 235 * @reserved 236 */ 237 struct cam_cmd_probe { 238 uint8_t data_type; 239 uint8_t addr_type; 240 uint8_t op_code; 241 uint8_t cmd_type; 242 uint32_t reg_addr; 243 uint32_t expected_data; 244 uint32_t data_mask; 245 uint16_t camera_id; 246 uint8_t fw_update_flag; 247 uint16_t reserved; 248 } __attribute__((packed)); 249 250 /** 251 * struct cam_power_settings - Contains sensor power setting info 252 * 253 * @power_seq_type : Type of power sequence 254 * @reserved 255 * @config_val_low : Lower 32 bit value configuration value 256 * @config_val_high : Higher 32 bit value configuration value 257 * 258 */ 259 struct cam_power_settings { 260 uint16_t power_seq_type; 261 uint16_t reserved; 262 uint32_t config_val_low; 263 uint32_t config_val_high; 264 } __attribute__((packed)); 265 266 /** 267 * struct cam_cmd_power - Explains about the power settings 268 * 269 * @count : Number of power settings follows 270 * @reserved 271 * @cmd_type : Explains type of command 272 * @power_settings : Contains power setting info 273 */ 274 struct cam_cmd_power { 275 uint16_t count; 276 uint8_t reserved; 277 uint8_t cmd_type; 278 struct cam_power_settings power_settings[1]; 279 } __attribute__((packed)); 280 281 /** 282 * struct i2c_rdwr_header - header of READ/WRITE I2C command 283 * 284 * @ count : Number of registers / data / reg-data pairs 285 * @ op_code : Operation code 286 * @ cmd_type : Command buffer type 287 * @ data_type : I2C data type 288 * @ addr_type : I2C address type 289 * @ slave_addr : Slave address 290 * @ reserved 291 */ 292 struct i2c_rdwr_header { 293 uint16_t count; 294 uint8_t op_code; 295 uint8_t cmd_type; 296 uint8_t data_type; 297 uint8_t addr_type; 298 299 #ifdef CONFIG_BOARD_FLORAL 300 uint16_t slave_addr; 301 #endif /*CONFIG_BOARD_FLORAL*/ 302 #ifdef CONFIG_BOARD_SUNFISH 303 int16_t reserved; 304 #endif /*CONFIG_BOARD_SUNFISH*/ 305 } __attribute__((packed)); 306 307 /** 308 * struct i2c_random_wr_payload - payload for I2C random write 309 * 310 * @ reg_addr : Register address 311 * @ reg_data : Register data 312 * 313 */ 314 struct i2c_random_wr_payload { 315 uint32_t reg_addr; 316 uint32_t reg_data; 317 } __attribute__((packed)); 318 319 /** 320 * struct cam_cmd_i2c_random_wr - I2C random write command 321 * @ header : header of READ/WRITE I2C command 322 * @ random_wr_payload : payload for I2C random write 323 */ 324 struct cam_cmd_i2c_random_wr { 325 struct i2c_rdwr_header header; 326 struct i2c_random_wr_payload random_wr_payload[1]; 327 } __attribute__((packed)); 328 329 /** 330 * struct cam_cmd_read - I2C read command 331 * @ reg_data : Register data 332 * @ reserved 333 */ 334 struct cam_cmd_read { 335 uint32_t reg_data; 336 uint32_t reserved; 337 } __attribute__((packed)); 338 339 /** 340 * struct cam_cmd_i2c_continuous_wr - I2C continuous write command 341 * @ header : header of READ/WRITE I2C command 342 * @ reg_addr : Register address 343 * @ data_read : I2C read command 344 */ 345 struct cam_cmd_i2c_continuous_wr { 346 struct i2c_rdwr_header header; 347 uint32_t reg_addr; 348 struct cam_cmd_read data_read[1]; 349 } __attribute__((packed)); 350 351 /** 352 * struct cam_cmd_i2c_random_rd - I2C random read command 353 * @ header : header of READ/WRITE I2C command 354 * @ data_read : I2C read command 355 */ 356 struct cam_cmd_i2c_random_rd { 357 struct i2c_rdwr_header header; 358 struct cam_cmd_read data_read[1]; 359 } __attribute__((packed)); 360 361 /** 362 * struct cam_cmd_i2c_continuous_rd - I2C continuous continuous read command 363 * @ header : header of READ/WRITE I2C command 364 * @ reg_addr : Register address 365 * 366 */ 367 struct cam_cmd_i2c_continuous_rd { 368 struct i2c_rdwr_header header; 369 uint32_t reg_addr; 370 } __attribute__((packed)); 371 372 /** 373 * struct cam_cmd_conditional_wait - Conditional wait command 374 * @data_type : Data type 375 * @addr_type : Address type 376 * @op_code : Opcode 377 * @cmd_type : Explains type of command 378 * @timeout : Timeout for retries 379 * @reserved 380 * @reg_addr : Register Address 381 * @reg_data : Register data 382 * @data_mask : Data mask if only few bits are valid 383 * @camera_id : Indicates the slot to which camera 384 * needs to be probed 385 * 386 */ 387 struct cam_cmd_conditional_wait { 388 uint8_t data_type; 389 uint8_t addr_type; 390 uint8_t op_code; 391 uint8_t cmd_type; 392 uint16_t timeout; 393 uint16_t reserved; 394 uint32_t reg_addr; 395 uint32_t reg_data; 396 uint32_t data_mask; 397 } __attribute__((packed)); 398 399 /** 400 * struct cam_cmd_unconditional_wait - Un-conditional wait command 401 * @delay : Delay 402 * @op_code : Opcode 403 * @cmd_type : Explains type of command 404 */ 405 struct cam_cmd_unconditional_wait { 406 int16_t delay; 407 uint8_t op_code; 408 uint8_t cmd_type; 409 } __attribute__((packed)); 410 411 /** 412 * cam_csiphy_info: Provides cmdbuffer structre 413 * @lane_mask : Lane mask details 414 * @lane_assign : Lane sensor will be using 415 * @csiphy_3phase : Total number of lanes 416 * @combo_mode : Info regarding combo_mode is enable / disable 417 * @lane_cnt : Total number of lanes 418 * @secure_mode : Secure mode flag to enable / disable 419 * @3phase : Details whether 3Phase / 2Phase operation 420 * @settle_time : Settling time in ms 421 * @data_rate : Data rate 422 * 423 */ 424 struct cam_csiphy_info { 425 uint16_t lane_mask; 426 uint16_t lane_assign; 427 uint8_t csiphy_3phase; 428 uint8_t combo_mode; 429 uint8_t lane_cnt; 430 uint8_t secure_mode; 431 uint64_t settle_time; 432 uint64_t data_rate; 433 } __attribute__((packed)); 434 435 /** 436 * cam_csiphy_acquire_dev_info : Information needed for 437 * csiphy at the time of acquire 438 * @combo_mode : Indicates the device mode of operation 439 * @reserved 440 * 441 */ 442 struct cam_csiphy_acquire_dev_info { 443 uint32_t combo_mode; 444 uint32_t reserved; 445 } __attribute__((packed)); 446 447 /** 448 * cam_sensor_acquire_dev : Updates sensor acuire cmd 449 * @device_handle : Updates device handle 450 * @session_handle : Session handle for acquiring device 451 * @handle_type : Resource handle type 452 * @reserved 453 * @info_handle : Handle to additional info 454 * needed for sensor sub modules 455 * 456 */ 457 struct cam_sensor_acquire_dev { 458 uint32_t session_handle; 459 uint32_t device_handle; 460 uint32_t handle_type; 461 uint32_t reserved; 462 uint64_t info_handle; 463 } __attribute__((packed)); 464 465 /** 466 * cam_sensor_streamon_dev : StreamOn command for the sensor 467 * @session_handle : Session handle for acquiring device 468 * @device_handle : Updates device handle 469 * @handle_type : Resource handle type 470 * @reserved 471 * @info_handle : Information Needed at the time of streamOn 472 * 473 */ 474 struct cam_sensor_streamon_dev { 475 uint32_t session_handle; 476 uint32_t device_handle; 477 uint32_t handle_type; 478 uint32_t reserved; 479 uint64_t info_handle; 480 } __attribute__((packed)); 481 482 /** 483 * struct cam_cmd_get_sensor_data - Contains Sensor data read cmd 484 * 485 * @reg_addr : register addr to read data from 486 * @reg_data : number of bytes to read 487 * @query_size_handle : handle to user space query_size address 488 * @query_data_handle : handle to user space query_data address 489 */ 490 struct cam_cmd_get_sensor_data { 491 uint32_t reg_addr; 492 uint32_t reg_data; 493 uint64_t query_size_handle; 494 uint64_t query_data_handle; 495 } __attribute__((packed)); 496 497 /** 498 * struct cam_flash_init : Init command for the flash 499 * @flash_type : flash hw type 500 * @reserved 501 * @cmd_type : command buffer type 502 */ 503 struct cam_flash_init { 504 uint8_t flash_type; 505 uint16_t reserved; 506 uint8_t cmd_type; 507 } __attribute__((packed)); 508 509 /** 510 * struct cam_flash_set_rer : RedEyeReduction command buffer 511 * 512 * @count : Number of flash leds 513 * @opcode : Command buffer opcode 514 * CAM_FLASH_FIRE_RER 515 * @cmd_type : command buffer operation type 516 * @num_iteration : Number of led turn on/off sequence 517 * @reserved 518 * @led_on_delay_ms : flash led turn on time in ms 519 * @led_off_delay_ms : flash led turn off time in ms 520 * @led_current_ma : flash led current in ma 521 * 522 */ 523 struct cam_flash_set_rer { 524 uint16_t count; 525 uint8_t opcode; 526 uint8_t cmd_type; 527 uint16_t num_iteration; 528 uint16_t reserved; 529 uint32_t led_on_delay_ms; 530 uint32_t led_off_delay_ms; 531 uint32_t led_current_ma[CAM_FLASH_MAX_LED_TRIGGERS]; 532 } __attribute__((packed)); 533 534 /** 535 * struct cam_flash_set_on_off : led turn on/off command buffer 536 * 537 * @count : Number of Flash leds 538 * @opcode : command buffer opcodes 539 * CAM_FLASH_FIRE_LOW 540 * CAM_FLASH_FIRE_HIGH 541 * CAM_FLASH_OFF 542 * @cmd_type : command buffer operation type 543 * @led_current_ma : flash led current in ma 544 * 545 */ 546 struct cam_flash_set_on_off { 547 uint16_t count; 548 uint8_t opcode; 549 uint8_t cmd_type; 550 uint32_t led_current_ma[CAM_FLASH_MAX_LED_TRIGGERS]; 551 } __attribute__((packed)); 552 553 /** 554 * struct cam_flash_query_curr : query current command buffer 555 * 556 * @reserved 557 * @opcode : command buffer opcode 558 * @cmd_type : command buffer operation type 559 * @query_current_ma : battery current in ma 560 * 561 */ 562 struct cam_flash_query_curr { 563 uint16_t reserved; 564 uint8_t opcode; 565 uint8_t cmd_type; 566 uint32_t query_current_ma; 567 } __attribute__ ((packed)); 568 569 /** 570 * struct cam_flash_query_cap : capabilities info for flash 571 * 572 * @slot_info : Indicates about the slotId or cell Index 573 * @max_current_flash : max supported current for flash 574 * @max_duration_flash : max flash turn on duration 575 * @max_current_torch : max supported current for torch 576 * 577 */ 578 struct cam_flash_query_cap_info { 579 uint32_t slot_info; 580 uint32_t max_current_flash[CAM_FLASH_MAX_LED_TRIGGERS]; 581 uint32_t max_duration_flash[CAM_FLASH_MAX_LED_TRIGGERS]; 582 uint32_t max_current_torch[CAM_FLASH_MAX_LED_TRIGGERS]; 583 } __attribute__ ((packed)); 584 585 #ifdef CONFIG_BOARD_SUNFISH 586 587 /** 588 * struct cam_ir_led_query_cap : capabilities info for ir_led 589 * 590 * @slot_info : Indicates about the slotId or cell Index 591 * 592 */ 593 struct cam_ir_led_query_cap_info { 594 uint32_t slot_info; 595 } __attribute__ ((packed)); 596 597 /** 598 * struct cam_ir_ledset_on_off : led turn on/off command buffer 599 * 600 * @opcode : command buffer opcodes 601 * @cmd_type : command buffer operation type 602 * @ir_led_intensity : ir led intensity level 603 * @pwm_duty_on_ns : PWM duty cycle in ns for IRLED intensity 604 * @pwm_period_ns : PWM period in ns 605 * 606 */ 607 struct cam_ir_led_set_on_off { 608 uint16_t reserved; 609 uint8_t opcode; 610 uint8_t cmd_type; 611 uint32_t ir_led_intensity; 612 uint32_t pwm_duty_on_ns; 613 uint32_t pwm_period_ns; 614 } __attribute__((packed)); 615 616 #endif /*CONFIG_BOARD_SUNFISH*/ 617 618 #endif 619