From dbb3fd871e3972b4e670f3161e7cd2f58f357600 Mon Sep 17 00:00:00 2001 From: Daniel Drake Date: Fri, 4 Jan 2008 00:54:57 +0000 Subject: [PATCH] API renaming: remove fpi and usb_ stuff fpi changed to usbi. We should not expose structures with prefix "usb_" in the public namespace as it is quite likely there will be some conflict somewhere. Instead, using "libusb_" should be safer. --- examples/dpfp.c | 12 ++-- examples/lsusb.c | 2 +- libusb/core.c | 20 +++---- libusb/descriptor.c | 74 ++++++++++++------------- libusb/io.c | 20 +++---- libusb/libusb.h | 130 ++++++++++++++++++++++---------------------- libusb/libusbi.h | 28 +++++----- 7 files changed, 143 insertions(+), 143 deletions(-) diff --git a/examples/dpfp.c b/examples/dpfp.c index ff4ae76..78251a7 100644 --- a/examples/dpfp.c +++ b/examples/dpfp.c @@ -28,10 +28,10 @@ #include -#define EP_INTR (1 | USB_ENDPOINT_IN) -#define EP_DATA (2 | USB_ENDPOINT_IN) -#define CTRL_IN (USB_TYPE_VENDOR | USB_ENDPOINT_IN) -#define CTRL_OUT (USB_TYPE_VENDOR | USB_ENDPOINT_OUT) +#define EP_INTR (1 | LIBUSB_ENDPOINT_IN) +#define EP_DATA (2 | LIBUSB_ENDPOINT_IN) +#define CTRL_IN (LIBUSB_TYPE_VENDOR | LIBUSB_ENDPOINT_IN) +#define CTRL_OUT (LIBUSB_TYPE_VENDOR | LIBUSB_ENDPOINT_OUT) #define USB_RQ 0x04 #define INTR_LENGTH 64 @@ -85,7 +85,7 @@ static struct libusb_dev *find_dpfp_device(void) libusb_find_devices(); for (dev = libusb_get_devices(); dev; dev = libusb_dev_next(dev)) { - struct usb_dev_descriptor *desc = libusb_dev_get_descriptor(dev); + struct libusb_dev_descriptor *desc = libusb_dev_get_descriptor(dev); if (desc->idVendor == 0x05ba && desc->idProduct == 0x000a) return dev; } @@ -206,7 +206,7 @@ static int set_mode(unsigned char data) static void cb_mode_changed(struct libusb_dev_handle *_devh, struct libusb_urb_handle *urbh, enum fp_urb_cb_status status, - struct usb_ctrl_setup *setup, unsigned char *data, int actual_length, + struct libusb_ctrl_setup *setup, unsigned char *data, int actual_length, void *user_data) { if (status != FP_URB_COMPLETED) { diff --git a/examples/lsusb.c b/examples/lsusb.c index d093709..8145d63 100644 --- a/examples/lsusb.c +++ b/examples/lsusb.c @@ -26,7 +26,7 @@ void print_devs(libusb_dev *devs) libusb_dev *dev; for (dev = devs; dev; dev = libusb_dev_next(dev)) { - struct usb_dev_descriptor *desc = libusb_dev_get_descriptor(dev); + struct libusb_dev_descriptor *desc = libusb_dev_get_descriptor(dev); printf("%04x:%04x\n", desc->idVendor, desc->idProduct); } } diff --git a/libusb/core.c b/libusb/core.c index dc54720..3540e54 100644 --- a/libusb/core.c +++ b/libusb/core.c @@ -68,7 +68,7 @@ static int scan_device(char *busdir, const char *devnum) } /* FIXME: short read handling? */ - fpi_parse_descriptor(raw_desc, "bbWbbbbWWWbbbb", &dev->desc); + usbi_parse_descriptor(raw_desc, "bbWbbbbWWWbbbb", &dev->desc); /* Now try to fetch the rest of the descriptors */ if (dev->desc.bNumConfigurations > USB_MAXCONFIG) { @@ -83,7 +83,7 @@ static int scan_device(char *busdir, const char *devnum) goto err; } - tmp = dev->desc.bNumConfigurations * sizeof(struct usb_config_descriptor); + tmp = dev->desc.bNumConfigurations * sizeof(struct libusb_config_descriptor); dev->config = malloc(tmp); if (!dev->config) { r = -1; @@ -94,7 +94,7 @@ static int scan_device(char *busdir, const char *devnum) for (i = 0; i < dev->desc.bNumConfigurations; i++) { unsigned char buffer[8], *bigbuffer; - struct usb_config_descriptor config; + struct libusb_config_descriptor config; /* Get the first 8 bytes to figure out what the total length is */ r = read(fd, buffer, sizeof(buffer)); @@ -103,7 +103,7 @@ static int scan_device(char *busdir, const char *devnum) goto err; } - fpi_parse_descriptor(buffer, "bbw", &config); + usbi_parse_descriptor(buffer, "bbw", &config); bigbuffer = malloc(config.wTotalLength); if (!bigbuffer) @@ -120,7 +120,7 @@ static int scan_device(char *busdir, const char *devnum) goto err; } - r = fpi_parse_configuration(&dev->config[i], bigbuffer); + r = usbi_parse_configuration(&dev->config[i], bigbuffer); if (r > 0) fp_warn("descriptor data still left\n"); free(bigbuffer); @@ -204,13 +204,13 @@ API_EXPORTED struct libusb_dev *libusb_dev_next(struct libusb_dev *dev) return list_entry(head->next, struct libusb_dev, list); } -API_EXPORTED struct usb_dev_descriptor *libusb_dev_get_descriptor( +API_EXPORTED struct libusb_dev_descriptor *libusb_dev_get_descriptor( struct libusb_dev *dev) { return &dev->desc; } -API_EXPORTED struct usb_config_descriptor *libusb_dev_get_config( +API_EXPORTED struct libusb_config_descriptor *libusb_dev_get_config( struct libusb_dev *dev) { return dev->config; @@ -291,7 +291,7 @@ API_EXPORTED int libusb_init(int signum) fp_dbg(""); list_init(&usb_devs); list_init(&open_devs); - return fpi_io_init(signum); + return usbi_io_init(signum); } API_EXPORTED void libusb_exit(void) @@ -303,10 +303,10 @@ API_EXPORTED void libusb_exit(void) list_for_each_entry(devh, &open_devs, list) do_close(devh); } - fpi_io_exit(); + usbi_io_exit(); } -void fpi_log(enum fpi_log_level level, const char *function, +void usbi_log(enum usbi_log_level level, const char *function, const char *format, ...) { va_list args; diff --git a/libusb/descriptor.c b/libusb/descriptor.c index d0c8bf9..57aa688 100644 --- a/libusb/descriptor.c +++ b/libusb/descriptor.c @@ -30,7 +30,7 @@ #define ENDPOINT_DESC_LENGTH 7 #define ENDPOINT_AUDIO_DESC_LENGTH 9 -int fpi_parse_descriptor(unsigned char *source, char *descriptor, void *dest) +int usbi_parse_descriptor(unsigned char *source, char *descriptor, void *dest) { unsigned char *sp = source, *dp = dest; uint16_t w; @@ -66,7 +66,7 @@ int fpi_parse_descriptor(unsigned char *source, char *descriptor, void *dest) return sp - source; } -static int parse_endpoint(struct usb_endpoint_descriptor *endpoint, +static int parse_endpoint(struct libusb_endpoint_descriptor *endpoint, unsigned char *buffer, int size) { struct usb_descriptor_header header; @@ -74,7 +74,7 @@ static int parse_endpoint(struct usb_endpoint_descriptor *endpoint, int parsed = 0; int len; - fpi_parse_descriptor(buffer, "bb", &header); + usbi_parse_descriptor(buffer, "bb", &header); /* Everything should be fine being passed into here, but we sanity */ /* check JIC */ @@ -83,16 +83,16 @@ static int parse_endpoint(struct usb_endpoint_descriptor *endpoint, return -1; } - if (header.bDescriptorType != USB_DT_ENDPOINT) { + if (header.bDescriptorType != LIBUSB_DT_ENDPOINT) { fp_err("unexpected descriptor %x (expected %x)", - header.bDescriptorType, USB_DT_ENDPOINT); + header.bDescriptorType, LIBUSB_DT_ENDPOINT); return parsed; } if (header.bLength >= ENDPOINT_AUDIO_DESC_LENGTH) - fpi_parse_descriptor(buffer, "bbbbwbbb", endpoint); + usbi_parse_descriptor(buffer, "bbbbwbbb", endpoint); else if (header.bLength >= ENDPOINT_DESC_LENGTH) - fpi_parse_descriptor(buffer, "bbbbwb", endpoint); + usbi_parse_descriptor(buffer, "bbbbwb", endpoint); buffer += header.bLength; size -= header.bLength; @@ -102,7 +102,7 @@ static int parse_endpoint(struct usb_endpoint_descriptor *endpoint, /* descriptors */ begin = buffer; while (size >= DESC_HEADER_LENGTH) { - fpi_parse_descriptor(buffer, "bb", &header); + usbi_parse_descriptor(buffer, "bb", &header); if (header.bLength < 2) { fp_err("invalid descriptor length %d", header.bLength); @@ -110,10 +110,10 @@ static int parse_endpoint(struct usb_endpoint_descriptor *endpoint, } /* If we find another "proper" descriptor then we're done */ - if ((header.bDescriptorType == USB_DT_ENDPOINT) || - (header.bDescriptorType == USB_DT_INTERFACE) || - (header.bDescriptorType == USB_DT_CONFIG) || - (header.bDescriptorType == USB_DT_DEVICE)) + if ((header.bDescriptorType == LIBUSB_DT_ENDPOINT) || + (header.bDescriptorType == LIBUSB_DT_INTERFACE) || + (header.bDescriptorType == LIBUSB_DT_CONFIG) || + (header.bDescriptorType == LIBUSB_DT_DEVICE)) break; fp_dbg("skipping descriptor %x", header.bDescriptorType); @@ -143,7 +143,7 @@ static int parse_endpoint(struct usb_endpoint_descriptor *endpoint, return parsed; } -static int parse_interface(struct usb_interface *interface, +static int parse_interface(struct libusb_interface *interface, unsigned char *buffer, int size) { int i; @@ -152,21 +152,21 @@ static int parse_interface(struct usb_interface *interface, int parsed = 0; int tmp; struct usb_descriptor_header header; - struct usb_interface_descriptor *ifp; + struct libusb_interface_descriptor *ifp; unsigned char *begin; interface->num_altsetting = 0; while (size >= INTERFACE_DESC_LENGTH) { interface->altsetting = realloc(interface->altsetting, - sizeof(struct usb_interface_descriptor) * + sizeof(struct libusb_interface_descriptor) * (interface->num_altsetting + 1)); if (!interface->altsetting) return -1; ifp = interface->altsetting + interface->num_altsetting; interface->num_altsetting++; - fpi_parse_descriptor(buffer, "bbbbbbbbb", ifp); + usbi_parse_descriptor(buffer, "bbbbbbbbb", ifp); /* Skip over the interface */ buffer += ifp->bLength; @@ -177,17 +177,17 @@ static int parse_interface(struct usb_interface *interface, /* Skip over any interface, class or vendor descriptors */ while (size >= DESC_HEADER_LENGTH) { - fpi_parse_descriptor(buffer, "bb", &header); + usbi_parse_descriptor(buffer, "bb", &header); if (header.bLength < 2) { fp_err("invalid descriptor of length %d", header.bLength); return -1; } /* If we find another "proper" descriptor then we're done */ - if ((header.bDescriptorType == USB_DT_INTERFACE) || - (header.bDescriptorType == USB_DT_ENDPOINT) || - (header.bDescriptorType == USB_DT_CONFIG) || - (header.bDescriptorType == USB_DT_DEVICE)) + if ((header.bDescriptorType == LIBUSB_DT_INTERFACE) || + (header.bDescriptorType == LIBUSB_DT_ENDPOINT) || + (header.bDescriptorType == LIBUSB_DT_CONFIG) || + (header.bDescriptorType == LIBUSB_DT_DEVICE)) break; buffer += header.bLength; @@ -213,10 +213,10 @@ static int parse_interface(struct usb_interface *interface, } /* Did we hit an unexpected descriptor? */ - fpi_parse_descriptor(buffer, "bb", &header); + usbi_parse_descriptor(buffer, "bb", &header); if ((size >= DESC_HEADER_LENGTH) && - ((header.bDescriptorType == USB_DT_CONFIG) || - (header.bDescriptorType == USB_DT_DEVICE))) + ((header.bDescriptorType == LIBUSB_DT_CONFIG) || + (header.bDescriptorType == LIBUSB_DT_DEVICE))) return parsed; if (ifp->bNumEndpoints > USB_MAXENDPOINTS) { @@ -226,7 +226,7 @@ static int parse_interface(struct usb_interface *interface, } if (ifp->bNumEndpoints > 0) { - tmp = ifp->bNumEndpoints * sizeof(struct usb_endpoint_descriptor); + tmp = ifp->bNumEndpoints * sizeof(struct libusb_endpoint_descriptor); ifp->endpoint = malloc(tmp); if (!ifp->endpoint) /* FIXME will leak memory? */ @@ -234,7 +234,7 @@ static int parse_interface(struct usb_interface *interface, memset(ifp->endpoint, 0, tmp); for (i = 0; i < ifp->bNumEndpoints; i++) { - fpi_parse_descriptor(buffer, "bb", &header); + usbi_parse_descriptor(buffer, "bb", &header); if (header.bLength > size) { fp_err("ran out of descriptors parsing"); @@ -255,9 +255,9 @@ static int parse_interface(struct usb_interface *interface, ifp->endpoint = NULL; /* We check to see if it's an alternate to this one */ - ifp = (struct usb_interface_descriptor *) buffer; - if (size < USB_DT_INTERFACE_SIZE || - ifp->bDescriptorType != USB_DT_INTERFACE || + ifp = (struct libusb_interface_descriptor *) buffer; + if (size < LIBUSB_DT_INTERFACE_SIZE || + ifp->bDescriptorType != LIBUSB_DT_INTERFACE || !ifp->bAlternateSetting) return parsed; } @@ -265,7 +265,7 @@ static int parse_interface(struct usb_interface *interface, return parsed; } -int fpi_parse_configuration(struct usb_config_descriptor *config, +int usbi_parse_configuration(struct libusb_config_descriptor *config, unsigned char *buffer) { int i; @@ -274,7 +274,7 @@ int fpi_parse_configuration(struct usb_config_descriptor *config, int tmp; struct usb_descriptor_header header; - fpi_parse_descriptor(buffer, "bbwbbbbb", config); + usbi_parse_descriptor(buffer, "bbwbbbbb", config); size = config->wTotalLength; if (config->bNumInterfaces > USB_MAXINTERFACES) { @@ -282,7 +282,7 @@ int fpi_parse_configuration(struct usb_config_descriptor *config, return -1; } - tmp = config->bNumInterfaces * sizeof(struct usb_interface); + tmp = config->bNumInterfaces * sizeof(struct libusb_interface); config->interface = malloc(tmp); if (!config->interface) return -1; @@ -302,7 +302,7 @@ int fpi_parse_configuration(struct usb_config_descriptor *config, /* Specific descriptors */ begin = buffer; while (size >= DESC_HEADER_LENGTH) { - fpi_parse_descriptor(buffer, "bb", &header); + usbi_parse_descriptor(buffer, "bb", &header); if ((header.bLength > size) || (header.bLength < DESC_HEADER_LENGTH)) { @@ -311,10 +311,10 @@ int fpi_parse_configuration(struct usb_config_descriptor *config, } /* If we find another "proper" descriptor then we're done */ - if ((header.bDescriptorType == USB_DT_ENDPOINT) || - (header.bDescriptorType == USB_DT_INTERFACE) || - (header.bDescriptorType == USB_DT_CONFIG) || - (header.bDescriptorType == USB_DT_DEVICE)) + if ((header.bDescriptorType == LIBUSB_DT_ENDPOINT) || + (header.bDescriptorType == LIBUSB_DT_INTERFACE) || + (header.bDescriptorType == LIBUSB_DT_CONFIG) || + (header.bDescriptorType == LIBUSB_DT_DEVICE)) break; fp_dbg("skipping descriptor 0x%x\n", header.bDescriptorType); diff --git a/libusb/io.c b/libusb/io.c index 47e7bba..20b2798 100644 --- a/libusb/io.c +++ b/libusb/io.c @@ -72,13 +72,13 @@ static int setup_signalfd(int _signum) return sigprocmask(SIG_BLOCK, &sigset, NULL); } -int fpi_io_init(int _signum) +int usbi_io_init(int _signum) { list_init(&flying_urbs); return setup_signalfd(signum); } -void fpi_io_exit(void) +void usbi_io_exit(void) { close(sigfd); } @@ -201,9 +201,9 @@ API_EXPORTED struct libusb_urb_handle *libusb_submit_ctrl_msg( libusb_ctrl_cb_fn callback, void *user_data, unsigned int timeout) { struct libusb_urb_handle *urbh = malloc(sizeof(*urbh)); - struct usb_ctrl_setup *setup; + struct libusb_ctrl_setup *setup; unsigned char *urbdata; - int urbdata_length = sizeof(struct usb_ctrl_setup) + msg->length; + int urbdata_length = sizeof(struct libusb_ctrl_setup) + msg->length; int r; if (!urbh) @@ -227,15 +227,15 @@ API_EXPORTED struct libusb_urb_handle *libusb_submit_ctrl_msg( fp_dbg("RQT=%02x RQ=%02x VAL=%04x IDX=%04x length=%d", msg->requesttype, msg->request, msg->value, msg->index, msg->length); - setup = (struct usb_ctrl_setup *) urbdata; + setup = (struct libusb_ctrl_setup *) urbdata; setup->bRequestType = msg->requesttype; setup->bRequest = msg->request; setup->wValue = cpu_to_le16(msg->value); setup->wIndex = cpu_to_le16(msg->index); setup->wLength = cpu_to_le16(msg->length); - if ((msg->requesttype & 0x80) == USB_ENDPOINT_OUT) - memcpy(urbdata + sizeof(struct usb_ctrl_setup), msg->data, msg->length); + if ((msg->requesttype & 0x80) == LIBUSB_ENDPOINT_OUT) + memcpy(urbdata + sizeof(struct libusb_ctrl_setup), msg->data, msg->length); urbh->urb_type = USB_URB_TYPE_CONTROL; urbh->buffer = urbdata; @@ -349,7 +349,7 @@ int handle_transfer_completion(struct libusb_dev_handle *devh, libusb_ctrl_cb_fn callback = urbh->callback; if (callback) callback(devh, urbh, status, urb->buffer, - urb->buffer + sizeof(struct usb_ctrl_setup), urbh->transferred, + urb->buffer + sizeof(struct libusb_ctrl_setup), urbh->transferred, urbh->user_data); } else if (urb->type == USB_URB_TYPE_BULK || urb->type == USB_URB_TYPE_INTERRUPT) { @@ -567,7 +567,7 @@ struct sync_ctrl_handle { static void ctrl_msg_cb(struct libusb_dev_handle *devh, struct libusb_urb_handle *urbh, enum fp_urb_cb_status status, - struct usb_ctrl_setup *setup, unsigned char *data, int actual_length, + struct libusb_ctrl_setup *setup, unsigned char *data, int actual_length, void *user_data) { struct sync_ctrl_handle *ctrlh = (struct sync_ctrl_handle *) user_data; @@ -575,7 +575,7 @@ static void ctrl_msg_cb(struct libusb_dev_handle *devh, if (status == FP_URB_COMPLETED) { /* copy results into user-defined buffer */ - if (setup->bRequestType & USB_ENDPOINT_IN) + if (setup->bRequestType & LIBUSB_ENDPOINT_IN) memcpy(ctrlh->data, data, actual_length); } diff --git a/libusb/libusb.h b/libusb/libusb.h index 2dfe896..63edb75 100644 --- a/libusb/libusb.h +++ b/libusb/libusb.h @@ -27,74 +27,74 @@ /* standard USB stuff */ /* Device and/or Interface Class codes */ -#define USB_CLASS_PER_INTERFACE 0 /* for DeviceClass */ -#define USB_CLASS_AUDIO 1 -#define USB_CLASS_COMM 2 -#define USB_CLASS_HID 3 -#define USB_CLASS_PRINTER 7 -#define USB_CLASS_PTP 6 -#define USB_CLASS_MASS_STORAGE 8 -#define USB_CLASS_HUB 9 -#define USB_CLASS_DATA 10 -#define USB_CLASS_VENDOR_SPEC 0xff +#define LIBUSB_CLASS_PER_INTERFACE 0 /* for DeviceClass */ +#define LIBUSB_CLASS_AUDIO 1 +#define LIBUSB_CLASS_COMM 2 +#define LIBUSB_CLASS_HID 3 +#define LIBUSB_CLASS_PRINTER 7 +#define LIBUSB_CLASS_PTP 6 +#define LIBUSB_CLASS_MASS_STORAGE 8 +#define LIBUSB_CLASS_HUB 9 +#define LIBUSB_CLASS_DATA 10 +#define LIBUSB_CLASS_VENDOR_SPEC 0xff /* Descriptor types */ -#define USB_DT_DEVICE 0x01 -#define USB_DT_CONFIG 0x02 -#define USB_DT_STRING 0x03 -#define USB_DT_INTERFACE 0x04 -#define USB_DT_ENDPOINT 0x05 -#define USB_DT_HID 0x21 -#define USB_DT_REPORT 0x22 -#define USB_DT_PHYSICAL 0x23 -#define USB_DT_HUB 0x29 +#define LIBUSB_DT_DEVICE 0x01 +#define LIBUSB_DT_CONFIG 0x02 +#define LIBUSB_DT_STRING 0x03 +#define LIBUSB_DT_INTERFACE 0x04 +#define LIBUSB_DT_ENDPOINT 0x05 +#define LIBUSB_DT_HID 0x21 +#define LIBUSB_DT_REPORT 0x22 +#define LIBUSB_DT_PHYSICAL 0x23 +#define LIBUSB_DT_HUB 0x29 /* 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 */ -#define USB_DT_HUB_NONVAR_SIZE 7 +#define LIBUSB_DT_DEVICE_SIZE 18 +#define LIBUSB_DT_CONFIG_SIZE 9 +#define LIBUSB_DT_INTERFACE_SIZE 9 +#define LIBUSB_DT_ENDPOINT_SIZE 7 +#define LIBUSB_DT_ENDPOINT_AUDIO_SIZE 9 /* Audio extension */ +#define LIBUSB_DT_HUB_NONVAR_SIZE 7 -#define USB_ENDPOINT_ADDRESS_MASK 0x0f /* in bEndpointAddress */ -#define USB_ENDPOINT_DIR_MASK 0x80 +#define LIBUSB_ENDPOINT_ADDRESS_MASK 0x0f /* in bEndpointAddress */ +#define LIBUSB_ENDPOINT_DIR_MASK 0x80 -#define USB_ENDPOINT_IN 0x80 -#define USB_ENDPOINT_OUT 0x00 +#define LIBUSB_ENDPOINT_IN 0x80 +#define LIBUSB_ENDPOINT_OUT 0x00 -#define USB_ENDPOINT_TYPE_MASK 0x03 /* in bmAttributes */ -#define USB_ENDPOINT_TYPE_CONTROL 0 -#define USB_ENDPOINT_TYPE_ISOCHRONOUS 1 -#define USB_ENDPOINT_TYPE_BULK 2 -#define USB_ENDPOINT_TYPE_INTERRUPT 3 +#define LIBUSB_ENDPOINT_TYPE_MASK 0x03 /* in bmAttributes */ +#define LIBUSB_ENDPOINT_TYPE_CONTROL 0 +#define LIBUSB_ENDPOINT_TYPE_ISOCHRONOUS 1 +#define LIBUSB_ENDPOINT_TYPE_BULK 2 +#define LIBUSB_ENDPOINT_TYPE_INTERRUPT 3 /* Standard requests */ -#define USB_REQ_GET_STATUS 0x00 -#define USB_REQ_CLEAR_FEATURE 0x01 +#define LIBUSB_REQ_GET_STATUS 0x00 +#define LIBUSB_REQ_CLEAR_FEATURE 0x01 /* 0x02 is reserved */ -#define USB_REQ_SET_FEATURE 0x03 +#define LIBUSB_REQ_SET_FEATURE 0x03 /* 0x04 is reserved */ -#define USB_REQ_SET_ADDRESS 0x05 -#define USB_REQ_GET_DESCRIPTOR 0x06 -#define USB_REQ_SET_DESCRIPTOR 0x07 -#define USB_REQ_GET_CONFIGURATION 0x08 -#define USB_REQ_SET_CONFIGURATION 0x09 -#define USB_REQ_GET_INTERFACE 0x0A -#define USB_REQ_SET_INTERFACE 0x0B -#define USB_REQ_SYNCH_FRAME 0x0C +#define LIBUSB_REQ_SET_ADDRESS 0x05 +#define LIBUSB_REQ_GET_DESCRIPTOR 0x06 +#define LIBUSB_REQ_SET_DESCRIPTOR 0x07 +#define LIBUSB_REQ_GET_CONFIGURATION 0x08 +#define LIBUSB_REQ_SET_CONFIGURATION 0x09 +#define LIBUSB_REQ_GET_INTERFACE 0x0A +#define LIBUSB_REQ_SET_INTERFACE 0x0B +#define LIBUSB_REQ_SYNCH_FRAME 0x0C -#define USB_TYPE_STANDARD (0x00 << 5) -#define USB_TYPE_CLASS (0x01 << 5) -#define USB_TYPE_VENDOR (0x02 << 5) -#define USB_TYPE_RESERVED (0x03 << 5) +#define LIBUSB_TYPE_STANDARD (0x00 << 5) +#define LIBUSB_TYPE_CLASS (0x01 << 5) +#define LIBUSB_TYPE_VENDOR (0x02 << 5) +#define LIBUSB_TYPE_RESERVED (0x03 << 5) -#define USB_RECIP_DEVICE 0x00 -#define USB_RECIP_INTERFACE 0x01 -#define USB_RECIP_ENDPOINT 0x02 -#define USB_RECIP_OTHER 0x03 +#define LIBUSB_RECIP_DEVICE 0x00 +#define LIBUSB_RECIP_INTERFACE 0x01 +#define LIBUSB_RECIP_ENDPOINT 0x02 +#define LIBUSB_RECIP_OTHER 0x03 -struct usb_dev_descriptor { +struct libusb_dev_descriptor { uint8_t bLength; uint8_t bDescriptorType; uint16_t bcdUSB; @@ -111,7 +111,7 @@ struct usb_dev_descriptor { uint8_t bNumConfigurations; }; -struct usb_endpoint_descriptor { +struct libusb_endpoint_descriptor { uint8_t bLength; uint8_t bDescriptorType; uint8_t bEndpointAddress; @@ -125,7 +125,7 @@ struct usb_endpoint_descriptor { int extralen; }; -struct usb_interface_descriptor { +struct libusb_interface_descriptor { uint8_t bLength; uint8_t bDescriptorType; uint8_t bInterfaceNumber; @@ -136,18 +136,18 @@ struct usb_interface_descriptor { uint8_t bInterfaceProtocol; uint8_t iInterface; - struct usb_endpoint_descriptor *endpoint; + struct libusb_endpoint_descriptor *endpoint; unsigned char *extra; /* Extra descriptors */ int extralen; }; -struct usb_interface { - struct usb_interface_descriptor *altsetting; +struct libusb_interface { + struct libusb_interface_descriptor *altsetting; int num_altsetting; }; -struct usb_config_descriptor { +struct libusb_config_descriptor { uint8_t bLength; uint8_t bDescriptorType; uint16_t wTotalLength; @@ -157,7 +157,7 @@ struct usb_config_descriptor { uint8_t bmAttributes; uint8_t MaxPower; - struct usb_interface *interface; + struct libusb_interface *interface; unsigned char *extra; /* Extra descriptors */ int extralen; @@ -165,7 +165,7 @@ struct usb_config_descriptor { /* off-the-wire structures */ -struct usb_ctrl_setup { +struct libusb_ctrl_setup { uint8_t bRequestType; uint8_t bRequest; uint16_t wValue; @@ -201,7 +201,7 @@ struct libusb_ctrl_msg { }; typedef void (*libusb_ctrl_cb_fn)(libusb_dev_handle *devh, libusb_urb_handle *urbh, - enum fp_urb_cb_status status, struct usb_ctrl_setup *setup, + enum fp_urb_cb_status status, struct libusb_ctrl_setup *setup, unsigned char *data, int actual_length, void *user_data); struct libusb_bulk_msg { @@ -219,8 +219,8 @@ void libusb_exit(void); int libusb_find_devices(void); libusb_dev *libusb_get_devices(void); -struct usb_dev_descriptor *libusb_dev_get_descriptor(libusb_dev *dev); -struct usb_config_descriptor *libusb_dev_get_config(libusb_dev *dev); +struct libusb_dev_descriptor *libusb_dev_get_descriptor(libusb_dev *dev); +struct libusb_config_descriptor *libusb_dev_get_config(libusb_dev *dev); libusb_dev *libusb_dev_next(libusb_dev *dev); libusb_dev_handle *libusb_devh_open(libusb_dev *dev); diff --git a/libusb/libusbi.h b/libusb/libusbi.h index bea6d59..d6d3b01 100644 --- a/libusb/libusbi.h +++ b/libusb/libusbi.h @@ -118,36 +118,36 @@ static inline void list_del(struct list_head *entry) #define TIMESPEC_IS_SET(ts) ((ts)->tv_sec != 0 || (ts)->tv_nsec != 0) -enum fpi_log_level { +enum usbi_log_level { LOG_LEVEL_DEBUG, LOG_LEVEL_INFO, LOG_LEVEL_WARNING, LOG_LEVEL_ERROR, }; -void fpi_log(enum fpi_log_level, const char *function, const char *format, ...); +void usbi_log(enum usbi_log_level, const char *function, const char *format, ...); #ifdef ENABLE_LOGGING -#define _fpi_log(level, fmt...) fpi_log(level, __FUNCTION__, fmt) +#define _usbi_log(level, fmt...) usbi_log(level, __FUNCTION__, fmt) #else -#define _fpi_log(level, fmt...) +#define _usbi_log(level, fmt...) #endif #ifdef ENABLE_DEBUG_LOGGING -#define fp_dbg(fmt...) _fpi_log(LOG_LEVEL_DEBUG, fmt) +#define fp_dbg(fmt...) _usbi_log(LOG_LEVEL_DEBUG, fmt) #else #define fp_dbg(fmt...) #endif -#define fp_info(fmt...) _fpi_log(LOG_LEVEL_INFO, fmt) -#define fp_warn(fmt...) _fpi_log(LOG_LEVEL_WARNING, fmt) -#define fp_err(fmt...) _fpi_log(LOG_LEVEL_ERROR, fmt) +#define fp_info(fmt...) _usbi_log(LOG_LEVEL_INFO, fmt) +#define fp_warn(fmt...) _usbi_log(LOG_LEVEL_WARNING, fmt) +#define fp_err(fmt...) _usbi_log(LOG_LEVEL_ERROR, fmt) struct libusb_dev { struct list_head list; char *nodepath; - struct usb_dev_descriptor desc; - struct usb_config_descriptor *config; + struct libusb_dev_descriptor desc; + struct libusb_config_descriptor *config; }; struct libusb_dev_handle { @@ -193,11 +193,11 @@ struct usb_descriptor_header { extern struct list_head open_devs; -int fpi_io_init(int _signum); -void fpi_io_exit(void); +int usbi_io_init(int _signum); +void usbi_io_exit(void); -int fpi_parse_descriptor(unsigned char *source, char *descriptor, void *dest); -int fpi_parse_configuration(struct usb_config_descriptor *config, +int usbi_parse_descriptor(unsigned char *source, char *descriptor, void *dest); +int usbi_parse_configuration(struct libusb_config_descriptor *config, unsigned char *buffer); #endif