diff options
author | Daniel Drake <dsd@gentoo.org> | 2008-03-23 21:13:14 +0000 |
---|---|---|
committer | Daniel Drake <dsd@gentoo.org> | 2008-03-23 21:17:30 +0000 |
commit | 62077b7fa5b222e1bb9dea3467585aed69d596e2 (patch) | |
tree | d29815b90d4d6c95750b2a9e8a666594a57a2a94 | |
parent | 0499e9f418607b5786ac0c3e97bc46737a609ca3 (diff) | |
download | libusb-62077b7fa5b222e1bb9dea3467585aed69d596e2.tar.gz |
Support for changing altsetting
Will probably be suject to later consideration w.r.t. claiming of endpoints
-rw-r--r-- | libusb/core.c | 8 | ||||
-rw-r--r-- | libusb/libusb.h | 3 | ||||
-rw-r--r-- | libusb/libusbi.h | 3 | ||||
-rw-r--r-- | libusb/os/linux_usbfs.c | 17 |
4 files changed, 31 insertions, 0 deletions
diff --git a/libusb/core.c b/libusb/core.c index 7840b80..a4c01ba 100644 --- a/libusb/core.c +++ b/libusb/core.c @@ -508,6 +508,14 @@ API_EXPORTED int libusb_release_interface(struct libusb_device_handle *dev, return usbi_backend->release_interface(dev, iface); } +/* FIXME docs */ +API_EXPORTED int libusb_set_interface_altsetting( + struct libusb_device_handle *dev, int iface, int altsetting) +{ + usbi_dbg("interface %d altsetting %d", iface, altsetting); + return usbi_backend->set_interface_altsetting(dev, iface, altsetting); +} + /** \ingroup lib * Initialize libusb. This function must be called before calling any other * libusb function. diff --git a/libusb/libusb.h b/libusb/libusb.h index 0b29223..4aa0e13 100644 --- a/libusb/libusb.h +++ b/libusb/libusb.h @@ -597,6 +597,9 @@ int libusb_release_interface(libusb_device_handle *dev, int iface); libusb_device_handle *libusb_open_device_with_vid_pid(uint16_t vendor_id, uint16_t product_id); +int libusb_set_interface_altsetting(libusb_device_handle *dev, int iface, + int altsetting); + /* async I/O */ /** \ingroup asyncio diff --git a/libusb/libusbi.h b/libusb/libusbi.h index 0ff418b..934fd60 100644 --- a/libusb/libusbi.h +++ b/libusb/libusbi.h @@ -239,6 +239,9 @@ struct usbi_os_backend { int (*claim_interface)(struct libusb_device_handle *handle, int iface); int (*release_interface)(struct libusb_device_handle *handle, int iface); + int (*set_interface_altsetting)(struct libusb_device_handle *handle, + int iface, int altsetting); + void (*destroy_device)(struct libusb_device *dev); int (*submit_transfer)(struct usbi_transfer *itransfer); diff --git a/libusb/os/linux_usbfs.c b/libusb/os/linux_usbfs.c index a64a7e7..f173930 100644 --- a/libusb/os/linux_usbfs.c +++ b/libusb/os/linux_usbfs.c @@ -408,6 +408,21 @@ static int op_release_interface(struct libusb_device_handle *handle, int iface) return r; } +static int op_set_interface(struct libusb_device_handle *handle, int iface, + int altsetting) +{ + int fd = __device_handle_priv(handle)->fd; + struct usbfs_setinterface setintf; + int r; + + setintf.interface = iface; + setintf.altsetting = altsetting; + r = ioctl(fd, IOCTL_USBFS_SETINTF, &setintf); + if (r < 0) + usbi_err("setintf failed error %d", r); + return r; +} + static void op_destroy_device(struct libusb_device *dev) { unsigned char *nodepath = __device_priv(dev)->nodepath; @@ -572,6 +587,8 @@ const struct usbi_os_backend linux_usbfs_backend = { .claim_interface = op_claim_interface, .release_interface = op_release_interface, + .set_interface_altsetting = op_set_interface, + .destroy_device = op_destroy_device, .submit_transfer = op_submit_transfer, |