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