cam_sensor.h 14 KB

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