ALSA: hda - Manage unsol tags in hda_jack.c

Manage the tags assigned for unsolicited events dynamically together
with the jack-detection routines.  Basically this is almost same as what
we've done in patch_sigmatel.c.  Assign the new tag number for each new
unsol event, associate with the given NID and the action type, etc.

With this change, now all pins looked over in snd_hda_jack_add_kctls()
are actually enabled for detection now even if the pins aren't used for
jack-retasking by the driver.

Signed-off-by: Takashi Iwai <tiwai@suse.de>
This commit is contained in:
Takashi Iwai
2011-10-28 01:16:55 +02:00
förälder 01a61e12b4
incheckning 3a93897ea3
8 ändrade filer med 105 tillägg och 126 borttagningar

Visa fil

@@ -14,8 +14,12 @@
struct hda_jack_tbl {
hda_nid_t nid;
unsigned char action; /* event action (0 = none) */
unsigned char tag; /* unsol event tag */
unsigned int private_data; /* arbitrary data */
/* jack-detection stuff */
unsigned int pin_sense; /* cached pin-sense value */
unsigned int jack_cachable:1; /* can be updated via unsol events */
unsigned int jack_detect:1; /* capable of jack-detection? */
unsigned int jack_dirty:1; /* needs to update? */
unsigned int need_notify:1; /* to be notified? */
struct snd_kcontrol *kctl; /* assigned kctl for jack-detection */
@@ -23,29 +27,34 @@ struct hda_jack_tbl {
struct hda_jack_tbl *
snd_hda_jack_tbl_get(struct hda_codec *codec, hda_nid_t nid);
struct hda_jack_tbl *
snd_hda_jack_tbl_get_from_tag(struct hda_codec *codec, unsigned char tag);
struct hda_jack_tbl *
snd_hda_jack_tbl_new(struct hda_codec *codec, hda_nid_t nid);
void snd_hda_jack_tbl_clear(struct hda_codec *codec);
/**
* snd_hda_jack_set_dirty - set the dirty flag for the given jack-entry
* snd_hda_jack_get_action - get jack-tbl entry for the tag
*
* Call this function when a pin-state may change, e.g. when the hardware
* notifies via an unsolicited event.
* Call this from the unsol event handler to get the assigned action for the
* event. This will mark the dirty flag for the later reporting, too.
*/
static inline void snd_hda_jack_set_dirty(struct hda_codec *codec,
hda_nid_t nid)
static inline unsigned char
snd_hda_jack_get_action(struct hda_codec *codec, unsigned int tag)
{
struct hda_jack_tbl *jack = snd_hda_jack_tbl_get(codec, nid);
if (jack)
struct hda_jack_tbl *jack = snd_hda_jack_tbl_get_from_tag(codec, tag);
if (jack) {
jack->jack_dirty = 1;
return jack->action;
}
return 0;
}
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,
unsigned int tag);
unsigned char action);
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);
@@ -68,7 +77,6 @@ int snd_hda_jack_add_kctl(struct hda_codec *codec, hda_nid_t nid,
int snd_hda_jack_add_kctls(struct hda_codec *codec,
const struct auto_pin_cfg *cfg);
void snd_hda_jack_report(struct hda_codec *codec, hda_nid_t nid);
void snd_hda_jack_report_sync(struct hda_codec *codec);