vmaster.c (126f7051b4daa3716d9af2851dcb55316e4c2b25) vmaster.c (acafe7e30216166a17e6e226aadc3ecb63993242)
1/*
2 * Virtual master and slave controls
3 *
4 * 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.

--- 245 unchanged lines hidden (view full) ---

254 * - master can only attenuate the volume, no gain
255 */
256int _snd_ctl_add_slave(struct snd_kcontrol *master, struct snd_kcontrol *slave,
257 unsigned int flags)
258{
259 struct link_master *master_link = snd_kcontrol_chip(master);
260 struct link_slave *srec;
261
1/*
2 * Virtual master and slave controls
3 *
4 * 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.

--- 245 unchanged lines hidden (view full) ---

254 * - master can only attenuate the volume, no gain
255 */
256int _snd_ctl_add_slave(struct snd_kcontrol *master, struct snd_kcontrol *slave,
257 unsigned int flags)
258{
259 struct link_master *master_link = snd_kcontrol_chip(master);
260 struct link_slave *srec;
261
262 srec = kzalloc(sizeof(*srec) +
263 slave->count * sizeof(*slave->vd), GFP_KERNEL);
262 srec = kzalloc(struct_size(srec, slave.vd, slave->count),
263 GFP_KERNEL);
264 if (!srec)
265 return -ENOMEM;
266 srec->kctl = slave;
267 srec->slave = *slave;
268 memcpy(srec->slave.vd, slave->vd, slave->count * sizeof(*slave->vd));
269 srec->master = master_link;
270 srec->flags = flags;
271

--- 144 unchanged lines hidden (view full) ---

416 }
417 /* override some callbacks */
418 kctl->info = master_info;
419 kctl->get = master_get;
420 kctl->put = master_put;
421 kctl->private_free = master_free;
422
423 /* additional (constant) TLV read */
264 if (!srec)
265 return -ENOMEM;
266 srec->kctl = slave;
267 srec->slave = *slave;
268 memcpy(srec->slave.vd, slave->vd, slave->count * sizeof(*slave->vd));
269 srec->master = master_link;
270 srec->flags = flags;
271

--- 144 unchanged lines hidden (view full) ---

416 }
417 /* override some callbacks */
418 kctl->info = master_info;
419 kctl->get = master_get;
420 kctl->put = master_put;
421 kctl->private_free = master_free;
422
423 /* additional (constant) TLV read */
424 if (tlv) {
425 unsigned int type = tlv[SNDRV_CTL_TLVO_TYPE];
426 if (type == SNDRV_CTL_TLVT_DB_SCALE ||
427 type == SNDRV_CTL_TLVT_DB_MINMAX ||
428 type == SNDRV_CTL_TLVT_DB_MINMAX_MUTE) {
429 kctl->vd[0].access |= SNDRV_CTL_ELEM_ACCESS_TLV_READ;
430 memcpy(master->tlv, tlv, sizeof(master->tlv));
431 kctl->tlv.p = master->tlv;
432 }
424 if (tlv &&
425 (tlv[0] == SNDRV_CTL_TLVT_DB_SCALE ||
426 tlv[0] == SNDRV_CTL_TLVT_DB_MINMAX ||
427 tlv[0] == SNDRV_CTL_TLVT_DB_MINMAX_MUTE)) {
428 kctl->vd[0].access |= SNDRV_CTL_ELEM_ACCESS_TLV_READ;
429 memcpy(master->tlv, tlv, sizeof(master->tlv));
430 kctl->tlv.p = master->tlv;
433 }
434
435 return kctl;
436}
437EXPORT_SYMBOL(snd_ctl_make_virtual_master);
438
439/**
440 * snd_ctl_add_vmaster_hook - Add a hook to a vmaster control

--- 84 unchanged lines hidden ---
431 }
432
433 return kctl;
434}
435EXPORT_SYMBOL(snd_ctl_make_virtual_master);
436
437/**
438 * snd_ctl_add_vmaster_hook - Add a hook to a vmaster control

--- 84 unchanged lines hidden ---