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