summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJonathan Gordon <rockbox@jdgordon.info>2007-02-18 05:32:06 +0000
committerJonathan Gordon <rockbox@jdgordon.info>2007-02-18 05:32:06 +0000
commit9a6f419775270340ee154c55dbe52e99682fb77a (patch)
tree188fa4854d2ac5529f701de1bbba29a3241495bc
parentbd47d48c21ddcdd56b3654db78613d93739b8ce7 (diff)
downloadrockbox-9a6f419775270340ee154c55dbe52e99682fb77a.tar.gz
rockbox-9a6f419775270340ee154c55dbe52e99682fb77a.zip
CONFIG_CHARGING
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@12384 a1c6a512-1295-4272-9138-f99709370657
-rw-r--r--apps/debug_menu.c2
-rw-r--r--apps/gui/gwps-common.c2
-rw-r--r--apps/gui/statusbar.c6
-rw-r--r--apps/gui/statusbar.h2
-rw-r--r--apps/main.c6
-rw-r--r--apps/menus/display_menu.c8
-rw-r--r--apps/menus/settings_menu.c8
-rw-r--r--apps/misc.c6
-rw-r--r--apps/plugin.c4
-rw-r--r--apps/plugin.h2
-rw-r--r--apps/plugins/battery_bench.c18
-rw-r--r--apps/screens.c6
-rw-r--r--apps/settings.c6
-rw-r--r--apps/settings.h2
-rw-r--r--apps/settings_list.c8
-rw-r--r--apps/tree.c4
-rw-r--r--firmware/backlight.c18
-rw-r--r--firmware/drivers/button.c2
-rw-r--r--firmware/drivers/power.c2
-rw-r--r--firmware/export/config.h4
-rw-r--r--firmware/export/power.h2
-rw-r--r--firmware/powermgmt.c14
-rw-r--r--firmware/target/coldfire/iriver/h300/power-h300.c2
-rw-r--r--firmware/usb.c2
-rw-r--r--flash/bootbox/main.c4
25 files changed, 72 insertions, 68 deletions
diff --git a/apps/debug_menu.c b/apps/debug_menu.c
index 9d449d78b9..a27ea50fad 100644
--- a/apps/debug_menu.c
+++ b/apps/debug_menu.c
@@ -1411,7 +1411,7 @@ static bool view_battery(void)
1411 snprintf(buf, 30, "External: %d.%02d V", y / 100, y % 100); 1411 snprintf(buf, 30, "External: %d.%02d V", y / 100, y % 100);
1412 lcd_puts(0, 2, buf); 1412 lcd_puts(0, 2, buf);
1413#endif 1413#endif
1414#ifdef CONFIG_CHARGING 1414#if CONFIG_CHARGING
1415#if CONFIG_CHARGING == CHARGING_CONTROL 1415#if CONFIG_CHARGING == CHARGING_CONTROL
1416 snprintf(buf, 30, "Chgr: %s %s", 1416 snprintf(buf, 30, "Chgr: %s %s",
1417 charger_inserted() ? "present" : "absent", 1417 charger_inserted() ? "present" : "absent",
diff --git a/apps/gui/gwps-common.c b/apps/gui/gwps-common.c
index d533e33f9c..0768c32fe9 100644
--- a/apps/gui/gwps-common.c
+++ b/apps/gui/gwps-common.c
@@ -823,7 +823,7 @@ static char* get_tag(struct wps_data* wps_data,
823 } 823 }
824 } 824 }
825 825
826#ifdef CONFIG_CHARGING 826#if CONFIG_CHARGING
827 case 'p': /* External power plugged in? */ 827 case 'p': /* External power plugged in? */
828 { 828 {
829 if(charger_input_state==CHARGER) 829 if(charger_input_state==CHARGER)
diff --git a/apps/gui/statusbar.c b/apps/gui/statusbar.c
index f1bd58d70f..0086abb484 100644
--- a/apps/gui/statusbar.c
+++ b/apps/gui/statusbar.c
@@ -146,7 +146,7 @@ void gui_statusbar_draw(struct gui_statusbar * bar, bool force_redraw)
146#ifdef HAVE_USB_POWER 146#ifdef HAVE_USB_POWER
147 bar->info.usb_inserted = usb_inserted(); 147 bar->info.usb_inserted = usb_inserted();
148#endif 148#endif
149#ifdef CONFIG_CHARGING 149#if CONFIG_CHARGING
150 bar->info.inserted = (charger_input_state == CHARGER); 150 bar->info.inserted = (charger_input_state == CHARGER);
151 if (bar->info.inserted) 151 if (bar->info.inserted)
152 { 152 {
@@ -245,7 +245,7 @@ void gui_statusbar_draw(struct gui_statusbar * bar, bool force_redraw)
245 STATUSBAR_Y_POS, STATUSBAR_PLUG_WIDTH, 245 STATUSBAR_Y_POS, STATUSBAR_PLUG_WIDTH,
246 STATUSBAR_HEIGHT); 246 STATUSBAR_HEIGHT);
247#endif /* HAVE_USB_POWER */ 247#endif /* HAVE_USB_POWER */
248#ifdef CONFIG_CHARGING 248#if CONFIG_CHARGING
249#ifdef HAVE_USB_POWER 249#ifdef HAVE_USB_POWER
250 else 250 else
251#endif 251#endif
@@ -358,7 +358,7 @@ void gui_statusbar_icon_battery(struct screen * display, int percent,
358 unsigned int prevfg = 0; 358 unsigned int prevfg = 0;
359#endif 359#endif
360 360
361#ifdef CONFIG_CHARGING 361#if CONFIG_CHARGING
362 if (batt_charge_step >= 0) 362 if (batt_charge_step >= 0)
363 { 363 {
364 fill = percent * (STATUSBAR_BATTERY_WIDTH-3) / 100; 364 fill = percent * (STATUSBAR_BATTERY_WIDTH-3) / 100;
diff --git a/apps/gui/statusbar.h b/apps/gui/statusbar.h
index 516598dd00..9269a7efe1 100644
--- a/apps/gui/statusbar.h
+++ b/apps/gui/statusbar.h
@@ -40,7 +40,7 @@ struct status_info {
40 int minute; 40 int minute;
41#endif 41#endif
42 42
43#ifdef CONFIG_CHARGING 43#if CONFIG_CHARGING
44 bool inserted; 44 bool inserted;
45#endif 45#endif
46#ifdef HAVE_USB_POWER 46#ifdef HAVE_USB_POWER
diff --git a/apps/main.c b/apps/main.c
index 22eda84f03..a912e07566 100644
--- a/apps/main.c
+++ b/apps/main.c
@@ -293,7 +293,7 @@ static void init(void)
293{ 293{
294 int rc; 294 int rc;
295 bool mounted = false; 295 bool mounted = false;
296#if defined(CONFIG_CHARGING) && (CONFIG_CPU == SH7034) 296#if CONFIG_CHARGING && (CONFIG_CPU == SH7034)
297 /* if nobody initialized ATA before, I consider this a cold start */ 297 /* if nobody initialized ATA before, I consider this a cold start */
298 bool coldstart = (PACR2 & 0x4000) != 0; /* starting from Flash */ 298 bool coldstart = (PACR2 & 0x4000) != 0; /* starting from Flash */
299#endif 299#endif
@@ -372,7 +372,7 @@ static void init(void)
372 screen_access_init(); 372 screen_access_init();
373 gui_syncstatusbar_init(&statusbars); 373 gui_syncstatusbar_init(&statusbars);
374 374
375#if defined(CONFIG_CHARGING) && (CONFIG_CPU == SH7034) 375#if CONFIG_CHARGING && (CONFIG_CPU == SH7034)
376 if (coldstart && charger_inserted() 376 if (coldstart && charger_inserted()
377 && !global_settings.car_adapter_mode 377 && !global_settings.car_adapter_mode
378#ifdef ATA_POWER_PLAYERSTYLE 378#ifdef ATA_POWER_PLAYERSTYLE
@@ -536,7 +536,7 @@ static void init(void)
536 } 536 }
537#endif /* #ifdef AUTOROCK */ 537#endif /* #ifdef AUTOROCK */
538 538
539#ifdef CONFIG_CHARGING 539#if CONFIG_CHARGING
540 car_adapter_mode_init(); 540 car_adapter_mode_init();
541#endif 541#endif
542} 542}
diff --git a/apps/menus/display_menu.c b/apps/menus/display_menu.c
index a1067fc333..5dc14ce5b9 100644
--- a/apps/menus/display_menu.c
+++ b/apps/menus/display_menu.c
@@ -79,7 +79,7 @@ int flipdisplay_callback(int action,const struct menu_item_ex *this_item)
79/* LCD MENU */ 79/* LCD MENU */
80#ifdef CONFIG_BACKLIGHT 80#ifdef CONFIG_BACKLIGHT
81MENUITEM_SETTING(backlight_timeout, &global_settings.backlight_timeout, NULL); 81MENUITEM_SETTING(backlight_timeout, &global_settings.backlight_timeout, NULL);
82#ifdef CONFIG_CHARGING 82#if CONFIG_CHARGING
83MENUITEM_SETTING(backlight_timeout_plugged, 83MENUITEM_SETTING(backlight_timeout_plugged,
84 &global_settings.backlight_timeout_plugged, NULL); 84 &global_settings.backlight_timeout_plugged, NULL);
85#endif 85#endif
@@ -174,7 +174,7 @@ MAKE_MENU(lcd_settings,ID2P(LANG_LCD_MENU),
174 NULL, bitmap_icons_6x8[Icon_Display_menu] 174 NULL, bitmap_icons_6x8[Icon_Display_menu]
175#ifdef CONFIG_BACKLIGHT 175#ifdef CONFIG_BACKLIGHT
176 ,&backlight_timeout 176 ,&backlight_timeout
177# ifdef CONFIG_CHARGING 177# if CONFIG_CHARGING
178 ,&backlight_timeout_plugged 178 ,&backlight_timeout_plugged
179# endif 179# endif
180# ifdef HAS_BUTTON_HOLD 180# ifdef HAS_BUTTON_HOLD
@@ -218,7 +218,7 @@ MAKE_MENU(lcd_settings,ID2P(LANG_LCD_MENU),
218MENUITEM_SETTING(remote_backlight_timeout, 218MENUITEM_SETTING(remote_backlight_timeout,
219 &global_settings.remote_backlight_timeout, NULL); 219 &global_settings.remote_backlight_timeout, NULL);
220 220
221#ifdef CONFIG_CHARGING 221#if CONFIG_CHARGING
222MENUITEM_SETTING(remote_backlight_timeout_plugged, 222MENUITEM_SETTING(remote_backlight_timeout_plugged,
223 &global_settings.remote_backlight_timeout_plugged, NULL); 223 &global_settings.remote_backlight_timeout_plugged, NULL);
224#endif 224#endif
@@ -260,7 +260,7 @@ MENUITEM_SETTING(remote_reduce_ticking,
260MAKE_MENU(lcd_remote_settings, ID2P(LANG_LCD_REMOTE_MENU), 260MAKE_MENU(lcd_remote_settings, ID2P(LANG_LCD_REMOTE_MENU),
261 NULL, bitmap_icons_6x8[Icon_Remote_Display_menu], 261 NULL, bitmap_icons_6x8[Icon_Remote_Display_menu],
262 &remote_backlight_timeout, 262 &remote_backlight_timeout,
263#ifdef CONFIG_CHARGING 263#if CONFIG_CHARGING
264 &remote_backlight_timeout_plugged, 264 &remote_backlight_timeout_plugged,
265#endif 265#endif
266#ifdef HAS_REMOTE_BUTTON_HOLD 266#ifdef HAS_REMOTE_BUTTON_HOLD
diff --git a/apps/menus/settings_menu.c b/apps/menus/settings_menu.c
index 22bd1d8c09..399002cd14 100644
--- a/apps/menus/settings_menu.c
+++ b/apps/menus/settings_menu.c
@@ -110,7 +110,7 @@ MAKE_MENU(file_menu, ID2P(LANG_FILE), 0, NOICON,
110MENUITEM_SETTING(battery_capacity, &global_settings.battery_capacity, NULL); 110MENUITEM_SETTING(battery_capacity, &global_settings.battery_capacity, NULL);
111MENUITEM_SETTING(battery_type, &global_settings.battery_type, NULL); 111MENUITEM_SETTING(battery_type, &global_settings.battery_type, NULL);
112#ifdef HAVE_USB_POWER 112#ifdef HAVE_USB_POWER
113#ifdef CONFIG_CHARGING 113#if CONFIG_CHARGING
114static int usbcharging_callback(int action,const struct menu_item_ex *this_item) 114static int usbcharging_callback(int action,const struct menu_item_ex *this_item)
115{ 115{
116 (void)this_item; 116 (void)this_item;
@@ -131,7 +131,7 @@ MAKE_MENU(battery_menu, ID2P(LANG_BATTERY_MENU), 0, NOICON,
131 &battery_type, 131 &battery_type,
132#endif 132#endif
133#ifdef HAVE_USB_POWER 133#ifdef HAVE_USB_POWER
134#ifdef CONFIG_CHARGING 134#if CONFIG_CHARGING
135 &usb_charging, 135 &usb_charging,
136#endif 136#endif
137#endif 137#endif
@@ -272,7 +272,7 @@ static int linein_callback(int action,const struct menu_item_ex *this_item)
272} 272}
273MENUITEM_SETTING(line_in, &global_settings.line_in, linein_callback); 273MENUITEM_SETTING(line_in, &global_settings.line_in, linein_callback);
274#endif 274#endif
275#ifdef CONFIG_CHARGING 275#if CONFIG_CHARGING
276MENUITEM_SETTING(car_adapter_mode, &global_settings.car_adapter_mode, NULL); 276MENUITEM_SETTING(car_adapter_mode, &global_settings.car_adapter_mode, NULL);
277#endif 277#endif
278 278
@@ -296,7 +296,7 @@ MAKE_MENU(system_menu, ID2P(LANG_SYSTEM),
296#if CONFIG_CODEC == MAS3507D 296#if CONFIG_CODEC == MAS3507D
297 &line_in, 297 &line_in,
298#endif 298#endif
299#ifdef CONFIG_CHARGING 299#if CONFIG_CHARGING
300 &car_adapter_mode, 300 &car_adapter_mode,
301#endif 301#endif
302 ); 302 );
diff --git a/apps/misc.c b/apps/misc.c
index d072d4f881..ad93dc2681 100644
--- a/apps/misc.c
+++ b/apps/misc.c
@@ -595,7 +595,7 @@ static bool clean_shutdown(void (*callback)(void *), void *parameter)
595#else 595#else
596 int i; 596 int i;
597 597
598#if defined(CONFIG_CHARGING) && !defined(HAVE_POWEROFF_WHILE_CHARGING) 598#if CONFIG_CHARGING && !defined(HAVE_POWEROFF_WHILE_CHARGING)
599 if(!charger_inserted()) 599 if(!charger_inserted())
600#endif 600#endif
601 { 601 {
@@ -668,7 +668,7 @@ static bool clean_shutdown(void (*callback)(void *), void *parameter)
668 return false; 668 return false;
669} 669}
670 670
671#ifdef CONFIG_CHARGING 671#if CONFIG_CHARGING
672static bool waiting_to_resume_play = false; 672static bool waiting_to_resume_play = false;
673static long play_resume_tick; 673static long play_resume_tick;
674 674
@@ -774,7 +774,7 @@ long default_event_handler_ex(long event, void (*callback)(void *), void *parame
774 if (!clean_shutdown(callback, parameter)) 774 if (!clean_shutdown(callback, parameter))
775 return SYS_POWEROFF; 775 return SYS_POWEROFF;
776 break; 776 break;
777#ifdef CONFIG_CHARGING 777#if CONFIG_CHARGING
778 case SYS_CHARGER_CONNECTED: 778 case SYS_CHARGER_CONNECTED:
779 car_adapter_mode_processing(true); 779 car_adapter_mode_processing(true);
780 return SYS_CHARGER_CONNECTED; 780 return SYS_CHARGER_CONNECTED;
diff --git a/apps/plugin.c b/apps/plugin.c
index dd82a8da75..ebf048419b 100644
--- a/apps/plugin.c
+++ b/apps/plugin.c
@@ -33,7 +33,7 @@
33#include "splash.h" 33#include "splash.h"
34#include "logf.h" 34#include "logf.h"
35 35
36#ifdef CONFIG_CHARGING 36#if CONFIG_CHARGING
37#include "power.h" 37#include "power.h"
38#endif 38#endif
39 39
@@ -406,7 +406,7 @@ static const struct plugin_api rockbox_api = {
406#ifndef SIMULATOR 406#ifndef SIMULATOR
407 battery_voltage, 407 battery_voltage,
408#endif 408#endif
409#ifdef CONFIG_CHARGING 409#if CONFIG_CHARGING
410 charger_inserted, 410 charger_inserted,
411# if CONFIG_CHARGING == CHARGING_MONITOR 411# if CONFIG_CHARGING == CHARGING_MONITOR
412 charging_state, 412 charging_state,
diff --git a/apps/plugin.h b/apps/plugin.h
index daab88eda1..a48a65dfbb 100644
--- a/apps/plugin.h
+++ b/apps/plugin.h
@@ -510,7 +510,7 @@ struct plugin_api {
510#ifndef SIMULATOR 510#ifndef SIMULATOR
511 unsigned int (*battery_voltage)(void); 511 unsigned int (*battery_voltage)(void);
512#endif 512#endif
513#ifdef CONFIG_CHARGING 513#if CONFIG_CHARGING
514 bool (*charger_inserted)(void); 514 bool (*charger_inserted)(void);
515# if CONFIG_CHARGING == CHARGING_MONITOR 515# if CONFIG_CHARGING == CHARGING_MONITOR
516 bool (*charging_state)(void); 516 bool (*charging_state)(void);
diff --git a/apps/plugins/battery_bench.c b/apps/plugins/battery_bench.c
index 4f1016b7eb..fff3c2fa57 100644
--- a/apps/plugins/battery_bench.c
+++ b/apps/plugins/battery_bench.c
@@ -156,11 +156,11 @@ bool exit_tsr(bool reenter)
156/* use long for aligning */ 156/* use long for aligning */
157unsigned long thread_stack[THREAD_STACK_SIZE/sizeof(long)]; 157unsigned long thread_stack[THREAD_STACK_SIZE/sizeof(long)];
158 158
159#if defined(CONFIG_CHARGING) || defined(HAVE_USB_POWER) 159#if CONFIG_CHARGING || defined(HAVE_USB_POWER)
160unsigned int charge_state(void) 160unsigned int charge_state(void)
161{ 161{
162 unsigned int ret = 0; 162 unsigned int ret = 0;
163#ifdef CONFIG_CHARGING 163#if CONFIG_CHARGING
164 if(rb->charger_inserted()) 164 if(rb->charger_inserted())
165 ret = BIT_CHARGER; 165 ret = BIT_CHARGER;
166#if CONFIG_CHARGING == CHARGING_MONITOR 166#if CONFIG_CHARGING == CHARGING_MONITOR
@@ -182,7 +182,7 @@ void thread(void)
182 int fd, buffelements, tick = 1, i = 0, skipped = 0, exit = 0; 182 int fd, buffelements, tick = 1, i = 0, skipped = 0, exit = 0;
183 int fst = 0, lst = 0; /* first and last skipped tick */ 183 int fst = 0, lst = 0; /* first and last skipped tick */
184 unsigned int last_voltage = 0; 184 unsigned int last_voltage = 0;
185#if defined(CONFIG_CHARGING) || defined(HAVE_USB_POWER) 185#if CONFIG_CHARGING || defined(HAVE_USB_POWER)
186 unsigned int last_state = 0; 186 unsigned int last_state = 0;
187#endif 187#endif
188 long sleep_time; 188 long sleep_time;
@@ -230,7 +230,7 @@ void thread(void)
230 rb->fdprintf(fd, 230 rb->fdprintf(fd,
231 "%02d:%02d:%02d, %05d, %03d%%, " 231 "%02d:%02d:%02d, %05d, %03d%%, "
232 "%02d:%02d, %04d, %04d" 232 "%02d:%02d, %04d, %04d"
233#ifdef CONFIG_CHARGING 233#if CONFIG_CHARGING
234 ", %c" 234 ", %c"
235#if CONFIG_CHARGING == CHARGING_MONITOR 235#if CONFIG_CHARGING == CHARGING_MONITOR
236 ", %c" 236 ", %c"
@@ -243,7 +243,7 @@ void thread(void)
243 243
244 HMS(secs), secs, bat[j].level, 244 HMS(secs), secs, bat[j].level,
245 bat[j].eta / 60, bat[j].eta % 60, 245 bat[j].eta / 60, bat[j].eta % 60,
246#if defined(CONFIG_CHARGING) || defined(HAVE_USB_POWER) 246#if CONFIG_CHARGING || defined(HAVE_USB_POWER)
247 (bat[j].voltage & 247 (bat[j].voltage &
248 (~(BIT_CHARGER|BIT_CHARGING|BIT_USB_POWER))) 248 (~(BIT_CHARGER|BIT_CHARGING|BIT_USB_POWER)))
249 *10, 249 *10,
@@ -251,7 +251,7 @@ void thread(void)
251 bat[j].voltage * 10, 251 bat[j].voltage * 10,
252#endif 252#endif
253 temp + 1 + (j-i) 253 temp + 1 + (j-i)
254#ifdef CONFIG_CHARGING 254#if CONFIG_CHARGING
255 ,(bat[j].voltage & BIT_CHARGER)?'A':'-' 255 ,(bat[j].voltage & BIT_CHARGER)?'A':'-'
256#if CONFIG_CHARGING == CHARGING_MONITOR 256#if CONFIG_CHARGING == CHARGING_MONITOR
257 ,(bat[j].voltage & BIT_CHARGING)?'C':'-' 257 ,(bat[j].voltage & BIT_CHARGING)?'C':'-'
@@ -288,7 +288,7 @@ void thread(void)
288 timeflag = true; 288 timeflag = true;
289 289
290 if(last_voltage != (current_voltage=rb->battery_voltage()) 290 if(last_voltage != (current_voltage=rb->battery_voltage())
291#if defined(CONFIG_CHARGING) || defined(HAVE_USB_POWER) 291#if CONFIG_CHARGING || defined(HAVE_USB_POWER)
292 || last_state != charge_state() 292 || last_state != charge_state()
293#endif 293#endif
294 ) 294 )
@@ -308,7 +308,7 @@ void thread(void)
308 bat[i].level = rb->battery_level(); 308 bat[i].level = rb->battery_level();
309 bat[i].eta = rb->battery_time(); 309 bat[i].eta = rb->battery_time();
310 last_voltage = bat[i].voltage = current_voltage; 310 last_voltage = bat[i].voltage = current_voltage;
311#if defined(CONFIG_CHARGING) || defined(HAVE_USB_POWER) 311#if CONFIG_CHARGING || defined(HAVE_USB_POWER)
312 bat[i].voltage |= last_state = charge_state(); 312 bat[i].voltage |= last_state = charge_state();
313#endif 313#endif
314 i++; 314 i++;
@@ -448,7 +448,7 @@ int main(void)
448 "Battery type: %d mAh Buffer Entries: %d\n" 448 "Battery type: %d mAh Buffer Entries: %d\n"
449 " Time:, Seconds:, Level:, Time Left:, Voltage[mV]:," 449 " Time:, Seconds:, Level:, Time Left:, Voltage[mV]:,"
450 " M/DA:" 450 " M/DA:"
451#ifdef CONFIG_CHARGING 451#if CONFIG_CHARGING
452 ", C:" 452 ", C:"
453#endif 453#endif
454#if CONFIG_CHARGING == CHARGING_MONITOR 454#if CONFIG_CHARGING == CHARGING_MONITOR
diff --git a/apps/screens.c b/apps/screens.c
index d74b7c193c..c7841c66b3 100644
--- a/apps/screens.c
+++ b/apps/screens.c
@@ -171,7 +171,7 @@ int mmc_remove_request(void)
171} 171}
172#endif 172#endif
173 173
174#if defined(CONFIG_CHARGING) && !defined(HAVE_POWEROFF_WHILE_CHARGING) 174#if CONFIG_CHARGING && !defined(HAVE_POWEROFF_WHILE_CHARGING)
175 175
176#ifdef HAVE_LCD_BITMAP 176#ifdef HAVE_LCD_BITMAP
177static void charging_display_info(bool animate) 177static void charging_display_info(bool animate)
@@ -778,7 +778,7 @@ bool quick_screen_f3(int button_enter)
778#endif /* BUTTON_F3 */ 778#endif /* BUTTON_F3 */
779#endif /* CONFIG_KEYPAD in (RECORDER_PAD |IRIVER_H100_PAD | IRIVER_H300_PAD) */ 779#endif /* CONFIG_KEYPAD in (RECORDER_PAD |IRIVER_H100_PAD | IRIVER_H300_PAD) */
780 780
781#if defined(CONFIG_CHARGING) || defined(SIMULATOR) 781#if CONFIG_CHARGING || defined(SIMULATOR)
782void charging_splash(void) 782void charging_splash(void)
783{ 783{
784 gui_syncsplash(2*HZ, true, (unsigned char *)str(LANG_BATTERY_CHARGE)); 784 gui_syncsplash(2*HZ, true, (unsigned char *)str(LANG_BATTERY_CHARGE));
@@ -1342,7 +1342,7 @@ bool view_runtime(void)
1342 } 1342 }
1343 1343
1344 if (state & 1) { 1344 if (state & 1) {
1345#ifdef CONFIG_CHARGING 1345#if CONFIG_CHARGING
1346 if (charger_inserted() 1346 if (charger_inserted()
1347#ifdef HAVE_USB_POWER 1347#ifdef HAVE_USB_POWER
1348 || usb_powered() 1348 || usb_powered()
diff --git a/apps/settings.c b/apps/settings.c
index 1a1a085ec7..8c51181ea0 100644
--- a/apps/settings.c
+++ b/apps/settings.c
@@ -665,7 +665,7 @@ void sound_settings_apply(void)
665#endif 665#endif
666 666
667#ifdef HAVE_USB_POWER 667#ifdef HAVE_USB_POWER
668#ifdef CONFIG_CHARGING 668#if CONFIG_CHARGING
669 usb_charging_enable(global_settings.usb_charging); 669 usb_charging_enable(global_settings.usb_charging);
670#endif 670#endif
671#endif 671#endif
@@ -699,7 +699,7 @@ void settings_apply(void)
699 lcd_remote_emireduce(global_settings.remote_reduce_ticking); 699 lcd_remote_emireduce(global_settings.remote_reduce_ticking);
700#endif 700#endif
701 remote_backlight_set_timeout(global_settings.remote_backlight_timeout); 701 remote_backlight_set_timeout(global_settings.remote_backlight_timeout);
702#ifdef CONFIG_CHARGING 702#if CONFIG_CHARGING
703 remote_backlight_set_timeout_plugged(global_settings.remote_backlight_timeout_plugged); 703 remote_backlight_set_timeout_plugged(global_settings.remote_backlight_timeout_plugged);
704#endif 704#endif
705#ifdef HAS_REMOTE_BUTTON_HOLD 705#ifdef HAS_REMOTE_BUTTON_HOLD
@@ -708,7 +708,7 @@ void settings_apply(void)
708#endif /* HAVE_REMOTE_LCD */ 708#endif /* HAVE_REMOTE_LCD */
709#ifdef CONFIG_BACKLIGHT 709#ifdef CONFIG_BACKLIGHT
710 backlight_set_timeout(global_settings.backlight_timeout); 710 backlight_set_timeout(global_settings.backlight_timeout);
711#ifdef CONFIG_CHARGING 711#if CONFIG_CHARGING
712 backlight_set_timeout_plugged(global_settings.backlight_timeout_plugged); 712 backlight_set_timeout_plugged(global_settings.backlight_timeout_plugged);
713#endif 713#endif
714#if defined(HAVE_BACKLIGHT_PWM_FADING) && !defined(SIMULATOR) 714#if defined(HAVE_BACKLIGHT_PWM_FADING) && !defined(SIMULATOR)
diff --git a/apps/settings.h b/apps/settings.h
index 35eed906fb..af1d65d78f 100644
--- a/apps/settings.h
+++ b/apps/settings.h
@@ -629,7 +629,7 @@ struct user_settings
629#endif 629#endif
630 630
631#ifdef HAVE_USB_POWER 631#ifdef HAVE_USB_POWER
632#ifdef CONFIG_CHARGING 632#if CONFIG_CHARGING
633 bool usb_charging; 633 bool usb_charging;
634#endif 634#endif
635#endif 635#endif
diff --git a/apps/settings_list.c b/apps/settings_list.c
index 37fa7c53c3..ee70e8c40b 100644
--- a/apps/settings_list.c
+++ b/apps/settings_list.c
@@ -415,7 +415,7 @@ const struct settings_list settings[] = {
415 "backlight timeout", backlight_times_conf, UNIT_SEC, 415 "backlight timeout", backlight_times_conf, UNIT_SEC,
416 0, 18, 1, backlight_formatter, backlight_getlang, 416 0, 18, 1, backlight_formatter, backlight_getlang,
417 backlight_set_timeout), 417 backlight_set_timeout),
418#ifdef CONFIG_CHARGING 418#if CONFIG_CHARGING
419 INT_SETTING_W_CFGVALS(0, backlight_timeout_plugged, 419 INT_SETTING_W_CFGVALS(0, backlight_timeout_plugged,
420 LANG_BACKLIGHT_ON_WHEN_CHARGING, 11, 420 LANG_BACKLIGHT_ON_WHEN_CHARGING, 11,
421 "backlight timeout plugged", backlight_times_conf, UNIT_SEC, 421 "backlight timeout plugged", backlight_times_conf, UNIT_SEC,
@@ -475,7 +475,7 @@ const struct settings_list settings[] = {
475 BATTERY_CAPACITY_MIN, BATTERY_CAPACITY_MAX, BATTERY_CAPACITY_INC, 475 BATTERY_CAPACITY_MIN, BATTERY_CAPACITY_MAX, BATTERY_CAPACITY_INC,
476 NULL, NULL, NULL), 476 NULL, NULL, NULL),
477#endif 477#endif
478#ifdef CONFIG_CHARGING 478#if CONFIG_CHARGING
479 OFFON_SETTING(NVRAM(1), car_adapter_mode, 479 OFFON_SETTING(NVRAM(1), car_adapter_mode,
480 LANG_CAR_ADAPTER_MODE, false, "car adapter mode", NULL), 480 LANG_CAR_ADAPTER_MODE, false, "car adapter mode", NULL),
481#endif 481#endif
@@ -504,7 +504,7 @@ const struct settings_list settings[] = {
504 "remote backlight timeout", backlight_times_conf, UNIT_SEC, 504 "remote backlight timeout", backlight_times_conf, UNIT_SEC,
505 0, 18, 1, backlight_formatter, backlight_getlang, 505 0, 18, 1, backlight_formatter, backlight_getlang,
506 remote_backlight_set_timeout), 506 remote_backlight_set_timeout),
507#ifdef CONFIG_CHARGING 507#if CONFIG_CHARGING
508 INT_SETTING_W_CFGVALS(0, remote_backlight_timeout_plugged, LANG_BACKLIGHT, 11, 508 INT_SETTING_W_CFGVALS(0, remote_backlight_timeout_plugged, LANG_BACKLIGHT, 11,
509 "remote backlight timeout plugged", backlight_times_conf, UNIT_SEC, 509 "remote backlight timeout plugged", backlight_times_conf, UNIT_SEC,
510 0, 18, 1, backlight_formatter, backlight_getlang, 510 0, 18, 1, backlight_formatter, backlight_getlang,
@@ -1057,7 +1057,7 @@ const struct settings_list settings[] = {
1057 FILENAME_SETTING(0,kbd_file,"kbd","",ROCKBOX_DIR "/",".kbd",MAX_FILENAME+1), 1057 FILENAME_SETTING(0,kbd_file,"kbd","",ROCKBOX_DIR "/",".kbd",MAX_FILENAME+1),
1058#endif 1058#endif
1059#ifdef HAVE_USB_POWER 1059#ifdef HAVE_USB_POWER
1060#ifdef CONFIG_CHARGING 1060#if CONFIG_CHARGING
1061 OFFON_SETTING(0,usb_charging,LANG_USB_CHARGING,false,"usb charging",NULL), 1061 OFFON_SETTING(0,usb_charging,LANG_USB_CHARGING,false,"usb charging",NULL),
1062#endif 1062#endif
1063#endif 1063#endif
diff --git a/apps/tree.c b/apps/tree.c
index 320e8f7e66..3074752add 100644
--- a/apps/tree.c
+++ b/apps/tree.c
@@ -742,7 +742,7 @@ static bool dirbrowse(void)
742 audio_stop(); 742 audio_stop();
743 } 743 }
744 } 744 }
745#if defined(CONFIG_CHARGING) && \ 745#if CONFIG_CHARGING && \
746 (CONFIG_KEYPAD == RECORDER_PAD) && !defined(HAVE_SW_POWEROFF) 746 (CONFIG_KEYPAD == RECORDER_PAD) && !defined(HAVE_SW_POWEROFF)
747 else { 747 else {
748 if (!charger_inserted()) { 748 if (!charger_inserted()) {
@@ -755,7 +755,7 @@ static bool dirbrowse(void)
755 } 755 }
756#endif 756#endif
757 } 757 }
758#if defined(CONFIG_CHARGING) && !defined(HAVE_POWEROFF_WHILE_CHARGING) 758#if CONFIG_CHARGING && !defined(HAVE_POWEROFF_WHILE_CHARGING)
759{ 759{
760 static int last_off = 0; 760 static int last_off = 0;
761 if (current_tick - last_off < 50) { 761 if (current_tick - last_off < 50) {
diff --git a/firmware/backlight.c b/firmware/backlight.c
index d621aa42d1..99da3df0a8 100644
--- a/firmware/backlight.c
+++ b/firmware/backlight.c
@@ -116,7 +116,7 @@ static struct event_queue backlight_queue;
116 116
117static int backlight_timer; 117static int backlight_timer;
118static int backlight_timeout = 5*HZ; 118static int backlight_timeout = 5*HZ;
119#ifdef CONFIG_CHARGING 119#if CONFIG_CHARGING
120static int backlight_timeout_plugged = 5*HZ; 120static int backlight_timeout_plugged = 5*HZ;
121#endif 121#endif
122#ifdef HAS_BUTTON_HOLD 122#ifdef HAS_BUTTON_HOLD
@@ -126,7 +126,7 @@ static int backlight_on_button_hold = 0;
126#ifdef HAVE_REMOTE_LCD 126#ifdef HAVE_REMOTE_LCD
127static int remote_backlight_timer; 127static int remote_backlight_timer;
128static int remote_backlight_timeout = 5*HZ; 128static int remote_backlight_timeout = 5*HZ;
129#ifdef CONFIG_CHARGING 129#if CONFIG_CHARGING
130static int remote_backlight_timeout_plugged = 5*HZ; 130static int remote_backlight_timeout_plugged = 5*HZ;
131#endif 131#endif
132#ifdef HAS_REMOTE_BUTTON_HOLD 132#ifdef HAS_REMOTE_BUTTON_HOLD
@@ -347,7 +347,7 @@ static void __remote_backlight_off(void)
347/* Update state of backlight according to timeout setting */ 347/* Update state of backlight according to timeout setting */
348static void backlight_update_state(void) 348static void backlight_update_state(void)
349{ 349{
350#ifdef CONFIG_CHARGING 350#if CONFIG_CHARGING
351 if (charger_inserted() 351 if (charger_inserted()
352#ifdef HAVE_USB_POWER 352#ifdef HAVE_USB_POWER
353 || usb_powered() 353 || usb_powered()
@@ -386,7 +386,7 @@ static void backlight_update_state(void)
386/* Update state of remote backlight according to timeout setting */ 386/* Update state of remote backlight according to timeout setting */
387static void remote_backlight_update_state(void) 387static void remote_backlight_update_state(void)
388{ 388{
389#ifdef CONFIG_CHARGING 389#if CONFIG_CHARGING
390 if (charger_inserted() 390 if (charger_inserted()
391#ifdef HAVE_USB_POWER 391#ifdef HAVE_USB_POWER
392 || usb_powered() 392 || usb_powered()
@@ -503,7 +503,7 @@ void backlight_thread(void)
503 503
504static void backlight_tick(void) 504static void backlight_tick(void)
505{ 505{
506#ifdef CONFIG_CHARGING 506#if CONFIG_CHARGING
507 static bool charger_was_inserted = false; 507 static bool charger_was_inserted = false;
508 bool charger_is_inserted = charger_inserted() 508 bool charger_is_inserted = charger_inserted()
509#ifdef HAVE_USB_POWER 509#ifdef HAVE_USB_POWER
@@ -622,7 +622,7 @@ bool is_backlight_on(void)
622/* return value in ticks; 0 means always on, <0 means always off */ 622/* return value in ticks; 0 means always on, <0 means always off */
623int backlight_get_current_timeout(void) 623int backlight_get_current_timeout(void)
624{ 624{
625#ifdef CONFIG_CHARGING 625#if CONFIG_CHARGING
626 if (charger_inserted() 626 if (charger_inserted()
627#ifdef HAVE_USB_POWER 627#ifdef HAVE_USB_POWER
628 || usb_powered() 628 || usb_powered()
@@ -645,7 +645,7 @@ void backlight_set_timeout(int index)
645 backlight_update_state(); 645 backlight_update_state();
646} 646}
647 647
648#ifdef CONFIG_CHARGING 648#if CONFIG_CHARGING
649void backlight_set_timeout_plugged(int index) 649void backlight_set_timeout_plugged(int index)
650{ 650{
651 if((unsigned)index >= sizeof(backlight_timeout_value)) 651 if((unsigned)index >= sizeof(backlight_timeout_value))
@@ -724,7 +724,7 @@ void remote_backlight_set_timeout(int index)
724 remote_backlight_update_state(); 724 remote_backlight_update_state();
725} 725}
726 726
727#ifdef CONFIG_CHARGING 727#if CONFIG_CHARGING
728void remote_backlight_set_timeout_plugged(int index) 728void remote_backlight_set_timeout_plugged(int index)
729{ 729{
730 if((unsigned)index >= sizeof(backlight_timeout_value)) 730 if((unsigned)index >= sizeof(backlight_timeout_value))
@@ -766,7 +766,7 @@ void remote_backlight_set_on_button_hold(int index)
766/* return value in ticks; 0 means always on, <0 means always off */ 766/* return value in ticks; 0 means always on, <0 means always off */
767int remote_backlight_get_current_timeout(void) 767int remote_backlight_get_current_timeout(void)
768{ 768{
769#ifdef CONFIG_CHARGING 769#if CONFIG_CHARGING
770 if (charger_inserted() 770 if (charger_inserted()
771#ifdef HAVE_USB_POWER 771#ifdef HAVE_USB_POWER
772 || usb_powered() 772 || usb_powered()
diff --git a/firmware/drivers/button.c b/firmware/drivers/button.c
index cab62f950c..5a40bdfde0 100644
--- a/firmware/drivers/button.c
+++ b/firmware/drivers/button.c
@@ -164,7 +164,7 @@ static void button_tick(void)
164 || btn == RC_POWEROFF_BUTTON 164 || btn == RC_POWEROFF_BUTTON
165#endif 165#endif
166 ) && 166 ) &&
167#if defined(CONFIG_CHARGING) && !defined(HAVE_POWEROFF_WHILE_CHARGING) 167#if CONFIG_CHARGING && !defined(HAVE_POWEROFF_WHILE_CHARGING)
168 !charger_inserted() && 168 !charger_inserted() &&
169#endif 169#endif
170 repeat_count > POWEROFF_COUNT) 170 repeat_count > POWEROFF_COUNT)
diff --git a/firmware/drivers/power.c b/firmware/drivers/power.c
index 872e8b0657..78e70f7466 100644
--- a/firmware/drivers/power.c
+++ b/firmware/drivers/power.c
@@ -83,7 +83,7 @@ void power_init(void)
83} 83}
84 84
85 85
86#ifdef CONFIG_CHARGING 86#if CONFIG_CHARGING
87bool charger_inserted(void) 87bool charger_inserted(void)
88{ 88{
89#if CONFIG_CHARGING == CHARGING_CONTROL 89#if CONFIG_CHARGING == CHARGING_CONTROL
diff --git a/firmware/export/config.h b/firmware/export/config.h
index 0a59c0bf89..8283b37fc8 100644
--- a/firmware/export/config.h
+++ b/firmware/export/config.h
@@ -230,6 +230,10 @@
230#define CONFIG_LED 0 230#define CONFIG_LED 0
231#endif 231#endif
232 232
233#ifndef CONFIG_CHARGING
234#define CONFIG_CHARGING 0
235#endif
236
233/* Enable the directory cache and tagcache in RAM if we have 237/* Enable the directory cache and tagcache in RAM if we have
234 * plenty of RAM. Both features can be enabled independently. */ 238 * plenty of RAM. Both features can be enabled independently. */
235#if ((defined(MEMORYSIZE) && (MEMORYSIZE > 8)) || MEM > 8) && \ 239#if ((defined(MEMORYSIZE) && (MEMORYSIZE > 8)) || MEM > 8) && \
diff --git a/firmware/export/power.h b/firmware/export/power.h
index 911ae1dd29..9eed1929fe 100644
--- a/firmware/export/power.h
+++ b/firmware/export/power.h
@@ -24,7 +24,7 @@ extern bool charger_enabled;
24void charger_enable(bool on); 24void charger_enable(bool on);
25#endif 25#endif
26 26
27#ifdef CONFIG_CHARGING 27#if CONFIG_CHARGING
28bool charger_inserted(void); 28bool charger_inserted(void);
29#endif 29#endif
30 30
diff --git a/firmware/powermgmt.c b/firmware/powermgmt.c
index 88fc5e8e33..a31acbcf0b 100644
--- a/firmware/powermgmt.c
+++ b/firmware/powermgmt.c
@@ -266,7 +266,7 @@ static const unsigned short percent_to_volt_discharge[BATTERY_TYPES_COUNT][11] =
266#endif 266#endif
267}; 267};
268 268
269#ifdef CONFIG_CHARGING 269#if CONFIG_CHARGING
270charger_input_state_type charger_input_state IDATA_ATTR; 270charger_input_state_type charger_input_state IDATA_ATTR;
271 271
272 272
@@ -545,7 +545,7 @@ static void battery_status_update(void)
545 / 100 / (CURRENT_MAX_CHG - runcurrent()); 545 / 100 / (CURRENT_MAX_CHG - runcurrent());
546 } 546 }
547 else 547 else
548#elif defined(CONFIG_CHARGING) && CONFIG_BATTERY == BATT_LIPOL1300 548#elif CONFIG_CHARGING && CONFIG_BATTERY == BATT_LIPOL1300
549 if (charger_inserted()) { 549 if (charger_inserted()) {
550#ifdef IRIVER_H300_SERIES 550#ifdef IRIVER_H300_SERIES
551 /* H300_SERIES use CURRENT_MAX_CHG for basic charge time (80%) 551 /* H300_SERIES use CURRENT_MAX_CHG for basic charge time (80%)
@@ -612,7 +612,7 @@ static void handle_auto_poweroff(void)
612 long timeout = poweroff_idle_timeout_value[poweroff_timeout]*60*HZ; 612 long timeout = poweroff_idle_timeout_value[poweroff_timeout]*60*HZ;
613 int audio_stat = audio_status(); 613 int audio_stat = audio_status();
614 614
615#ifdef CONFIG_CHARGING 615#if CONFIG_CHARGING
616 /* 616 /*
617 * Inhibit shutdown as long as the charger is plugged in. If it is 617 * Inhibit shutdown as long as the charger is plugged in. If it is
618 * unplugged, wait for a timeout period and then shut down. 618 * unplugged, wait for a timeout period and then shut down.
@@ -656,7 +656,7 @@ static void handle_auto_poweroff(void)
656 if(TIME_AFTER(current_tick, sleeptimer_endtick)) 656 if(TIME_AFTER(current_tick, sleeptimer_endtick))
657 { 657 {
658 audio_stop(); 658 audio_stop();
659#if defined(CONFIG_CHARGING) && !defined(HAVE_POWEROFF_WHILE_CHARGING) 659#if CONFIG_CHARGING && !defined(HAVE_POWEROFF_WHILE_CHARGING)
660 if((charger_input_state == CHARGER) || 660 if((charger_input_state == CHARGER) ||
661 (charger_input_state == CHARGER_PLUGGED)) 661 (charger_input_state == CHARGER_PLUGGED))
662 { 662 {
@@ -751,7 +751,7 @@ static void power_thread_sleep(int ticks)
751 751
752 while (ticks > 0) { 752 while (ticks > 0) {
753 753
754#ifdef CONFIG_CHARGING 754#if CONFIG_CHARGING
755 /* 755 /*
756 * Detect charger plugged/unplugged transitions. On a plugged or 756 * Detect charger plugged/unplugged transitions. On a plugged or
757 * unplugged event, we return immediately, run once through the main 757 * unplugged event, we return immediately, run once through the main
@@ -761,7 +761,7 @@ static void power_thread_sleep(int ticks)
761 if(charger_inserted() 761 if(charger_inserted()
762#ifdef HAVE_USB_POWER /* USB powered or USB inserted both provide power */ 762#ifdef HAVE_USB_POWER /* USB powered or USB inserted both provide power */
763 || usb_powered() 763 || usb_powered()
764#ifdef CONFIG_CHARGING 764#if CONFIG_CHARGING
765 || (usb_inserted() && usb_charging_enabled()) 765 || (usb_inserted() && usb_charging_enabled())
766#endif 766#endif
767#endif 767#endif
@@ -924,7 +924,7 @@ static void power_thread(void)
924 avgbat = avgbat * BATT_AVE_SAMPLES; 924 avgbat = avgbat * BATT_AVE_SAMPLES;
925 battery_centivolts = avgbat / BATT_AVE_SAMPLES / 10000; 925 battery_centivolts = avgbat / BATT_AVE_SAMPLES / 10000;
926 926
927#ifdef CONFIG_CHARGING 927#if CONFIG_CHARGING
928 if(charger_inserted()) { 928 if(charger_inserted()) {
929 battery_percent = voltage_to_percent(battery_centivolts, 929 battery_percent = voltage_to_percent(battery_centivolts,
930 percent_to_volt_charge); 930 percent_to_volt_charge);
diff --git a/firmware/target/coldfire/iriver/h300/power-h300.c b/firmware/target/coldfire/iriver/h300/power-h300.c
index 7c95aaf200..3d726d0714 100644
--- a/firmware/target/coldfire/iriver/h300/power-h300.c
+++ b/firmware/target/coldfire/iriver/h300/power-h300.c
@@ -61,7 +61,7 @@ void power_init(void)
61} 61}
62 62
63 63
64#ifdef CONFIG_CHARGING 64#if CONFIG_CHARGING
65bool charger_inserted(void) 65bool charger_inserted(void)
66{ 66{
67 return (GPIO1_READ & 0x00400000)?true:false; 67 return (GPIO1_READ & 0x00400000)?true:false;
diff --git a/firmware/usb.c b/firmware/usb.c
index 0a329ad624..ee08b04caa 100644
--- a/firmware/usb.c
+++ b/firmware/usb.c
@@ -492,7 +492,7 @@ bool usb_powered(void)
492 return usb_state == USB_POWERED; 492 return usb_state == USB_POWERED;
493} 493}
494 494
495#ifdef CONFIG_CHARGING 495#if CONFIG_CHARGING
496bool usb_charging_enable(bool on) 496bool usb_charging_enable(bool on)
497{ 497{
498 bool rc = false; 498 bool rc = false;
diff --git a/flash/bootbox/main.c b/flash/bootbox/main.c
index e3af78e721..9536d531f4 100644
--- a/flash/bootbox/main.c
+++ b/flash/bootbox/main.c
@@ -65,7 +65,7 @@ int show_logo(void)
65 return 0; 65 return 0;
66} 66}
67 67
68#ifdef CONFIG_CHARGING 68#if CONFIG_CHARGING
69/* 69/*
70bool backlight_get_on_when_charging(void) 70bool backlight_get_on_when_charging(void)
71{ 71{
@@ -167,7 +167,7 @@ void main(void)
167 button_init(); 167 button_init();
168 powermgmt_init(); 168 powermgmt_init();
169 169
170#if defined(CONFIG_CHARGING) && (CONFIG_CPU == SH7034) 170#if CONFIG_CHARGING && (CONFIG_CPU == SH7034)
171 if (charger_inserted() 171 if (charger_inserted()
172#ifdef ATA_POWER_PLAYERSTYLE 172#ifdef ATA_POWER_PLAYERSTYLE
173 && !ide_powered() /* relies on probing result from bootloader */ 173 && !ide_powered() /* relies on probing result from bootloader */