cam_req_mgr.h 31 KB

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