📄 hwctxt.h
字号:
typedef enum {
PORT4 = 3,
PORT5 = 4,
PORT6 = 5,
PORT7 = 6,
} AUDMUX_EXTERNAL_PORT;
// Define the timed delay interval that will be used between the completion
// of an audio I/O operation and the disabling of the audio CODEC hardware.
// On some hardware platforms, enabling the audio CODEC hardware can require
// a significant ramp-up time (up to 150 ms in the case of the MC13783 PMIC).
// Therefore, when back-to-back audio I/O operations are performed, it is
// best to just leave the audio CODEC hardware enabled in between the two
// audio streams.
//
// The delay interval that is defined here will be used to determine how
// long after an audio stream has been completed before the audio CODEC
// hardware is actually disabled. If another audio stream operation is
// started, before the interval has expired, then the timeout is simply
// cancelled and the audio CODEC will not need to be reenabled for the
// second audio stream.
//
// For the MC13783 PMIC, a delay of 1 sec is recommended since that should
// give enough time to perform back-to-back audio I/O operations. We don't
// want the delay interval to be too long, however, or else we end up
// wasting power by keeping the audio CODEC enabled when it is not being
// used.
//
// Making the delay interval shorter than 1 sec is also not recommended
// since that can cause the audio CODEC to be disabled just before another
// audio stream is processed. This would eliminate any benefit of having
// this delayed CODEC disable feature.
//
// Note that for audio CODECs that don't have any noticeable ramp-up or
// enable delay period, a timer value of 0 is allowed. Setting the timer
// delay interval to 0 will immediately disable the audio CODEC upon the
// completion of each audio stream I/O operation.
static const PLAYBACK_DISABLE_DELAY_MSEC = 1000; // Default 1000
#ifdef AUDIO_RECORDING_EANBLED
static const RECORD_DISABLE_DELAY_MSEC = 1000; // Default 1000
#else
static const RECORD_DISABLE_DELAY_MSEC = 0; // Must be zero if audio
// recording is disabled.
#endif // #ifdef AUDIO_RECORDING_ENABLED
DWORD m_DriverIndex;
CRITICAL_SECTION m_Lock;
BOOL m_Initialized;
static const int NUM_DMA_BUFFERS = 2; // For DMA transfers to/from the
// audio hardware we need to allocate
// 2 buffers and we just alternate
// between them. Note that we allocate
// separate pairs of DMA buffers for
// output/playback and for
// input/recording.
static const int INTR_PRIORITY = 249; // Default interrupt thread priority.
static const unsigned short INTR_PRIORITY_REGKEY[12];
OutputDeviceContext m_OutputDeviceContext;
DWORD m_dwOutputGain;
BOOL m_fOutputMute;
PBYTE m_Output_pbDMA_PAGES[NUM_DMA_BUFFERS];
BOOL m_OutputDMARunning;
WORD m_nOutputVolume; // Current HW Playback Volume.
// Volume.
#ifdef AUDIO_RECORDING_ENABLED
InputDeviceContext m_InputDeviceContext;
DWORD m_dwInputGain;
BOOL m_fInputMute;
PBYTE m_Input_pbDMA_PAGES[NUM_DMA_BUFFERS];
BOOL m_InputDMARunning;
WORD m_nInputVolume; // Current HW Input (Microphone)
// Declare 2 timer IDs (one for playback and another one for recording)
// that will be used to control the timed delay when disabling the audio
// hardware. This allows for better performance when back-to-back audio
// operations are performed.
MMRESULT m_AudioDelayDisableTimerID[2];
HANDLE m_hAudioDelayDisableEvent[2];
#else
// Declare 1 timer ID (for playback only) that will be used to control the
// timed delay when disabling the audio hardware. This allows for better
// performance when back-to-back audio operations are performed.
MMRESULT m_AudioDelayDisableTimerID[1];
HANDLE m_hAudioDelayDisableEvent[1];
#endif // #ifdef AUDIO_RECORDING_ENABLED
BOOL m_audioPowerdown; // Flag to indicate if PowerDown() has been called.
DWORD m_MicrophoneRouting;
DWORD m_SpeakerRouting;
DWORD m_InternalRouting;
DWORD m_MasterOutputGain;
BOOL InitInterruptThread();
BOOL InitOutputDMA();
BOOL DeinitOutputDMA();
ULONG TransferOutputBuffer(const PBYTE pBufferStart,
const PBYTE pBufferEnd);
ULONG TransferOutputBuffers(DWORD dwDCSR);
#ifdef AUDIO_RECORDING_ENABLED
BOOL InitInputDMA();
BOOL DeinitInputDMA();
ULONG TransferInputBuffer(ULONG NumBuf);
ULONG TransferInputBuffers(DWORD dwDCSR, DWORD checkFirst);
#endif // #ifdef AUDIO_RECORDING_ENABLED
BOOL MapRegisters();
BOOL UnmapRegisters();
BOOL MapDMABuffers();
BOOL UnmapDMABuffers();
DWORD GetInterruptThreadPriority();
HANDLE m_hAudioInterrupt; // Handle to Audio Interrupt event.
HANDLE m_hAudioInterruptThread; // Handle to thread which waits on
// an audio interrupt event.
HANDLE m_hAudioDelayedDisableThread; // Handle for thread that will
// process all timeout events from
// the CODEC delayed disable timer.
//-------------------- Platform specific members ---------------------------
volatile DWORD m_OutputDMAStatus; // Output DMA channel's status
UINT8 m_OutputDMAChan; // Ouput DMA virtual channel index
UINT32 m_OutputDMALevel; // Ouput DMA watermark level
#ifdef AUDIO_RECORDING_ENABLED
volatile DWORD m_InputDMAStatus; // Input DMA channel's status
UINT8 m_InputDMAChan; // Input DMA virtual channel index
UINT32 m_InputDMALevel; // Input DMA watermark level
#endif
AUDIO_PWR_STATE m_CodecPwrState;
PCSP_SSI_REG m_pSSI1;
DWORD m_dwSysintrSSI1;
PCSP_SSI_REG m_pSSI2;
DWORD m_dwSysintrSSI2;
PCSP_AUDMUX_REG m_pAUDMUX;
//------------------- Board Support Package Interface ----------------------
BOOL BSPAudioInit();
BOOL BSPAudioDeinit();
PBYTE BSPAudioAllocDMABuffers(PHYSICAL_ADDRESS *pPhysicalAddress);
void BSPAudioDeallocDMABuffers(PVOID virtualAddress);
void BSPAudioInitCodec(AUDIO_BUS bus);
void BSPAudioSetCodecPower(AUDIO_PWR_STATE state);
void BSPAudioPowerUp(const BOOL fullPowerUp);
void BSPAudioPowerDown(const BOOL fullPowerOff);
void BSPAudioInitSsi(AUDIO_BUS bus, PCSP_SSI_REG pSSI);
void BSPAudioRoute(AUDMUX_INTERNAL_PORT intPort,
AUDMUX_EXTERNAL_PORT extPort,
BOOL bMaster);
PCSP_SSI_REG BSPAudioGetStDACSSI();
BOOL BSPAudioInitOutput(AUDIO_BUS bus);
BOOL BSPAudioStartOutput(AUDIO_BUS bus, AUDIO_PATH path,
const HWSAMPLE *const ssiFifoPrefill,
const unsigned nSsiFifoPrefill);
BOOL BSPAudioStopOutput(AUDIO_BUS bus, AUDIO_PATH path);
BOOL BSPAudioSetOutputGain(AUDIO_BUS bus, const DWORD dwGain);
void BSPAudioStartSsiOutput(PCSP_SSI_REG pSSI,
const HWSAMPLE *const ssiFifoPrefill,
const unsigned nSsiFifoPrefill);
void BSPAudioStopSsiOutput(PCSP_SSI_REG pSSI);
void BSPAudioStartCodecOutput(AUDIO_BUS bus, AUDIO_PATH path);
void BSPAudioStopCodecOutput(AUDIO_BUS bus, AUDIO_PATH path);
#ifdef AUDIO_RECORDING_ENABLED
PCSP_SSI_REG BSPAudioGetVCodecSSI();
BOOL BSPAudioInitInput(AUDIO_BUS bus);
BOOL BSPAudioStartInput(AUDIO_BUS bus, AUDIO_PATH path);
BOOL BSPAudioStopInput(AUDIO_BUS bus, AUDIO_PATH path);
BOOL BSPAudioSetInputGain(AUDIO_BUS bus, const DWORD dwGain);
void BSPAudioStartSsiInput(PCSP_SSI_REG pSSI);
void BSPAudioStopSsiInput(PCSP_SSI_REG pSSI);
void BSPAudioStartCodecInput(AUDIO_BUS bus, AUDIO_PATH path);
void BSPAudioStopCodecInput(AUDIO_BUS bus, AUDIO_PATH path);
#endif // #ifdef AUDIO_RECORDING_ENABLED
};
extern void CallInterruptThread(HardwareContext *pHWContext);
extern void BSPAudioDisableDelayHandler(HardwareContext *pHWContext);
//--------------------------------- Externs ------------------------------------
extern HardwareContext *g_pHWContext;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -