2 * C-Media CMI8788 driver - PCM code
4 * Copyright (c) Clemens Ladisch <clemens@ladisch.de>
7 * This driver is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License, version 2.
10 * This driver is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with this driver; if not, write to the Free Software
17 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 #include <sound/driver.h>
21 #include <linux/pci.h>
22 #include <sound/control.h>
23 #include <sound/core.h>
24 #include <sound/pcm.h>
25 #include <sound/pcm_params.h>
28 static struct snd_pcm_hardware oxygen_hardware[PCM_COUNT] = {
30 .info = SNDRV_PCM_INFO_MMAP |
31 SNDRV_PCM_INFO_MMAP_VALID |
32 SNDRV_PCM_INFO_INTERLEAVED |
33 SNDRV_PCM_INFO_PAUSE |
34 SNDRV_PCM_INFO_SYNC_START,
35 .formats = SNDRV_PCM_FMTBIT_S16_LE |
36 SNDRV_PCM_FMTBIT_S32_LE,
37 .rates = SNDRV_PCM_RATE_44100 |
38 SNDRV_PCM_RATE_48000 |
39 SNDRV_PCM_RATE_96000 |
40 SNDRV_PCM_RATE_192000,
45 .buffer_bytes_max = 256 * 1024,
46 .period_bytes_min = 128,
47 .period_bytes_max = 128 * 1024,
52 .info = SNDRV_PCM_INFO_MMAP |
53 SNDRV_PCM_INFO_MMAP_VALID |
54 SNDRV_PCM_INFO_INTERLEAVED |
55 SNDRV_PCM_INFO_PAUSE |
56 SNDRV_PCM_INFO_SYNC_START,
57 .formats = SNDRV_PCM_FMTBIT_S16_LE |
58 SNDRV_PCM_FMTBIT_S32_LE,
59 .rates = SNDRV_PCM_RATE_32000 |
60 SNDRV_PCM_RATE_44100 |
61 SNDRV_PCM_RATE_48000 |
62 SNDRV_PCM_RATE_64000 |
63 SNDRV_PCM_RATE_88200 |
64 SNDRV_PCM_RATE_96000 |
65 SNDRV_PCM_RATE_176400 |
66 SNDRV_PCM_RATE_192000,
71 .buffer_bytes_max = 256 * 1024,
72 .period_bytes_min = 128,
73 .period_bytes_max = 128 * 1024,
78 .info = SNDRV_PCM_INFO_MMAP |
79 SNDRV_PCM_INFO_MMAP_VALID |
80 SNDRV_PCM_INFO_INTERLEAVED |
81 SNDRV_PCM_INFO_PAUSE |
82 SNDRV_PCM_INFO_SYNC_START,
83 .formats = SNDRV_PCM_FMTBIT_S16_LE |
84 SNDRV_PCM_FMTBIT_S32_LE,
85 .rates = SNDRV_PCM_RATE_44100 |
86 SNDRV_PCM_RATE_48000 |
87 SNDRV_PCM_RATE_88200 |
93 .buffer_bytes_max = 256 * 1024,
94 .period_bytes_min = 128,
95 .period_bytes_max = 128 * 1024,
100 .info = SNDRV_PCM_INFO_MMAP |
101 SNDRV_PCM_INFO_MMAP_VALID |
102 SNDRV_PCM_INFO_INTERLEAVED |
103 SNDRV_PCM_INFO_PAUSE |
104 SNDRV_PCM_INFO_SYNC_START,
105 .formats = SNDRV_PCM_FMTBIT_S16_LE |
106 SNDRV_PCM_FMTBIT_S32_LE,
107 .rates = SNDRV_PCM_RATE_32000 |
108 SNDRV_PCM_RATE_44100 |
109 SNDRV_PCM_RATE_48000 |
110 SNDRV_PCM_RATE_64000 |
111 SNDRV_PCM_RATE_88200 |
112 SNDRV_PCM_RATE_96000 |
113 SNDRV_PCM_RATE_176400 |
114 SNDRV_PCM_RATE_192000,
119 .buffer_bytes_max = 256 * 1024,
120 .period_bytes_min = 128,
121 .period_bytes_max = 128 * 1024,
126 .info = SNDRV_PCM_INFO_MMAP |
127 SNDRV_PCM_INFO_MMAP_VALID |
128 SNDRV_PCM_INFO_INTERLEAVED |
129 SNDRV_PCM_INFO_PAUSE |
130 SNDRV_PCM_INFO_SYNC_START,
131 .formats = SNDRV_PCM_FMTBIT_S16_LE |
132 SNDRV_PCM_FMTBIT_S32_LE,
133 .rates = SNDRV_PCM_RATE_32000 |
134 SNDRV_PCM_RATE_44100 |
135 SNDRV_PCM_RATE_48000 |
136 SNDRV_PCM_RATE_64000 |
137 SNDRV_PCM_RATE_88200 |
138 SNDRV_PCM_RATE_96000 |
139 SNDRV_PCM_RATE_176400 |
140 SNDRV_PCM_RATE_192000,
145 .buffer_bytes_max = 2048 * 1024,
146 .period_bytes_min = 128,
147 .period_bytes_max = 256 * 1024,
149 .periods_max = 16384,
152 .info = SNDRV_PCM_INFO_MMAP |
153 SNDRV_PCM_INFO_MMAP_VALID |
154 SNDRV_PCM_INFO_INTERLEAVED |
155 SNDRV_PCM_INFO_PAUSE |
156 SNDRV_PCM_INFO_SYNC_START,
157 .formats = SNDRV_PCM_FMTBIT_S16_LE,
158 .rates = SNDRV_PCM_RATE_48000,
163 .buffer_bytes_max = 256 * 1024,
164 .period_bytes_min = 128,
165 .period_bytes_max = 128 * 1024,
171 static int oxygen_open(struct snd_pcm_substream *substream,
172 unsigned int channel)
174 struct oxygen *chip = snd_pcm_substream_chip(substream);
175 struct snd_pcm_runtime *runtime = substream->runtime;
178 runtime->private_data = (void *)channel;
179 runtime->hw = oxygen_hardware[channel];
180 err = snd_pcm_hw_constraint_step(runtime, 0,
181 SNDRV_PCM_HW_PARAM_PERIOD_BYTES, 32);
184 err = snd_pcm_hw_constraint_step(runtime, 0,
185 SNDRV_PCM_HW_PARAM_BUFFER_BYTES, 32);
188 if (runtime->hw.formats & SNDRV_PCM_FMTBIT_S32_LE) {
189 err = snd_pcm_hw_constraint_msbits(runtime, 0, 32, 24);
193 if (runtime->hw.channels_max > 2) {
194 err = snd_pcm_hw_constraint_step(runtime, 0,
195 SNDRV_PCM_HW_PARAM_CHANNELS,
200 snd_pcm_set_sync(substream);
201 chip->streams[channel] = substream;
203 mutex_lock(&chip->mutex);
204 chip->pcm_active |= 1 << channel;
205 if (channel == PCM_SPDIF) {
206 chip->spdif_pcm_bits = chip->spdif_bits;
207 chip->spdif_pcm_ctl->vd[0].access &=
208 ~SNDRV_CTL_ELEM_ACCESS_INACTIVE;
209 snd_ctl_notify(chip->card, SNDRV_CTL_EVENT_MASK_VALUE |
210 SNDRV_CTL_EVENT_MASK_INFO,
211 &chip->spdif_pcm_ctl->id);
213 mutex_unlock(&chip->mutex);
218 static int oxygen_rec_a_open(struct snd_pcm_substream *substream)
220 return oxygen_open(substream, PCM_A);
223 static int oxygen_rec_b_open(struct snd_pcm_substream *substream)
225 return oxygen_open(substream, PCM_B);
228 static int oxygen_rec_c_open(struct snd_pcm_substream *substream)
230 return oxygen_open(substream, PCM_C);
233 static int oxygen_spdif_open(struct snd_pcm_substream *substream)
235 return oxygen_open(substream, PCM_SPDIF);
238 static int oxygen_multich_open(struct snd_pcm_substream *substream)
240 return oxygen_open(substream, PCM_MULTICH);
243 static int oxygen_ac97_open(struct snd_pcm_substream *substream)
245 return oxygen_open(substream, PCM_AC97);
248 static int oxygen_close(struct snd_pcm_substream *substream)
250 struct oxygen *chip = snd_pcm_substream_chip(substream);
251 unsigned int channel = (unsigned int)substream->runtime->private_data;
253 mutex_lock(&chip->mutex);
254 chip->pcm_active &= ~(1 << channel);
255 if (channel == PCM_SPDIF) {
256 chip->spdif_pcm_ctl->vd[0].access |=
257 SNDRV_CTL_ELEM_ACCESS_INACTIVE;
258 snd_ctl_notify(chip->card, SNDRV_CTL_EVENT_MASK_VALUE |
259 SNDRV_CTL_EVENT_MASK_INFO,
260 &chip->spdif_pcm_ctl->id);
262 if (channel == PCM_SPDIF || channel == PCM_MULTICH)
263 oxygen_update_spdif_source(chip);
264 mutex_unlock(&chip->mutex);
266 chip->streams[channel] = NULL;
270 static unsigned int oxygen_format(struct snd_pcm_hw_params *hw_params)
272 if (params_format(hw_params) == SNDRV_PCM_FORMAT_S32_LE)
273 return OXYGEN_FORMAT_24;
275 return OXYGEN_FORMAT_16;
278 static unsigned int oxygen_rate(struct snd_pcm_hw_params *hw_params)
280 switch (params_rate(hw_params)) {
282 return OXYGEN_RATE_32000;
284 return OXYGEN_RATE_44100;
286 return OXYGEN_RATE_48000;
288 return OXYGEN_RATE_64000;
290 return OXYGEN_RATE_88200;
292 return OXYGEN_RATE_96000;
294 return OXYGEN_RATE_176400;
296 return OXYGEN_RATE_192000;
300 static unsigned int oxygen_i2s_magic2(struct snd_pcm_hw_params *hw_params)
302 return params_rate(hw_params) <= 96000 ? 0x10 : 0x00;
305 static unsigned int oxygen_i2s_format(struct snd_pcm_hw_params *hw_params)
307 if (params_format(hw_params) == SNDRV_PCM_FORMAT_S32_LE)
308 return OXYGEN_I2S_FORMAT_24;
310 return OXYGEN_I2S_FORMAT_16;
313 static unsigned int oxygen_play_channels(struct snd_pcm_hw_params *hw_params)
315 switch (params_channels(hw_params)) {
317 return OXYGEN_PLAY_CHANNELS_2;
319 return OXYGEN_PLAY_CHANNELS_4;
321 return OXYGEN_PLAY_CHANNELS_6;
323 return OXYGEN_PLAY_CHANNELS_8;
327 static const unsigned int channel_base_registers[PCM_COUNT] = {
328 [PCM_A] = OXYGEN_DMA_A_ADDRESS,
329 [PCM_B] = OXYGEN_DMA_B_ADDRESS,
330 [PCM_C] = OXYGEN_DMA_C_ADDRESS,
331 [PCM_SPDIF] = OXYGEN_DMA_SPDIF_ADDRESS,
332 [PCM_MULTICH] = OXYGEN_DMA_MULTICH_ADDRESS,
333 [PCM_AC97] = OXYGEN_DMA_AC97_ADDRESS,
336 static int oxygen_hw_params(struct snd_pcm_substream *substream,
337 struct snd_pcm_hw_params *hw_params)
339 struct oxygen *chip = snd_pcm_substream_chip(substream);
340 unsigned int channel = (unsigned int)substream->runtime->private_data;
343 err = snd_pcm_lib_malloc_pages(substream,
344 params_buffer_bytes(hw_params));
348 oxygen_write32(chip, channel_base_registers[channel],
349 (u32)substream->runtime->dma_addr);
350 if (channel == PCM_MULTICH) {
351 oxygen_write32(chip, OXYGEN_DMA_MULTICH_COUNT,
352 params_buffer_bytes(hw_params) / 4 - 1);
353 oxygen_write32(chip, OXYGEN_DMA_MULTICH_TCOUNT,
354 params_period_bytes(hw_params) / 4 - 1);
356 oxygen_write16(chip, channel_base_registers[channel] + 4,
357 params_buffer_bytes(hw_params) / 4 - 1);
358 oxygen_write16(chip, channel_base_registers[channel] + 6,
359 params_period_bytes(hw_params) / 4 - 1);
364 static int oxygen_rec_a_hw_params(struct snd_pcm_substream *substream,
365 struct snd_pcm_hw_params *hw_params)
367 struct oxygen *chip = snd_pcm_substream_chip(substream);
370 err = oxygen_hw_params(substream, hw_params);
374 spin_lock_irq(&chip->reg_lock);
375 oxygen_write8_masked(chip, OXYGEN_REC_FORMAT,
376 oxygen_format(hw_params) << OXYGEN_REC_FORMAT_A_SHIFT,
377 OXYGEN_REC_FORMAT_A_MASK);
378 oxygen_write8_masked(chip, OXYGEN_I2S_A_FORMAT,
379 oxygen_rate(hw_params) |
380 oxygen_i2s_magic2(hw_params) |
381 oxygen_i2s_format(hw_params),
382 OXYGEN_I2S_RATE_MASK |
383 OXYGEN_I2S_MAGIC2_MASK |
384 OXYGEN_I2S_FORMAT_MASK);
385 oxygen_clear_bits8(chip, OXYGEN_REC_ROUTING, 0x08);
386 spin_unlock_irq(&chip->reg_lock);
388 mutex_lock(&chip->mutex);
389 chip->model->set_adc_params(chip, hw_params);
390 mutex_unlock(&chip->mutex);
394 static int oxygen_rec_b_hw_params(struct snd_pcm_substream *substream,
395 struct snd_pcm_hw_params *hw_params)
397 struct oxygen *chip = snd_pcm_substream_chip(substream);
400 err = oxygen_hw_params(substream, hw_params);
404 spin_lock_irq(&chip->reg_lock);
405 oxygen_write8_masked(chip, OXYGEN_REC_FORMAT,
406 oxygen_format(hw_params) << OXYGEN_REC_FORMAT_B_SHIFT,
407 OXYGEN_REC_FORMAT_B_MASK);
408 oxygen_write8_masked(chip, OXYGEN_I2S_B_FORMAT,
409 oxygen_rate(hw_params) |
410 oxygen_i2s_magic2(hw_params) |
411 oxygen_i2s_format(hw_params),
412 OXYGEN_I2S_RATE_MASK |
413 OXYGEN_I2S_MAGIC2_MASK |
414 OXYGEN_I2S_FORMAT_MASK);
415 oxygen_clear_bits8(chip, OXYGEN_REC_ROUTING, 0x10);
416 spin_unlock_irq(&chip->reg_lock);
418 mutex_lock(&chip->mutex);
419 chip->model->set_adc_params(chip, hw_params);
420 mutex_unlock(&chip->mutex);
424 static int oxygen_rec_c_hw_params(struct snd_pcm_substream *substream,
425 struct snd_pcm_hw_params *hw_params)
427 struct oxygen *chip = snd_pcm_substream_chip(substream);
430 err = oxygen_hw_params(substream, hw_params);
434 spin_lock_irq(&chip->reg_lock);
435 oxygen_write8_masked(chip, OXYGEN_REC_FORMAT,
436 oxygen_format(hw_params) << OXYGEN_REC_FORMAT_C_SHIFT,
437 OXYGEN_REC_FORMAT_C_MASK);
438 oxygen_clear_bits8(chip, OXYGEN_REC_ROUTING, 0x20);
439 spin_unlock_irq(&chip->reg_lock);
443 static int oxygen_spdif_hw_params(struct snd_pcm_substream *substream,
444 struct snd_pcm_hw_params *hw_params)
446 struct oxygen *chip = snd_pcm_substream_chip(substream);
449 err = oxygen_hw_params(substream, hw_params);
453 spin_lock_irq(&chip->reg_lock);
454 oxygen_clear_bits32(chip, OXYGEN_SPDIF_CONTROL,
455 OXYGEN_SPDIF_OUT_ENABLE);
456 oxygen_write8_masked(chip, OXYGEN_PLAY_FORMAT,
457 oxygen_format(hw_params) << OXYGEN_SPDIF_FORMAT_SHIFT,
458 OXYGEN_SPDIF_FORMAT_MASK);
459 oxygen_write32_masked(chip, OXYGEN_SPDIF_CONTROL,
460 oxygen_rate(hw_params) << OXYGEN_SPDIF_OUT_RATE_SHIFT,
461 OXYGEN_SPDIF_OUT_RATE_MASK);
462 oxygen_update_spdif_source(chip);
463 spin_unlock_irq(&chip->reg_lock);
467 static int oxygen_multich_hw_params(struct snd_pcm_substream *substream,
468 struct snd_pcm_hw_params *hw_params)
470 struct oxygen *chip = snd_pcm_substream_chip(substream);
473 err = oxygen_hw_params(substream, hw_params);
477 spin_lock_irq(&chip->reg_lock);
478 oxygen_write8_masked(chip, OXYGEN_PLAY_CHANNELS,
479 oxygen_play_channels(hw_params),
480 OXYGEN_PLAY_CHANNELS_MASK);
481 oxygen_write8_masked(chip, OXYGEN_PLAY_FORMAT,
482 oxygen_format(hw_params) << OXYGEN_MULTICH_FORMAT_SHIFT,
483 OXYGEN_MULTICH_FORMAT_MASK);
484 oxygen_write16_masked(chip, OXYGEN_I2S_MULTICH_FORMAT,
485 oxygen_rate(hw_params) | oxygen_i2s_format(hw_params),
486 OXYGEN_I2S_RATE_MASK | OXYGEN_I2S_FORMAT_MASK);
487 oxygen_clear_bits16(chip, OXYGEN_PLAY_ROUTING, 0x001f);
488 oxygen_update_dac_routing(chip);
489 oxygen_update_spdif_source(chip);
490 spin_unlock_irq(&chip->reg_lock);
492 mutex_lock(&chip->mutex);
493 chip->model->set_dac_params(chip, hw_params);
494 mutex_unlock(&chip->mutex);
498 static int oxygen_ac97_hw_params(struct snd_pcm_substream *substream,
499 struct snd_pcm_hw_params *hw_params)
501 struct oxygen *chip = snd_pcm_substream_chip(substream);
504 err = oxygen_hw_params(substream, hw_params);
508 spin_lock_irq(&chip->reg_lock);
509 oxygen_write8_masked(chip, OXYGEN_PLAY_FORMAT,
510 oxygen_format(hw_params) << OXYGEN_AC97_FORMAT_SHIFT,
511 OXYGEN_AC97_FORMAT_MASK);
512 spin_unlock_irq(&chip->reg_lock);
516 static int oxygen_hw_free(struct snd_pcm_substream *substream)
518 struct oxygen *chip = snd_pcm_substream_chip(substream);
519 unsigned int channel = (unsigned int)substream->runtime->private_data;
521 spin_lock_irq(&chip->reg_lock);
522 chip->interrupt_mask &= ~(1 << channel);
523 oxygen_write16(chip, OXYGEN_INTERRUPT_MASK, chip->interrupt_mask);
524 spin_unlock_irq(&chip->reg_lock);
526 return snd_pcm_lib_free_pages(substream);
529 static int oxygen_spdif_hw_free(struct snd_pcm_substream *substream)
531 struct oxygen *chip = snd_pcm_substream_chip(substream);
533 spin_lock_irq(&chip->reg_lock);
534 oxygen_clear_bits32(chip, OXYGEN_SPDIF_CONTROL,
535 OXYGEN_SPDIF_OUT_ENABLE);
536 spin_unlock_irq(&chip->reg_lock);
537 return oxygen_hw_free(substream);
540 static int oxygen_prepare(struct snd_pcm_substream *substream)
542 struct oxygen *chip = snd_pcm_substream_chip(substream);
543 unsigned int channel = (unsigned int)substream->runtime->private_data;
544 unsigned int channel_mask = 1 << channel;
546 spin_lock_irq(&chip->reg_lock);
547 oxygen_set_bits8(chip, OXYGEN_DMA_FLUSH, channel_mask);
548 oxygen_clear_bits8(chip, OXYGEN_DMA_FLUSH, channel_mask);
550 chip->interrupt_mask |= channel_mask;
551 oxygen_write16(chip, OXYGEN_INTERRUPT_MASK, chip->interrupt_mask);
552 spin_unlock_irq(&chip->reg_lock);
556 static int oxygen_trigger(struct snd_pcm_substream *substream, int cmd)
558 struct oxygen *chip = snd_pcm_substream_chip(substream);
559 struct snd_pcm_substream *s;
560 unsigned int mask = 0;
564 case SNDRV_PCM_TRIGGER_STOP:
565 case SNDRV_PCM_TRIGGER_PAUSE_PUSH:
568 case SNDRV_PCM_TRIGGER_START:
569 case SNDRV_PCM_TRIGGER_PAUSE_RELEASE:
576 snd_pcm_group_for_each_entry(s, substream) {
577 if (snd_pcm_substream_chip(s) == chip) {
578 mask |= 1 << (unsigned int)s->runtime->private_data;
579 snd_pcm_trigger_done(s, substream);
583 spin_lock(&chip->reg_lock);
585 chip->pcm_running |= mask;
587 chip->pcm_running &= ~mask;
588 oxygen_write8(chip, OXYGEN_DMA_STATUS, chip->pcm_running);
589 spin_unlock(&chip->reg_lock);
593 static snd_pcm_uframes_t oxygen_pointer(struct snd_pcm_substream *substream)
595 struct oxygen *chip = snd_pcm_substream_chip(substream);
596 struct snd_pcm_runtime *runtime = substream->runtime;
597 unsigned int channel = (unsigned int)runtime->private_data;
600 /* no spinlock, this read should be atomic */
601 curr_addr = oxygen_read32(chip, channel_base_registers[channel]);
602 return bytes_to_frames(runtime, curr_addr - (u32)runtime->dma_addr);
605 static struct snd_pcm_ops oxygen_rec_a_ops = {
606 .open = oxygen_rec_a_open,
607 .close = oxygen_close,
608 .ioctl = snd_pcm_lib_ioctl,
609 .hw_params = oxygen_rec_a_hw_params,
610 .hw_free = oxygen_hw_free,
611 .prepare = oxygen_prepare,
612 .trigger = oxygen_trigger,
613 .pointer = oxygen_pointer,
616 static struct snd_pcm_ops oxygen_rec_b_ops = {
617 .open = oxygen_rec_b_open,
618 .close = oxygen_close,
619 .ioctl = snd_pcm_lib_ioctl,
620 .hw_params = oxygen_rec_b_hw_params,
621 .hw_free = oxygen_hw_free,
622 .prepare = oxygen_prepare,
623 .trigger = oxygen_trigger,
624 .pointer = oxygen_pointer,
627 static struct snd_pcm_ops oxygen_rec_c_ops = {
628 .open = oxygen_rec_c_open,
629 .close = oxygen_close,
630 .ioctl = snd_pcm_lib_ioctl,
631 .hw_params = oxygen_rec_c_hw_params,
632 .hw_free = oxygen_hw_free,
633 .prepare = oxygen_prepare,
634 .trigger = oxygen_trigger,
635 .pointer = oxygen_pointer,
638 static struct snd_pcm_ops oxygen_spdif_ops = {
639 .open = oxygen_spdif_open,
640 .close = oxygen_close,
641 .ioctl = snd_pcm_lib_ioctl,
642 .hw_params = oxygen_spdif_hw_params,
643 .hw_free = oxygen_spdif_hw_free,
644 .prepare = oxygen_prepare,
645 .trigger = oxygen_trigger,
646 .pointer = oxygen_pointer,
649 static struct snd_pcm_ops oxygen_multich_ops = {
650 .open = oxygen_multich_open,
651 .close = oxygen_close,
652 .ioctl = snd_pcm_lib_ioctl,
653 .hw_params = oxygen_multich_hw_params,
654 .hw_free = oxygen_hw_free,
655 .prepare = oxygen_prepare,
656 .trigger = oxygen_trigger,
657 .pointer = oxygen_pointer,
660 static struct snd_pcm_ops oxygen_ac97_ops = {
661 .open = oxygen_ac97_open,
662 .close = oxygen_close,
663 .ioctl = snd_pcm_lib_ioctl,
664 .hw_params = oxygen_ac97_hw_params,
665 .hw_free = oxygen_hw_free,
666 .prepare = oxygen_prepare,
667 .trigger = oxygen_trigger,
668 .pointer = oxygen_pointer,
671 static void oxygen_pcm_free(struct snd_pcm *pcm)
673 snd_pcm_lib_preallocate_free_for_all(pcm);
676 int __devinit oxygen_pcm_init(struct oxygen *chip)
681 err = snd_pcm_new(chip->card, "Analog", 0, 1, 1, &pcm);
684 snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_PLAYBACK, &oxygen_multich_ops);
685 snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_CAPTURE,
686 chip->model->record_from_dma_b ?
687 &oxygen_rec_b_ops : &oxygen_rec_a_ops);
688 pcm->private_data = chip;
689 pcm->private_free = oxygen_pcm_free;
690 strcpy(pcm->name, "Analog");
691 snd_pcm_lib_preallocate_pages(pcm->streams[SNDRV_PCM_STREAM_PLAYBACK].substream,
693 snd_dma_pci_data(chip->pci),
694 512 * 1024, 2048 * 1024);
695 snd_pcm_lib_preallocate_pages(pcm->streams[SNDRV_PCM_STREAM_CAPTURE].substream,
697 snd_dma_pci_data(chip->pci),
698 128 * 1024, 256 * 1024);
700 err = snd_pcm_new(chip->card, "Digital", 1, 1, 1, &pcm);
703 snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_PLAYBACK, &oxygen_spdif_ops);
704 snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_CAPTURE, &oxygen_rec_c_ops);
705 pcm->private_data = chip;
706 pcm->private_free = oxygen_pcm_free;
707 strcpy(pcm->name, "Digital");
708 snd_pcm_lib_preallocate_pages_for_all(pcm, SNDRV_DMA_TYPE_DEV,
709 snd_dma_pci_data(chip->pci),
710 128 * 1024, 256 * 1024);
712 if (chip->has_2nd_ac97_codec) {
713 err = snd_pcm_new(chip->card, "AC97", 2, 1, 0, &pcm);
716 snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_PLAYBACK,
718 pcm->private_data = chip;
719 pcm->private_free = oxygen_pcm_free;
720 strcpy(pcm->name, "Front Panel");
721 snd_pcm_lib_preallocate_pages_for_all(pcm, SNDRV_DMA_TYPE_DEV,
722 snd_dma_pci_data(chip->pci),
723 128 * 1024, 256 * 1024);