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 int dev_id;
23 hda_jack_callback_fn func;
24 unsigned int private_data;
25 unsigned int unsol_res;
26 struct hda_jack_tbl *jack;
27 struct hda_jack_callback *next;
28};
29
30struct hda_jack_tbl {
31 hda_nid_t nid;
32 int dev_id;
33 unsigned char tag;
34 struct hda_jack_callback *callback;
35
36 unsigned int pin_sense;
37 unsigned int jack_detect:1;
38 unsigned int jack_dirty:1;
39 unsigned int phantom_jack:1;
40 unsigned int block_report:1;
41 hda_nid_t gating_jack;
42 hda_nid_t gated_jack;
43 hda_nid_t key_report_jack;
44 int type;
45 int button_state;
46 struct snd_jack *jack;
47};
48
49struct hda_jack_keymap {
50 enum snd_jack_types type;
51 int key;
52};
53
54struct hda_jack_tbl *
55snd_hda_jack_tbl_get_mst(struct hda_codec *codec, hda_nid_t nid, int dev_id);
56
57
58
59
60
61
62static inline struct hda_jack_tbl *
63snd_hda_jack_tbl_get(struct hda_codec *codec, hda_nid_t nid)
64{
65 return snd_hda_jack_tbl_get_mst(codec, nid, 0);
66}
67
68struct hda_jack_tbl *
69snd_hda_jack_tbl_get_from_tag(struct hda_codec *codec,
70 unsigned char tag, int dev_id);
71
72void snd_hda_jack_tbl_clear(struct hda_codec *codec);
73
74void snd_hda_jack_set_dirty_all(struct hda_codec *codec);
75
76int snd_hda_jack_detect_enable(struct hda_codec *codec, hda_nid_t nid,
77 int dev_id);
78
79struct hda_jack_callback *
80snd_hda_jack_detect_enable_callback_mst(struct hda_codec *codec, hda_nid_t nid,
81 int dev_id, hda_jack_callback_fn func);
82
83
84
85
86
87
88
89
90
91
92
93static inline struct hda_jack_callback *
94snd_hda_jack_detect_enable_callback(struct hda_codec *codec, hda_nid_t nid,
95 hda_jack_callback_fn cb)
96{
97 return snd_hda_jack_detect_enable_callback_mst(codec, nid, 0, cb);
98}
99
100int snd_hda_jack_set_gating_jack(struct hda_codec *codec, hda_nid_t gated_nid,
101 hda_nid_t gating_nid);
102
103int snd_hda_jack_bind_keymap(struct hda_codec *codec, hda_nid_t key_nid,
104 const struct hda_jack_keymap *keymap,
105 hda_nid_t jack_nid);
106
107void snd_hda_jack_set_button_state(struct hda_codec *codec, hda_nid_t jack_nid,
108 int button_state);
109
110u32 snd_hda_jack_pin_sense(struct hda_codec *codec, hda_nid_t nid, int dev_id);
111
112
113enum {
114 HDA_JACK_NOT_PRESENT, HDA_JACK_PRESENT, HDA_JACK_PHANTOM,
115};
116
117int snd_hda_jack_detect_state_mst(struct hda_codec *codec, hda_nid_t nid,
118 int dev_id);
119
120
121
122
123
124
125
126
127
128static inline int
129snd_hda_jack_detect_state(struct hda_codec *codec, hda_nid_t nid)
130{
131 return snd_hda_jack_detect_state_mst(codec, nid, 0);
132}
133
134
135
136
137
138
139
140static inline bool
141snd_hda_jack_detect_mst(struct hda_codec *codec, hda_nid_t nid, int dev_id)
142{
143 return snd_hda_jack_detect_state_mst(codec, nid, dev_id) !=
144 HDA_JACK_NOT_PRESENT;
145}
146
147
148
149
150
151
152static inline bool
153snd_hda_jack_detect(struct hda_codec *codec, hda_nid_t nid)
154{
155 return snd_hda_jack_detect_mst(codec, nid, 0);
156}
157
158bool is_jack_detectable(struct hda_codec *codec, hda_nid_t nid);
159
160int snd_hda_jack_add_kctl_mst(struct hda_codec *codec, hda_nid_t nid,
161 int dev_id, const char *name, bool phantom_jack,
162 int type, const struct hda_jack_keymap *keymap);
163
164
165
166
167
168
169
170
171
172
173
174
175
176static inline int
177snd_hda_jack_add_kctl(struct hda_codec *codec, hda_nid_t nid,
178 const char *name, bool phantom_jack,
179 int type, const struct hda_jack_keymap *keymap)
180{
181 return snd_hda_jack_add_kctl_mst(codec, nid, 0,
182 name, phantom_jack, type, keymap);
183}
184
185int snd_hda_jack_add_kctls(struct hda_codec *codec,
186 const struct auto_pin_cfg *cfg);
187
188void snd_hda_jack_report_sync(struct hda_codec *codec);
189
190void snd_hda_jack_unsol_event(struct hda_codec *codec, unsigned int res);
191
192void snd_hda_jack_poll_all(struct hda_codec *codec);
193
194#endif
195