[alsa-devel] [PATCH] ASoC: TWL4030: Add capture source selection and mic gain control

Grazvydas Ignotas notasas at gmail.com
Tue Dec 2 11:15:51 CET 2008

On Tue, Dec 2, 2008 at 1:26 AM, Mark Brown <broonie at sirena.org.uk> wrote:
> On Tue, Dec 02, 2008 at 01:07:28AM +0200, Grazvydas Ignotas wrote:
>> This patch adds controls for capture source controls. When a microphone
>> is selected, handlers automatically enable bias power (disable when
>> deselected). The patch also adds microphone gain control. Microphone
>> and line input recording tested on OMAP3 pandora board.
> Hrm.  Disabling the gain like this is likely to cause trouble for jack
> detect.  However, that's not implemented yet so not a problem currently.

Well the TRM doesn't mention jack detect at all (except headset detect
using separate switch connected to GPIO). Or is that some software

>> +static int twl4030_get_right_input(struct snd_kcontrol *kcontrol,
>> +     struct snd_ctl_elem_value *ucontrol)
>> +{
>> +     struct snd_soc_codec *codec = kcontrol->private_data;
>> +     u8 reg = twl4030_read_reg_cache(codec, TWL4030_REG_ANAMICR);
>> +
>> +     reg &= TWL4030_SUBMIC_EN|TWL4030_AUXR_EN;
>> +     if (reg == TWL4030_SUBMIC_EN)
>> +             ucontrol->value.integer.value[0] = 0;
>> +     else if (reg == TWL4030_AUXR_EN)
>> +             ucontrol->value.integer.value[0] = 1;
>> +
>> +     return 0;
> This will report something undefined as selected when neither option is
> selected.  Why not include a "None" option in the mux (the same applies
> to the other path)?  A switch statement might make for clearer code here.

Sounds good, will update.

>> +
>> +     SOC_DOUBLE_TLV("Microphone Boost", TWL4030_REG_ANAMIC_GAIN,
>> +             0, 3, 5, 0, microphone_gain_tlv),
> Should be "Microphone Boost Volume" or possibly just "Microphone Volume".

Setting this to 0 still records from MICs, but the signal is rather
weak, so it looks more like boost to me. This control also affects
aux/line inputs if they are selected, and causes rather bad
distortions for them if control is not set to 0. Perhaps this control
could be disabled (or at least automatically set to 0) while aux/line
inputs are selected? Can that be done?
There are actually MICAMP_EN bits to enable microphone amplifiers, but
if they are not set, aux/line recording won't work too (records some
strange noise).

More information about the Alsa-devel mailing list