raontv.c 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  1. /******************************************************************************
  2. * (c) COPYRIGHT 2013 RAONTECH, Inc. ALL RIGHTS RESERVED.
  3. *
  4. * TITLE : RAONTECH TV device driver API header file.
  5. *
  6. * FILENAME : raontv.c
  7. *
  8. * DESCRIPTION:
  9. * Configuration for RAONTECH TV Services.
  10. *
  11. ******************************************************************************/
  12. /******************************************************************************
  13. * REVISION HISTORY
  14. *
  15. * DATE NAME REMARKS
  16. * ---------- ------------- ------------------------------------------------
  17. * 07/26/2013 Yang, Maverick Created.
  18. ******************************************************************************/
  19. #include "raontv_rf.h"
  20. volatile BOOL g_fRtvChannelChange;
  21. U8 g_bRtvPage;
  22. volatile E_RTV_ADC_CLK_FREQ_TYPE g_eRtvAdcClkFreqType;
  23. BOOL g_fRtvStreamEnabled;
  24. #if defined(RTV_TDMB_ENABLE) || defined(RTV_ISDBT_ENABLE)
  25. E_RTV_COUNTRY_BAND_TYPE g_eRtvCountryBandType;
  26. #endif
  27. UINT g_nRtvMscThresholdSize;
  28. U8 g_bRtvIntrMaskRegL;
  29. U8 g_bAdjId;
  30. U8 g_bAdjSat;
  31. U8 g_bAdjRefL;
  32. INT rtv_InitSystem(E_RTV_TV_MODE_TYPE eTvMode,
  33. E_RTV_ADC_CLK_FREQ_TYPE eAdcClkFreqType)
  34. {
  35. INT nRet;
  36. int i;
  37. U8 read0, read1;
  38. g_fRtvChannelChange = FALSE;
  39. g_fRtvStreamEnabled = FALSE;
  40. g_bRtvIntrMaskRegL = 0xFF;
  41. #if defined(RTV_IF_SPI) || defined(RTV_IF_EBI2)
  42. #ifdef RTV_IF_SPI
  43. #define WR27_VAL 0x11
  44. #else
  45. #define WR27_VAL 0x13
  46. #endif
  47. #define WR29_VAL 0x31
  48. RTV_REG_MAP_SEL(SPI_CTRL_PAGE);
  49. for (i = 0; i < 100; i++) {
  50. RTV_REG_SET(0x29, WR29_VAL); /* BUFSEL first! */
  51. RTV_REG_SET(0x27, WR27_VAL);
  52. read0 = RTV_REG_GET(0x27);
  53. read1 = RTV_REG_GET(0x29);
  54. RTV_DBGMSG2("read27(0x%02X), read29(0x%02X)\n", read0, read1);
  55. if ((read0 == WR27_VAL) && (read1 == WR29_VAL))
  56. goto RTV_POWER_ON_SUCCESS;
  57. RTV_DBGMSG1("[rtv_InitSystem] Power On wait: %d\n", i);
  58. RTV_DELAY_MS(5);
  59. }
  60. #else
  61. RTV_REG_MAP_SEL(HOST_PAGE);
  62. for (i = 0; i < 100; i++) {
  63. read0 = RTV_REG_GET(0x00);
  64. read1 = RTV_REG_GET(0x01);
  65. RTV_DBGMSG2("read27(0x%02X), read29(0x%02X)\n", read0, read1);
  66. if ((read0 == 0xC6) && (read1 == 0x43))
  67. goto RTV_POWER_ON_SUCCESS;
  68. RTV_DBGMSG1("[rtv_InitSystem] Power On wait: %d\n", i);
  69. RTV_DELAY_MS(5);
  70. }
  71. #endif
  72. RTV_DBGMSG1("rtv_InitSystem: Power On Check error: %d\n", i);
  73. return RTV_POWER_ON_CHECK_ERROR;
  74. RTV_POWER_ON_SUCCESS:
  75. rtvRF_ConfigurePowerType(eTvMode);
  76. nRet = rtvRF_ChangeAdcClock(eTvMode, eAdcClkFreqType, 500);
  77. if (nRet != RTV_SUCCESS)
  78. return nRet;
  79. return RTV_SUCCESS;
  80. }