I think the HID_MAX_USAGES
is so "small" cause a HID-device report descriptor in cases where the hid-devices report the right size, the size is way smaller, and in that case it's descriptor won't exceed the hard coded HID_MAX_USAGES
limit.
When you get the issue of your keyboard or mice not working, and after a recompile of the kernel with the increased HID_MAX_USES
your device start working. Is that most likely because the lower limit would reject parsing the reported descriptor.
After reading and googling some did I inspect some Linux drivers that seemed to override what the device reported itself. Eg. if the device reported it had 2^15 the driver could override it to the maximum allowed by the HID_MAX_USAGES
, or with the device usages actually size.
So short summed, basically what happens, the hid-device report descriptor specifies an excessively large number of consumer usages (eg. 2^15 ), which is more than HID_MAX_USAGES
. This prevents proper parsing of the reported descriptor and most likely the device or parts of it won't work.
I have been using the dirty hack of increment the HID_MAX_USAGES
myself in a production environment. How dirty it is have I asked with no good answers. But with my knowledge I can see that the hack leaves a bigger memory-footprint, I have not looked into if it might be able to slightly hurt performance a bit. I could not see the hack pose any security risk. (Please correct me if I am wrong.)
I believe incrementing the HID_MAX_USAGES
in a bug-report is out of the question for any mainline kernel, it is no optimal solution. Rater I would suggest you to submit a detailed bug-report about your hid- keyboard\mice not working. You can also buzz the manufacture of your product to add proper support in a driver.
Extended (source):
On Tue, 21 May 2013, Christian Ohm wrote:
> Is there any reason why HID_MAX_USAGES shouldn't be more than 12288?
Well, the reasoning is a mixture of current implementation, and
reasonability.
- we currently have statically allocated arrays on a per-parser basis, for
parsing usages and collection indices. If the number of max usages is
going to grow in an uncontrolled manner, we'll have to change the way
our parser works (which is not impossible, of course).
- most of the ocurences of huge max usages being presented by the devices
have actually turned out to be bogus and could have been fixed by
patching the report descriptor in order to reflect the real behavior of
the device
Thanks,
--
Jiri Kosina
SUSE Labs
The above snippet is from the hid subsystem kernel mantainer.