Page MenuHomeFreeBSD

hid: Create hardware abstraction and hidbus

Authored by wulf on Jan 2 2021, 11:50 AM.



This is a core part of all proposed HID changes.

It introduces layered model and it`'s interfaces.
In the new HID world drivers are stcked in following order:

Front drivers (mouse, kbd, e.t.c.)
Transport backend (usbhid, iichid, ...?)
Transport bus (usbus, iicbus, ...?)

hidbus(4) itself provides support for multiple front HID driver attachments
to single HID transport backend. This ability existed in Net/OpenBSD
(uhidev and ihidev drivers) but has never been ported to FreeBSD.
Unlike Net/OpenBSD we do not use report number alone to
distinct report source but we follow MS way and use a top level
collection (TLC) usage index that report belongs to as a location key.

The driver performs child device autodiscovery based on HID report
descriptor data, proxying of HID requests from child devices to parent
transport backends and broadcasting of interrupts in backward direction.

Also this changes create an abstract HID interface that provides hardware independent
access to HID capabilities and functions through the device tree.

hid_if.m resembles existing USBHID KPI and consist of next methods:

HID method              USBHID variant
hid_intr_setup          usbd_transfer_setup   (INTERRUPT IN xfer)
hid_intr_unsetup        usbd_transfer_unsetup (INTERRUPT IN xfer)
hid_intr_start          usbd_transfer_start   (INTERRUPT IN xfer)
hid_intr_stop           usbd_transfer_stop    (INTERRUPT IN xfer)
hid_intr_poll           usbd_transfer_poll    (INTERRUPT IN xfer)

hid_get_rdesc           usbd_req_get_report_descriptor
hid_read                No direct analog. Not intended for common use.
hid_write               uhid(4) write()
hid_get_report          usbd_req_get_report
hid_set_report          usbd_req_set_report
hid_set_idle            usbd_req_set_idle
hid_set_protocol        usbd_req_set_protocol

The revision is subset of

Diff Detail

R10 FreeBSD src repository
Automatic diff as part of commit; lint not applicable.
Automatic diff as part of commit; unit tests not applicable.

Event Timeline

wulf requested review of this revision.Jan 2 2021, 11:50 AM
wulf created this revision.
This revision was not accepted when it landed; it landed in state Needs Review.Jan 7 2021, 11:22 PM
Closed by commit R10:2b4464b0b114: hid: Import hidbus(4) (authored by wulf). · Explain Why
This revision was automatically updated to reflect the committed changes.