usb: enable cpu boost for specific class drivers
rockbox-gerrit-noreply--- via rockbox-cvs <[email protected]> Mon, 4 May 2026 07:15:42 -0400
| Newsgroups | gmane.comp.systems.archos.rockbox.cvs |
|---|---|
| Message-ID | <[email protected]> |
commit bbdada76900bf76adbc12d7751bc318dfeb48207 Author: mojyack <[email protected]> Date: Fri Dec 19 22:45:47 2025 +0900 usb: enable cpu boost for specific class drivers add needs_cpu_boost field to usb_class_driver and manage boost state in usb_core, similar to needs_exclusive_storage. Change-Id: Ieb0cd7bedda5b24bb0d209d5ce907db30f4815db diff --git a/firmware/usb.c b/firmware/usb.c index ae9778c299..406a635140 100644 --- a/firmware/usb.c +++ b/firmware/usb.c @@ -266,23 +266,14 @@ static inline void usb_slave_mode(bool on) if(on) { - trigger_cpu_boost(); -#ifdef HAVE_PRIORITY_SCHEDULING - thread_set_priority(thread_self(), PRIORITY_REALTIME); -#endif disk_unmount_all(); } else { -#ifdef HAVE_PRIORITY_SCHEDULING - thread_set_priority(thread_self(), PRIORITY_SYSTEM); -#endif /* Entered exclusive mode */ rc = disk_mount_all(); if(rc <= 0) /* no partition */ panicf("mount: %d",rc); - - cancel_cpu_boost(); } } diff --git a/firmware/usbstack/usb_audio.c b/firmware/usbstack/usb_audio.c index fad3d12b8c..aceb3bf5a5 100644 --- a/firmware/usbstack/usb_audio.c +++ b/firmware/usbstack/usb_audio.c @@ -1497,6 +1497,7 @@ static bool usb_audio_fast_transfer_complete(int ep, int dir, int status, int le struct usb_class_driver usb_cdrv_audio = { .needs_exclusive_storage = false, + .needs_cpu_boost = false, .config = 1, .ep_allocs_size = ARRAYLEN(ep_allocs), .ep_allocs = ep_allocs, diff --git a/firmware/usbstack/usb_charging_only.c b/firmware/usbstack/usb_charging_only.c index 23d285923c..66683593db 100644 --- a/firmware/usbstack/usb_charging_only.c +++ b/firmware/usbstack/usb_charging_only.c @@ -65,6 +65,7 @@ static int usb_charging_only_get_config_descriptor(unsigned char *dest,int max_p struct usb_class_driver usb_cdrv_charging_only = { .needs_exclusive_storage = false, + .needs_cpu_boost = false, .config = 1, .set_first_interface = usb_charging_only_set_first_interface, .get_config_descriptor = usb_charging_only_get_config_descriptor, diff --git a/firmware/usbstack/usb_class_driver.h b/firmware/usbstack/usb_class_driver.h index 5d63ce0b89..a48d19ac62 100644 --- a/firmware/usbstack/usb_class_driver.h +++ b/firmware/usbstack/usb_class_driver.h @@ -54,6 +54,9 @@ struct usb_class_driver { /* Set this to true if the driver needs exclusive disk access (e.g. usb storage) */ bool needs_exclusive_storage; + /* Set this to true if the driver needs to enable cpu boost */ + bool needs_cpu_boost; + /* USB config number this driver belongs to */ uint8_t config; diff --git a/firmware/usbstack/usb_core.c b/firmware/usbstack/usb_core.c index 814d502242..8b7e4510fd 100644 --- a/firmware/usbstack/usb_core.c +++ b/firmware/usbstack/usb_core.c @@ -823,6 +823,11 @@ static void usb_core_do_set_addr(uint8_t address) usb_state = ADDRESS; } +#if !defined(HAVE_PRIORITY_SCHEDULING) +#define thread_set_priority(...) +#define thread_get_priority(...) +#endif /* HAVE_PRIORITY_SCHEDULING */ + static int usb_core_do_set_config(uint8_t new_config) { logf("usb_core: SET_CONFIG %d to %d", usb_config, new_config); @@ -852,6 +857,7 @@ static int usb_core_do_set_config(uint8_t new_config) usb_state = usb_config == 0 ? ADDRESS : CONFIGURED; bool require_exclusive = false; + bool require_cpu_boost = false; /* activate new config */ if(usb_config != 0) { @@ -865,6 +871,7 @@ static int usb_core_do_set_config(uint8_t new_config) continue; } require_exclusive |= drivers[i]->needs_exclusive_storage; + require_cpu_boost |= drivers[i]->needs_cpu_boost; } } @@ -876,6 +883,13 @@ static int usb_core_do_set_config(uint8_t new_config) } else { usb_release_exclusive_storage(); } + if(require_cpu_boost) { + trigger_cpu_boost(); + thread_set_priority(thread_self(), PRIORITY_REALTIME); + } else { + thread_set_priority(thread_self(), PRIORITY_SYSTEM); + cancel_cpu_boost(); + } #ifdef HAVE_USB_CHARGING_ENABLE usb_charging_maxcurrent_change(usb_charging_maxcurrent()); diff --git a/firmware/usbstack/usb_hid.c b/firmware/usbstack/usb_hid.c index ac06691df4..fef3ef45aa 100644 --- a/firmware/usbstack/usb_hid.c +++ b/firmware/usbstack/usb_hid.c @@ -832,6 +832,7 @@ void usb_hid_send(usage_page_t usage_page, int id) struct usb_class_driver usb_cdrv_hid = { .needs_exclusive_storage = false, + .needs_cpu_boost = false, .config = 1, .ep_allocs_size = ARRAYLEN(ep_allocs), .ep_allocs = ep_allocs, diff --git a/firmware/usbstack/usb_iap.c b/firmware/usbstack/usb_iap.c index 2d6d3d3022..df847fc8ad 100644 --- a/firmware/usbstack/usb_iap.c +++ b/firmware/usbstack/usb_iap.c @@ -692,6 +692,7 @@ static void usb_iap_notify_event(intptr_t data) { struct usb_class_driver usb_cdrv_iap = { .needs_exclusive_storage = false, + .needs_cpu_boost = true, .config = 2, .ep_allocs_size = ARRAYLEN(usb_iap_ep_allocs), .ep_allocs = usb_iap_ep_allocs, diff --git a/firmware/usbstack/usb_serial.c b/firmware/usbstack/usb_serial.c index 5490d1db11..d23df7f19b 100644 --- a/firmware/usbstack/usb_serial.c +++ b/firmware/usbstack/usb_serial.c @@ -445,6 +445,7 @@ static void usb_serial_transfer_complete(int ep,int dir, int status, int length) struct usb_class_driver usb_cdrv_serial = { .needs_exclusive_storage = false, + .needs_cpu_boost = false, .config = 1, .ep_allocs_size = ARRAYLEN(ep_allocs), .ep_allocs = ep_allocs, diff --git a/firmware/usbstack/usb_storage.c b/firmware/usbstack/usb_storage.c index c4bdbf9841..055668a56f 100644 --- a/firmware/usbstack/usb_storage.c +++ b/firmware/usbstack/usb_storage.c @@ -1483,6 +1483,7 @@ static void fill_inquiry(IF_MD_NONVOID(int lun)) struct usb_class_driver usb_cdrv_storage = { .needs_exclusive_storage = true, + .needs_cpu_boost = true, .config = 1, .ep_allocs_size = ARRAYLEN(ep_allocs), .ep_allocs = ep_allocs, -- rockbox-cvs mailing list [email protected] https://lists.haxx.se/mailman/listinfo/rockbox-cvs