* Re: [9front] bug: nusb fails to set report protocol with a stall error
@ 2020-11-20 21:43 Romano
2020-11-20 22:19 ` Nick Owens
2020-11-21 12:48 ` cinap_lenrek
0 siblings, 2 replies; 4+ messages in thread
From: Romano @ 2020-11-20 21:43 UTC (permalink / raw)
To: 9front
[-- Attachment #1: Type: text/plain, Size: 367 bytes --]
The patch to kb.c compiled fine, but the patch for joy.c didn't compile for me:
cpu% mk
7c -I../lib -FTVw joy.c
joy.c:228 name not declared: iface
mk: 7c -I../lib -FTVw joy.c : exit status=rc 2880351: 7c 2880353: error
Just to see if it would compile I replaced "iface" with "f->dev->usb->ep[eid]->iface" and it did. Did you have iface referring to something else?
[-- Attachment #2: Type: message/rfc822, Size: 11381 bytes --]
From: Nick Owens <mischief@offblast.org>
To: 9front@9front.org
Subject: [9front] bug: nusb fails to set report protocol with a stall error
Date: Fri, 20 Nov 2020 04:58:24 -0800
Message-ID: <20201120125824.typpmodrlnro2wnc@wololo.home.arpa>
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);
}
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [9front] bug: nusb fails to set report protocol with a stall error
2020-11-20 21:43 [9front] bug: nusb fails to set report protocol with a stall error Romano
@ 2020-11-20 22:19 ` Nick Owens
2020-11-21 12:48 ` cinap_lenrek
1 sibling, 0 replies; 4+ messages in thread
From: Nick Owens @ 2020-11-20 22:19 UTC (permalink / raw)
To: 9front
On Fri, Nov 20, 2020 at 01:43:04PM -0800, Romano wrote:
> The patch to kb.c compiled fine, but the patch for joy.c didn't compile for me:
>
> cpu% mk
> 7c -I../lib -FTVw joy.c
> joy.c:228 name not declared: iface
> mk: 7c -I../lib -FTVw joy.c : exit status=rc 2880351: 7c 2880353: error
>
> Just to see if it would compile I replaced "iface" with "f->dev->usb->ep[eid]->iface" and it did. Did you have iface referring to something else?
m( thats what i get for hasty copypasta. you are correct. update patch
below, uses Subclass macro to access subclass.
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(Subclass(f->dev->usb->ep[eid]->iface->csp) == 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(Subclass(iface->csp) == 0)
+ return 0;
+
return usbcmd(f->dev, Rh2d|Rclass|Riface, Setproto, proto, iface->id, nil, 0);
}
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [9front] bug: nusb fails to set report protocol with a stall error
2020-11-20 21:43 [9front] bug: nusb fails to set report protocol with a stall error Romano
2020-11-20 22:19 ` Nick Owens
@ 2020-11-21 12:48 ` cinap_lenrek
1 sibling, 0 replies; 4+ messages in thread
From: cinap_lenrek @ 2020-11-21 12:48 UTC (permalink / raw)
To: 9front
thats a very good catch!
maybe the test should be subclass != 1 instead? subclass code 1
means the device implements the boot protocol, and therfor supports
the SET_PROTOCOL request. the other values are reserved.
--
cinap
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [9front] bug: nusb fails to set report protocol with a stall error
2020-11-20 12:58 Nick Owens
@ 2020-11-20 20:57 ` Romano
0 siblings, 0 replies; 4+ messages in thread
From: Romano @ 2020-11-20 20:57 UTC (permalink / raw)
To: 9front
I had noticed this consistently on my rpi4, but hadn't had time to look at it. It generally occurs when I plug in my Logitech MX Ergo mouse.
On November 20, 2020 12:58:24 PM UTC, Nick Owens <mischief@offblast.org> wrote:
>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);
> }
>
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2020-11-21 12:48 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-11-20 21:43 [9front] bug: nusb fails to set report protocol with a stall error Romano
2020-11-20 22:19 ` Nick Owens
2020-11-21 12:48 ` cinap_lenrek
-- strict thread matches above, loose matches on Subject: below --
2020-11-20 12:58 Nick Owens
2020-11-20 20:57 ` [9front] " Romano
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).