2005-12-16 11:00:44 +00:00
|
|
|
/***************************************************************************
|
|
|
|
* __________ __ ___.
|
|
|
|
* Open \______ \ ____ ____ | | _\_ |__ _______ ___
|
|
|
|
* Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
|
|
|
|
* Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
|
|
|
|
* Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
|
|
|
|
* \/ \/ \/ \/ \/
|
|
|
|
* $Id$
|
|
|
|
*
|
2005-12-19 14:30:52 +00:00
|
|
|
* Driver for WM8975 audio codec
|
2005-12-16 11:00:44 +00:00
|
|
|
*
|
2005-12-19 14:30:52 +00:00
|
|
|
* 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)
|
2005-12-16 11:00:44 +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.
|
2005-12-16 11:00:44 +00:00
|
|
|
*
|
|
|
|
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
|
|
|
|
* KIND, either express or implied.
|
|
|
|
*
|
|
|
|
****************************************************************************/
|
2014-03-03 19:26:08 +00:00
|
|
|
|
2007-05-20 23:10:15 +00:00
|
|
|
#include "logf.h"
|
2005-12-16 11:00:44 +00:00
|
|
|
#include "system.h"
|
2014-03-03 19:26:08 +00:00
|
|
|
#include "kernel.h"
|
2005-12-16 11:00:44 +00:00
|
|
|
#include "string.h"
|
|
|
|
#include "audio.h"
|
2008-09-15 19:50:55 +00:00
|
|
|
#include "sound.h"
|
2005-12-16 11:00:44 +00:00
|
|
|
|
2006-10-20 17:12:42 +00:00
|
|
|
#include "wmcodec.h"
|
2007-05-22 20:39:50 +00:00
|
|
|
#include "audiohw.h"
|
2005-12-16 11:00:44 +00:00
|
|
|
|
2011-03-03 20:53:30 +00:00
|
|
|
static unsigned short wm8975_regs[WM8975_NUM_REGISTERS] =
|
2008-09-10 23:50:26 +00:00
|
|
|
{
|
|
|
|
[LINVOL] = LINVOL_LZCEN | 23, /* 0dB */
|
|
|
|
[RINVOL] = RINVOL_RIVU | RINVOL_RZCEN | 23, /* 0dB */
|
|
|
|
[DAPCTRL] = DAPCTRL_DACMU,
|
2010-11-13 11:38:38 +00:00
|
|
|
/* This reduces the popping noise during codec powerup
|
|
|
|
noticably, especially with high-impedance loads.
|
|
|
|
We might want to change this for all targets,
|
|
|
|
but it has only been tested on iPod Nano 2G so far. */
|
|
|
|
#ifdef IPOD_NANO2G
|
|
|
|
[PWRMGMT1] = PWRMGMT1_VMIDSEL_500K | PWRMGMT1_VREF,
|
|
|
|
#else
|
2008-09-10 23:50:26 +00:00
|
|
|
[PWRMGMT1] = PWRMGMT1_VMIDSEL_5K | PWRMGMT1_VREF,
|
2010-11-13 11:38:38 +00:00
|
|
|
#endif
|
2008-09-10 23:50:26 +00:00
|
|
|
[PWRMGMT2] = PWRMGMT2_DACL | PWRMGMT2_DACR | PWRMGMT2_LOUT1
|
|
|
|
| PWRMGMT2_ROUT1 | PWRMGMT2_LOUT2 | PWRMGMT2_ROUT2,
|
|
|
|
};
|
|
|
|
|
|
|
|
static void wm8975_write(int reg, unsigned val)
|
|
|
|
{
|
2011-03-03 20:53:30 +00:00
|
|
|
if (WM8975_NUM_REGISTERS > reg) {
|
|
|
|
wm8975_regs[reg] = val;
|
|
|
|
wmcodec_write(reg, val);
|
|
|
|
}
|
2008-09-10 23:50:26 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void wm8975_write_and(int reg, unsigned bits)
|
|
|
|
{
|
|
|
|
wm8975_write(reg, wm8975_regs[reg] & bits);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void wm8975_write_or(int reg, unsigned bits)
|
|
|
|
{
|
|
|
|
wm8975_write(reg, wm8975_regs[reg] | bits);
|
|
|
|
}
|
|
|
|
|
2006-12-06 13:34:15 +00:00
|
|
|
/* convert tenth of dB volume (-730..60) to master volume register value */
|
2013-04-13 03:35:47 +00:00
|
|
|
static int vol_tenthdb2hw(int db)
|
2006-12-06 13:34:15 +00:00
|
|
|
{
|
|
|
|
/* +6 to -73dB 1dB steps (plus mute == 80levels) 7bits */
|
|
|
|
/* 1111111 == +6dB (0x7f) */
|
|
|
|
/* 1111001 == 0dB (0x79) */
|
|
|
|
/* 0110000 == -73dB (0x30 */
|
2007-03-07 15:00:29 +00:00
|
|
|
/* 0101111..0000000 == mute (0x2f) */
|
2006-12-06 13:34:15 +00:00
|
|
|
|
2013-04-20 08:06:13 +00:00
|
|
|
if (db <= -740) {
|
2006-12-06 13:34:15 +00:00
|
|
|
return 0x0;
|
|
|
|
} else {
|
|
|
|
return((db/10)+73+0x30);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-04-27 00:05:02 +00:00
|
|
|
static void audiohw_mute(bool mute)
|
2005-12-16 11:00:44 +00:00
|
|
|
{
|
2008-09-10 23:50:26 +00:00
|
|
|
if (mute) {
|
|
|
|
/* Set DACMU = 1 to soft-mute the audio DACs. */
|
|
|
|
wm8975_write_or(DAPCTRL, DAPCTRL_DACMU);
|
|
|
|
} else {
|
|
|
|
/* Set DACMU = 0 to soft-un-mute the audio DACs. */
|
|
|
|
wm8975_write_and(DAPCTRL, ~DAPCTRL_DACMU);
|
|
|
|
}
|
|
|
|
}
|
2007-01-13 23:57:19 +00:00
|
|
|
|
2008-09-10 23:50:26 +00:00
|
|
|
#define IPOD_PCM_LEVEL 0x65 /* -6dB */
|
|
|
|
|
2010-11-13 11:38:38 +00:00
|
|
|
/* This reduces the popping noise during codec powerup
|
|
|
|
noticably, especially with high-impedance loads.
|
|
|
|
We might want to change this for all targets,
|
|
|
|
but it has only been tested on iPod Nano 2G so far. */
|
|
|
|
#ifdef IPOD_NANO2G
|
|
|
|
void audiohw_preinit(void)
|
|
|
|
{
|
2011-03-03 20:53:30 +00:00
|
|
|
wm8975_write(RESET, RESET_RESET);
|
2010-11-13 11:38:38 +00:00
|
|
|
|
2011-03-03 20:53:30 +00:00
|
|
|
wm8975_write(AINTFCE, AINTFCE_MS | AINTFCE_LRP_I2S_RLO
|
|
|
|
| AINTFCE_IWL_16BIT | AINTFCE_FORMAT_I2S);
|
2010-11-13 11:38:38 +00:00
|
|
|
|
2011-03-03 20:53:30 +00:00
|
|
|
wm8975_write(LOUTMIX1, LOUTMIX1_LD2LO | LOUTMIX1_LI2LOVOL(5));
|
|
|
|
wm8975_write(ROUTMIX2, ROUTMIX2_RD2RO | ROUTMIX2_RI2ROVOL(5));
|
2010-11-13 11:38:38 +00:00
|
|
|
|
|
|
|
wm8975_write(PWRMGMT1, wm8975_regs[PWRMGMT1]);
|
|
|
|
wm8975_write(PWRMGMT2, wm8975_regs[PWRMGMT2]);
|
|
|
|
}
|
|
|
|
|
|
|
|
void audiohw_postinit(void)
|
|
|
|
{
|
|
|
|
wm8975_regs[PWRMGMT1] &= ~PWRMGMT1_VMIDSEL_MASK;
|
|
|
|
wm8975_regs[PWRMGMT1] |= PWRMGMT1_VMIDSEL_50K;
|
|
|
|
wm8975_write(PWRMGMT1, wm8975_regs[PWRMGMT1]);
|
|
|
|
audiohw_mute(false);
|
|
|
|
}
|
2011-03-03 20:53:30 +00:00
|
|
|
#else /* !IPOD_NANO2G */
|
2008-09-10 23:50:26 +00:00
|
|
|
void audiohw_preinit(void)
|
|
|
|
{
|
|
|
|
/* POWER UP SEQUENCE */
|
2011-03-03 20:53:30 +00:00
|
|
|
wm8975_write(RESET, RESET_RESET);
|
2008-09-10 23:50:26 +00:00
|
|
|
|
|
|
|
/* 2. Enable Vmid and VREF, quick startup. */
|
|
|
|
wm8975_write(PWRMGMT1, wm8975_regs[PWRMGMT1]);
|
|
|
|
sleep(HZ/50);
|
|
|
|
wm8975_regs[PWRMGMT1] &= ~PWRMGMT1_VMIDSEL_MASK;
|
|
|
|
wm8975_write(PWRMGMT1, wm8975_regs[PWRMGMT1] | PWRMGMT1_VMIDSEL_50K);
|
2005-12-16 11:00:44 +00:00
|
|
|
|
2008-09-10 23:50:26 +00:00
|
|
|
/* 4. Enable DACs, line and headphone output buffers as required. */
|
|
|
|
wm8975_write(PWRMGMT2, wm8975_regs[PWRMGMT2]);
|
2005-12-16 11:00:44 +00:00
|
|
|
|
2011-03-03 20:53:30 +00:00
|
|
|
wm8975_write(AINTFCE, AINTFCE_MS | AINTFCE_LRP_I2S_RLO
|
|
|
|
| AINTFCE_IWL_16BIT | AINTFCE_FORMAT_I2S);
|
2008-09-10 23:50:26 +00:00
|
|
|
|
|
|
|
wm8975_write(DAPCTRL, wm8975_regs[DAPCTRL] );
|
|
|
|
|
2011-03-03 20:53:30 +00:00
|
|
|
/* Set sample rate. */
|
|
|
|
wm8975_write(SAMPCTRL, WM8975_44100HZ);
|
2006-02-12 17:18:47 +00:00
|
|
|
|
2008-09-10 23:50:26 +00:00
|
|
|
/* set the volume to -6dB */
|
2011-03-03 20:53:30 +00:00
|
|
|
wm8975_write(LOUT1VOL, LOUT1VOL_LO1ZC | IPOD_PCM_LEVEL);
|
|
|
|
wm8975_write(ROUT1VOL, ROUT1VOL_RO1VU | ROUT1VOL_RO1ZC | IPOD_PCM_LEVEL);
|
2008-09-10 23:50:26 +00:00
|
|
|
|
2011-03-03 20:53:30 +00:00
|
|
|
wm8975_write(LOUTMIX1, LOUTMIX1_LD2LO| LOUTMIX1_LI2LOVOL(5));
|
|
|
|
wm8975_write(LOUTMIX2, LOUTMIX2_RI2LOVOL(5));
|
2005-12-16 11:00:44 +00:00
|
|
|
|
2011-03-03 20:53:30 +00:00
|
|
|
wm8975_write(ROUTMIX1, ROUTMIX1_LI2ROVOL(5));
|
|
|
|
wm8975_write(ROUTMIX2, ROUTMIX2_RD2RO| ROUTMIX2_RI2ROVOL(5));
|
2005-12-16 11:00:44 +00:00
|
|
|
|
2011-03-03 20:53:30 +00:00
|
|
|
wm8975_write(MOUTMIX1, 0);
|
|
|
|
wm8975_write(MOUTMIX2, 0);
|
2005-12-16 11:00:44 +00:00
|
|
|
}
|
|
|
|
|
2008-09-10 23:50:26 +00:00
|
|
|
void audiohw_postinit(void)
|
|
|
|
{
|
|
|
|
audiohw_mute(false);
|
|
|
|
}
|
2010-11-13 11:38:38 +00:00
|
|
|
#endif
|
2007-01-13 23:57:19 +00:00
|
|
|
|
2013-04-13 03:35:47 +00:00
|
|
|
void audiohw_set_volume(int vol_l, int vol_r)
|
2005-12-16 11:00:44 +00:00
|
|
|
{
|
2013-04-13 03:35:47 +00:00
|
|
|
vol_l = vol_tenthdb2hw(vol_l);
|
|
|
|
vol_r = vol_tenthdb2hw(vol_r);
|
2005-12-16 11:00:44 +00:00
|
|
|
|
|
|
|
/* OUT1 */
|
2011-03-03 20:53:30 +00:00
|
|
|
wm8975_write(LOUT1VOL, LOUT1VOL_LO1ZC | vol_l);
|
|
|
|
wm8975_write(ROUT1VOL, ROUT1VOL_RO1VU | ROUT1VOL_RO1ZC | vol_r);
|
2006-03-22 13:04:49 +00:00
|
|
|
}
|
|
|
|
|
2013-04-15 18:58:00 +00:00
|
|
|
void audiohw_set_lineout_volume(int vol_l, int vol_r)
|
2006-03-22 13:04:49 +00:00
|
|
|
{
|
2013-04-13 03:35:47 +00:00
|
|
|
vol_l = vol_tenthdb2hw(vol_l);
|
|
|
|
vol_r = vol_tenthdb2hw(vol_r);
|
|
|
|
|
2005-12-16 11:00:44 +00:00
|
|
|
/* OUT2 */
|
2011-03-03 20:53:30 +00:00
|
|
|
wm8975_write(LOUT2VOL, LOUT2VOL_LO2ZC | vol_l);
|
|
|
|
wm8975_write(ROUT2VOL, ROUT2VOL_RO2VU | ROUT2VOL_RO2ZC | vol_r);
|
2005-12-16 11:00:44 +00:00
|
|
|
}
|
|
|
|
|
2010-09-24 22:42:06 +00:00
|
|
|
void audiohw_enable_lineout(bool enable)
|
|
|
|
{
|
|
|
|
if (enable) {
|
|
|
|
/* Enable lineout */
|
|
|
|
wm8975_regs[PWRMGMT2] |= (PWRMGMT2_LOUT2 | PWRMGMT2_ROUT2);
|
|
|
|
} else {
|
|
|
|
/* Disable lineout */
|
|
|
|
wm8975_regs[PWRMGMT2] &= ~(PWRMGMT2_LOUT2 | PWRMGMT2_ROUT2);
|
|
|
|
}
|
|
|
|
wm8975_write(PWRMGMT2, wm8975_regs[PWRMGMT2]);
|
|
|
|
}
|
|
|
|
|
2006-12-06 10:24:59 +00:00
|
|
|
void audiohw_set_bass(int value)
|
2005-12-16 11:00:44 +00:00
|
|
|
{
|
2007-03-07 15:00:29 +00:00
|
|
|
const int regvalues[] = {
|
2008-09-10 23:50:26 +00:00
|
|
|
11, 10, 10, 9, 8, 8, 0xf, 6, 6, 5, 4, 4, 3, 2, 2, 1
|
2007-03-07 15:00:29 +00:00
|
|
|
};
|
2006-01-30 21:12:31 +00:00
|
|
|
|
2007-03-07 15:00:29 +00:00
|
|
|
if ((value >= -6) && (value <= 9)) {
|
|
|
|
/* We use linear bass control with 200 Hz cutoff */
|
2011-03-03 20:53:30 +00:00
|
|
|
wm8975_write(BASSCTRL, regvalues[value + 6] | BASSCTRL_BC);
|
2007-03-07 15:00:29 +00:00
|
|
|
}
|
2005-12-16 11:00:44 +00:00
|
|
|
}
|
|
|
|
|
2006-12-06 10:24:59 +00:00
|
|
|
void audiohw_set_treble(int value)
|
2005-12-16 11:00:44 +00:00
|
|
|
{
|
2007-03-07 15:00:29 +00:00
|
|
|
const int regvalues[] = {
|
2008-09-10 23:50:26 +00:00
|
|
|
11, 10, 10, 9, 8, 8, 0xf, 6, 6, 5, 4, 4, 3, 2, 2, 1
|
2007-03-07 15:00:29 +00:00
|
|
|
};
|
2006-01-30 21:12:31 +00:00
|
|
|
|
2007-03-07 15:00:29 +00:00
|
|
|
if ((value >= -6) && (value <= 9)) {
|
|
|
|
/* We use linear treble control with 4 kHz cutoff */
|
2011-03-03 20:53:30 +00:00
|
|
|
wm8975_write(TREBCTRL, regvalues[value + 6] | TREBCTRL_TC);
|
2005-12-16 11:00:44 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Nice shutdown of WM8975 codec */
|
2006-12-06 10:24:59 +00:00
|
|
|
void audiohw_close(void)
|
2005-12-16 11:00:44 +00:00
|
|
|
{
|
2008-09-10 23:50:26 +00:00
|
|
|
audiohw_mute(true);
|
2005-12-16 11:00:44 +00:00
|
|
|
|
|
|
|
/* 2. Disable all output buffers. */
|
2011-03-03 20:53:30 +00:00
|
|
|
wm8975_write(PWRMGMT2, 0x0);
|
2005-12-16 11:00:44 +00:00
|
|
|
|
|
|
|
/* 3. Switch off the power supplies. */
|
2011-03-03 20:53:30 +00:00
|
|
|
wm8975_write(PWRMGMT1, 0x0);
|
2005-12-16 11:00:44 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Note: Disable output before calling this function */
|
2008-12-12 11:01:07 +00:00
|
|
|
void audiohw_set_frequency(int fsel)
|
2008-09-10 23:50:26 +00:00
|
|
|
{
|
2008-12-12 11:01:07 +00:00
|
|
|
(void)fsel;
|
2005-12-16 11:00:44 +00:00
|
|
|
}
|
|
|
|
|
2008-09-10 23:50:26 +00:00
|
|
|
#ifdef HAVE_RECORDING
|
2006-12-18 01:52:21 +00:00
|
|
|
void audiohw_enable_recording(bool source_mic)
|
|
|
|
{
|
2008-09-10 23:50:26 +00:00
|
|
|
wm8975_regs[PWRMGMT1] |= PWRMGMT1_AINL | PWRMGMT1_AINR
|
|
|
|
| PWRMGMT1_ADCL | PWRMGMT1_ADCR;
|
|
|
|
wm8975_write(PWRMGMT1, wm8975_regs[PWRMGMT1]);
|
2006-12-18 01:52:21 +00:00
|
|
|
|
2008-09-10 23:50:26 +00:00
|
|
|
/* NOTE: When switching to digital monitoring we will not want
|
|
|
|
* the DACs disabled. Also the outputs shouldn't be disabled
|
|
|
|
* when recording from line in (dock connector) - needs testing. */
|
|
|
|
wm8975_regs[PWRMGMT2] &= ~(PWRMGMT2_LOUT1 | PWRMGMT2_ROUT1
|
2011-03-03 20:53:30 +00:00
|
|
|
| PWRMGMT2_LOUT2 | PWRMGMT2_ROUT2);
|
2008-09-10 23:50:26 +00:00
|
|
|
wm8975_write(PWRMGMT2, wm8975_regs[PWRMGMT2]);
|
2006-12-18 01:52:21 +00:00
|
|
|
|
2008-09-10 23:50:26 +00:00
|
|
|
wm8975_write_or(LINVOL, LINVOL_LINMUTE);
|
|
|
|
wm8975_write_or(RINVOL, RINVOL_RINMUTE);
|
2006-12-18 01:52:21 +00:00
|
|
|
|
2011-03-03 20:53:30 +00:00
|
|
|
wm8975_write(ADDCTRL3, ADDCTRL3_VROI);
|
2006-12-18 01:52:21 +00:00
|
|
|
|
|
|
|
if (source_mic) {
|
2011-03-03 20:53:30 +00:00
|
|
|
wm8975_write(ADDCTRL1, ADDCTRL1_VSEL_LOWBIAS | ADDCTRL1_DATSEL_RADC
|
|
|
|
| ADDCTRL1_TOEN);
|
|
|
|
wm8975_write(ADCLPATH, 0);
|
|
|
|
wm8975_write(ADCRPATH, ADCRPATH_RINSEL_RIN2 | ADCRPATH_RMICBOOST_20dB);
|
2006-12-18 01:52:21 +00:00
|
|
|
} else {
|
2011-03-03 20:53:30 +00:00
|
|
|
wm8975_write(ADDCTRL1, ADDCTRL1_VSEL_LOWBIAS | ADDCTRL1_DATSEL_NORMAL
|
|
|
|
| ADDCTRL1_TOEN);
|
|
|
|
wm8975_write(ADCLPATH, ADCLPATH_LINSEL_LIN1 | ADCLPATH_LMICBOOST_OFF);
|
|
|
|
wm8975_write(ADCRPATH, ADCRPATH_RINSEL_RIN1 | ADCRPATH_RMICBOOST_OFF);
|
2006-12-18 01:52:21 +00:00
|
|
|
}
|
2008-09-10 23:50:26 +00:00
|
|
|
wm8975_write_and(LINVOL, ~LINVOL_LINMUTE);
|
|
|
|
wm8975_write_and(RINVOL, ~RINVOL_RINMUTE);
|
2006-12-18 01:52:21 +00:00
|
|
|
}
|
2005-12-16 11:00:44 +00:00
|
|
|
|
2008-09-10 23:50:26 +00:00
|
|
|
void audiohw_disable_recording(void)
|
|
|
|
{
|
|
|
|
/* mute inputs */
|
|
|
|
wm8975_write_or(LINVOL, LINVOL_LINMUTE);
|
|
|
|
wm8975_write_or(RINVOL, RINVOL_RINMUTE);
|
2006-12-18 01:52:21 +00:00
|
|
|
|
2011-03-03 20:53:30 +00:00
|
|
|
wm8975_write(ADDCTRL3, 0);
|
2005-12-16 11:00:44 +00:00
|
|
|
|
2008-09-10 23:50:26 +00:00
|
|
|
wm8975_regs[PWRMGMT2] |= PWRMGMT2_DACL | PWRMGMT2_DACR
|
|
|
|
| PWRMGMT2_LOUT1 | PWRMGMT2_ROUT1
|
|
|
|
| PWRMGMT2_LOUT2 | PWRMGMT2_ROUT2;
|
|
|
|
wm8975_write(PWRMGMT2, wm8975_regs[PWRMGMT2]);
|
2005-12-16 11:00:44 +00:00
|
|
|
|
2008-09-10 23:50:26 +00:00
|
|
|
wm8975_regs[PWRMGMT1] &= ~(PWRMGMT1_AINL | PWRMGMT1_AINR
|
|
|
|
| PWRMGMT1_ADCL | PWRMGMT1_ADCR);
|
|
|
|
wm8975_write(PWRMGMT1, wm8975_regs[PWRMGMT1]);
|
2005-12-16 11:00:44 +00:00
|
|
|
}
|
|
|
|
|
2016-08-21 19:31:55 +00:00
|
|
|
/* volume in 0 .. 63, corresponds to -17.25dB .. 30dB in steps of 0.75dB
|
|
|
|
* microphone has an extra 20dB boost so 0 .. 63 corresponds to 2.75dB .. 50dB */
|
2008-09-10 23:50:26 +00:00
|
|
|
void audiohw_set_recvol(int left, int right, int type)
|
|
|
|
{
|
|
|
|
switch (type)
|
|
|
|
{
|
|
|
|
case AUDIO_GAIN_MIC: /* Mic uses right ADC */
|
|
|
|
wm8975_regs[RINVOL] &= ~RINVOL_MASK;
|
|
|
|
wm8975_write_or(RINVOL, left & RINVOL_MASK);
|
|
|
|
break;
|
|
|
|
case AUDIO_GAIN_LINEIN:
|
|
|
|
wm8975_regs[LINVOL] &= ~LINVOL_MASK;
|
|
|
|
wm8975_write_or(LINVOL, left & LINVOL_MASK);
|
|
|
|
wm8975_regs[RINVOL] &= ~RINVOL_MASK;
|
|
|
|
wm8975_write_or(RINVOL, right & RINVOL_MASK);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
2005-12-16 11:00:44 +00:00
|
|
|
|
2008-09-10 23:50:26 +00:00
|
|
|
void audiohw_set_monitor(bool enable)
|
|
|
|
{
|
2010-10-24 09:24:35 +00:00
|
|
|
if (enable) {
|
2010-11-05 17:22:46 +00:00
|
|
|
/* set volume to 0 dB */
|
2010-10-24 09:24:35 +00:00
|
|
|
wm8975_regs[LOUTMIX1] &= ~LOUTMIX1_LI2LOVOL_MASK;
|
2011-03-03 20:53:30 +00:00
|
|
|
wm8975_regs[LOUTMIX1] |= LOUTMIX1_LI2LOVOL(2);
|
2010-10-24 09:24:35 +00:00
|
|
|
wm8975_regs[ROUTMIX2] &= ~ROUTMIX2_RI2ROVOL_MASK;
|
2011-03-03 20:53:30 +00:00
|
|
|
wm8975_regs[ROUTMIX2] |= ROUTMIX2_RI2ROVOL(2);
|
2010-11-05 17:22:46 +00:00
|
|
|
/* set mux to line input */
|
2011-03-03 20:53:30 +00:00
|
|
|
wm8975_write_and(LOUTMIX1, ~LOUTMIX1_LMIXSEL_MASK);
|
|
|
|
wm8975_write_and(ROUTMIX1, ~ROUTMIX1_RMIXSEL_MASK);
|
2010-11-05 17:22:46 +00:00
|
|
|
/* enable bypass */
|
2010-10-24 09:24:35 +00:00
|
|
|
wm8975_write_or(LOUTMIX1, LOUTMIX1_LI2LO);
|
|
|
|
wm8975_write_or(ROUTMIX2, ROUTMIX2_RI2RO);
|
|
|
|
} else {
|
2010-11-05 17:22:46 +00:00
|
|
|
/* disable bypass */
|
2010-10-24 09:24:35 +00:00
|
|
|
wm8975_write_and(LOUTMIX1, ~LOUTMIX1_LI2LO);
|
|
|
|
wm8975_write_and(ROUTMIX2, ~ROUTMIX2_RI2RO);
|
|
|
|
}
|
2005-12-16 11:00:44 +00:00
|
|
|
}
|
2008-09-10 23:50:26 +00:00
|
|
|
#endif /* HAVE_RECORDING */
|