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.

576 lines
21 KiB

  1. //==========================================================================;
  2. //
  3. // WDMXBar.CPP
  4. // WDM Audio/Video CrossBar MiniDriver.
  5. // AIW Hardware platform.
  6. // CWDMAVXBar class implementation.
  7. // Copyright (c) 1996 - 1997 ATI Technologies Inc. All Rights Reserved.
  8. //
  9. //==========================================================================;
  10. extern "C"
  11. {
  12. #include "strmini.h"
  13. #include "ksmedia.h"
  14. #include "wdmdebug.h"
  15. }
  16. #include "atixbar.h"
  17. #include "wdmdrv.h"
  18. #include "aticonfg.h"
  19. /*^^*
  20. * AdapterCompleteInitialization()
  21. * Purpose : Called when SRB_COMPLETE_INITIALIZATION SRB is received.
  22. *
  23. * Inputs : PHW_STREAM_REQUEST_BLOCK pSrb : pointer to the current Srb
  24. *
  25. * Outputs : BOOL : returns TRUE
  26. * Author : IKLEBANOV
  27. *^^*/
  28. NTSTATUS CWDMAVXBar::AdapterCompleteInitialization( PHW_STREAM_REQUEST_BLOCK pSrb)
  29. {
  30. PADAPTER_DATA_EXTENSION pPrivateData = ( PADAPTER_DATA_EXTENSION)( pSrb->HwDeviceExtension);
  31. NTSTATUS ntStatus;
  32. ULONG nPinsNumber;
  33. nPinsNumber = m_nNumberOfVideoInputs + m_nNumberOfAudioInputs +
  34. m_nNumberOfVideoOutputs + m_nNumberOfAudioOutputs;
  35. ENSURE
  36. {
  37. ntStatus = StreamClassRegisterFilterWithNoKSPins( \
  38. pPrivateData->PhysicalDeviceObject, // IN PDEVICE_OBJECT DeviceObject,
  39. &KSCATEGORY_CROSSBAR, // IN GUID * InterfaceClassGUID
  40. nPinsNumber, // IN ULONG PinCount,
  41. m_pXBarPinsDirectionInfo, // IN ULONG * Flags,
  42. m_pXBarPinsMediumInfo, // IN KSPIN_MEDIUM * MediumList,
  43. NULL); // IN GUID * CategoryList
  44. if( !NT_SUCCESS( ntStatus))
  45. FAIL;
  46. OutputDebugTrace(( "CWDMAVXBar:AdapterCompleteInitialization() exit\n"));
  47. } END_ENSURE;
  48. if( !NT_SUCCESS( ntStatus))
  49. OutputDebugError(( "CWDMAVXBar:AdapterCompleteInitialization() ntStatus=%x\n", ntStatus));
  50. return( ntStatus);
  51. }
  52. /*^^*
  53. * AdapterUnInitialize()
  54. * Purpose : Called when SRB_UNINITIALIZE_DEVICE SRB is received.
  55. *
  56. * Inputs : PHW_STREAM_REQUEST_BLOCK pSrb : pointer to the current Srb
  57. *
  58. * Outputs : BOOL : returns TRUE
  59. * Author : IKLEBANOV
  60. *^^*/
  61. BOOL CWDMAVXBar::AdapterUnInitialize( PHW_STREAM_REQUEST_BLOCK pSrb)
  62. {
  63. OutputDebugTrace(( "CWDMAVXBar:AdapterUnInitialize()\n"));
  64. if( m_pXBarInputPinsInfo != NULL)
  65. {
  66. ::ExFreePool( m_pXBarInputPinsInfo);
  67. m_pXBarInputPinsInfo = NULL;
  68. }
  69. if( m_pXBarPinsMediumInfo != NULL)
  70. {
  71. ::ExFreePool( m_pXBarPinsMediumInfo);
  72. m_pXBarPinsMediumInfo = NULL;
  73. }
  74. if( m_pXBarPinsDirectionInfo != NULL)
  75. {
  76. ::ExFreePool( m_pXBarPinsDirectionInfo);
  77. m_pXBarPinsDirectionInfo = NULL;
  78. }
  79. pSrb->Status = STATUS_SUCCESS;
  80. return( TRUE);
  81. }
  82. /*^^*
  83. * AdapterGetStreamInfo()
  84. * Purpose : Calles during StreamClass initialization procedure to get the information
  85. * about data streams exposed by the MiniDriver
  86. *
  87. * Inputs : PHW_STREAM_REQUEST_BLOCK pSrb : pointer to the current Srb
  88. *
  89. * Outputs : BOOL : returns TRUE
  90. * Author : IKLEBANOV
  91. *^^*/
  92. BOOL CWDMAVXBar::AdapterGetStreamInfo( PHW_STREAM_REQUEST_BLOCK pSrb)
  93. {
  94. // pick up the pointer to the stream header data structure
  95. PHW_STREAM_HEADER pStreamHeader = ( PHW_STREAM_HEADER) \
  96. &( pSrb->CommandData.StreamBuffer->StreamHeader);
  97. // pick up the pointer to the stream information data structure
  98. PHW_STREAM_INFORMATION pStreamInfo = ( PHW_STREAM_INFORMATION) \
  99. &( pSrb->CommandData.StreamBuffer->StreamInfo);
  100. // no streams are supported
  101. DEBUG_ASSERT( pSrb->NumberOfBytesToTransfer >= sizeof( HW_STREAM_HEADER));
  102. OutputDebugTrace(( "CWDMAVXBar:AdapterGetStreamInfo()\n"));
  103. m_wdmAVXBarStreamHeader.NumberOfStreams = 0;
  104. m_wdmAVXBarStreamHeader.SizeOfHwStreamInformation = sizeof( HW_STREAM_INFORMATION);
  105. m_wdmAVXBarStreamHeader.NumDevPropArrayEntries = KSPROPERTIES_AVXBAR_NUMBER_SET;
  106. m_wdmAVXBarStreamHeader.DevicePropertiesArray = m_wdmAVXBarPropertySet;
  107. m_wdmAVXBarStreamHeader.NumDevEventArrayEntries = 0;
  108. m_wdmAVXBarStreamHeader.DeviceEventsArray = NULL;
  109. m_wdmAVXBarStreamHeader.Topology = &m_wdmAVXBarTopology;
  110. * pStreamHeader = m_wdmAVXBarStreamHeader;
  111. pSrb->Status = STATUS_SUCCESS;
  112. return( TRUE);
  113. }
  114. /*^^*
  115. * AdapterQueryUnload()
  116. * Purpose : Called when the class driver is about to unload the MiniDriver
  117. * The MiniDriver checks if any open stream left.
  118. *
  119. * Inputs : PHW_STREAM_REQUEST_BLOCK pSrb : pointer to the current Srb
  120. *
  121. * Outputs : BOOL : returns TRUE
  122. * Author : IKLEBANOV
  123. *^^*/
  124. BOOL CWDMAVXBar::AdapterQueryUnload( PHW_STREAM_REQUEST_BLOCK pSrb)
  125. {
  126. OutputDebugTrace(( "CWDMAVXBar:AdapterQueryUnload()\n"));
  127. pSrb->Status = STATUS_SUCCESS;
  128. return( TRUE);
  129. }
  130. /*^^*
  131. * operator new
  132. * Purpose : CWDMAVXBar class overloaded operator new.
  133. * Provides placement for a CWDMAVXBar class object from the PADAPTER_DEVICE_EXTENSION
  134. * allocated by the StreamClassDriver for the MiniDriver.
  135. *
  136. * Inputs : UINT size_t : size of the object to be placed
  137. * PVOID pAllocation : casted pointer to the CWDMAVXBar allocated data
  138. *
  139. * Outputs : PVOID : pointer of the CWDMAVXBar class object
  140. * Author : IKLEBANOV
  141. *^^*/
  142. PVOID CWDMAVXBar::operator new( size_t size_t, PVOID pAllocation)
  143. {
  144. if( size_t != sizeof( CWDMAVXBar))
  145. {
  146. OutputDebugTrace(( "CWDMAVXBar: operator new() fails\n"));
  147. return( NULL);
  148. }
  149. else
  150. return( pAllocation);
  151. }
  152. /*^^*
  153. * ~CWDMAVXBar()
  154. * Purpose : CWDMAVXBar class destructor.
  155. * Frees the allocated memory.
  156. *
  157. * Inputs : none
  158. *
  159. * Outputs : none
  160. * Author : IKLEBANOV
  161. *^^*/
  162. CWDMAVXBar::~CWDMAVXBar()
  163. {
  164. OutputDebugTrace(( "CWDMAVXBar:~CWDMAVXBar() m_pXBarPinsInfo = %x\n", m_pXBarInputPinsInfo));
  165. if( m_pXBarInputPinsInfo != NULL)
  166. {
  167. ::ExFreePool( m_pXBarInputPinsInfo);
  168. m_pXBarInputPinsInfo = NULL;
  169. }
  170. if( m_pXBarPinsMediumInfo != NULL)
  171. {
  172. ::ExFreePool( m_pXBarPinsMediumInfo);
  173. m_pXBarPinsMediumInfo = NULL;
  174. }
  175. if( m_pXBarPinsDirectionInfo != NULL)
  176. {
  177. ::ExFreePool( m_pXBarPinsDirectionInfo);
  178. m_pXBarPinsDirectionInfo = NULL;
  179. }
  180. }
  181. /*^^*
  182. * CWDMAVXBar()
  183. * Purpose : CWDMAVXBar class constructor.
  184. * Performs checking of the hardware presence. Sets the hardware in an initial state.
  185. *
  186. * Inputs : CI2CScript * pCScript : pointer to the I2CScript class object
  187. * PUINT puiError : pointer to return a completion error code
  188. *
  189. * Outputs : none
  190. * Author : IKLEBANOV
  191. *^^*/
  192. CWDMAVXBar::CWDMAVXBar( PPORT_CONFIGURATION_INFORMATION pConfigInfo, CI2CScript * pCScript, PUINT puiErrorCode)
  193. :m_CATIConfiguration( pConfigInfo, pCScript, puiErrorCode)
  194. {
  195. UINT uiError;
  196. ULONG ulInstance;
  197. HANDLE hFolder = NULL;
  198. OutputDebugTrace(( "CWDMAVXBar:CWDMAVXBar() enter\n"));
  199. m_pXBarInputPinsInfo = m_pXBarOutputPinsInfo = NULL;
  200. m_pXBarPinsMediumInfo = NULL;
  201. m_pXBarPinsDirectionInfo = NULL;
  202. m_ulPowerState = PowerDeviceD0;
  203. // error code was caried over from ATIConfiguration class constructor
  204. uiError = * puiErrorCode;
  205. ENSURE
  206. {
  207. ULONG ulNumberOfPins, nPinIndex;
  208. UINT uiTunerId, nIndex;
  209. UCHAR uchTunerAddress;
  210. KSPIN_MEDIUM mediumKSPin;
  211. const KSPIN_MEDIUM * pMediumKSPin;
  212. if( uiError != WDMMINI_NOERROR)
  213. FAIL;
  214. if( pCScript == NULL)
  215. {
  216. uiError = WDMMINI_INVALIDPARAM;
  217. FAIL;
  218. }
  219. // first, find out whether any tuner type is installed. If not, we have only 2 video sources.
  220. m_CATIConfiguration.GetTunerConfiguration( &uiTunerId, &uchTunerAddress);
  221. m_nNumberOfVideoInputs = ( uchTunerAddress) ? 3 : 2;
  222. m_nNumberOfVideoOutputs = m_nNumberOfVideoInputs;
  223. m_CATIConfiguration.GetAudioProperties( &m_nNumberOfAudioInputs, &m_nNumberOfAudioOutputs);
  224. if( !uchTunerAddress)
  225. // if there is no tuner - no TVAudio input
  226. m_nNumberOfAudioInputs --;
  227. ulNumberOfPins = m_nNumberOfAudioInputs + m_nNumberOfVideoInputs + m_nNumberOfVideoOutputs + m_nNumberOfAudioOutputs;
  228. m_pXBarInputPinsInfo = ( PXBAR_PIN_INFORMATION) \
  229. ::ExAllocatePool( NonPagedPool, sizeof( XBAR_PIN_INFORMATION) * ulNumberOfPins);
  230. if( m_pXBarInputPinsInfo == NULL)
  231. {
  232. uiError = WDMMINI_ERROR_MEMORYALLOCATION;
  233. FAIL;
  234. }
  235. m_pXBarPinsMediumInfo = ( PKSPIN_MEDIUM) \
  236. ::ExAllocatePool( NonPagedPool, sizeof( KSPIN_MEDIUM) * ulNumberOfPins);
  237. if( m_pXBarPinsMediumInfo == NULL)
  238. {
  239. uiError = WDMMINI_ERROR_MEMORYALLOCATION;
  240. FAIL;
  241. }
  242. m_pXBarPinsDirectionInfo = ( PBOOL) \
  243. ::ExAllocatePool( NonPagedPool, sizeof( BOOL) * ulNumberOfPins);
  244. if( m_pXBarPinsDirectionInfo == NULL)
  245. {
  246. uiError = WDMMINI_ERROR_MEMORYALLOCATION;
  247. FAIL;
  248. }
  249. m_pI2CScript = pCScript;
  250. m_pXBarOutputPinsInfo = &m_pXBarInputPinsInfo[m_nNumberOfAudioInputs + m_nNumberOfVideoInputs];
  251. // Medium pin data has an Instance number inside
  252. ulInstance = ::GetDriverInstanceNumber( pConfigInfo->RealPhysicalDeviceObject);
  253. hFolder = ::OpenRegistryFolder( pConfigInfo->RealPhysicalDeviceObject, &UNICODE_WDM_REG_PIN_MEDIUMS);
  254. // initialize video input pins, TVTuner input is always the last one
  255. for( nIndex = 0; nIndex < m_nNumberOfVideoInputs; nIndex ++)
  256. {
  257. switch( nIndex)
  258. {
  259. case 0:
  260. // Composite
  261. m_pXBarInputPinsInfo[nIndex].AudioVideoPinType = KS_PhysConn_Video_Composite;
  262. // put the default value for the Medium first
  263. ::RtlCopyMemory( &m_pXBarPinsMediumInfo[nIndex], &MEDIUM_WILDCARD, sizeof( KSPIN_MEDIUM));
  264. // LineIn is always the first audio pin
  265. m_pXBarInputPinsInfo[nIndex].nRelatedPinNumber = m_nNumberOfVideoInputs;
  266. break;
  267. case 1:
  268. // SVideo
  269. m_pXBarInputPinsInfo[nIndex].AudioVideoPinType = KS_PhysConn_Video_SVideo;
  270. // put the default value for the Medium first
  271. ::RtlCopyMemory( &m_pXBarPinsMediumInfo[nIndex], &MEDIUM_WILDCARD, sizeof( KSPIN_MEDIUM));
  272. // LineIn is always the first audio pin
  273. m_pXBarInputPinsInfo[nIndex].nRelatedPinNumber = m_nNumberOfVideoInputs;
  274. break;
  275. case 2:
  276. // TVTuner
  277. m_pXBarInputPinsInfo[nIndex].AudioVideoPinType = KS_PhysConn_Video_Tuner;
  278. // put the default value for the Medium first
  279. ::RtlCopyMemory( &m_pXBarPinsMediumInfo[nIndex], &ATIXBarVideoTunerInMedium, sizeof( KSPIN_MEDIUM));
  280. // TVAudio is always the last audio pin
  281. m_pXBarInputPinsInfo[nIndex].nRelatedPinNumber = m_nNumberOfVideoInputs + m_nNumberOfAudioInputs - 1;
  282. break;
  283. default:
  284. TRAP;
  285. break;
  286. }
  287. // let's put another Medium value from the registry, if present
  288. if( ::ReadPinMediumFromRegistryFolder( hFolder, nIndex, &mediumKSPin))
  289. ::RtlCopyMemory( &m_pXBarPinsMediumInfo[nIndex], &mediumKSPin, sizeof( KSPIN_MEDIUM));
  290. m_pXBarInputPinsInfo[nIndex].pMedium = &m_pXBarPinsMediumInfo[nIndex];
  291. m_pXBarPinsMediumInfo[nIndex].Id = ulInstance;
  292. // all the pins here are inputs
  293. m_pXBarPinsDirectionInfo[nIndex] = FALSE;
  294. }
  295. // initialize audio input pins, TV Audio input is always the last one
  296. for( nIndex = 0; nIndex < m_nNumberOfAudioInputs; nIndex ++)
  297. {
  298. nPinIndex = nIndex + m_nNumberOfVideoInputs;
  299. switch( nIndex)
  300. {
  301. case 0:
  302. m_pXBarInputPinsInfo[nPinIndex].AudioVideoPinType = KS_PhysConn_Audio_Line;
  303. // put the default value for the Medium first
  304. ::RtlCopyMemory( &m_pXBarPinsMediumInfo[nPinIndex], &MEDIUM_WILDCARD, sizeof( KSPIN_MEDIUM));
  305. m_pXBarInputPinsInfo[nPinIndex].nRelatedPinNumber = 0;
  306. break;
  307. case 1:
  308. m_pXBarInputPinsInfo[nPinIndex].AudioVideoPinType = KS_PhysConn_Audio_Tuner;
  309. // put the default value for the Medium first
  310. ::RtlCopyMemory( &m_pXBarPinsMediumInfo[nPinIndex], &ATIXBarAudioTunerInMedium, sizeof( KSPIN_MEDIUM));
  311. m_pXBarInputPinsInfo[nPinIndex].nRelatedPinNumber = m_nNumberOfVideoInputs - 1;
  312. break;
  313. default:
  314. TRAP;
  315. break;
  316. }
  317. // let's put another Medium value from the registry, if present
  318. if( ::ReadPinMediumFromRegistryFolder( hFolder, nPinIndex, &mediumKSPin))
  319. ::RtlCopyMemory( &m_pXBarPinsMediumInfo[nPinIndex], &mediumKSPin, sizeof( KSPIN_MEDIUM));
  320. m_pXBarInputPinsInfo[nPinIndex].pMedium = &m_pXBarPinsMediumInfo[nPinIndex];
  321. m_pXBarPinsMediumInfo[nPinIndex].Id = ulInstance;
  322. // all the pins here are inputs
  323. m_pXBarPinsDirectionInfo[nPinIndex] = FALSE;
  324. }
  325. // initialize outputs video pins, no X-connection for Video
  326. for( nIndex = 0; nIndex < m_nNumberOfVideoOutputs; nIndex ++)
  327. {
  328. nPinIndex = nIndex + m_nNumberOfVideoInputs + m_nNumberOfAudioInputs;
  329. m_pXBarOutputPinsInfo[nIndex].AudioVideoPinType = m_pXBarInputPinsInfo[nIndex].AudioVideoPinType;
  330. m_pXBarOutputPinsInfo[nIndex].nConnectedToPin = nIndex;
  331. m_pXBarOutputPinsInfo[nIndex].nRelatedPinNumber = m_nNumberOfVideoOutputs; // jaybo
  332. switch( m_pXBarOutputPinsInfo[nIndex].AudioVideoPinType)
  333. {
  334. case KS_PhysConn_Video_Tuner:
  335. pMediumKSPin = &ATIXBarVideoTunerOutMedium;
  336. break;
  337. case KS_PhysConn_Video_SVideo:
  338. pMediumKSPin = &ATIXBarVideoSVideoOutMedium;
  339. break;
  340. case KS_PhysConn_Video_Composite:
  341. pMediumKSPin = &ATIXBarVideoCompositeOutMedium;
  342. break;
  343. default:
  344. pMediumKSPin = &MEDIUM_WILDCARD;
  345. break;
  346. }
  347. ::RtlCopyMemory( &m_pXBarPinsMediumInfo[nPinIndex], pMediumKSPin, sizeof( KSPIN_MEDIUM));
  348. // let's put another Medium value from the registry, if present
  349. if( ::ReadPinMediumFromRegistryFolder( hFolder, nPinIndex, &mediumKSPin))
  350. ::RtlCopyMemory( &m_pXBarPinsMediumInfo[nPinIndex], &mediumKSPin, sizeof( KSPIN_MEDIUM));
  351. m_pXBarOutputPinsInfo[nIndex].pMedium = &m_pXBarPinsMediumInfo[nPinIndex];
  352. m_pXBarPinsMediumInfo[nPinIndex].Id = ulInstance;
  353. // all the pins here are outputs
  354. m_pXBarPinsDirectionInfo[nPinIndex] = TRUE;
  355. }
  356. // initialize outputs audio pins
  357. for( nIndex = 0; nIndex < m_nNumberOfAudioOutputs; nIndex ++)
  358. {
  359. nPinIndex = nIndex + m_nNumberOfVideoInputs + m_nNumberOfAudioInputs + m_nNumberOfVideoOutputs;
  360. m_pXBarOutputPinsInfo[nIndex + m_nNumberOfVideoInputs].AudioVideoPinType = KS_PhysConn_Audio_AudioDecoder;
  361. // put the default value for the Medium first
  362. /* jaybo
  363. ::RtlCopyMemory( &m_pXBarPinsMediumInfo[nPinIndex], ATIXBarAudioDecoderOutMedium, sizeof( KSPIN_MEDIUM));
  364. */
  365. ::RtlCopyMemory( &m_pXBarPinsMediumInfo[nPinIndex], &MEDIUM_WILDCARD, sizeof( KSPIN_MEDIUM));
  366. // let's put another Medium value from the registry, if present
  367. if( ::ReadPinMediumFromRegistryFolder( hFolder, nPinIndex, &mediumKSPin))
  368. ::RtlCopyMemory( &m_pXBarPinsMediumInfo[nPinIndex], &mediumKSPin, sizeof( KSPIN_MEDIUM));
  369. m_pXBarOutputPinsInfo[nIndex + m_nNumberOfVideoInputs].nConnectedToPin = ( ULONG)-1;
  370. m_pXBarOutputPinsInfo[nIndex + m_nNumberOfVideoInputs].nRelatedPinNumber = (ULONG)-1;
  371. m_pXBarOutputPinsInfo[nIndex + m_nNumberOfVideoInputs].pMedium = &m_pXBarPinsMediumInfo[nPinIndex];
  372. m_pXBarPinsMediumInfo[nPinIndex].Id = ulInstance;
  373. // all the pins here are outputs
  374. m_pXBarPinsDirectionInfo[nPinIndex] = TRUE;
  375. }
  376. if( hFolder != NULL)
  377. ::ZwClose( hFolder);
  378. // mute the audio as the default power-up behaviour
  379. m_CATIConfiguration.ConnectAudioSource( m_pI2CScript, AUDIOSOURCE_MUTE);
  380. // these two functions has to be called after the CWDMAVXBar class object was build on
  381. // on the stack and copied over into the DeviceExtension
  382. // This commant was true for the case, where the class object was build on the stack first.
  383. // There is an overloaded operator new provided for this class, and we can call it from here
  384. SetWDMAVXBarKSProperties();
  385. SetWDMAVXBarKSTopology();
  386. // Set run-time WDM properties at the last
  387. * puiErrorCode = WDMMINI_NOERROR;
  388. OutputDebugTrace(( "CWDMAVXBar:CWDMAVXBar() exit\n"));
  389. return;
  390. } END_ENSURE;
  391. * puiErrorCode = uiError;
  392. OutputDebugError(( "CWDMAVXBar:CWDMAVXBar() Error = %x\n", uiError));
  393. }
  394. /*^^*
  395. * AdapterSetPowerState()
  396. * Purpose : Sets Power Management state for deviec
  397. *
  398. * Inputs : PHW_STREAM_REQUEST_BLOCK pSrb : pointer to the current Srb
  399. *
  400. * Outputs : NTSTATUS as the operation result
  401. * Author : TOM
  402. *^^*/
  403. NTSTATUS CWDMAVXBar::AdapterSetPowerState( PHW_STREAM_REQUEST_BLOCK pSrb)
  404. {
  405. ULONG nAudioSource;
  406. ULONG nInputPin;
  407. NTSTATUS ntStatus;
  408. UINT nIndex;
  409. DEVICE_POWER_STATE nDeviceState = pSrb->CommandData.DeviceState;
  410. ntStatus = STATUS_ADAPTER_HARDWARE_ERROR;
  411. switch( nDeviceState)
  412. {
  413. case PowerDeviceD0:
  414. case PowerDeviceD3:
  415. if( nDeviceState != m_ulPowerState)
  416. {
  417. // if transition form D3 to D0 we have to restore audio connections
  418. if(( nDeviceState == PowerDeviceD0) && ( m_ulPowerState == PowerDeviceD3))
  419. {
  420. for( nIndex = 0; nIndex < m_nNumberOfAudioOutputs; nIndex ++)
  421. {
  422. // we need to restore every audio output pin connection,
  423. // video output pins are hardwired
  424. nInputPin = m_pXBarOutputPinsInfo[nIndex + m_nNumberOfVideoOutputs].nConnectedToPin;
  425. switch( m_pXBarInputPinsInfo[nInputPin].AudioVideoPinType)
  426. {
  427. case KS_PhysConn_Audio_Line:
  428. nAudioSource = AUDIOSOURCE_LINEIN;
  429. break;
  430. case KS_PhysConn_Audio_Tuner:
  431. nAudioSource = AUDIOSOURCE_TVAUDIO;
  432. break;
  433. case 0xFFFFFFFF:
  434. nAudioSource = AUDIOSOURCE_MUTE;
  435. return( STATUS_SUCCESS);
  436. default:
  437. OutputDebugError(( "CWDMAVXBar:AdapterSetPowerState() Audio Pin type=%x\n", m_pXBarInputPinsInfo[nInputPin].AudioVideoPinType));
  438. return STATUS_SUCCESS;
  439. }
  440. if( m_CATIConfiguration.ConnectAudioSource( m_pI2CScript, nAudioSource))
  441. ntStatus = STATUS_SUCCESS;
  442. else
  443. {
  444. // error
  445. ntStatus = STATUS_ADAPTER_HARDWARE_ERROR;
  446. break;
  447. }
  448. }
  449. }
  450. else
  451. ntStatus = STATUS_SUCCESS;
  452. }
  453. else
  454. ntStatus = STATUS_SUCCESS;
  455. m_ulPowerState = nDeviceState;
  456. break;
  457. case PowerDeviceUnspecified:
  458. case PowerDeviceD1:
  459. case PowerDeviceD2:
  460. ntStatus = STATUS_SUCCESS;
  461. break;
  462. default:
  463. ntStatus = STATUS_INVALID_PARAMETER;
  464. break;
  465. }
  466. return( ntStatus);
  467. }