cam_defs.h 32 KB

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