mirror of
https://github.com/Rockbox/rockbox.git
synced 2025-12-08 20:55:17 -05:00
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:
parent
aad712d39f
commit
b7739fbf1c
23 changed files with 101 additions and 84 deletions
|
|
@ -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)
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
|
|
|||
|
|
@ -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();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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
|
||||
{
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue