raontv.h 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235
  1. /******************************************************************************
  2. * (c) COPYRIGHT 2013 RAONTECH, Inc. ALL RIGHTS RESERVED.
  3. *
  4. * TITLE : RAONTECH TV device driver API header file.
  5. *
  6. * FILENAME : raontv.h
  7. *
  8. * DESCRIPTION:
  9. * This file contains types and declarations associated with the RAONTECH
  10. * TV Services.
  11. *
  12. ******************************************************************************/
  13. /******************************************************************************
  14. * REVISION HISTORY
  15. *
  16. * DATE NAME REMARKS
  17. * ---------- ------------- ------------------------------------------------
  18. * 07/26/2013 Yang, Maverick Created.
  19. ******************************************************************************/
  20. #ifndef __RAONTV_H__
  21. #define __RAONTV_H__
  22. #ifdef __cplusplus
  23. extern "C"{
  24. #endif
  25. #include "raontv_port.h"
  26. #define RAONTV_CHIP_ID 0x8A
  27. #define MTV222_SPI_CMD_SIZE 3
  28. /*==============================================================================
  29. *
  30. * Common definitions and types.
  31. *
  32. *============================================================================*/
  33. #ifndef NULL
  34. #define NULL 0
  35. #endif
  36. #ifndef FALSE
  37. #define FALSE 0
  38. #endif
  39. #ifndef TRUE
  40. #define TRUE 1
  41. #endif
  42. #ifndef MAX
  43. #define MAX(a, b) (((a) > (b)) ? (a) : (b))
  44. #endif
  45. #ifndef MIN
  46. #define MIN(a, b) (((a) < (b)) ? (a) : (b))
  47. #endif
  48. #ifndef ABS
  49. #define ABS(x) (((x) < 0) ? -(x) : (x))
  50. #endif
  51. #define RTV_TS_PACKET_SIZE 188
  52. /* Error codes. */
  53. #define RTV_SUCCESS 0
  54. #define RTV_INVAILD_COUNTRY_BAND -1
  55. #define RTV_UNSUPPORT_ADC_CLK -2
  56. #define RTV_INVAILD_TV_MODE -3
  57. #define RTV_CHANNEL_NOT_DETECTED -4
  58. #define RTV_INSUFFICIENT_CHANNEL_BUF -5
  59. #define RTV_INVAILD_FREQ -6
  60. #define RTV_INVAILD_SUB_CHANNEL_ID -7 // for T-DMB and DAB
  61. #define RTV_NO_MORE_SUB_CHANNEL -8 // for T-DMB and DAB
  62. #define RTV_ALREADY_OPENED_SUB_CHANNEL_ID -9 // for T-DMB and DAB
  63. #define RTV_NOT_OPENED_SUB_CHANNEL_ID -10 // for T-DMB and DAB
  64. #define RTV_INVAILD_THRESHOLD_SIZE -11
  65. #define RTV_POWER_ON_CHECK_ERROR -12
  66. #define RTV_PLL_UNLOCKED -13
  67. #define RTV_ADC_CLK_UNLOCKED -14
  68. typedef enum
  69. {
  70. RTV_COUNTRY_BAND_JAPAN = 0,
  71. RTV_COUNTRY_BAND_KOREA,
  72. RTV_COUNTRY_BAND_BRAZIL,
  73. RTV_COUNTRY_BAND_ARGENTINA
  74. } E_RTV_COUNTRY_BAND_TYPE;
  75. // Do not modify the order!
  76. typedef enum
  77. {
  78. RTV_ADC_CLK_FREQ_8_MHz = 0,
  79. RTV_ADC_CLK_FREQ_8_192_MHz,
  80. RTV_ADC_CLK_FREQ_9_MHz,
  81. RTV_ADC_CLK_FREQ_9_6_MHz,
  82. MAX_NUM_RTV_ADC_CLK_FREQ_TYPE
  83. } E_RTV_ADC_CLK_FREQ_TYPE;
  84. // Modulation
  85. typedef enum
  86. {
  87. RTV_MOD_DQPSK = 0,
  88. RTV_MOD_QPSK,
  89. RTV_MOD_16QAM,
  90. RTV_MOD_64QAM
  91. } E_RTV_MODULATION_TYPE;
  92. typedef enum
  93. {
  94. RTV_CODE_RATE_1_2 = 0,
  95. RTV_CODE_RATE_2_3,
  96. RTV_CODE_RATE_3_4,
  97. RTV_CODE_RATE_5_6,
  98. RTV_CODE_RATE_7_8
  99. } E_RTV_CODE_RATE_TYPE;
  100. enum E_RTV_SERVICE_TYPE {
  101. RTV_SERVICE_INVALID = -1,
  102. RTV_SERVICE_UHF_ISDBT_1seg = 0, /* ISDB-T 1seg */
  103. MAX_NUM_RTV_SERVICE
  104. };
  105. enum E_RTV_BANDWIDTH_TYPE {
  106. RTV_BW_MODE_430KHZ = 0, //1SEG at 6MHz BW
  107. RTV_BW_MODE_500KHZ, //1SEG at 7MHz BW
  108. RTV_BW_MODE_571KHZ, //1SEG at 8MHz BW
  109. MAX_NUM_RTV_BW_MODE_TYPE
  110. };
  111. /*==============================================================================
  112. *
  113. * ISDB-T definitions, types and APIs.
  114. *
  115. *============================================================================*/
  116. static INLINE UINT RTV_ISDBT_FREQ2CHNUM(E_RTV_COUNTRY_BAND_TYPE eRtvCountryBandType, U32 dwFreqKHz)
  117. {
  118. switch (eRtvCountryBandType) {
  119. case RTV_COUNTRY_BAND_JAPAN:
  120. return ((dwFreqKHz - 395143) / 6000);
  121. case RTV_COUNTRY_BAND_BRAZIL:
  122. case RTV_COUNTRY_BAND_ARGENTINA:
  123. return (((dwFreqKHz - 395143) / 6000) + 1);
  124. default:
  125. return 0xFFFF;
  126. }
  127. }
  128. #define RTV_ISDBT_OFDM_LOCK_MASK 0x1
  129. #define RTV_ISDBT_TMCC_LOCK_MASK 0x2
  130. #define RTV_ISDBT_CHANNEL_LOCK_OK (RTV_ISDBT_OFDM_LOCK_MASK|RTV_ISDBT_TMCC_LOCK_MASK)
  131. #define RTV_ISDBT_BER_DIVIDER 100000
  132. #define RTV_ISDBT_CNR_DIVIDER 1000
  133. #define RTV_ISDBT_RSSI_DIVIDER 10
  134. typedef enum
  135. {
  136. RTV_ISDBT_SEG_1 = 0,
  137. RTV_ISDBT_SEG_3
  138. } E_RTV_ISDBT_SEG_TYPE;
  139. typedef enum
  140. {
  141. RTV_ISDBT_MODE_1 = 0, // 2048
  142. RTV_ISDBT_MODE_2, // 4096
  143. RTV_ISDBT_MODE_3 // 8192 fft
  144. } E_RTV_ISDBT_MODE_TYPE;
  145. typedef enum
  146. {
  147. RTV_ISDBT_GUARD_1_32 = 0, /* 1/32 */
  148. RTV_ISDBT_GUARD_1_16, /* 1/16 */
  149. RTV_ISDBT_GUARD_1_8, /* 1/8 */
  150. RTV_ISDBT_GUARD_1_4 /* 1/4 */
  151. } E_RTV_ISDBT_GUARD_TYPE;
  152. typedef enum
  153. {
  154. RTV_ISDBT_INTERLV_0 = 0,
  155. RTV_ISDBT_INTERLV_1,
  156. RTV_ISDBT_INTERLV_2,
  157. RTV_ISDBT_INTERLV_4,
  158. RTV_ISDBT_INTERLV_8,
  159. RTV_ISDBT_INTERLV_16,
  160. RTV_ISDBT_INTERLV_32
  161. } E_RTV_ISDBT_INTERLV_TYPE;
  162. // for Layer A.
  163. typedef struct
  164. {
  165. E_RTV_ISDBT_SEG_TYPE eSeg;
  166. E_RTV_ISDBT_MODE_TYPE eTvMode;
  167. E_RTV_ISDBT_GUARD_TYPE eGuard;
  168. E_RTV_MODULATION_TYPE eModulation;
  169. E_RTV_CODE_RATE_TYPE eCodeRate;
  170. E_RTV_ISDBT_INTERLV_TYPE eInterlv;
  171. int fEWS;
  172. } RTV_ISDBT_TMCC_INFO;
  173. void rtvISDBT_StandbyMode(int on);
  174. UINT rtvISDBT_GetLockStatus(void);
  175. U8 rtvISDBT_GetAGC(void);
  176. S32 rtvISDBT_GetRSSI(void);
  177. U32 rtvISDBT_GetPER(void);
  178. U32 rtvISDBT_GetCNR(void);
  179. U32 rtvISDBT_GetBER(void);
  180. UINT rtvISDBT_GetAntennaLevel(U32 dwCNR);
  181. void rtvISDBT_GetTMCC(RTV_ISDBT_TMCC_INFO *ptTmccInfo);
  182. void rtvISDBT_DisableStreamOut(void);
  183. void rtvISDBT_EnableStreamOut(void);
  184. INT rtvISDBT_SetFrequency(UINT nChNum);
  185. INT rtvISDBT_ScanFrequency(UINT nChNum);
  186. void rtvISDBT_SwReset(void);
  187. INT rtvISDBT_Initialize(E_RTV_COUNTRY_BAND_TYPE eRtvCountryBandType, UINT nThresholdSize);
  188. #ifdef __cplusplus
  189. }
  190. #endif
  191. #endif /* __RAONTV_H__ */