summaryrefslogtreecommitdiffstats
path: root/sound/core
diff options
context:
space:
mode:
authorTakashi Iwai <tiwai@suse.de>2011-03-16 17:38:41 +0100
committerTakashi Iwai <tiwai@suse.de>2011-03-16 17:38:41 +0100
commit27b92d4ff2be2359a21ff4acde5b63563ff720e2 (patch)
tree49691b22fe1318aa68d5ebdff74795f004f0cf8f /sound/core
parent5de0ee574be8f6922a6c33f2fbc7e9b130a2f626 (diff)
parente58a8947b0264ec1f43ce5deef563b72acf1284f (diff)
downloadop-kernel-dev-27b92d4ff2be2359a21ff4acde5b63563ff720e2.zip
op-kernel-dev-27b92d4ff2be2359a21ff4acde5b63563ff720e2.tar.gz
Merge branch 'topic/asoc' into for-linus
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 9ce00ed..db51e4e 100644
--- a/sound/core/control.c
+++ b/sound/core/control.c
@@ -466,6 +466,52 @@ error:
}
/**
+ * snd_ctl_activate_id - activate/inactivate the control of the given id
+ * @card: the card instance
+ * @id: the control id to activate/inactivate
+ * @active: non-zero to activate
+ *
+ * Finds the control instance with the given id, and activate or
+ * inactivate the control together with notification, if changed.
+ *
+ * Returns 0 if unchanged, 1 if changed, or a negative error code on failure.
+ */
+int snd_ctl_activate_id(struct snd_card *card, struct snd_ctl_elem_id *id,
+ int active)
+{
+ struct snd_kcontrol *kctl;
+ struct snd_kcontrol_volatile *vd;
+ unsigned int index_offset;
+ int ret;
+
+ down_write(&card->controls_rwsem);
+ kctl = snd_ctl_find_id(card, id);
+ if (kctl == NULL) {
+ ret = -ENOENT;
+ goto unlock;
+ }
+ index_offset = snd_ctl_get_ioff(kctl, &kctl->id);
+ vd = &kctl->vd[index_offset];
+ ret = 0;
+ if (active) {
+ if (!(vd->access & SNDRV_CTL_ELEM_ACCESS_INACTIVE))
+ goto unlock;
+ vd->access &= ~SNDRV_CTL_ELEM_ACCESS_INACTIVE;
+ } else {
+ if (vd->access & SNDRV_CTL_ELEM_ACCESS_INACTIVE)
+ goto unlock;
+ vd->access |= SNDRV_CTL_ELEM_ACCESS_INACTIVE;
+ }
+ ret = 1;
+ unlock:
+ up_write(&card->controls_rwsem);
+ if (ret > 0)
+ snd_ctl_notify(card, SNDRV_CTL_EVENT_MASK_INFO, id);
+ return ret;
+}
+EXPORT_SYMBOL_GPL(snd_ctl_activate_id);
+
+/**
* snd_ctl_rename_id - replace the id of a control on the card
* @card: the card instance
* @src_id: the old id
OpenPOWER on IntegriCloud