aboutsummaryrefslogtreecommitdiff
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 206b9333f91..a3fb1496e4d 100644
--- a/sound/ppc/Kconfig
+++ b/sound/ppc/Kconfig
@@ -13,7 +13,6 @@ config SND_POWERMAC
tristate "PowerMac (AWACS, DACA, Burgundy, Tumbler, Keywest)"
depends on SND && I2C && INPUT && PPC_PMAC
select SND_PCM
- select SND_GENERIC_DRIVER
help
Say Y here to include support for the integrated sound device.
diff --git a/sound/ppc/pmac.c b/sound/ppc/pmac.c
index 222765fd0dc..4f0a4204516 100644
--- a/sound/ppc/pmac.c
+++ b/sound/ppc/pmac.c
@@ -36,14 +36,6 @@
#include <asm/pci-bridge.h>
-#ifdef CONFIG_PM
-static int snd_pmac_register_sleep_notifier(struct snd_pmac *chip);
-static int snd_pmac_unregister_sleep_notifier(struct snd_pmac *chip);
-static int snd_pmac_suspend(struct snd_card *card, pm_message_t state);
-static int snd_pmac_resume(struct snd_card *card);
-#endif
-
-
/* fixed frequency table for awacs, screamer, burgundy, DACA (44100 max) */
static int awacs_freqs[8] = {
44100, 29400, 22050, 17640, 14700, 11025, 8820, 7350
@@ -784,9 +776,6 @@ static int snd_pmac_free(struct snd_pmac *chip)
}
snd_pmac_sound_feature(chip, 0);
-#ifdef CONFIG_PM
- snd_pmac_unregister_sleep_notifier(chip);
-#endif
/* clean up mixer if any */
if (chip->mixer_free)
@@ -1298,12 +1287,6 @@ int __init snd_pmac_new(struct snd_card *card, struct snd_pmac **chip_return)
/* Reset dbdma channels */
snd_pmac_dbdma_reset(chip);
-#ifdef CONFIG_PM
- /* add sleep notifier */
- if (! snd_pmac_register_sleep_notifier(chip))
- snd_card_set_pm_callback(chip->card, snd_pmac_suspend, snd_pmac_resume, chip);
-#endif
-
if ((err = snd_device_new(card, SNDRV_DEV_LOWLEVEL, chip, &ops)) < 0)
goto __error;
@@ -1328,11 +1311,11 @@ int __init snd_pmac_new(struct snd_card *card, struct snd_pmac **chip_return)
* Save state when going to sleep, restore it afterwards.
*/
-static int snd_pmac_suspend(struct snd_card *card, pm_message_t state)
+void snd_pmac_suspend(struct snd_pmac *chip)
{
- struct snd_pmac *chip = card->pm_private_data;
unsigned long flags;
+ snd_power_change_state(chip->card, SNDRV_CTL_POWER_D3hot);
if (chip->suspend)
chip->suspend(chip);
snd_pcm_suspend_all(chip->pcm);
@@ -1346,22 +1329,18 @@ static int snd_pmac_suspend(struct snd_card *card, pm_message_t state)
if (chip->rx_irq >= 0)
disable_irq(chip->rx_irq);
snd_pmac_sound_feature(chip, 0);
- return 0;
}
-static int snd_pmac_resume(struct snd_card *card)
+void snd_pmac_resume(struct snd_pmac *chip)
{
- struct snd_pmac *chip = card->pm_private_data;
-
snd_pmac_sound_feature(chip, 1);
if (chip->resume)
chip->resume(chip);
/* enable CD sound input */
- if (chip->macio_base && chip->is_pbook_G3) {
+ if (chip->macio_base && chip->is_pbook_G3)
out_8(chip->macio_base + 0x37, 3);
- } else if (chip->is_pbook_3400) {
+ else if (chip->is_pbook_3400)
in_8(chip->latch_base + 0x190);
- }
snd_pmac_pcm_set_format(chip);
@@ -1372,53 +1351,7 @@ static int snd_pmac_resume(struct snd_card *card)
if (chip->rx_irq >= 0)
enable_irq(chip->rx_irq);
- return 0;
-}
-
-/* the chip is stored statically by snd_pmac_register_sleep_notifier
- * because we can't have any private data for notify callback.
- */
-static struct snd_pmac *sleeping_pmac = NULL;
-
-static int snd_pmac_sleep_notify(struct pmu_sleep_notifier *self, int when)
-{
- struct snd_pmac *chip;
-
- chip = sleeping_pmac;
- if (! chip)
- return 0;
-
- switch (when) {
- case PBOOK_SLEEP_NOW:
- snd_pmac_suspend(chip->card, PMSG_SUSPEND);
- break;
- case PBOOK_WAKE:
- snd_pmac_resume(chip->card);
- break;
- }
- return PBOOK_SLEEP_OK;
-}
-
-static struct pmu_sleep_notifier snd_pmac_sleep_notifier = {
- snd_pmac_sleep_notify, SLEEP_LEVEL_SOUND,
-};
-
-static int __init snd_pmac_register_sleep_notifier(struct snd_pmac *chip)
-{
- /* should be protected here.. */
- snd_assert(! sleeping_pmac, return -EBUSY);
- sleeping_pmac = chip;
- pmu_register_sleep_notifier(&snd_pmac_sleep_notifier);
- return 0;
-}
-
-static int snd_pmac_unregister_sleep_notifier(struct snd_pmac *chip)
-{
- /* should be protected here.. */
- snd_assert(sleeping_pmac == chip, return -ENODEV);
- pmu_unregister_sleep_notifier(&snd_pmac_sleep_notifier);
- sleeping_pmac = NULL;
- return 0;
+ snd_power_change_state(chip->card, SNDRV_CTL_POWER_D0);
}
#endif /* CONFIG_PM */
diff --git a/sound/ppc/pmac.h b/sound/ppc/pmac.h
index e223884ccb2..086da7a1890 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,
void snd_pmac_beep_dma_start(struct snd_pmac *chip, int bytes, unsigned long addr, int speed);
void snd_pmac_beep_dma_stop(struct snd_pmac *chip);
+#ifdef CONFIG_PM
+void snd_pmac_suspend(struct snd_pmac *chip);
+void snd_pmac_resume(struct snd_pmac *chip);
+#endif
+
/* initialize mixer */
int snd_pmac_awacs_init(struct snd_pmac *chip);
int snd_pmac_burgundy_init(struct snd_pmac *chip);
diff --git a/sound/ppc/powermac.c b/sound/ppc/powermac.c
index db139cdee28..efa06fe5f01 100644
--- a/sound/ppc/powermac.c
+++ b/sound/ppc/powermac.c
@@ -20,6 +20,8 @@
#include <sound/driver.h>
#include <linux/init.h>
+#include <linux/err.h>
+#include <linux/platform_device.h>
#include <linux/moduleparam.h>
#include <sound/core.h>
#include <sound/initval.h>
@@ -46,15 +48,9 @@ MODULE_PARM_DESC(enable_beep, "Enable beep using PCM.");
/*
- * card entry
*/
-static struct snd_card *snd_pmac_card = NULL;
-
-/*
- */
-
-static int __init snd_pmac_probe(void)
+static int __init snd_pmac_probe(struct platform_device *devptr)
{
struct snd_card *card;
struct snd_pmac *chip;
@@ -67,6 +63,7 @@ static int __init snd_pmac_probe(void)
if ((err = snd_pmac_new(card, &chip)) < 0)
goto __error;
+ card->private_data = chip;
switch (chip->model) {
case PMAC_BURGUNDY:
@@ -131,13 +128,12 @@ static int __init snd_pmac_probe(void)
if (enable_beep)
snd_pmac_attach_beep(chip);
- if ((err = snd_card_set_generic_dev(card)) < 0)
- goto __error;
+ snd_card_set_dev(card, &devptr->dev);
if ((err = snd_card_register(card)) < 0)
goto __error;
- snd_pmac_card = card;
+ platform_set_drvdata(devptr, card);
return 0;
__error:
@@ -146,23 +142,62 @@ __error:
}
-/*
- * MODULE stuff
- */
+static int __devexit snd_pmac_remove(struct platform_device *devptr)
+{
+ snd_card_free(platform_get_drvdata(devptr));
+ platform_set_drvdata(devptr, NULL);
+ return 0;
+}
+
+#ifdef CONFIG_PM
+static int snd_pmac_driver_suspend(struct platform_device *devptr, pm_message_t state)
+{
+ struct snd_card *card = platform_get_drvdata(devptr);
+ snd_pmac_suspend(card->private_data);
+ return 0;
+}
+
+static int snd_pmac_driver_resume(struct platform_device *devptr)
+{
+ struct snd_card *card = platform_get_drvdata(devptr);
+ snd_pmac_resume(card->private_data);
+ return 0;
+}
+#endif
+
+#define SND_PMAC_DRIVER "snd_powermac"
+
+static struct platform_driver snd_pmac_driver = {
+ .probe = snd_pmac_probe,
+ .remove = __devexit_p(snd_pmac_remove),
+#ifdef CONFIG_PM
+ .suspend = snd_pmac_driver_suspend,
+ .resume = snd_pmac_driver_resume,
+#endif
+ .driver = {
+ .name = SND_PMAC_DRIVER
+ },
+};
static int __init alsa_card_pmac_init(void)
{
int err;
- if ((err = snd_pmac_probe()) < 0)
+ struct platform_device *device;
+
+ if ((err = platform_driver_register(&snd_pmac_driver)) < 0)
return err;
+ device = platform_device_register_simple(SND_PMAC_DRIVER, -1, NULL, 0);
+ if (IS_ERR(device)) {
+ platform_driver_unregister(&snd_pmac_driver);
+ return PTR_ERR(device);
+ }
return 0;
}
static void __exit alsa_card_pmac_exit(void)
{
- if (snd_pmac_card)
- snd_card_free(snd_pmac_card);
+ platform_driver_unregister(&snd_pmac_driver);
}
module_init(alsa_card_pmac_init)