diff options
Diffstat (limited to 'sound/ppc/pmac.c')
-rw-r--r-- | sound/ppc/pmac.c | 79 |
1 files changed, 6 insertions, 73 deletions
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 | ||
40 | static int snd_pmac_register_sleep_notifier(struct snd_pmac *chip); | ||
41 | static int snd_pmac_unregister_sleep_notifier(struct snd_pmac *chip); | ||
42 | static int snd_pmac_suspend(struct snd_card *card, pm_message_t state); | ||
43 | static 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) */ |
48 | static int awacs_freqs[8] = { | 40 | static 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 | ||
1331 | static int snd_pmac_suspend(struct snd_card *card, pm_message_t state) | 1314 | void 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 | ||
1352 | static int snd_pmac_resume(struct snd_card *card) | 1334 | void 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 | */ | ||
1381 | static struct snd_pmac *sleeping_pmac = NULL; | ||
1382 | |||
1383 | static 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 | |||
1402 | static struct pmu_sleep_notifier snd_pmac_sleep_notifier = { | ||
1403 | snd_pmac_sleep_notify, SLEEP_LEVEL_SOUND, | ||
1404 | }; | ||
1405 | |||
1406 | static 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 | |||
1415 | static 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 */ |