update rk29 alsa
authorlhh <lhh@rock-chips.com>
Mon, 22 Nov 2010 12:04:06 +0000 (20:04 +0800)
committerlhh <lhh@rock-chips.com>
Mon, 22 Nov 2010 12:04:06 +0000 (20:04 +0800)
sound/soc/rk29/Kconfig
sound/soc/rk29/Makefile
sound/soc/rk29/rk29_i2s.c
sound/soc/rk29/rk29_i2s.h
sound/soc/rk29/rk29_pcm.c
sound/soc/rk29/rk29_pcm.h
sound/soc/rk29/rk29_rk1000codec.c
sound/soc/rk29/rk29_wm8900.c [new file with mode: 0644]
sound/soc/rk29/rk29_wm8988.c

index 8fa4d2ee6ee9eb2435b8ffdcc50ff010d9fe7db6..e9f762f138a6432501e2d4bad9aa7ab187c5b74e 100755 (executable)
@@ -1,7 +1,6 @@
 config SND_RK29_SOC
        tristate "SoC Audio for the rockchip RK29 System-on-Chip"
        depends on ARCH_RK29 && SND_SOC
-        select SND_RK29_SOC_I2S
        help
          Say Y or M if you want to add support for codecs attached to
          the ROCKCHIP IIS interface. You will also need
@@ -12,30 +11,38 @@ config SND_RK29_SOC_I2S
 
 config SND_RK29_SOC_WM8988
        tristate "SoC I2S Audio support for rockchip - WM8988"
-       depends on SND_RK29_SOC 
+       depends on SND_RK29_SOC && I2C_RK29
        select SND_RK29_SOC_I2S
        select SND_SOC_WM8988
        help
          Say Y if you want to add support for SoC audio on rockchip
          with the WM8988.
 
+config SND_RK29_SOC_WM8900
+       tristate "SoC I2S Audio support for rockchip - WM8900"
+       depends on SND_RK29_SOC && I2C_RK29
+       select SND_RK29_SOC_I2S
+       select SND_SOC_WM8900
+       help
+         Say Y if you want to add support for SoC audio on rockchip
+         with the WM8900.
+
 config SND_RK29_SOC_RK1000
        tristate "SoC I2S Audio support for rockchip - RK1000"
-       depends on SND_RK29_SOC && RK1000_CONTROL
+       depends on SND_RK29_SOC && RK1000_CONTROL && I2C_RK29
        select SND_RK29_SOC_I2S
        select SND_SOC_RK1000
        help
          Say Y if you want to add support for SoC audio on rockchip
          with the RK1000.       
           
-if SND_RK29_SOC_WM8988 || SND_RK29_SOC_RK1000 || SND_RK29_SOC_WM8994
+if SND_RK29_SOC_WM8988 || SND_RK29_SOC_RK1000 || SND_RK29_SOC_WM8994 || SND_RK29_SOC_WM8900
 choice
   prompt "Set i2s type"
-
-       config SND_CODEC_SOC_MASTER
+       config SND_RK29_CODEC_SOC_MASTER
                tristate  "Codec run in Master"
 
-       config SND_CODEC_SOC_SLAVE
+       config SND_RK29_CODEC_SOC_SLAVE
                tristate  "Codec run in Slave"
 endchoice
 endif
index 762ffab5a8772e3c838201b2b4edd631d4d51b39..3e00a89cdbb63ba2c9e0f7f7f1d020de71ccc5d9 100755 (executable)
@@ -6,10 +6,12 @@ obj-$(CONFIG_SND_RK29_SOC) += snd-soc-rockchip.o
 obj-$(CONFIG_SND_RK29_SOC_I2S) += snd-soc-rockchip-i2s.o
 
 # ROCKCHIP Machine Support
+snd-soc-wm8900-objs := rk29_wm8900.o
 snd-soc-wm8988-objs := rk29_wm8988.o
 snd-soc-rk1000-objs := rk29_rk1000codec.o
 snd-soc-wm8994-objs := rk29_wm8994.o
 
 obj-$(CONFIG_SND_RK29_SOC_WM8994) += snd-soc-wm8994.o
 obj-$(CONFIG_SND_RK29_SOC_WM8988) += snd-soc-wm8988.o
