Commit | Line | Data |
---|---|---|
1da177e4 LT |
1 | /* |
2 | * Copyright (c) 2004 James Courtier-Dutton <James@superbug.demon.co.uk> | |
3 | * Driver CA0106 chips. e.g. Sound Blaster Audigy LS and Live 24bit | |
7199acdc | 4 | * Version: 0.0.23 |
1da177e4 LT |
5 | * |
6 | * FEATURES currently supported: | |
7 | * Front, Rear and Center/LFE. | |
8 | * Surround40 and Surround51. | |
9 | * Capture from MIC an LINE IN input. | |
10 | * SPDIF digital playback of PCM stereo and AC3/DTS works. | |
11 | * (One can use a standard mono mini-jack to one RCA plugs cable. | |
12 | * or one can use a standard stereo mini-jack to two RCA plugs cable. | |
13 | * Plug one of the RCA plugs into the Coax input of the external decoder/receiver.) | |
14 | * ( In theory one could output 3 different AC3 streams at once, to 3 different SPDIF outputs. ) | |
15 | * Notes on how to capture sound: | |
16 | * The AC97 is used in the PLAYBACK direction. | |
17 | * The output from the AC97 chip, instead of reaching the speakers, is fed into the Philips 1361T ADC. | |
18 | * So, to record from the MIC, set the MIC Playback volume to max, | |
19 | * unmute the MIC and turn up the MASTER Playback volume. | |
20 | * So, to prevent feedback when capturing, minimise the "Capture feedback into Playback" volume. | |
21 | * | |
22 | * The only playback controls that currently do anything are: - | |
23 | * Analog Front | |
24 | * Analog Rear | |
25 | * Analog Center/LFE | |
26 | * SPDIF Front | |
27 | * SPDIF Rear | |
28 | * SPDIF Center/LFE | |
29 | * | |
30 | * For capture from Mic in or Line in. | |
31 | * Digital/Analog ( switch must be in Analog mode for CAPTURE. ) | |
32 | * | |
33 | * CAPTURE feedback into PLAYBACK | |
34 | * | |
35 | * Changelog: | |
36 | * Support interrupts per period. | |
37 | * Removed noise from Center/LFE channel when in Analog mode. | |
38 | * Rename and remove mixer controls. | |
39 | * 0.0.6 | |
40 | * Use separate card based DMA buffer for periods table list. | |
41 | * 0.0.7 | |
42 | * Change remove and rename ctrls into lists. | |
43 | * 0.0.8 | |
44 | * Try to fix capture sources. | |
45 | * 0.0.9 | |
46 | * Fix AC3 output. | |
47 | * Enable S32_LE format support. | |
48 | * 0.0.10 | |
49 | * Enable playback 48000 and 96000 rates. (Rates other that these do not work, even with "plug:front".) | |
50 | * 0.0.11 | |
51 | * Add Model name recognition. | |
52 | * 0.0.12 | |
53 | * Correct interrupt timing. interrupt at end of period, instead of in the middle of a playback period. | |
54 | * Remove redundent "voice" handling. | |
55 | * 0.0.13 | |
56 | * Single trigger call for multi channels. | |
57 | * 0.0.14 | |
58 | * Set limits based on what the sound card hardware can do. | |
59 | * playback periods_min=2, periods_max=8 | |
60 | * capture hw constraints require period_size = n * 64 bytes. | |
61 | * playback hw constraints require period_size = n * 64 bytes. | |
62 | * 0.0.15 | |
63 | * Minor updates. | |
64 | * 0.0.16 | |
65 | * Implement 192000 sample rate. | |
66 | * 0.0.17 | |
67 | * Add support for SB0410 and SB0413. | |
68 | * 0.0.18 | |
69 | * Modified Copyright message. | |
70 | * 0.0.19 | |
71 | * Finally fix support for SB Live 24 bit. SB0410 and SB0413. | |
72 | * The output codec needs resetting, otherwise all output is muted. | |
73 | * 0.0.20 | |
74 | * Merge "pci_disable_device(pci);" fixes. | |
75 | * 0.0.21 | |
76 | * Add 4 capture channels. (SPDIF only comes in on channel 0. ) | |
77 | * Add SPDIF capture using optional digital I/O module for SB Live 24bit. (Analog capture does not yet work.) | |
78 | * 0.0.22 | |
79 | * Add support for MSI K8N Diamond Motherboard with onboard SB Live 24bit without AC97. From kiksen, bug #901 | |
7199acdc JCD |
80 | * 0.0.23 |
81 | * Implement support for Line-in capture on SB Live 24bit. | |
1da177e4 LT |
82 | * |
83 | * BUGS: | |
84 | * Some stability problems when unloading the snd-ca0106 kernel module. | |
85 | * -- | |
86 | * | |
87 | * TODO: | |
88 | * 4 Capture channels, only one implemented so far. | |
89 | * Other capture rates apart from 48khz not implemented. | |
90 | * MIDI | |
91 | * -- | |
92 | * GENERAL INFO: | |
93 | * Model: SB0310 | |
94 | * P17 Chip: CA0106-DAT | |
95 | * AC97 Codec: STAC 9721 | |
96 | * ADC: Philips 1361T (Stereo 24bit) | |
97 | * DAC: WM8746EDS (6-channel, 24bit, 192Khz) | |
98 | * | |
99 | * GENERAL INFO: | |
100 | * Model: SB0410 | |
101 | * P17 Chip: CA0106-DAT | |
102 | * AC97 Codec: None | |
103 | * ADC: WM8775EDS (4 Channel) | |
104 | * DAC: CS4382 (114 dB, 24-Bit, 192 kHz, 8-Channel D/A Converter with DSD Support) | |
105 | * SPDIF Out control switches between Mic in and SPDIF out. | |
106 | * No sound out or mic input working yet. | |
107 | * | |
108 | * GENERAL INFO: | |
109 | * Model: SB0413 | |
110 | * P17 Chip: CA0106-DAT | |
111 | * AC97 Codec: None. | |
112 | * ADC: Unknown | |
113 | * DAC: Unknown | |
114 | * Trying to handle it like the SB0410. | |
115 | * | |
116 | * This code was initally based on code from ALSA's emu10k1x.c which is: | |
117 | * Copyright (c) by Francisco Moraes <fmoraes@nc.rr.com> | |
118 | * | |
119 | * This program is free software; you can redistribute it and/or modify | |
120 | * it under the terms of the GNU General Public License as published by | |
121 | * the Free Software Foundation; either version 2 of the License, or | |
122 | * (at your option) any later version. | |
123 | * | |
124 | * This program is distributed in the hope that it will be useful, | |
125 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
126 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
127 | * GNU General Public License for more details. | |
128 | * | |
129 | * You should have received a copy of the GNU General Public License | |
130 | * along with this program; if not, write to the Free Software | |
131 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | |
132 | * | |
133 | */ | |
134 | #include <sound/driver.h> | |
135 | #include <linux/delay.h> | |
136 | #include <linux/init.h> | |
137 | #include <linux/interrupt.h> | |
138 | #include <linux/pci.h> | |
139 | #include <linux/slab.h> | |
140 | #include <linux/moduleparam.h> | |
141 | #include <sound/core.h> | |
142 | #include <sound/initval.h> | |
143 | #include <sound/pcm.h> | |
144 | #include <sound/ac97_codec.h> | |
145 | #include <sound/info.h> | |
146 | ||
147 | MODULE_AUTHOR("James Courtier-Dutton <James@superbug.demon.co.uk>"); | |
148 | MODULE_DESCRIPTION("CA0106"); | |
149 | MODULE_LICENSE("GPL"); | |
150 | MODULE_SUPPORTED_DEVICE("{{Creative,SB CA0106 chip}}"); | |
151 | ||
152 | // module parameters (see "Module Parameters") | |
153 | static int index[SNDRV_CARDS] = SNDRV_DEFAULT_IDX; | |
154 | static char *id[SNDRV_CARDS] = SNDRV_DEFAULT_STR; | |
155 | static int enable[SNDRV_CARDS] = SNDRV_DEFAULT_ENABLE_PNP; | |
156 | ||
157 | module_param_array(index, int, NULL, 0444); | |
158 | MODULE_PARM_DESC(index, "Index value for the CA0106 soundcard."); | |
159 | module_param_array(id, charp, NULL, 0444); | |
160 | MODULE_PARM_DESC(id, "ID string for the CA0106 soundcard."); | |
161 | module_param_array(enable, bool, NULL, 0444); | |
162 | MODULE_PARM_DESC(enable, "Enable the CA0106 soundcard."); | |
163 | ||
164 | #include "ca0106.h" | |
165 | ||
1baa705b JCD |
166 | static ca0106_details_t ca0106_chip_details[] = { |
167 | /* AudigyLS[SB0310] */ | |
168 | { .serial = 0x10021102, | |
169 | .name = "AudigyLS [SB0310]", | |
170 | .ac97 = 1 } , | |
171 | /* Unknown AudigyLS that also says SB0310 on it */ | |
172 | { .serial = 0x10051102, | |
173 | .name = "AudigyLS [SB0310b]", | |
174 | .ac97 = 1 } , | |
175 | /* New Sound Blaster Live! 7.1 24bit. This does not have an AC97. 53SB041000001 */ | |
176 | { .serial = 0x10061102, | |
177 | .name = "Live! 7.1 24bit [SB0410]", | |
7199acdc JCD |
178 | .gpio_type = 1, |
179 | .i2c_adc = 1 } , | |
1baa705b JCD |
180 | /* New Dell Sound Blaster Live! 7.1 24bit. This does not have an AC97. */ |
181 | { .serial = 0x10071102, | |
182 | .name = "Live! 7.1 24bit [SB0413]", | |
7199acdc JCD |
183 | .gpio_type = 1, |
184 | .i2c_adc = 1 } , | |
1baa705b JCD |
185 | /* MSI K8N Diamond Motherboard with onboard SB Live 24bit without AC97 */ |
186 | { .serial = 0x10091462, | |
187 | .name = "MSI K8N Diamond MB [SB0438]", | |
7199acdc JCD |
188 | .gpio_type = 1, |
189 | .i2c_adc = 1 } , | |
1baa705b JCD |
190 | { .serial = 0, |
191 | .name = "AudigyLS [Unknown]" } | |
1da177e4 LT |
192 | }; |
193 | ||
194 | /* hardware definition */ | |
195 | static snd_pcm_hardware_t snd_ca0106_playback_hw = { | |
196 | .info = (SNDRV_PCM_INFO_MMAP | | |
197 | SNDRV_PCM_INFO_INTERLEAVED | | |
198 | SNDRV_PCM_INFO_BLOCK_TRANSFER | | |
199 | SNDRV_PCM_INFO_MMAP_VALID), | |
200 | .formats = SNDRV_PCM_FMTBIT_S16_LE | SNDRV_PCM_FMTBIT_S32_LE, | |
201 | .rates = SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_96000 | SNDRV_PCM_RATE_192000, | |
202 | .rate_min = 48000, | |
203 | .rate_max = 192000, | |
204 | .channels_min = 2, //1, | |
205 | .channels_max = 2, //6, | |
206 | .buffer_bytes_max = ((65536 - 64) * 8), | |
207 | .period_bytes_min = 64, | |
208 | .period_bytes_max = (65536 - 64), | |
209 | .periods_min = 2, | |
210 | .periods_max = 8, | |
211 | .fifo_size = 0, | |
212 | }; | |
213 | ||
214 | static snd_pcm_hardware_t snd_ca0106_capture_hw = { | |
215 | .info = (SNDRV_PCM_INFO_MMAP | | |
216 | SNDRV_PCM_INFO_INTERLEAVED | | |
217 | SNDRV_PCM_INFO_BLOCK_TRANSFER | | |
218 | SNDRV_PCM_INFO_MMAP_VALID), | |
219 | .formats = SNDRV_PCM_FMTBIT_S16_LE, | |
220 | .rates = SNDRV_PCM_RATE_48000, | |
221 | .rate_min = 48000, | |
222 | .rate_max = 48000, | |
223 | .channels_min = 2, | |
224 | .channels_max = 2, | |
225 | .buffer_bytes_max = ((65536 - 64) * 8), | |
226 | .period_bytes_min = 64, | |
227 | .period_bytes_max = (65536 - 64), | |
228 | .periods_min = 2, | |
229 | .periods_max = 2, | |
230 | .fifo_size = 0, | |
231 | }; | |
232 | ||
233 | unsigned int snd_ca0106_ptr_read(ca0106_t * emu, | |
234 | unsigned int reg, | |
235 | unsigned int chn) | |
236 | { | |
237 | unsigned long flags; | |
238 | unsigned int regptr, val; | |
239 | ||
240 | regptr = (reg << 16) | chn; | |
241 | ||
242 | spin_lock_irqsave(&emu->emu_lock, flags); | |
243 | outl(regptr, emu->port + PTR); | |
244 | val = inl(emu->port + DATA); | |
245 | spin_unlock_irqrestore(&emu->emu_lock, flags); | |
246 | return val; | |
247 | } | |
248 | ||
249 | void snd_ca0106_ptr_write(ca0106_t *emu, | |
250 | unsigned int reg, | |
251 | unsigned int chn, | |
252 | unsigned int data) | |
253 | { | |
254 | unsigned int regptr; | |
255 | unsigned long flags; | |
256 | ||
257 | regptr = (reg << 16) | chn; | |
258 | ||
259 | spin_lock_irqsave(&emu->emu_lock, flags); | |
260 | outl(regptr, emu->port + PTR); | |
261 | outl(data, emu->port + DATA); | |
262 | spin_unlock_irqrestore(&emu->emu_lock, flags); | |
263 | } | |
264 | ||
7199acdc JCD |
265 | int snd_ca0106_i2c_write(ca0106_t *emu, |
266 | u32 reg, | |
267 | u32 value) | |
268 | { | |
269 | u32 tmp; | |
270 | int timeout=0; | |
271 | int status; | |
272 | int retry; | |
273 | if ((reg > 0x7f) || (value > 0x1ff)) | |
274 | { | |
275 | snd_printk("i2c_write: invalid values.\n"); | |
276 | return -EINVAL; | |
277 | } | |
278 | ||
279 | tmp = reg << 25 | value << 16; | |
280 | snd_ca0106_ptr_write(emu, I2C_D0, 0, tmp); | |
281 | snd_ca0106_ptr_write(emu, I2C_D1, 0, tmp); | |
282 | ||
283 | for(retry=0;retry<10;retry++) | |
284 | { | |
285 | /* Send the data to i2c */ | |
286 | tmp = snd_ca0106_ptr_read(emu, I2C_A, 0); | |
287 | tmp = tmp & ~(I2C_A_ADC_READ|I2C_A_ADC_LAST|I2C_A_ADC_START|I2C_A_ADC_ADD_MASK); | |
288 | tmp = tmp | (I2C_A_ADC_LAST|I2C_A_ADC_START|I2C_A_ADC_ADD); | |
289 | snd_ca0106_ptr_write(emu, I2C_A, 0, tmp); | |
290 | ||
291 | /* Wait till the transaction ends */ | |
292 | while(1) | |
293 | { | |
294 | status = snd_ca0106_ptr_read(emu, I2C_A, 0); | |
295 | //snd_printk("I2C:status=0x%x\n", status); | |
296 | timeout++; | |
297 | if((status & I2C_A_ADC_START)==0) | |
298 | break; | |
299 | ||
300 | if(timeout>1000) | |
301 | break; | |
302 | } | |
303 | //Read back and see if the transaction is successful | |
304 | if((status & I2C_A_ADC_ABORT)==0) | |
305 | break; | |
306 | } | |
307 | ||
308 | if(retry==10) | |
309 | { | |
310 | snd_printk("Writing to ADC failed!\n"); | |
311 | return -EINVAL; | |
312 | } | |
313 | ||
314 | return 0; | |
315 | } | |
316 | ||
317 | ||
1da177e4 LT |
318 | static void snd_ca0106_intr_enable(ca0106_t *emu, unsigned int intrenb) |
319 | { | |
320 | unsigned long flags; | |
321 | unsigned int enable; | |
322 | ||
323 | spin_lock_irqsave(&emu->emu_lock, flags); | |
324 | enable = inl(emu->port + INTE) | intrenb; | |
325 | outl(enable, emu->port + INTE); | |
326 | spin_unlock_irqrestore(&emu->emu_lock, flags); | |
327 | } | |
328 | ||
329 | static void snd_ca0106_pcm_free_substream(snd_pcm_runtime_t *runtime) | |
330 | { | |
331 | ca0106_pcm_t *epcm = runtime->private_data; | |
332 | ||
333 | if (epcm) { | |
334 | kfree(epcm); | |
335 | } | |
336 | } | |
337 | ||
338 | /* open_playback callback */ | |
339 | static int snd_ca0106_pcm_open_playback_channel(snd_pcm_substream_t *substream, int channel_id) | |
340 | { | |
341 | ca0106_t *chip = snd_pcm_substream_chip(substream); | |
342 | ca0106_channel_t *channel = &(chip->playback_channels[channel_id]); | |
343 | ca0106_pcm_t *epcm; | |
344 | snd_pcm_runtime_t *runtime = substream->runtime; | |
345 | int err; | |
346 | ||
347 | epcm = kcalloc(1, sizeof(*epcm), GFP_KERNEL); | |
348 | ||
349 | if (epcm == NULL) | |
350 | return -ENOMEM; | |
351 | epcm->emu = chip; | |
352 | epcm->substream = substream; | |
353 | epcm->channel_id=channel_id; | |
354 | ||
355 | runtime->private_data = epcm; | |
356 | runtime->private_free = snd_ca0106_pcm_free_substream; | |
357 | ||
358 | runtime->hw = snd_ca0106_playback_hw; | |
359 | ||
360 | channel->emu = chip; | |
361 | channel->number = channel_id; | |
362 | ||
363 | channel->use=1; | |
364 | //printk("open:channel_id=%d, chip=%p, channel=%p\n",channel_id, chip, channel); | |
365 | //channel->interrupt = snd_ca0106_pcm_channel_interrupt; | |
366 | channel->epcm=epcm; | |
367 | if ((err = snd_pcm_hw_constraint_integer(runtime, SNDRV_PCM_HW_PARAM_PERIODS)) < 0) | |
368 | return err; | |
369 | if ((err = snd_pcm_hw_constraint_step(runtime, 0, SNDRV_PCM_HW_PARAM_PERIOD_BYTES, 64)) < 0) | |
370 | return err; | |
371 | return 0; | |
372 | } | |
373 | ||
374 | /* close callback */ | |
375 | static int snd_ca0106_pcm_close_playback(snd_pcm_substream_t *substream) | |
376 | { | |
377 | ca0106_t *chip = snd_pcm_substream_chip(substream); | |
378 | snd_pcm_runtime_t *runtime = substream->runtime; | |
379 | ca0106_pcm_t *epcm = runtime->private_data; | |
380 | chip->playback_channels[epcm->channel_id].use=0; | |
381 | /* FIXME: maybe zero others */ | |
382 | return 0; | |
383 | } | |
384 | ||
385 | static int snd_ca0106_pcm_open_playback_front(snd_pcm_substream_t *substream) | |
386 | { | |
387 | return snd_ca0106_pcm_open_playback_channel(substream, PCM_FRONT_CHANNEL); | |
388 | } | |
389 | ||
390 | static int snd_ca0106_pcm_open_playback_center_lfe(snd_pcm_substream_t *substream) | |
391 | { | |
392 | return snd_ca0106_pcm_open_playback_channel(substream, PCM_CENTER_LFE_CHANNEL); | |
393 | } | |
394 | ||
395 | static int snd_ca0106_pcm_open_playback_unknown(snd_pcm_substream_t *substream) | |
396 | { | |
397 | return snd_ca0106_pcm_open_playback_channel(substream, PCM_UNKNOWN_CHANNEL); | |
398 | } | |
399 | ||
400 | static int snd_ca0106_pcm_open_playback_rear(snd_pcm_substream_t *substream) | |
401 | { | |
402 | return snd_ca0106_pcm_open_playback_channel(substream, PCM_REAR_CHANNEL); | |
403 | } | |
404 | ||
405 | /* open_capture callback */ | |
406 | static int snd_ca0106_pcm_open_capture_channel(snd_pcm_substream_t *substream, int channel_id) | |
407 | { | |
408 | ca0106_t *chip = snd_pcm_substream_chip(substream); | |
409 | ca0106_channel_t *channel = &(chip->capture_channels[channel_id]); | |
410 | ca0106_pcm_t *epcm; | |
411 | snd_pcm_runtime_t *runtime = substream->runtime; | |
412 | int err; | |
413 | ||
414 | epcm = kcalloc(1, sizeof(*epcm), GFP_KERNEL); | |
415 | if (epcm == NULL) { | |
416 | snd_printk("open_capture_channel: failed epcm alloc\n"); | |
417 | return -ENOMEM; | |
418 | } | |
419 | epcm->emu = chip; | |
420 | epcm->substream = substream; | |
421 | epcm->channel_id=channel_id; | |
422 | ||
423 | runtime->private_data = epcm; | |
424 | runtime->private_free = snd_ca0106_pcm_free_substream; | |
425 | ||
426 | runtime->hw = snd_ca0106_capture_hw; | |
427 | ||
428 | channel->emu = chip; | |
429 | channel->number = channel_id; | |
430 | ||
431 | channel->use=1; | |
432 | //printk("open:channel_id=%d, chip=%p, channel=%p\n",channel_id, chip, channel); | |
433 | //channel->interrupt = snd_ca0106_pcm_channel_interrupt; | |
434 | channel->epcm=epcm; | |
435 | if ((err = snd_pcm_hw_constraint_integer(runtime, SNDRV_PCM_HW_PARAM_PERIODS)) < 0) | |
436 | return err; | |
437 | //snd_pcm_hw_constraint_list(runtime, 0, SNDRV_PCM_HW_PARAM_PERIOD_SIZE, &hw_constraints_capture_period_sizes); | |
438 | if ((err = snd_pcm_hw_constraint_step(runtime, 0, SNDRV_PCM_HW_PARAM_PERIOD_BYTES, 64)) < 0) | |
439 | return err; | |
440 | return 0; | |
441 | } | |
442 | ||
443 | /* close callback */ | |
444 | static int snd_ca0106_pcm_close_capture(snd_pcm_substream_t *substream) | |
445 | { | |
446 | ca0106_t *chip = snd_pcm_substream_chip(substream); | |
447 | snd_pcm_runtime_t *runtime = substream->runtime; | |
448 | ca0106_pcm_t *epcm = runtime->private_data; | |
449 | chip->capture_channels[epcm->channel_id].use=0; | |
450 | /* FIXME: maybe zero others */ | |
451 | return 0; | |
452 | } | |
453 | ||
454 | static int snd_ca0106_pcm_open_0_capture(snd_pcm_substream_t *substream) | |
455 | { | |
456 | return snd_ca0106_pcm_open_capture_channel(substream, 0); | |
457 | } | |
458 | ||
459 | static int snd_ca0106_pcm_open_1_capture(snd_pcm_substream_t *substream) | |
460 | { | |
461 | return snd_ca0106_pcm_open_capture_channel(substream, 1); | |
462 | } | |
463 | ||
464 | static int snd_ca0106_pcm_open_2_capture(snd_pcm_substream_t *substream) | |
465 | { | |
466 | return snd_ca0106_pcm_open_capture_channel(substream, 2); | |
467 | } | |
468 | ||
469 | static int snd_ca0106_pcm_open_3_capture(snd_pcm_substream_t *substream) | |
470 | { | |
471 | return snd_ca0106_pcm_open_capture_channel(substream, 3); | |
472 | } | |
473 | ||
474 | /* hw_params callback */ | |
475 | static int snd_ca0106_pcm_hw_params_playback(snd_pcm_substream_t *substream, | |
476 | snd_pcm_hw_params_t * hw_params) | |
477 | { | |
478 | return snd_pcm_lib_malloc_pages(substream, | |
479 | params_buffer_bytes(hw_params)); | |
480 | } | |
481 | ||
482 | /* hw_free callback */ | |
483 | static int snd_ca0106_pcm_hw_free_playback(snd_pcm_substream_t *substream) | |
484 | { | |
485 | return snd_pcm_lib_free_pages(substream); | |
486 | } | |
487 | ||
488 | /* hw_params callback */ | |
489 | static int snd_ca0106_pcm_hw_params_capture(snd_pcm_substream_t *substream, | |
490 | snd_pcm_hw_params_t * hw_params) | |
491 | { | |
492 | return snd_pcm_lib_malloc_pages(substream, | |
493 | params_buffer_bytes(hw_params)); | |
494 | } | |
495 | ||
496 | /* hw_free callback */ | |
497 | static int snd_ca0106_pcm_hw_free_capture(snd_pcm_substream_t *substream) | |
498 | { | |
499 | return snd_pcm_lib_free_pages(substream); | |
500 | } | |
501 | ||
502 | /* prepare playback callback */ | |
503 | static int snd_ca0106_pcm_prepare_playback(snd_pcm_substream_t *substream) | |
504 | { | |
505 | ca0106_t *emu = snd_pcm_substream_chip(substream); | |
506 | snd_pcm_runtime_t *runtime = substream->runtime; | |
507 | ca0106_pcm_t *epcm = runtime->private_data; | |
508 | int channel = epcm->channel_id; | |
509 | u32 *table_base = (u32 *)(emu->buffer.area+(8*16*channel)); | |
510 | u32 period_size_bytes = frames_to_bytes(runtime, runtime->period_size); | |
511 | u32 hcfg_mask = HCFG_PLAYBACK_S32_LE; | |
512 | u32 hcfg_set = 0x00000000; | |
513 | u32 hcfg; | |
514 | u32 reg40_mask = 0x30000 << (channel<<1); | |
515 | u32 reg40_set = 0; | |
516 | u32 reg40; | |
517 | /* FIXME: Depending on mixer selection of SPDIF out or not, select the spdif rate or the DAC rate. */ | |
518 | u32 reg71_mask = 0x03030000 ; /* Global. Set SPDIF rate. We only support 44100 to spdif, not to DAC. */ | |
519 | u32 reg71_set = 0; | |
520 | u32 reg71; | |
521 | int i; | |
522 | ||
523 | //snd_printk("prepare:channel_number=%d, rate=%d, format=0x%x, channels=%d, buffer_size=%ld, period_size=%ld, periods=%u, frames_to_bytes=%d\n",channel, runtime->rate, runtime->format, runtime->channels, runtime->buffer_size, runtime->period_size, runtime->periods, frames_to_bytes(runtime, 1)); | |
524 | //snd_printk("dma_addr=%x, dma_area=%p, table_base=%p\n",runtime->dma_addr, runtime->dma_area, table_base); | |
525 | //snd_printk("dma_addr=%x, dma_area=%p, dma_bytes(size)=%x\n",emu->buffer.addr, emu->buffer.area, emu->buffer.bytes); | |
526 | /* Rate can be set per channel. */ | |
527 | /* reg40 control host to fifo */ | |
528 | /* reg71 controls DAC rate. */ | |
529 | switch (runtime->rate) { | |
530 | case 44100: | |
531 | reg40_set = 0x10000 << (channel<<1); | |
532 | reg71_set = 0x01010000; | |
533 | break; | |
534 | case 48000: | |
535 | reg40_set = 0; | |
536 | reg71_set = 0; | |
537 | break; | |
538 | case 96000: | |
539 | reg40_set = 0x20000 << (channel<<1); | |
540 | reg71_set = 0x02020000; | |
541 | break; | |
542 | case 192000: | |
543 | reg40_set = 0x30000 << (channel<<1); | |
544 | reg71_set = 0x03030000; | |
545 | break; | |
546 | default: | |
547 | reg40_set = 0; | |
548 | reg71_set = 0; | |
549 | break; | |
550 | } | |
551 | /* Format is a global setting */ | |
552 | /* FIXME: Only let the first channel accessed set this. */ | |
553 | switch (runtime->format) { | |
554 | case SNDRV_PCM_FORMAT_S16_LE: | |
555 | hcfg_set = 0; | |
556 | break; | |
557 | case SNDRV_PCM_FORMAT_S32_LE: | |
558 | hcfg_set = HCFG_PLAYBACK_S32_LE; | |
559 | break; | |
560 | default: | |
561 | hcfg_set = 0; | |
562 | break; | |
563 | } | |
564 | hcfg = inl(emu->port + HCFG) ; | |
565 | hcfg = (hcfg & ~hcfg_mask) | hcfg_set; | |
566 | outl(hcfg, emu->port + HCFG); | |
567 | reg40 = snd_ca0106_ptr_read(emu, 0x40, 0); | |
568 | reg40 = (reg40 & ~reg40_mask) | reg40_set; | |
569 | snd_ca0106_ptr_write(emu, 0x40, 0, reg40); | |
570 | reg71 = snd_ca0106_ptr_read(emu, 0x71, 0); | |
571 | reg71 = (reg71 & ~reg71_mask) | reg71_set; | |
572 | snd_ca0106_ptr_write(emu, 0x71, 0, reg71); | |
573 | ||
574 | /* FIXME: Check emu->buffer.size before actually writing to it. */ | |
575 | for(i=0; i < runtime->periods; i++) { | |
576 | table_base[i*2]=runtime->dma_addr+(i*period_size_bytes); | |
577 | table_base[(i*2)+1]=period_size_bytes<<16; | |
578 | } | |
579 | ||
580 | snd_ca0106_ptr_write(emu, PLAYBACK_LIST_ADDR, channel, emu->buffer.addr+(8*16*channel)); | |
581 | snd_ca0106_ptr_write(emu, PLAYBACK_LIST_SIZE, channel, (runtime->periods - 1) << 19); | |
582 | snd_ca0106_ptr_write(emu, PLAYBACK_LIST_PTR, channel, 0); | |
583 | snd_ca0106_ptr_write(emu, PLAYBACK_DMA_ADDR, channel, runtime->dma_addr); | |
584 | snd_ca0106_ptr_write(emu, PLAYBACK_PERIOD_SIZE, channel, frames_to_bytes(runtime, runtime->period_size)<<16); // buffer size in bytes | |
585 | /* FIXME test what 0 bytes does. */ | |
586 | snd_ca0106_ptr_write(emu, PLAYBACK_PERIOD_SIZE, channel, 0); // buffer size in bytes | |
587 | snd_ca0106_ptr_write(emu, PLAYBACK_POINTER, channel, 0); | |
588 | snd_ca0106_ptr_write(emu, 0x07, channel, 0x0); | |
589 | snd_ca0106_ptr_write(emu, 0x08, channel, 0); | |
590 | snd_ca0106_ptr_write(emu, PLAYBACK_MUTE, 0x0, 0x0); /* Unmute output */ | |
591 | #if 0 | |
592 | snd_ca0106_ptr_write(emu, SPCS0, 0, | |
593 | SPCS_CLKACCY_1000PPM | SPCS_SAMPLERATE_48 | | |
594 | SPCS_CHANNELNUM_LEFT | SPCS_SOURCENUM_UNSPEC | | |
595 | SPCS_GENERATIONSTATUS | 0x00001200 | | |
596 | 0x00000000 | SPCS_EMPHASIS_NONE | SPCS_COPYRIGHT ); | |
597 | } | |
598 | #endif | |
599 | ||
600 | return 0; | |
601 | } | |
602 | ||
603 | /* prepare capture callback */ | |
604 | static int snd_ca0106_pcm_prepare_capture(snd_pcm_substream_t *substream) | |
605 | { | |
606 | ca0106_t *emu = snd_pcm_substream_chip(substream); | |
607 | snd_pcm_runtime_t *runtime = substream->runtime; | |
608 | ca0106_pcm_t *epcm = runtime->private_data; | |
609 | int channel = epcm->channel_id; | |
610 | //printk("prepare:channel_number=%d, rate=%d, format=0x%x, channels=%d, buffer_size=%ld, period_size=%ld, frames_to_bytes=%d\n",channel, runtime->rate, runtime->format, runtime->channels, runtime->buffer_size, runtime->period_size, frames_to_bytes(runtime, 1)); | |
611 | snd_ca0106_ptr_write(emu, 0x13, channel, 0); | |
612 | snd_ca0106_ptr_write(emu, CAPTURE_DMA_ADDR, channel, runtime->dma_addr); | |
613 | snd_ca0106_ptr_write(emu, CAPTURE_BUFFER_SIZE, channel, frames_to_bytes(runtime, runtime->buffer_size)<<16); // buffer size in bytes | |
614 | snd_ca0106_ptr_write(emu, CAPTURE_POINTER, channel, 0); | |
615 | ||
616 | return 0; | |
617 | } | |
618 | ||
619 | /* trigger_playback callback */ | |
620 | static int snd_ca0106_pcm_trigger_playback(snd_pcm_substream_t *substream, | |
621 | int cmd) | |
622 | { | |
623 | ca0106_t *emu = snd_pcm_substream_chip(substream); | |
624 | snd_pcm_runtime_t *runtime; | |
625 | ca0106_pcm_t *epcm; | |
626 | int channel; | |
627 | int result = 0; | |
628 | struct list_head *pos; | |
629 | snd_pcm_substream_t *s; | |
630 | u32 basic = 0; | |
631 | u32 extended = 0; | |
632 | int running=0; | |
633 | ||
634 | switch (cmd) { | |
635 | case SNDRV_PCM_TRIGGER_START: | |
636 | running=1; | |
637 | break; | |
638 | case SNDRV_PCM_TRIGGER_STOP: | |
639 | default: | |
640 | running=0; | |
641 | break; | |
642 | } | |
643 | snd_pcm_group_for_each(pos, substream) { | |
644 | s = snd_pcm_group_substream_entry(pos); | |
645 | runtime = s->runtime; | |
646 | epcm = runtime->private_data; | |
647 | channel = epcm->channel_id; | |
648 | //snd_printk("channel=%d\n",channel); | |
649 | epcm->running = running; | |
650 | basic |= (0x1<<channel); | |
651 | extended |= (0x10<<channel); | |
652 | snd_pcm_trigger_done(s, substream); | |
653 | } | |
654 | //snd_printk("basic=0x%x, extended=0x%x\n",basic, extended); | |
655 | ||
656 | switch (cmd) { | |
657 | case SNDRV_PCM_TRIGGER_START: | |
658 | snd_ca0106_ptr_write(emu, EXTENDED_INT_MASK, 0, snd_ca0106_ptr_read(emu, EXTENDED_INT_MASK, 0) | (extended)); | |
659 | snd_ca0106_ptr_write(emu, BASIC_INTERRUPT, 0, snd_ca0106_ptr_read(emu, BASIC_INTERRUPT, 0)|(basic)); | |
660 | break; | |
661 | case SNDRV_PCM_TRIGGER_STOP: | |
662 | snd_ca0106_ptr_write(emu, BASIC_INTERRUPT, 0, snd_ca0106_ptr_read(emu, BASIC_INTERRUPT, 0) & ~(basic)); | |
663 | snd_ca0106_ptr_write(emu, EXTENDED_INT_MASK, 0, snd_ca0106_ptr_read(emu, EXTENDED_INT_MASK, 0) & ~(extended)); | |
664 | break; | |
665 | default: | |
666 | result = -EINVAL; | |
667 | break; | |
668 | } | |
669 | return result; | |
670 | } | |
671 | ||
672 | /* trigger_capture callback */ | |
673 | static int snd_ca0106_pcm_trigger_capture(snd_pcm_substream_t *substream, | |
674 | int cmd) | |
675 | { | |
676 | ca0106_t *emu = snd_pcm_substream_chip(substream); | |
677 | snd_pcm_runtime_t *runtime = substream->runtime; | |
678 | ca0106_pcm_t *epcm = runtime->private_data; | |
679 | int channel = epcm->channel_id; | |
680 | int result = 0; | |
681 | ||
682 | switch (cmd) { | |
683 | case SNDRV_PCM_TRIGGER_START: | |
684 | snd_ca0106_ptr_write(emu, EXTENDED_INT_MASK, 0, snd_ca0106_ptr_read(emu, EXTENDED_INT_MASK, 0) | (0x110000<<channel)); | |
685 | snd_ca0106_ptr_write(emu, BASIC_INTERRUPT, 0, snd_ca0106_ptr_read(emu, BASIC_INTERRUPT, 0)|(0x100<<channel)); | |
686 | epcm->running = 1; | |
687 | break; | |
688 | case SNDRV_PCM_TRIGGER_STOP: | |
689 | snd_ca0106_ptr_write(emu, BASIC_INTERRUPT, 0, snd_ca0106_ptr_read(emu, BASIC_INTERRUPT, 0) & ~(0x100<<channel)); | |
690 | snd_ca0106_ptr_write(emu, EXTENDED_INT_MASK, 0, snd_ca0106_ptr_read(emu, EXTENDED_INT_MASK, 0) & ~(0x110000<<channel)); | |
691 | epcm->running = 0; | |
692 | break; | |
693 | default: | |
694 | result = -EINVAL; | |
695 | break; | |
696 | } | |
697 | return result; | |
698 | } | |
699 | ||
700 | /* pointer_playback callback */ | |
701 | static snd_pcm_uframes_t | |
702 | snd_ca0106_pcm_pointer_playback(snd_pcm_substream_t *substream) | |
703 | { | |
704 | ca0106_t *emu = snd_pcm_substream_chip(substream); | |
705 | snd_pcm_runtime_t *runtime = substream->runtime; | |
706 | ca0106_pcm_t *epcm = runtime->private_data; | |
707 | snd_pcm_uframes_t ptr, ptr1, ptr2,ptr3,ptr4 = 0; | |
708 | int channel = epcm->channel_id; | |
709 | ||
710 | if (!epcm->running) | |
711 | return 0; | |
712 | ||
713 | ptr3 = snd_ca0106_ptr_read(emu, PLAYBACK_LIST_PTR, channel); | |
714 | ptr1 = snd_ca0106_ptr_read(emu, PLAYBACK_POINTER, channel); | |
715 | ptr4 = snd_ca0106_ptr_read(emu, PLAYBACK_LIST_PTR, channel); | |
716 | if (ptr3 != ptr4) ptr1 = snd_ca0106_ptr_read(emu, PLAYBACK_POINTER, channel); | |
717 | ptr2 = bytes_to_frames(runtime, ptr1); | |
718 | ptr2+= (ptr4 >> 3) * runtime->period_size; | |
719 | ptr=ptr2; | |
720 | if (ptr >= runtime->buffer_size) | |
721 | ptr -= runtime->buffer_size; | |
722 | //printk("ptr1 = 0x%lx, ptr2=0x%lx, ptr=0x%lx, buffer_size = 0x%x, period_size = 0x%x, bits=%d, rate=%d\n", ptr1, ptr2, ptr, (int)runtime->buffer_size, (int)runtime->period_size, (int)runtime->frame_bits, (int)runtime->rate); | |
723 | ||
724 | return ptr; | |
725 | } | |
726 | ||
727 | /* pointer_capture callback */ | |
728 | static snd_pcm_uframes_t | |
729 | snd_ca0106_pcm_pointer_capture(snd_pcm_substream_t *substream) | |
730 | { | |
731 | ca0106_t *emu = snd_pcm_substream_chip(substream); | |
732 | snd_pcm_runtime_t *runtime = substream->runtime; | |
733 | ca0106_pcm_t *epcm = runtime->private_data; | |
734 | snd_pcm_uframes_t ptr, ptr1, ptr2 = 0; | |
735 | int channel = channel=epcm->channel_id; | |
736 | ||
737 | if (!epcm->running) | |
738 | return 0; | |
739 | ||
740 | ptr1 = snd_ca0106_ptr_read(emu, CAPTURE_POINTER, channel); | |
741 | ptr2 = bytes_to_frames(runtime, ptr1); | |
742 | ptr=ptr2; | |
743 | if (ptr >= runtime->buffer_size) | |
744 | ptr -= runtime->buffer_size; | |
745 | //printk("ptr1 = 0x%lx, ptr2=0x%lx, ptr=0x%lx, buffer_size = 0x%x, period_size = 0x%x, bits=%d, rate=%d\n", ptr1, ptr2, ptr, (int)runtime->buffer_size, (int)runtime->period_size, (int)runtime->frame_bits, (int)runtime->rate); | |
746 | ||
747 | return ptr; | |
748 | } | |
749 | ||
750 | /* operators */ | |
751 | static snd_pcm_ops_t snd_ca0106_playback_front_ops = { | |
752 | .open = snd_ca0106_pcm_open_playback_front, | |
753 | .close = snd_ca0106_pcm_close_playback, | |
754 | .ioctl = snd_pcm_lib_ioctl, | |
755 | .hw_params = snd_ca0106_pcm_hw_params_playback, | |
756 | .hw_free = snd_ca0106_pcm_hw_free_playback, | |
757 | .prepare = snd_ca0106_pcm_prepare_playback, | |
758 | .trigger = snd_ca0106_pcm_trigger_playback, | |
759 | .pointer = snd_ca0106_pcm_pointer_playback, | |
760 | }; | |
761 | ||
762 | static snd_pcm_ops_t snd_ca0106_capture_0_ops = { | |
763 | .open = snd_ca0106_pcm_open_0_capture, | |
764 | .close = snd_ca0106_pcm_close_capture, | |
765 | .ioctl = snd_pcm_lib_ioctl, | |
766 | .hw_params = snd_ca0106_pcm_hw_params_capture, | |
767 | .hw_free = snd_ca0106_pcm_hw_free_capture, | |
768 | .prepare = snd_ca0106_pcm_prepare_capture, | |
769 | .trigger = snd_ca0106_pcm_trigger_capture, | |
770 | .pointer = snd_ca0106_pcm_pointer_capture, | |
771 | }; | |
772 | ||
773 | static snd_pcm_ops_t snd_ca0106_capture_1_ops = { | |
774 | .open = snd_ca0106_pcm_open_1_capture, | |
775 | .close = snd_ca0106_pcm_close_capture, | |
776 | .ioctl = snd_pcm_lib_ioctl, | |
777 | .hw_params = snd_ca0106_pcm_hw_params_capture, | |
778 | .hw_free = snd_ca0106_pcm_hw_free_capture, | |
779 | .prepare = snd_ca0106_pcm_prepare_capture, | |
780 | .trigger = snd_ca0106_pcm_trigger_capture, | |
781 | .pointer = snd_ca0106_pcm_pointer_capture, | |
782 | }; | |
783 | ||
784 | static snd_pcm_ops_t snd_ca0106_capture_2_ops = { | |
785 | .open = snd_ca0106_pcm_open_2_capture, | |
786 | .close = snd_ca0106_pcm_close_capture, | |
787 | .ioctl = snd_pcm_lib_ioctl, | |
788 | .hw_params = snd_ca0106_pcm_hw_params_capture, | |
789 | .hw_free = snd_ca0106_pcm_hw_free_capture, | |
790 | .prepare = snd_ca0106_pcm_prepare_capture, | |
791 | .trigger = snd_ca0106_pcm_trigger_capture, | |
792 | .pointer = snd_ca0106_pcm_pointer_capture, | |
793 | }; | |
794 | ||
795 | static snd_pcm_ops_t snd_ca0106_capture_3_ops = { | |
796 | .open = snd_ca0106_pcm_open_3_capture, | |
797 | .close = snd_ca0106_pcm_close_capture, | |
798 | .ioctl = snd_pcm_lib_ioctl, | |
799 | .hw_params = snd_ca0106_pcm_hw_params_capture, | |
800 | .hw_free = snd_ca0106_pcm_hw_free_capture, | |
801 | .prepare = snd_ca0106_pcm_prepare_capture, | |
802 | .trigger = snd_ca0106_pcm_trigger_capture, | |
803 | .pointer = snd_ca0106_pcm_pointer_capture, | |
804 | }; | |
805 | ||
806 | static snd_pcm_ops_t snd_ca0106_playback_center_lfe_ops = { | |
807 | .open = snd_ca0106_pcm_open_playback_center_lfe, | |
808 | .close = snd_ca0106_pcm_close_playback, | |
809 | .ioctl = snd_pcm_lib_ioctl, | |
810 | .hw_params = snd_ca0106_pcm_hw_params_playback, | |
811 | .hw_free = snd_ca0106_pcm_hw_free_playback, | |
812 | .prepare = snd_ca0106_pcm_prepare_playback, | |
813 | .trigger = snd_ca0106_pcm_trigger_playback, | |
814 | .pointer = snd_ca0106_pcm_pointer_playback, | |
815 | }; | |
816 | ||
817 | static snd_pcm_ops_t snd_ca0106_playback_unknown_ops = { | |
818 | .open = snd_ca0106_pcm_open_playback_unknown, | |
819 | .close = snd_ca0106_pcm_close_playback, | |
820 | .ioctl = snd_pcm_lib_ioctl, | |
821 | .hw_params = snd_ca0106_pcm_hw_params_playback, | |
822 | .hw_free = snd_ca0106_pcm_hw_free_playback, | |
823 | .prepare = snd_ca0106_pcm_prepare_playback, | |
824 | .trigger = snd_ca0106_pcm_trigger_playback, | |
825 | .pointer = snd_ca0106_pcm_pointer_playback, | |
826 | }; | |
827 | ||
828 | static snd_pcm_ops_t snd_ca0106_playback_rear_ops = { | |
829 | .open = snd_ca0106_pcm_open_playback_rear, | |
830 | .close = snd_ca0106_pcm_close_playback, | |
831 | .ioctl = snd_pcm_lib_ioctl, | |
832 | .hw_params = snd_ca0106_pcm_hw_params_playback, | |
833 | .hw_free = snd_ca0106_pcm_hw_free_playback, | |
834 | .prepare = snd_ca0106_pcm_prepare_playback, | |
835 | .trigger = snd_ca0106_pcm_trigger_playback, | |
836 | .pointer = snd_ca0106_pcm_pointer_playback, | |
837 | }; | |
838 | ||
839 | ||
840 | static unsigned short snd_ca0106_ac97_read(ac97_t *ac97, | |
841 | unsigned short reg) | |
842 | { | |
843 | ca0106_t *emu = ac97->private_data; | |
844 | unsigned long flags; | |
845 | unsigned short val; | |
846 | ||
847 | spin_lock_irqsave(&emu->emu_lock, flags); | |
848 | outb(reg, emu->port + AC97ADDRESS); | |
849 | val = inw(emu->port + AC97DATA); | |
850 | spin_unlock_irqrestore(&emu->emu_lock, flags); | |
851 | return val; | |
852 | } | |
853 | ||
854 | static void snd_ca0106_ac97_write(ac97_t *ac97, | |
855 | unsigned short reg, unsigned short val) | |
856 | { | |
857 | ca0106_t *emu = ac97->private_data; | |
858 | unsigned long flags; | |
859 | ||
860 | spin_lock_irqsave(&emu->emu_lock, flags); | |
861 | outb(reg, emu->port + AC97ADDRESS); | |
862 | outw(val, emu->port + AC97DATA); | |
863 | spin_unlock_irqrestore(&emu->emu_lock, flags); | |
864 | } | |
865 | ||
866 | static int snd_ca0106_ac97(ca0106_t *chip) | |
867 | { | |
868 | ac97_bus_t *pbus; | |
869 | ac97_template_t ac97; | |
870 | int err; | |
871 | static ac97_bus_ops_t ops = { | |
872 | .write = snd_ca0106_ac97_write, | |
873 | .read = snd_ca0106_ac97_read, | |
874 | }; | |
875 | ||
876 | if ((err = snd_ac97_bus(chip->card, 0, &ops, NULL, &pbus)) < 0) | |
877 | return err; | |
878 | pbus->no_vra = 1; /* we don't need VRA */ | |
879 | ||
880 | memset(&ac97, 0, sizeof(ac97)); | |
881 | ac97.private_data = chip; | |
36c4dc42 | 882 | ac97.scaps = AC97_SCAP_NO_SPDIF; |
1da177e4 LT |
883 | return snd_ac97_mixer(pbus, &ac97, &chip->ac97); |
884 | } | |
885 | ||
886 | static int snd_ca0106_free(ca0106_t *chip) | |
887 | { | |
888 | if (chip->res_port != NULL) { /* avoid access to already used hardware */ | |
889 | // disable interrupts | |
890 | snd_ca0106_ptr_write(chip, BASIC_INTERRUPT, 0, 0); | |
891 | outl(0, chip->port + INTE); | |
892 | snd_ca0106_ptr_write(chip, EXTENDED_INT_MASK, 0, 0); | |
893 | udelay(1000); | |
894 | // disable audio | |
895 | //outl(HCFG_LOCKSOUNDCACHE, chip->port + HCFG); | |
896 | outl(0, chip->port + HCFG); | |
897 | /* FIXME: We need to stop and DMA transfers here. | |
898 | * But as I am not sure how yet, we cannot from the dma pages. | |
899 | * So we can fix: snd-malloc: Memory leak? pages not freed = 8 | |
900 | */ | |
901 | } | |
902 | // release the data | |
903 | #if 1 | |
904 | if (chip->buffer.area) | |
905 | snd_dma_free_pages(&chip->buffer); | |
906 | #endif | |
907 | ||
908 | // release the i/o port | |
909 | if (chip->res_port) { | |
910 | release_resource(chip->res_port); | |
911 | kfree_nocheck(chip->res_port); | |
912 | } | |
913 | // release the irq | |
914 | if (chip->irq >= 0) | |
915 | free_irq(chip->irq, (void *)chip); | |
916 | pci_disable_device(chip->pci); | |
917 | kfree(chip); | |
918 | return 0; | |
919 | } | |
920 | ||
921 | static int snd_ca0106_dev_free(snd_device_t *device) | |
922 | { | |
923 | ca0106_t *chip = device->device_data; | |
924 | return snd_ca0106_free(chip); | |
925 | } | |
926 | ||
927 | static irqreturn_t snd_ca0106_interrupt(int irq, void *dev_id, | |
928 | struct pt_regs *regs) | |
929 | { | |
930 | unsigned int status; | |
931 | ||
932 | ca0106_t *chip = dev_id; | |
933 | int i; | |
934 | int mask; | |
935 | unsigned int stat76; | |
936 | ca0106_channel_t *pchannel; | |
937 | ||
938 | spin_lock(&chip->emu_lock); | |
939 | ||
940 | status = inl(chip->port + IPR); | |
941 | ||
942 | // call updater, unlock before it | |
943 | spin_unlock(&chip->emu_lock); | |
944 | ||
945 | if (! status) | |
946 | return IRQ_NONE; | |
947 | ||
948 | stat76 = snd_ca0106_ptr_read(chip, EXTENDED_INT, 0); | |
949 | //snd_printk("interrupt status = 0x%08x, stat76=0x%08x\n", status, stat76); | |
950 | //snd_printk("ptr=0x%08x\n",snd_ca0106_ptr_read(chip, PLAYBACK_POINTER, 0)); | |
951 | mask = 0x11; /* 0x1 for one half, 0x10 for the other half period. */ | |
952 | for(i = 0; i < 4; i++) { | |
953 | pchannel = &(chip->playback_channels[i]); | |
954 | if(stat76 & mask) { | |
955 | /* FIXME: Select the correct substream for period elapsed */ | |
956 | if(pchannel->use) { | |
957 | snd_pcm_period_elapsed(pchannel->epcm->substream); | |
958 | //printk(KERN_INFO "interrupt [%d] used\n", i); | |
959 | } | |
960 | } | |
961 | //printk(KERN_INFO "channel=%p\n",pchannel); | |
962 | //printk(KERN_INFO "interrupt stat76[%d] = %08x, use=%d, channel=%d\n", i, stat76, pchannel->use, pchannel->number); | |
963 | mask <<= 1; | |
964 | } | |
965 | mask = 0x110000; /* 0x1 for one half, 0x10 for the other half period. */ | |
966 | for(i = 0; i < 4; i++) { | |
967 | pchannel = &(chip->capture_channels[i]); | |
968 | if(stat76 & mask) { | |
969 | /* FIXME: Select the correct substream for period elapsed */ | |
970 | if(pchannel->use) { | |
971 | snd_pcm_period_elapsed(pchannel->epcm->substream); | |
972 | //printk(KERN_INFO "interrupt [%d] used\n", i); | |
973 | } | |
974 | } | |
975 | //printk(KERN_INFO "channel=%p\n",pchannel); | |
976 | //printk(KERN_INFO "interrupt stat76[%d] = %08x, use=%d, channel=%d\n", i, stat76, pchannel->use, pchannel->number); | |
977 | mask <<= 1; | |
978 | } | |
979 | ||
980 | snd_ca0106_ptr_write(chip, EXTENDED_INT, 0, stat76); | |
981 | spin_lock(&chip->emu_lock); | |
982 | // acknowledge the interrupt if necessary | |
983 | outl(status, chip->port+IPR); | |
984 | ||
985 | spin_unlock(&chip->emu_lock); | |
986 | ||
987 | return IRQ_HANDLED; | |
988 | } | |
989 | ||
990 | static void snd_ca0106_pcm_free(snd_pcm_t *pcm) | |
991 | { | |
992 | ca0106_t *emu = pcm->private_data; | |
993 | emu->pcm = NULL; | |
994 | snd_pcm_lib_preallocate_free_for_all(pcm); | |
995 | } | |
996 | ||
997 | static int __devinit snd_ca0106_pcm(ca0106_t *emu, int device, snd_pcm_t **rpcm) | |
998 | { | |
999 | snd_pcm_t *pcm; | |
1000 | snd_pcm_substream_t *substream; | |
1001 | int err; | |
1002 | ||
1003 | if (rpcm) | |
1004 | *rpcm = NULL; | |
1005 | if ((err = snd_pcm_new(emu->card, "ca0106", device, 1, 1, &pcm)) < 0) | |
1006 | return err; | |
1007 | ||
1008 | pcm->private_data = emu; | |
1009 | pcm->private_free = snd_ca0106_pcm_free; | |
1010 | ||
1011 | switch (device) { | |
1012 | case 0: | |
1013 | snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_PLAYBACK, &snd_ca0106_playback_front_ops); | |
1014 | snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_CAPTURE, &snd_ca0106_capture_0_ops); | |
1015 | break; | |
1016 | case 1: | |
1017 | snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_PLAYBACK, &snd_ca0106_playback_rear_ops); | |
1018 | snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_CAPTURE, &snd_ca0106_capture_1_ops); | |
1019 | break; | |
1020 | case 2: | |
1021 | snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_PLAYBACK, &snd_ca0106_playback_center_lfe_ops); | |
1022 | snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_CAPTURE, &snd_ca0106_capture_2_ops); | |
1023 | break; | |
1024 | case 3: | |
1025 | snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_PLAYBACK, &snd_ca0106_playback_unknown_ops); | |
1026 | snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_CAPTURE, &snd_ca0106_capture_3_ops); | |
1027 | break; | |
1028 | } | |
1029 | ||
1030 | pcm->info_flags = 0; | |
1031 | pcm->dev_subclass = SNDRV_PCM_SUBCLASS_GENERIC_MIX; | |
1032 | strcpy(pcm->name, "CA0106"); | |
1033 | emu->pcm = pcm; | |
1034 | ||
1035 | for(substream = pcm->streams[SNDRV_PCM_STREAM_PLAYBACK].substream; | |
1036 | substream; | |
1037 | substream = substream->next) { | |
1038 | if ((err = snd_pcm_lib_preallocate_pages(substream, | |
1039 | SNDRV_DMA_TYPE_DEV, | |
1040 | snd_dma_pci_data(emu->pci), | |
1041 | 64*1024, 64*1024)) < 0) /* FIXME: 32*1024 for sound buffer, between 32and64 for Periods table. */ | |
1042 | return err; | |
1043 | } | |
1044 | ||
1045 | for (substream = pcm->streams[SNDRV_PCM_STREAM_CAPTURE].substream; | |
1046 | substream; | |
1047 | substream = substream->next) { | |
1048 | if ((err = snd_pcm_lib_preallocate_pages(substream, | |
1049 | SNDRV_DMA_TYPE_DEV, | |
1050 | snd_dma_pci_data(emu->pci), | |
1051 | 64*1024, 64*1024)) < 0) | |
1052 | return err; | |
1053 | } | |
1054 | ||
1055 | if (rpcm) | |
1056 | *rpcm = pcm; | |
1057 | ||
1058 | return 0; | |
1059 | } | |
1060 | ||
1061 | static int __devinit snd_ca0106_create(snd_card_t *card, | |
1062 | struct pci_dev *pci, | |
1063 | ca0106_t **rchip) | |
1064 | { | |
1065 | ca0106_t *chip; | |
1baa705b | 1066 | ca0106_details_t *c; |
1da177e4 LT |
1067 | int err; |
1068 | int ch; | |
1069 | static snd_device_ops_t ops = { | |
1070 | .dev_free = snd_ca0106_dev_free, | |
1071 | }; | |
1072 | ||
1073 | *rchip = NULL; | |
1074 | ||
1075 | if ((err = pci_enable_device(pci)) < 0) | |
1076 | return err; | |
1077 | if (pci_set_dma_mask(pci, 0xffffffffUL) < 0 || | |
1078 | pci_set_consistent_dma_mask(pci, 0xffffffffUL) < 0) { | |
1079 | printk(KERN_ERR "error to set 32bit mask DMA\n"); | |
1080 | pci_disable_device(pci); | |
1081 | return -ENXIO; | |
1082 | } | |
1083 | ||
1084 | chip = kcalloc(1, sizeof(*chip), GFP_KERNEL); | |
1085 | if (chip == NULL) { | |
1086 | pci_disable_device(pci); | |
1087 | return -ENOMEM; | |
1088 | } | |
1089 | ||
1090 | chip->card = card; | |
1091 | chip->pci = pci; | |
1092 | chip->irq = -1; | |
1093 | ||
1094 | spin_lock_init(&chip->emu_lock); | |
1095 | ||
1096 | chip->port = pci_resource_start(pci, 0); | |
1097 | if ((chip->res_port = request_region(chip->port, 0x20, | |
1098 | "snd_ca0106")) == NULL) { | |
1099 | snd_ca0106_free(chip); | |
1100 | printk(KERN_ERR "cannot allocate the port\n"); | |
1101 | return -EBUSY; | |
1102 | } | |
1103 | ||
1104 | if (request_irq(pci->irq, snd_ca0106_interrupt, | |
1105 | SA_INTERRUPT|SA_SHIRQ, "snd_ca0106", | |
1106 | (void *)chip)) { | |
1107 | snd_ca0106_free(chip); | |
1108 | printk(KERN_ERR "cannot grab irq\n"); | |
1109 | return -EBUSY; | |
1110 | } | |
1111 | chip->irq = pci->irq; | |
1112 | ||
1113 | /* This stores the periods table. */ | |
1114 | if(snd_dma_alloc_pages(SNDRV_DMA_TYPE_DEV, snd_dma_pci_data(pci), 1024, &chip->buffer) < 0) { | |
1115 | snd_ca0106_free(chip); | |
1116 | return -ENOMEM; | |
1117 | } | |
1118 | ||
1119 | pci_set_master(pci); | |
1120 | /* read revision & serial */ | |
1121 | pci_read_config_byte(pci, PCI_REVISION_ID, (char *)&chip->revision); | |
1122 | pci_read_config_dword(pci, PCI_SUBSYSTEM_VENDOR_ID, &chip->serial); | |
1123 | pci_read_config_word(pci, PCI_SUBSYSTEM_ID, &chip->model); | |
1124 | #if 1 | |
1125 | printk(KERN_INFO "Model %04x Rev %08x Serial %08x\n", chip->model, | |
1126 | chip->revision, chip->serial); | |
1127 | #endif | |
1baa705b JCD |
1128 | strcpy(card->driver, "CA0106"); |
1129 | strcpy(card->shortname, "CA0106"); | |
1130 | ||
1131 | for (c=ca0106_chip_details; c->serial; c++) { | |
1132 | if (c->serial == chip->serial) break; | |
1133 | } | |
1134 | chip->details = c; | |
1135 | sprintf(card->longname, "%s at 0x%lx irq %i", | |
1136 | c->name, chip->port, chip->irq); | |
1da177e4 LT |
1137 | |
1138 | outl(0, chip->port + INTE); | |
1139 | ||
1140 | /* | |
1141 | * Init to 0x02109204 : | |
1142 | * Clock accuracy = 0 (1000ppm) | |
1143 | * Sample Rate = 2 (48kHz) | |
1144 | * Audio Channel = 1 (Left of 2) | |
1145 | * Source Number = 0 (Unspecified) | |
1146 | * Generation Status = 1 (Original for Cat Code 12) | |
1147 | * Cat Code = 12 (Digital Signal Mixer) | |
1148 | * Mode = 0 (Mode 0) | |
1149 | * Emphasis = 0 (None) | |
1150 | * CP = 1 (Copyright unasserted) | |
1151 | * AN = 0 (Audio data) | |
1152 | * P = 0 (Consumer) | |
1153 | */ | |
1154 | snd_ca0106_ptr_write(chip, SPCS0, 0, | |
1155 | chip->spdif_bits[0] = | |
1156 | SPCS_CLKACCY_1000PPM | SPCS_SAMPLERATE_48 | | |
1157 | SPCS_CHANNELNUM_LEFT | SPCS_SOURCENUM_UNSPEC | | |
1158 | SPCS_GENERATIONSTATUS | 0x00001200 | | |
1159 | 0x00000000 | SPCS_EMPHASIS_NONE | SPCS_COPYRIGHT); | |
1160 | /* Only SPCS1 has been tested */ | |
1161 | snd_ca0106_ptr_write(chip, SPCS1, 0, | |
1162 | chip->spdif_bits[1] = | |
1163 | SPCS_CLKACCY_1000PPM | SPCS_SAMPLERATE_48 | | |
1164 | SPCS_CHANNELNUM_LEFT | SPCS_SOURCENUM_UNSPEC | | |
1165 | SPCS_GENERATIONSTATUS | 0x00001200 | | |
1166 | 0x00000000 | SPCS_EMPHASIS_NONE | SPCS_COPYRIGHT); | |
1167 | snd_ca0106_ptr_write(chip, SPCS2, 0, | |
1168 | chip->spdif_bits[2] = | |
1169 | SPCS_CLKACCY_1000PPM | SPCS_SAMPLERATE_48 | | |
1170 | SPCS_CHANNELNUM_LEFT | SPCS_SOURCENUM_UNSPEC | | |
1171 | SPCS_GENERATIONSTATUS | 0x00001200 | | |
1172 | 0x00000000 | SPCS_EMPHASIS_NONE | SPCS_COPYRIGHT); | |
1173 | snd_ca0106_ptr_write(chip, SPCS3, 0, | |
1174 | chip->spdif_bits[3] = | |
1175 | SPCS_CLKACCY_1000PPM | SPCS_SAMPLERATE_48 | | |
1176 | SPCS_CHANNELNUM_LEFT | SPCS_SOURCENUM_UNSPEC | | |
1177 | SPCS_GENERATIONSTATUS | 0x00001200 | | |
1178 | 0x00000000 | SPCS_EMPHASIS_NONE | SPCS_COPYRIGHT); | |
1179 | ||
1180 | snd_ca0106_ptr_write(chip, PLAYBACK_MUTE, 0, 0x00fc0000); | |
1181 | snd_ca0106_ptr_write(chip, CAPTURE_MUTE, 0, 0x00fc0000); | |
1182 | ||
1183 | /* Write 0x8000 to AC97_REC_GAIN to mute it. */ | |
1184 | outb(AC97_REC_GAIN, chip->port + AC97ADDRESS); | |
1185 | outw(0x8000, chip->port + AC97DATA); | |
1186 | #if 0 | |
1187 | snd_ca0106_ptr_write(chip, SPCS0, 0, 0x2108006); | |
1188 | snd_ca0106_ptr_write(chip, 0x42, 0, 0x2108006); | |
1189 | snd_ca0106_ptr_write(chip, 0x43, 0, 0x2108006); | |
1190 | snd_ca0106_ptr_write(chip, 0x44, 0, 0x2108006); | |
1191 | #endif | |
1192 | ||
1193 | //snd_ca0106_ptr_write(chip, SPDIF_SELECT2, 0, 0xf0f003f); /* OSS drivers set this. */ | |
1194 | /* Analog or Digital output */ | |
1195 | snd_ca0106_ptr_write(chip, SPDIF_SELECT1, 0, 0xf); | |
8f55fbb0 | 1196 | snd_ca0106_ptr_write(chip, SPDIF_SELECT2, 0, 0x000f0000); /* 0x0b000000 for digital, 0x000b0000 for analog, from win2000 drivers. Use 0x000f0000 for surround71 */ |
1da177e4 LT |
1197 | chip->spdif_enable = 0; /* Set digital SPDIF output off */ |
1198 | chip->capture_source = 3; /* Set CAPTURE_SOURCE */ | |
1199 | //snd_ca0106_ptr_write(chip, 0x45, 0, 0); /* Analogue out */ | |
1200 | //snd_ca0106_ptr_write(chip, 0x45, 0, 0xf00); /* Digital out */ | |
1201 | ||
1202 | snd_ca0106_ptr_write(chip, CAPTURE_CONTROL, 0, 0x40c81000); /* goes to 0x40c80000 when doing SPDIF IN/OUT */ | |
1203 | snd_ca0106_ptr_write(chip, CAPTURE_CONTROL, 1, 0xffffffff); /* (Mute) CAPTURE feedback into PLAYBACK volume. Only lower 16 bits matter. */ | |
1204 | snd_ca0106_ptr_write(chip, CAPTURE_CONTROL, 2, 0x30300000); /* SPDIF IN Volume */ | |
1205 | snd_ca0106_ptr_write(chip, CAPTURE_CONTROL, 3, 0x00700000); /* SPDIF IN Volume, 0x70 = (vol & 0x3f) | 0x40 */ | |
1206 | snd_ca0106_ptr_write(chip, PLAYBACK_ROUTING1, 0, 0x32765410); | |
1207 | snd_ca0106_ptr_write(chip, PLAYBACK_ROUTING2, 0, 0x76767676); | |
1208 | snd_ca0106_ptr_write(chip, CAPTURE_ROUTING1, 0, 0x32765410); | |
1209 | snd_ca0106_ptr_write(chip, CAPTURE_ROUTING2, 0, 0x76767676); | |
1210 | for(ch = 0; ch < 4; ch++) { | |
1211 | snd_ca0106_ptr_write(chip, CAPTURE_VOLUME1, ch, 0x30303030); /* Only high 16 bits matter */ | |
1212 | snd_ca0106_ptr_write(chip, CAPTURE_VOLUME2, ch, 0x30303030); | |
1213 | //snd_ca0106_ptr_write(chip, PLAYBACK_VOLUME1, ch, 0x40404040); /* Mute */ | |
1214 | //snd_ca0106_ptr_write(chip, PLAYBACK_VOLUME2, ch, 0x40404040); /* Mute */ | |
1215 | snd_ca0106_ptr_write(chip, PLAYBACK_VOLUME1, ch, 0xffffffff); /* Mute */ | |
1216 | snd_ca0106_ptr_write(chip, PLAYBACK_VOLUME2, ch, 0xffffffff); /* Mute */ | |
1217 | } | |
1218 | snd_ca0106_ptr_write(chip, CAPTURE_SOURCE, 0x0, 0x333300e4); /* Select MIC, Line in, TAD in, AUX in */ | |
1219 | chip->capture_source = 3; /* Set CAPTURE_SOURCE */ | |
1220 | ||
1baa705b | 1221 | if (chip->details->gpio_type == 1) { /* The SB0410 and SB0413 use GPIO differently. */ |
1da177e4 LT |
1222 | /* FIXME: Still need to find out what the other GPIO bits do. E.g. For digital spdif out. */ |
1223 | outl(0x0, chip->port+GPIO); | |
1224 | //outl(0x00f0e000, chip->port+GPIO); /* Analog */ | |
8f55fbb0 | 1225 | outl(0x005f4301, chip->port+GPIO); /* Analog */ |
1da177e4 LT |
1226 | } else { |
1227 | outl(0x0, chip->port+GPIO); | |
1228 | outl(0x005f03a3, chip->port+GPIO); /* Analog */ | |
1229 | //outl(0x005f02a2, chip->port+GPIO); /* SPDIF */ | |
1230 | } | |
1231 | snd_ca0106_intr_enable(chip, 0x105); /* Win2000 uses 0x1e0 */ | |
1232 | ||
1233 | //outl(HCFG_LOCKSOUNDCACHE|HCFG_AUDIOENABLE, chip->port+HCFG); | |
1234 | //outl(0x00001409, chip->port+HCFG); /* 0x1000 causes AC3 to fails. Maybe it effects 24 bit output. */ | |
1235 | //outl(0x00000009, chip->port+HCFG); | |
1236 | outl(HCFG_AC97 | HCFG_AUDIOENABLE, chip->port+HCFG); /* AC97 2.0, Enable outputs. */ | |
1237 | ||
7199acdc JCD |
1238 | if (chip->details->i2c_adc == 1) { /* The SB0410 and SB0413 use I2C to control ADC. */ |
1239 | snd_ca0106_i2c_write(chip, ADC_MUX, ADC_MUX_LINEIN); /* Enable Line-in capture. MIC in currently untested. */ | |
1240 | } | |
1241 | ||
1da177e4 LT |
1242 | if ((err = snd_device_new(card, SNDRV_DEV_LOWLEVEL, |
1243 | chip, &ops)) < 0) { | |
1244 | snd_ca0106_free(chip); | |
1245 | return err; | |
1246 | } | |
1247 | *rchip = chip; | |
1248 | return 0; | |
1249 | } | |
1250 | ||
1251 | static int __devinit snd_ca0106_probe(struct pci_dev *pci, | |
1252 | const struct pci_device_id *pci_id) | |
1253 | { | |
1254 | static int dev; | |
1255 | snd_card_t *card; | |
1256 | ca0106_t *chip; | |
1da177e4 LT |
1257 | int err; |
1258 | ||
1259 | if (dev >= SNDRV_CARDS) | |
1260 | return -ENODEV; | |
1261 | if (!enable[dev]) { | |
1262 | dev++; | |
1263 | return -ENOENT; | |
1264 | } | |
1265 | ||
1266 | card = snd_card_new(index[dev], id[dev], THIS_MODULE, 0); | |
1267 | if (card == NULL) | |
1268 | return -ENOMEM; | |
1269 | ||
1270 | if ((err = snd_ca0106_create(card, pci, &chip)) < 0) { | |
1271 | snd_card_free(card); | |
1272 | return err; | |
1273 | } | |
1274 | ||
1275 | if ((err = snd_ca0106_pcm(chip, 0, NULL)) < 0) { | |
1276 | snd_card_free(card); | |
1277 | return err; | |
1278 | } | |
1279 | if ((err = snd_ca0106_pcm(chip, 1, NULL)) < 0) { | |
1280 | snd_card_free(card); | |
1281 | return err; | |
1282 | } | |
1283 | if ((err = snd_ca0106_pcm(chip, 2, NULL)) < 0) { | |
1284 | snd_card_free(card); | |
1285 | return err; | |
1286 | } | |
1287 | if ((err = snd_ca0106_pcm(chip, 3, NULL)) < 0) { | |
1288 | snd_card_free(card); | |
1289 | return err; | |
1290 | } | |
1baa705b | 1291 | if (chip->details->ac97 == 1) { /* The SB0410 and SB0413 do not have an AC97 chip. */ |
1da177e4 LT |
1292 | if ((err = snd_ca0106_ac97(chip)) < 0) { |
1293 | snd_card_free(card); | |
1294 | return err; | |
1295 | } | |
1296 | } | |
1297 | if ((err = snd_ca0106_mixer(chip)) < 0) { | |
1298 | snd_card_free(card); | |
1299 | return err; | |
1300 | } | |
1301 | ||
1302 | snd_ca0106_proc_init(chip); | |
1303 | ||
1da177e4 LT |
1304 | if ((err = snd_card_register(card)) < 0) { |
1305 | snd_card_free(card); | |
1306 | return err; | |
1307 | } | |
1308 | ||
1309 | pci_set_drvdata(pci, card); | |
1310 | dev++; | |
1311 | return 0; | |
1312 | } | |
1313 | ||
1314 | static void __devexit snd_ca0106_remove(struct pci_dev *pci) | |
1315 | { | |
1316 | snd_card_free(pci_get_drvdata(pci)); | |
1317 | pci_set_drvdata(pci, NULL); | |
1318 | } | |
1319 | ||
1320 | // PCI IDs | |
1321 | static struct pci_device_id snd_ca0106_ids[] = { | |
1322 | { 0x1102, 0x0007, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0 }, /* Audigy LS or Live 24bit */ | |
1323 | { 0, } | |
1324 | }; | |
1325 | MODULE_DEVICE_TABLE(pci, snd_ca0106_ids); | |
1326 | ||
1327 | // pci_driver definition | |
1328 | static struct pci_driver driver = { | |
1329 | .name = "CA0106", | |
1330 | .id_table = snd_ca0106_ids, | |
1331 | .probe = snd_ca0106_probe, | |
1332 | .remove = __devexit_p(snd_ca0106_remove), | |
1333 | }; | |
1334 | ||
1335 | // initialization of the module | |
1336 | static int __init alsa_card_ca0106_init(void) | |
1337 | { | |
1338 | int err; | |
1339 | ||
01d25d46 | 1340 | if ((err = pci_register_driver(&driver)) > 0) |
1da177e4 LT |
1341 | return err; |
1342 | ||
1343 | return 0; | |
1344 | } | |
1345 | ||
1346 | // clean up the module | |
1347 | static void __exit alsa_card_ca0106_exit(void) | |
1348 | { | |
1349 | pci_unregister_driver(&driver); | |
1350 | } | |
1351 | ||
1352 | module_init(alsa_card_ca0106_init) | |
1353 | module_exit(alsa_card_ca0106_exit) |