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 <linux/pci.h>
21 #include <sound/control.h>
22 #include <sound/core.h>
23 #include <sound/pcm.h>
24 #include <sound/pcm_params.h>
27 static const struct snd_pcm_hardware oxygen_stereo_hardware
= {
28 .info
= SNDRV_PCM_INFO_MMAP
|
29 SNDRV_PCM_INFO_MMAP_VALID
|
30 SNDRV_PCM_INFO_INTERLEAVED
|
31 SNDRV_PCM_INFO_PAUSE
|
32 SNDRV_PCM_INFO_SYNC_START
,
33 .formats
= SNDRV_PCM_FMTBIT_S16_LE
|
34 SNDRV_PCM_FMTBIT_S32_LE
,
35 .rates
= SNDRV_PCM_RATE_32000
|
36 SNDRV_PCM_RATE_44100
|
37 SNDRV_PCM_RATE_48000
|
38 SNDRV_PCM_RATE_64000
|
39 SNDRV_PCM_RATE_88200
|
40 SNDRV_PCM_RATE_96000
|
41 SNDRV_PCM_RATE_176400
|
42 SNDRV_PCM_RATE_192000
,
47 .buffer_bytes_max
= 256 * 1024,
48 .period_bytes_min
= 128,
49 .period_bytes_max
= 128 * 1024,
53 static const struct snd_pcm_hardware oxygen_multichannel_hardware
= {
54 .info
= SNDRV_PCM_INFO_MMAP
|
55 SNDRV_PCM_INFO_MMAP_VALID
|
56 SNDRV_PCM_INFO_INTERLEAVED
|
57 SNDRV_PCM_INFO_PAUSE
|
58 SNDRV_PCM_INFO_SYNC_START
,
59 .formats
= SNDRV_PCM_FMTBIT_S16_LE
|
60 SNDRV_PCM_FMTBIT_S32_LE
,
61 .rates
= SNDRV_PCM_RATE_32000
|
62 SNDRV_PCM_RATE_44100
|
63 SNDRV_PCM_RATE_48000
|
64 SNDRV_PCM_RATE_64000
|
65 SNDRV_PCM_RATE_88200
|
66 SNDRV_PCM_RATE_96000
|
67 SNDRV_PCM_RATE_176400
|
68 SNDRV_PCM_RATE_192000
,
73 .buffer_bytes_max
= 2048 * 1024,
74 .period_bytes_min
= 128,
75 .period_bytes_max
= 256 * 1024,
79 static const struct snd_pcm_hardware oxygen_ac97_hardware
= {
80 .info
= SNDRV_PCM_INFO_MMAP
|
81 SNDRV_PCM_INFO_MMAP_VALID
|
82 SNDRV_PCM_INFO_INTERLEAVED
|
83 SNDRV_PCM_INFO_PAUSE
|
84 SNDRV_PCM_INFO_SYNC_START
,
85 .formats
= SNDRV_PCM_FMTBIT_S16_LE
,
86 .rates
= SNDRV_PCM_RATE_48000
,
91 .buffer_bytes_max
= 256 * 1024,
92 .period_bytes_min
= 128,
93 .period_bytes_max
= 128 * 1024,
98 static const struct snd_pcm_hardware
*const oxygen_hardware
[PCM_COUNT
] = {
99 [PCM_A
] = &oxygen_stereo_hardware
,
100 [PCM_B
] = &oxygen_stereo_hardware
,
101 [PCM_C
] = &oxygen_stereo_hardware
,
102 [PCM_SPDIF
] = &oxygen_stereo_hardware
,
103 [PCM_MULTICH
] = &oxygen_multichannel_hardware
,
104 [PCM_AC97
] = &oxygen_ac97_hardware
,
107 static inline unsigned int
108 oxygen_substream_channel(struct snd_pcm_substream
*substream
)
110 return (unsigned int)(uintptr_t)substream
->runtime
->private_data
;
113 static int oxygen_open(struct snd_pcm_substream
*substream
,
114 unsigned int channel
)
116 struct oxygen
*chip
= snd_pcm_substream_chip(substream
);
117 struct snd_pcm_runtime
*runtime
= substream
->runtime
;
120 runtime
->private_data
= (void *)(uintptr_t)channel
;
121 runtime
->hw
= *oxygen_hardware
[channel
];
124 runtime
->hw
.rates
&= ~(SNDRV_PCM_RATE_32000
|
125 SNDRV_PCM_RATE_64000
);
126 runtime
->hw
.rate_min
= 44100;
129 runtime
->hw
.channels_max
= chip
->model
->dac_channels
;
132 if (chip
->model
->pcm_hardware_filter
)
133 chip
->model
->pcm_hardware_filter(channel
, &runtime
->hw
);
134 err
= snd_pcm_hw_constraint_step(runtime
, 0,
135 SNDRV_PCM_HW_PARAM_PERIOD_BYTES
, 32);
138 err
= snd_pcm_hw_constraint_step(runtime
, 0,
139 SNDRV_PCM_HW_PARAM_BUFFER_BYTES
, 32);
142 if (runtime
->hw
.formats
& SNDRV_PCM_FMTBIT_S32_LE
) {
143 err
= snd_pcm_hw_constraint_msbits(runtime
, 0, 32, 24);
147 if (runtime
->hw
.channels_max
> 2) {
148 err
= snd_pcm_hw_constraint_step(runtime
, 0,
149 SNDRV_PCM_HW_PARAM_CHANNELS
,
154 snd_pcm_set_sync(substream
);
155 chip
->streams
[channel
] = substream
;
157 mutex_lock(&chip
->mutex
);
158 chip
->pcm_active
|= 1 << channel
;
159 if (channel
== PCM_SPDIF
) {
160 chip
->spdif_pcm_bits
= chip
->spdif_bits
;
161 chip
->controls
[CONTROL_SPDIF_PCM
]->vd
[0].access
&=
162 ~SNDRV_CTL_ELEM_ACCESS_INACTIVE
;
163 snd_ctl_notify(chip
->card
, SNDRV_CTL_EVENT_MASK_VALUE
|
164 SNDRV_CTL_EVENT_MASK_INFO
,
165 &chip
->controls
[CONTROL_SPDIF_PCM
]->id
);
167 mutex_unlock(&chip
->mutex
);
172 static int oxygen_rec_a_open(struct snd_pcm_substream
*substream
)
174 return oxygen_open(substream
, PCM_A
);
177 static int oxygen_rec_b_open(struct snd_pcm_substream
*substream
)
179 return oxygen_open(substream
, PCM_B
);
182 static int oxygen_rec_c_open(struct snd_pcm_substream
*substream
)
184 return oxygen_open(substream
, PCM_C
);
187 static int oxygen_spdif_open(struct snd_pcm_substream
*substream
)
189 return oxygen_open(substream
, PCM_SPDIF
);
192 static int oxygen_multich_open(struct snd_pcm_substream
*substream
)
194 return oxygen_open(substream
, PCM_MULTICH
);
197 static int oxygen_ac97_open(struct snd_pcm_substream
*substream
)
199 return oxygen_open(substream
, PCM_AC97
);
202 static int oxygen_close(struct snd_pcm_substream
*substream
)
204 struct oxygen
*chip
= snd_pcm_substream_chip(substream
);
205 unsigned int channel
= oxygen_substream_channel(substream
);
207 mutex_lock(&chip
->mutex
);
208 chip
->pcm_active
&= ~(1 << channel
);
209 if (channel
== PCM_SPDIF
) {
210 chip
->controls
[CONTROL_SPDIF_PCM
]->vd
[0].access
|=
211 SNDRV_CTL_ELEM_ACCESS_INACTIVE
;
212 snd_ctl_notify(chip
->card
, SNDRV_CTL_EVENT_MASK_VALUE
|
213 SNDRV_CTL_EVENT_MASK_INFO
,
214 &chip
->controls
[CONTROL_SPDIF_PCM
]->id
);
216 if (channel
== PCM_SPDIF
|| channel
== PCM_MULTICH
)
217 oxygen_update_spdif_source(chip
);
218 mutex_unlock(&chip
->mutex
);
220 chip
->streams
[channel
] = NULL
;
224 static unsigned int oxygen_format(struct snd_pcm_hw_params
*hw_params
)
226 if (params_format(hw_params
) == SNDRV_PCM_FORMAT_S32_LE
)
227 return OXYGEN_FORMAT_24
;
229 return OXYGEN_FORMAT_16
;
232 static unsigned int oxygen_rate(struct snd_pcm_hw_params
*hw_params
)
234 switch (params_rate(hw_params
)) {
236 return OXYGEN_RATE_32000
;
238 return OXYGEN_RATE_44100
;
240 return OXYGEN_RATE_48000
;
242 return OXYGEN_RATE_64000
;
244 return OXYGEN_RATE_88200
;
246 return OXYGEN_RATE_96000
;
248 return OXYGEN_RATE_176400
;
250 return OXYGEN_RATE_192000
;
254 static unsigned int oxygen_i2s_mclk(struct snd_pcm_hw_params
*hw_params
)
256 if (params_rate(hw_params
) <= 96000)
257 return OXYGEN_I2S_MCLK_256
;
259 return OXYGEN_I2S_MCLK_128
;
262 static unsigned int oxygen_i2s_bits(struct snd_pcm_hw_params
*hw_params
)
264 if (params_format(hw_params
) == SNDRV_PCM_FORMAT_S32_LE
)
265 return OXYGEN_I2S_BITS_24
;
267 return OXYGEN_I2S_BITS_16
;
270 static unsigned int oxygen_play_channels(struct snd_pcm_hw_params
*hw_params
)
272 switch (params_channels(hw_params
)) {
274 return OXYGEN_PLAY_CHANNELS_2
;
276 return OXYGEN_PLAY_CHANNELS_4
;
278 return OXYGEN_PLAY_CHANNELS_6
;
280 return OXYGEN_PLAY_CHANNELS_8
;
284 static const unsigned int channel_base_registers
[PCM_COUNT
] = {
285 [PCM_A
] = OXYGEN_DMA_A_ADDRESS
,
286 [PCM_B
] = OXYGEN_DMA_B_ADDRESS
,
287 [PCM_C
] = OXYGEN_DMA_C_ADDRESS
,
288 [PCM_SPDIF
] = OXYGEN_DMA_SPDIF_ADDRESS
,
289 [PCM_MULTICH
] = OXYGEN_DMA_MULTICH_ADDRESS
,
290 [PCM_AC97
] = OXYGEN_DMA_AC97_ADDRESS
,
293 static int oxygen_hw_params(struct snd_pcm_substream
*substream
,
294 struct snd_pcm_hw_params
*hw_params
)
296 struct oxygen
*chip
= snd_pcm_substream_chip(substream
);
297 unsigned int channel
= oxygen_substream_channel(substream
);
300 err
= snd_pcm_lib_malloc_pages(substream
,
301 params_buffer_bytes(hw_params
));
305 oxygen_write32(chip
, channel_base_registers
[channel
],
306 (u32
)substream
->runtime
->dma_addr
);
307 if (channel
== PCM_MULTICH
) {
308 oxygen_write32(chip
, OXYGEN_DMA_MULTICH_COUNT
,
309 params_buffer_bytes(hw_params
) / 4 - 1);
310 oxygen_write32(chip
, OXYGEN_DMA_MULTICH_TCOUNT
,
311 params_period_bytes(hw_params
) / 4 - 1);
313 oxygen_write16(chip
, channel_base_registers
[channel
] + 4,
314 params_buffer_bytes(hw_params
) / 4 - 1);
315 oxygen_write16(chip
, channel_base_registers
[channel
] + 6,
316 params_period_bytes(hw_params
) / 4 - 1);
321 static int oxygen_rec_a_hw_params(struct snd_pcm_substream
*substream
,
322 struct snd_pcm_hw_params
*hw_params
)
324 struct oxygen
*chip
= snd_pcm_substream_chip(substream
);
327 err
= oxygen_hw_params(substream
, hw_params
);
331 spin_lock_irq(&chip
->reg_lock
);
332 oxygen_write8_masked(chip
, OXYGEN_REC_FORMAT
,
333 oxygen_format(hw_params
) << OXYGEN_REC_FORMAT_A_SHIFT
,
334 OXYGEN_REC_FORMAT_A_MASK
);
335 oxygen_write16_masked(chip
, OXYGEN_I2S_A_FORMAT
,
336 oxygen_rate(hw_params
) |
337 oxygen_i2s_mclk(hw_params
) |
338 chip
->model
->adc_i2s_format
|
339 oxygen_i2s_bits(hw_params
),
340 OXYGEN_I2S_RATE_MASK
|
341 OXYGEN_I2S_FORMAT_MASK
|
342 OXYGEN_I2S_MCLK_MASK
|
343 OXYGEN_I2S_BITS_MASK
);
344 spin_unlock_irq(&chip
->reg_lock
);
346 mutex_lock(&chip
->mutex
);
347 chip
->model
->set_adc_params(chip
, hw_params
);
348 mutex_unlock(&chip
->mutex
);
352 static int oxygen_rec_b_hw_params(struct snd_pcm_substream
*substream
,
353 struct snd_pcm_hw_params
*hw_params
)
355 struct oxygen
*chip
= snd_pcm_substream_chip(substream
);
358 err
= oxygen_hw_params(substream
, hw_params
);
362 spin_lock_irq(&chip
->reg_lock
);
363 oxygen_write8_masked(chip
, OXYGEN_REC_FORMAT
,
364 oxygen_format(hw_params
) << OXYGEN_REC_FORMAT_B_SHIFT
,
365 OXYGEN_REC_FORMAT_B_MASK
);
366 oxygen_write16_masked(chip
, OXYGEN_I2S_B_FORMAT
,
367 oxygen_rate(hw_params
) |
368 oxygen_i2s_mclk(hw_params
) |
369 chip
->model
->adc_i2s_format
|
370 oxygen_i2s_bits(hw_params
),
371 OXYGEN_I2S_RATE_MASK
|
372 OXYGEN_I2S_FORMAT_MASK
|
373 OXYGEN_I2S_MCLK_MASK
|
374 OXYGEN_I2S_BITS_MASK
);
375 spin_unlock_irq(&chip
->reg_lock
);
377 mutex_lock(&chip
->mutex
);
378 chip
->model
->set_adc_params(chip
, hw_params
);
379 mutex_unlock(&chip
->mutex
);
383 static int oxygen_rec_c_hw_params(struct snd_pcm_substream
*substream
,
384 struct snd_pcm_hw_params
*hw_params
)
386 struct oxygen
*chip
= snd_pcm_substream_chip(substream
);
389 err
= oxygen_hw_params(substream
, hw_params
);
393 spin_lock_irq(&chip
->reg_lock
);
394 oxygen_write8_masked(chip
, OXYGEN_REC_FORMAT
,
395 oxygen_format(hw_params
) << OXYGEN_REC_FORMAT_C_SHIFT
,
396 OXYGEN_REC_FORMAT_C_MASK
);
397 spin_unlock_irq(&chip
->reg_lock
);
401 static int oxygen_spdif_hw_params(struct snd_pcm_substream
*substream
,
402 struct snd_pcm_hw_params
*hw_params
)
404 struct oxygen
*chip
= snd_pcm_substream_chip(substream
);
407 err
= oxygen_hw_params(substream
, hw_params
);
411 spin_lock_irq(&chip
->reg_lock
);
412 oxygen_clear_bits32(chip
, OXYGEN_SPDIF_CONTROL
,
413 OXYGEN_SPDIF_OUT_ENABLE
);
414 oxygen_write8_masked(chip
, OXYGEN_PLAY_FORMAT
,
415 oxygen_format(hw_params
) << OXYGEN_SPDIF_FORMAT_SHIFT
,
416 OXYGEN_SPDIF_FORMAT_MASK
);
417 oxygen_write32_masked(chip
, OXYGEN_SPDIF_CONTROL
,
418 oxygen_rate(hw_params
) << OXYGEN_SPDIF_OUT_RATE_SHIFT
,
419 OXYGEN_SPDIF_OUT_RATE_MASK
);
420 oxygen_update_spdif_source(chip
);
421 spin_unlock_irq(&chip
->reg_lock
);
425 static int oxygen_multich_hw_params(struct snd_pcm_substream
*substream
,
426 struct snd_pcm_hw_params
*hw_params
)
428 struct oxygen
*chip
= snd_pcm_substream_chip(substream
);
431 err
= oxygen_hw_params(substream
, hw_params
);
435 spin_lock_irq(&chip
->reg_lock
);
436 oxygen_write8_masked(chip
, OXYGEN_PLAY_CHANNELS
,
437 oxygen_play_channels(hw_params
),
438 OXYGEN_PLAY_CHANNELS_MASK
);
439 oxygen_write8_masked(chip
, OXYGEN_PLAY_FORMAT
,
440 oxygen_format(hw_params
) << OXYGEN_MULTICH_FORMAT_SHIFT
,
441 OXYGEN_MULTICH_FORMAT_MASK
);
442 oxygen_write16_masked(chip
, OXYGEN_I2S_MULTICH_FORMAT
,
443 oxygen_rate(hw_params
) |
444 chip
->model
->dac_i2s_format
|
445 oxygen_i2s_bits(hw_params
),
446 OXYGEN_I2S_RATE_MASK
|
447 OXYGEN_I2S_FORMAT_MASK
|
448 OXYGEN_I2S_BITS_MASK
);
449 oxygen_update_dac_routing(chip
);
450 oxygen_update_spdif_source(chip
);
451 spin_unlock_irq(&chip
->reg_lock
);
453 mutex_lock(&chip
->mutex
);
454 chip
->model
->set_dac_params(chip
, hw_params
);
455 mutex_unlock(&chip
->mutex
);
459 static int oxygen_hw_free(struct snd_pcm_substream
*substream
)
461 struct oxygen
*chip
= snd_pcm_substream_chip(substream
);
462 unsigned int channel
= oxygen_substream_channel(substream
);
464 spin_lock_irq(&chip
->reg_lock
);
465 chip
->interrupt_mask
&= ~(1 << channel
);
466 oxygen_write16(chip
, OXYGEN_INTERRUPT_MASK
, chip
->interrupt_mask
);
467 spin_unlock_irq(&chip
->reg_lock
);
469 return snd_pcm_lib_free_pages(substream
);
472 static int oxygen_spdif_hw_free(struct snd_pcm_substream
*substream
)
474 struct oxygen
*chip
= snd_pcm_substream_chip(substream
);
476 spin_lock_irq(&chip
->reg_lock
);
477 oxygen_clear_bits32(chip
, OXYGEN_SPDIF_CONTROL
,
478 OXYGEN_SPDIF_OUT_ENABLE
);
479 spin_unlock_irq(&chip
->reg_lock
);
480 return oxygen_hw_free(substream
);
483 static int oxygen_prepare(struct snd_pcm_substream
*substream
)
485 struct oxygen
*chip
= snd_pcm_substream_chip(substream
);
486 unsigned int channel
= oxygen_substream_channel(substream
);
487 unsigned int channel_mask
= 1 << channel
;
489 spin_lock_irq(&chip
->reg_lock
);
490 oxygen_set_bits8(chip
, OXYGEN_DMA_FLUSH
, channel_mask
);
491 oxygen_clear_bits8(chip
, OXYGEN_DMA_FLUSH
, channel_mask
);
493 chip
->interrupt_mask
|= channel_mask
;
494 oxygen_write16(chip
, OXYGEN_INTERRUPT_MASK
, chip
->interrupt_mask
);
495 spin_unlock_irq(&chip
->reg_lock
);
499 static int oxygen_trigger(struct snd_pcm_substream
*substream
, int cmd
)
501 struct oxygen
*chip
= snd_pcm_substream_chip(substream
);
502 struct snd_pcm_substream
*s
;
503 unsigned int mask
= 0;
507 case SNDRV_PCM_TRIGGER_STOP
:
508 case SNDRV_PCM_TRIGGER_START
:
511 case SNDRV_PCM_TRIGGER_PAUSE_PUSH
:
512 case SNDRV_PCM_TRIGGER_PAUSE_RELEASE
:
519 snd_pcm_group_for_each_entry(s
, substream
) {
520 if (snd_pcm_substream_chip(s
) == chip
) {
521 mask
|= 1 << oxygen_substream_channel(s
);
522 snd_pcm_trigger_done(s
, substream
);
526 spin_lock(&chip
->reg_lock
);
528 if (cmd
== SNDRV_PCM_TRIGGER_START
)
529 chip
->pcm_running
|= mask
;
531 chip
->pcm_running
&= ~mask
;
532 oxygen_write8(chip
, OXYGEN_DMA_STATUS
, chip
->pcm_running
);
534 if (cmd
== SNDRV_PCM_TRIGGER_PAUSE_PUSH
)
535 oxygen_set_bits8(chip
, OXYGEN_DMA_PAUSE
, mask
);
537 oxygen_clear_bits8(chip
, OXYGEN_DMA_PAUSE
, mask
);
539 spin_unlock(&chip
->reg_lock
);
543 static snd_pcm_uframes_t
oxygen_pointer(struct snd_pcm_substream
*substream
)
545 struct oxygen
*chip
= snd_pcm_substream_chip(substream
);
546 struct snd_pcm_runtime
*runtime
= substream
->runtime
;
547 unsigned int channel
= oxygen_substream_channel(substream
);
550 /* no spinlock, this read should be atomic */
551 curr_addr
= oxygen_read32(chip
, channel_base_registers
[channel
]);
552 return bytes_to_frames(runtime
, curr_addr
- (u32
)runtime
->dma_addr
);
555 static struct snd_pcm_ops oxygen_rec_a_ops
= {
556 .open
= oxygen_rec_a_open
,
557 .close
= oxygen_close
,
558 .ioctl
= snd_pcm_lib_ioctl
,
559 .hw_params
= oxygen_rec_a_hw_params
,
560 .hw_free
= oxygen_hw_free
,
561 .prepare
= oxygen_prepare
,
562 .trigger
= oxygen_trigger
,
563 .pointer
= oxygen_pointer
,
566 static struct snd_pcm_ops oxygen_rec_b_ops
= {
567 .open
= oxygen_rec_b_open
,
568 .close
= oxygen_close
,
569 .ioctl
= snd_pcm_lib_ioctl
,
570 .hw_params
= oxygen_rec_b_hw_params
,
571 .hw_free
= oxygen_hw_free
,
572 .prepare
= oxygen_prepare
,
573 .trigger
= oxygen_trigger
,
574 .pointer
= oxygen_pointer
,
577 static struct snd_pcm_ops oxygen_rec_c_ops
= {
578 .open
= oxygen_rec_c_open
,
579 .close
= oxygen_close
,
580 .ioctl
= snd_pcm_lib_ioctl
,
581 .hw_params
= oxygen_rec_c_hw_params
,
582 .hw_free
= oxygen_hw_free
,
583 .prepare
= oxygen_prepare
,
584 .trigger
= oxygen_trigger
,
585 .pointer
= oxygen_pointer
,
588 static struct snd_pcm_ops oxygen_spdif_ops
= {
589 .open
= oxygen_spdif_open
,
590 .close
= oxygen_close
,
591 .ioctl
= snd_pcm_lib_ioctl
,
592 .hw_params
= oxygen_spdif_hw_params
,
593 .hw_free
= oxygen_spdif_hw_free
,
594 .prepare
= oxygen_prepare
,
595 .trigger
= oxygen_trigger
,
596 .pointer
= oxygen_pointer
,
599 static struct snd_pcm_ops oxygen_multich_ops
= {
600 .open
= oxygen_multich_open
,
601 .close
= oxygen_close
,
602 .ioctl
= snd_pcm_lib_ioctl
,
603 .hw_params
= oxygen_multich_hw_params
,
604 .hw_free
= oxygen_hw_free
,
605 .prepare
= oxygen_prepare
,
606 .trigger
= oxygen_trigger
,
607 .pointer
= oxygen_pointer
,
610 static struct snd_pcm_ops oxygen_ac97_ops
= {
611 .open
= oxygen_ac97_open
,
612 .close
= oxygen_close
,
613 .ioctl
= snd_pcm_lib_ioctl
,
614 .hw_params
= oxygen_hw_params
,
615 .hw_free
= oxygen_hw_free
,
616 .prepare
= oxygen_prepare
,
617 .trigger
= oxygen_trigger
,
618 .pointer
= oxygen_pointer
,
621 static void oxygen_pcm_free(struct snd_pcm
*pcm
)
623 snd_pcm_lib_preallocate_free_for_all(pcm
);
626 int __devinit
oxygen_pcm_init(struct oxygen
*chip
)
632 outs
= 1; /* OXYGEN_CHANNEL_MULTICH is always used */
633 ins
= !!(chip
->model
->used_channels
& (OXYGEN_CHANNEL_A
|
635 err
= snd_pcm_new(chip
->card
, "Analog", 0, outs
, ins
, &pcm
);
638 snd_pcm_set_ops(pcm
, SNDRV_PCM_STREAM_PLAYBACK
, &oxygen_multich_ops
);
639 if (chip
->model
->used_channels
& OXYGEN_CHANNEL_A
)
640 snd_pcm_set_ops(pcm
, SNDRV_PCM_STREAM_CAPTURE
,
642 else if (chip
->model
->used_channels
& OXYGEN_CHANNEL_B
)
643 snd_pcm_set_ops(pcm
, SNDRV_PCM_STREAM_CAPTURE
,
645 pcm
->private_data
= chip
;
646 pcm
->private_free
= oxygen_pcm_free
;
647 strcpy(pcm
->name
, "Analog");
648 snd_pcm_lib_preallocate_pages(pcm
->streams
[SNDRV_PCM_STREAM_PLAYBACK
].substream
,
650 snd_dma_pci_data(chip
->pci
),
651 512 * 1024, 2048 * 1024);
653 snd_pcm_lib_preallocate_pages(pcm
->streams
[SNDRV_PCM_STREAM_CAPTURE
].substream
,
655 snd_dma_pci_data(chip
->pci
),
656 128 * 1024, 256 * 1024);
658 outs
= !!(chip
->model
->used_channels
& OXYGEN_CHANNEL_SPDIF
);
659 ins
= !!(chip
->model
->used_channels
& OXYGEN_CHANNEL_C
);
661 err
= snd_pcm_new(chip
->card
, "Digital", 1, outs
, ins
, &pcm
);
665 snd_pcm_set_ops(pcm
, SNDRV_PCM_STREAM_PLAYBACK
,
668 snd_pcm_set_ops(pcm
, SNDRV_PCM_STREAM_CAPTURE
,
670 pcm
->private_data
= chip
;
671 pcm
->private_free
= oxygen_pcm_free
;
672 strcpy(pcm
->name
, "Digital");
673 snd_pcm_lib_preallocate_pages_for_all(pcm
, SNDRV_DMA_TYPE_DEV
,
674 snd_dma_pci_data(chip
->pci
),
675 128 * 1024, 256 * 1024);
678 outs
= chip
->has_ac97_1
&&
679 (chip
->model
->used_channels
& OXYGEN_CHANNEL_AC97
);
680 ins
= (chip
->model
->used_channels
& (OXYGEN_CHANNEL_A
|
682 == (OXYGEN_CHANNEL_A
| OXYGEN_CHANNEL_B
);
684 err
= snd_pcm_new(chip
->card
, ins
? "Analog2" : "AC97",
689 snd_pcm_set_ops(pcm
, SNDRV_PCM_STREAM_PLAYBACK
,
692 snd_pcm_set_ops(pcm
, SNDRV_PCM_STREAM_CAPTURE
,
694 pcm
->private_data
= chip
;
695 pcm
->private_free
= oxygen_pcm_free
;
696 strcpy(pcm
->name
, ins
? "Analog 2" : "Front Panel");
697 snd_pcm_lib_preallocate_pages_for_all(pcm
, SNDRV_DMA_TYPE_DEV
,
698 snd_dma_pci_data(chip
->pci
),
699 128 * 1024, 256 * 1024);