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"
32 #ifdef HAVE_BACKLIGHT_BRIGHTNESS
33 #include "backlight.h" /* for [MIN|MAX]_BRIGHTNESS_SETTING */
36 #define ROCKBOX_DIR "/.rockbox"
37 #define ROCKBOX_DIR_LEN 9
38 #define FONT_DIR ROCKBOX_DIR "/fonts"
39 #define LANG_DIR ROCKBOX_DIR "/langs"
40 #define WPS_DIR ROCKBOX_DIR "/wps"
41 #define THEME_DIR ROCKBOX_DIR "/themes"
42 #define PLUGIN_DIR ROCKBOX_DIR "/rocks"
43 #define BACKDROP_DIR ROCKBOX_DIR "/backdrops"
44 #define REC_BASE_DIR "/recordings"
45 #define EQS_DIR ROCKBOX_DIR "/eqs"
46 #define CODECS_DIR ROCKBOX_DIR"/codecs"
48 #define MAX_FILENAME 20
53 #define BOOKMARK_YES 1
54 #define BOOKMARK_ASK 2
55 #define BOOKMARK_UNIQUE_ONLY 2
56 #define BOOKMARK_RECENT_ONLY_YES 3
57 #define BOOKMARK_RECENT_ONLY_ASK 4
58 #define FF_REWIND_1000 0
59 #define FF_REWIND_2000 1
60 #define FF_REWIND_3000 2
61 #define FF_REWIND_4000 3
62 #define FF_REWIND_5000 4
63 #define FF_REWIND_6000 5
64 #define FF_REWIND_8000 6
65 #define FF_REWIND_10000 7
66 #define FF_REWIND_15000 8
67 #define FF_REWIND_20000 9
68 #define FF_REWIND_25000 10
69 #define FF_REWIND_30000 11
70 #define FF_REWIND_45000 12
71 #define FF_REWIND_60000 13
73 #define TRIG_MODE_OFF 0
74 #define TRIG_MODE_NOREARM 1
75 #define TRIG_MODE_REARM 2
77 #define TRIG_DURATION_COUNT 13
78 extern const char * const trig_durations
[TRIG_DURATION_COUNT
];
80 #define CROSSFADE_ENABLE_SHUFFLE 1
81 #define CROSSFADE_ENABLE_ALWAYS 2
83 #define FOLDER_ADVANCE_OFF 0
84 #define FOLDER_ADVANCE_NEXT 1
85 #define FOLDER_ADVANCE_RANDOM 2
87 /* These define "virtual pointers", which could either be a literal string,
88 or a mean a string ID if the pointer is in a certain range.
89 This helps to save space for menus and options. */
91 #define VIRT_SIZE 0xFFFF /* more than enough for our string ID range */
93 /* a space which is defined in stubs.c */
94 extern unsigned char vp_dummy
[VIRT_SIZE
];
95 #define VIRT_PTR vp_dummy
97 /* a location where we won't store strings, 0 is the fastest */
98 #define VIRT_PTR ((unsigned char*)0)
101 /* form a "virtual pointer" out of a language ID */
102 #define ID2P(id) (VIRT_PTR + id)
104 /* resolve a pointer which could be a virtualized ID or a literal */
105 #define P2STR(p) (char *)((p>=VIRT_PTR && p<=VIRT_PTR+VIRT_SIZE) ? str(p-VIRT_PTR) : p)
107 /* get the string ID from a virtual pointer, -1 if not virtual */
108 #define P2ID(p) ((p>=VIRT_PTR && p<=VIRT_PTR+VIRT_SIZE) ? p-VIRT_PTR : -1)
110 /* !defined(HAVE_LCD_COLOR) implies HAVE_LCD_CONTRAST with default 40.
111 Explicitly define HAVE_LCD_CONTRAST in config file for newer ports for
113 #if !defined(HAVE_LCD_COLOR)
114 #define HAVE_LCD_CONTRAST
121 int volume
; /* audio output volume: 0-100 0=off 100=max */
122 int balance
; /* stereo balance: 0-100 0=left 50=bal 100=right */
123 int bass
; /* bass eq: 0-100 0=off 100=max */
124 int treble
; /* treble eq: 0-100 0=low 100=high */
125 int loudness
; /* loudness eq: 0-100 0=off 100=max */
126 int avc
; /* auto volume correct: 0=off, 1=20ms, 2=2s 3=4s 4=8s */
127 int channel_config
; /* Stereo, Mono, Custom, Mono left, Mono right, Karaoke */
128 int stereo_width
; /* 0-255% */
129 int mdb_strength
; /* 0-127dB */
130 int mdb_harmonics
; /* 0-100% */
131 int mdb_center
; /* 20-300Hz */
132 int mdb_shape
; /* 50-300Hz */
133 bool mdb_enable
; /* true/false */
134 bool superbass
; /* true/false */
136 #if CONFIG_CODEC == SWCODEC
137 int crossfade
; /* Enable crossfade (0=off,1=shuffle,2=always) */
138 int crossfade_fade_in_delay
; /* Fade in delay (0-15s) */
139 int crossfade_fade_out_delay
; /* Fade out delay (0-15s) */
140 int crossfade_fade_in_duration
; /* Fade in duration (0-15s) */
141 int crossfade_fade_out_duration
; /* Fade out duration (0-15s) */
142 int crossfade_fade_out_mixmode
; /* Fade out mode (0=crossfade,1=mix) */
145 int rec_quality
; /* 0-7 */
146 int rec_source
; /* 0=mic, 1=line, 2=S/PDIF */
147 int rec_frequency
; /* 0 = 44.1kHz
153 int rec_channels
; /* 0=Stereo, 1=Mono */
154 int rec_mic_gain
; /* 0-15 */
155 int rec_left_gain
; /* 0-15 */
156 int rec_right_gain
; /* 0-15 */
157 bool rec_editable
; /* true means that the bit reservoir is off */
158 bool recscreen_on
; /* true if using the recording screen */
160 /* note: timesplit setting is not saved */
161 int rec_timesplit
; /* 0 = off,
162 1 = 00:05, 2 = 00:10, 3 = 00:15, 4 = 00:30
163 5 = 01:00, 6 = 02:00, 7 = 04:00, 8 = 06:00
164 9 = 08:00, 10= 10:00, 11= 12:00, 12= 18:00,
166 int rec_sizesplit
; /* 0 = off,
167 1 = 5MB, 2 = 10MB, 3 = 15MB, 4 = 32MB
168 5 = 64MB, 6 = 75MB, 7 = 100MB, 8 = 128MB
169 9 = 256MB, 10= 512MB, 11= 650MB, 12= 700MB,
170 13= 1GB, 14 = 1.5GB 15 = 1.75MB*/
171 int rec_split_type
; /* split/stop */
172 int rec_split_method
; /* time/filesize */
174 int rec_prerecord_time
; /* In seconds, 0-30, 0 means OFF */
175 int rec_directory
; /* 0=base dir, 1=current dir */
176 bool rec_startup
; /* true means start Rockbox in recording screen */
177 int cliplight
; /* 0 = off
179 2 = main and remote lcd
182 int rec_start_thres
; /* negative: db, positive: % range -87 .. 100 */
183 int rec_start_duration
; /* index of trig_durations */
184 int rec_stop_thres
; /* negative: db, positive: % */
185 int rec_stop_postrec
; /* negative: db, positive: % range -87 .. 100 */
186 int rec_stop_gap
; /* index of trig_durations */
187 int rec_trigger_mode
; /* see TRIG_MODE_XXX constants */
190 int rec_agc_preset_mic
; /* AGC mic preset modes:
197 int rec_agc_preset_line
; /* AGC line-in preset modes:
204 int rec_agc_maxgain_mic
; /* AGC maximum mic gain */
205 int rec_agc_maxgain_line
; /* AGC maximum line-in gain */
206 int rec_agc_cliptime
; /* 0.2, 0.4, 0.6, 0.8, 1s */
209 /* device settings */
211 #ifdef HAVE_LCD_CONTRAST
212 int contrast
; /* lcd contrast */
214 bool invert
; /* invert display */
215 bool invert_cursor
; /* invert the current file in dir browser and menu
216 instead of using the default cursor */
217 bool flip_display
; /* turn display (and button layout) by 180 degrees */
218 int poweroff
; /* power off timer */
219 int backlight_timeout
; /* backlight off timeout: 0-18 0=never,
221 then according to timeout_values[] */
222 int backlight_timeout_plugged
;
223 #ifdef HAVE_BACKLIGHT_PWM_FADING
224 int backlight_fade_in
; /* backlight fade in timing: 0..3 */
225 int backlight_fade_out
; /* backlight fade in timing: 0..7 */
227 int battery_capacity
; /* in mAh */
228 int battery_type
; /* for units which can take multiple types (Ondio). */
230 #ifdef HAVE_SPDIF_POWER
231 bool spdif_enable
; /* S/PDIF power on/off */
234 /* resume settings */
236 bool resume
; /* resume option: 0=off, 1=on */
237 int resume_index
; /* index in playlist (-1 for no active resume) */
238 int resume_first_index
; /* index of first track in playlist */
239 uint32_t resume_offset
; /* byte offset in mp3 file */
240 int resume_seed
; /* shuffle seed (-1=no resume shuffle 0=sorted
244 unsigned char fmr_file
[MAX_FILENAME
+1]; /* last fmr preset */
246 unsigned char font_file
[MAX_FILENAME
+1]; /* last font */
247 unsigned char wps_file
[MAX_FILENAME
+1]; /* last wps */
248 unsigned char lang_file
[MAX_FILENAME
+1]; /* last language */
252 int repeat_mode
; /* 0=off 1=repeat all 2=repeat one 3=shuffle 4=ab */
253 int dirfilter
; /* 0=display all, 1=only supported, 2=only music,
254 3=dirs+playlists, 4=ID3 database */
255 bool sort_case
; /* dir sort order: 0=case insensitive, 1=sensitive */
256 int volume_type
; /* how volume is displayed: 0=graphic, 1=percent */
257 int battery_display
; /* how battery is displayed: 0=graphic, 1=percent */
258 int timeformat
; /* time format: 0=24 hour clock, 1=12 hour clock */
259 bool playlist_shuffle
;
260 bool play_selected
; /* Plays selected file even in shuffle mode */
261 int ff_rewind_min_step
; /* FF/Rewind minimum step size */
262 int ff_rewind_accel
; /* FF/Rewind acceleration (in seconds per doubling) */
263 int disk_spindown
; /* time until disk spindown, in seconds (0=off) */
264 bool disk_poweroff
; /* whether to cut disk power after spindown or not */
265 int buffer_margin
; /* MP3 buffer watermark margin, in seconds */
267 int peak_meter_release
; /* units per read out */
268 int peak_meter_hold
; /* hold time for peak meter in 1/100 s */
269 int peak_meter_clip_hold
; /* hold time for clips */
270 bool peak_meter_dbfs
; /* show linear or dbfs values */
271 int peak_meter_min
; /* range minimum */
272 int peak_meter_max
; /* range maximum */
273 bool car_adapter_mode
; /* 0=off 1=on */
275 /* show status bar */
276 bool statusbar
; /* 0=hide, 1=show */
278 /* show button bar */
279 bool buttonbar
; /* 0=hide, 1=show */
281 /* show scroll bar */
282 bool scrollbar
; /* 0=hide, 1=show */
284 /* goto current song when exiting WPS */
285 bool browse_current
; /* 1=goto current song,
286 0=goto previous location */
288 int runtime
; /* current runtime since last charge */
289 int topruntime
; /* top known runtime */
291 int scroll_speed
; /* long texts scrolling speed: 1-30 */
292 int bidir_limit
; /* bidir scroll length limit */
293 int scroll_delay
; /* delay (in 1/10s) before starting scroll */
294 int scroll_step
; /* pixels to advance per update */
295 #ifdef HAVE_REMOTE_LCD
296 int remote_scroll_speed
; /* long texts scrolling speed: 1-30 */
297 int remote_scroll_delay
; /* delay (in 1/10s) before starting scroll */
298 int remote_scroll_step
; /* pixels to advance per update */
299 int remote_bidir_limit
; /* bidir scroll length limit */
302 #ifdef HAVE_LCD_BITMAP
303 bool offset_out_of_view
;
304 int screen_scroll_step
;
307 /* auto bookmark settings */
308 int autoloadbookmark
; /* auto load option: 0=off, 1=ask, 2=on */
309 int autocreatebookmark
; /* auto create option: 0=off, 1=ask, 2=on */
310 int usemrb
; /* use MRB list: 0=No, 1=Yes*/
311 #ifdef HAVE_LCD_CHARCELLS
312 int jump_scroll
; /* Fast jump when scrolling */
313 int jump_scroll_delay
; /* Delay between jump scroll screens */
315 bool fade_on_stop
; /* fade on pause/unpause/stop */
316 bool caption_backlight
; /* turn on backlight at end and start of track */
319 int fm_freq_step
; /* Frequency step for manual tuning, in kHz */
320 bool fm_force_mono
; /* Forces Mono mode if true */
321 bool fm_full_range
; /* Enables full 10MHz-160MHz range if true, else
323 int last_frequency
; /* Last frequency for resuming, in FREQ_STEP units,
324 relative to MIN_FREQ */
327 int max_files_in_dir
; /* Max entries in directory (file browser) */
328 int max_files_in_playlist
; /* Max entries in playlist */
329 bool show_icons
; /* 0=hide 1=show */
330 int recursive_dir_insert
; /* should directories be inserted recursively */
332 bool line_in
; /* false=off, true=active */
334 bool id3_v1_first
; /* true = ID3V1 has prio over ID3V2 tag */
336 /* playlist viewer settings */
337 bool playlist_viewer_icons
; /* display icons on viewer */
338 bool playlist_viewer_indices
; /* display playlist indices on viewer */
339 int playlist_viewer_track_display
; /* how to display tracks in viewer */
341 /* voice UI settings */
342 bool talk_menu
; /* enable voice UI */
343 int talk_dir
; /* talkbox mode: 0=off 1=number 2=clip@enter 3=clip@hover */
344 int talk_file
; /* voice filename mode: 0=off, 1=number, other t.b.d. */
346 /* file browser sorting */
347 int sort_file
; /* 0=alpha, 1=date, 2=date (new first), 3=type */
348 int sort_dir
; /* 0=alpha, 1=date (old first), 2=date (new first) */
350 #ifdef HAVE_REMOTE_LCD
352 int remote_contrast
; /* lcd contrast: 0-63 0=low 63=high */
353 bool remote_invert
; /* invert display */
354 bool remote_flip_display
; /* turn display (and button layout) by 180 degrees */
355 int remote_backlight_timeout
; /* backlight off timeout: 0-18 0=never,
357 then according to timeout_values[] */
358 int remote_backlight_timeout_plugged
;
359 bool remote_caption_backlight
; /* turn on backlight at end and start of track */
360 #ifdef HAS_REMOTE_BUTTON_HOLD
361 int remote_backlight_on_button_hold
; /* what to do with remote backlight when hold
364 #ifdef HAVE_REMOTE_LCD_TICKING
365 bool remote_reduce_ticking
; /* 0=normal operation,
366 1=EMI reduce on with cost more CPU. */
368 #endif /* HAVE_REMOTE_LCD */
370 int next_folder
; /* move to next folder */
371 bool runtimedb
; /* runtime database active? */
373 #if CONFIG_CODEC == SWCODEC
374 bool replaygain
; /* enable replaygain */
375 bool replaygain_noclip
; /* scale to prevent clips */
376 int replaygain_type
; /* 0=track gain, 1=album gain, 2=track gain if
377 shuffle is on, album gain otherwise */
378 int replaygain_preamp
; /* scale replaygained tracks by this */
379 int beep
; /* system beep volume when changing tracks etc. */
381 /* Crossfeed settings */
382 bool crossfeed
; /* enable crossfeed */
383 unsigned int crossfeed_direct_gain
; /* - dB x 10 */
384 unsigned int crossfeed_cross_gain
; /* - dB x 10 */
385 unsigned int crossfeed_hf_attenuation
; /* - dB x 10 */
386 unsigned int crossfeed_hf_cutoff
; /* Frequency in Hz */
389 bool dircache
; /* enable directory cache */
390 int dircache_size
; /* directory cache structure last size, 22 bits */
393 #ifdef HAVE_TC_RAMCACHE
394 bool tagcache_ram
; /* load tagcache to ram? */
396 bool tagcache_autoupdate
; /* automatically keep tagcache in sync? */
398 int default_codepage
; /* set default codepage for tag conversion */
399 #ifdef HAVE_REMOTE_LCD
400 unsigned char rwps_file
[MAX_FILENAME
+1]; /* last remote-wps */
402 #ifdef HAVE_BACKLIGHT_BRIGHTNESS
403 int brightness
; /* iriver h300: backlight PWM value: 2..15
404 (0 and 1 are black) */
407 #if CONFIG_CODEC == SWCODEC
408 bool eq_enabled
; /* Enable equalizer */
409 unsigned int eq_precut
; /* dB */
411 /* Order is important here, must be cutoff, q, then gain for each band.
412 See dsp_eq_update_data in dsp.c for why. */
414 /* Band 0 settings */
415 int eq_band0_cutoff
; /* Hz */
417 int eq_band0_gain
; /* +/- dB */
419 /* Band 1 settings */
420 int eq_band1_cutoff
; /* Hz */
422 int eq_band1_gain
; /* +/- dB */
424 /* Band 2 settings */
425 int eq_band2_cutoff
; /* Hz */
427 int eq_band2_gain
; /* +/- dB */
429 /* Band 3 settings */
430 int eq_band3_cutoff
; /* Hz */
432 int eq_band3_gain
; /* +/- dB */
434 /* Band 4 settings */
435 int eq_band4_cutoff
; /* Hz */
437 int eq_band4_gain
; /* +/- dB */
439 bool dithering_enabled
;
442 #ifdef HAVE_LCD_COLOR
443 unsigned char backdrop_file
[MAX_FILENAME
+1]; /* backdrop bitmap file */
446 bool warnon_erase_dynplaylist
; /* warn when erasing dynamic playlist */
447 bool scroll_paginated
; /* 0=dont 1=do */
448 #ifdef HAVE_LCD_COLOR
449 int bg_color
; /* background color native format */
450 int fg_color
; /* foreground color native format */
452 bool party_mode
; /* party mode - unstoppable music */
454 #ifdef CONFIG_BACKLIGHT
455 bool bl_filter_first_keypress
; /* filter first keypress when dark? */
456 #ifdef HAVE_REMOTE_LCD
457 bool remote_bl_filter_first_keypress
; /* filter first remote keypress when remote dark? */
459 #ifdef HAS_BUTTON_HOLD
460 int backlight_on_button_hold
; /* what to do with backlight when hold
463 #ifdef HAVE_LCD_SLEEP
464 int lcd_sleep_after_backlight_off
; /* when to put lcd to sleep after backlight
467 #endif /* CONFIG_BACKLIGHT */
469 #ifdef HAVE_LCD_BITMAP
470 unsigned char kbd_file
[MAX_FILENAME
+1]; /* last keyboard */
474 bool eq_hw_enabled
; /* Enable hardware equalizer */
476 int eq_hw_band0_cutoff
;
477 int eq_hw_band0_gain
;
479 int eq_hw_band1_center
;
480 int eq_hw_band1_bandwidth
;
481 int eq_hw_band1_gain
;
483 int eq_hw_band2_center
;
484 int eq_hw_band2_bandwidth
;
485 int eq_hw_band2_gain
;
487 int eq_hw_band3_center
;
488 int eq_hw_band3_bandwidth
;
489 int eq_hw_band3_gain
;
491 int eq_hw_band4_cutoff
;
492 int eq_hw_band4_gain
;
494 bool hold_lr_for_scroll_in_list
; /* hold L/R scrolls the list left/right */
495 int show_path_in_browser
; /* 0=off, 1=current directory, 2=full path */
497 #ifdef HAVE_HEADPHONE_DETECTION
498 int unplug_mode
; /* pause on headphone unplug */
499 int unplug_rw
; /* time in s to rewind when pausing */
500 bool unplug_autoresume
; /* disable auto-resume if no phones */
505 bool audioscrobbler
; /* Audioscrobbler logging */
509 enum optiontype
{ INT
, BOOL
};
512 unsigned const char* string
;
518 void settings_calc_config_sector(void);
519 int settings_save(void);
520 void settings_load(int which
);
521 void settings_reset(void);
522 void sound_settings_apply(void);
523 void settings_apply(void);
524 void settings_apply_pm_range(void);
525 void settings_display(void);
527 bool settings_load_config(const char* file
);
528 bool settings_save_config(void);
529 bool set_bool_options(const char* string
, bool* variable
,
530 const char* yes_str
, int yes_voice
,
531 const char* no_str
, int no_voice
,
532 void (*function
)(bool));
534 bool set_bool(const char* string
, bool* variable
);
535 bool set_option(const char* string
, void* variable
, enum optiontype type
,
536 const struct opt_items
* options
, int numoptions
, void (*function
)(int));
537 bool set_int(const unsigned char* string
, const char* unit
, int voice_unit
,
539 void (*function
)(int), int step
, int min
, int max
,
540 void (*formatter
)(char*, int, int, const char*) );
541 bool set_time_screen(const char* string
, struct tm
*tm
);
542 int read_line(int fd
, char* buffer
, int buffer_size
);
543 void set_file(char* filename
, char* setting
, int maxlen
);
545 unsigned int rec_timesplit_seconds(void);
546 unsigned long rec_sizesplit_bytes(void);
547 void settings_apply_trigger(void);
549 /* global settings */
550 extern struct user_settings global_settings
;
551 /* name of directory where configuration, fonts and other data
552 * files are stored */
553 extern long lasttime
;
555 /* Recording base directory */
556 extern const char rec_base_directory
[];
561 #ifndef HAVE_LCD_COLOR
562 #define DEFAULT_CONTRAST_SETTING 40
565 #if defined HAVE_LCD_CHARCELLS
566 #define MIN_CONTRAST_SETTING 5
567 #define MAX_CONTRAST_SETTING 31
569 #define MIN_CONTRAST_SETTING 5
570 #define MAX_CONTRAST_SETTING 63
574 #ifdef HAVE_REMOTE_LCD
575 #ifndef DEFAULT_REMOTE_CONTRAST_SETTING
576 /* May be defined in config file if driver code needs the value */
577 #define DEFAULT_REMOTE_CONTRAST_SETTING 42
579 #define MIN_REMOTE_CONTRAST_SETTING MIN_CONTRAST_SETTING
580 #define MAX_REMOTE_CONTRAST_SETTING MAX_CONTRAST_SETTING
583 #endif /* !TARGET_TREE */
585 /* argument bits for settings_load() */
586 #define SETTINGS_RTC 1 /* only the settings from the RTC nonvolatile RAM */
587 #define SETTINGS_HD 2 /* only the settings fron the disk sector */
588 #define SETTINGS_ALL 3 /* both */
590 /* repeat mode options */
597 #if (AB_REPEAT_ENABLE == 1)
603 /* dir filter options */
604 /* Note: Any new filter modes need to be added before NUM_FILTER_MODES.
605 * Any new rockbox browse filter modes (accessible through the menu)
606 * must be added after NUM_FILTER_MODES. */
607 enum { SHOW_ALL
, SHOW_SUPPORTED
, SHOW_MUSIC
, SHOW_PLAYLIST
, SHOW_ID3DB
,
609 SHOW_WPS
, SHOW_RWPS
, SHOW_FMR
, SHOW_CFG
, SHOW_LNG
, SHOW_MOD
, SHOW_FONT
, SHOW_PLUGINS
};
611 /* recursive dir insert options */
612 enum { RECURSE_OFF
, RECURSE_ON
, RECURSE_ASK
};
614 /* replaygain types */
615 enum { REPLAYGAIN_TRACK
= 0, REPLAYGAIN_ALBUM
, REPLAYGAIN_SHUFFLE
};
617 /* show path types */
618 enum { SHOW_PATH_OFF
= 0, SHOW_PATH_CURRENT
, SHOW_PATH_FULL
};
620 #endif /* __SETTINGS_H__ */