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.

810 lines
27 KiB

  1. // $Header: G:/SwDev/WDM/Video/bt848/rcs/Capprop.c 1.14 1998/05/13 14:44:20 tomz Exp $
  2. //==========================================================================;
  3. //
  4. // THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
  5. // KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
  6. // IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR
  7. // PURPOSE.
  8. //
  9. // Copyright (c) 1992 - 1996 Microsoft Corporation. All Rights Reserved.
  10. //
  11. //==========================================================================;
  12. #ifdef __cplusplus
  13. extern "C" {
  14. #endif
  15. #include "strmini.h"
  16. #include "ksmedia.h"
  17. #ifdef __cplusplus
  18. }
  19. #endif
  20. #include "device.h"
  21. #include "capdebug.h"
  22. #include "capprop.h"
  23. #include "capmain.h"
  24. extern PsDevice *gpPsDevice;
  25. bool CrossBar::TestRoute( int InPin, int OutPin )
  26. {
  27. Trace t("CrossBar::TestRoute()");
  28. // JBC 4/1/98 Handle Input Pin = -1 for Audio Mute case
  29. if ( InPin == -1 && (OutputPins [OutPin].PinType >= KS_PhysConn_Audio_Tuner)) { // JBC 4/1/98
  30. return true;
  31. }
  32. if ((InputPins [InPin].PinType >= KS_PhysConn_Audio_Tuner) && // 0x1000 first audio pin // JBC 4/1/98
  33. (OutputPins [OutPin].PinType >= KS_PhysConn_Audio_Tuner)) { // JBC 4/1/98
  34. return true;
  35. }
  36. else {
  37. if ((InputPins [InPin].PinType >= KS_PhysConn_Video_Tuner) &&
  38. (InputPins [InPin].PinType < KS_PhysConn_Audio_Tuner) && // JBC 4/1/98
  39. (OutputPins [OutPin].PinType < KS_PhysConn_Audio_Tuner)) {
  40. DebugOut((1, "TestRoute(%d,%d) = true\n", InPin, OutPin));
  41. return true;
  42. } else {
  43. return false;
  44. }
  45. }
  46. }
  47. // -------------------------------------------------------------------
  48. // XBar Property Set functions
  49. // -------------------------------------------------------------------
  50. //
  51. // The only property to set on the XBar selects the input to use
  52. //
  53. /* Method: AdapterGetCrossbarProperty
  54. * Purpose:
  55. */
  56. VOID AdapterSetCrossbarProperty( PHW_STREAM_REQUEST_BLOCK pSrb )
  57. {
  58. Trace t("AdapterSetCrossbarProperty()");
  59. PHW_DEVICE_EXTENSION HwDeviceExtension =
  60. (PHW_DEVICE_EXTENSION) pSrb->HwDeviceExtension;
  61. PsDevice *adapter = HwDeviceExtension->psdevice;
  62. PSTREAM_PROPERTY_DESCRIPTOR pSPD = pSrb->CommandData.PropertyInfo;
  63. ULONG Id = pSPD->Property->Id; // index of the property
  64. ULONG nS = pSPD->PropertyOutputSize; // size of data supplied
  65. switch ( Id ) {
  66. case KSPROPERTY_CROSSBAR_ROUTE:
  67. {
  68. PKSPROPERTY_CROSSBAR_ROUTE_S pRoute =
  69. (PKSPROPERTY_CROSSBAR_ROUTE_S)pSPD->PropertyInfo;
  70. ASSERT (nS >= sizeof (KSPROPERTY_CROSSBAR_ROUTE_S));
  71. // Copy the input property info to the output property info
  72. RtlCopyMemory( pRoute, pSPD->Property,
  73. sizeof( KSPROPERTY_CROSSBAR_ROUTE_S ) );
  74. int InPin, OutPin;
  75. InPin = pRoute->IndexInputPin;
  76. OutPin = pRoute->IndexOutputPin;
  77. DebugOut((1, "*** KSPROPERTY_CROSSBAR_ROUTE(%d,%d)\n", InPin, OutPin));
  78. if ( adapter->xBar.GoodPins( InPin, OutPin ) ) {
  79. DebugOut((1, "*** xBar.GoodPins succeeded\n"));
  80. if ( adapter->xBar.TestRoute( InPin, OutPin ) ) {
  81. DebugOut((1, "*** xBar.TestRoute succeeded\n"));
  82. pRoute->CanRoute = true;
  83. // JBC 4/1/98 What happens when we call setconnector for audio pins?
  84. if (OutPin == 0 ) // JBC 4/1/98 Check for Video Vs Audio pins settings
  85. {
  86. // Video out
  87. adapter->SetConnector( adapter->xBar.GetPinNo( InPin ) + 1 ); // our connectors are 1-based
  88. }
  89. else
  90. {
  91. // Audio out
  92. if ( InPin == -1 ) // then mute
  93. {
  94. gpPsDevice->EnableAudio( Off );
  95. }
  96. else
  97. {
  98. gpPsDevice->EnableAudio( On );
  99. }
  100. }
  101. // this just sets the association
  102. adapter->xBar.Route( OutPin, InPin );
  103. } else { // JBC 3/31/98 add curly braces
  104. DebugOut((1, "*** xBar.TestRoute failed\n"));
  105. pRoute->CanRoute = false;
  106. }
  107. } else { // JBC 3/31/98 add curly braces
  108. DebugOut((1, "*** xBar.GoodPins failed\n"));
  109. pRoute->CanRoute = 0;
  110. }
  111. }
  112. pSrb->ActualBytesTransferred = sizeof( KSPROPERTY_CROSSBAR_ROUTE_S );
  113. break;
  114. default:
  115. break;
  116. }
  117. pSrb->Status = STATUS_SUCCESS;
  118. }
  119. /* Method: AdapterGetCrossbarProperty
  120. * Purpose:
  121. */
  122. VOID AdapterGetCrossbarProperty( PHW_STREAM_REQUEST_BLOCK pSrb )
  123. {
  124. Trace t("AdapterGetCrossbarProperty()");
  125. PHW_DEVICE_EXTENSION HwDeviceExtension =
  126. (PHW_DEVICE_EXTENSION) pSrb->HwDeviceExtension;
  127. PsDevice *adapter = HwDeviceExtension->psdevice;
  128. PSTREAM_PROPERTY_DESCRIPTOR pSPD = pSrb->CommandData.PropertyInfo;
  129. ULONG Id = pSPD->Property->Id; // index of the property
  130. // PLONG pL = (PLONG) pSPD->PropertyInfo; // pointer to the data
  131. ULONG nS = pSPD->PropertyOutputSize; // size of data supplied
  132. // Property set specific structure
  133. switch ( Id ) {
  134. case KSPROPERTY_CROSSBAR_CAPS: // R
  135. if ( nS >= sizeof( KSPROPERTY_CROSSBAR_CAPS_S ) ) {
  136. PKSPROPERTY_CROSSBAR_CAPS_S pCaps =
  137. (PKSPROPERTY_CROSSBAR_CAPS_S)pSPD->PropertyInfo;
  138. // Copy the input property info to the output property info
  139. RtlCopyMemory( pCaps, pSPD->Property,
  140. sizeof( KSPROPERTY_CROSSBAR_CAPS_S ) );
  141. pCaps->NumberOfInputs = adapter->xBar.GetNoInputs();
  142. pCaps->NumberOfOutputs = adapter->xBar.GetNoOutputs();
  143. pSrb->ActualBytesTransferred = sizeof( KSPROPERTY_CROSSBAR_CAPS_S );
  144. }
  145. break;
  146. case KSPROPERTY_CROSSBAR_CAN_ROUTE:
  147. DebugOut((1, "*** KSPROPERTY_CROSSBAR_CAN_ROUTE\n"));
  148. if ( nS >= sizeof( KSPROPERTY_CROSSBAR_ROUTE_S ) ) {
  149. PKSPROPERTY_CROSSBAR_ROUTE_S pRoute =
  150. (PKSPROPERTY_CROSSBAR_ROUTE_S)pSPD->PropertyInfo;
  151. // Copy the input property info to the output property info
  152. RtlCopyMemory( pRoute, pSPD->Property,
  153. sizeof( KSPROPERTY_CROSSBAR_ROUTE_S ) );
  154. int InPin, OutPin;
  155. InPin = pRoute->IndexInputPin;
  156. OutPin = pRoute->IndexOutputPin;
  157. if ( adapter->xBar.GoodPins( InPin, OutPin ) ) {
  158. DebugOut((1, "*** xBar.GoodPins succeeded\n"));
  159. pRoute->CanRoute = adapter->xBar.TestRoute( InPin, OutPin );
  160. } else {
  161. DebugOut((1, "*** xBar.GoodPins failed\n"));
  162. pRoute->CanRoute = FALSE;
  163. }
  164. pSrb->ActualBytesTransferred = sizeof( KSPROPERTY_CROSSBAR_ROUTE_S );
  165. }
  166. break;
  167. case KSPROPERTY_CROSSBAR_ROUTE:
  168. DebugOut((1, "*** KSPROPERTY_CROSSBAR_ROUTE\n"));
  169. if ( nS >= sizeof( KSPROPERTY_CROSSBAR_ROUTE_S ) ) {
  170. PKSPROPERTY_CROSSBAR_ROUTE_S pRoute =
  171. (PKSPROPERTY_CROSSBAR_ROUTE_S)pSPD->PropertyInfo;
  172. // Copy the input property info to the output property info
  173. RtlCopyMemory( pRoute, pSPD->Property,
  174. sizeof( KSPROPERTY_CROSSBAR_ROUTE_S ) );
  175. int OutPin = pRoute->IndexOutputPin;
  176. if ( OutPin < adapter->xBar.GetNoOutputs() ) {
  177. DebugOut((1, "*** xBar.GetRoute(%d) called\n", OutPin));
  178. pRoute->IndexInputPin = adapter->xBar.GetRoute( OutPin );
  179. }
  180. else {
  181. pRoute->IndexInputPin = (DWORD) -1;
  182. }
  183. DebugOut((1, "*** pRoute->IndexInputPin = %d\n", pRoute->IndexInputPin));
  184. pSrb->ActualBytesTransferred = sizeof( KSPROPERTY_CROSSBAR_ROUTE_S );
  185. }
  186. break;
  187. case KSPROPERTY_CROSSBAR_PININFO: // R
  188. if ( nS >= sizeof( KSPROPERTY_CROSSBAR_PININFO_S ) ) {
  189. PKSPROPERTY_CROSSBAR_PININFO_S pPinInfo =
  190. (PKSPROPERTY_CROSSBAR_PININFO_S)pSPD->PropertyInfo;
  191. // Copy the input property info to the output property info
  192. RtlCopyMemory( pPinInfo, pSPD->Property,
  193. sizeof( KSPROPERTY_CROSSBAR_PININFO_S ) );
  194. pPinInfo->PinType = adapter->xBar.GetPinInfo( pPinInfo->Direction,
  195. pPinInfo->Index,
  196. pPinInfo->RelatedPinIndex,
  197. &(pPinInfo->Medium));
  198. pSrb->ActualBytesTransferred = sizeof( KSPROPERTY_CROSSBAR_PININFO_S );
  199. }
  200. break;
  201. default:
  202. pSrb->ActualBytesTransferred = 0;
  203. break;
  204. }
  205. pSrb->Status = STATUS_SUCCESS;
  206. }
  207. // -------------------------------------------------------------------
  208. // TVTuner Property Set functions
  209. // -------------------------------------------------------------------
  210. void AdapterSetTunerProperty( PHW_STREAM_REQUEST_BLOCK pSrb )
  211. {
  212. Trace t("AdapterSetTunerProperty()");
  213. PHW_DEVICE_EXTENSION HwDeviceExtension =
  214. (PHW_DEVICE_EXTENSION) pSrb->HwDeviceExtension;
  215. PsDevice *adapter = HwDeviceExtension->psdevice;
  216. PSTREAM_PROPERTY_DESCRIPTOR pSPD = pSrb->CommandData.PropertyInfo;
  217. ULONG Id = pSPD->Property->Id; // index of the property
  218. PVOID pV = pSPD->PropertyInfo; // pointer to the data
  219. ULONG nS = pSPD->PropertyOutputSize; // size of data returned
  220. ASSERT( nS >= sizeof( ULONG ) );
  221. switch ( Id ) {
  222. case KSPROPERTY_TUNER_FREQUENCY:
  223. {
  224. PKSPROPERTY_TUNER_FREQUENCY_S pFreq =
  225. (PKSPROPERTY_TUNER_FREQUENCY_S)pV;
  226. adapter->SetChannel( pFreq->Frequency );
  227. }
  228. break;
  229. case KSPROPERTY_TUNER_MODE:
  230. {
  231. PKSPROPERTY_TUNER_MODE_S pMode =
  232. (PKSPROPERTY_TUNER_MODE_S)pV;
  233. ASSERT (pMode->Mode == KSPROPERTY_TUNER_MODE_TV);
  234. }
  235. break;
  236. default:
  237. // do not process input and standard as we don't have a choice of them
  238. break;
  239. }
  240. pSrb->Status = STATUS_SUCCESS;
  241. }
  242. void AdapterGetTunerProperty( PHW_STREAM_REQUEST_BLOCK pSrb )
  243. {
  244. Trace t("AdapterGetTunerProperty()");
  245. PHW_DEVICE_EXTENSION HwDeviceExtension =
  246. (PHW_DEVICE_EXTENSION) pSrb->HwDeviceExtension;
  247. PsDevice *adapter = HwDeviceExtension->psdevice;
  248. PSTREAM_PROPERTY_DESCRIPTOR pSPD = pSrb->CommandData.PropertyInfo;
  249. ULONG Id = pSPD->Property->Id; // index of the property
  250. PVOID pV = pSPD->PropertyInfo; // pointer to the data
  251. ULONG nS = pSPD->PropertyOutputSize; // size of data supplied
  252. ASSERT (nS >= sizeof (LONG));
  253. pSrb->ActualBytesTransferred = 0;
  254. switch ( Id ) {
  255. case KSPROPERTY_TUNER_CAPS:
  256. {
  257. PKSPROPERTY_TUNER_CAPS_S pCaps =
  258. (PKSPROPERTY_TUNER_CAPS_S)pSPD->Property;
  259. ASSERT (nS >= sizeof( KSPROPERTY_TUNER_CAPS_S ) );
  260. // now work with the output buffer
  261. pCaps =(PKSPROPERTY_TUNER_CAPS_S)pV;
  262. pCaps->ModesSupported = KSPROPERTY_TUNER_MODE_TV;
  263. pCaps->VideoMedium = TVTunerMediums[0];
  264. pCaps->TVAudioMedium = TVTunerMediums[1];
  265. pCaps->RadioAudioMedium.Set = GUID_NULL; // No separate radio audio pin
  266. pCaps->RadioAudioMedium.Id = 0;
  267. pCaps->RadioAudioMedium.Flags = 0;
  268. pSrb->ActualBytesTransferred = sizeof( KSPROPERTY_TUNER_CAPS_S );
  269. }
  270. break;
  271. case KSPROPERTY_TUNER_MODE:
  272. {
  273. PKSPROPERTY_TUNER_MODE_S pMode =
  274. (PKSPROPERTY_TUNER_MODE_S)pV;
  275. ASSERT (nS >= sizeof( KSPROPERTY_TUNER_MODE_S ) );
  276. pMode->Mode = KSPROPERTY_TUNER_MODE_TV;
  277. pSrb->ActualBytesTransferred = sizeof( KSPROPERTY_TUNER_MODE_S);
  278. }
  279. break;
  280. case KSPROPERTY_TUNER_MODE_CAPS:
  281. {
  282. PKSPROPERTY_TUNER_MODE_CAPS_S pCaps =
  283. (PKSPROPERTY_TUNER_MODE_CAPS_S)pSPD->Property;
  284. ASSERT (nS >= sizeof( KSPROPERTY_TUNER_MODE_CAPS_S ) );
  285. ASSERT (pCaps->Mode == KSPROPERTY_TUNER_MODE_TV);
  286. // now work with the output buffer
  287. pCaps =(PKSPROPERTY_TUNER_MODE_CAPS_S)pV;
  288. //
  289. // List the formats actually supported by this tuner
  290. //
  291. pCaps->StandardsSupported = adapter->GetSupportedStandards();
  292. //
  293. // Get the min and max frequencies supported
  294. //
  295. pCaps->MinFrequency = 55250000L;
  296. pCaps->MaxFrequency = 997250000L;
  297. //
  298. // What is the frequency step size?
  299. //
  300. pCaps->TuningGranularity = 62500L;
  301. //
  302. // How many inputs are on the tuner?
  303. //
  304. pCaps->NumberOfInputs = 1;
  305. //
  306. // What is the maximum settling time in milliseconds?
  307. //
  308. pCaps->SettlingTime = 150;
  309. //
  310. // Strategy defines how the tuner knows when it is in tune:
  311. //
  312. // KS_TUNER_STRATEGY_PLL (Has PLL offset information)
  313. // KS_TUNER_STRATEGY_SIGNAL_STRENGTH (has signal strength info)
  314. // KS_TUNER_STRATEGY_DRIVER_TUNES (driver handles all fine tuning)
  315. //
  316. pCaps->Strategy = KS_TUNER_STRATEGY_PLL;
  317. pSrb->ActualBytesTransferred = sizeof( KSPROPERTY_TUNER_MODE_CAPS_S );
  318. }
  319. break;
  320. case KSPROPERTY_TUNER_STATUS:
  321. // Return the status of the tuner
  322. // PLLOffset is in units of TuningGranularity
  323. // SignalStrength is 0 to 100
  324. // Set Busy to 1 if tuning is still in process
  325. {
  326. PKSPROPERTY_TUNER_STATUS_S pStat =
  327. (PKSPROPERTY_TUNER_STATUS_S)pSPD->Property;
  328. ASSERT( nS >= sizeof( KSPROPERTY_TUNER_STATUS_S ) );
  329. // typedef struct {
  330. // KSPROPERTY Property;
  331. // ULONG CurrentFrequency; // Hz
  332. // ULONG PLLOffset; // if Strategy.KS_TUNER_STRATEGY_PLL
  333. // ULONG SignalStrength; // if Stretegy.KS_TUNER_STRATEGY_SIGNAL_STRENGTH
  334. // ULONG Busy; // TRUE if in the process of tuning
  335. // } KSPROPERTY_TUNER_STATUS_S, *PKSPROPERTY_TUNER_STATUS_S;
  336. // now work with the output buffer
  337. pStat = PKSPROPERTY_TUNER_STATUS_S( pV );
  338. pStat->PLLOffset = adapter->GetPllOffset( &pStat->Busy,
  339. pStat->CurrentFrequency );
  340. pSrb->ActualBytesTransferred = sizeof( KSPROPERTY_TUNER_STATUS_S );
  341. }
  342. break;
  343. case KSPROPERTY_TUNER_STANDARD:
  344. {
  345. PKSPROPERTY_TUNER_STANDARD_S pStd =
  346. (PKSPROPERTY_TUNER_STANDARD_S)pSPD->Property;
  347. ASSERT( nS >= sizeof( KSPROPERTY_TUNER_STANDARD_S ) );
  348. // now work with the output buffer
  349. pStd = PKSPROPERTY_TUNER_STANDARD_S( pV );
  350. pStd->Standard = KS_AnalogVideo_NTSC_M; // our TEMIC tuner supports this only
  351. pSrb->ActualBytesTransferred = sizeof( KSPROPERTY_TUNER_STANDARD_S );
  352. }
  353. break;
  354. case KSPROPERTY_TUNER_INPUT:
  355. {
  356. PKSPROPERTY_TUNER_INPUT_S pIn =
  357. (PKSPROPERTY_TUNER_INPUT_S)pSPD->Property;
  358. ASSERT( nS >= sizeof( KSPROPERTY_TUNER_INPUT_S ) );
  359. // now work with the output buffer
  360. pIn = PKSPROPERTY_TUNER_INPUT_S( pV );
  361. // What is the currently selected input?
  362. pIn->InputIndex = 0;
  363. pSrb->ActualBytesTransferred = sizeof( KSPROPERTY_TUNER_INPUT_S );
  364. }
  365. break;
  366. default:
  367. break;
  368. }
  369. pSrb->Status = STATUS_SUCCESS;
  370. }
  371. // -------------------------------------------------------------------
  372. // VideoProcAmp functions
  373. // -------------------------------------------------------------------
  374. VOID AdapterSetVideoProcAmpProperty( PHW_STREAM_REQUEST_BLOCK pSrb )
  375. {
  376. Trace t("AdapterSetVideoProcAmpProperty()");
  377. PHW_DEVICE_EXTENSION HwDeviceExtension =
  378. (PHW_DEVICE_EXTENSION) pSrb->HwDeviceExtension;
  379. PsDevice *adapter = HwDeviceExtension->psdevice;
  380. PSTREAM_PROPERTY_DESCRIPTOR pSPD = pSrb->CommandData.PropertyInfo;
  381. ULONG Id = pSPD->Property->Id; // index of the property
  382. PKSPROPERTY_VIDEOPROCAMP_S pS = (PKSPROPERTY_VIDEOPROCAMP_S) pSPD->PropertyInfo; // pointer to the data
  383. ASSERT (pSPD->PropertyOutputSize >= sizeof (KSPROPERTY_VIDEOPROCAMP_S));
  384. switch ( Id ) {
  385. case KSPROPERTY_VIDEOPROCAMP_BRIGHTNESS:
  386. adapter->SetBrightness( pS->Value );
  387. break;
  388. case KSPROPERTY_VIDEOPROCAMP_CONTRAST:
  389. adapter->SetContrast( pS->Value );
  390. break;
  391. case KSPROPERTY_VIDEOPROCAMP_HUE:
  392. adapter->SetHue( pS->Value );
  393. break;
  394. case KSPROPERTY_VIDEOPROCAMP_SATURATION:
  395. adapter->SetSaturation( pS->Value );
  396. break;
  397. default:
  398. break;
  399. }
  400. pSrb->Status = STATUS_SUCCESS;
  401. }
  402. /* Method: AdapterGetVideoProcAmpProperty
  403. * Purpose: Gets various video procamp properties
  404. */
  405. VOID AdapterGetVideoProcAmpProperty( PHW_STREAM_REQUEST_BLOCK pSrb )
  406. {
  407. Trace t("AdapterGetVideoProcAmpProperty()");
  408. PHW_DEVICE_EXTENSION HwDeviceExtension =
  409. (PHW_DEVICE_EXTENSION) pSrb->HwDeviceExtension;
  410. PsDevice *adapter = HwDeviceExtension->psdevice;
  411. PSTREAM_PROPERTY_DESCRIPTOR pSPD = pSrb->CommandData.PropertyInfo;
  412. ULONG Id = pSPD->Property->Id; // index of the property
  413. PKSPROPERTY_VIDEOPROCAMP_S pS = (PKSPROPERTY_VIDEOPROCAMP_S) pSPD->PropertyInfo; // pointer to the data
  414. ASSERT( pSPD->PropertyOutputSize >= sizeof( KSPROPERTY_VIDEOPROCAMP_S ) );
  415. switch ( Id ) {
  416. case KSPROPERTY_VIDEOPROCAMP_BRIGHTNESS:
  417. pS->Value = adapter->GetBrightness();
  418. pS->Flags = pS->Capabilities = KSPROPERTY_VIDEOPROCAMP_FLAGS_MANUAL;
  419. break;
  420. case KSPROPERTY_VIDEOPROCAMP_CONTRAST:
  421. pS->Value = adapter->GetContrast();
  422. pS->Flags = pS->Capabilities = KSPROPERTY_VIDEOPROCAMP_FLAGS_MANUAL;
  423. break;
  424. case KSPROPERTY_VIDEOPROCAMP_HUE:
  425. pS->Value = adapter->GetHue();
  426. pS->Flags = pS->Capabilities = KSPROPERTY_VIDEOPROCAMP_FLAGS_MANUAL;
  427. break;
  428. case KSPROPERTY_VIDEOPROCAMP_SATURATION:
  429. pS->Value = adapter->GetSaturation();
  430. pS->Flags = pS->Capabilities = KSPROPERTY_VIDEOPROCAMP_FLAGS_MANUAL;
  431. break;
  432. default:
  433. DebugOut((1, "*** AdapterGetVideoProcAmpProperty - KSPROPERTY_??? (%d) ***\n", Id));
  434. }
  435. pSrb->ActualBytesTransferred = sizeof( KSPROPERTY_VIDEOPROCAMP_S );
  436. pSrb->Status = STATUS_SUCCESS;
  437. }
  438. /* Method: AdapterSetVideoDecProperty
  439. * Purpose: Manipulates various video decoder properties
  440. * Input: SRB
  441. * Output: None
  442. */
  443. void AdapterSetVideoDecProperty( PHW_STREAM_REQUEST_BLOCK pSrb )
  444. {
  445. Trace t("AdapterSetVideoDecProperty()");
  446. PHW_DEVICE_EXTENSION HwDeviceExtension =
  447. (PHW_DEVICE_EXTENSION) pSrb->HwDeviceExtension;
  448. PsDevice *adapter = HwDeviceExtension->psdevice;
  449. PSTREAM_PROPERTY_DESCRIPTOR pSPD = pSrb->CommandData.PropertyInfo;
  450. ULONG Id = pSPD->Property->Id; // index of the property
  451. switch ( Id ) {
  452. case KSPROPERTY_VIDEODECODER_STANDARD: {
  453. PKSPROPERTY_VIDEODECODER_S pVDecStd =
  454. (PKSPROPERTY_VIDEODECODER_S)pSPD->PropertyInfo;
  455. adapter->SetFormat( pVDecStd->Value );
  456. }
  457. break;
  458. case KSPROPERTY_VIDEODECODER_STATUS:
  459. break;
  460. }
  461. }
  462. /* Method: AdapterGetVideoDecProperty
  463. * Purpose: Obtains various video decoder properties
  464. * Input: SRB
  465. * Output: None
  466. */
  467. void AdapterGetVideoDecProperty( PHW_STREAM_REQUEST_BLOCK pSrb )
  468. {
  469. Trace t("AdapterGetVideoDecProperty()");
  470. PHW_DEVICE_EXTENSION HwDeviceExtension =
  471. (PHW_DEVICE_EXTENSION) pSrb->HwDeviceExtension;
  472. PsDevice *adapter = HwDeviceExtension->psdevice;
  473. PSTREAM_PROPERTY_DESCRIPTOR pSPD = pSrb->CommandData.PropertyInfo;
  474. ULONG Id = pSPD->Property->Id; // index of the property
  475. switch ( Id ) {
  476. case KSPROPERTY_VIDEODECODER_CAPS: {
  477. PKSPROPERTY_VIDEODECODER_CAPS_S pVDecCaps =
  478. (PKSPROPERTY_VIDEODECODER_CAPS_S)pSPD->PropertyInfo;
  479. pVDecCaps->StandardsSupported = KS_AnalogVideo_NTSC_M;
  480. pVDecCaps->Capabilities =
  481. // KS_VIDEODECODER_FLAGS_CAN_DISABLE_OUTPUT |
  482. KS_VIDEODECODER_FLAGS_CAN_USE_VCR_LOCKING |
  483. KS_VIDEODECODER_FLAGS_CAN_INDICATE_LOCKED;
  484. pVDecCaps->SettlingTime = 10; // How long to delay after tuning
  485. // before locked indicator is valid
  486. pVDecCaps-> HSyncPerVSync = 6; // HSync per VSync
  487. pSrb->ActualBytesTransferred = sizeof (KSPROPERTY_VIDEODECODER_CAPS_S);
  488. }
  489. break;
  490. case KSPROPERTY_VIDEODECODER_STANDARD: {
  491. // Return the currently active analog video mode
  492. PKSPROPERTY_VIDEODECODER_S pVDecStd =
  493. (PKSPROPERTY_VIDEODECODER_S)pSPD->PropertyInfo;
  494. //pVDecStd->Value = GetSupportedStandards();
  495. pVDecStd->Value = KS_AnalogVideo_NTSC_M;
  496. pSrb->ActualBytesTransferred = sizeof (KSPROPERTY_VIDEODECODER_S);
  497. }
  498. break;
  499. case KSPROPERTY_VIDEODECODER_STATUS: {
  500. PKSPROPERTY_VIDEODECODER_STATUS_S pVDecStat =
  501. (PKSPROPERTY_VIDEODECODER_STATUS_S)pSPD->PropertyInfo;
  502. pVDecStat->NumberOfLines = adapter->GetFormat() == VFormat_NTSC ? 525 : 625;
  503. pVDecStat->SignalLocked = adapter->CaptureContrll_.PsDecoder_.IsDeviceInHLock();
  504. pSrb->ActualBytesTransferred = sizeof (KSPROPERTY_VIDEODECODER_S);
  505. }
  506. break;
  507. default:
  508. DebugOut((1, "*** AdapterGetVideoDecProperty - KSPROPERTY_??? (%d) ***\n", Id));
  509. }
  510. }
  511. // -------------------------------------------------------------------
  512. // TVAudio functions
  513. // -------------------------------------------------------------------
  514. /*
  515. ** AdapterSetTVAudioProperty ()
  516. **
  517. ** Handles Set operations on the TVAudio property set.
  518. ** Testcap uses this for demo purposes only.
  519. **
  520. ** Arguments:
  521. **
  522. ** pSRB -
  523. ** Pointer to the HW_STREAM_REQUEST_BLOCK
  524. **
  525. ** Returns:
  526. **
  527. ** Side Effects: none
  528. */
  529. ULONG gTVAudioMode = 0;
  530. VOID
  531. AdapterSetTVAudioProperty(
  532. PHW_STREAM_REQUEST_BLOCK pSrb
  533. )
  534. {
  535. PSTREAM_PROPERTY_DESCRIPTOR pSPD = pSrb->CommandData.PropertyInfo;
  536. ULONG Id = pSPD->Property->Id; // index of the property
  537. switch (Id) {
  538. case KSPROPERTY_TVAUDIO_MODE:
  539. {
  540. PKSPROPERTY_TVAUDIO_S pS = (PKSPROPERTY_TVAUDIO_S) pSPD->PropertyInfo;
  541. gTVAudioMode = pS->Mode;
  542. }
  543. break;
  544. default:
  545. break;
  546. }
  547. }
  548. /*
  549. ** AdapterGetTVAudioProperty ()
  550. **
  551. ** Handles Get operations on the TVAudio property set.
  552. ** Testcap uses this for demo purposes only.
  553. **
  554. ** Arguments:
  555. **
  556. ** pSRB -
  557. ** Pointer to the HW_STREAM_REQUEST_BLOCK
  558. **
  559. ** Returns:
  560. **
  561. ** Side Effects: none
  562. */
  563. VOID
  564. AdapterGetTVAudioProperty(
  565. PHW_STREAM_REQUEST_BLOCK pSrb
  566. )
  567. {
  568. PSTREAM_PROPERTY_DESCRIPTOR pSPD = pSrb->CommandData.PropertyInfo;
  569. ULONG Id = pSPD->Property->Id; // index of the property
  570. switch (Id) {
  571. case KSPROPERTY_TVAUDIO_CAPS:
  572. {
  573. DebugOut((1, "KSPROPERTY_TVAUDIO_CAPS\n"));
  574. PKSPROPERTY_TVAUDIO_CAPS_S pS = (PKSPROPERTY_TVAUDIO_CAPS_S) pSPD->PropertyInfo; // pointer to the data
  575. ASSERT (pSPD->PropertyOutputSize >= sizeof (KSPROPERTY_TVAUDIO_CAPS_S));
  576. pS->InputMedium = TVAudioMediums[0];
  577. pS->InputMedium.Id = 0; //(ULONG) pHwDevExt; // Multiple instance support
  578. pS->OutputMedium = TVAudioMediums[1];
  579. pS->OutputMedium.Id = 0; //(ULONG) pHwDevExt; // Multiple instance support
  580. // Report all of the possible audio decoding modes the hardware is capabable of
  581. pS->Capabilities = KS_TVAUDIO_MODE_MONO |
  582. KS_TVAUDIO_MODE_STEREO |
  583. KS_TVAUDIO_MODE_LANG_A |
  584. KS_TVAUDIO_MODE_LANG_B ;
  585. pSrb->ActualBytesTransferred = sizeof (KSPROPERTY_TVAUDIO_CAPS_S);
  586. }
  587. break;
  588. case KSPROPERTY_TVAUDIO_MODE:
  589. {
  590. DebugOut((1, "KSPROPERTY_TVAUDIO_MODE\n"));
  591. PKSPROPERTY_TVAUDIO_S pS = (PKSPROPERTY_TVAUDIO_S) pSPD->PropertyInfo; // pointer to the data
  592. ASSERT (pSPD->PropertyOutputSize >= sizeof (KSPROPERTY_TVAUDIO_S));
  593. // Report the currently selected mode
  594. pS->Mode = gTVAudioMode;
  595. pSrb->ActualBytesTransferred = sizeof (KSPROPERTY_TVAUDIO_S);
  596. }
  597. break;
  598. case KSPROPERTY_TVAUDIO_CURRENTLY_AVAILABLE_MODES:
  599. {
  600. DebugOut((1, "KSPROPERTY_TVAUDIO_CURRENTLY_AVAILABLE_MODES\n"));
  601. PKSPROPERTY_TVAUDIO_S pS = (PKSPROPERTY_TVAUDIO_S) pSPD->PropertyInfo; // pointer to the data
  602. ASSERT (pSPD->PropertyOutputSize >= sizeof (KSPROPERTY_TVAUDIO_S));
  603. // Report which audio modes could potentially be selected right now
  604. pS->Mode = KS_TVAUDIO_MODE_MONO |
  605. KS_TVAUDIO_MODE_STEREO |
  606. KS_TVAUDIO_MODE_LANG_A ;
  607. pSrb->ActualBytesTransferred = sizeof (KSPROPERTY_TVAUDIO_S);
  608. }
  609. break;
  610. default:
  611. DebugOut((0, "default - unrecognized (%x)\n", Id));
  612. break;
  613. }
  614. }
  615. /* Method: AdapterSetProperty
  616. * Purpose: Selects which adapter property to set
  617. */
  618. VOID AdapterSetProperty( PHW_STREAM_REQUEST_BLOCK pSrb )
  619. {
  620. Trace t("AdapterSetProperty()");
  621. PHW_DEVICE_EXTENSION HwDeviceExtension =
  622. (PHW_DEVICE_EXTENSION) pSrb->HwDeviceExtension;
  623. PsDevice *adapter = HwDeviceExtension->psdevice;
  624. PSTREAM_PROPERTY_DESCRIPTOR pSPD = pSrb->CommandData.PropertyInfo;
  625. if ( IsEqualGUID( PROPSETID_VIDCAP_CROSSBAR, pSPD->Property->Set ) ) {
  626. AdapterSetCrossbarProperty( pSrb );
  627. } else if ( IsEqualGUID( PROPSETID_TUNER, pSPD->Property->Set ) ) {
  628. AdapterSetTunerProperty( pSrb );
  629. } else if ( IsEqualGUID( PROPSETID_VIDCAP_VIDEOPROCAMP, pSPD->Property->Set ) ) {
  630. AdapterSetVideoProcAmpProperty( pSrb );
  631. } else if ( IsEqualGUID( PROPSETID_VIDCAP_VIDEODECODER, pSPD->Property->Set ) ) {
  632. AdapterSetVideoDecProperty( pSrb );
  633. } else if (IsEqualGUID( PROPSETID_VIDCAP_TVAUDIO, pSPD->Property->Set)) {
  634. AdapterSetTVAudioProperty( pSrb );
  635. } else {
  636. DebugOut((0, "AdapterSetProperty unrecognized GUID: pSrb(%x), pSPD->Property->Set(%x)\n", pSrb, pSPD->Property->Set));
  637. }
  638. }
  639. /* Method: AdapterGetProperty
  640. * Purpose: Selects which adapter property to get
  641. */
  642. VOID AdapterGetProperty( PHW_STREAM_REQUEST_BLOCK pSrb )
  643. {
  644. Trace t("AdapterGetProperty()");
  645. PHW_DEVICE_EXTENSION HwDeviceExtension =
  646. (PHW_DEVICE_EXTENSION) pSrb->HwDeviceExtension;
  647. PsDevice *adapter = HwDeviceExtension->psdevice;
  648. PSTREAM_PROPERTY_DESCRIPTOR pSPD = pSrb->CommandData.PropertyInfo;
  649. if ( IsEqualGUID( PROPSETID_VIDCAP_CROSSBAR, pSPD->Property->Set ) ) {
  650. AdapterGetCrossbarProperty( pSrb );
  651. } else if ( IsEqualGUID( PROPSETID_TUNER, pSPD->Property->Set ) ) {
  652. AdapterGetTunerProperty( pSrb );
  653. } else if ( IsEqualGUID( PROPSETID_VIDCAP_VIDEOPROCAMP, pSPD->Property->Set ) ) {
  654. AdapterGetVideoProcAmpProperty( pSrb );
  655. } else if ( IsEqualGUID( PROPSETID_VIDCAP_VIDEODECODER, pSPD->Property->Set ) ) {
  656. AdapterGetVideoDecProperty( pSrb );
  657. } else if (IsEqualGUID( PROPSETID_VIDCAP_TVAUDIO, pSPD->Property->Set)) {
  658. AdapterGetTVAudioProperty( pSrb );
  659. } else {
  660. DebugOut((0, "AdapterGetProperty unrecognized GUID: pSrb(%x), pSPD->Property->Set(%x)\n", pSrb, pSPD->Property->Set));
  661. }
  662. }