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

Mark Brown broonie at sirena.org.uk
Tue Dec 2 00:26:52 CET 2008


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.

> +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.

> +
> +	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".


More information about the Alsa-devel mailing list