diff options
Diffstat (limited to 'firmware/target')
36 files changed, 362 insertions, 190 deletions
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); |