Source code of Windows XP (NT5)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

163 lines
4.7 KiB

  1. //////////////////////////////////////////////////////////////////////////////
  2. // (C) Philips Semiconductors-CSU 1999
  3. // All rights are reserved. Reproduction in whole or in part is prohibited
  4. // without the written consent of the copyright owner.
  5. //
  6. // Philips reserves the right to make changes without notice at any time.
  7. // Philips makes no warranty, expressed, implied or statutory, including but
  8. // not limited to any implied warranty of merchantibility or fitness for any
  9. // particular purpose, or that the use will not infringe any third party
  10. // patent, copyright or trademark. Philips must not be liable for any loss
  11. // or damage arising from its use.
  12. //
  13. // ARI.CPP
  14. // CDevice class : ARI function implementations.
  15. //
  16. //////////////////////////////////////////////////////////////////////////////
  17. #include "philtune.h"
  18. //void STREAMAPI FEQualityCheckThread(IN PVOID Context);
  19. void FEQualityCheckThread(IN PVOID Context);
  20. /*
  21. * CreateQualityCheckThread()
  22. * Input :
  23. * Output: TRUE - if thread creation and timer creation succeeds
  24. * FALSE - if thread creation or timer creation does not succeed
  25. * Description: Creates a new thread to check the VSB hang condition and quality of the signal
  26. * and take necessary actions. Also Initializes a timer, which will wake up this
  27. * thread at regular intervals to do the check.
  28. */
  29. BOOL CDevice::CreateQualityCheckThread()
  30. {
  31. BOOL bStatus;
  32. HANDLE hHandle;
  33. // Enable QCM
  34. m_uiQualityCheckMode = QCM_ENABLE;
  35. // Create new thread
  36. if(StartThread( &hHandle, FEQualityCheckThread, this) == TRUE)
  37. {
  38. _DbgPrintF( DEBUGLVL_VERBOSE,("CDevice::CreateQualityCheckThread: Thread Created Success\n"));
  39. }
  40. else
  41. {
  42. _DbgPrintF( DEBUGLVL_ERROR,("CDevice::CreateQualityCheckThread: Thread Created Fail\n"));
  43. return FALSE;
  44. }
  45. m_bQualityCheckActiveFlag = TRUE;
  46. m_QualityCheckTimer.Set(100000);
  47. return TRUE;
  48. }
  49. /*
  50. * QualityCheckThread()
  51. * Input : Context
  52. * Output:
  53. * Description: Thread which checks signal quality
  54. */
  55. //void STREAMAPI FEQualityCheckThread(IN PVOID Context)
  56. void FEQualityCheckThread(IN PVOID Context)
  57. {
  58. CDevice *p_FE = (CDevice *)Context;
  59. p_FE->QualityCheckThread();
  60. }
  61. /*
  62. * QualityCheckThread()
  63. * Input : Context
  64. * Output:
  65. * Description: Thread which checks signal quality
  66. */
  67. void CDevice::QualityCheckThread()
  68. {
  69. _DbgPrintF( DEBUGLVL_VERBOSE,("CDevice::QualityCheckThread: In Quality Check Thread\n"));
  70. UINT i, k;
  71. Delay(10000);
  72. // Infinite loop
  73. while(1)
  74. {
  75. // Wait for timer to signal. Timeout = 200ms
  76. if(!m_QualityCheckTimer.Wait(200000))
  77. {
  78. _DbgPrintF( DEBUGLVL_VERBOSE,("QualityCheckThread: QCT Timed Out"));
  79. }
  80. else
  81. {
  82. // Wait for mutex
  83. m_QualityCheckMutex.Lock();
  84. UINT uiQcm;
  85. // if signalled , read Quality check mode (QCM). Release mutex
  86. uiQcm = m_uiQualityCheckMode;
  87. m_QualityCheckMutex.Unlock();
  88. // if QCM = ENABLE , check signal quality
  89. if (uiQcm == QCM_ENABLE)
  90. {
  91. m_uiQualityCheckModeAck = QCM_ENABLE;
  92. TimerRoutine();
  93. }
  94. // if QCM = DISABLE, do nothing
  95. else if (uiQcm == QCM_DISABLE)
  96. {
  97. // Reset all counters
  98. ((CVSB1Demod *)(m_pDemod))->ResetHangCounter();
  99. m_uiQualityCheckModeAck = QCM_DISABLE;
  100. // _DbgPrintF( DEBUGLVL_VERBOSE,("QualityCheckThread: Inside Disable\n"));
  101. }
  102. // if QCM = RESET. Reset all counters
  103. else if (uiQcm == QCM_RESET)
  104. {
  105. m_uiQualityCheckModeAck = QCM_RESET;
  106. _DbgPrintF( DEBUGLVL_VERBOSE,("QualityCheckThread: Inside Reset\n"));
  107. }
  108. // if QCM = TERMINATE, Cancel timer and end thread
  109. else if (uiQcm == QCM_TERMINATE)
  110. {
  111. m_uiQualityCheckModeAck = QCM_TERMINATE;
  112. break;
  113. }
  114. // if QCM = none of the above, do nothing
  115. else
  116. {
  117. }
  118. } // Wait for timer
  119. }// infinite while loop
  120. // Cancel timer
  121. m_QualityCheckTimer.Cancel();
  122. _DbgPrintF( DEBUGLVL_VERBOSE,("QualityCheckThread: Terminating Thread\n"));
  123. // End thread
  124. StopThread();
  125. }
  126. /*
  127. * TimerRoutine()
  128. * Input :
  129. * Output:
  130. * Description: Timer routine which periodically checks for a chip hang
  131. * Called only when QCM is Enabled
  132. */
  133. //void STREAMAPI CDevice::TimerRoutine()
  134. void CDevice::TimerRoutine()
  135. {
  136. if(m_bHangCheckFlag == TRUE)
  137. ((CVSB1Demod *)(m_pDemod))->CheckHang();
  138. else
  139. ((CVSB1Demod *)(m_pDemod))->ResetHangCounter();
  140. }