USB Hid driver Help
Greg KH
greg at kroah.com
Mon Feb 3 15:11:02 EST 2020
On Mon, Feb 03, 2020 at 04:32:46PM +0000, Lucas Tanure wrote:
> Hi,
>
> I'm trying to write a Hid driver for MCP2210.
What type of device is this?
> But the USB Hid specification is quite complicated.
The kernel should do it "all for you" already, why do you need to create
a custom HID driver for this device?
What type of HID reports does the device export and why doesn't the
existing kernel drivers work for you?
> I would like to know how to send and receive data to the device. Any
> links to a good tutorial ?
HID has the idea of "reports" and data comes in and out in that specific
format, all depending on how the device describes itself. There's isn't
usually a normal "send/receive" type of thing, but it all depends on the
type of device.
> This is my current driver is attached.
>
> Thanks
> Lucas
> #define DEBUG
> #include <linux/module.h>
> #include <linux/hid.h>
> #include <linux/usb.h>
>
> static int mcp2210_probe(struct hid_device *hdev,
> const struct hid_device_id *id)
> {
> struct usb_interface *intf = to_usb_interface(hdev->dev.parent);
> int ret = 0;
>
> hid_dbg(hdev, "%s\n", __FUNCTION__);
>
> ret = hid_parse(hdev);
> if (ret) {
> hid_err(hdev, "parse failed\n");
> return ret;
> } else {
> hid_dbg(hdev, "parse success\n");
> }
>
> ret = hid_hw_start(hdev, HID_CONNECT_DEFAULT);
> if (ret) {
> hid_err(hdev, "hw start failed\n");
> return ret;
> } else {
> hid_dbg(hdev, "start success\n");
> }
Does this all work?
What fails?
thanks,
greg k-h
More information about the Kernelnewbies
mailing list