Stap 1: Kernel wijzigen
De structuren en de lijnen van code wordt hieronder weergegeven (het kan ook worden gedownload vanaf hier):
statische LIST_HEAD(hidg_func_list);
/ * verborg descriptor voor een toetsenbord * /
statische struct hidg_func_descriptor pcduino_keyboard_date = {}
.subclass = 0, / * geen subklasse * /
.Protocol = 1, / * toetsenbord * /
.report_length = 8,
.report_desc_length = 63,
.report_desc = {}
0 × 05, 0 × 01, / * USAGE_PAGE (generieke Desktop) * /
0 × 09, 0 × 06, / * gebruik (toetsenbord) * /
0xa1, 0 × 01, / * collectie (toepassing) * /
0 × 05, 0 × 07, / * USAGE_PAGE (toetsenbord) * /
0 × 19, 0xe0, / * USAGE_MINIMUM (LeftControl toetsenbord) * /
0 × 29, 0xe7, / * USAGE_MAXIMUM (toetsenbord recht GUI) * /
0 × 15, 0 × 00, / * LOGICAL_MINIMUM (0) * /
0 × 25, 0 × 01, / * LOGICAL_MAXIMUM (1) * /
0 × 75, 0 × 01, / * REPORT_SIZE (1) * /
0 × 95, 0 × 08, / * REPORT_COUNT (8) * /
0 × 81, 0 × 02, / * INPUT (Data, Var, Abs) * /
0 × 95, 0 × 01, / * REPORT_COUNT (1) * /
0 × 75, 0 × 08, / * REPORT_SIZE (8) * /
0 × 81, 0 × 03, / * INPUT (Cnst, Var, Abs) * /
0 × 95, 0 × 05, / * REPORT_COUNT (5) * /
0 × 75, 0 × 01, / * REPORT_SIZE (1) * /
0 × 05, 0 × 08, / * USAGE_PAGE (LED's) * /
0 × 19, 0 × 01, / * USAGE_MINIMUM (Num Lock) * /
0 × 29, 0 × 05, / * USAGE_MAXIMUM (Kana) * /
0 × 91, 0 × 02, / * OUTPUT (Data, Var, Abs) * /
0 × 95, 0 × 01, / * REPORT_COUNT (1) * /
0 × 75, 0 × 03, / * REPORT_SIZE (3) * /
0 × 91, 0 × 03, / * OUTPUT (Cnst, Var, Abs) * /
0 × 95, 0 × 06, / * REPORT_COUNT (6) * /
0 × 75, 0 × 08, / * REPORT_SIZE (8) * /
0 × 15, 0 × 00, / * LOGICAL_MINIMUM (0) * /
0 × 25, 0 × 65, / * LOGICAL_MAXIMUM (101) * /
0 × 05, 0 × 07, / * USAGE_PAGE (toetsenbord) * /
0 × 19, 0 × 00, / * USAGE_MINIMUM (gereserveerd) * /
0 × 29, 0 × 65, / * USAGE_MAXIMUM (de toepassing van het toetsenbord) * /
0 × 81, 0 × 00, / * INPUT (Data, Aire, Abs) * /
0XC0 / * END_COLLECTION * /
}
};
statische struct platform_device pcduino_hid_keyboard = {}
.name = "hidg",
.id = 0,
.num_resources = 0,
.resource = 0,
. dev.platform_data = pcduino_keyboard_date,
};
/ * verborg descriptor voor een muis * /
statische struct hidg_func_descriptor pcduino_mouse_data = {}
.subclass = 0, //No subklasse
.Protocol = 2, //Mouse
.report_length = 4,
.report_desc_length = 52,
.report_desc = {}
0 × 05, 0 × 01, //Usage Page (generieke Desktop Controls)
0 × 09, 0 × 02, //Usage (muis)
0xa1, 0 × 01, //Collction (toepassing)
0 × 09, 0 × 01, //Usage (pointer)
0xa1, 0 × 00, //Collction (fysiek)
0 × 05, 0 × 09 //Usage pagina (knop)
0 × 19, 0 × 01, //Usage Minimum(1)
0 × 29, 0 × 05, //Usage Maximum(5)
0 × 15, 0 × 00, //Logical Minimum(1)
0 × 25, 0 × 01, //Logical Maximum(1)
0 × 95, 0 × 05, //Report Count(5)
0 × 75, 0 × 01, //Report Size(1)
0 × 81, 0 × 02, //Input(Data,Variable,Absolute,BitField)
0 × 95, 0 × 01, //Report Count(1)
0 × 75, 0 × 03, //Report Size(3)
0 × 81, 0 × 01, //Input(Constant,Array,Absolute,BitField)
0 × 05, 0 × 01, //Usage Page (generieke Desktop Controls)
0 × 09, 0 × 30, //Usage(x)
0 × 09, 0 × 31, //Usage(y)
0 × 09, 0 × 38, //Usage(Wheel)
0 × 15, 0 × 81, //Logical Minimum(-127)
0 × 25, 0x7F, //Logical Maximum(127)
0 × 75, 0 × 08, //Report Size(8)
0 × 95, 0 × 03, //Report Count(3)
0 × 81, 0 × 06, //Input(Data,Variable,Relative,BitField)
0xc0, //End-collectie
0xc0 //End collectie
}
};
statische struct platform_device pcduino_hid_mouse = {}
.name = "hidg",
.id = 1,
.num_resources = 0,
.resource = 0,
. dev.platform_data = pcduino_mouse_data,
};
statische int __init hidg_init(void)
{
int status;
status = platform_device_register(pcduino_hid_keyboard);
Als (status < 0) {}
printk ("hid toetsenbord reg failed\n");
platform_device_unregister(pcduino_hid_keyboard);
status; retourneren
}
status = platform_device_register(pcduino_hid_mouse);
Als (status < 0) {}
printk ("hid muis reg failed\n");
platform_device_unregister(pcduino_hid_mouse);
status; retourneren
}
status = platform_driver_probe (hidg_plat_driver,
hidg_plat_driver_probe);
Als (status < 0)
status; retourneren
status = usb_composite_probe (hidg_driver, hid_bind);
Als (status < 0)
platform_driver_unregister(hidg_plat_driver);
status; retourneren
}
module_init(hidg_init);
statische ongeldig __exit hidg_cleanup(void)
{
platform_driver_unregister(hidg_plat_driver);
platform_device_unregister(pcduino_hid_keyboard);
platform_device_unregister(pcduino_hid_mouse);
usb_composite_unregister(hidg_driver);
}
Structuren moeten worden toegevoegd. We moeten ook de structuren van de twee functies registreren. Gelieve worden opgemerkt volgens USB-protocol, elk apparaat heeft een descriptor. De twee structuren zijn de descriptoren van de HID muis en toetsenbord. In de volgende stap gaan wij voor het configureren van de kernel. Het kan ook worden gedownload vanaf hier. config_kernel
Apparaatstuurprogramma's — >
[*] USB-ondersteuning — >
USB-Gadget ondersteuning — >
SoftWinner SUN4I perifere USB-Controller
Combinatie dummy HCD (ontwikkeling)
USB-Gadget stuurprogramma 's
Combinatie gadget nul (ontwikkeling)
Combinatie audio Gadget (experimenteel)
Ethernet Gadget (met CDC Ethernet ondersteuning)
[*] RNDIS ondersteuning
[] Ethernet emulatie Model (EEM) ondersteuning
Network Control Model (NCM) ondersteuning in combinatie
Combinatie gadget Filesystem (experimenteel)
Combinatie functie Filesystem (experimenteel)
Combinatie bestandsgebaseerde opslag Gadget (AFGEKEURD)
Combinatie massaopslag Gadget
Seriële Gadget (met CDC ACM en CDC OBEX ondersteuning)
MIDI Gadget (experimenteel)
Printer Gadget
CDC in combinatie samengesteld apparaat (Ethernet en ACM)
Combinatie CDC samengesteld apparaat (ACM en massa-opslag)
Combinatie multifunctionele samengestelde Gadget (experimenteel)
HID Gadget
Combinatie EHCI Debug apparaat Gadget
Combinatie USB Webcam Gadget