2002-06-24 13:48:42 +00:00
|
|
|
/***************************************************************************
|
|
|
|
* __________ __ ___.
|
|
|
|
* Open \______ \ ____ ____ | | _\_ |__ _______ ___
|
|
|
|
* Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
|
|
|
|
* Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
|
|
|
|
* Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
|
|
|
|
* \/ \/ \/ \/ \/
|
|
|
|
* $Id$
|
|
|
|
*
|
|
|
|
* Copyright (C) 2002 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.
|
|
|
|
*
|
|
|
|
****************************************************************************/
|
|
|
|
#include "config.h"
|
|
|
|
#include <stdlib.h>
|
2004-10-07 08:38:51 +00:00
|
|
|
#include "cpu.h"
|
2002-06-24 13:48:42 +00:00
|
|
|
#include "kernel.h"
|
|
|
|
#include "thread.h"
|
|
|
|
#include "i2c.h"
|
|
|
|
#include "debug.h"
|
|
|
|
#include "rtc.h"
|
2002-06-29 23:01:10 +00:00
|
|
|
#include "usb.h"
|
2002-10-01 10:59:36 +00:00
|
|
|
#include "power.h"
|
2003-11-06 01:34:50 +00:00
|
|
|
#include "system.h"
|
2002-06-24 13:48:42 +00:00
|
|
|
|
2005-04-15 13:51:19 +00:00
|
|
|
#ifdef HAVE_REMOTE_LCD
|
|
|
|
#include "lcd-remote.h"
|
|
|
|
#endif
|
|
|
|
|
2004-12-18 10:29:47 +00:00
|
|
|
#ifdef CONFIG_BACKLIGHT
|
2004-10-09 19:56:27 +00:00
|
|
|
|
2004-09-10 13:56:54 +00:00
|
|
|
const char backlight_timeout_value[19] =
|
|
|
|
{
|
|
|
|
-1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 15, 20, 25, 30, 45, 60, 90
|
|
|
|
};
|
|
|
|
|
2002-06-24 13:48:42 +00:00
|
|
|
#define BACKLIGHT_ON 1
|
|
|
|
#define BACKLIGHT_OFF 2
|
2005-04-15 16:16:26 +00:00
|
|
|
#define REMOTE_BACKLIGHT_ON 3
|
|
|
|
#define REMOTE_BACKLIGHT_OFF 4
|
2002-06-24 13:48:42 +00:00
|
|
|
|
|
|
|
static void backlight_thread(void);
|
2005-02-06 02:43:26 +00:00
|
|
|
static long backlight_stack[DEFAULT_STACK_SIZE/sizeof(long)];
|
2004-08-03 05:58:46 +00:00
|
|
|
static const char backlight_thread_name[] = "backlight";
|
2002-06-24 13:48:42 +00:00
|
|
|
static struct event_queue backlight_queue;
|
|
|
|
|
2002-10-01 10:59:36 +00:00
|
|
|
static bool charger_was_inserted = 0;
|
|
|
|
static bool backlight_on_when_charging = 0;
|
|
|
|
|
2002-06-24 13:48:42 +00:00
|
|
|
static int backlight_timer;
|
2005-05-30 00:00:22 +00:00
|
|
|
static unsigned int backlight_timeout = 5;
|
2005-04-15 16:16:26 +00:00
|
|
|
#ifdef HAVE_REMOTE_LCD
|
|
|
|
static int remote_backlight_timer;
|
2005-05-30 00:00:22 +00:00
|
|
|
static unsigned int remote_backlight_timeout = 5;
|
2005-04-15 16:16:26 +00:00
|
|
|
#endif
|
2002-06-24 13:48:42 +00:00
|
|
|
|
2005-06-18 12:53:57 +00:00
|
|
|
#if CONFIG_BACKLIGHT == BL_IRIVER
|
|
|
|
#define BL_PWM_COUNT 100
|
|
|
|
/* Cycle interval in ms */
|
|
|
|
#define BL_PWM_INTERVAL 5000
|
|
|
|
#define BL_PWM_INTERVAL_IDLE 500000
|
|
|
|
#define BL_DIM_SPEED 4
|
|
|
|
#define __backlight_on __backlight_fade_in
|
|
|
|
#define __backlight_off __backlight_fade_out
|
|
|
|
|
|
|
|
#define DIM_STATE_START 0
|
|
|
|
#define DIM_STATE_MAIN 1
|
|
|
|
#define DIM_STATE_REMOTE 2
|
|
|
|
|
|
|
|
static bool bl_timer_active = false;
|
|
|
|
static int bl_dim_current = BL_PWM_COUNT;
|
|
|
|
static int bl_dim_target = BL_PWM_COUNT;
|
|
|
|
static int bl_pwm_counter = 0;
|
|
|
|
static volatile int bl_cycle_counter = 0;
|
|
|
|
|
|
|
|
/* Unfortunately we can't dim H1xx remote lcd :/ */
|
|
|
|
#ifdef HAVE_REMOTE_LCD_DIMMABLE
|
|
|
|
#define lcd_remote_backlight_on __backlight_fade_remote_in
|
|
|
|
#define lcd_remote_backlight_off __backlight_fade_remote_out
|
|
|
|
static int bl_dim_remote_current = BL_PWM_COUNT;
|
|
|
|
static int bl_dim_remote_target = BL_PWM_COUNT;
|
|
|
|
static int bl_pwm_remote_counter = 0;
|
|
|
|
static bool bl_dim_next_interval;
|
|
|
|
#endif
|
|
|
|
|
|
|
|
static int bl_dim_state = 0;
|
|
|
|
|
|
|
|
void backlight_start_timer(void)
|
|
|
|
{
|
|
|
|
unsigned int count;
|
|
|
|
|
|
|
|
if (bl_timer_active)
|
|
|
|
return ;
|
|
|
|
|
|
|
|
count = 1;
|
|
|
|
bl_timer_active = true;
|
|
|
|
|
|
|
|
/* We are using timer 1 */
|
|
|
|
TRR1 = count; /* The reference count */
|
|
|
|
TCN1 = 0; /* reset the timer */
|
|
|
|
TMR1 = 0x011d; /* prescaler=2, restart, CLK/16, enabled */
|
|
|
|
|
|
|
|
TER1 = 0xff; /* Clear all events */
|
|
|
|
|
|
|
|
/* ICR2 (Timer2) */
|
|
|
|
ICR0 = (ICR0 & 0xffff00ff) | 0x00009000; /* Interrupt on level 4.0 */
|
|
|
|
IMR &= ~(1<<10);
|
|
|
|
}
|
|
|
|
|
|
|
|
void TIMER1(void) __attribute__ ((interrupt_handler));
|
|
|
|
void TIMER1(void)
|
|
|
|
{
|
|
|
|
int timer_period;
|
|
|
|
#ifdef HAVE_REMOTE_LCD_DIMMABLE
|
|
|
|
int new_timer_period;
|
|
|
|
#endif
|
|
|
|
|
|
|
|
timer_period = FREQ/20000 * BL_PWM_INTERVAL / 100 / 32;
|
|
|
|
switch (bl_dim_state) {
|
|
|
|
/* New cycle */
|
|
|
|
case DIM_STATE_START:
|
|
|
|
bl_pwm_counter = 0;
|
|
|
|
bl_cycle_counter++;
|
|
|
|
|
|
|
|
if (bl_dim_current > 0 && bl_dim_current < BL_PWM_COUNT) {
|
|
|
|
GPIO1_OUT &= ~0x00020000;
|
|
|
|
bl_pwm_counter = bl_dim_current;
|
|
|
|
timer_period = timer_period * bl_pwm_counter / BL_PWM_COUNT;
|
|
|
|
bl_dim_state = DIM_STATE_MAIN;
|
|
|
|
} else {
|
|
|
|
if (bl_dim_current)
|
|
|
|
GPIO1_OUT &= ~0x00020000;
|
|
|
|
else
|
|
|
|
GPIO1_OUT |= 0x00020000;
|
|
|
|
}
|
|
|
|
|
|
|
|
#ifdef HAVE_REMOTE_LCD_DIMMABLE
|
|
|
|
bl_dim_next_interval = 0;
|
|
|
|
bl_pwm_remote_counter = 0;
|
|
|
|
if (bl_dim_remote_current > 0 &&
|
|
|
|
bl_dim_remote_current < BL_PWM_COUNT) {
|
|
|
|
GPIO_OUT &= ~0x00000800;
|
|
|
|
bl_pwm_remote_counter = bl_dim_remote_current;
|
|
|
|
if (bl_dim_state == DIM_STATE_START) {
|
|
|
|
timer_period = timer_period * bl_pwm_remote_counter
|
|
|
|
/ BL_PWM_COUNT;
|
|
|
|
bl_dim_state = DIM_STATE_REMOTE;
|
|
|
|
break ;
|
|
|
|
}
|
|
|
|
|
|
|
|
new_timer_period = timer_period * bl_pwm_remote_counter
|
|
|
|
/ BL_PWM_COUNT;
|
|
|
|
if (new_timer_period < timer_period) {
|
|
|
|
bl_dim_next_interval = timer_period - new_timer_period;
|
|
|
|
timer_period = new_timer_period;
|
|
|
|
bl_dim_state = DIM_STATE_REMOTE;
|
|
|
|
} else {
|
|
|
|
bl_dim_next_interval = new_timer_period - timer_period;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
if (bl_dim_remote_current)
|
|
|
|
GPIO_OUT &= ~0x00000800;
|
|
|
|
else
|
|
|
|
GPIO_OUT |= 0x00000800;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
break ;
|
|
|
|
|
|
|
|
/* Dim main screen */
|
|
|
|
case DIM_STATE_MAIN:
|
|
|
|
GPIO1_OUT |= 0x00020000;
|
|
|
|
#ifdef HAVE_REMOTE_LCD_DIMMABLE
|
|
|
|
if (bl_dim_next_interval) {
|
|
|
|
timer_period = bl_dim_next_interval;
|
|
|
|
bl_dim_next_interval = 0;
|
|
|
|
bl_dim_state = DIM_STATE_REMOTE;
|
|
|
|
break ;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
bl_dim_state = DIM_STATE_START;
|
|
|
|
timer_period = timer_period * (BL_PWM_COUNT - bl_pwm_counter) / BL_PWM_COUNT;
|
|
|
|
break ;
|
|
|
|
|
|
|
|
#ifdef HAVE_REMOTE_LCD_DIMMABLE
|
|
|
|
/* Dim remote lcd */
|
|
|
|
case DIM_STATE_REMOTE:
|
|
|
|
GPIO_OUT |= 0x00000800;
|
|
|
|
if (bl_dim_next_interval) {
|
|
|
|
timer_period = bl_dim_next_interval;
|
|
|
|
bl_dim_next_interval = 0;
|
|
|
|
bl_dim_state = DIM_STATE_MAIN;
|
|
|
|
break ;
|
|
|
|
}
|
|
|
|
|
|
|
|
bl_dim_state = DIM_STATE_START;
|
|
|
|
timer_period = timer_period * (BL_PWM_COUNT - bl_pwm_remote_counter) / BL_PWM_COUNT;
|
|
|
|
break ;
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
if (bl_cycle_counter >= BL_DIM_SPEED) {
|
|
|
|
bool idle = true;
|
|
|
|
if (bl_dim_target > bl_dim_current) {
|
|
|
|
bl_dim_current++;
|
|
|
|
idle = false;
|
|
|
|
}
|
|
|
|
else if (bl_dim_target < bl_dim_current) {
|
|
|
|
bl_dim_current--;
|
|
|
|
idle = false;
|
|
|
|
}
|
|
|
|
#ifdef HAVE_REMOTE_LCD_DIMMABLE
|
|
|
|
if (bl_dim_remote_target > bl_dim_remote_current) {
|
|
|
|
bl_dim_remote_current++;
|
|
|
|
idle = false;
|
|
|
|
}
|
|
|
|
else if (bl_dim_remote_target < bl_dim_remote_current) {
|
|
|
|
bl_dim_remote_current--;
|
|
|
|
idle = false;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
bl_cycle_counter = 0;
|
|
|
|
|
|
|
|
/* Save CPU & battery when idle, stop timer */
|
|
|
|
if (idle) {
|
|
|
|
bl_timer_active = false;
|
|
|
|
TMR1 = 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
TRR1 = timer_period;
|
|
|
|
TCN1 = 0;
|
|
|
|
TER1 = 0xff; /* Clear all events */
|
|
|
|
}
|
|
|
|
|
|
|
|
static void __backlight_dim(int value)
|
|
|
|
{
|
|
|
|
bl_dim_target = value;
|
|
|
|
backlight_start_timer();
|
|
|
|
}
|
|
|
|
|
|
|
|
static void __backlight_fade_in(void)
|
|
|
|
{
|
|
|
|
__backlight_dim(BL_PWM_COUNT);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void __backlight_fade_out(void)
|
|
|
|
{
|
|
|
|
__backlight_dim(0);
|
|
|
|
}
|
|
|
|
|
|
|
|
#ifdef HAVE_REMOTE_LCD_DIMMABLE
|
|
|
|
static void __backlight_dim_remote(int value)
|
|
|
|
{
|
|
|
|
bl_dim_remote_target = value;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void __backlight_fade_remote_in(void)
|
|
|
|
{
|
|
|
|
__backlight_dim_remote(BL_PWM_COUNT);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void __backlight_fade_remote_out(void)
|
|
|
|
{
|
|
|
|
__backlight_dim_remote(0);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#else
|
2004-10-07 08:38:51 +00:00
|
|
|
static void __backlight_off(void)
|
|
|
|
{
|
2004-12-18 10:29:47 +00:00
|
|
|
#if CONFIG_BACKLIGHT == BL_IRIVER
|
2004-11-18 23:24:32 +00:00
|
|
|
GPIO1_OUT |= 0x00020000;
|
2004-12-18 10:29:47 +00:00
|
|
|
#elif CONFIG_BACKLIGHT == BL_RTC
|
2004-10-07 08:38:51 +00:00
|
|
|
/* Disable square wave */
|
|
|
|
rtc_write(0x0a, rtc_read(0x0a) & ~0x40);
|
2004-12-18 10:29:47 +00:00
|
|
|
#elif CONFIG_BACKLIGHT == BL_PA14_LO /* Player */
|
|
|
|
and_b(~0x40, &PAIORH); /* let it float (up) */
|
|
|
|
#elif CONFIG_BACKLIGHT == BL_PA14_HI /* Ondio */
|
|
|
|
and_b(~0x40, &PADRH); /* drive it low */
|
2005-02-05 10:53:41 +00:00
|
|
|
#elif CONFIG_BACKLIGHT == BL_GMINI
|
|
|
|
P1 &= ~0x10;
|
2004-10-07 08:38:51 +00:00
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
static void __backlight_on(void)
|
|
|
|
{
|
2004-12-18 10:29:47 +00:00
|
|
|
#if CONFIG_BACKLIGHT == BL_IRIVER
|
2004-11-18 23:24:32 +00:00
|
|
|
GPIO1_OUT &= ~0x00020000;
|
2004-12-18 10:29:47 +00:00
|
|
|
#elif CONFIG_BACKLIGHT == BL_RTC
|
2004-10-07 08:38:51 +00:00
|
|
|
/* Enable square wave */
|
|
|
|
rtc_write(0x0a, rtc_read(0x0a) | 0x40);
|
2004-12-18 10:29:47 +00:00
|
|
|
#elif CONFIG_BACKLIGHT == BL_PA14_LO /* Player */
|
2005-04-22 19:18:01 +00:00
|
|
|
and_b(~0x40, &PADRH); /* drive and set low */
|
2004-10-07 08:38:51 +00:00
|
|
|
or_b(0x40, &PAIORH);
|
2004-12-18 10:29:47 +00:00
|
|
|
#elif CONFIG_BACKLIGHT == BL_PA14_HI /* Ondio */
|
|
|
|
or_b(0x40, &PADRH); /* drive it high */
|
2005-02-05 10:53:41 +00:00
|
|
|
#elif CONFIG_BACKLIGHT == BL_GMINI
|
|
|
|
P1 |= 0x10;
|
2004-10-07 08:38:51 +00:00
|
|
|
#endif
|
|
|
|
}
|
2005-06-18 12:53:57 +00:00
|
|
|
#endif
|
2004-10-07 08:38:51 +00:00
|
|
|
|
2002-06-24 13:48:42 +00:00
|
|
|
void backlight_thread(void)
|
|
|
|
{
|
|
|
|
struct event ev;
|
|
|
|
|
|
|
|
while(1)
|
|
|
|
{
|
|
|
|
queue_wait(&backlight_queue, &ev);
|
|
|
|
switch(ev.id)
|
|
|
|
{
|
2005-04-15 16:16:26 +00:00
|
|
|
#ifdef HAVE_REMOTE_LCD
|
|
|
|
case REMOTE_BACKLIGHT_ON:
|
|
|
|
remote_backlight_timer =
|
2005-05-30 00:00:22 +00:00
|
|
|
HZ*backlight_timeout_value[remote_backlight_timeout];
|
2005-04-15 16:16:26 +00:00
|
|
|
|
|
|
|
/* Backlight == OFF in the setting? */
|
|
|
|
if(remote_backlight_timer < 0)
|
|
|
|
{
|
|
|
|
remote_backlight_timer = 0; /* Disable the timeout */
|
|
|
|
lcd_remote_backlight_off();
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
lcd_remote_backlight_on();
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case REMOTE_BACKLIGHT_OFF:
|
|
|
|
lcd_remote_backlight_off();
|
|
|
|
break;
|
|
|
|
|
|
|
|
#endif
|
2002-06-24 13:48:42 +00:00
|
|
|
case BACKLIGHT_ON:
|
2002-10-01 10:59:36 +00:00
|
|
|
if( backlight_on_when_charging && charger_inserted() )
|
|
|
|
{
|
|
|
|
/* Forcing to zero keeps the lights on */
|
|
|
|
backlight_timer = 0;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2003-04-23 09:17:34 +00:00
|
|
|
backlight_timer = HZ*backlight_timeout_value[backlight_timeout];
|
2002-10-01 10:59:36 +00:00
|
|
|
}
|
2002-10-01 11:06:22 +00:00
|
|
|
|
2004-10-07 08:38:51 +00:00
|
|
|
if(backlight_timer < 0) /* Backlight == OFF in the setting? */
|
2002-08-15 13:56:06 +00:00
|
|
|
{
|
2004-10-07 08:38:51 +00:00
|
|
|
backlight_timer = 0; /* Disable the timeout */
|
|
|
|
__backlight_off();
|
2002-08-15 13:56:06 +00:00
|
|
|
}
|
2002-10-01 10:59:36 +00:00
|
|
|
else
|
2002-06-24 13:48:42 +00:00
|
|
|
{
|
2004-10-07 08:38:51 +00:00
|
|
|
__backlight_on();
|
2002-06-24 13:48:42 +00:00
|
|
|
}
|
|
|
|
break;
|
2002-07-23 00:30:47 +00:00
|
|
|
|
2002-06-24 13:48:42 +00:00
|
|
|
case BACKLIGHT_OFF:
|
2004-10-07 08:38:51 +00:00
|
|
|
__backlight_off();
|
2002-06-24 13:48:42 +00:00
|
|
|
break;
|
2002-07-23 00:30:47 +00:00
|
|
|
|
|
|
|
case SYS_USB_CONNECTED:
|
|
|
|
/* Tell the USB thread that we are safe */
|
|
|
|
DEBUGF("backlight_thread got SYS_USB_CONNECTED\n");
|
|
|
|
usb_acknowledge(SYS_USB_CONNECTED_ACK);
|
2002-08-23 09:36:49 +00:00
|
|
|
break;
|
2002-07-30 06:35:50 +00:00
|
|
|
|
|
|
|
case SYS_USB_DISCONNECTED:
|
|
|
|
usb_acknowledge(SYS_USB_DISCONNECTED_ACK);
|
2002-07-23 00:30:47 +00:00
|
|
|
break;
|
2002-06-24 13:48:42 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void backlight_on(void)
|
|
|
|
{
|
|
|
|
queue_post(&backlight_queue, BACKLIGHT_ON, NULL);
|
|
|
|
}
|
|
|
|
|
|
|
|
void backlight_off(void)
|
|
|
|
{
|
|
|
|
queue_post(&backlight_queue, BACKLIGHT_OFF, NULL);
|
|
|
|
}
|
|
|
|
|
2005-04-15 16:16:26 +00:00
|
|
|
#ifdef HAVE_REMOTE_LCD
|
|
|
|
void remote_backlight_on(void)
|
|
|
|
{
|
|
|
|
queue_post(&backlight_queue, REMOTE_BACKLIGHT_ON, NULL);
|
|
|
|
}
|
|
|
|
|
|
|
|
void remote_backlight_off(void)
|
|
|
|
{
|
|
|
|
queue_post(&backlight_queue, REMOTE_BACKLIGHT_OFF, NULL);
|
|
|
|
}
|
2005-05-30 00:00:22 +00:00
|
|
|
|
|
|
|
void remote_backlight_set_timeout(int index)
|
|
|
|
{
|
|
|
|
if((unsigned)index >= sizeof(backlight_timeout_value))
|
|
|
|
/* if given a weird value, use 0 */
|
|
|
|
index=0;
|
|
|
|
remote_backlight_timeout = index; /* index in the backlight_timeout_value table */
|
|
|
|
remote_backlight_on();
|
|
|
|
}
|
2005-04-15 16:16:26 +00:00
|
|
|
#endif
|
|
|
|
|
2002-12-14 22:01:27 +00:00
|
|
|
int backlight_get_timeout(void)
|
|
|
|
{
|
|
|
|
return backlight_timeout;
|
|
|
|
}
|
|
|
|
|
2004-01-30 23:27:44 +00:00
|
|
|
void backlight_set_timeout(int index)
|
2002-10-01 10:59:36 +00:00
|
|
|
{
|
2004-01-30 23:55:02 +00:00
|
|
|
if((unsigned)index >= sizeof(backlight_timeout_value))
|
2003-07-28 09:08:49 +00:00
|
|
|
/* if given a weird value, use 0 */
|
|
|
|
index=0;
|
|
|
|
backlight_timeout = index; /* index in the backlight_timeout_value table */
|
2002-10-01 10:59:36 +00:00
|
|
|
backlight_on();
|
|
|
|
}
|
|
|
|
|
2005-05-08 12:56:48 +00:00
|
|
|
#ifdef HAVE_CHARGE_CTRL
|
2002-12-14 22:01:27 +00:00
|
|
|
bool backlight_get_on_when_charging(void)
|
|
|
|
{
|
|
|
|
return backlight_on_when_charging;
|
|
|
|
}
|
2005-05-08 12:56:48 +00:00
|
|
|
#endif
|
2002-12-14 22:01:27 +00:00
|
|
|
|
2002-10-01 10:59:36 +00:00
|
|
|
void backlight_set_on_when_charging(bool yesno)
|
2002-06-27 00:20:00 +00:00
|
|
|
{
|
2002-10-01 10:59:36 +00:00
|
|
|
backlight_on_when_charging = yesno;
|
2002-06-27 00:20:00 +00:00
|
|
|
backlight_on();
|
|
|
|
}
|
|
|
|
|
2002-06-24 13:48:42 +00:00
|
|
|
void backlight_tick(void)
|
|
|
|
{
|
2002-10-04 11:52:46 +00:00
|
|
|
bool charger_is_inserted = charger_inserted();
|
2002-10-01 11:06:22 +00:00
|
|
|
if( backlight_on_when_charging &&
|
|
|
|
(charger_was_inserted != charger_is_inserted) )
|
2002-10-01 10:59:36 +00:00
|
|
|
{
|
|
|
|
backlight_on();
|
|
|
|
}
|
|
|
|
charger_was_inserted = charger_is_inserted;
|
2002-10-04 11:52:46 +00:00
|
|
|
|
2002-06-24 13:48:42 +00:00
|
|
|
if(backlight_timer)
|
|
|
|
{
|
|
|
|
backlight_timer--;
|
|
|
|
if(backlight_timer == 0)
|
|
|
|
{
|
|
|
|
backlight_off();
|
|
|
|
}
|
|
|
|
}
|
2005-04-15 16:16:26 +00:00
|
|
|
#ifdef HAVE_REMOTE_LCD
|
|
|
|
if(remote_backlight_timer)
|
|
|
|
{
|
|
|
|
remote_backlight_timer--;
|
|
|
|
if(remote_backlight_timer == 0)
|
|
|
|
{
|
|
|
|
remote_backlight_off();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#endif
|
2002-06-24 13:48:42 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void backlight_init(void)
|
|
|
|
{
|
|
|
|
queue_init(&backlight_queue);
|
2002-07-15 22:19:49 +00:00
|
|
|
create_thread(backlight_thread, backlight_stack,
|
2002-07-23 00:30:47 +00:00
|
|
|
sizeof(backlight_stack), backlight_thread_name);
|
2004-11-20 00:15:40 +00:00
|
|
|
|
2004-12-18 10:29:47 +00:00
|
|
|
#if CONFIG_BACKLIGHT == BL_IRIVER
|
|
|
|
GPIO1_ENABLE |= 0x00020000;
|
|
|
|
GPIO1_FUNCTION |= 0x00020000;
|
|
|
|
#elif CONFIG_BACKLIGHT == BL_PA14_LO || CONFIG_BACKLIGHT == BL_PA14_HI
|
2004-11-20 00:15:40 +00:00
|
|
|
PACR1 &= ~0x3000; /* Set PA14 (backlight control) to GPIO */
|
|
|
|
or_b(0x40, &PAIORH); /* ..and output */
|
2005-02-05 10:53:41 +00:00
|
|
|
#elif CONFIG_BACKLIGHT == BL_GMINI
|
|
|
|
P1CON |= 0x10; /* P1.4 C-MOS output mode */
|
2004-11-20 00:15:40 +00:00
|
|
|
#endif
|
2002-06-24 13:48:42 +00:00
|
|
|
backlight_on();
|
2005-04-15 16:16:26 +00:00
|
|
|
#ifdef HAVE_REMOTE_LCD
|
|
|
|
remote_backlight_on();
|
|
|
|
#endif
|
2002-06-24 13:48:42 +00:00
|
|
|
}
|
2004-09-10 13:56:54 +00:00
|
|
|
|
|
|
|
#else /* no backlight, empty dummy functions */
|
|
|
|
|
|
|
|
void backlight_init(void) {}
|
|
|
|
void backlight_on(void) {}
|
|
|
|
void backlight_off(void) {}
|
|
|
|
void backlight_tick(void) {}
|
|
|
|
int backlight_get_timeout(void) {return 0;}
|
|
|
|
void backlight_set_timeout(int index) {(void)index;}
|
|
|
|
void backlight_set_on_when_charging(bool yesno) {(void)yesno;}
|
2005-04-15 16:16:26 +00:00
|
|
|
#ifdef HAVE_REMOTE_LCD
|
|
|
|
void remote_backlight_on(void) {}
|
|
|
|
void remote_backlight_off(void) {}
|
2005-05-30 06:42:14 +00:00
|
|
|
void remote_backlight_set_timeout(int index) {(void)index;}
|
2005-04-15 16:16:26 +00:00
|
|
|
#endif
|
2004-12-18 10:29:47 +00:00
|
|
|
#endif /* #ifdef CONFIG_BACKLIGHT */
|
2004-09-10 13:56:54 +00:00
|
|
|
|