ad1816.c revision 65644
1/* 2 * Copyright (c) 1999 Cameron Grant <gandalf@vilnya.demon.co.uk> 3 * Copyright Luigi Rizzo, 1997,1998 4 * Copyright by Hannu Savolainen 1994, 1995 5 * All rights reserved. 6 * 7 * Redistribution and use in source and binary forms, with or without 8 * modification, are permitted provided that the following conditions 9 * are met: 10 * 1. Redistributions of source code must retain the above copyright 11 * notice, this list of conditions and the following disclaimer. 12 * 2. Redistributions in binary form must reproduce the above copyright 13 * notice, this list of conditions and the following disclaimer in the 14 * documentation and/or other materials provided with the distribution. 15 * 16 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 17 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 18 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 19 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 20 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 21 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 22 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 23 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 24 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 25 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 26 * SUCH DAMAGE. 27 * 28 * $FreeBSD: head/sys/dev/sound/isa/ad1816.c 65644 2000-09-09 19:21:04Z cg $ 29 */ 30 31#include <dev/sound/pcm/sound.h> 32#include <dev/sound/isa/ad1816.h> 33 34struct ad1816_info; 35 36struct ad1816_chinfo { 37 struct ad1816_info *parent; 38 pcm_channel *channel; 39 snd_dbuf *buffer; 40 int dir; 41}; 42 43struct ad1816_info { 44 struct resource *io_base; /* primary I/O address for the board */ 45 int io_rid; 46 struct resource *irq; 47 int irq_rid; 48 struct resource *drq1; /* play */ 49 int drq1_rid; 50 struct resource *drq2; /* rec */ 51 int drq2_rid; 52 void *ih; 53 bus_dma_tag_t parent_dmat; 54 55 struct ad1816_chinfo pch, rch; 56}; 57 58static driver_intr_t ad1816_intr; 59static int ad1816_probe(device_t dev); 60static int ad1816_attach(device_t dev); 61 62/* IO primitives */ 63static int ad1816_wait_init(struct ad1816_info *ad1816, int x); 64static u_short ad1816_read(struct ad1816_info *ad1816, u_int reg); 65static void ad1816_write(struct ad1816_info *ad1816, u_int reg, u_short data); 66 67static int ad1816mix_init(snd_mixer *m); 68static int ad1816mix_set(snd_mixer *m, unsigned dev, unsigned left, unsigned right); 69static int ad1816mix_setrecsrc(snd_mixer *m, u_int32_t src); 70static snd_mixer ad1816_mixer = { 71 "ad1816 mixer", 72 ad1816mix_init, 73 NULL, 74 ad1816mix_set, 75 ad1816mix_setrecsrc, 76}; 77 78static devclass_t pcm_devclass; 79 80/* channel interface */ 81static void *ad1816chan_init(void *devinfo, snd_dbuf *b, pcm_channel *c, int dir); 82static int ad1816chan_setdir(void *data, int dir); 83static int ad1816chan_setformat(void *data, u_int32_t format); 84static int ad1816chan_setspeed(void *data, u_int32_t speed); 85static int ad1816chan_setblocksize(void *data, u_int32_t blocksize); 86static int ad1816chan_trigger(void *data, int go); 87static int ad1816chan_getptr(void *data); 88static pcmchan_caps *ad1816chan_getcaps(void *data); 89 90static u_int32_t ad1816_fmt[] = { 91 AFMT_U8, 92 AFMT_STEREO | AFMT_U8, 93 AFMT_S16_LE, 94 AFMT_STEREO | AFMT_S16_LE, 95 AFMT_MU_LAW, 96 AFMT_STEREO | AFMT_MU_LAW, 97 AFMT_A_LAW, 98 AFMT_STEREO | AFMT_A_LAW, 99 0 100}; 101 102static pcmchan_caps ad1816_caps = {4000, 55200, ad1816_fmt, 0}; 103 104static pcm_channel ad1816_chantemplate = { 105 ad1816chan_init, 106 ad1816chan_setdir, 107 ad1816chan_setformat, 108 ad1816chan_setspeed, 109 ad1816chan_setblocksize, 110 ad1816chan_trigger, 111 ad1816chan_getptr, 112 ad1816chan_getcaps, 113 NULL, /* free */ 114 NULL, /* nop1 */ 115 NULL, /* nop2 */ 116 NULL, /* nop3 */ 117 NULL, /* nop4 */ 118 NULL, /* nop5 */ 119 NULL, /* nop6 */ 120 NULL, /* nop7 */ 121}; 122 123#define AD1816_MUTE 31 /* value for mute */ 124 125static int 126port_rd(struct resource *port, int off) 127{ 128 if (port) 129 return bus_space_read_1(rman_get_bustag(port), 130 rman_get_bushandle(port), 131 off); 132 else 133 return -1; 134} 135 136static void 137port_wr(struct resource *port, int off, u_int8_t data) 138{ 139 if (port) 140 return bus_space_write_1(rman_get_bustag(port), 141 rman_get_bushandle(port), 142 off, data); 143} 144 145static int 146io_rd(struct ad1816_info *ad1816, int reg) 147{ 148 return port_rd(ad1816->io_base, reg); 149} 150 151static void 152io_wr(struct ad1816_info *ad1816, int reg, u_int8_t data) 153{ 154 return port_wr(ad1816->io_base, reg, data); 155} 156 157static void 158ad1816_intr(void *arg) 159{ 160 struct ad1816_info *ad1816 = (struct ad1816_info *)arg; 161 unsigned char c, served = 0; 162 163 /* get interupt status */ 164 c = io_rd(ad1816, AD1816_INT); 165 166 /* check for stray interupts */ 167 if (c & ~(AD1816_INTRCI | AD1816_INTRPI)) { 168 printf("pcm: stray int (%x)\n", c); 169 c &= AD1816_INTRCI | AD1816_INTRPI; 170 } 171 /* check for capture interupt */ 172 if (ad1816->rch.buffer->dl && (c & AD1816_INTRCI)) { 173 chn_intr(ad1816->rch.channel); 174 served |= AD1816_INTRCI; /* cp served */ 175 } 176 /* check for playback interupt */ 177 if (ad1816->pch.buffer->dl && (c & AD1816_INTRPI)) { 178 chn_intr(ad1816->pch.channel); 179 served |= AD1816_INTRPI; /* pb served */ 180 } 181 if (served == 0) { 182 /* this probably means this is not a (working) ad1816 chip, */ 183 /* or an error in dma handling */ 184 printf("pcm: int without reason (%x)\n", c); 185 c = 0; 186 } else c &= ~served; 187 io_wr(ad1816, AD1816_INT, c); 188 c = io_rd(ad1816, AD1816_INT); 189 if (c != 0) printf("pcm: int clear failed (%x)\n", c); 190} 191 192static int 193ad1816_wait_init(struct ad1816_info *ad1816, int x) 194{ 195 int n = 0; /* to shut up the compiler... */ 196 197 for (; x--;) 198 if ((n = (io_rd(ad1816, AD1816_ALE) & AD1816_BUSY)) == 0) DELAY(10); 199 else return n; 200 printf("ad1816_wait_init failed 0x%02x.\n", n); 201 return -1; 202} 203 204static unsigned short 205ad1816_read(struct ad1816_info *ad1816, unsigned int reg) 206{ 207 int flags; 208 u_short x = 0; 209 210 /* we don't want to be blocked here */ 211 flags = spltty(); 212 if (ad1816_wait_init(ad1816, 100) == -1) return 0; 213 io_wr(ad1816, AD1816_ALE, 0); 214 io_wr(ad1816, AD1816_ALE, (reg & AD1816_ALEMASK)); 215 if (ad1816_wait_init(ad1816, 100) == -1) return 0; 216 x = (io_rd(ad1816, AD1816_HIGH) << 8) | io_rd(ad1816, AD1816_LOW); 217 splx(flags); 218 return x; 219} 220 221static void 222ad1816_write(struct ad1816_info *ad1816, unsigned int reg, unsigned short data) 223{ 224 int flags; 225 226 flags = spltty(); 227 if (ad1816_wait_init(ad1816, 100) == -1) return; 228 io_wr(ad1816, AD1816_ALE, (reg & AD1816_ALEMASK)); 229 io_wr(ad1816, AD1816_LOW, (data & 0x000000ff)); 230 io_wr(ad1816, AD1816_HIGH, (data & 0x0000ff00) >> 8); 231 splx(flags); 232} 233 234static int 235ad1816mix_init(snd_mixer *m) 236{ 237 mix_setdevs(m, AD1816_MIXER_DEVICES); 238 mix_setrecdevs(m, AD1816_REC_DEVICES); 239 return 0; 240} 241 242static int 243ad1816mix_set(snd_mixer *m, unsigned dev, unsigned left, unsigned right) 244{ 245 struct ad1816_info *ad1816 = mix_getdevinfo(m); 246 u_short reg = 0; 247 248 /* Scale volumes */ 249 left = AD1816_MUTE - (AD1816_MUTE * left) / 100; 250 right = AD1816_MUTE - (AD1816_MUTE * right) / 100; 251 252 reg = (left << 8) | right; 253 254 /* do channel selective muting if volume is zero */ 255 if (left == AD1816_MUTE) reg |= 0x8000; 256 if (right == AD1816_MUTE) reg |= 0x0080; 257 258 switch (dev) { 259 case SOUND_MIXER_VOLUME: /* Register 14 master volume */ 260 ad1816_write(ad1816, 14, reg); 261 break; 262 263 case SOUND_MIXER_CD: /* Register 15 cd */ 264 case SOUND_MIXER_LINE1: 265 ad1816_write(ad1816, 15, reg); 266 break; 267 268 case SOUND_MIXER_SYNTH: /* Register 16 synth */ 269 ad1816_write(ad1816, 16, reg); 270 break; 271 272 case SOUND_MIXER_PCM: /* Register 4 pcm */ 273 ad1816_write(ad1816, 4, reg); 274 break; 275 276 case SOUND_MIXER_LINE: 277 case SOUND_MIXER_LINE3: /* Register 18 line in */ 278 ad1816_write(ad1816, 18, reg); 279 break; 280 281 case SOUND_MIXER_MIC: /* Register 19 mic volume */ 282 ad1816_write(ad1816, 19, reg & ~0xff); /* mic is mono */ 283 break; 284 285 case SOUND_MIXER_IGAIN: 286 /* and now to something completely different ... */ 287 ad1816_write(ad1816, 20, ((ad1816_read(ad1816, 20) & ~0x0f0f) 288 | (((AD1816_MUTE - left) / 2) << 8) /* four bits of adc gain */ 289 | ((AD1816_MUTE - right) / 2))); 290 break; 291 292 default: 293 printf("ad1816_mixer_set(): unknown device.\n"); 294 break; 295 } 296 297 left = ((AD1816_MUTE - left) * 100) / AD1816_MUTE; 298 right = ((AD1816_MUTE - right) * 100) / AD1816_MUTE; 299 300 return left | (right << 8); 301} 302 303static int 304ad1816mix_setrecsrc(snd_mixer *m, u_int32_t src) 305{ 306 struct ad1816_info *ad1816 = mix_getdevinfo(m); 307 int dev; 308 309 switch (src) { 310 case SOUND_MASK_LINE: 311 case SOUND_MASK_LINE3: 312 dev = 0x00; 313 break; 314 315 case SOUND_MASK_CD: 316 case SOUND_MASK_LINE1: 317 dev = 0x20; 318 break; 319 320 case SOUND_MASK_MIC: 321 default: 322 dev = 0x50; 323 src = SOUND_MASK_MIC; 324 } 325 326 dev |= dev << 8; 327 ad1816_write(ad1816, 20, (ad1816_read(ad1816, 20) & ~0x7070) | dev); 328 return src; 329} 330 331/* channel interface */ 332static void * 333ad1816chan_init(void *devinfo, snd_dbuf *b, pcm_channel *c, int dir) 334{ 335 struct ad1816_info *ad1816 = devinfo; 336 struct ad1816_chinfo *ch = (dir == PCMDIR_PLAY)? &ad1816->pch : &ad1816->rch; 337 338 ch->parent = ad1816; 339 ch->channel = c; 340 ch->buffer = b; 341 ch->buffer->bufsize = DSP_BUFFSIZE; 342 if (chn_allocbuf(ch->buffer, ad1816->parent_dmat) == -1) return NULL; 343 return ch; 344} 345 346static int 347ad1816chan_setdir(void *data, int dir) 348{ 349 struct ad1816_chinfo *ch = data; 350 struct ad1816_info *ad1816 = ch->parent; 351 352 ch->buffer->chan = rman_get_start((dir == PCMDIR_PLAY)? 353 ad1816->drq1 : ad1816->drq2); 354 ch->dir = dir; 355 return 0; 356} 357 358static int 359ad1816chan_setformat(void *data, u_int32_t format) 360{ 361 struct ad1816_chinfo *ch = data; 362 struct ad1816_info *ad1816 = ch->parent; 363 364 int fmt = AD1816_U8, reg; 365 if (ch->dir == PCMDIR_PLAY) { 366 reg = AD1816_PLAY; 367 ad1816_write(ad1816, 8, 0x0000); /* reset base and current counter */ 368 ad1816_write(ad1816, 9, 0x0000); /* for playback and capture */ 369 } else { 370 reg = AD1816_CAPT; 371 ad1816_write(ad1816, 10, 0x0000); 372 ad1816_write(ad1816, 11, 0x0000); 373 } 374 switch (format & ~AFMT_STEREO) { 375 case AFMT_A_LAW: 376 fmt = AD1816_ALAW; 377 break; 378 379 case AFMT_MU_LAW: 380 fmt = AD1816_MULAW; 381 break; 382 383 case AFMT_S16_LE: 384 fmt = AD1816_S16LE; 385 break; 386 387 case AFMT_S16_BE: 388 fmt = AD1816_S16BE; 389 break; 390 391 case AFMT_U8: 392 fmt = AD1816_U8; 393 break; 394 } 395 if (format & AFMT_STEREO) fmt |= AD1816_STEREO; 396 io_wr(ad1816, reg, fmt); 397 return format; 398} 399 400static int 401ad1816chan_setspeed(void *data, u_int32_t speed) 402{ 403 struct ad1816_chinfo *ch = data; 404 struct ad1816_info *ad1816 = ch->parent; 405 406 RANGE(speed, 4000, 55200); 407 ad1816_write(ad1816, (ch->dir == PCMDIR_PLAY)? 2 : 3, speed); 408 return speed; 409} 410 411static int 412ad1816chan_setblocksize(void *data, u_int32_t blocksize) 413{ 414 return blocksize; 415} 416 417static int 418ad1816chan_trigger(void *data, int go) 419{ 420 struct ad1816_chinfo *ch = data; 421 struct ad1816_info *ad1816 = ch->parent; 422 int wr, reg; 423 424 if (go == PCMTRIG_EMLDMAWR || go == PCMTRIG_EMLDMARD) 425 return 0; 426 427 buf_isadma(ch->buffer, go); 428 wr = (ch->dir == PCMDIR_PLAY); 429 reg = wr? AD1816_PLAY : AD1816_CAPT; 430 switch (go) { 431 case PCMTRIG_START: 432 /* start only if not already running */ 433 if (!(io_rd(ad1816, reg) & AD1816_ENABLE)) { 434 int cnt = ((ch->buffer->dl) >> 2) - 1; 435 ad1816_write(ad1816, wr? 8 : 10, cnt); /* count */ 436 ad1816_write(ad1816, wr? 9 : 11, 0); /* reset cur cnt */ 437 ad1816_write(ad1816, 1, ad1816_read(ad1816, 1) | 438 (wr? 0x8000 : 0x4000)); /* enable int */ 439 /* enable playback */ 440 io_wr(ad1816, reg, io_rd(ad1816, reg) | AD1816_ENABLE); 441 if (!(io_rd(ad1816, reg) & AD1816_ENABLE)) 442 printf("ad1816: failed to start %s DMA!\n", 443 wr? "play" : "rec"); 444 } 445 break; 446 447 case PCMTRIG_STOP: 448 case PCMTRIG_ABORT: /* XXX check this... */ 449 /* we don't test here if it is running... */ 450 if (wr) { 451 ad1816_write(ad1816, 1, ad1816_read(ad1816, 1) & 452 ~(wr? 0x8000 : 0x4000)); 453 /* disable int */ 454 io_wr(ad1816, reg, io_rd(ad1816, reg) & ~AD1816_ENABLE); 455 /* disable playback */ 456 if (io_rd(ad1816, reg) & AD1816_ENABLE) 457 printf("ad1816: failed to stop %s DMA!\n", 458 wr? "play" : "rec"); 459 ad1816_write(ad1816, wr? 8 : 10, 0); /* reset base cnt */ 460 ad1816_write(ad1816, wr? 9 : 11, 0); /* reset cur cnt */ 461 } 462 break; 463 } 464 return 0; 465} 466 467static int 468ad1816chan_getptr(void *data) 469{ 470 struct ad1816_chinfo *ch = data; 471 return buf_isadmaptr(ch->buffer); 472} 473 474static pcmchan_caps * 475ad1816chan_getcaps(void *data) 476{ 477 return &ad1816_caps; 478} 479 480static void 481ad1816_release_resources(struct ad1816_info *ad1816, device_t dev) 482{ 483 if (ad1816->irq) { 484 if (ad1816->ih) 485 bus_teardown_intr(dev, ad1816->irq, ad1816->ih); 486 bus_release_resource(dev, SYS_RES_IRQ, ad1816->irq_rid, 487 ad1816->irq); 488 ad1816->irq = 0; 489 } 490 if (ad1816->drq1) { 491 bus_release_resource(dev, SYS_RES_DRQ, ad1816->drq1_rid, 492 ad1816->drq1); 493 ad1816->drq1 = 0; 494 } 495 if (ad1816->drq2) { 496 bus_release_resource(dev, SYS_RES_DRQ, ad1816->drq2_rid, 497 ad1816->drq2); 498 ad1816->drq2 = 0; 499 } 500 if (ad1816->io_base) { 501 bus_release_resource(dev, SYS_RES_IOPORT, ad1816->io_rid, 502 ad1816->io_base); 503 ad1816->io_base = 0; 504 } 505 if (ad1816->parent_dmat) { 506 bus_dma_tag_destroy(ad1816->parent_dmat); 507 ad1816->parent_dmat = 0; 508 } 509 free(ad1816, M_DEVBUF); 510} 511 512static int 513ad1816_alloc_resources(struct ad1816_info *ad1816, device_t dev) 514{ 515 int ok = 1, pdma, rdma; 516 if (!ad1816->io_base) 517 ad1816->io_base = bus_alloc_resource(dev, SYS_RES_IOPORT, &ad1816->io_rid, 518 0, ~0, 1, RF_ACTIVE); 519 if (!ad1816->irq) 520 ad1816->irq = bus_alloc_resource(dev, SYS_RES_IRQ, &ad1816->irq_rid, 521 0, ~0, 1, RF_ACTIVE); 522 if (!ad1816->drq1) 523 ad1816->drq1 = bus_alloc_resource(dev, SYS_RES_DRQ, &ad1816->drq1_rid, 524 0, ~0, 1, RF_ACTIVE); 525 if (!ad1816->drq2) 526 ad1816->drq2 = bus_alloc_resource(dev, SYS_RES_DRQ, &ad1816->drq2_rid, 527 0, ~0, 1, RF_ACTIVE); 528 529 if (!ad1816->io_base || !ad1816->drq1 || !ad1816->irq) ok = 0; 530 531 if (ok) { 532 pdma = rman_get_start(ad1816->drq1); 533 isa_dma_acquire(pdma); 534 isa_dmainit(pdma, DSP_BUFFSIZE); 535 if (ad1816->drq2) { 536 rdma = rman_get_start(ad1816->drq2); 537 isa_dma_acquire(rdma); 538 isa_dmainit(rdma, DSP_BUFFSIZE); 539 } else rdma = pdma; 540 if (pdma == rdma) 541 pcm_setflags(dev, pcm_getflags(dev) | SD_F_SIMPLEX); 542 } 543 return ok; 544} 545 546static int 547ad1816_init(struct ad1816_info *ad1816, device_t dev) 548{ 549 ad1816_write(ad1816, 1, 0x2); /* disable interrupts */ 550 ad1816_write(ad1816, 32, 0x90F0); /* SoundSys Mode, split fmt */ 551 552 ad1816_write(ad1816, 5, 0x8080); /* FM volume mute */ 553 ad1816_write(ad1816, 6, 0x8080); /* I2S1 volume mute */ 554 ad1816_write(ad1816, 7, 0x8080); /* I2S0 volume mute */ 555 ad1816_write(ad1816, 17, 0x8888); /* VID Volume mute */ 556 ad1816_write(ad1816, 20, 0x5050); /* recsrc mic, agc off */ 557 /* adc gain is set to 0 */ 558 559 return 0; 560} 561 562static int 563ad1816_probe(device_t dev) 564{ 565 char *s = NULL; 566 u_int32_t logical_id = isa_get_logicalid(dev); 567 568 switch (logical_id) { 569 case 0x80719304: /* ADS7180 */ 570 s = "AD1816"; 571 break; 572 } 573 574 if (s) { 575 device_set_desc(dev, s); 576 return 0; 577 } 578 return ENXIO; 579} 580 581static int 582ad1816_attach(device_t dev) 583{ 584 struct ad1816_info *ad1816; 585 char status[SND_STATUSLEN]; 586 587 ad1816 = (struct ad1816_info *)malloc(sizeof *ad1816, M_DEVBUF, M_NOWAIT); 588 if (!ad1816) return ENXIO; 589 bzero(ad1816, sizeof *ad1816); 590 591 ad1816->io_rid = 2; 592 ad1816->irq_rid = 0; 593 ad1816->drq1_rid = 0; 594 ad1816->drq2_rid = 1; 595 596 if (!ad1816_alloc_resources(ad1816, dev)) goto no; 597 ad1816_init(ad1816, dev); 598 mixer_init(dev, &ad1816_mixer, ad1816); 599 bus_setup_intr(dev, ad1816->irq, INTR_TYPE_TTY, ad1816_intr, ad1816, &ad1816->ih); 600 if (bus_dma_tag_create(/*parent*/NULL, /*alignment*/2, /*boundary*/0, 601 /*lowaddr*/BUS_SPACE_MAXADDR_24BIT, 602 /*highaddr*/BUS_SPACE_MAXADDR, 603 /*filter*/NULL, /*filterarg*/NULL, 604 /*maxsize*/DSP_BUFFSIZE, /*nsegments*/1, 605 /*maxsegz*/0x3ffff, 606 /*flags*/0, &ad1816->parent_dmat) != 0) { 607 device_printf(dev, "unable to create dma tag\n"); 608 goto no; 609 } 610 snprintf(status, SND_STATUSLEN, "at io 0x%lx irq %ld drq %ld", 611 rman_get_start(ad1816->io_base), 612 rman_get_start(ad1816->irq), 613 rman_get_start(ad1816->drq1)); 614 if (ad1816->drq2) snprintf(status + strlen(status), 615 SND_STATUSLEN - strlen(status), ":%ld", 616 rman_get_start(ad1816->drq2)); 617 618 if (pcm_register(dev, ad1816, 1, 1)) goto no; 619 pcm_addchan(dev, PCMDIR_REC, &ad1816_chantemplate, ad1816); 620 pcm_addchan(dev, PCMDIR_PLAY, &ad1816_chantemplate, ad1816); 621 pcm_setstatus(dev, status); 622 623 return 0; 624no: 625 ad1816_release_resources(ad1816, dev); 626 return ENXIO; 627 628} 629 630static int 631ad1816_detach(device_t dev) 632{ 633 int r; 634 struct ad1816_info *ad1816; 635 636 r = pcm_unregister(dev); 637 if (r) 638 return r; 639 640 ad1816 = pcm_getdevinfo(dev); 641 ad1816_release_resources(ad1816, dev); 642 return 0; 643} 644 645static device_method_t ad1816_methods[] = { 646 /* Device interface */ 647 DEVMETHOD(device_probe, ad1816_probe), 648 DEVMETHOD(device_attach, ad1816_attach), 649 DEVMETHOD(device_detach, ad1816_detach), 650 651 { 0, 0 } 652}; 653 654static driver_t ad1816_driver = { 655 "pcm", 656 ad1816_methods, 657 sizeof(snddev_info), 658}; 659 660DRIVER_MODULE(snd_ad1816, isa, ad1816_driver, pcm_devclass, 0, 0); 661MODULE_DEPEND(snd_ad1816, snd_pcm, PCM_MINVER, PCM_PREFVER, PCM_MAXVER); 662MODULE_VERSION(snd_ad1816, 1); 663 664 665