summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJens Arnold <amiconn@rockbox.org>2007-11-12 18:49:53 +0000
committerJens Arnold <amiconn@rockbox.org>2007-11-12 18:49:53 +0000
commitef12b3b5c678e4fa44d60061b0c1bc312e589ba1 (patch)
tree4c2572d7bf3d995be16b33fa2e46ccccad34f4ee
parent8537cbf091634efa57768dccff39049afdf6d288 (diff)
downloadrockbox-ef12b3b5c678e4fa44d60061b0c1bc312e589ba1.tar.gz
rockbox-ef12b3b5c678e4fa44d60061b0c1bc312e589ba1.tar.bz2
rockbox-ef12b3b5c678e4fa44d60061b0c1bc312e589ba1.zip
Hardware controlled backlight brightness for iPod Video and Nano, retaining the software PWM fade in/ fade out. * Backlight handling cleanup, getting rid of one layer of 'lowlevelness'. * Use atomic GPIO bit manipulation for PP502x backlight handling.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@15599 a1c6a512-1295-4272-9138-f99709370657
-rw-r--r--bootloader/iaudio_x5.c4
-rw-r--r--bootloader/ipod.c2
-rw-r--r--bootloader/iriver_h300.c10
-rw-r--r--bootloader/main-e200r-installer.c2
-rw-r--r--bootloader/main-pp.c2
-rw-r--r--bootloader/main.c12
-rw-r--r--bootloader/telechips.c2
-rw-r--r--firmware/backlight.c207
-rw-r--r--firmware/export/backlight.h9
-rw-r--r--firmware/export/config-ipodnano.h6
-rw-r--r--firmware/export/config-ipodvideo.h6
-rw-r--r--firmware/target/arm/imx31/gigabeat-s/backlight-imx31.c8
-rw-r--r--firmware/target/arm/imx31/gigabeat-s/backlight-target.h8
-rw-r--r--firmware/target/arm/ipod/1g2g/backlight-1g2g.c4
-rw-r--r--firmware/target/arm/ipod/1g2g/backlight-target.h6
-rw-r--r--firmware/target/arm/ipod/3g/backlight-3g.c4
-rw-r--r--firmware/target/arm/ipod/backlight-4g_color.c6
-rw-r--r--firmware/target/arm/ipod/backlight-mini1g_mini2g.c10
-rw-r--r--firmware/target/arm/ipod/backlight-nano_video.c87
-rw-r--r--firmware/target/arm/ipod/backlight-target.h36
-rw-r--r--firmware/target/arm/iriver/backlight-target.h6
-rw-r--r--firmware/target/arm/iriver/h10/backlight-h10.c21
-rw-r--r--firmware/target/arm/pnx0101/backlight-target.h6
-rw-r--r--firmware/target/arm/pnx0101/iriver-ifp7xx/backlight-ifp7xx.c4
-rw-r--r--firmware/target/arm/s3c2440/gigabeat-fx/backlight-meg-fx.c70
-rw-r--r--firmware/target/arm/s3c2440/gigabeat-fx/backlight-target.h22
-rw-r--r--firmware/target/arm/s3c2440/gigabeat-fx/power-meg-fx.c4
-rw-r--r--firmware/target/arm/sandisk/backlight-c200_e200.c38
-rw-r--r--firmware/target/arm/sandisk/backlight-target.h14
-rw-r--r--firmware/target/arm/tatung/tpj1022/backlight-target.h6
-rw-r--r--firmware/target/arm/tatung/tpj1022/backlight-tpj1022.c6
-rw-r--r--firmware/target/arm/tcc77x/logikdax/backlight-target.h6
-rw-r--r--firmware/target/arm/tms320dm320/mrobe-500/backlight-mr500.c16
-rw-r--r--firmware/target/arm/tms320dm320/mrobe-500/backlight-target.h8
-rw-r--r--firmware/target/arm/tms320dm320/mrobe-500/power-mr500.c2
-rw-r--r--firmware/target/coldfire/iaudio/m5/backlight-m5.c12
-rw-r--r--firmware/target/coldfire/iaudio/m5/backlight-target.h10
-rw-r--r--firmware/target/coldfire/iaudio/x5/backlight-target.h12
-rw-r--r--firmware/target/coldfire/iaudio/x5/backlight-x5.c25
-rw-r--r--firmware/target/coldfire/iriver/h100/backlight-h100.c10
-rw-r--r--firmware/target/coldfire/iriver/h100/backlight-target.h35
-rw-r--r--firmware/target/coldfire/iriver/h300/backlight-h300.c12
-rw-r--r--firmware/target/coldfire/iriver/h300/backlight-target.h (renamed from firmware/target/coldfire/iriver/backlight-target.h)14
-rw-r--r--firmware/target/sh/archos/fm_v2/backlight-target.h6
-rw-r--r--firmware/target/sh/archos/ondio/backlight-target.h6
-rw-r--r--firmware/target/sh/archos/player/backlight-target.h6
-rw-r--r--firmware/target/sh/archos/recorder/backlight-target.h6
47 files changed, 493 insertions, 321 deletions
diff --git a/bootloader/iaudio_x5.c b/bootloader/iaudio_x5.c
index d6ee7176ca..3cfbb7aec7 100644
--- a/bootloader/iaudio_x5.c
+++ b/bootloader/iaudio_x5.c
@@ -93,9 +93,9 @@ void shutdown(void)
sleep(HZ*2);
/* Backlight OFF */
- __backlight_off();
+ _backlight_off();
#ifdef HAVE_REMOTE_LCD
- __remote_backlight_off();
+ _remote_backlight_off();
#endif
__reset_cookie();
diff --git a/bootloader/ipod.c b/bootloader/ipod.c
index 441bda860c..816f13adde 100644
--- a/bootloader/ipod.c
+++ b/bootloader/ipod.c
@@ -239,7 +239,7 @@ void* main(void)
#ifndef HAVE_BACKLIGHT_INVERSION
/* Turn on the backlight */
- __backlight_on();
+ _backlight_on();
#endif
system_init();
diff --git a/bootloader/iriver_h300.c b/bootloader/iriver_h300.c
index a3a15bd4b5..5b742044eb 100644
--- a/bootloader/iriver_h300.c
+++ b/bootloader/iriver_h300.c
@@ -100,8 +100,8 @@ void shutdown(void)
sleep(HZ*2);
- __backlight_off();
- __remote_backlight_off();
+ _backlight_off();
+ _remote_backlight_off();
__reset_cookie();
power_off();
@@ -177,10 +177,10 @@ void main(void)
audiohw_reset();
/* Start with the main backlight OFF. */
- __backlight_init();
- __backlight_off();
+ _backlight_init();
+ _backlight_off();
- __remote_backlight_on();
+ _remote_backlight_on();
system_init();
kernel_init();
diff --git a/bootloader/main-e200r-installer.c b/bootloader/main-e200r-installer.c
index b128a3445a..46c1f9a2ff 100644
--- a/bootloader/main-e200r-installer.c
+++ b/bootloader/main-e200r-installer.c
@@ -102,7 +102,7 @@ void* main(void)
font_init();
button_init();
i2c_init();
- __backlight_on();
+ _backlight_on();
lcd_set_foreground(LCD_WHITE);
lcd_set_background(LCD_BLACK);
diff --git a/bootloader/main-pp.c b/bootloader/main-pp.c
index acc916e8a4..3c498d9ee1 100644
--- a/bootloader/main-pp.c
+++ b/bootloader/main-pp.c
@@ -441,7 +441,7 @@ void* main(void)
button_init();
#if defined(SANSA_E200)
i2c_init();
- __backlight_on();
+ _backlight_on();
#endif
lcd_set_foreground(LCD_WHITE);
diff --git a/bootloader/main.c b/bootloader/main.c
index e60799fa65..8d58ca71d0 100644
--- a/bootloader/main.c
+++ b/bootloader/main.c
@@ -156,9 +156,9 @@ void shutdown(void)
sleep(HZ*2);
/* Backlight OFF */
- __backlight_off();
+ _backlight_off();
#ifdef HAVE_REMOTE_LCD
- __remote_backlight_off();
+ _remote_backlight_off();
#endif
__reset_cookie();
@@ -395,12 +395,12 @@ void main(void)
}
/* Start with the main backlight OFF. */
- __backlight_init();
- __backlight_off();
+ _backlight_init();
+ _backlight_off();
/* Remote backlight ON */
#ifdef HAVE_REMOTE_LCD
- __remote_backlight_on();
+ _remote_backlight_on();
#endif
system_init();
@@ -531,7 +531,7 @@ void main(void)
sleep(HZ);
/* Backlight OFF */
- __backlight_off();
+ _backlight_off();
}
cpu_idle_mode(false);
diff --git a/bootloader/telechips.c b/bootloader/telechips.c
index 83dad704da..6093701044 100644
--- a/bootloader/telechips.c
+++ b/bootloader/telechips.c
@@ -57,7 +57,7 @@ void* main(void)
lcd_init();
font_init();
- __backlight_on();
+ _backlight_on();
while(!do_power_off) {
line = 0;
diff --git a/firmware/backlight.c b/firmware/backlight.c
index 357b446a23..78ba492942 100644
--- a/firmware/backlight.c
+++ b/firmware/backlight.c
@@ -46,29 +46,44 @@
handle this */
extern void screen_dump(void);
-static inline void __backlight_on(void)
+static inline void _backlight_on(void)
{
sim_backlight(100);
}
-static inline void __backlight_off(void)
+static inline void _backlight_off(void)
{
sim_backlight(0);
}
-#ifdef HAVE_BACKLIGHT_BRIGHTNESS
-static inline void __backlight_set_brightness(int val)
+static inline void _backlight_set_brightness(int val)
{
(void)val;
}
-#endif
-#ifdef HAVE_BUTTONLIGHT_BRIGHTNESS
-static inline void __buttonlight_set_brightness(int val)
+static inline void _buttonlight_on(void)
+{
+}
+
+static inline void _buttonlight_off(void)
+{
+}
+
+static inline void _buttonlight_set_brightness(int val)
{
(void)val;
}
-#endif
+#ifdef HAVE_REMOTE_LCD
+static inline void _remote_backlight_on(void)
+{
+ sim_remote_backlight(100);
+}
+
+static inline void _remote_backlight_off(void)
+{
+ sim_remote_backlight(0);
+}
+#endif /* HAVE_REMOTE_LCD */
#endif /* SIMULATOR */
@@ -79,18 +94,24 @@ const signed char backlight_timeout_value[19] =
-1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 15, 20, 25, 30, 45, 60, 90
};
-#define BACKLIGHT_ON 1
-#define BACKLIGHT_OFF 2
-#define REMOTE_BACKLIGHT_ON 3
-#define REMOTE_BACKLIGHT_OFF 4
-#define BACKLIGHT_UNBOOST_CPU 5
+enum {
+ BACKLIGHT_ON,
+ BACKLIGHT_OFF,
+#ifdef HAVE_REMOTE_LCD
+ REMOTE_BACKLIGHT_ON,
+ REMOTE_BACKLIGHT_OFF,
+#endif
+#if defined(_BACKLIGHT_FADE_BOOST) || defined(_BACKLIGHT_FADE_ENABLE)
+ BACKLIGHT_FADE_FINISH,
+#endif
#ifdef HAVE_LCD_SLEEP
-#define LCD_SLEEP 6
+ LCD_SLEEP,
#endif
#ifdef HAVE_BUTTON_LIGHT
-#define BUTTON_LIGHT_ON 7
-#define BUTTON_LIGHT_OFF 8
+ BUTTON_LIGHT_ON,
+ BUTTON_LIGHT_OFF,
#endif
+};
static void backlight_thread(void);
static long backlight_stack[DEFAULT_STACK_SIZE/sizeof(long)];
@@ -109,36 +130,12 @@ static int backlight_on_button_hold = 0;
#ifdef HAVE_BUTTON_LIGHT
static int buttonlight_timer;
-static int buttonlight_timeout = 5*HZ;
-
-/* internal interface */
-static void _buttonlight_on(void)
-{
-#ifndef SIMULATOR
-#ifdef HAVE_BUTTONLIGHT_BRIGHTNESS
- __buttonlight_dim(false);
-#else
- __buttonlight_on();
-#endif
-#endif
-}
-
-void _buttonlight_off(void)
-{
-#ifndef SIMULATOR
-#ifdef HAVE_BUTTONLIGHT_BRIGHTNESS
- if(buttonlight_timeout>0)
- __buttonlight_dim(true);
- else
-#endif
- __buttonlight_off();
-#endif
-}
+int _buttonlight_timeout = 5*HZ;
/* Update state of buttonlight according to timeout setting */
static void buttonlight_update_state(void)
{
- buttonlight_timer = buttonlight_timeout;
+ buttonlight_timer = _buttonlight_timeout;
/* Buttonlight == OFF in the setting? */
if (buttonlight_timer < 0)
@@ -167,7 +164,7 @@ void buttonlight_set_timeout(int index)
if((unsigned)index >= sizeof(backlight_timeout_value))
/* if given a weird value, use default */
index = 6;
- buttonlight_timeout = HZ * backlight_timeout_value[index];
+ _buttonlight_timeout = HZ * backlight_timeout_value[index];
buttonlight_update_state();
}
@@ -190,13 +187,13 @@ const signed char lcd_sleep_timeout_value[10] =
{
-1, 0, 5, 10, 15, 20, 30, 45, 60, 90
};
-static int lcd_sleep_timer;
-static int lcd_sleep_timeout = 10*HZ;
+int _lcd_sleep_timer;
+int _lcd_sleep_timeout = 10*HZ;
#endif
#if defined(HAVE_BACKLIGHT_PWM_FADING) && !defined(SIMULATOR)
/* backlight fading */
-#define BL_PWM_INTERVAL 5000 /* Cycle interval in s */
+#define BL_PWM_INTERVAL 5000 /* Cycle interval in us */
#define BL_PWM_COUNT 100
static const char backlight_fade_value[8] = { 0, 1, 2, 4, 6, 8, 10, 20 };
static int fade_in_count = 1;
@@ -224,7 +221,7 @@ static void backlight_isr(void)
if (bl_dim_current > 0 && bl_dim_current < BL_PWM_COUNT)
{
- __backlight_on();
+ _backlight_on_isr();
bl_pwm_counter = bl_dim_current;
timer_period = timer_period * bl_pwm_counter / BL_PWM_COUNT;
bl_dim_state = DIM_STATE_MAIN;
@@ -232,9 +229,9 @@ static void backlight_isr(void)
else
{
if (bl_dim_current)
- __backlight_on();
+ _backlight_on_isr();
else
- __backlight_off();
+ _backlight_off_isr();
if (bl_dim_current == bl_dim_target)
idle = true;
}
@@ -243,7 +240,7 @@ static void backlight_isr(void)
/* Dim main screen */
case DIM_STATE_MAIN:
- __backlight_off();
+ _backlight_off_isr();
bl_dim_state = DIM_STATE_START;
timer_period = timer_period * (BL_PWM_COUNT - bl_pwm_counter) / BL_PWM_COUNT;
break ;
@@ -263,8 +260,8 @@ static void backlight_isr(void)
if (idle)
{
-#ifdef CPU_COLDFIRE
- queue_post(&backlight_queue, BACKLIGHT_UNBOOST_CPU, 0);
+#if defined(_BACKLIGHT_FADE_BOOST) || defined(_BACKLIGHT_FADE_ENABLE)
+ queue_post(&backlight_queue, BACKLIGHT_FADE_FINISH, 0);
#endif
timer_unregister();
bl_timer_active = false;
@@ -277,19 +274,19 @@ static void backlight_switch(void)
{
if (bl_dim_target > (BL_PWM_COUNT/2))
{
- __backlight_on();
+ _backlight_on_normal();
bl_dim_current = BL_PWM_COUNT;
}
else
{
- __backlight_off();
+ _backlight_off_normal();
bl_dim_current = 0;
}
}
static void backlight_release_timer(void)
{
-#ifdef CPU_COLDFIRE
+#ifdef _BACKLIGHT_FADE_BOOST
cpu_boost(false);
#endif
timer_unregister();
@@ -310,7 +307,7 @@ static void backlight_dim(int value)
if (timer_register(0, backlight_release_timer, 2, 0, backlight_isr))
{
-#ifdef CPU_COLDFIRE
+#ifdef _BACKLIGHT_FADE_BOOST
/* Prevent cpu frequency changes while dimming. */
cpu_boost(true);
#endif
@@ -320,80 +317,58 @@ static void backlight_dim(int value)
backlight_switch();
}
-void backlight_set_fade_in(int index)
-{
- fade_in_count = backlight_fade_value[index];
-}
-
-void backlight_set_fade_out(int index)
-{
- fade_out_count = backlight_fade_value[index];
-}
-#endif /* defined(HAVE_BACKLIGHT_PWM_FADING) && !defined(SIMULATOR) */
-
static void _backlight_on(void)
{
-#if defined(HAVE_BACKLIGHT_PWM_FADING) && !defined(SIMULATOR)
if (fade_in_count > 0)
+ {
+#ifdef _BACKLIGHT_FADE_ENABLE
+ _backlight_hw_enable(true);
+#endif
backlight_dim(BL_PWM_COUNT);
+ }
else
{
bl_dim_target = bl_dim_current = BL_PWM_COUNT;
- __backlight_on();
+ _backlight_on_normal();
}
-#elif defined(HAVE_BACKLIGHT_SET_FADING) && !defined(SIMULATOR)
- /* call the enable from here - it takes longer than the disable */
- lcd_enable(true);
- __backlight_dim(false);
-#else
- __backlight_on();
-#endif
#ifdef HAVE_LCD_SLEEP
- lcd_sleep_timer = 0; /* LCD should be awake already */
+ _lcd_sleep_timer = 0; /* LCD should be awake already */
#endif
}
static void _backlight_off(void)
{
-#if defined(HAVE_BACKLIGHT_PWM_FADING) && !defined(SIMULATOR)
if (fade_out_count > 0)
+ {
backlight_dim(0);
+ }
else
{
bl_dim_target = bl_dim_current = 0;
- __backlight_off();
+ _backlight_off_normal();
}
-#elif defined(HAVE_BACKLIGHT_SET_FADING) && !defined(SIMULATOR)
- __backlight_dim(true);
-#else
- __backlight_off();
-#endif
-
#ifdef HAVE_LCD_SLEEP
/* Start LCD sleep countdown */
- if (lcd_sleep_timeout < 0)
+ if (_lcd_sleep_timeout < 0)
{
- lcd_sleep_timer = 0; /* Setting == Always */
+ _lcd_sleep_timer = 0; /* Setting == Always */
lcd_sleep();
}
else
- lcd_sleep_timer = lcd_sleep_timeout;
+ _lcd_sleep_timer = _lcd_sleep_timeout;
#endif
}
-#ifdef HAVE_REMOTE_LCD
-#ifdef SIMULATOR
-static void __remote_backlight_on(void)
+void backlight_set_fade_in(int index)
{
- sim_remote_backlight(100);
+ fade_in_count = backlight_fade_value[index];
}
-static void __remote_backlight_off(void)
+void backlight_set_fade_out(int index)
{
- sim_remote_backlight(0);
+ fade_out_count = backlight_fade_value[index];
}
-#endif /* SIMULATOR */
-#endif /* HAVE_REMOTE_LCD */
+#endif /* defined(HAVE_BACKLIGHT_PWM_FADING) && !defined(SIMULATOR) */
/* Update state of backlight according to timeout setting */
static void backlight_update_state(void)
@@ -453,12 +428,12 @@ static void remote_backlight_update_state(void)
if (remote_backlight_timeout < 0)
{
remote_backlight_timer = 0; /* Disable the timeout */
- __remote_backlight_off();
+ _remote_backlight_off();
}
else
{
remote_backlight_timer = remote_backlight_timeout;
- __remote_backlight_on();
+ _remote_backlight_on();
}
}
#endif /* HAVE_REMOTE_LCD */
@@ -473,12 +448,16 @@ void backlight_thread(void)
queue_wait(&backlight_queue, &ev);
switch(ev.id)
{ /* These events must always be processed */
-#if defined(HAVE_BACKLIGHT_PWM_FADING) && defined(CPU_COLDFIRE) \
- && !defined(SIMULATOR)
- case BACKLIGHT_UNBOOST_CPU:
+#ifdef _BACKLIGHT_FADE_BOOST
+ case BACKLIGHT_FADE_FINISH:
cpu_boost(false);
break;
#endif
+#ifdef _BACKLIGHT_FADE_ENABLE
+ case BACKLIGHT_FADE_FINISH:
+ _backlight_hw_enable((bl_dim_current|bl_dim_target) != 0);
+ break;
+#endif
#if defined(HAVE_REMOTE_LCD) && !defined(SIMULATOR)
/* Here for now or else the aggressive init messes up scrolling */
@@ -519,7 +498,7 @@ void backlight_thread(void)
case REMOTE_BACKLIGHT_OFF:
remote_backlight_timer = 0; /* Disable the timeout */
- __remote_backlight_off();
+ _remote_backlight_off();
break;
#endif /* HAVE_REMOTE_LCD */
@@ -575,10 +554,10 @@ static void backlight_tick(void)
}
}
#ifdef HAVE_LCD_SLEEP
- else if(lcd_sleep_timer)
+ else if(_lcd_sleep_timer)
{
- lcd_sleep_timer--;
- if(lcd_sleep_timer == 0)
+ _lcd_sleep_timer--;
+ if(_lcd_sleep_timer == 0)
{
/* Queue on bl thread or freeze! */
queue_post(&backlight_queue, LCD_SLEEP, 0);
@@ -613,7 +592,7 @@ void backlight_init(void)
queue_init(&backlight_queue, true);
#ifndef SIMULATOR
- if (__backlight_init())
+ if (_backlight_init())
{
# ifdef HAVE_BACKLIGHT_PWM_FADING
/* If backlight is already on, don't fade in. */
@@ -706,17 +685,17 @@ void lcd_set_sleep_after_backlight_off(int index)
/* if given a weird value, use default */
index = 3;
- lcd_sleep_timeout = HZ * lcd_sleep_timeout_value[index];
+ _lcd_sleep_timeout = HZ * lcd_sleep_timeout_value[index];
if (backlight_timer > 0 || backlight_get_current_timeout() == 0)
/* Timer will be set when bl turns off or bl set to on. */
return;
/* Backlight is Off */
- if (lcd_sleep_timeout < 0)
- lcd_sleep_timer = 1; /* Always - sleep next tick */
+ if (_lcd_sleep_timeout < 0)
+ _lcd_sleep_timer = 1; /* Always - sleep next tick */
else
- lcd_sleep_timer = lcd_sleep_timeout; /* Never, other */
+ _lcd_sleep_timer = _lcd_sleep_timeout; /* Never, other */
}
#endif /* HAVE_LCD_SLEEP */
@@ -796,7 +775,7 @@ void backlight_set_brightness(int val)
else if (val > MAX_BRIGHTNESS_SETTING)
val = MAX_BRIGHTNESS_SETTING;
- __backlight_set_brightness(val);
+ _backlight_set_brightness(val);
}
#endif /* HAVE_BACKLIGHT_BRIGHTNESS */
@@ -808,7 +787,7 @@ void buttonlight_set_brightness(int val)
else if (val > MAX_BRIGHTNESS_SETTING)
val = MAX_BRIGHTNESS_SETTING;
- __buttonlight_set_brightness(val);
+ _buttonlight_set_brightness(val);
}
#endif /* HAVE_BUTTONLIGHT_BRIGHTNESS */
@@ -818,8 +797,8 @@ void buttonlight_set_brightness(int val)
#if defined(BOOTLOADER) && defined(HAVE_BACKLIGHT)
void backlight_init(void)
{
- (void)__backlight_init();
- __backlight_on();
+ (void)_backlight_init();
+ _backlight_on();
}
#endif
diff --git a/firmware/export/backlight.h b/firmware/export/backlight.h
index 8df45990fd..47fee7d59e 100644
--- a/firmware/export/backlight.h
+++ b/firmware/export/backlight.h
@@ -85,4 +85,13 @@ void buttonlight_off(void);
void buttonlight_set_timeout(int index);
#endif
+/* Private API for use in target tree backlight code only */
+#ifdef HAVE_BUTTON_LIGHT
+extern int _buttonlight_timeout;
+#endif
+#ifdef HAVE_LCD_SLEEP
+extern int _lcd_sleep_timer;
+extern int _lcd_sleep_timeout;
+#endif
+
#endif /* BACKLIGHT_H */
diff --git a/firmware/export/config-ipodnano.h b/firmware/export/config-ipodnano.h
index 4fcb8f69dc..69095614dc 100644
--- a/firmware/export/config-ipodnano.h
+++ b/firmware/export/config-ipodnano.h
@@ -72,6 +72,12 @@
/* Define this for LCD backlight available */
#define HAVE_BACKLIGHT
+#define HAVE_BACKLIGHT_BRIGHTNESS
+
+/* Main LCD backlight brightness range and defaults */
+#define MIN_BRIGHTNESS_SETTING 1
+#define MAX_BRIGHTNESS_SETTING 32
+#define DEFAULT_BRIGHTNESS_SETTING 16
/* We can fade the backlight by using PWM */
#define HAVE_BACKLIGHT_PWM_FADING
diff --git a/firmware/export/config-ipodvideo.h b/firmware/export/config-ipodvideo.h
index eecb65c809..60a5dd8f6f 100644
--- a/firmware/export/config-ipodvideo.h
+++ b/firmware/export/config-ipodvideo.h
@@ -72,6 +72,12 @@
/* Define this for LCD backlight available */
#define HAVE_BACKLIGHT
+#define HAVE_BACKLIGHT_BRIGHTNESS
+
+/* Main LCD backlight brightness range and defaults */
+#define MIN_BRIGHTNESS_SETTING 1
+#define MAX_BRIGHTNESS_SETTING 32
+#define DEFAULT_BRIGHTNESS_SETTING 16
/* We can fade the backlight by using PWM */
#define HAVE_BACKLIGHT_PWM_FADING
diff --git a/firmware/target/arm/imx31/gigabeat-s/backlight-imx31.c b/firmware/target/arm/imx31/gigabeat-s/backlight-imx31.c
index 37cf086a0e..fc9abdb0e9 100644
--- a/firmware/target/arm/imx31/gigabeat-s/backlight-imx31.c
+++ b/firmware/target/arm/imx31/gigabeat-s/backlight-imx31.c
@@ -26,25 +26,25 @@
#include "spi-imx31.h"
#include "debug.h"
-bool __backlight_init(void)
+bool _backlight_init(void)
{
return true;
}
-void __backlight_on(void)
+void _backlight_on(void)
{
// This relies on the SPI interface being initialised already
spi_send(51, 1);
}
-void __backlight_off(void)
+void _backlight_off(void)
{
// This relies on the SPI interface being initialised already
spi_send(51, 0);
}
/* Assumes that the backlight has been initialized */
-void __backlight_set_brightness(int brightness)
+void _backlight_set_brightness(int brightness)
{
(void)brightness;
}
diff --git a/firmware/target/arm/imx31/gigabeat-s/backlight-target.h b/firmware/target/arm/imx31/gigabeat-s/backlight-target.h
index 8f14c76138..7c4b2fa0fd 100644
--- a/firmware/target/arm/imx31/gigabeat-s/backlight-target.h
+++ b/firmware/target/arm/imx31/gigabeat-s/backlight-target.h
@@ -19,10 +19,10 @@
#ifndef BACKLIGHT_TARGET_H
#define BACKLIGHT_TARGET_H
-bool __backlight_init(void);
-void __backlight_on(void);
-void __backlight_off(void);
-void __backlight_set_brightness(int brightness);
+bool _backlight_init(void);
+void _backlight_on(void);
+void _backlight_off(void);
+void _backlight_set_brightness(int brightness);
/* true: backlight fades off - false: backlight fades on */
void __backlight_dim(bool dim);
diff --git a/firmware/target/arm/ipod/1g2g/backlight-1g2g.c b/firmware/target/arm/ipod/1g2g/backlight-1g2g.c
index 88d638f4e3..688fc2a213 100644
--- a/firmware/target/arm/ipod/1g2g/backlight-1g2g.c
+++ b/firmware/target/arm/ipod/1g2g/backlight-1g2g.c
@@ -21,13 +21,13 @@
#include "backlight.h"
#include "lcd.h"
-void __backlight_on(void)
+void _backlight_on(void)
{
outl(inl(0xc0001000) | 0x02, 0xc0001000);
lcd_set_backlight_inversion(true);
}
-void __backlight_off(void)
+void _backlight_off(void)
{
outl(inl(0xc0001000) & ~0x02, 0xc0001000);
lcd_set_backlight_inversion(false);
diff --git a/firmware/target/arm/ipod/1g2g/backlight-target.h b/firmware/target/arm/ipod/1g2g/backlight-target.h
index a1a9785abc..31a21a4d27 100644
--- a/firmware/target/arm/ipod/1g2g/backlight-target.h
+++ b/firmware/target/arm/ipod/1g2g/backlight-target.h
@@ -19,8 +19,8 @@
#ifndef BACKLIGHT_TARGET_H
#define BACKLIGHT_TARGET_H
-#define __backlight_init() false
-void __backlight_on(void);
-void __backlight_off(void);
+#define _backlight_init() false
+void _backlight_on(void);
+void _backlight_off(void);
#endif
diff --git a/firmware/target/arm/ipod/3g/backlight-3g.c b/firmware/target/arm/ipod/3g/backlight-3g.c
index 251c722dae..41f8ba37cb 100644
--- a/firmware/target/arm/ipod/3g/backlight-3g.c
+++ b/firmware/target/arm/ipod/3g/backlight-3g.c
@@ -20,12 +20,12 @@
#include "system.h"
#include "backlight.h"
-inline void __backlight_on(void)
+void _backlight_on(void)
{
outl(inl(0xc0001000) | 0x02, 0xc0001000);
}
-inline void __backlight_off(void)
+void _backlight_off(void)
{
outl(inl(0xc0001000) & ~0x02, 0xc0001000);
}
diff --git a/firmware/target/arm/ipod/backlight-4g_color.c b/firmware/target/arm/ipod/backlight-4g_color.c
index 3097d8690b..28deba46b5 100644
--- a/firmware/target/arm/ipod/backlight-4g_color.c
+++ b/firmware/target/arm/ipod/backlight-4g_color.c
@@ -31,16 +31,16 @@
#include "timer.h"
#include "backlight.h"
-inline void __backlight_on(void)
+void _backlight_on(void)
{
/* brightness full */
outl(0x80000000 | (0xff << 16), 0x7000a010);
/* set port b bit 3 on */
- outl(((0x100 | 1) << 3), 0x6000d824);
+ GPIO_SET_BITWISE(GPIOB_OUTPUT_VAL, 0x08);
}
-inline void __backlight_off(void)
+void _backlight_off(void)
{
/* fades backlight off on 4g */
GPO32_ENABLE &= ~0x2000000;
diff --git a/firmware/target/arm/ipod/backlight-mini1g_mini2g.c b/firmware/target/arm/ipod/backlight-mini1g_mini2g.c
index 6cfa8f889c..e513c27349 100644
--- a/firmware/target/arm/ipod/backlight-mini1g_mini2g.c
+++ b/firmware/target/arm/ipod/backlight-mini1g_mini2g.c
@@ -31,14 +31,12 @@
#include "timer.h"
#include "backlight.h"
-inline void __backlight_on(void)
+void _backlight_hw_on(void)
{
- /* set port B03 on */
- outl(((0x100 | 1) << 3), 0x6000d824);
+ GPIO_SET_BITWISE(GPIOB_OUTPUT_VAL, 0x08);
}
-inline void __backlight_off(void)
+void _backlight_hw_off(void)
{
- /* set port B03 off */
- outl(((0x100 | 0) << 3), 0x6000d824);
+ GPIO_CLEAR_BITWISE(GPIOB_OUTPUT_VAL, 0x08);
}
diff --git a/firmware/target/arm/ipod/backlight-nano_video.c b/firmware/target/arm/ipod/backlight-nano_video.c
index 92a54225d0..6d77e2bd03 100644
--- a/firmware/target/arm/ipod/backlight-nano_video.c
+++ b/firmware/target/arm/ipod/backlight-nano_video.c
@@ -31,14 +31,89 @@
#include "timer.h"
#include "backlight.h"
-inline void __backlight_on(void)
+static int brightness = 1; /* 1 to 32 */
+static int current_dim = 16; /* default after enabling the backlight dimmer */
+static bool enabled = false;
+
+void _backlight_set_brightness(int val)
+{
+ int oldlevel;
+
+ if (current_dim < val)
+ {
+ do
+ {
+ oldlevel = set_irq_level(HIGHEST_IRQ_LEVEL);
+ GPIO_CLEAR_BITWISE(GPIOD_OUTPUT_VAL, 0x80);
+ udelay(10);
+ GPIO_SET_BITWISE(GPIOD_OUTPUT_VAL, 0x80);
+ set_irq_level(oldlevel);
+ udelay(10);
+ }
+ while (++current_dim < val);
+ }
+ else if (current_dim > val)
+ {
+ do
+ {
+ oldlevel = set_irq_level(HIGHEST_IRQ_LEVEL);
+ GPIO_CLEAR_BITWISE(GPIOD_OUTPUT_VAL, 0x80);
+ udelay(200);
+ GPIO_SET_BITWISE(GPIOD_OUTPUT_VAL, 0x80);
+ set_irq_level(oldlevel);
+ udelay(10);
+ }
+ while (--current_dim > val);
+ }
+ brightness = val;
+}
+
+void _backlight_hw_enable(bool on)
+{
+ if (on == enabled)
+ return;
+
+ if (on)
+ {
+ GPIO_SET_BITWISE(GPIOB_OUTPUT_VAL, 0x08);
+ GPIO_SET_BITWISE(GPIOD_OUTPUT_VAL, 0x80);
+ sleep(HZ/100);
+ current_dim = 16;
+ _backlight_set_brightness(brightness);
+ }
+ else
+ {
+ GPIO_CLEAR_BITWISE(GPIOD_OUTPUT_VAL, 0x80);
+ GPIO_CLEAR_BITWISE(GPIOB_OUTPUT_VAL, 0x08);
+ sleep(HZ/20);
+ }
+ enabled = on;
+}
+
+/* Switch the backlight on. Works only if the backlight circuit is enabled.
+ * Called in ISR context for fading, so it must be fast. */
+void _backlight_led_on(void)
+{
+ GPIO_SET_BITWISE(GPIOL_OUTPUT_VAL, 0x80);
+}
+
+/* Switch the backlight off. Keeps the backlight circuit enabled.
+ * Called in ISR context for fading, so it must be fast. */
+void _backlight_led_off(void)
{
- GPIO_SET_BITWISE(GPIOB_OUTPUT_VAL, 1<<3);
- GPIO_SET_BITWISE(GPIOL_OUTPUT_VAL, 1<<7);
+ GPIO_CLEAR_BITWISE(GPIOL_OUTPUT_VAL, 0x80);
}
-inline void __backlight_off(void)
+bool _backlight_init(void)
{
- GPIO_CLEAR_BITWISE(GPIOB_OUTPUT_VAL, 1<<3);
- GPIO_CLEAR_BITWISE(GPIOL_OUTPUT_VAL, 1<<7);
+ GPIO_SET_BITWISE(GPIOB_ENABLE, 0x08);
+ GPIO_SET_BITWISE(GPIOB_OUTPUT_EN, 0x08);
+ GPIO_SET_BITWISE(GPIOD_ENABLE, 0x80);
+ GPIO_SET_BITWISE(GPIOD_OUTPUT_EN, 0x80);
+ _backlight_hw_enable(true);
+ GPIO_SET_BITWISE(GPIOL_ENABLE, 0x80);
+ GPIO_SET_BITWISE(GPIOL_OUTPUT_EN, 0x80);
+ GPIO_SET_BITWISE(GPIOL_OUTPUT_VAL, 0x80);
+
+ return true;
}
diff --git a/firmware/target/arm/ipod/backlight-target.h b/firmware/target/arm/ipod/backlight-target.h
index f4e34cb53a..1a23ecf8be 100644
--- a/firmware/target/arm/ipod/backlight-target.h
+++ b/firmware/target/arm/ipod/backlight-target.h
@@ -19,8 +19,38 @@
#ifndef BACKLIGHT_TARGET_H
#define BACKLIGHT_TARGET_H
-#define __backlight_init() true
-void __backlight_on(void);
-void __backlight_off(void);
+#if defined(IPOD_VIDEO) || defined(IPOD_NANO)
+
+bool _backlight_init(void);
+void _backlight_set_brightness(int val);
+void _backlight_led_on(void);
+void _backlight_led_off(void);
+void _backlight_hw_enable(bool on);
+
+#define _backlight_on_isr() _backlight_led_on()
+#define _backlight_off_isr() _backlight_led_off()
+#define _backlight_on_normal() do { _backlight_hw_enable(true); \
+ _backlight_led_on(); } while(0)
+#define _backlight_off_normal() do { _backlight_led_off(); \
+ _backlight_hw_enable(false); } while(0)
+#define _BACKLIGHT_FADE_ENABLE
+
+#elif defined HAVE_BACKLIGHT_PWM_FADING
+
+#define _backlight_init() true
+void _backlight_hw_on(void);
+void _backlight_hw_off(void);
+
+#define _backlight_on_isr() _backlight_hw_on()
+#define _backlight_off_isr() _backlight_hw_off()
+#define _backlight_on_normal() _backlight_hw_on()
+#define _backlight_off_normal() _backlight_hw_off()
+
+#else
+
+#define _backlight_init() true
+void _backlight_on(void);
+void _backlight_off(void);
+#endif
#endif
diff --git a/firmware/target/arm/iriver/backlight-target.h b/firmware/target/arm/iriver/backlight-target.h
index f4e34cb53a..0a9fa26ce4 100644
--- a/firmware/target/arm/iriver/backlight-target.h
+++ b/firmware/target/arm/iriver/backlight-target.h
@@ -19,8 +19,8 @@
#ifndef BACKLIGHT_TARGET_H
#define BACKLIGHT_TARGET_H
-#define __backlight_init() true
-void __backlight_on(void);
-void __backlight_off(void);
+#define _backlight_init() true
+void _backlight_on(void);
+void _backlight_off(void);
#endif
diff --git a/firmware/target/arm/iriver/h10/backlight-h10.c b/firmware/target/arm/iriver/h10/backlight-h10.c
index db3e0b8877..8033aebf71 100644
--- a/firmware/target/arm/iriver/h10/backlight-h10.c
+++ b/firmware/target/arm/iriver/h10/backlight-h10.c
@@ -22,18 +22,27 @@
#include "backlight.h"
#include "lcd.h"
-void __backlight_on(void)
+void _backlight_on(void)
{
-#if (CONFIG_LCD == LCD_H10_20GB)
+#ifdef HAVE_LCD_SLEEP
lcd_enable(true);
+ _lcd_sleep_timer = 0;
#endif
- GPIOL_OUTPUT_VAL |= 0x20;
+ GPIO_SET_BITWISE(GPIOL_OUTPUT_VAL, 0x20);
}
-void __backlight_off(void)
+void _backlight_off(void)
{
- GPIOL_OUTPUT_VAL &=~ 0x20;
-#if (CONFIG_LCD == LCD_H10_20GB)
+ GPIO_CLEAR_BITWISE(GPIOL_OUTPUT_VAL, 0x20);
+#ifdef HAVE_LCD_SLEEP
lcd_enable(false);
+ /* Start LCD sleep countdown */
+ if (_lcd_sleep_timeout < 0)
+ {
+ _lcd_sleep_timer = 0; /* Setting == Always */
+ lcd_sleep();
+ }
+ else
+ _lcd_sleep_timer = _lcd_sleep_timeout;
#endif
}
diff --git a/firmware/target/arm/pnx0101/backlight-target.h b/firmware/target/arm/pnx0101/backlight-target.h
index 04236880ee..e1362c8f7f 100644
--- a/firmware/target/arm/pnx0101/backlight-target.h
+++ b/firmware/target/arm/pnx0101/backlight-target.h
@@ -19,8 +19,8 @@
#ifndef BACKLIGHT_TARGET_H
#define BACKLIGHT_TARGET_H
-#define __backlight_init() true
-void __backlight_on(void);
-void __backlight_off(void);
+#define _backlight_init() true
+void _backlight_on(void);
+void _backlight_off(void);
#endif
diff --git a/firmware/target/arm/pnx0101/iriver-ifp7xx/backlight-ifp7xx.c b/firmware/target/arm/pnx0101/iriver-ifp7xx/backlight-ifp7xx.c
index c0dc3974c0..d645555461 100644
--- a/firmware/target/arm/pnx0101/iriver-ifp7xx/backlight-ifp7xx.c
+++ b/firmware/target/arm/pnx0101/iriver-ifp7xx/backlight-ifp7xx.c
@@ -22,12 +22,12 @@
#include "backlight.h"
#include "lcd.h"
-void __backlight_on(void)
+void _backlight_on(void)
{
GPIO3_SET = 1;
}
-void __backlight_off(void)
+void _backlight_off(void)
{
GPIO3_CLR = 1;
}
diff --git a/firmware/target/arm/s3c2440/gigabeat-fx/backlight-meg-fx.c b/firmware/target/arm/s3c2440/gigabeat-fx/backlight-meg-fx.c
index c132be5f69..ee8801f99b 100644
--- a/firmware/target/arm/s3c2440/gigabeat-fx/backlight-meg-fx.c
+++ b/firmware/target/arm/s3c2440/gigabeat-fx/backlight-meg-fx.c
@@ -67,18 +67,8 @@ static unsigned char buttonlight_target;
static unsigned short buttonlight_trigger_now;
-void __backlight_on(void)
-{
- backlight_control = BACKLIGHT_CONTROL_ON;
-}
-
-void __backlight_off(void)
-{
- backlight_control = BACKLIGHT_CONTROL_OFF;
-}
-
/* Assumes that the backlight has been initialized */
-void __backlight_set_brightness(int brightness)
+void _backlight_set_brightness(int brightness)
{
/* stop the interrupt from messing us up */
backlight_control = BACKLIGHT_CONTROL_IDLE;
@@ -328,17 +318,44 @@ static void led_control_service(void)
}
#endif /* BOOTLOADER */
-void __buttonlight_on(void)
+static void __backlight_dim(bool dim_now)
+{
+ /* dont let the interrupt tick happen */
+ backlight_control = BACKLIGHT_CONTROL_IDLE;
+ backlight_target = (dim_now == true) ? 0 : backlight_brightness;
+ if(backlight_target==0 && backlight_brightness==0)
+ {
+ if(dim_now == false)
+ backlight_control = BACKLIGHT_CONTROL_ON;
+ else
+ backlight_control = BACKLIGHT_CONTROL_OFF;
+ }
+ else
+ backlight_control = BACKLIGHT_CONTROL_FADE;
+}
+
+void _backlight_on(void)
+{
+ lcd_enable(true);
+ __backlight_dim(false);
+}
+
+void _backlight_off(void)
+{
+ __backlight_dim(true);
+}
+
+static inline void __buttonlight_on(void)
{
buttonlight_control = BUTTONLIGHT_CONTROL_ON;
}
-void __buttonlight_off(void)
+static inline void __buttonlight_off(void)
{
buttonlight_control = BUTTONLIGHT_CONTROL_OFF;
}
-void __buttonlight_dim(bool dim_now)
+static void __buttonlight_dim(bool dim_now)
{
buttonlight_control = BUTTONLIGHT_CONTROL_IDLE;
buttonlight_target = (dim_now == true) ? 0 : buttonlight_brightness;
@@ -353,30 +370,27 @@ void __buttonlight_dim(bool dim_now)
buttonlight_control = BUTTONLIGHT_CONTROL_FADE;
}
-void __backlight_dim(bool dim_now)
+void _buttonlight_on(void)
{
- /* dont let the interrupt tick happen */
- backlight_control = BACKLIGHT_CONTROL_IDLE;
- backlight_target = (dim_now == true) ? 0 : backlight_brightness;
- if(backlight_target==0 && backlight_brightness==0)
- {
- if(dim_now == false)
- backlight_control = BACKLIGHT_CONTROL_ON;
- else
- backlight_control = BACKLIGHT_CONTROL_OFF;
- }
+ __buttonlight_dim(false);
+}
+
+void _buttonlight_off(void)
+{
+ if(_buttonlight_timeout>0)
+ __buttonlight_dim(true);
else
- backlight_control = BACKLIGHT_CONTROL_FADE;
+ __buttonlight_off();
}
-void __buttonlight_set_brightness(int brightness)
+void _buttonlight_set_brightness(int brightness)
{
buttonlight_control = BUTTONLIGHT_CONTROL_IDLE;
buttonlight_brightness = brightness;
buttonlight_control = BUTTONLIGHT_CONTROL_SET;
}
-bool __backlight_init(void)
+bool _backlight_init(void)
{
buttonlight_brightness = DEFAULT_BRIGHTNESS_SETTING;
backlight_brightness = DEFAULT_BRIGHTNESS_SETTING;
diff --git a/firmware/target/arm/s3c2440/gigabeat-fx/backlight-target.h b/firmware/target/arm/s3c2440/gigabeat-fx/backlight-target.h
index 0589557791..b899cc977c 100644
--- a/firmware/target/arm/s3c2440/gigabeat-fx/backlight-target.h
+++ b/firmware/target/arm/s3c2440/gigabeat-fx/backlight-target.h
@@ -41,18 +41,12 @@ void __buttonlight_trigger(void);
/* See enum buttonlight_mode for available functions */
void __buttonlight_mode(enum buttonlight_mode mode);
-bool __backlight_init(void);
-void __backlight_on(void);
-void __backlight_off(void);
-void __backlight_set_brightness(int brightness);
-
-void __buttonlight_set_brightness(int brightness);
-
-void __buttonlight_on(void);
-void __buttonlight_off(void);
-
-/* true: backlight fades off - false: backlight fades on */
-void __backlight_dim(bool dim);
-void __buttonlight_dim(bool dim_now);
-
+bool _backlight_init(void);
+void _backlight_on(void);
+void _backlight_off(void);
+void _backlight_set_brightness(int brightness);
+
+void _buttonlight_set_brightness(int brightness);
+void _buttonlight_on(void);
+void _buttonlight_off(void);
#endif
diff --git a/firmware/target/arm/s3c2440/gigabeat-fx/power-meg-fx.c b/firmware/target/arm/s3c2440/gigabeat-fx/power-meg-fx.c
index ac37908b05..b9da66e025 100644
--- a/firmware/target/arm/s3c2440/gigabeat-fx/power-meg-fx.c
+++ b/firmware/target/arm/s3c2440/gigabeat-fx/power-meg-fx.c
@@ -63,8 +63,8 @@ bool ide_powered(void)
void power_off(void)
{
/* turn off backlight and wait for 1 second */
- __backlight_off();
- __buttonlight_off();
+ _backlight_off();
+ _buttonlight_off();
sleep(HZ);
/* set SLEEP bit to on in CLKCON to turn off */
CLKCON |=(1<<3);
diff --git a/firmware/target/arm/sandisk/backlight-c200_e200.c b/firmware/target/arm/sandisk/backlight-c200_e200.c
index a9fc862966..fad1018d38 100644
--- a/firmware/target/arm/sandisk/backlight-c200_e200.c
+++ b/firmware/target/arm/sandisk/backlight-c200_e200.c
@@ -16,6 +16,7 @@
* KIND, either express or implied.
*
****************************************************************************/
+#include "config.h"
#include "backlight-target.h"
#include "system.h"
#include "lcd.h"
@@ -25,46 +26,57 @@
static unsigned short backlight_brightness = DEFAULT_BRIGHTNESS_SETTING;
-void __backlight_set_brightness(int brightness)
+void _backlight_set_brightness(int brightness)
{
backlight_brightness = brightness;
if (brightness > 0)
- __backlight_on();
+ _backlight_on();
else
- __backlight_off();
+ _backlight_off();
}
-void __backlight_on(void)
+void _backlight_on(void)
{
#ifdef HAVE_LCD_ENABLE
lcd_enable(true); /* power on lcd */
#endif
+#ifdef HAVE_LCD_SLEEP
+ _lcd_sleep_timer = 0; /* LCD should be awake already */
+#endif
pp_i2c_send(AS3514_I2C_ADDR, DCDC15, backlight_brightness);
}
-void __backlight_off(void)
+void _backlight_off(void)
{
pp_i2c_send(AS3514_I2C_ADDR, DCDC15, 0x0);
#ifdef HAVE_LCD_ENABLE
lcd_enable(false); /* power off lcd */
#endif
+#ifdef HAVE_LCD_SLEEP
+ /* Start LCD sleep countdown */
+ if (_lcd_sleep_timeout < 0)
+ {
+ _lcd_sleep_timer = 0; /* Setting == Always */
+ lcd_sleep();
+ }
+ else
+ _lcd_sleep_timer = _lcd_sleep_timeout;
+#endif
}
-#ifdef HAVE_BUTTON_LIGHT
-void __buttonlight_on(void)
+void _buttonlight_on(void)
{
- GPIOG_OUTPUT_VAL |= 0x80;
+ GPIO_SET_BITWISE(GPIOG_OUTPUT_VAL, 0x80);
#ifdef SANSA_C200
- GPIOB_OUTPUT_VAL |= 0x10; /* The "menu" backlight */
+ GPIO_SET_BITWISE(GPIOB_OUTPUT_VAL, 0x10); /* The "menu" backlight */
#endif
}
-void __buttonlight_off(void)
+void _buttonlight_off(void)
{
- GPIOG_OUTPUT_VAL &=~ 0x80;
+ GPIO_CLEAR_BITWISE(GPIOG_OUTPUT_VAL, 0x80);
#ifdef SANSA_C200
- GPIOB_OUTPUT_VAL &=~ 0x10; /* The "menu" backlight */
+ GPIO_CLEAR_BITWISE(GPIOB_OUTPUT_VAL, 0x10); /* The "menu" backlight */
#endif
}
-#endif
diff --git a/firmware/target/arm/sandisk/backlight-target.h b/firmware/target/arm/sandisk/backlight-target.h
index 53a87fbbb3..01573b8403 100644
--- a/firmware/target/arm/sandisk/backlight-target.h
+++ b/firmware/target/arm/sandisk/backlight-target.h
@@ -19,14 +19,12 @@
#ifndef BACKLIGHT_TARGET_H
#define BACKLIGHT_TARGET_H
-#define __backlight_init() true
-void __backlight_on(void);
-void __backlight_off(void);
-void __backlight_set_brightness(int brightness);
+#define _backlight_init() true
+void _backlight_on(void);
+void _backlight_off(void);
+void _backlight_set_brightness(int brightness);
int __backlight_is_on(void);
-#ifdef HAVE_BUTTON_LIGHT
-void __buttonlight_on(void);
-void __buttonlight_off(void);
-#endif
+void _buttonlight_on(void);
+void _buttonlight_off(void);
#endif
diff --git a/firmware/target/arm/tatung/tpj1022/backlight-target.h b/firmware/target/arm/tatung/tpj1022/backlight-target.h
index 079a8ce8aa..6513e11122 100644
--- a/firmware/target/arm/tatung/tpj1022/backlight-target.h
+++ b/firmware/target/arm/tatung/tpj1022/backlight-target.h
@@ -22,8 +22,8 @@
#ifndef BACKLIGHT_TARGET_H
#define BACKLIGHT_TARGET_H
-#define __backlight_init() true
-void __backlight_on(void);
-void __backlight_off(void);
+#define _backlight_init() true
+void _backlight_on(void);
+void _backlight_off(void);
#endif
diff --git a/firmware/target/arm/tatung/tpj1022/backlight-tpj1022.c b/firmware/target/arm/tatung/tpj1022/backlight-tpj1022.c
index 51218e21be..933ad5e930 100644
--- a/firmware/target/arm/tatung/tpj1022/backlight-tpj1022.c
+++ b/firmware/target/arm/tatung/tpj1022/backlight-tpj1022.c
@@ -25,16 +25,16 @@
#include "system.h"
#include "backlight.h"
-void __backlight_on(void)
+void _backlight_on(void)
{
-#if 0
+#if 0
int level = set_irq_level(HIGHEST_IRQ_LEVEL);
pcf50606_write(0x38, 0xb0); /* Backlight ON, GPO1INV=1, GPO1ACT=011 */
set_irq_level(level);
#endif
}
-void __backlight_off(void)
+void _backlight_off(void)
{
#if 0
int level = set_irq_level(HIGHEST_IRQ_LEVEL);
diff --git a/firmware/target/arm/tcc77x/logikdax/backlight-target.h b/firmware/target/arm/tcc77x/logikdax/backlight-target.h
index 4714f22aa3..5a64fcf0bc 100644
--- a/firmware/target/arm/tcc77x/logikdax/backlight-target.h
+++ b/firmware/target/arm/tcc77x/logikdax/backlight-target.h
@@ -21,15 +21,15 @@
#include "tcc77x.h"
-#define __backlight_init() true
+#define _backlight_init() true
-static inline void __backlight_on(void)
+static inline void _backlight_on(void)
{
/* Enable backlight */
GPIOD |= 0x10;
}
-static inline void __backlight_off(void)
+static inline void _backlight_off(void)
{
/* Disable backlight */
GPIOD &= ~0x10;
diff --git a/firmware/target/arm/tms320dm320/mrobe-500/backlight-mr500.c b/firmware/target/arm/tms320dm320/mrobe-500/backlight-mr500.c
index b570f3e8fc..88ed0994f5 100644
--- a/firmware/target/arm/tms320dm320/mrobe-500/backlight-mr500.c
+++ b/firmware/target/arm/tms320dm320/mrobe-500/backlight-mr500.c
@@ -26,18 +26,18 @@
#include "power.h"
#include "spi-target.h"
-void __backlight_on(void)
+void _backlight_on(void)
{
- __backlight_set_brightness(DEFAULT_BRIGHTNESS_SETTING);
+ _backlight_set_brightness(DEFAULT_BRIGHTNESS_SETTING);
}
-void __backlight_off(void)
+void _backlight_off(void)
{
- __backlight_set_brightness(0);
+ _backlight_set_brightness(0);
}
/* Assumes that the backlight has been initialized */
-void __backlight_set_brightness(int brightness)
+void _backlight_set_brightness(int brightness)
{
uint8_t bl_command[] = {0xa4, 0x00, brightness, 0xbb};
spi_block_transfer(SPI_target_BACKLIGHT, bl_command, 4, 0, 0);
@@ -45,13 +45,13 @@ void __backlight_set_brightness(int brightness)
void __backlight_dim(bool dim_now)
{
- __backlight_set_brightness(dim_now ?
+ _backlight_set_brightness(dim_now ?
DEFAULT_BRIGHTNESS_SETTING :
DEFAULT_DIMNESS_SETTING);
}
-bool __backlight_init(void)
+bool _backlight_init(void)
{
- __backlight_set_brightness(DEFAULT_BRIGHTNESS_SETTING);
+ _backlight_set_brightness(DEFAULT_BRIGHTNESS_SETTING);
return true;
}
diff --git a/firmware/target/arm/tms320dm320/mrobe-500/backlight-target.h b/firmware/target/arm/tms320dm320/mrobe-500/backlight-target.h
index 783b9e1320..e53f8eb691 100644
--- a/firmware/target/arm/tms320dm320/mrobe-500/backlight-target.h
+++ b/firmware/target/arm/tms320dm320/mrobe-500/backlight-target.h
@@ -20,10 +20,10 @@
#ifndef BACKLIGHT_TARGET_H
#define BACKLIGHT_TARGET_H
-bool __backlight_init(void);
-void __backlight_on(void);
-void __backlight_off(void);
-void __backlight_set_brightness(int brightness);
+bool _backlight_init(void);
+void _backlight_on(void);
+void _backlight_off(void);
+void _backlight_set_brightness(int brightness);
/* true: backlight fades off - false: backlight fades on */
void __backlight_dim(bool dim);
diff --git a/firmware/target/arm/tms320dm320/mrobe-500/power-mr500.c b/firmware/target/arm/tms320dm320/mrobe-500/power-mr500.c
index 3a6dad77f4..19f2439039 100644
--- a/firmware/target/arm/tms320dm320/mrobe-500/power-mr500.c
+++ b/firmware/target/arm/tms320dm320/mrobe-500/power-mr500.c
@@ -64,7 +64,7 @@ bool ide_powered(void)
void power_off(void)
{
/* turn off backlight and wait for 1 second */
- __backlight_off();
+ _backlight_off();
sleep(HZ);
/* Hard shutdown */
IO_GIO_BITSET1|=1<<10;
diff --git a/firmware/target/coldfire/iaudio/m5/backlight-m5.c b/firmware/target/coldfire/iaudio/m5/backlight-m5.c
index 63bc5bc30e..19bc5bfcae 100644
--- a/firmware/target/coldfire/iaudio/m5/backlight-m5.c
+++ b/firmware/target/coldfire/iaudio/m5/backlight-m5.c
@@ -24,14 +24,14 @@
#include "pcf50606.h"
#include "lcd.h"
-bool __backlight_init(void)
+bool _backlight_init(void)
{
- __backlight_on();
+ _backlight_on();
return true; /* Backlight always ON after boot. */
}
-void __backlight_on(void)
+void _backlight_on(void)
{
int level = set_irq_level(HIGHEST_IRQ_LEVEL);
@@ -39,7 +39,7 @@ void __backlight_on(void)
set_irq_level(level);
}
-void __backlight_off(void)
+void _backlight_off(void)
{
int level = set_irq_level(HIGHEST_IRQ_LEVEL);
@@ -47,12 +47,12 @@ void __backlight_off(void)
set_irq_level(level);
}
-void __remote_backlight_on(void)
+void _remote_backlight_on(void)
{
and_l(~0x00200000, &GPIO_OUT);
}
-void __remote_backlight_off(void)
+void _remote_backlight_off(void)
{
or_l(0x00200000, &GPIO_OUT);
}
diff --git a/firmware/target/coldfire/iaudio/m5/backlight-target.h b/firmware/target/coldfire/iaudio/m5/backlight-target.h
index 824810baa1..a5932d32db 100644
--- a/firmware/target/coldfire/iaudio/m5/backlight-target.h
+++ b/firmware/target/coldfire/iaudio/m5/backlight-target.h
@@ -19,10 +19,10 @@
#ifndef BACKLIGHT_TARGET_H
#define BACKLIGHT_TARGET_H
-bool __backlight_init(void);
-void __backlight_on(void);
-void __backlight_off(void);
-void __remote_backlight_on(void);
-void __remote_backlight_off(void);
+bool _backlight_init(void);
+void _backlight_on(void);
+void _backlight_off(void);
+void _remote_backlight_on(void);
+void _remote_backlight_off(void);
#endif
diff --git a/firmware/target/coldfire/iaudio/x5/backlight-target.h b/firmware/target/coldfire/iaudio/x5/backlight-target.h
index 6e03aaa76f..8b50638f85 100644
--- a/firmware/target/coldfire/iaudio/x5/backlight-target.h
+++ b/firmware/target/coldfire/iaudio/x5/backlight-target.h
@@ -19,11 +19,11 @@
#ifndef BACKLIGHT_TARGET_H
#define BACKLIGHT_TARGET_H
-bool __backlight_init(void);
-void __backlight_on(void);
-void __backlight_off(void);
-void __backlight_set_brightness(int val);
-void __remote_backlight_on(void);
-void __remote_backlight_off(void);
+bool _backlight_init(void);
+void _backlight_on(void);
+void _backlight_off(void);
+void _backlight_set_brightness(int val);
+void _remote_backlight_on(void);
+void _remote_backlight_off(void);
#endif
diff --git a/firmware/target/coldfire/iaudio/x5/backlight-x5.c b/firmware/target/coldfire/iaudio/x5/backlight-x5.c
index a2682ff1ae..667f4e7278 100644
--- a/firmware/target/coldfire/iaudio/x5/backlight-x5.c
+++ b/firmware/target/coldfire/iaudio/x5/backlight-x5.c
@@ -24,33 +24,42 @@
#include "pcf50606.h"
#include "lcd.h"
-bool __backlight_init(void)
+bool _backlight_init(void)
{
- __backlight_set_brightness(DEFAULT_BRIGHTNESS_SETTING);
- __backlight_on();
+ _backlight_set_brightness(DEFAULT_BRIGHTNESS_SETTING);
+ _backlight_on();
return true; /* Backlight always ON after boot. */
}
-void __backlight_on(void)
+void _backlight_on(void)
{
int level;
lcd_enable(true);
+ _lcd_sleep_timer = 0; /* LCD should be awake already */
level = set_irq_level(HIGHEST_IRQ_LEVEL);
pcf50606_write(0x38, 0xb0); /* Backlight ON, GPO1INV=1, GPO1ACT=011 */
set_irq_level(level);
}
-void __backlight_off(void)
+void _backlight_off(void)
{
int level = set_irq_level(HIGHEST_IRQ_LEVEL);
pcf50606_write(0x38, 0x80); /* Backlight OFF, GPO1INV=1, GPO1ACT=000 */
set_irq_level(level);
lcd_enable(false);
+ /* Start LCD sleep countdown */
+ if (_lcd_sleep_timeout < 0)
+ {
+ _lcd_sleep_timer = 0; /* Setting == Always */
+ lcd_sleep();
+ }
+ else
+ _lcd_sleep_timer = _lcd_sleep_timeout;
}
/* set brightness by changing the PWM */
-void __backlight_set_brightness(int val)
+void _backlight_set_brightness(int val)
{
/* disable IRQs while bitbanging */
int old_irq_level = set_irq_level(HIGHEST_IRQ_LEVEL);
@@ -59,12 +68,12 @@ void __backlight_set_brightness(int val)
set_irq_level(old_irq_level);
}
-void __remote_backlight_on(void)
+void _remote_backlight_on(void)
{
and_l(~0x00200000, &GPIO_OUT);
}
-void __remote_backlight_off(void)
+void _remote_backlight_off(void)
{
or_l(0x00200000, &GPIO_OUT);
}
diff --git a/firmware/target/coldfire/iriver/h100/backlight-h100.c b/firmware/target/coldfire/iriver/h100/backlight-h100.c
index 7cff965ff9..1c3dded5e5 100644
--- a/firmware/target/coldfire/iriver/h100/backlight-h100.c
+++ b/firmware/target/coldfire/iriver/h100/backlight-h100.c
@@ -25,7 +25,7 @@
#include "lcd.h"
/* Returns the current state of the backlight (true=ON, false=OFF). */
-bool __backlight_init(void)
+bool _backlight_init(void)
{
or_l(0x00020000, &GPIO1_ENABLE);
or_l(0x00020000, &GPIO1_FUNCTION);
@@ -33,22 +33,22 @@ bool __backlight_init(void)
return (GPIO1_OUT & 0x00020000) ? false : true;
}
-void __backlight_on(void)
+void _backlight_hw_on(void)
{
and_l(~0x00020000, &GPIO1_OUT);
}
-void __backlight_off(void)
+void _backlight_hw_off(void)
{
or_l(0x00020000, &GPIO1_OUT);
}
-void __remote_backlight_on(void)
+void _remote_backlight_on(void)
{
and_l(~0x00000800, &GPIO_OUT);
}
-void __remote_backlight_off(void)
+void _remote_backlight_off(void)
{
or_l(0x00000800, &GPIO_OUT);
}
diff --git a/firmware/target/coldfire/iriver/h100/backlight-target.h b/firmware/target/coldfire/iriver/h100/backlight-target.h
new file mode 100644
index 0000000000..6697fb19c3
--- /dev/null
+++ b/firmware/target/coldfire/iriver/h100/backlight-target.h
@@ -0,0 +1,35 @@
+/***************************************************************************
+ * __________ __ ___.
+ * Open \______ \ ____ ____ | | _\_ |__ _______ ___
+ * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
+ * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
+ * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
+ * \/ \/ \/ \/ \/
+ * $Id$
+ *
+ * Copyright (C) 2006 by Linus Nielsen Feltzing
+ *
+ * All files in this archive are subject to the GNU General Public License.
+ * See the file COPYING in the source tree root for full license agreement.
+ *
+ * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
+ * KIND, either express or implied.
+ *
+ ****************************************************************************/
+#ifndef BACKLIGHT_TARGET_H
+#define BACKLIGHT_TARGET_H
+
+bool _backlight_init(void); /* Returns backlight current state (true=ON). */
+void _backlight_hw_on(void);
+void _backlight_hw_off(void);
+
+#define _backlight_on_isr() _backlight_hw_on()
+#define _backlight_off_isr() _backlight_hw_off()
+#define _backlight_on_normal() _backlight_hw_on()
+#define _backlight_off_normal() _backlight_hw_off()
+#define _BACKLIGHT_FADE_BOOST
+
+void _remote_backlight_on(void);
+void _remote_backlight_off(void);
+
+#endif
diff --git a/firmware/target/coldfire/iriver/h300/backlight-h300.c b/firmware/target/coldfire/iriver/h300/backlight-h300.c
index 4cec54f0d7..c0d441ad3f 100644
--- a/firmware/target/coldfire/iriver/h300/backlight-h300.c
+++ b/firmware/target/coldfire/iriver/h300/backlight-h300.c
@@ -25,7 +25,7 @@
#include "pcf50606.h"
#include "lcd.h"
-bool __backlight_init(void)
+bool _backlight_init(void)
{
or_l(0x00020000, &GPIO1_ENABLE);
or_l(0x00020000, &GPIO1_FUNCTION);
@@ -34,21 +34,21 @@ bool __backlight_init(void)
return true; /* Backlight always ON after boot. */
}
-void __backlight_on(void)
+void _backlight_on(void)
{
lcd_enable(true);
sleep(HZ/100); /* lcd needs time - avoid flashing for dark screens */
or_l(0x00020000, &GPIO1_OUT);
}
-void __backlight_off(void)
+void _backlight_off(void)
{
and_l(~0x00020000, &GPIO1_OUT);
lcd_enable(false);
}
/* set brightness by changing the PWM */
-void __backlight_set_brightness(int val)
+void _backlight_set_brightness(int val)
{
/* disable IRQs while bitbanging */
int old_irq_level = set_irq_level(HIGHEST_IRQ_LEVEL);
@@ -57,12 +57,12 @@ void __backlight_set_brightness(int val)
set_irq_level(old_irq_level);
}
-void __remote_backlight_on(void)
+void _remote_backlight_on(void)
{
and_l(~0x00000002, &GPIO1_OUT);
}
-void __remote_backlight_off(void)
+void _remote_backlight_off(void)
{
or_l(0x00000002, &GPIO1_OUT);
}
diff --git a/firmware/target/coldfire/iriver/backlight-target.h b/firmware/target/coldfire/iriver/h300/backlight-target.h
index 30a57e4fbc..f0e1147304 100644
--- a/firmware/target/coldfire/iriver/backlight-target.h
+++ b/firmware/target/coldfire/iriver/h300/backlight-target.h
@@ -19,13 +19,11 @@
#ifndef BACKLIGHT_TARGET_H
#define BACKLIGHT_TARGET_H
-bool __backlight_init(void); /* Returns backlight current state (true=ON). */
-void __backlight_on(void);
-void __backlight_off(void);
-#ifdef HAVE_BACKLIGHT_BRIGHTNESS
-void __backlight_set_brightness(int val);
-#endif
-void __remote_backlight_on(void);
-void __remote_backlight_off(void);
+bool _backlight_init(void); /* Returns backlight current state (true=ON). */
+void _backlight_on(void);
+void _backlight_off(void);
+void _backlight_set_brightness(int val);
+void _remote_backlight_on(void);
+void _remote_backlight_off(void);
#endif
diff --git a/firmware/target/sh/archos/fm_v2/backlight-target.h b/firmware/target/sh/archos/fm_v2/backlight-target.h
index 834d10bdc6..693e2c8200 100644
--- a/firmware/target/sh/archos/fm_v2/backlight-target.h
+++ b/firmware/target/sh/archos/fm_v2/backlight-target.h
@@ -22,15 +22,15 @@
#include "config.h"
#include "rtc.h"
-#define __backlight_init() true
+#define _backlight_init() true
-static inline void __backlight_on(void)
+static inline void _backlight_on(void)
{
/* Enable square wave */
rtc_write(0x0a, rtc_read(0x0a) | 0x40);
}
-static inline void __backlight_off(void)
+static inline void _backlight_off(void)
{
/* Disable square wave */
rtc_write(0x0a, rtc_read(0x0a) & ~0x40);
diff --git a/firmware/target/sh/archos/ondio/backlight-target.h b/firmware/target/sh/archos/ondio/backlight-target.h
index 9be66bd6a0..94d5eb6f2f 100644
--- a/firmware/target/sh/archos/ondio/backlight-target.h
+++ b/firmware/target/sh/archos/ondio/backlight-target.h
@@ -25,7 +25,7 @@
#ifdef HAVE_BACKLIGHT
/* A stock Ondio has no backlight, it needs a hardware mod. */
-static inline bool __backlight_init(void)
+static inline bool _backlight_init(void)
{
PACR1 &= ~0x3000; /* Set PA14 (backlight control) to GPIO */
or_b(0x40, &PADRH); /* drive it high */
@@ -33,12 +33,12 @@ static inline bool __backlight_init(void)
return true;
}
-static inline void __backlight_on(void)
+static inline void _backlight_on(void)
{
or_b(0x40, &PADRH); /* drive it high */
}
-static inline void __backlight_off(void)
+static inline void _backlight_off(void)
{
and_b(~0x40, &PADRH); /* drive it low */
}
diff --git a/firmware/target/sh/archos/player/backlight-target.h b/firmware/target/sh/archos/player/backlight-target.h
index d3bb7f39ed..ede3c86635 100644
--- a/firmware/target/sh/archos/player/backlight-target.h
+++ b/firmware/target/sh/archos/player/backlight-target.h
@@ -22,7 +22,7 @@
#include "config.h"
#include "cpu.h"
-static inline bool __backlight_init(void)
+static inline bool _backlight_init(void)
{
PACR1 &= ~0x3000; /* Set PA14 (backlight control) to GPIO */
and_b(~0x40, &PADRH); /* drive and set low */
@@ -30,13 +30,13 @@ static inline bool __backlight_init(void)
return true;
}
-static inline void __backlight_on(void)
+static inline void _backlight_on(void)
{
and_b(~0x40, &PADRH); /* drive and set low */
or_b(0x40, &PAIORH);
}
-static inline void __backlight_off(void)
+static inline void _backlight_off(void)
{
and_b(~0x40, &PAIORH); /* let it float (up) */
}
diff --git a/firmware/target/sh/archos/recorder/backlight-target.h b/firmware/target/sh/archos/recorder/backlight-target.h
index 834d10bdc6..693e2c8200 100644
--- a/firmware/target/sh/archos/recorder/backlight-target.h
+++ b/firmware/target/sh/archos/recorder/backlight-target.h
@@ -22,15 +22,15 @@
#include "config.h"
#include "rtc.h"
-#define __backlight_init() true
+#define _backlight_init() true
-static inline void __backlight_on(void)
+static inline void _backlight_on(void)
{
/* Enable square wave */
rtc_write(0x0a, rtc_read(0x0a) | 0x40);
}
-static inline void __backlight_off(void)
+static inline void _backlight_off(void)
{
/* Disable square wave */
rtc_write(0x0a, rtc_read(0x0a) & ~0x40);