hal_api.h 6.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226
  1. #ifndef _HAL_API_H_
  2. #define _HAL_API_H_
  3. #include "val_types_public.h"
  4. #define DumpReg__ /* /< Dump Reg for debug */
  5. #ifdef DumpReg__
  6. #include <stdio.h>
  7. #endif
  8. #ifdef __cplusplus
  9. extern "C" {
  10. #endif
  11. #define ADD_QUEUE(queue, index, q_type, q_address, q_offset, q_value, q_mask) \
  12. { \
  13. queue[index].type = q_type; \
  14. queue[index].address = q_address; \
  15. queue[index].offset = q_offset; \
  16. queue[index].value = q_value; \
  17. queue[index].mask = q_mask; \
  18. index = index + 1; \
  19. } /* /< ADD QUEUE command */
  20. /**
  21. * @par Enumeration
  22. * HAL_CODEC_TYPE_T
  23. * @par Description
  24. * This is the item used for codec type
  25. */
  26. typedef enum __HAL_CODEC_TYPE_T {
  27. HAL_CODEC_TYPE_VDEC, /* /< VDEC */
  28. HAL_CODEC_TYPE_VENC, /* /< VENC */
  29. HAL_CODEC_TYPE_MAX = 0xFFFFFFFF /* /< MAX Value */
  30. }
  31. HAL_CODEC_TYPE_T;
  32. /**
  33. * @par Enumeration
  34. * HAL_CMD_T
  35. * @par Description
  36. * This is the item used for hal command type
  37. */
  38. typedef enum _HAL_CMD_T {
  39. HAL_CMD_SET_CMD_QUEUE, /* /< set command queue */
  40. HAL_CMD_SET_POWER, /* /< set power */
  41. HAL_CMD_SET_ISR, /* /< set ISR */
  42. HAL_CMD_GET_CACHE_CTRL_ADDR, /* /< get cahce control address */
  43. HAL_CMD_MAX = 0xFFFFFFFF /* /< MAX value */
  44. } HAL_CMD_T;
  45. /**
  46. * @par Enumeration
  47. * REGISTER_GROUP_T
  48. * @par Description
  49. * This is the item used for register group
  50. */
  51. typedef enum _REGISTER_GROUP_T {
  52. VDEC_SYS, /* /< VDEC_SYS */
  53. VDEC_MISC, /* /< VDEC_MISC */
  54. VDEC_VLD, /* /< VDEC_VLD */
  55. VDEC_VLD_TOP, /* /< VDEC_VLD_TOP */
  56. VDEC_MC, /* /< VDEC_MC */
  57. VDEC_AVC_VLD, /* /< VDEC_AVC_VLD */
  58. VDEC_AVC_MV, /* /< VDEC_AVC_MV */
  59. VDEC_HEVC_VLD, /* /< VDEC_HEVC_VLD */
  60. VDEC_HEVC_MV, /* /< VDEC_HEVC_MV */
  61. VDEC_PP, /* /< VDEC_PP */
  62. /* VDEC_SQT, */
  63. VDEC_VP8_VLD, /* /< VDEC_VP8_VLD */
  64. VDEC_VP6_VLD, /* /< VDEC_VP6_VLD */
  65. VDEC_VP8_VLD2, /* /< VDEC_VP8_VLD2 */
  66. VENC_HW_BASE, /* /< VENC_HW_BASE */
  67. VENC_MP4_HW_BASE, /* /< VENC_MP4_HW_BASE */
  68. VCODEC_MAX /* /< VCODEC_MAX */
  69. } REGISTER_GROUP_T;
  70. /**
  71. * @par Enumeration
  72. * REGISTER_GROUP_T
  73. * @par Description
  74. * This is the item used for driver command type
  75. */
  76. typedef enum _VCODEC_DRV_CMD_TYPE {
  77. ENABLE_HW_CMD, /* /< ENABLE_HW_CMD */
  78. DISABLE_HW_CMD, /* /< DISABLE_HW_CMD */
  79. WRITE_REG_CMD, /* /< WRITE_REG_CMD */
  80. READ_REG_CMD, /* /< READ_REG_CMD */
  81. WRITE_SYSRAM_CMD, /* /< WRITE_SYSRAM_CMD */
  82. READ_SYSRAM_CMD, /* /< READ_SYSRAM_CMD */
  83. MASTER_WRITE_CMD, /* /< MASTER_WRITE_CMD */
  84. WRITE_SYSRAM_RANGE_CMD, /* /< WRITE_SYSRAM_RANGE_CMD */
  85. READ_SYSRAM_RANGE_CMD, /* /< READ_SYSRAM_RANGE_CMD */
  86. SETUP_ISR_CMD, /* /< SETUP_ISR_CMD */
  87. WAIT_ISR_CMD, /* /< WAIT_ISR_CMD */
  88. TIMEOUT_CMD, /* /< TIMEOUT_CMD */
  89. MB_CMD, /* /< MB_CMD */
  90. POLL_REG_STATUS_CMD, /* /< POLL_REG_STATUS_CMD */
  91. END_CMD /* /< END_CMD */
  92. } VCODEC_DRV_CMD_TYPE;
  93. /**
  94. * @par Structure
  95. * P_VCODEC_DRV_CMD_T
  96. * @par Description
  97. * Pointer of VCODEC_DRV_CMD_T
  98. */
  99. typedef struct __VCODEC_DRV_CMD_T *P_VCODEC_DRV_CMD_T;
  100. /**
  101. * @par Structure
  102. * VCODEC_DRV_CMD_T
  103. * @par Description
  104. * driver command information
  105. */
  106. typedef struct __VCODEC_DRV_CMD_T {
  107. VAL_UINT32_T type; /* /< type */
  108. VAL_ULONG_T address; /* /< address */
  109. VAL_ULONG_T offset; /* /< offset */
  110. VAL_ULONG_T value; /* /< value */
  111. VAL_ULONG_T mask; /* /< mask */
  112. } VCODEC_DRV_CMD_T;
  113. /**
  114. * @par Structure
  115. * HAL_HANDLE_T
  116. * @par Description
  117. * hal handle information
  118. */
  119. typedef struct _HAL_HANDLE_T_ {
  120. VAL_INT32_T fd_vdec; /* /< fd_vdec */
  121. VAL_INT32_T fd_venc; /* /< fd_venc */
  122. VAL_MEMORY_T rHandleMem; /* /< rHandleMem */
  123. VAL_ULONG_T mmap[VCODEC_MAX]; /* /< mmap[VCODEC_MAX] */
  124. VAL_DRIVER_TYPE_T driverType; /* /< driverType */
  125. VAL_UINT32_T u4TimeOut; /* /< u4TimeOut */
  126. VAL_UINT32_T u4FrameCount; /* /< u4FrameCount */
  127. #ifdef DumpReg__
  128. FILE *pf_out;
  129. #endif
  130. VAL_BOOL_T bProfHWTime; /* /< bProfHWTime */
  131. VAL_UINT64_T u8HWTime[2]; /* /< u8HWTime */
  132. } HAL_HANDLE_T;
  133. /**
  134. * @par Function
  135. * eHalInit
  136. * @par Description
  137. * The init hal driver function
  138. * @param
  139. * a_phHalHandle [IN/OUT] The hal handle
  140. * @param
  141. * a_eHalCodecType [IN] VDEC or VENC
  142. * @par Returns
  143. * VAL_RESULT_T,
  144. * return VAL_RESULT_NO_ERROR if success,
  145. * return VAL_RESULT_INVALID_DRIVER or VAL_RESULT_INVALID_MEMORY if failed
  146. */
  147. VAL_RESULT_T eHalInit(VAL_HANDLE_T *a_phHalHandle, HAL_CODEC_TYPE_T a_eHalCodecType);
  148. /**
  149. * @par Function
  150. * eHalDeInit
  151. * @par Description
  152. * The deinit hal driver function
  153. * @param
  154. * a_phHalHandle [IN/OUT] The hal handle
  155. * @par Returns
  156. * VAL_RESULT_T, return VAL_RESULT_NO_ERROR if success, return else if failed
  157. */
  158. VAL_RESULT_T eHalDeInit(VAL_HANDLE_T *a_phHalHandle);
  159. /**
  160. * @par Function
  161. * eHalGetMMAP
  162. * @par Description
  163. * The get hw register memory map to vitural address function
  164. * @param
  165. * a_hHalHandle [IN/OUT] The hal handle
  166. * @param
  167. * RegAddr [IN] hw register address
  168. * @par Returns
  169. * VAL_UINT32_T, vitural address of hw register memory mapping
  170. */
  171. VAL_ULONG_T eHalGetMMAP(VAL_HANDLE_T *a_hHalHandle, VAL_UINT32_T RegAddr);
  172. /**
  173. * @par Function
  174. * eHalCmdProc
  175. * @par Description
  176. * The hal command processing function
  177. * @param
  178. * a_hHalHandle [IN/OUT] The hal handle
  179. * @param
  180. * a_eHalCmd [IN] The hal command structure
  181. * @param
  182. * a_pvInParam [IN] The hal input parameter
  183. * @param
  184. * a_pvOutParam [OUT] The hal output parameter
  185. * @par Returns
  186. * VAL_RESULT_T, return VAL_RESULT_NO_ERROR if success, return else if failed
  187. */
  188. VAL_RESULT_T eHalCmdProc(
  189. VAL_HANDLE_T *a_hHalHandle,
  190. HAL_CMD_T a_eHalCmd,
  191. VAL_VOID_T *a_pvInParam,
  192. VAL_VOID_T *a_pvOutParam
  193. );
  194. #ifdef __cplusplus
  195. }
  196. #endif
  197. #endif /* #ifndef _HAL_API_H_ */