Lines Matching defs:slave
2 * Virtual master and slave controls
27 * link master - this contains a list of slave controls that are
42 * link slave - this contains a slave control element
45 * master control. A slave may have either one or two channels.
54 struct snd_kcontrol slave; /* the copy of original control entry */
57 static int slave_update(struct link_slave *slave)
65 uctl->id = slave->slave.id;
66 err = slave->slave.get(&slave->slave, uctl);
67 for (ch = 0; ch < slave->info.count; ch++)
68 slave->vals[ch] = uctl->value.integer.value[ch];
73 /* get the slave ctl info and save the initial values */
74 static int slave_init(struct link_slave *slave)
79 if (slave->info.count) {
81 if (slave->flags & SND_CTL_SLAVE_NEED_UPDATE)
82 return slave_update(slave);
89 uinfo->id = slave->slave.id;
90 err = slave->slave.info(&slave->slave, uinfo);
95 slave->info.type = uinfo->type;
96 slave->info.count = uinfo->count;
97 if (slave->info.count > 2 ||
98 (slave->info.type != SNDRV_CTL_ELEM_TYPE_INTEGER &&
99 slave->info.type != SNDRV_CTL_ELEM_TYPE_BOOLEAN)) {
100 snd_printk(KERN_ERR "invalid slave element\n");
104 slave->info.min_val = uinfo->value.integer.min;
105 slave->info.max_val = uinfo->value.integer.max;
108 return slave_update(slave);
114 struct link_slave *slave;
119 list_for_each_entry(slave, &master->slaves, list) {
120 int err = slave_init(slave);
123 master->info = slave->info;
132 static int slave_get_val(struct link_slave *slave,
137 err = slave_init(slave);
140 for (ch = 0; ch < slave->info.count; ch++)
141 ucontrol->value.integer.value[ch] = slave->vals[ch];
145 static int slave_put_val(struct link_slave *slave,
150 err = master_init(slave->master);
154 switch (slave->info.type) {
156 for (ch = 0; ch < slave->info.count; ch++)
158 !!slave->master->val;
161 for (ch = 0; ch < slave->info.count; ch++) {
164 vol += slave->master->val - slave->master->info.max_val;
165 if (vol < slave->info.min_val)
166 vol = slave->info.min_val;
167 else if (vol > slave->info.max_val)
168 vol = slave->info.max_val;
173 return slave->slave.put(&slave->slave, ucontrol);
182 struct link_slave *slave = snd_kcontrol_chip(kcontrol);
183 return slave->slave.info(&slave->slave, uinfo);
189 struct link_slave *slave = snd_kcontrol_chip(kcontrol);
190 return slave_get_val(slave, ucontrol);
196 struct link_slave *slave = snd_kcontrol_chip(kcontrol);
199 err = slave_init(slave);
202 for (ch = 0; ch < slave->info.count; ch++) {
203 if (slave->vals[ch] != ucontrol->value.integer.value[ch]) {
205 slave->vals[ch] = ucontrol->value.integer.value[ch];
210 return slave_put_val(slave, ucontrol);
217 struct link_slave *slave = snd_kcontrol_chip(kcontrol);
218 return slave->slave.tlv.c(&slave->slave, op_flag, size, tlv);
223 struct link_slave *slave = snd_kcontrol_chip(kcontrol);
224 if (slave->slave.private_free)
225 slave->slave.private_free(&slave->slave);
226 if (slave->master)
227 list_del(&slave->list);
228 kfree(slave);
232 * Add a slave control to the group with the given master control
243 int _snd_ctl_add_slave(struct snd_kcontrol *master, struct snd_kcontrol *slave,
250 slave->count * sizeof(*slave->vd), GFP_KERNEL);
253 srec->slave = *slave;
254 memcpy(srec->slave.vd, slave->vd, slave->count * sizeof(*slave->vd));
259 slave->info = slave_info;
260 slave->get = slave_get;
261 slave->put = slave_put;
262 if (slave->vd[0].access & SNDRV_CTL_ELEM_ACCESS_TLV_CALLBACK)
263 slave->tlv.c = slave_tlv_cmd;
264 slave->private_data = srec;
265 slave->private_free = slave_free;
306 struct link_slave *slave;
320 list_for_each_entry(slave, &master->slaves, list) {
322 uval->id = slave->slave.id;
323 slave_get_val(slave, uval);
325 slave_put_val(slave, uval);
334 struct link_slave *slave;
336 list_for_each_entry(slave, &master->slaves, list)
337 slave->master = NULL;
350 * After creating a vmaster element, you can add the slave controls