Subject: Re: uhci & ugen & isochronous transfer
To: YAMAMOTO Takashi <yamt@netbsd.org>
From: Lennart Augustsson <lennart@augustsson.net>
List: tech-kern
Date: 09/16/2001 18:35:27
It looks ok. I don't have any way to test isoc with the ugen driver
so if you have and it works I'll trust you. :-)
-- Lennart
YAMAMOTO Takashi wrote:
> I made a patch to make ugen use updated frlengths.
> is this ok to commit?
>
> ---
> YAMAMOTO Takashi<yamt@netbsd.org>
>
> Index: ugen.c
> ===================================================================
> RCS file: /cvs/cvsroot/syssrc/sys/dev/usb/ugen.c,v
> retrieving revision 1.45
> diff -u -r1.45 ugen.c
> --- ugen.c 2000/12/13 04:05:14 1.45
> +++ ugen.c 2001/09/16 13:55:16
> @@ -822,6 +822,7 @@
> struct isoreq *req = addr;
> struct ugen_endpoint *sce = req->sce;
> u_int32_t count, n;
> + int i, isize;
>
> /* Return if we are aborting. */
> if (status == USBD_CANCELLED)
> @@ -840,15 +841,25 @@
> count));
> }
>
> - /* copy data to buffer */
> - while (count > 0) {
> - n = min(count, sce->limit - sce->fill);
> - memcpy(sce->fill, req->dmabuf, n);
> -
> - count -= n;
> - sce->fill += n;
> - if(sce->fill == sce->limit)
> - sce->fill = sce->ibuf;
> + isize = UGETW(sce->edesc->wMaxPacketSize);
> + for (i = 0; i < UGEN_NISORFRMS; i++) {
> + u_int32_t actlen = req->sizes[i];
> + char const *buf = (char const *)req->dmabuf + isize * i;
> +
> + /* copy data to buffer */
> + while (actlen > 0) {
> + n = min(actlen, sce->limit - sce->fill);
> + memcpy(sce->fill, buf, n);
> +
> + buf += n;
> + actlen -= n;
> + sce->fill += n;
> + if(sce->fill == sce->limit)
> + sce->fill = sce->ibuf;
> + }
> +
> + /* setup size for next transfer */
> + req->sizes[i] = isize;
> }
>
> usbd_setup_isoc_xfer(xfer, sce->pipeh, req, req->sizes, UGEN_NISORFRMS,