39 #include <linux/time.h>
40 #include <linux/module.h>
52 #ifdef CONFIG_SND_SB16_CSP
56 struct snd_sb_csp *
csp = chip->
csp;
61 ((1
U << runtime->
format) == csp->acc_format)) {
63 if (csp->ops.csp_use(csp) == 0) {
72 if (csp->ops.csp_use(csp) == 0) {
78 }
else if (csp->ops.csp_use(csp) == 0) {
82 csp->ops.csp_unuse(csp);
91 csp->ops.csp_unuse(csp);
104 struct snd_sb_csp *csp = chip->
csp;
109 ((1
U << runtime->
format) == csp->acc_format)) {
111 if (csp->ops.csp_use(csp) == 0) {
116 }
else if (csp->ops.csp_use(csp) == 0) {
120 csp->ops.csp_unuse(csp);
129 csp->ops.csp_unuse(csp);
142 struct snd_sb_csp *csp = chip->
csp;
144 if (csp->qpos_changed) {
146 csp->ops.csp_qsound_transfer (csp);
156 struct snd_sb_csp *csp = chip->
csp;
161 runtime->
hw.formats |= csp->acc_format;
174 struct snd_sb_csp *csp = chip->
csp;
176 if (csp->ops.csp_stop(csp) == 0) {
177 csp->ops.csp_unuse(csp);
187 struct snd_sb_csp *csp = chip->
csp;
192 runtime->
hw.formats |= csp->acc_format;
205 struct snd_sb_csp *csp = chip->
csp;
207 if (csp->ops.csp_stop(csp) == 0) {
208 csp->ops.csp_unuse(csp);
214 #define snd_sb16_csp_playback_prepare(chip, runtime)
215 #define snd_sb16_csp_capture_prepare(chip, runtime)
216 #define snd_sb16_csp_update(chip)
217 #define snd_sb16_csp_playback_open(chip, runtime)
218 #define snd_sb16_csp_playback_close(chip)
219 #define snd_sb16_csp_capture_open(chip, runtime)
220 #define snd_sb16_csp_capture_close(chip)
224 static void snd_sb16_setup_rate(
struct snd_sb *chip,
232 snd_sb_ack_16bit(chip);
234 snd_sb_ack_8bit(chip);
244 spin_unlock_irqrestore(&chip->
reg_lock, flags);
275 size = chip->
p_dma_size = snd_pcm_lib_buffer_bytes(substream);
279 count = snd_pcm_lib_period_bytes(substream);
297 spin_unlock_irqrestore(&chip->
reg_lock, flags);
344 size = chip->
c_dma_size = snd_pcm_lib_buffer_bytes(substream);
348 count = snd_pcm_lib_period_bytes(substream);
366 spin_unlock_irqrestore(&chip->
reg_lock, flags);
423 snd_sb_ack_8bit(chip);
440 snd_sb_ack_16bit(chip);
458 return bytes_to_frames(substream->
runtime, ptr);
469 return bytes_to_frames(substream->
runtime, ptr);
487 .period_bytes_min = 64,
488 .period_bytes_max = (128*1024),
505 .period_bytes_min = 64,
506 .period_bytes_max = (128*1024),
524 spin_unlock_irqrestore(&chip->
open_lock, flags);
527 runtime->
hw = snd_sb16_playback;
537 if (chip->
dma16 <= 3) {
538 runtime->
hw.buffer_bytes_max =
539 runtime->
hw.period_bytes_max = 64 * 1024;
550 if (chip->
dma16 < 0) {
556 runtime->
hw.buffer_bytes_max =
557 runtime->
hw.period_bytes_max = 64 * 1024;
560 spin_unlock_irqrestore(&chip->
open_lock, flags);
565 runtime->
hw.rate_max = 48000;
567 runtime->
hw.buffer_bytes_max = 32 * 1024;
568 runtime->
hw.periods_min = 2;
569 runtime->
hw.rate_min = 44100;
574 spin_unlock_irqrestore(&chip->
open_lock, flags);
587 spin_unlock_irqrestore(&chip->
open_lock, flags);
599 spin_unlock_irqrestore(&chip->
open_lock, flags);
602 runtime->
hw = snd_sb16_capture;
612 if (chip->
dma16 <= 3) {
613 runtime->
hw.buffer_bytes_max =
614 runtime->
hw.period_bytes_max = 64 * 1024;
625 if (chip->
dma16 < 0) {
631 runtime->
hw.buffer_bytes_max =
632 runtime->
hw.period_bytes_max = 64 * 1024;
635 spin_unlock_irqrestore(&chip->
open_lock, flags);
640 runtime->
hw.rate_max = 48000;
642 runtime->
hw.buffer_bytes_max = 32 * 1024;
643 runtime->
hw.periods_min = 2;
644 runtime->
hw.rate_min = 44100;
649 spin_unlock_irqrestore(&chip->
open_lock, flags);
662 spin_unlock_irqrestore(&chip->
open_lock, flags);
670 static int snd_sb16_set_dma_mode(
struct snd_sb *chip,
int what)
679 }
else if (what == 1) {
681 }
else if (what == 2) {
689 static int snd_sb16_get_dma_mode(
struct snd_sb *chip)
705 static char *texts[3] = {
706 "Auto",
"Playback",
"Capture"
724 ucontrol->
value.enumerated.item[0] = snd_sb16_get_dma_mode(chip);
725 spin_unlock_irqrestore(&chip->
reg_lock, flags);
733 unsigned char nval, oval;
736 if ((nval = ucontrol->
value.enumerated.item[0]) > 2)
739 oval = snd_sb16_get_dma_mode(chip);
740 change = nval != oval;
741 snd_sb16_set_dma_mode(chip, nval);
742 spin_unlock_irqrestore(&chip->
reg_lock, flags);
748 .name =
"16-bit DMA Allocation",
749 .info = snd_sb16_dma_control_info,
750 .get = snd_sb16_dma_control_get,
751 .put = snd_sb16_dma_control_put
761 unsigned char irqreg = 0,
dmareg = 0, mpureg;
762 unsigned char realirq, realdma, realmpureg;
768 spin_unlock_irqrestore(&chip->
mixer_lock, flags);
786 if (chip->
dma8 >= 0) {
787 switch (chip->
dma8) {
802 switch (chip->
dma16) {
837 spin_unlock_irqrestore(&chip->
mixer_lock, flags);
838 if ((~realirq) & irqreg || (~realdma) &
dmareg) {
840 snd_printk(
KERN_ERR "SB16 [0x%lx]: wanted: irqreg=0x%x, dmareg=0x%x, mpureg = 0x%x\n", chip->
port, realirq, realdma, realmpureg);
841 snd_printk(
KERN_ERR "SB16 [0x%lx]: got: irqreg=0x%x, dmareg=0x%x, mpureg = 0x%x\n", chip->
port, irqreg, dmareg, mpureg);
847 static struct snd_pcm_ops snd_sb16_playback_ops = {
848 .open = snd_sb16_playback_open,
849 .close = snd_sb16_playback_close,
851 .hw_params = snd_sb16_hw_params,
852 .hw_free = snd_sb16_hw_free,
853 .prepare = snd_sb16_playback_prepare,
854 .trigger = snd_sb16_playback_trigger,
855 .pointer = snd_sb16_playback_pointer,
859 .open = snd_sb16_capture_open,
860 .close = snd_sb16_capture_close,
862 .hw_params = snd_sb16_hw_params,
863 .hw_free = snd_sb16_hw_free,
864 .prepare = snd_sb16_capture_prepare,
865 .trigger = snd_sb16_capture_trigger,
866 .pointer = snd_sb16_capture_pointer,
877 if ((err =
snd_pcm_new(card,
"SB16 DSP", device, 1, 1, &pcm)) < 0)
903 &snd_sb16_playback_ops : &snd_sb16_capture_ops;
915 static int __init alsa_sb16_init(
void)
920 static void __exit alsa_sb16_exit(
void)