0

I have some questions regarding the hid-generic and implementing my own driver. Below is the hid-generic source code.

hid-generic.c source code

My questions are:

  1. How does the hid-generic driver report the behavior from the mouse to the kernel?

The source code is too simple. I cannot find which part provides this transformation.

  1. What is the actual purpose of the raw_event function within the driver code? Is it necessary to have when implementing the device driver?

  2. What would you recommend to set up a test environment for the HID device in order to make sure it functions correctly on a Raspberry Pi? Any tools used for testing in the industrial environment for the HID device driver?

1 Answer 1

0

How does the hid-generic driver report the behavior from the mouse to the kernel?

Not at all. This is just the generic HID driver.

Are you perhaps confusing this with hiddev.c from the usbhid directory?

What is the actual purpose of the raw_event function within the driver code? Is it necessary to have when implementing the device driver?

this function doesn't appear in hid-generic.c. Maybe you want to ask this in a new question.

What would you recommend to set up a test environment for the HID device in order to make sure it functions correctly on a Raspberry Pi? Any tools used for testing in the industrial environment for the HID device driver?

Two things:

  • for pure software testing, you would probably take the C file as you would use it as a driver (module or in-tree, but probably as module), and include it into a software test fixture, to run unit tests on your specific things. How you do that very much depends on your driver design. My guess is you shouldn't be implementing a kernel-mode driver at all and deal with most things in userland software (libuv?), but that only makes sense if your HID device is kind of similar to existing devices.
  • for hardware-in-the-loop-testing: Well, obviously, you will have to build a mechanical apparatus that exercises your input device, and then check that your Linux kernel driver does exactly what you want (hint: VMs are your friend). What you test with that, and to which degree, depends on the kind of HID you're building, and the kind of investment to quality you need to make for its use case. A pushbutton on a beverage vending machine probably needs different testing than the touchscreen controlling your manned space flight rocket or the steering wheel of your car.
3
  • Thanks for all your information. According to the raw_event, it actually does not exist in hid-generic. I'm just wondering how the hid-generic driver translates the device behavior (such as mouse clicking or mouse movement) to the format understood by the input subsystem. Commented Jun 24 at 2:13
  • I mention the raw_event in my question because I only know that the device behavior can be detected in this callback function. And I guess the behavior can then be translated to the format in this function. Actually, I did not find how the behavior is translated in hid-generic. Commented Jun 24 at 2:15
  • I think I am dealing with user-mode driver, since it does not directly interact with hardware resources. Alright, I kind of understand what you mention. The expected behavior would depends on our design, and it will be confirmed and defined in the unit test. Commented Jun 24 at 2:19

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.