.. | .. |
---|
| 1 | +// SPDX-License-Identifier: GPL-2.0-only |
---|
1 | 2 | /* |
---|
2 | | - * Virtual master and slave controls |
---|
| 3 | + * Virtual master and follower controls |
---|
3 | 4 | * |
---|
4 | 5 | * Copyright (c) 2008 by Takashi Iwai <tiwai@suse.de> |
---|
5 | | - * |
---|
6 | | - * This program is free software; you can redistribute it and/or |
---|
7 | | - * modify it under the terms of the GNU General Public License as |
---|
8 | | - * published by the Free Software Foundation, version 2. |
---|
9 | | - * |
---|
10 | 6 | */ |
---|
11 | 7 | |
---|
12 | 8 | #include <linux/slab.h> |
---|
.. | .. |
---|
25 | 21 | }; |
---|
26 | 22 | |
---|
27 | 23 | /* |
---|
28 | | - * link master - this contains a list of slave controls that are |
---|
| 24 | + * link master - this contains a list of follower controls that are |
---|
29 | 25 | * identical types, i.e. info returns the same value type and value |
---|
30 | 26 | * ranges, but may have different number of counts. |
---|
31 | 27 | * |
---|
32 | 28 | * The master control is so far only mono volume/switch for simplicity. |
---|
33 | | - * The same value will be applied to all slaves. |
---|
| 29 | + * The same value will be applied to all followers. |
---|
34 | 30 | */ |
---|
35 | 31 | struct link_master { |
---|
36 | | - struct list_head slaves; |
---|
| 32 | + struct list_head followers; |
---|
37 | 33 | struct link_ctl_info info; |
---|
38 | 34 | int val; /* the master value */ |
---|
39 | 35 | unsigned int tlv[4]; |
---|
.. | .. |
---|
42 | 38 | }; |
---|
43 | 39 | |
---|
44 | 40 | /* |
---|
45 | | - * link slave - this contains a slave control element |
---|
| 41 | + * link follower - this contains a follower control element |
---|
46 | 42 | * |
---|
47 | | - * It fakes the control callbacsk with additional attenuation by the |
---|
48 | | - * master control. A slave may have either one or two channels. |
---|
| 43 | + * It fakes the control callbacks with additional attenuation by the |
---|
| 44 | + * master control. A follower may have either one or two channels. |
---|
49 | 45 | */ |
---|
50 | 46 | |
---|
51 | | -struct link_slave { |
---|
| 47 | +struct link_follower { |
---|
52 | 48 | struct list_head list; |
---|
53 | 49 | struct link_master *master; |
---|
54 | 50 | struct link_ctl_info info; |
---|
55 | 51 | int vals[2]; /* current values */ |
---|
56 | 52 | unsigned int flags; |
---|
57 | 53 | struct snd_kcontrol *kctl; /* original kcontrol pointer */ |
---|
58 | | - struct snd_kcontrol slave; /* the copy of original control entry */ |
---|
| 54 | + struct snd_kcontrol follower; /* the copy of original control entry */ |
---|
59 | 55 | }; |
---|
60 | 56 | |
---|
61 | | -static int slave_update(struct link_slave *slave) |
---|
| 57 | +static int follower_update(struct link_follower *follower) |
---|
62 | 58 | { |
---|
63 | 59 | struct snd_ctl_elem_value *uctl; |
---|
64 | 60 | int err, ch; |
---|
.. | .. |
---|
66 | 62 | uctl = kzalloc(sizeof(*uctl), GFP_KERNEL); |
---|
67 | 63 | if (!uctl) |
---|
68 | 64 | return -ENOMEM; |
---|
69 | | - uctl->id = slave->slave.id; |
---|
70 | | - err = slave->slave.get(&slave->slave, uctl); |
---|
| 65 | + uctl->id = follower->follower.id; |
---|
| 66 | + err = follower->follower.get(&follower->follower, uctl); |
---|
71 | 67 | if (err < 0) |
---|
72 | 68 | goto error; |
---|
73 | | - for (ch = 0; ch < slave->info.count; ch++) |
---|
74 | | - slave->vals[ch] = uctl->value.integer.value[ch]; |
---|
| 69 | + for (ch = 0; ch < follower->info.count; ch++) |
---|
| 70 | + follower->vals[ch] = uctl->value.integer.value[ch]; |
---|
75 | 71 | error: |
---|
76 | 72 | kfree(uctl); |
---|
77 | 73 | return err < 0 ? err : 0; |
---|
78 | 74 | } |
---|
79 | 75 | |
---|
80 | | -/* get the slave ctl info and save the initial values */ |
---|
81 | | -static int slave_init(struct link_slave *slave) |
---|
| 76 | +/* get the follower ctl info and save the initial values */ |
---|
| 77 | +static int follower_init(struct link_follower *follower) |
---|
82 | 78 | { |
---|
83 | 79 | struct snd_ctl_elem_info *uinfo; |
---|
84 | 80 | int err; |
---|
85 | 81 | |
---|
86 | | - if (slave->info.count) { |
---|
| 82 | + if (follower->info.count) { |
---|
87 | 83 | /* already initialized */ |
---|
88 | | - if (slave->flags & SND_CTL_SLAVE_NEED_UPDATE) |
---|
89 | | - return slave_update(slave); |
---|
| 84 | + if (follower->flags & SND_CTL_FOLLOWER_NEED_UPDATE) |
---|
| 85 | + return follower_update(follower); |
---|
90 | 86 | return 0; |
---|
91 | 87 | } |
---|
92 | 88 | |
---|
93 | 89 | uinfo = kmalloc(sizeof(*uinfo), GFP_KERNEL); |
---|
94 | 90 | if (!uinfo) |
---|
95 | 91 | return -ENOMEM; |
---|
96 | | - uinfo->id = slave->slave.id; |
---|
97 | | - err = slave->slave.info(&slave->slave, uinfo); |
---|
| 92 | + uinfo->id = follower->follower.id; |
---|
| 93 | + err = follower->follower.info(&follower->follower, uinfo); |
---|
98 | 94 | if (err < 0) { |
---|
99 | 95 | kfree(uinfo); |
---|
100 | 96 | return err; |
---|
101 | 97 | } |
---|
102 | | - slave->info.type = uinfo->type; |
---|
103 | | - slave->info.count = uinfo->count; |
---|
104 | | - if (slave->info.count > 2 || |
---|
105 | | - (slave->info.type != SNDRV_CTL_ELEM_TYPE_INTEGER && |
---|
106 | | - slave->info.type != SNDRV_CTL_ELEM_TYPE_BOOLEAN)) { |
---|
107 | | - pr_err("ALSA: vmaster: invalid slave element\n"); |
---|
| 98 | + follower->info.type = uinfo->type; |
---|
| 99 | + follower->info.count = uinfo->count; |
---|
| 100 | + if (follower->info.count > 2 || |
---|
| 101 | + (follower->info.type != SNDRV_CTL_ELEM_TYPE_INTEGER && |
---|
| 102 | + follower->info.type != SNDRV_CTL_ELEM_TYPE_BOOLEAN)) { |
---|
| 103 | + pr_err("ALSA: vmaster: invalid follower element\n"); |
---|
108 | 104 | kfree(uinfo); |
---|
109 | 105 | return -EINVAL; |
---|
110 | 106 | } |
---|
111 | | - slave->info.min_val = uinfo->value.integer.min; |
---|
112 | | - slave->info.max_val = uinfo->value.integer.max; |
---|
| 107 | + follower->info.min_val = uinfo->value.integer.min; |
---|
| 108 | + follower->info.max_val = uinfo->value.integer.max; |
---|
113 | 109 | kfree(uinfo); |
---|
114 | 110 | |
---|
115 | | - return slave_update(slave); |
---|
| 111 | + return follower_update(follower); |
---|
116 | 112 | } |
---|
117 | 113 | |
---|
118 | 114 | /* initialize master volume */ |
---|
119 | 115 | static int master_init(struct link_master *master) |
---|
120 | 116 | { |
---|
121 | | - struct link_slave *slave; |
---|
| 117 | + struct link_follower *follower; |
---|
122 | 118 | |
---|
123 | 119 | if (master->info.count) |
---|
124 | 120 | return 0; /* already initialized */ |
---|
125 | 121 | |
---|
126 | | - list_for_each_entry(slave, &master->slaves, list) { |
---|
127 | | - int err = slave_init(slave); |
---|
| 122 | + list_for_each_entry(follower, &master->followers, list) { |
---|
| 123 | + int err = follower_init(follower); |
---|
128 | 124 | if (err < 0) |
---|
129 | 125 | return err; |
---|
130 | | - master->info = slave->info; |
---|
| 126 | + master->info = follower->info; |
---|
131 | 127 | master->info.count = 1; /* always mono */ |
---|
132 | 128 | /* set full volume as default (= no attenuation) */ |
---|
133 | 129 | master->val = master->info.max_val; |
---|
.. | .. |
---|
138 | 134 | return -ENOENT; |
---|
139 | 135 | } |
---|
140 | 136 | |
---|
141 | | -static int slave_get_val(struct link_slave *slave, |
---|
142 | | - struct snd_ctl_elem_value *ucontrol) |
---|
| 137 | +static int follower_get_val(struct link_follower *follower, |
---|
| 138 | + struct snd_ctl_elem_value *ucontrol) |
---|
143 | 139 | { |
---|
144 | 140 | int err, ch; |
---|
145 | 141 | |
---|
146 | | - err = slave_init(slave); |
---|
| 142 | + err = follower_init(follower); |
---|
147 | 143 | if (err < 0) |
---|
148 | 144 | return err; |
---|
149 | | - for (ch = 0; ch < slave->info.count; ch++) |
---|
150 | | - ucontrol->value.integer.value[ch] = slave->vals[ch]; |
---|
| 145 | + for (ch = 0; ch < follower->info.count; ch++) |
---|
| 146 | + ucontrol->value.integer.value[ch] = follower->vals[ch]; |
---|
151 | 147 | return 0; |
---|
152 | 148 | } |
---|
153 | 149 | |
---|
154 | | -static int slave_put_val(struct link_slave *slave, |
---|
155 | | - struct snd_ctl_elem_value *ucontrol) |
---|
| 150 | +static int follower_put_val(struct link_follower *follower, |
---|
| 151 | + struct snd_ctl_elem_value *ucontrol) |
---|
156 | 152 | { |
---|
157 | 153 | int err, ch, vol; |
---|
158 | 154 | |
---|
159 | | - err = master_init(slave->master); |
---|
| 155 | + err = master_init(follower->master); |
---|
160 | 156 | if (err < 0) |
---|
161 | 157 | return err; |
---|
162 | 158 | |
---|
163 | | - switch (slave->info.type) { |
---|
| 159 | + switch (follower->info.type) { |
---|
164 | 160 | case SNDRV_CTL_ELEM_TYPE_BOOLEAN: |
---|
165 | | - for (ch = 0; ch < slave->info.count; ch++) |
---|
| 161 | + for (ch = 0; ch < follower->info.count; ch++) |
---|
166 | 162 | ucontrol->value.integer.value[ch] &= |
---|
167 | | - !!slave->master->val; |
---|
| 163 | + !!follower->master->val; |
---|
168 | 164 | break; |
---|
169 | 165 | case SNDRV_CTL_ELEM_TYPE_INTEGER: |
---|
170 | | - for (ch = 0; ch < slave->info.count; ch++) { |
---|
| 166 | + for (ch = 0; ch < follower->info.count; ch++) { |
---|
171 | 167 | /* max master volume is supposed to be 0 dB */ |
---|
172 | 168 | vol = ucontrol->value.integer.value[ch]; |
---|
173 | | - vol += slave->master->val - slave->master->info.max_val; |
---|
174 | | - if (vol < slave->info.min_val) |
---|
175 | | - vol = slave->info.min_val; |
---|
176 | | - else if (vol > slave->info.max_val) |
---|
177 | | - vol = slave->info.max_val; |
---|
| 169 | + vol += follower->master->val - follower->master->info.max_val; |
---|
| 170 | + if (vol < follower->info.min_val) |
---|
| 171 | + vol = follower->info.min_val; |
---|
| 172 | + else if (vol > follower->info.max_val) |
---|
| 173 | + vol = follower->info.max_val; |
---|
178 | 174 | ucontrol->value.integer.value[ch] = vol; |
---|
179 | 175 | } |
---|
180 | 176 | break; |
---|
181 | 177 | } |
---|
182 | | - return slave->slave.put(&slave->slave, ucontrol); |
---|
| 178 | + return follower->follower.put(&follower->follower, ucontrol); |
---|
183 | 179 | } |
---|
184 | 180 | |
---|
185 | 181 | /* |
---|
186 | | - * ctl callbacks for slaves |
---|
| 182 | + * ctl callbacks for followers |
---|
187 | 183 | */ |
---|
188 | | -static int slave_info(struct snd_kcontrol *kcontrol, |
---|
189 | | - struct snd_ctl_elem_info *uinfo) |
---|
| 184 | +static int follower_info(struct snd_kcontrol *kcontrol, |
---|
| 185 | + struct snd_ctl_elem_info *uinfo) |
---|
190 | 186 | { |
---|
191 | | - struct link_slave *slave = snd_kcontrol_chip(kcontrol); |
---|
192 | | - return slave->slave.info(&slave->slave, uinfo); |
---|
| 187 | + struct link_follower *follower = snd_kcontrol_chip(kcontrol); |
---|
| 188 | + return follower->follower.info(&follower->follower, uinfo); |
---|
193 | 189 | } |
---|
194 | 190 | |
---|
195 | | -static int slave_get(struct snd_kcontrol *kcontrol, |
---|
196 | | - struct snd_ctl_elem_value *ucontrol) |
---|
| 191 | +static int follower_get(struct snd_kcontrol *kcontrol, |
---|
| 192 | + struct snd_ctl_elem_value *ucontrol) |
---|
197 | 193 | { |
---|
198 | | - struct link_slave *slave = snd_kcontrol_chip(kcontrol); |
---|
199 | | - return slave_get_val(slave, ucontrol); |
---|
| 194 | + struct link_follower *follower = snd_kcontrol_chip(kcontrol); |
---|
| 195 | + return follower_get_val(follower, ucontrol); |
---|
200 | 196 | } |
---|
201 | 197 | |
---|
202 | | -static int slave_put(struct snd_kcontrol *kcontrol, |
---|
203 | | - struct snd_ctl_elem_value *ucontrol) |
---|
| 198 | +static int follower_put(struct snd_kcontrol *kcontrol, |
---|
| 199 | + struct snd_ctl_elem_value *ucontrol) |
---|
204 | 200 | { |
---|
205 | | - struct link_slave *slave = snd_kcontrol_chip(kcontrol); |
---|
| 201 | + struct link_follower *follower = snd_kcontrol_chip(kcontrol); |
---|
206 | 202 | int err, ch, changed = 0; |
---|
207 | 203 | |
---|
208 | | - err = slave_init(slave); |
---|
| 204 | + err = follower_init(follower); |
---|
209 | 205 | if (err < 0) |
---|
210 | 206 | return err; |
---|
211 | | - for (ch = 0; ch < slave->info.count; ch++) { |
---|
212 | | - if (slave->vals[ch] != ucontrol->value.integer.value[ch]) { |
---|
| 207 | + for (ch = 0; ch < follower->info.count; ch++) { |
---|
| 208 | + if (follower->vals[ch] != ucontrol->value.integer.value[ch]) { |
---|
213 | 209 | changed = 1; |
---|
214 | | - slave->vals[ch] = ucontrol->value.integer.value[ch]; |
---|
| 210 | + follower->vals[ch] = ucontrol->value.integer.value[ch]; |
---|
215 | 211 | } |
---|
216 | 212 | } |
---|
217 | 213 | if (!changed) |
---|
218 | 214 | return 0; |
---|
219 | | - err = slave_put_val(slave, ucontrol); |
---|
| 215 | + err = follower_put_val(follower, ucontrol); |
---|
220 | 216 | if (err < 0) |
---|
221 | 217 | return err; |
---|
222 | 218 | return 1; |
---|
223 | 219 | } |
---|
224 | 220 | |
---|
225 | | -static int slave_tlv_cmd(struct snd_kcontrol *kcontrol, |
---|
226 | | - int op_flag, unsigned int size, |
---|
227 | | - unsigned int __user *tlv) |
---|
| 221 | +static int follower_tlv_cmd(struct snd_kcontrol *kcontrol, |
---|
| 222 | + int op_flag, unsigned int size, |
---|
| 223 | + unsigned int __user *tlv) |
---|
228 | 224 | { |
---|
229 | | - struct link_slave *slave = snd_kcontrol_chip(kcontrol); |
---|
| 225 | + struct link_follower *follower = snd_kcontrol_chip(kcontrol); |
---|
230 | 226 | /* FIXME: this assumes that the max volume is 0 dB */ |
---|
231 | | - return slave->slave.tlv.c(&slave->slave, op_flag, size, tlv); |
---|
| 227 | + return follower->follower.tlv.c(&follower->follower, op_flag, size, tlv); |
---|
232 | 228 | } |
---|
233 | 229 | |
---|
234 | | -static void slave_free(struct snd_kcontrol *kcontrol) |
---|
| 230 | +static void follower_free(struct snd_kcontrol *kcontrol) |
---|
235 | 231 | { |
---|
236 | | - struct link_slave *slave = snd_kcontrol_chip(kcontrol); |
---|
237 | | - if (slave->slave.private_free) |
---|
238 | | - slave->slave.private_free(&slave->slave); |
---|
239 | | - if (slave->master) |
---|
240 | | - list_del(&slave->list); |
---|
241 | | - kfree(slave); |
---|
| 232 | + struct link_follower *follower = snd_kcontrol_chip(kcontrol); |
---|
| 233 | + if (follower->follower.private_free) |
---|
| 234 | + follower->follower.private_free(&follower->follower); |
---|
| 235 | + if (follower->master) |
---|
| 236 | + list_del(&follower->list); |
---|
| 237 | + kfree(follower); |
---|
242 | 238 | } |
---|
243 | 239 | |
---|
244 | 240 | /* |
---|
245 | | - * Add a slave control to the group with the given master control |
---|
| 241 | + * Add a follower control to the group with the given master control |
---|
246 | 242 | * |
---|
247 | | - * All slaves must be the same type (returning the same information |
---|
| 243 | + * All followers must be the same type (returning the same information |
---|
248 | 244 | * via info callback). The function doesn't check it, so it's your |
---|
249 | 245 | * responsibility. |
---|
250 | 246 | * |
---|
.. | .. |
---|
253 | 249 | * - logarithmic volume control (dB level), no linear volume |
---|
254 | 250 | * - master can only attenuate the volume, no gain |
---|
255 | 251 | */ |
---|
256 | | -int _snd_ctl_add_slave(struct snd_kcontrol *master, struct snd_kcontrol *slave, |
---|
257 | | - unsigned int flags) |
---|
| 252 | +int _snd_ctl_add_follower(struct snd_kcontrol *master, |
---|
| 253 | + struct snd_kcontrol *follower, |
---|
| 254 | + unsigned int flags) |
---|
258 | 255 | { |
---|
259 | 256 | struct link_master *master_link = snd_kcontrol_chip(master); |
---|
260 | | - struct link_slave *srec; |
---|
| 257 | + struct link_follower *srec; |
---|
261 | 258 | |
---|
262 | | - srec = kzalloc(struct_size(srec, slave.vd, slave->count), |
---|
| 259 | + srec = kzalloc(struct_size(srec, follower.vd, follower->count), |
---|
263 | 260 | GFP_KERNEL); |
---|
264 | 261 | if (!srec) |
---|
265 | 262 | return -ENOMEM; |
---|
266 | | - srec->kctl = slave; |
---|
267 | | - srec->slave = *slave; |
---|
268 | | - memcpy(srec->slave.vd, slave->vd, slave->count * sizeof(*slave->vd)); |
---|
| 263 | + srec->kctl = follower; |
---|
| 264 | + srec->follower = *follower; |
---|
| 265 | + memcpy(srec->follower.vd, follower->vd, follower->count * sizeof(*follower->vd)); |
---|
269 | 266 | srec->master = master_link; |
---|
270 | 267 | srec->flags = flags; |
---|
271 | 268 | |
---|
272 | 269 | /* override callbacks */ |
---|
273 | | - slave->info = slave_info; |
---|
274 | | - slave->get = slave_get; |
---|
275 | | - slave->put = slave_put; |
---|
276 | | - if (slave->vd[0].access & SNDRV_CTL_ELEM_ACCESS_TLV_CALLBACK) |
---|
277 | | - slave->tlv.c = slave_tlv_cmd; |
---|
278 | | - slave->private_data = srec; |
---|
279 | | - slave->private_free = slave_free; |
---|
| 270 | + follower->info = follower_info; |
---|
| 271 | + follower->get = follower_get; |
---|
| 272 | + follower->put = follower_put; |
---|
| 273 | + if (follower->vd[0].access & SNDRV_CTL_ELEM_ACCESS_TLV_CALLBACK) |
---|
| 274 | + follower->tlv.c = follower_tlv_cmd; |
---|
| 275 | + follower->private_data = srec; |
---|
| 276 | + follower->private_free = follower_free; |
---|
280 | 277 | |
---|
281 | | - list_add_tail(&srec->list, &master_link->slaves); |
---|
| 278 | + list_add_tail(&srec->list, &master_link->followers); |
---|
282 | 279 | return 0; |
---|
283 | 280 | } |
---|
284 | | -EXPORT_SYMBOL(_snd_ctl_add_slave); |
---|
| 281 | +EXPORT_SYMBOL(_snd_ctl_add_follower); |
---|
285 | 282 | |
---|
286 | 283 | /* |
---|
287 | 284 | * ctl callbacks for master controls |
---|
.. | .. |
---|
313 | 310 | return 0; |
---|
314 | 311 | } |
---|
315 | 312 | |
---|
316 | | -static int sync_slaves(struct link_master *master, int old_val, int new_val) |
---|
| 313 | +static int sync_followers(struct link_master *master, int old_val, int new_val) |
---|
317 | 314 | { |
---|
318 | | - struct link_slave *slave; |
---|
| 315 | + struct link_follower *follower; |
---|
319 | 316 | struct snd_ctl_elem_value *uval; |
---|
320 | 317 | |
---|
321 | 318 | uval = kmalloc(sizeof(*uval), GFP_KERNEL); |
---|
322 | 319 | if (!uval) |
---|
323 | 320 | return -ENOMEM; |
---|
324 | | - list_for_each_entry(slave, &master->slaves, list) { |
---|
| 321 | + list_for_each_entry(follower, &master->followers, list) { |
---|
325 | 322 | master->val = old_val; |
---|
326 | | - uval->id = slave->slave.id; |
---|
327 | | - slave_get_val(slave, uval); |
---|
| 323 | + uval->id = follower->follower.id; |
---|
| 324 | + follower_get_val(follower, uval); |
---|
328 | 325 | master->val = new_val; |
---|
329 | | - slave_put_val(slave, uval); |
---|
| 326 | + follower_put_val(follower, uval); |
---|
330 | 327 | } |
---|
331 | 328 | kfree(uval); |
---|
332 | 329 | return 0; |
---|
.. | .. |
---|
348 | 345 | if (new_val == old_val) |
---|
349 | 346 | return 0; |
---|
350 | 347 | |
---|
351 | | - err = sync_slaves(master, old_val, new_val); |
---|
| 348 | + err = sync_followers(master, old_val, new_val); |
---|
352 | 349 | if (err < 0) |
---|
353 | 350 | return err; |
---|
354 | 351 | if (master->hook && !first_init) |
---|
.. | .. |
---|
359 | 356 | static void master_free(struct snd_kcontrol *kcontrol) |
---|
360 | 357 | { |
---|
361 | 358 | struct link_master *master = snd_kcontrol_chip(kcontrol); |
---|
362 | | - struct link_slave *slave, *n; |
---|
| 359 | + struct link_follower *follower, *n; |
---|
363 | 360 | |
---|
364 | | - /* free all slave links and retore the original slave kctls */ |
---|
365 | | - list_for_each_entry_safe(slave, n, &master->slaves, list) { |
---|
366 | | - struct snd_kcontrol *sctl = slave->kctl; |
---|
| 361 | + /* free all follower links and retore the original follower kctls */ |
---|
| 362 | + list_for_each_entry_safe(follower, n, &master->followers, list) { |
---|
| 363 | + struct snd_kcontrol *sctl = follower->kctl; |
---|
367 | 364 | struct list_head olist = sctl->list; |
---|
368 | | - memcpy(sctl, &slave->slave, sizeof(*sctl)); |
---|
369 | | - memcpy(sctl->vd, slave->slave.vd, |
---|
| 365 | + memcpy(sctl, &follower->follower, sizeof(*sctl)); |
---|
| 366 | + memcpy(sctl->vd, follower->follower.vd, |
---|
370 | 367 | sctl->count * sizeof(*sctl->vd)); |
---|
371 | 368 | sctl->list = olist; /* keep the current linked-list */ |
---|
372 | | - kfree(slave); |
---|
| 369 | + kfree(follower); |
---|
373 | 370 | } |
---|
374 | 371 | kfree(master); |
---|
375 | 372 | } |
---|
.. | .. |
---|
382 | 379 | * |
---|
383 | 380 | * Creates a virtual master control with the given name string. |
---|
384 | 381 | * |
---|
385 | | - * After creating a vmaster element, you can add the slave controls |
---|
386 | | - * via snd_ctl_add_slave() or snd_ctl_add_slave_uncached(). |
---|
| 382 | + * After creating a vmaster element, you can add the follower controls |
---|
| 383 | + * via snd_ctl_add_follower() or snd_ctl_add_follower_uncached(). |
---|
387 | 384 | * |
---|
388 | 385 | * The optional argument @tlv can be used to specify the TLV information |
---|
389 | 386 | * for dB scale of the master control. It should be a single element |
---|
.. | .. |
---|
407 | 404 | master = kzalloc(sizeof(*master), GFP_KERNEL); |
---|
408 | 405 | if (!master) |
---|
409 | 406 | return NULL; |
---|
410 | | - INIT_LIST_HEAD(&master->slaves); |
---|
| 407 | + INIT_LIST_HEAD(&master->followers); |
---|
411 | 408 | |
---|
412 | 409 | kctl = snd_ctl_new1(&knew, master); |
---|
413 | 410 | if (!kctl) { |
---|
.. | .. |
---|
459 | 456 | EXPORT_SYMBOL_GPL(snd_ctl_add_vmaster_hook); |
---|
460 | 457 | |
---|
461 | 458 | /** |
---|
462 | | - * snd_ctl_sync_vmaster - Sync the vmaster slaves and hook |
---|
| 459 | + * snd_ctl_sync_vmaster - Sync the vmaster followers and hook |
---|
463 | 460 | * @kcontrol: vmaster kctl element |
---|
464 | 461 | * @hook_only: sync only the hook |
---|
465 | 462 | * |
---|
466 | | - * Forcibly call the put callback of each slave and call the hook function |
---|
| 463 | + * Forcibly call the put callback of each follower and call the hook function |
---|
467 | 464 | * to synchronize with the current value of the given vmaster element. |
---|
468 | 465 | * NOP when NULL is passed to @kcontrol. |
---|
469 | 466 | */ |
---|
.. | .. |
---|
480 | 477 | if (err < 0) |
---|
481 | 478 | return; |
---|
482 | 479 | first_init = err; |
---|
483 | | - err = sync_slaves(master, master->val, master->val); |
---|
| 480 | + err = sync_followers(master, master->val, master->val); |
---|
484 | 481 | if (err < 0) |
---|
485 | 482 | return; |
---|
486 | 483 | } |
---|
.. | .. |
---|
491 | 488 | EXPORT_SYMBOL_GPL(snd_ctl_sync_vmaster); |
---|
492 | 489 | |
---|
493 | 490 | /** |
---|
494 | | - * snd_ctl_apply_vmaster_slaves - Apply function to each vmaster slave |
---|
| 491 | + * snd_ctl_apply_vmaster_followers - Apply function to each vmaster follower |
---|
495 | 492 | * @kctl: vmaster kctl element |
---|
496 | 493 | * @func: function to apply |
---|
497 | 494 | * @arg: optional function argument |
---|
498 | 495 | * |
---|
499 | | - * Apply the function @func to each slave kctl of the given vmaster kctl. |
---|
| 496 | + * Apply the function @func to each follower kctl of the given vmaster kctl. |
---|
500 | 497 | * Returns 0 if successful, or a negative error code. |
---|
501 | 498 | */ |
---|
502 | | -int snd_ctl_apply_vmaster_slaves(struct snd_kcontrol *kctl, |
---|
503 | | - int (*func)(struct snd_kcontrol *vslave, |
---|
504 | | - struct snd_kcontrol *slave, |
---|
505 | | - void *arg), |
---|
506 | | - void *arg) |
---|
| 499 | +int snd_ctl_apply_vmaster_followers(struct snd_kcontrol *kctl, |
---|
| 500 | + int (*func)(struct snd_kcontrol *vfollower, |
---|
| 501 | + struct snd_kcontrol *follower, |
---|
| 502 | + void *arg), |
---|
| 503 | + void *arg) |
---|
507 | 504 | { |
---|
508 | 505 | struct link_master *master; |
---|
509 | | - struct link_slave *slave; |
---|
| 506 | + struct link_follower *follower; |
---|
510 | 507 | int err; |
---|
511 | 508 | |
---|
512 | 509 | master = snd_kcontrol_chip(kctl); |
---|
513 | 510 | err = master_init(master); |
---|
514 | 511 | if (err < 0) |
---|
515 | 512 | return err; |
---|
516 | | - list_for_each_entry(slave, &master->slaves, list) { |
---|
517 | | - err = func(slave->kctl, &slave->slave, arg); |
---|
| 513 | + list_for_each_entry(follower, &master->followers, list) { |
---|
| 514 | + err = func(follower->kctl, &follower->follower, arg); |
---|
518 | 515 | if (err < 0) |
---|
519 | 516 | return err; |
---|
520 | 517 | } |
---|
521 | 518 | |
---|
522 | 519 | return 0; |
---|
523 | 520 | } |
---|
524 | | -EXPORT_SYMBOL_GPL(snd_ctl_apply_vmaster_slaves); |
---|
| 521 | +EXPORT_SYMBOL_GPL(snd_ctl_apply_vmaster_followers); |
---|