36 #include <linux/time.h>
37 #include <linux/module.h>
45 #define SB8_CLOCK 1000000
46 #define SB8_DEN(v) ((SB8_CLOCK + (v) / 2) / (v))
47 #define SB8_RATE(v) (SB8_CLOCK / SB8_DEN(v))
81 unsigned int num = 0,
den = 0;
83 2, stereo_clocks, &num, &
den);
84 if (err >= 0 &&
den) {
111 unsigned char stereo = runtime->
channels > 1;
114 rate = runtime->
rate;
157 size = chip->
p_dma_size = snd_pcm_lib_buffer_bytes(substream);
158 count = chip->
p_period_size = snd_pcm_lib_period_bytes(substream);
200 spin_unlock_irqrestore(&chip->
reg_lock, flags);
238 spin_unlock_irqrestore(&chip->
reg_lock, flags);
261 unsigned char stereo = runtime->
channels > 1;
264 rate = runtime->
rate;
308 size = chip->
c_dma_size = snd_pcm_lib_buffer_bytes(substream);
309 count = chip->
c_period_size = snd_pcm_lib_period_bytes(substream);
337 spin_unlock_irqrestore(&chip->
reg_lock, flags);
377 spin_unlock_irqrestore(&chip->
reg_lock, flags);
386 snd_sb_ack_8bit(chip);
387 switch (chip->
mode) {
427 return bytes_to_frames(substream->
runtime, ptr);
443 return bytes_to_frames(substream->
runtime, ptr);
461 .buffer_bytes_max = 65536,
462 .period_bytes_min = 64,
463 .period_bytes_max = 65536,
480 .buffer_bytes_max = 65536,
481 .period_bytes_min = 64,
482 .period_bytes_max = 65536,
500 spin_unlock_irqrestore(&chip->
open_lock, flags);
504 spin_unlock_irqrestore(&chip->
open_lock, flags);
507 runtime->
hw = snd_sb8_playback;
510 runtime->
hw = snd_sb8_capture;
517 runtime->
hw.rate_min = 4000;
518 runtime->
hw.rate_max = 50000;
519 runtime->
hw.channels_max = 2;
522 runtime->
hw.rate_max = 44100;
523 runtime->
hw.channels_max = 2;
525 snd_sb8_hw_constraint_rate_channels,
NULL,
529 snd_sb8_hw_constraint_channels_rate,
NULL,
534 runtime->
hw.rate_max = 44100;
536 runtime->
hw.rate_max = 15000;
542 &hw_constraints_clock);
543 if (chip->
dma8 > 3 || chip->
dma16 >= 0) {
548 runtime->
hw.buffer_bytes_max = 128 * 1024 * 1024;
549 runtime->
hw.period_bytes_max = 128 * 1024 * 1024;
567 spin_unlock_irqrestore(&chip->
open_lock, flags);
576 .open = snd_sb8_open,
577 .close = snd_sb8_close,
579 .hw_params = snd_sb8_hw_params,
580 .hw_free = snd_sb8_hw_free,
581 .prepare = snd_sb8_playback_prepare,
582 .trigger = snd_sb8_playback_trigger,
583 .pointer = snd_sb8_playback_pointer,
587 .open = snd_sb8_open,
588 .close = snd_sb8_close,
590 .hw_params = snd_sb8_hw_params,
591 .hw_free = snd_sb8_hw_free,
592 .prepare = snd_sb8_capture_prepare,
593 .trigger = snd_sb8_capture_trigger,
594 .pointer = snd_sb8_capture_pointer,
602 size_t max_prealloc = 64 * 1024;
606 if ((err =
snd_pcm_new(card,
"SB8 DSP", device, 1, 1, &pcm)) < 0)
616 max_prealloc = 128 * 1024;
619 64*1024, max_prealloc);
636 static int __init alsa_sb8_init(
void)
641 static void __exit alsa_sb8_exit(
void)