summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas Martitz <kugel@rockbox.org>2009-04-29 22:24:40 +0000
committerThomas Martitz <kugel@rockbox.org>2009-04-29 22:24:40 +0000
commita7f4e1f1c51c6f99d17eb25dbdd57a78af4cb0e1 (patch)
tree56e877c510c54d67688680f72ed2384389b4a3c7
parentecd4394f624b9f10b091bc90a63fd80653f85fad (diff)
downloadrockbox-a7f4e1f1c51c6f99d17eb25dbdd57a78af4cb0e1.zip
rockbox-a7f4e1f1c51c6f99d17eb25dbdd57a78af4cb0e1.tar.gz
rockbox-a7f4e1f1c51c6f99d17eb25dbdd57a78af4cb0e1.tar.bz2
rockbox-a7f4e1f1c51c6f99d17eb25dbdd57a78af4cb0e1.tar.xz
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
-rw-r--r--firmware/export/config-h300.h5
-rw-r--r--firmware/export/config-ipodvideo.h7
-rw-r--r--firmware/export/config-mrobe100.h17
-rw-r--r--uisimulator/common/SOURCES1
-rw-r--r--uisimulator/common/backlight-sim.c84
-rw-r--r--uisimulator/common/backlight-sim.h54
-rw-r--r--uisimulator/common/lcd-common.c55
-rw-r--r--uisimulator/common/stubs.c13
-rw-r--r--uisimulator/uisimulator.make2
9 files changed, 172 insertions, 66 deletions
diff --git a/firmware/export/config-h300.h b/firmware/export/config-h300.h
index ba09884..e6e07e0 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 c9f97dc..6adcda9 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 e440f7c..b1299a8 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 bda79b6..c186551 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 0000000..ec50249
--- /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 <stdbool.h>
+#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 59abe36..366ebf8 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 7d40f36..52db776 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 5d3c54a..1d0d6c5 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 f39d6e0..9aeb02c 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