summaryrefslogtreecommitdiff
path: root/sys/src/cmd/nusb
diff options
context:
space:
mode:
authorcinap_lenrek <cinap_lenrek@felloff.net>2022-02-23 18:00:34 +0000
committercinap_lenrek <cinap_lenrek@felloff.net>2022-02-23 18:00:34 +0000
commitbea20cd152066c1deee6f1acbf68cf1fcc569927 (patch)
tree99b07c05405f7cb8860fbb50a767e0fef805ea05 /sys/src/cmd/nusb
parent9cd55a085de274abb937a2d586b3d0a4e4d0e1b1 (diff)
nusb/lib: provide a setalt() function to set the interface to its altsetting
Diffstat (limited to 'sys/src/cmd/nusb')
-rw-r--r--sys/src/cmd/nusb/lib/dev.c10
-rw-r--r--sys/src/cmd/nusb/lib/usb.h1
2 files changed, 11 insertions, 0 deletions
diff --git a/sys/src/cmd/nusb/lib/dev.c b/sys/src/cmd/nusb/lib/dev.c
index f692b33fa..ccd75bfdb 100644
--- a/sys/src/cmd/nusb/lib/dev.c
+++ b/sys/src/cmd/nusb/lib/dev.c
@@ -482,6 +482,16 @@ unstall(Dev *dev, Dev *ep, int dir)
return 0;
}
+int
+setalt(Dev *d, Iface *ifc)
+{
+ if(usbcmd(d, Rh2d|Rstd|Riface, Rsetiface, ifc->alt, ifc->id, nil, 0) < 0){
+ werrstr("setalt: %s: %r", d->dir);
+ return -1;
+ }
+ return 0;
+}
+
/*
* To be sure it uses a single write.
*/
diff --git a/sys/src/cmd/nusb/lib/usb.h b/sys/src/cmd/nusb/lib/usb.h
index 3ed953d5b..c34df7082 100644
--- a/sys/src/cmd/nusb/lib/usb.h
+++ b/sys/src/cmd/nusb/lib/usb.h
@@ -353,5 +353,6 @@ int parsedev(Dev *xd, uchar *b, int n);
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 setalt(Dev *d, Iface *ifc);
extern int usbdebug; /* more messages for bigger values */