diff options
author | Takashi Iwai <tiwai@suse.de> | 2011-03-16 12:38:41 -0400 |
---|---|---|
committer | Takashi Iwai <tiwai@suse.de> | 2011-03-16 12:38:41 -0400 |
commit | 27b92d4ff2be2359a21ff4acde5b63563ff720e2 (patch) | |
tree | 49691b22fe1318aa68d5ebdff74795f004f0cf8f /sound/soc/ep93xx | |
parent | 5de0ee574be8f6922a6c33f2fbc7e9b130a2f626 (diff) | |
parent | e58a8947b0264ec1f43ce5deef563b72acf1284f (diff) |
Merge branch 'topic/asoc' into for-linus
Diffstat (limited to 'sound/soc/ep93xx')
-rw-r--r-- | sound/soc/ep93xx/Kconfig | 9 | ||||
-rw-r--r-- | sound/soc/ep93xx/Makefile | 2 | ||||
-rw-r--r-- | sound/soc/ep93xx/edb93xx.c | 142 | ||||
-rw-r--r-- | sound/soc/ep93xx/ep93xx-ac97.c | 1 | ||||
-rw-r--r-- | sound/soc/ep93xx/ep93xx-i2s.c | 31 | ||||
-rw-r--r-- | sound/soc/ep93xx/ep93xx-pcm.c | 4 |
6 files changed, 172 insertions, 17 deletions
diff --git a/sound/soc/ep93xx/Kconfig b/sound/soc/ep93xx/Kconfig index 57429041189c..91a28de94109 100644 --- a/sound/soc/ep93xx/Kconfig +++ b/sound/soc/ep93xx/Kconfig | |||
@@ -30,3 +30,12 @@ config SND_EP93XX_SOC_SIMONE | |||
30 | help | 30 | help |
31 | Say Y or M here if you want to add support for AC97 audio on the | 31 | Say Y or M here if you want to add support for AC97 audio on the |
32 | Simplemachines Sim.One board. | 32 | Simplemachines Sim.One board. |
33 | |||
34 | config SND_EP93XX_SOC_EDB93XX | ||
35 | tristate "SoC Audio support for Cirrus Logic EDB93xx boards" | ||
36 | depends on SND_EP93XX_SOC && (MACH_EDB9301 || MACH_EDB9302 || MACH_EDB9302A || MACH_EDB9307A || MACH_EDB9315A) | ||
37 | select SND_EP93XX_SOC_I2S | ||
38 | select SND_SOC_CS4271 | ||
39 | help | ||
40 | Say Y or M here if you want to add support for I2S audio on the | ||
41 | Cirrus Logic EDB93xx boards. | ||
diff --git a/sound/soc/ep93xx/Makefile b/sound/soc/ep93xx/Makefile index 8e7977fb6b7d..5514146cbdf0 100644 --- a/sound/soc/ep93xx/Makefile +++ b/sound/soc/ep93xx/Makefile | |||
@@ -10,6 +10,8 @@ obj-$(CONFIG_SND_EP93XX_SOC_AC97) += snd-soc-ep93xx-ac97.o | |||
10 | # EP93XX Machine Support | 10 | # EP93XX Machine Support |
11 | snd-soc-snappercl15-objs := snappercl15.o | 11 | snd-soc-snappercl15-objs := snappercl15.o |
12 | snd-soc-simone-objs := simone.o | 12 | snd-soc-simone-objs := simone.o |
13 | snd-soc-edb93xx-objs := edb93xx.o | ||
13 | 14 | ||
14 | obj-$(CONFIG_SND_EP93XX_SOC_SNAPPERCL15) += snd-soc-snappercl15.o | 15 | obj-$(CONFIG_SND_EP93XX_SOC_SNAPPERCL15) += snd-soc-snappercl15.o |
15 | obj-$(CONFIG_SND_EP93XX_SOC_SIMONE) += snd-soc-simone.o | 16 | obj-$(CONFIG_SND_EP93XX_SOC_SIMONE) += snd-soc-simone.o |
17 | obj-$(CONFIG_SND_EP93XX_SOC_EDB93XX) += snd-soc-edb93xx.o | ||
diff --git a/sound/soc/ep93xx/edb93xx.c b/sound/soc/ep93xx/edb93xx.c new file mode 100644 index 000000000000..d3aa15119d26 --- /dev/null +++ b/sound/soc/ep93xx/edb93xx.c | |||
@@ -0,0 +1,142 @@ | |||
1 | /* | ||
2 | * SoC audio for EDB93xx | ||
3 | * | ||
4 | * Copyright (c) 2010 Alexander Sverdlin <subaparts@yandex.ru> | ||
5 | * | ||
6 | * This program is free software; you can redistribute it and/or | ||
7 | * modify it under the terms of the GNU General Public License | ||
8 | * as published by the Free Software Foundation; either version 2 | ||
9 | * of the License, or (at your option) any later version. | ||
10 | * | ||
11 | * This program is distributed in the hope that it will be useful, | ||
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
14 | * GNU General Public License for more details. | ||
15 | * | ||
16 | * This driver support CS4271 codec being master or slave, working | ||
17 | * in control port mode, connected either via SPI or I2C. | ||
18 | * The data format accepted is I2S or left-justified. | ||
19 | * DAPM support not implemented. | ||
20 | */ | ||
21 | |||
22 | #include <linux/platform_device.h> | ||
23 | #include <linux/gpio.h> | ||
24 | #include <sound/core.h> | ||
25 | #include <sound/pcm.h> | ||
26 | #include <sound/soc.h> | ||
27 | #include <asm/mach-types.h> | ||
28 | #include <mach/hardware.h> | ||
29 | #include "ep93xx-pcm.h" | ||
30 | |||
31 | #define edb93xx_has_audio() (machine_is_edb9301() || \ | ||
32 | machine_is_edb9302() || \ | ||
33 | machine_is_edb9302a() || \ | ||
34 | machine_is_edb9307a() || \ | ||
35 | machine_is_edb9315a()) | ||
36 | |||
37 | static int edb93xx_hw_params(struct snd_pcm_substream *substream, | ||
38 | struct snd_pcm_hw_params *params) | ||
39 | { | ||
40 | struct snd_soc_pcm_runtime *rtd = substream->private_data; | ||
41 | struct snd_soc_dai *codec_dai = rtd->codec_dai; | ||
42 | struct snd_soc_dai *cpu_dai = rtd->cpu_dai; | ||
43 | int err; | ||
44 | unsigned int mclk_rate; | ||
45 | unsigned int rate = params_rate(params); | ||
46 | |||
47 | /* | ||
48 | * According to CS4271 datasheet we use MCLK/LRCK=256 for | ||
49 | * rates below 50kHz and 128 for higher sample rates | ||
50 | */ | ||
51 | if (rate < 50000) | ||
52 | mclk_rate = rate * 64 * 4; | ||
53 | else | ||
54 | mclk_rate = rate * 64 * 2; | ||
55 | |||
56 | err = snd_soc_dai_set_fmt(codec_dai, SND_SOC_DAIFMT_I2S | | ||
57 | SND_SOC_DAIFMT_NB_IF | | ||
58 | SND_SOC_DAIFMT_CBS_CFS); | ||
59 | if (err) | ||
60 | return err; | ||
61 | |||
62 | err = snd_soc_dai_set_fmt(cpu_dai, SND_SOC_DAIFMT_I2S | | ||
63 | SND_SOC_DAIFMT_NB_IF | | ||
64 | SND_SOC_DAIFMT_CBS_CFS); | ||
65 | if (err) | ||
66 | return err; | ||
67 | |||
68 | err = snd_soc_dai_set_sysclk(codec_dai, 0, mclk_rate, | ||
69 | SND_SOC_CLOCK_IN); | ||
70 | if (err) | ||
71 | return err; | ||
72 | |||
73 | return snd_soc_dai_set_sysclk(cpu_dai, 0, mclk_rate, | ||
74 | SND_SOC_CLOCK_OUT); | ||
75 | } | ||
76 | |||
77 | static struct snd_soc_ops edb93xx_ops = { | ||
78 | .hw_params = edb93xx_hw_params, | ||
79 | }; | ||
80 | |||
81 | static struct snd_soc_dai_link edb93xx_dai = { | ||
82 | .name = "CS4271", | ||
83 | .stream_name = "CS4271 HiFi", | ||
84 | .platform_name = "ep93xx-pcm-audio", | ||
85 | .cpu_dai_name = "ep93xx-i2s", | ||
86 | .codec_name = "spi0.0", | ||
87 | .codec_dai_name = "cs4271-hifi", | ||
88 | .ops = &edb93xx_ops, | ||
89 | }; | ||
90 | |||
91 | static struct snd_soc_card snd_soc_edb93xx = { | ||
92 | .name = "EDB93XX", | ||
93 | .dai_link = &edb93xx_dai, | ||
94 | .num_links = 1, | ||
95 | }; | ||
96 | |||
97 | static struct platform_device *edb93xx_snd_device; | ||
98 | |||
99 | static int __init edb93xx_init(void) | ||
100 | { | ||
101 | int ret; | ||
102 | |||
103 | if (!edb93xx_has_audio()) | ||
104 | return -ENODEV; | ||
105 | |||
106 | ret = ep93xx_i2s_acquire(EP93XX_SYSCON_DEVCFG_I2SONAC97, | ||
107 | EP93XX_SYSCON_I2SCLKDIV_ORIDE | | ||
108 | EP93XX_SYSCON_I2SCLKDIV_SPOL); | ||
109 | if (ret) | ||
110 | return ret; | ||
111 | |||
112 | edb93xx_snd_device = platform_device_alloc("soc-audio", -1); | ||
113 | if (!edb93xx_snd_device) { | ||
114 | ret = -ENOMEM; | ||
115 | goto free_i2s; | ||
116 | } | ||
117 | |||
118 | platform_set_drvdata(edb93xx_snd_device, &snd_soc_edb93xx); | ||
119 | ret = platform_device_add(edb93xx_snd_device); | ||
120 | if (ret) | ||
121 | goto device_put; | ||
122 | |||
123 | return 0; | ||
124 | |||
125 | device_put: | ||
126 | platform_device_put(edb93xx_snd_device); | ||
127 | free_i2s: | ||
128 | ep93xx_i2s_release(); | ||
129 | return ret; | ||
130 | } | ||
131 | module_init(edb93xx_init); | ||
132 | |||
133 | static void __exit edb93xx_exit(void) | ||
134 | { | ||
135 | platform_device_unregister(edb93xx_snd_device); | ||
136 | ep93xx_i2s_release(); | ||
137 | } | ||
138 | module_exit(edb93xx_exit); | ||
139 | |||
140 | MODULE_AUTHOR("Alexander Sverdlin <subaparts@yandex.ru>"); | ||
141 | MODULE_DESCRIPTION("ALSA SoC EDB93xx"); | ||
142 | MODULE_LICENSE("GPL"); | ||
diff --git a/sound/soc/ep93xx/ep93xx-ac97.c b/sound/soc/ep93xx/ep93xx-ac97.c index 68a0bae1208a..104e95cda0ad 100644 --- a/sound/soc/ep93xx/ep93xx-ac97.c +++ b/sound/soc/ep93xx/ep93xx-ac97.c | |||
@@ -253,7 +253,6 @@ static int ep93xx_ac97_trigger(struct snd_pcm_substream *substream, | |||
253 | struct ep93xx_ac97_info *info = snd_soc_dai_get_drvdata(dai); | 253 | struct ep93xx_ac97_info *info = snd_soc_dai_get_drvdata(dai); |
254 | unsigned v = 0; | 254 | unsigned v = 0; |
255 | 255 | ||
256 | |||
257 | switch (cmd) { | 256 | switch (cmd) { |
258 | case SNDRV_PCM_TRIGGER_START: | 257 | case SNDRV_PCM_TRIGGER_START: |
259 | case SNDRV_PCM_TRIGGER_RESUME: | 258 | case SNDRV_PCM_TRIGGER_RESUME: |
diff --git a/sound/soc/ep93xx/ep93xx-i2s.c b/sound/soc/ep93xx/ep93xx-i2s.c index fff579a1c134..042f4e93746f 100644 --- a/sound/soc/ep93xx/ep93xx-i2s.c +++ b/sound/soc/ep93xx/ep93xx-i2s.c | |||
@@ -242,7 +242,7 @@ static int ep93xx_i2s_hw_params(struct snd_pcm_substream *substream, | |||
242 | { | 242 | { |
243 | struct ep93xx_i2s_info *info = snd_soc_dai_get_drvdata(dai); | 243 | struct ep93xx_i2s_info *info = snd_soc_dai_get_drvdata(dai); |
244 | unsigned word_len, div, sdiv, lrdiv; | 244 | unsigned word_len, div, sdiv, lrdiv; |
245 | int found = 0, err; | 245 | int err; |
246 | 246 | ||
247 | switch (params_format(params)) { | 247 | switch (params_format(params)) { |
248 | case SNDRV_PCM_FORMAT_S16_LE: | 248 | case SNDRV_PCM_FORMAT_S16_LE: |
@@ -275,15 +275,14 @@ static int ep93xx_i2s_hw_params(struct snd_pcm_substream *substream, | |||
275 | * the codec uses. | 275 | * the codec uses. |
276 | */ | 276 | */ |
277 | div = clk_get_rate(info->mclk) / params_rate(params); | 277 | div = clk_get_rate(info->mclk) / params_rate(params); |
278 | for (sdiv = 2; sdiv <= 4; sdiv += 2) | 278 | sdiv = 4; |
279 | for (lrdiv = 64; lrdiv <= 128; lrdiv <<= 1) | 279 | if (div > (256 + 512) / 2) { |
280 | if (sdiv * lrdiv == div) { | 280 | lrdiv = 128; |
281 | found = 1; | 281 | } else { |
282 | goto out; | 282 | lrdiv = 64; |
283 | } | 283 | if (div < (128 + 256) / 2) |
284 | out: | 284 | sdiv = 2; |
285 | if (!found) | 285 | } |
286 | return -EINVAL; | ||
287 | 286 | ||
288 | err = clk_set_rate(info->sclk, clk_get_rate(info->mclk) / sdiv); | 287 | err = clk_set_rate(info->sclk, clk_get_rate(info->mclk) / sdiv); |
289 | if (err) | 288 | if (err) |
@@ -314,10 +313,12 @@ static int ep93xx_i2s_suspend(struct snd_soc_dai *dai) | |||
314 | struct ep93xx_i2s_info *info = snd_soc_dai_get_drvdata(dai); | 313 | struct ep93xx_i2s_info *info = snd_soc_dai_get_drvdata(dai); |
315 | 314 | ||
316 | if (!dai->active) | 315 | if (!dai->active) |
317 | return; | 316 | return 0; |
318 | 317 | ||
319 | ep93xx_i2s_disable(info, SNDRV_PCM_STREAM_PLAYBACK); | 318 | ep93xx_i2s_disable(info, SNDRV_PCM_STREAM_PLAYBACK); |
320 | ep93xx_i2s_disable(info, SNDRV_PCM_STREAM_CAPTURE); | 319 | ep93xx_i2s_disable(info, SNDRV_PCM_STREAM_CAPTURE); |
320 | |||
321 | return 0; | ||
321 | } | 322 | } |
322 | 323 | ||
323 | static int ep93xx_i2s_resume(struct snd_soc_dai *dai) | 324 | static int ep93xx_i2s_resume(struct snd_soc_dai *dai) |
@@ -325,10 +326,12 @@ static int ep93xx_i2s_resume(struct snd_soc_dai *dai) | |||
325 | struct ep93xx_i2s_info *info = snd_soc_dai_get_drvdata(dai); | 326 | struct ep93xx_i2s_info *info = snd_soc_dai_get_drvdata(dai); |
326 | 327 | ||
327 | if (!dai->active) | 328 | if (!dai->active) |
328 | return; | 329 | return 0; |
329 | 330 | ||
330 | ep93xx_i2s_enable(info, SNDRV_PCM_STREAM_PLAYBACK); | 331 | ep93xx_i2s_enable(info, SNDRV_PCM_STREAM_PLAYBACK); |
331 | ep93xx_i2s_enable(info, SNDRV_PCM_STREAM_CAPTURE); | 332 | ep93xx_i2s_enable(info, SNDRV_PCM_STREAM_CAPTURE); |
333 | |||
334 | return 0; | ||
332 | } | 335 | } |
333 | #else | 336 | #else |
334 | #define ep93xx_i2s_suspend NULL | 337 | #define ep93xx_i2s_suspend NULL |
@@ -352,13 +355,13 @@ static struct snd_soc_dai_driver ep93xx_i2s_dai = { | |||
352 | .playback = { | 355 | .playback = { |
353 | .channels_min = 2, | 356 | .channels_min = 2, |
354 | .channels_max = 2, | 357 | .channels_max = 2, |
355 | .rates = SNDRV_PCM_RATE_8000_96000, | 358 | .rates = SNDRV_PCM_RATE_8000_192000, |
356 | .formats = EP93XX_I2S_FORMATS, | 359 | .formats = EP93XX_I2S_FORMATS, |
357 | }, | 360 | }, |
358 | .capture = { | 361 | .capture = { |
359 | .channels_min = 2, | 362 | .channels_min = 2, |
360 | .channels_max = 2, | 363 | .channels_max = 2, |
361 | .rates = SNDRV_PCM_RATE_8000_96000, | 364 | .rates = SNDRV_PCM_RATE_8000_192000, |
362 | .formats = EP93XX_I2S_FORMATS, | 365 | .formats = EP93XX_I2S_FORMATS, |
363 | }, | 366 | }, |
364 | .ops = &ep93xx_i2s_dai_ops, | 367 | .ops = &ep93xx_i2s_dai_ops, |
diff --git a/sound/soc/ep93xx/ep93xx-pcm.c b/sound/soc/ep93xx/ep93xx-pcm.c index 06670776f649..a456e491155f 100644 --- a/sound/soc/ep93xx/ep93xx-pcm.c +++ b/sound/soc/ep93xx/ep93xx-pcm.c | |||
@@ -35,9 +35,9 @@ static const struct snd_pcm_hardware ep93xx_pcm_hardware = { | |||
35 | SNDRV_PCM_INFO_INTERLEAVED | | 35 | SNDRV_PCM_INFO_INTERLEAVED | |
36 | SNDRV_PCM_INFO_BLOCK_TRANSFER), | 36 | SNDRV_PCM_INFO_BLOCK_TRANSFER), |
37 | 37 | ||
38 | .rates = SNDRV_PCM_RATE_8000_96000, | 38 | .rates = SNDRV_PCM_RATE_8000_192000, |
39 | .rate_min = SNDRV_PCM_RATE_8000, | 39 | .rate_min = SNDRV_PCM_RATE_8000, |
40 | .rate_max = SNDRV_PCM_RATE_96000, | 40 | .rate_max = SNDRV_PCM_RATE_192000, |
41 | 41 | ||
42 | .formats = (SNDRV_PCM_FMTBIT_S16_LE | | 42 | .formats = (SNDRV_PCM_FMTBIT_S16_LE | |
43 | SNDRV_PCM_FMTBIT_S24_LE | | 43 | SNDRV_PCM_FMTBIT_S24_LE | |