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