亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來(lái)到蟲(chóng)蟲(chóng)下載站! | ?? 資源下載 ?? 資源專(zhuān)輯 ?? 關(guān)于我們
? 蟲(chóng)蟲(chóng)下載站

?? hwctxt.cpp

?? realtek562x系列驅(qū)動(dòng)源碼。wince
?? CPP
?? 第 1 頁(yè) / 共 4 頁(yè)
字號(hào):
//
// Copyright (c) Microsoft Corporation.  All rights reserved.
//
//
// Use of this sample source code is subject to the terms of the Microsoft
// license agreement under which you licensed this sample source code. If
// you did not accept the terms of the license agreement, you are not
// authorized to use this sample source code. For the terms of the license,
// please see the license agreement between you and Microsoft or, if applicable,
// see the LICENSE.RTF on your install media or the root of your tools installation.
// THE SAMPLE SOURCE CODE IS PROVIDED "AS IS", WITH NO WARRANTIES.
//
/*++

Module Name: 

        hwctxt.cpp

Abstract:

ChangesLog:

06-28-2005
    1. Added installable ISR for audio DMA interrupt handling.
    2. Improved DMA buffer handling.
    3. AC97 shared resource management is now in ACLink.lib which is shared by touch driver.
    4. Added power management support.

--*/
/* 
** Copyright 2000-2003 Intel Corporation All Rights Reserved
**
** Portions of the source code contained or described herein and all documents
** related to such source code (Material) are owned by Intel Corporation
** or its suppliers or licensors and is licensed by Microsoft Corporation for distribution.  
** Title to the Material remains with Intel Corporation or its suppliers and licensors. 
** Use of the Materials is subject to the terms of the Microsoft license agreement which accompanied the Materials.  
** No other license under any patent, copyright, trade secret or other intellectual
** property right is granted to or conferred upon you by disclosure or
** delivery of the Materials, either expressly, by implication, inducement,
** estoppel or otherwise 
** Some portion of the Materials may be copyrighted by Microsoft Corporation..
*/

#include <windows.h>

#if __cplusplus
extern "C" {
#endif
#include "xllp_ost.h"

#if __cplusplus
}
#endif


#include "ac97.h"
#include "wavemain.h"
#include "dmac.h"

#if !USE_I2S_INTERFACE	

#include <aclink.h>

#else

#include "i2s_control.h"
#include <xllp_i2s.h>	

#endif

#if USE_I2S_INTERFACE

#define DMAC_IIS_AUDIO_RCV_FIFO		0x40400080
#define DMAC_IIS_AUDIO_XMIT_FIFO	0x40400080 
#define DMA_CHMAP_I2S_RCV      2          // DRCMR2 - map dma channel for I2S receive request
#define DMA_CHMAP_I2S_TRA      3          // DRCMR3 - map dma channel for I2S transmit request

#endif	

#define DMA_INTERRUPT_REGISTER  0x400000f0

#define INTERRUPT_THREAD_PRIORITY_DEFAULT 150

const LPCWSTR g_wszDmaIsrDll     = L"giisr.dll";
const LPCWSTR g_wszDmaIsrHandler = L"ISRHandler";

HardwareContext *g_pHWContext=NULL;

static const POWER_CAPABILITIES g_PowerCaps = 
{
    // DeviceDx:    Supported power states
    DX_MASK(D0) | DX_MASK(D1) | DX_MASK(D2) | DX_MASK(D3) | DX_MASK(D4),

    0,              // WakeFromDx:
    0,              // InrushDx:    No inrush of power

    {               // Power: Maximum milliwatts in each state
        0x00000001, //        D0 = 0
        0x00000001, //        D1 = 0
        0x00000001, //        D2 = 0
        0x00000001, //        D3 = 0
        0x00000001  //        D4 = 0 (off)
    },

    {               // Latency
        0x00000000, //        D0 = 0
        0x00000000, //        D1 = 0
        0x00000000, //        D2 = 0
        0x00000000, //        D3 = 0
        0x00000000  //        D4 = 0
    },

    0,                    // Flags: None
};

BOOL HardwareContext::CreateHWContext(DWORD Index)
{
    DEBUGMSG(ZONE_FUNCTION, (TEXT("+HardwareContext::CreateHWContext")));

    //if the hardware context exists then don't init again
    if (g_pHWContext)
    {
        return TRUE;
    }

    g_pHWContext = new HardwareContext;
    if (!g_pHWContext)
    {
        return FALSE;  //oops we should have not be null
    }

    DEBUGMSG(ZONE_FUNCTION, (TEXT("-HardwareContext::CreateHWContext")));

    return g_pHWContext->Init(Index);
}

HardwareContext::HardwareContext(): m_InputDeviceContext(), m_OutputDeviceContext()
{
    InitializeCriticalSection(&m_Lock);  //some code is not reentrant
    m_Initialized=FALSE;  //we are just getting started, we are not initialized yet

    m_fOutputRenderMonoOnly = 0;
}

HardwareContext::~HardwareContext()
{
    DeleteCriticalSection(&m_Lock);             //we're going down, clean up semiphore
}


BOOL HardwareContext::Init(DWORD Index)
{
    DEBUGMSG(ZONE_INIT, (TEXT("+HardwareContext::Init")));

    //initialize the hardware, bring it up to a state ready for quick rendering of 
    //audio streams and UI sounds
    m_DriverIndex       = Index;
    m_InPowerHandler    = FALSE;
    m_InputDMARunning   = FALSE;
    m_OutputDMARunning  = FALSE;
    m_NumForcedSpeaker  = 0;
    m_Sleeping          = FALSE;
    m_audioDeinit       = FALSE;

    m_SysIntrAudioDMA   = SYSINTR_UNDEFINED;
    m_hAudioInterrupt   = NULL;
    m_hDMAIsrHandler    = NULL;
    
    m_PlaybackChannel   = (XLLP_DMAC_CHANNEL_T)DMA_CH_OUT;         // DMA Ch. 1
    m_RecordingChannel  = (XLLP_DMAC_CHANNEL_T)DMA_CH_RCV;         // DMA Ch. 4

    // Initial power state
    m_dwPowerState      = D0;

    GetRegKeys();

    m_OutputDeviceContext.SetMono(m_fOutputRenderMonoOnly);

	ALLOCATE_RT_CODEC_CLASS

	if(!m_RTCodec)
	{
		return FALSE;
	}
	else
	{
		if(!m_RTCodec->Init(this))
		{
			return FALSE;
		}		
	}

    if (!MapDeviceRegisters())
    {
        goto Exit;
    }
    
    if (!InitAudioDMA())
    {
        goto Exit;
    }

    if (!MapDMADescriptors())
    {
        goto Exit;
    }
    
    // Map the DMA buffers (and fill the descriptors) into driver's virtual address space
    if (!MapDMABuffers())
    {
        goto Exit;
    }


#if USE_I2S_INTERFACE

    // Bring up IIS-LINK and initialize the Codec
    if(InitializeI2S(FALSE))
    
#else

    // Bring up AC-LINK and initialize the Codec
    if(InitializeACLink(FALSE, DEV_AUDIO))
    
#endif

    {
        PowerUp();
        InitCodec();
    }
    else
    {
        goto Exit;
    }

    // Configure the DMA controller
    InitInputDMA();
    InitOutputDMA();

    m_Initialized = TRUE;

Exit: 
    if (FALSE == m_Initialized)
    {//fail to initialize
        Deinit();
    }

    DEBUGMSG(ZONE_INIT, (TEXT("-HardwareContext::Init")));
    return m_Initialized;
}


