1 /* sound/soc/samsung/jive_wm8750.c
3 * Copyright 2007,2008 Simtec Electronics
5 * Based on sound/soc/pxa/spitz.c
6 * Copyright 2005 Wolfson Microelectronics PLC.
7 * Copyright 2005 Openedhand Ltd.
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License version 2 as
11 * published by the Free Software Foundation.
14 #include <sound/soc.h>
16 #include <asm/mach-types.h>
18 #include "s3c2412-i2s.h"
19 #include "../codecs/wm8750.h"
21 static const struct snd_soc_dapm_route audio_map[] = {
22 { "Headphone Jack", NULL, "LOUT1" },
23 { "Headphone Jack", NULL, "ROUT1" },
24 { "Internal Speaker", NULL, "LOUT2" },
25 { "Internal Speaker", NULL, "ROUT2" },
26 { "LINPUT1", NULL, "Line Input" },
27 { "RINPUT1", NULL, "Line Input" },
30 static const struct snd_soc_dapm_widget wm8750_dapm_widgets[] = {
31 SND_SOC_DAPM_HP("Headphone Jack", NULL),
32 SND_SOC_DAPM_SPK("Internal Speaker", NULL),
33 SND_SOC_DAPM_LINE("Line In", NULL),
36 static int jive_hw_params(struct snd_pcm_substream *substream,
37 struct snd_pcm_hw_params *params)
39 struct snd_soc_pcm_runtime *rtd = substream->private_data;
40 struct snd_soc_dai *codec_dai = rtd->codec_dai;
41 struct snd_soc_dai *cpu_dai = rtd->cpu_dai;
42 struct s3c_i2sv2_rate_calc div;
46 switch (params_rate(params)) {
60 s3c_i2sv2_iis_calc_rate(&div, NULL, params_rate(params),
61 s3c_i2sv2_get_clock(cpu_dai));
63 /* set codec DAI configuration */
64 ret = snd_soc_dai_set_fmt(codec_dai, SND_SOC_DAIFMT_I2S |
65 SND_SOC_DAIFMT_NB_NF |
66 SND_SOC_DAIFMT_CBS_CFS);
70 /* set cpu DAI configuration */
71 ret = snd_soc_dai_set_fmt(cpu_dai, SND_SOC_DAIFMT_I2S |
72 SND_SOC_DAIFMT_NB_NF |
73 SND_SOC_DAIFMT_CBS_CFS);
77 /* set the codec system clock for DAC and ADC */
78 ret = snd_soc_dai_set_sysclk(codec_dai, WM8750_SYSCLK, clk,
83 ret = snd_soc_dai_set_clkdiv(cpu_dai, S3C2412_DIV_RCLK, div.fs_div);
87 ret = snd_soc_dai_set_clkdiv(cpu_dai, S3C2412_DIV_PRESCALER,
95 static struct snd_soc_ops jive_ops = {
96 .hw_params = jive_hw_params,
99 static int jive_wm8750_init(struct snd_soc_pcm_runtime *rtd)
101 struct snd_soc_codec *codec = rtd->codec;
102 struct snd_soc_dapm_context *dapm = &codec->dapm;
105 /* These endpoints are not being used. */
106 snd_soc_dapm_nc_pin(dapm, "LINPUT2");
107 snd_soc_dapm_nc_pin(dapm, "RINPUT2");
108 snd_soc_dapm_nc_pin(dapm, "LINPUT3");
109 snd_soc_dapm_nc_pin(dapm, "RINPUT3");
110 snd_soc_dapm_nc_pin(dapm, "OUT3");
111 snd_soc_dapm_nc_pin(dapm, "MONO");
116 static struct snd_soc_dai_link jive_dai = {
118 .stream_name = "WM8750",
119 .cpu_dai_name = "s3c2412-i2s",
120 .codec_dai_name = "wm8750-hifi",
121 .platform_name = "samsung-audio",
122 .codec_name = "wm8750.0-001a",
123 .init = jive_wm8750_init,
127 /* jive audio machine driver */
128 static struct snd_soc_card snd_soc_machine_jive = {
130 .dai_link = &jive_dai,
133 .dapm_widgtets = wm8750_dapm_widgets,
134 .num_dapm_widgets = ARRAY_SIZE(wm8750_dapm_widgets),
135 .dapm_routes = audio_map,
136 .num_dapm_routes = ARRAY_SIZE(audio_map),
139 static struct platform_device *jive_snd_device;
141 static int __init jive_init(void)
145 if (!machine_is_jive())
148 printk("JIVE WM8750 Audio support\n");
150 jive_snd_device = platform_device_alloc("soc-audio", -1);
151 if (!jive_snd_device)
154 platform_set_drvdata(jive_snd_device, &snd_soc_machine_jive);
155 ret = platform_device_add(jive_snd_device);
158 platform_device_put(jive_snd_device);
163 static void __exit jive_exit(void)
165 platform_device_unregister(jive_snd_device);
168 module_init(jive_init);
169 module_exit(jive_exit);
171 MODULE_AUTHOR("Ben Dooks <ben@simtec.co.uk>");
172 MODULE_DESCRIPTION("ALSA SoC Jive Audio support");
173 MODULE_LICENSE("GPL");