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

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

?? hwctxt.cpp

?? wince 下的bsp測試wince_bspSMDK2440_L35T32.rar
?? CPP
?? 第 1 頁 / 共 4 頁
字號:
//
// Copyright (c) Microsoft Corporation.  All rights reserved.
//
//
// Use of this source code is subject to the terms of the Microsoft end-user
// license agreement (EULA) under which you licensed this SOFTWARE PRODUCT.
// If you did not accept the terms of the EULA, you are not authorized to use
// this source code. For a copy of the EULA, please see the LICENSE.RTF on your
// install media.
//
/*++
THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF
ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO
THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
PARTICULAR PURPOSE.

   
Module Name:	HWCTXT.CPP

Abstract:		Platform dependent code for the mixing audio driver.

Notes:			The following file contains all the hardware specific code
				for the mixing audio driver.  This code's primary responsibilities
				are:

					* Initialize audio hardware (including codec chip)
					* Schedule DMA operations (move data from/to buffers)
					* Handle audio interrupts

				All other tasks (mixing, volume control, etc.) are handled by the "upper"
				layers of this driver.

				****** IMPORTANT ******
				Presently, audio input (i.e. RECORD functionality) IS NOT implemented.  On 
				this platform, in order to record the TLV320AIC codec chip needs to be 
				configured as MASTER and the CPU's I2S controller configured as SLAVE.  
				Unfortunately, a hardware bug in the current Samsung CPU samples prevents 
				SLAVE mode from working properly.  As a result, only audio playback is 
				supported by configuring the CPU I2S controller as MASTER and the audio
				codec chip as SLAVE.  
				
				The final revision of the Samsung SC2440 CPU is expected to fix this 
				hardware bug.  Once this issue is resolved, the CPU's I2S controller 
				(look at I2S.CPP) should be configured in SLAVE mode and the audio codec 
				chip (see InitCodec() below) should be configured as MASTER.  With these
				changes, the following routines need to be implemented:

					InitInputDMA()	- initialize the input DMA channel
					StartInputDMA()	- starts DMA operations on the input DMA channel
					StopInputDMA()	- stops any current DMA operations on the input DMA channel

				For the SC2440 CPU, DMA channel 2 can be used for both input and output.  In this,
				configuration, however, only one type operation (input or output) can execute.  In 
				order to implement simultaneous playback and recording, two things must be done:
 
					1) Input DMA should be moved to DMA Channel 1; Output DMA still uses DMA Channel 2.
					2) Step #3 in InterruptThread() needs to be implemented so that the DMA interrupt
					   source (input DMA or output DMA?) can be determined.  The interrupt source needs
					   to be determined so that the appropriate buffers can be copied (Steps #4,#5...etc.).

				Lastly, the m_OutputDMAStatus and m_InputDMAStatus variables shouldn't need to be modified.  
				The logic surrounding these drivers is simply used to determine which buffer (A or B) needs
				processing.

Environment:	PocketPC SMDK2440 Reference Platform:

				Hardware - Samsung SC2440 CPU
						   TI TLV320AIC audio codec chip where: 
								1) SPI bus is used for control 
								2) I2S bus is used for data (CPU is master
								   and codec chip is slave)

				Software - Windows CE 3.0 and later.    
-*/

#include "wavemain.h"
#include <p2.h>
#include "s2440.h"
#include "dma.h"
#include "hwctxt.h"

#define DMA_FLAG 1


#define AC97_DEBUG 0
#define AC97MSG(a,b)	RETAILMSG(AC97_DEBUG,b)

#define DMA_CH_MIC 2
#define DMA_CH_OUT 1

#define WAIT_DMA_END 0

#define DELAY_COUNT	0x1000


int rec_mode=0;

