2007-05-02 22:33:24 +00:00
|
|
|
/***************************************************************************
|
|
|
|
* __________ __ ___.
|
|
|
|
* Open \______ \ ____ ____ | | _\_ |__ _______ ___
|
|
|
|
* Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
|
|
|
|
* Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
|
|
|
|
* Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
|
|
|
|
* \/ \/ \/ \/ \/
|
|
|
|
* $Id$
|
|
|
|
*
|
|
|
|
* Driver for WM8751 audio codec
|
|
|
|
*
|
|
|
|
* Based on code from the ipodlinux project - http://ipodlinux.org/
|
|
|
|
* Adapted for Rockbox in December 2005
|
|
|
|
*
|
|
|
|
* Original file: linux/arch/armnommu/mach-ipod/audio.c
|
|
|
|
*
|
|
|
|
* Copyright (c) 2003-2005 Bernard Leach (leachbj@bouncycastle.org)
|
|
|
|
*
|
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-05-02 22:33:24 +00:00
|
|
|
*
|
|
|
|
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
|
|
|
|
* KIND, either express or implied.
|
|
|
|
*
|
|
|
|
****************************************************************************/
|
|
|
|
#include "kernel.h"
|
|
|
|
#include "wmcodec.h"
|
|
|
|
#include "audio.h"
|
2007-05-22 20:39:50 +00:00
|
|
|
#include "audiohw.h"
|
2008-02-06 05:15:06 +00:00
|
|
|
#include "system.h"
|
2011-12-21 18:02:50 +00:00
|
|
|
#include "sound.h"
|
2007-05-02 22:33:24 +00:00
|
|
|
|
2007-05-22 15:56:05 +00:00
|
|
|
const struct sound_settings_info audiohw_settings[] = {
|
|
|
|
[SOUND_VOLUME] = {"dB", 0, 1, -74, 6, -25},
|
|
|
|
[SOUND_BASS] = {"dB", 1, 15, -60, 90, 0},
|
|
|
|
[SOUND_TREBLE] = {"dB", 1, 15, -60, 90, 0},
|
2007-12-10 11:14:28 +00:00
|
|
|
[SOUND_BALANCE] = {"%", 0, 1,-100, 100, 0},
|
2007-05-22 15:56:05 +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},
|
2010-07-02 21:09:28 +00:00
|
|
|
#ifdef HAVE_RECORDING
|
2012-01-25 08:21:38 +00:00
|
|
|
/* PGA -17.25dB to 30.0dB in 0.75dB increments 64 steps
|
|
|
|
* digital gain 0dB to 30.0dB in 0.5dB increments
|
|
|
|
* we use 0.75dB fake steps through whole range
|
|
|
|
*
|
|
|
|
* This combined gives -17.25 to 60.0dB
|
|
|
|
*/
|
|
|
|
[SOUND_LEFT_GAIN] = {"dB", 2, 75, -1725, 6000, 0},
|
|
|
|
[SOUND_RIGHT_GAIN] = {"dB", 2, 75, -1725, 6000, 0},
|
|
|
|
[SOUND_MIC_GAIN] = {"dB", 2, 75, -1725, 6000, 3000},
|
2011-03-14 09:58:19 +00:00
|
|
|
#endif
|
|
|
|
#ifdef AUDIOHW_HAVE_BASS_CUTOFF
|
|
|
|
[SOUND_BASS_CUTOFF] = {"Hz", 0, 70, 130, 200, 200},
|
|
|
|
#endif
|
|
|
|
#ifdef AUDIOHW_HAVE_TREBLE_CUTOFF
|
2011-03-15 22:35:12 +00:00
|
|
|
[SOUND_TREBLE_CUTOFF] = {"kHz", 0, 4, 4, 8, 4},
|
2011-03-14 09:58:19 +00:00
|
|
|
#endif
|
|
|
|
#ifdef AUDIOHW_HAVE_DEPTH_3D
|
2011-03-14 23:06:33 +00:00
|
|
|
[SOUND_DEPTH_3D] = {"%", 0, 1, 0, 15, 0},
|
2010-07-02 21:09:28 +00:00
|
|
|
#endif
|
2007-05-22 15:56:05 +00:00
|
|
|
};
|
|
|
|
|
2011-03-14 09:58:19 +00:00
|
|
|
static uint16_t wmcodec_regs[WM_NUM_REGS] =
|
|
|
|
{
|
|
|
|
[0 ... WM_NUM_REGS-1] = 0x200, /* set invalid data in gaps */
|
|
|
|
#ifdef HAVE_WM8750
|
|
|
|
[LINVOL] = 0x097,
|
|
|
|
[RINVOL] = 0x097,
|
|
|
|
#endif
|
|
|
|
[LOUT1] = 0x079,
|
|
|
|
[ROUT1] = 0x079,
|
|
|
|
[DACCTRL] = 0x008,
|
|
|
|
[AINTFCE] = 0x00a,
|
|
|
|
[CLOCKING] = 0x000,
|
|
|
|
[LEFTGAIN] = 0x0ff,
|
|
|
|
[RIGHTGAIN] = 0x0ff,
|
|
|
|
[BASSCTRL] = 0x00f,
|
|
|
|
[TREBCTRL] = 0x00f,
|
|
|
|
/* [RESET] */
|
|
|
|
#ifdef HAVE_WM8750
|
|
|
|
[ENHANCE_3D] = 0x000,
|
|
|
|
[ALC1] = 0x07b,
|
|
|
|
[ALC2] = 0x000,
|
|
|
|
[ALC3] = 0x032,
|
|
|
|
[NGAT] = 0x000,
|
|
|
|
[LADCVOL] = 0x0c3,
|
|
|
|
[RADCVOL] = 0x0c3,
|
|
|
|
#endif
|
|
|
|
[ADDITIONAL1] = 0x0c0,
|
|
|
|
[ADDITIONAL2] = 0x000,
|
|
|
|
[PWRMGMT1] = 0x000,
|
|
|
|
[PWRMGMT2] = 0x000,
|
|
|
|
[ADDITIONAL3] = 0x000,
|
|
|
|
#ifdef HAVE_WM8750
|
|
|
|
[ADCIM] = 0x000,
|
|
|
|
[ADCL] = 0x000,
|
|
|
|
[ADCR] = 0x000,
|
2007-07-13 04:18:31 +00:00
|
|
|
#endif
|
2011-03-14 09:58:19 +00:00
|
|
|
[LEFTMIX1] = 0x050,
|
|
|
|
[LEFTMIX2] = 0x050,
|
|
|
|
[RIGHTMIX1] = 0x050,
|
|
|
|
[RIGHTMIX2] = 0x050,
|
|
|
|
[MONOMIX1] = 0x050,
|
|
|
|
[MONOMIX2] = 0x050,
|
|
|
|
[LOUT2] = 0x079,
|
|
|
|
[ROUT2] = 0x079,
|
|
|
|
[MONOOUT] = 0x079
|
|
|
|
};
|
2007-05-02 22:33:24 +00:00
|
|
|
|
2011-03-14 23:06:33 +00:00
|
|
|
/* global prescaler vars */
|
|
|
|
static int prescalertone = 0;
|
|
|
|
static int prescaler3d = 0;
|
|
|
|
|
2011-03-14 09:58:19 +00:00
|
|
|
static void wmcodec_set_reg(unsigned int reg, unsigned int val)
|
|
|
|
{
|
|
|
|
if (reg >= WM_NUM_REGS || (wmcodec_regs[reg] & 0x200))
|
|
|
|
/* invalid register */
|
|
|
|
return;
|
|
|
|
|
|
|
|
wmcodec_regs[reg] = val & 0x1ff;
|
|
|
|
wmcodec_write(reg, wmcodec_regs[reg]);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void wmcodec_set_bits(unsigned int reg, unsigned int bits)
|
|
|
|
{
|
|
|
|
wmcodec_set_reg(reg, wmcodec_regs[reg] | bits);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void wmcodec_clear_bits(unsigned int reg, unsigned int bits)
|
|
|
|
{
|
|
|
|
wmcodec_set_reg(reg, wmcodec_regs[reg] & ~bits);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void wmcodec_set_masked(unsigned int reg, unsigned int val,
|
|
|
|
unsigned int mask )
|
|
|
|
{
|
|
|
|
wmcodec_set_reg(reg, (wmcodec_regs[reg] & ~mask) | val);
|
|
|
|
}
|
2010-05-11 04:02:45 +00:00
|
|
|
|
2007-05-02 22:33:24 +00:00
|
|
|
/* convert tenth of dB volume (-730..60) to master volume register value */
|
|
|
|
int tenthdb2master(int db)
|
|
|
|
{
|
|
|
|
/* +6 to -73dB 1dB steps (plus mute == 80levels) 7bits */
|
|
|
|
/* 1111111 == +6dB (0x7f) */
|
|
|
|
/* 1111001 == 0dB (0x79) */
|
|
|
|
/* 0110000 == -73dB (0x30) */
|
|
|
|
/* 0101111..0000000 == mute (<= 0x2f) */
|
|
|
|
if (db < VOLUME_MIN)
|
|
|
|
return 0x0;
|
|
|
|
else
|
|
|
|
return (db / 10) + 73 + 0x30;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int tone_tenthdb2hw(int value)
|
|
|
|
{
|
|
|
|
/* -6.0db..+0db..+9.0db step 1.5db - translate -60..+0..+90 step 15
|
|
|
|
to 10..6..0 step -1.
|
|
|
|
*/
|
2008-04-28 22:15:52 +00:00
|
|
|
value = 10 - (value + 60) / 15;
|
2007-05-02 22:33:24 +00:00
|
|
|
|
|
|
|
if (value == 6)
|
|
|
|
value = 0xf; /* 0db -> off */
|
|
|
|
|
|
|
|
return value;
|
|
|
|
}
|
|
|
|
|
2011-03-14 09:58:19 +00:00
|
|
|
#ifdef AUDIOHW_HAVE_BASS_CUTOFF
|
|
|
|
void audiohw_set_bass_cutoff(int val)
|
2010-07-27 20:57:33 +00:00
|
|
|
{
|
2011-03-14 09:58:19 +00:00
|
|
|
if ( val == 130 )
|
|
|
|
wmcodec_clear_bits(BASSCTRL, BASSCTRL_BC);
|
|
|
|
else
|
|
|
|
wmcodec_set_bits(BASSCTRL, BASSCTRL_BC);
|
|
|
|
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef AUDIOHW_HAVE_TREBLE_CUTOFF
|
|
|
|
void audiohw_set_treble_cutoff(int val)
|
|
|
|
{
|
|
|
|
if ( val == 8 )
|
|
|
|
wmcodec_clear_bits(TREBCTRL, TREBCTRL_TC);
|
|
|
|
else
|
|
|
|
wmcodec_set_bits(TREBCTRL, TREBCTRL_TC);
|
2010-07-27 20:57:33 +00:00
|
|
|
}
|
|
|
|
#endif
|
2011-03-14 09:58:19 +00:00
|
|
|
|
|
|
|
|
2011-03-14 23:06:33 +00:00
|
|
|
int sound_val2phys(int setting, int value)
|
|
|
|
{
|
|
|
|
int result;
|
|
|
|
|
|
|
|
switch (setting)
|
|
|
|
{
|
2011-03-14 23:14:07 +00:00
|
|
|
#ifdef AUDIOHW_HAVE_DEPTH_3D
|
2011-03-14 23:06:33 +00:00
|
|
|
case SOUND_DEPTH_3D:
|
|
|
|
result = (100 * value + 8) / 15;
|
|
|
|
break;
|
2011-03-14 23:14:07 +00:00
|
|
|
#endif
|
2011-03-14 23:06:33 +00:00
|
|
|
default:
|
|
|
|
result = value;
|
|
|
|
}
|
|
|
|
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
2010-04-27 00:05:02 +00:00
|
|
|
static void audiohw_mute(bool mute)
|
|
|
|
{
|
|
|
|
/* Mute: Set DACMU = 1 to soft-mute the audio DACs. */
|
|
|
|
/* Unmute: Set DACMU = 0 to soft-un-mute the audio DACs. */
|
2011-03-14 09:58:19 +00:00
|
|
|
if (mute)
|
2011-03-14 23:06:33 +00:00
|
|
|
wmcodec_set_bits(DACCTRL, DACCTRL_DACMU);
|
2011-03-14 09:58:19 +00:00
|
|
|
else
|
2011-03-14 23:06:33 +00:00
|
|
|
wmcodec_clear_bits(DACCTRL, DACCTRL_DACMU);
|
2010-04-27 00:05:02 +00:00
|
|
|
}
|
|
|
|
|
2007-05-03 18:08:00 +00:00
|
|
|
/* Reset and power up the WM8751 */
|
|
|
|
void audiohw_preinit(void)
|
2007-05-02 22:33:24 +00:00
|
|
|
{
|
2011-11-05 14:01:22 +00:00
|
|
|
#if defined(MROBE_100)
|
2008-02-06 05:15:06 +00:00
|
|
|
/* controls headphone ouput */
|
|
|
|
GPIOL_ENABLE |= 0x10;
|
|
|
|
GPIOL_OUTPUT_EN |= 0x10;
|
|
|
|
GPIOL_OUTPUT_VAL |= 0x10; /* disable */
|
2011-11-05 14:01:22 +00:00
|
|
|
#elif defined(MPIO_HD200)
|
2010-10-13 20:35:58 +00:00
|
|
|
/* control headphone output
|
|
|
|
* disabled on startup
|
|
|
|
*/
|
2011-11-05 14:01:22 +00:00
|
|
|
and_l(~(1<<25), &GPIO1_OUT);
|
2010-10-13 20:35:58 +00:00
|
|
|
or_l((1<<25), &GPIO1_ENABLE);
|
|
|
|
or_l((1<<25), &GPIO1_FUNCTION);
|
2011-11-05 14:01:22 +00:00
|
|
|
#elif defined(MPIO_HD300)
|
|
|
|
and_l(~(1<<5), &GPIO1_OUT);
|
|
|
|
or_l((1<<5), &GPIO1_ENABLE);
|
|
|
|
or_l((1<<5), &GPIO1_FUNCTION);
|
2010-10-13 20:35:58 +00:00
|
|
|
#endif
|
|
|
|
|
2007-05-03 18:08:00 +00:00
|
|
|
/*
|
|
|
|
* 1. Switch on power supplies.
|
|
|
|
* By default the WM8751 is in Standby Mode, the DAC is
|
|
|
|
* digitally muted and the Audio Interface, Line outputs
|
|
|
|
* and Headphone outputs are all OFF (DACMU = 1 Power
|
|
|
|
* Management registers 1 and 2 are all zeros).
|
|
|
|
*/
|
2010-04-26 21:40:00 +00:00
|
|
|
|
2007-05-03 18:08:00 +00:00
|
|
|
wmcodec_write(RESET, RESET_RESET); /*Reset*/
|
|
|
|
|
|
|
|
/* 2. Enable Vmid and VREF. */
|
2011-03-14 09:58:19 +00:00
|
|
|
wmcodec_set_bits(PWRMGMT1, PWRMGMT1_VREF | PWRMGMT1_VMIDSEL_5K);
|
2007-05-03 18:08:00 +00:00
|
|
|
|
2010-04-26 21:40:00 +00:00
|
|
|
#ifdef CODEC_SLAVE
|
2011-03-14 23:06:33 +00:00
|
|
|
wmcodec_set_bits(AINTFCE,AINTFCE_WL_16 | AINTFCE_FORMAT_I2S);
|
2010-04-26 21:40:00 +00:00
|
|
|
#else
|
2007-05-03 18:08:00 +00:00
|
|
|
/* BCLKINV=0(Dont invert BCLK) MS=1(Enable Master) LRSWAP=0 LRP=0 */
|
|
|
|
/* IWL=00(16 bit) FORMAT=10(I2S format) */
|
2011-03-14 09:58:19 +00:00
|
|
|
wmcodec_set_bits(AINTFCE, AINTFCE_MS | AINTFCE_WL_16 |
|
2007-05-03 18:08:00 +00:00
|
|
|
AINTFCE_FORMAT_I2S);
|
2010-04-26 21:40:00 +00:00
|
|
|
#endif
|
2008-12-12 23:03:30 +00:00
|
|
|
/* Set default samplerate */
|
2010-04-26 21:40:00 +00:00
|
|
|
|
2008-12-12 23:03:30 +00:00
|
|
|
audiohw_set_frequency(HW_FREQ_DEFAULT);
|
2007-05-03 18:08:00 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Enable DACs and audio output after a short delay */
|
|
|
|
void audiohw_postinit(void)
|
|
|
|
{
|
|
|
|
/* From app notes: allow Vref to stabilize to reduce clicks */
|
|
|
|
sleep(HZ);
|
|
|
|
|
2011-03-14 09:58:19 +00:00
|
|
|
#ifdef AUDIOHW_HAVE_DEPTH_3D
|
|
|
|
wmcodec_set_bits(ENHANCE_3D, ENHANCE_3D_MODE3D_PLAYBACK);
|
|
|
|
#endif
|
|
|
|
|
2007-05-03 18:08:00 +00:00
|
|
|
/* 3. Enable DACs as required. */
|
2011-03-14 09:58:19 +00:00
|
|
|
wmcodec_set_bits(PWRMGMT2, PWRMGMT2_DACL | PWRMGMT2_DACR);
|
2007-05-03 18:08:00 +00:00
|
|
|
|
|
|
|
/* 4. Enable line and / or headphone output buffers as required. */
|
2011-03-26 13:12:24 +00:00
|
|
|
#if defined(GIGABEAT_F)
|
2011-03-14 23:06:33 +00:00
|
|
|
/* headphones + line-out */
|
2011-03-14 09:58:19 +00:00
|
|
|
wmcodec_set_bits(PWRMGMT2, PWRMGMT2_LOUT1 | PWRMGMT2_ROUT1 |
|
|
|
|
PWRMGMT2_LOUT2 | PWRMGMT2_ROUT2);
|
2011-03-14 23:06:33 +00:00
|
|
|
#else
|
|
|
|
/* headphones */
|
|
|
|
wmcodec_set_bits(PWRMGMT2, PWRMGMT2_LOUT1 | PWRMGMT2_ROUT1);
|
2008-02-06 05:15:06 +00:00
|
|
|
#endif
|
2007-05-03 18:08:00 +00:00
|
|
|
|
2010-05-11 04:02:45 +00:00
|
|
|
/* Full -0dB on the DACS */
|
2011-03-14 09:58:19 +00:00
|
|
|
wmcodec_set_bits(LEFTGAIN, 0xff);
|
|
|
|
wmcodec_set_bits(RIGHTGAIN, RIGHTGAIN_RDVU | 0xff);
|
2010-05-11 04:02:45 +00:00
|
|
|
|
2011-03-14 09:58:19 +00:00
|
|
|
/* Enable Thermal shutdown, Timeout when zero-crossing in use,
|
|
|
|
* set analog bias for 3.3V, monomix to DACR
|
|
|
|
*/
|
|
|
|
wmcodec_set_reg(ADDITIONAL1, ADDITIONAL1_TSDEN | ADDITIONAL1_TOEN |
|
2007-06-24 20:41:27 +00:00
|
|
|
ADDITIONAL1_DMONOMIX_LLRR | ADDITIONAL1_VSEL_DEFAULT);
|
|
|
|
|
2011-03-14 09:58:19 +00:00
|
|
|
|
|
|
|
/* Enable zero-crossing in out stage */
|
|
|
|
wmcodec_set_bits(LOUT1, LOUT1_LO1ZC);
|
|
|
|
wmcodec_set_bits(ROUT1, ROUT1_RO1ZC);
|
|
|
|
wmcodec_set_bits(LOUT2, LOUT2_LO2ZC);
|
|
|
|
wmcodec_set_bits(ROUT2, ROUT2_RO2ZC);
|
|
|
|
|
|
|
|
/* route signal from DAC to mixers */
|
|
|
|
wmcodec_set_bits(LEFTMIX1, LEFTMIX1_LD2LO);
|
|
|
|
wmcodec_set_bits(RIGHTMIX2, RIGHTMIX2_RD2RO);
|
2007-05-03 18:08:00 +00:00
|
|
|
|
2008-12-07 00:07:47 +00:00
|
|
|
#ifdef TOSHIBA_GIGABEAT_F
|
|
|
|
#ifdef HAVE_HARDWARE_BEEP
|
|
|
|
/* Single-ended mono input */
|
2011-03-14 09:58:19 +00:00
|
|
|
wmcodec_set_reg(MONOMIX1, 0x00);
|
2008-12-07 00:07:47 +00:00
|
|
|
|
|
|
|
/* Route mono input to both outputs at 0dB */
|
2011-03-14 09:58:19 +00:00
|
|
|
wmcodec_set_reg(LEFTMIX2, LEFTMIX2_MI2LO | LEFTMIX2_MI2LOVOL(2));
|
|
|
|
wmcodec_set_reg(RIGHTMIX1, RIGHTMIX1_MI2RO | RIGHTMIX1_MI2ROVOL(2));
|
2008-12-07 00:07:47 +00:00
|
|
|
#endif
|
|
|
|
#endif
|
|
|
|
|
2010-04-26 21:40:00 +00:00
|
|
|
/* lower power consumption */
|
2011-03-14 09:58:19 +00:00
|
|
|
wmcodec_set_masked(PWRMGMT1, PWRMGMT1_VMIDSEL_50K,
|
|
|
|
PWRMGMT1_VMIDSEL_MASK);
|
2010-04-26 21:40:00 +00:00
|
|
|
|
2007-05-03 18:08:00 +00:00
|
|
|
audiohw_mute(false);
|
2008-02-06 05:15:06 +00:00
|
|
|
|
2011-11-05 14:01:22 +00:00
|
|
|
#if defined(MROBE_100)
|
2008-02-06 05:15:06 +00:00
|
|
|
/* enable headphone output */
|
|
|
|
GPIOL_OUTPUT_VAL &= ~0x10;
|
|
|
|
GPIOL_OUTPUT_EN |= 0x10;
|
2011-11-05 14:01:22 +00:00
|
|
|
#elif defined(MPIO_HD200)
|
2010-10-13 20:35:58 +00:00
|
|
|
/* enable headphone output */
|
2011-11-05 14:01:22 +00:00
|
|
|
or_l((1<<25), &GPIO1_OUT);
|
|
|
|
#elif defined(MPIO_HD300)
|
|
|
|
or_l((1<<5), &GPIO1_OUT);
|
2010-10-13 20:35:58 +00:00
|
|
|
#endif
|
2007-05-02 22:33:24 +00:00
|
|
|
}
|
|
|
|
|
2008-02-13 11:19:23 +00:00
|
|
|
void audiohw_set_master_vol(int vol_l, int vol_r)
|
2007-05-02 22:33:24 +00:00
|
|
|
{
|
|
|
|
/* +6 to -73dB 1dB steps (plus mute == 80levels) 7bits */
|
|
|
|
/* 1111111 == +6dB */
|
|
|
|
/* 1111001 == 0dB */
|
|
|
|
/* 0110000 == -73dB */
|
|
|
|
/* 0101111 == mute (0x2f) */
|
|
|
|
|
2011-03-14 09:58:19 +00:00
|
|
|
wmcodec_set_masked(LOUT1, LOUT1_LOUT1VOL(vol_l),
|
|
|
|
LOUT1_LOUT1VOL_MASK);
|
|
|
|
wmcodec_set_masked(ROUT1, ROUT1_RO1VU | ROUT1_ROUT1VOL(vol_r),
|
|
|
|
ROUT1_ROUT1VOL_MASK);
|
2007-05-02 22:33:24 +00:00
|
|
|
}
|
|
|
|
|
2011-03-14 09:58:19 +00:00
|
|
|
#ifdef TOSHIBA_GIGABEAT_F
|
2008-02-13 11:19:23 +00:00
|
|
|
void audiohw_set_lineout_vol(int vol_l, int vol_r)
|
2007-05-02 22:33:24 +00:00
|
|
|
{
|
2011-03-14 09:58:19 +00:00
|
|
|
wmcodec_set_masked(LOUT2, LOUT2_LOUT2VOL(vol_l),
|
|
|
|
LOUT2_LOUT2VOL_MASK);
|
|
|
|
wmcodec_set_masked(ROUT2, ROUT2_RO2VU | ROUT2_ROUT2VOL(vol_r),
|
|
|
|
ROUT2_ROUT2VOL_MASK);
|
2007-05-02 22:33:24 +00:00
|
|
|
}
|
2008-02-06 05:15:06 +00:00
|
|
|
#endif
|
2007-05-02 22:33:24 +00:00
|
|
|
|
|
|
|
void audiohw_set_bass(int value)
|
|
|
|
{
|
2011-03-14 09:58:19 +00:00
|
|
|
wmcodec_set_masked(BASSCTRL,
|
2011-03-14 23:06:33 +00:00
|
|
|
BASSCTRL_BASS(tone_tenthdb2hw(value)),
|
|
|
|
BASSCTRL_BASS_MASK);
|
2007-05-02 22:33:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void audiohw_set_treble(int value)
|
|
|
|
{
|
2011-03-14 09:58:19 +00:00
|
|
|
wmcodec_set_masked(TREBCTRL, TREBCTRL_TREB(tone_tenthdb2hw(value)),
|
|
|
|
TREBCTRL_TREB_MASK);
|
2007-05-02 22:33:24 +00:00
|
|
|
}
|
|
|
|
|
2011-03-14 23:06:33 +00:00
|
|
|
static void sync_prescaler(void)
|
2010-05-11 04:02:45 +00:00
|
|
|
{
|
2011-03-14 23:06:33 +00:00
|
|
|
int prescaler;
|
|
|
|
prescaler = prescalertone + prescaler3d;
|
|
|
|
|
|
|
|
/* attenuate in 0.5dB steps (0dB - -127dB) */
|
2011-03-14 09:58:19 +00:00
|
|
|
wmcodec_set_reg(LEFTGAIN, 0xff - (prescaler & LEFTGAIN_LDACVOL));
|
2011-03-14 23:06:33 +00:00
|
|
|
wmcodec_set_reg(RIGHTGAIN, RIGHTGAIN_RDVU |
|
2011-03-14 09:58:19 +00:00
|
|
|
(0xff - (prescaler & RIGHTGAIN_RDACVOL)));
|
2010-05-11 04:02:45 +00:00
|
|
|
}
|
|
|
|
|
2011-03-14 23:06:33 +00:00
|
|
|
void audiohw_set_prescaler(int value)
|
|
|
|
{
|
|
|
|
prescalertone = 3 * value / 15; /* value in tdB */
|
|
|
|
sync_prescaler();
|
|
|
|
}
|
|
|
|
|
2007-05-02 22:33:24 +00:00
|
|
|
/* Nice shutdown of WM8751 codec */
|
|
|
|
void audiohw_close(void)
|
|
|
|
{
|
|
|
|
/* 1. Set DACMU = 1 to soft-mute the audio DACs. */
|
|
|
|
audiohw_mute(true);
|
|
|
|
|
2011-11-05 14:01:22 +00:00
|
|
|
#if defined(MPIO_HD200)
|
2010-10-13 20:35:58 +00:00
|
|
|
/* disable headphone out */
|
|
|
|
and_l(~(1<<25), &GPIO1_OUT);
|
2011-11-05 14:01:22 +00:00
|
|
|
#elif defined(MPIO_HD300)
|
|
|
|
and_l(~(1<<5), &GPIO1_OUT);
|
2010-10-13 20:35:58 +00:00
|
|
|
#endif
|
|
|
|
|
2007-05-02 22:33:24 +00:00
|
|
|
/* 2. Disable all output buffers. */
|
2011-03-14 09:58:19 +00:00
|
|
|
wmcodec_set_reg(PWRMGMT2, 0x0);
|
2007-05-02 22:33:24 +00:00
|
|
|
|
|
|
|
/* 3. Switch off the power supplies. */
|
2011-03-14 09:58:19 +00:00
|
|
|
wmcodec_set_reg(PWRMGMT1, 0x0);
|
2007-05-02 22:33:24 +00:00
|
|
|
}
|
|
|
|
|
2010-07-02 21:09:28 +00:00
|
|
|
/* According to datasheet of WM8750
|
|
|
|
* clocking setup is needed in both slave and master mode
|
|
|
|
*/
|
2007-05-02 22:33:24 +00:00
|
|
|
void audiohw_set_frequency(int fsel)
|
|
|
|
{
|
2010-04-26 21:40:00 +00:00
|
|
|
(void)fsel;
|
2008-12-12 11:01:07 +00:00
|
|
|
static const unsigned char srctrl_table[HW_NUM_FREQ] =
|
|
|
|
{
|
|
|
|
HW_HAVE_11_([HW_FREQ_11] = CODEC_SRCTRL_11025HZ,)
|
|
|
|
HW_HAVE_22_([HW_FREQ_22] = CODEC_SRCTRL_22050HZ,)
|
|
|
|
HW_HAVE_44_([HW_FREQ_44] = CODEC_SRCTRL_44100HZ,)
|
|
|
|
HW_HAVE_88_([HW_FREQ_88] = CODEC_SRCTRL_88200HZ,)
|
|
|
|
};
|
|
|
|
|
|
|
|
if ((unsigned)fsel >= HW_NUM_FREQ)
|
|
|
|
fsel = HW_FREQ_DEFAULT;
|
|
|
|
|
2011-03-14 09:58:19 +00:00
|
|
|
wmcodec_set_reg(CLOCKING, srctrl_table[fsel]);
|
2007-05-02 22:33:24 +00:00
|
|
|
}
|
2010-04-29 13:14:43 +00:00
|
|
|
|
2011-03-14 09:58:19 +00:00
|
|
|
#ifdef HAVE_WM8750
|
2010-07-02 21:09:28 +00:00
|
|
|
#ifdef AUDIOHW_HAVE_DEPTH_3D
|
|
|
|
/* Set the depth of the 3D effect */
|
|
|
|
void audiohw_set_depth_3d(int val)
|
|
|
|
{
|
2011-03-14 23:06:33 +00:00
|
|
|
if (val > 0)
|
2011-03-14 09:58:19 +00:00
|
|
|
{
|
2011-03-14 23:06:33 +00:00
|
|
|
wmcodec_set_bits(ENHANCE_3D, ENHANCE_3D_3DEN);
|
2011-03-14 09:58:19 +00:00
|
|
|
wmcodec_set_masked(ENHANCE_3D, ENHANCE_3D_DEPTH(val),
|
|
|
|
ENHANCE_3D_DEPTH_MASK);
|
|
|
|
}
|
2010-07-02 21:09:28 +00:00
|
|
|
else
|
2011-03-14 09:58:19 +00:00
|
|
|
{
|
|
|
|
wmcodec_clear_bits(ENHANCE_3D, ENHANCE_3D_3DEN);
|
|
|
|
}
|
2011-03-14 23:06:33 +00:00
|
|
|
|
|
|
|
/* -4 dB @ full setting
|
|
|
|
* this gives approximately constant volume on setting change
|
|
|
|
* and prevents clipping (at least on my HD300)
|
|
|
|
*/
|
|
|
|
prescaler3d = 8*val / 15;
|
|
|
|
sync_prescaler();
|
2010-07-02 21:09:28 +00:00
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef HAVE_RECORDING
|
2011-03-14 23:06:33 +00:00
|
|
|
#if 0
|
2011-03-14 09:58:19 +00:00
|
|
|
static void audiohw_set_ngat(int ngath, int type, bool enable)
|
2010-07-27 20:57:33 +00:00
|
|
|
{
|
|
|
|
/* This function controls Noise gate function
|
|
|
|
* of the codec. This can only run in conjunction
|
|
|
|
* with ALC
|
|
|
|
*/
|
|
|
|
|
|
|
|
if(enable)
|
2011-03-14 09:58:19 +00:00
|
|
|
wmcodec_set_reg(NGAT, NGAT_NGG(type) |
|
|
|
|
NGAT_NGTH(ngath) | NGAT_NGAT);
|
2010-07-27 20:57:33 +00:00
|
|
|
else
|
2011-03-14 09:58:19 +00:00
|
|
|
wmcodec_clear_bits(NGAT, NGAT_NGAT);
|
2010-07-27 20:57:33 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-03-14 09:58:19 +00:00
|
|
|
static void audiohw_set_alc(unsigned char level, /* signal level at ADC */
|
|
|
|
bool zc, /* zero cross detection */
|
|
|
|
unsigned char hold, /* hold time */
|
|
|
|
unsigned char decay, /* decay time */
|
|
|
|
unsigned char attack, /* attack time */
|
|
|
|
bool enable) /* hw function on/off */
|
2010-07-27 20:57:33 +00:00
|
|
|
{
|
|
|
|
if(enable)
|
|
|
|
{
|
2011-03-14 09:58:19 +00:00
|
|
|
wmcodec_set_reg(ALC1, ALC1_ALCSEL_STEREO | ALC1_MAXGAIN(0x07) |
|
|
|
|
ALC1_ALCL(level));
|
|
|
|
wmcodec_set_reg(ALC2, zc?ALC2_ALCZC:0 | ALC2_HLD(hold));
|
|
|
|
wmcodec_set_reg(ALC3, ALC3_DCY(decay) | ALC3_ATK(attack));
|
2010-07-27 20:57:33 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2011-03-14 09:58:19 +00:00
|
|
|
wmcodec_set_masked(ALC1, ALC1_ALCSEL_DISABLED, ALC1_ALCSEL_MASK);
|
2010-07-27 20:57:33 +00:00
|
|
|
}
|
|
|
|
}
|
2011-03-14 23:06:33 +00:00
|
|
|
#endif
|
2010-07-27 20:57:33 +00:00
|
|
|
|
2010-04-29 13:14:43 +00:00
|
|
|
void audiohw_set_recsrc(int source, bool recording)
|
|
|
|
{
|
|
|
|
/* INPUT1 - FM radio
|
|
|
|
* INPUT2 - Line-in
|
|
|
|
* INPUT3 - MIC
|
|
|
|
*
|
|
|
|
* if recording == false we use analog bypass from input
|
|
|
|
* turn off ADC, PGA to save power
|
|
|
|
* turn on output buffer(s)
|
|
|
|
*
|
|
|
|
* if recording == true we route input signal to PGA
|
2010-07-02 21:09:28 +00:00
|
|
|
* and monitoring picks up signal after PGA and ADC
|
2010-04-29 13:14:43 +00:00
|
|
|
* turn on ADC, PGA, DAC, output buffer(s)
|
|
|
|
*/
|
|
|
|
|
|
|
|
switch(source)
|
|
|
|
{
|
|
|
|
case AUDIO_SRC_PLAYBACK:
|
2011-03-14 09:58:19 +00:00
|
|
|
audiohw_mute(true);
|
2010-07-02 21:09:28 +00:00
|
|
|
|
2011-03-14 09:58:19 +00:00
|
|
|
/* mute PGA, disable all audio paths but DAC and output stage*/
|
|
|
|
wmcodec_set_bits(LINVOL, LINVOL_LINMUTE); /* Mute */
|
|
|
|
wmcodec_set_bits(RINVOL, RINVOL_RINMUTE); /* Mute */
|
2010-07-02 21:09:28 +00:00
|
|
|
|
2011-03-14 09:58:19 +00:00
|
|
|
wmcodec_clear_bits(PWRMGMT2, PWRMGMT2_OUT3 | PWRMGMT2_MOUT |
|
|
|
|
PWRMGMT2_ROUT2 | PWRMGMT2_LOUT2);
|
2010-04-29 13:14:43 +00:00
|
|
|
|
2011-03-14 09:58:19 +00:00
|
|
|
/* route DAC signal to output mixer, disable INPUT routing */
|
|
|
|
wmcodec_clear_bits(LEFTMIX1, LEFTMIX1_LI2LO);
|
|
|
|
wmcodec_set_bits(LEFTMIX1, LEFTMIX1_LD2LO);
|
|
|
|
wmcodec_clear_bits(RIGHTMIX2, RIGHTMIX2_RI2RO);
|
|
|
|
wmcodec_set_bits(RIGHTMIX2, RIGHTMIX2_RD2RO);
|
2010-04-29 13:14:43 +00:00
|
|
|
|
|
|
|
/* unmute DAC */
|
|
|
|
audiohw_mute(false);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case AUDIO_SRC_FMRADIO:
|
|
|
|
if(recording)
|
|
|
|
{
|
2011-03-14 09:58:19 +00:00
|
|
|
audiohw_mute(true);
|
2010-04-29 13:14:43 +00:00
|
|
|
/* Turn on PGA and ADC */
|
2011-03-14 09:58:19 +00:00
|
|
|
wmcodec_set_bits(PWRMGMT1, PWRMGMT1_AINL | PWRMGMT1_AINR |
|
|
|
|
PWRMGMT1_ADCL | PWRMGMT1_ADCR);
|
2010-04-29 13:14:43 +00:00
|
|
|
|
2011-03-14 09:58:19 +00:00
|
|
|
/* Setup input source for PGA as INPUT1 */
|
|
|
|
wmcodec_set_masked(ADCL, ADCL_LINSEL_LINPUT1, ADCL_LINSEL_MASK);
|
|
|
|
wmcodec_set_masked(ADCR, ADCR_RINSEL_RINPUT1, ADCR_RINSEL_MASK);
|
|
|
|
|
|
|
|
/* turn off ALC and NGAT as OF do */
|
2011-03-14 23:06:33 +00:00
|
|
|
/*
|
2011-03-14 09:58:19 +00:00
|
|
|
audiohw_set_alc(0x00, false, 0x00, 0x00, 0x00, false);
|
|
|
|
audiohw_set_ngat(0x00, 0x00, false);
|
2011-03-14 23:06:33 +00:00
|
|
|
*/
|
2010-04-29 13:14:43 +00:00
|
|
|
|
|
|
|
/* setup output digital data
|
|
|
|
* default is LADC -> LDATA, RADC -> RDATA
|
|
|
|
* so we don't touch this
|
|
|
|
*/
|
|
|
|
|
2011-03-14 09:58:19 +00:00
|
|
|
/* skip: power up DAC and output stage as its never powered down
|
|
|
|
wmcodec_set_bits(PWRMGMT2, PWRMGMT2_DACL | PWRMGMT2_DACR |
|
2010-04-29 13:14:43 +00:00
|
|
|
PWRMGMT2_LOUT1 | PWRMGMT2_ROUT1);
|
2011-03-14 09:58:19 +00:00
|
|
|
*/
|
2010-04-29 13:14:43 +00:00
|
|
|
|
2011-03-14 09:58:19 +00:00
|
|
|
/* route DAC signal to output mixer, disable INPUT routing */
|
|
|
|
wmcodec_clear_bits(LEFTMIX1, LEFTMIX1_LI2LO);
|
|
|
|
wmcodec_set_bits(LEFTMIX1, LEFTMIX1_LD2LO);
|
|
|
|
wmcodec_clear_bits(RIGHTMIX2, RIGHTMIX2_RI2RO);
|
|
|
|
wmcodec_set_bits(RIGHTMIX2, RIGHTMIX2_RD2RO);
|
|
|
|
|
|
|
|
audiohw_mute(false);
|
2010-04-29 13:14:43 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2011-03-14 09:58:19 +00:00
|
|
|
audiohw_mute(true);
|
2010-04-29 13:14:43 +00:00
|
|
|
|
2011-03-14 09:58:19 +00:00
|
|
|
/* turn off ADC, PGA */
|
|
|
|
wmcodec_clear_bits(PWRMGMT1, PWRMGMT1_AINL | PWRMGMT1_AINR |
|
|
|
|
PWRMGMT1_ADCL | PWRMGMT1_ADCR);
|
2010-04-29 13:14:43 +00:00
|
|
|
|
2011-03-14 09:58:19 +00:00
|
|
|
/* setup monitor mode by routing input signal to outmix
|
|
|
|
* at 0dB volume
|
|
|
|
*/
|
|
|
|
wmcodec_set_masked(LEFTMIX1, LEFTMIX1_LI2LOVOL(0x20),
|
|
|
|
LEFTMIX1_LI2LOVOL_MASK);
|
|
|
|
wmcodec_set_bits(LEFTMIX1, LEFTMIX1_LI2LO |
|
|
|
|
LEFTMIX1_LMIXSEL_LINPUT1 |
|
|
|
|
LEFTMIX1_LD2LO);
|
|
|
|
wmcodec_set_masked(RIGHTMIX2, RIGHTMIX2_RI2ROVOL(0x20),
|
|
|
|
RIGHTMIX2_RI2ROVOL_MASK);
|
|
|
|
wmcodec_set_bits(RIGHTMIX1, RIGHTMIX1_RMIXSEL_RINPUT1);
|
|
|
|
wmcodec_set_bits(RIGHTMIX2, RIGHTMIX2_RI2RO |
|
|
|
|
RIGHTMIX2_RD2RO);
|
|
|
|
|
|
|
|
audiohw_mute(false);
|
2010-04-29 13:14:43 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
2010-11-26 23:28:08 +00:00
|
|
|
#if (INPUT_SRC_CAPS & SRC_CAP_LINEIN)
|
2010-04-29 13:14:43 +00:00
|
|
|
case AUDIO_SRC_LINEIN:
|
2011-03-14 09:58:19 +00:00
|
|
|
audiohw_mute(true);
|
2010-04-29 13:14:43 +00:00
|
|
|
|
2010-07-02 21:09:28 +00:00
|
|
|
/* Turn on PGA, ADC */
|
2011-03-14 09:58:19 +00:00
|
|
|
wmcodec_set_bits(PWRMGMT1, PWRMGMT1_AINL | PWRMGMT1_AINR |
|
|
|
|
PWRMGMT1_ADCL | PWRMGMT1_ADCR);
|
2010-04-29 13:14:43 +00:00
|
|
|
|
|
|
|
/* Setup input source for PGA as INPUT2
|
|
|
|
* MICBOOST disabled
|
|
|
|
*/
|
2011-03-14 09:58:19 +00:00
|
|
|
wmcodec_set_masked(ADCL, ADCL_LINSEL_LINPUT2, ADCL_LINSEL_MASK);
|
|
|
|
wmcodec_set_masked(ADCR, ADCR_RINSEL_RINPUT2, ADCR_RINSEL_MASK);
|
|
|
|
|
|
|
|
/* setup ALC and NGAT as OF do */
|
|
|
|
/* level, zc, hold, decay, attack, enable */
|
2011-03-14 23:06:33 +00:00
|
|
|
/* audiohw_set_alc(0x0b, true, 0x00, 0x03, 0x02, true); */
|
2011-03-14 09:58:19 +00:00
|
|
|
/* ngath, type, enable */
|
2011-03-14 23:06:33 +00:00
|
|
|
/* audiohw_set_ngat(0x08, 0x02, true); */
|
2010-04-29 13:14:43 +00:00
|
|
|
|
|
|
|
/* setup output digital data
|
|
|
|
* default is LADC -> LDATA, RADC -> RDATA
|
|
|
|
* so we don't touch this
|
|
|
|
*/
|
2011-03-14 09:58:19 +00:00
|
|
|
|
|
|
|
/* route DAC signal to output mixer, disable INPUT routing */
|
|
|
|
wmcodec_clear_bits(LEFTMIX1, LEFTMIX1_LI2LO);
|
|
|
|
wmcodec_set_bits(LEFTMIX1, LEFTMIX1_LD2LO);
|
|
|
|
wmcodec_clear_bits(RIGHTMIX2, RIGHTMIX2_RI2RO);
|
|
|
|
wmcodec_set_bits(RIGHTMIX2, RIGHTMIX2_RD2RO);
|
|
|
|
|
2011-03-15 07:30:29 +00:00
|
|
|
#if !defined(MPIO_HD300)
|
|
|
|
/* HD300 uses the same socket for headphones and line-in */
|
2011-03-14 09:58:19 +00:00
|
|
|
audiohw_mute(false);
|
2011-03-15 07:30:29 +00:00
|
|
|
#endif
|
2010-04-29 13:14:43 +00:00
|
|
|
break;
|
2010-11-26 23:28:08 +00:00
|
|
|
#endif
|
|
|
|
#if (INPUT_SRC_CAPS & SRC_CAP_MIC)
|
2010-04-29 13:14:43 +00:00
|
|
|
case AUDIO_SRC_MIC:
|
2011-03-14 09:58:19 +00:00
|
|
|
audiohw_mute(true);
|
2010-04-29 13:14:43 +00:00
|
|
|
|
2011-03-14 09:58:19 +00:00
|
|
|
/* Turn on PGA and ADC */
|
|
|
|
wmcodec_set_bits(PWRMGMT1, PWRMGMT1_AINL | PWRMGMT1_AINR |
|
|
|
|
PWRMGMT1_ADCL | PWRMGMT1_ADCR);
|
2010-04-29 13:14:43 +00:00
|
|
|
|
|
|
|
/* Setup input source for PGA as INPUT3
|
|
|
|
* MICBOOST disabled
|
|
|
|
*/
|
2011-03-14 09:58:19 +00:00
|
|
|
wmcodec_set_masked(ADCL, ADCL_LINSEL_LINPUT3, ADCL_LINSEL_MASK);
|
|
|
|
wmcodec_set_masked(ADCR, ADCR_RINSEL_RINPUT3, ADCR_RINSEL_MASK);
|
|
|
|
|
|
|
|
/* setup ALC and NGAT as OF do */
|
|
|
|
/* level, zc, hold, decay, attack, enable */
|
2011-03-14 23:06:33 +00:00
|
|
|
/* audiohw_set_alc(0x0f, false, 0x00, 0x05, 0x02, true); */
|
2011-03-14 09:58:19 +00:00
|
|
|
/* ngath, type, enable */
|
2011-03-14 23:06:33 +00:00
|
|
|
/* audiohw_set_ngat(0x1f, 0x00, true); */
|
2010-04-29 13:14:43 +00:00
|
|
|
|
|
|
|
/* setup output digital data
|
|
|
|
* default is LADC -> LDATA, RADC -> RDATA
|
|
|
|
* so we don't touch this
|
|
|
|
*/
|
|
|
|
|
2011-03-14 09:58:19 +00:00
|
|
|
/* route DAC signal to output mixer, disable INPUT routing */
|
|
|
|
wmcodec_clear_bits(LEFTMIX1, LEFTMIX1_LI2LO);
|
|
|
|
wmcodec_set_bits(LEFTMIX1, LEFTMIX1_LD2LO);
|
|
|
|
wmcodec_clear_bits(RIGHTMIX2, RIGHTMIX2_RI2RO);
|
|
|
|
wmcodec_set_bits(RIGHTMIX2, RIGHTMIX2_RD2RO);
|
|
|
|
|
|
|
|
audiohw_mute(false);
|
2010-11-26 23:28:08 +00:00
|
|
|
break;
|
|
|
|
#endif
|
2010-04-29 13:14:43 +00:00
|
|
|
} /* switch(source) */
|
|
|
|
}
|
|
|
|
|
2012-01-25 08:21:38 +00:00
|
|
|
static int digital_gain2hw(int value)
|
|
|
|
{
|
|
|
|
/* -9700 to 3000 => 0 ... 195 ... 255 */
|
|
|
|
return (2 * value) / 100 + 195;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int pga_gain2hw(int value)
|
|
|
|
{
|
|
|
|
/* -1725 to 3000 => 0 ... 23 ... 63 */
|
|
|
|
return ((4 * value) / 300) + 23;
|
|
|
|
}
|
|
|
|
|
2010-07-02 21:09:28 +00:00
|
|
|
void audiohw_set_recvol(int vol_l, int vol_r, int type)
|
2010-04-29 13:14:43 +00:00
|
|
|
{
|
2012-01-25 08:21:38 +00:00
|
|
|
int d_vol_l = 0;
|
|
|
|
int d_vol_r = 0;
|
|
|
|
|
|
|
|
if (vol_l > 3000)
|
|
|
|
{
|
|
|
|
d_vol_l = vol_l - 3000;
|
|
|
|
vol_l = 3000;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (vol_r > 3000)
|
|
|
|
{
|
|
|
|
d_vol_r = vol_r - 3000;
|
|
|
|
vol_r = 3000;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* PGA left gain */
|
|
|
|
wmcodec_set_reg(LINVOL, LINVOL_LIZC | LINVOL_LINVOL(pga_gain2hw(vol_l)));
|
|
|
|
|
|
|
|
/* digital left gain set */
|
|
|
|
wmcodec_set_reg(LADCVOL, digital_gain2hw(d_vol_l));
|
2011-03-14 09:58:19 +00:00
|
|
|
|
|
|
|
if (type == AUDIO_GAIN_MIC)
|
2012-01-25 08:21:38 +00:00
|
|
|
{
|
|
|
|
/* PGA right gain = PGA left gain*/
|
2011-03-15 22:35:12 +00:00
|
|
|
wmcodec_set_reg(RINVOL, RINVOL_RIVU | RINVOL_RIZC |
|
2012-01-25 08:21:38 +00:00
|
|
|
RINVOL_RINVOL(pga_gain2hw(vol_l)));
|
|
|
|
|
|
|
|
/* digital right gain = digital left gain*/
|
|
|
|
wmcodec_set_reg(RADCVOL, RADCVOL_RAVU | digital_gain2hw(d_vol_l));
|
|
|
|
}
|
2011-03-14 09:58:19 +00:00
|
|
|
else
|
2012-01-25 08:21:38 +00:00
|
|
|
{
|
|
|
|
/* PGA right gain */
|
2011-03-15 22:35:12 +00:00
|
|
|
wmcodec_set_reg(RINVOL, RINVOL_RIVU | RINVOL_RIZC |
|
2012-01-25 08:21:38 +00:00
|
|
|
RINVOL_RINVOL(pga_gain2hw(vol_r)));
|
|
|
|
|
|
|
|
/* digital right gain */
|
|
|
|
wmcodec_set_reg(RADCVOL, RADCVOL_RAVU | digital_gain2hw(d_vol_r));
|
|
|
|
}
|
2010-04-29 13:14:43 +00:00
|
|
|
}
|
2010-07-02 21:09:28 +00:00
|
|
|
#endif /* HAVE_RECORDING */
|
|
|
|
#endif /* HAVE_WM8750 */
|