ewl.h 7.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182
  1. /*------------------------------------------------------------------------------
  2. -- --
  3. -- This software is confidential and proprietary and may be used --
  4. -- only as expressly authorized by a licensing agreement from --
  5. -- --
  6. -- Hantro Products Oy. --
  7. -- --
  8. -- (C) COPYRIGHT 2006 HANTRO PRODUCTS OY --
  9. -- ALL RIGHTS RESERVED --
  10. -- --
  11. -- The entire notice above must be reproduced --
  12. -- on all copies and should not be removed. --
  13. -- --
  14. --------------------------------------------------------------------------------
  15. --
  16. -- Abstract : Hantro Encoder Wrapper Layer for OS services
  17. --
  18. ------------------------------------------------------------------------------*/
  19. #ifndef __EWL_H__
  20. #define __EWL_H__
  21. #ifdef __cplusplus
  22. extern "C"
  23. {
  24. #endif
  25. #include "basetype.h"
  26. /* Return values */
  27. #define EWL_OK 0
  28. #define EWL_ERROR -1
  29. #define EWL_HW_WAIT_OK EWL_OK
  30. #define EWL_HW_WAIT_ERROR EWL_ERROR
  31. #define EWL_HW_WAIT_TIMEOUT 1
  32. /* HW configuration values */
  33. #define EWL_HW_BUS_TYPE_UNKNOWN 0
  34. #define EWL_HW_BUS_TYPE_AHB 1
  35. #define EWL_HW_BUS_TYPE_OCP 2
  36. #define EWL_HW_BUS_TYPE_AXI 3
  37. #define EWL_HW_BUS_TYPE_PCI 4
  38. #define EWL_HW_BUS_WIDTH_UNKNOWN 0
  39. #define EWL_HW_BUS_WIDTH_32BITS 1
  40. #define EWL_HW_BUS_WIDTH_64BITS 2
  41. #define EWL_HW_BUS_WIDTH_128BITS 3
  42. #define EWL_HW_SYNTHESIS_LANGUAGE_UNKNOWN 0
  43. #define EWL_HW_SYNTHESIS_LANGUAGE_VHDL 1
  44. #define EWL_HW_SYNTHESIS_LANGUAGE_VERILOG 2
  45. #define EWL_HW_CONFIG_NOT_SUPPORTED 0
  46. #define EWL_HW_CONFIG_ENABLED 1
  47. /* Hardware configuration description */
  48. typedef struct EWLHwConfig
  49. {
  50. u32 maxEncodedWidth; /* Maximum supported width for video encoding (not JPEG) */
  51. u32 h264Enabled; /* HW supports H.264 */
  52. u32 jpegEnabled; /* HW supports JPEG */
  53. u32 mpeg4Enabled; /* HW supports MPEG-4 */
  54. u32 vsEnabled; /* HW supports video stabilization */
  55. u32 rgbEnabled; /* HW supports RGB input */
  56. u32 searchAreaSmall; /* HW search area reduced */
  57. u32 inputYuvTiledEnabled; /* HW supports tiled YUV input format */
  58. u32 busType; /* HW bus type in use */
  59. u32 busWidth;
  60. u32 synthesisLanguage;
  61. } EWLHwConfig_t;
  62. /* Allocated linear memory area information */
  63. typedef struct EWLLinearMem
  64. {
  65. u32 *virtualAddress;
  66. u32 busAddress;
  67. u32 size;
  68. } EWLLinearMem_t;
  69. /* EWLInitParam is used to pass parameters when initializing the EWL */
  70. typedef struct EWLInitParam
  71. {
  72. u32 clientType;
  73. } EWLInitParam_t;
  74. #define EWL_CLIENT_TYPE_H264_ENC 1U
  75. #define EWL_CLIENT_TYPE_MPEG4_ENC 2U
  76. #define EWL_CLIENT_TYPE_JPEG_ENC 3U
  77. #define EWL_CLIENT_TYPE_VIDEOSTAB 4U
  78. /*------------------------------------------------------------------------------
  79. 4. Function prototypes
  80. ------------------------------------------------------------------------------*/
  81. /* Read and return the HW ID register value, static implementation */
  82. u32 EWLReadAsicID(void);
  83. /* Read and return HW configuration info, static implementation */
  84. EWLHwConfig_t EWLReadAsicConfig(void);
  85. /* Initialize the EWL instance
  86. * Returns a wrapper instance or NULL for error
  87. * EWLInit is called when the encoder instance is initialized */
  88. const void *EWLInit(EWLInitParam_t * param);
  89. /* Release the EWL instance
  90. * Returns EWL_OK or EWL_ERROR
  91. * EWLRelease is called when the encoder instance is released */
  92. i32 EWLRelease(const void *inst);
  93. /* Reserve the HW resource for one codec instance
  94. * EWLReserveHw is called when beginning a frame encoding
  95. * The function may block until the resource is available.
  96. * Returns EWL_OK if the resource was successfully reserved for this instance
  97. * or EWL_ERROR if unable to reserve the resource. */
  98. i32 EWLReserveHw(const void *inst);
  99. /* Release the HW resource
  100. * EWLReleaseHw is called when the HW has finished the frame encoding.
  101. * The codec SW will continue the frame encoding but the HW can
  102. * be used by another codec.*/
  103. void EWLReleaseHw(const void *inst);
  104. /* Frame buffers memory */
  105. i32 EWLMallocRefFrm(const void *inst, u32 size, EWLLinearMem_t * info);
  106. void EWLFreeRefFrm(const void *inst, EWLLinearMem_t * info);
  107. /* SW/HW shared memory */
  108. i32 EWLMallocLinear(const void *inst, u32 size, EWLLinearMem_t * info);
  109. void EWLFreeLinear(const void *inst, EWLLinearMem_t * info);
  110. /* D-Cache coherence *//* Not in use currently */
  111. void EWLDCacheRangeFlush(const void *instance, EWLLinearMem_t * info);
  112. void EWLDCacheRangeRefresh(const void *instance, EWLLinearMem_t * info);
  113. /* Write value to a HW register
  114. * All registers are written at once at the beginning of frame encoding
  115. * Offset is relative to the the HW ID register (#0) in bytes
  116. * Enable indicates when the HW is enabled. If shadow registers are used then
  117. * they must be flushed to the HW registers when enable is '1' before
  118. * writing the register that enables the HW */
  119. void EWLWriteReg(const void *inst, u32 offset, u32 val);
  120. /* Read and return the value of a HW register
  121. * The status register is read after every macroblock encoding by SW
  122. * The other registers which may be updated by the HW are read after
  123. * BUFFER_FULL or FRAME_READY interrupt
  124. * Offset is relative to the the HW ID register (#0) in bytes */
  125. u32 EWLReadReg(const void *inst, u32 offset);
  126. /* Writing all registers in one call *//*Not in use currently */
  127. void EWLWriteRegAll(const void *inst, const u32 * table, u32 size);
  128. /* Reading all registers in one call *//*Not in use currently */
  129. void EWLReadRegAll(const void *inst, u32 * table, u32 size);
  130. /* HW enable/disable. This will write <val> to register <offset> and by */
  131. /* this enablig/disabling the hardware. */
  132. void EWLEnableHW(const void *inst, u32 offset, u32 val);
  133. void EWLDisableHW(const void *inst, u32 offset, u32 val);
  134. /* Synchronize SW with HW
  135. * Returns EWL_HW_WAIT_OK, EWL_HW_WAIT_ERROR or EWL_HW_WAIT_TIMEOUT
  136. * EWLWaitHwRdy is called after enabling the HW to wait for IRQ from HW.
  137. * If slicesReady pointer is given, at input it should contain the number
  138. * of slicesReady received. The function will return when the HW has finished
  139. * encoding next slice. Upon return the slicesReady pointer will contain
  140. * the number of slices that are ready and available in the HW output buffer.
  141. */
  142. i32 EWLWaitHwRdy(const void *inst, u32 *slicesReady);
  143. /* SW/SW shared memory handling */
  144. void *EWLmalloc(u32 n);
  145. void *EWLcalloc(u32 n, u32 s);
  146. void EWLfree(void *p);
  147. void *EWLmemcpy(void *d, const void *s, u32 n);
  148. void *EWLmemset(void *d, i32 c, u32 n);
  149. #ifdef __cplusplus
  150. }
  151. #endif
  152. #endif /*__EWL_H__*/