summaryrefslogtreecommitdiff
path: root/include/linux
diff options
context:
space:
mode:
authorGreg Kroah-Hartman <greg@kroah.com>2002-10-29 16:55:41 -0800
committerGreg Kroah-Hartman <greg@kroah.com>2002-10-29 16:55:41 -0800
commit207dccc3e21e1b7b286d48e82bda8b8d4ff69f3e (patch)
tree0fa25fe55f03ffb97c64a65070a95381c17b7ccd /include/linux
parentd8c084f9fd65a1bf948acc5bf08b066f85160cba (diff)
parent5c1eeecc9564caaf24defb27435acfe65cc69626 (diff)
Merge kroah.com:/home/linux/linux/BK/bleeding-2.5
into kroah.com:/home/linux/linux/BK/gregkh-2.5
Diffstat (limited to 'include/linux')
-rw-r--r--include/linux/usb.h123
-rw-r--r--include/linux/usb_ch9.h91
2 files changed, 128 insertions, 86 deletions
diff --git a/include/linux/usb.h b/include/linux/usb.h
index 0397f55aabdc..0f486d95bdb7 100644
--- a/include/linux/usb.h
+++ b/include/linux/usb.h
@@ -41,56 +41,36 @@ struct usb_device;
/*-------------------------------------------------------------------------*/
/*
- * Standard USB Descriptor support.
+ * Host-side wrappers for standard USB descriptors ... these are parsed
+ * from the data provided by devices. Parsing turns them from a flat
+ * sequence of descriptors into a hierarchy:
+ *
+ * - devices have one (usually) or more configs;
+ * - configs have one (often) or more interfaces;
+ * - interfaces have one (usually) or more settings;
+ * - each interface setting has zero or (usually) more endpoints.
+ *
+ * And there might be other descriptors mixed in with those.
+ *
* Devices may also have class-specific or vendor-specific descriptors.
*/
-/*
- * Descriptor sizes per descriptor type
- */
-#define USB_DT_DEVICE_SIZE 18
-#define USB_DT_CONFIG_SIZE 9
-#define USB_DT_INTERFACE_SIZE 9
-#define USB_DT_ENDPOINT_SIZE 7
-#define USB_DT_ENDPOINT_AUDIO_SIZE 9 /* Audio extension */
-
-/* most of these maximums are arbitrary */
-#define USB_MAXCONFIG 8
-#define USB_ALTSETTINGALLOC 4
-#define USB_MAXALTSETTING 128 /* Hard limit */
-#define USB_MAXINTERFACES 32
-#define USB_MAXENDPOINTS 32 /* Hard limit */
-
-/* USB_DT_ENDPOINT: Endpoint descriptor */
-struct usb_endpoint_descriptor {
- __u8 bLength __attribute__ ((packed));
- __u8 bDescriptorType __attribute__ ((packed));
- __u8 bEndpointAddress __attribute__ ((packed));
- __u8 bmAttributes __attribute__ ((packed));
- __u16 wMaxPacketSize __attribute__ ((packed));
- __u8 bInterval __attribute__ ((packed));
- __u8 bRefresh __attribute__ ((packed));
- __u8 bSynchAddress __attribute__ ((packed));
-
- /* the rest is internal to the Linux implementation */
+/* host-side wrapper for parsed endpoint descriptors */
+struct usb_host_endpoint {
+ struct usb_endpoint_descriptor desc;
+
unsigned char *extra; /* Extra descriptors */
int extralen;
};
-/* USB_DT_INTERFACE: Interface descriptor */
-struct usb_interface_descriptor {
- __u8 bLength __attribute__ ((packed));
- __u8 bDescriptorType __attribute__ ((packed));
- __u8 bInterfaceNumber __attribute__ ((packed));
- __u8 bAlternateSetting __attribute__ ((packed));
- __u8 bNumEndpoints __attribute__ ((packed));
- __u8 bInterfaceClass __attribute__ ((packed));
- __u8 bInterfaceSubClass __attribute__ ((packed));
- __u8 bInterfaceProtocol __attribute__ ((packed));
- __u8 iInterface __attribute__ ((packed));
-
- /* the rest is internal to the Linux implementation */
- struct usb_endpoint_descriptor *endpoint;
+/* host-side wrapper for one interface setting's parsed descriptors */
+struct usb_host_interface {
+ struct usb_interface_descriptor desc;
+
+ /* array of desc.bNumEndpoint endpoints associated with this
+ * interface setting. these will be in no particular order.
+ */
+ struct usb_host_endpoint *endpoint;
unsigned char *extra; /* Extra descriptors */
int extralen;
@@ -127,7 +107,10 @@ struct usb_interface_descriptor {
* will use them in non-default settings.
*/
struct usb_interface {
- struct usb_interface_descriptor *altsetting;
+ /* array of alternate settings for this interface.
+ * these will be in numeric order, 0..num_altsettting
+ */
+ struct usb_host_interface *altsetting;
unsigned act_altsetting; /* active alternate setting */
unsigned num_altsetting; /* number of alternate settings */
@@ -148,17 +131,12 @@ struct usb_interface {
* different depending on what speed they're currently running. Only
* devices with a USB_DT_DEVICE_QUALIFIER have an OTHER_SPEED_CONFIG.
*/
-struct usb_config_descriptor {
- __u8 bLength __attribute__ ((packed));
- __u8 bDescriptorType __attribute__ ((packed));
- __u16 wTotalLength __attribute__ ((packed));
- __u8 bNumInterfaces __attribute__ ((packed));
- __u8 bConfigurationValue __attribute__ ((packed));
- __u8 iConfiguration __attribute__ ((packed));
- __u8 bmAttributes __attribute__ ((packed));
- __u8 MaxPower __attribute__ ((packed));
-
- /* the rest is internal to the Linux implementation */
+struct usb_host_config {
+ struct usb_config_descriptor desc;
+
+ /* the interfaces associated with this configuration
+ * these will be in numeric order, 0..desc.bNumInterfaces
+ */
struct usb_interface *interface;
unsigned char *extra; /* Extra descriptors */
@@ -178,8 +156,6 @@ int __usb_get_extra_descriptor(char *buffer, unsigned size,
/* -------------------------------------------------------------------------- */
-/* Host Controller Driver (HCD) support */
-
struct usb_operations;
/*
@@ -248,8 +224,8 @@ struct usb_device {
struct device dev; /* Generic device interface */
struct usb_device_descriptor descriptor;/* Descriptor */
- struct usb_config_descriptor *config; /* All of the configs */
- struct usb_config_descriptor *actconfig;/* the active configuration */
+ struct usb_host_config *config; /* All of the configs */
+ struct usb_host_config *actconfig;/* the active configuration */
char **rawdescriptors; /* Raw descriptors for each config */
@@ -560,17 +536,15 @@ extern int usb_disabled(void);
/*
* urb->transfer_flags:
- *
- * FIXME should _all_ be URB_* flags
*/
#define URB_SHORT_NOT_OK 0x0001 /* report short reads as errors */
-#define USB_ISO_ASAP 0x0002 /* iso-only, urb->start_frame ignored */
+#define URB_ISO_ASAP 0x0002 /* iso-only, urb->start_frame ignored */
#define URB_NO_DMA_MAP 0x0004 /* urb->*_dma are valid on submit */
-#define USB_ASYNC_UNLINK 0x0008 /* usb_unlink_urb() returns asap */
-#define USB_NO_FSBR 0x0020 /* UHCI-specific */
-#define USB_ZERO_PACKET 0x0040 /* Finish bulk OUTs with short packet */
+#define URB_ASYNC_UNLINK 0x0008 /* usb_unlink_urb() returns asap */
+#define URB_NO_FSBR 0x0020 /* UHCI-specific */
+#define URB_ZERO_PACKET 0x0040 /* Finish bulk OUTs with short packet */
#define URB_NO_INTERRUPT 0x0080 /* HINT: no non-error interrupt needed */
-#define USB_TIMEOUT_KILLED 0x1000 /* only set by HCD! */
+#define URB_TIMEOUT_KILLED 0x1000 /* only set by HCD! */
struct usb_iso_packet_descriptor {
unsigned int offset;
@@ -674,7 +648,7 @@ typedef void (*usb_complete_t)(struct urb *);
*
* All URBs submitted must initialize dev, pipe,
* transfer_flags (may be zero), complete, timeout (may be zero).
- * The USB_ASYNC_UNLINK transfer flag affects later invocations of
+ * The URB_ASYNC_UNLINK transfer flag affects later invocations of
* the usb_unlink_urb() routine.
*
* All URBs must also initialize
@@ -683,7 +657,7 @@ typedef void (*usb_complete_t)(struct urb *);
* to be treated as errors; that flag is invalid for write requests.
*
* Bulk URBs may
- * use the USB_ZERO_PACKET transfer flag, indicating that bulk OUT transfers
+ * use the URB_ZERO_PACKET transfer flag, indicating that bulk OUT transfers
* should always terminate with a short packet, even if it means adding an
* extra zero length packet.
*
@@ -700,7 +674,7 @@ typedef void (*usb_complete_t)(struct urb *);
* endpoints, as well as high speed interrupt endpoints, the encoding of
* the transfer interval in the endpoint descriptor is logarithmic.)
*
- * Isochronous URBs normally use the USB_ISO_ASAP transfer flag, telling
+ * Isochronous URBs normally use the URB_ISO_ASAP transfer flag, telling
* the host controller to schedule the transfer as soon as bandwidth
* utilization allows, and then set start_frame to reflect the actual frame
* selected during submission. Otherwise drivers must specify the start_frame
@@ -872,17 +846,6 @@ static inline void usb_fill_int_urb (struct urb *urb,
urb->start_frame = -1;
}
-/*
- * old style macros to enable 2.4 and 2.2 drivers to build
- * properly. Please do not use these for new USB drivers.
- */
-#define FILL_CONTROL_URB(URB,DEV,PIPE,SETUP_PACKET,TRANSFER_BUFFER,BUFFER_LENGTH,COMPLETE,CONTEXT) \
- usb_fill_control_urb(URB,DEV,PIPE,SETUP_PACKET,TRANSFER_BUFFER,BUFFER_LENGTH,COMPLETE,CONTEXT)
-#define FILL_BULK_URB(URB,DEV,PIPE,TRANSFER_BUFFER,BUFFER_LENGTH,COMPLETE,CONTEXT) \
- usb_fill_bulk_urb(URB,DEV,PIPE,TRANSFER_BUFFER,BUFFER_LENGTH,COMPLETE,CONTEXT)
-#define FILL_INT_URB(URB,DEV,PIPE,TRANSFER_BUFFER,BUFFER_LENGTH,COMPLETE,CONTEXT,INTERVAL) \
- usb_fill_int_urb(URB,DEV,PIPE,TRANSFER_BUFFER,BUFFER_LENGTH,COMPLETE,CONTEXT,INTERVAL)
-
extern struct urb *usb_alloc_urb(int iso_packets, int mem_flags);
extern void usb_free_urb(struct urb *urb);
#define usb_put_urb usb_free_urb
diff --git a/include/linux/usb_ch9.h b/include/linux/usb_ch9.h
index 9e05b8c05004..69645ae25aae 100644
--- a/include/linux/usb_ch9.h
+++ b/include/linux/usb_ch9.h
@@ -6,7 +6,7 @@
*
* - the master/host side Linux-USB kernel driver API;
* - the "usbfs" user space API; and
- * - (eventually) a Linux slave/device side driver API.
+ * - (eventually) a Linux "gadget" slave/device side driver API.
*
* USB 2.0 adds an additional "On The Go" (OTG) mode, which lets systems
* act either as a USB master/host or as a USB slave/device. That means
@@ -101,7 +101,8 @@ struct usb_ctrlrequest {
* (rarely) accepted by SET_DESCRIPTOR.
*
* Note that all multi-byte values here are encoded in little endian
- * byte order.
+ * byte order "on the wire". But when exposed through Linux-USB APIs,
+ * they've been converted to cpu byte order.
*/
/*
@@ -123,10 +124,13 @@ struct usb_descriptor_header {
} __attribute__ ((packed));
+/*-------------------------------------------------------------------------*/
+
/* USB_DT_DEVICE: Device descriptor */
struct usb_device_descriptor {
__u8 bLength;
__u8 bDescriptorType;
+
__u16 bcdUSB;
__u8 bDeviceClass;
__u8 bDeviceSubClass;
@@ -141,10 +145,12 @@ struct usb_device_descriptor {
__u8 bNumConfigurations;
} __attribute__ ((packed));
+#define USB_DT_DEVICE_SIZE 18
+
/*
* Device and/or Interface Class codes
- * as found in device and interface descriptors
+ * as found in bDeviceClass or bInterfaceClass
* and defined by www.usb.org documents
*/
#define USB_CLASS_PER_INTERFACE 0 /* for DeviceClass */
@@ -162,18 +168,88 @@ struct usb_device_descriptor {
#define USB_CLASS_APP_SPEC 0xfe
#define USB_CLASS_VENDOR_SPEC 0xff
-// FIXME include struct usb_config_descriptor
+/*-------------------------------------------------------------------------*/
+
+/* USB_DT_CONFIG: Configuration descriptor information.
+ *
+ * USB_DT_OTHER_SPEED_CONFIG is the same descriptor, except that the
+ * descriptor type is different. Highspeed-capable devices can look
+ * different depending on what speed they're currently running. Only
+ * devices with a USB_DT_DEVICE_QUALIFIER have any OTHER_SPEED_CONFIG
+ * descriptors.
+ */
+struct usb_config_descriptor {
+ __u8 bLength;
+ __u8 bDescriptorType;
+
+ __u16 wTotalLength;
+ __u8 bNumInterfaces;
+ __u8 bConfigurationValue;
+ __u8 iConfiguration;
+ __u8 bmAttributes;
+ __u8 bMaxPower;
+} __attribute__ ((packed));
+
+#define USB_DT_CONFIG_SIZE 9
+
+/* from config descriptor bmAttributes */
+#define USB_CONFIG_ATT_ONE (1 << 7) /* must be set */
+#define USB_CONFIG_ATT_SELFPOWER (1 << 6) /* self powered */
+#define USB_CONFIG_ATT_WAKEUP (1 << 5) /* can wakeup */
+
+/*-------------------------------------------------------------------------*/
/* USB_DT_STRING: String descriptor */
struct usb_string_descriptor {
__u8 bLength;
__u8 bDescriptorType;
+
__u16 wData[1]; /* UTF-16LE encoded */
} __attribute__ ((packed));
-// FIXME include struct usb_interface_descriptor
+/* note that "string" zero is special, it holds language codes that
+ * the device supports, not Unicode characters.
+ */
+
+/*-------------------------------------------------------------------------*/
+
+/* USB_DT_INTERFACE: Interface descriptor */
+struct usb_interface_descriptor {
+ __u8 bLength;
+ __u8 bDescriptorType;
+
+ __u8 bInterfaceNumber;
+ __u8 bAlternateSetting;
+ __u8 bNumEndpoints;
+ __u8 bInterfaceClass;
+ __u8 bInterfaceSubClass;
+ __u8 bInterfaceProtocol;
+ __u8 iInterface;
+} __attribute__ ((packed));
+
+#define USB_DT_INTERFACE_SIZE 9
+
+/*-------------------------------------------------------------------------*/
+
+/* USB_DT_ENDPOINT: Endpoint descriptor */
+struct usb_endpoint_descriptor {
+ __u8 bLength;
+ __u8 bDescriptorType;
+
+ __u8 bEndpointAddress;
+ __u8 bmAttributes;
+ __u16 wMaxPacketSize;
+ __u8 bInterval;
+
+ // NOTE: these two are _only_ in audio endpoints.
+ // use USB_DT_ENDPOINT*_SIZE in bLength, not sizeof.
+ __u8 bRefresh;
+ __u8 bSynchAddress;
+} __attribute__ ((packed));
+
+#define USB_DT_ENDPOINT_SIZE 7
+#define USB_DT_ENDPOINT_AUDIO_SIZE 9 /* Audio extension */
-// FIXME include struct usb_endpoint_descriptor
/*
* Endpoints
@@ -188,10 +264,13 @@ struct usb_string_descriptor {
#define USB_ENDPOINT_XFER_INT 3
+/*-------------------------------------------------------------------------*/
+
/* USB_DT_DEVICE_QUALIFIER: Device Qualifier descriptor */
struct usb_qualifier_descriptor {
__u8 bLength;
__u8 bDescriptorType;
+
__u16 bcdUSB;
__u8 bDeviceClass;
__u8 bDeviceSubClass;