diff options
author | Takashi Iwai <tiwai@suse.de> | 2011-10-27 16:12:46 -0400 |
---|---|---|
committer | Takashi Iwai <tiwai@suse.de> | 2011-11-16 05:11:15 -0500 |
commit | 1835a0f9a2121ce3198dab67507d4d3e960cc09e (patch) | |
tree | 5cbd9f34a3cb5d4906042c9fed5ab5fe2813123e /sound/pci/hda/patch_sigmatel.c | |
parent | 04f5ade6afc4326dc6cd10d235500972fba548eb (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_sigmatel.c')
-rw-r--r-- | sound/pci/hda/patch_sigmatel.c | 46 |
1 files changed, 27 insertions, 19 deletions
diff --git a/sound/pci/hda/patch_sigmatel.c b/sound/pci/hda/patch_sigmatel.c index 3b4ef0cba0e7..97c6df9db5e9 100644 --- a/sound/pci/hda/patch_sigmatel.c +++ b/sound/pci/hda/patch_sigmatel.c | |||
@@ -37,6 +37,7 @@ | |||
37 | #include "hda_codec.h" | 37 | #include "hda_codec.h" |
38 | #include "hda_local.h" | 38 | #include "hda_local.h" |
39 | #include "hda_beep.h" | 39 | #include "hda_beep.h" |
40 | #include "hda_jack.h" | ||
40 | 41 | ||
41 | enum { | 42 | enum { |
42 | STAC_VREF_EVENT = 1, | 43 | STAC_VREF_EVENT = 1, |
@@ -4244,9 +4245,7 @@ static int enable_pin_detect(struct hda_codec *codec, hda_nid_t nid, | |||
4244 | if (tag < 0) | 4245 | if (tag < 0) |
4245 | return 0; | 4246 | return 0; |
4246 | } | 4247 | } |
4247 | snd_hda_codec_write_cache(codec, nid, 0, | 4248 | snd_hda_jack_detect_enable(codec, nid, tag); |
4248 | AC_VERB_SET_UNSOLICITED_ENABLE, | ||
4249 | AC_USRSP_EN | tag); | ||
4250 | return 1; | 4249 | return 1; |
4251 | } | 4250 | } |
4252 | 4251 | ||
@@ -4795,24 +4794,11 @@ static void stac92xx_mic_detect(struct hda_codec *codec) | |||
4795 | mic->mux_idx); | 4794 | mic->mux_idx); |
4796 | } | 4795 | } |
4797 | 4796 | ||
4798 | static void stac_issue_unsol_event(struct hda_codec *codec, hda_nid_t nid) | 4797 | static void handle_unsol_event(struct hda_codec *codec, |
4799 | { | 4798 | struct sigmatel_event *event) |
4800 | struct sigmatel_event *event = stac_get_event(codec, nid); | ||
4801 | if (!event) | ||
4802 | return; | ||
4803 | codec->patch_ops.unsol_event(codec, (unsigned)event->tag << 26); | ||
4804 | } | ||
4805 | |||
4806 | static void stac92xx_unsol_event(struct hda_codec *codec, unsigned int res) | ||
4807 | { | 4799 | { |
4808 | struct sigmatel_spec *spec = codec->spec; | 4800 | struct sigmatel_spec *spec = codec->spec; |
4809 | struct sigmatel_event *event; | 4801 | int data; |
4810 | int tag, data; | ||
4811 | |||
4812 | tag = (res >> 26) & 0x7f; | ||
4813 | event = stac_get_event_from_tag(codec, tag); | ||
4814 | if (!event) | ||
4815 | return; | ||
4816 | 4802 | ||
4817 | switch (event->type) { | 4803 | switch (event->type) { |
4818 | case STAC_HP_EVENT: | 4804 | case STAC_HP_EVENT: |
@@ -4862,6 +4848,28 @@ static void stac92xx_unsol_event(struct hda_codec *codec, unsigned int res) | |||
4862 | } | 4848 | } |
4863 | } | 4849 | } |
4864 | 4850 | ||
4851 | static void stac_issue_unsol_event(struct hda_codec *codec, hda_nid_t nid) | ||
4852 | { | ||
4853 | struct sigmatel_event *event = stac_get_event(codec, nid); | ||
4854 | if (!event) | ||
4855 | return; | ||
4856 | handle_unsol_event(codec, event); | ||
4857 | } | ||
4858 | |||
4859 | static void stac92xx_unsol_event(struct hda_codec *codec, unsigned int res) | ||
4860 | { | ||
4861 | struct sigmatel_spec *spec = codec->spec; | ||
4862 | struct sigmatel_event *event; | ||
4863 | int tag; | ||
4864 | |||
4865 | tag = (res >> 26) & 0x7f; | ||
4866 | event = stac_get_event_from_tag(codec, tag); | ||
4867 | if (!event) | ||
4868 | return; | ||
4869 | snd_hda_jack_set_dirty(codec, event->nid); | ||
4870 | handle_unsol_event(codec, event); | ||
4871 | } | ||
4872 | |||
4865 | static int hp_blike_system(u32 subsystem_id); | 4873 | static int hp_blike_system(u32 subsystem_id); |
4866 | 4874 | ||
4867 | static void set_hp_led_gpio(struct hda_codec *codec) | 4875 | static void set_hp_led_gpio(struct hda_codec *codec) |