git: 9front

Download patch

ref: 00f7f2ceb6a1818e2975baf6f5c55c1d2d4ecb6e
parent: 84eb862aeccd05115d4f0d68f2327097358427dc
author: cinap_lenrek <cinap_lenrek@felloff.net>
date: Wed Feb 23 13:00:34 EST 2022

nusb/lib: provide a setalt() function to set the interface to its altsetting

--- a/sys/src/cmd/nusb/lib/dev.c
+++ b/sys/src/cmd/nusb/lib/dev.c
@@ -482,6 +482,16 @@
 	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.
  */
--- a/sys/src/cmd/nusb/lib/usb.h
+++ b/sys/src/cmd/nusb/lib/usb.h
@@ -353,5 +353,6 @@
 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 */
--