cam_req_mgr.h 29 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836
  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. * Copyright (c) 2022 Qualcomm Innovation Center, Inc. All rights reserved.
  5. */
  6. #ifndef __UAPI_LINUX_CAM_REQ_MGR_H
  7. #define __UAPI_LINUX_CAM_REQ_MGR_H
  8. #include <linux/videodev2.h>
  9. #include <linux/types.h>
  10. #include <linux/ioctl.h>
  11. #include <linux/media.h>
  12. #include <media/cam_defs.h>
  13. #define CAM_REQ_MGR_VNODE_NAME "cam-req-mgr-devnode"
  14. #define CAM_DEVICE_TYPE_BASE (MEDIA_ENT_F_OLD_BASE)
  15. #define CAM_VNODE_DEVICE_TYPE (CAM_DEVICE_TYPE_BASE)
  16. #define CAM_SENSOR_DEVICE_TYPE (CAM_DEVICE_TYPE_BASE + 1)
  17. #define CAM_IFE_DEVICE_TYPE (CAM_DEVICE_TYPE_BASE + 2)
  18. #define CAM_ICP_DEVICE_TYPE (CAM_DEVICE_TYPE_BASE + 3)
  19. #define CAM_LRME_DEVICE_TYPE (CAM_DEVICE_TYPE_BASE + 4)
  20. #define CAM_JPEG_DEVICE_TYPE (CAM_DEVICE_TYPE_BASE + 5)
  21. #define CAM_FD_DEVICE_TYPE (CAM_DEVICE_TYPE_BASE + 6)
  22. #define CAM_CPAS_DEVICE_TYPE (CAM_DEVICE_TYPE_BASE + 7)
  23. #define CAM_CSIPHY_DEVICE_TYPE (CAM_DEVICE_TYPE_BASE + 8)
  24. #define CAM_ACTUATOR_DEVICE_TYPE (CAM_DEVICE_TYPE_BASE + 9)
  25. #define CAM_CCI_DEVICE_TYPE (CAM_DEVICE_TYPE_BASE + 10)
  26. #define CAM_FLASH_DEVICE_TYPE (CAM_DEVICE_TYPE_BASE + 11)
  27. #define CAM_EEPROM_DEVICE_TYPE (CAM_DEVICE_TYPE_BASE + 12)
  28. #define CAM_OIS_DEVICE_TYPE (CAM_DEVICE_TYPE_BASE + 13)
  29. #define CAM_CUSTOM_DEVICE_TYPE (CAM_DEVICE_TYPE_BASE + 14)
  30. #define CAM_OPE_DEVICE_TYPE (CAM_DEVICE_TYPE_BASE + 15)
  31. #define CAM_TFE_DEVICE_TYPE (CAM_DEVICE_TYPE_BASE + 16)
  32. #define CAM_CRE_DEVICE_TYPE (CAM_DEVICE_TYPE_BASE + 17)
  33. #define CAM_TPG_DEVICE_TYPE (CAM_DEVICE_TYPE_BASE + 18)
  34. /* cam_req_mgr hdl info */
  35. #define CAM_REQ_MGR_HDL_IDX_POS 8
  36. #define CAM_REQ_MGR_HDL_IDX_MASK ((1 << CAM_REQ_MGR_HDL_IDX_POS) - 1)
  37. #define CAM_REQ_MGR_GET_HDL_IDX(hdl) (hdl & CAM_REQ_MGR_HDL_IDX_MASK)
  38. /**
  39. * Max handles supported by cam_req_mgr
  40. * It includes both session and device handles
  41. */
  42. #define CAM_REQ_MGR_MAX_HANDLES 64
  43. #define CAM_REQ_MGR_MAX_HANDLES_V2 256
  44. #define MAX_LINKS_PER_SESSION 2
  45. /* V4L event type which user space will subscribe to */
  46. #define V4L_EVENT_CAM_REQ_MGR_EVENT (V4L2_EVENT_PRIVATE_START + 0)
  47. /* Specific event ids to get notified in user space */
  48. #define V4L_EVENT_CAM_REQ_MGR_SOF 0
  49. #define V4L_EVENT_CAM_REQ_MGR_ERROR 1
  50. #define V4L_EVENT_CAM_REQ_MGR_SOF_BOOT_TS 2
  51. #define V4L_EVENT_CAM_REQ_MGR_CUSTOM_EVT 3
  52. #define V4L_EVENT_CAM_REQ_MGR_NODE_EVENT 4
  53. #define V4L_EVENT_CAM_REQ_MGR_SOF_UNIFIED_TS 5
  54. #define V4L_EVENT_CAM_REQ_MGR_PF_ERROR 6
  55. /* SOF Event status */
  56. #define CAM_REQ_MGR_SOF_EVENT_SUCCESS 0
  57. #define CAM_REQ_MGR_SOF_EVENT_ERROR 1
  58. /* Link control operations */
  59. #define CAM_REQ_MGR_LINK_ACTIVATE 0
  60. #define CAM_REQ_MGR_LINK_DEACTIVATE 1
  61. /* DMA buffer name length */
  62. #define CAM_DMA_BUF_NAME_LEN 128
  63. #define CAM_REQ_MGR_ALLOC_BUF_WITH_NAME 1
  64. /**
  65. * Request Manager : flush_type
  66. * @CAM_REQ_MGR_FLUSH_TYPE_ALL: Req mgr will remove all the pending
  67. * requests from input/processing queue.
  68. * @CAM_REQ_MGR_FLUSH_TYPE_CANCEL_REQ: Req mgr will remove only particular
  69. * request id from input/processing queue.
  70. * @CAM_REQ_MGR_FLUSH_TYPE_MAX: Max number of the flush type
  71. * @opcode: CAM_REQ_MGR_FLUSH_REQ
  72. */
  73. #define CAM_REQ_MGR_FLUSH_TYPE_ALL 0
  74. #define CAM_REQ_MGR_FLUSH_TYPE_CANCEL_REQ 1
  75. #define CAM_REQ_MGR_FLUSH_TYPE_MAX 2
  76. /**
  77. * Request Manager : Sync Mode type
  78. * @CAM_REQ_MGR_SYNC_MODE_NO_SYNC: Req mgr will apply non-sync mode for this
  79. * request.
  80. * @CAM_REQ_MGR_SYNC_MODE_SYNC: Req mgr will apply sync mode for this request.
  81. */
  82. #define CAM_REQ_MGR_SYNC_MODE_NO_SYNC 0
  83. #define CAM_REQ_MGR_SYNC_MODE_SYNC 1
  84. /**
  85. * struct cam_req_mgr_event_data
  86. * @session_hdl: session handle
  87. * @link_hdl: link handle
  88. * @frame_id: frame id
  89. * @reserved: reserved for 64 bit aligngment
  90. * @req_id: request id
  91. * @tv_sec: timestamp in seconds
  92. * @tv_usec: timestamp in micro seconds
  93. */
  94. struct cam_req_mgr_event_data {
  95. __s32 session_hdl;
  96. __s32 link_hdl;
  97. __s32 frame_id;
  98. __s32 reserved;
  99. __s64 req_id;
  100. __u64 tv_sec;
  101. __u64 tv_usec;
  102. };
  103. /**
  104. * struct cam_req_mgr_session_info
  105. * @session_hdl: In/Output param - session_handle
  106. * @opcode1: CAM_REQ_MGR_CREATE_SESSION
  107. * @opcode2: CAM_REQ_MGR_DESTROY_SESSION
  108. */
  109. struct cam_req_mgr_session_info {
  110. __s32 session_hdl;
  111. __s32 reserved;
  112. };
  113. /**
  114. * struct cam_req_mgr_link_info
  115. * @session_hdl: Input param - Identifier for CSL session
  116. * @num_devices: Input Param - Num of devices to be linked
  117. * @dev_hdls: Input param - List of device handles to be linked
  118. * @link_hdl: Output Param -Identifier for link
  119. * @opcode: CAM_REQ_MGR_LINK
  120. */
  121. struct cam_req_mgr_link_info {
  122. __s32 session_hdl;
  123. __u32 num_devices;
  124. __s32 dev_hdls[CAM_REQ_MGR_MAX_HANDLES];
  125. __s32 link_hdl;
  126. };
  127. struct cam_req_mgr_link_info_v2 {
  128. __s32 session_hdl;
  129. __u32 num_devices;
  130. __s32 dev_hdls[CAM_REQ_MGR_MAX_HANDLES_V2];
  131. __s32 link_hdl;
  132. };
  133. struct cam_req_mgr_ver_info {
  134. __u32 version;
  135. union {
  136. struct cam_req_mgr_link_info link_info_v1;
  137. struct cam_req_mgr_link_info_v2 link_info_v2;
  138. } u;
  139. };
  140. /**
  141. * struct cam_req_mgr_unlink_info
  142. * @session_hdl: input param - session handle
  143. * @link_hdl: input param - link handle
  144. * @opcode: CAM_REQ_MGR_UNLINK
  145. */
  146. struct cam_req_mgr_unlink_info {
  147. __s32 session_hdl;
  148. __s32 link_hdl;
  149. };
  150. /**
  151. * struct cam_req_mgr_flush_info
  152. * @brief: User can tell drivers to flush a particular request id or
  153. * flush all requests from its pending processing queue. Flush is a
  154. * blocking call and driver shall ensure all requests are flushed
  155. * before returning.
  156. * @session_hdl: Input param - Identifier for CSL session
  157. * @link_hdl: Input Param -Identifier for link
  158. * @flush_type: User can cancel a particular req id or can flush
  159. * all requests in queue
  160. * @reserved: reserved for 64 bit aligngment
  161. * @req_id: field is valid only if flush type is cancel request
  162. * for flush all this field value is not considered.
  163. * @opcode: CAM_REQ_MGR_FLUSH_REQ
  164. */
  165. struct cam_req_mgr_flush_info {
  166. __s32 session_hdl;
  167. __s32 link_hdl;
  168. __u32 flush_type;
  169. __u32 reserved;
  170. __s64 req_id;
  171. };
  172. /** struct cam_req_mgr_sched_request
  173. * @session_hdl: Input param - Identifier for CSL session
  174. * @link_hdl: Input Param -Identifier for link
  175. * inluding itself.
  176. * @bubble_enable: Input Param - Cam req mgr will do bubble recovery if this
  177. * flag is set.
  178. * @sync_mode: Type of Sync mode for this request
  179. * @additional_timeout: Additional timeout value (in ms) associated with
  180. * this request. This value needs to be 0 in cases where long exposure is
  181. * not configured for the sensor.The max timeout that will be supported
  182. * is 50000 ms
  183. * @reserved: Reserved
  184. * @req_id: Input Param - Request Id from which all requests will be flushed
  185. */
  186. struct cam_req_mgr_sched_request {
  187. __s32 session_hdl;
  188. __s32 link_hdl;
  189. __s32 bubble_enable;
  190. __s32 sync_mode;
  191. __s32 additional_timeout;
  192. __s32 reserved;
  193. __s64 req_id;
  194. };
  195. /** struct cam_req_mgr_sched_request_v2
  196. * @version: Version number
  197. * @session_hdl: Input param - Identifier for CSL session
  198. * @link_hdl: Input Param -Identifier for link including itself.
  199. * @bubble_enable: Input Param - Cam req mgr will do bubble recovery if this
  200. * flag is set.
  201. * @sync_mode: Type of Sync mode for this request
  202. * @additional_timeout: Additional timeout value (in ms) associated with
  203. * this request. This value needs to be 0 in cases where long exposure is
  204. * not configured for the sensor.The max timeout that will be supported
  205. * is 50000 ms
  206. * @num_links: Input Param - Num of links for sync
  207. * @num_valid_params: Number of valid params
  208. * @req_id: Input Param - Request Id from which all requests will be flushed
  209. * @link_hdls: Input Param - Array of link handles to be for sync
  210. * @param_mask: mask to indicate what the parameters are
  211. * @params: parameters passed from user space
  212. */
  213. struct cam_req_mgr_sched_request_v2 {
  214. __s32 version;
  215. __s32 session_hdl;
  216. __s32 link_hdl;
  217. __s32 bubble_enable;
  218. __s32 sync_mode;
  219. __s32 additional_timeout;
  220. __s32 num_links;
  221. __s32 num_valid_params;
  222. __s64 req_id;
  223. __s32 link_hdls[MAX_LINKS_PER_SESSION];
  224. __s32 param_mask;
  225. __s32 params[5];
  226. };
  227. /**
  228. * struct cam_req_mgr_sync_mode
  229. * @session_hdl: Input param - Identifier for CSL session
  230. * @sync_mode: Input Param - Type of sync mode
  231. * @num_links: Input Param - Num of links in sync mode (Valid only
  232. * when sync_mode is one of SYNC enabled modes)
  233. * @link_hdls: Input Param - Array of link handles to be in sync mode
  234. * (Valid only when sync_mode is one of SYNC
  235. * enabled modes)
  236. * @master_link_hdl: Input Param - To dictate which link's SOF drives system
  237. * (Valid only when sync_mode is one of SYNC
  238. * enabled modes)
  239. *
  240. * @opcode: CAM_REQ_MGR_SYNC_MODE
  241. */
  242. struct cam_req_mgr_sync_mode {
  243. __s32 session_hdl;
  244. __s32 sync_mode;
  245. __s32 num_links;
  246. __s32 link_hdls[MAX_LINKS_PER_SESSION];
  247. __s32 master_link_hdl;
  248. __s32 reserved;
  249. };
  250. /**
  251. * struct cam_req_mgr_link_control
  252. * @ops: Link operations: activate/deactive
  253. * @session_hdl: Input param - Identifier for CSL session
  254. * @num_links: Input Param - Num of links
  255. * @reserved: reserved field
  256. * @init_timeout: To account for INIT exposure settings (ms)
  257. * If there is no change in exp settings
  258. * field needs to assigned to 0ms.
  259. * @link_hdls: Input Param - Links to be activated/deactivated
  260. *
  261. * @opcode: CAM_REQ_MGR_LINK_CONTROL
  262. */
  263. struct cam_req_mgr_link_control {
  264. __s32 ops;
  265. __s32 session_hdl;
  266. __s32 num_links;
  267. __s32 reserved;
  268. __s32 init_timeout[MAX_LINKS_PER_SESSION];
  269. __s32 link_hdls[MAX_LINKS_PER_SESSION];
  270. };
  271. /**
  272. * struct cam_req_mgr_link_properties
  273. * @version: Input param - Version number
  274. * @session_hdl: Input param - Identifier for CSL session
  275. * @link_hdl: Input Param - Identifier for link
  276. * @properties_mask: Input Param - Properties mask to indicate if current
  277. * link enables some special properties
  278. * @num_valid_params: Input Param - Number of valid params
  279. * @param_mask: Input Param - Mask to indicate what are the parameters
  280. * @params: Input Param - Parameters passed from user space
  281. */
  282. /* CAM_REQ_MGR_LINK_PROPERTIES */
  283. struct cam_req_mgr_link_properties {
  284. __s32 version;
  285. __s32 session_hdl;
  286. __s32 link_hdl;
  287. __u32 properties_mask;
  288. __s32 num_valid_params;
  289. __u32 param_mask;
  290. __s32 params[6];
  291. };
  292. /**
  293. * Request Manager : Link properties codes
  294. * @CAM_LINK_PROPERTY_NONE : No special property
  295. * @CAM_LINK_PROPERTY_SENSOR_STANDBY_AFTER_EOF : Standby the sensor after EOF
  296. */
  297. #define CAM_LINK_PROPERTY_NONE 0
  298. #define CAM_LINK_PROPERTY_SENSOR_STANDBY_AFTER_EOF BIT(0)
  299. /**
  300. * cam_req_mgr specific opcode ids
  301. */
  302. #define CAM_REQ_MGR_CREATE_DEV_NODES (CAM_COMMON_OPCODE_MAX + 1)
  303. #define CAM_REQ_MGR_CREATE_SESSION (CAM_COMMON_OPCODE_MAX + 2)
  304. #define CAM_REQ_MGR_DESTROY_SESSION (CAM_COMMON_OPCODE_MAX + 3)
  305. #define CAM_REQ_MGR_LINK (CAM_COMMON_OPCODE_MAX + 4)
  306. #define CAM_REQ_MGR_UNLINK (CAM_COMMON_OPCODE_MAX + 5)
  307. #define CAM_REQ_MGR_SCHED_REQ (CAM_COMMON_OPCODE_MAX + 6)
  308. #define CAM_REQ_MGR_FLUSH_REQ (CAM_COMMON_OPCODE_MAX + 7)
  309. #define CAM_REQ_MGR_SYNC_MODE (CAM_COMMON_OPCODE_MAX + 8)
  310. #define CAM_REQ_MGR_ALLOC_BUF (CAM_COMMON_OPCODE_MAX + 9)
  311. #define CAM_REQ_MGR_MAP_BUF (CAM_COMMON_OPCODE_MAX + 10)
  312. #define CAM_REQ_MGR_RELEASE_BUF (CAM_COMMON_OPCODE_MAX + 11)
  313. #define CAM_REQ_MGR_CACHE_OPS (CAM_COMMON_OPCODE_MAX + 12)
  314. #define CAM_REQ_MGR_LINK_CONTROL (CAM_COMMON_OPCODE_MAX + 13)
  315. #define CAM_REQ_MGR_LINK_V2 (CAM_COMMON_OPCODE_MAX + 14)
  316. #define CAM_REQ_MGR_REQUEST_DUMP (CAM_COMMON_OPCODE_MAX + 15)
  317. #define CAM_REQ_MGR_SCHED_REQ_V2 (CAM_COMMON_OPCODE_MAX + 16)
  318. #define CAM_REQ_MGR_LINK_PROPERTIES (CAM_COMMON_OPCODE_MAX + 17)
  319. #define CAM_REQ_MGR_ALLOC_BUF_V2 (CAM_COMMON_OPCODE_MAX + 18)
  320. #define CAM_REQ_MGR_MAP_BUF_V2 (CAM_COMMON_OPCODE_MAX + 19)
  321. /* end of cam_req_mgr opcodes */
  322. #define CAM_MEM_FLAG_HW_READ_WRITE (1<<0)
  323. #define CAM_MEM_FLAG_HW_READ_ONLY (1<<1)
  324. #define CAM_MEM_FLAG_HW_WRITE_ONLY (1<<2)
  325. #define CAM_MEM_FLAG_KMD_ACCESS (1<<3)
  326. #define CAM_MEM_FLAG_UMD_ACCESS (1<<4)
  327. #define CAM_MEM_FLAG_PROTECTED_MODE (1<<5)
  328. #define CAM_MEM_FLAG_CMD_BUF_TYPE (1<<6)
  329. #define CAM_MEM_FLAG_PIXEL_BUF_TYPE (1<<7)
  330. #define CAM_MEM_FLAG_STATS_BUF_TYPE (1<<8)
  331. #define CAM_MEM_FLAG_PACKET_BUF_TYPE (1<<9)
  332. #define CAM_MEM_FLAG_CACHE (1<<10)
  333. #define CAM_MEM_FLAG_HW_SHARED_ACCESS (1<<11)
  334. #define CAM_MEM_FLAG_CDSP_OUTPUT (1<<12)
  335. #define CAM_MEM_FLAG_DISABLE_DELAYED_UNMAP (1<<13)
  336. #define CAM_MEM_FLAG_KMD_DEBUG_FLAG (1<<14)
  337. #define CAM_MEM_FLAG_EVA_NOPIXEL (1<<15)
  338. #define CAM_MEM_FLAG_HW_AND_CDM_OR_SHARED (1<<16)
  339. #define CAM_MEM_MMU_MAX_HANDLE 16
  340. /* Maximum allowed buffers in existence */
  341. #define CAM_MEM_BUFQ_MAX 2048
  342. #define CAM_MEM_MGR_SECURE_BIT_POS 15
  343. #define CAM_MEM_MGR_HDL_IDX_SIZE 15
  344. #define CAM_MEM_MGR_HDL_FD_SIZE 16
  345. #define CAM_MEM_MGR_HDL_IDX_END_POS 16
  346. #define CAM_MEM_MGR_HDL_FD_END_POS 32
  347. #define CAM_MEM_MGR_HDL_IDX_MASK ((1 << CAM_MEM_MGR_HDL_IDX_SIZE) - 1)
  348. #define GET_MEM_HANDLE(idx, fd) \
  349. ((idx & CAM_MEM_MGR_HDL_IDX_MASK) | \
  350. (fd << (CAM_MEM_MGR_HDL_FD_END_POS - CAM_MEM_MGR_HDL_FD_SIZE))) \
  351. #define GET_FD_FROM_HANDLE(hdl) \
  352. (hdl >> (CAM_MEM_MGR_HDL_FD_END_POS - CAM_MEM_MGR_HDL_FD_SIZE)) \
  353. #define CAM_MEM_MGR_GET_HDL_IDX(hdl) (hdl & CAM_MEM_MGR_HDL_IDX_MASK)
  354. #define CAM_MEM_MGR_SET_SECURE_HDL(hdl, flag) \
  355. ((flag) ? (hdl |= (1 << CAM_MEM_MGR_SECURE_BIT_POS)) : \
  356. ((hdl) &= ~(1 << CAM_MEM_MGR_SECURE_BIT_POS)))
  357. #define CAM_MEM_MGR_IS_SECURE_HDL(hdl) \
  358. (((hdl) & \
  359. (1<<CAM_MEM_MGR_SECURE_BIT_POS)) >> CAM_MEM_MGR_SECURE_BIT_POS)
  360. /**
  361. * memory allocation type
  362. */
  363. #define CAM_MEM_DMA_NONE 0
  364. #define CAM_MEM_DMA_BIDIRECTIONAL 1
  365. #define CAM_MEM_DMA_TO_DEVICE 2
  366. #define CAM_MEM_DMA_FROM_DEVICE 3
  367. /**
  368. * memory cache operation
  369. */
  370. #define CAM_MEM_CLEAN_CACHE 1
  371. #define CAM_MEM_INV_CACHE 2
  372. #define CAM_MEM_CLEAN_INV_CACHE 3
  373. /**
  374. * struct cam_mem_alloc_out_params
  375. * @buf_handle: buffer handle
  376. * @fd: output buffer file descriptor
  377. * @vaddr: virtual address pointer
  378. */
  379. struct cam_mem_alloc_out_params {
  380. __u32 buf_handle;
  381. __s32 fd;
  382. __u64 vaddr;
  383. };
  384. /**
  385. * struct cam_mem_map_out_params
  386. * @buf_handle: buffer handle
  387. * @size: size of the buffer being mapped
  388. * @vaddr: virtual address pointer
  389. */
  390. struct cam_mem_map_out_params {
  391. __u32 buf_handle;
  392. __u32 size;
  393. __u64 vaddr;
  394. };
  395. /**
  396. * struct cam_mem_mgr_alloc_cmd
  397. * @len: size of buffer to allocate
  398. * @align: alignment of the buffer
  399. * @mmu_hdls: array of mmu handles
  400. * @num_hdl: number of handles
  401. * @flags: flags of the buffer
  402. * @out: out params
  403. */
  404. /* CAM_REQ_MGR_ALLOC_BUF */
  405. struct cam_mem_mgr_alloc_cmd {
  406. __u64 len;
  407. __u64 align;
  408. __s32 mmu_hdls[CAM_MEM_MMU_MAX_HANDLE];
  409. __u32 num_hdl;
  410. __u32 flags;
  411. struct cam_mem_alloc_out_params out;
  412. };
  413. /**
  414. * struct cam_mem_mgr_alloc_cmd_v2
  415. * @version: Struct version
  416. * @num_hdl: number of handles
  417. * @mmu_hdls: array of mmu handles
  418. * @len: size of buffer to allocate
  419. * @align: alignment of the buffer
  420. * @vmids: reserved
  421. * @buf_name: DMA buffer name
  422. * @flags: flags of the buffer
  423. * @num_valid_params: Valid number of params being used
  424. * @valid_param_mask: Mask to indicate the field types in params
  425. * @params: Additional params
  426. * @out: out params
  427. */
  428. /* CAM_REQ_MGR_ALLOC_BUF_V2 */
  429. struct cam_mem_mgr_alloc_cmd_v2 {
  430. __u32 version;
  431. __u32 num_hdl;
  432. __s32 mmu_hdls[CAM_MEM_MMU_MAX_HANDLE];
  433. __u64 len;
  434. __u64 align;
  435. __u64 vmids;
  436. char buf_name[CAM_DMA_BUF_NAME_LEN];
  437. __u32 flags;
  438. __u32 num_valid_params;
  439. __u32 valid_param_mask;
  440. __s32 params[5];
  441. struct cam_mem_alloc_out_params out;
  442. };
  443. /**
  444. * struct cam_mem_mgr_map_cmd
  445. * @mmu_hdls: array of mmu handles
  446. * @num_hdl: number of handles
  447. * @flags: flags of the buffer
  448. * @fd: output buffer file descriptor
  449. * @reserved: reserved field
  450. * @out: out params
  451. */
  452. /* CAM_REQ_MGR_MAP_BUF */
  453. struct cam_mem_mgr_map_cmd {
  454. __s32 mmu_hdls[CAM_MEM_MMU_MAX_HANDLE];
  455. __u32 num_hdl;
  456. __u32 flags;
  457. __s32 fd;
  458. __u32 reserved;
  459. struct cam_mem_map_out_params out;
  460. };
  461. /**
  462. * struct cam_mem_mgr_map_cmd_v2
  463. * @version: Struct version
  464. * @fd: output buffer file descriptor
  465. * @mmu_hdls: array of mmu handles
  466. * @num_hdl: number of handles
  467. * @flags: flags of the buffer
  468. * @vmids: reserved
  469. * @buf_name: DMA buffer name
  470. * @num_valid_params: Valid number of params being used
  471. * @valid_param_mask: Mask to indicate the field types in params
  472. * @params: Additional params
  473. * @out: out params
  474. */
  475. /* CAM_REQ_MGR_MAP_BUF_V2 */
  476. struct cam_mem_mgr_map_cmd_v2 {
  477. __u32 version;
  478. __s32 fd;
  479. __s32 mmu_hdls[CAM_MEM_MMU_MAX_HANDLE];
  480. __u32 num_hdl;
  481. __u32 flags;
  482. __u64 vmids;
  483. char buf_name[CAM_DMA_BUF_NAME_LEN];
  484. __u32 num_valid_params;
  485. __u32 valid_param_mask;
  486. __s32 params[4];
  487. struct cam_mem_map_out_params out;
  488. };
  489. /**
  490. * struct cam_mem_mgr_map_cmd
  491. * @buf_handle: buffer handle
  492. * @reserved: reserved field
  493. */
  494. /* CAM_REQ_MGR_RELEASE_BUF */
  495. struct cam_mem_mgr_release_cmd {
  496. __s32 buf_handle;
  497. __u32 reserved;
  498. };
  499. /**
  500. * struct cam_mem_mgr_map_cmd
  501. * @buf_handle: buffer handle
  502. * @ops: cache operations
  503. */
  504. /* CAM_REQ_MGR_CACHE_OPS */
  505. struct cam_mem_cache_ops_cmd {
  506. __s32 buf_handle;
  507. __u32 mem_cache_ops;
  508. };
  509. /**
  510. * Request Manager : error message type
  511. * @CAM_REQ_MGR_ERROR_TYPE_DEVICE: Device error message, fatal to session
  512. * @CAM_REQ_MGR_ERROR_TYPE_REQUEST: Error on a single request, not fatal
  513. * @CAM_REQ_MGR_ERROR_TYPE_BUFFER: Buffer was not filled, not fatal
  514. * @CAM_REQ_MGR_ERROR_TYPE_RECOVERY: Fatal error, can be recovered
  515. * @CAM_REQ_MGR_ERROR_TYPE_SOF_FREEZE: SOF freeze, can be recovered
  516. * @CAM_REQ_MGR_ERROR_TYPE_FULL_RECOVERY: Full recovery, can be recovered
  517. * @CAM_REQ_MGR_ERROR_TYPE_PAGE_FAULT: page fault, can be recovered
  518. * @CAM_REQ_MGR_WARN_TYPE_KMD_RECOVERY: Do internal overflow recovery, notify UMD
  519. */
  520. #define CAM_REQ_MGR_ERROR_TYPE_DEVICE 0
  521. #define CAM_REQ_MGR_ERROR_TYPE_REQUEST 1
  522. #define CAM_REQ_MGR_ERROR_TYPE_BUFFER 2
  523. #define CAM_REQ_MGR_ERROR_TYPE_RECOVERY 3
  524. #define CAM_REQ_MGR_ERROR_TYPE_SOF_FREEZE 4
  525. #define CAM_REQ_MGR_ERROR_TYPE_FULL_RECOVERY 5
  526. #define CAM_REQ_MGR_ERROR_TYPE_PAGE_FAULT 6
  527. #define CAM_REQ_MGR_WARN_TYPE_KMD_RECOVERY 7
  528. /**
  529. * Request Manager : Error codes
  530. * @CAM_REQ_MGR_ISP_UNREPORTED_ERROR : No Error Code reported
  531. * @CAM_REQ_MGR_LINK_STALLED_ERROR : Unable to apply requests on link
  532. * @CAM_REQ_MGR_CSID_FATAL_ERROR : CSID FATAL Error
  533. * @CAM_REQ_MGR_CSID_FIFO_OVERFLOW_ERROR : CSID OutputFIFO Overflow
  534. * @CAM_REQ_MGR_CSID_RECOVERY_OVERFLOW_ERROR : CSID Recovery Overflow
  535. * @CAM_REQ_MGR_CSID_LANE_FIFO_OVERFLOW_ERROR : CSID Lane fifo overflow
  536. * @CAM_REQ_MGR_CSID_PIXEL_COUNT_MISMATCH : CSID Pixel Count Mismatch
  537. * @CAM_REQ_MGR_CSID_RX_PKT_HDR_CORRUPTION : Packet header received by the csid rx is corrupted
  538. * @CAM_REQ_MGR_CSID_MISSING_PKT_HDR_DATA : Lesser data received in packet header than expected
  539. * @CAM_REQ_MGR_CSID_ERR_ON_SENSOR_SWITCHING : Fatal Error encountered while switching the sensors
  540. * @CAM_REQ_MGR_CSID_UNBOUNDED_FRAME : No EOF in the frame or the frame started with eof
  541. * @CAM_REQ_MGR_ICP_NO_MEMORY : ICP No Memory
  542. * @CAM_REQ_MGR_ICP_ERROR_SYSTEM_FAILURE : ICP system failure
  543. * @CAM_REQ_MGR_CSID_MISSING_EOT : CSID is missing EOT on one or more lanes
  544. * @CAM_REQ_MGR_CSID_RX_PKT_PAYLOAD_CORRUPTION : CSID long packet payload CRC mismatch
  545. * @CAM_REQ_MGR_SENSOR_STREAM_OFF_FAILED : Failed to stream off sensor
  546. */
  547. #define CAM_REQ_MGR_ISP_UNREPORTED_ERROR 0
  548. #define CAM_REQ_MGR_LINK_STALLED_ERROR BIT(0)
  549. #define CAM_REQ_MGR_CSID_FATAL_ERROR BIT(1)
  550. #define CAM_REQ_MGR_CSID_FIFO_OVERFLOW_ERROR BIT(2)
  551. #define CAM_REQ_MGR_CSID_RECOVERY_OVERFLOW_ERROR BIT(3)
  552. #define CAM_REQ_MGR_CSID_LANE_FIFO_OVERFLOW_ERROR BIT(4)
  553. #define CAM_REQ_MGR_CSID_PIXEL_COUNT_MISMATCH BIT(5)
  554. #define CAM_REQ_MGR_CSID_RX_PKT_HDR_CORRUPTION BIT(6)
  555. #define CAM_REQ_MGR_CSID_MISSING_PKT_HDR_DATA BIT(7)
  556. #define CAM_REQ_MGR_CSID_ERR_ON_SENSOR_SWITCHING BIT(8)
  557. #define CAM_REQ_MGR_CSID_UNBOUNDED_FRAME BIT(9)
  558. #define CAM_REQ_MGR_ICP_NO_MEMORY BIT(10)
  559. #define CAM_REQ_MGR_ICP_SYSTEM_FAILURE BIT(11)
  560. #define CAM_REQ_MGR_CSID_MISSING_EOT BIT(12)
  561. #define CAM_REQ_MGR_CSID_RX_PKT_PAYLOAD_CORRUPTION BIT(13)
  562. #define CAM_REQ_MGR_SENSOR_STREAM_OFF_FAILED BIT(14)
  563. /**
  564. * struct cam_req_mgr_error_msg
  565. * @error_type: type of error
  566. * @request_id: request id of frame
  567. * @device_hdl: device handle
  568. * @linke_hdl: link_hdl
  569. * @resource_size: size of the resource
  570. * @error_code: Error code reported by the event.
  571. * Note: This field is a bit field.
  572. */
  573. struct cam_req_mgr_error_msg {
  574. __u32 error_type;
  575. __u32 request_id;
  576. __s32 device_hdl;
  577. __s32 link_hdl;
  578. __u32 resource_size;
  579. __u32 error_code;
  580. };
  581. /**
  582. * struct cam_req_mgr_frame_msg
  583. * @request_id: request id of the frame
  584. * @frame_id: frame id of the frame
  585. * @timestamp: timestamp of the frame
  586. * @link_hdl: link handle associated with this message
  587. * @sof_status: sof status success or fail
  588. * @frame_id_meta: refers to the meta for
  589. * that frame in specific usecases
  590. * @reserved: reserved
  591. */
  592. struct cam_req_mgr_frame_msg {
  593. __u64 request_id;
  594. __u64 frame_id;
  595. __u64 timestamp;
  596. __s32 link_hdl;
  597. __u32 sof_status;
  598. __u32 frame_id_meta;
  599. __u32 reserved;
  600. };
  601. /**
  602. * enum cam_req_msg_timestamp_type - Identifies index of timestamps
  603. *
  604. * @CAM_REQ_SOF_QTIMER_TIMESTAMP: SOF qtimer timestamp
  605. * @CAM_REQ_BOOT_TIMESTAMP: SOF boot timestamp
  606. * @CAM_REQ_TIMESTAMP_TYPE: Max enum index for timestamp type
  607. *
  608. */
  609. enum cam_req_msg_timestamp_type {
  610. CAM_REQ_SOF_QTIMER_TIMESTAMP = 0,
  611. CAM_REQ_BOOT_TIMESTAMP,
  612. CAM_REQ_TIMESTAMP_MAX
  613. };
  614. /**
  615. * struct cam_req_mgr_frame_msg
  616. * @request_id: request id of the frame
  617. * @frame_id: frame id of the frame
  618. * @timestamps: array for all the supported timestamps
  619. * @link_hdl: link handle associated with this message
  620. * @frame_id_meta: refers to the meta for
  621. * that frame in specific usecases
  622. * @reserved: reserved for future addtions and max size for structure can be 64 bytes
  623. */
  624. struct cam_req_mgr_frame_msg_v2 {
  625. __u64 request_id;
  626. __u64 frame_id;
  627. __u64 timestamps[CAM_REQ_TIMESTAMP_MAX];
  628. __s32 link_hdl;
  629. __u32 frame_id_meta;
  630. __u32 reserved[4];
  631. };
  632. /**
  633. * struct cam_req_mgr_custom_msg
  634. * @custom_type: custom type
  635. * @request_id: request id of the frame
  636. * @frame_id: frame id of the frame
  637. * @timestamp: timestamp of the frame
  638. * @link_hdl: link handle associated with this message
  639. * @custom_data: custom data
  640. */
  641. struct cam_req_mgr_custom_msg {
  642. __u32 custom_type;
  643. __u64 request_id;
  644. __u64 frame_id;
  645. __u64 timestamp;
  646. __s32 link_hdl;
  647. __u64 custom_data;
  648. };
  649. /**
  650. * Request Manager Node Msg Event Types
  651. * @CAM_REQ_MGR_NO_EVENT : Event type not reported by the hardware
  652. * @CAM_REQ_MGR_RETRY_EVENT : Retry request reported from the hardware
  653. */
  654. #define CAM_REQ_MGR_NO_EVENT 0
  655. #define CAM_REQ_MGR_RETRY_EVENT 1
  656. /**
  657. * Request Manager Node Msg Event Cause
  658. * @CAM_REQ_MGR_CAUSE_UNREPORTED : Event cause not reported by the hardware
  659. * @CAM_REQ_MGR_JPEG_THUBNAIL_SIZE_ERROR : JPEG Thumbnail encode size exceeds the threshold size
  660. */
  661. #define CAM_REQ_MGR_CAUSE_UNREPORTED 0
  662. #define CAM_REQ_MGR_JPEG_THUBNAIL_SIZE_ERROR 1
  663. /**
  664. * struct cam_req_mgr_node_msg
  665. * @device_hdl : Device handle of the device reporting the error
  666. * @link_hdl : link hdl for real time devices
  667. * @event_type : Type of the event
  668. * @event_cause : Cause of the event
  669. * @request_id : Request id
  670. * @custom_data : custom data
  671. * @reserved : Reserved field
  672. */
  673. struct cam_req_mgr_node_msg {
  674. __s32 device_hdl;
  675. __s32 link_hdl;
  676. __u32 event_type;
  677. __u32 event_cause;
  678. __u64 request_id;
  679. __u64 custom_data;
  680. __u32 reserved[2];
  681. };
  682. /**
  683. * Request Manager Msg Page Fault event
  684. * @CAM_REQ_MGR_PF_EVT_BUF_NOT_FOUND : Faulted buffer not found
  685. * @CAM_REQ_MGR_PF_EVT_BUF_FOUND_IO_CFG : Faulted buffer from io_cfg found
  686. * @CAM_REQ_MGR_PF_EVT_BUF_FOUND_REF_BUF : Faulted io region buffer in Patch found
  687. * @CAM_REQ_MGR_PF_EVT_BUF_FOUND_CDM : Fault in cmd buffer
  688. * @CAM_REQ_MGR_PF_EVT_BUF_FOUND_SHARED : Fault in shared region buffer
  689. */
  690. #define CAM_REQ_MGR_PF_EVT_BUF_NOT_FOUND 0
  691. #define CAM_REQ_MGR_PF_EVT_BUF_FOUND_IO_CFG 1
  692. #define CAM_REQ_MGR_PF_EVT_BUF_FOUND_REF_BUF 2
  693. #define CAM_REQ_MGR_PF_EVT_BUF_FOUND_CDM 3
  694. #define CAM_REQ_MGR_PF_EVT_BUF_FOUND_SHARED 4
  695. /**
  696. * Faulted Memory Type
  697. * @CAM_REQ_MGR_PF_TYPE_NULL : Fault on NULL
  698. * @CAM_REQ_MGR_PF_TYPE_OUT_OF_BOUND : Fault on address outside of any mapped buffer
  699. * @CAM_REQ_MGR_PF_TYPE_MAPPED_REGION : Fault on address within a mapped buffer
  700. */
  701. #define CAM_REQ_MGR_PF_TYPE_NULL 0
  702. #define CAM_REQ_MGR_PF_TYPE_OUT_OF_BOUND 1
  703. #define CAM_REQ_MGR_PF_TYPE_MAPPED_REGION 2
  704. /**
  705. * Faulted Memory stage
  706. * @CAM_REQ_MGR_STAGE1_FAULT : Faulted memory in non-secure stage
  707. * @CAM_REQ_MGR_STAGE2_FAULT : Faulted memory in secure stage
  708. */
  709. #define CAM_REQ_MGR_STAGE1_FAULT 0
  710. #define CAM_REQ_MGR_STAGE2_FAULT 1
  711. /**
  712. * struct cam_req_mgr_pf_err_msg
  713. * @device_hdl : device handle of the device reporting the error
  714. * @link_hdl : link hdl for real time devices
  715. * @pf_evt : indicates if no faulted buffer found or found
  716. * io cfg faulted buffer or found ref faulted buffer
  717. * or found cdm shared fautled buffer
  718. * @pf_type : indicates if page fault type is fault on NULL or
  719. * fault out of bound or fault within mapped region
  720. * @pf_stage : indicates if faulted memory is from secure or non-secure region
  721. * @patch_id : index to which patch in the packet is faulted
  722. * @buf_hdl : faulted buffer memory handle
  723. * @offset : offset provided in the packet
  724. * @port_id : resource type of the io cfg in packet
  725. * @far_delta : memory gab between faulted addr and closest
  726. * buffer's starting address
  727. * @req_id : request id for the faulted request
  728. * @bid : bus id
  729. * @pid : unique id for hw group of ports
  730. * @mid : port id of hw
  731. * @reserved : reserved fields
  732. */
  733. struct cam_req_mgr_pf_err_msg {
  734. __s32 device_hdl;
  735. __s32 link_hdl;
  736. __u8 pf_evt;
  737. __u8 pf_type;
  738. __u8 pf_stage;
  739. __u8 patch_id;
  740. __s32 buf_hdl;
  741. __u32 offset;
  742. __u32 port_id;
  743. __u64 far_delta;
  744. __u64 req_id;
  745. __u8 bid;
  746. __u8 pid;
  747. __u16 mid;
  748. __u32 reserved[3];
  749. };
  750. /**
  751. * struct cam_req_mgr_message - 64 bytes is the max size that can be sent as v4l2 evt
  752. * @session_hdl: session to which the frame belongs to
  753. * @reserved: reserved field
  754. * @u: union which can either be error/frame/custom/node message/page fault message
  755. */
  756. struct cam_req_mgr_message {
  757. __s32 session_hdl;
  758. __s32 reserved;
  759. union {
  760. struct cam_req_mgr_error_msg err_msg;
  761. struct cam_req_mgr_frame_msg frame_msg;
  762. struct cam_req_mgr_frame_msg_v2 frame_msg_v2;
  763. struct cam_req_mgr_custom_msg custom_msg;
  764. struct cam_req_mgr_node_msg node_msg;
  765. struct cam_req_mgr_pf_err_msg pf_err_msg;
  766. } u;
  767. };
  768. #endif /* __UAPI_LINUX_CAM_REQ_MGR_H */