[alsa-devel] [PATCH 13/31] HDA patch_via.c: Refresh front playback mute if hp plug-in mutes speaker.

Li Bo liboat at gmail.com
Tue Oct 6 07:10:54 CEST 2009


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?


>
>
> Takashi
>


More information about the Alsa-devel mailing list