product.h 8.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342
  1. //SPDX-License-Identifier: LGPL-2.1 OR BSD-3-Clause
  2. /*
  3. * Copyright (c) 2019, Chips&Media
  4. * All rights reserved.
  5. *
  6. * Redistribution and use in source and binary forms, with or without
  7. * modification, are permitted provided that the following conditions are met:
  8. *
  9. * 1. Redistributions of source code must retain the above copyright notice, this
  10. * list of conditions and the following disclaimer.
  11. * 2. Redistributions in binary form must reproduce the above copyright notice,
  12. * this list of conditions and the following disclaimer in the documentation
  13. * and/or other materials provided with the distribution.
  14. *
  15. * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
  16. * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
  17. * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
  18. * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
  19. * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
  20. * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
  21. * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  22. * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  23. * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
  24. * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  25. */
  26. #ifndef __VPUAPI_PRODUCT_ABSTRACT_H__
  27. #define __VPUAPI_PRODUCT_ABSTRACT_H__
  28. #ifdef USE_FEEDING_METHOD_BUFFER
  29. #include "wave511/vpuapi/vpuapi.h"
  30. #include "wave511/vpuapi/vpuapifunc.h"
  31. #else
  32. #include "vpuapi.h"
  33. #include "vpuapifunc.h"
  34. #endif
  35. #define IS_CODA_DECODER_HANDLE(_inst) (_inst->codecMode < AVC_ENC)
  36. #define IS_WAVE_DECODER_HANDLE(_inst) (_inst->codecMode == W_HEVC_DEC || _inst->codecMode == W_SVAC_DEC || _inst->codecMode == W_AVC_DEC || _inst->codecMode == W_VP9_DEC || _inst->codecMode == W_AVS2_DEC || _inst->codecMode == W_AV1_DEC)
  37. enum {
  38. FramebufCacheNone,
  39. FramebufCacheMaverickI,
  40. FramebufCacheMaverickII,
  41. };
  42. typedef struct _tag_FramebufferIndex {
  43. Int16 tiledIndex;
  44. Int16 linearIndex;
  45. } FramebufferIndex;
  46. extern VpuAttr g_VpuCoreAttributes[MAX_NUM_VPU_CORE];
  47. #ifdef __cplusplus
  48. extern "C" {
  49. #endif /* __cplusplus */
  50. /*
  51. * Returns 0 - not found product id
  52. * 1 - found product id
  53. */
  54. extern Uint32 ProductVpuScan(
  55. Uint32 coreIdx
  56. );
  57. extern Int32 ProductVpuGetId(
  58. Uint32 coreIdx
  59. );
  60. extern RetCode ProductVpuGetVersion(
  61. Uint32 coreIdx,
  62. Uint32* versionInfo,
  63. Uint32* revision
  64. );
  65. extern RetCode ProductVpuGetProductInfo(
  66. Uint32 coreIdx,
  67. VpuAttr* productInfo
  68. );
  69. extern RetCode ProductVpuInit(
  70. Uint32 coreIdx,
  71. void* firmware,
  72. Uint32 size
  73. );
  74. extern RetCode ProductVpuReInit(
  75. Uint32 coreIdx,
  76. void* firmware,
  77. Uint32 size
  78. );
  79. extern Uint32 ProductVpuIsInit(
  80. Uint32 coreIdx
  81. );
  82. extern Int32 ProductVpuIsBusy(
  83. Uint32 coreIdx
  84. );
  85. extern Int32 ProductVpuWaitInterrupt(
  86. CodecInst* instance,
  87. Int32 timeout
  88. );
  89. extern RetCode ProductVpuReset(
  90. Uint32 coreIdx,
  91. SWResetMode resetMode
  92. );
  93. extern RetCode ProductVpuSleepWake(
  94. Uint32 coreIdx,
  95. int iSleepWake,
  96. const Uint16* code,
  97. Uint32 size
  98. );
  99. extern RetCode ProductVpuClearInterrupt(
  100. Uint32 coreIdx,
  101. Uint32 flags
  102. );
  103. extern RetCode ProductVpuDecBuildUpOpenParam(
  104. CodecInst* instance,
  105. DecOpenParam* param
  106. );
  107. extern RetCode ProductCheckDecOpenParam(
  108. DecOpenParam* param
  109. );
  110. extern RetCode ProductVpuDecInitSeq(
  111. CodecInst* instance
  112. );
  113. extern RetCode ProductVpuDecFiniSeq(
  114. CodecInst* instance
  115. );
  116. extern RetCode ProductVpuDecSetBitstreamFlag(
  117. CodecInst* instance,
  118. BOOL running,
  119. Int32 size
  120. );
  121. /*
  122. * FINI_SEQ
  123. */
  124. extern RetCode ProductVpuDecEndSequence(
  125. CodecInst* instance
  126. );
  127. /**
  128. * @brief Abstract function for SEQ_INIT.
  129. */
  130. extern RetCode ProductVpuDecGetSeqInfo(
  131. CodecInst* instance,
  132. DecInitialInfo* info
  133. );
  134. /**
  135. * \brief Check parameters for product specific decoder.
  136. */
  137. extern RetCode ProductVpuDecCheckCapability(
  138. CodecInst* instance
  139. );
  140. /**
  141. * \brief Decode a coded picture.
  142. */
  143. extern RetCode ProductVpuDecode(
  144. CodecInst* instance,
  145. DecParam* option
  146. );
  147. /**
  148. *
  149. */
  150. extern RetCode ProductVpuDecGetResult(
  151. CodecInst* instance,
  152. DecOutputInfo* result
  153. );
  154. /**
  155. * \brief Flush framebuffers to prepare decoding new sequence
  156. * \param instance decoder handle
  157. * \param retIndexes Storing framebuffer indexes in display order.
  158. * If retIndexes[i] is -1 then there is no display index from i-th.
  159. */
  160. extern RetCode ProductVpuDecFlush(
  161. CodecInst* instance,
  162. FramebufferIndex* retIndexes,
  163. Uint32 size
  164. );
  165. /**
  166. * \brief Allocate framebuffers with given parameters
  167. */
  168. extern RetCode ProductVpuAllocateFramebuffer(
  169. CodecInst* instance,
  170. FrameBuffer* fbArr,
  171. TiledMapType mapType,
  172. Int32 num,
  173. Int32 stride,
  174. Int32 height,
  175. FrameBufferFormat format,
  176. BOOL cbcrInterleave,
  177. BOOL nv21,
  178. Int32 endian,
  179. vpu_buffer_t* vb,
  180. Int32 gdiIndex,
  181. FramebufferAllocType fbType
  182. );
  183. /**
  184. * \brief Register framebuffers to VPU
  185. */
  186. extern RetCode ProductVpuRegisterFramebuffer(
  187. CodecInst* instance
  188. );
  189. extern RetCode ProductVpuDecUpdateFrameBuffer(
  190. CodecInst* instance,
  191. FrameBuffer* fbcFb,
  192. FrameBuffer* linearFb,
  193. Uint32 mvColIndex,
  194. Uint32 picWidth,
  195. Uint32 picHeight
  196. );
  197. extern Int32 ProductCalculateFrameBufSize(
  198. CodecInst* inst,
  199. Int32 productId,
  200. Int32 stride,
  201. Int32 height,
  202. TiledMapType mapType,
  203. FrameBufferFormat format,
  204. BOOL interleave,
  205. DRAMConfig* pDramCfg
  206. );
  207. extern Int32 ProductCalculateAuxBufferSize(
  208. AUX_BUF_TYPE type,
  209. CodStd codStd,
  210. Int32 width,
  211. Int32 height
  212. );
  213. extern RetCode ProductClrDispFlag(
  214. CodecInst* instance,
  215. Uint32 index
  216. );
  217. extern RetCode ProductSetDispFlag(
  218. CodecInst* instance,
  219. Uint32 dispFlag
  220. );
  221. extern PhysicalAddress ProductVpuDecGetRdPtr(
  222. CodecInst* instance
  223. );
  224. extern RetCode ProductVpuGetBandwidth(
  225. CodecInst* instance,
  226. VPUBWData* data
  227. );
  228. extern RetCode ProductVpuGetDebugInfo(
  229. CodecInst* instance,
  230. VPUDebugInfo* info
  231. );
  232. /************************************************************************/
  233. /* ENCODER */
  234. /************************************************************************/
  235. extern RetCode ProductVpuEncUpdateBitstreamBuffer(
  236. CodecInst* instance,
  237. Int32 size
  238. );
  239. extern RetCode ProductVpuEncGetRdWrPtr(
  240. CodecInst* instance,
  241. PhysicalAddress* rdPtr,
  242. PhysicalAddress* wrPtr
  243. );
  244. extern RetCode ProductVpuEncBuildUpOpenParam(
  245. CodecInst* pCodec,
  246. EncOpenParam* param
  247. );
  248. extern RetCode ProductVpuEncFiniSeq(
  249. CodecInst* instance
  250. );
  251. extern RetCode ProductCheckEncOpenParam(
  252. EncOpenParam* param
  253. );
  254. extern RetCode ProductVpuEncSetup(
  255. CodecInst* instance
  256. );
  257. extern RetCode ProductVpuEncode(
  258. CodecInst* instance,
  259. EncParam* param
  260. );
  261. extern RetCode ProductVpuEncGetResult(
  262. CodecInst* instance,
  263. EncOutputInfo* result
  264. );
  265. extern RetCode ProductVpuEncGiveCommand(
  266. CodecInst* instance,
  267. CodecCommand cmd,
  268. void* param);
  269. extern RetCode ProductVpuEncInitSeq(
  270. CodecInst* instance
  271. );
  272. extern RetCode ProductVpuEncGetSeqInfo(
  273. CodecInst* instance,
  274. EncInitialInfo* info
  275. );
  276. extern RetCode ProductVpuGetSrcBufFlag(
  277. CodecInst* instance,
  278. Uint32* data
  279. );
  280. #ifdef __cplusplus
  281. };
  282. #endif /* __cplusplus */
  283. #endif /* __VPUAPI_PRODUCT_ABSTRACT_H__ */