From owner-freebsd-usb@FreeBSD.ORG Fri Jun 1 16:29:21 2012 Return-Path: Delivered-To: freebsd-usb@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 0F4171065670; Fri, 1 Jun 2012 16:29:21 +0000 (UTC) (envelope-from hselasky@c2i.net) Received: from swip.net (mailfe08.c2i.net [212.247.154.226]) by mx1.freebsd.org (Postfix) with ESMTP id 424198FC1D; Fri, 1 Jun 2012 16:29:20 +0000 (UTC) X-T2-Spam-Status: No, hits=-0.2 required=5.0 tests=ALL_TRUSTED, BAYES_50 Received: from [176.74.212.201] (account mc467741@c2i.net HELO laptop015.hselasky.homeunix.org) by mailfe08.swip.net (CommuniGate Pro SMTP 5.4.4) with ESMTPA id 282073769; Fri, 01 Jun 2012 18:24:11 +0200 From: Hans Petter Selasky To: "Engineering" , Alexander Motin Date: Fri, 1 Jun 2012 18:23:30 +0200 User-Agent: KMail/1.13.7 (FreeBSD/9.0-STABLE; KDE/4.7.4; amd64; ; ) References: <201205280640.q4S6e6L0035127@freefall.freebsd.org> <201206011730.31081.hselasky@c2i.net> <027901cd4011$53ec4ff0$fbc4efd0$@com> In-Reply-To: <027901cd4011$53ec4ff0$fbc4efd0$@com> X-Face: 'mmZ:T{)),Oru^0c+/}w'`gU1$ubmG?lp!=R4Wy\ELYo2)@'UZ24N@d2+AyewRX}mAm; Yp |U[@, _z/([?1bCfM{_"B<.J>mICJCHAzzGHI{y7{%JVz%R~yJHIji`y>Y}k1C4TfysrsUI -%GU9V5]iUZF&nRn9mJ'?&>O MIME-Version: 1.0 Content-Type: Text/Plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit Message-Id: <201206011823.30527.hselasky@c2i.net> Cc: freebsd-usb@freebsd.org Subject: Re: Recommendations for programming HID in FreeBSD 9 X-BeenThere: freebsd-usb@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: FreeBSD support for USB List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 01 Jun 2012 16:29:21 -0000 On Friday 01 June 2012 18:12:20 Engineering wrote: > From: Hans Petter Selasky [mailto:hselasky@c2i.net] > > >> uhid is not going to get obsoleted, though using libraries from > > user-space is sometimes more convenient. > > Thanks HPS (and Xiaofan) > > I definitely agree with that, but I've got legacy code... > > Last question - I've updated my code to convert the old 'usb_ctl_report' > and such to the new generic descriptors at runtime, and I've got two HIDs > up and running. > > As I read uhid.c, it seems to assume only one feature report ID and size. I > have devices that have multiple feature report sizes. And one device which > I'm pretty sure has bad device descriptors, so the size is wrong. > > In the BSD7, I added the following fakery to uhid.c: > > case USB_SET_REPORTZ: // report id and size are in first two bytes > re = (struct usb_ctl_report *)addr; > id = re->ucr_data[0]; > size = re->ucr_data[1]; > err = usbd_set_report(sc->sc_iface, re->ucr_report, id, > &re->ucr_data[2],size); > if (err) > { > return (EIO); > } > break; > > Do you think it would make sense to do this again with the BSD9 uhid.c? I think mav @ did some work in that area? Are you sure you cannot use: case USB_SET_REPORT: if (!(fflags & FWRITE)) { error = EPERM; break; } ugd = addr; switch (ugd->ugd_report_type) { case UHID_INPUT_REPORT: size = sc->sc_isize; id = sc->sc_iid; break; case UHID_OUTPUT_REPORT: size = sc->sc_osize; id = sc->sc_oid; break; case UHID_FEATURE_REPORT: size = sc->sc_fsize; id = sc->sc_fid; break; default: return (EINVAL); } if (id != 0) copyin(ugd->ugd_data, &id, 1); error = uhid_set_report(sc, ugd->ugd_report_type, id, NULL, ugd->ugd_data, imin(ugd->ugd_maxlen, size)); break; --HPS