cam_req_mgr.h 31 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897
  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. #define CAM_REQ_MGR_MEM_CPU_ACCESS_OP (CAM_COMMON_OPCODE_MAX + 20)
  322. #define CAM_REQ_MGR_QUERY_CAP (CAM_COMMON_OPCODE_MAX + 21)
  323. /* end of cam_req_mgr opcodes */
  324. #define CAM_MEM_FLAG_HW_READ_WRITE (1<<0)
  325. #define CAM_MEM_FLAG_HW_READ_ONLY (1<<1)
  326. #define CAM_MEM_FLAG_HW_WRITE_ONLY (1<<2)
  327. #define CAM_MEM_FLAG_KMD_ACCESS (1<<3)
  328. #define CAM_MEM_FLAG_UMD_ACCESS (1<<4)
  329. #define CAM_MEM_FLAG_PROTECTED_MODE (1<<5)
  330. #define CAM_MEM_FLAG_CMD_BUF_TYPE (1<<6)
  331. #define CAM_MEM_FLAG_PIXEL_BUF_TYPE (1<<7)
  332. #define CAM_MEM_FLAG_STATS_BUF_TYPE (1<<8)
  333. #define CAM_MEM_FLAG_PACKET_BUF_TYPE (1<<9)
  334. #define CAM_MEM_FLAG_CACHE (1<<10)
  335. #define CAM_MEM_FLAG_HW_SHARED_ACCESS (1<<11)
  336. #define CAM_MEM_FLAG_CDSP_OUTPUT (1<<12)
  337. #define CAM_MEM_FLAG_DISABLE_DELAYED_UNMAP (1<<13)
  338. #define CAM_MEM_FLAG_KMD_DEBUG_FLAG (1<<14)
  339. #define CAM_MEM_FLAG_EVA_NOPIXEL (1<<15)
  340. #define CAM_MEM_FLAG_HW_AND_CDM_OR_SHARED (1<<16)
  341. #define CAM_MEM_FLAG_UBWC_P_HEAP (1<<17)
  342. #define CAM_MEM_MMU_MAX_HANDLE 16
  343. /* Maximum allowed buffers in existence */
  344. #define CAM_MEM_BUFQ_MAX 2048
  345. #define CAM_MEM_MGR_SECURE_BIT_POS 15
  346. #define CAM_MEM_MGR_HDL_IDX_SIZE 15
  347. #define CAM_MEM_MGR_HDL_FD_SIZE 16
  348. #define CAM_MEM_MGR_HDL_IDX_END_POS 16
  349. #define CAM_MEM_MGR_HDL_FD_END_POS 32
  350. #define CAM_MEM_MGR_HDL_IDX_MASK ((1 << CAM_MEM_MGR_HDL_IDX_SIZE) - 1)
  351. #define GET_MEM_HANDLE(idx, fd) \
  352. ((idx & CAM_MEM_MGR_HDL_IDX_MASK) | \
  353. (fd << (CAM_MEM_MGR_HDL_FD_END_POS - CAM_MEM_MGR_HDL_FD_SIZE))) \
  354. #define GET_FD_FROM_HANDLE(hdl) \
  355. (hdl >> (CAM_MEM_MGR_HDL_FD_END_POS - CAM_MEM_MGR_HDL_FD_SIZE)) \
  356. #define CAM_MEM_MGR_GET_HDL_IDX(hdl) (hdl & CAM_MEM_MGR_HDL_IDX_MASK)
  357. #define CAM_MEM_MGR_SET_SECURE_HDL(hdl, flag) \
  358. ((flag) ? (hdl |= (1 << CAM_MEM_MGR_SECURE_BIT_POS)) : \
  359. ((hdl) &= ~(1 << CAM_MEM_MGR_SECURE_BIT_POS)))
  360. #define CAM_MEM_MGR_IS_SECURE_HDL(hdl) \
  361. (((hdl) & \
  362. (1<<CAM_MEM_MGR_SECURE_BIT_POS)) >> CAM_MEM_MGR_SECURE_BIT_POS)
  363. /**
  364. * memory allocation type
  365. */
  366. #define CAM_MEM_DMA_NONE 0
  367. #define CAM_MEM_DMA_BIDIRECTIONAL 1
  368. #define CAM_MEM_DMA_TO_DEVICE 2
  369. #define CAM_MEM_DMA_FROM_DEVICE 3
  370. /**
  371. * memory cache operation
  372. */
  373. #define CAM_MEM_CLEAN_CACHE 1
  374. #define CAM_MEM_INV_CACHE 2
  375. #define CAM_MEM_CLEAN_INV_CACHE 3
  376. /**
  377. * memory CPU access operation
  378. */
  379. #define CAM_MEM_BEGIN_CPU_ACCESS BIT(0)
  380. #define CAM_MEM_END_CPU_ACCESS BIT(1)
  381. /**
  382. * memory CPU access type
  383. */
  384. #define CAM_MEM_CPU_ACCESS_READ BIT(0)
  385. #define CAM_MEM_CPU_ACCESS_WRITE BIT(1)
  386. /**
  387. * Feature mask returned in query_cap
  388. */
  389. #define CAM_REQ_MGR_MEM_UBWC_P_HEAP_SUPPORTED BIT(0)
  390. /**
  391. * struct cam_req_mgr_query_cap
  392. * @version: Struct version
  393. * @feature_mask Supported features
  394. * @num_valid_params: Valid number of params being used
  395. * @valid_param_mask: Mask to indicate the field types in params
  396. * @params: Additional params
  397. */
  398. struct cam_req_mgr_query_cap {
  399. __u32 version;
  400. __u64 feature_mask;
  401. __u32 num_valid_params;
  402. __u32 valid_param_mask;
  403. __s32 params[5];
  404. };
  405. /**
  406. * struct cam_mem_alloc_out_params
  407. * @buf_handle: buffer handle
  408. * @fd: output buffer file descriptor
  409. * @vaddr: virtual address pointer
  410. */
  411. struct cam_mem_alloc_out_params {
  412. __u32 buf_handle;
  413. __s32 fd;
  414. __u64 vaddr;
  415. };
  416. /**
  417. * struct cam_mem_map_out_params
  418. * @buf_handle: buffer handle
  419. * @size: size of the buffer being mapped
  420. * @vaddr: virtual address pointer
  421. */
  422. struct cam_mem_map_out_params {
  423. __u32 buf_handle;
  424. __u32 size;
  425. __u64 vaddr;
  426. };
  427. /**
  428. * struct cam_mem_mgr_alloc_cmd
  429. * @len: size of buffer to allocate
  430. * @align: alignment of the buffer
  431. * @mmu_hdls: array of mmu handles
  432. * @num_hdl: number of handles
  433. * @flags: flags of the buffer
  434. * @out: out params
  435. */
  436. /* CAM_REQ_MGR_ALLOC_BUF */
  437. struct cam_mem_mgr_alloc_cmd {
  438. __u64 len;
  439. __u64 align;
  440. __s32 mmu_hdls[CAM_MEM_MMU_MAX_HANDLE];
  441. __u32 num_hdl;
  442. __u32 flags;
  443. struct cam_mem_alloc_out_params out;
  444. };
  445. /**
  446. * struct cam_mem_mgr_alloc_cmd_v2
  447. * @version: Struct version
  448. * @num_hdl: number of handles
  449. * @mmu_hdls: array of mmu handles
  450. * @len: size of buffer to allocate
  451. * @align: alignment of the buffer
  452. * @vmids: reserved
  453. * @buf_name: DMA buffer name
  454. * @flags: flags of the buffer
  455. * @num_valid_params: Valid number of params being used
  456. * @valid_param_mask: Mask to indicate the field types in params
  457. * @params: Additional params
  458. * @out: out params
  459. */
  460. /* CAM_REQ_MGR_ALLOC_BUF_V2 */
  461. struct cam_mem_mgr_alloc_cmd_v2 {
  462. __u32 version;
  463. __u32 num_hdl;
  464. __s32 mmu_hdls[CAM_MEM_MMU_MAX_HANDLE];
  465. __u64 len;
  466. __u64 align;
  467. __u64 vmids;
  468. char buf_name[CAM_DMA_BUF_NAME_LEN];
  469. __u32 flags;
  470. __u32 num_valid_params;
  471. __u32 valid_param_mask;
  472. __s32 params[5];
  473. struct cam_mem_alloc_out_params out;
  474. };
  475. /**
  476. * struct cam_mem_mgr_map_cmd
  477. * @mmu_hdls: array of mmu handles
  478. * @num_hdl: number of handles
  479. * @flags: flags of the buffer
  480. * @fd: output buffer file descriptor
  481. * @reserved: reserved field
  482. * @out: out params
  483. */
  484. /* CAM_REQ_MGR_MAP_BUF */
  485. struct cam_mem_mgr_map_cmd {
  486. __s32 mmu_hdls[CAM_MEM_MMU_MAX_HANDLE];
  487. __u32 num_hdl;
  488. __u32 flags;
  489. __s32 fd;
  490. __u32 reserved;
  491. struct cam_mem_map_out_params out;
  492. };
  493. /**
  494. * struct cam_mem_mgr_map_cmd_v2
  495. * @version: Struct version
  496. * @fd: output buffer file descriptor
  497. * @mmu_hdls: array of mmu handles
  498. * @num_hdl: number of handles
  499. * @flags: flags of the buffer
  500. * @vmids: reserved
  501. * @buf_name: DMA buffer name
  502. * @num_valid_params: Valid number of params being used
  503. * @valid_param_mask: Mask to indicate the field types in params
  504. * @params: Additional params
  505. * @out: out params
  506. */
  507. /* CAM_REQ_MGR_MAP_BUF_V2 */
  508. struct cam_mem_mgr_map_cmd_v2 {
  509. __u32 version;
  510. __s32 fd;
  511. __s32 mmu_hdls[CAM_MEM_MMU_MAX_HANDLE];
  512. __u32 num_hdl;
  513. __u32 flags;
  514. __u64 vmids;
  515. char buf_name[CAM_DMA_BUF_NAME_LEN];
  516. __u32 num_valid_params;
  517. __u32 valid_param_mask;
  518. __s32 params[4];
  519. struct cam_mem_map_out_params out;
  520. };
  521. /**
  522. * struct cam_mem_mgr_map_cmd
  523. * @buf_handle: buffer handle
  524. * @reserved: reserved field
  525. */
  526. /* CAM_REQ_MGR_RELEASE_BUF */
  527. struct cam_mem_mgr_release_cmd {
  528. __s32 buf_handle;
  529. __u32 reserved;
  530. };
  531. /**
  532. * struct cam_mem_mgr_map_cmd
  533. * @buf_handle: buffer handle
  534. * @ops: cache operations
  535. */
  536. /* CAM_REQ_MGR_CACHE_OPS */
  537. struct cam_mem_cache_ops_cmd {
  538. __s32 buf_handle;
  539. __u32 mem_cache_ops;
  540. };
  541. /**
  542. * struct cam_mem_cpu_access_op
  543. * @version: Struct version
  544. * @buf_handle: buffer handle
  545. * @access: CPU access operation. Allowed params :
  546. * CAM_MEM_BEGIN_CPU_ACCESS
  547. * CAM_MEM_END_CPU_ACCESS
  548. * both
  549. * @access_type: CPU access type. Allowed params :
  550. * CAM_MEM_CPU_ACCESS_READ
  551. * CAM_MEM_CPU_ACCESS_WRITE
  552. * both
  553. * @num_valid_params: Valid number of params being used
  554. * @valid_param_mask: Mask to indicate the field types in params
  555. * @params: Additional params
  556. */
  557. /* CAM_REQ_MGR_MEM_CPU_ACCESS_OP */
  558. struct cam_mem_cpu_access_op {
  559. __u32 version;
  560. __s32 buf_handle;
  561. __u32 access;
  562. __u32 access_type;
  563. __u32 num_valid_params;
  564. __u32 valid_param_mask;
  565. __s32 params[4];
  566. };
  567. /**
  568. * Request Manager : error message type
  569. * @CAM_REQ_MGR_ERROR_TYPE_DEVICE: Device error message, fatal to session
  570. * @CAM_REQ_MGR_ERROR_TYPE_REQUEST: Error on a single request, not fatal
  571. * @CAM_REQ_MGR_ERROR_TYPE_BUFFER: Buffer was not filled, not fatal
  572. * @CAM_REQ_MGR_ERROR_TYPE_RECOVERY: Fatal error, can be recovered
  573. * @CAM_REQ_MGR_ERROR_TYPE_SOF_FREEZE: SOF freeze, can be recovered
  574. * @CAM_REQ_MGR_ERROR_TYPE_FULL_RECOVERY: Full recovery, can be recovered
  575. * @CAM_REQ_MGR_ERROR_TYPE_PAGE_FAULT: page fault, can be recovered
  576. * @CAM_REQ_MGR_WARN_TYPE_KMD_RECOVERY: Do internal overflow recovery, notify UMD
  577. */
  578. #define CAM_REQ_MGR_ERROR_TYPE_DEVICE 0
  579. #define CAM_REQ_MGR_ERROR_TYPE_REQUEST 1
  580. #define CAM_REQ_MGR_ERROR_TYPE_BUFFER 2
  581. #define CAM_REQ_MGR_ERROR_TYPE_RECOVERY 3
  582. #define CAM_REQ_MGR_ERROR_TYPE_SOF_FREEZE 4
  583. #define CAM_REQ_MGR_ERROR_TYPE_FULL_RECOVERY 5
  584. #define CAM_REQ_MGR_ERROR_TYPE_PAGE_FAULT 6
  585. #define CAM_REQ_MGR_WARN_TYPE_KMD_RECOVERY 7
  586. /**
  587. * Request Manager : Error codes
  588. * @CAM_REQ_MGR_ISP_UNREPORTED_ERROR : No Error Code reported
  589. * @CAM_REQ_MGR_LINK_STALLED_ERROR : Unable to apply requests on link
  590. * @CAM_REQ_MGR_CSID_FATAL_ERROR : CSID FATAL Error
  591. * @CAM_REQ_MGR_CSID_FIFO_OVERFLOW_ERROR : CSID OutputFIFO Overflow
  592. * @CAM_REQ_MGR_CSID_RECOVERY_OVERFLOW_ERROR : CSID Recovery Overflow
  593. * @CAM_REQ_MGR_CSID_LANE_FIFO_OVERFLOW_ERROR : CSID Lane fifo overflow
  594. * @CAM_REQ_MGR_CSID_PIXEL_COUNT_MISMATCH : CSID Pixel Count Mismatch
  595. * @CAM_REQ_MGR_CSID_RX_PKT_HDR_CORRUPTION : Packet header received by the csid rx is corrupted
  596. * @CAM_REQ_MGR_CSID_MISSING_PKT_HDR_DATA : Lesser data received in packet header than expected
  597. * @CAM_REQ_MGR_CSID_ERR_ON_SENSOR_SWITCHING : Fatal Error encountered while switching the sensors
  598. * @CAM_REQ_MGR_CSID_UNBOUNDED_FRAME : No EOF in the frame or the frame started with eof
  599. * @CAM_REQ_MGR_ICP_NO_MEMORY : ICP No Memory
  600. * @CAM_REQ_MGR_ICP_ERROR_SYSTEM_FAILURE : ICP system failure
  601. * @CAM_REQ_MGR_CSID_MISSING_EOT : CSID is missing EOT on one or more lanes
  602. * @CAM_REQ_MGR_CSID_RX_PKT_PAYLOAD_CORRUPTION : CSID long packet payload CRC mismatch
  603. * @CAM_REQ_MGR_SENSOR_STREAM_OFF_FAILED : Failed to stream off sensor
  604. */
  605. #define CAM_REQ_MGR_ISP_UNREPORTED_ERROR 0
  606. #define CAM_REQ_MGR_LINK_STALLED_ERROR BIT(0)
  607. #define CAM_REQ_MGR_CSID_FATAL_ERROR BIT(1)
  608. #define CAM_REQ_MGR_CSID_FIFO_OVERFLOW_ERROR BIT(2)
  609. #define CAM_REQ_MGR_CSID_RECOVERY_OVERFLOW_ERROR BIT(3)
  610. #define CAM_REQ_MGR_CSID_LANE_FIFO_OVERFLOW_ERROR BIT(4)
  611. #define CAM_REQ_MGR_CSID_PIXEL_COUNT_MISMATCH BIT(5)
  612. #define CAM_REQ_MGR_CSID_RX_PKT_HDR_CORRUPTION BIT(6)
  613. #define CAM_REQ_MGR_CSID_MISSING_PKT_HDR_DATA BIT(7)
  614. #define CAM_REQ_MGR_CSID_ERR_ON_SENSOR_SWITCHING BIT(8)
  615. #define CAM_REQ_MGR_CSID_UNBOUNDED_FRAME BIT(9)
  616. #define CAM_REQ_MGR_ICP_NO_MEMORY BIT(10)
  617. #define CAM_REQ_MGR_ICP_SYSTEM_FAILURE BIT(11)
  618. #define CAM_REQ_MGR_CSID_MISSING_EOT BIT(12)
  619. #define CAM_REQ_MGR_CSID_RX_PKT_PAYLOAD_CORRUPTION BIT(13)
  620. #define CAM_REQ_MGR_SENSOR_STREAM_OFF_FAILED BIT(14)
  621. /**
  622. * struct cam_req_mgr_error_msg
  623. * @error_type: type of error
  624. * @request_id: request id of frame
  625. * @device_hdl: device handle
  626. * @linke_hdl: link_hdl
  627. * @resource_size: size of the resource
  628. * @error_code: Error code reported by the event.
  629. * Note: This field is a bit field.
  630. */
  631. struct cam_req_mgr_error_msg {
  632. __u32 error_type;
  633. __u32 request_id;
  634. __s32 device_hdl;
  635. __s32 link_hdl;
  636. __u32 resource_size;
  637. __u32 error_code;
  638. };
  639. /**
  640. * struct cam_req_mgr_frame_msg
  641. * @request_id: request id of the frame
  642. * @frame_id: frame id of the frame
  643. * @timestamp: timestamp of the frame
  644. * @link_hdl: link handle associated with this message
  645. * @sof_status: sof status success or fail
  646. * @frame_id_meta: refers to the meta for
  647. * that frame in specific usecases
  648. * @reserved: reserved
  649. */
  650. struct cam_req_mgr_frame_msg {
  651. __u64 request_id;
  652. __u64 frame_id;
  653. __u64 timestamp;
  654. __s32 link_hdl;
  655. __u32 sof_status;
  656. __u32 frame_id_meta;
  657. __u32 reserved;
  658. };
  659. /**
  660. * enum cam_req_msg_timestamp_type - Identifies index of timestamps
  661. *
  662. * @CAM_REQ_SOF_QTIMER_TIMESTAMP: SOF qtimer timestamp
  663. * @CAM_REQ_BOOT_TIMESTAMP: SOF boot timestamp
  664. * @CAM_REQ_TIMESTAMP_TYPE: Max enum index for timestamp type
  665. *
  666. */
  667. enum cam_req_msg_timestamp_type {
  668. CAM_REQ_SOF_QTIMER_TIMESTAMP = 0,
  669. CAM_REQ_BOOT_TIMESTAMP,
  670. CAM_REQ_TIMESTAMP_MAX
  671. };
  672. /**
  673. * struct cam_req_mgr_frame_msg
  674. * @request_id: request id of the frame
  675. * @frame_id: frame id of the frame
  676. * @timestamps: array for all the supported timestamps
  677. * @link_hdl: link handle associated with this message
  678. * @frame_id_meta: refers to the meta for
  679. * that frame in specific usecases
  680. * @reserved: reserved for future addtions and max size for structure can be 64 bytes
  681. */
  682. struct cam_req_mgr_frame_msg_v2 {
  683. __u64 request_id;
  684. __u64 frame_id;
  685. __u64 timestamps[CAM_REQ_TIMESTAMP_MAX];
  686. __s32 link_hdl;
  687. __u32 frame_id_meta;
  688. __u32 reserved[4];
  689. };
  690. /**
  691. * struct cam_req_mgr_custom_msg
  692. * @custom_type: custom type
  693. * @request_id: request id of the frame
  694. * @frame_id: frame id of the frame
  695. * @timestamp: timestamp of the frame
  696. * @link_hdl: link handle associated with this message
  697. * @custom_data: custom data
  698. */
  699. struct cam_req_mgr_custom_msg {
  700. __u32 custom_type;
  701. __u64 request_id;
  702. __u64 frame_id;
  703. __u64 timestamp;
  704. __s32 link_hdl;
  705. __u64 custom_data;
  706. };
  707. /**
  708. * Request Manager Node Msg Event Types
  709. * @CAM_REQ_MGR_NO_EVENT : Event type not reported by the hardware
  710. * @CAM_REQ_MGR_RETRY_EVENT : Retry request reported from the hardware
  711. */
  712. #define CAM_REQ_MGR_NO_EVENT 0
  713. #define CAM_REQ_MGR_RETRY_EVENT 1
  714. /**
  715. * Request Manager Node Msg Event Cause
  716. * @CAM_REQ_MGR_CAUSE_UNREPORTED : Event cause not reported by the hardware
  717. * @CAM_REQ_MGR_JPEG_THUBNAIL_SIZE_ERROR : JPEG Thumbnail encode size exceeds the threshold size
  718. */
  719. #define CAM_REQ_MGR_CAUSE_UNREPORTED 0
  720. #define CAM_REQ_MGR_JPEG_THUBNAIL_SIZE_ERROR 1
  721. /**
  722. * struct cam_req_mgr_node_msg
  723. * @device_hdl : Device handle of the device reporting the error
  724. * @link_hdl : link hdl for real time devices
  725. * @event_type : Type of the event
  726. * @event_cause : Cause of the event
  727. * @request_id : Request id
  728. * @custom_data : custom data
  729. * @reserved : Reserved field
  730. */
  731. struct cam_req_mgr_node_msg {
  732. __s32 device_hdl;
  733. __s32 link_hdl;
  734. __u32 event_type;
  735. __u32 event_cause;
  736. __u64 request_id;
  737. __u64 custom_data;
  738. __u32 reserved[2];
  739. };
  740. /**
  741. * Request Manager Msg Page Fault event
  742. * @CAM_REQ_MGR_PF_EVT_BUF_NOT_FOUND : Faulted buffer not found
  743. * @CAM_REQ_MGR_PF_EVT_BUF_FOUND_IO_CFG : Faulted buffer from io_cfg found
  744. * @CAM_REQ_MGR_PF_EVT_BUF_FOUND_REF_BUF : Faulted io region buffer in Patch found
  745. * @CAM_REQ_MGR_PF_EVT_BUF_FOUND_CDM : Fault in cmd buffer
  746. * @CAM_REQ_MGR_PF_EVT_BUF_FOUND_SHARED : Fault in shared region buffer
  747. */
  748. #define CAM_REQ_MGR_PF_EVT_BUF_NOT_FOUND 0
  749. #define CAM_REQ_MGR_PF_EVT_BUF_FOUND_IO_CFG 1
  750. #define CAM_REQ_MGR_PF_EVT_BUF_FOUND_REF_BUF 2
  751. #define CAM_REQ_MGR_PF_EVT_BUF_FOUND_CDM 3
  752. #define CAM_REQ_MGR_PF_EVT_BUF_FOUND_SHARED 4
  753. /**
  754. * Faulted Memory Type
  755. * @CAM_REQ_MGR_PF_TYPE_NULL : Fault on NULL
  756. * @CAM_REQ_MGR_PF_TYPE_OUT_OF_BOUND : Fault on address outside of any mapped buffer
  757. * @CAM_REQ_MGR_PF_TYPE_MAPPED_REGION : Fault on address within a mapped buffer
  758. */
  759. #define CAM_REQ_MGR_PF_TYPE_NULL 0
  760. #define CAM_REQ_MGR_PF_TYPE_OUT_OF_BOUND 1
  761. #define CAM_REQ_MGR_PF_TYPE_MAPPED_REGION 2
  762. /**
  763. * Faulted Memory stage
  764. * @CAM_REQ_MGR_STAGE1_FAULT : Faulted memory in non-secure stage
  765. * @CAM_REQ_MGR_STAGE2_FAULT : Faulted memory in secure stage
  766. */
  767. #define CAM_REQ_MGR_STAGE1_FAULT 0
  768. #define CAM_REQ_MGR_STAGE2_FAULT 1
  769. /**
  770. * struct cam_req_mgr_pf_err_msg
  771. * @device_hdl : device handle of the device reporting the error
  772. * @link_hdl : link hdl for real time devices
  773. * @pf_evt : indicates if no faulted buffer found or found
  774. * io cfg faulted buffer or found ref faulted buffer
  775. * or found cdm shared fautled buffer
  776. * @pf_type : indicates if page fault type is fault on NULL or
  777. * fault out of bound or fault within mapped region
  778. * @pf_stage : indicates if faulted memory is from secure or non-secure region
  779. * @patch_id : index to which patch in the packet is faulted
  780. * @buf_hdl : faulted buffer memory handle
  781. * @offset : offset provided in the packet
  782. * @port_id : resource type of the io cfg in packet
  783. * @far_delta : memory gab between faulted addr and closest
  784. * buffer's starting address
  785. * @req_id : request id for the faulted request
  786. * @bid : bus id
  787. * @pid : unique id for hw group of ports
  788. * @mid : port id of hw
  789. * @reserved : reserved fields
  790. */
  791. struct cam_req_mgr_pf_err_msg {
  792. __s32 device_hdl;
  793. __s32 link_hdl;
  794. __u8 pf_evt;
  795. __u8 pf_type;
  796. __u8 pf_stage;
  797. __u8 patch_id;
  798. __s32 buf_hdl;
  799. __u32 offset;
  800. __u32 port_id;
  801. __u64 far_delta;
  802. __u64 req_id;
  803. __u8 bid;
  804. __u8 pid;
  805. __u16 mid;
  806. __u32 reserved[3];
  807. };
  808. /**
  809. * struct cam_req_mgr_message - 64 bytes is the max size that can be sent as v4l2 evt
  810. * @session_hdl: session to which the frame belongs to
  811. * @reserved: reserved field
  812. * @u: union which can either be error/frame/custom/node message/page fault message
  813. */
  814. struct cam_req_mgr_message {
  815. __s32 session_hdl;
  816. __s32 reserved;
  817. union {
  818. struct cam_req_mgr_error_msg err_msg;
  819. struct cam_req_mgr_frame_msg frame_msg;
  820. struct cam_req_mgr_frame_msg_v2 frame_msg_v2;
  821. struct cam_req_mgr_custom_msg custom_msg;
  822. struct cam_req_mgr_node_msg node_msg;
  823. struct cam_req_mgr_pf_err_msg pf_err_msg;
  824. } u;
  825. };
  826. #endif /* __UAPI_LINUX_CAM_REQ_MGR_H */