aboutsummaryrefslogtreecommitdiffstats
path: root/sound/ppc
diff options
context:
space:
mode:
Diffstat (limited to 'sound/ppc')
-rw-r--r--sound/ppc/Kconfig1
-rw-r--r--sound/ppc/pmac.c79
-rw-r--r--sound/ppc/pmac.h5
-rw-r--r--sound/ppc/powermac.c67
4 files changed, 62 insertions, 90 deletions
diff --git a/sound/ppc/Kconfig b/sound/ppc/Kconfig
index 206b9333f91f..a3fb1496e4dc 100644
--- a/sound/ppc/Kconfig
+++ b/sound/ppc/Kconfig
@@ -13,7 +13,6 @@ config SND_POWERMAC
13 tristate "PowerMac (AWACS, DACA, Burgundy, Tumbler, Keywest)" 13 tristate "PowerMac (AWACS, DACA, Burgundy, Tumbler, Keywest)"
14 depends on SND && I2C && INPUT && PPC_PMAC 14 depends on SND && I2C && INPUT && PPC_PMAC
15 select SND_PCM 15 select SND_PCM
16 select SND_GENERIC_DRIVER
17 help 16 help
18 Say Y here to include support for the integrated sound device. 17 Say Y here to include support for the integrated sound device.
19 18
diff --git a/sound/ppc/pmac.c b/sound/ppc/pmac.c
index 222765fd0dc5..4f0a4204516d 100644
--- a/sound/ppc/pmac.c
+++ b/sound/ppc/pmac.c
@@ -36,14 +36,6 @@
36#include <asm/pci-bridge.h> 36#include <asm/pci-bridge.h>
37 37
38 38
39#ifdef CONFIG_PM
40static int snd_pmac_register_sleep_notifier(struct snd_pmac *chip);
41static int snd_pmac_unregister_sleep_notifier(struct snd_pmac *chip);
42static int snd_pmac_suspend(struct snd_card *card, pm_message_t state);
43static int snd_pmac_resume(struct snd_card *card);
44#endif
45
46
47/* fixed frequency table for awacs, screamer, burgundy, DACA (44100 max) */ 39/* fixed frequency table for awacs, screamer, burgundy, DACA (44100 max) */
48static int awacs_freqs[8] = { 40static int awacs_freqs[8] = {
49 44100, 29400, 22050, 17640, 14700, 11025, 8820, 7350 41 44100, 29400, 22050, 17640, 14700, 11025, 8820, 7350
@@ -784,9 +776,6 @@ static int snd_pmac_free(struct snd_pmac *chip)
784 } 776 }
785 777
786 snd_pmac_sound_feature(chip, 0); 778 snd_pmac_sound_feature(chip, 0);
787#ifdef CONFIG_PM
788 snd_pmac_unregister_sleep_notifier(chip);
789#endif
790 779
791 /* clean up mixer if any */ 780 /* clean up mixer if any */
792 if (chip->mixer_free) 781 if (chip->mixer_free)
@@ -1298,12 +1287,6 @@ int __init snd_pmac_new(struct snd_card *card, struct snd_pmac **chip_return)
1298 /* Reset dbdma channels */ 1287 /* Reset dbdma channels */
1299 snd_pmac_dbdma_reset(chip); 1288 snd_pmac_dbdma_reset(chip);
1300 1289
1301#ifdef CONFIG_PM
1302 /* add sleep notifier */
1303 if (! snd_pmac_register_sleep_notifier(chip))
1304 snd_card_set_pm_callback(chip->card, snd_pmac_suspend, snd_pmac_resume, chip);
1305#endif
1306
1307 if ((err = snd_device_new(card, SNDRV_DEV_LOWLEVEL, chip, &ops)) < 0) 1290 if ((err = snd_device_new(card, SNDRV_DEV_LOWLEVEL, chip, &ops)) < 0)
1308 goto __error; 1291 goto __error;
1309 1292
@@ -1328,11 +1311,11 @@ int __init snd_pmac_new(struct snd_card *card, struct snd_pmac **chip_return)
1328 * Save state when going to sleep, restore it afterwards. 1311 * Save state when going to sleep, restore it afterwards.
1329 */ 1312 */
1330 1313
1331static int snd_pmac_suspend(struct snd_card *card, pm_message_t state) 1314void snd_pmac_suspend(struct snd_pmac *chip)
1332{ 1315{
1333 struct snd_pmac *chip = card->pm_private_data;
1334 unsigned long flags; 1316 unsigned long flags;
1335 1317
1318 snd_power_change_state(chip->card, SNDRV_CTL_POWER_D3hot);
1336 if (chip->suspend) 1319 if (chip->suspend)
1337 chip->suspend(chip); 1320 chip->suspend(chip);
1338 snd_pcm_suspend_all(chip->pcm); 1321 snd_pcm_suspend_all(chip->pcm);
@@ -1346,22 +1329,18 @@ static int snd_pmac_suspend(struct snd_card *card, pm_message_t state)
1346 if (chip->rx_irq >= 0) 1329 if (chip->rx_irq >= 0)
1347 disable_irq(chip->rx_irq); 1330 disable_irq(chip->rx_irq);
1348 snd_pmac_sound_feature(chip, 0); 1331 snd_pmac_sound_feature(chip, 0);
1349 return 0;
1350} 1332}
1351 1333
1352static int snd_pmac_resume(struct snd_card *card) 1334void snd_pmac_resume(struct snd_pmac *chip)
1353{ 1335{
1354 struct snd_pmac *chip = card->pm_private_data;
1355
1356 snd_pmac_sound_feature(chip, 1); 1336 snd_pmac_sound_feature(chip, 1);
1357 if (chip->resume) 1337 if (chip->resume)
1358 chip->resume(chip); 1338 chip->resume(chip);
1359 /* enable CD sound input */ 1339 /* enable CD sound input */
1360 if (chip->macio_base && chip->is_pbook_G3) { 1340 if (chip->macio_base && chip->is_pbook_G3)
1361 out_8(chip->macio_base + 0x37, 3); 1341 out_8(chip->macio_base + 0x37, 3);
1362 } else if (chip->is_pbook_3400) { 1342 else if (chip->is_pbook_3400)
1363 in_8(chip->latch_base + 0x190); 1343 in_8(chip->latch_base + 0x190);
1364 }
1365 1344
1366 snd_pmac_pcm_set_format(chip); 1345 snd_pmac_pcm_set_format(chip);
1367 1346
@@ -1372,53 +1351,7 @@ static int snd_pmac_resume(struct snd_card *card)
1372 if (chip->rx_irq >= 0) 1351 if (chip->rx_irq >= 0)
1373 enable_irq(chip->rx_irq); 1352 enable_irq(chip->rx_irq);
1374 1353
1375 return 0; 1354 snd_power_change_state(chip->card, SNDRV_CTL_POWER_D0);
1376}
1377
1378/* the chip is stored statically by snd_pmac_register_sleep_notifier
1379 * because we can't have any private data for notify callback.
1380 */
1381static struct snd_pmac *sleeping_pmac = NULL;
1382
1383static int snd_pmac_sleep_notify(struct pmu_sleep_notifier *self, int when)
1384{
1385 struct snd_pmac *chip;
1386
1387 chip = sleeping_pmac;
1388 if (! chip)
1389 return 0;
1390
1391 switch (when) {
1392 case PBOOK_SLEEP_NOW:
1393 snd_pmac_suspend(chip->card, PMSG_SUSPEND);
1394 break;
1395 case PBOOK_WAKE:
1396 snd_pmac_resume(chip->card);
1397 break;
1398 }
1399 return PBOOK_SLEEP_OK;
1400}
1401
1402static struct pmu_sleep_notifier snd_pmac_sleep_notifier = {
1403 snd_pmac_sleep_notify, SLEEP_LEVEL_SOUND,
1404};
1405
1406static int __init snd_pmac_register_sleep_notifier(struct snd_pmac *chip)
1407{
1408 /* should be protected here.. */
1409 snd_assert(! sleeping_pmac, return -EBUSY);
1410 sleeping_pmac = chip;
1411 pmu_register_sleep_notifier(&snd_pmac_sleep_notifier);
1412 return 0;
1413}
1414
1415static int snd_pmac_unregister_sleep_notifier(struct snd_pmac *chip)
1416{
1417 /* should be protected here.. */
1418 snd_assert(sleeping_pmac == chip, return -ENODEV);
1419 pmu_unregister_sleep_notifier(&snd_pmac_sleep_notifier);
1420 sleeping_pmac = NULL;
1421 return 0;
1422} 1355}
1423 1356
1424#endif /* CONFIG_PM */ 1357#endif /* CONFIG_PM */
diff --git a/sound/ppc/pmac.h b/sound/ppc/pmac.h
index e223884ccb20..086da7a18909 100644
--- a/sound/ppc/pmac.h
+++ b/sound/ppc/pmac.h
@@ -176,6 +176,11 @@ unsigned int snd_pmac_rate_index(struct snd_pmac *chip, struct pmac_stream *rec,
176void snd_pmac_beep_dma_start(struct snd_pmac *chip, int bytes, unsigned long addr, int speed); 176void snd_pmac_beep_dma_start(struct snd_pmac *chip, int bytes, unsigned long addr, int speed);
177void snd_pmac_beep_dma_stop(struct snd_pmac *chip); 177void snd_pmac_beep_dma_stop(struct snd_pmac *chip);
178 178
179#ifdef CONFIG_PM
180void snd_pmac_suspend(struct snd_pmac *chip);
181void snd_pmac_resume(struct snd_pmac *chip);
182#endif
183
179/* initialize mixer */ 184/* initialize mixer */
180int snd_pmac_awacs_init(struct snd_pmac *chip); 185int snd_pmac_awacs_init(struct snd_pmac *chip);
181int snd_pmac_burgundy_init(struct snd_pmac *chip); 186int snd_pmac_burgundy_init(struct snd_pmac *chip);
diff --git a/sound/ppc/powermac.c b/sound/ppc/powermac.c
index db139cdee28b..efa06fe5f01b 100644
--- a/sound/ppc/powermac.c
+++ b/sound/ppc/powermac.c
@@ -20,6 +20,8 @@
20 20
21#include <sound/driver.h> 21#include <sound/driver.h>
22#include <linux/init.h> 22#include <linux/init.h>
23#include <linux/err.h>
24#include <linux/platform_device.h>
23#include <linux/moduleparam.h> 25#include <linux/moduleparam.h>
24#include <sound/core.h> 26#include <sound/core.h>
25#include <sound/initval.h> 27#include <sound/initval.h>
@@ -46,15 +48,9 @@ MODULE_PARM_DESC(enable_beep, "Enable beep using PCM.");
46 48
47 49
48/* 50/*
49 * card entry
50 */ 51 */
51 52
52static struct snd_card *snd_pmac_card = NULL; 53static int __init snd_pmac_probe(struct platform_device *devptr)
53
54/*
55 */
56
57static int __init snd_pmac_probe(void)
58{ 54{
59 struct snd_card *card; 55 struct snd_card *card;
60 struct snd_pmac *chip; 56 struct snd_pmac *chip;
@@ -67,6 +63,7 @@ static int __init snd_pmac_probe(void)
67 63
68 if ((err = snd_pmac_new(card, &chip)) < 0) 64 if ((err = snd_pmac_new(card, &chip)) < 0)
69 goto __error; 65 goto __error;
66 card->private_data = chip;
70 67
71 switch (chip->model) { 68 switch (chip->model) {
72 case PMAC_BURGUNDY: 69 case PMAC_BURGUNDY:
@@ -131,13 +128,12 @@ static int __init snd_pmac_probe(void)
131 if (enable_beep) 128 if (enable_beep)
132 snd_pmac_attach_beep(chip); 129 snd_pmac_attach_beep(chip);
133 130
134 if ((err = snd_card_set_generic_dev(card)) < 0) 131 snd_card_set_dev(card, &devptr->dev);
135 goto __error;
136 132
137 if ((err = snd_card_register(card)) < 0) 133 if ((err = snd_card_register(card)) < 0)
138 goto __error; 134 goto __error;
139 135
140 snd_pmac_card = card; 136 platform_set_drvdata(devptr, card);
141 return 0; 137 return 0;
142 138
143__error: 139__error:
@@ -146,23 +142,62 @@ __error:
146} 142}
147 143
148 144
149/* 145static int __devexit snd_pmac_remove(struct platform_device *devptr)
150 * MODULE stuff 146{
151 */ 147 snd_card_free(platform_get_drvdata(devptr));
148 platform_set_drvdata(devptr, NULL);
149 return 0;
150}
151
152#ifdef CONFIG_PM
153static int snd_pmac_driver_suspend(struct platform_device *devptr, pm_message_t state)
154{
155 struct snd_card *card = platform_get_drvdata(devptr);
156 snd_pmac_suspend(card->private_data);
157 return 0;
158}
159
160static int snd_pmac_driver_resume(struct platform_device *devptr)
161{
162 struct snd_card *card = platform_get_drvdata(devptr);
163 snd_pmac_resume(card->private_data);
164 return 0;
165}
166#endif
167
168#define SND_PMAC_DRIVER "snd_powermac"
169
170static struct platform_driver snd_pmac_driver = {
171 .probe = snd_pmac_probe,
172 .remove = __devexit_p(snd_pmac_remove),
173#ifdef CONFIG_PM
174 .suspend = snd_pmac_driver_suspend,
175 .resume = snd_pmac_driver_resume,
176#endif
177 .driver = {
178 .name = SND_PMAC_DRIVER
179 },
180};
152 181
153static int __init alsa_card_pmac_init(void) 182static int __init alsa_card_pmac_init(void)
154{ 183{
155 int err; 184 int err;
156 if ((err = snd_pmac_probe()) < 0) 185 struct platform_device *device;
186
187 if ((err = platform_driver_register(&snd_pmac_driver)) < 0)
157 return err; 188 return err;
189 device = platform_device_register_simple(SND_PMAC_DRIVER, -1, NULL, 0);
190 if (IS_ERR(device)) {
191 platform_driver_unregister(&snd_pmac_driver);
192 return PTR_ERR(device);
193 }
158 return 0; 194 return 0;
159 195
160} 196}
161 197
162static void __exit alsa_card_pmac_exit(void) 198static void __exit alsa_card_pmac_exit(void)
163{ 199{
164 if (snd_pmac_card) 200 platform_driver_unregister(&snd_pmac_driver);
165 snd_card_free(snd_pmac_card);
166} 201}
167 202
168module_init(alsa_card_pmac_init) 203module_init(alsa_card_pmac_init)