Skip to content

Commit e6ce180

Browse files
committed
ALSA: hda - Add jack pointer and unsolicited event bits to callback
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 <[email protected]>
1 parent 2bff7e9 commit e6ce180

File tree

2 files changed

+13
-5
lines changed

2 files changed

+13
-5
lines changed

sound/pci/hda/hda_jack.c

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -508,19 +508,25 @@ int snd_hda_jack_add_kctls(struct hda_codec *codec,
508508
}
509509
EXPORT_SYMBOL_GPL(snd_hda_jack_add_kctls);
510510

511-
static void call_jack_callback(struct hda_codec *codec,
511+
static void call_jack_callback(struct hda_codec *codec, unsigned int res,
512512
struct hda_jack_tbl *jack)
513513
{
514514
struct hda_jack_callback *cb;
515515

516-
for (cb = jack->callback; cb; cb = cb->next)
516+
for (cb = jack->callback; cb; cb = cb->next) {
517+
cb->jack = jack;
518+
cb->unsol_res = res;
517519
cb->func(codec, cb);
520+
}
518521
if (jack->gated_jack) {
519522
struct hda_jack_tbl *gated =
520523
snd_hda_jack_tbl_get(codec, jack->gated_jack);
521524
if (gated) {
522-
for (cb = gated->callback; cb; cb = cb->next)
525+
for (cb = gated->callback; cb; cb = cb->next) {
526+
cb->jack = gated;
527+
cb->unsol_res = res;
523528
cb->func(codec, cb);
529+
}
524530
}
525531
}
526532
}
@@ -540,7 +546,7 @@ void snd_hda_jack_unsol_event(struct hda_codec *codec, unsigned int res)
540546
return;
541547
event->jack_dirty = 1;
542548

543-
call_jack_callback(codec, event);
549+
call_jack_callback(codec, res, event);
544550
snd_hda_jack_report_sync(codec);
545551
}
546552
EXPORT_SYMBOL_GPL(snd_hda_jack_unsol_event);
@@ -566,7 +572,7 @@ void snd_hda_jack_poll_all(struct hda_codec *codec)
566572
if (old_sense == get_jack_plug_state(jack->pin_sense))
567573
continue;
568574
changes = 1;
569-
call_jack_callback(codec, jack);
575+
call_jack_callback(codec, 0, jack);
570576
}
571577
if (changes)
572578
snd_hda_jack_report_sync(codec);

sound/pci/hda/hda_jack.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@ struct hda_jack_callback {
2424
hda_nid_t nid;
2525
hda_jack_callback_fn func;
2626
unsigned int private_data; /* arbitrary data */
27+
unsigned int unsol_res; /* unsolicited event bits */
28+
struct hda_jack_tbl *jack; /* associated jack entry */
2729
struct hda_jack_callback *next;
2830
};
2931

0 commit comments

Comments
 (0)