⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 wdmxbar.cpp

📁 ATI显卡Windows驱动
💻 CPP
📖 第 1 页 / 共 2 页
字号:
			FAIL;
		}

		m_pXBarPinsMediumInfo = ( PKSPIN_MEDIUM) \
			::ExAllocatePool( NonPagedPool, sizeof( KSPIN_MEDIUM) * ulNumberOfPins);
		if( m_pXBarPinsMediumInfo == NULL)
		{
			uiError = WDMMINI_ERROR_MEMORYALLOCATION;
			FAIL;
		}
		
		m_pXBarPinsDirectionInfo = ( PBOOL) \
			::ExAllocatePool( NonPagedPool, sizeof( BOOL) * ulNumberOfPins);
		if( m_pXBarPinsDirectionInfo == NULL)
		{
			uiError = WDMMINI_ERROR_MEMORYALLOCATION;
			FAIL;
		}

		m_pI2CScript = pCScript;

		m_pXBarOutputPinsInfo = &m_pXBarInputPinsInfo[m_nNumberOfAudioInputs + m_nNumberOfVideoInputs];

		// Medium pin data has an Instance number inside
		ulInstance = ::GetDriverInstanceNumber( pDeviceObject);

		hFolder = ::OpenRegistryFolder( pDeviceObject, &UNICODE_WDM_REG_PIN_MEDIUMS);
		
		// initialize video input pins, TVTuner input is always the last one
		for( nIndex = 0; nIndex < m_nNumberOfVideoInputs; nIndex ++)
		{
			switch( nIndex)
			{
				case 0:
					// Composite
					m_pXBarInputPinsInfo[nIndex].AudioVideoPinType = KS_PhysConn_Video_Composite;
					// put the default value for the Medium first
					::RtlCopyMemory( &m_pXBarPinsMediumInfo[nIndex], &MEDIUM_WILDCARD, sizeof( KSPIN_MEDIUM));
					// LineIn is always the first audio pin
					m_pXBarInputPinsInfo[nIndex].nRelatedPinNumber = m_nNumberOfVideoInputs;
					break;

				case 1:
					// SVideo
					m_pXBarInputPinsInfo[nIndex].AudioVideoPinType = KS_PhysConn_Video_SVideo;
					// put the default value for the Medium first
					::RtlCopyMemory( &m_pXBarPinsMediumInfo[nIndex], &MEDIUM_WILDCARD, sizeof( KSPIN_MEDIUM));
					// LineIn is always the first audio pin
					m_pXBarInputPinsInfo[nIndex].nRelatedPinNumber = m_nNumberOfVideoInputs;
					break;

				case 2:
					// TVTuner
					m_pXBarInputPinsInfo[nIndex].AudioVideoPinType = KS_PhysConn_Video_Tuner;
					// put the default value for the Medium first
					::RtlCopyMemory( &m_pXBarPinsMediumInfo[nIndex], &ATIXBarVideoTunerInMedium, sizeof( KSPIN_MEDIUM));
					// TVAudio is always the last audio pin
					m_pXBarInputPinsInfo[nIndex].nRelatedPinNumber = m_nNumberOfVideoInputs + m_nNumberOfAudioInputs - 1;
					break;

				default:
					TRAP;
					break;
			}

			// let's put another Medium value from the registry, if present
			if( ::ReadPinMediumFromRegistryFolder( hFolder, nIndex, &mediumKSPin))
				::RtlCopyMemory( &m_pXBarPinsMediumInfo[nIndex], &mediumKSPin, sizeof( KSPIN_MEDIUM));
			m_pXBarInputPinsInfo[nIndex].pMedium = &m_pXBarPinsMediumInfo[nIndex];
			m_pXBarPinsMediumInfo[nIndex].Id = ulInstance;
			// all the pins here are inputs
			m_pXBarPinsDirectionInfo[nIndex] = FALSE;	
		}

		// initialize audio input pins, TV Audio input is always the last one
		for( nIndex = 0; nIndex < m_nNumberOfAudioInputs; nIndex ++)
		{
			nPinIndex = nIndex + m_nNumberOfVideoInputs;

			switch( nIndex)
			{
				case 0:
					m_pXBarInputPinsInfo[nPinIndex].AudioVideoPinType = KS_PhysConn_Audio_Line;
					// put the default value for the Medium first
					::RtlCopyMemory( &m_pXBarPinsMediumInfo[nPinIndex], &MEDIUM_WILDCARD, sizeof( KSPIN_MEDIUM));
					m_pXBarInputPinsInfo[nPinIndex].nRelatedPinNumber = 0;
					break;


				case 1:
					m_pXBarInputPinsInfo[nPinIndex].AudioVideoPinType = KS_PhysConn_Audio_Tuner;
					// put the default value for the Medium first
					::RtlCopyMemory( &m_pXBarPinsMediumInfo[nPinIndex], &ATIXBarAudioTunerInMedium, sizeof( KSPIN_MEDIUM));
					m_pXBarInputPinsInfo[nPinIndex].nRelatedPinNumber = m_nNumberOfVideoInputs - 1;
					break;

				default:
					TRAP;
					break;
			}

			// let's put another Medium value from the registry, if present
			if( ::ReadPinMediumFromRegistryFolder( hFolder, nPinIndex, &mediumKSPin))
				::RtlCopyMemory( &m_pXBarPinsMediumInfo[nPinIndex], &mediumKSPin, sizeof( KSPIN_MEDIUM));
			m_pXBarInputPinsInfo[nPinIndex].pMedium = &m_pXBarPinsMediumInfo[nPinIndex];
			m_pXBarPinsMediumInfo[nPinIndex].Id = ulInstance;
			// all the pins here are inputs
			m_pXBarPinsDirectionInfo[nPinIndex] = FALSE;
		}

		// initialize outputs video pins, no X-connection for Video
		for( nIndex = 0; nIndex < m_nNumberOfVideoOutputs; nIndex ++)
		{
			nPinIndex = nIndex + m_nNumberOfVideoInputs + m_nNumberOfAudioInputs;
			m_pXBarOutputPinsInfo[nIndex].AudioVideoPinType = m_pXBarInputPinsInfo[nIndex].AudioVideoPinType;
			m_pXBarOutputPinsInfo[nIndex].nConnectedToPin = nIndex;
         m_pXBarOutputPinsInfo[nIndex].nRelatedPinNumber = m_nNumberOfVideoOutputs; // jaybo

			switch( m_pXBarOutputPinsInfo[nIndex].AudioVideoPinType)
			{
				case KS_PhysConn_Video_Tuner:
					pMediumKSPin = &ATIXBarVideoTunerOutMedium;
					break;

				case KS_PhysConn_Video_SVideo:
					pMediumKSPin = &ATIXBarVideoSVideoOutMedium;
					break;

				case KS_PhysConn_Video_Composite:
					pMediumKSPin = &ATIXBarVideoCompositeOutMedium;
					break;

				default:
					pMediumKSPin = &MEDIUM_WILDCARD;
					break;
			}
			
			::RtlCopyMemory( &m_pXBarPinsMediumInfo[nPinIndex], pMediumKSPin, sizeof( KSPIN_MEDIUM));

			// let's put another Medium value from the registry, if present
			if( ::ReadPinMediumFromRegistryFolder( hFolder, nPinIndex, &mediumKSPin))
				::RtlCopyMemory( &m_pXBarPinsMediumInfo[nPinIndex], &mediumKSPin, sizeof( KSPIN_MEDIUM));

			m_pXBarOutputPinsInfo[nIndex].pMedium = &m_pXBarPinsMediumInfo[nPinIndex];
			m_pXBarPinsMediumInfo[nPinIndex].Id = ulInstance;
			// all the pins here are outputs
			m_pXBarPinsDirectionInfo[nPinIndex] = TRUE;
		}

		// initialize outputs audio pins
		for( nIndex = 0; nIndex < m_nNumberOfAudioOutputs; nIndex ++)
		{
			nPinIndex = nIndex + m_nNumberOfVideoInputs + m_nNumberOfAudioInputs + m_nNumberOfVideoOutputs;

			m_pXBarOutputPinsInfo[nIndex + m_nNumberOfVideoInputs].AudioVideoPinType = KS_PhysConn_Audio_AudioDecoder;

			// put the default value for the Medium first
/*	jaybo
			::RtlCopyMemory( &m_pXBarPinsMediumInfo[nPinIndex], ATIXBarAudioDecoderOutMedium, sizeof( KSPIN_MEDIUM));
*/
			::RtlCopyMemory( &m_pXBarPinsMediumInfo[nPinIndex], &MEDIUM_WILDCARD, sizeof( KSPIN_MEDIUM));
			// let's put another Medium value from the registry, if present
			if( ::ReadPinMediumFromRegistryFolder( hFolder, nPinIndex, &mediumKSPin))
				::RtlCopyMemory( &m_pXBarPinsMediumInfo[nPinIndex], &mediumKSPin, sizeof( KSPIN_MEDIUM));

			m_pXBarOutputPinsInfo[nIndex + m_nNumberOfVideoInputs].nConnectedToPin = ( ULONG)-1;
            m_pXBarOutputPinsInfo[nIndex + m_nNumberOfVideoInputs].nRelatedPinNumber = (ULONG)-1;
			m_pXBarOutputPinsInfo[nIndex + m_nNumberOfVideoInputs].pMedium = &m_pXBarPinsMediumInfo[nPinIndex];
			m_pXBarPinsMediumInfo[nPinIndex].Id = ulInstance;
			// all the pins here are outputs
			m_pXBarPinsDirectionInfo[nPinIndex] = TRUE;

		}

		if( hFolder != NULL)
			::ZwClose( hFolder);

		// mute the audio as the default power-up behaviour
		m_CATIConfiguration.ConnectAudioSource( m_pI2CScript, AUDIOSOURCE_MUTE);

		// these two functions has to be called after the CWDMAVXBar class object was build on
		// on the stack and copied over into the DeviceExtension
		// This commant was true for the case, where the class object was build on the stack first.
		// There is an overloaded operator new provided for this class, and we can call it from here
		SetWDMAVXBarKSProperties();
		SetWDMAVXBarKSTopology();

		// Set run-time WDM properties at the last

		 * puiErrorCode = WDMMINI_NOERROR;
		 OutputDebugTrace(( "CWDMAVXBar:CWDMAVXBar() exit\n"));

		return;

	} END_ENSURE;

	* puiErrorCode = uiError;
    OutputDebugError(( "CWDMAVXBar:CWDMAVXBar() Error = %x\n", uiError));
}



