From: mia soweli Date: Sat, 20 May 2023 19:15:57 +0000 Subject: [PATCH] nusb/lib: add setconf() to set the configuration --- diff f27164167a90a7bc8613375a2d90f2438625518b e3cd2bf512fee93d44d1f48c9813f15f81b21938 --- 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 */