From 0702a8ed537e427b77022423743a06364f952054 Mon Sep 17 00:00:00 2001 From: peter Date: Mon, 13 Aug 2007 22:31:11 +0000 Subject: [PATCH] Also keep the backlight on in mpegplayer when plugged in. Fixes FS #7584. Created two helper functions for this, because this issue also exists in other plugins (to do). The helper functions are in the pluginlib in helper.[ch], where other common stuff can be put. git-svn-id: svn://svn.rockbox.org/rockbox/trunk@14321 a1c6a512-1295-4272-9138-f99709370657 --- apps/plugin.c | 3 +++ apps/plugin.h | 7 ++++-- apps/plugins/lib/SOURCES | 1 + apps/plugins/lib/helper.c | 46 ++++++++++++++++++++++++++++++++++++ apps/plugins/lib/helper.h | 30 +++++++++++++++++++++++ apps/plugins/mpegplayer/mpegplayer.c | 15 +++--------- 6 files changed, 88 insertions(+), 14 deletions(-) create mode 100644 apps/plugins/lib/helper.c create mode 100644 apps/plugins/lib/helper.h diff --git a/apps/plugin.c b/apps/plugin.c index 1935297a2..9d46ea451 100644 --- a/apps/plugin.c +++ b/apps/plugin.c @@ -132,6 +132,9 @@ static const struct plugin_api rockbox_api = { backlight_on, backlight_off, backlight_set_timeout, +#if CONFIG_CHARGING + backlight_set_timeout_plugged, +#endif gui_syncsplash, #ifdef HAVE_REMOTE_LCD /* remote lcd */ diff --git a/apps/plugin.h b/apps/plugin.h index a424531a9..b446f6242 100644 --- a/apps/plugin.h +++ b/apps/plugin.h @@ -112,12 +112,12 @@ #define PLUGIN_MAGIC 0x526F634B /* RocK */ /* increase this every time the api struct changes */ -#define PLUGIN_API_VERSION 71 +#define PLUGIN_API_VERSION 72 /* update this to latest version if a change to the api struct breaks backwards compatibility (and please take the opportunity to sort in any new function which are "waiting" at the end of the function table) */ -#define PLUGIN_MIN_API_VERSION 71 +#define PLUGIN_MIN_API_VERSION 72 /* plugin return codes */ enum plugin_status { @@ -210,6 +210,9 @@ struct plugin_api { void (*backlight_on)(void); void (*backlight_off)(void); void (*backlight_set_timeout)(int index); +#if CONFIG_CHARGING + void (*backlight_set_timeout_plugged)(int index); +#endif void (*splash)(int ticks, const char *fmt, ...) ATTRIBUTE_PRINTF(2, 3); #ifdef HAVE_REMOTE_LCD diff --git a/apps/plugins/lib/SOURCES b/apps/plugins/lib/SOURCES index 88d362a67..f6711840e 100644 --- a/apps/plugins/lib/SOURCES +++ b/apps/plugins/lib/SOURCES @@ -30,3 +30,4 @@ bmp.c #endif #endif pluginlib_actions.c +helper.c diff --git a/apps/plugins/lib/helper.c b/apps/plugins/lib/helper.c new file mode 100644 index 000000000..cf1877d75 --- /dev/null +++ b/apps/plugins/lib/helper.c @@ -0,0 +1,46 @@ +/*************************************************************************** + * __________ __ ___. + * Open \______ \ ____ ____ | | _\_ |__ _______ ___ + * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / + * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < + * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ + * \/ \/ \/ \/ \/ + * $Id: helper.c 12179 2007-08-14 23:08:15Z peter $ + * + * Copyright (C) 2007 by Peter D'Hoye + * + * All files in this archive are subject to the GNU General Public License. + * See the file COPYING in the source tree root for full license agreement. + * + * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY + * KIND, either express or implied. + * + ****************************************************************************/ + +#include "plugin.h" + +/* the plugin must declare the plugin_api struct pointer itself */ +extern struct plugin_api* rb; + +/* force the backlight on */ +void backlight_force_on(void) +{ +#ifdef HAVE_BACKLIGHT + rb->backlight_set_timeout(1); +#if CONFIG_CHARGING + rb->backlight_set_timeout_plugged(1); +#endif +#endif +} + +/* reset backlight operation to its settings */ +void backlight_use_settings(void) +{ +#ifdef HAVE_BACKLIGHT + rb->backlight_set_timeout(rb->global_settings->backlight_timeout); +#if CONFIG_CHARGING + rb->backlight_set_timeout_plugged(rb->global_settings-> \ + backlight_timeout_plugged); +#endif +#endif +} diff --git a/apps/plugins/lib/helper.h b/apps/plugins/lib/helper.h new file mode 100644 index 000000000..abeac59d8 --- /dev/null +++ b/apps/plugins/lib/helper.h @@ -0,0 +1,30 @@ +/*************************************************************************** + * __________ __ ___. + * Open \______ \ ____ ____ | | _\_ |__ _______ ___ + * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / + * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < + * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ + * \/ \/ \/ \/ \/ + * $Id: helper.h 10254 2007-08-14 19:44:44Z peter $ + * + * Copyright (C) 2007 by Peter D'Hoye + * + * All files in this archive are subject to the GNU General Public License. + * See the file COPYING in the source tree root for full license agreement. + * + * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY + * KIND, either express or implied. + * + ****************************************************************************/ +#ifndef _LIB_HELPER_H_ +#define _LIB_HELPER_H_ + +#include "plugin.h" + +/** + * Backlight on/off operations + */ +void backlight_force_on(void); +void backlight_use_settings(void); + +#endif diff --git a/apps/plugins/mpegplayer/mpegplayer.c b/apps/plugins/mpegplayer/mpegplayer.c index 273e01b79..f4da97060 100644 --- a/apps/plugins/mpegplayer/mpegplayer.c +++ b/apps/plugins/mpegplayer/mpegplayer.c @@ -104,6 +104,7 @@ FPS | 27Mhz | 100Hz | 44.1KHz | 48KHz #include "plugin.h" #include "gray.h" +#include "helper.h" #include "mpeg2.h" #include "mpeg_settings.h" @@ -1856,14 +1857,7 @@ enum plugin_status plugin_start(struct plugin_api* api, void* parameter) rb->lcd_clear_display(); rb->lcd_update(); - /* make sure the backlight is always on when viewing video - (actually it should also set the timeout when plugged in, - but the function backlight_set_timeout_plugged is not - available in plugins) */ -#ifdef HAVE_BACKLIGHT - if (rb->global_settings->backlight_timeout > 0) - rb->backlight_set_timeout(1); -#endif + backlight_force_on(); #ifdef HAVE_ADJUSTABLE_CPU_FREQ rb->cpu_boost(true); @@ -2000,10 +1994,7 @@ enum plugin_status plugin_start(struct plugin_api* api, void* parameter) rb->pcm_set_frequency(HW_SAMPR_DEFAULT); -#ifdef HAVE_BACKLIGHT - /* reset backlight settings */ - rb->backlight_set_timeout(rb->global_settings->backlight_timeout); -#endif + backlight_use_settings(); return status; } -- 2.11.4.GIT