cam_defs.h 32 KB

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