cam_defs.h 33 KB

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