Diff for /src/sys/bus/usb/usbdi.h between versions 1.2 and 1.3

version 1.2, 2003/06/17 04:28:32 version 1.3, 2003/12/30 01:01:44
Line 1 Line 1
/*        $NetBSD: usbdi.h,v 1.39 2000/01/19 00:23:59 augustss Exp $ *//*
/*        $FreeBSD: src/sys/dev/usb/usbdi.h,v 2002/02/14 02:30:47 joe Exp $      */ * $NetBSD: usbdi.h,v 1.62 2002/07/11 21:14:35 augustss Exp $
/*        $DragonFly: src/sys/dev/usb/usbdi.h,v 1.1 2003/06/16 06:11:31 dillon Exp $        */ * $FreeBSD: src/sys/dev/usb/usbdi.h,v 1.48 2003/07/14 20:31:03 joe Exp $
  * $DragonFly$
 /*  /*
  * Copyright (c) 1998 The NetBSD Foundation, Inc.   * Copyright (c) 1998 The NetBSD Foundation, Inc.
Line 46  typedef struct usbd_pipe *usbd_pipe_hand Line 48  typedef struct usbd_pipe *usbd_pipe_hand
 typedef struct usbd_xfer        *usbd_xfer_handle;  typedef struct usbd_xfer        *usbd_xfer_handle;
 typedef void                    *usbd_private_handle;  typedef void                    *usbd_private_handle;
typedef enum {          /* keep in sync with usbd_status_msgs */ typedef enum {          /* keep in sync with usbd_status_msgs */
         USBD_NORMAL_COMPLETION = 0, /* must be 0 */          USBD_NORMAL_COMPLETION = 0, /* must be 0 */
        USBD_IN_PROGRESS,        USBD_IN_PROGRESS,       /* 1 */
         /* errors */          /* errors */
        USBD_NOT_STARTED,        USBD_NOT_STARTED,       /* 3 */
        USBD_INVAL,        USBD_INVAL,             /* 4 */
        USBD_NOMEM,        USBD_NOMEM,             /* 5 */
        USBD_CANCELLED,        USBD_CANCELLED,         /* 6 */
        USBD_BAD_ADDRESS,        USBD_BAD_ADDRESS,       /* 7 */
        USBD_IN_USE,        USBD_IN_USE,            /* 8 */
        USBD_NO_ADDR,        USBD_NO_ADDR,           /* 9 */
        USBD_SET_ADDR_FAILED,        USBD_SET_ADDR_FAILED,   /* 10 */
        USBD_NO_POWER,        USBD_NO_POWER,          /* 11 */
        USBD_TOO_DEEP,        USBD_TOO_DEEP,          /* 12 */
        USBD_IOERROR,        USBD_IOERROR,           /* 13 */
        USBD_NOT_CONFIGURED,        USBD_NOT_CONFIGURED,    /* 14 */
        USBD_TIMEOUT,        USBD_TIMEOUT,           /* 15 */
        USBD_SHORT_XFER,        USBD_SHORT_XFER,        /* 16 */
        USBD_STALLED,        USBD_STALLED,           /* 17 */
        USBD_INTERRUPTED,        USBD_INTERRUPTED,       /* 18 */
        USBD_ERROR_MAX,                /* must be last */        USBD_ERROR_MAX          /* must be last */
 } usbd_status;  } usbd_status;
 typedef void (*usbd_callback)(usbd_xfer_handle, usbd_private_handle,  typedef void (*usbd_callback)(usbd_xfer_handle, usbd_private_handle,
                                   usbd_status);                              usbd_status);
 /* Open flags */  /* Open flags */
 #define USBD_EXCLUSIVE_USE      0x01  #define USBD_EXCLUSIVE_USE      0x01
