/*! \addtogroup dvb_common DVB Middleware Common * @{ */ /******************************************************************************/ /** * * @file mid_common.h * * @brief This file specifies the APIs provided to control middleware * * @note Copyright (c) 2009 Sunplus Technology Co., Ltd. \n * All rights reserved. * * @author * ******************************************************************************/ #ifndef _MID_COMMON_H_2008_05_12_ #define _MID_COMMON_H_2008_05_12_ /******************************************************************************* * Header include ******************************************************************************/ #include #include #include #include "gl_mempool.h" #include "customize.h" /******************************************************************************* * Define ******************************************************************************/ //#define MID_DVB_VERSION (0x1005010A) //the date of major relase //#define FLASH_SIZE (DVB_FLASH_SIZE) //#define HEADER_ITEM_OFFSET(type, field) ((long)&(((type *)0)->field)) /**< get offset of item in a data structure */ typedef enum { DEMUX_UNIT0 = 0, /*!< */ #ifdef SUPPORT_DUAL_NIM DEMUX_UNIT1, /*!< */ #endif DEMUX_TOTAL_UNITS /*!< */ } DemuxUnit_t; #undef PRIMARY_LIVE_INPUT #ifndef PRIMARY_LIVE_INPUT #define PRIMARY_LIVE_INPUT DEMUX_UNIT0 #endif #ifdef SUPPORT_DUAL_NIM #undef SECOND_LIVE_INPUT #ifndef SECOND_LIVE_INPUT #define SECOND_LIVE_INPUT DEMUX_UNIT1 #endif #endif typedef enum { /* common status values */ MID_SUCCESS, /*!< successful outcome */ MID_ERR_FAILURE, /*!< operation failed */ MID_ERR_INVALID_HANDLE, /*!< invalid handle */ MID_ERR_INVALID_ID, /*!< invalid identifier */ MID_ERR_INVALID_PARAM, /*!< invalid parameter */ MID_ERR_INVALID_OP, /*!< requested operation is invalid */ MID_ERR_MEMORY_ALLOC, /*!< problem allocating memory */ MID_ERR_MEMORY_SIZE, /*!< problem with the size of memory */ /* < supplied */ MID_ERR_RESOURCE_UNAVAILABLE, MID_ERR_TIMEOUT, /*!< timeout */ MID_WARN_NO_ACTION, /* < the function completed successfully,*/ /* < but no action was taken */ MID_WARN_PARAM_CLIPPED, /*!< the function has completed */ /*!< successfully, though a parameter was */ /*!< clipped to within a valid range. */ MID_WARN_BUFFER_EMPTY, MID_WARN_BUFFER_FULL, MID_WARN_UNINITED, /*!< has not been initialized yet */ MID_WARN_INITED, /*!< has been initialized already */ MID_ERR_MODE_MISMATCH, /*!< deinterlacer off*/ MID_ERR_MAX /*!< Max error number*/ } MID_Status_t; #define CRC32 GL_CRC32 #ifndef INVALID_PID #define INVALID_PID 0x1fff #endif /******************************************************************************* * Enumerator ******************************************************************************/ /******************************************************************************* * Structure ******************************************************************************/ /*----------------------STRUCTURE DEFINES----------------------*/ typedef UINT32 LIVE_INPUT_UNIT; /** * \brief rtc_head */ typedef struct __attribute__ ((packed)) { unsigned short year; unsigned char mon; unsigned char date; unsigned char hour; unsigned char min; unsigned char sec; }rtc_head; /** * \brief _mid_common_bits_util_t */ typedef struct _mid_common_bits_util_t { UINT8 *pStart; /*!< \brief data start address */ UINT8 *pEnd; /*!< \brief data end address */ UINT8 *pCur; /*!< \brief data current address */ int nLeftBits; /*!< \brief left bits count of last byte */ UINT8 *pData; /*!< \brief data address */ UINT32 nSize; /*!< \brief data size */ UINT16 rBytes; /*!< \brief current read position of bytes of the data */ UINT8 rBits; /*!< \brief current read position of bits in the last byte */ }MID_CmnBitsUtil_t, *LP_MID_CmnBitsUtil_t; //JennyLee 20100624 added for mantis 86055 [start] #ifdef SUPPORT_TRD #define MAX_TRDNAME_LEN 64 //because this is a 6-bit field in the spec. #define MAX_SRV_TRD 4 //TODO: actually we are not sure what is the maximum ? #define TRD_COUNTRY_MATCHED (1<<0) #define TRD_HAS_PRIMARY (1<<1) #define TRD_HAS_SECONDARY (1<<2) #define TRD_HAS_TERTIARY (1<<3) #define MAX_REGION_LEVEL 4 /*target region signalling*/ typedef struct dvbpsi_target_region_dr_s { UINT8 u8RegionDepth; char u8CountryCode[3]; UINT16 RegionLevel[MAX_REGION_LEVEL+1]; //o not used struct dvbpsi_target_region_dr_s *next; } dvbpsi_target_region_dr_t; typedef struct dvbpsi_target_region_name_dr_s { UINT8 u8RegionDepth; char u8CountryCode[3]; UINT8 u8IsoLangCode[3]; UINT16 RegionLevel[MAX_REGION_LEVEL+1]; //o not used unsigned char ucName[MAX_TRDNAME_LEN]; struct dvbpsi_target_region_name_dr_s *next; } dvbpsi_target_region_name_dr_t; typedef struct trd_in_db_s { UINT8 u8DepthStatus; // 0 means not found the TRD UINT8 u8PrimaryCode; UINT8 u8SecondayCode; UINT16 u16TertiaryCode; } trd_in_db_t; #endif //JennyLee 20100624 added for mantis 86055 [end] /******************************************************************************* * Macro ******************************************************************************/ //-------mem alloc utility start ------------------------------------------------------// #define HAL_DCACHE_LINE_SIZE 32 #define ZERO_MALLOC_FUNC(func_malloc, x) \ ({ \ UINT32 x_align = (x + (HAL_DCACHE_LINE_SIZE-1)) & (~(HAL_DCACHE_LINE_SIZE-1)); \ UINT8 *ret = (UINT8 *)func_malloc(x_align); \ if(ret) memset(ret, 0, x_align); \ ret; \ }) #define SAFR_FREE_FUNC(func_free, p) {if(p){ func_free(p); p = NULL;}} // malloc cached DRAM-A or DRAM-B when A not enough #define zero_malloc(x) ZERO_MALLOC_FUNC(GL_MemAlloc, x) // free #define SAFE_FREE(p) SAFR_FREE_FUNC(GL_MemFree, p) // malloc uncache DRAM-A #define zero_malloc_UncachedA(x) ZERO_MALLOC_FUNC(GL_MemAllocUncachedA, x) // malloc uncache DRAM-B #define zero_malloc_UncachedB(x) ZERO_MALLOC_FUNC(GL_MemAllocUncachedB, x) // free #define SAFE_FREE_UCACHED(p) SAFR_FREE_FUNC(GL_MemFreeUncached, p) // malloc cache DRAM-A //UINT8 *zero_malloc_UncachedA(UINT32 x); #define zero_malloc_CachedA(x) ZERO_MALLOC_FUNC(GL_MemAllocAlignedA, x) // malloc uncache DRAM-B #define zero_malloc_CachedB(x) ZERO_MALLOC_FUNC(GL_MemAllocAlignedB, x) // free #define SAFE_FREE_CACHED(p) SAFR_FREE_FUNC(GL_MemFreeAligned, p) //-------mem alloc utility end ------------------------------------------------------// /******************************************************************************* * Program ******************************************************************************/ void MID_CmnTransStrWithSpeciChar(UINT8 *pu8Src, UINT32 u32Len); //Mika_100629: mantis 92541 void MID_CmnTransStrWithoutControlChar(UINT8 *pu8Src, UINT32 u32Len); //Mika_100707: mantis 94427 int MID_CmnGetDynamicStrLength(UINT8 *pbSrc, UINT32 dLen); //Mika_100629: modify string length incorrect possibly /******************************************************************************/ /** * \fn void MID_CmnTransStrWith00(UINT8 *pu8Src, UINT32 u32Len) * * \brief trans char 0x00 to 0x20(for DTG SI/PSI ).\n * * \param *pu8Src: pointer of a char str.\n * * \param u32Len: data length.\n * \return \e void * * \note none * ******************************************************************************/ //-------trans char 0x00 to 0x20(for DTG SI/PSI )--------------------------------------// void MID_CmnTransStrWith00(UINT8 *pu8Src, UINT32 u32Len); /******************************************************************************/ /** * \fn void MID_CmnTransStrWith00(UINT8 *pu8Src, UINT32 u32Len) * * \brief skip 0xFF, and less than 0x20 chars (for DTG SI/PSI ).\n * * \param *pu8Src: pointer of a char str.\n * * \param u32Len: data length.\n * * \return \e void * * \note none * ******************************************************************************/ void MID_CmnTransStrWithoutSpeciChar(UINT8 *pu8Src, UINT32 u32Len); /******************************************************************************/ /** * \fn void MID_CmnTransStrWithoutNewline(UINT8 *pu8Src, UINT32 u32Len) * * \brief skip 0x8A (for DTG SI/PSI ).\n * * \param *pu8Src: pointer of a char str.\n * * \param u32Len: data length.\n * * \return \e void * * \note none * ******************************************************************************/ void MID_CmnTransStrWithoutNewline(UINT8 *pu8Src, UINT32 u32Len); /******************************************************************************/ /** * \fn void MID_CmnTransStrWithEllipsis(UINT8 *pu8Src, UINT32 *pu32Len, UINT32 u32MaxLen) * * \brief TransStrWithEllipsis.\n * * \param *pu8Src: pointer of a char str.\n * * \param *pu32Len: data length.\n * * \param u32MaxLen: Max data length.\n * * \return \e void * * \note 100401 Fasky added for mantis 83029 start only when querying.\n * ******************************************************************************/ void MID_CmnTransStrWithEllipsis(UINT8 *pu8Src, UINT32 *pu32Len, UINT32 u32MaxLen); /******************************************************************************/ /** * \fn int MID_CmnDecompressString(UINT8 *pu8Src, UINT32 u32Len) * * \brief to decompress the compressed text. \n * * \param *pu8Src: pointer of a char str.\n * * \param u32Len: data length.\n * * \return \e number of charactor * * \note for DTG T2 SI/PSI specification \n * ******************************************************************************/ int MID_CmnDecompressString(UINT8 *pu8Src, UINT32 u32Len); //glenn@20100610 /******************************************************************************/ /** * \fn void MID_CmnBitsInit(MID_CmnBitsUtil_t *pBits, UINT8 *pData, int nSize) * * \brief to complete the struct of MID_CmnBitsUtil_t.\n * * \param *pBits: pointer of input MID_CmnBitsUtil_t struct\n * * \param *pData: point of data add.\n * * \param nSize: buffer size.\n * * \return \e void * * \note none * ******************************************************************************/ void MID_CmnSetDemuxUnit(LIVE_INPUT_UNIT TunerId); LIVE_INPUT_UNIT MID_CmnGetDemuxUnit( void); #endif // _MID_COMMON_H_2008_05_12_