sb16.c revision 51768
1/* 2 * Copyright (c) 1999 Cameron Grant <gandalf@vilnya.demon.co.uk> 3 * Copyright 1997,1998 Luigi Rizzo. 4 * 5 * Derived from files in the Voxware 3.5 distribution, 6 * Copyright by Hannu Savolainen 1994, under the same copyright 7 * conditions. 8 * All rights reserved. 9 * 10 * Redistribution and use in source and binary forms, with or without 11 * modification, are permitted provided that the following conditions 12 * are met: 13 * 1. Redistributions of source code must retain the above copyright 14 * notice, this list of conditions and the following disclaimer. 15 * 2. Redistributions in binary form must reproduce the above copyright 16 * notice, this list of conditions and the following disclaimer in the 17 * documentation and/or other materials provided with the distribution. 18 * 19 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 20 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 21 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 22 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 23 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 24 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 25 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 26 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 27 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 28 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 29 * SUCH DAMAGE. 30 * 31 * $FreeBSD: head/sys/dev/sound/isa/sb16.c 51768 1999-09-28 20:24:28Z cg $ 32 */ 33 34#include <dev/pcm/sound.h> 35#if NPCM > 0 36 37#define __SB_MIXER_C__ /* XXX warning... */ 38#include <dev/pcm/isa/sb.h> 39 40/* channel interface */ 41static void *sbchan_init(void *devinfo, snd_dbuf *b, pcm_channel *c, int dir); 42static int sbchan_setdir(void *data, int dir); 43static int sbchan_setformat(void *data, u_int32_t format); 44static int sbchan_setspeed(void *data, u_int32_t speed); 45static int sbchan_setblocksize(void *data, u_int32_t blocksize); 46static int sbchan_trigger(void *data, int go); 47static int sbchan_getptr(void *data); 48static pcmchan_caps *sbchan_getcaps(void *data); 49 50/* channel interface for ESS */ 51#ifdef notyet 52static void *esschan_init(void *devinfo, snd_dbuf *b, pcm_channel *c, int dir); 53#endif 54static int esschan_setdir(void *data, int dir); 55static int esschan_setformat(void *data, u_int32_t format); 56static int esschan_setspeed(void *data, u_int32_t speed); 57static int esschan_setblocksize(void *data, u_int32_t blocksize); 58static int esschan_trigger(void *data, int go); 59static int esschan_getptr(void *data); 60static pcmchan_caps *esschan_getcaps(void *data); 61static pcmchan_caps sb_playcaps = { 62 4000, 22050, 63 AFMT_U8, 64 AFMT_U8 65}; 66 67static pcmchan_caps sb_reccaps = { 68 4000, 13000, 69 AFMT_U8, 70 AFMT_U8 71}; 72 73static pcmchan_caps sbpro_playcaps = { 74 4000, 45000, 75 AFMT_STEREO | AFMT_U8, 76 AFMT_STEREO | AFMT_U8 77}; 78 79static pcmchan_caps sbpro_reccaps = { 80 4000, 15000, 81 AFMT_STEREO | AFMT_U8, 82 AFMT_STEREO | AFMT_U8 83}; 84 85static pcmchan_caps sb16_playcaps = { 86 5000, 45000, 87 AFMT_STEREO | AFMT_S16_LE, 88 AFMT_STEREO | AFMT_S16_LE 89}; 90 91static pcmchan_caps sb16_reccaps = { 92 5000, 45000, 93 AFMT_STEREO | AFMT_U8, 94 AFMT_STEREO | AFMT_U8 95}; 96 97static pcmchan_caps ess_playcaps = { 98 5000, 49000, 99 AFMT_STEREO | AFMT_U8 | AFMT_S16_LE, 100 AFMT_STEREO | AFMT_S16_LE 101}; 102 103static pcmchan_caps ess_reccaps = { 104 5000, 49000, 105 AFMT_STEREO | AFMT_U8 | AFMT_S16_LE, 106 AFMT_STEREO | AFMT_S16_LE 107}; 108 109static pcm_channel sb_chantemplate = { 110 sbchan_init, 111 sbchan_setdir, 112 sbchan_setformat, 113 sbchan_setspeed, 114 sbchan_setblocksize, 115 sbchan_trigger, 116 sbchan_getptr, 117 sbchan_getcaps, 118}; 119 120static pcm_channel ess_chantemplate = { 121 sbchan_init, 122 esschan_setdir, 123 esschan_setformat, 124 esschan_setspeed, 125 esschan_setblocksize, 126 esschan_trigger, 127 esschan_getptr, 128 esschan_getcaps, 129}; 130#define PLAIN_SB16(x) ((((x)->bd_flags) & (BD_F_SB16|BD_F_SB16X)) == BD_F_SB16) 131 132struct sb_info; 133 134struct sb_chinfo { 135 struct sb_info *parent; 136 pcm_channel *channel; 137 snd_dbuf *buffer; 138 int dir; 139 u_int32_t fmt; 140 int ess_dma_started; 141}; 142 143struct sb_info { 144 struct resource *io_base; /* I/O address for the board */ 145 int io_rid; 146 struct resource *irq; 147 int irq_rid; 148 struct resource *drq1; /* play */ 149 int drq1_rid; 150 struct resource *drq2; /* rec */ 151 int drq2_rid; 152 bus_dma_tag_t parent_dmat; 153 154 int dma16, dma8; 155 int bd_id; 156 u_long bd_flags; /* board-specific flags */ 157 struct sb_chinfo pch, rch; 158}; 159 160static int sb_rd(struct sb_info *sb, int reg); 161static void sb_wr(struct sb_info *sb, int reg, u_int8_t val); 162static int sb_dspready(struct sb_info *sb); 163static int sb_cmd(struct sb_info *sb, u_char val); 164static int sb_cmd1(struct sb_info *sb, u_char cmd, int val); 165static int sb_cmd2(struct sb_info *sb, u_char cmd, int val); 166static u_int sb_get_byte(struct sb_info *sb); 167static int ess_write(struct sb_info *sb, u_char reg, int val); 168static int ess_read(struct sb_info *sb, u_char reg); 169 170/* 171 * in the SB, there is a set of indirect "mixer" registers with 172 * address at offset 4, data at offset 5 173 */ 174static void sb_setmixer(struct sb_info *sb, u_int port, u_int value); 175static int sb_getmixer(struct sb_info *sb, u_int port); 176 177static void sb_intr(void *arg); 178static void ess_intr(void *arg); 179static int sb_init(device_t dev, struct sb_info *sb); 180static int sb_reset_dsp(struct sb_info *sb); 181 182static int sb_format(struct sb_chinfo *ch, u_int32_t format); 183static int sb_speed(struct sb_chinfo *ch, int speed); 184static int sb_start(struct sb_chinfo *ch); 185static int sb_stop(struct sb_chinfo *ch); 186 187static int ess_format(struct sb_chinfo *ch, u_int32_t format); 188static int ess_speed(struct sb_chinfo *ch, int speed); 189static int ess_start(struct sb_chinfo *ch); 190static int ess_stop(struct sb_chinfo *ch); 191static int ess_abort(struct sb_chinfo *ch); 192static int sbmix_init(snd_mixer *m); 193static int sbmix_set(snd_mixer *m, unsigned dev, unsigned left, unsigned right); 194static int sbmix_setrecsrc(snd_mixer *m, u_int32_t src); 195 196static snd_mixer sb_mixer = { 197 "SoundBlaster mixer", 198 sbmix_init, 199 sbmix_set, 200 sbmix_setrecsrc, 201}; 202 203static devclass_t pcm_devclass; 204 205/* 206 * Common code for the midi and pcm functions 207 * 208 * sb_cmd write a single byte to the CMD port. 209 * sb_cmd1 write a CMD + 1 byte arg 210 * sb_cmd2 write a CMD + 2 byte arg 211 * sb_get_byte returns a single byte from the DSP data port 212 * 213 * ess_write is actually sb_cmd1 214 * ess_read access ext. regs via sb_cmd(0xc0, reg) followed by sb_get_byte 215 */ 216 217static int 218port_rd(struct resource *port, int off) 219{ 220 return bus_space_read_1(rman_get_bustag(port), 221 rman_get_bushandle(port), 222 off); 223} 224 225static void 226port_wr(struct resource *port, int off, u_int8_t data) 227{ 228 return bus_space_write_1(rman_get_bustag(port), 229 rman_get_bushandle(port), 230 off, data); 231} 232 233static int 234sb_rd(struct sb_info *sb, int reg) 235{ 236 return port_rd(sb->io_base, reg); 237} 238 239static void 240sb_wr(struct sb_info *sb, int reg, u_int8_t val) 241{ 242 port_wr(sb->io_base, reg, val); 243} 244 245static int 246sb_dspready(struct sb_info *sb) 247{ 248 return ((sb_rd(sb, SBDSP_STATUS) & 0x80) == 0); 249} 250 251static int 252sb_dspwr(struct sb_info *sb, u_char val) 253{ 254 int i; 255 256 for (i = 0; i < 1000; i++) { 257 if (sb_dspready(sb)) { 258 sb_wr(sb, SBDSP_CMD, val); 259 return 1; 260 } 261 if (i > 10) DELAY((i > 100)? 1000 : 10); 262 } 263 printf("sb_dspwr(0x%02x) timed out.\n", val); 264 return 0; 265} 266 267static int 268sb_cmd(struct sb_info *sb, u_char val) 269{ 270#if 0 271 printf("sb_cmd: %x\n", val); 272#endif 273 return sb_dspwr(sb, val); 274} 275 276static int 277sb_cmd1(struct sb_info *sb, u_char cmd, int val) 278{ 279#if 0 280 printf("sb_cmd1: %x, %x\n", cmd, val); 281#endif 282 if (sb_dspwr(sb, cmd)) { 283 return sb_dspwr(sb, val & 0xff); 284 } else return 0; 285} 286 287static int 288sb_cmd2(struct sb_info *sb, u_char cmd, int val) 289{ 290#if 0 291 printf("sb_cmd2: %x, %x\n", cmd, val); 292#endif 293 if (sb_dspwr(sb, cmd)) { 294 return sb_dspwr(sb, val & 0xff) && 295 sb_dspwr(sb, (val >> 8) & 0xff); 296 } else return 0; 297} 298 299/* 300 * in the SB, there is a set of indirect "mixer" registers with 301 * address at offset 4, data at offset 5 302 */ 303static void 304sb_setmixer(struct sb_info *sb, u_int port, u_int value) 305{ 306 u_long flags; 307 308 flags = spltty(); 309 sb_wr(sb, SB_MIX_ADDR, (u_char) (port & 0xff)); /* Select register */ 310 DELAY(10); 311 sb_wr(sb, SB_MIX_DATA, (u_char) (value & 0xff)); 312 DELAY(10); 313 splx(flags); 314} 315 316static int 317sb_getmixer(struct sb_info *sb, u_int port) 318{ 319 int val; 320 u_long flags; 321 322 flags = spltty(); 323 sb_wr(sb, SB_MIX_ADDR, (u_char) (port & 0xff)); /* Select register */ 324 DELAY(10); 325 val = sb_rd(sb, SB_MIX_DATA); 326 DELAY(10); 327 splx(flags); 328 329 return val; 330} 331 332static u_int 333sb_get_byte(struct sb_info *sb) 334{ 335 int i; 336 337 for (i = 1000; i > 0; i--) { 338 if (sb_rd(sb, DSP_DATA_AVAIL) & 0x80) 339 return sb_rd(sb, DSP_READ); 340 else 341 DELAY(20); 342 } 343 return 0xffff; 344} 345 346static int 347ess_write(struct sb_info *sb, u_char reg, int val) 348{ 349 return sb_cmd1(sb, reg, val); 350} 351 352static int 353ess_read(struct sb_info *sb, u_char reg) 354{ 355 return (sb_cmd(sb, 0xc0) && sb_cmd(sb, reg))? sb_get_byte(sb) : 0xffff; 356} 357 358static int 359sb_reset_dsp(struct sb_info *sb) 360{ 361 sb_wr(sb, SBDSP_RST, 3); 362 DELAY(100); 363 sb_wr(sb, SBDSP_RST, 0); 364 if (sb_get_byte(sb) != 0xAA) { 365 DEB(printf("sb_reset_dsp 0x%lx failed\n", 366 rman_get_start(d->io_base))); 367 return ENXIO; /* Sorry */ 368 } 369 if (sb->bd_flags & BD_F_ESS) sb_cmd(sb, 0xc6); 370 return 0; 371} 372 373static void 374sb_release_resources(struct sb_info *sb, device_t dev) 375{ 376 /* should we bus_teardown_intr here? */ 377 if (sb->irq) { 378 bus_release_resource(dev, SYS_RES_IRQ, sb->irq_rid, sb->irq); 379 sb->irq = 0; 380 } 381 if (sb->drq1) { 382 bus_release_resource(dev, SYS_RES_DRQ, sb->drq1_rid, sb->drq1); 383 sb->drq1 = 0; 384 } 385 if (sb->drq2) { 386 bus_release_resource(dev, SYS_RES_DRQ, sb->drq2_rid, sb->drq2); 387 sb->drq2 = 0; 388 } 389 if (sb->io_base) { 390 bus_release_resource(dev, SYS_RES_IOPORT, sb->io_rid, 391 sb->io_base); 392 sb->io_base = 0; 393 } 394 free(sb, M_DEVBUF); 395} 396 397static int 398sb_alloc_resources(struct sb_info *sb, device_t dev) 399{ 400 if (!sb->io_base) 401 sb->io_base = bus_alloc_resource(dev, SYS_RES_IOPORT, 402 &sb->io_rid, 0, ~0, 1, 403 RF_ACTIVE); 404 if (!sb->irq) 405 sb->irq = bus_alloc_resource(dev, SYS_RES_IRQ, 406 &sb->irq_rid, 0, ~0, 1, 407 RF_ACTIVE); 408 if (!sb->drq1) 409 sb->drq1 = bus_alloc_resource(dev, SYS_RES_DRQ, 410 &sb->drq1_rid, 0, ~0, 1, 411 RF_ACTIVE); 412 if (!sb->drq2 && sb->drq2_rid > 0) 413 sb->drq2 = bus_alloc_resource(dev, SYS_RES_DRQ, 414 &sb->drq2_rid, 0, ~0, 1, 415 RF_ACTIVE); 416 417 if (sb->io_base && sb->drq1 && sb->irq) { 418 sb->dma8 = rman_get_start(sb->drq1); 419 isa_dma_acquire(sb->dma8); 420 isa_dmainit(sb->dma8, DSP_BUFFSIZE); 421 422 if (sb->drq2) { 423 sb->dma16 = rman_get_start(sb->drq2); 424 isa_dma_acquire(sb->dma16); 425 isa_dmainit(sb->dma16, DSP_BUFFSIZE); 426 } else sb->dma16 = sb->dma8; 427 428 if (sb->dma8 > sb->dma16) { 429 int tmp = sb->dma16; 430 sb->dma16 = sb->dma8; 431 sb->dma8 = tmp; 432 } 433 return 0; 434 } else return ENXIO; 435} 436 437static int 438sb_identify_board(device_t dev, struct sb_info *sb) 439{ 440 char *fmt = NULL; 441 static char buf[64]; 442 int essver = 0; 443 444 sb_cmd(sb, DSP_CMD_GETVER); /* Get version */ 445 sb->bd_id = (sb_get_byte(sb) << 8) | sb_get_byte(sb); 446 447 switch (sb->bd_id >> 8) { 448 case 1: /* old sound blaster has nothing... */ 449 case 2: 450 fmt = "SoundBlaster %d.%d" ; /* default */ 451 break; 452 453 case 3: 454 fmt = "SoundBlaster Pro %d.%d"; 455 if (sb->bd_id == 0x301) { 456 int rev; 457 458 /* Try to detect ESS chips. */ 459 sb_cmd(sb, DSP_CMD_GETID); /* Return ident. bytes. */ 460 essver = (sb_get_byte(sb) << 8) | sb_get_byte(sb); 461 rev = essver & 0x000f; 462 essver &= 0xfff0; 463 if (essver == 0x4880) { 464 /* the ESS488 can be treated as an SBPRO */ 465 fmt = "SoundBlaster Pro (ESS488 rev %d)"; 466 } else if (essver == 0x6880) { 467 if (rev < 8) fmt = "ESS688 rev %d"; 468 else fmt = "ESS1868 rev %d"; 469 sb->bd_flags |= BD_F_ESS; 470 } else return ENXIO; 471 sb->bd_id &= 0xff00; 472 sb->bd_id |= ((essver & 0xf000) >> 8) | rev; 473 } 474 break; 475 476 case 4: 477 sb->bd_flags |= BD_F_SB16; 478 if (sb->bd_flags & BD_F_SB16X) fmt = "SB16 ViBRA16X %d.%d"; 479 else fmt = "SoundBlaster 16 %d.%d"; 480 break; 481 482 default: 483 device_printf(dev, "failed to get SB version (%x)\n", 484 sb->bd_id); 485 return ENXIO; 486 } 487 if (essver) snprintf(buf, sizeof buf, fmt, sb->bd_id & 0x000f); 488 else snprintf(buf, sizeof buf, fmt, sb->bd_id >> 8, sb->bd_id & 0xff); 489 device_set_desc_copy(dev, buf); 490 return sb_reset_dsp(sb); 491} 492 493static int 494sb_init(device_t dev, struct sb_info *sb) 495{ 496 int x, irq; 497 498 sb->bd_flags &= ~BD_F_MIX_MASK; 499 /* do various initializations depending on board id. */ 500 switch (sb->bd_id >> 8) { 501 case 1: /* old sound blaster has nothing... */ 502 break; 503 504 case 2: 505 sb->bd_flags |= BD_F_DUP_MIDI; 506 if (sb->bd_id > 0x200) sb->bd_flags |= BD_F_MIX_CT1335; 507 break; 508 509 case 3: 510 sb->bd_flags |= BD_F_DUP_MIDI | BD_F_MIX_CT1345; 511 break; 512 513 case 4: 514 sb->bd_flags |= BD_F_SB16 | BD_F_MIX_CT1745; 515 if (sb->dma16 != sb->dma8) sb->bd_flags |= BD_F_DUPLEX; 516 517 /* soft irq/dma configuration */ 518 x = -1; 519 irq = rman_get_start(sb->irq); 520 if (irq == 5) x = 2; 521 else if (irq == 7) x = 4; 522 else if (irq == 9) x = 1; 523 else if (irq == 10) x = 8; 524 if (x == -1) device_printf(dev, 525 "bad irq %d (5/7/9/10 valid)\n", 526 irq); 527 else sb_setmixer(sb, IRQ_NR, x); 528 sb_setmixer(sb, DMA_NR, (1 << sb->dma16) | (1 << sb->dma8)); 529 break; 530 } 531 return 0; 532} 533 534static int 535sb_probe(device_t dev) 536{ 537 snddev_info *d = device_get_softc(dev); 538 struct sb_info *sb; 539 int allocated, i; 540 int error; 541 542 if (isa_get_vendorid(dev)) return ENXIO; /* not yet */ 543 544 device_set_desc(dev, "SoundBlaster"); 545 bzero(d, sizeof *d); 546 sb = (struct sb_info *)malloc(sizeof *sb, M_DEVBUF, M_NOWAIT); 547 if (!sb) return ENXIO; 548 bzero(sb, sizeof *sb); 549 550 allocated = 0; 551 sb->io_rid = 0; 552 sb->io_base = bus_alloc_resource(dev, SYS_RES_IOPORT, &sb->io_rid, 553 0, ~0, 16, RF_ACTIVE); 554 if (!sb->io_base) { 555 BVDDB(printf("sb_probe: no addr, trying (0x220, 0x240)\n")); 556 allocated = 1; 557 sb->io_rid = 0; 558 sb->io_base = bus_alloc_resource(dev, SYS_RES_IOPORT, 559 &sb->io_rid, 0x220, 0x22f, 560 16, RF_ACTIVE); 561 if (!sb->io_base) { 562 sb->io_base = bus_alloc_resource(dev, SYS_RES_IOPORT, 563 &sb->io_rid, 0x240, 564 0x24f, 16, RF_ACTIVE); 565 } 566 } 567 if (!sb->io_base) return ENXIO; 568 569 error = sb_reset_dsp(sb); 570 if (error) goto no; 571 error = sb_identify_board(dev, sb); 572 if (error) goto no; 573no: 574 i = sb->io_rid; 575 sb_release_resources(sb, dev); 576 if (allocated) ISA_DELETE_RESOURCE(device_get_parent(dev), dev, 577 SYS_RES_IOPORT, i); 578 return error; 579} 580 581static int 582sb_doattach(device_t dev, struct sb_info *sb) 583{ 584 snddev_info *d = device_get_softc(dev); 585 void *ih; 586 int error; 587 char status[SND_STATUSLEN]; 588 589 sb->irq_rid = 0; 590 sb->drq1_rid = 0; 591 sb->drq2_rid = 1; 592 if (sb_alloc_resources(sb, dev)) goto no; 593 error = sb_reset_dsp(sb); 594 if (error) goto no; 595 error = sb_identify_board(dev, sb); 596 if (error) goto no; 597 598 sb_init(dev, sb); 599 mixer_init(d, &sb_mixer, sb); 600 if (sb->bd_flags & BD_F_ESS) 601 bus_setup_intr(dev, sb->irq, INTR_TYPE_TTY, ess_intr, sb, &ih); 602 else 603 bus_setup_intr(dev, sb->irq, INTR_TYPE_TTY, sb_intr, sb, &ih); 604 605 if (sb->bd_flags & BD_F_SB16) 606 pcm_setflags(dev, pcm_getflags(dev) | SD_F_EVILSB16); 607 if (sb->dma16 == sb->dma8) 608 pcm_setflags(dev, pcm_getflags(dev) | SD_F_SIMPLEX); 609 if (bus_dma_tag_create(/*parent*/NULL, /*alignment*/2, /*boundary*/0, 610 /*lowaddr*/BUS_SPACE_MAXADDR_24BIT, 611 /*highaddr*/BUS_SPACE_MAXADDR, 612 /*filter*/NULL, /*filterarg*/NULL, 613 /*maxsize*/DSP_BUFFSIZE, /*nsegments*/1, 614 /*maxsegz*/0x3ffff, 615 /*flags*/0, &sb->parent_dmat) != 0) { 616 device_printf(dev, "unable to create dma tag\n"); 617 goto no; 618 } 619 620 snprintf(status, SND_STATUSLEN, "at io 0x%lx irq %ld drq %d", 621 rman_get_start(sb->io_base), rman_get_start(sb->irq), 622 sb->dma8); 623 if (sb->dma16 != sb->dma8) snprintf(status + strlen(status), 624 SND_STATUSLEN - strlen(status), ":%d", sb->dma16); 625 626 if (pcm_register(dev, sb, 1, 1)) goto no; 627 if (sb->bd_flags & BD_F_ESS) { 628 pcm_addchan(dev, PCMDIR_REC, &ess_chantemplate, sb); 629 pcm_addchan(dev, PCMDIR_PLAY, &ess_chantemplate, sb); 630 } else { 631 pcm_addchan(dev, PCMDIR_REC, &sb_chantemplate, sb); 632 pcm_addchan(dev, PCMDIR_PLAY, &sb_chantemplate, sb); 633 } 634 pcm_setstatus(dev, status); 635 636 return 0; 637 638no: 639 sb_release_resources(sb, dev); 640 return ENXIO; 641} 642 643static int 644sb_attach(device_t dev) 645{ 646 struct sb_info *sb; 647 int flags = device_get_flags(dev); 648 649 if (flags & DV_F_DUAL_DMA) { 650 ISA_SET_RESOURCE(device_get_parent(dev), dev, SYS_RES_DRQ, 1, 651 flags & DV_F_DRQ_MASK, 1); 652 } 653 sb = (struct sb_info *)malloc(sizeof *sb, M_DEVBUF, M_NOWAIT); 654 if (!sb) return ENXIO; 655 bzero(sb, sizeof *sb); 656 657 /* XXX in probe should set io resource to right val instead of this */ 658 sb->io_rid = 0; 659 sb->io_base = bus_alloc_resource(dev, SYS_RES_IOPORT, &sb->io_rid, 660 0, ~0, 16, RF_ACTIVE); 661 if (!sb->io_base) { 662 BVDDB(printf("sb_probe: no addr, trying (0x220, 0x240)\n")); 663 sb->io_rid = 0; 664 sb->io_base = bus_alloc_resource(dev, SYS_RES_IOPORT, 665 &sb->io_rid, 0x220, 0x22f, 666 16, RF_ACTIVE); 667 if (!sb->io_base) { 668 sb->io_base = bus_alloc_resource(dev, SYS_RES_IOPORT, 669 &sb->io_rid, 0x240, 670 0x24f, 16, RF_ACTIVE); 671 } 672 } 673 if (!sb->io_base) return ENXIO; 674 675 return sb_doattach(dev, sb); 676} 677 678static device_method_t sb_methods[] = { 679 /* Device interface */ 680 DEVMETHOD(device_probe, sb_probe), 681 DEVMETHOD(device_attach, sb_attach), 682 683 { 0, 0 } 684}; 685 686static driver_t sb_driver = { 687 "pcm", 688 sb_methods, 689 sizeof(snddev_info), 690}; 691 692DRIVER_MODULE(sb, isa, sb_driver, pcm_devclass, 0, 0); 693 694static void 695sb_intr(void *arg) 696{ 697 struct sb_info *sb = (struct sb_info *)arg; 698 int reason = 3, c; 699 700 /* 701 * SB < 4.0 is half duplex and has only 1 bit for int source, 702 * so we fake it. SB 4.x (SB16) has the int source in a separate 703 * register. 704 * The Vibra16X has separate flags for 8 and 16 bit transfers, but 705 * I have no idea how to tell capture from playback interrupts... 706 */ 707 if (sb->bd_flags & BD_F_SB16) { 708 c = sb_getmixer(sb, IRQ_STAT); 709 /* this tells us if the source is 8-bit or 16-bit dma. We 710 * have to check the io channel to map it to read or write... 711 */ 712 reason = 0; 713 if (c & 1) { /* 8-bit dma */ 714 if (sb->pch.fmt & AFMT_U8) reason |= 1; 715 if (sb->rch.fmt & AFMT_U8) reason |= 2; 716 } 717 if (c & 2) { /* 16-bit dma */ 718 if (sb->pch.fmt & AFMT_S16_LE) reason |= 1; 719 if (sb->rch.fmt & AFMT_S16_LE) reason |= 2; 720 } 721 } else c = 1; 722#if 0 723 printf("sb_intr: reason=%d c=0x%x\n", reason, c); 724#endif 725 if ((reason & 1) && (sb->pch.buffer->dl > 0)) 726 chn_intr(sb->pch.channel); 727 if ((reason & 2) && (sb->rch.buffer->dl > 0)) 728 chn_intr(sb->rch.channel); 729 if (c & 1) sb_rd(sb, DSP_DATA_AVAIL); /* 8-bit int ack */ 730 if (c & 2) sb_rd(sb, DSP_DATA_AVL16); /* 16-bit int ack */ 731} 732 733static void 734ess_intr(void *arg) 735{ 736 struct sb_info *sb = (struct sb_info *)arg; 737 sb_rd(sb, DSP_DATA_AVAIL); /* int ack */ 738#ifdef notyet 739 /* 740 * XXX 741 * for full-duplex mode: 742 * should read port 0x6 to identify where interrupt came from. 743 */ 744#endif 745 /* 746 * We are transferring data in DSP normal mode, 747 * so clear the dl to indicate the DMA is stopped. 748 */ 749 if (sb->pch.buffer->dl > 0) { 750 sb->pch.buffer->dl = -1; 751 chn_intr(sb->pch.channel); 752 } 753 if (sb->rch.buffer->dl > 0) { 754 sb->rch.buffer->dl = -1; 755 chn_intr(sb->rch.channel); 756 } 757} 758 759static int 760sb_format(struct sb_chinfo *ch, u_int32_t format) 761{ 762 ch->fmt = format; 763 return 0; 764} 765 766static int 767sb_speed(struct sb_chinfo *ch, int speed) 768{ 769 struct sb_info *sb = ch->parent; 770 int play = (ch->dir == PCMDIR_PLAY)? 1 : 0; 771 int stereo = (ch->fmt & AFMT_STEREO)? 1 : 0; 772 773 if (sb->bd_flags & BD_F_SB16) { 774 RANGE(speed, 5000, 45000); 775 sb_cmd(sb, 0x42 - play); 776 sb_cmd(sb, speed >> 8); 777 sb_cmd(sb, speed & 0xff); 778 } else { 779 u_char tconst; 780 int max_speed = 45000, tmp; 781 u_long flags; 782 783 /* here enforce speed limitations - max 22050 on sb 1.x*/ 784 if (sb->bd_id <= 0x200) max_speed = 22050; 785 786 /* 787 * SB models earlier than SB Pro have low limit for the 788 * input rate. Note that this is only for input, but since 789 * we do not support separate values for rec & play.... 790 */ 791 if (!play) { 792 if (sb->bd_id <= 0x200) max_speed = 13000; 793 else if (sb->bd_id < 0x300) max_speed = 15000; 794 } 795 RANGE(speed, 4000, max_speed); 796 if (stereo) speed <<= 1; 797 798 /* 799 * Now the speed should be valid. Compute the value to be 800 * programmed into the board. 801 */ 802 if (speed > 22050) { /* High speed mode on 2.01/3.xx */ 803 tconst = (u_char) 804 ((65536 - ((256000000 + speed / 2) / speed)) 805 >> 8); 806 sb->bd_flags |= BD_F_HISPEED; 807 tmp = 65536 - (tconst << 8); 808 speed = (256000000 + tmp / 2) / tmp; 809 } else { 810 sb->bd_flags &= ~BD_F_HISPEED; 811 tconst = (256 - ((1000000 + speed / 2) / speed)) & 0xff; 812 tmp = 256 - tconst; 813 speed = (1000000 + tmp / 2) / tmp; 814 } 815 flags = spltty(); 816 sb_cmd1(sb, 0x40, tconst); /* set time constant */ 817 splx(flags); 818 if (stereo) speed >>= 1; 819 } 820 return speed; 821} 822 823static int 824sb_start(struct sb_chinfo *ch) 825{ 826 struct sb_info *sb = ch->parent; 827 int play = (ch->dir == PCMDIR_PLAY)? 1 : 0; 828 int b16 = (ch->fmt & AFMT_S16_LE)? 1 : 0; 829 int stereo = (ch->fmt & AFMT_STEREO)? 1 : 0; 830 int l = ch->buffer->dl; 831 u_char i1, i2 = 0; 832 833 if (b16) l >>= 1; 834 l--; 835 if (play) sb_cmd(sb, DSP_CMD_SPKON); 836 if (sb->bd_flags & BD_F_SB16) { 837 i1 = DSP_F16_AUTO | DSP_F16_FIFO_ON | 838 (play? DSP_F16_DAC : DSP_F16_ADC); 839 i1 |= (b16 && (sb->bd_flags & BD_F_DUPLEX))? DSP_DMA16 : DSP_DMA8; 840 i2 = (stereo? DSP_F16_STEREO : 0) | (b16? DSP_F16_SIGNED : 0); 841 sb_cmd(sb, i1); 842 sb_cmd2(sb, i2, l); 843 } else { 844 if (sb->bd_flags & BD_F_HISPEED) i1 = play? 0x90 : 0x98; 845 else i1 = play? 0x1c : 0x2c; 846 sb_setmixer(sb, 0x0e, stereo? 2 : 0); 847 /* an ESS extension -- they can do 16 bits */ 848 if (b16) i1 |= 1; 849 sb_cmd2(sb, 0x48, l); 850 sb_cmd(sb, i1); 851 } 852 sb->bd_flags |= BD_F_DMARUN << b16; 853 return 0; 854} 855 856static int 857sb_stop(struct sb_chinfo *ch) 858{ 859 struct sb_info *sb = ch->parent; 860 int play = (ch->dir == PCMDIR_PLAY)? 1 : 0; 861 int b16 = (ch->fmt & AFMT_S16_LE)? 1 : 0; 862 863 if (sb->bd_flags & BD_F_HISPEED) sb_reset_dsp(sb); 864 else { 865 sb_cmd(sb, b16? DSP_CMD_DMAPAUSE_16 : DSP_CMD_DMAPAUSE_8); 866 /* 867 * The above seems to have the undocumented side effect of 868 * blocking the other side as well. If the other 869 * channel was active (SB16) I have to re-enable it :( 870 */ 871 if (sb->bd_flags & (BD_F_DMARUN << (1 - b16))) 872 sb_cmd(sb, b16? 0xd4 : 0xd6 ); 873 } 874 if (play) sb_cmd(sb, DSP_CMD_SPKOFF); /* speaker off */ 875 sb->bd_flags &= ~(BD_F_DMARUN << b16); 876 return 0; 877} 878 879/* utility functions for ESS */ 880static int 881ess_format(struct sb_chinfo *ch, u_int32_t format) 882{ 883 struct sb_info *sb = ch->parent; 884 int play = (ch->dir == PCMDIR_PLAY)? 1 : 0; 885 int b16 = (ch->fmt & AFMT_S16_LE)? 1 : 0; 886 int stereo = (ch->fmt & AFMT_STEREO)? 1 : 0; 887 u_char c; 888 ch->fmt = format; 889 sb_reset_dsp(sb); 890 /* normal DMA mode */ 891 ess_write(sb, 0xb8, play ? 0x00 : 0x0a); 892 /* mono/stereo */ 893 c = (ess_read(sb, 0xa8) & ~0x03) | 1; 894 if (!stereo) c++; 895 ess_write(sb, 0xa8, c); 896 /* demand mode, 4 bytes/xfer */ 897 ess_write(sb, 0xb9, 2); 898 /* setup dac/adc */ 899 if (play) ess_write(sb, 0xb6, b16? 0x00 : 0x80); 900 ess_write(sb, 0xb7, 0x51 | (b16? 0x20 : 0x00)); 901 ess_write(sb, 0xb7, 0x98 + (b16? 0x24 : 0x00) + (stereo? 0x00 : 0x38)); 902 /* irq/drq control */ 903 ess_write(sb, 0xb1, (ess_read(sb, 0xb1) & 0x0f) | 0x50); 904 ess_write(sb, 0xb2, (ess_read(sb, 0xb2) & 0x0f) | 0x50); 905 return 0; 906} 907 908static int 909ess_speed(struct sb_chinfo *ch, int speed) 910{ 911 struct sb_info *sb = ch->parent; 912 int t; 913 RANGE (speed, 5000, 49000); 914 if (speed > 22000) { 915 t = (795500 + speed / 2) / speed; 916 speed = (795500 + t / 2) / t; 917 t = (256 - t ) | 0x80; 918 } else { 919 t = (397700 + speed / 2) / speed; 920 speed = (397700 + t / 2) / t; 921 t = 128 - t; 922 } 923 ess_write(sb, 0xa1, t); /* set time constant */ 924#if 0 925 d->play_speed = d->rec_speed = speed; 926 speed = (speed * 9 ) / 20; 927#endif 928 t = 256 - 7160000 / ((speed * 9 / 20) * 82); 929 ess_write(sb, 0xa2, t); 930 return speed; 931} 932 933static int 934ess_start(struct sb_chinfo *ch) 935{ 936 struct sb_info *sb = ch->parent; 937 int play = (ch->dir == PCMDIR_PLAY)? 1 : 0; 938 short c = - ch->buffer->dl; 939 u_char c1; 940 /* 941 * clear bit 0 of register B8h 942 */ 943#if 1 944 c1 = play ? 0x00 : 0x0a; 945 ess_write(sb, 0xb8, c1++); 946#else 947 c1 = ess_read(sb, 0xb8) & 0xfe; 948 ess_write(sb, 0xb8, c1++); 949#endif 950 /* 951 * update ESS Transfer Count Register 952 */ 953 ess_write(sb, 0xa4, (u_char)((u_short)c & 0xff)); 954 ess_write(sb, 0xa5, (u_char)(((u_short)c >> 8) & 0xff)); 955 /* 956 * set bit 0 of register B8h 957 */ 958 ess_write(sb, 0xb8, c1); 959 if (play) 960 sb_cmd(sb, DSP_CMD_SPKON); 961 return 0; 962} 963 964static int 965ess_stop(struct sb_chinfo *ch) 966{ 967 struct sb_info *sb = ch->parent; 968 /* 969 * no need to send a stop command if the DMA has already stopped. 970 */ 971 if (ch->buffer->dl > 0) { 972 sb_cmd(sb, DSP_CMD_DMAPAUSE_8); /* pause dma. */ 973 } 974 return 0; 975} 976 977static int 978ess_abort(struct sb_chinfo *ch) 979{ 980 struct sb_info *sb = ch->parent; 981 int play = (ch->dir == PCMDIR_PLAY)? 1 : 0; 982 if (play) sb_cmd(sb, DSP_CMD_SPKOFF); /* speaker off */ 983 sb_reset_dsp(sb); 984 ess_format(ch, ch->fmt); 985 ess_speed(ch, ch->channel->speed); 986 return 0; 987} 988 989/* channel interface */ 990static void * 991sbchan_init(void *devinfo, snd_dbuf *b, pcm_channel *c, int dir) 992{ 993 struct sb_info *sb = devinfo; 994 struct sb_chinfo *ch = (dir == PCMDIR_PLAY)? &sb->pch : &sb->rch; 995 996 ch->parent = sb; 997 ch->channel = c; 998 ch->buffer = b; 999 ch->buffer->bufsize = DSP_BUFFSIZE; 1000 if (chn_allocbuf(ch->buffer, sb->parent_dmat) == -1) return NULL; 1001 ch->buffer->chan = (dir == PCMDIR_PLAY)? sb->dma16 : sb->dma8; 1002 return ch; 1003} 1004 1005static int 1006sbchan_setdir(void *data, int dir) 1007{ 1008 struct sb_chinfo *ch = data; 1009 ch->dir = dir; 1010 return 0; 1011} 1012 1013static int 1014sbchan_setformat(void *data, u_int32_t format) 1015{ 1016 struct sb_chinfo *ch = data; 1017 sb_format(ch, format); 1018 return 0; 1019} 1020 1021static int 1022sbchan_setspeed(void *data, u_int32_t speed) 1023{ 1024 struct sb_chinfo *ch = data; 1025 return sb_speed(ch, speed); 1026} 1027 1028static int 1029sbchan_setblocksize(void *data, u_int32_t blocksize) 1030{ 1031 return blocksize; 1032} 1033 1034static int 1035sbchan_trigger(void *data, int go) 1036{ 1037 struct sb_chinfo *ch = data; 1038 buf_isadma(ch->buffer, go); 1039 if (go == PCMTRIG_START) sb_start(ch); else sb_stop(ch); 1040 return 0; 1041} 1042 1043static int 1044sbchan_getptr(void *data) 1045{ 1046 struct sb_chinfo *ch = data; 1047 return buf_isadmaptr(ch->buffer); 1048} 1049 1050static pcmchan_caps * 1051sbchan_getcaps(void *data) 1052{ 1053 struct sb_chinfo *ch = data; 1054 int p = (ch->dir == PCMDIR_PLAY)? 1 : 0; 1055 if (ch->parent->bd_id <= 0x200) 1056 return p? &sb_playcaps : &sb_reccaps; 1057 else if (ch->parent->bd_id >= 0x400) 1058 return p? &sb16_playcaps : &sb16_reccaps; 1059 else 1060 return p? &sbpro_playcaps : &sbpro_reccaps; 1061} 1062/* channel interface for ESS18xx */ 1063#ifdef notyet 1064static void * 1065esschan_init(void *devinfo, snd_dbuf *b, pcm_channel *c, int dir) 1066{ 1067 /* the same as sbchan_init()? */ 1068} 1069#endif 1070 1071static int 1072esschan_setdir(void *data, int dir) 1073{ 1074 struct sb_chinfo *ch = data; 1075 ch->dir = dir; 1076 return 0; 1077} 1078 1079static int 1080esschan_setformat(void *data, u_int32_t format) 1081{ 1082 struct sb_chinfo *ch = data; 1083 ess_format(ch, format); 1084 return 0; 1085} 1086 1087static int 1088esschan_setspeed(void *data, u_int32_t speed) 1089{ 1090 struct sb_chinfo *ch = data; 1091 return ess_speed(ch, speed); 1092} 1093 1094static int 1095esschan_setblocksize(void *data, u_int32_t blocksize) 1096{ 1097 return blocksize; 1098} 1099 1100static int 1101esschan_trigger(void *data, int go) 1102{ 1103 struct sb_chinfo *ch = data; 1104 switch (go) { 1105 case PCMTRIG_START: 1106 if (!ch->ess_dma_started) 1107 buf_isadma(ch->buffer, go); 1108 ch->ess_dma_started = 1; 1109 ess_start(ch); 1110 break; 1111 case PCMTRIG_STOP: 1112 if (ch->buffer->dl >= 0) { 1113 buf_isadma(ch->buffer, go); 1114 ch->ess_dma_started = 0; 1115 ess_stop(ch); 1116 } 1117 break; 1118 case PCMTRIG_ABORT: 1119 default: 1120 ch->ess_dma_started = 0; 1121 ess_abort(ch); 1122 buf_isadma(ch->buffer, go); 1123 break; 1124 } 1125 return 0; 1126} 1127 1128static int 1129esschan_getptr(void *data) 1130{ 1131 struct sb_chinfo *ch = data; 1132 return buf_isadmaptr(ch->buffer); 1133} 1134 1135static pcmchan_caps * 1136esschan_getcaps(void *data) 1137{ 1138 struct sb_chinfo *ch = data; 1139 return (ch->dir == PCMDIR_PLAY)? &ess_playcaps : &ess_reccaps; 1140} 1141 1142/************************************************************/ 1143 1144static int 1145sbmix_init(snd_mixer *m) 1146{ 1147 struct sb_info *sb = mix_getdevinfo(m); 1148 1149 switch (sb->bd_flags & BD_F_MIX_MASK) { 1150 case BD_F_MIX_CT1345: /* SB 3.0 has 1345 mixer */ 1151 mix_setdevs(m, SBPRO_MIXER_DEVICES); 1152 mix_setrecdevs(m, SBPRO_RECORDING_DEVICES); 1153 sb_setmixer(sb, 0, 1); /* reset mixer */ 1154 sb_setmixer(sb, MIC_VOL, 0x6); /* mic volume max */ 1155 sb_setmixer(sb, RECORD_SRC, 0x0); /* mic source */ 1156 sb_setmixer(sb, FM_VOL, 0x0); /* no midi */ 1157 break; 1158 1159 case BD_F_MIX_CT1745: /* SB16 mixer ... */ 1160 mix_setdevs(m, SB16_MIXER_DEVICES); 1161 mix_setrecdevs(m, SB16_RECORDING_DEVICES); 1162 sb_setmixer(sb, 0x3c, 0x1f); /* make all output active */ 1163 sb_setmixer(sb, 0x3d, 0); /* make all inputs-l off */ 1164 sb_setmixer(sb, 0x3e, 0); /* make all inputs-r off */ 1165 } 1166 return 0; 1167} 1168 1169static int 1170sbmix_set(snd_mixer *m, unsigned dev, unsigned left, unsigned right) 1171{ 1172 struct sb_info *sb = mix_getdevinfo(m); 1173 int regoffs; 1174 u_char val; 1175 mixer_tab *iomap; 1176 1177 switch (sb->bd_flags & BD_F_MIX_MASK) { 1178 case BD_F_MIX_CT1345: 1179 iomap = &sbpro_mix; 1180 break; 1181 1182 case BD_F_MIX_CT1745: 1183 iomap = &sb16_mix; 1184 break; 1185 1186 default: 1187 return -1; 1188 /* XXX how about the SG NX Pro, iomap = sgnxpro_mix */ 1189 } 1190 regoffs = (*iomap)[dev][LEFT_CHN].regno; 1191 if (regoffs == 0) return -1; 1192 val = sb_getmixer(sb, regoffs); 1193 change_bits(iomap, &val, dev, LEFT_CHN, left); 1194 sb_setmixer(sb, regoffs, val); 1195 if ((*iomap)[dev][RIGHT_CHN].regno != regoffs) { /* Change register */ 1196 regoffs = (*iomap)[dev][RIGHT_CHN].regno; 1197 if (regoffs != 0) { 1198 val = sb_getmixer(sb, regoffs); /* Read the new one */ 1199 change_bits(iomap, &val, dev, RIGHT_CHN, right); 1200 sb_setmixer(sb, regoffs, val); 1201 } else right = left; 1202 } else right = left; 1203 return left | (right << 8); 1204} 1205 1206static int 1207sbmix_setrecsrc(snd_mixer *m, u_int32_t src) 1208{ 1209 struct sb_info *sb = mix_getdevinfo(m); 1210 u_char recdev; 1211 1212 switch (sb->bd_flags & BD_F_MIX_MASK) { 1213 case BD_F_MIX_CT1345: 1214 if (src == SOUND_MASK_LINE) recdev = 0x06; 1215 else if (src == SOUND_MASK_CD) recdev = 0x02; 1216 else { /* default: mic */ 1217 src = SOUND_MASK_MIC; 1218 recdev = 0; 1219 } 1220 sb_setmixer(sb, RECORD_SRC, recdev | 1221 (sb_getmixer(sb, RECORD_SRC) & ~0x07)); 1222 break; 1223 1224 case BD_F_MIX_CT1745: /* sb16 */ 1225 recdev = 0; 1226 if (src & SOUND_MASK_MIC) recdev |= 0x01; /* mono mic */ 1227 if (src & SOUND_MASK_CD) recdev |= 0x06; /* l+r cd */ 1228 if (src & SOUND_MASK_LINE) recdev |= 0x18; /* l+r line */ 1229 if (src & SOUND_MASK_SYNTH) recdev |= 0x60; /* l+r midi */ 1230 sb_setmixer(sb, SB16_IMASK_L, recdev); 1231 sb_setmixer(sb, SB16_IMASK_R, recdev); 1232 /* 1233 * since the same volume controls apply to the input and 1234 * output sections, the best approach to have a consistent 1235 * behaviour among cards would be to disable the output path 1236 * on devices which are used to record. 1237 * However, since users like to have feedback, we only disable 1238 * the mic -- permanently. 1239 */ 1240 sb_setmixer(sb, SB16_OMASK, 0x1f & ~1); 1241 break; 1242 } 1243 return src; 1244} 1245 1246#if NPNP > 0 1247static int 1248sbpnp_probe(device_t dev) 1249{ 1250 char *s = NULL; 1251 u_int32_t logical_id = isa_get_logicalid(dev); 1252 1253 switch(logical_id) { 1254 case 0x43008c0e: /* CTL0043 */ 1255 case 0x01008c0e: /* CTL0001 */ 1256 s = "Vibra16X"; 1257 break; 1258 1259 case 0x31008c0e: /* CTL0031 */ 1260 case 0x41008c0e: /* CTL0041 */ 1261 case 0x42008c0e: /* CTL0042 */ 1262 case 0x44008c0e: /* CTL0044 */ 1263 case 0x45008c0e: /* CTL0045 */ 1264 s = "SB16 PnP"; 1265 break; 1266 1267 case 0x01100000: /* @@@1001 */ 1268 s = "Avance Asound 110"; 1269 break; 1270 1271 case 0x01200000: /* @@@2001 */ 1272 s = "Avance Logic ALS120"; 1273 break; 1274 1275 case 0x68187316: /* ESS1868 */ 1276 s = "ESS1868"; 1277 break; 1278 } 1279 if (s) { 1280 device_set_desc(dev, s); 1281 return 0; 1282 } 1283 return ENXIO; 1284} 1285 1286static int 1287sbpnp_attach(device_t dev) 1288{ 1289 struct sb_info *sb; 1290 u_int32_t vend_id = isa_get_vendorid(dev); 1291 1292 sb = (struct sb_info *)malloc(sizeof *sb, M_DEVBUF, M_NOWAIT); 1293 if (!sb) return ENXIO; 1294 bzero(sb, sizeof *sb); 1295 1296 switch(vend_id) { 1297 case 0xf0008c0e: 1298 case 0x10019305: 1299 case 0x20019305: 1300 /* XXX add here the vend_id for other vibra16X cards... */ 1301 sb->bd_flags = BD_F_SB16X; 1302 } 1303 return sb_doattach(dev, sb); 1304} 1305 1306static device_method_t sbpnp_methods[] = { 1307 /* Device interface */ 1308 DEVMETHOD(device_probe, sbpnp_probe), 1309 DEVMETHOD(device_attach, sbpnp_attach), 1310 1311 { 0, 0 } 1312}; 1313 1314static driver_t sbpnp_driver = { 1315 "pcm", 1316 sbpnp_methods, 1317 sizeof(snddev_info), 1318}; 1319 1320DRIVER_MODULE(sbpnp, isa, sbpnp_driver, pcm_devclass, 0, 0); 1321 1322#endif /* NPNP > 0 */ 1323 1324#endif /* NPCM > 0 */ 1325 1326 1327