//-------------------------------- Global Variables --------------------------------------
volatile AC97reg	*v_pAC97regs		= NULL;		// AC97 control registers
volatile IOPreg		*v_pIOPregs		= NULL;		// GPIO registers (needed to enable I2S and SPI)
volatile DMAreg		*v_pDMAregs		= NULL;		// DMA registers (needed for I/O on I2S bus)
volatile CLKPWRreg	*g_pCLKPWRreg	= NULL;		// Clock power registers (needed to enable I2S and SPI clocks)
volatile INTreg 	*s2440INT 		= NULL;
				
HANDLE          g_hUTLObject		= INVALID_HANDLE_VALUE;

HardwareContext *g_pHWContext		= NULL;

void AC97_GPIO_Init();

unsigned int delay_count;
//----------------------------------------------------------------------------------------

/*#ifdef DEBUG
DBGPARAM dpCurSettings = {
    TEXT("CONSOLE"), {
        TEXT("0"),TEXT("1"),TEXT("2"),TEXT("3"),
        TEXT("4"),TEXT("5"),TEXT("6"),TEXT("7"),
        TEXT("8"),TEXT("9"),TEXT("10"),TEXT("11"),
        TEXT("12"),TEXT("Function"),TEXT("Init"),TEXT("Error")},
    0x8000  // Errors only, by default
}; 
#endif
*/

// Static Functions
volatile static int loop = S2440FCLK/100000;

static void Delay(USHORT count)
{
	volatile int i, j;
	
	for(;count > 0;count--)
		for(i=0;i < loop; i++) { j++; }
}

static void WriteCodecRegister(UCHAR Reg, USHORT Val)
{
	v_pAC97regs->rAC_CODEC_CMD = (Reg << AC97_CMD_ADDR_SHIFT) | (Val << AC97_CMD_DATA_SHIFT);
	Delay(100);
	//Sleep(5);
	v_pAC97regs->rAC_CODEC_CMD |= (AC97_READ_COMMAND);	//To receive SLOTREQ bits when VRA is '1'.
}

static USHORT ReadCodecRegister(UCHAR Reg)
{
	USHORT retval;
	
	v_pAC97regs->rAC_CODEC_CMD = AC97_READ_COMMAND | (Reg << AC97_CMD_ADDR_SHIFT);
	
	Delay(100);
	//Sleep(5);
	
	retval = v_pAC97regs->rAC_CODEC_STAT & AC97_STAT_DATA_READ_MASK;
	
	return retval;
}


BOOL HardwareContext::CreateHWContext(DWORD Index)
{
    if (g_pHWContext)
    {
        return TRUE;
    }

    g_pHWContext = new HardwareContext;
    if (!g_pHWContext)
    {
        return FALSE;
    }

    return g_pHWContext->Init(Index);
}

HardwareContext::HardwareContext()
: m_InputDeviceContext(), m_OutputDeviceContext()
{
    InitializeCriticalSection(&m_Lock);
}

HardwareContext::~HardwareContext()
{
    DeleteCriticalSection(&m_Lock);
}

BOOL HardwareContext::Init(DWORD Index)
{
	BOOL bRet = TRUE;
	
	//----- 1. Initialize the state/status variables -----
    m_DriverIndex		= Index;
    m_IntrAudio         = SYSINTR_AUDIO;
    m_InPowerHandler    = FALSE;
    m_InputDMARunning   = FALSE;
    m_OutputDMARunning  = FALSE;
	m_InputDMAStatus	= DMA_CLEAR;				
	m_OutputDMAStatus	= DMA_CLEAR;				

    //----- 2. Map the necessary descriptory channel and control registers into the driver's virtual address space -----
	if(!MapRegisters())
	{
		DEBUGMSG(ZONE_ERROR, (TEXT("WAVEDEV.DLL:HardwareContext::Init() - Failed to map config registers.\r\n")));
		bRet = FALSE;
        goto Exit;
	}

    //----- 3. Map the DMA buffers into driver's virtual address space -----
    if(!MapDMABuffers())
    {
		DEBUGMSG(ZONE_ERROR, (TEXT("WAVEDEV.DLL:HardwareContext::Init() - Failed to map DMA buffers.\r\n")));
		bRet = FALSE;
        goto Exit;
    }

	//---- Configure the AC97 Controller
	AC97_Init();

    //----- 4. Configure the Codec -----
    InitCodec();
    
	//----- 5. Initialize the interrupt thread -----
    if (!InitInterruptThread())
    {
		DEBUGMSG(ZONE_ERROR, (TEXT("WAVEDEV.DLL:HardwareContext::Init() - Failed to initialize interrupt thread.\r\n")));
		bRet = FALSE;
        goto Exit;
    }

    //
    // Power Manager expects us to init in D0.
    // We are normally in D4 unless we are opened for play.
    // Inform the PM.
    //
    m_Dx = D0;
    //DevicePowerNotify(_T("WAV1:"),(_CEDEVICE_POWER_STATE)D4, POWER_NAME);

    RETAILMSG(1,(_T("AC97AUDIO::Init.\r\n")));    
    
Exit:
    return bRet;
}


