cam_req_mgr.h 25 KB

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