cam_defs.h 35 KB

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