📄 xllp_audio.c
字号:
/******************************************************************************
**
** COPYRIGHT (C) 2001, 2002 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_touch.c
**
** PURPOSE: contains all primitive functions for Bulverde/Mainstone/UCB1400 basic
** audio operations
******************************************************************************/
#include "xllp_audio.h"
/******************************************************************************
XDP_DOC_HDR_END
Function Name: XllpAc97SetDACVolume(P_XLLP_AC97_T pAC97Reg,
XLLP_UINT8_T leftVolume, XLLP_UINT8_T rightVolume)
Description: Set master volume of UCB1400 codec
Global Registers Modified: Master volume register of UCB1400 codec
Input Arguments: P_XLLP_AC97_T, P_XLLP_OST_T, void *, XLLP_UINT8_T, XLLP_UINT8_T
leftVolume and rightVolume should be less than XLLP_AC97_U14_MAX_VOLUME
0 -- mute, 1 -- attenuation of -93db, 63 -- 0db attenuation,
every step from 1 -- 63 is 1.5db
Output Arguments:
None
return:
XLLP_TRUE
XLLP_FALSE
XLLP_DOC_HDR_END
*******************************************************************************/
XLLP_BOOL_T XllpAc97SetDACVolume(P_XLLP_AC97_T pAC97Reg, P_XLLP_OST_T pOstRegs,
XLLP_UINT8_T leftVolume, XLLP_UINT8_T rightVolume)
{
XLLP_AC97_ERROR_T err;
XLLP_UINT16_T value;
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;
}
err = XllpAc97Write(XLLP_AC97_CR_MASTER_VOLUME, value, pAC97Reg, pOstRegs, XLLP_AC97_RW_TIMEOUT_DEF,
XLLP_AUDIO_CODEC_ID);
if (XLLP_AC97_NO_ERROR != err)
{
return XLLP_FALSE;
}
return XLLP_TRUE;
}
/******************************************************************************
XDP_DOC_HDR_END
Function Name: XllpAc97SelectADCSource(P_XLLP_AC97_T pAC97Reg, XLLP_AC97_ADC_SOURCE source)
Description: Set record source of UCB1400 codec
Global Registers Modified: Record select register of UCB1400 codec
Input Arguments: P_XLLP_AC97_T, P_XLLP_OST_T, void *, XLLP_AC97_ADC_SOURCE
Output Arguments:
None
return:
XLLP_TRUE
XLLP_FALSE
XLLP_DOC_HDR_END
*******************************************************************************/
XLLP_BOOL_T XllpAc97SelectADCSource(P_XLLP_AC97_T pAC97Reg, P_XLLP_OST_T pOstRegs, XLLP_AC97_ADC_SOURCE source)
{
XLLP_AC97_ERROR_T err;
XLLP_UINT16_T value;
if (XLLP_AC97_MIC == source)
{//microphone
value = XLLP_AC97_U14_RSR_SL_MIC | XLLP_AC97_U14_RSR_SR_CL;
}
else
{//line in
value = (XLLP_UINT16_T)(XLLP_AC97_U14_RSR_SR_LINE | XLLP_AC97_U14_RSR_SL_LINE);
}
err = XllpAc97Write(XLLP_AC97_CR_RECORD_SELECT, value, pAC97Reg, pOstRegs, XLLP_AC97_RW_TIMEOUT_DEF,
XLLP_AUDIO_CODEC_ID);
if (XLLP_AC97_NO_ERROR != err)
{
return XLLP_FALSE;
}
return XLLP_TRUE;
}
/******************************************************************************
XDP_DOC_HDR_END
Function Name: XllpAc97SetADCGain(P_XLLP_AC97_T pAC97Reg, XLLP_UINT8_T leftVolume, XLLP_UINT8_T rightVolume)
Description: Set audio ADC gain of UCB1400 codec
Global Registers Modified: Record gain register of UCB1400 codec
Input Arguments: P_XLLP_AC97_T, P_XLLP_OST_T, void *, XLLP_UINT8_T, XLLP_UINT8_T
leftVolume and rightVolume should be less than XLLP_AC97_U14_MAX_ADCGAIN
0 -- mute, 1 -- 1.5db, 15 -- 22.5db
every step from 1 -- 15 is 1.5db
Output Arguments:
None
return:
XLLP_TRUE
XLLP_FALSE
XLLP_DOC_HDR_END
*******************************************************************************/
XLLP_BOOL_T XllpAc97SetADCGain(P_XLLP_AC97_T pAC97Reg, P_XLLP_OST_T pOstRegs, XLLP_UINT8_T leftVolume, XLLP_UINT8_T rightVolume)
{
XLLP_AC97_ERROR_T err;
XLLP_UINT16_T value;
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;
}
err = XllpAc97Write(XLLP_AC97_CR_RECORD_GAIN, value, pAC97Reg, pOstRegs,
XLLP_AC97_RW_TIMEOUT_DEF, XLLP_AUDIO_CODEC_ID);
if (XLLP_AC97_NO_ERROR != err)
{
return XLLP_FALSE;
}
return XLLP_TRUE;
}
/******************************************************************************
XDP_DOC_HDR_END
Function Name: XllpAc97SetSampleRate(P_XLLP_AC97_T pAC97Reg, XLLP_BOOL_T isDAC, XLLP_UINT32_T sampleRate)
Description: Set DAC or ADC sample rate of UCB1400 codec
Global Registers Modified: Extention audio control status register of UCB1400 codec
PCM front DAC rate control register
PCM L+R ADC rate control register
Input Arguments: P_XLLP_AC97_T, P_XLLP_OST_T, void *, XLLP_BOOL_T, XLLP_UINT32_T
Output Arguments:
None
return:
XLLP_TRUE
XLLP_FALSE
XLLP_DOC_HDR_END
*******************************************************************************/
XLLP_BOOL_T XllpAc97SetSampleRate(P_XLLP_AC97_T pAC97Reg, P_XLLP_OST_T pOstRegs, XLLP_BOOL_T isDAC, XLLP_UINT32_T sampleRate)
{
XLLP_AC97_ERROR_T err;
XLLP_UINT16_T value;
switch (sampleRate)
{
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_FALSE;
}
//enable VRA mode
err = XllpAc97Write(XLLP_AC97_CR_E_AUDIO_CTRL_STAT, XLLP_AC97_U14_EASCR_VRA, pAC97Reg,
pOstRegs, XLLP_AC97_RW_TIMEOUT_DEF,
XLLP_AUDIO_CODEC_ID);
if (XLLP_AC97_NO_ERROR != err)
{
return XLLP_FALSE;
}
if (XLLP_TRUE == isDAC)
{
err = XllpAc97Write(XLLP_AC97_CR_E_ASR_PCM_FRNT_DAC_RT, value, pAC97Reg, pOstRegs,
XLLP_AC97_RW_TIMEOUT_DEF, XLLP_AUDIO_CODEC_ID);
}
else
{
err = XllpAc97Write(XLLP_AC97_CR_E_ASR_PCM_LR_ADC_RT, value, pAC97Reg, pOstRegs,
XLLP_AC97_RW_TIMEOUT_DEF, XLLP_AUDIO_CODEC_ID);
}
if (XLLP_AC97_NO_ERROR != err)
{
return XLLP_FALSE;
}
return XLLP_TRUE;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -