A little research on Linux gadget HID device __linux

Source: Internet
Author: User
Tags abs

Above, configure the compile gadget HID module


Build G_hid.ko in Driver/usb/gadget directory after make modules

To execute the load command:

root@xxx:/mnt# insmod G_hid.ko 
insmod:can ' t insert ' G_hid.ko ': No such device
Hint error.

In the TI Technology Forum to see the relevant technical reply:

The error message for you had before ' error inserting ' G_hid.ko ':-1 No such device. ' are due to incomplete hid gadget Driv Er. You can followdocumentation/usb/gadget_hid.txt to add your own platform device portion.

for your reference, the following patch are what I tried and it works with the 3.3 kernel from the link I provided Abov E with SD card boot. Download the mentioned patches

From 6363b29be2c2b477a723b74e52025511be280979 Mon Sep 00:00:00 2001 From:bin Liu <b-liu@ti.com> Date:fri, Ja   N 2013 10:27:57-0600 Subject: [PATCH] patched hid Gadget---drivers/usb/gadget/hid.c | ++++++++++++++++++++++++++++++++++++++++++++++ 1 files changed, insertions (+), 0 deletions (-) diff--git A/drivers /USB/GADGET/HID.C B/DRIVERS/USB/GADGET/HID.C index f888c3e. c037039 100644---a/drivers/usb/gadget/hid.c +++ b/drivers/usb/gadget/hid.c @@ -16,6 +16,8 @@ -16,6 <linux/platfor
 m_device.h> #include <linux/list.h> + #include <linux/usb/g_hid.h> + #define DRIVER_DESC "hid Gadget"
 
#define Driver_version "2010/03/16" @@ -49,6 +51,57 @@ -49,6 hidg_func_node {static list_head (hidg_func_list); + +/* HID Descriptor for a keyboard * * +static struct hidg_func_descriptor = {+. My_hid_data = 0,/* No Subclass S/+ protocol = 1,/* Keyboard/+ Report_length = 8, +. Report_desc_length = =, +. Report_desc = {+ 0x05, 0x01,/* Usage_page (Generic Desktop) * * + 0x09, 0x06,/* USAGE (keyboard) * * + 0XA1, 0x01,/* COLLECTION (Application) * * + 0x05, 0x07,/* usage_page (keyboard) * * + 0x19, 0x E0,/* Usage_minimum (keyboard leftcontrol) * * + 0x29, 0xe7,//* Usage_maximum (keyboard right GUI) * * + 0x15, 0x00	,/* Logical_minimum (0) * * * + 0x25, 0x01,//* Logical_maximum (1) * * + 0x75, 0x01,    /* REPORT_SIZE (1) * * * + 0x95, 0x08,/* REPORT_COUNT (8) * * + 0x81, 0x02,/*   INPUT (data,var,abs)/+ 0x95, 0x01, * report_count (1) * * * + 0x75, 0x08,/* Report_size (8) * * * + 0x81, 0x03,/* INPUT (cnst,var,abs) * * + 0x95, 0x05,/* R Eport_count (5) * * * + 0x75, 0x01, * report_size (1) * * + 0x05, 0x08,/* USA          Ge_page (LEDs)          * * + 0x19, 0x01,/* Usage_minimum (Num Lock) * * * + 0x29, 0x05,//* Usage_maximum (Kana)                     * * + 0x91, 0x02,/* OUTPUT (data,var,abs)/+ 0x95, 0x01,/* Report_count (1)                * * + 0x75, 0x03,/* REPORT_SIZE (3) * * * + 0x91, 0x03,//OUTPUT (Cnst,var,abs)                      * * + 0x95, 0x06,///Report_count (6) * * * + 0x75, 0x08,/* Report_size (8)                * * + 0x15, 0x00,///logical_minimum (0) * * * + 0x25, 0x65,/* Logical_maximum (101) 
* * + 0x05, 0x07, * usage_page (keyboard)/+ 0x19, 0x00,/* Usage_minimum (Reserved) * * 		+ 0x29, 0x65,/* Usage_maximum (keyboard application)/+ 0X81, 0x00,/* INPUT (data,ary,abs) * * +
0XC0/* end_collection * * +} +}; + +static struct Platform_device My_hid = {+. Name = "HIDG", +. id = 0, +. Num_resources = 0, +. Resource = 0, +. Dev.platform_data = &my_hid_data, +}; +/*-------------------------------------------------------------------------/static struct USB_DEVICE_
 
Descriptor Device_desc = {@@ -267,6 +320,13 @@ -267,6 int __init hidg_init (void) {int status;
+ status = Platform_device_register (&my_hid); 
 	+ if (Status < 0) {+ PRINTK ("____ reg failed\n"); + platform_device_unregister (&my_hid); + return status; +} +
 	Status = Platform_driver_probe (&hidg_plat_driver, hidg_plat_driver_probe);
 if (Status < 0) @@ -283,6 +343,7 @@ -283,6 (hidg_init); static void __exit Hidg_cleanup (void) {platform_driver_unregister (&hidg_plat_driver); + Platform_device_
 	Unregister (&my_hid);
 Usb_composite_unregister (&hidg_driver);
} module_exit (Hidg_cleanup);
 --1.7.0.4


Keep trying ...




Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.