*** /usr/src/sys/dev/sound/pci/ali.c.orig Mon May 21 22:49:57 2001 --- /usr/src/sys/dev/sound/pci/ali.c Tue May 22 18:07:28 2001 *************** *** 0 **** --- 1,678 ---- + /* + * Copyright (c) 2001 Tatsuo YOKOGAWA. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. 2. + * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. 3. All advertising + * materials mentioning features or use of this software must display the + * following acknowledgement: This product includes software developed for + * the NetBSD Project by Jason R. Thorpe. 4. The name of the author may not + * be used to endorse or promote products derived from this software without + * specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO + * EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED + * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + + #include + + #include + #include + + #include + #include + + #include + #include + + #define ALI_BUFFSIZE (65536) + + static u_int32_t ali_playfmt[] = { + AFMT_U8, + AFMT_STEREO | AFMT_U8, + AFMT_S8, + AFMT_STEREO | AFMT_S8, + AFMT_S16_LE, + AFMT_STEREO | AFMT_S16_LE, + AFMT_U16_LE, + AFMT_STEREO | AFMT_U16_LE, + 0 + }; + static pcmchan_caps ali_playcaps = {5000, 48000, ali_playfmt, 0}; + + static u_int32_t ali_recfmt[] = { + AFMT_U8, + AFMT_STEREO | AFMT_U8, + AFMT_S8, + AFMT_STEREO | AFMT_S8, + AFMT_S16_LE, + AFMT_STEREO | AFMT_S16_LE, + AFMT_U16_LE, + AFMT_STEREO | AFMT_U16_LE, + 0 + }; + static pcmchan_caps ali_reccaps = {5000, 48000, ali_recfmt, 0}; + + struct ali_chinfo { + struct ali_info *parent; + pcm_channel *channel; + snd_dbuf *buffer; + int dir, stopping; + u_int32_t fmt, spd, blksz; + }; + + struct ali_info { + struct resource *io; /* I/O address for the board */ + struct resource *irq; + void *ih; + bus_dma_tag_t parent_dmat; + + struct ali_chinfo pch, rch; + }; + + static void ali_intr(void *arg); + static int ali_set_dma(struct ali_info *sc, u_int32_t base, u_int32_t cnt, int dir); + static void ali_set_channel(struct ali_info *sc, u_char ch); + static void ali_set_fmt(struct ali_info *sc, u_int32_t data); + static void ali_set_dac_rate(struct ali_info *sc, unsigned rate); + static void ali_start_dac(struct ali_info *sc, u_int ch); + static void ali_stop_dac(struct ali_info *sc, u_int ch); + + static devclass_t pcm_devclass; + + static int + port_rd(struct resource *port, int regno, int size) + { + bus_space_tag_t st = rman_get_bustag(port); + bus_space_handle_t sh = rman_get_bushandle(port); + + switch (size) { + case 1: + return bus_space_read_1(st, sh, regno); + case 2: + return bus_space_read_2(st, sh, regno); + case 4: + return bus_space_read_4(st, sh, regno); + default: + return 0xffffffff; + } + } + + static void + port_wr(struct resource *port, int regno, u_int32_t data, int size) + { + bus_space_tag_t st = rman_get_bustag(port); + bus_space_handle_t sh = rman_get_bushandle(port); + + switch (size) { + case 1: + bus_space_write_1(st, sh, regno, data); + break; + case 2: + bus_space_write_2(st, sh, regno, data); + break; + case 4: + bus_space_write_4(st, sh, regno, data); + break; + } + } + + static int + ali_rdcd(kobj_t obj, void *arg, int reg) + { + struct ali_info *sc = (struct ali_info *)arg; + u_int32_t cnt = 0xffff; + u_int32_t i = 0; + u_int32_t chk1, chk2; + + while(cnt--){ + if( (port_rd(sc->io, ALI_ACR0_AC97_R , 2) & 0x8000) == 0) + break; + } + + if(cnt == 0) + return 0; + + i |= (u_int32_t) reg & 0xff; + port_wr(sc->io, ALI_ACR0_AC97_R , i, 1); + cnt = 0xffff; + + chk1 = port_rd(sc->io, ALI_STimer, 4); + chk2 = port_rd(sc->io, ALI_STimer, 4); + + while(chk1 == chk2) + chk2 = port_rd(sc->io, ALI_STimer, 4); + port_wr(sc->io, ALI_ACR0_AC97_R + 1 , 0x80 , 1); + + while(cnt--){ + if( (port_rd(sc->io, ALI_ACR0_AC97_R , 2) & 0x8000) == 0){ + i = port_rd(sc->io, ALI_ACR0_AC97_R + 2, 2); + return i; + } + port_rd(sc->io, ALI_ACR0_AC97_R , 2); + } + + return 0x0; + } + + static int + ali_wrcd(kobj_t obj, void *arg, int reg, u_int32_t val) + { + struct ali_info *sc = (struct ali_info *)arg; + + u_int32_t cnt = 0xffff; + u_int32_t chk1, chk2; + + while(cnt--){ + if( (port_rd(sc->io, ALI_ACR0_AC97_W, 2) & 0x8000) == 0){ + port_wr(sc->io, ALI_ACR0_AC97_W + 2, val, 2); + port_wr(sc->io, ALI_ACR0_AC97_W, reg & 0xff, 1); + + chk1 = port_rd(sc->io, ALI_STimer, 4); + chk2 = port_rd(sc->io, ALI_STimer, 4); + + while(chk1 == chk2) + chk2 = port_rd(sc->io, ALI_STimer, 4); + port_wr(sc->io, ALI_ACR0_AC97_W + 1, 0x80, 1); + + return 0; + } + port_rd(sc->io, ALI_ACR0_AC97_W, 2); + } + + return 0xffffffff; + } + + static kobj_method_t ali_ac97_methods[] = { + KOBJMETHOD(ac97_read, ali_rdcd), + KOBJMETHOD(ac97_write, ali_wrcd), + { 0, 0 } + }; + AC97_DECLARE(ali_ac97); + + static void + ali_intr(void *arg) + { + struct ali_info *sc = (struct ali_info *)arg; + u_int32_t aint, ainten; + + ainten = port_rd(sc->io, ALI_AINTEN, 4); + port_wr(sc->io, ALI_AINTEN, ainten & ~1, 4); + + aint = port_rd(sc->io, ALI_AINT, 4); + + if(aint & 1){ + port_wr(sc->io, ALI_AINT, 1, 4); + chn_intr(sc->pch.channel); + ainten = port_rd(sc->io, ALI_AINTEN, 4); + port_wr(sc->io, ALI_AINTEN, ainten | 1, 4); + } + + if(aint & (1 << ALI_PCM_IN_CHANNEL)){ + port_wr(sc->io, ALI_AINT, (1 << ALI_PCM_IN_CHANNEL), 4); + chn_intr(sc->rch.channel); + ainten = port_rd(sc->io, ALI_AINTEN, 4); + port_wr(sc->io, ALI_AINTEN, ainten | (1 << ALI_PCM_IN_CHANNEL), 4); + } + + return; + } + + /* -------------------------------------------------------------------- */ + /* channel interface for ALI5451 */ + + static void * + alichan_init(kobj_t obj, void *devinfo, snd_dbuf *b, pcm_channel *c, int dir) + { + struct ali_info *sc = devinfo; + struct ali_chinfo *ch = (dir == PCMDIR_PLAY)? &sc->pch : &sc->rch; + + ch->parent = sc; + ch->channel = c; + ch->buffer = b; + ch->dir = dir; + if (sndbuf_alloc(ch->buffer, sc->parent_dmat, ALI_BUFFSIZE) == -1) + return NULL; + + return ch; + } + + static int + alichan_setformat(kobj_t obj, void *data, u_int32_t format) + { + struct ali_chinfo *ch = data; + + ch->fmt = format; + return 0; + } + + static int + alichan_setspeed(kobj_t obj, void *data, u_int32_t speed) + { + struct ali_chinfo *ch = data; + + ch->spd = speed; + + return ch->spd; + } + + static int + alichan_setblocksize(kobj_t obj, void *data, u_int32_t blocksize) + { + struct ali_chinfo *ch = data; + + ch->blksz = blocksize; + return ch->blksz; + } + + static int + alichan_trigger(kobj_t obj, void *data, int go) + { + struct ali_chinfo *ch = data; + struct ali_info *sc = ch->parent; + + if (go == PCMTRIG_EMLDMAWR || go == PCMTRIG_EMLDMARD) + return 0; + + if (ch->dir == PCMDIR_PLAY) { + switch(go){ + case PCMTRIG_START: + ali_set_dma(sc, vtophys(sndbuf_getbuf(ch->buffer)), + sndbuf_getsize(ch->buffer), ch->dir); + ali_start_dac(sc, 0); + break; + + case PCMTRIG_ABORT: + ali_stop_dac(sc, 0); + break; + } + }else{ + switch(go){ + case PCMTRIG_START: + ali_set_dma(sc, vtophys(sndbuf_getbuf(ch->buffer)), + sndbuf_getsize(ch->buffer), ch->dir); + ali_start_dac(sc, ALI_PCM_IN_CHANNEL); + break; + + case PCMTRIG_ABORT: + ali_stop_dac(sc, ALI_PCM_IN_CHANNEL); + break; + } + } + + + return 0; + } + + static int + alichan_getptr(kobj_t obj, void *data) + { + struct ali_chinfo *ch = data; + struct ali_info *sc = ch->parent; + u_int32_t ptr; + + if(ch->dir == PCMDIR_PLAY){ + ali_set_channel(sc, 0); + ptr = port_rd(sc->io, ALI_CH_CSO_ALPHA_FMS, 4); + ptr >>= 16; + return ptr; + }else{ + ali_set_channel(sc, ALI_PCM_IN_CHANNEL); + ptr = port_rd(sc->io, ALI_CH_CSO_ALPHA_FMS, 4); + ptr >>= 16; + return ptr; + } + + return 0; + } + + static pcmchan_caps * + alichan_getcaps(kobj_t obj, void *data) + { + struct ali_chinfo *ch = data; + + return (ch->dir == PCMDIR_PLAY)? &ali_playcaps : &ali_reccaps; + } + + static kobj_method_t alichan_methods[] = { + KOBJMETHOD(channel_init, alichan_init), + KOBJMETHOD(channel_setformat, alichan_setformat), + KOBJMETHOD(channel_setspeed, alichan_setspeed), + KOBJMETHOD(channel_setblocksize, alichan_setblocksize), + KOBJMETHOD(channel_trigger, alichan_trigger), + KOBJMETHOD(channel_getptr, alichan_getptr), + KOBJMETHOD(channel_getcaps, alichan_getcaps), + { 0, 0 } + }; + CHANNEL_DECLARE(alichan); + + /************************************************************/ + + /************************************************************/ + + static void ali_set_channel(struct ali_info *sc, u_char ch) + { + port_wr(sc->io, ALI_GC_CIR, ch, 1); + } + + static void ali_start_dac(struct ali_info *sc, u_int ch) + { + unsigned long flags; + + flags = spltty(); + + port_wr(sc->io, ALI_AINT, 0x0, 4); + port_wr(sc->io, ALI_START, 1 << ch , 4); + + splx(flags); + } + + static void ali_stop_dac(struct ali_info *sc, u_int ch) + { + unsigned long flags; + u_int32_t ainten; + + flags = spltty(); + + port_wr(sc->io, ALI_STOP, 1 << ch, 4); + ainten = port_rd(sc->io, ALI_AINTEN,4); + port_wr(sc->io, ALI_AINTEN, ainten | (1 << ch), 4); + + splx(flags); + } + + static void ali_set_fmt(struct ali_info *sc, u_int32_t data) + { + u_int32_t i; + u_int32_t fmt = 0; + + if(data & AFMT_STEREO) fmt |= ALI_CFMT_STEREO; + + if(data & AFMT_U16_LE) fmt |= ALI_CFMT_16BIT; + else if(data & AFMT_S16_LE) fmt |= ALI_CFMT_16BIT | ALI_CFMT_SIGNED; + else if(data & AFMT_S8) fmt |= ALI_CFMT_SIGNED; + + port_wr(sc->io, ALI_EBUF1, ALI_Still_Mode, 4); + port_wr(sc->io, ALI_EBUF2, ALI_Still_Mode, 4); + + i = port_rd( sc->io, ALI_CH_GVSEL_PAN_VOL_CTRL_EC, 4); + i &= ~(0xf000); + i |= (fmt << 8); + port_wr(sc->io, ALI_CH_GVSEL_PAN_VOL_CTRL_EC, i, 4); + + } + + static void ali_set_dac_rate(struct ali_info *sc, unsigned rate) + { + u_int32_t div; + u_int32_t i; + + if (rate > 48000) + rate = 48000; + if (rate < 5000) + rate = 5000; + div = ( u_int32_t ) rate ; + div = ((div << 12 )/48000) & 0x0000ffff; + + i = port_rd(sc->io, ALI_CH_ESO_DELTA, 4); + i = (i & 0xffff0000) | div ; + port_wr(sc->io, ALI_CH_ESO_DELTA, i, 4); + } + + static void ali_set_adc_rate(struct ali_info *sc, unsigned rate) + { + u_int32_t div; + u_int32_t i; + + if (rate > 48000) + rate = 48000; + if (rate < 5000) + rate = 5000; + + div = (u_int32_t) rate; + i = (u_int32_t) 48000; + div = ((i <<12) / div) & 0x0000ffff ; + + i = port_rd(sc->io, ALI_CH_ESO_DELTA, 4); + i = (i & 0xffff0000) | div; + port_wr(sc->io, ALI_CH_ESO_DELTA, i, 4); + } + + static int + ali_set_dma(struct ali_info *sc, u_int32_t base, u_int32_t cnt, int dir) + { + struct ali_chinfo *ch = (dir == PCMDIR_PLAY)? &sc->pch : &sc->rch; + u_int32_t i; + u_int32_t sz; + u_char val; + + if (dir == PCMDIR_PLAY) { + ali_set_channel(sc, 0); + + ali_set_fmt(sc, ch->fmt); + ali_set_dac_rate(sc, ch->spd); + + val = port_rd(sc->io, ALI_GC_CIR + 1, 1); + val |= ALI_MIDLP_ENDLP_IE; + port_wr(sc->io, ALI_GC_CIR + 1, val, 1); + + i = port_rd(sc->io, ALI_AINTEN, 4); + i |= 0x00000001; + port_wr(sc->io, ALI_AINTEN, i, 4); + + port_wr(sc->io, ALI_CH_CSO_ALPHA_FMS, 0, 4); + port_wr(sc->io, ALI_CH_LBA, base, 4); + + sz = cnt; + if(ch->fmt & AFMT_STEREO) sz >>= 1; + if(!(ch->fmt & AFMT_U8)&&!(ch->fmt & AFMT_S8)) sz >>= 1; + + i = port_rd(sc->io, ALI_CH_ESO_DELTA, 4); + i = (i & 0x0000ffff) | ((u_int32_t)(sz - 1) << 16 ); + port_wr(sc->io, ALI_CH_ESO_DELTA, i, 4); + + i = port_rd(sc->io, ALI_CH_GVSEL_PAN_VOL_CTRL_EC, 4); + i &= 0xf000; + i |= 0x80001000; + port_wr(sc->io, ALI_CH_GVSEL_PAN_VOL_CTRL_EC, i, 4); + }else{ + ali_set_channel(sc, ALI_PCM_IN_CHANNEL); + + ali_set_fmt(sc, ch->fmt); + ali_set_adc_rate(sc, ch->spd); + + val = port_rd(sc->io, ALI_GC_CIR + 1, 1); + val |= ALI_MIDLP_ENDLP_IE; + port_wr(sc->io, ALI_GC_CIR + 1, val, 1); + + i = port_rd(sc->io, ALI_AINTEN, 4); + i |= (1 << ALI_PCM_IN_CHANNEL); + port_wr(sc->io, ALI_AINTEN, i, 4); + + port_wr(sc->io, ALI_CH_CSO_ALPHA_FMS, 0, 4); + port_wr(sc->io, ALI_CH_LBA, base, 4); + + sz = cnt; + if(ch->fmt & AFMT_STEREO) sz >>= 1; + if(!(ch->fmt & AFMT_U8)&&!(ch->fmt & AFMT_S8)) sz >>= 1; + + i = port_rd(sc->io, ALI_CH_ESO_DELTA, 4); + i = (i & 0x0000ffff) | ((u_int32_t)(sz - 1) << 16 ); + port_wr(sc->io, ALI_CH_ESO_DELTA, i, 4); + + i = port_rd(sc->io, ALI_CH_GVSEL_PAN_VOL_CTRL_EC, 4); + i &= 0xf000; + i |= 0x80001000; + port_wr(sc->io, ALI_CH_GVSEL_PAN_VOL_CTRL_EC, i, 4); + } + + return 0; + } + + static void + ali_release_resources(struct ali_info *sc, device_t dev) + { + /* should we bus_teardown_intr here? */ + if (sc->irq) { + if (sc->ih) + bus_teardown_intr(dev, sc->irq, sc->ih); + bus_release_resource(dev, SYS_RES_IRQ, 0, sc->irq); + sc->irq = 0; + } + if (sc->io) { + bus_release_resource(dev, SYS_RES_IOPORT, PCIR_MAPS, sc->io); + sc->io = 0; + } + + if (sc->parent_dmat) { + bus_dma_tag_destroy(sc->parent_dmat); + sc->parent_dmat = 0; + } + + free(sc, M_DEVBUF); + } + + static int + ali_alloc_resources(struct ali_info *sc, device_t dev) + { + int rid; + + rid = PCIR_MAPS; + sc->io = bus_alloc_resource(dev, SYS_RES_IOPORT, &rid, 0, ~0, 1, RF_ACTIVE); + + rid = 0; + sc->irq = bus_alloc_resource(dev, SYS_RES_IRQ, &rid, 0, ~0, 1, RF_ACTIVE | RF_SHAREABLE); + + return (sc->irq && sc->io )? 0 : ENXIO; + } + + static int + ali_probe(device_t dev) + { + char *s = NULL; + u_int32_t subdev; + + subdev = (pci_get_subdevice(dev) << 16) | pci_get_subvendor(dev); + switch (pci_get_devid(dev)) { + case ALI_M5451_ID: + s = "AcerLabs M5451 Audio Driver"; + break; + } + + if (s) + device_set_desc(dev, s); + + return s? 0 : ENXIO; + } + + static int + ali_attach(device_t dev) + { + struct ali_info *sc; + struct ac97_info *codec; + char status[SND_STATUSLEN]; + u_int32_t data; + + sc = (struct ali_info *)malloc(sizeof *sc, M_DEVBUF, M_NOWAIT); + + if (!sc) return ENXIO; + + bzero(sc, sizeof *sc); + + data = pci_read_config(dev, PCIR_COMMAND, 2); + data |= PCIM_CMD_PORTEN | PCIM_CMD_BUSMASTEREN; + pci_write_config(dev, PCIR_COMMAND, data, 2); + data = pci_read_config(dev, PCIR_COMMAND, 2); + + if (ali_alloc_resources(sc, dev)) + goto no; + + codec = AC97_CREATE(dev, sc, ali_ac97); + if (codec == NULL) goto no; + if (mixer_init(dev, ac97_getmixerclass(), codec) == -1) goto no; + + port_wr(sc->io, ALI_GLOBAL_CONTROL, ALI_PCM_IN_ENABLE, 4); + port_wr(sc->io, ALI_AINTEN, ALI_AINTEN_DISABLE, 4); + port_wr(sc->io, ALI_AINT, ALI_AINT_RESET, 4); + + port_wr(sc->io, ALI_MUSICVOL_WAVEVOL, ALI_MUSICVOL_WAVEVOL_0dB , 4); + port_wr(sc->io, ALI_MPUR2, 0x10, 1); + + bus_setup_intr(dev, sc->irq, INTR_TYPE_TTY, ali_intr, sc, &sc->ih); + + if (bus_dma_tag_create(/*parent*/NULL, /*alignment*/65536, /*boundary*/0, + /*lowaddr*/BUS_SPACE_MAXADDR_32BIT, + /*highaddr*/BUS_SPACE_MAXADDR, + /*filter*/NULL, /*filterarg*/NULL, + /*maxsize*/ALI_BUFFSIZE, /*nsegments*/1, + /*maxsegz*/0x3ffff, + /*flags*/0, &sc->parent_dmat) != 0) { + device_printf(dev, "unable to create dma tag\n"); + goto no; + } + + snprintf(status, SND_STATUSLEN, "at io 0x%lx irq %ld", + rman_get_start(sc->io), rman_get_start(sc->irq)); + + if (pcm_register(dev, sc, 1, 1)) + goto no; + + pcm_addchan(dev, PCMDIR_REC, &alichan_class, sc); + pcm_addchan(dev, PCMDIR_PLAY, &alichan_class, sc); + pcm_setstatus(dev, status); + + return 0; + + no: + ali_release_resources(sc, dev); + return ENXIO; + } + + static int + ali_detach(device_t dev) + { + int r; + struct ali_info *sc; + + r = pcm_unregister(dev); + if (r) + return r; + + sc = pcm_getdevinfo(dev); + ali_release_resources(sc, dev); + return 0; + } + + static device_method_t ali_methods[] = { + /* Device interface */ + DEVMETHOD(device_probe, ali_probe), + DEVMETHOD(device_attach, ali_attach), + DEVMETHOD(device_detach, ali_detach), + /* + DEVMETHOD(device_resume, bus_generic_resume), + DEVMETHOD(device_suspend, bus_generic_suspend), + */ + { 0, 0 } + }; + + static driver_t ali_driver = { + "pcm", + ali_methods, + sizeof(snddev_info), + }; + + DRIVER_MODULE(snd_ali, pci, ali_driver, pcm_devclass, 0, 0); + MODULE_DEPEND(snd_ali, snd_pcm, PCM_MINVER, PCM_PREFVER, PCM_MAXVER); + MODULE_VERSION(snd_ali, 1); *** /usr/src/sys/dev/sound/pci/ali.h.orig Mon May 21 22:50:02 2001 --- /usr/src/sys/dev/sound/pci/ali.h Tue May 22 18:07:24 2001 *************** *** 0 **** --- 1,118 ---- + /* + * Copyright (c) 2001 Tatsuo YOKOGAWA. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. 2. + * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. 3. All advertising + * materials mentioning features or use of this software must display the + * following acknowledgement: This product includes software developed for + * the NetBSD Project by Jason R. Thorpe. 4. The name of the author may not + * be used to endorse or promote products derived from this software without + * specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO + * EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED + * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + + #define ALI_M5451_ID 0x545110b9 + + #define ALI_START 0x80 + #define ALI_STOP 0x84 + #define ALI_GC_CIR 0xa0 + #define ALI_CH_CSO_ALPHA_FMS 0xe0 + #define ALI_CH_LBA 0xe4 + #define ALI_CH_ESO_DELTA 0xe8 + #define ALI_CH_GVSEL_PAN_VOL_CTRL_EC 0xf0 + #define ALI_ACR0_AC97_W 0x40 + #define ALI_ACR0_AC97_R 0x44 + #define ALI_SCTRL 0x48 + #define ALI_AINTEN 0xa4 + #define ALI_AINT 0x98 + #define ALI_MPUR0 0x20 + #define ALI_MPUR1 0x21 + #define ALI_MPUR2 0x22 + #define ALI_MPUR3 0x23 + #define ALI_SPDIF_CS 0x70 + #define ALI_SPDIF_CTRL 0x74 + #define ALI_GLOBAL_CONTROL 0xd4 + #define ALI_MUSICVOL_WAVEVOL 0xa8 + #define ALI_EBUF1 0xf4 + #define ALI_EBUF2 0xf8 + + #define ALI_CHANNELS 32 + + #define ALI_MISCINT 0xb0 + #define ALI_STimer 0xc8 + + /* codec indirect registers */ + #define ALI_MIX_AUX1INL 0x17 + #define ALI_MIX_AUX1INR 0x16 + #define ALI_MIX_CDINL 0x13 + #define ALI_MIX_CDINR 0x12 + #define ALI_MIX_LINEINL 0x11 + #define ALI_MIX_LINEINR 0x10 + #define ALI_MIX_MICIN 0x0e + #define ALI_MIX_RECSEL 0x1a + #define ALI_MIX_PCBEEP 0x0a + #define ALI_MIX_MASTERVOLL 0x03 + #define ALI_MIX_MASTERVOLR 0x02 + #define ALI_MIX_PCMINL 0x19 + #define ALI_MIX_PCMINR 0x18 + #define ALI_MIX_RECORD_GAIN 0x1c + + #define ALI_CFMT_SIGNED 0x20 + #define ALI_CFMT_STEREO 0x40 + #define ALI_CFMT_16BIT 0x80 + #define ALI_CFMT_MASK(fmt) (fmt >> 6) + + #define ALI_MIDLP_ENDLP_IE 0x30 + #define ALI_Still_Mode 0x30000000 + #define ALI_AINTEN_DISABLE 0x00000000 + #define ALI_AINT_RESET 0xffffffff + #define ALI_MIX_RECORD_GAIN_0dB 0x0000 + #define ALI_MIX_PCBEEP_MUTE 0x8000 + #define ALI_MIX_RECSEL_MIC 0x0000 + #define ALI_MIX_REC_OFFSET 0x1 + #define ALI_MUSICVOL_WAVEVOL_0dB 0x00000000 + + #define ALI_CENABLE_PPE 0x4 + #define ALI_CENABLE_RE 0x2 + #define ALI_CENABLE_PE 0x1 + #define ALI_CENABLE_CLEAR 0x8 + + #define ALI_SPDIF_IN_CHANNEL 19 + #define ALI_SPDIF_OUT_CHANNEL 15 + #define ALI_PCM_IN_CHANNEL 31 + + #define ALI_RECORD 0 + #define ALI_PLAYBACK 1 + + #define ALI_SPDIF_OUT_ENABLE 0x20 + #define ALI_SPDIF_OUT_SEL_PCM 0x00000400 + #define ALI_SPDIF_IN_SUPPORT 0x00000800 + #define ALI_SPDIF_OUT_CH_ENABLE 0x00008000 + #define ALI_SPDIF_IN_CH_ENABLE 0x00080000 + #define ALI_SPDIF_IN_CH_DISABLE 0xfff7ffff + #define ALI_SPDIF_OUT_CH_DISABLE 0xffff7fff + #define ALI_SPDIF_OUT_SEL_SPDIF 0xfffffbff + #define ALI_PCM_IN_DISABLE 0x7fffffff + #define ALI_PCM_IN_ENABLE 0x80000000 + + #define ALI_SPDIF_IN_FUNC_ENABLE 0x02 + #define ALI_SPDIF_IN_CH_STATUS 0x40 + #define ALI_SPDIF_OUT_CH_STATUS 0xbf + + #define ALI_PCM_TO_SPDIF_OUT 0 + #define ALI_SPDIF_OUT_TO_SPDIF_OUT 1 *** /usr/src/sys/modules/sound/driver/ali/Makefile.orig Tue May 22 18:05:29 2001 --- /usr/src/sys/modules/sound/driver/ali/Makefile Tue May 22 18:00:17 2001 *************** *** 0 **** --- 1,7 ---- + .PATH: ${.CURDIR}/../../../../dev/sound/pci + KMOD = snd_ali + SRCS = device_if.h bus_if.h isa_if.h pci_if.h + SRCS += ali.c + KMODDEPS = snd_pcm + + .include *** /usr/src/sys/conf/files.orig Mon May 21 00:36:40 2001 --- /usr/src/sys/conf/files Mon May 21 00:37:11 2001 *************** *** 1125,1130 **** --- 1125,1131 ---- dev/sound/pci/t4dwave.c optional pcm pci dev/sound/pci/via82c686.c optional pcm pci dev/sound/pci/vibes.c optional pcm pci + dev/sound/pci/ali.c optional pcm pci # ac97_if.o optional pcm \ dependency "ac97_if.c ac97_if.h" \ *** /usr/src/sys/modules/sound/driver/Makefile.orig Mon Apr 30 02:31:51 2001 --- /usr/src/sys/modules/sound/driver/Makefile Tue May 22 17:55:38 2001 *************** *** 3,7 **** --- 3,8 ---- SUBDIR = ad1816 cmi cs4281 csa ds1 emu10k1 es137x ess fm801 maestro SUBDIR += maestro3 mss neomagic sb16 sb8 sbc solo t4dwave via82c686 SUBDIR += vibes + SUBDIR += ali .include