Bug 137189 - [usb8][patch] create and use sysctl nodes for HID report descriptors
Summary: [usb8][patch] create and use sysctl nodes for HID report descriptors
Status: Open
Alias: None
Product: Base System
Classification: Unclassified
Component: usb (show other bugs)
Version: 8.0-BETA2
Hardware: Any Any
: Normal Affects Only Me
Assignee: freebsd-usb mailing list
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2009-07-27 20:50 UTC by Eygene Ryabinkin
Modified: 2018-01-03 05:16 UTC (History)
0 users

See Also:


Attachments
0004-libusbhid-use-new-sysctl-node-hiddesc-to-get-HID-des.patch (12.22 KB, patch)
2009-07-27 20:50 UTC, Eygene Ryabinkin
no flags Details | Diff
0001-USB-implement-new-sysctl-node-hiddesc-for-HID-device.patch (17.70 KB, patch)
2009-07-30 21:38 UTC, Eygene Ryabinkin
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Eygene Ryabinkin 2009-07-27 20:50:03 UTC
usbhidctl in 8.x can dump report descriptors only from the uhid(4)
devices.  When, for example, ums(4) or ukbd(4) grab HID devices,
there is no way to dump and decode their descriptors via usbhidctl.

Fix: The following patch makes kernel-side changes: it introduces general
framework to create opaque sysctl nodes 'dev.<name>.<unit>.hiddesc'
that are exporting HID descriptor to the userspace.
This patch handles user-level stuff: libusbhid is extended with the new
function that obtains HID report descriptor from all available places
(currently, from the sysctl and iocal calls).  usbhidctl is modified to
use this new API function.


--- 0004-libusbhid-use-new-sysctl-node-hiddesc-to-get-HID-des.patch ends here -----sXe2kdbsOPakaKberu9J6wKPP4zAKR3Sk4Xhw0cXEBuIbhRY
Content-Type: text/plain; name="0003-UHID-implement-new-sysctl-node-hiddesc.patch"
Content-Transfer-Encoding: 7bit
Content-Disposition: attachment; filename="0003-UHID-implement-new-sysctl-node-hiddesc.patch"