BOOL HardwareContext::MapDMABuffers()
{
    PBYTE pbDMATemp;
    DMA_ADAPTER_OBJECT Adapter;
    PHYSICAL_ADDRESS   PA;

    DEBUGMSG(ZONE_INIT, (TEXT("+MapDMABuffers")));

    Adapter.ObjectSize    = sizeof(DMA_ADAPTER_OBJECT);
    Adapter.InterfaceType = Internal;
    Adapter.BusNumber     = 0;

    pbDMATemp = (BYTE *) HalAllocateCommonBuffer(&Adapter, (AUDIO_BUFFER_SIZE * NUM_DMA_AUDIO_BUFFERS), &PA, FALSE);
    if (!pbDMATemp)
    {
        DEBUGMSG(ZONE_ERROR, (TEXT("ERROR: AudioInitialize: failed to allocate DMA buffer(s).\r\n")));
        return(FALSE);
    }
    m_Output_pbDMA_PAGES[0] = pbDMATemp;
    m_Output_pbDMA_PAGES[1] = pbDMATemp + AUDIO_BUFFER_SIZE;

    m_Input_pbDMA_PAGES[0]  = pbDMATemp + 2*AUDIO_BUFFER_SIZE;
    m_Input_pbDMA_PAGES[1]  = pbDMATemp + 3*AUDIO_BUFFER_SIZE;

    m_Output_pbDMA_PAGES_Physical[0] = (BYTE *)PA.LowPart;
    m_Output_pbDMA_PAGES_Physical[1] = (BYTE *)PA.LowPart + AUDIO_BUFFER_SIZE;

    m_Input_pbDMA_PAGES_Physical[0]  = (BYTE *)PA.LowPart + 2*AUDIO_BUFFER_SIZE;
    m_Input_pbDMA_PAGES_Physical[1]  = (BYTE *)PA.LowPart + 3*AUDIO_BUFFER_SIZE;
    
    return TRUE;
}

void HardwareContext::InitInputDMA()
{
    FillInputDescriptors();
}

void HardwareContext::InitOutputDMA()
{
    FillOutputDescriptors();
}

int HardwareContext::GetNextOutputBuffer(void)
{
   return ((UINT32)m_pDMARegisters->ddg[m_PlaybackChannel].dsadr >= (UINT32)m_Output_pbDMA_PAGES_Physical[1]) ? 0 : 1 ;
}

void HardwareContext::StartOutputDMA()
{
    DEBUGMSG(ZONE_VERBOSE, (TEXT("+StartOutputDMA\r\n")));

    if (!m_OutputDMARunning)
    {
        ULONG OutputTransferred;

#if RT_ALC5621
		m_RTCodec->WriteCodecRegMask(RT5621_MISC_CTRL,DISABLE_FAST_VREG,DISABLE_FAST_VREG);	//disable fast vreg,it will affect quality of audio
#else
		m_RTCodec->WriteCodecRegMask(RT_MISC_CTRL,DISABLE_FAST_VREG,DISABLE_FAST_VREG);	//disable fast vreg,it will affect quality of audio
#endif
		
        // Fill in the first DMA buffer before kicking start DMA, which will
        // generate an interrupt (e.g. STARTINTR) right away. The IST thread will then
        // fill in the second DMA buffer.
        OutputTransferred = TransferOutputBuffer(0);

        if (OutputTransferred) 
        {
            m_OutputDMARunning=TRUE;

            // Initialize the DMA channel format
            //set the sample rate on every buffer due to ac97 work around. (???)
            SetSampleRate(SAMPLERATE, WAPI_OUT);

#if USE_I2S_INTERFACE

			m_pI2SRegs->SAICR=XLLP_SAICR_TUR;//clear transmit FIFO underrun
			
#else

            m_pAc97regs->POSR =  0x10;  //clear the output Fifo error
            
#endif

            if(OutputTransferred < AUDIO_BUFFER_SIZE)
            {
                // Set second buffer descriptor STOP bit and the minimum length
                // in case we overrun into the second buffer.
                m_vpAudioXmitB->ddadr |= DESC_ADDRESS_STOP_MASK;
                m_vpAudioXmitB->dcmd = DMAC_AC97_XMITAB_CMD_MASK | 32;
            }

            DEBUGMSG(ZONE_VERBOSE, (TEXT( "Starting DMA XMIT channel %d \r\n" ),m_PlaybackChannel) );

            // Load descriptor address reg to initialize DMA, pointing
            // to the buffer just loaded.
            m_pDMARegisters->ddg[m_PlaybackChannel].ddadr =(UINT32)m_vpAudioXmitA_Physical;
                

#if USE_I2S_INTERFACE

			m_pDMARegisters->drcmr[DMA_CHMAP_I2S_TRA] = DMA_MAP_VALID_MASK | m_PlaybackChannel ;
			
#else       
         
            m_pDMARegisters->drcmr[DMA_CHMAP_AC97_OUT] = DMA_MAP_VALID_MASK | m_PlaybackChannel ;
            
#endif


            // Enable STOPINTR so that we know DMA is done on final buffer. A zero length buffer
            // is considered the final buffer.
            // And finally set RUN bit to start DMA.
            m_pDMARegisters->dcsr[m_PlaybackChannel] |=  DCSR_RUN | DCSR_STOPIRQEN;

            DEBUGMSG(ZONE_VERBOSE, (TEXT("Started Output DMA\r\n")));
        }
        else
        {
            m_OutputDMARunning=FALSE;
            DEBUGMSG(ZONE_VERBOSE, (TEXT("no Output started with DMA\r\n")));
        }
    }
}

