diff options
author | Thomas Martitz <kugel@rockbox.org> | 2009-03-17 02:43:47 +0000 |
---|---|---|
committer | Thomas Martitz <kugel@rockbox.org> | 2009-03-17 02:43:47 +0000 |
commit | b7739fbf1c838cb6e6e47f9d28d5b339828e1e30 (patch) | |
tree | f4011d6a14cd93fae2002eeccdd63e039ab44f7e /firmware | |
parent | aad712d39f3cdeb95a22e56edb805554dd0a90e1 (diff) |
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
Diffstat (limited to 'firmware')
18 files changed, 81 insertions, 63 deletions
diff --git a/firmware/drivers/lcd-16bit.c b/firmware/drivers/lcd-16bit.c index c3e076b392..0aa62f66b4 100644 --- a/firmware/drivers/lcd-16bit.c +++ b/firmware/drivers/lcd-16bit.c @@ -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,33 +74,36 @@ static struct viewport* current_vp IDATA_ATTR = &default_vp; struct viewport* current_vp IDATA_ATTR = &default_vp; #endif -/* LCD init */ -void lcd_init(void) -{ - lcd_clear_display(); - - /* Call device specific init */ - lcd_init_device(); - scroll_init(); -} /*** Helpers - consolidate optional code ***/ -#ifdef HAVE_LCD_ENABLE -void lcd_set_enable_hook(void (*enable_hook)(void)) +#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_enable_hook = enable_hook; + lcd_activation_hook = func; } /* To be called by target driver after enabling display and refreshing it */ -void lcd_call_enable_hook(void) +void lcd_activation_call_hook(void) { - void (*enable_hook)(void) = lcd_enable_hook; + void (*func)(void) = lcd_activation_hook; - if (enable_hook != NULL) - enable_hook(); + if (func != NULL) + func(); } + #endif +/* LCD init */ +void lcd_init(void) +{ + lcd_clear_display(); + + /* Call device specific init */ + lcd_init_device(); + scroll_init(); +} /*** Viewports ***/ void lcd_set_viewport(struct viewport* vp) diff --git a/firmware/export/lcd.h b/firmware/export/lcd.h index e435d174f2..e34fac5d31 100644 --- a/firmware/export/lcd.h +++ b/firmware/export/lcd.h @@ -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); diff --git a/firmware/scroll_engine.c b/firmware/scroll_engine.c index 6c7f7e6eb0..8d84c797e9 100644 --- a/firmware/scroll_engine.c +++ b/firmware/scroll_engine.c @@ -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(); } diff --git a/firmware/target/arm/as3525/sansa-c200v2/lcd-c200v2.c b/firmware/target/arm/as3525/sansa-c200v2/lcd-c200v2.c index 2fc3e1f6c5..88adcd9d96 100644 --- a/firmware/target/arm/as3525/sansa-c200v2/lcd-c200v2.c +++ b/firmware/target/arm/as3525/sansa-c200v2/lcd-c200v2.c @@ -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; } diff --git a/firmware/target/arm/as3525/sansa-clip/lcd-ssd1303.c b/firmware/target/arm/as3525/sansa-clip/lcd-ssd1303.c index bfa02e796d..640f6694c9 100644 --- a/firmware/target/arm/as3525/sansa-clip/lcd-ssd1303.c +++ b/firmware/target/arm/as3525/sansa-clip/lcd-ssd1303.c @@ -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) diff --git a/firmware/target/arm/as3525/sansa-e200v2/lcd-e200v2.c b/firmware/target/arm/as3525/sansa-e200v2/lcd-e200v2.c index 57d5649570..8715622717 100644 --- a/firmware/target/arm/as3525/sansa-e200v2/lcd-e200v2.c +++ b/firmware/target/arm/as3525/sansa-e200v2/lcd-e200v2.c @@ -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; } diff --git a/firmware/target/arm/as3525/sansa-fuze/lcd-fuze.c b/firmware/target/arm/as3525/sansa-fuze/lcd-fuze.c index 44451133ca..5196784a2f 100644 --- a/firmware/target/arm/as3525/sansa-fuze/lcd-fuze.c +++ b/firmware/target/arm/as3525/sansa-fuze/lcd-fuze.c @@ -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; } diff --git a/firmware/target/arm/imx31/gigabeat-s/lcd-imx31.c b/firmware/target/arm/imx31/gigabeat-s/lcd-imx31.c index 47834b3b19..bddf03c5f6 100644 --- a/firmware/target/arm/imx31/gigabeat-s/lcd-imx31.c +++ b/firmware/target/arm/imx31/gigabeat-s/lcd-imx31.c @@ -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; } diff --git a/firmware/target/arm/ipod/video/lcd-video.c b/firmware/target/arm/ipod/video/lcd-video.c index d1701ea3d7..c0e98cf53c 100644 --- a/firmware/target/arm/ipod/video/lcd-video.c +++ b/firmware/target/arm/ipod/video/lcd-video.c @@ -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); } diff --git a/firmware/target/arm/iriver/h10/lcd-h10_20gb.c b/firmware/target/arm/iriver/h10/lcd-h10_20gb.c index ffd8ab69ec..03a398af8d 100644 --- a/firmware/target/arm/iriver/h10/lcd-h10_20gb.c +++ b/firmware/target/arm/iriver/h10/lcd-h10_20gb.c @@ -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; } diff --git a/firmware/target/arm/s3c2440/gigabeat-fx/lcd-meg-fx.c b/firmware/target/arm/s3c2440/gigabeat-fx/lcd-meg-fx.c index d9a28d152f..fd52eda5e9 100644 --- a/firmware/target/arm/s3c2440/gigabeat-fx/lcd-meg-fx.c +++ b/firmware/target/arm/s3c2440/gigabeat-fx/lcd-meg-fx.c @@ -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 { diff --git a/firmware/target/arm/sandisk/sansa-e200/lcd-e200.c b/firmware/target/arm/sandisk/sansa-e200/lcd-e200.c index e477f4fd45..e1a4d738d7 100644 --- a/firmware/target/arm/sandisk/sansa-e200/lcd-e200.c +++ b/firmware/target/arm/sandisk/sansa-e200/lcd-e200.c @@ -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; } diff --git a/firmware/target/arm/tcc77x/iaudio7/lcd-iaudio7.c b/firmware/target/arm/tcc77x/iaudio7/lcd-iaudio7.c index 0ca18bee67..134d936e7b 100644 --- a/firmware/target/arm/tcc77x/iaudio7/lcd-iaudio7.c +++ b/firmware/target/arm/tcc77x/iaudio7/lcd-iaudio7.c @@ -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; } diff --git a/firmware/target/arm/tcc780x/cowond2/lcd-cowond2.c b/firmware/target/arm/tcc780x/cowond2/lcd-cowond2.c index d6ee5f3649..7b64493c0a 100644 --- a/firmware/target/arm/tcc780x/cowond2/lcd-cowond2.c +++ b/firmware/target/arm/tcc780x/cowond2/lcd-cowond2.c @@ -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; } diff --git a/firmware/target/arm/tms320dm320/creative-zvm/lcd-creativezvm.c b/firmware/target/arm/tms320dm320/creative-zvm/lcd-creativezvm.c index f34e43687a..cd07fa9e6f 100644 --- a/firmware/target/arm/tms320dm320/creative-zvm/lcd-creativezvm.c +++ b/firmware/target/arm/tms320dm320/creative-zvm/lcd-creativezvm.c @@ -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; } diff --git a/firmware/target/coldfire/iaudio/x5/lcd-x5.c b/firmware/target/coldfire/iaudio/x5/lcd-x5.c index fca39e6e26..4737f31bc8 100644 --- a/firmware/target/coldfire/iaudio/x5/lcd-x5.c +++ b/firmware/target/coldfire/iaudio/x5/lcd-x5.c @@ -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; } diff --git a/firmware/target/coldfire/iriver/h300/lcd-h300.c b/firmware/target/coldfire/iriver/h300/lcd-h300.c index 3c70e5be17..867bc5ab74 100644 --- a/firmware/target/coldfire/iriver/h300/lcd-h300.c +++ b/firmware/target/coldfire/iriver/h300/lcd-h300.c @@ -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; } diff --git a/firmware/target/mips/ingenic_jz47xx/lcd-jz4740.c b/firmware/target/mips/ingenic_jz47xx/lcd-jz4740.c index d9eb3ecdef..783621c88b 100644 --- a/firmware/target/mips/ingenic_jz47xx/lcd-jz4740.c +++ b/firmware/target/mips/ingenic_jz47xx/lcd-jz4740.c @@ -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; } |