summaryrefslogtreecommitdiff
path: root/sys
diff options
context:
space:
mode:
authorJonathan Gray <jsg@cvs.openbsd.org>2004-12-17 08:04:46 +0000
committerJonathan Gray <jsg@cvs.openbsd.org>2004-12-17 08:04:46 +0000
commit2fc82003bd2a62998b3b16fa611b838c653b7c7f (patch)
tree6438353f47cc6d4242137321ae1dede45d1d57b7 /sys
parent92c57630e3134659657a1da7cf05129313db750f (diff)
Support for the eap MIDI UART from NetBSD.
Tested by serveral people. ok millert@, mickey@
Diffstat (limited to 'sys')
-rw-r--r--sys/arch/alpha/conf/GENERIC3
-rw-r--r--sys/arch/amd64/conf/GENERIC3
-rw-r--r--sys/arch/cats/conf/GENERIC3
-rw-r--r--sys/arch/i386/conf/GENERIC3
-rw-r--r--sys/arch/macppc/conf/GENERIC5
-rw-r--r--sys/arch/sparc64/conf/GENERIC3
-rw-r--r--sys/dev/pci/eap.c112
-rw-r--r--sys/dev/pci/files.pci4
8 files changed, 127 insertions, 9 deletions
diff --git a/sys/arch/alpha/conf/GENERIC b/sys/arch/alpha/conf/GENERIC
index 41651f1b2b1..3eb72767e00 100644
--- a/sys/arch/alpha/conf/GENERIC
+++ b/sys/arch/alpha/conf/GENERIC
@@ -1,4 +1,4 @@
-# $OpenBSD: GENERIC,v 1.132 2004/12/08 12:29:29 martin Exp $
+# $OpenBSD: GENERIC,v 1.133 2004/12/17 08:04:45 jsg Exp $
# $NetBSD: GENERIC,v 1.31 1996/12/03 17:25:29 cgd Exp $
machine alpha
@@ -322,6 +322,7 @@ opl* at eso?
# MIDI support
midi* at opl? # OPL FM synth
+#midi* at eap?
#Audio Support
audio* at eap?
diff --git a/sys/arch/amd64/conf/GENERIC b/sys/arch/amd64/conf/GENERIC
index 890938f4f9f..dea0b31eb2c 100644
--- a/sys/arch/amd64/conf/GENERIC
+++ b/sys/arch/amd64/conf/GENERIC
@@ -1,4 +1,4 @@
-# $OpenBSD: GENERIC,v 1.40 2004/12/13 23:30:12 millert Exp $
+# $OpenBSD: GENERIC,v 1.41 2004/12/17 08:04:45 jsg Exp $
#
# GENERIC -- everything that's currently supported
#
@@ -352,6 +352,7 @@ opl* at yds?
#midi* at pcppi? # MIDI interface to the PC speaker
#midi* at opl? # OPL FM synth
#midi* at autri?
+midi* at eap?
# The spkr driver provides a simple tone interface to the built in speaker.
#spkr0 at pcppi? # PC speaker
diff --git a/sys/arch/cats/conf/GENERIC b/sys/arch/cats/conf/GENERIC
index ddf08d0db6a..7725ae50b6f 100644
--- a/sys/arch/cats/conf/GENERIC
+++ b/sys/arch/cats/conf/GENERIC
@@ -1,4 +1,4 @@
-# $OpenBSD: GENERIC,v 1.15 2004/11/12 18:07:42 deraadt Exp $
+# $OpenBSD: GENERIC,v 1.16 2004/12/17 08:04:45 jsg Exp $
#
# GENERIC machine description file
#
@@ -294,6 +294,7 @@ ds1687rtc0 at isa? port 0x72 # Dallas RTC
# MIDI support
midi* at pcppi? # MIDI interface to the PC speaker
#midi* at mpu? # MPU 401
+#midi* at eap?
# Joysticks
diff --git a/sys/arch/i386/conf/GENERIC b/sys/arch/i386/conf/GENERIC
index 5c21002d1fd..5deac1eec48 100644
--- a/sys/arch/i386/conf/GENERIC
+++ b/sys/arch/i386/conf/GENERIC
@@ -1,4 +1,4 @@
-# $OpenBSD: GENERIC,v 1.389 2004/12/08 08:05:44 dlg Exp $
+# $OpenBSD: GENERIC,v 1.390 2004/12/17 08:04:45 jsg Exp $
#
# GENERIC -- everything that's currently supported
#
@@ -511,6 +511,7 @@ midi* at opl? # OPL FM synth
midi* at ym?
midi* at mpu?
midi* at autri?
+midi* at eap?
# The spkr driver provides a simple tone interface to the built in speaker.
#spkr0 at pcppi? # PC speaker
diff --git a/sys/arch/macppc/conf/GENERIC b/sys/arch/macppc/conf/GENERIC
index b3fc7db32b9..c7dbeaab95a 100644
--- a/sys/arch/macppc/conf/GENERIC
+++ b/sys/arch/macppc/conf/GENERIC
@@ -1,4 +1,4 @@
-# $OpenBSD: GENERIC,v 1.63 2004/12/08 08:05:44 dlg Exp $g
+# $OpenBSD: GENERIC,v 1.64 2004/12/17 08:04:45 jsg Exp $g
#
# PPC GENERIC config file
#
@@ -242,6 +242,9 @@ wdc* at pcmcia?
wsdisplay* at vgafb?
wskbd* at ukbd? mux 1
+# MIDI support
+#midi* at eap?
+
# Audio support
audio* at awacs?
audio* at snapper?
diff --git a/sys/arch/sparc64/conf/GENERIC b/sys/arch/sparc64/conf/GENERIC
index 6562bdac0df..cb63455d0c6 100644
--- a/sys/arch/sparc64/conf/GENERIC
+++ b/sys/arch/sparc64/conf/GENERIC
@@ -1,4 +1,4 @@
-# $OpenBSD: GENERIC,v 1.110 2004/11/29 18:12:50 miod Exp $
+# $OpenBSD: GENERIC,v 1.111 2004/12/17 08:04:45 jsg Exp $
# $NetBSD: GENERIC32,v 1.18 2001/07/20 00:07:12 eeh Exp $
machine sparc64
@@ -85,6 +85,7 @@ opl* at eso?
# MIDI support
midi* at autri?
midi* at opl?
+#midi* at eap?
# PCI USB Controllers
ohci* at pci? # Open Host Controller
diff --git a/sys/dev/pci/eap.c b/sys/dev/pci/eap.c
index 552909c9c7c..f53a41bec41 100644
--- a/sys/dev/pci/eap.c
+++ b/sys/dev/pci/eap.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: eap.c,v 1.22 2004/12/07 03:17:42 jsg Exp $ */
+/* $OpenBSD: eap.c,v 1.23 2004/12/17 08:04:45 jsg Exp $ */
/* $NetBSD: eap.c,v 1.46 2001/09/03 15:07:37 reinoud Exp $ */
/*
@@ -54,9 +54,12 @@
* ftp://ftp.alsa-project.org/pub/manuals/asahi_kasei/4531.pdf
*/
+#include "midi.h"
+
#include <sys/param.h>
#include <sys/systm.h>
#include <sys/kernel.h>
+#include <sys/fcntl.h>
#include <sys/malloc.h>
#include <sys/device.h>
#include <sys/proc.h>
@@ -66,6 +69,7 @@
#include <sys/audioio.h>
#include <dev/audio_if.h>
+#include <dev/midi_if.h>
#include <dev/mulaw.h>
#include <dev/auconv.h>
#include <dev/ic/ac97.h>
@@ -127,6 +131,13 @@ struct eap_softc {
char sc_rrun;
#endif
+#if NMIDI > 0
+ void (*sc_iintr)(void *, int); /* midi input ready handler */
+ void (*sc_ointr)(void *); /* midi output ready handler */
+ void *sc_arg;
+ struct device *sc_mididev;
+#endif
+
u_short sc_port[AK_NPORTS]; /* mirror of the hardware setting */
u_int sc_record_source; /* recording source mask */
u_int sc_output_source; /* output source mask */
@@ -143,8 +154,10 @@ enum ac97_host_flags eap_flags_codec(void *);
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))
#define EWRITE4(sc, r, x) bus_space_write_4((sc)->iot, (sc)->ioh, (r), (x))
+#define EREAD1(sc, r) bus_space_read_1((sc)->iot, (sc)->ioh, (r))
#define EREAD2(sc, r) bus_space_read_2((sc)->iot, (sc)->ioh, (r))
#define EREAD4(sc, r) bus_space_read_4((sc)->iot, (sc)->ioh, (r))
@@ -189,6 +202,13 @@ 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(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 = {
eap_open,
@@ -248,6 +268,16 @@ struct audio_hw_if eap1371_hw_if = {
eap_trigger_input,
};
+#if NMIDI > 0
+struct midi_hw_if eap_midi_hw_if = {
+ eap_midi_open,
+ eap_midi_close,
+ eap_midi_output,
+ eap_midi_getinfo,
+ 0, /* ioctl */
+};
+#endif
+
struct audio_device eap_device = {
"Ensoniq AudioPCI",
"",
@@ -689,6 +719,9 @@ eap_attach(struct device *parent, struct device *self, void *aux)
}
audio_attach_mi(eap_hw_if, sc, &sc->sc_dev);
+#if NMIDI > 0
+ sc->sc_mididev = midi_attach_mi(&eap_midi_hw_if, sc, &sc->sc_dev);
+#endif
}
int
@@ -764,6 +797,18 @@ eap_intr(void *p)
if (sc->sc_pintr)
sc->sc_pintr(sc->sc_parg);
}
+#if NMIDI > 0
+ if ((intr & EAP_I_UART) && sc->sc_iintr != NULL) {
+ u_int32_t data;
+
+ if (EREAD1(sc, EAP_UART_STATUS) & EAP_US_RXINT) {
+ while (EREAD1(sc, EAP_UART_STATUS) & EAP_US_RXRDY) {
+ data = EREAD1(sc, EAP_UART_DATA);
+ sc->sc_iintr(sc->sc_arg, data);
+ }
+ }
+ }
+#endif
return (1);
}
@@ -1640,3 +1685,68 @@ eap_flags_codec(void *v)
return (sc->flags);
}
+#if NMIDI > 0
+int
+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;
+
+ sc->sc_iintr = iintr;
+ sc->sc_ointr = ointr;
+ sc->sc_arg = arg;
+
+ EWRITE4(sc, EAP_ICSC, EREAD4(sc, EAP_ICSC) | EAP_UART_EN);
+ uctrl = 0;
+ if (flags & FREAD)
+ uctrl |= EAP_UC_RXINTEN;
+#if 0
+ /* I don't understand ../midi.c well enough to use output interrupts */
+ if (flags & FWRITE)
+ uctrl |= EAP_UC_TXINTEN; */
+#endif
+ EWRITE1(sc, EAP_UART_CONTROL, uctrl);
+
+ return (0);
+}
+
+void
+eap_midi_close(void *addr)
+{
+ struct eap_softc *sc = addr;
+
+ tsleep(sc, PWAIT, "eapclm", hz/10); /* give uart a chance to drain */
+ EWRITE1(sc, EAP_UART_CONTROL, 0);
+ EWRITE4(sc, EAP_ICSC, EREAD4(sc, EAP_ICSC) & ~EAP_UART_EN);
+
+ sc->sc_iintr = 0;
+ sc->sc_ointr = 0;
+}
+
+int
+eap_midi_output(void *addr, int d)
+{
+ struct eap_softc *sc = addr;
+ int x;
+
+ for (x = 0; x != MIDI_BUSY_WAIT; x++) {
+ if (EREAD1(sc, EAP_UART_STATUS) & EAP_US_TXRDY) {
+ EWRITE1(sc, EAP_UART_DATA, d);
+ return (0);
+ }
+ delay(MIDI_BUSY_DELAY);
+ }
+ return (EIO);
+}
+
+void
+eap_midi_getinfo(void *addr, struct midi_info *mi)
+{
+ mi->name = "AudioPCI MIDI UART";
+ mi->props = MIDI_PROP_CAN_INPUT;
+}
+
+#endif
diff --git a/sys/dev/pci/files.pci b/sys/dev/pci/files.pci
index 0084a7e77a4..85ce0be2a0b 100644
--- a/sys/dev/pci/files.pci
+++ b/sys/dev/pci/files.pci
@@ -1,4 +1,4 @@
-# $OpenBSD: files.pci,v 1.166 2004/12/14 01:50:42 deraadt Exp $
+# $OpenBSD: files.pci,v 1.167 2004/12/17 08:04:45 jsg Exp $
# $NetBSD: files.pci,v 1.20 1996/09/24 17:47:15 christos Exp $
#
# Config file and device description for machine-independent PCI code.
@@ -82,7 +82,7 @@ attach iop at pci with iop_pci
file dev/pci/iop_pci.c iop_pci
# Ensoniq AudioPCI S5016, 1371
-device eap: audio, auconv, mulaw, ac97
+device eap: audio, auconv, mulaw, ac97, midibus
attach eap at pci
file dev/pci/eap.c eap