Re: Clarification about the hidraw documentation on HIDIOCGFEATURE

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Wed, Jun 21, 2023 at 11:05 PM Benjamin Tissoires
<benjamin.tissoires@xxxxxxxxxx> wrote:
>
> On Wed, Jun 21, 2023 at 1:27 PM Xiaofan Chen <xiaofanc@xxxxxxxxx> wrote:
> >
> > On Tue, Jun 20, 2023 at 7:28 AM Xiaofan Chen <xiaofanc@xxxxxxxxx> wrote:
> > >
> > > On Mon, Jun 19, 2023 at 11:14 PM Xiaofan Chen <xiaofanc@xxxxxxxxx> wrote:
> > > >
> > > > On Mon, Jun 19, 2023 at 2:09 PM Xiaofan Chen <xiaofanc@xxxxxxxxx> wrote:
> > > > >
> > > > > I know that thurrent documentation has been there since it was created by
> > > > > Alan Ott many years ago. And he started the HIDAPI project around that
> > > > > time as well. However, I am starting to doubt whether it is correct or not
> > > > > based on the testing using HIDAPI.
> > > > >
> > > > > Please help to clarify. Thanks.
> > > > >
> > > > > https://docs.kernel.org/hid/hidraw.html
> > > > > +++++++++++++++++++++++++++++++++++++++++++++++++++++
> > > > > HIDIOCGFEATURE(len):
> > > > >
> > > > > Get a Feature Report
> > > > >
> > > > > This ioctl will request a feature report from the device using the
> > > > > control endpoint. The first byte of the supplied buffer should be
> > > > > set to the report number of the requested report. For devices
> > > > > which do not use numbered reports, set the first byte to 0. The
> > > > > returned report buffer will contain the report number in the first
> > > > > byte, followed by the report data read from the device. For devices
> > > > > which do not use numbered reports, the report data will begin at the
> > > > > first byte of the returned buffer.
>
>
> Yep, this is wrong.
>
> This should be read:
> ```
> The returned report buffer will contain the report number in the first
> byte or 0 when the device doesn't use numbered reports. The data read
> from the device will be stored in the following bytes.
> ```
>
> FWIW, the difficulty to find out what the code does is because this part
> is handled in each HID transport driver: USB, Bluetooth, I2C.
>
> Looking at drivers/hid/usbhid/hid-core.c, lines 869+, the function
> usbhid_get_raw_report() is the one used by hidraw in the end and is
> still the original code from Alan:
>
> ```
> /* Byte 0 is the report number. Report data starts at byte 1.*/
> buf[0] = report_number;
> if (report_number == 0x0) {
>         /* Offset the return buffer by 1, so that the report ID
>            will remain in byte 0. */
>         buf++;
>         count--;
>         skipped_report_id = 1;
> }
> ```
>
> > Hi Jiri and Benjamin,
> >
> > Sorry to ping the two maintainers, hopefully you two can give the
> > answer. Thanks.
>
> See above, I also think the documentation is wrong.
>

Thanks a lot for the confirmation.

On the same note, I think it is the same for HIDIOCGINPUT as well, but there
is no need to update the documentation once the documentation is fixed
for HIDIOCGFEATURE.

++++++++++++++
HIDIOCGINPUT(len):

Get an Input Report

This ioctl will request an input report from the device using the
control endpoint. This
is slower on most devices where a dedicated In endpoint exists for
regular input reports,
but allows the host to request the value of a specific report number.
Typically, this is
used to request the initial states of an input report of a device,
before an application
listens for normal reports via the regular device read() interface.
The format of the
buffer issued with this report is identical to that of HIDIOCGFEATURE.
++++++++++++++


-- 
Xiaofan




[Index of Archives]     [Linux Media Devel]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [Linux Wireless Networking]     [Linux Omap]

  Powered by Linux