aboutsummaryrefslogtreecommitdiffstats
path: root/sound/pci/hda/patch_realtek.c
diff options
context:
space:
mode:
authorTakashi Iwai <tiwai@suse.de>2011-10-27 16:12:46 -0400
committerTakashi Iwai <tiwai@suse.de>2011-11-16 05:11:15 -0500
commit1835a0f9a2121ce3198dab67507d4d3e960cc09e (patch)
tree5cbd9f34a3cb5d4906042c9fed5ab5fe2813123e /sound/pci/hda/patch_realtek.c
parent04f5ade6afc4326dc6cd10d235500972fba548eb (diff)
ALSA: hda - Cache the jack-detection value
Introduce a table containing the pins and their jack-detection states for avoiding the unnecessary verbs to check the pin status at each time. When the unsol event is enabled via snd_hda_jack_detect_enable(), it automatically adds the given NID to the table. Then the driver supposes that the codec driver will set the dirty flag appropariately when an unsolicited event is invoked for that pin. The behavior for reading other pins that aren't registered in the table doesn't change. Only the pins assigned to the table are cached, so far. In near futre, this table can be extended to use the central place for the unsolicited events of all pins, etc, and eventually include the jack-detect kcontrols that replace the current input-jack stuff. Signed-off-by: Takashi Iwai <tiwai@suse.de>
Diffstat (limited to 'sound/pci/hda/patch_realtek.c')
-rw-r--r--sound/pci/hda/patch_realtek.c20
1 files changed, 8 insertions, 12 deletions
diff --git a/sound/pci/hda/patch_realtek.c b/sound/pci/hda/patch_realtek.c
index 14feecf2d802..da9d2276e68b 100644
--- a/sound/pci/hda/patch_realtek.c
+++ b/sound/pci/hda/patch_realtek.c
@@ -33,6 +33,7 @@
33#include "hda_codec.h" 33#include "hda_codec.h"
34#include "hda_local.h" 34#include "hda_local.h"
35#include "hda_beep.h" 35#include "hda_beep.h"
36#include "hda_jack.h"
36 37
37/* unsol event tags */ 38/* unsol event tags */
38#define ALC_FRONT_EVENT 0x01 39#define ALC_FRONT_EVENT 0x01
@@ -664,6 +665,7 @@ static void alc_sku_unsol_event(struct hda_codec *codec, unsigned int res)
664 res >>= 28; 665 res >>= 28;
665 else 666 else
666 res >>= 26; 667 res >>= 26;
668 snd_hda_jack_set_dirty_all(codec); /* FIXME: to be more fine-grained */
667 switch (res) { 669 switch (res) {
668 case ALC_HP_EVENT: 670 case ALC_HP_EVENT:
669 alc_hp_automute(codec); 671 alc_hp_automute(codec);
@@ -964,9 +966,7 @@ static void alc_init_automute(struct hda_codec *codec)
964 continue; 966 continue;
965 snd_printdd("realtek: Enable HP auto-muting on NID 0x%x\n", 967 snd_printdd("realtek: Enable HP auto-muting on NID 0x%x\n",
966 nid); 968 nid);
967 snd_hda_codec_write_cache(codec, nid, 0, 969 snd_hda_jack_detect_enable(codec, nid, ALC_HP_EVENT);
968 AC_VERB_SET_UNSOLICITED_ENABLE,
969 AC_USRSP_EN | ALC_HP_EVENT);
970 spec->detect_hp = 1; 970 spec->detect_hp = 1;
971 } 971 }
972 972
@@ -978,9 +978,8 @@ static void alc_init_automute(struct hda_codec *codec)
978 continue; 978 continue;
979 snd_printdd("realtek: Enable Line-Out " 979 snd_printdd("realtek: Enable Line-Out "
980 "auto-muting on NID 0x%x\n", nid); 980 "auto-muting on NID 0x%x\n", nid);
981 snd_hda_codec_write_cache(codec, nid, 0, 981 snd_hda_jack_detect_enable(codec, nid,
982 AC_VERB_SET_UNSOLICITED_ENABLE, 982 ALC_FRONT_EVENT);
983 AC_USRSP_EN | ALC_FRONT_EVENT);
984 spec->detect_lo = 1; 983 spec->detect_lo = 1;
985 } 984 }
986 spec->automute_lo_possible = spec->detect_hp; 985 spec->automute_lo_possible = spec->detect_hp;
@@ -1108,13 +1107,10 @@ static bool alc_auto_mic_check_imux(struct hda_codec *codec)
1108 return false; /* no corresponding imux */ 1107 return false; /* no corresponding imux */
1109 } 1108 }
1110 1109
1111 snd_hda_codec_write_cache(codec, spec->ext_mic_pin, 0, 1110 snd_hda_jack_detect_enable(codec, spec->ext_mic_pin, ALC_MIC_EVENT);
1112 AC_VERB_SET_UNSOLICITED_ENABLE,
1113 AC_USRSP_EN | ALC_MIC_EVENT);
1114 if (spec->dock_mic_pin) 1111 if (spec->dock_mic_pin)
1115 snd_hda_codec_write_cache(codec, spec->dock_mic_pin, 0, 1112 snd_hda_jack_detect_enable(codec, spec->dock_mic_pin,
1116 AC_VERB_SET_UNSOLICITED_ENABLE, 1113 ALC_MIC_EVENT);
1117 AC_USRSP_EN | ALC_MIC_EVENT);
1118 1114
1119 spec->auto_mic_valid_imux = 1; 1115 spec->auto_mic_valid_imux = 1;
1120 spec->auto_mic = 1; 1116 spec->auto_mic = 1;