This commit is contained in:
augustss 2001-01-27 18:53:33 +00:00
parent d13e6a84f2
commit 532934d5f1

View File

@ -1,4 +1,4 @@
/* $NetBSD: eap.c,v 1.43 2001/01/27 18:37:01 augustss Exp $ */
/* $NetBSD: eap.c,v 1.44 2001/01/27 18:53:33 augustss Exp $ */
/* $OpenBSD: eap.c,v 1.6 1999/10/05 19:24:42 csapuntz Exp $ */
/*
@ -91,9 +91,9 @@ int eapdebug = 0;
#define DPRINTFN(n,x)
#endif
int eap_match __P((struct device *, struct cfdata *, void *));
void eap_attach __P((struct device *, struct device *, void *));
int eap_intr __P((void *));
int eap_match(struct device *, struct cfdata *, void *);
void eap_attach(struct device *, struct device *, void *);
int eap_intr(void *);
struct eap_dma {
bus_dmamap_t map;
@ -144,8 +144,8 @@ struct eap_softc {
struct ac97_host_if host_if;
};
int eap_allocmem __P((struct eap_softc *, size_t, size_t, struct eap_dma *));
int eap_freemem __P((struct eap_softc *, struct eap_dma *));
int eap_allocmem(struct eap_softc *, size_t, size_t, struct eap_dma *);
int eap_freemem(struct eap_softc *, struct eap_dma *);
#define EWRITE1(sc, r, x) bus_space_write_1((sc)->iot, (sc)->ioh, (r), (x))
#define EWRITE2(sc, r, x) bus_space_write_2((sc)->iot, (sc)->ioh, (r), (x))
@ -158,49 +158,49 @@ struct cfattach eap_ca = {
sizeof(struct eap_softc), eap_match, eap_attach
};
int eap_open __P((void *, int));
void eap_close __P((void *));
int eap_query_encoding __P((void *, struct audio_encoding *));
int eap_set_params __P((void *, int, int, struct audio_params *, struct audio_params *));
int eap_round_blocksize __P((void *, int));
int eap_trigger_output __P((void *, void *, void *, int, void (*)(void *),
void *, struct audio_params *));
int eap_trigger_input __P((void *, void *, void *, int, void (*)(void *),
void *, struct audio_params *));
int eap_halt_output __P((void *));
int eap_halt_input __P((void *));
void eap1370_write_codec __P((struct eap_softc *, int, int));
int eap_getdev __P((void *, struct audio_device *));
int eap1370_mixer_set_port __P((void *, mixer_ctrl_t *));
int eap1370_mixer_get_port __P((void *, mixer_ctrl_t *));
int eap1371_mixer_set_port __P((void *, mixer_ctrl_t *));
int eap1371_mixer_get_port __P((void *, mixer_ctrl_t *));
int eap1370_query_devinfo __P((void *, mixer_devinfo_t *));
void *eap_malloc __P((void *, int, size_t, int, int));
void eap_free __P((void *, void *, int));
size_t eap_round_buffersize __P((void *, int, size_t));
paddr_t eap_mappage __P((void *, void *, off_t, int));
int eap_get_props __P((void *));
void eap1370_set_mixer __P((struct eap_softc *sc, int a, int d));
u_int32_t eap1371_src_wait __P((struct eap_softc *sc));
void eap1371_set_adc_rate __P((struct eap_softc *sc, int rate));
void eap1371_set_dac_rate __P((struct eap_softc *sc, int rate, int which));
int eap1371_src_read __P((struct eap_softc *sc, int a));
void eap1371_src_write __P((struct eap_softc *sc, int a, int d));
int eap1371_query_devinfo __P((void *addr, mixer_devinfo_t *dip));
int eap_open(void *, int);
void eap_close(void *);
int eap_query_encoding(void *, struct audio_encoding *);
int eap_set_params(void *, int, int, struct audio_params *, struct audio_params *);
int eap_round_blocksize(void *, int);
int eap_trigger_output(void *, void *, void *, int, void (*)(void *),
void *, struct audio_params *);
int eap_trigger_input(void *, void *, void *, int, void (*)(void *),
void *, struct audio_params *);
int eap_halt_output(void *);
int eap_halt_input(void *);
void eap1370_write_codec(struct eap_softc *, int, int);
int eap_getdev(void *, struct audio_device *);
int eap1370_mixer_set_port(void *, mixer_ctrl_t *);
int eap1370_mixer_get_port(void *, mixer_ctrl_t *);
int eap1371_mixer_set_port(void *, mixer_ctrl_t *);
int eap1371_mixer_get_port(void *, mixer_ctrl_t *);
int eap1370_query_devinfo(void *, mixer_devinfo_t *);
void *eap_malloc(void *, int, size_t, int, int);
void eap_free(void *, void *, int);
size_t eap_round_buffersize(void *, int, size_t);
paddr_t eap_mappage(void *, void *, off_t, int);
int eap_get_props(void *);
void eap1370_set_mixer(struct eap_softc *sc, int a, int d);
u_int32_t eap1371_src_wait(struct eap_softc *sc);
void eap1371_set_adc_rate(struct eap_softc *sc, int rate);
void eap1371_set_dac_rate(struct eap_softc *sc, int rate, int which);
int eap1371_src_read(struct eap_softc *sc, int a);
void eap1371_src_write(struct eap_softc *sc, int a, int d);
int eap1371_query_devinfo(void *addr, mixer_devinfo_t *dip);
int eap1371_attach_codec __P((void *sc, struct ac97_codec_if *));
int eap1371_read_codec __P((void *sc, u_int8_t a, u_int16_t *d));
int eap1371_write_codec __P((void *sc, u_int8_t a, u_int16_t d));
void eap1371_reset_codec __P((void *sc));
int eap1371_get_portnum_by_name __P((struct eap_softc *, char *, char *,
char *));
int eap1371_attach_codec(void *sc, struct ac97_codec_if *);
int eap1371_read_codec(void *sc, u_int8_t a, u_int16_t *d);
int eap1371_write_codec(void *sc, u_int8_t a, u_int16_t d);
void eap1371_reset_codec(void *sc);
int eap1371_get_portnum_by_name(struct eap_softc *, char *, char *,
char *);
#if NMIDI > 0
void eap_midi_close __P((void *));
void eap_midi_getinfo __P((void *, struct midi_info *));
int eap_midi_open __P((void *, int, void (*)(void *, int),
void (*)(void *), void *));
int eap_midi_output __P((void *, int));
void eap_midi_close(void *);
void eap_midi_getinfo(void *, struct midi_info *);
int eap_midi_open(void *, int, void (*)(void *, int),
void (*)(void *), void *);
int eap_midi_output(void *, int);
#endif
struct audio_hw_if eap1370_hw_if = {
@ -278,10 +278,7 @@ struct audio_device eap_device = {
};
int
eap_match(parent, match, aux)
struct device *parent;
struct cfdata *match;
void *aux;
eap_match(struct device *parent, struct cfdata *match, void *aux)
{
struct pci_attach_args *pa = (struct pci_attach_args *) aux;
@ -306,9 +303,7 @@ eap_match(parent, match, aux)
}
void
eap1370_write_codec(sc, a, d)
struct eap_softc *sc;
int a, d;
eap1370_write_codec(struct eap_softc *sc, int a, int d)
{
int icss, to;
@ -329,13 +324,8 @@ eap1370_write_codec(sc, a, d)
* FreeBSD and Linux drivers.
*/
static __inline void eap1371_ready_codec
__P((struct eap_softc *sc, u_int8_t a, u_int32_t wd));
static __inline void
eap1371_ready_codec(sc, a, wd)
struct eap_softc *sc;
u_int8_t a;
u_int32_t wd;
eap1371_ready_codec(struct eap_softc *sc, u_int8_t a, u_int32_t wd)
{
int to, s;
u_int32_t src, t;
@ -382,10 +372,7 @@ eap1371_ready_codec(sc, a, wd)
}
int
eap1371_read_codec(sc_, a, d)
void *sc_;
u_int8_t a;
u_int16_t *d;
eap1371_read_codec(void *sc_, u_int8_t a, u_int16_t *d)
{
struct eap_softc *sc = sc_;
int to;
@ -418,10 +405,7 @@ eap1371_read_codec(sc_, a, d)
}
int
eap1371_write_codec(sc_, a, d)
void *sc_;
u_int8_t a;
u_int16_t d;
eap1371_write_codec(void *sc_, u_int8_t a, u_int16_t d)
{
struct eap_softc *sc = sc_;
@ -433,8 +417,7 @@ eap1371_write_codec(sc_, a, d)
}
u_int32_t
eap1371_src_wait(sc)
struct eap_softc *sc;
eap1371_src_wait(struct eap_softc *sc)
{
int to;
u_int32_t src;
@ -450,9 +433,7 @@ eap1371_src_wait(sc)
}
int
eap1371_src_read(sc, a)
struct eap_softc *sc;
int a;
eap1371_src_read(struct eap_softc *sc, int a)
{
int to;
u_int32_t src, t;
@ -473,9 +454,7 @@ eap1371_src_read(sc, a)
}
void
eap1371_src_write(sc, a, d)
struct eap_softc *sc;
int a,d;
eap1371_src_write(struct eap_softc *sc, int a, int d)
{
u_int32_t r;
@ -485,9 +464,7 @@ eap1371_src_write(sc, a, d)
}
void
eap1371_set_adc_rate(sc, rate)
struct eap_softc *sc;
int rate;
eap1371_set_adc_rate(struct eap_softc *sc, int rate)
{
int freq, n, truncm;
int out;
@ -528,10 +505,7 @@ eap1371_set_adc_rate(sc, rate)
}
void
eap1371_set_dac_rate(sc, rate, which)
struct eap_softc *sc;
int rate;
int which;
eap1371_set_dac_rate(struct eap_softc *sc, int rate, int which)
{
int dac = which == 1 ? ESRC_DAC1 : ESRC_DAC2;
int freq, r;
@ -562,10 +536,7 @@ eap1371_set_dac_rate(sc, rate, which)
}
void
eap_attach(parent, self, aux)
struct device *parent;
struct device *self;
void *aux;
eap_attach(struct device *parent, struct device *self, void *aux)
{
struct eap_softc *sc = (struct eap_softc *)self;
struct pci_attach_args *pa = (struct pci_attach_args *)aux;
@ -761,9 +732,7 @@ eap_attach(parent, self, aux)
}
int
eap1371_attach_codec(sc_, codec_if)
void *sc_;
struct ac97_codec_if *codec_if;
eap1371_attach_codec(void *sc_, struct ac97_codec_if *codec_if)
{
struct eap_softc *sc = sc_;
@ -772,8 +741,7 @@ eap1371_attach_codec(sc_, codec_if)
}
void
eap1371_reset_codec(sc_)
void *sc_;
eap1371_reset_codec(void *sc_)
{
struct eap_softc *sc = sc_;
u_int32_t icsc;
@ -791,8 +759,7 @@ eap1371_reset_codec(sc_)
}
int
eap_intr(p)
void *p;
eap_intr(void *p)
{
struct eap_softc *sc = p;
u_int32_t intr, sic;
@ -850,11 +817,7 @@ eap_intr(p)
}
int
eap_allocmem(sc, size, align, p)
struct eap_softc *sc;
size_t size;
size_t align;
struct eap_dma *p;
eap_allocmem(struct eap_softc *sc, size_t size, size_t align, struct eap_dma *p)
{
int error;
@ -891,9 +854,7 @@ free:
}
int
eap_freemem(sc, p)
struct eap_softc *sc;
struct eap_dma *p;
eap_freemem(struct eap_softc *sc, struct eap_dma *p)
{
bus_dmamap_unload(sc->sc_dmatag, p->map);
bus_dmamap_destroy(sc->sc_dmatag, p->map);
@ -903,9 +864,7 @@ eap_freemem(sc, p)
}
int
eap_open(addr, flags)
void *addr;
int flags;
eap_open(void *addr, int flags)
{
return (0);
}
@ -914,8 +873,7 @@ eap_open(addr, flags)
* Close function is called at splaudio().
*/
void
eap_close(addr)
void *addr;
eap_close(void *addr)
{
struct eap_softc *sc = addr;
@ -927,9 +885,7 @@ eap_close(addr)
}
int
eap_query_encoding(addr, fp)
void *addr;
struct audio_encoding *fp;
eap_query_encoding(void *addr, struct audio_encoding *fp)
{
switch (fp->index) {
case 0:
@ -986,10 +942,8 @@ eap_query_encoding(addr, fp)
}
int
eap_set_params(addr, setmode, usemode, play, rec)
void *addr;
int setmode, usemode;
struct audio_params *play, *rec;
eap_set_params(void *addr, int setmode, int usemode,
struct audio_params *play, struct audio_params *rec)
{
struct eap_softc *sc = addr;
struct audio_params *p;
@ -1099,21 +1053,20 @@ eap_set_params(addr, setmode, usemode, play, rec)
}
int
eap_round_blocksize(addr, blk)
void *addr;
int blk;
eap_round_blocksize(void *addr, int blk)
{
return (blk & -32); /* keep good alignment */
}
int
eap_trigger_output(addr, start, end, blksize, intr, arg, param)
void *addr;
void *start, *end;
int blksize;
void (*intr) __P((void *));
void *arg;
struct audio_params *param;
eap_trigger_output(
void *addr,
void *start,
void *end,
int blksize,
void (*intr)(void *),
void *arg,
struct audio_params *param)
{
struct eap_softc *sc = addr;
struct eap_dma *p;
@ -1173,13 +1126,14 @@ eap_trigger_output(addr, start, end, blksize, intr, arg, param)
}
int
eap_trigger_input(addr, start, end, blksize, intr, arg, param)
void *addr;
void *start, *end;
int blksize;
void (*intr) __P((void *));
void *arg;
struct audio_params *param;
eap_trigger_input(
void *addr,
void *start,
void *end,
int blksize,
void (*intr)(void *),
void *arg,
struct audio_params *param)
{
struct eap_softc *sc = addr;
struct eap_dma *p;
@ -1238,8 +1192,7 @@ eap_trigger_input(addr, start, end, blksize, intr, arg, param)
}
int
eap_halt_output(addr)
void *addr;
eap_halt_output(void *addr)
{
struct eap_softc *sc = addr;
u_int32_t icsc;
@ -1254,8 +1207,7 @@ eap_halt_output(addr)
}
int
eap_halt_input(addr)
void *addr;
eap_halt_input(void *addr)
{
struct eap_softc *sc = addr;
u_int32_t icsc;
@ -1270,18 +1222,14 @@ eap_halt_input(addr)
}
int
eap_getdev(addr, retp)
void *addr;
struct audio_device *retp;
eap_getdev(void *addr, struct audio_device *retp)
{
*retp = eap_device;
return (0);
}
int
eap1371_mixer_set_port(addr, cp)
void *addr;
mixer_ctrl_t *cp;
eap1371_mixer_set_port(void *addr, mixer_ctrl_t *cp)
{
struct eap_softc *sc = addr;
@ -1289,9 +1237,7 @@ eap1371_mixer_set_port(addr, cp)
}
int
eap1371_mixer_get_port(addr, cp)
void *addr;
mixer_ctrl_t *cp;
eap1371_mixer_get_port(void *addr, mixer_ctrl_t *cp)
{
struct eap_softc *sc = addr;
@ -1299,9 +1245,7 @@ eap1371_mixer_get_port(addr, cp)
}
int
eap1371_query_devinfo(addr, dip)
void *addr;
mixer_devinfo_t *dip;
eap1371_query_devinfo(void *addr, mixer_devinfo_t *dip)
{
struct eap_softc *sc = addr;
@ -1309,18 +1253,15 @@ eap1371_query_devinfo(addr, dip)
}
int
eap1371_get_portnum_by_name(sc, class, device, qualifier)
struct eap_softc *sc;
char *class, *device, *qualifier;
eap1371_get_portnum_by_name(struct eap_softc *sc,
char *class, char *device, char *qualifier)
{
return (sc->codec_if->vtbl->get_portnum_by_name(sc->codec_if, class,
device, qualifier));
}
void
eap1370_set_mixer(sc, a, d)
struct eap_softc *sc;
int a, d;
eap1370_set_mixer(struct eap_softc *sc, int a, int d)
{
eap1370_write_codec(sc, a, d);
@ -1329,9 +1270,7 @@ eap1370_set_mixer(sc, a, d)
}
int
eap1370_mixer_set_port(addr, cp)
void *addr;
mixer_ctrl_t *cp;
eap1370_mixer_set_port(void *addr, mixer_ctrl_t *cp)
{
struct eap_softc *sc = addr;
int lval, rval, l, r, la, ra;
@ -1446,9 +1385,7 @@ eap1370_mixer_set_port(addr, cp)
}
int
eap1370_mixer_get_port(addr, cp)
void *addr;
mixer_ctrl_t *cp;
eap1370_mixer_get_port(void *addr, mixer_ctrl_t *cp)
{
struct eap_softc *sc = addr;
int la, ra, l, r;
@ -1515,9 +1452,7 @@ eap1370_mixer_get_port(addr, cp)
}
int
eap1370_query_devinfo(addr, dip)
void *addr;
mixer_devinfo_t *dip;
eap1370_query_devinfo(void *addr, mixer_devinfo_t *dip)
{
switch (dip->index) {
case EAP_MASTER_VOL:
@ -1655,11 +1590,7 @@ eap1370_query_devinfo(addr, dip)
}
void *
eap_malloc(addr, direction, size, pool, flags)
void *addr;
int direction;
size_t size;
int pool, flags;
eap_malloc(void *addr, int direction, size_t size, int pool, int flags)
{
struct eap_softc *sc = addr;
struct eap_dma *p;
@ -1679,10 +1610,7 @@ eap_malloc(addr, direction, size, pool, flags)
}
void
eap_free(addr, ptr, pool)
void *addr;
void *ptr;
int pool;
eap_free(void *addr, void *ptr, int pool)
{
struct eap_softc *sc = addr;
struct eap_dma **pp, *p;
@ -1698,20 +1626,13 @@ eap_free(addr, ptr, pool)
}
size_t
eap_round_buffersize(addr, direction, size)
void *addr;
int direction;
size_t size;
eap_round_buffersize(void *addr, int direction, size_t size)
{
return (size);
}
paddr_t
eap_mappage(addr, mem, off, prot)
void *addr;
void *mem;
off_t off;
int prot;
eap_mappage(void *addr, void *mem, off_t off, int prot)
{
struct eap_softc *sc = addr;
struct eap_dma *p;
@ -1727,8 +1648,7 @@ eap_mappage(addr, mem, off, prot)
}
int
eap_get_props(addr)
void *addr;
eap_get_props(void *addr)
{
return (AUDIO_PROP_MMAP | AUDIO_PROP_INDEPENDENT |
AUDIO_PROP_FULLDUPLEX);
@ -1736,12 +1656,10 @@ eap_get_props(addr)
#if NMIDI > 0
int
eap_midi_open(addr, flags, iintr, ointr, arg)
void *addr;
int flags;
void (*iintr)__P((void *, int));
void (*ointr)__P((void *));
void *arg;
eap_midi_open(void *addr, int flags,
void (*iintr)(void *, int),
void (*ointr)(void *),
void *arg)
{
struct eap_softc *sc = addr;
u_int32_t uctrl;
@ -1765,8 +1683,7 @@ eap_midi_open(addr, flags, iintr, ointr, arg)
}
void
eap_midi_close(addr)
void *addr;
eap_midi_close(void *addr)
{
struct eap_softc *sc = addr;
@ -1779,9 +1696,7 @@ eap_midi_close(addr)
}
int
eap_midi_output(addr, d)
void *addr;
int d;
eap_midi_output(void *addr, int d)
{
struct eap_softc *sc = addr;
int x;
@ -1797,9 +1712,7 @@ eap_midi_output(addr, d)
}
void
eap_midi_getinfo(addr, mi)
void *addr;
struct midi_info *mi;
eap_midi_getinfo(void *addr, struct midi_info *mi)
{
mi->name = "AudioPCI MIDI UART";
mi->props = MIDI_PROP_CAN_INPUT;