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.
#include <libusb/libusb.h>
-#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
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;
}
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) {
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);
}
}
}
/* 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) {
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;
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));
goto err;
}
- fpi_parse_descriptor(buffer, "bbw", &config);
+ usbi_parse_descriptor(buffer, "bbw", &config);
bigbuffer = malloc(config.wTotalLength);
if (!bigbuffer)
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);
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;
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)
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;
#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;
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;
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 */
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;
/* 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);
}
/* 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);
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;
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;
/* 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;
}
/* 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) {
}
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? */
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");
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;
}
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;
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) {
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;
/* 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)) {
}
/* 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);
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);
}
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)
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;
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) {
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;
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);
}
/* 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 USB_TYPE_STANDARD (0x00 << 5)
-#define USB_TYPE_CLASS (0x01 << 5)
-#define USB_TYPE_VENDOR (0x02 << 5)
-#define USB_TYPE_RESERVED (0x03 << 5)
-
-#define USB_RECIP_DEVICE 0x00
-#define USB_RECIP_INTERFACE 0x01
-#define USB_RECIP_ENDPOINT 0x02
-#define USB_RECIP_OTHER 0x03
-
-struct usb_dev_descriptor {
+#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 LIBUSB_TYPE_STANDARD (0x00 << 5)
+#define LIBUSB_TYPE_CLASS (0x01 << 5)
+#define LIBUSB_TYPE_VENDOR (0x02 << 5)
+#define LIBUSB_TYPE_RESERVED (0x03 << 5)
+
+#define LIBUSB_RECIP_DEVICE 0x00
+#define LIBUSB_RECIP_INTERFACE 0x01
+#define LIBUSB_RECIP_ENDPOINT 0x02
+#define LIBUSB_RECIP_OTHER 0x03
+
+struct libusb_dev_descriptor {
uint8_t bLength;
uint8_t bDescriptorType;
uint16_t bcdUSB;
uint8_t bNumConfigurations;
};
-struct usb_endpoint_descriptor {
+struct libusb_endpoint_descriptor {
uint8_t bLength;
uint8_t bDescriptorType;
uint8_t bEndpointAddress;
int extralen;
};
-struct usb_interface_descriptor {
+struct libusb_interface_descriptor {
uint8_t bLength;
uint8_t bDescriptorType;
uint8_t bInterfaceNumber;
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;
uint8_t bmAttributes;
uint8_t MaxPower;
- struct usb_interface *interface;
+ struct libusb_interface *interface;
unsigned char *extra; /* Extra descriptors */
int extralen;
/* off-the-wire structures */
-struct usb_ctrl_setup {
+struct libusb_ctrl_setup {
uint8_t bRequestType;
uint8_t bRequest;
uint16_t wValue;
};
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 {
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);
#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 {
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