最終更新:2018-01-12 (金) 08:10:45 (2296d)
Linux/HID
ドキュメント
- kernel.org/doc/Documentation/hid
- kernel.org/doc/Documentation/hid/hid-transport.txt (Linux 3.15~)
- kernel.org/doc/Documentation/hid/hid-sensor.txt?
- kernel.org/doc/Documentation/hid/hiddev.txt
- kernel.org/doc/Documentation/hid/hidraw.txt
- kernel.org/doc/Documentation/hid/uhid.txt
ソースコード
メモ
Linux 3.4 Linux 3.5 CONFIG_HID Generic HID support HID bus support CONFIG_USB_HID USB Human Interface Device (full HID) support USB HID transport layer 汎用HIDドライバ (キーボードとか) generic-usb (drivers/hid/usbhid/hid-core.c) hid-generic (drivers/hid/hid-generic.c)
.config
drivers/hid/Kconfig
- CONFIG_HID_SUPPORT? (~Linux 3.4)
- CONFIG_HID - hid
- CONFIG_HID_BATTERY_STRENGTH?
- CONFIG_HIDRAW - hidraw - HID raw devices, giving access to raw HID events.
- CONFIG_UHID - uhid?
- CONFIG_HID_GENERIC - hid-generic (Linux 3.5~)
- Special HID Drivers (抜粋)
- CONFIG_HID_APPLE?
- CONFIG_HID_LOGITECH_DJ
- CONFIG_HID_MAGICMOUSE?
- CONFIG_HID_MICROSOFT?
- CONFIG_HID_MULTITOUCH - hid-multitouch
- CONFIG_HID_SONY
- CONFIG_HID_WACOM
- CONFIG_HID_WIIMOTE?
drivers/hid/usbhid/Kconfig
- CONFIG_USB_HID - usbhid - USB HID transport layer
- CONFIG_HID_PID?
- CONFIG_USB_HIDDEV - hiddev
- CONFIG_USB_KBD - usbkbd
- CONFIG_USB_MOUSE? - usbmouse
drivers/hid/i2c-hid/Kconfig?
ドライバ
ローレベルドライバ (hid_ll_driver)
usb_hid_driver (USB)
hidp_hid_driver? (Bluetooth)
- net/bluetooth/hidp/core.c?
i2c_hid_ll_driver? (I2C)
uhid_hid_driver? (UHID)
汎用ドライバ
- 〜Linux 3.4
- Linux 3.5〜
- CONFIG_HID_GENERIC - hid_generic? (name=hid-generic)
- drivers/hid/hid-generic.c
hid - HID bus support
usbhid - USB HID transport layer
- kernel.org/doc/Documentation/input/input.txt
- usbhid is the largest and most complex driver of the whole suite. It handles all HID devices, and because there is a very wide variety of them, and because the USB HID specification isn't simple, it needs to be this big.
- Currently, it handles USB mice, joysticks, gamepads, steering wheels keyboards, trackballs and digitizers.
- However, USB uses HID also for monitor controls, speaker controls, UPSs, LCDs and many other purposes.
- The monitor and speaker controls should be easy to add to the hid/input interface, but for the UPSs and LCDs it doesn't make much sense. For this, the hiddev interface was designed. See kernel.org/doc/Documentation/hid/hiddev.txt for more information about it.
- The usage of the usbhid module is very simple, it takes no parameters, detects everything automatically and when a HID device is inserted, it detects it appropriately.
- However, because the devices vary wildly, you might happen to have a device that doesn't work well. In that case #define DEBUG at the beginning of hid-core.c and send me the syslog traces.
hid-generic - Generic HID driver
- CONFIG_HID_GENERIC (Linux 3.5~)
- hid_driver hid_generic? (name=generic-usb)
usbmouse/usbkbd
- ブートプロトコル用のドライバ。
- Say Y here only if you are absolutely sure that you don't want to use the generic HID driver for your USB keyboard and prefer to use the keyboard in its limited Boot Protocol mode instead.
- For embedded systems, for mice with broken HID descriptors and just any other use when the big usbhid wouldn't be a good choice, there is the usbmouse driver.
hid-multitouchとか
ドライバの判定
VID
- drivers/hid/hid-ids.h
- drivers/hid/hid-core.c
- 配列
- hid_have_special_driver - A list of devices for which there is a specialized driver on HID bus.
- hid_ignore_list? - a list of devices that shouldn't be handled by HID core at all
- hid_mouse_ignore_list? - mouse devices which should not be handled by the hid layer
- 関数
- hid_match_id?(struct hid_device *hdev, const struct hid_device_id *id)
- hid_match_one_id(struct hid_device *hdev, const struct hid_device_id *id)
- 配列
hid
init
- drivers/hid/hid-core.c
- module_init(hid_init);
static struct bus_type hid_bus_type = { .name = "hid", .dev_groups = hid_dev_groups, .match = hid_bus_match, .probe = hid_device_probe, .remove = hid_device_remove, .uevent = hid_uevent, };
bus_type.probe = hid_device_probe (drivers/hid/hid-core.c)
- down_interruptible
- hid_match_device
- hid_match_one_id
- hid_driver.probe -> mt_probe?
- hid_match_id?
- hid_open_report
- hid_hw_start
- hid_connect - ここでhiddev/hidrawとして登録
- hidinput_connect - drivers/hid/hid-input.c (HID to Linux Input mapping)
- hiddev_connect? - hiddev - drivers/hid/usbhid/hiddev.c?
- hidraw_connect? - hidraw - drivers/hid/hidraw.c
- device_create_bin_file?
- hid_connect - ここでhiddev/hidrawとして登録
- hid_close_report?
usbhid
- drivers/hid/usbhid/hid-core.c
- module_init(hid_init);
- usbhid_quirks_init?
- usb_register(hid_driver) - usbhid
static struct usb_driver hid_driver = { .name = "usbhid", .probe = usbhid_probe, .disconnect = usbhid_disconnect, #ifdef CONFIG_PM .suspend = hid_suspend, .resume = hid_resume, .reset_resume = hid_reset_resume, #endif .pre_reset = hid_pre_reset, .post_reset = hid_post_reset, .id_table = hid_usb_ids, .supports_autosuspend = 1, };
- usb_register_driver(driver, THIS_MODULE, KBUILD_MODNAME)
usb_driver.probe = usbhid_probe()
- usbcoreのusb_probe_interfaceから呼ばれる
- usb_endpoint_is_int_in?
- hid_allocate_device?
- usb_set_intfdata?
- usbhid_lookup_quirk
- usb_make_path?
- usb_string
- init_waitqueue_head?
- hid_add_device
- hid_have_special_driverかどうかの判定
- hid_scan_report? - Scan a report descriptor before the device is added to the bus.
hid-multitouch
- drivers/hid/hid-multitouch.c
- module_hid_driver(mt_driver);
static struct hid_driver mt_driver = { .name = "hid-multitouch", .id_table = mt_devices, .probe = mt_probe, .remove = mt_remove, .input_mapping = mt_input_mapping, .input_mapped = mt_input_mapped, .input_configured = mt_input_configured, .feature_mapping = mt_feature_mapping, .usage_table = mt_grabbed_usages, .event = mt_event, .report = mt_report, #ifdef CONFIG_PM .reset_resume = mt_reset_resume, .resume = mt_resume, #endif };
- module_driver(mt_driver, hid_register_driver, hid_unregister_driver?)
- driver_register(mt_driver->driver)
- driver_create_file
- module_driver(mt_driver, hid_register_driver, hid_unregister_driver?)
hid_driver.probe = mt_probe?()
- hidのhid_match_deviceから呼ばれる
- devm_kzalloc?
- hid_set_drvdata?
- hid_parse
- hid_hw_start
- sysfs_create_group
API
hidraw
- /dev/hidraw raw HID device support
- Linux/dev/hidrawXを通してHIDデバイスを読み書き
- CONFIG_HIDRAW - Linux 2.6.24?~
- In comparison to hiddev, this device does not process the hid events at all (no parsing, no lookups)
hiddev
- /dev/hiddev raw HID device support
- CONFIG_USB_HIDDEV - Linux 2.6.22?~
- Linux/dev/usb/hiddev?
- drivers/hid/usbhid/hiddev.c?
UHID
- User-space I/O driver support for HID subsystem
- HIDのトランスポートレイヤを実装するためのドライバ。
- drivers/hid/uhid.c
ドライバ
hid_ll_driver - low level driver callbacks
- usb_hid_driver - USB/HID
- hidp_hid_driver? - Bluetooth/HID
- i2c_hid_ll_driver? - I2C/HID
- uhid_hid_driver? - UHID
- mousevsc_ll_driver? - Hyper-V
- logi_dj_ll_driver?
usb_class_driver
- hiddev_class? - hiddev%d
usb_driver
hid
- drivers/hid/hid.ko?
- drivers/hid/hid-input.c - HID to Linux Input mapping
- hid-core.ko?
hid_generic?
mac_hid?
- drivers/macintosh/mac_hid.ko?
g_hid
- drivers/gadget/g_hid.ko?
Bluetooth
- net/bluetooth/hidp/hidp.ko?