From: Ben Dooks <ben-alsa@fluff.org>
To: alsa-devel@alsa-project.org
Cc: Ben Dooks <benb@simtec.co.uk>, broonie@opensource.wolfsonmicro.com
Subject: [patch 8/9] SMDK6410: Add support for WM8731 on an add-on board
Date: Wed, 04 Mar 2009 00:49:33 +0000 [thread overview]
Message-ID: <20090304005139.317005352@fluff.org.uk> (raw)
In-Reply-To: 20090304004925.530566010@fluff.org.uk
[-- Attachment #1: audio/smdk6410-wm8713-bjd.patch --]
[-- Type: text/plain, Size: 7720 bytes --]
Add support for an WM8731 connected to an SMDK6410 instead
of the onboard codec.
Signed-off-by: Ben Dooks <benb@simtec.co.uk>
Index: linux.git/sound/soc/s3c24xx/Makefile
===================================================================
--- linux.git.orig/sound/soc/s3c24xx/Makefile 2009-03-04 00:44:31.000000000 +0000
+++ linux.git/sound/soc/s3c24xx/Makefile 2009-03-04 00:45:54.000000000 +0000
@@ -19,9 +19,11 @@ snd-soc-neo1973-wm8753-objs := neo1973_w
snd-soc-smdk2443-wm9710-objs := smdk2443_wm9710.o
snd-soc-ln2440sbc-alc650-objs := ln2440sbc_alc650.o
snd-soc-s3c24xx-uda134x-objs := s3c24xx_uda134x.o
+snd-soc-smdk6410-wm8731-objs := smdk6410-wm8731.o
obj-$(CONFIG_SND_S3C24XX_SOC_JIVE_WM8750) += snd-soc-jive-wm8750.o
obj-$(CONFIG_SND_S3C24XX_SOC_NEO1973_WM8753) += snd-soc-neo1973-wm8753.o
obj-$(CONFIG_SND_S3C24XX_SOC_SMDK2443_WM9710) += snd-soc-smdk2443-wm9710.o
obj-$(CONFIG_SND_S3C24XX_SOC_LN2440SBC_ALC650) += snd-soc-ln2440sbc-alc650.o
obj-$(CONFIG_SND_S3C24XX_SOC_S3C24XX_UDA134X) += snd-soc-s3c24xx-uda134x.o
+obj-$(CONFIG_SND_S3C64XX_SOC_SMDK6410_WM8731) += snd-soc-smdk6410-wm8731.o
Index: linux.git/sound/soc/s3c24xx/smdk6410-wm8731.c
===================================================================
--- /dev/null 1970-01-01 00:00:00.000000000 +0000
+++ linux.git/sound/soc/s3c24xx/smdk6410-wm8731.c 2009-03-04 00:45:04.000000000 +0000
@@ -0,0 +1,227 @@
+
+
+#include <linux/module.h>
+#include <linux/moduleparam.h>
+#include <linux/kernel.h>
+#include <linux/clk.h>
+#include <linux/timer.h>
+#include <linux/interrupt.h>
+#include <linux/platform_device.h>
+
+#include <sound/core.h>
+#include <sound/pcm.h>
+#include <sound/pcm_params.h>
+#include <sound/soc.h>
+#include <sound/soc-dapm.h>
+
+#include <asm/mach-types.h>
+
+#include "../codecs/wm8731.h"
+#include "s3c64xx-i2s.h"
+
+static struct platform_device *socdev;
+
+
+
+static void wm_shutdown(struct snd_pcm_substream *substream)
+{
+ printk(KERN_INFO "%s: substream %p\n", __func__, substream);
+}
+
+static int wm_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;
+ unsigned int fmt;
+ int ret;
+
+ printk(KERN_INFO "%s: (%p,%p)\n", __func__, substream, params);
+ printk(KERN_INFO "%s: dai: cpu %p, codec %p\n", __func__, cpu_dai, codec_dai);
+
+ //fmt = SND_SOC_DAIFMT_NB_NF | SND_SOC_DAIFMT_CBS_CFS;
+ fmt = SND_SOC_DAIFMT_NB_NF | SND_SOC_DAIFMT_CBM_CFM;
+ fmt |= SND_SOC_DAIFMT_I2S;
+
+ ret = snd_soc_dai_set_fmt(codec_dai, fmt);
+ if (ret < 0)
+ return ret;
+
+ /* set cpu DAI configuration */
+ ret = snd_soc_dai_set_fmt(cpu_dai, fmt);
+ if (ret < 0)
+ return ret;
+
+ if (fmt == (SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_NB_NF | SND_SOC_DAIFMT_CBM_CFM)) {
+ unsigned long iis_clkrate;
+
+ ret = snd_soc_dai_set_sysclk(cpu_dai, S3C64XX_CLKSRC_MUX, 0,
+ SND_SOC_CLOCK_OUT);
+ if (ret < 0) {
+ printk(KERN_ERR "%s: cpu set_sysclk err\n", __func__);
+ return ret;
+ }
+
+ /* set prescaler division for sample rate */
+ ret = snd_soc_dai_set_clkdiv(cpu_dai, S3C64XX_DIV_PRESCALER, 1);
+ if (ret < 0) {
+ printk(KERN_ERR "%s: codec clkdiv err\n", __func__);
+ return ret;
+ }
+
+ iis_clkrate = s3c64xx_i2s_get_clockrate(cpu_dai) / 2;
+ printk(KERN_INFO "%s: clockrate %ld\n", __func__, iis_clkrate);
+
+ iis_clkrate = 12000000; //tmphack//
+
+ /* set the codec system clock for DAC and ADC */
+ ret = snd_soc_dai_set_sysclk(codec_dai, WM8731_SYSCLK,
+ iis_clkrate,
+ SND_SOC_CLOCK_IN);
+ if (ret < 0) {
+ printk(KERN_ERR "%s: codec sysclk err\n", __func__);
+ return ret;
+ }
+
+ } else {
+ /* TODO */
+ BUG();
+ }
+
+ return 0;
+}
+
+static int wm_startup(struct snd_pcm_substream *substream)
+{
+ struct snd_soc_pcm_runtime *rtd = snd_pcm_substream_chip(substream);
+ struct snd_soc_dai *codec_dai = rtd->dai->codec_dai;
+ struct snd_soc_dai *cpu_dai = rtd->dai->cpu_dai;
+ int ret;
+
+ ret = snd_soc_dai_set_sysclk(cpu_dai, S3C64XX_CLKSRC_MUX, 0,
+ SND_SOC_CLOCK_OUT);
+ if (ret < 0) {
+ printk(KERN_ERR "%s: cpu set_sysclk err\n", __func__);
+ return ret;
+ }
+
+ ret = snd_soc_dai_set_clkdiv(cpu_dai, S3C64XX_DIV_PRESCALER, 1);
+ if (ret < 0) {
+ printk(KERN_ERR "%s: cpu set_clkdiv err\n", __func__);
+ return ret;
+ }
+
+ ret = snd_soc_dai_set_sysclk(codec_dai, WM8731_SYSCLK,
+ 12000000, SND_SOC_CLOCK_IN);
+ if (ret < 0) {
+ printk(KERN_ERR "%s: codec sysclk err\n", __func__);
+ return ret;
+ }
+
+ return 0;
+}
+
+static struct snd_soc_ops wm_ops = {
+ .startup = wm_startup,
+ .hw_params = wm_hw_params,
+ .shutdown = wm_shutdown,
+};
+
+static const struct snd_soc_dapm_widget widgets[] = {
+ SND_SOC_DAPM_LINE("Line Out", NULL),
+ SND_SOC_DAPM_HP("Headphone Jack", NULL),
+ SND_SOC_DAPM_INPUT("Line In"),
+};
+
+static const struct snd_soc_dapm_route intercon[] = {
+ /* headphone connected to LHPOUT1, RHPOUT1 */
+ {"Headphone Jack", NULL, "LHPOUT"},
+ {"Headphone Jack", NULL, "RHPOUT"},
+
+ {"Line Out", NULL, "LOUT" },
+ {"Line Out", NULL, "ROUT" },
+
+ {"LLINEIN", NULL, "Line In" },
+ {"RLINEIN", NULL, "Line In" },
+};
+
+static int wm_init(struct snd_soc_codec *codec)
+{
+ printk(KERN_DEBUG "%s: codec %p\n", __func__, codec);
+
+ snd_soc_dapm_new_controls(codec, widgets, ARRAY_SIZE(widgets));
+ snd_soc_dapm_add_routes(codec, intercon, ARRAY_SIZE(intercon));
+
+ snd_soc_dapm_sync(codec);
+
+ return 0;
+}
+
+#include "s3c24xx-pcm.h"
+
+static struct snd_soc_dai_link wm_dai_link = {
+ .name = "WM8731",
+ .stream_name = "WM8731",
+ .cpu_dai = &s3c64xx_i2s_dai,
+ .codec_dai = &wm8731_dai,
+ .init = wm_init,
+ .ops = &wm_ops,
+};
+
+static struct snd_soc_card wm_card = {
+ .name = "SMDK6410-WM8731",
+ .dai_link = &wm_dai_link,
+ .platform = &s3c24xx_soc_platform,
+ .num_links = 1,
+};
+
+struct wm8731_setup_data wm_setup = {
+ .i2c_bus = 0,
+ .i2c_address = 0x1a,
+};
+
+static struct snd_soc_device wm_snd_devdata = {
+ .card = &wm_card,
+ .codec_dev = &soc_codec_dev_wm8731,
+ .codec_data = &wm_setup,
+};
+
+static int __init smdk6410_wm8731_init(void)
+{
+ int ret;
+
+ printk(KERN_INFO "%s: welcome\n", __func__);
+
+ if (!machine_is_smdk6410()) {
+ printk(KERN_INFO "%s: for SMDK6410s\n", __func__);
+ return -ENOENT;
+ }
+
+ socdev = platform_device_alloc("soc-audio", 0);
+ if (!socdev) {
+ printk(KERN_ERR "%s: no device\n", __func__);
+ return -ENOMEM;
+ }
+
+ platform_set_drvdata(socdev, &wm_snd_devdata);
+
+ wm_snd_devdata.dev = &socdev->dev;
+
+ ret = platform_device_add(socdev);
+ if (ret) {
+ printk(KERN_ERR "%s: failed to add\n", __func__);
+ goto err_dev;
+ }
+
+ printk(KERN_INFO "%s: succesfull\n", __func__);
+ return 0;
+
+err_dev:
+ platform_device_put(socdev);
+ return ret;
+}
+
+module_init(smdk6410_wm8731_init);
+MODULE_AUTHOR("Ben Dooks <ben@simtec.co.uk>");
+MODULE_LICENSE("GPL");
Index: linux.git/sound/soc/s3c24xx/Kconfig
===================================================================
--- linux.git.orig/sound/soc/s3c24xx/Kconfig 2009-03-04 00:44:31.000000000 +0000
+++ linux.git/sound/soc/s3c24xx/Kconfig 2009-03-04 00:45:04.000000000 +0000
@@ -66,3 +66,11 @@ config SND_S3C24XX_SOC_S3C24XX_UDA134X
depends on SND_S3C24XX_SOC
select SND_S3C24XX_SOC_I2S
select SND_SOC_UDA134X
+
+config SND_S3C64XX_SOC_SMDK6410_WM8731
+ tristate "SoC I2S Audio support for WM8731 added to an SMDK6410"
+ depends on SND_S3C24XX_SOC
+ select SND_S3C64XX_SOC_I2S
+ select SND_SOC_WM8731
+ help
+ Support for an WM8731 add-on board on I2S channel 0 on an SMDK6410
--
Ben (ben@fluff.org, http://www.fluff.org/)
'a smiley only costs 4 bytes'
next prev parent reply other threads:[~2009-03-04 0:54 UTC|newest]
Thread overview: 24+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-03-04 0:49 [patch 0/9] S3C24XX/S3C64XX updates Ben Dooks
2009-03-04 0:49 ` [patch 1/9] S3C24XX: Move and update IIS headers Ben Dooks
2009-03-04 0:49 ` [patch 2/9] JIVE: Add ASoC audio support Ben Dooks
2009-03-04 14:57 ` Mark Brown
2009-03-04 0:49 ` [patch 3/9] S3C: Move <mach/audio.h> to <plat/audio.h> Ben Dooks
2009-03-04 0:49 ` [patch 4/9] S3C24XX ASoC: Fix copyright statements on Simtec files Ben Dooks
2009-03-04 19:20 ` Mark Brown
2009-03-04 0:49 ` [patch 5/9] S3C: Split s3c2412-i2s.c into core and SoC specific parts Ben Dooks
2009-03-04 19:52 ` Mark Brown
2009-03-04 0:49 ` [patch 6/9] S3C64XX: Add s3c64xx-i2s support Ben Dooks
2009-03-04 0:56 ` Ben Dooks
2009-03-04 19:56 ` Mark Brown
2009-03-04 0:49 ` [patch 7/9] ASoC: Ensure codec check hw_write error at probe Ben Dooks
2009-03-04 19:57 ` Mark Brown
2009-03-04 0:49 ` Ben Dooks [this message]
2009-03-04 20:06 ` [patch 8/9] SMDK6410: Add support for WM8731 on an add-on board Mark Brown
2009-03-04 0:49 ` [patch 9/9] AUDIO: Select DMA if I2S is configured Ben Dooks
2009-03-04 20:29 ` [patch 0/9] S3C24XX/S3C64XX updates Mark Brown
2009-03-05 7:23 ` Takashi Iwai
2009-03-05 10:31 ` Mark Brown
2009-03-05 10:36 ` Takashi Iwai
2009-03-05 11:03 ` Mark Brown
2009-03-11 10:39 ` Ben Dooks
2009-03-11 12:47 ` Mark Brown
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20090304005139.317005352@fluff.org.uk \
--to=ben-alsa@fluff.org \
--cc=alsa-devel@alsa-project.org \
--cc=benb@simtec.co.uk \
--cc=broonie@opensource.wolfsonmicro.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.