Import 2.3.18pre1
[davej-history.git] / drivers / usb / usb.h
blob7044bcf9631db94384b8da85d43bc0fff3a5f593
1 #ifndef __LINUX_USB_H
2 #define __LINUX_USB_H
4 #include <linux/types.h>
5 #include <linux/ioctl.h>
7 /* USB constants */
9 /*
10 * Device and/or Interface Class codes
12 #define USB_CLASS_PER_INTERFACE 0 /* for DeviceClass */
13 #define USB_CLASS_AUDIO 1
14 #define USB_CLASS_COMM 2
15 #define USB_CLASS_HID 3
16 #define USB_CLASS_PRINTER 7
17 #define USB_CLASS_MASS_STORAGE 8
18 #define USB_CLASS_HUB 9
19 #define USB_CLASS_DATA 10
20 #define USB_CLASS_VENDOR_SPEC 0xff
23 * Descriptor types
25 #define USB_DT_DEVICE 0x01
26 #define USB_DT_CONFIG 0x02
27 #define USB_DT_STRING 0x03
28 #define USB_DT_INTERFACE 0x04
29 #define USB_DT_ENDPOINT 0x05
31 #define USB_DT_HUB 0x29
32 #define USB_DT_HID 0x21
33 #define USB_DT_REPORT 0x22
34 #define USB_DT_PHYSICAL 0x23
37 * Descriptor sizes per descriptor type
39 #define USB_DT_DEVICE_SIZE 18
40 #define USB_DT_CONFIG_SIZE 9
41 #define USB_DT_INTERFACE_SIZE 9
42 #define USB_DT_ENDPOINT_SIZE 7
43 #define USB_DT_ENDPOINT_AUDIO_SIZE 9 /* Audio extension */
44 #define USB_DT_HUB_NONVAR_SIZE 7
47 * USB Request Type and Endpoint Directions
49 #define USB_DIR_OUT 0
50 #define USB_DIR_IN 0x80
53 * USB Packet IDs (PIDs)
55 #define USB_PID_OUT 0xe1
56 #define USB_PID_IN 0x69
57 #define USB_PID_SETUP 0x2d
60 * Standard requests
62 #define USB_REQ_GET_STATUS 0x00
63 #define USB_REQ_CLEAR_FEATURE 0x01
64 /* 0x02 is reserved */
65 #define USB_REQ_SET_FEATURE 0x03
66 /* 0x04 is reserved */
67 #define USB_REQ_SET_ADDRESS 0x05
68 #define USB_REQ_GET_DESCRIPTOR 0x06
69 #define USB_REQ_SET_DESCRIPTOR 0x07
70 #define USB_REQ_GET_CONFIGURATION 0x08
71 #define USB_REQ_SET_CONFIGURATION 0x09
72 #define USB_REQ_GET_INTERFACE 0x0A
73 #define USB_REQ_SET_INTERFACE 0x0B
74 #define USB_REQ_SYNCH_FRAME 0x0C
77 * HIDD requests
79 #define USB_REQ_GET_REPORT 0x01
80 #define USB_REQ_GET_IDLE 0x02
81 #define USB_REQ_GET_PROTOCOL 0x03
82 #define USB_REQ_SET_REPORT 0x09
83 #define USB_REQ_SET_IDLE 0x0A
84 #define USB_REQ_SET_PROTOCOL 0x0B
86 #define USB_TYPE_STANDARD (0x00 << 5)
87 #define USB_TYPE_CLASS (0x01 << 5)
88 #define USB_TYPE_VENDOR (0x02 << 5)
89 #define USB_TYPE_RESERVED (0x03 << 5)
91 #define USB_RECIP_DEVICE 0x00
92 #define USB_RECIP_INTERFACE 0x01
93 #define USB_RECIP_ENDPOINT 0x02
94 #define USB_RECIP_OTHER 0x03
96 #define USB_HID_RPT_INPUT 0x01
97 #define USB_HID_RPT_OUTPUT 0x02
98 #define USB_HID_RPT_FEATURE 0x03
101 * Request target types.
103 #define USB_RT_DEVICE 0x00
104 #define USB_RT_INTERFACE 0x01
105 #define USB_RT_ENDPOINT 0x02
107 #define USB_RT_HUB (USB_TYPE_CLASS | USB_RECIP_DEVICE)
108 #define USB_RT_PORT (USB_TYPE_CLASS | USB_RECIP_OTHER)
110 #define USB_RT_HIDD (USB_TYPE_CLASS | USB_RECIP_INTERFACE)
112 /* /proc/bus/usb/xxx/yyy ioctl codes */
114 struct usb_proc_ctrltransfer {
115 __u8 requesttype;
116 __u8 request;
117 __u16 value;
118 __u16 index;
119 __u16 length;
120 /* pointer to data */
121 void *data;
124 #define USB_PROC_CONTROL _IOWR('U', 0, struct usb_proc_ctrltransfer)
126 struct usb_proc_bulktransfer {
127 unsigned int ep;
128 unsigned int len;
129 void *data;
132 #define USB_PROC_BULK _IOWR('U', 2, struct usb_proc_bulktransfer)
134 #define USB_PROC_RESETEP _IOR('U', 3, unsigned int)
136 struct usb_proc_setinterface {
137 unsigned int interface;
138 unsigned int altsetting;
141 #define USB_PROC_SETINTERFACE _IOR('U', 4, struct usb_proc_setinterface)
143 #define USB_PROC_SETCONFIGURATION _IOR('U', 5, unsigned int)
148 #ifdef __KERNEL__
150 #include <linux/config.h>
151 #include <linux/list.h>
152 #include <linux/sched.h>
154 extern int usb_hub_init(void);
155 extern int usb_kbd_init(void);
156 extern int usb_cpia_init(void);
157 extern int usb_mouse_init(void);
158 extern int usb_printer_init(void);
160 extern void usb_hub_cleanup(void);
161 extern void usb_mouse_cleanup(void);
163 static __inline__ void wait_ms(unsigned int ms)
165 current->state = TASK_UNINTERRUPTIBLE;
166 schedule_timeout(1 + ms * HZ / 1000);
169 typedef struct {
170 __u8 requesttype;
171 __u8 request;
172 __u16 value;
173 __u16 index;
174 __u16 length;
175 } devrequest __attribute__ ((packed));
178 * Status codes (these follow OHCI controllers condition codes)
180 #define USB_ST_NOERROR 0x0
181 #define USB_ST_CRC 0x1
182 #define USB_ST_BITSTUFF 0x2
183 #define USB_ST_DTMISMATCH 0x3 /* data toggle mismatch */
184 #define USB_ST_STALL 0x4
185 #define USB_ST_NORESPONSE 0x5 /* device not responding/handshaking */
186 #define USB_ST_PIDCHECK 0x6 /* Check bits on PID failed */
187 #define USB_ST_PIDUNDEF 0x7 /* PID unexpected/undefined */
188 #define USB_ST_DATAOVERRUN 0x8
189 #define USB_ST_DATAUNDERRUN 0x9
190 #define USB_ST_RESERVED1 0xA
191 #define USB_ST_RESERVED2 0xB
192 #define USB_ST_BUFFEROVERRUN 0xC
193 #define USB_ST_BUFFERUNDERRUN 0xD
194 #define USB_ST_RESERVED3 0xE
195 #define USB_ST_RESERVED4 0xF
197 /* internal errors */
198 #define USB_ST_REMOVED 0x100
199 #define USB_ST_TIMEOUT 0x110
200 #define USB_ST_INTERNALERROR -1
201 #define USB_ST_NOTSUPPORTED -2
202 #define USB_ST_BANDWIDTH_ERROR -3
205 * USB device number allocation bitmap. There's one bitmap
206 * per USB tree.
208 struct usb_devmap {
209 unsigned long devicemap[128 / (8*sizeof(unsigned long))];
213 * This is a USB device descriptor.
215 * USB device information
218 /* Everything but the endpoint maximums are aribtrary */
219 #define USB_MAXCONFIG 8
220 #define USB_MAXALTSETTING 16
221 #define USB_MAXINTERFACES 32
222 #define USB_MAXENDPOINTS 32
224 /* All standard descriptors have these 2 fields in common */
225 struct usb_descriptor_header {
226 __u8 bLength;
227 __u8 bDescriptorType;
228 } __attribute__ ((packed));
230 /* Device descriptor */
231 struct usb_device_descriptor {
232 __u8 bLength;
233 __u8 bDescriptorType;
234 __u16 bcdUSB;
235 __u8 bDeviceClass;
236 __u8 bDeviceSubClass;
237 __u8 bDeviceProtocol;
238 __u8 bMaxPacketSize0;
239 __u16 idVendor;
240 __u16 idProduct;
241 __u16 bcdDevice;
242 __u8 iManufacturer;
243 __u8 iProduct;
244 __u8 iSerialNumber;
245 __u8 bNumConfigurations;
246 } __attribute__ ((packed));
248 /* Endpoint descriptor */
249 struct usb_endpoint_descriptor {
250 __u8 bLength;
251 __u8 bDescriptorType;
252 __u8 bEndpointAddress;
253 __u8 bmAttributes;
254 __u16 wMaxPacketSize;
255 __u8 bInterval;
256 __u8 bRefresh;
257 __u8 bSynchAddress;
258 } __attribute__ ((packed));
260 /* HID descriptor */
261 struct usb_hid_class_descriptor {
262 __u8 bDescriptorType;
263 __u16 wDescriptorLength;
264 } __attribute__ ((packed));
266 struct usb_hid_descriptor {
267 __u8 bLength;
268 __u8 bDescriptorType;
269 __u16 bcdHID;
270 __u8 bCountryCode;
271 __u8 bNumDescriptors;
273 struct usb_hid_class_descriptor desc[1];
274 } __attribute__ ((packed));
276 /* Interface descriptor */
277 struct usb_interface_descriptor {
278 __u8 bLength;
279 __u8 bDescriptorType;
280 __u8 bInterfaceNumber;
281 __u8 bAlternateSetting;
282 __u8 bNumEndpoints;
283 __u8 bInterfaceClass;
284 __u8 bInterfaceSubClass;
285 __u8 bInterfaceProtocol;
286 __u8 iInterface;
288 struct usb_hid_descriptor *hid;
289 struct usb_endpoint_descriptor *endpoint;
290 } __attribute__ ((packed));
292 struct usb_interface {
293 struct usb_interface_descriptor *altsetting;
295 int act_altsetting; /* active alternate setting */
296 int num_altsetting; /* number of alternate settings */
299 /* Configuration descriptor information.. */
300 struct usb_config_descriptor {
301 __u8 bLength;
302 __u8 bDescriptorType;
303 __u16 wTotalLength;
304 __u8 bNumInterfaces;
305 __u8 bConfigurationValue;
306 __u8 iConfiguration;
307 __u8 bmAttributes;
308 __u8 MaxPower;
310 struct usb_interface *interface;
311 } __attribute__ ((packed));
313 /* String descriptor */
314 struct usb_string_descriptor {
315 __u8 bLength;
316 __u8 bDescriptorType;
317 __u16 wData[1];
318 } __attribute__ ((packed));
320 struct usb_device;
322 struct usb_driver {
323 const char *name;
325 int (*probe)(struct usb_device *);
326 void (*disconnect)(struct usb_device *);
328 struct list_head driver_list;
332 * Pointer to a device endpoint interrupt function -greg
333 * Parameters:
334 * int status - This needs to be defined. Right now each HCD
335 * passes different transfer status bits back. Don't use it
336 * until we come up with a common meaning.
337 * void *buffer - This is a pointer to the data used in this
338 * USB transfer.
339 * int length - This is the number of bytes transferred in or out
340 * of the buffer by this transfer. (-1 = unknown/unsupported)
341 * void *dev_id - This is a user defined pointer set when the IRQ
342 * is requested that is passed back.
344 * Special Cases:
345 * if (status == USB_ST_REMOVED), don't trust buffer or len.
347 typedef int (*usb_device_irq)(int, void *, int, void *);
350 * Isoc. support additions
352 #define START_FRAME_FUDGE 3
354 #define USB_WRAP_FRAMENR(x) ((x) & 2047)
356 /* for start_type: */
357 enum {
358 START_ASAP = 0,
359 START_ABSOLUTE,
360 START_RELATIVE
362 #define START_TYPE_MAX START_RELATIVE
365 * Completion/Callback routine returns an enum,
366 * which tells the interrupt handler what to do
367 * with the completed frames (TDs).
369 enum {
370 CB_CONTINUE = 0, /* OK, remove all TDs;
371 needs to be 0 to be consistent with
372 current callback function ret. values */
373 CB_REUSE, /* leave descriptors as NULL, not active */
374 CB_RESTART, /* leave descriptors as they are, alive */
375 CB_ABORT, /* kill this USB transfer request */
376 CB_CONT_RUN /* append the isoc_desc at the end of all active isoc_desc */
379 struct isoc_frame_desc {
380 int frame_length; /* may be 0 (i.e., allowed) */
381 /* set by driver for OUTs to devices;
382 * set by USBD for INs from devices,
383 * after I/O complete */
384 unsigned int frame_status;
385 /* set by USBD after I/O complete */
388 struct usb_isoc_desc {
390 * The following fields are set by the usb_init_isoc() call.
392 struct usb_device *usb_dev;
393 unsigned int pipe;
394 int frame_count;
395 void *context; /* driver context (private) ptr */
396 int frame_size;
398 * The following fields are set by the driver between the
399 * usb_init_isoc() and usb_run_isoc() calls
400 * (along with the "frames" array for OUTput).
402 int start_type;
403 int start_frame; /* optional, depending on start_type */
404 int frame_spacing; /* not using (yet?) */
405 int callback_frames; /* every # frames + last one */
406 /* 0 means no callbacks until IOC on last frame */
407 usb_device_irq callback_fn;
408 void *data;
409 int buf_size;
410 struct usb_isoc_desc *prev_isocdesc; /* previous isoc_desc, for CB_CONT_RUN */
412 * The following fields are set by the usb_run_isoc() call.
414 int end_frame;
415 void *td; /* UHCI or OHCI TD ptr */
417 * The following fields are set by the USB HCD interrupt handler
418 * before calling the driver's callback function.
420 int total_completed_frames;
421 int prev_completed_frame; /* from the previous callback */
422 int cur_completed_frame; /* from this callback */
423 int total_length; /* accumulated */
424 int error_count; /* accumulated */
425 struct isoc_frame_desc frames [0]; /* variable size: [frame_count] */
428 struct usb_operations {
429 int (*allocate)(struct usb_device *);
430 int (*deallocate)(struct usb_device *);
431 int (*control_msg)(struct usb_device *, unsigned int, devrequest *, void *, int);
432 int (*bulk_msg)(struct usb_device *, unsigned int, void *, int,unsigned long *);
433 void *(*request_irq)(struct usb_device *, unsigned int, usb_device_irq, int, void *);
434 int (*release_irq)(struct usb_device *, void *);
435 void *(*request_bulk)(struct usb_device *, unsigned int, usb_device_irq,
436 void *, int, void *);
437 int (*terminate_bulk)(struct usb_device *, void *);
438 int (*get_frame_number) (struct usb_device *usb_dev);
439 int (*init_isoc) (struct usb_device *usb_dev, unsigned int pipe,
440 int frame_count, void *context, struct usb_isoc_desc **isocdesc);
441 void (*free_isoc) (struct usb_isoc_desc *isocdesc);
442 int (*run_isoc) (struct usb_isoc_desc *isocdesc, struct usb_isoc_desc *pr_isocdesc);
443 int (*kill_isoc) (struct usb_isoc_desc *isocdesc);
447 * Allocated per bus we have
449 struct usb_bus {
450 struct usb_devmap devmap; /* Device map */
451 struct usb_operations *op; /* Operations (specific to the HC) */
452 struct usb_device *root_hub; /* Root hub */
453 struct list_head bus_list;
454 void *hcpriv; /* Host Controller private data */
456 /* procfs entry */
457 int proc_busnum;
458 struct proc_dir_entry *proc_entry;
461 #define USB_MAXCHILDREN (8) /* This is arbitrary */
463 struct usb_device {
464 int devnum; /* Device number on USB bus */
465 int slow; /* Slow device? */
467 atomic_t refcnt; /* Reference count */
469 int maxpacketsize; /* Maximum packet size; encoded as 0,1,2,3 = 8,16,32,64 */
470 unsigned int toggle[2]; /* one bit for each endpoint ([0] = IN, [1] = OUT) */
471 unsigned int halted[2]; /* endpoint halts; one bit per endpoint # & direction; */
472 /* [0] = IN, [1] = OUT */
473 struct usb_config_descriptor *actconfig;/* the active configuration */
474 int epmaxpacketin[16]; /* INput endpoint specific maximums */
475 int epmaxpacketout[16]; /* OUTput endpoint specific maximums */
476 int ifnum; /* active interface number */
478 struct usb_device *parent;
479 struct usb_bus *bus; /* Bus we're part of */
480 struct usb_driver *driver; /* Driver */
482 struct usb_device_descriptor descriptor;/* Descriptor */
483 struct usb_config_descriptor *config; /* All of the configs */
485 char *string; /* pointer to the last string read from the device */
486 int string_langid; /* language ID for strings */
488 void *hcpriv; /* Host Controller private data */
489 void *private; /* Upper layer private data */
491 /* procfs entry */
492 struct proc_dir_entry *proc_entry;
495 * Child devices - these can be either new devices
496 * (if this is a hub device), or different instances
497 * of this same device.
499 * Each instance needs its own set of data structures.
502 int maxchild; /* Number of ports if hub */
503 struct usb_device *children[USB_MAXCHILDREN];
506 extern int usb_register(struct usb_driver *);
507 extern void usb_deregister(struct usb_driver *);
509 int usb_find_driver(struct usb_device *);
510 void usb_check_support(struct usb_device *);
511 void usb_driver_purge(struct usb_driver *, struct usb_device *);
513 extern struct usb_bus *usb_alloc_bus(struct usb_operations *);
514 extern void usb_free_bus(struct usb_bus *);
515 extern void usb_register_bus(struct usb_bus *);
516 extern void usb_deregister_bus(struct usb_bus *);
518 extern struct usb_device *usb_alloc_dev(struct usb_device *parent, struct usb_bus *);
519 extern void usb_free_dev(struct usb_device *);
520 extern void usb_inc_dev_use(struct usb_device *);
521 #define usb_dec_dev_use usb_free_dev
523 extern int usb_control_msg(struct usb_device *dev, unsigned int pipe, __u8 request, __u8 requesttype, __u16 value, __u16 index, void *data, __u16 size);
525 extern void *usb_request_irq(struct usb_device *, unsigned int, usb_device_irq, int, void *);
526 extern int usb_release_irq(struct usb_device *dev, void *handle);
528 extern void *usb_request_bulk(struct usb_device *, unsigned int, usb_device_irq, void *, int, void *);
529 extern int usb_terminate_bulk(struct usb_device *, void *);
531 extern void usb_init_root_hub(struct usb_device *dev);
532 extern void usb_connect(struct usb_device *dev);
533 extern void usb_disconnect(struct usb_device **);
535 extern void usb_destroy_configuration(struct usb_device *dev);
537 int usb_get_current_frame_number (struct usb_device *usb_dev);
539 int usb_init_isoc (struct usb_device *usb_dev,
540 unsigned int pipe,
541 int frame_count,
542 void *context,
543 struct usb_isoc_desc **isocdesc);
545 void usb_free_isoc (struct usb_isoc_desc *isocdesc);
547 int usb_run_isoc (struct usb_isoc_desc *isocdesc,
548 struct usb_isoc_desc *pr_isocdesc);
550 int usb_kill_isoc (struct usb_isoc_desc *isocdesc);
553 * Calling this entity a "pipe" is glorifying it. A USB pipe
554 * is something embarrassingly simple: it basically consists
555 * of the following information:
556 * - device number (7 bits)
557 * - endpoint number (4 bits)
558 * - current Data0/1 state (1 bit)
559 * - direction (1 bit)
560 * - speed (1 bit)
561 * - max packet size (2 bits: 8, 16, 32 or 64)
562 * - pipe type (2 bits: control, interrupt, bulk, isochronous)
564 * That's 18 bits. Really. Nothing more. And the USB people have
565 * documented these eighteen bits as some kind of glorious
566 * virtual data structure.
568 * Let's not fall in that trap. We'll just encode it as a simple
569 * unsigned int. The encoding is:
571 * - max size: bits 0-1 (00 = 8, 01 = 16, 10 = 32, 11 = 64)
572 * - direction: bit 7 (0 = Host-to-Device [Out], 1 = Device-to-Host [In])
573 * - device: bits 8-14
574 * - endpoint: bits 15-18
575 * - Data0/1: bit 19
576 * - speed: bit 26 (0 = Full, 1 = Low Speed)
577 * - pipe type: bits 30-31 (00 = isochronous, 01 = interrupt, 10 = control, 11 = bulk)
579 * Why? Because it's arbitrary, and whatever encoding we select is really
580 * up to us. This one happens to share a lot of bit positions with the UHCI
581 * specification, so that much of the uhci driver can just mask the bits
582 * appropriately.
585 #define usb_maxpacket(dev, pipe, out) (out \
586 ? (dev)->epmaxpacketout[usb_pipeendpoint(pipe)] \
587 : (dev)->epmaxpacketin [usb_pipeendpoint(pipe)] )
588 #define usb_packetid(pipe) (((pipe) & USB_DIR_IN) ? USB_PID_IN : USB_PID_OUT)
590 #define usb_pipeout(pipe) ((((pipe) >> 7) & 1) ^ 1)
591 #define usb_pipein(pipe) (((pipe) >> 7) & 1)
592 #define usb_pipedevice(pipe) (((pipe) >> 8) & 0x7f)
593 #define usb_pipe_endpdev(pipe) (((pipe) >> 8) & 0x7ff)
594 #define usb_pipeendpoint(pipe) (((pipe) >> 15) & 0xf)
595 #define usb_pipedata(pipe) (((pipe) >> 19) & 1)
596 #define usb_pipeslow(pipe) (((pipe) >> 26) & 1)
597 #define usb_pipetype(pipe) (((pipe) >> 30) & 3)
598 #define usb_pipeisoc(pipe) (usb_pipetype((pipe)) == 0)
599 #define usb_pipeint(pipe) (usb_pipetype((pipe)) == 1)
600 #define usb_pipecontrol(pipe) (usb_pipetype((pipe)) == 2)
601 #define usb_pipebulk(pipe) (usb_pipetype((pipe)) == 3)
603 #define PIPE_DEVEP_MASK 0x0007ff00
605 /* The D0/D1 toggle bits */
606 #define usb_gettoggle(dev, ep, out) (((dev)->toggle[out] >> ep) & 1)
607 #define usb_dotoggle(dev, ep, out) ((dev)->toggle[out] ^= (1 << ep))
608 #define usb_settoggle(dev, ep, out, bit) ((dev)->toggle[out] = ((dev)->toggle[out] & ~(1 << ep)) | ((bit) << ep))
610 /* Endpoint halt control/status */
611 #define usb_endpoint_out(ep_dir) (((ep_dir >> 7) & 1) ^ 1)
612 #define usb_endpoint_halt(dev, ep, out) ((dev)->halted[out] |= (1 << (ep)))
613 #define usb_endpoint_running(dev, ep, out) ((dev)->halted[out] &= ~(1 << (ep)))
614 #define usb_endpoint_halted(dev, ep, out) ((dev)->halted[out] & (1 << (ep)))
616 static inline unsigned int __create_pipe(struct usb_device *dev, unsigned int endpoint)
618 return (dev->devnum << 8) | (endpoint << 15) | (dev->slow << 26) | dev->maxpacketsize;
621 static inline unsigned int __default_pipe(struct usb_device *dev)
623 return (dev->slow << 26);
626 /* Create various pipes... */
627 #define usb_sndctrlpipe(dev,endpoint) ((2 << 30) | __create_pipe(dev,endpoint))
628 #define usb_rcvctrlpipe(dev,endpoint) ((2 << 30) | __create_pipe(dev,endpoint) | USB_DIR_IN)
629 #define usb_sndisocpipe(dev,endpoint) ((0 << 30) | __create_pipe(dev,endpoint))
630 #define usb_rcvisocpipe(dev,endpoint) ((0 << 30) | __create_pipe(dev,endpoint) | USB_DIR_IN)
631 #define usb_sndbulkpipe(dev,endpoint) ((3 << 30) | __create_pipe(dev,endpoint))
632 #define usb_rcvbulkpipe(dev,endpoint) ((3 << 30) | __create_pipe(dev,endpoint) | USB_DIR_IN)
633 #define usb_snddefctrl(dev) ((2 << 30) | __default_pipe(dev))
634 #define usb_rcvdefctrl(dev) ((2 << 30) | __default_pipe(dev) | USB_DIR_IN)
637 * Send and receive control messages..
639 int usb_new_device(struct usb_device *dev);
640 int usb_set_address(struct usb_device *dev);
641 int usb_get_descriptor(struct usb_device *dev, unsigned char desctype, unsigned
642 char descindex, void *buf, int size);
643 int usb_get_device_descriptor(struct usb_device *dev);
644 int usb_get_status (struct usb_device *dev, int type, int target, void *data);
645 int usb_get_protocol(struct usb_device *dev);
646 int usb_set_protocol(struct usb_device *dev, int protocol);
647 int usb_set_interface(struct usb_device *dev, int interface, int alternate);
648 int usb_set_idle(struct usb_device *dev, int duration, int report_id);
649 int usb_set_interface(struct usb_device *dev, int interface, int alternate);
650 int usb_set_configuration(struct usb_device *dev, int configuration);
651 int usb_get_report(struct usb_device *dev, unsigned char type, unsigned char id, unsigned char index, void *buf, int size);
652 char *usb_string(struct usb_device *dev, int index);
653 int usb_clear_halt(struct usb_device *dev, int endp);
656 * Debugging helpers..
658 void usb_show_device_descriptor(struct usb_device_descriptor *);
659 void usb_show_config_descriptor(struct usb_config_descriptor *);
660 void usb_show_interface_descriptor(struct usb_interface_descriptor *);
661 void usb_show_hid_descriptor(struct usb_hid_descriptor * desc);
662 void usb_show_endpoint_descriptor(struct usb_endpoint_descriptor *);
663 void usb_show_device(struct usb_device *);
664 void usb_show_string(struct usb_device *dev, char *id, int index);
667 * procfs stuff
670 #ifdef CONFIG_USB_PROC
671 void proc_usb_add_bus(struct usb_bus *bus);
672 void proc_usb_remove_bus(struct usb_bus *bus);
673 void proc_usb_add_device(struct usb_device *dev);
674 void proc_usb_remove_device(struct usb_device *dev);
675 #else
676 extern inline void proc_usb_add_bus(struct usb_bus *bus) {}
677 extern inline void proc_usb_remove_bus(struct usb_bus *bus) {}
678 extern inline void proc_usb_add_device(struct usb_device *dev) {}
679 extern inline void proc_usb_remove_device(struct usb_device *dev) {}
680 #endif
682 #endif /* __KERNEL */
684 #endif