X-Git-Url: http://cvs.zerfleddert.de/cgi-bin/gitweb.cgi/usb-driver/blobdiff_plain/6c235d59caa48963278183c19762c80dbabdec2e..0c2db148a4e604ceeab5eda38efcf64d1ef25c76:/xpcu.c diff --git a/xpcu.c b/xpcu.c index 28770fe..de23d9e 100644 --- a/xpcu.c +++ b/xpcu.c @@ -166,7 +166,7 @@ int xpcu_deviceinfo(struct xpcu_s *xpcu, unsigned char *buf) { return len; } -int xpcu_claim(struct xpcu_s *xpcu, int claim) { +static int xpcu_claim(struct xpcu_s *xpcu, int claim) { int ret = 0; static int claimed = 0; @@ -232,6 +232,23 @@ int xpcu_transfer(struct xpcu_s *xpcu, struct usb_transfer *ut) { return ret; } +void xpcu_set_interface(struct xpcu_s *xpcu, struct usb_set_interface *usi) { + if (xpcu->dev) { + if (!xpcu->handle) { + xpcu->handle = usb_open(xpcu->dev); +#ifndef NO_USB_RESET + if (xpcu->handle) { + usb_reset(xpcu->handle); + xpcu->handle = usb_open(xpcu->dev); + } +#endif + } + + xpcu->interface = xpcu->dev->config[0].interface[usi->dwInterfaceNum].altsetting[usi->dwAlternateSetting].bInterfaceNumber; + xpcu->alternate = usi->dwAlternateSetting; + } +} + struct xpcu_s *xpcu_open(void) { static struct xpcu_s xpcu; @@ -247,3 +264,14 @@ struct xpcu_s *xpcu_open(void) { return &xpcu; } + +void xpcu_close(struct xpcu_s *xpcu) { + if (xpcu->handle) { + xpcu_claim(xpcu, XPCU_RELEASE); + usb_close(xpcu->handle); + } + + xpcu->handle = NULL; + xpcu->interface = -1; + xpcu->alternate = -1; +}