* Devices may also have class-specific or vendor-specific descriptors.
*/
-/**
- * struct usb_host_endpoint - host-side endpoint descriptor and queue
- * @desc: descriptor for this endpoint, wMaxPacketSize in native byteorder
- * @urb_list: urbs queued to this endpoint; maintained by usbcore
- * @hcpriv: for use by HCD; typically holds hardware dma queue head (QH)
- * with one or more transfer descriptors (TDs) per urb
- * @extra: descriptors following this endpoint in the configuration
- * @extralen: how many bytes of "extra" are valid
- *
- * USB requests are always queued to a given endpoint, identified by a
- * descriptor within an active interface in a given USB configuration.
- */
+/* host-side wrapper for parsed endpoint descriptors */
struct usb_host_endpoint {
struct usb_endpoint_descriptor desc;
- struct list_head urb_list;
- void *hcpriv;
unsigned char *extra; /* Extra descriptors */
int extralen;
int extralen;
};
+// FIXME remove; exported only for drivers/usb/misc/auserwald.c
+// prefer usb_device->epnum[0..31]
+extern struct usb_endpoint_descriptor *
+ usb_epnum_to_ep_desc(struct usb_device *dev, unsigned epnum);
+
int __usb_get_extra_descriptor(char *buffer, unsigned size,
unsigned char type, void **ptr);
#define usb_get_extra_descriptor(ifpoint,type,ptr)\
struct semaphore serialize;
unsigned int toggle[2]; /* one bit for each endpoint ([0] = IN, [1] = OUT) */
+ int epmaxpacketin[16]; /* INput endpoint specific maximums */
+ int epmaxpacketout[16]; /* OUTput endpoint specific maximums */
struct usb_device *parent; /* our hub, unless we're the root */
struct usb_bus *bus; /* Bus we're part of */
- struct usb_host_endpoint ep0;
struct device dev; /* Generic device interface */
struct usb_device_descriptor descriptor;/* Descriptor */
struct usb_host_config *config; /* All of the configs */
-
struct usb_host_config *actconfig;/* the active configuration */
- struct usb_host_endpoint *ep_in[16];
- struct usb_host_endpoint *ep_out[16];
char **rawdescriptors; /* Raw descriptors for each config */
int have_langid; /* whether string_langid is valid yet */
int string_langid; /* language ID for strings */
+ void *hcpriv; /* Host Controller private data */
+
struct list_head filelist;
struct dentry *usbfs_dentry; /* usbfs dentry entry for the device */
extern struct usb_device *usb_find_device(u16 vendor_id, u16 product_id);
-/*-------------------------------------------------------------------------*/
-
/* for drivers using iso endpoints */
extern int usb_get_current_frame_number (struct usb_device *usb_dev);
* to poll for transfers. After the URB has been submitted, the interval
* field reflects how the transfer was actually scheduled.
* The polling interval may be more frequent than requested.
- * For example, some controllers have a maximum interval of 32 milliseconds,
- * while others support intervals of up to 1024 milliseconds.
+ * For example, some controllers have a maximum interval of 32 microseconds,
+ * while others support intervals of up to 1024 microseconds.
* Isochronous URBs also have transfer intervals. (Note that for isochronous
* endpoints, as well as high speed interrupt endpoints, the encoding of
* the transfer interval in the endpoint descriptor is logarithmic.
/* -------------------------------------------------------------------------- */
/*
- * For various legacy reasons, Linux has a small cookie that's paired with
- * a struct usb_device to identify an endpoint queue. Queue characteristics
- * are defined by the endpoint's descriptor. This cookie is called a "pipe",
- * an unsigned int encoded as:
+ * Calling this entity a "pipe" is glorifying it. A USB pipe
+ * is something embarrassingly simple: it basically consists
+ * of the following information:
+ * - device number (7 bits)
+ * - endpoint number (4 bits)
+ * - current Data0/1 state (1 bit) [Historical; now gone]
+ * - direction (1 bit)
+ * - speed (1 bit) [Historical and specific to USB 1.1; now gone.]
+ * - max packet size (2 bits: 8, 16, 32 or 64) [Historical; now gone.]
+ * - pipe type (2 bits: control, interrupt, bulk, isochronous)
+ *
+ * That's 18 bits. Really. Nothing more. And the USB people have
+ * documented these eighteen bits as some kind of glorious
+ * virtual data structure.
+ *
+ * Let's not fall in that trap. We'll just encode it as a simple
+ * unsigned int. The encoding is:
*
+ * - max size: bits 0-1 [Historical; now gone.]
* - direction: bit 7 (0 = Host-to-Device [Out],
* 1 = Device-to-Host [In] ...
* like endpoint bEndpointAddress)
- * - device address: bits 8-14 ... bit positions known to uhci-hcd
+ * - device: bits 8-14 ... bit positions known to uhci-hcd
* - endpoint: bits 15-18 ... bit positions known to uhci-hcd
+ * - Data0/1: bit 19 [Historical; now gone. ]
+ * - lowspeed: bit 26 [Historical; now gone. ]
* - pipe type: bits 30-31 (00 = isochronous, 01 = interrupt,
* 10 = control, 11 = bulk)
*
- * Given the device address and endpoint descriptor, pipes are redundant.
+ * Why? Because it's arbitrary, and whatever encoding we select is really
+ * up to us. This one happens to share a lot of bit positions with the UHCI
+ * specification, so that much of the uhci driver can just mask the bits
+ * appropriately.
*/
/* NOTE: these are not the standard USB_ENDPOINT_XFER_* values!! */
-/* (yet ... they're the values used by usbfs) */
#define PIPE_ISOCHRONOUS 0
#define PIPE_INTERRUPT 1
#define PIPE_CONTROL 2
#define PIPE_BULK 3
+#define usb_maxpacket(dev, pipe, out) (out \
+ ? (dev)->epmaxpacketout[usb_pipeendpoint(pipe)] \
+ : (dev)->epmaxpacketin [usb_pipeendpoint(pipe)] )
+
#define usb_pipein(pipe) ((pipe) & USB_DIR_IN)
#define usb_pipeout(pipe) (!usb_pipein(pipe))
-
#define usb_pipedevice(pipe) (((pipe) >> 8) & 0x7f)
#define usb_pipeendpoint(pipe) (((pipe) >> 15) & 0xf)
-
#define usb_pipetype(pipe) (((pipe) >> 30) & 3)
#define usb_pipeisoc(pipe) (usb_pipetype((pipe)) == PIPE_ISOCHRONOUS)
#define usb_pipeint(pipe) (usb_pipetype((pipe)) == PIPE_INTERRUPT)
#define usb_sndintpipe(dev,endpoint) ((PIPE_INTERRUPT << 30) | __create_pipe(dev,endpoint))
#define usb_rcvintpipe(dev,endpoint) ((PIPE_INTERRUPT << 30) | __create_pipe(dev,endpoint) | USB_DIR_IN)
-/*-------------------------------------------------------------------------*/
-
-static inline __u16
-usb_maxpacket(struct usb_device *udev, int pipe, int is_out)
-{
- struct usb_host_endpoint *ep;
- unsigned epnum = usb_pipeendpoint(pipe);
-
- if (is_out) {
- WARN_ON(usb_pipein(pipe));
- ep = udev->ep_out[epnum];
- } else {
- WARN_ON(usb_pipeout(pipe));
- ep = udev->ep_in[epnum];
- }
- if (!ep)
- return 0;
-
- /* NOTE: only 0x07ff bits are for packet size... */
- return le16_to_cpu(ep->desc.wMaxPacketSize);
-}
-
/* -------------------------------------------------------------------------- */
#ifdef DEBUG