#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
}
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)
/* 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;
* 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);
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);
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 */
#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>
/*
- * 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;
if ((err = snd_pmac_new(card, &chip)) < 0)
goto __error;
+ card->private_data = chip;
switch (chip->model) {
case PMAC_BURGUNDY:
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:
}
-/*
- * 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)