db_lcn.h 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343
  1. /**
  2. * Copyright(c) 2011 Sunmedia Technologies - All Rights Reserved.
  3. *
  4. * @file
  5. * macros, declarations and definitions for LCN Process.
  6. *
  7. * @author jun.luo
  8. *
  9. */
  10. #ifndef _DB_LCN_H_
  11. #define _DB_LCN_H_
  12. #include "db_common.h"
  13. #include "cdbi.h"
  14. #ifdef __cplusplus
  15. extern "C"{
  16. #endif
  17. #define HAS_LCN(ProgNum) (ProgNum & (DB_DVB_LCN_INDICATOR | DB_DVB_LCN2_INDICATOR))
  18. #define HAS_NORDIGV2_LCN(ProgNum) (ProgNum & DB_DVB_LCN2_INDICATOR)
  19. #define GET_LCN(ProgNum) (ProgNum & ~(DB_DVB_LCN_INDICATOR | DB_DVB_LCN2_INDICATOR))
  20. /* Exported constants */
  21. enum
  22. {
  23. DB_DVB_MAX_LCN_CONF_PROG = 10, /**< Define the max number of program have the same LCN number */
  24. DB_DVB_LCN_INDICATOR = 0x8000, /**<If a programe index MSB is set, it indicate a LCN number */
  25. DB_DVB_LCN2_INDICATOR = 0x4000, /**< Indicator for LCN version 2, actural used by Nordig */
  26. //#ifdef SUPPORT_DVBS_LCN
  27. DB_DVB_LCN_MASK = 0x3FFF,
  28. //#else
  29. //DB_DVB_LCN_MASK = 0x3FF,
  30. //#endif
  31. DB_DVB_MAX_CHNLIST_NUM = 10, /**< The value is the same with MAX_SGT_SEVLIST_NUM define */
  32. DB_DVB_MAX_CHNLIST_NAME_LEN = 40, /* Ghana spec required 23 bytes, and ASTRA LCN Spec required 31 bytes */
  33. DB_DVB_MAX_MULTILCN_NUM = 10, /**< Ghana use idx 0, ASTRA LCN use all slots(Actually we are not sure what is the maximum ?) */
  34. };
  35. /**< LCN Rule type */
  36. typedef enum
  37. {
  38. DB_DVB_LCNRULE_GBR = 0, /**< lcn sort rule of UK */
  39. DB_DVB_LCNRULE_ITA, /**< lcn sort rule of Italy */
  40. DB_DVB_LCNRULE_NORDIG, /**< lcn sort rule of Nordig */
  41. DB_DVB_LCNRULE_GHA, /**< lcn sort rule of Ghana */
  42. DB_DVB_LCNRULE_THA, /**< lcn sort rule of Thailand */
  43. DB_DVB_LCNRULE_NLD, /**< lcn sort rule of Netherlands */
  44. DB_DVB_LCNRULE_PANEURO, /**< lcn sort rule of pan Europe */
  45. DB_DVB_LCNRULE_AUS,
  46. #ifdef CONFIG_SUPPORT_FAST_SCANNING
  47. DB_DVB_LCNRULE_M7_FAST,
  48. #endif
  49. DB_DVB_LCNRULE_GUARD,
  50. } EDBLCNRule_t;
  51. /**< LCN Assign Rule deifne */
  52. typedef enum
  53. {
  54. /**< Assign Program Num of All None LCN services and conflict LCN services following their own Spec */
  55. DB_DVB_ASSIGN_NONELCN_FOLLOW_SPEC = 0,
  56. /**< Some customer required this behavior, assign Program Num of All None LCN services and conflict LCN services following the Max LCN Number */
  57. DB_DVB_ASSIGN_NONELCN_FOLLOW_MAX,
  58. /**< Assign Program Num of All None LCN services and conflict LCN services from 800 */
  59. DB_DVB_ASSIGN_NONELCN_FROM_800,
  60. } EDBLCNAssignRule_t;
  61. /**< Extend LCN Assign Rule deifne */
  62. typedef enum
  63. {
  64. /**< Assign Program Num of All None LCN services and conflict LCN services combine */
  65. DB_DVB_ASSIGN_NONELCN_COMBINE = 0,
  66. /**< Some customer required this behavior, assign Program Num independently within same service type(TV, Radio, Data service) */
  67. DB_DVB_ASSIGN_NONELCN_SEPARATE,
  68. } EDBLCNAssignRuleExt_t;
  69. typedef enum
  70. {
  71. DB_DVB_TRD_COUNTRY_MATCHED = 1 << 0,
  72. DB_DVB_TRD_HAS_PRIMARY = 1 << 1,
  73. DB_DVB_TRD_HAS_SECONDARY = 1 << 2,
  74. DB_DVB_TRD_HAS_TERTIARY = 1 << 3,
  75. } EDBTRDInfo_t;
  76. /**< TRND(Target Region Name Decriptor) Dictionary define */
  77. typedef struct _DBTRNDDictionary_t
  78. {
  79. struct _DBTRNDDictionary_t *pNext; /**< Pointer to The next TRND */
  80. UINT8 pTRND[0]; /**< Content of Target Ragion Name Decriptor */
  81. } DBTRNDDictionary_t, *PDBTRNDDictionary_t;
  82. /**< structure defined for ASTRA LCN & Ghana LCN processing */
  83. typedef struct _DBDVBLocator
  84. {
  85. UINT16 usONID;
  86. UINT16 usTSID;
  87. UINT16 usSrvID;
  88. }DBDVBLocator_t, *PDBDVBLocator_t;
  89. typedef struct _DBSingChnLCN_t
  90. {
  91. UINT16 usChnListID;
  92. UINT8 bVisibleFlag;
  93. UINT8 ucServType; /* loaded by Service descriptor */
  94. UINT16 usLCN;
  95. } DBSingChnLCN_t, *PDBSingChnLCN_t;
  96. typedef struct _DBMultiLCN_t
  97. {
  98. UINT32 uiUsrData; /**< this data will be explained by application itself */
  99. DBDVBLocator_t stLocator;
  100. DBSingChnLCN_t stChnLCNs[DB_DVB_MAX_CHNLIST_NUM][DB_DVB_MAX_MULTILCN_NUM];
  101. struct _DBMultiLCN_t *pNextServ;
  102. } DBMultiLCN_t, *PDBMultiLCN_t;
  103. typedef struct _DBMultiChnListInfo
  104. {
  105. PDBMultiLCN_t pCurPtr; /* iterator for single list traversal */
  106. PDBMultiLCN_t pDBMultiLCN;
  107. UINT16 usCurIdx; /* iterator for array traversal */
  108. UINT16 usValidCnt;
  109. /**< Notice: Nordig channel list required 8bits but ASTRA chnlist id required 16 bits space */
  110. UINT8 ucChnListID[DB_DVB_MAX_CHNLIST_NUM];
  111. UINT8 ucChnListName[DB_DVB_MAX_CHNLIST_NUM][DB_DVB_MAX_CHNLIST_NAME_LEN];
  112. } DBMultiChnListInfo_t, *PDBMultiChnListInfo;
  113. /**< LCN conflict list */
  114. typedef struct _DBLCNConfSet_t
  115. {
  116. UINT16 LCNNum; /**< The conflict LCN number */
  117. UINT8 ProgCount; /**< The count of service which request the same LCN */
  118. UINT8 ProgType[DB_DVB_MAX_LCN_CONF_PROG]; /**< The type of conflict lcn programe*/
  119. CDBIHandle_t hProg[DB_DVB_MAX_LCN_CONF_PROG]; /**< The handle of conflict lcn programe, use it to update or get something*/
  120. UINT8 ProgNIDMatch[DB_DVB_MAX_LCN_CONF_PROG]; /**< Specify this program whether match current country's ONID, used by Italy(Z-Book) only */
  121. UINT8 ProgSQI[DB_DVB_MAX_LCN_CONF_PROG]; /**< Signal Strength */
  122. UINT8 ProgSSI[DB_DVB_MAX_LCN_CONF_PROG]; /**< Signal Quality */
  123. DBTRDCodeInfo_t stTrd[DB_DVB_MAX_LCN_CONF_PROG][DB_DVB_MAX_SRV_TRD]; /**< the service's target region */
  124. struct _DBLCNConfSet_t *pNextConfSet; /**< Pointer to next LCN conflict set */
  125. } DBLCNConfSet_t, *PDBLCNConfSet_t;
  126. /**< Conflict LCN total list */
  127. typedef struct
  128. {
  129. UINT16 ConfCount; /**< The count of conflict lcn programe */
  130. PDBLCNConfSet_t pLCNConfSet; /**< Just store conflict lcn programe */
  131. } DBLCNConfInfo_t, *PDBLCNConfInfo_t;
  132. /**< LCN conflict list */
  133. typedef struct _DBLCNVariantSet_t
  134. {
  135. UINT16 LCNNum; /**< The conflict LCN number */
  136. UINT8 ProgCount; /**< The count of service which request the same LCN */
  137. UINT16 hMinTVProg; /**< The one has minimum program number */
  138. UINT16 hMinRadioProg; /**< The one has minimum program number */
  139. UINT16 hMinDataProg; /**< The one has minimum program number */
  140. UINT8 ProgType[DB_DVB_MAX_LCN_CONF_PROG]; /**< The type of conflict lcn programe*/
  141. UINT16 hProg[DB_DVB_MAX_LCN_CONF_PROG]; /**< The handle of conflict lcn programe, use it to update or get something*/
  142. UINT16 NID[DB_DVB_MAX_LCN_CONF_PROG]; /**< Network ID for this service */
  143. struct _DBLCNVariantSet_t *pNextConfSet; /**< Pointer to next LCN conflict set */
  144. } DBLCNRiksVariantNode_t, *PDBLCNRiksVariantNode_t;
  145. /**< Regional variants info for those services whihc LCN conflict */
  146. typedef struct
  147. {
  148. UINT16 ConfCount; /**< The count of conflict lcn programe */
  149. PDBLCNRiksVariantNode_t pLCNRiksVariantSet; /**< Just store conflict lcn programe */
  150. } DBLCNRiksVariantInfo_t, *PDBLCNRiksVariantInfo_t;
  151. /**
  152. * @brief Set LCN process rule.
  153. *
  154. * @param eLCNRule Specified LCN Rule.
  155. *
  156. * @return DB_SUCCESS if succeed, error code otherwise.
  157. */
  158. EDBError_t LCN_SetLCNRule(EDBLCNRule_t eLCNRule);
  159. /**
  160. * @brief whether support HD Simulcast LCN swap function.
  161. *
  162. * @return TRUE or FALSE.
  163. */
  164. bool LCN_SupportHDSimulSwap(void);
  165. /**
  166. * @brief Set LCN process rule.
  167. *
  168. * @param eAssignLCNRule None LCN service assign Rule follow spec or follow the max LCN.
  169. * @param eAssingLCNRuleExt Assign number to None LCN service combine or separately.
  170. *
  171. * @return DB_SUCCESS if succeed, error code otherwise.
  172. */
  173. EDBError_t LCN_SetExtLCNRule(EDBLCNAssignRule_t eAssignLCNRule, EDBLCNAssignRuleExt_t eAssingLCNRuleExt);
  174. /**
  175. * @brief Assign LCN to this service.
  176. *
  177. * @param hServ service handle.
  178. *
  179. * @return DB_SUCCESS if succeed, error code otherwise.
  180. */
  181. EDBError_t LCN_AssignLCN(CDBIHandle_t hServ);
  182. /**
  183. * @brief Assign a valid Number to None LCN service or the loser of conflict LCN service.
  184. *
  185. * @param hServ service handle.
  186. * @param usCurLCN used by Italy(Z-Book).
  187. *
  188. * @return DB_SUCCESS if succeed, error code otherwise.
  189. */
  190. EDBError_t LCN_AssignNonLCN(CDBIHandle_t hServ, UINT16 usCurLCN);
  191. /**
  192. * @brief Get all LCN conflict to conflict list.
  193. *
  194. * @param pLCNConflictList[out] pointer to LCN conflict List.
  195. *
  196. * @return DB_SUCCESS if succeed, error code otherwise.
  197. */
  198. EDBError_t LCN_QueryLCNConflict(DBLCNConfInfo_t *pLCNConflictList);
  199. /**
  200. * @brief free LCN conflict list.
  201. *
  202. * @return DB_SUCCESS if succeed, error code otherwise.
  203. */
  204. EDBError_t LCN_FreeLCNConflict(void);
  205. /**
  206. * @brief Query all regional variant for Riks TRD.
  207. *
  208. * @param pLCNConflictList[out] pointer to regional variants List.
  209. *
  210. * @return DB_SUCCESS if succeed, error code otherwise.
  211. */
  212. EDBError_t LCN_QueryRiksRegionalVariant(PDBLCNRiksVariantInfo_t pLCNConflictList);
  213. /**
  214. * @brief process regional variant for Riks TRD.
  215. *
  216. * @param pLCNConflictList[in] pointer to regional variants List.
  217. *
  218. * @param usFavNID[in] Faverite region.
  219. *
  220. * @return DB_SUCCESS if succeed, error code otherwise.
  221. */
  222. EDBError_t LCN_ProcRiksRegionalVariant(PDBLCNRiksVariantInfo_t pLCNConflictList, UINT16 usFavNID);
  223. /**
  224. * @brief Auto assign Number to those LCN conflict services.
  225. *
  226. * @return DB_SUCCESS if succeed, error code otherwise.
  227. */
  228. EDBError_t LCN_AutoAssignConflictLCN(void);
  229. /**
  230. * @brief Prejudge the LCN status for all Service.
  231. *
  232. * @return DB_SUCCESS if succeed, error code otherwise.
  233. */
  234. EDBError_t LCN_PreJudgeLCN(void);
  235. /**
  236. * @brief Post judge the LCN status for all Service.
  237. *
  238. * @return DB_SUCCESS if succeed, error code otherwise.
  239. */
  240. EDBError_t LCN_PostJudgeLCN(void);
  241. /**
  242. * @brief update LCN for specify service.
  243. *
  244. * @param hServIter service handle.
  245. * @param usNewLCN New LCN Number.
  246. * @param bForce Force update to the New LCN Number if true.
  247. *
  248. * @return DB_SUCCESS if succeed, error code otherwise.
  249. */
  250. EDBError_t LCN_UpdateLCN(CDBIHandle_t hServ, UINT16 usNewLCN, bool bForce);
  251. /**
  252. * @brief Process LCN conflict by TRD(Target region descriptor).
  253. *
  254. * @param u8RegionDepth region depth
  255. * @param u8PrimaryCode primary code
  256. * @param u8SecondayCode seconday code
  257. * @param u16TertiaryCode tertiary code
  258. * @note please refer to 300468 about the TRD
  259. * @return DB_SUCCESS if succeed, error code otherwise.
  260. */
  261. EDBError_t LCN_AssignConflictLCNByTRD(UINT8 u8RegionDepth, UINT8 u8PrimaryCode,
  262. UINT8 u8SecondayCode, UINT16 u16TertiaryCode);
  263. /**
  264. * @brief just create a Target Ragion Dictionary, user can get TargetRagionName with the given region index entry.
  265. *
  266. * @param pstTRND The pointer to the TRND(Target Region Name Desriptor).
  267. * @param ui32TRNDLenThe length of TRND
  268. * @return DB_SUCCESS if succeed, error code otherwise.
  269. */
  270. EDBError_t LCN_AddTRNDToDictionary(void *pstTRND, UINT32 ui32TRNDLen);
  271. /**
  272. * @brief Get TRND Dictionary.
  273. *
  274. * @param pTRDDictionary[out] The pointer to the TRND(Target Region Name Desriptor).
  275. * @return DB_SUCCESS if succeed, error code otherwise.
  276. */
  277. EDBError_t LCN_GetTRNDDictionary(PDBTRNDDictionary_t *pTRDDictionary);
  278. /**
  279. * @brief Free TRND Dictionary.
  280. *
  281. * @return DB_SUCCESS if succeed, error code otherwise.
  282. */
  283. EDBError_t LCN_FreeTRNDDictionary(void);
  284. EDBError_t LCN_MultiChnList_SetIdName( UINT32 usChnListID, UINT8 *pChnListName, UINT8 uiLen, UINT8 *puiIdx );
  285. EDBError_t LCN_MultiChnList_SetLCN( UINT32 uiUsrData, PDBSingChnLCN_t pLCN, UINT8 uiIdx );
  286. EDBError_t LCN_MultiChnList_SetLCNExt(PDBDVBLocator_t pLocator, PDBSingChnLCN_t pLCN, UINT8 uiIdx );
  287. UINT8 LCN_MultiChnList_GetValidCnt( void );
  288. EDBError_t LCN_MultiChnList_GetInfo( PDBMultiChnListInfo *pMultiLCNInfo );
  289. EDBError_t LCN_MultiChnList_GetNextServLCNByChnListID(UINT32 usIdx, PDBDVBLocator_t pLocator, PDBSingChnLCN_t pLCNInfo);
  290. EDBError_t LCN_FreeMultiChnListInfo(void);
  291. bool LCN_QueryLCNAllocate( UINT16 usProgNum, EServiceType_t eTvRadioType );
  292. UINT16 LCN_QueryValidRange();
  293. bool LCN_QueryListSeparate();
  294. #ifdef __cplusplus
  295. }
  296. #endif
  297. #endif