usb.h | usb.h | |||
---|---|---|---|---|
/* | ||||
* Prototypes, structure definitions and macros. | ||||
* | ||||
* Copyright (c) 2000-2003 Johannes Erdfelt <johannes@erdfelt.com> | ||||
* | ||||
* This library is covered by the LGPL, read LICENSE for details. | ||||
* | ||||
* This file (and only this file) may alternatively be licensed under the | ||||
* BSD license as well, read LICENSE for details. | ||||
*/ | ||||
#ifndef __USB_H__ | #ifndef __USB_H__ | |||
#define __USB_H__ | #define __USB_H__ | |||
#include <unistd.h> | #include <unistd.h> | |||
#include <stdlib.h> | #include <stdlib.h> | |||
#include <limits.h> | #include <limits.h> | |||
#include <dirent.h> | #include <dirent.h> | |||
/* | /* | |||
skipping to change at line 74 | skipping to change at line 84 | |||
u_int16_t wData[1]; | u_int16_t wData[1]; | |||
}; | }; | |||
/* HID descriptor */ | /* HID descriptor */ | |||
struct usb_hid_descriptor { | struct usb_hid_descriptor { | |||
u_int8_t bLength; | u_int8_t bLength; | |||
u_int8_t bDescriptorType; | u_int8_t bDescriptorType; | |||
u_int16_t bcdHID; | u_int16_t bcdHID; | |||
u_int8_t bCountryCode; | u_int8_t bCountryCode; | |||
u_int8_t bNumDescriptors; | u_int8_t bNumDescriptors; | |||
/* u_int8_t bReportDescriptorType; */ | ||||
/* u_int16_t wDescriptorLength; */ | ||||
/* ... */ | ||||
}; | }; | |||
/* Endpoint descriptor */ | /* Endpoint descriptor */ | |||
#define USB_MAXENDPOINTS 32 | #define USB_MAXENDPOINTS 32 | |||
struct usb_endpoint_descriptor { | struct usb_endpoint_descriptor { | |||
u_int8_t bLength; | u_int8_t bLength; | |||
u_int8_t bDescriptorType; | u_int8_t bDescriptorType; | |||
u_int8_t bEndpointAddress; | u_int8_t bEndpointAddress; | |||
u_int8_t bmAttributes; | u_int8_t bmAttributes; | |||
u_int16_t wMaxPacketSize; | u_int16_t wMaxPacketSize; | |||
skipping to change at line 163 | skipping to change at line 176 | |||
u_int8_t bMaxPacketSize0; | u_int8_t bMaxPacketSize0; | |||
u_int16_t idVendor; | u_int16_t idVendor; | |||
u_int16_t idProduct; | u_int16_t idProduct; | |||
u_int16_t bcdDevice; | u_int16_t bcdDevice; | |||
u_int8_t iManufacturer; | u_int8_t iManufacturer; | |||
u_int8_t iProduct; | u_int8_t iProduct; | |||
u_int8_t iSerialNumber; | u_int8_t iSerialNumber; | |||
u_int8_t bNumConfigurations; | u_int8_t bNumConfigurations; | |||
}; | }; | |||
struct usb_ctrl_setup { | ||||
u_int8_t bRequestType; | ||||
u_int8_t bRequest; | ||||
u_int16_t wValue; | ||||
u_int16_t wIndex; | ||||
u_int16_t wLength; | ||||
}; | ||||
/* | /* | |||
* Standard requests | * Standard requests | |||
*/ | */ | |||
#define USB_REQ_GET_STATUS 0x00 | #define USB_REQ_GET_STATUS 0x00 | |||
#define USB_REQ_CLEAR_FEATURE 0x01 | #define USB_REQ_CLEAR_FEATURE 0x01 | |||
/* 0x02 is reserved */ | /* 0x02 is reserved */ | |||
#define USB_REQ_SET_FEATURE 0x03 | #define USB_REQ_SET_FEATURE 0x03 | |||
/* 0x04 is reserved */ | /* 0x04 is reserved */ | |||
#define USB_REQ_SET_ADDRESS 0x05 | #define USB_REQ_SET_ADDRESS 0x05 | |||
#define USB_REQ_GET_DESCRIPTOR 0x06 | #define USB_REQ_GET_DESCRIPTOR 0x06 | |||
skipping to change at line 233 | skipping to change at line 254 | |||
void *dev; /* Darwin support */ | void *dev; /* Darwin support */ | |||
}; | }; | |||
struct usb_bus { | struct usb_bus { | |||
struct usb_bus *next, *prev; | struct usb_bus *next, *prev; | |||
char dirname[PATH_MAX + 1]; | char dirname[PATH_MAX + 1]; | |||
struct usb_device *devices; | struct usb_device *devices; | |||
u_int32_t location; | ||||
}; | }; | |||
struct usb_dev_handle; | struct usb_dev_handle; | |||
typedef struct usb_dev_handle usb_dev_handle; | typedef struct usb_dev_handle usb_dev_handle; | |||
/* Variables */ | /* Variables */ | |||
extern struct usb_bus *usb_busses; | extern struct usb_bus *usb_busses; | |||
#ifdef __cplusplus | #ifdef __cplusplus | |||
extern "C" { | extern "C" { | |||
#endif | #endif | |||
/* Function prototypes */ | /* Function prototypes */ | |||
/* usb.c */ | ||||
usb_dev_handle *usb_open(struct usb_device *dev); | usb_dev_handle *usb_open(struct usb_device *dev); | |||
int usb_close(usb_dev_handle *dev); | int usb_close(usb_dev_handle *dev); | |||
int usb_get_string(usb_dev_handle *dev, int index, int langid, char *buf, | ||||
size_t buflen); | ||||
int usb_get_string_simple(usb_dev_handle *dev, int index, char *buf, | ||||
size_t buflen); | ||||
/* descriptors.c */ | ||||
int usb_get_descriptor_by_endpoint(usb_dev_handle *udev, int ep, | ||||
unsigned char type, unsigned char index, void *buf, int size); | ||||
int usb_get_descriptor(usb_dev_handle *udev, unsigned char type, | ||||
unsigned char index, void *buf, int size); | ||||
/* <arch>.c */ | ||||
int usb_bulk_write(usb_dev_handle *dev, int ep, char *bytes, int size, | int usb_bulk_write(usb_dev_handle *dev, int ep, char *bytes, int size, | |||
int timeout); | int timeout); | |||
int usb_bulk_read(usb_dev_handle *dev, int ep, char *bytes, int size, | int usb_bulk_read(usb_dev_handle *dev, int ep, char *bytes, int size, | |||
int timeout); | int timeout); | |||
int usb_interrupt_write(usb_dev_handle *dev, int ep, char *bytes, int size, | ||||
int timeout); | ||||
int usb_interrupt_read(usb_dev_handle *dev, int ep, char *bytes, int size, | ||||
int timeout); | ||||
int usb_control_msg(usb_dev_handle *dev, int requesttype, int request, | int usb_control_msg(usb_dev_handle *dev, int requesttype, int request, | |||
int value, int index, char *bytes, int size, int timeout); | int value, int index, char *bytes, int size, int timeout); | |||
int usb_set_configuration(usb_dev_handle *dev, int configuration); | int usb_set_configuration(usb_dev_handle *dev, int configuration); | |||
int usb_claim_interface(usb_dev_handle *dev, int interface); | int usb_claim_interface(usb_dev_handle *dev, int interface); | |||
int usb_release_interface(usb_dev_handle *dev, int interface); | int usb_release_interface(usb_dev_handle *dev, int interface); | |||
int usb_set_altinterface(usb_dev_handle *dev, int alternate); | int usb_set_altinterface(usb_dev_handle *dev, int alternate); | |||
int usb_resetep(usb_dev_handle *dev, unsigned int ep); | int usb_resetep(usb_dev_handle *dev, unsigned int ep); | |||
int usb_clear_halt(usb_dev_handle *dev, unsigned int ep); | int usb_clear_halt(usb_dev_handle *dev, unsigned int ep); | |||
int usb_reset(usb_dev_handle *dev); | int usb_reset(usb_dev_handle *dev); | |||
int usb_get_string(usb_dev_handle *dev, int index, int langid, char *buf, | ||||
size_t buflen); | #if 1 | |||
int usb_get_string_simple(usb_dev_handle *dev, int index, char *buf, | #define LIBUSB_HAS_GET_DRIVER_NP 1 | |||
size_t buflen); | int usb_get_driver_np(usb_dev_handle *dev, int interface, char *name, | |||
unsigned int namelen); | ||||
#define LIBUSB_HAS_DETACH_KERNEL_DRIVER_NP 1 | ||||
int usb_detach_kernel_driver_np(usb_dev_handle *dev, int interface); | ||||
#endif | ||||
char *usb_strerror(void); | char *usb_strerror(void); | |||
void usb_init(void); | void usb_init(void); | |||
void usb_set_debug(int level); | void usb_set_debug(int level); | |||
int usb_find_busses(void); | int usb_find_busses(void); | |||
int usb_find_devices(void); | int usb_find_devices(void); | |||
struct usb_device *usb_device(usb_dev_handle *dev); | struct usb_device *usb_device(usb_dev_handle *dev); | |||
struct usb_bus *usb_get_busses(void); | struct usb_bus *usb_get_busses(void); | |||
End of changes. 8 change blocks. | ||||
4 lines changed or deleted | 48 lines changed or added | |||