cam_sensor.h 15 KB

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