Leaked source code of windows server 2003
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.

553 lines
14 KiB

  1. /*++
  2. Copyright (c) 1999 Microsoft Corporation
  3. Module Name:
  4. outpin.cpp
  5. Abstract:
  6. Transport Ouput pin code.
  7. --*/
  8. #include "BDATuner.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. /*
  16. ** (Static) PinCreate() method of the CTransportPin class
  17. **
  18. ** Creates the output pin object and
  19. ** associates it with the filter object.
  20. **
  21. */
  22. NTSTATUS
  23. CTransportPin::PinCreate(
  24. IN OUT PKSPIN pKSPin,
  25. IN PIRP Irp
  26. )
  27. {
  28. NTSTATUS Status = STATUS_SUCCESS;
  29. CTransportPin* pPin;
  30. CFilter* pFilter;
  31. _DbgPrintF(DEBUGLVL_VERBOSE,("CTransportPin::PinCreate"));
  32. ASSERT(pKSPin);
  33. ASSERT(Irp);
  34. // Obtain a pointer to the filter object for which the output pin is created.
  35. //
  36. pFilter = reinterpret_cast<CFilter*>(KsGetFilterFromIrp(Irp)->Context);
  37. // Create the transport output pin object.
  38. //
  39. pPin = new(PagedPool,MS_SAMPLE_TUNER_POOL_TAG) CTransportPin; // Tags the allocated memory
  40. if (pPin)
  41. {
  42. // Link the pin context to the filter context.
  43. // That is, set the output pin's filter pointer data member to the obtained filter pointer.
  44. //
  45. pPin->SetFilter( pFilter);
  46. // Link the pin context to the passed in pointer to the KSPIN structure.
  47. //
  48. pKSPin->Context = pPin;
  49. }
  50. else
  51. {
  52. Status = STATUS_INSUFFICIENT_RESOURCES;
  53. }
  54. return Status;
  55. }
  56. /*
  57. ** PinClose() method of the CTransportPin class
  58. **
  59. ** Deletes the previously created output pin object.
  60. **
  61. */
  62. NTSTATUS
  63. CTransportPin::PinClose(
  64. IN OUT PKSPIN Pin,
  65. IN PIRP Irp
  66. )
  67. {
  68. _DbgPrintF(DEBUGLVL_VERBOSE,("CTransportPin::PinClose"));
  69. ASSERT(Pin);
  70. ASSERT(Irp);
  71. // Retrieve the transport output pin object from the passed in
  72. // KSPIN structure's context member.
  73. //
  74. CTransportPin* pPin = reinterpret_cast<CTransportPin*>(Pin->Context);
  75. ASSERT(pPin);
  76. delete pPin;
  77. return STATUS_SUCCESS;
  78. }
  79. /*
  80. ** IntersectDataFormat() method of the CTransportPin class
  81. **
  82. ** Enables connection of the output pin with a downstream filter.
  83. **
  84. */
  85. NTSTATUS
  86. CTransportPin::IntersectDataFormat(
  87. IN PVOID pContext,
  88. IN PIRP pIrp,
  89. IN PKSP_PIN Pin,
  90. IN PKSDATARANGE DataRange,
  91. IN PKSDATARANGE MatchingDataRange,
  92. IN ULONG DataBufferSize,
  93. OUT PVOID Data OPTIONAL,
  94. OUT PULONG DataSize
  95. )
  96. {
  97. if ( DataBufferSize < sizeof(KS_DATARANGE_BDA_TRANSPORT) )
  98. {
  99. *DataSize = sizeof( KS_DATARANGE_BDA_TRANSPORT );
  100. return STATUS_BUFFER_OVERFLOW;
  101. }
  102. else if (DataRange -> FormatSize < sizeof (KS_DATARANGE_BDA_TRANSPORT))
  103. {
  104. return STATUS_NO_MATCH;
  105. } else
  106. {
  107. ASSERT(DataBufferSize == sizeof(KS_DATARANGE_BDA_TRANSPORT));
  108. *DataSize = sizeof( KS_DATARANGE_BDA_TRANSPORT );
  109. RtlCopyMemory( Data, (PVOID)DataRange, sizeof(KS_DATARANGE_BDA_TRANSPORT));
  110. return STATUS_SUCCESS;
  111. }
  112. }
  113. /*
  114. ** GetSignalStatus() method of the CTransportPin class
  115. **
  116. ** Retrieves the value of the demodulator node signal statistics properties.
  117. **
  118. */
  119. NTSTATUS
  120. CTransportPin::GetSignalStatus(
  121. IN PIRP pIrp,
  122. IN PKSPROPERTY pKSProperty,
  123. IN PULONG pulProperty
  124. )
  125. {
  126. NTSTATUS Status = STATUS_SUCCESS;
  127. CTransportPin * pPin;
  128. CFilter* pFilter;
  129. BDATUNER_DEVICE_STATUS DeviceStatus;
  130. _DbgPrintF(DEBUGLVL_VERBOSE,("CTransportPin::GetSignalStatus"));
  131. ASSERT(pIrp);
  132. ASSERT(pKSProperty);
  133. ASSERT(pulProperty);
  134. // Call the BDA support library to
  135. // validate that the node type is associated with this pin.
  136. //
  137. Status = BdaValidateNodeProperty( pIrp, pKSProperty);
  138. if (NT_SUCCESS( Status))
  139. {
  140. // Obtain a pointer to the pin object.
  141. //
  142. // Because the property dispatch table calls the CTransportPin::GetSignalStatus()
  143. // method directly, the method must retrieve a pointer to the underlying pin object.
  144. //
  145. pPin = reinterpret_cast<CTransportPin *>(KsGetPinFromIrp(pIrp)->Context);
  146. ASSERT(pPin);
  147. // Retrieve the filter context from the pin context.
  148. //
  149. pFilter = pPin->GetFilter();
  150. ASSERT( pFilter);
  151. Status = pFilter->GetStatus( &DeviceStatus);
  152. if (Status == STATUS_SUCCESS)
  153. {
  154. switch (pKSProperty->Id)
  155. {
  156. case KSPROPERTY_BDA_SIGNAL_LOCKED:
  157. *pulProperty = DeviceStatus.fSignalLocked;
  158. break;
  159. default:
  160. Status = STATUS_INVALID_PARAMETER;
  161. }
  162. }
  163. }
  164. return Status;
  165. }
  166. /*
  167. ** PutAutoDemodProperty() method of the CTransportPin class
  168. **
  169. ** Starts or Stops automatic demodulation.
  170. **
  171. */
  172. NTSTATUS
  173. CTransportPin::PutAutoDemodProperty(
  174. IN PIRP pIrp,
  175. IN PKSPROPERTY pKSProperty,
  176. IN PULONG pulProperty
  177. )
  178. {
  179. NTSTATUS Status = STATUS_SUCCESS;
  180. CTransportPin* pPin;
  181. CFilter* pFilter;
  182. _DbgPrintF(DEBUGLVL_VERBOSE,("CTransportPin::PutAutoDemodProperty"));
  183. ASSERT(pIrp);
  184. ASSERT(pKSProperty);
  185. ASSERT(pulProperty);
  186. // Call the BDA support library to
  187. // validate that the node type is associated with this pin.
  188. //
  189. Status = BdaValidateNodeProperty( pIrp, pKSProperty);
  190. if (NT_SUCCESS( Status))
  191. {
  192. // Obtain a pointer to the pin object.
  193. //
  194. // Because the property dispatch table calls the CTransportPin::PutAutoDemodProperty()
  195. // method directly, the method must retrieve a pointer to the underlying pin object.
  196. //
  197. pPin = reinterpret_cast<CTransportPin *>(KsGetPinFromIrp(pIrp)->Context);
  198. ASSERT( pPin);
  199. // Retrieve the filter context from the pin context.
  200. //
  201. pFilter = pPin->GetFilter();
  202. ASSERT( pFilter);
  203. switch (pKSProperty->Id)
  204. {
  205. case KSPROPERTY_BDA_AUTODEMODULATE_START:
  206. // Start Demodulator if stopped.
  207. // NOTE! The default state of the demod should match the
  208. // graph run state. This property will only be set
  209. // if KSPROPERTY_BDA_AUTODEMODULATE_STOP was previously
  210. // set.
  211. break;
  212. case KSPROPERTY_BDA_AUTODEMODULATE_STOP:
  213. // Stop Demodulator
  214. // A demodulator stop/start sequence may be used in an
  215. // attempt to retrain the demodulator after a channel change.
  216. break;
  217. default:
  218. Status = STATUS_INVALID_PARAMETER;
  219. }
  220. }
  221. return Status;
  222. }
  223. #if !ATSC_RECEIVER
  224. /*
  225. ** PutDigitalDemodProperty() method of the CTransportPin class
  226. **
  227. ** Sets the value of the digital demodulator node properties.
  228. **
  229. */
  230. NTSTATUS
  231. CTransportPin::PutDigitalDemodProperty(
  232. IN PIRP pIrp,
  233. IN PKSPROPERTY pKSProperty,
  234. IN PULONG pulProperty
  235. )
  236. {
  237. NTSTATUS Status = STATUS_SUCCESS;
  238. CTransportPin* pPin;
  239. CFilter* pFilter;
  240. _DbgPrintF(DEBUGLVL_VERBOSE,("CTransportPin::PutDigitalDemodProperty"));
  241. ASSERT(pIrp);
  242. ASSERT(pKSProperty);
  243. ASSERT(pulProperty);
  244. // Call the BDA support library to
  245. // validate that the node type is associated with this pin.
  246. //
  247. Status = BdaValidateNodeProperty( pIrp, pKSProperty);
  248. if (NT_SUCCESS( Status))
  249. {
  250. // Obtain a pointer to the pin object.
  251. //
  252. // Because the property dispatch table calls the CTransportPin::PutDigitalDemodProperty()
  253. // method directly, the method must retrieve a pointer to the underlying pin object.
  254. //
  255. pPin = reinterpret_cast<CTransportPin *>(KsGetPinFromIrp(pIrp)->Context);
  256. ASSERT( pPin);
  257. // Retrieve the filter context from the pin context.
  258. //
  259. pFilter = pPin->GetFilter();
  260. ASSERT( pFilter);
  261. switch (pKSProperty->Id)
  262. {
  263. case KSPROPERTY_BDA_MODULATION_TYPE:
  264. break;
  265. case KSPROPERTY_BDA_INNER_FEC_TYPE:
  266. break;
  267. case KSPROPERTY_BDA_INNER_FEC_RATE:
  268. break;
  269. case KSPROPERTY_BDA_OUTER_FEC_TYPE:
  270. break;
  271. case KSPROPERTY_BDA_OUTER_FEC_RATE:
  272. break;
  273. case KSPROPERTY_BDA_SYMBOL_RATE:
  274. break;
  275. case KSPROPERTY_BDA_SPECTRAL_INVERSION:
  276. break;
  277. case KSPROPERTY_BDA_GUARD_INTERVAL:
  278. break;
  279. case KSPROPERTY_BDA_TRANSMISSION_MODE:
  280. break;
  281. default:
  282. Status = STATUS_INVALID_PARAMETER;
  283. }
  284. }
  285. return Status;
  286. }
  287. /*
  288. ** GetDigitalDemodProperty() method of the CTransportPin class
  289. **
  290. ** Gets the value of the digital demodulator node properties.
  291. **
  292. */
  293. NTSTATUS
  294. CTransportPin::GetDigitalDemodProperty(
  295. IN PIRP pIrp,
  296. IN PKSPROPERTY pKSProperty,
  297. IN PULONG pulProperty
  298. )
  299. {
  300. NTSTATUS Status = STATUS_SUCCESS;
  301. CTransportPin* pPin;
  302. CFilter* pFilter;
  303. _DbgPrintF(DEBUGLVL_VERBOSE,("CTransportPin::GetDigitalDemodProperty"));
  304. ASSERT(pIrp);
  305. ASSERT(pKSProperty);
  306. ASSERT(pulProperty);
  307. // Call the BDA support library to
  308. // validate that the node type is associated with this pin.
  309. //
  310. Status = BdaValidateNodeProperty( pIrp, pKSProperty);
  311. if (NT_SUCCESS( Status))
  312. {
  313. // Obtain a pointer to the pin object.
  314. //
  315. // Because the property dispatch table calls the CTransportPin::GetDigitalDemodProperty()
  316. // method directly, the method must retrieve a pointer to the underlying pin object.
  317. //
  318. pPin = reinterpret_cast<CTransportPin *>(KsGetPinFromIrp(pIrp)->Context);
  319. ASSERT( pPin);
  320. // Retrieve the filter context from the pin context.
  321. //
  322. pFilter = pPin->GetFilter();
  323. ASSERT( pFilter);
  324. switch (pKSProperty->Id)
  325. {
  326. case KSPROPERTY_BDA_MODULATION_TYPE:
  327. break;
  328. case KSPROPERTY_BDA_INNER_FEC_TYPE:
  329. break;
  330. case KSPROPERTY_BDA_INNER_FEC_RATE:
  331. break;
  332. case KSPROPERTY_BDA_OUTER_FEC_TYPE:
  333. break;
  334. case KSPROPERTY_BDA_OUTER_FEC_RATE:
  335. break;
  336. case KSPROPERTY_BDA_SYMBOL_RATE:
  337. break;
  338. case KSPROPERTY_BDA_SPECTRAL_INVERSION:
  339. break;
  340. case KSPROPERTY_BDA_GUARD_INTERVAL:
  341. break;
  342. case KSPROPERTY_BDA_TRANSMISSION_MODE:
  343. break;
  344. default:
  345. Status = STATUS_INVALID_PARAMETER;
  346. }
  347. }
  348. return Status;
  349. }
  350. #endif // !ATSC_RECEIVER
  351. /*
  352. ** PutExtensionProperties() method of the CTransportPin class
  353. **
  354. ** Sets the value of the demodulator node extension properties.
  355. **
  356. */
  357. NTSTATUS
  358. CTransportPin::PutExtensionProperties(
  359. IN PIRP pIrp,
  360. IN PKSPROPERTY pKSProperty,
  361. IN PULONG pulProperty
  362. )
  363. {
  364. NTSTATUS Status = STATUS_SUCCESS;
  365. CTransportPin* pPin;
  366. CFilter* pFilter;
  367. _DbgPrintF(DEBUGLVL_VERBOSE,("CTransportPin::PutExtensionProperties"));
  368. ASSERT(pIrp);
  369. ASSERT(pKSProperty);
  370. ASSERT(pulProperty);
  371. // Call the BDA support library to
  372. // validate that the node type is associated with this pin.
  373. //
  374. Status = BdaValidateNodeProperty( pIrp, pKSProperty);
  375. if (NT_SUCCESS( Status))
  376. {
  377. // Obtain a pointer to the pin object.
  378. //
  379. // Because the property dispatch table calls the CTransportPin::PutExtensionProperties()
  380. // method directly, the method must retrieve a pointer to the underlying pin object.
  381. //
  382. pPin = reinterpret_cast<CTransportPin *>(KsGetPinFromIrp(pIrp)->Context);
  383. ASSERT( pPin);
  384. // Retrieve the filter context from the pin context.
  385. //
  386. pFilter = pPin->GetFilter();
  387. ASSERT( pFilter);
  388. switch (pKSProperty->Id)
  389. {
  390. case KSPROPERTY_BDA_SAMPLE_DEMOD_EXTENSION_PROPERTY1:
  391. Status = pFilter->SetDemodProperty1(*pulProperty);
  392. break;
  393. case KSPROPERTY_BDA_SAMPLE_DEMOD_EXTENSION_PROPERTY2:
  394. Status = pFilter->SetDemodProperty1(*pulProperty);
  395. break;
  396. // KSPROPERTY_BDA_SAMPLE_DEMOD_EXTENSION_PROPERTY3 does not have a SetHandler
  397. // according to declaration of BdaSampleDemodExtensionProperties
  398. default:
  399. Status = STATUS_INVALID_PARAMETER;
  400. }
  401. }
  402. return Status;
  403. }
  404. /*
  405. ** GetExtensionProperties() method of the CTransportPin class
  406. **
  407. ** Retrieves the value of the demodulator node extension properties.
  408. **
  409. */
  410. NTSTATUS
  411. CTransportPin::GetExtensionProperties(
  412. IN PIRP Irp,
  413. IN PKSPROPERTY pKSProperty,
  414. IN PULONG pulProperty
  415. )
  416. {
  417. NTSTATUS Status = STATUS_SUCCESS;
  418. CTransportPin * pPin;
  419. CFilter* pFilter;
  420. _DbgPrintF(DEBUGLVL_VERBOSE,("CTransportPin::GetExtensionProperties"));
  421. ASSERT(Irp);
  422. ASSERT(pKSProperty);
  423. ASSERT(pulProperty);
  424. // Obtain a pointer to the pin object.
  425. //
  426. // Because the property dispatch table calls the CTransportPin::GetExtensionProperties()
  427. // method directly, the method must retrieve a pointer to the underlying pin object.
  428. //
  429. pPin = reinterpret_cast<CTransportPin *>(KsGetPinFromIrp(Irp)->Context);
  430. ASSERT(pPin);
  431. // Retrieve the filter context from the pin context.
  432. //
  433. pFilter = pPin->GetFilter();
  434. ASSERT( pFilter);
  435. switch (pKSProperty->Id)
  436. {
  437. case KSPROPERTY_BDA_SAMPLE_DEMOD_EXTENSION_PROPERTY1:
  438. Status = pFilter->GetDemodProperty1(pulProperty);
  439. break;
  440. // KSPROPERTY_BDA_SAMPLE_DEMOD_EXTENSION_PROPERTY2 does not have a GetHandler
  441. // according to declaration of BdaSampleDemodExtensionProperties
  442. case KSPROPERTY_BDA_SAMPLE_DEMOD_EXTENSION_PROPERTY3:
  443. Status = pFilter->GetDemodProperty3(pulProperty);
  444. break;
  445. default:
  446. Status = STATUS_INVALID_PARAMETER;
  447. }
  448. return STATUS_SUCCESS;
  449. }