4 * Audio routines for Sound Blaster compatible cards.
7 * Copyright (C) by Hannu Savolainen 1993-1997
9 * OSS/Free for Linux is distributed under the GNU GENERAL PUBLIC LICENSE (GPL)
10 * Version 2 (June 1991). See the "COPYING" file distributed with this software
14 * Alan Cox : Formatting and clean ups
17 * Mostly working. Weird uart bug causing irq storms
19 * Daniel J. Rodriksson: Changes to make sb16 work full duplex.
20 * Maybe other 16 bit cards in this code could behave
24 #include "sound_config.h"
31 int sb_audio_open(int dev, int mode)
33 sb_devc *devc = audio_devs[dev]->devc;
38 printk(KERN_ERR "Sound Blaster: incomplete initialization.\n");
41 if (devc->caps & SB_NO_RECORDING && mode & OPEN_READ)
43 if (mode == OPEN_READ)
53 if (devc->dma16 != -1 && devc->dma16 != devc->dma8 && !devc->duplex)
55 if (sound_open_dma(devc->dma16, "Sound Blaster 16 bit"))
64 devc->irq_mode = IMODE_NONE;
65 devc->irq_mode_16 = IMODE_NONE;
66 devc->fullduplex = devc->duplex &&
67 ((mode & OPEN_READ) && (mode & OPEN_WRITE));
70 /* At first glance this check isn't enough, some ESS chips might not
71 * have a RECLEV. However if they don't common_mixer_set will refuse
72 * cause devc->iomap has no register mapping for RECLEV
74 if (devc->model == MDL_ESS) ess_mixer_reload (devc, SOUND_MIXER_RECLEV);
76 /* The ALS007 seems to require that the DSP be removed from the output */
77 /* in order for recording to be activated properly. This is done by */
78 /* setting the appropriate bits of the output control register 4ch to */
79 /* zero. This code assumes that the output control registers are not */
80 /* used anywhere else and therefore the DSP bits are *always* ON for */
81 /* output and OFF for sampling. */
83 if (devc->submodel == SUBMDL_ALS007)
86 sb_setmixer(devc,ALS007_OUTPUT_CTRL2,
87 sb_getmixer(devc,ALS007_OUTPUT_CTRL2) & 0xf9);
89 sb_setmixer(devc,ALS007_OUTPUT_CTRL2,
90 sb_getmixer(devc,ALS007_OUTPUT_CTRL2) | 0x06);
95 void sb_audio_close(int dev)
97 sb_devc *devc = audio_devs[dev]->devc;
99 /* fix things if mmap turned off fullduplex */
102 && (devc->opened & OPEN_READ) && (devc->opened & OPEN_WRITE))
104 struct dma_buffparms *dmap_temp;
105 dmap_temp = audio_devs[dev]->dmap_out;
106 audio_devs[dev]->dmap_out = audio_devs[dev]->dmap_in;
107 audio_devs[dev]->dmap_in = dmap_temp;
109 audio_devs[dev]->dmap_out->dma = devc->dma8;
110 audio_devs[dev]->dmap_in->dma = ( devc->duplex ) ?
111 devc->dma16 : devc->dma8;
113 if (devc->dma16 != -1 && devc->dma16 != devc->dma8 && !devc->duplex)
114 sound_close_dma(devc->dma16);
116 /* For ALS007, turn DSP output back on if closing the device for read */
118 if ((devc->submodel == SUBMDL_ALS007) && (devc->opened & OPEN_READ))
120 sb_setmixer(devc,ALS007_OUTPUT_CTRL2,
121 sb_getmixer(devc,ALS007_OUTPUT_CTRL2) | 0x06);
126 static void sb_set_output_parms(int dev, unsigned long buf, int nr_bytes,
129 sb_devc *devc = audio_devs[dev]->devc;
131 if (!devc->fullduplex || devc->bits == AFMT_S16_LE)
134 devc->trg_bytes = nr_bytes;
135 devc->trg_intrflag = intrflag;
136 devc->irq_mode = IMODE_OUTPUT;
140 devc->trg_buf_16 = buf;
141 devc->trg_bytes_16 = nr_bytes;
142 devc->trg_intrflag_16 = intrflag;
143 devc->irq_mode_16 = IMODE_OUTPUT;
147 static void sb_set_input_parms(int dev, unsigned long buf, int count, int intrflag)
149 sb_devc *devc = audio_devs[dev]->devc;
151 if (!devc->fullduplex || devc->bits != AFMT_S16_LE)
154 devc->trg_bytes = count;
155 devc->trg_intrflag = intrflag;
156 devc->irq_mode = IMODE_INPUT;
160 devc->trg_buf_16 = buf;
161 devc->trg_bytes_16 = count;
162 devc->trg_intrflag_16 = intrflag;
163 devc->irq_mode_16 = IMODE_INPUT;
168 * SB1.x compatible routines
171 static void sb1_audio_output_block(int dev, unsigned long buf, int nr_bytes, int intrflag)
174 int count = nr_bytes;
175 sb_devc *devc = audio_devs[dev]->devc;
177 /* DMAbuf_start_dma (dev, buf, count, DMA_MODE_WRITE); */
179 if (audio_devs[dev]->dmap_out->dma > 3)
183 devc->irq_mode = IMODE_OUTPUT;
187 if (sb_dsp_command(devc, 0x14)) /* 8 bit DAC using DMA */
189 sb_dsp_command(devc, (unsigned char) (count & 0xff));
190 sb_dsp_command(devc, (unsigned char) ((count >> 8) & 0xff));
193 printk(KERN_WARNING "Sound Blaster: unable to start DAC.\n");
194 restore_flags(flags);
195 devc->intr_active = 1;
198 static void sb1_audio_start_input(int dev, unsigned long buf, int nr_bytes, int intrflag)
201 int count = nr_bytes;
202 sb_devc *devc = audio_devs[dev]->devc;
205 * Start a DMA input to the buffer pointed by dmaqtail
208 /* DMAbuf_start_dma (dev, buf, count, DMA_MODE_READ); */
210 if (audio_devs[dev]->dmap_out->dma > 3)
214 devc->irq_mode = IMODE_INPUT;
218 if (sb_dsp_command(devc, 0x24)) /* 8 bit ADC using DMA */
220 sb_dsp_command(devc, (unsigned char) (count & 0xff));
221 sb_dsp_command(devc, (unsigned char) ((count >> 8) & 0xff));
224 printk(KERN_ERR "Sound Blaster: unable to start ADC.\n");
225 restore_flags(flags);
227 devc->intr_active = 1;
230 static void sb1_audio_trigger(int dev, int bits)
232 sb_devc *devc = audio_devs[dev]->devc;
234 bits &= devc->irq_mode;
237 sb_dsp_command(devc, 0xd0); /* Halt DMA */
240 switch (devc->irq_mode)
243 sb1_audio_start_input(dev, devc->trg_buf, devc->trg_bytes,
248 sb1_audio_output_block(dev, devc->trg_buf, devc->trg_bytes,
253 devc->trigger_bits = bits;
256 static int sb1_audio_prepare_for_input(int dev, int bsize, int bcount)
258 sb_devc *devc = audio_devs[dev]->devc;
263 if (sb_dsp_command(devc, 0x40))
264 sb_dsp_command(devc, devc->tconst);
265 sb_dsp_command(devc, DSP_CMD_SPKOFF);
266 restore_flags(flags);
268 devc->trigger_bits = 0;
272 static int sb1_audio_prepare_for_output(int dev, int bsize, int bcount)
274 sb_devc *devc = audio_devs[dev]->devc;
279 if (sb_dsp_command(devc, 0x40))
280 sb_dsp_command(devc, devc->tconst);
281 sb_dsp_command(devc, DSP_CMD_SPKON);
282 restore_flags(flags);
283 devc->trigger_bits = 0;
287 static int sb1_audio_set_speed(int dev, int speed)
289 int max_speed = 23000;
290 sb_devc *devc = audio_devs[dev]->devc;
293 if (devc->opened & OPEN_READ)
301 if (speed > max_speed)
304 devc->tconst = (256 - ((1000000 + speed / 2) / speed)) & 0xff;
305 tmp = 256 - devc->tconst;
306 speed = (1000000 + tmp / 2) / tmp;
313 static short sb1_audio_set_channels(int dev, short channels)
315 sb_devc *devc = audio_devs[dev]->devc;
316 return devc->channels = 1;
319 static unsigned int sb1_audio_set_bits(int dev, unsigned int bits)
321 sb_devc *devc = audio_devs[dev]->devc;
322 return devc->bits = 8;
325 static void sb1_audio_halt_xfer(int dev)
328 sb_devc *devc = audio_devs[dev]->devc;
333 restore_flags(flags);
337 * SB 2.0 and SB 2.01 compatible routines
340 static void sb20_audio_output_block(int dev, unsigned long buf, int nr_bytes,
344 int count = nr_bytes;
345 sb_devc *devc = audio_devs[dev]->devc;
348 /* DMAbuf_start_dma (dev, buf, count, DMA_MODE_WRITE); */
350 if (audio_devs[dev]->dmap_out->dma > 3)
354 devc->irq_mode = IMODE_OUTPUT;
358 if (sb_dsp_command(devc, 0x48)) /* DSP Block size */
360 sb_dsp_command(devc, (unsigned char) (count & 0xff));
361 sb_dsp_command(devc, (unsigned char) ((count >> 8) & 0xff));
363 if (devc->speed * devc->channels <= 23000)
364 cmd = 0x1c; /* 8 bit PCM output */
366 cmd = 0x90; /* 8 bit high speed PCM output (SB2.01/Pro) */
368 if (!sb_dsp_command(devc, cmd))
369 printk(KERN_ERR "Sound Blaster: unable to start DAC.\n");
372 printk(KERN_ERR "Sound Blaster: unable to start DAC.\n");
373 restore_flags(flags);
374 devc->intr_active = 1;
377 static void sb20_audio_start_input(int dev, unsigned long buf, int nr_bytes, int intrflag)
380 int count = nr_bytes;
381 sb_devc *devc = audio_devs[dev]->devc;
385 * Start a DMA input to the buffer pointed by dmaqtail
388 /* DMAbuf_start_dma (dev, buf, count, DMA_MODE_READ); */
390 if (audio_devs[dev]->dmap_out->dma > 3)
394 devc->irq_mode = IMODE_INPUT;
398 if (sb_dsp_command(devc, 0x48)) /* DSP Block size */
400 sb_dsp_command(devc, (unsigned char) (count & 0xff));
401 sb_dsp_command(devc, (unsigned char) ((count >> 8) & 0xff));
403 if (devc->speed * devc->channels <= (devc->major == 3 ? 23000 : 13000))
404 cmd = 0x2c; /* 8 bit PCM input */
406 cmd = 0x98; /* 8 bit high speed PCM input (SB2.01/Pro) */
408 if (!sb_dsp_command(devc, cmd))
409 printk(KERN_ERR "Sound Blaster: unable to start ADC.\n");
412 printk(KERN_ERR "Sound Blaster: unable to start ADC.\n");
413 restore_flags(flags);
414 devc->intr_active = 1;
417 static void sb20_audio_trigger(int dev, int bits)
419 sb_devc *devc = audio_devs[dev]->devc;
420 bits &= devc->irq_mode;
423 sb_dsp_command(devc, 0xd0); /* Halt DMA */
426 switch (devc->irq_mode)
429 sb20_audio_start_input(dev, devc->trg_buf, devc->trg_bytes,
434 sb20_audio_output_block(dev, devc->trg_buf, devc->trg_bytes,
439 devc->trigger_bits = bits;
443 * SB2.01 specific speed setup
446 static int sb201_audio_set_speed(int dev, int speed)
448 sb_devc *devc = audio_devs[dev]->devc;
450 int s = speed * devc->channels;
458 if (devc->opened & OPEN_READ && speed > 15000)
460 devc->tconst = (256 - ((1000000 + s / 2) / s)) & 0xff;
461 tmp = 256 - devc->tconst;
462 speed = ((1000000 + tmp / 2) / tmp) / devc->channels;
470 * SB Pro specific routines
473 static int sbpro_audio_prepare_for_input(int dev, int bsize, int bcount)
474 { /* For SB Pro and Jazz16 */
475 sb_devc *devc = audio_devs[dev]->devc;
477 unsigned char bits = 0;
479 if (devc->dma16 >= 0 && devc->dma16 != devc->dma8)
480 audio_devs[dev]->dmap_out->dma = audio_devs[dev]->dmap_in->dma =
481 devc->bits == 16 ? devc->dma16 : devc->dma8;
483 if (devc->model == MDL_JAZZ || devc->model == MDL_SMW)
484 if (devc->bits == AFMT_S16_LE)
485 bits = 0x04; /* 16 bit mode */
489 if (sb_dsp_command(devc, 0x40))
490 sb_dsp_command(devc, devc->tconst);
491 sb_dsp_command(devc, DSP_CMD_SPKOFF);
492 if (devc->channels == 1)
493 sb_dsp_command(devc, 0xa0 | bits); /* Mono input */
495 sb_dsp_command(devc, 0xa8 | bits); /* Stereo input */
496 restore_flags(flags);
498 devc->trigger_bits = 0;
502 static int sbpro_audio_prepare_for_output(int dev, int bsize, int bcount)
503 { /* For SB Pro and Jazz16 */
504 sb_devc *devc = audio_devs[dev]->devc;
507 unsigned char bits = 0;
509 if (devc->dma16 >= 0 && devc->dma16 != devc->dma8)
510 audio_devs[dev]->dmap_out->dma = audio_devs[dev]->dmap_in->dma = devc->bits == 16 ? devc->dma16 : devc->dma8;
511 if (devc->model == MDL_SBPRO)
512 sb_mixer_set_stereo(devc, devc->channels == 2);
516 if (sb_dsp_command(devc, 0x40))
517 sb_dsp_command(devc, devc->tconst);
518 sb_dsp_command(devc, DSP_CMD_SPKON);
520 if (devc->model == MDL_JAZZ || devc->model == MDL_SMW)
522 if (devc->bits == AFMT_S16_LE)
523 bits = 0x04; /* 16 bit mode */
525 if (devc->channels == 1)
526 sb_dsp_command(devc, 0xa0 | bits); /* Mono output */
528 sb_dsp_command(devc, 0xa8 | bits); /* Stereo output */
532 tmp = sb_getmixer(devc, 0x0e);
533 if (devc->channels == 1)
537 sb_setmixer(devc, 0x0e, tmp);
539 restore_flags(flags);
540 devc->trigger_bits = 0;
544 static int sbpro_audio_set_speed(int dev, int speed)
546 sb_devc *devc = audio_devs[dev]->devc;
554 if (devc->channels > 1 && speed > 22050)
556 sb201_audio_set_speed(dev, speed);
561 static short sbpro_audio_set_channels(int dev, short channels)
563 sb_devc *devc = audio_devs[dev]->devc;
565 if (channels == 1 || channels == 2)
567 if (channels != devc->channels)
569 devc->channels = channels;
570 if (devc->model == MDL_SBPRO && devc->channels == 2)
571 sbpro_audio_set_speed(dev, devc->speed);
574 return devc->channels;
577 static int jazz16_audio_set_speed(int dev, int speed)
579 sb_devc *devc = audio_devs[dev]->devc;
584 int s = speed * devc->channels;
591 devc->tconst = (256 - ((1000000 + s / 2) / s)) & 0xff;
593 tmp = 256 - devc->tconst;
594 speed = ((1000000 + tmp / 2) / tmp) / devc->channels;
602 * SB16 specific routines
605 static int sb16_audio_set_speed(int dev, int speed)
607 sb_devc *devc = audio_devs[dev]->devc;
608 int max_speed = devc->submodel == SUBMDL_ALS100 ? 48000 : 44100;
612 if (speed < 5000) /* which of these */
613 speed = 4000; /* is correct ??? */
615 if (speed > max_speed)
623 static unsigned int sb16_audio_set_bits(int dev, unsigned int bits)
625 sb_devc *devc = audio_devs[dev]->devc;
629 if (bits == AFMT_U8 || bits == AFMT_S16_LE)
632 devc->bits = AFMT_U8;
638 static int sb16_audio_prepare_for_input(int dev, int bsize, int bcount)
640 sb_devc *devc = audio_devs[dev]->devc;
642 if (!devc->fullduplex)
644 audio_devs[dev]->dmap_out->dma =
645 audio_devs[dev]->dmap_in->dma =
646 devc->bits == AFMT_S16_LE ?
647 devc->dma16 : devc->dma8;
649 else if (devc->bits == AFMT_S16_LE)
651 audio_devs[dev]->dmap_out->dma = devc->dma8;
652 audio_devs[dev]->dmap_in->dma = devc->dma16;
656 audio_devs[dev]->dmap_out->dma = devc->dma16;
657 audio_devs[dev]->dmap_in->dma = devc->dma8;
660 devc->trigger_bits = 0;
664 static int sb16_audio_prepare_for_output(int dev, int bsize, int bcount)
666 sb_devc *devc = audio_devs[dev]->devc;
668 if (!devc->fullduplex)
670 audio_devs[dev]->dmap_out->dma =
671 audio_devs[dev]->dmap_in->dma =
672 devc->bits == AFMT_S16_LE ?
673 devc->dma16 : devc->dma8;
675 else if (devc->bits == AFMT_S16_LE)
677 audio_devs[dev]->dmap_out->dma = devc->dma8;
678 audio_devs[dev]->dmap_in->dma = devc->dma16;
682 audio_devs[dev]->dmap_out->dma = devc->dma16;
683 audio_devs[dev]->dmap_in->dma = devc->dma8;
686 devc->trigger_bits = 0;
690 static void sb16_audio_output_block(int dev, unsigned long buf, int count,
693 unsigned long flags, cnt;
694 sb_devc *devc = audio_devs[dev]->devc;
697 if (!devc->fullduplex || devc->bits == AFMT_S16_LE)
699 devc->irq_mode = IMODE_OUTPUT;
700 devc->intr_active = 1;
704 devc->irq_mode_16 = IMODE_OUTPUT;
705 devc->intr_active_16 = 1;
712 if (devc->fullduplex)
713 devc->bits = (devc->bits == AFMT_S16_LE) ?
714 AFMT_U8 : AFMT_S16_LE;
715 restore_flags (flags);
718 if (devc->bits == AFMT_S16_LE)
725 /* DMAbuf_start_dma (dev, buf, count, DMA_MODE_WRITE); */
727 sb_dsp_command(devc, 0x41);
728 sb_dsp_command(devc, (unsigned char) ((devc->speed >> 8) & 0xff));
729 sb_dsp_command(devc, (unsigned char) (devc->speed & 0xff));
731 sb_dsp_command(devc, (devc->bits == AFMT_S16_LE ? 0xb6 : 0xc6));
732 sb_dsp_command(devc, ((devc->channels == 2 ? 0x20 : 0) +
733 (devc->bits == AFMT_S16_LE ? 0x10 : 0)));
734 sb_dsp_command(devc, (unsigned char) (cnt & 0xff));
735 sb_dsp_command(devc, (unsigned char) (cnt >> 8));
737 /* restore real value after all programming */
739 restore_flags(flags);
744 * This fails on the Cyrix MediaGX. If you don't have the DMA enabled
745 * before the first sample arrives it locks up. However even if you
746 * do enable the DMA in time you just get DMA timeouts and missing
747 * interrupts and stuff, so for now I've not bothered fixing this either.
750 static void sb16_audio_start_input(int dev, unsigned long buf, int count, int intrflag)
752 unsigned long flags, cnt;
753 sb_devc *devc = audio_devs[dev]->devc;
755 if (!devc->fullduplex || devc->bits != AFMT_S16_LE)
757 devc->irq_mode = IMODE_INPUT;
758 devc->intr_active = 1;
762 devc->irq_mode_16 = IMODE_INPUT;
763 devc->intr_active_16 = 1;
767 if (devc->bits == AFMT_S16_LE)
774 /* DMAbuf_start_dma (dev, buf, count, DMA_MODE_READ); */
776 sb_dsp_command(devc, 0x42);
777 sb_dsp_command(devc, (unsigned char) ((devc->speed >> 8) & 0xff));
778 sb_dsp_command(devc, (unsigned char) (devc->speed & 0xff));
780 sb_dsp_command(devc, (devc->bits == AFMT_S16_LE ? 0xbe : 0xce));
781 sb_dsp_command(devc, ((devc->channels == 2 ? 0x20 : 0) +
782 (devc->bits == AFMT_S16_LE ? 0x10 : 0)));
783 sb_dsp_command(devc, (unsigned char) (cnt & 0xff));
784 sb_dsp_command(devc, (unsigned char) (cnt >> 8));
786 restore_flags(flags);
789 static void sb16_audio_trigger(int dev, int bits)
791 sb_devc *devc = audio_devs[dev]->devc;
793 int bits_16 = bits & devc->irq_mode_16;
794 bits &= devc->irq_mode;
796 if (!bits && !bits_16)
797 sb_dsp_command(devc, 0xd0); /* Halt DMA */
802 switch (devc->irq_mode)
805 sb16_audio_start_input(dev,
812 sb16_audio_output_block(dev,
821 switch (devc->irq_mode_16)
824 sb16_audio_start_input(dev,
827 devc->trg_intrflag_16);
831 sb16_audio_output_block(dev,
834 devc->trg_intrflag_16);
840 devc->trigger_bits = bits | bits_16;
843 static unsigned char lbuf8[2048];
844 static signed short *lbuf16 = (signed short *)lbuf8;
845 #define LBUFCOPYSIZE 1024
847 sb16_copy_from_user(int dev,
848 char *localbuf, int localoffs,
849 const char *userbuf, int useroffs,
850 int max_in, int max_out,
851 int *used, int *returned,
854 sb_devc *devc = audio_devs[dev]->devc;
855 int i, c, p, locallen;
859 /* if not duplex no conversion */
860 if (!devc->fullduplex)
862 copy_from_user (localbuf + localoffs, userbuf + useroffs, len);
866 else if (devc->bits == AFMT_S16_LE)
869 /* max_in >> 1, max number of samples in ( 16 bits ) */
870 /* max_out, max number of samples out ( 8 bits ) */
871 /* len, number of samples that will be taken ( 16 bits )*/
872 /* c, count of samples remaining in buffer ( 16 bits )*/
873 /* p, count of samples already processed ( 16 bits )*/
874 len = ( (max_in >> 1) > max_out) ? max_out : (max_in >> 1);
877 buf8 = (unsigned char *)(localbuf + localoffs);
880 locallen = (c >= LBUFCOPYSIZE ? LBUFCOPYSIZE : c);
881 /* << 1 in order to get 16 bit samples */
882 copy_from_user (lbuf16,
883 userbuf+useroffs + (p << 1),
885 for (i = 0; i < locallen; i++)
887 buf8[p+i] = ~((lbuf16[i] >> 8) & 0xff) ^ 0x80;
889 c -= locallen; p += locallen;
891 /* used = ( samples * 16 bits size ) */
893 /* returned = ( samples * 8 bits size ) */
899 /* max_in, max number of samples in ( 8 bits ) */
900 /* max_out >> 1, max number of samples out ( 16 bits ) */
901 /* len, number of samples that will be taken ( 8 bits )*/
902 /* c, count of samples remaining in buffer ( 8 bits )*/
903 /* p, count of samples already processed ( 8 bits )*/
904 len = max_in > (max_out >> 1) ? (max_out >> 1) : max_in;
907 buf16 = (signed short *)(localbuf + localoffs);
910 locallen = (c >= LBUFCOPYSIZE ? LBUFCOPYSIZE : c);
911 copy_from_user (lbuf8,
912 userbuf+useroffs + p,
914 for (i = 0; i < locallen; i++)
916 buf16[p+i] = (~lbuf8[i] ^ 0x80) << 8;
918 c -= locallen; p += locallen;
920 /* used = ( samples * 8 bits size ) */
922 /* returned = ( samples * 16 bits size ) */
923 *returned = len << 1;
928 sb16_audio_mmap(int dev)
930 sb_devc *devc = audio_devs[dev]->devc;
931 devc->fullduplex = 0;
934 static struct audio_driver sb1_audio_driver = /* SB1.x */
938 close: sb_audio_close,
939 output_block: sb_set_output_parms,
940 start_input: sb_set_input_parms,
941 prepare_for_input: sb1_audio_prepare_for_input,
942 prepare_for_output: sb1_audio_prepare_for_output,
943 halt_io: sb1_audio_halt_xfer,
944 trigger: sb1_audio_trigger,
945 set_speed: sb1_audio_set_speed,
946 set_bits: sb1_audio_set_bits,
947 set_channels: sb1_audio_set_channels
950 static struct audio_driver sb20_audio_driver = /* SB2.0 */
954 close: sb_audio_close,
955 output_block: sb_set_output_parms,
956 start_input: sb_set_input_parms,
957 prepare_for_input: sb1_audio_prepare_for_input,
958 prepare_for_output: sb1_audio_prepare_for_output,
959 halt_io: sb1_audio_halt_xfer,
960 trigger: sb20_audio_trigger,
961 set_speed: sb1_audio_set_speed,
962 set_bits: sb1_audio_set_bits,
963 set_channels: sb1_audio_set_channels
966 static struct audio_driver sb201_audio_driver = /* SB2.01 */
970 close: sb_audio_close,
971 output_block: sb_set_output_parms,
972 start_input: sb_set_input_parms,
973 prepare_for_input: sb1_audio_prepare_for_input,
974 prepare_for_output: sb1_audio_prepare_for_output,
975 halt_io: sb1_audio_halt_xfer,
976 trigger: sb20_audio_trigger,
977 set_speed: sb201_audio_set_speed,
978 set_bits: sb1_audio_set_bits,
979 set_channels: sb1_audio_set_channels
982 static struct audio_driver sbpro_audio_driver = /* SB Pro */
986 close: sb_audio_close,
987 output_block: sb_set_output_parms,
988 start_input: sb_set_input_parms,
989 prepare_for_input: sbpro_audio_prepare_for_input,
990 prepare_for_output: sbpro_audio_prepare_for_output,
991 halt_io: sb1_audio_halt_xfer,
992 trigger: sb20_audio_trigger,
993 set_speed: sbpro_audio_set_speed,
994 set_bits: sb1_audio_set_bits,
995 set_channels: sbpro_audio_set_channels
998 static struct audio_driver jazz16_audio_driver = /* Jazz16 and SM Wave */
1001 open: sb_audio_open,
1002 close: sb_audio_close,
1003 output_block: sb_set_output_parms,
1004 start_input: sb_set_input_parms,
1005 prepare_for_input: sbpro_audio_prepare_for_input,
1006 prepare_for_output: sbpro_audio_prepare_for_output,
1007 halt_io: sb1_audio_halt_xfer,
1008 trigger: sb20_audio_trigger,
1009 set_speed: jazz16_audio_set_speed,
1010 set_bits: sb16_audio_set_bits,
1011 set_channels: sbpro_audio_set_channels
1014 static struct audio_driver sb16_audio_driver = /* SB16 */
1017 open: sb_audio_open,
1018 close: sb_audio_close,
1019 output_block: sb_set_output_parms,
1020 start_input: sb_set_input_parms,
1021 prepare_for_input: sb16_audio_prepare_for_input,
1022 prepare_for_output: sb16_audio_prepare_for_output,
1023 halt_io: sb1_audio_halt_xfer,
1024 copy_user: sb16_copy_from_user,
1025 trigger: sb16_audio_trigger,
1026 set_speed: sb16_audio_set_speed,
1027 set_bits: sb16_audio_set_bits,
1028 set_channels: sbpro_audio_set_channels,
1029 mmap: sb16_audio_mmap
1032 void sb_audio_init(sb_devc * devc, char *name, struct module *owner)
1034 int audio_flags = 0;
1035 int format_mask = AFMT_U8;
1037 struct audio_driver *driver = &sb1_audio_driver;
1039 switch (devc->model)
1041 case MDL_SB1: /* SB1.0 or SB 1.5 */
1042 DDB(printk("Will use standard SB1.x driver\n"));
1043 audio_flags = DMA_HARDSTOP;
1047 DDB(printk("Will use SB2.0 driver\n"));
1048 audio_flags = DMA_AUTOMODE;
1049 driver = &sb20_audio_driver;
1053 DDB(printk("Will use SB2.01 (high speed) driver\n"));
1054 audio_flags = DMA_AUTOMODE;
1055 driver = &sb201_audio_driver;
1060 DDB(printk("Will use Jazz16 driver\n"));
1061 audio_flags = DMA_AUTOMODE;
1062 format_mask |= AFMT_S16_LE;
1063 driver = &jazz16_audio_driver;
1067 DDB(printk("Will use ESS ES688/1688 driver\n"));
1068 driver = ess_audio_init (devc, &audio_flags, &format_mask);
1072 DDB(printk("Will use SB16 driver\n"));
1073 audio_flags = DMA_AUTOMODE;
1074 format_mask |= AFMT_S16_LE;
1075 if (devc->dma8 != devc->dma16 && devc->dma16 != -1)
1077 audio_flags |= DMA_DUPLEX;
1080 driver = &sb16_audio_driver;
1084 DDB(printk("Will use SB Pro driver\n"));
1085 audio_flags = DMA_AUTOMODE;
1086 driver = &sbpro_audio_driver;
1090 driver->owner = owner;
1092 if ((devc->dev = sound_install_audiodrv(AUDIO_DRIVER_VERSION,
1093 name,driver, sizeof(struct audio_driver),
1094 audio_flags, format_mask, devc,
1096 devc->duplex ? devc->dma16 : devc->dma8)) < 0)
1098 printk(KERN_ERR "Sound Blaster: unable to install audio.\n");
1101 audio_devs[devc->dev]->mixer_dev = devc->my_mixerdev;
1102 audio_devs[devc->dev]->min_fragment = 5;