Index: docs/PLUGIN_API.new =================================================================== --- docs/PLUGIN_API.new (Revision 20316) +++ docs/PLUGIN_API.new (Arbeitskopie) @@ -1384,8 +1384,8 @@ \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 Index: apps/plugins/mpegplayer/mpegplayer.c =================================================================== --- apps/plugins/mpegplayer/mpegplayer.c (Revision 20316) +++ apps/plugins/mpegplayer/mpegplayer.c (Arbeitskopie) @@ -621,7 +621,7 @@ } #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 @@ /* 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 @@ 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 @@ 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); Index: apps/plugins/mpegplayer/mpeg_settings.c =================================================================== --- apps/plugins/mpegplayer/mpeg_settings.c (Revision 20316) +++ apps/plugins/mpegplayer/mpeg_settings.c (Arbeitskopie) @@ -604,7 +604,7 @@ 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 @@ 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(); Index: apps/plugin.c =================================================================== --- apps/plugin.c (Revision 20316) +++ apps/plugin.c (Arbeitskopie) @@ -138,8 +138,8 @@ #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, Index: apps/plugin.h =================================================================== --- apps/plugin.h (Revision 20316) +++ apps/plugin.h (Arbeitskopie) @@ -223,8 +223,8 @@ 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 ); Index: firmware/export/lcd.h =================================================================== --- firmware/export/lcd.h (Revision 20316) +++ firmware/export/lcd.h (Arbeitskopie) @@ -341,21 +341,21 @@ #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); Index: firmware/target/arm/tcc780x/cowond2/lcd-cowond2.c =================================================================== --- firmware/target/arm/tcc780x/cowond2/lcd-cowond2.c (Revision 20316) +++ firmware/target/arm/tcc780x/cowond2/lcd-cowond2.c (Arbeitskopie) @@ -230,7 +230,7 @@ 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 @@ } } -bool lcd_enabled(void) +bool lcd_active(void) { return display_on; } Index: firmware/target/arm/tcc77x/iaudio7/lcd-iaudio7.c =================================================================== --- firmware/target/arm/tcc77x/iaudio7/lcd-iaudio7.c (Revision 20316) +++ firmware/target/arm/tcc77x/iaudio7/lcd-iaudio7.c (Arbeitskopie) @@ -143,7 +143,7 @@ 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 @@ } } -bool lcd_enabled(void) +bool lcd_active(void) { return display_on; } Index: firmware/target/arm/as3525/sansa-c200v2/lcd-c200v2.c =================================================================== --- firmware/target/arm/as3525/sansa-c200v2/lcd-c200v2.c (Revision 20316) +++ firmware/target/arm/as3525/sansa-c200v2/lcd-c200v2.c (Arbeitskopie) @@ -322,7 +322,7 @@ if(on) { _display_on(); - lcd_call_enable_hook(); + lcd_activation_call_hook(); } else { @@ -332,7 +332,7 @@ } } -bool lcd_enabled(void) +bool lcd_active(void) { return display_on; } Index: firmware/target/arm/as3525/sansa-e200v2/lcd-e200v2.c =================================================================== --- firmware/target/arm/as3525/sansa-e200v2/lcd-e200v2.c (Revision 20316) +++ firmware/target/arm/as3525/sansa-e200v2/lcd-e200v2.c (Arbeitskopie) @@ -328,7 +328,7 @@ if(on) { _display_on(); - lcd_call_enable_hook(); + lcd_activation_call_hook(); } else { @@ -338,7 +338,7 @@ } } -bool lcd_enabled(void) +bool lcd_active(void) { return display_on; } Index: firmware/target/arm/as3525/sansa-clip/lcd-ssd1303.c =================================================================== --- firmware/target/arm/as3525/sansa-clip/lcd-ssd1303.c (Revision 20316) +++ firmware/target/arm/as3525/sansa-clip/lcd-ssd1303.c (Arbeitskopie) @@ -159,22 +159,43 @@ } } +#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) Index: firmware/target/arm/as3525/sansa-fuze/lcd-fuze.c =================================================================== --- firmware/target/arm/as3525/sansa-fuze/lcd-fuze.c (Revision 20316) +++ firmware/target/arm/as3525/sansa-fuze/lcd-fuze.c (Arbeitskopie) @@ -206,6 +206,7 @@ /* a bit of delay before returning to * avoid irritating flash on backlight on */ while(delay--); + lcd_activation_call_hook(); } else @@ -217,7 +218,7 @@ } } -bool lcd_enabled(void) +bool lcd_active(void) { return display_on; } Index: firmware/target/arm/ipod/video/lcd-video.c =================================================================== --- firmware/target/arm/ipod/video/lcd-video.c (Revision 20316) +++ firmware/target/arm/ipod/video/lcd-video.c (Arbeitskopie) @@ -575,10 +575,7 @@ 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); } Index: firmware/target/arm/sandisk/sansa-e200/lcd-e200.c =================================================================== --- firmware/target/arm/sandisk/sansa-e200/lcd-e200.c (Revision 20316) +++ firmware/target/arm/sandisk/sansa-e200/lcd-e200.c (Arbeitskopie) @@ -438,7 +438,7 @@ 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 @@ } } -bool lcd_enabled(void) +bool lcd_active(void) { return display_on; } Index: firmware/target/arm/tms320dm320/creative-zvm/lcd-creativezvm.c =================================================================== --- firmware/target/arm/tms320dm320/creative-zvm/lcd-creativezvm.c (Revision 20316) +++ firmware/target/arm/tms320dm320/creative-zvm/lcd-creativezvm.c (Arbeitskopie) @@ -237,7 +237,7 @@ { lcd_display_on(false); /* Turn on display */ lcd_update(); /* Resync display */ - lcd_call_enable_hook(); + lcd_activation_call_hook(); } else { @@ -245,7 +245,7 @@ } } -bool lcd_enabled(void) +bool lcd_active(void) { return display_on; } Index: firmware/target/arm/iriver/h10/lcd-h10_20gb.c =================================================================== --- firmware/target/arm/iriver/h10/lcd-h10_20gb.c (Revision 20316) +++ firmware/target/arm/iriver/h10/lcd-h10_20gb.c (Arbeitskopie) @@ -363,7 +363,7 @@ /* 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 @@ } } -bool lcd_enabled(void) +bool lcd_active(void) { return display_on; } Index: firmware/target/arm/imx31/gigabeat-s/lcd-imx31.c =================================================================== --- firmware/target/arm/imx31/gigabeat-s/lcd-imx31.c (Revision 20316) +++ firmware/target/arm/imx31/gigabeat-s/lcd-imx31.c (Arbeitskopie) @@ -121,7 +121,7 @@ lcd_powered = true; lcd_on = true; lcd_update(); - lcd_call_enable_hook(); + lcd_activation_call_hook(); } else { @@ -129,7 +129,7 @@ } } -bool lcd_enabled(void) +bool lcd_active(void) { return lcd_on; } Index: firmware/target/arm/s3c2440/gigabeat-fx/lcd-meg-fx.c =================================================================== --- firmware/target/arm/s3c2440/gigabeat-fx/lcd-meg-fx.c (Revision 20316) +++ firmware/target/arm/s3c2440/gigabeat-fx/lcd-meg-fx.c (Arbeitskopie) @@ -42,7 +42,7 @@ 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 @@ lcd_on = true; lcd_update(); - lcd_call_enable_hook(); + lcd_activation_call_hook(); } else { Index: firmware/target/coldfire/iriver/h300/lcd-h300.c =================================================================== --- firmware/target/coldfire/iriver/h300/lcd-h300.c (Revision 20316) +++ firmware/target/coldfire/iriver/h300/lcd-h300.c (Arbeitskopie) @@ -263,7 +263,7 @@ if(on) { _display_on(); - lcd_call_enable_hook(); + lcd_activation_call_hook(); } else { @@ -290,7 +290,7 @@ } } -bool lcd_enabled(void) +bool lcd_active(void) { return display_on; } Index: firmware/target/coldfire/iaudio/x5/lcd-x5.c =================================================================== --- firmware/target/coldfire/iaudio/x5/lcd-x5.c (Revision 20316) +++ firmware/target/coldfire/iaudio/x5/lcd-x5.c (Arbeitskopie) @@ -385,7 +385,7 @@ /* 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 @@ } } -bool lcd_enabled(void) +bool lcd_active(void) { return display_on; } Index: firmware/target/mips/ingenic_jz47xx/lcd-jz4740.c =================================================================== --- firmware/target/mips/ingenic_jz47xx/lcd-jz4740.c (Revision 20316) +++ firmware/target/mips/ingenic_jz47xx/lcd-jz4740.c (Arbeitskopie) @@ -54,7 +54,7 @@ { lcd_on(); #ifdef HAVE_LCD_ENABLE - lcd_call_enable_hook(); + lcd_activation_call_hook(); #endif } else @@ -63,7 +63,7 @@ lcd_is_on = state; } -bool lcd_enabled(void) +bool lcd_active(void) { return lcd_is_on; } Index: firmware/scroll_engine.c =================================================================== --- firmware/scroll_engine.c (Revision 20316) +++ firmware/scroll_engine.c (Arbeitskopie) @@ -305,8 +305,8 @@ 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 @@ 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(); } Index: firmware/drivers/lcd-16bit.c =================================================================== --- firmware/drivers/lcd-16bit.c (Revision 20316) +++ firmware/drivers/lcd-16bit.c (Arbeitskopie) @@ -51,10 +51,6 @@ 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 @@ 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)