Commit 68f831c2 authored by Lars-Peter Clausen's avatar Lars-Peter Clausen Committed by Mark Brown

ASoC: Add a set_bias_level() callback to the DAPM context struct

Currently the DAPM code directly looks at the CODEC driver struct to get a
handle to the set_bias_level() callback. This patch adds a new set_bias_level()
callback to the DAPM context struct. The DAPM code will use this new callback
instead of the CODEC callback. For CODECs the new callback is set up to call the
CODEC specific set_bias_level callback(). Not looking directly at the CODEC
driver struct will allow non CODEC DAPM contexts to implement a set_bias_level()
callback.

This is also similar to how the seq_notifier() and stream_event() callbacks are
currently handled.
Signed-off-by: default avatarLars-Peter Clausen <lars@metafoo.de>
Signed-off-by: default avatarMark Brown <broonie@linaro.org>
parent 647d62d9
...@@ -601,6 +601,8 @@ struct snd_soc_dapm_context { ...@@ -601,6 +601,8 @@ struct snd_soc_dapm_context {
struct list_head list; struct list_head list;
int (*stream_event)(struct snd_soc_dapm_context *dapm, int event); int (*stream_event)(struct snd_soc_dapm_context *dapm, int event);
int (*set_bias_level)(struct snd_soc_dapm_context *dapm,
enum snd_soc_bias_level level);
#ifdef CONFIG_DEBUG_FS #ifdef CONFIG_DEBUG_FS
struct dentry *debugfs_dapm; struct dentry *debugfs_dapm;
......
...@@ -4285,6 +4285,14 @@ static int snd_soc_codec_drv_read(struct snd_soc_component *component, ...@@ -4285,6 +4285,14 @@ static int snd_soc_codec_drv_read(struct snd_soc_component *component,
return 0; return 0;
} }
static int snd_soc_codec_set_bias_level(struct snd_soc_dapm_context *dapm,
enum snd_soc_bias_level level)
{
struct snd_soc_codec *codec = snd_soc_dapm_to_codec(dapm);
return codec->driver->set_bias_level(codec, level);
}
/** /**
* snd_soc_register_codec - Register a codec with the ASoC core * snd_soc_register_codec - Register a codec with the ASoC core
* *
...@@ -4322,6 +4330,8 @@ int snd_soc_register_codec(struct device *dev, ...@@ -4322,6 +4330,8 @@ int snd_soc_register_codec(struct device *dev,
codec->dapm.component = &codec->component; codec->dapm.component = &codec->component;
codec->dapm.seq_notifier = codec_drv->seq_notifier; codec->dapm.seq_notifier = codec_drv->seq_notifier;
codec->dapm.stream_event = codec_drv->stream_event; codec->dapm.stream_event = codec_drv->stream_event;
if (codec_drv->set_bias_level)
codec->dapm.set_bias_level = snd_soc_codec_set_bias_level;
codec->dev = dev; codec->dev = dev;
codec->driver = codec_drv; codec->driver = codec_drv;
codec->component.val_bytes = codec_drv->reg_word_size; codec->component.val_bytes = codec_drv->reg_word_size;
......
...@@ -427,15 +427,10 @@ static int snd_soc_dapm_set_bias_level(struct snd_soc_dapm_context *dapm, ...@@ -427,15 +427,10 @@ static int snd_soc_dapm_set_bias_level(struct snd_soc_dapm_context *dapm,
if (ret != 0) if (ret != 0)
goto out; goto out;
if (dapm->codec) { if (dapm->set_bias_level)
if (dapm->codec->driver->set_bias_level) ret = dapm->set_bias_level(dapm, level);
ret = dapm->codec->driver->set_bias_level(dapm->codec, else if (!card || dapm != &card->dapm)
level);
else
dapm->bias_level = level;
} else if (!card || dapm != &card->dapm) {
dapm->bias_level = level; dapm->bias_level = level;
}
if (ret != 0) if (ret != 0)
goto out; goto out;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment