cam_sensor.h 15 KB

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