[alsa-devel] [PATCH 3/4] ASoC: si476x: add startup/shutdown to powerup/down si476x

Zidan Wang zidan.wang at freescale.com
Fri Sep 18 11:19:34 CEST 2015


si476x should be powered up to read/write register, so powerup/down
si476x in startup/shutdown.

Signed-off-by: Zidan Wang <zidan.wang at freescale.com>
---
 sound/soc/codecs/si476x.c | 19 +++++++++++++++++++
 1 file changed, 19 insertions(+)

diff --git a/sound/soc/codecs/si476x.c b/sound/soc/codecs/si476x.c
index a8402d0..d61a79f 100644
--- a/sound/soc/codecs/si476x.c
+++ b/sound/soc/codecs/si476x.c
@@ -208,7 +208,26 @@ out:
 	return err;
 }
 
+static int si476x_codec_startup(struct snd_pcm_substream *substream,
+					struct snd_soc_dai *dai) {
+	struct si476x_core *core = i2c_mfd_cell_to_core(dai->dev);
+
+	if (!si476x_core_is_powered_up(core))
+		si476x_core_set_power_state(core, SI476X_POWER_UP_FULL);
+	return 0;
+}
+
+static void si476x_codec_shutdown(struct snd_pcm_substream *substream,
+					struct snd_soc_dai *dai) {
+	struct si476x_core *core = i2c_mfd_cell_to_core(dai->dev);
+
+	if (si476x_core_is_powered_up(core))
+		si476x_core_set_power_state(core, SI476X_POWER_DOWN);
+}
+
 static const struct snd_soc_dai_ops si476x_dai_ops = {
+	.startup        = si476x_codec_startup,
+	.shutdown       = si476x_codec_shutdown,
 	.hw_params	= si476x_codec_hw_params,
 	.set_fmt	= si476x_codec_set_dai_fmt,
 };
-- 
1.9.1



More information about the Alsa-devel mailing list