diff options
Diffstat (limited to 'apps/plugins/mpegplayer/mpeg_settings.c')
-rw-r--r-- | apps/plugins/mpegplayer/mpeg_settings.c | 83 |
1 files changed, 83 insertions, 0 deletions
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 @@ | |||
1 | #include "plugin.h" | 1 | #include "plugin.h" |
2 | #include "helper.h" | ||
2 | #include "lib/configfile.h" | 3 | #include "lib/configfile.h" |
3 | #include "lib/oldmenuapi.h" | 4 | #include "lib/oldmenuapi.h" |
4 | 5 | ||
@@ -172,6 +173,10 @@ static struct configdata config[] = | |||
172 | {TYPE_INT, 0, 2, &settings.crossfeed, "Crossfeed", NULL, NULL}, | 173 | {TYPE_INT, 0, 2, &settings.crossfeed, "Crossfeed", NULL, NULL}, |
173 | {TYPE_INT, 0, 2, &settings.equalizer, "Equalizer", NULL, NULL}, | 174 | {TYPE_INT, 0, 2, &settings.equalizer, "Equalizer", NULL, NULL}, |
174 | {TYPE_INT, 0, 2, &settings.dithering, "Dithering", NULL, NULL}, | 175 | {TYPE_INT, 0, 2, &settings.dithering, "Dithering", NULL, NULL}, |
176 | #ifdef HAVE_BACKLIGHT_BRIGHTNESS | ||
177 | {TYPE_INT, -1, INT_MAX, &settings.backlight_brightness, | ||
178 | "Backlight brightness", NULL, NULL}, | ||
179 | #endif | ||
175 | }; | 180 | }; |
176 | 181 | ||
177 | static const struct opt_items noyes[2] = { | 182 | static const struct opt_items noyes[2] = { |
@@ -189,6 +194,10 @@ static const struct opt_items globaloff[2] = { | |||
189 | { "Use sound setting", -1 }, | 194 | { "Use sound setting", -1 }, |
190 | }; | 195 | }; |
191 | 196 | ||
197 | #ifdef HAVE_BACKLIGHT_BRIGHTNESS | ||
198 | #define BACKLIGHT_OPTION_DEFAULT "Use setting" | ||
199 | #endif | ||
200 | |||
192 | static long mpeg_menu_sysevent_id; | 201 | static long mpeg_menu_sysevent_id; |
193 | 202 | ||
194 | void mpeg_menu_sysevent_clear(void) | 203 | void mpeg_menu_sysevent_clear(void) |
@@ -252,6 +261,55 @@ static bool mpeg_set_option(const char* string, | |||
252 | return usb; | 261 | return usb; |
253 | } | 262 | } |
254 | 263 | ||
264 | static bool mpeg_set_int(const char *string, const char *unit, | ||
265 | int voice_unit, const int *variable, | ||
266 | void (*function)(int), int step, | ||
267 | int min, | ||
268 | int max, | ||
269 | void (*formatter)(char*, size_t, int, const char*)) | ||
270 | { | ||
271 | mpeg_menu_sysevent_clear(); | ||
272 | |||
273 | bool usb = rb->set_int(string, unit, voice_unit, variable, function, | ||
274 | step, min, max, formatter); | ||
275 | |||
276 | if (usb) | ||
277 | mpeg_menu_sysevent_id = ACTION_STD_CANCEL; | ||
278 | |||
279 | return usb; | ||
280 | } | ||
281 | |||
282 | #ifdef HAVE_BACKLIGHT_BRIGHTNESS | ||
283 | void mpeg_backlight_update_brightness(int value) | ||
284 | { | ||
285 | if (value >= 0) | ||
286 | { | ||
287 | value += MIN_BRIGHTNESS_SETTING; | ||
288 | backlight_brightness_set(rb, value); | ||
289 | } | ||
290 | else | ||
291 | { | ||
292 | backlight_brightness_use_setting(rb); | ||
293 | } | ||
294 | } | ||
295 | |||
296 | static void backlight_brightness_function(int value) | ||
297 | { | ||
298 | mpeg_backlight_update_brightness(value); | ||
299 | } | ||
300 | |||
301 | static void backlight_brightness_formatter(char *buf, size_t length, | ||
302 | int value, const char *input) | ||
303 | { | ||
304 | if (value < 0) | ||
305 | rb->strncpy(buf, BACKLIGHT_OPTION_DEFAULT, length); | ||
306 | else | ||
307 | rb->snprintf(buf, length, "%d", value + MIN_BRIGHTNESS_SETTING); | ||
308 | |||
309 | (void)input; | ||
310 | } | ||
311 | #endif /* HAVE_BACKLIGHT_BRIGHTNESS */ | ||
312 | |||
255 | /* Sync a particular audio setting to global or mpegplayer forced off */ | 313 | /* Sync a particular audio setting to global or mpegplayer forced off */ |
256 | static void sync_audio_setting(int setting, bool global) | 314 | static void sync_audio_setting(int setting, bool global) |
257 | { | 315 | { |
@@ -816,6 +874,10 @@ static void display_options(void) | |||
816 | { "Limit FPS", NULL }, | 874 | { "Limit FPS", NULL }, |
817 | [MPEG_OPTION_SKIP_FRAMES] = | 875 | [MPEG_OPTION_SKIP_FRAMES] = |
818 | { "Skip frames", NULL }, | 876 | { "Skip frames", NULL }, |
877 | #ifdef HAVE_BACKLIGHT_BRIGHTNESS | ||
878 | [MPEG_OPTION_BACKLIGHT_BRIGHTNESS] = | ||
879 | { "Backlight brightness", NULL }, | ||
880 | #endif | ||
819 | }; | 881 | }; |
820 | 882 | ||
821 | menu_id = menu_init(rb, items, ARRAYLEN(items), | 883 | menu_id = menu_init(rb, items, ARRAYLEN(items), |
@@ -856,6 +918,19 @@ static void display_options(void) | |||
856 | noyes, 2, NULL); | 918 | noyes, 2, NULL); |
857 | break; | 919 | break; |
858 | 920 | ||
921 | #ifdef HAVE_BACKLIGHT_BRIGHTNESS | ||
922 | case MPEG_OPTION_BACKLIGHT_BRIGHTNESS: | ||
923 | result = settings.backlight_brightness; | ||
924 | mpeg_backlight_update_brightness(result); | ||
925 | mpeg_set_int("Backlight brightness", NULL, -1, &result, | ||
926 | backlight_brightness_function, 1, -1, | ||
927 | MAX_BRIGHTNESS_SETTING - MIN_BRIGHTNESS_SETTING, | ||
928 | backlight_brightness_formatter); | ||
929 | settings.backlight_brightness = result; | ||
930 | mpeg_backlight_update_brightness(-1); | ||
931 | break; | ||
932 | #endif /* HAVE_BACKLIGHT_BRIGHTNESS */ | ||
933 | |||
859 | default: | 934 | default: |
860 | menu_quit = true; | 935 | menu_quit = true; |
861 | break; | 936 | break; |
@@ -1057,6 +1132,9 @@ void init_settings(const char* filename) | |||
1057 | settings.skipframes = 1; /* Skip frames */ | 1132 | settings.skipframes = 1; /* Skip frames */ |
1058 | settings.resume_options = MPEG_RESUME_MENU_ALWAYS; /* Enable start menu */ | 1133 | settings.resume_options = MPEG_RESUME_MENU_ALWAYS; /* Enable start menu */ |
1059 | settings.resume_count = -1; | 1134 | settings.resume_count = -1; |
1135 | #ifdef HAVE_BACKLIGHT_BRIGHTNESS | ||
1136 | settings.backlight_brightness = -1; /* Use default setting */ | ||
1137 | #endif | ||
1060 | #if MPEG_OPTION_DITHERING_ENABLED | 1138 | #if MPEG_OPTION_DITHERING_ENABLED |
1061 | settings.displayoptions = 0; /* No visual effects */ | 1139 | settings.displayoptions = 0; /* No visual effects */ |
1062 | #endif | 1140 | #endif |
@@ -1126,6 +1204,11 @@ void save_settings(void) | |||
1126 | ++settings.resume_count); | 1204 | ++settings.resume_count); |
1127 | } | 1205 | } |
1128 | 1206 | ||
1207 | #ifdef HAVE_BACKLIGHT_BRIGHTNESS | ||
1208 | configfile_update_entry(SETTINGS_FILENAME, "Backlight brightness", | ||
1209 | settings.backlight_brightness); | ||
1210 | #endif | ||
1211 | |||
1129 | #if MPEG_OPTION_DITHERING_ENABLED | 1212 | #if MPEG_OPTION_DITHERING_ENABLED |
1130 | configfile_update_entry(SETTINGS_FILENAME, "Display options", | 1213 | configfile_update_entry(SETTINGS_FILENAME, "Display options", |
1131 | settings.displayoptions); | 1214 | settings.displayoptions); |