NetBSD Problem Report #8578
Received: (qmail 15061 invoked from network); 7 Oct 1999 16:42:46 -0000
Message-Id: <199910071642.SAA00487@yacht.domestic.de>
Date: Thu, 7 Oct 1999 18:42:49 +0200 (CEST)
From: kuebart@mathematik.uni-ulm.de
To: gnats-bugs@gnats.netbsd.org
Subject: Adding MIDI support to eap driver (Ensoniq AudioPCI)
X-Send-Pr-Version: 3.95
>Number: 8578
>Category: kern
>Synopsis: Adding MIDI support to eap driver (Ensoniq AudioPCI)
>Confidential: no
>Severity: non-critical
>Priority: low
>Responsible: kern-bug-people
>State: closed
>Class: change-request
>Submitter-Id: net
>Arrival-Date: Thu Oct 07 09:50:01 +0000 1999
>Closed-Date: Fri Oct 29 23:03:22 +0000 1999
>Last-Modified: Fri Oct 29 23:03:45 +0000 1999
>Originator: Joachim Kuebart
>Release: NetBSD-current, Oct 2, 1999
>Organization:
>Environment:
i386, NetBSD-current
System: NetBSD yacht 1.4K NetBSD 1.4K (YACHT) #54: Thu Oct 7 18:23:35 CEST 1999 joki@yacht:/usr/src/sys/arch/i386/compile/YACHT i386
>Description:
The MIDI UART of the AudioPCI is not supported.
>How-To-Repeat:
Use "eap* at pci?". You can't do "midi* at eap?".
>Fix:
The following patch adds support for the MIDI UART to the eap
driver (/sys/dev/pci/eap.c). It also tells config that eap
supplies a midibus.
cvs diff: Diffing .
Index: eap.c
===================================================================
RCS file: /home/cvs/netbsd/src/sys/dev/pci/eap.c,v
retrieving revision 1.1.1.3
diff -u -r1.1.1.3 eap.c
--- eap.c 1999/10/01 18:43:15 1.1.1.3
+++ eap.c 1999/10/07 16:36:44
@@ -50,9 +50,12 @@
* http://206.214.38.151/pdf/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>
@@ -61,6 +64,7 @@
#include <sys/audioio.h>
#include <dev/audio_if.h>
+#include <dev/midi_if.h>
#include <dev/mulaw.h>
#include <dev/auconv.h>
@@ -108,7 +112,14 @@
#define EAP_UART_DATA 0x08
#define EAP_UART_STATUS 0x09
+#define EAP_US_RXRDY 0x01
+#define EAP_US_TXRDY 0x02
+#define EAP_US_TXINT 0x04
+#define EAP_US_RXINT 0x80
#define EAP_UART_CONTROL 0x09
+#define EAP_UC_CNTRL 0x03
+#define EAP_UC_TXINTEN 0x20
+#define EAP_UC_RXINTEN 0x80
#define EAP_MEMPAGE 0x0c
#define EAP_CODEC 0x10
#define EAP_SET_CODEC(a,d) (((a)<<8) | (d))
@@ -227,6 +238,9 @@
#define EAP_RECORD_CLASS 11
#define EAP_INPUT_CLASS 12
+#define MIDI_BUSY_WAIT 100
+#define MIDI_BUSY_DELAY 100 /* Delay when UART is busy */
+
#ifdef AUDIO_DEBUG
#define DPRINTF(x) if (eapdebug) printf x
#define DPRINTFN(n,x) if (eapdebug>(n)) printf x
@@ -272,6 +286,12 @@
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;
+#endif
+
u_char 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 */
@@ -281,8 +301,10 @@
int eap_allocmem __P((struct eap_softc *, size_t, size_t, struct eap_dma *));
int eap_freemem __P((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))
@@ -312,6 +334,13 @@
int eap_get_props __P((void *));
void eap_write_codec __P((struct eap_softc *sc, int a, int d));
void eap_set_mixer __P((struct eap_softc *sc, int a, int d));
+#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));
+#endif
struct audio_hw_if eap_hw_if = {
eap_open,
@@ -342,6 +371,16 @@
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",
"",
@@ -460,6 +499,10 @@
eap_mixer_set_port(sc, &ctl);
audio_attach_mi(&eap_hw_if, sc, &sc->sc_dev);
+
+#if NMIDI > 0
+ midi_attach_mi(&eap_midi_hw_if, sc, &sc->sc_dev);
+#endif
}
int
@@ -506,6 +549,19 @@
if (sc->sc_pintr)
sc->sc_pintr(sc->sc_parg);
}
+#if NMIDI > 0
+ if (intr & EAP_I_UART) {
+ 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);
+ if (sc->sc_iintr)
+ sc->sc_iintr(sc->sc_arg, data);
+ }
+ }
+ }
+#endif
return (1);
}
@@ -1344,3 +1400,75 @@
{
return (AUDIO_PROP_MMAP | AUDIO_PROP_INDEPENDENT | AUDIO_PROP_FULLDUPLEX);
}
+
+#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;
+{
+ 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(addr)
+ void *addr;
+{
+ struct eap_softc *sc = addr;
+
+ 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(addr, d)
+ 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(addr, mi)
+ void *addr;
+ struct midi_info *mi;
+{
+ mi->name = "AudioPCI MIDI UART";
+ mi->props = MIDI_PROP_CAN_INPUT;
+}
+
+#endif
Index: files.pci
===================================================================
RCS file: /home/cvs/netbsd/src/sys/dev/pci/files.pci,v
retrieving revision 1.1.1.6
diff -u -r1.1.1.6 files.pci
--- files.pci 1999/10/01 18:43:09 1.1.1.6
+++ files.pci 1999/10/07 13:02:13
@@ -145,7 +145,7 @@
file dev/pci/tga_bt485.c tga
# Ensoniq AudioPCI S5016
-device eap: audio, auconv, mulaw
+device eap: audio, auconv, mulaw, midibus
attach eap at pci
file dev/pci/eap.c eap
>Release-Note:
>Audit-Trail:
State-Changed-From-To: open->closed
State-Changed-By: augustss
State-Changed-When: Fri Oct 29 16:03:22 PDT 1999
State-Changed-Why:
Patch applied.
>Unformatted:
(Contact us)
$NetBSD: query-full-pr,v 1.51 2026/08/10 02:28:17 riastradh Exp $
$NetBSD: gnats_config.sh,v 1.10 2026/05/13 22:00:09 riastradh Exp $
Copyright © 1994-2026
The NetBSD Foundation, Inc. ALL RIGHTS RESERVED.