Rockbox open source high quality audio player as a Music Player Daemon
mpris rockbox mpd libadwaita audio rust zig deno
2
fork

Configure Feed

Select the types of activity you want to include in your feed.

usb: do not call usb_core_do_set_config(0) inside bus reset isr

Change-Id: Ic06719ef92cd1fae42c7155ab72029466826a59b

mojyack e3bb8038 6db1e937

+29 -12
+1
firmware/export/usb.h
··· 118 118 USB_TRANSFER_COMPLETION, /* Event */ 119 119 USB_NOTIFY_SET_ADDR, /* Event */ 120 120 USB_NOTIFY_SET_CONFIG, /* Event */ 121 + USB_NOTIFY_BUS_RESET, /* Event */ 121 122 #endif 122 123 #ifdef USB_FIREWIRE_HANDLING 123 124 USB_REQUEST_REBOOT, /* Event */
+1
firmware/usb.c
··· 477 477 #ifdef HAVE_USBSTACK 478 478 case USB_NOTIFY_SET_ADDR: 479 479 case USB_NOTIFY_SET_CONFIG: 480 + case USB_NOTIFY_BUS_RESET: 480 481 if(usb_state <= USB_EXTRACTED) 481 482 break; 482 483 usb_core_handle_notify(ev.id, ev.data);
+27 -12
firmware/usbstack/usb_core.c
··· 153 153 static int usb_address = 0; 154 154 static int usb_config = 0; 155 155 static bool initialized = false; 156 + static volatile bool bus_reset_pending = false; 156 157 static enum { DEFAULT, ADDRESS, CONFIGURED } usb_state; 157 158 158 159 #ifdef HAVE_USB_CHARGING_ENABLE ··· 1094 1095 } 1095 1096 } 1096 1097 1098 + static void do_bus_reset(void) { 1099 + usb_address = 0; 1100 + usb_state = DEFAULT; 1101 + #ifdef USB_LEGACY_CONTROL_API 1102 + num_active_requests = 0; 1103 + #endif 1104 + bus_reset_pending = false; 1105 + } 1106 + 1097 1107 /* called by usb_drv_int() */ 1098 1108 void usb_core_bus_reset(void) 1099 1109 { 1100 1110 logf("usb_core: bus reset"); 1101 - usb_core_do_set_config(0); 1102 - usb_address = 0; 1103 - usb_state = DEFAULT; 1104 - #ifdef HAVE_USB_CHARGING_ENABLE 1105 - #ifdef HAVE_USB_CHARGING_IN_THREAD 1106 - /* On some targets usb_charging_maxcurrent_change() cannot be called 1107 - * from an interrupt handler; get the USB thread to do it instead. */ 1108 - usb_charger_update(); 1109 - #else 1110 - usb_charging_maxcurrent_change(usb_charging_maxcurrent()); 1111 - #endif 1112 - #endif 1111 + if(bus_reset_pending) { 1112 + return; 1113 + } 1114 + bus_reset_pending = true; 1115 + if(usb_config == 0) { 1116 + do_bus_reset(); 1117 + } else { 1118 + /* need to disconnect class drivers, defer it to usb thread */ 1119 + usb_signal_notify(USB_NOTIFY_BUS_RESET, 0); 1120 + } 1113 1121 } 1114 1122 1115 1123 /* called by usb_drv_transfer_completed() */ ··· 1158 1166 break; 1159 1167 case USB_NOTIFY_SET_CONFIG: 1160 1168 usb_core_do_set_config(data); 1169 + break; 1170 + case USB_NOTIFY_BUS_RESET: 1171 + usb_core_do_set_config(0); 1172 + do_bus_reset(); 1173 + #ifdef HAVE_USB_CHARGING_ENABLE 1174 + usb_charging_maxcurrent_change(usb_charging_maxcurrent()); 1175 + #endif 1161 1176 break; 1162 1177 default: 1163 1178 break;