cam_defs.h 32 KB

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