cam_req_mgr.h 31 KB

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