Re: usb/137189: [usb][patch] create and use sysctl nodes for HID report descriptors

2009-07-31 Thread Hans Petter Selasky
The following reply was made to PR usb/137189; it has been noted by GNATS.

From: Hans Petter Selasky 
To: rea-f...@codelabs.ru
Cc: bug-follo...@freebsd.org,
 freebsd-usb@freebsd.org
Subject: Re: usb/137189: [usb][patch] create and use sysctl nodes for HID 
report descriptors
Date: Fri, 31 Jul 2009 09:19:03 +0200

 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
___
freebsd-usb@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-usb
To unsubscribe, send any mail to "freebsd-usb-unsubscr...@freebsd.org"


Re: usb/137189: [usb][patch] create and use sysctl nodes for HID report descriptors

2009-07-31 Thread Hans Petter Selasky
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
___
freebsd-usb@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-usb
To unsubscribe, send any mail to "freebsd-usb-unsubscr...@freebsd.org"


Re: usb/137189: [usb][patch] create and use sysctl nodes for HID report descriptors

2009-07-30 Thread Eygene Ryabinkin
The following reply was made to PR usb/137189; it has been noted by GNATS.

From: Eygene Ryabinkin 
To: bug-follo...@freebsd.org, freebsd-usb@FreeBSD.org
Cc: hsela...@c2i.net
Subject: Re: usb/137189: [usb][patch] create and use sysctl nodes for HID
 report descriptors
