From fe3cfcc9b2b0ce5f0862f891762794ddf42bb6ab Mon Sep 17 00:00:00 2001 From: Jonathan Gordon Date: Thu, 8 Feb 2007 10:28:42 +0000 Subject: [PATCH] Convert the sound menu to the new system git-svn-id: svn://svn.rockbox.org/rockbox/trunk@12230 a1c6a512-1295-4272-9138-f99709370657 --- apps/menu.c | 71 ++++++---- apps/menus/sound_menu.c | 98 +++++++++++++- apps/settings.c | 57 ++++++-- apps/settings.h | 3 +- apps/settings_list.c | 121 ++++++++++++----- apps/settings_list.h | 28 ++-- apps/sound_menu.c | 281 ---------------------------------------- 7 files changed, 301 insertions(+), 358 deletions(-) diff --git a/apps/menu.c b/apps/menu.c index 9c5afbe94a..ae2797ed09 100644 --- a/apps/menu.c +++ b/apps/menu.c @@ -43,6 +43,7 @@ #include "misc.h" #include "action.h" #include "menus/exported_menus.h" +#include "string.h" #ifdef HAVE_LCD_BITMAP #include "icons.h" @@ -370,11 +371,12 @@ static int current_subitems[MAX_MENU_SUBITEMS]; static int current_subitems_count = 0; void get_menu_callback(const struct menu_item_ex *m, - menu_callback_type menu_callback) + menu_callback_type *menu_callback) { if (m->flags&MENU_HAS_DESC) - menu_callback= m->callback_and_desc->menu_callback; - else menu_callback = m->menu_callback; + *menu_callback= m->callback_and_desc->menu_callback; + else + *menu_callback = m->menu_callback; } static int get_menu_selection(int selected_item, const struct menu_item_ex *menu) @@ -403,7 +405,7 @@ static char * get_menu_item_name(int selected_item,void * data, char *buffer) if (type == MT_SETTING) { const struct settings_list *v - = find_setting(menu->variable); + = find_setting(menu->variable, NULL); if (v) return str(v->lang_id); else return "Not Done yet!"; @@ -419,7 +421,7 @@ static void init_menu_lists(const struct menu_item_ex *menu, current_subitems_count = 0; for (i=0; isubmenus[i],menu_callback); + get_menu_callback(menu->submenus[i],&menu_callback); if (menu_callback) { if (menu_callback(ACTION_REQUEST_MENUITEM,menu->submenus[i]) @@ -443,7 +445,7 @@ static void init_menu_lists(const struct menu_item_ex *menu, gui_synclist_limit_scroll(lists,true); gui_synclist_select_item(lists, selected); - get_menu_callback(menu,menu_callback); + get_menu_callback(menu,&menu_callback); if (callback && menu_callback) menu_callback(ACTION_ENTER_MENUITEM,menu); } @@ -505,7 +507,7 @@ int do_menu(const struct menu_item_ex *start_menu) continue; } - get_menu_callback(menu,menu_callback); + get_menu_callback(menu,&menu_callback); if (menu_callback) { action = menu_callback(action,menu); @@ -526,7 +528,7 @@ int do_menu(const struct menu_item_ex *start_menu) in_stringlist = false; if (stack_top > 0) { - get_menu_callback(menu,menu_callback); + get_menu_callback(menu,&menu_callback); if (menu_callback) { if (menu_callback(action,menu) == @@ -551,8 +553,9 @@ int do_menu(const struct menu_item_ex *start_menu) temp = menu->submenus[selected]; if (in_stringlist) type = (menu->flags&MENU_TYPE_MASK); - else type = (temp->flags&MENU_TYPE_MASK); - get_menu_callback(temp,menu_callback); + else + type = (temp->flags&MENU_TYPE_MASK); + get_menu_callback(temp, &menu_callback); if (menu_callback) { action = menu_callback(ACTION_ENTER_MENUITEM,temp); @@ -584,8 +587,10 @@ int do_menu(const struct menu_item_ex *start_menu) break; case MT_SETTING: { + int setting_id; const struct settings_list *setting = find_setting( - temp->variable); + temp->variable, + &setting_id); if (setting) { if ((setting->flags&F_BOOL_SETTING) == F_BOOL_SETTING) @@ -624,11 +629,10 @@ int do_menu(const struct menu_item_ex *start_menu) { var = (int*)setting->setting; } - DEBUGF("%x\n",setting->flags); if (setting->flags&F_INT_SETTING) - {DEBUGF("boo"); + { set_int(str(setting->lang_id), - str(setting->int_setting->unit), + NULL, setting->int_setting->unit,var, setting->int_setting->option_callback, setting->int_setting->step, @@ -639,18 +643,41 @@ int do_menu(const struct menu_item_ex *start_menu) else if (setting->flags&F_CHOICE_SETTING) { static struct opt_items options[MAX_OPTIONS]; + static char buffer[1024]; + char *buf_start = buffer; + int buf_free = 1024; int i,j, count = setting->choice_setting->count; for (i=0, j=0; ichoice_setting->desc[i]); - options[j].voice_id = - P2ID(setting->choice_setting->desc[i]); - j++; + if (setting->flags&F_CHOICETALKS) + { + if (cfg_int_to_string(setting_id, i, + buf_start, buf_free)) + { + int len = strlen(buf_start) +1; + options[j].string = buf_start; + buf_start += len; + buf_free -= len; + options[j].voice_id = + setting->choice_setting->talks[i]; + j++; + } + } + else + { + options[j].string = + P2STR(setting-> + choice_setting->desc[i]); + options[j].voice_id = + P2ID(setting-> + choice_setting->desc[i]); + j++; + } } set_option(str(setting->lang_id), var, INT, - options,count, - setting->choice_setting->option_callback); + options,j, + setting-> + choice_setting->option_callback); } if (setting->flags&F_TEMPVAR) *(int*)setting->setting = temp_var; @@ -675,7 +702,7 @@ int do_menu(const struct menu_item_ex *start_menu) } break; } - get_menu_callback(temp,menu_callback); + get_menu_callback(temp,&menu_callback); if (type != MT_MENU && menu_callback) menu_callback(ACTION_EXIT_MENUITEM,temp); } diff --git a/apps/menus/sound_menu.c b/apps/menus/sound_menu.c index 6d656da14d..9d0e615a29 100644 --- a/apps/menus/sound_menu.c +++ b/apps/menus/sound_menu.c @@ -27,6 +27,102 @@ #include "settings.h" #include "menu.h" #include "sound_menu.h" +#include "eq_menu.h" +#if CONFIG_CODEC == SWCODEC +#include "pcmbuf.h" +#endif -MENUITEM_FUNCTION(sound_settings, ID2P(LANG_SOUND_SETTINGS), (menu_function)sound_menu, NULL); +/***********************************/ +/* SOUND MENU */ +#if CONFIG_CODEC == SWCODEC +int soundmenu_callback(int action,const struct menu_item_ex *this_item) +{ + (void)this_item; + switch (action) + { + case ACTION_ENTER_MENUITEM: /* on entering an item */ + pcmbuf_set_low_latency(true); + break; + case ACTION_EXIT_MENUITEM: /* on exit */ + pcmbuf_set_low_latency(false); + break; + } + return action; +} +#else +#define soundmenu_callback NULL +#endif +MENUITEM_SETTING(volume, &global_settings.volume, soundmenu_callback); + +#ifndef HAVE_TLV320 + MENUITEM_SETTING(bass, &global_settings.bass, soundmenu_callback); + MENUITEM_SETTING(treble, &global_settings.treble, soundmenu_callback); +#endif + +MENUITEM_SETTING(balance, &global_settings.balance, soundmenu_callback); +MENUITEM_SETTING(channel_config, &global_settings.channel_config, soundmenu_callback); +MENUITEM_SETTING(stereo_width, &global_settings.stereo_width, soundmenu_callback); + +#if CONFIG_CODEC == SWCODEC + /* Crossfeed Submenu */ + MENUITEM_SETTING(crossfeed, &global_settings.crossfeed, soundmenu_callback); + MENUITEM_SETTING(crossfeed_direct_gain, + &global_settings.crossfeed_direct_gain, soundmenu_callback); + MENUITEM_SETTING(crossfeed_cross_gain, + &global_settings.crossfeed_cross_gain, soundmenu_callback); + MENUITEM_SETTING(crossfeed_hf_attenuation, + &global_settings.crossfeed_hf_attenuation, soundmenu_callback); + MENUITEM_SETTING(crossfeed_hf_cutoff, + &global_settings.crossfeed_hf_cutoff, soundmenu_callback); + MAKE_MENU(crossfeed_menu,ID2P(LANG_CROSSFEED),soundmenu_callback, + &crossfeed, &crossfeed_direct_gain, &crossfeed_cross_gain, + &crossfeed_hf_attenuation, &crossfeed_hf_cutoff); + + MENUITEM_FUNCTION(equalizer_menu, ID2P(LANG_EQUALIZER), + (int(*)(void))eq_menu, NULL); + MENUITEM_SETTING(dithering_enabled, + &global_settings.dithering_enabled, soundmenu_callback); +#ifdef HAVE_WM8758 + MENUITEM_FUNCTION(hw_equalizer_menu, ID2P(LANG_EQUALIZER_HARDWARE), + (int(*)(void))eq_hw_menu, NULL); +#endif +#endif + +#if (CONFIG_CODEC == MAS3587F) || (CONFIG_CODEC == MAS3539F) + MENUITEM_SETTING(loudness, &global_settings.loudness, NULL); + MENUITEM_SETTING(avc, &global_settings.avc, NULL); + MENUITEM_SETTING(superbass, &global_settings.superbass, NULL); + MENUITEM_SETTING(mdb_enable, &global_settings.mdb_enable, NULL); + MENUITEM_SETTING(mdb_strength, &global_settings.mdb_strength, NULL); + MENUITEM_SETTING(mdb_harmonics, &global_settings.mdb_harmonics, NULL); + MENUITEM_SETTING(mdb_center, &global_settings.mdb_center, NULL); + MENUITEM_SETTING(mdb_shape, &global_settings.mdb_shape, NULL); +#endif + + + +MAKE_MENU(sound_settings, ID2P(LANG_SOUND_SETTINGS), NULL, + &volume, +#ifndef HAVE_TLV320 + &bass,&treble, +#endif + &balance,&channel_config,&stereo_width +#if CONFIG_CODEC == SWCODEC + ,&crossfeed_menu, &equalizer_menu,&dithering_enabled +#endif +#ifdef HAVE_WM8758 + ,&hw_equalizer_menu +#endif +#if (CONFIG_CODEC == MAS3587F) || (CONFIG_CODEC == MAS3539F) + ,&loudness,&avc,&superbass,&mdb_enable,&mdb_strength + ,&mdb_harmonics,&mdb_center,&mdb_shape +#endif + ); +/* SOUND MENU */ +/***********************************/ + +bool sound_menu(void) +{ + return do_menu(&sound_settings); +} diff --git a/apps/settings.c b/apps/settings.c index 4d4a96c639..42a66ace8b 100644 --- a/apps/settings.c +++ b/apps/settings.c @@ -395,7 +395,7 @@ bool settings_load_config(const char* file, bool apply) /** Writing to a config file and saving settings **/ -static bool cfg_int_to_string(int setting_id, int val, char* buf) +bool cfg_int_to_string(int setting_id, int val, char* buf, int buf_len) { const char* start = settings[setting_id].cfg_vals; char* end = NULL; @@ -410,11 +410,12 @@ static bool cfg_int_to_string(int setting_id, int val, char* buf) } end = strchr(start,','); if (end == NULL) - strcpy(buf,start); + strncpy(buf, start, buf_len); else { - strncpy(buf, start, end-start); - buf[end-start] = '\0'; + int len = (buf_len > (end-start))? end-start: buf_len; + strncpy(buf, start, len); + buf[len] = '\0'; } return true; } @@ -496,12 +497,13 @@ static bool settings_write_config(char* filename, int options) } else { - cfg_int_to_string(i,*(int*)settings[i].setting,value); + cfg_int_to_string(i, *(int*)settings[i].setting, + value, MAX_PATH); } break; case F_T_BOOL: cfg_int_to_string(i, - *(bool*)settings[i].setting==false?0:1,value); + *(bool*)settings[i].setting==false?0:1, value, MAX_PATH); break; case F_T_CHARPTR: case F_T_UCHARPTR: @@ -923,13 +925,17 @@ void settings_reset(void) { } /** Changing setting values **/ -const struct settings_list* find_setting(void* variable) +const struct settings_list* find_setting(void* variable, int *id) { int i; for(i=0;ilang_id) @@ -1173,6 +1179,37 @@ static bool do_set_setting(const unsigned char* string, void *variable, return false; } +static const char *unit_strings[] = +{ + [UNIT_INT] + = "", + [UNIT_MS] + = "ms", + [UNIT_SEC] + = "s", + [UNIT_MIN] + = "min", + [UNIT_HOUR] + = "hr", + [UNIT_KHZ] + = "KHz", + [UNIT_DB] + = "dB", + [UNIT_PERCENT] + = "%", + [UNIT_MAH] + = "mAh", + [UNIT_PIXEL] + = "px", + [UNIT_PER_SEC] + = "per sec", + [UNIT_HERTZ] + = "Hz", + [UNIT_MB] + = "MB", + [UNIT_KBIT] + = "kb/s", +}; bool set_int(const unsigned char* string, const char* unit, int voice_unit, @@ -1186,12 +1223,16 @@ bool set_int(const unsigned char* string, #if CONFIG_KEYPAD != PLAYER_PAD struct value_setting_data data = { INT,max, step, voice_unit,unit,formatter,NULL }; + if (unit == NULL) + data.unit = unit_strings[voice_unit]; return do_set_setting(string,variable,(max-min)/step + 1, (max-*variable)/step, &data,function); #else int count = (max-min)/step + 1; struct value_setting_data data = { INT,min, -step, voice_unit,unit,formatter,NULL }; + if (unit == NULL) + data.unit = unit_strings[voice_unit]; return do_set_setting(string,variable,count, count - ((max-*variable)/step), &data,function); #endif diff --git a/apps/settings.h b/apps/settings.h index 8244163e2e..21fd341cd4 100644 --- a/apps/settings.h +++ b/apps/settings.h @@ -224,7 +224,8 @@ struct opt_items { unsigned const char* string; long voice_id; }; -const struct settings_list* find_setting(void* variable); +const struct settings_list* find_setting(void* variable, int *id); +bool cfg_int_to_string(int setting_id, int val, char* buf, int buf_len); void talk_setting(void *global_settings_variable); bool set_sound(const unsigned char * string, int* variable, int setting); diff --git a/apps/settings_list.c b/apps/settings_list.c index 5f784d4998..894c724ddb 100644 --- a/apps/settings_list.c +++ b/apps/settings_list.c @@ -93,8 +93,8 @@ static const char backlight_times_conf [] = #define FUNCTYPE(a) {.func = a} #define NODEFAULT INT(0) -#define SOUND_SETTING(flags,var,lang_id,setting) \ - {flags|F_T_INT|F_T_SOUND, GS(var),lang_id, NODEFAULT,#var,NULL,\ +#define SOUND_SETTING(flags,var,lang_id,name,setting) \ + {flags|F_T_INT|F_T_SOUND, GS(var),lang_id, NODEFAULT,name,NULL,\ {.sound_setting=(struct sound_setting[]){{setting}}} } #define BOOL_SETTING(flags,var,lang_id,default,name,cfgvals,yes,no,opt_cb) \ @@ -119,26 +119,73 @@ static const char backlight_times_conf [] = {flags|F_CHOICE_SETTING|F_T_INT, GS(var), lang_id, \ INT(default), name, cfg_vals, \ {.choice_setting = (struct choice_setting[]){ \ - {cb,count,(unsigned char*[]){__VA_ARGS__}}}}} - + {cb, count, {.desc = (unsigned char*[]){__VA_ARGS__}}}}}} + +#define STRINGCHOICE_SETTING(flags,var,lang_id,default,name,cfg_vals,cb,count,...) \ + {flags|F_CHOICE_SETTING|F_T_INT|F_CHOICETALKS, GS(var), lang_id, \ + INT(default), name, cfg_vals, \ + {.choice_setting = (struct choice_setting[]){ \ + {cb, count, {.talks = (int[]){__VA_ARGS__}}}}}} + #define INT_SETTING(flags, var, lang_id, default, name, cfg_vals, \ unit, min, max, step, formatter, cb) \ {flags|F_INT_SETTING|F_T_INT, GS(var), lang_id, INT(default), \ name, cfg_vals, {.int_setting = (struct int_setting[]){ \ {cb, unit, min, max, step, formatter}}}} +#if CONFIG_CODEC == SWCODEC +static void crossfeed_format(char* buffer, int buffer_size, int value, + const char* unit) +{ + snprintf(buffer, buffer_size, "%s%d.%d %s", value == 0 ? " " : "-", + value / 10, value % 10, unit); +} +static void crossfeed_cross_gain_helper(int val) +{ + dsp_set_crossfeed_cross_params(val, + val + global_settings.crossfeed_hf_attenuation, + global_settings.crossfeed_hf_cutoff); +} +static void crossfeed_hf_att_helper(int val) +{ + dsp_set_crossfeed_cross_params(global_settings.crossfeed_cross_gain, + global_settings.crossfeed_cross_gain + val, + global_settings.crossfeed_hf_cutoff); +} +static void crossfeed_hf_cutoff_helper(int val) +{ + dsp_set_crossfeed_cross_params(global_settings.crossfeed_cross_gain, + global_settings.crossfeed_cross_gain + + global_settings.crossfeed_hf_attenuation, val); +} +#endif +#if (CONFIG_CODEC == MAS3587F) || (CONFIG_CODEC == MAS3539F) +static void set_mdb_enable(bool value) +{ + sound_set_mdb_enable((int)value); +} +static void set_superbass(bool value) +{ + sound_set_superbass((int)value); +} +#endif + const struct settings_list settings[] = { /* sound settings */ - SOUND_SETTING(0,volume, LANG_VOLUME, SOUND_VOLUME), - SOUND_SETTING(0,balance, LANG_BALANCE, SOUND_BALANCE), - SOUND_SETTING(0,bass, LANG_BASS, SOUND_BASS), - SOUND_SETTING(0,treble, LANG_TREBLE, SOUND_TREBLE), + SOUND_SETTING(0,volume, LANG_VOLUME, "volume", SOUND_VOLUME), + SOUND_SETTING(0,balance, LANG_BALANCE, "balance", SOUND_BALANCE), + SOUND_SETTING(0,bass, LANG_BASS, "bass", SOUND_BASS), + SOUND_SETTING(0,treble, LANG_TREBLE, "treble", SOUND_TREBLE), + #if (CONFIG_CODEC == MAS3587F) || (CONFIG_CODEC == MAS3539F) - { F_T_INT, GS(loudness), LANG_LOUDNESS, INT(0), "loudness", NULL, UNUSED }, - { F_T_INT, GS(avc), LANG_AUTOVOL, INT(0), "auto volume", - "off,20ms,2,4,8", UNUSED }, - OFFON_SETTING(0,superbass,LANG_SUPERBASS,false,"superbass",NULL), + SOUND_SETTING(0,loudness, LANG_LOUDNESS, "loudness", SOUND_LOUDNESS), + STRINGCHOICE_SETTING(0,avc,LANG_AUTOVOL,0,"auto volume", + "off,20ms,4,4,8,", sound_set_avc, 5, + LANG_OFF,TALK_ID(20, UNIT_MS),TALK_ID(2, UNIT_SEC), + TALK_ID(4, UNIT_SEC),TALK_ID(8, UNIT_SEC)), + OFFON_SETTING(0, superbass, LANG_SUPERBASS, false, "superbass", set_superbass), #endif + CHOICE_SETTING(0,channel_config,LANG_CHANNEL,0,"channels", "stereo,mono,custom,mono left,mono right,karaoke", #if CONFIG_CODEC == SWCODEC @@ -149,7 +196,8 @@ const struct settings_list settings[] = { 6, ID2P(LANG_CHANNEL_STEREO), ID2P(LANG_CHANNEL_MONO), ID2P(LANG_CHANNEL_CUSTOM), ID2P(LANG_CHANNEL_LEFT), ID2P(LANG_CHANNEL_RIGHT), ID2P(LANG_CHANNEL_KARAOKE)), - SOUND_SETTING(0,stereo_width, LANG_STEREO_WIDTH, SOUND_STEREO_WIDTH), + SOUND_SETTING(0,stereo_width, LANG_STEREO_WIDTH, + "stereo_width", SOUND_STEREO_WIDTH), /* playback */ OFFON_SETTING(0, resume, LANG_RESUME, false, "resume", NULL), OFFON_SETTING(0, playlist_shuffle, LANG_SHUFFLE, false, "shuffle", NULL), @@ -377,13 +425,16 @@ const struct settings_list settings[] = { {F_T_INT,GS(peak_meter_max),LANG_PM_MAX,INT(0),"peak meter max",NULL,UNUSED}, #endif #if (CONFIG_CODEC == MAS3587F) || (CONFIG_CODEC == MAS3539F) - {F_T_INT,GS(mdb_strength),LANG_MDB_STRENGTH,INT(0), - "mdb strength",NULL,UNUSED}, - {F_T_INT,GS(mdb_harmonics),LANG_MDB_HARMONICS,INT(0), - "mdb harmonics",NULL,UNUSED}, - {F_T_INT,GS(mdb_center),LANG_MDB_CENTER,INT(0),"mdb center",NULL,UNUSED}, - {F_T_INT,GS(mdb_shape),LANG_MDB_SHAPE,INT(0),"mdb shape",NULL,UNUSED}, - OFFON_SETTING(0,mdb_enable,LANG_MDB_ENABLE,false,"mdb enable",NULL), + SOUND_SETTING(0, mdb_strength, LANG_MDB_STRENGTH, + "mdb strength", SOUND_MDB_STRENGTH), + SOUND_SETTING(0, mdb_harmonics, LANG_MDB_HARMONICS, + "mdb harmonics", SOUND_MDB_HARMONICS), + SOUND_SETTING(0, mdb_center, LANG_MDB_CENTER, + "mdb center", SOUND_MDB_CENTER), + SOUND_SETTING(0, mdb_shape, LANG_MDB_SHAPE, + "mdb shape", SOUND_MDB_SHAPE), + OFFON_SETTING(0, mdb_enable, LANG_MDB_ENABLE, + false, "mdb enable", set_mdb_enable), #endif #if CONFIG_CODEC == MAS3507D OFFON_SETTING(0,line_in,LANG_LINE_IN,false,"line in",NULL), @@ -520,18 +571,22 @@ const struct settings_list settings[] = { {F_T_INT,GS(crossfade_fade_out_mixmode), LANG_CROSSFADE_FADE_OUT_MODE,INT(0), "crossfade fade out mode","crossfade,mix",UNUSED}, - + /* crossfeed */ - OFFON_SETTING(0,crossfeed,LANG_CROSSFEED,false,"crossfeed",NULL), - {F_T_INT,GS(crossfeed_direct_gain),LANG_CROSSFEED_DIRECT_GAIN,INT(15), - "crossfeed direct gain",NULL,UNUSED}, - {F_T_INT,GS(crossfeed_cross_gain),LANG_CROSSFEED_CROSS_GAIN,INT(60), - "crossfeed cross gain",NULL,UNUSED}, - {F_T_INT,GS(crossfeed_hf_attenuation),LANG_CROSSFEED_HF_ATTENUATION,INT(160), - "crossfeed hf attenuation",NULL,UNUSED}, - {F_T_INT,GS(crossfeed_hf_cutoff),LANG_CROSSFEED_HF_CUTOFF,INT(700), - "crossfeed hf cutoff",NULL,UNUSED}, - + OFFON_SETTING(0,crossfeed, LANG_CROSSFEED, false, + "crossfeed", dsp_set_crossfeed), + INT_SETTING(0, crossfeed_direct_gain, LANG_CROSSFEED_DIRECT_GAIN, 15, + "crossfeed direct gain", NULL, UNIT_DB, 0, 60, 5, + crossfeed_format, dsp_set_crossfeed_direct_gain), + INT_SETTING(0, crossfeed_cross_gain, LANG_CROSSFEED_CROSS_GAIN, 60, + "crossfeed cross gain", NULL, UNIT_DB, 30, 120, 5, + crossfeed_format, crossfeed_cross_gain_helper), + INT_SETTING(0, crossfeed_hf_attenuation, LANG_CROSSFEED_HF_ATTENUATION, 160, + "crossfeed hf attenuation", NULL, UNIT_DB, 60, 240, 5, + crossfeed_format, crossfeed_hf_att_helper), + INT_SETTING(0, crossfeed_hf_cutoff, LANG_CROSSFEED_HF_CUTOFF,700, + "crossfeed hf cutoff", NULL, UNIT_HERTZ, 500, 2000, 100, + crossfeed_format, crossfeed_hf_cutoff_helper), /* equalizer */ OFFON_SETTING(0,eq_enabled,LANG_EQUALIZER_ENABLED,false,"eq enabled",NULL), {F_T_INT,GS(eq_precut),LANG_EQUALIZER_PRECUT,INT(0), @@ -571,8 +626,8 @@ const struct settings_list settings[] = { "eq band 4 gain",NULL,UNUSED}, /* dithering */ - OFFON_SETTING(0,dithering_enabled,LANG_DITHERING, - false,"dithering enabled",NULL), + OFFON_SETTING(0, dithering_enabled, LANG_DITHERING, + false, "dithering enabled", dsp_dither_enable), #endif #ifdef HAVE_DIRCACHE OFFON_SETTING(0,dircache,LANG_DIRCACHE_ENABLE,false,"dircache",NULL), diff --git a/apps/settings_list.h b/apps/settings_list.h index 663d9db228..7a5a445469 100644 --- a/apps/settings_list.h +++ b/apps/settings_list.h @@ -64,22 +64,26 @@ struct filename_setting { #define F_FILENAME 0x40 struct int_setting { - void (*option_callback)(int); - int unit; - int min; - int max; - int step; - void (*formatter)(char*, int, int, const char*); + void (*option_callback)(int); + int unit; + int min; + int max; + int step; + void (*formatter)(char*, int, int, const char*); }; #define F_INT_SETTING 0x80 struct choice_setting { - void (*option_callback)(int); - int count; - unsigned char **desc; + void (*option_callback)(int); + int count; + union { + unsigned char **desc; + int *talks; + }; }; #define F_CHOICE_SETTING 0x100 - +#define F_CHOICETALKS 0x200 /* uses .talks in the above struct for the talks */ + /* and cfg_vals for the strings to display */ /* these use the _isfunc_type type for the function */ /* typedef int (*_isfunc_type)(void); */ #define F_MIN_ISFUNC 0x100000 /* min(above) is function pointer to above type */ @@ -96,10 +100,10 @@ struct choice_setting { - number of bytes for a NVRAM setting is changed - a NVRAM setting is removed */ -#define F_TEMPVAR 0x200 /* used if the setting should be set using a temp var */ +#define F_TEMPVAR 0x400 /* used if the setting should be set using a temp var */ struct settings_list { - uint32_t flags; /* ____ ____ TFFF ____ NNN_ __TC IFRB STTT */ + uint32_t flags; /* ____ ____ TFFF ____ NNN_ _TVC IFRB STTT */ void *setting; int lang_id; /* -1 for none */ union storage_type default_val; diff --git a/apps/sound_menu.c b/apps/sound_menu.c index f7ddc430cc..07f9d4b352 100644 --- a/apps/sound_menu.c +++ b/apps/sound_menu.c @@ -61,201 +61,6 @@ #endif #include "action.h" -static bool volume(void) -{ - return set_sound(str(LANG_VOLUME), &global_settings.volume, SOUND_VOLUME); -} - -static bool balance(void) -{ - return set_sound(str(LANG_BALANCE), &global_settings.balance, - SOUND_BALANCE); -} - -#ifndef HAVE_TLV320 -static bool bass(void) -{ - return set_sound(str(LANG_BASS), &global_settings.bass, SOUND_BASS); -} - -static bool treble(void) -{ - return set_sound(str(LANG_TREBLE), &global_settings.treble, SOUND_TREBLE); -} -#endif - -#if CONFIG_CODEC == SWCODEC -static void crossfeed_format(char* buffer, int buffer_size, int value, - const char* unit) -{ - snprintf(buffer, buffer_size, "%s%d.%d %s", value == 0 ? " " : "-", - value / 10, value % 10, unit); -} - -static bool crossfeed_enabled(void) -{ - bool result = set_bool_options(str(LANG_CROSSFEED), - &global_settings.crossfeed, - STR(LANG_ON), - STR(LANG_OFF), - NULL); - - dsp_set_crossfeed(global_settings.crossfeed); - - return result; -} - -static bool crossfeed_direct_gain(void) -{ - return set_int(str(LANG_CROSSFEED_DIRECT_GAIN), str(LANG_UNIT_DB), - UNIT_DB, &global_settings.crossfeed_direct_gain, - &dsp_set_crossfeed_direct_gain, 5, 0, 60, crossfeed_format); -} - -static void crossfeed_cross_gain_helper(int val) -{ - dsp_set_crossfeed_cross_params(val, - val + global_settings.crossfeed_hf_attenuation, - global_settings.crossfeed_hf_cutoff); -} - -static bool crossfeed_cross_gain(void) -{ - return set_int(str(LANG_CROSSFEED_CROSS_GAIN), str(LANG_UNIT_DB), - UNIT_DB, &global_settings.crossfeed_cross_gain, - &crossfeed_cross_gain_helper, 5, 30, 120, crossfeed_format); -} - -static void crossfeed_hf_att_helper(int val) -{ - dsp_set_crossfeed_cross_params(global_settings.crossfeed_cross_gain, - global_settings.crossfeed_cross_gain + val, - global_settings.crossfeed_hf_cutoff); -} - -static bool crossfeed_hf_attenuation(void) -{ - return set_int(str(LANG_CROSSFEED_HF_ATTENUATION), str(LANG_UNIT_DB), - UNIT_DB, &global_settings.crossfeed_hf_attenuation, - &crossfeed_hf_att_helper, 5, 60, 240, crossfeed_format); -} - -static void crossfeed_hf_cutoff_helper(int val) -{ - dsp_set_crossfeed_cross_params(global_settings.crossfeed_cross_gain, - global_settings.crossfeed_cross_gain + global_settings.crossfeed_hf_attenuation, val); -} - -static bool crossfeed_hf_cutoff(void) -{ - return set_int(str(LANG_CROSSFEED_HF_CUTOFF), str(LANG_UNIT_HERTZ), - UNIT_HERTZ, &global_settings.crossfeed_hf_cutoff, &crossfeed_hf_cutoff_helper, 100, 500, 2000, - NULL); -} - -static bool crossfeed_menu(void) -{ - int m; - bool result; - static const struct menu_item items[] = { - { ID2P(LANG_CROSSFEED), crossfeed_enabled }, - { ID2P(LANG_CROSSFEED_DIRECT_GAIN), crossfeed_direct_gain }, - { ID2P(LANG_CROSSFEED_CROSS_GAIN), crossfeed_cross_gain }, - { ID2P(LANG_CROSSFEED_HF_ATTENUATION), crossfeed_hf_attenuation }, - { ID2P(LANG_CROSSFEED_HF_CUTOFF), crossfeed_hf_cutoff }, - }; - - m=menu_init(items, sizeof(items) / sizeof(*items), NULL, - NULL, NULL, NULL); - result = menu_run(m); - menu_exit(m); - - return result; -} - -static bool dithering_enable(void) -{ - return set_bool_options(str(LANG_DITHERING), - &global_settings.dithering_enabled, - STR(LANG_SET_BOOL_YES), - STR(LANG_SET_BOOL_NO), - dsp_dither_enable); -} -#endif - -#if (CONFIG_CODEC == MAS3587F) || (CONFIG_CODEC == MAS3539F) -static bool loudness(void) -{ - return set_sound(str(LANG_LOUDNESS), &global_settings.loudness, - SOUND_LOUDNESS); -} - -static bool mdb_strength(void) -{ - return set_sound(str(LANG_MDB_STRENGTH), &global_settings.mdb_strength, - SOUND_MDB_STRENGTH); -} - -static bool mdb_harmonics(void) -{ - return set_sound(str(LANG_MDB_HARMONICS), &global_settings.mdb_harmonics, - SOUND_MDB_HARMONICS); -} - -static bool mdb_center(void) -{ - return set_sound(str(LANG_MDB_CENTER), &global_settings.mdb_center, - SOUND_MDB_CENTER); -} - -static bool mdb_shape(void) -{ - return set_sound(str(LANG_MDB_SHAPE), &global_settings.mdb_shape, - SOUND_MDB_SHAPE); -} - -static void set_mdb_enable(bool value) -{ - sound_set_mdb_enable((int)value); -} - -static bool mdb_enable(void) -{ - return set_bool_options(str(LANG_MDB_ENABLE), - &global_settings.mdb_enable, - STR(LANG_SET_BOOL_YES), - STR(LANG_SET_BOOL_NO), - set_mdb_enable); -} - -static void set_superbass(bool value) -{ - sound_set_superbass((int)value); -} - -static bool superbass(void) -{ - return set_bool_options(str(LANG_SUPERBASS), - &global_settings.superbass, - STR(LANG_SET_BOOL_YES), - STR(LANG_SET_BOOL_NO), - set_superbass); -} - -static bool avc(void) -{ - static const struct opt_items names[] = { - { STR(LANG_OFF) }, - { "20ms", TALK_ID(20, UNIT_MS) }, - { "2s", TALK_ID(2, UNIT_SEC) }, - { "4s", TALK_ID(4, UNIT_SEC) }, - { "8s", TALK_ID(8, UNIT_SEC) } - }; - return set_option(str(LANG_DECAY), &global_settings.avc, INT, - names, 5, sound_set_avc); -} -#endif - #ifdef HAVE_RECORDING static bool recsource(void) { @@ -684,93 +489,7 @@ static bool agc_cliptime(void) #endif /* HAVE_AGC */ #endif /* HAVE_RECORDING */ -static bool chanconf(void) -{ - static const struct opt_items names[] = { - { STR(LANG_CHANNEL_STEREO) }, - { STR(LANG_CHANNEL_MONO) }, - { STR(LANG_CHANNEL_CUSTOM) }, - { STR(LANG_CHANNEL_LEFT) }, - { STR(LANG_CHANNEL_RIGHT) }, - { STR(LANG_CHANNEL_KARAOKE) } - }; -#if CONFIG_CODEC == SWCODEC - return set_option(str(LANG_CHANNEL), &global_settings.channel_config, INT, - names, 6, channels_set); -#else - return set_option(str(LANG_CHANNEL), &global_settings.channel_config, INT, - names, 6, sound_set_channels); -#endif -} -static bool stereo_width(void) -{ - return set_sound(str(LANG_STEREO_WIDTH), &global_settings.stereo_width, - SOUND_STEREO_WIDTH); -} - -bool sound_menu(void) -{ - int m; - bool done = false; - int selected; - static const struct menu_item items[] = { - { ID2P(LANG_VOLUME), volume }, -#ifndef HAVE_TLV320 - { ID2P(LANG_BASS), bass }, - { ID2P(LANG_TREBLE), treble }, -#endif - { ID2P(LANG_BALANCE), balance }, - { ID2P(LANG_CHANNEL_MENU), chanconf }, - { ID2P(LANG_STEREO_WIDTH), stereo_width }, -#if CONFIG_CODEC == SWCODEC - { ID2P(LANG_CROSSFEED), crossfeed_menu }, - { ID2P(LANG_EQUALIZER), eq_menu }, - { ID2P(LANG_DITHERING), dithering_enable }, -#endif -#ifdef HAVE_WM8758 - { ID2P(LANG_EQUALIZER_HARDWARE), eq_hw_menu }, -#endif -#if (CONFIG_CODEC == MAS3587F) || (CONFIG_CODEC == MAS3539F) - { ID2P(LANG_LOUDNESS), loudness }, - { ID2P(LANG_AUTOVOL), avc }, - { ID2P(LANG_SUPERBASS), superbass }, - { ID2P(LANG_MDB_ENABLE), mdb_enable }, - { ID2P(LANG_MDB_STRENGTH), mdb_strength }, - { ID2P(LANG_MDB_HARMONICS), mdb_harmonics }, - { ID2P(LANG_MDB_CENTER), mdb_center }, - { ID2P(LANG_MDB_SHAPE), mdb_shape }, -#endif - }; - - m=menu_init( items, sizeof(items) / sizeof(*items), NULL, - NULL, NULL, NULL); - while (!done) - { - switch (selected=menu_show(m)) - { - case MENU_SELECTED_EXIT: - case MENU_ATTACHED_USB: - done = true; - break; - default: -#if CONFIG_CODEC == SWCODEC - pcmbuf_set_low_latency(true); -#endif - if (items[selected].function && - items[selected].function()) - done = true; - -#if CONFIG_CODEC == SWCODEC - pcmbuf_set_low_latency(false); -#endif - gui_syncstatusbar_draw(&statusbars, true); - } - } - menu_exit(m); - - return selected == MENU_SELECTED_EXIT ? false : true; -} #ifdef HAVE_RECORDING enum trigger_menu_option