BOOL HardwareContext::CodecPowerControl() { USHORT powerCtrl1; USHORT powerCtrl2;
powerCtrl1 = ReadCodecRegister(CS42L52__POWER_CONTROL_1); powerCtrl2 = ReadCodecRegister(CS42L52__POWER_CONTROL_2);
if( m_bInputDMARunning & m_bOutputDMARunning ) // ADC, DAC power up
{ RETAILMSG(HWC_MSG,(_T("Codec_channel() - In & Out\r\n")));
WriteCodecRegister(CS42L52__POWER_CONTROL_1, (powerCtrl1 & ( CS42L52_POWERUP_ADC_CHARGE_PUMP | CS42L52_POWERUP_PGA_A | CS42L52_POWERUP_PGA_B | CS42L52_POWERUP_ADC_A | CS42L52_POWERUP_ADC_B | CS42L52_POWERUP_CODEC )));
WriteCodecRegister(CS42L52__POWER_CONTROL_2, (powerCtrl2 & ( CS42L52_POWERDOWN_ADC_A_OVERRIDE_ENABLE | CS42L52_POWERDOWN_ADC_B_OVERRIDE_ENABLE | CS42L52_POWERUP_MIC_A | CS42L52_POWERUP_MIC_B | CS42L52_POWERUP_MIC_BIAS )));
WriteCodecRegister(CS42L52__POWER_CONTROL_3, ( CS42L52_HEADPHONE_A_ON_PIN31_HI | CS42L52_HEADPHONE_B_ON_PIN31_HI | CS42L52_SPEAKER_A_ON_PIN31_LO | CS42L52_SPEAKER_B_ON_PIN31_LO )); } else if( m_bInputDMARunning ) // ADC power up, DAC power down
{ RETAILMSG(HWC_MSG,(_T("Codec_channel() - In\r\n"))); WriteCodecRegister(CS42L52__POWER_CONTROL_1, (powerCtrl1 & ( CS42L52_POWERUP_ADC_CHARGE_PUMP | CS42L52_POWERUP_PGA_A | CS42L52_POWERUP_PGA_B | CS42L52_POWERUP_ADC_A | CS42L52_POWERUP_ADC_B | CS42L52_POWERUP_CODEC )));
WriteCodecRegister(CS42L52__POWER_CONTROL_2, (powerCtrl2 & ( CS42L52_POWERDOWN_ADC_A_OVERRIDE_ENABLE | CS42L52_POWERDOWN_ADC_B_OVERRIDE_ENABLE | CS42L52_POWERUP_MIC_A | CS42L52_POWERUP_MIC_B | CS42L52_POWERUP_MIC_BIAS )));
WriteCodecRegister(CS42L52__POWER_CONTROL_3, ( CS42L52_HEADPHONE_A_ALWAYS_OFF | CS42L52_HEADPHONE_B_ALWAYS_OFF | CS42L52_SPEAKER_A_ALWAYS_OFF | CS42L52_SPEAKER_B_ALWAYS_OFF ));
} else if( m_bOutputDMARunning ) // DAC power up, ADC power down
{ RETAILMSG(HWC_MSG,(_T("Codec_channel() - Out\r\n")));
WriteCodecRegister(CS42L52__POWER_CONTROL_1, (powerCtrl1 & ( CS42L52_POWERUP_ADC_CHARGE_PUMP | CS42L52_POWERDOWN_PGA_A | CS42L52_POWERDOWN_PGA_B | CS42L52_POWERDOWN_ADC_A | CS42L52_POWERDOWN_ADC_B | CS42L52_POWERDOWN_CODEC )));
WriteCodecRegister(CS42L52__POWER_CONTROL_2, (powerCtrl2 & ( CS42L52_POWERDOWN_ADC_A_OVERRIDE_DISABLE | CS42L52_POWERDOWN_ADC_B_OVERRIDE_DISABLE | CS42L52_POWERDOWN_MIC_A | CS42L52_POWERDOWN_MIC_B | CS42L52_POWERDOWN_MIC_BIAS )));
WriteCodecRegister(CS42L52__POWER_CONTROL_3, ( CS42L52_HEADPHONE_A_ON_PIN31_HI | CS42L52_HEADPHONE_B_ON_PIN31_HI | CS42L52_SPEAKER_A_ON_PIN31_LO | CS42L52_SPEAKER_B_ON_PIN31_LO )); } else // ADC/DAC power down
{ RETAILMSG(HWC_MSG,(_T("Codec_channel() - none\r\n")));
WriteCodecRegister(CS42L52__POWER_CONTROL_1, (powerCtrl1 & ( CS42L52_POWERUP_ADC_CHARGE_PUMP | CS42L52_POWERDOWN_PGA_A | CS42L52_POWERDOWN_PGA_B | CS42L52_POWERDOWN_ADC_A | CS42L52_POWERDOWN_ADC_B | CS42L52_POWERDOWN_CODEC )));
WriteCodecRegister(CS42L52__POWER_CONTROL_2, (powerCtrl2 & ( CS42L52_POWERDOWN_ADC_A_OVERRIDE_DISABLE | CS42L52_POWERDOWN_ADC_B_OVERRIDE_DISABLE | CS42L52_POWERDOWN_MIC_A | CS42L52_POWERDOWN_MIC_B | CS42L52_POWERDOWN_MIC_BIAS )));
WriteCodecRegister(CS42L52__POWER_CONTROL_3, ( CS42L52_HEADPHONE_A_ALWAYS_OFF | CS42L52_HEADPHONE_B_ALWAYS_OFF | CS42L52_SPEAKER_A_ALWAYS_OFF | CS42L52_SPEAKER_B_ALWAYS_OFF )); }
return(TRUE); }
BOOL HardwareContext::CodecMuteControl(DWORD channel, BOOL bMute) { USHORT val;
if(channel & DMA_CH_OUT) { val = ReadCodecRegister(CS42L52__PLAYBACK_CONTROL_2);
if(bMute) { WriteCodecRegister(CS42L52__PLAYBACK_CONTROL_2, (val & (CS42L52_SPEAKER_A_MUTE_ENABLE | CS42L52_SPEAKER_B_MUTE_ENABLE))); } else {
WriteCodecRegister(CS42L52__PLAYBACK_CONTROL_2, (val & (CS42L52_SPEAKER_A_MUTE_DISABLE| CS42L52_SPEAKER_B_MUTE_DISABLE))); } } if(channel & DMA_CH_IN) { val = ReadCodecRegister(CS42L52__MISC_ADC_CONTROL);
if(bMute) { WriteCodecRegister(CS42L52__MISC_ADC_CONTROL, (val & (CS42L52_ADC_A_MUTE_ENABLE | CS42L52_ADC_A_MUTE_ENABLE))); } else { WriteCodecRegister(CS42L52__MISC_ADC_CONTROL, (val & (CS42L52_ADC_A_MUTE_DISABLE | CS42L52_ADC_B_MUTE_DISABLE))); } } return(TRUE); }
|