summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorcg <cg@FreeBSD.org>1999-09-28 20:00:06 +0000
committercg <cg@FreeBSD.org>1999-09-28 20:00:06 +0000
commit378e4ff407df270d76c97341a64686471dff87bd (patch)
treef24cfaf1a3be9c9eca802001de9947ef5589057b
parent199022b99427101c61dc5973e775ca58b25fec82 (diff)
downloadFreeBSD-src-378e4ff407df270d76c97341a64686471dff87bd.zip
FreeBSD-src-378e4ff407df270d76c97341a64686471dff87bd.tar.gz
seperate the ad1816 driver from the mss driver since it shares no code
-rwxr-xr-xsys/dev/pcm/isa/ad1816.c622
-rwxr-xr-xsys/dev/pcm/isa/ad1816.h71
-rw-r--r--sys/dev/pcm/isa/mss.c360
-rw-r--r--sys/dev/pcm/isa/mss.h65
-rw-r--r--sys/dev/sound/isa/ad1816.c622
-rw-r--r--sys/dev/sound/isa/ad1816.h71
-rw-r--r--sys/dev/sound/isa/mss.c360
-rw-r--r--sys/dev/sound/isa/mss.h65
8 files changed, 1414 insertions, 822 deletions
diff --git a/sys/dev/pcm/isa/ad1816.c b/sys/dev/pcm/isa/ad1816.c
new file mode 100755
index 0000000..a069f6d
--- /dev/null
+++ b/sys/dev/pcm/isa/ad1816.c
@@ -0,0 +1,622 @@
+/*
+ * Copyright (c) 1999 Cameron Grant <gandalf@vilnya.demon.co.uk>
+ * Copyright Luigi Rizzo, 1997,1998
+ * Copyright by Hannu Savolainen 1994, 1995
+ * 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.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``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 OR CONTRIBUTORS 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.
+ *
+ * $FreeBSD$
+ */
+
+#include <dev/pcm/sound.h>
+
+#if NPCM > 0 && NPNP > 0
+
+#include <dev/pcm/isa/ad1816.h>
+
+struct ad1816_info;
+
+struct ad1816_chinfo {
+ struct ad1816_info *parent;
+ pcm_channel *channel;
+ snd_dbuf *buffer;
+ int dir;
+};
+
+struct ad1816_info {
+ struct resource *io_base; /* primary I/O address for the board */
+ int io_rid;
+ struct resource *irq;
+ int irq_rid;
+ struct resource *drq1; /* play */
+ int drq1_rid;
+ struct resource *drq2; /* rec */
+ int drq2_rid;
+ bus_dma_tag_t parent_dmat;
+
+ struct ad1816_chinfo pch, rch;
+};
+
+static driver_intr_t ad1816_intr;
+static int ad1816_probe(device_t dev);
+static int ad1816_attach(device_t dev);
+
+/* IO primitives */
+static int ad1816_wait_init(struct ad1816_info *ad1816, int x);
+static u_short ad1816_read(struct ad1816_info *ad1816, u_int reg);
+static void ad1816_write(struct ad1816_info *ad1816, u_int reg, u_short data);
+
+static int ad1816mix_init(snd_mixer *m);
+static int ad1816mix_set(snd_mixer *m, unsigned dev, unsigned left, unsigned right);
+static int ad1816mix_setrecsrc(snd_mixer *m, u_int32_t src);
+static snd_mixer ad1816_mixer = {
+ "ad1816 mixer",
+ ad1816mix_init,
+ ad1816mix_set,
+ ad1816mix_setrecsrc,
+};
+
+static devclass_t pcm_devclass;
+
+/* channel interface */
+static void *ad1816chan_init(void *devinfo, snd_dbuf *b, pcm_channel *c, int dir);
+static int ad1816chan_setdir(void *data, int dir);
+static int ad1816chan_setformat(void *data, u_int32_t format);
+static int ad1816chan_setspeed(void *data, u_int32_t speed);
+static int ad1816chan_setblocksize(void *data, u_int32_t blocksize);
+static int ad1816chan_trigger(void *data, int go);
+static int ad1816chan_getptr(void *data);
+static pcmchan_caps *ad1816chan_getcaps(void *data);
+
+static pcmchan_caps ad1816_caps = {
+ 4000, 55200,
+ AFMT_STEREO | AFMT_U8 | AFMT_S16_LE | AFMT_MU_LAW | AFMT_A_LAW,
+ AFMT_STEREO | AFMT_S16_LE
+};
+
+static pcm_channel ad1816_chantemplate = {
+ ad1816chan_init,
+ ad1816chan_setdir,
+ ad1816chan_setformat,
+ ad1816chan_setspeed,
+ ad1816chan_setblocksize,
+ ad1816chan_trigger,
+ ad1816chan_getptr,
+ ad1816chan_getcaps,
+};
+
+#define FULL_DUPLEX(x) (pcm_getflags(x) & SD_F_SIMPLEX)
+#define AD1816_MUTE 31 /* value for mute */
+
+static int
+port_rd(struct resource *port, int off)
+{
+ if (port)
+ return bus_space_read_1(rman_get_bustag(port),
+ rman_get_bushandle(port),
+ off);
+ else
+ return -1;
+}
+
+static void
+port_wr(struct resource *port, int off, u_int8_t data)
+{
+ if (port)
+ return bus_space_write_1(rman_get_bustag(port),
+ rman_get_bushandle(port),
+ off, data);
+}
+
+static int
+io_rd(struct ad1816_info *ad1816, int reg)
+{
+ return port_rd(ad1816->io_base, reg);
+}
+
+static void
+io_wr(struct ad1816_info *ad1816, int reg, u_int8_t data)
+{
+ return port_wr(ad1816->io_base, reg, data);
+}
+
+static void
+ad1816_intr(void *arg)
+{
+ struct ad1816_info *ad1816 = (struct ad1816_info *)arg;
+ unsigned char c, served = 0;
+
+ /* get interupt status */
+ c = io_rd(ad1816, AD1816_INT);
+
+ /* check for stray interupts */
+ if (c & ~(AD1816_INTRCI | AD1816_INTRPI)) {
+ printf("pcm: stray int (%x)\n", c);
+ c &= AD1816_INTRCI | AD1816_INTRPI;
+ }
+ /* check for capture interupt */
+ if (ad1816->rch.buffer->dl && (c & AD1816_INTRCI)) {
+ chn_intr(ad1816->rch.channel);
+ served |= AD1816_INTRCI; /* cp served */
+ }
+ /* check for playback interupt */
+ if (ad1816->pch.buffer->dl && (c & AD1816_INTRPI)) {
+ chn_intr(ad1816->pch.channel);
+ served |= AD1816_INTRPI; /* pb served */
+ }
+ if (served == 0) {
+ /* this probably means this is not a (working) ad1816 chip, */
+ /* or an error in dma handling */
+ printf("pcm: int without reason (%x)\n", c);
+ c = 0;
+ } else c &= ~served;
+ io_wr(ad1816, AD1816_INT, c);
+ c = io_rd(ad1816, AD1816_INT);
+ if (c != 0) printf("pcm: int clear failed (%x)\n", c);
+}
+
+static int
+ad1816_wait_init(struct ad1816_info *ad1816, int x)
+{
+ int n = 0; /* to shut up the compiler... */
+
+ for (; x--;)
+ if ((n = (io_rd(ad1816, AD1816_ALE) & AD1816_BUSY)) == 0) DELAY(10);
+ else return n;
+ printf("ad1816_wait_init failed 0x%02x.\n", n);
+ return -1;
+}
+
+static unsigned short
+ad1816_read(struct ad1816_info *ad1816, unsigned int reg)
+{
+ int flags;
+ u_short x = 0;
+
+ /* we don't want to be blocked here */
+ flags = spltty();
+ if (ad1816_wait_init(ad1816, 100) == -1) return 0;
+ io_wr(ad1816, AD1816_ALE, 0);
+ io_wr(ad1816, AD1816_ALE, (reg & AD1816_ALEMASK));
+ if (ad1816_wait_init(ad1816, 100) == -1) return 0;
+ x = (io_rd(ad1816, AD1816_HIGH) << 8) | io_rd(ad1816, AD1816_LOW);
+ splx(flags);
+ return x;
+}
+
+static void
+ad1816_write(struct ad1816_info *ad1816, unsigned int reg, unsigned short data)
+{
+ int flags;
+
+ flags = spltty();
+ if (ad1816_wait_init(ad1816, 100) == -1) return;
+ io_wr(ad1816, AD1816_ALE, (reg & AD1816_ALEMASK));
+ io_wr(ad1816, AD1816_LOW, (data & 0x000000ff));
+ io_wr(ad1816, AD1816_HIGH, (data & 0x0000ff00) >> 8);
+ splx(flags);
+}
+
+static int
+ad1816mix_init(snd_mixer *m)
+{
+ mix_setdevs(m, AD1816_MIXER_DEVICES);
+ mix_setrecdevs(m, AD1816_REC_DEVICES);
+ return 0;
+}
+
+static int
+ad1816mix_set(snd_mixer *m, unsigned dev, unsigned left, unsigned right)
+{
+ struct ad1816_info *ad1816 = mix_getdevinfo(m);
+ u_short reg = 0;
+
+ /* Scale volumes */
+ left = AD1816_MUTE - (AD1816_MUTE * left) / 100;
+ right = AD1816_MUTE - (AD1816_MUTE * right) / 100;
+
+ reg = (left << 8) | right;
+
+ /* do channel selective muting if volume is zero */
+ if (left == AD1816_MUTE) reg |= 0x8000;
+ if (right == AD1816_MUTE) reg |= 0x0080;
+
+ switch (dev) {
+ case SOUND_MIXER_VOLUME: /* Register 14 master volume */
+ ad1816_write(ad1816, 14, reg);
+ break;
+
+ case SOUND_MIXER_CD: /* Register 15 cd */
+ case SOUND_MIXER_LINE1:
+ ad1816_write(ad1816, 15, reg);
+ break;
+
+ case SOUND_MIXER_SYNTH: /* Register 16 synth */
+ ad1816_write(ad1816, 16, reg);
+ break;
+
+ case SOUND_MIXER_PCM: /* Register 4 pcm */
+ ad1816_write(ad1816, 4, reg);
+ break;
+
+ case SOUND_MIXER_LINE:
+ case SOUND_MIXER_LINE3: /* Register 18 line in */
+ ad1816_write(ad1816, 18, reg);
+ break;
+
+ case SOUND_MIXER_MIC: /* Register 19 mic volume */
+ ad1816_write(ad1816, 19, reg & ~0xff); /* mic is mono */
+ break;
+
+ case SOUND_MIXER_IGAIN:
+ /* and now to something completely different ... */
+ ad1816_write(ad1816, 20, ((ad1816_read(ad1816, 20) & ~0x0f0f)
+ | (((AD1816_MUTE - left) / 2) << 8) /* four bits of adc gain */
+ | ((AD1816_MUTE - right) / 2)));
+ break;
+
+ default:
+ printf("ad1816_mixer_set(): unknown device.\n");
+ break;
+ }
+
+ return left | (right << 8);
+}
+
+static int
+ad1816mix_setrecsrc(snd_mixer *m, u_int32_t src)
+{
+ struct ad1816_info *ad1816 = mix_getdevinfo(m);
+ int dev;
+
+ switch (src) {
+ case SOUND_MASK_LINE:
+ case SOUND_MASK_LINE3:
+ dev = 0x00;
+ break;
+
+ case SOUND_MASK_CD:
+ case SOUND_MASK_LINE1:
+ dev = 0x20;
+ break;
+
+ case SOUND_MASK_MIC:
+ default:
+ dev = 0x50;
+ src = SOUND_MASK_MIC;
+ }
+
+ dev |= dev << 8;
+ ad1816_write(ad1816, 20, (ad1816_read(ad1816, 20) & ~0x7070) | dev);
+ return src;
+}
+
+/* channel interface */
+static void *
+ad1816chan_init(void *devinfo, snd_dbuf *b, pcm_channel *c, int dir)
+{
+ struct ad1816_info *ad1816 = devinfo;
+ struct ad1816_chinfo *ch = (dir == PCMDIR_PLAY)? &ad1816->pch : &ad1816->rch;
+
+ ch->parent = ad1816;
+ ch->channel = c;
+ ch->buffer = b;
+ ch->buffer->bufsize = DSP_BUFFSIZE;
+ if (chn_allocbuf(ch->buffer, ad1816->parent_dmat) == -1) return NULL;
+ return ch;
+}
+
+static int
+ad1816chan_setdir(void *data, int dir)
+{
+ struct ad1816_chinfo *ch = data;
+ struct ad1816_info *ad1816 = ch->parent;
+
+ ch->buffer->chan = rman_get_start((dir == PCMDIR_PLAY)?
+ ad1816->drq1 : ad1816->drq2);
+ ch->dir = dir;
+ return 0;
+}
+
+static int
+ad1816chan_setformat(void *data, u_int32_t format)
+{
+ struct ad1816_chinfo *ch = data;
+ struct ad1816_info *ad1816 = ch->parent;
+
+ int fmt = AD1816_U8, reg;
+ if (ch->dir == PCMDIR_PLAY) {
+ reg = AD1816_PLAY;
+ ad1816_write(ad1816, 8, 0x0000); /* reset base and current counter */
+ ad1816_write(ad1816, 9, 0x0000); /* for playback and capture */
+ } else {
+ reg = AD1816_CAPT;
+ ad1816_write(ad1816, 10, 0x0000);
+ ad1816_write(ad1816, 11, 0x0000);
+ }
+ switch (format & ~AFMT_STEREO) {
+ case AFMT_A_LAW:
+ fmt = AD1816_ALAW;
+ break;
+
+ case AFMT_MU_LAW:
+ fmt = AD1816_MULAW;
+ break;
+
+ case AFMT_S16_LE:
+ fmt = AD1816_S16LE;
+ break;
+
+ case AFMT_S16_BE:
+ fmt = AD1816_S16BE;
+ break;
+
+ case AFMT_U8:
+ fmt = AD1816_U8;
+ break;
+ }
+ if (format & AFMT_STEREO) fmt |= AD1816_STEREO;
+ io_wr(ad1816, reg, fmt);
+ return format;
+}
+
+static int
+ad1816chan_setspeed(void *data, u_int32_t speed)
+{
+ struct ad1816_chinfo *ch = data;
+ struct ad1816_info *ad1816 = ch->parent;
+
+ RANGE(speed, 4000, 55200);
+ ad1816_write(ad1816, (ch->dir == PCMDIR_PLAY)? 2 : 3, speed);
+ return speed;
+}
+
+static int
+ad1816chan_setblocksize(void *data, u_int32_t blocksize)
+{
+ return blocksize;
+}
+
+static int
+ad1816chan_trigger(void *data, int go)
+{
+ struct ad1816_chinfo *ch = data;
+ struct ad1816_info *ad1816 = ch->parent;
+ int wr, reg;
+
+ buf_isadma(ch->buffer, go);
+ wr = (ch->dir == PCMDIR_PLAY);
+ reg = wr? AD1816_PLAY : AD1816_CAPT;
+ switch (go) {
+ case PCMTRIG_START:
+ /* start only if not already running */
+ if (!(io_rd(ad1816, reg) & AD1816_ENABLE)) {
+ int cnt = ((ch->buffer->dl) >> 2) - 1;
+ ad1816_write(ad1816, wr? 8 : 10, cnt); /* count */
+ ad1816_write(ad1816, 1, ad1816_read(ad1816, 1) |
+ (wr? 0x8000 : 0x4000)); /* enable int */
+ /* enable playback */
+ io_wr(ad1816, reg, io_rd(ad1816, reg) | AD1816_ENABLE);
+ if (!(io_rd(ad1816, reg) & AD1816_ENABLE))
+ printf("ad1816: failed to start %s DMA!\n",
+ wr? "play" : "rec");
+ }
+ break;
+
+ case PCMTRIG_STOP:
+ case PCMTRIG_ABORT: /* XXX check this... */
+ /* we don't test here if it is running... */
+ if (wr) {
+ ad1816_write(ad1816, 1, ad1816_read(ad1816, 1) &
+ ~(wr? 0x8000 : 0x4000));
+ /* disable int */
+ io_wr(ad1816, reg, io_rd(ad1816, reg) & ~AD1816_ENABLE);
+ /* disable playback */
+ if (io_rd(ad1816, reg) & AD1816_ENABLE)
+ printf("ad1816: failed to stop %s DMA!\n",
+ wr? "play" : "rec");
+ ad1816_write(ad1816, wr? 8 : 10, 0); /* reset base cnt */
+ ad1816_write(ad1816, wr? 9 : 11, 0); /* reset cur cnt */
+ }
+ break;
+ }
+ return 0;
+}
+
+static int
+ad1816chan_getptr(void *data)
+{
+ struct ad1816_chinfo *ch = data;
+ return buf_isadmaptr(ch->buffer);
+}
+
+static pcmchan_caps *
+ad1816chan_getcaps(void *data)
+{
+ return &ad1816_caps;
+}
+
+static void
+ad1816_release_resources(struct ad1816_info *ad1816, device_t dev)
+{
+ if (ad1816->irq) {
+ bus_release_resource(dev, SYS_RES_IRQ, ad1816->irq_rid,
+ ad1816->irq);
+ ad1816->irq = 0;
+ }
+ if (ad1816->drq1) {
+ bus_release_resource(dev, SYS_RES_DRQ, ad1816->drq1_rid,
+ ad1816->drq1);
+ ad1816->drq1 = 0;
+ }
+ if (ad1816->drq2) {
+ bus_release_resource(dev, SYS_RES_DRQ, ad1816->drq2_rid,
+ ad1816->drq2);
+ ad1816->drq2 = 0;
+ }
+ if (ad1816->io_base) {
+ bus_release_resource(dev, SYS_RES_IOPORT, ad1816->io_rid,
+ ad1816->io_base);
+ ad1816->io_base = 0;
+ }
+ free(ad1816, M_DEVBUF);
+}
+
+static int
+ad1816_alloc_resources(struct ad1816_info *ad1816, device_t dev)
+{
+ int ok = 1, pdma, rdma;
+ if (!ad1816->io_base)
+ ad1816->io_base = bus_alloc_resource(dev, SYS_RES_IOPORT, &ad1816->io_rid,
+ 0, ~0, 1, RF_ACTIVE);
+ if (!ad1816->irq)
+ ad1816->irq = bus_alloc_resource(dev, SYS_RES_IRQ, &ad1816->irq_rid,
+ 0, ~0, 1, RF_ACTIVE);
+ if (!ad1816->drq1)
+ ad1816->drq1 = bus_alloc_resource(dev, SYS_RES_DRQ, &ad1816->drq1_rid,
+ 0, ~0, 1, RF_ACTIVE);
+ if (ad1816->drq2_rid >= 0 && !ad1816->drq2)
+ ad1816->drq2 = bus_alloc_resource(dev, SYS_RES_DRQ, &ad1816->drq2_rid,
+ 0, ~0, 1, RF_ACTIVE);
+
+ if (!ad1816->io_base || !ad1816->drq1 || !ad1816->irq) ok = 0;
+ if (ad1816->drq2_rid >= 0 && !ad1816->drq2) ok = 0;
+
+ if (ok) {
+ pdma = rman_get_start(ad1816->drq1);
+ isa_dma_acquire(pdma);
+ isa_dmainit(pdma, DSP_BUFFSIZE);
+ if (ad1816->drq2) {
+ rdma = rman_get_start(ad1816->drq2);
+ isa_dma_acquire(rdma);
+ isa_dmainit(rdma, DSP_BUFFSIZE);
+ } else rdma = pdma;
+ if (pdma == rdma)
+ pcm_setflags(dev, pcm_getflags(dev) | SD_F_SIMPLEX);
+ }
+ return ok;
+}
+
+static int
+ad1816_init(struct ad1816_info *ad1816, device_t dev)
+{
+ ad1816_write(ad1816, 1, 0x2); /* disable interrupts */
+ ad1816_write(ad1816, 32, 0x90F0); /* SoundSys Mode, split fmt */
+
+ ad1816_write(ad1816, 5, 0x8080); /* FM volume mute */
+ ad1816_write(ad1816, 6, 0x8080); /* I2S1 volume mute */
+ ad1816_write(ad1816, 7, 0x8080); /* I2S0 volume mute */
+ ad1816_write(ad1816, 17, 0x8888); /* VID Volume mute */
+ ad1816_write(ad1816, 20, 0x5050); /* recsrc mic, agc off */
+ /* adc gain is set to 0 */
+
+ return 0;
+}
+
+static int
+ad1816_probe(device_t dev)
+{
+ char *s = NULL;
+ u_int32_t logical_id = isa_get_logicalid(dev);
+
+ switch (logical_id) {
+ case 0x80719304: /* ADS7180 */
+ s = "Terratec Soundsystem BASE 1";
+ break;
+ }
+
+ if (s) {
+ device_set_desc(dev, s);
+ return 0;
+ }
+ return ENXIO;
+}
+
+static int
+ad1816_attach(device_t dev)
+{
+ struct ad1816_info *ad1816;
+ snddev_info *d = device_get_softc(dev);
+ void *ih;
+ char status[SND_STATUSLEN];
+
+ ad1816 = (struct ad1816_info *)malloc(sizeof *ad1816, M_DEVBUF, M_NOWAIT);
+ if (!ad1816) return ENXIO;
+ bzero(ad1816, sizeof *ad1816);
+
+ ad1816->io_rid = 2;
+ ad1816->irq_rid = 0;
+ ad1816->drq1_rid = 0;
+ ad1816->drq2_rid = 1;
+
+ if (!ad1816_alloc_resources(ad1816, dev)) goto no;
+ ad1816_init(ad1816, dev);
+ mixer_init(d, &ad1816_mixer, ad1816);
+ bus_setup_intr(dev, ad1816->irq, INTR_TYPE_TTY, ad1816_intr, ad1816, &ih);
+ if (bus_dma_tag_create(/*parent*/NULL, /*alignment*/2, /*boundary*/0,
+ /*lowaddr*/BUS_SPACE_MAXADDR_24BIT,
+ /*highaddr*/BUS_SPACE_MAXADDR,
+ /*filter*/NULL, /*filterarg*/NULL,
+ /*maxsize*/DSP_BUFFSIZE, /*nsegments*/1,
+ /*maxsegz*/0x3ffff,
+ /*flags*/0, &ad1816->parent_dmat) != 0) {
+ device_printf(dev, "unable to create dma tag\n");
+ goto no;
+ }
+ snprintf(status, SND_STATUSLEN, "at io 0x%lx irq %ld drq %ld",
+ rman_get_start(ad1816->io_base),
+ rman_get_start(ad1816->irq),
+ rman_get_start(ad1816->drq1));
+ if (FULL_DUPLEX(dev)) snprintf(status + strlen(status),
+ SND_STATUSLEN - strlen(status), ":%ld",
+ rman_get_start(ad1816->drq1));
+
+ if (pcm_register(dev, ad1816, 1, 1)) goto no;
+ pcm_addchan(dev, PCMDIR_REC, &ad1816_chantemplate, ad1816);
+ pcm_addchan(dev, PCMDIR_PLAY, &ad1816_chantemplate, ad1816);
+ pcm_setstatus(dev, status);
+
+ return 0;
+no:
+ ad1816_release_resources(ad1816, dev);
+ return ENXIO;
+
+}
+
+static device_method_t ad1816_methods[] = {
+ /* Device interface */
+ DEVMETHOD(device_probe, ad1816_probe),
+ DEVMETHOD(device_attach, ad1816_attach),
+
+ { 0, 0 }
+};
+
+static driver_t ad1816_driver = {
+ "pcm",
+ ad1816_methods,
+ sizeof(snddev_info),
+};
+
+DRIVER_MODULE(mss, isa, ad1816_driver, pcm_devclass, 0, 0);
+
+#endif
diff --git a/sys/dev/pcm/isa/ad1816.h b/sys/dev/pcm/isa/ad1816.h
new file mode 100755
index 0000000..078523f
--- /dev/null
+++ b/sys/dev/pcm/isa/ad1816.h
@@ -0,0 +1,71 @@
+/*
+ * (C) 1997 Luigi Rizzo (luigi@iet.unipi.it)
+ *
+ * This file contains information and macro definitions for
+ * the ad1816 chip
+ *
+ * $FreeBSD$
+ */
+
+/* AD1816 register macros */
+
+#define AD1816_ALE 0 /* indirect reg access */
+#define AD1816_INT 1 /* interupt status */
+#define AD1816_LOW 2 /* indirect low byte */
+#define AD1816_HIGH 3 /* indirect high byte */
+
+#if 0
+#define ad1816_pioD(d) ((d)->io_base+4) /* PIO debug */
+#define ad1816_pios(d) ((d)->io_base+5) /* PIO status */
+#define ad1816_piod(d) ((d)->io_base+6) /* PIO data */
+#endif
+
+/* values for playback/capture config:
+ bits: 0 enable/disable
+ 1 pio/dma
+ 2 stereo/mono
+ 3 companded/linearPCM
+ 4-5 format : 00 8bit linear (uncomp)
+ 00 8bit mulaw (comp)
+ 01 16bit le (uncomp)
+ 01 8bit alaw (comp)
+ 11 16bit be (uncomp)
+*/
+
+#define AD1816_PLAY 8 /* playback config */
+#define AD1816_CAPT 9 /* capture config */
+
+#define AD1816_BUSY 0x80 /* chip is busy */
+#define AD1816_ALEMASK 0x3F /* mask for indirect adr. */
+
+#if 0
+#define AD1816_INTRSI 0x01 /* sb intr */
+#define AD1816_INTRGI 0x02 /* game intr */
+#define AD1816_INTRRI 0x04 /* ring intr */
+#define AD1816_INTRDI 0x08 /* dsp intr */
+#define AD1816_INTRVI 0x10 /* vol intr */
+#define AD1816_INTRTI 0x20 /* timer intr */
+#endif
+
+#define AD1816_INTRCI 0x40 /* capture intr */
+#define AD1816_INTRPI 0x80 /* playback intr */
+/* PIO stuff is not supplied here */
+/* playback / capture config */
+#define AD1816_ENABLE 0x01 /* enable pl/cp */
+#define AD1816_PIO 0x02 /* use pio */
+#define AD1816_STEREO 0x04
+#define AD1816_COMP 0x08 /* data is companded */
+#define AD1816_U8 0x00 /* 8 bit linear pcm */
+#define AD1816_MULAW 0x08 /* 8 bit mulaw */
+#define AD1816_ALAW 0x18 /* 8 bit alaw */
+#define AD1816_S16LE 0x10 /* 16 bit linear little endian */
+#define AD1816_S16BE 0x30 /* 16 bit linear big endian */
+#define AD1816_FORMASK 0x38 /* format mask */
+
+#define AD1816_REC_DEVICES \
+ (SOUND_MASK_LINE | SOUND_MASK_MIC | SOUND_MASK_CD)
+
+#define AD1816_MIXER_DEVICES \
+ (SOUND_MASK_VOLUME | SOUND_MASK_PCM | SOUND_MASK_SYNTH | \
+ SOUND_MASK_LINE | SOUND_MASK_MIC | SOUND_MASK_CD | SOUND_MASK_IGAIN)
+
diff --git a/sys/dev/pcm/isa/mss.c b/sys/dev/pcm/isa/mss.c
index 39bb2a6..43e3f90 100644
--- a/sys/dev/pcm/isa/mss.c
+++ b/sys/dev/pcm/isa/mss.c
@@ -94,16 +94,6 @@ static int pnpmss_probe(device_t dev);
static int pnpmss_attach(device_t dev);
static driver_intr_t opti931_intr;
-static driver_intr_t ad1816_intr;
-
-/* IO primitives */
-static int ad1816_wait_init(struct mss_info *mss, int x);
-static u_short ad1816_read(struct mss_info *mss, u_int reg);
-static void ad1816_write(struct mss_info *mss, u_int reg, u_short data);
-
-/* mixer set functions */
-static int ad1816_mixer_set(struct mss_info *mss, int dev, int left, int right);
-static int ad1816_set_recsrc(struct mss_info *mss, int mask);
#endif
static int mssmix_init(snd_mixer *m);
@@ -144,12 +134,6 @@ static pcmchan_caps mss_caps = {
AFMT_STEREO | AFMT_S16_LE
};
-static pcmchan_caps ad1816_caps = {
- 4000, 55200,
- AFMT_STEREO | AFMT_U8 | AFMT_S16_LE | AFMT_MU_LAW | AFMT_A_LAW,
- AFMT_STEREO | AFMT_S16_LE
-};
-
static pcmchan_caps guspnp_caps = {
4000, 48000,
AFMT_STEREO | AFMT_U8 | AFMT_S16_LE | AFMT_A_LAW,
@@ -157,7 +141,7 @@ static pcmchan_caps guspnp_caps = {
};
static pcmchan_caps opti931_caps = {
- 4000, 4800,
+ 4000, 48000,
AFMT_STEREO | AFMT_U8 | AFMT_S16_LE,
AFMT_STEREO | AFMT_S16_LE
};
@@ -175,7 +159,6 @@ static pcm_channel mss_chantemplate = {
#define MD_AD1848 0x91
#define MD_AD1845 0x92
-#define MD_AD1816 0x93
#define MD_CS4248 0xA1
#define MD_CS4231 0xA2
#define MD_CS4231A 0xA3
@@ -332,6 +315,10 @@ mss_alloc_resources(struct mss_info *mss, device_t dev)
static int
mss_init(struct mss_info *mss, device_t dev)
{
+ u_char r6, r9;
+ struct resource *alt;
+ int rid, tmp;
+
mss->bd_flags |= BD_F_MCE_BIT;
switch(mss->bd_id) {
#if NPNP > 0
@@ -343,10 +330,6 @@ mss_init(struct mss_info *mss, device_t dev)
break;
case MD_GUSPNP:
- {
- struct resource *alt;
- int rid, tmp;
-
gus_wr(mss, 0x4c /* _URSTI */, 0);/* Pull reset */
DELAY(1000 * 30);
/* release reset and enable DAC */
@@ -378,24 +361,9 @@ mss_init(struct mss_info *mss, device_t dev)
gus_wr(mss, 0x5b, tmp | 1);
BVDDB(printf("GUS: silicon rev %c\n", 'A' + ((tmp & 0xf) >> 4)));
break;
- }
-
- case MD_AD1816:
- ad1816_write(mss, 1, 0x2); /* disable interrupts */
- ad1816_write(mss, 32, 0x90F0); /* SoundSys Mode, split fmt */
-
- ad1816_write(mss, 5, 0x8080); /* FM volume mute */
- ad1816_write(mss, 6, 0x8080); /* I2S1 volume mute */
- ad1816_write(mss, 7, 0x8080); /* I2S0 volume mute */
- ad1816_write(mss, 17, 0x8888); /* VID Volume mute */
- ad1816_write(mss, 20, 0x5050); /* recsrc mic, agc off */
- /* adc gain is set to 0 */
- break;
#endif
case MD_YM0020:
- {
- u_char r6, r9;
- conf_wr(mss, OPL3SAx_DMACONF, 0xa9); /* dma-b rec, dma-a play */
+ conf_wr(mss, OPL3SAx_DMACONF, 0xa9); /* dma-b rec, dma-a play */
r6 = conf_rd(mss, OPL3SAx_DMACONF);
r9 = conf_rd(mss, OPL3SAx_MISC); /* version */
BVDDB(printf("Yamaha: ver 0x%x DMA config 0x%x\n", r6, r9);)
@@ -404,8 +372,7 @@ mss_init(struct mss_info *mss, device_t dev)
conf_wr(mss, OPL3SAx_VOLUMER, 0);
conf_wr(mss, OPL3SAx_DMACONF, FULL_DUPLEX(mss)? 0xa9 : 0x8b);
break;
- }
- }
+ }
if (FULL_DUPLEX(mss) && mss->bd_id != MD_OPTI931)
ad_write(mss, 12, ad_read(mss, 12) | 0x40); /* mode 2 */
ad_write(mss, 9, FULL_DUPLEX(mss)? 0 : 4);
@@ -500,12 +467,13 @@ mss_probe(device_t dev)
if (tmpx & 0x80) {
/* 8-bit board: only drq1/3 and irq7/9 */
if (drq == 0) {
- printf("MSS: Can't use DMA0 with a 8 bit card/slot\n");
- goto no;
+ printf("MSS: Can't use DMA0 with a 8 bit card/slot\n");
+ goto no;
}
if (!(irq == 7 || irq == 9)) {
- printf("MSS: Can't use IRQ%d with a 8 bit card/slot\n", irq);
- goto no;
+ printf("MSS: Can't use IRQ%d with a 8 bit card/slot\n",
+ irq);
+ goto no;
}
}
mss_probe_end:
@@ -821,10 +789,6 @@ mss_doattach(device_t dev, struct mss_info *mss)
mixer_init(d, (mss->bd_id == MD_YM0020)? &yamaha_mixer : &mss_mixer, mss);
switch (mss->bd_id) {
#if NPNP > 0
- case MD_AD1816:
- bus_setup_intr(dev, mss->irq, INTR_TYPE_TTY, ad1816_intr, mss, &ih);
- break;
-
case MD_OPTI931:
bus_setup_intr(dev, mss->irq, INTR_TYPE_TTY, opti931_intr, mss, &ih);
break;
@@ -981,6 +945,7 @@ ad_read(struct mss_info *mss, int reg)
io_wr(mss, MSS_INDEX, (u_char)(reg & MSS_IDXMASK) | x);
x = io_rd(mss, MSS_IDATA);
splx(flags);
+ /* printf("ad_read %d, %x\n", reg, x); */
return x;
}
@@ -990,6 +955,7 @@ ad_write(struct mss_info *mss, int reg, u_char data)
u_long flags;
int x;
+ /* printf("ad_write %d, %x\n", reg, data); */
flags = spltty();
ad_wait_init(mss, 1002);
x = io_rd(mss, MSS_INDEX) & ~MSS_IDXMASK;
@@ -1141,12 +1107,6 @@ mss_mixer_set(struct mss_info *mss, int dev, int left, int right)
return 0; /* success */
}
-/* mss_speed processes the value in play_speed finding the
- * matching one. As a side effect, it returns the value to
- * be written in the speed bits of the codec. It does _NOT_
- * set the speed of the device (but it should!)
- */
-
static int
mss_speed(struct mss_chinfo *ch, int speed)
{
@@ -1339,12 +1299,6 @@ pnpmss_attach(device_t dev)
mss->drq2_rid = 1;
switch (vend_id & 0xff00ffff) {
- case 0x1100b250: /* terratec */
- case 0x50009304: /* generic ad1815 */
- mss->io_rid = 2;
- mss->bd_id = MD_AD1816;
- break;
-
case 0x2000a865: /* Yamaha SA2 */
case 0x3000a865: /* Yamaha SA3 */
case 0x0000a865: /* Yamaha YMF719 SA3 */
@@ -1371,7 +1325,6 @@ pnpmss_attach(device_t dev)
break;
case 0x3100143e: /* opti931 */
- case 0x1093143e: /* OPT9310 */
mss->bd_flags |= BD_F_MSS_OFFSET;
mss->conf_rid = 3;
mss->bd_id = MD_OPTI931;
@@ -1473,267 +1426,6 @@ opti931_intr(void *arg)
DEB(printf("xxx too many loops\n");)
}
-static void
-ad1816_intr(void *arg)
-{
- struct mss_info *mss = (struct mss_info *)arg;
- unsigned char c, served = 0;
-
- /* get interupt status */
- c = io_rd(mss, AD1816_INT);
-
- /* check for stray interupts */
- if (c & ~(AD1816_INTRCI | AD1816_INTRPI)) {
- printf("pcm: stray int (%x)\n", c);
- c &= AD1816_INTRCI | AD1816_INTRPI;
- }
- /* check for capture interupt */
- if (mss->rch.buffer->dl && (c & AD1816_INTRCI)) {
- chn_intr(mss->rch.channel);
- served |= AD1816_INTRCI; /* cp served */
- }
- /* check for playback interupt */
- if (mss->pch.buffer->dl && (c & AD1816_INTRPI)) {
- chn_intr(mss->pch.channel);
- served |= AD1816_INTRPI; /* pb served */
- }
- if (served == 0) {
- /* this probably means this is not a (working) ad1816 chip, */
- /* or an error in dma handling */
- printf("pcm: int without reason (%x)\n", c);
- c = 0;
- } else c &= ~served;
- io_wr(mss, AD1816_INT, c);
- c = io_rd(mss, AD1816_INT);
- if (c != 0) printf("pcm: int clear failed (%x)\n", c);
-}
-
-static int
-ad1816_wait_init(struct mss_info *mss, int x)
-{
- int n = 0; /* to shut up the compiler... */
-
- for (; x--;)
- if ((n = (io_rd(mss, AD1816_ALE) & AD1816_BUSY)) == 0) DELAY(10);
- else return n;
- printf("ad1816_wait_init failed 0x%02x.\n", n);
- return -1;
-}
-
-static unsigned short
-ad1816_read(struct mss_info *mss, unsigned int reg)
-{
- int flags;
- u_short x = 0;
-
- /* we don't want to be blocked here */
- flags = spltty();
- if (ad1816_wait_init(mss, 100) == -1) return 0;
- io_wr(mss, AD1816_ALE, 0);
- io_wr(mss, AD1816_ALE, (reg & AD1816_ALEMASK));
- if (ad1816_wait_init(mss, 100) == -1) return 0;
- x = (io_rd(mss, AD1816_HIGH) << 8) | io_rd(mss, AD1816_LOW);
- splx(flags);
- return x;
-}
-
-static void
-ad1816_write(struct mss_info *mss, unsigned int reg, unsigned short data)
-{
- int flags;
-
- flags = spltty();
- if (ad1816_wait_init(mss, 100) == -1) return;
- io_wr(mss, AD1816_ALE, (reg & AD1816_ALEMASK));
- io_wr(mss, AD1816_LOW, (data & 0x000000ff));
- io_wr(mss, AD1816_HIGH, (data & 0x0000ff00) >> 8);
- splx(flags);
-}
-
-/* only one rec source is possible */
-static int
-ad1816_set_recsrc(struct mss_info *mss, int mask)
-{
- int dev;
-
- switch (mask) {
- case SOUND_MASK_LINE:
- case SOUND_MASK_LINE3:
- dev = 0x00;
- break;
-
- case SOUND_MASK_CD:
- case SOUND_MASK_LINE1:
- dev = 0x20;
- break;
-
- case SOUND_MASK_MIC:
- default:
- dev = 0x50;
- mask = SOUND_MASK_MIC;
- }
-
- dev |= dev << 8;
- ad1816_write(mss, 20, (ad1816_read(mss, 20) & ~0x7070) | dev);
- return mask;
-}
-
-#define AD1816_MUTE 31 /* value for mute */
-
-static int
-ad1816_mixer_set(struct mss_info *mss, int dev, int left, int right)
-{
- u_short reg = 0;
-
- /* Scale volumes */
- left = AD1816_MUTE - (AD1816_MUTE * left) / 100;
- right = AD1816_MUTE - (AD1816_MUTE * right) / 100;
-
- reg = (left << 8) | right;
-
- /* do channel selective muting if volume is zero */
- if (left == AD1816_MUTE) reg |= 0x8000;
- if (right == AD1816_MUTE) reg |= 0x0080;
-
- switch (dev) {
- case SOUND_MIXER_VOLUME: /* Register 14 master volume */
- ad1816_write(mss, 14, reg);
- break;
-
- case SOUND_MIXER_CD: /* Register 15 cd */
- case SOUND_MIXER_LINE1:
- ad1816_write(mss, 15, reg);
- break;
-
- case SOUND_MIXER_SYNTH: /* Register 16 synth */
- ad1816_write(mss, 16, reg);
- break;
-
- case SOUND_MIXER_PCM: /* Register 4 pcm */
- ad1816_write(mss, 4, reg);
- break;
-
- case SOUND_MIXER_LINE:
- case SOUND_MIXER_LINE3: /* Register 18 line in */
- ad1816_write(mss, 18, reg);
- break;
-
- case SOUND_MIXER_MIC: /* Register 19 mic volume */
- ad1816_write(mss, 19, reg & ~0xff); /* mic is mono */
- break;
-
- case SOUND_MIXER_IGAIN:
- /* and now to something completely different ... */
- ad1816_write(mss, 20, ((ad1816_read(mss, 20) & ~0x0f0f)
- | (((AD1816_MUTE - left) / 2) << 8) /* four bits of adc gain */
- | ((AD1816_MUTE - right) / 2)));
- break;
-
- default:
- printf("ad1816_mixer_set(): unknown device.\n");
- break;
- }
-
- return 0; /* success */
-}
-
-static int
-ad1816_trigger(struct mss_chinfo *ch, int go)
-{
- int wr, reg;
- struct mss_info *mss = ch->parent;
-
- wr = (ch->dir == PCMDIR_PLAY);
- reg = wr? AD1816_PLAY : AD1816_CAPT;
-
- switch (go) {
- case PCMTRIG_START:
- /* start only if not already running */
- if (!(io_rd(mss, reg) & AD1816_ENABLE)) {
- int cnt = ((ch->buffer->dl) >> 2) - 1;
- ad1816_write(mss, wr? 8 : 10, cnt); /* count */
- ad1816_write(mss, 1, ad1816_read(mss, 1) |
- (wr? 0x8000 : 0x4000)); /* enable int */
- /* enable playback */
- io_wr(mss, reg, io_rd(mss, reg) | AD1816_ENABLE);
- if (!(io_rd(mss, reg) & AD1816_ENABLE))
- printf("ad1816: failed to start %s DMA!\n",
- wr? "play" : "rec");
- }
- break;
-
- case PCMTRIG_STOP:
- case PCMTRIG_ABORT: /* XXX check this... */
- /* we don't test here if it is running... */
- if (wr) {
- ad1816_write(mss, 1, ad1816_read(mss, 1) &
- ~(wr? 0x8000 : 0x4000));
- /* disable int */
- io_wr(mss, reg, io_rd(mss, reg) & ~AD1816_ENABLE);
- /* disable playback */
- if (io_rd(mss, reg) & AD1816_ENABLE)
- printf("ad1816: failed to stop %s DMA!\n",
- wr? "play" : "rec");
- ad1816_write(mss, wr? 8 : 10, 0); /* reset base cnt */
- ad1816_write(mss, wr? 9 : 11, 0); /* reset cur cnt */
- }
- break;
- }
- return 0;
-}
-
-
-static int
-ad1816_speed(struct mss_chinfo *ch, u_int32_t speed)
-{
- struct mss_info *mss = ch->parent;
-
- RANGE(speed, 4000, 55200);
- ad1816_write(mss, (ch->dir == PCMDIR_PLAY)? 2 : 3, speed);
- return speed;
-}
-
-static int
-ad1816_format(struct mss_chinfo *ch, u_int32_t format)
-{
- struct mss_info *mss = ch->parent;
-
- int fmt = AD1816_U8, reg;
- if (ch->dir == PCMDIR_PLAY) {
- reg = AD1816_PLAY;
- ad1816_write(mss, 8, 0x0000); /* reset base and current counter */
- ad1816_write(mss, 9, 0x0000); /* for playback and capture */
- } else {
- reg = AD1816_CAPT;
- ad1816_write(mss, 10, 0x0000);
- ad1816_write(mss, 11, 0x0000);
- }
- switch (format & ~AFMT_STEREO) {
- case AFMT_A_LAW:
- fmt = AD1816_ALAW;
- break;
-
- case AFMT_MU_LAW:
- fmt = AD1816_MULAW;
- break;
-
- case AFMT_S16_LE:
- fmt = AD1816_S16LE;
- break;
-
- case AFMT_S16_BE:
- fmt = AD1816_S16BE;
- break;
-
- case AFMT_U8:
- fmt = AD1816_U8;
- break;
- }
- if (format & AFMT_STEREO) fmt |= AD1816_STEREO;
- io_wr(mss, reg, fmt);
- return format;
-}
-
#endif /* NPNP > 0 */
static int
@@ -1744,11 +1436,6 @@ mssmix_init(snd_mixer *m)
mix_setdevs(m, MODE2_MIXER_DEVICES);
mix_setrecdevs(m, MSS_REC_DEVICES);
switch(mss->bd_id) {
- case MD_AD1816:
- mix_setdevs(m, AD1816_MIXER_DEVICES);
- mix_setrecdevs(m, AD1816_REC_DEVICES);
- break;
-
case MD_OPTI931:
mix_setdevs(m, OPTI931_MIXER_DEVICES);
ad_write(mss, 20, 0x88);
@@ -1773,9 +1460,6 @@ mssmix_set(snd_mixer *m, unsigned dev, unsigned left, unsigned right)
{
struct mss_info *mss = mix_getdevinfo(m);
-#if NPNP > 0
- if (mss->bd_id == MD_AD1816) ad1816_mixer_set(mss, dev, left, right); else
-#endif
mss_mixer_set(mss, dev, left, right);
return left | (right << 8);
@@ -1786,9 +1470,6 @@ mssmix_setrecsrc(snd_mixer *m, u_int32_t src)
{
struct mss_info *mss = mix_getdevinfo(m);
-#if NPNP > 0
- if (mss->bd_id == MD_AD1816) src = ad1816_set_recsrc(mss, src); else
-#endif
src = mss_set_recsrc(mss, src);
return src;
}
@@ -1879,9 +1560,6 @@ msschan_setformat(void *data, u_int32_t format)
{
struct mss_chinfo *ch = data;
-#if NPNP > 0
- if (ch->parent->bd_id == MD_AD1816) ad1816_format(ch, format); else
-#endif
mss_format(ch, format);
return 0;
}
@@ -1891,9 +1569,6 @@ msschan_setspeed(void *data, u_int32_t speed)
{
struct mss_chinfo *ch = data;
-#if NPNP > 0
- if (ch->parent->bd_id == MD_AD1816) return ad1816_speed(ch, speed); else
-#endif
return mss_speed(ch, speed);
}
@@ -1909,9 +1584,6 @@ msschan_trigger(void *data, int go)
struct mss_chinfo *ch = data;
buf_isadma(ch->buffer, go);
-#if NPNP > 0
- if (ch->parent->bd_id == MD_AD1816) ad1816_trigger(ch, go); else
-#endif
mss_trigger(ch, go);
return 0;
}
@@ -1937,10 +1609,6 @@ msschan_getcaps(void *data)
return &guspnp_caps;
break;
- case MD_AD1816:
- return &ad1816_caps;
- break;
-
default:
return &mss_caps;
break;
diff --git a/sys/dev/pcm/isa/mss.h b/sys/dev/pcm/isa/mss.h
index 8db435e..a0a35bb 100644
--- a/sys/dev/pcm/isa/mss.h
+++ b/sys/dev/pcm/isa/mss.h
@@ -108,64 +108,6 @@ ahead.
#define BD_F_MSS_OFFSET 0x0008 /* offset mss writes by -4 */
#define BD_F_DUPLEX 0x0010
-/* AD1816 register macros */
-
-#define AD1816_ALE 0 /* indirect reg access */
-#define AD1816_INT 1 /* interupt status */
-#define AD1816_LOW 2 /* indirect low byte */
-#define AD1816_HIGH 3 /* indirect high byte */
-
-#if 0
-#define ad1816_pioD(d) ((d)->io_base+4) /* PIO debug */
-#define ad1816_pios(d) ((d)->io_base+5) /* PIO status */
-#define ad1816_piod(d) ((d)->io_base+6) /* PIO data */
-#endif
-
-/* values for playback/capture config:
- bits: 0 enable/disable
- 1 pio/dma
- 2 stereo/mono
- 3 companded/linearPCM
- 4-5 format : 00 8bit linear (uncomp)
- 00 8bit mulaw (comp)
- 01 16bit le (uncomp)
- 01 8bit alaw (comp)
- 11 16bit be (uncomp)
-*/
-
-#define AD1816_PLAY 8 /* playback config */
-#define AD1816_CAPT 9 /* capture config */
-
-#define AD1816_BUSY 0x80 /* chip is busy */
-#define AD1816_ALEMASK 0x3F /* mask for indirect adr. */
-
-#if 0
-#define AD1816_INTRSI 0x01 /* sb intr */
-#define AD1816_INTRGI 0x02 /* game intr */
-#define AD1816_INTRRI 0x04 /* ring intr */
-#define AD1816_INTRDI 0x08 /* dsp intr */
-#define AD1816_INTRVI 0x10 /* vol intr */
-#define AD1816_INTRTI 0x20 /* timer intr */
-#endif
-
-#define AD1816_INTRCI 0x40 /* capture intr */
-#define AD1816_INTRPI 0x80 /* playback intr */
-/* PIO stuff is not supplied here */
-/* playback / capture config */
-#define AD1816_ENABLE 0x01 /* enable pl/cp */
-#define AD1816_PIO 0x02 /* use pio */
-#define AD1816_STEREO 0x04
-#define AD1816_COMP 0x08 /* data is companded */
-#define AD1816_U8 0x00 /* 8 bit linear pcm */
-#define AD1816_MULAW 0x08 /* 8 bit mulaw */
-#define AD1816_ALAW 0x18 /* 8 bit alaw */
-#define AD1816_S16LE 0x10 /* 16 bit linear little endian */
-#define AD1816_S16BE 0x30 /* 16 bit linear big endian */
-#define AD1816_FORMASK 0x38 /* format mask */
-
-
-
-
/*
* sound/ad1848_mixer.h
*
@@ -285,13 +227,6 @@ MIX_NONE(SOUND_MIXER_LINE3),
SOUND_MASK_LINE | SOUND_MASK_MIC | SOUND_MASK_CD | \
SOUND_MASK_IGAIN | SOUND_MASK_LINE1 )
-#define AD1816_REC_DEVICES \
- (SOUND_MASK_LINE | SOUND_MASK_MIC | SOUND_MASK_CD)
-
-#define AD1816_MIXER_DEVICES \
- (SOUND_MASK_VOLUME | SOUND_MASK_PCM | SOUND_MASK_SYNTH | \
- SOUND_MASK_LINE | SOUND_MASK_MIC | SOUND_MASK_CD | SOUND_MASK_IGAIN)
-
/*-
* Copyright (c) 1999 Doug Rabson
* All rights reserved.
diff --git a/sys/dev/sound/isa/ad1816.c b/sys/dev/sound/isa/ad1816.c
new file mode 100644
index 0000000..a069f6d
--- /dev/null
+++ b/sys/dev/sound/isa/ad1816.c
@@ -0,0 +1,622 @@
+/*
+ * Copyright (c) 1999 Cameron Grant <gandalf@vilnya.demon.co.uk>
+ * Copyright Luigi Rizzo, 1997,1998
+ * Copyright by Hannu Savolainen 1994, 1995
+ * 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.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``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 OR CONTRIBUTORS 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.
+ *
+ * $FreeBSD$
+ */
+
+#include <dev/pcm/sound.h>
+
+#if NPCM > 0 && NPNP > 0
+
+#include <dev/pcm/isa/ad1816.h>
+
+struct ad1816_info;
+
+struct ad1816_chinfo {
+ struct ad1816_info *parent;
+ pcm_channel *channel;
+ snd_dbuf *buffer;
+ int dir;
+};
+
+struct ad1816_info {
+ struct resource *io_base; /* primary I/O address for the board */
+ int io_rid;
+ struct resource *irq;
+ int irq_rid;
+ struct resource *drq1; /* play */
+ int drq1_rid;
+ struct resource *drq2; /* rec */
+ int drq2_rid;
+ bus_dma_tag_t parent_dmat;
+
+ struct ad1816_chinfo pch, rch;
+};
+
+static driver_intr_t ad1816_intr;
+static int ad1816_probe(device_t dev);
+static int ad1816_attach(device_t dev);
+
+/* IO primitives */
+static int ad1816_wait_init(struct ad1816_info *ad1816, int x);
+static u_short ad1816_read(struct ad1816_info *ad1816, u_int reg);
+static void ad1816_write(struct ad1816_info *ad1816, u_int reg, u_short data);
+
+static int ad1816mix_init(snd_mixer *m);
+static int ad1816mix_set(snd_mixer *m, unsigned dev, unsigned left, unsigned right);
+static int ad1816mix_setrecsrc(snd_mixer *m, u_int32_t src);
+static snd_mixer ad1816_mixer = {
+ "ad1816 mixer",
+ ad1816mix_init,
+ ad1816mix_set,
+ ad1816mix_setrecsrc,
+};
+
+static devclass_t pcm_devclass;
+
+/* channel interface */
+static void *ad1816chan_init(void *devinfo, snd_dbuf *b, pcm_channel *c, int dir);
+static int ad1816chan_setdir(void *data, int dir);
+static int ad1816chan_setformat(void *data, u_int32_t format);
+static int ad1816chan_setspeed(void *data, u_int32_t speed);
+static int ad1816chan_setblocksize(void *data, u_int32_t blocksize);
+static int ad1816chan_trigger(void *data, int go);
+static int ad1816chan_getptr(void *data);
+static pcmchan_caps *ad1816chan_getcaps(void *data);
+
+static pcmchan_caps ad1816_caps = {
+ 4000, 55200,
+ AFMT_STEREO | AFMT_U8 | AFMT_S16_LE | AFMT_MU_LAW | AFMT_A_LAW,
+ AFMT_STEREO | AFMT_S16_LE
+};
+
+static pcm_channel ad1816_chantemplate = {
+ ad1816chan_init,
+ ad1816chan_setdir,
+ ad1816chan_setformat,
+ ad1816chan_setspeed,
+ ad1816chan_setblocksize,
+ ad1816chan_trigger,
+ ad1816chan_getptr,
+ ad1816chan_getcaps,
+};
+
+#define FULL_DUPLEX(x) (pcm_getflags(x) & SD_F_SIMPLEX)
+#define AD1816_MUTE 31 /* value for mute */
+
+static int
+port_rd(struct resource *port, int off)
+{
+ if (port)
+ return bus_space_read_1(rman_get_bustag(port),
+ rman_get_bushandle(port),
+ off);
+ else
+ return -1;
+}
+
+static void
+port_wr(struct resource *port, int off, u_int8_t data)
+{
+ if (port)
+ return bus_space_write_1(rman_get_bustag(port),
+ rman_get_bushandle(port),
+ off, data);
+}
+
+static int
+io_rd(struct ad1816_info *ad1816, int reg)
+{
+ return port_rd(ad1816->io_base, reg);
+}
+
+static void
+io_wr(struct ad1816_info *ad1816, int reg, u_int8_t data)
+{
+ return port_wr(ad1816->io_base, reg, data);
+}
+
+static void
+ad1816_intr(void *arg)
+{
+ struct ad1816_info *ad1816 = (struct ad1816_info *)arg;
+ unsigned char c, served = 0;
+
+ /* get interupt status */
+ c = io_rd(ad1816, AD1816_INT);
+
+ /* check for stray interupts */
+ if (c & ~(AD1816_INTRCI | AD1816_INTRPI)) {
+ printf("pcm: stray int (%x)\n", c);
+ c &= AD1816_INTRCI | AD1816_INTRPI;
+ }
+ /* check for capture interupt */
+ if (ad1816->rch.buffer->dl && (c & AD1816_INTRCI)) {
+ chn_intr(ad1816->rch.channel);
+ served |= AD1816_INTRCI; /* cp served */
+ }
+ /* check for playback interupt */
+ if (ad1816->pch.buffer->dl && (c & AD1816_INTRPI)) {
+ chn_intr(ad1816->pch.channel);
+ served |= AD1816_INTRPI; /* pb served */
+ }
+ if (served == 0) {
+ /* this probably means this is not a (working) ad1816 chip, */
+ /* or an error in dma handling */
+ printf("pcm: int without reason (%x)\n", c);
+ c = 0;
+ } else c &= ~served;
+ io_wr(ad1816, AD1816_INT, c);
+ c = io_rd(ad1816, AD1816_INT);
+ if (c != 0) printf("pcm: int clear failed (%x)\n", c);
+}
+
+static int
+ad1816_wait_init(struct ad1816_info *ad1816, int x)
+{
+ int n = 0; /* to shut up the compiler... */
+
+ for (; x--;)
+ if ((n = (io_rd(ad1816, AD1816_ALE) & AD1816_BUSY)) == 0) DELAY(10);
+ else return n;
+ printf("ad1816_wait_init failed 0x%02x.\n", n);
+ return -1;
+}
+
+static unsigned short
+ad1816_read(struct ad1816_info *ad1816, unsigned int reg)
+{
+ int flags;
+ u_short x = 0;
+
+ /* we don't want to be blocked here */
+ flags = spltty();
+ if (ad1816_wait_init(ad1816, 100) == -1) return 0;
+ io_wr(ad1816, AD1816_ALE, 0);
+ io_wr(ad1816, AD1816_ALE, (reg & AD1816_ALEMASK));
+ if (ad1816_wait_init(ad1816, 100) == -1) return 0;
+ x = (io_rd(ad1816, AD1816_HIGH) << 8) | io_rd(ad1816, AD1816_LOW);
+ splx(flags);
+ return x;
+}
+
+static void
+ad1816_write(struct ad1816_info *ad1816, unsigned int reg, unsigned short data)
+{
+ int flags;
+
+ flags = spltty();
+ if (ad1816_wait_init(ad1816, 100) == -1) return;
+ io_wr(ad1816, AD1816_ALE, (reg & AD1816_ALEMASK));
+ io_wr(ad1816, AD1816_LOW, (data & 0x000000ff));
+ io_wr(ad1816, AD1816_HIGH, (data & 0x0000ff00) >> 8);
+ splx(flags);
+}
+
+static int
+ad1816mix_init(snd_mixer *m)
+{
+ mix_setdevs(m, AD1816_MIXER_DEVICES);
+ mix_setrecdevs(m, AD1816_REC_DEVICES);
+ return 0;
+}
+
+static int
+ad1816mix_set(snd_mixer *m, unsigned dev, unsigned left, unsigned right)
+{
+ struct ad1816_info *ad1816 = mix_getdevinfo(m);
+ u_short reg = 0;
+
+ /* Scale volumes */
+ left = AD1816_MUTE - (AD1816_MUTE * left) / 100;
+ right = AD1816_MUTE - (AD1816_MUTE * right) / 100;
+
+ reg = (left << 8) | right;
+
+ /* do channel selective muting if volume is zero */
+ if (left == AD1816_MUTE) reg |= 0x8000;
+ if (right == AD1816_MUTE) reg |= 0x0080;
+
+ switch (dev) {
+ case SOUND_MIXER_VOLUME: /* Register 14 master volume */
+ ad1816_write(ad1816, 14, reg);
+ break;
+
+ case SOUND_MIXER_CD: /* Register 15 cd */
+ case SOUND_MIXER_LINE1:
+ ad1816_write(ad1816, 15, reg);
+ break;
+
+ case SOUND_MIXER_SYNTH: /* Register 16 synth */
+ ad1816_write(ad1816, 16, reg);
+ break;
+
+ case SOUND_MIXER_PCM: /* Register 4 pcm */
+ ad1816_write(ad1816, 4, reg);
+ break;
+
+ case SOUND_MIXER_LINE:
+ case SOUND_MIXER_LINE3: /* Register 18 line in */
+ ad1816_write(ad1816, 18, reg);
+ break;
+
+ case SOUND_MIXER_MIC: /* Register 19 mic volume */
+ ad1816_write(ad1816, 19, reg & ~0xff); /* mic is mono */
+ break;
+
+ case SOUND_MIXER_IGAIN:
+ /* and now to something completely different ... */
+ ad1816_write(ad1816, 20, ((ad1816_read(ad1816, 20) & ~0x0f0f)
+ | (((AD1816_MUTE - left) / 2) << 8) /* four bits of adc gain */
+ | ((AD1816_MUTE - right) / 2)));
+ break;
+
+ default:
+ printf("ad1816_mixer_set(): unknown device.\n");
+ break;
+ }
+
+ return left | (right << 8);
+}
+
+static int
+ad1816mix_setrecsrc(snd_mixer *m, u_int32_t src)
+{
+ struct ad1816_info *ad1816 = mix_getdevinfo(m);
+ int dev;
+
+ switch (src) {
+ case SOUND_MASK_LINE:
+ case SOUND_MASK_LINE3:
+ dev = 0x00;
+ break;
+
+ case SOUND_MASK_CD:
+ case SOUND_MASK_LINE1:
+ dev = 0x20;
+ break;
+
+ case SOUND_MASK_MIC:
+ default:
+ dev = 0x50;
+ src = SOUND_MASK_MIC;
+ }
+
+ dev |= dev << 8;
+ ad1816_write(ad1816, 20, (ad1816_read(ad1816, 20) & ~0x7070) | dev);
+ return src;
+}
+
+/* channel interface */
+static void *
+ad1816chan_init(void *devinfo, snd_dbuf *b, pcm_channel *c, int dir)
+{
+ struct ad1816_info *ad1816 = devinfo;
+ struct ad1816_chinfo *ch = (dir == PCMDIR_PLAY)? &ad1816->pch : &ad1816->rch;
+
+ ch->parent = ad1816;
+ ch->channel = c;
+ ch->buffer = b;
+ ch->buffer->bufsize = DSP_BUFFSIZE;
+ if (chn_allocbuf(ch->buffer, ad1816->parent_dmat) == -1) return NULL;
+ return ch;
+}
+
+static int
+ad1816chan_setdir(void *data, int dir)
+{
+ struct ad1816_chinfo *ch = data;
+ struct ad1816_info *ad1816 = ch->parent;
+
+ ch->buffer->chan = rman_get_start((dir == PCMDIR_PLAY)?
+ ad1816->drq1 : ad1816->drq2);
+ ch->dir = dir;
+ return 0;
+}
+
+static int
+ad1816chan_setformat(void *data, u_int32_t format)
+{
+ struct ad1816_chinfo *ch = data;
+ struct ad1816_info *ad1816 = ch->parent;
+
+ int fmt = AD1816_U8, reg;
+ if (ch->dir == PCMDIR_PLAY) {
+ reg = AD1816_PLAY;
+ ad1816_write(ad1816, 8, 0x0000); /* reset base and current counter */
+ ad1816_write(ad1816, 9, 0x0000); /* for playback and capture */
+ } else {
+ reg = AD1816_CAPT;
+ ad1816_write(ad1816, 10, 0x0000);
+ ad1816_write(ad1816, 11, 0x0000);
+ }
+ switch (format & ~AFMT_STEREO) {
+ case AFMT_A_LAW:
+ fmt = AD1816_ALAW;
+ break;
+
+ case AFMT_MU_LAW:
+ fmt = AD1816_MULAW;
+ break;
+
+ case AFMT_S16_LE:
+ fmt = AD1816_S16LE;
+ break;
+
+ case AFMT_S16_BE:
+ fmt = AD1816_S16BE;
+ break;
+
+ case AFMT_U8:
+ fmt = AD1816_U8;
+ break;
+ }
+ if (format & AFMT_STEREO) fmt |= AD1816_STEREO;
+ io_wr(ad1816, reg, fmt);
+ return format;
+}
+
+static int
+ad1816chan_setspeed(void *data, u_int32_t speed)
+{
+ struct ad1816_chinfo *ch = data;
+ struct ad1816_info *ad1816 = ch->parent;
+
+ RANGE(speed, 4000, 55200);
+ ad1816_write(ad1816, (ch->dir == PCMDIR_PLAY)? 2 : 3, speed);
+ return speed;
+}
+
+static int
+ad1816chan_setblocksize(void *data, u_int32_t blocksize)
+{
+ return blocksize;
+}
+
+static int
+ad1816chan_trigger(void *data, int go)
+{
+ struct ad1816_chinfo *ch = data;
+ struct ad1816_info *ad1816 = ch->parent;
+ int wr, reg;
+
+ buf_isadma(ch->buffer, go);
+ wr = (ch->dir == PCMDIR_PLAY);
+ reg = wr? AD1816_PLAY : AD1816_CAPT;
+ switch (go) {
+ case PCMTRIG_START:
+ /* start only if not already running */
+ if (!(io_rd(ad1816, reg) & AD1816_ENABLE)) {
+ int cnt = ((ch->buffer->dl) >> 2) - 1;
+ ad1816_write(ad1816, wr? 8 : 10, cnt); /* count */
+ ad1816_write(ad1816, 1, ad1816_read(ad1816, 1) |
+ (wr? 0x8000 : 0x4000)); /* enable int */
+ /* enable playback */
+ io_wr(ad1816, reg, io_rd(ad1816, reg) | AD1816_ENABLE);
+ if (!(io_rd(ad1816, reg) & AD1816_ENABLE))
+ printf("ad1816: failed to start %s DMA!\n",
+ wr? "play" : "rec");
+ }
+ break;
+
+ case PCMTRIG_STOP:
+ case PCMTRIG_ABORT: /* XXX check this... */
+ /* we don't test here if it is running... */
+ if (wr) {
+ ad1816_write(ad1816, 1, ad1816_read(ad1816, 1) &
+ ~(wr? 0x8000 : 0x4000));
+ /* disable int */
+ io_wr(ad1816, reg, io_rd(ad1816, reg) & ~AD1816_ENABLE);
+ /* disable playback */
+ if (io_rd(ad1816, reg) & AD1816_ENABLE)
+ printf("ad1816: failed to stop %s DMA!\n",
+ wr? "play" : "rec");
+ ad1816_write(ad1816, wr? 8 : 10, 0); /* reset base cnt */
+ ad1816_write(ad1816, wr? 9 : 11, 0); /* reset cur cnt */
+ }
+ break;
+ }
+ return 0;
+}
+
+static int
+ad1816chan_getptr(void *data)
+{
+ struct ad1816_chinfo *ch = data;
+ return buf_isadmaptr(ch->buffer);
+}
+
+static pcmchan_caps *
+ad1816chan_getcaps(void *data)
+{
+ return &ad1816_caps;
+}
+
+static void
+ad1816_release_resources(struct ad1816_info *ad1816, device_t dev)
+{
+ if (ad1816->irq) {
+ bus_release_resource(dev, SYS_RES_IRQ, ad1816->irq_rid,
+ ad1816->irq);
+ ad1816->irq = 0;
+ }
+ if (ad1816->drq1) {
+ bus_release_resource(dev, SYS_RES_DRQ, ad1816->drq1_rid,
+ ad1816->drq1);
+ ad1816->drq1 = 0;
+ }
+ if (ad1816->drq2) {
+ bus_release_resource(dev, SYS_RES_DRQ, ad1816->drq2_rid,
+ ad1816->drq2);
+ ad1816->drq2 = 0;
+ }
+ if (ad1816->io_base) {
+ bus_release_resource(dev, SYS_RES_IOPORT, ad1816->io_rid,
+ ad1816->io_base);
+ ad1816->io_base = 0;
+ }
+ free(ad1816, M_DEVBUF);
+}
+
+static int
+ad1816_alloc_resources(struct ad1816_info *ad1816, device_t dev)
+{
+ int ok = 1, pdma, rdma;
+ if (!ad1816->io_base)
+ ad1816->io_base = bus_alloc_resource(dev, SYS_RES_IOPORT, &ad1816->io_rid,
+ 0, ~0, 1, RF_ACTIVE);
+ if (!ad1816->irq)
+ ad1816->irq = bus_alloc_resource(dev, SYS_RES_IRQ, &ad1816->irq_rid,
+ 0, ~0, 1, RF_ACTIVE);
+ if (!ad1816->drq1)
+ ad1816->drq1 = bus_alloc_resource(dev, SYS_RES_DRQ, &ad1816->drq1_rid,
+ 0, ~0, 1, RF_ACTIVE);
+ if (ad1816->drq2_rid >= 0 && !ad1816->drq2)
+ ad1816->drq2 = bus_alloc_resource(dev, SYS_RES_DRQ, &ad1816->drq2_rid,
+ 0, ~0, 1, RF_ACTIVE);
+
+ if (!ad1816->io_base || !ad1816->drq1 || !ad1816->irq) ok = 0;
+ if (ad1816->drq2_rid >= 0 && !ad1816->drq2) ok = 0;
+
+ if (ok) {
+ pdma = rman_get_start(ad1816->drq1);
+ isa_dma_acquire(pdma);
+ isa_dmainit(pdma, DSP_BUFFSIZE);
+ if (ad1816->drq2) {
+ rdma = rman_get_start(ad1816->drq2);
+ isa_dma_acquire(rdma);
+ isa_dmainit(rdma, DSP_BUFFSIZE);
+ } else rdma = pdma;
+ if (pdma == rdma)
+ pcm_setflags(dev, pcm_getflags(dev) | SD_F_SIMPLEX);
+ }
+ return ok;
+}
+
+static int
+ad1816_init(struct ad1816_info *ad1816, device_t dev)
+{
+ ad1816_write(ad1816, 1, 0x2); /* disable interrupts */
+ ad1816_write(ad1816, 32, 0x90F0); /* SoundSys Mode, split fmt */
+
+ ad1816_write(ad1816, 5, 0x8080); /* FM volume mute */
+ ad1816_write(ad1816, 6, 0x8080); /* I2S1 volume mute */
+ ad1816_write(ad1816, 7, 0x8080); /* I2S0 volume mute */
+ ad1816_write(ad1816, 17, 0x8888); /* VID Volume mute */
+ ad1816_write(ad1816, 20, 0x5050); /* recsrc mic, agc off */
+ /* adc gain is set to 0 */
+
+ return 0;
+}
+
+static int
+ad1816_probe(device_t dev)
+{
+ char *s = NULL;
+ u_int32_t logical_id = isa_get_logicalid(dev);
+
+ switch (logical_id) {
+ case 0x80719304: /* ADS7180 */
+ s = "Terratec Soundsystem BASE 1";
+ break;
+ }
+
+ if (s) {
+ device_set_desc(dev, s);
+ return 0;
+ }
+ return ENXIO;
+}
+
+static int
+ad1816_attach(device_t dev)
+{
+ struct ad1816_info *ad1816;
+ snddev_info *d = device_get_softc(dev);
+ void *ih;
+ char status[SND_STATUSLEN];
+
+ ad1816 = (struct ad1816_info *)malloc(sizeof *ad1816, M_DEVBUF, M_NOWAIT);
+ if (!ad1816) return ENXIO;
+ bzero(ad1816, sizeof *ad1816);
+
+ ad1816->io_rid = 2;
+ ad1816->irq_rid = 0;
+ ad1816->drq1_rid = 0;
+ ad1816->drq2_rid = 1;
+
+ if (!ad1816_alloc_resources(ad1816, dev)) goto no;
+ ad1816_init(ad1816, dev);
+ mixer_init(d, &ad1816_mixer, ad1816);
+ bus_setup_intr(dev, ad1816->irq, INTR_TYPE_TTY, ad1816_intr, ad1816, &ih);
+ if (bus_dma_tag_create(/*parent*/NULL, /*alignment*/2, /*boundary*/0,
+ /*lowaddr*/BUS_SPACE_MAXADDR_24BIT,
+ /*highaddr*/BUS_SPACE_MAXADDR,
+ /*filter*/NULL, /*filterarg*/NULL,
+ /*maxsize*/DSP_BUFFSIZE, /*nsegments*/1,
+ /*maxsegz*/0x3ffff,
+ /*flags*/0, &ad1816->parent_dmat) != 0) {
+ device_printf(dev, "unable to create dma tag\n");
+ goto no;
+ }
+ snprintf(status, SND_STATUSLEN, "at io 0x%lx irq %ld drq %ld",
+ rman_get_start(ad1816->io_base),
+ rman_get_start(ad1816->irq),
+ rman_get_start(ad1816->drq1));
+ if (FULL_DUPLEX(dev)) snprintf(status + strlen(status),
+ SND_STATUSLEN - strlen(status), ":%ld",
+ rman_get_start(ad1816->drq1));
+
+ if (pcm_register(dev, ad1816, 1, 1)) goto no;
+ pcm_addchan(dev, PCMDIR_REC, &ad1816_chantemplate, ad1816);
+ pcm_addchan(dev, PCMDIR_PLAY, &ad1816_chantemplate, ad1816);
+ pcm_setstatus(dev, status);
+
+ return 0;
+no:
+ ad1816_release_resources(ad1816, dev);
+ return ENXIO;
+
+}
+
+static device_method_t ad1816_methods[] = {
+ /* Device interface */
+ DEVMETHOD(device_probe, ad1816_probe),
+ DEVMETHOD(device_attach, ad1816_attach),
+
+ { 0, 0 }
+};
+
+static driver_t ad1816_driver = {
+ "pcm",
+ ad1816_methods,
+ sizeof(snddev_info),
+};
+
+DRIVER_MODULE(mss, isa, ad1816_driver, pcm_devclass, 0, 0);
+
+#endif
diff --git a/sys/dev/sound/isa/ad1816.h b/sys/dev/sound/isa/ad1816.h
new file mode 100644
index 0000000..078523f
--- /dev/null
+++ b/sys/dev/sound/isa/ad1816.h
@@ -0,0 +1,71 @@
+/*
+ * (C) 1997 Luigi Rizzo (luigi@iet.unipi.it)
+ *
+ * This file contains information and macro definitions for
+ * the ad1816 chip
+ *
+ * $FreeBSD$
+ */
+
+/* AD1816 register macros */
+
+#define AD1816_ALE 0 /* indirect reg access */
+#define AD1816_INT 1 /* interupt status */
+#define AD1816_LOW 2 /* indirect low byte */
+#define AD1816_HIGH 3 /* indirect high byte */
+
+#if 0
+#define ad1816_pioD(d) ((d)->io_base+4) /* PIO debug */
+#define ad1816_pios(d) ((d)->io_base+5) /* PIO status */
+#define ad1816_piod(d) ((d)->io_base+6) /* PIO data */
+#endif
+
+/* values for playback/capture config:
+ bits: 0 enable/disable
+ 1 pio/dma
+ 2 stereo/mono
+ 3 companded/linearPCM
+ 4-5 format : 00 8bit linear (uncomp)
+ 00 8bit mulaw (comp)
+ 01 16bit le (uncomp)
+ 01 8bit alaw (comp)
+ 11 16bit be (uncomp)
+*/
+
+#define AD1816_PLAY 8 /* playback config */
+#define AD1816_CAPT 9 /* capture config */
+
+#define AD1816_BUSY 0x80 /* chip is busy */
+#define AD1816_ALEMASK 0x3F /* mask for indirect adr. */
+
+#if 0
+#define AD1816_INTRSI 0x01 /* sb intr */
+#define AD1816_INTRGI 0x02 /* game intr */
+#define AD1816_INTRRI 0x04 /* ring intr */
+#define AD1816_INTRDI 0x08 /* dsp intr */
+#define AD1816_INTRVI 0x10 /* vol intr */
+#define AD1816_INTRTI 0x20 /* timer intr */
+#endif
+
+#define AD1816_INTRCI 0x40 /* capture intr */
+#define AD1816_INTRPI 0x80 /* playback intr */
+/* PIO stuff is not supplied here */
+/* playback / capture config */
+#define AD1816_ENABLE 0x01 /* enable pl/cp */
+#define AD1816_PIO 0x02 /* use pio */
+#define AD1816_STEREO 0x04
+#define AD1816_COMP 0x08 /* data is companded */
+#define AD1816_U8 0x00 /* 8 bit linear pcm */
+#define AD1816_MULAW 0x08 /* 8 bit mulaw */
+#define AD1816_ALAW 0x18 /* 8 bit alaw */
+#define AD1816_S16LE 0x10 /* 16 bit linear little endian */
+#define AD1816_S16BE 0x30 /* 16 bit linear big endian */
+#define AD1816_FORMASK 0x38 /* format mask */
+
+#define AD1816_REC_DEVICES \
+ (SOUND_MASK_LINE | SOUND_MASK_MIC | SOUND_MASK_CD)
+
+#define AD1816_MIXER_DEVICES \
+ (SOUND_MASK_VOLUME | SOUND_MASK_PCM | SOUND_MASK_SYNTH | \
+ SOUND_MASK_LINE | SOUND_MASK_MIC | SOUND_MASK_CD | SOUND_MASK_IGAIN)
+
diff --git a/sys/dev/sound/isa/mss.c b/sys/dev/sound/isa/mss.c
index 39bb2a6..43e3f90 100644
--- a/sys/dev/sound/isa/mss.c
+++ b/sys/dev/sound/isa/mss.c
@@ -94,16 +94,6 @@ static int pnpmss_probe(device_t dev);
static int pnpmss_attach(device_t dev);
static driver_intr_t opti931_intr;
-static driver_intr_t ad1816_intr;
-
-/* IO primitives */
-static int ad1816_wait_init(struct mss_info *mss, int x);
-static u_short ad1816_read(struct mss_info *mss, u_int reg);
-static void ad1816_write(struct mss_info *mss, u_int reg, u_short data);
-
-/* mixer set functions */
-static int ad1816_mixer_set(struct mss_info *mss, int dev, int left, int right);
-static int ad1816_set_recsrc(struct mss_info *mss, int mask);
#endif
static int mssmix_init(snd_mixer *m);
@@ -144,12 +134,6 @@ static pcmchan_caps mss_caps = {
AFMT_STEREO | AFMT_S16_LE
};
-static pcmchan_caps ad1816_caps = {
- 4000, 55200,
- AFMT_STEREO | AFMT_U8 | AFMT_S16_LE | AFMT_MU_LAW | AFMT_A_LAW,
- AFMT_STEREO | AFMT_S16_LE
-};
-
static pcmchan_caps guspnp_caps = {
4000, 48000,
AFMT_STEREO | AFMT_U8 | AFMT_S16_LE | AFMT_A_LAW,
@@ -157,7 +141,7 @@ static pcmchan_caps guspnp_caps = {
};
static pcmchan_caps opti931_caps = {
- 4000, 4800,
+ 4000, 48000,
AFMT_STEREO | AFMT_U8 | AFMT_S16_LE,
AFMT_STEREO | AFMT_S16_LE
};
@@ -175,7 +159,6 @@ static pcm_channel mss_chantemplate = {
#define MD_AD1848 0x91
#define MD_AD1845 0x92
-#define MD_AD1816 0x93
#define MD_CS4248 0xA1
#define MD_CS4231 0xA2
#define MD_CS4231A 0xA3
@@ -332,6 +315,10 @@ mss_alloc_resources(struct mss_info *mss, device_t dev)
static int
mss_init(struct mss_info *mss, device_t dev)
{
+ u_char r6, r9;
+ struct resource *alt;
+ int rid, tmp;
+
mss->bd_flags |= BD_F_MCE_BIT;
switch(mss->bd_id) {
#if NPNP > 0
@@ -343,10 +330,6 @@ mss_init(struct mss_info *mss, device_t dev)
break;
case MD_GUSPNP:
- {
- struct resource *alt;
- int rid, tmp;
-
gus_wr(mss, 0x4c /* _URSTI */, 0);/* Pull reset */
DELAY(1000 * 30);
/* release reset and enable DAC */
@@ -378,24 +361,9 @@ mss_init(struct mss_info *mss, device_t dev)
gus_wr(mss, 0x5b, tmp | 1);
BVDDB(printf("GUS: silicon rev %c\n", 'A' + ((tmp & 0xf) >> 4)));
break;
- }
-
- case MD_AD1816:
- ad1816_write(mss, 1, 0x2); /* disable interrupts */
- ad1816_write(mss, 32, 0x90F0); /* SoundSys Mode, split fmt */
-
- ad1816_write(mss, 5, 0x8080); /* FM volume mute */
- ad1816_write(mss, 6, 0x8080); /* I2S1 volume mute */
- ad1816_write(mss, 7, 0x8080); /* I2S0 volume mute */
- ad1816_write(mss, 17, 0x8888); /* VID Volume mute */
- ad1816_write(mss, 20, 0x5050); /* recsrc mic, agc off */
- /* adc gain is set to 0 */
- break;
#endif
case MD_YM0020:
- {
- u_char r6, r9;
- conf_wr(mss, OPL3SAx_DMACONF, 0xa9); /* dma-b rec, dma-a play */
+ conf_wr(mss, OPL3SAx_DMACONF, 0xa9); /* dma-b rec, dma-a play */
r6 = conf_rd(mss, OPL3SAx_DMACONF);
r9 = conf_rd(mss, OPL3SAx_MISC); /* version */
BVDDB(printf("Yamaha: ver 0x%x DMA config 0x%x\n", r6, r9);)
@@ -404,8 +372,7 @@ mss_init(struct mss_info *mss, device_t dev)
conf_wr(mss, OPL3SAx_VOLUMER, 0);
conf_wr(mss, OPL3SAx_DMACONF, FULL_DUPLEX(mss)? 0xa9 : 0x8b);
break;
- }
- }
+ }
if (FULL_DUPLEX(mss) && mss->bd_id != MD_OPTI931)
ad_write(mss, 12, ad_read(mss, 12) | 0x40); /* mode 2 */
ad_write(mss, 9, FULL_DUPLEX(mss)? 0 : 4);
@@ -500,12 +467,13 @@ mss_probe(device_t dev)
if (tmpx & 0x80) {
/* 8-bit board: only drq1/3 and irq7/9 */
if (drq == 0) {
- printf("MSS: Can't use DMA0 with a 8 bit card/slot\n");
- goto no;
+ printf("MSS: Can't use DMA0 with a 8 bit card/slot\n");
+ goto no;
}
if (!(irq == 7 || irq == 9)) {
- printf("MSS: Can't use IRQ%d with a 8 bit card/slot\n", irq);
- goto no;
+ printf("MSS: Can't use IRQ%d with a 8 bit card/slot\n",
+ irq);
+ goto no;
}
}
mss_probe_end:
@@ -821,10 +789,6 @@ mss_doattach(device_t dev, struct mss_info *mss)
mixer_init(d, (mss->bd_id == MD_YM0020)? &yamaha_mixer : &mss_mixer, mss);
switch (mss->bd_id) {
#if NPNP > 0
- case MD_AD1816:
- bus_setup_intr(dev, mss->irq, INTR_TYPE_TTY, ad1816_intr, mss, &ih);
- break;
-
case MD_OPTI931:
bus_setup_intr(dev, mss->irq, INTR_TYPE_TTY, opti931_intr, mss, &ih);
break;
@@ -981,6 +945,7 @@ ad_read(struct mss_info *mss, int reg)
io_wr(mss, MSS_INDEX, (u_char)(reg & MSS_IDXMASK) | x);
x = io_rd(mss, MSS_IDATA);
splx(flags);
+ /* printf("ad_read %d, %x\n", reg, x); */
return x;
}
@@ -990,6 +955,7 @@ ad_write(struct mss_info *mss, int reg, u_char data)
u_long flags;
int x;
+ /* printf("ad_write %d, %x\n", reg, data); */
flags = spltty();
ad_wait_init(mss, 1002);
x = io_rd(mss, MSS_INDEX) & ~MSS_IDXMASK;
@@ -1141,12 +1107,6 @@ mss_mixer_set(struct mss_info *mss, int dev, int left, int right)
return 0; /* success */
}
-/* mss_speed processes the value in play_speed finding the
- * matching one. As a side effect, it returns the value to
- * be written in the speed bits of the codec. It does _NOT_
- * set the speed of the device (but it should!)
- */
-
static int
mss_speed(struct mss_chinfo *ch, int speed)
{
@@ -1339,12 +1299,6 @@ pnpmss_attach(device_t dev)
mss->drq2_rid = 1;
switch (vend_id & 0xff00ffff) {
- case 0x1100b250: /* terratec */
- case 0x50009304: /* generic ad1815 */
- mss->io_rid = 2;
- mss->bd_id = MD_AD1816;
- break;
-
case 0x2000a865: /* Yamaha SA2 */
case 0x3000a865: /* Yamaha SA3 */
case 0x0000a865: /* Yamaha YMF719 SA3 */
@@ -1371,7 +1325,6 @@ pnpmss_attach(device_t dev)
break;
case 0x3100143e: /* opti931 */
- case 0x1093143e: /* OPT9310 */
mss->bd_flags |= BD_F_MSS_OFFSET;
mss->conf_rid = 3;
mss->bd_id = MD_OPTI931;
@@ -1473,267 +1426,6 @@ opti931_intr(void *arg)
DEB(printf("xxx too many loops\n");)
}
-static void
-ad1816_intr(void *arg)
-{
- struct mss_info *mss = (struct mss_info *)arg;
- unsigned char c, served = 0;
-
- /* get interupt status */
- c = io_rd(mss, AD1816_INT);
-
- /* check for stray interupts */
- if (c & ~(AD1816_INTRCI | AD1816_INTRPI)) {
- printf("pcm: stray int (%x)\n", c);
- c &= AD1816_INTRCI | AD1816_INTRPI;
- }
- /* check for capture interupt */
- if (mss->rch.buffer->dl && (c & AD1816_INTRCI)) {
- chn_intr(mss->rch.channel);
- served |= AD1816_INTRCI; /* cp served */
- }
- /* check for playback interupt */
- if (mss->pch.buffer->dl && (c & AD1816_INTRPI)) {
- chn_intr(mss->pch.channel);
- served |= AD1816_INTRPI; /* pb served */
- }
- if (served == 0) {
- /* this probably means this is not a (working) ad1816 chip, */
- /* or an error in dma handling */
- printf("pcm: int without reason (%x)\n", c);
- c = 0;
- } else c &= ~served;
- io_wr(mss, AD1816_INT, c);
- c = io_rd(mss, AD1816_INT);
- if (c != 0) printf("pcm: int clear failed (%x)\n", c);
-}
-
-static int
-ad1816_wait_init(struct mss_info *mss, int x)
-{
- int n = 0; /* to shut up the compiler... */
-
- for (; x--;)
- if ((n = (io_rd(mss, AD1816_ALE) & AD1816_BUSY)) == 0) DELAY(10);
- else return n;
- printf("ad1816_wait_init failed 0x%02x.\n", n);
- return -1;
-}
-
-static unsigned short
-ad1816_read(struct mss_info *mss, unsigned int reg)
-{
- int flags;
- u_short x = 0;
-
- /* we don't want to be blocked here */
- flags = spltty();
- if (ad1816_wait_init(mss, 100) == -1) return 0;
- io_wr(mss, AD1816_ALE, 0);
- io_wr(mss, AD1816_ALE, (reg & AD1816_ALEMASK));
- if (ad1816_wait_init(mss, 100) == -1) return 0;
- x = (io_rd(mss, AD1816_HIGH) << 8) | io_rd(mss, AD1816_LOW);
- splx(flags);
- return x;
-}
-
-static void
-ad1816_write(struct mss_info *mss, unsigned int reg, unsigned short data)
-{
- int flags;
-
- flags = spltty();
- if (ad1816_wait_init(mss, 100) == -1) return;
- io_wr(mss, AD1816_ALE, (reg & AD1816_ALEMASK));
- io_wr(mss, AD1816_LOW, (data & 0x000000ff));
- io_wr(mss, AD1816_HIGH, (data & 0x0000ff00) >> 8);
- splx(flags);
-}
-
-/* only one rec source is possible */
-static int
-ad1816_set_recsrc(struct mss_info *mss, int mask)
-{
- int dev;
-
- switch (mask) {
- case SOUND_MASK_LINE:
- case SOUND_MASK_LINE3:
- dev = 0x00;
- break;
-
- case SOUND_MASK_CD:
- case SOUND_MASK_LINE1:
- dev = 0x20;
- break;
-
- case SOUND_MASK_MIC:
- default:
- dev = 0x50;
- mask = SOUND_MASK_MIC;
- }
-
- dev |= dev << 8;
- ad1816_write(mss, 20, (ad1816_read(mss, 20) & ~0x7070) | dev);
- return mask;
-}
-
-#define AD1816_MUTE 31 /* value for mute */
-
-static int
-ad1816_mixer_set(struct mss_info *mss, int dev, int left, int right)
-{
- u_short reg = 0;
-
- /* Scale volumes */
- left = AD1816_MUTE - (AD1816_MUTE * left) / 100;
- right = AD1816_MUTE - (AD1816_MUTE * right) / 100;
-
- reg = (left << 8) | right;
-
- /* do channel selective muting if volume is zero */
- if (left == AD1816_MUTE) reg |= 0x8000;
- if (right == AD1816_MUTE) reg |= 0x0080;
-
- switch (dev) {
- case SOUND_MIXER_VOLUME: /* Register 14 master volume */
- ad1816_write(mss, 14, reg);
- break;
-
- case SOUND_MIXER_CD: /* Register 15 cd */
- case SOUND_MIXER_LINE1:
- ad1816_write(mss, 15, reg);
- break;
-
- case SOUND_MIXER_SYNTH: /* Register 16 synth */
- ad1816_write(mss, 16, reg);
- break;
-
- case SOUND_MIXER_PCM: /* Register 4 pcm */
- ad1816_write(mss, 4, reg);
- break;
-
- case SOUND_MIXER_LINE:
- case SOUND_MIXER_LINE3: /* Register 18 line in */
- ad1816_write(mss, 18, reg);
- break;
-
- case SOUND_MIXER_MIC: /* Register 19 mic volume */
- ad1816_write(mss, 19, reg & ~0xff); /* mic is mono */
- break;
-
- case SOUND_MIXER_IGAIN:
- /* and now to something completely different ... */
- ad1816_write(mss, 20, ((ad1816_read(mss, 20) & ~0x0f0f)
- | (((AD1816_MUTE - left) / 2) << 8) /* four bits of adc gain */
- | ((AD1816_MUTE - right) / 2)));
- break;
-
- default:
- printf("ad1816_mixer_set(): unknown device.\n");
- break;
- }
-
- return 0; /* success */
-}
-
-static int
-ad1816_trigger(struct mss_chinfo *ch, int go)
-{
- int wr, reg;
- struct mss_info *mss = ch->parent;
-
- wr = (ch->dir == PCMDIR_PLAY);
- reg = wr? AD1816_PLAY : AD1816_CAPT;
-
- switch (go) {
- case PCMTRIG_START:
- /* start only if not already running */
- if (!(io_rd(mss, reg) & AD1816_ENABLE)) {
- int cnt = ((ch->buffer->dl) >> 2) - 1;
- ad1816_write(mss, wr? 8 : 10, cnt); /* count */
- ad1816_write(mss, 1, ad1816_read(mss, 1) |
- (wr? 0x8000 : 0x4000)); /* enable int */
- /* enable playback */
- io_wr(mss, reg, io_rd(mss, reg) | AD1816_ENABLE);
- if (!(io_rd(mss, reg) & AD1816_ENABLE))
- printf("ad1816: failed to start %s DMA!\n",
- wr? "play" : "rec");
- }
- break;
-
- case PCMTRIG_STOP:
- case PCMTRIG_ABORT: /* XXX check this... */
- /* we don't test here if it is running... */
- if (wr) {
- ad1816_write(mss, 1, ad1816_read(mss, 1) &
- ~(wr? 0x8000 : 0x4000));
- /* disable int */
- io_wr(mss, reg, io_rd(mss, reg) & ~AD1816_ENABLE);
- /* disable playback */
- if (io_rd(mss, reg) & AD1816_ENABLE)
- printf("ad1816: failed to stop %s DMA!\n",
- wr? "play" : "rec");
- ad1816_write(mss, wr? 8 : 10, 0); /* reset base cnt */
- ad1816_write(mss, wr? 9 : 11, 0); /* reset cur cnt */
- }
- break;
- }
- return 0;
-}
-
-
-static int
-ad1816_speed(struct mss_chinfo *ch, u_int32_t speed)
-{
- struct mss_info *mss = ch->parent;
-
- RANGE(speed, 4000, 55200);
- ad1816_write(mss, (ch->dir == PCMDIR_PLAY)? 2 : 3, speed);
- return speed;
-}
-
-static int
-ad1816_format(struct mss_chinfo *ch, u_int32_t format)
-{
- struct mss_info *mss = ch->parent;
-
- int fmt = AD1816_U8, reg;
- if (ch->dir == PCMDIR_PLAY) {
- reg = AD1816_PLAY;
- ad1816_write(mss, 8, 0x0000); /* reset base and current counter */
- ad1816_write(mss, 9, 0x0000); /* for playback and capture */
- } else {
- reg = AD1816_CAPT;
- ad1816_write(mss, 10, 0x0000);
- ad1816_write(mss, 11, 0x0000);
- }
- switch (format & ~AFMT_STEREO) {
- case AFMT_A_LAW:
- fmt = AD1816_ALAW;
- break;
-
- case AFMT_MU_LAW:
- fmt = AD1816_MULAW;
- break;
-
- case AFMT_S16_LE:
- fmt = AD1816_S16LE;
- break;
-
- case AFMT_S16_BE:
- fmt = AD1816_S16BE;
- break;
-
- case AFMT_U8:
- fmt = AD1816_U8;
- break;
- }
- if (format & AFMT_STEREO) fmt |= AD1816_STEREO;
- io_wr(mss, reg, fmt);
- return format;
-}
-
#endif /* NPNP > 0 */
static int
@@ -1744,11 +1436,6 @@ mssmix_init(snd_mixer *m)
mix_setdevs(m, MODE2_MIXER_DEVICES);
mix_setrecdevs(m, MSS_REC_DEVICES);
switch(mss->bd_id) {
- case MD_AD1816:
- mix_setdevs(m, AD1816_MIXER_DEVICES);
- mix_setrecdevs(m, AD1816_REC_DEVICES);
- break;
-
case MD_OPTI931:
mix_setdevs(m, OPTI931_MIXER_DEVICES);
ad_write(mss, 20, 0x88);
@@ -1773,9 +1460,6 @@ mssmix_set(snd_mixer *m, unsigned dev, unsigned left, unsigned right)
{
struct mss_info *mss = mix_getdevinfo(m);
-#if NPNP > 0
- if (mss->bd_id == MD_AD1816) ad1816_mixer_set(mss, dev, left, right); else
-#endif
mss_mixer_set(mss, dev, left, right);
return left | (right << 8);
@@ -1786,9 +1470,6 @@ mssmix_setrecsrc(snd_mixer *m, u_int32_t src)
{
struct mss_info *mss = mix_getdevinfo(m);
-#if NPNP > 0
- if (mss->bd_id == MD_AD1816) src = ad1816_set_recsrc(mss, src); else
-#endif
src = mss_set_recsrc(mss, src);
return src;
}
@@ -1879,9 +1560,6 @@ msschan_setformat(void *data, u_int32_t format)
{
struct mss_chinfo *ch = data;
-#if NPNP > 0
- if (ch->parent->bd_id == MD_AD1816) ad1816_format(ch, format); else
-#endif
mss_format(ch, format);
return 0;
}
@@ -1891,9 +1569,6 @@ msschan_setspeed(void *data, u_int32_t speed)
{
struct mss_chinfo *ch = data;
-#if NPNP > 0
- if (ch->parent->bd_id == MD_AD1816) return ad1816_speed(ch, speed); else
-#endif
return mss_speed(ch, speed);
}
@@ -1909,9 +1584,6 @@ msschan_trigger(void *data, int go)
struct mss_chinfo *ch = data;
buf_isadma(ch->buffer, go);
-#if NPNP > 0
- if (ch->parent->bd_id == MD_AD1816) ad1816_trigger(ch, go); else
-#endif
mss_trigger(ch, go);
return 0;
}
@@ -1937,10 +1609,6 @@ msschan_getcaps(void *data)
return &guspnp_caps;
break;
- case MD_AD1816:
- return &ad1816_caps;
- break;
-
default:
return &mss_caps;
break;
diff --git a/sys/dev/sound/isa/mss.h b/sys/dev/sound/isa/mss.h
index 8db435e..a0a35bb 100644
--- a/sys/dev/sound/isa/mss.h
+++ b/sys/dev/sound/isa/mss.h
@@ -108,64 +108,6 @@ ahead.
#define BD_F_MSS_OFFSET 0x0008 /* offset mss writes by -4 */
#define BD_F_DUPLEX 0x0010
-/* AD1816 register macros */
-
-#define AD1816_ALE 0 /* indirect reg access */
-#define AD1816_INT 1 /* interupt status */
-#define AD1816_LOW 2 /* indirect low byte */
-#define AD1816_HIGH 3 /* indirect high byte */
-
-#if 0
-#define ad1816_pioD(d) ((d)->io_base+4) /* PIO debug */
-#define ad1816_pios(d) ((d)->io_base+5) /* PIO status */
-#define ad1816_piod(d) ((d)->io_base+6) /* PIO data */
-#endif
-
-/* values for playback/capture config:
- bits: 0 enable/disable
- 1 pio/dma
- 2 stereo/mono
- 3 companded/linearPCM
- 4-5 format : 00 8bit linear (uncomp)
- 00 8bit mulaw (comp)
- 01 16bit le (uncomp)
- 01 8bit alaw (comp)
- 11 16bit be (uncomp)
-*/
-
-#define AD1816_PLAY 8 /* playback config */
-#define AD1816_CAPT 9 /* capture config */
-
-#define AD1816_BUSY 0x80 /* chip is busy */
-#define AD1816_ALEMASK 0x3F /* mask for indirect adr. */
-
-#if 0
-#define AD1816_INTRSI 0x01 /* sb intr */
-#define AD1816_INTRGI 0x02 /* game intr */
-#define AD1816_INTRRI 0x04 /* ring intr */
-#define AD1816_INTRDI 0x08 /* dsp intr */
-#define AD1816_INTRVI 0x10 /* vol intr */
-#define AD1816_INTRTI 0x20 /* timer intr */
-#endif
-
-#define AD1816_INTRCI 0x40 /* capture intr */
-#define AD1816_INTRPI 0x80 /* playback intr */
-/* PIO stuff is not supplied here */
-/* playback / capture config */
-#define AD1816_ENABLE 0x01 /* enable pl/cp */
-#define AD1816_PIO 0x02 /* use pio */
-#define AD1816_STEREO 0x04
-#define AD1816_COMP 0x08 /* data is companded */
-#define AD1816_U8 0x00 /* 8 bit linear pcm */
-#define AD1816_MULAW 0x08 /* 8 bit mulaw */
-#define AD1816_ALAW 0x18 /* 8 bit alaw */
-#define AD1816_S16LE 0x10 /* 16 bit linear little endian */
-#define AD1816_S16BE 0x30 /* 16 bit linear big endian */
-#define AD1816_FORMASK 0x38 /* format mask */
-
-
-
-
/*
* sound/ad1848_mixer.h
*
@@ -285,13 +227,6 @@ MIX_NONE(SOUND_MIXER_LINE3),
SOUND_MASK_LINE | SOUND_MASK_MIC | SOUND_MASK_CD | \
SOUND_MASK_IGAIN | SOUND_MASK_LINE1 )
-#define AD1816_REC_DEVICES \
- (SOUND_MASK_LINE | SOUND_MASK_MIC | SOUND_MASK_CD)
-
-#define AD1816_MIXER_DEVICES \
- (SOUND_MASK_VOLUME | SOUND_MASK_PCM | SOUND_MASK_SYNTH | \
- SOUND_MASK_LINE | SOUND_MASK_MIC | SOUND_MASK_CD | SOUND_MASK_IGAIN)
-
/*-
* Copyright (c) 1999 Doug Rabson
* All rights reserved.
OpenPOWER on IntegriCloud