void HardwareContext::StopOutputDMA()
{
    DEBUGMSG(ZONE_VERBOSE, (TEXT("StopOutputDMA\r\n")));
    if (m_OutputDMARunning)
    {
        //stop the dma channel and mute
        StopDmac(m_PlaybackChannel);
        m_OutputDMARunning=FALSE;
    }

}

int HardwareContext::GetLastInputBuffer(void)
{
   return ((UINT32)m_pDMARegisters->ddg[m_RecordingChannel].dtadr >= (UINT32)m_Input_pbDMA_PAGES_Physical[1]) ? 0 : 1 ;
}

void HardwareContext::StartInputDMA()
{
    if (!m_InputDMARunning)
    {    	    	
#if RT_ALC5621
		m_RTCodec->WriteCodecRegMask(RT5621_MISC_CTRL,DISABLE_FAST_VREG,DISABLE_FAST_VREG);	//disable fast vreg,it will affect quality of audio
#else
		m_RTCodec->WriteCodecRegMask(RT_MISC_CTRL,DISABLE_FAST_VREG,DISABLE_FAST_VREG);	//disable fast vreg,it will affect quality of audio
#endif
        //set it on every buffer due to ac97 work around. (???)
        SetSampleRate(SAMPLERATE, WAPI_IN);

        // For now, pretend input dma is running in case we accidentally get reentered
        m_InputDMARunning=TRUE;

        //DMA_CH_RCV:
        DEBUGMSG(ZONE_VERBOSE, (TEXT( "Starting DMA Recieve channel \r\n" )) );
        m_pDMARegisters->ddg[m_RecordingChannel].ddadr = (UINT32)m_vpAudioRcvA_Physical;
 
#if	USE_I2S_INTERFACE

        m_pDMARegisters->drcmr[DMA_CHMAP_I2S_RCV] = DMA_MAP_VALID_MASK | m_RecordingChannel ;
		m_pI2SRegs->SAICR=XLLP_SAICR_ROR;//clear receive FIFO overrun
		
#else

        m_pDMARegisters->drcmr[DMA_CHMAP_AC97_RCV] = DMA_MAP_VALID_MASK | m_RecordingChannel ;
        m_pAc97regs->PISR = 0x10;  // clear Pcm Input Fifo status
        m_pAc97regs->PISR = 0x8;   // dedicated write to clear EOC bit
        
#endif

        m_pDMARegisters->dcsr[m_RecordingChannel] |=  DCSR_RUN;          // set the RUN bit
    }
}

void HardwareContext::StopInputDMA()
{
    if (m_InputDMARunning)
    {
        m_InputDMARunning=FALSE;
        StopDmac(m_RecordingChannel);
    }
}

/* ;resample stereo output to mono output?
   ;set this if your platform has only mono speaker. if your platform supports
   ; both mono speaker and a stereo headset you'll have to dynamically change
   ; the flag in wavedev2 driver for proper output rendering (mono vs. stereo)
   ;MainstoneIII has both a mono speaker and a stereo headphone jack. But unfortunately
   ; headphone presence detection is not supported by the onboard philips codec.
   ; For this reason we only render mono output.
   "HKLM\Drivers\BuiltIn\WaveDev\OutputRenderMonoOnly"=dword:1          <-- Reg Key
   m_fOutputRenderMonoOnly                                              <-- flag in wavedev2 driver
*/
#define WAV_OUTPUT_RENDER_MONO_ONLY TEXT("OutputRenderMonoOnly")

