From: Takashi Iwai Subject: Re: [PATCH 13/31] HDA patch_via.c: Refresh front playback mute if hp plug-in mutes speaker. Date: Mon, 05 Oct 2009 17:08:14 +0200 Message-ID: References: <16685ee0910050727k72411ca7kd80cbb8eb6771f6e@mail.gmail.com> Mime-Version: 1.0 (generated by SEMI 1.14.6 - "Maruoka") Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: Received: from mx1.suse.de (cantor.suse.de [195.135.220.2]) by alsa0.perex.cz (Postfix) with ESMTP id B3278244C8 for ; Mon, 5 Oct 2009 17:08:14 +0200 (CEST) In-Reply-To: <16685ee0910050727k72411ca7kd80cbb8eb6771f6e@mail.gmail.com> List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: alsa-devel-bounces@alsa-project.org Errors-To: alsa-devel-bounces@alsa-project.org To: Li Bo Cc: LoganLi@viatech.com.cn, alsa-devel@alsa-project.org, HaraldWelte@viatech.com, lydiawang@viatech.com.cn List-Id: alsa-devel@alsa-project.org 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 > > 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... > > 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. Takashi