cam_sensor.h 31 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084
  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. * Copyright (c) 2021-2022 Qualcomm Innovation Center, Inc. All rights reserved.
  5. */
  6. #ifndef __UAPI_CAM_SENSOR_H__
  7. #define __UAPI_CAM_SENSOR_H__
  8. #include <linux/types.h>
  9. #include <linux/ioctl.h>
  10. #include <media/cam_defs.h>
  11. #define CAM_SENSOR_PROBE_CMD (CAM_COMMON_OPCODE_MAX + 1)
  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. #define SKEW_CAL_MASK BIT(1)
  17. #define PREAMBLE_PATTEN_CAL_MASK BIT(2)
  18. /* CSIPHY driver cmd buffer meta types */
  19. #define CAM_CSIPHY_PACKET_META_LANE_INFO 0
  20. #define CAM_CSIPHY_PACKET_META_GENERIC_BLOB 1
  21. /* CSIPHY blob types */
  22. #define CAM_CSIPHY_GENERIC_BLOB_TYPE_CDR_CONFIG 0
  23. #define CAM_CSIPHY_GENERIC_BLOB_TYPE_AUX_CONFIG 1
  24. /* CSIPHY CDR tolerance operations */
  25. #define CAM_CSIPHY_CDR_ADD_TOLERANCE 1
  26. #define CAM_CSIPHY_CDR_SUB_TOLERANCE 2
  27. /* SENSOR driver cmd buffer meta types */
  28. #define CAM_SENSOR_PACKET_I2C_COMMANDS 0
  29. #define CAM_SENSOR_PACKET_GENERIC_BLOB 1
  30. /* SENSOR blob types */
  31. #define CAM_SENSOR_GENERIC_BLOB_RES_INFO 0
  32. enum camera_sensor_cmd_type {
  33. CAMERA_SENSOR_CMD_TYPE_INVALID,
  34. CAMERA_SENSOR_CMD_TYPE_PROBE,
  35. CAMERA_SENSOR_CMD_TYPE_PWR_UP,
  36. CAMERA_SENSOR_CMD_TYPE_PWR_DOWN,
  37. CAMERA_SENSOR_CMD_TYPE_I2C_INFO,
  38. CAMERA_SENSOR_CMD_TYPE_I2C_RNDM_WR,
  39. CAMERA_SENSOR_CMD_TYPE_I2C_RNDM_RD,
  40. CAMERA_SENSOR_CMD_TYPE_I2C_CONT_WR,
  41. CAMERA_SENSOR_CMD_TYPE_I2C_CONT_RD,
  42. CAMERA_SENSOR_CMD_TYPE_WAIT,
  43. CAMERA_SENSOR_FLASH_CMD_TYPE_INIT_INFO,
  44. CAMERA_SENSOR_FLASH_CMD_TYPE_FIRE,
  45. CAMERA_SENSOR_FLASH_CMD_TYPE_RER,
  46. CAMERA_SENSOR_FLASH_CMD_TYPE_QUERYCURR,
  47. CAMERA_SENSOR_FLASH_CMD_TYPE_WIDGET,
  48. CAMERA_SENSOR_CMD_TYPE_RD_DATA,
  49. CAMERA_SENSOR_FLASH_CMD_TYPE_INIT_FIRE,
  50. CAMERA_SENSOR_CMD_TYPE_MAX,
  51. };
  52. enum cam_actuator_packet_opcodes {
  53. CAM_ACTUATOR_PACKET_OPCODE_INIT,
  54. CAM_ACTUATOR_PACKET_AUTO_MOVE_LENS,
  55. CAM_ACTUATOR_PACKET_MANUAL_MOVE_LENS,
  56. CAM_ACTUATOR_PACKET_OPCODE_READ
  57. };
  58. enum cam_eeprom_packet_opcodes {
  59. CAM_EEPROM_PACKET_OPCODE_INIT,
  60. CAM_EEPROM_WRITE
  61. };
  62. enum cam_ois_packet_opcodes {
  63. CAM_OIS_PACKET_OPCODE_INIT,
  64. CAM_OIS_PACKET_OPCODE_OIS_CONTROL,
  65. CAM_OIS_PACKET_OPCODE_READ,
  66. CAM_OIS_PACKET_OPCODE_WRITE_TIME
  67. };
  68. enum camera_sensor_i2c_op_code {
  69. CAMERA_SENSOR_I2C_OP_INVALID,
  70. CAMERA_SENSOR_I2C_OP_RNDM_WR,
  71. CAMERA_SENSOR_I2C_OP_RNDM_WR_VERF,
  72. CAMERA_SENSOR_I2C_OP_CONT_WR_BRST,
  73. CAMERA_SENSOR_I2C_OP_CONT_WR_BRST_VERF,
  74. CAMERA_SENSOR_I2C_OP_CONT_WR_SEQN,
  75. CAMERA_SENSOR_I2C_OP_CONT_WR_SEQN_VERF,
  76. CAMERA_SENSOR_I2C_OP_MAX,
  77. };
  78. enum camera_sensor_wait_op_code {
  79. CAMERA_SENSOR_WAIT_OP_INVALID,
  80. CAMERA_SENSOR_WAIT_OP_COND,
  81. CAMERA_SENSOR_WAIT_OP_HW_UCND,
  82. CAMERA_SENSOR_WAIT_OP_SW_UCND,
  83. CAMERA_SENSOR_WAIT_OP_MAX,
  84. };
  85. enum cam_tpg_packet_opcodes {
  86. CAM_TPG_PACKET_OPCODE_INVALID = 0,
  87. CAM_TPG_PACKET_OPCODE_INITIAL_CONFIG,
  88. CAM_TPG_PACKET_OPCODE_NOP,
  89. CAM_TPG_PACKET_OPCODE_MAX,
  90. };
  91. enum cam_sensor_packet_opcodes {
  92. CAM_SENSOR_PACKET_OPCODE_SENSOR_STREAMON,
  93. CAM_SENSOR_PACKET_OPCODE_SENSOR_UPDATE,
  94. CAM_SENSOR_PACKET_OPCODE_SENSOR_INITIAL_CONFIG,
  95. CAM_SENSOR_PACKET_OPCODE_SENSOR_PROBE,
  96. CAM_SENSOR_PACKET_OPCODE_SENSOR_CONFIG,
  97. CAM_SENSOR_PACKET_OPCODE_SENSOR_STREAMOFF,
  98. CAM_SENSOR_PACKET_OPCODE_SENSOR_READ,
  99. CAM_SENSOR_PACKET_OPCODE_SENSOR_FRAME_SKIP_UPDATE,
  100. CAM_SENSOR_PACKET_OPCODE_SENSOR_PROBE_V2,
  101. CAM_SENSOR_PACKET_OPCODE_SENSOR_REG_BANK_UNLOCK,
  102. CAM_SENSOR_PACKET_OPCODE_SENSOR_REG_BANK_LOCK,
  103. CAM_SENSOR_PACKET_OPCODE_SENSOR_NOP = 127,
  104. };
  105. enum tpg_command_type_t {
  106. TPG_CMD_TYPE_INVALID = 0,
  107. TPG_CMD_TYPE_GLOBAL_CONFIG,
  108. TPG_CMD_TYPE_STREAM_CONFIG,
  109. TPG_CMD_TYPE_ILLUMINATION_CONFIG,
  110. TPG_CMD_TYPE_MAX,
  111. };
  112. enum tpg_pattern_t {
  113. TPG_PATTERN_INVALID = 0,
  114. TPG_PATTERN_REAL_IMAGE,
  115. TPG_PATTERN_RANDOM_PIXL,
  116. TPG_PATTERN_RANDOM_INCREMENTING_PIXEL,
  117. TPG_PATTERN_COLOR_BAR,
  118. TPG_PATTERN_ALTERNATING_55_AA,
  119. TPG_PATTERN_ALTERNATING_USER_DEFINED,
  120. TPG_PATTERN_MAX,
  121. };
  122. enum tpg_color_bar_mode_t {
  123. TPG_COLOR_BAR_MODE_INVALID = 0,
  124. TPG_COLOR_BAR_MODE_NORMAL,
  125. TPG_COLOR_BAR_MODE_SPLIT,
  126. TPG_COLOR_BAR_MODE_ROTATING,
  127. TPG_COLOR_BAR_MODE_MAX,
  128. };
  129. enum tpg_image_format_t {
  130. TPG_IMAGE_FORMAT_INVALID = 0,
  131. TPG_IMAGE_FORMAT_BAYER,
  132. TPG_IMAGE_FORMAT_QCFA,
  133. TPG_IMAGE_FORMAT_YUV,
  134. TPG_IMAGE_FORMAT_JPEG,
  135. TPG_IMAGE_FORMAT_MAX,
  136. };
  137. enum tpg_phy_type_t {
  138. TPG_PHY_TYPE_INVALID = 0,
  139. TPG_PHY_TYPE_DPHY,
  140. TPG_PHY_TYPE_CPHY,
  141. TPG_PHY_TYPE_MAX,
  142. };
  143. enum tpg_pixel_type_t {
  144. TPG_PIXEL_TYPE_INVALID = 0,
  145. TPG_PIXEL_TYPE_RED,
  146. TPG_PIXEL_TYPE_GREEN,
  147. TPG_PIXEL_TYPE_BLUE,
  148. TPG_PIXEL_TYPE_IR,
  149. TPG_PIXEL_TYPE_MONO,
  150. };
  151. enum tpg_exposure_type_t {
  152. TPG_EXPOSUREL_TYPE_INVALID = 0,
  153. TPG_EXPOSURE_TYPE_LONG,
  154. TPG_EXPOSURE_TYPE_MIDDLE,
  155. TPG_EXPOSURE_TYPE_SHORT,
  156. };
  157. enum xcfa_type_t {
  158. XCFA_TYPE_BAYER = 0,
  159. XCFA_TYPE_QUADCFA,
  160. XCFA_TYPE_THREEXTHREECFA,
  161. XCFA_TYPE_FOURXFOURCFA,
  162. XCFA_TYPE_RGBIR,
  163. XCFA_TYPE_RGBWC,
  164. XCFA_TYPE_RGBWK,
  165. XCFA_TYPE_UNCONVENTIONAL_BAYER,
  166. };
  167. enum tpg_interleaving_format_t {
  168. TPG_INTERLEAVING_FORMAT_INVALID = 0,
  169. TPG_INTERLEAVING_FORMAT_FRAME,
  170. TPG_INTERLEAVING_FORMAT_LINE,
  171. TPG_INTERLEAVING_FORMAT_SHDR,
  172. TPG_INTERLEAVING_FORMAT_SPARSE_PD,
  173. TPG_INTERLEAVING_FORMAT_MAX,
  174. };
  175. enum tpg_shutter_t {
  176. TPG_SHUTTER_TYPE_INVALID = 0,
  177. TPG_SHUTTER_TYPE_ROLLING,
  178. TPG_SHUTTER_TYPE_GLOBAL,
  179. TPG_SHUTTER_TYPE_MAX,
  180. };
  181. enum tpg_stream_t {
  182. TPG_STREAM_TYPE_INVALID = 0,
  183. TPG_STREAM_TYPE_IMAGE,
  184. TPG_STREAM_TYPE_PDAF,
  185. TPG_STREAM_TYPE_META,
  186. TPG_STREAM_TYPE_MAX,
  187. };
  188. enum tpg_cfa_arrangement_t {
  189. TPG_CFA_ARRANGEMENT_TYPE_INVALID = 0,
  190. TPG_CFA_ARRANGEMENT_TYPE_MAX,
  191. };
  192. /**
  193. * struct cam_sensor_query_cap - capabilities info for sensor
  194. *
  195. * @slot_info : Indicates about the slotId or cell Index
  196. * @secure_camera : Camera is in secure/Non-secure mode
  197. * @pos_pitch : Sensor position pitch
  198. * @pos_roll : Sensor position roll
  199. * @pos_yaw : Sensor position yaw
  200. * @actuator_slot_id : Actuator slot id which connected to sensor
  201. * @eeprom_slot_id : EEPROM slot id which connected to sensor
  202. * @ois_slot_id : OIS slot id which connected to sensor
  203. * @flash_slot_id : Flash slot id which connected to sensor
  204. * @csiphy_slot_id : CSIphy slot id which connected to sensor
  205. *
  206. */
  207. struct cam_sensor_query_cap {
  208. __u32 slot_info;
  209. __u32 secure_camera;
  210. __u32 pos_pitch;
  211. __u32 pos_roll;
  212. __u32 pos_yaw;
  213. __u32 actuator_slot_id;
  214. __u32 eeprom_slot_id;
  215. __u32 ois_slot_id;
  216. __u32 flash_slot_id;
  217. __u32 csiphy_slot_id;
  218. } __attribute__((packed));
  219. /**
  220. * struct cam_csiphy_query_cap - capabilities info for csiphy
  221. *
  222. * @slot_info : Indicates about the slotId or cell Index
  223. * @version : CSIphy version
  224. * @clk lane : Of the 5 lanes, informs lane configured
  225. * as clock lane
  226. * @reserved
  227. */
  228. struct cam_csiphy_query_cap {
  229. __u32 slot_info;
  230. __u32 version;
  231. __u32 clk_lane;
  232. __u32 reserved;
  233. } __attribute__((packed));
  234. /**
  235. * struct cam_actuator_query_cap - capabilities info for actuator
  236. *
  237. * @slot_info : Indicates about the slotId or cell Index
  238. * @reserved
  239. */
  240. struct cam_actuator_query_cap {
  241. __u32 slot_info;
  242. __u32 reserved;
  243. } __attribute__((packed));
  244. /**
  245. * struct cam_eeprom_query_cap_t - capabilities info for eeprom
  246. *
  247. * @slot_info : Indicates about the slotId or cell Index
  248. * @eeprom_kernel_probe : Indicates about the kernel or userspace probe
  249. */
  250. struct cam_eeprom_query_cap_t {
  251. __u32 slot_info;
  252. __u16 eeprom_kernel_probe;
  253. __u16 is_multimodule_mode;
  254. } __attribute__((packed));
  255. /**
  256. * struct cam_ois_query_cap_t - capabilities info for ois
  257. *
  258. * @slot_info : Indicates about the slotId or cell Index
  259. */
  260. struct cam_ois_query_cap_t {
  261. __u32 slot_info;
  262. __u16 reserved;
  263. } __attribute__((packed));
  264. /**
  265. * struct cam_tpg_query_cap - capabilities info for tpg
  266. *
  267. * @slot_info : Indicates about the slotId or cell Index
  268. * @version : TPG version , in msb
  269. * @reserved : Reserved for future Use
  270. * @secure_camera : Camera is in secure/Non-secure mode
  271. * @csiphy_slot_id : CSIphy slot id which connected to sensor
  272. */
  273. struct cam_tpg_query_cap {
  274. __u32 slot_info;
  275. __u32 version;
  276. __u32 secure_camera;
  277. __u32 csiphy_slot_id;
  278. __u32 reserved[2];
  279. } __attribute__((packed));
  280. /**
  281. * struct cam_cmd_i2c_info - Contains slave I2C related info
  282. *
  283. * @slave_addr : Slave address
  284. * @i2c_freq_mode : 4 bits are used for I2c freq mode
  285. * @cmd_type : Explains type of command
  286. */
  287. struct cam_cmd_i2c_info {
  288. __u32 slave_addr;
  289. __u8 i2c_freq_mode;
  290. __u8 cmd_type;
  291. __u16 reserved;
  292. } __attribute__((packed));
  293. /**
  294. * struct cam_cmd_sensor_res_info - Contains sensor res info
  295. *
  296. * res_index is the key property, it specifies the
  297. * combinations of other properties enclosed in this
  298. * structure.
  299. *
  300. * @res_index : The resolution index that gets updated
  301. * during a mode switch
  302. * @fps : Frame rate
  303. * @width : Pixel width to output to csiphy
  304. * @height : Pixel height to output to csiphy
  305. * @caps : Specifies capability sensor is configured
  306. * for, (eg, XCFA, HFR), num_exposures and
  307. * PDAF type
  308. * @num_valid_params : Number of valid params
  309. * @valid_param_mask : Valid param mask
  310. * @params : params
  311. */
  312. struct cam_sensor_res_info {
  313. __u16 res_index;
  314. __u32 fps;
  315. __u32 width;
  316. __u32 height;
  317. char caps[64];
  318. __u32 num_valid_params;
  319. __u32 valid_param_mask;
  320. __u16 params[3];
  321. } __attribute__((packed));
  322. /**
  323. * struct cam_ois_opcode - Contains OIS opcode
  324. *
  325. * @prog : OIS FW prog register address
  326. * @coeff : OIS FW coeff register address
  327. * @pheripheral : OIS pheripheral
  328. * @memory : OIS memory
  329. */
  330. struct cam_ois_opcode {
  331. __u32 prog;
  332. __u32 coeff;
  333. __u32 pheripheral;
  334. __u32 memory;
  335. } __attribute__((packed));
  336. /**
  337. * struct cam_cmd_ois_info - Contains OIS slave info
  338. *
  339. * @slave_addr : OIS i2c slave address
  340. * @i2c_freq_mode : i2c frequency mode
  341. * @cmd_type : Explains type of command
  342. * @ois_fw_flag : indicates if fw is present or not
  343. * @is_ois_calib : indicates the calibration data is available
  344. * @ois_name : OIS name
  345. * @opcode : opcode
  346. */
  347. struct cam_cmd_ois_info {
  348. __u32 slave_addr;
  349. __u8 i2c_freq_mode;
  350. __u8 cmd_type;
  351. __u8 ois_fw_flag;
  352. __u8 is_ois_calib;
  353. char ois_name[MAX_OIS_NAME_SIZE];
  354. struct cam_ois_opcode opcode;
  355. } __attribute__((packed));
  356. /**
  357. * struct cam_cmd_probe - Contains sensor slave info
  358. *
  359. * @data_type : Slave register data type
  360. * @addr_type : Slave register address type
  361. * @op_code : Don't Care
  362. * @cmd_type : Explains type of command
  363. * @reg_addr : Slave register address
  364. * @expected_data : Data expected at slave register address
  365. * @data_mask : Data mask if only few bits are valid
  366. * @camera_id : Indicates the slot to which camera
  367. * needs to be probed
  368. * @reserved
  369. */
  370. struct cam_cmd_probe {
  371. __u8 data_type;
  372. __u8 addr_type;
  373. __u8 op_code;
  374. __u8 cmd_type;
  375. __u32 reg_addr;
  376. __u32 expected_data;
  377. __u32 data_mask;
  378. __u16 camera_id;
  379. __u16 reserved;
  380. } __attribute__((packed));
  381. /**
  382. * struct cam_cmd_probe_v2 - Contains sensor slave info version 2
  383. *
  384. * @data_type : Slave register data type
  385. * @addr_type : Slave register address type
  386. * @op_code : Don't Care
  387. * @cmd_type : Explains type of command
  388. * @reg_addr : Slave register address
  389. * @expected_data : Data expected at slave register address
  390. * @data_mask : Data mask if only few bits are valid
  391. * @camera_id : Indicates the slot to which camera
  392. * needs to be probed
  393. * @pipeline_delay : Pipeline delay
  394. * @logical_camera_id : Logical Camera ID
  395. * @sensor_name : Sensor's name
  396. * @reserved
  397. */
  398. struct cam_cmd_probe_v2 {
  399. __u8 data_type;
  400. __u8 addr_type;
  401. __u8 op_code;
  402. __u8 cmd_type;
  403. __u32 reg_addr;
  404. __u32 expected_data;
  405. __u32 data_mask;
  406. __u16 camera_id;
  407. __u16 pipeline_delay;
  408. __u32 logical_camera_id;
  409. char sensor_name[CAM_SENSOR_NAME_MAX_SIZE];
  410. __u32 reserved[4];
  411. } __attribute__((packed));
  412. /**
  413. * struct cam_power_settings - Contains sensor power setting info
  414. *
  415. * @power_seq_type : Type of power sequence
  416. * @reserved
  417. * @config_val_low : Lower 32 bit value configuration value
  418. * @config_val_high : Higher 32 bit value configuration value
  419. *
  420. */
  421. struct cam_power_settings {
  422. __u16 power_seq_type;
  423. __u16 reserved;
  424. __u32 config_val_low;
  425. __u32 config_val_high;
  426. } __attribute__((packed));
  427. /**
  428. * struct cam_cmd_power - Explains about the power settings
  429. *
  430. * @count : Number of power settings follows
  431. * @reserved
  432. * @cmd_type : Explains type of command
  433. * @power_settings : Contains power setting info
  434. */
  435. struct cam_cmd_power {
  436. __u32 count;
  437. __u8 reserved;
  438. __u8 cmd_type;
  439. __u16 more_reserved;
  440. struct cam_power_settings power_settings[1];
  441. } __attribute__((packed));
  442. /**
  443. * struct i2c_rdwr_header - header of READ/WRITE I2C command
  444. *
  445. * @ count : Number of registers / data / reg-data pairs
  446. * @ op_code : Operation code
  447. * @ cmd_type : Command buffer type
  448. * @ data_type : I2C data type
  449. * @ addr_type : I2C address type
  450. * @ reserved
  451. */
  452. struct i2c_rdwr_header {
  453. __u32 count;
  454. __u8 op_code;
  455. __u8 cmd_type;
  456. __u8 data_type;
  457. __u8 addr_type;
  458. } __attribute__((packed));
  459. /**
  460. * struct i2c_random_wr_payload - payload for I2C random write
  461. *
  462. * @ reg_addr : Register address
  463. * @ reg_data : Register data
  464. *
  465. */
  466. struct i2c_random_wr_payload {
  467. __u32 reg_addr;
  468. __u32 reg_data;
  469. } __attribute__((packed));
  470. /**
  471. * struct cam_cmd_i2c_random_wr - I2C random write command
  472. * @ header : header of READ/WRITE I2C command
  473. * @ random_wr_payload : payload for I2C random write
  474. */
  475. struct cam_cmd_i2c_random_wr {
  476. struct i2c_rdwr_header header;
  477. struct i2c_random_wr_payload random_wr_payload[1];
  478. } __attribute__((packed));
  479. /**
  480. * struct cam_cmd_read - I2C read command
  481. * @ reg_data : Register data
  482. * @ reserved
  483. */
  484. struct cam_cmd_read {
  485. __u32 reg_data;
  486. __u32 reserved;
  487. } __attribute__((packed));
  488. /**
  489. * struct cam_cmd_i2c_continuous_wr - I2C continuous write command
  490. * @ header : header of READ/WRITE I2C command
  491. * @ reg_addr : Register address
  492. * @ data_read : I2C read command
  493. */
  494. struct cam_cmd_i2c_continuous_wr {
  495. struct i2c_rdwr_header header;
  496. __u32 reg_addr;
  497. struct cam_cmd_read data_read[1];
  498. } __attribute__((packed));
  499. /**
  500. * struct cam_cmd_i2c_random_rd - I2C random read command
  501. * @ header : header of READ/WRITE I2C command
  502. * @ data_read : I2C read command
  503. */
  504. struct cam_cmd_i2c_random_rd {
  505. struct i2c_rdwr_header header;
  506. struct cam_cmd_read data_read[1];
  507. } __attribute__((packed));
  508. /**
  509. * struct cam_cmd_i2c_continuous_rd - I2C continuous continuous read command
  510. * @ header : header of READ/WRITE I2C command
  511. * @ reg_addr : Register address
  512. *
  513. */
  514. struct cam_cmd_i2c_continuous_rd {
  515. struct i2c_rdwr_header header;
  516. __u32 reg_addr;
  517. } __attribute__((packed));
  518. /**
  519. * struct cam_cmd_conditional_wait - Conditional wait command
  520. * @data_type : Data type
  521. * @addr_type : Address type
  522. * @op_code : Opcode
  523. * @cmd_type : Explains type of command
  524. * @timeout : Timeout for retries
  525. * @reserved
  526. * @reg_addr : Register Address
  527. * @reg_data : Register data
  528. * @data_mask : Data mask if only few bits are valid
  529. * @camera_id : Indicates the slot to which camera
  530. * needs to be probed
  531. *
  532. */
  533. struct cam_cmd_conditional_wait {
  534. __u8 data_type;
  535. __u8 addr_type;
  536. __u16 reserved;
  537. __u8 op_code;
  538. __u8 cmd_type;
  539. __u16 timeout;
  540. __u32 reg_addr;
  541. __u32 reg_data;
  542. __u32 data_mask;
  543. } __attribute__((packed));
  544. /**
  545. * struct cam_cmd_unconditional_wait - Un-conditional wait command
  546. * @delay : Delay
  547. * @op_code : Opcode
  548. * @cmd_type : Explains type of command
  549. */
  550. struct cam_cmd_unconditional_wait {
  551. __s16 delay;
  552. __s16 reserved;
  553. __u8 op_code;
  554. __u8 cmd_type;
  555. __u16 reserved1;
  556. } __attribute__((packed));
  557. /**
  558. * cam_csiphy_cdr_sweep_params : Provides cdr blob structre
  559. *
  560. * @cdr_tolerance : CDR tolerance param
  561. * @tolerance_op_type : Determines if the tolerance needs to be added/subtracted
  562. * from default CDR value
  563. * @configured_cdr : Configured CDR value for all the lanes for the
  564. * selected data rate, default +/- tolerance,
  565. * this is the output
  566. * @num_valid_params : Number of valid params
  567. * @valid_param_mask : Valid param mask
  568. * @params : params
  569. *
  570. */
  571. struct cam_csiphy_cdr_sweep_params {
  572. __u32 cdr_tolerance;
  573. __u32 tolerance_op_type;
  574. __u32 configured_cdr;
  575. __u32 num_valid_params;
  576. __u32 valid_param_mask;
  577. __u32 params[3];
  578. };
  579. /**
  580. * cam_csiphy_aux_settings_params : Provides aux blob structre
  581. *
  582. * @data_rate_aux_mask : Auxiliary settings update for different data rates,
  583. * this is the output
  584. * @num_valid_params : Number of valid params
  585. * @valid_param_mask : Valid param mask
  586. * @params : params
  587. *
  588. */
  589. struct cam_csiphy_aux_settings_params {
  590. __u64 data_rate_aux_mask;
  591. __u32 num_valid_params;
  592. __u32 valid_param_mask;
  593. __u32 params[2];
  594. };
  595. /**
  596. * cam_csiphy_info : Provides cmdbuffer structre
  597. * @lane_assign : Lane sensor will be using
  598. * @mipi_flags : Phy flags for different calibration operations
  599. * @lane_cnt : Total number of lanes
  600. * @secure_mode : Secure mode flag to enable / disable
  601. * @settle_time : Settling time in ms
  602. * @data_rate : Data rate
  603. *
  604. */
  605. struct cam_csiphy_info {
  606. __u16 reserved;
  607. __u16 lane_assign;
  608. __u16 mipi_flags;
  609. __u8 lane_cnt;
  610. __u8 secure_mode;
  611. __u64 settle_time;
  612. __u64 data_rate;
  613. } __attribute__((packed));
  614. /**
  615. * cam_csiphy_acquire_dev_info : Information needed for
  616. * csiphy at the time of acquire
  617. * @combo_mode : Indicates the device mode of operation
  618. * @cphy_dphy_combo_mode : Info regarding cphy_dphy_combo mode
  619. * @csiphy_3phase : Details whether 3Phase / 2Phase operation
  620. * @reserve
  621. *
  622. */
  623. struct cam_csiphy_acquire_dev_info {
  624. __u32 combo_mode;
  625. __u16 cphy_dphy_combo_mode;
  626. __u8 csiphy_3phase;
  627. __u8 reserve;
  628. } __attribute__((packed));
  629. /**
  630. * cam_sensor_acquire_dev : Updates sensor acuire cmd
  631. * @device_handle : Updates device handle
  632. * @session_handle : Session handle for acquiring device
  633. * @handle_type : Resource handle type
  634. * @reserved
  635. * @info_handle : Handle to additional info
  636. * needed for sensor sub modules
  637. *
  638. */
  639. struct cam_sensor_acquire_dev {
  640. __u32 session_handle;
  641. __u32 device_handle;
  642. __u32 handle_type;
  643. __u32 reserved;
  644. __u64 info_handle;
  645. } __attribute__((packed));
  646. /**
  647. * cam_tpg_acquire_dev : Updates tpg acuire cmd
  648. * @device_handle : Updates device handle
  649. * @session_handle : Session handle for acquiring device
  650. * @handle_type : Resource handle type
  651. * @reserved
  652. * @info_handle : Handle to additional info
  653. * needed for sensor sub modules
  654. */
  655. struct cam_tpg_acquire_dev {
  656. __u32 session_handle;
  657. __u32 device_handle;
  658. __u32 handle_type;
  659. __u32 reserved;
  660. __u64 info_handle;
  661. } __attribute__((packed));
  662. /**
  663. * cam_sensor_streamon_dev : StreamOn command for the sensor
  664. * @session_handle : Session handle for acquiring device
  665. * @device_handle : Updates device handle
  666. * @handle_type : Resource handle type
  667. * @reserved
  668. * @info_handle : Information Needed at the time of streamOn
  669. *
  670. */
  671. struct cam_sensor_streamon_dev {
  672. __u32 session_handle;
  673. __u32 device_handle;
  674. __u32 handle_type;
  675. __u32 reserved;
  676. __u64 info_handle;
  677. } __attribute__((packed));
  678. /**
  679. * stream_dimension : Stream dimension
  680. *
  681. * @left : left pixel locaiton of stream
  682. * @top : top pixel location of stream
  683. * @width : width of the image stream
  684. * @height : Height of the image stream
  685. */
  686. struct stream_dimension {
  687. uint32_t left;
  688. uint32_t top;
  689. uint32_t width;
  690. uint32_t height;
  691. };
  692. /**
  693. * tpg_command_header_t : tpg command common header
  694. *
  695. * @cmd_type : command type
  696. * @size : size of the command including header
  697. * @cmd_version : version of the command associated
  698. */
  699. struct tpg_command_header_t {
  700. __u32 cmd_type;
  701. ssize_t size;
  702. uint32_t cmd_version;
  703. } __attribute__((packed));
  704. /**
  705. * tpg_pixel_coordinate_t : pixel coordinate structure
  706. *
  707. * @xcoordinate : X coordinate
  708. * @ycoordinate : Y coordiante
  709. * @pixel_type : red green blue ir mono
  710. */
  711. struct tpg_pixel_coordinate_t {
  712. uint32_t xcoordinate;
  713. uint32_t ycoordinate;
  714. uint32_t exposure_type;
  715. uint32_t pixel_type;
  716. } __attribute__((packed));
  717. /**
  718. * tpg_cfa_information_t : tpg cfa information structure
  719. *
  720. * @number_of_pixel_per_color : number of pixel per color
  721. * @pattern_width : pattern width
  722. * @pattern_height : pattern height
  723. * @pixel_coordinate_count : pixel coordinate count
  724. * @pixel_coordinate : pixel coordinate array
  725. */
  726. struct tpg_cfa_information_t {
  727. uint32_t number_of_pixel_per_color;
  728. uint32_t pattern_width;
  729. uint32_t pattern_height;
  730. uint32_t pixel_coordinate_count;
  731. struct tpg_pixel_coordinate_t pixel_coordinate[64];
  732. } __attribute__((packed));
  733. /**
  734. * tpg_global_config_t : global configuration command structure
  735. *
  736. * @header : common header
  737. * @phy_type : phy type , cpy , dphy
  738. * @lane_count : number of lanes used
  739. * @interleaving_format : interleaving format used
  740. * @phy_mode : phy mode of operation
  741. * @shutter_type : shutter type
  742. * @mode : if any specific mode needs to configured
  743. * @hbi : horizontal blanking intervel
  744. * @vbi : vertical blanking intervel
  745. * @skip_pattern : frame skip pattern
  746. * @tpg_clock : tpg clock
  747. * @reserved : reserved for future use
  748. */
  749. struct tpg_global_config_t {
  750. struct tpg_command_header_t header;
  751. enum tpg_phy_type_t phy_type;
  752. uint8_t lane_count;
  753. enum tpg_interleaving_format_t interleaving_format;
  754. uint8_t phy_mode;
  755. enum tpg_shutter_t shutter_type;
  756. uint32_t mode;
  757. uint32_t hbi;
  758. uint32_t vbi;
  759. uint32_t skip_pattern;
  760. uint64_t tpg_clock;
  761. uint32_t reserved[4];
  762. } __attribute__((packed));
  763. /**
  764. * tpg_old_stream_config_t : stream configuration command
  765. *
  766. * @header: common tpg command header
  767. * @pattern_type : tpg pattern type used in this stream
  768. * @cb_mode : tpg color bar mode used in this stream
  769. * @frame_count : frame count in case of trigger burst mode
  770. * @stream_type : type of stream like image pdaf etc
  771. * @stream_dimension : Dimension of the stream
  772. * @pixel_depth : bits per each pixel
  773. * @cfa_arrangement : color filter arragement
  774. * @output_format : output image format
  775. * @hbi : horizontal blanking intervel
  776. * @vbi : vertical blanking intervel
  777. * @vc : virtual channel of this stream
  778. * @dt : data type of this stream
  779. * @skip_pattern : skip pattern for this stream
  780. * @rotate_period : rotate period for this stream
  781. * @reserved : reserved for future use
  782. */
  783. struct tpg_old_stream_config_t {
  784. struct tpg_command_header_t header;
  785. enum tpg_pattern_t pattern_type;
  786. enum tpg_color_bar_mode_t cb_mode;
  787. uint32_t frame_count;
  788. enum tpg_stream_t stream_type;
  789. struct stream_dimension stream_dimension;
  790. uint8_t pixel_depth;
  791. enum tpg_cfa_arrangement_t cfa_arrangement;
  792. enum tpg_image_format_t output_format;
  793. uint32_t hbi;
  794. uint32_t vbi;
  795. uint16_t vc;
  796. uint16_t dt;
  797. uint32_t skip_pattern;
  798. uint32_t rotate_period;
  799. uint32_t reserved[4];
  800. } __attribute__((packed));
  801. /**
  802. * tpg_stream_config_t : stream configuration command
  803. *
  804. * @header: common tpg command header
  805. * @pattern_type : tpg pattern type used in this stream
  806. * @cb_mode : tpg color bar mode used in this stream
  807. * @frame_count : frame count in case of trigger burst mode
  808. * @stream_type : type of stream like image pdaf etc
  809. * @stream_dimension : Dimension of the stream
  810. * @pixel_depth : bits per each pixel
  811. * @cfa_arrangement : color filter arragement
  812. * @output_format : output image format
  813. * @hbi : horizontal blanking intervel
  814. * @vbi : vertical blanking intervel
  815. * @vc : virtual channel of this stream
  816. * @dt : data type of this stream
  817. * @skip_pattern : skip pattern for this stream
  818. * @rotate_period : rotate period for this stream
  819. * @xcfa_debug : for xcfa debug;
  820. * @shdr_line_offset0 : for shdr line offset0
  821. * @shdr_line_offset1 : for shdr line offset1
  822. * @reserved : reserved for future use
  823. */
  824. struct tpg_stream_config_t {
  825. struct tpg_command_header_t header;
  826. enum tpg_pattern_t pattern_type;
  827. enum tpg_color_bar_mode_t cb_mode;
  828. uint32_t frame_count;
  829. enum tpg_stream_t stream_type;
  830. struct stream_dimension stream_dimension;
  831. uint8_t pixel_depth;
  832. enum tpg_cfa_arrangement_t cfa_arrangement;
  833. enum tpg_image_format_t output_format;
  834. uint32_t hbi;
  835. uint32_t vbi;
  836. uint16_t vc;
  837. uint16_t dt;
  838. uint32_t skip_pattern;
  839. uint32_t rotate_period;
  840. uint32_t xcfa_debug;
  841. uint32_t shdr_line_offset0;
  842. uint32_t shdr_line_offset1;
  843. uint32_t reserved[4];
  844. } __attribute__((packed));
  845. /**
  846. * tpg_stream_config_t : stream configuration command
  847. *
  848. * @header: common tpg command header
  849. * @pattern_type : tpg pattern type used in this stream
  850. * @cb_mode : tpg color bar mode used in this stream
  851. * @frame_count : frame count in case of trigger burst mode
  852. * @stream_type : type of stream like image pdaf etc
  853. * @stream_dimension : Dimension of the stream
  854. * @pixel_depth : bits per each pixel
  855. * @cfa_arrangement : color filter arragement
  856. * @output_format : output image format
  857. * @hbi : horizontal blanking intervel
  858. * @vbi : vertical blanking intervel
  859. * @vc : virtual channel of this stream
  860. * @dt : data type of this stream
  861. * @skip_pattern : skip pattern for this stream
  862. * @rotate_period : rotate period for this stream
  863. * @shdr_line_offset0 : for shdr line offset0
  864. * @shdr_line_offset1 : for shdr line offset1
  865. * @cfa_info_exist : cfa info exists
  866. * @cfa_info : cfa information
  867. * @xcfa_type : xcfa type
  868. * @reserved : reserved for future use
  869. */
  870. struct tpg_stream_config_v3_t {
  871. struct tpg_command_header_t header;
  872. uint32_t pattern_type;
  873. uint32_t cb_mode;
  874. uint32_t frame_count;
  875. uint32_t stream_type;
  876. struct stream_dimension stream_dimension;
  877. uint32_t pixel_depth;
  878. uint32_t cfa_arrangement;
  879. uint32_t output_format;
  880. uint32_t hbi;
  881. uint32_t vbi;
  882. uint16_t vc;
  883. uint16_t dt;
  884. uint32_t skip_pattern;
  885. uint32_t rotate_period;
  886. uint32_t xcfa_debug;
  887. uint32_t shdr_line_offset0;
  888. uint32_t shdr_line_offset1;
  889. uint32_t cfa_info_exist;
  890. struct tpg_cfa_information_t cfa_info;
  891. uint32_t xcfa_type;
  892. uint32_t reserved[5];
  893. } __attribute__((packed));
  894. /**
  895. * tpg_illumination_control : illumianation control command
  896. *
  897. * @header : common header for tpg command
  898. * @vc : virtual channel to identify the stream
  899. * @dt : dt to identify the stream
  900. * @exposure_short : short exposure time
  901. * @exposure_mid : mid exposure time
  902. * @exposure_long : long exposure time
  903. * @r_gain : r channel gain
  904. * @g_gain : g channel gain
  905. * @b_gain : b channel gain
  906. * @reserved : reserved for future use
  907. */
  908. struct tpg_illumination_control {
  909. struct tpg_command_header_t header;
  910. uint16_t vc;
  911. uint16_t dt;
  912. uint32_t exposure_short;
  913. uint32_t exposure_mid;
  914. uint32_t exposure_long;
  915. uint16_t r_gain;
  916. uint16_t g_gain;
  917. uint16_t b_gain;
  918. uint32_t reserved[4];
  919. } __attribute__((packed));
  920. /**
  921. * struct cam_flash_init : Init command for the flash
  922. * @flash_type : flash hw type
  923. * @reserved
  924. * @cmd_type : command buffer type
  925. */
  926. struct cam_flash_init {
  927. __u32 flash_type;
  928. __u8 reserved;
  929. __u8 cmd_type;
  930. __u16 reserved1;
  931. } __attribute__((packed));
  932. /**
  933. * struct cam_flash_set_rer : RedEyeReduction command buffer
  934. *
  935. * @count : Number of flash leds
  936. * @opcode : Command buffer opcode
  937. * CAM_FLASH_FIRE_RER
  938. * @cmd_type : command buffer operation type
  939. * @num_iteration : Number of led turn on/off sequence
  940. * @reserved
  941. * @led_on_delay_ms : flash led turn on time in ms
  942. * @led_off_delay_ms : flash led turn off time in ms
  943. * @led_current_ma : flash led current in ma
  944. *
  945. */
  946. struct cam_flash_set_rer {
  947. __u32 count;
  948. __u8 opcode;
  949. __u8 cmd_type;
  950. __u16 num_iteration;
  951. __u32 led_on_delay_ms;
  952. __u32 led_off_delay_ms;
  953. __u32 led_current_ma[CAM_FLASH_MAX_LED_TRIGGERS];
  954. } __attribute__((packed));
  955. /**
  956. * struct cam_flash_set_on_off : led turn on/off command buffer
  957. *
  958. * @count : Number of Flash leds
  959. * @opcode : Command buffer opcodes
  960. * CAM_FLASH_FIRE_LOW
  961. * CAM_FLASH_FIRE_HIGH
  962. * CAM_FLASH_OFF
  963. * @cmd_type : Command buffer operation type
  964. * @led_current_ma : Flash led current in ma
  965. * @time_on_duration_ns : Flash time on duration in ns
  966. * @led_on_wait_time_ns : Flash led turn on wait time in ns
  967. *
  968. */
  969. struct cam_flash_set_on_off {
  970. __u32 count;
  971. __u8 opcode;
  972. __u8 cmd_type;
  973. __u16 reserved;
  974. __u32 led_current_ma[CAM_FLASH_MAX_LED_TRIGGERS];
  975. __u64 time_on_duration_ns;
  976. __u64 led_on_wait_time_ns;
  977. } __attribute__((packed));
  978. /**
  979. * struct cam_flash_query_curr : query current command buffer
  980. *
  981. * @reserved
  982. * @opcode : command buffer opcode
  983. * @cmd_type : command buffer operation type
  984. * @query_current_ma : battery current in ma
  985. *
  986. */
  987. struct cam_flash_query_curr {
  988. __u16 reserved;
  989. __u8 opcode;
  990. __u8 cmd_type;
  991. __u32 query_current_ma;
  992. } __attribute__ ((packed));
  993. /**
  994. * struct cam_flash_query_cap : capabilities info for flash
  995. *
  996. * @slot_info : Indicates about the slotId or cell Index
  997. * @max_current_flash : max supported current for flash
  998. * @max_duration_flash : max flash turn on duration
  999. * @max_current_torch : max supported current for torch
  1000. *
  1001. */
  1002. struct cam_flash_query_cap_info {
  1003. __u32 slot_info;
  1004. __u32 max_current_flash[CAM_FLASH_MAX_LED_TRIGGERS];
  1005. __u32 max_duration_flash[CAM_FLASH_MAX_LED_TRIGGERS];
  1006. __u32 max_current_torch[CAM_FLASH_MAX_LED_TRIGGERS];
  1007. } __attribute__ ((packed));
  1008. #endif