1
2
3
4
5
6
7
8#ifndef __SOUND_HDA_JACK_H
9#define __SOUND_HDA_JACK_H
10
11#include <linux/err.h>
12#include <sound/jack.h>
13
14struct auto_pin_cfg;
15struct hda_jack_tbl;
16struct hda_jack_callback;
17
18typedef void (*hda_jack_callback_fn) (struct hda_codec *, struct hda_jack_callback *);
19
20struct hda_jack_callback {
21 hda_nid_t nid;
22 hda_jack_callback_fn func;
23 unsigned int private_data;
24 unsigned int unsol_res;
25 struct hda_jack_tbl *jack;
26 struct hda_jack_callback *next;
27};
28
29struct hda_jack_tbl {
30 hda_nid_t nid;
31 unsigned char tag;
32 struct hda_jack_callback *callback;
33
34 unsigned int pin_sense;
35 unsigned int jack_detect:1;
36 unsigned int jack_dirty:1;
37 unsigned int phantom_jack:1;
38 unsigned int block_report:1;
39 hda_nid_t gating_jack;
40 hda_nid_t gated_jack;
41 int type;
42 int button_state;
43 struct snd_jack *jack;
44};
45
46struct hda_jack_keymap {
47 enum snd_jack_types type;
48 int key;
49};
50
51struct hda_jack_tbl *
52snd_hda_jack_tbl_get(struct hda_codec *codec, hda_nid_t nid);
53struct hda_jack_tbl *
54snd_hda_jack_tbl_get_from_tag(struct hda_codec *codec, unsigned char tag);
55
56void snd_hda_jack_tbl_clear(struct hda_codec *codec);
57
58void snd_hda_jack_set_dirty_all(struct hda_codec *codec);
59
60int snd_hda_jack_detect_enable(struct hda_codec *codec, hda_nid_t nid);
61struct hda_jack_callback *
62snd_hda_jack_detect_enable_callback(struct hda_codec *codec, hda_nid_t nid,
63 hda_jack_callback_fn cb);
64
65int snd_hda_jack_set_gating_jack(struct hda_codec *codec, hda_nid_t gated_nid,
66 hda_nid_t gating_nid);
67
68u32 snd_hda_pin_sense(struct hda_codec *codec, hda_nid_t nid);
69
70
71enum {
72 HDA_JACK_NOT_PRESENT, HDA_JACK_PRESENT, HDA_JACK_PHANTOM,
73};
74
75int snd_hda_jack_detect_state(struct hda_codec *codec, hda_nid_t nid);
76
77
78
79
80
81
82static inline bool snd_hda_jack_detect(struct hda_codec *codec, hda_nid_t nid)
83{
84 return snd_hda_jack_detect_state(codec, nid) != HDA_JACK_NOT_PRESENT;
85}
86
87bool is_jack_detectable(struct hda_codec *codec, hda_nid_t nid);
88
89int snd_hda_jack_add_kctl(struct hda_codec *codec, hda_nid_t nid,
90 const char *name, bool phantom_jack,
91 int type, const struct hda_jack_keymap *keymap);
92int snd_hda_jack_add_kctls(struct hda_codec *codec,
93 const struct auto_pin_cfg *cfg);
94
95void snd_hda_jack_report_sync(struct hda_codec *codec);
96
97void snd_hda_jack_unsol_event(struct hda_codec *codec, unsigned int res);
98
99void snd_hda_jack_poll_all(struct hda_codec *codec);
100
101#endif
102