Skip to content

Commit c705551

Browse files
tmon-nordickartben
authored andcommitted
usb: device_next: hid: Pass request buffer in input report done
Pass the report buffer originally provided in hid_device_submit_report() as a parameter to input_report_done() callback. Example use case is to enable HID report multi buffering which is easiest achieved by allocating report buffer before submitting it and then releasing the buffer after it has been sent. Signed-off-by: Tomasz Moń <[email protected]>
1 parent 263ddc2 commit c705551

File tree

3 files changed

+8
-4
lines changed

3 files changed

+8
-4
lines changed

include/zephyr/usb/class/usbd_hid.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ extern "C" {
2525
* @defgroup usbd_hid_device USBD HID device API
2626
* @ingroup usb
2727
* @since 3.7
28-
* @version 0.1.0
28+
* @version 0.1.1
2929
* @{
3030
*/
3131

@@ -159,7 +159,8 @@ struct hid_device_ops {
159159
* If the device does not use the callback, hid_device_submit_report()
160160
* will be processed synchronously.
161161
*/
162-
void (*input_report_done)(const struct device *dev);
162+
void (*input_report_done)(const struct device *dev,
163+
const uint8_t *const report);
163164

164165
/**
165166
* New output report callback. Callback will only be called for reports

subsys/usb/device_next/class/usbd_hid.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ static int usbd_hid_request(struct usbd_class_data *const c_data,
122122

123123
if (bi->ep == hid_get_in_ep(c_data)) {
124124
if (ops->input_report_done != NULL) {
125-
ops->input_report_done(dev);
125+
ops->input_report_done(dev, buf->__buf);
126126
} else {
127127
k_sem_give(&ddata->in_sem);
128128
}

subsys/usb/device_next/class/usbd_hid_api.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,8 +129,11 @@ void wrapper_set_protocol(const struct device *dev, const uint8_t proto)
129129
}
130130
}
131131

132-
void wrapper_input_report_done(const struct device *dev)
132+
void wrapper_input_report_done(const struct device *dev,
133+
const uint8_t *const report)
133134
{
135+
ARG_UNUSED(report);
136+
134137
const struct hid_ops *legacy_ops = get_legacy_ops(dev);
135138

136139
if (legacy_ops != NULL && legacy_ops->int_in_ready != NULL) {

0 commit comments

Comments
 (0)