Clarify usb_powered() and fix some code.
Either by mistake or because its meaning changed, usb_powered() doesn't mean what the name suggest, so clarify its meaning by renaming it to usb_powered_only. So use of usb_powered() are replaced by usb_inserted() when it makes more sense. Change-Id: I112887e2d8560e84587bee5f55c826dde8c806d8 Reviewed-on: http://gerrit.rockbox.org/1097 Reviewed-by: Amaury Pouly <amaury.pouly@gmail.com>
This commit is contained in:
parent
1ab91550e6
commit
dc127f213c
|
@ -1149,12 +1149,10 @@ const char *get_token_value(struct gui_wps *gwps,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
#ifdef HAVE_USB_POWER
|
case SKIN_TOKEN_USB_INSERTED:
|
||||||
case SKIN_TOKEN_USB_POWERED:
|
if (usb_inserted())
|
||||||
if (usb_powered())
|
|
||||||
return "u";
|
return "u";
|
||||||
return NULL;
|
return NULL;
|
||||||
#endif
|
|
||||||
case SKIN_TOKEN_BATTERY_SLEEPTIME:
|
case SKIN_TOKEN_BATTERY_SLEEPTIME:
|
||||||
{
|
{
|
||||||
if (get_sleep_timer() == 0)
|
if (get_sleep_timer() == 0)
|
||||||
|
|
|
@ -586,7 +586,8 @@ static void init(void)
|
||||||
mounted = true; /* mounting done @ end of USB mode */
|
mounted = true; /* mounting done @ end of USB mode */
|
||||||
}
|
}
|
||||||
#ifdef HAVE_USB_POWER
|
#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;
|
break;
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
|
@ -712,9 +712,7 @@ static const struct plugin_api rockbox_api = {
|
||||||
charging_state,
|
charging_state,
|
||||||
# endif
|
# endif
|
||||||
#endif
|
#endif
|
||||||
#ifdef HAVE_USB_POWER
|
usb_inserted,
|
||||||
usb_powered,
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/* misc */
|
/* misc */
|
||||||
#if (CONFIG_PLATFORM & PLATFORM_NATIVE)
|
#if (CONFIG_PLATFORM & PLATFORM_NATIVE)
|
||||||
|
|
|
@ -160,12 +160,12 @@ void* plugin_get_buffer(size_t *buffer_size);
|
||||||
#define PLUGIN_MAGIC 0x526F634B /* RocK */
|
#define PLUGIN_MAGIC 0x526F634B /* RocK */
|
||||||
|
|
||||||
/* increase this every time the api struct changes */
|
/* 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
|
/* update this to latest version if a change to the api struct breaks
|
||||||
backwards compatibility (and please take the opportunity to sort in any
|
backwards compatibility (and please take the opportunity to sort in any
|
||||||
new function which are "waiting" at the end of the function table) */
|
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 */
|
/* plugin return codes */
|
||||||
/* internal returns start at 0x100 to make exit(1..255) work */
|
/* internal returns start at 0x100 to make exit(1..255) work */
|
||||||
|
@ -823,9 +823,8 @@ struct plugin_api {
|
||||||
bool (*charging_state)(void);
|
bool (*charging_state)(void);
|
||||||
# endif
|
# endif
|
||||||
#endif
|
#endif
|
||||||
#ifdef HAVE_USB_POWER
|
/* usb */
|
||||||
bool (*usb_powered)(void);
|
bool (*usb_inserted)(void);
|
||||||
#endif
|
|
||||||
|
|
||||||
/* misc */
|
/* misc */
|
||||||
#if (CONFIG_PLATFORM & PLATFORM_NATIVE)
|
#if (CONFIG_PLATFORM & PLATFORM_NATIVE)
|
||||||
|
|
|
@ -358,11 +358,12 @@ static unsigned int charge_state(void)
|
||||||
ret |= BIT_CHARGING;
|
ret |= BIT_CHARGING;
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
/* USB insertion means nothing if USB cannot power the device */
|
||||||
#ifdef HAVE_USB_POWER
|
#ifdef HAVE_USB_POWER
|
||||||
if (rb->usb_powered())
|
if (rb->usb_inserted())
|
||||||
ret |= BIT_USB_POWER;
|
ret |= BIT_USB_POWER;
|
||||||
#endif
|
#endif
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
|
@ -199,7 +199,8 @@ int usb_detect(void);
|
||||||
void usb_status_event(int current_status);
|
void usb_status_event(int current_status);
|
||||||
#endif
|
#endif
|
||||||
#ifdef HAVE_USB_POWER
|
#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
|
#ifdef HAVE_USB_CHARGING_ENABLE
|
||||||
enum {
|
enum {
|
||||||
USB_CHARGING_DISABLE, /* the USB code will never ask for more than 100mA */
|
USB_CHARGING_DISABLE, /* the USB code will never ask for more than 100mA */
|
||||||
|
|
|
@ -329,9 +329,9 @@ static int runcurrent(void)
|
||||||
if (usb_inserted()
|
if (usb_inserted()
|
||||||
#ifdef HAVE_USB_POWER
|
#ifdef HAVE_USB_POWER
|
||||||
#if (CURRENT_USB < CURRENT_NORMAL)
|
#if (CURRENT_USB < CURRENT_NORMAL)
|
||||||
|| usb_powered()
|
|| usb_powered_only()
|
||||||
#else
|
#else
|
||||||
&& !usb_powered()
|
&& !usb_powered_only()
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
) {
|
) {
|
||||||
|
|
|
@ -769,7 +769,7 @@ int usb_release_exclusive_storage(void)
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef HAVE_USB_POWER
|
#ifdef HAVE_USB_POWER
|
||||||
bool usb_powered(void)
|
bool usb_powered_only(void)
|
||||||
{
|
{
|
||||||
return usb_state == USB_POWERED;
|
return usb_state == USB_POWERED;
|
||||||
}
|
}
|
||||||
|
|
|
@ -43,7 +43,7 @@ static const struct tag_info legal_tags[] =
|
||||||
{ SKIN_TOKEN_BATTERY_SLEEPTIME, "bs", "", SKIN_REFRESH_DYNAMIC },
|
{ SKIN_TOKEN_BATTERY_SLEEPTIME, "bs", "", SKIN_REFRESH_DYNAMIC },
|
||||||
{ SKIN_TOKEN_BATTERY_CHARGING, "bc", "", SKIN_REFRESH_DYNAMIC },
|
{ SKIN_TOKEN_BATTERY_CHARGING, "bc", "", SKIN_REFRESH_DYNAMIC },
|
||||||
{ SKIN_TOKEN_BATTERY_CHARGER_CONNECTED, "bp", "", 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 },
|
{ SKIN_TOKEN_RTC_PRESENT, "cc", "", FEATURE_TAG },
|
||||||
|
|
|
@ -102,7 +102,7 @@ enum skin_token_type {
|
||||||
SKIN_TOKEN_BATTERY_CHARGER_CONNECTED,
|
SKIN_TOKEN_BATTERY_CHARGER_CONNECTED,
|
||||||
SKIN_TOKEN_BATTERY_CHARGING,
|
SKIN_TOKEN_BATTERY_CHARGING,
|
||||||
SKIN_TOKEN_BATTERY_SLEEPTIME,
|
SKIN_TOKEN_BATTERY_SLEEPTIME,
|
||||||
SKIN_TOKEN_USB_POWERED,
|
SKIN_TOKEN_USB_INSERTED,
|
||||||
|
|
||||||
/* Sound */
|
/* Sound */
|
||||||
SKIN_TOKEN_SOUND_PITCH,
|
SKIN_TOKEN_SOUND_PITCH,
|
||||||
|
|
|
@ -313,7 +313,7 @@ bool is_new_player(void)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef HAVE_USB_POWER
|
#ifdef HAVE_USB_POWER
|
||||||
bool usb_powered(void)
|
bool usb_powered_only(void)
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue