From: Daniel Drake Date: Sun, 23 Mar 2008 21:13:14 +0000 (+0000) Subject: Support for changing altsetting X-Git-Tag: upstream/1.0.21~1111 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=62077b7fa5b222e1bb9dea3467585aed69d596e2;p=platform%2Fupstream%2Flibusb.git Support for changing altsetting Will probably be suject to later consideration w.r.t. claiming of endpoints --- 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,