📄 xllp_wm9712.c
字号:
/******************************************************************************
**
** COPYRIGHT (C) 2000, 2001 Intel Corporation.
**
** This software as well as the software described in it is furnished under
** license and may only be used or copied in accordance with the terms of the
** license. The information in this file is furnished for informational use
** only, is subject to change without notice, and should not be construed as
** a commitment by Intel Corporation. Intel Corporation assumes no
** responsibility or liability for any errors or inaccuracies that may appear
** in this document or any software that may be provided in association with
** this document.
** Except as permitted by such license, no part of this document may be
** reproduced, stored in a retrieval system, or transmitted in any form or by
** any means without the express written consent of Intel Corporation.
**
** FILENAME: xllp_wm9712.c
**
** PURPOSE: XLLP ACODEC for wm9712 codec.
**
** Valid for : wm9712 codec
**
**
******************************************************************************/
#include "xllp_ac97acodec.h"
#include "xllp_wm9712.h"
XLLP_ACODEC_ERROR_T XllpWm9712SetMasterVol(XLLP_ACODEC_CONTEXT_T *pDeviceContext, XLLP_UINT16_T GainInDb)
{
XLLP_ACODEC_ERROR_T status = XLLP_ACODEC_SUCCESS;
XLLP_UINT16_T value;
XLLP_UINT8_T leftVolume, rightVolume;
/*take the unit of GainInDb as 1 db*/
leftVolume = (XLLP_UINT8_T)(GainInDb * 10 / 15);
if (leftVolume > XLLP_AC97_U14_MAX_VOLUME)
{
leftVolume = XLLP_AC97_U14_MAX_VOLUME;
}
rightVolume = leftVolume;
if ((0 == leftVolume) && (0 == rightVolume))
{
//mute the output
value = XLLP_AC97_U14_MVR_MM;
}
else
{
leftVolume = XLLP_AC97_U14_MAX_VOLUME - leftVolume; //translate into attenuation value
rightVolume = XLLP_AC97_U14_MAX_VOLUME - rightVolume;
value = leftVolume << XLLP_AC97_U14_MVR_ML_SHIFT;
value |= rightVolume;
}
status = XllpAc97ACodecWrite (pDeviceContext, XLLP_AC97_CR_MASTER_VOLUME, value);
return status;
}
XLLP_ACODEC_ERROR_T XllpWm9712SetMasterInputGain(XLLP_ACODEC_CONTEXT_T *pDeviceContext, XLLP_UINT16_T GainInDb)
{
XLLP_ACODEC_ERROR_T status = XLLP_ACODEC_SUCCESS;
XLLP_UINT8_T leftVolume, rightVolume;
XLLP_UINT16_T value;
/*take the unit of GainInDb as 1 db*/
leftVolume = (XLLP_UINT8_T)(GainInDb * 10 / 15);
if (leftVolume > XLLP_AC97_U14_MAX_ADCGAIN)
{
leftVolume = XLLP_AC97_U14_MAX_ADCGAIN;
}
rightVolume = leftVolume;
if ((0 == leftVolume) && (0 == rightVolume))
{
//mute the record
value = XLLP_AC97_U14_RGR_RM;
}
else
{
value = leftVolume << XLLP_AC97_U14_RGR_GL_SHIFT;
value |= rightVolume;
}
status = XllpAc97ACodecWrite (pDeviceContext, XLLP_AC97_CR_RECORD_GAIN, value);
return status;
}
XLLP_ACODEC_ERROR_T XllpWm9712GetInSampleRate(XLLP_ACODEC_CONTEXT_T *pDeviceContext, XLLP_UINT16_T * RateInHz)
{
XLLP_ACODEC_ERROR_T status = XLLP_ACODEC_SUCCESS;
XLLP_UINT16_T value;
status = XllpAc97ACodecRead(pDeviceContext, XLLP_AC97_CR_E_ASR_PCM_LR_ADC_RT, &value);
if (XLLP_ACODEC_SUCCESS != status)
{
return status;
}
switch (value)
{
case XLLP_AC97_U14_DR_8000:
*RateInHz = 8000;
break;
case XLLP_AC97_U14_DR_11025:
*RateInHz = 11025;
break;
case XLLP_AC97_U14_DR_16000:
*RateInHz = 16000;
break;
case XLLP_AC97_U14_DR_22050:
*RateInHz = 22050;
break;
case XLLP_AC97_U14_DR_32000:
*RateInHz = 32000;
break;
case XLLP_AC97_U14_DR_44100:
*RateInHz = 44100;
break;
default:
*RateInHz = 48000;
break;
}
return status;
}
XLLP_ACODEC_ERROR_T XllpWm9712GetOutSampleRate (XLLP_ACODEC_CONTEXT_T *pDeviceContext, XLLP_UINT16_T * RateInHz)
{
XLLP_ACODEC_ERROR_T status = XLLP_ACODEC_SUCCESS;
XLLP_UINT16_T value;
status = XllpAc97ACodecRead(pDeviceContext, XLLP_AC97_CR_E_ASR_PCM_FRNT_DAC_RT, &value);
if (XLLP_ACODEC_SUCCESS != status)
{
return status;
}
switch (value)
{
case XLLP_AC97_U14_DR_8000:
*RateInHz = 8000;
break;
case XLLP_AC97_U14_DR_11025:
*RateInHz = 11025;
break;
case XLLP_AC97_U14_DR_16000:
*RateInHz = 16000;
break;
case XLLP_AC97_U14_DR_22050:
*RateInHz = 22050;
break;
case XLLP_AC97_U14_DR_32000:
*RateInHz = 32000;
break;
case XLLP_AC97_U14_DR_44100:
*RateInHz = 44100;
break;
default:
*RateInHz = 48000;
break;
}
return status;
}
XLLP_ACODEC_ERROR_T XllpWm9712SetInSampleRate(XLLP_ACODEC_CONTEXT_T *pDeviceContext, XLLP_UINT16_T RateInHz)
{
XLLP_ACODEC_ERROR_T status = XLLP_ACODEC_SUCCESS;
XLLP_UINT16_T value;
switch (RateInHz)
{
case 8000:
value = XLLP_AC97_U14_DR_8000;
break;
case 11025:
value = XLLP_AC97_U14_DR_11025;
break;
case 16000:
value = XLLP_AC97_U14_DR_16000;
break;
case 22050:
value = XLLP_AC97_U14_DR_22050;
break;
case 32000:
value = XLLP_AC97_U14_DR_32000;
break;
case 44100:
value = XLLP_AC97_U14_DR_44100;
break;
case 48000:
value = XLLP_AC97_U14_DR_48000;
break;
default:
return XLLP_ACODEC_SAMPLERATE_INVALID;
}
//enable VRA mode
status = XllpAc97ACodecWrite(pDeviceContext, XLLP_AC97_CR_E_AUDIO_CTRL_STAT, XLLP_AC97_U14_EASCR_VRA);
if (XLLP_ACODEC_SUCCESS != status)
{
return status;
}
status = XllpAc97ACodecWrite(pDeviceContext, XLLP_AC97_CR_E_ASR_PCM_LR_ADC_RT, value);
return status;
}
XLLP_ACODEC_ERROR_T XllpWm9712SetOutSampleRate (XLLP_ACODEC_CONTEXT_T *pDeviceContext, XLLP_UINT16_T RateInHz)
{
XLLP_ACODEC_ERROR_T status = XLLP_ACODEC_SUCCESS;
XLLP_UINT16_T value;
switch (RateInHz)
{
case 8000:
value = XLLP_AC97_U14_DR_8000;
break;
case 11025:
value = XLLP_AC97_U14_DR_11025;
break;
case 16000:
value = XLLP_AC97_U14_DR_16000;
break;
case 22050:
value = XLLP_AC97_U14_DR_22050;
break;
case 32000:
value = XLLP_AC97_U14_DR_32000;
break;
case 44100:
value = XLLP_AC97_U14_DR_44100;
break;
case 48000:
value = XLLP_AC97_U14_DR_48000;
break;
default:
return XLLP_ACODEC_SAMPLERATE_INVALID;
}
//enable VRA mode
status = XllpAc97ACodecWrite(pDeviceContext, XLLP_AC97_CR_E_AUDIO_CTRL_STAT, XLLP_AC97_U14_EASCR_VRA);
if (XLLP_ACODEC_SUCCESS != status)
{
return status;
}
status = XllpAc97ACodecWrite(pDeviceContext, XLLP_AC97_CR_E_ASR_PCM_FRNT_DAC_RT, value);
return status;
}
XLLP_ACODEC_ERROR_T XllpWm9712EnterEquipmentState (XLLP_ACODEC_CONTEXT_T *pDeviceContext,XLLP_ACODEC_EQUIPMENT_T equipmentState)
{
return XLLP_ACODEC_CODEC_FEATURE_NOT_SUPPORTED;
}
XLLP_ACODEC_ERROR_T XllpWm9712GetEquipmentState (XLLP_ACODEC_CONTEXT_T *pDeviceContext,XLLP_ACODEC_EQUIPMENT_T * pEquipmentState)
{
return XLLP_ACODEC_CODEC_FEATURE_NOT_SUPPORTED;
}
XLLP_ACODEC_ERROR_T XllpWm9712SpecificInit (XLLP_ACODEC_CONTEXT_T *pDeviceContext)
{
XllpAc97ACodecWrite (pDeviceContext, MIC_VOLUME, 0x6000);
XllpAc97ACodecWrite (pDeviceContext, RECORD_GAIN, 0x8000);
XllpAc97ACodecWrite (pDeviceContext, LOUT2_ROUT2, 0x0);
XllpAc97ACodecWrite (pDeviceContext, OUT3_VOLUME, 0x0);
XllpAc97ACodecWrite (pDeviceContext, MONOOUT_VOLUME, 0x0);
XllpAc97ACodecWrite (pDeviceContext, PHONE_VOLUME, 0x0);
XllpAc97ACodecWrite (pDeviceContext, RECORD_SELECT, 0x0);
XllpAc97ACodecWrite (pDeviceContext, HEADPHONE_VOLUME, 0x0);
XllpAc97ACodecWrite (pDeviceContext, DAC_VOLUME, 0x0);
XllpAc97ACodecWrite (pDeviceContext, MASTER_VOLUME, 0x0);
return XLLP_ACODEC_SUCCESS;
}
XLLP_ACODEC_ERROR_T XllpWm9712SpecificDeInit (XLLP_ACODEC_CONTEXT_T *pDeviceContext)
{
return XLLP_ACODEC_SUCCESS;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -