aboutsummaryrefslogtreecommitdiffstats
path: root/sound/pci/hda/patch_cirrus.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_cirrus.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_cirrus.c')
-rw-r--r--sound/pci/hda/patch_cirrus.c18
1 files changed, 8 insertions, 10 deletions
diff --git a/sound/pci/hda/patch_cirrus.c b/sound/pci/hda/patch_cirrus.c
index 34a460bd27bb..6f158777f71a 100644
--- a/sound/pci/hda/patch_cirrus.c
+++ b/sound/pci/hda/patch_cirrus.c
@@ -26,6 +26,7 @@
26#include <sound/core.h> 26#include <sound/core.h>
27#include "hda_codec.h" 27#include "hda_codec.h"
28#include "hda_local.h" 28#include "hda_local.h"
29#include "hda_jack.h"
29#include <sound/tlv.h> 30#include <sound/tlv.h>
30 31
31/* 32/*
@@ -1020,9 +1021,7 @@ static void init_output(struct hda_codec *codec)
1020 if (!cfg->speaker_outs) 1021 if (!cfg->speaker_outs)
1021 continue; 1022 continue;
1022 if (get_wcaps(codec, nid) & AC_WCAP_UNSOL_CAP) { 1023 if (get_wcaps(codec, nid) & AC_WCAP_UNSOL_CAP) {
1023 snd_hda_codec_write(codec, nid, 0, 1024 snd_hda_jack_detect_enable(codec, nid, HP_EVENT);
1024 AC_VERB_SET_UNSOLICITED_ENABLE,
1025 AC_USRSP_EN | HP_EVENT);
1026 spec->hp_detect = 1; 1025 spec->hp_detect = 1;
1027 } 1026 }
1028 } 1027 }
@@ -1063,9 +1062,7 @@ static void init_input(struct hda_codec *codec)
1063 AC_VERB_SET_AMP_GAIN_MUTE, 1062 AC_VERB_SET_AMP_GAIN_MUTE,
1064 AMP_IN_MUTE(spec->adc_idx[i])); 1063 AMP_IN_MUTE(spec->adc_idx[i]));
1065 if (spec->mic_detect && spec->automic_idx == i) 1064 if (spec->mic_detect && spec->automic_idx == i)
1066 snd_hda_codec_write(codec, pin, 0, 1065 snd_hda_jack_detect_enable(codec, pin, MIC_EVENT);
1067 AC_VERB_SET_UNSOLICITED_ENABLE,
1068 AC_USRSP_EN | MIC_EVENT);
1069 } 1066 }
1070 /* specific to CS421x */ 1067 /* specific to CS421x */
1071 if (spec->vendor_nid == CS421X_VENDOR_NID) { 1068 if (spec->vendor_nid == CS421X_VENDOR_NID) {
@@ -1227,6 +1224,8 @@ static void cs_free(struct hda_codec *codec)
1227 1224
1228static void cs_unsol_event(struct hda_codec *codec, unsigned int res) 1225static void cs_unsol_event(struct hda_codec *codec, unsigned int res)
1229{ 1226{
1227 snd_hda_jack_set_dirty_all(codec); /* FIXME: to be more fine-grained */
1228
1230 switch ((res >> 26) & 0x7f) { 1229 switch ((res >> 26) & 0x7f) {
1231 case HP_EVENT: 1230 case HP_EVENT:
1232 cs_automute(codec); 1231 cs_automute(codec);
@@ -1585,10 +1584,7 @@ static void init_cs421x_digital(struct hda_codec *codec)
1585 if (!cfg->speaker_outs) 1584 if (!cfg->speaker_outs)
1586 continue; 1585 continue;
1587 if (get_wcaps(codec, nid) & AC_WCAP_UNSOL_CAP) { 1586 if (get_wcaps(codec, nid) & AC_WCAP_UNSOL_CAP) {
1588 1587 snd_hda_jack_detect_enable(codec, nid, SPDIF_EVENT);
1589 snd_hda_codec_write(codec, nid, 0,
1590 AC_VERB_SET_UNSOLICITED_ENABLE,
1591 AC_USRSP_EN | SPDIF_EVENT);
1592 spec->spdif_detect = 1; 1588 spec->spdif_detect = 1;
1593 } 1589 }
1594 } 1590 }
@@ -1806,6 +1802,8 @@ static int cs421x_build_controls(struct hda_codec *codec)
1806 1802
1807static void cs421x_unsol_event(struct hda_codec *codec, unsigned int res) 1803static void cs421x_unsol_event(struct hda_codec *codec, unsigned int res)
1808{ 1804{
1805 snd_hda_jack_set_dirty_all(codec); /* FIXME: to be more fine-grained */
1806
1809 switch ((res >> 26) & 0x3f) { 1807 switch ((res >> 26) & 0x3f) {
1810 case HP_EVENT: 1808 case HP_EVENT:
1811 case SPDIF_EVENT: 1809 case SPDIF_EVENT: