aboutsummaryrefslogtreecommitdiffstats
path: root/sound/soc/soc-dapm.c
diff options
context:
space:
mode:
authorMark Brown <broonie@opensource.wolfsonmicro.com>2009-10-06 10:21:04 -0400
committerMark Brown <broonie@opensource.wolfsonmicro.com>2009-10-06 10:57:02 -0400
commitd2b247a8be57647d1745535acd58169fbcbe431a (patch)
treeca87ca863440ae512ffc7758c91441abe2d28ca6 /sound/soc/soc-dapm.c
parent3a65577d2199a7b33c85fd32838020c39da200f3 (diff)
ASoC: Add virtual enumeration support for DAPM muxes
Sometimes it is desirable to have a mux which does not reflect any direct register configuration but which will instead only have an effect implicitly (for example, as a result of changing which parts of the device are powered up). Provide a virtual mux for this purpose. Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
Diffstat (limited to 'sound/soc/soc-dapm.c')
-rw-r--r--sound/soc/soc-dapm.c48
1 files changed, 48 insertions, 0 deletions
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