MLK-10899: ASoC: si476x: add startup/shutdown to powerup/down FM
authorShengjiu Wang <shengjiu.wang@freescale.com>
Thu, 28 May 2015 06:57:33 +0000 (14:57 +0800)
committerNitin Garg <nitin.garg@nxp.com>
Mon, 19 Mar 2018 19:48:14 +0000 (14:48 -0500)
The hw parameter is set failed for si476x if si476x is not powerup,
the codec use the default value of this module. So add startup/shutdown
to powerup/powerdown FM, then we can set parameter successfully.

Signed-off-by: Shengjiu Wang <shengjiu.wang@freescale.com>
(cherry picked from commit 796665760605e020e6835f13db6ce49e0a0e03f5)

sound/soc/codecs/si476x.c

index 5344f4a..db5676a 100644 (file)
@@ -208,9 +208,28 @@ 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 = {
        .hw_params      = si476x_codec_hw_params,
        .set_fmt        = si476x_codec_set_dai_fmt,
+       .startup        = si476x_codec_startup,
+       .shutdown       = si476x_codec_shutdown,
 };
 
 static struct snd_soc_dai_driver si476x_dai = {