1 /***************************************************************************
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
10 * Copyright (C) 2002 by wavey@wavey.org
12 * All files in this archive are subject to the GNU General Public License.
13 * See the file COPYING in the source tree root for full license agreement.
15 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
16 * KIND, either express or implied.
18 ****************************************************************************/
20 #ifndef __SETTINGS_H__
21 #define __SETTINGS_H__
28 #include "timefuncs.h"
30 #ifdef HAVE_BACKLIGHT_BRIGHTNESS
31 #include "backlight.h" /* for [MIN|MAX]_BRIGHTNESS_SETTING */
34 #define ROCKBOX_DIR "/.rockbox"
35 #define ROCKBOX_DIR_LEN 9
36 #define FONT_DIR "/fonts"
37 #define LANG_DIR "/langs"
38 #define WPS_DIR ROCKBOX_DIR "/wps"
39 #define THEME_DIR ROCKBOX_DIR "/themes"
40 #define PLUGIN_DIR ROCKBOX_DIR"/rocks"
41 #define BACKDROP_DIR ROCKBOX_DIR"/backdrops"
42 #define REC_BASE_DIR "/recordings"
43 #define EQS_DIR ROCKBOX_DIR "/eqs"
45 #define MAX_FILENAME 20
47 /* button definitions */
48 #if (CONFIG_KEYPAD == IRIVER_H100_PAD) || \
49 (CONFIG_KEYPAD == IRIVER_H300_PAD)
50 #define SETTINGS_INC BUTTON_UP
51 #define SETTINGS_DEC BUTTON_DOWN
52 #define SETTINGS_OK BUTTON_SELECT
53 #define SETTINGS_OK2 BUTTON_LEFT
54 #define SETTINGS_CANCEL BUTTON_OFF
55 #define SETTINGS_CANCEL2 BUTTON_MODE
56 #define SETTINGS_PREV BUTTON_LEFT
57 #define SETTINGS_NEXT BUTTON_RIGHT
58 #define SETTINGS_ACCEPT BUTTON_ON
60 #elif CONFIG_KEYPAD == RECORDER_PAD
61 #define SETTINGS_INC BUTTON_UP
62 #define SETTINGS_DEC BUTTON_DOWN
63 #define SETTINGS_OK BUTTON_PLAY
64 #define SETTINGS_OK2 BUTTON_LEFT
65 #define SETTINGS_CANCEL BUTTON_OFF
66 #define SETTINGS_CANCEL2 BUTTON_F1
67 #define SETTINGS_PREV BUTTON_LEFT
68 #define SETTINGS_NEXT BUTTON_RIGHT
69 #define SETTINGS_ACCEPT BUTTON_ON
71 #elif CONFIG_KEYPAD == PLAYER_PAD
72 #define SETTINGS_INC BUTTON_RIGHT
73 #define SETTINGS_DEC BUTTON_LEFT
74 #define SETTINGS_OK BUTTON_PLAY
75 #define SETTINGS_CANCEL BUTTON_STOP
76 #define SETTINGS_CANCEL2 BUTTON_MENU
78 #elif CONFIG_KEYPAD == ONDIO_PAD
79 #define SETTINGS_INC BUTTON_UP
80 #define SETTINGS_DEC BUTTON_DOWN
81 #define SETTINGS_OK BUTTON_RIGHT
82 #define SETTINGS_OK2 BUTTON_LEFT
83 #define SETTINGS_CANCEL BUTTON_MENU
84 #define SETTINGS_CANCEL2 BUTTON_OFF
86 #elif CONFIG_KEYPAD == GMINI100_PAD
87 #define SETTINGS_INC BUTTON_UP
88 #define SETTINGS_DEC BUTTON_DOWN
89 #define SETTINGS_OK BUTTON_PLAY
90 #define SETTINGS_OK2 BUTTON_LEFT
91 #define SETTINGS_CANCEL BUTTON_OFF
92 #define SETTINGS_CANCEL2 BUTTON_MENU
93 #define SETTINGS_PREV BUTTON_LEFT
94 #define SETTINGS_NEXT BUTTON_RIGHT
95 #define SETTINGS_ACCEPT BUTTON_MENU
97 #elif (CONFIG_KEYPAD == IPOD_3G_PAD) || (CONFIG_KEYPAD == IPOD_4G_PAD)
98 #define SETTINGS_INC BUTTON_SCROLL_FWD
99 #define SETTINGS_DEC BUTTON_SCROLL_BACK
100 #define SETTINGS_OK BUTTON_SELECT
101 #define SETTINGS_CANCEL BUTTON_MENU
102 #define SETTINGS_PREV BUTTON_LEFT
103 #define SETTINGS_NEXT BUTTON_RIGHT
104 #define SETTINGS_ACCEPT BUTTON_PLAY
106 #elif CONFIG_KEYPAD == IRIVER_IFP7XX_PAD
107 #define SETTINGS_INC BUTTON_UP
108 #define SETTINGS_DEC BUTTON_DOWN
109 #define SETTINGS_OK BUTTON_SELECT
110 #define SETTINGS_CANCEL BUTTON_PLAY
111 #define SETTINGS_PREV BUTTON_LEFT
112 #define SETTINGS_NEXT BUTTON_RIGHT
114 #elif CONFIG_KEYPAD == IAUDIO_X5_PAD
115 #define SETTINGS_INC BUTTON_UP
116 #define SETTINGS_DEC BUTTON_DOWN
117 #define SETTINGS_OK BUTTON_SELECT
118 #define SETTINGS_OK2 BUTTON_LEFT
119 #define SETTINGS_CANCEL BUTTON_REC
120 #define SETTINGS_PREV BUTTON_LEFT
121 #define SETTINGS_NEXT BUTTON_RIGHT
122 #define SETTINGS_ACCEPT BUTTON_PLAY
124 #elif CONFIG_KEYPAD == GIGABEAT_PAD
125 #define SETTINGS_INC BUTTON_UP
126 #define SETTINGS_DEC BUTTON_DOWN
127 #define SETTINGS_OK BUTTON_MENU
128 #define SETTINGS_CANCEL BUTTON_A
129 #define SETTINGS_PREV BUTTON_LEFT
130 #define SETTINGS_NEXT BUTTON_RIGHT
131 #define SETTINGS_ACCEPT BUTTON_SELECT
135 /* data structures */
137 #define BOOKMARK_NO 0
138 #define BOOKMARK_YES 1
139 #define BOOKMARK_ASK 2
140 #define BOOKMARK_UNIQUE_ONLY 2
141 #define BOOKMARK_RECENT_ONLY_YES 3
142 #define BOOKMARK_RECENT_ONLY_ASK 4
143 #define FF_REWIND_1000 0
144 #define FF_REWIND_2000 1
145 #define FF_REWIND_3000 2
146 #define FF_REWIND_4000 3
147 #define FF_REWIND_5000 4
148 #define FF_REWIND_6000 5
149 #define FF_REWIND_8000 6
150 #define FF_REWIND_10000 7
151 #define FF_REWIND_15000 8
152 #define FF_REWIND_20000 9
153 #define FF_REWIND_25000 10
154 #define FF_REWIND_30000 11
155 #define FF_REWIND_45000 12
156 #define FF_REWIND_60000 13
158 #define TRIG_MODE_OFF 0
159 #define TRIG_MODE_NOREARM 1
160 #define TRIG_MODE_REARM 2
162 #define TRIG_DURATION_COUNT 13
163 extern const char * const trig_durations
[TRIG_DURATION_COUNT
];
165 #define CROSSFADE_ENABLE_SHUFFLE 1
166 #define CROSSFADE_ENABLE_ALWAYS 2
168 /* These define "virtual pointers", which could either be a literal string,
169 or a mean a string ID if the pointer is in a certain range.
170 This helps to save space for menus and options. */
172 #define VIRT_SIZE 0xFFFF /* more than enough for our string ID range */
174 /* a space which is defined in stubs.c */
175 extern unsigned char vp_dummy
[VIRT_SIZE
];
176 #define VIRT_PTR vp_dummy
178 /* a location where we won't store strings, 0 is the fastest */
179 #define VIRT_PTR ((unsigned char*)0)
182 /* form a "virtual pointer" out of a language ID */
183 #define ID2P(id) (VIRT_PTR + id)
185 /* resolve a pointer which could be a virtualized ID or a literal */
186 #define P2STR(p) (char *)((p>=VIRT_PTR && p<=VIRT_PTR+VIRT_SIZE) ? str(p-VIRT_PTR) : p)
188 /* get the string ID from a virtual pointer, -1 if not virtual */
189 #define P2ID(p) ((p>=VIRT_PTR && p<=VIRT_PTR+VIRT_SIZE) ? p-VIRT_PTR : -1)
196 int volume
; /* audio output volume: 0-100 0=off 100=max */
197 int balance
; /* stereo balance: 0-100 0=left 50=bal 100=right */
198 int bass
; /* bass eq: 0-100 0=off 100=max */
199 int treble
; /* treble eq: 0-100 0=low 100=high */
200 int loudness
; /* loudness eq: 0-100 0=off 100=max */
201 int avc
; /* auto volume correct: 0=off, 1=20ms, 2=2s 3=4s 4=8s */
202 int channel_config
; /* Stereo, Mono, Custom, Mono left, Mono right, Karaoke */
203 int stereo_width
; /* 0-255% */
204 int mdb_strength
; /* 0-127dB */
205 int mdb_harmonics
; /* 0-100% */
206 int mdb_center
; /* 20-300Hz */
207 int mdb_shape
; /* 50-300Hz */
208 bool mdb_enable
; /* true/false */
209 bool superbass
; /* true/false */
211 #if CONFIG_CODEC == SWCODEC
212 int crossfade
; /* Enable crossfade (0=off,1=shuffle,2=always) */
213 int crossfade_fade_in_delay
; /* Fade in delay (0-15s) */
214 int crossfade_fade_out_delay
; /* Fade out delay (0-15s) */
215 int crossfade_fade_in_duration
; /* Fade in duration (0-15s) */
216 int crossfade_fade_out_duration
; /* Fade out duration (0-15s) */
217 int crossfade_fade_out_mixmode
; /* Fade out mode (0=crossfade,1=mix) */
220 int rec_quality
; /* 0-7 */
221 int rec_source
; /* 0=mic, 1=line, 2=S/PDIF */
222 int rec_frequency
; /* 0 = 44.1kHz
228 int rec_channels
; /* 0=Stereo, 1=Mono */
229 int rec_mic_gain
; /* 0-15 */
230 int rec_left_gain
; /* 0-15 */
231 int rec_right_gain
; /* 0-15 */
233 int rec_linein_decimator_left_gain
; /* -128 .. 48 */
234 int rec_linein_decimator_right_gain
; /* -128 .. 48 */
235 int rec_mic_decimator_left_gain
; /* -128 .. 48 */
236 int rec_mic_decimator_right_gain
; /* -128 .. 48 */
238 bool rec_editable
; /* true means that the bit reservoir is off */
240 /* note: timesplit setting is not saved */
241 int rec_timesplit
; /* 0 = off,
242 1 = 00:05, 2 = 00:10, 3 = 00:15, 4 = 00:30
243 5 = 01:00, 6 = 02:00, 7 = 04:00, 8 = 06:00
244 9 = 08:00, 10= 10:00, 11= 12:00, 12= 18:00,
247 int rec_prerecord_time
; /* In seconds, 0-30, 0 means OFF */
248 int rec_directory
; /* 0=base dir, 1=current dir */
249 bool rec_startup
; /* true means start Rockbox in recording screen */
250 int cliplight
; /* 0 = off
252 2 = main and remote lcd
255 int rec_start_thres
; /* negative: db, positive: % range -87 .. 100 */
256 int rec_start_duration
; /* index of trig_durations */
257 int rec_stop_thres
; /* negative: db, positive: % */
258 int rec_stop_postrec
; /* negative: db, positive: % range -87 .. 100 */
259 int rec_stop_gap
; /* index of trig_durations */
260 int rec_trigger_mode
; /* see TRIG_MODE_XXX constants */
262 /* device settings */
264 int contrast
; /* lcd contrast: 0-63 0=low 63=high */
265 bool invert
; /* invert display */
266 bool invert_cursor
; /* invert the current file in dir browser and menu
267 instead of using the default cursor */
268 bool flip_display
; /* turn display (and button layout) by 180 degrees */
269 int poweroff
; /* power off timer */
270 int backlight_timeout
; /* backlight off timeout: 0-18 0=never,
272 then according to timeout_values[] */
273 int backlight_timeout_plugged
;
274 #if CONFIG_BACKLIGHT == BL_IRIVER_H100
275 int backlight_fade_in
; /* backlight fade in timing: 0..3 */
276 int backlight_fade_out
; /* backlight fade in timing: 0..7 */
278 int battery_capacity
; /* in mAh */
279 int battery_type
; /* for units which can take multiple types (Ondio). */
281 #ifdef HAVE_SPDIF_POWER
282 bool spdif_enable
; /* S/PDIF power on/off */
285 /* resume settings */
287 bool resume
; /* resume option: 0=off, 1=on */
288 int resume_index
; /* index in playlist (-1 for no active resume) */
289 int resume_first_index
; /* index of first track in playlist */
290 uint32_t resume_offset
; /* byte offset in mp3 file */
291 int resume_seed
; /* shuffle seed (-1=no resume shuffle 0=sorted
294 unsigned char font_file
[MAX_FILENAME
+1]; /* last font */
295 unsigned char wps_file
[MAX_FILENAME
+1]; /* last wps */
296 unsigned char lang_file
[MAX_FILENAME
+1]; /* last language */
300 int repeat_mode
; /* 0=off 1=repeat all 2=repeat one 3=shuffle 4=ab */
301 int dirfilter
; /* 0=display all, 1=only supported, 2=only music,
302 3=dirs+playlists, 4=ID3 database */
303 bool sort_case
; /* dir sort order: 0=case insensitive, 1=sensitive */
304 int volume_type
; /* how volume is displayed: 0=graphic, 1=percent */
305 int battery_display
; /* how battery is displayed: 0=graphic, 1=percent */
306 int timeformat
; /* time format: 0=24 hour clock, 1=12 hour clock */
307 int scroll_speed
; /* long texts scrolling speed: 1-30 */
308 bool playlist_shuffle
;
309 bool play_selected
; /* Plays selected file even in shuffle mode */
310 int ff_rewind_min_step
; /* FF/Rewind minimum step size */
311 int ff_rewind_accel
; /* FF/Rewind acceleration (in seconds per doubling) */
312 int disk_spindown
; /* time until disk spindown, in seconds (0=off) */
313 bool disk_poweroff
; /* whether to cut disk power after spindown or not */
314 int buffer_margin
; /* MP3 buffer watermark margin, in seconds */
316 int peak_meter_release
; /* units per read out */
317 int peak_meter_hold
; /* hold time for peak meter in 1/100 s */
318 int peak_meter_clip_hold
; /* hold time for clips */
319 bool peak_meter_dbfs
; /* show linear or dbfs values */
320 int peak_meter_min
; /* range minimum */
321 int peak_meter_max
; /* range maximum */
322 bool car_adapter_mode
; /* 0=off 1=on */
324 /* show status bar */
325 bool statusbar
; /* 0=hide, 1=show */
327 /* show button bar */
328 bool buttonbar
; /* 0=hide, 1=show */
330 /* show scroll bar */
331 bool scrollbar
; /* 0=hide, 1=show */
333 /* goto current song when exiting WPS */
334 bool browse_current
; /* 1=goto current song,
335 0=goto previous location */
337 int runtime
; /* current runtime since last charge */
338 int topruntime
; /* top known runtime */
340 int bidir_limit
; /* bidir scroll length limit */
341 int scroll_delay
; /* delay (in 1/10s) before starting scroll */
342 int scroll_step
; /* pixels to advance per update */
343 #ifdef HAVE_LCD_BITMAP
344 bool offset_out_of_view
;
345 int screen_scroll_step
;
348 /* auto bookmark settings */
349 int autoloadbookmark
; /* auto load option: 0=off, 1=ask, 2=on */
350 int autocreatebookmark
; /* auto create option: 0=off, 1=ask, 2=on */
351 int usemrb
; /* use MRB list: 0=No, 1=Yes*/
352 #ifdef HAVE_LCD_CHARCELLS
353 int jump_scroll
; /* Fast jump when scrolling */
354 int jump_scroll_delay
; /* Delay between jump scroll screens */
356 bool fade_on_stop
; /* fade on pause/unpause/stop */
357 bool caption_backlight
; /* turn on backlight at end and start of track */
360 int fm_freq_step
; /* Frequency step for manual tuning, in kHz */
361 bool fm_force_mono
; /* Forces Mono mode if true */
362 bool fm_full_range
; /* Enables full 10MHz-160MHz range if true, else
364 int last_frequency
; /* Last frequency for resuming, in FREQ_STEP units,
365 relative to MIN_FREQ */
368 int max_files_in_dir
; /* Max entries in directory (file browser) */
369 int max_files_in_playlist
; /* Max entries in playlist */
370 bool show_icons
; /* 0=hide 1=show */
371 int recursive_dir_insert
; /* should directories be inserted recursively */
373 bool line_in
; /* false=off, true=active */
375 bool id3_v1_first
; /* true = ID3V1 has prio over ID3V2 tag */
377 /* playlist viewer settings */
378 bool playlist_viewer_icons
; /* display icons on viewer */
379 bool playlist_viewer_indices
; /* display playlist indices on viewer */
380 int playlist_viewer_track_display
; /* how to display tracks in viewer */
382 /* voice UI settings */
383 bool talk_menu
; /* enable voice UI */
384 int talk_dir
; /* talkbox mode: 0=off 1=number 2=clip@enter 3=clip@hover */
385 int talk_file
; /* voice filename mode: 0=off, 1=number, other t.b.d. */
387 /* file browser sorting */
388 int sort_file
; /* 0=alpha, 1=date, 2=date (new first), 3=type */
389 int sort_dir
; /* 0=alpha, 1=date (old first), 2=date (new first) */
391 #ifdef HAVE_REMOTE_LCD
393 int remote_contrast
; /* lcd contrast: 0-63 0=low 63=high */
394 bool remote_invert
; /* invert display */
395 bool remote_flip_display
; /* turn display (and button layout) by 180 degrees */
396 int remote_backlight_timeout
; /* backlight off timeout: 0-18 0=never,
398 then according to timeout_values[] */
399 int remote_backlight_timeout_plugged
;
400 bool remote_caption_backlight
; /* turn on backlight at end and start of track */
401 #ifdef HAVE_REMOTE_LCD_TICKING
402 bool remote_reduce_ticking
; /* 0=normal operation,
403 1=EMI reduce on with cost more CPU. */
407 bool next_folder
; /* move to next folder */
408 bool runtimedb
; /* runtime database active? */
410 #if CONFIG_CODEC == SWCODEC
411 bool replaygain
; /* enable replaygain */
412 bool replaygain_noclip
; /* scale to prevent clips */
413 int replaygain_type
; /* 0=track gain, 1=album gain, 2=track gain if
414 shuffle is on, album gain otherwise */
415 int replaygain_preamp
; /* scale replaygained tracks by this */
416 int beep
; /* system beep volume when changing tracks etc. */
417 bool crossfeed
; /* enable crossfeed */
420 bool dircache
; /* enable directory cache */
421 int dircache_size
; /* directory cache structure last size, 22 bits */
423 int default_codepage
; /* set default codepage for tag conversion */
424 #ifdef HAVE_REMOTE_LCD
425 unsigned char rwps_file
[MAX_FILENAME
+1]; /* last remote-wps */
427 #ifdef HAVE_BACKLIGHT_BRIGHTNESS
428 int brightness
; /* iriver h300: backlight PWM value: 2..15
429 (0 and 1 are black) */
432 #if CONFIG_CODEC == SWCODEC
433 bool eq_enabled
; /* Enable equalizer */
435 /* Order is important here, must be cutoff, q, then gain for each band.
436 See dsp_eq_update_data in dsp.c for why. */
438 /* Band 0 settings */
439 int eq_band0_cutoff
; /* Hz */
441 int eq_band0_gain
; /* +/- dB */
443 /* Band 1 settings */
444 int eq_band1_cutoff
; /* Hz */
446 int eq_band1_gain
; /* +/- dB */
448 /* Band 2 settings */
449 int eq_band2_cutoff
; /* Hz */
451 int eq_band2_gain
; /* +/- dB */
453 /* Band 3 settings */
454 int eq_band3_cutoff
; /* Hz */
456 int eq_band3_gain
; /* +/- dB */
458 /* Band 4 settings */
459 int eq_band4_cutoff
; /* Hz */
461 int eq_band4_gain
; /* +/- dB */
464 #ifdef HAVE_LCD_COLOR
465 unsigned char backdrop_file
[MAX_FILENAME
+1]; /* backdrop bitmap file */
468 bool warnon_erase_dynplaylist
; /* warn when erasing dynamic playlist */
469 bool scroll_paginated
; /* 0=dont 1=do */
470 #ifdef HAVE_LCD_COLOR
471 int bg_color
; /* background color native format */
472 int fg_color
; /* foreground color native format */
474 bool party_mode
; /* party mode - unstoppable music */
477 enum optiontype
{ INT
, BOOL
};
480 unsigned const char* string
;
486 void settings_calc_config_sector(void);
487 int settings_save(void);
488 void settings_load(int which
);
489 void settings_reset(void);
490 void sound_settings_apply(void);
491 void settings_apply(void);
492 void settings_apply_pm_range(void);
493 void settings_display(void);
495 bool settings_load_config(const char* file
);
496 bool settings_save_config(void);
497 bool set_bool_options(const char* string
, bool* variable
,
498 const char* yes_str
, int yes_voice
,
499 const char* no_str
, int no_voice
,
500 void (*function
)(bool));
502 bool set_bool(const char* string
, bool* variable
);
503 bool set_option(const char* string
, void* variable
, enum optiontype type
,
504 const struct opt_items
* options
, int numoptions
, void (*function
)(int));
505 bool set_int(const unsigned char* string
, const char* unit
, int voice_unit
,
507 void (*function
)(int), int step
, int min
, int max
,
508 void (*formatter
)(char*, int, int, const char*) );
509 bool set_time_screen(const char* string
, struct tm
*tm
);
510 int read_line(int fd
, char* buffer
, int buffer_size
);
511 void set_file(char* filename
, char* setting
, int maxlen
);
513 unsigned int rec_timesplit_seconds(void);
514 void settings_apply_trigger(void);
516 /* global settings */
517 extern struct user_settings global_settings
;
518 /* name of directory where configuration, fonts and other data
519 * files are stored */
520 extern long lasttime
;
522 /* Recording base directory */
523 extern const char rec_base_directory
[];
527 #ifdef HAVE_LCD_CHARCELLS
528 #define MAX_CONTRAST_SETTING 31
529 #define DEFAULT_CONTRAST_SETTING 30
531 #define MAX_CONTRAST_SETTING 63
532 #define DEFAULT_CONTRAST_SETTING 38
534 #define MIN_CONTRAST_SETTING 5
537 /* argument bits for settings_load() */
538 #define SETTINGS_RTC 1 /* only the settings from the RTC nonvolatile RAM */
539 #define SETTINGS_HD 2 /* only the settings fron the disk sector */
540 #define SETTINGS_ALL 3 /* both */
542 /* repeat mode options */
549 #if (AB_REPEAT_ENABLE == 1)
555 /* dir filter options */
556 /* Note: Any new filter modes need to be added before NUM_FILTER_MODES.
557 * Any new rockbox browse filter modes (accessible through the menu)
558 * must be added after NUM_FILTER_MODES. */
559 enum { SHOW_ALL
, SHOW_SUPPORTED
, SHOW_MUSIC
, SHOW_PLAYLIST
, SHOW_ID3DB
,
561 SHOW_WPS
, SHOW_RWPS
, SHOW_CFG
, SHOW_LNG
, SHOW_MOD
, SHOW_FONT
, SHOW_PLUGINS
};
563 /* recursive dir insert options */
564 enum { RECURSE_OFF
, RECURSE_ON
, RECURSE_ASK
};
566 /* replaygain types */
567 enum { REPLAYGAIN_TRACK
= 0, REPLAYGAIN_ALBUM
, REPLAYGAIN_SHUFFLE
};
569 #endif /* __SETTINGS_H__ */