usb.h 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. /* USB core: device enumeration, descriptor parsing, hub recursion, bus
  2. scans and the hotplug watcher. Controller-specific work (transfers, root
  3. ports) goes through the usb_hcd_ops vtable (uhci.c / ohci.c). */
  4. #ifndef USB_H
  5. #define USB_H
  6. #include "usb_hcd.h"
  7. /* `lsusb` command: full scan, print the tree. */
  8. void usb_enumerate_and_print(void);
  9. /* Find + bring up a host controller; 0 when one is available. */
  10. int usb_hcd_init(void);
  11. const char *usb_hcd_name(void);
  12. /* Full bus scan: resets every connected root port, re-enumerates and calls
  13. the probe for each interface (probe may be NULL to print instead).
  14. Returns 0, -1 (no controller) or -2 (a scan is already running); every
  15. completed scan bumps the generation counter. */
  16. int usb_scan(usb_probe_fn probe);
  17. /* Cheap periodic watcher: enumerates devices on root ports whose connect
  18. state changed since the last call (internally throttled). Returns the
  19. number of ports with a new device. */
  20. int usb_hotplug_poll(usb_probe_fn probe);
  21. /* Incremented by every scan; consumers re-init when it changes. */
  22. unsigned int usb_generation(void);
  23. /* Root-port query (used to watch the port the mouse hangs off). */
  24. int usb_port_connected(unsigned int ctrl, unsigned int port);
  25. /* Control request helpers. rt is the raw bmRequestType (standard 0x80/0x00,
  26. class 0xA0/0x20, other 0xA3/0x23); the rest is the raw setup fields. */
  27. int usb_control_in(unsigned int ctrl, unsigned int addr, unsigned int mps,
  28. int low_speed, unsigned char rt, unsigned char req,
  29. unsigned short value, unsigned short index,
  30. unsigned char *buf, unsigned int len);
  31. int usb_control_out(unsigned int ctrl, unsigned int addr, unsigned int mps,
  32. int low_speed, unsigned char rt, unsigned char req,
  33. unsigned short value, unsigned short index);
  34. /* Interrupt-IN endpoints (slots 0..USB_HCD_INT_SLOTS-1; usbhid assigns
  35. one per HID interface it claims). */
  36. int usb_int_in_start(unsigned int ctrl, unsigned int slot, unsigned int addr,
  37. unsigned int ep, unsigned int mps, int low_speed);
  38. int usb_int_in_poll(unsigned int slot, unsigned char *buf, unsigned int len);
  39. void usb_int_in_stop(unsigned int slot);
  40. #endif