1#ifndef __SOUND_CONTROL_H
2#define __SOUND_CONTROL_H
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25#include <linux/wait.h>
26#include <sound/asound.h>
27
28#define snd_kcontrol_chip(kcontrol) ((kcontrol)->private_data)
29
30struct snd_kcontrol;
31typedef int (snd_kcontrol_info_t) (struct snd_kcontrol * kcontrol, struct snd_ctl_elem_info * uinfo);
32typedef int (snd_kcontrol_get_t) (struct snd_kcontrol * kcontrol, struct snd_ctl_elem_value * ucontrol);
33typedef int (snd_kcontrol_put_t) (struct snd_kcontrol * kcontrol, struct snd_ctl_elem_value * ucontrol);
34typedef int (snd_kcontrol_tlv_rw_t)(struct snd_kcontrol *kcontrol,
35 int op_flag,
36 unsigned int size,
37 unsigned int __user *tlv);
38
39enum {
40 SNDRV_CTL_TLV_OP_READ = 0,
41 SNDRV_CTL_TLV_OP_WRITE = 1,
42 SNDRV_CTL_TLV_OP_CMD = -1,
43};
44
45struct snd_kcontrol_new {
46 snd_ctl_elem_iface_t iface;
47 unsigned int device;
48 unsigned int subdevice;
49 const unsigned char *name;
50 unsigned int index;
51 unsigned int access;
52 unsigned int count;
53 snd_kcontrol_info_t *info;
54 snd_kcontrol_get_t *get;
55 snd_kcontrol_put_t *put;
56 union {
57 snd_kcontrol_tlv_rw_t *c;
58 const unsigned int *p;
59 } tlv;
60 unsigned long private_value;
61};
62
63struct snd_kcontrol_volatile {
64 struct snd_ctl_file *owner;
65 unsigned int access;
66};
67
68struct snd_kcontrol {
69 struct list_head list;
70 struct snd_ctl_elem_id id;
71 unsigned int count;
72 snd_kcontrol_info_t *info;
73 snd_kcontrol_get_t *get;
74 snd_kcontrol_put_t *put;
75 union {
76 snd_kcontrol_tlv_rw_t *c;
77 const unsigned int *p;
78 } tlv;
79 unsigned long private_value;
80 void *private_data;
81 void (*private_free)(struct snd_kcontrol *kcontrol);
82 struct snd_kcontrol_volatile vd[0];
83};
84
85#define snd_kcontrol(n) list_entry(n, struct snd_kcontrol, list)
86
87struct snd_kctl_event {
88 struct list_head list;
89 struct snd_ctl_elem_id id;
90 unsigned int mask;
91};
92
93#define snd_kctl_event(n) list_entry(n, struct snd_kctl_event, list)
94
95struct pid;
96
97enum {
98 SND_CTL_SUBDEV_PCM,
99 SND_CTL_SUBDEV_RAWMIDI,
100 SND_CTL_SUBDEV_ITEMS,
101};
102
103struct snd_ctl_file {
104 struct list_head list;
105 struct snd_card *card;
106 struct pid *pid;
107 int preferred_subdevice[SND_CTL_SUBDEV_ITEMS];
108 wait_queue_head_t change_sleep;
109 spinlock_t read_lock;
110 struct fasync_struct *fasync;
111 int subscribed;
112 struct list_head events;
113};
114
115#define snd_ctl_file(n) list_entry(n, struct snd_ctl_file, list)
116
117typedef int (*snd_kctl_ioctl_func_t) (struct snd_card * card,
118 struct snd_ctl_file * control,
119 unsigned int cmd, unsigned long arg);
120
121void snd_ctl_notify(struct snd_card * card, unsigned int mask, struct snd_ctl_elem_id * id);
122
123struct snd_kcontrol *snd_ctl_new1(const struct snd_kcontrol_new * kcontrolnew, void * private_data);
124void snd_ctl_free_one(struct snd_kcontrol * kcontrol);
125int snd_ctl_add(struct snd_card * card, struct snd_kcontrol * kcontrol);
126int snd_ctl_remove(struct snd_card * card, struct snd_kcontrol * kcontrol);
127int snd_ctl_replace(struct snd_card *card, struct snd_kcontrol *kcontrol, bool add_on_replace);
128int snd_ctl_remove_id(struct snd_card * card, struct snd_ctl_elem_id *id);
129int snd_ctl_rename_id(struct snd_card * card, struct snd_ctl_elem_id *src_id, struct snd_ctl_elem_id *dst_id);
130int snd_ctl_activate_id(struct snd_card *card, struct snd_ctl_elem_id *id,
131 int active);
132struct snd_kcontrol *snd_ctl_find_numid(struct snd_card * card, unsigned int numid);
133struct snd_kcontrol *snd_ctl_find_id(struct snd_card * card, struct snd_ctl_elem_id *id);
134
135int snd_ctl_create(struct snd_card *card);
136
137int snd_ctl_register_ioctl(snd_kctl_ioctl_func_t fcn);
138int snd_ctl_unregister_ioctl(snd_kctl_ioctl_func_t fcn);
139#ifdef CONFIG_COMPAT
140int snd_ctl_register_ioctl_compat(snd_kctl_ioctl_func_t fcn);
141int snd_ctl_unregister_ioctl_compat(snd_kctl_ioctl_func_t fcn);
142#else
143#define snd_ctl_register_ioctl_compat(fcn)
144#define snd_ctl_unregister_ioctl_compat(fcn)
145#endif
146
147int snd_ctl_get_preferred_subdevice(struct snd_card *card, int type);
148
149static inline unsigned int snd_ctl_get_ioffnum(struct snd_kcontrol *kctl, struct snd_ctl_elem_id *id)
150{
151 return id->numid - kctl->id.numid;
152}
153
154static inline unsigned int snd_ctl_get_ioffidx(struct snd_kcontrol *kctl, struct snd_ctl_elem_id *id)
155{
156 return id->index - kctl->id.index;
157}
158
159static inline unsigned int snd_ctl_get_ioff(struct snd_kcontrol *kctl, struct snd_ctl_elem_id *id)
160{
161 if (id->numid) {
162 return snd_ctl_get_ioffnum(kctl, id);
163 } else {
164 return snd_ctl_get_ioffidx(kctl, id);
165 }
166}
167
168static inline struct snd_ctl_elem_id *snd_ctl_build_ioff(struct snd_ctl_elem_id *dst_id,
169 struct snd_kcontrol *src_kctl,
170 unsigned int offset)
171{
172 *dst_id = src_kctl->id;
173 dst_id->index += offset;
174 dst_id->numid += offset;
175 return dst_id;
176}
177
178
179
180
181int snd_ctl_boolean_mono_info(struct snd_kcontrol *kcontrol,
182 struct snd_ctl_elem_info *uinfo);
183int snd_ctl_boolean_stereo_info(struct snd_kcontrol *kcontrol,
184 struct snd_ctl_elem_info *uinfo);
185int snd_ctl_enum_info(struct snd_ctl_elem_info *info, unsigned int channels,
186 unsigned int items, const char *const names[]);
187
188
189
190
191struct snd_kcontrol *snd_ctl_make_virtual_master(char *name,
192 const unsigned int *tlv);
193int _snd_ctl_add_slave(struct snd_kcontrol *master, struct snd_kcontrol *slave,
194 unsigned int flags);
195
196#define SND_CTL_SLAVE_NEED_UPDATE (1 << 0)
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217static inline int
218snd_ctl_add_slave(struct snd_kcontrol *master, struct snd_kcontrol *slave)
219{
220 return _snd_ctl_add_slave(master, slave, 0);
221}
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239static inline int
240snd_ctl_add_slave_uncached(struct snd_kcontrol *master,
241 struct snd_kcontrol *slave)
242{
243 return _snd_ctl_add_slave(master, slave, SND_CTL_SLAVE_NEED_UPDATE);
244}
245
246int snd_ctl_add_vmaster_hook(struct snd_kcontrol *kctl,
247 void (*hook)(void *private_data, int),
248 void *private_data);
249void snd_ctl_sync_vmaster(struct snd_kcontrol *kctl, bool hook_only);
250#define snd_ctl_sync_vmaster_hook(kctl) snd_ctl_sync_vmaster(kctl, true)
251
252
253
254
255struct snd_kcontrol *
256snd_kctl_jack_new(const char *name, struct snd_card *card);
257void snd_kctl_jack_report(struct snd_card *card,
258 struct snd_kcontrol *kctl, bool status);
259
260#endif
261