+obj-$(CONFIG_SND_RK29_SOC_WM8900) += snd-soc-wm8900.o
 obj-$(CONFIG_SND_RK29_SOC_RK1000) += snd-soc-rk1000.o
index bef2a8b4fdd8ecb34b2453023aa8b19d93d4bdb4..13c33c1d62e465b784ee4c5c45ddc89832df9ee0 100755 (executable)
@@ -2,7 +2,6 @@
  * rk29_i2s.c  --  ALSA SoC ROCKCHIP IIS Audio Layer Platform driver
  *
  * Driver for rockchip iis audio
- *  Copyright (C) 2009 lhh
  *
  *
  *  This program is free software; you can redistribute  it and/or modify it
@@ -577,7 +576,7 @@ static void __exit rockchip_i2s_exit(void)
 module_exit(rockchip_i2s_exit);
 
 /* Module information */
-MODULE_AUTHOR("lhh lhh@rock-chips.com");
+MODULE_AUTHOR("rockchip");
 MODULE_DESCRIPTION("ROCKCHIP IIS ASoC Interface");
 MODULE_LICENSE("GPL");
 
index 310576f5991357b56deae2bee4b1a0842750f62e..794bac9d43d2d3af09d1230dc15a2a234783b357 100755 (executable)
@@ -2,7 +2,6 @@
  * rockchip-iis.h - ALSA IIS interface for the Rockchip rk28 SoC
  *
  * Driver for rockchip iis audio
- *  Copyright (C) 2009 lhh
  *
  * 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
index d11be2cf844c646a9d226ca0fb6c06d2eb14bf75..e0b0d3a3e1fa83154771f67d565bb83506f8c911 100755 (executable)
@@ -2,7 +2,6 @@
  * rk29_pcm.c  --  ALSA SoC ROCKCHIP PCM Audio Layer Platform driver
  *
  * Driver for rockchip pcm audio
- *  Copyright (C) 2009 lhh
  *
  *
  *  This program is free software; you can redistribute  it and/or modify it
@@ -676,7 +675,7 @@ static void __exit rockchip_soc_platform_exit(void)
 module_exit(rockchip_soc_platform_exit);
 
 /* Module information */
-MODULE_AUTHOR("lhh lhh@rock-chips.com");
+MODULE_AUTHOR("rockchip");
 MODULE_DESCRIPTION("ROCKCHIP PCM ASoC Interface");
 MODULE_LICENSE("GPL");
 
index 8c5932409e42d3b87b8296b56d8b9c073750bb64..58710e1ca6a442cd7d28eefe99c794a7474a5f82 100755 (executable)
@@ -2,7 +2,6 @@
  * rockchip-pcm.h - ALSA PCM interface for the Rockchip rk28 SoC
  *
  * Driver for rockchip iis audio
- *  Copyright (C) 2009 lhh
  *
  *
  * This program is free software; you can redistribute it and/or modify
index 790732eb3d22f1ffa9f99a4c674e2dd286faf4ec..99676bce8c5f4606662bcbb4cacde212562a32bb 100644 (file)
@@ -2,7 +2,6 @@
  * rk29_wm8988.c  --  SoC audio for rockchip
  *
  * Driver for rockchip wm8988 audio
- *  Copyright (C) 2009 lhh
  *
  *  This program is free software; you can redistribute  it and/or modify it
  *  under  the terms of  the GNU General  Public License as published by the
