From a7f4e1f1c51c6f99d17eb25dbdd57a78af4cb0e1 Mon Sep 17 00:00:00 2001 From: Thomas Martitz Date: Wed, 29 Apr 2009 22:24:40 +0000 Subject: Simulate lcd_enable and lcd_sleep in the simulator. Therefore, turn backlight-sim.h into a .c too. git-svn-id: svn://svn.rockbox.org/rockbox/trunk@20829 a1c6a512-1295-4272-9138-f99709370657 --- firmware/export/config-h300.h | 5 +-- firmware/export/config-ipodvideo.h | 7 ++-- firmware/export/config-mrobe100.h | 17 ++++---- uisimulator/common/SOURCES | 1 + uisimulator/common/backlight-sim.c | 84 ++++++++++++++++++++++++++++++++++++++ uisimulator/common/backlight-sim.h | 54 ++++++++---------------- uisimulator/common/lcd-common.c | 55 ++++++++++++++++++++++++- uisimulator/common/stubs.c | 13 ------ uisimulator/uisimulator.make | 2 +- 9 files changed, 172 insertions(+), 66 deletions(-) create mode 100644 uisimulator/common/backlight-sim.c diff --git a/firmware/export/config-h300.h b/firmware/export/config-h300.h index ba09884957..e6e07e0bbc 100644 --- a/firmware/export/config-h300.h +++ b/firmware/export/config-h300.h @@ -76,6 +76,8 @@ #define HAVE_BACKLIGHT_BRIGHTNESS /* Which backlight fading type? */ #define CONFIG_BACKLIGHT_FADING BACKLIGHT_FADING_SW_HW_REG +/* Define this if your LCD can be enabled/disabled */ +#define HAVE_LCD_ENABLE /* Define this if you have a software controlled poweroff */ #define HAVE_SW_POWEROFF @@ -133,9 +135,6 @@ #ifndef SIMULATOR -/* Define this if your LCD can be enabled/disabled */ -#define HAVE_LCD_ENABLE - /* Define this if you have a Motorola SCF5249 */ #define CONFIG_CPU MCF5249 diff --git a/firmware/export/config-ipodvideo.h b/firmware/export/config-ipodvideo.h index c9f97dcea5..6adcda9a1e 100644 --- a/firmware/export/config-ipodvideo.h +++ b/firmware/export/config-ipodvideo.h @@ -91,6 +91,10 @@ #define HAVE_BACKLIGHT #define HAVE_BACKLIGHT_BRIGHTNESS +/* Support for LCD sleep/BCM shutdown */ +#define HAVE_LCD_SLEEP +#define HAVE_LCD_SLEEP_SETTING + /* We can fade the backlight by using PWM */ #define CONFIG_BACKLIGHT_FADING BACKLIGHT_FADING_PWM @@ -208,9 +212,6 @@ #define HAVE_SERIAL #ifndef BOOTLOADER -/* Support for LCD sleep/BCM shutdown */ -#define HAVE_LCD_SLEEP -#define HAVE_LCD_SLEEP_SETTING /* The same code may also be used when shutting down the iPod */ #define HAVE_LCD_SHUTDOWN #endif diff --git a/firmware/export/config-mrobe100.h b/firmware/export/config-mrobe100.h index e440f7c9a0..b1299a820a 100644 --- a/firmware/export/config-mrobe100.h +++ b/firmware/export/config-mrobe100.h @@ -90,6 +90,15 @@ #define HAVE_BUTTONLIGHT_BRIGHTNESS +/* Define this if your LCD can be enabled/disabled */ +/* TODO: #define HAVE_LCD_ENABLE */ + +/* Define this if your LCD can be put to sleep. HAVE_LCD_ENABLE + * should be defined as well. + * We can currently put the lcd to sleep but it won't wake up properly */ +/*TODO: #define HAVE_LCD_SLEEP*/ +/*TODO: #define HAVE_LCD_SLEEP_SETTING <= optional */ + #define BATTERY_CAPACITY_DEFAULT 720 /* default battery capacity */ #ifndef SIMULATOR @@ -132,14 +141,6 @@ #define MAX_CONTRAST_SETTING 40 #define DEFAULT_CONTRAST_SETTING 20 -/* Define this if your LCD can be enabled/disabled */ -/* TODO: #define HAVE_LCD_ENABLE */ - -/* Define this if your LCD can be put to sleep. HAVE_LCD_ENABLE - * should be defined as well. - * We can currently put the lcd to sleep but it won't wake up properly */ -/*TODO: #define HAVE_LCD_SLEEP*/ -/*TODO: #define HAVE_LCD_SLEEP_SETTING <= optional */ /* We're able to shut off power to the HDD */ #define HAVE_ATA_POWER_OFF diff --git a/uisimulator/common/SOURCES b/uisimulator/common/SOURCES index bda79b66b9..c1865513f9 100644 --- a/uisimulator/common/SOURCES +++ b/uisimulator/common/SOURCES @@ -9,4 +9,5 @@ sim_icons.c sim_tasks.c stubs.c powermgmt-sim.c +backlight-sim.c diff --git a/uisimulator/common/backlight-sim.c b/uisimulator/common/backlight-sim.c new file mode 100644 index 0000000000..ec50249dde --- /dev/null +++ b/uisimulator/common/backlight-sim.c @@ -0,0 +1,84 @@ +/*************************************************************************** + * __________ __ ___. + * Open \______ \ ____ ____ | | _\_ |__ _______ ___ + * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / + * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < + * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ + * \/ \/ \/ \/ \/ + * $Id$ + * + * Copyright (C) 2009 by Thomas Martitz + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY + * KIND, either express or implied. + * + ****************************************************************************/ + +#include +#include "config.h" +#include "backlight.h" +#include "lcd.h" + +#ifdef HAVE_LCD_SLEEP +extern void lcd_awake(void); +#endif +/* in uisimulator/sdl/lcd-bitmap.c and lcd-charcell.c */ +extern void sim_backlight(int value); + +void _backlight_on(void) +{ + sim_backlight(100); +#if defined(HAVE_LCD_ENABLE) + lcd_enable(true); +#elif defined(HAVE_LCD_SLEEP) + lcd_awake(); +#endif +} + +void _backlight_off(void) +{ + sim_backlight(0); +#ifdef HAVE_LCD_ENABLE + lcd_enable(false); +#endif +} + +#ifdef HAVE_BACKLIGHT_BRIGHTNESS +void _backlight_set_brightness(int val) +{ + (void)val; +} +#endif /* HAVE_BACKLIGHT_BRIGHTNESS */ +#ifdef HAVE_BUTTON_LIGHT +void _buttonlight_on(void) +{ +} + +void _buttonlight_off(void) +{ +} + +#ifdef HAVE_BUTTONLIGHT_BRIGHTNESS +void _buttonlight_set_brightness(int val) +{ + (void)val; +} +#endif /* HAVE_BUTTONLIGHT_BRIGHTNESS */ +#endif /* HAVE_BUTTON_LIGHT */ + +#ifdef HAVE_REMOTE_LCD +void _remote_backlight_on(void) +{ + sim_remote_backlight(100); +} + +void _remote_backlight_off(void) +{ + sim_remote_backlight(0); +} +#endif /* HAVE_REMOTE_LCD */ diff --git a/uisimulator/common/backlight-sim.h b/uisimulator/common/backlight-sim.h index 59abe36f7d..366ebf8096 100644 --- a/uisimulator/common/backlight-sim.h +++ b/uisimulator/common/backlight-sim.h @@ -5,9 +5,8 @@ * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ * \/ \/ \/ \/ \/ - * $Id$ + * $Id:$ * - * Copyright (C) 2002 by Linus Nielsen Feltzing * Copyright (C) 2009 by Thomas Martitz * * This program is free software; you can redistribute it and/or @@ -19,50 +18,31 @@ * KIND, either express or implied. * ****************************************************************************/ -#ifdef SIMULATOR -static inline void _backlight_on(void) -{ - sim_backlight(100); -} +#ifndef BACKLIGHT_SIM_H +#define BACKLIGHT_SIM_H + +#include "config.h" + +void _backlight_on(void); +void _backlight_off(void); -static inline void _backlight_off(void) -{ - sim_backlight(0); -} #ifdef HAVE_BACKLIGHT_BRIGHTNESS -static inline void _backlight_set_brightness(int val) -{ - (void)val; -} +void _backlight_set_brightness(int val); #endif /* HAVE_BACKLIGHT_BRIGHTNESS */ #ifdef HAVE_BUTTON_LIGHT -static inline void _buttonlight_on(void) -{ -} - -static inline void _buttonlight_off(void) -{ -} - +void _buttonlight_on(void); +void _buttonlight_off(void); #ifdef HAVE_BUTTONLIGHT_BRIGHTNESS -static inline void _buttonlight_set_brightness(int val) -{ - (void)val; -} +void _buttonlight_set_brightness(int val); #endif /* HAVE_BUTTONLIGHT_BRIGHTNESS */ #endif /* HAVE_BUTTON_LIGHT */ #ifdef HAVE_REMOTE_LCD -static inline void _remote_backlight_on(void) -{ - sim_remote_backlight(100); -} - -static inline void _remote_backlight_off(void) -{ - sim_remote_backlight(0); -} +void _remote_backlight_on(void); +void _remote_backlight_off(void); #endif /* HAVE_REMOTE_LCD */ -#endif /* SIMULATOR */ + +#endif /* BACKLIGHT_SIM_H */ + diff --git a/uisimulator/common/lcd-common.c b/uisimulator/common/lcd-common.c index 7d40f36b0f..52db776856 100644 --- a/uisimulator/common/lcd-common.c +++ b/uisimulator/common/lcd-common.c @@ -22,8 +22,15 @@ * ****************************************************************************/ +#include "config.h" #include "lcd.h" -#include "lcd-sdl.h" + +#ifdef HAVE_LCD_ENABLE +static bool lcd_enabled = false; +#endif +#ifdef HAVE_LCD_SLEEP +static bool lcd_sleeping = true; +#endif void lcd_set_flip(bool yesno) { @@ -64,3 +71,49 @@ void lcd_remote_set_invert_display(bool invert) (void)invert; } #endif + +#ifdef HAVE_LCD_SLEEP +void lcd_sleep(void) +{ + lcd_sleeping = true; +} + +void lcd_awake(void) +{ + if (lcd_sleeping) + { + lcd_activation_call_hook(); + lcd_sleeping = false; + } +} +#endif +#ifdef HAVE_LCD_ENABLE +void lcd_enable(bool on) +{ + if (on && !lcd_enabled) + { +#ifdef HAVE_LCD_SLEEP + /* lcd_awake will handle the activation call */ + lcd_awake(); +#else + lcd_activation_call_hook(); +#endif + } + lcd_enabled = on; +} +#endif + +#if defined(HAVE_LCD_ENABLE) || defined(HAVE_LCD_SLEEP) +bool lcd_active(void) +{ + bool retval = false; +#ifdef HAVE_LCD_ENABLE + retval = lcd_enabled; +#endif +#ifdef HAVE_LCD_SLEEP + if (!retval) + retval = !lcd_sleeping; +#endif + return retval; +} +#endif diff --git a/uisimulator/common/stubs.c b/uisimulator/common/stubs.c index 5d3c54a8d0..1d0d6c51d8 100644 --- a/uisimulator/common/stubs.c +++ b/uisimulator/common/stubs.c @@ -202,19 +202,6 @@ bool headphones_inserted(void) } #endif -#if defined(HAVE_LCD_ENABLE) || defined(HAVE_LCD_SLEEP) -bool lcd_active(void) -{ - return true; -} -#endif - -#ifdef HAVE_LCD_SLEEP -void lcd_sleep(void) -{ -} -#endif - #ifdef HAVE_SPDIF_POWER void spdif_power_enable(bool on) { diff --git a/uisimulator/uisimulator.make b/uisimulator/uisimulator.make index f39d6e0265..9aeb02cd3d 100644 --- a/uisimulator/uisimulator.make +++ b/uisimulator/uisimulator.make @@ -28,7 +28,7 @@ $(SIMLIB): $$(SIMOBJ) $(UIBMP) $(SILENT)$(shell rm -f $@) $(call PRINTS,AR $(@F))$(AR) rcs $@ $^ >/dev/null -$(BUILDDIR)/$(BINARY): $$(OBJ) $(SIMLIB) $(VOICESPEEXLIB) $(FIRMLIB) +$(BUILDDIR)/$(BINARY): $$(OBJ) $(FIRMLIB) $(SIMLIB) $(VOICESPEEXLIB) $(call PRINTS,LD $(BINARY))$(CC) -o $@ $^ $(LDOPTS) $(BUILDDIR)/uisimulator/%.o: $(ROOTDIR)/uisimulator/%.c -- cgit v1.2.3