2007-03-11 17:38:08 +00:00
|
|
|
/***************************************************************************
|
|
|
|
* __________ __ ___.
|
|
|
|
* Open \______ \ ____ ____ | | _\_ |__ _______ ___
|
|
|
|
* Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
|
|
|
|
* Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
|
|
|
|
* Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
|
|
|
|
* \/ \/ \/ \/ \/
|
|
|
|
* $Id$
|
|
|
|
*
|
|
|
|
* Driver for AS3514 audio codec
|
|
|
|
*
|
|
|
|
* Copyright (c) 2007 Daniel Ankers
|
2007-04-14 00:49:35 +00:00
|
|
|
* Copyright (c) 2007 Christian Gmeiner
|
2007-03-11 17:38:08 +00:00
|
|
|
*
|
2008-06-28 18:10:04 +00:00
|
|
|
* This program is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU General Public License
|
|
|
|
* as published by the Free Software Foundation; either version 2
|
|
|
|
* of the License, or (at your option) any later version.
|
2007-03-11 17:38:08 +00:00
|
|
|
*
|
|
|
|
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
|
|
|
|
* KIND, either express or implied.
|
|
|
|
*
|
|
|
|
****************************************************************************/
|
|
|
|
#include "cpu.h"
|
|
|
|
#include "debug.h"
|
|
|
|
#include "system.h"
|
2007-06-05 07:03:30 +00:00
|
|
|
#include "audio.h"
|
2008-05-03 08:35:14 +00:00
|
|
|
#include "sound.h"
|
2007-03-11 17:38:08 +00:00
|
|
|
|
2007-05-22 20:39:50 +00:00
|
|
|
#include "audiohw.h"
|
2007-03-11 17:38:08 +00:00
|
|
|
#include "i2s.h"
|
2008-10-31 00:16:42 +00:00
|
|
|
#include "ascodec.h"
|
2007-03-11 17:38:08 +00:00
|
|
|
|
2009-02-05 19:57:18 +00:00
|
|
|
/* AMS Sansas based on the AS3525 use the LINE2 input for the analog radio
|
|
|
|
signal instead of LINE1 */
|
|
|
|
#if CONFIG_CPU == AS3525
|
|
|
|
#define LINE_INPUT 2
|
|
|
|
#else
|
|
|
|
#define LINE_INPUT 1
|
|
|
|
#endif
|
|
|
|
|
2007-05-22 15:56:05 +00:00
|
|
|
const struct sound_settings_info audiohw_settings[] = {
|
2007-06-05 07:03:30 +00:00
|
|
|
[SOUND_VOLUME] = {"dB", 0, 1, -74, 6, -25},
|
2007-05-22 15:56:05 +00:00
|
|
|
/* HAVE_SW_TONE_CONTROLS */
|
2007-06-05 07:03:30 +00:00
|
|
|
[SOUND_BASS] = {"dB", 0, 1, -24, 24, 0},
|
|
|
|
[SOUND_TREBLE] = {"dB", 0, 1, -24, 24, 0},
|
2007-12-10 11:14:28 +00:00
|
|
|
[SOUND_BALANCE] = {"%", 0, 1,-100, 100, 0},
|
2007-06-05 07:03:30 +00:00
|
|
|
[SOUND_CHANNELS] = {"", 0, 1, 0, 5, 0},
|
2007-10-09 21:29:20 +00:00
|
|
|
[SOUND_STEREO_WIDTH] = {"%", 0, 5, 0, 250, 100},
|
2008-05-25 21:19:07 +00:00
|
|
|
#ifdef HAVE_RECORDING
|
2007-06-05 07:03:30 +00:00
|
|
|
[SOUND_MIC_GAIN] = {"dB", 1, 1, 0, 39, 23},
|
|
|
|
[SOUND_LEFT_GAIN] = {"dB", 1, 1, 0, 31, 23},
|
|
|
|
[SOUND_RIGHT_GAIN] = {"dB", 1, 1, 0, 31, 23},
|
2008-05-21 03:55:17 +00:00
|
|
|
#endif
|
2007-05-22 15:56:05 +00:00
|
|
|
};
|
|
|
|
|
2007-04-14 00:49:35 +00:00
|
|
|
/* Shadow registers */
|
2008-04-20 10:24:15 +00:00
|
|
|
static struct as3514_info
|
2007-06-05 07:03:30 +00:00
|
|
|
{
|
2008-11-25 16:16:06 +00:00
|
|
|
int vol_r; /* Cached volume level (R) */
|
|
|
|
int vol_l; /* Cached volume level (L) */
|
|
|
|
uint8_t regs[AS3514_NUM_AUDIO_REGS]; /* 8-bit registers */
|
2007-06-05 07:03:30 +00:00
|
|
|
} as3514;
|
|
|
|
|
2007-04-14 00:49:35 +00:00
|
|
|
/*
|
|
|
|
* little helper method to set register values.
|
2007-06-05 07:03:30 +00:00
|
|
|
* With the help of as3514.regs, we minimize i2c
|
2007-04-14 00:49:35 +00:00
|
|
|
* traffic.
|
|
|
|
*/
|
2007-06-05 07:03:30 +00:00
|
|
|
static void as3514_write(unsigned int reg, unsigned int value)
|
2007-04-14 00:49:35 +00:00
|
|
|
{
|
2008-10-31 00:16:42 +00:00
|
|
|
if (ascodec_write(reg, value) != 2)
|
2007-04-14 00:49:35 +00:00
|
|
|
{
|
2007-06-05 07:03:30 +00:00
|
|
|
DEBUGF("as3514 error reg=0x%02x", reg);
|
2007-04-14 00:49:35 +00:00
|
|
|
}
|
2007-05-04 10:28:07 +00:00
|
|
|
|
2007-06-05 07:03:30 +00:00
|
|
|
if (reg < ARRAYLEN(as3514.regs))
|
2007-05-04 10:28:07 +00:00
|
|
|
{
|
2007-06-05 07:03:30 +00:00
|
|
|
as3514.regs[reg] = value;
|
2007-05-04 10:28:07 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2007-06-05 07:03:30 +00:00
|
|
|
DEBUGF("as3514 error reg=0x%02x", reg);
|
2007-05-04 10:28:07 +00:00
|
|
|
}
|
2007-04-14 00:49:35 +00:00
|
|
|
}
|
|
|
|
|
2007-06-05 07:03:30 +00:00
|
|
|
/* Helpers to set/clear bits */
|
2008-11-25 16:16:06 +00:00
|
|
|
static void as3514_set(unsigned int reg, unsigned int bits)
|
2007-06-05 07:03:30 +00:00
|
|
|
{
|
|
|
|
as3514_write(reg, as3514.regs[reg] | bits);
|
|
|
|
}
|
|
|
|
|
2008-11-25 16:16:06 +00:00
|
|
|
static void as3514_clear(unsigned int reg, unsigned int bits)
|
2007-06-05 07:03:30 +00:00
|
|
|
{
|
2008-11-25 16:16:06 +00:00
|
|
|
as3514_write(reg, as3514.regs[reg] & ~bits);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void as3514_write_masked(unsigned int reg, unsigned int bits,
|
|
|
|
unsigned int mask)
|
|
|
|
{
|
|
|
|
as3514_write(reg, (as3514.regs[reg] & ~mask) | (bits & mask));
|
2007-06-05 07:03:30 +00:00
|
|
|
}
|
|
|
|
|
2007-03-11 17:38:08 +00:00
|
|
|
/* convert tenth of dB volume to master volume register value */
|
|
|
|
int tenthdb2master(int db)
|
|
|
|
{
|
2007-05-20 19:09:15 +00:00
|
|
|
/* +6 to -73.5dB in 1.5dB steps == 53 levels */
|
2007-03-11 17:38:08 +00:00
|
|
|
if (db < VOLUME_MIN) {
|
|
|
|
return 0x0;
|
|
|
|
} else if (db >= VOLUME_MAX) {
|
2007-05-20 19:09:15 +00:00
|
|
|
return 0x35;
|
2007-03-11 17:38:08 +00:00
|
|
|
} else {
|
|
|
|
return((db-VOLUME_MIN)/15); /* VOLUME_MIN is negative */
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2007-06-05 07:03:30 +00:00
|
|
|
int sound_val2phys(int setting, int value)
|
|
|
|
{
|
|
|
|
int result;
|
|
|
|
|
|
|
|
switch(setting)
|
|
|
|
{
|
2008-05-21 03:55:17 +00:00
|
|
|
#if defined(HAVE_RECORDING)
|
2007-06-05 07:03:30 +00:00
|
|
|
case SOUND_LEFT_GAIN:
|
|
|
|
case SOUND_RIGHT_GAIN:
|
|
|
|
case SOUND_MIC_GAIN:
|
|
|
|
result = (value - 23) * 15;
|
|
|
|
break;
|
2008-05-21 03:55:17 +00:00
|
|
|
#endif
|
2007-06-05 07:03:30 +00:00
|
|
|
|
|
|
|
default:
|
|
|
|
result = value;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
2007-03-11 17:38:08 +00:00
|
|
|
/*
|
|
|
|
* Initialise the PP I2C and I2S.
|
|
|
|
*/
|
2008-10-31 00:16:42 +00:00
|
|
|
void audiohw_preinit(void)
|
2007-04-14 00:49:35 +00:00
|
|
|
{
|
|
|
|
unsigned int i;
|
|
|
|
|
2008-11-25 16:16:06 +00:00
|
|
|
/* read all reg values */
|
|
|
|
for (i = 0; i < ARRAYLEN(as3514.regs); i++)
|
|
|
|
{
|
|
|
|
as3514.regs[i] = ascodec_read(i);
|
|
|
|
}
|
|
|
|
|
2007-03-11 17:38:08 +00:00
|
|
|
/* Set ADC off, mixer on, DAC on, line out off, line in off, mic off */
|
2007-06-05 07:03:30 +00:00
|
|
|
|
|
|
|
/* Turn on SUM, DAC */
|
2008-11-25 16:16:06 +00:00
|
|
|
as3514_write(AS3514_AUDIOSET1, AUDIOSET1_DAC_on | AUDIOSET1_SUM_on);
|
2007-06-05 07:03:30 +00:00
|
|
|
|
2007-10-25 09:15:31 +00:00
|
|
|
/* Set BIAS on, DITH on, AGC on, IBR_DAC max, LSP_LP on, IBR_LSP min */
|
2008-11-25 16:16:06 +00:00
|
|
|
as3514_write(AS3514_AUDIOSET2,
|
|
|
|
AUDIOSET2_IBR_DAC_0 | AUDIOSET2_LSP_LP |
|
|
|
|
AUDIOSET2_IBR_LSP_50);
|
2007-10-25 09:15:31 +00:00
|
|
|
|
2008-12-16 22:16:55 +00:00
|
|
|
/* AMS Sansas based on the AS3525 need HPCM enabled, otherwise they output the
|
|
|
|
L-R signal on both L and R headphone outputs instead of normal stereo.
|
|
|
|
Turning it off saves a little power on targets that don't need it. */
|
|
|
|
#if (CONFIG_CPU == AS3525)
|
2008-11-25 16:16:06 +00:00
|
|
|
/* Set HPCM on, ZCU on */
|
|
|
|
as3514_write(AS3514_AUDIOSET3, 0);
|
2008-12-16 22:16:55 +00:00
|
|
|
#else
|
|
|
|
/* Set HPCM off, ZCU on */
|
|
|
|
as3514_write(AS3514_AUDIOSET3, AUDIOSET3_HPCM_off);
|
|
|
|
#endif
|
2007-06-05 07:03:30 +00:00
|
|
|
|
2007-10-25 09:15:31 +00:00
|
|
|
/* Mute and disable speaker */
|
2008-11-25 16:16:06 +00:00
|
|
|
as3514_write(AS3514_LSP_OUT_R, LSP_OUT_R_SP_OVC_TO_256MS | 0x00);
|
|
|
|
as3514_write(AS3514_LSP_OUT_L, LSP_OUT_L_SP_MUTE | 0x00);
|
2007-10-25 09:15:31 +00:00
|
|
|
|
2008-11-25 16:16:06 +00:00
|
|
|
/* Set headphone over-current to 0, Min volume */
|
|
|
|
as3514_write(AS3514_HPH_OUT_R,
|
|
|
|
HPH_OUT_R_HP_OVC_TO_0MS | 0x00);
|
|
|
|
|
|
|
|
/* Headphone ON, MUTE, Min volume */
|
|
|
|
as3514_write(AS3514_HPH_OUT_L,
|
|
|
|
HPH_OUT_L_HP_ON | HPH_OUT_L_HP_MUTE | 0x00);
|
2007-06-05 07:03:30 +00:00
|
|
|
|
|
|
|
/* LRCK 24-48kHz */
|
2008-11-25 16:16:06 +00:00
|
|
|
as3514_write(AS3514_PLLMODE, PLLMODE_LRCK_24_48);
|
2007-04-14 00:49:35 +00:00
|
|
|
|
2007-06-05 07:03:30 +00:00
|
|
|
/* DAC_Mute_off */
|
2008-11-25 16:16:06 +00:00
|
|
|
as3514_set(AS3514_DAC_L, DAC_L_DAC_MUTE_off);
|
2007-06-05 07:03:30 +00:00
|
|
|
|
|
|
|
/* M1_Sup_off */
|
2008-11-25 16:16:06 +00:00
|
|
|
as3514_set(AS3514_MIC1_L, MIC1_L_M1_SUP_off);
|
2007-06-05 07:03:30 +00:00
|
|
|
/* M2_Sup_off */
|
2008-11-25 16:16:06 +00:00
|
|
|
as3514_set(AS3514_MIC2_L, MIC2_L_M2_SUP_off);
|
2007-03-11 17:38:08 +00:00
|
|
|
}
|
|
|
|
|
2008-11-25 16:16:06 +00:00
|
|
|
void audiohw_postinit(void)
|
2007-03-11 17:38:08 +00:00
|
|
|
{
|
2008-11-25 16:16:06 +00:00
|
|
|
/* wait until outputs have stabilized */
|
|
|
|
sleep(HZ/4);
|
2007-03-11 17:38:08 +00:00
|
|
|
|
2008-11-25 16:16:06 +00:00
|
|
|
#ifdef CPU_PP
|
2008-11-26 05:46:33 +00:00
|
|
|
ascodec_suppressor_on(false);
|
2008-11-25 16:16:06 +00:00
|
|
|
#endif
|
|
|
|
|
|
|
|
audiohw_mute(false);
|
2007-03-11 17:38:08 +00:00
|
|
|
}
|
|
|
|
|
2008-02-13 11:19:23 +00:00
|
|
|
void audiohw_set_master_vol(int vol_l, int vol_r)
|
2007-03-11 17:38:08 +00:00
|
|
|
{
|
2008-11-25 16:16:06 +00:00
|
|
|
unsigned int hph_r, hph_l;
|
2007-06-05 07:03:30 +00:00
|
|
|
unsigned int mix_l, mix_r;
|
|
|
|
|
|
|
|
/* keep track of current setting */
|
|
|
|
as3514.vol_l = vol_l;
|
|
|
|
as3514.vol_r = vol_r;
|
|
|
|
|
2008-11-25 16:16:06 +00:00
|
|
|
/* We combine the mixer channel volume range with the headphone volume
|
|
|
|
range - keep first stage as loud as possible */
|
2007-06-05 07:03:30 +00:00
|
|
|
if (vol_r <= 0x16) {
|
2008-11-25 16:16:06 +00:00
|
|
|
mix_r = vol_r;
|
|
|
|
hph_r = 0;
|
2007-06-05 07:03:30 +00:00
|
|
|
} else {
|
2008-11-25 16:16:06 +00:00
|
|
|
mix_r = 0x16;
|
|
|
|
hph_r = vol_r - 0x16;
|
2007-05-20 19:09:15 +00:00
|
|
|
}
|
2007-06-05 07:03:30 +00:00
|
|
|
|
|
|
|
if (vol_l <= 0x16) {
|
2008-11-25 16:16:06 +00:00
|
|
|
mix_l = vol_l;
|
|
|
|
hph_l = 0;
|
2007-06-05 07:03:30 +00:00
|
|
|
} else {
|
2008-11-25 16:16:06 +00:00
|
|
|
mix_l = 0x16;
|
|
|
|
hph_l = vol_l - 0x16;
|
2007-05-20 19:09:15 +00:00
|
|
|
}
|
2007-03-11 17:38:08 +00:00
|
|
|
|
2009-01-08 04:21:24 +00:00
|
|
|
as3514_write_masked(AS3514_DAC_R, mix_r, AS3514_VOL_MASK);
|
|
|
|
as3514_write_masked(AS3514_DAC_L, mix_l, AS3514_VOL_MASK);
|
2009-02-05 19:57:18 +00:00
|
|
|
#if defined(HAVE_RECORDING) || defined(HAVE_FMRADIO_IN)
|
|
|
|
as3514_write_masked((LINE_INPUT == 1) ? AS3514_LINE_IN1_R :
|
|
|
|
AS3514_LINE_IN2_R,
|
|
|
|
mix_r, AS3514_VOL_MASK);
|
|
|
|
as3514_write_masked((LINE_INPUT == 1) ? AS3514_LINE_IN1_L :
|
|
|
|
AS3514_LINE_IN2_L,
|
|
|
|
mix_l, AS3514_VOL_MASK);
|
2009-01-08 04:21:24 +00:00
|
|
|
#endif
|
2008-11-25 16:16:06 +00:00
|
|
|
as3514_write_masked(AS3514_HPH_OUT_R, hph_r, AS3514_VOL_MASK);
|
|
|
|
as3514_write_masked(AS3514_HPH_OUT_L, hph_l, AS3514_VOL_MASK);
|
2007-03-11 17:38:08 +00:00
|
|
|
}
|
|
|
|
|
2008-02-13 11:19:23 +00:00
|
|
|
void audiohw_set_lineout_vol(int vol_l, int vol_r)
|
2007-03-11 17:38:08 +00:00
|
|
|
{
|
2009-02-05 19:57:18 +00:00
|
|
|
as3514_write_masked(AS3514_LINE_OUT_R, vol_r, AS3514_VOL_MASK);
|
|
|
|
as3514_write_masked(AS3514_LINE_OUT_L, vol_l, AS3514_VOL_MASK);
|
2007-03-11 17:38:08 +00:00
|
|
|
}
|
|
|
|
|
2007-06-13 06:33:40 +00:00
|
|
|
void audiohw_mute(bool mute)
|
2007-03-11 17:38:08 +00:00
|
|
|
{
|
2007-06-05 07:03:30 +00:00
|
|
|
if (mute) {
|
2008-11-25 16:16:06 +00:00
|
|
|
as3514_set(AS3514_HPH_OUT_L, HPH_OUT_L_HP_MUTE);
|
2007-03-11 17:38:08 +00:00
|
|
|
} else {
|
2008-11-25 16:16:06 +00:00
|
|
|
as3514_clear(AS3514_HPH_OUT_L, HPH_OUT_L_HP_MUTE);
|
2007-03-11 17:38:08 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-05-14 00:39:24 +00:00
|
|
|
/* Nice shutdown of AS3514 audio codec */
|
2007-03-11 17:38:08 +00:00
|
|
|
void audiohw_close(void)
|
|
|
|
{
|
2007-04-14 00:49:35 +00:00
|
|
|
/* mute headphones */
|
2007-06-05 07:03:30 +00:00
|
|
|
audiohw_mute(true);
|
2007-03-11 17:38:08 +00:00
|
|
|
|
2008-11-25 16:16:06 +00:00
|
|
|
#ifdef CPU_PP
|
2008-11-26 05:46:33 +00:00
|
|
|
ascodec_suppressor_on(true);
|
2008-11-25 16:16:06 +00:00
|
|
|
#endif
|
|
|
|
|
|
|
|
/* turn on common */
|
|
|
|
as3514_clear(AS3514_AUDIOSET3, AUDIOSET3_HPCM_off);
|
|
|
|
|
2007-04-14 00:49:35 +00:00
|
|
|
/* turn off everything */
|
2008-11-25 16:16:06 +00:00
|
|
|
as3514_clear(AS3514_HPH_OUT_L, HPH_OUT_L_HP_ON);
|
2008-04-15 21:33:32 +00:00
|
|
|
as3514_write(AS3514_AUDIOSET1, 0x0);
|
2008-11-25 16:16:06 +00:00
|
|
|
|
|
|
|
/* Allow caps to discharge */
|
|
|
|
sleep(HZ/4);
|
2007-03-11 17:38:08 +00:00
|
|
|
}
|
|
|
|
|
2008-12-12 11:01:07 +00:00
|
|
|
void audiohw_set_frequency(int fsel)
|
2007-03-11 17:38:08 +00:00
|
|
|
{
|
2008-12-12 11:01:07 +00:00
|
|
|
(void)fsel;
|
2007-03-11 17:38:08 +00:00
|
|
|
}
|
|
|
|
|
2008-05-21 03:55:17 +00:00
|
|
|
#if defined(HAVE_RECORDING)
|
2007-03-11 17:38:08 +00:00
|
|
|
void audiohw_enable_recording(bool source_mic)
|
|
|
|
{
|
2007-06-05 07:03:30 +00:00
|
|
|
if (source_mic) {
|
|
|
|
/* ADCmux = Stereo Microphone */
|
2008-11-25 16:16:06 +00:00
|
|
|
as3514_write_masked(AS3514_ADC_R, ADC_R_ADCMUX_ST_MIC,
|
|
|
|
ADC_R_ADCMUX);
|
|
|
|
|
2009-02-05 19:57:18 +00:00
|
|
|
/* MIC1_on, others off */
|
|
|
|
as3514_write_masked(AS3514_AUDIOSET1, AUDIOSET1_MIC1_on,
|
|
|
|
AUDIOSET1_INPUT_MASK);
|
|
|
|
|
2007-06-05 07:03:30 +00:00
|
|
|
/* M1_AGC_off */
|
2008-11-25 16:16:06 +00:00
|
|
|
as3514_clear(AS3514_MIC1_R, MIC1_R_M1_AGC_off);
|
2007-06-05 07:03:30 +00:00
|
|
|
} else {
|
2009-02-05 19:57:18 +00:00
|
|
|
/* ADCmux = Line_IN1 or Line_IN2 */
|
|
|
|
as3514_write_masked(AS3514_ADC_R,
|
|
|
|
(LINE_INPUT == 1) ? ADC_R_ADCMUX_LINE_IN1 :
|
|
|
|
ADC_R_ADCMUX_LINE_IN2,
|
2008-11-25 16:16:06 +00:00
|
|
|
ADC_R_ADCMUX);
|
|
|
|
|
2009-02-05 19:57:18 +00:00
|
|
|
/* LIN1_or LIN2 on, rest off */
|
|
|
|
as3514_write_masked(AS3514_AUDIOSET1,
|
|
|
|
(LINE_INPUT == 1) ? AUDIOSET1_LIN1_on :
|
|
|
|
AUDIOSET1_LIN2_on,
|
|
|
|
AUDIOSET1_INPUT_MASK);
|
2007-06-05 07:03:30 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* ADC_Mute_off */
|
2008-11-25 16:16:06 +00:00
|
|
|
as3514_set(AS3514_ADC_L, ADC_L_ADC_MUTE_off);
|
2007-06-05 07:03:30 +00:00
|
|
|
/* ADC_on */
|
2008-11-25 16:16:06 +00:00
|
|
|
as3514_set(AS3514_AUDIOSET1, AUDIOSET1_ADC_on);
|
2007-03-11 17:38:08 +00:00
|
|
|
}
|
|
|
|
|
2007-04-14 00:49:35 +00:00
|
|
|
void audiohw_disable_recording(void)
|
|
|
|
{
|
2007-06-05 07:03:30 +00:00
|
|
|
/* ADC_Mute_on */
|
2008-11-25 16:16:06 +00:00
|
|
|
as3514_clear(AS3514_ADC_L, ADC_L_ADC_MUTE_off);
|
2007-06-05 07:03:30 +00:00
|
|
|
|
2009-02-05 19:57:18 +00:00
|
|
|
/* ADC_off, all input sources off */
|
|
|
|
as3514_clear(AS3514_AUDIOSET1, AUDIOSET1_ADC_on | AUDIOSET1_INPUT_MASK);
|
2007-03-11 17:38:08 +00:00
|
|
|
}
|
|
|
|
|
2007-06-05 07:03:30 +00:00
|
|
|
/**
|
|
|
|
* Set recording volume
|
|
|
|
*
|
|
|
|
* Line in : 0 .. 23 .. 31 =>
|
|
|
|
Volume -34.5 .. +00.0 .. +12.0 dB
|
|
|
|
* Mic (left): 0 .. 23 .. 39 =>
|
|
|
|
* Volume -34.5 .. +00.0 .. +24.0 dB
|
|
|
|
*
|
|
|
|
*/
|
2007-04-14 00:49:35 +00:00
|
|
|
void audiohw_set_recvol(int left, int right, int type)
|
|
|
|
{
|
2007-06-05 07:03:30 +00:00
|
|
|
switch (type)
|
|
|
|
{
|
|
|
|
case AUDIO_GAIN_MIC:
|
|
|
|
{
|
|
|
|
/* Combine MIC gains seamlessly with ADC levels */
|
2008-11-25 16:16:06 +00:00
|
|
|
unsigned int mic1_r;
|
2007-06-05 07:03:30 +00:00
|
|
|
|
|
|
|
if (left >= 36) {
|
|
|
|
/* M1_Gain = +40db, ADR_Vol = +7.5dB .. +12.0 dB =>
|
|
|
|
+19.5 dB .. +24.0 dB */
|
|
|
|
left -= 8;
|
2008-11-25 16:16:06 +00:00
|
|
|
mic1_r = MIC1_R_M1_GAIN_40DB;
|
2007-06-05 07:03:30 +00:00
|
|
|
} else if (left >= 32) {
|
|
|
|
/* M1_Gain = +34db, ADR_Vol = +7.5dB .. +12.0 dB =>
|
|
|
|
+13.5 dB .. +18.0 dB */
|
|
|
|
left -= 4;
|
2008-11-25 16:16:06 +00:00
|
|
|
mic1_r = MIC1_R_M1_GAIN_34DB;
|
|
|
|
} else {
|
2007-06-05 07:03:30 +00:00
|
|
|
/* M1_Gain = +28db, ADR_Vol = -34.5dB .. +12.0 dB =>
|
|
|
|
-34.5 dB .. +12.0 dB */
|
2008-11-25 16:16:06 +00:00
|
|
|
mic1_r = MIC1_R_M1_GAIN_28DB;
|
|
|
|
}
|
2007-06-05 07:03:30 +00:00
|
|
|
|
|
|
|
right = left;
|
|
|
|
|
2008-11-25 16:16:06 +00:00
|
|
|
as3514_write_masked(AS3514_MIC1_R, mic1_r, MIC1_R_M1_GAIN);
|
2007-06-05 07:03:30 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
case AUDIO_GAIN_LINEIN:
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2008-11-25 16:16:06 +00:00
|
|
|
as3514_write_masked(AS3514_ADC_R, right, AS3514_VOL_MASK);
|
|
|
|
as3514_write_masked(AS3514_ADC_L, left, AS3514_VOL_MASK);
|
2007-03-11 17:38:08 +00:00
|
|
|
}
|
2009-02-05 19:57:18 +00:00
|
|
|
#endif /* HAVE_RECORDING */
|
2007-03-11 17:38:08 +00:00
|
|
|
|
2009-02-05 19:57:18 +00:00
|
|
|
#if defined(HAVE_RECORDING) || defined(HAVE_FMRADIO_IN)
|
2007-06-05 07:03:30 +00:00
|
|
|
/**
|
2009-02-05 19:57:18 +00:00
|
|
|
* Enable line in analog monitoring
|
2007-06-05 07:03:30 +00:00
|
|
|
*
|
|
|
|
*/
|
2007-11-19 15:50:52 +00:00
|
|
|
void audiohw_set_monitor(bool enable)
|
2007-03-11 17:38:08 +00:00
|
|
|
{
|
2007-06-05 07:03:30 +00:00
|
|
|
if (enable) {
|
2009-02-05 19:57:18 +00:00
|
|
|
/* select either LIN1 or LIN2 */
|
|
|
|
as3514_write_masked(AS3514_AUDIOSET1,
|
|
|
|
(LINE_INPUT == 1) ?
|
|
|
|
AUDIOSET1_LIN1_on : AUDIOSET1_LIN2_on,
|
|
|
|
AUDIOSET1_LIN1_on | AUDIOSET1_LIN2_on);
|
|
|
|
as3514_set((LINE_INPUT == 1) ? AS3514_LINE_IN1_R : AS3514_LINE_IN2_R,
|
|
|
|
LINE_IN1_R_LI1R_MUTE_off);
|
|
|
|
as3514_set((LINE_INPUT == 1) ? AS3514_LINE_IN1_L : AS3514_LINE_IN2_L,
|
|
|
|
LINE_IN1_L_LI1L_MUTE_off);
|
2008-11-25 16:16:06 +00:00
|
|
|
}
|
|
|
|
else {
|
2009-02-05 19:57:18 +00:00
|
|
|
/* turn off both LIN1 and LIN2 */
|
2008-11-25 16:16:06 +00:00
|
|
|
as3514_clear(AS3514_LINE_IN1_R, LINE_IN1_R_LI1R_MUTE_off);
|
|
|
|
as3514_clear(AS3514_LINE_IN1_L, LINE_IN1_L_LI1L_MUTE_off);
|
2009-02-05 19:57:18 +00:00
|
|
|
as3514_clear(AS3514_LINE_IN2_R, LINE_IN2_R_LI2R_MUTE_off);
|
|
|
|
as3514_clear(AS3514_LINE_IN2_L, LINE_IN2_L_LI2L_MUTE_off);
|
|
|
|
as3514_clear(AS3514_AUDIOSET1, AUDIOSET1_LIN1_on | AUDIOSET1_LIN2_on);
|
2007-06-05 07:03:30 +00:00
|
|
|
}
|
2007-03-11 17:38:08 +00:00
|
|
|
}
|
2009-02-05 19:57:18 +00:00
|
|
|
#endif /* HAVE_RECORDING || HAVE_FMRADIO_IN */
|
|
|
|
|
|
|
|
|