Skip to content

Commit

Permalink
ALSA: hda - Add jack pointer and unsolicited event bits to callback
Browse files Browse the repository at this point in the history
For allowing the callee to evaluate the associated jack information
and the unsolicited event data, add the new fields to
hda_jack_callback.  They can be used, for example, to retrieve the
headset button state in the callback.

Signed-off-by: Takashi Iwai <tiwai@suse.de>
  • Loading branch information
Takashi Iwai committed Dec 7, 2018
1 parent 2bff7e9 commit e6ce180
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 5 deletions.
16 changes: 11 additions & 5 deletions sound/pci/hda/hda_jack.c
Original file line number Diff line number Diff line change
Expand Up @@ -508,19 +508,25 @@ int snd_hda_jack_add_kctls(struct hda_codec *codec,
}
EXPORT_SYMBOL_GPL(snd_hda_jack_add_kctls);

static void call_jack_callback(struct hda_codec *codec,
static void call_jack_callback(struct hda_codec *codec, unsigned int res,
struct hda_jack_tbl *jack)
{
struct hda_jack_callback *cb;

for (cb = jack->callback; cb; cb = cb->next)
for (cb = jack->callback; cb; cb = cb->next) {
cb->jack = jack;
cb->unsol_res = res;
cb->func(codec, cb);
}
if (jack->gated_jack) {
struct hda_jack_tbl *gated =
snd_hda_jack_tbl_get(codec, jack->gated_jack);
if (gated) {
for (cb = gated->callback; cb; cb = cb->next)
for (cb = gated->callback; cb; cb = cb->next) {
cb->jack = gated;
cb->unsol_res = res;
cb->func(codec, cb);
}
}
}
}
Expand All @@ -540,7 +546,7 @@ void snd_hda_jack_unsol_event(struct hda_codec *codec, unsigned int res)
return;
event->jack_dirty = 1;

call_jack_callback(codec, event);
call_jack_callback(codec, res, event);
snd_hda_jack_report_sync(codec);
}
EXPORT_SYMBOL_GPL(snd_hda_jack_unsol_event);
Expand All @@ -566,7 +572,7 @@ void snd_hda_jack_poll_all(struct hda_codec *codec)
if (old_sense == get_jack_plug_state(jack->pin_sense))
continue;
changes = 1;
call_jack_callback(codec, jack);
call_jack_callback(codec, 0, jack);
}
if (changes)
snd_hda_jack_report_sync(codec);
Expand Down
2 changes: 2 additions & 0 deletions sound/pci/hda/hda_jack.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ struct hda_jack_callback {
hda_nid_t nid;
hda_jack_callback_fn func;
unsigned int private_data; /* arbitrary data */
unsigned int unsol_res; /* unsolicited event bits */
struct hda_jack_tbl *jack; /* associated jack entry */
struct hda_jack_callback *next;
};

Expand Down

0 comments on commit e6ce180

Please sign in to comment.