/*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Function:		MapRegisters()

Description:	Maps the config registers used by both the SPI and
				I2S controllers.

Notes:			The SPI and I2S controllers both use the GPIO config
				registers, so these MUST be initialized FIRST.

Returns:		Boolean indicating success
-------------------------------------------------------------------*/
BOOL HardwareContext::MapRegisters()
{
    v_pAC97regs = (volatile AC97reg *)VirtualAlloc(0, sizeof(AC97reg), MEM_RESERVE, PAGE_NOACCESS);
	if (!v_pAC97regs)
	{
		AC97MSG(1, (TEXT("AC97reg: VirtualAlloc failed!\r\n")));
		return(FALSE);
	}
	if (!VirtualCopy((PVOID)v_pAC97regs, (PVOID)(AC97_BASE), sizeof(AC97reg), PAGE_READWRITE | PAGE_NOCACHE))
	{
		AC97MSG(1, (TEXT("AC97reg: VirtualCopy failed!\r\n")));
		return(FALSE);
	}

	v_pIOPregs = (volatile IOPreg *)VirtualAlloc(0,sizeof(IOPreg),MEM_RESERVE, PAGE_NOACCESS);
	if (!v_pIOPregs)
	{
		AC97MSG(1,(TEXT("IOPreg: VirtualAlloc failed!\r\n")));
		return FALSE;
	}
	if (!VirtualCopy((PVOID)v_pIOPregs,(PVOID)(IOP_BASE),sizeof(IOPreg), PAGE_READWRITE | PAGE_NOCACHE ))
	{
		AC97MSG(1,(TEXT("IOPreg: VirtualCopy failed!\r\n")));
		return FALSE;
	}

	v_pDMAregs = (volatile DMAreg *)VirtualAlloc(0,sizeof(DMAreg),MEM_RESERVE, PAGE_NOACCESS);
	if (!v_pDMAregs)
	{
		AC97MSG(1,(TEXT("DMAreg: VirtualAlloc failed!\r\n")));
		return FALSE;
	}
	if (!VirtualCopy((PVOID)v_pDMAregs,(PVOID)(DMA_BASE),sizeof(DMAreg), PAGE_READWRITE | PAGE_NOCACHE ))
	{
		AC97MSG(1,(TEXT("DMAreg: VirtualCopy failed!\r\n")));
		return FALSE;
	}

	s2440INT = (volatile INTreg *)VirtualAlloc(0,sizeof(INTreg),MEM_RESERVE, PAGE_NOACCESS);
	if (!v_pDMAregs)
	{
		AC97MSG(1,(TEXT("INTreg: VirtualAlloc failed!\r\n")));
		return FALSE;
	}
	if (!VirtualCopy((PVOID)s2440INT,(PVOID)(INT_BASE),sizeof(INTreg), PAGE_READWRITE | PAGE_NOCACHE ))
	{
		AC97MSG(1,(TEXT("INTreg: VirtualCopy failed!\r\n")));
		return FALSE;
	}

	g_pCLKPWRreg = (volatile CLKPWRreg *)VirtualAlloc(0,sizeof(CLKPWRreg),MEM_RESERVE, PAGE_NOACCESS);
	if (!g_pCLKPWRreg)
	{
		AC97MSG(1,(TEXT("DMAreg: VirtualAlloc failed!\r\n")));
		return FALSE;
	}
	if (!VirtualCopy((PVOID)g_pCLKPWRreg,(PVOID)(CLKPWR_BASE),sizeof(CLKPWRreg), PAGE_READWRITE | PAGE_NOCACHE ))
	{
		AC97MSG(1,(TEXT("DMAreg: VirtualCopy failed!\r\n")));
		return FALSE;
	}
   
	return TRUE;
}


