diff options
author | David Henningsson <david.henningsson@canonical.com> | 2012-09-25 13:30:59 +0400 |
---|---|---|
committer | Takashi Iwai <tiwai@suse.de> | 2012-10-06 18:43:31 +0400 |
commit | 954df2a9686cebbb9cc4067697b370aa9ce77d4a (patch) | |
tree | c80b9b5959d14637b3061934c15b348449f0e79b /sound/pci/hda/hda_jack.c | |
parent | 0fd0ba5f9e8ebae66afded580f5f34936f740ac7 (diff) | |
download | linux-954df2a9686cebbb9cc4067697b370aa9ce77d4a.tar.xz |
ALSA: hda - make a generic unsol event handler
Moving towards less duplication of code between codecs - this patch
takes some of the common code of unsol event handling and makes it
generic.
Signed-off-by: David Henningsson <david.henningsson@canonical.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Diffstat (limited to 'sound/pci/hda/hda_jack.c')
-rw-r--r-- | sound/pci/hda/hda_jack.c | 32 |
1 files changed, 30 insertions, 2 deletions
diff --git a/sound/pci/hda/hda_jack.c b/sound/pci/hda/hda_jack.c index c9333c9688fb..5c690cb873d4 100644 --- a/sound/pci/hda/hda_jack.c +++ b/sound/pci/hda/hda_jack.c @@ -192,8 +192,9 @@ EXPORT_SYMBOL_HDA(snd_hda_jack_detect); /** * snd_hda_jack_detect_enable - enable the jack-detection */ -int snd_hda_jack_detect_enable(struct hda_codec *codec, hda_nid_t nid, - unsigned char action) +int snd_hda_jack_detect_enable_callback(struct hda_codec *codec, hda_nid_t nid, + unsigned char action, + hda_jack_callback cb) { struct hda_jack_tbl *jack = snd_hda_jack_tbl_new(codec, nid); if (!jack) @@ -203,10 +204,19 @@ int snd_hda_jack_detect_enable(struct hda_codec *codec, hda_nid_t nid, jack->jack_detect = 1; if (action) jack->action = action; + if (cb) + jack->callback = cb; return snd_hda_codec_write_cache(codec, nid, 0, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | jack->tag); } +EXPORT_SYMBOL_HDA(snd_hda_jack_detect_enable_callback); + +int snd_hda_jack_detect_enable(struct hda_codec *codec, hda_nid_t nid, + unsigned char action) +{ + return snd_hda_jack_detect_enable_callback(codec, nid, action, NULL); +} EXPORT_SYMBOL_HDA(snd_hda_jack_detect_enable); /** @@ -411,3 +421,21 @@ int snd_hda_jack_add_kctls(struct hda_codec *codec, return 0; } EXPORT_SYMBOL_HDA(snd_hda_jack_add_kctls); + +void snd_hda_jack_unsol_event(struct hda_codec *codec, unsigned int res) +{ + struct hda_jack_tbl *event; + int tag = (res >> AC_UNSOL_RES_TAG_SHIFT) & 0x7f; + + event = snd_hda_jack_tbl_get_from_tag(codec, tag); + if (!event) + return; + event->jack_dirty = 1; + + if (event->callback) + event->callback(codec, event); + + snd_hda_jack_report_sync(codec); +} +EXPORT_SYMBOL_HDA(snd_hda_jack_unsol_event); + |