aboutsummaryrefslogtreecommitdiffstats
path: root/sound/core
diff options
context:
space:
mode:
authorTakashi Iwai <tiwai@suse.de>2008-08-29 10:09:01 -0400
committerMark Brown <broonie@opensource.wolfsonmicro.com>2011-03-11 05:49:15 -0500
commit3cbdd7533148f00444013700af89548b8cf32646 (patch)
tree08778f54d3ab95cefafb696c5b655f8b99bd8dc8 /sound/core
parent80e1b84ffe1354f314fd85c939900b816f394e5a (diff)
ALSA: Add snd_ctl_activate_id()
Added a new API function snd_ctl_activate_id() for activate / inactivate the control element dynamically. Signed-off-by: Takashi Iwai <tiwai@suse.de> Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
Diffstat (limited to 'sound/core')
-rw-r--r--sound/core/control.c46
1 files changed, 46 insertions, 0 deletions
diff --git a/sound/core/control.c b/sound/core/control.c
index 9ce00ed20fb..db51e4e6498 100644
--- a/sound/core/control.c
+++ b/sound/core/control.c
@@ -466,6 +466,52 @@ error:
466} 466}
467 467
468/** 468/**
469 * snd_ctl_activate_id - activate/inactivate the control of the given id
470 * @card: the card instance
471 * @id: the control id to activate/inactivate
472 * @active: non-zero to activate
473 *
474 * Finds the control instance with the given id, and activate or
475 * inactivate the control together with notification, if changed.
476 *
477 * Returns 0 if unchanged, 1 if changed, or a negative error code on failure.
478 */
479int snd_ctl_activate_id(struct snd_card *card, struct snd_ctl_elem_id *id,
480 int active)
481{
482 struct snd_kcontrol *kctl;
483 struct snd_kcontrol_volatile *vd;
484 unsigned int index_offset;
485 int ret;
486
487 down_write(&card->controls_rwsem);
488 kctl = snd_ctl_find_id(card, id);
489 if (kctl == NULL) {
490 ret = -ENOENT;
491 goto unlock;
492 }
493 index_offset = snd_ctl_get_ioff(kctl, &kctl->id);
494 vd = &kctl->vd[index_offset];
495 ret = 0;
496 if (active) {
497 if (!(vd->access & SNDRV_CTL_ELEM_ACCESS_INACTIVE))
498 goto unlock;
499 vd->access &= ~SNDRV_CTL_ELEM_ACCESS_INACTIVE;
500 } else {
501 if (vd->access & SNDRV_CTL_ELEM_ACCESS_INACTIVE)
502 goto unlock;
503 vd->access |= SNDRV_CTL_ELEM_ACCESS_INACTIVE;
504 }
505 ret = 1;
506 unlock:
507 up_write(&card->controls_rwsem);
508 if (ret > 0)
509 snd_ctl_notify(card, SNDRV_CTL_EVENT_MASK_INFO, id);
510 return ret;
511}
512EXPORT_SYMBOL_GPL(snd_ctl_activate_id);
513
514/**
469 * snd_ctl_rename_id - replace the id of a control on the card 515 * snd_ctl_rename_id - replace the id of a control on the card
470 * @card: the card instance 516 * @card: the card instance
471 * @src_id: the old id 517 * @src_id: the old id