/*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Function:		Deinit()

Description:	Deinitializest the hardware: disables DMA channel(s), 
				clears any pending interrupts, powers down the audio
				codec chip, etc.

Returns:		Boolean indicating success
-------------------------------------------------------------------*/
BOOL HardwareContext::Deinit()
{
	//----- 1. Disable the input/output channels -----
//	AUDIO_IN_DMA_DISABLE();
	AUDIO_OUT_DMA_DISABLE();

	//----- 2. Disable/clear DMA input/output interrupts -----
	AUDIO_IN_CLEAR_INTERRUPTS();
	AUDIO_OUT_CLEAR_INTERRUPTS();

	//----- 3. Turn the audio hardware off -----
    AudioMute(DMA_CH_OUT | DMA_CH_MIC, TRUE);

    //----- 4. Unmap the control registers and DMA buffers -----
    UnmapRegisters();
	UnmapDMABuffers();

    return TRUE;
}


/*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Function:		UnmapRegisters()

Description:	Unmaps the config registers used by both the SPI and
				I2S controllers.

Notes:			The SPI and I2S controllers both use the GPIO config
				registers, so these MUST be deinitialized LAST.

Returns:		Boolean indicating success
-------------------------------------------------------------------*/
BOOL HardwareContext::UnmapRegisters()
{
	//----- 1. Free the fast driver-->driver calling mechanism object -----
	if(g_hUTLObject) 
	{
        CloseHandle(g_hUTLObject);
	}

	return TRUE;
}


/*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Function:		MapDMABuffers()

Description:	Maps the DMA buffers used for audio input/output
				on the I2S bus.

Returns:		Boolean indicating success
-------------------------------------------------------------------*/
BOOL HardwareContext::MapDMABuffers()
{
    BOOL bSuccess=FALSE;

	PBYTE pTemp;

    //----- 1. Allocate a block of virtual memory big enough to hold the DMA buffers -----
    if(!(pTemp = (PBYTE)VirtualAlloc(0, AUDIO_DMA_PAGE_SIZE * 4, MEM_RESERVE, PAGE_NOACCESS)))
	{
		DEBUGMSG(ZONE_ERROR, (TEXT("WAVEDEV.DLL:HardwareContext::MapDMABuffers() - Unable to allocate memory for DMA buffers!\r\n")));
		goto MAP_ERROR;
	}

    //----- 2. Map the physical DMA buffer to the virtual address we just allocated -----
	if(!VirtualCopy((LPVOID)pTemp, (LPVOID)AUDIO_DMA_BUFFER_BASE, (AUDIO_DMA_PAGE_SIZE * 4), 
					PAGE_READWRITE | PAGE_NOCACHE))
	{
		DEBUGMSG(ZONE_ERROR, (TEXT("WAVEDEV.DLL:HardwareContext::MapDMABuffers() - VirtualCopy() failed when binding DMA buffers.\r\n")));
		goto MAP_ERROR;
    }

	//----- 3. Setup the DMA page pointers -----
	//		   NOTE: Currently, input and output each have two DMA pages; these pages are used in a round-robin
	//				 fashion so that the OS can read/write one buffer while the audio codec chip read/writes the
	//				 other buffer.
    m_Output_pbDMA_PAGES[0] = pTemp;
    m_Output_pbDMA_PAGES[1] = pTemp + AUDIO_DMA_PAGE_SIZE;
    m_Input_pbDMA_PAGES[0]  = pTemp + 2*AUDIO_DMA_PAGE_SIZE;
    m_Input_pbDMA_PAGES[1]  = pTemp + 3*AUDIO_DMA_PAGE_SIZE;

    return TRUE;
	
MAP_ERROR:
	if(pTemp)
		VirtualFree(pTemp, 0, MEM_RELEASE);

	return FALSE;
}



