HDA patch_via.c: Refresh front playback mute if hp plug-in mutes speaker.
PATCH 13/31 HDA patch_via.c: Refresh front playback mute if hp plug-in mutes speaker.
[ALSA] HDA VIA: Refresh front playback mute if hp plug-in mutes speaker.
sound/pci/hda/patch_via.c +16 -4
@@ -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" ; 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); + } }static void via_gpio_control (struct hda_codec *codec)
At Mon, 5 Oct 2009 22:27:16 +0800,
Quoted 10 lines · Li Bo
[ALSA] HDA VIA: Refresh front playback mute if hp plug-in mutes speaker.
Signed-off-by Lydia Wang <[email protected]>Index:
sound-2.6/sound/pci/hda/patch_via.c
===================================================================
sound/pci/hda/patch_via.c line 1351
Quoted 7 lines
sound/pci/hda/patch_via.c +2
-1@@ -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...
Quoted 9 lines
sound/pci/hda/patch_via.c +3
-3present =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;
sound/pci/hda/patch_via.c line 1367
Quoted 10 lines
sound/pci/hda/patch_via.c +10
-0+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
Quoted 7 lines · Takashi Iwai
At Mon, 5 Oct 2009 22:27:16 +0800,
Quoted 5 lines · Li Bo
[ALSA] HDA VIA: Refresh front playback mute if hp plug-in mutes speaker.
Signed-off-by Lydia Wang <[email protected]>
Quoted 15 lines
sound/pci/hda/patch_via.c 2009-10-05 15:10:22.000000000 +0800 line 1351
Quoted 12 lines
Index:
sound-2.6/sound/pci/hda/patch_via.c
===================================================================sound/pci/hda/patch_via.c 2009-10-05 15:10:22.000000000 +0800 renamed from sound/pci/hda/patch_via.c 2009-10-05 15:10:13.000000000 +0800 +2
-1@@ -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
Quoted 21 lines
Quoted 10 lines
sound/pci/hda/patch_via.c 2009-10-05 15:10:22.000000000 +0800 renamed from sound/pci/hda/patch_via.c 2009-10-05 15:10:13.000000000 +0800 +3
-3present = 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;sound/pci/hda/patch_via.c 2009-10-05 15:10:22.000000000 +0800 line 1366
Quoted 10 lines
sound/pci/hda/patch_via.c 2009-10-05 15:10:22.000000000 +0800 renamed from sound/pci/hda/patch_via.c 2009-10-05 15:10:13.000000000 +0800 +10
-0+ 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);
Quoted 3 lines
Don't search for a kctl here.
Just set upkctl->id, and letsnd_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?
Quoted 4 lines
Takashi
At Tue, 6 Oct 2009 13:10:54 +0800,
Quoted 48 lines · Li Bo
Quoted 7 lines · Takashi Iwai
At Mon, 5 Oct 2009 22:27:16 +0800,
Quoted 5 lines · Li Bo
[ALSA] HDA VIA: Refresh front playback mute if hp plug-in mutes speaker.
Signed-off-by Lydia Wang <[email protected]>Quoted 15 lines
sound/pci/hda/patch_via.c 2009-10-05 15:10:22.000000000 +0800 line 1351
Quoted 12 lines
Index:
sound-2.6/sound/pci/hda/patch_via.c
===================================================================sound/pci/hda/patch_via.c 2009-10-05 15:10:22.000000000 +0800 renamed from sound/pci/hda/patch_via.c 2009-10-05 15:10:13.000000000 +0800 +2
-1@@ -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
Quoted 21 lines
Quoted 20 lines
sound/pci/hda/patch_via.c 2009-10-05 15:10:22.000000000 +0800 renamed from sound/pci/hda/patch_via.c 2009-10-05 15:10:13.000000000 +0800 +13
-3present = 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);
Quoted 6 lines
Quoted 3 lines
Don't search for a kctl here.
Just set upkctl->id, and letsnd_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
_______________________________________________
Alsa-devel mailing list
[email protected]
http://mailman.alsa-project.org/mailman/listinfo/alsa-devel
Quoted 60 lines · Takashi Iwai
At Tue, 6 Oct 2009 13:10:54 +0800,
Quoted 48 lines · Li Bo
Quoted 7 lines · Takashi Iwai
At Mon, 5 Oct 2009 22:27:16 +0800,
Quoted 5 lines · Li Bo
[ALSA] HDA VIA: Refresh front playback mute if hp plug-in mutes speaker.
Signed-off-by Lydia Wang <[email protected]>Quoted 15 lines
sound/pci/hda/patch_via.c 2009-10-05 15:10:22.000000000 +0800 line 1351
Quoted 12 lines
Index:
sound-2.6/sound/pci/hda/patch_via.c
===================================================================sound/pci/hda/patch_via.c 2009-10-05 15:10:22.000000000 +0800 renamed from sound/pci/hda/patch_via.c 2009-10-05 15:10:13.000000000 +0800 +2
-1@@ -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
Quoted 21 lines
Quoted 20 lines
sound/pci/hda/patch_via.c 2009-10-05 15:10:22.000000000 +0800 renamed from sound/pci/hda/patch_via.c 2009-10-05 15:10:13.000000000 +0800 +13
-3present = 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);Quoted 6 lines
Quoted 3 lines
Don't search for a kctl here.
Just set upkctl->id, and letsnd_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:
Quoted 9 lines
struct
snd_ctl_elem_idid;
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
Good, it works just fine:)
[ALSA] HDA VIA: Refresh front playback mute if hp plug-in mutes speaker.
--- sound/pci/hda/patch_via.c | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-)
sound/pci/hda/patch_via.c +15 -4
@@ -1351,14 +1351,25 @@/* 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; 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_ctl_elem_id id; +/* 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 */ +memset (&id,0 ,sizeof (id)); + id.iface =SNDRV_CTL_ELEM_IFACE_MIXER ; +strcpy (id.name,"Front Playback Switch" ); +snd_ctl_notify (codec->bus->card,SNDRV_CTL_EVENT_MASK_VALUE , + &id); + } }static void via_gpio_control (struct hda_codec *codec)