mirror of
https://github.com/Rockbox/rockbox.git
synced 2025-10-14 02:27:39 -04:00
ibasso: Use correct API to query power input and charging state
Instead of using the generic hosted sysfs code, which expects a full path, the ibasso code's sysfs code uses an enumeration. Unfortunatley the generic power input/charging code used the former API but linked with the latter. oops. Correct this by placing a private copy of these functions in the ibasso-specific port, and removing the generic version from that build. (A "proper" fix would be to rework all 17 of the ibasso sysfs calls to use the generic sysfs API) Change-Id: Ic13adc9782d85560f0c74d77f60a629619d38668
This commit is contained in:
parent
2bd88936f7
commit
08a6f804ce
4 changed files with 28 additions and 9 deletions
|
@ -2032,7 +2032,6 @@ target/hosted/lc-unix.c
|
||||||
target/hosted/ibasso/audiohw-ibasso.c
|
target/hosted/ibasso/audiohw-ibasso.c
|
||||||
target/hosted/ibasso/backlight-ibasso.c
|
target/hosted/ibasso/backlight-ibasso.c
|
||||||
target/hosted/ibasso/button-ibasso.c
|
target/hosted/ibasso/button-ibasso.c
|
||||||
target/hosted/power-linux.c
|
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
target/hosted/ibasso/debug-ibasso.c
|
target/hosted/ibasso/debug-ibasso.c
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -140,7 +140,3 @@
|
||||||
#define NUM_DRIVES 2
|
#define NUM_DRIVES 2
|
||||||
#define HAVE_HOTSWAP
|
#define HAVE_HOTSWAP
|
||||||
#define MULTIDRIVE_DIR "/mnt/external_sd"
|
#define MULTIDRIVE_DIR "/mnt/external_sd"
|
||||||
|
|
||||||
/* More common stuff */
|
|
||||||
#define BATTERY_DEV_NAME "battery"
|
|
||||||
#define POWER_DEV_NAME "usb"
|
|
||||||
|
|
|
@ -137,7 +137,3 @@
|
||||||
#define NUM_DRIVES 2
|
#define NUM_DRIVES 2
|
||||||
#define HAVE_HOTSWAP
|
#define HAVE_HOTSWAP
|
||||||
#define MULTIDRIVE_DIR "/mnt/external_sd"
|
#define MULTIDRIVE_DIR "/mnt/external_sd"
|
||||||
|
|
||||||
/* More common stuff */
|
|
||||||
#define BATTERY_DEV_NAME "battery"
|
|
||||||
#define POWER_DEV_NAME "usb"
|
|
||||||
|
|
|
@ -112,3 +112,31 @@ int _battery_voltage(void)
|
||||||
|
|
||||||
return(val / 1000);
|
return(val / 1000);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* NOTE: This is largely lifted from the generic hostedpower-linux.c
|
||||||
|
but that uses a different sysfs api (expecting a path strning rather than
|
||||||
|
an enumeration */
|
||||||
|
#include "tick.h"
|
||||||
|
#include "power.h"
|
||||||
|
|
||||||
|
static long last_tick = 0;
|
||||||
|
static bool last_power = false;
|
||||||
|
bool charging_state(void)
|
||||||
|
{
|
||||||
|
if ((current_tick - last_tick) > HZ/2 ) {
|
||||||
|
char buf[12] = {0};
|
||||||
|
sysfs_get_string(SYSFS_BATTERY_STATUS, buf, sizeof(buf));
|
||||||
|
|
||||||
|
last_tick = current_tick;
|
||||||
|
last_power = (strncmp(buf, "Charging", 8) == 0);
|
||||||
|
}
|
||||||
|
return last_power;
|
||||||
|
}
|
||||||
|
|
||||||
|
unsigned int power_input_status(void)
|
||||||
|
{
|
||||||
|
int present = 0;
|
||||||
|
sysfs_get_int(SYSFS_USB_POWER_ONLINE, &present);
|
||||||
|
|
||||||
|
return present ? POWER_INPUT_USB_CHARGER : POWER_INPUT_NONE;
|
||||||
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue