diff options
author | Linus Torvalds <torvalds@ppc970.osdl.org> | 2005-04-16 18:20:36 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@ppc970.osdl.org> | 2005-04-16 18:20:36 -0400 |
commit | 1da177e4c3f41524e886b7f1b8a0c1fc7321cac2 (patch) | |
tree | 0bba044c4ce775e45a88a51686b5d9f90697ea9d /sound/pci/vx222/vx222.c |
Linux-2.6.12-rc2v2.6.12-rc2
Initial git repository build. I'm not bothering with the full history,
even though we have it. We can create a separate "historical" git
archive of that later if we want to, and in the meantime it's about
3.2GB when imported into git - space that would just make the early
git days unnecessarily complicated, when we don't have a lot of good
infrastructure for it.
Let it rip!
Diffstat (limited to 'sound/pci/vx222/vx222.c')
-rw-r--r-- | sound/pci/vx222/vx222.c | 272 |
1 files changed, 272 insertions, 0 deletions
diff --git a/sound/pci/vx222/vx222.c b/sound/pci/vx222/vx222.c new file mode 100644 index 000000000000..4ffbb25658a5 --- /dev/null +++ b/sound/pci/vx222/vx222.c | |||
@@ -0,0 +1,272 @@ | |||
1 | /* | ||
2 | * Driver for Digigram VX222 V2/Mic PCI soundcards | ||
3 | * | ||
4 | * Copyright (c) 2002 by Takashi Iwai <tiwai@suse.de> | ||
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/interrupt.h> | ||
24 | #include <linux/pci.h> | ||
25 | #include <linux/slab.h> | ||
26 | #include <linux/moduleparam.h> | ||
27 | #include <sound/core.h> | ||
28 | #include <sound/initval.h> | ||
29 | #include "vx222.h" | ||
30 | |||
31 | #define CARD_NAME "VX222" | ||
32 | |||
33 | MODULE_AUTHOR("Takashi Iwai <tiwai@suse.de>"); | ||
34 | MODULE_DESCRIPTION("Digigram VX222 V2/Mic"); | ||
35 | MODULE_LICENSE("GPL"); | ||
36 | MODULE_SUPPORTED_DEVICE("{{Digigram," CARD_NAME "}}"); | ||
37 | |||
38 | static int index[SNDRV_CARDS] = SNDRV_DEFAULT_IDX; /* Index 0-MAX */ | ||
39 | static char *id[SNDRV_CARDS] = SNDRV_DEFAULT_STR; /* ID for this card */ | ||
40 | static int enable[SNDRV_CARDS] = SNDRV_DEFAULT_ENABLE_PNP; /* Enable this card */ | ||
41 | static int mic[SNDRV_CARDS]; /* microphone */ | ||
42 | static int ibl[SNDRV_CARDS]; /* microphone */ | ||
43 | |||
44 | module_param_array(index, int, NULL, 0444); | ||
45 | MODULE_PARM_DESC(index, "Index value for Digigram " CARD_NAME " soundcard."); | ||
46 | module_param_array(id, charp, NULL, 0444); | ||
47 | MODULE_PARM_DESC(id, "ID string for Digigram " CARD_NAME " soundcard."); | ||
48 | module_param_array(enable, bool, NULL, 0444); | ||
49 | MODULE_PARM_DESC(enable, "Enable Digigram " CARD_NAME " soundcard."); | ||
50 | module_param_array(mic, bool, NULL, 0444); | ||
51 | MODULE_PARM_DESC(mic, "Enable Microphone."); | ||
52 | module_param_array(ibl, int, NULL, 0444); | ||
53 | MODULE_PARM_DESC(ibl, "Capture IBL size."); | ||
54 | |||
55 | /* | ||
56 | */ | ||
57 | |||
58 | enum { | ||
59 | VX_PCI_VX222_OLD, | ||
60 | VX_PCI_VX222_NEW | ||
61 | }; | ||
62 | |||
63 | static struct pci_device_id snd_vx222_ids[] = { | ||
64 | { 0x10b5, 0x9050, 0x1369, PCI_ANY_ID, 0, 0, VX_PCI_VX222_OLD, }, /* PLX */ | ||
65 | { 0x10b5, 0x9030, 0x1369, PCI_ANY_ID, 0, 0, VX_PCI_VX222_NEW, }, /* PLX */ | ||
66 | { 0, } | ||
67 | }; | ||
68 | |||
69 | MODULE_DEVICE_TABLE(pci, snd_vx222_ids); | ||
70 | |||
71 | |||
72 | /* | ||
73 | */ | ||
74 | |||
75 | static struct snd_vx_hardware vx222_old_hw = { | ||
76 | |||
77 | .name = "VX222/Old", | ||
78 | .type = VX_TYPE_BOARD, | ||
79 | /* hw specs */ | ||
80 | .num_codecs = 1, | ||
81 | .num_ins = 1, | ||
82 | .num_outs = 1, | ||
83 | .output_level_max = VX_ANALOG_OUT_LEVEL_MAX, | ||
84 | }; | ||
85 | |||
86 | static struct snd_vx_hardware vx222_v2_hw = { | ||
87 | |||
88 | .name = "VX222/v2", | ||
89 | .type = VX_TYPE_V2, | ||
90 | /* hw specs */ | ||
91 | .num_codecs = 1, | ||
92 | .num_ins = 1, | ||
93 | .num_outs = 1, | ||
94 | .output_level_max = VX2_AKM_LEVEL_MAX, | ||
95 | }; | ||
96 | |||
97 | static struct snd_vx_hardware vx222_mic_hw = { | ||
98 | |||
99 | .name = "VX222/Mic", | ||
100 | .type = VX_TYPE_MIC, | ||
101 | /* hw specs */ | ||
102 | .num_codecs = 1, | ||
103 | .num_ins = 1, | ||
104 | .num_outs = 1, | ||
105 | .output_level_max = VX2_AKM_LEVEL_MAX, | ||
106 | }; | ||
107 | |||
108 | |||
109 | /* | ||
110 | */ | ||
111 | static int snd_vx222_free(vx_core_t *chip) | ||
112 | { | ||
113 | struct snd_vx222 *vx = (struct snd_vx222 *)chip; | ||
114 | |||
115 | if (chip->irq >= 0) | ||
116 | free_irq(chip->irq, (void*)chip); | ||
117 | if (vx->port[0]) | ||
118 | pci_release_regions(vx->pci); | ||
119 | pci_disable_device(vx->pci); | ||
120 | kfree(chip); | ||
121 | return 0; | ||
122 | } | ||
123 | |||
124 | static int snd_vx222_dev_free(snd_device_t *device) | ||
125 | { | ||
126 | vx_core_t *chip = device->device_data; | ||
127 | return snd_vx222_free(chip); | ||
128 | } | ||
129 | |||
130 | |||
131 | static int __devinit snd_vx222_create(snd_card_t *card, struct pci_dev *pci, | ||
132 | struct snd_vx_hardware *hw, | ||
133 | struct snd_vx222 **rchip) | ||
134 | { | ||
135 | vx_core_t *chip; | ||
136 | struct snd_vx222 *vx; | ||
137 | int i, err; | ||
138 | static snd_device_ops_t ops = { | ||
139 | .dev_free = snd_vx222_dev_free, | ||
140 | }; | ||
141 | struct snd_vx_ops *vx_ops; | ||
142 | |||
143 | /* enable PCI device */ | ||
144 | if ((err = pci_enable_device(pci)) < 0) | ||
145 | return err; | ||
146 | pci_set_master(pci); | ||
147 | |||
148 | vx_ops = hw->type == VX_TYPE_BOARD ? &vx222_old_ops : &vx222_ops; | ||
149 | chip = snd_vx_create(card, hw, vx_ops, | ||
150 | sizeof(struct snd_vx222) - sizeof(vx_core_t)); | ||
151 | if (! chip) { | ||
152 | pci_disable_device(pci); | ||
153 | return -ENOMEM; | ||
154 | } | ||
155 | vx = (struct snd_vx222 *)chip; | ||
156 | vx->pci = pci; | ||
157 | |||
158 | if ((err = pci_request_regions(pci, CARD_NAME)) < 0) { | ||
159 | snd_vx222_free(chip); | ||
160 | return err; | ||
161 | } | ||
162 | for (i = 0; i < 2; i++) | ||
163 | vx->port[i] = pci_resource_start(pci, i + 1); | ||
164 | |||
165 | if (request_irq(pci->irq, snd_vx_irq_handler, SA_INTERRUPT|SA_SHIRQ, | ||
166 | CARD_NAME, (void *) chip)) { | ||
167 | snd_printk(KERN_ERR "unable to grab IRQ %d\n", pci->irq); | ||
168 | snd_vx222_free(chip); | ||
169 | return -EBUSY; | ||
170 | } | ||
171 | chip->irq = pci->irq; | ||
172 | |||
173 | if ((err = snd_device_new(card, SNDRV_DEV_LOWLEVEL, chip, &ops)) < 0) { | ||
174 | snd_vx222_free(chip); | ||
175 | return err; | ||
176 | } | ||
177 | |||
178 | snd_card_set_dev(card, &pci->dev); | ||
179 | |||
180 | *rchip = vx; | ||
181 | return 0; | ||
182 | } | ||
183 | |||
184 | |||
185 | static int __devinit snd_vx222_probe(struct pci_dev *pci, | ||
186 | const struct pci_device_id *pci_id) | ||
187 | { | ||
188 | static int dev; | ||
189 | snd_card_t *card; | ||
190 | struct snd_vx_hardware *hw; | ||
191 | struct snd_vx222 *vx; | ||
192 | int err; | ||
193 | |||
194 | if (dev >= SNDRV_CARDS) | ||
195 | return -ENODEV; | ||
196 | if (!enable[dev]) { | ||
197 | dev++; | ||
198 | return -ENOENT; | ||
199 | } | ||
200 | |||
201 | card = snd_card_new(index[dev], id[dev], THIS_MODULE, 0); | ||
202 | if (card == NULL) | ||
203 | return -ENOMEM; | ||
204 | |||
205 | switch ((int)pci_id->driver_data) { | ||
206 | case VX_PCI_VX222_OLD: | ||
207 | hw = &vx222_old_hw; | ||
208 | break; | ||
209 | case VX_PCI_VX222_NEW: | ||
210 | default: | ||
211 | if (mic[dev]) | ||
212 | hw = &vx222_mic_hw; | ||
213 | else | ||
214 | hw = &vx222_v2_hw; | ||
215 | break; | ||
216 | } | ||
217 | if ((err = snd_vx222_create(card, pci, hw, &vx)) < 0) { | ||
218 | snd_card_free(card); | ||
219 | return err; | ||
220 | } | ||
221 | vx->core.ibl.size = ibl[dev]; | ||
222 | |||
223 | sprintf(card->longname, "%s at 0x%lx & 0x%lx, irq %i", | ||
224 | card->shortname, vx->port[0], vx->port[1], vx->core.irq); | ||
225 | snd_printdd("%s at 0x%lx & 0x%lx, irq %i\n", | ||
226 | card->shortname, vx->port[0], vx->port[1], vx->core.irq); | ||
227 | |||
228 | #ifdef SND_VX_FW_LOADER | ||
229 | vx->core.dev = &pci->dev; | ||
230 | #endif | ||
231 | |||
232 | if ((err = snd_vx_setup_firmware(&vx->core)) < 0) { | ||
233 | snd_card_free(card); | ||
234 | return err; | ||
235 | } | ||
236 | |||
237 | if ((err = snd_card_register(card)) < 0) { | ||
238 | snd_card_free(card); | ||
239 | return err; | ||
240 | } | ||
241 | |||
242 | pci_set_drvdata(pci, card); | ||
243 | dev++; | ||
244 | return 0; | ||
245 | } | ||
246 | |||
247 | static void __devexit snd_vx222_remove(struct pci_dev *pci) | ||
248 | { | ||
249 | snd_card_free(pci_get_drvdata(pci)); | ||
250 | pci_set_drvdata(pci, NULL); | ||
251 | } | ||
252 | |||
253 | static struct pci_driver driver = { | ||
254 | .name = "Digigram VX222", | ||
255 | .id_table = snd_vx222_ids, | ||
256 | .probe = snd_vx222_probe, | ||
257 | .remove = __devexit_p(snd_vx222_remove), | ||
258 | SND_PCI_PM_CALLBACKS | ||
259 | }; | ||
260 | |||
261 | static int __init alsa_card_vx222_init(void) | ||
262 | { | ||
263 | return pci_module_init(&driver); | ||
264 | } | ||
265 | |||
266 | static void __exit alsa_card_vx222_exit(void) | ||
267 | { | ||
268 | pci_unregister_driver(&driver); | ||
269 | } | ||
270 | |||
271 | module_init(alsa_card_vx222_init) | ||
272 | module_exit(alsa_card_vx222_exit) | ||