diff options
-rw-r--r-- | share/man/man4/usb.4 | 25 | ||||
-rw-r--r-- | sys/dev/usb/usb.c | 21 | ||||
-rw-r--r-- | sys/dev/usb/usb.h | 9 |
3 files changed, 51 insertions, 4 deletions
diff --git a/share/man/man4/usb.4 b/share/man/man4/usb.4 index 19c0e24517f..dbf60ad39e6 100644 --- a/share/man/man4/usb.4 +++ b/share/man/man4/usb.4 @@ -1,4 +1,4 @@ -.\" $OpenBSD: usb.4,v 1.137 2013/04/08 10:34:20 mglocker Exp $ +.\" $OpenBSD: usb.4,v 1.138 2013/04/17 11:53:10 mglocker Exp $ .\" $NetBSD: usb.4,v 1.15 1999/07/29 14:20:32 augustss Exp $ .\" .\" Copyright (c) 1999 The NetBSD Foundation, Inc. @@ -28,7 +28,7 @@ .\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE .\" POSSIBILITY OF SUCH DAMAGE. .\" -.Dd $Mdocdate: April 8 2013 $ +.Dd $Mdocdate: April 17 2013 $ .Dt USB 4 .Os .Sh NAME @@ -508,6 +508,27 @@ field is indexed by the transfer kind, i.e.\& .Dv UE_* , and indicates how many transfers of each kind have been completed by the controller. +.It Dv USB_DEVICE_GET_DDESC (struct usb_device_ddesc) +This command can be used to retrieve the device descriptor +of a device on the bus. +The +.Va udd_addr +field needs to be filled with the bus device address: +.Bd -literal +struct usb_device_ddesc { + u_int8_t udd_bus; + u_int8_t udd_addr; /* device address */ + usb_device_descriptor_t udd_desc; +}; +.Ed +.Pp +The +.Va udc_bus +field contains the device unit number. +.Pp +The +.Va udd_desc +field contains the device descriptor structure. .It Dv USB_DEVICE_GET_CDESC (struct usb_device_cdesc) This command can be used to retrieve the configuration descriptor for the given configuration of a device on the bus. diff --git a/sys/dev/usb/usb.c b/sys/dev/usb/usb.c index b3bf1440a09..ca67a997c2f 100644 --- a/sys/dev/usb/usb.c +++ b/sys/dev/usb/usb.c @@ -1,4 +1,4 @@ -/* $OpenBSD: usb.c,v 1.86 2013/04/15 09:23:02 mglocker Exp $ */ +/* $OpenBSD: usb.c,v 1.87 2013/04/17 11:53:10 mglocker Exp $ */ /* $NetBSD: usb.c,v 1.77 2003/01/01 00:10:26 thorpej Exp $ */ /* @@ -679,6 +679,25 @@ usbioctl(dev_t devt, u_long cmd, caddr_t data, int flag, struct proc *p) *(struct usb_device_stats *)data = sc->sc_bus->stats; break; + case USB_DEVICE_GET_DDESC: + { + struct usb_device_ddesc *udd = (struct usb_device_ddesc *)data; + int addr = udd->udd_addr; + struct usbd_device *dev; + + if (addr < 1 || addr >= USB_MAX_DEVICES) + return (EINVAL); + + dev = sc->sc_bus->devices[addr]; + if (dev == NULL) + return (ENXIO); + + udd->udd_bus = unit; + + udd->udd_desc = *usbd_get_device_descriptor(dev); + break; + } + case USB_DEVICE_GET_CDESC: { struct usb_device_cdesc *udc = (struct usb_device_cdesc *)data; diff --git a/sys/dev/usb/usb.h b/sys/dev/usb/usb.h index a889553c302..bc37a1afda7 100644 --- a/sys/dev/usb/usb.h +++ b/sys/dev/usb/usb.h @@ -1,4 +1,4 @@ -/* $OpenBSD: usb.h,v 1.43 2013/04/08 10:34:20 mglocker Exp $ */ +/* $OpenBSD: usb.h,v 1.44 2013/04/17 11:53:10 mglocker Exp $ */ /* $NetBSD: usb.h,v 1.69 2002/09/22 23:20:50 augustss Exp $ */ /* $FreeBSD: src/sys/dev/usb/usb.h,v 1.14 1999/11/17 22:33:46 n_hibma Exp $ */ @@ -596,6 +596,12 @@ struct usb_device_fdesc { u_char *udf_data; }; +struct usb_device_ddesc { + u_int8_t udd_bus; + u_int8_t udd_addr; /* device address */ + usb_device_descriptor_t udd_desc; +}; + struct usb_string_desc { int usd_string_index; int usd_language_id; @@ -654,6 +660,7 @@ struct usb_device_stats { #define USB_DEVICESTATS _IOR ('U', 5, struct usb_device_stats) #define USB_DEVICE_GET_CDESC _IOWR('U', 6, struct usb_device_cdesc) #define USB_DEVICE_GET_FDESC _IOWR('U', 7, struct usb_device_fdesc) +#define USB_DEVICE_GET_DDESC _IOWR('U', 8, struct usb_device_ddesc) /* Generic HID device */ #define USB_GET_REPORT_DESC _IOR ('U', 21, struct usb_ctl_report_desc) |