1 // SPDX-License-Identifier: GPL-2.0-or-later
3 * Driver for PowerMac AWACS
4 * Copyright (c) 2001 by Takashi Iwai <tiwai@suse.de>
8 #include <linux/init.h>
10 #include <linux/platform_device.h>
11 #include <linux/module.h>
12 #include <sound/core.h>
13 #include <sound/initval.h>
18 #define CHIP_NAME "PMac"
20 MODULE_DESCRIPTION("PowerMac");
21 MODULE_SUPPORTED_DEVICE("{{Apple,PowerMac}}");
22 MODULE_LICENSE("GPL");
24 static int index = SNDRV_DEFAULT_IDX1; /* Index 0-MAX */
25 static char *id = SNDRV_DEFAULT_STR1; /* ID for this card */
26 static bool enable_beep = 1;
28 module_param(index, int, 0444);
29 MODULE_PARM_DESC(index, "Index value for " CHIP_NAME " soundchip.");
30 module_param(id, charp, 0444);
31 MODULE_PARM_DESC(id, "ID string for " CHIP_NAME " soundchip.");
32 module_param(enable_beep, bool, 0444);
33 MODULE_PARM_DESC(enable_beep, "Enable beep using PCM.");
35 static struct platform_device *device;
41 static int snd_pmac_probe(struct platform_device *devptr)
43 struct snd_card *card;
44 struct snd_pmac *chip;
48 err = snd_card_new(&devptr->dev, index, id, THIS_MODULE, 0, &card);
52 if ((err = snd_pmac_new(card, &chip)) < 0)
54 card->private_data = chip;
56 switch (chip->model) {
58 strcpy(card->driver, "PMac Burgundy");
59 strcpy(card->shortname, "PowerMac Burgundy");
60 sprintf(card->longname, "%s (Dev %d) Sub-frame %d",
61 card->shortname, chip->device_id, chip->subframe);
62 if ((err = snd_pmac_burgundy_init(chip)) < 0)
66 strcpy(card->driver, "PMac DACA");
67 strcpy(card->shortname, "PowerMac DACA");
68 sprintf(card->longname, "%s (Dev %d) Sub-frame %d",
69 card->shortname, chip->device_id, chip->subframe);
70 if ((err = snd_pmac_daca_init(chip)) < 0)
75 name_ext = chip->model == PMAC_TUMBLER ? "Tumbler" : "Snapper";
76 sprintf(card->driver, "PMac %s", name_ext);
77 sprintf(card->shortname, "PowerMac %s", name_ext);
78 sprintf(card->longname, "%s (Dev %d) Sub-frame %d",
79 card->shortname, chip->device_id, chip->subframe);
80 err = snd_pmac_tumbler_init(chip);
83 err = snd_pmac_tumbler_post_init();
89 name_ext = chip->model == PMAC_SCREAMER ? "Screamer" : "AWACS";
90 sprintf(card->driver, "PMac %s", name_ext);
91 sprintf(card->shortname, "PowerMac %s", name_ext);
92 if (chip->is_pbook_3400)
93 name_ext = " [PB3400]";
94 else if (chip->is_pbook_G3)
98 sprintf(card->longname, "%s%s Rev %d",
99 card->shortname, name_ext, chip->revision);
100 if ((err = snd_pmac_awacs_init(chip)) < 0)
104 snd_printk(KERN_ERR "unsupported hardware %d\n", chip->model);
109 if ((err = snd_pmac_pcm_new(chip)) < 0)
112 chip->initialized = 1;
114 snd_pmac_attach_beep(chip);
116 if ((err = snd_card_register(card)) < 0)
119 platform_set_drvdata(devptr, card);
128 static int snd_pmac_remove(struct platform_device *devptr)
130 snd_card_free(platform_get_drvdata(devptr));
134 #ifdef CONFIG_PM_SLEEP
135 static int snd_pmac_driver_suspend(struct device *dev)
137 struct snd_card *card = dev_get_drvdata(dev);
138 snd_pmac_suspend(card->private_data);
142 static int snd_pmac_driver_resume(struct device *dev)
144 struct snd_card *card = dev_get_drvdata(dev);
145 snd_pmac_resume(card->private_data);
149 static SIMPLE_DEV_PM_OPS(snd_pmac_pm, snd_pmac_driver_suspend, snd_pmac_driver_resume);
150 #define SND_PMAC_PM_OPS &snd_pmac_pm
152 #define SND_PMAC_PM_OPS NULL
155 #define SND_PMAC_DRIVER "snd_powermac"
157 static struct platform_driver snd_pmac_driver = {
158 .probe = snd_pmac_probe,
159 .remove = snd_pmac_remove,
161 .name = SND_PMAC_DRIVER,
162 .pm = SND_PMAC_PM_OPS,
166 static int __init alsa_card_pmac_init(void)
170 if ((err = platform_driver_register(&snd_pmac_driver)) < 0)
172 device = platform_device_register_simple(SND_PMAC_DRIVER, -1, NULL, 0);
177 static void __exit alsa_card_pmac_exit(void)
180 platform_device_unregister(device);
181 platform_driver_unregister(&snd_pmac_driver);
184 module_init(alsa_card_pmac_init)
185 module_exit(alsa_card_pmac_exit)