Lines Matching +full:dma +full:- +full:router

1 /*-
2 * SPDX-License-Identifier: BSD-2-Clause
35 * generous gift - an 'Audiotrak Prodigy HD2' audio card! I also want to
58 /* -------------------------------------------------------------------- */
140 /* DMA tag */
159 /* Play/Record DMA fifo */
162 u_int32_t psize, rsize; /* DMA buffer size(byte) */
178 /* -------------------------------------------------------------------- */
184 /* DMA emulator */
214 /* -------------------------------------------------------------------- */
220 /* API -> hardware channel map */
235 /* mixer -> API channel map. see above */
237 -1, /* Master output level. It is depend on codec support */
238 -1, /* Treble level of all output channels */
239 -1, /* Bass level of all output channels */
240 -1, /* Volume of synthesier input */
242 -1, /* Output level for the PC speaker */
244 -1, /* microphone jack */
245 -1, /* CD audio input */
246 -1, /* Recording monitor */
248 -1, /* global recording level */
249 -1, /* Input gain */
250 -1, /* Output gain */
255 -1, /* Digital (input) 2 */
256 -1, /* Digital (input) 3 */
257 -1, /* Phone input */
258 -1, /* Phone output */
259 -1, /* Video/TV (audio) in */
260 -1, /* Radio in */
261 -1, /* Monitor volume */
327 "Envy24HT-S audio (Terratec PHASE 22)",
354 "Envy24HT audio (M-Audio Revolution 7.1)",
363 "Envy24GT audio (M-Audio Revolution 5.1)",
372 "Envy24HT audio (M-Audio Audiophile 192)",
399 "Envy24HT-S audio (Terrasoniq TS22PCI)",
453 /* -------------------------------------------------------------------- */
461 return bus_space_read_1(sc->cst, sc->csh, regno); in envy24ht_rdcs()
463 return bus_space_read_2(sc->cst, sc->csh, regno); in envy24ht_rdcs()
465 return bus_space_read_4(sc->cst, sc->csh, regno); in envy24ht_rdcs()
476 bus_space_write_1(sc->cst, sc->csh, regno, data); in envy24ht_wrcs()
479 bus_space_write_2(sc->cst, sc->csh, regno, data); in envy24ht_wrcs()
482 bus_space_write_4(sc->cst, sc->csh, regno, data); in envy24ht_wrcs()
492 return bus_space_read_1(sc->mtt, sc->mth, regno); in envy24ht_rdmt()
494 return bus_space_read_2(sc->mtt, sc->mth, regno); in envy24ht_rdmt()
496 return bus_space_read_4(sc->mtt, sc->mth, regno); in envy24ht_rdmt()
507 bus_space_write_1(sc->mtt, sc->mth, regno, data); in envy24ht_wrmt()
510 bus_space_write_2(sc->mtt, sc->mth, regno, data); in envy24ht_wrmt()
513 bus_space_write_4(sc->mtt, sc->mth, regno, data); in envy24ht_wrmt()
518 /* -------------------------------------------------------------------- */
529 device_printf(sc->dev, "envy24ht_rdi2c(sc, 0x%02x, 0x%02x)\n", dev, addr); in envy24ht_rdi2c()
538 return -1; in envy24ht_rdi2c()
550 return -1; in envy24ht_rdi2c()
555 device_printf(sc->dev, "envy24ht_rdi2c(): return 0x%x\n", data); in envy24ht_rdi2c()
567 device_printf(sc->dev, "envy24ht_rdi2c(sc, 0x%02x, 0x%02x)\n", dev, addr); in envy24ht_wri2c()
576 return -1; in envy24ht_wri2c()
589 return -1; in envy24ht_wri2c()
601 device_printf(sc->dev, "envy24ht_rdrom(sc, 0x%02x)\n", addr); in envy24ht_rdrom()
606 device_printf(sc->dev, "envy24ht_rdrom(): E2PROM not presented\n"); in envy24ht_rdrom()
608 return -1; in envy24ht_rdrom()
622 device_printf(sc->dev, "envy24ht_rom2cfg(sc)\n"); in envy24ht_rom2cfg()
627 device_printf(sc->dev, "envy24ht_rom2cfg(): ENVY24HT_E2PROM_SIZE-->%d\n", size); in envy24ht_rom2cfg()
632 device_printf(sc->dev, "envy24ht_rom2cfg(): malloc()\n"); in envy24ht_rom2cfg()
636 buff->free = 1; in envy24ht_rom2cfg()
639 buff->subvendor = envy24ht_rdrom(sc, ENVY24HT_E2PROM_SUBVENDOR) << 8; in envy24ht_rom2cfg()
640 buff->subvendor += envy24ht_rdrom(sc, ENVY24HT_E2PROM_SUBVENDOR + 1); in envy24ht_rom2cfg()
641 buff->subdevice = envy24ht_rdrom(sc, ENVY24HT_E2PROM_SUBDEVICE) << 8; in envy24ht_rom2cfg()
642 buff->subdevice += envy24ht_rdrom(sc, ENVY24HT_E2PROM_SUBDEVICE + 1); in envy24ht_rom2cfg()
643 buff->scfg = 0x0b; in envy24ht_rom2cfg()
644 buff->acl = 0x80; in envy24ht_rom2cfg()
645 buff->i2s = 0xfc; in envy24ht_rom2cfg()
646 buff->spdif = 0xc3; in envy24ht_rom2cfg()
647 buff->gpiomask = 0x21efff; in envy24ht_rom2cfg()
648 buff->gpiostate = 0x7fffff; in envy24ht_rom2cfg()
649 buff->gpiodir = 0x5e1000; in envy24ht_rom2cfg()
650 buff->cdti = 0x40000; in envy24ht_rom2cfg()
651 buff->cclk = 0x80000; in envy24ht_rom2cfg()
652 buff->cs = 0x1000; in envy24ht_rom2cfg()
653 buff->cif = 0x00; in envy24ht_rom2cfg()
654 buff->type = 0x02; in envy24ht_rom2cfg()
658 if (cfg_table[i].subvendor == buff->subvendor && in envy24ht_rom2cfg()
659 cfg_table[i].subdevice == buff->subdevice) in envy24ht_rom2cfg()
661 buff->name = cfg_table[i].name; in envy24ht_rom2cfg()
662 buff->codec = cfg_table[i].codec; in envy24ht_rom2cfg()
672 device_printf(sc->dev, "envy24ht_rom2cfg(): malloc()\n"); in envy24ht_rom2cfg()
676 buff->free = 1; in envy24ht_rom2cfg()
678 buff->subvendor = envy24ht_rdrom(sc, ENVY24HT_E2PROM_SUBVENDOR) << 8; in envy24ht_rom2cfg()
679 buff->subvendor += envy24ht_rdrom(sc, ENVY24HT_E2PROM_SUBVENDOR + 1); in envy24ht_rom2cfg()
680 buff->subdevice = envy24ht_rdrom(sc, ENVY24HT_E2PROM_SUBDEVICE) << 8; in envy24ht_rom2cfg()
681 buff->subdevice += envy24ht_rdrom(sc, ENVY24HT_E2PROM_SUBDEVICE + 1); in envy24ht_rom2cfg()
682 buff->scfg = envy24ht_rdrom(sc, ENVY24HT_E2PROM_SCFG); in envy24ht_rom2cfg()
683 buff->acl = envy24ht_rdrom(sc, ENVY24HT_E2PROM_ACL); in envy24ht_rom2cfg()
684 buff->i2s = envy24ht_rdrom(sc, ENVY24HT_E2PROM_I2S); in envy24ht_rom2cfg()
685 buff->spdif = envy24ht_rdrom(sc, ENVY24HT_E2PROM_SPDIF); in envy24ht_rom2cfg()
686 buff->gpiomask = envy24ht_rdrom(sc, ENVY24HT_E2PROM_GPIOMASK) | \ in envy24ht_rom2cfg()
689 buff->gpiostate = envy24ht_rdrom(sc, ENVY24HT_E2PROM_GPIOSTATE) | \ in envy24ht_rom2cfg()
692 buff->gpiodir = envy24ht_rdrom(sc, ENVY24HT_E2PROM_GPIODIR) | \ in envy24ht_rom2cfg()
697 if (cfg_table[i].subvendor == buff->subvendor && in envy24ht_rom2cfg()
698 cfg_table[i].subdevice == buff->subdevice) in envy24ht_rom2cfg()
700 buff->name = cfg_table[i].name; in envy24ht_rom2cfg()
701 buff->codec = cfg_table[i].codec; in envy24ht_rom2cfg()
710 if (cfg->free) in envy24ht_cfgfree()
715 /* -------------------------------------------------------------------- */
727 device_printf(sc->dev, "envy24ht_coldcd()\n"); in envy24ht_coldcd()
740 return -1; in envy24ht_coldcd()
750 device_printf(sc->dev, "envy24ht_slavecd()\n"); in envy24ht_slavecd()
764 return -1; in envy24ht_slavecd()
775 device_printf(sc->dev, "envy24ht_rdcd(obj, sc, 0x%02x)\n", regno); in envy24ht_rdcd()
787 device_printf(sc->dev, "envy24ht_rdcd(): return 0x%x\n", data); in envy24ht_rdcd()
800 device_printf(sc->dev, "envy24ht_wrcd(obj, sc, 0x%02x, 0x%04x)\n", regno, data); in envy24ht_wrcd()
822 /* -------------------------------------------------------------------- */
829 if (sc->cfg->subvendor == 0x153b && sc->cfg->subdevice == 0x1150) in envy24ht_gpiord()
839 device_printf(sc->dev, "envy24ht_gpiowr(sc, 0x%02x)\n", data & 0x7FFFFF); in envy24ht_gpiowr()
843 if (sc->cfg->subdevice != 0x1150) in envy24ht_gpiowr()
860 if (sc->cfg->subdevice != 0x1150) in envy24ht_gpiosetmask()
876 if (sc->cfg->subvendor == 0x153b && sc->cfg->subdevice == 0x1150) in envy24ht_gpiosetdir()
883 /* -------------------------------------------------------------------- */
902 device_printf(ptr->parent->dev, "--> %d, %d, %d\n", cs, cclk, cdti); in envy24ht_spi_ctl()
904 data = envy24ht_gpiord(ptr->parent); in envy24ht_spi_ctl()
905 data &= ~(ptr->cs | ptr->cclk | ptr->cdti); in envy24ht_spi_ctl()
906 if (cs) data += ptr->cs; in envy24ht_spi_ctl()
907 if (cclk) data += ptr->cclk; in envy24ht_spi_ctl()
908 if (cdti) data += ptr->cdti; in envy24ht_spi_ctl()
909 envy24ht_gpiowr(ptr->parent, data); in envy24ht_spi_ctl()
920 device_printf(sc->dev, "envy24ht_spi_create(dev, sc, %d, %d)\n", dir, num); in envy24ht_spi_create()
927 if (dir == PCMDIR_REC && sc->adc[num] != NULL) in envy24ht_spi_create()
928 buff->info = ((struct envy24ht_spi_codec *)sc->adc[num])->info; in envy24ht_spi_create()
929 else if (dir == PCMDIR_PLAY && sc->dac[num] != NULL) in envy24ht_spi_create()
930 buff->info = ((struct envy24ht_spi_codec *)sc->dac[num])->info; in envy24ht_spi_create()
932 buff->info = spicds_create(dev, buff, num, envy24ht_spi_ctl); in envy24ht_spi_create()
933 if (buff->info == NULL) { in envy24ht_spi_create()
938 buff->parent = sc; in envy24ht_spi_create()
939 buff->dir = dir; in envy24ht_spi_create()
940 buff->num = num; in envy24ht_spi_create()
952 device_printf(ptr->parent->dev, "envy24ht_spi_destroy()\n"); in envy24ht_spi_destroy()
955 if (ptr->dir == PCMDIR_PLAY) { in envy24ht_spi_destroy()
956 if (ptr->parent->dac[ptr->num] != NULL) in envy24ht_spi_destroy()
957 spicds_destroy(ptr->info); in envy24ht_spi_destroy()
960 if (ptr->parent->adc[ptr->num] != NULL) in envy24ht_spi_destroy()
961 spicds_destroy(ptr->info); in envy24ht_spi_destroy()
974 device_printf(ptr->parent->dev, "envy24ht_spicds_init()\n"); in envy24ht_spi_init()
976 ptr->cs = ptr->parent->cfg->cs; in envy24ht_spi_init()
977 ptr->cclk = ptr->parent->cfg->cclk; in envy24ht_spi_init()
978 ptr->cdti = ptr->parent->cfg->cdti; in envy24ht_spi_init()
979 spicds_settype(ptr->info, ptr->parent->cfg->type); in envy24ht_spi_init()
980 spicds_setcif(ptr->info, ptr->parent->cfg->cif); in envy24ht_spi_init()
981 if (ptr->parent->cfg->type == SPICDS_TYPE_AK4524 || \ in envy24ht_spi_init()
982 ptr->parent->cfg->type == SPICDS_TYPE_AK4528) { in envy24ht_spi_init()
983 spicds_setformat(ptr->info, in envy24ht_spi_init()
985 spicds_setdvc(ptr->info, AK452X_DVC_DEMOFF); in envy24ht_spi_init()
989 if (ptr->num == 0) in envy24ht_spi_init()
990 spicds_init(ptr->info); in envy24ht_spi_init()
1000 device_printf(ptr->parent->dev, "envy24ht_spi_reinit()\n"); in envy24ht_spi_reinit()
1003 spicds_reinit(ptr->info); in envy24ht_spi_reinit()
1013 device_printf(ptr->parent->dev, "envy24ht_spi_set()\n"); in envy24ht_spi_setvolume()
1016 spicds_set(ptr->info, dir, left, right); in envy24ht_spi_setvolume()
1019 /* -------------------------------------------------------------------- */
1051 device_printf(sc->dev, "envy24ht_setspeed(sc, %d)\n", speed); in envy24ht_setspeed()
1065 …device_printf(sc->dev, "envy24ht_setspeed(): speed %d/code 0x%04x\n", envy24ht_speedtab[i].speed, … in envy24ht_setspeed()
1069 …if ((((sc->cfg->scfg & ENVY24HT_CCSM_SCFG_XIN2) == 0x00) && (code == ENVY24HT_MT_RATE_192000)) || \ in envy24ht_setspeed()
1092 device_printf(sc->dev, "envy24ht_setspeed(): return %d\n", speed); in envy24ht_setspeed()
1101 device_printf(sc->dev, "envy24ht_setvolume(sc, %d)\n", ch); in envy24ht_setvolume()
1103 envy24ht_wrmt(sc, ENVY24HT_MT_VOLUME, 0x7f00 | sc->left[ch], 2); in envy24ht_setvolume()
1105 envy24ht_wrmt(sc, ENVY24HT_MT_VOLUME, (sc->right[ch] << 8) | 0x7f, 2); in envy24ht_setvolume()
1115 device_printf(sc->dev, "envy24ht_mutevolume(sc, %d)\n", ch); in envy24ht_mutevolume()
1131 device_printf(sc->dev, "envy24ht_gethwptr(sc, %d)\n", dir); in envy24ht_gethwptr()
1134 rtn = sc->psize / 4; in envy24ht_gethwptr()
1139 rtn = sc->rsize / 4; in envy24ht_gethwptr()
1145 rtn -= (ptr + 1); in envy24ht_gethwptr()
1149 device_printf(sc->dev, "envy24ht_gethwptr(): return %d\n", rtn); in envy24ht_gethwptr()
1163 device_printf(sc->dev, "envy24ht_updintr(sc, %d)\n", dir); in envy24ht_updintr()
1166 blk = sc->blk[0]; in envy24ht_updintr()
1171 blk = sc->blk[1]; in envy24ht_updintr()
1176 cnt = blk - 1; in envy24ht_updintr()
1178 device_printf(sc->dev, "envy24ht_updintr():blk = %d, cnt = %d\n", blk, cnt); in envy24ht_updintr()
1183 device_printf(sc->dev, "envy24ht_updintr():intr = 0x%02x, mask = 0x%02x\n", intr, mask); in envy24ht_updintr()
1187 device_printf(sc->dev, "envy24ht_updintr():INT-->0x%02x\n", in envy24ht_updintr()
1201 device_printf(sc->dev, "envy24ht_maskintr(sc, %d)\n", dir); in envy24ht_maskintr()
1220 device_printf(sc->dev, "envy24ht_checkintr(sc, %d)\n", dir); in envy24ht_checkintr()
1253 device_printf(sc->dev, "envy24ht_start(sc, %d)\n", dir); in envy24ht_start()
1264 device_printf(sc->dev, "PADDR:0x%08x\n", envy24ht_rdmt(sc, ENVY24HT_MT_PADDR, 4)); in envy24ht_start()
1265 device_printf(sc->dev, "PCNT:%ld\n", envy24ht_rdmt(sc, ENVY24HT_MT_PCNT, 2)); in envy24ht_start()
1277 device_printf(sc->dev, "envy24ht_stop(sc, %d)\n", dir); in envy24ht_stop()
1298 /* -------------------------------------------------------------------- */
1310 length = sndbuf_getready(ch->buffer) / 8; in envy24ht_p32sl()
1311 dmabuf = ch->parent->pbuf; in envy24ht_p32sl()
1312 data = (u_int32_t *)ch->data; in envy24ht_p32sl()
1313 src = sndbuf_getreadyptr(ch->buffer) / 4; in envy24ht_p32sl()
1314 dst = src / 2 + ch->offset; in envy24ht_p32sl()
1315 ssize = ch->size / 4; in envy24ht_p32sl()
1316 dsize = ch->size / 8; in envy24ht_p32sl()
1317 slot = ch->num * 2; in envy24ht_p32sl()
1341 device_printf(ch->parent->dev, "envy24ht_p16sl()\n"); in envy24ht_p16sl()
1343 length = sndbuf_getready(ch->buffer) / 4; in envy24ht_p16sl()
1344 dmabuf = ch->parent->pbuf; in envy24ht_p16sl()
1345 data = (u_int16_t *)ch->data; in envy24ht_p16sl()
1346 src = sndbuf_getreadyptr(ch->buffer) / 2; in envy24ht_p16sl()
1347 dst = src / 2 + ch->offset; in envy24ht_p16sl()
1348 ssize = ch->size / 2; in envy24ht_p16sl()
1349 dsize = ch->size / 4; in envy24ht_p16sl()
1350 slot = ch->num * 2; in envy24ht_p16sl()
1352 device_printf(ch->parent->dev, "envy24ht_p16sl():%lu-->%lu(%lu)\n", src, dst, length); in envy24ht_p16sl()
1385 length = sndbuf_getready(ch->buffer) / 2; in envy24ht_p8u()
1386 dmabuf = ch->parent->pbuf; in envy24ht_p8u()
1387 data = (u_int8_t *)ch->data; in envy24ht_p8u()
1388 src = sndbuf_getreadyptr(ch->buffer); in envy24ht_p8u()
1389 dst = src / 2 + ch->offset; in envy24ht_p8u()
1390 ssize = ch->size; in envy24ht_p8u()
1391 dsize = ch->size / 4; in envy24ht_p8u()
1392 slot = ch->num * 2; in envy24ht_p8u()
1415 length = sndbuf_getfree(ch->buffer) / 8; in envy24ht_r32sl()
1416 dmabuf = ch->parent->rbuf; in envy24ht_r32sl()
1417 data = (u_int32_t *)ch->data; in envy24ht_r32sl()
1418 dst = sndbuf_getfreeptr(ch->buffer) / 4; in envy24ht_r32sl()
1419 src = dst / 2 + ch->offset; in envy24ht_r32sl()
1420 dsize = ch->size / 4; in envy24ht_r32sl()
1421 ssize = ch->size / 8; in envy24ht_r32sl()
1422 slot = (ch->num - ENVY24HT_CHAN_REC_ADC1) * 2; in envy24ht_r32sl()
1445 length = sndbuf_getfree(ch->buffer) / 4; in envy24ht_r16sl()
1446 dmabuf = ch->parent->rbuf; in envy24ht_r16sl()
1447 data = (u_int16_t *)ch->data; in envy24ht_r16sl()
1448 dst = sndbuf_getfreeptr(ch->buffer) / 2; in envy24ht_r16sl()
1449 src = dst / 2 + ch->offset; in envy24ht_r16sl()
1450 dsize = ch->size / 2; in envy24ht_r16sl()
1451 ssize = ch->size / 8; in envy24ht_r16sl()
1452 slot = (ch->num - ENVY24HT_CHAN_REC_ADC1) * 2; in envy24ht_r16sl()
1466 /* -------------------------------------------------------------------- */
1477 device_printf(sc->dev, "envy24htchan_init(obj, devinfo, b, c, %d)\n", dir); in envy24htchan_init()
1479 snd_mtxlock(sc->lock); in envy24htchan_init()
1481 if ((sc->chnum > ENVY24HT_CHAN_PLAY_SPDIF && dir != PCMDIR_REC) || in envy24htchan_init()
1482 (sc->chnum < ENVY24HT_CHAN_REC_ADC1 && dir != PCMDIR_PLAY)) { in envy24htchan_init()
1483 snd_mtxunlock(sc->lock); in envy24htchan_init()
1487 num = sc->chnum; in envy24htchan_init()
1489 ch = &sc->chan[num]; in envy24htchan_init()
1490 ch->size = 8 * ENVY24HT_SAMPLE_NUM; in envy24htchan_init()
1491 ch->data = malloc(ch->size, M_ENVY24HT, M_NOWAIT); in envy24htchan_init()
1492 if (ch->data == NULL) { in envy24htchan_init()
1493 ch->size = 0; in envy24htchan_init()
1497 ch->buffer = b; in envy24htchan_init()
1498 ch->channel = c; in envy24htchan_init()
1499 ch->parent = sc; in envy24htchan_init()
1500 ch->dir = dir; in envy24htchan_init()
1502 ch->num = envy24ht_chanmap[num]; in envy24htchan_init()
1503 snd_mtxunlock(sc->lock); in envy24htchan_init()
1504 sndbuf_setup(ch->buffer, ch->data, ch->size); in envy24htchan_init()
1505 snd_mtxlock(sc->lock); in envy24htchan_init()
1507 ch->unit = 4; in envy24htchan_init()
1508 ch->blk = 10240; in envy24htchan_init()
1510 snd_mtxunlock(sc->lock); in envy24htchan_init()
1519 struct sc_info *sc = ch->parent; in envy24htchan_free()
1522 device_printf(sc->dev, "envy24htchan_free()\n"); in envy24htchan_free()
1524 snd_mtxlock(sc->lock); in envy24htchan_free()
1525 if (ch->data != NULL) { in envy24htchan_free()
1526 free(ch->data, M_ENVY24HT); in envy24htchan_free()
1527 ch->data = NULL; in envy24htchan_free()
1529 snd_mtxunlock(sc->lock); in envy24htchan_free()
1538 struct sc_info *sc = ch->parent; in envy24htchan_setformat()
1544 device_printf(sc->dev, "envy24htchan_setformat(obj, data, 0x%08x)\n", format); in envy24htchan_setformat()
1546 snd_mtxlock(sc->lock); in envy24htchan_setformat()
1548 if (ch->dir == PCMDIR_PLAY) in envy24htchan_setformat()
1553 snd_mtxunlock(sc->lock); in envy24htchan_setformat()
1554 return -1; in envy24htchan_setformat()
1560 snd_mtxunlock(sc->lock); in envy24htchan_setformat()
1561 return -1; in envy24htchan_setformat()
1565 ch->format = format; in envy24htchan_setformat()
1566 ch->emldma = emltab[i].emldma; in envy24htchan_setformat()
1567 if (ch->unit > emltab[i].unit) in envy24htchan_setformat()
1568 ch->blk *= ch->unit / emltab[i].unit; in envy24htchan_setformat()
1570 ch->blk /= emltab[i].unit / ch->unit; in envy24htchan_setformat()
1571 ch->unit = emltab[i].unit; in envy24htchan_setformat()
1574 ch->size = ch->unit * ENVY24HT_SAMPLE_NUM; in envy24htchan_setformat()
1576 if (ch->dir == PCMDIR_PLAY) in envy24htchan_setformat()
1577 bsize = ch->blk * 4 / ENVY24HT_PLAY_BUFUNIT; in envy24htchan_setformat()
1579 bsize = ch->blk * 4 / ENVY24HT_REC_BUFUNIT; in envy24htchan_setformat()
1580 bsize *= ch->unit; in envy24htchan_setformat()
1581 bcnt = ch->size / bsize; in envy24htchan_setformat()
1582 sndbuf_resize(ch->buffer, bcnt, bsize); in envy24htchan_setformat()
1584 snd_mtxunlock(sc->lock); in envy24htchan_setformat()
1587 device_printf(sc->dev, "envy24htchan_setformat(): return 0x%08x\n", 0); in envy24htchan_setformat()
1608 device_printf(ch->parent->dev, "envy24htchan_setspeed(obj, data, %d)\n", speed); in envy24htchan_setspeed()
1612 if (abs(val - speed) < abs(prev - speed)) in envy24htchan_setspeed()
1617 ch->speed = prev; in envy24htchan_setspeed()
1620 device_printf(ch->parent->dev, "envy24htchan_setspeed(): return %d\n", ch->speed); in envy24htchan_setspeed()
1622 return ch->speed; in envy24htchan_setspeed()
1629 /* struct sc_info *sc = ch->parent; */ in envy24htchan_setblocksize()
1634 device_printf(sc->dev, "envy24htchan_setblocksize(obj, data, %d)\n", blocksize); in envy24htchan_setblocksize()
1637 /* snd_mtxlock(sc->lock); */ in envy24htchan_setblocksize()
1638 for (size = ch->size / 2; size > 0; size /= 2) { in envy24htchan_setblocksize()
1639 if (abs(size - blocksize) < abs(prev - blocksize)) in envy24htchan_setblocksize()
1645 ch->blk = prev / ch->unit; in envy24htchan_setblocksize()
1646 if (ch->dir == PCMDIR_PLAY) in envy24htchan_setblocksize()
1647 ch->blk *= ENVY24HT_PLAY_BUFUNIT / 4; in envy24htchan_setblocksize()
1649 ch->blk *= ENVY24HT_REC_BUFUNIT / 4; in envy24htchan_setblocksize()
1651 /* ch->size = ch->unit * ENVY24HT_SAMPLE_NUM; */ in envy24htchan_setblocksize()
1652 if (ch->dir == PCMDIR_PLAY) in envy24htchan_setblocksize()
1653 bsize = ch->blk * 4 / ENVY24HT_PLAY_BUFUNIT; in envy24htchan_setblocksize()
1655 bsize = ch->blk * 4 / ENVY24HT_REC_BUFUNIT; in envy24htchan_setblocksize()
1656 bsize *= ch->unit; in envy24htchan_setblocksize()
1657 bcnt = ch->size / bsize; in envy24htchan_setblocksize()
1658 sndbuf_resize(ch->buffer, bcnt, bsize); in envy24htchan_setblocksize()
1659 /* snd_mtxunlock(sc->lock); */ in envy24htchan_setblocksize()
1662 device_printf(sc->dev, "envy24htchan_setblocksize(): return %d\n", prev); in envy24htchan_setblocksize()
1672 struct sc_info *sc = ch->parent; in envy24htchan_trigger()
1679 device_printf(sc->dev, "envy24htchan_trigger(obj, data, %d)\n", go); in envy24htchan_trigger()
1681 snd_mtxlock(sc->lock); in envy24htchan_trigger()
1682 if (ch->dir == PCMDIR_PLAY) in envy24htchan_trigger()
1689 device_printf(sc->dev, "envy24htchan_trigger(): start\n"); in envy24htchan_trigger()
1692 if (sc->run[0] == 0 && sc->run[1] == 0) { in envy24htchan_trigger()
1693 sc->speed = envy24ht_setspeed(sc, ch->speed); in envy24htchan_trigger()
1694 sc->caps[0].minspeed = sc->caps[0].maxspeed = sc->speed; in envy24htchan_trigger()
1695 sc->caps[1].minspeed = sc->caps[1].maxspeed = sc->speed; in envy24htchan_trigger()
1697 else if (ch->speed != 0 && ch->speed != sc->speed) { in envy24htchan_trigger()
1698 error = -1; in envy24htchan_trigger()
1701 if (ch->speed == 0) in envy24htchan_trigger()
1702 ch->channel->speed = sc->speed; in envy24htchan_trigger()
1704 sc->run[slot]++; in envy24htchan_trigger()
1705 if (sc->run[slot] == 1) { in envy24htchan_trigger()
1707 ch->offset = 0; in envy24htchan_trigger()
1708 sc->blk[slot] = ch->blk; in envy24htchan_trigger()
1711 ptr = envy24ht_gethwptr(sc, ch->dir); in envy24htchan_trigger()
1712 ch->offset = ((ptr / ch->blk + 1) * ch->blk % in envy24htchan_trigger()
1713 (ch->size / 4)) * 4 / ch->unit; in envy24htchan_trigger()
1714 if (ch->blk < sc->blk[slot]) in envy24htchan_trigger()
1715 sc->blk[slot] = ch->blk; in envy24htchan_trigger()
1717 if (ch->dir == PCMDIR_PLAY) { in envy24htchan_trigger()
1718 ch->emldma(ch); in envy24htchan_trigger()
1719 envy24ht_setvolume(sc, ch->num); in envy24htchan_trigger()
1721 envy24ht_updintr(sc, ch->dir); in envy24htchan_trigger()
1722 if (sc->run[slot] == 1) in envy24htchan_trigger()
1723 envy24ht_start(sc, ch->dir); in envy24htchan_trigger()
1724 ch->run = 1; in envy24htchan_trigger()
1728 device_printf(sc->dev, "envy24htchan_trigger(): emldmawr\n"); in envy24htchan_trigger()
1730 if (ch->run != 1) { in envy24htchan_trigger()
1731 error = -1; in envy24htchan_trigger()
1734 ch->emldma(ch); in envy24htchan_trigger()
1738 device_printf(sc->dev, "envy24htchan_trigger(): emldmard\n"); in envy24htchan_trigger()
1740 if (ch->run != 1) { in envy24htchan_trigger()
1741 error = -1; in envy24htchan_trigger()
1744 ch->emldma(ch); in envy24htchan_trigger()
1747 if (ch->run) { in envy24htchan_trigger()
1749 device_printf(sc->dev, "envy24htchan_trigger(): abort\n"); in envy24htchan_trigger()
1751 ch->run = 0; in envy24htchan_trigger()
1752 sc->run[slot]--; in envy24htchan_trigger()
1753 if (ch->dir == PCMDIR_PLAY) in envy24htchan_trigger()
1754 envy24ht_mutevolume(sc, ch->num); in envy24htchan_trigger()
1755 if (sc->run[slot] == 0) { in envy24htchan_trigger()
1756 envy24ht_stop(sc, ch->dir); in envy24htchan_trigger()
1757 sc->intr[slot] = 0; in envy24htchan_trigger()
1759 /* else if (ch->blk == sc->blk[slot]) { in envy24htchan_trigger()
1760 sc->blk[slot] = ENVY24HT_SAMPLE_NUM / 2; in envy24htchan_trigger()
1762 if (sc->chan[i].dir == ch->dir && in envy24htchan_trigger()
1763 sc->chan[i].run == 1 && in envy24htchan_trigger()
1764 sc->chan[i].blk < sc->blk[slot]) in envy24htchan_trigger()
1765 sc->blk[slot] = sc->chan[i].blk; in envy24htchan_trigger()
1767 if (ch->blk != sc->blk[slot]) in envy24htchan_trigger()
1768 envy24ht_updintr(sc, ch->dir); in envy24htchan_trigger()
1774 snd_mtxunlock(sc->lock); in envy24htchan_trigger()
1782 struct sc_info *sc = ch->parent; in envy24htchan_getptr()
1786 device_printf(sc->dev, "envy24htchan_getptr()\n"); in envy24htchan_getptr()
1788 snd_mtxlock(sc->lock); in envy24htchan_getptr()
1789 ptr = envy24ht_gethwptr(sc, ch->dir); in envy24htchan_getptr()
1790 rtn = ptr * ch->unit; in envy24htchan_getptr()
1791 snd_mtxunlock(sc->lock); in envy24htchan_getptr()
1794 device_printf(sc->dev, "envy24htchan_getptr(): return %d\n", in envy24htchan_getptr()
1804 struct sc_info *sc = ch->parent; in envy24htchan_getcaps()
1808 device_printf(sc->dev, "envy24htchan_getcaps()\n"); in envy24htchan_getcaps()
1810 snd_mtxlock(sc->lock); in envy24htchan_getcaps()
1811 if (ch->dir == PCMDIR_PLAY) { in envy24htchan_getcaps()
1812 if (sc->run[0] == 0) in envy24htchan_getcaps()
1815 rtn = &sc->caps[0]; in envy24htchan_getcaps()
1818 if (sc->run[1] == 0) in envy24htchan_getcaps()
1821 rtn = &sc->caps[1]; in envy24htchan_getcaps()
1823 snd_mtxunlock(sc->lock); in envy24htchan_getcaps()
1841 /* -------------------------------------------------------------------- */
1851 device_printf(sc->dev, "envy24htmixer_init()\n"); in envy24htmixer_init()
1854 return -1; in envy24htmixer_init()
1857 snd_mtxlock(sc->lock); in envy24htmixer_init()
1862 pcm_setflags(sc->dev, pcm_getflags(sc->dev) | SD_F_SOFTPCMVOL); in envy24htmixer_init()
1867 snd_mtxunlock(sc->lock); in envy24htmixer_init()
1878 return -1; in envy24htmixer_reinit()
1880 device_printf(sc->dev, "envy24htmixer_reinit()\n"); in envy24htmixer_reinit()
1892 return -1; in envy24htmixer_uninit()
1894 device_printf(sc->dev, "envy24htmixer_uninit()\n"); in envy24htmixer_uninit()
1909 return -1; in envy24htmixer_set()
1910 if (dev == 0 && sc->cfg->codec->setvolume == NULL) in envy24htmixer_set()
1911 return -1; in envy24htmixer_set()
1912 if (dev != 0 && ch == -1) in envy24htmixer_set()
1913 return -1; in envy24htmixer_set()
1916 device_printf(sc->dev, "envy24htmixer_set(m, %d, %d, %d)\n", in envy24htmixer_set()
1920 snd_mtxlock(sc->lock); in envy24htmixer_set()
1922 for (i = 0; i < sc->dacn; i++) { in envy24htmixer_set()
1923 sc->cfg->codec->setvolume(sc->dac[i], PCMDIR_PLAY, left, right); in envy24htmixer_set()
1928 if ((sc->left[hwch] = 100 - left) > ENVY24HT_VOL_MIN) in envy24htmixer_set()
1929 sc->left[hwch] = ENVY24HT_VOL_MUTE; in envy24htmixer_set()
1930 if ((sc->right[hwch] = 100 - right) > ENVY24HT_VOL_MIN) in envy24htmixer_set()
1931 sc->right[hwch] = ENVY24HT_VOL_MUTE; in envy24htmixer_set()
1934 if (hwch > ENVY24HT_CHAN_PLAY_SPDIF || sc->chan[ch].run) in envy24htmixer_set()
1937 snd_mtxunlock(sc->lock); in envy24htmixer_set()
1948 device_printf(sc->dev, "envy24htmixer_setrecsrc(m, %d)\n", src); in envy24htmixer_setrecsrc()
1952 sc->src = ch; in envy24htmixer_setrecsrc()
1966 /* -------------------------------------------------------------------- */
1978 device_printf(sc->dev, "envy24ht_intr()\n"); in envy24ht_intr()
1980 snd_mtxlock(sc->lock); in envy24ht_intr()
1983 device_printf(sc->dev, "envy24ht_intr(): play\n"); in envy24ht_intr()
1985 dsize = sc->psize / 4; in envy24ht_intr()
1986 ptr = dsize - envy24ht_rdmt(sc, ENVY24HT_MT_PCNT, 2) - 1; in envy24ht_intr()
1988 device_printf(sc->dev, "envy24ht_intr(): ptr = %d-->", ptr); in envy24ht_intr()
1990 ptr -= ptr % sc->blk[0]; in envy24ht_intr()
1991 feed = (ptr + dsize - sc->intr[0]) % dsize; in envy24ht_intr()
1993 printf("%d intr = %d feed = %d\n", ptr, sc->intr[0], feed); in envy24ht_intr()
1996 ch = &sc->chan[i]; in envy24ht_intr()
1998 if (ch->run) in envy24ht_intr()
1999 device_printf(sc->dev, "envy24ht_intr(): chan[%d].blk = %d\n", i, ch->blk); in envy24ht_intr()
2001 if (ch->run && ch->blk <= feed) { in envy24ht_intr()
2002 snd_mtxunlock(sc->lock); in envy24ht_intr()
2003 chn_intr(ch->channel); in envy24ht_intr()
2004 snd_mtxlock(sc->lock); in envy24ht_intr()
2007 sc->intr[0] = ptr; in envy24ht_intr()
2012 device_printf(sc->dev, "envy24ht_intr(): rec\n"); in envy24ht_intr()
2014 dsize = sc->rsize / 4; in envy24ht_intr()
2015 ptr = dsize - envy24ht_rdmt(sc, ENVY24HT_MT_RCNT, 2) - 1; in envy24ht_intr()
2016 ptr -= ptr % sc->blk[1]; in envy24ht_intr()
2017 feed = (ptr + dsize - sc->intr[1]) % dsize; in envy24ht_intr()
2019 ch = &sc->chan[i]; in envy24ht_intr()
2020 if (ch->run && ch->blk <= feed) { in envy24ht_intr()
2021 snd_mtxunlock(sc->lock); in envy24ht_intr()
2022 chn_intr(ch->channel); in envy24ht_intr()
2023 snd_mtxlock(sc->lock); in envy24ht_intr()
2026 sc->intr[1] = ptr; in envy24ht_intr()
2029 snd_mtxunlock(sc->lock); in envy24ht_intr()
2076 sc->paddr = segs->ds_addr; in envy24ht_dmapsetmap()
2078 device_printf(sc->dev, "envy24ht_dmapsetmap()\n"); in envy24ht_dmapsetmap()
2081 (unsigned long)segs->ds_addr, in envy24ht_dmapsetmap()
2082 (unsigned long)segs->ds_len); in envy24ht_dmapsetmap()
2085 envy24ht_wrmt(sc, ENVY24HT_MT_PADDR, (uint32_t)segs->ds_addr, 4); in envy24ht_dmapsetmap()
2086 envy24ht_wrmt(sc, ENVY24HT_MT_PCNT, (uint32_t)(segs->ds_len / 4 - 1), 2); in envy24ht_dmapsetmap()
2094 sc->raddr = segs->ds_addr; in envy24ht_dmarsetmap()
2096 device_printf(sc->dev, "envy24ht_dmarsetmap()\n"); in envy24ht_dmarsetmap()
2099 (unsigned long)segs->ds_addr, in envy24ht_dmarsetmap()
2100 (unsigned long)segs->ds_len); in envy24ht_dmarsetmap()
2103 envy24ht_wrmt(sc, ENVY24HT_MT_RADDR, (uint32_t)segs->ds_addr, 4); in envy24ht_dmarsetmap()
2104 envy24ht_wrmt(sc, ENVY24HT_MT_RCNT, (uint32_t)(segs->ds_len / 4 - 1), 2); in envy24ht_dmarsetmap()
2111 device_printf(sc->dev, "envy24ht_dmafree():"); in envy24ht_dmafree()
2112 printf(" sc->raddr(0x%08x)", (u_int32_t)sc->raddr); in envy24ht_dmafree()
2113 printf(" sc->paddr(0x%08x)", (u_int32_t)sc->paddr); in envy24ht_dmafree()
2114 if (sc->rbuf) printf(" sc->rbuf(0x%08x)", (u_int32_t)sc->rbuf); in envy24ht_dmafree()
2115 else printf(" sc->rbuf(null)"); in envy24ht_dmafree()
2116 if (sc->pbuf) printf(" sc->pbuf(0x%08x)\n", (u_int32_t)sc->pbuf); in envy24ht_dmafree()
2117 else printf(" sc->pbuf(null)\n"); in envy24ht_dmafree()
2120 if (sc->raddr) in envy24ht_dmafree()
2121 bus_dmamap_unload(sc->dmat, sc->rmap); in envy24ht_dmafree()
2122 if (sc->paddr) in envy24ht_dmafree()
2123 bus_dmamap_unload(sc->dmat, sc->pmap); in envy24ht_dmafree()
2124 if (sc->rbuf) in envy24ht_dmafree()
2125 bus_dmamem_free(sc->dmat, sc->rbuf, sc->rmap); in envy24ht_dmafree()
2126 if (sc->pbuf) in envy24ht_dmafree()
2127 bus_dmamem_free(sc->dmat, sc->pbuf, sc->pmap); in envy24ht_dmafree()
2129 bus_dmamap_unload(sc->dmat, sc->rmap); in envy24ht_dmafree()
2130 bus_dmamap_unload(sc->dmat, sc->pmap); in envy24ht_dmafree()
2131 bus_dmamem_free(sc->dmat, sc->rbuf, sc->rmap); in envy24ht_dmafree()
2132 bus_dmamem_free(sc->dmat, sc->pbuf, sc->pmap); in envy24ht_dmafree()
2135 sc->raddr = sc->paddr = 0; in envy24ht_dmafree()
2136 sc->pbuf = NULL; in envy24ht_dmafree()
2137 sc->rbuf = NULL; in envy24ht_dmafree()
2147 device_printf(sc->dev, "envy24ht_dmainit()\n"); in envy24ht_dmainit()
2150 sc->psize = ENVY24HT_PLAY_BUFUNIT * ENVY24HT_SAMPLE_NUM; in envy24ht_dmainit()
2151 sc->rsize = ENVY24HT_REC_BUFUNIT * ENVY24HT_SAMPLE_NUM; in envy24ht_dmainit()
2152 sc->pbuf = NULL; in envy24ht_dmainit()
2153 sc->rbuf = NULL; in envy24ht_dmainit()
2154 sc->paddr = sc->raddr = 0; in envy24ht_dmainit()
2155 sc->blk[0] = sc->blk[1] = 0; in envy24ht_dmainit()
2157 /* allocate DMA buffer */ in envy24ht_dmainit()
2159 device_printf(sc->dev, "envy24ht_dmainit(): bus_dmamem_alloc(): sc->pbuf\n"); in envy24ht_dmainit()
2161 if (bus_dmamem_alloc(sc->dmat, (void **)&sc->pbuf, BUS_DMA_NOWAIT, &sc->pmap)) in envy24ht_dmainit()
2164 device_printf(sc->dev, "envy24ht_dmainit(): bus_dmamem_alloc(): sc->rbuf\n"); in envy24ht_dmainit()
2166 if (bus_dmamem_alloc(sc->dmat, (void **)&sc->rbuf, BUS_DMA_NOWAIT, &sc->rmap)) in envy24ht_dmainit()
2169 device_printf(sc->dev, "envy24ht_dmainit(): bus_dmamem_load(): sc->pmap\n"); in envy24ht_dmainit()
2171 …if (bus_dmamap_load(sc->dmat, sc->pmap, sc->pbuf, sc->psize, envy24ht_dmapsetmap, sc, BUS_DMA_NOWA… in envy24ht_dmainit()
2174 device_printf(sc->dev, "envy24ht_dmainit(): bus_dmamem_load(): sc->rmap\n"); in envy24ht_dmainit()
2176 …if (bus_dmamap_load(sc->dmat, sc->rmap, sc->rbuf, sc->rsize, envy24ht_dmarsetmap, sc, BUS_DMA_NOWA… in envy24ht_dmainit()
2178 bzero(sc->pbuf, sc->psize); in envy24ht_dmainit()
2179 bzero(sc->rbuf, sc->rsize); in envy24ht_dmainit()
2190 device_printf(sc->dev, "system configuration\n"); in envy24ht_putcfg()
2192 sc->cfg->subvendor, sc->cfg->subdevice); in envy24ht_putcfg()
2194 switch (sc->cfg->scfg & ENVY24HT_CCSM_SCFG_XIN2) { in envy24ht_putcfg()
2207 printf(" MPU-401 UART(s) #: "); in envy24ht_putcfg()
2208 if (sc->cfg->scfg & ENVY24HT_CCSM_SCFG_MPU) in envy24ht_putcfg()
2212 switch (sc->adcn) { in envy24ht_putcfg()
2216 printf("%d\n", sc->adcn); in envy24ht_putcfg()
2227 printf("%d\n", sc->dacn); in envy24ht_putcfg()
2228 printf(" Multi-track converter type: "); in envy24ht_putcfg()
2229 if ((sc->cfg->acl & ENVY24HT_CCSM_ACL_MTC) == 0) { in envy24ht_putcfg()
2231 if (sc->cfg->acl & ENVY24HT_CCSM_ACL_OMODE) in envy24ht_putcfg()
2239 if (sc->cfg->i2s & ENVY24HT_CCSM_I2S_VOL) in envy24ht_putcfg()
2241 if (sc->cfg->i2s & ENVY24HT_CCSM_I2S_192KHZ) in envy24ht_putcfg()
2244 if (sc->cfg->i2s & ENVY24HT_CCSM_I2S_96KHZ) in envy24ht_putcfg()
2248 switch (sc->cfg->i2s & ENVY24HT_CCSM_I2S_RES) { in envy24ht_putcfg()
2262 printf("ID#0x%x)\n", sc->cfg->i2s & ENVY24HT_CCSM_I2S_ID); in envy24ht_putcfg()
2265 if (sc->cfg->spdif & ENVY24HT_CCSM_SPDIF_IN) in envy24ht_putcfg()
2269 if (sc->cfg->spdif & ENVY24HT_CCSM_SPDIF_OUT) in envy24ht_putcfg()
2273 if (sc->cfg->spdif & (ENVY24HT_CCSM_SPDIF_IN | ENVY24HT_CCSM_SPDIF_OUT)) in envy24ht_putcfg()
2274 printf("ID# 0x%02x\n", (sc->cfg->spdif & ENVY24HT_CCSM_SPDIF_ID) >> 2); in envy24ht_putcfg()
2276 sc->cfg->gpiomask, sc->cfg->gpiodir, sc->cfg->gpiostate); in envy24ht_putcfg()
2290 device_printf(sc->dev, "envy24ht_init()\n"); in envy24ht_init()
2301 data = pci_read_config(sc->dev, PCIR_LAC, 2); in envy24ht_init()
2303 pci_write_config(sc->dev, PCIR_LAC, data, 2); in envy24ht_init()
2307 sc->cfg = NULL; in envy24ht_init()
2310 sv = pci_get_subvendor(sc->dev); in envy24ht_init()
2311 sd = pci_get_subdevice(sc->dev); in envy24ht_init()
2314 device_printf(sc->dev, "Set configuration from table\n"); in envy24ht_init()
2316 sc->cfg = &cfg_table[i]; in envy24ht_init()
2320 if (sc->cfg == NULL) { in envy24ht_init()
2322 sc->cfg = envy24ht_rom2cfg(sc); in envy24ht_init()
2324 sc->adcn = ((sc->cfg->scfg & ENVY24HT_CCSM_SCFG_ADC) >> 2) + 1; /* need to be fixed */ in envy24ht_init()
2325 sc->dacn = (sc->cfg->scfg & ENVY24HT_CCSM_SCFG_DAC) + 1; in envy24ht_init()
2332 envy24ht_wrcs(sc, ENVY24HT_CCS_SCFG, sc->cfg->scfg, 1); in envy24ht_init()
2333 envy24ht_wrcs(sc, ENVY24HT_CCS_ACL, sc->cfg->acl, 1); in envy24ht_init()
2334 envy24ht_wrcs(sc, ENVY24HT_CCS_I2S, sc->cfg->i2s, 1); in envy24ht_init()
2335 envy24ht_wrcs(sc, ENVY24HT_CCS_SPDIF, sc->cfg->spdif, 1); in envy24ht_init()
2336 envy24ht_gpiosetmask(sc, sc->cfg->gpiomask); in envy24ht_init()
2337 envy24ht_gpiosetdir(sc, sc->cfg->gpiodir); in envy24ht_init()
2338 envy24ht_gpiowr(sc, sc->cfg->gpiostate); in envy24ht_init()
2340 if ((sc->cfg->subvendor == 0x3031) && (sc->cfg->subdevice == 0x4553)) { in envy24ht_init()
2346 for (i = 0; i < sc->adcn; i++) { in envy24ht_init()
2347 sc->adc[i] = sc->cfg->codec->create(sc->dev, sc, PCMDIR_REC, i); in envy24ht_init()
2348 sc->cfg->codec->init(sc->adc[i]); in envy24ht_init()
2350 for (i = 0; i < sc->dacn; i++) { in envy24ht_init()
2351 sc->dac[i] = sc->cfg->codec->create(sc->dev, sc, PCMDIR_PLAY, i); in envy24ht_init()
2352 sc->cfg->codec->init(sc->dac[i]); in envy24ht_init()
2355 /* initialize DMA buffer */ in envy24ht_init()
2357 device_printf(sc->dev, "envy24ht_init(): initialize DMA buffer\n"); in envy24ht_init()
2363 sc->run[0] = sc->run[1] = 0; in envy24ht_init()
2364 sc->intr[0] = sc->intr[1] = 0; in envy24ht_init()
2365 sc->speed = 0; in envy24ht_init()
2366 sc->caps[0].fmtlist = envy24ht_playfmt; in envy24ht_init()
2367 sc->caps[1].fmtlist = envy24ht_recfmt; in envy24ht_init()
2369 /* set channel router */ in envy24ht_init()
2381 device_printf(sc->dev, "envy24ht_init(): CCS_IMASK-->0x%02x\n", data); in envy24ht_init()
2391 sc->csid = PCIR_CCS; in envy24ht_alloc_resource()
2392 sc->cs = bus_alloc_resource_any(sc->dev, SYS_RES_IOPORT, in envy24ht_alloc_resource()
2393 &sc->csid, RF_ACTIVE); in envy24ht_alloc_resource()
2394 sc->mtid = ENVY24HT_PCIR_MT; in envy24ht_alloc_resource()
2395 sc->mt = bus_alloc_resource_any(sc->dev, SYS_RES_IOPORT, in envy24ht_alloc_resource()
2396 &sc->mtid, RF_ACTIVE); in envy24ht_alloc_resource()
2397 if (!sc->cs || !sc->mt) { in envy24ht_alloc_resource()
2398 device_printf(sc->dev, "unable to map IO port space\n"); in envy24ht_alloc_resource()
2401 sc->cst = rman_get_bustag(sc->cs); in envy24ht_alloc_resource()
2402 sc->csh = rman_get_bushandle(sc->cs); in envy24ht_alloc_resource()
2403 sc->mtt = rman_get_bustag(sc->mt); in envy24ht_alloc_resource()
2404 sc->mth = rman_get_bushandle(sc->mt); in envy24ht_alloc_resource()
2406 device_printf(sc->dev, in envy24ht_alloc_resource()
2408 pci_read_config(sc->dev, PCIR_CCS, 4), in envy24ht_alloc_resource()
2409 pci_read_config(sc->dev, PCIR_MT, 4)); in envy24ht_alloc_resource()
2413 sc->irqid = 0; in envy24ht_alloc_resource()
2414 sc->irq = bus_alloc_resource_any(sc->dev, SYS_RES_IRQ, &sc->irqid, in envy24ht_alloc_resource()
2416 if (!sc->irq || in envy24ht_alloc_resource()
2417 snd_setup_intr(sc->dev, sc->irq, INTR_MPSAFE, envy24ht_intr, sc, &sc->ih)) { in envy24ht_alloc_resource()
2418 device_printf(sc->dev, "unable to map interrupt\n"); in envy24ht_alloc_resource()
2422 /* allocate DMA resource */ in envy24ht_alloc_resource()
2423 if (bus_dma_tag_create(/*parent*/bus_get_dma_tag(sc->dev), in envy24ht_alloc_resource()
2432 /*lockarg*/NULL, &sc->dmat) != 0) { in envy24ht_alloc_resource()
2433 device_printf(sc->dev, "unable to create dma tag\n"); in envy24ht_alloc_resource()
2458 sc->lock = snd_mtxcreate(device_get_nameunit(dev), in envy24ht_pci_attach()
2460 sc->dev = dev; in envy24ht_pci_attach()
2484 sc->chnum = 0; in envy24ht_pci_attach()
2487 sc->chnum++; in envy24ht_pci_attach()
2489 for (i = 0; i < 2 + sc->adcn; i++) { in envy24ht_pci_attach()
2491 sc->chnum++; in envy24ht_pci_attach()
2497 rman_get_start(sc->cs), in envy24ht_pci_attach()
2498 rman_get_end(sc->cs) - rman_get_start(sc->cs) + 1, in envy24ht_pci_attach()
2499 rman_get_start(sc->mt), in envy24ht_pci_attach()
2500 rman_get_end(sc->mt) - rman_get_start(sc->mt) + 1, in envy24ht_pci_attach()
2501 rman_get_start(sc->irq), in envy24ht_pci_attach()
2509 if (sc->ih) in envy24ht_pci_attach()
2510 bus_teardown_intr(dev, sc->irq, sc->ih); in envy24ht_pci_attach()
2511 if (sc->irq) in envy24ht_pci_attach()
2512 bus_release_resource(dev, SYS_RES_IRQ, sc->irqid, sc->irq); in envy24ht_pci_attach()
2514 if (sc->dmat) in envy24ht_pci_attach()
2515 bus_dma_tag_destroy(sc->dmat); in envy24ht_pci_attach()
2516 if (sc->cfg->codec->destroy != NULL) { in envy24ht_pci_attach()
2517 for (i = 0; i < sc->adcn; i++) in envy24ht_pci_attach()
2518 sc->cfg->codec->destroy(sc->adc[i]); in envy24ht_pci_attach()
2519 for (i = 0; i < sc->dacn; i++) in envy24ht_pci_attach()
2520 sc->cfg->codec->destroy(sc->dac[i]); in envy24ht_pci_attach()
2522 envy24ht_cfgfree(sc->cfg); in envy24ht_pci_attach()
2523 if (sc->cs) in envy24ht_pci_attach()
2524 bus_release_resource(dev, SYS_RES_IOPORT, sc->csid, sc->cs); in envy24ht_pci_attach()
2525 if (sc->mt) in envy24ht_pci_attach()
2526 bus_release_resource(dev, SYS_RES_IOPORT, sc->mtid, sc->mt); in envy24ht_pci_attach()
2527 if (sc->lock) in envy24ht_pci_attach()
2528 snd_mtxfree(sc->lock); in envy24ht_pci_attach()
2551 if (sc->cfg->codec->destroy != NULL) { in envy24ht_pci_detach()
2552 for (i = 0; i < sc->adcn; i++) in envy24ht_pci_detach()
2553 sc->cfg->codec->destroy(sc->adc[i]); in envy24ht_pci_detach()
2554 for (i = 0; i < sc->dacn; i++) in envy24ht_pci_detach()
2555 sc->cfg->codec->destroy(sc->dac[i]); in envy24ht_pci_detach()
2557 envy24ht_cfgfree(sc->cfg); in envy24ht_pci_detach()
2558 bus_dma_tag_destroy(sc->dmat); in envy24ht_pci_detach()
2559 bus_teardown_intr(dev, sc->irq, sc->ih); in envy24ht_pci_detach()
2560 bus_release_resource(dev, SYS_RES_IRQ, sc->irqid, sc->irq); in envy24ht_pci_detach()
2561 bus_release_resource(dev, SYS_RES_IOPORT, sc->csid, sc->cs); in envy24ht_pci_detach()
2562 bus_release_resource(dev, SYS_RES_IOPORT, sc->mtid, sc->mt); in envy24ht_pci_detach()
2563 snd_mtxfree(sc->lock); in envy24ht_pci_detach()