sb16.c revision 41653
1/* 2 * sound/sb_dsp.c 3 * 4 * driver for the SoundBlaster and clones. 5 * 6 * Copyright 1997,1998 Luigi Rizzo. 7 * 8 * Derived from files in the Voxware 3.5 distribution, 9 * Copyright by Hannu Savolainen 1994, under the same copyright 10 * conditions. 11 * 12 * Redistribution and use in source and binary forms, with or without 13 * modification, are permitted provided that the following conditions 14 * are met: 15 * 1. Redistributions of source code must retain the above copyright 16 * notice, this list of conditions and the following disclaimer. 17 * 2. Redistributions in binary form must reproduce the above copyright 18 * notice, this list of conditions and the following disclaimer in 19 * the documentation and/or other materials provided with the 20 * distribution. 21 * 22 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' 23 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 24 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A 25 * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR 26 * OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 27 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 28 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF 29 * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED 30 * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 31 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN 32 * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 33 * POSSIBILITY OF SUCH DAMAGE. 34 * 35 */ 36 37/* 38 * use this as a template file for board-specific drivers. 39 * The next two lines (and the final #endif) are in all drivers: 40 */ 41 42#include <i386/isa/snd/sound.h> 43#if NPCM > 0 44 45/* 46 * Begin with the board-specific include files... 47 */ 48 49#define __SB_MIXER_C__ /* XXX warning... */ 50#include <i386/isa/snd/sbcard.h> 51 52/* 53 * then prototypes of functions which go in the snddev_info 54 * (usually static, unless they are shared by other modules)... 55 */ 56 57static int sb_probe(struct isa_device *dev); 58static int sb_attach(struct isa_device *dev); 59 60static d_open_t sb_dsp_open; 61static d_close_t sb_dsp_close; 62static d_ioctl_t sb_dsp_ioctl; 63static irq_proc_t sb_intr; 64static snd_callback_t sb_callback; 65 66/* 67 * and prototypes for other private functions defined in this module. 68 */ 69 70static void sb_dsp_init(snddev_info *d, struct isa_device *dev); 71static void sb_mix_init(snddev_info *d); 72static int sb_mixer_set(snddev_info *d, int dev, int value); 73static int dsp_speed(snddev_info *d); 74static void sb_mixer_reset(snddev_info *d); 75 76u_int sb_get_byte(int io_base); 77int ess_write(int io_base, u_char reg, int val); 78int ess_read(int io_base, u_char reg); 79 80/* 81 * Then put here the descriptors for the various boards supported 82 * by this module, properly initialized. 83 */ 84 85snddev_info sb_op_desc = { 86 "basic soundblaster", 87 88 SNDCARD_SB, 89 sb_probe, 90 sb_attach, 91 92 sb_dsp_open, 93 sb_dsp_close /* sb_close */, 94 NULL /* use generic sndread */, 95 NULL /* use generic sndwrite */, 96 sb_dsp_ioctl, 97 sndselect, 98 99 sb_intr, 100 sb_callback, 101 102 DSP_BUFFSIZE, /* bufsize */ 103 104 AFMT_STEREO | AFMT_U8, /* audio format */ 105 106} ; 107 108/* 109 * Then the file continues with the body of all functions 110 * directly referenced in the descriptor. 111 */ 112 113/* 114 * the probe routine for the SoundBlaster only consists in 115 * resetting the dsp and testing if it is there. 116 * Version detection etc. will be done at attach time. 117 * 118 * Remember, ISA probe routines are supposed to return the 119 * size of io space used. 120 */ 121 122static int 123sb_probe(struct isa_device *dev) 124{ 125 bzero(&pcm_info[dev->id_unit], sizeof(pcm_info[dev->id_unit]) ); 126 if (dev->id_iobase == -1) { 127 dev->id_iobase = 0x220; 128 BVDDB(printf("sb_probe: no address supplied, try defaults (0x220,0x240)\n");) 129 if (snd_conflict(dev->id_iobase)) 130 dev->id_iobase = 0x240; 131 } 132 if (snd_conflict(dev->id_iobase)) 133 return 0 ; 134 135 if (sb_reset_dsp(dev->id_iobase)) 136 return 16 ; /* the SB uses 16 registers... */ 137 else 138 return 0; 139} 140 141static int 142sb_attach(struct isa_device *dev) 143{ 144 snddev_info *d = &pcm_info[dev->id_unit] ; 145 146 dev->id_alive = 16 ; /* number of io ports */ 147 /* should be already set but just in case... */ 148 sb_dsp_init(d, dev); 149 return 0 ; 150} 151 152/* 153 * here are the main routines from the switches. 154 */ 155 156/* 157 * Unlike MSS, the sb only supports a single open (does not mean 158 * that only a single process is using it, since it can fork 159 * afterwards, or pass the descriptor to another process). 160 * 161 */ 162static int 163sb_dsp_open(dev_t dev, int flags, int mode, struct proc * p) 164{ 165 snddev_info *d; 166 int unit ; 167 168 dev = minor(dev); 169 unit = dev >> 4 ; 170 d = &pcm_info[unit] ; 171 172 DEB(printf("<%s>%d : open\n", d->name, unit)); 173 174 if (d->flags & SND_F_BUSY) { 175 DEB(printf("<%s>%d open: device busy\n", d->name, unit)); 176 return EBUSY ; 177 } 178 179 d->wsel.si_pid = 0; 180 d->wsel.si_flags = 0; 181 182 d->rsel.si_pid = 0; 183 d->rsel.si_flags = 0; 184 185 d->dbuf_out.total = d->dbuf_out.prev_total = 0 ; 186 d->dbuf_in.total = d->dbuf_in.prev_total = 0 ; 187 188 d->flags = 0 ; 189 d->bd_flags &= ~BD_F_HISPEED ; 190 191 switch ( dev & 0xf ) { 192 case SND_DEV_DSP16 : 193 if ((d->audio_fmt & AFMT_S16_LE) == 0) { 194 printf("sorry, 16-bit not supported on SB %d.%02d\n", 195 (d->bd_id >>8) & 0xff, d->bd_id & 0xff); 196 return ENXIO; 197 } 198 d->play_fmt = d->rec_fmt = AFMT_S16_LE ; 199 break; 200 case SND_DEV_AUDIO : 201 d->play_fmt = d->rec_fmt = AFMT_MU_LAW ; 202 break ; 203 case SND_DEV_DSP : 204 d->play_fmt = d->rec_fmt = AFMT_U8 ; 205 break ; 206 } 207 /* 208 * since the SB is not simmetric, I use the open mode to select 209 * which channel should be privileged, and disable I/O in the 210 * other direction. 211 * In case the board is opened RW, we don't have enough 212 * information on what to do. Temporarily, privilege the 213 * playback channel, which is used more often, and set the other 214 * one to U8. 215 */ 216 if ( (flags & FREAD) == 0) /* opened write only */ 217 d->rec_fmt = 0 ; 218 else if ( (flags & FWRITE) == 0) /* opened read only */ 219 d->play_fmt = 0 ; 220 else /* opened read/write */ 221 d->rec_fmt = (d->play_fmt == AFMT_S16_LE) ? AFMT_U8 : AFMT_S16_LE ; 222 223 d->flags |= SND_F_BUSY ; 224 d->play_speed = d->rec_speed = DSP_DEFAULT_SPEED ; 225 226 if (flags & O_NONBLOCK) 227 d->flags |= SND_F_NBIO ; 228 229 sb_reset_dsp(d->io_base); 230 if (d->bd_flags & BD_F_ESS) 231 sb_cmd(d->io_base, 0xc6 ); /* enable extended ESS mode */ 232 ask_init(d); 233 234 return 0; 235} 236 237static int 238sb_dsp_close(dev_t dev, int flags, int mode, struct proc * p) 239{ 240 int unit; 241 snddev_info *d; 242 u_long s; 243 244 dev = minor(dev); 245 unit = dev >> 4 ; 246 d = &pcm_info[unit] ; 247 248 s = spltty(); 249 d->flags |= SND_F_CLOSING ; 250 splx(s); 251 snd_flush(d); 252 253 sb_cmd(d->io_base, DSP_CMD_SPKOFF ); /* XXX useless ? */ 254 255 d->flags = 0 ; 256 return 0 ; 257} 258 259static int 260sb_dsp_ioctl(dev_t dev, u_long cmd, caddr_t arg, int mode, struct proc * p) 261{ 262 int unit; 263 snddev_info *d; 264 265 dev = minor(dev); 266 unit = dev >> 4 ; 267 d = &pcm_info[unit] ; 268 269 /* 270 * handle mixer calls first. Reads are in the default handler, 271 * so do not bother about them. 272 */ 273 if ( (cmd & MIXER_WRITE(0)) == MIXER_WRITE(0) ) 274 return sb_mixer_set(d, cmd & 0xff, *(int *)arg) ; 275 276 /* 277 * for the remaining functions, use the default handler. 278 * ENOSYS means that the default handler should take care 279 * of implementing the ioctl. 280 */ 281 282 return ENOSYS ; 283} 284 285static void 286sb_intr(int unit) 287{ 288 snddev_info *d = &pcm_info[unit]; 289 int reason = 3, c=1, io_base = d->io_base; 290 291 DEB(printf("got sb_intr for unit %d, flags 0x%08lx\n", unit, d->flags)); 292 293 /* 294 * SB < 4.0 is half duplex and has only 1 bit for int source, 295 * so we fake it. SB 4.x (SB16) has the int source in a separate 296 * register. 297 * The Vibra16X has separate flags for 8 and 16 bit transfers, but 298 * I have no idea how to tell capture from playback interrupts... 299 */ 300#define PLAIN_SB16(x) ( ( (x) & (BD_F_SB16|BD_F_SB16X) ) == BD_F_SB16) 301again: 302 if (d->bd_flags & BD_F_SB16) { 303 c = sb_getmixer(io_base, IRQ_STAT); 304 /* this tells us if the source is 8-bit or 16-bit dma. We 305 * have to check the io channel to map it to read or write... 306 */ 307 reason = 0 ; 308 if ( c & 1 ) { /* 8-bit dma */ 309 if (d->play_fmt == AFMT_U8 || d->play_fmt == AFMT_MU_LAW ) 310 reason |= 1; 311 if (d->rec_fmt == AFMT_U8 || d->rec_fmt == AFMT_MU_LAW ) 312 reason |= 2; 313 } 314 if ( c & 2 ) { /* 16-bit dma */ 315 if (d->play_fmt == AFMT_S16_LE) 316 reason |= 1; 317 if (d->rec_fmt == AFMT_S16_LE) 318 reason |= 2; 319 } 320 } 321 /* XXX previous location of ack... */ 322 DEB(printf("sb_intr, flags 0x%08lx reason %d c 0x%x\n", 323 d->flags, reason, c)); 324 if ( reason & 1 ) { /* possibly a write interrupt */ 325 if ( d->dbuf_out.dl ) 326 dsp_wrintr(d); 327 } 328 if ( reason & 2 ) { 329 if ( d->dbuf_in.dl ) 330 dsp_rdintr(d); 331 } 332 if ( c & 2 ) 333 inb(DSP_DATA_AVL16); /* 16-bit int ack */ 334 if (c & 1) 335 inb(DSP_DATA_AVAIL); /* 8-bit int ack */ 336 337 /* 338 * the sb16 might have multiple sources etc. 339 */ 340 if ((d->bd_flags & BD_F_SB16) && (c & 3)) 341 goto again; 342} 343 344/* 345 * device-specific function called back from the dma module. 346 * The reason of the callback is the second argument. 347 * NOTE: during operations, some ioctl can be called to change 348 * settings (e.g. speed, channels, format), and the default 349 * ioctl handler will just record the change and set the 350 * flag SND_F_INIT. The callback routine is in charge of applying 351 * the changes at the next convenient time (typically, at the 352 * start of operations). For full duplex devices, in some cases the 353 * init requires both channels to be idle. 354 */ 355static int 356sb_callback(snddev_info *d, int reason) 357{ 358 int rd = reason & SND_CB_RD ; 359 snd_dbuf *b = (rd) ? & (d->dbuf_in) : & (d->dbuf_out) ; 360 int l = b->dl ; 361 362 switch (reason & SND_CB_REASON_MASK) { 363 case SND_CB_INIT : /* called with int enabled and no pending io */ 364 /* 365 * set the speed 366 */ 367 dsp_speed(d); 368 /* 369 * set the desired DMA blocksize (influences select behaviour) 370 */ 371 snd_set_blocksize(d); 372 /* 373 * since native mulaw is not present, emulate it. 374 */ 375 if ( (d->play_fmt & AFMT_MU_LAW) || (d->rec_fmt & AFMT_MU_LAW) ) 376 d->flags |= SND_F_XLAT8 ; 377 else 378 d->flags &= ~SND_F_XLAT8 ; 379 380 /* 381 * there are too many flavours of SB for my taste... here i try to do 382 * the proper initialization for each one. 383 */ 384 if (PLAIN_SB16(d->bd_flags)) { 385 u_char c, c1 ; 386 387 /* the original SB16 (non-PnP, or PnP, or Vibra16C) 388 * can do full duplex using one 16-bit channel 389 * and one 8-bit channel. It needs to be programmed to 390 * use split format though. 391 * I DON'T do this for the Vibra16X because I have no idea 392 * of what needs to be done there... 393 * 394 * I use the following algorithm: 395 * 1. check which direction(s) are active; 396 * 2. check if we should swap dma channels 397 * 3. check if we can do the swap. 398 */ 399 int swap = 1 ; /* default... */ 400 401 if (d->play_fmt == 0) { 402 /* do whatever the read channel wants */ 403 if ( d->rec_fmt == AFMT_S16_LE && d->dbuf_in.chan > 4 ) 404 swap = 0; 405 if ( d->rec_fmt != AFMT_S16_LE && d->dbuf_in.chan < 4 ) 406 swap = 0; 407 } else { 408 /* privilege the write channel */ 409 if ( d->play_fmt == AFMT_S16_LE && d->dbuf_out.chan > 4 ) 410 swap = 0; 411 if ( d->play_fmt != AFMT_S16_LE && d->dbuf_out.chan < 4 ) 412 swap = 0; 413 if ( d->rec_fmt ) { 414 /* check for possible config errors. 415 * This cannot happen at open time since even in 416 * case of opening rw we privilege the play 417 * channel. 418 */ 419 if (d->rec_fmt == d->play_fmt) { 420 DDB(printf("sorry, read DMA channel unavailable\n")); 421 } 422 } 423 } 424 DEB(printf("sb16: play_fmt %d, rec_fmt %x, swap %d\n", 425 d->play_fmt, d->rec_fmt, swap);) 426 if (swap) { 427 int c = d->dbuf_in.chan ; 428 d->dbuf_in.chan = d->dbuf_out.chan; 429 d->dbuf_out.chan = c ; 430 } 431 } 432 else if (d->bd_flags & BD_F_ESS) { 433 u_char c; 434 435 DEB(printf("SND_CB_INIT, play_fmt == 0x%x, rec_fmt == 0x%x\n", 436 (int) d->play_fmt, (int) d->rec_fmt)); 437 438 /* autoinit DMA mode */ 439 if (d->play_fmt) 440 ess_write(d->io_base, 0xb8, 0x04); 441 else 442 ess_write(d->io_base, 0xb8, 0x0e); 443 444 c = (ess_read(d->io_base, 0xa8) & ~0x03) | 0x01; 445 if ((d->flags & SND_F_STEREO) == 0) 446 c++; 447 ess_write(d->io_base, 0xa8, c); /* select mono/stereo */ 448 ess_write(d->io_base, 0xb9, 2); /* demand 4 bytes/transfer */ 449 450 switch (d->play_fmt ? d->play_fmt : d->rec_fmt) { 451 case AFMT_S16_LE: 452 if (d->flags & SND_F_STEREO) { 453 /* 16 bit stereo */ 454 if (d->play_fmt) 455 ess_write(d->io_base, 0xb6, 0x00); 456 ess_write(d->io_base, 0xb7, 0x71); 457 ess_write(d->io_base, 0xb7, 0xbc); 458 } 459 else { 460 /* 16 bit mono */ 461 if (d->play_fmt) 462 ess_write(d->io_base, 0xb6, 0x00); 463 ess_write(d->io_base, 0xb7, 0x71); 464 ess_write(d->io_base, 0xb7, 0xf4); 465 } 466 break; 467 case AFMT_U8: 468 if (d->flags & SND_F_STEREO) { 469 /* 8 bit stereo */ 470 if (d->play_fmt) 471 ess_write(d->io_base, 0xb6, 0x80); 472 ess_write(d->io_base, 0xb7, 0x51); 473 ess_write(d->io_base, 0xb7, 0x98); 474 } 475 else { 476 /* 8 bit mono */ 477 if (d->play_fmt) 478 ess_write(d->io_base, 0xb6, 0x80); 479 ess_write(d->io_base, 0xb7, 0x51); 480 ess_write(d->io_base, 0xb7, 0xd0); 481 } 482 break; 483 } 484 ess_write(d->io_base, 0xb1, 485 ess_read(d->io_base, 0xb1) | 0x50); 486 ess_write(d->io_base, 0xb2, 487 ess_read(d->io_base, 0xb1) | 0x50); 488 } 489 reset_dbuf(& (d->dbuf_in), SND_CHAN_RD ); 490 reset_dbuf(& (d->dbuf_out), SND_CHAN_WR ); 491 break ; 492 493 case SND_CB_START : /* called with int disabled */ 494 if (d->bd_flags & BD_F_SB16) { 495 u_char c, c1 ; 496 497 if (d->bd_flags & BD_F_SB16X) { 498 /* just a guess: on the Vibra16X, the first 499 * op started takes the first dma channel, 500 * the second one takes the next... 501 * The default is to be ready for play. 502 */ 503 int swap = 0 ; 504 DEB(printf("start %s -- now dma %d:%d\n", 505 rd ? "rd" : "wr", 506 d->dbuf_out.chan, d->dbuf_in.chan);); 507 /* swap only if both channels are idle 508 * play: dl=0, since there is no pause; 509 * rec: rl=0 510 */ 511 if ( rd && d->dbuf_out.dl == 0 && d->dbuf_in.rl == 0 ) { 512 /* must swap channels, but also save dl */ 513 int c = d->dbuf_in.chan ; 514 int dl = d->dbuf_in.dl ; 515 d->dbuf_in.chan = d->dbuf_out.chan; 516 d->dbuf_out.chan = c ; 517 reset_dbuf(& (d->dbuf_in), SND_CHAN_RD ); 518 reset_dbuf(& (d->dbuf_out), SND_CHAN_WR ); 519 d->dbuf_in.dl = dl ; 520 printf("swapped -- now dma %d:%d\n", 521 d->dbuf_out.chan, d->dbuf_in.chan); 522 } 523 } 524 525 /* 526 * XXX note: c1 and l should be set basing on d->rec_fmt, 527 * but there is no choice once a 16 or 8-bit channel 528 * is assigned. This means that if the application 529 * tries to use a bad format, the sound will not be nice. 530 */ 531 if ( b->chan > 4 532 || (rd && d->rec_fmt == AFMT_S16_LE) 533 || (!rd && d->play_fmt == AFMT_S16_LE) 534 ) { 535 c = DSP_F16_AUTO | DSP_F16_FIFO_ON | DSP_DMA16 ; 536 c1 = DSP_F16_SIGNED ; 537 l /= 2 ; 538 } else { 539 c = DSP_F16_AUTO | DSP_F16_FIFO_ON | DSP_DMA8 ; 540 c1 = 0 ; 541 } 542 c |= (rd) ? DSP_F16_ADC : DSP_F16_DAC ; 543 if (d->flags & SND_F_STEREO) 544 c1 |= DSP_F16_STEREO ; 545 546 sb_cmd(d->io_base, c ); 547 sb_cmd3(d->io_base, c1 , l - 1) ; 548 } else if (d->bd_flags & BD_F_ESS) { 549 u_long fmt = rd ? d->rec_fmt : d->play_fmt; 550 551 DEB(printf("SND_CB_START: %s (%d)\n", rd ? "rd" : "wr", l)); 552 if (fmt == AFMT_S16_LE) 553 l >>= 1; 554 l--; 555 if (!rd) 556 sb_cmd(d->io_base, DSP_CMD_SPKON); 557 ess_write(d->io_base, 0xa4, l); 558 ess_write(d->io_base, 0xa5, l >> 8); 559 ess_write(d->io_base, 0xb8, 560 ess_read(d->io_base, 0xb8) | (rd ? 0x0f : 0x05)); 561 } else { /* SBPro -- stereo not supported */ 562 u_char c ; 563 if (!rd) 564 sb_cmd(d->io_base, DSP_CMD_SPKON); 565 /* code for the SB2 and SB3, only MONO */ 566 if (d->bd_flags & BD_F_HISPEED) 567 c = (rd) ? 0x98 : 0x90 ; 568 else 569 c = (rd) ? 0x2c : 0x1c ; 570 if (d->flags & SND_F_STEREO) 571 sb_setmixer(d->io_base, 0xe, 2 ); 572 else 573 sb_setmixer(d->io_base, 0xe, 0 ); 574 /* 575 * some ESS extensions -- they can do 16 bits 576 */ 577 if ( (rd && d->rec_fmt == AFMT_S16_LE) || 578 (!rd && d->play_fmt == AFMT_S16_LE) ) { 579 c |= 1; 580 l /= 2 ; 581 } 582 sb_cmd3(d->io_base, 0x48 , l - 1) ; 583 sb_cmd(d->io_base, c ) ; 584 } 585 break; 586 587 case SND_CB_ABORT : /* XXX */ 588 case SND_CB_STOP : 589 { 590 int cmd = DSP_CMD_DMAPAUSE_8 ; /* default: halt 8 bit chan */ 591 DEB(printf("SND_CB_XXX: reason 0x%x\n", reason)); 592 if ( b->chan > 4 593 || (rd && d->rec_fmt == AFMT_S16_LE) 594 || (!rd && d->play_fmt == AFMT_S16_LE) 595 ) 596 cmd = DSP_CMD_DMAPAUSE_16 ; 597 if (d->bd_flags & BD_F_HISPEED) { 598 sb_reset_dsp(d->io_base); 599 if (d->bd_flags & BD_F_ESS) 600 sb_cmd(d->io_base, 0xc6 ); /* enable extended ESS mode */ 601 d->flags |= SND_F_INIT ; 602 } else { 603 sb_cmd(d->io_base, cmd); /* pause dma. */ 604 /* 605 * The above seems to have the undocumented side effect of 606 * blocking the other side as well. If the other 607 * channel was active (SB16) I have to re-enable it :( 608 */ 609 if ( (rd && d->dbuf_out.dl) || 610 (!rd && d->dbuf_in.dl) ) 611 sb_cmd(d->io_base, cmd == DSP_CMD_DMAPAUSE_8 ? 612 0xd6 : 0xd4); /* continue other dma */ 613 } 614 if (d->bd_flags & BD_F_SB16X) { 615 /* restore possible swapped channels. 616 * The default is to be ready for play. 617 * XXX right now, it kills all input on overflow 618 */ 619 if ( rd && d->dbuf_out.dl == 0 ) { 620 /* must swap channels ? */ 621 int c = d->dbuf_in.chan ; 622 d->dbuf_in.chan = d->dbuf_out.chan; 623 d->dbuf_out.chan = c ; 624 reset_dbuf(& (d->dbuf_in), SND_CHAN_RD ); 625 reset_dbuf(& (d->dbuf_out), SND_CHAN_WR ); 626 printf("restored -- now dma %d:%d\n", 627 d->dbuf_out.chan, d->dbuf_in.chan); 628 } 629 } 630 } 631 DEB( sb_cmd(d->io_base, DSP_CMD_SPKOFF) ); /* speaker off */ 632 break ; 633 634 } 635 return 0 ; 636} 637 638/* 639 * The second part of the file contains all functions specific to 640 * the board and (usually) not exported to other modules. 641 */ 642 643int 644sb_reset_dsp(int io_base) 645{ 646 int loopc; 647 648 outb(io_base + SBDSP_RST, 3); 649 DELAY(100); 650 outb(io_base + SBDSP_RST, 0); 651 for (loopc = 0; loopc<100 && !(inb(DSP_DATA_AVAIL) & 0x80); loopc++) 652 DELAY(30); 653 654 if (inb(DSP_READ) != 0xAA) { 655 DEB(printf("sb_reset_dsp 0x%x failed\n", io_base)); 656 return 0; /* Sorry */ 657 } 658 return 1; 659} 660 661/* 662 * only used in sb_attach from here. 663 */ 664 665static void 666sb_dsp_init(snddev_info *d, struct isa_device *dev) 667{ 668 int i, x; 669 char *fmt = NULL ; 670 int io_base = dev->id_iobase ; 671 672 d->bd_id = 0 ; 673 674 sb_reset_dsp(io_base); 675 sb_cmd(io_base, DSP_CMD_GETVER); /* Get version */ 676 677 for (i = 10000; i; i--) { /* perhaps wait longer on a fast machine ? */ 678 if (inb(DSP_DATA_AVAIL) & 0x80) { /* wait for Data Ready */ 679 if ( (d->bd_id & 0xff00) == 0) 680 d->bd_id = inb(DSP_READ) << 8; /* major */ 681 else { 682 d->bd_id |= inb(DSP_READ); /* minor */ 683 break; 684 } 685 } else 686 DELAY(20); 687 } 688 689 /* 690 * now do various initializations depending on board id. 691 */ 692 693 fmt = "SoundBlaster %d.%d" ; /* default */ 694 695 switch ( d->bd_id >> 8 ) { 696 case 0 : 697 printf("\n\nFailed to get SB version (%x) - possible I/O conflict\n\n", 698 inb(DSP_DATA_AVAIL)); 699 d->bd_id = 0x100; 700 case 1 : /* old sound blaster has nothing... */ 701 break ; 702 703 case 2 : 704 d->dbuf_in.chan = d->dbuf_out.chan ; /* half duplex */ 705 d->bd_flags |= BD_F_DUP_MIDI ; 706 707 if (d->bd_id == 0x200) 708 break ; /* no mixer on the 2.0 */ 709 d->bd_flags &= ~BD_F_MIX_MASK ; 710 d->bd_flags |= BD_F_MIX_CT1335 ; 711 712 break ; 713 case 4 : 714 fmt = "SoundBlaster 16 %d.%d"; 715 d->audio_fmt |= AFMT_FULLDUPLEX | AFMT_WEIRD | AFMT_S8 | AFMT_S16_LE; 716 d->bd_flags |= BD_F_SB16; 717 d->bd_flags &= ~BD_F_MIX_MASK ; 718 d->bd_flags |= BD_F_MIX_CT1745 ; 719 720 /* soft irq/dma configuration */ 721 x = -1 ; 722 if (d->irq == 5) x = 2; 723 else if (d->irq == 7) x = 4; 724 else if (d->irq == 9) x = 1; 725 else if (d->irq == 10) x = 8; 726 if (x == -1) 727 printf("<%s>%d: bad irq %d (only 5,7,9,10 allowed)\n", 728 d->name, dev->id_unit, d->irq); 729 else 730 sb_setmixer(io_base, IRQ_NR, x); 731 if (d->dbuf_out.chan == d->dbuf_in.chan) { 732 printf("WARNING: sb: misconfigured secondary DMA channel\n"); 733 } 734 sb_setmixer(io_base, DMA_NR, (1 << d->dbuf_out.chan) | (1 << d->dbuf_in.chan)); 735 break ; 736 737 case 3 : 738 d->dbuf_in.chan = d->dbuf_out.chan ; /* half duplex */ 739 fmt = "SoundBlaster Pro %d.%d"; 740 d->bd_flags |= BD_F_DUP_MIDI ; 741 d->bd_flags &= ~BD_F_MIX_MASK ; 742 d->bd_flags |= BD_F_MIX_CT1345 ; 743 if (d->bd_id == 0x301) { 744 int ess_major = 0, ess_minor = 0; 745 746 /* 747 * Try to detect ESS chips. 748 */ 749 750 sb_cmd(io_base, DSP_CMD_GETID); /* Return ident. bytes. */ 751 752 for (i = 1000; i; i--) { 753 if (inb(DSP_DATA_AVAIL) & 0x80) { /* wait for Data Ready */ 754 if (ess_major == 0) 755 ess_major = inb(DSP_READ); 756 else { 757 ess_minor = inb(DSP_READ); 758 break; 759 } 760 } else 761 DELAY(20); 762 } 763 764 if (ess_major == 0x48 && (ess_minor & 0xf0) == 0x80) { 765 /* the ESS488 can be treated as an SBPRO */ 766 printf("ESS488 (rev %d)\n", ess_minor & 0x0f); 767 break ; 768 } 769 else if (ess_major == 0x68 && (ess_minor & 0xf0) == 0x80) { 770 u_char cfg; 771 u_char bits; 772 int rev = ess_minor & 0xf; 773 774 if (rev >= 8) 775 printf("ESS1868 (rev %d)\n", rev); 776 else 777 printf("ESS688 (rev %d)\n", rev); 778 d->bd_flags |= BD_F_ESS; 779 d->audio_fmt |= AFMT_S16_LE; 780 781 /* enable extended ESS mode */ 782 sb_cmd(d->io_base, 0xc6); 783 break; 784 } else { 785 printf("Unknown card 0x%x 0x%x -- hope it is SBPRO\n", 786 ess_major, ess_minor); 787 break ; 788 } 789 } 790 791 } 792 793 snprintf(d->name, sizeof(d->name), 794 fmt, (d->bd_id >> 8) &0xff, d->bd_id & 0xff); 795 796 sb_mix_init(d); 797} 798 799static void 800sb_mix_init(snddev_info *d) 801{ 802 switch (d->bd_flags & BD_F_MIX_MASK) { 803 case BD_F_MIX_CT1345 : /* SB 3.0 has 1345 mixer */ 804 805 d->mix_devs = SBPRO_MIXER_DEVICES ; 806 d->mix_rec_devs = SBPRO_RECORDING_DEVICES ; 807 d->mix_recsrc = SOUND_MASK_MIC ; 808 809 sb_setmixer(d->io_base, 0, 1 ); /* reset mixer */ 810 sb_setmixer(d->io_base, MIC_VOL , 0x6 ); /* mic volume max */ 811 sb_setmixer(d->io_base, RECORD_SRC , 0x0 ); /* mic source */ 812 sb_setmixer(d->io_base, FM_VOL , 0x0 ); /* no midi */ 813 break ; 814 815 case BD_F_MIX_CT1745 : /* SB16 mixer ... */ 816 817 d->mix_devs = SB16_MIXER_DEVICES ; 818 d->mix_rec_devs = SB16_RECORDING_DEVICES ; 819 d->mix_recsrc = SOUND_MASK_MIC ; 820 } 821 sb_mixer_reset(d); 822} 823 824/* 825 * Common code for the midi and pcm functions 826 * 827 * sb_cmd write a single byte to the CMD port. 828 * sb_cmd2 write a CMD + 1 byte arg 829 * sb_cmd3 write a CMD + 2 byte arg 830 * sb_get_byte returns a single byte from the DSP data port 831 * 832 * ess_write is actually sb_cmd2 833 * ess_read access ext. regs via sb_cmd(0xc0, reg) followed by sb_get_byte 834 */ 835 836int 837sb_cmd(int io_base, u_char val) 838{ 839 int i; 840 841 for (i = 0; i < 1000 ; i++) { 842 if ((inb(io_base + SBDSP_STATUS) & 0x80) == 0) { 843 outb(io_base + SBDSP_CMD, val); 844 return 1; 845 } 846 if (i > 10) 847 DELAY (i > 100 ? 1000 : 10 ); 848 } 849 850 printf("SoundBlaster: DSP Command(0x%02x) timeout. IRQ conflict ?\n", val); 851 return 0; 852} 853 854int 855sb_cmd3(int io_base, u_char cmd, int val) 856{ 857 if (sb_cmd(io_base, cmd)) { 858 sb_cmd(io_base, val & 0xff ); 859 sb_cmd(io_base, (val>>8) & 0xff ); 860 return 1 ; 861 } else 862 return 0; 863} 864 865int 866sb_cmd2(int io_base, u_char cmd, int val) 867{ 868 if (sb_cmd(io_base, cmd)) { 869 sb_cmd(io_base, val & 0xff ); 870 return 1 ; 871 } else 872 return 0; 873} 874 875/* 876 * in the SB, there is a set of indirect "mixer" registers with 877 * address at offset 4, data at offset 5 878 */ 879void 880sb_setmixer(int io_base, u_int port, u_int value) 881{ 882 u_long flags; 883 884 flags = spltty(); 885 outb(io_base + SB_MIX_ADDR, (u_char) (port & 0xff)); /* Select register */ 886 DELAY(10); 887 outb(io_base + SB_MIX_DATA, (u_char) (value & 0xff)); 888 DELAY(10); 889 splx(flags); 890} 891 892int 893sb_getmixer(int io_base, u_int port) 894{ 895 int val; 896 u_long flags; 897 898 flags = spltty(); 899 outb(io_base + SB_MIX_ADDR, (u_char) (port & 0xff)); /* Select register */ 900 DELAY(10); 901 val = inb(io_base + SB_MIX_DATA); 902 DELAY(10); 903 splx(flags); 904 905 return val; 906} 907 908u_int 909sb_get_byte(int io_base) 910{ 911 int i; 912 913 for (i = 1000; i; i--) 914 if (inb(DSP_DATA_AVAIL) & 0x80) 915 return inb(DSP_READ); 916 else 917 DELAY(20); 918 return 0xffff; 919} 920 921int 922ess_write(int io_base, u_char reg, int val) 923{ 924 return sb_cmd2(io_base, reg, val); 925} 926 927int 928ess_read(int io_base, u_char reg) 929{ 930 if (!sb_cmd(io_base, 0xc0) || !sb_cmd(io_base, reg) ) 931 return 0xffff ; 932 return sb_get_byte(io_base); 933} 934 935 936/* 937 * various utility functions for the DSP 938 */ 939 940/* 941 * dsp_speed updates the speed setting from the descriptor. make sure 942 * it is called at spltty(). 943 * Besides, it takes care of stereo setting. 944 */ 945static int 946dsp_speed(snddev_info *d) 947{ 948 u_char tconst; 949 u_long flags; 950 int max_speed = 44100, speed = d->play_speed ; 951 952 /* 953 * special code for the SB16 954 */ 955 if (d->bd_flags & BD_F_SB16) { 956 RANGE (speed, 5000, 45000); 957 d->play_speed = d->rec_speed = speed ; 958 sb_cmd(d->io_base, 0x41); 959 sb_cmd(d->io_base, d->play_speed >> 8 ); 960 sb_cmd(d->io_base, d->play_speed & 0xff ); 961 sb_cmd(d->io_base, 0x42); 962 sb_cmd(d->io_base, d->rec_speed >> 8 ); 963 sb_cmd(d->io_base, d->rec_speed & 0xff ); 964 return speed ; 965 } 966 967 /* 968 * special code for the ESS ... 969 */ 970 if (d->bd_flags & BD_F_ESS) { 971 int t; 972 RANGE (speed, 5000, 49000); 973 if (speed > 22000) { 974 t = (795500 + speed / 2) / speed; 975 speed = (795500 + t / 2) / t ; 976 t = (256 - t ) | 0x80 ; 977 } else { 978 t = (397700 + speed / 2) / speed; 979 speed = (397700 + t / 2) / t ; 980 t = 128 - t ; 981 } 982 ess_write(d->io_base, 0xa1, t); /* set time constant */ 983 d->play_speed = d->rec_speed = speed ; 984 speed = (speed * 9 ) / 20 ; 985 t = 256-7160000/(speed*82); 986 ess_write(d->io_base,0xa2,t); 987 return speed ; 988 } 989 990 /* 991 * This is code for the SB3.x and lower. 992 * Only some models can do stereo, and only if not 993 * simultaneously using midi. 994 * At the moment we do not support either... 995 */ 996#if 0 997 d->flags &= ~SND_F_STEREO; 998#endif 999 1000 /* 1001 * here enforce speed limitations. 1002 */ 1003 if (d->bd_id <= 0x200) 1004 max_speed = 22050; /* max 22050 on SB 1.X */ 1005 1006 /* 1007 * SB models earlier than SB Pro have low limit for the 1008 * input rate. Note that this is only for input, but since 1009 * we do not support separate values for rec & play.... 1010 */ 1011 if (d->bd_id <= 0x200) 1012 max_speed = 13000; 1013 else if (d->bd_id < 0x300) 1014 max_speed = 15000; 1015 1016 RANGE(speed, 4000, max_speed); 1017 1018 if (d->flags & SND_F_STEREO) /* really unused right now... */ 1019 speed *= 2; 1020 1021 /* 1022 * Now the speed should be valid. Compute the value to be 1023 * programmed into the board. 1024 */ 1025 1026 if (speed > 22050) { /* High speed mode on 2.01/3.xx */ 1027 int tmp; 1028 1029 tconst = (u_char) ((65536 - ((256000000 + speed / 2) / speed)) >> 8) ; 1030 d->bd_flags |= BD_F_HISPEED ; 1031 1032 flags = spltty(); 1033 sb_cmd2(d->io_base, 0x40, tconst); /* set time constant */ 1034 splx(flags); 1035 1036 tmp = 65536 - (tconst << 8); 1037 speed = (256000000 + tmp / 2) / tmp; 1038 } else { 1039 int tmp; 1040 1041 d->bd_flags &= ~BD_F_HISPEED ; 1042 tconst = (256 - ((1000000 + speed / 2) / speed)) & 0xff; 1043 1044 flags = spltty(); 1045 sb_cmd2(d->io_base, 0x40, tconst); /* set time constant */ 1046 splx(flags); 1047 1048 tmp = 256 - tconst; 1049 speed = (1000000 + tmp / 2) / tmp; 1050 } 1051 1052 if (d->flags & SND_F_STEREO) /* really unused right now... */ 1053 speed /= 2; 1054 1055 d->play_speed = d->rec_speed = speed; 1056 return speed; 1057} 1058 1059/* 1060 * mixer support, originally in sb_mixer.c 1061 */ 1062 1063static void 1064sb_set_recsrc(snddev_info *d, int mask) 1065{ 1066 u_char recdev ; 1067 1068 mask &= d->mix_rec_devs; 1069 switch (d->bd_flags & BD_F_MIX_MASK) { 1070 case BD_F_MIX_CT1345 : 1071 if (mask == SOUND_MASK_LINE) 1072 recdev = 6 ; 1073 else if (mask == SOUND_MASK_CD) 1074 recdev = 2 ; 1075 else { /* default: mic */ 1076 mask = SOUND_MASK_MIC ; 1077 recdev = 0 ; 1078 } 1079 sb_setmixer(d->io_base, RECORD_SRC, 1080 recdev | (sb_getmixer(d->io_base, RECORD_SRC) & ~7 )); 1081 break ; 1082 case BD_F_MIX_CT1745 : /* sb16 */ 1083 if (mask == 0) 1084 mask = SOUND_MASK_MIC ; /* XXX For compatibility. Bug ? */ 1085 recdev = 0 ; 1086 if (mask & SOUND_MASK_MIC) 1087 recdev |= 1 ; 1088 if (mask & SOUND_MASK_CD) 1089 recdev |= 6 ; /* l+r cd */ 1090 if (mask & SOUND_MASK_LINE) 1091 recdev |= 0x18 ; /* l+r line */ 1092 if (mask & SOUND_MASK_SYNTH) 1093 recdev |= 0x60 ; /* l+r midi */ 1094 sb_setmixer(d->io_base, SB16_IMASK_L, recdev); 1095 sb_setmixer(d->io_base, SB16_IMASK_R, recdev); 1096 /* 1097 * since the same volume controls apply to the input and 1098 * output sections, the best approach to have a consistent 1099 * behaviour among cards would be to disable the output path 1100 * on devices which are used to record. 1101 * However, since users like to have feedback, we only disable 1102 * the mike -- permanently. 1103 */ 1104 sb_setmixer(d->io_base, SB16_OMASK, 0x1f & ~1); 1105 break ; 1106 } 1107 d->mix_recsrc = mask; 1108} 1109 1110static void 1111sb_mixer_reset(snddev_info *d) 1112{ 1113 int i; 1114 1115 for (i = 0; i < SOUND_MIXER_NRDEVICES; i++) 1116 sb_mixer_set(d, i, levels[i]); 1117 if (d->bd_flags & BD_F_SB16) { 1118 sb_setmixer(d->io_base, 0x3c, 0x1f); /* make all output active */ 1119 sb_setmixer(d->io_base, 0x3d, 0); /* make all inputs-l off */ 1120 sb_setmixer(d->io_base, 0x3e, 0); /* make all inputs-r off */ 1121 } 1122 sb_set_recsrc(d, SOUND_MASK_MIC); 1123} 1124 1125static int 1126sb_mixer_set(snddev_info *d, int dev, int value) 1127{ 1128 int left = value & 0x000000ff; 1129 int right = (value & 0x0000ff00) >> 8; 1130 int regoffs; 1131 u_char val; 1132 mixer_tab *iomap; 1133 1134#ifdef JAZZ16 1135 if (d->bd_flags & BD_F_JAZZ16 && d->bd_flags & BD_F_JAZZ16_2) 1136 return smw_mixer_set(dev, value); 1137#endif 1138 1139 if (dev == SOUND_MIXER_RECSRC) { 1140 sb_set_recsrc(d, value); 1141 return 0 ; 1142 } 1143 if (left > 100) 1144 left = 100; 1145 if (right > 100) 1146 right = 100; 1147 1148 if (dev > 31) 1149 return EINVAL ; 1150 1151 if (!(d->mix_devs & (1 << dev))) /* Not supported */ 1152 return EINVAL; 1153 1154 switch ( d->bd_flags & BD_F_MIX_MASK ) { 1155 default: 1156 /* mixer unknown, fail... */ 1157 return EINVAL ;/* XXX change this */ 1158 case BD_F_MIX_CT1345 : 1159 iomap = &sbpro_mix ; 1160 break; 1161 case BD_F_MIX_CT1745 : 1162 iomap = &sb16_mix ; 1163 break; 1164 /* XXX how about the SG NX Pro, iomap = sgnxpro_mix */ 1165 } 1166 regoffs = (*iomap)[dev][LEFT_CHN].regno; 1167 if (regoffs == 0) 1168 return EINVAL; 1169 1170 val = sb_getmixer(d->io_base, regoffs); 1171 1172 change_bits(iomap, &val, dev, LEFT_CHN, left); 1173 1174 d->mix_levels[dev] = left | (left << 8); 1175 1176 if ((*iomap)[dev][RIGHT_CHN].regno != regoffs) { /* Change register */ 1177 sb_setmixer(d->io_base, regoffs, val); /* Save the old one */ 1178 regoffs = (*iomap)[dev][RIGHT_CHN].regno; 1179 1180 if (regoffs == 0) 1181 return 0 ; /* Just left channel present */ 1182 1183 val = sb_getmixer(d->io_base, regoffs); /* Read the new one */ 1184 } 1185 change_bits(iomap, &val, dev, RIGHT_CHN, right); 1186 1187 sb_setmixer(d->io_base, regoffs, val); 1188 1189 d->mix_levels[dev] = left | (right << 8); 1190 return 0 ; /* ok */ 1191} 1192 1193/* 1194 * now support for some PnP boards. 1195 */ 1196 1197#if NPNP > 0 1198static char *ess1868_probe(u_long csn, u_long vend_id); 1199static void ess1868_attach(u_long csn, u_long vend_id, char *name, 1200 struct isa_device *dev); 1201 1202static struct pnp_device ess1868 = { 1203 "ESS1868", 1204 ess1868_probe, 1205 ess1868_attach, 1206 &nsnd, /* use this for all sound cards */ 1207 &tty_imask /* imask */ 1208}; 1209DATA_SET (pnpdevice_set, ess1868); 1210 1211static char * 1212ess1868_probe(u_long csn, u_long vend_id) 1213{ 1214 /* 1215 * pnp X 1 os enable drq0 3 irq0 12 port0 0x240 1216 */ 1217 if (vend_id == 0x68187316) { 1218 struct pnp_cinfo d ; 1219 read_pnp_parms ( &d , 1 ) ; 1220 if (d.enable == 0) { 1221 printf("This is an ESS1868, but LDN 1 is disabled\n"); 1222 return NULL; 1223 } 1224 return "ESS1868" ; 1225 } 1226 return NULL ; 1227} 1228 1229static void 1230ess1868_attach(u_long csn, u_long vend_id, char *name, 1231 struct isa_device *dev) 1232{ 1233 struct pnp_cinfo d ; 1234 snddev_info tmp_d ; /* patched copy of the basic snddev_info */ 1235 int the_irq = 0 ; 1236 1237 tmp_d = sb_op_desc; 1238 snddev_last_probed = &tmp_d; 1239 1240#if 0 1241 read_pnp_parms ( &d , 3 ); /* disable LDN 3 */ 1242 d.port[0] = 0 ; 1243 d.enable = 0 ; 1244 write_pnp_parms ( &d , 3 ); 1245 1246 read_pnp_parms ( &d , 2 ); /* disable LDN 2 */ 1247 d.port[0] = 0 ; 1248 d.enable = 0 ; 1249 write_pnp_parms ( &d , 2 ); 1250 read_pnp_parms ( &d , 0 ); /* read config base */ 1251 tmp_d.conf_base = d.port[0]; 1252 write_pnp_parms ( &d , 0 ); 1253#endif 1254 1255 read_pnp_parms ( &d , 1 ) ; 1256 dev->id_iobase = d.port[0]; 1257 d.port[1] = 0 ; 1258 d.port[2] = 0 ; 1259 write_pnp_parms ( &d , 1 ); 1260 enable_pnp_card(); 1261 1262 dev->id_drq = d.drq[0] ; /* primary dma */ 1263 dev->id_irq = (1 << d.irq[0] ) ; 1264 dev->id_intr = (inthand2_t *)pcmintr ; 1265 dev->id_flags = 0 /* DV_F_DUAL_DMA | (d.drq[1] ) */; 1266 1267#if 0 1268 snddev_last_probed->probe(dev); /* not really necessary but doesn't harm */ 1269#endif 1270 pcmattach(dev); 1271} 1272 1273/* 1274 * A driver for some SB16pnp and compatibles... 1275 * 1276 * Avance Asound 100 -- 0x01009305 1277 * Avance Logic ALS100+ -- 0x10019305 1278 * xxx -- 0x2b008c0e 1279 * 1280 */ 1281 1282static char *sb16pnp_probe(u_long csn, u_long vend_id); 1283static void sb16pnp_attach(u_long csn, u_long vend_id, char *name, 1284 struct isa_device *dev); 1285 1286static struct pnp_device sb16pnp = { 1287 "SB16pnp", 1288 sb16pnp_probe, 1289 sb16pnp_attach, 1290 &nsnd, /* use this for all sound cards */ 1291 &tty_imask /* imask */ 1292}; 1293DATA_SET (pnpdevice_set, sb16pnp); 1294 1295static char * 1296sb16pnp_probe(u_long csn, u_long vend_id) 1297{ 1298 char *s = NULL ; 1299 1300 /* 1301 * The SB16/AWExx cards seem to differ in the fourth byte of 1302 * the vendor id, so I have just masked it for the time being... 1303 * Reported values are: 1304 * SB16 Value PnP: 0x2b008c0e 1305 * SB AWExx PnP: 0x39008c0e 0x9d008c0e 0xc3008c0e 1306 * Vibra16X: 0xf0008c0e 1307 */ 1308 if (vend_id == 0xf0008c0e) 1309 s = "Vibra16X" ; 1310 else if ( (vend_id & 0xffffff) == (0x9d008c0e & 0xffffff) ) 1311 s = "SB16 PnP"; 1312 else if (vend_id == 0x01009305) 1313 s = "Avance Asound 100" ; 1314 else if (vend_id == 0x10019305) 1315 s = "Avance Logic 100+" ; /* Vibra16X-class */ 1316 if (s) { 1317 struct pnp_cinfo d; 1318 read_pnp_parms(&d, 0); 1319 if (d.enable == 0) { 1320 printf("This is a %s, but LDN 0 is disabled\n", s); 1321 return NULL ; 1322 } 1323 return s ; 1324 } 1325 return NULL ; 1326} 1327 1328static void 1329sb16pnp_attach(u_long csn, u_long vend_id, char *name, 1330 struct isa_device *dev) 1331{ 1332 struct pnp_cinfo d ; 1333 snddev_info tmp_d ; /* patched copy of the basic snddev_info */ 1334 1335 tmp_d = sb_op_desc; 1336 snddev_last_probed = &tmp_d; 1337 1338 read_pnp_parms ( &d , 0 ) ; 1339 d.port[1] = 0 ; /* only the first address is used */ 1340 dev->id_iobase = d.port[0]; 1341 tmp_d.synth_base = d.port[2]; 1342 write_pnp_parms ( &d , 0 ); 1343 enable_pnp_card(); 1344 1345 dev->id_drq = d.drq[0] ; /* primary dma */ 1346 dev->id_irq = (1 << d.irq[0] ) ; 1347 dev->id_intr = (inthand2_t *)pcmintr ; 1348 dev->id_flags = DV_F_DUAL_DMA | (d.drq[1] ) ; 1349 1350 pcm_info[dev->id_unit] = tmp_d; /* pcm_info[] will be reinitialized after */ 1351 snddev_last_probed->probe(dev); /* not really necessary but doesn't harm */ 1352 1353 if (vend_id == 0x10019305 || vend_id == 0xf0008c0e) { 1354 /* 1355 * XXX please add here the vend_id for other vibra16X cards... 1356 * And remember, must change tmp_d, not 1357 */ 1358 tmp_d.bd_flags |= BD_F_SB16X ; 1359 } 1360 pcmattach(dev); 1361} 1362#endif /* NPNP */ 1363 1364#endif 1365