cam_sensor.h 34 KB

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