/*^^*
 *		AdapterSetPowerState()
 * Purpose	: Sets Power Management state for deviec
 *
 * Inputs	:	PHW_STREAM_REQUEST_BLOCK pSrb	: pointer to the current Srb
 *
 * Outputs	: NTSTATUS as the operation result
 * Author	: TOM
 *^^*/
NTSTATUS CWDMAVXBar::AdapterSetPowerState( PHW_STREAM_REQUEST_BLOCK pSrb)
{
	ULONG				nAudioSource;
	ULONG				nInputPin;
	NTSTATUS			ntStatus;
	UINT				nIndex;
    DEVICE_POWER_STATE	nDeviceState = pSrb->CommandData.DeviceState;

	ntStatus = STATUS_ADAPTER_HARDWARE_ERROR;

	switch( nDeviceState)
	{
		case PowerDeviceD0:
		case PowerDeviceD3:
			if( nDeviceState != m_ulPowerState)
			{
				// if transition form D3 to D0 we have to restore audio connections
				if(( nDeviceState == PowerDeviceD0) && ( m_ulPowerState == PowerDeviceD3))
				{
					for( nIndex = 0; nIndex < m_nNumberOfAudioOutputs; nIndex ++)
					{
						// we need to restore every audio output pin connection,
						// video output pins are hardwired 
						nInputPin = m_pXBarOutputPinsInfo[nIndex + m_nNumberOfVideoOutputs].nConnectedToPin;

						switch( m_pXBarInputPinsInfo[nInputPin].AudioVideoPinType)
						{
							case KS_PhysConn_Audio_Line:
								nAudioSource = AUDIOSOURCE_LINEIN;
								break;

							case KS_PhysConn_Audio_Tuner:
								nAudioSource = AUDIOSOURCE_TVAUDIO;
								break;

							case 0xFFFFFFFF:
								nAudioSource = AUDIOSOURCE_MUTE;
								return( STATUS_SUCCESS);

							default:
								OutputDebugError(( "CWDMAVXBar:AdapterSetPowerState() Audio Pin type=%x\n", m_pXBarInputPinsInfo[nInputPin].AudioVideoPinType));
								return STATUS_SUCCESS;
						}

						if( m_CATIConfiguration.ConnectAudioSource( m_pI2CScript, nAudioSource))
							ntStatus = STATUS_SUCCESS;
						else
						{
							// error
							ntStatus = STATUS_ADAPTER_HARDWARE_ERROR;
							break;
						}
					}
				}
				else
					ntStatus = STATUS_SUCCESS;
				}
			else
				ntStatus = STATUS_SUCCESS;

			m_ulPowerState = nDeviceState;
			break;

		case PowerDeviceUnspecified:
		case PowerDeviceD1:
		case PowerDeviceD2:
			ntStatus = STATUS_SUCCESS;
			break;

		default:
			ntStatus = STATUS_INVALID_PARAMETER;
			break;
	}

	return( ntStatus);
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -