📄 lm4549.cpp
字号:
// LM4549.cpp: implementation of the CLM4549 class.
//
//////////////////////////////////////////////////////////////////////
#include "LM4549.h"
const int MAX_FREQ = 48000;
const int MIN_FREQ = 8000;
//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////
CLM4549::CLM4549(CCX5530Audio *pController):
CAC97Codec(pController)
{
}
CLM4549::~CLM4549()
{
}
bool CLM4549::SetSampleRate(bool bInput, DWORD dwFrequency)
{
FUNCMSG2("+CLM4549::SetSampleRate: %s, %d", bInput?(TEXT("recording")):(TEXT("playback")), dwFrequency);
if (!m_pController)
return false;
if (dwFrequency < MIN_FREQ || dwFrequency > MAX_FREQ)
return false;
WORD wReg = bInput?LM4549_PCM_LR_ADC_RATE:LM4549_PCM_FRONT_DAC_RATE;
return m_pController->WriteAC97(wReg, WORD(dwFrequency));
}
bool CLM4549::Reset()
{
WORD wReg = 0;
int nAttempts;
FUNCMSG("+CAD1819A::Reset()");
if (!m_pController)
return false;
// initialize the codec
m_pController->WriteAC97( AC97_RESET, 0);
wReg = 0;
nAttempts = 5;
while(nAttempts >0 && (wReg & 0x000F) != 0x000F)
{
Sleep(200);
m_pController->ReadAC97(LM4549_POWERDOWN_CTRL_STAT, wReg);
nAttempts--;
}
if ((wReg & 0x000F) != 0x000F)
{
ERRMSG1("LM4549_POWERDOWN_CTRL_STAT invalid: 0x%4.4x", wReg);
return false;
}
//enable variable sample rate
m_pController->ReadAC97( LM4549_EXT_AUDIO_CTRL_STAT, wReg); // read VRA register
m_pController->WriteAC97( LM4549_EXT_AUDIO_CTRL_STAT,wReg|1); // set the VRA bit to ON
// set default sample rate
SetSampleRate(true, 44100);
SetSampleRate(false, 44100);
// set default volumes to max
m_pController->WriteAC97( AC97_MASTER_VOLUME, 0); // left/right vol to max
m_pController->WriteAC97( AC97_PCM_OUT_VOL, 0); // left/right vol to max
FUNCMSG("-CLM4549::Reset() success");
return true;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -