Rework lcd_enabled and lcd_set/call_enable hook

a) lcd_enabled() is now lcd_active(), and is available for HAVE_LCD_SLEEP only targets (e.g. ipod video) too. It was depandent on HAVE_LCD_ENALE only before
b) rename the hook accordingly, and implement the hook for other other targets too (e.g. the clip [the only mono target with lcd_enable/lcd_sleep yet, so the code is still in the lcd driver], ipod, fuze, c200)

git-svn-id: svn://svn.rockbox.org/rockbox/trunk@20331 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
Thomas Martitz 2009-03-17 02:43:47 +00:00
parent aad712d39f
commit b7739fbf1c
23 changed files with 101 additions and 84 deletions

View file

@ -138,8 +138,8 @@ static const struct plugin_api rockbox_api = {
#ifdef HAVE_LCD_INVERT
lcd_set_invert_display,
#endif /* HAVE_LCD_INVERT */
#if defined(HAVE_LCD_ENABLE) && defined(HAVE_LCD_COLOR)
lcd_set_enable_hook,
#if defined(HAVE_LCD_ENABLE) || defined(HAVE_LCD_SLEEP)
lcd_activation_set_hook,
&button_queue,
#endif
bidi_l2v,

View file

@ -223,8 +223,8 @@ struct plugin_api {
void (*lcd_set_invert_display)(bool yesno);
#endif /* HAVE_LCD_INVERT */
#if defined(HAVE_LCD_ENABLE) && defined(HAVE_LCD_COLOR)
void (*lcd_set_enable_hook)(void (*enable_hook)(void));
#if defined(HAVE_LCD_ENABLE) || defined(HAVE_LCD_SLEEP)
void (*lcd_activation_set_hook)(void (*enable_hook)(void));
struct event_queue *button_queue;
#endif
unsigned short *(*bidi_l2v)( const unsigned char *str, int orientation );

View file

@ -604,7 +604,7 @@ static int get_start_time(uint32_t duration)
lcd_(update)();
#if defined(HAVE_LCD_ENABLE) && defined(HAVE_LCD_COLOR)
rb->lcd_set_enable_hook(get_start_time_lcd_enable_hook);
rb->lcd_activation_set_hook(get_start_time_lcd_enable_hook);
#endif
draw_slider(0, 100, &rc_bound);
@ -794,11 +794,10 @@ static int get_start_time(uint32_t duration)
rb->yield();
}
#ifdef HAVE_LCD_COLOR
#ifdef HAVE_LCD_ENABLE
rb->lcd_set_enable_hook(NULL);
#if defined(HAVE_LCD_ENABLE) || defined(HAVE_LCD_SLEEP)
rb->lcd_activation_set_hook(NULL);
#endif
#else
#ifndef HAVE_LCD_COLOR
stream_gray_show(false);
grey_clear_display();
grey_update();

View file

@ -621,7 +621,7 @@ static void draw_putsxy_oriented(int x, int y, const char *str)
}
#endif /* LCD_PORTRAIT */
#if defined(HAVE_LCD_ENABLE) && defined(HAVE_LCD_COLOR)
#if defined(HAVE_LCD_ENABLE) || defined(HAVE_LCD_SLEEP)
/* So we can refresh the overlay */
static void wvs_lcd_enable_hook(void)
{
@ -635,12 +635,12 @@ static void wvs_backlight_on_video_mode(bool video_on)
/* Turn off backlight timeout */
/* backlight control in lib/helper.c */
backlight_force_on();
#if defined(HAVE_LCD_ENABLE) && defined(HAVE_LCD_COLOR)
rb->lcd_set_enable_hook(NULL);
#if defined(HAVE_LCD_ENABLE) || defined(HAVE_LCD_SLEEP)
rb->lcd_activation_set_hook(NULL);
#endif
} else {
#if defined(HAVE_LCD_ENABLE) && defined(HAVE_LCD_COLOR)
rb->lcd_set_enable_hook(wvs_lcd_enable_hook);
#if defined(HAVE_LCD_ENABLE) || defined(HAVE_LCD_SLEEP)
rb->lcd_activation_set_hook(wvs_lcd_enable_hook);
#endif
/* Revert to user's backlight settings */
backlight_use_settings();
@ -1485,7 +1485,7 @@ static void button_loop(void)
continue;
} /* BUTTON_NONE: */
#ifdef HAVE_LCD_ENABLE
#if defined(HAVE_LCD_ENABLE) || defined(HAVE_LCD_SLEEP)
case LCD_ENABLE_EVENT_1:
{
/* Draw the current frame if prepared already */
@ -1628,10 +1628,10 @@ static void button_loop(void)
wvs_stop();
#if defined(HAVE_LCD_ENABLE) && defined(HAVE_LCD_COLOR)
#if defined(HAVE_LCD_ENABLE) || defined(HAVE_LCD_SLEEP)
/* Be sure hook is removed before exiting since the stop will put it
* back because of the backlight restore. */
rb->lcd_set_enable_hook(NULL);
rb->lcd_activation_set_hook(NULL);
#endif
rb->lcd_setfont(FONT_UI);

View file

@ -1384,8 +1384,8 @@ void lcd_set_drawmode(int mode)
\param mode
\description
void lcd_set_enable_hook(void (*enable_hook)(void))
\conditions !defined(HAVE_LCD_CHARCELLS) && defined(HAVE_LCD_ENABLE) && defined(HAVE_LCD_COLOR)
void lcd_activation_set_hook(void (*enable_hook)(void))
\conditions !defined(HAVE_LCD_CHARCELLS) && (defined(HAVE_LCD_ENABLE) || defined(HAVE_LCD_SLEEP))
\param enable_hook
\description

View file

@ -51,10 +51,6 @@ fb_data lcd_framebuffer[LCD_FBHEIGHT][LCD_FBWIDTH]
static fb_data* lcd_backdrop = NULL;
static long lcd_backdrop_offset IDATA_ATTR = 0;
#ifdef HAVE_LCD_ENABLE
static void (*lcd_enable_hook)(void) = NULL;
#endif
static struct viewport default_vp =
{
.x = 0,
@ -78,6 +74,27 @@ static struct viewport* current_vp IDATA_ATTR = &default_vp;
struct viewport* current_vp IDATA_ATTR = &default_vp;
#endif
/*** Helpers - consolidate optional code ***/
#if defined(HAVE_LCD_ENABLE) || defined(HAVE_LCD_SLEEP)
static void (*lcd_activation_hook)(void) = NULL;
void lcd_activation_set_hook(void (*func)(void))
{
lcd_activation_hook = func;
}
/* To be called by target driver after enabling display and refreshing it */
void lcd_activation_call_hook(void)
{
void (*func)(void) = lcd_activation_hook;
if (func != NULL)
func();
}
#endif
/* LCD init */
void lcd_init(void)
{
@ -87,24 +104,6 @@ void lcd_init(void)
lcd_init_device();
scroll_init();
}
/*** Helpers - consolidate optional code ***/
#ifdef HAVE_LCD_ENABLE
void lcd_set_enable_hook(void (*enable_hook)(void))
{
lcd_enable_hook = enable_hook;
}
/* To be called by target driver after enabling display and refreshing it */
void lcd_call_enable_hook(void)
{
void (*enable_hook)(void) = lcd_enable_hook;
if (enable_hook != NULL)
enable_hook();
}
#endif
/*** Viewports ***/
void lcd_set_viewport(struct viewport* vp)

View file

@ -341,21 +341,21 @@ void lcd_poweroff(void);
#ifdef HAVE_LCD_ENABLE
/* Enable/disable the main display. */
extern void lcd_enable(bool on);
extern bool lcd_enabled(void);
#ifdef HAVE_LCD_COLOR
/* Register a hook that is called when the lcd is powered and after the
* framebuffer data is synchronized */
void lcd_set_enable_hook(void (*enable_hook)(void));
#endif /* HAVE_LCD_COLOR */
#endif /* HAVE_LCD_ENABLE */
void lcd_call_enable_hook(void);
#ifdef HAVE_LCD_SLEEP
/* Put the LCD into a power saving state deeper than lcd_enable(false). */
extern void lcd_sleep(void);
#endif /* HAVE_LCD_SLEEP */
#if defined(HAVE_LCD_ENABLE) || defined(HAVE_LCD_SLEEP)
/* Register a hook that is called when the lcd is powered and after the
* framebuffer data is synchronized */
/* Sansa Clip has these function in it's lcd driver, since it's the only
* 1-bit display featuring lcd_active, so far */
extern bool lcd_active(void);
extern void lcd_activation_set_hook(void (*enable_hook)(void));
extern void lcd_activation_call_hook(void);
#endif
#ifdef HAVE_LCD_SHUTDOWN
void lcd_shutdown(void);

View file

@ -305,8 +305,8 @@ static void scroll_thread(void)
if (scroll & SCROLL_LCD)
{
#ifdef HAVE_LCD_ENABLE
if (lcd_enabled())
#if defined(HAVE_LCD_ENABLE) || defined(HAVE_LCD_SLEEP)
if (lcd_active())
#endif
lcd_scroll_fn();
lcd_scroll_info.last_scroll = current_tick;
@ -328,8 +328,8 @@ static void scroll_thread(void)
while (1)
{
sleep(lcd_scroll_info.ticks);
#ifdef HAVE_LCD_ENABLE
if (lcd_enabled())
#if defined(HAVE_LCD_ENABLE) || defined(HAVE_LCD_SLEEP)
if (lcd_active())
#endif
lcd_scroll_fn();
}

View file

@ -322,7 +322,7 @@ void lcd_enable(bool on)
if(on)
{
_display_on();
lcd_call_enable_hook();
lcd_activation_call_hook();
}
else
{
@ -332,7 +332,7 @@ void lcd_enable(bool on)
}
}
bool lcd_enabled(void)
bool lcd_active(void)
{
return display_on;
}

View file

@ -159,22 +159,43 @@ void lcd_set_flip(bool yesno)
}
}
#ifdef HAVE_LCD_ENABLE
static void (*lcd_activation_hook)(void) = NULL;
void lcd_activation_set_hook(void (*func)(void))
{
lcd_activation_hook = func;
}
void lcd_activation_call_hook(void)
{
void (*func)(void) = lcd_activation_hook;
if (func != NULL)
func();
}
void lcd_enable(bool enable)
{
if(display_on == enable)
return;
if( (display_on = enable) ) /* simple '=' is not a typo ! */
{
lcd_write_command(LCD_SET_DISPLAY_ON);
lcd_activation_call_hook();
}
else
lcd_write_command(LCD_SET_DISPLAY_OFF);
}
bool lcd_enabled(void)
bool lcd_active(void)
{
return display_on;
}
#endif
/* LCD init, largely based on what OF does */
void lcd_init_device(void)

View file

@ -328,7 +328,7 @@ void lcd_enable(bool on)
if(on)
{
_display_on();
lcd_call_enable_hook();
lcd_activation_call_hook();
}
else
{
@ -338,7 +338,7 @@ void lcd_enable(bool on)
}
}
bool lcd_enabled(void)
bool lcd_active(void)
{
return display_on;
}

View file

@ -206,6 +206,7 @@ void lcd_enable(bool on)
/* a bit of delay before returning to
* avoid irritating flash on backlight on */
while(delay--);
lcd_activation_call_hook();
}
else
@ -217,7 +218,7 @@ void lcd_enable(bool on)
}
}
bool lcd_enabled(void)
bool lcd_active(void)
{
return display_on;
}

View file

@ -121,7 +121,7 @@ void lcd_enable(bool state)
lcd_powered = true;
lcd_on = true;
lcd_update();
lcd_call_enable_hook();
lcd_activation_call_hook();
}
else
{
@ -129,7 +129,7 @@ void lcd_enable(bool state)
}
}
bool lcd_enabled(void)
bool lcd_active(void)
{
return lcd_on;
}

View file

@ -575,10 +575,7 @@ void lcd_awake(void)
lcd_state.state = LCD_INITIAL;
tick_add_task(&lcd_tick);
lcd_state.display_on = true;
/* Note that only the RGB data from lcd_framebuffer has been
displayed. If YUV data was displayed, it needs to be updated
now. (eg. see lcd_call_enable_hook())
*/
lcd_activation_call_hook();
}
mutex_unlock(&lcdstate_lock);
}

View file

@ -363,7 +363,7 @@ void lcd_enable(bool on)
/* Probably out of sync and we don't wanna pepper the code with
lcd_update() calls for this. */
lcd_update();
lcd_call_enable_hook();
lcd_activation_call_hook();
}
else
{
@ -371,7 +371,7 @@ void lcd_enable(bool on)
}
}
bool lcd_enabled(void)
bool lcd_active(void)
{
return display_on;
}

View file

@ -42,7 +42,7 @@ extern struct viewport* current_vp;
extern void lcd_copy_buffer_rect(fb_data *dst, const fb_data *src,
int width, int height);
bool lcd_enabled(void)
bool lcd_active(void)
{
return lcd_on;
}
@ -308,7 +308,7 @@ void lcd_enable(bool state)
lcd_on = true;
lcd_update();
lcd_call_enable_hook();
lcd_activation_call_hook();
}
else
{

View file

@ -438,7 +438,7 @@ void lcd_enable(bool on)
DEV_EN |= DEV_LCD; /* Enable LCD controller */
lcd_display_on(); /* Turn on display */
lcd_update(); /* Resync display */
lcd_call_enable_hook();
lcd_activation_call_hook();
LCD_REG_6 |= 1; /* Restart DMA */
sleep(HZ/50); /* Wait for a frame to be written */
}
@ -451,7 +451,7 @@ void lcd_enable(bool on)
}
}
bool lcd_enabled(void)
bool lcd_active(void)
{
return display_on;
}

View file

@ -143,7 +143,7 @@ void lcd_enable(bool on)
if (on) {
_display_on();
lcd_call_enable_hook();
lcd_activation_call_hook();
} else {
/** Off sequence according to datasheet, p. 130 **/
lcd_write_reg(R_FRAME_CYCLE_CONTROL, 0x0002); /* EQ=0, 18 clks/line */
@ -166,7 +166,7 @@ void lcd_enable(bool on)
}
}
bool lcd_enabled(void)
bool lcd_active(void)
{
return display_on;
}

View file

@ -230,7 +230,7 @@ void lcd_enable(bool on)
lcd_display_on();
LCDC_CTRL |= 1; /* controller enable */
lcd_update(); /* Resync display */
lcd_call_enable_hook();
lcd_activation_call_hook();
}
else
{
@ -239,7 +239,7 @@ void lcd_enable(bool on)
}
}
bool lcd_enabled(void)
bool lcd_active(void)
{
return display_on;
}

View file

@ -237,7 +237,7 @@ return;
{
lcd_display_on(false); /* Turn on display */
lcd_update(); /* Resync display */
lcd_call_enable_hook();
lcd_activation_call_hook();
}
else
{
@ -245,7 +245,7 @@ return;
}
}
bool lcd_enabled(void)
bool lcd_active(void)
{
return display_on;
}

View file

@ -385,7 +385,7 @@ void lcd_enable(bool on)
/* Probably out of sync and we don't wanna pepper the code with
lcd_update() calls for this. */
lcd_update();
lcd_call_enable_hook();
lcd_activation_call_hook();
}
else
{
@ -393,7 +393,7 @@ void lcd_enable(bool on)
}
}
bool lcd_enabled(void)
bool lcd_active(void)
{
return display_on;
}

View file

@ -263,7 +263,7 @@ void lcd_enable(bool on)
if(on)
{
_display_on();
lcd_call_enable_hook();
lcd_activation_call_hook();
}
else
{
@ -290,7 +290,7 @@ void lcd_enable(bool on)
}
}
bool lcd_enabled(void)
bool lcd_active(void)
{
return display_on;
}

View file

@ -54,7 +54,7 @@ void lcd_enable(bool state)
{
lcd_on();
#ifdef HAVE_LCD_ENABLE
lcd_call_enable_hook();
lcd_activation_call_hook();
#endif
}
else
@ -63,7 +63,7 @@ void lcd_enable(bool state)
lcd_is_on = state;
}
bool lcd_enabled(void)
bool lcd_active(void)
{
return lcd_is_on;
}