-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
applications: nrf_desktop: Add HID reportq documentation
Change introduces documentation for the HID report queue utility. Jira: NCSDK-28433 Signed-off-by: Marek Pieta <[email protected]>
- Loading branch information
1 parent
d2c76f9
commit 3583488
Showing
4 changed files
with
90 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
.. _nrf_desktop_hid_reportq: | ||
|
||
HID report queue utility | ||
######################## | ||
|
||
.. contents:: | ||
:local: | ||
:depth: 2 | ||
|
||
A HID subscriber (for example an USB HID class instance handled by :ref:`nrf_desktop_usb_state`) limits maximum number of HID input reports that can be handled simultaneously. | ||
Enqueuing reports locally at the source may be necessary to prevent HID report drops. | ||
The HID report queue utility can be used by an application module to simplify enqueuing HID input reports received from connected HID peripherals before providing them to HID subscriber. | ||
|
||
Configuration | ||
************* | ||
|
||
Make sure that heap size (:kconfig:option:`CONFIG_HEAP_MEM_POOL_SIZE`) is big enough. | ||
Data structures used to enqueue HID reports are dynamically allocated using :c:func:`k_malloc`. | ||
When no longer needed, the structured are freed using :c:func:`k_free`. | ||
|
||
Use the :ref:`CONFIG_DESKTOP_HID_REPORTQ <config_desktop_app_options>` Kconfig option to enable the utility. | ||
The utility can be used only on HID dongles (:ref:`CONFIG_DESKTOP_ROLE_HID_DONGLE <config_desktop_app_options>`). | ||
|
||
You can also configure the following properties: | ||
|
||
* Maximum number of enqueued HID reports (:ref:`CONFIG_DESKTOP_HID_REPORTQ_MAX_ENQUEUED_REPORTS <config_desktop_app_options>`) | ||
* Number of supported HID report queues (:ref:`CONFIG_DESKTOP_HID_REPORTQ_QUEUE_COUNT <config_desktop_app_options>`) | ||
|
||
See Kconfig help for more details. | ||
|
||
Using HID report queue | ||
********************** | ||
|
||
The utility acts as a middleware between a connected HID peripheral and a HID subscriber. | ||
The following sections describe how to integrate HID report queue APIs in an application module. | ||
|
||
The :ref:`nrf_desktop_hid_forward` is an example of application module that uses the HID report queue utility. | ||
Refer to the module's implementation (:file:`src/modules/hid_forward.c`) for an example of HID report queue integration. | ||
|
||
Allocation | ||
========== | ||
|
||
HID report queue instance must be allocated with :c:func:`hid_reportq_alloc` before it's used. | ||
A separate HID report queue object needs to be allocated per HID report subscriber. | ||
During allocation, the caller specifies the HID subscriber identifier. | ||
The :c:func:`hid_reportq_get_sub_id` can be used to access the identifier later. | ||
After the HID report queue object is no longer used, it should be freed with :c:func:`hid_reportq_free`. | ||
|
||
HID subscriptions | ||
================= | ||
|
||
A HID report queue instance tracks HID input report subscriptions enabled by a HID subscriber. | ||
The :c:func:`hid_reportq_subscribe` and :c:func:`hid_reportq_unsubscribe` functions can be used to update state of enabled subscriptions. | ||
The functions should be called while handling an :c:struct:`hid_report_subscription_event`. | ||
The :c:func:`hid_reportq_is_subscribed` function can be used to check if subscription is enabled for the specified HID input report. | ||
|
||
Enqueuing HID input reports | ||
=========================== | ||
|
||
An application module can call :c:func:`hid_reportq_report_add` for a received HID input report to enqueue the report. | ||
The function allocates a :c:struct:`hid_report_event` for the received HID input report. | ||
If HID subscriber can handle the :c:struct:`hid_report_event`, the event is instantly passed to the subscriber. | ||
Otherwise the event is enqueued and will be submitted later. | ||
|
||
When HID subscriber (for example an USB HID class instance) delivers a HID input report to the HID host (on :c:struct:`hid_report_sent_event`), the :c:struct:`hid_reportq_report_sent` API needs to be called to notify the HID report queue. | ||
This allows the queue to track state of HID reports provided to the HID subscriber. | ||
If there is an enqueued report, the HID report queue object will instantly submit the subsequent :c:struct:`hid_report_event`. | ||
The enqueued report to be sent is chosen in the round-robin fashion. | ||
|
||
API documentation | ||
***************** | ||
|
||
Application modules can use the following API of the HID report queue: | ||
|
||
| Header file: :file:`applications/nrf_desktop/src/util/hid_reportq.h` | ||
| Source file: :file:`applications/nrf_desktop/src/util/hid_reportq.c` | ||
.. doxygengroup:: hid_reportq |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters