Add a flag in the request to determine if the data copying is done by the
driver or the usbdi layer.
This commit is contained in:
parent
305998532f
commit
b1a719a6cc
|
@ -38,8 +38,6 @@ uaudio problems:
|
|||
implement input
|
||||
test with more devices
|
||||
|
||||
Preallocate buffer in ulpt.
|
||||
|
||||
Document device driver API.
|
||||
|
||||
Document HC driver API.
|
||||
|
|
|
@ -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 @@ uaudio_activate(self, act)
|
|||
enum devact act;
|
||||
{
|
||||
struct uaudio_softc *sc = (struct uaudio_softc *)self;
|
||||
int rv = 0;
|
||||
|
||||
switch (act) {
|
||||
case DVACT_ACTIVATE:
|
||||
|
@ -372,10 +373,12 @@ uaudio_activate(self, act)
|
|||
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 @@ uaudio_chan_transfer(ch)
|
|||
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);
|
||||
}
|
||||
|
|
|
@ -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 @@ uhub_activate(self, act)
|
|||
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);
|
||||
|
|
|
@ -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 @@ ulpt_do_write(sc, uio, flags)
|
|||
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));
|
||||
|
|
|
@ -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_transfer(reqh)
|
|||
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 @@ usbd_transfer(reqh)
|
|||
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,12 +241,13 @@ usbd_transfer(reqh)
|
|||
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);
|
||||
|
||||
if (r != USBD_IN_PROGRESS && r != USBD_NORMAL_COMPLETION) {
|
||||
|
@ -313,6 +314,15 @@ usbd_free_buffer(reqh)
|
|||
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 @@ usbd_setup_default_request(reqh, dev, priv, timeout, req, buffer,
|
|||
}
|
||||
|
||||
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 @@ usbd_setup_isoc_request(reqh, pipe, priv, frlengths, nframes, callback)
|
|||
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 @@ usb_transfer_complete(reqh)
|
|||
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 @@ usb_transfer_complete(reqh)
|
|||
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);
|
||||
|
|
|
@ -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 @@ typedef void (*usbd_callback) __P((usbd_request_handle, usbd_private_handle,
|
|||
#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_default_request
|
|||
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_status usbd_device2interface_handle
|
|||
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,
|
||||
|
|
Loading…
Reference in New Issue