BOOL HardwareContext::GetRegKeys()
{

    HKEY hDevKey;

    hDevKey = OpenDeviceKey((LPWSTR)m_DriverIndex);
    
    if (hDevKey)
    {
        DWORD dwValLen = sizeof(DWORD);
        DWORD dwOutputRenderMonoOnly = 0;
        LONG regError = RegQueryValueEx(hDevKey, WAV_OUTPUT_RENDER_MONO_ONLY, NULL, NULL,
            (PUCHAR)&dwOutputRenderMonoOnly, &dwValLen);

        if (regError != ERROR_SUCCESS)
        {
            DEBUGMSG(ZONE_INIT,(TEXT("WAVEDEV_GetRegKeys: INFO: Failed opening \\Drivers\\BuiltIn\\WaveDev\\OutputRenderMonoOnly\r\n")));

?? 快捷鍵說(shuō)明

復(fù)制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號(hào) Ctrl + =
減小字號(hào) Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
日韩欧美一区在线观看| 精品剧情在线观看| 亚洲精品视频一区二区| 国产白丝网站精品污在线入口| 精品盗摄一区二区三区| 蜜桃精品在线观看| 日韩欧美的一区| 老司机精品视频一区二区三区| 91精品国产综合久久久久久久| 天天综合网 天天综合色| 欧美日韩亚洲国产综合| 天堂久久久久va久久久久| 欧美日韩三级视频| 日韩av电影免费观看高清完整版| 777久久久精品| 日本vs亚洲vs韩国一区三区 | 欧美无砖专区一中文字| 一二三四区精品视频| 欧洲色大大久久| 亚洲成精国产精品女| 欧美日韩成人一区二区| 奇米一区二区三区av| 日韩欧美一区二区不卡| 国产激情视频一区二区三区欧美 | 亚洲二区在线观看| 欧美日韩午夜在线视频| 日本91福利区| 26uuuu精品一区二区| 国产传媒久久文化传媒| 中文字幕在线视频一区| 91成人在线精品| 日本人妖一区二区| 久久久久久久综合色一本| 成人免费视频播放| 一区二区三区高清在线| 欧美日本一道本在线视频| 蜜臀av性久久久久蜜臀av麻豆 | 久久免费美女视频| 成人黄色av网站在线| 一区二区三区av电影| 91精品国产美女浴室洗澡无遮挡| 国产在线播放一区三区四| 国产精品久久综合| 精品污污网站免费看| 美女一区二区视频| 国产精品久线观看视频| 欧美美女直播网站| 色噜噜夜夜夜综合网| 日韩精品久久久久久| 久久综合成人精品亚洲另类欧美| 99热99精品| 日日摸夜夜添夜夜添国产精品| 久久人人爽爽爽人久久久| 99精品国产一区二区三区不卡 | 1000部国产精品成人观看| 欧美网站一区二区| 激情六月婷婷久久| 亚洲欧洲日本在线| 欧美日韩小视频| 丁香一区二区三区| 性感美女久久精品| 国产视频在线观看一区二区三区| 欧美中文字幕一区二区三区亚洲| 狠狠v欧美v日韩v亚洲ⅴ| 国产性做久久久久久| 欧美日韩视频一区二区| 国产在线精品一区二区夜色| 亚洲精品久久久久久国产精华液| 日韩三级在线观看| 91女厕偷拍女厕偷拍高清| 婷婷综合另类小说色区| 久久精品亚洲麻豆av一区二区| 99视频在线精品| 久久国产免费看| 亚洲一区二区在线观看视频| 久久精品一区二区三区不卡| 欧美精选一区二区| 国产精品夜夜嗨| 日韩精品亚洲一区| 中文字幕在线不卡一区二区三区| 日韩精品一区二区三区在线播放 | 国产激情一区二区三区| 亚洲国产日韩av| 中文字幕欧美激情| 日韩一级完整毛片| 欧美专区日韩专区| 丁香啪啪综合成人亚洲小说| 美女视频黄免费的久久 | 1024国产精品| 精品国产免费一区二区三区四区| 91精品办公室少妇高潮对白| 国产精品自产自拍| 日本人妖一区二区| 亚洲成人免费电影| 中文字幕日本乱码精品影院| 91精品欧美综合在线观看最新| 成人免费三级在线| 精品在线视频一区| 午夜精品国产更新| 亚洲一区二区三区在线| 中文一区在线播放| 2020国产精品| 欧美日韩精品一区二区在线播放| 91在线精品一区二区| 风流少妇一区二区| 国产乱码精品一品二品| 日本午夜精品一区二区三区电影 | 免费成人美女在线观看| 日韩码欧中文字| 国产精品毛片a∨一区二区三区| 日韩欧美国产成人一区二区| 欧美欧美午夜aⅴ在线观看| 欧洲在线/亚洲| 欧洲另类一二三四区| 丁香婷婷深情五月亚洲| 国产一区二区三区黄视频| 免费在线观看日韩欧美| 日韩精品一二三| 亚洲成人一区二区| 亚洲国产欧美日韩另类综合| 成人性生交大合| 国产一区999| 精品一区二区三区在线观看国产| 青青草成人在线观看| 日韩精品色哟哟| 日本aⅴ免费视频一区二区三区| 丝袜美腿亚洲色图| 天天免费综合色| 日韩中文字幕一区二区三区| 亚洲不卡在线观看| 亚洲综合无码一区二区| 亚洲综合在线观看视频| 亚洲综合色自拍一区| 亚洲综合成人在线| 亚洲成人激情av| 日日摸夜夜添夜夜添精品视频| 日韩不卡在线观看日韩不卡视频| 午夜精品久久久久久久久| 无码av中文一区二区三区桃花岛| 午夜视频在线观看一区二区三区| 五月婷婷久久丁香| 日本强好片久久久久久aaa| 麻豆一区二区在线| 国模冰冰炮一区二区| 成人一道本在线| 一本久道中文字幕精品亚洲嫩| 在线观看免费一区| 欧美三区在线视频| 欧美一区三区四区| 91精品国产91综合久久蜜臀| 精品奇米国产一区二区三区| 久久人人爽爽爽人久久久| 国产精品三级电影| 一区二区三区四区不卡在线 | 国产精品第四页| 亚洲人成伊人成综合网小说| 亚洲夂夂婷婷色拍ww47| 日本成人超碰在线观看| 激情国产一区二区| 成人福利电影精品一区二区在线观看 | 日本不卡在线视频| 国产九九视频一区二区三区| 99久久精品免费看国产免费软件| 精品视频一区二区三区免费| 日韩午夜小视频| 国产欧美日韩视频在线观看| 亚洲婷婷综合久久一本伊一区| 亚洲国产aⅴ成人精品无吗| 另类小说图片综合网| 国产91精品一区二区麻豆网站| 99re这里只有精品首页| 在线不卡免费av| 久久日一线二线三线suv| 成人欧美一区二区三区小说 | 色婷婷综合久久久| 91精品国产综合久久蜜臀| 国产无人区一区二区三区| 亚洲蜜桃精久久久久久久| 免费av成人在线| 成人网男人的天堂| 欧美精品 国产精品| 国产亚洲精品免费| 亚洲一区在线观看网站| 国产一区 二区| 在线亚洲人成电影网站色www| 日韩一本二本av| 亚洲色图第一区| 久久精品噜噜噜成人av农村| caoporn国产一区二区| 91精品国产综合久久精品| 中文字幕欧美激情一区| 日韩中文字幕1| av在线播放一区二区三区| 欧美精品 国产精品| 国产精品对白交换视频| 极品少妇xxxx偷拍精品少妇| 色综合久久中文综合久久牛| 久久影院午夜论| 亚洲国产成人va在线观看天堂| 国产成人精品aa毛片|