summaryrefslogtreecommitdiff
path: root/firmware
diff options
context:
space:
mode:
Diffstat (limited to 'firmware')
-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
8 files changed, 25 insertions, 21 deletions
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;