Date: Fri, 31 Jul 2009 00:38:12 +0400

 --tThc/1wpZn/ma/RB
 Content-Type: text/plain; charset=us-ascii
 Content-Disposition: inline
 
 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
 {_.-``-' {_/#
 
 --tThc/1wpZn/ma/RB
 Content-Type: text/x-diff; charset=us-ascii
 Content-Disposition: attachment; 
filename="0001-USB-implement-new-sysctl-node-hiddesc-for-HID-device.patch"
 Content-Transfer-Encoding: quoted-printable
 
 =46rom 4f8fd6e07cc388e96ab567ef29c6d592231ffb8a Mon Sep 17 00:00:00 2001
 =46rom: Eygene Ryabinkin 
 Date: Mon, 27 Jul 2009 08:36:07 +0400
 Subject: [PATCH 1/3] USB: implement new sysctl node, "hiddesc" for HID devi=
 ces
 
 =2E..and also implement per-class attach/detach hooks -- now USB classes
 can register theis handlers that will be called just after attachment
 of device from their class and just before detachment of such device.
 This functionality provides the foundation to implement the needed
 sysctl in a generic manner where all HID-type devices will automatically
 gain this sysctl.
 
 The sysctl node will give out HID descriptor for the given device.  It
 should be useful both for debugging and for the usbhidctl(1) utility --
 it will be able to get (and dump) report descriptors from the devices
 that are "children" of the uhid(4): ukbd(4), ums(4) and others.
 
 We can't export this data via the ioctl, because ums(4) and ukbd(4)
 devices are typically used (by moused, Xorg, etc), so we just can't
 open them to pass the file descriptor to the ioctl call.
 
 Any driver can override the automated sysctl creation (that will read
 the report descriptor from the device-supplied data): this is handy for
 uhid(4) -- it sometimes uses hand-crafted report descriptors and we want
 to export the descriptor that driver really uses.
 
 Signed-off-by: Eygene Ryabinkin 
 ---
  sys/dev/usb/input/uhid.c |5 +
  sys/dev/usb/usb_device.c |   68 ---
  sys/dev/usb/usb_hid.c|  214 ++=
 
  sys/dev/usb/usb_hooks.h  |   48 ++
  sys/dev/usb/usbhid.h |1 +
  5 files changed, 325 insertions(+), 11 deletions(-)
  create mode 100644 sys/dev/usb/usb_hooks.h
 
 diff --git a/sys/dev/usb/input/uhid.c b/sys/dev/usb/input/uhid.c
 index 411aeb6..2432491 100644
 --- a/sys/dev/usb/input/uhid.c
 +++ b/sys/dev/usb/input/uhid.c
 @@ -756,6 +756,11 @@ uhid_attach(device_t dev)
if (error) {
goto detach;
}
 +
 +  /* Sysctl stuff */
 +  hid_install_hiddesc_sysctl_handler(dev,
 +  sc->sc_repdesc_ptr, sc->sc_repdesc_size);
 +
return (0); /* success */
 =20
  detach:
 diff --git a/sys/dev/usb/usb_device.c b/sys/dev/usb/usb_device.c
 index 6617297..df2d531 100644
 --- a/sys/dev/usb/usb_device.c
 +++ b/sys/dev/usb/usb_device.c
 @@ -50,6 +50,7 @@
  #include 
  #include 
  #include 
 +#include 
  #include "usbdevs.h"
 =20
  #define   USB_DEBUG_VAR usb_debug
 @@ -81,8 +82,8 @@ static void  usb_init_endpoint(struct usb_device *, uint8_=
 t,
struct usb_endpoi

Re: usb/137189: [usb][patch] create and use sysctl nodes for HID report descriptors

2009-07-30 Thread Eygene Ryabinkin
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
{_.-``-' {_/#
___
freebsd-usb@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-usb
To unsubscribe, send any mail to "freebsd-usb-unsubscr...@freebsd.org"


Re: usb/137189: [usb][patch] create and use sysctl nodes for HID report descriptors

2009-07-28 Thread Eygene Ryabinkin
The following reply was made to PR usb/137189; it has been noted by GNATS.

From: Eygene Ryabinkin 
To: bug-follo...@freebsd.org, freebsd-usb@FreeBSD.org
Cc: hsela...@c2i.net
Subject: Re: usb/137189: [usb][patch] create and use sysctl nodes for HID
 report descriptors
Date: Tue, 28 Jul 2009 19:40:27 +0400

 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
 {_.-``-' {_/#
___
freebsd-usb@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-usb
To unsubscribe, send any mail to "freebsd-usb-unsubscr...@freebsd.org"


Re: usb/137189: [usb][patch] create and use sysctl nodes for HID report descriptors

2009-07-28 Thread Eygene Ryabinkin
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
{_.-``-' {_/#
___
freebsd-usb@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-usb
To unsubscribe, send any mail to "freebsd-usb-unsubscr...@freebsd.org"


Re: usb/137189: [usb][patch] create and use sysctl nodes for HID report descriptors

2009-07-28 Thread Hans Petter Selasky
The following reply was made to PR usb/137189; it has been noted by GNATS.

From: Hans Petter Selasky 
To: rea-f...@codelabs.ru
Cc: bug-follo...@freebsd.org,
 freebsd-usb@freebsd.org
Subject: Re: usb/137189: [usb][patch] create and use sysctl nodes for HID 
report descriptors
Date: Tue, 28 Jul 2009 14:13:25 +0200

 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
 
___
freebsd-usb@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-usb
To unsubscribe, send any mail to "freebsd-usb-unsubscr...@freebsd.org"


Re: usb/137189: [usb][patch] create and use sysctl nodes for HID report descriptors

2009-07-28 Thread Hans Petter Selasky
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

___
freebsd-usb@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-usb
To unsubscribe, send any mail to "freebsd-usb-unsubscr...@freebsd.org"


Re: usb/137189: [usb][patch] create and use sysctl nodes for HID report descriptors

2009-07-28 Thread Eygene Ryabinkin
The following reply was made to PR usb/137189; it has been noted by GNATS.

From: Eygene Ryabinkin 
To: bug-follo...@freebsd.org, freebsd-usb@FreeBSD.org
Cc: hsela...@c2i.net
Subject: Re: usb/137189: [usb][patch] create and use sysctl nodes for HID
 report descriptors
Date: Tue, 28 Jul 2009 15:51:43 +0400

 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
 {_.-``-' {_/#
___
freebsd-usb@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-usb
To unsubscribe, send any mail to "freebsd-usb-unsubscr...@freebsd.org"


Re: usb/137189: [usb][patch] create and use sysctl nodes for HID report descriptors

2009-07-28 Thread Eygene Ryabinkin
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
{_.-``-' {_/#
___
freebsd-usb@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-usb
To unsubscribe, send any mail to "freebsd-usb-unsubscr...@freebsd.org"


Re: usb/137189: [usb][patch] create and use sysctl nodes for HID report descriptors

2009-07-27 Thread Hans Petter Selasky
The following reply was made to PR usb/137189; it has been noted by GNATS.

From: Hans Petter Selasky 
To: Eygene Ryabinkin 
Cc: freebsd-gnats-sub...@freebsd.org
Subject: Re: usb/137189: [usb][patch] create and use sysctl nodes for HID 
report descriptors
Date: Mon, 27 Jul 2009 22:41:38 +0200

 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
 
___
freebsd-usb@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-usb
To unsubscribe, send any mail to "freebsd-usb-unsubscr...@freebsd.org"


Re: usb/137189: [usb][patch] create and use sysctl nodes for HID report descriptors

2009-07-27 Thread Eygene Ryabinkin
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%F8S6=E;f...@4gea8fen
M:VEN(#QR96$M9F)S9$!C;V1E;&%BF5S(&%R92!A;'-O(&-A
M;&-U;&%t...@9f]r(&%L;"!R97!O3...@17eg96ye(%)Y86)I;FMI;B`\"`U93`T,34U+BXX-&,V.30P(#$P,#8t-`hm...@82]uF4@/2!H:61?F4HF4@)6...@8get97-<
M;B(L('-I>F4I.PH@"BT)71EF4@)6...@8get97-<;B(L('-I>f4i...@?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
{_.-``-' {_/#
___
freebsd-usb@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-usb
To unsubscribe, send any mail to "freebsd-usb-unsubscr...@freebsd.org"


Re: usb/137189: [usb][patch] create and use sysctl nodes for HID report descriptors

2009-07-27 Thread Eygene Ryabinkin
The following reply was made to PR usb/137189; it has been noted by GNATS.

From: Eygene Ryabinkin 
To: freebsd-gnats-sub...@freebsd.org, freebsd-usb@FreeBSD.org
Cc:  
Subject: Re: usb/137189: [usb][patch] create and use sysctl nodes for HID
report descriptors
Date: Tue, 28 Jul 2009 00:01:28 +0400

 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%F8S6=E;f...@4gea8fen
 M:VEN(#QR96$M9F)S9$!C;V1E;&%BF5S(&%R92!A;'-O(&-A
 M;&-U;&%t...@9f]r(&%L;"!R97!O3...@17eg96ye(%)Y86)I;FMI;B`\"`U93`T,34U+BXX-&,V.30P(#$P,#8t-`hm...@82]uF4@/2!H:61?F4HF4@)6...@8get97-<
 M;B(L('-I>F4I.PH@"BT)71EF4@)6...@8get97-<;B(L('-I>f4i...@?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
 {_.-``-' {_/#
___
freebsd-usb@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-usb
To unsubscribe, send any mail to "freebsd-usb-unsubscr...@freebsd.org"


usb/137189: [usb][patch] create and use sysctl nodes for HID report descriptors

2009-07-27 Thread Eygene Ryabinkin

>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.

>Fix:

The following patch makes kernel-side changes: it introduces general
framework to create opaque sysctl nodes 'dev...hiddesc'
that are exporting HID descriptor to the userspace.
--- 0003-UHID-implement-new-sysctl-node-hiddesc.patch begins here ---
begin 644 0003-UHID-implement-new-sysctl-node-hiddesc.patch
M1G)O;2`S-3,R931F-3EC,#6=E;f...@4gea8fen
M:VEN(#QR96$M9F)S9$!C;V1E;&%B7-C=&PN"@I3:6=N960M;V9F+6)Y.B!%
M>6=E;f...@4gea8fen:VEN(#QR96$M9F)S9$!C;V1E;&%B7,O9&5V+W5S8B]I;G!U="]U:&ED+F,@?"`@("`U("LK*RLK"B!S>7,O9&5V
M+W5S8B]I;G!U="]U:V)D+F,@?"`@(#,T("LK*RLK*RLK*RLK*RLK*RLK*RLK
M*RLK*RTM+2TM+2TM+2T*('-Y7,O9&5V+W5S8B]I;G!U="]U
M:&ED+F,@8B]S>7,O9&5V+W5S8B]I;G!U="]U:&ED+F,*:6YD97@@-#$Q865B
M-BXN,C0S,C0Y,2`Q,#`V-#0*+2TM(&$OF4I.PHK"B`)"`R.34T-F$U+BYC,F,Y9F%C
M(#$P,#8t-`hm...@82]s>7,O9&5V+W5S8B]I;G!U="]U:V)D+F,**RLK(&(O
MPH@"75I;G0X7W0)#`Q"D!`("TW,C8L,3...@*s#`P,#,I+`H@"0D)("`@(&AI9%]I;G!U
M="P@,"P@)G-C+3YS8U]L;V-?87!P;&5?9FXL("9F;&%GF4H:&ED7W!T71E(&9OF4H:&ED7W!TF4L"BL)"2`@("!H:61?;W5T<'5T+"`F7-C=&Q?:&%N9&QEF4I.PHK"B`)
M+RH@;&]C:R!K97EB;V%R9"!M=71E>"`J+PH@"B`);71X7VQO8VLH)D=I86YT
m*3l*...@+3@U-RPV("LX-C8L."!`0"!U:V)D7V%T=&%C:"AD979I8V5?="!D
M978I"B`*(&1E=&%C:#H*(`EU:V)D7V1E=&%C:"AD978I.PHK"6EF("AS8RT^
M:&ED7W)D97-C*0HK"0EF%]I;FET*"9S8RT^"D["B`*(`EI9B`H97)R*2!["BL)"7-C+3YH
M:61?F4@/2!H:61?F4H9%]P='(L(&1?
M;&5N+"!H:61?:6YP=70L("9S8RT^PHM"0D)=6US7VAI9%]P
M87)s92as...@9&5V+"!D7W!TF4L(&DI.PH@"0E]"B`)?0H@"D!`("TU-C&9E2...@f
M"D["B`**PEI9B`H7,O9&5V+W5S8B]U7,O9&5V
M+W5S8B]U"P*(`E]"B`)2!W86YT('-U8V@@7-C=&Q?:&%N
M9&QEF4I"BM["BL):6...@*&1E"AD978I+`HK
M"2`@("!365-#5$Q?0TA)3$1214XH9&5V:6-E7V=E=%]S>7-C=&Q?=')E92AD
M978I*2P**PD@("`...@3te$7t%55$\l(")H:61D97-C(b...@0u1,5%E015]35%))
M3D=\0U1,1DQ!1U]21"P**PD@("`...@9&5s...@*&EN="ES:7IE+"!H:61?7-C=&Q?:&%N9&QE
MF5?="!S:7IE*3L*("-E
M;f...@d)"0D)+...@7tm%4dy%3"`J+PH@(V5N9&EF"0D)"0DO*B!?55-"7TA)
51%](7R`J+PHM+2`*,2XV+C,N,0H*
`
end
--- 0003-UHID-implement-new-sysctl-node-hiddesc.patch ends here ---

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 begins here 
---
begin 644 0004-libusbhid-use-new-sysctl-node-hiddesc-to-get-HID-des.patch
M1G)O;2`X96(V-F4V.#9B,C1B-V1F9&8S831C83$W-38U,34U,&,V93EF,F%F
M($UO;B!397`@,3<@,#`Z,#`Z,#`@,C`P,0I&6=E;f...@4gea8fen
M:VEN(#QR96$M9F)S9$!C;V1E;&%B3...@17eg96ye(%)Y86)I;FMI;B`\7,O9&5V+W5S8B]U
M7!E7-C=&PN:#X*(`H@
M(VEN8VQU9&4@/&%S7!...@^"B`C:6YC
M;'5D92`\97)R;F\N:#X**R-I;F-L=61E(#QF8VYT;"YH/@H@(VEN8VQU9&4@
M/'-T9&QI8BYH/@H@(VEN8VQU9&4@/'-TPHK"2\J(&-H96-K
M('-I>f...@*b\**pei9b`h;&5N(#T](#`I"BL)"7)E='5R;B`P.PHK"BL)+RH@
m8vae...@14y$7t-/3$Q%0U1)3...@*b\**pei9b`h*&1A=&$I6VQE;B`M(#%=
M("$](#!X0S`I"BL)"7)E='5R;B`P.PHK"BL)F5?="!S>7-C=&Q?;G-I>F4L(&DL(&H["BL):6YT('-E
M96Y?9&EG:70["BL**PES;&%S:"`]('-T7-C=&Q?;G-I
M>F4@/0HK"2`@("!S:7IE;V8H(F1E=BXB*2`K('-T7-C=&Q?;F%M92D**PD)0HK("H@
M=7-E9"!M96-H86YIPHK"79O:6...@*f1e7-C
M=&Q?;F]D92`](%]H:61?9&5V;F%M95]T;U]S>7-C=&Q?;F%M92AD978I.PHK
M"6EF("AS>7-C=&Q?;F]D92`]/2!.54Q,*0HK"0EG;W1O(&)A9#L**PHK"2\J
M($1E=&5R;6EN92!T:&4@7-C=&Q?;f]d...@9&5S8U]D871A
M+"`F9&5S8U]S:7IE+"!.54Q,+"`P*3L**PEI9B`H97)R*0HK"0EG;W1O(&)A
M9#L**PHK"69R964H&QE;B`](#8U-3,U.PHK"75G9"YU9V1?;6%X;&5N(#T@
M54=$7TU!6%-)6D4["B`):6...@*&EO8W1L*&9D+"!54T)?1T547U)%4$]25%]$
M15-#+"`F=6=D*2`\(#`I('L*("-I9F1E9B!(241?0T]-4$%4-PH@"0DO*B!C
M;W5L9"!N;W0@PHM"0DO*B!I;G9A;&ED(&5N9"!B>71E("HO"BL)
m...@0vae8vl@9&5S8W)I<'1O2`J+PHK"6EF("@A7VES7W9A
M;&ED7VAI9%]D97-C*&1A=&$L('5G9"YU9V1?86-T;&5N*2D@>PH@"0EF2!C86QL:6YG"B!W:71H(&$...@9fel92!d97-c2UQ=6%L
M:69I960@<&%T:"!T;R!T:&4...@9&5V:6-E.R!T:&ES(&9U;F-T:6]N(&%L;&]W
M6EN9PHK;v...@=&AE(')E<&]R="!D97-C"!B.#7,O9&5V+W5S
M8B]U"!F.3`Q.&4R+BXQ861A-C7,O9&5V+W5S8B]U7,O9&5V+W5S
M8B]UPH@"75I;G0X7W0)=6%I7V%L=%]I;F1E>#L*('T["B`*
M*R\J($UA>&em...@=f%l=64@;v...@=&AE('9AVUA>&QE
M;b...@86-t;&5N+"!O9F9S971]+B`J+PHK(V1E9FEN90E51T1?34%84TE:10DV
M-34S-0HK"B!S=')u...@=7-b7v=e;E]D97-C"`T.#4T,3AF+BXU93`T,34U(#$P,#8T-`HM
m...@82]uRelease-Note