2002-06-27 00:20:00 +00:00
|
|
|
/***************************************************************************
|
|
|
|
* __________ __ ___.
|
|
|
|
* Open \______ \ ____ ____ | | _\_ |__ _______ ___
|
|
|
|
* Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
|
|
|
|
* Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
|
|
|
|
* Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
|
|
|
|
* \/ \/ \/ \/ \/
|
|
|
|
* $Id$
|
|
|
|
*
|
|
|
|
* Copyright (C) 2002 by wavey@wavey.org
|
2002-07-15 11:02:12 +00:00
|
|
|
* RTC config saving code (C) 2002 by hessu@hes.iki.fi
|
2002-06-27 00:20:00 +00:00
|
|
|
*
|
|
|
|
* All files in this archive are subject to the GNU General Public License.
|
|
|
|
* See the file COPYING in the source tree root for full license agreement.
|
|
|
|
*
|
|
|
|
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
|
|
|
|
* KIND, either express or implied.
|
|
|
|
*
|
|
|
|
****************************************************************************/
|
|
|
|
#include <stdio.h>
|
2004-06-18 20:41:59 +00:00
|
|
|
#include <stddef.h>
|
2007-02-08 04:33:41 +00:00
|
|
|
#include <stdlib.h>
|
2005-02-15 15:30:19 +00:00
|
|
|
#include <limits.h>
|
2006-03-03 01:12:50 +00:00
|
|
|
#include "inttypes.h"
|
2002-06-27 00:20:00 +00:00
|
|
|
#include "config.h"
|
2006-08-15 12:27:07 +00:00
|
|
|
#include "action.h"
|
2007-01-23 13:40:44 +00:00
|
|
|
#include "crc32.h"
|
2002-06-27 00:20:00 +00:00
|
|
|
#include "settings.h"
|
|
|
|
#include "debug.h"
|
2002-08-31 04:58:35 +00:00
|
|
|
#include "usb.h"
|
|
|
|
#include "backlight.h"
|
2005-04-04 12:06:29 +00:00
|
|
|
#include "audio.h"
|
2005-09-11 12:07:13 +00:00
|
|
|
#include "mpeg.h"
|
2004-03-15 08:27:51 +00:00
|
|
|
#include "talk.h"
|
2002-07-15 11:02:12 +00:00
|
|
|
#include "string.h"
|
2007-01-29 13:44:22 +00:00
|
|
|
#include "rtc.h"
|
2007-01-29 13:58:35 +00:00
|
|
|
#include "power.h"
|
2006-11-08 01:55:26 +00:00
|
|
|
#include "ata_idle_notify.h"
|
2002-09-05 16:30:07 +00:00
|
|
|
#include "atoi.h"
|
2002-09-24 17:22:12 +00:00
|
|
|
#include "screens.h"
|
2002-10-02 16:33:26 +00:00
|
|
|
#include "ctype.h"
|
|
|
|
#include "file.h"
|
2002-10-29 12:16:36 +00:00
|
|
|
#include "system.h"
|
2003-05-04 02:04:31 +00:00
|
|
|
#include "misc.h"
|
2002-08-20 19:37:00 +00:00
|
|
|
#ifdef HAVE_LCD_BITMAP
|
|
|
|
#include "icons.h"
|
2002-09-12 13:33:59 +00:00
|
|
|
#include "font.h"
|
2002-10-29 12:09:15 +00:00
|
|
|
#include "peakmeter.h"
|
2002-08-20 19:37:00 +00:00
|
|
|
#endif
|
2002-09-18 14:08:05 +00:00
|
|
|
#include "lang.h"
|
2002-10-08 15:42:40 +00:00
|
|
|
#include "language.h"
|
2005-11-17 20:14:59 +00:00
|
|
|
#include "gwps.h"
|
2002-12-02 16:07:56 +00:00
|
|
|
#include "powermgmt.h"
|
2003-02-15 00:03:23 +00:00
|
|
|
#include "sprintf.h"
|
2003-03-10 16:31:02 +00:00
|
|
|
#include "keyboard.h"
|
2003-04-25 10:33:38 +00:00
|
|
|
#include "version.h"
|
2005-04-01 13:41:03 +00:00
|
|
|
#include "sound.h"
|
2005-12-06 13:27:15 +00:00
|
|
|
#include "rbunicode.h"
|
2005-10-07 17:38:05 +00:00
|
|
|
#include "dircache.h"
|
2005-11-04 07:18:36 +00:00
|
|
|
#include "statusbar.h"
|
2005-11-04 17:25:29 +00:00
|
|
|
#include "splash.h"
|
2006-01-22 01:42:05 +00:00
|
|
|
#include "list.h"
|
2007-01-23 13:40:44 +00:00
|
|
|
#include "settings_list.h"
|
2007-06-17 21:29:24 +00:00
|
|
|
#include "filetypes.h"
|
2007-04-25 22:08:00 +00:00
|
|
|
|
|
|
|
#if (LCD_DEPTH > 1) || (defined(HAVE_LCD_REMOTE) && (LCD_REMOTE_DEPTH > 1))
|
2006-02-02 20:42:56 +00:00
|
|
|
#include "backdrop.h"
|
2006-02-02 21:39:09 +00:00
|
|
|
#endif
|
2005-10-07 17:38:05 +00:00
|
|
|
|
2007-02-18 02:16:03 +00:00
|
|
|
#if CONFIG_TUNER
|
2006-04-02 12:23:08 +00:00
|
|
|
#include "radio.h"
|
|
|
|
#endif
|
|
|
|
|
2005-08-29 21:15:27 +00:00
|
|
|
#if CONFIG_CODEC == MAS3507D
|
2003-11-04 00:18:19 +00:00
|
|
|
void dac_line_in(bool enable);
|
2003-11-03 23:36:36 +00:00
|
|
|
#endif
|
2002-06-27 00:20:00 +00:00
|
|
|
struct user_settings global_settings;
|
2007-02-08 10:36:49 +00:00
|
|
|
struct system_status global_status;
|
2007-02-07 04:24:21 +00:00
|
|
|
|
2005-08-29 21:15:27 +00:00
|
|
|
#if CONFIG_CODEC == SWCODEC
|
2005-07-13 12:48:22 +00:00
|
|
|
#include "pcmbuf.h"
|
2005-09-24 15:22:48 +00:00
|
|
|
#include "dsp.h"
|
2006-11-06 18:07:30 +00:00
|
|
|
#ifdef HAVE_RECORDING
|
|
|
|
#include "enc_config.h"
|
2005-06-09 09:47:00 +00:00
|
|
|
#endif
|
2006-11-06 18:07:30 +00:00
|
|
|
#endif /* CONFIG_CODEC == SWCODEC */
|
2004-09-19 21:58:37 +00:00
|
|
|
|
2007-01-23 13:40:44 +00:00
|
|
|
#define NVRAM_BLOCK_SIZE 44
|
2002-08-13 17:16:09 +00:00
|
|
|
|
2002-09-27 09:31:31 +00:00
|
|
|
#ifdef HAVE_LCD_BITMAP
|
|
|
|
#define MAX_LINES 10
|
|
|
|
#else
|
|
|
|
#define MAX_LINES 2
|
|
|
|
#endif
|
|
|
|
|
2005-04-15 12:08:49 +00:00
|
|
|
#ifdef HAVE_REMOTE_LCD
|
|
|
|
#include "lcd-remote.h"
|
|
|
|
#endif
|
|
|
|
|
2004-06-18 20:41:59 +00:00
|
|
|
long lasttime = 0;
|
|
|
|
|
2007-01-29 13:18:57 +00:00
|
|
|
/** NVRAM stuff, if the target doesnt have NVRAM it is saved in ROCKBOX_DIR /nvram.bin **/
|
2007-01-23 13:40:44 +00:00
|
|
|
/* NVRAM is set out as
|
|
|
|
[0] 'R'
|
|
|
|
[1] 'b'
|
|
|
|
[2] version
|
|
|
|
[3] stored variable count
|
|
|
|
[4-7] crc32 checksum
|
|
|
|
[8-NVRAM_BLOCK_SIZE] data
|
2004-06-18 20:41:59 +00:00
|
|
|
*/
|
2007-01-23 13:40:44 +00:00
|
|
|
#define NVRAM_DATA_START 8
|
|
|
|
#define NVRAM_FILE ROCKBOX_DIR "/nvram.bin"
|
|
|
|
static char nvram_buffer[NVRAM_BLOCK_SIZE];
|
2004-06-18 20:41:59 +00:00
|
|
|
|
2007-01-23 13:40:44 +00:00
|
|
|
static bool read_nvram_data(char* buf, int max_len)
|
2004-06-18 20:41:59 +00:00
|
|
|
{
|
2007-01-23 13:40:44 +00:00
|
|
|
unsigned crc32 = 0xffffffff;
|
|
|
|
int var_count = 0, i = 0, buf_pos = 0;
|
|
|
|
#ifndef HAVE_RTC_RAM
|
|
|
|
int fd = open(NVRAM_FILE,O_RDONLY);
|
|
|
|
if (fd < 0)
|
|
|
|
return false;
|
|
|
|
memset(buf,0,max_len);
|
|
|
|
if (read(fd,buf,max_len) < 8) /* min is 8 bytes,magic, ver, vars, crc32 */
|
|
|
|
return false;
|
|
|
|
close(fd);
|
2006-08-12 23:01:52 +00:00
|
|
|
#else
|
2007-01-23 13:40:44 +00:00
|
|
|
memset(buf,0,max_len);
|
|
|
|
/* read rtc block */
|
|
|
|
for (i=0; i < max_len; i++ )
|
|
|
|
buf[i] = rtc_read(0x14+i);
|
|
|
|
#endif
|
|
|
|
/* check magic, version */
|
|
|
|
if ((buf[0] != 'R') || (buf[1] != 'b')
|
|
|
|
|| (buf[2] != NVRAM_CONFIG_VERSION))
|
|
|
|
return false;
|
|
|
|
/* check crc32 */
|
|
|
|
crc32 = crc_32(&buf[NVRAM_DATA_START],
|
|
|
|
max_len-NVRAM_DATA_START-1,0xffffffff);
|
|
|
|
if (memcmp(&crc32,&buf[4],4))
|
|
|
|
return false;
|
|
|
|
/* all good, so read in the settings */
|
|
|
|
var_count = buf[3];
|
|
|
|
buf_pos = NVRAM_DATA_START;
|
2007-08-12 07:22:38 +00:00
|
|
|
for(i=0; i<nb_settings; i++)
|
2007-01-23 13:40:44 +00:00
|
|
|
{
|
|
|
|
int nvram_bytes = (settings[i].flags&F_NVRAM_BYTES_MASK)
|
|
|
|
>>F_NVRAM_MASK_SHIFT;
|
|
|
|
if (nvram_bytes)
|
|
|
|
{
|
2007-08-12 07:22:38 +00:00
|
|
|
if ((var_count>0) && (buf_pos<max_len))
|
|
|
|
{
|
|
|
|
memcpy(settings[i].setting,&buf[buf_pos],nvram_bytes);
|
|
|
|
buf_pos += nvram_bytes;
|
|
|
|
var_count--;
|
|
|
|
}
|
|
|
|
else /* should only happen when new items are added to the end */
|
|
|
|
{
|
|
|
|
memcpy(settings[i].setting, &settings[i].default_val, nvram_bytes);
|
|
|
|
}
|
2007-01-23 13:40:44 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
static bool write_nvram_data(char* buf, int max_len)
|
2004-06-18 20:41:59 +00:00
|
|
|
{
|
2007-01-23 13:40:44 +00:00
|
|
|
unsigned crc32 = 0xffffffff;
|
|
|
|
int i = 0, buf_pos = 0;
|
|
|
|
char var_count = 0;
|
|
|
|
#ifndef HAVE_RTC_RAM
|
|
|
|
int fd;
|
2004-06-18 20:41:59 +00:00
|
|
|
#endif
|
2007-01-23 13:40:44 +00:00
|
|
|
memset(buf,0,max_len);
|
|
|
|
/* magic, version */
|
|
|
|
buf[0] = 'R'; buf[1] = 'b';
|
|
|
|
buf[2] = NVRAM_CONFIG_VERSION;
|
|
|
|
buf_pos = NVRAM_DATA_START;
|
|
|
|
for(i=0; (i<nb_settings) && (buf_pos<max_len); i++)
|
|
|
|
{
|
|
|
|
int nvram_bytes = (settings[i].flags&F_NVRAM_BYTES_MASK)
|
|
|
|
>>F_NVRAM_MASK_SHIFT;
|
|
|
|
if (nvram_bytes)
|
|
|
|
{
|
|
|
|
memcpy(&buf[buf_pos],settings[i].setting,nvram_bytes);
|
|
|
|
buf_pos += nvram_bytes;
|
|
|
|
var_count++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
/* count and crc32 */
|
|
|
|
buf[3] = var_count;
|
|
|
|
crc32 = crc_32(&buf[NVRAM_DATA_START],
|
|
|
|
max_len-NVRAM_DATA_START-1,0xffffffff);
|
|
|
|
memcpy(&buf[4],&crc32,4);
|
|
|
|
#ifndef HAVE_RTC_RAM
|
|
|
|
fd = open(NVRAM_FILE,O_CREAT|O_TRUNC|O_WRONLY);
|
|
|
|
if (fd >= 0)
|
2006-08-28 22:38:41 +00:00
|
|
|
{
|
2007-01-23 13:40:44 +00:00
|
|
|
int len = write(fd,buf,max_len);
|
|
|
|
close(fd);
|
|
|
|
if (len < 8)
|
|
|
|
return false;
|
|
|
|
}
|
2006-05-14 23:34:24 +00:00
|
|
|
#else
|
2007-01-23 13:40:44 +00:00
|
|
|
/* FIXME: okay, it _would_ be cleaner and faster to implement rtc_write so
|
|
|
|
that it would write a number of bytes at a time since the RTC chip
|
|
|
|
supports that, but this will have to do for now 8-) */
|
|
|
|
for (i=0; i < NVRAM_BLOCK_SIZE; i++ ) {
|
|
|
|
int r = rtc_write(0x14+i, buf[i]);
|
|
|
|
if (r) {
|
|
|
|
DEBUGF( "save_config_buffer: rtc_write failed at addr 0x%02x: %d\n",
|
|
|
|
14+i, r );
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
2006-11-09 12:27:56 +00:00
|
|
|
#endif
|
2007-01-23 13:40:44 +00:00
|
|
|
return true;
|
2004-06-18 20:41:59 +00:00
|
|
|
}
|
2002-07-15 11:02:12 +00:00
|
|
|
|
2007-01-29 13:18:57 +00:00
|
|
|
/** Reading from a config file **/
|
|
|
|
/*
|
|
|
|
* load settings from disk or RTC RAM
|
|
|
|
*/
|
|
|
|
void settings_load(int which)
|
|
|
|
{
|
|
|
|
DEBUGF( "reload_all_settings()\n" );
|
|
|
|
if (which&SETTINGS_RTC)
|
|
|
|
read_nvram_data(nvram_buffer,NVRAM_BLOCK_SIZE);
|
|
|
|
if (which&SETTINGS_HD)
|
|
|
|
{
|
|
|
|
settings_load_config(CONFIGFILE,false);
|
|
|
|
settings_load_config(FIXEDSETTINGSFILE,false);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static bool cfg_string_to_int(int setting_id, int* out, char* str)
|
|
|
|
{
|
|
|
|
const char* start = settings[setting_id].cfg_vals;
|
|
|
|
char* end = NULL;
|
|
|
|
char temp[MAX_PATH];
|
|
|
|
int count = 0;
|
|
|
|
while (1)
|
|
|
|
{
|
|
|
|
end = strchr(start, ',');
|
|
|
|
if (!end)
|
|
|
|
{
|
|
|
|
if (!strcmp(str, start))
|
|
|
|
{
|
|
|
|
*out = count;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
else return false;
|
|
|
|
}
|
|
|
|
strncpy(temp, start, end-start);
|
|
|
|
temp[end-start] = '\0';
|
|
|
|
if (!strcmp(str, temp))
|
|
|
|
{
|
|
|
|
*out = count;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
start = end +1;
|
|
|
|
count++;
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool settings_load_config(const char* file, bool apply)
|
|
|
|
{
|
|
|
|
int fd;
|
|
|
|
char line[128];
|
|
|
|
char* name;
|
|
|
|
char* value;
|
|
|
|
int i;
|
|
|
|
fd = open(file, O_RDONLY);
|
|
|
|
if (fd < 0)
|
|
|
|
return false;
|
|
|
|
|
|
|
|
while (read_line(fd, line, sizeof line) > 0)
|
|
|
|
{
|
|
|
|
if (!settings_parseline(line, &name, &value))
|
|
|
|
continue;
|
|
|
|
for(i=0; i<nb_settings; i++)
|
|
|
|
{
|
|
|
|
if (settings[i].cfg_name == NULL)
|
|
|
|
continue;
|
|
|
|
if (!strcasecmp(name,settings[i].cfg_name))
|
|
|
|
{
|
|
|
|
switch (settings[i].flags&F_T_MASK)
|
|
|
|
{
|
|
|
|
case F_T_INT:
|
|
|
|
case F_T_UINT:
|
|
|
|
#ifdef HAVE_LCD_COLOR
|
|
|
|
if (settings[i].flags&F_RGB)
|
|
|
|
*(int*)settings[i].setting = hex_to_rgb(value);
|
|
|
|
else
|
|
|
|
#endif
|
|
|
|
if (settings[i].cfg_vals == NULL)
|
|
|
|
{
|
|
|
|
*(int*)settings[i].setting = atoi(value);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2007-11-25 17:36:21 +00:00
|
|
|
int temp, *v = (int*)settings[i].setting;
|
|
|
|
bool found = cfg_string_to_int(i, &temp, value);
|
|
|
|
if (found)
|
|
|
|
{
|
|
|
|
if (settings[i].flags&F_TABLE_SETTING)
|
|
|
|
*v = settings[i].table_setting->values[temp];
|
|
|
|
else
|
|
|
|
*v = temp;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
*v = atoi(value);
|
2007-01-29 13:18:57 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
case F_T_BOOL:
|
|
|
|
{
|
|
|
|
int temp;
|
|
|
|
if (cfg_string_to_int(i,&temp,value))
|
|
|
|
*(bool*)settings[i].setting = (temp==0?false:true);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case F_T_CHARPTR:
|
|
|
|
case F_T_UCHARPTR:
|
|
|
|
{
|
|
|
|
char storage[MAX_PATH];
|
|
|
|
if (settings[i].filename_setting->prefix)
|
|
|
|
{
|
|
|
|
int len = strlen(settings[i].filename_setting->prefix);
|
2007-02-12 02:36:32 +00:00
|
|
|
if (!strncasecmp(value,
|
|
|
|
settings[i].filename_setting->prefix,
|
|
|
|
len))
|
2007-01-29 13:18:57 +00:00
|
|
|
{
|
|
|
|
strncpy(storage,&value[len],MAX_PATH);
|
|
|
|
}
|
|
|
|
else strncpy(storage,value,MAX_PATH);
|
|
|
|
}
|
|
|
|
else strncpy(storage,value,MAX_PATH);
|
|
|
|
if (settings[i].filename_setting->suffix)
|
|
|
|
{
|
|
|
|
char *s = strcasestr(storage,settings[i].filename_setting->suffix);
|
|
|
|
if (s) *s = '\0';
|
|
|
|
}
|
|
|
|
strncpy((char*)settings[i].setting,storage,
|
|
|
|
settings[i].filename_setting->max_len);
|
|
|
|
((char*)settings[i].setting)
|
|
|
|
[settings[i].filename_setting->max_len-1] = '\0';
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
} /* if (!strcmp(name,settings[i].cfg_name)) */
|
|
|
|
} /* for(...) */
|
|
|
|
} /* while(...) */
|
|
|
|
|
|
|
|
close(fd);
|
|
|
|
settings_save();
|
|
|
|
if (apply)
|
|
|
|
settings_apply();
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
/** Writing to a config file and saving settings **/
|
2006-02-26 02:48:05 +00:00
|
|
|
|
2007-02-08 10:28:42 +00:00
|
|
|
bool cfg_int_to_string(int setting_id, int val, char* buf, int buf_len)
|
2007-01-29 12:32:56 +00:00
|
|
|
{
|
2007-11-25 17:36:21 +00:00
|
|
|
int flags = settings[setting_id].flags;
|
2007-01-29 12:32:56 +00:00
|
|
|
const char* start = settings[setting_id].cfg_vals;
|
|
|
|
char* end = NULL;
|
|
|
|
int count = 0;
|
2007-11-25 17:36:21 +00:00
|
|
|
|
|
|
|
if ((flags&F_T_MASK)==F_T_INT &&
|
|
|
|
flags&F_TABLE_SETTING)
|
|
|
|
{
|
|
|
|
const int *value = settings[setting_id].table_setting->values;
|
|
|
|
while (start)
|
|
|
|
{
|
|
|
|
end = strchr(start,',');
|
|
|
|
if (value[count] == val)
|
|
|
|
{
|
|
|
|
if (end == NULL)
|
|
|
|
strncpy(buf, start, buf_len);
|
|
|
|
else
|
|
|
|
{
|
|
|
|
int len = (buf_len > (end-start))? end-start: buf_len;
|
|
|
|
strncpy(buf, start, len);
|
|
|
|
buf[len] = '\0';
|
|
|
|
}
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
count++;
|
|
|
|
|
|
|
|
if (end)
|
|
|
|
start = end+1;
|
|
|
|
else
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2007-01-29 12:32:56 +00:00
|
|
|
while (count < val)
|
|
|
|
{
|
|
|
|
start = strchr(start,',');
|
|
|
|
if (!start)
|
|
|
|
return false;
|
|
|
|
count++;
|
|
|
|
start++;
|
|
|
|
}
|
|
|
|
end = strchr(start,',');
|
|
|
|
if (end == NULL)
|
2007-02-08 10:28:42 +00:00
|
|
|
strncpy(buf, start, buf_len);
|
2007-01-29 12:32:56 +00:00
|
|
|
else
|
|
|
|
{
|
2007-02-08 10:28:42 +00:00
|
|
|
int len = (buf_len > (end-start))? end-start: buf_len;
|
|
|
|
strncpy(buf, start, len);
|
|
|
|
buf[len] = '\0';
|
2007-01-29 12:32:56 +00:00
|
|
|
}
|
|
|
|
return true;
|
|
|
|
}
|
2007-02-01 13:57:14 +00:00
|
|
|
static bool is_changed(int setting_id)
|
|
|
|
{
|
2007-02-16 10:20:30 +00:00
|
|
|
const struct settings_list *setting = &settings[setting_id];
|
|
|
|
switch (setting->flags&F_T_MASK)
|
|
|
|
{
|
|
|
|
case F_T_INT:
|
|
|
|
case F_T_UINT:
|
|
|
|
if (setting->flags&F_DEF_ISFUNC)
|
|
|
|
{
|
|
|
|
if (*(int*)setting->setting == setting->default_val.func())
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
else if (setting->flags&F_T_SOUND)
|
|
|
|
{
|
|
|
|
if (*(int*)setting->setting ==
|
|
|
|
sound_default(setting->sound_setting->setting))
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
else if (*(int*)setting->setting == setting->default_val.int_)
|
|
|
|
return false;
|
|
|
|
break;
|
|
|
|
case F_T_BOOL:
|
|
|
|
if (*(bool*)setting->setting == setting->default_val.bool_)
|
|
|
|
return false;
|
|
|
|
break;
|
|
|
|
case F_T_CHARPTR:
|
|
|
|
case F_T_UCHARPTR:
|
|
|
|
if (!strcmp((char*)setting->setting, setting->default_val.charptr))
|
|
|
|
return false;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
return true;
|
2007-02-01 13:57:14 +00:00
|
|
|
}
|
2007-01-25 07:19:45 +00:00
|
|
|
|
2007-02-01 13:57:14 +00:00
|
|
|
static bool settings_write_config(char* filename, int options)
|
2004-09-28 18:09:10 +00:00
|
|
|
{
|
2005-02-11 18:41:40 +00:00
|
|
|
int i;
|
2007-01-23 13:40:44 +00:00
|
|
|
int fd;
|
2007-01-24 03:47:25 +00:00
|
|
|
char value[MAX_PATH];
|
2007-01-23 13:40:44 +00:00
|
|
|
fd = open(filename,O_CREAT|O_TRUNC|O_WRONLY);
|
|
|
|
if (fd < 0)
|
|
|
|
return false;
|
|
|
|
fdprintf(fd, "# .cfg file created by rockbox %s - "
|
|
|
|
"http://www.rockbox.org\r\n\r\n", appsversion);
|
|
|
|
for(i=0; i<nb_settings; i++)
|
2004-09-28 18:09:10 +00:00
|
|
|
{
|
2007-01-23 13:40:44 +00:00
|
|
|
if (settings[i].cfg_name == NULL)
|
|
|
|
continue;
|
2007-01-29 12:32:56 +00:00
|
|
|
value[0] = '\0';
|
2007-02-16 10:20:30 +00:00
|
|
|
|
|
|
|
if ((options == SETTINGS_SAVE_CHANGED) &&
|
|
|
|
!is_changed(i))
|
|
|
|
continue;
|
|
|
|
else if ((options == SETTINGS_SAVE_THEME) &&
|
|
|
|
((settings[i].flags&F_THEMESETTING) == 0))
|
|
|
|
continue;
|
2007-05-29 04:39:11 +00:00
|
|
|
#ifdef HAVE_RECORDING
|
|
|
|
else if ((options == SETTINGS_SAVE_RECPRESETS) &&
|
|
|
|
((settings[i].flags&F_RECSETTING) == 0))
|
|
|
|
continue;
|
|
|
|
#endif
|
2007-01-23 13:40:44 +00:00
|
|
|
switch (settings[i].flags&F_T_MASK)
|
2004-09-28 18:09:10 +00:00
|
|
|
{
|
2007-01-23 13:40:44 +00:00
|
|
|
case F_T_INT:
|
|
|
|
case F_T_UINT:
|
|
|
|
#ifdef HAVE_LCD_COLOR
|
|
|
|
if (settings[i].flags&F_RGB)
|
|
|
|
{
|
|
|
|
int colour = *(int*)settings[i].setting;
|
|
|
|
snprintf(value,MAX_PATH,"%02x%02x%02x",
|
|
|
|
(int)RGB_UNPACK_RED(colour),
|
|
|
|
(int)RGB_UNPACK_GREEN(colour),
|
|
|
|
(int)RGB_UNPACK_BLUE(colour));
|
|
|
|
}
|
|
|
|
else
|
2004-09-28 18:09:10 +00:00
|
|
|
#endif
|
2007-01-23 19:54:09 +00:00
|
|
|
if (settings[i].cfg_vals == NULL)
|
2007-01-23 13:40:44 +00:00
|
|
|
{
|
|
|
|
snprintf(value,MAX_PATH,"%d",*(int*)settings[i].setting);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2007-11-25 17:36:21 +00:00
|
|
|
if (cfg_int_to_string(i, *(int*)settings[i].setting,
|
|
|
|
value, MAX_PATH) == false)
|
|
|
|
{
|
|
|
|
snprintf(value,MAX_PATH,"%d",*(int*)settings[i].setting);
|
|
|
|
}
|
2007-01-23 13:40:44 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
case F_T_BOOL:
|
2007-01-29 12:32:56 +00:00
|
|
|
cfg_int_to_string(i,
|
2007-02-08 10:28:42 +00:00
|
|
|
*(bool*)settings[i].setting==false?0:1, value, MAX_PATH);
|
2007-01-23 13:40:44 +00:00
|
|
|
break;
|
|
|
|
case F_T_CHARPTR:
|
|
|
|
case F_T_UCHARPTR:
|
|
|
|
if (((char*)settings[i].setting)[0] == '\0')
|
|
|
|
break;
|
|
|
|
if (settings[i].filename_setting->prefix)
|
|
|
|
{
|
|
|
|
snprintf(value,MAX_PATH,"%s%s%s",
|
|
|
|
settings[i].filename_setting->prefix,
|
|
|
|
(char*)settings[i].setting,
|
|
|
|
settings[i].filename_setting->suffix);
|
|
|
|
}
|
|
|
|
else strncpy(value,(char*)settings[i].setting,
|
|
|
|
settings[i].filename_setting->max_len);
|
|
|
|
break;
|
|
|
|
} /* switch () */
|
|
|
|
if (value[0])
|
|
|
|
fdprintf(fd,"%s: %s\r\n",settings[i].cfg_name,value);
|
|
|
|
} /* for(...) */
|
|
|
|
close(fd);
|
|
|
|
return true;
|
|
|
|
}
|
2007-01-24 02:19:22 +00:00
|
|
|
#ifndef HAVE_RTC_RAM
|
|
|
|
static bool flush_global_status_callback(void)
|
|
|
|
{
|
|
|
|
return write_nvram_data(nvram_buffer,NVRAM_BLOCK_SIZE);
|
|
|
|
}
|
|
|
|
#endif
|
2007-01-23 13:40:44 +00:00
|
|
|
static bool flush_config_block_callback(void)
|
|
|
|
{
|
|
|
|
bool r1, r2;
|
|
|
|
r1 = write_nvram_data(nvram_buffer,NVRAM_BLOCK_SIZE);
|
2007-02-01 13:57:14 +00:00
|
|
|
r2 = settings_write_config(CONFIGFILE, SETTINGS_SAVE_CHANGED);
|
2007-01-23 13:40:44 +00:00
|
|
|
return r1 || r2;
|
2004-09-28 18:09:10 +00:00
|
|
|
}
|
2004-06-18 20:41:59 +00:00
|
|
|
|
2002-06-27 00:20:00 +00:00
|
|
|
/*
|
2002-07-15 11:02:12 +00:00
|
|
|
* persist all runtime user settings to disk or RTC RAM
|
2002-06-27 00:20:00 +00:00
|
|
|
*/
|
2007-01-24 02:19:22 +00:00
|
|
|
static void update_runtime(void)
|
2002-06-27 00:20:00 +00:00
|
|
|
{
|
2007-01-23 13:40:44 +00:00
|
|
|
int elapsed_secs;
|
2006-04-02 12:23:08 +00:00
|
|
|
|
2007-01-23 13:40:44 +00:00
|
|
|
elapsed_secs = (current_tick - lasttime) / HZ;
|
2007-01-24 02:19:22 +00:00
|
|
|
global_status.runtime += elapsed_secs;
|
2007-01-23 13:40:44 +00:00
|
|
|
lasttime += (elapsed_secs * HZ);
|
2006-04-02 12:23:08 +00:00
|
|
|
|
2007-01-24 02:19:22 +00:00
|
|
|
if ( global_status.runtime > global_status.topruntime )
|
|
|
|
global_status.topruntime = global_status.runtime;
|
|
|
|
}
|
|
|
|
|
|
|
|
void status_save( void )
|
|
|
|
{
|
|
|
|
update_runtime();
|
|
|
|
#ifdef HAVE_RTC_RAM
|
|
|
|
/* this will be done in the ata_callback if
|
|
|
|
target doesnt have rtc ram */
|
|
|
|
write_nvram_data(nvram_buffer,NVRAM_BLOCK_SIZE);
|
|
|
|
#else
|
|
|
|
register_ata_idle_func(flush_global_status_callback);
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
int settings_save( void )
|
|
|
|
{
|
|
|
|
update_runtime();
|
2007-01-23 13:40:44 +00:00
|
|
|
#ifdef HAVE_RTC_RAM
|
|
|
|
/* this will be done in the ata_callback if
|
|
|
|
target doesnt have rtc ram */
|
|
|
|
write_nvram_data(nvram_buffer,NVRAM_BLOCK_SIZE);
|
2006-03-29 16:21:42 +00:00
|
|
|
#endif
|
2007-01-23 13:40:44 +00:00
|
|
|
if(!register_ata_idle_func(flush_config_block_callback))
|
2002-07-28 16:09:44 +00:00
|
|
|
{
|
2007-01-23 13:40:44 +00:00
|
|
|
int i;
|
|
|
|
FOR_NB_SCREENS(i)
|
|
|
|
{
|
|
|
|
screens[i].clear_display();
|
2002-07-28 16:09:44 +00:00
|
|
|
#ifdef HAVE_LCD_CHARCELLS
|
2007-08-05 19:19:39 +00:00
|
|
|
screens[i].puts(0, 0, str(LANG_SETTINGS_SAVE_FAILED));
|
|
|
|
screens[i].puts(0, 1, str(LANG_SETTINGS_PARTITION));
|
2002-07-28 16:09:44 +00:00
|
|
|
#else
|
2007-08-05 19:19:39 +00:00
|
|
|
screens[i].puts(4, 2, str(LANG_SETTINGS_SAVE_FAILED));
|
|
|
|
screens[i].puts(2, 4, str(LANG_SETTINGS_PARTITION));
|
2007-01-23 13:40:44 +00:00
|
|
|
screens[i].update();
|
2002-07-28 16:09:44 +00:00
|
|
|
#endif
|
2007-01-23 13:40:44 +00:00
|
|
|
}
|
2007-08-06 13:08:36 +00:00
|
|
|
cond_talk_ids_fq(LANG_SETTINGS_SAVE_FAILED);
|
2002-07-28 16:09:44 +00:00
|
|
|
sleep(HZ*2);
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
return 0;
|
2002-06-27 00:20:00 +00:00
|
|
|
}
|
2007-02-01 13:57:14 +00:00
|
|
|
bool settings_save_config(int options)
|
2007-01-29 13:18:57 +00:00
|
|
|
{
|
|
|
|
char filename[MAX_PATH];
|
2007-05-29 04:39:11 +00:00
|
|
|
char *folder;
|
|
|
|
switch (options)
|
|
|
|
{
|
|
|
|
case SETTINGS_SAVE_THEME:
|
|
|
|
folder = THEME_DIR;
|
|
|
|
break;
|
|
|
|
#ifdef HAVE_RECORDING
|
|
|
|
case SETTINGS_SAVE_RECPRESETS:
|
|
|
|
folder = RECPRESETS_DIR;
|
|
|
|
break;
|
|
|
|
#endif
|
|
|
|
default:
|
|
|
|
folder = ROCKBOX_DIR;
|
|
|
|
}
|
|
|
|
create_numbered_filename(filename, folder, "config", ".cfg", 2
|
2007-01-29 13:18:57 +00:00
|
|
|
IF_CNFN_NUM_(, NULL));
|
|
|
|
|
|
|
|
/* allow user to modify filename */
|
|
|
|
while (true) {
|
|
|
|
if (!kbd_input(filename, sizeof filename)) {
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
else {
|
2007-08-06 13:08:36 +00:00
|
|
|
gui_syncsplash(HZ, ID2P(LANG_CANCEL));
|
2007-01-29 13:18:57 +00:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2007-02-01 13:57:14 +00:00
|
|
|
if (settings_write_config(filename, options))
|
2007-08-06 13:08:36 +00:00
|
|
|
gui_syncsplash(HZ, ID2P(LANG_SETTINGS_SAVED));
|
2007-02-16 10:20:30 +00:00
|
|
|
else
|
2007-08-06 13:08:36 +00:00
|
|
|
gui_syncsplash(HZ, ID2P(LANG_FAILED));
|
2007-01-29 13:18:57 +00:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
/** Apply and Reset settings **/
|
|
|
|
|
2002-06-27 00:20:00 +00:00
|
|
|
|
2002-10-29 12:09:15 +00:00
|
|
|
#ifdef HAVE_LCD_BITMAP
|
2007-01-29 13:18:57 +00:00
|
|
|
/*
|
2005-11-04 07:18:36 +00:00
|
|
|
* Applies the range infos stored in global_settings to
|
|
|
|
* the peak meter.
|
2002-10-29 12:09:15 +00:00
|
|
|
*/
|
|
|
|
void settings_apply_pm_range(void)
|
|
|
|
{
|
|
|
|
int pm_min, pm_max;
|
|
|
|
|
|
|
|
/* depending on the scale mode (dBfs or percent) the values
|
|
|
|
of global_settings.peak_meter_dbfs have different meanings */
|
2005-11-04 07:18:36 +00:00
|
|
|
if (global_settings.peak_meter_dbfs)
|
2002-10-29 12:09:15 +00:00
|
|
|
{
|
|
|
|
/* convert to dBfs * 100 */
|
|
|
|
pm_min = -(((int)global_settings.peak_meter_min) * 100);
|
|
|
|
pm_max = -(((int)global_settings.peak_meter_max) * 100);
|
|
|
|
}
|
2005-11-04 07:18:36 +00:00
|
|
|
else
|
2002-10-29 12:09:15 +00:00
|
|
|
{
|
|
|
|
/* percent is stored directly -> no conversion */
|
|
|
|
pm_min = global_settings.peak_meter_min;
|
|
|
|
pm_max = global_settings.peak_meter_max;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* apply the range */
|
|
|
|
peak_meter_init_range(global_settings.peak_meter_dbfs, pm_min, pm_max);
|
|
|
|
}
|
|
|
|
#endif /* HAVE_LCD_BITMAP */
|
|
|
|
|
2004-07-06 12:17:14 +00:00
|
|
|
void sound_settings_apply(void)
|
2002-10-03 09:31:01 +00:00
|
|
|
{
|
2007-03-07 19:11:16 +00:00
|
|
|
#if CONFIG_CODEC == SWCODEC
|
2007-02-26 00:41:26 +00:00
|
|
|
sound_set_dsp_callback(dsp_callback);
|
|
|
|
#endif
|
2005-04-01 13:41:03 +00:00
|
|
|
sound_set(SOUND_BASS, global_settings.bass);
|
|
|
|
sound_set(SOUND_TREBLE, global_settings.treble);
|
|
|
|
sound_set(SOUND_BALANCE, global_settings.balance);
|
|
|
|
sound_set(SOUND_VOLUME, global_settings.volume);
|
|
|
|
sound_set(SOUND_CHANNELS, global_settings.channel_config);
|
|
|
|
sound_set(SOUND_STEREO_WIDTH, global_settings.stereo_width);
|
2005-08-29 21:15:27 +00:00
|
|
|
#if (CONFIG_CODEC == MAS3587F) || (CONFIG_CODEC == MAS3539F)
|
2005-04-01 13:41:03 +00:00
|
|
|
sound_set(SOUND_LOUDNESS, global_settings.loudness);
|
|
|
|
sound_set(SOUND_AVC, global_settings.avc);
|
|
|
|
sound_set(SOUND_MDB_STRENGTH, global_settings.mdb_strength);
|
|
|
|
sound_set(SOUND_MDB_HARMONICS, global_settings.mdb_harmonics);
|
|
|
|
sound_set(SOUND_MDB_CENTER, global_settings.mdb_center);
|
|
|
|
sound_set(SOUND_MDB_SHAPE, global_settings.mdb_shape);
|
|
|
|
sound_set(SOUND_MDB_ENABLE, global_settings.mdb_enable);
|
|
|
|
sound_set(SOUND_SUPERBASS, global_settings.superbass);
|
2002-10-03 09:31:01 +00:00
|
|
|
#endif
|
2007-02-01 11:08:35 +00:00
|
|
|
|
2007-11-24 07:51:00 +00:00
|
|
|
#ifdef HAVE_WM8758
|
|
|
|
sound_set(SOUND_BASS_CUTOFF, global_settings.bass_cutoff);
|
|
|
|
sound_set(SOUND_TREBLE_CUTOFF, global_settings.treble_cutoff);
|
|
|
|
#endif
|
|
|
|
|
2007-02-01 11:08:35 +00:00
|
|
|
#ifdef HAVE_USB_POWER
|
2007-02-18 05:32:06 +00:00
|
|
|
#if CONFIG_CHARGING
|
2007-02-01 11:08:35 +00:00
|
|
|
usb_charging_enable(global_settings.usb_charging);
|
|
|
|
#endif
|
|
|
|
#endif
|
2004-07-06 12:17:14 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void settings_apply(void)
|
|
|
|
{
|
|
|
|
char buf[64];
|
2006-02-17 21:55:11 +00:00
|
|
|
#if CONFIG_CODEC == SWCODEC
|
2006-02-17 19:56:22 +00:00
|
|
|
int i;
|
2006-02-17 21:55:11 +00:00
|
|
|
#endif
|
2004-07-06 12:17:14 +00:00
|
|
|
|
2007-01-23 13:40:44 +00:00
|
|
|
DEBUGF( "settings_apply()\n" );
|
2004-07-06 12:17:14 +00:00
|
|
|
sound_settings_apply();
|
2002-10-03 09:31:01 +00:00
|
|
|
|
2007-08-01 08:50:44 +00:00
|
|
|
#ifndef HAVE_FLASH_STORAGE
|
2005-04-04 12:06:29 +00:00
|
|
|
audio_set_buffer_margin(global_settings.buffer_margin);
|
2007-08-01 08:50:44 +00:00
|
|
|
#endif
|
2005-11-04 07:18:36 +00:00
|
|
|
|
2006-07-31 19:13:21 +00:00
|
|
|
#ifdef HAVE_LCD_CONTRAST
|
2002-10-03 09:31:01 +00:00
|
|
|
lcd_set_contrast(global_settings.contrast);
|
2006-07-25 11:15:50 +00:00
|
|
|
#endif
|
2002-10-03 09:31:01 +00:00
|
|
|
lcd_scroll_speed(global_settings.scroll_speed);
|
2005-04-15 12:08:49 +00:00
|
|
|
#ifdef HAVE_REMOTE_LCD
|
2005-06-17 21:43:00 +00:00
|
|
|
lcd_remote_set_contrast(global_settings.remote_contrast);
|
|
|
|
lcd_remote_set_invert_display(global_settings.remote_invert);
|
|
|
|
lcd_remote_set_flip(global_settings.remote_flip_display);
|
2006-05-22 16:40:41 +00:00
|
|
|
lcd_remote_scroll_speed(global_settings.remote_scroll_speed);
|
|
|
|
lcd_remote_scroll_step(global_settings.remote_scroll_step);
|
2007-02-21 13:34:45 +00:00
|
|
|
lcd_remote_scroll_delay(global_settings.remote_scroll_delay);
|
2006-07-22 13:47:11 +00:00
|
|
|
lcd_remote_bidir_scroll(global_settings.remote_bidir_limit);
|
2005-11-19 09:26:02 +00:00
|
|
|
#ifdef HAVE_REMOTE_LCD_TICKING
|
2005-11-19 08:05:03 +00:00
|
|
|
lcd_remote_emireduce(global_settings.remote_reduce_ticking);
|
2005-11-19 09:26:02 +00:00
|
|
|
#endif
|
2005-05-30 00:00:22 +00:00
|
|
|
remote_backlight_set_timeout(global_settings.remote_backlight_timeout);
|
2007-02-18 05:32:06 +00:00
|
|
|
#if CONFIG_CHARGING
|
2005-11-23 20:12:33 +00:00
|
|
|
remote_backlight_set_timeout_plugged(global_settings.remote_backlight_timeout_plugged);
|
|
|
|
#endif
|
2006-09-10 02:00:40 +00:00
|
|
|
#ifdef HAS_REMOTE_BUTTON_HOLD
|
|
|
|
remote_backlight_set_on_button_hold(global_settings.remote_backlight_on_button_hold);
|
2005-06-17 21:43:00 +00:00
|
|
|
#endif
|
2006-09-10 02:00:40 +00:00
|
|
|
#endif /* HAVE_REMOTE_LCD */
|
2007-05-14 04:44:55 +00:00
|
|
|
#ifdef HAVE_BACKLIGHT_BRIGHTNESS
|
|
|
|
backlight_set_brightness(global_settings.brightness);
|
|
|
|
#endif
|
2007-04-12 22:12:13 +00:00
|
|
|
#ifdef HAVE_BACKLIGHT
|
2002-10-03 09:31:01 +00:00
|
|
|
backlight_set_timeout(global_settings.backlight_timeout);
|
2007-02-18 05:32:06 +00:00
|
|
|
#if CONFIG_CHARGING
|
2005-11-23 20:12:33 +00:00
|
|
|
backlight_set_timeout_plugged(global_settings.backlight_timeout_plugged);
|
2005-11-21 23:55:39 +00:00
|
|
|
#endif
|
2006-03-19 17:42:58 +00:00
|
|
|
#if defined(HAVE_BACKLIGHT_PWM_FADING) && !defined(SIMULATOR)
|
2005-06-20 17:03:09 +00:00
|
|
|
backlight_set_fade_in(global_settings.backlight_fade_in);
|
|
|
|
backlight_set_fade_out(global_settings.backlight_fade_out);
|
2005-11-21 23:55:39 +00:00
|
|
|
#endif
|
2005-12-22 10:43:36 +00:00
|
|
|
#endif
|
2007-05-08 06:45:38 +00:00
|
|
|
#ifdef HAVE_BUTTONLIGHT_BRIGHTNESS
|
|
|
|
buttonlight_set_brightness(global_settings.buttonlight_brightness);
|
|
|
|
#endif
|
2007-05-14 04:44:55 +00:00
|
|
|
#ifdef HAVE_BUTTON_LIGHT
|
2007-10-07 15:02:02 +00:00
|
|
|
buttonlight_set_timeout(global_settings.buttonlight_timeout);
|
2005-06-20 17:03:09 +00:00
|
|
|
#endif
|
2007-08-01 08:50:44 +00:00
|
|
|
#ifndef HAVE_FLASH_STORAGE
|
2002-10-03 09:31:01 +00:00
|
|
|
ata_spindown(global_settings.disk_spindown);
|
2007-08-01 08:50:44 +00:00
|
|
|
#endif
|
2005-11-06 23:12:11 +00:00
|
|
|
#if (CONFIG_CODEC == MAS3507D) && !defined(SIMULATOR)
|
2003-11-03 23:36:36 +00:00
|
|
|
dac_line_in(global_settings.line_in);
|
|
|
|
#endif
|
2002-10-03 09:31:01 +00:00
|
|
|
set_poweroff_timeout(global_settings.poweroff);
|
2002-10-08 15:42:40 +00:00
|
|
|
|
2002-12-16 22:58:48 +00:00
|
|
|
set_battery_capacity(global_settings.battery_capacity);
|
2005-01-30 16:25:46 +00:00
|
|
|
#if BATTERY_TYPES_COUNT > 1
|
|
|
|
set_battery_type(global_settings.battery_type);
|
|
|
|
#endif
|
2002-12-16 22:58:48 +00:00
|
|
|
|
2002-10-29 12:09:15 +00:00
|
|
|
#ifdef HAVE_LCD_BITMAP
|
2003-02-27 14:22:30 +00:00
|
|
|
lcd_set_invert_display(global_settings.invert);
|
2003-12-20 10:00:37 +00:00
|
|
|
lcd_set_flip(global_settings.flip_display);
|
|
|
|
button_set_flip(global_settings.flip_display);
|
2007-01-23 13:40:44 +00:00
|
|
|
lcd_update(); /* refresh after flipping the screen */
|
2002-10-29 12:09:15 +00:00
|
|
|
settings_apply_pm_range();
|
|
|
|
peak_meter_init_times(
|
2005-11-04 07:18:36 +00:00
|
|
|
global_settings.peak_meter_release, global_settings.peak_meter_hold,
|
2002-10-29 12:09:15 +00:00
|
|
|
global_settings.peak_meter_clip_hold);
|
|
|
|
#endif
|
|
|
|
|
2006-11-13 00:45:21 +00:00
|
|
|
#if LCD_DEPTH > 1
|
2006-05-21 11:00:02 +00:00
|
|
|
unload_wps_backdrop();
|
2007-04-25 21:44:56 +00:00
|
|
|
#endif
|
|
|
|
#if defined(HAVE_REMOTE_LCD) && LCD_REMOTE_DEPTH > 1
|
|
|
|
unload_remote_wps_backdrop();
|
2006-05-21 11:00:02 +00:00
|
|
|
#endif
|
2005-11-04 07:18:36 +00:00
|
|
|
if ( global_settings.wps_file[0] &&
|
2002-10-09 08:51:08 +00:00
|
|
|
global_settings.wps_file[0] != 0xff ) {
|
2005-11-12 21:48:06 +00:00
|
|
|
snprintf(buf, sizeof buf, WPS_DIR "/%s.wps",
|
2002-10-08 15:42:40 +00:00
|
|
|
global_settings.wps_file);
|
2005-12-09 01:11:14 +00:00
|
|
|
wps_data_load(gui_wps[0].data, buf, true);
|
2002-10-08 15:42:40 +00:00
|
|
|
}
|
2002-10-09 23:13:25 +00:00
|
|
|
else
|
2006-05-21 11:00:02 +00:00
|
|
|
{
|
2005-11-18 09:03:25 +00:00
|
|
|
wps_data_init(gui_wps[0].data);
|
2007-04-25 13:09:56 +00:00
|
|
|
#ifdef HAVE_REMOTE_LCD
|
|
|
|
gui_wps[0].data->remote_wps = false;
|
|
|
|
#endif
|
2006-05-21 11:00:02 +00:00
|
|
|
}
|
2005-11-17 20:14:59 +00:00
|
|
|
|
2006-11-13 00:45:21 +00:00
|
|
|
#if LCD_DEPTH > 1
|
2006-02-02 20:42:56 +00:00
|
|
|
if ( global_settings.backdrop_file[0] &&
|
|
|
|
global_settings.backdrop_file[0] != 0xff ) {
|
|
|
|
snprintf(buf, sizeof buf, BACKDROP_DIR "/%s.bmp",
|
|
|
|
global_settings.backdrop_file);
|
|
|
|
load_main_backdrop(buf);
|
|
|
|
} else {
|
2006-05-21 11:00:02 +00:00
|
|
|
unload_main_backdrop();
|
2006-02-02 20:42:56 +00:00
|
|
|
}
|
2006-05-21 11:00:02 +00:00
|
|
|
show_main_backdrop();
|
2007-01-17 09:49:42 +00:00
|
|
|
#endif
|
2007-04-25 21:44:56 +00:00
|
|
|
#if defined(HAVE_REMOTE_LCD) && LCD_REMOTE_DEPTH > 1
|
|
|
|
show_remote_main_backdrop();
|
|
|
|
#endif
|
2007-01-17 09:49:42 +00:00
|
|
|
|
2006-11-13 00:45:21 +00:00
|
|
|
#ifdef HAVE_LCD_COLOR
|
2006-02-26 02:48:05 +00:00
|
|
|
screens[SCREEN_MAIN].set_foreground(global_settings.fg_color);
|
|
|
|
screens[SCREEN_MAIN].set_background(global_settings.bg_color);
|
2007-09-27 15:42:55 +00:00
|
|
|
screens[SCREEN_MAIN].set_selector_start(global_settings.lss_color);
|
|
|
|
screens[SCREEN_MAIN].set_selector_end(global_settings.lse_color);
|
|
|
|
screens[SCREEN_MAIN].set_selector_text(global_settings.lst_color);
|
2006-02-02 20:42:56 +00:00
|
|
|
#endif
|
|
|
|
|
2005-12-04 12:11:08 +00:00
|
|
|
#if defined(HAVE_REMOTE_LCD) && (NB_SCREENS > 1)
|
2007-02-16 10:20:30 +00:00
|
|
|
if ( global_settings.rwps_file[0]) {
|
2005-11-17 20:14:59 +00:00
|
|
|
snprintf(buf, sizeof buf, WPS_DIR "/%s.rwps",
|
|
|
|
global_settings.rwps_file);
|
2005-12-09 01:11:14 +00:00
|
|
|
wps_data_load(gui_wps[1].data, buf, true);
|
2005-11-17 20:14:59 +00:00
|
|
|
}
|
|
|
|
else
|
2007-04-25 13:09:56 +00:00
|
|
|
{
|
2005-11-18 09:03:25 +00:00
|
|
|
wps_data_init(gui_wps[1].data);
|
2007-04-25 13:09:56 +00:00
|
|
|
gui_wps[1].data->remote_wps = true;
|
|
|
|
}
|
2005-11-17 20:14:59 +00:00
|
|
|
#endif
|
2002-10-09 23:13:25 +00:00
|
|
|
|
2002-10-08 15:42:40 +00:00
|
|
|
#ifdef HAVE_LCD_BITMAP
|
2007-02-16 10:20:30 +00:00
|
|
|
if ( global_settings.font_file[0]) {
|
2006-10-03 10:38:27 +00:00
|
|
|
snprintf(buf, sizeof buf, FONT_DIR "/%s.fnt",
|
2002-10-08 15:42:40 +00:00
|
|
|
global_settings.font_file);
|
|
|
|
font_load(buf);
|
|
|
|
}
|
2002-10-09 23:13:25 +00:00
|
|
|
else
|
|
|
|
font_reset();
|
2002-12-12 15:20:37 +00:00
|
|
|
|
2007-02-16 10:20:30 +00:00
|
|
|
if ( global_settings.kbd_file[0]) {
|
2006-03-29 16:21:42 +00:00
|
|
|
snprintf(buf, sizeof buf, ROCKBOX_DIR "/%s.kbd",
|
|
|
|
global_settings.kbd_file);
|
|
|
|
load_kbd(buf);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
load_kbd(NULL);
|
|
|
|
|
2002-12-12 15:20:37 +00:00
|
|
|
lcd_scroll_step(global_settings.scroll_step);
|
2006-01-22 01:42:05 +00:00
|
|
|
gui_list_screen_scroll_step(global_settings.screen_scroll_step);
|
|
|
|
gui_list_screen_scroll_out_of_view(global_settings.offset_out_of_view);
|
2003-05-22 06:42:14 +00:00
|
|
|
#else
|
|
|
|
lcd_jump_scroll(global_settings.jump_scroll);
|
2007-02-21 13:34:45 +00:00
|
|
|
lcd_jump_scroll_delay(global_settings.jump_scroll_delay);
|
2002-10-08 15:42:40 +00:00
|
|
|
#endif
|
2003-02-12 09:07:48 +00:00
|
|
|
lcd_bidir_scroll(global_settings.bidir_limit);
|
2007-02-21 13:34:45 +00:00
|
|
|
lcd_scroll_delay(global_settings.scroll_delay);
|
2002-10-09 23:13:25 +00:00
|
|
|
|
2007-02-16 10:20:30 +00:00
|
|
|
if ( global_settings.lang_file[0]) {
|
2006-10-03 10:38:27 +00:00
|
|
|
snprintf(buf, sizeof buf, LANG_DIR "/%s.lng",
|
2002-10-08 15:42:40 +00:00
|
|
|
global_settings.lang_file);
|
|
|
|
lang_load(buf);
|
2004-04-06 07:06:59 +00:00
|
|
|
talk_init(); /* use voice of same language */
|
2002-10-08 15:42:40 +00:00
|
|
|
}
|
2005-06-09 09:47:00 +00:00
|
|
|
|
2005-12-06 13:27:15 +00:00
|
|
|
set_codepage(global_settings.default_codepage);
|
|
|
|
|
2005-08-29 21:15:27 +00:00
|
|
|
#if CONFIG_CODEC == SWCODEC
|
2005-07-22 16:46:27 +00:00
|
|
|
audio_set_crossfade(global_settings.crossfade);
|
2007-02-24 17:06:36 +00:00
|
|
|
dsp_set_replaygain();
|
2005-11-14 21:56:56 +00:00
|
|
|
dsp_set_crossfeed(global_settings.crossfeed);
|
2006-04-11 13:49:05 +00:00
|
|
|
dsp_set_crossfeed_direct_gain(global_settings.crossfeed_direct_gain);
|
|
|
|
dsp_set_crossfeed_cross_params(global_settings.crossfeed_cross_gain,
|
2007-03-07 15:06:33 +00:00
|
|
|
global_settings.crossfeed_hf_attenuation,
|
2006-04-11 13:49:05 +00:00
|
|
|
global_settings.crossfeed_hf_cutoff);
|
2006-03-27 21:20:35 +00:00
|
|
|
|
2007-04-11 09:13:13 +00:00
|
|
|
/* Configure software equalizer, hardware eq is handled in audio_init() */
|
2006-03-28 21:19:30 +00:00
|
|
|
dsp_set_eq(global_settings.eq_enabled);
|
2006-03-30 05:56:19 +00:00
|
|
|
dsp_set_eq_precut(global_settings.eq_precut);
|
2006-02-17 19:56:22 +00:00
|
|
|
for(i = 0; i < 5; i++) {
|
2006-03-28 21:19:30 +00:00
|
|
|
dsp_set_eq_coefs(i);
|
2006-02-17 19:56:22 +00:00
|
|
|
}
|
2006-10-27 20:41:33 +00:00
|
|
|
|
|
|
|
dsp_dither_enable(global_settings.dithering_enabled);
|
2005-06-09 09:47:00 +00:00
|
|
|
#endif
|
2005-07-01 09:42:39 +00:00
|
|
|
|
|
|
|
#ifdef HAVE_SPDIF_POWER
|
|
|
|
spdif_power_enable(global_settings.spdif_enable);
|
|
|
|
#endif
|
2006-03-24 13:47:24 +00:00
|
|
|
|
2007-04-12 22:12:13 +00:00
|
|
|
#ifdef HAVE_BACKLIGHT
|
2006-03-24 13:47:24 +00:00
|
|
|
set_backlight_filter_keypress(global_settings.bl_filter_first_keypress);
|
2006-03-25 19:16:45 +00:00
|
|
|
#ifdef HAVE_REMOTE_LCD
|
|
|
|
set_remote_backlight_filter_keypress(global_settings.remote_bl_filter_first_keypress);
|
|
|
|
#endif
|
2006-08-08 22:03:56 +00:00
|
|
|
#ifdef HAS_BUTTON_HOLD
|
|
|
|
backlight_set_on_button_hold(global_settings.backlight_on_button_hold);
|
|
|
|
#endif
|
|
|
|
#ifdef HAVE_LCD_SLEEP
|
|
|
|
lcd_set_sleep_after_backlight_off(global_settings.lcd_sleep_after_backlight_off);
|
2006-03-24 13:47:24 +00:00
|
|
|
#endif
|
2007-04-12 22:12:13 +00:00
|
|
|
#endif /* HAVE_BACKLIGHT */
|
2006-11-06 18:07:30 +00:00
|
|
|
|
|
|
|
/* This should stay last */
|
|
|
|
#if defined(HAVE_RECORDING) && CONFIG_CODEC == SWCODEC
|
|
|
|
enc_global_settings_apply();
|
|
|
|
#endif
|
2007-04-16 09:14:36 +00:00
|
|
|
/* load the icon set */
|
|
|
|
icons_init();
|
2007-06-17 21:16:34 +00:00
|
|
|
|
|
|
|
#ifdef HAVE_LCD_COLOR
|
|
|
|
if (global_settings.colors_file)
|
|
|
|
read_color_theme_file();
|
|
|
|
#endif
|
2007-09-30 12:25:06 +00:00
|
|
|
|
2002-10-03 09:31:01 +00:00
|
|
|
}
|
|
|
|
|
2003-03-10 16:31:02 +00:00
|
|
|
|
2002-06-27 00:20:00 +00:00
|
|
|
/*
|
2005-11-04 07:18:36 +00:00
|
|
|
* reset all settings to their default value
|
2002-06-27 00:20:00 +00:00
|
|
|
*/
|
2002-07-15 11:02:12 +00:00
|
|
|
void settings_reset(void) {
|
2005-11-04 07:18:36 +00:00
|
|
|
|
2007-01-23 13:40:44 +00:00
|
|
|
int i;
|
2002-07-15 11:02:12 +00:00
|
|
|
DEBUGF( "settings_reset()\n" );
|
|
|
|
|
2007-01-23 13:40:44 +00:00
|
|
|
for(i=0; i<nb_settings; i++)
|
|
|
|
{
|
|
|
|
switch (settings[i].flags&F_T_MASK)
|
|
|
|
{
|
|
|
|
case F_T_INT:
|
|
|
|
case F_T_UINT:
|
2007-01-24 03:14:07 +00:00
|
|
|
if (settings[i].flags&F_DEF_ISFUNC)
|
|
|
|
*(int*)settings[i].setting = settings[i].default_val.func();
|
|
|
|
else if (settings[i].flags&F_T_SOUND)
|
2007-01-23 13:40:44 +00:00
|
|
|
*(int*)settings[i].setting =
|
|
|
|
sound_default(settings[i].sound_setting->setting);
|
|
|
|
else *(int*)settings[i].setting = settings[i].default_val.int_;
|
|
|
|
break;
|
|
|
|
case F_T_BOOL:
|
|
|
|
*(bool*)settings[i].setting = settings[i].default_val.bool_;
|
|
|
|
break;
|
|
|
|
case F_T_CHARPTR:
|
|
|
|
case F_T_UCHARPTR:
|
|
|
|
strncpy((char*)settings[i].setting,
|
|
|
|
settings[i].default_val.charptr,MAX_FILENAME);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
} /* for(...) */
|
2006-11-06 18:07:30 +00:00
|
|
|
#if defined (HAVE_RECORDING) && CONFIG_CODEC == SWCODEC
|
|
|
|
enc_global_settings_reset();
|
|
|
|
#endif
|
2002-06-27 00:20:00 +00:00
|
|
|
}
|
2002-06-27 01:08:11 +00:00
|
|
|
|
2007-01-29 13:18:57 +00:00
|
|
|
/** Changing setting values **/
|
2007-02-08 10:28:42 +00:00
|
|
|
const struct settings_list* find_setting(void* variable, int *id)
|
2007-02-08 04:33:41 +00:00
|
|
|
{
|
|
|
|
int i;
|
|
|
|
for(i=0;i<nb_settings;i++)
|
|
|
|
{
|
|
|
|
if (settings[i].setting == variable)
|
2007-02-08 10:28:42 +00:00
|
|
|
{
|
|
|
|
if (id)
|
|
|
|
*id = i;
|
2007-02-08 04:33:41 +00:00
|
|
|
return &settings[i];
|
2007-02-08 10:28:42 +00:00
|
|
|
}
|
2007-02-08 04:33:41 +00:00
|
|
|
}
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
void talk_setting(void *global_settings_variable)
|
|
|
|
{
|
|
|
|
const struct settings_list *setting;
|
2007-10-19 15:31:42 +00:00
|
|
|
if (!global_settings.talk_menu)
|
2007-02-08 04:33:41 +00:00
|
|
|
return;
|
2007-02-08 10:28:42 +00:00
|
|
|
setting = find_setting(global_settings_variable, NULL);
|
2007-02-08 04:33:41 +00:00
|
|
|
if (setting == NULL)
|
|
|
|
return;
|
|
|
|
if (setting->lang_id)
|
|
|
|
talk_id(setting->lang_id,false);
|
|
|
|
}
|
2007-02-16 10:20:30 +00:00
|
|
|
|
2004-08-18 01:09:31 +00:00
|
|
|
bool set_bool(const char* string, bool* variable )
|
2002-06-27 01:08:11 +00:00
|
|
|
{
|
2005-10-16 11:15:51 +00:00
|
|
|
return set_bool_options(string, variable,
|
2005-12-05 22:44:42 +00:00
|
|
|
(char *)STR(LANG_SET_BOOL_YES),
|
|
|
|
(char *)STR(LANG_SET_BOOL_NO),
|
|
|
|
NULL);
|
2003-06-05 11:11:10 +00:00
|
|
|
}
|
|
|
|
|
2002-08-20 19:37:00 +00:00
|
|
|
|
2004-08-18 01:09:31 +00:00
|
|
|
bool set_bool_options(const char* string, bool* variable,
|
|
|
|
const char* yes_str, int yes_voice,
|
|
|
|
const char* no_str, int no_voice,
|
2004-03-15 08:27:51 +00:00
|
|
|
void (*function)(bool))
|
2002-09-05 04:42:12 +00:00
|
|
|
{
|
2005-12-05 22:44:42 +00:00
|
|
|
struct opt_items names[] = {
|
|
|
|
{(unsigned char *)no_str, no_voice},
|
|
|
|
{(unsigned char *)yes_str, yes_voice}
|
|
|
|
};
|
2002-09-24 17:22:12 +00:00
|
|
|
bool result;
|
|
|
|
|
2005-11-04 07:18:36 +00:00
|
|
|
result = set_option(string, variable, BOOL, names, 2,
|
2007-07-11 05:41:23 +00:00
|
|
|
(void (*)(int))function);
|
2002-09-24 17:22:12 +00:00
|
|
|
return result;
|
2002-06-27 01:08:11 +00:00
|
|
|
}
|
|
|
|
|
2007-02-12 14:22:35 +00:00
|
|
|
bool set_int(const unsigned char* string,
|
|
|
|
const char* unit,
|
|
|
|
int voice_unit,
|
|
|
|
int* variable,
|
|
|
|
void (*function)(int),
|
|
|
|
int step,
|
|
|
|
int min,
|
|
|
|
int max,
|
2007-08-19 10:22:46 +00:00
|
|
|
void (*formatter)(char*, size_t, int, const char*) )
|
2007-02-12 14:22:35 +00:00
|
|
|
{
|
|
|
|
return set_int_ex(string, unit, voice_unit, variable, function,
|
|
|
|
step, min, max, formatter, NULL);
|
|
|
|
}
|
2007-07-11 05:41:23 +00:00
|
|
|
|
2002-08-09 12:38:45 +00:00
|
|
|
|
2007-01-29 13:18:57 +00:00
|
|
|
/** extra stuff which is probably misplaced **/
|
|
|
|
|
|
|
|
void set_file(char* filename, char* setting, int maxlen)
|
|
|
|
{
|
|
|
|
char* fptr = strrchr(filename,'/');
|
|
|
|
int len;
|
|
|
|
int extlen = 0;
|
|
|
|
char* ptr;
|
|
|
|
|
|
|
|
if (!fptr)
|
|
|
|
return;
|
|
|
|
|
|
|
|
*fptr = 0;
|
|
|
|
fptr++;
|
|
|
|
|
|
|
|
len = strlen(fptr);
|
|
|
|
ptr = fptr + len;
|
|
|
|
while ((*ptr != '.') && (ptr != fptr)) {
|
|
|
|
extlen++;
|
|
|
|
ptr--;
|
|
|
|
}
|
|
|
|
if(ptr == fptr) extlen = 0;
|
|
|
|
|
|
|
|
if (strncasecmp(ROCKBOX_DIR, filename ,strlen(ROCKBOX_DIR)) ||
|
|
|
|
(len-extlen > maxlen))
|
|
|
|
return;
|
|
|
|
|
|
|
|
strncpy(setting, fptr, len-extlen);
|
|
|
|
setting[len-extlen]=0;
|
|
|
|
|
|
|
|
settings_save();
|
|
|
|
}
|
|
|
|
|