summaryrefslogtreecommitdiff
path: root/sys
diff options
context:
space:
mode:
authorAaron Campbell <aaron@cvs.openbsd.org>2000-11-08 18:10:40 +0000
committerAaron Campbell <aaron@cvs.openbsd.org>2000-11-08 18:10:40 +0000
commit96193b435e7220a9f8f67ac9bfc6b65078b640dd (patch)
tree74eb2fdcb11cee875aa2f839f567d32c10c92b5f /sys
parent20c739f74e8cfbfe57d19328e02606c2ed711946 (diff)
Sync with NetBSD. Too many changes to mention. For now I have skipped
umass.c and ukbd.c as the diffs are a bit hairier.
Diffstat (limited to 'sys')
-rw-r--r--sys/dev/usb/TODO12
-rw-r--r--sys/dev/usb/hid.c45
-rw-r--r--sys/dev/usb/hid.h21
-rw-r--r--sys/dev/usb/ohci.c548
-rw-r--r--sys/dev/usb/ohcireg.h4
-rw-r--r--sys/dev/usb/ohcivar.h12
-rw-r--r--sys/dev/usb/uaudio.c469
-rw-r--r--sys/dev/usb/uaudioreg.h4
-rw-r--r--sys/dev/usb/ucom.c241
-rw-r--r--sys/dev/usb/ucomvar.h36
-rw-r--r--sys/dev/usb/ugen.c296
-rw-r--r--sys/dev/usb/uhci.c803
-rw-r--r--sys/dev/usb/uhcireg.h13
-rw-r--r--sys/dev/usb/uhcivar.h20
-rw-r--r--sys/dev/usb/uhid.c80
-rw-r--r--sys/dev/usb/uhub.c42
-rw-r--r--sys/dev/usb/ukbdmap.c1
-rw-r--r--sys/dev/usb/ukbdvar.h1
-rw-r--r--sys/dev/usb/ulpt.c62
-rw-r--r--sys/dev/usb/umodem.c128
-rw-r--r--sys/dev/usb/ums.c10
-rw-r--r--sys/dev/usb/urio.c6
-rw-r--r--sys/dev/usb/urio.h4
-rw-r--r--sys/dev/usb/usb.c93
-rw-r--r--sys/dev/usb/usb.h4
-rw-r--r--sys/dev/usb/usb_mem.c33
-rw-r--r--sys/dev/usb/usb_mem.h11
-rw-r--r--sys/dev/usb/usb_port.h42
-rw-r--r--sys/dev/usb/usb_quirks.c14
-rw-r--r--sys/dev/usb/usb_quirks.h25
-rw-r--r--sys/dev/usb/usb_subr.c216
-rw-r--r--sys/dev/usb/usbcdc.h4
-rw-r--r--sys/dev/usb/usbdi.c261
-rw-r--r--sys/dev/usb/usbdi.h173
-rw-r--r--sys/dev/usb/usbdi_util.c141
-rw-r--r--sys/dev/usb/usbdi_util.h93
-rw-r--r--sys/dev/usb/usbdivar.h87
-rw-r--r--sys/dev/usb/usbhid.h32
-rw-r--r--sys/dev/usb/uvisor.c6
39 files changed, 1855 insertions, 2238 deletions
diff --git a/sys/dev/usb/TODO b/sys/dev/usb/TODO
index fdd8eb79a8a..28088a69fb3 100644
--- a/sys/dev/usb/TODO
+++ b/sys/dev/usb/TODO
@@ -1,8 +1,10 @@
Some things that need to be done:
---------------------------------
-Before 1.5:
------------
+High priority:
+--------------
+
+On a short control transfer the status phase needs to be executed anyway.
Allow interrupt out endpoints. (USB 1.1)
@@ -26,8 +28,6 @@ mel kravitz's problem, lockups with disk and printer
Aaron's problem: Test aue with ohci.
-Y-E data floppy doesn't work.
-
General:
--------
@@ -35,8 +35,6 @@ General:
Figure out why uvisor is so slow.
Try to get specs, and check if Linux driver is really right.
-Translate UFI commands?
-
Add lots of bus_dmamap_sync().
Do bandwidth accounting.
@@ -87,8 +85,6 @@ Get rid of hcpriv.
Keyspan serial driver
-Factor out comon code in network drivers.
-
Documentation:
--------------
diff --git a/sys/dev/usb/hid.c b/sys/dev/usb/hid.c
index 1907b6ca708..dcd656415cc 100644
--- a/sys/dev/usb/hid.c
+++ b/sys/dev/usb/hid.c
@@ -1,5 +1,5 @@
-/* $OpenBSD: hid.c,v 1.8 2000/07/04 11:44:21 fgsch Exp $ */
-/* $NetBSD: hid.c,v 1.14 2000/04/06 22:58:32 augustss Exp $ */
+/* $OpenBSD: hid.c,v 1.9 2000/11/08 18:10:37 aaron Exp $ */
+/* $NetBSD: hid.c,v 1.16 2000/06/01 14:28:57 augustss Exp $ */
/* $FreeBSD: src/sys/dev/usb/hid.c,v 1.11 1999/11/17 22:33:39 n_hibma Exp $ */
/*
@@ -60,7 +60,7 @@ extern int usbdebug;
#define DPRINTFN(n,x)
#endif
-Static void hid_clear_local __P((struct hid_item *));
+Static void hid_clear_local(struct hid_item *);
#define MAXUSAGE 100
struct hid_data {
@@ -77,8 +77,7 @@ struct hid_data {
};
Static void
-hid_clear_local(c)
- struct hid_item *c;
+hid_clear_local(struct hid_item *c)
{
c->usage = 0;
@@ -94,10 +93,7 @@ hid_clear_local(c)
}
struct hid_data *
-hid_start_parse(d, len, kindset)
- void *d;
- int len;
- int kindset;
+hid_start_parse(void *d, int len, int kindset)
{
struct hid_data *s;
@@ -110,8 +106,7 @@ hid_start_parse(d, len, kindset)
}
void
-hid_end_parse(s)
- struct hid_data *s;
+hid_end_parse(struct hid_data *s)
{
while (s->cur.next != NULL) {
@@ -123,9 +118,7 @@ hid_end_parse(s)
}
int
-hid_get_item(s, h)
- struct hid_data *s;
- struct hid_item *h;
+hid_get_item(struct hid_data *s, struct hid_item *h)
{
struct hid_item *c = &s->cur;
unsigned int bTag, bType, bSize;
@@ -374,11 +367,7 @@ hid_get_item(s, h)
}
int
-hid_report_size(buf, len, k, idp)
- void *buf;
- int len;
- enum hid_kind k;
- u_int8_t *idp;
+hid_report_size(void *buf, int len, enum hid_kind k, u_int8_t *idp)
{
struct hid_data *d;
struct hid_item h;
@@ -399,13 +388,8 @@ hid_report_size(buf, len, k, idp)
}
int
-hid_locate(desc, size, u, k, loc, flags)
- void *desc;
- int size;
- u_int32_t u;
- enum hid_kind k;
- struct hid_location *loc;
- u_int32_t *flags;
+hid_locate(void *desc, int size, u_int32_t u, enum hid_kind k,
+ struct hid_location *loc, u_int32_t *flags)
{
struct hid_data *d;
struct hid_item h;
@@ -426,9 +410,7 @@ hid_locate(desc, size, u, k, loc, flags)
}
u_long
-hid_get_data(buf, loc)
- u_char *buf;
- struct hid_location *loc;
+hid_get_data(u_char *buf, struct hid_location *loc)
{
u_int hpos = loc->pos;
u_int hsize = loc->size;
@@ -455,10 +437,7 @@ hid_get_data(buf, loc)
}
int
-hid_is_collection(desc, size, usage)
- void *desc;
- int size;
- u_int32_t usage;
+hid_is_collection(void *desc, int size, u_int32_t usage)
{
struct hid_data *hd;
struct hid_item hi;
diff --git a/sys/dev/usb/hid.h b/sys/dev/usb/hid.h
index 022a8f795bd..73608bbbaff 100644
--- a/sys/dev/usb/hid.h
+++ b/sys/dev/usb/hid.h
@@ -1,5 +1,5 @@
-/* $OpenBSD: hid.h,v 1.3 2000/07/04 11:44:21 fgsch Exp $ */
-/* $NetBSD: hid.h,v 1.4 1999/11/18 23:32:26 augustss Exp $ */
+/* $OpenBSD: hid.h,v 1.4 2000/11/08 18:10:37 aaron Exp $ */
+/* $NetBSD: hid.h,v 1.6 2000/06/01 14:28:57 augustss Exp $ */
/* $FreeBSD: src/sys/dev/usb/hid.h,v 1.7 1999/11/17 22:33:40 n_hibma Exp $ */
/*
@@ -81,12 +81,11 @@ struct hid_item {
struct hid_item *next;
};
-struct hid_data *hid_start_parse __P((void *d, int len, int kindset));
-void hid_end_parse __P((struct hid_data *s));
-int hid_get_item __P((struct hid_data *s, struct hid_item *h));
-int hid_report_size __P((void *buf, int len, enum hid_kind k, u_int8_t *id));
-int hid_locate __P((void *desc, int size, u_int32_t usage,
- enum hid_kind kind, struct hid_location *loc,
- u_int32_t *flags));
-u_long hid_get_data __P((u_char *buf, struct hid_location *loc));
-int hid_is_collection __P((void *desc, int size, u_int32_t usage));
+struct hid_data *hid_start_parse(void *d, int len, int kindset);
+void hid_end_parse(struct hid_data *s);
+int hid_get_item(struct hid_data *s, struct hid_item *h);
+int hid_report_size(void *buf, int len, enum hid_kind k, u_int8_t *id);
+int hid_locate(void *desc, int size, u_int32_t usage, enum hid_kind kind,
+ struct hid_location *loc, u_int32_t *flags);
+u_long hid_get_data(u_char *buf, struct hid_location *loc);
+int hid_is_collection(void *desc, int size, u_int32_t usage);
diff --git a/sys/dev/usb/ohci.c b/sys/dev/usb/ohci.c
index f463a10ce6e..90de79ce567 100644
--- a/sys/dev/usb/ohci.c
+++ b/sys/dev/usb/ohci.c
@@ -1,5 +1,5 @@
-/* $OpenBSD: ohci.c,v 1.14 2000/09/06 22:42:10 rahnds Exp $ */
-/* $NetBSD: ohci.c,v 1.85 2000/04/01 09:27:35 augustss Exp $ */
+/* $OpenBSD: ohci.c,v 1.15 2000/11/08 18:10:37 aaron Exp $ */
+/* $NetBSD: ohci.c,v 1.93 2000/08/17 23:18:56 augustss Exp $ */
/* $FreeBSD: src/sys/dev/usb/ohci.c,v 1.22 1999/11/17 22:33:40 n_hibma Exp $ */
/*
@@ -93,130 +93,146 @@ struct cfdriver ohci_cd = {
#define DPRINTF(x) if (ohcidebug) logprintf x
#define DPRINTFN(n,x) if (ohcidebug>(n)) logprintf x
int ohcidebug = 0;
+#ifndef __NetBSD__
+#define bitmask_snprintf(q,f,b,l) snprintf((b), (l), "%b", (q), (f))
+#endif
#else
#define DPRINTF(x)
#define DPRINTFN(n,x)
#endif
+/*
+ * The OHCI controller is little endian, so on big endian machines
+ * the data strored in memory needs to be swapped.
+ */
+#if defined(__FreeBSD__) || defined(__OpenBSD__)
+#if BYTE_ORDER == BIG_ENDIAN
+#define htole32(x) (bswap32(x))
+#define le32toh(x) (bswap32(x))
+#else
+#define htole32(x) (x)
+#define le32toh(x) (x)
+#endif
+#endif
+
struct ohci_pipe;
-Static ohci_soft_ed_t *ohci_alloc_sed __P((ohci_softc_t *));
-Static void ohci_free_sed __P((ohci_softc_t *, ohci_soft_ed_t *));
+Static ohci_soft_ed_t *ohci_alloc_sed(ohci_softc_t *);
+Static void ohci_free_sed(ohci_softc_t *, ohci_soft_ed_t *);
-Static ohci_soft_td_t *ohci_alloc_std __P((ohci_softc_t *));
-Static void ohci_free_std __P((ohci_softc_t *, ohci_soft_td_t *));
+Static ohci_soft_td_t *ohci_alloc_std(ohci_softc_t *);
+Static void ohci_free_std(ohci_softc_t *, ohci_soft_td_t *);
-Static ohci_soft_itd_t *ohci_alloc_sitd __P((ohci_softc_t *));
-Static void ohci_free_sitd __P((ohci_softc_t *,ohci_soft_itd_t *));
+Static ohci_soft_itd_t *ohci_alloc_sitd(ohci_softc_t *);
+Static void ohci_free_sitd(ohci_softc_t *,ohci_soft_itd_t *);
#if 0
-Static void ohci_free_std_chain __P((ohci_softc_t *,
- ohci_soft_td_t *, ohci_soft_td_t *));
+Static void ohci_free_std_chain(ohci_softc_t *, ohci_soft_td_t *,
+ ohci_soft_td_t *);
#endif
-Static usbd_status ohci_alloc_std_chain __P((struct ohci_pipe *,
+Static usbd_status ohci_alloc_std_chain(struct ohci_pipe *,
ohci_softc_t *, int, int, usbd_xfer_handle,
- ohci_soft_td_t *, ohci_soft_td_t **));
-
-Static void ohci_shutdown __P((void *v));
-Static void ohci_power __P((int, void *));
-Static usbd_status ohci_open __P((usbd_pipe_handle));
-Static void ohci_poll __P((struct usbd_bus *));
-Static void ohci_softintr __P((struct usbd_bus *));
-Static void ohci_waitintr __P((ohci_softc_t *, usbd_xfer_handle));
-Static void ohci_add_done __P((ohci_softc_t *, ohci_physaddr_t));
-Static void ohci_rhsc __P((ohci_softc_t *, usbd_xfer_handle));
-
-Static usbd_status ohci_device_request __P((usbd_xfer_handle xfer));
-Static void ohci_add_ed __P((ohci_soft_ed_t *, ohci_soft_ed_t *));
-Static void ohci_rem_ed __P((ohci_soft_ed_t *, ohci_soft_ed_t *));
-Static void ohci_hash_add_td __P((ohci_softc_t *,
- ohci_soft_td_t *));
-Static void ohci_hash_rem_td __P((ohci_softc_t *,
- ohci_soft_td_t *));
-Static ohci_soft_td_t *ohci_hash_find_td __P((ohci_softc_t *,
- ohci_physaddr_t));
-Static void ohci_hash_add_itd __P((ohci_softc_t *,
- ohci_soft_itd_t *));
-Static void ohci_hash_rem_itd __P((ohci_softc_t *,
- ohci_soft_itd_t *));
-Static ohci_soft_itd_t *ohci_hash_find_itd __P((ohci_softc_t *,
- ohci_physaddr_t));
-
-Static usbd_status ohci_setup_isoc __P((usbd_pipe_handle pipe));
-Static void ohci_device_isoc_enter __P((usbd_xfer_handle));
-
-Static usbd_status ohci_allocm __P((struct usbd_bus *, usb_dma_t *,
- u_int32_t));
-Static void ohci_freem __P((struct usbd_bus *, usb_dma_t *));
-
-Static usbd_xfer_handle ohci_allocx __P((struct usbd_bus *));
-Static void ohci_freex __P((struct usbd_bus *, usbd_xfer_handle));
-
-Static usbd_status ohci_root_ctrl_transfer __P((usbd_xfer_handle));
-Static usbd_status ohci_root_ctrl_start __P((usbd_xfer_handle));
-Static void ohci_root_ctrl_abort __P((usbd_xfer_handle));
-Static void ohci_root_ctrl_close __P((usbd_pipe_handle));
-Static void ohci_root_ctrl_done __P((usbd_xfer_handle));
-
-Static usbd_status ohci_root_intr_transfer __P((usbd_xfer_handle));
-Static usbd_status ohci_root_intr_start __P((usbd_xfer_handle));
-Static void ohci_root_intr_abort __P((usbd_xfer_handle));
-Static void ohci_root_intr_close __P((usbd_pipe_handle));
-Static void ohci_root_intr_done __P((usbd_xfer_handle));
-
-Static usbd_status ohci_device_ctrl_transfer __P((usbd_xfer_handle));
-Static usbd_status ohci_device_ctrl_start __P((usbd_xfer_handle));
-Static void ohci_device_ctrl_abort __P((usbd_xfer_handle));
-Static void ohci_device_ctrl_close __P((usbd_pipe_handle));
-Static void ohci_device_ctrl_done __P((usbd_xfer_handle));
-
-Static usbd_status ohci_device_bulk_transfer __P((usbd_xfer_handle));
-Static usbd_status ohci_device_bulk_start __P((usbd_xfer_handle));
-Static void ohci_device_bulk_abort __P((usbd_xfer_handle));
-Static void ohci_device_bulk_close __P((usbd_pipe_handle));
-Static void ohci_device_bulk_done __P((usbd_xfer_handle));
-
-Static usbd_status ohci_device_intr_transfer __P((usbd_xfer_handle));
-Static usbd_status ohci_device_intr_start __P((usbd_xfer_handle));
-Static void ohci_device_intr_abort __P((usbd_xfer_handle));
-Static void ohci_device_intr_close __P((usbd_pipe_handle));
-Static void ohci_device_intr_done __P((usbd_xfer_handle));
-
-Static usbd_status ohci_device_isoc_transfer __P((usbd_xfer_handle));
-Static usbd_status ohci_device_isoc_start __P((usbd_xfer_handle));
-Static void ohci_device_isoc_abort __P((usbd_xfer_handle));
-Static void ohci_device_isoc_close __P((usbd_pipe_handle));
-Static void ohci_device_isoc_done __P((usbd_xfer_handle));
-
-Static usbd_status ohci_device_setintr __P((ohci_softc_t *sc,
- struct ohci_pipe *pipe, int ival));
-
-Static int ohci_str __P((usb_string_descriptor_t *, int, char *));
-
-Static void ohci_timeout __P((void *));
-Static void ohci_rhsc_able __P((ohci_softc_t *, int));
-
-Static void ohci_close_pipe __P((usbd_pipe_handle pipe,
- ohci_soft_ed_t *head));
-Static void ohci_abort_xfer __P((usbd_xfer_handle xfer,
- usbd_status status));
-Static void ohci_abort_xfer_end __P((void *));
-
-Static void ohci_device_clear_toggle __P((usbd_pipe_handle pipe));
-Static void ohci_noop __P((usbd_pipe_handle pipe));
+ ohci_soft_td_t *, ohci_soft_td_t **);
+
+Static void ohci_shutdown(void *v);
+Static void ohci_power(int, void *);
+Static usbd_status ohci_open(usbd_pipe_handle);
+Static void ohci_poll(struct usbd_bus *);
+Static void ohci_softintr(struct usbd_bus *);
+Static void ohci_waitintr(ohci_softc_t *, usbd_xfer_handle);
+Static void ohci_add_done(ohci_softc_t *, ohci_physaddr_t);
+Static void ohci_rhsc(ohci_softc_t *, usbd_xfer_handle);
+
+Static usbd_status ohci_device_request(usbd_xfer_handle xfer);
+Static void ohci_add_ed(ohci_soft_ed_t *, ohci_soft_ed_t *);
+Static void ohci_rem_ed(ohci_soft_ed_t *, ohci_soft_ed_t *);
+Static void ohci_hash_add_td(ohci_softc_t *, ohci_soft_td_t *);
+Static void ohci_hash_rem_td(ohci_softc_t *, ohci_soft_td_t *);
+Static ohci_soft_td_t *ohci_hash_find_td(ohci_softc_t *, ohci_physaddr_t);
+Static void ohci_hash_add_itd(ohci_softc_t *, ohci_soft_itd_t *);
+Static void ohci_hash_rem_itd(ohci_softc_t *, ohci_soft_itd_t *);
+Static ohci_soft_itd_t *ohci_hash_find_itd(ohci_softc_t *, ohci_physaddr_t);
+
+Static usbd_status ohci_setup_isoc(usbd_pipe_handle pipe);
+Static void ohci_device_isoc_enter(usbd_xfer_handle);
+
+Static usbd_status ohci_allocm(struct usbd_bus *, usb_dma_t *, u_int32_t);
+Static void ohci_freem(struct usbd_bus *, usb_dma_t *);
+
+Static usbd_xfer_handle ohci_allocx(struct usbd_bus *);
+Static void ohci_freex(struct usbd_bus *, usbd_xfer_handle);
+
+Static usbd_status ohci_root_ctrl_transfer(usbd_xfer_handle);
+Static usbd_status ohci_root_ctrl_start(usbd_xfer_handle);
+Static void ohci_root_ctrl_abort(usbd_xfer_handle);
+Static void ohci_root_ctrl_close(usbd_pipe_handle);
+Static void ohci_root_ctrl_done(usbd_xfer_handle);
+
+Static usbd_status ohci_root_intr_transfer(usbd_xfer_handle);
+Static usbd_status ohci_root_intr_start(usbd_xfer_handle);
+Static void ohci_root_intr_abort(usbd_xfer_handle);
+Static void ohci_root_intr_close(usbd_pipe_handle);
+Static void ohci_root_intr_done(usbd_xfer_handle);
+
+Static usbd_status ohci_device_ctrl_transfer(usbd_xfer_handle);
+Static usbd_status ohci_device_ctrl_start(usbd_xfer_handle);
+Static void ohci_device_ctrl_abort(usbd_xfer_handle);
+Static void ohci_device_ctrl_close(usbd_pipe_handle);
+Static void ohci_device_ctrl_done(usbd_xfer_handle);
+
+Static usbd_status ohci_device_bulk_transfer(usbd_xfer_handle);
+Static usbd_status ohci_device_bulk_start(usbd_xfer_handle);
+Static void ohci_device_bulk_abort(usbd_xfer_handle);
+Static void ohci_device_bulk_close(usbd_pipe_handle);
+Static void ohci_device_bulk_done(usbd_xfer_handle);
+
+Static usbd_status ohci_device_intr_transfer(usbd_xfer_handle);
+Static usbd_status ohci_device_intr_start(usbd_xfer_handle);
+Static void ohci_device_intr_abort(usbd_xfer_handle);
+Static void ohci_device_intr_close(usbd_pipe_handle);
+Static void ohci_device_intr_done(usbd_xfer_handle);
+
+Static usbd_status ohci_device_isoc_transfer(usbd_xfer_handle);
+Static usbd_status ohci_device_isoc_start(usbd_xfer_handle);
+Static void ohci_device_isoc_abort(usbd_xfer_handle);
+Static void ohci_device_isoc_close(usbd_pipe_handle);
+Static void ohci_device_isoc_done(usbd_xfer_handle);
+
+Static usbd_status ohci_device_setintr(ohci_softc_t *sc,
+ struct ohci_pipe *pipe, int ival);
+
+Static int ohci_str(usb_string_descriptor_t *, int, char *);
+
+Static void ohci_timeout(void *);
+Static void ohci_rhsc_able(ohci_softc_t *, int);
+
+Static void ohci_close_pipe(usbd_pipe_handle, ohci_soft_ed_t *);
+Static void ohci_abort_xfer(usbd_xfer_handle, usbd_status);
+Static void ohci_abort_xfer_end(void *);
+
+Static void ohci_device_clear_toggle(usbd_pipe_handle pipe);
+Static void ohci_noop(usbd_pipe_handle pipe);
#ifdef OHCI_DEBUG
-Static void ohci_dumpregs __P((ohci_softc_t *));
-Static void ohci_dump_tds __P((ohci_soft_td_t *));
-Static void ohci_dump_td __P((ohci_soft_td_t *));
-Static void ohci_dump_ed __P((ohci_soft_ed_t *));
-Static void ohci_dump_itd __P((ohci_soft_itd_t *));
-Static void ohci_dump_itds __P((ohci_soft_itd_t *));
+Static void ohci_dumpregs(ohci_softc_t *);
+Static void ohci_dump_tds(ohci_soft_td_t *);
+Static void ohci_dump_td(ohci_soft_td_t *);
+Static void ohci_dump_ed(ohci_soft_ed_t *);
+Static void ohci_dump_itd(ohci_soft_itd_t *);
+Static void ohci_dump_itds(ohci_soft_itd_t *);
#endif
-#define OWRITE4(sc, r, x) bus_space_write_4((sc)->iot, (sc)->ioh, (r), (x))
-#define OREAD4(sc, r) bus_space_read_4((sc)->iot, (sc)->ioh, (r))
-#define OREAD2(sc, r) bus_space_read_2((sc)->iot, (sc)->ioh, (r))
+#define OBARR(sc) bus_space_barrier((sc)->iot, (sc)->ioh, 0, (sc)->sc_size, \
+ BUS_SPACE_BARRIER_READ|BUS_SPACE_BARRIER_WRITE)
+#define OWRITE1(sc, r, x) \
+ do { OBARR(sc); bus_space_write_1((sc)->iot, (sc)->ioh, (r), (x)); } while (0)
+#define OWRITE2(sc, r, x) \
+ do { OBARR(sc); bus_space_write_2((sc)->iot, (sc)->ioh, (r), (x)); } while (0)
+#define OWRITE4(sc, r, x) \
+ do { OBARR(sc); bus_space_write_4((sc)->iot, (sc)->ioh, (r), (x)); } while (0)
+#define OREAD1(sc, r) (OBARR(sc), bus_space_read_1((sc)->iot, (sc)->ioh, (r)))
+#define OREAD2(sc, r) (OBARR(sc), bus_space_read_2((sc)->iot, (sc)->ioh, (r)))
+#define OREAD4(sc, r) (OBARR(sc), bus_space_read_4((sc)->iot, (sc)->ioh, (r)))
/* Reverse the bits in a value 0 .. 31 */
Static u_int8_t revbits[OHCI_NO_INTRS] =
@@ -325,9 +341,7 @@ Static struct usbd_pipe_methods ohci_device_isoc_methods = {
#if defined(__NetBSD__) || defined(__OpenBSD__)
int
-ohci_activate(self, act)
- device_ptr_t self;
- enum devact act;
+ohci_activate(device_ptr_t self, enum devact act)
{
struct ohci_softc *sc = (struct ohci_softc *)self;
int rv = 0;
@@ -347,9 +361,7 @@ ohci_activate(self, act)
}
int
-ohci_detach(sc, flags)
- struct ohci_softc *sc;
- int flags;
+ohci_detach(struct ohci_softc *sc, int flags)
{
int rv = 0;
@@ -371,8 +383,7 @@ ohci_detach(sc, flags)
#endif
ohci_soft_ed_t *
-ohci_alloc_sed(sc)
- ohci_softc_t *sc;
+ohci_alloc_sed(ohci_softc_t *sc)
{
ohci_soft_ed_t *sed;
usbd_status err;
@@ -401,17 +412,14 @@ ohci_alloc_sed(sc)
}
void
-ohci_free_sed(sc, sed)
- ohci_softc_t *sc;
- ohci_soft_ed_t *sed;
+ohci_free_sed(ohci_softc_t *sc, ohci_soft_ed_t *sed)
{
sed->next = sc->sc_freeeds;
sc->sc_freeeds = sed;
}
ohci_soft_td_t *
-ohci_alloc_std(sc)
- ohci_softc_t *sc;
+ohci_alloc_std(ohci_softc_t *sc)
{
ohci_soft_td_t *std;
usbd_status err;
@@ -449,9 +457,7 @@ ohci_alloc_std(sc)
}
void
-ohci_free_std(sc, std)
- ohci_softc_t *sc;
- ohci_soft_td_t *std;
+ohci_free_std(ohci_softc_t *sc, ohci_soft_td_t *std)
{
int s;
@@ -463,12 +469,9 @@ ohci_free_std(sc, std)
}
usbd_status
-ohci_alloc_std_chain(opipe, sc, alen, rd, xfer, sp, ep)
- struct ohci_pipe *opipe;
- ohci_softc_t *sc;
- int alen, rd;
- usbd_xfer_handle xfer;
- ohci_soft_td_t *sp, **ep;
+ohci_alloc_std_chain(struct ohci_pipe *opipe, ohci_softc_t *sc,
+ int alen, int rd, usbd_xfer_handle xfer,
+ ohci_soft_td_t *sp, ohci_soft_td_t **ep)
{
ohci_soft_td_t *next, *cur;
ohci_physaddr_t dataphys, dataphysend;
@@ -561,10 +564,8 @@ ohci_alloc_std_chain(opipe, sc, alen, rd, xfer, sp, ep)
#if 0
Static void
-ohci_free_std_chain(sc, std, stdend)
- ohci_softc_t *sc;
- ohci_soft_td_t *std;
- ohci_soft_td_t *stdend;
+ohci_free_std_chain(ohci_softc_t *sc, ohci_soft_td_t *std,
+ ohci_soft_td_t *stdend)
{
ohci_soft_td_t *p;
@@ -576,8 +577,7 @@ ohci_free_std_chain(sc, std, stdend)
#endif
ohci_soft_itd_t *
-ohci_alloc_sitd(sc)
- ohci_softc_t *sc;
+ohci_alloc_sitd(ohci_softc_t *sc)
{
ohci_soft_itd_t *sitd;
usbd_status err;
@@ -616,9 +616,7 @@ ohci_alloc_sitd(sc)
}
void
-ohci_free_sitd(sc, sitd)
- ohci_softc_t *sc;
- ohci_soft_itd_t *sitd;
+ohci_free_sitd(ohci_softc_t *sc, ohci_soft_itd_t *sitd)
{
int s;
@@ -639,8 +637,7 @@ ohci_free_sitd(sc, sitd)
}
usbd_status
-ohci_init(sc)
- ohci_softc_t *sc;
+ohci_init(ohci_softc_t *sc)
{
ohci_soft_ed_t *sed, *psed;
usbd_status err;
@@ -878,10 +875,7 @@ ohci_init(sc)
}
usbd_status
-ohci_allocm(bus, dma, size)
- struct usbd_bus *bus;
- usb_dma_t *dma;
- u_int32_t size;
+ohci_allocm(struct usbd_bus *bus, usb_dma_t *dma, u_int32_t size)
{
#if defined(__NetBSD__) || defined(__OpenBSD__)
struct ohci_softc *sc = (struct ohci_softc *)bus;
@@ -891,9 +885,7 @@ ohci_allocm(bus, dma, size)
}
void
-ohci_freem(bus, dma)
- struct usbd_bus *bus;
- usb_dma_t *dma;
+ohci_freem(struct usbd_bus *bus, usb_dma_t *dma)
{
#if defined(__NetBSD__) || defined(__OpenBSD__)
struct ohci_softc *sc = (struct ohci_softc *)bus;
@@ -903,8 +895,7 @@ ohci_freem(bus, dma)
}
usbd_xfer_handle
-ohci_allocx(bus)
- struct usbd_bus *bus;
+ohci_allocx(struct usbd_bus *bus)
{
struct ohci_softc *sc = (struct ohci_softc *)bus;
usbd_xfer_handle xfer;
@@ -920,9 +911,7 @@ ohci_allocx(bus)
}
void
-ohci_freex(bus, xfer)
- struct usbd_bus *bus;
- usbd_xfer_handle xfer;
+ohci_freex(struct usbd_bus *bus, usbd_xfer_handle xfer)
{
struct ohci_softc *sc = (struct ohci_softc *)bus;
@@ -933,8 +922,7 @@ ohci_freex(bus, xfer)
* Shut down the controller when the system is going down.
*/
void
-ohci_shutdown(v)
- void *v;
+ohci_shutdown(void *v)
{
ohci_softc_t *sc = v;
@@ -950,9 +938,7 @@ ohci_shutdown(v)
* are almost suspended anyway.
*/
void
-ohci_power(why, v)
- int why;
- void *v;
+ohci_power(int why, void *v)
{
#ifdef OHCI_DEBUG
ohci_softc_t *sc = v;
@@ -965,8 +951,7 @@ ohci_power(why, v)
#ifdef OHCI_DEBUG
void
-ohci_dumpregs(sc)
- ohci_softc_t *sc;
+ohci_dumpregs(ohci_softc_t *sc)
{
DPRINTF(("ohci_dumpregs: rev=0x%08x control=0x%08x command=0x%08x\n",
OREAD4(sc, OHCI_REVISION),
@@ -1005,11 +990,10 @@ ohci_dumpregs(sc)
}
#endif
-Static int ohci_intr1 __P((ohci_softc_t *));
+Static int ohci_intr1(ohci_softc_t *);
int
-ohci_intr(p)
- void *p;
+ohci_intr(void *p)
{
ohci_softc_t *sc = p;
@@ -1025,8 +1009,7 @@ ohci_intr(p)
}
Static int
-ohci_intr1(sc)
- ohci_softc_t *sc;
+ohci_intr1(ohci_softc_t *sc)
{
u_int32_t intrs, eintrs;
ohci_physaddr_t done;
@@ -1106,9 +1089,7 @@ ohci_intr1(sc)
}
void
-ohci_rhsc_able(sc, on)
- ohci_softc_t *sc;
- int on;
+ohci_rhsc_able(ohci_softc_t *sc, int on)
{
DPRINTFN(4, ("ohci_rhsc_able: on=%d\n", on));
if (on) {
@@ -1142,9 +1123,7 @@ char *ohci_cc_strs[] = {
#endif
void
-ohci_add_done(sc, done)
- ohci_softc_t *sc;
- ohci_physaddr_t done;
+ohci_add_done(ohci_softc_t *sc, ohci_physaddr_t done)
{
ohci_soft_itd_t *sitd, *sidone, **ip;
ohci_soft_td_t *std, *sdone, **p;
@@ -1180,12 +1159,8 @@ ohci_add_done(sc, done)
*ip = sidone;
}
-void baaz(void);
-void baaz(void) {}
-
void
-ohci_softintr(bus)
- struct usbd_bus *bus;
+ohci_softintr(struct usbd_bus *bus)
{
ohci_softc_t *sc = (ohci_softc_t *)bus;
ohci_soft_itd_t *sitd, *sidone, *sitdnext;
@@ -1326,8 +1301,7 @@ ohci_softintr(bus)
}
void
-ohci_device_ctrl_done(xfer)
- usbd_xfer_handle xfer;
+ohci_device_ctrl_done(usbd_xfer_handle xfer)
{
DPRINTFN(10,("ohci_ctrl_done: xfer=%p\n", xfer));
@@ -1340,8 +1314,7 @@ ohci_device_ctrl_done(xfer)
}
void
-ohci_device_intr_done(xfer)
- usbd_xfer_handle xfer;
+ohci_device_intr_done(usbd_xfer_handle xfer)
{
struct ohci_pipe *opipe = (struct ohci_pipe *)xfer->pipe;
ohci_softc_t *sc = (ohci_softc_t *)opipe->pipe.device->bus;
@@ -1385,8 +1358,7 @@ ohci_device_intr_done(xfer)
}
void
-ohci_device_bulk_done(xfer)
- usbd_xfer_handle xfer;
+ohci_device_bulk_done(usbd_xfer_handle xfer)
{
DPRINTFN(10,("ohci_bulk_done: xfer=%p, actlen=%d\n",
xfer, xfer->actlen));
@@ -1395,9 +1367,7 @@ ohci_device_bulk_done(xfer)
}
void
-ohci_rhsc(sc, xfer)
- ohci_softc_t *sc;
- usbd_xfer_handle xfer;
+ohci_rhsc(ohci_softc_t *sc, usbd_xfer_handle xfer)
{
usbd_pipe_handle pipe;
struct ohci_pipe *opipe;
@@ -1433,15 +1403,13 @@ ohci_rhsc(sc, xfer)
}
void
-ohci_root_intr_done(xfer)
- usbd_xfer_handle xfer;
+ohci_root_intr_done(usbd_xfer_handle xfer)
{
xfer->hcpriv = NULL;
}
void
-ohci_root_ctrl_done(xfer)
- usbd_xfer_handle xfer;
+ohci_root_ctrl_done(usbd_xfer_handle xfer)
{
xfer->hcpriv = NULL;
}
@@ -1452,9 +1420,7 @@ ohci_root_ctrl_done(xfer)
* too long.
*/
void
-ohci_waitintr(sc, xfer)
- ohci_softc_t *sc;
- usbd_xfer_handle xfer;
+ohci_waitintr(ohci_softc_t *sc, usbd_xfer_handle xfer)
{
int timo = xfer->timeout;
int usecs;
@@ -1484,8 +1450,7 @@ ohci_waitintr(sc, xfer)
}
void
-ohci_poll(bus)
- struct usbd_bus *bus;
+ohci_poll(struct usbd_bus *bus)
{
ohci_softc_t *sc = (ohci_softc_t *)bus;
@@ -1494,8 +1459,7 @@ ohci_poll(bus)
}
usbd_status
-ohci_device_request(xfer)
- usbd_xfer_handle xfer;
+ohci_device_request(usbd_xfer_handle xfer)
{
struct ohci_pipe *opipe = (struct ohci_pipe *)xfer->pipe;
usb_device_request_t *req = &xfer->request;
@@ -1625,9 +1589,7 @@ ohci_device_request(xfer)
* Add an ED to the schedule. Called at splusb().
*/
void
-ohci_add_ed(sed, head)
- ohci_soft_ed_t *sed;
- ohci_soft_ed_t *head;
+ohci_add_ed(ohci_soft_ed_t *sed, ohci_soft_ed_t *head)
{
SPLUSBCHECK;
sed->next = head->next;
@@ -1640,9 +1602,7 @@ ohci_add_ed(sed, head)
* Remove an ED from the schedule. Called at splusb().
*/
void
-ohci_rem_ed(sed, head)
- ohci_soft_ed_t *sed;
- ohci_soft_ed_t *head;
+ohci_rem_ed(ohci_soft_ed_t *sed, ohci_soft_ed_t *head)
{
ohci_soft_ed_t *p;
@@ -1670,9 +1630,7 @@ ohci_rem_ed(sed, head)
#define HASH(a) (((a) >> 4) % OHCI_HASH_SIZE)
/* Called at splusb() */
void
-ohci_hash_add_td(sc, std)
- ohci_softc_t *sc;
- ohci_soft_td_t *std;
+ohci_hash_add_td(ohci_softc_t *sc, ohci_soft_td_t *std)
{
int h = HASH(std->physaddr);
@@ -1683,9 +1641,7 @@ ohci_hash_add_td(sc, std)
/* Called at splusb() */
void
-ohci_hash_rem_td(sc, std)
- ohci_softc_t *sc;
- ohci_soft_td_t *std;
+ohci_hash_rem_td(ohci_softc_t *sc, ohci_soft_td_t *std)
{
SPLUSBCHECK;
@@ -1693,9 +1649,7 @@ ohci_hash_rem_td(sc, std)
}
ohci_soft_td_t *
-ohci_hash_find_td(sc, a)
- ohci_softc_t *sc;
- ohci_physaddr_t a;
+ohci_hash_find_td(ohci_softc_t *sc, ohci_physaddr_t a)
{
int h = HASH(a);
ohci_soft_td_t *std;
@@ -1710,9 +1664,7 @@ ohci_hash_find_td(sc, a)
/* Called at splusb() */
void
-ohci_hash_add_itd(sc, sitd)
- ohci_softc_t *sc;
- ohci_soft_itd_t *sitd;
+ohci_hash_add_itd(ohci_softc_t *sc, ohci_soft_itd_t *sitd)
{
int h = HASH(sitd->physaddr);
@@ -1726,9 +1678,7 @@ ohci_hash_add_itd(sc, sitd)
/* Called at splusb() */
void
-ohci_hash_rem_itd(sc, sitd)
- ohci_softc_t *sc;
- ohci_soft_itd_t *sitd;
+ohci_hash_rem_itd(ohci_softc_t *sc, ohci_soft_itd_t *sitd)
{
SPLUSBCHECK;
@@ -1739,9 +1689,7 @@ ohci_hash_rem_itd(sc, sitd)
}
ohci_soft_itd_t *
-ohci_hash_find_itd(sc, a)
- ohci_softc_t *sc;
- ohci_physaddr_t a;
+ohci_hash_find_itd(ohci_softc_t *sc, ohci_physaddr_t a)
{
int h = HASH(a);
ohci_soft_itd_t *sitd;
@@ -1755,8 +1703,7 @@ ohci_hash_find_itd(sc, a)
}
void
-ohci_timeout(addr)
- void *addr;
+ohci_timeout(void *addr)
{
usbd_xfer_handle xfer = addr;
int s;
@@ -1772,22 +1719,24 @@ ohci_timeout(addr)
#ifdef OHCI_DEBUG
void
-ohci_dump_tds(std)
- ohci_soft_td_t *std;
+ohci_dump_tds(ohci_soft_td_t *std)
{
for (; std; std = std->nexttd)
ohci_dump_td(std);
}
void
-ohci_dump_td(std)
- ohci_soft_td_t *std;
+ohci_dump_td(ohci_soft_td_t *std)
{
- DPRINTF(("TD(%p) at %08lx: %b delay=%d ec=%d cc=%d\ncbp=0x%08lx "
+ char sbuf[128];
+
+ bitmask_snprintf((int)le32toh(std->td.td_flags),
+ "\20\23R\24OUT\25IN\31TOG1\32SETTOGGLE",
+ sbuf, sizeof(sbuf));
+
+ DPRINTF(("TD(%p) at %08lx: %s delay=%d ec=%d cc=%d\ncbp=0x%08lx "
"nexttd=0x%08lx be=0x%08lx\n",
- std, (u_long)std->physaddr,
- (int)le32toh(std->td.td_flags),
- "\20\23R\24OUT\25IN\31TOG1\32SETTOGGLE",
+ std, (u_long)std->physaddr, sbuf,
OHCI_TD_GET_DI(le32toh(std->td.td_flags)),
OHCI_TD_GET_EC(le32toh(std->td.td_flags)),
OHCI_TD_GET_CC(le32toh(std->td.td_flags)),
@@ -1797,8 +1746,7 @@ ohci_dump_td(std)
}
void
-ohci_dump_itd(sitd)
- ohci_soft_itd_t *sitd;
+ohci_dump_itd(ohci_soft_itd_t *sitd)
{
int i;
@@ -1819,36 +1767,37 @@ ohci_dump_itd(sitd)
}
void
-ohci_dump_itds(sitd)
- ohci_soft_itd_t *sitd;
+ohci_dump_itds(ohci_soft_itd_t *sitd)
{
for (; sitd; sitd = sitd->nextitd)
ohci_dump_itd(sitd);
}
void
-ohci_dump_ed(sed)
- ohci_soft_ed_t *sed;
+ohci_dump_ed(ohci_soft_ed_t *sed)
{
- DPRINTF(("ED(%p) at 0x%08lx: addr=%d endpt=%d maxp=%d %b\ntailp=0x%08lx "
- "headflags=%b headp=0x%08lx nexted=0x%08lx\n",
+ char sbuf[128], sbuf2[128];
+
+ bitmask_snprintf((int)le32toh(sed->ed.ed_flags),
+ "\20\14OUT\15IN\16LOWSPEED\17SKIP\20ISO",
+ sbuf, sizeof(sbuf));
+ bitmask_snprintf((u_long)le32toh(sed->ed.ed_headp),
+ "\20\1HALT\2CARRY", sbuf2, sizeof(sbuf2));
+
+ DPRINTF(("ED(%p) at 0x%08lx: addr=%d endpt=%d maxp=%d %s\ntailp=0x%08lx "
+ "headflags=%s headp=0x%08lx nexted=0x%08lx\n",
sed, (u_long)sed->physaddr,
OHCI_ED_GET_FA(le32toh(sed->ed.ed_flags)),
OHCI_ED_GET_EN(le32toh(sed->ed.ed_flags)),
- OHCI_ED_GET_MAXP(le32toh(sed->ed.ed_flags)),
- (int)le32toh(sed->ed.ed_flags),
- "\20\14OUT\15IN\16LOWSPEED\17SKIP\20ISO",
- (u_long)le32toh(sed->ed.ed_tailp),
- (u_long)le32toh(sed->ed.ed_headp),
- "\20\1HALT\2CARRY",
+ OHCI_ED_GET_MAXP(le32toh(sed->ed.ed_flags)), sbuf,
+ (u_long)le32toh(sed->ed.ed_tailp), sbuf2,
(u_long)le32toh(sed->ed.ed_headp),
(u_long)le32toh(sed->ed.ed_nexted)));
}
#endif
usbd_status
-ohci_open(pipe)
- usbd_pipe_handle pipe;
+ohci_open(usbd_pipe_handle pipe)
{
usbd_device_handle dev = pipe->device;
ohci_softc_t *sc = (ohci_softc_t *)dev->bus;
@@ -1964,9 +1913,7 @@ ohci_open(pipe)
* Assumes that there are no pending transactions.
*/
void
-ohci_close_pipe(pipe, head)
- usbd_pipe_handle pipe;
- ohci_soft_ed_t *head;
+ohci_close_pipe(usbd_pipe_handle pipe, ohci_soft_ed_t *head)
{
struct ohci_pipe *opipe = (struct ohci_pipe *)pipe;
ohci_softc_t *sc = (ohci_softc_t *)pipe->device->bus;
@@ -2012,9 +1959,7 @@ ohci_close_pipe(pipe, head)
* interrupt processing to process it.
*/
void
-ohci_abort_xfer(xfer, status)
- usbd_xfer_handle xfer;
- usbd_status status;
+ohci_abort_xfer(usbd_xfer_handle xfer, usbd_status status)
{
struct ohci_pipe *opipe = (struct ohci_pipe *)xfer->pipe;
ohci_soft_ed_t *sed;
@@ -2049,8 +1994,7 @@ ohci_abort_xfer(xfer, status)
}
void
-ohci_abort_xfer_end(v)
- void *v;
+ohci_abort_xfer_end(void *v)
{
usbd_xfer_handle xfer = v;
struct ohci_pipe *opipe = (struct ohci_pipe *)xfer->pipe;
@@ -2168,8 +2112,7 @@ ohci_str(p, l, s)
* Simulate a hardware hub by handling all the necessary requests.
*/
Static usbd_status
-ohci_root_ctrl_transfer(xfer)
- usbd_xfer_handle xfer;
+ohci_root_ctrl_transfer(usbd_xfer_handle xfer)
{
usbd_status err;
@@ -2183,8 +2126,7 @@ ohci_root_ctrl_transfer(xfer)
}
Static usbd_status
-ohci_root_ctrl_start(xfer)
- usbd_xfer_handle xfer;
+ohci_root_ctrl_start(usbd_xfer_handle xfer)
{
ohci_softc_t *sc = (ohci_softc_t *)xfer->pipe->device->bus;
usb_device_request_t *req;
@@ -2454,7 +2396,7 @@ ohci_root_ctrl_start(xfer)
index));
OWRITE4(sc, port, UPS_RESET);
for (i = 0; i < 10; i++) {
- usb_delay_ms(&sc->sc_bus, 10);
+ usb_delay_ms(&sc->sc_bus, 10); /* XXX */
if ((OREAD4(sc, port) & UPS_RESET) == 0)
break;
}
@@ -2487,24 +2429,21 @@ ohci_root_ctrl_start(xfer)
/* Abort a root control request. */
Static void
-ohci_root_ctrl_abort(xfer)
- usbd_xfer_handle xfer;
+ohci_root_ctrl_abort(usbd_xfer_handle xfer)
{
/* Nothing to do, all transfers are synchronous. */
}
/* Close the root pipe. */
Static void
-ohci_root_ctrl_close(pipe)
- usbd_pipe_handle pipe;
+ohci_root_ctrl_close(usbd_pipe_handle pipe)
{
DPRINTF(("ohci_root_ctrl_close\n"));
/* Nothing to do. */
}
Static usbd_status
-ohci_root_intr_transfer(xfer)
- usbd_xfer_handle xfer;
+ohci_root_intr_transfer(usbd_xfer_handle xfer)
{
usbd_status err;
@@ -2518,8 +2457,7 @@ ohci_root_intr_transfer(xfer)
}
Static usbd_status
-ohci_root_intr_start(xfer)
- usbd_xfer_handle xfer;
+ohci_root_intr_start(usbd_xfer_handle xfer)
{
usbd_pipe_handle pipe = xfer->pipe;
ohci_softc_t *sc = (ohci_softc_t *)pipe->device->bus;
@@ -2534,8 +2472,7 @@ ohci_root_intr_start(xfer)
/* Abort a root interrupt request. */
Static void
-ohci_root_intr_abort(xfer)
- usbd_xfer_handle xfer;
+ohci_root_intr_abort(usbd_xfer_handle xfer)
{
int s;
@@ -2551,8 +2488,7 @@ ohci_root_intr_abort(xfer)
/* Close the root pipe. */
Static void
-ohci_root_intr_close(pipe)
- usbd_pipe_handle pipe;
+ohci_root_intr_close(usbd_pipe_handle pipe)
{
ohci_softc_t *sc = (ohci_softc_t *)pipe->device->bus;
@@ -2564,8 +2500,7 @@ ohci_root_intr_close(pipe)
/************************/
Static usbd_status
-ohci_device_ctrl_transfer(xfer)
- usbd_xfer_handle xfer;
+ohci_device_ctrl_transfer(usbd_xfer_handle xfer)
{
usbd_status err;
@@ -2579,8 +2514,7 @@ ohci_device_ctrl_transfer(xfer)
}
Static usbd_status
-ohci_device_ctrl_start(xfer)
- usbd_xfer_handle xfer;
+ohci_device_ctrl_start(usbd_xfer_handle xfer)
{
ohci_softc_t *sc = (ohci_softc_t *)xfer->pipe->device->bus;
usbd_status err;
@@ -2607,8 +2541,7 @@ ohci_device_ctrl_start(xfer)
/* Abort a device control request. */
Static void
-ohci_device_ctrl_abort(xfer)
- usbd_xfer_handle xfer;
+ohci_device_ctrl_abort(usbd_xfer_handle xfer)
{
DPRINTF(("ohci_device_ctrl_abort: xfer=%p\n", xfer));
ohci_abort_xfer(xfer, USBD_CANCELLED);
@@ -2616,8 +2549,7 @@ ohci_device_ctrl_abort(xfer)
/* Close a device control pipe. */
Static void
-ohci_device_ctrl_close(pipe)
- usbd_pipe_handle pipe;
+ohci_device_ctrl_close(usbd_pipe_handle pipe)
{
struct ohci_pipe *opipe = (struct ohci_pipe *)pipe;
ohci_softc_t *sc = (ohci_softc_t *)pipe->device->bus;
@@ -2630,8 +2562,7 @@ ohci_device_ctrl_close(pipe)
/************************/
Static void
-ohci_device_clear_toggle(pipe)
- usbd_pipe_handle pipe;
+ohci_device_clear_toggle(usbd_pipe_handle pipe)
{
struct ohci_pipe *opipe = (struct ohci_pipe *)pipe;
@@ -2639,14 +2570,12 @@ ohci_device_clear_toggle(pipe)
}
Static void
-ohci_noop(pipe)
- usbd_pipe_handle pipe;
+ohci_noop(usbd_pipe_handle pipe)
{
}
Static usbd_status
-ohci_device_bulk_transfer(xfer)
- usbd_xfer_handle xfer;
+ohci_device_bulk_transfer(usbd_xfer_handle xfer)
{
usbd_status err;
@@ -2660,8 +2589,7 @@ ohci_device_bulk_transfer(xfer)
}
Static usbd_status
-ohci_device_bulk_start(xfer)
- usbd_xfer_handle xfer;
+ohci_device_bulk_start(usbd_xfer_handle xfer)
{
struct ohci_pipe *opipe = (struct ohci_pipe *)xfer->pipe;
usbd_device_handle dev = opipe->pipe.device;
@@ -2760,8 +2688,7 @@ ohci_device_bulk_start(xfer)
}
Static void
-ohci_device_bulk_abort(xfer)
- usbd_xfer_handle xfer;
+ohci_device_bulk_abort(usbd_xfer_handle xfer)
{
DPRINTF(("ohci_device_bulk_abort: xfer=%p\n", xfer));
ohci_abort_xfer(xfer, USBD_CANCELLED);
@@ -2771,8 +2698,7 @@ ohci_device_bulk_abort(xfer)
* Close a device bulk pipe.
*/
Static void
-ohci_device_bulk_close(pipe)
- usbd_pipe_handle pipe;
+ohci_device_bulk_close(usbd_pipe_handle pipe)
{
struct ohci_pipe *opipe = (struct ohci_pipe *)pipe;
ohci_softc_t *sc = (ohci_softc_t *)pipe->device->bus;
@@ -2785,8 +2711,7 @@ ohci_device_bulk_close(pipe)
/************************/
Static usbd_status
-ohci_device_intr_transfer(xfer)
- usbd_xfer_handle xfer;
+ohci_device_intr_transfer(usbd_xfer_handle xfer)
{
usbd_status err;
@@ -2800,8 +2725,7 @@ ohci_device_intr_transfer(xfer)
}
Static usbd_status
-ohci_device_intr_start(xfer)
- usbd_xfer_handle xfer;
+ohci_device_intr_start(usbd_xfer_handle xfer)
{
struct ohci_pipe *opipe = (struct ohci_pipe *)xfer->pipe;
usbd_device_handle dev = opipe->pipe.device;
@@ -2880,8 +2804,7 @@ ohci_device_intr_start(xfer)
/* Abort a device control request. */
Static void
-ohci_device_intr_abort(xfer)
- usbd_xfer_handle xfer;
+ohci_device_intr_abort(usbd_xfer_handle xfer)
{
if (xfer->pipe->intrxfer == xfer) {
DPRINTF(("ohci_device_intr_abort: remove\n"));
@@ -2892,8 +2815,7 @@ ohci_device_intr_abort(xfer)
/* Close a device interrupt pipe. */
Static void
-ohci_device_intr_close(pipe)
- usbd_pipe_handle pipe;
+ohci_device_intr_close(usbd_pipe_handle pipe)
{
struct ohci_pipe *opipe = (struct ohci_pipe *)pipe;
ohci_softc_t *sc = (ohci_softc_t *)pipe->device->bus;
@@ -2929,10 +2851,7 @@ ohci_device_intr_close(pipe)
}
Static usbd_status
-ohci_device_setintr(sc, opipe, ival)
- ohci_softc_t *sc;
- struct ohci_pipe *opipe;
- int ival;
+ohci_device_setintr(ohci_softc_t *sc, struct ohci_pipe *opipe, int ival)
{
int i, j, s, best;
u_int npoll, slow, shigh, nslots;
@@ -2996,8 +2915,7 @@ ohci_device_setintr(sc, opipe, ival)
/***********************/
usbd_status
-ohci_device_isoc_transfer(xfer)
- usbd_xfer_handle xfer;
+ohci_device_isoc_transfer(usbd_xfer_handle xfer)
{
usbd_status err;
@@ -3023,8 +2941,7 @@ ohci_device_isoc_transfer(xfer)
}
void
-ohci_device_isoc_enter(xfer)
- usbd_xfer_handle xfer;
+ohci_device_isoc_enter(usbd_xfer_handle xfer)
{
struct ohci_pipe *opipe = (struct ohci_pipe *)xfer->pipe;
usbd_device_handle dev = opipe->pipe.device;
@@ -3144,8 +3061,7 @@ ohci_device_isoc_enter(xfer)
}
usbd_status
-ohci_device_isoc_start(xfer)
- usbd_xfer_handle xfer;
+ohci_device_isoc_start(usbd_xfer_handle xfer)
{
struct ohci_pipe *opipe = (struct ohci_pipe *)xfer->pipe;
ohci_softc_t *sc = (ohci_softc_t *)opipe->pipe.device->bus;
@@ -3166,8 +3082,7 @@ ohci_device_isoc_start(xfer)
}
void
-ohci_device_isoc_abort(xfer)
- usbd_xfer_handle xfer;
+ohci_device_isoc_abort(usbd_xfer_handle xfer)
{
struct ohci_pipe *opipe = (struct ohci_pipe *)xfer->pipe;
ohci_softc_t *sc = (ohci_softc_t *)opipe->pipe.device->bus;
@@ -3223,8 +3138,7 @@ ohci_device_isoc_abort(xfer)
}
void
-ohci_device_isoc_done(xfer)
- usbd_xfer_handle xfer;
+ohci_device_isoc_done(usbd_xfer_handle xfer)
{
struct ohci_pipe *opipe = (struct ohci_pipe *)xfer->pipe;
ohci_softc_t *sc = (ohci_softc_t *)opipe->pipe.device->bus;
@@ -3244,8 +3158,7 @@ ohci_device_isoc_done(xfer)
}
usbd_status
-ohci_setup_isoc(pipe)
- usbd_pipe_handle pipe;
+ohci_setup_isoc(usbd_pipe_handle pipe)
{
struct ohci_pipe *opipe = (struct ohci_pipe *)pipe;
ohci_softc_t *sc = (ohci_softc_t *)pipe->device->bus;
@@ -3263,8 +3176,7 @@ ohci_setup_isoc(pipe)
}
void
-ohci_device_isoc_close(pipe)
- usbd_pipe_handle pipe;
+ohci_device_isoc_close(usbd_pipe_handle pipe)
{
struct ohci_pipe *opipe = (struct ohci_pipe *)pipe;
ohci_softc_t *sc = (ohci_softc_t *)pipe->device->bus;
diff --git a/sys/dev/usb/ohcireg.h b/sys/dev/usb/ohcireg.h
index 0616ddfc6e7..ab6f4cecf6b 100644
--- a/sys/dev/usb/ohcireg.h
+++ b/sys/dev/usb/ohcireg.h
@@ -1,5 +1,5 @@
-/* $OpenBSD: ohcireg.h,v 1.8 2000/07/04 11:44:22 fgsch Exp $ */
-/* $NetBSD: ohcireg.h,v 1.17 2000/04/01 09:27:35 augustss Exp $ */
+/* $OpenBSD: ohcireg.h,v 1.9 2000/11/08 18:10:37 aaron Exp $ */
+/* $NetBSD: ohcireg.h,v 1.18 2000/04/27 15:26:47 augustss Exp $ */
/* $FreeBSD: src/sys/dev/usb/ohcireg.h,v 1.8 1999/11/17 22:33:40 n_hibma Exp $ */
diff --git a/sys/dev/usb/ohcivar.h b/sys/dev/usb/ohcivar.h
index 95ef02f6981..ca2ff486a2b 100644
--- a/sys/dev/usb/ohcivar.h
+++ b/sys/dev/usb/ohcivar.h
@@ -1,5 +1,5 @@
-/* $OpenBSD: ohcivar.h,v 1.10 2000/07/04 11:44:22 fgsch Exp $ */
-/* $NetBSD: ohcivar.h,v 1.21 2000/03/29 01:46:27 augustss Exp $ */
+/* $OpenBSD: ohcivar.h,v 1.11 2000/11/08 18:10:37 aaron Exp $ */
+/* $NetBSD: ohcivar.h,v 1.24 2000/06/01 14:28:58 augustss Exp $ */
/* $FreeBSD: src/sys/dev/usb/ohcivar.h,v 1.13 1999/11/17 22:33:41 n_hibma Exp $ */
/*
@@ -131,11 +131,11 @@ typedef struct ohci_softc {
char sc_dying;
} ohci_softc_t;
-usbd_status ohci_init __P((ohci_softc_t *));
-int ohci_intr __P((void *));
+usbd_status ohci_init(ohci_softc_t *);
+int ohci_intr(void *);
#if defined(__NetBSD__) || defined(__OpenBSD__)
-int ohci_detach __P((ohci_softc_t *, int));
-int ohci_activate __P((device_ptr_t, enum devact));
+int ohci_detach(ohci_softc_t *, int);
+int ohci_activate(device_ptr_t, enum devact);
#endif
#define MS_TO_TICKS(ms) ((ms) * hz / 1000)
diff --git a/sys/dev/usb/uaudio.c b/sys/dev/usb/uaudio.c
index 31bdd8ee56b..c93d757cf87 100644
--- a/sys/dev/usb/uaudio.c
+++ b/sys/dev/usb/uaudio.c
@@ -1,5 +1,5 @@
-/* $OpenBSD: uaudio.c,v 1.6 2000/07/04 11:44:22 fgsch Exp $ */
-/* $NetBSD: uaudio.c,v 1.23 2000/03/29 18:24:53 augustss Exp $ */
+/* $OpenBSD: uaudio.c,v 1.7 2000/11/08 18:10:37 aaron Exp $ */
+/* $NetBSD: uaudio.c,v 1.29 2000/10/05 01:35:07 augustss Exp $ */
/*
* Copyright (c) 1999 The NetBSD Foundation, Inc.
@@ -112,7 +112,7 @@ struct as_info {
struct chan {
int terminal; /* terminal id */
- void (*intr) __P((void *)); /* dma completion intr handler */
+ void (*intr)(void *); /* dma completion intr handler */
void *arg; /* arg for intr() */
usbd_pipe_handle pipe;
int dir; /* direction, UE_DIR_XXX */
@@ -180,103 +180,98 @@ struct uaudio_softc {
#define UAC_INPUT 1
#define UAC_EQUAL 2
-Static usbd_status uaudio_identify_ac __P((struct uaudio_softc *sc,
- usb_config_descriptor_t *cdesc));
-Static usbd_status uaudio_identify_as __P((struct uaudio_softc *sc,
- usb_config_descriptor_t *cdesc));
-Static usbd_status uaudio_process_as __P((struct uaudio_softc *sc,
+Static usbd_status uaudio_identify_ac(struct uaudio_softc *sc,
+ usb_config_descriptor_t *cdesc);
+Static usbd_status uaudio_identify_as(struct uaudio_softc *sc,
+ usb_config_descriptor_t *cdesc);
+Static usbd_status uaudio_process_as(struct uaudio_softc *sc,
char *buf, int *offsp, int size,
- usb_interface_descriptor_t *id));
-
-Static void uaudio_add_alt __P((struct uaudio_softc *sc,
- struct as_info *ai));
-
-Static usb_interface_descriptor_t *uaudio_find_iface
- __P((char *buf, int size, int *offsp, int subtype));
-
-Static void uaudio_mixer_add_ctl __P((struct uaudio_softc *sc,
- struct mixerctl *mp));
-Static char *uaudio_id_name __P((struct uaudio_softc *sc,
- usb_descriptor_t **dps, int id));
-Static struct usb_audio_cluster uaudio_get_cluster __P((int id,
- usb_descriptor_t **dps));
-Static void uaudio_add_input __P((struct uaudio_softc *sc,
- usb_descriptor_t *v, usb_descriptor_t **dps));
-Static void uaudio_add_output __P((struct uaudio_softc *sc,
- usb_descriptor_t *v, usb_descriptor_t **dps));
-Static void uaudio_add_mixer __P((struct uaudio_softc *sc,
- usb_descriptor_t *v, usb_descriptor_t **dps));
-Static void uaudio_add_selector __P((struct uaudio_softc *sc,
- usb_descriptor_t *v, usb_descriptor_t **dps));
-Static void uaudio_add_feature __P((struct uaudio_softc *sc,
- usb_descriptor_t *v, usb_descriptor_t **dps));
-Static void uaudio_add_processing_updown
- __P((struct uaudio_softc *sc,
- usb_descriptor_t *v, usb_descriptor_t **dps));
-Static void uaudio_add_processing __P((struct uaudio_softc *sc,
- usb_descriptor_t *v, usb_descriptor_t **dps));
-Static void uaudio_add_extension __P((struct uaudio_softc *sc,
- usb_descriptor_t *v, usb_descriptor_t **dps));
-Static usbd_status uaudio_identify __P((struct uaudio_softc *sc,
- usb_config_descriptor_t *cdesc));
-
-Static int uaudio_signext __P((int type, int val));
-Static int uaudio_value2bsd __P((struct mixerctl *mc, int val));
-Static int uaudio_bsd2value __P((struct mixerctl *mc, int val));
-Static int uaudio_get __P((struct uaudio_softc *sc, int type,
- int which, int wValue, int wIndex, int len));
-Static int uaudio_ctl_get __P((struct uaudio_softc *sc, int which,
- struct mixerctl *mc, int chan));
-Static void uaudio_set __P((struct uaudio_softc *sc, int type,
- int which, int wValue, int wIndex, int l, int v));
-Static void uaudio_ctl_set __P((struct uaudio_softc *sc, int which,
- struct mixerctl *mc, int chan, int val));
-
-Static usbd_status uaudio_set_speed __P((struct uaudio_softc *, int,
- u_int));
-
-Static usbd_status uaudio_chan_open __P((struct uaudio_softc *sc,
- struct chan *ch));
-Static void uaudio_chan_close __P((struct uaudio_softc *sc,
- struct chan *ch));
-Static usbd_status uaudio_chan_alloc_buffers __P((struct uaudio_softc *,
- struct chan *));
-Static void uaudio_chan_free_buffers __P((struct uaudio_softc *,
- struct chan *));
-Static void uaudio_chan_set_param __P((struct chan *ch,
+ usb_interface_descriptor_t *id);
+
+Static void uaudio_add_alt(struct uaudio_softc *sc,
+ struct as_info *ai);
+
+Static usb_interface_descriptor_t *uaudio_find_iface(char *buf,
+ int size, int *offsp, int subtype);
+
+Static void uaudio_mixer_add_ctl(struct uaudio_softc *sc,
+ struct mixerctl *mp);
+Static char *uaudio_id_name(struct uaudio_softc *sc,
+ usb_descriptor_t **dps, int id);
+Static struct usb_audio_cluster uaudio_get_cluster(int id,
+ usb_descriptor_t **dps);
+Static void uaudio_add_input(struct uaudio_softc *sc,
+ usb_descriptor_t *v, usb_descriptor_t **dps);
+Static void uaudio_add_output(struct uaudio_softc *sc,
+ usb_descriptor_t *v, usb_descriptor_t **dps);
+Static void uaudio_add_mixer(struct uaudio_softc *sc,
+ usb_descriptor_t *v, usb_descriptor_t **dps);
+Static void uaudio_add_selector(struct uaudio_softc *sc,
+ usb_descriptor_t *v, usb_descriptor_t **dps);
+Static void uaudio_add_feature(struct uaudio_softc *sc,
+ usb_descriptor_t *v, usb_descriptor_t **dps);
+Static void uaudio_add_processing_updown(struct uaudio_softc *sc,
+ usb_descriptor_t *v, usb_descriptor_t **dps);
+Static void uaudio_add_processing(struct uaudio_softc *sc,
+ usb_descriptor_t *v, usb_descriptor_t **dps);
+Static void uaudio_add_extension(struct uaudio_softc *sc,
+ usb_descriptor_t *v, usb_descriptor_t **dps);
+Static usbd_status uaudio_identify(struct uaudio_softc *sc,
+ usb_config_descriptor_t *cdesc);
+
+Static int uaudio_signext(int type, int val);
+Static int uaudio_value2bsd(struct mixerctl *mc, int val);
+Static int uaudio_bsd2value(struct mixerctl *mc, int val);
+Static int uaudio_get(struct uaudio_softc *sc, int type,
+ int which, int wValue, int wIndex, int len);
+Static int uaudio_ctl_get(struct uaudio_softc *sc, int which,
+ struct mixerctl *mc, int chan);
+Static void uaudio_set(struct uaudio_softc *sc, int type,
+ int which, int wValue, int wIndex, int l, int v);
+Static void uaudio_ctl_set(struct uaudio_softc *sc, int which,
+ struct mixerctl *mc, int chan, int val);
+
+Static usbd_status uaudio_set_speed(struct uaudio_softc *, int, u_int);
+
+Static usbd_status uaudio_chan_open(struct uaudio_softc *sc,
+ struct chan *ch);
+Static void uaudio_chan_close(struct uaudio_softc *sc,
+ struct chan *ch);
+Static usbd_status uaudio_chan_alloc_buffers(struct uaudio_softc *,
+ struct chan *);
+Static void uaudio_chan_free_buffers(struct uaudio_softc *,
+ struct chan *);
+Static void uaudio_chan_set_param(struct chan *ch,
struct audio_params *param, u_char *start,
- u_char *end, int blksize));
-Static void uaudio_chan_ptransfer __P((struct chan *ch));
-Static void uaudio_chan_pintr __P((usbd_xfer_handle xfer,
- usbd_private_handle priv, usbd_status status));
-
-Static void uaudio_chan_rtransfer __P((struct chan *ch));
-Static void uaudio_chan_rintr __P((usbd_xfer_handle xfer,
- usbd_private_handle priv, usbd_status status));
-
-
-
-Static int uaudio_open __P((void *, int));
-Static void uaudio_close __P((void *));
-Static int uaudio_drain __P((void *));
-Static int uaudio_query_encoding __P((void *,
- struct audio_encoding *));
-Static int uaudio_set_params __P((void *, int, int,
- struct audio_params *, struct audio_params *));
-Static int uaudio_round_blocksize __P((void *, int));
-Static int uaudio_trigger_output __P((void *, void *, void *,
- int, void (*)(void *), void *,
- struct audio_params *));
-Static int uaudio_trigger_input __P((void *, void *, void *,
- int, void (*)(void *), void *,
- struct audio_params *));
-Static int uaudio_halt_in_dma __P((void *));
-Static int uaudio_halt_out_dma __P((void *));
-Static int uaudio_getdev __P((void *, struct audio_device *));
-Static int uaudio_mixer_set_port __P((void *, mixer_ctrl_t *));
-Static int uaudio_mixer_get_port __P((void *, mixer_ctrl_t *));
-Static int uaudio_query_devinfo __P((void *, mixer_devinfo_t *));
-Static int uaudio_get_props __P((void *));
+ u_char *end, int blksize);
+Static void uaudio_chan_ptransfer(struct chan *ch);
+Static void uaudio_chan_pintr(usbd_xfer_handle xfer,
+ usbd_private_handle priv, usbd_status status);
+
+Static void uaudio_chan_rtransfer(struct chan *ch);
+Static void uaudio_chan_rintr(usbd_xfer_handle xfer,
+ usbd_private_handle priv, usbd_status status);
+
+Static int uaudio_open(void *, int);
+Static void uaudio_close(void *);
+Static int uaudio_drain(void *);
+Static int uaudio_query_encoding(void *, struct audio_encoding *);
+Static int uaudio_set_params(void *, int, int,
+ struct audio_params *, struct audio_params *);
+Static int uaudio_round_blocksize(void *, int);
+Static int uaudio_trigger_output(void *, void *, void *,
+ int, void (*)(void *), void *,
+ struct audio_params *);
+Static int uaudio_trigger_input (void *, void *, void *,
+ int, void (*)(void *), void *,
+ struct audio_params *);
+Static int uaudio_halt_in_dma(void *);
+Static int uaudio_halt_out_dma(void *);
+Static int uaudio_getdev(void *, struct audio_device *);
+Static int uaudio_mixer_set_port(void *, mixer_ctrl_t *);
+Static int uaudio_mixer_get_port(void *, mixer_ctrl_t *);
+Static int uaudio_query_devinfo(void *, mixer_devinfo_t *);
+Static int uaudio_get_props(void *);
Static struct audio_hw_if uaudio_hw_if = {
uaudio_open,
@@ -388,8 +383,11 @@ USB_ATTACH(uaudio)
sc->sc_chan.sc = sc;
DPRINTF(("uaudio_attach: doing audio_attach_mi\n"));
-
+#if defined(__OpenBSD__)
+ audio_attach_mi(&uaudio_hw_if, sc, &sc->sc_dev);
+#else
sc->sc_audiodev = audio_attach_mi(&uaudio_hw_if, sc, &sc->sc_dev);
+#endif
usbd_add_drv_event(USB_EVENT_DRIVER_ATTACH, sc->sc_udev,
USBDEV(sc->sc_dev));
@@ -398,9 +396,7 @@ USB_ATTACH(uaudio)
}
int
-uaudio_activate(self, act)
- device_ptr_t self;
- enum devact act;
+uaudio_activate(device_ptr_t self, enum devact act)
{
struct uaudio_softc *sc = (struct uaudio_softc *)self;
int rv = 0;
@@ -420,9 +416,7 @@ uaudio_activate(self, act)
}
int
-uaudio_detach(self, flags)
- device_ptr_t self;
- int flags;
+uaudio_detach(device_ptr_t self, int flags)
{
struct uaudio_softc *sc = (struct uaudio_softc *)self;
int rv = 0;
@@ -440,9 +434,7 @@ uaudio_detach(self, flags)
}
int
-uaudio_query_encoding(addr, fp)
- void *addr;
- struct audio_encoding *fp;
+uaudio_query_encoding(void *addr, struct audio_encoding *fp)
{
struct uaudio_softc *sc = addr;
int flags = sc->sc_altflags;
@@ -510,11 +502,7 @@ uaudio_query_encoding(addr, fp)
}
usb_interface_descriptor_t *
-uaudio_find_iface(buf, size, offsp, subtype)
- char *buf;
- int size;
- int *offsp;
- int subtype;
+uaudio_find_iface(char *buf, int size, int *offsp, int subtype)
{
usb_interface_descriptor_t *d;
@@ -530,11 +518,9 @@ uaudio_find_iface(buf, size, offsp, subtype)
}
void
-uaudio_mixer_add_ctl(sc, mc)
- struct uaudio_softc *sc;
- struct mixerctl *mc;
+uaudio_mixer_add_ctl(struct uaudio_softc *sc, struct mixerctl *mc)
{
- if (sc->sc_nctls == NULL)
+ if (sc->sc_nctls == 0)
sc->sc_ctls = malloc(sizeof *mc, M_USBDEV, M_NOWAIT);
else
sc->sc_ctls = realloc(sc->sc_ctls,
@@ -577,10 +563,7 @@ uaudio_mixer_add_ctl(sc, mc)
}
char *
-uaudio_id_name(sc, dps, id)
- struct uaudio_softc *sc;
- usb_descriptor_t **dps;
- int id;
+uaudio_id_name(struct uaudio_softc *sc, usb_descriptor_t **dps, int id)
{
static char buf[32];
sprintf(buf, "i%d", id);
@@ -588,9 +571,7 @@ uaudio_id_name(sc, dps, id)
}
struct usb_audio_cluster
-uaudio_get_cluster(id, dps)
- int id;
- usb_descriptor_t **dps;
+uaudio_get_cluster(int id, usb_descriptor_t **dps)
{
struct usb_audio_cluster r;
usb_descriptor_t *dp;
@@ -654,10 +635,8 @@ uaudio_get_cluster(id, dps)
}
void
-uaudio_add_input(sc, v, dps)
- struct uaudio_softc *sc;
- usb_descriptor_t *v;
- usb_descriptor_t **dps;
+uaudio_add_input(struct uaudio_softc *sc, usb_descriptor_t *v,
+ usb_descriptor_t **dps)
{
#ifdef UAUDIO_DEBUG
struct usb_audio_input_terminal *d =
@@ -673,10 +652,8 @@ uaudio_add_input(sc, v, dps)
}
void
-uaudio_add_output(sc, v, dps)
- struct uaudio_softc *sc;
- usb_descriptor_t *v;
- usb_descriptor_t **dps;
+uaudio_add_output(struct uaudio_softc *sc, usb_descriptor_t *v,
+ usb_descriptor_t **dps)
{
#ifdef UAUDIO_DEBUG
struct usb_audio_output_terminal *d =
@@ -690,10 +667,8 @@ uaudio_add_output(sc, v, dps)
}
void
-uaudio_add_mixer(sc, v, dps)
- struct uaudio_softc *sc;
- usb_descriptor_t *v;
- usb_descriptor_t **dps;
+uaudio_add_mixer(struct uaudio_softc *sc, usb_descriptor_t *v,
+ usb_descriptor_t **dps)
{
struct usb_audio_mixer_unit *d = (struct usb_audio_mixer_unit *)v;
struct usb_audio_mixer_unit_1 *d1;
@@ -756,10 +731,8 @@ uaudio_add_mixer(sc, v, dps)
}
void
-uaudio_add_selector(sc, v, dps)
- struct uaudio_softc *sc;
- usb_descriptor_t *v;
- usb_descriptor_t **dps;
+uaudio_add_selector(struct uaudio_softc *sc, usb_descriptor_t *v,
+ usb_descriptor_t **dps)
{
#ifdef UAUDIO_DEBUG
struct usb_audio_selector_unit *d =
@@ -772,10 +745,8 @@ uaudio_add_selector(sc, v, dps)
}
void
-uaudio_add_feature(sc, v, dps)
- struct uaudio_softc *sc;
- usb_descriptor_t *v;
- usb_descriptor_t **dps;
+uaudio_add_feature(struct uaudio_softc *sc, usb_descriptor_t *v,
+ usb_descriptor_t **dps)
{
struct usb_audio_feature_unit *d = (struct usb_audio_feature_unit *)v;
uByte *ctls = d->bmaControls;
@@ -898,10 +869,8 @@ uaudio_add_feature(sc, v, dps)
}
void
-uaudio_add_processing_updown(sc, v, dps)
- struct uaudio_softc *sc;
- usb_descriptor_t *v;
- usb_descriptor_t **dps;
+uaudio_add_processing_updown(struct uaudio_softc *sc, usb_descriptor_t *v,
+ usb_descriptor_t **dps)
{
struct usb_audio_processing_unit *d =
(struct usb_audio_processing_unit *)v;
@@ -938,10 +907,8 @@ uaudio_add_processing_updown(sc, v, dps)
}
void
-uaudio_add_processing(sc, v, dps)
- struct uaudio_softc *sc;
- usb_descriptor_t *v;
- usb_descriptor_t **dps;
+uaudio_add_processing(struct uaudio_softc *sc, usb_descriptor_t *v,
+ usb_descriptor_t **dps)
{
struct usb_audio_processing_unit *d =
(struct usb_audio_processing_unit *)v;
@@ -983,10 +950,8 @@ uaudio_add_processing(sc, v, dps)
}
void
-uaudio_add_extension(sc, v, dps)
- struct uaudio_softc *sc;
- usb_descriptor_t *v;
- usb_descriptor_t **dps;
+uaudio_add_extension(struct uaudio_softc *sc, usb_descriptor_t *v,
+ usb_descriptor_t **dps)
{
struct usb_audio_extension_unit *d =
(struct usb_audio_extension_unit *)v;
@@ -997,6 +962,9 @@ uaudio_add_extension(sc, v, dps)
DPRINTFN(2,("uaudio_add_extension: bUnitId=%d bNrInPins=%d\n",
d->bUnitId, d->bNrInPins));
+ if (usbd_get_quirks(sc->sc_udev)->uq_flags & UQ_NO_XU)
+ return;
+
if (d1->bmControls[0] & UA_EXT_ENABLE_MASK) {
mix.wIndex = MAKE(d->bUnitId, sc->sc_ac_iface);
mix.nchan = 1;
@@ -1010,9 +978,7 @@ uaudio_add_extension(sc, v, dps)
}
usbd_status
-uaudio_identify(sc, cdesc)
- struct uaudio_softc *sc;
- usb_config_descriptor_t *cdesc;
+uaudio_identify(struct uaudio_softc *sc, usb_config_descriptor_t *cdesc)
{
usbd_status err;
@@ -1023,11 +989,9 @@ uaudio_identify(sc, cdesc)
}
void
-uaudio_add_alt(sc, ai)
- struct uaudio_softc *sc;
- struct as_info *ai;
+uaudio_add_alt(struct uaudio_softc *sc, struct as_info *ai)
{
- if (sc->sc_nalts == NULL)
+ if (sc->sc_nalts == 0)
sc->sc_alts = malloc(sizeof *ai, M_USBDEV, M_NOWAIT);
else
sc->sc_alts = realloc(sc->sc_alts,
@@ -1043,13 +1007,9 @@ uaudio_add_alt(sc, ai)
}
usbd_status
-uaudio_process_as(sc, buf, offsp, size, id)
- struct uaudio_softc *sc;
- char *buf;
- int *offsp;
+uaudio_process_as(struct uaudio_softc *sc, char *buf, int *offsp,
+ int size, usb_interface_descriptor_t *id)
#define offs (*offsp)
- int size;
- usb_interface_descriptor_t *id;
{
struct usb_audio_streaming_interface_descriptor *asid;
struct usb_audio_streaming_type1_descriptor *asf1d;
@@ -1161,9 +1121,7 @@ uaudio_process_as(sc, buf, offsp, size, id)
#undef offs
usbd_status
-uaudio_identify_as(sc, cdesc)
- struct uaudio_softc *sc;
- usb_config_descriptor_t *cdesc;
+uaudio_identify_as(struct uaudio_softc *sc, usb_config_descriptor_t *cdesc)
{
usb_interface_descriptor_t *id;
usbd_status err;
@@ -1218,9 +1176,7 @@ uaudio_identify_as(sc, cdesc)
}
usbd_status
-uaudio_identify_ac(sc, cdesc)
- struct uaudio_softc *sc;
- usb_config_descriptor_t *cdesc;
+uaudio_identify_ac(struct uaudio_softc *sc, usb_config_descriptor_t *cdesc)
{
usb_interface_descriptor_t *id;
struct usb_audio_control_descriptor *acdp;
@@ -1326,9 +1282,7 @@ uaudio_identify_ac(sc, cdesc)
}
int
-uaudio_query_devinfo(addr, mi)
- void *addr;
- mixer_devinfo_t *mi;
+uaudio_query_devinfo(void *addr, mixer_devinfo_t *mi)
{
struct uaudio_softc *sc = addr;
struct mixerctl *mc;
@@ -1388,9 +1342,7 @@ uaudio_query_devinfo(addr, mi)
}
int
-uaudio_open(addr, flags)
- void *addr;
- int flags;
+uaudio_open(void *addr, int flags)
{
struct uaudio_softc *sc = addr;
@@ -1415,8 +1367,7 @@ uaudio_open(addr, flags)
* Close function is called at splaudio().
*/
void
-uaudio_close(addr)
- void *addr;
+uaudio_close(void *addr)
{
struct uaudio_softc *sc = addr;
@@ -1428,8 +1379,7 @@ uaudio_close(addr)
}
int
-uaudio_drain(addr)
- void *addr;
+uaudio_drain(void *addr)
{
struct uaudio_softc *sc = addr;
@@ -1439,8 +1389,7 @@ uaudio_drain(addr)
}
int
-uaudio_halt_out_dma(addr)
- void *addr;
+uaudio_halt_out_dma(void *addr)
{
struct uaudio_softc *sc = addr;
@@ -1454,8 +1403,7 @@ uaudio_halt_out_dma(addr)
}
int
-uaudio_halt_in_dma(addr)
- void *addr;
+uaudio_halt_in_dma(void *addr)
{
struct uaudio_softc *sc = addr;
@@ -1469,9 +1417,7 @@ uaudio_halt_in_dma(addr)
}
int
-uaudio_getdev(addr, retp)
- void *addr;
- struct audio_device *retp;
+uaudio_getdev(void *addr, struct audio_device *retp)
{
struct uaudio_softc *sc = addr;
@@ -1487,9 +1433,7 @@ uaudio_getdev(addr, retp)
* Make sure the block size is large enough to hold all outstanding transfers.
*/
int
-uaudio_round_blocksize(addr, blk)
- void *addr;
- int blk;
+uaudio_round_blocksize(void *addr, int blk)
{
struct uaudio_softc *sc = addr;
int bpf;
@@ -1515,8 +1459,7 @@ uaudio_round_blocksize(addr, blk)
}
int
-uaudio_get_props(addr)
- void *addr;
+uaudio_get_props(void *addr)
{
struct uaudio_softc *sc = addr;
@@ -1524,9 +1467,8 @@ uaudio_get_props(addr)
}
int
-uaudio_get(sc, which, type, wValue, wIndex, len)
- struct uaudio_softc *sc;
- int type, which, wValue, wIndex, len;
+uaudio_get(struct uaudio_softc *sc, int which, int type, int wValue,
+ int wIndex, int len)
{
usb_device_request_t req;
u_int8_t data[4];
@@ -1565,9 +1507,8 @@ uaudio_get(sc, which, type, wValue, wIndex, len)
}
void
-uaudio_set(sc, which, type, wValue, wIndex, len, val)
- struct uaudio_softc *sc;
- int type, which, wValue, wIndex, len, val;
+uaudio_set(struct uaudio_softc *sc, int which, int type, int wValue,
+ int wIndex, int len, int val)
{
usb_device_request_t req;
u_int8_t data[4];
@@ -1603,8 +1544,7 @@ uaudio_set(sc, which, type, wValue, wIndex, len, val)
}
int
-uaudio_signext(type, val)
- int type, val;
+uaudio_signext(int type, int val)
{
if (!MIX_UNSIGNED(type)) {
if (MIX_SIZE(type) == 2)
@@ -1616,9 +1556,7 @@ uaudio_signext(type, val)
}
int
-uaudio_value2bsd(mc, val)
- struct mixerctl *mc;
- int val;
+uaudio_value2bsd(struct mixerctl *mc, int val)
{
DPRINTFN(5, ("uaudio_value2bsd: type=%03x val=%d min=%d max=%d ",
mc->type, val, mc->minval, mc->maxval));
@@ -1632,9 +1570,7 @@ uaudio_value2bsd(mc, val)
}
int
-uaudio_bsd2value(mc, val)
- struct mixerctl *mc;
- int val;
+uaudio_bsd2value(struct mixerctl *mc, int val)
{
DPRINTFN(5,("uaudio_bsd2value: type=%03x val=%d min=%d max=%d ",
mc->type, val, mc->minval, mc->maxval));
@@ -1647,11 +1583,8 @@ uaudio_bsd2value(mc, val)
}
int
-uaudio_ctl_get(sc, which, mc, chan)
- struct uaudio_softc *sc;
- int which;
- struct mixerctl *mc;
- int chan;
+uaudio_ctl_get(struct uaudio_softc *sc, int which, struct mixerctl *mc,
+ int chan)
{
int val;
@@ -1662,12 +1595,8 @@ uaudio_ctl_get(sc, which, mc, chan)
}
void
-uaudio_ctl_set(sc, which, mc, chan, val)
- struct uaudio_softc *sc;
- int which;
- struct mixerctl *mc;
- int chan;
- int val;
+uaudio_ctl_set(struct uaudio_softc *sc, int which, struct mixerctl *mc,
+ int chan, int val)
{
val = uaudio_bsd2value(mc, val);
uaudio_set(sc, which, UT_WRITE_CLASS_INTERFACE, mc->wValue[chan],
@@ -1675,9 +1604,7 @@ uaudio_ctl_set(sc, which, mc, chan, val)
}
int
-uaudio_mixer_get_port(addr, cp)
- void *addr;
- mixer_ctrl_t *cp;
+uaudio_mixer_get_port(void *addr, mixer_ctrl_t *cp)
{
struct uaudio_softc *sc = addr;
struct mixerctl *mc;
@@ -1718,9 +1645,7 @@ uaudio_mixer_get_port(addr, cp)
}
int
-uaudio_mixer_set_port(addr, cp)
- void *addr;
- mixer_ctrl_t *cp;
+uaudio_mixer_set_port(void *addr, mixer_ctrl_t *cp)
{
struct uaudio_softc *sc = addr;
struct mixerctl *mc;
@@ -1757,13 +1682,9 @@ uaudio_mixer_set_port(addr, cp)
}
int
-uaudio_trigger_input(addr, start, end, blksize, intr, arg, param)
- void *addr;
- void *start, *end;
- int blksize;
- void (*intr) __P((void *));
- void *arg;
- struct audio_params *param;
+uaudio_trigger_input(void *addr, void *start, void *end, int blksize,
+ void (*intr)(void *), void *arg,
+ struct audio_params *param)
{
struct uaudio_softc *sc = addr;
struct chan *ch = &sc->sc_chan;
@@ -1803,13 +1724,9 @@ uaudio_trigger_input(addr, start, end, blksize, intr, arg, param)
}
int
-uaudio_trigger_output(addr, start, end, blksize, intr, arg, param)
- void *addr;
- void *start, *end;
- int blksize;
- void (*intr) __P((void *));
- void *arg;
- struct audio_params *param;
+uaudio_trigger_output(void *addr, void *start, void *end, int blksize,
+ void (*intr)(void *), void *arg,
+ struct audio_params *param)
{
struct uaudio_softc *sc = addr;
struct chan *ch = &sc->sc_chan;
@@ -1850,9 +1767,7 @@ uaudio_trigger_output(addr, start, end, blksize, intr, arg, param)
/* Set up a pipe for a channel. */
usbd_status
-uaudio_chan_open(sc, ch)
- struct uaudio_softc *sc;
- struct chan *ch;
+uaudio_chan_open(struct uaudio_softc *sc, struct chan *ch)
{
struct as_info *as = &sc->sc_alts[sc->sc_curaltidx];
int endpt = as->edesc->bEndpointAddress;
@@ -1882,9 +1797,7 @@ uaudio_chan_open(sc, ch)
}
void
-uaudio_chan_close(sc, ch)
- struct uaudio_softc *sc;
- struct chan *ch;
+uaudio_chan_close(struct uaudio_softc *sc, struct chan *ch)
{
if (sc->sc_nullalt >= 0) {
DPRINTF(("uaudio_close_chan: set null alt=%d\n",
@@ -1896,9 +1809,7 @@ uaudio_chan_close(sc, ch)
}
usbd_status
-uaudio_chan_alloc_buffers(sc, ch)
- struct uaudio_softc *sc;
- struct chan *ch;
+uaudio_chan_alloc_buffers(struct uaudio_softc *sc, struct chan *ch)
{
usbd_xfer_handle xfer;
void *buf;
@@ -1929,9 +1840,7 @@ bad:
}
void
-uaudio_chan_free_buffers(sc, ch)
- struct uaudio_softc *sc;
- struct chan *ch;
+uaudio_chan_free_buffers(struct uaudio_softc *sc, struct chan *ch)
{
int i;
@@ -1941,8 +1850,7 @@ uaudio_chan_free_buffers(sc, ch)
/* Called at splusb() */
void
-uaudio_chan_ptransfer(ch)
- struct chan *ch;
+uaudio_chan_ptransfer(struct chan *ch)
{
struct chanbuf *cb;
int i, n, size, residue, total;
@@ -2006,10 +1914,8 @@ uaudio_chan_ptransfer(ch)
}
void
-uaudio_chan_pintr(xfer, priv, status)
- usbd_xfer_handle xfer;
- usbd_private_handle priv;
- usbd_status status;
+uaudio_chan_pintr(usbd_xfer_handle xfer, usbd_private_handle priv,
+ usbd_status status)
{
struct chanbuf *cb = priv;
struct chan *ch = cb->chan;
@@ -2047,8 +1953,7 @@ uaudio_chan_pintr(xfer, priv, status)
/* Called at splusb() */
void
-uaudio_chan_rtransfer(ch)
- struct chan *ch;
+uaudio_chan_rtransfer(struct chan *ch)
{
struct chanbuf *cb;
int i, size, residue, total;
@@ -2097,10 +2002,8 @@ uaudio_chan_rtransfer(ch)
}
void
-uaudio_chan_rintr(xfer, priv, status)
- usbd_xfer_handle xfer;
- usbd_private_handle priv;
- usbd_status status;
+uaudio_chan_rintr(usbd_xfer_handle xfer, usbd_private_handle priv,
+ usbd_status status)
{
struct chanbuf *cb = priv;
struct chan *ch = cb->chan;
@@ -2151,11 +2054,8 @@ uaudio_chan_rintr(xfer, priv, status)
}
void
-uaudio_chan_set_param(ch, param, start, end, blksize)
- struct chan *ch;
- struct audio_params *param;
- u_char *start, *end;
- int blksize;
+uaudio_chan_set_param(struct chan *ch, struct audio_params *param,
+ u_char *start, u_char *end, int blksize)
{
int samples_per_frame, sample_size;
@@ -2177,17 +2077,15 @@ uaudio_chan_set_param(ch, param, start, end, blksize)
}
int
-uaudio_set_params(addr, setmode, usemode, p, r)
- void *addr;
- int setmode, usemode;
- struct audio_params *p, *r;
+uaudio_set_params(void *addr, int setmode, int usemode,
+ struct audio_params *p, struct audio_params *r)
{
struct uaudio_softc *sc = addr;
int flags = sc->sc_altflags;
int pfactor, rfactor;
int enc, i, j;
- void (*pswcode) __P((void *, u_char *buf, int cnt));
- void (*rswcode) __P((void *, u_char *buf, int cnt));
+ void (*pswcode)(void *, u_char *buf, int cnt);
+ void (*rswcode)(void *, u_char *buf, int cnt);
if (sc->sc_dying)
return (EIO);
@@ -2243,13 +2141,13 @@ uaudio_set_params(addr, setmode, usemode, p, r)
pswcode = mulaw_to_slinear8;
rswcode = slinear8_to_mulaw;
enc = AUDIO_ENCODING_SLINEAR_LE;
-#if 0
} else if (flags & HAS_16) {
pswcode = mulaw_to_slinear16_le;
pfactor = 2;
- /* XXX recording not handled */
enc = AUDIO_ENCODING_SLINEAR_LE;
-#endif
+ /* XXX recording not handled */
+ if (setmode & AUMODE_RECORD)
+ return (EINVAL);
} else
return (EINVAL);
}
@@ -2264,13 +2162,13 @@ uaudio_set_params(addr, setmode, usemode, p, r)
pswcode = alaw_to_slinear8;
rswcode = slinear8_to_alaw;
enc = AUDIO_ENCODING_SLINEAR_LE;
-#if 0
} else if (flags & HAS_16) {
pswcode = alaw_to_slinear16_le;
pfactor = 2;
- /* XXX recording not handled */
enc = AUDIO_ENCODING_SLINEAR_LE;
-#endif
+ /* XXX recording not handled */
+ if (setmode & AUMODE_RECORD)
+ return (EINVAL);
} else
return (EINVAL);
}
@@ -2324,10 +2222,7 @@ uaudio_set_params(addr, setmode, usemode, p, r)
}
usbd_status
-uaudio_set_speed(sc, endpt, speed)
- struct uaudio_softc *sc;
- int endpt;
- u_int speed;
+uaudio_set_speed(struct uaudio_softc *sc, int endpt, u_int speed)
{
usb_device_request_t req;
u_int8_t data[3];
diff --git a/sys/dev/usb/uaudioreg.h b/sys/dev/usb/uaudioreg.h
index 45ce629a443..49fd49c07e6 100644
--- a/sys/dev/usb/uaudioreg.h
+++ b/sys/dev/usb/uaudioreg.h
@@ -1,5 +1,5 @@
-/* $OpenBSD: uaudioreg.h,v 1.4 2000/07/04 11:44:22 fgsch Exp $ */
-/* $NetBSD: uaudioreg.h,v 1.4 2000/01/16 09:32:56 augustss Exp $ */
+/* $OpenBSD: uaudioreg.h,v 1.5 2000/11/08 18:10:37 aaron Exp $ */
+/* $NetBSD: uaudioreg.h,v 1.6 2000/05/30 10:10:17 augustss Exp $ */
/*
* Copyright (c) 1999 The NetBSD Foundation, Inc.
diff --git a/sys/dev/usb/ucom.c b/sys/dev/usb/ucom.c
index 28d49c05b96..1fdf8aa071f 100644
--- a/sys/dev/usb/ucom.c
+++ b/sys/dev/usb/ucom.c
@@ -1,5 +1,5 @@
-/* $OpenBSD: ucom.c,v 1.5 2000/07/06 21:51:56 fgsch Exp $ */
-/* $NetBSD: ucom.c,v 1.22 2000/04/14 14:21:55 augustss Exp $ */
+/* $OpenBSD: ucom.c,v 1.6 2000/11/08 18:10:37 aaron Exp $ */
+/* $NetBSD: ucom.c,v 1.30 2000/09/23 04:33:04 augustss Exp $ */
/*
* Copyright (c) 1998, 2000 The NetBSD Foundation, Inc.
@@ -75,9 +75,17 @@ int ucomdebug = 0;
#endif
#define DPRINTF(x) DPRINTFN(0, x)
+#if defined(__NetBSD__)
+#define UCOMUNIT_MASK 0x3ffff
+#define UCOMDIALOUT_MASK 0x80000
+#define UCOMCALLUNIT_MASK 0x40000
+#endif
+
+#if defined(__OpenBSD__)
#define UCOMUNIT_MASK 0x3f
#define UCOMDIALOUT_MASK 0x80
#define UCOMCALLUNIT_MASK 0x40
+#endif
#define UCOMUNIT(x) (minor(x) & UCOMUNIT_MASK)
#define UCOMDIALOUT(x) (minor(x) & UCOMDIALOUT_MASK)
@@ -102,7 +110,8 @@ struct ucom_softc {
usbd_xfer_handle sc_oxfer; /* write request */
u_char *sc_obuf; /* write buffer */
u_int sc_obufsize; /* write buffer size */
- u_int sc_obufsizepad; /* write buffer size padded */
+ u_int sc_opkthdrlen; /* header length of
+ * output packet */
struct ucom_methods *sc_methods;
void *sc_parent;
@@ -122,23 +131,21 @@ struct ucom_softc {
cdev_decl(ucom);
-Static void ucom_cleanup __P((struct ucom_softc *));
-Static void ucom_hwiflow __P((struct ucom_softc *));
-Static int ucomparam __P((struct tty *, struct termios *));
-Static void ucomstart __P((struct tty *));
-Static void ucom_shutdown __P((struct ucom_softc *));
-Static int ucom_do_ioctl __P((struct ucom_softc *, u_long, caddr_t,
- int, struct proc *));
-Static void ucom_dtr __P((struct ucom_softc *, int));
-Static void ucom_rts __P((struct ucom_softc *, int));
-Static void ucom_break __P((struct ucom_softc *, int));
-Static usbd_status ucomstartread __P((struct ucom_softc *));
-Static void ucomreadcb __P((usbd_xfer_handle, usbd_private_handle,
- usbd_status status));
-Static void ucomwritecb __P((usbd_xfer_handle, usbd_private_handle,
- usbd_status status));
-Static void tiocm_to_ucom __P((struct ucom_softc *, int, int));
-Static int ucom_to_tiocm __P((struct ucom_softc *));
+Static void ucom_cleanup(struct ucom_softc *);
+Static void ucom_hwiflow(struct ucom_softc *);
+Static int ucomparam(struct tty *, struct termios *);
+Static void ucomstart(struct tty *);
+Static void ucom_shutdown(struct ucom_softc *);
+Static int ucom_do_ioctl(struct ucom_softc *, u_long, caddr_t,
+ int, struct proc *);
+Static void ucom_dtr(struct ucom_softc *, int);
+Static void ucom_rts(struct ucom_softc *, int);
+Static void ucom_break(struct ucom_softc *, int);
+Static usbd_status ucomstartread(struct ucom_softc *);
+Static void ucomreadcb(usbd_xfer_handle, usbd_private_handle, usbd_status);
+Static void ucomwritecb(usbd_xfer_handle, usbd_private_handle, usbd_status);
+Static void tiocm_to_ucom(struct ucom_softc *, u_long, int);
+Static int ucom_to_tiocm(struct ucom_softc *);
USB_DECLARE_DRIVER(ucom);
@@ -164,7 +171,7 @@ USB_ATTACH(ucom)
sc->sc_ibufsize = uca->ibufsize;
sc->sc_ibufsizepad = uca->ibufsizepad;
sc->sc_obufsize = uca->obufsize;
- sc->sc_obufsizepad = uca->obufsizepad;
+ sc->sc_opkthdrlen = uca->opkthdrlen;
sc->sc_methods = uca->methods;
sc->sc_parent = uca->arg;
sc->sc_portno = uca->portno;
@@ -228,9 +235,7 @@ USB_DETACH(ucom)
#if defined(__NetBSD__) || defined(__OpenBSD__)
int
-ucom_activate(self, act)
- device_ptr_t self;
- enum devact act;
+ucom_activate(device_ptr_t self, enum devact act)
{
struct ucom_softc *sc = (struct ucom_softc *)self;
@@ -248,8 +253,7 @@ ucom_activate(self, act)
#endif
void
-ucom_shutdown(sc)
- struct ucom_softc *sc;
+ucom_shutdown(struct ucom_softc *sc)
{
struct tty *tp = sc->sc_tty;
@@ -265,10 +269,7 @@ ucom_shutdown(sc)
}
int
-ucomopen(dev, flag, mode, p)
- dev_t dev;
- int flag, mode;
- struct proc *p;
+ucomopen(dev_t dev, int flag, int mode, struct proc *p)
{
int unit = UCOMUNIT(dev);
usbd_status err;
@@ -326,6 +327,9 @@ ucomopen(dev, flag, mode, p)
sc->sc_portno);
if (error) {
ucom_cleanup(sc);
+ sc->sc_opening = 0;
+ wakeup(&sc->sc_opening);
+ splx(s);
return (error);
}
}
@@ -363,7 +367,7 @@ ucomopen(dev, flag, mode, p)
*/
ucom_dtr(sc, 1);
- // XXX CLR(sc->sc_rx_flags, RX_ANY_BLOCK);
+ /* XXX CLR(sc->sc_rx_flags, RX_ANY_BLOCK);*/
ucom_hwiflow(sc);
DPRINTF(("ucomopen: open pipes in=%d out=%d\n",
@@ -376,7 +380,8 @@ ucomopen(dev, flag, mode, p)
DPRINTF(("%s: open bulk out error (addr %d), err=%s\n",
USBDEVNAME(sc->sc_dev), sc->sc_bulkin_no,
usbd_errstr(err)));
- return (EIO);
+ error = EIO;
+ goto fail_0;
}
err = usbd_open_pipe(sc->sc_iface, sc->sc_bulkout_no,
USBD_EXCLUSIVE_USE, &sc->sc_bulkout_pipe);
@@ -384,41 +389,36 @@ ucomopen(dev, flag, mode, p)
DPRINTF(("%s: open bulk in error (addr %d), err=%s\n",
USBDEVNAME(sc->sc_dev), sc->sc_bulkout_no,
usbd_errstr(err)));
- usbd_close_pipe(sc->sc_bulkin_pipe);
- return (EIO);
+ error = EIO;
+ goto fail_1;
}
/* Allocate a request and an input buffer and start reading. */
sc->sc_ixfer = usbd_alloc_xfer(sc->sc_udev);
if (sc->sc_ixfer == NULL) {
- usbd_close_pipe(sc->sc_bulkin_pipe);
- usbd_close_pipe(sc->sc_bulkout_pipe);
- return (ENOMEM);
+ error = ENOMEM;
+ goto fail_2;
}
+
sc->sc_ibuf = usbd_alloc_buffer(sc->sc_ixfer,
sc->sc_ibufsizepad);
if (sc->sc_ibuf == NULL) {
- usbd_free_xfer(sc->sc_ixfer);
- usbd_close_pipe(sc->sc_bulkin_pipe);
- usbd_close_pipe(sc->sc_bulkout_pipe);
- return (ENOMEM);
+ error = ENOMEM;
+ goto fail_3;
}
sc->sc_oxfer = usbd_alloc_xfer(sc->sc_udev);
if (sc->sc_oxfer == NULL) {
- usbd_free_xfer(sc->sc_ixfer);
- usbd_close_pipe(sc->sc_bulkin_pipe);
- usbd_close_pipe(sc->sc_bulkout_pipe);
- return (ENOMEM);
+ error = ENOMEM;
+ goto fail_3;
}
+
sc->sc_obuf = usbd_alloc_buffer(sc->sc_oxfer,
- sc->sc_obufsizepad);
+ sc->sc_obufsize +
+ sc->sc_opkthdrlen);
if (sc->sc_obuf == NULL) {
- usbd_free_xfer(sc->sc_oxfer);
- usbd_free_xfer(sc->sc_ixfer);
- usbd_close_pipe(sc->sc_bulkin_pipe);
- usbd_close_pipe(sc->sc_bulkout_pipe);
- return (ENOMEM);
+ error = ENOMEM;
+ goto fail_4;
}
ucomstartread(sc);
@@ -441,6 +441,20 @@ ucomopen(dev, flag, mode, p)
return (0);
+fail_4:
+ usbd_free_xfer(sc->sc_oxfer);
+fail_3:
+ usbd_free_xfer(sc->sc_ixfer);
+fail_2:
+ usbd_close_pipe(sc->sc_bulkout_pipe);
+fail_1:
+ usbd_close_pipe(sc->sc_bulkin_pipe);
+fail_0:
+ sc->sc_opening = 0;
+ wakeup(&sc->sc_opening);
+ splx(s);
+ return (error);
+
bad:
#if defined(__NetBSD__)
if (!ISSET(tp->t_state, TS_ISOPEN) && tp->t_wopen == 0) {
@@ -458,10 +472,7 @@ bad:
}
int
-ucomclose(dev, flag, mode, p)
- dev_t dev;
- int flag, mode;
- struct proc *p;
+ucomclose(dev_t dev, int flag, int mode, struct proc *p)
{
struct ucom_softc *sc = ucom_cd.cd_devs[UCOMUNIT(dev)];
struct tty *tp = sc->sc_tty;
@@ -498,10 +509,7 @@ ucomclose(dev, flag, mode, p)
}
int
-ucomread(dev, uio, flag)
- dev_t dev;
- struct uio *uio;
- int flag;
+ucomread(dev_t dev, struct uio *uio, int flag)
{
struct ucom_softc *sc = ucom_cd.cd_devs[UCOMUNIT(dev)];
struct tty *tp = sc->sc_tty;
@@ -518,10 +526,7 @@ ucomread(dev, uio, flag)
}
int
-ucomwrite(dev, uio, flag)
- dev_t dev;
- struct uio *uio;
- int flag;
+ucomwrite(dev_t dev, struct uio *uio, int flag)
{
struct ucom_softc *sc = ucom_cd.cd_devs[UCOMUNIT(dev)];
struct tty *tp = sc->sc_tty;
@@ -538,8 +543,7 @@ ucomwrite(dev, uio, flag)
}
struct tty *
-ucomtty(dev)
- dev_t dev;
+ucomtty(dev_t dev)
{
struct ucom_softc *sc = ucom_cd.cd_devs[UCOMUNIT(dev)];
struct tty *tp = sc->sc_tty;
@@ -548,12 +552,7 @@ ucomtty(dev)
}
int
-ucomioctl(dev, cmd, data, flag, p)
- dev_t dev;
- u_long cmd;
- caddr_t data;
- int flag;
- struct proc *p;
+ucomioctl(dev_t dev, u_long cmd, caddr_t data, int flag, struct proc *p)
{
struct ucom_softc *sc = ucom_cd.cd_devs[UCOMUNIT(dev)];
int error;
@@ -566,12 +565,8 @@ ucomioctl(dev, cmd, data, flag, p)
}
Static int
-ucom_do_ioctl(sc, cmd, data, flag, p)
- struct ucom_softc *sc;
- u_long cmd;
- caddr_t data;
- int flag;
- struct proc *p;
+ucom_do_ioctl(struct ucom_softc *sc, u_long cmd, caddr_t data,
+ int flag, struct proc *p)
{
struct tty *tp = sc->sc_tty;
int error;
@@ -651,9 +646,7 @@ ucom_do_ioctl(sc, cmd, data, flag, p)
}
Static void
-tiocm_to_ucom(sc, how, ttybits)
- struct ucom_softc *sc;
- int how, ttybits;
+tiocm_to_ucom(struct ucom_softc *sc, u_long how, int ttybits)
{
u_char combits;
@@ -678,13 +671,14 @@ tiocm_to_ucom(sc, how, ttybits)
break;
}
- ucom_dtr(sc, (sc->sc_mcr & UMCR_DTR) != 0);
- ucom_rts(sc, (sc->sc_mcr & UMCR_RTS) != 0);
+ if (how == TIOCMSET || ISSET(combits, UMCR_DTR))
+ ucom_dtr(sc, (sc->sc_mcr & UMCR_DTR) != 0);
+ if (how == TIOCMSET || ISSET(combits, UMCR_RTS))
+ ucom_rts(sc, (sc->sc_mcr & UMCR_RTS) != 0);
}
Static int
-ucom_to_tiocm(sc)
- struct ucom_softc *sc;
+ucom_to_tiocm(struct ucom_softc *sc)
{
u_char combits;
int ttybits = 0;
@@ -727,9 +721,7 @@ ucom_break(sc, onoff)
}
Static void
-ucom_dtr(sc, onoff)
- struct ucom_softc *sc;
- int onoff;
+ucom_dtr(struct ucom_softc *sc, int onoff)
{
DPRINTF(("ucom_dtr: onoff=%d\n", onoff));
@@ -739,9 +731,7 @@ ucom_dtr(sc, onoff)
}
Static void
-ucom_rts(sc, onoff)
- struct ucom_softc *sc;
- int onoff;
+ucom_rts(struct ucom_softc *sc, int onoff)
{
DPRINTF(("ucom_rts: onoff=%d\n", onoff));
@@ -751,12 +741,18 @@ ucom_rts(sc, onoff)
}
void
-ucom_status_change(sc)
- struct ucom_softc *sc;
+ucom_status_change(struct ucom_softc *sc)
{
+ struct tty *tp = sc->sc_tty;
+ u_char old_msr;
+
if (sc->sc_methods->ucom_get_status != NULL) {
+ old_msr = sc->sc_msr;
sc->sc_methods->ucom_get_status(sc->sc_parent, sc->sc_portno,
&sc->sc_lsr, &sc->sc_msr);
+ if (ISSET((sc->sc_msr ^ old_msr), UMSR_DCD))
+ (*linesw[tp->t_line].l_modem)(tp,
+ ISSET(sc->sc_msr, UMSR_DCD));
} else {
sc->sc_lsr = 0;
sc->sc_msr = 0;
@@ -764,9 +760,7 @@ ucom_status_change(sc)
}
Static int
-ucomparam(tp, t)
- struct tty *tp;
- struct termios *t;
+ucomparam(struct tty *tp, struct termios *t)
{
struct ucom_softc *sc = ucom_cd.cd_devs[UCOMUNIT(tp->t_dev)];
int error;
@@ -796,7 +790,7 @@ ucomparam(tp, t)
tp->t_cflag == t->c_cflag)
return (0);
- //XXX lcr = ISSET(sc->sc_lcr, LCR_SBREAK) | cflag2lcr(t->c_cflag);
+ /* XXX lcr = ISSET(sc->sc_lcr, LCR_SBREAK) | cflag2lcr(t->c_cflag); */
/* And copy to tty. */
tp->t_ispeed = 0;
@@ -810,7 +804,7 @@ ucomparam(tp, t)
return (error);
}
- // XXX worry about CHWFLOW
+ /* XXX worry about CHWFLOW */
/*
* Update the tty layer's idea of the carrier bit, in case we changed
@@ -837,8 +831,7 @@ XXX what if the hardware is not open
* (un)block input via hw flowcontrol
*/
Static void
-ucom_hwiflow(sc)
- struct ucom_softc *sc;
+ucom_hwiflow(struct ucom_softc *sc)
{
DPRINTF(("ucom_hwiflow:\n"));
#if 0
@@ -861,8 +854,7 @@ XXX
}
Static void
-ucomstart(tp)
- struct tty *tp;
+ucomstart(struct tty *tp)
{
struct ucom_softc *sc = ucom_cd.cd_devs[UCOMUNIT(tp->t_dev)];
usbd_status err;
@@ -932,9 +924,7 @@ void
#else
int
#endif
-ucomstop(tp, flag)
- struct tty *tp;
- int flag;
+ucomstop(struct tty *tp, int flag)
{
DPRINTF(("ucomstop: flag=%d\n", flag));
#if 0
@@ -951,15 +941,12 @@ ucomstop(tp, flag)
splx(s);
#endif
#if !defined(__NetBSD__)
- return 0;
+ return (0);
#endif
}
Static void
-ucomwritecb(xfer, p, status)
- usbd_xfer_handle xfer;
- usbd_private_handle p;
- usbd_status status;
+ucomwritecb(usbd_xfer_handle xfer, usbd_private_handle p, usbd_status status)
{
struct ucom_softc *sc = (struct ucom_softc *)p;
struct tty *tp = sc->sc_tty;
@@ -980,6 +967,8 @@ ucomwritecb(xfer, p, status)
usbd_get_xfer_status(xfer, NULL, NULL, &cc, NULL);
DPRINTFN(5,("ucomwritecb: cc=%d\n", cc));
+ /* convert from USB bytes to tty bytes */
+ cc -= sc->sc_opkthdrlen;
s = spltty();
CLR(tp->t_state, TS_BUSY);
@@ -992,8 +981,7 @@ ucomwritecb(xfer, p, status)
}
Static usbd_status
-ucomstartread(sc)
- struct ucom_softc *sc;
+ucomstartread(struct ucom_softc *sc)
{
usbd_status err;
@@ -1012,14 +1000,11 @@ ucomstartread(sc)
}
Static void
-ucomreadcb(xfer, p, status)
- usbd_xfer_handle xfer;
- usbd_private_handle p;
- usbd_status status;
+ucomreadcb(usbd_xfer_handle xfer, usbd_private_handle p, usbd_status status)
{
struct ucom_softc *sc = (struct ucom_softc *)p;
struct tty *tp = sc->sc_tty;
- int (*rint) __P((int c, struct tty *tp)) = linesw[tp->t_line].l_rint;
+ int (*rint)(int c, struct tty *tp) = linesw[tp->t_line].l_rint;
usbd_status err;
u_int32_t cc;
u_char *cp;
@@ -1062,8 +1047,7 @@ ucomreadcb(xfer, p, status)
}
Static void
-ucom_cleanup(sc)
- struct ucom_softc *sc;
+ucom_cleanup(struct ucom_softc *sc)
{
DPRINTF(("ucom_cleanup: closing pipes\n"));
@@ -1079,9 +1063,7 @@ ucom_cleanup(sc)
#endif /* NUCOM > 0 */
int
-ucomprint(aux, pnp)
- void *aux;
- const char *pnp;
+ucomprint(void *aux, const char *pnp)
{
if (pnp)
@@ -1091,20 +1073,15 @@ ucomprint(aux, pnp)
int
#if defined(__OpenBSD__)
-ucomsubmatch(parent, match, aux)
- struct device *parent;
- void *match;
- void *aux;
-{
- struct cfdata *cf = match;
+ucomsubmatch(struct device *parent, void *match, void *aux)
#else
-ucomsubmatch(parent, cf, aux)
- struct device *parent;
- struct cfdata *cf;
- void *aux;
-{
+ucomsubmatch(struct device *parent, struct cfdata *cf, void *aux)
#endif
+{
struct ucom_attach_args *uca = aux;
+#if defined(__OpenBSD__)
+ struct cfdata *cf = match;
+#endif
if (uca->portno != UCOM_UNK_PORTNO &&
cf->ucomcf_portno != UCOM_UNK_PORTNO &&
diff --git a/sys/dev/usb/ucomvar.h b/sys/dev/usb/ucomvar.h
index bd34d061f4b..9fd5245d8cc 100644
--- a/sys/dev/usb/ucomvar.h
+++ b/sys/dev/usb/ucomvar.h
@@ -1,5 +1,5 @@
-/* $OpenBSD: ucomvar.h,v 1.4 2000/07/04 11:44:22 fgsch Exp $ */
-/* $NetBSD: ucomvar.h,v 1.5 2000/04/14 14:21:55 augustss Exp $ */
+/* $OpenBSD: ucomvar.h,v 1.5 2000/11/08 18:10:38 aaron Exp $ */
+/* $NetBSD: ucomvar.h,v 1.8 2000/09/03 19:15:45 augustss Exp $ */
/*
* Copyright (c) 1999 The NetBSD Foundation, Inc.
@@ -54,21 +54,19 @@
struct ucom_softc;
struct ucom_methods {
- void (*ucom_get_status)__P((void *sc, int portno,
- u_char *lsr, u_char *msr));
- void (*ucom_set)__P((void *sc, int portno, int reg, int onoff));
+ void (*ucom_get_status)(void *sc, int portno, u_char *lsr, u_char *msr);
+ void (*ucom_set)(void *sc, int portno, int reg, int onoff);
#define UCOM_SET_DTR 1
#define UCOM_SET_RTS 2
#define UCOM_SET_BREAK 3
- int (*ucom_param)__P((void *sc, int portno, struct termios *));
- int (*ucom_ioctl)__P((void *sc, int portno, u_long cmd,
- caddr_t data, int flag, struct proc *p));
- int (*ucom_open)__P((void *sc, int portno));
- void (*ucom_close)__P((void *sc, int portno));
- void (*ucom_read)__P((void *sc, int portno, u_char **ptr,
- u_int32_t *count));
- void (*ucom_write)__P((void *sc, int portno, u_char *to, u_char *from,
- u_int32_t *count));
+ int (*ucom_param)(void *sc, int portno, struct termios *);
+ int (*ucom_ioctl)(void *sc, int portno, u_long cmd,
+ caddr_t data, int flag, struct proc *p);
+ int (*ucom_open)(void *sc, int portno);
+ void (*ucom_close)(void *sc, int portno);
+ void (*ucom_read)(void *sc, int portno, u_char **ptr, u_int32_t *count);
+ void (*ucom_write)(void *sc, int portno, u_char *to, u_char *from,
+ u_int32_t *count);
};
/* modem control register */
@@ -104,17 +102,17 @@ struct ucom_attach_args {
u_int ibufsize;
u_int ibufsizepad;
u_int obufsize;
- u_int obufsizepad;
+ u_int opkthdrlen;
usbd_device_handle device;
usbd_interface_handle iface;
struct ucom_methods *methods;
void *arg;
};
-int ucomprint __P((void *aux, const char *pnp));
+int ucomprint(void *aux, const char *pnp);
#if defined(__OpenBSD__)
-int ucomsubmatch __P((struct device *parent, void *match, void *aux));
+int ucomsubmatch(struct device *parent, void *cf, void *aux);
#else
-int ucomsubmatch __P((struct device *parent, struct cfdata *cf, void *aux));
+int ucomsubmatch(struct device *parent, struct cfdata *cf, void *aux);
#endif
-void ucom_status_change __P((struct ucom_softc *));
+void ucom_status_change(struct ucom_softc *);
diff --git a/sys/dev/usb/ugen.c b/sys/dev/usb/ugen.c
index 6f3221bfe73..d500d4f1daa 100644
--- a/sys/dev/usb/ugen.c
+++ b/sys/dev/usb/ugen.c
@@ -1,5 +1,5 @@
-/* $OpenBSD: ugen.c,v 1.11 2000/07/04 11:44:23 fgsch Exp $ */
-/* $NetBSD: ugen.c,v 1.37 2000/03/27 12:33:55 augustss Exp $ */
+/* $OpenBSD: ugen.c,v 1.12 2000/11/08 18:10:38 aaron Exp $ */
+/* $NetBSD: ugen.c,v 1.43 2000/10/24 14:53:59 augustss Exp $ */
/* $FreeBSD: src/sys/dev/usb/ugen.c,v 1.26 1999/11/17 22:33:41 n_hibma Exp $ */
/*
@@ -76,6 +76,14 @@ int ugendebug = 0;
#define DPRINTFN(n,x)
#endif
+#define UGEN_CHUNK 128 /* chunk size for read */
+#define UGEN_IBSIZE 1020 /* buffer size */
+#define UGEN_BBSIZE 1024
+
+#define UGEN_NISOFRAMES 500 /* 0.5 seconds worth */
+#define UGEN_NISOREQS 6 /* number of outstanding xfer requests */
+#define UGEN_NISORFRMS 4 /* number of frames (miliseconds) per req */
+
struct ugen_endpoint {
struct ugen_softc *sc;
usb_endpoint_descriptor_t *edesc;
@@ -86,14 +94,19 @@ struct ugen_endpoint {
usbd_pipe_handle pipeh;
struct clist q;
struct selinfo rsel;
- void *ibuf;
+ u_char *ibuf; /* start of buffer (circular for isoc) */
+ u_char *fill; /* location for input (isoc) */
+ u_char *limit; /* end of circular buffer (isoc) */
+ u_char *cur; /* current read location (isoc) */
u_int32_t timeout;
+ struct isoreq {
+ struct ugen_endpoint *sce;
+ usbd_xfer_handle xfer;
+ void *dmabuf;
+ u_int16_t sizes[UGEN_NISORFRMS];
+ } isoreqs[UGEN_NISOREQS];
};
-#define UGEN_CHUNK 128 /* chunk size for read */
-#define UGEN_IBSIZE 1020 /* buffer size */
-#define UGEN_BBSIZE 1024
-
struct ugen_softc {
USBBASEDEVICE sc_dev; /* base device */
usbd_device_handle sc_udev;
@@ -137,18 +150,19 @@ Static struct cdevsw ugen_cdevsw = {
};
#endif
-Static void ugenintr __P((usbd_xfer_handle xfer, usbd_private_handle addr,
- usbd_status status));
-
-Static int ugen_do_read __P((struct ugen_softc *, int, struct uio *, int));
-Static int ugen_do_write __P((struct ugen_softc *, int, struct uio *, int));
-Static int ugen_do_ioctl __P((struct ugen_softc *, int, u_long,
- caddr_t, int, struct proc *));
-Static int ugen_set_config __P((struct ugen_softc *sc, int configno));
-Static usb_config_descriptor_t *ugen_get_cdesc __P((struct ugen_softc *sc,
- int index, int *lenp));
-Static usbd_status ugen_set_interface __P((struct ugen_softc *, int, int));
-Static int ugen_get_alt_index __P((struct ugen_softc *sc, int ifaceidx));
+Static void ugenintr(usbd_xfer_handle xfer, usbd_private_handle addr,
+ usbd_status status);
+Static void ugen_isoc_rintr(usbd_xfer_handle xfer, usbd_private_handle addr,
+ usbd_status status);
+Static int ugen_do_read(struct ugen_softc *, int, struct uio *, int);
+Static int ugen_do_write(struct ugen_softc *, int, struct uio *, int);
+Static int ugen_do_ioctl(struct ugen_softc *, int, u_long,
+ caddr_t, int, struct proc *);
+Static int ugen_set_config(struct ugen_softc *sc, int configno);
+Static usb_config_descriptor_t *ugen_get_cdesc(struct ugen_softc *sc,
+ int index, int *lenp);
+Static usbd_status ugen_set_interface(struct ugen_softc *, int, int);
+Static int ugen_get_alt_index(struct ugen_softc *sc, int ifaceidx);
#define UGENUNIT(n) ((minor(n) >> 4) & 0xf)
#define UGENENDPOINT(n) (minor(n) & 0xf)
@@ -216,9 +230,7 @@ USB_ATTACH(ugen)
}
Static int
-ugen_set_config(sc, configno)
- struct ugen_softc *sc;
- int configno;
+ugen_set_config(struct ugen_softc *sc, int configno)
{
usbd_device_handle dev = sc->sc_udev;
usbd_interface_handle iface;
@@ -233,7 +245,7 @@ ugen_set_config(sc, configno)
USBDEVNAME(sc->sc_dev), configno, sc));
/* Avoid setting the current value. */
if (usbd_get_config_descriptor(dev)->bConfigurationValue != configno) {
- err = usbd_set_config_no(dev, configno, 0);
+ err = usbd_set_config_no(dev, configno, 1);
if (err)
return (err);
}
@@ -268,11 +280,7 @@ ugen_set_config(sc, configno)
}
int
-ugenopen(dev, flag, mode, p)
- dev_t dev;
- int flag;
- int mode;
- struct proc *p;
+ugenopen(dev_t dev, int flag, int mode, struct proc *p)
{
struct ugen_softc *sc;
int unit = UGENUNIT(dev);
@@ -281,6 +289,9 @@ ugenopen(dev, flag, mode, p)
struct ugen_endpoint *sce;
int dir, isize;
usbd_status err;
+ usbd_xfer_handle xfer;
+ void *buf;
+ int i, j;
USB_GET_SC_OPEN(ugen, unit, sc);
@@ -346,8 +357,53 @@ ugenopen(dev, flag, mode, p)
if (err)
return (EIO);
break;
- case UE_CONTROL:
case UE_ISOCHRONOUS:
+ if (dir == OUT)
+ return (EINVAL);
+ isize = UGETW(edesc->wMaxPacketSize);
+ if (isize == 0) /* shouldn't happen */
+ return (EINVAL);
+ sce->ibuf = malloc(isize * UGEN_NISOFRAMES,
+ M_USBDEV, M_WAITOK);
+ sce->cur = sce->fill = sce->ibuf;
+ sce->limit = sce->ibuf + isize * UGEN_NISOFRAMES;
+ DPRINTFN(5, ("ugenopen: isoc endpt=%d, isize=%d\n",
+ endpt, isize));
+ err = usbd_open_pipe(sce->iface,
+ edesc->bEndpointAddress, 0, &sce->pipeh);
+ if (err) {
+ free(sce->ibuf, M_USBDEV);
+ return (EIO);
+ }
+ for(i = 0; i < UGEN_NISOREQS; ++i) {
+ sce->isoreqs[i].sce = sce;
+ xfer = usbd_alloc_xfer(sc->sc_udev);
+ if (xfer == 0)
+ goto bad;
+ sce->isoreqs[i].xfer = xfer;
+ buf = usbd_alloc_buffer
+ (xfer, isize * UGEN_NISORFRMS);
+ if (buf == 0) {
+ i++;
+ goto bad;
+ }
+ sce->isoreqs[i].dmabuf = buf;
+ for(j = 0; j < UGEN_NISORFRMS; ++j)
+ sce->isoreqs[i].sizes[j] = isize;
+ usbd_setup_isoc_xfer
+ (xfer, sce->pipeh, &sce->isoreqs[i],
+ sce->isoreqs[i].sizes,
+ UGEN_NISORFRMS, USBD_NO_COPY,
+ ugen_isoc_rintr);
+ (void)usbd_transfer(xfer);
+ }
+ DPRINTFN(5, ("ugenopen: isoc open done\n"));
+ break;
+ bad:
+ while (--i >= 0) /* implicit buffer free */
+ usbd_free_xfer(sce->isoreqs[i].xfer);
+ return (ENOMEM);
+ case UE_CONTROL:
return (EINVAL);
}
}
@@ -356,16 +412,13 @@ ugenopen(dev, flag, mode, p)
}
int
-ugenclose(dev, flag, mode, p)
- dev_t dev;
- int flag;
- int mode;
- struct proc *p;
+ugenclose(dev_t dev, int flag, int mode, struct proc *p)
{
int endpt = UGENENDPOINT(dev);
struct ugen_softc *sc;
struct ugen_endpoint *sce;
int dir;
+ int i;
USB_GET_SC(ugen, UGENUNIT(dev), sc);
@@ -397,7 +450,20 @@ ugenclose(dev, flag, mode, p)
usbd_abort_pipe(sce->pipeh);
usbd_close_pipe(sce->pipeh);
sce->pipeh = NULL;
-
+
+ switch (sce->edesc->bmAttributes & UE_XFERTYPE) {
+ case UE_INTERRUPT:
+ ndflush(&sce->q, sce->q.c_cc);
+ clfree(&sce->q);
+ break;
+ case UE_ISOCHRONOUS:
+ for (i = 0; i < UGEN_NISOREQS; ++i)
+ usbd_free_xfer(sce->isoreqs[i].xfer);
+
+ default:
+ break;
+ }
+
if (sce->ibuf != NULL) {
free(sce->ibuf, M_USBDEV);
sce->ibuf = NULL;
@@ -411,11 +477,7 @@ ugenclose(dev, flag, mode, p)
}
Static int
-ugen_do_read(sc, endpt, uio, flag)
- struct ugen_softc *sc;
- int endpt;
- struct uio *uio;
- int flag;
+ugen_do_read(struct ugen_softc *sc, int endpt, struct uio *uio, int flag)
{
struct ugen_endpoint *sce = &sc->sc_endpoints[endpt][IN];
u_int32_t n, tn;
@@ -513,6 +575,45 @@ ugen_do_read(sc, endpt, uio, flag)
}
usbd_free_xfer(xfer);
break;
+ case UE_ISOCHRONOUS:
+ s = splusb();
+ while (sce->cur == sce->fill) {
+ if (flag & IO_NDELAY) {
+ splx(s);
+ return (EWOULDBLOCK);
+ }
+ sce->state |= UGEN_ASLP;
+ DPRINTFN(5, ("ugenread: sleep on %p\n", sc));
+ error = tsleep(sce, PZERO | PCATCH, "ugenri", 0);
+ DPRINTFN(5, ("ugenread: woke, error=%d\n", error));
+ if (sc->sc_dying)
+ error = EIO;
+ if (error) {
+ sce->state &= ~UGEN_ASLP;
+ break;
+ }
+ }
+
+ while (sce->cur != sce->fill && uio->uio_resid > 0 && !error) {
+ if(sce->fill > sce->cur)
+ n = min(sce->fill - sce->cur, uio->uio_resid);
+ else
+ n = min(sce->limit - sce->cur, uio->uio_resid);
+
+ DPRINTFN(5, ("ugenread: isoc got %d chars\n", n));
+
+ /* Copy the data to the user process. */
+ error = uiomove(sce->cur, n, uio);
+ if (error)
+ break;
+ sce->cur += n;
+ if(sce->cur >= sce->limit)
+ sce->cur = sce->ibuf;
+ }
+ splx(s);
+ break;
+
+
default:
return (ENXIO);
}
@@ -520,10 +621,7 @@ ugen_do_read(sc, endpt, uio, flag)
}
int
-ugenread(dev, uio, flag)
- dev_t dev;
- struct uio *uio;
- int flag;
+ugenread(dev_t dev, struct uio *uio, int flag)
{
int endpt = UGENENDPOINT(dev);
struct ugen_softc *sc;
@@ -539,11 +637,7 @@ ugenread(dev, uio, flag)
}
Static int
-ugen_do_write(sc, endpt, uio, flag)
- struct ugen_softc *sc;
- int endpt;
- struct uio *uio;
- int flag;
+ugen_do_write(struct ugen_softc *sc, int endpt, struct uio *uio, int flag)
{
struct ugen_endpoint *sce = &sc->sc_endpoints[endpt][OUT];
u_int32_t n;
@@ -602,10 +696,7 @@ ugen_do_write(sc, endpt, uio, flag)
}
int
-ugenwrite(dev, uio, flag)
- dev_t dev;
- struct uio *uio;
- int flag;
+ugenwrite(dev_t dev, struct uio *uio, int flag)
{
int endpt = UGENENDPOINT(dev);
struct ugen_softc *sc;
@@ -622,9 +713,7 @@ ugenwrite(dev, uio, flag)
#if defined(__NetBSD__) || defined(__OpenBSD__)
int
-ugen_activate(self, act)
- device_ptr_t self;
- enum devact act;
+ugen_activate(device_ptr_t self, enum devact act)
{
struct ugen_softc *sc = (struct ugen_softc *)self;
@@ -695,10 +784,7 @@ USB_DETACH(ugen)
}
Static void
-ugenintr(xfer, addr, status)
- usbd_xfer_handle xfer;
- usbd_private_handle addr;
- usbd_status status;
+ugenintr(usbd_xfer_handle xfer, usbd_private_handle addr, usbd_status status)
{
struct ugen_endpoint *sce = addr;
/*struct ugen_softc *sc = sce->sc;*/
@@ -732,10 +818,56 @@ ugenintr(xfer, addr, status)
selwakeup(&sce->rsel);
}
+Static void
+ugen_isoc_rintr(usbd_xfer_handle xfer, usbd_private_handle addr,
+ usbd_status status)
+{
+ struct isoreq *req = addr;
+ struct ugen_endpoint *sce = req->sce;
+ u_int32_t count, n;
+
+ /* Return if we are aborting. */
+ if (status == USBD_CANCELLED)
+ return;
+
+ usbd_get_xfer_status(xfer, NULL, NULL, &count, NULL);
+ DPRINTFN(5,("ugen_isoc_rintr: xfer %d, count=%d\n", req - sce->isoreqs,
+ count));
+
+ /* throw away oldest input if the buffer is full */
+ if(sce->fill < sce->cur && sce->cur <= sce->fill + count) {
+ sce->cur += count;
+ if(sce->cur >= sce->limit)
+ sce->cur = sce->ibuf + (sce->limit - sce->cur);
+ DPRINTFN(5, ("ugen_isoc_rintr: throwing away %d bytes\n",
+ 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;
+ }
+
+ usbd_setup_isoc_xfer(xfer, sce->pipeh, req, req->sizes, UGEN_NISORFRMS,
+ USBD_NO_COPY, ugen_isoc_rintr);
+ (void)usbd_transfer(xfer);
+
+ if (sce->state & UGEN_ASLP) {
+ sce->state &= ~UGEN_ASLP;
+ DPRINTFN(5, ("ugen_isoc_rintr: waking %p\n", sce));
+ wakeup(sce);
+ }
+ selwakeup(&sce->rsel);
+}
+
Static usbd_status
-ugen_set_interface(sc, ifaceidx, altno)
- struct ugen_softc *sc;
- int ifaceidx, altno;
+ugen_set_interface(struct ugen_softc *sc, int ifaceidx, int altno)
{
usbd_interface_handle iface;
usb_endpoint_descriptor_t *ed;
@@ -791,10 +923,7 @@ ugen_set_interface(sc, ifaceidx, altno)
/* Retrieve a complete descriptor for a certain device and index. */
Static usb_config_descriptor_t *
-ugen_get_cdesc(sc, index, lenp)
- struct ugen_softc *sc;
- int index;
- int *lenp;
+ugen_get_cdesc(struct ugen_softc *sc, int index, int *lenp)
{
usb_config_descriptor_t *cdesc, *tdesc, cdescr;
int len;
@@ -827,9 +956,7 @@ ugen_get_cdesc(sc, index, lenp)
}
Static int
-ugen_get_alt_index(sc, ifaceidx)
- struct ugen_softc *sc;
- int ifaceidx;
+ugen_get_alt_index(struct ugen_softc *sc, int ifaceidx)
{
usbd_interface_handle iface;
usbd_status err;
@@ -841,13 +968,8 @@ ugen_get_alt_index(sc, ifaceidx)
}
Static int
-ugen_do_ioctl(sc, endpt, cmd, addr, flag, p)
- struct ugen_softc *sc;
- int endpt;
- u_long cmd;
- caddr_t addr;
- int flag;
- struct proc *p;
+ugen_do_ioctl(struct ugen_softc *sc, int endpt, u_long cmd,
+ caddr_t addr, int flag, struct proc *p)
{
struct ugen_endpoint *sce;
usbd_status err;
@@ -1113,12 +1235,7 @@ ugen_do_ioctl(sc, endpt, cmd, addr, flag, p)
}
int
-ugenioctl(dev, cmd, addr, flag, p)
- dev_t dev;
- u_long cmd;
- caddr_t addr;
- int flag;
- struct proc *p;
+ugenioctl(dev_t dev, u_long cmd, caddr_t addr, int flag, struct proc *p)
{
int endpt = UGENENDPOINT(dev);
struct ugen_softc *sc;
@@ -1134,10 +1251,7 @@ ugenioctl(dev, cmd, addr, flag, p)
}
int
-ugenpoll(dev, events, p)
- dev_t dev;
- int events;
- struct proc *p;
+ugenpoll(dev_t dev, int events, struct proc *p)
{
struct ugen_softc *sc;
struct ugen_endpoint *sce;
@@ -1173,6 +1287,14 @@ ugenpoll(dev, events, p)
selrecord(p, &sce->rsel);
}
break;
+ case UE_ISOCHRONOUS:
+ if (events & (POLLIN | POLLRDNORM)) {
+ if (sce->cur != sce->fill)
+ revents |= events & (POLLIN | POLLRDNORM);
+ else
+ selrecord(p, &sce->rsel);
+ }
+ break;
case UE_BULK:
/*
* We have no easy way of determining if a read will
diff --git a/sys/dev/usb/uhci.c b/sys/dev/usb/uhci.c
index daeeac9e198..0e003af212e 100644
--- a/sys/dev/usb/uhci.c
+++ b/sys/dev/usb/uhci.c
@@ -1,5 +1,5 @@
-/* $OpenBSD: uhci.c,v 1.14 2000/09/06 22:42:10 rahnds Exp $ */
-/* $NetBSD: uhci.c,v 1.110 2000/04/14 14:11:36 augustss Exp $ */
+/* $OpenBSD: uhci.c,v 1.15 2000/11/08 18:10:38 aaron Exp $ */
+/* $NetBSD: uhci.c,v 1.125 2000/09/23 21:00:10 augustss Exp $ */
/* $FreeBSD: src/sys/dev/usb/uhci.c,v 1.33 1999/11/17 22:33:41 n_hibma Exp $ */
/*
@@ -79,6 +79,9 @@
#include <dev/usb/uhcireg.h>
#include <dev/usb/uhcivar.h>
+/* Use bandwidth reclamation for control transfers. Some devices choke on it. */
+/*#define UHCI_CTL_LOOP */
+
#if defined(__FreeBSD__)
#include <machine/clock.h>
@@ -98,11 +101,29 @@ uhci_softc_t *thesc;
#define DPRINTF(x) if (uhcidebug) printf x
#define DPRINTFN(n,x) if (uhcidebug>(n)) printf x
int uhcidebug = 0;
+int uhcinoloop = 0;
+#ifndef __NetBSD__
+#define bitmask_snprintf(q,f,b,l) snprintf((b), (l), "%b", (q), (f))
+#endif
#else
#define DPRINTF(x)
#define DPRINTFN(n,x)
#endif
+/*
+ * The UHCI controller is little endian, so on big endian machines
+ * the data strored in memory needs to be swapped.
+ */
+#if defined(__FreeBSD__) || defined(__OpenBSD__)
+#if BYTE_ORDER == BIG_ENDIAN
+#define htole32(x) (bswap32(x))
+#define le32toh(x) (bswap32(x))
+#else
+#define htole32(x) (x)
+#define le32toh(x) (x)
+#endif
+#endif
+
struct uhci_pipe {
struct usbd_pipe pipe;
int nexttoggle;
@@ -138,122 +159,127 @@ struct uhci_pipe {
} u;
};
-Static void uhci_busreset __P((uhci_softc_t *));
-Static void uhci_shutdown __P((void *v));
-Static void uhci_power __P((int, void *));
-Static usbd_status uhci_run __P((uhci_softc_t *, int run));
-Static uhci_soft_td_t *uhci_alloc_std __P((uhci_softc_t *));
-Static void uhci_free_std __P((uhci_softc_t *, uhci_soft_td_t *));
-Static uhci_soft_qh_t *uhci_alloc_sqh __P((uhci_softc_t *));
-Static void uhci_free_sqh __P((uhci_softc_t *, uhci_soft_qh_t *));
+Static void uhci_busreset(uhci_softc_t *);
+Static void uhci_shutdown(void *v);
+Static void uhci_power(int, void *);
+Static usbd_status uhci_run(uhci_softc_t *, int run);
+Static uhci_soft_td_t *uhci_alloc_std(uhci_softc_t *);
+Static void uhci_free_std(uhci_softc_t *, uhci_soft_td_t *);
+Static uhci_soft_qh_t *uhci_alloc_sqh(uhci_softc_t *);
+Static void uhci_free_sqh(uhci_softc_t *, uhci_soft_qh_t *);
#if 0
-Static void uhci_enter_ctl_q __P((uhci_softc_t *, uhci_soft_qh_t *,
- uhci_intr_info_t *));
-Static void uhci_exit_ctl_q __P((uhci_softc_t *, uhci_soft_qh_t *));
+Static void uhci_enter_ctl_q(uhci_softc_t *, uhci_soft_qh_t *,
+ uhci_intr_info_t *);
+Static void uhci_exit_ctl_q(uhci_softc_t *, uhci_soft_qh_t *);
#endif
-Static void uhci_free_std_chain __P((uhci_softc_t *,
- uhci_soft_td_t *, uhci_soft_td_t *));
-Static usbd_status uhci_alloc_std_chain __P((struct uhci_pipe *,
+Static void uhci_free_std_chain(uhci_softc_t *,
+ uhci_soft_td_t *, uhci_soft_td_t *);
+Static usbd_status uhci_alloc_std_chain(struct uhci_pipe *,
uhci_softc_t *, int, int, u_int16_t, usb_dma_t *,
- uhci_soft_td_t **, uhci_soft_td_t **));
-Static void uhci_poll_hub __P((void *));
-Static void uhci_waitintr __P((uhci_softc_t *,
- usbd_xfer_handle));
-Static void uhci_check_intr __P((uhci_softc_t *,
- uhci_intr_info_t *));
-Static void uhci_idone __P((uhci_intr_info_t *));
-
-Static void uhci_abort_xfer __P((usbd_xfer_handle,
- usbd_status status));
-
-Static void uhci_timeout __P((void *));
-Static void uhci_add_ctrl __P((uhci_softc_t *, uhci_soft_qh_t *));
-Static void uhci_add_bulk __P((uhci_softc_t *, uhci_soft_qh_t *));
-Static void uhci_remove_ctrl __P((uhci_softc_t *,uhci_soft_qh_t *));
-Static void uhci_remove_bulk __P((uhci_softc_t *,uhci_soft_qh_t *));
-Static int uhci_str __P((usb_string_descriptor_t *, int, char *));
-
-Static usbd_status uhci_setup_isoc __P((usbd_pipe_handle pipe));
-Static void uhci_device_isoc_enter __P((usbd_xfer_handle));
-
-Static usbd_status uhci_allocm __P((struct usbd_bus *, usb_dma_t *,
- u_int32_t));
-Static void uhci_freem __P((struct usbd_bus *, usb_dma_t *));
-
-Static usbd_xfer_handle uhci_allocx __P((struct usbd_bus *));
-Static void uhci_freex __P((struct usbd_bus *, usbd_xfer_handle));
-
-Static usbd_status uhci_device_ctrl_transfer __P((usbd_xfer_handle));
-Static usbd_status uhci_device_ctrl_start __P((usbd_xfer_handle));
-Static void uhci_device_ctrl_abort __P((usbd_xfer_handle));
-Static void uhci_device_ctrl_close __P((usbd_pipe_handle));
-Static void uhci_device_ctrl_done __P((usbd_xfer_handle));
-
-Static usbd_status uhci_device_intr_transfer __P((usbd_xfer_handle));
-Static usbd_status uhci_device_intr_start __P((usbd_xfer_handle));
-Static void uhci_device_intr_abort __P((usbd_xfer_handle));
-Static void uhci_device_intr_close __P((usbd_pipe_handle));
-Static void uhci_device_intr_done __P((usbd_xfer_handle));
-
-Static usbd_status uhci_device_bulk_transfer __P((usbd_xfer_handle));
-Static usbd_status uhci_device_bulk_start __P((usbd_xfer_handle));
-Static void uhci_device_bulk_abort __P((usbd_xfer_handle));
-Static void uhci_device_bulk_close __P((usbd_pipe_handle));
-Static void uhci_device_bulk_done __P((usbd_xfer_handle));
-
-Static usbd_status uhci_device_isoc_transfer __P((usbd_xfer_handle));
-Static usbd_status uhci_device_isoc_start __P((usbd_xfer_handle));
-Static void uhci_device_isoc_abort __P((usbd_xfer_handle));
-Static void uhci_device_isoc_close __P((usbd_pipe_handle));
-Static void uhci_device_isoc_done __P((usbd_xfer_handle));
-
-Static usbd_status uhci_root_ctrl_transfer __P((usbd_xfer_handle));
-Static usbd_status uhci_root_ctrl_start __P((usbd_xfer_handle));
-Static void uhci_root_ctrl_abort __P((usbd_xfer_handle));
-Static void uhci_root_ctrl_close __P((usbd_pipe_handle));
-Static void uhci_root_ctrl_done __P((usbd_xfer_handle));
-
-Static usbd_status uhci_root_intr_transfer __P((usbd_xfer_handle));
-Static usbd_status uhci_root_intr_start __P((usbd_xfer_handle));
-Static void uhci_root_intr_abort __P((usbd_xfer_handle));
-Static void uhci_root_intr_close __P((usbd_pipe_handle));
-Static void uhci_root_intr_done __P((usbd_xfer_handle));
-
-Static usbd_status uhci_open __P((usbd_pipe_handle));
-Static void uhci_poll __P((struct usbd_bus *));
-Static void uhci_softintr __P((struct usbd_bus *));
-
-Static usbd_status uhci_device_request __P((usbd_xfer_handle xfer));
-
-Static void uhci_add_intr __P((uhci_softc_t *, uhci_soft_qh_t *));
-Static void uhci_remove_intr __P((uhci_softc_t*, uhci_soft_qh_t*));
-Static usbd_status uhci_device_setintr __P((uhci_softc_t *sc,
- struct uhci_pipe *pipe, int ival));
-
-Static void uhci_device_clear_toggle __P((usbd_pipe_handle pipe));
-Static void uhci_noop __P((usbd_pipe_handle pipe));
-
-Static __inline__ uhci_soft_qh_t *uhci_find_prev_qh
- __P((uhci_soft_qh_t *, uhci_soft_qh_t *));
+ uhci_soft_td_t **, uhci_soft_td_t **);
+Static void uhci_poll_hub(void *);
+Static void uhci_waitintr(uhci_softc_t *, usbd_xfer_handle);
+Static void uhci_check_intr(uhci_softc_t *, uhci_intr_info_t *);
+Static void uhci_idone(uhci_intr_info_t *);
+
+Static void uhci_abort_xfer(usbd_xfer_handle, usbd_status status);
+
+Static void uhci_timeout(void *);
+Static void uhci_add_ls_ctrl(uhci_softc_t *, uhci_soft_qh_t *);
+Static void uhci_add_hs_ctrl(uhci_softc_t *, uhci_soft_qh_t *);
+Static void uhci_add_bulk(uhci_softc_t *, uhci_soft_qh_t *);
+Static void uhci_remove_ls_ctrl(uhci_softc_t *,uhci_soft_qh_t *);
+Static void uhci_remove_hs_ctrl(uhci_softc_t *,uhci_soft_qh_t *);
+Static void uhci_remove_bulk(uhci_softc_t *,uhci_soft_qh_t *);
+Static int uhci_str(usb_string_descriptor_t *, int, char *);
+Static void uhci_add_loop(uhci_softc_t *sc);
+Static void uhci_rem_loop(uhci_softc_t *sc);
+
+Static usbd_status uhci_setup_isoc(usbd_pipe_handle pipe);
+Static void uhci_device_isoc_enter(usbd_xfer_handle);
+
+Static usbd_status uhci_allocm(struct usbd_bus *, usb_dma_t *, u_int32_t);
+Static void uhci_freem(struct usbd_bus *, usb_dma_t *);
+
+Static usbd_xfer_handle uhci_allocx(struct usbd_bus *);
+Static void uhci_freex(struct usbd_bus *, usbd_xfer_handle);
+
+Static usbd_status uhci_device_ctrl_transfer(usbd_xfer_handle);
+Static usbd_status uhci_device_ctrl_start(usbd_xfer_handle);
+Static void uhci_device_ctrl_abort(usbd_xfer_handle);
+Static void uhci_device_ctrl_close(usbd_pipe_handle);
+Static void uhci_device_ctrl_done(usbd_xfer_handle);
+
+Static usbd_status uhci_device_intr_transfer(usbd_xfer_handle);
+Static usbd_status uhci_device_intr_start(usbd_xfer_handle);
+Static void uhci_device_intr_abort(usbd_xfer_handle);
+Static void uhci_device_intr_close(usbd_pipe_handle);
+Static void uhci_device_intr_done(usbd_xfer_handle);
+
+Static usbd_status uhci_device_bulk_transfer(usbd_xfer_handle);
+Static usbd_status uhci_device_bulk_start(usbd_xfer_handle);
+Static void uhci_device_bulk_abort(usbd_xfer_handle);
+Static void uhci_device_bulk_close(usbd_pipe_handle);
+Static void uhci_device_bulk_done(usbd_xfer_handle);
+
+Static usbd_status uhci_device_isoc_transfer(usbd_xfer_handle);
+Static usbd_status uhci_device_isoc_start(usbd_xfer_handle);
+Static void uhci_device_isoc_abort(usbd_xfer_handle);
+Static void uhci_device_isoc_close(usbd_pipe_handle);
+Static void uhci_device_isoc_done(usbd_xfer_handle);
+
+Static usbd_status uhci_root_ctrl_transfer(usbd_xfer_handle);
+Static usbd_status uhci_root_ctrl_start(usbd_xfer_handle);
+Static void uhci_root_ctrl_abort(usbd_xfer_handle);
+Static void uhci_root_ctrl_close(usbd_pipe_handle);
+Static void uhci_root_ctrl_done(usbd_xfer_handle);
+
+Static usbd_status uhci_root_intr_transfer(usbd_xfer_handle);
+Static usbd_status uhci_root_intr_start(usbd_xfer_handle);
+Static void uhci_root_intr_abort(usbd_xfer_handle);
+Static void uhci_root_intr_close(usbd_pipe_handle);
+Static void uhci_root_intr_done(usbd_xfer_handle);
+
+Static usbd_status uhci_open(usbd_pipe_handle);
+Static void uhci_poll(struct usbd_bus *);
+Static void uhci_softintr(struct usbd_bus *);
+
+Static usbd_status uhci_device_request(usbd_xfer_handle xfer);
+
+Static void uhci_add_intr(uhci_softc_t *, uhci_soft_qh_t *);
+Static void uhci_remove_intr(uhci_softc_t*, uhci_soft_qh_t*);
+Static usbd_status uhci_device_setintr(uhci_softc_t *sc,
+ struct uhci_pipe *pipe, int ival);
+
+Static void uhci_device_clear_toggle(usbd_pipe_handle pipe);
+Static void uhci_noop(usbd_pipe_handle pipe);
+
+Static __inline__ uhci_soft_qh_t *uhci_find_prev_qh(uhci_soft_qh_t *,
+ uhci_soft_qh_t *);
#ifdef UHCI_DEBUG
-Static void uhci_dump_all __P((uhci_softc_t *));
-Static void uhci_dumpregs __P((uhci_softc_t *));
-Static void uhci_dump_qhs __P((uhci_soft_qh_t *));
-Static void uhci_dump_qh __P((uhci_soft_qh_t *));
-Static void uhci_dump_tds __P((uhci_soft_td_t *));
-Static void uhci_dump_td __P((uhci_soft_td_t *));
-Static void uhci_dump_ii __P((uhci_intr_info_t *ii));
-Static void uhci_dump __P((void));
-#endif
-
-#define UWRITE1(sc, r, x) bus_space_write_1((sc)->iot, (sc)->ioh, (r), (x))
-#define UWRITE2(sc, r, x) bus_space_write_2((sc)->iot, (sc)->ioh, (r), (x))
-#define UWRITE4(sc, r, x) bus_space_write_4((sc)->iot, (sc)->ioh, (r), (x))
-#define UREAD1(sc, r) bus_space_read_1((sc)->iot, (sc)->ioh, (r))
-#define UREAD2(sc, r) bus_space_read_2((sc)->iot, (sc)->ioh, (r))
-#define UREAD4(sc, r) bus_space_read_4((sc)->iot, (sc)->ioh, (r))
+Static void uhci_dump_all(uhci_softc_t *);
+Static void uhci_dumpregs(uhci_softc_t *);
+Static void uhci_dump_qhs(uhci_soft_qh_t *);
+Static void uhci_dump_qh(uhci_soft_qh_t *);
+Static void uhci_dump_tds(uhci_soft_td_t *);
+Static void uhci_dump_td(uhci_soft_td_t *);
+Static void uhci_dump_ii(uhci_intr_info_t *ii);
+void uhci_dump(void);
+#endif
+
+#define UBARR(sc) bus_space_barrier((sc)->iot, (sc)->ioh, 0, (sc)->sc_size, \
+ BUS_SPACE_BARRIER_READ|BUS_SPACE_BARRIER_WRITE)
+#define UWRITE1(sc, r, x) \
+ do { UBARR(sc); bus_space_write_1((sc)->iot, (sc)->ioh, (r), (x)); } while (0)
+#define UWRITE2(sc, r, x) \
+ do { UBARR(sc); bus_space_write_2((sc)->iot, (sc)->ioh, (r), (x)); } while (0)
+#define UWRITE4(sc, r, x) \
+ do { UBARR(sc); bus_space_write_4((sc)->iot, (sc)->ioh, (r), (x)); } while (0)
+#define UREAD1(sc, r) (UBARR(sc), bus_space_read_1((sc)->iot, (sc)->ioh, (r)))
+#define UREAD2(sc, r) (UBARR(sc), bus_space_read_2((sc)->iot, (sc)->ioh, (r)))
+#define UREAD4(sc, r) (UBARR(sc), bus_space_read_4((sc)->iot, (sc)->ioh, (r)))
#define UHCICMD(sc, cmd) UWRITE2(sc, UHCI_CMD, cmd)
#define UHCISTS(sc) UREAD2(sc, UHCI_STS)
@@ -334,8 +360,7 @@ struct usbd_pipe_methods uhci_device_isoc_methods = {
LIST_REMOVE((ii), list)
Static __inline__ uhci_soft_qh_t *
-uhci_find_prev_qh(pqh, sqh)
- uhci_soft_qh_t *pqh, *sqh;
+uhci_find_prev_qh(uhci_soft_qh_t *pqh, uhci_soft_qh_t *sqh)
{
DPRINTFN(15,("uhci_find_prev_qh: pqh=%p sqh=%p\n", pqh, sqh));
@@ -351,8 +376,7 @@ uhci_find_prev_qh(pqh, sqh)
}
void
-uhci_busreset(sc)
- uhci_softc_t *sc;
+uhci_busreset(uhci_softc_t *sc)
{
UHCICMD(sc, UHCI_CMD_GRESET); /* global reset */
usb_delay_ms(&sc->sc_bus, USB_BUS_RESET_DELAY); /* wait a little */
@@ -360,12 +384,11 @@ uhci_busreset(sc)
}
usbd_status
-uhci_init(sc)
- uhci_softc_t *sc;
+uhci_init(uhci_softc_t *sc)
{
usbd_status err;
int i, j;
- uhci_soft_qh_t *csqh, *bsqh, *sqh;
+ uhci_soft_qh_t *clsqh, *chsqh, *bsqh, *sqh, *lsqh;
uhci_soft_td_t *std;
DPRINTFN(1,("uhci_init: start\n"));
@@ -392,22 +415,59 @@ uhci_init(sc)
UWRITE2(sc, UHCI_FRNUM, 0); /* set frame number to 0 */
UWRITE4(sc, UHCI_FLBASEADDR, DMAADDR(&sc->sc_dma)); /* set frame list*/
+ /*
+ * Allocate a TD, inactive, that hangs from the last QH.
+ * This is to avoid a bug in the PIIX that makes it run berserk
+ * otherwise.
+ */
+ std = uhci_alloc_std(sc);
+ if (std == NULL)
+ return (USBD_NOMEM);
+ std->link.std = NULL;
+ std->td.td_link = htole32(UHCI_PTR_T);
+ std->td.td_status = htole32(0); /* inactive */
+ std->td.td_token = htole32(0);
+ std->td.td_buffer = htole32(0);
+
+ /* Allocate the dummy QH marking the end and used for looping the QHs.*/
+ lsqh = uhci_alloc_sqh(sc);
+ if (lsqh == NULL)
+ return (USBD_NOMEM);
+ lsqh->hlink = NULL;
+ lsqh->qh.qh_hlink = htole32(UHCI_PTR_T); /* end of QH chain */
+ lsqh->elink = std;
+ lsqh->qh.qh_elink = htole32(std->physaddr | UHCI_PTR_TD);
+ sc->sc_last_qh = lsqh;
+
/* Allocate the dummy QH where bulk traffic will be queued. */
bsqh = uhci_alloc_sqh(sc);
if (bsqh == NULL)
return (USBD_NOMEM);
- bsqh->qh.qh_hlink = htole32(UHCI_PTR_T); /* end of QH chain */
+ bsqh->hlink = lsqh;
+ bsqh->qh.qh_hlink = htole32(lsqh->physaddr | UHCI_PTR_QH);
+ bsqh->elink = NULL;
bsqh->qh.qh_elink = htole32(UHCI_PTR_T);
sc->sc_bulk_start = sc->sc_bulk_end = bsqh;
- /* Allocate the dummy QH where control traffic will be queued. */
- csqh = uhci_alloc_sqh(sc);
- if (csqh == NULL)
+ /* Allocate dummy QH where high speed control traffic will be queued. */
+ chsqh = uhci_alloc_sqh(sc);
+ if (chsqh == NULL)
+ return (USBD_NOMEM);
+ chsqh->hlink = bsqh;
+ chsqh->qh.qh_hlink = htole32(bsqh->physaddr | UHCI_PTR_QH);
+ chsqh->elink = NULL;
+ chsqh->qh.qh_elink = htole32(UHCI_PTR_T);
+ sc->sc_hctl_start = sc->sc_hctl_end = chsqh;
+
+ /* Allocate dummy QH where control traffic will be queued. */
+ clsqh = uhci_alloc_sqh(sc);
+ if (clsqh == NULL)
return (USBD_NOMEM);
- csqh->hlink = bsqh;
- csqh->qh.qh_hlink = htole32(bsqh->physaddr | UHCI_PTR_Q);
- csqh->qh.qh_elink = htole32(UHCI_PTR_T);
- sc->sc_ctl_start = sc->sc_ctl_end = csqh;
+ clsqh->hlink = bsqh;
+ clsqh->qh.qh_hlink = htole32(chsqh->physaddr | UHCI_PTR_QH);
+ clsqh->elink = NULL;
+ clsqh->qh.qh_elink = htole32(UHCI_PTR_T);
+ sc->sc_lctl_start = sc->sc_lctl_end = clsqh;
/*
* Make all (virtual) frame list pointers point to the interrupt
@@ -420,13 +480,13 @@ uhci_init(sc)
if (std == NULL || sqh == NULL)
return (USBD_NOMEM);
std->link.sqh = sqh;
- std->td.td_link = htole32(sqh->physaddr | UHCI_PTR_Q);
+ std->td.td_link = htole32(sqh->physaddr | UHCI_PTR_QH);
std->td.td_status = htole32(UHCI_TD_IOS); /* iso, inactive */
std->td.td_token = htole32(0);
std->td.td_buffer = htole32(0);
- sqh->hlink = csqh;
- sqh->qh.qh_hlink = htole32(csqh->physaddr | UHCI_PTR_Q);
- sqh->elink = 0;
+ sqh->hlink = clsqh;
+ sqh->qh.qh_hlink = htole32(clsqh->physaddr | UHCI_PTR_QH);
+ sqh->elink = NULL;
sqh->qh.qh_elink = htole32(UHCI_PTR_T);
sc->sc_vframes[i].htd = std;
sc->sc_vframes[i].etd = std;
@@ -465,9 +525,7 @@ uhci_init(sc)
#if defined(__NetBSD__) || defined(__OpenBSD__)
int
-uhci_activate(self, act)
- device_ptr_t self;
- enum devact act;
+uhci_activate(device_ptr_t self, enum devact act)
{
struct uhci_softc *sc = (struct uhci_softc *)self;
int rv = 0;
@@ -486,9 +544,7 @@ uhci_activate(self, act)
}
int
-uhci_detach(sc, flags)
- struct uhci_softc *sc;
- int flags;
+uhci_detach(struct uhci_softc *sc, int flags)
{
usbd_xfer_handle xfer;
int rv = 0;
@@ -520,10 +576,7 @@ uhci_detach(sc, flags)
#endif
usbd_status
-uhci_allocm(bus, dma, size)
- struct usbd_bus *bus;
- usb_dma_t *dma;
- u_int32_t size;
+uhci_allocm(struct usbd_bus *bus, usb_dma_t *dma, u_int32_t size)
{
struct uhci_softc *sc = (struct uhci_softc *)bus;
u_int32_t n;
@@ -554,16 +607,13 @@ uhci_allocm(bus, dma, size)
}
void
-uhci_freem(bus, dma)
- struct usbd_bus *bus;
- usb_dma_t *dma;
+uhci_freem(struct usbd_bus *bus, usb_dma_t *dma)
{
usb_freemem(&((struct uhci_softc *)bus)->sc_bus, dma);
}
usbd_xfer_handle
-uhci_allocx(bus)
- struct usbd_bus *bus;
+uhci_allocx(struct usbd_bus *bus)
{
struct uhci_softc *sc = (struct uhci_softc *)bus;
usbd_xfer_handle xfer;
@@ -594,9 +644,7 @@ uhci_allocx(bus)
}
void
-uhci_freex(bus, xfer)
- struct usbd_bus *bus;
- usbd_xfer_handle xfer;
+uhci_freex(struct usbd_bus *bus, usbd_xfer_handle xfer)
{
struct uhci_softc *sc = (struct uhci_softc *)bus;
@@ -619,8 +667,7 @@ uhci_freex(bus, xfer)
* Shut down the controller when the system is going down.
*/
void
-uhci_shutdown(v)
- void *v;
+uhci_shutdown(void *v)
{
uhci_softc_t *sc = v;
@@ -636,9 +683,7 @@ uhci_shutdown(v)
* are almost suspended anyway.
*/
void
-uhci_power(why, v)
- int why;
- void *v;
+uhci_power(int why, void *v)
{
uhci_softc_t *sc = v;
int cmd;
@@ -706,8 +751,7 @@ uhci_power(why, v)
#ifdef UHCI_DEBUG
Static void
-uhci_dumpregs(sc)
- uhci_softc_t *sc;
+uhci_dumpregs(uhci_softc_t *sc)
{
DPRINTFN(-1,("%s regs: cmd=%04x, sts=%04x, intr=%04x, frnum=%04x, "
"flbase=%08x, sof=%04x, portsc1=%04x, portsc2=%04x\n",
@@ -723,9 +767,10 @@ uhci_dumpregs(sc)
}
void
-uhci_dump_td(p)
- uhci_soft_td_t *p;
+uhci_dump_td(uhci_soft_td_t *p)
{
+ char sbuf[128], sbuf2[128];
+
DPRINTFN(-1,("TD(%p) at %08lx = link=0x%08lx status=0x%08lx "
"token=0x%08lx buffer=0x%08lx\n",
p, (long)p->physaddr,
@@ -733,13 +778,16 @@ uhci_dump_td(p)
(long)le32toh(p->td.td_status),
(long)le32toh(p->td.td_token),
(long)le32toh(p->td.td_buffer)));
- DPRINTFN(-1,(" %b %b,errcnt=%d,actlen=%d pid=%02x,addr=%d,endpt=%d,"
- "D=%d,maxlen=%d\n",
- (int)le32toh(p->td.td_link),
- "\20\1T\2Q\3VF",
- (int)le32toh(p->td.td_status),
- "\20\22BITSTUFF\23CRCTO\24NAK\25BABBLE\26DBUFFER\27"
- "STALLED\30ACTIVE\31IOC\32ISO\33LS\36SPD",
+
+ bitmask_snprintf((int)le32toh(p->td.td_link), "\20\1T\2Q\3VF",
+ sbuf, sizeof(sbuf));
+ bitmask_snprintf((int)le32toh(p->td.td_status),
+ "\20\22BITSTUFF\23CRCTO\24NAK\25BABBLE\26DBUFFER\27"
+ "STALLED\30ACTIVE\31IOC\32ISO\33LS\36SPD",
+ sbuf2, sizeof(sbuf2));
+
+ DPRINTFN(-1,(" %s %s,errcnt=%d,actlen=%d pid=%02x,addr=%d,endpt=%d,"
+ "D=%d,maxlen=%d\n", sbuf, sbuf2,
UHCI_TD_GET_ERRCNT(le32toh(p->td.td_status)),
UHCI_TD_GET_ACTLEN(le32toh(p->td.td_status)),
UHCI_TD_GET_PID(le32toh(p->td.td_token)),
@@ -750,8 +798,7 @@ uhci_dump_td(p)
}
void
-uhci_dump_qh(sqh)
- uhci_soft_qh_t *sqh;
+uhci_dump_qh(uhci_soft_qh_t *sqh)
{
DPRINTFN(-1,("QH(%p) at %08x: hlink=%08x elink=%08x\n", sqh,
(int)sqh->physaddr, le32toh(sqh->qh.qh_hlink),
@@ -761,26 +808,24 @@ uhci_dump_qh(sqh)
#if 1
void
-uhci_dump()
+uhci_dump(void)
{
uhci_dump_all(thesc);
}
#endif
void
-uhci_dump_all(sc)
- uhci_softc_t *sc;
+uhci_dump_all(uhci_softc_t *sc)
{
uhci_dumpregs(sc);
printf("intrs=%d\n", sc->sc_bus.no_intrs);
/*printf("framelist[i].link = %08x\n", sc->sc_framelist[0].link);*/
- uhci_dump_qh(sc->sc_ctl_start);
+ uhci_dump_qh(sc->sc_lctl_start);
}
void
-uhci_dump_qhs(sqh)
- uhci_soft_qh_t *sqh;
+uhci_dump_qhs(uhci_soft_qh_t *sqh)
{
uhci_dump_qh(sqh);
@@ -811,8 +856,7 @@ uhci_dump_qhs(sqh)
}
void
-uhci_dump_tds(std)
- uhci_soft_td_t *std;
+uhci_dump_tds(uhci_soft_td_t *std)
{
uhci_soft_td_t *td;
@@ -831,8 +875,7 @@ uhci_dump_tds(std)
}
Static void
-uhci_dump_ii(ii)
- uhci_intr_info_t *ii;
+uhci_dump_ii(uhci_intr_info_t *ii)
{
usbd_pipe_handle pipe;
usb_endpoint_descriptor_t *ed;
@@ -869,10 +912,9 @@ uhci_dump_ii(ii)
#undef DONE
}
-void uhci_dump_iis(struct uhci_softc *);
+void uhci_dump_iis(struct uhci_softc *sc);
void
-uhci_dump_iis(sc)
- struct uhci_softc *sc;
+uhci_dump_iis(struct uhci_softc *sc)
{
uhci_intr_info_t *ii;
@@ -882,7 +924,7 @@ uhci_dump_iis(sc)
}
void iidump(void);
-void iidump() { uhci_dump_iis(thesc); }
+void iidump(void) { uhci_dump_iis(thesc); }
#endif
@@ -891,8 +933,7 @@ void iidump() { uhci_dump_iis(thesc); }
* from the root controller interrupt pipe for port status change.
*/
void
-uhci_poll_hub(addr)
- void *addr;
+uhci_poll_hub(void *addr)
{
usbd_xfer_handle xfer = addr;
usbd_pipe_handle pipe = xfer->pipe;
@@ -924,59 +965,142 @@ uhci_poll_hub(addr)
}
void
-uhci_root_intr_done(xfer)
- usbd_xfer_handle xfer;
+uhci_root_intr_done(usbd_xfer_handle xfer)
{
}
void
-uhci_root_ctrl_done(xfer)
- usbd_xfer_handle xfer;
+uhci_root_ctrl_done(usbd_xfer_handle xfer)
{
}
-/* Add control QH, called at splusb(). */
+/*
+ * Let the last QH loop back to the high speed control transfer QH.
+ * This is what intel calls "bandwidth reclamation" and improves
+ * USB performance a lot for some devices.
+ * If we are already looping, just count it.
+ */
void
-uhci_add_ctrl(sc, sqh)
- uhci_softc_t *sc;
- uhci_soft_qh_t *sqh;
+uhci_add_loop(uhci_softc_t *sc) {
+#ifdef UHCI_DEBUG
+ if (uhcinoloop)
+ return;
+#endif
+ if (++sc->sc_loops == 1) {
+ DPRINTFN(5,("uhci_start_loop: add\n"));
+ /* Note, we don't loop back the soft pointer. */
+ sc->sc_last_qh->qh.qh_hlink =
+ htole32(sc->sc_hctl_start->physaddr | UHCI_PTR_QH);
+ }
+}
+
+void
+uhci_rem_loop(uhci_softc_t *sc) {
+#ifdef UHCI_DEBUG
+ if (uhcinoloop)
+ return;
+#endif
+ if (--sc->sc_loops == 0) {
+ DPRINTFN(5,("uhci_end_loop: remove\n"));
+ sc->sc_last_qh->qh.qh_hlink = htole32(UHCI_PTR_T);
+ }
+}
+
+/* Add high speed control QH, called at splusb(). */
+void
+uhci_add_hs_ctrl(uhci_softc_t *sc, uhci_soft_qh_t *sqh)
{
uhci_soft_qh_t *eqh;
SPLUSBCHECK;
DPRINTFN(10, ("uhci_add_ctrl: sqh=%p\n", sqh));
- eqh = sc->sc_ctl_end;
+ eqh = sc->sc_hctl_end;
sqh->hlink = eqh->hlink;
sqh->qh.qh_hlink = eqh->qh.qh_hlink;
eqh->hlink = sqh;
- eqh->qh.qh_hlink = htole32(sqh->physaddr | UHCI_PTR_Q);
- sc->sc_ctl_end = sqh;
+ eqh->qh.qh_hlink = htole32(sqh->physaddr | UHCI_PTR_QH);
+ sc->sc_hctl_end = sqh;
+#ifdef UHCI_CTL_LOOP
+ uhci_add_loop(sc);
+#endif
}
-/* Remove control QH, called at splusb(). */
+/* Remove high speed control QH, called at splusb(). */
void
-uhci_remove_ctrl(sc, sqh)
- uhci_softc_t *sc;
- uhci_soft_qh_t *sqh;
+uhci_remove_hs_ctrl(uhci_softc_t *sc, uhci_soft_qh_t *sqh)
+{
+ uhci_soft_qh_t *pqh;
+
+ SPLUSBCHECK;
+
+ DPRINTFN(10, ("uhci_remove_hs_ctrl: sqh=%p\n", sqh));
+#ifdef UHCI_CTL_LOOP
+ uhci_rem_loop(sc);
+#endif
+ /*
+ * The T bit should be set in the elink of the QH so that the HC
+ * doesn't follow the pointer. This condition may fail if the
+ * the transferred packet was short so that the QH still points
+ * at the last used TD.
+ * In this case we set the T bit and wait a little for the HC
+ * to stop looking at the TD.
+ */
+ if (!(sqh->qh.qh_elink & htole32(UHCI_PTR_T))) {
+ sqh->qh.qh_elink = htole32(UHCI_PTR_T);
+ delay(UHCI_QH_REMOVE_DELAY);
+ }
+
+ pqh = uhci_find_prev_qh(sc->sc_hctl_start, sqh);
+ pqh->hlink = sqh->hlink;
+ pqh->qh.qh_hlink = sqh->qh.qh_hlink;
+ delay(UHCI_QH_REMOVE_DELAY);
+ if (sc->sc_hctl_end == sqh)
+ sc->sc_hctl_end = pqh;
+}
+
+/* Add low speed control QH, called at splusb(). */
+void
+uhci_add_ls_ctrl(uhci_softc_t *sc, uhci_soft_qh_t *sqh)
+{
+ uhci_soft_qh_t *eqh;
+
+ SPLUSBCHECK;
+
+ DPRINTFN(10, ("uhci_add_ls_ctrl: sqh=%p\n", sqh));
+ eqh = sc->sc_lctl_end;
+ sqh->hlink = eqh->hlink;
+ sqh->qh.qh_hlink = eqh->qh.qh_hlink;
+ eqh->hlink = sqh;
+ eqh->qh.qh_hlink = htole32(sqh->physaddr | UHCI_PTR_QH);
+ sc->sc_lctl_end = sqh;
+}
+
+/* Remove low speed control QH, called at splusb(). */
+void
+uhci_remove_ls_ctrl(uhci_softc_t *sc, uhci_soft_qh_t *sqh)
{
uhci_soft_qh_t *pqh;
SPLUSBCHECK;
- DPRINTFN(10, ("uhci_remove_ctrl: sqh=%p\n", sqh));
- pqh = uhci_find_prev_qh(sc->sc_ctl_start, sqh);
+ DPRINTFN(10, ("uhci_remove_ls_ctrl: sqh=%p\n", sqh));
+ /* See comment in uhci_remove_hs_ctrl() */
+ if (!(sqh->qh.qh_elink & htole32(UHCI_PTR_T))) {
+ sqh->qh.qh_elink = htole32(UHCI_PTR_T);
+ delay(UHCI_QH_REMOVE_DELAY);
+ }
+ pqh = uhci_find_prev_qh(sc->sc_lctl_start, sqh);
pqh->hlink = sqh->hlink;
pqh->qh.qh_hlink = sqh->qh.qh_hlink;
- if (sc->sc_ctl_end == sqh)
- sc->sc_ctl_end = pqh;
+ delay(UHCI_QH_REMOVE_DELAY);
+ if (sc->sc_lctl_end == sqh)
+ sc->sc_lctl_end = pqh;
}
/* Add bulk QH, called at splusb(). */
void
-uhci_add_bulk(sc, sqh)
- uhci_softc_t *sc;
- uhci_soft_qh_t *sqh;
+uhci_add_bulk(uhci_softc_t *sc, uhci_soft_qh_t *sqh)
{
uhci_soft_qh_t *eqh;
@@ -987,31 +1111,36 @@ uhci_add_bulk(sc, sqh)
sqh->hlink = eqh->hlink;
sqh->qh.qh_hlink = eqh->qh.qh_hlink;
eqh->hlink = sqh;
- eqh->qh.qh_hlink = htole32(sqh->physaddr | UHCI_PTR_Q);
+ eqh->qh.qh_hlink = htole32(sqh->physaddr | UHCI_PTR_QH);
sc->sc_bulk_end = sqh;
+ uhci_add_loop(sc);
}
/* Remove bulk QH, called at splusb(). */
void
-uhci_remove_bulk(sc, sqh)
- uhci_softc_t *sc;
- uhci_soft_qh_t *sqh;
+uhci_remove_bulk(uhci_softc_t *sc, uhci_soft_qh_t *sqh)
{
uhci_soft_qh_t *pqh;
SPLUSBCHECK;
DPRINTFN(10, ("uhci_remove_bulk: sqh=%p\n", sqh));
+ uhci_rem_loop(sc);
+ /* See comment in uhci_remove_hs_ctrl() */
+ if (!(sqh->qh.qh_elink & htole32(UHCI_PTR_T))) {
+ sqh->qh.qh_elink = htole32(UHCI_PTR_T);
+ delay(UHCI_QH_REMOVE_DELAY);
+ }
pqh = uhci_find_prev_qh(sc->sc_bulk_start, sqh);
pqh->hlink = sqh->hlink;
pqh->qh.qh_hlink = sqh->qh.qh_hlink;
+ delay(UHCI_QH_REMOVE_DELAY);
if (sc->sc_bulk_end == sqh)
sc->sc_bulk_end = pqh;
}
int
-uhci_intr(arg)
- void *arg;
+uhci_intr(void *arg)
{
uhci_softc_t *sc = arg;
int status;
@@ -1046,7 +1175,9 @@ uhci_intr(arg)
ack |= UHCI_STS_USBEI;
if (status & UHCI_STS_RD) {
ack |= UHCI_STS_RD;
+#ifdef UHCI_DEBUG
printf("%s: resume detect\n", USBDEVNAME(sc->sc_bus.bdev));
+#endif
}
if (status & UHCI_STS_HSE) {
ack |= UHCI_STS_HSE;
@@ -1082,8 +1213,7 @@ uhci_intr(arg)
}
void
-uhci_softintr(bus)
- struct usbd_bus *bus;
+uhci_softintr(struct usbd_bus *bus)
{
uhci_softc_t *sc = (uhci_softc_t *)bus;
uhci_intr_info_t *ii;
@@ -1111,9 +1241,7 @@ uhci_softintr(bus)
/* Check for an interrupt. */
void
-uhci_check_intr(sc, ii)
- uhci_softc_t *sc;
- uhci_intr_info_t *ii;
+uhci_check_intr(uhci_softc_t *sc, uhci_intr_info_t *ii)
{
uhci_soft_td_t *std, *lstd;
u_int32_t status;
@@ -1167,8 +1295,7 @@ uhci_check_intr(sc, ii)
/* Called at splusb() */
void
-uhci_idone(ii)
- uhci_intr_info_t *ii;
+uhci_idone(uhci_intr_info_t *ii)
{
usbd_xfer_handle xfer = ii->xfer;
struct uhci_pipe *upipe = (struct uhci_pipe *)xfer->pipe;
@@ -1258,14 +1385,21 @@ uhci_idone(ii)
actlen, status));
xfer->actlen = actlen;
if (status != 0) {
+#ifdef UHCI_DEBUG
+ char sbuf[128];
+
+ bitmask_snprintf((int)status, "\20\22BITSTUFF\23CRCTO\24NAK\25"
+ "BABBLE\26DBUFFER\27STALLED\30ACTIVE",
+ sbuf, sizeof(sbuf));
+
DPRINTFN((status == UHCI_TD_STALLED)*10,
("uhci_idone: error, addr=%d, endpt=0x%02x, "
- "status 0x%b\n",
+ "status 0x%s\n",
xfer->pipe->device->address,
xfer->pipe->endpoint->edesc->bEndpointAddress,
- (int)status,
- "\20\22BITSTUFF\23CRCTO\24NAK\25BABBLE\26DBUFFER\27"
- "STALLED\30ACTIVE"));
+ sbuf));
+#endif
+
if (status == UHCI_TD_STALLED)
xfer->status = USBD_STALLED;
else
@@ -1280,8 +1414,7 @@ uhci_idone(ii)
* Called when a request does not complete.
*/
void
-uhci_timeout(addr)
- void *addr;
+uhci_timeout(void *addr)
{
uhci_intr_info_t *ii = addr;
@@ -1304,9 +1437,7 @@ uhci_timeout(addr)
* Only used during boot when interrupts are not enabled yet.
*/
void
-uhci_waitintr(sc, xfer)
- uhci_softc_t *sc;
- usbd_xfer_handle xfer;
+uhci_waitintr(uhci_softc_t *sc, usbd_xfer_handle xfer)
{
int timo = xfer->timeout;
uhci_intr_info_t *ii;
@@ -1338,8 +1469,7 @@ uhci_waitintr(sc, xfer)
}
void
-uhci_poll(bus)
- struct usbd_bus *bus;
+uhci_poll(struct usbd_bus *bus)
{
uhci_softc_t *sc = (uhci_softc_t *)bus;
@@ -1349,8 +1479,7 @@ uhci_poll(bus)
#if 0
void
-uhci_reset(sc)
- uhci_softc_t *sc;
+uhci_reset(uhci_softc_t *sc)
{
int n;
@@ -1366,9 +1495,7 @@ uhci_reset(sc)
#endif
usbd_status
-uhci_run(sc, run)
- uhci_softc_t *sc;
- int run;
+uhci_run(uhci_softc_t *sc, int run)
{
int s, n, running;
u_int16_t cmd;
@@ -1410,8 +1537,7 @@ uhci_run(sc, run)
*/
uhci_soft_td_t *
-uhci_alloc_std(sc)
- uhci_softc_t *sc;
+uhci_alloc_std(uhci_softc_t *sc)
{
uhci_soft_td_t *std;
usbd_status err;
@@ -1439,9 +1565,7 @@ uhci_alloc_std(sc)
}
void
-uhci_free_std(sc, std)
- uhci_softc_t *sc;
- uhci_soft_td_t *std;
+uhci_free_std(uhci_softc_t *sc, uhci_soft_td_t *std)
{
#ifdef DIAGNOSTIC
#define TD_IS_FREE 0x12345678
@@ -1456,8 +1580,7 @@ uhci_free_std(sc, std)
}
uhci_soft_qh_t *
-uhci_alloc_sqh(sc)
- uhci_softc_t *sc;
+uhci_alloc_sqh(uhci_softc_t *sc)
{
uhci_soft_qh_t *sqh;
usbd_status err;
@@ -1485,19 +1608,15 @@ uhci_alloc_sqh(sc)
}
void
-uhci_free_sqh(sc, sqh)
- uhci_softc_t *sc;
- uhci_soft_qh_t *sqh;
+uhci_free_sqh(uhci_softc_t *sc, uhci_soft_qh_t *sqh)
{
sqh->hlink = sc->sc_freeqhs;
sc->sc_freeqhs = sqh;
}
void
-uhci_free_std_chain(sc, std, stdend)
- uhci_softc_t *sc;
- uhci_soft_td_t *std;
- uhci_soft_td_t *stdend;
+uhci_free_std_chain(uhci_softc_t *sc, uhci_soft_td_t *std,
+ uhci_soft_td_t *stdend)
{
uhci_soft_td_t *p;
@@ -1508,13 +1627,9 @@ uhci_free_std_chain(sc, std, stdend)
}
usbd_status
-uhci_alloc_std_chain(upipe, sc, len, rd, flags, dma, sp, ep)
- struct uhci_pipe *upipe;
- uhci_softc_t *sc;
- int len, rd;
- u_int16_t flags;
- usb_dma_t *dma;
- uhci_soft_td_t **sp, **ep;
+uhci_alloc_std_chain(struct uhci_pipe *upipe, uhci_softc_t *sc, int len,
+ int rd, u_int16_t flags, usb_dma_t *dma,
+ uhci_soft_td_t **sp, uhci_soft_td_t **ep)
{
uhci_soft_td_t *p, *lastp;
uhci_physaddr_t lastlink;
@@ -1544,7 +1659,7 @@ uhci_alloc_std_chain(upipe, sc, len, rd, flags, dma, sp, ep)
if (ntd % 2 == 0)
tog ^= 1;
upipe->nexttoggle = tog ^ 1;
- lastp = 0;
+ lastp = NULL;
lastlink = UHCI_PTR_T;
ntd--;
status = UHCI_TD_ZERO_ACTLEN(UHCI_TD_SET_ERRCNT(3) | UHCI_TD_ACTIVE);
@@ -1559,10 +1674,7 @@ uhci_alloc_std_chain(upipe, sc, len, rd, flags, dma, sp, ep)
return (USBD_NOMEM);
}
p->link.std = lastp;
- if (lastlink == UHCI_PTR_T)
- p->td.td_link = htole32(lastlink);
- else
- p->td.td_link = htole32(lastlink|UHCI_PTR_VF);
+ p->td.td_link = htole32(lastlink | UHCI_PTR_VF | UHCI_PTR_TD);
lastp = p;
lastlink = p->physaddr;
p->td.td_status = htole32(status);
@@ -1587,22 +1699,19 @@ uhci_alloc_std_chain(upipe, sc, len, rd, flags, dma, sp, ep)
}
void
-uhci_device_clear_toggle(pipe)
- usbd_pipe_handle pipe;
+uhci_device_clear_toggle(usbd_pipe_handle pipe)
{
struct uhci_pipe *upipe = (struct uhci_pipe *)pipe;
upipe->nexttoggle = 0;
}
void
-uhci_noop(pipe)
- usbd_pipe_handle pipe;
+uhci_noop(usbd_pipe_handle pipe)
{
}
usbd_status
-uhci_device_bulk_transfer(xfer)
- usbd_xfer_handle xfer;
+uhci_device_bulk_transfer(usbd_xfer_handle xfer)
{
usbd_status err;
@@ -1619,8 +1728,7 @@ uhci_device_bulk_transfer(xfer)
}
usbd_status
-uhci_device_bulk_start(xfer)
- usbd_xfer_handle xfer;
+uhci_device_bulk_start(usbd_xfer_handle xfer)
{
struct uhci_pipe *upipe = (struct uhci_pipe *)xfer->pipe;
usbd_device_handle dev = upipe->pipe.device;
@@ -1676,7 +1784,7 @@ uhci_device_bulk_start(xfer)
#endif
sqh->elink = data;
- sqh->qh.qh_elink = htole32(data->physaddr);
+ sqh->qh.qh_elink = htole32(data->physaddr | UHCI_PTR_TD);
s = splusb();
uhci_add_bulk(sc, sqh);
@@ -1704,8 +1812,7 @@ uhci_device_bulk_start(xfer)
/* Abort a device bulk request. */
void
-uhci_device_bulk_abort(xfer)
- usbd_xfer_handle xfer;
+uhci_device_bulk_abort(usbd_xfer_handle xfer)
{
DPRINTF(("uhci_device_bulk_abort:\n"));
uhci_abort_xfer(xfer, USBD_CANCELLED);
@@ -1717,9 +1824,7 @@ uhci_device_bulk_abort(xfer)
* I apologize for the delay().
*/
void
-uhci_abort_xfer(xfer, status)
- usbd_xfer_handle xfer;
- usbd_status status;
+uhci_abort_xfer(usbd_xfer_handle xfer, usbd_status status)
{
uhci_intr_info_t *ii = &UXFER(xfer)->iinfo;
uhci_soft_td_t *std;
@@ -1762,8 +1867,7 @@ uhci_abort_xfer(xfer, status)
/* Close a device bulk pipe. */
void
-uhci_device_bulk_close(pipe)
- usbd_pipe_handle pipe;
+uhci_device_bulk_close(usbd_pipe_handle pipe)
{
struct uhci_pipe *upipe = (struct uhci_pipe *)pipe;
usbd_device_handle dev = upipe->pipe.device;
@@ -1773,8 +1877,7 @@ uhci_device_bulk_close(pipe)
}
usbd_status
-uhci_device_ctrl_transfer(xfer)
- usbd_xfer_handle xfer;
+uhci_device_ctrl_transfer(usbd_xfer_handle xfer)
{
usbd_status err;
@@ -1791,8 +1894,7 @@ uhci_device_ctrl_transfer(xfer)
}
usbd_status
-uhci_device_ctrl_start(xfer)
- usbd_xfer_handle xfer;
+uhci_device_ctrl_start(usbd_xfer_handle xfer)
{
uhci_softc_t *sc = (uhci_softc_t *)xfer->pipe->device->bus;
usbd_status err;
@@ -1815,8 +1917,7 @@ uhci_device_ctrl_start(xfer)
}
usbd_status
-uhci_device_intr_transfer(xfer)
- usbd_xfer_handle xfer;
+uhci_device_intr_transfer(usbd_xfer_handle xfer)
{
usbd_status err;
@@ -1833,8 +1934,7 @@ uhci_device_intr_transfer(xfer)
}
usbd_status
-uhci_device_intr_start(xfer)
- usbd_xfer_handle xfer;
+uhci_device_intr_start(usbd_xfer_handle xfer)
{
struct uhci_pipe *upipe = (struct uhci_pipe *)xfer->pipe;
usbd_device_handle dev = upipe->pipe.device;
@@ -1887,7 +1987,7 @@ uhci_device_intr_start(xfer)
for (i = 0; i < upipe->u.intr.npoll; i++) {
sqh = upipe->u.intr.qhs[i];
sqh->elink = data;
- sqh->qh.qh_elink = htole32(data->physaddr);
+ sqh->qh.qh_elink = htole32(data->physaddr | UHCI_PTR_TD);
}
uhci_add_intr_info(sc, ii);
xfer->status = USBD_IN_PROGRESS;
@@ -1906,8 +2006,7 @@ uhci_device_intr_start(xfer)
/* Abort a device control request. */
void
-uhci_device_ctrl_abort(xfer)
- usbd_xfer_handle xfer;
+uhci_device_ctrl_abort(usbd_xfer_handle xfer)
{
DPRINTF(("uhci_device_ctrl_abort:\n"));
uhci_abort_xfer(xfer, USBD_CANCELLED);
@@ -1915,15 +2014,13 @@ uhci_device_ctrl_abort(xfer)
/* Close a device control pipe. */
void
-uhci_device_ctrl_close(pipe)
- usbd_pipe_handle pipe;
+uhci_device_ctrl_close(usbd_pipe_handle pipe)
{
}
/* Abort a device interrupt request. */
void
-uhci_device_intr_abort(xfer)
- usbd_xfer_handle xfer;
+uhci_device_intr_abort(usbd_xfer_handle xfer)
{
DPRINTFN(1,("uhci_device_intr_abort: xfer=%p\n", xfer));
if (xfer->pipe->intrxfer == xfer) {
@@ -1935,8 +2032,7 @@ uhci_device_intr_abort(xfer)
/* Close a device interrupt pipe. */
void
-uhci_device_intr_close(pipe)
- usbd_pipe_handle pipe;
+uhci_device_intr_close(usbd_pipe_handle pipe)
{
struct uhci_pipe *upipe = (struct uhci_pipe *)pipe;
uhci_softc_t *sc = (uhci_softc_t *)pipe->device->bus;
@@ -1964,8 +2060,7 @@ uhci_device_intr_close(pipe)
}
usbd_status
-uhci_device_request(xfer)
- usbd_xfer_handle xfer;
+uhci_device_request(usbd_xfer_handle xfer)
{
struct uhci_pipe *upipe = (struct uhci_pipe *)xfer->pipe;
usb_device_request_t *req = &xfer->request;
@@ -2005,7 +2100,7 @@ uhci_device_request(xfer)
return (err);
next = data;
dataend->link.std = stat;
- dataend->td.td_link = htole32(stat->physaddr | UHCI_PTR_VF);
+ dataend->td.td_link = htole32(stat->physaddr | UHCI_PTR_VF | UHCI_PTR_TD);
} else {
next = stat;
}
@@ -2014,7 +2109,7 @@ uhci_device_request(xfer)
memcpy(KERNADDR(&upipe->u.ctl.reqdma), req, sizeof *req);
setup->link.std = next;
- setup->td.td_link = htole32(next->physaddr | UHCI_PTR_VF);
+ setup->td.td_link = htole32(next->physaddr | UHCI_PTR_VF | UHCI_PTR_TD);
setup->td.td_status = htole32(UHCI_TD_SET_ERRCNT(3) | ls |
UHCI_TD_ACTIVE);
setup->td.td_token = htole32(UHCI_TD_SETUP(sizeof *req, endpt, addr));
@@ -2048,10 +2143,13 @@ uhci_device_request(xfer)
#endif
sqh->elink = setup;
- sqh->qh.qh_elink = htole32(setup->physaddr);
+ sqh->qh.qh_elink = htole32(setup->physaddr | UHCI_PTR_TD);
s = splusb();
- uhci_add_ctrl(sc, sqh);
+ if (dev->lowspeed)
+ uhci_add_ls_ctrl(sc, sqh);
+ else
+ uhci_add_hs_ctrl(sc, sqh);
uhci_add_intr_info(sc, ii);
#ifdef UHCI_DEBUG
if (uhcidebug > 12) {
@@ -2062,7 +2160,7 @@ uhci_device_request(xfer)
uhci_physaddr_t link;
DPRINTF(("uhci_enter_ctl_q: follow from [0]\n"));
for (std = sc->sc_vframes[0].htd, link = 0;
- (link & UHCI_PTR_Q) == 0;
+ (link & UHCI_PTR_QH) == 0;
std = std->link.std) {
link = le32toh(std->td.td_link);
uhci_dump_td(std);
@@ -2071,8 +2169,8 @@ uhci_device_request(xfer)
uhci_dump_qh(sxqh);
for (xqh = sxqh;
xqh != NULL;
- xqh = (maxqh++ == 5 || xqh->hlink==sxqh ||
- xqh->hlink==xqh ? NULL : xqh->hlink)) {
+ xqh = (maxqh++ == 5 || xqh->hlink == sxqh ||
+ xqh->hlink == xqh ? NULL : xqh->hlink)) {
uhci_dump_qh(xqh);
}
DPRINTF(("Enqueued QH:\n"));
@@ -2091,8 +2189,7 @@ uhci_device_request(xfer)
}
usbd_status
-uhci_device_isoc_transfer(xfer)
- usbd_xfer_handle xfer;
+uhci_device_isoc_transfer(usbd_xfer_handle xfer)
{
usbd_status err;
@@ -2118,8 +2215,7 @@ uhci_device_isoc_transfer(xfer)
}
void
-uhci_device_isoc_enter(xfer)
- usbd_xfer_handle xfer;
+uhci_device_isoc_enter(usbd_xfer_handle xfer)
{
struct uhci_pipe *upipe = (struct uhci_pipe *)xfer->pipe;
usbd_device_handle dev = upipe->pipe.device;
@@ -2189,8 +2285,7 @@ uhci_device_isoc_enter(xfer)
}
usbd_status
-uhci_device_isoc_start(xfer)
- usbd_xfer_handle xfer;
+uhci_device_isoc_start(usbd_xfer_handle xfer)
{
struct uhci_pipe *upipe = (struct uhci_pipe *)xfer->pipe;
uhci_softc_t *sc = (uhci_softc_t *)upipe->pipe.device->bus;
@@ -2240,8 +2335,7 @@ uhci_device_isoc_start(xfer)
}
void
-uhci_device_isoc_abort(xfer)
- usbd_xfer_handle xfer;
+uhci_device_isoc_abort(usbd_xfer_handle xfer)
{
struct uhci_pipe *upipe = (struct uhci_pipe *)xfer->pipe;
uhci_soft_td_t **stds = upipe->u.iso.stds;
@@ -2287,8 +2381,7 @@ uhci_device_isoc_abort(xfer)
}
void
-uhci_device_isoc_close(pipe)
- usbd_pipe_handle pipe;
+uhci_device_isoc_close(usbd_pipe_handle pipe)
{
struct uhci_pipe *upipe = (struct uhci_pipe *)pipe;
usbd_device_handle dev = upipe->pipe.device;
@@ -2332,8 +2425,7 @@ uhci_device_isoc_close(pipe)
}
usbd_status
-uhci_setup_isoc(pipe)
- usbd_pipe_handle pipe;
+uhci_setup_isoc(usbd_pipe_handle pipe)
{
struct uhci_pipe *upipe = (struct uhci_pipe *)pipe;
usbd_device_handle dev = upipe->pipe.device;
@@ -2371,7 +2463,7 @@ uhci_setup_isoc(pipe)
std->link = vstd->link;
std->td.td_link = vstd->td.td_link;
vstd->link.std = std;
- vstd->td.td_link = htole32(std->physaddr);
+ vstd->td.td_link = htole32(std->physaddr | UHCI_PTR_TD);
}
splx(s);
@@ -2388,8 +2480,7 @@ uhci_setup_isoc(pipe)
}
void
-uhci_device_isoc_done(xfer)
- usbd_xfer_handle xfer;
+uhci_device_isoc_done(usbd_xfer_handle xfer)
{
uhci_intr_info_t *ii = &UXFER(xfer)->iinfo;
@@ -2422,8 +2513,7 @@ uhci_device_isoc_done(xfer)
}
void
-uhci_device_intr_done(xfer)
- usbd_xfer_handle xfer;
+uhci_device_intr_done(usbd_xfer_handle xfer)
{
uhci_intr_info_t *ii = &UXFER(xfer)->iinfo;
uhci_softc_t *sc = ii->sc;
@@ -2436,7 +2526,7 @@ uhci_device_intr_done(xfer)
npoll = upipe->u.intr.npoll;
for(i = 0; i < npoll; i++) {
sqh = upipe->u.intr.qhs[i];
- sqh->elink = 0;
+ sqh->elink = NULL;
sqh->qh.qh_elink = htole32(UHCI_PTR_T);
}
uhci_free_std_chain(sc, ii->stdstart, 0);
@@ -2471,7 +2561,7 @@ uhci_device_intr_done(xfer)
for (i = 0; i < npoll; i++) {
sqh = upipe->u.intr.qhs[i];
sqh->elink = data;
- sqh->qh.qh_elink = htole32(data->physaddr);
+ sqh->qh.qh_elink = htole32(data->physaddr | UHCI_PTR_TD);
}
xfer->status = USBD_IN_PROGRESS;
/* The ii is already on the examined list, just leave it. */
@@ -2483,8 +2573,7 @@ uhci_device_intr_done(xfer)
/* Deallocate request data structures */
void
-uhci_device_ctrl_done(xfer)
- usbd_xfer_handle xfer;
+uhci_device_ctrl_done(usbd_xfer_handle xfer)
{
uhci_intr_info_t *ii = &UXFER(xfer)->iinfo;
uhci_softc_t *sc = ii->sc;
@@ -2497,7 +2586,10 @@ uhci_device_ctrl_done(xfer)
uhci_del_intr_info(ii); /* remove from active list */
- uhci_remove_ctrl(sc, upipe->u.ctl.sqh);
+ if (upipe->pipe.device->lowspeed)
+ uhci_remove_ls_ctrl(sc, upipe->u.ctl.sqh);
+ else
+ uhci_remove_hs_ctrl(sc, upipe->u.ctl.sqh);
if (upipe->u.ctl.length != 0)
uhci_free_std_chain(sc, ii->stdstart->link.std, ii->stdend);
@@ -2507,8 +2599,7 @@ uhci_device_ctrl_done(xfer)
/* Deallocate request data structures */
void
-uhci_device_bulk_done(xfer)
- usbd_xfer_handle xfer;
+uhci_device_bulk_done(usbd_xfer_handle xfer)
{
uhci_intr_info_t *ii = &UXFER(xfer)->iinfo;
uhci_softc_t *sc = ii->sc;
@@ -2525,9 +2616,7 @@ uhci_device_bulk_done(xfer)
/* Add interrupt QH, called with vflock. */
void
-uhci_add_intr(sc, sqh)
- uhci_softc_t *sc;
- uhci_soft_qh_t *sqh;
+uhci_add_intr(uhci_softc_t *sc, uhci_soft_qh_t *sqh)
{
struct uhci_vframe *vf = &sc->sc_vframes[sqh->pos];
uhci_soft_qh_t *eqh;
@@ -2538,35 +2627,37 @@ uhci_add_intr(sc, sqh)
sqh->hlink = eqh->hlink;
sqh->qh.qh_hlink = eqh->qh.qh_hlink;
eqh->hlink = sqh;
- eqh->qh.qh_hlink = htole32(sqh->physaddr | UHCI_PTR_Q);
+ eqh->qh.qh_hlink = htole32(sqh->physaddr | UHCI_PTR_QH);
vf->eqh = sqh;
vf->bandwidth++;
}
/* Remove interrupt QH. */
void
-uhci_remove_intr(sc, sqh)
- uhci_softc_t *sc;
- uhci_soft_qh_t *sqh;
+uhci_remove_intr(uhci_softc_t *sc, uhci_soft_qh_t *sqh)
{
struct uhci_vframe *vf = &sc->sc_vframes[sqh->pos];
uhci_soft_qh_t *pqh;
DPRINTFN(4, ("uhci_remove_intr: n=%d sqh=%p\n", sqh->pos, sqh));
+ /* See comment in uhci_remove_ctrl() */
+ if (!(sqh->qh.qh_elink & htole32(UHCI_PTR_T))) {
+ sqh->qh.qh_elink = htole32(UHCI_PTR_T);
+ delay(UHCI_QH_REMOVE_DELAY);
+ }
+
pqh = uhci_find_prev_qh(vf->hqh, sqh);
pqh->hlink = sqh->hlink;
pqh->qh.qh_hlink = sqh->qh.qh_hlink;
+ delay(UHCI_QH_REMOVE_DELAY);
if (vf->eqh == sqh)
vf->eqh = pqh;
vf->bandwidth--;
}
usbd_status
-uhci_device_setintr(sc, upipe, ival)
- uhci_softc_t *sc;
- struct uhci_pipe *upipe;
- int ival;
+uhci_device_setintr(uhci_softc_t *sc, struct uhci_pipe *upipe, int ival)
{
uhci_soft_qh_t *sqh;
int i, npoll, s;
@@ -2604,7 +2695,7 @@ uhci_device_setintr(sc, upipe, ival)
for(i = 0; i < npoll; i++) {
upipe->u.intr.qhs[i] = sqh = uhci_alloc_sqh(sc);
- sqh->elink = 0;
+ sqh->elink = NULL;
sqh->qh.qh_elink = htole32(UHCI_PTR_T);
sqh->pos = MOD(i * ival + bestoffs);
}
@@ -2622,8 +2713,7 @@ uhci_device_setintr(sc, upipe, ival)
/* Open a new pipe. */
usbd_status
-uhci_open(pipe)
- usbd_pipe_handle pipe;
+uhci_open(usbd_pipe_handle pipe)
{
uhci_softc_t *sc = (uhci_softc_t *)pipe->device->bus;
struct uhci_pipe *upipe = (struct uhci_pipe *)pipe;
@@ -2761,10 +2851,7 @@ usb_hub_descriptor_t uhci_hubd_piix = {
};
int
-uhci_str(p, l, s)
- usb_string_descriptor_t *p;
- int l;
- char *s;
+uhci_str(usb_string_descriptor_t *p, int l, char *s)
{
int i;
@@ -2784,8 +2871,7 @@ uhci_str(p, l, s)
* Simulate a hardware hub by handling all the necessary requests.
*/
usbd_status
-uhci_root_ctrl_transfer(xfer)
- usbd_xfer_handle xfer;
+uhci_root_ctrl_transfer(usbd_xfer_handle xfer)
{
usbd_status err;
@@ -2802,8 +2888,7 @@ uhci_root_ctrl_transfer(xfer)
}
usbd_status
-uhci_root_ctrl_start(xfer)
- usbd_xfer_handle xfer;
+uhci_root_ctrl_start(usbd_xfer_handle xfer)
{
uhci_softc_t *sc = (uhci_softc_t *)xfer->pipe->device->bus;
usb_device_request_t *req;
@@ -3094,12 +3179,12 @@ uhci_root_ctrl_start(xfer)
case UHF_PORT_RESET:
x = UREAD2(sc, port);
UWRITE2(sc, port, x | UHCI_PORTSC_PR);
- usb_delay_ms(&sc->sc_bus, 10);
+ usb_delay_ms(&sc->sc_bus, 50); /*XXX USB v1.1 7.1.7.3 */
UWRITE2(sc, port, x & ~UHCI_PORTSC_PR);
delay(100);
x = UREAD2(sc, port);
UWRITE2(sc, port, x | UHCI_PORTSC_PE);
- delay(100);
+ usb_delay_ms(&sc->sc_bus, 10); /* XXX */
DPRINTFN(3,("uhci port %d reset, status = 0x%04x\n",
index, UREAD2(sc, port)));
sc->sc_isreset = 1;
@@ -3137,24 +3222,21 @@ uhci_root_ctrl_start(xfer)
/* Abort a root control request. */
void
-uhci_root_ctrl_abort(xfer)
- usbd_xfer_handle xfer;
+uhci_root_ctrl_abort(usbd_xfer_handle xfer)
{
/* Nothing to do, all transfers are synchronous. */
}
/* Close the root pipe. */
void
-uhci_root_ctrl_close(pipe)
- usbd_pipe_handle pipe;
+uhci_root_ctrl_close(usbd_pipe_handle pipe)
{
DPRINTF(("uhci_root_ctrl_close\n"));
}
/* Abort a root interrupt request. */
void
-uhci_root_intr_abort(xfer)
- usbd_xfer_handle xfer;
+uhci_root_intr_abort(usbd_xfer_handle xfer)
{
uhci_softc_t *sc = (uhci_softc_t *)xfer->pipe->device->bus;
@@ -3173,8 +3255,7 @@ uhci_root_intr_abort(xfer)
}
usbd_status
-uhci_root_intr_transfer(xfer)
- usbd_xfer_handle xfer;
+uhci_root_intr_transfer(usbd_xfer_handle xfer)
{
usbd_status err;
@@ -3191,8 +3272,7 @@ uhci_root_intr_transfer(xfer)
/* Start a transfer on the root interrupt pipe */
usbd_status
-uhci_root_intr_start(xfer)
- usbd_xfer_handle xfer;
+uhci_root_intr_start(usbd_xfer_handle xfer)
{
usbd_pipe_handle pipe = xfer->pipe;
uhci_softc_t *sc = (uhci_softc_t *)pipe->device->bus;
@@ -3211,8 +3291,7 @@ uhci_root_intr_start(xfer)
/* Close the root interrupt pipe. */
void
-uhci_root_intr_close(pipe)
- usbd_pipe_handle pipe;
+uhci_root_intr_close(usbd_pipe_handle pipe)
{
uhci_softc_t *sc = (uhci_softc_t *)pipe->device->bus;
diff --git a/sys/dev/usb/uhcireg.h b/sys/dev/usb/uhcireg.h
index 0777e92b468..0b98a634d91 100644
--- a/sys/dev/usb/uhcireg.h
+++ b/sys/dev/usb/uhcireg.h
@@ -1,5 +1,5 @@
-/* $OpenBSD: uhcireg.h,v 1.6 2000/07/04 11:44:23 fgsch Exp $ */
-/* $NetBSD: uhcireg.h,v 1.10 2000/04/06 23:44:21 augustss Exp $ */
+/* $OpenBSD: uhcireg.h,v 1.7 2000/11/08 18:10:38 aaron Exp $ */
+/* $NetBSD: uhcireg.h,v 1.11.4.1 2000/08/22 04:11:56 augustss Exp $ */
/* $FreeBSD: src/sys/dev/usb/uhcireg.h,v 1.12 1999/11/17 22:33:42 n_hibma Exp $ */
/*
@@ -115,9 +115,16 @@
typedef u_int32_t uhci_physaddr_t;
#define UHCI_PTR_T 0x00000001
-#define UHCI_PTR_Q 0x00000002
+#define UHCI_PTR_TD 0x00000000
+#define UHCI_PTR_QH 0x00000002
#define UHCI_PTR_VF 0x00000004
+/*
+ * Wait this long after a QH has been removed. This gives that HC a
+ * chance to stop looking at it before it's recycled.
+ */
+#define UHCI_QH_REMOVE_DELAY 5
+
/*
* The Queue Heads and Transfer Descriptors are accessed
* by both the CPU and the USB controller which run
diff --git a/sys/dev/usb/uhcivar.h b/sys/dev/usb/uhcivar.h
index d461973ae73..a6094b725c0 100644
--- a/sys/dev/usb/uhcivar.h
+++ b/sys/dev/usb/uhcivar.h
@@ -1,5 +1,5 @@
-/* $OpenBSD: uhcivar.h,v 1.9 2000/07/04 11:44:23 fgsch Exp $ */
-/* $NetBSD: uhcivar.h,v 1.28 2000/04/06 23:44:21 augustss Exp $ */
+/* $OpenBSD: uhcivar.h,v 1.10 2000/11/08 18:10:38 aaron Exp $ */
+/* $NetBSD: uhcivar.h,v 1.32 2000/08/13 16:18:09 augustss Exp $ */
/* $FreeBSD: src/sys/dev/usb/uhcivar.h,v 1.14 1999/11/17 22:33:42 n_hibma Exp $ */
/*
@@ -141,10 +141,14 @@ typedef struct uhci_softc {
usb_dma_t sc_dma;
struct uhci_vframe sc_vframes[UHCI_VFRAMELIST_COUNT];
- uhci_soft_qh_t *sc_ctl_start; /* dummy QH for control */
- uhci_soft_qh_t *sc_ctl_end; /* last control QH */
+ uhci_soft_qh_t *sc_lctl_start; /* dummy QH for low speed control */
+ uhci_soft_qh_t *sc_lctl_end; /* last control QH */
+ uhci_soft_qh_t *sc_hctl_start; /* dummy QH for high speed control */
+ uhci_soft_qh_t *sc_hctl_end; /* last control QH */
uhci_soft_qh_t *sc_bulk_start; /* dummy QH for bulk */
uhci_soft_qh_t *sc_bulk_end; /* last bulk transfer */
+ uhci_soft_qh_t *sc_last_qh; /* dummy QH at the end */
+ u_int32_t sc_loops; /* number of QHs that wants looping */
uhci_soft_td_t *sc_freetds; /* TD free list */
uhci_soft_qh_t *sc_freeqhs; /* QH free list */
@@ -177,10 +181,10 @@ typedef struct uhci_softc {
device_ptr_t sc_child; /* /dev/usb# device */
} uhci_softc_t;
-usbd_status uhci_init __P((uhci_softc_t *));
-int uhci_intr __P((void *));
+usbd_status uhci_init(uhci_softc_t *);
+int uhci_intr(void *);
#if defined(__NetBSD__) || defined(__OpenBSD__)
-int uhci_detach __P((uhci_softc_t *, int));
-int uhci_activate __P((device_ptr_t, enum devact));
+int uhci_detach(uhci_softc_t *, int);
+int uhci_activate(device_ptr_t, enum devact);
#endif
diff --git a/sys/dev/usb/uhid.c b/sys/dev/usb/uhid.c
index 41459b39e88..e47a2454e3d 100644
--- a/sys/dev/usb/uhid.c
+++ b/sys/dev/usb/uhid.c
@@ -1,5 +1,5 @@
-/* $OpenBSD: uhid.c,v 1.11 2000/07/04 11:44:23 fgsch Exp $ */
-/* $NetBSD: uhid.c,v 1.37 2000/04/14 14:12:47 augustss Exp $ */
+/* $OpenBSD: uhid.c,v 1.12 2000/11/08 18:10:38 aaron Exp $ */
+/* $NetBSD: uhid.c,v 1.40 2000/10/10 12:37:01 augustss Exp $ */
/* $FreeBSD: src/sys/dev/usb/uhid.c,v 1.22 1999/11/17 22:33:43 n_hibma Exp $ */
/*
@@ -150,13 +150,11 @@ Static struct cdevsw uhid_cdevsw = {
};
#endif
-Static void uhid_intr __P((usbd_xfer_handle, usbd_private_handle,
- usbd_status));
+Static void uhid_intr(usbd_xfer_handle, usbd_private_handle, usbd_status);
-Static int uhid_do_read __P((struct uhid_softc *, struct uio *uio, int));
-Static int uhid_do_write __P((struct uhid_softc *, struct uio *uio, int));
-Static int uhid_do_ioctl __P((struct uhid_softc *, u_long, caddr_t, int,
- struct proc *));
+Static int uhid_do_read(struct uhid_softc *, struct uio *uio, int);
+Static int uhid_do_write(struct uhid_softc *, struct uio *uio, int);
+Static int uhid_do_ioctl(struct uhid_softc*, u_long, caddr_t, int,struct proc*);
USB_DECLARE_DRIVER(uhid);
@@ -218,7 +216,7 @@ USB_ATTACH(uhid)
sc->sc_ep_addr = ed->bEndpointAddress;
- desc = 0;
+ desc = NULL;
err = usbd_alloc_report_desc(uaa->iface, &desc, &size, M_USBDEV);
if (err) {
printf("%s: no report descriptor\n", USBDEVNAME(sc->sc_dev));
@@ -254,9 +252,7 @@ USB_ATTACH(uhid)
#if defined(__NetBSD__) || defined(__OpenBSD__)
int
-uhid_activate(self, act)
- device_ptr_t self;
- enum devact act;
+uhid_activate(device_ptr_t self, enum devact act)
{
struct uhid_softc *sc = (struct uhid_softc *)self;
@@ -313,7 +309,8 @@ USB_DETACH(uhid)
/* XXX not implemented yet */
#endif
- free(sc->sc_repdesc, M_USBDEV);
+ if (sc->sc_repdesc)
+ free(sc->sc_repdesc, M_USBDEV);
usbd_add_drv_event(USB_EVENT_DRIVER_DETACH, sc->sc_udev,
USBDEV(sc->sc_dev));
@@ -322,10 +319,7 @@ USB_DETACH(uhid)
}
void
-uhid_intr(xfer, addr, status)
- usbd_xfer_handle xfer;
- usbd_private_handle addr;
- usbd_status status;
+uhid_intr(usbd_xfer_handle xfer, usbd_private_handle addr, usbd_status status)
{
struct uhid_softc *sc = addr;
@@ -366,11 +360,7 @@ uhid_intr(xfer, addr, status)
}
int
-uhidopen(dev, flag, mode, p)
- dev_t dev;
- int flag;
- int mode;
- struct proc *p;
+uhidopen(dev_t dev, int flag, int mode, struct proc *p)
{
struct uhid_softc *sc;
usbd_status err;
@@ -415,11 +405,7 @@ uhidopen(dev, flag, mode, p)
}
int
-uhidclose(dev, flag, mode, p)
- dev_t dev;
- int flag;
- int mode;
- struct proc *p;
+uhidclose(dev_t dev, int flag, int mode, struct proc *p)
{
struct uhid_softc *sc;
@@ -445,10 +431,7 @@ uhidclose(dev, flag, mode, p)
}
int
-uhid_do_read(sc, uio, flag)
- struct uhid_softc *sc;
- struct uio *uio;
- int flag;
+uhid_do_read(struct uhid_softc *sc, struct uio *uio, int flag)
{
int s;
int error = 0;
@@ -510,10 +493,7 @@ uhid_do_read(sc, uio, flag)
}
int
-uhidread(dev, uio, flag)
- dev_t dev;
- struct uio *uio;
- int flag;
+uhidread(dev_t dev, struct uio *uio, int flag)
{
struct uhid_softc *sc;
int error;
@@ -528,10 +508,7 @@ uhidread(dev, uio, flag)
}
int
-uhid_do_write(sc, uio, flag)
- struct uhid_softc *sc;
- struct uio *uio;
- int flag;
+uhid_do_write(struct uhid_softc *sc, struct uio *uio, int flag)
{
int error;
int size;
@@ -562,10 +539,7 @@ uhid_do_write(sc, uio, flag)
}
int
-uhidwrite(dev, uio, flag)
- dev_t dev;
- struct uio *uio;
- int flag;
+uhidwrite(dev_t dev, struct uio *uio, int flag)
{
struct uhid_softc *sc;
int error;
@@ -580,12 +554,8 @@ uhidwrite(dev, uio, flag)
}
int
-uhid_do_ioctl(sc, cmd, addr, flag, p)
- struct uhid_softc *sc;
- u_long cmd;
- caddr_t addr;
- int flag;
- struct proc *p;
+uhid_do_ioctl(struct uhid_softc *sc, u_long cmd, caddr_t addr,
+ int flag, struct proc *p)
{
struct usb_ctl_report_desc *rd;
struct usb_ctl_report *re;
@@ -695,12 +665,7 @@ uhid_do_ioctl(sc, cmd, addr, flag, p)
}
int
-uhidioctl(dev, cmd, addr, flag, p)
- dev_t dev;
- u_long cmd;
- caddr_t addr;
- int flag;
- struct proc *p;
+uhidioctl(dev_t dev, u_long cmd, caddr_t addr, int flag, struct proc *p)
{
struct uhid_softc *sc;
int error;
@@ -715,10 +680,7 @@ uhidioctl(dev, cmd, addr, flag, p)
}
int
-uhidpoll(dev, events, p)
- dev_t dev;
- int events;
- struct proc *p;
+uhidpoll(dev_t dev, int events, struct proc *p)
{
struct uhid_softc *sc;
int revents = 0;
diff --git a/sys/dev/usb/uhub.c b/sys/dev/usb/uhub.c
index 9d45b72d556..b3298635eca 100644
--- a/sys/dev/usb/uhub.c
+++ b/sys/dev/usb/uhub.c
@@ -1,5 +1,5 @@
-/* $OpenBSD: uhub.c,v 1.10 2000/07/04 11:44:23 fgsch Exp $ */
-/* $NetBSD: uhub.c,v 1.41 2000/03/27 12:33:56 augustss Exp $ */
+/* $OpenBSD: uhub.c,v 1.11 2000/11/08 18:10:38 aaron Exp $ */
+/* $NetBSD: uhub.c,v 1.47 2000/09/24 02:08:38 augustss Exp $ */
/* $FreeBSD: src/sys/dev/usb/uhub.c,v 1.18 1999/11/17 22:33:43 n_hibma Exp $ */
/*
@@ -82,8 +82,8 @@ struct uhub_softc {
u_char sc_running;
};
-Static usbd_status uhub_explore __P((usbd_device_handle hub));
-Static void uhub_intr __P((usbd_xfer_handle, usbd_private_handle,usbd_status));
+Static usbd_status uhub_explore(usbd_device_handle hub);
+Static void uhub_intr(usbd_xfer_handle, usbd_private_handle,usbd_status);
#if defined(__FreeBSD__)
Static bus_child_detached_t uhub_child_detached;
@@ -317,8 +317,7 @@ USB_ATTACH(uhub)
}
usbd_status
-uhub_explore(dev)
- usbd_device_handle dev;
+uhub_explore(usbd_device_handle dev)
{
usb_hub_descriptor_t *hd = &dev->hub->hubdesc;
struct uhub_softc *sc = dev->hub->hubsoftc;
@@ -356,16 +355,17 @@ uhub_explore(dev)
USBDEVNAME(sc->sc_dev), port);
} else {
/* Port error condition. */
- if (up->restartcnt++ < USBD_RESTART_MAX) {
+ if (up->restartcnt) /* no message first time */
printf("%s: port error, restarting "
"port %d\n",
USBDEVNAME(sc->sc_dev), port);
+
+ if (up->restartcnt++ < USBD_RESTART_MAX)
goto disco;
- } else {
+ else
printf("%s: port error, giving up "
"port %d\n",
USBDEVNAME(sc->sc_dev), port);
- }
}
}
if (!(change & UPS_C_CONNECT_STATUS)) {
@@ -412,8 +412,6 @@ uhub_explore(dev)
printf("%s: strange, connected port %d has no power\n",
USBDEVNAME(sc->sc_dev), port);
- up->restartcnt = 0;
-
/* Wait for maximum device power up time. */
usbd_delay_ms(dev, USB_PORT_POWERUP_DELAY);
@@ -443,9 +441,10 @@ uhub_explore(dev)
printf("%s: device problem, disabling port %d\n",
USBDEVNAME(sc->sc_dev), port);
usbd_clear_port_feature(dev, port, UHF_PORT_ENABLE);
- /* Make sure we don't try to restart it infinitely. */
- up->restartcnt = USBD_RESTART_MAX;
} else {
+ /* The port set up succeeded, reset error count. */
+ up->restartcnt = 0;
+
if (up->device->hub)
up->device->hub->explore(up->device);
}
@@ -455,9 +454,7 @@ uhub_explore(dev)
#if defined(__NetBSD__) || defined(__OpenBSD__)
int
-uhub_activate(self, act)
- device_ptr_t self;
- enum devact act;
+uhub_activate(device_ptr_t self, enum devact act)
{
struct uhub_softc *sc = (struct uhub_softc *)self;
struct usbd_hub *hub = sc->sc_hub->hub;
@@ -475,8 +472,8 @@ uhub_activate(self, act)
nports = hub->hubdesc.bNbrPorts;
for(port = 0; port < nports; port++) {
dev = hub->ports[port].device;
- if (dev != NULL) {
- for (i = 0; dev->subdevs[i]; i++)
+ if (dev != NULL && dev->subdevs != NULL) {
+ for (i = 0; dev->subdevs[i] != NULL; i++)
config_deactivate(dev->subdevs[i]);
}
}
@@ -528,9 +525,7 @@ USB_DETACH(uhub)
#if defined(__FreeBSD__)
/* Called when a device has been detached from it */
Static void
-uhub_child_detached(self, child)
- device_t self;
- device_t child;
+uhub_child_detached(device_t self, device_t child)
{
struct uhub_softc *sc = device_get_softc(self);
usbd_device_handle devhub = sc->sc_hub;
@@ -566,10 +561,7 @@ uhub_child_detached(self, child)
* to be explored again.
*/
void
-uhub_intr(xfer, addr, status)
- usbd_xfer_handle xfer;
- usbd_private_handle addr;
- usbd_status status;
+uhub_intr(usbd_xfer_handle xfer, usbd_private_handle addr, usbd_status status)
{
struct uhub_softc *sc = addr;
diff --git a/sys/dev/usb/ukbdmap.c b/sys/dev/usb/ukbdmap.c
index 98c19e57969..6d316abcb7d 100644
--- a/sys/dev/usb/ukbdmap.c
+++ b/sys/dev/usb/ukbdmap.c
@@ -1,3 +1,4 @@
+/* $OpenBSD: ukbdmap.c,v 1.2 2000/11/08 18:10:38 aaron Exp $ */
/* $NetBSD: ukbdmap.c,v 1.5 2000/04/27 15:26:49 augustss Exp $ */
/*
diff --git a/sys/dev/usb/ukbdvar.h b/sys/dev/usb/ukbdvar.h
index e49f9629270..968de7c810d 100644
--- a/sys/dev/usb/ukbdvar.h
+++ b/sys/dev/usb/ukbdvar.h
@@ -1,3 +1,4 @@
+/* $OpenBSD: ukbdvar.h,v 1.2 2000/11/08 18:10:38 aaron Exp $ */
/* $NetBSD: ukbdvar.h,v 1.2 2000/06/01 14:29:00 augustss Exp $ */
/*-
diff --git a/sys/dev/usb/ulpt.c b/sys/dev/usb/ulpt.c
index 04d874e6be9..d17b46e035b 100644
--- a/sys/dev/usb/ulpt.c
+++ b/sys/dev/usb/ulpt.c
@@ -1,5 +1,5 @@
-/* $OpenBSD: ulpt.c,v 1.4 2000/07/04 11:44:24 fgsch Exp $ */
-/* $NetBSD: ulpt.c,v 1.36 2000/04/14 14:12:11 augustss Exp $ */
+/* $OpenBSD: ulpt.c,v 1.5 2000/11/08 18:10:38 aaron Exp $ */
+/* $NetBSD: ulpt.c,v 1.38 2000/06/01 14:29:00 augustss Exp $ */
/* $FreeBSD: src/sys/dev/usb/ulpt.c,v 1.24 1999/11/17 22:33:44 n_hibma Exp $ */
/*
@@ -144,14 +144,14 @@ Static struct cdevsw ulpt_cdevsw = {
};
#endif
-void ulpt_disco __P((void *));
+void ulpt_disco(void *);
-int ulpt_do_write __P((struct ulpt_softc *, struct uio *uio, int));
-int ulpt_status __P((struct ulpt_softc *));
-void ulpt_reset __P((struct ulpt_softc *));
-int ulpt_statusmsg __P((u_char, struct ulpt_softc *));
+int ulpt_do_write(struct ulpt_softc *, struct uio *uio, int);
+int ulpt_status(struct ulpt_softc *);
+void ulpt_reset(struct ulpt_softc *);
+int ulpt_statusmsg(u_char, struct ulpt_softc *);
-void ieee1284_print_id __P((char *));
+void ieee1284_print_id(char *);
#define ULPTUNIT(s) (minor(s) & 0x1f)
#define ULPTFLAGS(s) (minor(s) & 0xe0)
@@ -275,9 +275,7 @@ USB_ATTACH(ulpt)
#if defined(__NetBSD__) || defined(__OpenBSD__)
int
-ulpt_activate(self, act)
- device_ptr_t self;
- enum devact act;
+ulpt_activate(device_ptr_t self, enum devact act)
{
struct ulpt_softc *sc = (struct ulpt_softc *)self;
@@ -341,8 +339,7 @@ USB_DETACH(ulpt)
}
int
-ulpt_status(sc)
- struct ulpt_softc *sc;
+ulpt_status(struct ulpt_softc *sc)
{
usb_device_request_t req;
usbd_status err;
@@ -362,8 +359,7 @@ ulpt_status(sc)
}
void
-ulpt_reset(sc)
- struct ulpt_softc *sc;
+ulpt_reset(struct ulpt_softc *sc)
{
usb_device_request_t req;
@@ -380,11 +376,7 @@ ulpt_reset(sc)
* Reset the printer, then wait until it's selected and not busy.
*/
int
-ulptopen(dev, flag, mode, p)
- dev_t dev;
- int flag;
- int mode;
- struct proc *p;
+ulptopen(dev_t dev, int flag, int mode, struct proc *p)
{
u_char flags = ULPTFLAGS(dev);
struct ulpt_softc *sc;
@@ -441,9 +433,7 @@ ulptopen(dev, flag, mode, p)
}
int
-ulpt_statusmsg(status, sc)
- u_char status;
- struct ulpt_softc *sc;
+ulpt_statusmsg(u_char status, struct ulpt_softc *sc)
{
u_char new;
@@ -462,11 +452,7 @@ ulpt_statusmsg(status, sc)
}
int
-ulptclose(dev, flag, mode, p)
- dev_t dev;
- int flag;
- int mode;
- struct proc *p;
+ulptclose(dev_t dev, int flag, int mode, struct proc *p)
{
struct ulpt_softc *sc;
@@ -486,10 +472,7 @@ ulptclose(dev, flag, mode, p)
}
int
-ulpt_do_write(sc, uio, flags)
- struct ulpt_softc *sc;
- struct uio *uio;
- int flags;
+ulpt_do_write(struct ulpt_softc *sc, struct uio *uio, int flags)
{
u_int32_t n;
int error = 0;
@@ -526,10 +509,7 @@ ulpt_do_write(sc, uio, flags)
}
int
-ulptwrite(dev, uio, flags)
- dev_t dev;
- struct uio *uio;
- int flags;
+ulptwrite(dev_t dev, struct uio *uio, int flags)
{
struct ulpt_softc *sc;
int error;
@@ -547,12 +527,7 @@ ulptwrite(dev, uio, flags)
}
int
-ulptioctl(dev, cmd, data, flag, p)
- dev_t dev;
- u_long cmd;
- caddr_t data;
- int flag;
- struct proc *p;
+ulptioctl(dev_t dev, u_long cmd, caddr_t data, int flag, struct proc *p)
{
int error = 0;
@@ -570,8 +545,7 @@ ulptioctl(dev, cmd, data, flag, p)
* Print select parts of a IEEE 1284 device ID.
*/
void
-ieee1284_print_id(str)
- char *str;
+ieee1284_print_id(char *str)
{
char *p, *q;
diff --git a/sys/dev/usb/umodem.c b/sys/dev/usb/umodem.c
index b3d5c738197..458c8ac4e11 100644
--- a/sys/dev/usb/umodem.c
+++ b/sys/dev/usb/umodem.c
@@ -1,5 +1,5 @@
-/* $OpenBSD: umodem.c,v 1.4 2000/07/04 11:44:24 fgsch Exp $ */
-/* $NetBSD: umodem.c,v 1.27 2000/04/14 14:21:55 augustss Exp $ */
+/* $OpenBSD: umodem.c,v 1.5 2000/11/08 18:10:38 aaron Exp $ */
+/* $NetBSD: umodem.c,v 1.31 2000/10/22 08:20:09 explorer Exp $ */
/*
* Copyright (c) 1998 The NetBSD Foundation, Inc.
@@ -115,25 +115,22 @@ struct umodem_softc {
u_char sc_dying; /* disconnecting */
};
-Static void *umodem_get_desc
- __P((usbd_device_handle dev, int type, int subtype));
-Static usbd_status umodem_set_comm_feature
- __P((struct umodem_softc *sc, int feature, int state));
-Static usbd_status umodem_set_line_coding
- __P((struct umodem_softc *sc, usb_cdc_line_state_t *state));
-
-Static void umodem_get_caps __P((usbd_device_handle, int *, int *));
-
-Static void umodem_get_status
- __P((void *, int portno, u_char *lsr, u_char *msr));
-Static void umodem_set __P((void *, int, int, int));
-Static void umodem_dtr __P((struct umodem_softc *, int));
-Static void umodem_rts __P((struct umodem_softc *, int));
-Static void umodem_break __P((struct umodem_softc *, int));
-Static void umodem_set_line_state __P((struct umodem_softc *));
-Static int umodem_param __P((void *, int, struct termios *));
-Static int umodem_ioctl __P((void *, int, u_long, caddr_t, int,
- struct proc *));
+Static void *umodem_get_desc(usbd_device_handle dev, int type, int subtype);
+Static usbd_status umodem_set_comm_feature(struct umodem_softc *sc,
+ int feature, int state);
+Static usbd_status umodem_set_line_coding(struct umodem_softc *sc,
+ usb_cdc_line_state_t *state);
+
+Static void umodem_get_caps(usbd_device_handle, int *, int *);
+
+Static void umodem_get_status(void *, int portno, u_char *lsr, u_char *msr);
+Static void umodem_set(void *, int, int, int);
+Static void umodem_dtr(struct umodem_softc *, int);
+Static void umodem_rts(struct umodem_softc *, int);
+Static void umodem_break(struct umodem_softc *, int);
+Static void umodem_set_line_state(struct umodem_softc *);
+Static int umodem_param(void *, int, struct termios *);
+Static int umodem_ioctl(void *, int, u_long, caddr_t, int, struct proc *);
Static struct ucom_methods umodem_methods = {
umodem_get_status,
@@ -153,7 +150,7 @@ USB_MATCH(umodem)
USB_MATCH_START(umodem, uaa);
usb_interface_descriptor_t *id;
int cm, acm;
-
+
if (uaa->iface == NULL)
return (UMATCH_NONE);
@@ -163,7 +160,7 @@ USB_MATCH(umodem)
id->bInterfaceSubClass != UISUBCLASS_ABSTRACT_CONTROL_MODEL ||
id->bInterfaceProtocol != UIPROTO_CDC_AT)
return (UMATCH_NONE);
-
+
umodem_get_caps(uaa->device, &cm, &acm);
if (!(cm & USB_CDC_CM_DOES_CM) ||
!(cm & USB_CDC_CM_OVER_DATA) ||
@@ -262,17 +259,20 @@ USB_ATTACH(umodem)
goto bad;
}
- if (sc->sc_cm_cap & USB_CDC_CM_OVER_DATA) {
- err = umodem_set_comm_feature(sc, UCDC_ABSTRACT_STATE,
- UCDC_DATA_MULTIPLEXED);
- if (err) {
- printf("%s: could not set data multiplex mode\n",
- USBDEVNAME(sc->sc_dev));
- goto bad;
- }
+ if (usbd_get_quirks(sc->sc_udev)->uq_flags & UQ_ASSUME_CM_OVER_DATA) {
sc->sc_cm_over_data = 1;
+ } else {
+ if (sc->sc_cm_cap & USB_CDC_CM_OVER_DATA) {
+ err = umodem_set_comm_feature(sc, UCDC_ABSTRACT_STATE,
+ UCDC_DATA_MULTIPLEXED);
+ if (err) {
+ printf("%s: could not set data multiplex mode\n",
+ USBDEVNAME(sc->sc_dev));
+ goto bad;
+ }
+ sc->sc_cm_over_data = 1;
+ }
}
-
sc->sc_dtr = -1;
uca.portno = UCOM_UNK_PORTNO;
@@ -280,7 +280,7 @@ USB_ATTACH(umodem)
uca.ibufsize = UMODEMIBUFSIZE;
uca.obufsize = UMODEMOBUFSIZE;
uca.ibufsizepad = UMODEMIBUFSIZE;
- uca.obufsizepad = UMODEMOBUFSIZE;
+ uca.opkthdrlen = 0;
uca.device = sc->sc_udev;
uca.iface = sc->sc_data_iface;
uca.methods = &umodem_methods;
@@ -300,9 +300,7 @@ USB_ATTACH(umodem)
}
void
-umodem_get_caps(dev, cm, acm)
- usbd_device_handle dev;
- int *cm, *acm;
+umodem_get_caps(usbd_device_handle dev, int *cm, int *acm)
{
usb_cdc_cm_descriptor_t *cmd;
usb_cdc_acm_descriptor_t *cad;
@@ -325,10 +323,7 @@ umodem_get_caps(dev, cm, acm)
}
void
-umodem_get_status(addr, portno, lsr, msr)
- void *addr;
- int portno;
- u_char *lsr, *msr;
+umodem_get_status(void *addr, int portno, u_char *lsr, u_char *msr)
{
DPRINTF(("umodem_get_status:\n"));
@@ -339,10 +334,7 @@ umodem_get_status(addr, portno, lsr, msr)
}
int
-umodem_param(addr, portno, t)
- void *addr;
- int portno;
- struct termios *t;
+umodem_param(void *addr, int portno, struct termios *t)
{
struct umodem_softc *sc = addr;
usbd_status err;
@@ -386,13 +378,8 @@ umodem_param(addr, portno, t)
}
int
-umodem_ioctl(addr, portno, cmd, data, flag, p)
- void *addr;
- int portno;
- u_long cmd;
- caddr_t data;
- int flag;
- struct proc *p;
+umodem_ioctl(void *addr, int portno, u_long cmd, caddr_t data, int flag,
+ struct proc *p)
{
struct umodem_softc *sc = addr;
int error = 0;
@@ -423,9 +410,7 @@ umodem_ioctl(addr, portno, cmd, data, flag, p)
}
void
-umodem_dtr(sc, onoff)
- struct umodem_softc *sc;
- int onoff;
+umodem_dtr(struct umodem_softc *sc, int onoff)
{
DPRINTF(("umodem_modem: onoff=%d\n", onoff));
@@ -437,9 +422,7 @@ umodem_dtr(sc, onoff)
}
void
-umodem_rts(sc, onoff)
- struct umodem_softc *sc;
- int onoff;
+umodem_rts(struct umodem_softc *sc, int onoff)
{
DPRINTF(("umodem_modem: onoff=%d\n", onoff));
@@ -451,8 +434,7 @@ umodem_rts(sc, onoff)
}
void
-umodem_set_line_state(sc)
- struct umodem_softc *sc;
+umodem_set_line_state(struct umodem_softc *sc)
{
usb_device_request_t req;
int ls;
@@ -470,9 +452,7 @@ umodem_set_line_state(sc)
}
void
-umodem_break(sc, onoff)
- struct umodem_softc *sc;
- int onoff;
+umodem_break(struct umodem_softc *sc, int onoff)
{
usb_device_request_t req;
@@ -491,11 +471,7 @@ umodem_break(sc, onoff)
}
void
-umodem_set(addr, portno, reg, onoff)
- void *addr;
- int portno;
- int reg;
- int onoff;
+umodem_set(void *addr, int portno, int reg, int onoff)
{
struct umodem_softc *sc = addr;
@@ -515,9 +491,7 @@ umodem_set(addr, portno, reg, onoff)
}
usbd_status
-umodem_set_line_coding(sc, state)
- struct umodem_softc *sc;
- usb_cdc_line_state_t *state;
+umodem_set_line_coding(struct umodem_softc *sc, usb_cdc_line_state_t *state)
{
usb_device_request_t req;
usbd_status err;
@@ -550,10 +524,7 @@ umodem_set_line_coding(sc, state)
}
void *
-umodem_get_desc(dev, type, subtype)
- usbd_device_handle dev;
- int type;
- int subtype;
+umodem_get_desc(usbd_device_handle dev, int type, int subtype)
{
usb_descriptor_t *desc;
usb_config_descriptor_t *cd = usbd_get_config_descriptor(dev);
@@ -572,10 +543,7 @@ umodem_get_desc(dev, type, subtype)
}
usbd_status
-umodem_set_comm_feature(sc, feature, state)
- struct umodem_softc *sc;
- int feature;
- int state;
+umodem_set_comm_feature(struct umodem_softc *sc, int feature, int state)
{
usb_device_request_t req;
usbd_status err;
@@ -602,9 +570,7 @@ umodem_set_comm_feature(sc, feature, state)
}
int
-umodem_activate(self, act)
- device_ptr_t self;
- enum devact act;
+umodem_activate(device_ptr_t self, enum devact act)
{
struct umodem_softc *sc = (struct umodem_softc *)self;
int rv = 0;
diff --git a/sys/dev/usb/ums.c b/sys/dev/usb/ums.c
index 00efafc9e36..bf013a2d675 100644
--- a/sys/dev/usb/ums.c
+++ b/sys/dev/usb/ums.c
@@ -1,5 +1,5 @@
-/* $NetBSD: ums.c,v 1.44 2000/06/01 14:29:01 augustss Exp $ */
-/* $OpenBSD: ums.c,v 1.2 2000/09/07 22:17:48 matthieu Exp $ */
+/* $OpenBSD: ums.c,v 1.3 2000/11/08 18:10:38 aaron Exp $ */
+/* $NetBSD: ums.c,v 1.45 2000/10/08 20:52:18 augustss Exp $ */
/*
* Copyright (c) 1998 The NetBSD Foundation, Inc.
@@ -261,7 +261,7 @@ USB_ATTACH(ums)
hid_input, &loc_btn, 0))
break;
sc->nbuttons = i - 1;
- sc->sc_loc_btn = malloc(sizeof(struct hid_location)*sc->nbuttons,
+ sc->sc_loc_btn = malloc(sizeof(struct hid_location) * sc->nbuttons,
M_USBDEV, M_NOWAIT);
if (!sc->sc_loc_btn) {
printf("%s: no memory\n", USBDEVNAME(sc->sc_dev));
@@ -269,8 +269,8 @@ USB_ATTACH(ums)
}
printf("%s: %d button%s%s\n", USBDEVNAME(sc->sc_dev),
- sc->nbuttons, sc->nbuttons == 1 ? "" : "s",
- sc->flags & UMS_Z ? " and Z dir." : "");
+ sc->nbuttons, sc->nbuttons == 1 ? "" : "s",
+ sc->flags & UMS_Z ? " and Z dir." : "");
for (i = 1; i <= sc->nbuttons; i++)
hid_locate(desc, size, HID_USAGE2(HUP_BUTTON, i),
diff --git a/sys/dev/usb/urio.c b/sys/dev/usb/urio.c
index 2e79871e680..ca8e549f0e2 100644
--- a/sys/dev/usb/urio.c
+++ b/sys/dev/usb/urio.c
@@ -1,5 +1,5 @@
-/* $OpenBSD: urio.c,v 1.3 2000/09/14 15:19:46 jakob Exp $ */
-/* $NetBSD: urio.c,v 1.4 2000/09/14 03:13:21 augustss Exp $ */
+/* $OpenBSD: urio.c,v 1.4 2000/11/08 18:10:38 aaron Exp $ */
+/* $NetBSD: urio.c,v 1.5 2000/10/24 14:53:59 augustss Exp $ */
/*
* Copyright (c) 2000 The NetBSD Foundation, Inc.
@@ -164,7 +164,7 @@ USB_ATTACH(urio)
USB_ATTACH_SETUP;
printf("%s: %s\n", USBDEVNAME(sc->sc_dev), devinfo);
- err = usbd_set_config_no(dev, URIO_CONFIG_NO, 0);
+ err = usbd_set_config_no(dev, URIO_CONFIG_NO, 1);
if (err) {
printf("%s: setting config no failed\n",
USBDEVNAME(sc->sc_dev));
diff --git a/sys/dev/usb/urio.h b/sys/dev/usb/urio.h
index c885b6ff5a2..30144106d0d 100644
--- a/sys/dev/usb/urio.h
+++ b/sys/dev/usb/urio.h
@@ -1,5 +1,5 @@
-/* $OpenBSD: urio.h,v 1.2 2000/07/04 11:44:24 fgsch Exp $ */
-/* $NetBSD: urio.h,v 1.1 2000/04/14 18:15:47 augustss Exp $ */
+/* $OpenBSD: urio.h,v 1.3 2000/11/08 18:10:38 aaron Exp $ */
+/* $NetBSD: urio.h,v 1.2 2000/04/27 15:26:49 augustss Exp $ */
/*
* Copyright (c) 2000 The NetBSD Foundation, Inc.
diff --git a/sys/dev/usb/usb.c b/sys/dev/usb/usb.c
index 78f98668b31..b1a0cb22b41 100644
--- a/sys/dev/usb/usb.c
+++ b/sys/dev/usb/usb.c
@@ -1,5 +1,5 @@
-/* $OpenBSD: usb.c,v 1.12 2000/07/04 11:44:24 fgsch Exp $ */
-/* $NetBSD: usb.c,v 1.43 2000/03/29 18:24:53 augustss Exp $ */
+/* $OpenBSD: usb.c,v 1.13 2000/11/08 18:10:38 aaron Exp $ */
+/* $NetBSD: usb.c,v 1.47 2000/08/24 14:12:34 augustss Exp $ */
/* $FreeBSD: src/sys/dev/usb/usb.c,v 1.20 1999/11/17 22:33:46 n_hibma Exp $ */
/*
@@ -127,7 +127,7 @@ d_open_t usbopen;
d_close_t usbclose;
d_read_t usbread;
d_ioctl_t usbioctl;
-int usbpoll __P((dev_t, int, struct proc *));
+int usbpoll(dev_t, int, struct proc *);
struct cdevsw usb_cdevsw = {
/* open */ usbopen,
@@ -147,9 +147,9 @@ struct cdevsw usb_cdevsw = {
};
#endif
-Static usbd_status usb_discover __P((struct usb_softc *));
-Static void usb_create_event_thread __P((void *));
-Static void usb_event_thread __P((void *));
+Static usbd_status usb_discover(struct usb_softc *);
+Static void usb_create_event_thread(void *);
+Static void usb_event_thread(void *);
#define USB_MAX_EVENTS 100
struct usb_event_q {
@@ -160,16 +160,11 @@ Static SIMPLEQ_HEAD(, usb_event_q) usb_events =
SIMPLEQ_HEAD_INITIALIZER(usb_events);
Static int usb_nevents = 0;
Static struct selinfo usb_selevent;
-Static struct proc *usb_async_proc; /* process who wants USB SIGIO */
+Static struct proc *usb_async_proc; /* process that wants USB SIGIO */
Static int usb_dev_open = 0;
-Static void usb_add_event __P((int, struct usb_event *));
+Static void usb_add_event(int, struct usb_event *);
-Static int usb_get_next_event __P((struct usb_event *));
-
-#if defined(__NetBSD__) || defined(__OpenBSD__)
-/* Flag to see if we are in the cold boot process. */
-extern int cold;
-#endif
+Static int usb_get_next_event(struct usb_event *);
Static const char *usbrev_str[] = USBREV_STR;
@@ -262,8 +257,7 @@ USB_ATTACH(usb)
#if defined(__NetBSD__) || defined(__OpenBSD__)
void
-usb_create_event_thread(arg)
- void *arg;
+usb_create_event_thread(void *arg)
{
struct usb_softc *sc = arg;
@@ -276,8 +270,7 @@ usb_create_event_thread(arg)
}
void
-usb_event_thread(arg)
- void *arg;
+usb_event_thread(void *arg)
{
struct usb_softc *sc = arg;
int first = 1;
@@ -315,9 +308,7 @@ usb_event_thread(arg)
}
int
-usbctlprint(aux, pnp)
- void *aux;
- const char *pnp;
+usbctlprint(void *aux, const char *pnp)
{
/* only "usb"es can attach to host controllers */
if (pnp)
@@ -328,10 +319,7 @@ usbctlprint(aux, pnp)
#endif /* defined(__NetBSD__) || defined(__OpenBSD__) */
int
-usbopen(dev, flag, mode, p)
- dev_t dev;
- int flag, mode;
- struct proc *p;
+usbopen(dev_t dev, int flag, int mode, struct proc *p)
{
int unit = minor(dev);
struct usb_softc *sc;
@@ -353,10 +341,7 @@ usbopen(dev, flag, mode, p)
}
int
-usbread(dev, uio, flag)
- dev_t dev;
- struct uio *uio;
- int flag;
+usbread(dev_t dev, struct uio *uio, int flag)
{
struct usb_event ue;
int s, error, n;
@@ -389,10 +374,7 @@ usbread(dev, uio, flag)
}
int
-usbclose(dev, flag, mode, p)
- dev_t dev;
- int flag, mode;
- struct proc *p;
+usbclose(dev_t dev, int flag, int mode, struct proc *p)
{
int unit = minor(dev);
@@ -405,12 +387,7 @@ usbclose(dev, flag, mode, p)
}
int
-usbioctl(devt, cmd, data, flag, p)
- dev_t devt;
- u_long cmd;
- caddr_t data;
- int flag;
- struct proc *p;
+usbioctl(dev_t devt, u_long cmd, caddr_t data, int flag, struct proc *p)
{
struct usb_softc *sc;
int unit = minor(devt);
@@ -537,10 +514,7 @@ usbioctl(devt, cmd, data, flag, p)
}
int
-usbpoll(dev, events, p)
- dev_t dev;
- int events;
- struct proc *p;
+usbpoll(dev_t dev, int events, struct proc *p)
{
int revents, mask, s;
@@ -583,8 +557,7 @@ usbpoll(dev, events, p)
/* Explore device tree from the root. */
usbd_status
-usb_discover(sc)
- struct usb_softc *sc;
+usb_discover(struct usb_softc *sc)
{
#if defined(__FreeBSD__)
/* The splxxx parts should be deleted when kthreads is available */
@@ -617,8 +590,7 @@ usb_discover(sc)
}
void
-usb_needs_explore(bus)
- usbd_bus_handle bus;
+usb_needs_explore(usbd_bus_handle bus)
{
bus->needs_explore = 1;
#if defined(__FreeBSD__)
@@ -630,8 +602,7 @@ usb_needs_explore(bus)
/* Called at splusb() */
int
-usb_get_next_event(ue)
- struct usb_event *ue;
+usb_get_next_event(struct usb_event *ue)
{
struct usb_event_q *ueq;
@@ -646,9 +617,7 @@ usb_get_next_event(ue)
}
void
-usbd_add_dev_event(type, udev)
- int type;
- usbd_device_handle udev;
+usbd_add_dev_event(int type, usbd_device_handle udev)
{
struct usb_event ue;
@@ -657,10 +626,7 @@ usbd_add_dev_event(type, udev)
}
void
-usbd_add_drv_event(type, udev, dev)
- int type;
- usbd_device_handle udev;
- device_ptr_t dev;
+usbd_add_drv_event(int type, usbd_device_handle udev, device_ptr_t dev)
{
struct usb_event ue;
@@ -671,9 +637,7 @@ usbd_add_drv_event(type, udev, dev)
}
Static void
-usb_add_event(type, uep)
- int type;
- struct usb_event *uep;
+usb_add_event(int type, struct usb_event *uep)
{
struct usb_event_q *ueq;
struct usb_event ue;
@@ -701,17 +665,14 @@ usb_add_event(type, uep)
splx(s);
}
void
-usb_schedsoftintr(bus)
- struct usbd_bus *bus;
+usb_schedsoftintr(struct usbd_bus *bus)
{
bus->methods->soft_intr(bus);
}
#if defined(__NetBSD__) || defined(__OpenBSD__)
int
-usb_activate(self, act)
- device_ptr_t self;
- enum devact act;
+usb_activate(device_ptr_t self, enum devact act)
{
struct usb_softc *sc = (struct usb_softc *)self;
usbd_device_handle dev = sc->sc_port.device;
@@ -734,9 +695,7 @@ usb_activate(self, act)
}
int
-usb_detach(self, flags)
- device_ptr_t self;
- int flags;
+usb_detach(device_ptr_t self, int flags)
{
struct usb_softc *sc = (struct usb_softc *)self;
struct usb_event ue;
diff --git a/sys/dev/usb/usb.h b/sys/dev/usb/usb.h
index 97ae2b8c702..956ba2fca84 100644
--- a/sys/dev/usb/usb.h
+++ b/sys/dev/usb/usb.h
@@ -1,5 +1,5 @@
-/* $OpenBSD: usb.h,v 1.10 2000/07/04 11:44:24 fgsch Exp $ */
-/* $NetBSD: usb.h,v 1.44 2000/04/03 13:40:05 augustss Exp $ */
+/* $OpenBSD: usb.h,v 1.11 2000/11/08 18:10:39 aaron Exp $ */
+/* $NetBSD: usb.h,v 1.50 2000/06/01 15:43:32 augustss Exp $ */
/* $FreeBSD: src/sys/dev/usb/usb.h,v 1.14 1999/11/17 22:33:46 n_hibma Exp $ */
/*
diff --git a/sys/dev/usb/usb_mem.c b/sys/dev/usb/usb_mem.c
index 8b97d677c56..451f9a7cfeb 100644
--- a/sys/dev/usb/usb_mem.c
+++ b/sys/dev/usb/usb_mem.c
@@ -1,5 +1,5 @@
-/* $OpenBSD: usb_mem.c,v 1.10 2000/07/04 11:44:24 fgsch Exp $ */
-/* $NetBSD: usb_mem.c,v 1.19 2000/03/27 12:33:58 augustss Exp $ */
+/* $OpenBSD: usb_mem.c,v 1.11 2000/11/08 18:10:39 aaron Exp $ */
+/* $NetBSD: usb_mem.c,v 1.21 2000/06/01 14:29:01 augustss Exp $ */
/*
* Copyright (c) 1998 The NetBSD Foundation, Inc.
@@ -82,9 +82,9 @@ struct usb_frag_dma {
LIST_ENTRY(usb_frag_dma) next;
};
-Static usbd_status usb_block_allocmem __P((bus_dma_tag_t, size_t, size_t,
- usb_dma_block_t **));
-Static void usb_block_freemem __P((usb_dma_block_t *));
+Static usbd_status usb_block_allocmem(bus_dma_tag_t, size_t, size_t,
+ usb_dma_block_t **);
+Static void usb_block_freemem(usb_dma_block_t *);
Static LIST_HEAD(, usb_dma_block) usb_blk_freelist =
LIST_HEAD_INITIALIZER(usb_blk_freelist);
@@ -94,11 +94,8 @@ Static LIST_HEAD(, usb_frag_dma) usb_frag_freelist =
LIST_HEAD_INITIALIZER(usb_frag_freelist);
Static usbd_status
-usb_block_allocmem(tag, size, align, dmap)
- bus_dma_tag_t tag;
- size_t size;
- size_t align;
- usb_dma_block_t **dmap;
+usb_block_allocmem(bus_dma_tag_t tag, size_t size, size_t align,
+ usb_dma_block_t **dmap)
{
int error;
usb_dma_block_t *p;
@@ -178,8 +175,7 @@ free:
#if 0
void
-usb_block_real_freemem(p)
- usb_dma_block_t *p;
+usb_block_real_freemem(usb_dma_block_t *p)
{
#ifdef DIAGNOSTIC
if (!curproc) {
@@ -201,8 +197,7 @@ usb_block_real_freemem(p)
* XXX when should we really free?
*/
Static void
-usb_block_freemem(p)
- usb_dma_block_t *p;
+usb_block_freemem(usb_dma_block_t *p)
{
int s;
@@ -214,11 +209,7 @@ usb_block_freemem(p)
}
usbd_status
-usb_allocmem(bus, size, align, p)
- usbd_bus_handle bus;
- size_t size;
- size_t align;
- usb_dma_t *p;
+usb_allocmem(usbd_bus_handle bus, size_t size, size_t align, usb_dma_t *p)
{
bus_dma_tag_t tag = bus->dmatag;
usbd_status err;
@@ -269,9 +260,7 @@ usb_allocmem(bus, size, align, p)
}
void
-usb_freemem(bus, p)
- usbd_bus_handle bus;
- usb_dma_t *p;
+usb_freemem(usbd_bus_handle bus, usb_dma_t *p)
{
struct usb_frag_dma *f;
int s;
diff --git a/sys/dev/usb/usb_mem.h b/sys/dev/usb/usb_mem.h
index c44ad09e1b8..23879b7e546 100644
--- a/sys/dev/usb/usb_mem.h
+++ b/sys/dev/usb/usb_mem.h
@@ -1,5 +1,5 @@
-/* $OpenBSD: usb_mem.h,v 1.7 2000/07/04 11:44:24 fgsch Exp $ */
-/* $NetBSD: usb_mem.h,v 1.12 2000/03/12 23:10:29 nathanw Exp $ */
+/* $OpenBSD: usb_mem.h,v 1.8 2000/11/08 18:10:39 aaron Exp $ */
+/* $NetBSD: usb_mem.h,v 1.15 2000/06/28 16:39:27 mrg Exp $ */
/* $FreeBSD: src/sys/dev/usb/usb_mem.h,v 1.9 1999/11/17 22:33:47 n_hibma Exp $ */
/*
@@ -55,8 +55,8 @@ typedef struct usb_dma_block {
#define DMAADDR(dma) ((dma)->block->map->dm_segs[0].ds_addr + (dma)->offs)
#define KERNADDR(dma) ((void *)((dma)->block->kaddr + (dma)->offs))
-usbd_status usb_allocmem __P((usbd_bus_handle,size_t,size_t, usb_dma_t *));
-void usb_freemem __P((usbd_bus_handle, usb_dma_t *));
+usbd_status usb_allocmem(usbd_bus_handle,size_t,size_t, usb_dma_t *);
+void usb_freemem(usbd_bus_handle, usb_dma_t *);
#elif defined(__FreeBSD__)
@@ -73,9 +73,6 @@ void usb_freemem __P((usbd_bus_handle, usb_dma_t *));
#include <sys/malloc.h>
#include <sys/kernel.h>
#include <vm/vm.h>
-#include <vm/pmap.h>
-
-#include <machine/pmap.h> /* for vtophys */
#define usb_allocmem(t,s,a,p) (*(p) = malloc(s, M_USB, M_NOWAIT), (*(p) == NULL? USBD_NOMEM: USBD_NORMAL_COMPLETION))
#define usb_freemem(t,p) (free(*(p), M_USB))
diff --git a/sys/dev/usb/usb_port.h b/sys/dev/usb/usb_port.h
index 31ec8c211e2..9408c28e9c5 100644
--- a/sys/dev/usb/usb_port.h
+++ b/sys/dev/usb/usb_port.h
@@ -1,5 +1,5 @@
-/* $OpenBSD: usb_port.h,v 1.18 2000/09/06 22:42:10 rahnds Exp $ */
-/* $NetBSD: usb_port.h,v 1.28 2000/03/30 08:53:31 augustss Exp $ */
+/* $OpenBSD: usb_port.h,v 1.19 2000/11/08 18:10:39 aaron Exp $ */
+/* $NetBSD: usb_port.h,v 1.35 2000/09/23 04:32:23 augustss Exp $ */
/* $FreeBSD: src/sys/dev/usb/usb_port.h,v 1.21 1999/11/17 22:33:47 n_hibma Exp $ */
/*
@@ -52,6 +52,7 @@
#include "opt_usbverbose.h"
#ifdef USB_DEBUG
+#define UKBD_DEBUG 1
#define UHID_DEBUG 1
#define OHCI_DEBUG 1
#define UGEN_DEBUG 1
@@ -69,6 +70,7 @@
#define UZCOM_DEBUG 1
#define URIO_DEBUG 1
#define UFTDI_DEBUG 1
+#define USCANNER_DEBUG 1
#define Static
#else
#define Static static
@@ -105,10 +107,10 @@ typedef int usb_malloc_type;
#define logprintf printf
#define USB_DECLARE_DRIVER(dname) \
-int __CONCAT(dname,_match) __P((struct device *, struct cfdata *, void *)); \
-void __CONCAT(dname,_attach) __P((struct device *, struct device *, void *)); \
-int __CONCAT(dname,_detach) __P((struct device *, int)); \
-int __CONCAT(dname,_activate) __P((struct device *, enum devact)); \
+int __CONCAT(dname,_match)(struct device *, struct cfdata *, void *); \
+void __CONCAT(dname,_attach)(struct device *, struct device *, void *); \
+int __CONCAT(dname,_detach)(struct device *, int); \
+int __CONCAT(dname,_activate)(struct device *, enum devact); \
\
extern struct cfdriver __CONCAT(dname,_cd); \
\
@@ -162,7 +164,7 @@ __CONCAT(dname,_detach)(self, flags) \
if (unit >= __CONCAT(dname,_cd).cd_ndevs) \
return (ENXIO); \
sc = __CONCAT(dname,_cd).cd_devs[unit]; \
- if (!sc) \
+ if (sc == NULL) \
return (ENXIO)
#define USB_GET_SC(dname, unit, sc) \
@@ -176,6 +178,7 @@ __CONCAT(dname,_detach)(self, flags) \
* OpenBSD
*/
#ifdef USB_DEBUG
+#define UKBD_DEBUG 1
#define UHID_DEBUG 1
#define OHCI_DEBUG 1
#define UGEN_DEBUG 1
@@ -194,6 +197,7 @@ __CONCAT(dname,_detach)(self, flags) \
#define UZCOM_DEBUG 1
#define URIO_DEBUG 1
#define UFTDI_DEBUG 1
+#define USCANNER_DEBUG 1
#endif
#define Static
@@ -222,16 +226,6 @@ __CONCAT(dname,_detach)(self, flags) \
#define bswap32(x) swap32(x)
#define bswap16(x) swap16(x)
-/*
- * The UHCI/OHCI controllers are little endian, so on big endian machines
- * the data strored in memory needs to be swapped.
- */
-
-#if defined(letoh32)
-#define le32toh(x) letoh32(x)
-#define le16toh(x) letoh16(x)
-#endif
-
#define usb_kthread_create1 kthread_create
#define usb_kthread_create kthread_create_deferred
@@ -266,7 +260,7 @@ typedef int usb_malloc_type;
#define change_sign16_le change_sign16
#define realloc usb_realloc
-void *usb_realloc __P((void *, u_int, int, int));
+void *usb_realloc(void *, u_int, int, int);
extern int cold;
@@ -291,10 +285,10 @@ typedef char usb_callout_t;
#define usb_uncallout(h, f, d) untimeout((f), (d))
#define USB_DECLARE_DRIVER(dname) \
-int __CONCAT(dname,_match) __P((struct device *, void *, void *)); \
-void __CONCAT(dname,_attach) __P((struct device *, struct device *, void *)); \
-int __CONCAT(dname,_detach) __P((struct device *, int)); \
-int __CONCAT(dname,_activate) __P((struct device *, enum devact)); \
+int __CONCAT(dname,_match)(struct device *, void *, void *); \
+void __CONCAT(dname,_attach)(struct device *, struct device *, void *); \
+int __CONCAT(dname,_detach)(struct device *, int); \
+int __CONCAT(dname,_activate)(struct device *, enum devact); \
\
struct cfdriver __CONCAT(dname,_cd) = { \
NULL, #dname, DV_DULL \
@@ -350,7 +344,7 @@ __CONCAT(dname,_detach)(self, flags) \
if (unit >= __CONCAT(dname,_cd).cd_ndevs) \
return (ENXIO); \
sc = __CONCAT(dname,_cd).cd_devs[unit]; \
- if (!sc) \
+ if (sc == NULL) \
return (ENXIO)
#define USB_GET_SC(dname, unit, sc) \
@@ -459,7 +453,7 @@ __CONCAT(dname,_detach)(device_t self)
#define USB_GET_SC_OPEN(dname, unit, sc) \
sc = devclass_get_softc(__CONCAT(dname,_devclass), unit); \
- if (!sc) \
+ if (sc == NULL) \
return (ENXIO)
#define USB_GET_SC(dname, unit, sc) \
diff --git a/sys/dev/usb/usb_quirks.c b/sys/dev/usb/usb_quirks.c
index e7494e750fc..09e198590bd 100644
--- a/sys/dev/usb/usb_quirks.c
+++ b/sys/dev/usb/usb_quirks.c
@@ -1,5 +1,5 @@
-/* $OpenBSD: usb_quirks.c,v 1.6 2000/07/04 11:44:25 fgsch Exp $ */
-/* $NetBSD: usb_quirks.c,v 1.24 2000/03/27 12:33:58 augustss Exp $ */
+/* $OpenBSD: usb_quirks.c,v 1.7 2000/11/08 18:10:39 aaron Exp $ */
+/* $NetBSD: usb_quirks.c,v 1.31 2000/10/24 14:57:35 augustss Exp $ */
/* $FreeBSD: src/sys/dev/usb/usb_quirks.c,v 1.13 1999/11/17 22:33:47 n_hibma Exp $ */
/*
@@ -58,26 +58,30 @@ Static struct usbd_quirk_entry {
struct usbd_quirks quirks;
} usb_quirks[] = {
{ USB_VENDOR_KYE, USB_PRODUCT_KYE_NICHE, 0x100, { UQ_NO_SET_PROTO}},
- { USB_VENDOR_INSIDEOUT,USB_PRODUCT_INSIDEOUT_EDGEPORT4,
+ { USB_VENDOR_INSIDEOUT, USB_PRODUCT_INSIDEOUT_EDGEPORT4,
0x094, { UQ_SWAP_UNICODE}},
{ USB_VENDOR_BTC, USB_PRODUCT_BTC_BTC7932, 0x100, { UQ_NO_STRINGS }},
{ USB_VENDOR_ADS, USB_PRODUCT_ADS_UBS10BT, 0x002, { UQ_NO_STRINGS }},
{ USB_VENDOR_PERACOM, USB_PRODUCT_PERACOM_SERIAL1, 0x101, { UQ_NO_STRINGS }},
{ USB_VENDOR_WACOM, USB_PRODUCT_WACOM_CT0405U, 0x101, { UQ_NO_STRINGS }},
{ USB_VENDOR_DALLAS, USB_PRODUCT_DALLAS_J6502, 0x0a2, { UQ_BAD_ADC }},
+ { USB_VENDOR_DALLAS, USB_PRODUCT_DALLAS_J6502, 0x0a2, { UQ_NO_XU }},
{ USB_VENDOR_ALTEC, USB_PRODUCT_ALTEC_ADA70, 0x103, { UQ_BAD_ADC }},
{ USB_VENDOR_ALTEC, USB_PRODUCT_ALTEC_ASC495, 0x000, { UQ_BAD_AUDIO }},
{ USB_VENDOR_QTRONIX, USB_PRODUCT_QTRONIX_980N, 0x110, { UQ_SPUR_BUT_UP }},
+ { USB_VENDOR_ALCOR2, USB_PRODUCT_ALCOR2_KBD_HUB, 0x001, { UQ_SPUR_BUT_UP }},
{ USB_VENDOR_MCT, USB_PRODUCT_MCT_HUB0100, 0x102, { UQ_BUS_POWERED }},
{ USB_VENDOR_MCT, USB_PRODUCT_MCT_USB232, 0x102, { UQ_BUS_POWERED }},
+ { USB_VENDOR_METRICOM, USB_PRODUCT_METRICOM_RICOCHET_GS,
+ 0x100, { UQ_ASSUME_CM_OVER_DATA | UQ_NO_STRINGS }},
+ { USB_VENDOR_TI, USB_PRODUCT_TI_UTUSB41, 0x110, { UQ_POWER_CLAIM }},
{ 0, 0, 0, { 0 } }
};
struct usbd_quirks usbd_no_quirk = { 0 };
struct usbd_quirks *
-usbd_find_quirk(d)
- usb_device_descriptor_t *d;
+usbd_find_quirk(usb_device_descriptor_t *d)
{
struct usbd_quirk_entry *t;
diff --git a/sys/dev/usb/usb_quirks.h b/sys/dev/usb/usb_quirks.h
index a8611a68f09..94212334792 100644
--- a/sys/dev/usb/usb_quirks.h
+++ b/sys/dev/usb/usb_quirks.h
@@ -1,5 +1,5 @@
-/* $OpenBSD: usb_quirks.h,v 1.5 2000/07/04 11:44:25 fgsch Exp $ */
-/* $NetBSD: usb_quirks.h,v 1.10 1999/11/18 23:32:31 augustss Exp $ */
+/* $OpenBSD: usb_quirks.h,v 1.6 2000/11/08 18:10:39 aaron Exp $ */
+/* $NetBSD: usb_quirks.h,v 1.15 2000/10/24 14:56:09 augustss Exp $ */
/* $FreeBSD: src/sys/dev/usb/usb_quirks.h,v 1.9 1999/11/12 23:31:03 n_hibma Exp $ */
/*
@@ -41,16 +41,19 @@
struct usbd_quirks {
u_int32_t uq_flags; /* Device problems: */
-#define UQ_NO_SET_PROTO 0x01 /* cannot handle SET PROTOCOL. */
-#define UQ_SWAP_UNICODE 0x02 /* has some Unicode strings swapped. */
-#define UQ_MS_REVZ 0x04 /* mouse has Z-axis reversed */
-#define UQ_NO_STRINGS 0x08 /* string descriptors are broken. */
-#define UQ_BAD_ADC 0x10 /* bad audio spec version number. */
-#define UQ_BUS_POWERED 0x20 /* device is bus powered, despite claim */
-#define UQ_BAD_AUDIO 0x40 /* device claims audio class, but isn't */
-#define UQ_SPUR_BUT_UP 0x80 /* spurious mouse button up events */
+#define UQ_NO_SET_PROTO 0x0001 /* cannot handle SET PROTOCOL. */
+#define UQ_SWAP_UNICODE 0x0002 /* has some Unicode strings swapped. */
+#define UQ_MS_REVZ 0x0004 /* mouse has Z-axis reversed */
+#define UQ_NO_STRINGS 0x0008 /* string descriptors are broken. */
+#define UQ_BAD_ADC 0x0010 /* bad audio spec version number. */
+#define UQ_BUS_POWERED 0x0020 /* device is bus powered, despite claim */
+#define UQ_BAD_AUDIO 0x0040 /* device claims audio class, but isn't */
+#define UQ_SPUR_BUT_UP 0x0080 /* spurious mouse button up events */
+#define UQ_NO_XU 0x0100 /* audio device has broken extension unit */
+#define UQ_ASSUME_CM_OVER_DATA 0x0200 /* modem device breaks on cm over data */
+#define UQ_POWER_CLAIM 0x0400 /* hub lies about power status */
};
extern struct usbd_quirks usbd_no_quirk;
-struct usbd_quirks *usbd_find_quirk __P((usb_device_descriptor_t *));
+struct usbd_quirks *usbd_find_quirk(usb_device_descriptor_t *);
diff --git a/sys/dev/usb/usb_subr.c b/sys/dev/usb/usb_subr.c
index 9e34225bea1..cba9455b243 100644
--- a/sys/dev/usb/usb_subr.c
+++ b/sys/dev/usb/usb_subr.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: usb_subr.c,v 1.13 2000/09/07 20:38:56 aaron Exp $ */
+/* $OpenBSD: usb_subr.c,v 1.14 2000/11/08 18:10:39 aaron Exp $ */
/* $NetBSD: usb_subr.c,v 1.72 2000/04/14 14:13:56 augustss Exp $ */
/* $FreeBSD: src/sys/dev/usb/usb_subr.c,v 1.18 1999/11/17 22:33:47 n_hibma Exp $ */
@@ -76,20 +76,20 @@ extern int usbdebug;
#define DPRINTFN(n,x)
#endif
-Static usbd_status usbd_set_config __P((usbd_device_handle, int));
-Static char *usbd_get_string __P((usbd_device_handle, int, char *));
-Static int usbd_getnewaddr __P((usbd_bus_handle bus));
+Static usbd_status usbd_set_config(usbd_device_handle, int);
+Static char *usbd_get_string(usbd_device_handle, int, char *);
+Static int usbd_getnewaddr(usbd_bus_handle bus);
#if defined(__NetBSD__)
-Static int usbd_print __P((void *aux, const char *pnp));
-Static int usbd_submatch __P((device_ptr_t, struct cfdata *cf, void *));
+Static int usbd_print(void *aux, const char *pnp);
+Static int usbd_submatch(device_ptr_t, struct cfdata *cf, void *);
#elif defined(__OpenBSD__)
-Static int usbd_print __P((void *aux, const char *pnp));
-Static int usbd_submatch __P((device_ptr_t, void *, void *));
+Static int usbd_print(void *aux, const char *pnp);
+Static int usbd_submatch(device_ptr_t, void *, void *);
#endif
-Static void usbd_free_iface_data __P((usbd_device_handle dev, int ifcno));
-Static void usbd_kill_pipe __P((usbd_pipe_handle));
-Static usbd_status usbd_probe_and_attach
- __P((device_ptr_t parent, usbd_device_handle dev, int port, int addr));
+Static void usbd_free_iface_data(usbd_device_handle dev, int ifcno);
+Static void usbd_kill_pipe(usbd_pipe_handle);
+Static usbd_status usbd_probe_and_attach(device_ptr_t parent,
+ usbd_device_handle dev, int port, int addr);
Static u_int32_t usb_cookie_no = 0;
@@ -135,8 +135,7 @@ Static const char *usbd_error_strs[] = {
};
const char *
-usbd_errstr(err)
- usbd_status err;
+usbd_errstr(usbd_status err)
{
static char buffer[5];
@@ -149,11 +148,8 @@ usbd_errstr(err)
}
usbd_status
-usbd_get_string_desc(dev, sindex, langid, sdesc)
- usbd_device_handle dev;
- int sindex;
- int langid;
- usb_string_descriptor_t *sdesc;
+usbd_get_string_desc(usbd_device_handle dev, int sindex, int langid,
+ usb_string_descriptor_t *sdesc)
{
usb_device_request_t req;
usbd_status err;
@@ -171,10 +167,7 @@ usbd_get_string_desc(dev, sindex, langid, sdesc)
}
char *
-usbd_get_string(dev, si, buf)
- usbd_device_handle dev;
- int si;
- char *buf;
+usbd_get_string(usbd_device_handle dev, int si, char *buf)
{
int swap = dev->quirks->uq_flags & UQ_SWAP_UNICODE;
usb_string_descriptor_t us;
@@ -217,9 +210,7 @@ usbd_get_string(dev, si, buf)
}
void
-usbd_devinfo_vp(dev, v, p)
- usbd_device_handle dev;
- char *v, *p;
+usbd_devinfo_vp(usbd_device_handle dev, char *v, char *p)
{
usb_device_descriptor_t *udd = &dev->ddesc;
char *vendor = 0, *product = 0;
@@ -253,29 +244,24 @@ usbd_devinfo_vp(dev, v, p)
}
}
#endif
- if (vendor != NULL)
+ if (vendor != NULL && *vendor)
strcpy(v, vendor);
else
sprintf(v, "vendor 0x%04x", UGETW(udd->idVendor));
- if (product != NULL)
+ if (product != NULL && *product)
strcpy(p, product);
else
sprintf(p, "product 0x%04x", UGETW(udd->idProduct));
}
int
-usbd_printBCD(cp, bcd)
- char *cp;
- int bcd;
+usbd_printBCD(char *cp, int bcd)
{
return (sprintf(cp, "%x.%02x", bcd >> 8, bcd & 0xff));
}
void
-usbd_devinfo(dev, showclass, cp)
- usbd_device_handle dev;
- int showclass;
- char *cp;
+usbd_devinfo(usbd_device_handle dev, int showclass, char *cp)
{
usb_device_descriptor_t *udd = &dev->ddesc;
char vendor[USB_MAX_STRING_LEN];
@@ -299,9 +285,7 @@ usbd_devinfo(dev, showclass, cp)
/* Delay for a certain number of ms */
void
-usb_delay_ms(bus, ms)
- usbd_bus_handle bus;
- u_int ms;
+usb_delay_ms(usbd_bus_handle bus, u_int ms)
{
/* Wait at least two clock ticks so we know the time has passed. */
if (bus->use_polling || cold)
@@ -312,18 +296,13 @@ usb_delay_ms(bus, ms)
/* Delay given a device handle. */
void
-usbd_delay_ms(dev, ms)
- usbd_device_handle dev;
- u_int ms;
+usbd_delay_ms(usbd_device_handle dev, u_int ms)
{
usb_delay_ms(dev->bus, ms);
}
usbd_status
-usbd_reset_port(dev, port, ps)
- usbd_device_handle dev;
- int port;
- usb_port_status_t *ps;
+usbd_reset_port(usbd_device_handle dev, int port, usb_port_status_t *ps)
{
usb_device_request_t req;
usbd_status err;
@@ -365,10 +344,7 @@ usbd_reset_port(dev, port, ps)
}
usb_interface_descriptor_t *
-usbd_find_idesc(cd, ifaceidx, altidx)
- usb_config_descriptor_t *cd;
- int ifaceidx;
- int altidx;
+usbd_find_idesc(usb_config_descriptor_t *cd, int ifaceidx, int altidx)
{
char *p = (char *)cd;
char *end = p + UGETW(cd->wTotalLength);
@@ -399,11 +375,8 @@ usbd_find_idesc(cd, ifaceidx, altidx)
}
usb_endpoint_descriptor_t *
-usbd_find_edesc(cd, ifaceidx, altidx, endptidx)
- usb_config_descriptor_t *cd;
- int ifaceidx;
- int altidx;
- int endptidx;
+usbd_find_edesc(usb_config_descriptor_t *cd, int ifaceidx, int altidx,
+ int endptidx)
{
char *p = (char *)cd;
char *end = p + UGETW(cd->wTotalLength);
@@ -435,10 +408,7 @@ usbd_find_edesc(cd, ifaceidx, altidx, endptidx)
}
usbd_status
-usbd_fill_iface_data(dev, ifaceidx, altidx)
- usbd_device_handle dev;
- int ifaceidx;
- int altidx;
+usbd_fill_iface_data(usbd_device_handle dev, int ifaceidx, int altidx)
{
usbd_interface_handle ifc = &dev->ifaces[ifaceidx];
usb_interface_descriptor_t *idesc;
@@ -505,9 +475,7 @@ usbd_fill_iface_data(dev, ifaceidx, altidx)
}
void
-usbd_free_iface_data(dev, ifcno)
- usbd_device_handle dev;
- int ifcno;
+usbd_free_iface_data(usbd_device_handle dev, int ifcno)
{
usbd_interface_handle ifc = &dev->ifaces[ifcno];
if (ifc->endpoints)
@@ -515,9 +483,7 @@ usbd_free_iface_data(dev, ifcno)
}
Static usbd_status
-usbd_set_config(dev, conf)
- usbd_device_handle dev;
- int conf;
+usbd_set_config(usbd_device_handle dev, int conf)
{
usb_device_request_t req;
@@ -530,10 +496,7 @@ usbd_set_config(dev, conf)
}
usbd_status
-usbd_set_config_no(dev, no, msg)
- usbd_device_handle dev;
- int no;
- int msg;
+usbd_set_config_no(usbd_device_handle dev, int no, int msg)
{
int index;
usb_config_descriptor_t cd;
@@ -555,10 +518,7 @@ usbd_set_config_no(dev, no, msg)
}
usbd_status
-usbd_set_config_index(dev, index, msg)
- usbd_device_handle dev;
- int index;
- int msg;
+usbd_set_config_index(usbd_device_handle dev, int index, int msg)
{
usb_status_t ds;
usb_config_descriptor_t cd, *cdp;
@@ -617,18 +577,43 @@ usbd_set_config_index(dev, index, msg)
/* May be self powered. */
if (cdp->bmAttributes & UC_BUS_POWERED) {
/* Must ask device. */
- err = usbd_get_device_status(dev, &ds);
- if (!err && (UGETW(ds.wStatus) & UDS_SELF_POWERED))
- selfpowered = 1;
- DPRINTF(("usbd_set_config_index: status=0x%04x, "
- "error=%s\n",
- UGETW(ds.wStatus), usbd_errstr(err)));
+ if (dev->quirks->uq_flags & UQ_POWER_CLAIM) {
+ /*
+ * Hub claims to be self powered, but isn't.
+ * It seems that the power status can be
+ * determined by the hub characteristics.
+ */
+ usb_hub_descriptor_t hd;
+ usb_device_request_t req;
+ req.bmRequestType = UT_READ_CLASS_DEVICE;
+ req.bRequest = UR_GET_DESCRIPTOR;
+ USETW(req.wValue, 0);
+ USETW(req.wIndex, 0);
+ USETW(req.wLength, USB_HUB_DESCRIPTOR_SIZE);
+ err = usbd_do_request(dev, &req, &hd);
+ if (!err &&
+ (UGETW(hd.wHubCharacteristics) &
+ UHD_PWR_INDIVIDUAL))
+ selfpowered = 1;
+ DPRINTF(("usbd_set_config_index: charac=0x%04x"
+ ", error=%s\n",
+ UGETW(hd.wHubCharacteristics),
+ usbd_errstr(err)));
+ } else {
+ err = usbd_get_device_status(dev, &ds);
+ if (!err &&
+ (UGETW(ds.wStatus) & UDS_SELF_POWERED))
+ selfpowered = 1;
+ DPRINTF(("usbd_set_config_index: status=0x%04x"
+ ", error=%s\n",
+ UGETW(ds.wStatus), usbd_errstr(err)));
+ }
} else
selfpowered = 1;
}
- DPRINTF(("usbd_set_config_index: (addr %d) attr=0x%02x, "
- "selfpowered=%d, power=%d\n",
- dev->address, cdp->bmAttributes,
+ DPRINTF(("usbd_set_config_index: (addr %d) cno=%d attr=0x%02x, "
+ "selfpowered=%d, power=%d\n",
+ cdp->bConfigurationValue, dev->address, cdp->bmAttributes,
selfpowered, cdp->bMaxPower * 2));
/* Check if we have enough power. */
@@ -640,6 +625,7 @@ usbd_set_config_index(dev, index, msg)
#endif
power = cdp->bMaxPower * 2;
if (power > dev->powersrc->power) {
+ DPRINTF(("power exceeded %d %d\n", power,dev->powersrc->power));
/* XXX print nicer message. */
if (msg)
printf("%s: device addr %d (config %d) exceeds power "
@@ -694,12 +680,8 @@ usbd_set_config_index(dev, index, msg)
/* XXX add function for alternate settings */
usbd_status
-usbd_setup_pipe(dev, iface, ep, ival, pipe)
- usbd_device_handle dev;
- usbd_interface_handle iface;
- struct usbd_endpoint *ep;
- int ival;
- usbd_pipe_handle *pipe;
+usbd_setup_pipe(usbd_device_handle dev, usbd_interface_handle iface,
+ struct usbd_endpoint *ep, int ival, usbd_pipe_handle *pipe)
{
usbd_pipe_handle p;
usbd_status err;
@@ -738,8 +720,7 @@ usbd_setup_pipe(dev, iface, ep, ival, pipe)
/* Abort the device control pipe. */
void
-usbd_kill_pipe(pipe)
- usbd_pipe_handle pipe;
+usbd_kill_pipe(usbd_pipe_handle pipe)
{
pipe->methods->close(pipe);
pipe->endpoint->refcnt--;
@@ -747,8 +728,7 @@ usbd_kill_pipe(pipe)
}
int
-usbd_getnewaddr(bus)
- usbd_bus_handle bus;
+usbd_getnewaddr(usbd_bus_handle bus)
{
int addr;
@@ -760,11 +740,8 @@ usbd_getnewaddr(bus)
usbd_status
-usbd_probe_and_attach(parent, dev, port, addr)
- device_ptr_t parent;
- usbd_device_handle dev;
- int port;
- int addr;
+usbd_probe_and_attach(device_ptr_t parent, usbd_device_handle dev,
+ int port, int addr)
{
struct usb_attach_arg uaa;
usb_device_descriptor_t *dd = &dev->ddesc;
@@ -926,13 +903,8 @@ usbd_probe_and_attach(parent, dev, port, addr)
* and attach a driver.
*/
usbd_status
-usbd_new_device(parent, bus, depth, lowspeed, port, up)
- device_ptr_t parent;
- usbd_bus_handle bus;
- int depth;
- int lowspeed;
- int port;
- struct usbd_port *up;
+usbd_new_device(device_ptr_t parent, usbd_bus_handle bus, int depth,
+ int lowspeed, int port, struct usbd_port *up)
{
usbd_device_handle dev;
usb_device_descriptor_t *dd;
@@ -1065,8 +1037,7 @@ usbd_new_device(parent, bus, depth, lowspeed, port, up)
}
usbd_status
-usbd_reload_device_desc(dev)
- usbd_device_handle dev;
+usbd_reload_device_desc(usbd_device_handle dev)
{
usbd_status err;
@@ -1082,9 +1053,7 @@ usbd_reload_device_desc(dev)
}
void
-usbd_remove_device(dev, up)
- usbd_device_handle dev;
- struct usbd_port *up;
+usbd_remove_device(usbd_device_handle dev, struct usbd_port *up)
{
DPRINTF(("usbd_remove_device: %p\n", dev));
@@ -1098,9 +1067,7 @@ usbd_remove_device(dev, up)
#if defined(__NetBSD__) || defined(__OpenBSD__)
int
-usbd_print(aux, pnp)
- void *aux;
- const char *pnp;
+usbd_print(void *aux, const char *pnp)
{
struct usb_attach_arg *uaa = aux;
char devinfo[1024];
@@ -1136,17 +1103,11 @@ usbd_print(aux, pnp)
#if defined(__NetBSD__)
int
-usbd_submatch(parent, cf, aux)
- struct device *parent;
- struct cfdata *cf;
- void *aux;
+usbd_submatch(struct device *parent, struct cfdata *cf, void *aux)
{
#elif defined(__OpenBSD__)
int
-usbd_submatch(parent, match, aux)
- struct device *parent;
- void *match;
- void *aux;
+usbd_submatch(struct device *parent, void *match, void *aux)
{
struct cfdata *cf = match;
#endif
@@ -1188,9 +1149,7 @@ usbd_submatch(parent, match, aux)
#endif
void
-usbd_fill_deviceinfo(dev, di)
- usbd_device_handle dev;
- struct usb_device_info *di;
+usbd_fill_deviceinfo(usbd_device_handle dev, struct usb_device_info *di)
{
struct usbd_port *p;
int i, err, s;
@@ -1250,8 +1209,7 @@ usbd_fill_deviceinfo(dev, di)
}
void
-usb_free_device(dev)
- usbd_device_handle dev;
+usb_free_device(usbd_device_handle dev)
{
int ifcidx, nifc;
@@ -1288,9 +1246,7 @@ usb_free_device(dev)
* been disconnected.
*/
void
-usb_disconnect_port(up, parent)
- struct usbd_port *up;
- device_ptr_t parent;
+usb_disconnect_port(struct usbd_port *up, device_ptr_t parent)
{
usbd_device_handle dev = up->device;
char *hubname = USBDEVPTRNAME(parent);
@@ -1331,11 +1287,7 @@ usb_disconnect_port(up, parent)
}
#ifdef __OpenBSD__
-void *usb_realloc(p, size, pool, flags)
- void *p;
- u_int size;
- int pool;
- int flags;
+void *usb_realloc(void *p, u_int size, int pool, int flags)
{
void *q;
diff --git a/sys/dev/usb/usbcdc.h b/sys/dev/usb/usbcdc.h
index 35242e979c6..1b877d2ea6b 100644
--- a/sys/dev/usb/usbcdc.h
+++ b/sys/dev/usb/usbcdc.h
@@ -1,5 +1,5 @@
-/* $OpenBSD: usbcdc.h,v 1.3 2000/07/04 11:44:25 fgsch Exp $ */
-/* $NetBSD: usbcdc.h,v 1.5 1999/11/18 23:32:32 augustss Exp $ */
+/* $OpenBSD: usbcdc.h,v 1.4 2000/11/08 18:10:39 aaron Exp $ */
+/* $NetBSD: usbcdc.h,v 1.7 2000/05/30 10:10:18 augustss Exp $ */
/* $FreeBSD: src/sys/dev/usb/usbcdc.h,v 1.7 1999/11/17 22:33:48 n_hibma Exp $ */
/*
diff --git a/sys/dev/usb/usbdi.c b/sys/dev/usb/usbdi.c
index bf37703bb65..212888b4860 100644
--- a/sys/dev/usb/usbdi.c
+++ b/sys/dev/usb/usbdi.c
@@ -1,5 +1,5 @@
-/* $OpenBSD: usbdi.c,v 1.11 2000/07/04 11:44:25 fgsch Exp $ */
-/* $NetBSD: usbdi.c,v 1.71 2000/03/29 01:45:21 augustss Exp $ */
+/* $OpenBSD: usbdi.c,v 1.12 2000/11/08 18:10:39 aaron Exp $ */
+/* $NetBSD: usbdi.c,v 1.77 2000/09/23 21:02:04 augustss Exp $ */
/* $FreeBSD: src/sys/dev/usb/usbdi.c,v 1.28 1999/11/17 22:33:49 n_hibma Exp $ */
/*
@@ -77,31 +77,29 @@ extern int usbdebug;
#define DPRINTFN(n,x)
#endif
-Static usbd_status usbd_ar_pipe __P((usbd_pipe_handle pipe));
+Static usbd_status usbd_ar_pipe(usbd_pipe_handle pipe);
Static void usbd_do_request_async_cb
- __P((usbd_xfer_handle, usbd_private_handle, usbd_status));
-Static void usbd_start_next __P((usbd_pipe_handle pipe));
+(usbd_xfer_handle, usbd_private_handle, usbd_status);
+Static void usbd_start_next(usbd_pipe_handle pipe);
Static usbd_status usbd_open_pipe_ival
- __P((usbd_interface_handle, u_int8_t, u_int8_t, usbd_pipe_handle *, int));
+(usbd_interface_handle, u_int8_t, u_int8_t, usbd_pipe_handle *, int);
Static int usbd_nbuses = 0;
void
-usbd_init()
+usbd_init(void)
{
usbd_nbuses++;
}
void
-usbd_finish()
+usbd_finish(void)
{
--usbd_nbuses;
}
-Static __inline int usbd_xfer_isread __P((usbd_xfer_handle xfer));
-Static __inline int
-usbd_xfer_isread(xfer)
- usbd_xfer_handle xfer;
+static __inline int
+usbd_xfer_isread(usbd_xfer_handle xfer)
{
if (xfer->rqflags & URQ_REQUEST)
return (xfer->request.bmRequestType & UT_READ);
@@ -111,11 +109,9 @@ usbd_xfer_isread(xfer)
}
#ifdef USB_DEBUG
-void usbd_dump_queue __P((usbd_pipe_handle));
-
+void usbd_dump_queue(usbd_pipe_handle pipe);
void
-usbd_dump_queue(pipe)
- usbd_pipe_handle pipe;
+usbd_dump_queue(usbd_pipe_handle pipe)
{
usbd_xfer_handle xfer;
@@ -129,23 +125,16 @@ usbd_dump_queue(pipe)
#endif
usbd_status
-usbd_open_pipe(iface, address, flags, pipe)
- usbd_interface_handle iface;
- u_int8_t address;
- u_int8_t flags;
- usbd_pipe_handle *pipe;
+usbd_open_pipe(usbd_interface_handle iface, u_int8_t address,
+ u_int8_t flags, usbd_pipe_handle *pipe)
{
return (usbd_open_pipe_ival(iface, address, flags, pipe,
USBD_DEFAULT_INTERVAL));
}
usbd_status
-usbd_open_pipe_ival(iface, address, flags, pipe, ival)
- usbd_interface_handle iface;
- u_int8_t address;
- u_int8_t flags;
- usbd_pipe_handle *pipe;
- int ival;
+usbd_open_pipe_ival(usbd_interface_handle iface, u_int8_t address,
+ u_int8_t flags, usbd_pipe_handle *pipe, int ival)
{
usbd_pipe_handle p;
struct usbd_endpoint *ep;
@@ -175,16 +164,10 @@ usbd_open_pipe_ival(iface, address, flags, pipe, ival)
}
usbd_status
-usbd_open_pipe_intr(iface, address, flags, pipe, priv, buffer, len, cb, ival)
- usbd_interface_handle iface;
- u_int8_t address;
- u_int8_t flags;
- usbd_pipe_handle *pipe;
- usbd_private_handle priv;
- void *buffer;
- u_int32_t len;
- usbd_callback cb;
- int ival;
+usbd_open_pipe_intr(usbd_interface_handle iface, u_int8_t address,
+ u_int8_t flags, usbd_pipe_handle *pipe,
+ usbd_private_handle priv, void *buffer, u_int32_t len,
+ usbd_callback cb, int ival)
{
usbd_status err;
usbd_xfer_handle xfer;
@@ -222,8 +205,7 @@ usbd_open_pipe_intr(iface, address, flags, pipe, priv, buffer, len, cb, ival)
}
usbd_status
-usbd_close_pipe(pipe)
- usbd_pipe_handle pipe;
+usbd_close_pipe(usbd_pipe_handle pipe)
{
#ifdef DIAGNOSTIC
if (pipe == NULL) {
@@ -252,8 +234,7 @@ usbd_close_pipe(pipe)
}
usbd_status
-usbd_transfer(xfer)
- usbd_xfer_handle xfer;
+usbd_transfer(usbd_xfer_handle xfer)
{
usbd_pipe_handle pipe = xfer->pipe;
usb_dma_t *dmap = &xfer->dmabuf;
@@ -340,17 +321,14 @@ usbd_transfer(xfer)
/* Like usbd_transfer(), but waits for completion. */
usbd_status
-usbd_sync_transfer(xfer)
- usbd_xfer_handle xfer;
+usbd_sync_transfer(usbd_xfer_handle xfer)
{
xfer->flags |= USBD_SYNCHRONOUS;
return (usbd_transfer(xfer));
}
void *
-usbd_alloc_buffer(xfer, size)
- usbd_xfer_handle xfer;
- u_int32_t size;
+usbd_alloc_buffer(usbd_xfer_handle xfer, u_int32_t size)
{
struct usbd_bus *bus = xfer->device->bus;
usbd_status err;
@@ -363,8 +341,7 @@ usbd_alloc_buffer(xfer, size)
}
void
-usbd_free_buffer(xfer)
- usbd_xfer_handle xfer;
+usbd_free_buffer(usbd_xfer_handle xfer)
{
#ifdef DIAGNOSTIC
if (!(xfer->rqflags & (URQ_DEV_DMABUF | URQ_AUTO_DMABUF))) {
@@ -377,8 +354,7 @@ usbd_free_buffer(xfer)
}
void *
-usbd_get_buffer(xfer)
- usbd_xfer_handle xfer;
+usbd_get_buffer(usbd_xfer_handle xfer)
{
if (!(xfer->rqflags & URQ_DEV_DMABUF))
return (0);
@@ -386,8 +362,7 @@ usbd_get_buffer(xfer)
}
usbd_xfer_handle
-usbd_alloc_xfer(dev)
- usbd_device_handle dev;
+usbd_alloc_xfer(usbd_device_handle dev)
{
usbd_xfer_handle xfer;
@@ -401,8 +376,7 @@ usbd_alloc_xfer(dev)
}
usbd_status
-usbd_free_xfer(xfer)
- usbd_xfer_handle xfer;
+usbd_free_xfer(usbd_xfer_handle xfer)
{
DPRINTFN(5,("usbd_free_xfer: %p\n", xfer));
if (xfer->rqflags & (URQ_DEV_DMABUF | URQ_AUTO_DMABUF))
@@ -418,17 +392,10 @@ usbd_free_xfer(xfer)
}
void
-usbd_setup_xfer(xfer, pipe, priv, buffer, length, flags, timeout, callback)
- usbd_xfer_handle xfer;
- usbd_pipe_handle pipe;
- usbd_private_handle priv;
- void *buffer;
- u_int32_t length;
- u_int16_t flags;
- u_int32_t timeout;
- void (*callback) __P((usbd_xfer_handle,
- usbd_private_handle,
- usbd_status));
+usbd_setup_xfer(usbd_xfer_handle xfer, usbd_pipe_handle pipe,
+ usbd_private_handle priv, void *buffer, u_int32_t length,
+ u_int16_t flags, u_int32_t timeout,
+ usbd_callback callback)
{
xfer->pipe = pipe;
xfer->priv = priv;
@@ -444,19 +411,11 @@ usbd_setup_xfer(xfer, pipe, priv, buffer, length, flags, timeout, callback)
}
void
-usbd_setup_default_xfer(xfer, dev, priv, timeout, req, buffer,
- length, flags, callback)
- usbd_xfer_handle xfer;
- usbd_device_handle dev;
- usbd_private_handle priv;
- u_int32_t timeout;
- usb_device_request_t *req;
- void *buffer;
- u_int32_t length;
- u_int16_t flags;
- void (*callback) __P((usbd_xfer_handle,
- usbd_private_handle,
- usbd_status));
+usbd_setup_default_xfer(usbd_xfer_handle xfer, usbd_device_handle dev,
+ usbd_private_handle priv, u_int32_t timeout,
+ usb_device_request_t *req, void *buffer,
+ u_int32_t length, u_int16_t flags,
+ usbd_callback callback)
{
xfer->pipe = dev->default_pipe;
xfer->priv = priv;
@@ -473,14 +432,9 @@ usbd_setup_default_xfer(xfer, dev, priv, timeout, req, buffer,
}
void
-usbd_setup_isoc_xfer(xfer, pipe, priv, frlengths, nframes, flags, callback)
- usbd_xfer_handle xfer;
- usbd_pipe_handle pipe;
- usbd_private_handle priv;
- u_int16_t *frlengths;
- u_int32_t nframes;
- u_int16_t flags;
- usbd_callback callback;
+usbd_setup_isoc_xfer(usbd_xfer_handle xfer, usbd_pipe_handle pipe,
+ usbd_private_handle priv, u_int16_t *frlengths,
+ u_int32_t nframes, u_int16_t flags, usbd_callback callback)
{
xfer->pipe = pipe;
xfer->priv = priv;
@@ -497,12 +451,8 @@ usbd_setup_isoc_xfer(xfer, pipe, priv, frlengths, nframes, flags, callback)
}
void
-usbd_get_xfer_status(xfer, priv, buffer, count, status)
- usbd_xfer_handle xfer;
- usbd_private_handle *priv;
- void **buffer;
- u_int32_t *count;
- usbd_status *status;
+usbd_get_xfer_status(usbd_xfer_handle xfer, usbd_private_handle *priv,
+ void **buffer, u_int32_t *count, usbd_status *status)
{
if (priv != NULL)
*priv = xfer->priv;
@@ -515,8 +465,7 @@ usbd_get_xfer_status(xfer, priv, buffer, count, status)
}
usb_config_descriptor_t *
-usbd_get_config_descriptor(dev)
- usbd_device_handle dev;
+usbd_get_config_descriptor(usbd_device_handle dev)
{
#ifdef DIAGNOSTIC
if (dev == NULL) {
@@ -528,8 +477,7 @@ usbd_get_config_descriptor(dev)
}
usb_interface_descriptor_t *
-usbd_get_interface_descriptor(iface)
- usbd_interface_handle iface;
+usbd_get_interface_descriptor(usbd_interface_handle iface)
{
#ifdef DIAGNOSTIC
if (iface == NULL) {
@@ -541,16 +489,13 @@ usbd_get_interface_descriptor(iface)
}
usb_device_descriptor_t *
-usbd_get_device_descriptor(dev)
- usbd_device_handle dev;
+usbd_get_device_descriptor(usbd_device_handle dev)
{
return (&dev->ddesc);
}
usb_endpoint_descriptor_t *
-usbd_interface2endpoint_descriptor(iface, index)
- usbd_interface_handle iface;
- u_int8_t index;
+usbd_interface2endpoint_descriptor(usbd_interface_handle iface, u_int8_t index)
{
if (index >= iface->idesc->bNumEndpoints)
return (0);
@@ -558,8 +503,7 @@ usbd_interface2endpoint_descriptor(iface, index)
}
usbd_status
-usbd_abort_pipe(pipe)
- usbd_pipe_handle pipe;
+usbd_abort_pipe(usbd_pipe_handle pipe)
{
usbd_status err;
int s;
@@ -577,8 +521,7 @@ usbd_abort_pipe(pipe)
}
usbd_status
-usbd_clear_endpoint_stall(pipe)
- usbd_pipe_handle pipe;
+usbd_clear_endpoint_stall(usbd_pipe_handle pipe)
{
usbd_device_handle dev = pipe->device;
usb_device_request_t req;
@@ -609,8 +552,7 @@ XXX should we do this?
}
usbd_status
-usbd_clear_endpoint_stall_async(pipe)
- usbd_pipe_handle pipe;
+usbd_clear_endpoint_stall_async(usbd_pipe_handle pipe)
{
usbd_device_handle dev = pipe->device;
usb_device_request_t req;
@@ -629,16 +571,13 @@ usbd_clear_endpoint_stall_async(pipe)
void usbd_clear_endpoint_toggle(usbd_pipe_handle pipe); /* XXXXX */
void
-usbd_clear_endpoint_toggle(pipe)
- usbd_pipe_handle pipe;
+usbd_clear_endpoint_toggle(usbd_pipe_handle pipe)
{
pipe->methods->cleartoggle(pipe);
}
usbd_status
-usbd_endpoint_count(iface, count)
- usbd_interface_handle iface;
- u_int8_t *count;
+usbd_endpoint_count(usbd_interface_handle iface, u_int8_t *count)
{
#ifdef DIAGNOSTIC
if (iface == NULL || iface->idesc == NULL) {
@@ -651,9 +590,7 @@ usbd_endpoint_count(iface, count)
}
usbd_status
-usbd_interface_count(dev, count)
- usbd_device_handle dev;
- u_int8_t *count;
+usbd_interface_count(usbd_device_handle dev, u_int8_t *count)
{
if (dev->cdesc == NULL)
return (USBD_NOT_CONFIGURED);
@@ -662,19 +599,16 @@ usbd_interface_count(dev, count)
}
usbd_status
-usbd_interface2device_handle(iface, dev)
- usbd_interface_handle iface;
- usbd_device_handle *dev;
+usbd_interface2device_handle(usbd_interface_handle iface,
+ usbd_device_handle *dev)
{
*dev = iface->device;
return (USBD_NORMAL_COMPLETION);
}
usbd_status
-usbd_device2interface_handle(dev, ifaceno, iface)
- usbd_device_handle dev;
- u_int8_t ifaceno;
- usbd_interface_handle *iface;
+usbd_device2interface_handle(usbd_device_handle dev,
+ u_int8_t ifaceno, usbd_interface_handle *iface)
{
if (dev->cdesc == NULL)
return (USBD_NOT_CONFIGURED);
@@ -685,17 +619,14 @@ usbd_device2interface_handle(dev, ifaceno, iface)
}
usbd_device_handle
-usbd_pipe2device_handle(pipe)
- usbd_pipe_handle pipe;
+usbd_pipe2device_handle(usbd_pipe_handle pipe)
{
return (pipe->device);
}
/* XXXX use altno */
usbd_status
-usbd_set_interface(iface, altidx)
- usbd_interface_handle iface;
- int altidx;
+usbd_set_interface(usbd_interface_handle iface, int altidx)
{
usb_device_request_t req;
usbd_status err;
@@ -729,9 +660,7 @@ usbd_set_interface(iface, altidx)
}
int
-usbd_get_no_alts(cdesc, ifaceno)
- usb_config_descriptor_t *cdesc;
- int ifaceno;
+usbd_get_no_alts(usb_config_descriptor_t *cdesc, int ifaceno)
{
char *p = (char *)cdesc;
char *end = p + UGETW(cdesc->wTotalLength);
@@ -749,16 +678,13 @@ usbd_get_no_alts(cdesc, ifaceno)
}
int
-usbd_get_interface_altindex(iface)
- usbd_interface_handle iface;
+usbd_get_interface_altindex(usbd_interface_handle iface)
{
return (iface->altindex);
}
usbd_status
-usbd_get_interface(iface, aiface)
- usbd_interface_handle iface;
- u_int8_t *aiface;
+usbd_get_interface(usbd_interface_handle iface, u_int8_t *aiface)
{
usb_device_request_t req;
@@ -774,8 +700,7 @@ usbd_get_interface(iface, aiface)
/* Dequeue all pipe operations, called at splusb(). */
Static usbd_status
-usbd_ar_pipe(pipe)
- usbd_pipe_handle pipe;
+usbd_ar_pipe(usbd_pipe_handle pipe)
{
usbd_xfer_handle xfer;
@@ -801,8 +726,7 @@ usbd_ar_pipe(pipe)
/* Called at splusb() */
void
-usb_transfer_complete(xfer)
- usbd_xfer_handle xfer;
+usb_transfer_complete(usbd_xfer_handle xfer)
{
usbd_pipe_handle pipe = xfer->pipe;
usb_dma_t *dmap = &xfer->dmabuf;
@@ -897,8 +821,7 @@ usb_transfer_complete(xfer)
}
usbd_status
-usb_insert_transfer(xfer)
- usbd_xfer_handle xfer;
+usb_insert_transfer(usbd_xfer_handle xfer)
{
usbd_pipe_handle pipe = xfer->pipe;
usbd_status err;
@@ -920,8 +843,7 @@ usb_insert_transfer(xfer)
/* Called at splusb() */
void
-usbd_start_next(pipe)
- usbd_pipe_handle pipe;
+usbd_start_next(usbd_pipe_handle pipe)
{
usbd_xfer_handle xfer;
usbd_status err;
@@ -955,21 +877,22 @@ usbd_start_next(pipe)
}
usbd_status
-usbd_do_request(dev, req, data)
- usbd_device_handle dev;
- usb_device_request_t *req;
- void *data;
+usbd_do_request(usbd_device_handle dev, usb_device_request_t *req, void *data)
{
return (usbd_do_request_flags(dev, req, data, 0, 0));
}
usbd_status
-usbd_do_request_flags(dev, req, data, flags, actlen)
- usbd_device_handle dev;
- usb_device_request_t *req;
- void *data;
- u_int16_t flags;
- int *actlen;
+usbd_do_request_flags(usbd_device_handle dev, usb_device_request_t *req,
+ void *data, u_int16_t flags, int *actlen)
+{
+ return (usbd_do_request_flags_pipe(dev, dev->default_pipe, req,
+ data, flags, actlen));
+}
+
+usbd_status
+usbd_do_request_flags_pipe(usbd_device_handle dev, usbd_pipe_handle pipe,
+ usb_device_request_t *req, void *data, u_int16_t flags, int *actlen)
{
usbd_xfer_handle xfer;
usbd_status err;
@@ -989,7 +912,8 @@ usbd_do_request_flags(dev, req, data, flags, actlen)
if (xfer == NULL)
return (USBD_NOMEM);
usbd_setup_default_xfer(xfer, dev, 0, USBD_DEFAULT_TIMEOUT, req,
- data, UGETW(req->wLength), flags, 0);
+ data, UGETW(req->wLength), flags, 0);
+ xfer->pipe = pipe;
err = usbd_sync_transfer(xfer);
#if defined(USB_DEBUG) || defined(DIAGNOSTIC)
if (xfer->actlen > xfer->length)
@@ -1047,10 +971,8 @@ usbd_do_request_flags(dev, req, data, flags, actlen)
}
void
-usbd_do_request_async_cb(xfer, priv, status)
- usbd_xfer_handle xfer;
- usbd_private_handle priv;
- usbd_status status;
+usbd_do_request_async_cb(usbd_xfer_handle xfer, usbd_private_handle priv,
+ usbd_status status)
{
#if defined(USB_DEBUG) || defined(DIAGNOSTIC)
if (xfer->actlen > xfer->length)
@@ -1071,10 +993,8 @@ usbd_do_request_async_cb(xfer, priv, status)
* Can be used from interrupt context.
*/
usbd_status
-usbd_do_request_async(dev, req, data)
- usbd_device_handle dev;
- usb_device_request_t *req;
- void *data;
+usbd_do_request_async(usbd_device_handle dev, usb_device_request_t *req,
+ void *data)
{
usbd_xfer_handle xfer;
usbd_status err;
@@ -1093,8 +1013,7 @@ usbd_do_request_async(dev, req, data)
}
struct usbd_quirks *
-usbd_get_quirks(dev)
- usbd_device_handle dev;
+usbd_get_quirks(usbd_device_handle dev)
{
return (dev->quirks);
}
@@ -1105,16 +1024,13 @@ usbd_get_quirks(dev)
* Called from keyboard driver when in polling mode.
*/
void
-usbd_dopoll(iface)
- usbd_interface_handle iface;
+usbd_dopoll(usbd_interface_handle iface)
{
iface->device->bus->methods->do_poll(iface->device->bus);
}
void
-usbd_set_polling(dev, on)
- usbd_device_handle dev;
- int on;
+usbd_set_polling(usbd_device_handle dev, int on)
{
if (on)
dev->bus->use_polling++;
@@ -1124,9 +1040,7 @@ usbd_set_polling(dev, on)
usb_endpoint_descriptor_t *
-usbd_get_endpoint_descriptor(iface, address)
- usbd_interface_handle iface;
- u_int8_t address;
+usbd_get_endpoint_descriptor(usbd_interface_handle iface, u_int8_t address)
{
struct usbd_endpoint *ep;
int i;
@@ -1146,8 +1060,7 @@ usbd_get_endpoint_descriptor(iface, address)
* this can generate a large number of messages.
*/
int
-usbd_ratecheck(last)
- struct timeval *last;
+usbd_ratecheck(struct timeval *last)
{
static struct timeval errinterval = { 0, 250000 }; /* 0.25 s*/
diff --git a/sys/dev/usb/usbdi.h b/sys/dev/usb/usbdi.h
index e253ffdeab9..603324a3d64 100644
--- a/sys/dev/usb/usbdi.h
+++ b/sys/dev/usb/usbdi.h
@@ -1,5 +1,5 @@
-/* $OpenBSD: usbdi.h,v 1.9 2000/07/04 11:44:25 fgsch Exp $ */
-/* $NetBSD: usbdi.h,v 1.41 2000/03/02 12:37:51 augustss Exp $ */
+/* $OpenBSD: usbdi.h,v 1.10 2000/11/08 18:10:39 aaron Exp $ */
+/* $NetBSD: usbdi.h,v 1.44 2000/09/23 21:02:04 augustss Exp $ */
/* $FreeBSD: src/sys/dev/usb/usbdi.h,v 1.18 1999/11/17 22:33:49 n_hibma Exp $ */
/*
@@ -71,8 +71,8 @@ typedef enum { /* keep in sync with usbd_status_msgs */
USBD_ERROR_MAX, /* must be last */
} usbd_status;
-typedef void (*usbd_callback) __P((usbd_xfer_handle, usbd_private_handle,
- usbd_status));
+typedef void (*usbd_callback)(usbd_xfer_handle, usbd_private_handle,
+ usbd_status);
/* Open flags */
#define USBD_EXCLUSIVE_USE 0x01
@@ -96,97 +96,88 @@ typedef void (*usbd_callback) __P((usbd_xfer_handle, usbd_private_handle,
#define USB_CDEV_MAJOR 108
#endif
-usbd_status usbd_open_pipe
- __P((usbd_interface_handle iface, u_int8_t address,
- u_int8_t flags, usbd_pipe_handle *pipe));
-usbd_status usbd_close_pipe __P((usbd_pipe_handle pipe));
-usbd_status usbd_transfer __P((usbd_xfer_handle req));
-usbd_xfer_handle usbd_alloc_xfer __P((usbd_device_handle));
-usbd_status usbd_free_xfer __P((usbd_xfer_handle xfer));
-void usbd_setup_xfer
- __P((usbd_xfer_handle xfer, usbd_pipe_handle pipe,
- usbd_private_handle priv, void *buffer,
- u_int32_t length, u_int16_t flags, u_int32_t timeout,
- usbd_callback));
-void usbd_setup_default_xfer
- __P((usbd_xfer_handle xfer, usbd_device_handle dev,
- usbd_private_handle priv, u_int32_t timeout,
- usb_device_request_t *req, void *buffer,
- u_int32_t length, u_int16_t flags, usbd_callback));
-void usbd_setup_isoc_xfer
- __P((usbd_xfer_handle xfer, usbd_pipe_handle pipe,
- usbd_private_handle priv, u_int16_t *frlengths,
- u_int32_t nframes, u_int16_t flags, usbd_callback));
-void usbd_get_xfer_status
- __P((usbd_xfer_handle xfer, usbd_private_handle *priv,
- void **buffer, u_int32_t *count, usbd_status *status));
+usbd_status usbd_open_pipe(usbd_interface_handle iface, u_int8_t address,
+ u_int8_t flags, usbd_pipe_handle *pipe);
+usbd_status usbd_close_pipe(usbd_pipe_handle pipe);
+usbd_status usbd_transfer(usbd_xfer_handle req);
+usbd_xfer_handle usbd_alloc_xfer(usbd_device_handle);
+usbd_status usbd_free_xfer(usbd_xfer_handle xfer);
+void usbd_setup_xfer(usbd_xfer_handle xfer, usbd_pipe_handle pipe,
+ usbd_private_handle priv, void *buffer,
+ u_int32_t length, u_int16_t flags, u_int32_t timeout,
+ usbd_callback);
+void usbd_setup_default_xfer(usbd_xfer_handle xfer, usbd_device_handle dev,
+ usbd_private_handle priv, u_int32_t timeout,
+ usb_device_request_t *req, void *buffer,
+ u_int32_t length, u_int16_t flags, usbd_callback);
+void usbd_setup_isoc_xfer(usbd_xfer_handle xfer, usbd_pipe_handle pipe,
+ usbd_private_handle priv, u_int16_t *frlengths,
+ u_int32_t nframes, u_int16_t flags, usbd_callback);
+void usbd_get_xfer_status(usbd_xfer_handle xfer, usbd_private_handle *priv,
+ void **buffer, u_int32_t *count, usbd_status *status);
usb_endpoint_descriptor_t *usbd_interface2endpoint_descriptor
- __P((usbd_interface_handle iface, u_int8_t address));
-usbd_status usbd_abort_pipe __P((usbd_pipe_handle pipe));
-usbd_status usbd_clear_endpoint_stall __P((usbd_pipe_handle pipe));
-usbd_status usbd_clear_endpoint_stall_async __P((usbd_pipe_handle pipe));
-usbd_status usbd_endpoint_count
- __P((usbd_interface_handle dev, u_int8_t *count));
-usbd_status usbd_interface_count
- __P((usbd_device_handle dev, u_int8_t *count));
-usbd_status usbd_interface2device_handle
- __P((usbd_interface_handle iface, usbd_device_handle *dev));
-usbd_status usbd_device2interface_handle
- __P((usbd_device_handle dev, u_int8_t ifaceno, usbd_interface_handle *iface));
-
-usbd_device_handle usbd_pipe2device_handle __P((usbd_pipe_handle));
-void *usbd_alloc_buffer __P((usbd_xfer_handle req, u_int32_t size));
-void usbd_free_buffer __P((usbd_xfer_handle req));
-void *usbd_get_buffer __P((usbd_xfer_handle xfer));
-usbd_status usbd_sync_transfer __P((usbd_xfer_handle req));
-usbd_status usbd_open_pipe_intr
- __P((usbd_interface_handle iface, u_int8_t address,
- u_int8_t flags, usbd_pipe_handle *pipe,
- usbd_private_handle priv, void *buffer,
- u_int32_t length, usbd_callback, int));
-usbd_status usbd_do_request
- __P((usbd_device_handle pipe, usb_device_request_t *req, void *data));
-usbd_status usbd_do_request_async
- __P((usbd_device_handle pipe, usb_device_request_t *req, void *data));
-usbd_status usbd_do_request_flags
- __P((usbd_device_handle pipe, usb_device_request_t *req,
- void *data, u_int16_t flags, int *));
+ (usbd_interface_handle iface, u_int8_t address);
+usbd_status usbd_abort_pipe(usbd_pipe_handle pipe);
+usbd_status usbd_clear_endpoint_stall(usbd_pipe_handle pipe);
+usbd_status usbd_clear_endpoint_stall_async(usbd_pipe_handle pipe);
+usbd_status usbd_endpoint_count(usbd_interface_handle dev, u_int8_t *count);
+usbd_status usbd_interface_count(usbd_device_handle dev, u_int8_t *count);
+usbd_status usbd_interface2device_handle(usbd_interface_handle iface,
+ usbd_device_handle *dev);
+usbd_status usbd_device2interface_handle(usbd_device_handle dev,
+ u_int8_t ifaceno, usbd_interface_handle *iface);
+
+usbd_device_handle usbd_pipe2device_handle(usbd_pipe_handle);
+void *usbd_alloc_buffer(usbd_xfer_handle req, u_int32_t size);
+void usbd_free_buffer(usbd_xfer_handle req);
+void *usbd_get_buffer(usbd_xfer_handle xfer);
+usbd_status usbd_sync_transfer(usbd_xfer_handle req);
+usbd_status usbd_open_pipe_intr(usbd_interface_handle iface, u_int8_t address,
+ u_int8_t flags, usbd_pipe_handle *pipe,
+ usbd_private_handle priv, void *buffer,
+ u_int32_t length, usbd_callback, int);
+usbd_status usbd_do_request(usbd_device_handle pipe, usb_device_request_t *req,
+ void *data);
+usbd_status usbd_do_request_async(usbd_device_handle pipe,
+ usb_device_request_t *req, void *data);
+usbd_status usbd_do_request_flags(usbd_device_handle pipe,
+ usb_device_request_t *req,
+ void *data, u_int16_t flags, int *);
+usbd_status usbd_do_request_flags_pipe(
+ usbd_device_handle dev, usbd_pipe_handle pipe,
+ usb_device_request_t *req, void *data, u_int16_t flags, int *actlen);
usb_interface_descriptor_t *usbd_get_interface_descriptor
- __P((usbd_interface_handle iface));
-usb_config_descriptor_t *usbd_get_config_descriptor
- __P((usbd_device_handle dev));
-usb_device_descriptor_t *usbd_get_device_descriptor
- __P((usbd_device_handle dev));
-usbd_status usbd_set_interface __P((usbd_interface_handle, int));
-int usbd_get_no_alts __P((usb_config_descriptor_t *, int));
-usbd_status usbd_get_interface
- __P((usbd_interface_handle iface, u_int8_t *aiface));
-void usbd_fill_deviceinfo
- __P((usbd_device_handle dev, struct usb_device_info *di));
-int usbd_get_interface_altindex __P((usbd_interface_handle iface));
-
-usb_interface_descriptor_t *usbd_find_idesc
- __P((usb_config_descriptor_t *cd, int iindex, int ano));
-usb_endpoint_descriptor_t *usbd_find_edesc
- __P((usb_config_descriptor_t *cd, int ifaceidx, int altidx,
- int endptidx));
-
-void usbd_dopoll __P((usbd_interface_handle));
-void usbd_set_polling __P((usbd_device_handle iface, int on));
-
-const char *usbd_errstr __P((usbd_status err));
-
-void usbd_add_dev_event __P((int, usbd_device_handle));
-void usbd_add_drv_event __P((int, usbd_device_handle, device_ptr_t));
-
-void usbd_devinfo __P((usbd_device_handle, int, char *));
-struct usbd_quirks *usbd_get_quirks __P((usbd_device_handle));
+ (usbd_interface_handle iface);
+usb_config_descriptor_t *usbd_get_config_descriptor(usbd_device_handle dev);
+usb_device_descriptor_t *usbd_get_device_descriptor(usbd_device_handle dev);
+usbd_status usbd_set_interface(usbd_interface_handle, int);
+int usbd_get_no_alts(usb_config_descriptor_t *, int);
+usbd_status usbd_get_interface(usbd_interface_handle iface, u_int8_t *aiface);
+void usbd_fill_deviceinfo(usbd_device_handle dev, struct usb_device_info *di);
+int usbd_get_interface_altindex(usbd_interface_handle iface);
+
+usb_interface_descriptor_t *usbd_find_idesc(usb_config_descriptor_t *cd,
+ int iindex, int ano);
+usb_endpoint_descriptor_t *usbd_find_edesc(usb_config_descriptor_t *cd,
+ int ifaceidx, int altidx,
+ int endptidx);
+
+void usbd_dopoll(usbd_interface_handle);
+void usbd_set_polling(usbd_device_handle iface, int on);
+
+const char *usbd_errstr(usbd_status err);
+
+void usbd_add_dev_event(int, usbd_device_handle);
+void usbd_add_drv_event(int, usbd_device_handle, device_ptr_t);
+
+void usbd_devinfo(usbd_device_handle, int, char *);
+struct usbd_quirks *usbd_get_quirks(usbd_device_handle);
usb_endpoint_descriptor_t *usbd_get_endpoint_descriptor
- __P((usbd_interface_handle iface, u_int8_t address));
+ (usbd_interface_handle iface, u_int8_t address);
-usbd_status usbd_reload_device_desc __P((usbd_device_handle));
+usbd_status usbd_reload_device_desc(usbd_device_handle);
-int usbd_ratecheck __P((struct timeval *last));
+int usbd_ratecheck(struct timeval *last);
/* NetBSD attachment information */
@@ -248,7 +239,7 @@ struct usb_attach_arg {
#endif
#if defined(__FreeBSD__)
-int usbd_driver_load __P((module_t mod, int what, void *arg));
+int usbd_driver_load(module_t mod, int what, void *arg);
#endif
/*
diff --git a/sys/dev/usb/usbdi_util.c b/sys/dev/usb/usbdi_util.c
index ec96641e4c1..433ef577664 100644
--- a/sys/dev/usb/usbdi_util.c
+++ b/sys/dev/usb/usbdi_util.c
@@ -1,5 +1,5 @@
-/* $OpenBSD: usbdi_util.c,v 1.9 2000/07/04 11:44:26 fgsch Exp $ */
-/* $NetBSD: usbdi_util.c,v 1.29 2000/03/27 12:33:59 augustss Exp $ */
+/* $OpenBSD: usbdi_util.c,v 1.10 2000/11/08 18:10:39 aaron Exp $ */
+/* $NetBSD: usbdi_util.c,v 1.33 2000/06/01 15:51:27 augustss Exp $ */
/* $FreeBSD: src/sys/dev/usb/usbdi_util.c,v 1.14 1999/11/17 22:33:50 n_hibma Exp $ */
/*
@@ -66,11 +66,7 @@ extern int usbdebug;
#endif
usbd_status
-usbd_get_desc(dev, type, index, len, desc)
- usbd_device_handle dev;
- int type, index;
- int len;
- void *desc;
+usbd_get_desc(usbd_device_handle dev, int type, int index, int len, void *desc)
{
usb_device_request_t req;
@@ -86,10 +82,8 @@ usbd_get_desc(dev, type, index, len, desc)
}
usbd_status
-usbd_get_config_desc(dev, confidx, d)
- usbd_device_handle dev;
- int confidx;
- usb_config_descriptor_t *d;
+usbd_get_config_desc(usbd_device_handle dev, int confidx,
+ usb_config_descriptor_t *d)
{
usbd_status err;
@@ -108,20 +102,14 @@ usbd_get_config_desc(dev, confidx, d)
}
usbd_status
-usbd_get_config_desc_full(dev, conf, d, size)
- usbd_device_handle dev;
- int conf;
- void *d;
- int size;
+usbd_get_config_desc_full(usbd_device_handle dev, int conf, void *d, int size)
{
DPRINTFN(3,("usbd_get_config_desc_full: conf=%d\n", conf));
return (usbd_get_desc(dev, UDESC_CONFIG, conf, size, d));
}
usbd_status
-usbd_get_device_desc(dev, d)
- usbd_device_handle dev;
- usb_device_descriptor_t *d;
+usbd_get_device_desc(usbd_device_handle dev, usb_device_descriptor_t *d)
{
DPRINTFN(3,("usbd_get_device_desc:\n"));
return (usbd_get_desc(dev, UDESC_DEVICE,
@@ -129,9 +117,7 @@ usbd_get_device_desc(dev, d)
}
usbd_status
-usbd_get_device_status(dev, st)
- usbd_device_handle dev;
- usb_status_t *st;
+usbd_get_device_status(usbd_device_handle dev, usb_status_t *st)
{
usb_device_request_t req;
@@ -144,9 +130,7 @@ usbd_get_device_status(dev, st)
}
usbd_status
-usbd_get_hub_status(dev, st)
- usbd_device_handle dev;
- usb_hub_status_t *st;
+usbd_get_hub_status(usbd_device_handle dev, usb_hub_status_t *st)
{
usb_device_request_t req;
@@ -159,9 +143,7 @@ usbd_get_hub_status(dev, st)
}
usbd_status
-usbd_set_address(dev, addr)
- usbd_device_handle dev;
- int addr;
+usbd_set_address(usbd_device_handle dev, int addr)
{
usb_device_request_t req;
@@ -174,10 +156,7 @@ usbd_set_address(dev, addr)
}
usbd_status
-usbd_get_port_status(dev, port, ps)
- usbd_device_handle dev;
- int port;
- usb_port_status_t *ps;
+usbd_get_port_status(usbd_device_handle dev, int port, usb_port_status_t *ps)
{
usb_device_request_t req;
@@ -190,9 +169,7 @@ usbd_get_port_status(dev, port, ps)
}
usbd_status
-usbd_clear_hub_feature(dev, sel)
- usbd_device_handle dev;
- int sel;
+usbd_clear_hub_feature(usbd_device_handle dev, int sel)
{
usb_device_request_t req;
@@ -205,9 +182,7 @@ usbd_clear_hub_feature(dev, sel)
}
usbd_status
-usbd_set_hub_feature(dev, sel)
- usbd_device_handle dev;
- int sel;
+usbd_set_hub_feature(usbd_device_handle dev, int sel)
{
usb_device_request_t req;
@@ -220,9 +195,7 @@ usbd_set_hub_feature(dev, sel)
}
usbd_status
-usbd_clear_port_feature(dev, port, sel)
- usbd_device_handle dev;
- int port, sel;
+usbd_clear_port_feature(usbd_device_handle dev, int port, int sel)
{
usb_device_request_t req;
@@ -235,9 +208,7 @@ usbd_clear_port_feature(dev, port, sel)
}
usbd_status
-usbd_set_port_feature(dev, port, sel)
- usbd_device_handle dev;
- int port, sel;
+usbd_set_port_feature(usbd_device_handle dev, int port, int sel)
{
usb_device_request_t req;
@@ -251,9 +222,7 @@ usbd_set_port_feature(dev, port, sel)
usbd_status
-usbd_set_protocol(iface, report)
- usbd_interface_handle iface;
- int report;
+usbd_set_protocol(usbd_interface_handle iface, int report)
{
usb_interface_descriptor_t *id = usbd_get_interface_descriptor(iface);
usbd_device_handle dev;
@@ -276,12 +245,8 @@ usbd_set_protocol(iface, report)
}
usbd_status
-usbd_set_report(iface, type, id, data, len)
- usbd_interface_handle iface;
- int type;
- int id;
- void *data;
- int len;
+usbd_set_report(usbd_interface_handle iface, int type, int id, void *data,
+ int len)
{
usb_interface_descriptor_t *ifd = usbd_get_interface_descriptor(iface);
usbd_device_handle dev;
@@ -303,12 +268,8 @@ usbd_set_report(iface, type, id, data, len)
}
usbd_status
-usbd_set_report_async(iface, type, id, data, len)
- usbd_interface_handle iface;
- int type;
- int id;
- void *data;
- int len;
+usbd_set_report_async(usbd_interface_handle iface, int type, int id, void *data,
+ int len)
{
usb_interface_descriptor_t *ifd = usbd_get_interface_descriptor(iface);
usbd_device_handle dev;
@@ -330,12 +291,8 @@ usbd_set_report_async(iface, type, id, data, len)
}
usbd_status
-usbd_get_report(iface, type, id, data, len)
- usbd_interface_handle iface;
- int type;
- int id;
- void *data;
- int len;
+usbd_get_report(usbd_interface_handle iface, int type, int id, void *data,
+ int len)
{
usb_interface_descriptor_t *ifd = usbd_get_interface_descriptor(iface);
usbd_device_handle dev;
@@ -357,10 +314,7 @@ usbd_get_report(iface, type, id, data, len)
}
usbd_status
-usbd_set_idle(iface, duration, id)
- usbd_interface_handle iface;
- int duration;
- int id;
+usbd_set_idle(usbd_interface_handle iface, int duration, int id)
{
usb_interface_descriptor_t *ifd = usbd_get_interface_descriptor(iface);
usbd_device_handle dev;
@@ -382,12 +336,8 @@ usbd_set_idle(iface, duration, id)
}
usbd_status
-usbd_get_report_descriptor(dev, ifcno, repid, size, d)
- usbd_device_handle dev;
- int ifcno;
- int repid;
- int size;
- void *d;
+usbd_get_report_descriptor(usbd_device_handle dev, int ifcno, int repid,
+ int size, void *d)
{
usb_device_request_t req;
@@ -400,8 +350,7 @@ usbd_get_report_descriptor(dev, ifcno, repid, size, d)
}
usb_hid_descriptor_t *
-usbd_get_hid_descriptor(ifc)
- usbd_interface_handle ifc;
+usbd_get_hid_descriptor(usbd_interface_handle ifc)
{
usb_interface_descriptor_t *idesc = usbd_get_interface_descriptor(ifc);
usbd_device_handle dev;
@@ -431,11 +380,8 @@ usbd_get_hid_descriptor(ifc)
}
usbd_status
-usbd_alloc_report_desc(ifc, descp, sizep, mem)
- usbd_interface_handle ifc;
- void **descp;
- int *sizep;
- usb_malloc_type mem;
+usbd_alloc_report_desc(usbd_interface_handle ifc, void **descp, int *sizep,
+ usb_malloc_type mem)
{
usb_interface_descriptor_t *id;
usb_hid_descriptor_t *hid;
@@ -466,9 +412,7 @@ usbd_alloc_report_desc(ifc, descp, sizep, mem)
}
usbd_status
-usbd_get_config(dev, conf)
- usbd_device_handle dev;
- u_int8_t *conf;
+usbd_get_config(usbd_device_handle dev, u_int8_t *conf)
{
usb_device_request_t req;
@@ -480,26 +424,19 @@ usbd_get_config(dev, conf)
return (usbd_do_request(dev, &req, conf));
}
-Static void usbd_bulk_transfer_cb __P((usbd_xfer_handle xfer,
- usbd_private_handle priv, usbd_status status));
+Static void usbd_bulk_transfer_cb(usbd_xfer_handle xfer,
+ usbd_private_handle priv, usbd_status status);
Static void
-usbd_bulk_transfer_cb(xfer, priv, status)
- usbd_xfer_handle xfer;
- usbd_private_handle priv;
- usbd_status status;
+usbd_bulk_transfer_cb(usbd_xfer_handle xfer, usbd_private_handle priv,
+ usbd_status status)
{
wakeup(xfer);
}
usbd_status
-usbd_bulk_transfer(xfer, pipe, flags, timeout, buf, size, lbl)
- usbd_xfer_handle xfer;
- usbd_pipe_handle pipe;
- u_int16_t flags;
- u_int32_t timeout;
- void *buf;
- u_int32_t *size;
- char *lbl;
+usbd_bulk_transfer(usbd_xfer_handle xfer, usbd_pipe_handle pipe,
+ u_int16_t flags, u_int32_t timeout, void *buf,
+ u_int32_t *size, char *lbl)
{
usbd_status err;
int s, error;
@@ -530,8 +467,7 @@ usbd_bulk_transfer(xfer, pipe, flags, timeout, buf, size, lbl)
}
void
-usb_detach_wait(dv)
- device_ptr_t dv;
+usb_detach_wait(device_ptr_t dv)
{
DPRINTF(("usb_detach_wait: waiting for %s\n", USBDEVPTRNAME(dv)));
if (tsleep(dv, PZERO, "usbdet", hz * 60))
@@ -541,8 +477,7 @@ usb_detach_wait(dv)
}
void
-usb_detach_wakeup(dv)
- device_ptr_t dv;
+usb_detach_wakeup(device_ptr_t dv)
{
DPRINTF(("usb_detach_wakeup: for %s\n", USBDEVPTRNAME(dv)));
wakeup(dv);
diff --git a/sys/dev/usb/usbdi_util.h b/sys/dev/usb/usbdi_util.h
index fa98b7197d8..b2be4000ae6 100644
--- a/sys/dev/usb/usbdi_util.h
+++ b/sys/dev/usb/usbdi_util.h
@@ -1,5 +1,5 @@
-/* $OpenBSD: usbdi_util.h,v 1.6 2000/07/04 11:44:26 fgsch Exp $ */
-/* $NetBSD: usbdi_util.h,v 1.19 1999/11/18 23:32:37 augustss Exp $ */
+/* $OpenBSD: usbdi_util.h,v 1.7 2000/11/08 18:10:39 aaron Exp $ */
+/* $NetBSD: usbdi_util.h,v 1.22 2000/06/01 14:37:52 augustss Exp $ */
/* $FreeBSD: src/sys/dev/usb/usbdi_util.h,v 1.9 1999/11/17 22:33:50 n_hibma Exp $ */
/*
@@ -39,57 +39,48 @@
* POSSIBILITY OF SUCH DAMAGE.
*/
-usbd_status usbd_get_desc __P((usbd_device_handle dev, int type,
- int index, int len, void *desc));
-usbd_status usbd_get_config_desc __P((usbd_device_handle, int,
- usb_config_descriptor_t *));
-usbd_status usbd_get_config_desc_full __P((usbd_device_handle, int,
- void *, int));
-usbd_status usbd_get_device_desc __P((usbd_device_handle dev,
- usb_device_descriptor_t *d));
-usbd_status usbd_set_address __P((usbd_device_handle dev, int addr));
-usbd_status usbd_get_port_status __P((usbd_device_handle,
- int, usb_port_status_t *));
-usbd_status usbd_set_hub_feature __P((usbd_device_handle dev, int));
-usbd_status usbd_clear_hub_feature __P((usbd_device_handle, int));
-usbd_status usbd_set_port_feature __P((usbd_device_handle dev, int, int));
-usbd_status usbd_clear_port_feature __P((usbd_device_handle, int, int));
-usbd_status usbd_get_device_status __P((usbd_device_handle,usb_status_t*));
-usbd_status usbd_get_hub_status __P((usbd_device_handle dev,
- usb_hub_status_t *st));
-usbd_status usbd_set_protocol __P((usbd_interface_handle dev, int report));
-usbd_status usbd_get_report_descriptor
- __P((usbd_device_handle dev, int ifcno, int repid, int size, void *d));
-struct usb_hid_descriptor *usbd_get_hid_descriptor
- __P((usbd_interface_handle ifc));
-usbd_status usbd_set_report
- __P((usbd_interface_handle iface,int type,int id,void *data,int len));
-usbd_status usbd_set_report_async
- __P((usbd_interface_handle iface,int type,int id,void *data,int len));
-usbd_status usbd_get_report
- __P((usbd_interface_handle iface,int type,int id,void *data,int len));
-usbd_status usbd_set_idle
- __P((usbd_interface_handle iface, int duration, int id));
-usbd_status usbd_alloc_report_desc
- __P((usbd_interface_handle ifc, void **descp, int *sizep,
- usb_malloc_type mem));
-usbd_status usbd_get_config
- __P((usbd_device_handle dev, u_int8_t *conf));
-usbd_status usbd_get_string_desc
- __P((usbd_device_handle dev, int sindex, int langid,
- usb_string_descriptor_t *sdesc));
-void usbd_delay_ms __P((usbd_device_handle, u_int));
+usbd_status usbd_get_desc(usbd_device_handle dev, int type,
+ int index, int len, void *desc);
+usbd_status usbd_get_config_desc(usbd_device_handle, int,
+ usb_config_descriptor_t *);
+usbd_status usbd_get_config_desc_full(usbd_device_handle, int, void *, int);
+usbd_status usbd_get_device_desc(usbd_device_handle dev,
+ usb_device_descriptor_t *d);
+usbd_status usbd_set_address(usbd_device_handle dev, int addr);
+usbd_status usbd_get_port_status(usbd_device_handle,
+ int, usb_port_status_t *);
+usbd_status usbd_set_hub_feature(usbd_device_handle dev, int);
+usbd_status usbd_clear_hub_feature(usbd_device_handle, int);
+usbd_status usbd_set_port_feature(usbd_device_handle dev, int, int);
+usbd_status usbd_clear_port_feature(usbd_device_handle, int, int);
+usbd_status usbd_get_device_status(usbd_device_handle,usb_status_t*);
+usbd_status usbd_get_hub_status(usbd_device_handle, usb_hub_status_t *);
+usbd_status usbd_set_protocol(usbd_interface_handle dev, int report);
+usbd_status usbd_get_report_descriptor(usbd_device_handle dev, int ifcno,
+ int repid, int size, void *d);
+struct usb_hid_descriptor *usbd_get_hid_descriptor(usbd_interface_handle ifc);
+usbd_status usbd_set_report(usbd_interface_handle iface, int type, int id,
+ void *data,int len);
+usbd_status usbd_set_report_async(usbd_interface_handle iface, int type,
+ int id, void *data, int len);
+usbd_status usbd_get_report(usbd_interface_handle iface, int type, int id,
+ void *data, int len);
+usbd_status usbd_set_idle(usbd_interface_handle iface, int duration,int id);
+usbd_status usbd_alloc_report_desc(usbd_interface_handle ifc, void **descp,
+ int *sizep, usb_malloc_type mem);
+usbd_status usbd_get_config(usbd_device_handle dev, u_int8_t *conf);
+usbd_status usbd_get_string_desc(usbd_device_handle dev, int sindex,
+ int langid,usb_string_descriptor_t *sdesc);
+void usbd_delay_ms(usbd_device_handle, u_int);
-usbd_status usbd_set_config_no
- __P((usbd_device_handle dev, int no, int msg));
-usbd_status usbd_set_config_index
- __P((usbd_device_handle dev, int index, int msg));
+usbd_status usbd_set_config_no(usbd_device_handle dev, int no, int msg);
+usbd_status usbd_set_config_index(usbd_device_handle dev, int index, int msg);
-usbd_status usbd_bulk_transfer
- __P((usbd_xfer_handle xfer, usbd_pipe_handle pipe, u_int16_t flags,
- u_int32_t timeout, void *buf, u_int32_t *size, char *lbl));
+usbd_status usbd_bulk_transfer(usbd_xfer_handle xfer, usbd_pipe_handle pipe,
+ u_int16_t flags, u_int32_t timeout, void *buf,
+ u_int32_t *size, char *lbl);
-void usb_detach_wait __P((device_ptr_t));
-void usb_detach_wakeup __P((device_ptr_t));
+void usb_detach_wait(device_ptr_t);
+void usb_detach_wakeup(device_ptr_t);
diff --git a/sys/dev/usb/usbdivar.h b/sys/dev/usb/usbdivar.h
index 56166c21ac1..1c23d14a27c 100644
--- a/sys/dev/usb/usbdivar.h
+++ b/sys/dev/usb/usbdivar.h
@@ -1,5 +1,5 @@
-/* $OpenBSD: usbdivar.h,v 1.10 2000/07/04 11:44:26 fgsch Exp $ */
-/* $NetBSD: usbdivar.h,v 1.55 2000/03/30 00:18:18 augustss Exp $ */
+/* $OpenBSD: usbdivar.h,v 1.11 2000/11/08 18:10:39 aaron Exp $ */
+/* $NetBSD: usbdivar.h,v 1.56 2000/06/01 14:29:03 augustss Exp $ */
/* $FreeBSD: src/sys/dev/usb/usbdivar.h,v 1.11 1999/11/17 22:33:51 n_hibma Exp $ */
/*
@@ -55,24 +55,23 @@ struct usbd_endpoint {
};
struct usbd_bus_methods {
- usbd_status (*open_pipe)__P((struct usbd_pipe *pipe));
- void (*soft_intr)__P((struct usbd_bus *));
- void (*do_poll)__P((struct usbd_bus *));
- usbd_status (*allocm)__P((struct usbd_bus *, usb_dma_t *,
- u_int32_t bufsize));
- void (*freem)__P((struct usbd_bus *, usb_dma_t *));
- struct usbd_xfer * (*allocx)__P((struct usbd_bus *));
- void (*freex)__P((struct usbd_bus *,
- struct usbd_xfer *));
+ usbd_status (*open_pipe)(struct usbd_pipe *pipe);
+ void (*soft_intr)(struct usbd_bus *);
+ void (*do_poll)(struct usbd_bus *);
+ usbd_status (*allocm)(struct usbd_bus *, usb_dma_t *,
+ u_int32_t bufsize);
+ void (*freem)(struct usbd_bus *, usb_dma_t *);
+ struct usbd_xfer * (*allocx)(struct usbd_bus *);
+ void (*freex)(struct usbd_bus *, struct usbd_xfer *);
};
struct usbd_pipe_methods {
- usbd_status (*transfer)__P((usbd_xfer_handle xfer));
- usbd_status (*start)__P((usbd_xfer_handle xfer));
- void (*abort)__P((usbd_xfer_handle xfer));
- void (*close)__P((usbd_pipe_handle pipe));
- void (*cleartoggle)__P((usbd_pipe_handle pipe));
- void (*done)__P((usbd_xfer_handle xfer));
+ usbd_status (*transfer)(usbd_xfer_handle xfer);
+ usbd_status (*start)(usbd_xfer_handle xfer);
+ void (*abort)(usbd_xfer_handle xfer);
+ void (*close)(usbd_pipe_handle pipe);
+ void (*cleartoggle)(usbd_pipe_handle pipe);
+ void (*done)(usbd_xfer_handle xfer);
};
struct usbd_port {
@@ -86,7 +85,7 @@ struct usbd_port {
};
struct usbd_hub {
- usbd_status (*explore)__P((usbd_device_handle hub));
+ usbd_status (*explore)(usbd_device_handle hub);
void *hubsoftc;
usb_hub_descriptor_t hubdesc;
struct usbd_port ports[1];
@@ -215,37 +214,35 @@ struct usbd_xfer {
usb_callout_t timeout_handle;
};
-void usbd_init __P((void));
-void usbd_finish __P((void));
+void usbd_init(void);
+void usbd_finish(void);
/* Routines from usb_subr.c */
-int usbctlprint __P((void *, const char *));
-void usb_delay_ms __P((usbd_bus_handle, u_int));
-void usbd_devinfo_vp __P((usbd_device_handle, char *, char *));
-usbd_status usbd_reset_port __P((usbd_device_handle dev,
- int port, usb_port_status_t *ps));
-usbd_status usbd_setup_pipe __P((usbd_device_handle dev,
- usbd_interface_handle iface,
- struct usbd_endpoint *, int,
- usbd_pipe_handle *pipe));
-usbd_status usbd_new_device __P((device_ptr_t parent,
- usbd_bus_handle bus, int depth,
- int lowspeed, int port,
- struct usbd_port *));
-void usbd_remove_device __P((usbd_device_handle,
- struct usbd_port *));
-int usbd_printBCD __P((char *cp, int bcd));
-usbd_status usbd_fill_iface_data __P((usbd_device_handle dev,
- int i, int a));
-void usb_free_device __P((usbd_device_handle));
-
-usbd_status usb_insert_transfer __P((usbd_xfer_handle xfer));
-void usb_transfer_complete __P((usbd_xfer_handle xfer));
-void usb_disconnect_port __P((struct usbd_port *up, device_ptr_t));
+int usbctlprint(void *, const char *);
+void usb_delay_ms(usbd_bus_handle, u_int);
+void usbd_devinfo_vp(usbd_device_handle, char *, char *);
+usbd_status usbd_reset_port(usbd_device_handle dev,
+ int port, usb_port_status_t *ps);
+usbd_status usbd_setup_pipe(usbd_device_handle dev,
+ usbd_interface_handle iface,
+ struct usbd_endpoint *, int,
+ usbd_pipe_handle *pipe);
+usbd_status usbd_new_device(device_ptr_t parent,
+ usbd_bus_handle bus, int depth,
+ int lowspeed, int port,
+ struct usbd_port *);
+void usbd_remove_device(usbd_device_handle, struct usbd_port *);
+int usbd_printBCD(char *cp, int bcd);
+usbd_status usbd_fill_iface_data(usbd_device_handle dev, int i, int a);
+void usb_free_device(usbd_device_handle);
+
+usbd_status usb_insert_transfer(usbd_xfer_handle xfer);
+void usb_transfer_complete(usbd_xfer_handle xfer);
+void usb_disconnect_port(struct usbd_port *up, device_ptr_t);
/* Routines from usb.c */
-void usb_needs_explore __P((usbd_bus_handle));
-void usb_schedsoftintr __P((struct usbd_bus *));
+void usb_needs_explore(usbd_bus_handle);
+void usb_schedsoftintr(struct usbd_bus *);
/*
* XXX This check is extremely bogus. Bad Bad Bad.
diff --git a/sys/dev/usb/usbhid.h b/sys/dev/usb/usbhid.h
index 9a802ec1c9a..86c7948ccee 100644
--- a/sys/dev/usb/usbhid.h
+++ b/sys/dev/usb/usbhid.h
@@ -1,5 +1,5 @@
-/* $OpenBSD: usbhid.h,v 1.3 2000/07/04 11:44:26 fgsch Exp $ */
-/* $NetBSD: usbhid.h,v 1.6 1999/11/18 23:32:37 augustss Exp $ */
+/* $OpenBSD: usbhid.h,v 1.4 2000/11/08 18:10:39 aaron Exp $ */
+/* $NetBSD: usbhid.h,v 1.9 2000/09/03 19:09:14 augustss Exp $ */
/* $FreeBSD: src/sys/dev/usb/usbhid.h,v 1.7 1999/11/17 22:33:51 n_hibma Exp $ */
/*
@@ -69,11 +69,33 @@ typedef struct usb_hid_descriptor {
#define USB_HID_DESCRIPTOR_SIZE(n) (9+(n)*3)
/* Usage pages */
+#define HUP_UNDEFINED 0x0000
#define HUP_GENERIC_DESKTOP 0x0001
#define HUP_SIMULATION 0x0002
+#define HUP_VR_CONTROLS 0x0003
+#define HUP_SPORTS_CONTROLS 0x0004
+#define HUP_GAMING_CONTROLS 0x0005
+#define HUP_KEYBOARD 0x0007
#define HUP_LEDS 0x0008
#define HUP_BUTTON 0x0009
+#define HUP_ORDINALS 0x000a
+#define HUP_TELEPHONY 0x000b
+#define HUP_CONSUMER 0x000c
#define HUP_DIGITIZERS 0x000d
+#define HUP_PHYSICAL_IFACE 0x000e
+#define HUP_UNICODE 0x0010
+#define HUP_ALPHANUM_DISPLAY 0x0014
+#define HUP_MONITOR 0x0080
+#define HUP_MONITOR_ENUM_VAL 0x0081
+#define HUP_VESA_VC 0x0082
+#define HUP_VESA_CMD 0x0083
+#define HUP_POWER 0x0084
+#define HUP_BATTERY_SYSTEM 0x0085
+#define HUP_BARCODE_SCANNER 0x008b
+#define HUP_SCALE 0x008c
+#define HUP_CAMERA_CONTROL 0x0090
+#define HUP_ARCADE 0x0091
+#define HUP_MICROSOFT 0xff00
/* Usages, generic desktop */
#define HUG_POINTER 0x0001
@@ -118,6 +140,7 @@ typedef struct usb_hid_descriptor {
#define HUG_SYSTEM_MENU_DOWN 0x008d
/* Usages Digitizers */
+#define HUD_UNDEFINED 0x0000
#define HUD_TIP_PRESSURE 0x0030
#define HUD_BARREL_PRESSURE 0x0031
#define HUD_IN_RANGE 0x0032
@@ -125,6 +148,11 @@ typedef struct usb_hid_descriptor {
#define HUD_UNTOUCH 0x0034
#define HUD_TAP 0x0035
#define HUD_QUALITY 0x0036
+#define HUD_DATA_VALID 0x0037
+#define HUD_TRANSDUCER_INDEX 0x0038
+#define HUD_TABLET_FKEYS 0x0039
+#define HUD_PROGRAM_CHANGE_KEYS 0x003a
+#define HUD_BATTERY_STRENGTH 0x003b
#define HUD_INVERT 0x003c
#define HUD_X_TILT 0x003d
#define HUD_Y_TILT 0x003e
diff --git a/sys/dev/usb/uvisor.c b/sys/dev/usb/uvisor.c
index 5d313f6c9c1..7fb1480f26e 100644
--- a/sys/dev/usb/uvisor.c
+++ b/sys/dev/usb/uvisor.c
@@ -1,5 +1,5 @@
-/* $OpenBSD: uvisor.c,v 1.1 2000/07/04 11:34:31 fgsch Exp $ */
-/* $NetBSD: uvisor.c,v 1.7 2000/06/01 14:29:03 augustss Exp $ */
+/* $OpenBSD: uvisor.c,v 1.2 2000/11/08 18:10:39 aaron Exp $ */
+/* $NetBSD: uvisor.c,v 1.8 2000/09/03 19:15:45 augustss Exp $ */
/*
* Copyright (c) 2000 The NetBSD Foundation, Inc.
@@ -241,7 +241,7 @@ USB_ATTACH(uvisor)
uca.ibufsize = UVISORIBUFSIZE;
uca.obufsize = UVISOROBUFSIZE;
uca.ibufsizepad = UVISORIBUFSIZE;
- uca.obufsizepad = UVISOROBUFSIZE;
+ uca.opkthdrlen = 0;
uca.device = dev;
uca.iface = iface;
uca.methods = &uvisor_methods;