Backlight handling: * Added 'Caption Backlight' and 'Backlight On When Charging' for the iriver remote LCD. * Enabled the backlight code for the simulator, and prepared backlight simulation. It's only a stub atm, writing messages to the console window. * Added tick task handling to the simulators for this to work. * Code cleanup in backlight.c, less dead code.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@8034 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
parent
e68680ac31
commit
b51f7dfc9b
29 changed files with 416 additions and 231 deletions
|
@ -1612,12 +1612,12 @@ bool gui_wps_refresh(struct gui_wps *gwps, int ffwd_offset,
|
|||
data->peak_meter_enabled = enable_pm;
|
||||
#endif
|
||||
|
||||
#if defined(CONFIG_BACKLIGHT) && !defined(SIMULATOR)
|
||||
#ifdef CONFIG_BACKLIGHT
|
||||
if (global_settings.caption_backlight && state->id3) {
|
||||
/* turn on backlight n seconds before track ends, and turn it off n
|
||||
seconds into the new track. n == backlight_timeout, or 5s */
|
||||
int n =
|
||||
backlight_timeout_value[global_settings.backlight_timeout] * 1000;
|
||||
int n = backlight_timeout_value[global_settings.backlight_timeout]
|
||||
* 1000;
|
||||
|
||||
if ( n < 1000 )
|
||||
n = 5000; /* use 5s if backlight is always on or off */
|
||||
|
@ -1626,6 +1626,22 @@ bool gui_wps_refresh(struct gui_wps *gwps, int ffwd_offset,
|
|||
((state->id3->length - state->id3->elapsed) < (unsigned)n))
|
||||
backlight_on();
|
||||
}
|
||||
#endif
|
||||
#ifdef HAVE_REMOTE_LCD
|
||||
if (global_settings.remote_caption_backlight && state->id3) {
|
||||
/* turn on remote backlight n seconds before track ends, and turn it
|
||||
off n seconds into the new track. n == remote_backlight_timeout,
|
||||
or 5s */
|
||||
int n = backlight_timeout_value[global_settings.remote_backlight_timeout]
|
||||
* 1000;
|
||||
|
||||
if ( n < 1000 )
|
||||
n = 5000; /* use 5s if backlight is always on or off */
|
||||
|
||||
if ((state->id3->elapsed < 1000) ||
|
||||
((state->id3->length - state->id3->elapsed) < (unsigned)n))
|
||||
remote_backlight_on();
|
||||
}
|
||||
#endif
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -147,6 +147,8 @@ void init(void)
|
|||
#endif
|
||||
font_init();
|
||||
show_logo();
|
||||
button_init();
|
||||
backlight_init();
|
||||
lang_init();
|
||||
/* Must be done before any code uses the multi-screen APi */
|
||||
screen_access_init();
|
||||
|
|
|
@ -169,8 +169,8 @@ static const struct plugin_api rockbox_api = {
|
|||
lcd_remote_update,
|
||||
lcd_remote_update_rect,
|
||||
|
||||
lcd_remote_backlight_on,
|
||||
lcd_remote_backlight_off,
|
||||
remote_backlight_on,
|
||||
remote_backlight_off,
|
||||
#endif
|
||||
/* button */
|
||||
button_get,
|
||||
|
|
|
@ -277,8 +277,14 @@ static const struct bit_entry rtc_bits[] =
|
|||
{1, S_O(bidi_support), false, "bidi hebrew/arabic", off_on },
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_REMOTE_LCD_TICKING /* move to REMOTE_LCD next time we bump version */
|
||||
#ifdef HAVE_REMOTE_LCD /* move to REMOTE_LCD next time we bump version */
|
||||
#ifdef HAVE_REMOTE_LCD_TICKING
|
||||
{1, S_O(remote_reduce_ticking), false, "remote reduce ticking", off_on },
|
||||
#endif
|
||||
#ifdef HAVE_CHARGING
|
||||
{1, S_O(remote_backlight_on_when_charging), false,
|
||||
"remote backlight when plugged", off_on },
|
||||
#endif
|
||||
#endif
|
||||
|
||||
/* new stuff to be added here */
|
||||
|
@ -475,6 +481,10 @@ static const struct bit_entry hd_bits[] =
|
|||
{8|SIGNED, S_O(rec_adc_right_gain), 0, /* 0dB */ "adc right gain", NULL }, /* -128...48 */
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_REMOTE_LCD
|
||||
{1, S_O(remote_caption_backlight), false,
|
||||
"remote caption backlight", off_on },
|
||||
#endif
|
||||
/* If values are just added to the end, no need to bump the version. */
|
||||
/* new stuff to be added at the end */
|
||||
|
||||
|
@ -862,11 +872,15 @@ void settings_apply(void)
|
|||
#endif
|
||||
remote_backlight_set_timeout(global_settings.remote_backlight_timeout);
|
||||
#endif
|
||||
#ifdef CONFIG_BACKLIGHT
|
||||
backlight_set_timeout(global_settings.backlight_timeout);
|
||||
#ifdef HAVE_CHARGING
|
||||
backlight_set_on_when_charging(global_settings.backlight_on_when_charging);
|
||||
#if CONFIG_BACKLIGHT == BL_IRIVER_H100
|
||||
#endif
|
||||
#if (CONFIG_BACKLIGHT == BL_IRIVER_H100) && !defined(SIMULATOR)
|
||||
backlight_set_fade_in(global_settings.backlight_fade_in);
|
||||
backlight_set_fade_out(global_settings.backlight_fade_out);
|
||||
#endif
|
||||
#endif
|
||||
ata_spindown(global_settings.disk_spindown);
|
||||
#if (CONFIG_CODEC == MAS3507D) && !defined(SIMULATOR)
|
||||
|
|
|
@ -343,6 +343,8 @@ struct user_settings
|
|||
int remote_backlight_timeout; /* backlight off timeout: 0-18 0=never,
|
||||
1=always,
|
||||
then according to timeout_values[] */
|
||||
bool remote_backlight_on_when_charging;
|
||||
bool remote_caption_backlight; /* turn on backlight at end and start of track */
|
||||
#ifdef HAVE_REMOTE_LCD_TICKING
|
||||
bool remote_reduce_ticking; /* 0=normal operation,
|
||||
1=EMI reduce on with cost more CPU. */
|
||||
|
|
|
@ -137,10 +137,8 @@ static bool remote_reduce_ticking(void)
|
|||
#ifdef CONFIG_BACKLIGHT
|
||||
static bool caption_backlight(void)
|
||||
{
|
||||
bool rc = set_bool( str(LANG_CAPTION_BACKLIGHT),
|
||||
return set_bool( str(LANG_CAPTION_BACKLIGHT),
|
||||
&global_settings.caption_backlight);
|
||||
|
||||
return rc;
|
||||
}
|
||||
|
||||
#ifdef HAVE_CHARGING
|
||||
|
@ -180,7 +178,7 @@ static bool backlight_timer(void)
|
|||
INT, names, 19, backlight_set_timeout );
|
||||
}
|
||||
|
||||
#if CONFIG_BACKLIGHT == BL_IRIVER_H100
|
||||
#if (CONFIG_BACKLIGHT == BL_IRIVER_H100) && !defined(SIMULATOR)
|
||||
static bool backlight_fade_in(void)
|
||||
{
|
||||
static const struct opt_items names[] = {
|
||||
|
@ -242,6 +240,22 @@ static bool remote_backlight_timer(void)
|
|||
INT, names, 19, remote_backlight_set_timeout );
|
||||
}
|
||||
|
||||
#ifdef HAVE_CHARGING
|
||||
static bool remote_backlight_on_when_charging(void)
|
||||
{
|
||||
bool result = set_bool(str(LANG_BACKLIGHT_ON_WHEN_CHARGING),
|
||||
&global_settings.remote_backlight_on_when_charging);
|
||||
remote_backlight_set_on_when_charging(
|
||||
global_settings.remote_backlight_on_when_charging);
|
||||
return result;
|
||||
}
|
||||
#endif
|
||||
|
||||
static bool remote_caption_backlight(void)
|
||||
{
|
||||
return set_bool( str(LANG_CAPTION_BACKLIGHT),
|
||||
&global_settings.remote_caption_backlight);
|
||||
}
|
||||
#endif /* HAVE_REMOTE_LCD */
|
||||
|
||||
static bool contrast(void)
|
||||
|
@ -1521,7 +1535,7 @@ static bool lcd_settings_menu(void)
|
|||
{ ID2P(LANG_BACKLIGHT_ON_WHEN_CHARGING), backlight_on_when_charging },
|
||||
#endif
|
||||
{ ID2P(LANG_CAPTION_BACKLIGHT), caption_backlight },
|
||||
#if CONFIG_BACKLIGHT == BL_IRIVER_H100
|
||||
#if (CONFIG_BACKLIGHT == BL_IRIVER_H100) && !defined(SIMULATOR)
|
||||
{ ID2P(LANG_BACKLIGHT_FADE_IN), backlight_fade_in },
|
||||
{ ID2P(LANG_BACKLIGHT_FADE_OUT), backlight_fade_out },
|
||||
#endif
|
||||
|
@ -1549,6 +1563,11 @@ static bool lcd_remote_settings_menu(void)
|
|||
|
||||
static const struct menu_item items[] = {
|
||||
{ ID2P(LANG_BACKLIGHT), remote_backlight_timer },
|
||||
#ifdef HAVE_CHARGING
|
||||
{ ID2P(LANG_BACKLIGHT_ON_WHEN_CHARGING),
|
||||
remote_backlight_on_when_charging },
|
||||
#endif
|
||||
{ ID2P(LANG_CAPTION_BACKLIGHT), remote_caption_backlight },
|
||||
{ ID2P(LANG_CONTRAST), remote_contrast },
|
||||
{ ID2P(LANG_INVERT), remote_invert },
|
||||
{ ID2P(LANG_FLIP_DISPLAY), remote_flip_display },
|
||||
|
|
|
@ -1,9 +1,7 @@
|
|||
#ifdef ROCKBOX_HAS_LOGF
|
||||
logf.c
|
||||
#endif
|
||||
#ifndef SIMULATOR
|
||||
backlight.c
|
||||
#endif
|
||||
buffer.c
|
||||
common/atoi.c
|
||||
common/ctype.c
|
||||
|
|
|
@ -28,6 +28,7 @@
|
|||
#include "power.h"
|
||||
#include "system.h"
|
||||
#include "timer.h"
|
||||
#include "backlight.h"
|
||||
|
||||
#ifdef HAVE_REMOTE_LCD
|
||||
#include "lcd-remote.h"
|
||||
|
@ -51,17 +52,17 @@ static long backlight_stack[DEFAULT_STACK_SIZE/sizeof(long)];
|
|||
static const char backlight_thread_name[] = "backlight";
|
||||
static struct event_queue backlight_queue;
|
||||
|
||||
static bool charger_was_inserted = 0;
|
||||
static bool backlight_on_when_charging = 0;
|
||||
|
||||
static bool backlight_on_when_charging = false;
|
||||
static int backlight_timer;
|
||||
static unsigned int backlight_timeout = 5;
|
||||
|
||||
#ifdef HAVE_REMOTE_LCD
|
||||
static bool remote_backlight_on_when_charging = false;
|
||||
static int remote_backlight_timer;
|
||||
static unsigned int remote_backlight_timeout = 5;
|
||||
#endif
|
||||
|
||||
#if CONFIG_BACKLIGHT == BL_IRIVER_H100
|
||||
#if (CONFIG_BACKLIGHT == BL_IRIVER_H100) && !defined(SIMULATOR)
|
||||
/* backlight fading */
|
||||
#define BL_PWM_INTERVAL 5000 /* Cycle interval in µs */
|
||||
#define BL_PWM_COUNT 100
|
||||
|
@ -191,45 +192,13 @@ void backlight_set_fade_out(int index)
|
|||
{
|
||||
fade_out_count = backlight_fade_value[index];
|
||||
}
|
||||
#endif
|
||||
|
||||
static void __backlight_off(void)
|
||||
{
|
||||
#if CONFIG_BACKLIGHT == BL_IRIVER_H100
|
||||
if (fade_out_count > 0)
|
||||
backlight_dim(0);
|
||||
else
|
||||
{
|
||||
bl_dim_target = bl_dim_current = 0;
|
||||
or_l(0x00020000, &GPIO1_OUT);
|
||||
}
|
||||
#elif CONFIG_BACKLIGHT == BL_IRIVER_H300
|
||||
and_l(~0x00020000, &GPIO1_OUT);
|
||||
#elif CONFIG_BACKLIGHT == BL_RTC
|
||||
/* Disable square wave */
|
||||
rtc_write(0x0a, rtc_read(0x0a) & ~0x40);
|
||||
#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 */
|
||||
#elif CONFIG_BACKLIGHT == BL_GMINI
|
||||
P1 &= ~0x10;
|
||||
#elif CONFIG_BACKLIGHT == BL_IPOD4G
|
||||
/* fades backlight off on 4g */
|
||||
outl(inl(0x70000084) & ~0x2000000, 0x70000084);
|
||||
outl(0x80000000, 0x7000a010);
|
||||
#elif CONFIG_BACKLIGHT==BL_IPODNANO
|
||||
/* set port B03 off */
|
||||
outl(((0x100 | 0) << 3), 0x6000d824);
|
||||
|
||||
/* set port L07 off */
|
||||
outl(((0x100 | 0) << 7), 0x6000d12c);
|
||||
#endif
|
||||
}
|
||||
#endif /* (CONFIG_BACKLIGHT == BL_IRIVER_H100) && !defined(SIMULATOR) */
|
||||
|
||||
static void __backlight_on(void)
|
||||
{
|
||||
#if CONFIG_BACKLIGHT == BL_IRIVER_H100
|
||||
#ifdef SIMULATOR
|
||||
sim_backlight(100);
|
||||
#elif CONFIG_BACKLIGHT == BL_IRIVER_H100
|
||||
if (fade_in_count > 0)
|
||||
backlight_dim(BL_PWM_COUNT);
|
||||
else
|
||||
|
@ -264,6 +233,66 @@ static void __backlight_on(void)
|
|||
#endif
|
||||
}
|
||||
|
||||
static void __backlight_off(void)
|
||||
{
|
||||
#ifdef SIMULATOR
|
||||
sim_backlight(0);
|
||||
#elif CONFIG_BACKLIGHT == BL_IRIVER_H100
|
||||
if (fade_out_count > 0)
|
||||
backlight_dim(0);
|
||||
else
|
||||
{
|
||||
bl_dim_target = bl_dim_current = 0;
|
||||
or_l(0x00020000, &GPIO1_OUT);
|
||||
}
|
||||
#elif CONFIG_BACKLIGHT == BL_IRIVER_H300
|
||||
and_l(~0x00020000, &GPIO1_OUT);
|
||||
#elif CONFIG_BACKLIGHT == BL_RTC
|
||||
/* Disable square wave */
|
||||
rtc_write(0x0a, rtc_read(0x0a) & ~0x40);
|
||||
#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 */
|
||||
#elif CONFIG_BACKLIGHT == BL_GMINI
|
||||
P1 &= ~0x10;
|
||||
#elif CONFIG_BACKLIGHT == BL_IPOD4G
|
||||
/* fades backlight off on 4g */
|
||||
outl(inl(0x70000084) & ~0x2000000, 0x70000084);
|
||||
outl(0x80000000, 0x7000a010);
|
||||
#elif CONFIG_BACKLIGHT==BL_IPODNANO
|
||||
/* set port B03 off */
|
||||
outl(((0x100 | 0) << 3), 0x6000d824);
|
||||
|
||||
/* set port L07 off */
|
||||
outl(((0x100 | 0) << 7), 0x6000d12c);
|
||||
#endif
|
||||
}
|
||||
|
||||
#ifdef HAVE_REMOTE_LCD
|
||||
static void __remote_backlight_on(void)
|
||||
{
|
||||
#ifdef SIMULATOR
|
||||
sim_remote_backlight(100);
|
||||
#elif defined(IRIVER_H300_SERIES)
|
||||
and_l(~0x00000002, &GPIO1_OUT);
|
||||
#else
|
||||
and_l(~0x00000800, &GPIO_OUT);
|
||||
#endif
|
||||
}
|
||||
|
||||
static void __remote_backlight_off(void)
|
||||
{
|
||||
#ifdef SIMULATOR
|
||||
sim_remote_backlight(0);
|
||||
#elif defined(IRIVER_H300_SERIES)
|
||||
or_l(0x00000002, &GPIO1_OUT);
|
||||
#else
|
||||
or_l(0x00000800, &GPIO_OUT);
|
||||
#endif
|
||||
}
|
||||
#endif /* HAVE_REMOTE_LCD */
|
||||
|
||||
void backlight_thread(void)
|
||||
{
|
||||
struct event ev;
|
||||
|
@ -275,26 +304,34 @@ void backlight_thread(void)
|
|||
{
|
||||
#ifdef HAVE_REMOTE_LCD
|
||||
case REMOTE_BACKLIGHT_ON:
|
||||
if( remote_backlight_on_when_charging && charger_inserted() )
|
||||
{
|
||||
/* Forcing to zero keeps the lights on */
|
||||
remote_backlight_timer = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
remote_backlight_timer =
|
||||
HZ*backlight_timeout_value[remote_backlight_timeout];
|
||||
}
|
||||
|
||||
/* Backlight == OFF in the setting? */
|
||||
if(remote_backlight_timer < 0)
|
||||
{
|
||||
remote_backlight_timer = 0; /* Disable the timeout */
|
||||
lcd_remote_backlight_off();
|
||||
__remote_backlight_off();
|
||||
}
|
||||
else
|
||||
{
|
||||
lcd_remote_backlight_on();
|
||||
__remote_backlight_on();
|
||||
}
|
||||
break;
|
||||
|
||||
case REMOTE_BACKLIGHT_OFF:
|
||||
lcd_remote_backlight_off();
|
||||
__remote_backlight_off();
|
||||
break;
|
||||
|
||||
#endif
|
||||
#endif /* HAVE_REMOTE_LCD */
|
||||
case BACKLIGHT_ON:
|
||||
if( backlight_on_when_charging && charger_inserted() )
|
||||
{
|
||||
|
@ -321,7 +358,7 @@ void backlight_thread(void)
|
|||
__backlight_off();
|
||||
break;
|
||||
|
||||
#if CONFIG_BACKLIGHT == BL_IRIVER_H100
|
||||
#if (CONFIG_BACKLIGHT == BL_IRIVER_H100) && !defined(SIMULATOR)
|
||||
case BACKLIGHT_UNBOOST_CPU:
|
||||
cpu_boost(false);
|
||||
break;
|
||||
|
@ -340,73 +377,23 @@ void backlight_thread(void)
|
|||
}
|
||||
}
|
||||
|
||||
void backlight_on(void)
|
||||
{
|
||||
queue_post(&backlight_queue, BACKLIGHT_ON, NULL);
|
||||
}
|
||||
|
||||
void backlight_off(void)
|
||||
{
|
||||
queue_post(&backlight_queue, BACKLIGHT_OFF, NULL);
|
||||
}
|
||||
|
||||
#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);
|
||||
}
|
||||
|
||||
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();
|
||||
}
|
||||
#endif
|
||||
|
||||
int backlight_get_timeout(void)
|
||||
{
|
||||
return backlight_timeout;
|
||||
}
|
||||
|
||||
void backlight_set_timeout(int index)
|
||||
{
|
||||
if((unsigned)index >= sizeof(backlight_timeout_value))
|
||||
/* if given a weird value, use 0 */
|
||||
index=0;
|
||||
backlight_timeout = index; /* index in the backlight_timeout_value table */
|
||||
backlight_on();
|
||||
}
|
||||
|
||||
#ifdef HAVE_CHARGE_CTRL
|
||||
bool backlight_get_on_when_charging(void)
|
||||
{
|
||||
return backlight_on_when_charging;
|
||||
}
|
||||
#endif
|
||||
|
||||
void backlight_set_on_when_charging(bool yesno)
|
||||
{
|
||||
backlight_on_when_charging = yesno;
|
||||
backlight_on();
|
||||
}
|
||||
|
||||
void backlight_tick(void)
|
||||
static void backlight_tick(void)
|
||||
{
|
||||
#ifdef HAVE_CHARGING
|
||||
static bool charger_was_inserted = false;
|
||||
bool charger_is_inserted = charger_inserted();
|
||||
if( backlight_on_when_charging &&
|
||||
(charger_was_inserted != charger_is_inserted) )
|
||||
|
||||
if( charger_was_inserted != charger_is_inserted )
|
||||
{
|
||||
if( backlight_on_when_charging )
|
||||
backlight_on();
|
||||
#ifdef HAVE_REMOTE_LCD
|
||||
if( remote_backlight_on_when_charging )
|
||||
remote_backlight_on();
|
||||
#endif
|
||||
}
|
||||
charger_was_inserted = charger_is_inserted;
|
||||
#endif /* HAVE_CHARGING */
|
||||
|
||||
if(backlight_timer)
|
||||
{
|
||||
|
@ -433,8 +420,10 @@ void backlight_init(void)
|
|||
queue_init(&backlight_queue);
|
||||
create_thread(backlight_thread, backlight_stack,
|
||||
sizeof(backlight_stack), backlight_thread_name);
|
||||
|
||||
#if CONFIG_BACKLIGHT == BL_IRIVER_H100
|
||||
tick_add_task(backlight_tick);
|
||||
#ifdef SIMULATOR
|
||||
/* do nothing */
|
||||
#elif CONFIG_BACKLIGHT == BL_IRIVER_H100
|
||||
or_l(0x00020000, &GPIO1_ENABLE);
|
||||
or_l(0x00020000, &GPIO1_FUNCTION);
|
||||
and_l(~0x00020000, &GPIO1_OUT); /* Start with the backlight ON */
|
||||
|
@ -454,22 +443,77 @@ void backlight_init(void)
|
|||
#endif
|
||||
}
|
||||
|
||||
void backlight_on(void)
|
||||
{
|
||||
queue_post(&backlight_queue, BACKLIGHT_ON, NULL);
|
||||
}
|
||||
|
||||
void backlight_off(void)
|
||||
{
|
||||
queue_post(&backlight_queue, BACKLIGHT_OFF, NULL);
|
||||
}
|
||||
|
||||
int backlight_get_timeout(void)
|
||||
{
|
||||
return backlight_timeout;
|
||||
}
|
||||
|
||||
void backlight_set_timeout(int index)
|
||||
{
|
||||
if((unsigned)index >= sizeof(backlight_timeout_value))
|
||||
/* if given a weird value, use 0 */
|
||||
index=0;
|
||||
backlight_timeout = index; /* index in the backlight_timeout_value table */
|
||||
backlight_on();
|
||||
}
|
||||
|
||||
#ifdef HAVE_CHARGING
|
||||
bool backlight_get_on_when_charging(void)
|
||||
{
|
||||
return backlight_on_when_charging;
|
||||
}
|
||||
|
||||
void backlight_set_on_when_charging(bool yesno)
|
||||
{
|
||||
backlight_on_when_charging = yesno;
|
||||
backlight_on();
|
||||
}
|
||||
#endif
|
||||
|
||||
#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);
|
||||
}
|
||||
|
||||
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();
|
||||
}
|
||||
|
||||
#ifdef HAVE_CHARGING
|
||||
void remote_backlight_set_on_when_charging(bool yesno)
|
||||
{
|
||||
remote_backlight_on_when_charging = yesno;
|
||||
remote_backlight_on();
|
||||
}
|
||||
#endif
|
||||
#endif /* HAVE_REMOTE_LCD */
|
||||
|
||||
#else /* no backlight, empty dummy functions */
|
||||
|
||||
void backlight_init(void)
|
||||
{
|
||||
#if defined(IRIVER_H300_SERIES) && defined(BOOTLOADER)
|
||||
or_l(0x00020000, &GPIO1_OUT);
|
||||
or_l(0x00020000, &GPIO1_ENABLE);
|
||||
or_l(0x00020000, &GPIO1_FUNCTION);
|
||||
#endif
|
||||
}
|
||||
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;}
|
||||
#ifdef HAVE_REMOTE_LCD
|
||||
void remote_backlight_on(void) {}
|
||||
void remote_backlight_off(void) {}
|
||||
|
|
|
@ -181,8 +181,6 @@ static void button_tick(void)
|
|||
lastbtn = btn & ~(BUTTON_REL | BUTTON_REPEAT);
|
||||
tick = 0;
|
||||
}
|
||||
|
||||
backlight_tick();
|
||||
}
|
||||
|
||||
long button_get(bool block)
|
||||
|
|
|
@ -122,24 +122,6 @@ static const char scroll_tick_table[16] = {
|
|||
/*** driver routines ***/
|
||||
|
||||
#ifndef SIMULATOR
|
||||
void lcd_remote_backlight_on(void)
|
||||
{
|
||||
#ifdef IRIVER_H300_SERIES
|
||||
and_l(~0x00000002, &GPIO1_OUT);
|
||||
#else
|
||||
and_l(~0x00000800, &GPIO_OUT);
|
||||
#endif
|
||||
}
|
||||
|
||||
void lcd_remote_backlight_off(void)
|
||||
{
|
||||
#ifdef IRIVER_H300_SERIES
|
||||
or_l(0x00000002, &GPIO1_OUT);
|
||||
#else
|
||||
or_l(0x00000800, &GPIO_OUT);
|
||||
#endif
|
||||
}
|
||||
|
||||
void lcd_remote_write_command(int cmd)
|
||||
{
|
||||
int i;
|
||||
|
|
|
@ -21,24 +21,32 @@
|
|||
|
||||
#include "config.h"
|
||||
|
||||
void backlight_init(void);
|
||||
void backlight_on(void);
|
||||
void backlight_off(void);
|
||||
void backlight_tick(void);
|
||||
int backlight_get_timeout(void);
|
||||
void backlight_set_timeout(int index);
|
||||
#ifdef CONFIG_BACKLIGHT
|
||||
void backlight_init(void);
|
||||
int backlight_get_timeout(void);
|
||||
#if CONFIG_BACKLIGHT == BL_IRIVER_H100
|
||||
void backlight_set_fade_in(int index);
|
||||
void backlight_set_fade_out(int index);
|
||||
#endif
|
||||
bool backlight_get_on_when_charging(void);
|
||||
void backlight_set_on_when_charging(bool yesno);
|
||||
void remote_backlight_on(void);
|
||||
void remote_backlight_off(void);
|
||||
extern const char backlight_timeout_value[];
|
||||
#else
|
||||
#define backlight_init()
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_REMOTE_LCD
|
||||
void remote_backlight_on(void);
|
||||
void remote_backlight_off(void);
|
||||
void remote_backlight_set_timeout(int index);
|
||||
void remote_backlight_set_on_when_charging(bool yesno);
|
||||
#endif
|
||||
|
||||
#ifdef SIMULATOR
|
||||
void sim_backlight(int value);
|
||||
void sim_remote_backlight(int value);
|
||||
#endif
|
||||
#endif
|
||||
|
|
|
@ -32,6 +32,9 @@
|
|||
/* Define this for S/PDIF input available */
|
||||
#define HAVE_SPDIF_IN
|
||||
|
||||
/* Define this for LCD backlight available */
|
||||
#define CONFIG_BACKLIGHT BL_RTC /* on I2C controlled RTC port */
|
||||
|
||||
#ifndef SIMULATOR
|
||||
|
||||
/* Define this if you have a SH7034 */
|
||||
|
@ -83,9 +86,6 @@
|
|||
/* Software controlled LED */
|
||||
#define CONFIG_LED LED_REAL
|
||||
|
||||
/* Define this for LCD backlight available */
|
||||
#define CONFIG_BACKLIGHT BL_RTC /* on I2C controlled RTC port */
|
||||
|
||||
/* define this if the unit can be powered or charged via USB */
|
||||
#define HAVE_USB_POWER
|
||||
|
||||
|
|
|
@ -38,6 +38,9 @@
|
|||
|
||||
#define CONFIG_LCD LCD_S1D15E06
|
||||
|
||||
/* Define this for LCD backlight available */
|
||||
#define CONFIG_BACKLIGHT BL_IRIVER_H100 /* port controlled */
|
||||
|
||||
/* Define this if you have a software controlled poweroff */
|
||||
#define HAVE_SW_POWEROFF
|
||||
|
||||
|
@ -77,9 +80,6 @@
|
|||
/* The size of the flash ROM */
|
||||
#define FLASH_SIZE 0x200000
|
||||
|
||||
/* Define this for LCD backlight available */
|
||||
#define CONFIG_BACKLIGHT BL_IRIVER_H100 /* port controlled */
|
||||
|
||||
/* Define this to the CPU frequency */
|
||||
#define CPU_FREQ 11289600
|
||||
|
||||
|
|
|
@ -31,6 +31,9 @@
|
|||
|
||||
#define CONFIG_LCD LCD_S1D15E06
|
||||
|
||||
/* Define this for LCD backlight available */
|
||||
#define CONFIG_BACKLIGHT BL_IRIVER_H100 /* port controlled */
|
||||
|
||||
/* Define this if you have a software controlled poweroff */
|
||||
#define HAVE_SW_POWEROFF
|
||||
|
||||
|
@ -72,9 +75,6 @@
|
|||
/* The size of the flash ROM */
|
||||
#define FLASH_SIZE 0x200000
|
||||
|
||||
/* Define this for LCD backlight available */
|
||||
#define CONFIG_BACKLIGHT BL_IRIVER_H100 /* port controlled */
|
||||
|
||||
/* Define this to the CPU frequency */
|
||||
#define CPU_FREQ 11289600
|
||||
|
||||
|
|
|
@ -36,6 +36,9 @@
|
|||
/* Define this if you have an remote lcd */
|
||||
#define HAVE_REMOTE_LCD
|
||||
|
||||
/* Define this for LCD backlight available */
|
||||
#define CONFIG_BACKLIGHT BL_IRIVER_H300 /* port controlled PWM */
|
||||
|
||||
/* Define this if you have a software controlled poweroff */
|
||||
#define HAVE_SW_POWEROFF
|
||||
|
||||
|
@ -69,9 +72,6 @@
|
|||
/* The size of the flash ROM */
|
||||
#define FLASH_SIZE 0x400000
|
||||
|
||||
/* Define this for LCD backlight available */
|
||||
#define CONFIG_BACKLIGHT BL_IRIVER_H300 /* port controlled PWM */
|
||||
|
||||
/* Define this to the CPU frequency */
|
||||
#define CPU_FREQ 11289600
|
||||
|
||||
|
|
|
@ -38,6 +38,9 @@
|
|||
/* Define this if you have the WM8975 audio codec */
|
||||
#define HAVE_WM8975
|
||||
|
||||
/* Define this for LCD backlight available */
|
||||
#define CONFIG_BACKLIGHT BL_IPOD4G /* port controlled */
|
||||
|
||||
#ifndef SIMULATOR
|
||||
|
||||
/* Define this if you have a PortalPlayer PP5020 */
|
||||
|
@ -60,9 +63,6 @@
|
|||
/* The start address index for ROM builds */
|
||||
#define ROM_START 0x00000000
|
||||
|
||||
/* Define this for LCD backlight available */
|
||||
#define CONFIG_BACKLIGHT BL_IPOD4G /* port controlled */
|
||||
|
||||
/* Define this to the CPU frequency */
|
||||
#define CPU_FREQ 11289600
|
||||
|
||||
|
|
|
@ -38,6 +38,9 @@
|
|||
/* Define this if you have the WM8975 audio codec */
|
||||
#define HAVE_WM8975
|
||||
|
||||
/* Define this for LCD backlight available */
|
||||
#define CONFIG_BACKLIGHT BL_IPODNANO /* port controlled */
|
||||
|
||||
#ifndef SIMULATOR
|
||||
|
||||
/* The Nano actually has a PP5021 - but it's register compatible with
|
||||
|
@ -62,9 +65,6 @@
|
|||
/* The start address index for ROM builds */
|
||||
#define ROM_START 0x00000000
|
||||
|
||||
/* Define this for LCD backlight available */
|
||||
#define CONFIG_BACKLIGHT BL_IPODNANO /* port controlled */
|
||||
|
||||
/* Define this to the CPU frequency */
|
||||
#define CPU_FREQ 11289600
|
||||
|
||||
|
|
|
@ -20,6 +20,9 @@
|
|||
/* Define this if you have a DAC3550A */
|
||||
#define HAVE_DAC3550A
|
||||
|
||||
/* Define this for LCD backlight available */
|
||||
#define CONFIG_BACKLIGHT BL_PA14_LO /* port PA14, low active */
|
||||
|
||||
#ifndef SIMULATOR
|
||||
|
||||
/* Define this if you have a SH7034 */
|
||||
|
@ -70,9 +73,6 @@
|
|||
/* Software controlled LED */
|
||||
#define CONFIG_LED LED_REAL
|
||||
|
||||
/* Define this for LCD backlight available */
|
||||
#define CONFIG_BACKLIGHT BL_PA14_LO /* port PA14, low active */
|
||||
|
||||
#define CONFIG_LCD LCD_SSD1801
|
||||
|
||||
#define BOOTFILE_EXT "mod"
|
||||
|
|
|
@ -26,6 +26,9 @@
|
|||
/* Define this for S/PDIF input available */
|
||||
#define HAVE_SPDIF_IN
|
||||
|
||||
/* Define this for LCD backlight available */
|
||||
#define CONFIG_BACKLIGHT BL_RTC /* on I2C controlled RTC port */
|
||||
|
||||
#ifndef SIMULATOR
|
||||
|
||||
/* Define this if you have a SH7034 */
|
||||
|
@ -74,9 +77,6 @@
|
|||
/* Software controlled LED */
|
||||
#define CONFIG_LED LED_REAL
|
||||
|
||||
/* Define this for LCD backlight available */
|
||||
#define CONFIG_BACKLIGHT BL_RTC /* on I2C controlled RTC port */
|
||||
|
||||
/* Define this for S/PDIF output available */
|
||||
#define HAVE_SPDIF_OUT
|
||||
|
||||
|
|
|
@ -29,6 +29,9 @@
|
|||
/* Define this for S/PDIF input available */
|
||||
#define HAVE_SPDIF_IN
|
||||
|
||||
/* Define this for LCD backlight available */
|
||||
#define CONFIG_BACKLIGHT BL_RTC /* on I2C controlled RTC port */
|
||||
|
||||
#ifndef SIMULATOR
|
||||
|
||||
/* Define this if you have a SH7034 */
|
||||
|
@ -83,9 +86,6 @@
|
|||
/* Software controlled LED */
|
||||
#define CONFIG_LED LED_REAL
|
||||
|
||||
/* Define this for LCD backlight available */
|
||||
#define CONFIG_BACKLIGHT BL_RTC /* on I2C controlled RTC port */
|
||||
|
||||
/* define this if the unit can be powered or charged via USB */
|
||||
#define HAVE_USB_POWER
|
||||
|
||||
|
|
|
@ -30,8 +30,6 @@
|
|||
#define STYLE_INVERT 1
|
||||
|
||||
extern void lcd_remote_init(void);
|
||||
extern void lcd_remote_backlight_on(void);
|
||||
extern void lcd_remote_backlight_off(void);
|
||||
extern int lcd_remote_default_contrast(void);
|
||||
extern void lcd_remote_set_contrast(int val);
|
||||
extern void lcd_remote_emireduce(bool state);
|
||||
|
|
|
@ -448,7 +448,7 @@ static int runcurrent(void)
|
|||
current = CURRENT_USB;
|
||||
}
|
||||
|
||||
#ifndef BOOTLOADER
|
||||
#if defined(CONFIG_BACKLIGHT) && !defined(BOOTLOADER)
|
||||
if ((backlight_get_timeout() == 1) /* LED always on */
|
||||
#ifdef HAVE_CHARGE_CTRL
|
||||
|| (charger_inserted() && backlight_get_on_when_charging())
|
||||
|
@ -915,13 +915,11 @@ void shutdown_hw(void)
|
|||
#elif HAVE_TLV320
|
||||
tlv320_close();
|
||||
#endif
|
||||
#if CONFIG_KEYPAD == ONDIO_PAD
|
||||
backlight_off();
|
||||
sleep(1);
|
||||
lcd_set_contrast(0);
|
||||
#endif
|
||||
#ifdef HAVE_REMOTE_LCD
|
||||
lcd_remote_backlight_off();
|
||||
remote_backlight_off();
|
||||
lcd_remote_set_contrast(0);
|
||||
#endif
|
||||
power_off();
|
||||
#endif /* #ifndef SIMULATOR */
|
||||
|
|
|
@ -78,21 +78,19 @@ void audio_set_buffer_margin(int seconds)
|
|||
}
|
||||
#endif
|
||||
|
||||
/* Generic firmware stubs. */
|
||||
void backlight_on(void)
|
||||
#ifdef CONFIG_BACKLIGHT
|
||||
void sim_backlight(int value)
|
||||
{
|
||||
/* we could do something better here! */
|
||||
DEBUGF("backlight: %s\n", (value > 0) ? "on" : "off");
|
||||
}
|
||||
#endif
|
||||
|
||||
void backlight_off(void)
|
||||
#ifdef HAVE_REMOTE_LCD
|
||||
void sim_remote_backlight(int value)
|
||||
{
|
||||
/* we could do something better here! */
|
||||
}
|
||||
|
||||
void backlight_time(int dummy)
|
||||
{
|
||||
(void)dummy;
|
||||
DEBUGF("remote backlight: %s\n", (value > 0) ? "on" : "off");
|
||||
}
|
||||
#endif
|
||||
|
||||
int fat_startsector(void)
|
||||
{
|
||||
|
@ -167,21 +165,6 @@ bool simulate_usb(void)
|
|||
return false;
|
||||
}
|
||||
|
||||
void backlight_set_timeout(int index)
|
||||
{
|
||||
(void)index;
|
||||
}
|
||||
|
||||
void backlight_set_on_when_charging(bool beep)
|
||||
{
|
||||
(void)beep;
|
||||
}
|
||||
|
||||
void remote_backlight_set_timeout(int index)
|
||||
{
|
||||
(void)index;
|
||||
}
|
||||
|
||||
int rtc_read(int address)
|
||||
{
|
||||
time_t now = time(NULL);
|
||||
|
|
|
@ -202,7 +202,13 @@ void button_event(int key, bool pressed)
|
|||
else
|
||||
queue_post(&button_queue, btn, NULL);
|
||||
|
||||
#ifdef HAVE_REMOTE_LCD
|
||||
if(btn & BUTTON_REMOTE)
|
||||
remote_backlight_on();
|
||||
else
|
||||
#endif
|
||||
backlight_on();
|
||||
|
||||
}
|
||||
}
|
||||
else
|
||||
|
|
|
@ -22,12 +22,15 @@
|
|||
#include "kernel.h"
|
||||
#include "thread-win32.h"
|
||||
#include "thread.h"
|
||||
#include "debug.h"
|
||||
|
||||
/* (Daniel 2002-10-31) Mingw32 requires this errno variable to be present.
|
||||
I'm not quite sure why and I don't know if this breaks the MSVC compile.
|
||||
If it does, we should put this within #ifdef __MINGW32__ */
|
||||
int errno;
|
||||
|
||||
static void (*tick_funcs[MAX_NUM_TICK_TASKS])(void);
|
||||
|
||||
int set_irq_level (int level)
|
||||
{
|
||||
static int _lv = 0;
|
||||
|
@ -99,6 +102,54 @@ void switch_thread (void)
|
|||
yield ();
|
||||
}
|
||||
|
||||
void sim_tick_tasks(void)
|
||||
{
|
||||
int i;
|
||||
|
||||
/* Run through the list of tick tasks */
|
||||
for(i = 0;i < MAX_NUM_TICK_TASKS;i++)
|
||||
{
|
||||
if(tick_funcs[i])
|
||||
{
|
||||
tick_funcs[i]();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
int tick_add_task(void (*f)(void))
|
||||
{
|
||||
int i;
|
||||
|
||||
/* Add a task if there is room */
|
||||
for(i = 0;i < MAX_NUM_TICK_TASKS;i++)
|
||||
{
|
||||
if(tick_funcs[i] == NULL)
|
||||
{
|
||||
tick_funcs[i] = f;
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
DEBUGF("Error! tick_add_task(): out of tasks");
|
||||
return -1;
|
||||
}
|
||||
|
||||
int tick_remove_task(void (*f)(void))
|
||||
{
|
||||
int i;
|
||||
|
||||
/* Remove a task if it is there */
|
||||
for(i = 0;i < MAX_NUM_TICK_TASKS;i++)
|
||||
{
|
||||
if(tick_funcs[i] == f)
|
||||
{
|
||||
tick_funcs[i] = NULL;
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* TODO: Implement mutexes for win32 */
|
||||
void mutex_init(struct mutex *m)
|
||||
{
|
||||
|
|
|
@ -37,6 +37,7 @@
|
|||
// extern functions
|
||||
extern void app_main (void *); // mod entry point
|
||||
extern void new_key(int key);
|
||||
extern void sim_tick_tasks(void);
|
||||
|
||||
void button_event(int key, bool pressed);
|
||||
|
||||
|
@ -67,12 +68,18 @@ LRESULT CALLBACK GUIWndProc (
|
|||
static HDC hMemDc;
|
||||
|
||||
static LARGE_INTEGER persec, tick1, ticknow;
|
||||
long new_tick;
|
||||
|
||||
switch (uMsg)
|
||||
{
|
||||
case WM_TIMER:
|
||||
QueryPerformanceCounter(&ticknow);
|
||||
current_tick = ((ticknow.QuadPart-tick1.QuadPart)*HZ)/persec.QuadPart;
|
||||
new_tick = ((ticknow.QuadPart-tick1.QuadPart)*HZ)/persec.QuadPart;
|
||||
if (new_tick != current_tick)
|
||||
{
|
||||
sim_tick_tasks();
|
||||
current_tick = new_tick;
|
||||
}
|
||||
return TRUE;
|
||||
case WM_ACTIVATE:
|
||||
if (LOWORD(wParam) == WA_ACTIVE || LOWORD(wParam) == WA_CLICKACTIVE)
|
||||
|
|
|
@ -21,6 +21,7 @@
|
|||
#include "button.h"
|
||||
#include "kernel.h"
|
||||
#include "debug.h"
|
||||
#include "backlight.h"
|
||||
#include "misc.h"
|
||||
|
||||
#include "X11/keysym.h"
|
||||
|
@ -47,7 +48,7 @@ static long lastbtn; /* Last valid button status */
|
|||
/* mostly copied from real button.c */
|
||||
void button_read (void);
|
||||
|
||||
void button_tick(void)
|
||||
static void button_tick(void)
|
||||
{
|
||||
static int tick = 0;
|
||||
static int count = 0;
|
||||
|
@ -117,6 +118,13 @@ void button_tick(void)
|
|||
queue_post(&button_queue, BUTTON_REPEAT | btn, NULL);
|
||||
else
|
||||
queue_post(&button_queue, btn, NULL);
|
||||
#ifdef HAVE_REMOTE_LCD
|
||||
if(btn & BUTTON_REMOTE)
|
||||
remote_backlight_on();
|
||||
else
|
||||
#endif
|
||||
backlight_on();
|
||||
|
||||
}
|
||||
}
|
||||
else
|
||||
|
@ -276,6 +284,7 @@ long button_get_w_tmo(int ticks)
|
|||
|
||||
void button_init(void)
|
||||
{
|
||||
tick_add_task(button_tick);
|
||||
}
|
||||
|
||||
int button_status(void)
|
||||
|
|
|
@ -17,8 +17,12 @@
|
|||
*
|
||||
****************************************************************************/
|
||||
|
||||
#include <stddef.h>
|
||||
#include "kernel.h"
|
||||
#include "thread.h"
|
||||
#include "debug.h"
|
||||
|
||||
static void (*tick_funcs[MAX_NUM_TICK_TASKS])(void);
|
||||
|
||||
int set_irq_level (int level)
|
||||
{
|
||||
|
@ -91,6 +95,54 @@ void switch_thread (void)
|
|||
yield ();
|
||||
}
|
||||
|
||||
void sim_tick_tasks(void)
|
||||
{
|
||||
int i;
|
||||
|
||||
/* Run through the list of tick tasks */
|
||||
for(i = 0;i < MAX_NUM_TICK_TASKS;i++)
|
||||
{
|
||||
if(tick_funcs[i])
|
||||
{
|
||||
tick_funcs[i]();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
int tick_add_task(void (*f)(void))
|
||||
{
|
||||
int i;
|
||||
|
||||
/* Add a task if there is room */
|
||||
for(i = 0;i < MAX_NUM_TICK_TASKS;i++)
|
||||
{
|
||||
if(tick_funcs[i] == NULL)
|
||||
{
|
||||
tick_funcs[i] = f;
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
DEBUGF("Error! tick_add_task(): out of tasks");
|
||||
return -1;
|
||||
}
|
||||
|
||||
int tick_remove_task(void (*f)(void))
|
||||
{
|
||||
int i;
|
||||
|
||||
/* Remove a task if it is there */
|
||||
for(i = 0;i < MAX_NUM_TICK_TASKS;i++)
|
||||
{
|
||||
if(tick_funcs[i] == f)
|
||||
{
|
||||
tick_funcs[i] = NULL;
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
void mutex_init(struct mutex *m)
|
||||
{
|
||||
(void)m;
|
||||
|
|
|
@ -30,7 +30,7 @@
|
|||
#endif
|
||||
|
||||
long current_tick = 0;
|
||||
extern void button_tick(void);
|
||||
extern void sim_tick_tasks(void);
|
||||
|
||||
static void msleep(int msec)
|
||||
{
|
||||
|
@ -59,10 +59,8 @@ static void update_tick_thread()
|
|||
+ (now.tv_usec - start.tv_usec) / (1000000/HZ);
|
||||
if (new_tick > current_tick)
|
||||
{
|
||||
sim_tick_tasks();
|
||||
current_tick = new_tick;
|
||||
button_tick(); /* Dirty call to button.c. This should probably
|
||||
* be implemented as a tick task the same way
|
||||
* as on the target. */
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue