cam_defs.h 32 KB

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