cam_req_mgr.h 31 KB

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