From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-pl1-f172.google.com ([209.85.214.172]) by ewsd; Fri Nov 20 07:58:35 -0500 2020 Received: by mail-pl1-f172.google.com with SMTP id b3so4803882pls.11 for <9front@9front.org>; Fri, 20 Nov 2020 04:58:28 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=offblast-org.20150623.gappssmtp.com; s=20150623; h=date:from:to:subject:message-id:mime-version:content-disposition :user-agent; bh=8r/8u57r778sVmAuu9tiWJ2Orim73fUnATf95NoYvu0=; b=GCxDWJvvvDJbQWTyeWGxOAsDS8NYysAQVhZIltliq8JePnG0NPbgtJSJfK1QGMZ4Cm PmWrvjFgbVDzp6D937b0G9P5gmwKBdtEZDaPrnGynZr9Bm45AwXpfRJZruYO7QU+TtQ2 ZYv2D9/WfasHQRjmypqWoTB6AQ1Ugr6d7hbns40aGL35GWgzgoZyQR+uA2l7Ff6xDJHo 20ikWY6vb0SzPwpsYPX6QGGeNX3D1VFiG56xaVP9KEvjGiviEb9qxsB7U04QRQbQPf1x 29X0v5sbHxfHFjoAZitrn9iOSvTotgGT1etdr9tVLyTG89OvpuB2YA947XqSGU3j3Cvz 34Yw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:subject:message-id:mime-version :content-disposition:user-agent; bh=8r/8u57r778sVmAuu9tiWJ2Orim73fUnATf95NoYvu0=; b=s3sHitHNzk8qpOVYRvYcv3J8OkEdXaQEHGyzQWcuIA3ApFapRXLK4/xcelUxVZoaWP GObxfz2yccLoNI8rzjsXJ5gBmRfOo6l1lvcAHJzEbru2/V/++zLJcoFoWzgzNp1v5KMZ zS5Hz+S+vCBPbzC/P+cjpIbeUi2NE44R9Cqw6ruaG7tAgQAoKtKLez8tEifAUi8K9QLv D01GoC6/OixWO4giH9Jp74d5Tjgliz7JTrOwcVnShedLN3kx28nbEqDnjnTGgIHr0EZ7 DuEsF7GtZN3rQu1m+5u3Q6T421UqAyp7DuTcSr82FkvYXWaTluqZwvnU1JKOrKCmRJzd xCaA== X-Gm-Message-State: AOAM533pXW1mvUDfJ8TEUlIi4ujpqyTIxIaw7KYMjH0Ro8fuvhONK2XT 0zj9SGstmTe/xVu8gTd62odPlO7k5zgcJm5P X-Google-Smtp-Source: ABdhPJxr9ieE4FQEYzFlcwRu7sQ1fz5jfqNvZjSC3aqxogDdPJ0X0pga8uy1kbwHhdhKeJpkRkLdNQ== X-Received: by 2002:a17:902:8a90:b029:d8:e34d:2700 with SMTP id p16-20020a1709028a90b02900d8e34d2700mr13552031plo.3.1605877107914; Fri, 20 Nov 2020 04:58:27 -0800 (PST) Return-Path: Received: from wololo.home.arpa ([2601:646:100:8cb:2c6d:f3ff:fe32:a632]) by smtp.gmail.com with ESMTPSA id y19sm3803214pfp.160.2020.11.20.04.58.26 for <9front@9front.org> (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 20 Nov 2020 04:58:27 -0800 (PST) Date: Fri, 20 Nov 2020 04:58:24 -0800 From: Nick Owens To: 9front@9front.org Subject: bug: nusb fails to set report protocol with a stall error Message-ID: <20201120125824.typpmodrlnro2wnc@wololo.home.arpa> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: NeoMutt/20180716 List-ID: <9front.9front.org> List-Help: X-Glyph: ➈ X-Bullshit: ISO-certified callback-based XMPP over ActivityPub high-performance extension 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); }