aboutsummaryrefslogtreecommitdiffstats
path: root/sound/soc/kirkwood/kirkwood-i2s.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/kirkwood/kirkwood-i2s.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/kirkwood/kirkwood-i2s.c')
-rw-r--r--sound/soc/kirkwood/kirkwood-i2s.c52
1 files changed, 29 insertions, 23 deletions
diff --git a/sound/soc/kirkwood/kirkwood-i2s.c b/sound/soc/kirkwood/kirkwood-i2s.c
index 981ffc2a13c8..9b62cba4f590 100644
--- a/sound/soc/kirkwood/kirkwood-i2s.c
+++ b/sound/soc/kirkwood/kirkwood-i2s.c
@@ -20,7 +20,6 @@
20#include <sound/pcm_params.h> 20#include <sound/pcm_params.h>
21#include <sound/soc.h> 21#include <sound/soc.h>
22#include <plat/audio.h> 22#include <plat/audio.h>
23#include "kirkwood-i2s.h"
24#include "kirkwood.h" 23#include "kirkwood.h"
25 24
26#define DRV_NAME "kirkwood-i2s" 25#define DRV_NAME "kirkwood-i2s"
@@ -33,13 +32,10 @@
33 SNDRV_PCM_FMTBIT_S24_LE | \ 32 SNDRV_PCM_FMTBIT_S24_LE | \
34 SNDRV_PCM_FMTBIT_S32_LE) 33 SNDRV_PCM_FMTBIT_S32_LE)
35 34
36
37struct snd_soc_dai kirkwood_i2s_dai;
38static struct kirkwood_dma_data *priv;
39
40static int kirkwood_i2s_set_fmt(struct snd_soc_dai *cpu_dai, 35static int kirkwood_i2s_set_fmt(struct snd_soc_dai *cpu_dai,
41 unsigned int fmt) 36 unsigned int fmt)
42{ 37{
38 struct kirkwood_dma_data *priv = snd_soc_dai_get_drvdata(cpu_dai);
43 unsigned long mask; 39 unsigned long mask;
44 unsigned long value; 40 unsigned long value;
45 41
@@ -101,10 +97,20 @@ static inline void kirkwood_set_dco(void __iomem *io, unsigned long rate)
101 } while (value == 0); 97 } while (value == 0);
102} 98}
103 99
100static int kirkwood_i2s_startup(struct snd_pcm_substream *substream,
101 struct snd_soc_dai *dai)
102{
103 struct kirkwood_dma_data *priv = snd_soc_dai_get_drvdata(dai);
104
105 snd_soc_dai_set_dma_data(dai, substream, priv);
106 return 0;
107}
108
104static int kirkwood_i2s_hw_params(struct snd_pcm_substream *substream, 109static int kirkwood_i2s_hw_params(struct snd_pcm_substream *substream,
105 struct snd_pcm_hw_params *params, 110 struct snd_pcm_hw_params *params,
106 struct snd_soc_dai *dai) 111 struct snd_soc_dai *dai)
107{ 112{
113 struct kirkwood_dma_data *priv = snd_soc_dai_get_drvdata(dai);
108 unsigned int i2s_reg, reg; 114 unsigned int i2s_reg, reg;
109 unsigned long i2s_value, value; 115 unsigned long i2s_value, value;
110 116
@@ -171,6 +177,7 @@ static int kirkwood_i2s_hw_params(struct snd_pcm_substream *substream,
171static int kirkwood_i2s_play_trigger(struct snd_pcm_substream *substream, 177static int kirkwood_i2s_play_trigger(struct snd_pcm_substream *substream,
172 int cmd, struct snd_soc_dai *dai) 178 int cmd, struct snd_soc_dai *dai)
173{ 179{
180 struct kirkwood_dma_data *priv = snd_soc_dai_get_drvdata(dai);
174 unsigned long value; 181 unsigned long value;
175 182
176 /* 183 /*
@@ -244,6 +251,7 @@ static int kirkwood_i2s_play_trigger(struct snd_pcm_substream *substream,
244static int kirkwood_i2s_rec_trigger(struct snd_pcm_substream *substream, 251static int kirkwood_i2s_rec_trigger(struct snd_pcm_substream *substream,
245 int cmd, struct snd_soc_dai *dai) 252 int cmd, struct snd_soc_dai *dai)
246{ 253{
254 struct kirkwood_dma_data *priv = snd_soc_dai_get_drvdata(dai);
247 unsigned long value; 255 unsigned long value;
248 256
249 value = readl(priv->io + KIRKWOOD_RECCTL); 257 value = readl(priv->io + KIRKWOOD_RECCTL);
@@ -323,9 +331,9 @@ static int kirkwood_i2s_trigger(struct snd_pcm_substream *substream, int cmd,
323 return 0; 331 return 0;
324} 332}
325 333
326static int kirkwood_i2s_probe(struct platform_device *pdev, 334static int kirkwood_i2s_probe(struct snd_soc_dai *dai)
327 struct snd_soc_dai *dai)
328{ 335{
336 struct kirkwood_dma_data *priv = snd_soc_dai_get_drvdata(dai);
329 unsigned long value; 337 unsigned long value;
330 unsigned int reg_data; 338 unsigned int reg_data;
331 339
@@ -359,21 +367,20 @@ static int kirkwood_i2s_probe(struct platform_device *pdev,
359 367
360} 368}
361 369
362static void kirkwood_i2s_remove(struct platform_device *pdev, 370static int kirkwood_i2s_remove(struct snd_soc_dai *dai)
363 struct snd_soc_dai *dai)
364{ 371{
372 return 0;
365} 373}
366 374
367static struct snd_soc_dai_ops kirkwood_i2s_dai_ops = { 375static struct snd_soc_dai_ops kirkwood_i2s_dai_ops = {
376 .startup = kirkwood_i2s_startup,
368 .trigger = kirkwood_i2s_trigger, 377 .trigger = kirkwood_i2s_trigger,
369 .hw_params = kirkwood_i2s_hw_params, 378 .hw_params = kirkwood_i2s_hw_params,
370 .set_fmt = kirkwood_i2s_set_fmt, 379 .set_fmt = kirkwood_i2s_set_fmt,
371}; 380};
372 381
373 382
374struct snd_soc_dai kirkwood_i2s_dai = { 383static struct snd_soc_dai_driver kirkwood_i2s_dai = {
375 .name = DRV_NAME,
376 .id = 0,
377 .probe = kirkwood_i2s_probe, 384 .probe = kirkwood_i2s_probe,
378 .remove = kirkwood_i2s_remove, 385 .remove = kirkwood_i2s_remove,
379 .playback = { 386 .playback = {
@@ -388,13 +395,13 @@ struct snd_soc_dai kirkwood_i2s_dai = {
388 .formats = KIRKWOOD_I2S_FORMATS,}, 395 .formats = KIRKWOOD_I2S_FORMATS,},
389 .ops = &kirkwood_i2s_dai_ops, 396 .ops = &kirkwood_i2s_dai_ops,
390}; 397};
391EXPORT_SYMBOL_GPL(kirkwood_i2s_dai);
392 398
393static __devinit int kirkwood_i2s_dev_probe(struct platform_device *pdev) 399static __devinit int kirkwood_i2s_dev_probe(struct platform_device *pdev)
394{ 400{
395 struct resource *mem; 401 struct resource *mem;
396 struct kirkwood_asoc_platform_data *data = 402 struct kirkwood_asoc_platform_data *data =
397 pdev->dev.platform_data; 403 pdev->dev.platform_data;
404 struct kirkwood_dma_data *priv;
398 int err; 405 int err;
399 406
400 priv = kzalloc(sizeof(struct kirkwood_dma_data), GFP_KERNEL); 407 priv = kzalloc(sizeof(struct kirkwood_dma_data), GFP_KERNEL);
@@ -403,6 +410,7 @@ static __devinit int kirkwood_i2s_dev_probe(struct platform_device *pdev)
403 err = -ENOMEM; 410 err = -ENOMEM;
404 goto error; 411 goto error;
405 } 412 }
413 dev_set_drvdata(&pdev->dev, priv);
406 414
407 mem = platform_get_resource(pdev, IORESOURCE_MEM, 0); 415 mem = platform_get_resource(pdev, IORESOURCE_MEM, 0);
408 if (!mem) { 416 if (!mem) {
@@ -441,10 +449,7 @@ static __devinit int kirkwood_i2s_dev_probe(struct platform_device *pdev)
441 priv->dram = data->dram; 449 priv->dram = data->dram;
442 priv->burst = data->burst; 450 priv->burst = data->burst;
443 451
444 kirkwood_i2s_dai.capture.dma_data = priv; 452 return snd_soc_register_dai(&pdev->dev, &kirkwood_i2s_dai);
445 kirkwood_i2s_dai.playback.dma_data = priv;
446
447 return snd_soc_register_dai(&kirkwood_i2s_dai);
448 453
449err_ioremap: 454err_ioremap:
450 iounmap(priv->io); 455 iounmap(priv->io);
@@ -458,12 +463,13 @@ error:
458 463
459static __devexit int kirkwood_i2s_dev_remove(struct platform_device *pdev) 464static __devexit int kirkwood_i2s_dev_remove(struct platform_device *pdev)
460{ 465{
461 if (priv) { 466 struct kirkwood_dma_data *priv = dev_get_drvdata(&pdev->dev);
462 iounmap(priv->io); 467
463 release_mem_region(priv->mem->start, SZ_16K); 468 snd_soc_unregister_dai(&pdev->dev);
464 kfree(priv); 469 iounmap(priv->io);
465 } 470 release_mem_region(priv->mem->start, SZ_16K);
466 snd_soc_unregister_dai(&kirkwood_i2s_dai); 471 kfree(priv);
472
467 return 0; 473 return 0;
468} 474}
469 475