summaryrefslogtreecommitdiffstats
path: root/firmware/target
diff options
context:
space:
mode:
authorThomas Martitz <kugel@rockbox.org>2012-01-03 23:44:38 +0000
committerThomas Martitz <kugel@rockbox.org>2012-01-03 23:44:38 +0000
commitc1bd9b0361ba92c29ceef68d74093e70a1a3e481 (patch)
tree1a42acdf2099b7f5ac06eee11e1d488b388c6d9f /firmware/target
parent949e6398c89e3c277a4c542f67a5ee788c6f642d (diff)
downloadrockbox-c1bd9b0361ba92c29ceef68d74093e70a1a3e481.tar.gz
rockbox-c1bd9b0361ba92c29ceef68d74093e70a1a3e481.tar.bz2
rockbox-c1bd9b0361ba92c29ceef68d74093e70a1a3e481.zip
Rework powermgmt to enable code re-use on appliation and sims.
* Introduce CONFIG_BATTERY_MEASURE define, to allow targets (application) to break powermgmt.c's assumption about the ability to read battery voltage. There's now additionally percentage (android) and remaining time measure (maemo). No measure at all also works (sdl app). If voltage can't be measured, then battery_level() is king and it'll be used for power_history and runtime estimation. * Implement target's API in the simulator, i.e. _battery_voltage(), so it doesn't need to implement it's own powermgmt.c and other stubs. Now the sim behaves much more like a native target, although it still changes the simulated battery voltage quickly, * Other changes include include renaming battery_adc_voltage() to _battery_voltage(), for consistency with the new target functions and making some of the apps code aware that voltage and runtime estimation is not always available. git-svn-id: svn://svn.rockbox.org/rockbox/trunk@31548 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'firmware/target')
-rw-r--r--firmware/target/arm/as3525/sansa-m200v4/powermgmt-m200v4.c2
-rw-r--r--firmware/target/arm/imx233/debug-imx233.c2
-rw-r--r--firmware/target/arm/imx233/powermgmt-imx233.c2
-rw-r--r--firmware/target/arm/imx31/gigabeat-s/powermgmt-gigabeat-s.c6
-rw-r--r--firmware/target/arm/ipod/1g2g/powermgmt-1g2g.c2
-rw-r--r--firmware/target/arm/ipod/powermgmt-ipod-pcf.c2
-rw-r--r--firmware/target/arm/iriver/h10/powermgmt-h10.c2
-rw-r--r--firmware/target/arm/olympus/mrobe-100/powermgmt-mr100.c2
-rw-r--r--firmware/target/arm/pbell/vibe500/powermgmt-vibe500.c2
-rw-r--r--firmware/target/arm/philips/hdd1630/powermgmt-hdd1630.c2
-rw-r--r--firmware/target/arm/philips/hdd6330/powermgmt-hdd6330.c2
-rw-r--r--firmware/target/arm/pnx0101/iriver-ifp7xx/powermgmt-ifp7xx.c2
-rw-r--r--firmware/target/arm/powermgmt-ascodec.c4
-rw-r--r--firmware/target/arm/rk27xx/hm60x/powermgmt-hm60x.c2
-rw-r--r--firmware/target/arm/rk27xx/hm801/powermgmt-hm801.c2
-rw-r--r--firmware/target/arm/rk27xx/rk27generic/powermgmt-rk27generic.c2
-rw-r--r--firmware/target/arm/s3c2440/gigabeat-fx/powermgmt-meg-fx.c2
-rw-r--r--firmware/target/arm/s3c2440/mini2440/powermgmt-mini2440.c2
-rw-r--r--firmware/target/arm/s5l8700/ipodnano2g/powermgmt-nano2g.c2
-rw-r--r--firmware/target/arm/s5l8700/meizu-m3/powermgmt-m3.c2
-rw-r--r--firmware/target/arm/s5l8700/meizu-m6sp/powermgmt-m6sp.c2
-rw-r--r--firmware/target/arm/s5l8702/ipod6g/powermgmt-ipod6g.c2
-rw-r--r--firmware/target/arm/samsung/yh820/powermgmt-yh820.c2
-rw-r--r--firmware/target/arm/samsung/yh920/powermgmt-yh920.c2
-rw-r--r--firmware/target/arm/samsung/yh925/powermgmt-yh925.c2
-rw-r--r--firmware/target/arm/sandisk/sansa-view/powermgmt-view.c2
-rw-r--r--firmware/target/arm/tatung/tpj1022/powermgmt-tpj1022.c2
-rw-r--r--firmware/target/arm/tcc77x/iaudio7/powermgmt-iaudio7.c2
-rw-r--r--firmware/target/arm/tcc77x/powermgmt-tcc77x.c2
-rw-r--r--firmware/target/arm/tcc780x/cowond2/powermgmt-cowond2.c2
-rw-r--r--firmware/target/arm/tms320dm320/creative-zvm/powermgmt-creativezvm.c2
-rw-r--r--firmware/target/arm/tms320dm320/mrobe-500/powermgmt-mr500.c2
-rw-r--r--firmware/target/arm/tms320dm320/sansa-connect/powermgmt-sansaconnect.c2
-rw-r--r--firmware/target/coldfire/iaudio/m3/powermgmt-m3.c2
-rw-r--r--firmware/target/coldfire/iaudio/powermgmt-iaudio.c2
-rw-r--r--firmware/target/coldfire/iriver/h100/powermgmt-h100.c2
-rw-r--r--firmware/target/coldfire/iriver/h300/powermgmt-h300.c2
-rw-r--r--firmware/target/coldfire/mpio/hd200/powermgmt-hd200.c2
-rw-r--r--firmware/target/coldfire/mpio/hd300/powermgmt-hd300.c2
-rw-r--r--firmware/target/hosted/android/powermgmt-android.c28
-rw-r--r--firmware/target/hosted/android/system-android.c2
-rw-r--r--firmware/target/hosted/maemo/maemo-thread.c30
-rw-r--r--firmware/target/hosted/powermgmt.c56
-rw-r--r--firmware/target/hosted/sdl/system-sdl.c2
-rw-r--r--firmware/target/hosted/ypr0/powermgmt-ypr0.c4
-rw-r--r--firmware/target/mips/ingenic_jz47xx/onda_vx747/sadc-onda_vx747.c2
-rw-r--r--firmware/target/mips/ingenic_jz47xx/onda_vx767/sadc-onda_vx767.c2
-rw-r--r--firmware/target/sh/archos/fm_v2/powermgmt-fm_v2.c2
-rw-r--r--firmware/target/sh/archos/ondio/powermgmt-ondio.c2
-rw-r--r--firmware/target/sh/archos/player/powermgmt-player.c2
-rw-r--r--firmware/target/sh/archos/recorder/powermgmt-recorder.c2
51 files changed, 61 insertions, 157 deletions
diff --git a/firmware/target/arm/as3525/sansa-m200v4/powermgmt-m200v4.c b/firmware/target/arm/as3525/sansa-m200v4/powermgmt-m200v4.c
index cbd2c4bf27..829ed36a8e 100644
--- a/firmware/target/arm/as3525/sansa-m200v4/powermgmt-m200v4.c
+++ b/firmware/target/arm/as3525/sansa-m200v4/powermgmt-m200v4.c
@@ -52,7 +52,7 @@ const unsigned short percent_to_volt_discharge[BATTERY_TYPES_COUNT][11] =
/* full-scale ADC readout (2^10) in millivolt */
/* Returns battery voltage from ADC [millivolts] */
-unsigned int battery_adc_voltage(void)
+int _battery_voltage(void)
{
return (adc_read(ADC_VBAT) * BATTERY_SCALE_FACTOR) >> 10;
}
diff --git a/firmware/target/arm/imx233/debug-imx233.c b/firmware/target/arm/imx233/debug-imx233.c
index 228d2abcdb..82ad86f148 100644
--- a/firmware/target/arm/imx233/debug-imx233.c
+++ b/firmware/target/arm/imx233/debug-imx233.c
@@ -153,7 +153,7 @@ bool dbg_hw_info_adc(void)
lcd_clear_display();
/* add battery readout in mV, this it is not the direct output of a channel */
- lcd_putsf(0, 0, "Battery(mV) %d", battery_adc_voltage());
+ lcd_putsf(0, 0, "Battery(mV) %d", _battery_voltage());
for(unsigned i = 0; i < NUM_ADC_CHANNELS; i++)
{
lcd_putsf(0, i + 1, "%s %d", imx233_adc_channel_name[i],
diff --git a/firmware/target/arm/imx233/powermgmt-imx233.c b/firmware/target/arm/imx233/powermgmt-imx233.c
index 87c48e7655..0f3336d602 100644
--- a/firmware/target/arm/imx233/powermgmt-imx233.c
+++ b/firmware/target/arm/imx233/powermgmt-imx233.c
@@ -38,7 +38,7 @@ static int timeout_topping_off; /* timeout before stopping charging after toppin
static int timeout_4p2_ilimit_increase; /* timeout before increasing 4p2 ilimit */
/* Returns battery voltage from ADC [millivolts] */
-unsigned int battery_adc_voltage(void)
+int _battery_voltage(void)
{
/* battery value is in 8mV LSB */
return __XTRACT(HW_POWER_BATTMONITOR, BATT_VAL) * 8;
diff --git a/firmware/target/arm/imx31/gigabeat-s/powermgmt-gigabeat-s.c b/firmware/target/arm/imx31/gigabeat-s/powermgmt-gigabeat-s.c
index d87e367cba..1a8e12182a 100644
--- a/firmware/target/arm/imx31/gigabeat-s/powermgmt-gigabeat-s.c
+++ b/firmware/target/arm/imx31/gigabeat-s/powermgmt-gigabeat-s.c
@@ -53,7 +53,7 @@ const unsigned short percent_to_volt_charge[11] =
};
/* Returns battery voltage from ADC [millivolts] */
-unsigned int battery_adc_voltage(void)
+int _battery_voltage(void)
{
/* ADC reading 0-1023 = 2400mV-4700mV */
return ((adc_read(ADC_BATTERY) * 2303) >> 10) + 2400;
@@ -249,7 +249,7 @@ static int stat_battery_reading(int type)
switch (type)
{
case ADC_BATTERY:
- reading = battery_adc_voltage();
+ reading = _battery_voltage();
break;
case ADC_CHARGER_CURRENT:
@@ -780,7 +780,7 @@ static void charger_control(void)
/* Battery voltage may have dropped and a charge cycle should
* start again. Debounced. */
if (autorecharge_counter < 0 &&
- battery_adc_voltage() < BATT_FULL_VOLTAGE)
+ _battery_voltage() < BATT_FULL_VOLTAGE)
{
/* Try starting a cycle now if battery isn't already topped
* off to allow user to ensure the battery is full. */
diff --git a/firmware/target/arm/ipod/1g2g/powermgmt-1g2g.c b/firmware/target/arm/ipod/1g2g/powermgmt-1g2g.c
index 1bc5de9986..c3eca14332 100644
--- a/firmware/target/arm/ipod/1g2g/powermgmt-1g2g.c
+++ b/firmware/target/arm/ipod/1g2g/powermgmt-1g2g.c
@@ -57,7 +57,7 @@ const unsigned short percent_to_volt_charge[11] =
/* full-scale ADC readout (2^8) in millivolt */
/* Returns battery voltage from ADC [millivolts] */
-unsigned int battery_adc_voltage(void)
+int _battery_voltage(void)
{
unsigned adcval = adc_read(ADC_UNREG_POWER);
diff --git a/firmware/target/arm/ipod/powermgmt-ipod-pcf.c b/firmware/target/arm/ipod/powermgmt-ipod-pcf.c
index 44e908a4a2..1241f47302 100644
--- a/firmware/target/arm/ipod/powermgmt-ipod-pcf.c
+++ b/firmware/target/arm/ipod/powermgmt-ipod-pcf.c
@@ -109,7 +109,7 @@ const unsigned short percent_to_volt_charge[11] =
/* full-scale ADC readout (2^10) in millivolt */
/* Returns battery voltage from ADC [millivolts] */
-unsigned int battery_adc_voltage(void)
+int _battery_voltage(void)
{
return (adc_read(ADC_UNREG_POWER) * BATTERY_SCALE_FACTOR) >> 10;
}
diff --git a/firmware/target/arm/iriver/h10/powermgmt-h10.c b/firmware/target/arm/iriver/h10/powermgmt-h10.c
index 9970c292bc..c20d802983 100644
--- a/firmware/target/arm/iriver/h10/powermgmt-h10.c
+++ b/firmware/target/arm/iriver/h10/powermgmt-h10.c
@@ -67,7 +67,7 @@ const unsigned short percent_to_volt_charge[11] =
/* full-scale ADC readout (2^10) in millivolt */
/* Returns battery voltage from ADC [millivolts] */
-unsigned int battery_adc_voltage(void)
+int _battery_voltage(void)
{
return (adc_read(ADC_UNREG_POWER) * BATTERY_SCALE_FACTOR) >> 10;
}
diff --git a/firmware/target/arm/olympus/mrobe-100/powermgmt-mr100.c b/firmware/target/arm/olympus/mrobe-100/powermgmt-mr100.c
index c8d5584305..ae33fc5ca3 100644
--- a/firmware/target/arm/olympus/mrobe-100/powermgmt-mr100.c
+++ b/firmware/target/arm/olympus/mrobe-100/powermgmt-mr100.c
@@ -58,7 +58,7 @@ const unsigned short percent_to_volt_charge[11] =
*/
/* Returns battery voltage from ADC [millivolts] */
-unsigned int battery_adc_voltage(void)
+int _battery_voltage(void)
{
return (adc_read(ADC_UNREG_POWER) * BATTERY_SCALE_FACTOR) >> 10;
}
diff --git a/firmware/target/arm/pbell/vibe500/powermgmt-vibe500.c b/firmware/target/arm/pbell/vibe500/powermgmt-vibe500.c
index d84881cea1..dbd7d8cbf7 100644
--- a/firmware/target/arm/pbell/vibe500/powermgmt-vibe500.c
+++ b/firmware/target/arm/pbell/vibe500/powermgmt-vibe500.c
@@ -51,7 +51,7 @@ const unsigned short percent_to_volt_charge[11] =
/* full-scale ADC readout (2^10) in millivolt */
/* Returns battery voltage from ADC [millivolts] */
-unsigned int battery_adc_voltage(void)
+int _battery_voltage(void)
{
return (adc_read(ADC_UNREG_POWER) * BATTERY_SCALE_FACTOR) >> 10;
}
diff --git a/firmware/target/arm/philips/hdd1630/powermgmt-hdd1630.c b/firmware/target/arm/philips/hdd1630/powermgmt-hdd1630.c
index 8090c624df..7d132523e6 100644
--- a/firmware/target/arm/philips/hdd1630/powermgmt-hdd1630.c
+++ b/firmware/target/arm/philips/hdd1630/powermgmt-hdd1630.c
@@ -57,7 +57,7 @@ const unsigned short percent_to_volt_charge[11] =
/* full-scale ADC readout (2^10) in millivolt */
/* Returns battery voltage from ADC [millivolts] */
-unsigned int battery_adc_voltage(void)
+int _battery_voltage(void)
{
/* return (adc_read(ADC_UNREG_POWER) * BATTERY_SCALE_FACTOR) >> 10; */
diff --git a/firmware/target/arm/philips/hdd6330/powermgmt-hdd6330.c b/firmware/target/arm/philips/hdd6330/powermgmt-hdd6330.c
index 8090c624df..7d132523e6 100644
--- a/firmware/target/arm/philips/hdd6330/powermgmt-hdd6330.c
+++ b/firmware/target/arm/philips/hdd6330/powermgmt-hdd6330.c
@@ -57,7 +57,7 @@ const unsigned short percent_to_volt_charge[11] =
/* full-scale ADC readout (2^10) in millivolt */
/* Returns battery voltage from ADC [millivolts] */
-unsigned int battery_adc_voltage(void)
+int _battery_voltage(void)
{
/* return (adc_read(ADC_UNREG_POWER) * BATTERY_SCALE_FACTOR) >> 10; */
diff --git a/firmware/target/arm/pnx0101/iriver-ifp7xx/powermgmt-ifp7xx.c b/firmware/target/arm/pnx0101/iriver-ifp7xx/powermgmt-ifp7xx.c
index 76646d368c..4ce90a4c4f 100644
--- a/firmware/target/arm/pnx0101/iriver-ifp7xx/powermgmt-ifp7xx.c
+++ b/firmware/target/arm/pnx0101/iriver-ifp7xx/powermgmt-ifp7xx.c
@@ -48,7 +48,7 @@ const unsigned short percent_to_volt_discharge[BATTERY_TYPES_COUNT][11] =
/* full-scale ADC readout (2^10) in millivolt */
/* Returns battery voltage from ADC [millivolts] */
-unsigned int battery_adc_voltage(void)
+int _battery_voltage(void)
{
return (adc_read(ADC_UNREG_POWER) * BATTERY_SCALE_FACTOR) >> 10;
}
diff --git a/firmware/target/arm/powermgmt-ascodec.c b/firmware/target/arm/powermgmt-ascodec.c
index 3232a9a6fb..c05fc7bf7a 100644
--- a/firmware/target/arm/powermgmt-ascodec.c
+++ b/firmware/target/arm/powermgmt-ascodec.c
@@ -67,7 +67,7 @@ static unsigned int batt_threshold = 0;
/* full-scale ADC readout (2^10) in millivolt */
/* Returns battery voltage from ADC [millivolts] */
-unsigned int battery_adc_voltage(void)
+int _battery_voltage(void)
{
return (adc_read(ADC_BATTERY) * 5125 + 512) >> 10;
}
@@ -85,7 +85,7 @@ static void battery_voltage_sync(void)
unsigned int mv;
for (i = 0, mv = 0; i < 5; i++)
- mv += battery_adc_voltage();
+ mv += _battery_voltage();
reset_battery_filter(mv / 5);
}
diff --git a/firmware/target/arm/rk27xx/hm60x/powermgmt-hm60x.c b/firmware/target/arm/rk27xx/hm60x/powermgmt-hm60x.c
index 7b5b171ccb..6ab761672a 100644
--- a/firmware/target/arm/rk27xx/hm60x/powermgmt-hm60x.c
+++ b/firmware/target/arm/rk27xx/hm60x/powermgmt-hm60x.c
@@ -60,7 +60,7 @@ const unsigned short percent_to_volt_charge[11] =
#define BATTERY_SCALE_FACTOR 6000
/* Returns battery voltage from ADC [millivolts] */
-unsigned int battery_adc_voltage(void)
+int _battery_voltage(void)
{
return (adc_read(ADC_BATTERY) * BATTERY_SCALE_FACTOR) >> 10;
}
diff --git a/firmware/target/arm/rk27xx/hm801/powermgmt-hm801.c b/firmware/target/arm/rk27xx/hm801/powermgmt-hm801.c
index a815d893b2..dc555be4cf 100644
--- a/firmware/target/arm/rk27xx/hm801/powermgmt-hm801.c
+++ b/firmware/target/arm/rk27xx/hm801/powermgmt-hm801.c
@@ -54,7 +54,7 @@ const unsigned short percent_to_volt_charge[11] =
/* TODO: simple uncalibrated curve */
{ 425, 430, 440, 450, 460, 470, 480, 490, 500, 510, 520 };
-unsigned int battery_adc_voltage(void)
+int _battery_voltage(void)
{
return adc_read(ADC_BATTERY);
}
diff --git a/firmware/target/arm/rk27xx/rk27generic/powermgmt-rk27generic.c b/firmware/target/arm/rk27xx/rk27generic/powermgmt-rk27generic.c
index 3960dab2c1..ccbc098d91 100644
--- a/firmware/target/arm/rk27xx/rk27generic/powermgmt-rk27generic.c
+++ b/firmware/target/arm/rk27xx/rk27generic/powermgmt-rk27generic.c
@@ -60,7 +60,7 @@ const unsigned short percent_to_volt_charge[11] =
#define BATTERY_SCALE_FACTOR 6000
/* Returns battery voltage from ADC [millivolts] */
-unsigned int battery_adc_voltage(void)
+int _battery_voltage(void)
{
return (adc_read(ADC_BATTERY) * BATTERY_SCALE_FACTOR) >> 10;
}
diff --git a/firmware/target/arm/s3c2440/gigabeat-fx/powermgmt-meg-fx.c b/firmware/target/arm/s3c2440/gigabeat-fx/powermgmt-meg-fx.c
index 49f7e2e049..4cc43d038a 100644
--- a/firmware/target/arm/s3c2440/gigabeat-fx/powermgmt-meg-fx.c
+++ b/firmware/target/arm/s3c2440/gigabeat-fx/powermgmt-meg-fx.c
@@ -54,7 +54,7 @@ const unsigned short percent_to_volt_charge[11] =
/* full-scale ADC readout (2^10) in millivolt */
/* Returns battery voltage from ADC [millivolts] */
-unsigned int battery_adc_voltage(void)
+int _battery_voltage(void)
{
return (adc_read(ADC_UNREG_POWER) * BATTERY_SCALE_FACTOR) >> 10;
}
diff --git a/firmware/target/arm/s3c2440/mini2440/powermgmt-mini2440.c b/firmware/target/arm/s3c2440/mini2440/powermgmt-mini2440.c
index 5281b10698..9a05cd37c6 100644
--- a/firmware/target/arm/s3c2440/mini2440/powermgmt-mini2440.c
+++ b/firmware/target/arm/s3c2440/mini2440/powermgmt-mini2440.c
@@ -52,7 +52,7 @@ const unsigned short percent_to_volt_charge[11] =
/* Returns battery voltage from ADC [millivolts] */
/* full-scale (2^10) in millivolt */
-unsigned int battery_adc_voltage(void)
+int _battery_voltage(void)
{
/* Since we have no battery, return a fully charged value */
return 4000 * 1024 / 1000;
diff --git a/firmware/target/arm/s5l8700/ipodnano2g/powermgmt-nano2g.c b/firmware/target/arm/s5l8700/ipodnano2g/powermgmt-nano2g.c
index 52491cf480..647c13ed79 100644
--- a/firmware/target/arm/s5l8700/ipodnano2g/powermgmt-nano2g.c
+++ b/firmware/target/arm/s5l8700/ipodnano2g/powermgmt-nano2g.c
@@ -55,7 +55,7 @@ const unsigned short percent_to_volt_charge[11] =
/* Returns battery voltage from ADC [millivolts] */
-unsigned int battery_adc_voltage(void)
+int _battery_voltage(void)
{
int compensation = (10 * (pmu_read_battery_current() - 7)) / 12;
if (charging_state()) return pmu_read_battery_voltage() - compensation;
diff --git a/firmware/target/arm/s5l8700/meizu-m3/powermgmt-m3.c b/firmware/target/arm/s5l8700/meizu-m3/powermgmt-m3.c
index 3960dab2c1..ccbc098d91 100644
--- a/firmware/target/arm/s5l8700/meizu-m3/powermgmt-m3.c
+++ b/firmware/target/arm/s5l8700/meizu-m3/powermgmt-m3.c
@@ -60,7 +60,7 @@ const unsigned short percent_to_volt_charge[11] =
#define BATTERY_SCALE_FACTOR 6000
/* Returns battery voltage from ADC [millivolts] */
-unsigned int battery_adc_voltage(void)
+int _battery_voltage(void)
{
return (adc_read(ADC_BATTERY) * BATTERY_SCALE_FACTOR) >> 10;
}
diff --git a/firmware/target/arm/s5l8700/meizu-m6sp/powermgmt-m6sp.c b/firmware/target/arm/s5l8700/meizu-m6sp/powermgmt-m6sp.c
index 86b6e46b4d..b59d0fac45 100644
--- a/firmware/target/arm/s5l8700/meizu-m6sp/powermgmt-m6sp.c
+++ b/firmware/target/arm/s5l8700/meizu-m6sp/powermgmt-m6sp.c
@@ -58,7 +58,7 @@ const unsigned short percent_to_volt_charge[11] =
/* Returns battery voltage from ADC [millivolts] */
-unsigned int battery_adc_voltage(void)
+int _battery_voltage(void)
{
return (adc_read(ADC_BATTERY) * BATTERY_SCALE_FACTOR) >> 10;
}
diff --git a/firmware/target/arm/s5l8702/ipod6g/powermgmt-ipod6g.c b/firmware/target/arm/s5l8702/ipod6g/powermgmt-ipod6g.c
index 6caeafd8fc..b88ac16d55 100644
--- a/firmware/target/arm/s5l8702/ipod6g/powermgmt-ipod6g.c
+++ b/firmware/target/arm/s5l8702/ipod6g/powermgmt-ipod6g.c
@@ -55,7 +55,7 @@ const unsigned short percent_to_volt_charge[11] =
/* Returns battery voltage from ADC [millivolts] */
-unsigned int battery_adc_voltage(void)
+int _battery_voltage(void)
{
int compensation = (10 * (pmu_read_battery_current() - 7)) / 12;
if (charging_state()) return pmu_read_battery_voltage() - compensation;
diff --git a/firmware/target/arm/samsung/yh820/powermgmt-yh820.c b/firmware/target/arm/samsung/yh820/powermgmt-yh820.c
index 495590413c..180194c704 100644
--- a/firmware/target/arm/samsung/yh820/powermgmt-yh820.c
+++ b/firmware/target/arm/samsung/yh820/powermgmt-yh820.c
@@ -52,7 +52,7 @@ const unsigned short percent_to_volt_charge[11] =
/* full-scale ADC readout (2^10) in millivolt */
/* Returns battery voltage from ADC [millivolts] */
-unsigned int battery_adc_voltage(void)
+int _battery_voltage(void)
{
/* return (adc_read(ADC_UNREG_POWER) * BATTERY_SCALE_FACTOR) >> 10; */
return 4100;
diff --git a/firmware/target/arm/samsung/yh920/powermgmt-yh920.c b/firmware/target/arm/samsung/yh920/powermgmt-yh920.c
index 0ea3c5d50e..f33afb31bd 100644
--- a/firmware/target/arm/samsung/yh920/powermgmt-yh920.c
+++ b/firmware/target/arm/samsung/yh920/powermgmt-yh920.c
@@ -52,7 +52,7 @@ const unsigned short percent_to_volt_charge[11] =
/* full-scale ADC readout (2^10) in millivolt */
/* Returns battery voltage from ADC [millivolts] */
-unsigned int battery_adc_voltage(void)
+int _battery_voltage(void)
{
return (adc_read(ADC_UNREG_POWER) * BATTERY_SCALE_FACTOR) >> 10;
}
diff --git a/firmware/target/arm/samsung/yh925/powermgmt-yh925.c b/firmware/target/arm/samsung/yh925/powermgmt-yh925.c
index 3eb5dd6c61..ab9cbcdfc1 100644
--- a/firmware/target/arm/samsung/yh925/powermgmt-yh925.c
+++ b/firmware/target/arm/samsung/yh925/powermgmt-yh925.c
@@ -52,7 +52,7 @@ const unsigned short percent_to_volt_charge[11] =
/* full-scale ADC readout (2^10) in millivolt */
/* Returns battery voltage from ADC [millivolts] */
-unsigned int battery_adc_voltage(void)
+int _battery_voltage(void)
{
return (adc_read(ADC_UNREG_POWER) * BATTERY_SCALE_FACTOR) >> 10;
}
diff --git a/firmware/target/arm/sandisk/sansa-view/powermgmt-view.c b/firmware/target/arm/sandisk/sansa-view/powermgmt-view.c
index 459b60dd45..870a883087 100644
--- a/firmware/target/arm/sandisk/sansa-view/powermgmt-view.c
+++ b/firmware/target/arm/sandisk/sansa-view/powermgmt-view.c
@@ -23,7 +23,7 @@
#include "adc.h"
#include "powermgmt.h"
-unsigned int battery_adc_voltage(void)
+int _battery_voltage(void)
{
return 0;
}
diff --git a/firmware/target/arm/tatung/tpj1022/powermgmt-tpj1022.c b/firmware/target/arm/tatung/tpj1022/powermgmt-tpj1022.c
index ef7919d5aa..cc91012fcd 100644
--- a/firmware/target/arm/tatung/tpj1022/powermgmt-tpj1022.c
+++ b/firmware/target/arm/tatung/tpj1022/powermgmt-tpj1022.c
@@ -56,7 +56,7 @@ const unsigned short percent_to_volt_charge[11] =
/* full-scale ADC readout (2^10) in millivolt */
/* Returns battery voltage from ADC [millivolts] */
-unsigned int battery_adc_voltage(void)
+int _battery_voltage(void)
{
return (adc_read(ADC_UNREG_POWER) * BATTERY_SCALE_FACTOR) >> 10;
}
diff --git a/firmware/target/arm/tcc77x/iaudio7/powermgmt-iaudio7.c b/firmware/target/arm/tcc77x/iaudio7/powermgmt-iaudio7.c
index 9b65bbde1f..bc7ead61f0 100644
--- a/firmware/target/arm/tcc77x/iaudio7/powermgmt-iaudio7.c
+++ b/firmware/target/arm/tcc77x/iaudio7/powermgmt-iaudio7.c
@@ -59,7 +59,7 @@ const unsigned short percent_to_volt_charge[11] =
/* full-scale ADC readout (2^10) in millivolt */
/* Returns battery voltage from ADC [millivolts] */
-unsigned int battery_adc_voltage(void)
+int _battery_voltage(void)
{
static unsigned last_tick = 0;
diff --git a/firmware/target/arm/tcc77x/powermgmt-tcc77x.c b/firmware/target/arm/tcc77x/powermgmt-tcc77x.c
index 90c66d30e6..07a56777d0 100644
--- a/firmware/target/arm/tcc77x/powermgmt-tcc77x.c
+++ b/firmware/target/arm/tcc77x/powermgmt-tcc77x.c
@@ -59,7 +59,7 @@ const unsigned short percent_to_volt_charge[11] =
/* full-scale ADC readout (2^10) in millivolt */
/* Returns battery voltage from ADC [millivolts] */
-unsigned int battery_adc_voltage(void)
+int _battery_voltage(void)
{
return current_voltage;
}
diff --git a/firmware/target/arm/tcc780x/cowond2/powermgmt-cowond2.c b/firmware/target/arm/tcc780x/cowond2/powermgmt-cowond2.c
index 9b2320b7cf..91361fe5f4 100644
--- a/firmware/target/arm/tcc780x/cowond2/powermgmt-cowond2.c
+++ b/firmware/target/arm/tcc780x/cowond2/powermgmt-cowond2.c
@@ -61,7 +61,7 @@ const unsigned short percent_to_volt_charge[11] =
/* full-scale ADC readout (2^10) in millivolt */
/* Returns battery voltage from ADC [millivolts] */
-unsigned int battery_adc_voltage(void)
+int _battery_voltage(void)
{
static unsigned last_tick = 0;
diff --git a/firmware/target/arm/tms320dm320/creative-zvm/powermgmt-creativezvm.c b/firmware/target/arm/tms320dm320/creative-zvm/powermgmt-creativezvm.c
index a6d19347c4..23ee9c6abe 100644
--- a/firmware/target/arm/tms320dm320/creative-zvm/powermgmt-creativezvm.c
+++ b/firmware/target/arm/tms320dm320/creative-zvm/powermgmt-creativezvm.c
@@ -50,7 +50,7 @@ const unsigned short percent_to_volt_charge[11] =
};
/* Returns battery voltage from ADC [millivolts] */
-unsigned int battery_adc_voltage(void)
+int _battery_voltage(void)
{
return current_voltage;
}
diff --git a/firmware/target/arm/tms320dm320/mrobe-500/powermgmt-mr500.c b/firmware/target/arm/tms320dm320/mrobe-500/powermgmt-mr500.c
index 5da03692f7..78f9bbb9c2 100644
--- a/firmware/target/arm/tms320dm320/mrobe-500/powermgmt-mr500.c
+++ b/firmware/target/arm/tms320dm320/mrobe-500/powermgmt-mr500.c
@@ -60,7 +60,7 @@ const unsigned short percent_to_volt_charge[11] =
};
/* Returns battery voltage from ADC [millivolts] */
-unsigned int battery_adc_voltage(void)
+int _battery_voltage(void)
{
short bat1, bat2, aux;
static unsigned last_tick = 0;
diff --git a/firmware/target/arm/tms320dm320/sansa-connect/powermgmt-sansaconnect.c b/firmware/target/arm/tms320dm320/sansa-connect/powermgmt-sansaconnect.c
index c42f56b0b3..8b3f05107c 100644
--- a/firmware/target/arm/tms320dm320/sansa-connect/powermgmt-sansaconnect.c
+++ b/firmware/target/arm/tms320dm320/sansa-connect/powermgmt-sansaconnect.c
@@ -53,7 +53,7 @@ const unsigned short percent_to_volt_charge[11] =
};
/* Returns battery voltage from ADC [millivolts] */
-unsigned int battery_adc_voltage(void)
+int _battery_voltage(void)
{
return current_battery_level;
}
diff --git a/firmware/target/coldfire/iaudio/m3/powermgmt-m3.c b/firmware/target/coldfire/iaudio/m3/powermgmt-m3.c
index bb8f5cf811..b97d6913f2 100644
--- a/firmware/target/coldfire/iaudio/m3/powermgmt-m3.c
+++ b/firmware/target/coldfire/iaudio/m3/powermgmt-m3.c
@@ -52,7 +52,7 @@ const unsigned short percent_to_volt_charge[11] =
/* full-scale ADC readout (2^8) in millivolt */
/* Returns battery voltage from ADC [millivolts] */
-unsigned int battery_adc_voltage(void)
+int _battery_voltage(void)
{
return (adc_read(ADC_BATTERY) * BATTERY_SCALE_FACTOR) >> 8;
}
diff --git a/firmware/target/coldfire/iaudio/powermgmt-iaudio.c b/firmware/target/coldfire/iaudio/powermgmt-iaudio.c
index 4bfea20432..56915266da 100644
--- a/firmware/target/coldfire/iaudio/powermgmt-iaudio.c
+++ b/firmware/target/coldfire/iaudio/powermgmt-iaudio.c
@@ -53,7 +53,7 @@ const unsigned short percent_to_volt_charge[11] =
/* full-scale ADC readout (2^10) in millivolt */
/* Returns battery voltage from ADC [millivolts] */
-unsigned int battery_adc_voltage(void)
+int _battery_voltage(void)
{
return (adc_read(ADC_UNREG_POWER) * BATTERY_SCALE_FACTOR) >> 10;
}
diff --git a/firmware/target/coldfire/iriver/h100/powermgmt-h100.c b/firmware/target/coldfire/iriver/h100/powermgmt-h100.c
index e238711120..20e1a88d4a 100644
--- a/firmware/target/coldfire/iriver/h100/powermgmt-h100.c
+++ b/firmware/target/coldfire/iriver/h100/powermgmt-h100.c
@@ -53,7 +53,7 @@ const unsigned short percent_to_volt_charge[11] =
/* full-scale ADC readout (2^8) in millivolt */
/* Returns battery voltage from ADC [millivolts] */
-unsigned int battery_adc_voltage(void)
+int _battery_voltage(void)
{
return (adc_read(ADC_UNREG_POWER) * BATTERY_SCALE_FACTOR) >> 8;
}
diff --git a/firmware/target/coldfire/iriver/h300/powermgmt-h300.c b/firmware/target/coldfire/iriver/h300/powermgmt-h300.c
index 95a5741759..00aad31279 100644
--- a/firmware/target/coldfire/iriver/h300/powermgmt-h300.c
+++ b/firmware/target/coldfire/iriver/h300/powermgmt-h300.c
@@ -53,7 +53,7 @@ const unsigned short percent_to_volt_charge[11] =
/* full-scale ADC readout (2^10) in millivolt */
/* Returns battery voltage from ADC [millivolts] */
-unsigned int battery_adc_voltage(void)
+int _battery_voltage(void)
{
return (adc_read(ADC_UNREG_POWER) * BATTERY_SCALE_FACTOR) >> 10;
}
diff --git a/firmware/target/coldfire/mpio/hd200/powermgmt-hd200.c b/firmware/target/coldfire/mpio/hd200/powermgmt-hd200.c
index 9d95938ff9..964d551de1 100644
--- a/firmware/target/coldfire/mpio/hd200/powermgmt-hd200.c
+++ b/firmware/target/coldfire/mpio/hd200/powermgmt-hd200.c
@@ -51,7 +51,7 @@ const unsigned short percent_to_volt_charge[11] =
/* Returns battery voltage from ADC [millivolts] */
-unsigned int battery_adc_voltage(void)
+int _battery_voltage(void)
{
return (adc_read(ADC_BATTERY) * BATTERY_SCALE_FACTOR) >> 11;
}
diff --git a/firmware/target/coldfire/mpio/hd300/powermgmt-hd300.c b/firmware/target/coldfire/mpio/hd300/powermgmt-hd300.c
index bdfe9b5fc4..ffd0190073 100644
--- a/firmware/target/coldfire/mpio/hd300/powermgmt-hd300.c
+++ b/firmware/target/coldfire/mpio/hd300/powermgmt-hd300.c
@@ -51,7 +51,7 @@ const unsigned short percent_to_volt_charge[11] =
/* Returns battery voltage from ADC [millivolts] */
-unsigned int battery_adc_voltage(void)
+int _battery_voltage(void)
{
return (adc_read(ADC_BATTERY) * BATTERY_SCALE_FACTOR) >> 11;
}
diff --git a/firmware/target/hosted/android/powermgmt-android.c b/firmware/target/hosted/android/powermgmt-android.c
index dcbd7a6214..1e70a81753 100644
--- a/firmware/target/hosted/android/powermgmt-android.c
+++ b/firmware/target/hosted/android/powermgmt-android.c
@@ -28,10 +28,10 @@ extern JNIEnv *env_ptr;
extern jclass RockboxService_class;
extern jobject RockboxService_instance;
-static jfieldID _battery_level;
+static jfieldID __battery_level;
static jobject BatteryMonitor_instance;
-void powermgmt_init_target(void)
+static void new_battery_monitor(void)
{
JNIEnv e = *env_ptr;
jclass class = e->FindClass(env_ptr, "org/rockbox/monitors/BatteryMonitor");
@@ -43,29 +43,15 @@ void powermgmt_init_target(void)
RockboxService_instance);
/* cache the battery level field id */
- _battery_level = (*env_ptr)->GetFieldID(env_ptr,
+ __battery_level = (*env_ptr)->GetFieldID(env_ptr,
class,
"mBattLevel", "I");
}
-int battery_level(void)
+int _battery_level(void)
{
- return (*env_ptr)->GetIntField(env_ptr, BatteryMonitor_instance, _battery_level);
+ if (!BatteryMonitor_instance)
+ new_battery_monitor();
+ return (*env_ptr)->GetIntField(env_ptr, BatteryMonitor_instance, __battery_level);
}
-int battery_time(void)
-{ /* cannot calculate yet */
- return 0;
-}
-
-/* should always be safe on android targets, the host shuts us down before */
-bool battery_level_safe(void)
-{
- return true;
-}
-
-/* TODO */
-unsigned battery_voltage(void)
-{
- return 0;
-}
diff --git a/firmware/target/hosted/android/system-android.c b/firmware/target/hosted/android/system-android.c
index fba7ff4e2c..e48e910c0c 100644
--- a/firmware/target/hosted/android/system-android.c
+++ b/firmware/target/hosted/android/system-android.c
@@ -45,7 +45,7 @@ void system_reboot(void) { }
/* this is used to return from the entry point of the native library. */
static jmp_buf poweroff_buf;
-void shutdown_hw(void)
+void power_off(void)
{
longjmp(poweroff_buf, 1);
}
diff --git a/firmware/target/hosted/maemo/maemo-thread.c b/firmware/target/hosted/maemo/maemo-thread.c
index a32a563459..2f1d033baa 100644
--- a/firmware/target/hosted/maemo/maemo-thread.c
+++ b/firmware/target/hosted/maemo/maemo-thread.c
@@ -163,40 +163,14 @@ int maemo_thread_func (void *wait_for_osso_startup)
return 0;
}
-/** Rockbox battery related functions */
-void battery_status_update(void)
-{
- battery_percent = maemo_battery_level;
- send_battery_level_event();
-}
-
-/* Returns true if any power input is connected - charging-capable
- * or not. */
-bool power_input_present(void)
-{
- return false;
-}
-
-unsigned battery_voltage(void)
-{
- return 0;
-}
-
/* Returns battery level in percent */
-int battery_level(void)
+int _battery_level(void)
{
- battery_status_update();
return maemo_battery_level;
}
/* Return remaining battery time in minutes */
-int battery_time(void)
+int _battery_time(void)
{
- battery_status_update();
return maemo_remaining_time_sec / 60;
}
-
-bool battery_level_safe(void)
-{
- return battery_level() >= 5;
-}
diff --git a/firmware/target/hosted/powermgmt.c b/firmware/target/hosted/powermgmt.c
deleted file mode 100644
index bf05e5ff19..0000000000
--- a/firmware/target/hosted/powermgmt.c
+++ /dev/null
@@ -1,56 +0,0 @@
-/***************************************************************************
- * __________ __ ___.
- * Open \______ \ ____ ____ | | _\_ |__ _______ ___
- * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
- * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
- * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
- * \/ \/ \/ \/ \/
- * $Id$
- *
- * Copyright (C) 2011 by Thomas Jarosch
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
- *
- * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
- * KIND, either express or implied.
- *
- ****************************************************************************/
-#include "config.h"
-#include "powermgmt.h"
-#include "thread.h"
-#include "kernel.h"
-
-static char power_stack[DEFAULT_STACK_SIZE];
-static const char power_thread_name[] = "power";
-
-void powermgmt_init_target(void);
-
-#if !(CONFIG_PLATFORM & PLATFORM_ANDROID)
-void powermgmt_init_target(void)
-{
- /* Nothing to do */
-}
-#endif
-
-static void power_thread(void)
-{
- powermgmt_init_target();
-
- while (1)
- {
- /* Sleep two seconds */
- sleep(HZ*2);
-
- handle_auto_poweroff();
- }
-} /* power_thread */
-
-void powermgmt_init(void)
-{
- create_thread(power_thread, power_stack, sizeof(power_stack), 0,
- power_thread_name IF_PRIO(, PRIORITY_SYSTEM)
- IF_COP(, CPU));
-}
diff --git a/firmware/target/hosted/sdl/system-sdl.c b/firmware/target/hosted/sdl/system-sdl.c
index 93a8a7cb66..87b2e0ccd1 100644
--- a/firmware/target/hosted/sdl/system-sdl.c
+++ b/firmware/target/hosted/sdl/system-sdl.c
@@ -196,7 +196,7 @@ static int sdl_event_thread(void * param)
return 0;
}
-void shutdown_hw(void)
+void power_off(void)
{
/* Shut down SDL event loop */
SDL_Event event;
diff --git a/firmware/target/hosted/ypr0/powermgmt-ypr0.c b/firmware/target/hosted/ypr0/powermgmt-ypr0.c
index 0c162a619d..9c90f7ea02 100644
--- a/firmware/target/hosted/ypr0/powermgmt-ypr0.c
+++ b/firmware/target/hosted/ypr0/powermgmt-ypr0.c
@@ -70,7 +70,7 @@ unsigned int power_input_status(void)
/* Returns battery voltage from ADC [millivolts],
* adc returns voltage in 5mV steps */
-unsigned int battery_adc_voltage(void)
+int _battery_voltage(void)
{
return adc_read(3) * 5;
}
@@ -80,5 +80,5 @@ bool charging_state(void)
const unsigned short charged_thres = 4170;
bool ret = (power_input_status() == POWER_INPUT_MAIN_CHARGER);
/* dont indicate for > ~95% */
- return ret && (battery_adc_voltage() <= charged_thres);
+ return ret && (_battery_voltage() <= charged_thres);
}
diff --git a/firmware/target/mips/ingenic_jz47xx/onda_vx747/sadc-onda_vx747.c b/firmware/target/mips/ingenic_jz47xx/onda_vx747/sadc-onda_vx747.c
index 99d73fa3c7..e6f0cd9cc3 100644
--- a/firmware/target/mips/ingenic_jz47xx/onda_vx747/sadc-onda_vx747.c
+++ b/firmware/target/mips/ingenic_jz47xx/onda_vx747/sadc-onda_vx747.c
@@ -102,7 +102,7 @@ const unsigned short percent_to_volt_charge[11] =
#define BATTERY_SCALE_FACTOR 7500
/* Returns battery voltage from ADC [millivolts] */
-unsigned int battery_adc_voltage(void)
+int _battery_voltage(void)
{
unsigned int dummy, bat_val;
diff --git a/firmware/target/mips/ingenic_jz47xx/onda_vx767/sadc-onda_vx767.c b/firmware/target/mips/ingenic_jz47xx/onda_vx767/sadc-onda_vx767.c
index 98dbf08fe9..710da6b729 100644
--- a/firmware/target/mips/ingenic_jz47xx/onda_vx767/sadc-onda_vx767.c
+++ b/firmware/target/mips/ingenic_jz47xx/onda_vx767/sadc-onda_vx767.c
@@ -67,7 +67,7 @@ const unsigned short percent_to_volt_charge[11] =
#define BATTERY_SCALE_FACTOR 1875
/* Returns battery voltage from ADC [millivolts] */
-unsigned int battery_adc_voltage(void)
+int _battery_voltage(void)
{
unsigned int dummy, timeout=HZ/4;
diff --git a/firmware/target/sh/archos/fm_v2/powermgmt-fm_v2.c b/firmware/target/sh/archos/fm_v2/powermgmt-fm_v2.c
index 20596ddedb..5dd7f26d2f 100644
--- a/firmware/target/sh/archos/fm_v2/powermgmt-fm_v2.c
+++ b/firmware/target/sh/archos/fm_v2/powermgmt-fm_v2.c
@@ -54,7 +54,7 @@ const unsigned short percent_to_volt_charge[11] =
/* full-scale ADC readout (2^10) in millivolt */
/* Returns battery voltage from ADC [millivolts] */
-unsigned int battery_adc_voltage(void)
+int _battery_voltage(void)
{
return (adc_read(ADC_UNREG_POWER) * BATTERY_SCALE_FACTOR) >> 10;
}
diff --git a/firmware/target/sh/archos/ondio/powermgmt-ondio.c b/firmware/target/sh/archos/ondio/powermgmt-ondio.c
index dc0c37b9f9..dc3cab031f 100644
--- a/firmware/target/sh/archos/ondio/powermgmt-ondio.c
+++ b/firmware/target/sh/archos/ondio/powermgmt-ondio.c
@@ -46,7 +46,7 @@ const unsigned short percent_to_volt_discharge[BATTERY_TYPES_COUNT][11] =
/* full-scale ADC readout (2^10) in millivolt */
/* Returns battery voltage from ADC [millivolts] */
-unsigned int battery_adc_voltage(void)
+int _battery_voltage(void)
{
return (adc_read(ADC_UNREG_POWER) * BATTERY_SCALE_FACTOR) >> 10;
}
diff --git a/firmware/target/sh/archos/player/powermgmt-player.c b/firmware/target/sh/archos/player/powermgmt-player.c
index b9a4fe3277..8aa03d88a5 100644
--- a/firmware/target/sh/archos/player/powermgmt-player.c
+++ b/firmware/target/sh/archos/player/powermgmt-player.c
@@ -56,7 +56,7 @@ const unsigned short percent_to_volt_charge[11] =
/* full-scale ADC readout (2^10) in millivolt */
/* Returns battery voltage from ADC [millivolts] */
-unsigned int battery_adc_voltage(void)
+int _battery_voltage(void)
{
return (adc_read(ADC_UNREG_POWER) * BATTERY_SCALE_FACTOR) >> 10;
}
diff --git a/firmware/target/sh/archos/recorder/powermgmt-recorder.c b/firmware/target/sh/archos/recorder/powermgmt-recorder.c
index 47f0093456..0bce1585cd 100644
--- a/firmware/target/sh/archos/recorder/powermgmt-recorder.c
+++ b/firmware/target/sh/archos/recorder/powermgmt-recorder.c
@@ -60,7 +60,7 @@ const unsigned short percent_to_volt_charge[11] =
/* full-scale ADC readout (2^10) in millivolt */
/* Returns battery voltage from ADC [millivolts] */
-unsigned int battery_adc_voltage(void)
+int _battery_voltage(void)
{
return (adc_read(ADC_UNREG_POWER) * BATTERY_SCALE_FACTOR) >> 10;
}