Add AAC audio type
[Rockbox.git] / apps / settings.h
blob99254e377f739df90cdd307e9fea9dd585937fa4
1 /***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
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__
23 #include <stdbool.h>
24 #include "config.h"
25 #include "file.h"
26 #include "dircache.h"
27 #include "timefuncs.h"
28 #include "abrepeat.h"
30 #define ROCKBOX_DIR "/.rockbox"
31 #define ROCKBOX_DIR_LEN 9
32 #define FONT_DIR "/fonts"
33 #define LANG_DIR "/langs"
34 #define PLUGIN_DIR ROCKBOX_DIR"/rocks"
35 #define REC_BASE_DIR "/recordings"
37 #define MAX_FILENAME 20
39 /* button definitions */
40 #if (CONFIG_KEYPAD == IRIVER_H100_PAD) || \
41 (CONFIG_KEYPAD == IRIVER_H300_PAD)
42 #define SETTINGS_INC BUTTON_UP
43 #define SETTINGS_DEC BUTTON_DOWN
44 #define SETTINGS_OK BUTTON_SELECT
45 #define SETTINGS_OK2 BUTTON_LEFT
46 #define SETTINGS_CANCEL BUTTON_OFF
47 #define SETTINGS_CANCEL2 BUTTON_MODE
49 #elif CONFIG_KEYPAD == RECORDER_PAD
50 #define SETTINGS_INC BUTTON_UP
51 #define SETTINGS_DEC BUTTON_DOWN
52 #define SETTINGS_OK BUTTON_PLAY
53 #define SETTINGS_OK2 BUTTON_LEFT
54 #define SETTINGS_CANCEL BUTTON_OFF
55 #define SETTINGS_CANCEL2 BUTTON_F1
57 #elif CONFIG_KEYPAD == PLAYER_PAD
58 #define SETTINGS_INC BUTTON_RIGHT
59 #define SETTINGS_DEC BUTTON_LEFT
60 #define SETTINGS_OK BUTTON_PLAY
61 #define SETTINGS_CANCEL BUTTON_STOP
62 #define SETTINGS_CANCEL2 BUTTON_MENU
64 #elif CONFIG_KEYPAD == ONDIO_PAD
65 #define SETTINGS_INC BUTTON_UP
66 #define SETTINGS_DEC BUTTON_DOWN
67 #define SETTINGS_OK BUTTON_RIGHT
68 #define SETTINGS_OK2 BUTTON_LEFT
69 #define SETTINGS_CANCEL BUTTON_MENU
70 #define SETTINGS_CANCEL2 BUTTON_OFF
72 #elif CONFIG_KEYPAD == GMINI100_PAD
73 #define SETTINGS_INC BUTTON_UP
74 #define SETTINGS_DEC BUTTON_DOWN
75 #define SETTINGS_OK BUTTON_PLAY
76 #define SETTINGS_OK2 BUTTON_LEFT
77 #define SETTINGS_CANCEL BUTTON_OFF
78 #define SETTINGS_CANCEL2 BUTTON_MENU
80 #endif
82 /* data structures */
84 #define BOOKMARK_NO 0
85 #define BOOKMARK_YES 1
86 #define BOOKMARK_ASK 2
87 #define BOOKMARK_UNIQUE_ONLY 2
88 #define BOOKMARK_RECENT_ONLY_YES 3
89 #define BOOKMARK_RECENT_ONLY_ASK 4
90 #define FF_REWIND_1000 0
91 #define FF_REWIND_2000 1
92 #define FF_REWIND_3000 2
93 #define FF_REWIND_4000 3
94 #define FF_REWIND_5000 4
95 #define FF_REWIND_6000 5
96 #define FF_REWIND_8000 6
97 #define FF_REWIND_10000 7
98 #define FF_REWIND_15000 8
99 #define FF_REWIND_20000 9
100 #define FF_REWIND_25000 10
101 #define FF_REWIND_30000 11
102 #define FF_REWIND_45000 12
103 #define FF_REWIND_60000 13
105 #define TRIG_MODE_OFF 0
106 #define TRIG_MODE_NOREARM 1
107 #define TRIG_MODE_REARM 2
109 #define TRIG_DURATION_COUNT 13
110 extern const char * const trig_durations[TRIG_DURATION_COUNT];
112 #define CROSSFADE_MODE_OFF 0
113 #define CROSSFADE_MODE_CROSSFADE 1
114 #define CROSSFADE_MODE_MIX 2
116 /* These define "virtual pointers", which could either be a literal string,
117 or a mean a string ID if the pointer is in a certain range.
118 This helps to save space for menus and options. */
120 #define VIRT_SIZE 0xFFFF /* more than enough for our string ID range */
121 #ifdef SIMULATOR
122 /* a space which is defined in stubs.c */
123 extern unsigned char vp_dummy[VIRT_SIZE];
124 #define VIRT_PTR vp_dummy
125 #else
126 /* a location where we won't store strings, 0 is the fastest */
127 #define VIRT_PTR ((unsigned char*)0)
128 #endif
130 /* form a "virtual pointer" out of a language ID */
131 #define ID2P(id) (VIRT_PTR + id)
133 /* resolve a pointer which could be a virtualized ID or a literal */
134 #define P2STR(p) ((p>=VIRT_PTR && p<=VIRT_PTR+VIRT_SIZE) ? str(p-VIRT_PTR) : p)
136 /* get the string ID from a virtual pointer, -1 if not virtual */
137 #define P2ID(p) ((p>=VIRT_PTR && p<=VIRT_PTR+VIRT_SIZE) ? p-VIRT_PTR : -1)
140 struct user_settings
142 /* audio settings */
144 int volume; /* audio output volume: 0-100 0=off 100=max */
145 int balance; /* stereo balance: 0-100 0=left 50=bal 100=right */
146 int bass; /* bass eq: 0-100 0=off 100=max */
147 int treble; /* treble eq: 0-100 0=low 100=high */
148 int loudness; /* loudness eq: 0-100 0=off 100=max */
149 int avc; /* auto volume correct: 0=off, 1=20ms, 2=2s 3=4s 4=8s */
150 int channel_config; /* Stereo, Mono, Custom, Mono left, Mono right, Karaoke */
151 int stereo_width; /* 0-255% */
152 int mdb_strength; /* 0-127dB */
153 int mdb_harmonics; /* 0-100% */
154 int mdb_center; /* 20-300Hz */
155 int mdb_shape; /* 50-300Hz */
156 bool mdb_enable; /* true/false */
157 bool superbass; /* true/false */
159 #if CONFIG_CODEC == SWCODEC
160 int crossfade;
161 int crossfade_duration;
162 #endif
164 int rec_quality; /* 0-7 */
165 int rec_source; /* 0=mic, 1=line, 2=S/PDIF */
166 int rec_frequency; /* 0 = 44.1kHz
167 1 = 48kHz
168 2 = 32kHz
169 3 = 22.05kHz
170 4 = 24kHz
171 5 = 16kHz */
172 int rec_channels; /* 0=Stereo, 1=Mono */
173 int rec_mic_gain; /* 0-15 */
174 int rec_left_gain; /* 0-15 */
175 int rec_right_gain; /* 0-15 */
176 bool rec_editable; /* true means that the bit reservoir is off */
178 /* note: timesplit setting is not saved */
179 int rec_timesplit; /* 0 = off,
180 1 = 00:05, 2 = 00:10, 3 = 00:15, 4 = 00:30
181 5 = 01:00, 6 = 02:00, 7 = 04:00, 8 = 06:00
182 9 = 08:00, 10= 10:00, 11= 12:00, 12= 18:00,
183 13= 24:00 */
185 int rec_prerecord_time; /* In seconds, 0-30, 0 means OFF */
186 int rec_directory; /* 0=base dir, 1=current dir */
187 bool rec_startup; /* true means start Rockbox in recording screen */
189 int rec_start_thres; /* negative: db, positive: % range -87 .. 100 */
190 int rec_start_duration; /* index of trig_durations */
191 int rec_stop_thres; /* negative: db, positive: % */
192 int rec_stop_postrec; /* negative: db, positive: % range -87 .. 100 */
193 int rec_stop_gap; /* index of trig_durations */
194 int rec_trigger_mode; /* see TRIG_MODE_XXX constants */
196 /* device settings */
198 int contrast; /* lcd contrast: 0-63 0=low 63=high */
199 bool invert; /* invert display */
200 bool invert_cursor; /* invert the current file in dir browser and menu
201 instead of using the default cursor */
202 bool flip_display; /* turn display (and button layout) by 180 degrees */
203 bool bidi_support; /* reverse hebrew/arabic chars: 0=off, 1=on */
204 int poweroff; /* power off timer */
205 int backlight_timeout; /* backlight off timeout: 0-18 0=never,
206 1=always,
207 then according to timeout_values[] */
208 bool backlight_on_when_charging;
209 #if CONFIG_BACKLIGHT == BL_IRIVER
210 int backlight_fade_in; /* backlight fade in timing: 0..3 */
211 int backlight_fade_out; /* backlight fade in timing: 0..7 */
212 #endif
213 int battery_capacity; /* in mAh */
214 int battery_type; /* for units which can take multiple types (Ondio). */
216 #ifdef HAVE_SPDIF_POWER
217 bool spdif_enable; /* S/PDIF power on/off */
218 #endif
220 /* resume settings */
222 bool resume; /* resume option: 0=off, 1=on */
223 int resume_index; /* index in playlist (-1 for no active resume) */
224 int resume_first_index; /* index of first track in playlist */
225 unsigned long resume_offset; /* byte offset in mp3 file */
226 int resume_seed; /* shuffle seed (-1=no resume shuffle 0=sorted
227 >0=shuffled) */
229 unsigned char font_file[MAX_FILENAME+1]; /* last font */
230 unsigned char wps_file[MAX_FILENAME+1]; /* last wps */
231 unsigned char lang_file[MAX_FILENAME+1]; /* last language */
233 /* misc options */
235 int repeat_mode; /* 0=off 1=repeat all 2=repeat one 3=shuffle 4=ab */
236 int dirfilter; /* 0=display all, 1=only supported, 2=only music,
237 3=dirs+playlists, 4=ID3 database */
238 bool sort_case; /* dir sort order: 0=case insensitive, 1=sensitive */
239 int volume_type; /* how volume is displayed: 0=graphic, 1=percent */
240 int battery_display; /* how battery is displayed: 0=graphic, 1=percent */
241 int timeformat; /* time format: 0=24 hour clock, 1=12 hour clock */
242 int scroll_speed; /* long texts scrolling speed: 1-30 */
243 bool playlist_shuffle;
244 bool play_selected; /* Plays selected file even in shuffle mode */
245 int ff_rewind_min_step; /* FF/Rewind minimum step size */
246 int ff_rewind_accel; /* FF/Rewind acceleration (in seconds per doubling) */
247 int disk_spindown; /* time until disk spindown, in seconds (0=off) */
248 bool disk_poweroff; /* whether to cut disk power after spindown or not */
249 int buffer_margin; /* MP3 buffer watermark margin, in seconds */
251 int peak_meter_release; /* units per read out */
252 int peak_meter_hold; /* hold time for peak meter in 1/100 s */
253 int peak_meter_clip_hold; /* hold time for clips */
254 bool peak_meter_dbfs; /* show linear or dbfs values */
255 int peak_meter_min; /* range minimum */
256 int peak_meter_max; /* range maximum */
257 bool car_adapter_mode; /* 0=off 1=on */
259 /* show status bar */
260 bool statusbar; /* 0=hide, 1=show */
262 /* show button bar */
263 bool buttonbar; /* 0=hide, 1=show */
265 /* show scroll bar */
266 bool scrollbar; /* 0=hide, 1=show */
268 /* goto current song when exiting WPS */
269 bool browse_current; /* 1=goto current song,
270 0=goto previous location */
272 int runtime; /* current runtime since last charge */
273 int topruntime; /* top known runtime */
275 int bidir_limit; /* bidir scroll length limit */
276 int scroll_delay; /* delay (in 1/10s) before starting scroll */
277 int scroll_step; /* pixels to advance per update */
279 /* auto bookmark settings */
280 int autoloadbookmark; /* auto load option: 0=off, 1=ask, 2=on */
281 int autocreatebookmark; /* auto create option: 0=off, 1=ask, 2=on */
282 int usemrb; /* use MRB list: 0=No, 1=Yes*/
283 #ifdef HAVE_LCD_CHARCELLS
284 int jump_scroll; /* Fast jump when scrolling */
285 int jump_scroll_delay; /* Delay between jump scroll screens */
286 #endif
287 bool fade_on_stop; /* fade on pause/unpause/stop */
288 bool caption_backlight; /* turn on backlight at end and start of track */
290 #ifdef CONFIG_TUNER
291 int fm_freq_step; /* Frequency step for manual tuning, in kHz */
292 bool fm_force_mono; /* Forces Mono mode if true */
293 bool fm_full_range; /* Enables full 10MHz-160MHz range if true, else
294 only 88MHz-108MHz */
295 int last_frequency; /* Last frequency for resuming, in FREQ_STEP units,
296 relative to MIN_FREQ */
297 #endif
299 int max_files_in_dir; /* Max entries in directory (file browser) */
300 int max_files_in_playlist; /* Max entries in playlist */
301 bool show_icons; /* 0=hide 1=show */
302 int recursive_dir_insert; /* should directories be inserted recursively */
304 bool line_in; /* false=off, true=active */
306 bool id3_v1_first; /* true = ID3V1 has prio over ID3V2 tag */
308 /* playlist viewer settings */
309 bool playlist_viewer_icons; /* display icons on viewer */
310 bool playlist_viewer_indices; /* display playlist indices on viewer */
311 int playlist_viewer_track_display; /* how to display tracks in viewer */
313 /* voice UI settings */
314 bool talk_menu; /* enable voice UI */
315 int talk_dir; /* talkbox mode: 0=off 1=number 2=clip@enter 3=clip@hover */
316 int talk_file; /* voice filename mode: 0=off, 1=number, other t.b.d. */
318 /* file browser sorting */
319 int sort_file; /* 0=alpha, 1=date, 2=date (new first), 3=type */
320 int sort_dir; /* 0=alpha, 1=date (old first), 2=date (new first) */
322 #ifdef HAVE_REMOTE_LCD
323 /* remote lcd */
324 int remote_contrast; /* lcd contrast: 0-63 0=low 63=high */
325 bool remote_invert; /* invert display */
326 bool remote_flip_display; /* turn display (and button layout) by 180 degrees */
327 int remote_backlight_timeout; /* backlight off timeout: 0-18 0=never,
328 1=always,
329 then according to timeout_values[] */
330 #endif
332 bool next_folder; /* move to next folder */
333 bool runtimedb; /* runtime database active? */
335 #if CONFIG_CODEC == SWCODEC
336 bool replaygain; /* enable replaygain */
337 bool replaygain_noclip; /* scale to prevent clips */
338 int replaygain_type; /* 0=track gain, 1=album gain, 2=track gain if
339 shuffle is on, album gain otherwise */
340 int replaygain_preamp; /* scale replaygained tracks by this */
341 int beep; /* system beep volume when changing tracks etc. */
342 #endif
343 #ifdef HAVE_DIRCACHE
344 bool dircache; /* enable directory cache */
345 int dircache_size; /* directory cache structure last size, 22 bits */
346 #endif
349 enum optiontype { INT, BOOL };
351 struct opt_items {
352 unsigned const char* string;
353 long voice_id;
356 /* prototypes */
358 void settings_calc_config_sector(void);
359 int settings_save(void);
360 void settings_load(int which);
361 void settings_reset(void);
362 void sound_settings_apply(void);
363 void settings_apply(void);
364 void settings_apply_pm_range(void);
365 void settings_display(void);
367 bool settings_load_config(const char* file);
368 bool settings_save_config(void);
369 bool set_bool_options(const char* string, bool* variable,
370 const char* yes_str, int yes_voice,
371 const char* no_str, int no_voice,
372 void (*function)(bool));
374 bool set_bool(const char* string, bool* variable );
375 bool set_option(const char* string, void* variable, enum optiontype type,
376 const struct opt_items* options, int numoptions, void (*function)(int));
377 bool set_int(const char* string, const char* unit, int voice_unit, int* variable,
378 void (*function)(int), int step, int min, int max,
379 void (*formatter)(char*, int, int, const char*) );
380 bool set_time_screen(const char* string, struct tm *tm);
381 int read_line(int fd, char* buffer, int buffer_size);
382 void set_file(char* filename, char* setting, int maxlen);
384 unsigned int rec_timesplit_seconds(void);
385 void settings_apply_trigger(void);
387 /* global settings */
388 extern struct user_settings global_settings;
389 /* name of directory where configuration, fonts and other data
390 * files are stored */
391 extern long lasttime;
393 /* Recording base directory */
394 extern const char rec_base_directory[];
396 /* system defines */
398 #ifdef HAVE_LCD_CHARCELLS
399 #define MAX_CONTRAST_SETTING 31
400 #define DEFAULT_CONTRAST_SETTING 30
401 #else
402 #define MAX_CONTRAST_SETTING 63
403 #define DEFAULT_CONTRAST_SETTING 38
404 #endif
405 #define MIN_CONTRAST_SETTING 5
407 /* argument bits for settings_load() */
408 #define SETTINGS_RTC 1 /* only the settings from the RTC nonvolatile RAM */
409 #define SETTINGS_HD 2 /* only the settings fron the disk sector */
410 #define SETTINGS_ALL 3 /* both */
412 /* repeat mode options */
413 enum
415 REPEAT_OFF,
416 REPEAT_ALL,
417 REPEAT_ONE,
418 REPEAT_SHUFFLE,
419 #ifdef AB_REPEAT_ENABLE
420 REPEAT_AB,
421 #endif
422 NUM_REPEAT_MODES
425 /* dir filter options */
426 /* Note: Any new filter modes need to be added before NUM_FILTER_MODES.
427 * Any new rockbox browse filter modes (accessible through the menu)
428 * must be added after NUM_FILTER_MODES. */
429 enum { SHOW_ALL, SHOW_SUPPORTED, SHOW_MUSIC, SHOW_PLAYLIST, SHOW_ID3DB,
430 NUM_FILTER_MODES,
431 SHOW_WPS, SHOW_CFG, SHOW_LNG, SHOW_MOD, SHOW_FONT, SHOW_PLUGINS};
433 /* recursive dir insert options */
434 enum { RECURSE_OFF, RECURSE_ON, RECURSE_ASK };
436 /* replaygain types */
437 enum { REPLAYGAIN_TRACK = 0, REPLAYGAIN_ALBUM, REPLAYGAIN_SHUFFLE };
439 #endif /* __SETTINGS_H__ */