Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/dev/usb Add a flag in the request to determine if the da...
details: https://anonhg.NetBSD.org/src/rev/3d464b4983be
branches: trunk
changeset: 476283:3d464b4983be
user: augustss <augustss%NetBSD.org@localhost>
date: Sun Sep 12 08:23:42 1999 +0000
description:
Add a flag in the request to determine if the data copying is done by the
driver or the usbdi layer.
diffstat:
sys/dev/usb/TODO | 2 --
sys/dev/usb/uaudio.c | 10 +++++++---
sys/dev/usb/uhub.c | 14 +++++++++++++-
sys/dev/usb/ulpt.c | 4 ++--
sys/dev/usb/usbdi.c | 38 +++++++++++++++++++++++++-------------
sys/dev/usb/usbdi.h | 8 +++++---
6 files changed, 52 insertions(+), 24 deletions(-)
diffs (252 lines):
diff -r b2fead35d51b -r 3d464b4983be sys/dev/usb/TODO
--- a/sys/dev/usb/TODO Sun Sep 12 08:21:49 1999 +0000
+++ b/sys/dev/usb/TODO Sun Sep 12 08:23:42 1999 +0000
@@ -38,8 +38,6 @@
implement input
test with more devices
-Preallocate buffer in ulpt.
-
Document device driver API.
Document HC driver API.
diff -r b2fead35d51b -r 3d464b4983be sys/dev/usb/uaudio.c
--- a/sys/dev/usb/uaudio.c Sun Sep 12 08:21:49 1999 +0000
+++ b/sys/dev/usb/uaudio.c Sun Sep 12 08:23:42 1999 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: uaudio.c,v 1.1 1999/09/09 12:28:25 augustss Exp $ */
+/* $NetBSD: uaudio.c,v 1.2 1999/09/12 08:23:42 augustss Exp $ */
/*
* Copyright (c) 1999 The NetBSD Foundation, Inc.
@@ -365,6 +365,7 @@
enum devact act;
{
struct uaudio_softc *sc = (struct uaudio_softc *)self;
+ int rv = 0;
switch (act) {
case DVACT_ACTIVATE:
@@ -372,10 +373,12 @@
break;
case DVACT_DEACTIVATE:
+ if (sc->sc_audiodev)
+ rv = config_deactivate(sc->sc_audiodev);
sc->sc_dying = 1;
break;
}
- return (0);
+ return (rv);
}
int
@@ -1832,7 +1835,8 @@
DPRINTFN(5,("uaudio_chan_transfer: transfer reqh=%p\n", cb->reqh));
/* Fill the request */
usbd_setup_isoc_request(cb->reqh, ch->pipe, cb, cb->sizes,
- UAUDIO_NFRAMES, uaudio_chan_pintr);
+ UAUDIO_NFRAMES, USBD_NO_COPY,
+ uaudio_chan_pintr);
(void)usbd_transfer(cb->reqh);
}
diff -r b2fead35d51b -r 3d464b4983be sys/dev/usb/uhub.c
--- a/sys/dev/usb/uhub.c Sun Sep 12 08:21:49 1999 +0000
+++ b/sys/dev/usb/uhub.c Sun Sep 12 08:23:42 1999 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: uhub.c,v 1.26 1999/09/05 19:32:18 augustss Exp $ */
+/* $NetBSD: uhub.c,v 1.27 1999/09/12 08:23:42 augustss Exp $ */
/*
* Copyright (c) 1998 The NetBSD Foundation, Inc.
@@ -491,12 +491,24 @@
device_ptr_t self;
enum devact act;
{
+ struct uhub_softc *sc = (struct uhub_softc *)self;
+ usbd_device_handle devhub = sc->sc_hub;
+ int nports, p, i;
+
switch (act) {
case DVACT_ACTIVATE:
return (EOPNOTSUPP);
break;
case DVACT_DEACTIVATE:
+ nports = devhub->hub->hubdesc.bNbrPorts;
+ for(p = 0; p < nports; p++) {
+ usbd_device_handle dev = devhub->hub->ports[p].device;
+ if (dev) {
+ for (i = 0; dev->subdevs[i]; i++)
+ config_deactivate(dev->subdevs[i]);
+ }
+ }
break;
}
return (0);
diff -r b2fead35d51b -r 3d464b4983be sys/dev/usb/ulpt.c
--- a/sys/dev/usb/ulpt.c Sun Sep 12 08:21:49 1999 +0000
+++ b/sys/dev/usb/ulpt.c Sun Sep 12 08:23:42 1999 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: ulpt.c,v 1.23 1999/09/11 10:40:07 augustss Exp $ */
+/* $NetBSD: ulpt.c,v 1.24 1999/09/12 08:23:42 augustss Exp $ */
/*
* Copyright (c) 1998 The NetBSD Foundation, Inc.
@@ -443,7 +443,7 @@
if (error)
break;
DPRINTFN(1, ("ulptwrite: transfer %d bytes\n", n));
- r = usbd_bulk_transfer(reqh, sc->sc_bulkpipe, 0,
+ r = usbd_bulk_transfer(reqh, sc->sc_bulkpipe, USBD_NO_COPY,
USBD_NO_TIMEOUT, buf, &n, "ulptwr");
if (r != USBD_NORMAL_COMPLETION) {
DPRINTF(("ulptwrite: error=%d\n", r));
diff -r b2fead35d51b -r 3d464b4983be sys/dev/usb/usbdi.c
--- a/sys/dev/usb/usbdi.c Sun Sep 12 08:21:49 1999 +0000
+++ b/sys/dev/usb/usbdi.c Sun Sep 12 08:23:42 1999 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: usbdi.c,v 1.37 1999/09/11 08:19:27 augustss Exp $ */
+/* $NetBSD: usbdi.c,v 1.38 1999/09/12 08:23:42 augustss Exp $ */
/*
* Copyright (c) 1998 The NetBSD Foundation, Inc.
@@ -215,6 +215,7 @@
usbd_request_handle reqh;
{
usbd_pipe_handle pipe = reqh->pipe;
+ usb_dma_t *dmap = &reqh->dmabuf;
usbd_status r;
u_int size;
int s;
@@ -228,9 +229,8 @@
reqh->done = 0;
size = reqh->length;
- /* If there is no buffer, allocate one and copy data. */
+ /* If there is no buffer, allocate one. */
if (!(reqh->rqflags & URQ_DEV_DMABUF) && size != 0) {
- usb_dma_t *dmap = &reqh->dmabuf;
struct usbd_bus *bus = pipe->device->bus;
#ifdef DIAGNOSTIC
@@ -241,11 +241,12 @@
if (r != USBD_NORMAL_COMPLETION)
return (r);
reqh->rqflags |= URQ_AUTO_DMABUF;
+ }
- /* finally copy data if going out */
- if (!usbd_reqh_isread(reqh))
- memcpy(KERNADDR(dmap), reqh->buffer, size);
- }
+ /* Copy data if going out. */
+ if (!(reqh->flags & USBD_NO_COPY) && size != 0 &&
+ !usbd_reqh_isread(reqh))
+ memcpy(KERNADDR(dmap), reqh->buffer, size);
r = pipe->methods->transfer(reqh);
@@ -313,6 +314,15 @@
reqh->device->bus->methods->freem(reqh->device->bus, &reqh->dmabuf);
}
+void *
+usbd_get_buffer(reqh)
+ usbd_request_handle reqh;
+{
+ if (!(reqh->rqflags & URQ_DEV_DMABUF))
+ return (0);
+ return (KERNADDR(&reqh->dmabuf));
+}
+
usbd_request_handle
usbd_alloc_request(dev)
usbd_device_handle dev;
@@ -399,12 +409,13 @@
}
void
-usbd_setup_isoc_request(reqh, pipe, priv, frlengths, nframes, callback)
+usbd_setup_isoc_request(reqh, pipe, priv, frlengths, nframes, flags, callback)
usbd_request_handle reqh;
usbd_pipe_handle pipe;
usbd_private_handle priv;
u_int16_t *frlengths;
u_int32_t nframes;
+ u_int16_t flags;
usbd_callback callback;
{
reqh->pipe = pipe;
@@ -412,7 +423,7 @@
reqh->buffer = 0;
reqh->length = 0;
reqh->actlen = 0;
- reqh->flags = 0;
+ reqh->flags = flags;
reqh->timeout = USBD_NO_TIMEOUT;
reqh->status = USBD_NOT_STARTED;
reqh->callback = callback;
@@ -710,6 +721,7 @@
usbd_request_handle reqh;
{
usbd_pipe_handle pipe = reqh->pipe;
+ usb_dma_t *dmap = &reqh->dmabuf;
int polling;
DPRINTFN(5, ("usb_transfer_complete: pipe=%p reqh=%p actlen=%d\n",
@@ -726,12 +738,12 @@
if (polling)
pipe->running = 0;
+ if (!(reqh->flags & USBD_NO_COPY) && reqh->actlen != 0 &&
+ usbd_reqh_isread(reqh))
+ memcpy(reqh->buffer, KERNADDR(dmap), reqh->actlen);
+
/* if we allocated the buffer in usbd_transfer() we free it here. */
if (reqh->rqflags & URQ_AUTO_DMABUF) {
- usb_dma_t *dmap = &reqh->dmabuf;
-
- if (usbd_reqh_isread(reqh))
- memcpy(reqh->buffer, KERNADDR(dmap), reqh->actlen);
if (!pipe->repeat) {
struct usbd_bus *bus = pipe->device->bus;
bus->methods->freem(bus, dmap);
diff -r b2fead35d51b -r 3d464b4983be sys/dev/usb/usbdi.h
--- a/sys/dev/usb/usbdi.h Sun Sep 12 08:21:49 1999 +0000
+++ b/sys/dev/usb/usbdi.h Sun Sep 12 08:23:42 1999 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: usbdi.h,v 1.28 1999/09/11 08:19:27 augustss Exp $ */
+/* $NetBSD: usbdi.h,v 1.29 1999/09/12 08:23:42 augustss Exp $ */
/*
* Copyright (c) 1998 The NetBSD Foundation, Inc.
@@ -78,8 +78,9 @@
#define USBD_EXCLUSIVE_USE 0x01
/* Request flags */
+#define USBD_NO_COPY 0x01 /* do not copy data to DMA buffer */
+#define USBD_SYNCHRONOUS 0x02 /* wait for completion */
/* in usb.h #define USBD_SHORT_XFER_OK 0x04*/ /* allow short reads */
-#define USBD_SYNCHRONOUS 0x08 /* wait for completion */
#define USBD_NO_TIMEOUT 0
#define USBD_DEFAULT_TIMEOUT 5000 /* ms = 5 s */
@@ -104,7 +105,7 @@
void usbd_setup_isoc_request
__P((usbd_request_handle reqh, usbd_pipe_handle pipe,
usbd_private_handle priv, u_int16_t *frlengths,
- u_int32_t nframes, usbd_callback));
+ u_int32_t nframes, u_int16_t flags, usbd_callback));
void usbd_get_request_status
__P((usbd_request_handle reqh, usbd_private_handle *priv,
void **buffer, u_int32_t *count, usbd_status *status));
@@ -125,6 +126,7 @@
usbd_device_handle usbd_pipe2device_handle __P((usbd_pipe_handle));
void *usbd_alloc_buffer __P((usbd_request_handle req, u_int32_t size));
void usbd_free_buffer __P((usbd_request_handle req));
+void *usbd_get_buffer __P((usbd_request_handle reqh));
usbd_status usbd_sync_transfer __P((usbd_request_handle req));
usbd_status usbd_open_pipe_intr
__P((usbd_interface_handle iface, u_int8_t address,
Home |
Main Index |
Thread Index |
Old Index