cam_defs.h 35 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990
  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) 2022-2023 Qualcomm Innovation Center, Inc. All rights reserved.
  5. */
  6. #ifndef __UAPI_CAM_DEFS_H__
  7. #define __UAPI_CAM_DEFS_H__
  8. #include <linux/videodev2.h>
  9. #include <linux/types.h>
  10. #include <linux/ioctl.h>
  11. /* camera op codes */
  12. #define CAM_COMMON_OPCODE_BASE 0x100
  13. #define CAM_QUERY_CAP (CAM_COMMON_OPCODE_BASE + 0x1)
  14. #define CAM_ACQUIRE_DEV (CAM_COMMON_OPCODE_BASE + 0x2)
  15. #define CAM_START_DEV (CAM_COMMON_OPCODE_BASE + 0x3)
  16. #define CAM_STOP_DEV (CAM_COMMON_OPCODE_BASE + 0x4)
  17. #define CAM_CONFIG_DEV (CAM_COMMON_OPCODE_BASE + 0x5)
  18. #define CAM_RELEASE_DEV (CAM_COMMON_OPCODE_BASE + 0x6)
  19. #define CAM_SD_SHUTDOWN (CAM_COMMON_OPCODE_BASE + 0x7)
  20. #define CAM_FLUSH_REQ (CAM_COMMON_OPCODE_BASE + 0x8)
  21. #define CAM_QUERY_CAP_V2 (CAM_COMMON_OPCODE_BASE + 0x9)
  22. #define CAM_COMMON_OPCODE_MAX (CAM_COMMON_OPCODE_BASE + 0xa)
  23. #define CAM_COMMON_OPCODE_BASE_v2 0x150
  24. #define CAM_ACQUIRE_HW (CAM_COMMON_OPCODE_BASE_v2 + 0x1)
  25. #define CAM_RELEASE_HW (CAM_COMMON_OPCODE_BASE_v2 + 0x2)
  26. #define CAM_DUMP_REQ (CAM_COMMON_OPCODE_BASE_v2 + 0x3)
  27. #define CAM_QUERY_CAP_V3 (CAM_COMMON_OPCODE_BASE_v2 + 0x4)
  28. #define CAM_SYNX_TEST_TRIGGER (CAM_COMMON_OPCODE_BASE_v2 + 0x5)
  29. #define CAM_EXT_OPCODE_BASE 0x200
  30. #define CAM_CONFIG_DEV_EXTERNAL (CAM_EXT_OPCODE_BASE + 0x1)
  31. /* camera handle type */
  32. #define CAM_HANDLE_USER_POINTER 1
  33. #define CAM_HANDLE_MEM_HANDLE 2
  34. /* Generic Blob CmdBuffer header properties */
  35. #define CAM_GENERIC_BLOB_CMDBUFFER_SIZE_MASK 0xFFFFFF00
  36. #define CAM_GENERIC_BLOB_CMDBUFFER_SIZE_SHIFT 8
  37. #define CAM_GENERIC_BLOB_CMDBUFFER_TYPE_MASK 0xFF
  38. #define CAM_GENERIC_BLOB_CMDBUFFER_TYPE_SHIFT 0
  39. /* Command Buffer Types */
  40. #define CAM_CMD_BUF_DMI 0x1
  41. #define CAM_CMD_BUF_DMI16 0x2
  42. #define CAM_CMD_BUF_DMI32 0x3
  43. #define CAM_CMD_BUF_DMI64 0x4
  44. #define CAM_CMD_BUF_DIRECT 0x5
  45. #define CAM_CMD_BUF_INDIRECT 0x6
  46. #define CAM_CMD_BUF_I2C 0x7
  47. #define CAM_CMD_BUF_FW 0x8
  48. #define CAM_CMD_BUF_GENERIC 0x9
  49. #define CAM_CMD_BUF_LEGACY 0xA
  50. /* UBWC API Version */
  51. #define CAM_UBWC_CFG_VERSION_1 1
  52. #define CAM_UBWC_CFG_VERSION_2 2
  53. #define CAM_MAX_ACQ_RES 5
  54. #define CAM_MAX_HW_SPLIT 3
  55. /**
  56. * enum flush_type_t - Identifies the various flush types
  57. *
  58. * @CAM_FLUSH_TYPE_REQ: Flush specific request
  59. * @CAM_FLUSH_TYPE_ALL: Flush all requests belonging to a context
  60. * @CAM_FLUSH_TYPE_MAX: Max enum to validate flush type
  61. *
  62. */
  63. enum flush_type_t {
  64. CAM_FLUSH_TYPE_REQ,
  65. CAM_FLUSH_TYPE_ALL,
  66. CAM_FLUSH_TYPE_MAX
  67. };
  68. /**
  69. * struct cam_control - Structure used by ioctl control for camera
  70. *
  71. * @op_code: This is the op code for camera control
  72. * @size: Control command size
  73. * @handle_type: User pointer or shared memory handle
  74. * @reserved: Reserved field for 64 bit alignment
  75. * @handle: Control command payload
  76. */
  77. struct cam_control {
  78. __u32 op_code;
  79. __u32 size;
  80. __u32 handle_type;
  81. __u32 reserved;
  82. __u64 handle;
  83. };
  84. /* camera IOCTL */
  85. #define VIDIOC_CAM_CONTROL \
  86. _IOWR('V', BASE_VIDIOC_PRIVATE, struct cam_control)
  87. /**
  88. * struct cam_hw_version - Structure for HW version of camera devices
  89. *
  90. * @major : Hardware version major
  91. * @minor : Hardware version minor
  92. * @incr : Hardware version increment
  93. * @reserved : Reserved for 64 bit aligngment
  94. */
  95. struct cam_hw_version {
  96. __u32 major;
  97. __u32 minor;
  98. __u32 incr;
  99. __u32 reserved;
  100. };
  101. /**
  102. * struct cam_iommu_handle - Structure for IOMMU handles of camera hw devices
  103. *
  104. * @non_secure: Device Non Secure IOMMU handle
  105. * @secure: Device Secure IOMMU handle
  106. *
  107. */
  108. struct cam_iommu_handle {
  109. __s32 non_secure;
  110. __s32 secure;
  111. };
  112. /* camera secure mode */
  113. #define CAM_SECURE_MODE_NON_SECURE 0
  114. #define CAM_SECURE_MODE_SECURE 1
  115. /* Camera Format Type */
  116. #define CAM_FORMAT_BASE 0
  117. #define CAM_FORMAT_MIPI_RAW_6 1
  118. #define CAM_FORMAT_MIPI_RAW_8 2
  119. #define CAM_FORMAT_MIPI_RAW_10 3
  120. #define CAM_FORMAT_MIPI_RAW_12 4
  121. #define CAM_FORMAT_MIPI_RAW_14 5
  122. #define CAM_FORMAT_MIPI_RAW_16 6
  123. #define CAM_FORMAT_MIPI_RAW_20 7
  124. #define CAM_FORMAT_QTI_RAW_8 8
  125. #define CAM_FORMAT_QTI_RAW_10 9
  126. #define CAM_FORMAT_QTI_RAW_12 10
  127. #define CAM_FORMAT_QTI_RAW_14 11
  128. #define CAM_FORMAT_PLAIN8 12
  129. #define CAM_FORMAT_PLAIN16_8 13
  130. #define CAM_FORMAT_PLAIN16_10 14
  131. #define CAM_FORMAT_PLAIN16_12 15
  132. #define CAM_FORMAT_PLAIN16_14 16
  133. #define CAM_FORMAT_PLAIN16_16 17
  134. #define CAM_FORMAT_PLAIN32_20 18
  135. #define CAM_FORMAT_PLAIN64 19
  136. #define CAM_FORMAT_PLAIN128 20
  137. #define CAM_FORMAT_ARGB 21
  138. #define CAM_FORMAT_ARGB_10 22
  139. #define CAM_FORMAT_ARGB_12 23
  140. #define CAM_FORMAT_ARGB_14 24
  141. #define CAM_FORMAT_DPCM_10_6_10 25
  142. #define CAM_FORMAT_DPCM_10_8_10 26
  143. #define CAM_FORMAT_DPCM_12_6_12 27
  144. #define CAM_FORMAT_DPCM_12_8_12 28
  145. #define CAM_FORMAT_DPCM_14_8_14 29
  146. #define CAM_FORMAT_DPCM_14_10_14 30
  147. #define CAM_FORMAT_NV21 31
  148. #define CAM_FORMAT_NV12 32
  149. #define CAM_FORMAT_TP10 33
  150. #define CAM_FORMAT_YUV422 34
  151. #define CAM_FORMAT_PD8 35
  152. #define CAM_FORMAT_PD10 36
  153. #define CAM_FORMAT_UBWC_NV12 37
  154. #define CAM_FORMAT_UBWC_NV12_4R 38
  155. #define CAM_FORMAT_UBWC_TP10 39
  156. #define CAM_FORMAT_UBWC_P010 40
  157. #define CAM_FORMAT_PLAIN8_SWAP 41
  158. #define CAM_FORMAT_PLAIN8_10 42
  159. #define CAM_FORMAT_PLAIN8_10_SWAP 43
  160. #define CAM_FORMAT_YV12 44
  161. #define CAM_FORMAT_Y_ONLY 45
  162. #define CAM_FORMAT_DPCM_12_10_12 46
  163. #define CAM_FORMAT_PLAIN32 47
  164. #define CAM_FORMAT_ARGB_16 48
  165. #define CAM_FORMAT_PLAIN16_10_LSB 49
  166. #define CAM_FORMAT_YUV422_10 50
  167. #define CAM_FORMAT_GBR_UBWC_TP10 51
  168. #define CAM_FORMAT_GBR_TP10 52
  169. #define CAM_FORMAT_UBWC_P016 53
  170. #define CAM_FORMAT_BAYER_UBWC_TP10 54
  171. /* This macro is deprecated and no longer needed */
  172. #define CAM_FORMAT_MAX 51
  173. /* Pixel Patterns */
  174. #define PIXEL_PATTERN_RGRGRG 0x0
  175. #define PIXEL_PATTERN_GRGRGR 0x1
  176. #define PIXEL_PATTERN_BGBGBG 0x2
  177. #define PIXEL_PATTERN_GBGBGB 0x3
  178. #define PIXEL_PATTERN_YCBYCR 0x4
  179. #define PIXEL_PATTERN_YCRYCB 0x5
  180. #define PIXEL_PATTERN_CBYCRY 0x6
  181. #define PIXEL_PATTERN_CRYCBY 0x7
  182. /* camera rotaion */
  183. #define CAM_ROTATE_CW_0_DEGREE 0
  184. #define CAM_ROTATE_CW_90_DEGREE 1
  185. #define CAM_RORATE_CW_180_DEGREE 2
  186. #define CAM_ROTATE_CW_270_DEGREE 3
  187. /* camera Color Space */
  188. #define CAM_COLOR_SPACE_BASE 0
  189. #define CAM_COLOR_SPACE_BT601_FULL 1
  190. #define CAM_COLOR_SPACE_BT601625 2
  191. #define CAM_COLOR_SPACE_BT601525 3
  192. #define CAM_COLOR_SPACE_BT709 4
  193. #define CAM_COLOR_SPACE_DEPTH 5
  194. #define CAM_COLOR_SPACE_MAX 6
  195. /* camera buffer direction */
  196. #define CAM_BUF_INPUT 1
  197. #define CAM_BUF_OUTPUT 2
  198. #define CAM_BUF_IN_OUT 3
  199. /* camera packet device Type */
  200. #define CAM_PACKET_DEV_BASE 0
  201. #define CAM_PACKET_DEV_IMG_SENSOR 1
  202. #define CAM_PACKET_DEV_ACTUATOR 2
  203. #define CAM_PACKET_DEV_COMPANION 3
  204. #define CAM_PACKET_DEV_EEPOM 4
  205. #define CAM_PACKET_DEV_CSIPHY 5
  206. #define CAM_PACKET_DEV_OIS 6
  207. #define CAM_PACKET_DEV_FLASH 7
  208. #define CAM_PACKET_DEV_FD 8
  209. #define CAM_PACKET_DEV_JPEG_ENC 9
  210. #define CAM_PACKET_DEV_JPEG_DEC 10
  211. #define CAM_PACKET_DEV_VFE 11
  212. #define CAM_PACKET_DEV_CPP 12
  213. #define CAM_PACKET_DEV_CSID 13
  214. #define CAM_PACKET_DEV_ISPIF 14
  215. #define CAM_PACKET_DEV_IFE 15
  216. #define CAM_PACKET_DEV_ICP 16
  217. #define CAM_PACKET_DEV_LRME 17
  218. #define CAM_PACKET_DEV_TFE 18
  219. #define CAM_PACKET_DEV_OPE 19
  220. #define CAM_PACKET_DEV_MAX 20
  221. /* Register base type */
  222. #define CAM_REG_DUMP_BASE_TYPE_ISP_LEFT 1
  223. #define CAM_REG_DUMP_BASE_TYPE_ISP_RIGHT 2
  224. #define CAM_REG_DUMP_BASE_TYPE_CAMNOC 3
  225. #define CAM_REG_DUMP_BASE_TYPE_CSID_WRAPPER 4
  226. #define CAM_REG_DUMP_BASE_TYPE_CSID_LEFT 5
  227. #define CAM_REG_DUMP_BASE_TYPE_CSID_RIGHT 6
  228. #define CAM_REG_DUMP_BASE_TYPE_SFE_LEFT 7
  229. #define CAM_REG_DUMP_BASE_TYPE_SFE_RIGHT 8
  230. /* Register dump read type */
  231. #define CAM_REG_DUMP_READ_TYPE_CONT_RANGE 1
  232. #define CAM_REG_DUMP_READ_TYPE_DMI 2
  233. /* Max number of config writes to read from DMI */
  234. #define CAM_REG_DUMP_DMI_CONFIG_MAX 5
  235. /* constants */
  236. #define CAM_PACKET_MAX_PLANES 3
  237. /* synx test cmd types */
  238. #define CAM_SYNX_TEST_CMD_TYPE_CORE_CTRL 1
  239. #define CAM_SYNX_TEST_CMD_TYPE_SYNX_CMD 2
  240. /**
  241. * struct cam_plane_cfg - Plane configuration info
  242. *
  243. * @width: Plane width in pixels
  244. * @height: Plane height in lines
  245. * @plane_stride: Plane stride in pixel
  246. * @slice_height: Slice height in line (not used by ISP)
  247. * @meta_stride: UBWC metadata stride
  248. * @meta_size: UBWC metadata plane size
  249. * @meta_offset: UBWC metadata offset
  250. * @packer_config: UBWC packer config
  251. * @mode_config: UBWC mode config
  252. * @tile_config: UBWC tile config
  253. * @h_init: UBWC horizontal initial coordinate in pixels
  254. * @v_init: UBWC vertical initial coordinate in lines
  255. *
  256. */
  257. struct cam_plane_cfg {
  258. __u32 width;
  259. __u32 height;
  260. __u32 plane_stride;
  261. __u32 slice_height;
  262. __u32 meta_stride;
  263. __u32 meta_size;
  264. __u32 meta_offset;
  265. __u32 packer_config;
  266. __u32 mode_config;
  267. __u32 tile_config;
  268. __u32 h_init;
  269. __u32 v_init;
  270. };
  271. /**
  272. * struct cam_ubwc_plane_cfg_v1 - UBWC Plane configuration info
  273. *
  274. * @port_type: Port Type
  275. * @meta_stride: UBWC metadata stride
  276. * @meta_size: UBWC metadata plane size
  277. * @meta_offset: UBWC metadata offset
  278. * @packer_config: UBWC packer config
  279. * @mode_config_0: UBWC mode config 0
  280. * @mode_config_1: UBWC 3 mode config 1
  281. * @tile_config: UBWC tile config
  282. * @h_init: UBWC horizontal initial coordinate in pixels
  283. * @v_init: UBWC vertical initial coordinate in lines
  284. *
  285. */
  286. struct cam_ubwc_plane_cfg_v1 {
  287. __u32 port_type;
  288. __u32 meta_stride;
  289. __u32 meta_size;
  290. __u32 meta_offset;
  291. __u32 packer_config;
  292. __u32 mode_config_0;
  293. __u32 mode_config_1;
  294. __u32 tile_config;
  295. __u32 h_init;
  296. __u32 v_init;
  297. };
  298. /**
  299. * struct cam_ubwc_plane_cfg_v2 - UBWC Plane configuration info
  300. *
  301. * @port_type: Port Type
  302. * @meta_stride: UBWC metadata stride
  303. * @meta_size: UBWC metadata plane size
  304. * @meta_offset: UBWC metadata offset
  305. * @packer_config: UBWC packer config
  306. * @mode_config: UBWC mode config
  307. * @static ctrl: UBWC static ctrl
  308. * @ctrl_2: UBWC ctrl 2
  309. * @tile_config: UBWC tile config
  310. * @h_init: UBWC horizontal initial coordinate in pixels
  311. * @v_init: UBWC vertical initial coordinate in lines
  312. * @stats_ctrl_2: UBWC stats control
  313. * @lossy_threshold0 UBWC lossy threshold 0
  314. * @lossy_threshold1 UBWC lossy threshold 1
  315. * @lossy_var_offset UBWC offset variance thrshold
  316. * @bandwidth_limit: BW counter limit
  317. * BW limiter config skipped if value is 0xFFFF or more
  318. * If skipped here, use generic BW limiter blob to
  319. * configure the appropriate value.
  320. *
  321. */
  322. struct cam_ubwc_plane_cfg_v2 {
  323. __u32 port_type;
  324. __u32 meta_stride;
  325. __u32 meta_size;
  326. __u32 meta_offset;
  327. __u32 packer_config;
  328. __u32 mode_config_0;
  329. __u32 mode_config_1;
  330. __u32 tile_config;
  331. __u32 h_init;
  332. __u32 v_init;
  333. __u32 static_ctrl;
  334. __u32 ctrl_2;
  335. __u32 stats_ctrl_2;
  336. __u32 lossy_threshold_0;
  337. __u32 lossy_threshold_1;
  338. __u32 lossy_var_offset;
  339. __u32 bandwidth_limit;
  340. __u32 reserved[3];
  341. };
  342. /**
  343. * struct cam_cmd_buf_desc - Command buffer descriptor
  344. *
  345. * @mem_handle: Command buffer handle
  346. * @offset: Command start offset
  347. * @size: Size of the command buffer in bytes
  348. * @length: Used memory in command buffer in bytes
  349. * @type: Type of the command buffer
  350. * @meta_data: Data type for private command buffer
  351. * Between UMD and KMD
  352. *
  353. */
  354. struct cam_cmd_buf_desc {
  355. __s32 mem_handle;
  356. __u32 offset;
  357. __u32 size;
  358. __u32 length;
  359. __u32 type;
  360. __u32 meta_data;
  361. };
  362. /**
  363. * struct cam_buf_io_cfg - Buffer io configuration for buffers
  364. *
  365. * @mem_handle: Mem_handle array for the buffers.
  366. * @offsets: Offsets for each planes in the buffer
  367. * @planes: Per plane information
  368. * @width: Main plane width in pixel
  369. * @height: Main plane height in lines
  370. * @format: Format of the buffer
  371. * @color_space: Color space for the buffer
  372. * @color_pattern: Color pattern in the buffer
  373. * @bpp: Bit per pixel
  374. * @rotation: Rotation information for the buffer
  375. * @resource_type: Resource type associated with the buffer
  376. * @fence: Fence handle
  377. * @early_fence: Fence handle for early signal
  378. * @aux_cmd_buf: An auxiliary command buffer that may be
  379. * used for programming the IO
  380. * @direction: Direction of the config
  381. * @batch_size: Batch size in HFR mode
  382. * @subsample_pattern: Subsample pattern. Used in HFR mode. It
  383. * should be consistent with batchSize and
  384. * CAMIF programming.
  385. * @subsample_period: Subsample period. Used in HFR mode. It
  386. * should be consistent with batchSize and
  387. * CAMIF programming.
  388. * @framedrop_pattern: Framedrop pattern
  389. * @framedrop_period: Framedrop period
  390. * @flag: Flags for extra information
  391. * for acquired version 3--> corresponds to context_id
  392. * @direction: Buffer direction: input or output
  393. * @padding: Padding for the structure
  394. *
  395. */
  396. struct cam_buf_io_cfg {
  397. __s32 mem_handle[CAM_PACKET_MAX_PLANES];
  398. __u32 offsets[CAM_PACKET_MAX_PLANES];
  399. struct cam_plane_cfg planes[CAM_PACKET_MAX_PLANES];
  400. __u32 format;
  401. __u32 color_space;
  402. __u32 color_pattern;
  403. __u32 bpp;
  404. __u32 rotation;
  405. __u32 resource_type;
  406. __s32 fence;
  407. __s32 early_fence;
  408. struct cam_cmd_buf_desc aux_cmd_buf;
  409. __u32 direction;
  410. __u32 batch_size;
  411. __u32 subsample_pattern;
  412. __u32 subsample_period;
  413. __u32 framedrop_pattern;
  414. __u32 framedrop_period;
  415. __u32 flag;
  416. __u32 padding;
  417. };
  418. /**
  419. * struct cam_packet_header - Camera packet header
  420. *
  421. * @op_code: Camera packet opcode
  422. * @size: Size of the camera packet in bytes
  423. * @request_id: Request id for this camera packet
  424. * @flags: Flags for the camera packet
  425. * @padding: Padding
  426. *
  427. */
  428. struct cam_packet_header {
  429. __u32 op_code;
  430. __u32 size;
  431. __u64 request_id;
  432. __u32 flags;
  433. __u32 padding;
  434. };
  435. /**
  436. * struct cam_patch_desc - Patch structure
  437. *
  438. * @dst_buf_hdl: Memory handle for the dest buffer
  439. * @dst_offset: Offset byte in the dest buffer
  440. * @src_buf_hdl: Memory handle for the source buffer
  441. * @src_offset: Offset byte in the source buffer
  442. *
  443. */
  444. struct cam_patch_desc {
  445. __s32 dst_buf_hdl;
  446. __u32 dst_offset;
  447. __s32 src_buf_hdl;
  448. __u32 src_offset;
  449. };
  450. /**
  451. * struct cam_packet - Camera packet structure
  452. *
  453. * @header: Camera packet header
  454. * @cmd_buf_offset: Command buffer start offset
  455. * @num_cmd_buf: Number of the command buffer in the packet
  456. * @io_config_offset: Buffer io configuration start offset
  457. * @num_io_configs: Number of the buffer io configurations
  458. * @patch_offset: Patch offset for the patch structure
  459. * @num_patches: Number of the patch structure
  460. * @kmd_cmd_buf_index: Command buffer index which contains extra
  461. * space for the KMD buffer
  462. * @kmd_cmd_buf_offset: Offset from the beginning of the command
  463. * buffer for KMD usage.
  464. * @payload: Camera packet payload
  465. *
  466. */
  467. struct cam_packet {
  468. struct cam_packet_header header;
  469. __u32 cmd_buf_offset;
  470. __u32 num_cmd_buf;
  471. __u32 io_configs_offset;
  472. __u32 num_io_configs;
  473. __u32 patch_offset;
  474. __u32 num_patches;
  475. __u32 kmd_cmd_buf_index;
  476. __u32 kmd_cmd_buf_offset;
  477. __u64 payload[1];
  478. };
  479. /**
  480. * struct cam_release_dev_cmd - Control payload for release devices
  481. *
  482. * @session_handle: Session handle for the release
  483. * @dev_handle: Device handle for the release
  484. */
  485. struct cam_release_dev_cmd {
  486. __s32 session_handle;
  487. __s32 dev_handle;
  488. };
  489. /**
  490. * struct cam_start_stop_dev_cmd - Control payload for start/stop device
  491. *
  492. * @session_handle: Session handle for the start/stop command
  493. * @dev_handle: Device handle for the start/stop command
  494. *
  495. */
  496. struct cam_start_stop_dev_cmd {
  497. __s32 session_handle;
  498. __s32 dev_handle;
  499. };
  500. /**
  501. * struct cam_config_dev_cmd - Command payload for configure device
  502. *
  503. * @session_handle: Session handle for the command
  504. * @dev_handle: Device handle for the command
  505. * @offset: Offset byte in the packet handle.
  506. * @packet_handle: Packet memory handle for the actual packet:
  507. * struct cam_packet.
  508. *
  509. */
  510. struct cam_config_dev_cmd {
  511. __s32 session_handle;
  512. __s32 dev_handle;
  513. __u64 offset;
  514. __u64 packet_handle;
  515. };
  516. /**
  517. * struct cam_query_cap_cmd - Payload for query device capability
  518. *
  519. * @size: Handle size
  520. * @handle_type: User pointer or shared memory handle
  521. * @caps_handle: Device specific query command payload
  522. *
  523. */
  524. struct cam_query_cap_cmd {
  525. __u32 size;
  526. __u32 handle_type;
  527. __u64 caps_handle;
  528. };
  529. /**
  530. * struct cam_acquire_dev_cmd - Control payload for acquire devices
  531. *
  532. * @session_handle: Session handle for the acquire command
  533. * @dev_handle: Device handle to be returned
  534. * @handle_type: Resource handle type:
  535. * 1 = user pointer, 2 = mem handle
  536. * @num_resources: Number of the resources to be acquired
  537. * @resources_hdl: Resource handle that refers to the actual
  538. * resource array. Each item in this
  539. * array is device specific resource structure
  540. *
  541. */
  542. struct cam_acquire_dev_cmd {
  543. __s32 session_handle;
  544. __s32 dev_handle;
  545. __u32 handle_type;
  546. __u32 num_resources;
  547. __u64 resource_hdl;
  548. };
  549. /*
  550. * In old version, while acquiring device the num_resources in
  551. * struct cam_acquire_dev_cmd will be a valid value. During ACQUIRE_DEV
  552. * KMD driver will return dev_handle as well as associate HW to handle.
  553. * If num_resources is set to the constant below, we are using
  554. * the new version and we do not acquire HW in ACQUIRE_DEV IOCTL.
  555. * ACQUIRE_DEV will only return handle and we should receive
  556. * ACQUIRE_HW IOCTL after ACQUIRE_DEV and that is when the HW
  557. * is associated with the dev_handle.
  558. *
  559. * (Data type): __u32
  560. */
  561. #define CAM_API_COMPAT_CONSTANT 0xFEFEFEFE
  562. #define CAM_ACQUIRE_HW_STRUCT_VERSION_1 1
  563. #define CAM_ACQUIRE_HW_STRUCT_VERSION_2 2
  564. /**
  565. * struct cam_acquire_hw_cmd_v1 - Control payload for acquire HW IOCTL (Ver 1)
  566. *
  567. * @struct_version: = CAM_ACQUIRE_HW_STRUCT_VERSION_1 for this struct
  568. * This value should be the first 32-bits in any structure
  569. * related to this IOCTL. So that if the struct needs to
  570. * change, we can first read the starting 32-bits, get the
  571. * version number and then typecast the data to struct
  572. * accordingly.
  573. * @reserved: Reserved field for 64-bit alignment
  574. * @session_handle: Session handle for the acquire command
  575. * @dev_handle: Device handle to be returned
  576. * @handle_type: Tells you how to interpret the variable resource_hdl-
  577. * 1 = user pointer, 2 = mem handle
  578. * @data_size: Total size of data contained in memory pointed
  579. * to by resource_hdl
  580. * @resource_hdl: Resource handle that refers to the actual
  581. * resource data.
  582. */
  583. struct cam_acquire_hw_cmd_v1 {
  584. __u32 struct_version;
  585. __u32 reserved;
  586. __s32 session_handle;
  587. __s32 dev_handle;
  588. __u32 handle_type;
  589. __u32 data_size;
  590. __u64 resource_hdl;
  591. };
  592. /**
  593. * struct cam_acquired_hw_info - Update the acquired hardware info
  594. *
  595. * @acquired_hw_id: Acquired hardware mask
  596. * @acquired_hw_path: Acquired path mask for an input
  597. * if input splits into multiple paths,
  598. * its updated per hardware
  599. * valid_acquired_hw: Valid num of acquired hardware
  600. */
  601. struct cam_acquired_hw_info {
  602. __u32 acquired_hw_id[CAM_MAX_ACQ_RES];
  603. __u32 acquired_hw_path[CAM_MAX_ACQ_RES][CAM_MAX_HW_SPLIT];
  604. __u32 valid_acquired_hw;
  605. };
  606. /**
  607. * struct cam_acquire_hw_cmd_v2 - Control payload for acquire HW IOCTL (Ver 2)
  608. *
  609. * @struct_version: = CAM_ACQUIRE_HW_STRUCT_VERSION_2 for this struct
  610. * This value should be the first 32-bits in any structure
  611. * related to this IOCTL. So that if the struct needs to
  612. * change, we can first read the starting 32-bits, get the
  613. * version number and then typecast the data to struct
  614. * accordingly.
  615. * @reserved: Reserved field for 64-bit alignment
  616. * @session_handle: Session handle for the acquire command
  617. * @dev_handle: Device handle to be returned
  618. * @handle_type: Tells you how to interpret the variable resource_hdl-
  619. * 1 = user pointer, 2 = mem handle
  620. * @data_size: Total size of data contained in memory pointed
  621. * to by resource_hdl
  622. * @resource_hdl: Resource handle that refers to the actual
  623. * resource data.
  624. */
  625. struct cam_acquire_hw_cmd_v2 {
  626. __u32 struct_version;
  627. __u32 reserved;
  628. __s32 session_handle;
  629. __s32 dev_handle;
  630. __u32 handle_type;
  631. __u32 data_size;
  632. __u64 resource_hdl;
  633. struct cam_acquired_hw_info hw_info;
  634. };
  635. #define CAM_RELEASE_HW_STRUCT_VERSION_1 1
  636. /**
  637. * struct cam_release_hw_cmd_v1 - Control payload for release HW IOCTL (Ver 1)
  638. *
  639. * @struct_version: = CAM_RELEASE_HW_STRUCT_VERSION_1 for this struct
  640. * This value should be the first 32-bits in any structure
  641. * related to this IOCTL. So that if the struct needs to
  642. * change, we can first read the starting 32-bits, get the
  643. * version number and then typecast the data to struct
  644. * accordingly.
  645. * @reserved: Reserved field for 64-bit alignment
  646. * @session_handle: Session handle for the release
  647. * @dev_handle: Device handle for the release
  648. */
  649. struct cam_release_hw_cmd_v1 {
  650. __u32 struct_version;
  651. __u32 reserved;
  652. __s32 session_handle;
  653. __s32 dev_handle;
  654. };
  655. /**
  656. * struct cam_flush_dev_cmd - Control payload for flush devices
  657. *
  658. * @version: Version
  659. * @session_handle: Session handle for the acquire command
  660. * @dev_handle: Device handle to be returned
  661. * @flush_type: Flush type:
  662. * 0 = flush specific request
  663. * 1 = flush all
  664. * @reserved: Reserved for 64 bit aligngment
  665. * @req_id: Request id that needs to cancel
  666. *
  667. */
  668. struct cam_flush_dev_cmd {
  669. __u64 version;
  670. __s32 session_handle;
  671. __s32 dev_handle;
  672. __u32 flush_type;
  673. __u32 reserved;
  674. __s64 req_id;
  675. };
  676. /**
  677. * struct cam_ubwc_config - UBWC Configuration Payload
  678. *
  679. * @api_version: UBWC config api version
  680. * @num_ports: Number of ports to be configured
  681. * @ubwc_plane_config: Array of UBWC configurations per port
  682. * Size [CAM_PACKET_MAX_PLANES - 1] per port
  683. * as UBWC is supported on Y & C planes
  684. * and therefore a max size of 2 planes
  685. *
  686. */
  687. struct cam_ubwc_config {
  688. __u32 api_version;
  689. __u32 num_ports;
  690. struct cam_ubwc_plane_cfg_v1
  691. ubwc_plane_cfg[1][CAM_PACKET_MAX_PLANES - 1];
  692. };
  693. /**
  694. * struct cam_ubwc_config_v2 - UBWC Configuration Payload
  695. *
  696. * @api_version: UBWC config api version
  697. * @num_ports: Number of ports to be configured
  698. * @ubwc_plane_config: Array of UBWC configurations per port
  699. * Size [CAM_PACKET_MAX_PLANES - 1] per port
  700. * as UBWC is supported on Y & C planes
  701. * and therefore a max size of 2 planes
  702. *
  703. */
  704. struct cam_ubwc_config_v2 {
  705. __u32 api_version;
  706. __u32 num_ports;
  707. struct cam_ubwc_plane_cfg_v2
  708. ubwc_plane_cfg[1][CAM_PACKET_MAX_PLANES - 1];
  709. };
  710. /**
  711. * struct cam_cmd_mem_region_info -
  712. * Cmd buffer region info
  713. *
  714. * @mem_handle : Memory handle of the region
  715. * @offset : Offset if any
  716. * @size : Size of the region
  717. * @flags : Flags if any
  718. */
  719. struct cam_cmd_mem_region_info {
  720. __s32 mem_handle;
  721. __u32 offset;
  722. __u32 size;
  723. __u32 flags;
  724. };
  725. /**
  726. * struct cam_cmd_mem_regions -
  727. * List of multiple memory descriptors of
  728. * of different regions
  729. *
  730. * @version : Version number
  731. * @num_regions : Number of regions
  732. * @map_info_array : Array of all the regions
  733. */
  734. struct cam_cmd_mem_regions {
  735. __u32 version;
  736. __u32 num_regions;
  737. struct cam_cmd_mem_region_info map_info_array[1];
  738. };
  739. /**
  740. * struct cam_reg_write_desc - Register write descriptor
  741. *
  742. * @offset : Register offset at which 'value' needs to written
  743. * @value : Register value to write
  744. */
  745. struct cam_reg_write_desc {
  746. __u32 offset;
  747. __u32 value;
  748. };
  749. /**
  750. * struct cam_reg_range_read_desc - Descriptor to provide read info
  751. *
  752. * @offset : Register offset address to start with
  753. * @num_values : Number of values to read
  754. */
  755. struct cam_reg_range_read_desc {
  756. __u32 offset;
  757. __u32 num_values;
  758. };
  759. /**
  760. * struct cam_dmi_read_desc - Descriptor to provide DMI read info
  761. *
  762. * @num_pre_writes : Number of registers to write before reading DMI data
  763. * @num_post_writes : Number of registers to write after reading DMI data
  764. * @pre_read_config : Registers to write before reading DMI data
  765. * @dmi_data_read : DMI Register, number of values to read to dump
  766. * DMI data
  767. * @post_read_config : Registers to write after reading DMI data
  768. */
  769. struct cam_dmi_read_desc {
  770. __u32 num_pre_writes;
  771. __u32 num_post_writes;
  772. struct cam_reg_write_desc pre_read_config[
  773. CAM_REG_DUMP_DMI_CONFIG_MAX];
  774. struct cam_reg_range_read_desc dmi_data_read;
  775. struct cam_reg_write_desc post_read_config[
  776. CAM_REG_DUMP_DMI_CONFIG_MAX];
  777. };
  778. /**
  779. * struct cam_reg_read_info - Register read info for both reg continuous read
  780. * or DMI read
  781. *
  782. * @type : Whether Register range read or DMI read
  783. * @reserved : For acquired version 3, this corresponds to context_id
  784. * @reg_read : Range of registers to read
  785. * @dmi_read : DMI data to read
  786. */
  787. struct cam_reg_read_info {
  788. __u32 type;
  789. __u32 reserved;
  790. union {
  791. struct cam_reg_range_read_desc reg_read;
  792. struct cam_dmi_read_desc dmi_read;
  793. };
  794. };
  795. /**
  796. * struct cam_reg_dump_out_buffer -Buffer info for dump data to be provided
  797. *
  798. * @req_id : Request ID corresponding to reg dump data
  799. * @bytes_written : Number of bytes written
  800. * @dump_data : Register dump data
  801. */
  802. struct cam_reg_dump_out_buffer {
  803. __u64 req_id;
  804. __u32 bytes_written;
  805. __u32 dump_data[1];
  806. };
  807. /**
  808. * struct cam_reg_dump_desc - Descriptor to provide dump info
  809. *
  810. * @reg_base_type : Register base type, e.g. ISP_LEFT, ISP_RIGHT, CAMNOC
  811. * @dump_buffer_offset : Offset from base of mem_handle at which Register dump
  812. * will be written for this set
  813. * @dump_buffer_size : Available size in bytes for writing dump values
  814. * @num_read_range : Number register range reads (Continuous + DMI)
  815. * @read_range : Read range info
  816. */
  817. struct cam_reg_dump_desc {
  818. __u32 reg_base_type;
  819. __u32 dump_buffer_offset;
  820. __u32 dump_buffer_size;
  821. __u32 num_read_range;
  822. struct cam_reg_read_info read_range[1];
  823. };
  824. /**
  825. * struct cam_reg_dump_input_info - Info about required dump sets
  826. *
  827. * @num_dump_sets : Number of different dump sets (base types) given
  828. * @dump_set_offsets : Points to the given dump description structures
  829. * (cam_reg_dump_desc)
  830. */
  831. struct cam_reg_dump_input_info {
  832. __u32 num_dump_sets;
  833. __u32 dump_set_offsets[1];
  834. };
  835. /**
  836. * struct cam_dump_req_cmd -
  837. * Dump the information of issue req id
  838. *
  839. * @issue_req_id : Issue Request Id
  840. * @offset : Offset for the buffer
  841. * @buf_handle : Buffer Handle
  842. * @error_type : Error type, using it, dumping information can be extended
  843. * @session_handle : Session Handle
  844. * @link_hdl : link handle
  845. * @dev_handle : Device Handle
  846. */
  847. struct cam_dump_req_cmd {
  848. __u64 issue_req_id;
  849. __kernel_size_t offset;
  850. __u32 buf_handle;
  851. __u32 error_type;
  852. __s32 session_handle;
  853. __s32 link_hdl;
  854. __s32 dev_handle;
  855. };
  856. /**
  857. * struct cam_synx_test_cmd - Synx test cmds
  858. *
  859. * @version: Struct version
  860. * @ip_mem_hdl: Input buf mem handle
  861. * corresponds to synx test inputs to the
  862. * fencing core
  863. * @op_mem_hdl: Output buf mem handle
  864. * corresponds to synx output generated by
  865. * the fencing core
  866. * @num_valid_params: Num valid params
  867. * @valid_param_mask: Valid param mask
  868. * @params: additional params
  869. */
  870. struct cam_synx_test_cmd {
  871. __u32 version;
  872. __s32 ip_mem_hdl;
  873. __s32 op_mem_hdl;
  874. __u32 num_valid_params;
  875. __u32 valid_param_mask;
  876. __u32 params[5];
  877. };
  878. /**
  879. * struct cam_synx_core_control - Synx core ctrl
  880. *
  881. * @version: Struct version
  882. * @core_control: Set for resume, unset for collapse
  883. * @num_valid_params: Num valid params
  884. * @valid_param_mask: Valid param mask
  885. * @params: additional params
  886. */
  887. struct cam_synx_core_control {
  888. __u32 version;
  889. __u32 core_control;
  890. __u32 num_valid_params;
  891. __u32 valid_param_mask;
  892. __u32 params[4];
  893. };
  894. /**
  895. * struct cam_synx_test_params - Synx test params
  896. *
  897. * A test sequence could include creating and signaling
  898. * synx handle between ICP <-> APPs. These test params
  899. * would be cmds such as session initialize, synx create,
  900. * synx async wait, synx signal and so on
  901. *
  902. * @version: Struct version
  903. * @cmd_type: Type of test cmd - core control/synx cmd/...
  904. * @num_valid_params: Num valid params
  905. * @valid_param_mask: Valid param mask
  906. * @params: additional params
  907. * @test_cmd: Synx test cmd forwarded to the core
  908. * @core_ctrl: Synx test cmd to control fencing core
  909. */
  910. struct cam_synx_test_params {
  911. __u32 version;
  912. __u32 cmd_type;
  913. __u32 num_valid_params;
  914. __u32 valid_param_mask;
  915. __u32 params[4];
  916. union {
  917. struct cam_synx_test_cmd test_cmd;
  918. struct cam_synx_core_control core_ctrl;
  919. } u;
  920. } __attribute__((__packed__));
  921. #endif /* __UAPI_CAM_DEFS_H__ */