aboutsummaryrefslogtreecommitdiffstats
path: root/sound/soc/pxa/raumfeld.c
diff options
context:
space:
mode:
authorLiam Girdwood <lrg@slimlogic.co.uk>2010-03-17 16:15:21 -0400
committerLiam Girdwood <lrg@slimlogic.co.uk>2010-08-12 09:00:00 -0400
commitf0fba2ad1b6b53d5360125c41953b7afcd6deff0 (patch)
treef6ad50905f8daa616593c978d7ae992e73241180 /sound/soc/pxa/raumfeld.c
parentbda7d2a862e6b788bca2d02d38a07966a9c92e48 (diff)
ASoC: multi-component - ASoC Multi-Component Support
This patch extends the ASoC API to allow sound cards to have more than one CODEC and more than one platform DMA controller. This is achieved by dividing some current ASoC structures that contain both driver data and device data into structures that only either contain device data or driver data. i.e. struct snd_soc_codec ---> struct snd_soc_codec (device data) +-> struct snd_soc_codec_driver (driver data) struct snd_soc_platform ---> struct snd_soc_platform (device data) +-> struct snd_soc_platform_driver (driver data) struct snd_soc_dai ---> struct snd_soc_dai (device data) +-> struct snd_soc_dai_driver (driver data) struct snd_soc_device ---> deleted This now allows ASoC to be more tightly aligned with the Linux driver model and also means that every ASoC codec, platform and (platform) DAI is a kernel device. ASoC component private data is now stored as device private data. The ASoC sound card struct snd_soc_card has also been updated to store lists of it's components rather than a pointer to a codec and platform. The PCM runtime struct soc_pcm_runtime now has pointers to all its components. This patch adds DAPM support for ASoC multi-component and removes struct snd_soc_socdev from DAPM core. All DAPM calls are now made on a card, codec or runtime PCM level basis rather than using snd_soc_socdev. Other notable multi-component changes:- * Stream operations now de-reference less structures. * close_delayed work() now runs on a DAI basis rather than looping all DAIs in a card. * PM suspend()/resume() operations can now handle N CODECs and Platforms per sound card. * Added soc_bind_dai_link() to bind the component devices to the sound card. * Added soc_dai_link_probe() and soc_dai_link_remove() to probe and remove DAI link components. * sysfs entries can now be registered per component per card. * snd_soc_new_pcms() functionailty rolled into dai_link_probe(). * snd_soc_register_codec() now does all the codec list and mutex init. This patch changes the probe() and remove() of the CODEC drivers as follows:- o Make CODEC driver a platform driver o Moved all struct snd_soc_codec list, mutex, etc initialiasation to core. o Removed all static codec pointers (drivers now support > 1 codec dev) o snd_soc_register_pcms() now done by core. o snd_soc_register_dai() folded into snd_soc_register_codec(). CS4270 portions: Acked-by: Timur Tabi <timur@freescale.com> Some TLV320aic23 and Cirrus platform fixes. Signed-off-by: Ryan Mallon <ryan@bluewatersys.com> TI CODEC and OMAP fixes Signed-off-by: Peter Ujfalusi <peter.ujfalusi@nokia.com> Signed-off-by: Janusz Krzysztofik <jkrzyszt@tis.icnet.pl> Signed-off-by: Jarkko Nikula <jhnikula@gmail.com> Samsung platform and misc fixes :- Signed-off-by: Chanwoo Choi <cw00.choi@samsung.com> Signed-off-by: Joonyoung Shim <jy0922.shim@samsung.com> Signed-off-by: Kyungmin Park <kyungmin.park@samsung.com> Reviewed-by: Jassi Brar <jassi.brar@samsung.com> Signed-off-by: Seungwhan Youn <sw.youn@samsung.com> MPC8610 and PPC fixes. Signed-off-by: Timur Tabi <timur@freescale.com> i.MX fixes and some core fixes. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de> J4740 platform fixes:- Signed-off-by: Lars-Peter Clausen <lars@metafoo.de> CC: Tony Lindgren <tony@atomide.com> CC: Nicolas Ferre <nicolas.ferre@atmel.com> CC: Kevin Hilman <khilman@deeprootsystems.com> CC: Sascha Hauer <s.hauer@pengutronix.de> CC: Atsushi Nemoto <anemo@mba.ocn.ne.jp> CC: Kuninori Morimoto <morimoto.kuninori@renesas.com> CC: Daniel Gloeckner <dg@emlix.com> CC: Manuel Lauss <mano@roarinelk.homelinux.net> CC: Mike Frysinger <vapier.adi@gmail.com> CC: Arnaud Patard <apatard@mandriva.com> CC: Wan ZongShun <mcuos.com@gmail.com> Acked-by: Mark Brown <broonie@opensource.wolfsonmicro.com> Signed-off-by: Liam Girdwood <lrg@slimlogic.co.uk>
Diffstat (limited to 'sound/soc/pxa/raumfeld.c')
-rw-r--r--sound/soc/pxa/raumfeld.c114
1 files changed, 36 insertions, 78 deletions
diff --git a/sound/soc/pxa/raumfeld.c b/sound/soc/pxa/raumfeld.c
index 7e3f41696c41..2cda82bc5d2e 100644
--- a/sound/soc/pxa/raumfeld.c
+++ b/sound/soc/pxa/raumfeld.c
@@ -26,9 +26,6 @@
26 26
27#include <asm/mach-types.h> 27#include <asm/mach-types.h>
28 28
29#include "../codecs/cs4270.h"
30#include "../codecs/ak4104.h"
31#include "pxa2xx-pcm.h"
32#include "pxa-ssp.h" 29#include "pxa-ssp.h"
33 30
34#define GPIO_SPDIF_RESET (38) 31#define GPIO_SPDIF_RESET (38)
@@ -71,7 +68,7 @@ static void raumfeld_enable_audio(bool en)
71static int raumfeld_cs4270_startup(struct snd_pcm_substream *substream) 68static int raumfeld_cs4270_startup(struct snd_pcm_substream *substream)
72{ 69{
73 struct snd_soc_pcm_runtime *rtd = substream->private_data; 70 struct snd_soc_pcm_runtime *rtd = substream->private_data;
74 struct snd_soc_dai *codec_dai = rtd->dai->codec_dai; 71 struct snd_soc_dai *codec_dai = rtd->codec_dai;
75 72
76 /* set freq to 0 to enable all possible codec sample rates */ 73 /* set freq to 0 to enable all possible codec sample rates */
77 return snd_soc_dai_set_sysclk(codec_dai, 0, 0, 0); 74 return snd_soc_dai_set_sysclk(codec_dai, 0, 0, 0);
@@ -80,7 +77,7 @@ static int raumfeld_cs4270_startup(struct snd_pcm_substream *substream)
80static void raumfeld_cs4270_shutdown(struct snd_pcm_substream *substream) 77static void raumfeld_cs4270_shutdown(struct snd_pcm_substream *substream)
81{ 78{
82 struct snd_soc_pcm_runtime *rtd = substream->private_data; 79 struct snd_soc_pcm_runtime *rtd = substream->private_data;
83 struct snd_soc_dai *codec_dai = rtd->dai->codec_dai; 80 struct snd_soc_dai *codec_dai = rtd->codec_dai;
84 81
85 /* set freq to 0 to enable all possible codec sample rates */ 82 /* set freq to 0 to enable all possible codec sample rates */
86 snd_soc_dai_set_sysclk(codec_dai, 0, 0, 0); 83 snd_soc_dai_set_sysclk(codec_dai, 0, 0, 0);
@@ -90,8 +87,8 @@ static int raumfeld_cs4270_hw_params(struct snd_pcm_substream *substream,
90 struct snd_pcm_hw_params *params) 87 struct snd_pcm_hw_params *params)
91{ 88{
92 struct snd_soc_pcm_runtime *rtd = substream->private_data; 89 struct snd_soc_pcm_runtime *rtd = substream->private_data;
93 struct snd_soc_dai *codec_dai = rtd->dai->codec_dai; 90 struct snd_soc_dai *codec_dai = rtd->codec_dai;
94 struct snd_soc_dai *cpu_dai = rtd->dai->cpu_dai; 91 struct snd_soc_dai *cpu_dai = rtd->cpu_dai;
95 unsigned int fmt, clk = 0; 92 unsigned int fmt, clk = 0;
96 int ret = 0; 93 int ret = 0;
97 94
@@ -167,32 +164,14 @@ static int raumfeld_line_resume(struct platform_device *pdev)
167 return 0; 164 return 0;
168} 165}
169 166
170static struct snd_soc_dai_link raumfeld_line_dai = {
171 .name = "CS4270",
172 .stream_name = "CS4270",
173 .cpu_dai = &pxa_ssp_dai[PXA_DAI_SSP1],
174 .codec_dai = &cs4270_dai,
175 .ops = &raumfeld_cs4270_ops,
176};
177
178static struct snd_soc_card snd_soc_line_raumfeld = {
179 .name = "Raumfeld analog",
180 .platform = &pxa2xx_soc_platform,
181 .dai_link = &raumfeld_line_dai,
182 .suspend_post = raumfeld_line_suspend,
183 .resume_pre = raumfeld_line_resume,
184 .num_links = 1,
185};
186
187
188/* AK4104 */ 167/* AK4104 */
189 168
190static int raumfeld_ak4104_hw_params(struct snd_pcm_substream *substream, 169static int raumfeld_ak4104_hw_params(struct snd_pcm_substream *substream,
191 struct snd_pcm_hw_params *params) 170 struct snd_pcm_hw_params *params)
192{ 171{
193 struct snd_soc_pcm_runtime *rtd = substream->private_data; 172 struct snd_soc_pcm_runtime *rtd = substream->private_data;
194 struct snd_soc_dai *codec_dai = rtd->dai->codec_dai; 173 struct snd_soc_dai *codec_dai = rtd->codec_dai;
195 struct snd_soc_dai *cpu_dai = rtd->dai->cpu_dai; 174 struct snd_soc_dai *cpu_dai = rtd->cpu_dai;
196 int fmt, ret = 0, clk = 0; 175 int fmt, ret = 0, clk = 0;
197 176
198 switch (params_rate(params)) { 177 switch (params_rate(params)) {
@@ -247,34 +226,35 @@ static struct snd_soc_ops raumfeld_ak4104_ops = {
247 .hw_params = raumfeld_ak4104_hw_params, 226 .hw_params = raumfeld_ak4104_hw_params,
248}; 227};
249 228
250static struct snd_soc_dai_link raumfeld_spdif_dai = { 229static struct snd_soc_dai_link raumfeld_dai[] = {
230{
251 .name = "ak4104", 231 .name = "ak4104",
252 .stream_name = "Playback", 232 .stream_name = "Playback",
253 .cpu_dai = &pxa_ssp_dai[PXA_DAI_SSP2], 233 .cpu_dai_name = "pxa-ssp-dai.1",
254 .codec_dai = &ak4104_dai, 234 .codec_dai_name = "ak4104-hifi",
235 .platform_name = "pxa-pcm-audio",
255 .ops = &raumfeld_ak4104_ops, 236 .ops = &raumfeld_ak4104_ops,
256}; 237 .codec_name = "ak4104-codec.0",
257 238},
258static struct snd_soc_card snd_soc_spdif_raumfeld = { 239{
259 .name = "Raumfeld S/PDIF", 240 .name = "CS4270",
260 .platform = &pxa2xx_soc_platform, 241 .stream_name = "CS4270",
261 .dai_link = &raumfeld_spdif_dai, 242 .cpu_dai_name = "pxa-ssp-dai.0",
262 .num_links = 1 243 .platform_name = "pxa-pcm-audio",
263}; 244 .codec_dai_name = "cs4270-hifi",
264 245 .codec_name = "cs4270-codec.0-0048",
265/* raumfeld_audio audio subsystem */ 246 .ops = &raumfeld_cs4270_ops,
266static struct snd_soc_device raumfeld_line_devdata = { 247},};
267 .card = &snd_soc_line_raumfeld,
268 .codec_dev = &soc_codec_device_cs4270,
269};
270 248
271static struct snd_soc_device raumfeld_spdif_devdata = { 249static struct snd_soc_card snd_soc_raumfeld = {
272 .card = &snd_soc_spdif_raumfeld, 250 .name = "Raumfeld",
273 .codec_dev = &soc_codec_device_ak4104, 251 .dai_link = raumfeld_dai,
252 .suspend_post = raumfeld_line_suspend,
253 .resume_pre = raumfeld_line_resume,
254 .num_links = ARRAY_SIZE(raumfeld_dai),
274}; 255};
275 256
276static struct platform_device *raumfeld_audio_line_device; 257static struct platform_device *raumfeld_audio_device;
277static struct platform_device *raumfeld_audio_spdif_device;
278 258
279static int __init raumfeld_audio_init(void) 259static int __init raumfeld_audio_init(void)
280{ 260{
@@ -292,38 +272,19 @@ static int __init raumfeld_audio_init(void)
292 272
293 set_max9485_clk(MAX9485_MCLK_FREQ_122880); 273 set_max9485_clk(MAX9485_MCLK_FREQ_122880);
294 274
295 /* LINE */ 275 /* Register LINE and SPDIF */
296 raumfeld_audio_line_device = platform_device_alloc("soc-audio", 0); 276 raumfeld_audio_device = platform_device_alloc("soc-audio", 0);
297 if (!raumfeld_audio_line_device) 277 if (!raumfeld_audio_device)
298 return -ENOMEM; 278 return -ENOMEM;
299 279
300 platform_set_drvdata(raumfeld_audio_line_device, 280 platform_set_drvdata(raumfeld_audio_device,
301 &raumfeld_line_devdata); 281 &snd_soc_raumfeld);
302 raumfeld_line_devdata.dev = &raumfeld_audio_line_device->dev; 282 ret = platform_device_add(raumfeld_audio_device);
303 ret = platform_device_add(raumfeld_audio_line_device);
304 if (ret)
305 platform_device_put(raumfeld_audio_line_device);
306 283
307 /* no S/PDIF on Speakers */ 284 /* no S/PDIF on Speakers */
308 if (machine_is_raumfeld_speaker()) 285 if (machine_is_raumfeld_speaker())
309 return ret; 286 return ret;
310 287
311 /* S/PDIF */
312 raumfeld_audio_spdif_device = platform_device_alloc("soc-audio", 1);
313 if (!raumfeld_audio_spdif_device) {
314 platform_device_put(raumfeld_audio_line_device);
315 return -ENOMEM;
316 }
317
318 platform_set_drvdata(raumfeld_audio_spdif_device,
319 &raumfeld_spdif_devdata);
320 raumfeld_spdif_devdata.dev = &raumfeld_audio_spdif_device->dev;
321 ret = platform_device_add(raumfeld_audio_spdif_device);
322 if (ret) {
323 platform_device_put(raumfeld_audio_line_device);
324 platform_device_put(raumfeld_audio_spdif_device);
325 }
326
327 raumfeld_enable_audio(true); 288 raumfeld_enable_audio(true);
328 289
329 return ret; 290 return ret;
@@ -333,10 +294,7 @@ static void __exit raumfeld_audio_exit(void)
333{ 294{
334 raumfeld_enable_audio(false); 295 raumfeld_enable_audio(false);
335 296
336 platform_device_unregister(raumfeld_audio_line_device); 297 platform_device_unregister(raumfeld_audio_device);
337
338 if (machine_is_raumfeld_connector())
339 platform_device_unregister(raumfeld_audio_spdif_device);
340 298
341 i2c_unregister_device(max9486_client); 299 i2c_unregister_device(max9486_client);
342 300