From: lhh Date: Mon, 22 Nov 2010 12:04:06 +0000 (+0800) Subject: update rk29 alsa X-Git-Tag: firefly_0821_release~11016^2~11 X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=57a60e6afb1160e5279e269c1aaf3665af67a148;p=firefly-linux-kernel-4.4.55.git update rk29 alsa --- diff --git a/sound/soc/rk29/Kconfig b/sound/soc/rk29/Kconfig index 8fa4d2ee6ee9..e9f762f138a6 100755 --- a/sound/soc/rk29/Kconfig +++ b/sound/soc/rk29/Kconfig @@ -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 diff --git a/sound/soc/rk29/Makefile b/sound/soc/rk29/Makefile index 762ffab5a877..3e00a89cdbb6 100755 --- a/sound/soc/rk29/Makefile +++ b/sound/soc/rk29/Makefile @@ -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 diff --git a/sound/soc/rk29/rk29_i2s.c b/sound/soc/rk29/rk29_i2s.c index bef2a8b4fdd8..13c33c1d62e4 100755 --- a/sound/soc/rk29/rk29_i2s.c +++ b/sound/soc/rk29/rk29_i2s.c @@ -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"); diff --git a/sound/soc/rk29/rk29_i2s.h b/sound/soc/rk29/rk29_i2s.h index 310576f59913..794bac9d43d2 100755 --- a/sound/soc/rk29/rk29_i2s.h +++ b/sound/soc/rk29/rk29_i2s.h @@ -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 diff --git a/sound/soc/rk29/rk29_pcm.c b/sound/soc/rk29/rk29_pcm.c index d11be2cf844c..e0b0d3a3e1fa 100755 --- a/sound/soc/rk29/rk29_pcm.c +++ b/sound/soc/rk29/rk29_pcm.c @@ -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"); diff --git a/sound/soc/rk29/rk29_pcm.h b/sound/soc/rk29/rk29_pcm.h index 8c5932409e42..58710e1ca6a4 100755 --- a/sound/soc/rk29/rk29_pcm.h +++ b/sound/soc/rk29/rk29_pcm.h @@ -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 diff --git a/sound/soc/rk29/rk29_rk1000codec.c b/sound/soc/rk29/rk29_rk1000codec.c index 790732eb3d22..99676bce8c5f 100644 --- a/sound/soc/rk29/rk29_rk1000codec.c +++ b/sound/soc/rk29/rk29_rk1000codec.c @@ -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 index 000000000000..5a45f5cd899f --- /dev/null +++ b/sound/soc/rk29/rk29_wm8900.c @@ -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 +#include +#include +#include +#include +#include +#include +#include +#include +#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"); diff --git a/sound/soc/rk29/rk29_wm8988.c b/sound/soc/rk29/rk29_wm8988.c index 68c000cc23b7..29c4a709ab84 100755 --- a/sound/soc/rk29/rk29_wm8988.c +++ b/sound/soc/rk29/rk29_wm8988.c @@ -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");