aboutsummaryrefslogtreecommitdiffstats
path: root/sound/ppc/powermac.c
diff options
context:
space:
mode:
Diffstat (limited to 'sound/ppc/powermac.c')
-rw-r--r--sound/ppc/powermac.c159
1 files changed, 159 insertions, 0 deletions
diff --git a/sound/ppc/powermac.c b/sound/ppc/powermac.c
new file mode 100644
index 000000000000..8f1953a8e290
--- /dev/null
+++ b/sound/ppc/powermac.c
@@ -0,0 +1,159 @@
1/*
2 * Driver for PowerMac AWACS
3 * Copyright (c) 2001 by Takashi Iwai <tiwai@suse.de>
4 * based on dmasound.c.
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 */
20
21#include <sound/driver.h>
22#include <linux/init.h>
23#include <linux/moduleparam.h>
24#include <sound/core.h>
25#include <sound/initval.h>
26#include "pmac.h"
27#include "awacs.h"
28#include "burgundy.h"
29
30#define CHIP_NAME "PMac"
31
32MODULE_DESCRIPTION("PowerMac");
33MODULE_SUPPORTED_DEVICE("{{Apple,PowerMac}}");
34MODULE_LICENSE("GPL");
35
36static int index = SNDRV_DEFAULT_IDX1; /* Index 0-MAX */
37static char *id = SNDRV_DEFAULT_STR1; /* ID for this card */
38static int enable_beep = 1;
39
40module_param(index, int, 0444);
41MODULE_PARM_DESC(index, "Index value for " CHIP_NAME " soundchip.");
42module_param(id, charp, 0444);
43MODULE_PARM_DESC(id, "ID string for " CHIP_NAME " soundchip.");
44module_param(enable_beep, bool, 0444);
45MODULE_PARM_DESC(enable_beep, "Enable beep using PCM.");
46
47
48/*
49 * card entry
50 */
51
52static snd_card_t *snd_pmac_card = NULL;
53
54/*
55 */
56
57static int __init snd_pmac_probe(void)
58{
59 snd_card_t *card;
60 pmac_t *chip;
61 char *name_ext;
62 int err;
63
64 card = snd_card_new(index, id, THIS_MODULE, 0);
65 if (card == NULL)
66 return -ENOMEM;
67
68 if ((err = snd_pmac_new(card, &chip)) < 0)
69 goto __error;
70
71 switch (chip->model) {
72 case PMAC_BURGUNDY:
73 strcpy(card->driver, "PMac Burgundy");
74 strcpy(card->shortname, "PowerMac Burgundy");
75 sprintf(card->longname, "%s (Dev %d) Sub-frame %d",
76 card->shortname, chip->device_id, chip->subframe);
77 if ((err = snd_pmac_burgundy_init(chip)) < 0)
78 goto __error;
79 break;
80 case PMAC_DACA:
81 strcpy(card->driver, "PMac DACA");
82 strcpy(card->shortname, "PowerMac DACA");
83 sprintf(card->longname, "%s (Dev %d) Sub-frame %d",
84 card->shortname, chip->device_id, chip->subframe);
85 if ((err = snd_pmac_daca_init(chip)) < 0)
86 goto __error;
87 break;
88 case PMAC_TUMBLER:
89 case PMAC_SNAPPER:
90 name_ext = chip->model == PMAC_TUMBLER ? "Tumbler" : "Snapper";
91 sprintf(card->driver, "PMac %s", name_ext);
92 sprintf(card->shortname, "PowerMac %s", name_ext);
93 sprintf(card->longname, "%s (Dev %d) Sub-frame %d",
94 card->shortname, chip->device_id, chip->subframe);
95 if ( snd_pmac_tumbler_init(chip) < 0 || snd_pmac_tumbler_post_init() < 0)
96 goto __error;
97 break;
98 case PMAC_AWACS:
99 case PMAC_SCREAMER:
100 name_ext = chip->model == PMAC_SCREAMER ? "Screamer" : "AWACS";
101 sprintf(card->driver, "PMac %s", name_ext);
102 sprintf(card->shortname, "PowerMac %s", name_ext);
103 if (chip->is_pbook_3400)
104 name_ext = " [PB3400]";
105 else if (chip->is_pbook_G3)
106 name_ext = " [PBG3]";
107 else
108 name_ext = "";
109 sprintf(card->longname, "%s%s Rev %d",
110 card->shortname, name_ext, chip->revision);
111 if ((err = snd_pmac_awacs_init(chip)) < 0)
112 goto __error;
113 break;
114 default:
115 snd_printk("unsupported hardware %d\n", chip->model);
116 err = -EINVAL;
117 goto __error;
118 }
119
120 if ((err = snd_pmac_pcm_new(chip)) < 0)
121 goto __error;
122
123 chip->initialized = 1;
124 if (enable_beep)
125 snd_pmac_attach_beep(chip);
126
127 if ((err = snd_card_register(card)) < 0)
128 goto __error;
129
130 snd_pmac_card = card;
131 return 0;
132
133__error:
134 snd_card_free(card);
135 return err;
136}
137
138
139/*
140 * MODULE stuff
141 */
142
143static int __init alsa_card_pmac_init(void)
144{
145 int err;
146 if ((err = snd_pmac_probe()) < 0)
147 return err;
148 return 0;
149
150}
151
152static void __exit alsa_card_pmac_exit(void)
153{
154 if (snd_pmac_card)
155 snd_card_free(snd_pmac_card);
156}
157
158module_init(alsa_card_pmac_init)
159module_exit(alsa_card_pmac_exit)