From: Nick Owens <mischief@offblast.org>
To: 9front@9front.org
Subject: bug: nusb fails to set report protocol with a stall error
Date: Fri, 20 Nov 2020 04:58:24 -0800 [thread overview]
Message-ID: <20201120125824.typpmodrlnro2wnc@wololo.home.arpa> (raw)
on my desktop with usb3, i see 'setproto: Stall Error' with certain
devices.
when using nusb/kb with my tex shinobi, i see a stall error, but only
for the builtin trackpoint.
when using nusb/joy i see a stall error with my ps4 controller.
with a short test, i just removed the command to set the interface
protocol, and now both devices work.
after looking at the HID 1.11 spec, it seems like if a HID interface
descriptor has an interface subclass of 0, support for set protocol is
optional.
here is a patch which avoids setproto for devices which might not
support it, and it works for both my tex shinobi and ps4 controller.
thoughts?
diff --git a/sys/src/cmd/nusb/joy/joy.c b/sys/src/cmd/nusb/joy/joy.c
--- a/sys/src/cmd/nusb/joy/joy.c
+++ b/sys/src/cmd/nusb/joy/joy.c
@@ -222,6 +222,12 @@ setproto(KDev *f, int eid)
proto = Reportproto;
}else
kbfatal(f, "no report");
+
+ // if a HID's subclass code is 0, it may not support setproto,
+ // and is always initialized in report mode.
+ if(((iface->csp>>8)&0xFF) == 0)
+ return 0;
+
return usbcmd(f->dev, Rh2d|Rclass|Riface, Setproto, proto, id, nil, 0);
}
diff --git a/sys/src/cmd/nusb/kb/kb.c b/sys/src/cmd/nusb/kb/kb.c
--- a/sys/src/cmd/nusb/kb/kb.c
+++ b/sys/src/cmd/nusb/kb/kb.c
@@ -368,6 +368,12 @@ setproto(Hiddev *f, int eid)
}
proto = Bootproto;
}
+
+ // if a HID's subclass code is 0, it may not support setproto,
+ // and is always initialized in report mode.
+ if(((iface->csp>>8)&0xFF) == 0)
+ return 0;
+
return usbcmd(f->dev, Rh2d|Rclass|Riface, Setproto, proto, iface->id, nil, 0);
}
next reply other threads:[~2020-11-20 12:58 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-11-20 12:58 Nick Owens [this message]
2020-11-20 20:57 ` [9front] " Romano
2020-11-21 20:57 ` Nick Owens
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20201120125824.typpmodrlnro2wnc@wololo.home.arpa \
--to=mischief@offblast.org \
--cc=9front@9front.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).