aboutsummaryrefslogtreecommitdiffstats
path: root/sound/soc/samsung/jive_wm8750.c
diff options
context:
space:
mode:
authorGlenn Elliott <gelliott@cs.unc.edu>2012-03-04 19:47:13 -0500
committerGlenn Elliott <gelliott@cs.unc.edu>2012-03-04 19:47:13 -0500
commitc71c03bda1e86c9d5198c5d83f712e695c4f2a1e (patch)
treeecb166cb3e2b7e2adb3b5e292245fefd23381ac8 /sound/soc/samsung/jive_wm8750.c
parentea53c912f8a86a8567697115b6a0d8152beee5c8 (diff)
parent6a00f206debf8a5c8899055726ad127dbeeed098 (diff)
Merge branch 'mpi-master' into wip-k-fmlpwip-k-fmlp
Conflicts: litmus/sched_cedf.c
Diffstat (limited to 'sound/soc/samsung/jive_wm8750.c')
-rw-r--r--sound/soc/samsung/jive_wm8750.c180
1 files changed, 180 insertions, 0 deletions
diff --git a/sound/soc/samsung/jive_wm8750.c b/sound/soc/samsung/jive_wm8750.c
new file mode 100644
index 000000000000..3b53ad54bc33
--- /dev/null
+++ b/sound/soc/samsung/jive_wm8750.c
@@ -0,0 +1,180 @@
1/* sound/soc/samsung/jive_wm8750.c
2 *
3 * Copyright 2007,2008 Simtec Electronics
4 *
5 * Based on sound/soc/pxa/spitz.c
6 * Copyright 2005 Wolfson Microelectronics PLC.
7 * Copyright 2005 Openedhand Ltd.
8 *
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.
12*/
13
14#include <sound/soc.h>
15
16#include <asm/mach-types.h>
17
18#include "s3c2412-i2s.h"
19#include "../codecs/wm8750.h"
20
21static 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" },
28};
29
30static 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),
34};
35
36static int jive_hw_params(struct snd_pcm_substream *substream,
37 struct snd_pcm_hw_params *params)
38{
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;
43 unsigned int clk = 0;
44 int ret = 0;
45
46 switch (params_rate(params)) {
47 case 8000:
48 case 16000:
49 case 48000:
50 case 96000:
51 clk = 12288000;
52 break;
53 case 11025:
54 case 22050:
55 case 44100:
56 clk = 11289600;
57 break;
58 }
59
60 s3c_i2sv2_iis_calc_rate(&div, NULL, params_rate(params),
61 s3c_i2sv2_get_clock(cpu_dai));
62
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);
67 if (ret < 0)
68 return ret;
69
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);
74 if (ret < 0)
75 return ret;
76
77 /* set the codec system clock for DAC and ADC */
78 ret = snd_soc_dai_set_sysclk(codec_dai, WM8750_SYSCLK, clk,
79 SND_SOC_CLOCK_IN);
80 if (ret < 0)
81 return ret;
82
83 ret = snd_soc_dai_set_clkdiv(cpu_dai, S3C2412_DIV_RCLK, div.fs_div);
84 if (ret < 0)
85 return ret;
86
87 ret = snd_soc_dai_set_clkdiv(cpu_dai, S3C2412_DIV_PRESCALER,
88 div.clk_div - 1);
89 if (ret < 0)
90 return ret;
91
92 return 0;
93}
94
95static struct snd_soc_ops jive_ops = {
96 .hw_params = jive_hw_params,
97};
98
99static int jive_wm8750_init(struct snd_soc_pcm_runtime *rtd)
100{
101 struct snd_soc_codec *codec = rtd->codec;
102 struct snd_soc_dapm_context *dapm = &codec->dapm;
103 int err;
104
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");
112
113 /* Add jive specific widgets */
114 err = snd_soc_dapm_new_controls(dapm, wm8750_dapm_widgets,
115 ARRAY_SIZE(wm8750_dapm_widgets));
116 if (err) {
117 printk(KERN_ERR "%s: failed to add widgets (%d)\n",
118 __func__, err);
119 return err;
120 }
121
122 snd_soc_dapm_add_routes(dapm, audio_map, ARRAY_SIZE(audio_map));
123 snd_soc_dapm_sync(dapm);
124
125 return 0;
126}
127
128static struct snd_soc_dai_link jive_dai = {
129 .name = "wm8750",
130 .stream_name = "WM8750",
131 .cpu_dai_name = "s3c2412-i2s",
132 .codec_dai_name = "wm8750-hifi",
133 .platform_name = "samsung-audio",
134 .codec_name = "wm8750-codec.0-0x1a",
135 .init = jive_wm8750_init,
136 .ops = &jive_ops,
137};
138
139/* jive audio machine driver */
140static struct snd_soc_card snd_soc_machine_jive = {
141 .name = "Jive",
142 .dai_link = &jive_dai,
143 .num_links = 1,
144};
145
146static struct platform_device *jive_snd_device;
147
148static int __init jive_init(void)
149{
150 int ret;
151
152 if (!machine_is_jive())
153 return 0;
154
155 printk("JIVE WM8750 Audio support\n");
156
157 jive_snd_device = platform_device_alloc("soc-audio", -1);
158 if (!jive_snd_device)
159 return -ENOMEM;
160
161 platform_set_drvdata(jive_snd_device, &snd_soc_machine_jive);
162 ret = platform_device_add(jive_snd_device);
163
164 if (ret)
165 platform_device_put(jive_snd_device);
166
167 return ret;
168}
169
170static void __exit jive_exit(void)
171{
172 platform_device_unregister(jive_snd_device);
173}
174
175module_init(jive_init);
176module_exit(jive_exit);
177
178MODULE_AUTHOR("Ben Dooks <ben@simtec.co.uk>");
179MODULE_DESCRIPTION("ALSA SoC Jive Audio support");
180MODULE_LICENSE("GPL");