Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/jmcneill-audiomp3]: src/sys/dev/usb port umidi to audiomp: get_locks sup...
details: https://anonhg.NetBSD.org/src/rev/547d9dbdeb59
branches: jmcneill-audiomp3
changeset: 771395:547d9dbdeb59
user: mrg <mrg%NetBSD.org@localhost>
date: Tue Nov 22 07:56:15 2011 +0000
description:
port umidi to audiomp: get_locks support, take locks in interrupts.
untested, and midi in this branch has general problems still anyway.
diffstat:
sys/dev/usb/umidi.c | 35 ++++++++++++++++++++++++++++-------
sys/dev/usb/umidivar.h | 5 ++++-
2 files changed, 32 insertions(+), 8 deletions(-)
diffs (143 lines):
diff -r 845e46db1b86 -r 547d9dbdeb59 sys/dev/usb/umidi.c
--- a/sys/dev/usb/umidi.c Tue Nov 22 07:54:45 2011 +0000
+++ b/sys/dev/usb/umidi.c Tue Nov 22 07:56:15 2011 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: umidi.c,v 1.44 2011/10/07 19:41:03 jakllsch Exp $ */
+/* $NetBSD: umidi.c,v 1.44.4.1 2011/11/22 07:56:15 mrg Exp $ */
/*
* Copyright (c) 2001 The NetBSD Foundation, Inc.
* All rights reserved.
@@ -30,7 +30,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: umidi.c,v 1.44 2011/10/07 19:41:03 jakllsch Exp $");
+__KERNEL_RCSID(0, "$NetBSD: umidi.c,v 1.44.4.1 2011/11/22 07:56:15 mrg Exp $");
#include <sys/types.h>
#include <sys/param.h>
@@ -79,6 +79,7 @@
static int umidi_sysex(void *, u_char *, int);
static int umidi_rtmsg(void *, int);
static void umidi_getinfo(void *, struct midi_info *);
+static void umidi_get_locks(void *, kmutex_t **, kmutex_t **);
static usbd_status alloc_pipe(struct umidi_endpoint *);
static void free_pipe(struct umidi_endpoint *);
@@ -127,11 +128,11 @@
const struct midi_hw_if umidi_hw_if = {
- umidi_open,
- umidi_close,
- umidi_rtmsg,
- umidi_getinfo,
- 0, /* ioctl */
+ .open = umidi_open,
+ .close = umidi_close,
+ .output = umidi_rtmsg,
+ .getinfo = umidi_getinfo,
+ .get_locks = umidi_get_locks,
};
struct midi_hw_if_ext umidi_hw_if_ext = {
@@ -200,6 +201,8 @@
aprint_normal_dev(self, "");
umidi_print_quirk(sc->sc_quirk);
+ mutex_init(&sc->sc_lock, MUTEX_DEFAULT, IPL_NONE);
+ mutex_init(&sc->sc_intr_lock, MUTEX_DEFAULT, IPL_USB);
err = alloc_all_endpoints(sc);
if (err!=USBD_NORMAL_COMPLETION) {
@@ -297,6 +300,9 @@
usbd_add_drv_event(USB_EVENT_DRIVER_DETACH, sc->sc_udev,
sc->sc_dev);
+ mutex_destroy(&sc->sc_lock);
+ mutex_destroy(&sc->sc_intr_lock);
+
return 0;
}
@@ -436,6 +442,15 @@
midi_register_hw_if_ext(mm? &umidi_hw_if_mm : &umidi_hw_if_ext);
}
+static void
+umidi_get_locks(void *addr, kmutex_t **intr, kmutex_t **thread)
+{
+ struct umidi_mididev *mididev = addr;
+ struct umidi_softc *sc = mididev->sc;
+
+ *intr = &sc->sc_intr_lock;
+ *thread = &sc->sc_lock;
+}
/*
* each endpoint stuffs
@@ -1547,6 +1562,7 @@
{
int cn, len, i;
struct umidi_endpoint *ep = (struct umidi_endpoint *)priv;
+ struct umidi_softc *sc = ep->sc;
struct umidi_jack *jack;
unsigned char *packet;
umidi_packet_bufp slot;
@@ -1557,6 +1573,7 @@
if (ep->sc->sc_dying || !ep->num_open)
return;
+ mutex_enter(&sc->sc_intr_lock);
usbd_get_xfer_status(xfer, NULL, NULL, &count, NULL);
if ( 0 == count % UMIDI_PACKET_SIZE ) {
DPRINTFN(200,("%s: input endpoint %p transfer length %u\n",
@@ -1588,6 +1605,7 @@
(unsigned)data[0],
(unsigned)data[1],
(unsigned)data[2]));
+ mutex_exit(&sc->sc_intr_lock);
return;
}
@@ -1610,6 +1628,7 @@
}
(void)start_input_transfer(ep);
+ mutex_exit(&sc->sc_intr_lock);
}
static void
@@ -1623,6 +1642,7 @@
if (sc->sc_dying)
return;
+ mutex_enter(&sc->sc_intr_lock);
#ifdef UMIDI_DEBUG
if ( umididebug >= 200 )
microtime(&umidi_tv);
@@ -1657,6 +1677,7 @@
ep->soliciting = 1;
out_solicit(ep);
}
+ mutex_exit(&sc->sc_intr_lock);
}
/*
diff -r 845e46db1b86 -r 547d9dbdeb59 sys/dev/usb/umidivar.h
--- a/sys/dev/usb/umidivar.h Tue Nov 22 07:54:45 2011 +0000
+++ b/sys/dev/usb/umidivar.h Tue Nov 22 07:56:15 2011 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: umidivar.h,v 1.14 2010/11/03 22:34:24 dyoung Exp $ */
+/* $NetBSD: umidivar.h,v 1.14.10.1 2011/11/22 07:56:15 mrg Exp $ */
/*
* Copyright (c) 2001 The NetBSD Foundation, Inc.
* All rights reserved.
@@ -119,4 +119,7 @@
struct umidi_endpoint *sc_in_ep;
struct umidi_endpoint *sc_endpoints;
int cblnums_global;
+
+ kmutex_t sc_lock;
+ kmutex_t sc_intr_lock;
};
Home |
Main Index |
Thread Index |
Old Index