20 #include <linux/pci.h>
28 #define BUFFER_BYTES_MAX ((1 << 16) * 4)
30 #define BUFFER_BYTES_MAX_MULTICH ((1 << 24) * 4)
32 #define PERIOD_BYTES_MIN 64
34 #define DEFAULT_BUFFER_BYTES (BUFFER_BYTES_MAX / 2)
35 #define DEFAULT_BUFFER_BYTES_MULTICH (1024 * 1024)
112 [
PCM_A] = &oxygen_stereo_hardware,
113 [
PCM_B] = &oxygen_stereo_hardware,
114 [
PCM_C] = &oxygen_stereo_hardware,
120 static inline unsigned int
136 runtime->
hw = oxygen_ac97_hardware;
138 runtime->
hw = *oxygen_hardware[channel];
143 runtime->
hw.rate_min = 44100;
146 runtime->
hw.channels_max = chip->
model.dac_channels_pcm;
149 if (chip->
model.pcm_hardware_filter)
150 chip->
model.pcm_hardware_filter(channel, &runtime->
hw);
164 if (runtime->
hw.channels_max > 2) {
191 return oxygen_open(substream,
PCM_A);
196 return oxygen_open(substream,
PCM_B);
201 return oxygen_open(substream,
PCM_C);
206 return oxygen_open(substream,
PCM_SPDIF);
216 return oxygen_open(substream,
PCM_AC97);
222 unsigned int channel = oxygen_substream_channel(substream);
293 static const unsigned int channel_base_registers[
PCM_COUNT] = {
306 unsigned int channel = oxygen_substream_channel(substream);
320 params_period_bytes(hw_params) / 4 - 1);
325 params_period_bytes(hw_params) / 4 - 1);
330 static u16 get_mclk(
struct oxygen *chip,
unsigned int channel,
333 unsigned int mclks, shift;
336 mclks = chip->
model.dac_mclks;
338 mclks = chip->
model.adc_mclks;
356 err = oxygen_hw_params(substream, hw_params);
365 oxygen_rate(hw_params) |
366 chip->
model.adc_i2s_format |
367 get_mclk(chip,
PCM_A, hw_params) |
368 oxygen_i2s_bits(hw_params),
376 chip->
model.set_adc_params(chip, hw_params);
388 err = oxygen_hw_params(substream, hw_params);
401 oxygen_rate(hw_params) |
402 chip->
model.adc_i2s_format |
403 get_mclk(chip,
PCM_B, hw_params) |
404 oxygen_i2s_bits(hw_params),
413 chip->
model.set_adc_params(chip, hw_params);
425 err = oxygen_hw_params(substream, hw_params);
443 err = oxygen_hw_params(substream, hw_params);
469 err = oxygen_hw_params(substream, hw_params);
476 oxygen_play_channels(hw_params),
482 oxygen_rate(hw_params) |
483 chip->
model.dac_i2s_format |
485 oxygen_i2s_bits(hw_params),
493 chip->
model.set_dac_params(chip, hw_params);
502 unsigned int channel = oxygen_substream_channel(substream);
503 unsigned int channel_mask = 1 <<
channel;
524 return oxygen_hw_free(substream);
530 unsigned int channel = oxygen_substream_channel(substream);
531 unsigned int channel_mask = 1 <<
channel;
537 if (substream->
runtime->no_period_wakeup)
550 unsigned int mask = 0;
569 mask |= 1 << oxygen_substream_channel(s);
570 snd_pcm_trigger_done(s, substream);
595 unsigned int channel = oxygen_substream_channel(substream);
599 curr_addr =
oxygen_read32(chip, channel_base_registers[channel]);
600 return bytes_to_frames(runtime, curr_addr - (
u32)runtime->
dma_addr);
604 .open = oxygen_rec_a_open,
605 .close = oxygen_close,
607 .hw_params = oxygen_rec_a_hw_params,
608 .hw_free = oxygen_hw_free,
609 .prepare = oxygen_prepare,
610 .trigger = oxygen_trigger,
611 .pointer = oxygen_pointer,
615 .open = oxygen_rec_b_open,
616 .close = oxygen_close,
618 .hw_params = oxygen_rec_b_hw_params,
619 .hw_free = oxygen_hw_free,
620 .prepare = oxygen_prepare,
621 .trigger = oxygen_trigger,
622 .pointer = oxygen_pointer,
626 .open = oxygen_rec_c_open,
627 .close = oxygen_close,
629 .hw_params = oxygen_rec_c_hw_params,
630 .hw_free = oxygen_hw_free,
631 .prepare = oxygen_prepare,
632 .trigger = oxygen_trigger,
633 .pointer = oxygen_pointer,
637 .open = oxygen_spdif_open,
638 .close = oxygen_close,
640 .hw_params = oxygen_spdif_hw_params,
641 .hw_free = oxygen_spdif_hw_free,
642 .prepare = oxygen_prepare,
643 .trigger = oxygen_trigger,
644 .pointer = oxygen_pointer,
648 .open = oxygen_multich_open,
649 .close = oxygen_close,
651 .hw_params = oxygen_multich_hw_params,
652 .hw_free = oxygen_hw_free,
653 .prepare = oxygen_prepare,
654 .trigger = oxygen_trigger,
655 .pointer = oxygen_pointer,
659 .open = oxygen_ac97_open,
660 .close = oxygen_close,
662 .hw_params = oxygen_hw_params,
663 .hw_free = oxygen_hw_free,
664 .prepare = oxygen_prepare,
665 .trigger = oxygen_trigger,
666 .pointer = oxygen_pointer,
669 static void oxygen_pcm_free(
struct snd_pcm *pcm)
690 &oxygen_multich_ops);
759 strcpy(pcm->
name, outs ?
"Front Panel" :
"Analog 2");