[alsa-devel] [RFC v2 2/3] ASoC: core: Helper function to request reversed widget power up
Peter Ujfalusi
peter.ujfalusi at nokia.com
Fri Dec 3 14:31:12 CET 2010
Helper function for drivers to request reversed power up sequence
on a given DAPM widget.
Signed-off-by: Peter Ujfalusi <peter.ujfalusi at nokia.com>
---
include/sound/soc-dapm.h | 2 ++
sound/soc/soc-dapm.c | 37 +++++++++++++++++++++++++++++++++++++
2 files changed, 39 insertions(+), 0 deletions(-)
diff --git a/include/sound/soc-dapm.h b/include/sound/soc-dapm.h
index e5a3c74..d5e11df 100644
--- a/include/sound/soc-dapm.h
+++ b/include/sound/soc-dapm.h
@@ -358,6 +358,8 @@ int snd_soc_dapm_force_enable_pin(struct snd_soc_dapm_context *dapm,
const char *pin);
int snd_soc_dapm_ignore_suspend(struct snd_soc_dapm_context *dapm,
const char *pin);
+int snd_soc_dapm_reverse_powerup_sequence(struct snd_soc_dapm_context *dapm,
+ const char *name);
/* dapm widget types */
enum snd_soc_dapm_type {
diff --git a/sound/soc/soc-dapm.c b/sound/soc/soc-dapm.c
index 7fae969..a3a3e94 100644
--- a/sound/soc/soc-dapm.c
+++ b/sound/soc/soc-dapm.c
@@ -119,6 +119,19 @@ static inline struct snd_soc_dapm_widget *dapm_cnew_widget(
return kmemdup(_widget, sizeof(*_widget), GFP_KERNEL);
}
+/* Find a widget by name */
+static inline struct snd_soc_dapm_widget *snd_soc_dapm_get_widget(
+ struct snd_soc_dapm_context *dapm, const char *name)
+{
+ struct snd_soc_dapm_widget *w;
+
+ list_for_each_entry(w, &dapm->widgets, list) {
+ if (!strcmp(w->name, name))
+ return w;
+ }
+ return NULL;
+}
+
/**
* snd_soc_dapm_set_bias_level - set the bias level for the system
* @card: audio device
@@ -2260,6 +2273,30 @@ int snd_soc_dapm_ignore_suspend(struct snd_soc_dapm_context *dapm,
EXPORT_SYMBOL_GPL(snd_soc_dapm_ignore_suspend);
/**
+ * snd_soc_dapm_reverse_powerup_sequence - reverse power up sequence on a widget
+ * @codec: audio codec
+ * @pin: Name of the DAPM widget
+ *
+ * Change the power up sequence on a given DAPM widget.
+ *
+ * Returns 0 on success, otherwise -EINVAL.
+ */
+int snd_soc_dapm_reverse_powerup_sequence(struct snd_soc_dapm_context *dapm,
+ const char *name)
+{
+ int ret = -EINVAL;
+ struct snd_soc_dapm_widget *widget;
+
+ widget = snd_soc_dapm_get_widget(dapm, name);
+ if (widget) {
+ widget->route_change_before_powerup = 1;
+ ret = 0;
+ }
+ return ret;
+}
+EXPORT_SYMBOL_GPL(snd_soc_dapm_reverse_powerup_sequence);
+
+/**
* snd_soc_dapm_free - free dapm resources
* @card: SoC device
*
--
1.7.3.2
More information about the Alsa-devel
mailing list