cam_sensor.h 17 KB

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