Björn Stenberg | f80d8a70 | 2002-06-27 00:20:00 +0000 | [diff] [blame] | 1 | /*************************************************************************** |
| 2 | * __________ __ ___. |
| 3 | * Open \______ \ ____ ____ | | _\_ |__ _______ ___ |
| 4 | * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / |
| 5 | * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < |
| 6 | * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ |
| 7 | * \/ \/ \/ \/ \/ |
| 8 | * $Id$ |
| 9 | * |
| 10 | * Copyright (C) 2002 by wavey@wavey.org |
Björn Stenberg | 6b25f79 | 2002-07-15 11:02:12 +0000 | [diff] [blame] | 11 | * RTC config saving code (C) 2002 by hessu@hes.iki.fi |
Björn Stenberg | f80d8a70 | 2002-06-27 00:20:00 +0000 | [diff] [blame] | 12 | * |
| 13 | * All files in this archive are subject to the GNU General Public License. |
| 14 | * See the file COPYING in the source tree root for full license agreement. |
| 15 | * |
| 16 | * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY |
| 17 | * KIND, either express or implied. |
| 18 | * |
| 19 | ****************************************************************************/ |
Björn Stenberg | f80d8a70 | 2002-06-27 00:20:00 +0000 | [diff] [blame] | 20 | #include <stdio.h> |
Jörg Hohensohn | 44171b9 | 2004-06-18 20:41:59 +0000 | [diff] [blame] | 21 | #include <stddef.h> |
Jean-Philippe Bernardy | 00cf0da | 2005-02-15 15:30:19 +0000 | [diff] [blame] | 22 | #include <limits.h> |
Björn Stenberg | f80d8a70 | 2002-06-27 00:20:00 +0000 | [diff] [blame] | 23 | #include "config.h" |
Linus Nielsen Feltzing | d0abfe8 | 2002-07-28 16:09:44 +0000 | [diff] [blame] | 24 | #include "kernel.h" |
Björn Stenberg | c4d8d97 | 2003-02-14 09:44:34 +0000 | [diff] [blame] | 25 | #include "thread.h" |
Björn Stenberg | f80d8a70 | 2002-06-27 00:20:00 +0000 | [diff] [blame] | 26 | #include "settings.h" |
| 27 | #include "disk.h" |
| 28 | #include "panic.h" |
| 29 | #include "debug.h" |
Björn Stenberg | 60b356e | 2002-06-27 01:08:11 +0000 | [diff] [blame] | 30 | #include "button.h" |
Justin Heiner | b5025a8 | 2002-08-31 04:58:35 +0000 | [diff] [blame] | 31 | #include "usb.h" |
| 32 | #include "backlight.h" |
Björn Stenberg | 60b356e | 2002-06-27 01:08:11 +0000 | [diff] [blame] | 33 | #include "lcd.h" |
Linus Nielsen Feltzing | 8a237a8 | 2005-04-04 12:06:29 +0000 | [diff] [blame] | 34 | #include "audio.h" |
Jörg Hohensohn | f993365 | 2004-01-05 20:42:51 +0000 | [diff] [blame] | 35 | #include "mp3_playback.h" |
Jens Arnold | 61a2550 | 2005-09-11 12:07:13 +0000 | [diff] [blame] | 36 | #include "mpeg.h" |
Jörg Hohensohn | 42ffbf9 | 2004-03-15 08:27:51 +0000 | [diff] [blame] | 37 | #include "talk.h" |
Björn Stenberg | 6b25f79 | 2002-07-15 11:02:12 +0000 | [diff] [blame] | 38 | #include "string.h" |
Linus Nielsen Feltzing | d0abfe8 | 2002-07-28 16:09:44 +0000 | [diff] [blame] | 39 | #include "ata.h" |
Björn Stenberg | cd7691d | 2002-08-13 17:16:09 +0000 | [diff] [blame] | 40 | #include "fat.h" |
Linus Nielsen Feltzing | d0abfe8 | 2002-07-28 16:09:44 +0000 | [diff] [blame] | 41 | #include "power.h" |
Linus Nielsen Feltzing | 17cf49a | 2002-07-30 07:56:16 +0000 | [diff] [blame] | 42 | #include "backlight.h" |
Heikki Hannikainen | 6eb4254 | 2002-08-06 10:52:51 +0000 | [diff] [blame] | 43 | #include "powermgmt.h" |
Markus Braun | 5e4c1d2 | 2002-08-20 19:37:00 +0000 | [diff] [blame] | 44 | #include "status.h" |
Justin Heiner | c4207f1 | 2002-09-05 16:30:07 +0000 | [diff] [blame] | 45 | #include "atoi.h" |
Björn Stenberg | b1b8bd4 | 2002-09-24 17:22:12 +0000 | [diff] [blame] | 46 | #include "screens.h" |
Björn Stenberg | 0e6088f | 2002-10-02 16:33:26 +0000 | [diff] [blame] | 47 | #include "ctype.h" |
| 48 | #include "file.h" |
Linus Nielsen Feltzing | c843ba4 | 2002-10-29 12:16:36 +0000 | [diff] [blame] | 49 | #include "errno.h" |
| 50 | #include "system.h" |
Linus Nielsen Feltzing | 75b41a8 | 2003-05-04 02:04:31 +0000 | [diff] [blame] | 51 | #include "misc.h" |
Linus Nielsen Feltzing | 7ddf0d6 | 2004-04-20 10:23:57 +0000 | [diff] [blame] | 52 | #include "timefuncs.h" |
Markus Braun | 5e4c1d2 | 2002-08-20 19:37:00 +0000 | [diff] [blame] | 53 | #ifdef HAVE_LCD_BITMAP |
| 54 | #include "icons.h" |
Daniel Stenberg | 93b231c | 2002-09-12 13:33:59 +0000 | [diff] [blame] | 55 | #include "font.h" |
Linus Nielsen Feltzing | fd0cc3b | 2002-10-29 12:09:15 +0000 | [diff] [blame] | 56 | #include "peakmeter.h" |
Linus Nielsen Feltzing | 9fb2d34 | 2003-06-25 23:24:47 +0000 | [diff] [blame] | 57 | #include "hwcompat.h" |
Markus Braun | 5e4c1d2 | 2002-08-20 19:37:00 +0000 | [diff] [blame] | 58 | #endif |
Björn Stenberg | 505eca7 | 2002-09-18 14:08:05 +0000 | [diff] [blame] | 59 | #include "lang.h" |
Björn Stenberg | dea3122 | 2002-10-08 15:42:40 +0000 | [diff] [blame] | 60 | #include "language.h" |
Christi Scarborough | 4c0b83f | 2005-11-17 20:14:59 +0000 | [diff] [blame] | 61 | #include "gwps.h" |
Björn Stenberg | ae22de2 | 2002-12-02 16:07:56 +0000 | [diff] [blame] | 62 | #include "powermgmt.h" |
Björn Stenberg | a108ec2 | 2004-01-14 00:13:04 +0000 | [diff] [blame] | 63 | #include "bookmark.h" |
Daniel Stenberg | 79a6cb6 | 2003-02-15 00:03:23 +0000 | [diff] [blame] | 64 | #include "sprintf.h" |
Björn Stenberg | c5aaab4 | 2003-03-10 16:31:02 +0000 | [diff] [blame] | 65 | #include "keyboard.h" |
Björn Stenberg | a6b8bdf | 2003-04-25 10:33:38 +0000 | [diff] [blame] | 66 | #include "version.h" |
Jörg Hohensohn | 44171b9 | 2004-06-18 20:41:59 +0000 | [diff] [blame] | 67 | #include "rtc.h" |
Linus Nielsen Feltzing | 674eaca | 2005-04-01 13:41:03 +0000 | [diff] [blame] | 68 | #include "sound.h" |
Marcoen Hirschberg | b0fee17 | 2005-12-06 13:27:15 +0000 | [diff] [blame^] | 69 | #include "rbunicode.h" |
Miika Pekkarinen | ab78b04 | 2005-10-07 17:38:05 +0000 | [diff] [blame] | 70 | #include "dircache.h" |
Kevin Ferrare | cbbdc95 | 2005-11-04 07:18:36 +0000 | [diff] [blame] | 71 | #include "select.h" |
| 72 | #include "statusbar.h" |
Kevin Ferrare | 9ccca4a | 2005-11-04 17:25:29 +0000 | [diff] [blame] | 73 | #include "splash.h" |
Miika Pekkarinen | ab78b04 | 2005-10-07 17:38:05 +0000 | [diff] [blame] | 74 | |
Jens Arnold | d6c0545 | 2005-08-29 21:15:27 +0000 | [diff] [blame] | 75 | #if CONFIG_CODEC == MAS3507D |
Linus Nielsen Feltzing | 54a7e20 | 2003-11-04 00:18:19 +0000 | [diff] [blame] | 76 | void dac_line_in(bool enable); |
Linus Nielsen Feltzing | c22b411 | 2003-11-03 23:36:36 +0000 | [diff] [blame] | 77 | #endif |
Björn Stenberg | f80d8a70 | 2002-06-27 00:20:00 +0000 | [diff] [blame] | 78 | struct user_settings global_settings; |
Jens Arnold | a559cf2 | 2005-05-08 13:41:24 +0000 | [diff] [blame] | 79 | #ifdef HAVE_RECORDING |
Jens Arnold | abe77a1 | 2004-08-01 21:50:57 +0000 | [diff] [blame] | 80 | const char rec_base_directory[] = REC_BASE_DIR; |
Jens Arnold | a559cf2 | 2005-05-08 13:41:24 +0000 | [diff] [blame] | 81 | #endif |
Jens Arnold | d6c0545 | 2005-08-29 21:15:27 +0000 | [diff] [blame] | 82 | #if CONFIG_CODEC == SWCODEC |
Miika Pekkarinen | 20b3897 | 2005-07-13 12:48:22 +0000 | [diff] [blame] | 83 | #include "pcmbuf.h" |
Linus Nielsen Feltzing | 6271b2b | 2005-06-09 09:47:00 +0000 | [diff] [blame] | 84 | #include "pcm_playback.h" |
Magnus Holmgren | 4b711c2 | 2005-09-24 15:22:48 +0000 | [diff] [blame] | 85 | #include "dsp.h" |
Linus Nielsen Feltzing | 6271b2b | 2005-06-09 09:47:00 +0000 | [diff] [blame] | 86 | #endif |
Björn Stenberg | 6c33c51 | 2004-09-19 21:58:37 +0000 | [diff] [blame] | 87 | |
Marcoen Hirschberg | b0fee17 | 2005-12-06 13:27:15 +0000 | [diff] [blame^] | 88 | #define CONFIG_BLOCK_VERSION 35 |
Björn Stenberg | 6224cdb | 2002-08-16 14:41:47 +0000 | [diff] [blame] | 89 | #define CONFIG_BLOCK_SIZE 512 |
| 90 | #define RTC_BLOCK_SIZE 44 |
Björn Stenberg | cd7691d | 2002-08-13 17:16:09 +0000 | [diff] [blame] | 91 | |
Linus Nielsen Feltzing | bb572c4 | 2002-09-27 09:31:31 +0000 | [diff] [blame] | 92 | #ifdef HAVE_LCD_BITMAP |
| 93 | #define MAX_LINES 10 |
| 94 | #else |
| 95 | #define MAX_LINES 2 |
| 96 | #endif |
| 97 | |
Christian Gmeiner | 7c1879b | 2005-04-15 12:08:49 +0000 | [diff] [blame] | 98 | #ifdef HAVE_REMOTE_LCD |
| 99 | #include "lcd-remote.h" |
| 100 | #endif |
| 101 | |
Jörg Hohensohn | 44171b9 | 2004-06-18 20:41:59 +0000 | [diff] [blame] | 102 | long lasttime = 0; |
Jean-Philippe Bernardy | 2860c5e | 2005-02-11 18:41:40 +0000 | [diff] [blame] | 103 | static long config_sector = 0; /* mark uninitialized */ |
Jörg Hohensohn | 44171b9 | 2004-06-18 20:41:59 +0000 | [diff] [blame] | 104 | static unsigned char config_block[CONFIG_BLOCK_SIZE]; |
| 105 | |
| 106 | |
| 107 | /* descriptor for a configuration value */ |
| 108 | /* (watch the struct packing and member sizes to keep this small) */ |
| 109 | struct bit_entry |
| 110 | { |
| 111 | /* how many bits within the bitfield (1-32), MSB set if value is signed */ |
| 112 | unsigned char bit_size; /* min 6+1 bit */ |
| 113 | /* how many bytes in the global_settings struct (1,2,4) */ |
Jörg Hohensohn | 75e7e50 | 2004-06-19 09:39:25 +0000 | [diff] [blame] | 114 | unsigned char byte_size; /* min 3 bits */ |
Jörg Hohensohn | 44171b9 | 2004-06-18 20:41:59 +0000 | [diff] [blame] | 115 | /* store position in global_settings struct */ |
| 116 | short settings_offset; /* min 9 bit, better 10 */ |
| 117 | /* default value */ |
Kevin Ferrare | cbbdc95 | 2005-11-04 07:18:36 +0000 | [diff] [blame] | 118 | int default_val; /* min 15 bit */ |
Jörg Hohensohn | 75e7e50 | 2004-06-19 09:39:25 +0000 | [diff] [blame] | 119 | /* variable name in a .cfg file, NULL if not to be saved */ |
Jörg Hohensohn | 44171b9 | 2004-06-18 20:41:59 +0000 | [diff] [blame] | 120 | const char* cfg_name; |
Jörg Hohensohn | 75e7e50 | 2004-06-19 09:39:25 +0000 | [diff] [blame] | 121 | /* set of values, or NULL for a numerical value */ |
Jörg Hohensohn | 44171b9 | 2004-06-18 20:41:59 +0000 | [diff] [blame] | 122 | const char* cfg_val; |
| 123 | }; |
| 124 | |
Björn Stenberg | 6b25f79 | 2002-07-15 11:02:12 +0000 | [diff] [blame] | 125 | /******************************************** |
| 126 | |
| 127 | Config block as saved on the battery-packed RTC user RAM memory block |
| 128 | of 44 bytes, starting at offset 0x14 of the RTC memory space. |
| 129 | |
| 130 | offset abs |
| 131 | 0x00 0x14 "Roc" header signature: 0x52 0x6f 0x63 |
| 132 | 0x03 0x17 <version byte: 0x0> |
Jörg Hohensohn | 44171b9 | 2004-06-18 20:41:59 +0000 | [diff] [blame] | 133 | 0x04 0x18 start of bit-table |
| 134 | ... |
| 135 | 0x28,0x29 unused, not reachable by set_bits() without disturbing the next 2 |
| 136 | 0x2A,0x2B <checksum 2 bytes: xor of 0x00-0x29> |
Björn Stenberg | 6b25f79 | 2002-07-15 11:02:12 +0000 | [diff] [blame] | 137 | |
| 138 | Config memory is reset to 0xff and initialized with 'factory defaults' if |
| 139 | a valid header & checksum is not found. Config version number is only |
| 140 | increased when information is _relocated_ or space is _reused_ so that old |
Kevin Ferrare | cbbdc95 | 2005-11-04 07:18:36 +0000 | [diff] [blame] | 141 | versions can read and modify configuration changed by new versions. |
Jörg Hohensohn | 44171b9 | 2004-06-18 20:41:59 +0000 | [diff] [blame] | 142 | Memory locations not used by a given version should not be |
Björn Stenberg | 6b25f79 | 2002-07-15 11:02:12 +0000 | [diff] [blame] | 143 | modified unless the header & checksum test fails. |
| 144 | |
Björn Stenberg | 6224cdb | 2002-08-16 14:41:47 +0000 | [diff] [blame] | 145 | Rest of config block, only saved to disk: |
Jörg Hohensohn | 44171b9 | 2004-06-18 20:41:59 +0000 | [diff] [blame] | 146 | 0x2C start of 2nd bit-table |
| 147 | ... |
Björn Stenberg | dea3122 | 2002-10-08 15:42:40 +0000 | [diff] [blame] | 148 | 0xB8 (char[20]) WPS file |
| 149 | 0xCC (char[20]) Lang file |
| 150 | 0xE0 (char[20]) Font file |
Jörg Hohensohn | 44171b9 | 2004-06-18 20:41:59 +0000 | [diff] [blame] | 151 | 0xF4-0xFF <unused> |
Björn Stenberg | 6224cdb | 2002-08-16 14:41:47 +0000 | [diff] [blame] | 152 | |
Björn Stenberg | 6b25f79 | 2002-07-15 11:02:12 +0000 | [diff] [blame] | 153 | *************************************/ |
| 154 | |
Jörg Hohensohn | 44171b9 | 2004-06-18 20:41:59 +0000 | [diff] [blame] | 155 | /* The persistence of the global_settings members is now controlled by |
Kevin Ferrare | cbbdc95 | 2005-11-04 07:18:36 +0000 | [diff] [blame] | 156 | the two tables below, rtc_bits and hd_bits. |
| 157 | New values can just be added to the end, it will be backwards |
Jörg Hohensohn | 44171b9 | 2004-06-18 20:41:59 +0000 | [diff] [blame] | 158 | compatible. If you however change order, bitsize, etc. of existing |
| 159 | entries, you need to bump CONFIG_BLOCK_VERSION to break compatibility. |
| 160 | */ |
| 161 | |
| 162 | |
| 163 | /* convenience macro for both size and offset of global_settings member */ |
| 164 | #define S_O(val) sizeof(global_settings.val), offsetof(struct user_settings, val) |
| 165 | #define SIGNED 0x80 /* for bitsize value with signed attribute */ |
| 166 | |
| 167 | /* some sets of values which are used more than once, to save memory */ |
| 168 | static const char off_on[] = "off,on"; |
| 169 | static const char off_on_ask[] = "off,on,ask"; |
Jörg Hohensohn | d484420 | 2004-10-06 21:37:46 +0000 | [diff] [blame] | 170 | static const char off_number_spell_hover[] = "off,number,spell,hover"; |
Jens Arnold | a559cf2 | 2005-05-08 13:41:24 +0000 | [diff] [blame] | 171 | #ifdef HAVE_LCD_BITMAP |
| 172 | static const char graphic_numeric[] = "graphic,numeric"; |
| 173 | #endif |
Jörg Hohensohn | 44171b9 | 2004-06-18 20:41:59 +0000 | [diff] [blame] | 174 | |
Jens Arnold | cf986e8 | 2005-04-04 20:16:01 +0000 | [diff] [blame] | 175 | #ifdef HAVE_RECORDING |
Linus Nielsen Feltzing | 68482bb | 2005-04-04 09:12:12 +0000 | [diff] [blame] | 176 | /* keep synchronous to trig_durations and |
| 177 | trigger_times in settings_apply_trigger */ |
| 178 | static const char trig_durations_conf [] = |
| 179 | "0s,1s,2s,5s,10s,15s,20s,25s,30s,1min,2min,5min,10min"; |
Jens Arnold | cf986e8 | 2005-04-04 20:16:01 +0000 | [diff] [blame] | 180 | #endif |
Linus Nielsen Feltzing | 68482bb | 2005-04-04 09:12:12 +0000 | [diff] [blame] | 181 | |
Jens Arnold | a6d409d | 2005-11-23 20:12:33 +0000 | [diff] [blame] | 182 | #if defined(CONFIG_BACKLIGHT) |
| 183 | static const char backlight_times_conf [] = |
| 184 | "off,on,1,2,3,4,5,6,7,8,9,10,15,20,25,30,45,60,90"; |
| 185 | #endif |
| 186 | |
Kevin Ferrare | cbbdc95 | 2005-11-04 07:18:36 +0000 | [diff] [blame] | 187 | /* the part of the settings which ends up in the RTC RAM, where available |
Jörg Hohensohn | 44171b9 | 2004-06-18 20:41:59 +0000 | [diff] [blame] | 188 | (those we either need early, save frequently, or without spinup) */ |
Jens Arnold | c50a069 | 2004-07-20 19:13:46 +0000 | [diff] [blame] | 189 | static const struct bit_entry rtc_bits[] = |
Jörg Hohensohn | 44171b9 | 2004-06-18 20:41:59 +0000 | [diff] [blame] | 190 | { |
| 191 | /* placeholder, containing the size information */ |
| 192 | {9, 0, 0, 0, NULL, NULL }, /* 9 bit to tell how far this is populated */ |
| 193 | |
| 194 | /* # of bits, offset+size, default, .cfg name, .cfg values */ |
| 195 | /* sound */ |
| 196 | {7, S_O(volume), 70, "volume", NULL }, /* 0...100 */ |
Linus Nielsen Feltzing | 3db9c83 | 2004-06-21 13:42:37 +0000 | [diff] [blame] | 197 | {8 | SIGNED, S_O(balance), 0, "balance", NULL }, /* -100...100 */ |
Jens Arnold | d6c0545 | 2005-08-29 21:15:27 +0000 | [diff] [blame] | 198 | #if CONFIG_CODEC != SWCODEC /* any MAS */ |
Linus Nielsen Feltzing | 3db9c83 | 2004-06-21 13:42:37 +0000 | [diff] [blame] | 199 | {5 | SIGNED, S_O(bass), 0, "bass", NULL }, /* -15..+15 / -12..+12 */ |
| 200 | {5 | SIGNED, S_O(treble), 0, "treble", NULL }, /* -15..+15 / -12..+12 */ |
Jens Arnold | 17f6d65 | 2005-06-16 21:20:00 +0000 | [diff] [blame] | 201 | #elif defined HAVE_UDA1380 |
| 202 | {5, S_O(bass), 0, "bass", NULL }, /* 0..+24 */ |
| 203 | {3, S_O(treble), 0, "treble", NULL }, /* 0..+6 */ |
| 204 | #endif |
Jens Arnold | d6c0545 | 2005-08-29 21:15:27 +0000 | [diff] [blame] | 205 | #if (CONFIG_CODEC == MAS3587F) || (CONFIG_CODEC == MAS3539F) |
Jörg Hohensohn | 44171b9 | 2004-06-18 20:41:59 +0000 | [diff] [blame] | 206 | {5, S_O(loudness), 0, "loudness", NULL }, /* 0...17 */ |
Linus Nielsen Feltzing | 94da3b5 | 2004-06-22 12:37:42 +0000 | [diff] [blame] | 207 | {3, S_O(avc), 0, "auto volume", "off,20ms,2,4,8" }, |
Linus Nielsen Feltzing | 7bade1a | 2004-07-06 12:17:14 +0000 | [diff] [blame] | 208 | {1, S_O(superbass), false, "superbass", off_on }, |
Jörg Hohensohn | 44171b9 | 2004-06-18 20:41:59 +0000 | [diff] [blame] | 209 | #endif |
Jens Arnold | 76b257f | 2005-01-12 00:24:15 +0000 | [diff] [blame] | 210 | {3, S_O(channel_config), 0, "channels", |
| 211 | "stereo,mono,custom,mono left,mono right,karaoke" }, |
| 212 | {8, S_O(stereo_width), 100, "stereo width", NULL}, |
Anton Oleynikov | 2654d91 | 2005-12-04 14:33:10 +0000 | [diff] [blame] | 213 | #ifdef HAVE_UDA1380 |
| 214 | {2, S_O(sound_scaling), SOUND_SCALE_VOLUME, "prevent clipping", "adjust volume,adjust bass,adjust current,off"}, |
| 215 | #endif |
Jörg Hohensohn | 44171b9 | 2004-06-18 20:41:59 +0000 | [diff] [blame] | 216 | /* playback */ |
Miika Pekkarinen | f090dc3 | 2005-07-21 11:44:00 +0000 | [diff] [blame] | 217 | {1, S_O(resume), false, "resume", off_on }, |
Jörg Hohensohn | 44171b9 | 2004-06-18 20:41:59 +0000 | [diff] [blame] | 218 | {1, S_O(playlist_shuffle), false, "shuffle", off_on }, |
| 219 | {16 | SIGNED, S_O(resume_index), -1, NULL, NULL }, |
| 220 | {16 | SIGNED, S_O(resume_first_index), 0, NULL, NULL }, |
| 221 | {32 | SIGNED, S_O(resume_offset), -1, NULL, NULL }, |
| 222 | {32 | SIGNED, S_O(resume_seed), -1, NULL, NULL }, |
Linus Nielsen Feltzing | 0ad617c | 2005-08-21 23:01:12 +0000 | [diff] [blame] | 223 | {3, S_O(repeat_mode), REPEAT_ALL, "repeat", "off,all,one,shuffle,ab" }, |
Jörg Hohensohn | 44171b9 | 2004-06-18 20:41:59 +0000 | [diff] [blame] | 224 | /* LCD */ |
| 225 | {6, S_O(contrast), 40, "contrast", NULL }, |
Jörg Hohensohn | fee8617 | 2004-12-18 10:29:47 +0000 | [diff] [blame] | 226 | #ifdef CONFIG_BACKLIGHT |
Jens Arnold | a6d409d | 2005-11-23 20:12:33 +0000 | [diff] [blame] | 227 | {5, S_O(backlight_timeout), 5, "backlight timeout", backlight_times_conf }, |
Jörg Hohensohn | fee8617 | 2004-12-18 10:29:47 +0000 | [diff] [blame] | 228 | #ifdef HAVE_CHARGING |
Jens Arnold | a6d409d | 2005-11-23 20:12:33 +0000 | [diff] [blame] | 229 | {5, S_O(backlight_timeout_plugged), 11, "backlight timeout plugged", |
| 230 | backlight_times_conf }, |
Jörg Hohensohn | fee8617 | 2004-12-18 10:29:47 +0000 | [diff] [blame] | 231 | #endif |
Jörg Hohensohn | fee8617 | 2004-12-18 10:29:47 +0000 | [diff] [blame] | 232 | #endif /* CONFIG_BACKLIGHT */ |
Jörg Hohensohn | 44171b9 | 2004-06-18 20:41:59 +0000 | [diff] [blame] | 233 | #ifdef HAVE_LCD_BITMAP |
| 234 | {1, S_O(invert), false, "invert", off_on }, |
| 235 | {1, S_O(flip_display), false, "flip display", off_on }, |
| 236 | /* display */ |
Kevin Ferrare | ed95645 | 2005-11-20 03:18:00 +0000 | [diff] [blame] | 237 | {1, S_O(invert_cursor), true, "invert cursor", off_on }, |
Jörg Hohensohn | 44171b9 | 2004-06-18 20:41:59 +0000 | [diff] [blame] | 238 | {1, S_O(statusbar), true, "statusbar", off_on }, |
| 239 | {1, S_O(scrollbar), true, "scrollbar", off_on }, |
Jens Arnold | 1f0908d | 2004-10-09 20:54:15 +0000 | [diff] [blame] | 240 | #if CONFIG_KEYPAD == RECORDER_PAD |
Jörg Hohensohn | 44171b9 | 2004-06-18 20:41:59 +0000 | [diff] [blame] | 241 | {1, S_O(buttonbar), true, "buttonbar", off_on }, |
Jens Arnold | 1f0908d | 2004-10-09 20:54:15 +0000 | [diff] [blame] | 242 | #endif |
Jörg Hohensohn | 44171b9 | 2004-06-18 20:41:59 +0000 | [diff] [blame] | 243 | {1, S_O(volume_type), 0, "volume display", graphic_numeric }, |
Jens Arnold | 9d42e2b | 2005-01-30 13:48:44 +0000 | [diff] [blame] | 244 | {1, S_O(battery_display), 0, "battery display", graphic_numeric }, |
Jörg Hohensohn | 44171b9 | 2004-06-18 20:41:59 +0000 | [diff] [blame] | 245 | {1, S_O(timeformat), 0, "time format", "24hour,12hour" }, |
Jens Arnold | 05af280 | 2005-07-28 08:36:24 +0000 | [diff] [blame] | 246 | #endif /* HAVE_LCD_BITMAP */ |
Hardeep Sidhu | ea598c7 | 2004-07-12 22:02:53 +0000 | [diff] [blame] | 247 | {1, S_O(show_icons), true, "show icons", off_on }, |
Jörg Hohensohn | 44171b9 | 2004-06-18 20:41:59 +0000 | [diff] [blame] | 248 | /* system */ |
Jens Arnold | 76b257f | 2005-01-12 00:24:15 +0000 | [diff] [blame] | 249 | {4, S_O(poweroff), 10, |
Jörg Hohensohn | 44171b9 | 2004-06-18 20:41:59 +0000 | [diff] [blame] | 250 | "idle poweroff", "off,1,2,3,4,5,6,7,8,9,10,15,30,45,60" }, |
| 251 | {18, S_O(runtime), 0, NULL, NULL }, |
| 252 | {18, S_O(topruntime), 0, NULL, NULL }, |
Kevin Ferrare | cbbdc95 | 2005-11-04 07:18:36 +0000 | [diff] [blame] | 253 | {15, S_O(max_files_in_playlist), 10000, |
Jörg Hohensohn | 44171b9 | 2004-06-18 20:41:59 +0000 | [diff] [blame] | 254 | "max files in playlist", NULL }, /* 1000...20000 */ |
Kevin Ferrare | cbbdc95 | 2005-11-04 07:18:36 +0000 | [diff] [blame] | 255 | {14, S_O(max_files_in_dir), 400, |
Jörg Hohensohn | 44171b9 | 2004-06-18 20:41:59 +0000 | [diff] [blame] | 256 | "max files in dir", NULL }, /* 50...10000 */ |
| 257 | /* battery */ |
Jens Arnold | fe32456 | 2004-10-10 10:28:21 +0000 | [diff] [blame] | 258 | {12, S_O(battery_capacity), BATTERY_CAPACITY_MIN, "battery capacity", |
| 259 | NULL }, /* 1500...3200 for NiMH, 2200...3200 for LiIon, |
Jens Arnold | 76b257f | 2005-01-12 00:24:15 +0000 | [diff] [blame] | 260 | 500...1500 for Alkaline */ |
Jens Arnold | ccfa4cd | 2004-10-10 01:25:32 +0000 | [diff] [blame] | 261 | #ifdef HAVE_CHARGING |
Jörg Hohensohn | 44171b9 | 2004-06-18 20:41:59 +0000 | [diff] [blame] | 262 | {1, S_O(car_adapter_mode), false, "car adapter mode", off_on }, |
Jens Arnold | ccfa4cd | 2004-10-10 01:25:32 +0000 | [diff] [blame] | 263 | #endif |
Jens Arnold | 76b257f | 2005-01-12 00:24:15 +0000 | [diff] [blame] | 264 | /* tuner */ |
Jörg Hohensohn | 593cc00 | 2004-09-28 22:13:26 +0000 | [diff] [blame] | 265 | #ifdef CONFIG_TUNER |
Linus Nielsen Feltzing | 6e95efd | 2004-07-05 14:27:50 +0000 | [diff] [blame] | 266 | {1, S_O(fm_force_mono), false, "force fm mono", off_on }, |
Linus Nielsen Feltzing | 4a7784a | 2004-07-12 15:06:48 +0000 | [diff] [blame] | 267 | {8, S_O(last_frequency), 0, NULL, NULL }, /* Default: MIN_FREQ */ |
Linus Nielsen Feltzing | 09a1725 | 2004-07-05 18:09:00 +0000 | [diff] [blame] | 268 | #endif |
Jörg Hohensohn | 44171b9 | 2004-06-18 20:41:59 +0000 | [diff] [blame] | 269 | |
Jens Arnold | 91846a1 | 2005-01-30 16:25:46 +0000 | [diff] [blame] | 270 | #if BATTERY_TYPES_COUNT > 1 |
| 271 | {1, S_O(battery_type), 0, "battery type", "alkaline,nimh" }, |
| 272 | #endif |
| 273 | |
Christian Gmeiner | 7c1879b | 2005-04-15 12:08:49 +0000 | [diff] [blame] | 274 | #ifdef HAVE_REMOTE_LCD |
| 275 | /* remote lcd */ |
Christian Gmeiner | 7477c09 | 2005-05-30 00:00:22 +0000 | [diff] [blame] | 276 | {6, S_O(remote_contrast), 42, "remote contrast", NULL }, |
| 277 | {1, S_O(remote_invert), false, "remote invert", off_on }, |
Jens Arnold | bd1bb5f | 2005-06-17 21:43:00 +0000 | [diff] [blame] | 278 | {1, S_O(remote_flip_display), false, "remote flip display", off_on }, |
Jens Arnold | a6d409d | 2005-11-23 20:12:33 +0000 | [diff] [blame] | 279 | {5, S_O(remote_backlight_timeout), 5, "remote backlight timeout", |
| 280 | backlight_times_conf }, |
| 281 | #ifdef HAVE_CHARGING |
| 282 | {5, S_O(remote_backlight_timeout_plugged), 11, |
| 283 | "remote backlight timeout plugged", backlight_times_conf }, |
Christian Gmeiner | 7c1879b | 2005-04-15 12:08:49 +0000 | [diff] [blame] | 284 | #endif |
Jens Arnold | b51f7df | 2005-11-21 23:55:39 +0000 | [diff] [blame] | 285 | #ifdef HAVE_REMOTE_LCD_TICKING |
Miika Pekkarinen | 05fdb1a | 2005-11-19 07:58:20 +0000 | [diff] [blame] | 286 | {1, S_O(remote_reduce_ticking), false, "remote reduce ticking", off_on }, |
| 287 | #endif |
Jens Arnold | b51f7df | 2005-11-21 23:55:39 +0000 | [diff] [blame] | 288 | #endif |
Miika Pekkarinen | 05fdb1a | 2005-11-19 07:58:20 +0000 | [diff] [blame] | 289 | |
Jens Arnold | 05af280 | 2005-07-28 08:36:24 +0000 | [diff] [blame] | 290 | /* new stuff to be added here */ |
| 291 | /* If values are just added to the end, no need to bump the version. */ |
| 292 | |
Linus Nielsen Feltzing | 41a53d2 | 2005-08-08 19:23:28 +0000 | [diff] [blame] | 293 | /* Current sum of bits: 277 (worst case, but w/o remote lcd) */ |
Jörg Hohensohn | 44171b9 | 2004-06-18 20:41:59 +0000 | [diff] [blame] | 294 | /* Sum of all bit sizes must not grow beyond 288! */ |
| 295 | }; |
| 296 | |
| 297 | |
| 298 | /* the part of the settings which ends up in HD sector only */ |
Jens Arnold | c50a069 | 2004-07-20 19:13:46 +0000 | [diff] [blame] | 299 | static const struct bit_entry hd_bits[] = |
Jörg Hohensohn | 44171b9 | 2004-06-18 20:41:59 +0000 | [diff] [blame] | 300 | { |
| 301 | /* This table starts after the 44 RTC bytes = 352 bits. */ |
| 302 | /* Here we need 11 bits to tell how far this is populated. */ |
| 303 | |
| 304 | /* placeholder, containing the size information */ |
| 305 | {11, 0, 0, 0, NULL, NULL }, /* 11 bit to tell how far this is populated */ |
| 306 | |
| 307 | /* # of bits, offset+size, default, .cfg name, .cfg values */ |
| 308 | /* more display */ |
Jörg Hohensohn | fee8617 | 2004-12-18 10:29:47 +0000 | [diff] [blame] | 309 | #ifdef CONFIG_BACKLIGHT |
Jörg Hohensohn | 44171b9 | 2004-06-18 20:41:59 +0000 | [diff] [blame] | 310 | {1, S_O(caption_backlight), false, "caption backlight", off_on }, |
Jens Arnold | a1a08d0 | 2004-10-09 19:56:27 +0000 | [diff] [blame] | 311 | #endif |
Jens Arnold | 566eae2 | 2004-10-15 20:30:29 +0000 | [diff] [blame] | 312 | {4, S_O(scroll_speed), 9, "scroll speed", NULL }, /* 0...15 */ |
Jens Arnold | 05af280 | 2005-07-28 08:36:24 +0000 | [diff] [blame] | 313 | #ifdef HAVE_LCD_BITMAP |
| 314 | #if LCD_WIDTH > 127 |
| 315 | {8, S_O(scroll_step), 6, "scroll step", NULL }, /* 1...160 */ |
| 316 | #else |
Jörg Hohensohn | 44171b9 | 2004-06-18 20:41:59 +0000 | [diff] [blame] | 317 | {7, S_O(scroll_step), 6, "scroll step", NULL }, /* 1...112 */ |
Jens Arnold | 05af280 | 2005-07-28 08:36:24 +0000 | [diff] [blame] | 318 | #endif |
| 319 | #endif /* HAVE_LCD_BITMAP */ |
Jörg Hohensohn | 44171b9 | 2004-06-18 20:41:59 +0000 | [diff] [blame] | 320 | {8, S_O(scroll_delay), 100, "scroll delay", NULL }, /* 0...250 */ |
| 321 | {8, S_O(bidir_limit), 50, "bidir limit", NULL }, /* 0...200 */ |
| 322 | #ifdef HAVE_LCD_CHARCELLS |
| 323 | {3, S_O(jump_scroll), 0, "jump scroll", NULL }, /* 0...5 */ |
| 324 | {8, S_O(jump_scroll_delay), 50, "jump scroll delay", NULL }, /* 0...250 */ |
| 325 | #endif |
| 326 | /* more playback */ |
| 327 | {1, S_O(play_selected), true, "play selected", off_on }, |
| 328 | {1, S_O(fade_on_stop), true, "volume fade", off_on }, |
Kevin Ferrare | cbbdc95 | 2005-11-04 07:18:36 +0000 | [diff] [blame] | 329 | {4, S_O(ff_rewind_min_step), FF_REWIND_1000, |
Jörg Hohensohn | 44171b9 | 2004-06-18 20:41:59 +0000 | [diff] [blame] | 330 | "scan min step", "1,2,3,4,5,6,8,10,15,20,25,30,45,60" }, |
| 331 | {4, S_O(ff_rewind_accel), 3, "scan accel", NULL }, |
Jens Arnold | d6c0545 | 2005-08-29 21:15:27 +0000 | [diff] [blame] | 332 | #if CONFIG_CODEC == SWCODEC |
Miika Pekkarinen | f090dc3 | 2005-07-21 11:44:00 +0000 | [diff] [blame] | 333 | {3, S_O(buffer_margin), 0, "antiskip", |
| 334 | "5s,15s,30s,1min,2min,3min,5min,10min" }, |
| 335 | #else |
Jörg Hohensohn | 44171b9 | 2004-06-18 20:41:59 +0000 | [diff] [blame] | 336 | {3, S_O(buffer_margin), 0, "antiskip", NULL }, |
Miika Pekkarinen | f090dc3 | 2005-07-21 11:44:00 +0000 | [diff] [blame] | 337 | #endif |
Jörg Hohensohn | 44171b9 | 2004-06-18 20:41:59 +0000 | [diff] [blame] | 338 | /* disk */ |
Jens Arnold | dd937dc | 2004-10-09 22:04:47 +0000 | [diff] [blame] | 339 | #ifndef HAVE_MMC |
Jörg Hohensohn | 44171b9 | 2004-06-18 20:41:59 +0000 | [diff] [blame] | 340 | #ifdef HAVE_ATA_POWER_OFF |
| 341 | {1, S_O(disk_poweroff), false, "disk poweroff", off_on }, |
| 342 | #endif |
| 343 | {8, S_O(disk_spindown), 5, "disk spindown", NULL }, |
Jens Arnold | 05af280 | 2005-07-28 08:36:24 +0000 | [diff] [blame] | 344 | #endif /* HAVE_MMC */ |
Jörg Hohensohn | 44171b9 | 2004-06-18 20:41:59 +0000 | [diff] [blame] | 345 | /* browser */ |
Kevin Ferrare | cbbdc95 | 2005-11-04 07:18:36 +0000 | [diff] [blame] | 346 | {3, S_O(dirfilter), SHOW_SUPPORTED, |
Björn Stenberg | fc53fd7 | 2005-01-17 11:37:36 +0000 | [diff] [blame] | 347 | "show files", "all,supported,music,playlists,id3 database" }, |
Jörg Hohensohn | 44171b9 | 2004-06-18 20:41:59 +0000 | [diff] [blame] | 348 | {1, S_O(sort_case), false, "sort case", off_on }, |
Björn Stenberg | c34d046 | 2005-11-04 12:49:42 +0000 | [diff] [blame] | 349 | {1, S_O(browse_current), false, "follow playlist", off_on }, |
Jörg Hohensohn | 44171b9 | 2004-06-18 20:41:59 +0000 | [diff] [blame] | 350 | /* playlist */ |
| 351 | {1, S_O(playlist_viewer_icons), true, "playlist viewer icons", off_on }, |
Jens Arnold | ccfa4cd | 2004-10-10 01:25:32 +0000 | [diff] [blame] | 352 | {1, S_O(playlist_viewer_indices), true, |
Jörg Hohensohn | 44171b9 | 2004-06-18 20:41:59 +0000 | [diff] [blame] | 353 | "playlist viewer indices", off_on }, |
Kevin Ferrare | cbbdc95 | 2005-11-04 07:18:36 +0000 | [diff] [blame] | 354 | {1, S_O(playlist_viewer_track_display), 0, |
Jörg Hohensohn | 44171b9 | 2004-06-18 20:41:59 +0000 | [diff] [blame] | 355 | "playlist viewer track display", "track name,full path" }, |
Kevin Ferrare | cbbdc95 | 2005-11-04 07:18:36 +0000 | [diff] [blame] | 356 | {2, S_O(recursive_dir_insert), RECURSE_OFF, |
Jörg Hohensohn | 44171b9 | 2004-06-18 20:41:59 +0000 | [diff] [blame] | 357 | "recursive directory insert", off_on_ask }, |
| 358 | /* bookmarks */ |
Kevin Ferrare | cbbdc95 | 2005-11-04 07:18:36 +0000 | [diff] [blame] | 359 | {3, S_O(autocreatebookmark), BOOKMARK_NO, "autocreate bookmarks", |
Jörg Hohensohn | 44171b9 | 2004-06-18 20:41:59 +0000 | [diff] [blame] | 360 | "off,on,ask,recent only - on,recent only - ask" }, |
| 361 | {2, S_O(autoloadbookmark), BOOKMARK_NO, |
| 362 | "autoload bookmarks", off_on_ask }, |
Kevin Ferrare | cbbdc95 | 2005-11-04 07:18:36 +0000 | [diff] [blame] | 363 | {2, S_O(usemrb), BOOKMARK_NO, |
Jörg Hohensohn | 44171b9 | 2004-06-18 20:41:59 +0000 | [diff] [blame] | 364 | "use most-recent-bookmarks", "off,on,unique only" }, |
| 365 | #ifdef HAVE_LCD_BITMAP |
| 366 | /* peak meter */ |
| 367 | {5, S_O(peak_meter_clip_hold), 16, "peak meter clip hold", /* 0...25 */ |
| 368 | "on,1,2,3,4,5,6,7,8,9,10,15,20,25,30,45,60,90,2min,3min,5min,10min,20min,45min,90min" }, |
Jens Arnold | 99a0598 | 2005-08-29 20:07:17 +0000 | [diff] [blame] | 369 | {5, S_O(peak_meter_hold), 3, "peak meter hold", |
Jörg Hohensohn | 44171b9 | 2004-06-18 20:41:59 +0000 | [diff] [blame] | 370 | "off,200ms,300ms,500ms,1,2,3,4,5,6,7,8,9,10,15,20,30,1min" }, |
| 371 | {7, S_O(peak_meter_release), 8, "peak meter release", NULL }, /* 0...126 */ |
Jens Arnold | bb187c3 | 2004-06-23 07:15:22 +0000 | [diff] [blame] | 372 | {1, S_O(peak_meter_dbfs), true, "peak meter dbfs", off_on }, |
Jörg Hohensohn | 44171b9 | 2004-06-18 20:41:59 +0000 | [diff] [blame] | 373 | {7, S_O(peak_meter_min), 60, "peak meter min", NULL }, /* 0...100 */ |
| 374 | {7, S_O(peak_meter_max), 0, "peak meter max", NULL }, /* 0...100 */ |
| 375 | #endif |
Jens Arnold | d6c0545 | 2005-08-29 21:15:27 +0000 | [diff] [blame] | 376 | #if CONFIG_CODEC == MAS3587F |
Jörg Hohensohn | 44171b9 | 2004-06-18 20:41:59 +0000 | [diff] [blame] | 377 | /* recording */ |
| 378 | {1, S_O(rec_editable), false, "editable recordings", off_on }, |
Linus Nielsen Feltzing | fb60a29 | 2004-10-27 09:24:02 +0000 | [diff] [blame] | 379 | {4, S_O(rec_timesplit), 0, "rec timesplit", /* 0...15 */ |
| 380 | "off,00:05,00:10,00:15,00:30,01:00,01:14,01:20,02:00,04:00,06:00,08:00,10:00,12:00,18:00,24:00" }, |
Jörg Hohensohn | 44171b9 | 2004-06-18 20:41:59 +0000 | [diff] [blame] | 381 | {1, S_O(rec_channels), 0, "rec channels", "stereo,mono" }, |
| 382 | {4, S_O(rec_mic_gain), 8, "rec mic gain", NULL }, |
| 383 | {3, S_O(rec_quality), 5, "rec quality", NULL }, |
Jens Arnold | 8fd5b17 | 2005-09-06 20:48:28 +0000 | [diff] [blame] | 384 | #ifdef HAVE_SPDIF_IN |
| 385 | {2, S_O(rec_source), 0 /* 0=mic */, "rec source", "mic,line,spdif" }, |
| 386 | #else |
| 387 | {1, S_O(rec_source), 0 /* 0=mic */, "rec source", "mic,line" }, |
| 388 | #endif |
Jörg Hohensohn | 44171b9 | 2004-06-18 20:41:59 +0000 | [diff] [blame] | 389 | {3, S_O(rec_frequency), 0, /* 0=44.1kHz */ |
| 390 | "rec frequency", "44,48,32,22,24,16" }, |
| 391 | {4, S_O(rec_left_gain), 2, /* 0dB */ |
| 392 | "rec left gain", NULL }, /* 0...15 */ |
| 393 | {4, S_O(rec_right_gain), 2, /* 0dB */ |
| 394 | "rec right gain", NULL }, /* 0...15 */ |
Linus Nielsen Feltzing | 0bc2c6c | 2004-10-04 13:12:31 +0000 | [diff] [blame] | 395 | {5, S_O(rec_prerecord_time), 0, "prerecording time", NULL }, /* 0...30 */ |
Jörg Hohensohn | 44171b9 | 2004-06-18 20:41:59 +0000 | [diff] [blame] | 396 | {1, S_O(rec_directory), 0, /* rec_base_directory */ |
| 397 | "rec directory", REC_BASE_DIR ",current" }, |
| 398 | #endif |
Jens Arnold | d6c0545 | 2005-08-29 21:15:27 +0000 | [diff] [blame] | 399 | #if (CONFIG_CODEC == MAS3587F) || (CONFIG_CODEC == MAS3539F) |
Jens Arnold | 05af280 | 2005-07-28 08:36:24 +0000 | [diff] [blame] | 400 | {7, S_O(mdb_strength), 0, "mdb strength", NULL}, |
| 401 | {7, S_O(mdb_harmonics), 0, "mdb harmonics", NULL}, |
| 402 | {9, S_O(mdb_center), 0, "mdb center", NULL}, |
| 403 | {9, S_O(mdb_shape), 0, "mdb shape", NULL}, |
| 404 | {1, S_O(mdb_enable), 0, "mdb enable", off_on}, |
| 405 | #endif |
Jens Arnold | d6c0545 | 2005-08-29 21:15:27 +0000 | [diff] [blame] | 406 | #if CONFIG_CODEC == MAS3507D |
Jörg Hohensohn | 44171b9 | 2004-06-18 20:41:59 +0000 | [diff] [blame] | 407 | {1, S_O(line_in), false, "line in", off_on }, |
| 408 | #endif |
| 409 | /* voice */ |
Jörg Hohensohn | d484420 | 2004-10-06 21:37:46 +0000 | [diff] [blame] | 410 | {2, S_O(talk_dir), 0, "talk dir", off_number_spell_hover }, |
| 411 | {2, S_O(talk_file), 0, "talk file", off_number_spell_hover }, |
Jörg Hohensohn | 44171b9 | 2004-06-18 20:41:59 +0000 | [diff] [blame] | 412 | {1, S_O(talk_menu), true, "talk menu", off_on }, |
| 413 | |
Jörg Hohensohn | 5c8a2f5 | 2004-06-22 09:16:44 +0000 | [diff] [blame] | 414 | {2, S_O(sort_file), 0, "sort files", "alpha,oldest,newest,type" }, |
| 415 | {2, S_O(sort_dir), 0, "sort dirs", "alpha,oldest,newest" }, |
Linus Nielsen Feltzing | 8036acc | 2004-07-27 22:23:01 +0000 | [diff] [blame] | 416 | {1, S_O(id3_v1_first), 0, "id3 tag priority", "v2-v1,v1-v2"}, |
Linus Nielsen Feltzing | 4cdcbb9 | 2004-07-27 19:20:51 +0000 | [diff] [blame] | 417 | |
Christi Scarborough | 8a8bd91 | 2005-02-04 10:37:21 +0000 | [diff] [blame] | 418 | #ifdef HAVE_RECORDING |
| 419 | {1, S_O(rec_startup), false, "rec screen on startup", off_on }, |
Linus Nielsen Feltzing | 68482bb | 2005-04-04 09:12:12 +0000 | [diff] [blame] | 420 | |
| 421 | /* values for the trigger */ |
| 422 | {8 | SIGNED, S_O(rec_start_thres), -35, "trigger start threshold", NULL}, |
| 423 | {8 | SIGNED, S_O(rec_stop_thres), -45, "trigger stop threshold", NULL}, |
| 424 | {4, S_O(rec_start_duration), 0, "trigger start duration", trig_durations_conf}, |
| 425 | {4, S_O(rec_stop_postrec), 2, "trigger stop postrec", trig_durations_conf}, |
| 426 | {4, S_O(rec_stop_gap), 1, "trigger min gap", trig_durations_conf}, |
Linus Nielsen Feltzing | c35f6a0 | 2005-09-02 07:27:07 +0000 | [diff] [blame] | 427 | {4, S_O(rec_trigger_mode ), 0, "trigger mode", "off,once,repeat"}, |
Christi Scarborough | 8a8bd91 | 2005-02-04 10:37:21 +0000 | [diff] [blame] | 428 | #endif |
Jörg Hohensohn | 44171b9 | 2004-06-18 20:41:59 +0000 | [diff] [blame] | 429 | |
Daniel Stenberg | 6b569d3 | 2005-11-14 23:37:19 +0000 | [diff] [blame] | 430 | #if CONFIG_BACKLIGHT == BL_IRIVER_H100 |
Jens Arnold | 61b9d34 | 2005-06-20 17:03:09 +0000 | [diff] [blame] | 431 | /* backlight fading */ |
| 432 | {2, S_O(backlight_fade_in), 1, "backlight fade in", "off,500ms,1s,2s"}, |
| 433 | {3, S_O(backlight_fade_out), 3, "backlight fade out", |
| 434 | "off,500ms,1s,2s,3s,4s,5s,10s"}, |
| 435 | #endif |
Kevin Ferrare | cbbdc95 | 2005-11-04 07:18:36 +0000 | [diff] [blame] | 436 | |
Linus Nielsen Feltzing | 8782bc8 | 2005-07-01 09:42:39 +0000 | [diff] [blame] | 437 | #ifdef HAVE_SPDIF_POWER |
| 438 | {1, S_O(spdif_enable), false, "spdif enable", off_on}, |
| 439 | #endif |
Hardeep Sidhu | 71d2281 | 2005-07-01 11:25:16 +0000 | [diff] [blame] | 440 | |
Jens Arnold | 5acbd3e | 2005-11-07 00:40:58 +0000 | [diff] [blame] | 441 | {1, S_O(next_folder), false, "folder navigation", off_on }, |
Jens Arnold | 8102f3d | 2005-07-02 10:50:42 +0000 | [diff] [blame] | 442 | {1, S_O(runtimedb), false, "gather runtime data", off_on }, |
Hardeep Sidhu | 71d2281 | 2005-07-01 11:25:16 +0000 | [diff] [blame] | 443 | |
Jens Arnold | d6c0545 | 2005-08-29 21:15:27 +0000 | [diff] [blame] | 444 | #if CONFIG_CODEC == SWCODEC |
Magnus Holmgren | 4a53787 | 2005-07-24 15:32:28 +0000 | [diff] [blame] | 445 | {1, S_O(replaygain), false, "replaygain", off_on }, |
Kevin Ferrare | cbbdc95 | 2005-11-04 07:18:36 +0000 | [diff] [blame] | 446 | {2, S_O(replaygain_type), REPLAYGAIN_ALBUM, "replaygain type", |
Magnus Holmgren | 4b711c2 | 2005-09-24 15:22:48 +0000 | [diff] [blame] | 447 | "track,album,track shuffle" }, |
Magnus Holmgren | 4a53787 | 2005-07-24 15:32:28 +0000 | [diff] [blame] | 448 | {1, S_O(replaygain_noclip), false, "replaygain noclip", off_on }, |
Magnus Holmgren | c78c229 | 2005-08-14 06:22:53 +0000 | [diff] [blame] | 449 | {8 | SIGNED, S_O(replaygain_preamp), 0, "replaygain preamp", NULL }, |
Jens Arnold | 4960808 | 2005-10-16 11:15:51 +0000 | [diff] [blame] | 450 | {2, S_O(beep), 0, "beep", "off,weak,moderate,strong" }, |
Miika Pekkarinen | e7461b3 | 2005-11-06 16:40:20 +0000 | [diff] [blame] | 451 | {2, S_O(crossfade), 0, "crossfade", "off,shuffle,always"}, |
| 452 | {3, S_O(crossfade_fade_in_delay), 0, "crossfade fade in delay", NULL}, |
| 453 | {3, S_O(crossfade_fade_out_delay), 0, "crossfade fade out delay", NULL}, |
| 454 | {4, S_O(crossfade_fade_in_duration), 0, "crossfade fade in duration", NULL}, |
| 455 | {4, S_O(crossfade_fade_out_duration), 0, "crossfade fade out duration", NULL}, |
| 456 | {1, S_O(crossfade_fade_out_mixmode), 0, "crossfade fade out mode", "crossfade,mix"}, |
Marcoen Hirschberg | e13fad3 | 2005-11-14 21:56:56 +0000 | [diff] [blame] | 457 | {1, S_O(crossfeed), false, "crossfeed", off_on }, |
Miika Pekkarinen | 90161c9 | 2005-07-22 16:46:27 +0000 | [diff] [blame] | 458 | #endif |
Miika Pekkarinen | ab78b04 | 2005-10-07 17:38:05 +0000 | [diff] [blame] | 459 | #ifdef HAVE_DIRCACHE |
| 460 | {1, S_O(dircache), false, "dircache", off_on }, |
| 461 | {22, S_O(dircache_size), 0, NULL, NULL }, |
| 462 | #endif |
Kevin Ferrare | cbbdc95 | 2005-11-04 07:18:36 +0000 | [diff] [blame] | 463 | |
Andy | e6e5496 | 2005-11-12 04:00:56 +0000 | [diff] [blame] | 464 | #if defined(HAVE_UDA1380) |
| 465 | /* recording settings for iriver */ |
| 466 | {4, S_O(rec_timesplit), 0, "rec timesplit", /* 0...15 */ |
| 467 | "off,00:05,00:10,00:15,00:30,01:00,01:14,01:20,02:00,04:00,06:00,08:00,10:00,12:00,18:00,24:00" }, |
| 468 | {1, S_O(rec_channels), 0, "rec channels", "stereo,mono" }, |
| 469 | {4, S_O(rec_mic_gain), 4, "rec mic gain", NULL }, |
| 470 | {1, S_O(rec_source), 0 /* 0=mic */, "rec source", "mic,line" }, |
| 471 | {3, S_O(rec_frequency), 0, /* 0=44.1kHz */ |
| 472 | "rec frequency", "44,48,32,22,24,16" }, |
| 473 | {4, S_O(rec_left_gain), 2, /* 0dB */ |
| 474 | "rec left gain", NULL }, /* 0...15 */ |
| 475 | {4, S_O(rec_right_gain), 2, /* 0dB */ |
| 476 | "rec right gain", NULL }, /* 0...15 */ |
| 477 | {5, S_O(rec_prerecord_time), 0, "prerecording time", NULL }, /* 0...30 */ |
| 478 | {1, S_O(rec_directory), 0, /* rec_base_directory */ |
| 479 | "rec directory", REC_BASE_DIR ",current" }, |
| 480 | {8|SIGNED, S_O(rec_adc_left_gain), 0, /* 0dB */ "adc left gain", NULL }, /* -128...48 */ |
| 481 | {8|SIGNED, S_O(rec_adc_right_gain), 0, /* 0dB */ "adc right gain", NULL }, /* -128...48 */ |
| 482 | #endif |
| 483 | |
Jens Arnold | b51f7df | 2005-11-21 23:55:39 +0000 | [diff] [blame] | 484 | #ifdef HAVE_REMOTE_LCD |
| 485 | {1, S_O(remote_caption_backlight), false, |
| 486 | "remote caption backlight", off_on }, |
| 487 | #endif |
Jens Arnold | 05af280 | 2005-07-28 08:36:24 +0000 | [diff] [blame] | 488 | /* If values are just added to the end, no need to bump the version. */ |
Christi Scarborough | 8a8bd91 | 2005-02-04 10:37:21 +0000 | [diff] [blame] | 489 | /* new stuff to be added at the end */ |
Jens Arnold | 05af280 | 2005-07-28 08:36:24 +0000 | [diff] [blame] | 490 | |
Jörg Hohensohn | 44171b9 | 2004-06-18 20:41:59 +0000 | [diff] [blame] | 491 | /* Sum of all bit sizes must not grow beyond 0xB8*8 = 1472 */ |
| 492 | }; |
| 493 | |
Jens Arnold | 251deaa | 2005-05-04 22:30:36 +0000 | [diff] [blame] | 494 | /* helper function to extract n (<=32) bits from an arbitrary position |
| 495 | * counting from LSB to MSB */ |
Jörg Hohensohn | 44171b9 | 2004-06-18 20:41:59 +0000 | [diff] [blame] | 496 | static unsigned long get_bits( |
Jens Arnold | 8fb3361 | 2004-08-18 01:09:31 +0000 | [diff] [blame] | 497 | const unsigned long* p, /* the start of the bitfield array */ |
Jörg Hohensohn | 44171b9 | 2004-06-18 20:41:59 +0000 | [diff] [blame] | 498 | unsigned int from, /* bit no. to start reading from */ |
| 499 | unsigned int size) /* how many bits to read */ |
| 500 | { |
Jens Arnold | 251deaa | 2005-05-04 22:30:36 +0000 | [diff] [blame] | 501 | unsigned int long_index = from / 32; |
| 502 | unsigned int bit_index = from % 32; |
Jörg Hohensohn | 44171b9 | 2004-06-18 20:41:59 +0000 | [diff] [blame] | 503 | unsigned long result; |
| 504 | |
Jens Arnold | 251deaa | 2005-05-04 22:30:36 +0000 | [diff] [blame] | 505 | result = p[long_index] >> bit_index; |
Jörg Hohensohn | 44171b9 | 2004-06-18 20:41:59 +0000 | [diff] [blame] | 506 | |
Jens Arnold | 251deaa | 2005-05-04 22:30:36 +0000 | [diff] [blame] | 507 | if (bit_index + size > 32) /* crossing longword boundary */ |
| 508 | result |= p[long_index+1] << (32 - bit_index); |
Jörg Hohensohn | 44171b9 | 2004-06-18 20:41:59 +0000 | [diff] [blame] | 509 | |
Jens Arnold | 251deaa | 2005-05-04 22:30:36 +0000 | [diff] [blame] | 510 | result &= 0xFFFFFFFF >> (32 - size); |
Jörg Hohensohn | 44171b9 | 2004-06-18 20:41:59 +0000 | [diff] [blame] | 511 | |
| 512 | return result; |
| 513 | } |
| 514 | |
Jens Arnold | 251deaa | 2005-05-04 22:30:36 +0000 | [diff] [blame] | 515 | /* helper function to set n (<=32) bits to an arbitrary position, |
| 516 | * counting from LSB to MSB */ |
Jörg Hohensohn | 44171b9 | 2004-06-18 20:41:59 +0000 | [diff] [blame] | 517 | static void set_bits( |
| 518 | unsigned long* p, /* the start of the bitfield array */ |
| 519 | unsigned int from, /* bit no. to start writing into */ |
| 520 | unsigned int size, /* how many bits to change */ |
| 521 | unsigned long value) /* content (LSBs will be taken) */ |
| 522 | { |
Jens Arnold | 251deaa | 2005-05-04 22:30:36 +0000 | [diff] [blame] | 523 | unsigned int long_index = from / 32; |
| 524 | unsigned int bit_index = from % 32; |
Jörg Hohensohn | 44171b9 | 2004-06-18 20:41:59 +0000 | [diff] [blame] | 525 | unsigned long mask; |
| 526 | |
Jens Arnold | 251deaa | 2005-05-04 22:30:36 +0000 | [diff] [blame] | 527 | mask = 0xFFFFFFFF >> (32 - size); |
| 528 | value &= mask; |
| 529 | mask <<= bit_index; |
Jörg Hohensohn | 44171b9 | 2004-06-18 20:41:59 +0000 | [diff] [blame] | 530 | |
Jens Arnold | 251deaa | 2005-05-04 22:30:36 +0000 | [diff] [blame] | 531 | if (bit_index + size > 32) |
Kevin Ferrare | cbbdc95 | 2005-11-04 07:18:36 +0000 | [diff] [blame] | 532 | p[long_index+1] = |
Jens Arnold | 251deaa | 2005-05-04 22:30:36 +0000 | [diff] [blame] | 533 | (p[long_index+1] & (0xFFFFFFFF << (bit_index + size - 32))) |
| 534 | | (value >> (32 - bit_index)); |
Jörg Hohensohn | 44171b9 | 2004-06-18 20:41:59 +0000 | [diff] [blame] | 535 | |
Jens Arnold | 251deaa | 2005-05-04 22:30:36 +0000 | [diff] [blame] | 536 | p[long_index] = (p[long_index] & ~mask) | (value << bit_index); |
Jörg Hohensohn | 44171b9 | 2004-06-18 20:41:59 +0000 | [diff] [blame] | 537 | } |
Björn Stenberg | 6b25f79 | 2002-07-15 11:02:12 +0000 | [diff] [blame] | 538 | |
Björn Stenberg | f80d8a70 | 2002-06-27 00:20:00 +0000 | [diff] [blame] | 539 | /* |
Björn Stenberg | 6224cdb | 2002-08-16 14:41:47 +0000 | [diff] [blame] | 540 | * Calculates the checksum for the config block and returns it |
Björn Stenberg | f80d8a70 | 2002-06-27 00:20:00 +0000 | [diff] [blame] | 541 | */ |
Björn Stenberg | 6b25f79 | 2002-07-15 11:02:12 +0000 | [diff] [blame] | 542 | |
Jens Arnold | 8fb3361 | 2004-08-18 01:09:31 +0000 | [diff] [blame] | 543 | static unsigned short calculate_config_checksum(const unsigned char* buf) |
Björn Stenberg | f80d8a70 | 2002-06-27 00:20:00 +0000 | [diff] [blame] | 544 | { |
Björn Stenberg | cd7691d | 2002-08-13 17:16:09 +0000 | [diff] [blame] | 545 | unsigned int i; |
| 546 | unsigned char cksum[2]; |
Björn Stenberg | 6b25f79 | 2002-07-15 11:02:12 +0000 | [diff] [blame] | 547 | cksum[0] = cksum[1] = 0; |
Kevin Ferrare | cbbdc95 | 2005-11-04 07:18:36 +0000 | [diff] [blame] | 548 | |
Björn Stenberg | 6224cdb | 2002-08-16 14:41:47 +0000 | [diff] [blame] | 549 | for (i=0; i < RTC_BLOCK_SIZE - 2; i+=2 ) { |
| 550 | cksum[0] ^= buf[i]; |
| 551 | cksum[1] ^= buf[i+1]; |
Björn Stenberg | 6b25f79 | 2002-07-15 11:02:12 +0000 | [diff] [blame] | 552 | } |
Björn Stenberg | cd7691d | 2002-08-13 17:16:09 +0000 | [diff] [blame] | 553 | |
| 554 | return (cksum[0] << 8) | cksum[1]; |
Björn Stenberg | 6b25f79 | 2002-07-15 11:02:12 +0000 | [diff] [blame] | 555 | } |
| 556 | |
| 557 | /* |
| 558 | * initialize the config block buffer |
| 559 | */ |
| 560 | static void init_config_buffer( void ) |
| 561 | { |
| 562 | DEBUGF( "init_config_buffer()\n" ); |
Kevin Ferrare | cbbdc95 | 2005-11-04 07:18:36 +0000 | [diff] [blame] | 563 | |
Jörg Hohensohn | 6ff6d21 | 2004-06-19 15:50:02 +0000 | [diff] [blame] | 564 | /* reset to 0 - all unused */ |
| 565 | memset(config_block, 0, CONFIG_BLOCK_SIZE); |
Björn Stenberg | 6b25f79 | 2002-07-15 11:02:12 +0000 | [diff] [blame] | 566 | /* insert header */ |
Björn Stenberg | 6224cdb | 2002-08-16 14:41:47 +0000 | [diff] [blame] | 567 | config_block[0] = 'R'; |
| 568 | config_block[1] = 'o'; |
| 569 | config_block[2] = 'c'; |
| 570 | config_block[3] = CONFIG_BLOCK_VERSION; |
Björn Stenberg | 6b25f79 | 2002-07-15 11:02:12 +0000 | [diff] [blame] | 571 | } |
| 572 | |
| 573 | /* |
Björn Stenberg | cd7691d | 2002-08-13 17:16:09 +0000 | [diff] [blame] | 574 | * save the config block buffer to disk or RTC RAM |
Björn Stenberg | 6b25f79 | 2002-07-15 11:02:12 +0000 | [diff] [blame] | 575 | */ |
| 576 | static int save_config_buffer( void ) |
| 577 | { |
Björn Stenberg | cd7691d | 2002-08-13 17:16:09 +0000 | [diff] [blame] | 578 | unsigned short chksum; |
Dave Chapman | 5009c9c | 2005-12-04 13:05:56 +0000 | [diff] [blame] | 579 | #ifdef HAVE_RTC_RAM |
Björn Stenberg | cd7691d | 2002-08-13 17:16:09 +0000 | [diff] [blame] | 580 | unsigned int i; |
Björn Stenberg | cd7691d | 2002-08-13 17:16:09 +0000 | [diff] [blame] | 581 | #endif |
| 582 | |
Björn Stenberg | 6b25f79 | 2002-07-15 11:02:12 +0000 | [diff] [blame] | 583 | /* update the checksum in the end of the block before saving */ |
Björn Stenberg | 6224cdb | 2002-08-16 14:41:47 +0000 | [diff] [blame] | 584 | chksum = calculate_config_checksum(config_block); |
| 585 | config_block[ RTC_BLOCK_SIZE - 2 ] = chksum >> 8; |
| 586 | config_block[ RTC_BLOCK_SIZE - 1 ] = chksum & 0xff; |
Björn Stenberg | cd7691d | 2002-08-13 17:16:09 +0000 | [diff] [blame] | 587 | |
Dave Chapman | 5009c9c | 2005-12-04 13:05:56 +0000 | [diff] [blame] | 588 | #ifdef HAVE_RTC_RAM |
Björn Stenberg | 6b25f79 | 2002-07-15 11:02:12 +0000 | [diff] [blame] | 589 | /* FIXME: okay, it _would_ be cleaner and faster to implement rtc_write so |
| 590 | that it would write a number of bytes at a time since the RTC chip |
| 591 | supports that, but this will have to do for now 8-) */ |
Björn Stenberg | 6224cdb | 2002-08-16 14:41:47 +0000 | [diff] [blame] | 592 | for (i=0; i < RTC_BLOCK_SIZE; i++ ) { |
| 593 | int r = rtc_write(0x14+i, config_block[i]); |
Björn Stenberg | 6b25f79 | 2002-07-15 11:02:12 +0000 | [diff] [blame] | 594 | if (r) { |
Robert Hak | 36dc9c1 | 2002-10-14 09:11:59 +0000 | [diff] [blame] | 595 | DEBUGF( "save_config_buffer: rtc_write failed at addr 0x%02x: %d\n", |
| 596 | 14+i, r ); |
Björn Stenberg | 6b25f79 | 2002-07-15 11:02:12 +0000 | [diff] [blame] | 597 | return r; |
| 598 | } |
Björn Stenberg | 6b25f79 | 2002-07-15 11:02:12 +0000 | [diff] [blame] | 599 | } |
Björn Stenberg | 6b25f79 | 2002-07-15 11:02:12 +0000 | [diff] [blame] | 600 | |
Björn Stenberg | 6224cdb | 2002-08-16 14:41:47 +0000 | [diff] [blame] | 601 | #endif |
Björn Stenberg | 6b25f79 | 2002-07-15 11:02:12 +0000 | [diff] [blame] | 602 | |
Jens Arnold | c12e87d | 2004-09-28 18:09:10 +0000 | [diff] [blame] | 603 | if (config_sector != 0) |
| 604 | ata_delayed_write( config_sector, config_block); |
Linus Nielsen Feltzing | d0abfe8 | 2002-07-28 16:09:44 +0000 | [diff] [blame] | 605 | else |
| 606 | return -1; |
Björn Stenberg | cd7691d | 2002-08-13 17:16:09 +0000 | [diff] [blame] | 607 | |
Björn Stenberg | cd7691d | 2002-08-13 17:16:09 +0000 | [diff] [blame] | 608 | return 0; |
Linus Nielsen Feltzing | d0abfe8 | 2002-07-28 16:09:44 +0000 | [diff] [blame] | 609 | } |
| 610 | |
| 611 | /* |
Björn Stenberg | cd7691d | 2002-08-13 17:16:09 +0000 | [diff] [blame] | 612 | * load the config block buffer from disk or RTC RAM |
Linus Nielsen Feltzing | d0abfe8 | 2002-07-28 16:09:44 +0000 | [diff] [blame] | 613 | */ |
Jörg Hohensohn | 6ff6d21 | 2004-06-19 15:50:02 +0000 | [diff] [blame] | 614 | static int load_config_buffer(int which) |
Linus Nielsen Feltzing | d0abfe8 | 2002-07-28 16:09:44 +0000 | [diff] [blame] | 615 | { |
Björn Stenberg | cd7691d | 2002-08-13 17:16:09 +0000 | [diff] [blame] | 616 | unsigned short chksum; |
Björn Stenberg | 6224cdb | 2002-08-16 14:41:47 +0000 | [diff] [blame] | 617 | bool correct = false; |
Björn Stenberg | cd7691d | 2002-08-13 17:16:09 +0000 | [diff] [blame] | 618 | |
Kevin Ferrare | cbbdc95 | 2005-11-04 07:18:36 +0000 | [diff] [blame] | 619 | |
Linus Nielsen Feltzing | d0abfe8 | 2002-07-28 16:09:44 +0000 | [diff] [blame] | 620 | DEBUGF( "load_config_buffer()\n" ); |
Linus Nielsen Feltzing | d0abfe8 | 2002-07-28 16:09:44 +0000 | [diff] [blame] | 621 | |
Jörg Hohensohn | 6ff6d21 | 2004-06-19 15:50:02 +0000 | [diff] [blame] | 622 | if (which & SETTINGS_HD) |
| 623 | { |
Jens Arnold | c12e87d | 2004-09-28 18:09:10 +0000 | [diff] [blame] | 624 | if (config_sector != 0) { |
Jörg Hohensohn | da84857 | 2004-12-28 22:16:07 +0000 | [diff] [blame] | 625 | ata_read_sectors(IF_MV2(0,) config_sector, 1, config_block); |
Jörg Hohensohn | 6ff6d21 | 2004-06-19 15:50:02 +0000 | [diff] [blame] | 626 | /* calculate the checksum, check it and the header */ |
| 627 | chksum = calculate_config_checksum(config_block); |
Kevin Ferrare | cbbdc95 | 2005-11-04 07:18:36 +0000 | [diff] [blame] | 628 | |
Jörg Hohensohn | 6ff6d21 | 2004-06-19 15:50:02 +0000 | [diff] [blame] | 629 | if (config_block[0] == 'R' && |
| 630 | config_block[1] == 'o' && |
| 631 | config_block[2] == 'c' && |
| 632 | config_block[3] == CONFIG_BLOCK_VERSION && |
| 633 | (chksum >> 8) == config_block[RTC_BLOCK_SIZE - 2] && |
| 634 | (chksum & 0xff) == config_block[RTC_BLOCK_SIZE - 1]) |
| 635 | { |
| 636 | DEBUGF( "load_config_buffer: header & checksum test ok\n" ); |
| 637 | correct = true; |
| 638 | } |
Björn Stenberg | 6224cdb | 2002-08-16 14:41:47 +0000 | [diff] [blame] | 639 | } |
| 640 | } |
| 641 | |
Dave Chapman | 5009c9c | 2005-12-04 13:05:56 +0000 | [diff] [blame] | 642 | #ifdef HAVE_RTC_RAM |
Linus Nielsen Feltzing | e8db003 | 2004-03-13 00:04:58 +0000 | [diff] [blame] | 643 | if(!correct) |
| 644 | { |
| 645 | /* If the disk sector was incorrect, reinit the buffer */ |
Jörg Hohensohn | 6ff6d21 | 2004-06-19 15:50:02 +0000 | [diff] [blame] | 646 | memset(config_block, 0, CONFIG_BLOCK_SIZE); |
Linus Nielsen Feltzing | e8db003 | 2004-03-13 00:04:58 +0000 | [diff] [blame] | 647 | } |
Björn Stenberg | 6224cdb | 2002-08-16 14:41:47 +0000 | [diff] [blame] | 648 | |
Jörg Hohensohn | 6ff6d21 | 2004-06-19 15:50:02 +0000 | [diff] [blame] | 649 | if (which & SETTINGS_RTC) |
Björn Stenberg | 6224cdb | 2002-08-16 14:41:47 +0000 | [diff] [blame] | 650 | { |
Jörg Hohensohn | 6ff6d21 | 2004-06-19 15:50:02 +0000 | [diff] [blame] | 651 | unsigned int i; |
| 652 | unsigned char rtc_block[RTC_BLOCK_SIZE]; |
| 653 | |
| 654 | /* read rtc block */ |
| 655 | for (i=0; i < RTC_BLOCK_SIZE; i++ ) |
| 656 | rtc_block[i] = rtc_read(0x14+i); |
| 657 | |
| 658 | chksum = calculate_config_checksum(rtc_block); |
Kevin Ferrare | cbbdc95 | 2005-11-04 07:18:36 +0000 | [diff] [blame] | 659 | |
Jörg Hohensohn | 6ff6d21 | 2004-06-19 15:50:02 +0000 | [diff] [blame] | 660 | /* if rtc block is ok, use that */ |
| 661 | if (rtc_block[0] == 'R' && |
| 662 | rtc_block[1] == 'o' && |
| 663 | rtc_block[2] == 'c' && |
| 664 | rtc_block[3] == CONFIG_BLOCK_VERSION && |
| 665 | (chksum >> 8) == rtc_block[RTC_BLOCK_SIZE - 2] && |
| 666 | (chksum & 0xff) == rtc_block[RTC_BLOCK_SIZE - 1]) |
| 667 | { |
| 668 | memcpy(config_block, rtc_block, RTC_BLOCK_SIZE); |
| 669 | correct = true; |
| 670 | } |
Björn Stenberg | 6224cdb | 2002-08-16 14:41:47 +0000 | [diff] [blame] | 671 | } |
Linus Nielsen Feltzing | d0abfe8 | 2002-07-28 16:09:44 +0000 | [diff] [blame] | 672 | #endif |
Kevin Ferrare | cbbdc95 | 2005-11-04 07:18:36 +0000 | [diff] [blame] | 673 | |
Björn Stenberg | 6224cdb | 2002-08-16 14:41:47 +0000 | [diff] [blame] | 674 | if ( !correct ) { |
| 675 | /* if checksum is not valid, clear the config buffer */ |
| 676 | DEBUGF( "load_config_buffer: header & checksum test failed\n" ); |
| 677 | init_config_buffer(); |
| 678 | return -1; |
Björn Stenberg | cd7691d | 2002-08-13 17:16:09 +0000 | [diff] [blame] | 679 | } |
Björn Stenberg | 6224cdb | 2002-08-16 14:41:47 +0000 | [diff] [blame] | 680 | |
| 681 | return 0; |
Linus Nielsen Feltzing | d0abfe8 | 2002-07-28 16:09:44 +0000 | [diff] [blame] | 682 | } |
| 683 | |
Jörg Hohensohn | 44171b9 | 2004-06-18 20:41:59 +0000 | [diff] [blame] | 684 | |
| 685 | /* helper to save content of global_settings into a bitfield, |
Kevin Ferrare | cbbdc95 | 2005-11-04 07:18:36 +0000 | [diff] [blame] | 686 | as described per table */ |
Jörg Hohensohn | 44171b9 | 2004-06-18 20:41:59 +0000 | [diff] [blame] | 687 | static void save_bit_table(const struct bit_entry* p_table, int count, int bitstart) |
| 688 | { |
| 689 | unsigned long* p_bitfield = (unsigned long*)config_block; /* 32 bit addr. */ |
| 690 | unsigned long value; /* 32 bit content */ |
| 691 | int i; |
| 692 | const struct bit_entry* p_run = p_table; /* start after the size info */ |
| 693 | int curr_bit = bitstart + p_table->bit_size; |
| 694 | count--; /* first is excluded from loop */ |
| 695 | |
| 696 | for (i=0; i<count; i++) |
| 697 | { |
| 698 | p_run++; |
| 699 | /* could do a memcpy, but that would be endian-dependent */ |
| 700 | switch(p_run->byte_size) |
| 701 | { |
| 702 | case 1: |
| 703 | value = ((unsigned char*)&global_settings)[p_run->settings_offset]; |
| 704 | break; |
| 705 | case 2: |
| 706 | value = ((unsigned short*)&global_settings)[p_run->settings_offset/2]; |
| 707 | break; |
| 708 | case 4: |
| 709 | value = ((unsigned int*)&global_settings)[p_run->settings_offset/4]; |
| 710 | break; |
| 711 | default: |
| 712 | DEBUGF( "illegal size!" ); |
| 713 | continue; |
| 714 | } |
| 715 | set_bits(p_bitfield, curr_bit, p_run->bit_size & 0x3F, value); |
| 716 | curr_bit += p_run->bit_size & 0x3F; |
| 717 | } |
| 718 | set_bits(p_bitfield, bitstart, p_table->bit_size, /* write size */ |
| 719 | curr_bit); /* = position after last element */ |
| 720 | } |
| 721 | |
Jens Arnold | c12e87d | 2004-09-28 18:09:10 +0000 | [diff] [blame] | 722 | /* |
| 723 | * figure out the config sector from the partition table and the |
Kevin Ferrare | cbbdc95 | 2005-11-04 07:18:36 +0000 | [diff] [blame] | 724 | * mounted file system |
Jens Arnold | c12e87d | 2004-09-28 18:09:10 +0000 | [diff] [blame] | 725 | */ |
| 726 | void settings_calc_config_sector(void) |
| 727 | { |
| 728 | #ifdef SIMULATOR |
| 729 | config_sector = 61; |
| 730 | #else |
Jean-Philippe Bernardy | 2860c5e | 2005-02-11 18:41:40 +0000 | [diff] [blame] | 731 | int i; |
| 732 | long partition_start; |
| 733 | long sector = 0; |
Jens Arnold | c12e87d | 2004-09-28 18:09:10 +0000 | [diff] [blame] | 734 | |
Jörg Hohensohn | da84857 | 2004-12-28 22:16:07 +0000 | [diff] [blame] | 735 | if (fat_startsector(IF_MV(0)) != 0) /* There is a partition table */ |
Jens Arnold | c12e87d | 2004-09-28 18:09:10 +0000 | [diff] [blame] | 736 | { |
| 737 | sector = 61; |
| 738 | for (i = 0; i < 4; i++) |
| 739 | { |
| 740 | partition_start = disk_partinfo(i)->start; |
| 741 | if (partition_start != 0 && (partition_start - 2) < sector) |
| 742 | sector = partition_start - 2; |
| 743 | } |
| 744 | if (sector < 0) |
| 745 | sector = 0; |
| 746 | } |
Kevin Ferrare | cbbdc95 | 2005-11-04 07:18:36 +0000 | [diff] [blame] | 747 | |
Jens Arnold | c12e87d | 2004-09-28 18:09:10 +0000 | [diff] [blame] | 748 | config_sector = sector; |
| 749 | #endif |
| 750 | } |
Jörg Hohensohn | 44171b9 | 2004-06-18 20:41:59 +0000 | [diff] [blame] | 751 | |
Björn Stenberg | 6b25f79 | 2002-07-15 11:02:12 +0000 | [diff] [blame] | 752 | /* |
| 753 | * persist all runtime user settings to disk or RTC RAM |
| 754 | */ |
| 755 | int settings_save( void ) |
| 756 | { |
Björn Stenberg | ae22de2 | 2002-12-02 16:07:56 +0000 | [diff] [blame] | 757 | { |
Björn Stenberg | 745eed6 | 2003-07-04 08:20:30 +0000 | [diff] [blame] | 758 | int elapsed_secs; |
Björn Stenberg | ae22de2 | 2002-12-02 16:07:56 +0000 | [diff] [blame] | 759 | |
Björn Stenberg | 745eed6 | 2003-07-04 08:20:30 +0000 | [diff] [blame] | 760 | elapsed_secs = (current_tick - lasttime) / HZ; |
| 761 | global_settings.runtime += elapsed_secs; |
| 762 | lasttime += (elapsed_secs * HZ); |
Björn Stenberg | 34351e8 | 2002-12-04 11:25:56 +0000 | [diff] [blame] | 763 | |
Björn Stenberg | ae22de2 | 2002-12-02 16:07:56 +0000 | [diff] [blame] | 764 | if ( global_settings.runtime > global_settings.topruntime ) |
| 765 | global_settings.topruntime = global_settings.runtime; |
Björn Stenberg | ae22de2 | 2002-12-02 16:07:56 +0000 | [diff] [blame] | 766 | } |
Björn Stenberg | c78e1b0 | 2003-01-09 00:55:00 +0000 | [diff] [blame] | 767 | |
Jörg Hohensohn | 44171b9 | 2004-06-18 20:41:59 +0000 | [diff] [blame] | 768 | /* serialize scalar values into RTC and HD sector, specified via table */ |
| 769 | save_bit_table(rtc_bits, sizeof(rtc_bits)/sizeof(rtc_bits[0]), 4*8); |
| 770 | save_bit_table(hd_bits, sizeof(hd_bits)/sizeof(hd_bits[0]), RTC_BLOCK_SIZE*8); |
Björn Stenberg | a2e98c1 | 2002-12-12 15:20:37 +0000 | [diff] [blame] | 771 | |
Daniel Stenberg | f981ea9 | 2005-12-05 22:44:42 +0000 | [diff] [blame] | 772 | strncpy((char *)&config_block[0xb8], (char *)global_settings.wps_file, |
| 773 | MAX_FILENAME); |
| 774 | strncpy((char *)&config_block[0xcc], (char *)global_settings.lang_file, |
| 775 | MAX_FILENAME); |
| 776 | strncpy((char *)&config_block[0xe0], (char *)global_settings.font_file, |
| 777 | MAX_FILENAME); |
Christi Scarborough | 4c0b83f | 2005-11-17 20:14:59 +0000 | [diff] [blame] | 778 | #ifdef HAVE_REMOTE_LCD |
Daniel Stenberg | f981ea9 | 2005-12-05 22:44:42 +0000 | [diff] [blame] | 779 | strncpy((char *)&config_block[0xf4], (char *)global_settings.rwps_file, |
| 780 | MAX_FILENAME); |
Christi Scarborough | 4c0b83f | 2005-11-17 20:14:59 +0000 | [diff] [blame] | 781 | #endif |
Björn Stenberg | 6224cdb | 2002-08-16 14:41:47 +0000 | [diff] [blame] | 782 | |
Linus Nielsen Feltzing | d0abfe8 | 2002-07-28 16:09:44 +0000 | [diff] [blame] | 783 | if(save_config_buffer()) |
| 784 | { |
| 785 | lcd_clear_display(); |
Christi Scarborough | 4c0b83f | 2005-11-17 20:14:59 +0000 | [diff] [blame] | 786 | #ifdef HAVE_REMOTE_LCD |
| 787 | lcd_remote_clear_display(); |
| 788 | #endif |
Linus Nielsen Feltzing | d0abfe8 | 2002-07-28 16:09:44 +0000 | [diff] [blame] | 789 | #ifdef HAVE_LCD_CHARCELLS |
Björn Stenberg | 505eca7 | 2002-09-18 14:08:05 +0000 | [diff] [blame] | 790 | lcd_puts(0, 0, str(LANG_SETTINGS_SAVE_PLAYER)); |
| 791 | lcd_puts(0, 1, str(LANG_SETTINGS_BATTERY_PLAYER)); |
Linus Nielsen Feltzing | d0abfe8 | 2002-07-28 16:09:44 +0000 | [diff] [blame] | 792 | #else |
Björn Stenberg | 505eca7 | 2002-09-18 14:08:05 +0000 | [diff] [blame] | 793 | lcd_puts(4, 2, str(LANG_SETTINGS_SAVE_RECORDER)); |
| 794 | lcd_puts(2, 4, str(LANG_SETTINGS_BATTERY_RECORDER)); |
Linus Nielsen Feltzing | d0abfe8 | 2002-07-28 16:09:44 +0000 | [diff] [blame] | 795 | lcd_update(); |
Christi Scarborough | 4c0b83f | 2005-11-17 20:14:59 +0000 | [diff] [blame] | 796 | #ifdef HAVE_REMOTE_LCD |
| 797 | lcd_remote_puts(4, 2, str(LANG_SETTINGS_SAVE_RECORDER)); |
| 798 | lcd_remote_puts(2, 4, str(LANG_SETTINGS_BATTERY_RECORDER)); |
| 799 | lcd_remote_update(); |
| 800 | #endif |
Linus Nielsen Feltzing | d0abfe8 | 2002-07-28 16:09:44 +0000 | [diff] [blame] | 801 | #endif |
| 802 | sleep(HZ*2); |
| 803 | return -1; |
| 804 | } |
| 805 | return 0; |
Björn Stenberg | f80d8a70 | 2002-06-27 00:20:00 +0000 | [diff] [blame] | 806 | } |
| 807 | |
Linus Nielsen Feltzing | fd0cc3b | 2002-10-29 12:09:15 +0000 | [diff] [blame] | 808 | #ifdef HAVE_LCD_BITMAP |
| 809 | /** |
Kevin Ferrare | cbbdc95 | 2005-11-04 07:18:36 +0000 | [diff] [blame] | 810 | * Applies the range infos stored in global_settings to |
| 811 | * the peak meter. |
Linus Nielsen Feltzing | fd0cc3b | 2002-10-29 12:09:15 +0000 | [diff] [blame] | 812 | */ |
| 813 | void settings_apply_pm_range(void) |
| 814 | { |
| 815 | int pm_min, pm_max; |
| 816 | |
| 817 | /* depending on the scale mode (dBfs or percent) the values |
| 818 | of global_settings.peak_meter_dbfs have different meanings */ |
Kevin Ferrare | cbbdc95 | 2005-11-04 07:18:36 +0000 | [diff] [blame] | 819 | if (global_settings.peak_meter_dbfs) |
Linus Nielsen Feltzing | fd0cc3b | 2002-10-29 12:09:15 +0000 | [diff] [blame] | 820 | { |
| 821 | /* convert to dBfs * 100 */ |
| 822 | pm_min = -(((int)global_settings.peak_meter_min) * 100); |
| 823 | pm_max = -(((int)global_settings.peak_meter_max) * 100); |
| 824 | } |
Kevin Ferrare | cbbdc95 | 2005-11-04 07:18:36 +0000 | [diff] [blame] | 825 | else |
Linus Nielsen Feltzing | fd0cc3b | 2002-10-29 12:09:15 +0000 | [diff] [blame] | 826 | { |
| 827 | /* percent is stored directly -> no conversion */ |
| 828 | pm_min = global_settings.peak_meter_min; |
| 829 | pm_max = global_settings.peak_meter_max; |
| 830 | } |
| 831 | |
| 832 | /* apply the range */ |
| 833 | peak_meter_init_range(global_settings.peak_meter_dbfs, pm_min, pm_max); |
| 834 | } |
| 835 | #endif /* HAVE_LCD_BITMAP */ |
| 836 | |
Linus Nielsen Feltzing | 7bade1a | 2004-07-06 12:17:14 +0000 | [diff] [blame] | 837 | void sound_settings_apply(void) |
Linus Nielsen Feltzing | 40ffbb1 | 2002-10-03 09:31:01 +0000 | [diff] [blame] | 838 | { |
Linus Nielsen Feltzing | 674eaca | 2005-04-01 13:41:03 +0000 | [diff] [blame] | 839 | sound_set(SOUND_BASS, global_settings.bass); |
| 840 | sound_set(SOUND_TREBLE, global_settings.treble); |
| 841 | sound_set(SOUND_BALANCE, global_settings.balance); |
| 842 | sound_set(SOUND_VOLUME, global_settings.volume); |
| 843 | sound_set(SOUND_CHANNELS, global_settings.channel_config); |
| 844 | sound_set(SOUND_STEREO_WIDTH, global_settings.stereo_width); |
Anton Oleynikov | 2654d91 | 2005-12-04 14:33:10 +0000 | [diff] [blame] | 845 | #ifdef HAVE_UDA1380 |
| 846 | sound_set(SOUND_SCALING, global_settings.sound_scaling); |
| 847 | #endif |
Jens Arnold | d6c0545 | 2005-08-29 21:15:27 +0000 | [diff] [blame] | 848 | #if (CONFIG_CODEC == MAS3587F) || (CONFIG_CODEC == MAS3539F) |
Linus Nielsen Feltzing | 674eaca | 2005-04-01 13:41:03 +0000 | [diff] [blame] | 849 | sound_set(SOUND_LOUDNESS, global_settings.loudness); |
| 850 | sound_set(SOUND_AVC, global_settings.avc); |
| 851 | sound_set(SOUND_MDB_STRENGTH, global_settings.mdb_strength); |
| 852 | sound_set(SOUND_MDB_HARMONICS, global_settings.mdb_harmonics); |
| 853 | sound_set(SOUND_MDB_CENTER, global_settings.mdb_center); |
| 854 | sound_set(SOUND_MDB_SHAPE, global_settings.mdb_shape); |
| 855 | sound_set(SOUND_MDB_ENABLE, global_settings.mdb_enable); |
| 856 | sound_set(SOUND_SUPERBASS, global_settings.superbass); |
Linus Nielsen Feltzing | 40ffbb1 | 2002-10-03 09:31:01 +0000 | [diff] [blame] | 857 | #endif |
Linus Nielsen Feltzing | 7bade1a | 2004-07-06 12:17:14 +0000 | [diff] [blame] | 858 | } |
| 859 | |
| 860 | void settings_apply(void) |
| 861 | { |
| 862 | char buf[64]; |
| 863 | |
| 864 | sound_settings_apply(); |
Linus Nielsen Feltzing | 40ffbb1 | 2002-10-03 09:31:01 +0000 | [diff] [blame] | 865 | |
Linus Nielsen Feltzing | 8a237a8 | 2005-04-04 12:06:29 +0000 | [diff] [blame] | 866 | audio_set_buffer_margin(global_settings.buffer_margin); |
Kevin Ferrare | cbbdc95 | 2005-11-04 07:18:36 +0000 | [diff] [blame] | 867 | |
Linus Nielsen Feltzing | 40ffbb1 | 2002-10-03 09:31:01 +0000 | [diff] [blame] | 868 | lcd_set_contrast(global_settings.contrast); |
| 869 | lcd_scroll_speed(global_settings.scroll_speed); |
Christian Gmeiner | 7c1879b | 2005-04-15 12:08:49 +0000 | [diff] [blame] | 870 | #ifdef HAVE_REMOTE_LCD |
Jens Arnold | bd1bb5f | 2005-06-17 21:43:00 +0000 | [diff] [blame] | 871 | lcd_remote_set_contrast(global_settings.remote_contrast); |
| 872 | lcd_remote_set_invert_display(global_settings.remote_invert); |
| 873 | lcd_remote_set_flip(global_settings.remote_flip_display); |
Linus Nielsen Feltzing | 062a0b3 | 2005-11-20 09:54:57 +0000 | [diff] [blame] | 874 | lcd_remote_scroll_speed(global_settings.scroll_speed); |
| 875 | lcd_remote_scroll_step(global_settings.scroll_step); |
Anton Oleynikov | 6707892 | 2005-11-20 11:15:32 +0000 | [diff] [blame] | 876 | lcd_remote_scroll_delay(global_settings.scroll_delay * (HZ/10)); |
Miika Pekkarinen | 93d8ca5 | 2005-11-19 09:26:02 +0000 | [diff] [blame] | 877 | #ifdef HAVE_REMOTE_LCD_TICKING |
Miika Pekkarinen | f9234b3 | 2005-11-19 08:05:03 +0000 | [diff] [blame] | 878 | lcd_remote_emireduce(global_settings.remote_reduce_ticking); |
Miika Pekkarinen | 93d8ca5 | 2005-11-19 09:26:02 +0000 | [diff] [blame] | 879 | #endif |
Christian Gmeiner | 7477c09 | 2005-05-30 00:00:22 +0000 | [diff] [blame] | 880 | remote_backlight_set_timeout(global_settings.remote_backlight_timeout); |
Jens Arnold | a6d409d | 2005-11-23 20:12:33 +0000 | [diff] [blame] | 881 | #ifdef HAVE_CHARGING |
| 882 | remote_backlight_set_timeout_plugged(global_settings.remote_backlight_timeout_plugged); |
| 883 | #endif |
Jens Arnold | bd1bb5f | 2005-06-17 21:43:00 +0000 | [diff] [blame] | 884 | #endif |
Jens Arnold | b51f7df | 2005-11-21 23:55:39 +0000 | [diff] [blame] | 885 | #ifdef CONFIG_BACKLIGHT |
Linus Nielsen Feltzing | 40ffbb1 | 2002-10-03 09:31:01 +0000 | [diff] [blame] | 886 | backlight_set_timeout(global_settings.backlight_timeout); |
Jens Arnold | b51f7df | 2005-11-21 23:55:39 +0000 | [diff] [blame] | 887 | #ifdef HAVE_CHARGING |
Jens Arnold | a6d409d | 2005-11-23 20:12:33 +0000 | [diff] [blame] | 888 | backlight_set_timeout_plugged(global_settings.backlight_timeout_plugged); |
Jens Arnold | b51f7df | 2005-11-21 23:55:39 +0000 | [diff] [blame] | 889 | #endif |
| 890 | #if (CONFIG_BACKLIGHT == BL_IRIVER_H100) && !defined(SIMULATOR) |
Jens Arnold | 61b9d34 | 2005-06-20 17:03:09 +0000 | [diff] [blame] | 891 | backlight_set_fade_in(global_settings.backlight_fade_in); |
| 892 | backlight_set_fade_out(global_settings.backlight_fade_out); |
| 893 | #endif |
Jens Arnold | b51f7df | 2005-11-21 23:55:39 +0000 | [diff] [blame] | 894 | #endif |
Linus Nielsen Feltzing | 40ffbb1 | 2002-10-03 09:31:01 +0000 | [diff] [blame] | 895 | ata_spindown(global_settings.disk_spindown); |
Jens Arnold | 8051a0b | 2005-11-06 23:12:11 +0000 | [diff] [blame] | 896 | #if (CONFIG_CODEC == MAS3507D) && !defined(SIMULATOR) |
Linus Nielsen Feltzing | c22b411 | 2003-11-03 23:36:36 +0000 | [diff] [blame] | 897 | dac_line_in(global_settings.line_in); |
| 898 | #endif |
Jens Arnold | 61a2550 | 2005-09-11 12:07:13 +0000 | [diff] [blame] | 899 | mpeg_id3_options(global_settings.id3_v1_first); |
Björn Stenberg | f1a6855 | 2003-02-12 09:02:55 +0000 | [diff] [blame] | 900 | #ifdef HAVE_ATA_POWER_OFF |
Björn Stenberg | 3d4cc9b | 2002-11-29 13:57:00 +0000 | [diff] [blame] | 901 | ata_poweroff(global_settings.disk_poweroff); |
Robert Hak | 0789d42 | 2002-11-30 09:42:13 +0000 | [diff] [blame] | 902 | #endif |
| 903 | |
Linus Nielsen Feltzing | 40ffbb1 | 2002-10-03 09:31:01 +0000 | [diff] [blame] | 904 | set_poweroff_timeout(global_settings.poweroff); |
Björn Stenberg | dea3122 | 2002-10-08 15:42:40 +0000 | [diff] [blame] | 905 | |
Uwe Freese | 0bf70e6 | 2002-12-16 22:58:48 +0000 | [diff] [blame] | 906 | set_battery_capacity(global_settings.battery_capacity); |
Jens Arnold | 91846a1 | 2005-01-30 16:25:46 +0000 | [diff] [blame] | 907 | #if BATTERY_TYPES_COUNT > 1 |
| 908 | set_battery_type(global_settings.battery_type); |
| 909 | #endif |
Uwe Freese | 0bf70e6 | 2002-12-16 22:58:48 +0000 | [diff] [blame] | 910 | |
Linus Nielsen Feltzing | fd0cc3b | 2002-10-29 12:09:15 +0000 | [diff] [blame] | 911 | #ifdef HAVE_LCD_BITMAP |
Björn Stenberg | b107920 | 2003-02-27 14:22:30 +0000 | [diff] [blame] | 912 | lcd_set_invert_display(global_settings.invert); |
Jörg Hohensohn | a5e1d06 | 2003-12-20 10:00:37 +0000 | [diff] [blame] | 913 | lcd_set_flip(global_settings.flip_display); |
| 914 | button_set_flip(global_settings.flip_display); |
| 915 | lcd_update(); /* refresh after flipping the screen */ |
Linus Nielsen Feltzing | fd0cc3b | 2002-10-29 12:09:15 +0000 | [diff] [blame] | 916 | settings_apply_pm_range(); |
| 917 | peak_meter_init_times( |
Kevin Ferrare | cbbdc95 | 2005-11-04 07:18:36 +0000 | [diff] [blame] | 918 | global_settings.peak_meter_release, global_settings.peak_meter_hold, |
Linus Nielsen Feltzing | fd0cc3b | 2002-10-29 12:09:15 +0000 | [diff] [blame] | 919 | global_settings.peak_meter_clip_hold); |
| 920 | #endif |
| 921 | |
Kevin Ferrare | cbbdc95 | 2005-11-04 07:18:36 +0000 | [diff] [blame] | 922 | if ( global_settings.wps_file[0] && |
Björn Stenberg | 746501f | 2002-10-09 08:51:08 +0000 | [diff] [blame] | 923 | global_settings.wps_file[0] != 0xff ) { |
Daniel Stenberg | 0b4576c | 2005-11-12 21:48:06 +0000 | [diff] [blame] | 924 | snprintf(buf, sizeof buf, WPS_DIR "/%s.wps", |
Björn Stenberg | dea3122 | 2002-10-08 15:42:40 +0000 | [diff] [blame] | 925 | global_settings.wps_file); |
Daniel Stenberg | 09fce70 | 2005-11-18 09:03:25 +0000 | [diff] [blame] | 926 | wps_data_load(gui_wps[0].data, buf, true, false); |
Björn Stenberg | dea3122 | 2002-10-08 15:42:40 +0000 | [diff] [blame] | 927 | } |
Björn Stenberg | 227253c | 2002-10-09 23:13:25 +0000 | [diff] [blame] | 928 | else |
Daniel Stenberg | 09fce70 | 2005-11-18 09:03:25 +0000 | [diff] [blame] | 929 | wps_data_init(gui_wps[0].data); |
Christi Scarborough | 4c0b83f | 2005-11-17 20:14:59 +0000 | [diff] [blame] | 930 | |
Magnus Holmgren | f9fa33f | 2005-12-04 12:11:08 +0000 | [diff] [blame] | 931 | #if defined(HAVE_REMOTE_LCD) && (NB_SCREENS > 1) |
Christi Scarborough | 4c0b83f | 2005-11-17 20:14:59 +0000 | [diff] [blame] | 932 | if ( global_settings.rwps_file[0] && |
| 933 | global_settings.rwps_file[0] != 0xff ) { |
| 934 | snprintf(buf, sizeof buf, WPS_DIR "/%s.rwps", |
| 935 | global_settings.rwps_file); |
Daniel Stenberg | 09fce70 | 2005-11-18 09:03:25 +0000 | [diff] [blame] | 936 | wps_data_load(gui_wps[1].data, buf, true, false); |
Christi Scarborough | 4c0b83f | 2005-11-17 20:14:59 +0000 | [diff] [blame] | 937 | } |
| 938 | else |
Daniel Stenberg | 09fce70 | 2005-11-18 09:03:25 +0000 | [diff] [blame] | 939 | wps_data_init(gui_wps[1].data); |
Christi Scarborough | 4c0b83f | 2005-11-17 20:14:59 +0000 | [diff] [blame] | 940 | #endif |
Björn Stenberg | 227253c | 2002-10-09 23:13:25 +0000 | [diff] [blame] | 941 | |
Björn Stenberg | dea3122 | 2002-10-08 15:42:40 +0000 | [diff] [blame] | 942 | #ifdef HAVE_LCD_BITMAP |
Björn Stenberg | 746501f | 2002-10-09 08:51:08 +0000 | [diff] [blame] | 943 | if ( global_settings.font_file[0] && |
| 944 | global_settings.font_file[0] != 0xff ) { |
Daniel Stenberg | 0f68958 | 2004-01-08 12:40:25 +0000 | [diff] [blame] | 945 | snprintf(buf, sizeof buf, ROCKBOX_DIR FONT_DIR "/%s.fnt", |
Björn Stenberg | dea3122 | 2002-10-08 15:42:40 +0000 | [diff] [blame] | 946 | global_settings.font_file); |
| 947 | font_load(buf); |
| 948 | } |
Björn Stenberg | 227253c | 2002-10-09 23:13:25 +0000 | [diff] [blame] | 949 | else |
| 950 | font_reset(); |
Björn Stenberg | a2e98c1 | 2002-12-12 15:20:37 +0000 | [diff] [blame] | 951 | |
Björn Stenberg | a2e98c1 | 2002-12-12 15:20:37 +0000 | [diff] [blame] | 952 | lcd_scroll_step(global_settings.scroll_step); |
Kjell Ericson | 53f156a | 2003-05-22 06:42:14 +0000 | [diff] [blame] | 953 | #else |
| 954 | lcd_jump_scroll(global_settings.jump_scroll); |
Kjell Ericson | 849469a | 2003-05-28 09:00:27 +0000 | [diff] [blame] | 955 | lcd_jump_scroll_delay(global_settings.jump_scroll_delay * (HZ/10)); |
Björn Stenberg | dea3122 | 2002-10-08 15:42:40 +0000 | [diff] [blame] | 956 | #endif |
Björn Stenberg | f0d02aa | 2003-02-12 09:07:48 +0000 | [diff] [blame] | 957 | lcd_bidir_scroll(global_settings.bidir_limit); |
Björn Stenberg | a2e98c1 | 2002-12-12 15:20:37 +0000 | [diff] [blame] | 958 | lcd_scroll_delay(global_settings.scroll_delay * (HZ/10)); |
Björn Stenberg | 227253c | 2002-10-09 23:13:25 +0000 | [diff] [blame] | 959 | |
Björn Stenberg | 746501f | 2002-10-09 08:51:08 +0000 | [diff] [blame] | 960 | if ( global_settings.lang_file[0] && |
| 961 | global_settings.lang_file[0] != 0xff ) { |
Daniel Stenberg | 0f68958 | 2004-01-08 12:40:25 +0000 | [diff] [blame] | 962 | snprintf(buf, sizeof buf, ROCKBOX_DIR LANG_DIR "/%s.lng", |
Björn Stenberg | dea3122 | 2002-10-08 15:42:40 +0000 | [diff] [blame] | 963 | global_settings.lang_file); |
| 964 | lang_load(buf); |
Jörg Hohensohn | 6e77d1f | 2004-04-06 07:06:59 +0000 | [diff] [blame] | 965 | talk_init(); /* use voice of same language */ |
Björn Stenberg | dea3122 | 2002-10-08 15:42:40 +0000 | [diff] [blame] | 966 | } |
Linus Nielsen Feltzing | 6271b2b | 2005-06-09 09:47:00 +0000 | [diff] [blame] | 967 | |
Marcoen Hirschberg | b0fee17 | 2005-12-06 13:27:15 +0000 | [diff] [blame^] | 968 | set_codepage(global_settings.default_codepage); |
| 969 | |
Jens Arnold | d6c0545 | 2005-08-29 21:15:27 +0000 | [diff] [blame] | 970 | #if CONFIG_CODEC == SWCODEC |
Miika Pekkarinen | 90161c9 | 2005-07-22 16:46:27 +0000 | [diff] [blame] | 971 | audio_set_crossfade(global_settings.crossfade); |
Magnus Holmgren | 4b711c2 | 2005-09-24 15:22:48 +0000 | [diff] [blame] | 972 | dsp_set_replaygain(true); |
Marcoen Hirschberg | e13fad3 | 2005-11-14 21:56:56 +0000 | [diff] [blame] | 973 | dsp_set_crossfeed(global_settings.crossfeed); |
Linus Nielsen Feltzing | 6271b2b | 2005-06-09 09:47:00 +0000 | [diff] [blame] | 974 | #endif |
Linus Nielsen Feltzing | 8782bc8 | 2005-07-01 09:42:39 +0000 | [diff] [blame] | 975 | |
| 976 | #ifdef HAVE_SPDIF_POWER |
| 977 | spdif_power_enable(global_settings.spdif_enable); |
| 978 | #endif |
Linus Nielsen Feltzing | 40ffbb1 | 2002-10-03 09:31:01 +0000 | [diff] [blame] | 979 | } |
| 980 | |
Jörg Hohensohn | 44171b9 | 2004-06-18 20:41:59 +0000 | [diff] [blame] | 981 | |
| 982 | /* helper to load global_settings from a bitfield, as described per table */ |
| 983 | static void load_bit_table(const struct bit_entry* p_table, int count, int bitstart) |
| 984 | { |
| 985 | unsigned long* p_bitfield = (unsigned long*)config_block; /* 32 bit addr. */ |
| 986 | unsigned long value; /* 32 bit content */ |
| 987 | int i; |
| 988 | int maxbit; /* how many bits are valid in the saved part */ |
| 989 | const struct bit_entry* p_run = p_table; /* start after the size info */ |
| 990 | count--; /* first is excluded from loop */ |
| 991 | maxbit = get_bits(p_bitfield, bitstart, p_table->bit_size); |
| 992 | bitstart += p_table->bit_size; |
| 993 | |
| 994 | for (i=0; i<count; i++) |
| 995 | { |
| 996 | int size; |
| 997 | p_run++; |
| 998 | |
| 999 | size = p_run->bit_size & 0x3F; /* mask off abused bits */ |
| 1000 | if (bitstart + size > maxbit) |
| 1001 | break; /* exit if this is not valid any more in bitfield */ |
| 1002 | |
| 1003 | value = get_bits(p_bitfield, bitstart, size); |
| 1004 | bitstart += size; |
| 1005 | if (p_run->bit_size & SIGNED) |
| 1006 | { // sign extend the read value |
| 1007 | unsigned long mask = 0xFFFFFFFF << (size - 1); |
| 1008 | if (value & mask) /* true if MSB of value is set */ |
| 1009 | value |= mask; |
| 1010 | } |
| 1011 | |
| 1012 | /* could do a memcpy, but that would be endian-dependent */ |
| 1013 | switch(p_run->byte_size) |
| 1014 | { |
| 1015 | case 1: |
Kevin Ferrare | cbbdc95 | 2005-11-04 07:18:36 +0000 | [diff] [blame] | 1016 | ((unsigned char*)&global_settings)[p_run->settings_offset] = |
Jörg Hohensohn | 44171b9 | 2004-06-18 20:41:59 +0000 | [diff] [blame] | 1017 | (unsigned char)value; |
| 1018 | break; |
| 1019 | case 2: |
Kevin Ferrare | cbbdc95 | 2005-11-04 07:18:36 +0000 | [diff] [blame] | 1020 | ((unsigned short*)&global_settings)[p_run->settings_offset/2] = |
Jörg Hohensohn | 44171b9 | 2004-06-18 20:41:59 +0000 | [diff] [blame] | 1021 | (unsigned short)value; |
| 1022 | break; |
| 1023 | case 4: |
Kevin Ferrare | cbbdc95 | 2005-11-04 07:18:36 +0000 | [diff] [blame] | 1024 | ((unsigned int*)&global_settings)[p_run->settings_offset/4] = |
Jörg Hohensohn | 44171b9 | 2004-06-18 20:41:59 +0000 | [diff] [blame] | 1025 | (unsigned int)value; |
| 1026 | break; |
| 1027 | default: |
| 1028 | DEBUGF( "illegal size!" ); |
| 1029 | continue; |
| 1030 | } |
| 1031 | } |
| 1032 | } |
| 1033 | |
| 1034 | |
Björn Stenberg | f80d8a70 | 2002-06-27 00:20:00 +0000 | [diff] [blame] | 1035 | /* |
Björn Stenberg | 6b25f79 | 2002-07-15 11:02:12 +0000 | [diff] [blame] | 1036 | * load settings from disk or RTC RAM |
Björn Stenberg | f80d8a70 | 2002-06-27 00:20:00 +0000 | [diff] [blame] | 1037 | */ |
Jörg Hohensohn | 6ff6d21 | 2004-06-19 15:50:02 +0000 | [diff] [blame] | 1038 | void settings_load(int which) |
Björn Stenberg | f80d8a70 | 2002-06-27 00:20:00 +0000 | [diff] [blame] | 1039 | { |
Björn Stenberg | f80d8a70 | 2002-06-27 00:20:00 +0000 | [diff] [blame] | 1040 | DEBUGF( "reload_all_settings()\n" ); |
| 1041 | |
Björn Stenberg | 6b25f79 | 2002-07-15 11:02:12 +0000 | [diff] [blame] | 1042 | /* load the buffer from the RTC (resets it to all-unused if the block |
| 1043 | is invalid) and decode the settings which are set in the block */ |
Kevin Ferrare | cbbdc95 | 2005-11-04 07:18:36 +0000 | [diff] [blame] | 1044 | if (!load_config_buffer(which)) |
Jörg Hohensohn | 44171b9 | 2004-06-18 20:41:59 +0000 | [diff] [blame] | 1045 | { |
Jörg Hohensohn | 44171b9 | 2004-06-18 20:41:59 +0000 | [diff] [blame] | 1046 | /* load scalar values from RTC and HD sector, specified via table */ |
Jörg Hohensohn | 6ff6d21 | 2004-06-19 15:50:02 +0000 | [diff] [blame] | 1047 | if (which & SETTINGS_RTC) |
| 1048 | { |
| 1049 | load_bit_table(rtc_bits, sizeof(rtc_bits)/sizeof(rtc_bits[0]), 4*8); |
| 1050 | } |
| 1051 | if (which & SETTINGS_HD) |
| 1052 | { |
Jens Arnold | 05af280 | 2005-07-28 08:36:24 +0000 | [diff] [blame] | 1053 | load_bit_table(hd_bits, sizeof(hd_bits)/sizeof(hd_bits[0]), |
Jörg Hohensohn | 6ff6d21 | 2004-06-19 15:50:02 +0000 | [diff] [blame] | 1054 | RTC_BLOCK_SIZE*8); |
| 1055 | } |
Kevin Ferrare | cbbdc95 | 2005-11-04 07:18:36 +0000 | [diff] [blame] | 1056 | |
Jörg Hohensohn | 44171b9 | 2004-06-18 20:41:59 +0000 | [diff] [blame] | 1057 | if ( global_settings.contrast < MIN_CONTRAST_SETTING ) |
| 1058 | global_settings.contrast = lcd_default_contrast(); |
Linus Nielsen Feltzing | 20d031f | 2003-05-09 16:01:21 +0000 | [diff] [blame] | 1059 | |
Daniel Stenberg | f981ea9 | 2005-12-05 22:44:42 +0000 | [diff] [blame] | 1060 | strncpy((char *)global_settings.wps_file, (char *)&config_block[0xb8], |
| 1061 | MAX_FILENAME); |
| 1062 | strncpy((char *)global_settings.lang_file, (char *)&config_block[0xcc], |
| 1063 | MAX_FILENAME); |
| 1064 | strncpy((char *)global_settings.font_file, (char *)&config_block[0xe0], |
| 1065 | MAX_FILENAME); |
Christi Scarborough | 4c0b83f | 2005-11-17 20:14:59 +0000 | [diff] [blame] | 1066 | #ifdef HAVE_REMOTE_LCD |
Daniel Stenberg | f981ea9 | 2005-12-05 22:44:42 +0000 | [diff] [blame] | 1067 | strncpy((char *)global_settings.rwps_file, (char *)&config_block[0xf4], |
| 1068 | MAX_FILENAME); |
Christi Scarborough | 4c0b83f | 2005-11-17 20:14:59 +0000 | [diff] [blame] | 1069 | #endif |
Jörg Hohensohn | 6ff6d21 | 2004-06-19 15:50:02 +0000 | [diff] [blame] | 1070 | } |
Björn Stenberg | f80d8a70 | 2002-06-27 00:20:00 +0000 | [diff] [blame] | 1071 | } |
| 1072 | |
Björn Stenberg | bda4ec1 | 2003-02-17 09:53:11 +0000 | [diff] [blame] | 1073 | void set_file(char* filename, char* setting, int maxlen) |
| 1074 | { |
| 1075 | char* fptr = strrchr(filename,'/'); |
| 1076 | int len; |
| 1077 | int extlen = 0; |
| 1078 | char* ptr; |
| 1079 | |
| 1080 | if (!fptr) |
| 1081 | return; |
| 1082 | |
| 1083 | *fptr = 0; |
| 1084 | fptr++; |
| 1085 | |
| 1086 | len = strlen(fptr); |
| 1087 | ptr = fptr + len; |
| 1088 | while (*ptr != '.') { |
| 1089 | extlen++; |
| 1090 | ptr--; |
| 1091 | } |
Kevin Ferrare | cbbdc95 | 2005-11-04 07:18:36 +0000 | [diff] [blame] | 1092 | |
Henrik Backe | c8e2791 | 2004-09-05 16:43:31 +0000 | [diff] [blame] | 1093 | if (strncasecmp(ROCKBOX_DIR, filename ,strlen(ROCKBOX_DIR)) || |
Daniel Stenberg | 0f68958 | 2004-01-08 12:40:25 +0000 | [diff] [blame] | 1094 | (len-extlen > maxlen)) |
Björn Stenberg | bda4ec1 | 2003-02-17 09:53:11 +0000 | [diff] [blame] | 1095 | return; |
Kevin Ferrare | cbbdc95 | 2005-11-04 07:18:36 +0000 | [diff] [blame] | 1096 | |
Björn Stenberg | bda4ec1 | 2003-02-17 09:53:11 +0000 | [diff] [blame] | 1097 | strncpy(setting, fptr, len-extlen); |
| 1098 | setting[len-extlen]=0; |
| 1099 | |
| 1100 | settings_save(); |
| 1101 | } |
| 1102 | |
Jörg Hohensohn | 44171b9 | 2004-06-18 20:41:59 +0000 | [diff] [blame] | 1103 | /* helper to sort a .cfg file entry into a global_settings member, |
Kevin Ferrare | cbbdc95 | 2005-11-04 07:18:36 +0000 | [diff] [blame] | 1104 | as described per table. Returns the position if found, else 0. */ |
Jörg Hohensohn | 44171b9 | 2004-06-18 20:41:59 +0000 | [diff] [blame] | 1105 | static int load_cfg_table( |
| 1106 | const struct bit_entry* p_table, /* the table which describes the entries */ |
| 1107 | int count, /* number of entries in the table, including the first */ |
Jens Arnold | 8fb3361 | 2004-08-18 01:09:31 +0000 | [diff] [blame] | 1108 | const char* name, /* the item to be searched */ |
| 1109 | const char* value, /* the value which got loaded for that item */ |
Jörg Hohensohn | 44171b9 | 2004-06-18 20:41:59 +0000 | [diff] [blame] | 1110 | int hint) /* position to start looking */ |
Björn Stenberg | 0e6088f | 2002-10-02 16:33:26 +0000 | [diff] [blame] | 1111 | { |
Jörg Hohensohn | 44171b9 | 2004-06-18 20:41:59 +0000 | [diff] [blame] | 1112 | int i = hint; |
Björn Stenberg | 0e6088f | 2002-10-02 16:33:26 +0000 | [diff] [blame] | 1113 | |
Jörg Hohensohn | 44171b9 | 2004-06-18 20:41:59 +0000 | [diff] [blame] | 1114 | do |
Björn Stenberg | 0e6088f | 2002-10-02 16:33:26 +0000 | [diff] [blame] | 1115 | { |
Jörg Hohensohn | 44171b9 | 2004-06-18 20:41:59 +0000 | [diff] [blame] | 1116 | if (p_table[i].cfg_name != NULL && !strcasecmp(name, p_table[i].cfg_name)) |
| 1117 | { /* found */ |
| 1118 | int val = 0; |
| 1119 | if (p_table[i].cfg_val == NULL) |
| 1120 | { /* numerical value, just convert the string */ |
| 1121 | val = atoi(value); |
| 1122 | } |
| 1123 | else |
| 1124 | { /* set of string values, find the index */ |
| 1125 | const char* item; |
| 1126 | const char* run; |
| 1127 | int len = strlen(value); |
Kevin Ferrare | cbbdc95 | 2005-11-04 07:18:36 +0000 | [diff] [blame] | 1128 | |
Jörg Hohensohn | 44171b9 | 2004-06-18 20:41:59 +0000 | [diff] [blame] | 1129 | item = run = p_table[i].cfg_val; |
Kevin Ferrare | cbbdc95 | 2005-11-04 07:18:36 +0000 | [diff] [blame] | 1130 | |
Jörg Hohensohn | 44171b9 | 2004-06-18 20:41:59 +0000 | [diff] [blame] | 1131 | while(1) |
| 1132 | { |
| 1133 | /* count the length of the field */ |
| 1134 | while (*run != ',' && *run != '\0') |
| 1135 | run++; |
Björn Stenberg | 0e6088f | 2002-10-02 16:33:26 +0000 | [diff] [blame] | 1136 | |
Jörg Hohensohn | 44171b9 | 2004-06-18 20:41:59 +0000 | [diff] [blame] | 1137 | if (!strncasecmp(value, item, MAX(run-item, len))) |
| 1138 | break; /* match, exit the search */ |
Kevin Ferrare | cbbdc95 | 2005-11-04 07:18:36 +0000 | [diff] [blame] | 1139 | |
Jörg Hohensohn | 44171b9 | 2004-06-18 20:41:59 +0000 | [diff] [blame] | 1140 | if (*run == '\0') /* reached the end of the choices */ |
| 1141 | return i; /* return the position, but don't update */ |
Linus Nielsen Feltzing | c843ba4 | 2002-10-29 12:16:36 +0000 | [diff] [blame] | 1142 | |
Jörg Hohensohn | 44171b9 | 2004-06-18 20:41:59 +0000 | [diff] [blame] | 1143 | val++; /* count the item up */ |
| 1144 | run++; /* behind the ',' */ |
| 1145 | item = run; |
| 1146 | } |
| 1147 | } |
Kevin Ferrare | cbbdc95 | 2005-11-04 07:18:36 +0000 | [diff] [blame] | 1148 | |
Jörg Hohensohn | 44171b9 | 2004-06-18 20:41:59 +0000 | [diff] [blame] | 1149 | /* could do a memcpy, but that would be endian-dependent */ |
| 1150 | switch(p_table[i].byte_size) |
| 1151 | { |
| 1152 | case 1: |
Kevin Ferrare | cbbdc95 | 2005-11-04 07:18:36 +0000 | [diff] [blame] | 1153 | ((unsigned char*)&global_settings)[p_table[i].settings_offset] = |
Jörg Hohensohn | 44171b9 | 2004-06-18 20:41:59 +0000 | [diff] [blame] | 1154 | (unsigned char)val; |
| 1155 | break; |
| 1156 | case 2: |
Kevin Ferrare | cbbdc95 | 2005-11-04 07:18:36 +0000 | [diff] [blame] | 1157 | ((unsigned short*)&global_settings)[p_table[i].settings_offset/2] = |
Jörg Hohensohn | 44171b9 | 2004-06-18 20:41:59 +0000 | [diff] [blame] | 1158 | (unsigned short)val; |
| 1159 | break; |
| 1160 | case 4: |
Kevin Ferrare | cbbdc95 | 2005-11-04 07:18:36 +0000 | [diff] [blame] | 1161 | ((unsigned int*)&global_settings)[p_table[i].settings_offset/4] = |
Jörg Hohensohn | 44171b9 | 2004-06-18 20:41:59 +0000 | [diff] [blame] | 1162 | (unsigned int)val; |
| 1163 | break; |
| 1164 | default: |
| 1165 | DEBUGF( "illegal size!" ); |
| 1166 | continue; |
| 1167 | } |
Björn Stenberg | 0e6088f | 2002-10-02 16:33:26 +0000 | [diff] [blame] | 1168 | |
Jörg Hohensohn | 44171b9 | 2004-06-18 20:41:59 +0000 | [diff] [blame] | 1169 | return i; /* return the position */ |
Björn Stenberg | 9c16e12 | 2003-02-14 14:14:55 +0000 | [diff] [blame] | 1170 | } |
Jörg Hohensohn | 44171b9 | 2004-06-18 20:41:59 +0000 | [diff] [blame] | 1171 | |
| 1172 | i++; |
| 1173 | if (i==count) |
| 1174 | i=1; /* wraparound */ |
| 1175 | } while (i != hint); /* back where we started, all searched */ |
Kevin Ferrare | cbbdc95 | 2005-11-04 07:18:36 +0000 | [diff] [blame] | 1176 | |
Jörg Hohensohn | 44171b9 | 2004-06-18 20:41:59 +0000 | [diff] [blame] | 1177 | return 0; /* indicate not found */ |
Björn Stenberg | 9c16e12 | 2003-02-14 14:14:55 +0000 | [diff] [blame] | 1178 | } |
| 1179 | |
Jörg Hohensohn | 44171b9 | 2004-06-18 20:41:59 +0000 | [diff] [blame] | 1180 | |
Jens Arnold | 8fb3361 | 2004-08-18 01:09:31 +0000 | [diff] [blame] | 1181 | bool settings_load_config(const char* file) |
Justin Heiner | e4a2761 | 2002-09-05 01:20:10 +0000 | [diff] [blame] | 1182 | { |
Justin Heiner | e4a2761 | 2002-09-05 01:20:10 +0000 | [diff] [blame] | 1183 | int fd; |
Björn Stenberg | 0e6088f | 2002-10-02 16:33:26 +0000 | [diff] [blame] | 1184 | char line[128]; |
Justin Heiner | e4a2761 | 2002-09-05 01:20:10 +0000 | [diff] [blame] | 1185 | |
| 1186 | fd = open(file, O_RDONLY); |
Björn Stenberg | f0c0765 | 2003-04-11 07:47:30 +0000 | [diff] [blame] | 1187 | if (fd < 0) |
Björn Stenberg | 0e6088f | 2002-10-02 16:33:26 +0000 | [diff] [blame] | 1188 | return false; |
Eric Linenberg | 8d47c5c | 2002-09-17 12:48:56 +0000 | [diff] [blame] | 1189 | |
Linus Nielsen Feltzing | c843ba4 | 2002-10-29 12:16:36 +0000 | [diff] [blame] | 1190 | while (read_line(fd, line, sizeof line) > 0) |
Björn Stenberg | 0e6088f | 2002-10-02 16:33:26 +0000 | [diff] [blame] | 1191 | { |
| 1192 | char* name; |
| 1193 | char* value; |
Jörg Hohensohn | 44171b9 | 2004-06-18 20:41:59 +0000 | [diff] [blame] | 1194 | const struct bit_entry* table[2] = { rtc_bits, hd_bits }; |
Kevin Ferrare | cbbdc95 | 2005-11-04 07:18:36 +0000 | [diff] [blame] | 1195 | const int ta_size[2] = { |
| 1196 | sizeof(rtc_bits)/sizeof(rtc_bits[0]), |
Jörg Hohensohn | 44171b9 | 2004-06-18 20:41:59 +0000 | [diff] [blame] | 1197 | sizeof(hd_bits)/sizeof(hd_bits[0]) |
| 1198 | }; |
| 1199 | int last_table = 0; /* which table was used last round */ |
| 1200 | int last_pos = 1; /* at which position did we succeed */ |
| 1201 | int pos; /* currently returned position */ |
Björn Stenberg | 0e6088f | 2002-10-02 16:33:26 +0000 | [diff] [blame] | 1202 | |
| 1203 | if (!settings_parseline(line, &name, &value)) |
| 1204 | continue; |
| 1205 | |
Jörg Hohensohn | 44171b9 | 2004-06-18 20:41:59 +0000 | [diff] [blame] | 1206 | /* check for the string values */ |
| 1207 | if (!strcasecmp(name, "wps")) { |
Daniel Stenberg | 09fce70 | 2005-11-18 09:03:25 +0000 | [diff] [blame] | 1208 | if (wps_data_load(gui_wps[0].data,value,true, false)) |
Daniel Stenberg | f981ea9 | 2005-12-05 22:44:42 +0000 | [diff] [blame] | 1209 | set_file(value, (char *)global_settings.wps_file, MAX_FILENAME); |
Björn Stenberg | bda4ec1 | 2003-02-17 09:53:11 +0000 | [diff] [blame] | 1210 | } |
Magnus Holmgren | f9fa33f | 2005-12-04 12:11:08 +0000 | [diff] [blame] | 1211 | #if defined(HAVE_REMOTE_LCD) && (NB_SCREENS > 1) |
Christi Scarborough | 4c0b83f | 2005-11-17 20:14:59 +0000 | [diff] [blame] | 1212 | else if (!strcasecmp(name, "rwps")) { |
Daniel Stenberg | 09fce70 | 2005-11-18 09:03:25 +0000 | [diff] [blame] | 1213 | if (wps_data_load(gui_wps[1].data,value,true, false)) |
Daniel Stenberg | f981ea9 | 2005-12-05 22:44:42 +0000 | [diff] [blame] | 1214 | set_file(value, (char *)global_settings.rwps_file, MAX_FILENAME); |
Christi Scarborough | 4c0b83f | 2005-11-17 20:14:59 +0000 | [diff] [blame] | 1215 | } |
| 1216 | #endif |
Björn Stenberg | bda4ec1 | 2003-02-17 09:53:11 +0000 | [diff] [blame] | 1217 | else if (!strcasecmp(name, "lang")) { |
| 1218 | if (!lang_load(value)) |
Jörg Hohensohn | 6e77d1f | 2004-04-06 07:06:59 +0000 | [diff] [blame] | 1219 | { |
Daniel Stenberg | f981ea9 | 2005-12-05 22:44:42 +0000 | [diff] [blame] | 1220 | set_file(value, (char *)global_settings.lang_file, MAX_FILENAME); |
Jörg Hohensohn | 6e77d1f | 2004-04-06 07:06:59 +0000 | [diff] [blame] | 1221 | talk_init(); /* use voice of same language */ |
| 1222 | } |
Björn Stenberg | bda4ec1 | 2003-02-17 09:53:11 +0000 | [diff] [blame] | 1223 | } |
Björn Stenberg | 9c16e12 | 2003-02-14 14:14:55 +0000 | [diff] [blame] | 1224 | #ifdef HAVE_LCD_BITMAP |
Björn Stenberg | 82054dc | 2003-02-23 18:54:28 +0000 | [diff] [blame] | 1225 | else if (!strcasecmp(name, "font")) { |
Björn Stenberg | 45a8413 | 2003-02-24 23:47:21 +0000 | [diff] [blame] | 1226 | if (font_load(value)) |
Daniel Stenberg | f981ea9 | 2005-12-05 22:44:42 +0000 | [diff] [blame] | 1227 | set_file(value, (char *)global_settings.font_file, MAX_FILENAME); |
Björn Stenberg | 82054dc | 2003-02-23 18:54:28 +0000 | [diff] [blame] | 1228 | } |
Björn Stenberg | bda4ec1 | 2003-02-17 09:53:11 +0000 | [diff] [blame] | 1229 | #endif |
Jörg Hohensohn | 44171b9 | 2004-06-18 20:41:59 +0000 | [diff] [blame] | 1230 | |
| 1231 | /* check for scalar values, using the two tables */ |
Kevin Ferrare | cbbdc95 | 2005-11-04 07:18:36 +0000 | [diff] [blame] | 1232 | pos = load_cfg_table(table[last_table], ta_size[last_table], |
Jörg Hohensohn | 44171b9 | 2004-06-18 20:41:59 +0000 | [diff] [blame] | 1233 | name, value, last_pos); |
| 1234 | if (pos) /* success */ |
Björn Stenberg | a108ec2 | 2004-01-14 00:13:04 +0000 | [diff] [blame] | 1235 | { |
Jörg Hohensohn | 44171b9 | 2004-06-18 20:41:59 +0000 | [diff] [blame] | 1236 | last_pos = pos; /* remember as a position hint for next round */ |
| 1237 | continue; |
Björn Stenberg | a108ec2 | 2004-01-14 00:13:04 +0000 | [diff] [blame] | 1238 | } |
Jörg Hohensohn | 44171b9 | 2004-06-18 20:41:59 +0000 | [diff] [blame] | 1239 | |
| 1240 | last_table = 1-last_table; /* try other table */ |
| 1241 | last_pos = 1; /* search from start */ |
| 1242 | pos = load_cfg_table(table[last_table], ta_size[last_table], |
| 1243 | name, value, last_pos); |
| 1244 | if (pos) /* success */ |
Björn Stenberg | a108ec2 | 2004-01-14 00:13:04 +0000 | [diff] [blame] | 1245 | { |
Jörg Hohensohn | 44171b9 | 2004-06-18 20:41:59 +0000 | [diff] [blame] | 1246 | last_pos = pos; /* remember as a position hint for next round */ |
| 1247 | continue; |
Jörg Hohensohn | 3aa99e1 | 2004-03-27 00:11:01 +0000 | [diff] [blame] | 1248 | } |
Justin Heiner | e4a2761 | 2002-09-05 01:20:10 +0000 | [diff] [blame] | 1249 | } |
Björn Stenberg | 0e6088f | 2002-10-02 16:33:26 +0000 | [diff] [blame] | 1250 | |
| 1251 | close(fd); |
Björn Stenberg | 9c16e12 | 2003-02-14 14:14:55 +0000 | [diff] [blame] | 1252 | settings_apply(); |
Björn Stenberg | f9d3486 | 2002-10-02 16:37:05 +0000 | [diff] [blame] | 1253 | settings_save(); |
Björn Stenberg | 0e6088f | 2002-10-02 16:33:26 +0000 | [diff] [blame] | 1254 | return true; |
Justin Heiner | e4a2761 | 2002-09-05 01:20:10 +0000 | [diff] [blame] | 1255 | } |
Justin Heiner | e4a2761 | 2002-09-05 01:20:10 +0000 | [diff] [blame] | 1256 | |
Björn Stenberg | c5aaab4 | 2003-03-10 16:31:02 +0000 | [diff] [blame] | 1257 | |
Jörg Hohensohn | 44171b9 | 2004-06-18 20:41:59 +0000 | [diff] [blame] | 1258 | /* helper to save content of global_settings into a file, |
Kevin Ferrare | cbbdc95 | 2005-11-04 07:18:36 +0000 | [diff] [blame] | 1259 | as described per table */ |
Jörg Hohensohn | 44171b9 | 2004-06-18 20:41:59 +0000 | [diff] [blame] | 1260 | static void save_cfg_table(const struct bit_entry* p_table, int count, int fd) |
| 1261 | { |
| 1262 | long value; /* 32 bit content */ |
| 1263 | int i; |
| 1264 | const struct bit_entry* p_run = p_table; /* start after the size info */ |
| 1265 | count--; /* first is excluded from loop */ |
| 1266 | |
| 1267 | for (i=0; i<count; i++) |
| 1268 | { |
| 1269 | p_run++; |
| 1270 | |
| 1271 | if (p_run->cfg_name == NULL) |
| 1272 | continue; /* this value is not to be saved */ |
| 1273 | |
| 1274 | /* could do a memcpy, but that would be endian-dependent */ |
| 1275 | switch(p_run->byte_size) |
| 1276 | { |
| 1277 | case 1: |
| 1278 | if (p_run->bit_size & SIGNED) /* signed? */ |
| 1279 | value = ((char*)&global_settings)[p_run->settings_offset]; |
| 1280 | else |
| 1281 | value = ((unsigned char*)&global_settings)[p_run->settings_offset]; |
| 1282 | break; |
| 1283 | case 2: |
| 1284 | if (p_run->bit_size & SIGNED) /* signed? */ |
| 1285 | value = ((short*)&global_settings)[p_run->settings_offset/2]; |
| 1286 | else |
| 1287 | value = ((unsigned short*)&global_settings)[p_run->settings_offset/2]; |
| 1288 | break; |
| 1289 | case 4: |
| 1290 | value = ((unsigned int*)&global_settings)[p_run->settings_offset/4]; |
| 1291 | break; |
| 1292 | default: |
| 1293 | DEBUGF( "illegal size!" ); |
| 1294 | continue; |
| 1295 | } |
Kevin Ferrare | cbbdc95 | 2005-11-04 07:18:36 +0000 | [diff] [blame] | 1296 | |
Jörg Hohensohn | 44171b9 | 2004-06-18 20:41:59 +0000 | [diff] [blame] | 1297 | if (p_run->cfg_val == NULL) /* write as number */ |
| 1298 | { |
Daniel Stenberg | 22b7701 | 2005-02-22 12:19:12 +0000 | [diff] [blame] | 1299 | fdprintf(fd, "%s: %ld\r\n", p_run->cfg_name, value); |
Jörg Hohensohn | 44171b9 | 2004-06-18 20:41:59 +0000 | [diff] [blame] | 1300 | } |
| 1301 | else /* write as item */ |
| 1302 | { |
| 1303 | const char* p = p_run->cfg_val; |
| 1304 | |
Daniel Stenberg | 22b7701 | 2005-02-22 12:19:12 +0000 | [diff] [blame] | 1305 | fdprintf(fd, "%s: ", p_run->cfg_name); |
Kevin Ferrare | cbbdc95 | 2005-11-04 07:18:36 +0000 | [diff] [blame] | 1306 | |
Jörg Hohensohn | 44171b9 | 2004-06-18 20:41:59 +0000 | [diff] [blame] | 1307 | while(value >= 0) |
| 1308 | { |
| 1309 | char c = *p++; /* currently processed char */ |
| 1310 | if (c == ',') /* separator */ |
| 1311 | value--; |
| 1312 | else if (c == '\0') /* end of string */ |
| 1313 | break; /* not found */ |
| 1314 | else if (value == 0) /* the right place */ |
| 1315 | write(fd, &c, 1); /* char by char, this is lame, OK */ |
| 1316 | } |
| 1317 | |
Daniel Stenberg | 22b7701 | 2005-02-22 12:19:12 +0000 | [diff] [blame] | 1318 | fdprintf(fd, "\r\n"); |
Jörg Hohensohn | 986675d | 2004-06-23 08:12:19 +0000 | [diff] [blame] | 1319 | if (p_run->cfg_val != off_on) /* explaination for non-bool */ |
Daniel Stenberg | 22b7701 | 2005-02-22 12:19:12 +0000 | [diff] [blame] | 1320 | fdprintf(fd, "# (possible values: %s)\r\n", p_run->cfg_val); |
Jörg Hohensohn | 44171b9 | 2004-06-18 20:41:59 +0000 | [diff] [blame] | 1321 | } |
| 1322 | } |
| 1323 | } |
| 1324 | |
| 1325 | |
Björn Stenberg | c5aaab4 | 2003-03-10 16:31:02 +0000 | [diff] [blame] | 1326 | bool settings_save_config(void) |
| 1327 | { |
Jens Arnold | 58e9412 | 2005-09-02 01:15:35 +0000 | [diff] [blame] | 1328 | int fd; |
Björn Stenberg | c5aaab4 | 2003-03-10 16:31:02 +0000 | [diff] [blame] | 1329 | char filename[MAX_PATH]; |
Kevin Ferrare | cbbdc95 | 2005-11-04 07:18:36 +0000 | [diff] [blame] | 1330 | |
Jens Arnold | 58e9412 | 2005-09-02 01:15:35 +0000 | [diff] [blame] | 1331 | create_numbered_filename(filename, ROCKBOX_DIR, "config", ".cfg", 2); |
Björn Stenberg | c5aaab4 | 2003-03-10 16:31:02 +0000 | [diff] [blame] | 1332 | |
| 1333 | /* allow user to modify filename */ |
Jens Arnold | 58e9412 | 2005-09-02 01:15:35 +0000 | [diff] [blame] | 1334 | while (true) { |
Björn Stenberg | c5aaab4 | 2003-03-10 16:31:02 +0000 | [diff] [blame] | 1335 | if (!kbd_input(filename, sizeof filename)) { |
| 1336 | fd = creat(filename,0); |
Kevin Ferrare | 9ccca4a | 2005-11-04 17:25:29 +0000 | [diff] [blame] | 1337 | if (fd < 0) |
| 1338 | gui_syncsplash(HZ, true, str(LANG_FAILED)); |
Björn Stenberg | c5aaab4 | 2003-03-10 16:31:02 +0000 | [diff] [blame] | 1339 | else |
Jens Arnold | 58e9412 | 2005-09-02 01:15:35 +0000 | [diff] [blame] | 1340 | break; |
Björn Stenberg | c5aaab4 | 2003-03-10 16:31:02 +0000 | [diff] [blame] | 1341 | } |
Jens Arnold | 58e9412 | 2005-09-02 01:15:35 +0000 | [diff] [blame] | 1342 | else { |
Kevin Ferrare | 9ccca4a | 2005-11-04 17:25:29 +0000 | [diff] [blame] | 1343 | gui_syncsplash(HZ, true, str(LANG_RESET_DONE_CANCEL)); |
Jens Arnold | 58e9412 | 2005-09-02 01:15:35 +0000 | [diff] [blame] | 1344 | return false; |
| 1345 | } |
Björn Stenberg | c5aaab4 | 2003-03-10 16:31:02 +0000 | [diff] [blame] | 1346 | } |
| 1347 | |
Jens Arnold | 58e9412 | 2005-09-02 01:15:35 +0000 | [diff] [blame] | 1348 | fdprintf(fd, "# .cfg file created by rockbox %s - " |
| 1349 | "http://www.rockbox.org\r\n#\r\n" |
| 1350 | "#\r\n# wps / language / font \r\n#\r\n", appsversion); |
Björn Stenberg | c5aaab4 | 2003-03-10 16:31:02 +0000 | [diff] [blame] | 1351 | |
Björn Stenberg | e4e4665 | 2003-04-24 17:53:17 +0000 | [diff] [blame] | 1352 | if (global_settings.wps_file[0] != 0) |
Daniel Stenberg | 0b4576c | 2005-11-12 21:48:06 +0000 | [diff] [blame] | 1353 | fdprintf(fd, "wps: %s/%s.wps\r\n", WPS_DIR, |
Jens Arnold | 58e9412 | 2005-09-02 01:15:35 +0000 | [diff] [blame] | 1354 | global_settings.wps_file); |
Björn Stenberg | c5aaab4 | 2003-03-10 16:31:02 +0000 | [diff] [blame] | 1355 | |
Christi Scarborough | 4c0b83f | 2005-11-17 20:14:59 +0000 | [diff] [blame] | 1356 | #ifdef HAVE_REMOTE_LCD |
| 1357 | if (global_settings.rwps_file[0] != 0) |
| 1358 | fdprintf(fd, "rwps: %s/%s.rwps\r\n", WPS_DIR, |
| 1359 | global_settings.rwps_file); |
| 1360 | #endif |
| 1361 | |
Björn Stenberg | e4e4665 | 2003-04-24 17:53:17 +0000 | [diff] [blame] | 1362 | if (global_settings.lang_file[0] != 0) |
Jens Arnold | 58e9412 | 2005-09-02 01:15:35 +0000 | [diff] [blame] | 1363 | fdprintf(fd, "lang: %s/%s.lng\r\n", ROCKBOX_DIR LANG_DIR, |
| 1364 | global_settings.lang_file); |
Björn Stenberg | c5aaab4 | 2003-03-10 16:31:02 +0000 | [diff] [blame] | 1365 | |
| 1366 | #ifdef HAVE_LCD_BITMAP |
Björn Stenberg | e4e4665 | 2003-04-24 17:53:17 +0000 | [diff] [blame] | 1367 | if (global_settings.font_file[0] != 0) |
Daniel Stenberg | 22b7701 | 2005-02-22 12:19:12 +0000 | [diff] [blame] | 1368 | fdprintf(fd, "font: %s/%s.fnt\r\n", ROCKBOX_DIR FONT_DIR, |
Jens Arnold | 58e9412 | 2005-09-02 01:15:35 +0000 | [diff] [blame] | 1369 | global_settings.font_file); |
Björn Stenberg | c5aaab4 | 2003-03-10 16:31:02 +0000 | [diff] [blame] | 1370 | #endif |
| 1371 | |
Jörg Hohensohn | 44171b9 | 2004-06-18 20:41:59 +0000 | [diff] [blame] | 1372 | /* here's the action: write values to file, specified via table */ |
| 1373 | save_cfg_table(rtc_bits, sizeof(rtc_bits)/sizeof(rtc_bits[0]), fd); |
| 1374 | save_cfg_table(hd_bits, sizeof(hd_bits)/sizeof(hd_bits[0]), fd); |
Björn Stenberg | c5aaab4 | 2003-03-10 16:31:02 +0000 | [diff] [blame] | 1375 | |
Björn Stenberg | c5aaab4 | 2003-03-10 16:31:02 +0000 | [diff] [blame] | 1376 | close(fd); |
| 1377 | |
Daniel Stenberg | f981ea9 | 2005-12-05 22:44:42 +0000 | [diff] [blame] | 1378 | gui_syncsplash(HZ, true, (unsigned char *)"%s %s", str(LANG_SETTINGS_SAVED1), |
Jens Arnold | 58e9412 | 2005-09-02 01:15:35 +0000 | [diff] [blame] | 1379 | str(LANG_SETTINGS_SAVED2)); |
Björn Stenberg | c5aaab4 | 2003-03-10 16:31:02 +0000 | [diff] [blame] | 1380 | return true; |
| 1381 | } |
| 1382 | |
Jörg Hohensohn | 44171b9 | 2004-06-18 20:41:59 +0000 | [diff] [blame] | 1383 | |
| 1384 | /* helper to load defaults from table into global_settings members */ |
| 1385 | static void default_table(const struct bit_entry* p_table, int count) |
| 1386 | { |
| 1387 | int i; |
| 1388 | |
| 1389 | for (i=1; i<count; i++) /* exclude the first, the size placeholder */ |
| 1390 | { |
| 1391 | /* could do a memcpy, but that would be endian-dependent */ |
| 1392 | switch(p_table[i].byte_size) |
| 1393 | { |
| 1394 | case 1: |
Kevin Ferrare | cbbdc95 | 2005-11-04 07:18:36 +0000 | [diff] [blame] | 1395 | ((unsigned char*)&global_settings)[p_table[i].settings_offset] = |
Jörg Hohensohn | 44171b9 | 2004-06-18 20:41:59 +0000 | [diff] [blame] | 1396 | (unsigned char)p_table[i].default_val; |
| 1397 | break; |
| 1398 | case 2: |
Kevin Ferrare | cbbdc95 | 2005-11-04 07:18:36 +0000 | [diff] [blame] | 1399 | ((unsigned short*)&global_settings)[p_table[i].settings_offset/2] = |
Jörg Hohensohn | 44171b9 | 2004-06-18 20:41:59 +0000 | [diff] [blame] | 1400 | (unsigned short)p_table[i].default_val; |
| 1401 | break; |
| 1402 | case 4: |
Kevin Ferrare | cbbdc95 | 2005-11-04 07:18:36 +0000 | [diff] [blame] | 1403 | ((unsigned int*)&global_settings)[p_table[i].settings_offset/4] = |
Jörg Hohensohn | 44171b9 | 2004-06-18 20:41:59 +0000 | [diff] [blame] | 1404 | (unsigned int)p_table[i].default_val; |
| 1405 | break; |
| 1406 | default: |
| 1407 | DEBUGF( "illegal size!" ); |
| 1408 | continue; |
| 1409 | } |
| 1410 | } |
| 1411 | } |
| 1412 | |
| 1413 | |
Björn Stenberg | f80d8a70 | 2002-06-27 00:20:00 +0000 | [diff] [blame] | 1414 | /* |
Kevin Ferrare | cbbdc95 | 2005-11-04 07:18:36 +0000 | [diff] [blame] | 1415 | * reset all settings to their default value |
Björn Stenberg | f80d8a70 | 2002-06-27 00:20:00 +0000 | [diff] [blame] | 1416 | */ |
Björn Stenberg | 6b25f79 | 2002-07-15 11:02:12 +0000 | [diff] [blame] | 1417 | void settings_reset(void) { |
Kevin Ferrare | cbbdc95 | 2005-11-04 07:18:36 +0000 | [diff] [blame] | 1418 | |
Björn Stenberg | 6b25f79 | 2002-07-15 11:02:12 +0000 | [diff] [blame] | 1419 | DEBUGF( "settings_reset()\n" ); |
Björn Stenberg | f80d8a70 | 2002-06-27 00:20:00 +0000 | [diff] [blame] | 1420 | |
Jörg Hohensohn | 44171b9 | 2004-06-18 20:41:59 +0000 | [diff] [blame] | 1421 | /* read defaults from table(s) into global_settings */ |
| 1422 | default_table(rtc_bits, sizeof(rtc_bits)/sizeof(rtc_bits[0])); |
| 1423 | default_table(hd_bits, sizeof(hd_bits)/sizeof(hd_bits[0])); |
| 1424 | |
| 1425 | /* do some special cases not covered by table */ |
Linus Nielsen Feltzing | 674eaca | 2005-04-01 13:41:03 +0000 | [diff] [blame] | 1426 | global_settings.volume = sound_default(SOUND_VOLUME); |
| 1427 | global_settings.balance = sound_default(SOUND_BALANCE); |
| 1428 | global_settings.bass = sound_default(SOUND_BASS); |
| 1429 | global_settings.treble = sound_default(SOUND_TREBLE); |
Linus Nielsen Feltzing | 674eaca | 2005-04-01 13:41:03 +0000 | [diff] [blame] | 1430 | global_settings.channel_config = sound_default(SOUND_CHANNELS); |
| 1431 | global_settings.stereo_width = sound_default(SOUND_STEREO_WIDTH); |
Anton Oleynikov | 2654d91 | 2005-12-04 14:33:10 +0000 | [diff] [blame] | 1432 | #ifdef HAVE_UDA1380 |
| 1433 | global_settings.sound_scaling = sound_default(SOUND_SCALING); |
| 1434 | #endif |
Jens Arnold | 8051a0b | 2005-11-06 23:12:11 +0000 | [diff] [blame] | 1435 | #if (CONFIG_CODEC == MAS3587F) || (CONFIG_CODEC == MAS3539F) |
| 1436 | global_settings.loudness = sound_default(SOUND_LOUDNESS); |
| 1437 | global_settings.avc = sound_default(SOUND_AVC); |
Linus Nielsen Feltzing | 674eaca | 2005-04-01 13:41:03 +0000 | [diff] [blame] | 1438 | global_settings.mdb_strength = sound_default(SOUND_MDB_STRENGTH); |
| 1439 | global_settings.mdb_harmonics = sound_default(SOUND_MDB_HARMONICS); |
| 1440 | global_settings.mdb_center = sound_default(SOUND_MDB_CENTER); |
| 1441 | global_settings.mdb_shape = sound_default(SOUND_MDB_SHAPE); |
| 1442 | global_settings.mdb_enable = sound_default(SOUND_MDB_ENABLE); |
| 1443 | global_settings.superbass = sound_default(SOUND_SUPERBASS); |
Jens Arnold | 8051a0b | 2005-11-06 23:12:11 +0000 | [diff] [blame] | 1444 | #endif |
Björn Stenberg | 067262d | 2003-07-09 23:07:49 +0000 | [diff] [blame] | 1445 | global_settings.contrast = lcd_default_contrast(); |
Jörg Hohensohn | 44171b9 | 2004-06-18 20:41:59 +0000 | [diff] [blame] | 1446 | global_settings.wps_file[0] = '\0'; |
Christi Scarborough | 4c0b83f | 2005-11-17 20:14:59 +0000 | [diff] [blame] | 1447 | #ifdef HAVE_REMOTE_LCD |
| 1448 | global_settings.rwps_file[0] = '\0'; |
| 1449 | #endif |
Jörg Hohensohn | 44171b9 | 2004-06-18 20:41:59 +0000 | [diff] [blame] | 1450 | global_settings.font_file[0] = '\0'; |
| 1451 | global_settings.lang_file[0] = '\0'; |
| 1452 | |
Björn Stenberg | f80d8a70 | 2002-06-27 00:20:00 +0000 | [diff] [blame] | 1453 | } |
Björn Stenberg | 60b356e | 2002-06-27 01:08:11 +0000 | [diff] [blame] | 1454 | |
Jens Arnold | 8fb3361 | 2004-08-18 01:09:31 +0000 | [diff] [blame] | 1455 | bool set_bool(const char* string, bool* variable ) |
Björn Stenberg | 60b356e | 2002-06-27 01:08:11 +0000 | [diff] [blame] | 1456 | { |
Jens Arnold | 4960808 | 2005-10-16 11:15:51 +0000 | [diff] [blame] | 1457 | return set_bool_options(string, variable, |
Daniel Stenberg | f981ea9 | 2005-12-05 22:44:42 +0000 | [diff] [blame] | 1458 | (char *)STR(LANG_SET_BOOL_YES), |
| 1459 | (char *)STR(LANG_SET_BOOL_NO), |
| 1460 | NULL); |
Björn Stenberg | 26712d5 | 2003-06-05 11:11:10 +0000 | [diff] [blame] | 1461 | } |
| 1462 | |
| 1463 | /* wrapper to convert from int param to bool param in set_option */ |
| 1464 | static void (*boolfunction)(bool); |
| 1465 | void bool_funcwrapper(int value) |
| 1466 | { |
| 1467 | if (value) |
| 1468 | boolfunction(true); |
| 1469 | else |
| 1470 | boolfunction(false); |
Eric Linenberg | c5b645b | 2002-09-05 04:42:12 +0000 | [diff] [blame] | 1471 | } |
Björn Stenberg | 60b356e | 2002-06-27 01:08:11 +0000 | [diff] [blame] | 1472 | |
Jens Arnold | 8fb3361 | 2004-08-18 01:09:31 +0000 | [diff] [blame] | 1473 | bool set_bool_options(const char* string, bool* variable, |
| 1474 | const char* yes_str, int yes_voice, |
| 1475 | const char* no_str, int no_voice, |
Jörg Hohensohn | 42ffbf9 | 2004-03-15 08:27:51 +0000 | [diff] [blame] | 1476 | void (*function)(bool)) |
Eric Linenberg | c5b645b | 2002-09-05 04:42:12 +0000 | [diff] [blame] | 1477 | { |
Daniel Stenberg | f981ea9 | 2005-12-05 22:44:42 +0000 | [diff] [blame] | 1478 | struct opt_items names[] = { |
| 1479 | {(unsigned char *)no_str, no_voice}, |
| 1480 | {(unsigned char *)yes_str, yes_voice} |
| 1481 | }; |
Björn Stenberg | b1b8bd4 | 2002-09-24 17:22:12 +0000 | [diff] [blame] | 1482 | bool result; |
| 1483 | |
Björn Stenberg | 26712d5 | 2003-06-05 11:11:10 +0000 | [diff] [blame] | 1484 | boolfunction = function; |
Kevin Ferrare | cbbdc95 | 2005-11-04 07:18:36 +0000 | [diff] [blame] | 1485 | result = set_option(string, variable, BOOL, names, 2, |
Björn Stenberg | 26712d5 | 2003-06-05 11:11:10 +0000 | [diff] [blame] | 1486 | function ? bool_funcwrapper : NULL); |
Björn Stenberg | b1b8bd4 | 2002-09-24 17:22:12 +0000 | [diff] [blame] | 1487 | return result; |
Björn Stenberg | 60b356e | 2002-06-27 01:08:11 +0000 | [diff] [blame] | 1488 | } |
| 1489 | |
Kevin Ferrare | 81411a8 | 2005-11-05 02:19:21 +0000 | [diff] [blame] | 1490 | void talk_unit(int unit, int value) |
| 1491 | { |
| 1492 | if (global_settings.talk_menu) |
| 1493 | { |
| 1494 | if (unit < UNIT_LAST) |
| 1495 | { /* use the available unit definition */ |
| 1496 | talk_value(value, unit, false); |
| 1497 | } |
| 1498 | else |
| 1499 | { /* say the number, followed by an arbitrary voice ID */ |
| 1500 | talk_number(value, false); |
| 1501 | talk_id(unit, true); |
| 1502 | } |
| 1503 | } |
| 1504 | } |
| 1505 | |
Daniel Stenberg | f981ea9 | 2005-12-05 22:44:42 +0000 | [diff] [blame] | 1506 | bool set_int(const unsigned char* string, |
Jens Arnold | 8fb3361 | 2004-08-18 01:09:31 +0000 | [diff] [blame] | 1507 | const char* unit, |
Jörg Hohensohn | beec2e9 | 2004-03-20 16:49:58 +0000 | [diff] [blame] | 1508 | int voice_unit, |
Björn Stenberg | 60b356e | 2002-06-27 01:08:11 +0000 | [diff] [blame] | 1509 | int* variable, |
| 1510 | void (*function)(int), |
| 1511 | int step, |
| 1512 | int min, |
Magnus Holmgren | 5a8eac1 | 2005-08-11 18:56:20 +0000 | [diff] [blame] | 1513 | int max, |
| 1514 | void (*formatter)(char*, int, int, const char*) ) |
Björn Stenberg | 60b356e | 2002-06-27 01:08:11 +0000 | [diff] [blame] | 1515 | { |
Linus Nielsen Feltzing | c3eb83c | 2002-09-19 09:00:25 +0000 | [diff] [blame] | 1516 | int button; |
Kevin Ferrare | cbbdc95 | 2005-11-04 07:18:36 +0000 | [diff] [blame] | 1517 | int oldvalue=*variable; |
| 1518 | struct gui_select select; |
Daniel Stenberg | f981ea9 | 2005-12-05 22:44:42 +0000 | [diff] [blame] | 1519 | gui_select_init_numeric(&select, (char *)string, *variable, min, max, step, unit, |
| 1520 | formatter); |
Kevin Ferrare | cbbdc95 | 2005-11-04 07:18:36 +0000 | [diff] [blame] | 1521 | gui_syncselect_draw(&select); |
Kevin Ferrare | 81411a8 | 2005-11-05 02:19:21 +0000 | [diff] [blame] | 1522 | talk_unit(voice_unit, *variable); |
Daniel Stenberg | b05eec8 | 2005-12-05 23:37:14 +0000 | [diff] [blame] | 1523 | while (!select.validated) |
Kevin Ferrare | cbbdc95 | 2005-11-04 07:18:36 +0000 | [diff] [blame] | 1524 | { |
Linus Nielsen Feltzing | c3eb83c | 2002-09-19 09:00:25 +0000 | [diff] [blame] | 1525 | button = button_get_w_tmo(HZ/2); |
Kevin Ferrare | cbbdc95 | 2005-11-04 07:18:36 +0000 | [diff] [blame] | 1526 | if(gui_syncselect_do_button(&select, button)) |
| 1527 | { |
Daniel Stenberg | b05eec8 | 2005-12-05 23:37:14 +0000 | [diff] [blame] | 1528 | *variable=select.options.option; |
Kevin Ferrare | 80c0f99 | 2005-11-04 16:07:50 +0000 | [diff] [blame] | 1529 | gui_syncselect_draw(&select); |
Kevin Ferrare | 81411a8 | 2005-11-05 02:19:21 +0000 | [diff] [blame] | 1530 | talk_unit(voice_unit, *variable); |
Kevin Ferrare | cbbdc95 | 2005-11-04 07:18:36 +0000 | [diff] [blame] | 1531 | if ( function ) |
Kevin Ferrare | 9b5264d | 2005-11-06 03:18:34 +0000 | [diff] [blame] | 1532 | function(*variable); |
Björn Stenberg | 60b356e | 2002-06-27 01:08:11 +0000 | [diff] [blame] | 1533 | } |
Kevin Ferrare | cbbdc95 | 2005-11-04 07:18:36 +0000 | [diff] [blame] | 1534 | gui_syncstatusbar_draw(&statusbars, false); |
Daniel Stenberg | b05eec8 | 2005-12-05 23:37:14 +0000 | [diff] [blame] | 1535 | if(select.canceled) |
Kevin Ferrare | cbbdc95 | 2005-11-04 07:18:36 +0000 | [diff] [blame] | 1536 | { |
| 1537 | *variable=oldvalue; |
Kevin Ferrare | 9b5264d | 2005-11-06 03:18:34 +0000 | [diff] [blame] | 1538 | if ( function ) |
| 1539 | function(*variable); |
Kevin Ferrare | cbbdc95 | 2005-11-04 07:18:36 +0000 | [diff] [blame] | 1540 | return false; |
| 1541 | } |
| 1542 | if(default_event_handler(button) == SYS_USB_CONNECTED) |
| 1543 | return true; |
Björn Stenberg | 60b356e | 2002-06-27 01:08:11 +0000 | [diff] [blame] | 1544 | } |
Björn Stenberg | b1b8bd4 | 2002-09-24 17:22:12 +0000 | [diff] [blame] | 1545 | return false; |
Björn Stenberg | 60b356e | 2002-06-27 01:08:11 +0000 | [diff] [blame] | 1546 | } |
| 1547 | |
Björn Stenberg | 26712d5 | 2003-06-05 11:11:10 +0000 | [diff] [blame] | 1548 | /* NOTE: the 'type' parameter specifies the actual type of the variable |
| 1549 | that 'variable' points to. not the value within. Only variables with |
| 1550 | type 'bool' should use parameter BOOL. |
| 1551 | |
Björn Stenberg | 9a82b23 | 2003-06-05 14:22:03 +0000 | [diff] [blame] | 1552 | The type separation is necessary since int and bool are fundamentally |
Björn Stenberg | 26712d5 | 2003-06-05 11:11:10 +0000 | [diff] [blame] | 1553 | different and bit-incompatible types and can not share the same access |
| 1554 | code. */ |
| 1555 | |
Kevin Ferrare | cbbdc95 | 2005-11-04 07:18:36 +0000 | [diff] [blame] | 1556 | #define set_type_fromint(type, dest, value) \ |
| 1557 | if (type == INT) \ |
| 1558 | *(int *)dest=value; \ |
| 1559 | else \ |
| 1560 | *(bool *)dest=value?true:false |
| 1561 | |
Kevin Ferrare | 9b5264d | 2005-11-06 03:18:34 +0000 | [diff] [blame] | 1562 | #define type_fromvoidptr(type, value) \ |
| 1563 | (type == INT)? \ |
| 1564 | (int)(*(int*)(value)) \ |
| 1565 | : \ |
| 1566 | (bool)(*(bool*)(value)) |
| 1567 | |
| 1568 | #define get_int_fromtype(type, var) \ |
| 1569 | (type == INT)?*(int *)var:(*(bool *)var?1:0) |
Kevin Ferrare | cbbdc95 | 2005-11-04 07:18:36 +0000 | [diff] [blame] | 1570 | |
Jens Arnold | 8fb3361 | 2004-08-18 01:09:31 +0000 | [diff] [blame] | 1571 | bool set_option(const char* string, void* variable, enum optiontype type, |
Jörg Hohensohn | b1403ee | 2004-07-23 23:01:20 +0000 | [diff] [blame] | 1572 | const struct opt_items* options, int numoptions, void (*function)(int)) |
Björn Stenberg | 60b356e | 2002-06-27 01:08:11 +0000 | [diff] [blame] | 1573 | { |
Linus Nielsen Feltzing | c3eb83c | 2002-09-19 09:00:25 +0000 | [diff] [blame] | 1574 | int button; |
Kevin Ferrare | cbbdc95 | 2005-11-04 07:18:36 +0000 | [diff] [blame] | 1575 | int oldvalue; |
| 1576 | /* oldvalue=*variable; */ |
Kevin Ferrare | 9b5264d | 2005-11-06 03:18:34 +0000 | [diff] [blame] | 1577 | oldvalue=get_int_fromtype(type, variable); |
Kevin Ferrare | cbbdc95 | 2005-11-04 07:18:36 +0000 | [diff] [blame] | 1578 | struct gui_select select; |
| 1579 | gui_select_init_items(&select, string, oldvalue, options, numoptions); |
| 1580 | gui_syncselect_draw(&select); |
Kevin Ferrare | 81411a8 | 2005-11-05 02:19:21 +0000 | [diff] [blame] | 1581 | if (global_settings.talk_menu) |
Daniel Stenberg | b05eec8 | 2005-12-05 23:37:14 +0000 | [diff] [blame] | 1582 | talk_id(options[select.options.option].voice_id, true); |
| 1583 | |
| 1584 | while ( !select.validated ) |
Kevin Ferrare | cbbdc95 | 2005-11-04 07:18:36 +0000 | [diff] [blame] | 1585 | { |
| 1586 | gui_syncstatusbar_draw(&statusbars, true); |
Linus Nielsen Feltzing | c3eb83c | 2002-09-19 09:00:25 +0000 | [diff] [blame] | 1587 | button = button_get_w_tmo(HZ/2); |
Kevin Ferrare | cbbdc95 | 2005-11-04 07:18:36 +0000 | [diff] [blame] | 1588 | if(gui_syncselect_do_button(&select, button)) |
| 1589 | { |
| 1590 | /* *variable = gui_select_get_selected(&select) */ |
Daniel Stenberg | b05eec8 | 2005-12-05 23:37:14 +0000 | [diff] [blame] | 1591 | set_type_fromint(type, variable, select.options.option); |
Kevin Ferrare | cbbdc95 | 2005-11-04 07:18:36 +0000 | [diff] [blame] | 1592 | gui_syncselect_draw(&select); |
| 1593 | if (global_settings.talk_menu) |
Daniel Stenberg | b05eec8 | 2005-12-05 23:37:14 +0000 | [diff] [blame] | 1594 | talk_id(options[select.options.option].voice_id, false); |
Kevin Ferrare | cbbdc95 | 2005-11-04 07:18:36 +0000 | [diff] [blame] | 1595 | if ( function ) |
Kevin Ferrare | 9b5264d | 2005-11-06 03:18:34 +0000 | [diff] [blame] | 1596 | function(type_fromvoidptr(type, variable)); |
Björn Stenberg | 60b356e | 2002-06-27 01:08:11 +0000 | [diff] [blame] | 1597 | } |
Kevin Ferrare | cbbdc95 | 2005-11-04 07:18:36 +0000 | [diff] [blame] | 1598 | gui_syncstatusbar_draw(&statusbars, false); |
Daniel Stenberg | b05eec8 | 2005-12-05 23:37:14 +0000 | [diff] [blame] | 1599 | if(select.canceled) |
Kevin Ferrare | cbbdc95 | 2005-11-04 07:18:36 +0000 | [diff] [blame] | 1600 | { |
| 1601 | /* *variable=oldvalue; */ |
| 1602 | set_type_fromint(type, variable, oldvalue); |
Kevin Ferrare | 9b5264d | 2005-11-06 03:18:34 +0000 | [diff] [blame] | 1603 | if ( function ) |
| 1604 | function(type_fromvoidptr(type, variable)); |
Kevin Ferrare | cbbdc95 | 2005-11-04 07:18:36 +0000 | [diff] [blame] | 1605 | return false; |
Björn Stenberg | 26712d5 | 2003-06-05 11:11:10 +0000 | [diff] [blame] | 1606 | } |
Kevin Ferrare | cbbdc95 | 2005-11-04 07:18:36 +0000 | [diff] [blame] | 1607 | if(default_event_handler(button) == SYS_USB_CONNECTED) |
| 1608 | return true; |
Björn Stenberg | 60b356e | 2002-06-27 01:08:11 +0000 | [diff] [blame] | 1609 | } |
Björn Stenberg | b1b8bd4 | 2002-09-24 17:22:12 +0000 | [diff] [blame] | 1610 | return false; |
Björn Stenberg | 60b356e | 2002-06-27 01:08:11 +0000 | [diff] [blame] | 1611 | } |
Markus Braun | 3181f68 | 2002-08-09 12:38:45 +0000 | [diff] [blame] | 1612 | |
Daniel Stenberg | 6ff399f | 2005-02-02 21:52:55 +0000 | [diff] [blame] | 1613 | #ifdef HAVE_RECORDING |
Linus Nielsen Feltzing | aaa99e7 | 2003-11-20 00:33:43 +0000 | [diff] [blame] | 1614 | /* This array holds the record timer interval lengths, in seconds */ |
Jens Arnold | abe77a1 | 2004-08-01 21:50:57 +0000 | [diff] [blame] | 1615 | static const unsigned long rec_timer_seconds[] = |
Linus Nielsen Feltzing | aaa99e7 | 2003-11-20 00:33:43 +0000 | [diff] [blame] | 1616 | { |
Jens Arnold | 031e4b8 | 2005-06-04 12:14:46 +0000 | [diff] [blame] | 1617 | 0, /* 0 means OFF */ |
Linus Nielsen Feltzing | aaa99e7 | 2003-11-20 00:33:43 +0000 | [diff] [blame] | 1618 | 5*60, /* 00:05 */ |
| 1619 | 10*60, /* 00:10 */ |
| 1620 | 15*60, /* 00:15 */ |
| 1621 | 30*60, /* 00:30 */ |
| 1622 | 60*60, /* 01:00 */ |
Linus Nielsen Feltzing | fb60a29 | 2004-10-27 09:24:02 +0000 | [diff] [blame] | 1623 | 74*60, /* 74:00 */ |
| 1624 | 80*60, /* 80:00 */ |
Linus Nielsen Feltzing | aaa99e7 | 2003-11-20 00:33:43 +0000 | [diff] [blame] | 1625 | 2*60*60, /* 02:00 */ |
| 1626 | 4*60*60, /* 04:00 */ |
| 1627 | 6*60*60, /* 06:00 */ |
| 1628 | 8*60*60, /* 08:00 */ |
Jean-Philippe Bernardy | 2860c5e | 2005-02-11 18:41:40 +0000 | [diff] [blame] | 1629 | 10L*60*60, /* 10:00 */ |
| 1630 | 12L*60*60, /* 12:00 */ |
| 1631 | 18L*60*60, /* 18:00 */ |
| 1632 | 24L*60*60 /* 24:00 */ |
Linus Nielsen Feltzing | aaa99e7 | 2003-11-20 00:33:43 +0000 | [diff] [blame] | 1633 | }; |
| 1634 | |
| 1635 | unsigned int rec_timesplit_seconds(void) |
| 1636 | { |
| 1637 | return rec_timer_seconds[global_settings.rec_timesplit]; |
| 1638 | } |
Linus Nielsen Feltzing | 68482bb | 2005-04-04 09:12:12 +0000 | [diff] [blame] | 1639 | |
| 1640 | /* |
| 1641 | * Time strings used for the trigger durations. |
| 1642 | * Keep synchronous to trigger_times in settings_apply_trigger |
| 1643 | */ |
Linus Nielsen Feltzing | b3e49e2 | 2005-08-18 07:02:03 +0000 | [diff] [blame] | 1644 | const char * const trig_durations[TRIG_DURATION_COUNT] = |
Linus Nielsen Feltzing | 68482bb | 2005-04-04 09:12:12 +0000 | [diff] [blame] | 1645 | { |
| 1646 | "0s", "1s", "2s", "5s", |
| 1647 | "10s", "15s", "20s", "25s", "30s", |
| 1648 | "1min", "2min", "5min", "10min" |
| 1649 | }; |
| 1650 | |
| 1651 | void settings_apply_trigger(void) |
| 1652 | { |
| 1653 | /* Keep synchronous to trig_durations and trig_durations_conf*/ |
| 1654 | static const long trigger_times[TRIG_DURATION_COUNT] = { |
| 1655 | 0, HZ, 2*HZ, 5*HZ, |
| 1656 | 10*HZ, 15*HZ, 20*HZ, 25*HZ, 30*HZ, |
| 1657 | 60*HZ, 2*60*HZ, 5*60*HZ, 10*60*HZ |
| 1658 | }; |
| 1659 | |
| 1660 | peak_meter_define_trigger( |
| 1661 | global_settings.rec_start_thres, |
| 1662 | trigger_times[global_settings.rec_start_duration], |
| 1663 | MIN(trigger_times[global_settings.rec_start_duration] / 2, 2*HZ), |
| 1664 | global_settings |