[PATCH] w1_therm: removed duplicated family id.
[linux-2.6/verdex.git] / sound / ppc / powermac.c
blob231f6432ea6d08bb27023c8423860b9b2e0ac03d
1 /*
2 * Driver for PowerMac AWACS
3 * Copyright (c) 2001 by Takashi Iwai <tiwai@suse.de>
4 * based on dmasound.c.
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.
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.
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
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"
30 #define CHIP_NAME "PMac"
32 MODULE_DESCRIPTION("PowerMac");
33 MODULE_SUPPORTED_DEVICE("{{Apple,PowerMac}}");
34 MODULE_LICENSE("GPL");
36 static int index = SNDRV_DEFAULT_IDX1; /* Index 0-MAX */
37 static char *id = SNDRV_DEFAULT_STR1; /* ID for this card */
38 static int enable_beep = 1;
40 module_param(index, int, 0444);
41 MODULE_PARM_DESC(index, "Index value for " CHIP_NAME " soundchip.");
42 module_param(id, charp, 0444);
43 MODULE_PARM_DESC(id, "ID string for " CHIP_NAME " soundchip.");
44 module_param(enable_beep, bool, 0444);
45 MODULE_PARM_DESC(enable_beep, "Enable beep using PCM.");
49 * card entry
52 static snd_card_t *snd_pmac_card = NULL;
57 static int __init snd_pmac_probe(void)
59 snd_card_t *card;
60 pmac_t *chip;
61 char *name_ext;
62 int err;
64 card = snd_card_new(index, id, THIS_MODULE, 0);
65 if (card == NULL)
66 return -ENOMEM;
68 if ((err = snd_pmac_new(card, &chip)) < 0)
69 goto __error;
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_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;
105 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;
127 if ((err = snd_pmac_pcm_new(chip)) < 0)
128 goto __error;
130 chip->initialized = 1;
131 if (enable_beep)
132 snd_pmac_attach_beep(chip);
134 if ((err = snd_card_register(card)) < 0)
135 goto __error;
137 snd_pmac_card = card;
138 return 0;
140 __error:
141 snd_card_free(card);
142 return err;
147 * MODULE stuff
150 static int __init alsa_card_pmac_init(void)
152 int err;
153 if ((err = snd_pmac_probe()) < 0)
154 return err;
155 return 0;
159 static void __exit alsa_card_pmac_exit(void)
161 if (snd_pmac_card)
162 snd_card_free(snd_pmac_card);
165 module_init(alsa_card_pmac_init)
166 module_exit(alsa_card_pmac_exit)