al_channel_search.h 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522
  1. /**
  2. * Copyright(c) 2011 Sunmedia Technologies - All Rights Reserved.
  3. *
  4. * @file al_channel_search.h
  5. *
  6. * @brief Channel search function framework implement
  7. *
  8. */
  9. #ifndef __AL_CHANNEL_SEARCH_H__
  10. #define __AL_CHANNEL_SEARCH_H__
  11. /**<header files*/
  12. #include "al_basictypes.h"
  13. #include "al_area_info.h"
  14. #include "al_database.h"
  15. #ifdef CONFIG_DTV_SUPPORT
  16. #include "mid_dtv_scan.h"
  17. #endif
  18. #ifdef CONFIG_ATV_SUPPORT
  19. #include "mid_atv_scan.h"
  20. #endif
  21. /**<Macro define*/
  22. #define AL_CS_SUPPORT_GET_FREQ_FROM_NIT (1 << 0)
  23. #define AL_CS_FILTER_SCRAMBLE_SERVICE (1 << 1)
  24. #define AL_CS_SUPPORT_STEP_BLIND_SCAN (1 << 2)
  25. #define AL_CS_SUPPORT_BLIND_SCAN_METHOD_1 (1 << 3)
  26. #define AL_CS_SUPPORT_BLIND_SCAN_METHOD_2 (1 << 4)
  27. #define AL_CS_SUPPORT_BLIND_SCAN_METHOD_3 (1 << 5)
  28. #define AL_CS_SUPPORT_NIT_FREQ_LIST_SCAN (1 << 6)
  29. #define AL_CS_SUPPORT_DVB_T2_IMMEDIATE_MODE (1 << 7)
  30. #define AL_CS_SUPPORT_DVB_T2_DELAY_MODE (1 << 8)
  31. #define AL_CS_SUPPORT_SELECT_TP_SCAN_MODE (1 << 9) //for dvb-s/s2
  32. #ifdef CONFIG_SUPPORT_FAST_SCANNING
  33. #define AL_CS_SUPPORT_M7_FAST_SCAN (1 << 10) //for dvb-s/s2
  34. #endif
  35. #define AL_CS_SET_SERVICE_COUNT(ser_type, tv, radio, data) do { \
  36. if (ser_type == AL_RECTYPE_DVBTV) \
  37. { \
  38. tv++; \
  39. } \
  40. else if (ser_type == AL_RECTYPE_DVBRADIO) \
  41. { \
  42. radio++;\
  43. } \
  44. else if (ser_type == AL_RECTYPE_DVBDATA) \
  45. { \
  46. data++; \
  47. } \
  48. } while(0);
  49. /**<Type define*/
  50. /**
  51. * @brief dvb-s/s2 scan sequence type define.
  52. */
  53. typedef enum
  54. {
  55. AL_CS_DVBSX_S_TO_S2 = 0,
  56. AL_CS_DVBSX_S2_TO_S = 1,
  57. AL_CS_DVBSX_ONLY_S = 2,
  58. AL_CS_DVBSX_ONLY_S2 = 3,
  59. AL_CS_DVBSX_INVALID,
  60. }DVBSX_ScanSequenceMode_e;
  61. #define DVBSX_SCAN_SEQUENCE_MODE AL_CS_DVBSX_S_TO_S2
  62. /**
  63. * @brief channel search type define.
  64. */
  65. typedef enum
  66. {
  67. AL_CS_TYPE_MIN = -1,
  68. AL_CS_TYPE_ANALOG, /**< analog auto search */
  69. AL_CS_TYPE_ANALOG_MANUAL, /**< analog manual search */
  70. AL_CS_TYPE_DIGITAL, /**< digital auto search or istallation */
  71. AL_CS_TYPE_DIGITAL_MANUAL, /**< digital manual search */
  72. AL_CS_TYPE_DIGITAL_BLIND, /**< dvbs digital blind search */
  73. #ifdef CONFIG_SUPPORT_FAST_SCANNING
  74. AL_CS_TYPE_DIGITAL_M7_FAST, /**< dvbs digital M7 Fast scan */
  75. #endif
  76. AL_CS_TYPE_ACI, /**< auto channel installation */
  77. AL_CS_TYPE_ANALOG_TABLE,
  78. AL_CS_TYPE_MAX
  79. } al_cs_type_en;
  80. /**
  81. * @brief channel search notify uplayer message type.
  82. */
  83. typedef enum
  84. {
  85. AL_CS_MSG_TYPE_NONE = 0,
  86. AL_CS_MSG_TYPE_NEW_BAND, /**< blind scan next band */
  87. AL_CS_MSG_TYPE_NEW_CH, /**< Lock next channel */
  88. AL_CS_MSG_TYPE_LOCK_CH, /**< Current channel locked */
  89. AL_CS_MSG_TYPE_FINISHED, /**< Channel search finished */
  90. CS_MSG_TYPE_ABORT ,
  91. CS_MSG_TYPE_PAUSE,
  92. CS_MSG_TYPE_RESUME,
  93. } al_cs_msg_type_en;
  94. /**
  95. * @brief tuner type define.
  96. */
  97. typedef enum
  98. {
  99. AL_CS_TUNER_QPSK = 0, /**< QPSK type */
  100. AL_CS_TUNER_QAM, /**< QAM type, for DVB_C */
  101. AL_CS_TUNER_OFDM, /**< OFDM type, for DVB_T */
  102. AL_CS_TUNER_TDS_OFDM, /**< TDS_OFDM type, for DVB_T */
  103. AL_CS_TUNER_BST_OFDM, /**< BST_OFDM type, for SBTVD */
  104. AL_CS_TUNER_MAX
  105. } al_tuner_type_en;
  106. /**
  107. * @brief DVB_C modulation type.
  108. */
  109. typedef enum
  110. {
  111. AL_QAM_AUTO = 0,
  112. AL_QAM_16,
  113. AL_QAM_32,
  114. AL_QAM_64,
  115. AL_QAM_128,
  116. AL_QAM_256,
  117. AL_QAM_MAX
  118. } al_qam_modulation_en;
  119. /**
  120. * @brief DVB_C Search Mode type.
  121. */
  122. typedef enum
  123. {
  124. AL_DVBC_SEARCHMODE_FULL = 0,
  125. AL_DVBC_SEARCHMODE_FULL_NETWORK,
  126. AL_DVBC_SEARCHMODE_QUICK,
  127. AL_DVBC_SEARCHMODE_QUICK_NETWORK,
  128. AL_DVBC_SEARCHMODE_MAX
  129. } al_DVBC_SearchMode_en;
  130. /**
  131. * @brief DVB_C Operator type.
  132. */
  133. typedef enum
  134. {
  135. AL_DVBC_OPERATOR_AUTO = 0,
  136. AL_DVBC_OPERATOR_YOU_SEE,
  137. AL_DVBC_OPERATOR_UNITY_MEDIA,
  138. AL_DVBC_OPERATOR_KDG,
  139. AL_DVBC_OPERATOR_KBW,
  140. AL_DVBC_OPERATOR_COMHEM,
  141. AL_DVBC_OPERATOR_ZIGGO,
  142. AL_DVBC_OPERATOR_TELIA_STOFA,
  143. AL_DVBC_OPERATOR_MAX
  144. } al_DVBC_Operator_en;
  145. /**
  146. * @brief DVB_S ploarity type.
  147. */
  148. typedef enum
  149. {
  150. VERTICAL = 0,
  151. HORIZONTAL,
  152. BOTH_H_V,
  153. POLAR_MAX,
  154. } al_polarity_en;
  155. /**
  156. * @brief DVB_S service type.
  157. */
  158. typedef enum
  159. {
  160. ALL_SER = 0,
  161. FREE_SER,
  162. SER_MAX,
  163. } al_service_type_en;
  164. /**
  165. * @brief DVB_S channel type.
  166. */
  167. typedef enum
  168. {
  169. ALL_CHN = 0,
  170. TV_ONLY,
  171. CHAN_MAX,
  172. } al_channel_type_en;
  173. /**
  174. * @brief Scan mode for DVB_T2
  175. */
  176. typedef enum
  177. {
  178. AL_SCAN_DVB_T_T2_DEFAULT_MODE = (0),//default
  179. AL_SCAN_DVB_T2_NOT_SUPPORT = (1<<0), //not support dvb-t2
  180. AL_SCAN_ONLY_DVBT = (1<<1), //current scanning dvb-t
  181. AL_SCAN_ONLY_DVBT2 = (1<<2), //current scanning dvb-t2
  182. AL_SCAN_DVB_T_T2_TOGETHER_MODE = (1<<3),
  183. AL_SCAN_TOGETHER_DVBT = (1<<4), //current scanning dvb-t(scan dvb-t/t2 same time)
  184. AL_SCAN_TOGETHER_DVBT2 = (1<<5), //current scanning dvb-t2(scan dvb-t/t2 same time)
  185. AL_SCAN_DVB_T_T2_SEPARATE_MODE = (1<<6),
  186. AL_SCAN_SEPARATE_DVBT = (1<<7), //current scanning dvb-t(scan dvb-t/t2 separate time)
  187. AL_SCAN_SEPARATE_DVBT2 = (1<<8), //current scanning dvb-t2(scan dvb-t/t2 separate time)
  188. AL_SCAN_INVALID = (1<<9), //INVALID
  189. } AL_ScanDVB_T2_mode_t;
  190. #ifdef CONFIG_ATV_SUPPORT
  191. /**
  192. * @brief video format supported.
  193. */
  194. typedef enum
  195. {
  196. AL_ANALOG_SCAN_VIDEO_FORMAT_AUTO = ANA_SCAN_VIDEO_FORMAT_AUTO,
  197. AL_ANALOG_SCAN_VIDEO_FORMAT_NTSC358 = ANA_SCAN_VIDEO_FORMAT_NTSC358,
  198. AL_ANALOG_SCAN_VIDEO_FORMAT_NTSC443 = ANA_SCAN_VIDEO_FORMAT_NTSC443,
  199. AL_ANALOG_SCAN_VIDEO_FORMAT_PAL = ANA_SCAN_VIDEO_FORMAT_PAL,
  200. AL_ANALOG_SCAN_VIDEO_FORMAT_PALM = ANA_SCAN_VIDEO_FORMAT_PALM,
  201. AL_ANALOG_SCAN_VIDEO_FORMAT_PALCN = ANA_SCAN_VIDEO_FORMAT_PALCN,
  202. AL_ANALOG_SCAN_VIDEO_FORMAT_PAL60 = ANA_SCAN_VIDEO_FORMAT_PAL60,
  203. AL_ANALOG_SCAN_VIDEO_FORMAT_SECAM = ANA_SCAN_VIDEO_FORMAT_SECAM,
  204. AL_ANALOG_SCAN_VIDEO_FORMAT_SECAML = ANA_SCAN_VIDEO_FORMAT_SECAML,
  205. } AL_ScanVideoFormat_t;
  206. /**
  207. * @brief audio format supported.
  208. */
  209. typedef enum
  210. {
  211. AL_ANALOG_SCAN_AUDIO_STD_NULL = 0 ,
  212. AL_ANALOG_SCAN_AUDIO_STD_M = (1 << 0),
  213. AL_ANALOG_SCAN_AUDIO_STD_BG = (1 << 1),
  214. AL_ANALOG_SCAN_AUDIO_STD_DK = (1 << 2),
  215. AL_ANALOG_SCAN_AUDIO_STD_I = (1 << 3),
  216. AL_ANALOG_SCAN_AUDIO_STD_L = (1 << 4),
  217. AL_ANALOG_SCAN_AUDIO_STD_L1 = (1 << 5),
  218. } AL_ScanAudioStd_t;
  219. #endif
  220. /**
  221. * @brief channel search input parameter strunction define.
  222. */
  223. typedef struct
  224. {
  225. al_cs_type_en enCsType; /**< Channel search type */
  226. al_uint32 uiStartFreq; /**< Start frequency */
  227. al_uint32 uiCurrentFreq; /**< current frequency for ATV */
  228. al_uint32 uiEndFreq; /**< End frequency */
  229. AL_BandWidth_Info_st stBandwidth; /**< Band width */
  230. union
  231. {
  232. #ifdef CONFIG_ATV_SUPPORT
  233. struct
  234. {
  235. al_uint32 uiDirection; /**< Direction type for analog */
  236. al_uint32 uiScanCnt;
  237. al_uint32 *puiScanTable;
  238. al_uint8 ucAreaIdx; /*ATV area*/
  239. al_uint8 ucBlueScreen; /*Blue Screen*/
  240. AL_ScanVideoFormat_t VideoFormat;
  241. AL_ScanAudioStd_t AudioStd;
  242. al_uint32 Manual_Num;
  243. bool Manual_Scan;
  244. } atv;
  245. #endif
  246. #ifdef CONFIG_DTV_SUPPORT
  247. struct
  248. {
  249. struct
  250. {
  251. al_uint32 uiSymRate; /**< sym rate for dvb_c */
  252. al_uint32 network_id; /**< network id */
  253. al_qam_modulation_en enModulation; /**< modulation type for dvb_c */
  254. al_DVBC_SearchMode_en uiDVBCSearchMode; /**< Search mode for dvb_c */
  255. al_uint8 uiNetworkIdAutoEn; /**< User set network id is auto or not for dvb_c */
  256. al_uint8 uiFreqAutoEn; /**< User set freq is auto or not for dvb_c */
  257. al_uint32 uiNetworkScanFreq; /**< User set freq to start when network id search for dvb_c */
  258. } qam_info;
  259. struct
  260. {
  261. al_uint8 u8FreqStep;
  262. al_uint8 u8Polarization;
  263. al_uint32 uiSymRate; /**< sym rate for dvb_s */
  264. AL_RecHandle_t hNet; /**< satellite handle */
  265. al_uint32 uiFeType; /**< fe type: DVBSX_ScanSequenceMode_e */
  266. } qpsk_info;
  267. struct
  268. {
  269. al_uint32 FreqlistHdl; /**< Freq list handle derived from frequency_list_descriptor */
  270. AL_ScanDVB_T2_mode_t dvbt2mode; /** <for DVB-T2 mode */
  271. } ofdm_info;
  272. const void* pstScanTable; /**< current default area table for dtv*/
  273. al_tuner_type_en enTunerType; /**< tuner type for dtv, TUNER_QPSK/TUNER_QAM/TUNER_OFDM*/
  274. al_uint8 ucAreaIdx; /**< area index for dtv*/
  275. AL_ScanDVB_T2_mode_t dvbt2mode; /** <for DVB-T2 mode */
  276. #ifdef CONFIG_SUPPORT_FAST_SCANNING
  277. al_uint16 uiM7FstPid;
  278. al_bool bM7CheckVersion;
  279. #endif
  280. } dtv;
  281. #endif
  282. } u;
  283. al_uint32 uiCapabilities; /**< Capabilities select*/
  284. } al_cs_input_params_st;
  285. /**
  286. * @brief atv channel search infomation.
  287. */
  288. typedef struct
  289. {
  290. al_uint16 usCurChaInx; /**< current search channel index */
  291. al_uint16 usCurChaCnt; /**< current channel number have be connected */
  292. } al_cs_atv_info_st;
  293. /**
  294. * @brief dtv channel search infomation.
  295. */
  296. typedef struct
  297. {
  298. al_uint8 ucTotalBand; /**< total band number at DTV */
  299. al_uint8 ucCurBand; /**< current band number at DTV */
  300. al_uint16 usRadioCnt; /**< current radio number at DTV */
  301. al_uint16 usDataServCnt; /**< current data service number have searched at DTV */
  302. al_uint16 usTotalTpNum; /**< total TP number at current DTV area table */
  303. al_uint16 usCurTpCnt; /**< current TP number have searched at DTV */
  304. al_uint32 uiProgress; /**< current band process at DTV */
  305. } al_cs_dtv_info_st;
  306. /**
  307. * @brief channel search infomation.
  308. */
  309. typedef struct
  310. {
  311. al_uint32 uiCurFreq; /**< current frequency */
  312. al_uint32 uiCurBandwidth; /**< current bandwidth */
  313. al_uint16 usTVCnt; /**< total channel number should be connected at ATV or total TV number have be connected at DTV */
  314. union
  315. {
  316. al_cs_atv_info_st atv; /**< atv channel search infomation */
  317. al_cs_dtv_info_st dtv; /**< dtv channel search infomation */
  318. } u;
  319. } al_cs_search_info_st;
  320. /**
  321. * @brief Call back function prototype for uplayer to register.
  322. */
  323. typedef AL_Return_t (*al_cs_search_save_st)(const void* pstCurScanInfo, const void* pstChannelInfo, void* pstCurScanResult);
  324. typedef AL_Return_t (*al_cs_search_over_st)(void);
  325. typedef AL_Return_t (*al_cs_search_start_st)(void);
  326. typedef AL_Return_t (*al_cs_search_update_st)(al_cs_msg_type_en, const al_cs_search_info_st*);
  327. typedef al_DVBC_Operator_en (*al_cs_search_query_operator)(void);
  328. #ifdef CONFIG_DVB_SYSTEM_DVBS_SUPPORT
  329. al_int32 AL_CS_DTV_GetStartEndFreq(AL_RecHandle_t hNet, al_uint16 usLNBFreq, al_uint32 *puiStartFreq, al_uint32 *puiEndFreq);
  330. al_uint32 AL_CS_DVBSX_InitScanFEType(al_uint32 fe_type);
  331. #endif
  332. /**
  333. * @brief Start the channel search function.
  334. *
  335. * @param input_params[input] the start params of channel search function.
  336. *
  337. * @param search_start[input] Initilize callback function called.
  338. *
  339. * @param search_over[input] Uninitilize callback function.
  340. *
  341. * @param search_update[input] Update callback function used to update UI display.
  342. *
  343. * @param search_save[input] save program into database function.
  344. *
  345. * @return AL_SUCCESS start channel search is successful, AL_FAILURE otherwise.
  346. */
  347. AL_Return_t AL_CS_Start(al_cs_input_params_st* input_params,
  348. al_cs_search_start_st search_start,
  349. al_cs_search_over_st search_over,
  350. al_cs_search_update_st search_update,
  351. al_cs_search_save_st search_save);
  352. /**
  353. * @brief Set the search direction mainly used in ATV.
  354. *
  355. * @param direction[input] zero for positive, or other for negative.
  356. *
  357. * @return AL_SUCCESS set search direction is successful, AL_FAILURE otherwise.
  358. */
  359. AL_Return_t AL_CS_SetSearchDirection(al_int32 direction);
  360. /**
  361. * @brief Send message to stop the channel search flow.
  362. *
  363. * @return AL_SUCCESS stop channel search is successful, AL_FAILURE otherwise.
  364. */
  365. AL_Return_t AL_CS_Stop(void);
  366. /**
  367. * @brief Send message to pause the search flow.
  368. *
  369. * @return AL_SUCCESS channel search pause is success, AL_FAILURE otherwise.
  370. */
  371. AL_Return_t AL_CS_Pause(void);
  372. /**
  373. * @brief Send message to resume the search flow.
  374. *
  375. * @return AL_SUCCESS channel search resume is success, AL_FAILURE otherwise.
  376. */
  377. AL_Return_t AL_CS_Resume(void);
  378. /**
  379. * @brief Is the channel search module stop or not.
  380. *
  381. * @return al_true channel search is stoped, al_false channel search is not stoped.
  382. */
  383. al_bool AL_CS_IsStop(void);
  384. al_bool AL_CS_IsStopFinish(void);
  385. al_uint16 AL_CS_AtvCurIdx(void);
  386. #ifdef CONFIG_SUPPORT_ATV_SCAN_NTSCM_PALM_N
  387. al_bool AL_CS_UpdateParam(al_cs_input_params_st* input_params,al_uint32 i);
  388. #endif
  389. #ifdef CONFIG_DTV_SUPPORT
  390. /*****************************************************************************
  391. ** FUNCTION : AL_CS_DtvMinBW
  392. **
  393. ** DESCRIPTION : Get BW of special area
  394. **
  395. **
  396. ** PARAMETERS :
  397. ** stBW - BW struct
  398. ** pbBW - BW
  399. **
  400. ** RETURN VALUES:
  401. ** AL_FAILURE - operation failure
  402. ** AL_SUCCESS - operation success
  403. *****************************************************************************/
  404. AL_Return_t AL_CS_DtvMinBW(AL_BandWidth_Info_st stBW, UINT8 *pbBW);
  405. /*****************************************************************************
  406. ** FUNCTION : AL_CS_DtvMaxBW
  407. **
  408. ** DESCRIPTION : Get BW of special area
  409. **
  410. **
  411. ** PARAMETERS :
  412. ** stBW - BW struct
  413. ** pbBW - BW
  414. **
  415. ** RETURN VALUES:
  416. ** AL_FAILURE - operation failure
  417. ** AL_SUCCESS - operation success
  418. *****************************************************************************/
  419. AL_Return_t AL_CS_DtvMaxBW(AL_BandWidth_Info_st stBW, UINT8 *pbBW);
  420. /*****************************************************************************
  421. ** FUNCTION : AL_CS_DtvNextBW
  422. **
  423. ** DESCRIPTION : Get BW of special area
  424. **
  425. **
  426. ** PARAMETERS :
  427. ** stBW - BW struct
  428. ** pbBW - BW
  429. ** bDirect - search direct
  430. **
  431. ** RETURN VALUES:
  432. ** AL_FAILURE - operation failure
  433. ** AL_SUCCESS - operation success
  434. *****************************************************************************/
  435. AL_Return_t AL_CS_DtvNextBW(AL_BandWidth_Info_st stBW, UINT8 *pbBW, INT8 bDirect);
  436. /*****************************************************************************
  437. ** FUNCTION : AL_CS_DtvSetSpecialSpec
  438. **
  439. ** DESCRIPTION : set special spec
  440. **
  441. **
  442. ** PARAMETERS :
  443. ** ePriSpec - DVB private special spec
  444. **
  445. ** RETURN VALUES:
  446. ** AL_FAILURE - operation failure
  447. ** AL_SUCCESS - operation success
  448. *****************************************************************************/
  449. AL_Return_t AL_CS_DtvSetSpecialSpec(AL_DBPrivateSpec_t ePriSpec);
  450. #endif
  451. #ifdef SUPPORT_LCN
  452. DBLCNConfInfo_t* AL_LCN_GetLCNConfChannel(al_void);
  453. bool AL_LCN_ProcessAndJudgeWhetherPopToUser(AL_DB_EDBType_t eNetType, al_uint8 u8Country, al_bool bForceAutoProc);
  454. #endif
  455. al_uint32 AL_CS_GetCurFreq(void);
  456. al_uint16 AL_CS_GetAtvCurChannel(void) ;
  457. al_void AL_CS_SetOperatorQueryFunc(al_cs_search_query_operator search_query_op);
  458. al_uint32 AL_CS_GetCurPolar(void);
  459. al_uint32 AL_CS_GetCurSymbolRate(void);
  460. #endif /* __AL_CHANNEL_SEARCH_H__ */
  461. /*****************************************************************************
  462. ** $Rev$
  463. **
  464. *****************************************************************************/