cam_sensor.h 33 KB

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