Added get descriptors length function to enable direct access to raw descriptors.
Bug: 68936964 Test: manual Peripherals - Skylab, Mir, HTC dongle, Microsoft LX-3000 (headset), Rosewill (gaming) headset Peripherals - PreSonus AudioBox 22VSL Change-Id: Icbfd64c3ac29acab6a4c731d604cb0e620e41dc6
This commit is contained in:
parent
4b7f0fdccb
commit
baea1bd815
2 changed files with 21 additions and 3 deletions
|
@ -137,8 +137,15 @@ uint16_t usb_device_get_vendor_id(struct usb_device *device);
|
|||
/* Returns the USB product ID from the device descriptor for the USB device */
|
||||
uint16_t usb_device_get_product_id(struct usb_device *device);
|
||||
|
||||
/* Returns a pointer to device descriptor */
|
||||
const struct usb_device_descriptor* usb_device_get_device_descriptor(struct usb_device *device);
|
||||
|
||||
/* Returns the length in bytes read into the raw descriptors array */
|
||||
size_t usb_device_get_descriptors_length(const struct usb_device* device);
|
||||
|
||||
/* Returns a pointer to the raw descriptors array */
|
||||
const unsigned char* usb_device_get_raw_descriptors(const struct usb_device* device);
|
||||
|
||||
/* Returns a USB descriptor string for the given string ID.
|
||||
* Used to implement usb_device_get_manufacturer_name,
|
||||
* usb_device_get_product_name and usb_device_get_serial.
|
||||
|
|
|
@ -80,9 +80,11 @@ struct usb_host_context {
|
|||
int wddbus;
|
||||
};
|
||||
|
||||
#define MAX_DESCRIPTORS_LENGTH 4096
|
||||
|
||||
struct usb_device {
|
||||
char dev_name[64];
|
||||
unsigned char desc[4096];
|
||||
unsigned char desc[MAX_DESCRIPTORS_LENGTH];
|
||||
int desc_length;
|
||||
int fd;
|
||||
int writeable;
|
||||
|
@ -381,6 +383,8 @@ struct usb_device *usb_device_new(const char *dev_name, int fd)
|
|||
return device;
|
||||
|
||||
failed:
|
||||
// TODO It would be more appropriate to have callers do this
|
||||
// since this function doesn't "own" this file descriptor.
|
||||
close(fd);
|
||||
free(device);
|
||||
return NULL;
|
||||
|
@ -449,11 +453,18 @@ uint16_t usb_device_get_product_id(struct usb_device *device)
|
|||
return __le16_to_cpu(desc->idProduct);
|
||||
}
|
||||
|
||||
const struct usb_device_descriptor* usb_device_get_device_descriptor(struct usb_device *device)
|
||||
{
|
||||
const struct usb_device_descriptor* usb_device_get_device_descriptor(struct usb_device* device) {
|
||||
return (struct usb_device_descriptor*)device->desc;
|
||||
}
|
||||
|
||||
size_t usb_device_get_descriptors_length(const struct usb_device* device) {
|
||||
return device->desc_length;
|
||||
}
|
||||
|
||||
const unsigned char* usb_device_get_raw_descriptors(const struct usb_device* device) {
|
||||
return device->desc;
|
||||
}
|
||||
|
||||
char* usb_device_get_string(struct usb_device *device, int id, int timeout)
|
||||
{
|
||||
char string[256];
|
||||
|
|
Loading…
Reference in a new issue