📄 hwctxt.h
字号:
//------------------------------------------------------------------------------
//
// 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.
//
//------------------------------------------------------------------------------
//
// Copyright (C) 2004-2006, Freescale Semiconductor, Inc. All Rights Reserved
// THIS SOURCE CODE IS CONFIDENTIAL AND PROPRIETARY AND MAY NOT
// BE USED OR DISTRIBUTED WITHOUT THE WRITTEN PERMISSION OF
// Freescale Semiconductor, Inc.
//
//------------------------------------------------------------------------------
//
// Copyright (C) 2005, MOTOROLA, INC. All Rights Reserved
// THIS SOURCE CODE IS CONFIDENTIAL AND PROPRIETARY AND MAY NOT
// BE USED OR DISTRIBUTED WITHOUT THE WRITTEN PERMISSION OF
// MOTOROLA, INC.
//
//------------------------------------------------------------------------------
//
// Header: hwctxt.h
//
// Provides definitions for audio driver hardware context.
//
//------------------------------------------------------------------------------
#pragma once
#include <windows.h>
#include <nkintr.h>
#include <ceddk.h>
#include <pm.h>
#include <mmreg.h>
#include "csp.h"
#include "ssiclass.h"
//------------------------------------------------------------------------------
// MACRO DEFINITIONS
//------------------------------------------------------------------------------
#define OUTCHANNELS (2)
#define INCHANNELS (2)
#define BITSPERSAMPLE (16)
// Inverse sample rate, in .32 fixed format, with 1 added at bottom to ensure round up.
#define INVSAMPLERATE ((UINT32)(((1i64<<32)/BSPAudioGetSampleRate())+1))
typedef INT16 HWSAMPLE;
typedef HWSAMPLE *PHWSAMPLE;
// Set USE_MIX_SATURATE to 1 if you want the mixing code to guard against saturation
// This costs a couple of instructions in the inner loop
#define USE_MIX_SATURATE (1)
// The code will use the follwing values as saturation points
#define AUDIO_SAMPLE_MAX (32767)
#define AUDIO_SAMPLE_MIN (-32768)
#define AUDIO_DMA_PAGE_SIZE 2048
class HardwareContext
{
public:
static BOOL CreateHWContext(DWORD Index);
HardwareContext();
~HardwareContext();
void Lock() {EnterCriticalSection(&m_Lock);}
void Unlock() {LeaveCriticalSection(&m_Lock);}
DWORD GetNumInputDevices() {return 1;}
DWORD GetNumOutputDevices() {return 1;}
DWORD GetNumMixerDevices() {return 1;}
DeviceContext *GetInputDeviceContext(UINT DeviceId)
{
return &m_InputDeviceContext;
}
DeviceContext *GetOutputDeviceContext(UINT DeviceId)
{
return &m_OutputDeviceContext;
}
BOOL Init(DWORD Index);
BOOL Deinit();
void PowerUp();
void PowerDown();
BOOL StartInputDMA();
BOOL StartOutputDMA();
void StopInputDMA();
void StopOutputDMA();
void InterruptThread();
DWORD GetOutputGain (void);
MMRESULT SetOutputGain (DWORD dwVolume);
DWORD GetInputGain (void);
MMRESULT SetInputGain (DWORD dwVolume);
BOOL GetOutputMute (void);
MMRESULT SetOutputMute (BOOL fMute);
BOOL GetInputMute (void);
MMRESULT SetInputMute (BOOL fMute);
BOOL PmControlMessage (
DWORD dwCode,
PBYTE pBufIn,
DWORD dwLenIn,
PBYTE pBufOut,
DWORD dwLenOut,
PDWORD pdwActualOut);
DWORD RT_AudioMessage(UINT uMsg,DWORD dwParam1,DWORD dwParam2);
protected:
DWORD m_dwOutputGain;
DWORD m_dwInputGain;
BOOL m_fInputMute;
BOOL m_fOutputMute;
DWORD m_MicrophoneRouting;
DWORD m_SpeakerRouting;
DWORD m_InternalRouting;
DWORD m_MasterOutputGain;
BOOL InitInterruptThread();
BOOL InitInputDMA();
BOOL InitOutputDMA();
BOOL MapRegisters();
BOOL UnmapRegisters();
BOOL MapDMABuffers();
BOOL UnmapDMABuffers();
UINT32 TransferInputBuffer(UINT8 bufIndex);
UINT32 TransferOutputBuffer(UINT8 bufIndex);
UINT32 TransferInputBuffers(void);
UINT32 TransferOutputBuffers(void);
DWORD GetInterruptThreadPriority();
DWORD m_DriverIndex;
CRITICAL_SECTION m_Lock;
BOOL m_Initialized;
BOOL m_InPowerHandler;
DWORD m_dwSysintrOutput;
DWORD m_dwSysintrInput;
PHYSICAL_ADDRESS m_PhysDMABufferAddr;
InputDeviceContext m_InputDeviceContext;
OutputDeviceContext m_OutputDeviceContext;
PBYTE m_Input_pbDMA_PAGES[2];
PBYTE m_Output_pbDMA_PAGES[2];
BOOL m_InputDMARunning;
BOOL m_OutputDMARunning;
// Track how many data bytes in each input/output buffers
ULONG m_OutBytes[2];
ULONG m_InBytes[2];
UINT32 m_DmaTxBuffer[2];
UINT32 m_DmaRxBuffer[2];
UINT8 m_DmaTxChannel;
UINT8 m_DmaRxChannel;
UINT8 m_TxBufIndex;
UINT8 m_RxBufIndex;
// SsiClass *m_Ssi;
//#if AC97
// UINT32 m_InputSlotMask;
//#else
// WM8731_LINEID m_RecordInput;
//#endif
HANDLE m_hAudioInterrupt; // Handle to Audio Interrupt event.
HANDLE m_hAudioInterruptThread; // Handle to thread which waits on an audio interrupt event.
//----------------------- Platform specific members ----------------------------------
DWORD m_OutputDMABuffer; // Output DMA channel's current buffer
DWORD m_InputDMABuffer; // Input DMA channel's current buffer
BOOL AudioMute(DWORD channel, BOOL bMute);
//------------------------------------------------------------------------------------
CEDEVICE_POWER_STATE m_DxState;
// ---------------- Board Support Package Interface -------------------
BOOL BSPAudioInit(); // Initialize the codec, ssi, audmux and dma
BOOL BSPAudioDeinit(); // Deinitialize
BOOL BSPAudioInitCodec(void); // initialize audio codec
MMRESULT BSPSetOutputGain(DWORD dwGain);
MMRESULT BSPSetOutputMute(BOOL fMute);
BOOL BSPSetSwap(BOOL bSwap);
BOOL BSPSetSlotTag(DWORD Tag);
BOOL BSPAudioStartOutput(BOOL enable); // to enable the output(transmit)
BOOL BSPAudioStartInput(BOOL enable); // to enable the input(receive)
UINT32 BSPAudioClearInterruptStatus(SSI_TRANSFER_DIR dir, SSI_CHANNEL channel); // to clear interrupt status of ssi
// function for power management
void BSPAudioSetPowerOnOff(BOOL bSetPlayback, BOOL bSetRecord, BOOL bOff);
// function to get the audio codec hardware sample rate
// UINT64 BSPAudioGetSampleRate( void );
};
void CallInterruptThread(HardwareContext *pHWContext);
// function to get the audio codec hardware sample rate
UINT64 BSPAudioGetSampleRate( void );
//------------------------------------------ Externs ----------------------------------------------
extern HardwareContext *g_pHWContext;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -