aboutsummaryrefslogtreecommitdiffstats
path: root/sound/soc/au1x/psc-ac97.c
diff options
context:
space:
mode:
authorManuel Lauss <manuel.lauss@googlemail.com>2010-08-26 08:53:51 -0400
committerMark Brown <broonie@opensource.wolfsonmicro.com>2010-08-31 08:06:31 -0400
commitffc4fdbbe1b4be79e98340ebcd5a0ade6f5de318 (patch)
treee4f16ef2561497482df5ac9039ba7bdb21212b2d /sound/soc/au1x/psc-ac97.c
parent0bb5f267af41c39af895faee3abe2d9ab8c562e0 (diff)
ASoC: fix au1x platform
This patch fixes up the au1x audio platform after the multi-component merge: - compile fixes and updates to get DB1200 platform audio working again, - removal of global variables in AC97/I2S/DMA(PCM) modules. The AC97 part is limited to one instance only for now due to issues with getting at driver data in the soc_ac97_ops. Signed-off-by: Manuel Lauss <manuel.lauss@googlemail.com> Acked-by: Liam Girdwood <lrg@slimlogic.co.uk> Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
Diffstat (limited to 'sound/soc/au1x/psc-ac97.c')
-rw-r--r--sound/soc/au1x/psc-ac97.c59
1 files changed, 35 insertions, 24 deletions
diff --git a/sound/soc/au1x/psc-ac97.c b/sound/soc/au1x/psc-ac97.c
index 6a9516cbe424..d0db66f24a00 100644
--- a/sound/soc/au1x/psc-ac97.c
+++ b/sound/soc/au1x/psc-ac97.c
@@ -10,9 +10,6 @@
10 * 10 *
11 * Au1xxx-PSC AC97 glue. 11 * Au1xxx-PSC AC97 glue.
12 * 12 *
13 * NOTE: all of these drivers can only work with a SINGLE instance
14 * of a PSC. Multiple independent audio devices are impossible
15 * with ASoC v1.
16 */ 13 */
17 14
18#include <linux/init.h> 15#include <linux/init.h>
@@ -56,12 +53,29 @@
56/* instance data. There can be only one, MacLeod!!!! */ 53/* instance data. There can be only one, MacLeod!!!! */
57static struct au1xpsc_audio_data *au1xpsc_ac97_workdata; 54static struct au1xpsc_audio_data *au1xpsc_ac97_workdata;
58 55
56#if 0
57
58/* this could theoretically work, but ac97->bus->card->private_data can be NULL
59 * when snd_ac97_mixer() is called; I don't know if the rest further down the
60 * chain are always valid either.
61 */
62static inline struct au1xpsc_audio_data *ac97_to_pscdata(struct snd_ac97 *x)
63{
64 struct snd_soc_card *c = x->bus->card->private_data;
65 return snd_soc_dai_get_drvdata(c->rtd->cpu_dai);
66}
67
68#else
69
70#define ac97_to_pscdata(x) au1xpsc_ac97_workdata
71
72#endif
73
59/* AC97 controller reads codec register */ 74/* AC97 controller reads codec register */
60static unsigned short au1xpsc_ac97_read(struct snd_ac97 *ac97, 75static unsigned short au1xpsc_ac97_read(struct snd_ac97 *ac97,
61 unsigned short reg) 76 unsigned short reg)
62{ 77{
63 /* FIXME */ 78 struct au1xpsc_audio_data *pscdata = ac97_to_pscdata(ac97);
64 struct au1xpsc_audio_data *pscdata = au1xpsc_ac97_workdata;
65 unsigned short retry, tmo; 79 unsigned short retry, tmo;
66 unsigned long data; 80 unsigned long data;
67 81
@@ -102,8 +116,7 @@ static unsigned short au1xpsc_ac97_read(struct snd_ac97 *ac97,
102static void au1xpsc_ac97_write(struct snd_ac97 *ac97, unsigned short reg, 116static void au1xpsc_ac97_write(struct snd_ac97 *ac97, unsigned short reg,
103 unsigned short val) 117 unsigned short val)
104{ 118{
105 /* FIXME */ 119 struct au1xpsc_audio_data *pscdata = ac97_to_pscdata(ac97);
106 struct au1xpsc_audio_data *pscdata = au1xpsc_ac97_workdata;
107 unsigned int tmo, retry; 120 unsigned int tmo, retry;
108 121
109 au_writel(PSC_AC97EVNT_CD, AC97_EVNT(pscdata)); 122 au_writel(PSC_AC97EVNT_CD, AC97_EVNT(pscdata));
@@ -134,8 +147,7 @@ static void au1xpsc_ac97_write(struct snd_ac97 *ac97, unsigned short reg,
134/* AC97 controller asserts a warm reset */ 147/* AC97 controller asserts a warm reset */
135static void au1xpsc_ac97_warm_reset(struct snd_ac97 *ac97) 148static void au1xpsc_ac97_warm_reset(struct snd_ac97 *ac97)
136{ 149{
137 /* FIXME */ 150 struct au1xpsc_audio_data *pscdata = ac97_to_pscdata(ac97);
138 struct au1xpsc_audio_data *pscdata = au1xpsc_ac97_workdata;
139 151
140 au_writel(PSC_AC97RST_SNC, AC97_RST(pscdata)); 152 au_writel(PSC_AC97RST_SNC, AC97_RST(pscdata));
141 au_sync(); 153 au_sync();
@@ -146,8 +158,7 @@ static void au1xpsc_ac97_warm_reset(struct snd_ac97 *ac97)
146 158
147static void au1xpsc_ac97_cold_reset(struct snd_ac97 *ac97) 159static void au1xpsc_ac97_cold_reset(struct snd_ac97 *ac97)
148{ 160{
149 /* FIXME */ 161 struct au1xpsc_audio_data *pscdata = ac97_to_pscdata(ac97);
150 struct au1xpsc_audio_data *pscdata = au1xpsc_ac97_workdata;
151 int i; 162 int i;
152 163
153 /* disable PSC during cold reset */ 164 /* disable PSC during cold reset */
@@ -202,8 +213,7 @@ static int au1xpsc_ac97_hw_params(struct snd_pcm_substream *substream,
202 struct snd_pcm_hw_params *params, 213 struct snd_pcm_hw_params *params,
203 struct snd_soc_dai *dai) 214 struct snd_soc_dai *dai)
204{ 215{
205 /* FIXME */ 216 struct au1xpsc_audio_data *pscdata = snd_soc_dai_get_drvdata(dai);
206 struct au1xpsc_audio_data *pscdata = au1xpsc_ac97_workdata;
207 unsigned long r, ro, stat; 217 unsigned long r, ro, stat;
208 int chans, t, stype = SUBSTREAM_TYPE(substream); 218 int chans, t, stype = SUBSTREAM_TYPE(substream);
209 219
@@ -283,8 +293,7 @@ out:
283static int au1xpsc_ac97_trigger(struct snd_pcm_substream *substream, 293static int au1xpsc_ac97_trigger(struct snd_pcm_substream *substream,
284 int cmd, struct snd_soc_dai *dai) 294 int cmd, struct snd_soc_dai *dai)
285{ 295{
286 /* FIXME */ 296 struct au1xpsc_audio_data *pscdata = snd_soc_dai_get_drvdata(dai);
287 struct au1xpsc_audio_data *pscdata = au1xpsc_ac97_workdata;
288 int ret, stype = SUBSTREAM_TYPE(substream); 297 int ret, stype = SUBSTREAM_TYPE(substream);
289 298
290 ret = 0; 299 ret = 0;
@@ -325,7 +334,7 @@ static struct snd_soc_dai_ops au1xpsc_ac97_dai_ops = {
325 .hw_params = au1xpsc_ac97_hw_params, 334 .hw_params = au1xpsc_ac97_hw_params,
326}; 335};
327 336
328struct snd_soc_dai_driver au1xpsc_ac97_dai = { 337static const struct snd_soc_dai_driver au1xpsc_ac97_dai_template = {
329 .ac97_control = 1, 338 .ac97_control = 1,
330 .probe = au1xpsc_ac97_probe, 339 .probe = au1xpsc_ac97_probe,
331 .playback = { 340 .playback = {
@@ -342,7 +351,6 @@ struct snd_soc_dai_driver au1xpsc_ac97_dai = {
342 }, 351 },
343 .ops = &au1xpsc_ac97_dai_ops, 352 .ops = &au1xpsc_ac97_dai_ops,
344}; 353};
345EXPORT_SYMBOL_GPL(au1xpsc_ac97_dai);
346 354
347static int __devinit au1xpsc_ac97_drvprobe(struct platform_device *pdev) 355static int __devinit au1xpsc_ac97_drvprobe(struct platform_device *pdev)
348{ 356{
@@ -351,9 +359,6 @@ static int __devinit au1xpsc_ac97_drvprobe(struct platform_device *pdev)
351 unsigned long sel; 359 unsigned long sel;
352 struct au1xpsc_audio_data *wd; 360 struct au1xpsc_audio_data *wd;
353 361
354 if (au1xpsc_ac97_workdata)
355 return -EBUSY;
356
357 wd = kzalloc(sizeof(struct au1xpsc_audio_data), GFP_KERNEL); 362 wd = kzalloc(sizeof(struct au1xpsc_audio_data), GFP_KERNEL);
358 if (!wd) 363 if (!wd)
359 return -ENOMEM; 364 return -ENOMEM;
@@ -387,14 +392,20 @@ static int __devinit au1xpsc_ac97_drvprobe(struct platform_device *pdev)
387 au_writel(PSC_SEL_PS_AC97MODE | sel, PSC_SEL(wd)); 392 au_writel(PSC_SEL_PS_AC97MODE | sel, PSC_SEL(wd));
388 au_sync(); 393 au_sync();
389 394
390 ret = snd_soc_register_dai(&pdev->dev, &au1xpsc_ac97_dai); 395 /* name the DAI like this device instance ("au1xpsc-ac97.PSCINDEX") */
396 memcpy(&wd->dai_drv, &au1xpsc_ac97_dai_template,
397 sizeof(struct snd_soc_dai_driver));
398 wd->dai_drv.name = dev_name(&pdev->dev);
399
400 platform_set_drvdata(pdev, wd);
401
402 ret = snd_soc_register_dai(&pdev->dev, &wd->dai_drv);
391 if (ret) 403 if (ret)
392 goto out1; 404 goto out1;
393 405
394 wd->dmapd = au1xpsc_pcm_add(pdev); 406 wd->dmapd = au1xpsc_pcm_add(pdev);
395 if (wd->dmapd) { 407 if (wd->dmapd) {
396 platform_set_drvdata(pdev, wd); 408 au1xpsc_ac97_workdata = wd;
397 au1xpsc_ac97_workdata = wd; /* MDEV */
398 return 0; 409 return 0;
399 } 410 }
400 411
@@ -477,7 +488,7 @@ static struct dev_pm_ops au1xpscac97_pmops = {
477 488
478static struct platform_driver au1xpsc_ac97_driver = { 489static struct platform_driver au1xpsc_ac97_driver = {
479 .driver = { 490 .driver = {
480 .name = "au1xpsc-ac97", 491 .name = "au1xpsc_ac97",
481 .owner = THIS_MODULE, 492 .owner = THIS_MODULE,
482 .pm = AU1XPSCAC97_PMOPS, 493 .pm = AU1XPSCAC97_PMOPS,
483 }, 494 },