aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--include/sound/soc-dapm.h10
-rw-r--r--sound/soc/soc-dapm.c48
2 files changed, 58 insertions, 0 deletions
diff --git a/include/sound/soc-dapm.h b/include/sound/soc-dapm.h
index 67224db60348..c5c95e1da65b 100644
--- a/include/sound/soc-dapm.h
+++ b/include/sound/soc-dapm.h
@@ -206,6 +206,12 @@
206 .get = snd_soc_dapm_get_enum_double, \ 206 .get = snd_soc_dapm_get_enum_double, \
207 .put = snd_soc_dapm_put_enum_double, \ 207 .put = snd_soc_dapm_put_enum_double, \
208 .private_value = (unsigned long)&xenum } 208 .private_value = (unsigned long)&xenum }
209#define SOC_DAPM_ENUM_VIRT(xname, xenum) \
210{ .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, \
211 .info = snd_soc_info_enum_double, \
212 .get = snd_soc_dapm_get_enum_virt, \
213 .put = snd_soc_dapm_put_enum_virt, \
214 .private_value = (unsigned long)&xenum }
209#define SOC_DAPM_VALUE_ENUM(xname, xenum) \ 215#define SOC_DAPM_VALUE_ENUM(xname, xenum) \
210{ .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, \ 216{ .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, \
211 .info = snd_soc_info_enum_double, \ 217 .info = snd_soc_info_enum_double, \
@@ -260,6 +266,10 @@ int snd_soc_dapm_get_enum_double(struct snd_kcontrol *kcontrol,
260 struct snd_ctl_elem_value *ucontrol); 266 struct snd_ctl_elem_value *ucontrol);
261int snd_soc_dapm_put_enum_double(struct snd_kcontrol *kcontrol, 267int snd_soc_dapm_put_enum_double(struct snd_kcontrol *kcontrol,
262 struct snd_ctl_elem_value *ucontrol); 268 struct snd_ctl_elem_value *ucontrol);
269int snd_soc_dapm_get_enum_virt(struct snd_kcontrol *kcontrol,
270 struct snd_ctl_elem_value *ucontrol);
271int snd_soc_dapm_put_enum_virt(struct snd_kcontrol *kcontrol,
272 struct snd_ctl_elem_value *ucontrol);
263int snd_soc_dapm_get_value_enum_double(struct snd_kcontrol *kcontrol, 273int snd_soc_dapm_get_value_enum_double(struct snd_kcontrol *kcontrol,
264 struct snd_ctl_elem_value *ucontrol); 274 struct snd_ctl_elem_value *ucontrol);
265int snd_soc_dapm_put_value_enum_double(struct snd_kcontrol *kcontrol, 275int snd_soc_dapm_put_value_enum_double(struct snd_kcontrol *kcontrol,
diff --git a/sound/soc/soc-dapm.c b/sound/soc/soc-dapm.c
index 311467b95afb..d2af872e4771 100644
--- a/sound/soc/soc-dapm.c
+++ b/sound/soc/soc-dapm.c
@@ -1808,6 +1808,54 @@ out:
1808EXPORT_SYMBOL_GPL(snd_soc_dapm_put_enum_double); 1808EXPORT_SYMBOL_GPL(snd_soc_dapm_put_enum_double);
1809 1809
1810/** 1810/**
1811 * snd_soc_dapm_get_enum_virt - Get virtual DAPM mux
1812 * @kcontrol: mixer control
1813 * @ucontrol: control element information
1814 *
1815 * Returns 0 for success.
1816 */
1817int snd_soc_dapm_get_enum_virt(struct snd_kcontrol *kcontrol,
1818 struct snd_ctl_elem_value *ucontrol)
1819{
1820 struct snd_soc_dapm_widget *widget = snd_kcontrol_chip(kcontrol);
1821
1822 ucontrol->value.enumerated.item[0] = widget->value;
1823
1824 return 0;
1825}
1826EXPORT_SYMBOL_GPL(snd_soc_dapm_get_enum_virt);
1827
1828/**
1829 * snd_soc_dapm_put_enum_virt - Set virtual DAPM mux
1830 * @kcontrol: mixer control
1831 * @ucontrol: control element information
1832 *
1833 * Returns 0 for success.
1834 */
1835int snd_soc_dapm_put_enum_virt(struct snd_kcontrol *kcontrol,
1836 struct snd_ctl_elem_value *ucontrol)
1837{
1838 struct snd_soc_dapm_widget *widget = snd_kcontrol_chip(kcontrol);
1839 struct soc_enum *e =
1840 (struct soc_enum *)kcontrol->private_value;
1841 int change;
1842 int ret = 0;
1843
1844 if (ucontrol->value.enumerated.item[0] >= e->max)
1845 return -EINVAL;
1846
1847 mutex_lock(&widget->codec->mutex);
1848
1849 change = widget->value != ucontrol->value.enumerated.item[0];
1850 widget->value = ucontrol->value.enumerated.item[0];
1851 dapm_mux_update_power(widget, kcontrol, change, widget->value, e);
1852
1853 mutex_unlock(&widget->codec->mutex);
1854 return ret;
1855}
1856EXPORT_SYMBOL_GPL(snd_soc_dapm_put_enum_virt);
1857
1858/**
1811 * snd_soc_dapm_get_value_enum_double - dapm semi enumerated double mixer get 1859 * snd_soc_dapm_get_value_enum_double - dapm semi enumerated double mixer get
1812 * callback 1860 * callback
1813 * @kcontrol: mixer control 1861 * @kcontrol: mixer control