cam_sensor.h 15 KB

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