Re: [PATCH 2/2] USB: gadget: f_hid: Add Set-Feature report

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

 




On 7/26/22 02:51, Maxim Devaev wrote:
> В Mon, 25 Jul 2022 17:58:26 -0700
> Vicki Pfau <vi@xxxxxxxxxxx> пишет:
> 
>> While the HID gadget implementation has been sufficient for devices that only
>> use INTERRUPT transfers, the USB HID standard includes provisions for Set- and
>> Get-Feature report CONTROL transfers that go over endpoint 0. These were
>> previously impossible with the existing implementation, and would either send
>> an empty reply, or stall out.
>>
>> As the feature is a standard part of USB HID, it stands to reason that devices
>> would use it, and that the HID gadget should support it. This patch adds
>> support for host-to-device Set-Feature reports through a new ioctl
>> interface to the hidg class dev nodes.
>>
>> Signed-off-by: Vicki Pfau <vi@xxxxxxxxxxx>
> 
> Won't it break the logic of the existing software that works with /dev/hidgX?
> Will it work if I want my gadget to work the old way?

For existing software to use SET_FEATURE at all it has to use an alternative mode, which seems to have only been added somewhat recently. That mode also appears to preclude use of INTERRUPT transfers at all, unless there's some way to set up two hidg nodes that map to the same interface, with one for INTERRUPT and one for SET_FEATURE. If this breaks that, I suppose that's a regression, but this is meant to augment the original, long-standing mode so you can mix INTERRUPT and SET/GET_FEATURE transfers, as there is no way to do that yet. Honestly, the alternate mode seems more like a workaround, as far as I can tell, and not an ideal implementation. I'm not sure when it was added, but as I was originally authoring this against 5.13 and didn't see it until I went to rebase onto master, it can't have been that long ago. So if it breaks any software (which I don't believe it does), it would only affect very new software.

As I alluded to, I'd thought about perhaps adding a second node per interface so one would act as INTERRUPT transfers and the other as SET/GET_FEATURE transfers, but I already had this code half written and wanted to get feedback first, especially since what I have now works (although it's not well-tested after rebasing).

> It is important that the old behavior is the default without having to use
> the new ioctls. As for these ioctls, since this is an addition to the new API,
> they should be documented. I think it's also worth adding these ioctls
> to the userspace example:
>   - Documentation/usb/gadget_hid.rst
>   - Documentation/usb/gadget-testing.rst

Yup, I should probably do that. Forgot about that before sending the patch, though I'm hoping to be told if my approach was even worthwhile before I write that, but I can work on that soon either way.

> 
> But it seems to me that extending the HID functionality to meet
> the specifications is definitely a good idea :)



[Index of Archives]     [Linux Media]     [Linux Input]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [Old Linux USB Devel Archive]

  Powered by Linux