aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTakashi Iwai <tiwai@suse.de>2017-12-12 09:54:10 +0100
committerTakashi Iwai <tiwai@suse.de>2017-12-12 09:54:43 +0100
commita219de51e81d2d8ae4baa28d83b29647136065ce (patch)
tree2f345d97fab5b1ecbec783d33fdd4306bdac60dd
parent84359f87b89a63c1b8de67d38a4bd37f22cd4b1a (diff)
downloadhda-emu-a219de51e81d2d8ae4baa28d83b29647136065ce.tar.gz
Update vmaster stuff for 4.14/4.15
Added snd_ctl_apply_vmaster_slaves() Signed-off-by: Takashi Iwai <tiwai@suse.de>
-rw-r--r--include/sound/control.h5
-rw-r--r--snd-vmaster.c33
2 files changed, 38 insertions, 0 deletions
diff --git a/include/sound/control.h b/include/sound/control.h
index e3318b9..1fe1ee8 100644
--- a/include/sound/control.h
+++ b/include/sound/control.h
@@ -164,6 +164,11 @@ int snd_ctl_add_vmaster_hook(struct snd_kcontrol *kctl,
void *private_data);
void snd_ctl_sync_vmaster(struct snd_kcontrol *kctl, bool hook_only);
#define snd_ctl_sync_vmaster_hook(kctl) snd_ctl_sync_vmaster(kctl, true)
+int snd_ctl_apply_vmaster_slaves(struct snd_kcontrol *kctl,
+ int (*func)(struct snd_kcontrol *vslave,
+ struct snd_kcontrol *slave,
+ void *arg),
+ void *arg);
/*
* Helper functions for jack-detection controls
diff --git a/snd-vmaster.c b/snd-vmaster.c
index 842a97d..cfd08d2 100644
--- a/snd-vmaster.c
+++ b/snd-vmaster.c
@@ -484,3 +484,36 @@ void snd_ctl_sync_vmaster(struct snd_kcontrol *kcontrol, bool hook_only)
master->hook(master->hook_private_data, master->val);
}
EXPORT_SYMBOL_GPL(snd_ctl_sync_vmaster);
+
+/**
+ * snd_ctl_apply_vmaster_slaves - Apply function to each vmaster slave
+ * @kctl: vmaster kctl element
+ * @func: function to apply
+ * @arg: optional function argument
+ *
+ * Apply the function @func to each slave kctl of the given vmaster kctl.
+ * Returns 0 if successful, or a negative error code.
+ */
+int snd_ctl_apply_vmaster_slaves(struct snd_kcontrol *kctl,
+ int (*func)(struct snd_kcontrol *vslave,
+ struct snd_kcontrol *slave,
+ void *arg),
+ void *arg)
+{
+ struct link_master *master;
+ struct link_slave *slave;
+ int err;
+
+ master = snd_kcontrol_chip(kctl);
+ err = master_init(master);
+ if (err < 0)
+ return err;
+ list_for_each_entry(slave, &master->slaves, list) {
+ err = func(slave->kctl, &slave->slave, arg);
+ if (err < 0)
+ return err;
+ }
+
+ return 0;
+}
+EXPORT_SYMBOL_GPL(snd_ctl_apply_vmaster_slaves);