diff options
Diffstat (limited to 'apps')
-rw-r--r-- | apps/plugins/lib/helper.c | 17 | ||||
-rw-r--r-- | apps/plugins/lib/helper.h | 11 | ||||
-rw-r--r-- | apps/plugins/mpegplayer/mpeg_settings.c | 83 | ||||
-rw-r--r-- | apps/plugins/mpegplayer/mpeg_settings.h | 13 | ||||
-rw-r--r-- | apps/plugins/mpegplayer/mpegplayer.c | 64 |
5 files changed, 172 insertions, 16 deletions
diff --git a/apps/plugins/lib/helper.c b/apps/plugins/lib/helper.c index 691a17f15c..273b066599 100644 --- a/apps/plugins/lib/helper.c +++ b/apps/plugins/lib/helper.c @@ -91,3 +91,20 @@ void buttonlight_use_settings(const struct plugin_api* rb) rb->buttonlight_set_timeout(rb->global_settings->buttonlight_timeout); } #endif /* HAVE_BUTTON_LIGHT */ + +#ifdef HAVE_BACKLIGHT_BRIGHTNESS +void backlight_brightness_set(const struct plugin_api *rb, + int brightness) +{ + if (!rb) + return; + rb->backlight_set_brightness(brightness); +} + +void backlight_brightness_use_setting(const struct plugin_api *rb) +{ + if (!rb) + return; + rb->backlight_set_brightness(rb->global_settings->brightness); +} +#endif /* HAVE_BACKLIGHT_BRIGHTNESS */ diff --git a/apps/plugins/lib/helper.h b/apps/plugins/lib/helper.h index d34e6334f0..eb52a8bfdc 100644 --- a/apps/plugins/lib/helper.h +++ b/apps/plugins/lib/helper.h @@ -34,4 +34,15 @@ void remote_backlight_use_settings(const struct plugin_api* rb); void buttonlight_force_on(const struct plugin_api* rb); void buttonlight_use_settings(const struct plugin_api* rb); #endif + +/** + * Backlight brightness adjustment settings + */ +#ifdef HAVE_BACKLIGHT_BRIGHTNESS +void backlight_brightness_set(const struct plugin_api *rb, + int brightness); +void backlight_brightness_use_setting(const struct plugin_api *rb); #endif + + +#endif /* _LIB_HELPER_H_ */ diff --git a/apps/plugins/mpegplayer/mpeg_settings.c b/apps/plugins/mpegplayer/mpeg_settings.c index 06083dfe10..9e8c153cc4 100644 --- a/apps/plugins/mpegplayer/mpeg_settings.c +++ b/apps/plugins/mpegplayer/mpeg_settings.c @@ -1,4 +1,5 @@ #include "plugin.h" +#include "helper.h" #include "lib/configfile.h" #include "lib/oldmenuapi.h" @@ -172,6 +173,10 @@ static struct configdata config[] = {TYPE_INT, 0, 2, &settings.crossfeed, "Crossfeed", NULL, NULL}, {TYPE_INT, 0, 2, &settings.equalizer, "Equalizer", NULL, NULL}, {TYPE_INT, 0, 2, &settings.dithering, "Dithering", NULL, NULL}, +#ifdef HAVE_BACKLIGHT_BRIGHTNESS + {TYPE_INT, -1, INT_MAX, &settings.backlight_brightness, + "Backlight brightness", NULL, NULL}, +#endif }; static const struct opt_items noyes[2] = { @@ -189,6 +194,10 @@ static const struct opt_items globaloff[2] = { { "Use sound setting", -1 }, }; +#ifdef HAVE_BACKLIGHT_BRIGHTNESS +#define BACKLIGHT_OPTION_DEFAULT "Use setting" +#endif + static long mpeg_menu_sysevent_id; void mpeg_menu_sysevent_clear(void) @@ -252,6 +261,55 @@ static bool mpeg_set_option(const char* string, return usb; } +static bool mpeg_set_int(const char *string, const char *unit, + int voice_unit, const int *variable, + void (*function)(int), int step, + int min, + int max, + void (*formatter)(char*, size_t, int, const char*)) +{ + mpeg_menu_sysevent_clear(); + + bool usb = rb->set_int(string, unit, voice_unit, variable, function, + step, min, max, formatter); + + if (usb) + mpeg_menu_sysevent_id = ACTION_STD_CANCEL; + + return usb; +} + +#ifdef HAVE_BACKLIGHT_BRIGHTNESS +void mpeg_backlight_update_brightness(int value) +{ + if (value >= 0) + { + value += MIN_BRIGHTNESS_SETTING; + backlight_brightness_set(rb, value); + } + else + { + backlight_brightness_use_setting(rb); + } +} + +static void backlight_brightness_function(int value) +{ + mpeg_backlight_update_brightness(value); +} + +static void backlight_brightness_formatter(char *buf, size_t length, + int value, const char *input) +{ + if (value < 0) + rb->strncpy(buf, BACKLIGHT_OPTION_DEFAULT, length); + else + rb->snprintf(buf, length, "%d", value + MIN_BRIGHTNESS_SETTING); + + (void)input; +} +#endif /* HAVE_BACKLIGHT_BRIGHTNESS */ + /* Sync a particular audio setting to global or mpegplayer forced off */ static void sync_audio_setting(int setting, bool global) { @@ -816,6 +874,10 @@ static void display_options(void) { "Limit FPS", NULL }, [MPEG_OPTION_SKIP_FRAMES] = { "Skip frames", NULL }, +#ifdef HAVE_BACKLIGHT_BRIGHTNESS + [MPEG_OPTION_BACKLIGHT_BRIGHTNESS] = + { "Backlight brightness", NULL }, +#endif }; menu_id = menu_init(rb, items, ARRAYLEN(items), @@ -856,6 +918,19 @@ static void display_options(void) noyes, 2, NULL); break; +#ifdef HAVE_BACKLIGHT_BRIGHTNESS + case MPEG_OPTION_BACKLIGHT_BRIGHTNESS: + result = settings.backlight_brightness; + mpeg_backlight_update_brightness(result); + mpeg_set_int("Backlight brightness", NULL, -1, &result, + backlight_brightness_function, 1, -1, + MAX_BRIGHTNESS_SETTING - MIN_BRIGHTNESS_SETTING, + backlight_brightness_formatter); + settings.backlight_brightness = result; + mpeg_backlight_update_brightness(-1); + break; +#endif /* HAVE_BACKLIGHT_BRIGHTNESS */ + default: menu_quit = true; break; @@ -1057,6 +1132,9 @@ void init_settings(const char* filename) settings.skipframes = 1; /* Skip frames */ settings.resume_options = MPEG_RESUME_MENU_ALWAYS; /* Enable start menu */ settings.resume_count = -1; +#ifdef HAVE_BACKLIGHT_BRIGHTNESS + settings.backlight_brightness = -1; /* Use default setting */ +#endif #if MPEG_OPTION_DITHERING_ENABLED settings.displayoptions = 0; /* No visual effects */ #endif @@ -1126,6 +1204,11 @@ void save_settings(void) ++settings.resume_count); } +#ifdef HAVE_BACKLIGHT_BRIGHTNESS + configfile_update_entry(SETTINGS_FILENAME, "Backlight brightness", + settings.backlight_brightness); +#endif + #if MPEG_OPTION_DITHERING_ENABLED configfile_update_entry(SETTINGS_FILENAME, "Display options", settings.displayoptions); diff --git a/apps/plugins/mpegplayer/mpeg_settings.h b/apps/plugins/mpegplayer/mpeg_settings.h index 1557ff433e..d00dc197cb 100644 --- a/apps/plugins/mpegplayer/mpeg_settings.h +++ b/apps/plugins/mpegplayer/mpeg_settings.h @@ -1,7 +1,7 @@ #include "plugin.h" -#define SETTINGS_VERSION 4 +#define SETTINGS_VERSION 5 #define SETTINGS_MIN_VERSION 1 #define SETTINGS_FILENAME "mpegplayer.cfg" @@ -22,6 +22,9 @@ enum mpeg_option_id MPEG_OPTION_DISPLAY_FPS, MPEG_OPTION_LIMIT_FPS, MPEG_OPTION_SKIP_FRAMES, +#ifdef HAVE_BACKLIGHT_BRIGHTNESS + MPEG_OPTION_BACKLIGHT_BRIGHTNESS, +#endif }; enum mpeg_audio_option_id @@ -78,6 +81,10 @@ struct mpeg_settings { int crossfeed; int equalizer; int dithering; + /* Backlight options */ +#ifdef HAVE_BACKLIGHT_BRIGHTNESS + int backlight_brightness; +#endif }; extern struct mpeg_settings settings; @@ -97,3 +104,7 @@ void mpeg_menu_sysevent_handle(void); void init_settings(const char* filename); void save_settings(void); + +#ifdef HAVE_BACKLIGHT_BRIGHTNESS +void mpeg_backlight_update_brightness(int value); +#endif diff --git a/apps/plugins/mpegplayer/mpegplayer.c b/apps/plugins/mpegplayer/mpegplayer.c index 82703ca840..5b92ccced1 100644 --- a/apps/plugins/mpegplayer/mpegplayer.c +++ b/apps/plugins/mpegplayer/mpegplayer.c @@ -587,6 +587,30 @@ static void draw_putsxy_oriented(int x, int y, const char *str) } #endif /* LCD_PORTRAIT */ +static void wvs_backlight_on_video_mode(bool video_on) +{ + if (video_on) { + /* Turn off backlight timeout */ + /* backlight control in lib/helper.c */ + backlight_force_on(rb); + } else { + /* Revert to user's backlight settings */ + backlight_use_settings(rb); + } +} + +#ifdef HAVE_BACKLIGHT_BRIGHTNESS +static void wvs_backlight_brightness_video_mode(bool video_on) +{ + if (settings.backlight_brightness < 0) + return; + + mpeg_backlight_update_brightness( + video_on ? settings.backlight_brightness : -1); +} +#else +#define wvs_backlight_brightness_video_mode(video_on) +#endif /* HAVE_BACKLIGHT_BRIGHTNESS */ static void wvs_text_init(void) { @@ -1012,6 +1036,11 @@ static void wvs_show(unsigned show) wvs.flags |= WVS_SHOW; + if (wvs.status != WVS_STATUS_PLAYING) { + /* Not playing - set brightness to mpegplayer setting */ + wvs_backlight_brightness_video_mode(true); + } + stream_vo_set_clip(&rc); if (!(show & WVS_NODRAW)) @@ -1032,6 +1061,11 @@ static void wvs_show(unsigned show) } else { stream_vo_set_clip(NULL); } + + if (wvs.status != WVS_STATUS_PLAYING) { + /* Not playing - restore backlight brightness */ + wvs_backlight_brightness_video_mode(false); + } } } @@ -1227,6 +1261,8 @@ static int wvs_play(uint32_t time) retval = stream_seek(time, SEEK_SET); if (retval >= STREAM_OK) { + wvs_backlight_on_video_mode(true); + wvs_backlight_brightness_video_mode(true); stream_show_vo(true); retval = stream_play(); @@ -1251,6 +1287,8 @@ static int wvs_halt(void) /* Cancel some auto refreshes - caller will restart them if desired */ wvs_cancel_refresh(WVS_REFRESH_VIDEO | WVS_REFRESH_RESUME); + /* No backlight fiddling here - callers does the right thing */ + return status; } @@ -1267,14 +1305,19 @@ static int wvs_pause(void) wvs_set_status(WVS_STATUS_PAUSED); + wvs_backlight_on_video_mode(false); + /* Leave brightness alone and restore it when WVS is hidden */ + return status; } /* Resume playback if halted or paused */ static void wvs_resume(void) { - /* Cancel video and resume auto refresh - the resyc when starting playback - * will perform those tasks */ + /* Cancel video and resume auto refresh - the resyc when starting + * playback will perform those tasks */ + wvs_backlight_on_video_mode(true); + wvs_backlight_brightness_video_mode(true); wvs_cancel_refresh(WVS_REFRESH_VIDEO | WVS_REFRESH_RESUME); wvs_set_status(WVS_STATUS_PLAYING); stream_resume(); @@ -1295,6 +1338,9 @@ static void wvs_stop(void) if (resume_time != INVALID_TIMESTAMP) settings.resume_time = resume_time; + + wvs_backlight_on_video_mode(false); + wvs_backlight_brightness_video_mode(false); } /* Perform a seek if seeking is possible for this stream - if playing, a delay @@ -1343,14 +1389,12 @@ static void wvs_handle_phone_plug(bool inserted) if (inserted) { if (rb->global_settings->unplug_mode > 1) { if (status == STREAM_PAUSED) { - backlight_force_on(rb); wvs_resume(); } } } else { if (status == STREAM_PLAYING) { wvs_pause(); - backlight_use_settings(rb); if (stream_can_seek() && rb->global_settings->unplug_rw) { stream_seek(-rb->global_settings->unplug_rw*TS_SECOND, @@ -1371,10 +1415,6 @@ static void button_loop(void) rb->lcd_clear_display(); rb->lcd_update(); - /* Turn off backlight timeout */ - /* backlight control in lib/helper.c */ - backlight_force_on(rb); - wvs_init(); /* Start playback at the specified starting time */ @@ -1442,7 +1482,7 @@ static void button_loop(void) /* Hide video output */ wvs_show(WVS_HIDE | WVS_NODRAW); stream_show_vo(false); - backlight_use_settings(rb); + wvs_backlight_brightness_video_mode(false); result = mpeg_menu(0); @@ -1464,7 +1504,6 @@ static void button_loop(void) /* If stream was playing, restart it */ if (state == STREAM_PLAYING) { - backlight_force_on(rb); wvs_resume(); } break; @@ -1495,11 +1534,9 @@ static void button_loop(void) if (status == STREAM_PLAYING) { /* Playing => Paused */ wvs_pause(); - backlight_use_settings(rb); } else if (status == STREAM_PAUSED) { /* Paused => Playing */ - backlight_force_on(rb); wvs_resume(); } @@ -1539,9 +1576,6 @@ static void button_loop(void) wvs_stop(); rb->lcd_setfont(FONT_UI); - - /* Turn on backlight timeout (revert to settings) */ - backlight_use_settings(rb); } enum plugin_status plugin_start(const struct plugin_api* api, const void* parameter) |