2 * Copyright (c) 2001 Orion Hodson <oho@acm.org>
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright
11 * notice, this list of conditions and the following disclaimer in the
12 * documentation and/or other materials provided with the distribution.
14 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
15 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
16 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
17 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
18 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
19 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
20 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
21 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHERIN CONTRACT, STRICT
22 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
23 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THEPOSSIBILITY OF
28 * als4000.c - driver for the Avance Logic ALS 4000 chipset.
30 * The ALS4000 is a effectively an SB16 with a PCI interface.
32 * This driver derives from ALS4000a.PDF, Bart Hartgers alsa driver, and
33 * SB16 register descriptions.
36 #include <dev/sound/pcm/sound.h>
37 #include <dev/sound/isa/sb.h>
38 #include <dev/sound/pci/als4000.h>
40 #include <pci/pcireg.h>
41 #include <pci/pcivar.h>
45 SND_DECLARE_FILE("$FreeBSD: src/sys/dev/sound/pci/als4000.c,v 1.2.2.5 2002/04/22 15:49:31 cg Exp $");
47 /* Debugging macro's */
50 #define DEB(x) /* x */
53 #define ALS_DEFAULT_BUFSZ 16384
55 /* ------------------------------------------------------------------------- */
61 struct sc_info *parent;
62 struct pcm_channel *channel;
63 struct snd_dbuf *buffer;
64 u_int32_t format, speed, phys_buf, bps;
65 u_int32_t dma_active:1, dma_was_active:1;
66 u_int8_t gcr_fifo_status;
73 bus_space_handle_t sh;
74 bus_dma_tag_t parent_dmat;
75 struct resource *reg, *irq;
80 struct sc_chinfo pch, rch;
85 static u_int32_t als_format[] = {
87 AFMT_STEREO | AFMT_U8,
89 AFMT_STEREO | AFMT_S16_LE,
93 static struct pcmchan_caps als_caps = { 4000, 48000, als_format, 0 };
95 /* ------------------------------------------------------------------------- */
96 /* Register Utilities */
99 als_gcr_rd(struct sc_info *sc, int index)
101 bus_space_write_1(sc->st, sc->sh, ALS_GCR_INDEX, index);
102 return bus_space_read_4(sc->st, sc->sh, ALS_GCR_DATA);
106 als_gcr_wr(struct sc_info *sc, int index, int data)
108 bus_space_write_1(sc->st, sc->sh, ALS_GCR_INDEX, index);
109 bus_space_write_4(sc->st, sc->sh, ALS_GCR_DATA, data);
113 als_intr_rd(struct sc_info *sc)
115 return bus_space_read_1(sc->st, sc->sh, ALS_SB_MPU_IRQ);
119 als_intr_wr(struct sc_info *sc, u_int8_t data)
121 bus_space_write_1(sc->st, sc->sh, ALS_SB_MPU_IRQ, data);
125 als_mix_rd(struct sc_info *sc, u_int8_t index)
127 bus_space_write_1(sc->st, sc->sh, ALS_MIXER_INDEX, index);
128 return bus_space_read_1(sc->st, sc->sh, ALS_MIXER_DATA);
132 als_mix_wr(struct sc_info *sc, u_int8_t index, u_int8_t data)
134 bus_space_write_1(sc->st, sc->sh, ALS_MIXER_INDEX, index);
135 bus_space_write_1(sc->st, sc->sh, ALS_MIXER_DATA, data);
139 als_esp_wr(struct sc_info *sc, u_int8_t data)
145 v = bus_space_read_1(sc->st, sc->sh, ALS_ESP_WR_STATUS);
149 } while (--tries != 0);
152 device_printf(sc->dev, "als_esp_wr timeout");
154 bus_space_write_1(sc->st, sc->sh, ALS_ESP_WR_DATA, data);
158 als_esp_reset(struct sc_info *sc)
160 u_int32_t tries, u, v;
162 bus_space_write_1(sc->st, sc->sh, ALS_ESP_RST, 1);
164 bus_space_write_1(sc->st, sc->sh, ALS_ESP_RST, 0);
169 u = bus_space_read_1(sc->st, sc->sh, ALS_ESP_RD_STATUS8);
171 v = bus_space_read_1(sc->st, sc->sh, ALS_ESP_RD_DATA);
178 } while (--tries != 0);
181 device_printf(sc->dev, "als_esp_reset timeout");
186 als_ack_read(struct sc_info *sc, u_int8_t addr)
188 u_int8_t r = bus_space_read_1(sc->st, sc->sh, addr);
192 /* ------------------------------------------------------------------------- */
193 /* Common pcm channel implementation */
196 alschan_init(kobj_t obj, void *devinfo,
197 struct snd_dbuf *b, struct pcm_channel *c, int dir)
199 struct sc_info *sc = devinfo;
200 struct sc_chinfo *ch;
202 if (dir == PCMDIR_PLAY) {
204 ch->gcr_fifo_status = ALS_GCR_FIFO0_STATUS;
207 ch->gcr_fifo_status = ALS_GCR_FIFO1_STATUS;
213 ch->format = AFMT_U8;
214 ch->speed = DSP_DEFAULT_SPEED;
216 if (sndbuf_alloc(ch->buffer, sc->parent_dmat, sc->bufsz) != 0) {
223 alschan_setformat(kobj_t obj, void *data, u_int32_t format)
225 struct sc_chinfo *ch = data;
232 alschan_setspeed(kobj_t obj, void *data, u_int32_t speed)
234 struct sc_chinfo *ch = data, *other;
235 struct sc_info *sc = ch->parent;
237 other = (ch->dir == PCMDIR_PLAY) ? &sc->rch : &sc->pch;
239 /* Deny request if other dma channel is active */
240 if (other->dma_active) {
241 ch->speed = other->speed;
250 alschan_setblocksize(kobj_t obj, void *data, u_int32_t blocksize)
252 struct sc_chinfo *ch = data;
253 struct sc_info *sc = ch->parent;
255 if (blocksize > sc->bufsz / 2) {
256 blocksize = sc->bufsz / 2;
258 sndbuf_resize(ch->buffer, 2, blocksize);
263 alschan_getptr(kobj_t obj, void *data)
265 struct sc_chinfo *ch = data;
268 pos = als_gcr_rd(ch->parent, ch->gcr_fifo_status) & 0xffff;
269 sz = sndbuf_getsize(ch->buffer);
270 return (2 * sz - pos - 1) % sz;
273 static struct pcmchan_caps*
274 alschan_getcaps(kobj_t obj, void *data)
280 als_set_speed(struct sc_chinfo *ch)
282 struct sc_info *sc = ch->parent;
283 struct sc_chinfo *other;
285 other = (ch->dir == PCMDIR_PLAY) ? &sc->rch : &sc->pch;
286 if (other->dma_active == 0) {
287 als_esp_wr(sc, ALS_ESP_SAMPLE_RATE);
288 als_esp_wr(sc, ch->speed >> 8);
289 als_esp_wr(sc, ch->speed & 0xff);
291 DEB(printf("speed locked at %d (tried %d)\n",
292 other->speed, ch->speed));
296 /* ------------------------------------------------------------------------- */
297 /* Playback channel implementation */
299 #define ALS_8BIT_CMD(x, y) { (x), (y), DSP_DMA8, DSP_CMD_DMAPAUSE_8 }
300 #define ALS_16BIT_CMD(x, y) { (x), (y), DSP_DMA16, DSP_CMD_DMAPAUSE_16 }
302 struct playback_command {
303 u_int32_t pcm_format; /* newpcm format */
304 u_int8_t format_val; /* sb16 format value */
305 u_int8_t dma_prog; /* sb16 dma program */
306 u_int8_t dma_stop; /* sb16 stop register */
307 } static const playback_cmds[] = {
308 ALS_8BIT_CMD(AFMT_U8, DSP_MODE_U8MONO),
309 ALS_8BIT_CMD(AFMT_U8 | AFMT_STEREO, DSP_MODE_U8STEREO),
310 ALS_16BIT_CMD(AFMT_S16_LE, DSP_MODE_S16MONO),
311 ALS_16BIT_CMD(AFMT_S16_LE | AFMT_STEREO, DSP_MODE_S16STEREO),
314 static const struct playback_command*
315 als_get_playback_command(u_int32_t format)
319 n = sizeof(playback_cmds) / sizeof(playback_cmds[0]);
320 for (i = 0; i < n; i++) {
321 if (playback_cmds[i].pcm_format == format) {
322 return &playback_cmds[i];
325 DEB(printf("als_get_playback_command: invalid format 0x%08x\n",
327 return &playback_cmds[0];
331 als_playback_start(struct sc_chinfo *ch)
333 const struct playback_command *p;
334 struct sc_info *sc = ch->parent;
335 u_int32_t buf, bufsz, count, dma_prog;
337 buf = vtophys(sndbuf_getbuf(ch->buffer));
338 bufsz = sndbuf_getsize(ch->buffer);
340 if (ch->format & AFMT_16BIT)
344 als_esp_wr(sc, DSP_CMD_SPKON);
347 als_gcr_wr(sc, ALS_GCR_DMA0_START, buf);
348 als_gcr_wr(sc, ALS_GCR_DMA0_MODE, (bufsz - 1) | 0x180000);
350 p = als_get_playback_command(ch->format);
351 dma_prog = p->dma_prog | DSP_F16_DAC | DSP_F16_AUTO | DSP_F16_FIFO_ON;
353 als_esp_wr(sc, dma_prog);
354 als_esp_wr(sc, p->format_val);
355 als_esp_wr(sc, count & 0xff);
356 als_esp_wr(sc, count >> 8);
362 als_playback_stop(struct sc_chinfo *ch)
364 const struct playback_command *p;
365 struct sc_info *sc = ch->parent;
368 active = ch->dma_active;
370 p = als_get_playback_command(ch->format);
371 als_esp_wr(sc, p->dma_stop);
378 alspchan_trigger(kobj_t obj, void *data, int go)
380 struct sc_chinfo *ch = data;
384 als_playback_start(ch);
387 als_playback_stop(ch);
393 static kobj_method_t alspchan_methods[] = {
394 KOBJMETHOD(channel_init, alschan_init),
395 KOBJMETHOD(channel_setformat, alschan_setformat),
396 KOBJMETHOD(channel_setspeed, alschan_setspeed),
397 KOBJMETHOD(channel_setblocksize, alschan_setblocksize),
398 KOBJMETHOD(channel_trigger, alspchan_trigger),
399 KOBJMETHOD(channel_getptr, alschan_getptr),
400 KOBJMETHOD(channel_getcaps, alschan_getcaps),
403 CHANNEL_DECLARE(alspchan);
405 /* ------------------------------------------------------------------------- */
406 /* Capture channel implementation */
409 als_get_fifo_format(struct sc_info *sc, u_int32_t format)
413 return ALS_FIFO1_8BIT;
414 case AFMT_U8 | AFMT_STEREO:
415 return ALS_FIFO1_8BIT | ALS_FIFO1_STEREO;
417 return ALS_FIFO1_SIGNED;
418 case AFMT_S16_LE | AFMT_STEREO:
419 return ALS_FIFO1_SIGNED | ALS_FIFO1_STEREO;
421 device_printf(sc->dev, "format not found: 0x%08x\n", format);
422 return ALS_FIFO1_8BIT;
426 als_capture_start(struct sc_chinfo *ch)
428 struct sc_info *sc = ch->parent;
429 u_int32_t buf, bufsz, count, dma_prog;
431 buf = vtophys(sndbuf_getbuf(ch->buffer));
432 bufsz = sndbuf_getsize(ch->buffer);
434 if (ch->format & AFMT_16BIT)
438 als_esp_wr(sc, DSP_CMD_SPKON);
441 als_gcr_wr(sc, ALS_GCR_FIFO1_START, buf);
442 als_gcr_wr(sc, ALS_GCR_FIFO1_COUNT, (bufsz - 1));
444 als_mix_wr(sc, ALS_FIFO1_LENGTH_LO, count & 0xff);
445 als_mix_wr(sc, ALS_FIFO1_LENGTH_HI, count >> 8);
447 dma_prog = ALS_FIFO1_RUN | als_get_fifo_format(sc, ch->format);
448 als_mix_wr(sc, ALS_FIFO1_CONTROL, dma_prog);
454 als_capture_stop(struct sc_chinfo *ch)
456 struct sc_info *sc = ch->parent;
459 active = ch->dma_active;
461 als_mix_wr(sc, ALS_FIFO1_CONTROL, ALS_FIFO1_STOP);
468 alsrchan_trigger(kobj_t obj, void *data, int go)
470 struct sc_chinfo *ch = data;
474 als_capture_start(ch);
477 als_capture_stop(ch);
483 static kobj_method_t alsrchan_methods[] = {
484 KOBJMETHOD(channel_init, alschan_init),
485 KOBJMETHOD(channel_setformat, alschan_setformat),
486 KOBJMETHOD(channel_setspeed, alschan_setspeed),
487 KOBJMETHOD(channel_setblocksize, alschan_setblocksize),
488 KOBJMETHOD(channel_trigger, alsrchan_trigger),
489 KOBJMETHOD(channel_getptr, alschan_getptr),
490 KOBJMETHOD(channel_getcaps, alschan_getcaps),
493 CHANNEL_DECLARE(alsrchan);
495 /* ------------------------------------------------------------------------- */
499 * ALS4000 has an sb16 mixer, with some additional controls that we do
500 * not yet a means to support.
508 u_int8_t iselect; /* left input mask */
509 } static const amt[SOUND_MIXER_NRDEVICES] = {
510 [SOUND_MIXER_VOLUME] = { 0x30, 0x31, 5, 0x00, 0x00 },
511 [SOUND_MIXER_PCM] = { 0x32, 0x33, 5, 0x00, 0x00 },
512 [SOUND_MIXER_SYNTH] = { 0x34, 0x35, 5, 0x60, 0x40 },
513 [SOUND_MIXER_CD] = { 0x36, 0x37, 5, 0x06, 0x04 },
514 [SOUND_MIXER_LINE] = { 0x38, 0x39, 5, 0x18, 0x10 },
515 [SOUND_MIXER_MIC] = { 0x3a, 0x00, 5, 0x01, 0x01 },
516 [SOUND_MIXER_SPEAKER] = { 0x3b, 0x00, 2, 0x00, 0x00 },
517 [SOUND_MIXER_IGAIN] = { 0x3f, 0x40, 2, 0x00, 0x00 },
518 [SOUND_MIXER_OGAIN] = { 0x41, 0x42, 2, 0x00, 0x00 },
519 /* The following have register values but no h/w implementation */
520 [SOUND_MIXER_TREBLE] = { 0x44, 0x45, 4, 0x00, 0x00 },
521 [SOUND_MIXER_BASS] = { 0x46, 0x47, 4, 0x00, 0x00 }
525 alsmix_init(struct snd_mixer *m)
529 for (i = v = 0; i < SOUND_MIXER_NRDEVICES; i++) {
530 if (amt[i].bits) v |= 1 << i;
534 for (i = v = 0; i < SOUND_MIXER_NRDEVICES; i++) {
535 if (amt[i].iselect) v |= 1 << i;
537 mix_setrecdevs(m, v);
542 alsmix_set(struct snd_mixer *m, unsigned dev, unsigned left, unsigned right)
544 struct sc_info *sc = mix_getdevinfo(m);
545 u_int32_t r, l, v, mask;
547 /* Fill upper n bits in mask with 1's */
548 mask = ((1 << amt[dev].bits) - 1) << (8 - amt[dev].bits);
550 l = (left * mask / 100) & mask;
551 v = als_mix_rd(sc, amt[dev].lreg) & ~mask;
552 als_mix_wr(sc, amt[dev].lreg, l | v);
555 r = (right * mask / 100) & mask;
556 v = als_mix_rd(sc, amt[dev].rreg) & ~mask;
557 als_mix_wr(sc, amt[dev].rreg, r | v);
562 /* Zero gain does not mute channel from output, but this does. */
563 v = als_mix_rd(sc, SB16_OMASK);
564 if (l == 0 && r == 0) {
565 v &= ~amt[dev].oselect;
567 v |= amt[dev].oselect;
569 als_mix_wr(sc, SB16_OMASK, v);
574 alsmix_setrecsrc(struct snd_mixer *m, u_int32_t src)
576 struct sc_info *sc = mix_getdevinfo(m);
579 for (i = l = r = 0; i < SOUND_MIXER_NRDEVICES; i++) {
580 if (src & (1 << i)) {
582 r |= amt[i].iselect << 1;
586 als_mix_wr(sc, SB16_IMASK_L, l);
587 als_mix_wr(sc, SB16_IMASK_R, r);
591 static kobj_method_t als_mixer_methods[] = {
592 KOBJMETHOD(mixer_init, alsmix_init),
593 KOBJMETHOD(mixer_set, alsmix_set),
594 KOBJMETHOD(mixer_setrecsrc, alsmix_setrecsrc),
597 MIXER_DECLARE(als_mixer);
599 /* ------------------------------------------------------------------------- */
600 /* Interrupt Handler */
605 struct sc_info *sc = (struct sc_info *)p;
606 u_int8_t intr, sb_status;
608 intr = als_intr_rd(sc);
611 chn_intr(sc->pch.channel);
614 chn_intr(sc->rch.channel);
616 /* ACK interrupt in PCI core */
617 als_intr_wr(sc, intr);
619 /* ACK interrupt in SB core */
620 sb_status = als_mix_rd(sc, IRQ_STAT);
622 if (sb_status & ALS_IRQ_STATUS8)
623 als_ack_read(sc, ALS_ESP_RD_STATUS8);
624 if (sb_status & ALS_IRQ_STATUS16)
625 als_ack_read(sc, ALS_ESP_RD_STATUS16);
626 if (sb_status & ALS_IRQ_MPUIN)
627 als_ack_read(sc, ALS_MIDI_DATA);
628 if (sb_status & ALS_IRQ_CR1E)
629 als_ack_read(sc, ALS_CR1E_ACK_PORT);
633 /* ------------------------------------------------------------------------- */
634 /* H/W initialization */
637 als_init(struct sc_info *sc)
642 if (als_esp_reset(sc)) {
646 /* Enable write on DMA_SETUP register */
647 v = als_mix_rd(sc, ALS_SB16_CONFIG);
648 als_mix_wr(sc, ALS_SB16_CONFIG, v | 0x80);
651 als_mix_wr(sc, ALS_SB16_DMA_SETUP, 0x01);
653 /* Disable write on DMA_SETUP register */
654 als_mix_wr(sc, ALS_SB16_CONFIG, v & 0x7f);
656 /* Enable interrupts */
657 v = als_gcr_rd(sc, ALS_GCR_MISC);
658 als_gcr_wr(sc, ALS_GCR_MISC, v | 0x28000);
660 /* Black out GCR DMA registers */
661 for (i = 0x91; i <= 0x96; i++) {
662 als_gcr_wr(sc, i, 0);
666 v = als_gcr_rd(sc, ALS_GCR_DMA_EMULATION);
667 als_gcr_wr(sc, ALS_GCR_DMA_EMULATION, v);
668 DEB(printf("GCR_DMA_EMULATION 0x%08x\n", v));
673 als_uninit(struct sc_info *sc)
675 /* Disable interrupts */
676 als_gcr_wr(sc, ALS_GCR_MISC, 0);
679 /* ------------------------------------------------------------------------- */
680 /* Probe and attach card */
683 als_pci_probe(device_t dev)
685 if (pci_get_devid(dev) == ALS_PCI_ID0) {
686 device_set_desc(dev, "Avance Logic ALS4000");
693 als_resource_free(device_t dev, struct sc_info *sc)
696 bus_release_resource(dev, SYS_RES_IOPORT, sc->regid, sc->reg);
700 bus_teardown_intr(dev, sc->irq, sc->ih);
704 bus_release_resource(dev, SYS_RES_IRQ, sc->irqid, sc->irq);
707 if (sc->parent_dmat) {
708 bus_dma_tag_destroy(sc->parent_dmat);
714 als_resource_grab(device_t dev, struct sc_info *sc)
716 sc->regid = PCIR_MAPS;
717 sc->reg = bus_alloc_resource(dev, SYS_RES_IOPORT, &sc->regid, 0, ~0,
718 ALS_CONFIG_SPACE_BYTES, RF_ACTIVE);
720 device_printf(dev, "unable to allocate register space\n");
723 sc->st = rman_get_bustag(sc->reg);
724 sc->sh = rman_get_bushandle(sc->reg);
726 sc->irq = bus_alloc_resource(dev, SYS_RES_IRQ, &sc->irqid, 0, ~0, 1,
727 RF_ACTIVE | RF_SHAREABLE);
729 device_printf(dev, "unable to allocate interrupt\n");
733 if (bus_setup_intr(dev, sc->irq, INTR_TYPE_AV, als_intr,
735 device_printf(dev, "unable to setup interrupt\n");
739 sc->bufsz = pcm_getbuffersize(dev, 4096, ALS_DEFAULT_BUFSZ, 65536);
741 if (bus_dma_tag_create(/*parent*/NULL,
742 /*alignment*/2, /*boundary*/0,
743 /*lowaddr*/BUS_SPACE_MAXADDR_24BIT,
744 /*highaddr*/BUS_SPACE_MAXADDR,
745 /*filter*/NULL, /*filterarg*/NULL,
746 /*maxsize*/sc->bufsz,
747 /*nsegments*/1, /*maxsegz*/0x3ffff,
748 /*flags*/0, &sc->parent_dmat) != 0) {
749 device_printf(dev, "unable to create dma tag\n");
754 als_resource_free(dev, sc);
759 als_pci_attach(device_t dev)
763 char status[SND_STATUSLEN];
765 if ((sc = malloc(sizeof(*sc), M_DEVBUF, M_NOWAIT | M_ZERO)) == NULL) {
766 device_printf(dev, "cannot allocate softc\n");
772 data = pci_read_config(dev, PCIR_COMMAND, 2);
773 data |= (PCIM_CMD_PORTEN | PCIM_CMD_MEMEN | PCIM_CMD_BUSMASTEREN);
774 pci_write_config(dev, PCIR_COMMAND, data, 2);
776 * By default the power to the various components on the
777 * ALS4000 is entirely controlled by the pci powerstate. We
778 * could attempt finer grained control by setting GCR6.31.
780 #if __FreeBSD_version > 500000
781 if (pci_get_powerstate(dev) != PCI_POWERSTATE_D0) {
782 /* Reset the power state. */
783 device_printf(dev, "chip is in D%d power mode "
784 "-- setting to D0\n", pci_get_powerstate(dev));
785 pci_set_powerstate(dev, PCI_POWERSTATE_D0);
788 data = pci_read_config(dev, ALS_PCI_POWERREG, 2);
789 if ((data & 0x03) != 0) {
790 device_printf(dev, "chip is in D%d power mode "
791 "-- setting to D0\n", data & 0x03);
793 pci_write_config(dev, ALS_PCI_POWERREG, data, 2);
797 if (als_resource_grab(dev, sc)) {
798 device_printf(dev, "failed to allocate resources\n");
803 device_printf(dev, "failed to initialize hardware\n");
807 if (mixer_init(dev, &als_mixer_class, sc)) {
808 device_printf(dev, "failed to initialize mixer\n");
812 if (pcm_register(dev, sc, 1, 1)) {
813 device_printf(dev, "failed to register pcm entries\n");
817 pcm_addchan(dev, PCMDIR_PLAY, &alspchan_class, sc);
818 pcm_addchan(dev, PCMDIR_REC, &alsrchan_class, sc);
820 snprintf(status, SND_STATUSLEN, "at io 0x%lx irq %ld",
821 rman_get_start(sc->reg), rman_get_start(sc->irq));
822 pcm_setstatus(dev, status);
826 als_resource_free(dev, sc);
832 als_pci_detach(device_t dev)
837 r = pcm_unregister(dev);
841 sc = pcm_getdevinfo(dev);
843 als_resource_free(dev, sc);
849 als_pci_suspend(device_t dev)
851 struct sc_info *sc = pcm_getdevinfo(dev);
853 sc->pch.dma_was_active = als_playback_stop(&sc->pch);
854 sc->rch.dma_was_active = als_capture_stop(&sc->rch);
860 als_pci_resume(device_t dev)
862 struct sc_info *sc = pcm_getdevinfo(dev);
864 if (als_init(sc) != 0) {
865 device_printf(dev, "unable to reinitialize the card\n");
869 if (mixer_reinit(dev) != 0) {
870 device_printf(dev, "unable to reinitialize the mixer\n");
874 if (sc->pch.dma_was_active) {
875 als_playback_start(&sc->pch);
878 if (sc->rch.dma_was_active) {
879 als_capture_start(&sc->rch);
884 static device_method_t als_methods[] = {
885 /* Device interface */
886 DEVMETHOD(device_probe, als_pci_probe),
887 DEVMETHOD(device_attach, als_pci_attach),
888 DEVMETHOD(device_detach, als_pci_detach),
889 DEVMETHOD(device_suspend, als_pci_suspend),
890 DEVMETHOD(device_resume, als_pci_resume),
894 static driver_t als_driver = {
900 DRIVER_MODULE(snd_als4000, pci, als_driver, pcm_devclass, 0, 0);
901 MODULE_DEPEND(snd_als4000, snd_pcm, PCM_MINVER, PCM_PREFVER, PCM_MAXVER);
902 MODULE_VERSION(snd_als4000, 1);