?? wavepdd.c
字號(hào):
//
// Copyright(C) Renesas Technology Corp. 1999-2005. All rights reserved.
//
// WaveDev Driver for ITS-DS7
//
//----------------------------------------------------------------------------
//
// FILE : WAVEPDD.C
// CREATED : 1999.04.26 (for HD64465 on PFM-DS6)
// MODIFIED : 2005.02.25
// AUTHOR : Renesas Technology Corp.
// HARDWARE : RENESAS ITS-DS7
// FUNCTION : MDD-PDD interface layer of waveform audio driver
// HISTORY :
// 2003.06.20
// - Created release code.
// (based on WaveDev driver for ITS-DS6 Ver.2.2.0 for WCE4.1)
// 2004.03.03
// - Revised initialize RegQueryValueEx parameter.
// 2004.09.01
// - Created release code for WCE5.0.
// 2005.02.25
// - Modified SetMute argument.
// - Moved UpdateInputSelect and private_SetMixerValue are moved to each hac.c and hssi.c.
// - Removed software volume control.
//
// Copyright (c) 1995-2000 Microsoft Corporation. All rights reserved.
//
// Functions:
// PDD_AudioGetInterruptType
// PDD_AudioMessage
// PDD_AudioInitialize
// PDD_AudioDeinitialize
// PDD_AudioPowerHandler
// PDD_WaveProc
#include <windows.h>
#include <types.h>
#include <memory.h>
#include <excpt.h>
#include <waveddsi.h>
#include <wavedbg.h>
#include <mmsystem.h>
#include "wavepdd.h"
#include "waveOutpdd.h"
#include "waveInpdd.h"
#include "drv_glob.h"
#include "platform.h"
#include "shx.h"
#include "oalintr.h"
#define ZONE_VOLUME 0
PWAVEFORMATEX g_pwfx[2];
PCM_TYPE g_pcmtype[2];
struct _global_volume
{
ULONG dwMasterVolume;
ULONG dwLineInVolume;
ULONG dwMicVolume;
BOOL fMasterMute;
BOOL fLineInMute;
BOOL fMicMute;
ULONG dwInputSelect;
} g_VolumeSettings;
DWORD gIntrAudio;
DWORD AUDIO_NO; // Audio Driver No.
PDRIVER_GLOBALS pDriverGlobals; // Drivers Globals
extern VOID set_aud_index(PDRIVER_GLOBALS, int);
extern VOID codec_updateRecordSelect( USHORT );
extern VOID codec_updateRecordGain( ULONG );
extern VOID private_waveOutSetVolume( ULONG );
extern void SetMute ( BOOL );
extern void private_waveOutGetVolume(PULONG);
extern void private_SetDefaultVolume();
MMRESULT private_SetMixerValue(DWORD, DWORD);
void DumpRegKey( DWORD, PTSTR, HKEY); //TEST
/*****************************************************************************
* FUNCTION : PDD_AudioGetInterruptType
* DESCRIPTION : decodes type of audio interrupt
* INPUTS : None
* OUTPUTS : interrupt type
* DESIGN NOTES :
* CAUTIONS : returned value contains both audio-in and -out states
*****************************************************************************/
AUDIO_STATE
PDD_AudioGetInterruptType(
VOID
)
{
// An audio interrupt has occured. We need to tell the MDD who owns it
// and what state that puts us in.
//
// Note: return value represents both an audio-in and an audio-out state
// (AUDIO_STATE stores audio-in and audio-out in separate nybbles)
return (private_AudioInGetInterruptType() & AUDIO_STATE_IN_MASK) |
(private_AudioOutGetInterruptType() & AUDIO_STATE_OUT_MASK) ;
}
/*****************************************************************************
* FUNCTION : PDD_AudioInitialize
* DESCRIPTION : intializes system for audio-in and audio-out
* INPUTS : None
* OUTPUTS : TRUE
* DESIGN NOTES : tries to initialize the other, even if one fails
* CAUTIONS :
*****************************************************************************/
BOOL
PDD_AudioInitialize(
DWORD dwIndex
)
{
BOOL inSuccess, outSuccess;
HKEY hKey;
HKEY hActive;
DWORD dwData;
DWORD dwSize;
DWORD dwType;
DWORD dwRet;
BYTE key[256];
int PLAY_CH; // DMA Ch (for Playback)
int REC_CH; // DMA Ch (for Recording)
FUNC_WPDD("+PDD_AudioInitialize");
// Open key
dwRet = (DWORD)RegOpenKeyEx(HKEY_LOCAL_MACHINE, (LPCWSTR)dwIndex, 0, 0, &hActive);
if (dwRet != ERROR_SUCCESS) {
RETAILMSG(1,(TEXT("!PDD_AudioInitialize: GetRegistryConfig RegOpenKeyEx(%s) failed %d\r\n"),
dwIndex, dwRet));
return FALSE;
}
#ifdef DEBUG
DumpRegKey( 1, (PTSTR)dwIndex, hActive );
#endif
dwSize = sizeof(key);
// Get Key
dwRet = RegQueryValueEx(hActive, TEXT("Key"), 0, &dwType,
(PUCHAR)key, &dwSize);
if (dwRet == ERROR_SUCCESS) {
DEBUGMSG(ZONE_INIT,(TEXT("!PDD_AudioInitialize: Key = %s\r\n"), key));
}
else {
RETAILMSG(1,(TEXT("!PDD_AudioInitialize: Key not found in registry.\r\n")));
return FALSE;
}
// Open key
dwRet = (DWORD)RegOpenKeyEx(HKEY_LOCAL_MACHINE, (USHORT*)key, 0, 0, (PHKEY)&hKey);
if (dwRet != ERROR_SUCCESS) {
RETAILMSG(1,(TEXT("!PDD_AudioInitialize: GetRegistryConfig RegOpenKeyEx(%s) failed %d\r\n"),
dwIndex, dwRet));
return FALSE;
}
#ifdef DEBUG
DumpRegKey( 1, (PTSTR)&key, hKey );
#endif
dwSize = sizeof(dwData);
// Get SYSINTR
dwRet = RegQueryValueEx(hKey, TEXT("SysIntr"), 0, &dwType,
(PUCHAR)&dwData, &dwSize);
if (dwRet == ERROR_SUCCESS) {
gIntrAudio = dwData;
DEBUGMSG(ZONE_INIT,(TEXT("!PDD_AudioInitialize: SysIntr = %08x.\r\n"), gIntrAudio));
}
else {
RETAILMSG(1,(TEXT("!PDD_AudioInitialize: SysIntr not found in registry.\r\n")));
return FALSE;
}
// Get Audio No.
dwRet = RegQueryValueEx(hKey, TEXT("Audio_No"), 0, &dwType,
(PUCHAR)&dwData, &dwSize);
if (dwRet == ERROR_SUCCESS) {
AUDIO_NO = dwData;
DEBUGMSG(ZONE_INIT,(TEXT("!PDD_AudioInitialize: AUDIO_NO = %08x.\r\n"), AUDIO_NO));
}
else {
RETAILMSG(1,(TEXT("!PDD_AudioInitialize: AUDIO_NO not found in registry.\r\n")));
return FALSE;
}
// Get PLAY_CH
dwRet = RegQueryValueEx(hKey, TEXT("PLAY_CH"), 0, &dwType,
(PUCHAR)&dwData, &dwSize);
if (dwRet == ERROR_SUCCESS) {
PLAY_CH = dwData;
DEBUGMSG(ZONE_INIT,(TEXT("!PDD_AudioInitialize: PLAY_CH = %08x.\r\n"), PLAY_CH));
}
else {
RETAILMSG(1,(TEXT("!PDD_AudioInitialize: PLAY_CH not found in registry.\r\n")));
return FALSE;
}
// Get REC_CH
dwRet = RegQueryValueEx(hKey, TEXT("REC_CH"), 0, &dwType,
(PUCHAR)&dwData, &dwSize);
if (dwRet == ERROR_SUCCESS) {
REC_CH = dwData;
DEBUGMSG(ZONE_INIT,(TEXT("!PDD_AudioInitialize: REC_CH = %08x.\r\n"), REC_CH));
}
else {
RETAILMSG(1,(TEXT("!PDD_AudioInitialize: REC_CH not found in registry.\r\n")));
return FALSE;
}
// Close Key
dwRet = RegCloseKey(hKey);
// Close Key
dwRet = RegCloseKey(hActive);
// Setup a Access to AudioPlaying Address and AudioOutInterrupt
pDriverGlobals = VirtualAlloc( NULL,
DRIVER_GLOBALS_PHYSICAL_MEMORY_SIZE,
MEM_RESERVE,
PAGE_NOACCESS);
if (pDriverGlobals == NULL) {
DEBUGMSG(ZONE_ERROR,(TEXT("Drv Global virtual alloc NG!!\r\n")));
return FALSE;
}
if (!VirtualCopy( (PVOID)pDriverGlobals,
(PVOID)DRIVER_GLOBALS_PHYSICAL_MEMORY_START,
(DWORD)DRIVER_GLOBALS_PHYSICAL_MEMORY_SIZE,
PAGE_READWRITE | PAGE_NOCACHE)) {
DEBUGMSG(ZONE_ERROR,(TEXT("Drv Global virtual copy NG!!\r\n")));
VirtualFree((PVOID)pDriverGlobals, 0, MEM_RELEASE);
return FALSE;
}
pDriverGlobals->aud[AUDIO_NO].PLAY_CH = PLAY_CH;
pDriverGlobals->aud[AUDIO_NO].REC_CH = REC_CH;
set_aud_index(pDriverGlobals, AUDIO_NO);
outSuccess = private_AudioOutInitialize();
if ( outSuccess == FALSE ) return outSuccess;
inSuccess = private_AudioInInitialize();
set_aud_index(pDriverGlobals, AUDIO_NO);
// Set the global master volume and input volume
private_SetDefaultVolume();
FUNC_WPDD("-PDD_AudioInitialize");
return inSuccess && outSuccess;
}
/*****************************************************************************
* FUNCTION : private_GetMixerValue
* DESCRIPTION : Get Mixer Value
* INPUTS : None
* OUTPUTS : None
* DESIGN NOTES :
* CAUTIONS :
*****************************************************************************/
MMRESULT
private_GetMixerValue(DWORD dwControl, PDWORD pdwSetting)
{
switch (dwControl) {
case WPDMX_MASTER_VOL:
private_waveOutGetVolume(pdwSetting);
break;
case WPDMX_MASTER_MUTE:
*pdwSetting = g_VolumeSettings.fMasterMute;
break;
case WPDMX_LINEIN_VOL:
*pdwSetting = g_VolumeSettings.dwLineInVolume;
break;
case WPDMX_LINEIN_MUTE:
*pdwSetting = g_VolumeSettings.fLineInMute;
break;
case WPDMX_MIC_VOL:
*pdwSetting = g_VolumeSettings.dwMicVolume;
break;
case WPDMX_MIC_MUTE:
*pdwSetting = g_VolumeSettings.fMicMute;
break;
case WPDMX_INPUT_MUX:
*pdwSetting = g_VolumeSettings.dwInputSelect;
break;
default:
DEBUGMSG(1, (TEXT("private_GetMixerValue: unrecognized control %d"), dwControl));
return MMSYSERR_NOTSUPPORTED;
}
DEBUGMSG(ZONE_VOLUME, (TEXT("private_GetMixerValue(%04x, %08x)\r\n"), dwControl, *pdwSetting));
return MMSYSERR_NOERROR;
}
/*****************************************************************************
?? 快捷鍵說(shuō)明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號(hào)
Ctrl + =
減小字號(hào)
Ctrl + -