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

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關于我們
? 蟲蟲下載站

?? hwctxt.cpp

?? 音頻編解碼器Codec: UCB1400 WinCE6.0音頻驅動WAVEDEV2
?? CPP
?? 第 1 頁 / 共 4 頁
字號:
//
// 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>
#include <aclink.h>
#include "ac97.h"
#include "wavemain.h"
#include "dmac.h"

#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);


    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;
    }

    // Bring up AC-LINK and initialize the Codec
    if(InitializeACLink(FALSE, DEV_AUDIO))
    {
        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;

        // 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);

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

            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;
                
            m_pDMARegisters->drcmr[DMA_CHMAP_AC97_OUT] = DMA_MAP_VALID_MASK | m_PlaybackChannel ;

            // 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)
    {
        //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;
        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
        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")));
        }
        
        m_fOutputRenderMonoOnly = (dwOutputRenderMonoOnly == 1);

        RegCloseKey(hDevKey);
    }

    return (TRUE);   
}

DWORD HardwareContext::GetInterruptThreadPriority()
{
    HKEY hDevKey;
    DWORD dwValType;
    DWORD dwValLen;
    LONG regError;
    
    DWORD dwPrio = INTERRUPT_THREAD_PRIORITY_DEFAULT; // Default priority

    hDevKey = OpenDeviceKey((LPWSTR)m_DriverIndex);

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
在线区一区二视频| 欧美日精品一区视频| 久久99最新地址| 日本欧洲一区二区| 蜜桃视频一区二区三区在线观看| 五月婷婷综合激情| 裸体一区二区三区| 麻豆国产一区二区| 国产精品一二三区| 99久久国产综合精品女不卡| 91麻豆精东视频| 欧美日韩视频在线观看一区二区三区 | 日韩成人一级大片| 精品中文字幕一区二区| 国产成人免费在线视频| 成人免费看的视频| 色婷婷av一区二区三区软件 | 久久这里只精品最新地址| 国产亚洲短视频| 亚洲女人****多毛耸耸8| 亚洲h动漫在线| 国产一区二区三区精品视频| 国产suv精品一区二区6| 色成年激情久久综合| 欧美一区二区在线观看| 欧美激情一区三区| 亚洲大片一区二区三区| 国产在线一区观看| 欧美探花视频资源| 久久久国际精品| 亚洲chinese男男1069| 国产一区二区三区日韩| av亚洲精华国产精华| 欧美日韩一区二区三区高清| 2020国产精品久久精品美国| 亚洲乱码国产乱码精品精可以看 | 91久久精品日日躁夜夜躁欧美| 欧美久久久久久蜜桃| 国产精品乱人伦| 石原莉奈在线亚洲三区| 成人免费观看av| 欧美一区二区在线免费观看| 亚洲色图另类专区| 国产在线国偷精品产拍免费yy| 欧美色区777第一页| 国产欧美精品一区二区色综合| 日韩国产在线观看| 欧美午夜在线一二页| 日本一区二区免费在线| 美女脱光内衣内裤视频久久网站 | 99精品欧美一区二区蜜桃免费| 欧美一区二区三区免费大片| 亚洲男同1069视频| 国产成人福利片| 久久久蜜桃精品| 久久精品久久99精品久久| 欧美精品粉嫩高潮一区二区| 亚洲色欲色欲www| 99久久婷婷国产精品综合| 久久免费午夜影院| 国产精品99久久久久久有的能看| 在线综合亚洲欧美在线视频| 亚洲国产aⅴ成人精品无吗| 色综合婷婷久久| 亚洲日穴在线视频| 91污在线观看| 日韩一区在线看| 不卡在线观看av| 国产精品国产三级国产有无不卡| 国产成人高清视频| 欧美国产精品一区二区三区| 国产麻豆日韩欧美久久| 久久综合九色综合97婷婷女人| 老司机免费视频一区二区三区| 91麻豆精品国产综合久久久久久| 亚洲成人高清在线| 69久久99精品久久久久婷婷| 日韩专区在线视频| 91精品国产一区二区人妖| 轻轻草成人在线| 久久综合色8888| 国产成人精品亚洲午夜麻豆| 亚洲国产精品v| 日本精品视频一区二区| 亚洲一区二区三区四区五区黄 | 6080国产精品一区二区| 日韩电影网1区2区| 久久影音资源网| 成人一二三区视频| 亚洲欧洲日韩av| 欧美日韩黄色影视| 久久综合综合久久综合| 国产午夜精品福利| 91美女视频网站| 日韩av电影一区| 国产视频911| 在线中文字幕一区二区| 免费成人av在线| 国产精品少妇自拍| 欧美日韩亚州综合| 国产成人8x视频一区二区| 国产精品久久久久久久久久久免费看| 一本久道久久综合中文字幕| 日韩精品福利网| 国产精品欧美极品| 欧美日韩久久一区二区| 国产一区二区三区观看| 亚洲三级久久久| 精品日韩在线观看| 成人av电影在线网| 久久精品国产99国产精品| 国产精品福利电影一区二区三区四区| 欧美手机在线视频| 国产成人欧美日韩在线电影| 亚洲国产精品视频| 欧美极品xxx| 日韩视频一区在线观看| 97久久超碰精品国产| 久久成人久久爱| 亚洲一区二区三区中文字幕| 久久精品亚洲一区二区三区浴池| 欧美日韩在线播| 99精品视频中文字幕| 国产一区在线观看麻豆| 亚洲不卡av一区二区三区| 中文av字幕一区| 久久久激情视频| 日韩欧美一级二级| 精品视频色一区| 91伊人久久大香线蕉| 国产乱妇无码大片在线观看| 丝袜亚洲另类丝袜在线| 中文字幕欧美一区| 国产免费久久精品| 2024国产精品| 精品久久久久99| 6080国产精品一区二区| 欧美日韩国产免费| 欧美亚洲国产一区二区三区va| 99热在这里有精品免费| 国产精品资源在线看| 黄色日韩网站视频| 伦理电影国产精品| 精品一区二区精品| 免费成人在线网站| 日本不卡高清视频| 美女视频黄免费的久久| 免费观看日韩电影| 麻豆精品视频在线| 韩国av一区二区| 国产伦精品一区二区三区免费迷 | 精品久久99ma| 日韩午夜激情免费电影| 精品日韩一区二区| 欧美xxxxxxxx| 久久久久国产精品麻豆ai换脸| 久久久99久久精品欧美| 欧美精彩视频一区二区三区| 欧美激情一区二区三区四区| 国产精品沙发午睡系列990531| 国产精品久久久久久久岛一牛影视 | 日韩亚洲欧美在线| 欧美电影免费观看高清完整版在线 | 国产91精品一区二区麻豆亚洲| 国产资源精品在线观看| 成人激情午夜影院| 在线亚洲一区观看| 日韩午夜av一区| 欧美激情一区二区三区蜜桃视频| 综合久久综合久久| 天天av天天翘天天综合网色鬼国产| 三级亚洲高清视频| 国产河南妇女毛片精品久久久| 成人免费看片app下载| 在线看一区二区| 日韩欧美123| 综合色中文字幕| 蜜臀久久99精品久久久久久9| 国产精品一区三区| 91丨九色丨蝌蚪富婆spa| 欧美视频在线一区| 久久久亚洲综合| 亚洲一区二区在线观看视频| 久久9热精品视频| 色网综合在线观看| 欧美www视频| 亚洲自拍偷拍综合| 国产精品资源网| 欧美日韩视频在线观看一区二区三区| 欧美变态tickle挠乳网站| 亚洲色图清纯唯美| 精品一区二区三区在线观看国产| 成人av电影在线| 精品乱人伦小说| 亚洲aaa精品| 色噜噜狠狠色综合欧洲selulu| 欧美成人官网二区| 亚洲一区二区三区四区的| 成人免费高清视频| 精品动漫一区二区三区在线观看|