mtv23x_internal.h 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682
  1. /******************************************************************************
  2. * (c) COPYRIGHT 2013 RAONTECH, Inc. ALL RIGHTS RESERVED.
  3. *
  4. * TITLE : MTV23x internal header file.
  5. *
  6. * FILENAME : mtv23x_internal.h
  7. *
  8. * DESCRIPTION :
  9. * All the declarations and definitions necessary for
  10. * the MTV23x TV driver.
  11. *
  12. ******************************************************************************/
  13. /******************************************************************************
  14. * REVISION HISTORY
  15. *
  16. * DATE NAME REMARKS
  17. * ---------- ------------- ------------------------------------------------
  18. * 03/03/2013 Yang, Maverick Created.
  19. ******************************************************************************/
  20. #ifndef __MTV23X_INTERNAL_H__
  21. #define __MTV23X_INTERNAL_H__
  22. #include "mtv23x.h"
  23. #ifdef __cplusplus
  24. extern "C"{
  25. #endif
  26. #if defined(RTV_IF_SPI) || defined(RTV_IF_SPI_TSIFx) || defined(RTV_IF_EBI2)
  27. #if defined(RTV_INTR_POLARITY_LOW_ACTIVE)
  28. #define SPI_INTR_POL_ACTIVE 0x00
  29. #elif defined(RTV_INTR_POLARITY_HIGH_ACTIVE)
  30. #define SPI_INTR_POL_ACTIVE (1<<3)
  31. #endif
  32. #endif
  33. struct RTV_REG_INIT_INFO {
  34. U8 bReg;
  35. U8 bVal;
  36. };
  37. struct RTV_REG_MASK_INFO {
  38. U8 bReg;
  39. U8 bMask;
  40. U8 bVal;
  41. };
  42. struct RTV_ADC_CFG_INFO {
  43. U8 bData2A;
  44. U8 bData6E;
  45. U8 bData70;
  46. U8 bData71;
  47. U8 bData75;
  48. U32 dwTNCO;
  49. U32 dwPNCO;
  50. U32 dwCFREQGAIN;
  51. U16 dwGAIN;
  52. };
  53. #if defined(RTV_IF_TSIF_0) || defined(RTV_IF_TSIF_1)\
  54. || defined(RTV_IF_SPI_SLAVE)
  55. #if defined(RTV_TSIF_SPEED_500_kbps)
  56. #define RTV_FEC_TSIF_OUT_SPEED 7
  57. #elif defined(RTV_TSIF_SPEED_1_Mbps)
  58. #define RTV_FEC_TSIF_OUT_SPEED 6
  59. #elif defined(RTV_TSIF_SPEED_2_Mbps)
  60. #define RTV_FEC_TSIF_OUT_SPEED 5
  61. #elif defined(RTV_TSIF_SPEED_4_Mbps)
  62. #define RTV_FEC_TSIF_OUT_SPEED 4
  63. #elif defined(RTV_TSIF_SPEED_7_Mbps)
  64. #define RTV_FEC_TSIF_OUT_SPEED 3
  65. #elif defined(RTV_TSIF_SPEED_15_Mbps)
  66. #define RTV_FEC_TSIF_OUT_SPEED 2
  67. #elif defined(RTV_TSIF_SPEED_30_Mbps)
  68. #define RTV_FEC_TSIF_OUT_SPEED 1
  69. #elif defined(RTV_TSIF_SPEED_60_Mbps)
  70. #define RTV_FEC_TSIF_OUT_SPEED 0
  71. #else
  72. #error "Code not present"
  73. #endif
  74. #endif
  75. #if defined(RTV_IF_SPI) || defined(RTV_IF_EBI2)
  76. #if (RTV_SRC_CLK_FREQ_KHz == 4000)
  77. #define RTV_SPI_INTR_DEACT_PRD_VAL 0x51
  78. #elif (RTV_SRC_CLK_FREQ_KHz == 13000)
  79. #define RTV_SPI_INTR_DEACT_PRD_VAL ((6<<4)|3)
  80. #elif (RTV_SRC_CLK_FREQ_KHz == 16000)
  81. #define RTV_SPI_INTR_DEACT_PRD_VAL ((6<<4)|3)
  82. #elif (RTV_SRC_CLK_FREQ_KHz == 16384)
  83. #define RTV_SPI_INTR_DEACT_PRD_VAL ((6<<4)|3)
  84. #elif (RTV_SRC_CLK_FREQ_KHz == 18000)
  85. #define RTV_SPI_INTR_DEACT_PRD_VAL ((6<<4)|3)
  86. #elif (RTV_SRC_CLK_FREQ_KHz == 19200) /* 1 clk: 52.08ns */
  87. #define RTV_SPI_INTR_DEACT_PRD_VAL ((6<<4)|3)
  88. #elif (RTV_SRC_CLK_FREQ_KHz == 24000)
  89. #define RTV_SPI_INTR_DEACT_PRD_VAL ((6<<4)|3)
  90. #elif (RTV_SRC_CLK_FREQ_KHz == 24576) /* 1 clk: 40.7ns */
  91. #define RTV_SPI_INTR_DEACT_PRD_VAL ((7<<4)|2)/*about 10us*/
  92. #elif (RTV_SRC_CLK_FREQ_KHz == 26000)
  93. #define RTV_SPI_INTR_DEACT_PRD_VAL ((6<<4)|3)
  94. #elif (RTV_SRC_CLK_FREQ_KHz == 27000)
  95. #define RTV_SPI_INTR_DEACT_PRD_VAL ((6<<4)|3)
  96. #elif (RTV_SRC_CLK_FREQ_KHz == 32000)
  97. #define RTV_SPI_INTR_DEACT_PRD_VAL ((7<<4)|3)
  98. #elif (RTV_SRC_CLK_FREQ_KHz == 32768)
  99. #define RTV_SPI_INTR_DEACT_PRD_VAL ((6<<4)|3)
  100. #elif (RTV_SRC_CLK_FREQ_KHz == 36000) /* 1clk: 27.7 ns */
  101. #define RTV_SPI_INTR_DEACT_PRD_VAL ((7<<4)|3)
  102. #elif (RTV_SRC_CLK_FREQ_KHz == 38400)
  103. #define RTV_SPI_INTR_DEACT_PRD_VAL ((6<<4)|3)
  104. #elif (RTV_SRC_CLK_FREQ_KHz == 40000)
  105. #define RTV_SPI_INTR_DEACT_PRD_VAL ((6<<4)|3)
  106. #elif (RTV_SRC_CLK_FREQ_KHz == 48000) /* 1clk: 20.8 ns */
  107. #define RTV_SPI_INTR_DEACT_PRD_VAL ((9<<4)|0)
  108. #else
  109. #error "Code not present"
  110. #endif
  111. #endif /* #if defined(RTV_IF_SPI) */
  112. #if (RTV_TSP_XFER_SIZE == 188)
  113. #define N_DATA_LEN_BITVAL 0x02
  114. #define ONE_DATA_LEN_BITVAL 0x00
  115. #elif (RTV_TSP_XFER_SIZE == 204)
  116. #define N_DATA_LEN_BITVAL 0x03
  117. #define ONE_DATA_LEN_BITVAL (1<<5)
  118. #endif
  119. #define SPI_OVERFLOW_INTR 0x02
  120. #define SPI_UNDERFLOW_INTR 0x20
  121. #define SPI_THRESHOLD_INTR 0x08
  122. #define SPI_INTR_BITS (SPI_THRESHOLD_INTR|SPI_UNDERFLOW_INTR|SPI_OVERFLOW_INTR)
  123. #define TOP_PAGE 0x00
  124. #define HOST_PAGE 0x00
  125. #define OFDM_PAGE 0x01
  126. #define SHAD_PAGE 0x02
  127. #define FEC_PAGE 0x03
  128. #define DATA_PAGE 0x04
  129. #define FEC2_PAGE 0x06
  130. #define LPOFDM_PAGE 0x07
  131. #define SPI_CTRL_PAGE 0x0E
  132. #define RF_PAGE 0x0F
  133. #define SPI_MEM_PAGE 0xFF /* Temp value. > 15 */
  134. #define MAP_SEL_REG 0x03
  135. #define MAP_SEL_VAL(page) (page)
  136. #if defined(RTV_IF_SPI) || defined(RTV_IF_SPI_TSIFx) || defined(RTV_IF_EBI2)
  137. #define RTV_REG_MAP_SEL(page) g_bRtvPage = page
  138. #define RTV_REG_GET_MAP_SEL g_bRtvPage
  139. #else
  140. #define RTV_REG_MAP_SEL(page) \
  141. do {\
  142. RTV_REG_SET(MAP_SEL_REG, MAP_SEL_VAL(page));\
  143. } while (0)
  144. #define RTV_REG_GET_MAP_SEL \
  145. (RTV_REG_GET(MAP_SEL_REG))
  146. #endif
  147. extern U8 g_bRtvIntrMaskReg;
  148. extern UINT g_nRtvThresholdSize;
  149. /*==============================================================================
  150. *
  151. * Common inline functions.
  152. *
  153. *============================================================================*/
  154. static INLINE void rtv_SetupInterruptThreshold(void)
  155. {
  156. #if defined(RTV_IF_SPI) || defined(RTV_IF_EBI2)
  157. RTV_REG_MAP_SEL(SPI_CTRL_PAGE);
  158. RTV_REG_SET(0x23, (g_nRtvThresholdSize/188)/4);
  159. #endif
  160. }
  161. /* Forward prototype. */
  162. static INLINE void rtv_DisableTSIF(void)
  163. {
  164. RTV_REG_MAP_SEL(FEC_PAGE);
  165. RTV_REG_SET(0xA8, 0x80);
  166. #if defined(RTV_IF_SPI) || defined(RTV_IF_EBI2)
  167. RTV_REG_SET(0xAA, 0x80);
  168. RTV_REG_MAP_SEL(SPI_CTRL_PAGE);
  169. /* Disable interrupts. */
  170. g_bRtvIntrMaskReg |= SPI_INTR_BITS;
  171. RTV_REG_SET(0x24, g_bRtvIntrMaskReg);
  172. /* To clear interrupt and data. */
  173. RTV_REG_SET(0x2A, 1);
  174. RTV_REG_SET(0x2A, 0);
  175. #else
  176. #if defined(RTV_IF_TSIF_0)
  177. RTV_REG_SET(0xAA, 0x80);
  178. #endif
  179. #if defined(RTV_IF_TSIF_1)
  180. RTV_REG_SET(0xAB, 0x80);
  181. #endif
  182. #endif
  183. }
  184. static INLINE void rtv_EnableTSIF(void)
  185. {
  186. #if defined(RTV_IF_SPI) || defined(RTV_IF_EBI2)
  187. rtv_SetupInterruptThreshold();
  188. /* To clear interrupt and data. */
  189. RTV_REG_SET(0x2A, 1);
  190. RTV_REG_SET(0x2A, 0);
  191. /* Enable SPI interrupts */
  192. g_bRtvIntrMaskReg &= ~(SPI_INTR_BITS);
  193. RTV_REG_SET(0x24, g_bRtvIntrMaskReg);
  194. RTV_REG_MAP_SEL(FEC_PAGE);
  195. RTV_REG_SET(0xA8, 0x87);
  196. RTV_REG_SET(0xAA, 0x87);
  197. #else
  198. RTV_REG_MAP_SEL(FEC_PAGE);
  199. RTV_REG_SET(0xA8, 0x87);
  200. #if defined(DUAL_PORT_TSOUT_ENABLE)
  201. RTV_REG_SET(0xAA, 0x82); /* TS0 Layer A only */
  202. RTV_REG_SET(0xAB, 0x85); /* TS1 Layer B,C only */
  203. #else
  204. #if defined(RTV_IF_TSIF_0)
  205. RTV_REG_SET(0xAA, 0x87);
  206. #endif
  207. #if defined(RTV_IF_TSIF_1)
  208. RTV_REG_SET(0xAB, 0x87);
  209. #endif
  210. #endif
  211. #endif
  212. }
  213. /* #define PRE_EXTEND_VALID_SIGNAL */
  214. #if defined(RTV_IF_TSIF_0) || defined(RTV_IF_SPI_SLAVE)
  215. static INLINE void rtv_ConfigureTsif0Format(void)
  216. {
  217. U8 REG9F;
  218. RTV_REG_MAP_SEL(FEC_PAGE);
  219. REG9F = RTV_REG_GET(0x9F) & 0xAA;
  220. #if defined(RTV_TSIF_FORMAT_0) /* EN_high, CLK_rising */
  221. RTV_REG_SET(0x9F, (REG9F | 0x00));
  222. RTV_REG_SET(0xA5, 0x08);
  223. #elif defined(RTV_TSIF_FORMAT_1) /* EN_high, CLK_falling */
  224. RTV_REG_SET(0x9F, (REG9F | 0x00));
  225. RTV_REG_SET(0xA5, 0x00);
  226. #elif defined(RTV_TSIF_FORMAT_2) /* EN_low, CLK_rising */
  227. RTV_REG_SET(0x9F, (REG9F | 0x10));
  228. RTV_REG_SET(0xA5, 0x08);
  229. #elif defined(RTV_TSIF_FORMAT_3) /* EN_low, CLK_falling */
  230. RTV_REG_SET(0x9F, (REG9F | 0x10));
  231. RTV_REG_SET(0xA5, 0x00);
  232. #elif defined(RTV_TSIF_FORMAT_4) /* EN_high, CLK_rising + 1CLK add */
  233. RTV_REG_SET(0x9F, (REG9F | 0x00));
  234. RTV_REG_SET(0xA5, 0x0C);
  235. #elif defined(RTV_TSIF_FORMAT_5) /* EN_high, CLK_falling + 1CLK add */
  236. RTV_REG_SET(0x9F, (REG9F | 0x00));
  237. RTV_REG_SET(0xA5, 0x04);
  238. #elif defined(RTV_TSIF_FORMAT_6) || defined(RTV_TSIF_FORMAT_7)
  239. #error "RTV_TSIF_FORMAT_6/7 is not suported at RTV_IF_TSIF_0 Mode"
  240. #else
  241. #error "Code not present"
  242. #endif
  243. RTV_REG_SET(0xA4, 0x89);
  244. RTV_REG_SET(0xA8, 0x87);
  245. RTV_REG_SET(0xA9, (0xB8|RTV_FEC_TSIF_OUT_SPEED));
  246. #if defined(RTV_ERROR_TSP_OUTPUT_DISABLE)
  247. RTV_REG_MASK_SET(0xA5, 0x40, 0x40);
  248. #endif
  249. #if defined(RTV_NULL_PID_TSP_OUTPUT_DISABLE)
  250. RTV_REG_MASK_SET(0xA5, 0x20, 0x20);
  251. #endif
  252. #if defined(RTV_NULL_PID_GENERATE)
  253. RTV_REG_MASK_SET(0xA4, 0x02, 0x02);
  254. #endif
  255. #if defined(RTV_IF_CSI656_RAW_8BIT_ENABLE)
  256. RTV_REG_MASK_SET(0x9F, 0x0F, 0x05); /* One clock pre-add. */
  257. RTV_REG_SET(0x9D, 0x01); /* Sync signal One pre-move. */
  258. #endif
  259. #if defined(PRE_EXTEND_VALID_SIGNAL)
  260. RTV_REG_MASK_SET(0xA5, 0x10, 0x10);
  261. #endif
  262. #if defined(DUAL_PORT_TSOUT_ENABLE)
  263. RTV_REG_SET(0xAA, 0x82); /* TS0 Layer A only */
  264. #else
  265. RTV_REG_SET(0xAA, 0x87);
  266. #endif
  267. }
  268. #endif /* #elif defined(RTV_IF_TSIF_0) || defined(RTV_IF_SPI_SLAVE) */
  269. #if defined(RTV_IF_TSIF_1) || defined(RTV_IF_SPI_SLAVE)
  270. static INLINE void rtv_ConfigureTsif1Format(void)
  271. {
  272. U8 REG9F;
  273. RTV_REG_MAP_SEL(FEC_PAGE);
  274. REG9F = RTV_REG_GET(0x9F) & 0x55;
  275. #if defined(RTV_TSIF_FORMAT_0) /* EN_high, CLK_rising */
  276. RTV_REG_SET(0x9F, (REG9F | 0x00));
  277. RTV_REG_SET(0xA6, 0x88);
  278. RTV_REG_SET(0xA7, 0x48);
  279. #elif defined(RTV_TSIF_FORMAT_1) /* EN_high, CLK_falling */
  280. RTV_REG_SET(0x9F, (REG9F | 0x00));
  281. RTV_REG_SET(0xA6, 0x88);
  282. RTV_REG_SET(0xA7, 0x40);
  283. #elif defined(RTV_TSIF_FORMAT_2) /* EN_low, CLK_rising */
  284. RTV_REG_SET(0x9F, (REG9F | 0x20));
  285. RTV_REG_SET(0xA6, 0x88);
  286. RTV_REG_SET(0xA7, 0x48);
  287. #elif defined(RTV_TSIF_FORMAT_3) /* EN_low, CLK_falling */
  288. RTV_REG_SET(0x9F, (REG9F | 0x20));
  289. RTV_REG_SET(0xA6, 0x88);
  290. RTV_REG_SET(0xA7, 0x40);
  291. #elif defined(RTV_TSIF_FORMAT_4) /* EN_high, CLK_rising + 1CLK add */
  292. RTV_REG_SET(0x9F, (REG9F | 0x00));
  293. RTV_REG_SET(0xA6, 0x88);
  294. RTV_REG_SET(0xA7, 0x4C);
  295. #elif defined(RTV_TSIF_FORMAT_5) /* EN_high, CLK_falling + 1CLK add */
  296. RTV_REG_SET(0x9F, (REG9F | 0x00));
  297. RTV_REG_SET(0xA6, 0x88);
  298. RTV_REG_SET(0xA7, 0x44);
  299. #elif defined(RTV_TSIF_FORMAT_6) /* Parallel: EN_high, CLK_rising*/
  300. #if defined(RTV_IF_SPI_SLAVE)
  301. #error "RTV_TSIF_FORMAT_6 is not suported at RTV_IF_SPI_SLAVE Mode"
  302. #else
  303. RTV_REG_SET(0x9F, (REG9F | 0x00));
  304. RTV_REG_SET(0xA6, 0x80);
  305. RTV_REG_SET(0xA7, 0x48);
  306. #endif
  307. #elif defined(RTV_TSIF_FORMAT_7) /* Parallel: EN_high, CLK_falling */
  308. #if defined(RTV_IF_SPI_SLAVE)
  309. #error "RTV_TSIF_FORMAT_7 is not suported at RTV_IF_SPI_SLAVE Mode"
  310. #else
  311. RTV_REG_SET(0x9F, (REG9F | 0x00));
  312. RTV_REG_SET(0xA6, 0x80);
  313. RTV_REG_SET(0xA7, 0x40);
  314. #endif
  315. #else
  316. #error "Code not present"
  317. #endif
  318. RTV_REG_MASK_SET(0xA4, 0x01, 0x01); /* TEI Enable */
  319. #if defined(RTV_ERROR_TSP_OUTPUT_DISABLE)
  320. RTV_REG_MASK_SET(0xA5, 0x40, 0x40);
  321. #endif
  322. #if defined(RTV_NULL_PID_TSP_OUTPUT_DISABLE)
  323. RTV_REG_MASK_SET(0xA5, 0x20, 0x20);
  324. #endif
  325. #if defined(RTV_NULL_PID_GENERATE)
  326. RTV_REG_MASK_SET(0xA4, 0x02, 0x02);
  327. #endif
  328. RTV_REG_SET(0xA8, 0x87);
  329. RTV_REG_SET(0xA9, (0xB8|RTV_FEC_TSIF_OUT_SPEED));
  330. #if defined(RTV_IF_CSI656_RAW_8BIT_ENABLE)
  331. RTV_REG_MASK_SET(0x9F, 0x0F, 0x0A); /* One clock pre-add. */
  332. #if defined(RTV_TSIF_FORMAT_6) || defined(RTV_TSIF_FORMAT_7)
  333. RTV_REG_SET(0x9E, 0x04); /* 4bit clock pre-move. */
  334. #else
  335. RTV_REG_SET(0x9E, 0x01); /* 8bit clock pre-move. */
  336. #endif
  337. #endif
  338. #if defined(PRE_EXTEND_VALID_SIGNAL)
  339. RTV_REG_MASK_SET(0xA7, 0x10, 0x10);
  340. #endif
  341. #if defined(DUAL_PORT_TSOUT_ENABLE)
  342. RTV_REG_SET(0xAB, 0x85); /* TS1 Layer B,C only */
  343. #else
  344. RTV_REG_SET(0xAB, 0x87);
  345. #endif
  346. }
  347. #endif /* #elif defined(RTV_IF_TSIF_1) || defined(RTV_IF_SPI_SLAVE) */
  348. static INLINE int rtvRF_LockCheck(U8 bCheckBlock)
  349. {
  350. INT i = 0;
  351. INT nRet = RTV_SUCCESS;
  352. U8 nLockCheck = 0;
  353. RTV_REG_MAP_SEL(RF_PAGE);
  354. switch (bCheckBlock) {
  355. case 0: /* O == RF Lock Check */
  356. for (i = 0; i < 10; i++) {
  357. nLockCheck = RTV_REG_GET(0x1B) & 0x02;
  358. if (nLockCheck)
  359. break;
  360. else
  361. RTV_DBGMSG1("[rtvRF_LockCheck]VCheck(%d)\n", i);
  362. RTV_DELAY_MS(1);
  363. }
  364. if (i == 10) {
  365. RTV_DBGMSG0("[rtvRF_LockCheck] VCO Pll unlocked!\n");
  366. nRet = RTV_PLL_UNLOCKED;
  367. }
  368. break;
  369. case 1: /* CLK Synth Lock Check */
  370. for (i = 0; i < 10; i++) {
  371. nLockCheck = RTV_REG_GET(0x1B) & 0x01;
  372. if (nLockCheck)
  373. break;
  374. else
  375. RTV_DBGMSG1("[rtvRF_LockCheck]SCheck(%d)\n", i);
  376. RTV_DELAY_MS(1);
  377. }
  378. if (i == 10) {
  379. RTV_DBGMSG0("[rtvRF_LockCheck] ADC clock unlocked!\n");
  380. nRet = RTV_ADC_CLK_UNLOCKED;
  381. }
  382. break;
  383. }
  384. return nRet;
  385. }
  386. extern BOOL g_fRtv1segLpMode;
  387. extern enum E_RTV_SERVICE_TYPE g_eRtvServiceType;
  388. #ifdef RTV_DUAL_DIVERISTY_ENABLE
  389. extern enum E_RTV_SERVICE_TYPE g_eRtvServiceType_slave;
  390. #endif
  391. static INLINE void rtv_UpdateMon(void)
  392. {
  393. if (g_fRtv1segLpMode) {
  394. RTV_REG_MAP_SEL(LPOFDM_PAGE);
  395. RTV_REG_MASK_SET(0x13, 0x80, 0x80);
  396. RTV_REG_MASK_SET(0x13, 0x80, 0x00);
  397. } else {
  398. RTV_REG_MAP_SEL(OFDM_PAGE);
  399. RTV_REG_MASK_SET(0x1B, 0x80, 0x80);
  400. RTV_REG_MASK_SET(0x1B, 0x80, 0x00);
  401. }
  402. RTV_REG_MAP_SEL(FEC_PAGE);
  403. RTV_REG_MASK_SET(0x11, 0x04, 0x04);
  404. RTV_REG_MASK_SET(0x11, 0x04, 0x00);
  405. }
  406. static INLINE void rtv_SoftReset(void)
  407. {
  408. if (g_fRtv1segLpMode)
  409. RTV_REG_MAP_SEL(LPOFDM_PAGE);
  410. else
  411. RTV_REG_MAP_SEL(OFDM_PAGE);
  412. RTV_REG_MASK_SET(0x10, 0x01, 0x01);
  413. RTV_REG_MASK_SET(0x10, 0x01, 0x00);
  414. RTV_REG_MAP_SEL(FEC_PAGE);
  415. RTV_REG_MASK_SET(0xFB, 0x01, 0x01);
  416. RTV_REG_MASK_SET(0xFB, 0x01, 0x00);
  417. }
  418. static INLINE INT rtv_ServiceTypeSelect(enum E_RTV_SERVICE_TYPE eServiceType)
  419. {
  420. INT nRet = RTV_SUCCESS;
  421. switch (eServiceType) {
  422. #if defined(RTV_ISDBT_ENABLE)
  423. case RTV_SERVICE_UHF_ISDBT_1seg:
  424. case RTV_SERVICE_VHF_ISDBTmm_1seg:
  425. case RTV_SERVICE_VHF_ISDBTsb_1seg:
  426. RTV_REG_MAP_SEL(HOST_PAGE);
  427. RTV_REG_SET(0x0B, 0x36);
  428. RTV_REG_SET(0x12, 0x08);
  429. RTV_REG_SET(0x21, 0x01);
  430. RTV_REG_SET(0x26, 0x00);
  431. RTV_REG_MAP_SEL(FEC_PAGE);
  432. RTV_REG_SET(0x20, 0x0C);
  433. RTV_REG_SET(0x23, 0xF0); /* Layer A */
  434. #if !defined(RTV_IF_SPI) && !defined(RTV_IF_EBI2)
  435. RTV_REG_SET(0x24, 0x31);
  436. RTV_REG_SET(0x4F, 0x1F);
  437. #endif
  438. RTV_REG_SET(0x44, 0x68);
  439. RTV_REG_SET(0x47, 0x40);
  440. RTV_REG_SET(0x53, 0x3E);
  441. RTV_REG_SET(0x21, 0x00);
  442. RTV_REG_SET(0x22, 0x00);
  443. RTV_REG_SET(0x5C, 0x10);
  444. RTV_REG_SET(0x5F, 0x10);
  445. RTV_REG_SET(0x77, 0x40);
  446. RTV_REG_SET(0x7A, 0x20);
  447. RTV_REG_SET(0x83, 0x10);
  448. RTV_REG_SET(0x96, 0x00);
  449. RTV_REG_SET(0xAE, 0x00);
  450. RTV_REG_SET(0xFC, 0x83);
  451. RTV_REG_SET(0xFF, 0x03);
  452. #if 0
  453. RTV_REG_SET(0x44, 0x48);
  454. RTV_REG_SET(0x47, 0x00);
  455. #endif
  456. g_fRtv1segLpMode = 1;
  457. break;
  458. case RTV_SERVICE_VHF_ISDBTsb_3seg:
  459. RTV_DBGMSG0("[rtvRF_SelectService] 3seg is not implemented\n");
  460. break;
  461. case RTV_SERVICE_UHF_ISDBT_13seg:
  462. case RTV_SERVICE_VHF_ISDBTmm_13seg:
  463. RTV_REG_MAP_SEL(HOST_PAGE);
  464. RTV_REG_SET(0x0B, 0x96);
  465. RTV_REG_SET(0x12, 0x00);
  466. RTV_REG_SET(0x21, 0x00);
  467. RTV_REG_SET(0x26, 0xB8);
  468. RTV_REG_MAP_SEL(OFDM_PAGE);
  469. RTV_REG_SET(0x10, 0xD4);
  470. RTV_REG_MAP_SEL(FEC_PAGE);
  471. RTV_REG_SET(0x20, 0x00);
  472. #ifdef RTV_DUAL_DIVERISTY_ENABLE
  473. RTV_REG_SET(0x21, 0x22);
  474. RTV_REG_SET(0x22, 0x22);
  475. #else
  476. RTV_REG_SET(0x21, 0x21);
  477. RTV_REG_SET(0x22, 0x21);
  478. #endif
  479. #if 0
  480. RTV_REG_SET(0x23, 0x84);
  481. RTV_REG_SET(0x24, 0x31);
  482. RTV_REG_SET(0x4F, 0x1F);
  483. #endif
  484. RTV_REG_SET(0x23, 0x90);
  485. #if !defined(RTV_IF_SPI) && !defined(RTV_IF_EBI2)
  486. RTV_REG_SET(0x24, 0x01);
  487. RTV_REG_SET(0x4F, 0x00);
  488. #endif
  489. RTV_REG_SET(0x44, 0x68);
  490. RTV_REG_SET(0x47, 0x40);
  491. RTV_REG_SET(0x53, 0x1E);
  492. RTV_REG_SET(0x5C, 0x11);
  493. RTV_REG_SET(0x5F, 0x11);
  494. RTV_REG_SET(0x77, 0x00);
  495. RTV_REG_SET(0x7A, 0x00);
  496. RTV_REG_SET(0x83, 0x00);
  497. RTV_REG_SET(0x96, 0x20);
  498. RTV_REG_SET(0xAE, 0x02);
  499. RTV_REG_SET(0xFC, 0x83);
  500. RTV_REG_SET(0xFF, 0x03);
  501. #if 0
  502. RTV_REG_SET(0x44, 0xE8);
  503. RTV_REG_SET(0x47, 0x40);
  504. #endif
  505. g_fRtv1segLpMode = 0;
  506. break;
  507. #endif
  508. #if defined(RTV_DVBT_ENABLE)
  509. case RTV_SERVICE_DVBT:
  510. RTV_REG_MAP_SEL(HOST_PAGE);
  511. RTV_REG_SET(0x0B, 0x96);
  512. RTV_REG_SET(0x12, 0x00);
  513. RTV_REG_SET(0x21, 0x00);
  514. RTV_REG_SET(0x26, 0xB8);
  515. RTV_REG_MAP_SEL(DATA_PAGE);
  516. RTV_REG_SET(0xA2, 0x0E);
  517. RTV_REG_SET(0xA3, 0x0E);
  518. RTV_REG_SET(0xA7, 0x0D);
  519. RTV_REG_SET(0xA6, 0x0D);
  520. RTV_REG_MAP_SEL(OFDM_PAGE);
  521. RTV_REG_SET(0x10, 0xD6);
  522. RTV_REG_MAP_SEL(FEC_PAGE);
  523. RTV_REG_SET(0x20, 0x00);
  524. #ifdef RTV_DUAL_DIVERISTY_ENABLE
  525. RTV_REG_SET(0x21, 0x22);
  526. RTV_REG_SET(0x22, 0x22);
  527. RTV_REG_SET(0x53, 0x03); //
  528. #else
  529. RTV_REG_SET(0x21, 0x21);
  530. RTV_REG_SET(0x22, 0x21);
  531. RTV_REG_SET(0x53, 0x1E);
  532. #endif
  533. RTV_REG_SET(0x23, 0xF0); /* Layer A */
  534. #if !defined(RTV_IF_SPI) && !defined(RTV_IF_EBI2)
  535. RTV_REG_SET(0x24, 0x11);
  536. RTV_REG_SET(0x4F, 0x07);
  537. #endif
  538. RTV_REG_SET(0x44, 0xE8);
  539. RTV_REG_SET(0x47, 0x40);
  540. RTV_REG_SET(0x5C, 0x10);
  541. RTV_REG_SET(0x5F, 0x10);
  542. RTV_REG_SET(0x77, 0x00);
  543. RTV_REG_SET(0x7A, 0x00);
  544. RTV_REG_SET(0x83, 0x00);
  545. RTV_REG_SET(0x96, 0x20);
  546. RTV_REG_SET(0xAE, 0x02);
  547. RTV_REG_SET(0xFC, 0x83);
  548. RTV_REG_SET(0xFF, 0xFF);
  549. #if 0
  550. RTV_REG_SET(0x44, 0xE8);
  551. RTV_REG_SET(0x47, 0x40);
  552. #endif
  553. g_fRtv1segLpMode = 0;
  554. break;
  555. #endif
  556. default:
  557. nRet = RTV_INVAILD_SERVICE_TYPE;
  558. }
  559. return nRet;
  560. }
  561. /*=============================================================================
  562. * External functions for RAONTV driver core.
  563. *============================================================================*/
  564. INT rtv_InitSystem(void);
  565. #ifdef __cplusplus
  566. }
  567. #endif
  568. #endif /* __MTV23X_INTERNAL_H__ */