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.

241 lines
4.9 KiB

  1. /*++
  2. Copyright (c) 1999 Microsoft Corporation
  3. Module Name:
  4. Antenna.cpp
  5. Abstract:
  6. Antenna pin code.
  7. --*/
  8. #include "PhilTune.h"
  9. #ifdef ALLOC_DATA_PRAGMA
  10. #pragma const_seg("PAGECONST")
  11. #endif // ALLOC_DATA_PRAGMA
  12. #ifdef ALLOC_PRAGMA
  13. #pragma code_seg("PAGE")
  14. #endif // ALLOC_PRAGMA
  15. enum tuner_errors { NO_ERRORS_DEFINED};
  16. NTSTATUS
  17. CAntennaPin::PinCreate(
  18. IN OUT PKSPIN pKSPin,
  19. IN PIRP pIrp
  20. )
  21. {
  22. NTSTATUS Status = STATUS_SUCCESS;
  23. CAntennaPin* pPin;
  24. CFilter* pFilter;
  25. _DbgPrintF(DEBUGLVL_VERBOSE,("CAntennaPin::PinCreate"));
  26. ASSERT( pKSPin);
  27. ASSERT( pIrp);
  28. pFilter = FilterFromIRP( pIrp);
  29. ASSERT( pFilter);
  30. if (!pFilter)
  31. {
  32. Status = STATUS_DEVICE_NOT_CONNECTED;
  33. goto exit;
  34. }
  35. pPin = new(NonPagedPool,'IFsK') CAntennaPin;
  36. if (!pPin)
  37. {
  38. Status = STATUS_INSUFFICIENT_RESOURCES;
  39. goto exit;
  40. }
  41. // Link our pin context to our filter context.
  42. //
  43. pPin->SetFilter( pFilter);
  44. // Link our context to the KSPIN structure.
  45. //
  46. pKSPin->Context = pPin;
  47. exit:
  48. return Status;
  49. }
  50. NTSTATUS
  51. CAntennaPin::PinClose(
  52. IN OUT PKSPIN Pin,
  53. IN PIRP Irp
  54. )
  55. {
  56. _DbgPrintF(DEBUGLVL_VERBOSE,("PinClose"));
  57. ASSERT(Pin);
  58. ASSERT(Irp);
  59. CAntennaPin* pin = reinterpret_cast<CAntennaPin*>(Pin->Context);
  60. ASSERT(pin);
  61. delete pin;
  62. return STATUS_SUCCESS;
  63. }
  64. NTSTATUS
  65. CAntennaPin::PinSetDeviceState(
  66. IN PKSPIN Pin,
  67. IN KSSTATE ToState,
  68. IN KSSTATE FromState
  69. )
  70. {
  71. NTSTATUS Status = STATUS_SUCCESS;
  72. PKSDEVICE pKSDevice;
  73. CAntennaPin * pPin;
  74. CDevice * pDevice;
  75. _DbgPrintF( DEBUGLVL_VERBOSE,
  76. ("CAntennaPin::PinSetDeviceState"));
  77. ASSERT(Pin);
  78. pKSDevice = KsPinGetDevice( Pin);
  79. pPin = reinterpret_cast<CAntennaPin*>(Pin->Context);
  80. ASSERT( pPin);
  81. pDevice = reinterpret_cast<CDevice *>(pKSDevice->Context);
  82. ASSERT(pDevice);
  83. if ((ToState == KSSTATE_STOP) && (FromState != KSSTATE_STOP))
  84. {
  85. // Since this driver allocates resources on a filter wide basis,
  86. // we tell the filter to release resources when the last pin,
  87. // most upstream pin, transitions to stop.
  88. //
  89. // The antenna pin is the last one to be transitioned to stop,
  90. // so tell the filter to release its resources.
  91. //
  92. Status = pPin->m_pFilter->ReleaseResources();
  93. pPin->m_KsState = ToState;
  94. }
  95. else if ((ToState == KSSTATE_ACQUIRE) && (FromState == KSSTATE_STOP))
  96. {
  97. // Since this driver allocates resources on a filter wide basis,
  98. // we tell the filter to acquire resources when the last pin,
  99. // most upstream pin, transitions out of stop.
  100. //
  101. // The antenna pin is the last one to be transitioned to stop,
  102. // so tell the filter to acquire its resources.
  103. //
  104. Status = pPin->m_pFilter->AcquireResources();
  105. if (NT_SUCCESS( Status))
  106. {
  107. pPin->m_KsState = ToState;
  108. }
  109. }
  110. else if (ToState > KSSTATE_RUN)
  111. {
  112. _DbgPrintF( DEBUGLVL_TERSE,
  113. ("CAntennaPin::PinSetDeviceState - Invalid Device State. ToState 0x%08x. FromState 0x%08x.",
  114. ToState, FromState));
  115. Status = STATUS_INVALID_PARAMETER;
  116. }
  117. else
  118. {
  119. pPin->m_KsState = ToState;
  120. }
  121. pPin->m_pFilter->SetDeviceState( pPin->m_KsState);
  122. return Status;
  123. }
  124. NTSTATUS
  125. CAntennaPin::GetCenterFrequency(
  126. IN PIRP pIrp,
  127. IN PKSPROPERTY pKSProperty,
  128. IN PULONG pulProperty
  129. )
  130. {
  131. CAntennaPin* pPin;
  132. _DbgPrintF(DEBUGLVL_VERBOSE,("PinClose"));
  133. ASSERT(pIrp);
  134. ASSERT(pKSProperty);
  135. ASSERT(pulProperty);
  136. pPin = AntennaPinFromIRP( pIrp);
  137. ASSERT(pPin);
  138. if (!pPin)
  139. {
  140. return STATUS_INVALID_PARAMETER;
  141. }
  142. *pulProperty = pPin->m_ulCurrentFrequency;
  143. return STATUS_SUCCESS;
  144. }
  145. NTSTATUS
  146. CAntennaPin::PutCenterFrequency(
  147. IN PIRP pIrp,
  148. IN PKSPROPERTY pKSProperty,
  149. IN PULONG pulProperty
  150. )
  151. {
  152. NTSTATUS Status = STATUS_SUCCESS;
  153. CAntennaPin* pPin;
  154. CFilter* pFilter;
  155. _DbgPrintF(DEBUGLVL_VERBOSE,("PinClose"));
  156. ASSERT(pIrp);
  157. ASSERT(pKSProperty);
  158. ASSERT(pulProperty);
  159. // Validate that the node type is associated with this pin.
  160. //
  161. Status = BdaValidateNodeProperty( pIrp, pKSProperty);
  162. if (!NT_SUCCESS( Status))
  163. {
  164. goto errExit;
  165. }
  166. // Get a pointer to our object.
  167. //
  168. pPin = AntennaPinFromIRP( pIrp);
  169. ASSERT( pPin);
  170. if (!pPin)
  171. {
  172. Status = STATUS_INVALID_PARAMETER;
  173. goto errExit;
  174. }
  175. pFilter = pPin->GetFilter();
  176. ASSERT( pFilter);
  177. if (!pFilter)
  178. {
  179. Status = STATUS_INVALID_PARAMETER;
  180. goto errExit;
  181. }
  182. Status = pFilter->ChangeFrequency( *pulProperty);
  183. errExit:
  184. return Status;
  185. }