[alsa-devel] [PATCH v2 2/3] ASoC: Intel: Skylake: Add enum control for mic selection

Takashi Iwai tiwai at suse.de
Tue May 30 14:44:20 CEST 2017


On Tue, 30 May 2017 14:03:00 +0200,
Subhransu S. Prusty wrote:
> 
> +static int skl_tplg_mic_control_get(struct snd_kcontrol *kcontrol,
> +		struct snd_ctl_elem_value *ucontrol)
> +{
> +	struct snd_soc_dapm_widget *w = snd_soc_dapm_kcontrol_widget(kcontrol);
> +	struct skl_module_cfg *mconfig = w->priv;
> +	struct soc_enum *ec = (struct soc_enum *)kcontrol->private_value;
> +	u32 ch_type = *((u32 *)ec->dobj.private);
> +
> +	if (mconfig->dmic_ch_type == ch_type)
> +		ucontrol->value.integer.value[0] = mconfig->dmic_ch_combo_index;
> +	else
> +		ucontrol->value.integer.value[0] = 0;

Is this enum kctl or not?  If it is, you're accessing to the wrong
field, as already mentioned.  ucontrol->value.integer.xxx is for
volumes and switches.

Ditto for skl_tplg_mic_control_set().

> +static const struct snd_soc_tplg_kcontrol_ops skl_tplg_kcontrol_ops[] = {
> +	{SKL_CONTROL_TYPE_MIC_SELECT, skl_tplg_mic_control_get,
> +					skl_tplg_mic_control_set},
> +};

Better to do in C99 init style.


thanks,

Takashi


More information about the Alsa-devel mailing list