cam_ope.h 9.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333
  1. /* SPDX-License-Identifier: GPL-2.0-only WITH Linux-syscall-note */
  2. /*
  3. * Copyright (c) 2019, The Linux Foundation. All rights reserved.
  4. */
  5. #ifndef __UAPI_OPE_H__
  6. #define __UAPI_OPE_H__
  7. #include "cam_defs.h"
  8. #include "cam_cpas.h"
  9. #define OPE_DEV_NAME_SIZE 128
  10. /* OPE HW TYPE */
  11. #define OPE_HW_TYPE_OPE 0x1
  12. #define OPE_HW_TYPE_OPE_CDM 0x2
  13. #define OPE_HW_TYPE_MAX 0x3
  14. /* OPE Device type */
  15. #define OPE_DEV_TYPE_OPE_RT 0x1
  16. #define OPE_DEV_TYPE_OPE_NRT 0x2
  17. #define OPE_DEV_TYPE_OPE_SEMI_RT 0x3
  18. #define OPE_DEV_TYPE_MAX 0x4
  19. /* OPE Input Res Ports */
  20. #define OPE_IN_RES_FULL 0x1
  21. #define OPE_IN_RES_MAX OPE_IN_RES_FULL
  22. /* OPE Output Res Ports */
  23. #define OPE_OUT_RES_VIDEO 0x1
  24. #define OPE_OUT_RES_DISP 0x2
  25. #define OPE_OUT_RES_ARGB 0x3
  26. #define OPE_OUT_RES_STATS_RS 0x4
  27. #define OPE_OUT_RES_STATS_IHIST 0x5
  28. #define OPE_OUT_RES_STATS_LTM 0x6
  29. #define OPE_OUT_RES_MAX OPE_OUT_RES_STATS_LTM
  30. /* OPE packet opcodes */
  31. #define OPE_OPCODE_CONFIG 0x1
  32. /* OPE Command Buffer Scope */
  33. #define OPE_CMD_BUF_SCOPE_BATCH 0x1
  34. #define OPE_CMD_BUF_SCOPE_FRAME 0x2
  35. #define OPE_CMD_BUF_SCOPE_PASS 0x3
  36. #define OPE_CMD_BUF_SCOPE_STRIPE 0x4
  37. /* OPE Command Buffer Types */
  38. #define OPE_CMD_BUF_TYPE_DIRECT 0x1
  39. #define OPE_CMD_BUF_TYPE_INDIRECT 0x2
  40. /* OPE Command Buffer Usage */
  41. #define OPE_CMD_BUF_UMD 0x1
  42. #define OPE_CMD_BUF_KMD 0x2
  43. #define OPE_CMD_BUF_DEBUG 0x3
  44. /* OPE Single/Double Buffered */
  45. #define OPE_CMD_BUF_SINGLE_BUFFERED 0x1
  46. #define OPE_CMD_BUF_DOUBLE_BUFFERED 0x2
  47. /* Command meta types */
  48. #define OPE_CMD_META_GENERIC_BLOB 0x1
  49. /* Generic blob types */
  50. #define OPE_CMD_GENERIC_BLOB_CLK_V2 0x1
  51. /* Stripe location */
  52. #define OPE_STRIPE_FULL 0x0
  53. #define OPE_STRIPE_LEFT 0x1
  54. #define OPE_STRIPE_RIGHT 0x2
  55. #define OPE_STRIPE_MIDDLE 0x3
  56. #define OPE_MAX_CMD_BUFS 64
  57. #define OPE_MAX_IO_BUFS (OPE_OUT_RES_MAX + OPE_IN_RES_MAX)
  58. #define OPE_MAX_PASS 1
  59. #define OPE_MAX_PLANES 2
  60. #define OPE_MAX_STRIPES 32
  61. #define OPE_MAX_BATCH_SIZE 16
  62. /**
  63. * struct ope_stripe_info - OPE stripe Info
  64. *
  65. * @offset: Offset in Bytes
  66. * @x_init: X_init
  67. * @stripe_location: Stripe location (OPE_STRIPE_XXX)
  68. * @width: Width of a stripe
  69. * @disable_bus: Flag to disable BUS master
  70. * @reserved: Reserved
  71. *
  72. */
  73. struct ope_stripe_info {
  74. uint32_t offset;
  75. uint32_t x_init;
  76. uint32_t stripe_location;
  77. uint32_t width;
  78. uint32_t disable_bus;
  79. uint32_t reserved;
  80. };
  81. /**
  82. * struct ope_io_buf_info - OPE IO buffers meta
  83. *
  84. * @direction: Direction of a buffer of a port(Input/Output)
  85. * @resource_type: Port type
  86. * @num_planes: Number of planes for a port
  87. * @reserved: Reserved
  88. * @num_stripes: Stripes per plane
  89. * @mem_handle: Memhandles of each Input/Output Port
  90. * @plane_offset: Offsets of planes
  91. * @length: Length of a plane buffer
  92. * @plane_stride: Plane stride
  93. * @height: Height of a plane buffer
  94. * @format: Format
  95. * @fence: Fence of a Port
  96. * @stripe_info: Stripe Info
  97. *
  98. */
  99. struct ope_io_buf_info {
  100. uint32_t direction;
  101. uint32_t resource_type;
  102. uint32_t num_planes;
  103. uint32_t reserved;
  104. uint32_t num_stripes[OPE_MAX_PLANES];
  105. uint32_t mem_handle[OPE_MAX_PLANES];
  106. uint32_t plane_offset[OPE_MAX_PLANES];
  107. uint32_t length[OPE_MAX_PLANES];
  108. uint32_t plane_stride[OPE_MAX_PLANES];
  109. uint32_t height[OPE_MAX_PLANES];
  110. uint32_t format;
  111. uint32_t fence;
  112. struct ope_stripe_info stripe_info[OPE_MAX_PLANES][OPE_MAX_STRIPES];
  113. };
  114. /**
  115. * struct ope_frame_set - OPE frameset
  116. *
  117. * @num_io_bufs: Number of I/O buffers
  118. * @reserved: Reserved
  119. * @io_buf: IO buffer info for all Input and Output ports
  120. *
  121. */
  122. struct ope_frame_set {
  123. uint32_t num_io_bufs;
  124. uint32_t reserved;
  125. struct ope_io_buf_info io_buf[OPE_MAX_IO_BUFS];
  126. };
  127. /**
  128. * struct ope_cmd_buf_info - OPE command buffer meta
  129. *
  130. * @mem_handle: Memory handle for command buffer
  131. * @offset: Offset of a command buffer
  132. * @size: Size of command buffer
  133. * @length: Length of a command buffer
  134. * @cmd_buf_scope : Scope of a command buffer (OPE_CMD_BUF_SCOPE_XXX)
  135. * @type: Command buffer type (OPE_CMD_BUF_TYPE_XXX)
  136. * @cmd_buf_usage: Usage of command buffer ( OPE_CMD_BUF_USAGE_XXX)
  137. * @stripe_idx: Stripe index in a req, It is valid for SCOPE_STRIPE
  138. * @cmd_buf_pass_idx: Pass index
  139. * @prefetch_disable: Prefecth disable flag
  140. *
  141. */
  142. struct ope_cmd_buf_info {
  143. uint32_t mem_handle;
  144. uint32_t offset;
  145. uint32_t size;
  146. uint32_t length;
  147. uint32_t cmd_buf_scope;
  148. uint32_t type;
  149. uint32_t cmd_buf_usage;
  150. uint32_t cmd_buf_buffered;
  151. uint32_t stripe_idx;
  152. uint32_t cmd_buf_pass_idx;
  153. uint32_t prefetch_disable;
  154. };
  155. /**
  156. * struct ope_packet_payload - payload for a request
  157. *
  158. * @num_cmd_bufs: Number of command buffers
  159. * @batch_size: Batch size in HFR mode
  160. * @ope_cmd_buf_info: Command buffer meta data
  161. * @ope_io_buf_info: Io buffer Info
  162. *
  163. */
  164. struct ope_frame_process {
  165. uint32_t num_cmd_bufs[OPE_MAX_BATCH_SIZE];
  166. uint32_t batch_size;
  167. struct ope_cmd_buf_info cmd_buf[OPE_MAX_BATCH_SIZE][OPE_MAX_CMD_BUFS];
  168. struct ope_frame_set frame_set[OPE_MAX_BATCH_SIZE];
  169. };
  170. /**
  171. * struct ope_clk_bw_request_v2 - clock and bandwidth for a request
  172. *
  173. * @budget_ns: Time required to process frame
  174. * @frame_cycles: Frame cycles needed to process the frame
  175. * @rt_flag: Flag to indicate real time stream
  176. * @reserved: For memory alignment
  177. * @axi_path: Per path vote info for OPE
  178. *
  179. */
  180. struct ope_clk_bw_request_v2 {
  181. uint64_t budget_ns;
  182. uint32_t frame_cycles;
  183. uint32_t rt_flag;
  184. uint32_t reserved;
  185. uint32_t num_paths;
  186. struct cam_axi_per_path_bw_vote axi_path[1];
  187. };
  188. /**
  189. * struct ope_hw_ver - Device information for OPE
  190. *
  191. * This is used to get device version info of
  192. * OPE, CDM and use this info in CAM_QUERY_CAP IOCTL
  193. *
  194. * @hw_type: Hardware type for the cap info(OPE_HW_TYPE_XXX)
  195. * @reserved: Reserved field
  196. * @hw_ver: Major, minor and incr values of a hardware version
  197. *
  198. */
  199. struct ope_hw_ver {
  200. uint32_t hw_type;
  201. uint32_t reserved;
  202. struct cam_hw_version hw_ver;
  203. };
  204. /**
  205. * struct ope_query_cap_cmd - OPE query device capability payload
  206. *
  207. * @dev_iommu_handle: OPE iommu handles for secure/non secure modes
  208. * @cdm_iommu_handle: CDM iommu handles for secure/non secure modes
  209. * @num_ope: Number of OPEs
  210. * @reserved: Reserved Parameter
  211. * @hw_ver: Hardware capability array
  212. */
  213. struct ope_query_cap_cmd {
  214. struct cam_iommu_handle dev_iommu_handle;
  215. struct cam_iommu_handle cdm_iommu_handle;
  216. uint32_t num_ope;
  217. uint32_t reserved;
  218. struct ope_hw_ver hw_ver[OPE_DEV_TYPE_MAX];
  219. };
  220. /**
  221. * struct ope_out_res_info - OPE Output resource info
  222. *
  223. * @res_id: Resource ID
  224. * @format: Output resource format
  225. * @width: Output width
  226. * @height: Output Height
  227. * @alignment: Alignment
  228. * @packer_format: Packer format
  229. * @subsample_period: Subsample period in HFR
  230. * @subsample_pattern: Subsample pattern in HFR
  231. * @pixel_pattern: Pixel pattern
  232. * @reserved: Reserved Parameter
  233. *
  234. */
  235. struct ope_out_res_info {
  236. uint32_t res_id;
  237. uint32_t format;
  238. uint32_t width;
  239. uint32_t height;
  240. uint32_t alignment;
  241. uint32_t packer_format;
  242. uint32_t subsample_period;
  243. uint32_t subsample_pattern;
  244. uint32_t pixel_pattern;
  245. uint32_t reserved;
  246. };
  247. /**
  248. * struct ope_in_res_info - OPE Input resource info
  249. *
  250. * @res_id: Resource ID
  251. * @format: Input resource format
  252. * @width: Input width
  253. * @height: Input Height
  254. * @pixel_pattern: Pixel pattern
  255. * @alignment: Alignment
  256. * @unpacker_format: Unpacker format
  257. * @max_stripe_size: Max stripe size supported for this instance configuration
  258. * @fps: Frames per second
  259. * @reserved: Reserved Parameter
  260. *
  261. */
  262. struct ope_in_res_info {
  263. uint32_t res_id;
  264. uint32_t format;
  265. uint32_t width;
  266. uint32_t height;
  267. uint32_t pixel_pattern;
  268. uint32_t alignment;
  269. uint32_t unpacker_format;
  270. uint32_t max_stripe_size;
  271. uint32_t fps;
  272. uint32_t reserved;
  273. };
  274. /**
  275. * struct ope_acquire_dev_info - OPE Acquire Info
  276. *
  277. * @hw_type: OPE HW Types (OPE)
  278. * @dev_type: Nature of Device Instance (RT/NRT)
  279. * @dev_name: Name of Device Instance
  280. * @nrt_stripes_for_arb: Program num stripes in OPE CDM for NRT device
  281. * before setting ARB bit
  282. * @secure_mode: Mode of Device operation (Secure or Non Secure)
  283. * @batch_size: Batch size
  284. * @num_in_res: Number of input resources (OPE_IN_RES_XXX)
  285. * @in_res: Input resource info
  286. * @num_out_res: Number of output resources (OPE_OUT_RES_XXX)
  287. * @reserved: Reserved Parameter
  288. * @out_res: Output resource info
  289. *
  290. */
  291. struct ope_acquire_dev_info {
  292. uint32_t hw_type;
  293. uint32_t dev_type;
  294. char dev_name[OPE_DEV_NAME_SIZE];
  295. uint32_t nrt_stripes_for_arb;
  296. uint32_t secure_mode;
  297. uint32_t batch_size;
  298. uint32_t num_in_res;
  299. struct ope_in_res_info in_res[OPE_IN_RES_MAX];
  300. uint32_t num_out_res;
  301. uint32_t reserved;
  302. struct ope_out_res_info out_res[OPE_OUT_RES_MAX];
  303. } __attribute__((__packed__));
  304. #endif /* __UAPI_OPE_H__ */