diff options
author | Liam Girdwood <lrg@ti.com> | 2011-07-24 15:59:42 -0400 |
---|---|---|
committer | Paolo Pisati <paolo.pisati@canonical.com> | 2012-08-17 04:18:24 -0400 |
commit | fcfaca1a5440c0520360e2c3230312e1d247efdb (patch) | |
tree | b830566aebc73d55ae517e2be793c46b3b75f76f | |
parent | dcde0098348d1ab3029bd1a3ad413d9e98313242 (diff) |
Subject: [PATCH 069/104] ASoC: dapm - allow custom widgets to update power events.
In preparation for ASoC DSP support.
Allow for the operation of custom mixer and mux DAPM widgets that can call
snd_soc_dapm_mixer_update_power() and snd_soc_dapm_mux_update_power() directly
after updating their status.
This adds two previously static calls to the public DAPM API.
Signed-off-by: Liam Girdwood <lrg@ti.com>
-rw-r--r-- | include/sound/soc-dapm.h | 12 | ||||
-rw-r--r-- | sound/soc/soc-dapm.c | 31 |
2 files changed, 32 insertions, 11 deletions
diff --git a/include/sound/soc-dapm.h b/include/sound/soc-dapm.h index 0f67cf6383d..22827a4897c 100644 --- a/include/sound/soc-dapm.h +++ b/include/sound/soc-dapm.h | |||
@@ -266,6 +266,12 @@ | |||
266 | .get = snd_soc_dapm_get_enum_virt, \ | 266 | .get = snd_soc_dapm_get_enum_virt, \ |
267 | .put = snd_soc_dapm_put_enum_virt, \ | 267 | .put = snd_soc_dapm_put_enum_virt, \ |
268 | .private_value = (unsigned long)&xenum } | 268 | .private_value = (unsigned long)&xenum } |
269 | #define SOC_DAPM_ENUM_EXT(xname, xenum, xget, xput) \ | ||
270 | { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, \ | ||
271 | .info = snd_soc_info_enum_double, \ | ||
272 | .get = xget, \ | ||
273 | .put = xput, \ | ||
274 | .private_value = (unsigned long)&xenum } | ||
269 | #define SOC_DAPM_VALUE_ENUM(xname, xenum) \ | 275 | #define SOC_DAPM_VALUE_ENUM(xname, xenum) \ |
270 | { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, \ | 276 | { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, \ |
271 | .info = snd_soc_info_enum_double, \ | 277 | .info = snd_soc_info_enum_double, \ |
@@ -356,6 +362,12 @@ int snd_soc_dapm_weak_routes(struct snd_soc_dapm_context *dapm, | |||
356 | int snd_soc_dapm_stream_event(struct snd_soc_pcm_runtime *rtd, | 362 | int snd_soc_dapm_stream_event(struct snd_soc_pcm_runtime *rtd, |
357 | const char *stream, int event); | 363 | const char *stream, int event); |
358 | void snd_soc_dapm_shutdown(struct snd_soc_card *card); | 364 | void snd_soc_dapm_shutdown(struct snd_soc_card *card); |
365 | /* external DAPM widget events */ | ||
366 | int snd_soc_dapm_mixer_update_power(struct snd_soc_dapm_widget *widget, | ||
367 | struct snd_kcontrol *kcontrol, int connect); | ||
368 | int snd_soc_dapm_mux_update_power(struct snd_soc_dapm_widget *widget, | ||
369 | struct snd_kcontrol *kcontrol, int change, | ||
370 | int mux, struct soc_enum *e); | ||
359 | 371 | ||
360 | /* dapm sys fs - used by the core */ | 372 | /* dapm sys fs - used by the core */ |
361 | int snd_soc_dapm_sys_add(struct device *dev); | 373 | int snd_soc_dapm_sys_add(struct device *dev); |
diff --git a/sound/soc/soc-dapm.c b/sound/soc/soc-dapm.c index 199afd92895..7c368ea40ac 100644 --- a/sound/soc/soc-dapm.c +++ b/sound/soc/soc-dapm.c | |||
@@ -50,6 +50,8 @@ | |||
50 | 50 | ||
51 | #define PATH_MAX_HOPS 16 | 51 | #define PATH_MAX_HOPS 16 |
52 | 52 | ||
53 | int soc_dsp_runtime_update(struct snd_soc_dapm_widget *); | ||
54 | |||
53 | /* dapm power sequences - make this per codec in the future */ | 55 | /* dapm power sequences - make this per codec in the future */ |
54 | static int dapm_up_seq[] = { | 56 | static int dapm_up_seq[] = { |
55 | [snd_soc_dapm_pre] = 0, | 57 | [snd_soc_dapm_pre] = 0, |
@@ -167,7 +169,7 @@ static void dapm_clear_paths(struct snd_soc_dapm_context *dapm) | |||
167 | struct snd_soc_dapm_widget *w; | 169 | struct snd_soc_dapm_widget *w; |
168 | struct list_head *l; | 170 | struct list_head *l; |
169 | 171 | ||
170 | list_for_each(l, &dapm->paths) { | 172 | list_for_each(l, &dapm->card->paths) { |
171 | p = list_entry(l, struct snd_soc_dapm_path, list); | 173 | p = list_entry(l, struct snd_soc_dapm_path, list); |
172 | p->length = 0; | 174 | p->length = 0; |
173 | } | 175 | } |
@@ -1807,7 +1809,7 @@ static inline void dapm_debugfs_cleanup(struct snd_soc_dapm_context *dapm) | |||
1807 | #endif | 1809 | #endif |
1808 | 1810 | ||
1809 | /* test and update the power status of a mux widget */ | 1811 | /* test and update the power status of a mux widget */ |
1810 | static int dapm_mux_update_power(struct snd_soc_dapm_widget *widget, | 1812 | int snd_soc_dapm_mux_update_power(struct snd_soc_dapm_widget *widget, |
1811 | struct snd_kcontrol *kcontrol, int change, | 1813 | struct snd_kcontrol *kcontrol, int change, |
1812 | int mux, struct soc_enum *e) | 1814 | int mux, struct soc_enum *e) |
1813 | { | 1815 | { |
@@ -1824,6 +1826,7 @@ static int dapm_mux_update_power(struct snd_soc_dapm_widget *widget, | |||
1824 | 1826 | ||
1825 | /* find dapm widget path assoc with kcontrol */ | 1827 | /* find dapm widget path assoc with kcontrol */ |
1826 | list_for_each_entry(path, &widget->dapm->card->paths, list) { | 1828 | list_for_each_entry(path, &widget->dapm->card->paths, list) { |
1829 | |||
1827 | if (path->kcontrol != kcontrol) | 1830 | if (path->kcontrol != kcontrol) |
1828 | continue; | 1831 | continue; |
1829 | 1832 | ||
@@ -1838,15 +1841,18 @@ static int dapm_mux_update_power(struct snd_soc_dapm_widget *widget, | |||
1838 | path->connect = 0; /* old connection must be powered down */ | 1841 | path->connect = 0; /* old connection must be powered down */ |
1839 | } | 1842 | } |
1840 | 1843 | ||
1841 | if (found) | 1844 | if (found) { |
1842 | dapm_power_widgets(widget->dapm, SND_SOC_DAPM_STREAM_NOP); | 1845 | dapm_power_widgets(widget->dapm, SND_SOC_DAPM_STREAM_NOP); |
1846 | soc_dsp_runtime_update(widget); | ||
1847 | } | ||
1843 | 1848 | ||
1844 | return 0; | 1849 | return 0; |
1845 | } | 1850 | } |
1851 | EXPORT_SYMBOL_GPL(snd_soc_dapm_mux_update_power); | ||
1846 | 1852 | ||
1847 | /* test and update the power status of a mixer or switch widget */ | 1853 | /* test and update the power status of a mixer or switch widget */ |
1848 | static int dapm_mixer_update_power(struct snd_soc_dapm_widget *widget, | 1854 | int snd_soc_dapm_mixer_update_power(struct snd_soc_dapm_widget *widget, |
1849 | struct snd_kcontrol *kcontrol, int connect) | 1855 | struct snd_kcontrol *kcontrol, int connect) |
1850 | { | 1856 | { |
1851 | struct snd_soc_dapm_path *path; | 1857 | struct snd_soc_dapm_path *path; |
1852 | int found = 0; | 1858 | int found = 0; |
@@ -1867,11 +1873,14 @@ static int dapm_mixer_update_power(struct snd_soc_dapm_widget *widget, | |||
1867 | break; | 1873 | break; |
1868 | } | 1874 | } |
1869 | 1875 | ||
1870 | if (found) | 1876 | if (found) { |
1871 | dapm_power_widgets(widget->dapm, SND_SOC_DAPM_STREAM_NOP); | 1877 | dapm_power_widgets(widget->dapm, SND_SOC_DAPM_STREAM_NOP); |
1878 | soc_dsp_runtime_update(widget); | ||
1879 | } | ||
1872 | 1880 | ||
1873 | return 0; | 1881 | return 0; |
1874 | } | 1882 | } |
1883 | EXPORT_SYMBOL_GPL(snd_soc_dapm_mixer_update_power); | ||
1875 | 1884 | ||
1876 | /* show dapm widget status in sys fs */ | 1885 | /* show dapm widget status in sys fs */ |
1877 | static ssize_t dapm_widget_show(struct device *dev, | 1886 | static ssize_t dapm_widget_show(struct device *dev, |
@@ -2469,7 +2478,7 @@ int snd_soc_dapm_put_volsw(struct snd_kcontrol *kcontrol, | |||
2469 | update.val = val; | 2478 | update.val = val; |
2470 | widget->dapm->update = &update; | 2479 | widget->dapm->update = &update; |
2471 | 2480 | ||
2472 | dapm_mixer_update_power(widget, kcontrol, connect); | 2481 | snd_soc_dapm_mixer_update_power(widget, kcontrol, connect); |
2473 | 2482 | ||
2474 | widget->dapm->update = NULL; | 2483 | widget->dapm->update = NULL; |
2475 | } | 2484 | } |
@@ -2560,7 +2569,7 @@ int snd_soc_dapm_put_enum_double(struct snd_kcontrol *kcontrol, | |||
2560 | update.val = val; | 2569 | update.val = val; |
2561 | widget->dapm->update = &update; | 2570 | widget->dapm->update = &update; |
2562 | 2571 | ||
2563 | dapm_mux_update_power(widget, kcontrol, change, mux, e); | 2572 | snd_soc_dapm_mux_update_power(widget, kcontrol, change, mux, e); |
2564 | 2573 | ||
2565 | widget->dapm->update = NULL; | 2574 | widget->dapm->update = NULL; |
2566 | } | 2575 | } |
@@ -2621,8 +2630,8 @@ int snd_soc_dapm_put_enum_virt(struct snd_kcontrol *kcontrol, | |||
2621 | 2630 | ||
2622 | widget->value = ucontrol->value.enumerated.item[0]; | 2631 | widget->value = ucontrol->value.enumerated.item[0]; |
2623 | 2632 | ||
2624 | dapm_mux_update_power(widget, kcontrol, change, | 2633 | snd_soc_dapm_mux_update_power(widget, kcontrol, change, |
2625 | widget->value, e); | 2634 | widget->value, e); |
2626 | } | 2635 | } |
2627 | } | 2636 | } |
2628 | 2637 | ||
@@ -2725,7 +2734,7 @@ int snd_soc_dapm_put_value_enum_double(struct snd_kcontrol *kcontrol, | |||
2725 | update.val = val; | 2734 | update.val = val; |
2726 | widget->dapm->update = &update; | 2735 | widget->dapm->update = &update; |
2727 | 2736 | ||
2728 | dapm_mux_update_power(widget, kcontrol, change, mux, e); | 2737 | snd_soc_dapm_mux_update_power(widget, kcontrol, change, mux, e); |
2729 | 2738 | ||
2730 | widget->dapm->update = NULL; | 2739 | widget->dapm->update = NULL; |
2731 | } | 2740 | } |