diff --git a/apps/gui/skin_engine/skin_tokens.c b/apps/gui/skin_engine/skin_tokens.c index e58393e19c..934085c707 100644 --- a/apps/gui/skin_engine/skin_tokens.c +++ b/apps/gui/skin_engine/skin_tokens.c @@ -1149,12 +1149,10 @@ const char *get_token_value(struct gui_wps *gwps, } } #endif -#ifdef HAVE_USB_POWER - case SKIN_TOKEN_USB_POWERED: - if (usb_powered()) + case SKIN_TOKEN_USB_INSERTED: + if (usb_inserted()) return "u"; return NULL; -#endif case SKIN_TOKEN_BATTERY_SLEEPTIME: { if (get_sleep_timer() == 0) diff --git a/apps/main.c b/apps/main.c index 60164515fa..211f7f1b3c 100644 --- a/apps/main.c +++ b/apps/main.c @@ -586,7 +586,8 @@ static void init(void) mounted = true; /* mounting done @ end of USB mode */ } #ifdef HAVE_USB_POWER - if (usb_powered()) /* avoid deadlock */ + /* if there is no host or user requested no USB, skip this */ + if (usb_powered_only()) break; #endif } diff --git a/apps/plugin.c b/apps/plugin.c index 8a6c577f69..c6b9744ed4 100644 --- a/apps/plugin.c +++ b/apps/plugin.c @@ -712,9 +712,7 @@ static const struct plugin_api rockbox_api = { charging_state, # endif #endif -#ifdef HAVE_USB_POWER - usb_powered, -#endif + usb_inserted, /* misc */ #if (CONFIG_PLATFORM & PLATFORM_NATIVE) diff --git a/apps/plugin.h b/apps/plugin.h index e55dcf13cb..f781f60350 100644 --- a/apps/plugin.h +++ b/apps/plugin.h @@ -160,12 +160,12 @@ void* plugin_get_buffer(size_t *buffer_size); #define PLUGIN_MAGIC 0x526F634B /* RocK */ /* increase this every time the api struct changes */ -#define PLUGIN_API_VERSION 232 +#define PLUGIN_API_VERSION 233 /* update this to latest version if a change to the api struct breaks backwards compatibility (and please take the opportunity to sort in any new function which are "waiting" at the end of the function table) */ -#define PLUGIN_MIN_API_VERSION 232 +#define PLUGIN_MIN_API_VERSION 233 /* plugin return codes */ /* internal returns start at 0x100 to make exit(1..255) work */ @@ -823,9 +823,8 @@ struct plugin_api { bool (*charging_state)(void); # endif #endif -#ifdef HAVE_USB_POWER - bool (*usb_powered)(void); -#endif + /* usb */ + bool (*usb_inserted)(void); /* misc */ #if (CONFIG_PLATFORM & PLATFORM_NATIVE) diff --git a/apps/plugins/battery_bench.c b/apps/plugins/battery_bench.c index b0976d5e10..289b399e27 100644 --- a/apps/plugins/battery_bench.c +++ b/apps/plugins/battery_bench.c @@ -358,11 +358,12 @@ static unsigned int charge_state(void) ret |= BIT_CHARGING; #endif #endif + /* USB insertion means nothing if USB cannot power the device */ #ifdef HAVE_USB_POWER - if (rb->usb_powered()) + if (rb->usb_inserted()) ret |= BIT_USB_POWER; #endif - return ret; + return ret; } #endif diff --git a/firmware/export/usb.h b/firmware/export/usb.h index 62bcffe666..74c4826006 100644 --- a/firmware/export/usb.h +++ b/firmware/export/usb.h @@ -199,7 +199,8 @@ int usb_detect(void); void usb_status_event(int current_status); #endif #ifdef HAVE_USB_POWER -bool usb_powered(void); +/* returns whether the USB is in powered-only state */ +bool usb_powered_only(void); #ifdef HAVE_USB_CHARGING_ENABLE enum { USB_CHARGING_DISABLE, /* the USB code will never ask for more than 100mA */ diff --git a/firmware/powermgmt.c b/firmware/powermgmt.c index a4b260b315..61cf1b34c4 100644 --- a/firmware/powermgmt.c +++ b/firmware/powermgmt.c @@ -329,9 +329,9 @@ static int runcurrent(void) if (usb_inserted() #ifdef HAVE_USB_POWER #if (CURRENT_USB < CURRENT_NORMAL) - || usb_powered() + || usb_powered_only() #else - && !usb_powered() + && !usb_powered_only() #endif #endif ) { diff --git a/firmware/usb.c b/firmware/usb.c index fc89df709c..a736f31ca5 100644 --- a/firmware/usb.c +++ b/firmware/usb.c @@ -769,7 +769,7 @@ int usb_release_exclusive_storage(void) } #ifdef HAVE_USB_POWER -bool usb_powered(void) +bool usb_powered_only(void) { return usb_state == USB_POWERED; } diff --git a/lib/skin_parser/tag_table.c b/lib/skin_parser/tag_table.c index 2cea048548..d2aded1b12 100644 --- a/lib/skin_parser/tag_table.c +++ b/lib/skin_parser/tag_table.c @@ -43,7 +43,7 @@ static const struct tag_info legal_tags[] = { SKIN_TOKEN_BATTERY_SLEEPTIME, "bs", "", SKIN_REFRESH_DYNAMIC }, { SKIN_TOKEN_BATTERY_CHARGING, "bc", "", SKIN_REFRESH_DYNAMIC }, { SKIN_TOKEN_BATTERY_CHARGER_CONNECTED, "bp", "", SKIN_REFRESH_DYNAMIC }, - { SKIN_TOKEN_USB_POWERED, "bu", "", SKIN_REFRESH_DYNAMIC }, + { SKIN_TOKEN_USB_INSERTED, "bu", "", SKIN_REFRESH_DYNAMIC }, { SKIN_TOKEN_RTC_PRESENT, "cc", "", FEATURE_TAG }, diff --git a/lib/skin_parser/tag_table.h b/lib/skin_parser/tag_table.h index 94f82fd759..dc0c11f0ad 100644 --- a/lib/skin_parser/tag_table.h +++ b/lib/skin_parser/tag_table.h @@ -102,7 +102,7 @@ enum skin_token_type { SKIN_TOKEN_BATTERY_CHARGER_CONNECTED, SKIN_TOKEN_BATTERY_CHARGING, SKIN_TOKEN_BATTERY_SLEEPTIME, - SKIN_TOKEN_USB_POWERED, + SKIN_TOKEN_USB_INSERTED, /* Sound */ SKIN_TOKEN_SOUND_PITCH, diff --git a/uisimulator/common/stubs.c b/uisimulator/common/stubs.c index 922b9e8da0..b540735904 100644 --- a/uisimulator/common/stubs.c +++ b/uisimulator/common/stubs.c @@ -313,7 +313,7 @@ bool is_new_player(void) #endif #ifdef HAVE_USB_POWER -bool usb_powered(void) +bool usb_powered_only(void) { return false; }