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.

210 lines
6.1 KiB

  1. //////////////////////////////////////////////////////////////////////////////
  2. //
  3. // (C) Philips Semiconductors 1998
  4. // All rights are reserved. Reproduction in whole or in part is prohibited
  5. // without the written consent of the copyright owner.
  6. //
  7. // Philips reserves the right to make changes without notice at any time.
  8. // Philips makes no warranty, expressed, implied or statutory, including but
  9. // not limited to any implied warranty of merchantibility or fitness for any
  10. // particular purpose, or that the use will not infringe any third party
  11. // patent, copyright or trademark. Philips must not be liable for any loss
  12. // or damage arising from its use.
  13. //
  14. // MPOC.CPP
  15. // Implementation for MPOC
  16. //////////////////////////////////////////////////////////////////////////////
  17. #include "philtune.h"
  18. #include "mpoc.h"
  19. #include "wdmdebug.h"
  20. UCHAR MpocInitArray[] =
  21. {
  22. 0x20, // 1D
  23. 0x20, // 1E
  24. 0x1F, // 1F
  25. 0x00, // 20
  26. 0x00, // 21
  27. 0x00, // 22
  28. 0x00, // 23
  29. 0x00, // 24
  30. 0x00, // 25
  31. 0x00, // 26
  32. 0x10, // 27
  33. 0x12, // 28
  34. 0x00, // 29
  35. 0x13, // 2A
  36. 0x00, // 2B
  37. 0x00, // 2C
  38. 0x00, // 2D
  39. 0x00, // 2E
  40. };
  41. /*
  42. * MpocInit()
  43. * Input
  44. * Output : TRUE - mode initialization succeeds
  45. * FALSE - if there is an I2C error
  46. * Description: Initialize MPOC registers
  47. */
  48. NTSTATUS CDevice::MpocInit()
  49. {
  50. NTSTATUS Status = STATUS_SUCCESS;
  51. _DbgPrintF( DEBUGLVL_VERBOSE,("CDevice::MPOCInit(): Inside\n"));
  52. m_MpocRegisters.reg_set.offset = MPOC_CONTROL_REG_OFFSET;
  53. MemoryCopy(m_MpocRegisters.reg_set.buffer, &MpocInitArray, sizeof(MpocInitArray));
  54. if(!m_pI2CScript->WriteSeq(MPOC_I2C_ADDRESS, (UCHAR *)(m_MpocRegisters.array), sizeof(MpocInitArray)+1))
  55. {
  56. _DbgPrintF( DEBUGLVL_ERROR,("CDevice: MPOC Initialize failed"));
  57. return STATUS_ADAPTER_HARDWARE_ERROR;
  58. }
  59. return STATUS_SUCCESS;
  60. }
  61. /*
  62. * SetMpocIFMode()
  63. * Input
  64. * Output : TRUE - mode initialization succeeds
  65. * FALSE - if there is an I2C error
  66. * Description: Set IF Mpode on MPOC
  67. */
  68. NTSTATUS CDevice::SetMpocIFMode(ULONG ulMode)
  69. {
  70. NTSTATUS Status = STATUS_SUCCESS;
  71. UCHAR ucBuffer;
  72. _DbgPrintF( DEBUGLVL_VERBOSE,("CDevice::MPOCSetMode(): Inside\n"));
  73. ucBuffer = m_MpocRegisters.reg_set.buffer[MPOC_CONTROL_REG_VIDEO_ADC - MPOC_CONTROL_REG_OFFSET];
  74. ucBuffer &= 0xF8;
  75. if(ulMode == (ULONG)KSPROPERTY_TUNER_MODE_ATSC)
  76. {
  77. // Set the appropriate bits based on the Output ( this corresponds
  78. // directly to the bits to be set for Video ADC output)
  79. if(m_BoardInfo.uiMpocVersion < 4)
  80. {
  81. ucBuffer |= MPOC_VIDEOADC_VSBI;
  82. }
  83. else
  84. {
  85. // 1/25/2000 . Versions >= N1D have the VSB-1 value shifted
  86. // by 1 (register value changes)
  87. ucBuffer |= MPOC_VIDEOADC_VSBIQ;
  88. }
  89. m_MpocRegisters.reg_set.buffer[MPOC_CONTROL_REG_VIDEO_ADC- MPOC_CONTROL_REG_OFFSET] = ucBuffer;
  90. // Set AGC to external mode
  91. m_MpocRegisters.reg_set.buffer[MPOC_CONTROL_REG_VISION_IF_1 - MPOC_CONTROL_REG_OFFSET] |= EXTERNAL_AGC;
  92. }
  93. else if(ulMode == (ULONG)KSPROPERTY_TUNER_MODE_TV)
  94. {
  95. // Set the appropriate bits based on the Output ( this corresponds
  96. // directly to the bits to be set for Video ADC output)
  97. ucBuffer |= MPOC_VIDEOADC_TV27;
  98. m_MpocRegisters.reg_set.buffer[MPOC_CONTROL_REG_VIDEO_ADC- MPOC_CONTROL_REG_OFFSET] = ucBuffer;
  99. if(m_BoardInfo.uiMpocVersion >= 4)
  100. {
  101. m_MpocRegisters.reg_set.buffer[MPOC_CONTROL_REG_VISION_IF_0 - MPOC_CONTROL_REG_OFFSET] |=
  102. MPOC_PLL_IF_FREQ_45_POINT_75;
  103. }
  104. // Set AGC to external mode
  105. m_MpocRegisters.reg_set.buffer[MPOC_CONTROL_REG_VISION_IF_1 - MPOC_CONTROL_REG_OFFSET] &= ~EXTERNAL_AGC;
  106. }
  107. else {}
  108. if(!m_pI2CScript->WriteSeq(MPOC_I2C_ADDRESS, (UCHAR *)(m_MpocRegisters.array), sizeof(m_MpocRegisters.array)))
  109. {
  110. _DbgPrintF( DEBUGLVL_ERROR,("CDevice: SetIFMode: MPOC Write failed"));
  111. return STATUS_ADAPTER_HARDWARE_ERROR;
  112. }
  113. return STATUS_SUCCESS;
  114. }
  115. /*
  116. * GetMpocVersion()
  117. * Input:
  118. * Output:
  119. * Description: Get MPOC version number
  120. */
  121. NTSTATUS CDevice::GetMpocVersion(UINT *p_version)
  122. {
  123. // Read EEPROM for version number
  124. // MPOC version number is in register 0xFC of EEPROM at address 0xA6
  125. // Version N1A - 1
  126. // N1B - 2
  127. // N1C - 3
  128. // N1D - 4
  129. // N1F - 6
  130. UCHAR ucStartAddr = 0xFC;
  131. UCHAR ucVersion = 4;
  132. NTSTATUS Status = STATUS_SUCCESS;
  133. if(!m_pI2CScript->WriteSeq(BOARD_EEPROM_ADDRESS, &ucStartAddr, 1))
  134. {
  135. Status = STATUS_ADAPTER_HARDWARE_ERROR;
  136. // Set default version to N1D
  137. ucVersion = 4;
  138. }
  139. if(!m_pI2CScript->ReadSeq(BOARD_EEPROM_ADDRESS, &ucVersion, 1))
  140. {
  141. Status = STATUS_ADAPTER_HARDWARE_ERROR;
  142. // Set default version to N1D
  143. ucVersion = 4;
  144. }
  145. //Mini: Test
  146. //ucVersion = 6;
  147. *p_version = (UINT)(ucVersion);
  148. _DbgPrintF( DEBUGLVL_VERBOSE,("CDevice :MPOC Version = %x \n", ucVersion));
  149. return Status;
  150. }
  151. /*
  152. * GetMpocIFStatus()
  153. * Input:
  154. * Output:
  155. * Description:
  156. */
  157. NTSTATUS CDevice::GetMpocStatus(UINT StatusType, UINT *puiStatus)
  158. {
  159. UCHAR ucBuffer[MAX_MPOC_STATUS_REGISTERS];
  160. if(!m_pI2CScript->ReadSeq(MPOC_I2C_ADDRESS, ucBuffer, MAX_MPOC_STATUS_REGISTERS))
  161. {
  162. _DbgPrintF( DEBUGLVL_ERROR,("CDevice: MPOC Read failed"));
  163. return STATUS_ADAPTER_HARDWARE_ERROR;
  164. }
  165. switch (StatusType)
  166. {
  167. case MPOC_STATUS_IF_PLL_LOCK:
  168. // Bit 5 of status register 0
  169. *puiStatus = (ucBuffer[MPOC_STATUS_REG_0] & 0x20) ? 1 : 0;
  170. break;
  171. case MPOC_STATUS_PHASE_LOCK:
  172. // Bit 4 of status register 0
  173. *puiStatus = (ucBuffer[MPOC_STATUS_REG_0] & 0x10) ? 1 : 0;
  174. break;
  175. case MPOC_STATUS_PLL_OFFSET:
  176. // Bits 3 and 2 of status register 2
  177. *puiStatus = (ucBuffer[MPOC_STATUS_REG_2] & 0x0c) >> 2;
  178. break;
  179. default:
  180. return STATUS_INVALID_PARAMETER;
  181. break;
  182. }
  183. return STATUS_SUCCESS;
  184. }