2 * ALSA driver for Echoaudio soundcards.
3 * Copyright (C) 2003-2004 Giuliano Pochini <pochini@shiny.it>
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; version 2 of the License.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
19 MODULE_AUTHOR("Giuliano Pochini <pochini@shiny.it>");
20 MODULE_LICENSE("GPL v2");
21 MODULE_DESCRIPTION("Echoaudio " ECHOCARD_NAME " soundcards driver");
22 MODULE_SUPPORTED_DEVICE("{{Echoaudio," ECHOCARD_NAME "}}");
23 MODULE_DEVICE_TABLE(pci, snd_echo_ids);
25 static int index[SNDRV_CARDS] = SNDRV_DEFAULT_IDX;
26 static char *id[SNDRV_CARDS] = SNDRV_DEFAULT_STR;
27 static int enable[SNDRV_CARDS] = SNDRV_DEFAULT_ENABLE_PNP;
29 module_param_array(index, int, NULL, 0444);
30 MODULE_PARM_DESC(index, "Index value for " ECHOCARD_NAME " soundcard.");
31 module_param_array(id, charp, NULL, 0444);
32 MODULE_PARM_DESC(id, "ID string for " ECHOCARD_NAME " soundcard.");
33 module_param_array(enable, bool, NULL, 0444);
34 MODULE_PARM_DESC(enable, "Enable " ECHOCARD_NAME " soundcard.");
36 static unsigned int channels_list[10] = {1, 2, 4, 6, 8, 10, 12, 14, 16, 999999};
37 static const DECLARE_TLV_DB_SCALE(db_scale_output_gain, -12800, 100, 1);
39 static int get_firmware(const struct firmware **fw_entry,
40 const struct firmware *frm, struct echoaudio *chip)
44 DE_ACT(("firmware requested: %s\n", frm->data));
45 snprintf(name, sizeof(name), "ea/%s", frm->data);
46 if ((err = request_firmware(fw_entry, name, pci_device(chip))) < 0)
47 snd_printk(KERN_ERR "get_firmware(): Firmware not available (%d)\n", err);
51 static void free_firmware(const struct firmware *fw_entry)
53 release_firmware(fw_entry);
54 DE_ACT(("firmware released\n"));
59 /******************************************************************************
61 ******************************************************************************/
63 static void audiopipe_free(struct snd_pcm_runtime *runtime)
65 struct audiopipe *pipe = runtime->private_data;
67 if (pipe->sgpage.area)
68 snd_dma_free_pages(&pipe->sgpage);
74 static int hw_rule_capture_format_by_channels(struct snd_pcm_hw_params *params,
75 struct snd_pcm_hw_rule *rule)
77 struct snd_interval *c = hw_param_interval(params,
78 SNDRV_PCM_HW_PARAM_CHANNELS);
79 struct snd_mask *f = hw_param_mask(params, SNDRV_PCM_HW_PARAM_FORMAT);
84 #ifndef ECHOCARD_HAS_STEREO_BIG_ENDIAN32
85 /* >=2 channels cannot be S32_BE */
87 fmt.bits[0] &= ~SNDRV_PCM_FMTBIT_S32_BE;
88 return snd_mask_refine(f, &fmt);
91 /* > 2 channels cannot be U8 and S32_BE */
93 fmt.bits[0] &= ~(SNDRV_PCM_FMTBIT_U8 | SNDRV_PCM_FMTBIT_S32_BE);
94 return snd_mask_refine(f, &fmt);
96 /* Mono is ok with any format */
102 static int hw_rule_capture_channels_by_format(struct snd_pcm_hw_params *params,
103 struct snd_pcm_hw_rule *rule)
105 struct snd_interval *c = hw_param_interval(params,
106 SNDRV_PCM_HW_PARAM_CHANNELS);
107 struct snd_mask *f = hw_param_mask(params, SNDRV_PCM_HW_PARAM_FORMAT);
108 struct snd_interval ch;
110 snd_interval_any(&ch);
112 /* S32_BE is mono (and stereo) only */
113 if (f->bits[0] == SNDRV_PCM_FMTBIT_S32_BE) {
115 #ifdef ECHOCARD_HAS_STEREO_BIG_ENDIAN32
121 return snd_interval_refine(c, &ch);
123 /* U8 can be only mono or stereo */
124 if (f->bits[0] == SNDRV_PCM_FMTBIT_U8) {
128 return snd_interval_refine(c, &ch);
130 /* S16_LE, S24_3LE and S32_LE support any number of channels. */
136 static int hw_rule_playback_format_by_channels(struct snd_pcm_hw_params *params,
137 struct snd_pcm_hw_rule *rule)
139 struct snd_interval *c = hw_param_interval(params,
140 SNDRV_PCM_HW_PARAM_CHANNELS);
141 struct snd_mask *f = hw_param_mask(params, SNDRV_PCM_HW_PARAM_FORMAT);
146 fmask = fmt.bits[0] + ((u64)fmt.bits[1] << 32);
148 /* >2 channels must be S16_LE, S24_3LE or S32_LE */
150 fmask &= SNDRV_PCM_FMTBIT_S16_LE |
151 SNDRV_PCM_FMTBIT_S24_3LE |
152 SNDRV_PCM_FMTBIT_S32_LE;
153 /* 1 channel must be S32_BE or S32_LE */
154 } else if (c->max == 1)
155 fmask &= SNDRV_PCM_FMTBIT_S32_LE | SNDRV_PCM_FMTBIT_S32_BE;
156 #ifndef ECHOCARD_HAS_STEREO_BIG_ENDIAN32
157 /* 2 channels cannot be S32_BE */
158 else if (c->min == 2 && c->max == 2)
159 fmask &= ~SNDRV_PCM_FMTBIT_S32_BE;
164 fmt.bits[0] &= (u32)fmask;
165 fmt.bits[1] &= (u32)(fmask >> 32);
166 return snd_mask_refine(f, &fmt);
171 static int hw_rule_playback_channels_by_format(struct snd_pcm_hw_params *params,
172 struct snd_pcm_hw_rule *rule)
174 struct snd_interval *c = hw_param_interval(params,
175 SNDRV_PCM_HW_PARAM_CHANNELS);
176 struct snd_mask *f = hw_param_mask(params, SNDRV_PCM_HW_PARAM_FORMAT);
177 struct snd_interval ch;
180 snd_interval_any(&ch);
182 fmask = f->bits[0] + ((u64)f->bits[1] << 32);
184 /* S32_BE is mono (and stereo) only */
185 if (fmask == SNDRV_PCM_FMTBIT_S32_BE) {
187 #ifdef ECHOCARD_HAS_STEREO_BIG_ENDIAN32
192 /* U8 is stereo only */
193 } else if (fmask == SNDRV_PCM_FMTBIT_U8)
195 /* S16_LE and S24_3LE must be at least stereo */
196 else if (!(fmask & ~(SNDRV_PCM_FMTBIT_S16_LE |
197 SNDRV_PCM_FMTBIT_S24_3LE)))
202 return snd_interval_refine(c, &ch);
207 /* Since the sample rate is a global setting, do allow the user to change the
208 sample rate only if there is only one pcm device open. */
209 static int hw_rule_sample_rate(struct snd_pcm_hw_params *params,
210 struct snd_pcm_hw_rule *rule)
212 struct snd_interval *rate = hw_param_interval(params,
213 SNDRV_PCM_HW_PARAM_RATE);
214 struct echoaudio *chip = rule->private;
215 struct snd_interval fixed;
217 if (!chip->can_set_rate) {
218 snd_interval_any(&fixed);
219 fixed.min = fixed.max = chip->sample_rate;
220 return snd_interval_refine(rate, &fixed);
226 static int pcm_open(struct snd_pcm_substream *substream,
227 signed char max_channels)
229 struct echoaudio *chip;
230 struct snd_pcm_runtime *runtime;
231 struct audiopipe *pipe;
234 if (max_channels <= 0)
237 chip = snd_pcm_substream_chip(substream);
238 runtime = substream->runtime;
240 pipe = kzalloc(sizeof(struct audiopipe), GFP_KERNEL);
243 pipe->index = -1; /* Not configured yet */
245 /* Set up hw capabilities and contraints */
246 memcpy(&pipe->hw, &pcm_hardware_skel, sizeof(struct snd_pcm_hardware));
247 DE_HWP(("max_channels=%d\n", max_channels));
248 pipe->constr.list = channels_list;
249 pipe->constr.mask = 0;
250 for (i = 0; channels_list[i] <= max_channels; i++);
251 pipe->constr.count = i;
252 if (pipe->hw.channels_max > max_channels)
253 pipe->hw.channels_max = max_channels;
254 if (chip->digital_mode == DIGITAL_MODE_ADAT) {
255 pipe->hw.rate_max = 48000;
256 pipe->hw.rates &= SNDRV_PCM_RATE_8000_48000;
259 runtime->hw = pipe->hw;
260 runtime->private_data = pipe;
261 runtime->private_free = audiopipe_free;
262 snd_pcm_set_sync(substream);
264 /* Only mono and any even number of channels are allowed */
265 if ((err = snd_pcm_hw_constraint_list(runtime, 0,
266 SNDRV_PCM_HW_PARAM_CHANNELS,
270 /* All periods should have the same size */
271 if ((err = snd_pcm_hw_constraint_integer(runtime,
272 SNDRV_PCM_HW_PARAM_PERIODS)) < 0)
275 /* The hw accesses memory in chunks 32 frames long and they should be
276 32-bytes-aligned. It's not a requirement, but it seems that IRQs are
277 generated with a resolution of 32 frames. Thus we need the following */
278 if ((err = snd_pcm_hw_constraint_step(runtime, 0,
279 SNDRV_PCM_HW_PARAM_PERIOD_SIZE,
282 if ((err = snd_pcm_hw_constraint_step(runtime, 0,
283 SNDRV_PCM_HW_PARAM_BUFFER_SIZE,
287 if ((err = snd_pcm_hw_rule_add(substream->runtime, 0,
288 SNDRV_PCM_HW_PARAM_RATE,
289 hw_rule_sample_rate, chip,
290 SNDRV_PCM_HW_PARAM_RATE, -1)) < 0)
293 /* Finally allocate a page for the scatter-gather list */
294 if ((err = snd_dma_alloc_pages(SNDRV_DMA_TYPE_DEV,
295 snd_dma_pci_data(chip->pci),
296 PAGE_SIZE, &pipe->sgpage)) < 0) {
297 DE_HWP(("s-g list allocation failed\n"));
306 static int pcm_analog_in_open(struct snd_pcm_substream *substream)
308 struct echoaudio *chip = snd_pcm_substream_chip(substream);
311 DE_ACT(("pcm_analog_in_open\n"));
312 if ((err = pcm_open(substream, num_analog_busses_in(chip) -
313 substream->number)) < 0)
315 if ((err = snd_pcm_hw_rule_add(substream->runtime, 0,
316 SNDRV_PCM_HW_PARAM_CHANNELS,
317 hw_rule_capture_channels_by_format, NULL,
318 SNDRV_PCM_HW_PARAM_FORMAT, -1)) < 0)
320 if ((err = snd_pcm_hw_rule_add(substream->runtime, 0,
321 SNDRV_PCM_HW_PARAM_FORMAT,
322 hw_rule_capture_format_by_channels, NULL,
323 SNDRV_PCM_HW_PARAM_CHANNELS, -1)) < 0)
325 atomic_inc(&chip->opencount);
326 if (atomic_read(&chip->opencount) > 1 && chip->rate_set)
327 chip->can_set_rate=0;
328 DE_HWP(("pcm_analog_in_open cs=%d oc=%d r=%d\n",
329 chip->can_set_rate, atomic_read(&chip->opencount),
336 static int pcm_analog_out_open(struct snd_pcm_substream *substream)
338 struct echoaudio *chip = snd_pcm_substream_chip(substream);
339 int max_channels, err;
341 #ifdef ECHOCARD_HAS_VMIXER
342 max_channels = num_pipes_out(chip);
344 max_channels = num_analog_busses_out(chip);
346 DE_ACT(("pcm_analog_out_open\n"));
347 if ((err = pcm_open(substream, max_channels - substream->number)) < 0)
349 if ((err = snd_pcm_hw_rule_add(substream->runtime, 0,
350 SNDRV_PCM_HW_PARAM_CHANNELS,
351 hw_rule_playback_channels_by_format,
353 SNDRV_PCM_HW_PARAM_FORMAT, -1)) < 0)
355 if ((err = snd_pcm_hw_rule_add(substream->runtime, 0,
356 SNDRV_PCM_HW_PARAM_FORMAT,
357 hw_rule_playback_format_by_channels,
359 SNDRV_PCM_HW_PARAM_CHANNELS, -1)) < 0)
361 atomic_inc(&chip->opencount);
362 if (atomic_read(&chip->opencount) > 1 && chip->rate_set)
363 chip->can_set_rate=0;
364 DE_HWP(("pcm_analog_out_open cs=%d oc=%d r=%d\n",
365 chip->can_set_rate, atomic_read(&chip->opencount),
372 #ifdef ECHOCARD_HAS_DIGITAL_IO
374 static int pcm_digital_in_open(struct snd_pcm_substream *substream)
376 struct echoaudio *chip = snd_pcm_substream_chip(substream);
377 int err, max_channels;
379 DE_ACT(("pcm_digital_in_open\n"));
380 max_channels = num_digital_busses_in(chip) - substream->number;
381 mutex_lock(&chip->mode_mutex);
382 if (chip->digital_mode == DIGITAL_MODE_ADAT)
383 err = pcm_open(substream, max_channels);
384 else /* If the card has ADAT, subtract the 6 channels
385 * that S/PDIF doesn't have
387 err = pcm_open(substream, max_channels - ECHOCARD_HAS_ADAT);
392 if ((err = snd_pcm_hw_rule_add(substream->runtime, 0,
393 SNDRV_PCM_HW_PARAM_CHANNELS,
394 hw_rule_capture_channels_by_format, NULL,
395 SNDRV_PCM_HW_PARAM_FORMAT, -1)) < 0)
397 if ((err = snd_pcm_hw_rule_add(substream->runtime, 0,
398 SNDRV_PCM_HW_PARAM_FORMAT,
399 hw_rule_capture_format_by_channels, NULL,
400 SNDRV_PCM_HW_PARAM_CHANNELS, -1)) < 0)
403 atomic_inc(&chip->opencount);
404 if (atomic_read(&chip->opencount) > 1 && chip->rate_set)
405 chip->can_set_rate=0;
408 mutex_unlock(&chip->mode_mutex);
414 #ifndef ECHOCARD_HAS_VMIXER /* See the note in snd_echo_new_pcm() */
416 static int pcm_digital_out_open(struct snd_pcm_substream *substream)
418 struct echoaudio *chip = snd_pcm_substream_chip(substream);
419 int err, max_channels;
421 DE_ACT(("pcm_digital_out_open\n"));
422 max_channels = num_digital_busses_out(chip) - substream->number;
423 mutex_lock(&chip->mode_mutex);
424 if (chip->digital_mode == DIGITAL_MODE_ADAT)
425 err = pcm_open(substream, max_channels);
426 else /* If the card has ADAT, subtract the 6 channels
427 * that S/PDIF doesn't have
429 err = pcm_open(substream, max_channels - ECHOCARD_HAS_ADAT);
434 if ((err = snd_pcm_hw_rule_add(substream->runtime, 0,
435 SNDRV_PCM_HW_PARAM_CHANNELS,
436 hw_rule_playback_channels_by_format,
437 NULL, SNDRV_PCM_HW_PARAM_FORMAT,
440 if ((err = snd_pcm_hw_rule_add(substream->runtime, 0,
441 SNDRV_PCM_HW_PARAM_FORMAT,
442 hw_rule_playback_format_by_channels,
443 NULL, SNDRV_PCM_HW_PARAM_CHANNELS,
446 atomic_inc(&chip->opencount);
447 if (atomic_read(&chip->opencount) > 1 && chip->rate_set)
448 chip->can_set_rate=0;
450 mutex_unlock(&chip->mode_mutex);
454 #endif /* !ECHOCARD_HAS_VMIXER */
456 #endif /* ECHOCARD_HAS_DIGITAL_IO */
460 static int pcm_close(struct snd_pcm_substream *substream)
462 struct echoaudio *chip = snd_pcm_substream_chip(substream);
465 /* Nothing to do here. Audio is already off and pipe will be
466 * freed by its callback
468 DE_ACT(("pcm_close\n"));
470 atomic_dec(&chip->opencount);
471 oc = atomic_read(&chip->opencount);
472 DE_ACT(("pcm_close oc=%d cs=%d rs=%d\n", oc,
473 chip->can_set_rate, chip->rate_set));
475 chip->can_set_rate = 1;
478 DE_ACT(("pcm_close2 oc=%d cs=%d rs=%d\n", oc,
479 chip->can_set_rate,chip->rate_set));
486 /* Channel allocation and scatter-gather list setup */
487 static int init_engine(struct snd_pcm_substream *substream,
488 struct snd_pcm_hw_params *hw_params,
489 int pipe_index, int interleave)
491 struct echoaudio *chip;
492 int err, per, rest, page, edge, offs;
493 struct audiopipe *pipe;
495 chip = snd_pcm_substream_chip(substream);
496 pipe = (struct audiopipe *) substream->runtime->private_data;
498 /* Sets up che hardware. If it's already initialized, reset and
499 * redo with the new parameters
501 spin_lock_irq(&chip->lock);
502 if (pipe->index >= 0) {
503 DE_HWP(("hwp_ie free(%d)\n", pipe->index));
504 err = free_pipes(chip, pipe);
506 chip->substream[pipe->index] = NULL;
509 err = allocate_pipes(chip, pipe, pipe_index, interleave);
511 spin_unlock_irq(&chip->lock);
512 DE_ACT((KERN_NOTICE "allocate_pipes(%d) err=%d\n",
516 spin_unlock_irq(&chip->lock);
517 DE_ACT((KERN_NOTICE "allocate_pipes()=%d\n", pipe_index));
519 DE_HWP(("pcm_hw_params (bufsize=%dB periods=%d persize=%dB)\n",
520 params_buffer_bytes(hw_params), params_periods(hw_params),
521 params_period_bytes(hw_params)));
522 err = snd_pcm_lib_malloc_pages(substream,
523 params_buffer_bytes(hw_params));
525 snd_printk(KERN_ERR "malloc_pages err=%d\n", err);
526 spin_lock_irq(&chip->lock);
527 free_pipes(chip, pipe);
528 spin_unlock_irq(&chip->lock);
533 sglist_init(chip, pipe);
535 for (offs = page = per = 0; offs < params_buffer_bytes(hw_params);
537 rest = params_period_bytes(hw_params);
538 if (offs + rest > params_buffer_bytes(hw_params))
539 rest = params_buffer_bytes(hw_params) - offs;
542 addr = snd_pcm_sgbuf_get_addr(substream, offs);
543 if (rest <= edge - offs) {
544 sglist_add_mapping(chip, pipe, addr, rest);
545 sglist_add_irq(chip, pipe);
549 sglist_add_mapping(chip, pipe, addr,
561 /* Close the ring buffer */
562 sglist_wrap(chip, pipe);
564 /* This stuff is used by the irq handler, so it must be
565 * initialized before chip->substream
567 chip->last_period[pipe_index] = 0;
568 pipe->last_counter = 0;
571 chip->substream[pipe_index] = substream;
573 spin_lock_irq(&chip->lock);
574 set_sample_rate(chip, hw_params->rate_num / hw_params->rate_den);
575 spin_unlock_irq(&chip->lock);
576 DE_HWP(("pcm_hw_params ok\n"));
582 static int pcm_analog_in_hw_params(struct snd_pcm_substream *substream,
583 struct snd_pcm_hw_params *hw_params)
585 struct echoaudio *chip = snd_pcm_substream_chip(substream);
587 return init_engine(substream, hw_params, px_analog_in(chip) +
588 substream->number, params_channels(hw_params));
593 static int pcm_analog_out_hw_params(struct snd_pcm_substream *substream,
594 struct snd_pcm_hw_params *hw_params)
596 return init_engine(substream, hw_params, substream->number,
597 params_channels(hw_params));
602 #ifdef ECHOCARD_HAS_DIGITAL_IO
604 static int pcm_digital_in_hw_params(struct snd_pcm_substream *substream,
605 struct snd_pcm_hw_params *hw_params)
607 struct echoaudio *chip = snd_pcm_substream_chip(substream);
609 return init_engine(substream, hw_params, px_digital_in(chip) +
610 substream->number, params_channels(hw_params));
615 #ifndef ECHOCARD_HAS_VMIXER /* See the note in snd_echo_new_pcm() */
616 static int pcm_digital_out_hw_params(struct snd_pcm_substream *substream,
617 struct snd_pcm_hw_params *hw_params)
619 struct echoaudio *chip = snd_pcm_substream_chip(substream);
621 return init_engine(substream, hw_params, px_digital_out(chip) +
622 substream->number, params_channels(hw_params));
624 #endif /* !ECHOCARD_HAS_VMIXER */
626 #endif /* ECHOCARD_HAS_DIGITAL_IO */
630 static int pcm_hw_free(struct snd_pcm_substream *substream)
632 struct echoaudio *chip;
633 struct audiopipe *pipe;
635 chip = snd_pcm_substream_chip(substream);
636 pipe = (struct audiopipe *) substream->runtime->private_data;
638 spin_lock_irq(&chip->lock);
639 if (pipe->index >= 0) {
640 DE_HWP(("pcm_hw_free(%d)\n", pipe->index));
641 free_pipes(chip, pipe);
642 chip->substream[pipe->index] = NULL;
645 spin_unlock_irq(&chip->lock);
647 DE_HWP(("pcm_hw_freed\n"));
648 snd_pcm_lib_free_pages(substream);
654 static int pcm_prepare(struct snd_pcm_substream *substream)
656 struct echoaudio *chip = snd_pcm_substream_chip(substream);
657 struct snd_pcm_runtime *runtime = substream->runtime;
658 struct audioformat format;
659 int pipe_index = ((struct audiopipe *)runtime->private_data)->index;
661 DE_HWP(("Prepare rate=%d format=%d channels=%d\n",
662 runtime->rate, runtime->format, runtime->channels));
663 format.interleave = runtime->channels;
664 format.data_are_bigendian = 0;
665 format.mono_to_stereo = 0;
666 switch (runtime->format) {
667 case SNDRV_PCM_FORMAT_U8:
668 format.bits_per_sample = 8;
670 case SNDRV_PCM_FORMAT_S16_LE:
671 format.bits_per_sample = 16;
673 case SNDRV_PCM_FORMAT_S24_3LE:
674 format.bits_per_sample = 24;
676 case SNDRV_PCM_FORMAT_S32_BE:
677 format.data_are_bigendian = 1;
678 case SNDRV_PCM_FORMAT_S32_LE:
679 format.bits_per_sample = 32;
682 DE_HWP(("Prepare error: unsupported format %d\n",
687 if (snd_BUG_ON(pipe_index >= px_num(chip)))
689 if (snd_BUG_ON(!is_pipe_allocated(chip, pipe_index)))
691 set_audio_format(chip, pipe_index, &format);
697 static int pcm_trigger(struct snd_pcm_substream *substream, int cmd)
699 struct echoaudio *chip = snd_pcm_substream_chip(substream);
700 struct snd_pcm_runtime *runtime = substream->runtime;
701 struct audiopipe *pipe = runtime->private_data;
704 struct snd_pcm_substream *s;
706 snd_pcm_group_for_each_entry(s, substream) {
707 for (i = 0; i < DSP_MAXPIPES; i++) {
708 if (s == chip->substream[i]) {
709 channelmask |= 1 << i;
710 snd_pcm_trigger_done(s, substream);
715 spin_lock(&chip->lock);
717 case SNDRV_PCM_TRIGGER_START:
718 case SNDRV_PCM_TRIGGER_PAUSE_RELEASE:
719 DE_ACT(("pcm_trigger start\n"));
720 for (i = 0; i < DSP_MAXPIPES; i++) {
721 if (channelmask & (1 << i)) {
722 pipe = chip->substream[i]->runtime->private_data;
723 switch (pipe->state) {
724 case PIPE_STATE_STOPPED:
725 chip->last_period[i] = 0;
726 pipe->last_counter = 0;
728 *pipe->dma_counter = 0;
729 case PIPE_STATE_PAUSED:
730 pipe->state = PIPE_STATE_STARTED;
732 case PIPE_STATE_STARTED:
737 err = start_transport(chip, channelmask,
738 chip->pipe_cyclic_mask);
740 case SNDRV_PCM_TRIGGER_STOP:
741 DE_ACT(("pcm_trigger stop\n"));
742 for (i = 0; i < DSP_MAXPIPES; i++) {
743 if (channelmask & (1 << i)) {
744 pipe = chip->substream[i]->runtime->private_data;
745 pipe->state = PIPE_STATE_STOPPED;
748 err = stop_transport(chip, channelmask);
750 case SNDRV_PCM_TRIGGER_PAUSE_PUSH:
751 DE_ACT(("pcm_trigger pause\n"));
752 for (i = 0; i < DSP_MAXPIPES; i++) {
753 if (channelmask & (1 << i)) {
754 pipe = chip->substream[i]->runtime->private_data;
755 pipe->state = PIPE_STATE_PAUSED;
758 err = pause_transport(chip, channelmask);
763 spin_unlock(&chip->lock);
769 static snd_pcm_uframes_t pcm_pointer(struct snd_pcm_substream *substream)
771 struct snd_pcm_runtime *runtime = substream->runtime;
772 struct audiopipe *pipe = runtime->private_data;
773 size_t cnt, bufsize, pos;
775 cnt = le32_to_cpu(*pipe->dma_counter);
776 pipe->position += cnt - pipe->last_counter;
777 pipe->last_counter = cnt;
778 bufsize = substream->runtime->buffer_size;
779 pos = bytes_to_frames(substream->runtime, pipe->position);
781 while (pos >= bufsize) {
782 pipe->position -= frames_to_bytes(substream->runtime, bufsize);
790 /* pcm *_ops structures */
791 static struct snd_pcm_ops analog_playback_ops = {
792 .open = pcm_analog_out_open,
794 .ioctl = snd_pcm_lib_ioctl,
795 .hw_params = pcm_analog_out_hw_params,
796 .hw_free = pcm_hw_free,
797 .prepare = pcm_prepare,
798 .trigger = pcm_trigger,
799 .pointer = pcm_pointer,
800 .page = snd_pcm_sgbuf_ops_page,
802 static struct snd_pcm_ops analog_capture_ops = {
803 .open = pcm_analog_in_open,
805 .ioctl = snd_pcm_lib_ioctl,
806 .hw_params = pcm_analog_in_hw_params,
807 .hw_free = pcm_hw_free,
808 .prepare = pcm_prepare,
809 .trigger = pcm_trigger,
810 .pointer = pcm_pointer,
811 .page = snd_pcm_sgbuf_ops_page,
813 #ifdef ECHOCARD_HAS_DIGITAL_IO
814 #ifndef ECHOCARD_HAS_VMIXER
815 static struct snd_pcm_ops digital_playback_ops = {
816 .open = pcm_digital_out_open,
818 .ioctl = snd_pcm_lib_ioctl,
819 .hw_params = pcm_digital_out_hw_params,
820 .hw_free = pcm_hw_free,
821 .prepare = pcm_prepare,
822 .trigger = pcm_trigger,
823 .pointer = pcm_pointer,
824 .page = snd_pcm_sgbuf_ops_page,
826 #endif /* !ECHOCARD_HAS_VMIXER */
827 static struct snd_pcm_ops digital_capture_ops = {
828 .open = pcm_digital_in_open,
830 .ioctl = snd_pcm_lib_ioctl,
831 .hw_params = pcm_digital_in_hw_params,
832 .hw_free = pcm_hw_free,
833 .prepare = pcm_prepare,
834 .trigger = pcm_trigger,
835 .pointer = pcm_pointer,
836 .page = snd_pcm_sgbuf_ops_page,
838 #endif /* ECHOCARD_HAS_DIGITAL_IO */
842 /* Preallocate memory only for the first substream because it's the most
845 static int snd_echo_preallocate_pages(struct snd_pcm *pcm, struct device *dev)
847 struct snd_pcm_substream *ss;
850 for (stream = 0; stream < 2; stream++)
851 for (ss = pcm->streams[stream].substream; ss; ss = ss->next) {
852 err = snd_pcm_lib_preallocate_pages(ss, SNDRV_DMA_TYPE_DEV_SG,
854 ss->number ? 0 : 128<<10,
864 /*<--snd_echo_probe() */
865 static int __devinit snd_echo_new_pcm(struct echoaudio *chip)
870 #ifdef ECHOCARD_HAS_VMIXER
871 /* This card has a Vmixer, that is there is no direct mapping from PCM
872 streams to physical outputs. The user can mix the streams as he wishes
873 via control interface and it's possible to send any stream to any
874 output, thus it makes no sense to keep analog and digital outputs
877 /* PCM#0 Virtual outputs and analog inputs */
878 if ((err = snd_pcm_new(chip->card, "PCM", 0, num_pipes_out(chip),
879 num_analog_busses_in(chip), &pcm)) < 0)
881 pcm->private_data = chip;
882 chip->analog_pcm = pcm;
883 strcpy(pcm->name, chip->card->shortname);
884 snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_PLAYBACK, &analog_playback_ops);
885 snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_CAPTURE, &analog_capture_ops);
886 if ((err = snd_echo_preallocate_pages(pcm, snd_dma_pci_data(chip->pci))) < 0)
888 DE_INIT(("Analog PCM ok\n"));
890 #ifdef ECHOCARD_HAS_DIGITAL_IO
891 /* PCM#1 Digital inputs, no outputs */
892 if ((err = snd_pcm_new(chip->card, "Digital PCM", 1, 0,
893 num_digital_busses_in(chip), &pcm)) < 0)
895 pcm->private_data = chip;
896 chip->digital_pcm = pcm;
897 strcpy(pcm->name, chip->card->shortname);
898 snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_CAPTURE, &digital_capture_ops);
899 if ((err = snd_echo_preallocate_pages(pcm, snd_dma_pci_data(chip->pci))) < 0)
901 DE_INIT(("Digital PCM ok\n"));
902 #endif /* ECHOCARD_HAS_DIGITAL_IO */
904 #else /* ECHOCARD_HAS_VMIXER */
906 /* The card can manage substreams formed by analog and digital channels
907 at the same time, but I prefer to keep analog and digital channels
908 separated, because that mixed thing is confusing and useless. So we
909 register two PCM devices: */
911 /* PCM#0 Analog i/o */
912 if ((err = snd_pcm_new(chip->card, "Analog PCM", 0,
913 num_analog_busses_out(chip),
914 num_analog_busses_in(chip), &pcm)) < 0)
916 pcm->private_data = chip;
917 chip->analog_pcm = pcm;
918 strcpy(pcm->name, chip->card->shortname);
919 snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_PLAYBACK, &analog_playback_ops);
920 snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_CAPTURE, &analog_capture_ops);
921 if ((err = snd_echo_preallocate_pages(pcm, snd_dma_pci_data(chip->pci))) < 0)
923 DE_INIT(("Analog PCM ok\n"));
925 #ifdef ECHOCARD_HAS_DIGITAL_IO
926 /* PCM#1 Digital i/o */
927 if ((err = snd_pcm_new(chip->card, "Digital PCM", 1,
928 num_digital_busses_out(chip),
929 num_digital_busses_in(chip), &pcm)) < 0)
931 pcm->private_data = chip;
932 chip->digital_pcm = pcm;
933 strcpy(pcm->name, chip->card->shortname);
934 snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_PLAYBACK, &digital_playback_ops);
935 snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_CAPTURE, &digital_capture_ops);
936 if ((err = snd_echo_preallocate_pages(pcm, snd_dma_pci_data(chip->pci))) < 0)
938 DE_INIT(("Digital PCM ok\n"));
939 #endif /* ECHOCARD_HAS_DIGITAL_IO */
941 #endif /* ECHOCARD_HAS_VMIXER */
949 /******************************************************************************
951 ******************************************************************************/
953 #ifndef ECHOCARD_HAS_VMIXER
955 /******************* PCM output volume *******************/
956 static int snd_echo_output_gain_info(struct snd_kcontrol *kcontrol,
957 struct snd_ctl_elem_info *uinfo)
959 struct echoaudio *chip;
961 chip = snd_kcontrol_chip(kcontrol);
962 uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER;
963 uinfo->count = num_busses_out(chip);
964 uinfo->value.integer.min = ECHOGAIN_MINOUT;
965 uinfo->value.integer.max = ECHOGAIN_MAXOUT;
969 static int snd_echo_output_gain_get(struct snd_kcontrol *kcontrol,
970 struct snd_ctl_elem_value *ucontrol)
972 struct echoaudio *chip;
975 chip = snd_kcontrol_chip(kcontrol);
976 for (c = 0; c < num_busses_out(chip); c++)
977 ucontrol->value.integer.value[c] = chip->output_gain[c];
981 static int snd_echo_output_gain_put(struct snd_kcontrol *kcontrol,
982 struct snd_ctl_elem_value *ucontrol)
984 struct echoaudio *chip;
985 int c, changed, gain;
988 chip = snd_kcontrol_chip(kcontrol);
989 spin_lock_irq(&chip->lock);
990 for (c = 0; c < num_busses_out(chip); c++) {
991 gain = ucontrol->value.integer.value[c];
992 /* Ignore out of range values */
993 if (gain < ECHOGAIN_MINOUT || gain > ECHOGAIN_MAXOUT)
995 if (chip->output_gain[c] != gain) {
996 set_output_gain(chip, c, gain);
1001 update_output_line_level(chip);
1002 spin_unlock_irq(&chip->lock);
1006 static struct snd_kcontrol_new snd_echo_pcm_output_gain __devinitdata = {
1007 .name = "PCM Playback Volume",
1008 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1009 .access = SNDRV_CTL_ELEM_ACCESS_READWRITE | SNDRV_CTL_ELEM_ACCESS_TLV_READ,
1010 .info = snd_echo_output_gain_info,
1011 .get = snd_echo_output_gain_get,
1012 .put = snd_echo_output_gain_put,
1013 .tlv = {.p = db_scale_output_gain},
1020 #ifdef ECHOCARD_HAS_INPUT_GAIN
1022 /******************* Analog input volume *******************/
1023 static int snd_echo_input_gain_info(struct snd_kcontrol *kcontrol,
1024 struct snd_ctl_elem_info *uinfo)
1026 struct echoaudio *chip;
1028 chip = snd_kcontrol_chip(kcontrol);
1029 uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER;
1030 uinfo->count = num_analog_busses_in(chip);
1031 uinfo->value.integer.min = ECHOGAIN_MININP;
1032 uinfo->value.integer.max = ECHOGAIN_MAXINP;
1036 static int snd_echo_input_gain_get(struct snd_kcontrol *kcontrol,
1037 struct snd_ctl_elem_value *ucontrol)
1039 struct echoaudio *chip;
1042 chip = snd_kcontrol_chip(kcontrol);
1043 for (c = 0; c < num_analog_busses_in(chip); c++)
1044 ucontrol->value.integer.value[c] = chip->input_gain[c];
1048 static int snd_echo_input_gain_put(struct snd_kcontrol *kcontrol,
1049 struct snd_ctl_elem_value *ucontrol)
1051 struct echoaudio *chip;
1052 int c, gain, changed;
1055 chip = snd_kcontrol_chip(kcontrol);
1056 spin_lock_irq(&chip->lock);
1057 for (c = 0; c < num_analog_busses_in(chip); c++) {
1058 gain = ucontrol->value.integer.value[c];
1059 /* Ignore out of range values */
1060 if (gain < ECHOGAIN_MININP || gain > ECHOGAIN_MAXINP)
1062 if (chip->input_gain[c] != gain) {
1063 set_input_gain(chip, c, gain);
1068 update_input_line_level(chip);
1069 spin_unlock_irq(&chip->lock);
1073 static const DECLARE_TLV_DB_SCALE(db_scale_input_gain, -2500, 50, 0);
1075 static struct snd_kcontrol_new snd_echo_line_input_gain __devinitdata = {
1076 .name = "Line Capture Volume",
1077 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1078 .access = SNDRV_CTL_ELEM_ACCESS_READWRITE | SNDRV_CTL_ELEM_ACCESS_TLV_READ,
1079 .info = snd_echo_input_gain_info,
1080 .get = snd_echo_input_gain_get,
1081 .put = snd_echo_input_gain_put,
1082 .tlv = {.p = db_scale_input_gain},
1085 #endif /* ECHOCARD_HAS_INPUT_GAIN */
1089 #ifdef ECHOCARD_HAS_OUTPUT_NOMINAL_LEVEL
1091 /************ Analog output nominal level (+4dBu / -10dBV) ***************/
1092 static int snd_echo_output_nominal_info (struct snd_kcontrol *kcontrol,
1093 struct snd_ctl_elem_info *uinfo)
1095 struct echoaudio *chip;
1097 chip = snd_kcontrol_chip(kcontrol);
1098 uinfo->type = SNDRV_CTL_ELEM_TYPE_BOOLEAN;
1099 uinfo->count = num_analog_busses_out(chip);
1100 uinfo->value.integer.min = 0;
1101 uinfo->value.integer.max = 1;
1105 static int snd_echo_output_nominal_get(struct snd_kcontrol *kcontrol,
1106 struct snd_ctl_elem_value *ucontrol)
1108 struct echoaudio *chip;
1111 chip = snd_kcontrol_chip(kcontrol);
1112 for (c = 0; c < num_analog_busses_out(chip); c++)
1113 ucontrol->value.integer.value[c] = chip->nominal_level[c];
1117 static int snd_echo_output_nominal_put(struct snd_kcontrol *kcontrol,
1118 struct snd_ctl_elem_value *ucontrol)
1120 struct echoaudio *chip;
1124 chip = snd_kcontrol_chip(kcontrol);
1125 spin_lock_irq(&chip->lock);
1126 for (c = 0; c < num_analog_busses_out(chip); c++) {
1127 if (chip->nominal_level[c] != ucontrol->value.integer.value[c]) {
1128 set_nominal_level(chip, c,
1129 ucontrol->value.integer.value[c]);
1134 update_output_line_level(chip);
1135 spin_unlock_irq(&chip->lock);
1139 static struct snd_kcontrol_new snd_echo_output_nominal_level __devinitdata = {
1140 .name = "Line Playback Switch (-10dBV)",
1141 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1142 .info = snd_echo_output_nominal_info,
1143 .get = snd_echo_output_nominal_get,
1144 .put = snd_echo_output_nominal_put,
1147 #endif /* ECHOCARD_HAS_OUTPUT_NOMINAL_LEVEL */
1151 #ifdef ECHOCARD_HAS_INPUT_NOMINAL_LEVEL
1153 /*************** Analog input nominal level (+4dBu / -10dBV) ***************/
1154 static int snd_echo_input_nominal_info(struct snd_kcontrol *kcontrol,
1155 struct snd_ctl_elem_info *uinfo)
1157 struct echoaudio *chip;
1159 chip = snd_kcontrol_chip(kcontrol);
1160 uinfo->type = SNDRV_CTL_ELEM_TYPE_BOOLEAN;
1161 uinfo->count = num_analog_busses_in(chip);
1162 uinfo->value.integer.min = 0;
1163 uinfo->value.integer.max = 1;
1167 static int snd_echo_input_nominal_get(struct snd_kcontrol *kcontrol,
1168 struct snd_ctl_elem_value *ucontrol)
1170 struct echoaudio *chip;
1173 chip = snd_kcontrol_chip(kcontrol);
1174 for (c = 0; c < num_analog_busses_in(chip); c++)
1175 ucontrol->value.integer.value[c] =
1176 chip->nominal_level[bx_analog_in(chip) + c];
1180 static int snd_echo_input_nominal_put(struct snd_kcontrol *kcontrol,
1181 struct snd_ctl_elem_value *ucontrol)
1183 struct echoaudio *chip;
1187 chip = snd_kcontrol_chip(kcontrol);
1188 spin_lock_irq(&chip->lock);
1189 for (c = 0; c < num_analog_busses_in(chip); c++) {
1190 if (chip->nominal_level[bx_analog_in(chip) + c] !=
1191 ucontrol->value.integer.value[c]) {
1192 set_nominal_level(chip, bx_analog_in(chip) + c,
1193 ucontrol->value.integer.value[c]);
1198 update_output_line_level(chip); /* "Output" is not a mistake
1201 spin_unlock_irq(&chip->lock);
1205 static struct snd_kcontrol_new snd_echo_intput_nominal_level __devinitdata = {
1206 .name = "Line Capture Switch (-10dBV)",
1207 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1208 .info = snd_echo_input_nominal_info,
1209 .get = snd_echo_input_nominal_get,
1210 .put = snd_echo_input_nominal_put,
1213 #endif /* ECHOCARD_HAS_INPUT_NOMINAL_LEVEL */
1217 #ifdef ECHOCARD_HAS_MONITOR
1219 /******************* Monitor mixer *******************/
1220 static int snd_echo_mixer_info(struct snd_kcontrol *kcontrol,
1221 struct snd_ctl_elem_info *uinfo)
1223 struct echoaudio *chip;
1225 chip = snd_kcontrol_chip(kcontrol);
1226 uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER;
1228 uinfo->value.integer.min = ECHOGAIN_MINOUT;
1229 uinfo->value.integer.max = ECHOGAIN_MAXOUT;
1230 uinfo->dimen.d[0] = num_busses_out(chip);
1231 uinfo->dimen.d[1] = num_busses_in(chip);
1235 static int snd_echo_mixer_get(struct snd_kcontrol *kcontrol,
1236 struct snd_ctl_elem_value *ucontrol)
1238 struct echoaudio *chip;
1240 chip = snd_kcontrol_chip(kcontrol);
1241 ucontrol->value.integer.value[0] =
1242 chip->monitor_gain[ucontrol->id.index / num_busses_in(chip)]
1243 [ucontrol->id.index % num_busses_in(chip)];
1247 static int snd_echo_mixer_put(struct snd_kcontrol *kcontrol,
1248 struct snd_ctl_elem_value *ucontrol)
1250 struct echoaudio *chip;
1255 chip = snd_kcontrol_chip(kcontrol);
1256 out = ucontrol->id.index / num_busses_in(chip);
1257 in = ucontrol->id.index % num_busses_in(chip);
1258 gain = ucontrol->value.integer.value[0];
1259 if (gain < ECHOGAIN_MINOUT || gain > ECHOGAIN_MAXOUT)
1261 if (chip->monitor_gain[out][in] != gain) {
1262 spin_lock_irq(&chip->lock);
1263 set_monitor_gain(chip, out, in, gain);
1264 update_output_line_level(chip);
1265 spin_unlock_irq(&chip->lock);
1271 static struct snd_kcontrol_new snd_echo_monitor_mixer __devinitdata = {
1272 .name = "Monitor Mixer Volume",
1273 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1274 .access = SNDRV_CTL_ELEM_ACCESS_READWRITE | SNDRV_CTL_ELEM_ACCESS_TLV_READ,
1275 .info = snd_echo_mixer_info,
1276 .get = snd_echo_mixer_get,
1277 .put = snd_echo_mixer_put,
1278 .tlv = {.p = db_scale_output_gain},
1281 #endif /* ECHOCARD_HAS_MONITOR */
1285 #ifdef ECHOCARD_HAS_VMIXER
1287 /******************* Vmixer *******************/
1288 static int snd_echo_vmixer_info(struct snd_kcontrol *kcontrol,
1289 struct snd_ctl_elem_info *uinfo)
1291 struct echoaudio *chip;
1293 chip = snd_kcontrol_chip(kcontrol);
1294 uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER;
1296 uinfo->value.integer.min = ECHOGAIN_MINOUT;
1297 uinfo->value.integer.max = ECHOGAIN_MAXOUT;
1298 uinfo->dimen.d[0] = num_busses_out(chip);
1299 uinfo->dimen.d[1] = num_pipes_out(chip);
1303 static int snd_echo_vmixer_get(struct snd_kcontrol *kcontrol,
1304 struct snd_ctl_elem_value *ucontrol)
1306 struct echoaudio *chip;
1308 chip = snd_kcontrol_chip(kcontrol);
1309 ucontrol->value.integer.value[0] =
1310 chip->vmixer_gain[ucontrol->id.index / num_pipes_out(chip)]
1311 [ucontrol->id.index % num_pipes_out(chip)];
1315 static int snd_echo_vmixer_put(struct snd_kcontrol *kcontrol,
1316 struct snd_ctl_elem_value *ucontrol)
1318 struct echoaudio *chip;
1323 chip = snd_kcontrol_chip(kcontrol);
1324 out = ucontrol->id.index / num_pipes_out(chip);
1325 vch = ucontrol->id.index % num_pipes_out(chip);
1326 gain = ucontrol->value.integer.value[0];
1327 if (gain < ECHOGAIN_MINOUT || gain > ECHOGAIN_MAXOUT)
1329 if (chip->vmixer_gain[out][vch] != ucontrol->value.integer.value[0]) {
1330 spin_lock_irq(&chip->lock);
1331 set_vmixer_gain(chip, out, vch, ucontrol->value.integer.value[0]);
1332 update_vmixer_level(chip);
1333 spin_unlock_irq(&chip->lock);
1339 static struct snd_kcontrol_new snd_echo_vmixer __devinitdata = {
1340 .name = "VMixer Volume",
1341 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1342 .access = SNDRV_CTL_ELEM_ACCESS_READWRITE | SNDRV_CTL_ELEM_ACCESS_TLV_READ,
1343 .info = snd_echo_vmixer_info,
1344 .get = snd_echo_vmixer_get,
1345 .put = snd_echo_vmixer_put,
1346 .tlv = {.p = db_scale_output_gain},
1349 #endif /* ECHOCARD_HAS_VMIXER */
1353 #ifdef ECHOCARD_HAS_DIGITAL_MODE_SWITCH
1355 /******************* Digital mode switch *******************/
1356 static int snd_echo_digital_mode_info(struct snd_kcontrol *kcontrol,
1357 struct snd_ctl_elem_info *uinfo)
1359 static char *names[4] = {
1360 "S/PDIF Coaxial", "S/PDIF Optical", "ADAT Optical",
1363 struct echoaudio *chip;
1365 chip = snd_kcontrol_chip(kcontrol);
1366 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
1367 uinfo->value.enumerated.items = chip->num_digital_modes;
1369 if (uinfo->value.enumerated.item >= chip->num_digital_modes)
1370 uinfo->value.enumerated.item = chip->num_digital_modes - 1;
1371 strcpy(uinfo->value.enumerated.name, names[
1372 chip->digital_mode_list[uinfo->value.enumerated.item]]);
1376 static int snd_echo_digital_mode_get(struct snd_kcontrol *kcontrol,
1377 struct snd_ctl_elem_value *ucontrol)
1379 struct echoaudio *chip;
1382 chip = snd_kcontrol_chip(kcontrol);
1383 mode = chip->digital_mode;
1384 for (i = chip->num_digital_modes - 1; i >= 0; i--)
1385 if (mode == chip->digital_mode_list[i]) {
1386 ucontrol->value.enumerated.item[0] = i;
1392 static int snd_echo_digital_mode_put(struct snd_kcontrol *kcontrol,
1393 struct snd_ctl_elem_value *ucontrol)
1395 struct echoaudio *chip;
1397 unsigned short emode, dmode;
1400 chip = snd_kcontrol_chip(kcontrol);
1402 emode = ucontrol->value.enumerated.item[0];
1403 if (emode >= chip->num_digital_modes)
1405 dmode = chip->digital_mode_list[emode];
1407 if (dmode != chip->digital_mode) {
1408 /* mode_mutex is required to make this operation atomic wrt
1409 pcm_digital_*_open() and set_input_clock() functions. */
1410 mutex_lock(&chip->mode_mutex);
1412 /* Do not allow the user to change the digital mode when a pcm
1413 device is open because it also changes the number of channels
1414 and the allowed sample rates */
1415 if (atomic_read(&chip->opencount)) {
1418 changed = set_digital_mode(chip, dmode);
1419 /* If we had to change the clock source, report it */
1420 if (changed > 0 && chip->clock_src_ctl) {
1421 snd_ctl_notify(chip->card,
1422 SNDRV_CTL_EVENT_MASK_VALUE,
1423 &chip->clock_src_ctl->id);
1424 DE_ACT(("SDM() =%d\n", changed));
1427 changed = 1; /* No errors */
1429 mutex_unlock(&chip->mode_mutex);
1434 static struct snd_kcontrol_new snd_echo_digital_mode_switch __devinitdata = {
1435 .name = "Digital mode Switch",
1436 .iface = SNDRV_CTL_ELEM_IFACE_CARD,
1437 .info = snd_echo_digital_mode_info,
1438 .get = snd_echo_digital_mode_get,
1439 .put = snd_echo_digital_mode_put,
1442 #endif /* ECHOCARD_HAS_DIGITAL_MODE_SWITCH */
1446 #ifdef ECHOCARD_HAS_DIGITAL_IO
1448 /******************* S/PDIF mode switch *******************/
1449 static int snd_echo_spdif_mode_info(struct snd_kcontrol *kcontrol,
1450 struct snd_ctl_elem_info *uinfo)
1452 static char *names[2] = {"Consumer", "Professional"};
1454 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
1455 uinfo->value.enumerated.items = 2;
1457 if (uinfo->value.enumerated.item)
1458 uinfo->value.enumerated.item = 1;
1459 strcpy(uinfo->value.enumerated.name,
1460 names[uinfo->value.enumerated.item]);
1464 static int snd_echo_spdif_mode_get(struct snd_kcontrol *kcontrol,
1465 struct snd_ctl_elem_value *ucontrol)
1467 struct echoaudio *chip;
1469 chip = snd_kcontrol_chip(kcontrol);
1470 ucontrol->value.enumerated.item[0] = !!chip->professional_spdif;
1474 static int snd_echo_spdif_mode_put(struct snd_kcontrol *kcontrol,
1475 struct snd_ctl_elem_value *ucontrol)
1477 struct echoaudio *chip;
1480 chip = snd_kcontrol_chip(kcontrol);
1481 mode = !!ucontrol->value.enumerated.item[0];
1482 if (mode != chip->professional_spdif) {
1483 spin_lock_irq(&chip->lock);
1484 set_professional_spdif(chip, mode);
1485 spin_unlock_irq(&chip->lock);
1491 static struct snd_kcontrol_new snd_echo_spdif_mode_switch __devinitdata = {
1492 .name = "S/PDIF mode Switch",
1493 .iface = SNDRV_CTL_ELEM_IFACE_CARD,
1494 .info = snd_echo_spdif_mode_info,
1495 .get = snd_echo_spdif_mode_get,
1496 .put = snd_echo_spdif_mode_put,
1499 #endif /* ECHOCARD_HAS_DIGITAL_IO */
1503 #ifdef ECHOCARD_HAS_EXTERNAL_CLOCK
1505 /******************* Select input clock source *******************/
1506 static int snd_echo_clock_source_info(struct snd_kcontrol *kcontrol,
1507 struct snd_ctl_elem_info *uinfo)
1509 static char *names[8] = {
1510 "Internal", "Word", "Super", "S/PDIF", "ADAT", "ESync",
1513 struct echoaudio *chip;
1515 chip = snd_kcontrol_chip(kcontrol);
1516 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
1517 uinfo->value.enumerated.items = chip->num_clock_sources;
1519 if (uinfo->value.enumerated.item >= chip->num_clock_sources)
1520 uinfo->value.enumerated.item = chip->num_clock_sources - 1;
1521 strcpy(uinfo->value.enumerated.name, names[
1522 chip->clock_source_list[uinfo->value.enumerated.item]]);
1526 static int snd_echo_clock_source_get(struct snd_kcontrol *kcontrol,
1527 struct snd_ctl_elem_value *ucontrol)
1529 struct echoaudio *chip;
1532 chip = snd_kcontrol_chip(kcontrol);
1533 clock = chip->input_clock;
1535 for (i = 0; i < chip->num_clock_sources; i++)
1536 if (clock == chip->clock_source_list[i])
1537 ucontrol->value.enumerated.item[0] = i;
1542 static int snd_echo_clock_source_put(struct snd_kcontrol *kcontrol,
1543 struct snd_ctl_elem_value *ucontrol)
1545 struct echoaudio *chip;
1547 unsigned int eclock, dclock;
1550 chip = snd_kcontrol_chip(kcontrol);
1551 eclock = ucontrol->value.enumerated.item[0];
1552 if (eclock >= chip->input_clock_types)
1554 dclock = chip->clock_source_list[eclock];
1555 if (chip->input_clock != dclock) {
1556 mutex_lock(&chip->mode_mutex);
1557 spin_lock_irq(&chip->lock);
1558 if ((changed = set_input_clock(chip, dclock)) == 0)
1559 changed = 1; /* no errors */
1560 spin_unlock_irq(&chip->lock);
1561 mutex_unlock(&chip->mode_mutex);
1565 DE_ACT(("seticlk val%d err 0x%x\n", dclock, changed));
1570 static struct snd_kcontrol_new snd_echo_clock_source_switch __devinitdata = {
1571 .name = "Sample Clock Source",
1572 .iface = SNDRV_CTL_ELEM_IFACE_PCM,
1573 .info = snd_echo_clock_source_info,
1574 .get = snd_echo_clock_source_get,
1575 .put = snd_echo_clock_source_put,
1578 #endif /* ECHOCARD_HAS_EXTERNAL_CLOCK */
1582 #ifdef ECHOCARD_HAS_PHANTOM_POWER
1584 /******************* Phantom power switch *******************/
1585 #define snd_echo_phantom_power_info snd_ctl_boolean_mono_info
1587 static int snd_echo_phantom_power_get(struct snd_kcontrol *kcontrol,
1588 struct snd_ctl_elem_value *ucontrol)
1590 struct echoaudio *chip = snd_kcontrol_chip(kcontrol);
1592 ucontrol->value.integer.value[0] = chip->phantom_power;
1596 static int snd_echo_phantom_power_put(struct snd_kcontrol *kcontrol,
1597 struct snd_ctl_elem_value *ucontrol)
1599 struct echoaudio *chip = snd_kcontrol_chip(kcontrol);
1600 int power, changed = 0;
1602 power = !!ucontrol->value.integer.value[0];
1603 if (chip->phantom_power != power) {
1604 spin_lock_irq(&chip->lock);
1605 changed = set_phantom_power(chip, power);
1606 spin_unlock_irq(&chip->lock);
1608 changed = 1; /* no errors */
1613 static struct snd_kcontrol_new snd_echo_phantom_power_switch __devinitdata = {
1614 .name = "Phantom power Switch",
1615 .iface = SNDRV_CTL_ELEM_IFACE_CARD,
1616 .info = snd_echo_phantom_power_info,
1617 .get = snd_echo_phantom_power_get,
1618 .put = snd_echo_phantom_power_put,
1621 #endif /* ECHOCARD_HAS_PHANTOM_POWER */
1625 #ifdef ECHOCARD_HAS_DIGITAL_IN_AUTOMUTE
1627 /******************* Digital input automute switch *******************/
1628 #define snd_echo_automute_info snd_ctl_boolean_mono_info
1630 static int snd_echo_automute_get(struct snd_kcontrol *kcontrol,
1631 struct snd_ctl_elem_value *ucontrol)
1633 struct echoaudio *chip = snd_kcontrol_chip(kcontrol);
1635 ucontrol->value.integer.value[0] = chip->digital_in_automute;
1639 static int snd_echo_automute_put(struct snd_kcontrol *kcontrol,
1640 struct snd_ctl_elem_value *ucontrol)
1642 struct echoaudio *chip = snd_kcontrol_chip(kcontrol);
1643 int automute, changed = 0;
1645 automute = !!ucontrol->value.integer.value[0];
1646 if (chip->digital_in_automute != automute) {
1647 spin_lock_irq(&chip->lock);
1648 changed = set_input_auto_mute(chip, automute);
1649 spin_unlock_irq(&chip->lock);
1651 changed = 1; /* no errors */
1656 static struct snd_kcontrol_new snd_echo_automute_switch __devinitdata = {
1657 .name = "Digital Capture Switch (automute)",
1658 .iface = SNDRV_CTL_ELEM_IFACE_CARD,
1659 .info = snd_echo_automute_info,
1660 .get = snd_echo_automute_get,
1661 .put = snd_echo_automute_put,
1664 #endif /* ECHOCARD_HAS_DIGITAL_IN_AUTOMUTE */
1668 /******************* VU-meters switch *******************/
1669 #define snd_echo_vumeters_switch_info snd_ctl_boolean_mono_info
1671 static int snd_echo_vumeters_switch_put(struct snd_kcontrol *kcontrol,
1672 struct snd_ctl_elem_value *ucontrol)
1674 struct echoaudio *chip;
1676 chip = snd_kcontrol_chip(kcontrol);
1677 spin_lock_irq(&chip->lock);
1678 set_meters_on(chip, ucontrol->value.integer.value[0]);
1679 spin_unlock_irq(&chip->lock);
1683 static struct snd_kcontrol_new snd_echo_vumeters_switch __devinitdata = {
1684 .name = "VU-meters Switch",
1685 .iface = SNDRV_CTL_ELEM_IFACE_CARD,
1686 .access = SNDRV_CTL_ELEM_ACCESS_WRITE,
1687 .info = snd_echo_vumeters_switch_info,
1688 .put = snd_echo_vumeters_switch_put,
1693 /***** Read VU-meters (input, output, analog and digital together) *****/
1694 static int snd_echo_vumeters_info(struct snd_kcontrol *kcontrol,
1695 struct snd_ctl_elem_info *uinfo)
1697 struct echoaudio *chip;
1699 chip = snd_kcontrol_chip(kcontrol);
1700 uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER;
1702 uinfo->value.integer.min = ECHOGAIN_MINOUT;
1703 uinfo->value.integer.max = 0;
1704 #ifdef ECHOCARD_HAS_VMIXER
1705 uinfo->dimen.d[0] = 3; /* Out, In, Virt */
1707 uinfo->dimen.d[0] = 2; /* Out, In */
1709 uinfo->dimen.d[1] = 16; /* 16 channels */
1710 uinfo->dimen.d[2] = 2; /* 0=level, 1=peak */
1714 static int snd_echo_vumeters_get(struct snd_kcontrol *kcontrol,
1715 struct snd_ctl_elem_value *ucontrol)
1717 struct echoaudio *chip;
1719 chip = snd_kcontrol_chip(kcontrol);
1720 get_audio_meters(chip, ucontrol->value.integer.value);
1724 static struct snd_kcontrol_new snd_echo_vumeters __devinitdata = {
1725 .name = "VU-meters",
1726 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1727 .access = SNDRV_CTL_ELEM_ACCESS_READ |
1728 SNDRV_CTL_ELEM_ACCESS_VOLATILE |
1729 SNDRV_CTL_ELEM_ACCESS_TLV_READ,
1730 .info = snd_echo_vumeters_info,
1731 .get = snd_echo_vumeters_get,
1732 .tlv = {.p = db_scale_output_gain},
1737 /*** Channels info - it exports informations about the number of channels ***/
1738 static int snd_echo_channels_info_info(struct snd_kcontrol *kcontrol,
1739 struct snd_ctl_elem_info *uinfo)
1741 struct echoaudio *chip;
1743 chip = snd_kcontrol_chip(kcontrol);
1744 uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER;
1746 uinfo->value.integer.min = 0;
1747 uinfo->value.integer.max = 1 << ECHO_CLOCK_NUMBER;
1751 static int snd_echo_channels_info_get(struct snd_kcontrol *kcontrol,
1752 struct snd_ctl_elem_value *ucontrol)
1754 struct echoaudio *chip;
1755 int detected, clocks, bit, src;
1757 chip = snd_kcontrol_chip(kcontrol);
1758 ucontrol->value.integer.value[0] = num_busses_in(chip);
1759 ucontrol->value.integer.value[1] = num_analog_busses_in(chip);
1760 ucontrol->value.integer.value[2] = num_busses_out(chip);
1761 ucontrol->value.integer.value[3] = num_analog_busses_out(chip);
1762 ucontrol->value.integer.value[4] = num_pipes_out(chip);
1764 /* Compute the bitmask of the currently valid input clocks */
1765 detected = detect_input_clocks(chip);
1767 src = chip->num_clock_sources - 1;
1768 for (bit = ECHO_CLOCK_NUMBER - 1; bit >= 0; bit--)
1769 if (detected & (1 << bit))
1770 for (; src >= 0; src--)
1771 if (bit == chip->clock_source_list[src]) {
1775 ucontrol->value.integer.value[5] = clocks;
1780 static struct snd_kcontrol_new snd_echo_channels_info __devinitdata = {
1781 .name = "Channels info",
1782 .iface = SNDRV_CTL_ELEM_IFACE_HWDEP,
1783 .access = SNDRV_CTL_ELEM_ACCESS_READ | SNDRV_CTL_ELEM_ACCESS_VOLATILE,
1784 .info = snd_echo_channels_info_info,
1785 .get = snd_echo_channels_info_get,
1791 /******************************************************************************
1793 ******************************************************************************/
1795 static irqreturn_t snd_echo_interrupt(int irq, void *dev_id)
1797 struct echoaudio *chip = dev_id;
1798 struct snd_pcm_substream *substream;
1801 spin_lock(&chip->lock);
1802 st = service_irq(chip);
1804 spin_unlock(&chip->lock);
1807 /* The hardware doesn't tell us which substream caused the irq,
1808 thus we have to check all running substreams. */
1809 for (ss = 0; ss < DSP_MAXPIPES; ss++) {
1810 if ((substream = chip->substream[ss])) {
1811 period = pcm_pointer(substream) /
1812 substream->runtime->period_size;
1813 if (period != chip->last_period[ss]) {
1814 chip->last_period[ss] = period;
1815 spin_unlock(&chip->lock);
1816 snd_pcm_period_elapsed(substream);
1817 spin_lock(&chip->lock);
1821 spin_unlock(&chip->lock);
1823 #ifdef ECHOCARD_HAS_MIDI
1824 if (st > 0 && chip->midi_in) {
1825 snd_rawmidi_receive(chip->midi_in, chip->midi_buffer, st);
1826 DE_MID(("rawmidi_iread=%d\n", st));
1835 /******************************************************************************
1836 Module construction / destruction
1837 ******************************************************************************/
1839 static int snd_echo_free(struct echoaudio *chip)
1841 DE_INIT(("Stop DSP...\n"));
1842 if (chip->comm_page)
1843 rest_in_peace(chip);
1844 DE_INIT(("Stopped.\n"));
1847 free_irq(chip->irq, chip);
1849 if (chip->comm_page)
1850 snd_dma_free_pages(&chip->commpage_dma_buf);
1852 if (chip->dsp_registers)
1853 iounmap(chip->dsp_registers);
1856 release_and_free_resource(chip->iores);
1858 DE_INIT(("MMIO freed.\n"));
1860 pci_disable_device(chip->pci);
1862 /* release chip data */
1864 DE_INIT(("Chip freed.\n"));
1870 static int snd_echo_dev_free(struct snd_device *device)
1872 struct echoaudio *chip = device->device_data;
1874 DE_INIT(("snd_echo_dev_free()...\n"));
1875 return snd_echo_free(chip);
1880 /* <--snd_echo_probe() */
1881 static __devinit int snd_echo_create(struct snd_card *card,
1882 struct pci_dev *pci,
1883 struct echoaudio **rchip)
1885 struct echoaudio *chip;
1888 static struct snd_device_ops ops = {
1889 .dev_free = snd_echo_dev_free,
1894 pci_write_config_byte(pci, PCI_LATENCY_TIMER, 0xC0);
1896 if ((err = pci_enable_device(pci)) < 0)
1898 pci_set_master(pci);
1900 /* allocate a chip-specific data */
1901 chip = kzalloc(sizeof(*chip), GFP_KERNEL);
1903 pci_disable_device(pci);
1906 DE_INIT(("chip=%p\n", chip));
1908 spin_lock_init(&chip->lock);
1913 /* PCI resource allocation */
1914 chip->dsp_registers_phys = pci_resource_start(pci, 0);
1915 sz = pci_resource_len(pci, 0);
1917 sz = PAGE_SIZE; /* We map only the required part */
1919 if ((chip->iores = request_mem_region(chip->dsp_registers_phys, sz,
1920 ECHOCARD_NAME)) == NULL) {
1921 snd_echo_free(chip);
1922 snd_printk(KERN_ERR "cannot get memory region\n");
1925 chip->dsp_registers = (volatile u32 __iomem *)
1926 ioremap_nocache(chip->dsp_registers_phys, sz);
1928 if (request_irq(pci->irq, snd_echo_interrupt, IRQF_SHARED,
1929 ECHOCARD_NAME, chip)) {
1930 snd_echo_free(chip);
1931 snd_printk(KERN_ERR "cannot grab irq\n");
1934 chip->irq = pci->irq;
1935 DE_INIT(("pci=%p irq=%d subdev=%04x Init hardware...\n",
1936 chip->pci, chip->irq, chip->pci->subsystem_device));
1938 /* Create the DSP comm page - this is the area of memory used for most
1939 of the communication with the DSP, which accesses it via bus mastering */
1940 if (snd_dma_alloc_pages(SNDRV_DMA_TYPE_DEV, snd_dma_pci_data(chip->pci),
1941 sizeof(struct comm_page),
1942 &chip->commpage_dma_buf) < 0) {
1943 snd_echo_free(chip);
1944 snd_printk(KERN_ERR "cannot allocate the comm page\n");
1947 chip->comm_page_phys = chip->commpage_dma_buf.addr;
1948 chip->comm_page = (struct comm_page *)chip->commpage_dma_buf.area;
1950 err = init_hw(chip, chip->pci->device, chip->pci->subsystem_device);
1952 DE_INIT(("init_hw err=%d\n", err));
1953 snd_echo_free(chip);
1956 DE_INIT(("Card init OK\n"));
1958 if ((err = snd_device_new(card, SNDRV_DEV_LOWLEVEL, chip, &ops)) < 0) {
1959 snd_echo_free(chip);
1962 atomic_set(&chip->opencount, 0);
1963 mutex_init(&chip->mode_mutex);
1964 chip->can_set_rate = 1;
1973 static int __devinit snd_echo_probe(struct pci_dev *pci,
1974 const struct pci_device_id *pci_id)
1977 struct snd_card *card;
1978 struct echoaudio *chip;
1982 if (dev >= SNDRV_CARDS)
1989 DE_INIT(("Echoaudio driver starting...\n"));
1991 err = snd_card_create(index[dev], id[dev], THIS_MODULE, 0, &card);
1995 snd_card_set_dev(card, &pci->dev);
1997 if ((err = snd_echo_create(card, pci, &chip)) < 0) {
1998 snd_card_free(card);
2002 strcpy(card->driver, "Echo_" ECHOCARD_NAME);
2003 strcpy(card->shortname, chip->card_name);
2006 if (pci_id->device == 0x3410)
2009 sprintf(card->longname, "%s rev.%d (DSP%s) at 0x%lx irq %i",
2010 card->shortname, pci_id->subdevice & 0x000f, dsp,
2011 chip->dsp_registers_phys, chip->irq);
2013 if ((err = snd_echo_new_pcm(chip)) < 0) {
2014 snd_printk(KERN_ERR "new pcm error %d\n", err);
2015 snd_card_free(card);
2019 #ifdef ECHOCARD_HAS_MIDI
2020 if (chip->has_midi) { /* Some Mia's do not have midi */
2021 if ((err = snd_echo_midi_create(card, chip)) < 0) {
2022 snd_printk(KERN_ERR "new midi error %d\n", err);
2023 snd_card_free(card);
2029 #ifdef ECHOCARD_HAS_VMIXER
2030 snd_echo_vmixer.count = num_pipes_out(chip) * num_busses_out(chip);
2031 if ((err = snd_ctl_add(chip->card, snd_ctl_new1(&snd_echo_vmixer, chip))) < 0)
2034 if ((err = snd_ctl_add(chip->card, snd_ctl_new1(&snd_echo_pcm_output_gain, chip))) < 0)
2038 #ifdef ECHOCARD_HAS_INPUT_GAIN
2039 if ((err = snd_ctl_add(chip->card, snd_ctl_new1(&snd_echo_line_input_gain, chip))) < 0)
2043 #ifdef ECHOCARD_HAS_INPUT_NOMINAL_LEVEL
2044 if (!chip->hasnt_input_nominal_level)
2045 if ((err = snd_ctl_add(chip->card, snd_ctl_new1(&snd_echo_intput_nominal_level, chip))) < 0)
2049 #ifdef ECHOCARD_HAS_OUTPUT_NOMINAL_LEVEL
2050 if ((err = snd_ctl_add(chip->card, snd_ctl_new1(&snd_echo_output_nominal_level, chip))) < 0)
2054 if ((err = snd_ctl_add(chip->card, snd_ctl_new1(&snd_echo_vumeters_switch, chip))) < 0)
2057 if ((err = snd_ctl_add(chip->card, snd_ctl_new1(&snd_echo_vumeters, chip))) < 0)
2060 #ifdef ECHOCARD_HAS_MONITOR
2061 snd_echo_monitor_mixer.count = num_busses_in(chip) * num_busses_out(chip);
2062 if ((err = snd_ctl_add(chip->card, snd_ctl_new1(&snd_echo_monitor_mixer, chip))) < 0)
2066 #ifdef ECHOCARD_HAS_DIGITAL_IN_AUTOMUTE
2067 if ((err = snd_ctl_add(chip->card, snd_ctl_new1(&snd_echo_automute_switch, chip))) < 0)
2071 if ((err = snd_ctl_add(chip->card, snd_ctl_new1(&snd_echo_channels_info, chip))) < 0)
2074 #ifdef ECHOCARD_HAS_DIGITAL_MODE_SWITCH
2075 /* Creates a list of available digital modes */
2076 chip->num_digital_modes = 0;
2077 for (i = 0; i < 6; i++)
2078 if (chip->digital_modes & (1 << i))
2079 chip->digital_mode_list[chip->num_digital_modes++] = i;
2081 if ((err = snd_ctl_add(chip->card, snd_ctl_new1(&snd_echo_digital_mode_switch, chip))) < 0)
2083 #endif /* ECHOCARD_HAS_DIGITAL_MODE_SWITCH */
2085 #ifdef ECHOCARD_HAS_EXTERNAL_CLOCK
2086 /* Creates a list of available clock sources */
2087 chip->num_clock_sources = 0;
2088 for (i = 0; i < 10; i++)
2089 if (chip->input_clock_types & (1 << i))
2090 chip->clock_source_list[chip->num_clock_sources++] = i;
2092 if (chip->num_clock_sources > 1) {
2093 chip->clock_src_ctl = snd_ctl_new1(&snd_echo_clock_source_switch, chip);
2094 if ((err = snd_ctl_add(chip->card, chip->clock_src_ctl)) < 0)
2097 #endif /* ECHOCARD_HAS_EXTERNAL_CLOCK */
2099 #ifdef ECHOCARD_HAS_DIGITAL_IO
2100 if ((err = snd_ctl_add(chip->card, snd_ctl_new1(&snd_echo_spdif_mode_switch, chip))) < 0)
2104 #ifdef ECHOCARD_HAS_PHANTOM_POWER
2105 if (chip->has_phantom_power)
2106 if ((err = snd_ctl_add(chip->card, snd_ctl_new1(&snd_echo_phantom_power_switch, chip))) < 0)
2110 if ((err = snd_card_register(card)) < 0) {
2111 snd_card_free(card);
2114 snd_printk(KERN_INFO "Card registered: %s\n", card->longname);
2116 pci_set_drvdata(pci, chip);
2121 snd_printk(KERN_ERR "new control error %d\n", err);
2122 snd_card_free(card);
2128 static void __devexit snd_echo_remove(struct pci_dev *pci)
2130 struct echoaudio *chip;
2132 chip = pci_get_drvdata(pci);
2134 snd_card_free(chip->card);
2135 pci_set_drvdata(pci, NULL);
2140 /******************************************************************************
2141 Everything starts and ends here
2142 ******************************************************************************/
2144 /* pci_driver definition */
2145 static struct pci_driver driver = {
2146 .name = "Echoaudio " ECHOCARD_NAME,
2147 .id_table = snd_echo_ids,
2148 .probe = snd_echo_probe,
2149 .remove = __devexit_p(snd_echo_remove),
2154 /* initialization of the module */
2155 static int __init alsa_card_echo_init(void)
2157 return pci_register_driver(&driver);
2162 /* clean up the module */
2163 static void __exit alsa_card_echo_exit(void)
2165 pci_unregister_driver(&driver);
2169 module_init(alsa_card_echo_init)
2170 module_exit(alsa_card_echo_exit)