hi_comm_pciv.h 9.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287
  1. /******************************************************************************
  2. Copyright (C), 2001-2011, Hisilicon Tech. Co., Ltd.
  3. ******************************************************************************
  4. File Name : hi_comm_pciv.h
  5. Version : Initial Draft
  6. Author : Hisilicon multimedia software pciv
  7. Created : 2008/06/04
  8. Last Modified :
  9. Description : common struct definition for PCIV
  10. Function List :
  11. History :
  12. ******************************************************************************/
  13. #ifndef __HI_COMM_PCIV_H__
  14. #define __HI_COMM_PCIV_H__
  15. #include "hi_type.h"
  16. #include "hi_common.h"
  17. #include "hi_errno.h"
  18. #include "hi_comm_video.h"
  19. #include "hi_comm_vpss.h"
  20. #ifdef __cplusplus
  21. #if __cplusplus
  22. extern "C"{
  23. #endif
  24. #endif /* __cplusplus */
  25. typedef HI_S32 PCIV_CHN;
  26. #define PCIV_MAX_BUF_NUM 16 /* pciv channel max buffer number */
  27. #define PCIV_MAX_CHIPNUM 32 /* max pciv device number which can join in the system */
  28. #define PCIV_TIMER_EXPIRES 10
  29. #define MAKE_DWORD(high,low) (((low)&0x0000ffff)|((high)<<16))
  30. #define HIGH_WORD(x) (((x)&0xffff0000)>>16)
  31. #define LOW_WORD(x) ((x)&0x0000ffff)
  32. typedef struct hiPCIV_VIDEVICE_S
  33. {
  34. VI_DEV viDev; /* vi device number */
  35. VI_CHN viChn; /* vi channel number */
  36. } PCIV_VIDEVICE_S;
  37. typedef struct hiPCIV_VODEVICE_S
  38. {
  39. VO_DEV voDev; /* vo device number */
  40. VO_CHN voChn; /* vo channel number */
  41. } PCIV_VODEVICE_S;
  42. typedef struct hiPCIV_VDECDEVICE_S
  43. {
  44. VDEC_CHN vdecChn; /* vedc channel number */
  45. } PCIV_VDECDEVICE_S;
  46. typedef struct hiPCIV_VPSSDEVICE_S
  47. {
  48. VPSS_GRP vpssGrp; /* vpss group number */
  49. VPSS_CHN vpssChn; /* vpss channel number */
  50. } PCIV_VPSSDEVICE_S;
  51. typedef struct hiPCIV_VENCDEVICE_S
  52. {
  53. VENC_CHN vencChn; /* venc channel number */
  54. } PCIV_VENCDEVICE_S;
  55. /* bind type for pciv */
  56. typedef enum hiPCIV_BIND_TYPE_E
  57. {
  58. PCIV_BIND_VI = 0,
  59. PCIV_BIND_VO = 1,
  60. PCIV_BIND_VDEC = 2,
  61. PCIV_BIND_VPSS = 3,
  62. PCIV_BIND_VENC = 4,
  63. PCIV_BIND_BUTT
  64. } PCIV_BIND_TYPE_E;
  65. /*status of share buff*/
  66. typedef enum hiPCIV_BUFF_STATUS_E
  67. {
  68. BUFF_FREE = 0,
  69. BUFF_BUSY = 1,
  70. BUFF_HOLD = 2,
  71. BUFF_BUTT
  72. }PCIV_BUFF_STATUS_E;
  73. /* bind object struct for pciv */
  74. typedef struct hiPCI_BIND_OBJ_S
  75. {
  76. HI_BOOL bVpssSend;
  77. PCIV_BIND_TYPE_E enType; /* bind type for pciv */
  78. union
  79. {
  80. PCIV_VIDEVICE_S viDevice;
  81. PCIV_VODEVICE_S voDevice;
  82. PCIV_VDECDEVICE_S vdecDevice;
  83. PCIV_VPSSDEVICE_S vpssDevice;
  84. PCIV_VENCDEVICE_S vencDevice;
  85. } unAttachObj;
  86. } PCIV_BIND_OBJ_S;
  87. /* remote pciv object */
  88. typedef struct hiPCIV_REMOTE_OBJ_S
  89. {
  90. HI_S32 s32ChipId; /* remote pciv device Id number */
  91. PCIV_CHN pcivChn; /* pciv channel number of remote pciv device */
  92. } PCIV_REMOTE_OBJ_S;
  93. /* attribution of target picture */
  94. typedef struct hiPCIV_PIC_ATTR_S
  95. {
  96. HI_U32 u32Width; /* pciture width of pciv channel */
  97. HI_U32 u32Height; /* picture height of pciv channel */
  98. HI_U32 u32Stride[3]; /* pciture stride of pciv channel */
  99. VIDEO_FIELD_E u32Field; /* video frame field type of pciv channel */
  100. PIXEL_FORMAT_E enPixelFormat; /* pixel format of pciture of pciv channel */
  101. DYNAMIC_RANGE_E enDynamicRange; /* */
  102. COMPRESS_MODE_E enCompressMode; /* */
  103. VIDEO_FORMAT_E enVideoFormat; /* */
  104. } PCIV_PIC_ATTR_S;
  105. /* attribution of pciv chn */
  106. typedef struct hiPCIV_ATTR_S
  107. {
  108. PCIV_PIC_ATTR_S stPicAttr; /* picture attibute */
  109. HI_S32 s32BufChip; /* The chip id which buffer is belong to */
  110. HI_U32 u32BlkSize; /* vb size of receiver for preview */
  111. HI_U32 u32Count; /* lenght of address list */
  112. HI_U64 u64PhyAddr[PCIV_MAX_BUF_NUM]; /* address list for picture move */
  113. PCIV_REMOTE_OBJ_S stRemoteObj; /* remote pciv object */
  114. } PCIV_ATTR_S;
  115. /* max count of video buffer block for pci window */
  116. #define PCIV_MAX_VBCOUNT 8
  117. /* mpp video buffer config for pci window */
  118. typedef struct hiPCIV_WINVBCFG_S
  119. {
  120. HI_U32 u32PoolCount; /* total number of video buffer pool */
  121. HI_U32 u32BlkSize[PCIV_MAX_VBCOUNT]; /* size of video buffer pool */
  122. HI_U32 u32BlkCount[PCIV_MAX_VBCOUNT]; /* number of video buffer pool */
  123. } PCIV_WINVBCFG_S;
  124. typedef struct hiPCIV_BASEWINDOW_S
  125. {
  126. HI_S32 s32ChipId; /* pciv device number */
  127. HI_U64 u64NpWinBase; /* non-prefetch window pcie base address */
  128. HI_U64 u64PfWinBase; /* prefetch window pcie base address */
  129. HI_U64 u64CfgWinBase; /* config window pcie base address */
  130. HI_U64 u64PfAHBAddr; /* prefetch window AHB base address */
  131. } PCIV_BASEWINDOW_S;
  132. #define PCIV_MAX_DMABLK 128
  133. typedef struct hiPCIV_DMA_BLOCK_S
  134. {
  135. HI_U64 u64SrcAddr; /* source address of dma task */
  136. HI_U64 u64DstAddr; /* destination address of dma task */
  137. HI_U32 u32BlkSize; /* data block size of dma task */
  138. } PCIV_DMA_BLOCK_S;
  139. typedef struct hiPCIV_DMA_TASK_S
  140. {
  141. HI_U32 u32Count; /* total dma task number */
  142. HI_BOOL bRead; /* dam task is read or write data */
  143. PCIV_DMA_BLOCK_S *pBlock;
  144. } PCIV_DMA_TASK_S;
  145. /*
  146. * Message port used in pciv_drvadp, you can't use it in your application.
  147. */
  148. #define PCIV_MSGPORT_KERNEL 80
  149. /*
  150. * You should not use follow mocros, they will be deleted !
  151. */
  152. #define PCIV_MSGPORT_MAXPORT 100
  153. #define PCIV_MSGPORT_TIME 79
  154. #define PCIV_MSGPORT_USERCMD 81
  155. #define PCIV_MSGPORT_USERNOTIFY2HOST 82
  156. #define PCIV_MSGPORT_USERNOTIFY2SLAVE 83
  157. #define PCIV_MSGPORT_USERNOTIFY2HOST_VDEC 84
  158. #define PCIV_MSGPORT_USERNOTIFY2SLAVE_VDEC 85
  159. #define PCIV_MAXVO_BIND 4
  160. /*----------------------------------------*/
  161. typedef enum hiPCIV_FILTER_TYPE_E
  162. {
  163. PCIV_FILTER_TYPE_NORM,
  164. PCIV_FILTER_TYPE_EX,
  165. PCIV_FILTER_TYPE_EX2,
  166. PCIV_FILTER_TYPE_BUTT
  167. } PCIV_FILTER_TYPE_E;
  168. typedef enum hiPCIV_PIC_FIELD_E
  169. {
  170. PCIV_FIELD_TOP,
  171. PCIV_FIELD_BOTTOM,
  172. PCIV_FIELD_BOTH,
  173. PCIV_FIELD_BUTT
  174. } PCIV_PIC_FIELD_E;
  175. /*
  176. * configuration of pre-process before sending source picture whth PCI
  177. * item in this structrue have default value when sys init
  178. */
  179. typedef struct hiPCIV_PREPROC_CFG_S
  180. {
  181. PCIV_PIC_FIELD_E enFieldSel; /* pictrue field select */
  182. PCIV_FILTER_TYPE_E enFilterType; /* filter group type */
  183. } PCIV_PREPROC_CFG_S;
  184. #if 0
  185. /* Synchronize the time and PTS. The host is base. */
  186. typedef struct hiPCIV_TIME_SYNC_S
  187. {
  188. struct timeval stSysTime; /* The current system time */
  189. HI_U64 u64PtsBase; /* The media PTS */
  190. HI_U32 u32ReqTagId;
  191. } PCIV_TIME_SYNC_S;
  192. #endif
  193. /* invlalid channel ID */
  194. #define HI_ERR_PCIV_INVALID_CHNID HI_DEF_ERR(HI_ID_PCIV, EN_ERR_LEVEL_ERROR, EN_ERR_INVALID_CHNID)
  195. /* at lease one parameter is illagal ,eg, an illegal enumeration value */
  196. #define HI_ERR_PCIV_ILLEGAL_PARAM HI_DEF_ERR(HI_ID_PCIV, EN_ERR_LEVEL_ERROR, EN_ERR_ILLEGAL_PARAM)
  197. /* channel exists */
  198. #define HI_ERR_PCIV_EXIST HI_DEF_ERR(HI_ID_PCIV, EN_ERR_LEVEL_ERROR, EN_ERR_EXIST)
  199. /* channel exists */
  200. #define HI_ERR_PCIV_UNEXIST HI_DEF_ERR(HI_ID_PCIV, EN_ERR_LEVEL_ERROR, EN_ERR_UNEXIST)
  201. /* using a NULL point */
  202. #define HI_ERR_PCIV_NULL_PTR HI_DEF_ERR(HI_ID_PCIV, EN_ERR_LEVEL_ERROR, EN_ERR_NULL_PTR)
  203. /* try to enable or initialize system,device or channel, before configing attribute */
  204. #define HI_ERR_PCIV_NOT_CONFIG HI_DEF_ERR(HI_ID_PCIV, EN_ERR_LEVEL_ERROR, EN_ERR_NOT_CONFIG)
  205. /* operation is not supported by NOW */
  206. #define HI_ERR_PCIV_NOT_SUPPORT HI_DEF_ERR(HI_ID_PCIV, EN_ERR_LEVEL_ERROR, EN_ERR_NOT_SUPPORT)
  207. /* operation is not permitted ,eg, try to change stati attribute */
  208. #define HI_ERR_PCIV_NOT_PERM HI_DEF_ERR(HI_ID_PCIV, EN_ERR_LEVEL_ERROR, EN_ERR_NOT_PERM)
  209. /* failure caused by malloc memory */
  210. #define HI_ERR_PCIV_NOMEM HI_DEF_ERR(HI_ID_PCIV, EN_ERR_LEVEL_ERROR, EN_ERR_NOMEM)
  211. /* failure caused by malloc buffer */
  212. #define HI_ERR_PCIV_NOBUF HI_DEF_ERR(HI_ID_PCIV, EN_ERR_LEVEL_ERROR, EN_ERR_NOBUF)
  213. /* no data in buffer */
  214. #define HI_ERR_PCIV_BUF_EMPTY HI_DEF_ERR(HI_ID_PCIV, EN_ERR_LEVEL_ERROR, EN_ERR_BUF_EMPTY)
  215. /* no buffer for new data */
  216. #define HI_ERR_PCIV_BUF_FULL HI_DEF_ERR(HI_ID_PCIV, EN_ERR_LEVEL_ERROR, EN_ERR_BUF_FULL)
  217. /* system is not ready,had not initialed or loaded*/
  218. #define HI_ERR_PCIV_SYS_NOTREADY HI_DEF_ERR(HI_ID_PCIV, EN_ERR_LEVEL_ERROR, EN_ERR_SYS_NOTREADY)
  219. /* One DMA task is working, wait a minute */
  220. #define HI_ERR_PCIV_BUSY HI_DEF_ERR(HI_ID_PCIV, EN_ERR_LEVEL_ERROR, EN_ERR_BUSY)
  221. #define HI_ERR_PCIV_TIMEOUT HI_DEF_ERR(HI_ID_PCIV, EN_ERR_LEVEL_ERROR, EN_ERR_BUTT+1)
  222. #define PCIV_TRACE(level, fmt...)\
  223. do{ \
  224. HI_TRACE(level, HI_ID_PCIV,"[Func]:%s [Line]:%d [Info]:", __FUNCTION__, __LINE__);\
  225. HI_TRACE(level,HI_ID_PCIV,##fmt);\
  226. }while(0)
  227. #define PCIV_CHECK_CHNID(ChnID)\
  228. do{\
  229. if(((ChnID) < 0) || ((ChnID) >= PCIV_MAX_CHN_NUM))\
  230. {\
  231. PCIV_TRACE(HI_DBG_ERR, "invalid chn id:%d \n", ChnID);\
  232. return HI_ERR_PCIV_INVALID_CHNID;\
  233. }\
  234. }while(0)
  235. #define PCIV_CHECK_PTR(ptr)\
  236. do{\
  237. if(NULL == (ptr))\
  238. {\
  239. PCIV_TRACE(HI_DBG_ERR, "PTR is NULL!\n");\
  240. return HI_ERR_PCIV_NULL_PTR;\
  241. }\
  242. }while(0)
  243. #ifdef __cplusplus
  244. #if __cplusplus
  245. }
  246. #endif
  247. #endif /* __cplusplus */
  248. #endif /* __HI_COMM_PCIV_H__ */