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>
This commit is contained in:
parent
0fd0ba5f9e
commit
954df2a968
|
@ -192,8 +192,9 @@ EXPORT_SYMBOL_HDA(snd_hda_jack_detect);
|
||||||
/**
|
/**
|
||||||
* snd_hda_jack_detect_enable - enable the jack-detection
|
* snd_hda_jack_detect_enable - enable the jack-detection
|
||||||
*/
|
*/
|
||||||
int snd_hda_jack_detect_enable(struct hda_codec *codec, hda_nid_t nid,
|
int snd_hda_jack_detect_enable_callback(struct hda_codec *codec, hda_nid_t nid,
|
||||||
unsigned char action)
|
unsigned char action,
|
||||||
|
hda_jack_callback cb)
|
||||||
{
|
{
|
||||||
struct hda_jack_tbl *jack = snd_hda_jack_tbl_new(codec, nid);
|
struct hda_jack_tbl *jack = snd_hda_jack_tbl_new(codec, nid);
|
||||||
if (!jack)
|
if (!jack)
|
||||||
|
@ -203,10 +204,19 @@ int snd_hda_jack_detect_enable(struct hda_codec *codec, hda_nid_t nid,
|
||||||
jack->jack_detect = 1;
|
jack->jack_detect = 1;
|
||||||
if (action)
|
if (action)
|
||||||
jack->action = action;
|
jack->action = action;
|
||||||
|
if (cb)
|
||||||
|
jack->callback = cb;
|
||||||
return snd_hda_codec_write_cache(codec, nid, 0,
|
return snd_hda_codec_write_cache(codec, nid, 0,
|
||||||
AC_VERB_SET_UNSOLICITED_ENABLE,
|
AC_VERB_SET_UNSOLICITED_ENABLE,
|
||||||
AC_USRSP_EN | jack->tag);
|
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);
|
EXPORT_SYMBOL_HDA(snd_hda_jack_detect_enable);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -411,3 +421,21 @@ int snd_hda_jack_add_kctls(struct hda_codec *codec,
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
EXPORT_SYMBOL_HDA(snd_hda_jack_add_kctls);
|
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);
|
||||||
|
|
||||||
|
|
|
@ -13,12 +13,16 @@
|
||||||
#define __SOUND_HDA_JACK_H
|
#define __SOUND_HDA_JACK_H
|
||||||
|
|
||||||
struct auto_pin_cfg;
|
struct auto_pin_cfg;
|
||||||
|
struct hda_jack_tbl;
|
||||||
|
|
||||||
|
typedef void (*hda_jack_callback) (struct hda_codec *, struct hda_jack_tbl *);
|
||||||
|
|
||||||
struct hda_jack_tbl {
|
struct hda_jack_tbl {
|
||||||
hda_nid_t nid;
|
hda_nid_t nid;
|
||||||
unsigned char action; /* event action (0 = none) */
|
unsigned char action; /* event action (0 = none) */
|
||||||
unsigned char tag; /* unsol event tag */
|
unsigned char tag; /* unsol event tag */
|
||||||
unsigned int private_data; /* arbitrary data */
|
unsigned int private_data; /* arbitrary data */
|
||||||
|
hda_jack_callback callback;
|
||||||
/* jack-detection stuff */
|
/* jack-detection stuff */
|
||||||
unsigned int pin_sense; /* cached pin-sense value */
|
unsigned int pin_sense; /* cached pin-sense value */
|
||||||
unsigned int jack_detect:1; /* capable of jack-detection? */
|
unsigned int jack_detect:1; /* capable of jack-detection? */
|
||||||
|
@ -61,6 +65,10 @@ void snd_hda_jack_set_dirty_all(struct hda_codec *codec);
|
||||||
|
|
||||||
int snd_hda_jack_detect_enable(struct hda_codec *codec, hda_nid_t nid,
|
int snd_hda_jack_detect_enable(struct hda_codec *codec, hda_nid_t nid,
|
||||||
unsigned char action);
|
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);
|
||||||
|
|
||||||
|
|
||||||
u32 snd_hda_pin_sense(struct hda_codec *codec, hda_nid_t nid);
|
u32 snd_hda_pin_sense(struct hda_codec *codec, hda_nid_t nid);
|
||||||
int snd_hda_jack_detect(struct hda_codec *codec, hda_nid_t nid);
|
int snd_hda_jack_detect(struct hda_codec *codec, hda_nid_t nid);
|
||||||
|
@ -74,5 +82,6 @@ int snd_hda_jack_add_kctls(struct hda_codec *codec,
|
||||||
|
|
||||||
void snd_hda_jack_report_sync(struct hda_codec *codec);
|
void snd_hda_jack_report_sync(struct hda_codec *codec);
|
||||||
|
|
||||||
|
void snd_hda_jack_unsol_event(struct hda_codec *codec, unsigned int res);
|
||||||
|
|
||||||
#endif /* __SOUND_HDA_JACK_H */
|
#endif /* __SOUND_HDA_JACK_H */
|
||||||
|
|
Loading…
Reference in New Issue