Split the AD1848 driver into MI (dev/ic/ad1848.c) and ISA parts.

This commit is contained in:
pk 1998-08-25 22:34:29 +00:00
parent 47e470f2af
commit 2ffb54bdcc
11 changed files with 839 additions and 1979 deletions

File diff suppressed because it is too large Load Diff

689
sys/dev/isa/ad1848_isa.c Normal file
View File

@ -0,0 +1,689 @@
/* $NetBSD: ad1848_isa.c,v 1.1 1998/08/25 22:34:29 pk Exp $ */
/*
* Copyright (c) 1994 John Brezak
* Copyright (c) 1991-1993 Regents of the University of California.
* 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 by the Computer Systems
* Engineering Group at Lawrence Berkeley Laboratory.
* 4. Neither the name of the University nor of the Laboratory may be used
* to endorse or promote products derived from this software without
* specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE REGENTS 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 REGENTS 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.
*
*/
/*
* Copyright by Hannu Savolainen 1994
*
* 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.
*
*/
/*
* Portions of this code are from the VOXware support for the ad1848
* by Hannu Savolainen <hannu@voxware.pp.fi>
*
* Portions also supplied from the SoundBlaster driver for NetBSD.
*/
#include <sys/param.h>
#include <sys/systm.h>
#include <sys/errno.h>
#include <sys/ioctl.h>
#include <sys/syslog.h>
#include <sys/device.h>
#include <sys/proc.h>
#include <sys/buf.h>
#include <machine/cpu.h>
#include <machine/bus.h>
#include <sys/audioio.h>
#include <vm/vm.h>
#include <dev/audio_if.h>
#include <dev/auconv.h>
#include <dev/isa/isavar.h>
#include <dev/isa/isadmavar.h>
#include <dev/ic/ad1848reg.h>
#include <dev/ic/cs4231reg.h>
#include <dev/isa/ad1848var.h>
#include <dev/isa/cs4231var.h>
#ifdef AUDIO_DEBUG
#define DPRINTF(x) if (ad1848debug) printf x
extern int ad1848debug;
#else
#define DPRINTF(x)
#endif
static int ad1848_isa_read __P(( struct ad1848_softc *, int));
static void ad1848_isa_write __P(( struct ad1848_softc *, int, int));
int
ad1848_isa_read(sc, index)
struct ad1848_softc *sc;
int index;
{
struct ad1848_isa_softc *isc = (struct ad1848_isa_softc *)sc;
return (bus_space_read_1((sc)->sc_iot, (sc)->sc_ioh,
(isc)->sc_iooffs+(index)));
}
void
ad1848_isa_write(sc, index, value)
struct ad1848_softc *sc;
int index;
int value;
{
struct ad1848_isa_softc *isc = (struct ad1848_isa_softc *)sc;
bus_space_write_1((sc)->sc_iot, (sc)->sc_ioh,
(isc)->sc_iooffs+(index), value);
}
/*
* Map and probe for the ad1848 chip
*/
int
ad1848_isa_mapprobe(isc, iobase)
struct ad1848_isa_softc *isc;
int iobase;
{
struct ad1848_softc *sc = (struct ad1848_softc *)&isc->sc_ad1848;
if (!AD1848_BASE_VALID(iobase)) {
#ifdef AUDIO_DEBUG
printf("ad1848: configured iobase %04x invalid\n", iobase);
#endif
return 0;
}
isc->sc_iooffs = 0;
/* Map the AD1848 ports */
if (bus_space_map(sc->sc_iot, iobase, AD1848_NPORT, 0, &sc->sc_ioh))
return 0;
if (!ad1848_isa_probe(isc)) {
bus_space_unmap(sc->sc_iot, sc->sc_ioh, AD1848_NPORT);
return 0;
} else
return 1;
}
/*
* Probe for the ad1848 chip
*/
int
ad1848_isa_probe(isc)
struct ad1848_isa_softc *isc;
{
struct ad1848_softc *sc = (struct ad1848_softc *)&isc->sc_ad1848;
u_char tmp, tmp1 = 0xff, tmp2 = 0xff;
int i;
sc->sc_readreg = ad1848_isa_read;
sc->sc_writereg = ad1848_isa_write;
/* Is there an ad1848 chip ? */
sc->MCE_bit = MODE_CHANGE_ENABLE;
sc->mode = 1; /* MODE 1 = original ad1848/ad1846/cs4248 */
/*
* Check that the I/O address is in use.
*
* The SP_IN_INIT bit of the base I/O port is known to be 0 after the
* chip has performed its power-on initialization. Just assume
* this has happened before the OS is starting.
*
* If the I/O address is unused, inb() typically returns 0xff.
*/
tmp = ADREAD(sc, AD1848_IADDR);
if (tmp & SP_IN_INIT) { /* Not a AD1848 */
#if 0
DPRINTF(("ad_detect_A %x\n", tmp));
#endif
goto bad;
}
/*
* Test if it's possible to change contents of the indirect registers.
* Registers 0 and 1 are ADC volume registers. The bit 0x10 is read
* only so try to avoid using it.
*/
ad_write(sc, 0, 0xaa);
ad_write(sc, 1, 0x45); /* 0x55 with bit 0x10 clear */
if ((tmp1 = ad_read(sc, 0)) != 0xaa ||
(tmp2 = ad_read(sc, 1)) != 0x45) {
DPRINTF(("ad_detect_B (%x/%x)\n", tmp1, tmp2));
goto bad;
}
ad_write(sc, 0, 0x45);
ad_write(sc, 1, 0xaa);
if ((tmp1 = ad_read(sc, 0)) != 0x45 ||
(tmp2 = ad_read(sc, 1)) != 0xaa) {
DPRINTF(("ad_detect_C (%x/%x)\n", tmp1, tmp2));
goto bad;
}
/*
* The indirect register I12 has some read only bits. Lets
* try to change them.
*/
tmp = ad_read(sc, SP_MISC_INFO);
ad_write(sc, SP_MISC_INFO, (~tmp) & 0x0f);
if ((tmp & 0x0f) != ((tmp1 = ad_read(sc, SP_MISC_INFO)) & 0x0f)) {
DPRINTF(("ad_detect_D (%x)\n", tmp1));
goto bad;
}
/*
* MSB and 4 LSBs of the reg I12 tell the chip revision.
*
* A preliminary version of the AD1846 data sheet stated that it
* used an ID field of 0x0B. The current version, however,
* states that the AD1846 uses ID 0x0A, just like the AD1848K.
*
* this switch statement will need updating as newer clones arrive....
*/
switch (tmp1 & 0x8f) {
case 0x09:
sc->chip_name = "AD1848J";
break;
case 0x0A:
sc->chip_name = "AD1848K";
break;
#if 0 /* See above */
case 0x0B:
sc->chip_name = "AD1846";
break;
#endif
case 0x81:
sc->chip_name = "CS4248revB"; /* or CS4231 rev B; see below */
break;
case 0x89:
sc->chip_name = "CS4248";
break;
case 0x8A:
sc->chip_name = "broken"; /* CS4231/AD1845; see below */
break;
default:
sc->chip_name = "unknown";
DPRINTF(("ad1848: unknown codec version 0x%02x\n",
tmp1 & 0x8f));
break;
}
/*
* The original AD1848/CS4248 has just 16 indirect registers. This
* means that I0 and I16 should return the same value (etc.).
* Ensure that the Mode2 enable bit of I12 is 0. Otherwise this test
* fails with CS4231, AD1845, etc.
*/
ad_write(sc, SP_MISC_INFO, 0); /* Mode2 = disabled */
for (i = 0; i < 16; i++)
if ((tmp1 = ad_read(sc, i)) != (tmp2 = ad_read(sc, i + 16))) {
DPRINTF(("ad_detect_F(%d/%x/%x)\n", i, tmp1, tmp2));
if (i != SP_TEST_AND_INIT) goto bad;
}
/*
* Try to switch the chip to mode2 (CS4231) by setting the MODE2 bit
* The bit 0x80 is always 1 in CS4248, CS4231, and AD1845.
*/
ad_write(sc, SP_MISC_INFO, MODE2); /* Set mode2, clear 0x80 */
tmp1 = ad_read(sc, SP_MISC_INFO);
if ((tmp1 & 0xc0) == (0x80 | MODE2)) {
/*
* CS4231 or AD1845 detected - is it?
*
* Verify that setting I2 doesn't change I18.
*/
ad_write(sc, 18, 0x88); /* Set I18 to known value */
ad_write(sc, 2, 0x45);
if ((tmp2 = ad_read(sc, 18)) != 0x45) { /* No change -> CS4231? */
ad_write(sc, 2, 0xaa);
if ((tmp2 = ad_read(sc, 18)) == 0xaa) { /* Rotten bits? */
DPRINTF(("ad_detect_H(%x)\n", tmp2));
goto bad;
}
/*
* It's a CS4231, or another clone with 32 registers.
* Let's find out which by checking I25.
*/
if ((tmp1 & 0x8f) == 0x8a) {
tmp1 = ad_read(sc, CS_VERSION_ID);
switch (tmp1 & 0xe7) {
case 0xA0:
sc->chip_name = "CS4231A";
break;
case 0x80:
/* XXX I25 no good, AD1845 same as CS4231 */
sc->chip_name = "CS4231 or AD1845";
break;
case 0x82:
sc->chip_name = "CS4232";
break;
case 0x03:
sc->chip_name = "CS4236/CS4236B";
break;
}
}
sc->mode = 2;
}
}
/* Wait for 1848 to init */
while(ADREAD(sc, AD1848_IADDR) & SP_IN_INIT)
;
/* Wait for 1848 to autocal */
ADWRITE(sc, AD1848_IADDR, SP_TEST_AND_INIT);
while(ADREAD(sc, AD1848_IDATA) & AUTO_CAL_IN_PROG)
;
return 1;
bad:
return 0;
}
/* Unmap the I/O ports */
void
ad1848_isa_unmap(isc)
struct ad1848_isa_softc *isc;
{
struct ad1848_softc *sc = (struct ad1848_softc *)&isc->sc_ad1848;
bus_space_unmap(sc->sc_iot, sc->sc_ioh, AD1848_NPORT);
}
/*
* Attach hardware to driver, attach hardware driver to audio
* pseudo-device driver .
*/
void
ad1848_isa_attach(isc)
struct ad1848_isa_softc *isc;
{
struct ad1848_softc *sc = (struct ad1848_softc *)&isc->sc_ad1848;
sc->sc_readreg = ad1848_isa_read;
sc->sc_writereg = ad1848_isa_write;
isc->sc_playrun = NOTRUNNING;
isc->sc_recrun = NOTRUNNING;
if (isc->sc_drq != -1) {
if (isa_dmamap_create(isc->sc_ic, isc->sc_drq, MAX_ISADMA,
BUS_DMA_NOWAIT|BUS_DMA_ALLOCNOW)) {
printf("ad1848_attach: can't create map for drq %d\n",
isc->sc_drq);
return;
}
}
if (isc->sc_recdrq != -1 && isc->sc_recdrq != isc->sc_drq) {
if (isa_dmamap_create(isc->sc_ic, isc->sc_recdrq, MAX_ISADMA,
BUS_DMA_NOWAIT|BUS_DMA_ALLOCNOW)) {
printf("ad1848_attach: can't create map for drq %d\n",
isc->sc_recdrq);
return;
}
}
ad1848_attach(sc);
}
int
ad1848_isa_round_blocksize(addr, blk)
void *addr;
int blk;
{
struct ad1848_isa_softc *sc = addr;
sc->sc_lastcc = -1;
/* Round to a multiple of the biggest sample size. */
return (blk &= -4);
}
int
ad1848_isa_open(addr, flags)
void *addr;
int flags;
{
struct ad1848_isa_softc *sc = addr;
DPRINTF(("ad1848_open: sc=%p\n", sc));
sc->sc_lastcc = -1;
sc->sc_intr = 0;
return (ad1848_open(&sc->sc_ad1848, flags));
}
/*
* Close function is called at splaudio().
*/
void
ad1848_isa_close(addr)
void *addr;
{
struct ad1848_isa_softc *sc = addr;
sc->sc_intr = 0;
DPRINTF(("ad1848_isa_close: stop DMA\n"));
if (sc->sc_playrun != NOTRUNNING) {
isa_dmaabort(sc->sc_ic, sc->sc_drq);
sc->sc_playrun = NOTRUNNING;
}
if (sc->sc_recrun != NOTRUNNING) {
isa_dmaabort(sc->sc_ic, sc->sc_recdrq);
sc->sc_recrun = NOTRUNNING;
}
ad1848_close(&sc->sc_ad1848);
}
int
ad1848_isa_dma_init_input(addr, buf, cc)
void *addr;
void *buf;
int cc;
{
struct ad1848_isa_softc *isc = addr;
isc->sc_recrun = DMARUNNING;
isc->sc_dma_flags = DMAMODE_READ | DMAMODE_LOOP;
isc->sc_dma_bp = buf;
isc->sc_dma_cnt = cc;
isa_dmastart(isc->sc_ic, isc->sc_recdrq, buf, cc, NULL,
isc->sc_dma_flags, BUS_DMA_NOWAIT);
DPRINTF(("ad1848_dma_init_input: %p %d\n", buf, cc));
return 0;
}
/*
* DMA input/output are called at splaudio().
*/
int
ad1848_isa_dma_input(addr, p, cc, intr, arg)
void *addr;
void *p;
int cc;
void (*intr) __P((void *));
void *arg;
{
struct ad1848_isa_softc *isc = addr;
struct ad1848_softc *sc = (struct ad1848_softc *)&isc->sc_ad1848;
u_char reg;
if (sc->sc_locked) {
DPRINTF(("ad1848_dma_input: locked\n"));
return 0;
}
#ifdef AUDIO_DEBUG
if (ad1848debug > 1)
printf("ad1848_dma_input: cc=%d %p (%p)\n", cc, intr, arg);
#endif
sc->sc_locked = 1;
isc->sc_intr = intr;
isc->sc_arg = arg;
switch (isc->sc_recrun) {
case NOTRUNNING:
isc->sc_dma_flags = DMAMODE_READ;
isc->sc_dma_bp = p;
isc->sc_dma_cnt = cc;
isa_dmastart(isc->sc_ic, isc->sc_recdrq, p, cc, NULL,
DMAMODE_READ, BUS_DMA_NOWAIT);
goto startpcm;
case DMARUNNING:
isc->sc_recrun = PCMRUNNING;
startpcm:
if (sc->precision == 16)
cc >>= 1;
if (sc->channels == 2)
cc >>= 1;
cc--;
if (isc->sc_lastcc != cc || sc->sc_mode != AUMODE_RECORD) {
ad_write(sc, SP_LOWER_BASE_COUNT, cc & 0xff);
ad_write(sc, SP_UPPER_BASE_COUNT, cc >> 8);
if (sc->mode == 2) {
ad_write(sc, CS_LOWER_REC_CNT, cc & 0xff);
ad_write(sc, CS_UPPER_REC_CNT, cc >> 8);
}
reg = ad_read(sc, SP_INTERFACE_CONFIG);
ad_write(sc, SP_INTERFACE_CONFIG, CAPTURE_ENABLE|reg);
isc->sc_lastcc = cc;
sc->sc_mode = AUMODE_RECORD;
#ifdef AUDIO_DEBUG
if (ad1848debug > 1)
printf("ad1848_dma_input: started capture\n");
#endif
}
case PCMRUNNING:
break;
}
return 0;
}
int
ad1848_isa_dma_init_output(addr, buf, cc)
void *addr;
void *buf;
int cc;
{
struct ad1848_isa_softc *isc = addr;
isc->sc_playrun = DMARUNNING;
isc->sc_dma_flags = DMAMODE_WRITE | DMAMODE_LOOP;
isc->sc_dma_bp = buf;
isc->sc_dma_cnt = cc;
isa_dmastart(isc->sc_ic, isc->sc_drq, buf, cc, NULL,
isc->sc_dma_flags, BUS_DMA_NOWAIT);
DPRINTF(("ad1848_dma_init_output: %p %d\n", buf, cc));
return 0;
}
int
ad1848_isa_dma_output(addr, p, cc, intr, arg)
void *addr;
void *p;
int cc;
void (*intr) __P((void *));
void *arg;
{
struct ad1848_isa_softc *isc = addr;
struct ad1848_softc *sc = (struct ad1848_softc *)&isc->sc_ad1848;
u_char reg;
if (sc->sc_locked) {
DPRINTF(("ad1848_dma_output: locked\n"));
return 0;
}
#ifdef AUDIO_DEBUG
if (ad1848debug > 0)
printf("ad1848_dma_output: cc=%d at %p 0x%p (0x%p)\n",
cc, p, intr, arg);
#endif
sc->sc_locked = 1;
isc->sc_intr = intr;
isc->sc_arg = arg;
switch (isc->sc_playrun) {
case NOTRUNNING:
isc->sc_dma_flags = DMAMODE_WRITE;
isc->sc_dma_bp = p;
isc->sc_dma_cnt = cc;
isa_dmastart(isc->sc_ic, isc->sc_drq, p, cc, NULL,
DMAMODE_WRITE, BUS_DMA_NOWAIT);
goto startpcm;
case DMARUNNING:
isc->sc_playrun = PCMRUNNING;
startpcm:
if (sc->precision == 16)
cc >>= 1;
if (sc->channels == 2)
cc >>= 1;
cc--;
if (isc->sc_lastcc != cc || sc->sc_mode != AUMODE_PLAY) {
ad_write(sc, SP_LOWER_BASE_COUNT, cc & 0xff);
ad_write(sc, SP_UPPER_BASE_COUNT, cc >> 8);
reg = ad_read(sc, SP_INTERFACE_CONFIG);
ad_write(sc, SP_INTERFACE_CONFIG, PLAYBACK_ENABLE|reg);
isc->sc_lastcc = cc;
sc->sc_mode = AUMODE_PLAY;
}
break;
case PCMRUNNING:
break;
}
return 0;
}
int
ad1848_isa_intr(arg)
void *arg;
{
struct ad1848_isa_softc *isc = arg;
struct ad1848_softc *sc = (struct ad1848_softc *)&isc->sc_ad1848;
int retval = 0;
u_char status;
/* Get intr status */
status = ADREAD(sc, AD1848_STATUS);
#ifdef AUDIO_DEBUG
if (ad1848debug > 1)
printf("ad1848_intr: intr=%p status=%x\n", sc->sc_intr,status);
#endif
sc->sc_locked = 0;
isc->sc_interrupts++;
/* Handle interrupt */
if (isc->sc_intr && (status & INTERRUPT_STATUS)) {
/* ACK DMA read because it may be in a bounce buffer */
/* XXX Do write to mask DMA ? */
if ((isc->sc_dma_flags & DMAMODE_READ) &&
isc->sc_recrun == NOTRUNNING)
isa_dmadone(isc->sc_ic, isc->sc_recdrq);
(*isc->sc_intr)(isc->sc_arg);
retval = 1;
}
/* clear interrupt */
if (status & INTERRUPT_STATUS)
ADWRITE(sc, AD1848_STATUS, 0);
return(retval);
}
void *
ad1848_isa_malloc(addr, size, pool, flags)
void *addr;
unsigned long size;
int pool;
int flags;
{
struct ad1848_isa_softc *isc = addr;
return isa_malloc(isc->sc_ic, 4, size, pool, flags);
}
void
ad1848_isa_free(addr, ptr, pool)
void *addr;
void *ptr;
int pool;
{
isa_free(ptr, pool);
}
unsigned long
ad1848_isa_round(addr, size)
void *addr;
unsigned long size;
{
if (size > MAX_ISADMA)
size = MAX_ISADMA;
return size;
}
int
ad1848_isa_mappage(addr, mem, off, prot)
void *addr;
void *mem;
int off;
int prot;
{
return isa_mappage(mem, off, prot);
}
int
ad1848_isa_get_props(addr)
void *addr;
{
struct ad1848_isa_softc *isc = addr;
return (AUDIO_PROP_MMAP |
(isc->sc_drq != isc->sc_recdrq ? AUDIO_PROP_FULLDUPLEX : 0));
}

View File

@ -1,4 +1,4 @@
/* $NetBSD: ad1848var.h,v 1.24 1998/06/09 00:05:44 thorpej Exp $ */
/* $NetBSD: ad1848var.h,v 1.25 1998/08/25 22:34:29 pk Exp $ */
/*
* Copyright (c) 1994 John Brezak
@ -37,25 +37,16 @@
#define AD1848_NPORT 4
struct ad1848_volume {
u_char left;
u_char right;
};
#include <dev/ic/ad1848var.h>
struct ad1848_softc {
struct device sc_dev; /* base device */
struct ad1848_isa_softc {
struct ad1848_softc sc_ad1848; /* AD1848 device */
struct isadev sc_id; /* ISA device */
void *sc_ih; /* interrupt vectoring */
bus_space_tag_t sc_iot; /* tag */
bus_space_handle_t sc_ioh; /* handle */
isa_chipset_tag_t sc_ic; /* ISA chipset info */
int sc_iooffs; /* offset from handle */
void *parent;
u_short sc_locked; /* true when doing HS DMA */
u_int sc_lastcc; /* size of last DMA xfer */
int sc_mode; /* half-duplex record/play */
#ifndef NEWCONFIG
int sc_dma_flags;
@ -73,28 +64,6 @@ struct ad1848_softc {
int sc_drq; /* DMA */
int sc_recdrq; /* record/capture DMA */
/* We keep track of these */
struct ad1848_volume gains[6];
struct ad1848_volume rec_gain;
int rec_port; /* recording port */
/* ad1848 */
u_char MCE_bit;
char mic_gain_on; /* CS4231 only */
char mute[6];
char *chip_name;
int mode;
u_int precision; /* 8/16 bits */
int channels;
u_char speed_bits;
u_char format_bits;
u_char need_commit;
u_long sc_interrupts; /* number of interrupts taken */
void (*sc_intr)(void *); /* dma completion intr handler */
void *sc_arg; /* arg for sc_intr() */
@ -103,91 +72,29 @@ struct ad1848_softc {
int sc_iobase;
};
#define MUTE_LEFT 1
#define MUTE_RIGHT 2
#define MUTE_ALL (MUTE_LEFT | MUTE_RIGHT)
#define MUTE_MONO MUTE_ALL
/* Don't change this ordering without seriously looking around.
These are indexes into mute[] array and into a register information
array */
#define AD1848_AUX2_CHANNEL 0
#define AD1848_AUX1_CHANNEL 1
#define AD1848_DAC_CHANNEL 2
#define AD1848_LINE_CHANNEL 3
#define AD1848_MONO_CHANNEL 4
#define AD1848_MONITOR_CHANNEL 5 /* Doesn't seem to be on all later chips */
/*
* Ad1848 ports
*/
#define MIC_IN_PORT 0
#define LINE_IN_PORT 1
#define AUX1_IN_PORT 2
#define DAC_IN_PORT 3
#ifdef _KERNEL
int ad1848_isa_mapprobe __P((struct ad1848_isa_softc *, int));
int ad1848_isa_probe __P((struct ad1848_isa_softc *));
void ad1848_isa_unmap __P((struct ad1848_isa_softc *));
void ad1848_isa_attach __P((struct ad1848_isa_softc *));
#define AD1848_KIND_LVL 0
#define AD1848_KIND_MUTE 1
#define AD1848_KIND_RECORDGAIN 2
#define AD1848_KIND_MICGAIN 3
#define AD1848_KIND_RECORDSOURCE 4
int ad1848_isa_open __P((void *, int));
void ad1848_isa_close __P((void *));
int ad1848_isa_round_blocksize __P((void *, int));
typedef struct ad1848_devmap {
int id;
int kind;
int dev;
} ad1848_devmap_t;
int ad1848_isa_dma_init_output __P((void *, void *, int));
int ad1848_isa_dma_init_input __P((void *, void *, int));
int ad1848_isa_dma_output __P((void *, void *, int,
void (*)(void *), void*));
int ad1848_isa_dma_input __P((void *, void *, int,
void (*)(void *), void*));
int ad1848_mixer_get_port __P((struct ad1848_softc *, ad1848_devmap_t *, int cnt, mixer_ctrl_t *));
int ad1848_mixer_set_port __P((struct ad1848_softc *, ad1848_devmap_t *, int, mixer_ctrl_t *));
int ad1848_mapprobe __P((struct ad1848_softc *, int));
int ad1848_probe __P((struct ad1848_softc *));
void ad1848_unmap __P((struct ad1848_softc *));
void ad1848_attach __P((struct ad1848_softc *));
int ad1848_open __P((void *, int));
void ad1848_close __P((void *));
void ad1848_forceintr __P((struct ad1848_softc *));
int ad1848_query_encoding __P((void *, struct audio_encoding *));
int ad1848_set_params __P((void *, int, int, struct audio_params *, struct audio_params *));
int ad1848_round_blocksize __P((void *, int));
int ad1848_dma_init_output __P((void *, void *, int));
int ad1848_dma_init_input __P((void *, void *, int));
int ad1848_dma_output __P((void *, void *, int, void (*)(void *), void*));
int ad1848_dma_input __P((void *, void *, int, void (*)(void *), void*));
int ad1848_commit_settings __P((void *));
int ad1848_halt_in_dma __P((void *));
int ad1848_halt_out_dma __P((void *));
int ad1848_intr __P((void *));
int ad1848_set_rec_port __P((struct ad1848_softc *, int));
int ad1848_get_rec_port __P((struct ad1848_softc *));
int ad1848_set_channel_gain __P((struct ad1848_softc *, int, struct ad1848_volume *));
int ad1848_get_device_gain __P((struct ad1848_softc *, int, struct ad1848_volume *));
int ad1848_set_rec_gain __P((struct ad1848_softc *, struct ad1848_volume *));
int ad1848_get_rec_gain __P((struct ad1848_softc *, struct ad1848_volume *));
/* Note: The mic pre-MUX gain is not a variable gain, it's 20dB or 0dB */
int ad1848_set_mic_gain __P((struct ad1848_softc *, struct ad1848_volume *));
int ad1848_get_mic_gain __P((struct ad1848_softc *, struct ad1848_volume *));
void ad1848_mute_channel __P((struct ad1848_softc *, int device, int mute));
int ad1848_to_vol __P((mixer_ctrl_t *, struct ad1848_volume *));
int ad1848_from_vol __P((mixer_ctrl_t *, struct ad1848_volume *));
void *ad1848_malloc __P((void *, unsigned long, int, int));
void ad1848_free __P((void *, void *, int));
unsigned long ad1848_round __P((void *, unsigned long));
int ad1848_mappage __P((void *, void *, int, int));
int ad1848_get_props __P((void *));
int ad1848_isa_intr __P((void *));
void *ad1848_isa_malloc __P((void *, unsigned long, int, int));
void ad1848_isa_free __P((void *, void *, int));
unsigned long ad1848_isa_round __P((void *, unsigned long));
int ad1848_isa_mappage __P((void *, void *, int, int));
int ad1848_isa_get_props __P((void *));
#endif

View File

@ -1,4 +1,4 @@
# $NetBSD: files.isa,v 1.73 1998/08/22 22:55:09 augustss Exp $
# $NetBSD: files.isa,v 1.74 1998/08/25 22:34:29 pk Exp $
#
# Config file and device description for machine-independent ISA code.
# Included by ports that need it. Requires that the SCSI files be
@ -269,8 +269,7 @@ attach pas at isa
file dev/isa/pas.c pas needs-flag
# AD1848 (CS4248, CS4231, AD1845) audio codec support; used by other drivers
define ad1848
file dev/isa/ad1848.c ad1848
file dev/isa/ad1848_isa.c ad1848
# ICS2101 mixer chip support; used by other drivers
define ics2101

View File

@ -1,4 +1,4 @@
/* $NetBSD: gus.c,v 1.59 1998/08/17 21:16:14 augustss Exp $ */
/* $NetBSD: gus.c,v 1.60 1998/08/25 22:34:30 pk Exp $ */
/*-
* Copyright (c) 1996 The NetBSD Foundation, Inc.
@ -255,7 +255,7 @@ struct gus_softc {
struct gus_voice sc_voc[32]; /* Voice data for each voice */
union {
struct ics2101_softc sc_mixer_u;
struct ad1848_softc sc_codec_u;
struct ad1848_isa_softc sc_codec_u;
} u;
#define sc_mixer u.sc_mixer_u
#define sc_codec u.sc_codec_u
@ -1057,11 +1057,15 @@ gusopen(addr, flags)
if (HAS_CODEC(sc)) {
ad1848_open(&sc->sc_codec, flags);
sc->sc_codec.mute[AD1848_AUX1_CHANNEL] = 0;
ad1848_mute_channel(&sc->sc_codec, AD1848_AUX1_CHANNEL, 0); /* turn on DAC output */
sc->sc_codec.sc_ad1848.mute[AD1848_AUX1_CHANNEL] = 0;
/* turn on DAC output */
ad1848_mute_channel(&sc->sc_codec.sc_ad1848,
AD1848_AUX1_CHANNEL, 0);
if (flags & FREAD) {
sc->sc_codec.mute[AD1848_MONO_CHANNEL] = 0;
ad1848_mute_channel(&sc->sc_codec, AD1848_MONO_CHANNEL, 0);
sc->sc_codec.sc_ad1848.mute[AD1848_MONO_CHANNEL] = 0;
ad1848_mute_channel(&sc->sc_codec.sc_ad1848,
AD1848_MONO_CHANNEL, 0);
}
} else if (flags & FREAD) {
/* enable/unmute the microphone */
@ -1355,7 +1359,7 @@ gusintr(arg)
gusintrcnt++;
#endif
if (HAS_CODEC(sc))
retval = ad1848_intr(&sc->sc_codec);
retval = ad1848_isa_intr(&sc->sc_codec);
if ((intr = bus_space_read_1(iot, ioh1, GUS_IRQ_STATUS)) & GUSMASK_IRQ_DMATC) {
DMAPRINTF(("gusintr dma flags=%x\n", sc->sc_flags));
#ifdef DIAGNOSTIC
@ -2874,16 +2878,16 @@ gus_init_cs4231(sc)
bus_space_write_1(iot, ioh1, GUS_MAX_CTRL, ctrl);
sc->sc_codec.sc_iot = sc->sc_iot;
sc->sc_codec.sc_ad1848.sc_iot = sc->sc_iot;
sc->sc_codec.sc_iobase = port+GUS_MAX_CODEC_BASE;
if (ad1848_mapprobe(&sc->sc_codec, sc->sc_codec.sc_iobase) == 0) {
if (ad1848_isa_mapprobe(&sc->sc_codec, sc->sc_codec.sc_iobase) == 0) {
sc->sc_flags &= ~GUS_CODEC_INSTALLED;
return (0);
} else {
struct ad1848_volume vol = {AUDIO_MAX_GAIN, AUDIO_MAX_GAIN};
sc->sc_flags |= GUS_CODEC_INSTALLED;
sc->sc_codec.parent = sc;
sc->sc_codec.sc_ad1848.parent = sc;
sc->sc_codec.sc_drq = sc->sc_recdrq;
sc->sc_codec.sc_recdrq = sc->sc_drq;
gus_hw_if = gusmax_hw_if;
@ -2893,9 +2897,9 @@ gus_init_cs4231(sc)
sc->sc_mixcontrol |= GUSMASK_MIC_IN; /* 1 enables. */
bus_space_write_1(iot, ioh1, GUS_MIX_CONTROL, sc->sc_mixcontrol);
ad1848_attach(&sc->sc_codec);
ad1848_attach(&sc->sc_codec.sc_ad1848);
/* turn on pre-MUX microphone gain. */
ad1848_set_mic_gain(&sc->sc_codec, &vol);
ad1848_set_mic_gain(&sc->sc_codec.sc_ad1848, &vol);
return (1);
}

View File

@ -1,4 +1,4 @@
/* $NetBSD: pss.c,v 1.47 1998/08/17 21:16:14 augustss Exp $ */
/* $NetBSD: pss.c,v 1.48 1998/08/25 22:34:30 pk Exp $ */
/*
* Copyright (c) 1994 John Brezak
@ -52,12 +52,8 @@
#include <sys/param.h>
#include <sys/systm.h>
#include <sys/errno.h>
#include <sys/ioctl.h>
#include <sys/syslog.h>
#include <sys/device.h>
#include <sys/proc.h>
#include <sys/buf.h>
#include <sys/errno.h>
#include <machine/cpu.h>
#include <machine/intr.h>
@ -168,7 +164,7 @@ static int pssfind __P((struct device *, struct pss_softc *,
int spprobe __P((struct device *, struct cfdata *, void *));
void spattach __P((struct device *, struct device *, void *));
static int spfind __P((struct device *, struct ad1848_softc *,
static int spfind __P((struct device *, struct ad1848_isa_softc *,
struct isa_attach_args *));
#ifdef notyet
@ -225,30 +221,30 @@ void wss_dump_regs __P((struct ad1848_softc *));
*/
struct audio_hw_if pss_audio_if = {
ad1848_open,
ad1848_close,
ad1848_isa_open,
ad1848_isa_close,
NULL,
ad1848_query_encoding,
ad1848_set_params,
ad1848_round_blocksize,
ad1848_isa_round_blocksize,
ad1848_commit_settings,
ad1848_dma_init_output,
ad1848_dma_init_input,
ad1848_dma_output,
ad1848_dma_input,
ad1848_halt_out_dma,
ad1848_halt_in_dma,
ad1848_isa_dma_init_output,
ad1848_isa_dma_init_input,
ad1848_isa_dma_output,
ad1848_isa_dma_input,
ad1848_halt_out,
ad1848_halt_in,
pss_speaker_ctl,
pss_getdev,
NULL,
pss_mixer_set_port,
pss_mixer_get_port,
pss_query_devinfo,
ad1848_malloc,
ad1848_free,
ad1848_round,
ad1848_mappage,
ad1848_get_props,
ad1848_isa_malloc,
ad1848_isa_free,
ad1848_isa_round,
ad1848_isa_mappage,
ad1848_isa_get_props,
};
/* Interrupt translation for WSS config */
@ -266,7 +262,7 @@ struct cfattach pss_ca = {
};
struct cfattach sp_ca = {
sizeof(struct ad1848_softc), spprobe, spattach
sizeof(struct ad1848_isa_softc), spprobe, spattach
};
#ifdef notyet
@ -677,7 +673,7 @@ pss_download_dsp(sc, block, size)
#ifdef AUDIO_DEBUG
void
wss_dump_regs(sc)
struct ad1848_softc *sc;
struct ad1848_isa_softc *sc;
{
printf("WSS reg: status=%02x\n",
@ -821,31 +817,31 @@ spprobe(parent, match, aux)
struct cfdata *match;
void *aux;
{
struct ad1848_softc probesc, *sc = &probesc;
struct ad1848_isa_softc probesc, *sc = &probesc;
bzero(sc, sizeof *sc);
sc->sc_dev.dv_cfdata = match;
sc->sc_ad1848.sc_dev.dv_cfdata = match;
return spfind(parent, sc, aux);
}
static int
spfind(parent, sc, ia)
struct device *parent;
struct ad1848_softc *sc;
struct ad1848_isa_softc *sc;
struct isa_attach_args *ia;
{
struct pss_softc *pc = (void *) parent;
struct cfdata *cf = (void *)sc->sc_dev.dv_cfdata;
struct cfdata *cf = (void *)sc->sc_ad1848.sc_dev.dv_cfdata;
u_char bits;
int i;
sc->sc_iot = ia->ia_iot;
sc->sc_ad1848.sc_iot = ia->ia_iot;
/* Set WSS io address */
pss_setaddr(cf->cf_iobase, pc->sc_iobase+PSS_WSS_CONFIG);
/* Is there an ad1848 chip at the WSS iobase ? */
if (ad1848_mapprobe(sc, cf->cf_iobase + WSS_CODEC) == 0) {
if (ad1848_isa_mapprobe(sc, cf->cf_iobase + WSS_CODEC) == 0) {
DPRINTF(("sp: no ad1848 ? iobase=%x\n", sc->sc_iobase));
return 0;
}
@ -916,8 +912,8 @@ spfind(parent, sc, ia)
outb(sc->sc_iobase+WSS_CONFIG, (bits | wss_dma_bits[sc->sc_drq]));
pc->ad1848_sc = sc;
sc->parent = pc;
pc->ad1848_sc = (struct ad1848_softc *)sc;
sc->sc_ad1848.parent = pc;
return 1;
}
@ -1081,14 +1077,14 @@ spattach(parent, self, aux)
struct device *parent, *self;
void *aux;
{
struct ad1848_softc *sc = (struct ad1848_softc *)self;
struct cfdata *cf = (void *)sc->sc_dev.dv_cfdata;
struct ad1848_isa_softc *sc = (struct ad1848_isa_softc *)self;
struct cfdata *cf = (void *)sc->sc_ad1848.sc_dev.dv_cfdata;
struct isa_attach_args *ia = (struct isa_attach_args *)aux;
isa_chipset_tag_t ic = ia->ia_ic;
int iobase = cf->cf_iobase;
if (!spfind(parent, sc, ia)) {
printf("%s: spfind failed\n", sc->sc_dev.dv_xname);
printf("%s: spfind failed\n", sc->sc_ad1848.sc_dev.dv_xname);
return;
}
@ -1100,12 +1096,11 @@ spattach(parent, self, aux)
#endif
sc->sc_ih = isa_intr_establish(ic, cf->cf_irq, IST_EDGE, IPL_AUDIO,
ad1848_intr, sc);
ad1848_isa_intr, sc);
sc->sc_ic = ic;
ad1848_attach(sc);
printf(": %s\n", sc->chip_name);
ad1848_attach(&sc->sc_ad1848);
}
#ifdef notyet

View File

@ -1,4 +1,4 @@
/* $NetBSD: wss.c,v 1.51 1998/08/17 21:16:15 augustss Exp $ */
/* $NetBSD: wss.c,v 1.52 1998/08/25 22:34:31 pk Exp $ */
/*
* Copyright (c) 1994 John Brezak
@ -37,12 +37,8 @@
#include <sys/param.h>
#include <sys/systm.h>
#include <sys/errno.h>
#include <sys/ioctl.h>
#include <sys/syslog.h>
#include <sys/device.h>
#include <sys/proc.h>
#include <sys/buf.h>
#include <sys/errno.h>
#include <machine/cpu.h>
#include <machine/intr.h>
@ -93,23 +89,23 @@ struct audio_hw_if wss_hw_if = {
ad1848_set_params,
ad1848_round_blocksize,
ad1848_commit_settings,
ad1848_dma_init_output,
ad1848_dma_init_input,
ad1848_dma_output,
ad1848_dma_input,
ad1848_halt_out_dma,
ad1848_halt_in_dma,
ad1848_isa_dma_init_output,
ad1848_isa_dma_init_input,
ad1848_isa_dma_output,
ad1848_isa_dma_input,
ad1848_halt_out,
ad1848_halt_in,
NULL,
wss_getdev,
NULL,
wss_mixer_set_port,
wss_mixer_get_port,
wss_query_devinfo,
ad1848_malloc,
ad1848_free,
ad1848_round,
ad1848_mappage,
ad1848_get_props,
ad1848_isa_malloc,
ad1848_isa_free,
ad1848_isa_round,
ad1848_isa_mappage,
ad1848_isa_get_props,
};
/*
@ -120,16 +116,20 @@ void
wssattach(sc)
struct wss_softc *sc;
{
struct ad1848_softc *ac = &sc->sc_ad1848.sc_ad1848;
#if 0 /* loses on CS423X chips */
int version;
#endif
madattach(sc);
sc->sc_ih = isa_intr_establish(sc->wss_ic, sc->wss_irq, IST_EDGE,
IPL_AUDIO, ad1848_intr, &sc->sc_ad1848);
sc->sc_ad1848.sc_ih = isa_intr_establish(sc->wss_ic, sc->wss_irq,
IST_EDGE,
IPL_AUDIO, ad1848_isa_intr,
&sc->sc_ad1848);
ad1848_attach(&sc->sc_ad1848);
ad1848_isa_attach(&sc->sc_ad1848);
#if 0 /* loses on CS423X chips */
version = bus_space_read_1(sc->sc_iot, sc->sc_ioh, WSS_STATUS)
@ -155,9 +155,9 @@ wssattach(sc)
}
printf("\n");
sc->sc_ad1848.parent = sc;
ac->parent = sc;
audio_attach_mi(&wss_hw_if, &sc->sc_ad1848, &sc->sc_dev);
audio_attach_mi(&wss_hw_if, &sc->sc_ad1848, &ac->sc_dev);
}
int
@ -439,6 +439,7 @@ void
madattach(sc)
struct wss_softc *sc;
{
struct ad1848_softc *ac = (struct ad1848_softc *)&sc->sc_ad1848;
unsigned char cs4231_mode;
int joy;
@ -446,7 +447,7 @@ madattach(sc)
return;
/* Do we want the joystick disabled? */
joy = sc->sc_dev.dv_cfdata->cf_flags & 2 ? MC1_JOYDISABLE : 0;
joy = ac->sc_dev.dv_cfdata->cf_flags & 2 ? MC1_JOYDISABLE : 0;
/* enable WSS emulation at the I/O port */
mad_write(sc, MC1_PORT, M_WSS_PORT_SELECT(sc->mad_ioindex) | joy);
@ -454,8 +455,8 @@ madattach(sc)
mad_write(sc, MC3_PORT, 0xf0); /* Disable SB */
cs4231_mode =
strncmp(sc->sc_ad1848.chip_name, "CS4248", 6) == 0 ||
strncmp(sc->sc_ad1848.chip_name, "CS4231", 6) == 0 ? 0x02 : 0;
strncmp(ac->chip_name, "CS4248", 6) == 0 ||
strncmp(ac->chip_name, "CS4231", 6) == 0 ? 0x02 : 0;
if (sc->mad_chip_type == MAD_82C929) {
mad_write(sc, MC4_PORT, 0x92);

View File

@ -1,4 +1,4 @@
/* $NetBSD: wss_isa.c,v 1.4 1998/06/09 07:25:07 thorpej Exp $ */
/* $NetBSD: wss_isa.c,v 1.5 1998/08/25 22:34:31 pk Exp $ */
/*
* Copyright (c) 1994 John Brezak
@ -41,12 +41,8 @@
*/
#include <sys/param.h>
#include <sys/systm.h>
#include <sys/errno.h>
#include <sys/ioctl.h>
#include <sys/syslog.h>
#include <sys/device.h>
#include <sys/proc.h>
#include <sys/buf.h>
#include <sys/errno.h>
#include <machine/cpu.h>
#include <machine/intr.h>
@ -94,12 +90,13 @@ wss_isa_probe(parent, match, aux)
void *aux;
{
struct wss_softc probesc, *sc = &probesc;
struct ad1848_softc *ac = (struct ad1848_softc *)&sc->sc_ad1848;
bzero(sc, sizeof *sc);
sc->sc_dev.dv_cfdata = match;
ac->sc_dev.dv_cfdata = match;
if (wssfind(parent, sc, aux)) {
bus_space_unmap(sc->sc_iot, sc->sc_ioh, WSS_CODEC);
ad1848_unmap(&sc->sc_ad1848);
ad1848_isa_unmap(&sc->sc_ad1848);
madunmap(sc);
return 1;
} else
@ -113,13 +110,14 @@ wssfind(parent, sc, ia)
struct wss_softc *sc;
struct isa_attach_args *ia;
{
struct ad1848_softc *ac = (struct ad1848_softc *)&sc->sc_ad1848;
static u_char interrupt_bits[12] = {
-1, -1, -1, -1, -1, -1, -1, 0x08, -1, 0x10, 0x18, 0x20
};
static u_char dma_bits[4] = {1, 2, 0, 3};
sc->sc_iot = ia->ia_iot;
if (sc->sc_dev.dv_cfdata->cf_flags & 1)
if (ac->sc_dev.dv_cfdata->cf_flags & 1)
madprobe(sc, ia->ia_iobase);
else
sc->mad_chip_type = MAD_NONE;
@ -133,10 +131,10 @@ wssfind(parent, sc, ia)
if (bus_space_map(sc->sc_iot, ia->ia_iobase, WSS_CODEC, 0, &sc->sc_ioh))
goto bad1;
sc->sc_ad1848.sc_iot = sc->sc_iot;
ac->sc_iot = sc->sc_iot;
/* Is there an ad1848 chip at (WSS iobase + WSS_CODEC)? */
if (ad1848_mapprobe(&sc->sc_ad1848, ia->ia_iobase + WSS_CODEC) == 0)
if (ad1848_isa_mapprobe(&sc->sc_ad1848, ia->ia_iobase + WSS_CODEC) == 0)
goto bad;
ia->ia_iosize = WSS_NPORT;
@ -159,10 +157,10 @@ wssfind(parent, sc, ia)
sc->wss_irq = ia->ia_irq;
if (sc->sc_ad1848.mode <= 1)
if (ac->mode <= 1)
ia->ia_drq2 = DRQUNK;
sc->wss_recdrq =
sc->sc_ad1848.mode > 1 && ia->ia_drq2 != DRQUNK ?
ac->mode > 1 && ia->ia_drq2 != DRQUNK ?
ia->ia_drq2 : ia->ia_drq;
if (sc->wss_recdrq != sc->wss_drq && !isa_drq_isfree(sc->wss_ic,
sc->wss_recdrq))
@ -191,10 +189,11 @@ wss_isa_attach(parent, self, aux)
void *aux;
{
struct wss_softc *sc = (struct wss_softc *)self;
struct ad1848_softc *ac = (struct ad1848_softc *)&sc->sc_ad1848;
struct isa_attach_args *ia = (struct isa_attach_args *)aux;
if (!wssfind(parent, sc, ia)) {
printf("%s: wssfind failed\n", sc->sc_dev.dv_xname);
printf("%s: wssfind failed\n", ac->sc_dev.dv_xname);
return;
}

View File

@ -1,4 +1,4 @@
/* $NetBSD: wssvar.h,v 1.3 1998/06/30 16:54:52 mycroft Exp $ */
/* $NetBSD: wssvar.h,v 1.4 1998/08/25 22:34:31 pk Exp $ */
/*
* Copyright (c) 1994 John Brezak
@ -56,18 +56,19 @@
#define WSS_MONITOR_CLASS 12
struct wss_softc {
struct device sc_dev; /* base device */
struct isadev sc_id; /* ISA device */
void *sc_ih; /* interrupt vectoring */
bus_space_tag_t sc_iot; /* tag */
bus_space_handle_t sc_ioh; /* handle */
struct ad1848_softc sc_ad1848;
struct ad1848_isa_softc sc_ad1848;
#define wss_ic sc_ad1848.sc_ic
#define wss_irq sc_ad1848.sc_irq
#define wss_drq sc_ad1848.sc_drq
#define wss_recdrq sc_ad1848.sc_recdrq
#if 0
struct isadev sc_id; /* ISA device */
void *sc_ih; /* interrupt vectoring */
#endif
bus_space_tag_t sc_iot; /* tag */
bus_space_handle_t sc_ioh; /* handle */
int mic_mute, cd_mute, dac_mute;
int mad_chip_type; /* chip type if MAD emulation of WSS */

View File

@ -1,4 +1,4 @@
/* $NetBSD: ym.c,v 1.4 1998/08/17 21:16:15 augustss Exp $ */
/* $NetBSD: ym.c,v 1.5 1998/08/25 22:34:31 pk Exp $ */
/*
@ -35,11 +35,7 @@
#include <sys/param.h>
#include <sys/systm.h>
#include <sys/errno.h>
#include <sys/ioctl.h>
#include <sys/syslog.h>
#include <sys/device.h>
#include <sys/proc.h>
#include <sys/buf.h>
#include <machine/cpu.h>
#include <machine/intr.h>
@ -69,30 +65,30 @@ static void ym_set_mic_gain __P((struct ym_softc *, struct ad1848_volume *));
struct audio_hw_if ym_hw_if = {
ad1848_open,
ad1848_close,
ad1848_isa_open,
ad1848_isa_close,
NULL,
ad1848_query_encoding,
ad1848_set_params,
ad1848_round_blocksize,
ad1848_commit_settings,
ad1848_dma_init_output,
ad1848_dma_init_input,
ad1848_dma_output,
ad1848_dma_input,
ad1848_halt_out_dma,
ad1848_halt_in_dma,
ad1848_isa_dma_init_output,
ad1848_isa_dma_init_input,
ad1848_isa_dma_output,
ad1848_isa_dma_input,
ad1848_halt_out,
ad1848_halt_in,
NULL,
ym_getdev,
NULL,
ym_mixer_set_port,
ym_mixer_get_port,
ym_query_devinfo,
ad1848_malloc,
ad1848_free,
ad1848_round,
ad1848_mappage,
ad1848_get_props,
ad1848_isa_malloc,
ad1848_isa_free,
ad1848_isa_round,
ad1848_isa_mappage,
ad1848_isa_get_props,
};
@ -109,15 +105,18 @@ void
ym_attach(sc)
struct ym_softc *sc;
{
struct ad1848_softc *ac = &sc->sc_ad1848.sc_ad1848;
struct ad1848_volume vol_mid = {220, 220};
struct ad1848_volume vol_0 = {0, 0};
sc->sc_ih = isa_intr_establish(sc->sc_ic, sc->ym_irq, IST_EDGE,
IPL_AUDIO, ad1848_intr, &sc->sc_ad1848);
sc->sc_ad1848.sc_ih = isa_intr_establish(sc->sc_ic, sc->ym_irq,
IST_EDGE,
IPL_AUDIO, ad1848_isa_intr,
&sc->sc_ad1848);
ad1848_attach(&sc->sc_ad1848);
ad1848_attach(ac);
printf("\n");
sc->sc_ad1848.parent = sc;
ac->parent = sc;
/* Establish chip in well known mode */
ym_set_master_gain(sc, &vol_mid);
@ -129,7 +128,7 @@ ym_attach(sc)
sc->mic_mute = 1;
ym_mute(sc, SA3_MIC, sc->mic_mute);
audio_attach_mi(&ym_hw_if, &sc->sc_ad1848, &sc->sc_dev);
audio_attach_mi(&ym_hw_if, ac, &ac->sc_dev);
}
static __inline int

View File

@ -1,4 +1,4 @@
/* $NetBSD: ymvar.h,v 1.1 1998/05/20 16:19:43 augustss Exp $ */
/* $NetBSD: ymvar.h,v 1.2 1998/08/25 22:34:32 pk Exp $ */
/*
* Copyright (c) 1994 John Brezak
@ -71,20 +71,17 @@
struct ym_softc {
struct device sc_dev; /* base device */
struct isadev sc_id; /* ISA device */
void *sc_ih; /* interrupt vectoring */
struct ad1848_isa_softc sc_ad1848;
#define ym_irq sc_ad1848.sc_irq
#define ym_drq sc_ad1848.sc_drq
#define ym_recdrq sc_ad1848.sc_recdrq
bus_space_tag_t sc_iot; /* tag */
bus_space_handle_t sc_ioh; /* handle */
isa_chipset_tag_t sc_ic;
bus_space_handle_t sc_controlioh;
struct ad1848_softc sc_ad1848;
#define ym_irq sc_ad1848.sc_irq
#define ym_drq sc_ad1848.sc_drq
#define ym_recdrq sc_ad1848.sc_recdrq
int master_mute, mic_mute;
struct ad1848_volume mic_gain, master_gain;
};