begin 644 0003-UHID-implement-new-sysctl-node-hiddesc.patch
M1G)O;2`S-3,R931F-3EC,#<P8C%A-C(V-#%C,S8X.6(R.&8U.3%E,C9C,3@U
M($UO;B!397`@,3<@,#`Z,#`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?55-"7TA)
51%](7R`J+PHM+2`*,2XV+C,N,0H*
`
end
How-To-Repeat: 
Run 'usbhidctl -f /dev/ums0 -d' and see how it will fail.
Comment 1 Eygene Ryabinkin 2009-07-27 21:01:28 UTC
I forgot to add another patch that enabled usbhidctl to parse
all report IDs and not just report ID zero.
--- 0005-usbhidctl-dump-report-descriptor-for-all-IDs.patch begins here ---
begin 600 0005-usbhidctl-dump-report-descriptor-for-all-IDs.patch
M1G)O;2!E9C`U-&,Y-65B8C1B-&0W86%F8S<W.&9C,V9C-68R,V0X-&9F,3`X
M($UO;B!397`@,3<@,#`Z,#`Z,#`@,C`P,0I&<F]M.B!%>6=E;F4@4GEA8FEN
M:VEN(#QR96$M9F)S9$!C;V1E;&%B<RYR=3X*1&%T93H@36]N+"`R-R!*=6P@
M,C`P.2`Q-#HU,CHS-"`K,#0P,`I3=6)J96-T.B!;4$%40T@@-2\W72!U<V)H
M:61C=&PZ(&1U;7`@<F5P;W)T(&1E<V-R:7!T;W(@9F]R(&%L;"!)1',*"E!R
M979I;W5S;'D@9&%T82!W87,@9'5M<&5D(&]N;'D@9F]R('1H92!R97!O<G0@
M240@/2`P+"!B96-A=7-E('1H90IV87)I86)L92`G<F5P;W)T:60G(&ES('-T
M871I8RX@(%1H870G<R!N;W0@9V]O9"`M+2!N;W0@979E<GD@9&5V:6-E(&AA
M<PIR97!O<G0@240@,"!A;F0@9V5N97)A;&QY('=E('=A;G0@=&\@<V5E('1H
M92!W:&]L92!R97!O<G0@9&5S8W)I<'1O<BX*"E-I>F5S(&%R92!A;'-O(&-A
M;&-U;&%T960@9F]R(&%L;"!R97!O<G0@241S("AT:&5Y(&%R92!S=6UM960@
M=7`I+@H*4VEG;F5D+6]F9BUB>3H@17EG96YE(%)Y86)I;FMI;B`\<F5A+69B
M<V1`8V]D96QA8G,N<G4^"BTM+0H@=7-R+F)I;B]U<V)H:61C=&PO=7-B:&ED
M+F,@?"`@("`Y("LK*RLK+2TM+0H@,2!F:6QE<R!C:&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(BP@<VEZ92D["B`*+0ES:7IE(#T@:&ED7W)E<&]R=%]S
M:7IE*'(L(&AI9%]F96%T=7)E+"`P*3L**PES:7IE(#T@:&ED7W)E<&]R=%]S
M:7IE*'(L(&AI9%]F96%T=7)E+"!R97!O<G1I9"D["B`)<')I;G1F*")4;W1A
M;"!F96%T=7)E('-I>F4@)60@8GET97-<;B(L('-I>F4I.PH@?0H@"BTM(`HQ
(+C8N,RXQ"@H`
`
end
--- 0005-usbhidctl-dump-report-descriptor-for-all-IDs.patch ends here ---
-- 
Eygene
 _                ___       _.--.   #
 \`.|\..----...-'`   `-._.-'_.-'`   #  Remember that it is hard
 /  ' `         ,       __.--'      #  to read the on-line manual
 )/' _/     \   `-_,   /            #  while single-stepping the kernel.
 `-'" `"\_  ,_.-;_.-\_ ',  fsc/as   #
     _.-'_./   {_.'   ; /           #    -- FreeBSD Developers handbook
    {_.-``-'         {_/            #
Comment 2 Hans Petter Selasky freebsd_committer 2009-07-27 21:41:38 UTC
On Monday 27 July 2009 21:44:59 Eygene Ryabinkin wrote:
> >Number:         137189
> >Category:       usb
> >Synopsis:       [usb][patch] create and use sysctl nodes for HID report
> > descriptors Confidential:   no
> >Severity:       non-critical
> >Priority:       medium
> >Responsible:    freebsd-usb
> >State:          open
> >Quarter:
> >Keywords:
> >Date-Required:
> >Class:          sw-bug
> >Submitter-Id:   current-users
> >Arrival-Date:   Mon Jul 27 19:50:03 UTC 2009
> >Closed-Date:
> >Last-Modified:
> >Originator:     Eygene Ryabinkin
> >Release:        FreeBSD 8.0-BETA2 amd64
> >Organization:
>
> Code Labs
>
> >Environment:
>
> System: FreeBSD 8.0-BETA2 amd64
>
> >Description:
>
> usbhidctl in 8.x can dump report descriptors only from the uhid(4)
> devices.  When, for example, ums(4) or ukbd(4) grab HID devices,
> there is no way to dump and decode their descriptors via usbhidctl.
>
> >How-To-Repeat:
>
> Run 'usbhidctl -f /dev/ums0 -d' and see how it will fail.
>

Hi,

Can you change your patch, so that usbhidctl uses libusb to get the HID 
descriptor, instead of sysctl?

1) Locate all HID descriptors on a per interface basis:

struct usb_hid_descriptor *
hid_get_descriptor_from_usb(struct usb_config_descriptor *cd,
    struct usb_interface_descriptor *id)
{
        struct usb_descriptor *desc = (void *)id;

        if (desc == NULL) {
                return (NULL);
        }
        while ((desc = usb_desc_foreach(cd, desc))) {
                if ((desc->bDescriptorType == UDESC_HID) &&
                    (desc->bLength >= USB_HID_DESCRIPTOR_SIZE(0))) {
                        return (void *)desc;
                }
                if (desc->bDescriptorType == UDESC_INTERFACE) {
                        break;
                }
        }
        return (NULL);
}

2) Retrieve HID descriptor using control request:
usb_error_t
usbd_req_get_hid_desc(struct usb_device *udev, struct mtx *mtx,
    void **descp, uint16_t *sizep,
    struct malloc_type *mem, uint8_t iface_index)
{
        struct usb_interface *iface = usbd_get_iface(udev, iface_index);
        struct usb_hid_descriptor *hid;
        usb_error_t err;

        if ((iface == NULL) || (iface->idesc == NULL)) {
                return (USB_ERR_INVAL);
        }
        hid = hid_get_descriptor_from_usb
            (usbd_get_config_descriptor(udev), iface->idesc);

        if (hid == NULL) {
                return (USB_ERR_IOERROR);
        }
        *sizep = UGETW(hid->descrs[0].wDescriptorLength);
        if (*sizep == 0) {
                return (USB_ERR_IOERROR);
        }
        if (mtx)
                mtx_unlock(mtx);

        *descp = malloc(*sizep, mem, M_ZERO | M_WAITOK);

        if (mtx)
                mtx_lock(mtx);

        if (*descp == NULL) {
                return (USB_ERR_NOMEM);
        }
        err = usbd_req_get_report_descriptor
            (udev, mtx, *descp, *sizep, iface_index);

        if (err) {
                free(*descp, mem);
                *descp = NULL;
                return (err);
        }
        return (USB_ERR_NORMAL_COMPLETION);
}

See kernel code in sys/dev/usb/ for reference and man libusb.

--HPS



--HPS
Comment 3 Eygene Ryabinkin 2009-07-28 12:51:43 UTC
Hans Petter, good day.

HPS wrote:
> Can you change your patch, so that usbhidctl uses libusb to get the
> HID descriptor, instead of sysctl?

I can, but how to relate the device name under devfs to the descriptor
to be retrieved?  I can enumerate all HID descriptors via libusb, but I
can't currently say which device uses them.  And I don't want to torture
users with the crawl over the list of all vendor/device pairs for the
discovered HID descriptors and ask to choose one -- that's not
productive.

Why do you dislike the sysctl approach?  It is simple and reliable.
-- 
Eygene
 _                ___       _.--.   #
 \`.|\..----...-'`   `-._.-'_.-'`   #  Remember that it is hard
 /  ' `         ,       __.--'      #  to read the on-line manual
 )/' _/     \   `-_,   /            #  while single-stepping the kernel.
 `-'" `"\_  ,_.-;_.-\_ ',  fsc/as   #
     _.-'_./   {_.'   ; /           #    -- FreeBSD Developers handbook
    {_.-``-'         {_/            #
Comment 4 Hans Petter Selasky 2009-07-28 13:13:25 UTC
On Tuesday 28 July 2009 13:51:43 Eygene Ryabinkin wrote:
> Hans Petter, good day.
>
> HPS wrote:
> > Can you change your patch, so that usbhidctl uses libusb to get the
> > HID descriptor, instead of sysctl?
>
> I can, but how to relate the device name under devfs to the descriptor
> to be retrieved?

By unit number and device address, like usbconfig.

> I can enumerate all HID descriptors via libusb, but I
> can't currently say which device uses them. 

Try:

usbconfig show_ifdrv

> And I don't want to torture
> users with the crawl over the list of all vendor/device pairs for the
> discovered HID descriptors and ask to choose one -- that's not
> productive.

>
> Why do you dislike the sysctl approach?  It is simple and reliable.

It's duplicating access to data. There is not that much wrong about it, except 
it will not work if the device is of another kind. I.E. you would have to 
patch the HID sysctl node into every driver accessing HID descriptors?

--HPS
Comment 5 Eygene Ryabinkin 2009-07-28 16:40:27 UTC
HPS wrote:
> > I can, but how to relate the device name under devfs to the descriptor
> > to be retrieved?
>
> By unit number and device address, like usbconfig.

Yes, but these numbers are the ugen ones; on my system, for example,
ums0 maps to ugen5.3.0.

>>  I can enumerate all HID descriptors via libusb, but I
> > can't currently say which device uses them.
>
> Try:
>
> usbconfig show_ifdrv

Yes, that's better.  But can I rely that the first item in the output of
the libusb20_dev_get_iface_desc() will be the device name?  And still,
to get the report descriptor from one device, I should walk the entire
USB tree until I'll find the device I am interested in.  May be there
are some other ways?  I understand that enumeration is the principle of
the USB bus, but may be there are another ways to directly grab 'struct
libusb20_device *' or alike for the devfs node I am interested in?

> > Why do you dislike the sysctl approach? It is simple and reliable.
>
> It's duplicating access to data. There is not that much wrong about
> it, except it will not work if the device is of another kind. I.E. you
> would have to patch the HID sysctl node into every driver accessing
> HID descriptors?

Just now -- yes, I'll need it.  But probably I can move this
functionality into the USB bus level -- it will automatically create
this sysctl node for all HID children and will dispose it on the detach.
usb_probe_and_attach() is a candidate for such functionality.  Will it
be bad?
-- 
Eygene
 _                ___       _.--.   #
 \`.|\..----...-'`   `-._.-'_.-'`   #  Remember that it is hard
 /  ' `         ,       __.--'      #  to read the on-line manual
 )/' _/     \   `-_,   /            #  while single-stepping the kernel.
 `-'" `"\_  ,_.-;_.-\_ ',  fsc/as   #
     _.-'_./   {_.'   ; /           #    -- FreeBSD Developers handbook
    {_.-``-'         {_/            #
Comment 6 Eygene Ryabinkin 2009-07-30 21:38:12 UTC
Hans Petter, good day.

Tue, Jul 28, 2009 at 07:40:27PM +0400, Eygene Ryabinkin wrote:
> HPS wrote:
> > > Why do you dislike the sysctl approach? It is simple and reliable.
> >
> > It's duplicating access to data. There is not that much wrong about
> > it, except it will not work if the device is of another kind. I.E. you
> > would have to patch the HID sysctl node into every driver accessing
> > HID descriptors?
> 
> Just now -- yes, I'll need it.  But probably I can move this
> functionality into the USB bus level -- it will automatically create
> this sysctl node for all HID children and will dispose it on the detach.
> usb_probe_and_attach() is a candidate for such functionality.  Will it
> be bad?

OK, attached is the reworked version of the sysctl patch: it now creates
the needed nodes automatically (though they still can be created by
explicit call from the driver, as in uhid(4)).  As a bonus, kernel got the
ability to install per-USB class post-attach and pre-detach handlers, so
we can do some class-specific things for every driver.  What do you think
of it?

Thanks!
-- 
Eygene
 _                ___       _.--.   #
 \`.|\..----...-'`   `-._.-'_.-'`   #  Remember that it is hard
 /  ' `         ,       __.--'      #  to read the on-line manual
 )/' _/     \   `-_,   /            #  while single-stepping the kernel.
 `-'" `"\_  ,_.-;_.-\_ ',  fsc/as   #
     _.-'_./   {_.'   ; /           #    -- FreeBSD Developers handbook
    {_.-``-'         {_/            #
Comment 7 Hans Petter Selasky 2009-07-31 08:19:03 UTC
On Thursday 30 July 2009 22:38:12 Eygene Ryabinkin wrote:
> Hans Petter, good day.
>
> Tue, Jul 28, 2009 at 07:40:27PM +0400, Eygene Ryabinkin wrote:
> > HPS wrote:
> > > > Why do you dislike the sysctl approach? It is simple and reliable.
> > >
> > > It's duplicating access to data. There is not that much wrong about
> > > it, except it will not work if the device is of another kind. I.E. you
> > > would have to patch the HID sysctl node into every driver accessing
> > > HID descriptors?
> >
> > Just now -- yes, I'll need it.  But probably I can move this
> > functionality into the USB bus level -- it will automatically create
> > this sysctl node for all HID children and will dispose it on the detach.
> > usb_probe_and_attach() is a candidate for such functionality.  Will it
> > be bad?
>
> OK, attached is the reworked version of the sysctl patch: it now creates
> the needed nodes automatically (though they still can be created by
> explicit call from the driver, as in uhid(4)).  As a bonus, kernel got the
> ability to install per-USB class post-attach and pre-detach handlers, so
> we can do some class-specific things for every driver.  What do you think
> of it?

Hi,

I think it's too much code to doo too little, and adds extra complexity, and 
that doing this via libusb would be much more generic.

--HPS
Comment 8 Eitan Adler freebsd_committer freebsd_triage 2017-12-31 08:00:58 UTC
For bugs matching the following criteria:

Status: In Progress Changed: (is less than) 2014-06-01

Reset to default assignee and clear in-progress tags.

Mail being skipped