2008-10-31 04:35:26 +00:00
|
|
|
/*
|
|
|
|
* ALSA SoC TWL4030 codec driver
|
|
|
|
*
|
|
|
|
* Author: Steve Sakoman, <steve@sakoman.com>
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU General Public License
|
|
|
|
* version 2 as published by the Free Software Foundation.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful, but
|
|
|
|
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
|
|
|
|
* 02110-1301 USA
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <linux/module.h>
|
|
|
|
#include <linux/moduleparam.h>
|
|
|
|
#include <linux/init.h>
|
|
|
|
#include <linux/delay.h>
|
|
|
|
#include <linux/pm.h>
|
|
|
|
#include <linux/i2c.h>
|
|
|
|
#include <linux/platform_device.h>
|
2012-09-10 10:46:32 +00:00
|
|
|
#include <linux/of.h>
|
|
|
|
#include <linux/of_gpio.h>
|
2009-12-13 19:05:51 +00:00
|
|
|
#include <linux/i2c/twl.h>
|
include cleanup: Update gfp.h and slab.h includes to prepare for breaking implicit slab.h inclusion from percpu.h
percpu.h is included by sched.h and module.h and thus ends up being
included when building most .c files. percpu.h includes slab.h which
in turn includes gfp.h making everything defined by the two files
universally available and complicating inclusion dependencies.
percpu.h -> slab.h dependency is about to be removed. Prepare for
this change by updating users of gfp and slab facilities include those
headers directly instead of assuming availability. As this conversion
needs to touch large number of source files, the following script is
used as the basis of conversion.
http://userweb.kernel.org/~tj/misc/slabh-sweep.py
The script does the followings.
* Scan files for gfp and slab usages and update includes such that
only the necessary includes are there. ie. if only gfp is used,
gfp.h, if slab is used, slab.h.
* When the script inserts a new include, it looks at the include
blocks and try to put the new include such that its order conforms
to its surrounding. It's put in the include block which contains
core kernel includes, in the same order that the rest are ordered -
alphabetical, Christmas tree, rev-Xmas-tree or at the end if there
doesn't seem to be any matching order.
* If the script can't find a place to put a new include (mostly
because the file doesn't have fitting include block), it prints out
an error message indicating which .h file needs to be added to the
file.
The conversion was done in the following steps.
1. The initial automatic conversion of all .c files updated slightly
over 4000 files, deleting around 700 includes and adding ~480 gfp.h
and ~3000 slab.h inclusions. The script emitted errors for ~400
files.
2. Each error was manually checked. Some didn't need the inclusion,
some needed manual addition while adding it to implementation .h or
embedding .c file was more appropriate for others. This step added
inclusions to around 150 files.
3. The script was run again and the output was compared to the edits
from #2 to make sure no file was left behind.
4. Several build tests were done and a couple of problems were fixed.
e.g. lib/decompress_*.c used malloc/free() wrappers around slab
APIs requiring slab.h to be added manually.
5. The script was run on all .h files but without automatically
editing them as sprinkling gfp.h and slab.h inclusions around .h
files could easily lead to inclusion dependency hell. Most gfp.h
inclusion directives were ignored as stuff from gfp.h was usually
wildly available and often used in preprocessor macros. Each
slab.h inclusion directive was examined and added manually as
necessary.
6. percpu.h was updated not to include slab.h.
7. Build test were done on the following configurations and failures
were fixed. CONFIG_GCOV_KERNEL was turned off for all tests (as my
distributed build env didn't work with gcov compiles) and a few
more options had to be turned off depending on archs to make things
build (like ipr on powerpc/64 which failed due to missing writeq).
* x86 and x86_64 UP and SMP allmodconfig and a custom test config.
* powerpc and powerpc64 SMP allmodconfig
* sparc and sparc64 SMP allmodconfig
* ia64 SMP allmodconfig
* s390 SMP allmodconfig
* alpha SMP allmodconfig
* um on x86_64 SMP allmodconfig
8. percpu.h modifications were reverted so that it could be applied as
a separate patch and serve as bisection point.
Given the fact that I had only a couple of failures from tests on step
6, I'm fairly confident about the coverage of this conversion patch.
If there is a breakage, it's likely to be something in one of the arch
headers which should be easily discoverable easily on most builds of
the specific arch.
Signed-off-by: Tejun Heo <tj@kernel.org>
Guess-its-ok-by: Christoph Lameter <cl@linux-foundation.org>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: Lee Schermerhorn <Lee.Schermerhorn@hp.com>
2010-03-24 08:04:11 +00:00
|
|
|
#include <linux/slab.h>
|
2012-09-10 10:46:27 +00:00
|
|
|
#include <linux/gpio.h>
|
2008-10-31 04:35:26 +00:00
|
|
|
#include <sound/core.h>
|
|
|
|
#include <sound/pcm.h>
|
|
|
|
#include <sound/pcm_params.h>
|
|
|
|
#include <sound/soc.h>
|
|
|
|
#include <sound/initval.h>
|
2008-11-24 11:49:35 +00:00
|
|
|
#include <sound/tlv.h>
|
2008-10-31 04:35:26 +00:00
|
|
|
|
2010-03-17 20:15:21 +00:00
|
|
|
/* Register descriptions are here */
|
2011-05-31 09:02:49 +00:00
|
|
|
#include <linux/mfd/twl4030-audio.h>
|
2010-03-17 20:15:21 +00:00
|
|
|
|
2012-12-31 10:51:46 +00:00
|
|
|
/* TWL4030 PMBR1 Register */
|
|
|
|
#define TWL4030_PMBR1_REG 0x0D
|
|
|
|
/* TWL4030 PMBR1 Register GPIO6 mux bits */
|
|
|
|
#define TWL4030_GPIO6_PWM0_MUTE(value) ((value & 0x03) << 2)
|
|
|
|
|
2013-10-06 11:43:50 +00:00
|
|
|
#define TWL4030_CACHEREGNUM (TWL4030_REG_MISC_SET_2 + 1)
|
2008-10-31 04:35:26 +00:00
|
|
|
|
2009-01-29 12:57:50 +00:00
|
|
|
/* codec private data */
|
|
|
|
struct twl4030_priv {
|
|
|
|
unsigned int codec_powered;
|
2010-04-29 07:58:08 +00:00
|
|
|
|
|
|
|
/* reference counts of AIF/APLL users */
|
2009-10-28 08:57:05 +00:00
|
|
|
unsigned int apll_enabled;
|
2009-03-27 08:39:08 +00:00
|
|
|
|
|
|
|
struct snd_pcm_substream *master_substream;
|
|
|
|
struct snd_pcm_substream *slave_substream;
|
2009-04-17 12:55:08 +00:00
|
|
|
|
|
|
|
unsigned int configured;
|
|
|
|
unsigned int rate;
|
|
|
|
unsigned int sample_bits;
|
|
|
|
unsigned int channels;
|
2009-05-18 13:02:05 +00:00
|
|
|
|
|
|
|
unsigned int sysclk;
|
|
|
|
|
ASoC: TWL4030: PM fix for output amplifiers
Gain controls on outputs affect the power consumption
when the gain is set to non 0 value.
Outputs with amps have one register to configure the
routing and the gain:
PREDL_CTL (0x25):
bit 0: Voice enable
bit 1: Audio L1 enable
bit 2: Audio L2 enable
bit 3: Audio R2 enable
bit 4-5: Gain (0x0 - power down, 0x1 - 6dB, 0x2 - 0dB, 0x3 - -6dB)
bit 0 - 3: is handled in DAPM domain (DAPM_MIXER)
bit 4 - 5: has simple volume control
If there is no audio activity (BIAS_STANDBY), and
user changes the volume, than the output amplifier will
be enabled.
If the user changes the routing (but the codec remains in
BIAS_STANDBY), than the cached gain value also be written
to the register, which enables the amplifier.
The existing workaround for this is to have virtual
PGAs associated with the outputs, and whit DAPM PMD
the gain on the output will be forced to 0 (off) by
bypassing the regcache.
This failed to disable the amplifiers in several
scenario (as mentioned above).
Also if the codec is in BIAS_ON state, and user modifies
a volume control, which path is actually not enabled, than
that amplifier will be enabled as well, but it will
be not turned off, since there is no DAPM path, which
would make mute it.
To prevent amps being enabled, when they are not
needed, introduce the following workaround:
Track the state of each of this type of output.
In twl4030_write only allow actual write, when the
given output is enabled, otherwise only update
the reg_cache.
The PGA event handlers on power up will write the cached
value to the chip (restoring gain, routing selection).
On power down 0 is written to the register (disabling
the amp, and also just in case clearing the routing).
Signed-off-by: Peter Ujfalusi <peter.ujfalusi@nokia.com>
Acked-by: Liam Girdwood <lrg@slimlogic.co.uk>
Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
2010-03-22 15:46:37 +00:00
|
|
|
/* Output (with associated amp) states */
|
|
|
|
u8 hsl_enabled, hsr_enabled;
|
|
|
|
u8 earpiece_enabled;
|
|
|
|
u8 predrivel_enabled, predriver_enabled;
|
|
|
|
u8 carkitl_enabled, carkitr_enabled;
|
2014-01-03 13:27:52 +00:00
|
|
|
u8 ctl_cache[TWL4030_REG_PRECKR_CTL - TWL4030_REG_EAR_CTL + 1];
|
2010-07-20 12:49:09 +00:00
|
|
|
|
2012-09-10 10:46:31 +00:00
|
|
|
struct twl4030_codec_data *pdata;
|
2009-01-29 12:57:50 +00:00
|
|
|
};
|
|
|
|
|
2014-01-03 13:27:52 +00:00
|
|
|
static void tw4030_init_ctl_cache(struct twl4030_priv *twl4030)
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
u8 byte;
|
|
|
|
|
|
|
|
for (i = TWL4030_REG_EAR_CTL; i <= TWL4030_REG_PRECKR_CTL; i++) {
|
|
|
|
twl_i2c_read_u8(TWL4030_MODULE_AUDIO_VOICE, &byte, i);
|
|
|
|
twl4030->ctl_cache[i - TWL4030_REG_EAR_CTL] = byte;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-01-03 13:27:53 +00:00
|
|
|
static unsigned int twl4030_read(struct snd_soc_codec *codec, unsigned int reg)
|
2008-10-31 04:35:26 +00:00
|
|
|
{
|
2014-01-03 13:27:53 +00:00
|
|
|
struct twl4030_priv *twl4030 = snd_soc_codec_get_drvdata(codec);
|
|
|
|
u8 value = 0;
|
2008-10-31 04:35:26 +00:00
|
|
|
|
|
|
|
if (reg >= TWL4030_CACHEREGNUM)
|
2014-01-03 13:27:53 +00:00
|
|
|
return -EIO;
|
|
|
|
|
|
|
|
switch (reg) {
|
|
|
|
case TWL4030_REG_EAR_CTL:
|
|
|
|
case TWL4030_REG_PREDL_CTL:
|
|
|
|
case TWL4030_REG_PREDR_CTL:
|
|
|
|
case TWL4030_REG_PRECKL_CTL:
|
|
|
|
case TWL4030_REG_PRECKR_CTL:
|
|
|
|
case TWL4030_REG_HS_GAIN_SET:
|
|
|
|
value = twl4030->ctl_cache[reg - TWL4030_REG_EAR_CTL];
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
twl_i2c_read_u8(TWL4030_MODULE_AUDIO_VOICE, &value, reg);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
return value;
|
2008-10-31 04:35:26 +00:00
|
|
|
}
|
|
|
|
|
2014-01-03 13:27:56 +00:00
|
|
|
static bool twl4030_can_write_to_chip(struct twl4030_priv *twl4030,
|
2014-01-03 13:27:49 +00:00
|
|
|
unsigned int reg)
|
2008-10-31 04:35:26 +00:00
|
|
|
{
|
2014-01-03 13:27:49 +00:00
|
|
|
bool write_to_reg = false;
|
ASoC: TWL4030: PM fix for output amplifiers
Gain controls on outputs affect the power consumption
when the gain is set to non 0 value.
Outputs with amps have one register to configure the
routing and the gain:
PREDL_CTL (0x25):
bit 0: Voice enable
bit 1: Audio L1 enable
bit 2: Audio L2 enable
bit 3: Audio R2 enable
bit 4-5: Gain (0x0 - power down, 0x1 - 6dB, 0x2 - 0dB, 0x3 - -6dB)
bit 0 - 3: is handled in DAPM domain (DAPM_MIXER)
bit 4 - 5: has simple volume control
If there is no audio activity (BIAS_STANDBY), and
user changes the volume, than the output amplifier will
be enabled.
If the user changes the routing (but the codec remains in
BIAS_STANDBY), than the cached gain value also be written
to the register, which enables the amplifier.
The existing workaround for this is to have virtual
PGAs associated with the outputs, and whit DAPM PMD
the gain on the output will be forced to 0 (off) by
bypassing the regcache.
This failed to disable the amplifiers in several
scenario (as mentioned above).
Also if the codec is in BIAS_ON state, and user modifies
a volume control, which path is actually not enabled, than
that amplifier will be enabled as well, but it will
be not turned off, since there is no DAPM path, which
would make mute it.
To prevent amps being enabled, when they are not
needed, introduce the following workaround:
Track the state of each of this type of output.
In twl4030_write only allow actual write, when the
given output is enabled, otherwise only update
the reg_cache.
The PGA event handlers on power up will write the cached
value to the chip (restoring gain, routing selection).
On power down 0 is written to the register (disabling
the amp, and also just in case clearing the routing).
Signed-off-by: Peter Ujfalusi <peter.ujfalusi@nokia.com>
Acked-by: Liam Girdwood <lrg@slimlogic.co.uk>
Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
2010-03-22 15:46:37 +00:00
|
|
|
|
2013-10-06 11:43:50 +00:00
|
|
|
/* Decide if the given register can be written */
|
|
|
|
switch (reg) {
|
|
|
|
case TWL4030_REG_EAR_CTL:
|
|
|
|
if (twl4030->earpiece_enabled)
|
2014-01-03 13:27:49 +00:00
|
|
|
write_to_reg = true;
|
2013-10-06 11:43:50 +00:00
|
|
|
break;
|
|
|
|
case TWL4030_REG_PREDL_CTL:
|
|
|
|
if (twl4030->predrivel_enabled)
|
2014-01-03 13:27:49 +00:00
|
|
|
write_to_reg = true;
|
2013-10-06 11:43:50 +00:00
|
|
|
break;
|
|
|
|
case TWL4030_REG_PREDR_CTL:
|
|
|
|
if (twl4030->predriver_enabled)
|
2014-01-03 13:27:49 +00:00
|
|
|
write_to_reg = true;
|
2013-10-06 11:43:50 +00:00
|
|
|
break;
|
|
|
|
case TWL4030_REG_PRECKL_CTL:
|
|
|
|
if (twl4030->carkitl_enabled)
|
2014-01-03 13:27:49 +00:00
|
|
|
write_to_reg = true;
|
2013-10-06 11:43:50 +00:00
|
|
|
break;
|
|
|
|
case TWL4030_REG_PRECKR_CTL:
|
|
|
|
if (twl4030->carkitr_enabled)
|
2014-01-03 13:27:49 +00:00
|
|
|
write_to_reg = true;
|
2013-10-06 11:43:50 +00:00
|
|
|
break;
|
|
|
|
case TWL4030_REG_HS_GAIN_SET:
|
|
|
|
if (twl4030->hsl_enabled || twl4030->hsr_enabled)
|
2014-01-03 13:27:49 +00:00
|
|
|
write_to_reg = true;
|
2013-10-06 11:43:50 +00:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
/* All other register can be written */
|
2014-01-03 13:27:49 +00:00
|
|
|
write_to_reg = true;
|
2013-10-06 11:43:50 +00:00
|
|
|
break;
|
ASoC: TWL4030: PM fix for output amplifiers
Gain controls on outputs affect the power consumption
when the gain is set to non 0 value.
Outputs with amps have one register to configure the
routing and the gain:
PREDL_CTL (0x25):
bit 0: Voice enable
bit 1: Audio L1 enable
bit 2: Audio L2 enable
bit 3: Audio R2 enable
bit 4-5: Gain (0x0 - power down, 0x1 - 6dB, 0x2 - 0dB, 0x3 - -6dB)
bit 0 - 3: is handled in DAPM domain (DAPM_MIXER)
bit 4 - 5: has simple volume control
If there is no audio activity (BIAS_STANDBY), and
user changes the volume, than the output amplifier will
be enabled.
If the user changes the routing (but the codec remains in
BIAS_STANDBY), than the cached gain value also be written
to the register, which enables the amplifier.
The existing workaround for this is to have virtual
PGAs associated with the outputs, and whit DAPM PMD
the gain on the output will be forced to 0 (off) by
bypassing the regcache.
This failed to disable the amplifiers in several
scenario (as mentioned above).
Also if the codec is in BIAS_ON state, and user modifies
a volume control, which path is actually not enabled, than
that amplifier will be enabled as well, but it will
be not turned off, since there is no DAPM path, which
would make mute it.
To prevent amps being enabled, when they are not
needed, introduce the following workaround:
Track the state of each of this type of output.
In twl4030_write only allow actual write, when the
given output is enabled, otherwise only update
the reg_cache.
The PGA event handlers on power up will write the cached
value to the chip (restoring gain, routing selection).
On power down 0 is written to the register (disabling
the amp, and also just in case clearing the routing).
Signed-off-by: Peter Ujfalusi <peter.ujfalusi@nokia.com>
Acked-by: Liam Girdwood <lrg@slimlogic.co.uk>
Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
2010-03-22 15:46:37 +00:00
|
|
|
}
|
2014-01-03 13:27:49 +00:00
|
|
|
|
|
|
|
return write_to_reg;
|
|
|
|
}
|
|
|
|
|
2014-01-03 13:27:54 +00:00
|
|
|
static int twl4030_write(struct snd_soc_codec *codec, unsigned int reg,
|
|
|
|
unsigned int value)
|
2014-01-03 13:27:49 +00:00
|
|
|
{
|
2014-01-03 13:27:55 +00:00
|
|
|
struct twl4030_priv *twl4030 = snd_soc_codec_get_drvdata(codec);
|
|
|
|
|
|
|
|
/* Update the ctl cache */
|
|
|
|
switch (reg) {
|
|
|
|
case TWL4030_REG_EAR_CTL:
|
|
|
|
case TWL4030_REG_PREDL_CTL:
|
|
|
|
case TWL4030_REG_PREDR_CTL:
|
|
|
|
case TWL4030_REG_PRECKL_CTL:
|
|
|
|
case TWL4030_REG_PRECKR_CTL:
|
|
|
|
case TWL4030_REG_HS_GAIN_SET:
|
|
|
|
twl4030->ctl_cache[reg - TWL4030_REG_EAR_CTL] = value;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2014-01-03 13:27:56 +00:00
|
|
|
if (twl4030_can_write_to_chip(twl4030, reg))
|
2014-01-03 13:27:49 +00:00
|
|
|
return twl_i2c_write_u8(TWL4030_MODULE_AUDIO_VOICE, value, reg);
|
2013-10-06 11:43:50 +00:00
|
|
|
|
ASoC: TWL4030: PM fix for output amplifiers
Gain controls on outputs affect the power consumption
when the gain is set to non 0 value.
Outputs with amps have one register to configure the
routing and the gain:
PREDL_CTL (0x25):
bit 0: Voice enable
bit 1: Audio L1 enable
bit 2: Audio L2 enable
bit 3: Audio R2 enable
bit 4-5: Gain (0x0 - power down, 0x1 - 6dB, 0x2 - 0dB, 0x3 - -6dB)
bit 0 - 3: is handled in DAPM domain (DAPM_MIXER)
bit 4 - 5: has simple volume control
If there is no audio activity (BIAS_STANDBY), and
user changes the volume, than the output amplifier will
be enabled.
If the user changes the routing (but the codec remains in
BIAS_STANDBY), than the cached gain value also be written
to the register, which enables the amplifier.
The existing workaround for this is to have virtual
PGAs associated with the outputs, and whit DAPM PMD
the gain on the output will be forced to 0 (off) by
bypassing the regcache.
This failed to disable the amplifiers in several
scenario (as mentioned above).
Also if the codec is in BIAS_ON state, and user modifies
a volume control, which path is actually not enabled, than
that amplifier will be enabled as well, but it will
be not turned off, since there is no DAPM path, which
would make mute it.
To prevent amps being enabled, when they are not
needed, introduce the following workaround:
Track the state of each of this type of output.
In twl4030_write only allow actual write, when the
given output is enabled, otherwise only update
the reg_cache.
The PGA event handlers on power up will write the cached
value to the chip (restoring gain, routing selection).
On power down 0 is written to the register (disabling
the amp, and also just in case clearing the routing).
Signed-off-by: Peter Ujfalusi <peter.ujfalusi@nokia.com>
Acked-by: Liam Girdwood <lrg@slimlogic.co.uk>
Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
2010-03-22 15:46:37 +00:00
|
|
|
return 0;
|
2008-10-31 04:35:26 +00:00
|
|
|
}
|
|
|
|
|
2010-10-25 08:34:23 +00:00
|
|
|
static inline void twl4030_wait_ms(int time)
|
|
|
|
{
|
|
|
|
if (time < 60) {
|
|
|
|
time *= 1000;
|
|
|
|
usleep_range(time, time + 500);
|
|
|
|
} else {
|
|
|
|
msleep(time);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-01-27 09:29:40 +00:00
|
|
|
static void twl4030_codec_enable(struct snd_soc_codec *codec, int enable)
|
2008-10-31 04:35:26 +00:00
|
|
|
{
|
2010-04-14 06:35:19 +00:00
|
|
|
struct twl4030_priv *twl4030 = snd_soc_codec_get_drvdata(codec);
|
2009-10-22 10:26:48 +00:00
|
|
|
int mode;
|
2008-10-31 04:35:26 +00:00
|
|
|
|
2009-01-29 12:57:50 +00:00
|
|
|
if (enable == twl4030->codec_powered)
|
|
|
|
return;
|
|
|
|
|
2009-01-27 09:29:40 +00:00
|
|
|
if (enable)
|
2011-05-31 09:02:49 +00:00
|
|
|
mode = twl4030_audio_enable_resource(TWL4030_AUDIO_RES_POWER);
|
2009-01-27 09:29:40 +00:00
|
|
|
else
|
2011-05-31 09:02:49 +00:00
|
|
|
mode = twl4030_audio_disable_resource(TWL4030_AUDIO_RES_POWER);
|
2008-10-31 04:35:26 +00:00
|
|
|
|
2014-01-03 13:27:53 +00:00
|
|
|
if (mode >= 0)
|
2009-10-22 10:26:48 +00:00
|
|
|
twl4030->codec_powered = enable;
|
2008-10-31 04:35:26 +00:00
|
|
|
|
|
|
|
/* REVISIT: this delay is present in TI sample drivers */
|
|
|
|
/* but there seems to be no TRM requirement for it */
|
|
|
|
udelay(10);
|
|
|
|
}
|
|
|
|
|
2012-09-10 10:46:32 +00:00
|
|
|
static void twl4030_setup_pdata_of(struct twl4030_codec_data *pdata,
|
|
|
|
struct device_node *node)
|
|
|
|
{
|
|
|
|
int value;
|
|
|
|
|
|
|
|
of_property_read_u32(node, "ti,digimic_delay",
|
|
|
|
&pdata->digimic_delay);
|
|
|
|
of_property_read_u32(node, "ti,ramp_delay_value",
|
|
|
|
&pdata->ramp_delay_value);
|
|
|
|
of_property_read_u32(node, "ti,offset_cncl_path",
|
|
|
|
&pdata->offset_cncl_path);
|
|
|
|
if (!of_property_read_u32(node, "ti,hs_extmute", &value))
|
|
|
|
pdata->hs_extmute = value;
|
|
|
|
|
|
|
|
pdata->hs_extmute_gpio = of_get_named_gpio(node,
|
|
|
|
"ti,hs_extmute_gpio", 0);
|
|
|
|
if (gpio_is_valid(pdata->hs_extmute_gpio))
|
|
|
|
pdata->hs_extmute = 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
static struct twl4030_codec_data *twl4030_get_pdata(struct snd_soc_codec *codec)
|
2009-01-29 12:57:50 +00:00
|
|
|
{
|
2011-05-31 12:21:13 +00:00
|
|
|
struct twl4030_codec_data *pdata = dev_get_platdata(codec->dev);
|
2012-09-10 10:46:32 +00:00
|
|
|
struct device_node *twl4030_codec_node = NULL;
|
|
|
|
|
|
|
|
twl4030_codec_node = of_find_node_by_name(codec->dev->parent->of_node,
|
|
|
|
"codec");
|
|
|
|
|
|
|
|
if (!pdata && twl4030_codec_node) {
|
|
|
|
pdata = devm_kzalloc(codec->dev,
|
|
|
|
sizeof(struct twl4030_codec_data),
|
|
|
|
GFP_KERNEL);
|
|
|
|
if (!pdata) {
|
|
|
|
dev_err(codec->dev, "Can not allocate memory\n");
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
twl4030_setup_pdata_of(pdata, twl4030_codec_node);
|
|
|
|
}
|
|
|
|
|
|
|
|
return pdata;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void twl4030_init_chip(struct snd_soc_codec *codec)
|
|
|
|
{
|
|
|
|
struct twl4030_codec_data *pdata;
|
2010-04-14 06:35:19 +00:00
|
|
|
struct twl4030_priv *twl4030 = snd_soc_codec_get_drvdata(codec);
|
2010-05-26 08:38:17 +00:00
|
|
|
u8 reg, byte;
|
|
|
|
int i = 0;
|
2009-01-29 12:57:50 +00:00
|
|
|
|
2012-09-10 10:46:32 +00:00
|
|
|
pdata = twl4030_get_pdata(codec);
|
|
|
|
|
2012-12-31 10:51:46 +00:00
|
|
|
if (pdata && pdata->hs_extmute) {
|
|
|
|
if (gpio_is_valid(pdata->hs_extmute_gpio)) {
|
|
|
|
int ret;
|
|
|
|
|
|
|
|
if (!pdata->hs_extmute_gpio)
|
|
|
|
dev_warn(codec->dev,
|
|
|
|
"Extmute GPIO is 0 is this correct?\n");
|
|
|
|
|
|
|
|
ret = gpio_request_one(pdata->hs_extmute_gpio,
|
|
|
|
GPIOF_OUT_INIT_LOW,
|
|
|
|
"hs_extmute");
|
|
|
|
if (ret) {
|
|
|
|
dev_err(codec->dev,
|
|
|
|
"Failed to get hs_extmute GPIO\n");
|
|
|
|
pdata->hs_extmute_gpio = -1;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
u8 pin_mux;
|
|
|
|
|
|
|
|
/* Set TWL4030 GPIO6 as EXTMUTE signal */
|
|
|
|
twl_i2c_read_u8(TWL4030_MODULE_INTBR, &pin_mux,
|
|
|
|
TWL4030_PMBR1_REG);
|
|
|
|
pin_mux &= ~TWL4030_GPIO6_PWM0_MUTE(0x03);
|
|
|
|
pin_mux |= TWL4030_GPIO6_PWM0_MUTE(0x02);
|
|
|
|
twl_i2c_write_u8(TWL4030_MODULE_INTBR, pin_mux,
|
|
|
|
TWL4030_PMBR1_REG);
|
2012-09-10 10:46:27 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-01-03 13:27:52 +00:00
|
|
|
/* Initialize the local ctl register cache */
|
|
|
|
tw4030_init_ctl_cache(twl4030);
|
|
|
|
|
2010-05-26 08:38:17 +00:00
|
|
|
/* anti-pop when changing analog gain */
|
2014-01-03 13:27:53 +00:00
|
|
|
reg = twl4030_read(codec, TWL4030_REG_MISC_SET_1);
|
2010-05-26 08:38:17 +00:00
|
|
|
twl4030_write(codec, TWL4030_REG_MISC_SET_1,
|
2014-01-03 13:27:54 +00:00
|
|
|
reg | TWL4030_SMOOTH_ANAVOL_EN);
|
2009-01-29 12:57:50 +00:00
|
|
|
|
2010-05-26 08:38:17 +00:00
|
|
|
twl4030_write(codec, TWL4030_REG_OPTION,
|
2014-01-03 13:27:54 +00:00
|
|
|
TWL4030_ATXL1_EN | TWL4030_ATXR1_EN |
|
|
|
|
TWL4030_ARXL2_EN | TWL4030_ARXR2_EN);
|
2009-01-27 09:29:43 +00:00
|
|
|
|
2010-05-26 08:38:19 +00:00
|
|
|
/* REG_ARXR2_APGA_CTL reset according to the TRM: 0dB, DA_EN */
|
|
|
|
twl4030_write(codec, TWL4030_REG_ARXR2_APGA_CTL, 0x32);
|
|
|
|
|
2010-05-26 08:38:17 +00:00
|
|
|
/* Machine dependent setup */
|
2010-03-17 20:15:21 +00:00
|
|
|
if (!pdata)
|
2009-01-29 12:57:50 +00:00
|
|
|
return;
|
|
|
|
|
2012-09-10 10:46:31 +00:00
|
|
|
twl4030->pdata = pdata;
|
2010-05-26 08:38:17 +00:00
|
|
|
|
2014-01-03 13:27:53 +00:00
|
|
|
reg = twl4030_read(codec, TWL4030_REG_HS_POPN_SET);
|
2010-05-26 08:38:17 +00:00
|
|
|
reg &= ~TWL4030_RAMP_DELAY;
|
2010-03-17 20:15:21 +00:00
|
|
|
reg |= (pdata->ramp_delay_value << 2);
|
2014-01-03 13:27:53 +00:00
|
|
|
twl4030_write(codec, TWL4030_REG_HS_POPN_SET, reg);
|
2009-01-27 09:29:43 +00:00
|
|
|
|
|
|
|
/* initiate offset cancellation */
|
2010-05-26 08:38:17 +00:00
|
|
|
twl4030_codec_enable(codec, 1);
|
|
|
|
|
2014-01-03 13:27:53 +00:00
|
|
|
reg = twl4030_read(codec, TWL4030_REG_ANAMICL);
|
2010-05-26 08:38:17 +00:00
|
|
|
reg &= ~TWL4030_OFFSET_CNCL_SEL;
|
2010-03-17 20:15:21 +00:00
|
|
|
reg |= pdata->offset_cncl_path;
|
2009-01-27 09:29:43 +00:00
|
|
|
twl4030_write(codec, TWL4030_REG_ANAMICL,
|
2014-01-03 13:27:54 +00:00
|
|
|
reg | TWL4030_CNCL_OFFSET_START);
|
2009-01-27 09:29:43 +00:00
|
|
|
|
2010-10-25 08:34:23 +00:00
|
|
|
/*
|
|
|
|
* Wait for offset cancellation to complete.
|
|
|
|
* Since this takes a while, do not slam the i2c.
|
|
|
|
* Start polling the status after ~20ms.
|
|
|
|
*/
|
|
|
|
msleep(20);
|
2009-01-27 09:29:43 +00:00
|
|
|
do {
|
2010-10-25 08:34:23 +00:00
|
|
|
usleep_range(1000, 2000);
|
2014-01-03 13:27:53 +00:00
|
|
|
twl_set_regcache_bypass(TWL4030_MODULE_AUDIO_VOICE, true);
|
2009-12-13 20:23:33 +00:00
|
|
|
twl_i2c_read_u8(TWL4030_MODULE_AUDIO_VOICE, &byte,
|
2014-01-03 13:27:54 +00:00
|
|
|
TWL4030_REG_ANAMICL);
|
2014-01-03 13:27:53 +00:00
|
|
|
twl_set_regcache_bypass(TWL4030_MODULE_AUDIO_VOICE, false);
|
2009-01-27 09:29:43 +00:00
|
|
|
} while ((i++ < 100) &&
|
|
|
|
((byte & TWL4030_CNCL_OFFSET_START) ==
|
|
|
|
TWL4030_CNCL_OFFSET_START));
|
|
|
|
|
|
|
|
twl4030_codec_enable(codec, 0);
|
|
|
|
}
|
|
|
|
|
2010-05-26 08:38:17 +00:00
|
|
|
static void twl4030_apll_enable(struct snd_soc_codec *codec, int enable)
|
2009-01-27 09:29:43 +00:00
|
|
|
{
|
2010-05-26 08:38:17 +00:00
|
|
|
struct twl4030_priv *twl4030 = snd_soc_codec_get_drvdata(codec);
|
|
|
|
|
|
|
|
if (enable) {
|
|
|
|
twl4030->apll_enabled++;
|
|
|
|
if (twl4030->apll_enabled == 1)
|
2014-07-01 04:29:31 +00:00
|
|
|
twl4030_audio_enable_resource(
|
2011-05-31 09:02:49 +00:00
|
|
|
TWL4030_AUDIO_RES_APLL);
|
2010-05-26 08:38:17 +00:00
|
|
|
} else {
|
|
|
|
twl4030->apll_enabled--;
|
|
|
|
if (!twl4030->apll_enabled)
|
2014-07-01 04:29:31 +00:00
|
|
|
twl4030_audio_disable_resource(
|
2011-05-31 09:02:49 +00:00
|
|
|
TWL4030_AUDIO_RES_APLL);
|
2010-05-26 08:38:17 +00:00
|
|
|
}
|
2009-01-27 09:29:43 +00:00
|
|
|
}
|
|
|
|
|
2008-12-09 10:35:47 +00:00
|
|
|
/* Earpiece */
|
2009-04-22 04:13:34 +00:00
|
|
|
static const struct snd_kcontrol_new twl4030_dapm_earpiece_controls[] = {
|
|
|
|
SOC_DAPM_SINGLE("Voice", TWL4030_REG_EAR_CTL, 0, 1, 0),
|
|
|
|
SOC_DAPM_SINGLE("AudioL1", TWL4030_REG_EAR_CTL, 1, 1, 0),
|
|
|
|
SOC_DAPM_SINGLE("AudioL2", TWL4030_REG_EAR_CTL, 2, 1, 0),
|
|
|
|
SOC_DAPM_SINGLE("AudioR1", TWL4030_REG_EAR_CTL, 3, 1, 0),
|
|
|
|
};
|
2008-12-09 10:35:47 +00:00
|
|
|
|
2008-12-09 10:35:48 +00:00
|
|
|
/* PreDrive Left */
|
2009-04-22 04:13:34 +00:00
|
|
|
static const struct snd_kcontrol_new twl4030_dapm_predrivel_controls[] = {
|
|
|
|
SOC_DAPM_SINGLE("Voice", TWL4030_REG_PREDL_CTL, 0, 1, 0),
|
|
|
|
SOC_DAPM_SINGLE("AudioL1", TWL4030_REG_PREDL_CTL, 1, 1, 0),
|
|
|
|
SOC_DAPM_SINGLE("AudioL2", TWL4030_REG_PREDL_CTL, 2, 1, 0),
|
|
|
|
SOC_DAPM_SINGLE("AudioR2", TWL4030_REG_PREDL_CTL, 3, 1, 0),
|
|
|
|
};
|
2008-12-09 10:35:48 +00:00
|
|
|
|
|
|
|
/* PreDrive Right */
|
2009-04-22 04:13:34 +00:00
|
|
|
static const struct snd_kcontrol_new twl4030_dapm_predriver_controls[] = {
|
|
|
|
SOC_DAPM_SINGLE("Voice", TWL4030_REG_PREDR_CTL, 0, 1, 0),
|
|
|
|
SOC_DAPM_SINGLE("AudioR1", TWL4030_REG_PREDR_CTL, 1, 1, 0),
|
|
|
|
SOC_DAPM_SINGLE("AudioR2", TWL4030_REG_PREDR_CTL, 2, 1, 0),
|
|
|
|
SOC_DAPM_SINGLE("AudioL2", TWL4030_REG_PREDR_CTL, 3, 1, 0),
|
|
|
|
};
|
2008-12-09 10:35:48 +00:00
|
|
|
|
2008-12-09 10:35:49 +00:00
|
|
|
/* Headset Left */
|
2009-04-22 04:13:34 +00:00
|
|
|
static const struct snd_kcontrol_new twl4030_dapm_hsol_controls[] = {
|
|
|
|
SOC_DAPM_SINGLE("Voice", TWL4030_REG_HS_SEL, 0, 1, 0),
|
|
|
|
SOC_DAPM_SINGLE("AudioL1", TWL4030_REG_HS_SEL, 1, 1, 0),
|
|
|
|
SOC_DAPM_SINGLE("AudioL2", TWL4030_REG_HS_SEL, 2, 1, 0),
|
|
|
|
};
|
2008-12-09 10:35:49 +00:00
|
|
|
|
|
|
|
/* Headset Right */
|
2009-04-22 04:13:34 +00:00
|
|
|
static const struct snd_kcontrol_new twl4030_dapm_hsor_controls[] = {
|
|
|
|
SOC_DAPM_SINGLE("Voice", TWL4030_REG_HS_SEL, 3, 1, 0),
|
|
|
|
SOC_DAPM_SINGLE("AudioR1", TWL4030_REG_HS_SEL, 4, 1, 0),
|
|
|
|
SOC_DAPM_SINGLE("AudioR2", TWL4030_REG_HS_SEL, 5, 1, 0),
|
|
|
|
};
|
2008-12-09 10:35:49 +00:00
|
|
|
|
2008-12-09 10:35:50 +00:00
|
|
|
/* Carkit Left */
|
2009-04-22 04:13:34 +00:00
|
|
|
static const struct snd_kcontrol_new twl4030_dapm_carkitl_controls[] = {
|
|
|
|
SOC_DAPM_SINGLE("Voice", TWL4030_REG_PRECKL_CTL, 0, 1, 0),
|
|
|
|
SOC_DAPM_SINGLE("AudioL1", TWL4030_REG_PRECKL_CTL, 1, 1, 0),
|
|
|
|
SOC_DAPM_SINGLE("AudioL2", TWL4030_REG_PRECKL_CTL, 2, 1, 0),
|
|
|
|
};
|
2008-12-09 10:35:50 +00:00
|
|
|
|
|
|
|
/* Carkit Right */
|
2009-04-22 04:13:34 +00:00
|
|
|
static const struct snd_kcontrol_new twl4030_dapm_carkitr_controls[] = {
|
|
|
|
SOC_DAPM_SINGLE("Voice", TWL4030_REG_PRECKR_CTL, 0, 1, 0),
|
|
|
|
SOC_DAPM_SINGLE("AudioR1", TWL4030_REG_PRECKR_CTL, 1, 1, 0),
|
|
|
|
SOC_DAPM_SINGLE("AudioR2", TWL4030_REG_PRECKR_CTL, 2, 1, 0),
|
|
|
|
};
|
2008-12-09 10:35:50 +00:00
|
|
|
|
2008-12-09 10:35:51 +00:00
|
|
|
/* Handsfree Left */
|
|
|
|
static const char *twl4030_handsfreel_texts[] =
|
2009-04-22 04:13:34 +00:00
|
|
|
{"Voice", "AudioL1", "AudioL2", "AudioR2"};
|
2008-12-09 10:35:51 +00:00
|
|
|
|
2014-02-18 09:28:25 +00:00
|
|
|
static SOC_ENUM_SINGLE_DECL(twl4030_handsfreel_enum,
|
|
|
|
TWL4030_REG_HFL_CTL, 0,
|
|
|
|
twl4030_handsfreel_texts);
|
2008-12-09 10:35:51 +00:00
|
|
|
|
|
|
|
static const struct snd_kcontrol_new twl4030_dapm_handsfreel_control =
|
|
|
|
SOC_DAPM_ENUM("Route", twl4030_handsfreel_enum);
|
|
|
|
|
2009-05-25 08:12:13 +00:00
|
|
|
/* Handsfree Left virtual mute */
|
|
|
|
static const struct snd_kcontrol_new twl4030_dapm_handsfreelmute_control =
|
2013-10-06 11:43:50 +00:00
|
|
|
SOC_DAPM_SINGLE_VIRT("Switch", 1);
|
2009-05-25 08:12:13 +00:00
|
|
|
|
2008-12-09 10:35:51 +00:00
|
|
|
/* Handsfree Right */
|
|
|
|
static const char *twl4030_handsfreer_texts[] =
|
2009-04-22 04:13:34 +00:00
|
|
|
{"Voice", "AudioR1", "AudioR2", "AudioL2"};
|
2008-12-09 10:35:51 +00:00
|
|
|
|
2014-02-18 09:28:25 +00:00
|
|
|
static SOC_ENUM_SINGLE_DECL(twl4030_handsfreer_enum,
|
|
|
|
TWL4030_REG_HFR_CTL, 0,
|
|
|
|
twl4030_handsfreer_texts);
|
2008-12-09 10:35:51 +00:00
|
|
|
|
|
|
|
static const struct snd_kcontrol_new twl4030_dapm_handsfreer_control =
|
|
|
|
SOC_DAPM_ENUM("Route", twl4030_handsfreer_enum);
|
|
|
|
|
2009-05-25 08:12:13 +00:00
|
|
|
/* Handsfree Right virtual mute */
|
|
|
|
static const struct snd_kcontrol_new twl4030_dapm_handsfreermute_control =
|
2013-10-06 11:43:50 +00:00
|
|
|
SOC_DAPM_SINGLE_VIRT("Switch", 1);
|
2009-05-25 08:12:13 +00:00
|
|
|
|
2009-05-05 05:55:47 +00:00
|
|
|
/* Vibra */
|
|
|
|
/* Vibra audio path selection */
|
|
|
|
static const char *twl4030_vibra_texts[] =
|
|
|
|
{"AudioL1", "AudioR1", "AudioL2", "AudioR2"};
|
|
|
|
|
2014-02-18 09:28:25 +00:00
|
|
|
static SOC_ENUM_SINGLE_DECL(twl4030_vibra_enum,
|
|
|
|
TWL4030_REG_VIBRA_CTL, 2,
|
|
|
|
twl4030_vibra_texts);
|
2009-05-05 05:55:47 +00:00
|
|
|
|
|
|
|
static const struct snd_kcontrol_new twl4030_dapm_vibra_control =
|
|
|
|
SOC_DAPM_ENUM("Route", twl4030_vibra_enum);
|
|
|
|
|
|
|
|
/* Vibra path selection: local vibrator (PWM) or audio driven */
|
|
|
|
static const char *twl4030_vibrapath_texts[] =
|
|
|
|
{"Local vibrator", "Audio"};
|
|
|
|
|
2014-02-18 09:28:25 +00:00
|
|
|
static SOC_ENUM_SINGLE_DECL(twl4030_vibrapath_enum,
|
|
|
|
TWL4030_REG_VIBRA_CTL, 4,
|
|
|
|
twl4030_vibrapath_texts);
|
2009-05-05 05:55:47 +00:00
|
|
|
|
|
|
|
static const struct snd_kcontrol_new twl4030_dapm_vibrapath_control =
|
|
|
|
SOC_DAPM_ENUM("Route", twl4030_vibrapath_enum);
|
|
|
|
|
ASoC: TWL4030: DAPM based capture implementation
This patch adds DAPM implementaion for the capture path
on twlx030.
TWL has two physical ADC and two digital microphone (stereo) connections.
The CPU interface has four microphone channels.
For simplicity the microphone channel paths are named as:
TX1 (Left/Right) - when using i2s mode, only the TX1 data is valid
TX2 (Left/Right)
Input routing (simplified version):
There is two levels of mux settings for TWL in input path:
Analog input mux:
ADCL <- {Off, Main mic, Headset mic, AUXL, Carkit mic}
ADCR <- {Off, Sub mic, AUXR}
Analog/Digital mux:
TX1 Analog mode:
TX1L <- ADCL
TX1R <- ADCR
TX1 Digital mode:
TX1L <- Digimic0 (Left)
TX1R <- Digimic0 (Right)
TX2 Analog mode:
TX2L <- ADCL
TX2R <- ADCR
TX2 Digital mode:
TX2L <- Digimic1 (Left)
TX2R <- Digimic1 (Right)
The patch provides the following user controls for the capture path:
Mux settings:
"TX1 Capture Route": {Analog, Digimic0}
"TX2 Capture Route": {Analog, Digimic1}
"Analog Left Capture Route": {Off, Main Mic, Headset Mic, AUXL, Carkit Mic}
"Analog Right Capture Route": {Off, Sub Mic, AUXR}
Volume/Gain controls:
"TX1 Digital Capture Volume": Stereo gain control for TX1 path
"TX2 Digital Capture Volume": Stereo gain control for TX2 path
"Analog Capture Volume": Stereo gain control for the analog path only
Important things for the board files:
Microphone bias:
"Mic Bias 1": Bias for Main mic or for digimic0 (analog or digital path)
"Mic Bias 2": Bias for Sub mic or for digimic1 (analog or digital path)
"Headset Mic Bias": Bias for Headset mic
When the routing configured correctly only the needed components will be
powered/enabled.
Signed-off-by: Peter Ujfalusi <peter.ujfalusi@nokia.com>
Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
2008-12-31 08:08:38 +00:00
|
|
|
/* Left analog microphone selection */
|
2009-05-11 11:36:08 +00:00
|
|
|
static const struct snd_kcontrol_new twl4030_dapm_analoglmic_controls[] = {
|
2009-08-14 05:44:00 +00:00
|
|
|
SOC_DAPM_SINGLE("Main Mic Capture Switch",
|
|
|
|
TWL4030_REG_ANAMICL, 0, 1, 0),
|
|
|
|
SOC_DAPM_SINGLE("Headset Mic Capture Switch",
|
|
|
|
TWL4030_REG_ANAMICL, 1, 1, 0),
|
|
|
|
SOC_DAPM_SINGLE("AUXL Capture Switch",
|
|
|
|
TWL4030_REG_ANAMICL, 2, 1, 0),
|
|
|
|
SOC_DAPM_SINGLE("Carkit Mic Capture Switch",
|
|
|
|
TWL4030_REG_ANAMICL, 3, 1, 0),
|
2009-05-11 11:36:08 +00:00
|
|
|
};
|
ASoC: TWL4030: DAPM based capture implementation
This patch adds DAPM implementaion for the capture path
on twlx030.
TWL has two physical ADC and two digital microphone (stereo) connections.
The CPU interface has four microphone channels.
For simplicity the microphone channel paths are named as:
TX1 (Left/Right) - when using i2s mode, only the TX1 data is valid
TX2 (Left/Right)
Input routing (simplified version):
There is two levels of mux settings for TWL in input path:
Analog input mux:
ADCL <- {Off, Main mic, Headset mic, AUXL, Carkit mic}
ADCR <- {Off, Sub mic, AUXR}
Analog/Digital mux:
TX1 Analog mode:
TX1L <- ADCL
TX1R <- ADCR
TX1 Digital mode:
TX1L <- Digimic0 (Left)
TX1R <- Digimic0 (Right)
TX2 Analog mode:
TX2L <- ADCL
TX2R <- ADCR
TX2 Digital mode:
TX2L <- Digimic1 (Left)
TX2R <- Digimic1 (Right)
The patch provides the following user controls for the capture path:
Mux settings:
"TX1 Capture Route": {Analog, Digimic0}
"TX2 Capture Route": {Analog, Digimic1}
"Analog Left Capture Route": {Off, Main Mic, Headset Mic, AUXL, Carkit Mic}
"Analog Right Capture Route": {Off, Sub Mic, AUXR}
Volume/Gain controls:
"TX1 Digital Capture Volume": Stereo gain control for TX1 path
"TX2 Digital Capture Volume": Stereo gain control for TX2 path
"Analog Capture Volume": Stereo gain control for the analog path only
Important things for the board files:
Microphone bias:
"Mic Bias 1": Bias for Main mic or for digimic0 (analog or digital path)
"Mic Bias 2": Bias for Sub mic or for digimic1 (analog or digital path)
"Headset Mic Bias": Bias for Headset mic
When the routing configured correctly only the needed components will be
powered/enabled.
Signed-off-by: Peter Ujfalusi <peter.ujfalusi@nokia.com>
Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
2008-12-31 08:08:38 +00:00
|
|
|
|
|
|
|
/* Right analog microphone selection */
|
2009-05-11 11:36:08 +00:00
|
|
|
static const struct snd_kcontrol_new twl4030_dapm_analogrmic_controls[] = {
|
2009-08-14 05:44:00 +00:00
|
|
|
SOC_DAPM_SINGLE("Sub Mic Capture Switch", TWL4030_REG_ANAMICR, 0, 1, 0),
|
|
|
|
SOC_DAPM_SINGLE("AUXR Capture Switch", TWL4030_REG_ANAMICR, 2, 1, 0),
|
2009-05-11 11:36:08 +00:00
|
|
|
};
|
ASoC: TWL4030: DAPM based capture implementation
This patch adds DAPM implementaion for the capture path
on twlx030.
TWL has two physical ADC and two digital microphone (stereo) connections.
The CPU interface has four microphone channels.
For simplicity the microphone channel paths are named as:
TX1 (Left/Right) - when using i2s mode, only the TX1 data is valid
TX2 (Left/Right)
Input routing (simplified version):
There is two levels of mux settings for TWL in input path:
Analog input mux:
ADCL <- {Off, Main mic, Headset mic, AUXL, Carkit mic}
ADCR <- {Off, Sub mic, AUXR}
Analog/Digital mux:
TX1 Analog mode:
TX1L <- ADCL
TX1R <- ADCR
TX1 Digital mode:
TX1L <- Digimic0 (Left)
TX1R <- Digimic0 (Right)
TX2 Analog mode:
TX2L <- ADCL
TX2R <- ADCR
TX2 Digital mode:
TX2L <- Digimic1 (Left)
TX2R <- Digimic1 (Right)
The patch provides the following user controls for the capture path:
Mux settings:
"TX1 Capture Route": {Analog, Digimic0}
"TX2 Capture Route": {Analog, Digimic1}
"Analog Left Capture Route": {Off, Main Mic, Headset Mic, AUXL, Carkit Mic}
"Analog Right Capture Route": {Off, Sub Mic, AUXR}
Volume/Gain controls:
"TX1 Digital Capture Volume": Stereo gain control for TX1 path
"TX2 Digital Capture Volume": Stereo gain control for TX2 path
"Analog Capture Volume": Stereo gain control for the analog path only
Important things for the board files:
Microphone bias:
"Mic Bias 1": Bias for Main mic or for digimic0 (analog or digital path)
"Mic Bias 2": Bias for Sub mic or for digimic1 (analog or digital path)
"Headset Mic Bias": Bias for Headset mic
When the routing configured correctly only the needed components will be
powered/enabled.
Signed-off-by: Peter Ujfalusi <peter.ujfalusi@nokia.com>
Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
2008-12-31 08:08:38 +00:00
|
|
|
|
|
|
|
/* TX1 L/R Analog/Digital microphone selection */
|
|
|
|
static const char *twl4030_micpathtx1_texts[] =
|
|
|
|
{"Analog", "Digimic0"};
|
|
|
|
|
2014-02-18 09:28:25 +00:00
|
|
|
static SOC_ENUM_SINGLE_DECL(twl4030_micpathtx1_enum,
|
|
|
|
TWL4030_REG_ADCMICSEL, 0,
|
|
|
|
twl4030_micpathtx1_texts);
|
ASoC: TWL4030: DAPM based capture implementation
This patch adds DAPM implementaion for the capture path
on twlx030.
TWL has two physical ADC and two digital microphone (stereo) connections.
The CPU interface has four microphone channels.
For simplicity the microphone channel paths are named as:
TX1 (Left/Right) - when using i2s mode, only the TX1 data is valid
TX2 (Left/Right)
Input routing (simplified version):
There is two levels of mux settings for TWL in input path:
Analog input mux:
ADCL <- {Off, Main mic, Headset mic, AUXL, Carkit mic}
ADCR <- {Off, Sub mic, AUXR}
Analog/Digital mux:
TX1 Analog mode:
TX1L <- ADCL
TX1R <- ADCR
TX1 Digital mode:
TX1L <- Digimic0 (Left)
TX1R <- Digimic0 (Right)
TX2 Analog mode:
TX2L <- ADCL
TX2R <- ADCR
TX2 Digital mode:
TX2L <- Digimic1 (Left)
TX2R <- Digimic1 (Right)
The patch provides the following user controls for the capture path:
Mux settings:
"TX1 Capture Route": {Analog, Digimic0}
"TX2 Capture Route": {Analog, Digimic1}
"Analog Left Capture Route": {Off, Main Mic, Headset Mic, AUXL, Carkit Mic}
"Analog Right Capture Route": {Off, Sub Mic, AUXR}
Volume/Gain controls:
"TX1 Digital Capture Volume": Stereo gain control for TX1 path
"TX2 Digital Capture Volume": Stereo gain control for TX2 path
"Analog Capture Volume": Stereo gain control for the analog path only
Important things for the board files:
Microphone bias:
"Mic Bias 1": Bias for Main mic or for digimic0 (analog or digital path)
"Mic Bias 2": Bias for Sub mic or for digimic1 (analog or digital path)
"Headset Mic Bias": Bias for Headset mic
When the routing configured correctly only the needed components will be
powered/enabled.
Signed-off-by: Peter Ujfalusi <peter.ujfalusi@nokia.com>
Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
2008-12-31 08:08:38 +00:00
|
|
|
|
|
|
|
static const struct snd_kcontrol_new twl4030_dapm_micpathtx1_control =
|
|
|
|
SOC_DAPM_ENUM("Route", twl4030_micpathtx1_enum);
|
|
|
|
|
|
|
|
/* TX2 L/R Analog/Digital microphone selection */
|
|
|
|
static const char *twl4030_micpathtx2_texts[] =
|
|
|
|
{"Analog", "Digimic1"};
|
|
|
|
|
2014-02-18 09:28:25 +00:00
|
|
|
static SOC_ENUM_SINGLE_DECL(twl4030_micpathtx2_enum,
|
|
|
|
TWL4030_REG_ADCMICSEL, 2,
|
|
|
|
twl4030_micpathtx2_texts);
|
ASoC: TWL4030: DAPM based capture implementation
This patch adds DAPM implementaion for the capture path
on twlx030.
TWL has two physical ADC and two digital microphone (stereo) connections.
The CPU interface has four microphone channels.
For simplicity the microphone channel paths are named as:
TX1 (Left/Right) - when using i2s mode, only the TX1 data is valid
TX2 (Left/Right)
Input routing (simplified version):
There is two levels of mux settings for TWL in input path:
Analog input mux:
ADCL <- {Off, Main mic, Headset mic, AUXL, Carkit mic}
ADCR <- {Off, Sub mic, AUXR}
Analog/Digital mux:
TX1 Analog mode:
TX1L <- ADCL
TX1R <- ADCR
TX1 Digital mode:
TX1L <- Digimic0 (Left)
TX1R <- Digimic0 (Right)
TX2 Analog mode:
TX2L <- ADCL
TX2R <- ADCR
TX2 Digital mode:
TX2L <- Digimic1 (Left)
TX2R <- Digimic1 (Right)
The patch provides the following user controls for the capture path:
Mux settings:
"TX1 Capture Route": {Analog, Digimic0}
"TX2 Capture Route": {Analog, Digimic1}
"Analog Left Capture Route": {Off, Main Mic, Headset Mic, AUXL, Carkit Mic}
"Analog Right Capture Route": {Off, Sub Mic, AUXR}
Volume/Gain controls:
"TX1 Digital Capture Volume": Stereo gain control for TX1 path
"TX2 Digital Capture Volume": Stereo gain control for TX2 path
"Analog Capture Volume": Stereo gain control for the analog path only
Important things for the board files:
Microphone bias:
"Mic Bias 1": Bias for Main mic or for digimic0 (analog or digital path)
"Mic Bias 2": Bias for Sub mic or for digimic1 (analog or digital path)
"Headset Mic Bias": Bias for Headset mic
When the routing configured correctly only the needed components will be
powered/enabled.
Signed-off-by: Peter Ujfalusi <peter.ujfalusi@nokia.com>
Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
2008-12-31 08:08:38 +00:00
|
|
|
|
|
|
|
static const struct snd_kcontrol_new twl4030_dapm_micpathtx2_control =
|
|
|
|
SOC_DAPM_ENUM("Route", twl4030_micpathtx2_enum);
|
|
|
|
|
2009-01-29 12:57:50 +00:00
|
|
|
/* Analog bypass for AudioR1 */
|
|
|
|
static const struct snd_kcontrol_new twl4030_dapm_abypassr1_control =
|
|
|
|
SOC_DAPM_SINGLE("Switch", TWL4030_REG_ARXR1_APGA_CTL, 2, 1, 0);
|
|
|
|
|
|
|
|
/* Analog bypass for AudioL1 */
|
|
|
|
static const struct snd_kcontrol_new twl4030_dapm_abypassl1_control =
|
|
|
|
SOC_DAPM_SINGLE("Switch", TWL4030_REG_ARXL1_APGA_CTL, 2, 1, 0);
|
|
|
|
|
|
|
|
/* Analog bypass for AudioR2 */
|
|
|
|
static const struct snd_kcontrol_new twl4030_dapm_abypassr2_control =
|
|
|
|
SOC_DAPM_SINGLE("Switch", TWL4030_REG_ARXR2_APGA_CTL, 2, 1, 0);
|
|
|
|
|
|
|
|
/* Analog bypass for AudioL2 */
|
|
|
|
static const struct snd_kcontrol_new twl4030_dapm_abypassl2_control =
|
|
|
|
SOC_DAPM_SINGLE("Switch", TWL4030_REG_ARXL2_APGA_CTL, 2, 1, 0);
|
|
|
|
|
2009-05-01 02:47:22 +00:00
|
|
|
/* Analog bypass for Voice */
|
|
|
|
static const struct snd_kcontrol_new twl4030_dapm_abypassv_control =
|
|
|
|
SOC_DAPM_SINGLE("Switch", TWL4030_REG_VDL_APGA_CTL, 2, 1, 0);
|
|
|
|
|
2010-07-12 08:50:06 +00:00
|
|
|
/* Digital bypass gain, mute instead of -30dB */
|
2009-02-18 12:39:05 +00:00
|
|
|
static const unsigned int twl4030_dapm_dbypass_tlv[] = {
|
2010-07-12 08:50:06 +00:00
|
|
|
TLV_DB_RANGE_HEAD(3),
|
|
|
|
0, 1, TLV_DB_SCALE_ITEM(-3000, 600, 1),
|
|
|
|
2, 3, TLV_DB_SCALE_ITEM(-2400, 0, 0),
|
2009-02-18 12:39:05 +00:00
|
|
|
4, 7, TLV_DB_SCALE_ITEM(-1800, 600, 0),
|
|
|
|
};
|
|
|
|
|
|
|
|
/* Digital bypass left (TX1L -> RX2L) */
|
|
|
|
static const struct snd_kcontrol_new twl4030_dapm_dbypassl_control =
|
|
|
|
SOC_DAPM_SINGLE_TLV("Volume",
|
|
|
|
TWL4030_REG_ATX2ARXPGA, 3, 7, 0,
|
|
|
|
twl4030_dapm_dbypass_tlv);
|
|
|
|
|
|
|
|
/* Digital bypass right (TX1R -> RX2R) */
|
|
|
|
static const struct snd_kcontrol_new twl4030_dapm_dbypassr_control =
|
|
|
|
SOC_DAPM_SINGLE_TLV("Volume",
|
|
|
|
TWL4030_REG_ATX2ARXPGA, 0, 7, 0,
|
|
|
|
twl4030_dapm_dbypass_tlv);
|
|
|
|
|
2009-05-01 02:48:08 +00:00
|
|
|
/*
|
|
|
|
* Voice Sidetone GAIN volume control:
|
|
|
|
* from -51 to -10 dB in 1 dB steps (mute instead of -51 dB)
|
|
|
|
*/
|
|
|
|
static DECLARE_TLV_DB_SCALE(twl4030_dapm_dbypassv_tlv, -5100, 100, 1);
|
|
|
|
|
|
|
|
/* Digital bypass voice: sidetone (VUL -> VDL)*/
|
|
|
|
static const struct snd_kcontrol_new twl4030_dapm_dbypassv_control =
|
|
|
|
SOC_DAPM_SINGLE_TLV("Volume",
|
|
|
|
TWL4030_REG_VSTPGA, 0, 0x29, 0,
|
|
|
|
twl4030_dapm_dbypassv_tlv);
|
|
|
|
|
2009-08-13 12:59:34 +00:00
|
|
|
/*
|
|
|
|
* Output PGA builder:
|
|
|
|
* Handle the muting and unmuting of the given output (turning off the
|
|
|
|
* amplifier associated with the output pin)
|
ASoC: TWL4030: PM fix for output amplifiers
Gain controls on outputs affect the power consumption
when the gain is set to non 0 value.
Outputs with amps have one register to configure the
routing and the gain:
PREDL_CTL (0x25):
bit 0: Voice enable
bit 1: Audio L1 enable
bit 2: Audio L2 enable
bit 3: Audio R2 enable
bit 4-5: Gain (0x0 - power down, 0x1 - 6dB, 0x2 - 0dB, 0x3 - -6dB)
bit 0 - 3: is handled in DAPM domain (DAPM_MIXER)
bit 4 - 5: has simple volume control
If there is no audio activity (BIAS_STANDBY), and
user changes the volume, than the output amplifier will
be enabled.
If the user changes the routing (but the codec remains in
BIAS_STANDBY), than the cached gain value also be written
to the register, which enables the amplifier.
The existing workaround for this is to have virtual
PGAs associated with the outputs, and whit DAPM PMD
the gain on the output will be forced to 0 (off) by
bypassing the regcache.
This failed to disable the amplifiers in several
scenario (as mentioned above).
Also if the codec is in BIAS_ON state, and user modifies
a volume control, which path is actually not enabled, than
that amplifier will be enabled as well, but it will
be not turned off, since there is no DAPM path, which
would make mute it.
To prevent amps being enabled, when they are not
needed, introduce the following workaround:
Track the state of each of this type of output.
In twl4030_write only allow actual write, when the
given output is enabled, otherwise only update
the reg_cache.
The PGA event handlers on power up will write the cached
value to the chip (restoring gain, routing selection).
On power down 0 is written to the register (disabling
the amp, and also just in case clearing the routing).
Signed-off-by: Peter Ujfalusi <peter.ujfalusi@nokia.com>
Acked-by: Liam Girdwood <lrg@slimlogic.co.uk>
Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
2010-03-22 15:46:37 +00:00
|
|
|
* On mute bypass the reg_cache and write 0 to the register
|
|
|
|
* On unmute: restore the register content from the reg_cache
|
2009-08-13 12:59:34 +00:00
|
|
|
* Outputs handled in this way: Earpiece, PreDrivL/R, CarkitL/R
|
|
|
|
*/
|
|
|
|
#define TWL4030_OUTPUT_PGA(pin_name, reg, mask) \
|
|
|
|
static int pin_name##pga_event(struct snd_soc_dapm_widget *w, \
|
2014-01-03 13:27:54 +00:00
|
|
|
struct snd_kcontrol *kcontrol, int event) \
|
2009-08-13 12:59:34 +00:00
|
|
|
{ \
|
2015-01-15 11:52:06 +00:00
|
|
|
struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm); \
|
|
|
|
struct twl4030_priv *twl4030 = snd_soc_codec_get_drvdata(codec); \
|
2009-08-13 12:59:34 +00:00
|
|
|
\
|
|
|
|
switch (event) { \
|
|
|
|
case SND_SOC_DAPM_POST_PMU: \
|
ASoC: TWL4030: PM fix for output amplifiers
Gain controls on outputs affect the power consumption
when the gain is set to non 0 value.
Outputs with amps have one register to configure the
routing and the gain:
PREDL_CTL (0x25):
bit 0: Voice enable
bit 1: Audio L1 enable
bit 2: Audio L2 enable
bit 3: Audio R2 enable
bit 4-5: Gain (0x0 - power down, 0x1 - 6dB, 0x2 - 0dB, 0x3 - -6dB)
bit 0 - 3: is handled in DAPM domain (DAPM_MIXER)
bit 4 - 5: has simple volume control
If there is no audio activity (BIAS_STANDBY), and
user changes the volume, than the output amplifier will
be enabled.
If the user changes the routing (but the codec remains in
BIAS_STANDBY), than the cached gain value also be written
to the register, which enables the amplifier.
The existing workaround for this is to have virtual
PGAs associated with the outputs, and whit DAPM PMD
the gain on the output will be forced to 0 (off) by
bypassing the regcache.
This failed to disable the amplifiers in several
scenario (as mentioned above).
Also if the codec is in BIAS_ON state, and user modifies
a volume control, which path is actually not enabled, than
that amplifier will be enabled as well, but it will
be not turned off, since there is no DAPM path, which
would make mute it.
To prevent amps being enabled, when they are not
needed, introduce the following workaround:
Track the state of each of this type of output.
In twl4030_write only allow actual write, when the
given output is enabled, otherwise only update
the reg_cache.
The PGA event handlers on power up will write the cached
value to the chip (restoring gain, routing selection).
On power down 0 is written to the register (disabling
the amp, and also just in case clearing the routing).
Signed-off-by: Peter Ujfalusi <peter.ujfalusi@nokia.com>
Acked-by: Liam Girdwood <lrg@slimlogic.co.uk>
Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
2010-03-22 15:46:37 +00:00
|
|
|
twl4030->pin_name##_enabled = 1; \
|
2015-01-15 11:52:06 +00:00
|
|
|
twl4030_write(codec, reg, twl4030_read(codec, reg)); \
|
2009-08-13 12:59:34 +00:00
|
|
|
break; \
|
|
|
|
case SND_SOC_DAPM_POST_PMD: \
|
ASoC: TWL4030: PM fix for output amplifiers
Gain controls on outputs affect the power consumption
when the gain is set to non 0 value.
Outputs with amps have one register to configure the
routing and the gain:
PREDL_CTL (0x25):
bit 0: Voice enable
bit 1: Audio L1 enable
bit 2: Audio L2 enable
bit 3: Audio R2 enable
bit 4-5: Gain (0x0 - power down, 0x1 - 6dB, 0x2 - 0dB, 0x3 - -6dB)
bit 0 - 3: is handled in DAPM domain (DAPM_MIXER)
bit 4 - 5: has simple volume control
If there is no audio activity (BIAS_STANDBY), and
user changes the volume, than the output amplifier will
be enabled.
If the user changes the routing (but the codec remains in
BIAS_STANDBY), than the cached gain value also be written
to the register, which enables the amplifier.
The existing workaround for this is to have virtual
PGAs associated with the outputs, and whit DAPM PMD
the gain on the output will be forced to 0 (off) by
bypassing the regcache.
This failed to disable the amplifiers in several
scenario (as mentioned above).
Also if the codec is in BIAS_ON state, and user modifies
a volume control, which path is actually not enabled, than
that amplifier will be enabled as well, but it will
be not turned off, since there is no DAPM path, which
would make mute it.
To prevent amps being enabled, when they are not
needed, introduce the following workaround:
Track the state of each of this type of output.
In twl4030_write only allow actual write, when the
given output is enabled, otherwise only update
the reg_cache.
The PGA event handlers on power up will write the cached
value to the chip (restoring gain, routing selection).
On power down 0 is written to the register (disabling
the amp, and also just in case clearing the routing).
Signed-off-by: Peter Ujfalusi <peter.ujfalusi@nokia.com>
Acked-by: Liam Girdwood <lrg@slimlogic.co.uk>
Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
2010-03-22 15:46:37 +00:00
|
|
|
twl4030->pin_name##_enabled = 0; \
|
2014-01-03 13:27:54 +00:00
|
|
|
twl_i2c_write_u8(TWL4030_MODULE_AUDIO_VOICE, 0, reg); \
|
2009-08-13 12:59:34 +00:00
|
|
|
break; \
|
|
|
|
} \
|
|
|
|
return 0; \
|
|
|
|
}
|
|
|
|
|
|
|
|
TWL4030_OUTPUT_PGA(earpiece, TWL4030_REG_EAR_CTL, TWL4030_EAR_GAIN);
|
|
|
|
TWL4030_OUTPUT_PGA(predrivel, TWL4030_REG_PREDL_CTL, TWL4030_PREDL_GAIN);
|
|
|
|
TWL4030_OUTPUT_PGA(predriver, TWL4030_REG_PREDR_CTL, TWL4030_PREDR_GAIN);
|
|
|
|
TWL4030_OUTPUT_PGA(carkitl, TWL4030_REG_PRECKL_CTL, TWL4030_PRECKL_GAIN);
|
|
|
|
TWL4030_OUTPUT_PGA(carkitr, TWL4030_REG_PRECKR_CTL, TWL4030_PRECKR_GAIN);
|
|
|
|
|
2009-05-25 08:12:11 +00:00
|
|
|
static void handsfree_ramp(struct snd_soc_codec *codec, int reg, int ramp)
|
2008-12-11 15:28:10 +00:00
|
|
|
{
|
|
|
|
unsigned char hs_ctl;
|
|
|
|
|
2014-01-03 13:27:53 +00:00
|
|
|
hs_ctl = twl4030_read(codec, reg);
|
2008-12-11 15:28:10 +00:00
|
|
|
|
2009-05-25 08:12:11 +00:00
|
|
|
if (ramp) {
|
|
|
|
/* HF ramp-up */
|
|
|
|
hs_ctl |= TWL4030_HF_CTL_REF_EN;
|
|
|
|
twl4030_write(codec, reg, hs_ctl);
|
|
|
|
udelay(10);
|
2008-12-11 15:28:10 +00:00
|
|
|
hs_ctl |= TWL4030_HF_CTL_RAMP_EN;
|
2009-05-25 08:12:11 +00:00
|
|
|
twl4030_write(codec, reg, hs_ctl);
|
|
|
|
udelay(40);
|
2008-12-11 15:28:10 +00:00
|
|
|
hs_ctl |= TWL4030_HF_CTL_LOOP_EN;
|
|
|
|
hs_ctl |= TWL4030_HF_CTL_HB_EN;
|
2009-05-25 08:12:11 +00:00
|
|
|
twl4030_write(codec, reg, hs_ctl);
|
2008-12-11 15:28:10 +00:00
|
|
|
} else {
|
2009-05-25 08:12:11 +00:00
|
|
|
/* HF ramp-down */
|
|
|
|
hs_ctl &= ~TWL4030_HF_CTL_LOOP_EN;
|
|
|
|
hs_ctl &= ~TWL4030_HF_CTL_HB_EN;
|
|
|
|
twl4030_write(codec, reg, hs_ctl);
|
|
|
|
hs_ctl &= ~TWL4030_HF_CTL_RAMP_EN;
|
|
|
|
twl4030_write(codec, reg, hs_ctl);
|
|
|
|
udelay(40);
|
|
|
|
hs_ctl &= ~TWL4030_HF_CTL_REF_EN;
|
|
|
|
twl4030_write(codec, reg, hs_ctl);
|
2008-12-11 15:28:10 +00:00
|
|
|
}
|
2009-05-25 08:12:11 +00:00
|
|
|
}
|
2008-12-11 15:28:10 +00:00
|
|
|
|
2009-05-25 08:12:11 +00:00
|
|
|
static int handsfreelpga_event(struct snd_soc_dapm_widget *w,
|
2014-01-03 13:27:54 +00:00
|
|
|
struct snd_kcontrol *kcontrol, int event)
|
2009-05-25 08:12:11 +00:00
|
|
|
{
|
2015-01-15 11:52:06 +00:00
|
|
|
struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm);
|
|
|
|
|
2009-05-25 08:12:11 +00:00
|
|
|
switch (event) {
|
|
|
|
case SND_SOC_DAPM_POST_PMU:
|
2015-01-15 11:52:06 +00:00
|
|
|
handsfree_ramp(codec, TWL4030_REG_HFL_CTL, 1);
|
2009-05-25 08:12:11 +00:00
|
|
|
break;
|
|
|
|
case SND_SOC_DAPM_POST_PMD:
|
2015-01-15 11:52:06 +00:00
|
|
|
handsfree_ramp(codec, TWL4030_REG_HFL_CTL, 0);
|
2009-05-25 08:12:11 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int handsfreerpga_event(struct snd_soc_dapm_widget *w,
|
2014-01-03 13:27:54 +00:00
|
|
|
struct snd_kcontrol *kcontrol, int event)
|
2009-05-25 08:12:11 +00:00
|
|
|
{
|
2015-01-15 11:52:06 +00:00
|
|
|
struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm);
|
|
|
|
|
2009-05-25 08:12:11 +00:00
|
|
|
switch (event) {
|
|
|
|
case SND_SOC_DAPM_POST_PMU:
|
2015-01-15 11:52:06 +00:00
|
|
|
handsfree_ramp(codec, TWL4030_REG_HFR_CTL, 1);
|
2009-05-25 08:12:11 +00:00
|
|
|
break;
|
|
|
|
case SND_SOC_DAPM_POST_PMD:
|
2015-01-15 11:52:06 +00:00
|
|
|
handsfree_ramp(codec, TWL4030_REG_HFR_CTL, 0);
|
2009-05-25 08:12:11 +00:00
|
|
|
break;
|
|
|
|
}
|
2008-12-11 15:28:10 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2009-10-29 09:58:09 +00:00
|
|
|
static int vibramux_event(struct snd_soc_dapm_widget *w,
|
2014-01-03 13:27:54 +00:00
|
|
|
struct snd_kcontrol *kcontrol, int event)
|
2009-10-29 09:58:09 +00:00
|
|
|
{
|
2015-01-15 11:52:06 +00:00
|
|
|
struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm);
|
|
|
|
|
|
|
|
twl4030_write(codec, TWL4030_REG_VIBRA_SET, 0xff);
|
2009-10-29 09:58:09 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2009-10-29 09:58:10 +00:00
|
|
|
static int apll_event(struct snd_soc_dapm_widget *w,
|
2014-01-03 13:27:54 +00:00
|
|
|
struct snd_kcontrol *kcontrol, int event)
|
2009-10-29 09:58:10 +00:00
|
|
|
{
|
2015-01-15 11:52:06 +00:00
|
|
|
struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm);
|
|
|
|
|
2009-10-29 09:58:10 +00:00
|
|
|
switch (event) {
|
|
|
|
case SND_SOC_DAPM_PRE_PMU:
|
2015-01-15 11:52:06 +00:00
|
|
|
twl4030_apll_enable(codec, 1);
|
2009-10-29 09:58:10 +00:00
|
|
|
break;
|
|
|
|
case SND_SOC_DAPM_POST_PMD:
|
2015-01-15 11:52:06 +00:00
|
|
|
twl4030_apll_enable(codec, 0);
|
2009-10-29 09:58:10 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2010-04-29 07:58:08 +00:00
|
|
|
static int aif_event(struct snd_soc_dapm_widget *w,
|
2014-01-03 13:27:54 +00:00
|
|
|
struct snd_kcontrol *kcontrol, int event)
|
2010-04-29 07:58:08 +00:00
|
|
|
{
|
2015-01-15 11:52:06 +00:00
|
|
|
struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm);
|
2010-04-29 07:58:08 +00:00
|
|
|
u8 audio_if;
|
|
|
|
|
2015-01-15 11:52:06 +00:00
|
|
|
audio_if = twl4030_read(codec, TWL4030_REG_AUDIO_IF);
|
2010-04-29 07:58:08 +00:00
|
|
|
switch (event) {
|
|
|
|
case SND_SOC_DAPM_PRE_PMU:
|
|
|
|
/* Enable AIF */
|
|
|
|
/* enable the PLL before we use it to clock the DAI */
|
2015-01-15 11:52:06 +00:00
|
|
|
twl4030_apll_enable(codec, 1);
|
2010-04-29 07:58:08 +00:00
|
|
|
|
2015-01-15 11:52:06 +00:00
|
|
|
twl4030_write(codec, TWL4030_REG_AUDIO_IF,
|
2014-01-03 13:27:54 +00:00
|
|
|
audio_if | TWL4030_AIF_EN);
|
2010-04-29 07:58:08 +00:00
|
|
|
break;
|
|
|
|
case SND_SOC_DAPM_POST_PMD:
|
|
|
|
/* disable the DAI before we stop it's source PLL */
|
2015-01-15 11:52:06 +00:00
|
|
|
twl4030_write(codec, TWL4030_REG_AUDIO_IF,
|
2014-01-03 13:27:54 +00:00
|
|
|
audio_if & ~TWL4030_AIF_EN);
|
2015-01-15 11:52:06 +00:00
|
|
|
twl4030_apll_enable(codec, 0);
|
2010-04-29 07:58:08 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2009-05-18 13:02:05 +00:00
|
|
|
static void headset_ramp(struct snd_soc_codec *codec, int ramp)
|
2009-01-27 09:29:41 +00:00
|
|
|
{
|
|
|
|
unsigned char hs_gain, hs_pop;
|
2010-04-14 06:35:19 +00:00
|
|
|
struct twl4030_priv *twl4030 = snd_soc_codec_get_drvdata(codec);
|
2012-09-10 10:46:31 +00:00
|
|
|
struct twl4030_codec_data *pdata = twl4030->pdata;
|
2009-05-18 13:02:05 +00:00
|
|
|
/* Base values for ramp delay calculation: 2^19 - 2^26 */
|
|
|
|
unsigned int ramp_base[] = {524288, 1048576, 2097152, 4194304,
|
|
|
|
8388608, 16777216, 33554432, 67108864};
|
2010-10-25 08:34:23 +00:00
|
|
|
unsigned int delay;
|
2009-01-27 09:29:41 +00:00
|
|
|
|
2014-01-03 13:27:53 +00:00
|
|
|
hs_gain = twl4030_read(codec, TWL4030_REG_HS_GAIN_SET);
|
|
|
|
hs_pop = twl4030_read(codec, TWL4030_REG_HS_POPN_SET);
|
2010-10-25 08:34:23 +00:00
|
|
|
delay = (ramp_base[(hs_pop & TWL4030_RAMP_DELAY) >> 2] /
|
|
|
|
twl4030->sysclk) + 1;
|
2009-01-27 09:29:41 +00:00
|
|
|
|
2009-07-02 00:17:43 +00:00
|
|
|
/* Enable external mute control, this dramatically reduces
|
|
|
|
* the pop-noise */
|
2010-03-17 20:15:21 +00:00
|
|
|
if (pdata && pdata->hs_extmute) {
|
2012-09-10 10:46:27 +00:00
|
|
|
if (gpio_is_valid(pdata->hs_extmute_gpio)) {
|
|
|
|
gpio_set_value(pdata->hs_extmute_gpio, 1);
|
2009-07-02 00:17:43 +00:00
|
|
|
} else {
|
|
|
|
hs_pop |= TWL4030_EXTMUTE;
|
|
|
|
twl4030_write(codec, TWL4030_REG_HS_POPN_SET, hs_pop);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-05-18 13:02:05 +00:00
|
|
|
if (ramp) {
|
|
|
|
/* Headset ramp-up according to the TRM */
|
2009-01-27 09:29:41 +00:00
|
|
|
hs_pop |= TWL4030_VMID_EN;
|
2009-05-18 13:02:05 +00:00
|
|
|
twl4030_write(codec, TWL4030_REG_HS_POPN_SET, hs_pop);
|
ASoC: TWL4030: PM fix for output amplifiers
Gain controls on outputs affect the power consumption
when the gain is set to non 0 value.
Outputs with amps have one register to configure the
routing and the gain:
PREDL_CTL (0x25):
bit 0: Voice enable
bit 1: Audio L1 enable
bit 2: Audio L2 enable
bit 3: Audio R2 enable
bit 4-5: Gain (0x0 - power down, 0x1 - 6dB, 0x2 - 0dB, 0x3 - -6dB)
bit 0 - 3: is handled in DAPM domain (DAPM_MIXER)
bit 4 - 5: has simple volume control
If there is no audio activity (BIAS_STANDBY), and
user changes the volume, than the output amplifier will
be enabled.
If the user changes the routing (but the codec remains in
BIAS_STANDBY), than the cached gain value also be written
to the register, which enables the amplifier.
The existing workaround for this is to have virtual
PGAs associated with the outputs, and whit DAPM PMD
the gain on the output will be forced to 0 (off) by
bypassing the regcache.
This failed to disable the amplifiers in several
scenario (as mentioned above).
Also if the codec is in BIAS_ON state, and user modifies
a volume control, which path is actually not enabled, than
that amplifier will be enabled as well, but it will
be not turned off, since there is no DAPM path, which
would make mute it.
To prevent amps being enabled, when they are not
needed, introduce the following workaround:
Track the state of each of this type of output.
In twl4030_write only allow actual write, when the
given output is enabled, otherwise only update
the reg_cache.
The PGA event handlers on power up will write the cached
value to the chip (restoring gain, routing selection).
On power down 0 is written to the register (disabling
the amp, and also just in case clearing the routing).
Signed-off-by: Peter Ujfalusi <peter.ujfalusi@nokia.com>
Acked-by: Liam Girdwood <lrg@slimlogic.co.uk>
Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
2010-03-22 15:46:37 +00:00
|
|
|
/* Actually write to the register */
|
2014-01-03 13:27:54 +00:00
|
|
|
twl_i2c_write_u8(TWL4030_MODULE_AUDIO_VOICE, hs_gain,
|
|
|
|
TWL4030_REG_HS_GAIN_SET);
|
2009-01-27 09:29:41 +00:00
|
|
|
hs_pop |= TWL4030_RAMP_EN;
|
2009-05-18 13:02:05 +00:00
|
|
|
twl4030_write(codec, TWL4030_REG_HS_POPN_SET, hs_pop);
|
2009-07-02 00:17:43 +00:00
|
|
|
/* Wait ramp delay time + 1, so the VMID can settle */
|
2010-10-25 08:34:23 +00:00
|
|
|
twl4030_wait_ms(delay);
|
2009-05-18 13:02:05 +00:00
|
|
|
} else {
|
|
|
|
/* Headset ramp-down _not_ according to
|
|
|
|
* the TRM, but in a way that it is working */
|
2009-01-27 09:29:41 +00:00
|
|
|
hs_pop &= ~TWL4030_RAMP_EN;
|
2009-05-18 13:02:05 +00:00
|
|
|
twl4030_write(codec, TWL4030_REG_HS_POPN_SET, hs_pop);
|
|
|
|
/* Wait ramp delay time + 1, so the VMID can settle */
|
2010-10-25 08:34:23 +00:00
|
|
|
twl4030_wait_ms(delay);
|
2009-01-27 09:29:41 +00:00
|
|
|
/* Bypass the reg_cache to mute the headset */
|
2014-01-03 13:27:54 +00:00
|
|
|
twl_i2c_write_u8(TWL4030_MODULE_AUDIO_VOICE, hs_gain & (~0x0f),
|
|
|
|
TWL4030_REG_HS_GAIN_SET);
|
2009-05-18 13:02:05 +00:00
|
|
|
|
2009-01-27 09:29:41 +00:00
|
|
|
hs_pop &= ~TWL4030_VMID_EN;
|
2009-05-18 13:02:05 +00:00
|
|
|
twl4030_write(codec, TWL4030_REG_HS_POPN_SET, hs_pop);
|
|
|
|
}
|
2009-07-02 00:17:43 +00:00
|
|
|
|
|
|
|
/* Disable external mute */
|
2010-03-17 20:15:21 +00:00
|
|
|
if (pdata && pdata->hs_extmute) {
|
2012-09-10 10:46:27 +00:00
|
|
|
if (gpio_is_valid(pdata->hs_extmute_gpio)) {
|
|
|
|
gpio_set_value(pdata->hs_extmute_gpio, 0);
|
2009-07-02 00:17:43 +00:00
|
|
|
} else {
|
|
|
|
hs_pop &= ~TWL4030_EXTMUTE;
|
|
|
|
twl4030_write(codec, TWL4030_REG_HS_POPN_SET, hs_pop);
|
|
|
|
}
|
|
|
|
}
|
2009-05-18 13:02:05 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static int headsetlpga_event(struct snd_soc_dapm_widget *w,
|
2014-01-03 13:27:54 +00:00
|
|
|
struct snd_kcontrol *kcontrol, int event)
|
2009-05-18 13:02:05 +00:00
|
|
|
{
|
2015-01-15 11:52:06 +00:00
|
|
|
struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm);
|
|
|
|
struct twl4030_priv *twl4030 = snd_soc_codec_get_drvdata(codec);
|
2009-05-18 13:02:05 +00:00
|
|
|
|
|
|
|
switch (event) {
|
|
|
|
case SND_SOC_DAPM_POST_PMU:
|
|
|
|
/* Do the ramp-up only once */
|
|
|
|
if (!twl4030->hsr_enabled)
|
2015-01-15 11:52:06 +00:00
|
|
|
headset_ramp(codec, 1);
|
2009-05-18 13:02:05 +00:00
|
|
|
|
|
|
|
twl4030->hsl_enabled = 1;
|
|
|
|
break;
|
|
|
|
case SND_SOC_DAPM_POST_PMD:
|
|
|
|
/* Do the ramp-down only if both headsetL/R is disabled */
|
|
|
|
if (!twl4030->hsr_enabled)
|
2015-01-15 11:52:06 +00:00
|
|
|
headset_ramp(codec, 0);
|
2009-05-18 13:02:05 +00:00
|
|
|
|
|
|
|
twl4030->hsl_enabled = 0;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int headsetrpga_event(struct snd_soc_dapm_widget *w,
|
2014-01-03 13:27:54 +00:00
|
|
|
struct snd_kcontrol *kcontrol, int event)
|
2009-05-18 13:02:05 +00:00
|
|
|
{
|
2015-01-15 11:52:06 +00:00
|
|
|
struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm);
|
|
|
|
struct twl4030_priv *twl4030 = snd_soc_codec_get_drvdata(codec);
|
2009-05-18 13:02:05 +00:00
|
|
|
|
|
|
|
switch (event) {
|
|
|
|
case SND_SOC_DAPM_POST_PMU:
|
|
|
|
/* Do the ramp-up only once */
|
|
|
|
if (!twl4030->hsl_enabled)
|
2015-01-15 11:52:06 +00:00
|
|
|
headset_ramp(codec, 1);
|
2009-05-18 13:02:05 +00:00
|
|
|
|
|
|
|
twl4030->hsr_enabled = 1;
|
|
|
|
break;
|
|
|
|
case SND_SOC_DAPM_POST_PMD:
|
|
|
|
/* Do the ramp-down only if both headsetL/R is disabled */
|
|
|
|
if (!twl4030->hsl_enabled)
|
2015-01-15 11:52:06 +00:00
|
|
|
headset_ramp(codec, 0);
|
2009-05-18 13:02:05 +00:00
|
|
|
|
|
|
|
twl4030->hsr_enabled = 0;
|
2009-01-27 09:29:41 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2010-07-20 12:49:09 +00:00
|
|
|
static int digimic_event(struct snd_soc_dapm_widget *w,
|
2014-01-03 13:27:54 +00:00
|
|
|
struct snd_kcontrol *kcontrol, int event)
|
2010-07-20 12:49:09 +00:00
|
|
|
{
|
2015-01-15 11:52:06 +00:00
|
|
|
struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm);
|
|
|
|
struct twl4030_priv *twl4030 = snd_soc_codec_get_drvdata(codec);
|
2012-09-10 10:46:31 +00:00
|
|
|
struct twl4030_codec_data *pdata = twl4030->pdata;
|
2010-07-20 12:49:09 +00:00
|
|
|
|
2012-09-10 10:46:31 +00:00
|
|
|
if (pdata && pdata->digimic_delay)
|
|
|
|
twl4030_wait_ms(pdata->digimic_delay);
|
2010-07-20 12:49:09 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2008-11-24 11:49:38 +00:00
|
|
|
/*
|
|
|
|
* Some of the gain controls in TWL (mostly those which are associated with
|
|
|
|
* the outputs) are implemented in an interesting way:
|
|
|
|
* 0x0 : Power down (mute)
|
|
|
|
* 0x1 : 6dB
|
|
|
|
* 0x2 : 0 dB
|
|
|
|
* 0x3 : -6 dB
|
|
|
|
* Inverting not going to help with these.
|
|
|
|
* Custom volsw and volsw_2r get/put functions to handle these gain bits.
|
|
|
|
*/
|
|
|
|
static int snd_soc_get_volsw_twl4030(struct snd_kcontrol *kcontrol,
|
2014-01-03 13:27:54 +00:00
|
|
|
struct snd_ctl_elem_value *ucontrol)
|
2008-11-24 11:49:38 +00:00
|
|
|
{
|
|
|
|
struct soc_mixer_control *mc =
|
|
|
|
(struct soc_mixer_control *)kcontrol->private_value;
|
2014-03-18 08:02:04 +00:00
|
|
|
struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol);
|
2008-11-24 11:49:38 +00:00
|
|
|
unsigned int reg = mc->reg;
|
|
|
|
unsigned int shift = mc->shift;
|
|
|
|
unsigned int rshift = mc->rshift;
|
|
|
|
int max = mc->max;
|
|
|
|
int mask = (1 << fls(max)) - 1;
|
|
|
|
|
|
|
|
ucontrol->value.integer.value[0] =
|
|
|
|
(snd_soc_read(codec, reg) >> shift) & mask;
|
|
|
|
if (ucontrol->value.integer.value[0])
|
|
|
|
ucontrol->value.integer.value[0] =
|
|
|
|
max + 1 - ucontrol->value.integer.value[0];
|
|
|
|
|
|
|
|
if (shift != rshift) {
|
|
|
|
ucontrol->value.integer.value[1] =
|
|
|
|
(snd_soc_read(codec, reg) >> rshift) & mask;
|
|
|
|
if (ucontrol->value.integer.value[1])
|
|
|
|
ucontrol->value.integer.value[1] =
|
|
|
|
max + 1 - ucontrol->value.integer.value[1];
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int snd_soc_put_volsw_twl4030(struct snd_kcontrol *kcontrol,
|
2014-01-03 13:27:54 +00:00
|
|
|
struct snd_ctl_elem_value *ucontrol)
|
2008-11-24 11:49:38 +00:00
|
|
|
{
|
|
|
|
struct soc_mixer_control *mc =
|
|
|
|
(struct soc_mixer_control *)kcontrol->private_value;
|
2014-03-18 08:02:04 +00:00
|
|
|
struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol);
|
2008-11-24 11:49:38 +00:00
|
|
|
unsigned int reg = mc->reg;
|
|
|
|
unsigned int shift = mc->shift;
|
|
|
|
unsigned int rshift = mc->rshift;
|
|
|
|
int max = mc->max;
|
|
|
|
int mask = (1 << fls(max)) - 1;
|
|
|
|
unsigned short val, val2, val_mask;
|
|
|
|
|
|
|
|
val = (ucontrol->value.integer.value[0] & mask);
|
|
|
|
|
|
|
|
val_mask = mask << shift;
|
|
|
|
if (val)
|
|
|
|
val = max + 1 - val;
|
|
|
|
val = val << shift;
|
|
|
|
if (shift != rshift) {
|
|
|
|
val2 = (ucontrol->value.integer.value[1] & mask);
|
|
|
|
val_mask |= mask << rshift;
|
|
|
|
if (val2)
|
|
|
|
val2 = max + 1 - val2;
|
|
|
|
val |= val2 << rshift;
|
|
|
|
}
|
|
|
|
return snd_soc_update_bits(codec, reg, val_mask, val);
|
|
|
|
}
|
|
|
|
|
|
|
|
static int snd_soc_get_volsw_r2_twl4030(struct snd_kcontrol *kcontrol,
|
2014-01-03 13:27:54 +00:00
|
|
|
struct snd_ctl_elem_value *ucontrol)
|
2008-11-24 11:49:38 +00:00
|
|
|
{
|
|
|
|
struct soc_mixer_control *mc =
|
|
|
|
(struct soc_mixer_control *)kcontrol->private_value;
|
2014-03-18 08:02:04 +00:00
|
|
|
struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol);
|
2008-11-24 11:49:38 +00:00
|
|
|
unsigned int reg = mc->reg;
|
|
|
|
unsigned int reg2 = mc->rreg;
|
|
|
|
unsigned int shift = mc->shift;
|
|
|
|
int max = mc->max;
|
|
|
|
int mask = (1<<fls(max))-1;
|
|
|
|
|
|
|
|
ucontrol->value.integer.value[0] =
|
|
|
|
(snd_soc_read(codec, reg) >> shift) & mask;
|
|
|
|
ucontrol->value.integer.value[1] =
|
|
|
|
(snd_soc_read(codec, reg2) >> shift) & mask;
|
|
|
|
|
|
|
|
if (ucontrol->value.integer.value[0])
|
|
|
|
ucontrol->value.integer.value[0] =
|
|
|
|
max + 1 - ucontrol->value.integer.value[0];
|
|
|
|
if (ucontrol->value.integer.value[1])
|
|
|
|
ucontrol->value.integer.value[1] =
|
|
|
|
max + 1 - ucontrol->value.integer.value[1];
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int snd_soc_put_volsw_r2_twl4030(struct snd_kcontrol *kcontrol,
|
2014-01-03 13:27:54 +00:00
|
|
|
struct snd_ctl_elem_value *ucontrol)
|
2008-11-24 11:49:38 +00:00
|
|
|
{
|
|
|
|
struct soc_mixer_control *mc =
|
|
|
|
(struct soc_mixer_control *)kcontrol->private_value;
|
2014-03-18 08:02:04 +00:00
|
|
|
struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol);
|
2008-11-24 11:49:38 +00:00
|
|
|
unsigned int reg = mc->reg;
|
|
|
|
unsigned int reg2 = mc->rreg;
|
|
|
|
unsigned int shift = mc->shift;
|
|
|
|
int max = mc->max;
|
|
|
|
int mask = (1 << fls(max)) - 1;
|
|
|
|
int err;
|
|
|
|
unsigned short val, val2, val_mask;
|
|
|
|
|
|
|
|
val_mask = mask << shift;
|
|
|
|
val = (ucontrol->value.integer.value[0] & mask);
|
|
|
|
val2 = (ucontrol->value.integer.value[1] & mask);
|
|
|
|
|
|
|
|
if (val)
|
|
|
|
val = max + 1 - val;
|
|
|
|
if (val2)
|
|
|
|
val2 = max + 1 - val2;
|
|
|
|
|
|
|
|
val = val << shift;
|
|
|
|
val2 = val2 << shift;
|
|
|
|
|
|
|
|
err = snd_soc_update_bits(codec, reg, val_mask, val);
|
|
|
|
if (err < 0)
|
|
|
|
return err;
|
|
|
|
|
|
|
|
err = snd_soc_update_bits(codec, reg2, val_mask, val2);
|
|
|
|
return err;
|
|
|
|
}
|
|
|
|
|
2009-05-18 16:52:55 +00:00
|
|
|
/* Codec operation modes */
|
|
|
|
static const char *twl4030_op_modes_texts[] = {
|
|
|
|
"Option 2 (voice/audio)", "Option 1 (audio)"
|
|
|
|
};
|
|
|
|
|
2014-02-18 09:28:25 +00:00
|
|
|
static SOC_ENUM_SINGLE_DECL(twl4030_op_modes_enum,
|
|
|
|
TWL4030_REG_CODEC_MODE, 0,
|
|
|
|
twl4030_op_modes_texts);
|
2009-05-18 16:52:55 +00:00
|
|
|
|
2009-06-20 12:54:02 +00:00
|
|
|
static int snd_soc_put_twl4030_opmode_enum_double(struct snd_kcontrol *kcontrol,
|
2009-05-18 16:52:55 +00:00
|
|
|
struct snd_ctl_elem_value *ucontrol)
|
|
|
|
{
|
2014-03-18 08:02:04 +00:00
|
|
|
struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol);
|
2010-04-14 06:35:19 +00:00
|
|
|
struct twl4030_priv *twl4030 = snd_soc_codec_get_drvdata(codec);
|
2009-05-18 16:52:55 +00:00
|
|
|
|
|
|
|
if (twl4030->configured) {
|
2012-02-21 07:34:20 +00:00
|
|
|
dev_err(codec->dev,
|
|
|
|
"operation mode cannot be changed on-the-fly\n");
|
2009-05-18 16:52:55 +00:00
|
|
|
return -EBUSY;
|
|
|
|
}
|
|
|
|
|
2014-02-18 07:56:39 +00:00
|
|
|
return snd_soc_put_enum_double(kcontrol, ucontrol);
|
2009-05-18 16:52:55 +00:00
|
|
|
}
|
|
|
|
|
2008-11-24 11:49:35 +00:00
|
|
|
/*
|
|
|
|
* FGAIN volume control:
|
|
|
|
* from -62 to 0 dB in 1 dB steps (mute instead of -63 dB)
|
|
|
|
*/
|
2008-12-01 08:03:46 +00:00
|
|
|
static DECLARE_TLV_DB_SCALE(digital_fine_tlv, -6300, 100, 1);
|
2008-11-24 11:49:35 +00:00
|
|
|
|
2008-11-24 11:49:36 +00:00
|
|
|
/*
|
|
|
|
* CGAIN volume control:
|
|
|
|
* 0 dB to 12 dB in 6 dB steps
|
|
|
|
* value 2 and 3 means 12 dB
|
|
|
|
*/
|
2008-12-01 08:03:46 +00:00
|
|
|
static DECLARE_TLV_DB_SCALE(digital_coarse_tlv, 0, 600, 0);
|
|
|
|
|
2009-04-22 04:13:34 +00:00
|
|
|
/*
|
|
|
|
* Voice Downlink GAIN volume control:
|
|
|
|
* from -37 to 12 dB in 1 dB steps (mute instead of -37 dB)
|
|
|
|
*/
|
|
|
|
static DECLARE_TLV_DB_SCALE(digital_voice_downlink_tlv, -3700, 100, 1);
|
|
|
|
|
2008-12-01 08:03:46 +00:00
|
|
|
/*
|
|
|
|
* Analog playback gain
|
|
|
|
* -24 dB to 12 dB in 2 dB steps
|
|
|
|
*/
|
|
|
|
static DECLARE_TLV_DB_SCALE(analog_tlv, -2400, 200, 0);
|
2008-11-24 11:49:36 +00:00
|
|
|
|
2008-12-01 08:03:47 +00:00
|
|
|
/*
|
|
|
|
* Gain controls tied to outputs
|
|
|
|
* -6 dB to 6 dB in 6 dB steps (mute instead of -12)
|
|
|
|
*/
|
|
|
|
static DECLARE_TLV_DB_SCALE(output_tvl, -1200, 600, 1);
|
|
|
|
|
2009-04-28 09:18:05 +00:00
|
|
|
/*
|
|
|
|
* Gain control for earpiece amplifier
|
|
|
|
* 0 dB to 12 dB in 6 dB steps (mute instead of -6)
|
|
|
|
*/
|
|
|
|
static DECLARE_TLV_DB_SCALE(output_ear_tvl, -600, 600, 1);
|
|
|
|
|
2008-12-01 08:03:45 +00:00
|
|
|
/*
|
|
|
|
* Capture gain after the ADCs
|
|
|
|
* from 0 dB to 31 dB in 1 dB steps
|
|
|
|
*/
|
|
|
|
static DECLARE_TLV_DB_SCALE(digital_capture_tlv, 0, 100, 0);
|
|
|
|
|
2008-12-02 18:48:58 +00:00
|
|
|
/*
|
|
|
|
* Gain control for input amplifiers
|
|
|
|
* 0 dB to 30 dB in 6 dB steps
|
|
|
|
*/
|
|
|
|
static DECLARE_TLV_DB_SCALE(input_gain_tlv, 0, 600, 0);
|
|
|
|
|
2009-06-22 15:51:52 +00:00
|
|
|
/* AVADC clock priority */
|
|
|
|
static const char *twl4030_avadc_clk_priority_texts[] = {
|
|
|
|
"Voice high priority", "HiFi high priority"
|
|
|
|
};
|
|
|
|
|
2014-02-18 09:28:25 +00:00
|
|
|
static SOC_ENUM_SINGLE_DECL(twl4030_avadc_clk_priority_enum,
|
|
|
|
TWL4030_REG_AVADC_CTL, 2,
|
|
|
|
twl4030_avadc_clk_priority_texts);
|
2009-06-22 15:51:52 +00:00
|
|
|
|
2009-03-05 10:48:49 +00:00
|
|
|
static const char *twl4030_rampdelay_texts[] = {
|
|
|
|
"27/20/14 ms", "55/40/27 ms", "109/81/55 ms", "218/161/109 ms",
|
|
|
|
"437/323/218 ms", "874/645/437 ms", "1748/1291/874 ms",
|
|
|
|
"3495/2581/1748 ms"
|
|
|
|
};
|
|
|
|
|
2014-02-18 09:28:25 +00:00
|
|
|
static SOC_ENUM_SINGLE_DECL(twl4030_rampdelay_enum,
|
|
|
|
TWL4030_REG_HS_POPN_SET, 2,
|
|
|
|
twl4030_rampdelay_texts);
|
2009-03-05 10:48:49 +00:00
|
|
|
|
2009-05-05 05:55:47 +00:00
|
|
|
/* Vibra H-bridge direction mode */
|
|
|
|
static const char *twl4030_vibradirmode_texts[] = {
|
|
|
|
"Vibra H-bridge direction", "Audio data MSB",
|
|
|
|
};
|
|
|
|
|
2014-02-18 09:28:25 +00:00
|
|
|
static SOC_ENUM_SINGLE_DECL(twl4030_vibradirmode_enum,
|
|
|
|
TWL4030_REG_VIBRA_CTL, 5,
|
|
|
|
twl4030_vibradirmode_texts);
|
2009-05-05 05:55:47 +00:00
|
|
|
|
|
|
|
/* Vibra H-bridge direction */
|
|
|
|
static const char *twl4030_vibradir_texts[] = {
|
|
|
|
"Positive polarity", "Negative polarity",
|
|
|
|
};
|
|
|
|
|
2014-02-18 09:28:25 +00:00
|
|
|
static SOC_ENUM_SINGLE_DECL(twl4030_vibradir_enum,
|
|
|
|
TWL4030_REG_VIBRA_CTL, 1,
|
|
|
|
twl4030_vibradir_texts);
|
2009-05-05 05:55:47 +00:00
|
|
|
|
2010-05-12 07:35:36 +00:00
|
|
|
/* Digimic Left and right swapping */
|
|
|
|
static const char *twl4030_digimicswap_texts[] = {
|
|
|
|
"Not swapped", "Swapped",
|
|
|
|
};
|
|
|
|
|
2014-02-18 09:28:25 +00:00
|
|
|
static SOC_ENUM_SINGLE_DECL(twl4030_digimicswap_enum,
|
|
|
|
TWL4030_REG_MISC_SET_1, 0,
|
|
|
|
twl4030_digimicswap_texts);
|
2010-05-12 07:35:36 +00:00
|
|
|
|
2008-10-31 04:35:26 +00:00
|
|
|
static const struct snd_kcontrol_new twl4030_snd_controls[] = {
|
2009-05-18 16:52:55 +00:00
|
|
|
/* Codec operation mode control */
|
|
|
|
SOC_ENUM_EXT("Codec Operation Mode", twl4030_op_modes_enum,
|
|
|
|
snd_soc_get_enum_double,
|
|
|
|
snd_soc_put_twl4030_opmode_enum_double),
|
|
|
|
|
2008-12-01 08:03:46 +00:00
|
|
|
/* Common playback gain controls */
|
|
|
|
SOC_DOUBLE_R_TLV("DAC1 Digital Fine Playback Volume",
|
|
|
|
TWL4030_REG_ARXL1PGA, TWL4030_REG_ARXR1PGA,
|
|
|
|
0, 0x3f, 0, digital_fine_tlv),
|
|
|
|
SOC_DOUBLE_R_TLV("DAC2 Digital Fine Playback Volume",
|
|
|
|
TWL4030_REG_ARXL2PGA, TWL4030_REG_ARXR2PGA,
|
|
|
|
0, 0x3f, 0, digital_fine_tlv),
|
|
|
|
|
|
|
|
SOC_DOUBLE_R_TLV("DAC1 Digital Coarse Playback Volume",
|
|
|
|
TWL4030_REG_ARXL1PGA, TWL4030_REG_ARXR1PGA,
|
|
|
|
6, 0x2, 0, digital_coarse_tlv),
|
|
|
|
SOC_DOUBLE_R_TLV("DAC2 Digital Coarse Playback Volume",
|
|
|
|
TWL4030_REG_ARXL2PGA, TWL4030_REG_ARXR2PGA,
|
|
|
|
6, 0x2, 0, digital_coarse_tlv),
|
|
|
|
|
|
|
|
SOC_DOUBLE_R_TLV("DAC1 Analog Playback Volume",
|
|
|
|
TWL4030_REG_ARXL1_APGA_CTL, TWL4030_REG_ARXR1_APGA_CTL,
|
|
|
|
3, 0x12, 1, analog_tlv),
|
|
|
|
SOC_DOUBLE_R_TLV("DAC2 Analog Playback Volume",
|
|
|
|
TWL4030_REG_ARXL2_APGA_CTL, TWL4030_REG_ARXR2_APGA_CTL,
|
|
|
|
3, 0x12, 1, analog_tlv),
|
2008-12-09 06:45:44 +00:00
|
|
|
SOC_DOUBLE_R("DAC1 Analog Playback Switch",
|
|
|
|
TWL4030_REG_ARXL1_APGA_CTL, TWL4030_REG_ARXR1_APGA_CTL,
|
|
|
|
1, 1, 0),
|
|
|
|
SOC_DOUBLE_R("DAC2 Analog Playback Switch",
|
|
|
|
TWL4030_REG_ARXL2_APGA_CTL, TWL4030_REG_ARXR2_APGA_CTL,
|
|
|
|
1, 1, 0),
|
2008-12-01 08:03:45 +00:00
|
|
|
|
2009-04-22 04:13:34 +00:00
|
|
|
/* Common voice downlink gain controls */
|
|
|
|
SOC_SINGLE_TLV("DAC Voice Digital Downlink Volume",
|
|
|
|
TWL4030_REG_VRXPGA, 0, 0x31, 0, digital_voice_downlink_tlv),
|
|
|
|
|
|
|
|
SOC_SINGLE_TLV("DAC Voice Analog Downlink Volume",
|
|
|
|
TWL4030_REG_VDL_APGA_CTL, 3, 0x12, 1, analog_tlv),
|
|
|
|
|
|
|
|
SOC_SINGLE("DAC Voice Analog Downlink Switch",
|
|
|
|
TWL4030_REG_VDL_APGA_CTL, 1, 1, 0),
|
|
|
|
|
2008-12-01 08:03:47 +00:00
|
|
|
/* Separate output gain controls */
|
2011-10-05 07:29:19 +00:00
|
|
|
SOC_DOUBLE_R_EXT_TLV("PreDriv Playback Volume",
|
2008-12-01 08:03:47 +00:00
|
|
|
TWL4030_REG_PREDL_CTL, TWL4030_REG_PREDR_CTL,
|
2011-10-05 07:29:19 +00:00
|
|
|
4, 3, 0, snd_soc_get_volsw_r2_twl4030,
|
|
|
|
snd_soc_put_volsw_r2_twl4030, output_tvl),
|
2008-12-01 08:03:47 +00:00
|
|
|
|
2011-10-05 07:29:19 +00:00
|
|
|
SOC_DOUBLE_EXT_TLV("Headset Playback Volume",
|
|
|
|
TWL4030_REG_HS_GAIN_SET, 0, 2, 3, 0, snd_soc_get_volsw_twl4030,
|
|
|
|
snd_soc_put_volsw_twl4030, output_tvl),
|
2008-12-01 08:03:47 +00:00
|
|
|
|
2011-10-05 07:29:19 +00:00
|
|
|
SOC_DOUBLE_R_EXT_TLV("Carkit Playback Volume",
|
2008-12-01 08:03:47 +00:00
|
|
|
TWL4030_REG_PRECKL_CTL, TWL4030_REG_PRECKR_CTL,
|
2011-10-05 07:29:19 +00:00
|
|
|
4, 3, 0, snd_soc_get_volsw_r2_twl4030,
|
|
|
|
snd_soc_put_volsw_r2_twl4030, output_tvl),
|
2008-12-01 08:03:47 +00:00
|
|
|
|
2011-10-05 07:29:19 +00:00
|
|
|
SOC_SINGLE_EXT_TLV("Earpiece Playback Volume",
|
|
|
|
TWL4030_REG_EAR_CTL, 4, 3, 0, snd_soc_get_volsw_twl4030,
|
|
|
|
snd_soc_put_volsw_twl4030, output_ear_tvl),
|
2008-12-01 08:03:47 +00:00
|
|
|
|
2008-12-01 08:03:45 +00:00
|
|
|
/* Common capture gain controls */
|
ASoC: TWL4030: DAPM based capture implementation
This patch adds DAPM implementaion for the capture path
on twlx030.
TWL has two physical ADC and two digital microphone (stereo) connections.
The CPU interface has four microphone channels.
For simplicity the microphone channel paths are named as:
TX1 (Left/Right) - when using i2s mode, only the TX1 data is valid
TX2 (Left/Right)
Input routing (simplified version):
There is two levels of mux settings for TWL in input path:
Analog input mux:
ADCL <- {Off, Main mic, Headset mic, AUXL, Carkit mic}
ADCR <- {Off, Sub mic, AUXR}
Analog/Digital mux:
TX1 Analog mode:
TX1L <- ADCL
TX1R <- ADCR
TX1 Digital mode:
TX1L <- Digimic0 (Left)
TX1R <- Digimic0 (Right)
TX2 Analog mode:
TX2L <- ADCL
TX2R <- ADCR
TX2 Digital mode:
TX2L <- Digimic1 (Left)
TX2R <- Digimic1 (Right)
The patch provides the following user controls for the capture path:
Mux settings:
"TX1 Capture Route": {Analog, Digimic0}
"TX2 Capture Route": {Analog, Digimic1}
"Analog Left Capture Route": {Off, Main Mic, Headset Mic, AUXL, Carkit Mic}
"Analog Right Capture Route": {Off, Sub Mic, AUXR}
Volume/Gain controls:
"TX1 Digital Capture Volume": Stereo gain control for TX1 path
"TX2 Digital Capture Volume": Stereo gain control for TX2 path
"Analog Capture Volume": Stereo gain control for the analog path only
Important things for the board files:
Microphone bias:
"Mic Bias 1": Bias for Main mic or for digimic0 (analog or digital path)
"Mic Bias 2": Bias for Sub mic or for digimic1 (analog or digital path)
"Headset Mic Bias": Bias for Headset mic
When the routing configured correctly only the needed components will be
powered/enabled.
Signed-off-by: Peter Ujfalusi <peter.ujfalusi@nokia.com>
Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
2008-12-31 08:08:38 +00:00
|
|
|
SOC_DOUBLE_R_TLV("TX1 Digital Capture Volume",
|
2008-12-01 08:03:45 +00:00
|
|
|
TWL4030_REG_ATXL1PGA, TWL4030_REG_ATXR1PGA,
|
|
|
|
0, 0x1f, 0, digital_capture_tlv),
|
ASoC: TWL4030: DAPM based capture implementation
This patch adds DAPM implementaion for the capture path
on twlx030.
TWL has two physical ADC and two digital microphone (stereo) connections.
The CPU interface has four microphone channels.
For simplicity the microphone channel paths are named as:
TX1 (Left/Right) - when using i2s mode, only the TX1 data is valid
TX2 (Left/Right)
Input routing (simplified version):
There is two levels of mux settings for TWL in input path:
Analog input mux:
ADCL <- {Off, Main mic, Headset mic, AUXL, Carkit mic}
ADCR <- {Off, Sub mic, AUXR}
Analog/Digital mux:
TX1 Analog mode:
TX1L <- ADCL
TX1R <- ADCR
TX1 Digital mode:
TX1L <- Digimic0 (Left)
TX1R <- Digimic0 (Right)
TX2 Analog mode:
TX2L <- ADCL
TX2R <- ADCR
TX2 Digital mode:
TX2L <- Digimic1 (Left)
TX2R <- Digimic1 (Right)
The patch provides the following user controls for the capture path:
Mux settings:
"TX1 Capture Route": {Analog, Digimic0}
"TX2 Capture Route": {Analog, Digimic1}
"Analog Left Capture Route": {Off, Main Mic, Headset Mic, AUXL, Carkit Mic}
"Analog Right Capture Route": {Off, Sub Mic, AUXR}
Volume/Gain controls:
"TX1 Digital Capture Volume": Stereo gain control for TX1 path
"TX2 Digital Capture Volume": Stereo gain control for TX2 path
"Analog Capture Volume": Stereo gain control for the analog path only
Important things for the board files:
Microphone bias:
"Mic Bias 1": Bias for Main mic or for digimic0 (analog or digital path)
"Mic Bias 2": Bias for Sub mic or for digimic1 (analog or digital path)
"Headset Mic Bias": Bias for Headset mic
When the routing configured correctly only the needed components will be
powered/enabled.
Signed-off-by: Peter Ujfalusi <peter.ujfalusi@nokia.com>
Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
2008-12-31 08:08:38 +00:00
|
|
|
SOC_DOUBLE_R_TLV("TX2 Digital Capture Volume",
|
|
|
|
TWL4030_REG_AVTXL2PGA, TWL4030_REG_AVTXR2PGA,
|
|
|
|
0, 0x1f, 0, digital_capture_tlv),
|
2008-12-02 18:48:58 +00:00
|
|
|
|
ASoC: TWL4030: DAPM based capture implementation
This patch adds DAPM implementaion for the capture path
on twlx030.
TWL has two physical ADC and two digital microphone (stereo) connections.
The CPU interface has four microphone channels.
For simplicity the microphone channel paths are named as:
TX1 (Left/Right) - when using i2s mode, only the TX1 data is valid
TX2 (Left/Right)
Input routing (simplified version):
There is two levels of mux settings for TWL in input path:
Analog input mux:
ADCL <- {Off, Main mic, Headset mic, AUXL, Carkit mic}
ADCR <- {Off, Sub mic, AUXR}
Analog/Digital mux:
TX1 Analog mode:
TX1L <- ADCL
TX1R <- ADCR
TX1 Digital mode:
TX1L <- Digimic0 (Left)
TX1R <- Digimic0 (Right)
TX2 Analog mode:
TX2L <- ADCL
TX2R <- ADCR
TX2 Digital mode:
TX2L <- Digimic1 (Left)
TX2R <- Digimic1 (Right)
The patch provides the following user controls for the capture path:
Mux settings:
"TX1 Capture Route": {Analog, Digimic0}
"TX2 Capture Route": {Analog, Digimic1}
"Analog Left Capture Route": {Off, Main Mic, Headset Mic, AUXL, Carkit Mic}
"Analog Right Capture Route": {Off, Sub Mic, AUXR}
Volume/Gain controls:
"TX1 Digital Capture Volume": Stereo gain control for TX1 path
"TX2 Digital Capture Volume": Stereo gain control for TX2 path
"Analog Capture Volume": Stereo gain control for the analog path only
Important things for the board files:
Microphone bias:
"Mic Bias 1": Bias for Main mic or for digimic0 (analog or digital path)
"Mic Bias 2": Bias for Sub mic or for digimic1 (analog or digital path)
"Headset Mic Bias": Bias for Headset mic
When the routing configured correctly only the needed components will be
powered/enabled.
Signed-off-by: Peter Ujfalusi <peter.ujfalusi@nokia.com>
Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
2008-12-31 08:08:38 +00:00
|
|
|
SOC_DOUBLE_TLV("Analog Capture Volume", TWL4030_REG_ANAMIC_GAIN,
|
2008-12-02 18:48:58 +00:00
|
|
|
0, 3, 5, 0, input_gain_tlv),
|
2009-03-05 10:48:49 +00:00
|
|
|
|
2009-06-22 15:51:52 +00:00
|
|
|
SOC_ENUM("AVADC Clock Priority", twl4030_avadc_clk_priority_enum),
|
|
|
|
|
2009-03-05 10:48:49 +00:00
|
|
|
SOC_ENUM("HS ramp delay", twl4030_rampdelay_enum),
|
2009-05-05 05:55:47 +00:00
|
|
|
|
|
|
|
SOC_ENUM("Vibra H-bridge mode", twl4030_vibradirmode_enum),
|
|
|
|
SOC_ENUM("Vibra H-bridge direction", twl4030_vibradir_enum),
|
2010-05-12 07:35:36 +00:00
|
|
|
|
|
|
|
SOC_ENUM("Digimic LR Swap", twl4030_digimicswap_enum),
|
2008-10-31 04:35:26 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
static const struct snd_soc_dapm_widget twl4030_dapm_widgets[] = {
|
ASoC: TWL4030: DAPM based capture implementation
This patch adds DAPM implementaion for the capture path
on twlx030.
TWL has two physical ADC and two digital microphone (stereo) connections.
The CPU interface has four microphone channels.
For simplicity the microphone channel paths are named as:
TX1 (Left/Right) - when using i2s mode, only the TX1 data is valid
TX2 (Left/Right)
Input routing (simplified version):
There is two levels of mux settings for TWL in input path:
Analog input mux:
ADCL <- {Off, Main mic, Headset mic, AUXL, Carkit mic}
ADCR <- {Off, Sub mic, AUXR}
Analog/Digital mux:
TX1 Analog mode:
TX1L <- ADCL
TX1R <- ADCR
TX1 Digital mode:
TX1L <- Digimic0 (Left)
TX1R <- Digimic0 (Right)
TX2 Analog mode:
TX2L <- ADCL
TX2R <- ADCR
TX2 Digital mode:
TX2L <- Digimic1 (Left)
TX2R <- Digimic1 (Right)
The patch provides the following user controls for the capture path:
Mux settings:
"TX1 Capture Route": {Analog, Digimic0}
"TX2 Capture Route": {Analog, Digimic1}
"Analog Left Capture Route": {Off, Main Mic, Headset Mic, AUXL, Carkit Mic}
"Analog Right Capture Route": {Off, Sub Mic, AUXR}
Volume/Gain controls:
"TX1 Digital Capture Volume": Stereo gain control for TX1 path
"TX2 Digital Capture Volume": Stereo gain control for TX2 path
"Analog Capture Volume": Stereo gain control for the analog path only
Important things for the board files:
Microphone bias:
"Mic Bias 1": Bias for Main mic or for digimic0 (analog or digital path)
"Mic Bias 2": Bias for Sub mic or for digimic1 (analog or digital path)
"Headset Mic Bias": Bias for Headset mic
When the routing configured correctly only the needed components will be
powered/enabled.
Signed-off-by: Peter Ujfalusi <peter.ujfalusi@nokia.com>
Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
2008-12-31 08:08:38 +00:00
|
|
|
/* Left channel inputs */
|
|
|
|
SND_SOC_DAPM_INPUT("MAINMIC"),
|
|
|
|
SND_SOC_DAPM_INPUT("HSMIC"),
|
|
|
|
SND_SOC_DAPM_INPUT("AUXL"),
|
|
|
|
SND_SOC_DAPM_INPUT("CARKITMIC"),
|
|
|
|
/* Right channel inputs */
|
|
|
|
SND_SOC_DAPM_INPUT("SUBMIC"),
|
|
|
|
SND_SOC_DAPM_INPUT("AUXR"),
|
|
|
|
/* Digital microphones (Stereo) */
|
|
|
|
SND_SOC_DAPM_INPUT("DIGIMIC0"),
|
|
|
|
SND_SOC_DAPM_INPUT("DIGIMIC1"),
|
|
|
|
|
|
|
|
/* Outputs */
|
2008-12-09 10:35:47 +00:00
|
|
|
SND_SOC_DAPM_OUTPUT("EARPIECE"),
|
2008-12-09 10:35:48 +00:00
|
|
|
SND_SOC_DAPM_OUTPUT("PREDRIVEL"),
|
|
|
|
SND_SOC_DAPM_OUTPUT("PREDRIVER"),
|
2008-12-09 10:35:49 +00:00
|
|
|
SND_SOC_DAPM_OUTPUT("HSOL"),
|
|
|
|
SND_SOC_DAPM_OUTPUT("HSOR"),
|
2008-12-10 10:51:46 +00:00
|
|
|
SND_SOC_DAPM_OUTPUT("CARKITL"),
|
|
|
|
SND_SOC_DAPM_OUTPUT("CARKITR"),
|
2008-12-09 10:35:51 +00:00
|
|
|
SND_SOC_DAPM_OUTPUT("HFL"),
|
|
|
|
SND_SOC_DAPM_OUTPUT("HFR"),
|
2009-05-05 05:55:47 +00:00
|
|
|
SND_SOC_DAPM_OUTPUT("VIBRA"),
|
2008-10-31 04:35:26 +00:00
|
|
|
|
2010-04-29 07:58:08 +00:00
|
|
|
/* AIF and APLL clocks for running DAIs (including loopback) */
|
|
|
|
SND_SOC_DAPM_OUTPUT("Virtual HiFi OUT"),
|
|
|
|
SND_SOC_DAPM_INPUT("Virtual HiFi IN"),
|
|
|
|
SND_SOC_DAPM_OUTPUT("Virtual Voice OUT"),
|
|
|
|
|
2008-12-09 06:45:43 +00:00
|
|
|
/* DACs */
|
2012-09-20 13:32:02 +00:00
|
|
|
SND_SOC_DAPM_DAC("DAC Right1", NULL, SND_SOC_NOPM, 0, 0),
|
|
|
|
SND_SOC_DAPM_DAC("DAC Left1", NULL, SND_SOC_NOPM, 0, 0),
|
|
|
|
SND_SOC_DAPM_DAC("DAC Right2", NULL, SND_SOC_NOPM, 0, 0),
|
|
|
|
SND_SOC_DAPM_DAC("DAC Left2", NULL, SND_SOC_NOPM, 0, 0),
|
|
|
|
SND_SOC_DAPM_DAC("DAC Voice", NULL, SND_SOC_NOPM, 0, 0),
|
2008-10-31 04:35:26 +00:00
|
|
|
|
2012-12-31 10:51:42 +00:00
|
|
|
SND_SOC_DAPM_AIF_IN("VAIFIN", "Voice Playback", 0,
|
|
|
|
TWL4030_REG_VOICE_IF, 6, 0),
|
|
|
|
|
2009-01-29 12:57:50 +00:00
|
|
|
/* Analog bypasses */
|
2009-10-28 08:57:04 +00:00
|
|
|
SND_SOC_DAPM_SWITCH("Right1 Analog Loopback", SND_SOC_NOPM, 0, 0,
|
|
|
|
&twl4030_dapm_abypassr1_control),
|
|
|
|
SND_SOC_DAPM_SWITCH("Left1 Analog Loopback", SND_SOC_NOPM, 0, 0,
|
|
|
|
&twl4030_dapm_abypassl1_control),
|
|
|
|
SND_SOC_DAPM_SWITCH("Right2 Analog Loopback", SND_SOC_NOPM, 0, 0,
|
|
|
|
&twl4030_dapm_abypassr2_control),
|
|
|
|
SND_SOC_DAPM_SWITCH("Left2 Analog Loopback", SND_SOC_NOPM, 0, 0,
|
|
|
|
&twl4030_dapm_abypassl2_control),
|
|
|
|
SND_SOC_DAPM_SWITCH("Voice Analog Loopback", SND_SOC_NOPM, 0, 0,
|
|
|
|
&twl4030_dapm_abypassv_control),
|
|
|
|
|
|
|
|
/* Master analog loopback switch */
|
|
|
|
SND_SOC_DAPM_SUPPLY("FM Loop Enable", TWL4030_REG_MISC_SET_1, 5, 0,
|
|
|
|
NULL, 0),
|
2009-01-29 12:57:50 +00:00
|
|
|
|
2009-02-18 12:39:05 +00:00
|
|
|
/* Digital bypasses */
|
2009-10-28 08:57:04 +00:00
|
|
|
SND_SOC_DAPM_SWITCH("Left Digital Loopback", SND_SOC_NOPM, 0, 0,
|
|
|
|
&twl4030_dapm_dbypassl_control),
|
|
|
|
SND_SOC_DAPM_SWITCH("Right Digital Loopback", SND_SOC_NOPM, 0, 0,
|
|
|
|
&twl4030_dapm_dbypassr_control),
|
|
|
|
SND_SOC_DAPM_SWITCH("Voice Digital Loopback", SND_SOC_NOPM, 0, 0,
|
|
|
|
&twl4030_dapm_dbypassv_control),
|
2009-02-18 12:39:05 +00:00
|
|
|
|
2009-05-18 13:02:04 +00:00
|
|
|
/* Digital mixers, power control for the physical DACs */
|
|
|
|
SND_SOC_DAPM_MIXER("Digital R1 Playback Mixer",
|
|
|
|
TWL4030_REG_AVDAC_CTL, 0, 0, NULL, 0),
|
|
|
|
SND_SOC_DAPM_MIXER("Digital L1 Playback Mixer",
|
|
|
|
TWL4030_REG_AVDAC_CTL, 1, 0, NULL, 0),
|
|
|
|
SND_SOC_DAPM_MIXER("Digital R2 Playback Mixer",
|
|
|
|
TWL4030_REG_AVDAC_CTL, 2, 0, NULL, 0),
|
|
|
|
SND_SOC_DAPM_MIXER("Digital L2 Playback Mixer",
|
|
|
|
TWL4030_REG_AVDAC_CTL, 3, 0, NULL, 0),
|
|
|
|
SND_SOC_DAPM_MIXER("Digital Voice Playback Mixer",
|
|
|
|
TWL4030_REG_AVDAC_CTL, 4, 0, NULL, 0),
|
|
|
|
|
|
|
|
/* Analog mixers, power control for the physical PGAs */
|
|
|
|
SND_SOC_DAPM_MIXER("Analog R1 Playback Mixer",
|
|
|
|
TWL4030_REG_ARXR1_APGA_CTL, 0, 0, NULL, 0),
|
|
|
|
SND_SOC_DAPM_MIXER("Analog L1 Playback Mixer",
|
|
|
|
TWL4030_REG_ARXL1_APGA_CTL, 0, 0, NULL, 0),
|
|
|
|
SND_SOC_DAPM_MIXER("Analog R2 Playback Mixer",
|
|
|
|
TWL4030_REG_ARXR2_APGA_CTL, 0, 0, NULL, 0),
|
|
|
|
SND_SOC_DAPM_MIXER("Analog L2 Playback Mixer",
|
|
|
|
TWL4030_REG_ARXL2_APGA_CTL, 0, 0, NULL, 0),
|
|
|
|
SND_SOC_DAPM_MIXER("Analog Voice Playback Mixer",
|
|
|
|
TWL4030_REG_VDL_APGA_CTL, 0, 0, NULL, 0),
|
2009-01-29 12:57:50 +00:00
|
|
|
|
2009-10-29 09:58:10 +00:00
|
|
|
SND_SOC_DAPM_SUPPLY("APLL Enable", SND_SOC_NOPM, 0, 0, apll_event,
|
|
|
|
SND_SOC_DAPM_PRE_PMU|SND_SOC_DAPM_POST_PMD),
|
|
|
|
|
2010-04-29 07:58:08 +00:00
|
|
|
SND_SOC_DAPM_SUPPLY("AIF Enable", SND_SOC_NOPM, 0, 0, aif_event,
|
|
|
|
SND_SOC_DAPM_PRE_PMU|SND_SOC_DAPM_POST_PMD),
|
2010-02-09 13:24:04 +00:00
|
|
|
|
2009-04-22 04:13:34 +00:00
|
|
|
/* Output MIXER controls */
|
2008-12-09 10:35:47 +00:00
|
|
|
/* Earpiece */
|
2009-04-22 04:13:34 +00:00
|
|
|
SND_SOC_DAPM_MIXER("Earpiece Mixer", SND_SOC_NOPM, 0, 0,
|
|
|
|
&twl4030_dapm_earpiece_controls[0],
|
|
|
|
ARRAY_SIZE(twl4030_dapm_earpiece_controls)),
|
2009-08-13 12:59:34 +00:00
|
|
|
SND_SOC_DAPM_PGA_E("Earpiece PGA", SND_SOC_NOPM,
|
|
|
|
0, 0, NULL, 0, earpiecepga_event,
|
|
|
|
SND_SOC_DAPM_POST_PMU|SND_SOC_DAPM_POST_PMD),
|
2008-12-09 10:35:48 +00:00
|
|
|
/* PreDrivL/R */
|
2009-04-22 04:13:34 +00:00
|
|
|
SND_SOC_DAPM_MIXER("PredriveL Mixer", SND_SOC_NOPM, 0, 0,
|
|
|
|
&twl4030_dapm_predrivel_controls[0],
|
|
|
|
ARRAY_SIZE(twl4030_dapm_predrivel_controls)),
|
2009-08-13 12:59:34 +00:00
|
|
|
SND_SOC_DAPM_PGA_E("PredriveL PGA", SND_SOC_NOPM,
|
|
|
|
0, 0, NULL, 0, predrivelpga_event,
|
|
|
|
SND_SOC_DAPM_POST_PMU|SND_SOC_DAPM_POST_PMD),
|
2009-04-22 04:13:34 +00:00
|
|
|
SND_SOC_DAPM_MIXER("PredriveR Mixer", SND_SOC_NOPM, 0, 0,
|
|
|
|
&twl4030_dapm_predriver_controls[0],
|
|
|
|
ARRAY_SIZE(twl4030_dapm_predriver_controls)),
|
2009-08-13 12:59:34 +00:00
|
|
|
SND_SOC_DAPM_PGA_E("PredriveR PGA", SND_SOC_NOPM,
|
|
|
|
0, 0, NULL, 0, predriverpga_event,
|
|
|
|
SND_SOC_DAPM_POST_PMU|SND_SOC_DAPM_POST_PMD),
|
2008-12-09 10:35:49 +00:00
|
|
|
/* HeadsetL/R */
|
2009-05-18 13:02:05 +00:00
|
|
|
SND_SOC_DAPM_MIXER("HeadsetL Mixer", SND_SOC_NOPM, 0, 0,
|
2009-04-22 04:13:34 +00:00
|
|
|
&twl4030_dapm_hsol_controls[0],
|
2009-05-18 13:02:05 +00:00
|
|
|
ARRAY_SIZE(twl4030_dapm_hsol_controls)),
|
|
|
|
SND_SOC_DAPM_PGA_E("HeadsetL PGA", SND_SOC_NOPM,
|
|
|
|
0, 0, NULL, 0, headsetlpga_event,
|
2009-04-22 04:13:34 +00:00
|
|
|
SND_SOC_DAPM_POST_PMU|SND_SOC_DAPM_POST_PMD),
|
|
|
|
SND_SOC_DAPM_MIXER("HeadsetR Mixer", SND_SOC_NOPM, 0, 0,
|
|
|
|
&twl4030_dapm_hsor_controls[0],
|
|
|
|
ARRAY_SIZE(twl4030_dapm_hsor_controls)),
|
2009-05-18 13:02:05 +00:00
|
|
|
SND_SOC_DAPM_PGA_E("HeadsetR PGA", SND_SOC_NOPM,
|
|
|
|
0, 0, NULL, 0, headsetrpga_event,
|
|
|
|
SND_SOC_DAPM_POST_PMU|SND_SOC_DAPM_POST_PMD),
|
2008-12-09 10:35:50 +00:00
|
|
|
/* CarkitL/R */
|
2009-04-22 04:13:34 +00:00
|
|
|
SND_SOC_DAPM_MIXER("CarkitL Mixer", SND_SOC_NOPM, 0, 0,
|
|
|
|
&twl4030_dapm_carkitl_controls[0],
|
|
|
|
ARRAY_SIZE(twl4030_dapm_carkitl_controls)),
|
2009-08-13 12:59:34 +00:00
|
|
|
SND_SOC_DAPM_PGA_E("CarkitL PGA", SND_SOC_NOPM,
|
|
|
|
0, 0, NULL, 0, carkitlpga_event,
|
|
|
|
SND_SOC_DAPM_POST_PMU|SND_SOC_DAPM_POST_PMD),
|
2009-04-22 04:13:34 +00:00
|
|
|
SND_SOC_DAPM_MIXER("CarkitR Mixer", SND_SOC_NOPM, 0, 0,
|
|
|
|
&twl4030_dapm_carkitr_controls[0],
|
|
|
|
ARRAY_SIZE(twl4030_dapm_carkitr_controls)),
|
2009-08-13 12:59:34 +00:00
|
|
|
SND_SOC_DAPM_PGA_E("CarkitR PGA", SND_SOC_NOPM,
|
|
|
|
0, 0, NULL, 0, carkitrpga_event,
|
|
|
|
SND_SOC_DAPM_POST_PMU|SND_SOC_DAPM_POST_PMD),
|
2009-04-22 04:13:34 +00:00
|
|
|
|
|
|
|
/* Output MUX controls */
|
2008-12-09 10:35:51 +00:00
|
|
|
/* HandsfreeL/R */
|
2009-05-25 08:12:11 +00:00
|
|
|
SND_SOC_DAPM_MUX("HandsfreeL Mux", SND_SOC_NOPM, 0, 0,
|
|
|
|
&twl4030_dapm_handsfreel_control),
|
2009-06-25 17:36:14 +00:00
|
|
|
SND_SOC_DAPM_SWITCH("HandsfreeL", SND_SOC_NOPM, 0, 0,
|
2009-05-25 08:12:13 +00:00
|
|
|
&twl4030_dapm_handsfreelmute_control),
|
2009-05-25 08:12:11 +00:00
|
|
|
SND_SOC_DAPM_PGA_E("HandsfreeL PGA", SND_SOC_NOPM,
|
|
|
|
0, 0, NULL, 0, handsfreelpga_event,
|
|
|
|
SND_SOC_DAPM_POST_PMU|SND_SOC_DAPM_POST_PMD),
|
|
|
|
SND_SOC_DAPM_MUX("HandsfreeR Mux", SND_SOC_NOPM, 5, 0,
|
|
|
|
&twl4030_dapm_handsfreer_control),
|
2009-06-25 17:36:14 +00:00
|
|
|
SND_SOC_DAPM_SWITCH("HandsfreeR", SND_SOC_NOPM, 0, 0,
|
2009-05-25 08:12:13 +00:00
|
|
|
&twl4030_dapm_handsfreermute_control),
|
2009-05-25 08:12:11 +00:00
|
|
|
SND_SOC_DAPM_PGA_E("HandsfreeR PGA", SND_SOC_NOPM,
|
|
|
|
0, 0, NULL, 0, handsfreerpga_event,
|
|
|
|
SND_SOC_DAPM_POST_PMU|SND_SOC_DAPM_POST_PMD),
|
2009-05-05 05:55:47 +00:00
|
|
|
/* Vibra */
|
2009-10-29 09:58:09 +00:00
|
|
|
SND_SOC_DAPM_MUX_E("Vibra Mux", TWL4030_REG_VIBRA_CTL, 0, 0,
|
|
|
|
&twl4030_dapm_vibra_control, vibramux_event,
|
|
|
|
SND_SOC_DAPM_PRE_PMU),
|
2009-05-05 05:55:47 +00:00
|
|
|
SND_SOC_DAPM_MUX("Vibra Route", SND_SOC_NOPM, 0, 0,
|
|
|
|
&twl4030_dapm_vibrapath_control),
|
2008-12-09 10:35:47 +00:00
|
|
|
|
ASoC: TWL4030: DAPM based capture implementation
This patch adds DAPM implementaion for the capture path
on twlx030.
TWL has two physical ADC and two digital microphone (stereo) connections.
The CPU interface has four microphone channels.
For simplicity the microphone channel paths are named as:
TX1 (Left/Right) - when using i2s mode, only the TX1 data is valid
TX2 (Left/Right)
Input routing (simplified version):
There is two levels of mux settings for TWL in input path:
Analog input mux:
ADCL <- {Off, Main mic, Headset mic, AUXL, Carkit mic}
ADCR <- {Off, Sub mic, AUXR}
Analog/Digital mux:
TX1 Analog mode:
TX1L <- ADCL
TX1R <- ADCR
TX1 Digital mode:
TX1L <- Digimic0 (Left)
TX1R <- Digimic0 (Right)
TX2 Analog mode:
TX2L <- ADCL
TX2R <- ADCR
TX2 Digital mode:
TX2L <- Digimic1 (Left)
TX2R <- Digimic1 (Right)
The patch provides the following user controls for the capture path:
Mux settings:
"TX1 Capture Route": {Analog, Digimic0}
"TX2 Capture Route": {Analog, Digimic1}
"Analog Left Capture Route": {Off, Main Mic, Headset Mic, AUXL, Carkit Mic}
"Analog Right Capture Route": {Off, Sub Mic, AUXR}
Volume/Gain controls:
"TX1 Digital Capture Volume": Stereo gain control for TX1 path
"TX2 Digital Capture Volume": Stereo gain control for TX2 path
"Analog Capture Volume": Stereo gain control for the analog path only
Important things for the board files:
Microphone bias:
"Mic Bias 1": Bias for Main mic or for digimic0 (analog or digital path)
"Mic Bias 2": Bias for Sub mic or for digimic1 (analog or digital path)
"Headset Mic Bias": Bias for Headset mic
When the routing configured correctly only the needed components will be
powered/enabled.
Signed-off-by: Peter Ujfalusi <peter.ujfalusi@nokia.com>
Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
2008-12-31 08:08:38 +00:00
|
|
|
/* Introducing four virtual ADC, since TWL4030 have four channel for
|
|
|
|
capture */
|
2012-09-20 13:32:02 +00:00
|
|
|
SND_SOC_DAPM_ADC("ADC Virtual Left1", NULL, SND_SOC_NOPM, 0, 0),
|
|
|
|
SND_SOC_DAPM_ADC("ADC Virtual Right1", NULL, SND_SOC_NOPM, 0, 0),
|
|
|
|
SND_SOC_DAPM_ADC("ADC Virtual Left2", NULL, SND_SOC_NOPM, 0, 0),
|
|
|
|
SND_SOC_DAPM_ADC("ADC Virtual Right2", NULL, SND_SOC_NOPM, 0, 0),
|
ASoC: TWL4030: DAPM based capture implementation
This patch adds DAPM implementaion for the capture path
on twlx030.
TWL has two physical ADC and two digital microphone (stereo) connections.
The CPU interface has four microphone channels.
For simplicity the microphone channel paths are named as:
TX1 (Left/Right) - when using i2s mode, only the TX1 data is valid
TX2 (Left/Right)
Input routing (simplified version):
There is two levels of mux settings for TWL in input path:
Analog input mux:
ADCL <- {Off, Main mic, Headset mic, AUXL, Carkit mic}
ADCR <- {Off, Sub mic, AUXR}
Analog/Digital mux:
TX1 Analog mode:
TX1L <- ADCL
TX1R <- ADCR
TX1 Digital mode:
TX1L <- Digimic0 (Left)
TX1R <- Digimic0 (Right)
TX2 Analog mode:
TX2L <- ADCL
TX2R <- ADCR
TX2 Digital mode:
TX2L <- Digimic1 (Left)
TX2R <- Digimic1 (Right)
The patch provides the following user controls for the capture path:
Mux settings:
"TX1 Capture Route": {Analog, Digimic0}
"TX2 Capture Route": {Analog, Digimic1}
"Analog Left Capture Route": {Off, Main Mic, Headset Mic, AUXL, Carkit Mic}
"Analog Right Capture Route": {Off, Sub Mic, AUXR}
Volume/Gain controls:
"TX1 Digital Capture Volume": Stereo gain control for TX1 path
"TX2 Digital Capture Volume": Stereo gain control for TX2 path
"Analog Capture Volume": Stereo gain control for the analog path only
Important things for the board files:
Microphone bias:
"Mic Bias 1": Bias for Main mic or for digimic0 (analog or digital path)
"Mic Bias 2": Bias for Sub mic or for digimic1 (analog or digital path)
"Headset Mic Bias": Bias for Headset mic
When the routing configured correctly only the needed components will be
powered/enabled.
Signed-off-by: Peter Ujfalusi <peter.ujfalusi@nokia.com>
Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
2008-12-31 08:08:38 +00:00
|
|
|
|
2012-12-31 10:51:42 +00:00
|
|
|
SND_SOC_DAPM_AIF_OUT("VAIFOUT", "Voice Capture", 0,
|
|
|
|
TWL4030_REG_VOICE_IF, 5, 0),
|
|
|
|
|
ASoC: TWL4030: DAPM based capture implementation
This patch adds DAPM implementaion for the capture path
on twlx030.
TWL has two physical ADC and two digital microphone (stereo) connections.
The CPU interface has four microphone channels.
For simplicity the microphone channel paths are named as:
TX1 (Left/Right) - when using i2s mode, only the TX1 data is valid
TX2 (Left/Right)
Input routing (simplified version):
There is two levels of mux settings for TWL in input path:
Analog input mux:
ADCL <- {Off, Main mic, Headset mic, AUXL, Carkit mic}
ADCR <- {Off, Sub mic, AUXR}
Analog/Digital mux:
TX1 Analog mode:
TX1L <- ADCL
TX1R <- ADCR
TX1 Digital mode:
TX1L <- Digimic0 (Left)
TX1R <- Digimic0 (Right)
TX2 Analog mode:
TX2L <- ADCL
TX2R <- ADCR
TX2 Digital mode:
TX2L <- Digimic1 (Left)
TX2R <- Digimic1 (Right)
The patch provides the following user controls for the capture path:
Mux settings:
"TX1 Capture Route": {Analog, Digimic0}
"TX2 Capture Route": {Analog, Digimic1}
"Analog Left Capture Route": {Off, Main Mic, Headset Mic, AUXL, Carkit Mic}
"Analog Right Capture Route": {Off, Sub Mic, AUXR}
Volume/Gain controls:
"TX1 Digital Capture Volume": Stereo gain control for TX1 path
"TX2 Digital Capture Volume": Stereo gain control for TX2 path
"Analog Capture Volume": Stereo gain control for the analog path only
Important things for the board files:
Microphone bias:
"Mic Bias 1": Bias for Main mic or for digimic0 (analog or digital path)
"Mic Bias 2": Bias for Sub mic or for digimic1 (analog or digital path)
"Headset Mic Bias": Bias for Headset mic
When the routing configured correctly only the needed components will be
powered/enabled.
Signed-off-by: Peter Ujfalusi <peter.ujfalusi@nokia.com>
Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
2008-12-31 08:08:38 +00:00
|
|
|
/* Analog/Digital mic path selection.
|
|
|
|
TX1 Left/Right: either analog Left/Right or Digimic0
|
|
|
|
TX2 Left/Right: either analog Left/Right or Digimic1 */
|
2010-08-03 09:01:01 +00:00
|
|
|
SND_SOC_DAPM_MUX("TX1 Capture Route", SND_SOC_NOPM, 0, 0,
|
|
|
|
&twl4030_dapm_micpathtx1_control),
|
|
|
|
SND_SOC_DAPM_MUX("TX2 Capture Route", SND_SOC_NOPM, 0, 0,
|
|
|
|
&twl4030_dapm_micpathtx2_control),
|
ASoC: TWL4030: DAPM based capture implementation
This patch adds DAPM implementaion for the capture path
on twlx030.
TWL has two physical ADC and two digital microphone (stereo) connections.
The CPU interface has four microphone channels.
For simplicity the microphone channel paths are named as:
TX1 (Left/Right) - when using i2s mode, only the TX1 data is valid
TX2 (Left/Right)
Input routing (simplified version):
There is two levels of mux settings for TWL in input path:
Analog input mux:
ADCL <- {Off, Main mic, Headset mic, AUXL, Carkit mic}
ADCR <- {Off, Sub mic, AUXR}
Analog/Digital mux:
TX1 Analog mode:
TX1L <- ADCL
TX1R <- ADCR
TX1 Digital mode:
TX1L <- Digimic0 (Left)
TX1R <- Digimic0 (Right)
TX2 Analog mode:
TX2L <- ADCL
TX2R <- ADCR
TX2 Digital mode:
TX2L <- Digimic1 (Left)
TX2R <- Digimic1 (Right)
The patch provides the following user controls for the capture path:
Mux settings:
"TX1 Capture Route": {Analog, Digimic0}
"TX2 Capture Route": {Analog, Digimic1}
"Analog Left Capture Route": {Off, Main Mic, Headset Mic, AUXL, Carkit Mic}
"Analog Right Capture Route": {Off, Sub Mic, AUXR}
Volume/Gain controls:
"TX1 Digital Capture Volume": Stereo gain control for TX1 path
"TX2 Digital Capture Volume": Stereo gain control for TX2 path
"Analog Capture Volume": Stereo gain control for the analog path only
Important things for the board files:
Microphone bias:
"Mic Bias 1": Bias for Main mic or for digimic0 (analog or digital path)
"Mic Bias 2": Bias for Sub mic or for digimic1 (analog or digital path)
"Headset Mic Bias": Bias for Headset mic
When the routing configured correctly only the needed components will be
powered/enabled.
Signed-off-by: Peter Ujfalusi <peter.ujfalusi@nokia.com>
Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
2008-12-31 08:08:38 +00:00
|
|
|
|
2009-05-11 11:36:08 +00:00
|
|
|
/* Analog input mixers for the capture amplifiers */
|
2009-08-14 05:44:00 +00:00
|
|
|
SND_SOC_DAPM_MIXER("Analog Left",
|
2009-05-11 11:36:08 +00:00
|
|
|
TWL4030_REG_ANAMICL, 4, 0,
|
|
|
|
&twl4030_dapm_analoglmic_controls[0],
|
|
|
|
ARRAY_SIZE(twl4030_dapm_analoglmic_controls)),
|
2009-08-14 05:44:00 +00:00
|
|
|
SND_SOC_DAPM_MIXER("Analog Right",
|
2009-05-11 11:36:08 +00:00
|
|
|
TWL4030_REG_ANAMICR, 4, 0,
|
|
|
|
&twl4030_dapm_analogrmic_controls[0],
|
|
|
|
ARRAY_SIZE(twl4030_dapm_analogrmic_controls)),
|
ASoC: TWL4030: DAPM based capture implementation
This patch adds DAPM implementaion for the capture path
on twlx030.
TWL has two physical ADC and two digital microphone (stereo) connections.
The CPU interface has four microphone channels.
For simplicity the microphone channel paths are named as:
TX1 (Left/Right) - when using i2s mode, only the TX1 data is valid
TX2 (Left/Right)
Input routing (simplified version):
There is two levels of mux settings for TWL in input path:
Analog input mux:
ADCL <- {Off, Main mic, Headset mic, AUXL, Carkit mic}
ADCR <- {Off, Sub mic, AUXR}
Analog/Digital mux:
TX1 Analog mode:
TX1L <- ADCL
TX1R <- ADCR
TX1 Digital mode:
TX1L <- Digimic0 (Left)
TX1R <- Digimic0 (Right)
TX2 Analog mode:
TX2L <- ADCL
TX2R <- ADCR
TX2 Digital mode:
TX2L <- Digimic1 (Left)
TX2R <- Digimic1 (Right)
The patch provides the following user controls for the capture path:
Mux settings:
"TX1 Capture Route": {Analog, Digimic0}
"TX2 Capture Route": {Analog, Digimic1}
"Analog Left Capture Route": {Off, Main Mic, Headset Mic, AUXL, Carkit Mic}
"Analog Right Capture Route": {Off, Sub Mic, AUXR}
Volume/Gain controls:
"TX1 Digital Capture Volume": Stereo gain control for TX1 path
"TX2 Digital Capture Volume": Stereo gain control for TX2 path
"Analog Capture Volume": Stereo gain control for the analog path only
Important things for the board files:
Microphone bias:
"Mic Bias 1": Bias for Main mic or for digimic0 (analog or digital path)
"Mic Bias 2": Bias for Sub mic or for digimic1 (analog or digital path)
"Headset Mic Bias": Bias for Headset mic
When the routing configured correctly only the needed components will be
powered/enabled.
Signed-off-by: Peter Ujfalusi <peter.ujfalusi@nokia.com>
Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
2008-12-31 08:08:38 +00:00
|
|
|
|
2009-01-27 09:29:42 +00:00
|
|
|
SND_SOC_DAPM_PGA("ADC Physical Left",
|
|
|
|
TWL4030_REG_AVADC_CTL, 3, 0, NULL, 0),
|
|
|
|
SND_SOC_DAPM_PGA("ADC Physical Right",
|
|
|
|
TWL4030_REG_AVADC_CTL, 1, 0, NULL, 0),
|
ASoC: TWL4030: DAPM based capture implementation
This patch adds DAPM implementaion for the capture path
on twlx030.
TWL has two physical ADC and two digital microphone (stereo) connections.
The CPU interface has four microphone channels.
For simplicity the microphone channel paths are named as:
TX1 (Left/Right) - when using i2s mode, only the TX1 data is valid
TX2 (Left/Right)
Input routing (simplified version):
There is two levels of mux settings for TWL in input path:
Analog input mux:
ADCL <- {Off, Main mic, Headset mic, AUXL, Carkit mic}
ADCR <- {Off, Sub mic, AUXR}
Analog/Digital mux:
TX1 Analog mode:
TX1L <- ADCL
TX1R <- ADCR
TX1 Digital mode:
TX1L <- Digimic0 (Left)
TX1R <- Digimic0 (Right)
TX2 Analog mode:
TX2L <- ADCL
TX2R <- ADCR
TX2 Digital mode:
TX2L <- Digimic1 (Left)
TX2R <- Digimic1 (Right)
The patch provides the following user controls for the capture path:
Mux settings:
"TX1 Capture Route": {Analog, Digimic0}
"TX2 Capture Route": {Analog, Digimic1}
"Analog Left Capture Route": {Off, Main Mic, Headset Mic, AUXL, Carkit Mic}
"Analog Right Capture Route": {Off, Sub Mic, AUXR}
Volume/Gain controls:
"TX1 Digital Capture Volume": Stereo gain control for TX1 path
"TX2 Digital Capture Volume": Stereo gain control for TX2 path
"Analog Capture Volume": Stereo gain control for the analog path only
Important things for the board files:
Microphone bias:
"Mic Bias 1": Bias for Main mic or for digimic0 (analog or digital path)
"Mic Bias 2": Bias for Sub mic or for digimic1 (analog or digital path)
"Headset Mic Bias": Bias for Headset mic
When the routing configured correctly only the needed components will be
powered/enabled.
Signed-off-by: Peter Ujfalusi <peter.ujfalusi@nokia.com>
Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
2008-12-31 08:08:38 +00:00
|
|
|
|
2010-07-20 12:49:09 +00:00
|
|
|
SND_SOC_DAPM_PGA_E("Digimic0 Enable",
|
|
|
|
TWL4030_REG_ADCMICSEL, 1, 0, NULL, 0,
|
|
|
|
digimic_event, SND_SOC_DAPM_POST_PMU),
|
|
|
|
SND_SOC_DAPM_PGA_E("Digimic1 Enable",
|
|
|
|
TWL4030_REG_ADCMICSEL, 3, 0, NULL, 0,
|
|
|
|
digimic_event, SND_SOC_DAPM_POST_PMU),
|
ASoC: TWL4030: DAPM based capture implementation
This patch adds DAPM implementaion for the capture path
on twlx030.
TWL has two physical ADC and two digital microphone (stereo) connections.
The CPU interface has four microphone channels.
For simplicity the microphone channel paths are named as:
TX1 (Left/Right) - when using i2s mode, only the TX1 data is valid
TX2 (Left/Right)
Input routing (simplified version):
There is two levels of mux settings for TWL in input path:
Analog input mux:
ADCL <- {Off, Main mic, Headset mic, AUXL, Carkit mic}
ADCR <- {Off, Sub mic, AUXR}
Analog/Digital mux:
TX1 Analog mode:
TX1L <- ADCL
TX1R <- ADCR
TX1 Digital mode:
TX1L <- Digimic0 (Left)
TX1R <- Digimic0 (Right)
TX2 Analog mode:
TX2L <- ADCL
TX2R <- ADCR
TX2 Digital mode:
TX2L <- Digimic1 (Left)
TX2R <- Digimic1 (Right)
The patch provides the following user controls for the capture path:
Mux settings:
"TX1 Capture Route": {Analog, Digimic0}
"TX2 Capture Route": {Analog, Digimic1}
"Analog Left Capture Route": {Off, Main Mic, Headset Mic, AUXL, Carkit Mic}
"Analog Right Capture Route": {Off, Sub Mic, AUXR}
Volume/Gain controls:
"TX1 Digital Capture Volume": Stereo gain control for TX1 path
"TX2 Digital Capture Volume": Stereo gain control for TX2 path
"Analog Capture Volume": Stereo gain control for the analog path only
Important things for the board files:
Microphone bias:
"Mic Bias 1": Bias for Main mic or for digimic0 (analog or digital path)
"Mic Bias 2": Bias for Sub mic or for digimic1 (analog or digital path)
"Headset Mic Bias": Bias for Headset mic
When the routing configured correctly only the needed components will be
powered/enabled.
Signed-off-by: Peter Ujfalusi <peter.ujfalusi@nokia.com>
Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
2008-12-31 08:08:38 +00:00
|
|
|
|
2010-08-03 09:01:01 +00:00
|
|
|
SND_SOC_DAPM_SUPPLY("micbias1 select", TWL4030_REG_MICBIAS_CTL, 5, 0,
|
|
|
|
NULL, 0),
|
|
|
|
SND_SOC_DAPM_SUPPLY("micbias2 select", TWL4030_REG_MICBIAS_CTL, 6, 0,
|
|
|
|
NULL, 0),
|
|
|
|
|
2012-12-31 10:51:45 +00:00
|
|
|
/* Microphone bias */
|
|
|
|
SND_SOC_DAPM_SUPPLY("Mic Bias 1",
|
|
|
|
TWL4030_REG_MICBIAS_CTL, 0, 0, NULL, 0),
|
|
|
|
SND_SOC_DAPM_SUPPLY("Mic Bias 2",
|
|
|
|
TWL4030_REG_MICBIAS_CTL, 1, 0, NULL, 0),
|
|
|
|
SND_SOC_DAPM_SUPPLY("Headset Mic Bias",
|
|
|
|
TWL4030_REG_MICBIAS_CTL, 2, 0, NULL, 0),
|
2009-01-29 12:57:50 +00:00
|
|
|
|
2012-12-31 10:51:42 +00:00
|
|
|
SND_SOC_DAPM_SUPPLY("VIF Enable", TWL4030_REG_VOICE_IF, 0, 0, NULL, 0),
|
2008-10-31 04:35:26 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
static const struct snd_soc_dapm_route intercon[] = {
|
2012-09-20 13:32:02 +00:00
|
|
|
/* Stream -> DAC mapping */
|
|
|
|
{"DAC Right1", NULL, "HiFi Playback"},
|
|
|
|
{"DAC Left1", NULL, "HiFi Playback"},
|
|
|
|
{"DAC Right2", NULL, "HiFi Playback"},
|
|
|
|
{"DAC Left2", NULL, "HiFi Playback"},
|
2012-12-31 10:51:42 +00:00
|
|
|
{"DAC Voice", NULL, "VAIFIN"},
|
2012-09-20 13:32:02 +00:00
|
|
|
|
|
|
|
/* ADC -> Stream mapping */
|
|
|
|
{"HiFi Capture", NULL, "ADC Virtual Left1"},
|
|
|
|
{"HiFi Capture", NULL, "ADC Virtual Right1"},
|
|
|
|
{"HiFi Capture", NULL, "ADC Virtual Left2"},
|
|
|
|
{"HiFi Capture", NULL, "ADC Virtual Right2"},
|
2012-12-31 10:51:42 +00:00
|
|
|
{"VAIFOUT", NULL, "ADC Virtual Left2"},
|
|
|
|
{"VAIFOUT", NULL, "ADC Virtual Right2"},
|
|
|
|
{"VAIFOUT", NULL, "VIF Enable"},
|
2012-09-20 13:32:02 +00:00
|
|
|
|
2009-05-18 13:02:04 +00:00
|
|
|
{"Digital L1 Playback Mixer", NULL, "DAC Left1"},
|
|
|
|
{"Digital R1 Playback Mixer", NULL, "DAC Right1"},
|
|
|
|
{"Digital L2 Playback Mixer", NULL, "DAC Left2"},
|
|
|
|
{"Digital R2 Playback Mixer", NULL, "DAC Right2"},
|
|
|
|
{"Digital Voice Playback Mixer", NULL, "DAC Voice"},
|
|
|
|
|
2009-10-29 09:58:10 +00:00
|
|
|
/* Supply for the digital part (APLL) */
|
|
|
|
{"Digital Voice Playback Mixer", NULL, "APLL Enable"},
|
|
|
|
|
2010-07-13 09:07:44 +00:00
|
|
|
{"DAC Left1", NULL, "AIF Enable"},
|
|
|
|
{"DAC Right1", NULL, "AIF Enable"},
|
|
|
|
{"DAC Left2", NULL, "AIF Enable"},
|
|
|
|
{"DAC Right1", NULL, "AIF Enable"},
|
2012-12-31 10:51:42 +00:00
|
|
|
{"DAC Voice", NULL, "VIF Enable"},
|
2010-07-13 09:07:44 +00:00
|
|
|
|
2010-02-09 13:24:04 +00:00
|
|
|
{"Digital R2 Playback Mixer", NULL, "AIF Enable"},
|
|
|
|
{"Digital L2 Playback Mixer", NULL, "AIF Enable"},
|
|
|
|
|
2009-05-18 13:02:04 +00:00
|
|
|
{"Analog L1 Playback Mixer", NULL, "Digital L1 Playback Mixer"},
|
|
|
|
{"Analog R1 Playback Mixer", NULL, "Digital R1 Playback Mixer"},
|
|
|
|
{"Analog L2 Playback Mixer", NULL, "Digital L2 Playback Mixer"},
|
|
|
|
{"Analog R2 Playback Mixer", NULL, "Digital R2 Playback Mixer"},
|
|
|
|
{"Analog Voice Playback Mixer", NULL, "Digital Voice Playback Mixer"},
|
2009-04-22 04:13:34 +00:00
|
|
|
|
2008-12-09 10:35:47 +00:00
|
|
|
/* Internal playback routings */
|
|
|
|
/* Earpiece */
|
2009-05-18 13:02:04 +00:00
|
|
|
{"Earpiece Mixer", "Voice", "Analog Voice Playback Mixer"},
|
|
|
|
{"Earpiece Mixer", "AudioL1", "Analog L1 Playback Mixer"},
|
|
|
|
{"Earpiece Mixer", "AudioL2", "Analog L2 Playback Mixer"},
|
|
|
|
{"Earpiece Mixer", "AudioR1", "Analog R1 Playback Mixer"},
|
2009-08-13 12:59:34 +00:00
|
|
|
{"Earpiece PGA", NULL, "Earpiece Mixer"},
|
2008-12-09 10:35:48 +00:00
|
|
|
/* PreDrivL */
|
2009-05-18 13:02:04 +00:00
|
|
|
{"PredriveL Mixer", "Voice", "Analog Voice Playback Mixer"},
|
|
|
|
{"PredriveL Mixer", "AudioL1", "Analog L1 Playback Mixer"},
|
|
|
|
{"PredriveL Mixer", "AudioL2", "Analog L2 Playback Mixer"},
|
|
|
|
{"PredriveL Mixer", "AudioR2", "Analog R2 Playback Mixer"},
|
2009-08-13 12:59:34 +00:00
|
|
|
{"PredriveL PGA", NULL, "PredriveL Mixer"},
|
2008-12-09 10:35:48 +00:00
|
|
|
/* PreDrivR */
|
2009-05-18 13:02:04 +00:00
|
|
|
{"PredriveR Mixer", "Voice", "Analog Voice Playback Mixer"},
|
|
|
|
{"PredriveR Mixer", "AudioR1", "Analog R1 Playback Mixer"},
|
|
|
|
{"PredriveR Mixer", "AudioR2", "Analog R2 Playback Mixer"},
|
|
|
|
{"PredriveR Mixer", "AudioL2", "Analog L2 Playback Mixer"},
|
2009-08-13 12:59:34 +00:00
|
|
|
{"PredriveR PGA", NULL, "PredriveR Mixer"},
|
2008-12-09 10:35:49 +00:00
|
|
|
/* HeadsetL */
|
2009-05-18 13:02:04 +00:00
|
|
|
{"HeadsetL Mixer", "Voice", "Analog Voice Playback Mixer"},
|
|
|
|
{"HeadsetL Mixer", "AudioL1", "Analog L1 Playback Mixer"},
|
|
|
|
{"HeadsetL Mixer", "AudioL2", "Analog L2 Playback Mixer"},
|
2009-05-18 13:02:05 +00:00
|
|
|
{"HeadsetL PGA", NULL, "HeadsetL Mixer"},
|
2008-12-09 10:35:49 +00:00
|
|
|
/* HeadsetR */
|
2009-05-18 13:02:04 +00:00
|
|
|
{"HeadsetR Mixer", "Voice", "Analog Voice Playback Mixer"},
|
|
|
|
{"HeadsetR Mixer", "AudioR1", "Analog R1 Playback Mixer"},
|
|
|
|
{"HeadsetR Mixer", "AudioR2", "Analog R2 Playback Mixer"},
|
2009-05-18 13:02:05 +00:00
|
|
|
{"HeadsetR PGA", NULL, "HeadsetR Mixer"},
|
2008-12-09 10:35:50 +00:00
|
|
|
/* CarkitL */
|
2009-05-18 13:02:04 +00:00
|
|
|
{"CarkitL Mixer", "Voice", "Analog Voice Playback Mixer"},
|
|
|
|
{"CarkitL Mixer", "AudioL1", "Analog L1 Playback Mixer"},
|
|
|
|
{"CarkitL Mixer", "AudioL2", "Analog L2 Playback Mixer"},
|
2009-08-13 12:59:34 +00:00
|
|
|
{"CarkitL PGA", NULL, "CarkitL Mixer"},
|
2008-12-09 10:35:50 +00:00
|
|
|
/* CarkitR */
|
2009-05-18 13:02:04 +00:00
|
|
|
{"CarkitR Mixer", "Voice", "Analog Voice Playback Mixer"},
|
|
|
|
{"CarkitR Mixer", "AudioR1", "Analog R1 Playback Mixer"},
|
|
|
|
{"CarkitR Mixer", "AudioR2", "Analog R2 Playback Mixer"},
|
2009-08-13 12:59:34 +00:00
|
|
|
{"CarkitR PGA", NULL, "CarkitR Mixer"},
|
2008-12-09 10:35:51 +00:00
|
|
|
/* HandsfreeL */
|
2009-05-18 13:02:04 +00:00
|
|
|
{"HandsfreeL Mux", "Voice", "Analog Voice Playback Mixer"},
|
|
|
|
{"HandsfreeL Mux", "AudioL1", "Analog L1 Playback Mixer"},
|
|
|
|
{"HandsfreeL Mux", "AudioL2", "Analog L2 Playback Mixer"},
|
|
|
|
{"HandsfreeL Mux", "AudioR2", "Analog R2 Playback Mixer"},
|
2009-06-25 17:36:14 +00:00
|
|
|
{"HandsfreeL", "Switch", "HandsfreeL Mux"},
|
|
|
|
{"HandsfreeL PGA", NULL, "HandsfreeL"},
|
2008-12-09 10:35:51 +00:00
|
|
|
/* HandsfreeR */
|
2009-05-18 13:02:04 +00:00
|
|
|
{"HandsfreeR Mux", "Voice", "Analog Voice Playback Mixer"},
|
|
|
|
{"HandsfreeR Mux", "AudioR1", "Analog R1 Playback Mixer"},
|
|
|
|
{"HandsfreeR Mux", "AudioR2", "Analog R2 Playback Mixer"},
|
|
|
|
{"HandsfreeR Mux", "AudioL2", "Analog L2 Playback Mixer"},
|
2009-06-25 17:36:14 +00:00
|
|
|
{"HandsfreeR", "Switch", "HandsfreeR Mux"},
|
|
|
|
{"HandsfreeR PGA", NULL, "HandsfreeR"},
|
2009-05-05 05:55:47 +00:00
|
|
|
/* Vibra */
|
|
|
|
{"Vibra Mux", "AudioL1", "DAC Left1"},
|
|
|
|
{"Vibra Mux", "AudioR1", "DAC Right1"},
|
|
|
|
{"Vibra Mux", "AudioL2", "DAC Left2"},
|
|
|
|
{"Vibra Mux", "AudioR2", "DAC Right2"},
|
2008-12-09 10:35:47 +00:00
|
|
|
|
2008-10-31 04:35:26 +00:00
|
|
|
/* outputs */
|
2010-04-29 07:58:08 +00:00
|
|
|
/* Must be always connected (for AIF and APLL) */
|
2010-07-13 09:07:44 +00:00
|
|
|
{"Virtual HiFi OUT", NULL, "DAC Left1"},
|
|
|
|
{"Virtual HiFi OUT", NULL, "DAC Right1"},
|
|
|
|
{"Virtual HiFi OUT", NULL, "DAC Left2"},
|
|
|
|
{"Virtual HiFi OUT", NULL, "DAC Right2"},
|
2010-04-29 07:58:08 +00:00
|
|
|
/* Must be always connected (for APLL) */
|
|
|
|
{"Virtual Voice OUT", NULL, "Digital Voice Playback Mixer"},
|
|
|
|
/* Physical outputs */
|
2009-08-13 12:59:34 +00:00
|
|
|
{"EARPIECE", NULL, "Earpiece PGA"},
|
|
|
|
{"PREDRIVEL", NULL, "PredriveL PGA"},
|
|
|
|
{"PREDRIVER", NULL, "PredriveR PGA"},
|
2009-05-18 13:02:05 +00:00
|
|
|
{"HSOL", NULL, "HeadsetL PGA"},
|
|
|
|
{"HSOR", NULL, "HeadsetR PGA"},
|
2009-08-13 12:59:34 +00:00
|
|
|
{"CARKITL", NULL, "CarkitL PGA"},
|
|
|
|
{"CARKITR", NULL, "CarkitR PGA"},
|
2009-05-25 08:12:11 +00:00
|
|
|
{"HFL", NULL, "HandsfreeL PGA"},
|
|
|
|
{"HFR", NULL, "HandsfreeR PGA"},
|
2009-05-05 05:55:47 +00:00
|
|
|
{"Vibra Route", "Audio", "Vibra Mux"},
|
|
|
|
{"VIBRA", NULL, "Vibra Route"},
|
2008-10-31 04:35:26 +00:00
|
|
|
|
ASoC: TWL4030: DAPM based capture implementation
This patch adds DAPM implementaion for the capture path
on twlx030.
TWL has two physical ADC and two digital microphone (stereo) connections.
The CPU interface has four microphone channels.
For simplicity the microphone channel paths are named as:
TX1 (Left/Right) - when using i2s mode, only the TX1 data is valid
TX2 (Left/Right)
Input routing (simplified version):
There is two levels of mux settings for TWL in input path:
Analog input mux:
ADCL <- {Off, Main mic, Headset mic, AUXL, Carkit mic}
ADCR <- {Off, Sub mic, AUXR}
Analog/Digital mux:
TX1 Analog mode:
TX1L <- ADCL
TX1R <- ADCR
TX1 Digital mode:
TX1L <- Digimic0 (Left)
TX1R <- Digimic0 (Right)
TX2 Analog mode:
TX2L <- ADCL
TX2R <- ADCR
TX2 Digital mode:
TX2L <- Digimic1 (Left)
TX2R <- Digimic1 (Right)
The patch provides the following user controls for the capture path:
Mux settings:
"TX1 Capture Route": {Analog, Digimic0}
"TX2 Capture Route": {Analog, Digimic1}
"Analog Left Capture Route": {Off, Main Mic, Headset Mic, AUXL, Carkit Mic}
"Analog Right Capture Route": {Off, Sub Mic, AUXR}
Volume/Gain controls:
"TX1 Digital Capture Volume": Stereo gain control for TX1 path
"TX2 Digital Capture Volume": Stereo gain control for TX2 path
"Analog Capture Volume": Stereo gain control for the analog path only
Important things for the board files:
Microphone bias:
"Mic Bias 1": Bias for Main mic or for digimic0 (analog or digital path)
"Mic Bias 2": Bias for Sub mic or for digimic1 (analog or digital path)
"Headset Mic Bias": Bias for Headset mic
When the routing configured correctly only the needed components will be
powered/enabled.
Signed-off-by: Peter Ujfalusi <peter.ujfalusi@nokia.com>
Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
2008-12-31 08:08:38 +00:00
|
|
|
/* Capture path */
|
2010-04-29 07:58:08 +00:00
|
|
|
/* Must be always connected (for AIF and APLL) */
|
|
|
|
{"ADC Virtual Left1", NULL, "Virtual HiFi IN"},
|
|
|
|
{"ADC Virtual Right1", NULL, "Virtual HiFi IN"},
|
|
|
|
{"ADC Virtual Left2", NULL, "Virtual HiFi IN"},
|
|
|
|
{"ADC Virtual Right2", NULL, "Virtual HiFi IN"},
|
|
|
|
/* Physical inputs */
|
2009-08-14 05:44:00 +00:00
|
|
|
{"Analog Left", "Main Mic Capture Switch", "MAINMIC"},
|
|
|
|
{"Analog Left", "Headset Mic Capture Switch", "HSMIC"},
|
|
|
|
{"Analog Left", "AUXL Capture Switch", "AUXL"},
|
|
|
|
{"Analog Left", "Carkit Mic Capture Switch", "CARKITMIC"},
|
ASoC: TWL4030: DAPM based capture implementation
This patch adds DAPM implementaion for the capture path
on twlx030.
TWL has two physical ADC and two digital microphone (stereo) connections.
The CPU interface has four microphone channels.
For simplicity the microphone channel paths are named as:
TX1 (Left/Right) - when using i2s mode, only the TX1 data is valid
TX2 (Left/Right)
Input routing (simplified version):
There is two levels of mux settings for TWL in input path:
Analog input mux:
ADCL <- {Off, Main mic, Headset mic, AUXL, Carkit mic}
ADCR <- {Off, Sub mic, AUXR}
Analog/Digital mux:
TX1 Analog mode:
TX1L <- ADCL
TX1R <- ADCR
TX1 Digital mode:
TX1L <- Digimic0 (Left)
TX1R <- Digimic0 (Right)
TX2 Analog mode:
TX2L <- ADCL
TX2R <- ADCR
TX2 Digital mode:
TX2L <- Digimic1 (Left)
TX2R <- Digimic1 (Right)
The patch provides the following user controls for the capture path:
Mux settings:
"TX1 Capture Route": {Analog, Digimic0}
"TX2 Capture Route": {Analog, Digimic1}
"Analog Left Capture Route": {Off, Main Mic, Headset Mic, AUXL, Carkit Mic}
"Analog Right Capture Route": {Off, Sub Mic, AUXR}
Volume/Gain controls:
"TX1 Digital Capture Volume": Stereo gain control for TX1 path
"TX2 Digital Capture Volume": Stereo gain control for TX2 path
"Analog Capture Volume": Stereo gain control for the analog path only
Important things for the board files:
Microphone bias:
"Mic Bias 1": Bias for Main mic or for digimic0 (analog or digital path)
"Mic Bias 2": Bias for Sub mic or for digimic1 (analog or digital path)
"Headset Mic Bias": Bias for Headset mic
When the routing configured correctly only the needed components will be
powered/enabled.
Signed-off-by: Peter Ujfalusi <peter.ujfalusi@nokia.com>
Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
2008-12-31 08:08:38 +00:00
|
|
|
|
2009-08-14 05:44:00 +00:00
|
|
|
{"Analog Right", "Sub Mic Capture Switch", "SUBMIC"},
|
|
|
|
{"Analog Right", "AUXR Capture Switch", "AUXR"},
|
ASoC: TWL4030: DAPM based capture implementation
This patch adds DAPM implementaion for the capture path
on twlx030.
TWL has two physical ADC and two digital microphone (stereo) connections.
The CPU interface has four microphone channels.
For simplicity the microphone channel paths are named as:
TX1 (Left/Right) - when using i2s mode, only the TX1 data is valid
TX2 (Left/Right)
Input routing (simplified version):
There is two levels of mux settings for TWL in input path:
Analog input mux:
ADCL <- {Off, Main mic, Headset mic, AUXL, Carkit mic}
ADCR <- {Off, Sub mic, AUXR}
Analog/Digital mux:
TX1 Analog mode:
TX1L <- ADCL
TX1R <- ADCR
TX1 Digital mode:
TX1L <- Digimic0 (Left)
TX1R <- Digimic0 (Right)
TX2 Analog mode:
TX2L <- ADCL
TX2R <- ADCR
TX2 Digital mode:
TX2L <- Digimic1 (Left)
TX2R <- Digimic1 (Right)
The patch provides the following user controls for the capture path:
Mux settings:
"TX1 Capture Route": {Analog, Digimic0}
"TX2 Capture Route": {Analog, Digimic1}
"Analog Left Capture Route": {Off, Main Mic, Headset Mic, AUXL, Carkit Mic}
"Analog Right Capture Route": {Off, Sub Mic, AUXR}
Volume/Gain controls:
"TX1 Digital Capture Volume": Stereo gain control for TX1 path
"TX2 Digital Capture Volume": Stereo gain control for TX2 path
"Analog Capture Volume": Stereo gain control for the analog path only
Important things for the board files:
Microphone bias:
"Mic Bias 1": Bias for Main mic or for digimic0 (analog or digital path)
"Mic Bias 2": Bias for Sub mic or for digimic1 (analog or digital path)
"Headset Mic Bias": Bias for Headset mic
When the routing configured correctly only the needed components will be
powered/enabled.
Signed-off-by: Peter Ujfalusi <peter.ujfalusi@nokia.com>
Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
2008-12-31 08:08:38 +00:00
|
|
|
|
2009-08-14 05:44:00 +00:00
|
|
|
{"ADC Physical Left", NULL, "Analog Left"},
|
|
|
|
{"ADC Physical Right", NULL, "Analog Right"},
|
ASoC: TWL4030: DAPM based capture implementation
This patch adds DAPM implementaion for the capture path
on twlx030.
TWL has two physical ADC and two digital microphone (stereo) connections.
The CPU interface has four microphone channels.
For simplicity the microphone channel paths are named as:
TX1 (Left/Right) - when using i2s mode, only the TX1 data is valid
TX2 (Left/Right)
Input routing (simplified version):
There is two levels of mux settings for TWL in input path:
Analog input mux:
ADCL <- {Off, Main mic, Headset mic, AUXL, Carkit mic}
ADCR <- {Off, Sub mic, AUXR}
Analog/Digital mux:
TX1 Analog mode:
TX1L <- ADCL
TX1R <- ADCR
TX1 Digital mode:
TX1L <- Digimic0 (Left)
TX1R <- Digimic0 (Right)
TX2 Analog mode:
TX2L <- ADCL
TX2R <- ADCR
TX2 Digital mode:
TX2L <- Digimic1 (Left)
TX2R <- Digimic1 (Right)
The patch provides the following user controls for the capture path:
Mux settings:
"TX1 Capture Route": {Analog, Digimic0}
"TX2 Capture Route": {Analog, Digimic1}
"Analog Left Capture Route": {Off, Main Mic, Headset Mic, AUXL, Carkit Mic}
"Analog Right Capture Route": {Off, Sub Mic, AUXR}
Volume/Gain controls:
"TX1 Digital Capture Volume": Stereo gain control for TX1 path
"TX2 Digital Capture Volume": Stereo gain control for TX2 path
"Analog Capture Volume": Stereo gain control for the analog path only
Important things for the board files:
Microphone bias:
"Mic Bias 1": Bias for Main mic or for digimic0 (analog or digital path)
"Mic Bias 2": Bias for Sub mic or for digimic1 (analog or digital path)
"Headset Mic Bias": Bias for Headset mic
When the routing configured correctly only the needed components will be
powered/enabled.
Signed-off-by: Peter Ujfalusi <peter.ujfalusi@nokia.com>
Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
2008-12-31 08:08:38 +00:00
|
|
|
|
|
|
|
{"Digimic0 Enable", NULL, "DIGIMIC0"},
|
|
|
|
{"Digimic1 Enable", NULL, "DIGIMIC1"},
|
|
|
|
|
2010-08-03 09:01:01 +00:00
|
|
|
{"DIGIMIC0", NULL, "micbias1 select"},
|
|
|
|
{"DIGIMIC1", NULL, "micbias2 select"},
|
|
|
|
|
ASoC: TWL4030: DAPM based capture implementation
This patch adds DAPM implementaion for the capture path
on twlx030.
TWL has two physical ADC and two digital microphone (stereo) connections.
The CPU interface has four microphone channels.
For simplicity the microphone channel paths are named as:
TX1 (Left/Right) - when using i2s mode, only the TX1 data is valid
TX2 (Left/Right)
Input routing (simplified version):
There is two levels of mux settings for TWL in input path:
Analog input mux:
ADCL <- {Off, Main mic, Headset mic, AUXL, Carkit mic}
ADCR <- {Off, Sub mic, AUXR}
Analog/Digital mux:
TX1 Analog mode:
TX1L <- ADCL
TX1R <- ADCR
TX1 Digital mode:
TX1L <- Digimic0 (Left)
TX1R <- Digimic0 (Right)
TX2 Analog mode:
TX2L <- ADCL
TX2R <- ADCR
TX2 Digital mode:
TX2L <- Digimic1 (Left)
TX2R <- Digimic1 (Right)
The patch provides the following user controls for the capture path:
Mux settings:
"TX1 Capture Route": {Analog, Digimic0}
"TX2 Capture Route": {Analog, Digimic1}
"Analog Left Capture Route": {Off, Main Mic, Headset Mic, AUXL, Carkit Mic}
"Analog Right Capture Route": {Off, Sub Mic, AUXR}
Volume/Gain controls:
"TX1 Digital Capture Volume": Stereo gain control for TX1 path
"TX2 Digital Capture Volume": Stereo gain control for TX2 path
"Analog Capture Volume": Stereo gain control for the analog path only
Important things for the board files:
Microphone bias:
"Mic Bias 1": Bias for Main mic or for digimic0 (analog or digital path)
"Mic Bias 2": Bias for Sub mic or for digimic1 (analog or digital path)
"Headset Mic Bias": Bias for Headset mic
When the routing configured correctly only the needed components will be
powered/enabled.
Signed-off-by: Peter Ujfalusi <peter.ujfalusi@nokia.com>
Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
2008-12-31 08:08:38 +00:00
|
|
|
/* TX1 Left capture path */
|
2009-01-27 09:29:42 +00:00
|
|
|
{"TX1 Capture Route", "Analog", "ADC Physical Left"},
|
ASoC: TWL4030: DAPM based capture implementation
This patch adds DAPM implementaion for the capture path
on twlx030.
TWL has two physical ADC and two digital microphone (stereo) connections.
The CPU interface has four microphone channels.
For simplicity the microphone channel paths are named as:
TX1 (Left/Right) - when using i2s mode, only the TX1 data is valid
TX2 (Left/Right)
Input routing (simplified version):
There is two levels of mux settings for TWL in input path:
Analog input mux:
ADCL <- {Off, Main mic, Headset mic, AUXL, Carkit mic}
ADCR <- {Off, Sub mic, AUXR}
Analog/Digital mux:
TX1 Analog mode:
TX1L <- ADCL
TX1R <- ADCR
TX1 Digital mode:
TX1L <- Digimic0 (Left)
TX1R <- Digimic0 (Right)
TX2 Analog mode:
TX2L <- ADCL
TX2R <- ADCR
TX2 Digital mode:
TX2L <- Digimic1 (Left)
TX2R <- Digimic1 (Right)
The patch provides the following user controls for the capture path:
Mux settings:
"TX1 Capture Route": {Analog, Digimic0}
"TX2 Capture Route": {Analog, Digimic1}
"Analog Left Capture Route": {Off, Main Mic, Headset Mic, AUXL, Carkit Mic}
"Analog Right Capture Route": {Off, Sub Mic, AUXR}
Volume/Gain controls:
"TX1 Digital Capture Volume": Stereo gain control for TX1 path
"TX2 Digital Capture Volume": Stereo gain control for TX2 path
"Analog Capture Volume": Stereo gain control for the analog path only
Important things for the board files:
Microphone bias:
"Mic Bias 1": Bias for Main mic or for digimic0 (analog or digital path)
"Mic Bias 2": Bias for Sub mic or for digimic1 (analog or digital path)
"Headset Mic Bias": Bias for Headset mic
When the routing configured correctly only the needed components will be
powered/enabled.
Signed-off-by: Peter Ujfalusi <peter.ujfalusi@nokia.com>
Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
2008-12-31 08:08:38 +00:00
|
|
|
{"TX1 Capture Route", "Digimic0", "Digimic0 Enable"},
|
|
|
|
/* TX1 Right capture path */
|
2009-01-27 09:29:42 +00:00
|
|
|
{"TX1 Capture Route", "Analog", "ADC Physical Right"},
|
ASoC: TWL4030: DAPM based capture implementation
This patch adds DAPM implementaion for the capture path
on twlx030.
TWL has two physical ADC and two digital microphone (stereo) connections.
The CPU interface has four microphone channels.
For simplicity the microphone channel paths are named as:
TX1 (Left/Right) - when using i2s mode, only the TX1 data is valid
TX2 (Left/Right)
Input routing (simplified version):
There is two levels of mux settings for TWL in input path:
Analog input mux:
ADCL <- {Off, Main mic, Headset mic, AUXL, Carkit mic}
ADCR <- {Off, Sub mic, AUXR}
Analog/Digital mux:
TX1 Analog mode:
TX1L <- ADCL
TX1R <- ADCR
TX1 Digital mode:
TX1L <- Digimic0 (Left)
TX1R <- Digimic0 (Right)
TX2 Analog mode:
TX2L <- ADCL
TX2R <- ADCR
TX2 Digital mode:
TX2L <- Digimic1 (Left)
TX2R <- Digimic1 (Right)
The patch provides the following user controls for the capture path:
Mux settings:
"TX1 Capture Route": {Analog, Digimic0}
"TX2 Capture Route": {Analog, Digimic1}
"Analog Left Capture Route": {Off, Main Mic, Headset Mic, AUXL, Carkit Mic}
"Analog Right Capture Route": {Off, Sub Mic, AUXR}
Volume/Gain controls:
"TX1 Digital Capture Volume": Stereo gain control for TX1 path
"TX2 Digital Capture Volume": Stereo gain control for TX2 path
"Analog Capture Volume": Stereo gain control for the analog path only
Important things for the board files:
Microphone bias:
"Mic Bias 1": Bias for Main mic or for digimic0 (analog or digital path)
"Mic Bias 2": Bias for Sub mic or for digimic1 (analog or digital path)
"Headset Mic Bias": Bias for Headset mic
When the routing configured correctly only the needed components will be
powered/enabled.
Signed-off-by: Peter Ujfalusi <peter.ujfalusi@nokia.com>
Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
2008-12-31 08:08:38 +00:00
|
|
|
{"TX1 Capture Route", "Digimic0", "Digimic0 Enable"},
|
|
|
|
/* TX2 Left capture path */
|
2009-01-27 09:29:42 +00:00
|
|
|
{"TX2 Capture Route", "Analog", "ADC Physical Left"},
|
ASoC: TWL4030: DAPM based capture implementation
This patch adds DAPM implementaion for the capture path
on twlx030.
TWL has two physical ADC and two digital microphone (stereo) connections.
The CPU interface has four microphone channels.
For simplicity the microphone channel paths are named as:
TX1 (Left/Right) - when using i2s mode, only the TX1 data is valid
TX2 (Left/Right)
Input routing (simplified version):
There is two levels of mux settings for TWL in input path:
Analog input mux:
ADCL <- {Off, Main mic, Headset mic, AUXL, Carkit mic}
ADCR <- {Off, Sub mic, AUXR}
Analog/Digital mux:
TX1 Analog mode:
TX1L <- ADCL
TX1R <- ADCR
TX1 Digital mode:
TX1L <- Digimic0 (Left)
TX1R <- Digimic0 (Right)
TX2 Analog mode:
TX2L <- ADCL
TX2R <- ADCR
TX2 Digital mode:
TX2L <- Digimic1 (Left)
TX2R <- Digimic1 (Right)
The patch provides the following user controls for the capture path:
Mux settings:
"TX1 Capture Route": {Analog, Digimic0}
"TX2 Capture Route": {Analog, Digimic1}
"Analog Left Capture Route": {Off, Main Mic, Headset Mic, AUXL, Carkit Mic}
"Analog Right Capture Route": {Off, Sub Mic, AUXR}
Volume/Gain controls:
"TX1 Digital Capture Volume": Stereo gain control for TX1 path
"TX2 Digital Capture Volume": Stereo gain control for TX2 path
"Analog Capture Volume": Stereo gain control for the analog path only
Important things for the board files:
Microphone bias:
"Mic Bias 1": Bias for Main mic or for digimic0 (analog or digital path)
"Mic Bias 2": Bias for Sub mic or for digimic1 (analog or digital path)
"Headset Mic Bias": Bias for Headset mic
When the routing configured correctly only the needed components will be
powered/enabled.
Signed-off-by: Peter Ujfalusi <peter.ujfalusi@nokia.com>
Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
2008-12-31 08:08:38 +00:00
|
|
|
{"TX2 Capture Route", "Digimic1", "Digimic1 Enable"},
|
|
|
|
/* TX2 Right capture path */
|
2009-01-27 09:29:42 +00:00
|
|
|
{"TX2 Capture Route", "Analog", "ADC Physical Right"},
|
ASoC: TWL4030: DAPM based capture implementation
This patch adds DAPM implementaion for the capture path
on twlx030.
TWL has two physical ADC and two digital microphone (stereo) connections.
The CPU interface has four microphone channels.
For simplicity the microphone channel paths are named as:
TX1 (Left/Right) - when using i2s mode, only the TX1 data is valid
TX2 (Left/Right)
Input routing (simplified version):
There is two levels of mux settings for TWL in input path:
Analog input mux:
ADCL <- {Off, Main mic, Headset mic, AUXL, Carkit mic}
ADCR <- {Off, Sub mic, AUXR}
Analog/Digital mux:
TX1 Analog mode:
TX1L <- ADCL
TX1R <- ADCR
TX1 Digital mode:
TX1L <- Digimic0 (Left)
TX1R <- Digimic0 (Right)
TX2 Analog mode:
TX2L <- ADCL
TX2R <- ADCR
TX2 Digital mode:
TX2L <- Digimic1 (Left)
TX2R <- Digimic1 (Right)
The patch provides the following user controls for the capture path:
Mux settings:
"TX1 Capture Route": {Analog, Digimic0}
"TX2 Capture Route": {Analog, Digimic1}
"Analog Left Capture Route": {Off, Main Mic, Headset Mic, AUXL, Carkit Mic}
"Analog Right Capture Route": {Off, Sub Mic, AUXR}
Volume/Gain controls:
"TX1 Digital Capture Volume": Stereo gain control for TX1 path
"TX2 Digital Capture Volume": Stereo gain control for TX2 path
"Analog Capture Volume": Stereo gain control for the analog path only
Important things for the board files:
Microphone bias:
"Mic Bias 1": Bias for Main mic or for digimic0 (analog or digital path)
"Mic Bias 2": Bias for Sub mic or for digimic1 (analog or digital path)
"Headset Mic Bias": Bias for Headset mic
When the routing configured correctly only the needed components will be
powered/enabled.
Signed-off-by: Peter Ujfalusi <peter.ujfalusi@nokia.com>
Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
2008-12-31 08:08:38 +00:00
|
|
|
{"TX2 Capture Route", "Digimic1", "Digimic1 Enable"},
|
|
|
|
|
|
|
|
{"ADC Virtual Left1", NULL, "TX1 Capture Route"},
|
|
|
|
{"ADC Virtual Right1", NULL, "TX1 Capture Route"},
|
|
|
|
{"ADC Virtual Left2", NULL, "TX2 Capture Route"},
|
|
|
|
{"ADC Virtual Right2", NULL, "TX2 Capture Route"},
|
|
|
|
|
2010-02-09 13:24:04 +00:00
|
|
|
{"ADC Virtual Left1", NULL, "AIF Enable"},
|
|
|
|
{"ADC Virtual Right1", NULL, "AIF Enable"},
|
|
|
|
{"ADC Virtual Left2", NULL, "AIF Enable"},
|
|
|
|
{"ADC Virtual Right2", NULL, "AIF Enable"},
|
|
|
|
|
2009-01-29 12:57:50 +00:00
|
|
|
/* Analog bypass routes */
|
2009-08-14 05:44:00 +00:00
|
|
|
{"Right1 Analog Loopback", "Switch", "Analog Right"},
|
|
|
|
{"Left1 Analog Loopback", "Switch", "Analog Left"},
|
|
|
|
{"Right2 Analog Loopback", "Switch", "Analog Right"},
|
|
|
|
{"Left2 Analog Loopback", "Switch", "Analog Left"},
|
|
|
|
{"Voice Analog Loopback", "Switch", "Analog Left"},
|
2009-01-29 12:57:50 +00:00
|
|
|
|
2009-10-28 08:57:04 +00:00
|
|
|
/* Supply for the Analog loopbacks */
|
|
|
|
{"Right1 Analog Loopback", NULL, "FM Loop Enable"},
|
|
|
|
{"Left1 Analog Loopback", NULL, "FM Loop Enable"},
|
|
|
|
{"Right2 Analog Loopback", NULL, "FM Loop Enable"},
|
|
|
|
{"Left2 Analog Loopback", NULL, "FM Loop Enable"},
|
|
|
|
{"Voice Analog Loopback", NULL, "FM Loop Enable"},
|
|
|
|
|
2009-01-29 12:57:50 +00:00
|
|
|
{"Analog R1 Playback Mixer", NULL, "Right1 Analog Loopback"},
|
|
|
|
{"Analog L1 Playback Mixer", NULL, "Left1 Analog Loopback"},
|
|
|
|
{"Analog R2 Playback Mixer", NULL, "Right2 Analog Loopback"},
|
|
|
|
{"Analog L2 Playback Mixer", NULL, "Left2 Analog Loopback"},
|
2009-05-01 02:47:22 +00:00
|
|
|
{"Analog Voice Playback Mixer", NULL, "Voice Analog Loopback"},
|
2009-01-29 12:57:50 +00:00
|
|
|
|
2009-02-18 12:39:05 +00:00
|
|
|
/* Digital bypass routes */
|
|
|
|
{"Right Digital Loopback", "Volume", "TX1 Capture Route"},
|
|
|
|
{"Left Digital Loopback", "Volume", "TX1 Capture Route"},
|
2009-05-01 02:48:08 +00:00
|
|
|
{"Voice Digital Loopback", "Volume", "TX2 Capture Route"},
|
2009-02-18 12:39:05 +00:00
|
|
|
|
2009-05-18 13:02:04 +00:00
|
|
|
{"Digital R2 Playback Mixer", NULL, "Right Digital Loopback"},
|
|
|
|
{"Digital L2 Playback Mixer", NULL, "Left Digital Loopback"},
|
|
|
|
{"Digital Voice Playback Mixer", NULL, "Voice Digital Loopback"},
|
2009-02-18 12:39:05 +00:00
|
|
|
|
2008-10-31 04:35:26 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
static int twl4030_set_bias_level(struct snd_soc_codec *codec,
|
|
|
|
enum snd_soc_bias_level level)
|
|
|
|
{
|
|
|
|
switch (level) {
|
|
|
|
case SND_SOC_BIAS_ON:
|
|
|
|
break;
|
|
|
|
case SND_SOC_BIAS_PREPARE:
|
|
|
|
break;
|
|
|
|
case SND_SOC_BIAS_STANDBY:
|
2015-05-15 10:32:59 +00:00
|
|
|
if (snd_soc_codec_get_bias_level(codec) == SND_SOC_BIAS_OFF)
|
2010-05-26 08:38:17 +00:00
|
|
|
twl4030_codec_enable(codec, 1);
|
2008-10-31 04:35:26 +00:00
|
|
|
break;
|
|
|
|
case SND_SOC_BIAS_OFF:
|
2010-05-26 08:38:15 +00:00
|
|
|
twl4030_codec_enable(codec, 0);
|
2008-10-31 04:35:26 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2009-04-17 12:55:08 +00:00
|
|
|
static void twl4030_constraints(struct twl4030_priv *twl4030,
|
|
|
|
struct snd_pcm_substream *mst_substream)
|
|
|
|
{
|
|
|
|
struct snd_pcm_substream *slv_substream;
|
|
|
|
|
|
|
|
/* Pick the stream, which need to be constrained */
|
|
|
|
if (mst_substream == twl4030->master_substream)
|
|
|
|
slv_substream = twl4030->slave_substream;
|
|
|
|
else if (mst_substream == twl4030->slave_substream)
|
|
|
|
slv_substream = twl4030->master_substream;
|
|
|
|
else /* This should not happen.. */
|
|
|
|
return;
|
|
|
|
|
|
|
|
/* Set the constraints according to the already configured stream */
|
|
|
|
snd_pcm_hw_constraint_minmax(slv_substream->runtime,
|
|
|
|
SNDRV_PCM_HW_PARAM_RATE,
|
|
|
|
twl4030->rate,
|
|
|
|
twl4030->rate);
|
|
|
|
|
|
|
|
snd_pcm_hw_constraint_minmax(slv_substream->runtime,
|
|
|
|
SNDRV_PCM_HW_PARAM_SAMPLE_BITS,
|
|
|
|
twl4030->sample_bits,
|
|
|
|
twl4030->sample_bits);
|
|
|
|
|
|
|
|
snd_pcm_hw_constraint_minmax(slv_substream->runtime,
|
|
|
|
SNDRV_PCM_HW_PARAM_CHANNELS,
|
|
|
|
twl4030->channels,
|
|
|
|
twl4030->channels);
|
|
|
|
}
|
|
|
|
|
2009-04-23 11:36:49 +00:00
|
|
|
/* In case of 4 channel mode, the RX1 L/R for playback and the TX2 L/R for
|
|
|
|
* capture has to be enabled/disabled. */
|
|
|
|
static void twl4030_tdm_enable(struct snd_soc_codec *codec, int direction,
|
2014-01-03 13:27:54 +00:00
|
|
|
int enable)
|
2009-04-23 11:36:49 +00:00
|
|
|
{
|
|
|
|
u8 reg, mask;
|
|
|
|
|
2014-01-03 13:27:53 +00:00
|
|
|
reg = twl4030_read(codec, TWL4030_REG_OPTION);
|
2009-04-23 11:36:49 +00:00
|
|
|
|
|
|
|
if (direction == SNDRV_PCM_STREAM_PLAYBACK)
|
|
|
|
mask = TWL4030_ARXL1_VRX_EN | TWL4030_ARXR1_EN;
|
|
|
|
else
|
|
|
|
mask = TWL4030_ATXL2_VTXL_EN | TWL4030_ATXR2_VTXR_EN;
|
|
|
|
|
|
|
|
if (enable)
|
|
|
|
reg |= mask;
|
|
|
|
else
|
|
|
|
reg &= ~mask;
|
|
|
|
|
|
|
|
twl4030_write(codec, TWL4030_REG_OPTION, reg);
|
|
|
|
}
|
|
|
|
|
2009-04-07 06:14:00 +00:00
|
|
|
static int twl4030_startup(struct snd_pcm_substream *substream,
|
|
|
|
struct snd_soc_dai *dai)
|
2009-03-27 08:39:08 +00:00
|
|
|
{
|
2012-04-04 14:58:16 +00:00
|
|
|
struct snd_soc_codec *codec = dai->codec;
|
2010-04-14 06:35:19 +00:00
|
|
|
struct twl4030_priv *twl4030 = snd_soc_codec_get_drvdata(codec);
|
2009-03-27 08:39:08 +00:00
|
|
|
|
|
|
|
if (twl4030->master_substream) {
|
|
|
|
twl4030->slave_substream = substream;
|
2009-04-17 12:55:08 +00:00
|
|
|
/* The DAI has one configuration for playback and capture, so
|
|
|
|
* if the DAI has been already configured then constrain this
|
|
|
|
* substream to match it. */
|
|
|
|
if (twl4030->configured)
|
|
|
|
twl4030_constraints(twl4030, twl4030->master_substream);
|
|
|
|
} else {
|
2014-01-03 13:27:53 +00:00
|
|
|
if (!(twl4030_read(codec, TWL4030_REG_CODEC_MODE) &
|
2009-04-23 11:36:49 +00:00
|
|
|
TWL4030_OPTION_1)) {
|
|
|
|
/* In option2 4 channel is not supported, set the
|
|
|
|
* constraint for the first stream for channels, the
|
|
|
|
* second stream will 'inherit' this cosntraint */
|
|
|
|
snd_pcm_hw_constraint_minmax(substream->runtime,
|
2014-01-03 13:27:54 +00:00
|
|
|
SNDRV_PCM_HW_PARAM_CHANNELS,
|
|
|
|
2, 2);
|
2009-04-23 11:36:49 +00:00
|
|
|
}
|
2009-03-27 08:39:08 +00:00
|
|
|
twl4030->master_substream = substream;
|
2009-04-17 12:55:08 +00:00
|
|
|
}
|
2009-03-27 08:39:08 +00:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2009-04-07 06:14:00 +00:00
|
|
|
static void twl4030_shutdown(struct snd_pcm_substream *substream,
|
|
|
|
struct snd_soc_dai *dai)
|
2009-03-27 08:39:08 +00:00
|
|
|
{
|
2012-04-04 14:58:16 +00:00
|
|
|
struct snd_soc_codec *codec = dai->codec;
|
2010-04-14 06:35:19 +00:00
|
|
|
struct twl4030_priv *twl4030 = snd_soc_codec_get_drvdata(codec);
|
2009-03-27 08:39:08 +00:00
|
|
|
|
|
|
|
if (twl4030->master_substream == substream)
|
|
|
|
twl4030->master_substream = twl4030->slave_substream;
|
|
|
|
|
|
|
|
twl4030->slave_substream = NULL;
|
2009-04-17 12:55:08 +00:00
|
|
|
|
|
|
|
/* If all streams are closed, or the remaining stream has not yet
|
|
|
|
* been configured than set the DAI as not configured. */
|
|
|
|
if (!twl4030->master_substream)
|
|
|
|
twl4030->configured = 0;
|
|
|
|
else if (!twl4030->master_substream->runtime->channels)
|
|
|
|
twl4030->configured = 0;
|
2009-04-23 11:36:49 +00:00
|
|
|
|
|
|
|
/* If the closing substream had 4 channel, do the necessary cleanup */
|
|
|
|
if (substream->runtime->channels == 4)
|
|
|
|
twl4030_tdm_enable(codec, substream->stream, 0);
|
2009-03-27 08:39:08 +00:00
|
|
|
}
|
|
|
|
|
2008-10-31 04:35:26 +00:00
|
|
|
static int twl4030_hw_params(struct snd_pcm_substream *substream,
|
2014-01-03 13:27:54 +00:00
|
|
|
struct snd_pcm_hw_params *params,
|
|
|
|
struct snd_soc_dai *dai)
|
2008-10-31 04:35:26 +00:00
|
|
|
{
|
2012-04-04 14:58:16 +00:00
|
|
|
struct snd_soc_codec *codec = dai->codec;
|
2010-04-14 06:35:19 +00:00
|
|
|
struct twl4030_priv *twl4030 = snd_soc_codec_get_drvdata(codec);
|
2008-10-31 04:35:26 +00:00
|
|
|
u8 mode, old_mode, format, old_format;
|
|
|
|
|
2009-04-23 11:36:49 +00:00
|
|
|
/* If the substream has 4 channel, do the necessary setup */
|
|
|
|
if (params_channels(params) == 4) {
|
2014-01-03 13:27:53 +00:00
|
|
|
format = twl4030_read(codec, TWL4030_REG_AUDIO_IF);
|
|
|
|
mode = twl4030_read(codec, TWL4030_REG_CODEC_MODE);
|
2009-06-01 11:06:40 +00:00
|
|
|
|
|
|
|
/* Safety check: are we in the correct operating mode and
|
|
|
|
* the interface is in TDM mode? */
|
|
|
|
if ((mode & TWL4030_OPTION_1) &&
|
|
|
|
((format & TWL4030_AIF_FORMAT) == TWL4030_AIF_FORMAT_TDM))
|
2009-04-23 11:36:49 +00:00
|
|
|
twl4030_tdm_enable(codec, substream->stream, 1);
|
|
|
|
else
|
|
|
|
return -EINVAL;
|
|
|
|
}
|
|
|
|
|
2009-04-17 12:55:08 +00:00
|
|
|
if (twl4030->configured)
|
|
|
|
/* Ignoring hw_params for already configured DAI */
|
2009-03-27 08:39:08 +00:00
|
|
|
return 0;
|
|
|
|
|
2008-10-31 04:35:26 +00:00
|
|
|
/* bit rate */
|
2014-01-03 13:27:53 +00:00
|
|
|
old_mode = twl4030_read(codec,
|
|
|
|
TWL4030_REG_CODEC_MODE) & ~TWL4030_CODECPDZ;
|
2008-10-31 04:35:26 +00:00
|
|
|
mode = old_mode & ~TWL4030_APLL_RATE;
|
|
|
|
|
|
|
|
switch (params_rate(params)) {
|
|
|
|
case 8000:
|
|
|
|
mode |= TWL4030_APLL_RATE_8000;
|
|
|
|
break;
|
|
|
|
case 11025:
|
|
|
|
mode |= TWL4030_APLL_RATE_11025;
|
|
|
|
break;
|
|
|
|
case 12000:
|
|
|
|
mode |= TWL4030_APLL_RATE_12000;
|
|
|
|
break;
|
|
|
|
case 16000:
|
|
|
|
mode |= TWL4030_APLL_RATE_16000;
|
|
|
|
break;
|
|
|
|
case 22050:
|
|
|
|
mode |= TWL4030_APLL_RATE_22050;
|
|
|
|
break;
|
|
|
|
case 24000:
|
|
|
|
mode |= TWL4030_APLL_RATE_24000;
|
|
|
|
break;
|
|
|
|
case 32000:
|
|
|
|
mode |= TWL4030_APLL_RATE_32000;
|
|
|
|
break;
|
|
|
|
case 44100:
|
|
|
|
mode |= TWL4030_APLL_RATE_44100;
|
|
|
|
break;
|
|
|
|
case 48000:
|
|
|
|
mode |= TWL4030_APLL_RATE_48000;
|
|
|
|
break;
|
2009-04-03 11:39:05 +00:00
|
|
|
case 96000:
|
|
|
|
mode |= TWL4030_APLL_RATE_96000;
|
|
|
|
break;
|
2008-10-31 04:35:26 +00:00
|
|
|
default:
|
2012-02-21 07:34:20 +00:00
|
|
|
dev_err(codec->dev, "%s: unknown rate %d\n", __func__,
|
2008-10-31 04:35:26 +00:00
|
|
|
params_rate(params));
|
|
|
|
return -EINVAL;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* sample size */
|
2014-01-03 13:27:53 +00:00
|
|
|
old_format = twl4030_read(codec, TWL4030_REG_AUDIO_IF);
|
2008-10-31 04:35:26 +00:00
|
|
|
format = old_format;
|
|
|
|
format &= ~TWL4030_DATA_WIDTH;
|
2014-07-31 11:49:12 +00:00
|
|
|
switch (params_width(params)) {
|
|
|
|
case 16:
|
2008-10-31 04:35:26 +00:00
|
|
|
format |= TWL4030_DATA_WIDTH_16S_16W;
|
|
|
|
break;
|
2014-07-31 11:49:12 +00:00
|
|
|
case 32:
|
2008-10-31 04:35:26 +00:00
|
|
|
format |= TWL4030_DATA_WIDTH_32S_24W;
|
|
|
|
break;
|
|
|
|
default:
|
2014-07-31 11:49:12 +00:00
|
|
|
dev_err(codec->dev, "%s: unsupported bits/sample %d\n",
|
|
|
|
__func__, params_width(params));
|
2008-10-31 04:35:26 +00:00
|
|
|
return -EINVAL;
|
|
|
|
}
|
|
|
|
|
2010-05-26 08:38:20 +00:00
|
|
|
if (format != old_format || mode != old_mode) {
|
|
|
|
if (twl4030->codec_powered) {
|
|
|
|
/*
|
|
|
|
* If the codec is powered, than we need to toggle the
|
|
|
|
* codec power.
|
|
|
|
*/
|
|
|
|
twl4030_codec_enable(codec, 0);
|
|
|
|
twl4030_write(codec, TWL4030_REG_CODEC_MODE, mode);
|
|
|
|
twl4030_write(codec, TWL4030_REG_AUDIO_IF, format);
|
|
|
|
twl4030_codec_enable(codec, 1);
|
|
|
|
} else {
|
|
|
|
twl4030_write(codec, TWL4030_REG_CODEC_MODE, mode);
|
|
|
|
twl4030_write(codec, TWL4030_REG_AUDIO_IF, format);
|
|
|
|
}
|
2008-10-31 04:35:26 +00:00
|
|
|
}
|
2009-04-17 12:55:08 +00:00
|
|
|
|
|
|
|
/* Store the important parameters for the DAI configuration and set
|
|
|
|
* the DAI as configured */
|
|
|
|
twl4030->configured = 1;
|
|
|
|
twl4030->rate = params_rate(params);
|
|
|
|
twl4030->sample_bits = hw_param_interval(params,
|
|
|
|
SNDRV_PCM_HW_PARAM_SAMPLE_BITS)->min;
|
|
|
|
twl4030->channels = params_channels(params);
|
|
|
|
|
|
|
|
/* If both playback and capture streams are open, and one of them
|
|
|
|
* is setting the hw parameters right now (since we are here), set
|
|
|
|
* constraints to the other stream to match the current one. */
|
|
|
|
if (twl4030->slave_substream)
|
|
|
|
twl4030_constraints(twl4030, substream);
|
|
|
|
|
2008-10-31 04:35:26 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2014-01-03 13:27:54 +00:00
|
|
|
static int twl4030_set_dai_sysclk(struct snd_soc_dai *codec_dai, int clk_id,
|
|
|
|
unsigned int freq, int dir)
|
2008-10-31 04:35:26 +00:00
|
|
|
{
|
|
|
|
struct snd_soc_codec *codec = codec_dai->codec;
|
2010-04-14 06:35:19 +00:00
|
|
|
struct twl4030_priv *twl4030 = snd_soc_codec_get_drvdata(codec);
|
2008-10-31 04:35:26 +00:00
|
|
|
|
|
|
|
switch (freq) {
|
|
|
|
case 19200000:
|
|
|
|
case 26000000:
|
|
|
|
case 38400000:
|
|
|
|
break;
|
|
|
|
default:
|
2012-02-21 07:34:20 +00:00
|
|
|
dev_err(codec->dev, "Unsupported HFCLKIN: %u\n", freq);
|
2008-10-31 04:35:26 +00:00
|
|
|
return -EINVAL;
|
|
|
|
}
|
|
|
|
|
2009-11-04 07:58:20 +00:00
|
|
|
if ((freq / 1000) != twl4030->sysclk) {
|
|
|
|
dev_err(codec->dev,
|
2012-02-21 07:34:20 +00:00
|
|
|
"Mismatch in HFCLKIN: %u (configured: %u)\n",
|
2009-11-04 07:58:20 +00:00
|
|
|
freq, twl4030->sysclk * 1000);
|
|
|
|
return -EINVAL;
|
|
|
|
}
|
2008-10-31 04:35:26 +00:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2014-01-03 13:27:54 +00:00
|
|
|
static int twl4030_set_dai_fmt(struct snd_soc_dai *codec_dai, unsigned int fmt)
|
2008-10-31 04:35:26 +00:00
|
|
|
{
|
|
|
|
struct snd_soc_codec *codec = codec_dai->codec;
|
2010-05-26 08:38:20 +00:00
|
|
|
struct twl4030_priv *twl4030 = snd_soc_codec_get_drvdata(codec);
|
2008-10-31 04:35:26 +00:00
|
|
|
u8 old_format, format;
|
|
|
|
|
|
|
|
/* get format */
|
2014-01-03 13:27:53 +00:00
|
|
|
old_format = twl4030_read(codec, TWL4030_REG_AUDIO_IF);
|
2008-10-31 04:35:26 +00:00
|
|
|
format = old_format;
|
|
|
|
|
|
|
|
/* set master/slave audio interface */
|
|
|
|
switch (fmt & SND_SOC_DAIFMT_MASTER_MASK) {
|
|
|
|
case SND_SOC_DAIFMT_CBM_CFM:
|
|
|
|
format &= ~(TWL4030_AIF_SLAVE_EN);
|
2008-11-05 21:51:05 +00:00
|
|
|
format &= ~(TWL4030_CLK256FS_EN);
|
2008-10-31 04:35:26 +00:00
|
|
|
break;
|
|
|
|
case SND_SOC_DAIFMT_CBS_CFS:
|
|
|
|
format |= TWL4030_AIF_SLAVE_EN;
|
2008-11-05 21:51:05 +00:00
|
|
|
format |= TWL4030_CLK256FS_EN;
|
2008-10-31 04:35:26 +00:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
return -EINVAL;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* interface format */
|
|
|
|
format &= ~TWL4030_AIF_FORMAT;
|
|
|
|
switch (fmt & SND_SOC_DAIFMT_FORMAT_MASK) {
|
|
|
|
case SND_SOC_DAIFMT_I2S:
|
|
|
|
format |= TWL4030_AIF_FORMAT_CODEC;
|
|
|
|
break;
|
2009-04-23 11:36:49 +00:00
|
|
|
case SND_SOC_DAIFMT_DSP_A:
|
|
|
|
format |= TWL4030_AIF_FORMAT_TDM;
|
|
|
|
break;
|
2008-10-31 04:35:26 +00:00
|
|
|
default:
|
|
|
|
return -EINVAL;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (format != old_format) {
|
2010-05-26 08:38:20 +00:00
|
|
|
if (twl4030->codec_powered) {
|
|
|
|
/*
|
|
|
|
* If the codec is powered, than we need to toggle the
|
|
|
|
* codec power.
|
|
|
|
*/
|
|
|
|
twl4030_codec_enable(codec, 0);
|
|
|
|
twl4030_write(codec, TWL4030_REG_AUDIO_IF, format);
|
|
|
|
twl4030_codec_enable(codec, 1);
|
|
|
|
} else {
|
|
|
|
twl4030_write(codec, TWL4030_REG_AUDIO_IF, format);
|
|
|
|
}
|
2008-10-31 04:35:26 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2009-07-03 07:21:39 +00:00
|
|
|
static int twl4030_set_tristate(struct snd_soc_dai *dai, int tristate)
|
|
|
|
{
|
|
|
|
struct snd_soc_codec *codec = dai->codec;
|
2014-01-03 13:27:53 +00:00
|
|
|
u8 reg = twl4030_read(codec, TWL4030_REG_AUDIO_IF);
|
2009-07-03 07:21:39 +00:00
|
|
|
|
|
|
|
if (tristate)
|
|
|
|
reg |= TWL4030_AIF_TRI_EN;
|
|
|
|
else
|
|
|
|
reg &= ~TWL4030_AIF_TRI_EN;
|
|
|
|
|
|
|
|
return twl4030_write(codec, TWL4030_REG_AUDIO_IF, reg);
|
|
|
|
}
|
|
|
|
|
2009-05-18 01:02:31 +00:00
|
|
|
/* In case of voice mode, the RX1 L(VRX) for downlink and the TX2 L/R
|
|
|
|
* (VTXL, VTXR) for uplink has to be enabled/disabled. */
|
|
|
|
static void twl4030_voice_enable(struct snd_soc_codec *codec, int direction,
|
2014-01-03 13:27:54 +00:00
|
|
|
int enable)
|
2009-05-18 01:02:31 +00:00
|
|
|
{
|
|
|
|
u8 reg, mask;
|
|
|
|
|
2014-01-03 13:27:53 +00:00
|
|
|
reg = twl4030_read(codec, TWL4030_REG_OPTION);
|
2009-05-18 01:02:31 +00:00
|
|
|
|
|
|
|
if (direction == SNDRV_PCM_STREAM_PLAYBACK)
|
|
|
|
mask = TWL4030_ARXL1_VRX_EN;
|
|
|
|
else
|
|
|
|
mask = TWL4030_ATXL2_VTXL_EN | TWL4030_ATXR2_VTXR_EN;
|
|
|
|
|
|
|
|
if (enable)
|
|
|
|
reg |= mask;
|
|
|
|
else
|
|
|
|
reg &= ~mask;
|
|
|
|
|
|
|
|
twl4030_write(codec, TWL4030_REG_OPTION, reg);
|
|
|
|
}
|
|
|
|
|
2009-04-20 10:21:35 +00:00
|
|
|
static int twl4030_voice_startup(struct snd_pcm_substream *substream,
|
2014-01-03 13:27:54 +00:00
|
|
|
struct snd_soc_dai *dai)
|
2009-04-20 10:21:35 +00:00
|
|
|
{
|
2012-04-04 14:58:16 +00:00
|
|
|
struct snd_soc_codec *codec = dai->codec;
|
2010-04-14 06:35:19 +00:00
|
|
|
struct twl4030_priv *twl4030 = snd_soc_codec_get_drvdata(codec);
|
2009-04-20 10:21:35 +00:00
|
|
|
u8 mode;
|
|
|
|
|
|
|
|
/* If the system master clock is not 26MHz, the voice PCM interface is
|
2011-03-31 01:57:33 +00:00
|
|
|
* not available.
|
2009-04-20 10:21:35 +00:00
|
|
|
*/
|
2009-11-04 07:58:20 +00:00
|
|
|
if (twl4030->sysclk != 26000) {
|
2012-02-21 07:34:20 +00:00
|
|
|
dev_err(codec->dev,
|
|
|
|
"%s: HFCLKIN is %u KHz, voice interface needs 26MHz\n",
|
|
|
|
__func__, twl4030->sysclk);
|
2009-04-20 10:21:35 +00:00
|
|
|
return -EINVAL;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* If the codec mode is not option2, the voice PCM interface is not
|
2011-03-31 01:57:33 +00:00
|
|
|
* available.
|
2009-04-20 10:21:35 +00:00
|
|
|
*/
|
2014-01-03 13:27:53 +00:00
|
|
|
mode = twl4030_read(codec, TWL4030_REG_CODEC_MODE)
|
2009-04-20 10:21:35 +00:00
|
|
|
& TWL4030_OPT_MODE;
|
|
|
|
|
|
|
|
if (mode != TWL4030_OPTION_2) {
|
2012-02-21 07:34:20 +00:00
|
|
|
dev_err(codec->dev, "%s: the codec mode is not option2\n",
|
|
|
|
__func__);
|
2009-04-20 10:21:35 +00:00
|
|
|
return -EINVAL;
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2009-05-18 01:02:31 +00:00
|
|
|
static void twl4030_voice_shutdown(struct snd_pcm_substream *substream,
|
2014-01-03 13:27:54 +00:00
|
|
|
struct snd_soc_dai *dai)
|
2009-05-18 01:02:31 +00:00
|
|
|
{
|
2012-04-04 14:58:16 +00:00
|
|
|
struct snd_soc_codec *codec = dai->codec;
|
2009-05-18 01:02:31 +00:00
|
|
|
|
|
|
|
/* Enable voice digital filters */
|
|
|
|
twl4030_voice_enable(codec, substream->stream, 0);
|
|
|
|
}
|
|
|
|
|
2009-04-20 10:21:35 +00:00
|
|
|
static int twl4030_voice_hw_params(struct snd_pcm_substream *substream,
|
2014-01-03 13:27:54 +00:00
|
|
|
struct snd_pcm_hw_params *params,
|
|
|
|
struct snd_soc_dai *dai)
|
2009-04-20 10:21:35 +00:00
|
|
|
{
|
2012-04-04 14:58:16 +00:00
|
|
|
struct snd_soc_codec *codec = dai->codec;
|
2010-05-26 08:38:20 +00:00
|
|
|
struct twl4030_priv *twl4030 = snd_soc_codec_get_drvdata(codec);
|
2009-04-20 10:21:35 +00:00
|
|
|
u8 old_mode, mode;
|
|
|
|
|
2009-05-18 01:02:31 +00:00
|
|
|
/* Enable voice digital filters */
|
|
|
|
twl4030_voice_enable(codec, substream->stream, 1);
|
|
|
|
|
2009-04-20 10:21:35 +00:00
|
|
|
/* bit rate */
|
2014-01-03 13:27:54 +00:00
|
|
|
old_mode = twl4030_read(codec,
|
|
|
|
TWL4030_REG_CODEC_MODE) & ~TWL4030_CODECPDZ;
|
2009-04-20 10:21:35 +00:00
|
|
|
mode = old_mode;
|
|
|
|
|
|
|
|
switch (params_rate(params)) {
|
|
|
|
case 8000:
|
|
|
|
mode &= ~(TWL4030_SEL_16K);
|
|
|
|
break;
|
|
|
|
case 16000:
|
|
|
|
mode |= TWL4030_SEL_16K;
|
|
|
|
break;
|
|
|
|
default:
|
2012-02-21 07:34:20 +00:00
|
|
|
dev_err(codec->dev, "%s: unknown rate %d\n", __func__,
|
2009-04-20 10:21:35 +00:00
|
|
|
params_rate(params));
|
|
|
|
return -EINVAL;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (mode != old_mode) {
|
2010-05-26 08:38:20 +00:00
|
|
|
if (twl4030->codec_powered) {
|
|
|
|
/*
|
|
|
|
* If the codec is powered, than we need to toggle the
|
|
|
|
* codec power.
|
|
|
|
*/
|
|
|
|
twl4030_codec_enable(codec, 0);
|
|
|
|
twl4030_write(codec, TWL4030_REG_CODEC_MODE, mode);
|
|
|
|
twl4030_codec_enable(codec, 1);
|
|
|
|
} else {
|
|
|
|
twl4030_write(codec, TWL4030_REG_CODEC_MODE, mode);
|
|
|
|
}
|
2009-04-20 10:21:35 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int twl4030_voice_set_dai_sysclk(struct snd_soc_dai *codec_dai,
|
2014-01-03 13:27:54 +00:00
|
|
|
int clk_id, unsigned int freq, int dir)
|
2009-04-20 10:21:35 +00:00
|
|
|
{
|
|
|
|
struct snd_soc_codec *codec = codec_dai->codec;
|
2010-04-20 06:20:31 +00:00
|
|
|
struct twl4030_priv *twl4030 = snd_soc_codec_get_drvdata(codec);
|
2009-04-20 10:21:35 +00:00
|
|
|
|
2009-11-04 07:58:20 +00:00
|
|
|
if (freq != 26000000) {
|
2012-02-21 07:34:20 +00:00
|
|
|
dev_err(codec->dev,
|
|
|
|
"%s: HFCLKIN is %u KHz, voice interface needs 26MHz\n",
|
|
|
|
__func__, freq / 1000);
|
2009-11-04 07:58:20 +00:00
|
|
|
return -EINVAL;
|
|
|
|
}
|
|
|
|
if ((freq / 1000) != twl4030->sysclk) {
|
|
|
|
dev_err(codec->dev,
|
2012-02-21 07:34:20 +00:00
|
|
|
"Mismatch in HFCLKIN: %u (configured: %u)\n",
|
2009-11-04 07:58:20 +00:00
|
|
|
freq, twl4030->sysclk * 1000);
|
2009-04-20 10:21:35 +00:00
|
|
|
return -EINVAL;
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int twl4030_voice_set_dai_fmt(struct snd_soc_dai *codec_dai,
|
2014-01-03 13:27:54 +00:00
|
|
|
unsigned int fmt)
|
2009-04-20 10:21:35 +00:00
|
|
|
{
|
|
|
|
struct snd_soc_codec *codec = codec_dai->codec;
|
2010-05-26 08:38:20 +00:00
|
|
|
struct twl4030_priv *twl4030 = snd_soc_codec_get_drvdata(codec);
|
2009-04-20 10:21:35 +00:00
|
|
|
u8 old_format, format;
|
|
|
|
|
|
|
|
/* get format */
|
2014-01-03 13:27:53 +00:00
|
|
|
old_format = twl4030_read(codec, TWL4030_REG_VOICE_IF);
|
2009-04-20 10:21:35 +00:00
|
|
|
format = old_format;
|
|
|
|
|
|
|
|
/* set master/slave audio interface */
|
|
|
|
switch (fmt & SND_SOC_DAIFMT_MASTER_MASK) {
|
2009-06-19 08:23:42 +00:00
|
|
|
case SND_SOC_DAIFMT_CBM_CFM:
|
2009-04-20 10:21:35 +00:00
|
|
|
format &= ~(TWL4030_VIF_SLAVE_EN);
|
|
|
|
break;
|
|
|
|
case SND_SOC_DAIFMT_CBS_CFS:
|
|
|
|
format |= TWL4030_VIF_SLAVE_EN;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
return -EINVAL;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* clock inversion */
|
|
|
|
switch (fmt & SND_SOC_DAIFMT_INV_MASK) {
|
|
|
|
case SND_SOC_DAIFMT_IB_NF:
|
|
|
|
format &= ~(TWL4030_VIF_FORMAT);
|
|
|
|
break;
|
|
|
|
case SND_SOC_DAIFMT_NB_IF:
|
|
|
|
format |= TWL4030_VIF_FORMAT;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
return -EINVAL;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (format != old_format) {
|
2010-05-26 08:38:20 +00:00
|
|
|
if (twl4030->codec_powered) {
|
|
|
|
/*
|
|
|
|
* If the codec is powered, than we need to toggle the
|
|
|
|
* codec power.
|
|
|
|
*/
|
|
|
|
twl4030_codec_enable(codec, 0);
|
|
|
|
twl4030_write(codec, TWL4030_REG_VOICE_IF, format);
|
|
|
|
twl4030_codec_enable(codec, 1);
|
|
|
|
} else {
|
|
|
|
twl4030_write(codec, TWL4030_REG_VOICE_IF, format);
|
|
|
|
}
|
2009-04-20 10:21:35 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2009-07-03 07:21:39 +00:00
|
|
|
static int twl4030_voice_set_tristate(struct snd_soc_dai *dai, int tristate)
|
|
|
|
{
|
|
|
|
struct snd_soc_codec *codec = dai->codec;
|
2014-01-03 13:27:53 +00:00
|
|
|
u8 reg = twl4030_read(codec, TWL4030_REG_VOICE_IF);
|
2009-07-03 07:21:39 +00:00
|
|
|
|
|
|
|
if (tristate)
|
|
|
|
reg |= TWL4030_VIF_TRI_EN;
|
|
|
|
else
|
|
|
|
reg &= ~TWL4030_VIF_TRI_EN;
|
|
|
|
|
|
|
|
return twl4030_write(codec, TWL4030_REG_VOICE_IF, reg);
|
|
|
|
}
|
|
|
|
|
2008-11-12 15:05:41 +00:00
|
|
|
#define TWL4030_RATES (SNDRV_PCM_RATE_8000_48000)
|
2010-12-14 11:45:29 +00:00
|
|
|
#define TWL4030_FORMATS (SNDRV_PCM_FMTBIT_S16_LE | SNDRV_PCM_FMTBIT_S32_LE)
|
2008-10-31 04:35:26 +00:00
|
|
|
|
2011-11-23 10:40:40 +00:00
|
|
|
static const struct snd_soc_dai_ops twl4030_dai_hifi_ops = {
|
2009-03-27 08:39:08 +00:00
|
|
|
.startup = twl4030_startup,
|
|
|
|
.shutdown = twl4030_shutdown,
|
2009-03-16 12:23:35 +00:00
|
|
|
.hw_params = twl4030_hw_params,
|
|
|
|
.set_sysclk = twl4030_set_dai_sysclk,
|
|
|
|
.set_fmt = twl4030_set_dai_fmt,
|
2009-07-03 07:21:39 +00:00
|
|
|
.set_tristate = twl4030_set_tristate,
|
2009-03-16 12:23:35 +00:00
|
|
|
};
|
|
|
|
|
2011-11-23 10:40:40 +00:00
|
|
|
static const struct snd_soc_dai_ops twl4030_dai_voice_ops = {
|
2009-04-20 10:21:35 +00:00
|
|
|
.startup = twl4030_voice_startup,
|
2009-05-18 01:02:31 +00:00
|
|
|
.shutdown = twl4030_voice_shutdown,
|
2009-04-20 10:21:35 +00:00
|
|
|
.hw_params = twl4030_voice_hw_params,
|
|
|
|
.set_sysclk = twl4030_voice_set_dai_sysclk,
|
|
|
|
.set_fmt = twl4030_voice_set_dai_fmt,
|
2009-07-03 07:21:39 +00:00
|
|
|
.set_tristate = twl4030_voice_set_tristate,
|
2009-04-20 10:21:35 +00:00
|
|
|
};
|
|
|
|
|
2010-03-17 20:15:21 +00:00
|
|
|
static struct snd_soc_dai_driver twl4030_dai[] = {
|
2009-04-20 10:21:35 +00:00
|
|
|
{
|
2010-03-17 20:15:21 +00:00
|
|
|
.name = "twl4030-hifi",
|
2008-10-31 04:35:26 +00:00
|
|
|
.playback = {
|
2009-05-22 12:12:15 +00:00
|
|
|
.stream_name = "HiFi Playback",
|
2008-10-31 04:35:26 +00:00
|
|
|
.channels_min = 2,
|
2009-04-23 11:36:49 +00:00
|
|
|
.channels_max = 4,
|
2009-03-27 08:39:07 +00:00
|
|
|
.rates = TWL4030_RATES | SNDRV_PCM_RATE_96000,
|
2012-01-18 11:18:26 +00:00
|
|
|
.formats = TWL4030_FORMATS,
|
|
|
|
.sig_bits = 24,},
|
2008-10-31 04:35:26 +00:00
|
|
|
.capture = {
|
2012-09-20 13:32:02 +00:00
|
|
|
.stream_name = "HiFi Capture",
|
2008-10-31 04:35:26 +00:00
|
|
|
.channels_min = 2,
|
2009-04-23 11:36:49 +00:00
|
|
|
.channels_max = 4,
|
2008-10-31 04:35:26 +00:00
|
|
|
.rates = TWL4030_RATES,
|
2012-01-18 11:18:26 +00:00
|
|
|
.formats = TWL4030_FORMATS,
|
|
|
|
.sig_bits = 24,},
|
2010-03-17 20:15:21 +00:00
|
|
|
.ops = &twl4030_dai_hifi_ops,
|
2009-04-20 10:21:35 +00:00
|
|
|
},
|
|
|
|
{
|
2010-03-17 20:15:21 +00:00
|
|
|
.name = "twl4030-voice",
|
2009-04-20 10:21:35 +00:00
|
|
|
.playback = {
|
2009-05-22 12:12:15 +00:00
|
|
|
.stream_name = "Voice Playback",
|
2009-04-20 10:21:35 +00:00
|
|
|
.channels_min = 1,
|
|
|
|
.channels_max = 1,
|
|
|
|
.rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000,
|
|
|
|
.formats = SNDRV_PCM_FMTBIT_S16_LE,},
|
|
|
|
.capture = {
|
2012-09-20 13:32:02 +00:00
|
|
|
.stream_name = "Voice Capture",
|
2009-04-20 10:21:35 +00:00
|
|
|
.channels_min = 1,
|
|
|
|
.channels_max = 2,
|
|
|
|
.rates = SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000,
|
|
|
|
.formats = SNDRV_PCM_FMTBIT_S16_LE,},
|
|
|
|
.ops = &twl4030_dai_voice_ops,
|
|
|
|
},
|
2008-10-31 04:35:26 +00:00
|
|
|
};
|
|
|
|
|
2010-03-17 20:15:21 +00:00
|
|
|
static int twl4030_soc_probe(struct snd_soc_codec *codec)
|
2008-10-31 04:35:26 +00:00
|
|
|
{
|
2010-03-17 20:15:21 +00:00
|
|
|
struct twl4030_priv *twl4030;
|
2009-05-22 07:13:15 +00:00
|
|
|
|
2012-09-10 10:46:30 +00:00
|
|
|
twl4030 = devm_kzalloc(codec->dev, sizeof(struct twl4030_priv),
|
|
|
|
GFP_KERNEL);
|
2014-06-20 09:59:03 +00:00
|
|
|
if (!twl4030)
|
2010-03-17 20:15:21 +00:00
|
|
|
return -ENOMEM;
|
|
|
|
snd_soc_codec_set_drvdata(codec, twl4030);
|
|
|
|
/* Set the defaults, and power up the codec */
|
2011-05-31 09:02:49 +00:00
|
|
|
twl4030->sysclk = twl4030_audio_get_mclk() / 1000;
|
2010-03-17 20:15:21 +00:00
|
|
|
|
|
|
|
twl4030_init_chip(codec);
|
2008-10-31 04:35:26 +00:00
|
|
|
|
2009-10-22 10:26:48 +00:00
|
|
|
return 0;
|
2008-10-31 04:35:26 +00:00
|
|
|
}
|
|
|
|
|
2010-03-17 20:15:21 +00:00
|
|
|
static int twl4030_soc_remove(struct snd_soc_codec *codec)
|
2008-10-31 04:35:26 +00:00
|
|
|
{
|
2010-11-19 09:31:08 +00:00
|
|
|
struct twl4030_priv *twl4030 = snd_soc_codec_get_drvdata(codec);
|
2012-09-10 10:46:31 +00:00
|
|
|
struct twl4030_codec_data *pdata = twl4030->pdata;
|
2010-11-19 09:31:08 +00:00
|
|
|
|
2012-09-10 10:46:27 +00:00
|
|
|
if (pdata && pdata->hs_extmute && gpio_is_valid(pdata->hs_extmute_gpio))
|
|
|
|
gpio_free(pdata->hs_extmute_gpio);
|
|
|
|
|
2009-10-22 10:26:48 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2010-03-17 20:15:21 +00:00
|
|
|
static struct snd_soc_codec_driver soc_codec_dev_twl4030 = {
|
|
|
|
.probe = twl4030_soc_probe,
|
|
|
|
.remove = twl4030_soc_remove,
|
2014-01-03 13:27:53 +00:00
|
|
|
.read = twl4030_read,
|
2010-03-17 20:15:21 +00:00
|
|
|
.write = twl4030_write,
|
|
|
|
.set_bias_level = twl4030_set_bias_level,
|
2012-01-27 10:02:09 +00:00
|
|
|
.idle_bias_off = true,
|
2011-10-11 10:11:32 +00:00
|
|
|
|
|
|
|
.controls = twl4030_snd_controls,
|
|
|
|
.num_controls = ARRAY_SIZE(twl4030_snd_controls),
|
|
|
|
.dapm_widgets = twl4030_dapm_widgets,
|
|
|
|
.num_dapm_widgets = ARRAY_SIZE(twl4030_dapm_widgets),
|
|
|
|
.dapm_routes = intercon,
|
|
|
|
.num_dapm_routes = ARRAY_SIZE(intercon),
|
2010-03-17 20:15:21 +00:00
|
|
|
};
|
|
|
|
|
2012-12-07 14:26:20 +00:00
|
|
|
static int twl4030_codec_probe(struct platform_device *pdev)
|
2009-10-22 10:26:48 +00:00
|
|
|
{
|
2010-03-17 20:15:21 +00:00
|
|
|
return snd_soc_register_codec(&pdev->dev, &soc_codec_dev_twl4030,
|
2014-01-03 13:27:54 +00:00
|
|
|
twl4030_dai, ARRAY_SIZE(twl4030_dai));
|
2008-10-31 04:35:26 +00:00
|
|
|
}
|
|
|
|
|
2012-12-07 14:26:20 +00:00
|
|
|
static int twl4030_codec_remove(struct platform_device *pdev)
|
2008-10-31 04:35:26 +00:00
|
|
|
{
|
2010-03-17 20:15:21 +00:00
|
|
|
snd_soc_unregister_codec(&pdev->dev);
|
2008-10-31 04:35:26 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2010-03-17 20:15:21 +00:00
|
|
|
MODULE_ALIAS("platform:twl4030-codec");
|
2009-10-22 10:26:48 +00:00
|
|
|
|
|
|
|
static struct platform_driver twl4030_codec_driver = {
|
|
|
|
.probe = twl4030_codec_probe,
|
2012-12-07 14:26:20 +00:00
|
|
|
.remove = twl4030_codec_remove,
|
2009-10-22 10:26:48 +00:00
|
|
|
.driver = {
|
2010-03-17 20:15:21 +00:00
|
|
|
.name = "twl4030-codec",
|
2009-10-22 10:26:48 +00:00
|
|
|
},
|
2008-10-31 04:35:26 +00:00
|
|
|
};
|
|
|
|
|
2011-11-23 22:52:08 +00:00
|
|
|
module_platform_driver(twl4030_codec_driver);
|
2008-12-08 19:17:58 +00:00
|
|
|
|
2008-10-31 04:35:26 +00:00
|
|
|
MODULE_DESCRIPTION("ASoC TWL4030 codec driver");
|
|
|
|
MODULE_AUTHOR("Steve Sakoman");
|
|
|
|
MODULE_LICENSE("GPL");
|