blob: a6d8cbf4064f8a749880d756956a23979918ce1c [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001/*
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;
Benjamin Herrenschmidt1f7b49d2005-05-01 08:58:43 -070098 case PMAC_TOONIE:
99 strcpy(card->driver, "PMac Toonie");
100 strcpy(card->shortname, "PowerMac Toonie");
101 strcpy(card->longname, card->shortname);
102 if ((err = snd_pmac_toonie_init(chip)) < 0)
103 goto __error;
104 break;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700105 case PMAC_AWACS:
106 case PMAC_SCREAMER:
107 name_ext = chip->model == PMAC_SCREAMER ? "Screamer" : "AWACS";
108 sprintf(card->driver, "PMac %s", name_ext);
109 sprintf(card->shortname, "PowerMac %s", name_ext);
110 if (chip->is_pbook_3400)
111 name_ext = " [PB3400]";
112 else if (chip->is_pbook_G3)
113 name_ext = " [PBG3]";
114 else
115 name_ext = "";
116 sprintf(card->longname, "%s%s Rev %d",
117 card->shortname, name_ext, chip->revision);
118 if ((err = snd_pmac_awacs_init(chip)) < 0)
119 goto __error;
120 break;
121 default:
122 snd_printk("unsupported hardware %d\n", chip->model);
123 err = -EINVAL;
124 goto __error;
125 }
126
127 if ((err = snd_pmac_pcm_new(chip)) < 0)
128 goto __error;
129
130 chip->initialized = 1;
131 if (enable_beep)
132 snd_pmac_attach_beep(chip);
133
Takashi Iwai16dab542005-09-05 17:17:58 +0200134 if ((err = snd_card_set_generic_dev(card)) < 0)
135 goto __error;
136
Linus Torvalds1da177e2005-04-16 15:20:36 -0700137 if ((err = snd_card_register(card)) < 0)
138 goto __error;
139
140 snd_pmac_card = card;
141 return 0;
142
143__error:
144 snd_card_free(card);
145 return err;
146}
147
148
149/*
150 * MODULE stuff
151 */
152
153static int __init alsa_card_pmac_init(void)
154{
155 int err;
156 if ((err = snd_pmac_probe()) < 0)
157 return err;
158 return 0;
159
160}
161
162static void __exit alsa_card_pmac_exit(void)
163{
164 if (snd_pmac_card)
165 snd_card_free(snd_pmac_card);
166}
167
168module_init(alsa_card_pmac_init)
169module_exit(alsa_card_pmac_exit)