@@ -51,22 +50,22 @@ static int rk29_hw_params(struct snd_pcm_substream *substream,
     else
     {
            /* set codec DAI configuration */
-           #if defined (CONFIG_SND_ROCKCHIP_SOC_MASTER
+           #if defined (CONFIG_SND_CODEC_SOC_SLAVE
            ret = codec_dai->ops->set_fmt(codec_dai, SND_SOC_DAIFMT_I2S |
                SND_SOC_DAIFMT_NB_NF | SND_SOC_DAIFMT_CBS_CFS); 
            #endif      
-           #if defined (CONFIG_SND_ROCKCHIP_SOC_SLAVE
+           #if defined (CONFIG_SND_CODEC_SOC_MASTER
            ret = codec_dai->ops->set_fmt(codec_dai, SND_SOC_DAIFMT_I2S |
                SND_SOC_DAIFMT_NB_NF | SND_SOC_DAIFMT_CBM_CFM ); 
            #endif
            if (ret < 0)
                  return ret; 
            /* set cpu DAI configuration */
-           #if defined (CONFIG_SND_ROCKCHIP_SOC_MASTER
+           #if defined (CONFIG_SND_CODEC_SOC_SLAVE
            ret = cpu_dai->ops->set_fmt(cpu_dai, SND_SOC_DAIFMT_I2S |
                SND_SOC_DAIFMT_NB_NF | SND_SOC_DAIFMT_CBM_CFM);
            #endif      
-           #if defined (CONFIG_SND_ROCKCHIP_SOC_SLAVE
+           #if defined (CONFIG_SND_CODEC_SOC_MASTER
            ret = cpu_dai->ops->set_fmt(cpu_dai, SND_SOC_DAIFMT_I2S |
                SND_SOC_DAIFMT_NB_NF | SND_SOC_DAIFMT_CBS_CFS); 
            #endif              
@@ -181,6 +180,6 @@ static void __exit audio_card_exit(void)
 module_init(audio_card_init);
 module_exit(audio_card_exit);
 /* Module information */
-MODULE_AUTHOR("lhh lhh@rock-chips.com");
+MODULE_AUTHOR("rockchip");
 MODULE_DESCRIPTION("ROCKCHIP i2s ASoC Interface");
 MODULE_LICENSE("GPL");
diff --git a/sound/soc/rk29/rk29_wm8900.c b/sound/soc/rk29/rk29_wm8900.c
new file mode 100644 (file)
index 0000000..5a45f5c
--- /dev/null
@@ -0,0 +1,185 @@
+/*
+ * rk29_wm8900.c  --  SoC audio for rockchip
+ *
+ * Driver for rockchip wm8900 audio
+ *
+ *  This program is free software; you can redistribute  it and/or modify it
+ *  under  the terms of  the GNU General  Public License as published by the
+ *  Free Software Foundation;  either version 2 of the  License, or (at your
+ *  option) any later version.
+ *
+ *
+ */
+
+#include <linux/module.h>
+#include <linux/device.h>
+#include <sound/core.h>
+#include <sound/pcm.h>
+#include <sound/soc.h>
+#include <sound/soc-dapm.h>
+#include <asm/io.h>
+#include <mach/hardware.h>
+#include <mach/rk29_iomap.h>
+#include "../codecs/wm8900.h"
+#include "rk29_pcm.h"
+#include "rk29_i2s.h"
+
+#if 0
+#define        DBG(x...)       printk(KERN_INFO x)
+#else
+#define        DBG(x...)
+#endif
+
+static int rk29_hw_params(struct snd_pcm_substream *substream,
+       struct snd_pcm_hw_params *params)
+{
+    struct snd_soc_pcm_runtime *rtd = substream->private_data;
+       struct snd_soc_dai *codec_dai = rtd->dai->codec_dai;
+       struct snd_soc_dai *cpu_dai = rtd->dai->cpu_dai;
+       int ret;
+         
+    DBG("Enter::%s----%d\n",__FUNCTION__,__LINE__);    
+       /*by Vincent Hsiung for EQ Vol Change*/
+       #define HW_PARAMS_FLAG_EQVOL_ON 0x21
+       #define HW_PARAMS_FLAG_EQVOL_OFF 0x22
+    if ((params->flags == HW_PARAMS_FLAG_EQVOL_ON)||(params->flags == HW_PARAMS_FLAG_EQVOL_OFF))
+    {
+       ret = codec_dai->ops->hw_params(substream, params, codec_dai); //by Vincent
+       DBG("Enter::%s----%d\n",__FUNCTION__,__LINE__);
+    }
+    else
+    {
+           /* set codec DAI configuration */
+           #if defined (CONFIG_SND_CODEC_SOC_SLAVE) 
+           ret = codec_dai->ops->set_fmt(codec_dai, SND_SOC_DAIFMT_I2S |
+               SND_SOC_DAIFMT_NB_NF | SND_SOC_DAIFMT_CBS_CFS); 
+           #endif      
+           #if defined (CONFIG_SND_CODEC_SOC_MASTER) 
+           ret = codec_dai->ops->set_fmt(codec_dai, SND_SOC_DAIFMT_I2S |
+               SND_SOC_DAIFMT_NB_NF | SND_SOC_DAIFMT_CBM_CFM ); 
+           #endif
+           if (ret < 0)
+                 return ret; 
+           /* set cpu DAI configuration */
+           #if defined (CONFIG_SND_CODEC_SOC_SLAVE) 
+           ret = cpu_dai->ops->set_fmt(cpu_dai, SND_SOC_DAIFMT_I2S |
+               SND_SOC_DAIFMT_NB_NF | SND_SOC_DAIFMT_CBM_CFM);
+           #endif      
+           #if defined (CONFIG_SND_CODEC_SOC_MASTER) 
+           ret = cpu_dai->ops->set_fmt(cpu_dai, SND_SOC_DAIFMT_I2S |
+               SND_SOC_DAIFMT_NB_NF | SND_SOC_DAIFMT_CBS_CFS); 
+           #endif              
+           if (ret < 0)
+                 return ret;
+         }
+    
+         return 0;
+}
+
+static const struct snd_soc_dapm_widget wm8900_dapm_widgets[] = {
+       SND_SOC_DAPM_LINE("Audio Out", NULL),
+       SND_SOC_DAPM_LINE("Line in", NULL),
+       SND_SOC_DAPM_MIC("Micn", NULL),
+       SND_SOC_DAPM_MIC("Micp", NULL),
+};
+
+static const struct snd_soc_dapm_route audio_map[]= {
+       
+       {"Audio Out", NULL, "LOUT1"},
+       {"Audio Out", NULL, "ROUT1"},
+       {"Line in", NULL, "RINPUT1"},
+       {"Line in", NULL, "LINPUT1"},
+       {"Micn", NULL, "RINPUT2"},
+       {"Micp", NULL, "LINPUT2"},
+};
+
+/*
+ * Logic for a wm8900 as connected on a rockchip board.
+ */
+static int rk29_wm8900_init(struct snd_soc_codec *codec)
+{
+       struct snd_soc_dai *codec_dai = &codec->dai[0];
+       int ret;
+         
+    DBG("Enter::%s----%d\n",__FUNCTION__,__LINE__);
+    
+    ret = snd_soc_dai_set_sysclk(codec_dai, 0,
+               12000000, SND_SOC_CLOCK_IN);
+       if (ret < 0) {
+               printk(KERN_ERR "Failed to set WM8900 SYSCLK: %d\n", ret);
+               return ret;
+       }
+       
+    /* Add specific widgets */
+       snd_soc_dapm_new_controls(codec, wm8900_dapm_widgets,
+                                 ARRAY_SIZE(wm8900_dapm_widgets));
+       snd_soc_dapm_nc_pin(codec, "LOUT1");
+       snd_soc_dapm_nc_pin(codec, "ROUT1");
+       
+    /* Set up specific audio path audio_mapnects */
+    snd_soc_dapm_add_routes(codec, audio_map, ARRAY_SIZE(audio_map));
+       
+    snd_soc_dapm_sync(codec);
+    return 0;
+}
+
+static struct snd_soc_ops rk29_ops = {
+         .hw_params = rk29_hw_params,
+};
+
+static struct snd_soc_dai_link rk29_dai = {
+         .name = "WM8900",
+         .stream_name = "WM8900 PCM",
+         .cpu_dai = &rk29_i2s_dai,
+         .codec_dai = &wm8900_dai,
+         .init = rk29_wm8900_init,
+         .ops = &rk29_ops,
+};
+
+static struct snd_soc_card snd_soc_card_rk29 = {
+         .name = "RK29_WM8900",
+         .platform = &rk29_soc_platform,
+         .dai_link = &rk29_dai,
+         .num_links = 1,
+};
+
+
+static struct snd_soc_device rk29_snd_devdata = {
+         .card = &snd_soc_card_rk29,
+         .codec_dev = &soc_codec_dev_wm8900,
+};
+
+static struct platform_device *rk29_snd_device;
+
+static int __init audio_card_init(void)
+{
+       int ret =0;     
+    DBG("Enter::%s----%d\n",__FUNCTION__,__LINE__);
+       rk29_snd_device = platform_device_alloc("soc-audio", -1);
+       if (!rk29_snd_device) {
+                 DBG("platform device allocation failed\n");
+                 ret = -ENOMEM;
+                 return ret;
+       }
+       platform_set_drvdata(rk29_snd_device, &rk29_snd_devdata);
+       rk29_snd_devdata.dev = &rk29_snd_device->dev;
+       ret = platform_device_add(rk29_snd_device);
+       if (ret) {
+           DBG("platform device add failed\n");
+           platform_device_put(rk29_snd_device);
+       }
+       return ret;
+}
+
+static void __exit audio_card_exit(void)
+{
+       platform_device_unregister(rk29_snd_device);
+}
+
+module_init(audio_card_init);
+module_exit(audio_card_exit);
+/* Module information */
+MODULE_AUTHOR("rockchip");
+MODULE_DESCRIPTION("ROCKCHIP i2s ASoC Interface");
+MODULE_LICENSE("GPL");
index 68c000cc23b726bf6c8ec18eec83bc207c0b0e2c..29c4a709ab84a91cfdf7feab8c9b35d4443cb0f3 100755 (executable)
@@ -2,7 +2,6 @@
  * rk2818_wm8988.c  --  SoC audio for rockchip
  *
  * Driver for rockchip wm8988 audio
- *  Copyright (C) 2009 lhh
  *
  *  This program is free software; you can redistribute  it and/or modify it
  *  under  the terms of  the GNU General  Public License as published by the
@@ -51,22 +50,22 @@ static int rk2818_hw_params(struct snd_pcm_substream *substream,
     else
     {
            /* set codec DAI configuration */
-           #if defined (CONFIG_SND_ROCKCHIP_SOC_MASTER
+           #if defined (CONFIG_SND_CODEC_SOC_SLAVE
            ret = codec_dai->ops->set_fmt(codec_dai, SND_SOC_DAIFMT_I2S |
                SND_SOC_DAIFMT_NB_NF | SND_SOC_DAIFMT_CBS_CFS); 
            #endif      
-           #if defined (CONFIG_SND_ROCKCHIP_SOC_SLAVE
+           #if defined (CONFIG_SND_CODEC_SOC_MASTER
            ret = codec_dai->ops->set_fmt(codec_dai, SND_SOC_DAIFMT_I2S |
                SND_SOC_DAIFMT_NB_NF | SND_SOC_DAIFMT_CBM_CFM ); 
            #endif
            if (ret < 0)
                  return ret; 
            /* set cpu DAI configuration */
-           #if defined (CONFIG_SND_ROCKCHIP_SOC_MASTER
+           #if defined (CONFIG_SND_CODEC_SOC_SLAVE
            ret = cpu_dai->ops->set_fmt(cpu_dai, SND_SOC_DAIFMT_I2S |
                SND_SOC_DAIFMT_NB_NF | SND_SOC_DAIFMT_CBM_CFM);
            #endif      
-           #if defined (CONFIG_SND_ROCKCHIP_SOC_SLAVE
+           #if defined (CONFIG_SND_CODEC_SOC_MASTER
            ret = cpu_dai->ops->set_fmt(cpu_dai, SND_SOC_DAIFMT_I2S |
                SND_SOC_DAIFMT_NB_NF | SND_SOC_DAIFMT_CBS_CFS); 
            #endif              
@@ -180,6 +179,6 @@ static void __exit audio_card_exit(void)
 module_init(audio_card_init);
 module_exit(audio_card_exit);
 /* Module information */
-MODULE_AUTHOR("lhh lhh@rock-chips.com");
+MODULE_AUTHOR("rockchip");
 MODULE_DESCRIPTION("ROCKCHIP i2s ASoC Interface");
 MODULE_LICENSE("GPL");