From d2b76a99f340ff59639cc49ca6e50dc2a087769d Mon Sep 17 00:00:00 2001 From: mojyack Date: Fri, 19 Dec 2025 16:59:43 +0900 Subject: [PATCH] usb: introduce batched request api in order to implement iap digital audio interface, we have to send a pcm packet every usb frame i.e. 1000 packets per second. this rate can't be achieved with current standard request-response design, even with fast_completion_handler. this is why this new api is needed. Change-Id: Id3d7dd037660871e2bdb69656f63ff13280c3804 --- firmware/export/usb_drv.h | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/firmware/export/usb_drv.h b/firmware/export/usb_drv.h index ea048a3cd1..76cba9d82b 100644 --- a/firmware/export/usb_drv.h +++ b/firmware/export/usb_drv.h @@ -109,6 +109,27 @@ int usb_drv_deinit_endpoint(int endpoint); int usb_drv_get_frame_number(void); #endif +#if USB_BATCH_SLOTS > 0 + +/* batched request api is for workloads that perform very high-frequency, + * performance-sensitive isochronous transactions continuously. + * this api allows multiple transaction requests to be buffered in udc driver. + * so that it can maximize the controller's performance. */ + +/* called when usb system requires more buffer */ +typedef void(*usb_drv_batch_get_more)(const void** ptr, size_t* len); + +/* prepare request queue */ +int usb_drv_batch_init(int ep, usb_drv_batch_get_more get_more); +/* destroy request queue */ +int usb_drv_batch_deinit(void); +/* start processing */ +int usb_drv_batch_start(void); +/* stop processing */ +int usb_drv_batch_stop(void); + +#endif + /* USB_STRING_INITIALIZER(u"Example String") */ #define USB_STRING_INITIALIZER(S) { \ sizeof(struct usb_string_descriptor) + sizeof(S) - sizeof(*S), \