Line 86  typedef void (*usbd_callback)(usbd_xfer_ Line 88  typedef void (*usbd_callback)(usbd_xfer_
 /* in usb.h #define USBD_SHORT_XFER_OK  0x04*/  /* allow short reads */  /* in usb.h #define USBD_SHORT_XFER_OK  0x04*/  /* allow short reads */
 #define USBD_FORCE_SHORT_XFER   0x08    /* force last short packet on write */  #define USBD_FORCE_SHORT_XFER   0x08    /* force last short packet on write */
 /* XXX Temporary hack XXX */  
 #define USBD_NO_TSLEEP          0x80    /* XXX use busy wait */  
 #define USBD_NO_TIMEOUT 0  #define USBD_NO_TIMEOUT 0
 #define USBD_DEFAULT_TIMEOUT 5000 /* ms = 5 s */  #define USBD_DEFAULT_TIMEOUT 5000 /* ms = 5 s */
Line 96  typedef void (*usbd_callback)(usbd_xfer_ Line 95  typedef void (*usbd_callback)(usbd_xfer_
 #define USB_CDEV_MAJOR 108  #define USB_CDEV_MAJOR 108
 #endif  #endif
usbd_status usbd_open_pipeusbd_status usbd_open_pipe(usbd_interface_handle iface, u_int8_t address,
        (usbd_interface_handle iface, u_int8_t address,                           u_int8_t flags, usbd_pipe_handle *pipe);
         u_int8_t flags, usbd_pipe_handle *pipe);usbd_status usbd_close_pipe(usbd_pipe_handle pipe);
usbd_status usbd_close_pipe     (usbd_pipe_handle pipe);usbd_status usbd_transfer(usbd_xfer_handle req);
usbd_status usbd_transfer       (usbd_xfer_handle req);usbd_xfer_handle usbd_alloc_xfer(usbd_device_handle);
usbd_xfer_handle usbd_alloc_xfer (usbd_device_handle);usbd_status usbd_free_xfer(usbd_xfer_handle xfer);
usbd_status usbd_free_xfer      (usbd_xfer_handle xfer);void usbd_setup_xfer(usbd_xfer_handle xfer, usbd_pipe_handle pipe,
void usbd_setup_xfer                     usbd_private_handle priv, void *buffer,
        (usbd_xfer_handle xfer, usbd_pipe_handle pipe,                     u_int32_t length, u_int16_t flags, u_int32_t timeout,
         usbd_private_handle priv, void *buffer,                     usbd_callback);
         u_int32_t length, u_int16_t flags, u_int32_t timeout,void usbd_setup_default_xfer(usbd_xfer_handle xfer, usbd_device_handle dev,
         usbd_callback);                             usbd_private_handle priv, u_int32_t timeout,
void usbd_setup_default_xfer                             usb_device_request_t *req, void *buffer,
        (usbd_xfer_handle xfer, usbd_device_handle dev,                             u_int32_t length, u_int16_t flags, usbd_callback);
         usbd_private_handle priv, u_int32_t timeout,void usbd_setup_isoc_xfer(usbd_xfer_handle xfer, usbd_pipe_handle pipe,
         usb_device_request_t *req,  void *buffer,                          usbd_private_handle priv, u_int16_t *frlengths,
         u_int32_t length, u_int16_t flags, usbd_callback);                          u_int32_t nframes, u_int16_t flags, usbd_callback);
void usbd_setup_isoc_xfer       void usbd_get_xfer_status(usbd_xfer_handle xfer, usbd_private_handle *priv,
        (usbd_xfer_handle xfer, usbd_pipe_handle pipe,                          void **buffer, u_int32_t *count, usbd_status *status);
         usbd_private_handle priv, u_int16_t *frlengths, 
         u_int32_t nframes, u_int16_t flags, usbd_callback); 
void usbd_get_xfer_status 
        (usbd_xfer_handle xfer, usbd_private_handle *priv, 
         void **buffer, u_int32_t *count, usbd_status *status); 
 usb_endpoint_descriptor_t *usbd_interface2endpoint_descriptor  usb_endpoint_descriptor_t *usbd_interface2endpoint_descriptor
        (usbd_interface_handle iface, u_int8_t address);                        (usbd_interface_handle iface, u_int8_t address);
 usbd_status usbd_abort_pipe(usbd_pipe_handle pipe);  usbd_status usbd_abort_pipe(usbd_pipe_handle pipe);
 usbd_status usbd_clear_endpoint_stall(usbd_pipe_handle pipe);  usbd_status usbd_clear_endpoint_stall(usbd_pipe_handle pipe);
 usbd_status usbd_clear_endpoint_stall_async(usbd_pipe_handle pipe);  usbd_status usbd_clear_endpoint_stall_async(usbd_pipe_handle pipe);
 void usbd_clear_endpoint_toggle(usbd_pipe_handle pipe);  void usbd_clear_endpoint_toggle(usbd_pipe_handle pipe);
usbd_status usbd_endpoint_countusbd_status usbd_endpoint_count(usbd_interface_handle dev, u_int8_t *count);
        (usbd_interface_handle dev, u_int8_t *count);usbd_status usbd_interface_count(usbd_device_handle dev, u_int8_t *count);
usbd_status usbd_interface_countvoid usbd_interface2device_handle(usbd_interface_handle iface,
        (usbd_device_handle dev, u_int8_t *count);                                         usbd_device_handle *dev);
usbd_status usbd_interface2device_handleusbd_status usbd_device2interface_handle(usbd_device_handle dev,
        (usbd_interface_handle iface, usbd_device_handle *dev);                              u_int8_t ifaceno, usbd_interface_handle *iface);
usbd_status usbd_device2interface_handle 
        (usbd_device_handle dev, u_int8_t ifaceno, usbd_interface_handle *iface); 
 usbd_device_handle usbd_pipe2device_handle(usbd_pipe_handle);  usbd_device_handle usbd_pipe2device_handle(usbd_pipe_handle);
void *usbd_alloc_buffer(usbd_xfer_handle req, u_int32_t size);void *usbd_alloc_buffer(usbd_xfer_handle xfer, u_int32_t size);
void usbd_free_buffer(usbd_xfer_handle req);void usbd_free_buffer(usbd_xfer_handle xfer);
 void *usbd_get_buffer(usbd_xfer_handle xfer);  void *usbd_get_buffer(usbd_xfer_handle xfer);
 usbd_status usbd_sync_transfer(usbd_xfer_handle req);  usbd_status usbd_sync_transfer(usbd_xfer_handle req);
usbd_status usbd_open_pipe_intrusbd_status usbd_open_pipe_intr(usbd_interface_handle iface, u_int8_t address,
        (usbd_interface_handle iface, u_int8_t address,                                u_int8_t flags, usbd_pipe_handle *pipe,
         u_int8_t flags, usbd_pipe_handle *pipe,                                usbd_private_handle priv, void *buffer,
         usbd_private_handle priv, void *buffer,                                u_int32_t length, usbd_callback, int);
         u_int32_t length, usbd_callback, int);usbd_status usbd_do_request(usbd_device_handle pipe, usb_device_request_t *req,
usbd_status usbd_do_request                             void *data);
        (usbd_device_handle pipe, usb_device_request_t *req, void *data);usbd_status usbd_do_request_async(usbd_device_handle pipe,
usbd_status usbd_do_request_async                                  usb_device_request_t *req, void *data);
        (usbd_device_handle pipe, usb_device_request_t *req, void *data);usbd_status usbd_do_request_flags(usbd_device_handle pipe,
usbd_status usbd_do_request_flags                                  usb_device_request_t *req,
        (usbd_device_handle pipe, usb_device_request_t *req,                                   void *data, u_int16_t flags, int*, u_int32_t);
         void *data, u_int16_t flags, int *);usbd_status usbd_do_request_flags_pipe(
         usbd_device_handle dev, usbd_pipe_handle pipe,
         usb_device_request_t *req, void *data, u_int16_t flags, int *actlen,
 usb_interface_descriptor_t *usbd_get_interface_descriptor  usb_interface_descriptor_t *usbd_get_interface_descriptor
        (usbd_interface_handle iface);                                (usbd_interface_handle iface);
usb_config_descriptor_t *usbd_get_config_descriptorusb_config_descriptor_t *usbd_get_config_descriptor(usbd_device_handle dev);
        (usbd_device_handle dev);usb_device_descriptor_t *usbd_get_device_descriptor(usbd_device_handle dev);
usb_device_descriptor_t *usbd_get_device_descriptor 
        (usbd_device_handle dev); 
 usbd_status usbd_set_interface(usbd_interface_handle, int);  usbd_status usbd_set_interface(usbd_interface_handle, int);
 int usbd_get_no_alts(usb_config_descriptor_t *, int);  int usbd_get_no_alts(usb_config_descriptor_t *, int);
usbd_status     usbd_get_interfaceusbd_status  usbd_get_interface(usbd_interface_handle iface, u_int8_t *aiface);
        (usbd_interface_handle iface, u_int8_t *aiface);void usbd_fill_deviceinfo(usbd_device_handle, struct usb_device_info *, int);
void usbd_fill_deviceinfo  
        (usbd_device_handle dev, struct usb_device_info *di); 
 int usbd_get_interface_altindex(usbd_interface_handle iface);  int usbd_get_interface_altindex(usbd_interface_handle iface);
usb_interface_descriptor_t *usbd_find_idescusb_interface_descriptor_t *usbd_find_idesc(usb_config_descriptor_t *cd,
        (usb_config_descriptor_t *cd, int iindex, int ano);                                            int iindex, int ano);
usb_endpoint_descriptor_t *usbd_find_edescusb_endpoint_descriptor_t *usbd_find_edesc(usb_config_descriptor_t *cd,
        (usb_config_descriptor_t *cd, int ifaceidx, int altidx,                                            int ifaceidx, int altidx,
             int endptidx);                                           int endptidx);
 void usbd_dopoll(usbd_interface_handle);  void usbd_dopoll(usbd_interface_handle);
void usbd_set_polling(usbd_interface_handle iface, int on);void usbd_set_polling(usbd_device_handle dev, int on);
 const char *usbd_errstr(usbd_status err);  const char *usbd_errstr(usbd_status err);
void usbd_add_event(int, usbd_device_handle);void usbd_add_dev_event(int, usbd_device_handle);
 void usbd_add_drv_event(int, usbd_device_handle, device_ptr_t);
 void usbd_devinfo(usbd_device_handle, int, char *);  void usbd_devinfo(usbd_device_handle, int, char *);
struct usbd_quirks *usbd_get_quirks(usbd_device_handle);const struct usbd_quirks *usbd_get_quirks(usbd_device_handle);
 usb_endpoint_descriptor_t *usbd_get_endpoint_descriptor  usb_endpoint_descriptor_t *usbd_get_endpoint_descriptor
        (usbd_interface_handle iface, u_int8_t address);                        (usbd_interface_handle iface, u_int8_t address);
 usbd_status usbd_reload_device_desc(usbd_device_handle);  usbd_status usbd_reload_device_desc(usbd_device_handle);
   int usbd_ratecheck(struct timeval *last);
    * The usb_task structs form a queue of things to run in the USB event
    * thread.  Normally this is just device discovery when a connect/disconnect
    * has been detected.  But it may also be used by drivers that need to
    * perform (short) tasks that must have a process context.
   struct usb_task {
           TAILQ_ENTRY(usb_task) next;
           void (*fun)(void *);
           void *arg;
           char onqueue;
   void usb_add_task(usbd_device_handle dev, struct usb_task *task);
   void usb_rem_task(usbd_device_handle dev, struct usb_task *task);
   #define usb_init_task(t, f, a) ((t)->fun = (f), (t)->arg = (a), (t)->onqueue = 0)
 struct usb_devno {  struct usb_devno {
         u_int16_t ud_vendor;          u_int16_t ud_vendor;
         u_int16_t ud_product;          u_int16_t ud_product;
Line 194  const struct usb_devno *usb_match_device Line 205  const struct usb_devno *usb_match_device
         u_int nentries, u_int sz, u_int16_t vendor, u_int16_t product);          u_int nentries, u_int sz, u_int16_t vendor, u_int16_t product);
 #define usb_lookup(tbl, vendor, product) \  #define usb_lookup(tbl, vendor, product) \
         usb_match_device((const struct usb_devno *)(tbl), sizeof (tbl) / sizeof ((tbl)[0]), sizeof ((tbl)[0]), (vendor), (product))          usb_match_device((const struct usb_devno *)(tbl), sizeof (tbl) / sizeof ((tbl)[0]), sizeof ((tbl)[0]), (vendor), (product))
   #define USB_PRODUCT_ANY         0xffff
 /* NetBSD attachment information */  /* NetBSD attachment information */
Line 205  struct usb_attach_arg { Line 217  struct usb_attach_arg {
         int                     vendor;          int                     vendor;
         int                     product;          int                     product;
         int                     release;          int                     release;
           int                     matchlvl;
         usbd_device_handle      device; /* current device */          usbd_device_handle      device; /* current device */
         usbd_interface_handle   iface; /* current interface */          usbd_interface_handle   iface; /* current interface */
         int                     usegeneric;          int                     usegeneric;
Line 258  struct usb_attach_arg { Line 271  struct usb_attach_arg {
 int usbd_driver_load(module_t mod, int what, void *arg);  int usbd_driver_load(module_t mod, int what, void *arg);
 #endif  #endif
/*/* XXX Perhaps USB should have its own levels? */
 * splusb MUST be the lowest level interrupt so that within USB callbacks#ifdef __HAVE_GENERIC_SOFT_INTERRUPTS
 * the level can be raised the appropriate level.#define splusb splsoftnet
 * XXX Should probably use a softsplusb.#else
 */#define        splusb splsoftclock
 #define splusb splbio  #define splusb splbio
   #endif /* USB_USE_SOFTINTR */
   #define splhardusb splbio
 #define IPL_USB IPL_BIO  #define IPL_USB IPL_BIO
 /* XXX */  

Removed from v.1.2  
changed lines
  Added in v.1.3