[alsa-devel] [PATCH 13/31] HDA patch_via.c: Refresh front playback mute if hp plug-in mutes speaker.
Takashi Iwai
tiwai at suse.de
Tue Oct 6 07:52:42 CEST 2009
At Tue, 6 Oct 2009 13:10:54 +0800,
Li Bo wrote:
>
> On Mon, Oct 5, 2009 at 11:08 PM, Takashi Iwai <tiwai at suse.de> wrote:
> > At Mon, 5 Oct 2009 22:27:16 +0800,
> > Li Bo wrote:
> >>
> >> [ALSA] HDA VIA: Refresh front playback mute if hp plug-in mutes speaker.
> >>
> >> Signed-off-by: Lydia Wang <lydiawang at viatech.com.cn>
> >>
> >> Index: sound-2.6/sound/pci/hda/patch_via.c
> >> ===================================================================
> >> --- sound-2.6.orig/sound/pci/hda/patch_via.c 2009-10-05 15:10:13.000000000 +0800
> >> +++ sound-2.6/sound/pci/hda/patch_via.c 2009-10-05 15:10:22.000000000 +0800
> >> @@ -1346,14 +1346,26 @@
> >> /* mute internal speaker if HP is plugged */
> >> static void via_hp_automute(struct hda_codec *codec)
> >> {
> >> - unsigned int present;
> >> + unsigned int present = 0;
> >> struct via_spec *spec = codec->spec;
> >> + char name[32] = "Front Playback Switch";
> >
> > Use a constant string, at least a form like: const char *name = "...";
> > But...
> OK
>
>
> >
> >>
> >> present = snd_hda_codec_read(codec, spec->autocfg.hp_pins[0], 0,
> >> AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
> >> - snd_hda_codec_amp_stereo(codec, spec->autocfg.line_out_pins[0],
> >> - HDA_OUTPUT, 0, HDA_AMP_MUTE,
> >> - present ? HDA_AMP_MUTE : 0);
> >> +
> >> + if (!spec->hp_independent_mode) {
> >> + struct snd_card *card = codec->bus->card;
> >> + struct snd_kcontrol *kctl;
> >> + /* auto mute */
> >> + snd_hda_codec_amp_stereo(
> >> + codec, spec->autocfg.line_out_pins[0], HDA_OUTPUT, 0,
> >> + HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
> >> + /* notify change */
> >> + list_for_each_entry(kctl, &card->controls, list)
> >> + if (strcmp(kctl->id.name, name) == 0)
> >> + snd_ctl_notify(card, SNDRV_CTL_EVENT_MASK_VALUE,
> >> + &kctl->id);
> >
> > Don't search for a kctl here.
> > Just set up kctl->id, and let snd_ctl_notify() to search for the
> > element.
> I tried to setup kctl->id, but found that to setup it properly, we
> also need search.
> Maybe we have to search here?
No, you just need to set up a control id struct, and call with it.
Something like below:
struct snd_ctl_elem_id id;
memset(&id, 0, sizeof(id));
id.iface = SNDRV_CTL_ELEM_IFACE_MIXER;
strcpy(id.name, "Front Playback Switch");
snd_ctl_notify(card, SNDRV_CTL_ELEM_MASK_VALUE, &id);
Takashi
More information about the Alsa-devel
mailing list