ref: ce72cab0e49c08c71888c57cf616563b90d7497a
parent: daed100cfb370092e7da4fb5eb99729d045dd88c
author: mia soweli <[email protected]>
date: Sat May 20 15:15:57 EDT 2023
nusb/lib: add setconf() to set the configuration
--- a/sys/src/cmd/nusb/lib/dev.c
+++ b/sys/src/cmd/nusb/lib/dev.c
@@ -483,6 +483,16 @@
}
int
+setconf(Dev *d, Conf *c)
+{
+ if(usbcmd(d, Rh2d|Rstd|Rdev, Rsetconf, c->cval, 0, nil, 0) > 0) {
+ werrstr("setconf: %s: %r", d->dir);
+ return -1;
+ }
+ return 0;
+}
+
+int
setalt(Dev *d, Iface *ifc)
{
if(usbcmd(d, Rh2d|Rstd|Riface, Rsetiface, ifc->alt, ifc->id, nil, 0) < 0){
--- a/sys/src/cmd/nusb/lib/usb.h
+++ b/sys/src/cmd/nusb/lib/usb.h
@@ -353,6 +353,7 @@
int unstall(Dev *dev, Dev *ep, int dir);
int usbcmd(Dev *d, int type, int req, int value, int index, uchar *data, int count);
Dev* getdev(char *devid);
+int setconf(Dev *d, Conf *c);
int setalt(Dev *d, Iface *ifc);
extern int usbdebug; /* more messages for bigger values */