asoc: codecs: spdif: Add support for setting bias level
Manoj Gangwal [Mon, 30 Apr 2012 15:47:24 +0000 (20:47 +0530)]
Allow setting bias level to turn off clock extern1 on KAI when
codec is idle. Added a dummy widgets to make the target_bias_level
to BIAS_OFF as per required by the new ALSA kernel.

Bug 964287

Change-Id: I628744040866a9879eedc41ed4ee25af38ed86fb
Signed-off-by: Manoj Gangwal <mgangwal@nvidia.com>
Reviewed-on: http://git-master/r/99667
Reviewed-by: Automatic_Commit_Validation_User
Tested-by: Hunk Lin <hulin@nvidia.com>
Reviewed-by: Scott Peterson <speterson@nvidia.com>

sound/soc/codecs/spdif_transciever.c

index 7c1bf5c..16ea0ed 100644 (file)
@@ -8,12 +8,15 @@
  * Author:      Steve Chen,  <schen@mvista.com>
  * Copyright:   (C) 2009 MontaVista Software, Inc., <source@mvista.com>
  * Copyright:   (C) 2009  Texas Instruments, India
+ * Copyright:   (C) 2009-2012, NVIDIA Corporation.
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License version 2 as
  * published by the Free Software Foundation.
  */
 
+
+#include <asm/mach-types.h>
 #include <linux/module.h>
 #include <linux/moduleparam.h>
 #include <linux/slab.h>
 #define STUB_RATES     SNDRV_PCM_RATE_8000_96000
 #define STUB_FORMATS   SNDRV_PCM_FMTBIT_S16_LE
 
-
 static struct snd_soc_codec_driver soc_codec_spdif_dit;
 
+static int spdif_probe(struct snd_soc_codec *codec) {
+       codec->dapm.idle_bias_off = 1;
+       return 0;
+}
+
+static const struct snd_soc_dapm_widget spdif_dapm_widgets[] = {
+       SND_SOC_DAPM_VMID("spdif dummy Vmid"),
+};
+
+static int spdif_write(struct snd_soc_codec * codec, unsigned int reg,
+                                                       unsigned int val){
+       return 0;
+}
+
+static int spdif_read(struct snd_soc_codec * codec, unsigned int reg){
+       return 0;
+}
+
+static struct snd_soc_codec_driver soc_codec_spdif_dit1 = {
+       .probe = spdif_probe,
+       .dapm_widgets = spdif_dapm_widgets,
+       .num_dapm_widgets = ARRAY_SIZE(spdif_dapm_widgets),
+       .read = spdif_read,
+       .write = spdif_write,
+};
+
 static struct snd_soc_dai_driver dit_stub_dai = {
        .name           = "dit-hifi",
        .playback       = {
@@ -49,8 +77,12 @@ static struct snd_soc_dai_driver dit_stub_dai = {
 
 static int spdif_dit_probe(struct platform_device *pdev)
 {
-       return snd_soc_register_codec(&pdev->dev, &soc_codec_spdif_dit,
-                       &dit_stub_dai, 1);
+       if(machine_is_kai())
+               return snd_soc_register_codec(&pdev->dev,
+                       &soc_codec_spdif_dit1, &dit_stub_dai, 1);
+       else
+               return snd_soc_register_codec(&pdev->dev,
+                        &soc_codec_spdif_dit, &dit_stub_dai, 1);
 }
 
 static int spdif_dit_remove(struct platform_device *pdev)