/*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Function:		UnmapDMABuffers()

Description:	Unmaps the DMA buffers used for audio input/output
				on the I2S bus.

Returns:		Boolean indicating success
-------------------------------------------------------------------*/
BOOL HardwareContext::UnmapDMABuffers()
{
	if(m_Output_pbDMA_PAGES[0])
	{
		VirtualFree((PVOID)m_Output_pbDMA_PAGES[0], 0, MEM_RELEASE);
	}

	return TRUE;
}

void AC97_GPIO_Init()
{
	//----- 2. Configure the GPIO pins for AC97 mode -----
	//		   

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
国产最新精品免费| 91精品国产品国语在线不卡| 欧美三日本三级三级在线播放| 精品久久久久久亚洲综合网| 一区二区三区免费| 国产成人免费在线| 欧美一区二区三级| 亚洲国产精品影院| 色综合色综合色综合| 国产精品色哟哟| 国产一区二区免费视频| 欧美tickling挠脚心丨vk| 日韩精品视频网站| 欧美男同性恋视频网站| 一区二区在线免费| 色噜噜狠狠色综合欧洲selulu| 国产无遮挡一区二区三区毛片日本| 日韩精品三区四区| 91麻豆精品国产91久久久资源速度| 最新成人av在线| 99精品偷自拍| 亚洲欧美日韩国产一区二区三区| gogogo免费视频观看亚洲一| 久久色.com| 国产伦理精品不卡| 国产亚洲一区二区三区在线观看 | 久久精品一区二区三区不卡| 日韩精品一二三四| 在线成人av网站| 三级影片在线观看欧美日韩一区二区| 日本韩国欧美国产| 亚洲图片欧美视频| 欧美日韩成人在线一区| 天天综合色天天综合| 7777精品伊人久久久大香线蕉完整版| 亚洲1区2区3区4区| 欧美一区二区三区的| 久久国产尿小便嘘嘘| 欧美变态凌虐bdsm| 处破女av一区二区| 综合欧美亚洲日本| 欧美猛男gaygay网站| 丝袜a∨在线一区二区三区不卡| 制服丝袜av成人在线看| 久久69国产一区二区蜜臀| 久久精品视频免费| 91在线观看美女| 日韩高清在线电影| 久久综合狠狠综合久久激情| 高清成人免费视频| 亚洲欧美视频在线观看视频| 91精品在线免费| 国产精品一级在线| 亚洲影视在线观看| 精品国产91亚洲一区二区三区婷婷| 国产剧情一区在线| 亚洲欧美区自拍先锋| 在线电影一区二区三区| 国产成人免费视频网站| 亚洲综合清纯丝袜自拍| 亚洲精品在线一区二区| 一本色道久久综合亚洲aⅴ蜜桃 | 日韩视频免费直播| 成人综合婷婷国产精品久久 | 亚洲激情第一区| 日韩午夜激情免费电影| 波多野结衣91| 五月天久久比比资源色| 国产欧美综合在线观看第十页 | 99久久精品国产毛片| 免费在线观看成人| 亚洲美女免费在线| 26uuuu精品一区二区| 欧美日韩在线三级| 成人高清av在线| 国模冰冰炮一区二区| 亚洲第一成年网| 17c精品麻豆一区二区免费| 精品国产伦一区二区三区观看方式 | 日韩亚洲欧美一区| 91蜜桃视频在线| 国产不卡视频在线观看| 日本在线观看不卡视频| 亚洲精品一二三区| 国产精品天干天干在线综合| 欧美tickling网站挠脚心| 欧美日韩高清一区| 91福利在线导航| 91啪在线观看| 成人国产精品免费网站| 国产揄拍国内精品对白| 另类专区欧美蜜桃臀第一页| 亚洲成人你懂的| 亚洲国产精品欧美一二99| 日韩理论片中文av| 国产精品对白交换视频| 国产偷国产偷精品高清尤物 | 日韩午夜在线观看| 欧美日韩国产影片| 色哟哟一区二区| 91小视频在线| 9色porny自拍视频一区二区| 国产成人精品亚洲777人妖| 精品一区二区免费看| 久热成人在线视频| 蜜桃av噜噜一区二区三区小说| 日韩中文字幕区一区有砖一区| 亚洲一区二区三区视频在线播放| 亚洲视频一区在线| 一区二区三区在线免费播放| 亚洲男人都懂的| 一区二区免费在线播放| 一区二区免费看| 亚洲成av人片在线观看| 天堂蜜桃91精品| 偷窥少妇高潮呻吟av久久免费| 午夜私人影院久久久久| 天天综合天天做天天综合| 青青草91视频| 国产一区二区在线视频| 国产成人午夜片在线观看高清观看| 国产尤物一区二区| www.日韩精品| 欧美性生活大片视频| 欧美一区二区三区视频免费播放 | 制服丝袜亚洲色图| 日韩一级在线观看| 久久精品视频免费观看| 亚洲欧美日韩在线播放| 日韩中文字幕一区二区三区| 久久99精品国产.久久久久久| 国产精品白丝jk黑袜喷水| av电影在线观看完整版一区二区| 91在线观看高清| 制服丝袜成人动漫| 国产日韩欧美麻豆| 亚洲精品国产第一综合99久久 | av电影在线观看一区| 欧美性淫爽ww久久久久无| 日韩视频在线你懂得| 亚洲国产精华液网站w| 亚洲自拍偷拍九九九| 热久久国产精品| 成人国产视频在线观看| 欧美日韩1区2区| 中文字幕精品一区二区精品绿巨人| 亚洲精品欧美在线| 久久99久久99小草精品免视看| 丁香婷婷综合网| 7799精品视频| 亚洲天天做日日做天天谢日日欢| 亚洲成av人片在线| 成人免费视频免费观看| 911精品产国品一二三产区 | 久久九九影视网| 亚洲综合免费观看高清完整版在线| 免费日韩伦理电影| 色一情一乱一乱一91av| 精品裸体舞一区二区三区| 亚洲一区在线视频| 国产成人av自拍| 日韩你懂的在线播放| 夜夜嗨av一区二区三区四季av| 国产精品99久久久| 日韩亚洲欧美综合| 亚洲国产另类精品专区| 91在线丨porny丨国产| 亚洲精品一区二区三区蜜桃下载 | 欧美伦理影视网| 亚洲三级电影网站| 国产电影一区在线| 日韩欧美国产一区二区在线播放 | 欧美日本一道本在线视频| 中文字幕亚洲一区二区va在线| 蜜臀精品一区二区三区在线观看| 在线观看不卡一区| 亚洲乱码中文字幕综合| 国产成a人无v码亚洲福利| 精品欧美一区二区久久| 五月天视频一区| 欧美日韩免费高清一区色橹橹| 1000部国产精品成人观看| 国产精品一区二区三区网站| 日韩免费成人网| 免费看日韩a级影片| 欧美精品自拍偷拍动漫精品| 亚洲一二三级电影| 色视频一区二区| 亚洲午夜精品一区二区三区他趣| 97久久精品人人做人人爽50路| 亚洲国产精品v| 99精品欧美一区二区三区综合在线| 2014亚洲片线观看视频免费| 久久91精品久久久久久秒播| 精品日产卡一卡二卡麻豆| 免费观看日韩av| 日韩精品一区二区在线| 韩国成人精品a∨在线观看| 久久久久久久性| 成人午夜精品一区二区三区|