cam_defs.h 32 KB

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