diff options
author | Jonathan Gordon <rockbox@jdgordon.info> | 2007-02-08 10:28:42 +0000 |
---|---|---|
committer | Jonathan Gordon <rockbox@jdgordon.info> | 2007-02-08 10:28:42 +0000 |
commit | fe3cfcc9b2b0ce5f0862f891762794ddf42bb6ab (patch) | |
tree | 996bf94f160d31eb8879295efb3b159ebdea0042 | |
parent | e645e2dcf2cc03c7e4c9a9d26ac93bbf82e8414b (diff) | |
download | rockbox-fe3cfcc9b2b0ce5f0862f891762794ddf42bb6ab.tar.gz rockbox-fe3cfcc9b2b0ce5f0862f891762794ddf42bb6ab.zip |
Convert the sound menu to the new system
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@12230 a1c6a512-1295-4272-9138-f99709370657
-rw-r--r-- | apps/menu.c | 71 | ||||
-rw-r--r-- | apps/menus/sound_menu.c | 98 | ||||
-rw-r--r-- | apps/settings.c | 57 | ||||
-rw-r--r-- | apps/settings.h | 3 | ||||
-rw-r--r-- | apps/settings_list.c | 123 | ||||
-rw-r--r-- | apps/settings_list.h | 28 | ||||
-rw-r--r-- | apps/sound_menu.c | 281 |
7 files changed, 302 insertions, 359 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 @@ | |||
43 | #include "misc.h" | 43 | #include "misc.h" |
44 | #include "action.h" | 44 | #include "action.h" |
45 | #include "menus/exported_menus.h" | 45 | #include "menus/exported_menus.h" |
46 | #include "string.h" | ||
46 | 47 | ||
47 | #ifdef HAVE_LCD_BITMAP | 48 | #ifdef HAVE_LCD_BITMAP |
48 | #include "icons.h" | 49 | #include "icons.h" |
@@ -370,11 +371,12 @@ static int current_subitems[MAX_MENU_SUBITEMS]; | |||
370 | static int current_subitems_count = 0; | 371 | static int current_subitems_count = 0; |
371 | 372 | ||
372 | void get_menu_callback(const struct menu_item_ex *m, | 373 | void get_menu_callback(const struct menu_item_ex *m, |
373 | menu_callback_type menu_callback) | 374 | menu_callback_type *menu_callback) |
374 | { | 375 | { |
375 | if (m->flags&MENU_HAS_DESC) | 376 | if (m->flags&MENU_HAS_DESC) |
376 | menu_callback= m->callback_and_desc->menu_callback; | 377 | *menu_callback= m->callback_and_desc->menu_callback; |
377 | else menu_callback = m->menu_callback; | 378 | else |
379 | *menu_callback = m->menu_callback; | ||
378 | } | 380 | } |
379 | 381 | ||
380 | static int get_menu_selection(int selected_item, const struct menu_item_ex *menu) | 382 | 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) | |||
403 | if (type == MT_SETTING) | 405 | if (type == MT_SETTING) |
404 | { | 406 | { |
405 | const struct settings_list *v | 407 | const struct settings_list *v |
406 | = find_setting(menu->variable); | 408 | = find_setting(menu->variable, NULL); |
407 | if (v) | 409 | if (v) |
408 | return str(v->lang_id); | 410 | return str(v->lang_id); |
409 | else return "Not Done yet!"; | 411 | else return "Not Done yet!"; |
@@ -419,7 +421,7 @@ static void init_menu_lists(const struct menu_item_ex *menu, | |||
419 | current_subitems_count = 0; | 421 | current_subitems_count = 0; |
420 | for (i=0; i<count; i++) | 422 | for (i=0; i<count; i++) |
421 | { | 423 | { |
422 | get_menu_callback(menu->submenus[i],menu_callback); | 424 | get_menu_callback(menu->submenus[i],&menu_callback); |
423 | if (menu_callback) | 425 | if (menu_callback) |
424 | { | 426 | { |
425 | if (menu_callback(ACTION_REQUEST_MENUITEM,menu->submenus[i]) | 427 | if (menu_callback(ACTION_REQUEST_MENUITEM,menu->submenus[i]) |
@@ -443,7 +445,7 @@ static void init_menu_lists(const struct menu_item_ex *menu, | |||
443 | gui_synclist_limit_scroll(lists,true); | 445 | gui_synclist_limit_scroll(lists,true); |
444 | gui_synclist_select_item(lists, selected); | 446 | gui_synclist_select_item(lists, selected); |
445 | 447 | ||
446 | get_menu_callback(menu,menu_callback); | 448 | get_menu_callback(menu,&menu_callback); |
447 | if (callback && menu_callback) | 449 | if (callback && menu_callback) |
448 | menu_callback(ACTION_ENTER_MENUITEM,menu); | 450 | menu_callback(ACTION_ENTER_MENUITEM,menu); |
449 | } | 451 | } |
@@ -505,7 +507,7 @@ int do_menu(const struct menu_item_ex *start_menu) | |||
505 | continue; | 507 | continue; |
506 | } | 508 | } |
507 | 509 | ||
508 | get_menu_callback(menu,menu_callback); | 510 | get_menu_callback(menu,&menu_callback); |
509 | if (menu_callback) | 511 | if (menu_callback) |
510 | { | 512 | { |
511 | action = menu_callback(action,menu); | 513 | action = menu_callback(action,menu); |
@@ -526,7 +528,7 @@ int do_menu(const struct menu_item_ex *start_menu) | |||
526 | in_stringlist = false; | 528 | in_stringlist = false; |
527 | if (stack_top > 0) | 529 | if (stack_top > 0) |
528 | { | 530 | { |
529 | get_menu_callback(menu,menu_callback); | 531 | get_menu_callback(menu,&menu_callback); |
530 | if (menu_callback) | 532 | if (menu_callback) |
531 | { | 533 | { |
532 | if (menu_callback(action,menu) == | 534 | if (menu_callback(action,menu) == |
@@ -551,8 +553,9 @@ int do_menu(const struct menu_item_ex *start_menu) | |||
551 | temp = menu->submenus[selected]; | 553 | temp = menu->submenus[selected]; |
552 | if (in_stringlist) | 554 | if (in_stringlist) |
553 | type = (menu->flags&MENU_TYPE_MASK); | 555 | type = (menu->flags&MENU_TYPE_MASK); |
554 | else type = (temp->flags&MENU_TYPE_MASK); | 556 | else |
555 | get_menu_callback(temp,menu_callback); | 557 | type = (temp->flags&MENU_TYPE_MASK); |
558 | get_menu_callback(temp, &menu_callback); | ||
556 | if (menu_callback) | 559 | if (menu_callback) |
557 | { | 560 | { |
558 | action = menu_callback(ACTION_ENTER_MENUITEM,temp); | 561 | action = menu_callback(ACTION_ENTER_MENUITEM,temp); |
@@ -584,8 +587,10 @@ int do_menu(const struct menu_item_ex *start_menu) | |||
584 | break; | 587 | break; |
585 | case MT_SETTING: | 588 | case MT_SETTING: |
586 | { | 589 | { |
590 | int setting_id; | ||
587 | const struct settings_list *setting = find_setting( | 591 | const struct settings_list *setting = find_setting( |
588 | temp->variable); | 592 | temp->variable, |
593 | &setting_id); | ||
589 | if (setting) | 594 | if (setting) |
590 | { | 595 | { |
591 | if ((setting->flags&F_BOOL_SETTING) == F_BOOL_SETTING) | 596 | if ((setting->flags&F_BOOL_SETTING) == F_BOOL_SETTING) |
@@ -624,11 +629,10 @@ int do_menu(const struct menu_item_ex *start_menu) | |||
624 | { | 629 | { |
625 | var = (int*)setting->setting; | 630 | var = (int*)setting->setting; |
626 | } | 631 | } |
627 | DEBUGF("%x\n",setting->flags); | ||
628 | if (setting->flags&F_INT_SETTING) | 632 | if (setting->flags&F_INT_SETTING) |
629 | {DEBUGF("boo"); | 633 | { |
630 | set_int(str(setting->lang_id), | 634 | set_int(str(setting->lang_id), |
631 | str(setting->int_setting->unit), | 635 | NULL, |
632 | setting->int_setting->unit,var, | 636 | setting->int_setting->unit,var, |
633 | setting->int_setting->option_callback, | 637 | setting->int_setting->option_callback, |
634 | setting->int_setting->step, | 638 | setting->int_setting->step, |
@@ -639,18 +643,41 @@ int do_menu(const struct menu_item_ex *start_menu) | |||
639 | else if (setting->flags&F_CHOICE_SETTING) | 643 | else if (setting->flags&F_CHOICE_SETTING) |
640 | { | 644 | { |
641 | static struct opt_items options[MAX_OPTIONS]; | 645 | static struct opt_items options[MAX_OPTIONS]; |
646 | static char buffer[1024]; | ||
647 | char *buf_start = buffer; | ||
648 | int buf_free = 1024; | ||
642 | int i,j, count = setting->choice_setting->count; | 649 | int i,j, count = setting->choice_setting->count; |
643 | for (i=0, j=0; i<count && i<MAX_OPTIONS; i++) | 650 | for (i=0, j=0; i<count && i<MAX_OPTIONS; i++) |
644 | { | 651 | { |
645 | options[j].string = | 652 | if (setting->flags&F_CHOICETALKS) |
646 | P2STR(setting->choice_setting->desc[i]); | 653 | { |
647 | options[j].voice_id = | 654 | if (cfg_int_to_string(setting_id, i, |
648 | P2ID(setting->choice_setting->desc[i]); | 655 | buf_start, buf_free)) |
649 | j++; | 656 | { |
657 | int len = strlen(buf_start) +1; | ||
658 | options[j].string = buf_start; | ||
659 | buf_start += len; | ||
660 | buf_free -= len; | ||
661 | options[j].voice_id = | ||
662 | setting->choice_setting->talks[i]; | ||
663 | j++; | ||
664 | } | ||
665 | } | ||
666 | else | ||
667 | { | ||
668 | options[j].string = | ||
669 | P2STR(setting-> | ||
670 | choice_setting->desc[i]); | ||
671 | options[j].voice_id = | ||
672 | P2ID(setting-> | ||
673 | choice_setting->desc[i]); | ||
674 | j++; | ||
675 | } | ||
650 | } | 676 | } |
651 | set_option(str(setting->lang_id), var, INT, | 677 | set_option(str(setting->lang_id), var, INT, |
652 | options,count, | 678 | options,j, |
653 | setting->choice_setting->option_callback); | 679 | setting-> |
680 | choice_setting->option_callback); | ||
654 | } | 681 | } |
655 | if (setting->flags&F_TEMPVAR) | 682 | if (setting->flags&F_TEMPVAR) |
656 | *(int*)setting->setting = temp_var; | 683 | *(int*)setting->setting = temp_var; |
@@ -675,7 +702,7 @@ int do_menu(const struct menu_item_ex *start_menu) | |||
675 | } | 702 | } |
676 | break; | 703 | break; |
677 | } | 704 | } |
678 | get_menu_callback(temp,menu_callback); | 705 | get_menu_callback(temp,&menu_callback); |
679 | if (type != MT_MENU && menu_callback) | 706 | if (type != MT_MENU && menu_callback) |
680 | menu_callback(ACTION_EXIT_MENUITEM,temp); | 707 | menu_callback(ACTION_EXIT_MENUITEM,temp); |
681 | } | 708 | } |
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 @@ | |||
27 | #include "settings.h" | 27 | #include "settings.h" |
28 | #include "menu.h" | 28 | #include "menu.h" |
29 | #include "sound_menu.h" | 29 | #include "sound_menu.h" |
30 | #include "eq_menu.h" | ||
31 | #if CONFIG_CODEC == SWCODEC | ||
32 | #include "pcmbuf.h" | ||
33 | #endif | ||
30 | 34 | ||
31 | MENUITEM_FUNCTION(sound_settings, ID2P(LANG_SOUND_SETTINGS), (menu_function)sound_menu, NULL); | 35 | /***********************************/ |
36 | /* SOUND MENU */ | ||
37 | #if CONFIG_CODEC == SWCODEC | ||
38 | int soundmenu_callback(int action,const struct menu_item_ex *this_item) | ||
39 | { | ||
40 | (void)this_item; | ||
41 | switch (action) | ||
42 | { | ||
43 | case ACTION_ENTER_MENUITEM: /* on entering an item */ | ||
44 | pcmbuf_set_low_latency(true); | ||
45 | break; | ||
46 | case ACTION_EXIT_MENUITEM: /* on exit */ | ||
47 | pcmbuf_set_low_latency(false); | ||
48 | break; | ||
49 | } | ||
50 | return action; | ||
51 | } | ||
52 | #else | ||
53 | #define soundmenu_callback NULL | ||
54 | #endif | ||
32 | 55 | ||
56 | MENUITEM_SETTING(volume, &global_settings.volume, soundmenu_callback); | ||
57 | |||
58 | #ifndef HAVE_TLV320 | ||
59 | MENUITEM_SETTING(bass, &global_settings.bass, soundmenu_callback); | ||
60 | MENUITEM_SETTING(treble, &global_settings.treble, soundmenu_callback); | ||
61 | #endif | ||
62 | |||
63 | MENUITEM_SETTING(balance, &global_settings.balance, soundmenu_callback); | ||
64 | MENUITEM_SETTING(channel_config, &global_settings.channel_config, soundmenu_callback); | ||
65 | MENUITEM_SETTING(stereo_width, &global_settings.stereo_width, soundmenu_callback); | ||
66 | |||
67 | #if CONFIG_CODEC == SWCODEC | ||
68 | /* Crossfeed Submenu */ | ||
69 | MENUITEM_SETTING(crossfeed, &global_settings.crossfeed, soundmenu_callback); | ||
70 | MENUITEM_SETTING(crossfeed_direct_gain, | ||
71 | &global_settings.crossfeed_direct_gain, soundmenu_callback); | ||
72 | MENUITEM_SETTING(crossfeed_cross_gain, | ||
73 | &global_settings.crossfeed_cross_gain, soundmenu_callback); | ||
74 | MENUITEM_SETTING(crossfeed_hf_attenuation, | ||
75 | &global_settings.crossfeed_hf_attenuation, soundmenu_callback); | ||
76 | MENUITEM_SETTING(crossfeed_hf_cutoff, | ||
77 | &global_settings.crossfeed_hf_cutoff, soundmenu_callback); | ||
78 | MAKE_MENU(crossfeed_menu,ID2P(LANG_CROSSFEED),soundmenu_callback, | ||
79 | &crossfeed, &crossfeed_direct_gain, &crossfeed_cross_gain, | ||
80 | &crossfeed_hf_attenuation, &crossfeed_hf_cutoff); | ||
81 | |||
82 | MENUITEM_FUNCTION(equalizer_menu, ID2P(LANG_EQUALIZER), | ||
83 | (int(*)(void))eq_menu, NULL); | ||
84 | MENUITEM_SETTING(dithering_enabled, | ||
85 | &global_settings.dithering_enabled, soundmenu_callback); | ||
86 | #ifdef HAVE_WM8758 | ||
87 | MENUITEM_FUNCTION(hw_equalizer_menu, ID2P(LANG_EQUALIZER_HARDWARE), | ||
88 | (int(*)(void))eq_hw_menu, NULL); | ||
89 | #endif | ||
90 | #endif | ||
91 | |||
92 | #if (CONFIG_CODEC == MAS3587F) || (CONFIG_CODEC == MAS3539F) | ||
93 | MENUITEM_SETTING(loudness, &global_settings.loudness, NULL); | ||
94 | MENUITEM_SETTING(avc, &global_settings.avc, NULL); | ||
95 | MENUITEM_SETTING(superbass, &global_settings.superbass, NULL); | ||
96 | MENUITEM_SETTING(mdb_enable, &global_settings.mdb_enable, NULL); | ||
97 | MENUITEM_SETTING(mdb_strength, &global_settings.mdb_strength, NULL); | ||
98 | MENUITEM_SETTING(mdb_harmonics, &global_settings.mdb_harmonics, NULL); | ||
99 | MENUITEM_SETTING(mdb_center, &global_settings.mdb_center, NULL); | ||
100 | MENUITEM_SETTING(mdb_shape, &global_settings.mdb_shape, NULL); | ||
101 | #endif | ||
102 | |||
103 | |||
104 | |||
105 | MAKE_MENU(sound_settings, ID2P(LANG_SOUND_SETTINGS), NULL, | ||
106 | &volume, | ||
107 | #ifndef HAVE_TLV320 | ||
108 | &bass,&treble, | ||
109 | #endif | ||
110 | &balance,&channel_config,&stereo_width | ||
111 | #if CONFIG_CODEC == SWCODEC | ||
112 | ,&crossfeed_menu, &equalizer_menu,&dithering_enabled | ||
113 | #endif | ||
114 | #ifdef HAVE_WM8758 | ||
115 | ,&hw_equalizer_menu | ||
116 | #endif | ||
117 | #if (CONFIG_CODEC == MAS3587F) || (CONFIG_CODEC == MAS3539F) | ||
118 | ,&loudness,&avc,&superbass,&mdb_enable,&mdb_strength | ||
119 | ,&mdb_harmonics,&mdb_center,&mdb_shape | ||
120 | #endif | ||
121 | ); | ||
122 | /* SOUND MENU */ | ||
123 | /***********************************/ | ||
124 | |||
125 | bool sound_menu(void) | ||
126 | { | ||
127 | return do_menu(&sound_settings); | ||
128 | } | ||
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) | |||
395 | 395 | ||
396 | /** Writing to a config file and saving settings **/ | 396 | /** Writing to a config file and saving settings **/ |
397 | 397 | ||
398 | static bool cfg_int_to_string(int setting_id, int val, char* buf) | 398 | bool cfg_int_to_string(int setting_id, int val, char* buf, int buf_len) |
399 | { | 399 | { |
400 | const char* start = settings[setting_id].cfg_vals; | 400 | const char* start = settings[setting_id].cfg_vals; |
401 | char* end = NULL; | 401 | char* end = NULL; |
@@ -410,11 +410,12 @@ static bool cfg_int_to_string(int setting_id, int val, char* buf) | |||
410 | } | 410 | } |
411 | end = strchr(start,','); | 411 | end = strchr(start,','); |
412 | if (end == NULL) | 412 | if (end == NULL) |
413 | strcpy(buf,start); | 413 | strncpy(buf, start, buf_len); |
414 | else | 414 | else |
415 | { | 415 | { |
416 | strncpy(buf, start, end-start); | 416 | int len = (buf_len > (end-start))? end-start: buf_len; |
417 | buf[end-start] = '\0'; | 417 | strncpy(buf, start, len); |
418 | buf[len] = '\0'; | ||
418 | } | 419 | } |
419 | return true; | 420 | return true; |
420 | } | 421 | } |
@@ -496,12 +497,13 @@ static bool settings_write_config(char* filename, int options) | |||
496 | } | 497 | } |
497 | else | 498 | else |
498 | { | 499 | { |
499 | cfg_int_to_string(i,*(int*)settings[i].setting,value); | 500 | cfg_int_to_string(i, *(int*)settings[i].setting, |
501 | value, MAX_PATH); | ||
500 | } | 502 | } |
501 | break; | 503 | break; |
502 | case F_T_BOOL: | 504 | case F_T_BOOL: |
503 | cfg_int_to_string(i, | 505 | cfg_int_to_string(i, |
504 | *(bool*)settings[i].setting==false?0:1,value); | 506 | *(bool*)settings[i].setting==false?0:1, value, MAX_PATH); |
505 | break; | 507 | break; |
506 | case F_T_CHARPTR: | 508 | case F_T_CHARPTR: |
507 | case F_T_UCHARPTR: | 509 | case F_T_UCHARPTR: |
@@ -923,13 +925,17 @@ void settings_reset(void) { | |||
923 | } | 925 | } |
924 | 926 | ||
925 | /** Changing setting values **/ | 927 | /** Changing setting values **/ |
926 | const struct settings_list* find_setting(void* variable) | 928 | const struct settings_list* find_setting(void* variable, int *id) |
927 | { | 929 | { |
928 | int i; | 930 | int i; |
929 | for(i=0;i<nb_settings;i++) | 931 | for(i=0;i<nb_settings;i++) |
930 | { | 932 | { |
931 | if (settings[i].setting == variable) | 933 | if (settings[i].setting == variable) |
934 | { | ||
935 | if (id) | ||
936 | *id = i; | ||
932 | return &settings[i]; | 937 | return &settings[i]; |
938 | } | ||
933 | } | 939 | } |
934 | return NULL; | 940 | return NULL; |
935 | } | 941 | } |
@@ -939,7 +945,7 @@ void talk_setting(void *global_settings_variable) | |||
939 | const struct settings_list *setting; | 945 | const struct settings_list *setting; |
940 | if (global_settings.talk_menu == 0) | 946 | if (global_settings.talk_menu == 0) |
941 | return; | 947 | return; |
942 | setting = find_setting(global_settings_variable); | 948 | setting = find_setting(global_settings_variable, NULL); |
943 | if (setting == NULL) | 949 | if (setting == NULL) |
944 | return; | 950 | return; |
945 | if (setting->lang_id) | 951 | if (setting->lang_id) |
@@ -1173,6 +1179,37 @@ static bool do_set_setting(const unsigned char* string, void *variable, | |||
1173 | 1179 | ||
1174 | return false; | 1180 | return false; |
1175 | } | 1181 | } |
1182 | static const char *unit_strings[] = | ||
1183 | { | ||
1184 | [UNIT_INT] | ||
1185 | = "", | ||
1186 | [UNIT_MS] | ||
1187 | = "ms", | ||
1188 | [UNIT_SEC] | ||
1189 | = "s", | ||
1190 | [UNIT_MIN] | ||
1191 | = "min", | ||
1192 | [UNIT_HOUR] | ||
1193 | = "hr", | ||
1194 | [UNIT_KHZ] | ||
1195 | = "KHz", | ||
1196 | [UNIT_DB] | ||
1197 | = "dB", | ||
1198 | [UNIT_PERCENT] | ||
1199 | = "%", | ||
1200 | [UNIT_MAH] | ||
1201 | = "mAh", | ||
1202 | [UNIT_PIXEL] | ||
1203 | = "px", | ||
1204 | [UNIT_PER_SEC] | ||
1205 | = "per sec", | ||
1206 | [UNIT_HERTZ] | ||
1207 | = "Hz", | ||
1208 | [UNIT_MB] | ||
1209 | = "MB", | ||
1210 | [UNIT_KBIT] | ||
1211 | = "kb/s", | ||
1212 | }; | ||
1176 | bool set_int(const unsigned char* string, | 1213 | bool set_int(const unsigned char* string, |
1177 | const char* unit, | 1214 | const char* unit, |
1178 | int voice_unit, | 1215 | int voice_unit, |
@@ -1186,12 +1223,16 @@ bool set_int(const unsigned char* string, | |||
1186 | #if CONFIG_KEYPAD != PLAYER_PAD | 1223 | #if CONFIG_KEYPAD != PLAYER_PAD |
1187 | struct value_setting_data data = { | 1224 | struct value_setting_data data = { |
1188 | INT,max, step, voice_unit,unit,formatter,NULL }; | 1225 | INT,max, step, voice_unit,unit,formatter,NULL }; |
1226 | if (unit == NULL) | ||
1227 | data.unit = unit_strings[voice_unit]; | ||
1189 | return do_set_setting(string,variable,(max-min)/step + 1, | 1228 | return do_set_setting(string,variable,(max-min)/step + 1, |
1190 | (max-*variable)/step, &data,function); | 1229 | (max-*variable)/step, &data,function); |
1191 | #else | 1230 | #else |
1192 | int count = (max-min)/step + 1; | 1231 | int count = (max-min)/step + 1; |
1193 | struct value_setting_data data = { | 1232 | struct value_setting_data data = { |
1194 | INT,min, -step, voice_unit,unit,formatter,NULL }; | 1233 | INT,min, -step, voice_unit,unit,formatter,NULL }; |
1234 | if (unit == NULL) | ||
1235 | data.unit = unit_strings[voice_unit]; | ||
1195 | return do_set_setting(string,variable,count, | 1236 | return do_set_setting(string,variable,count, |
1196 | count - ((max-*variable)/step), &data,function); | 1237 | count - ((max-*variable)/step), &data,function); |
1197 | #endif | 1238 | #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 { | |||
224 | unsigned const char* string; | 224 | unsigned const char* string; |
225 | long voice_id; | 225 | long voice_id; |
226 | }; | 226 | }; |
227 | const struct settings_list* find_setting(void* variable); | 227 | const struct settings_list* find_setting(void* variable, int *id); |
228 | bool cfg_int_to_string(int setting_id, int val, char* buf, int buf_len); | ||
228 | void talk_setting(void *global_settings_variable); | 229 | void talk_setting(void *global_settings_variable); |
229 | bool set_sound(const unsigned char * string, | 230 | bool set_sound(const unsigned char * string, |
230 | int* variable, int setting); | 231 | 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 [] = | |||
93 | #define FUNCTYPE(a) {.func = a} | 93 | #define FUNCTYPE(a) {.func = a} |
94 | #define NODEFAULT INT(0) | 94 | #define NODEFAULT INT(0) |
95 | 95 | ||
96 | #define SOUND_SETTING(flags,var,lang_id,setting) \ | 96 | #define SOUND_SETTING(flags,var,lang_id,name,setting) \ |
97 | {flags|F_T_INT|F_T_SOUND, GS(var),lang_id, NODEFAULT,#var,NULL,\ | 97 | {flags|F_T_INT|F_T_SOUND, GS(var),lang_id, NODEFAULT,name,NULL,\ |
98 | {.sound_setting=(struct sound_setting[]){{setting}}} } | 98 | {.sound_setting=(struct sound_setting[]){{setting}}} } |
99 | 99 | ||
100 | #define BOOL_SETTING(flags,var,lang_id,default,name,cfgvals,yes,no,opt_cb) \ | 100 | #define BOOL_SETTING(flags,var,lang_id,default,name,cfgvals,yes,no,opt_cb) \ |
@@ -119,26 +119,73 @@ static const char backlight_times_conf [] = | |||
119 | {flags|F_CHOICE_SETTING|F_T_INT, GS(var), lang_id, \ | 119 | {flags|F_CHOICE_SETTING|F_T_INT, GS(var), lang_id, \ |
120 | INT(default), name, cfg_vals, \ | 120 | INT(default), name, cfg_vals, \ |
121 | {.choice_setting = (struct choice_setting[]){ \ | 121 | {.choice_setting = (struct choice_setting[]){ \ |
122 | {cb,count,(unsigned char*[]){__VA_ARGS__}}}}} | 122 | {cb, count, {.desc = (unsigned char*[]){__VA_ARGS__}}}}}} |
123 | 123 | ||
124 | #define STRINGCHOICE_SETTING(flags,var,lang_id,default,name,cfg_vals,cb,count,...) \ | ||
125 | {flags|F_CHOICE_SETTING|F_T_INT|F_CHOICETALKS, GS(var), lang_id, \ | ||
126 | INT(default), name, cfg_vals, \ | ||
127 | {.choice_setting = (struct choice_setting[]){ \ | ||
128 | {cb, count, {.talks = (int[]){__VA_ARGS__}}}}}} | ||
129 | |||
124 | #define INT_SETTING(flags, var, lang_id, default, name, cfg_vals, \ | 130 | #define INT_SETTING(flags, var, lang_id, default, name, cfg_vals, \ |
125 | unit, min, max, step, formatter, cb) \ | 131 | unit, min, max, step, formatter, cb) \ |
126 | {flags|F_INT_SETTING|F_T_INT, GS(var), lang_id, INT(default), \ | 132 | {flags|F_INT_SETTING|F_T_INT, GS(var), lang_id, INT(default), \ |
127 | name, cfg_vals, {.int_setting = (struct int_setting[]){ \ | 133 | name, cfg_vals, {.int_setting = (struct int_setting[]){ \ |
128 | {cb, unit, min, max, step, formatter}}}} | 134 | {cb, unit, min, max, step, formatter}}}} |
129 | 135 | ||
136 | #if CONFIG_CODEC == SWCODEC | ||
137 | static void crossfeed_format(char* buffer, int buffer_size, int value, | ||
138 | const char* unit) | ||
139 | { | ||
140 | snprintf(buffer, buffer_size, "%s%d.%d %s", value == 0 ? " " : "-", | ||
141 | value / 10, value % 10, unit); | ||
142 | } | ||
143 | static void crossfeed_cross_gain_helper(int val) | ||
144 | { | ||
145 | dsp_set_crossfeed_cross_params(val, | ||
146 | val + global_settings.crossfeed_hf_attenuation, | ||
147 | global_settings.crossfeed_hf_cutoff); | ||
148 | } | ||
149 | static void crossfeed_hf_att_helper(int val) | ||
150 | { | ||
151 | dsp_set_crossfeed_cross_params(global_settings.crossfeed_cross_gain, | ||
152 | global_settings.crossfeed_cross_gain + val, | ||
153 | global_settings.crossfeed_hf_cutoff); | ||
154 | } | ||
155 | static void crossfeed_hf_cutoff_helper(int val) | ||
156 | { | ||
157 | dsp_set_crossfeed_cross_params(global_settings.crossfeed_cross_gain, | ||
158 | global_settings.crossfeed_cross_gain | ||
159 | + global_settings.crossfeed_hf_attenuation, val); | ||
160 | } | ||
161 | #endif | ||
162 | #if (CONFIG_CODEC == MAS3587F) || (CONFIG_CODEC == MAS3539F) | ||
163 | static void set_mdb_enable(bool value) | ||
164 | { | ||
165 | sound_set_mdb_enable((int)value); | ||
166 | } | ||
167 | static void set_superbass(bool value) | ||
168 | { | ||
169 | sound_set_superbass((int)value); | ||
170 | } | ||
171 | #endif | ||
172 | |||
130 | const struct settings_list settings[] = { | 173 | const struct settings_list settings[] = { |
131 | /* sound settings */ | 174 | /* sound settings */ |
132 | SOUND_SETTING(0,volume, LANG_VOLUME, SOUND_VOLUME), | 175 | SOUND_SETTING(0,volume, LANG_VOLUME, "volume", SOUND_VOLUME), |
133 | SOUND_SETTING(0,balance, LANG_BALANCE, SOUND_BALANCE), | 176 | SOUND_SETTING(0,balance, LANG_BALANCE, "balance", SOUND_BALANCE), |
134 | SOUND_SETTING(0,bass, LANG_BASS, SOUND_BASS), | 177 | SOUND_SETTING(0,bass, LANG_BASS, "bass", SOUND_BASS), |
135 | SOUND_SETTING(0,treble, LANG_TREBLE, SOUND_TREBLE), | 178 | SOUND_SETTING(0,treble, LANG_TREBLE, "treble", SOUND_TREBLE), |
179 | |||
136 | #if (CONFIG_CODEC == MAS3587F) || (CONFIG_CODEC == MAS3539F) | 180 | #if (CONFIG_CODEC == MAS3587F) || (CONFIG_CODEC == MAS3539F) |
137 | { F_T_INT, GS(loudness), LANG_LOUDNESS, INT(0), "loudness", NULL, UNUSED }, | 181 | SOUND_SETTING(0,loudness, LANG_LOUDNESS, "loudness", SOUND_LOUDNESS), |
138 | { F_T_INT, GS(avc), LANG_AUTOVOL, INT(0), "auto volume", | 182 | STRINGCHOICE_SETTING(0,avc,LANG_AUTOVOL,0,"auto volume", |
139 | "off,20ms,2,4,8", UNUSED }, | 183 | "off,20ms,4,4,8,", sound_set_avc, 5, |
140 | OFFON_SETTING(0,superbass,LANG_SUPERBASS,false,"superbass",NULL), | 184 | LANG_OFF,TALK_ID(20, UNIT_MS),TALK_ID(2, UNIT_SEC), |
141 | #endif | 185 | TALK_ID(4, UNIT_SEC),TALK_ID(8, UNIT_SEC)), |
186 | OFFON_SETTING(0, superbass, LANG_SUPERBASS, false, "superbass", set_superbass), | ||
187 | #endif | ||
188 | |||
142 | CHOICE_SETTING(0,channel_config,LANG_CHANNEL,0,"channels", | 189 | CHOICE_SETTING(0,channel_config,LANG_CHANNEL,0,"channels", |
143 | "stereo,mono,custom,mono left,mono right,karaoke", | 190 | "stereo,mono,custom,mono left,mono right,karaoke", |
144 | #if CONFIG_CODEC == SWCODEC | 191 | #if CONFIG_CODEC == SWCODEC |
@@ -149,7 +196,8 @@ const struct settings_list settings[] = { | |||
149 | 6, ID2P(LANG_CHANNEL_STEREO), ID2P(LANG_CHANNEL_MONO), | 196 | 6, ID2P(LANG_CHANNEL_STEREO), ID2P(LANG_CHANNEL_MONO), |
150 | ID2P(LANG_CHANNEL_CUSTOM), ID2P(LANG_CHANNEL_LEFT), | 197 | ID2P(LANG_CHANNEL_CUSTOM), ID2P(LANG_CHANNEL_LEFT), |
151 | ID2P(LANG_CHANNEL_RIGHT), ID2P(LANG_CHANNEL_KARAOKE)), | 198 | ID2P(LANG_CHANNEL_RIGHT), ID2P(LANG_CHANNEL_KARAOKE)), |
152 | SOUND_SETTING(0,stereo_width, LANG_STEREO_WIDTH, SOUND_STEREO_WIDTH), | 199 | SOUND_SETTING(0,stereo_width, LANG_STEREO_WIDTH, |
200 | "stereo_width", SOUND_STEREO_WIDTH), | ||
153 | /* playback */ | 201 | /* playback */ |
154 | OFFON_SETTING(0, resume, LANG_RESUME, false, "resume", NULL), | 202 | OFFON_SETTING(0, resume, LANG_RESUME, false, "resume", NULL), |
155 | OFFON_SETTING(0, playlist_shuffle, LANG_SHUFFLE, false, "shuffle", NULL), | 203 | OFFON_SETTING(0, playlist_shuffle, LANG_SHUFFLE, false, "shuffle", NULL), |
@@ -377,13 +425,16 @@ const struct settings_list settings[] = { | |||
377 | {F_T_INT,GS(peak_meter_max),LANG_PM_MAX,INT(0),"peak meter max",NULL,UNUSED}, | 425 | {F_T_INT,GS(peak_meter_max),LANG_PM_MAX,INT(0),"peak meter max",NULL,UNUSED}, |
378 | #endif | 426 | #endif |
379 | #if (CONFIG_CODEC == MAS3587F) || (CONFIG_CODEC == MAS3539F) | 427 | #if (CONFIG_CODEC == MAS3587F) || (CONFIG_CODEC == MAS3539F) |
380 | {F_T_INT,GS(mdb_strength),LANG_MDB_STRENGTH,INT(0), | 428 | SOUND_SETTING(0, mdb_strength, LANG_MDB_STRENGTH, |
381 | "mdb strength",NULL,UNUSED}, | 429 | "mdb strength", SOUND_MDB_STRENGTH), |
382 | {F_T_INT,GS(mdb_harmonics),LANG_MDB_HARMONICS,INT(0), | 430 | SOUND_SETTING(0, mdb_harmonics, LANG_MDB_HARMONICS, |
383 | "mdb harmonics",NULL,UNUSED}, | 431 | "mdb harmonics", SOUND_MDB_HARMONICS), |
384 | {F_T_INT,GS(mdb_center),LANG_MDB_CENTER,INT(0),"mdb center",NULL,UNUSED}, | 432 | SOUND_SETTING(0, mdb_center, LANG_MDB_CENTER, |
385 | {F_T_INT,GS(mdb_shape),LANG_MDB_SHAPE,INT(0),"mdb shape",NULL,UNUSED}, | 433 | "mdb center", SOUND_MDB_CENTER), |
386 | OFFON_SETTING(0,mdb_enable,LANG_MDB_ENABLE,false,"mdb enable",NULL), | 434 | SOUND_SETTING(0, mdb_shape, LANG_MDB_SHAPE, |
435 | "mdb shape", SOUND_MDB_SHAPE), | ||
436 | OFFON_SETTING(0, mdb_enable, LANG_MDB_ENABLE, | ||
437 | false, "mdb enable", set_mdb_enable), | ||
387 | #endif | 438 | #endif |
388 | #if CONFIG_CODEC == MAS3507D | 439 | #if CONFIG_CODEC == MAS3507D |
389 | OFFON_SETTING(0,line_in,LANG_LINE_IN,false,"line in",NULL), | 440 | OFFON_SETTING(0,line_in,LANG_LINE_IN,false,"line in",NULL), |
@@ -520,18 +571,22 @@ const struct settings_list settings[] = { | |||
520 | {F_T_INT,GS(crossfade_fade_out_mixmode), | 571 | {F_T_INT,GS(crossfade_fade_out_mixmode), |
521 | LANG_CROSSFADE_FADE_OUT_MODE,INT(0), | 572 | LANG_CROSSFADE_FADE_OUT_MODE,INT(0), |
522 | "crossfade fade out mode","crossfade,mix",UNUSED}, | 573 | "crossfade fade out mode","crossfade,mix",UNUSED}, |
523 | 574 | ||
524 | /* crossfeed */ | 575 | /* crossfeed */ |
525 | OFFON_SETTING(0,crossfeed,LANG_CROSSFEED,false,"crossfeed",NULL), | 576 | OFFON_SETTING(0,crossfeed, LANG_CROSSFEED, false, |
526 | {F_T_INT,GS(crossfeed_direct_gain),LANG_CROSSFEED_DIRECT_GAIN,INT(15), | 577 | "crossfeed", dsp_set_crossfeed), |
527 | "crossfeed direct gain",NULL,UNUSED}, | 578 | INT_SETTING(0, crossfeed_direct_gain, LANG_CROSSFEED_DIRECT_GAIN, 15, |
528 | {F_T_INT,GS(crossfeed_cross_gain),LANG_CROSSFEED_CROSS_GAIN,INT(60), | 579 | "crossfeed direct gain", NULL, UNIT_DB, 0, 60, 5, |
529 | "crossfeed cross gain",NULL,UNUSED}, | 580 | crossfeed_format, dsp_set_crossfeed_direct_gain), |
530 | {F_T_INT,GS(crossfeed_hf_attenuation),LANG_CROSSFEED_HF_ATTENUATION,INT(160), | 581 | INT_SETTING(0, crossfeed_cross_gain, LANG_CROSSFEED_CROSS_GAIN, 60, |
531 | "crossfeed hf attenuation",NULL,UNUSED}, | 582 | "crossfeed cross gain", NULL, UNIT_DB, 30, 120, 5, |
532 | {F_T_INT,GS(crossfeed_hf_cutoff),LANG_CROSSFEED_HF_CUTOFF,INT(700), | 583 | crossfeed_format, crossfeed_cross_gain_helper), |
533 | "crossfeed hf cutoff",NULL,UNUSED}, | 584 | INT_SETTING(0, crossfeed_hf_attenuation, LANG_CROSSFEED_HF_ATTENUATION, 160, |
534 | 585 | "crossfeed hf attenuation", NULL, UNIT_DB, 60, 240, 5, | |
586 | crossfeed_format, crossfeed_hf_att_helper), | ||
587 | INT_SETTING(0, crossfeed_hf_cutoff, LANG_CROSSFEED_HF_CUTOFF,700, | ||
588 | "crossfeed hf cutoff", NULL, UNIT_HERTZ, 500, 2000, 100, | ||
589 | crossfeed_format, crossfeed_hf_cutoff_helper), | ||
535 | /* equalizer */ | 590 | /* equalizer */ |
536 | OFFON_SETTING(0,eq_enabled,LANG_EQUALIZER_ENABLED,false,"eq enabled",NULL), | 591 | OFFON_SETTING(0,eq_enabled,LANG_EQUALIZER_ENABLED,false,"eq enabled",NULL), |
537 | {F_T_INT,GS(eq_precut),LANG_EQUALIZER_PRECUT,INT(0), | 592 | {F_T_INT,GS(eq_precut),LANG_EQUALIZER_PRECUT,INT(0), |
@@ -571,8 +626,8 @@ const struct settings_list settings[] = { | |||
571 | "eq band 4 gain",NULL,UNUSED}, | 626 | "eq band 4 gain",NULL,UNUSED}, |
572 | 627 | ||
573 | /* dithering */ | 628 | /* dithering */ |
574 | OFFON_SETTING(0,dithering_enabled,LANG_DITHERING, | 629 | OFFON_SETTING(0, dithering_enabled, LANG_DITHERING, |
575 | false,"dithering enabled",NULL), | 630 | false, "dithering enabled", dsp_dither_enable), |
576 | #endif | 631 | #endif |
577 | #ifdef HAVE_DIRCACHE | 632 | #ifdef HAVE_DIRCACHE |
578 | OFFON_SETTING(0,dircache,LANG_DIRCACHE_ENABLE,false,"dircache",NULL), | 633 | 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 { | |||
64 | #define F_FILENAME 0x40 | 64 | #define F_FILENAME 0x40 |
65 | 65 | ||
66 | struct int_setting { | 66 | struct int_setting { |
67 | void (*option_callback)(int); | 67 | void (*option_callback)(int); |
68 | int unit; | 68 | int unit; |
69 | int min; | 69 | int min; |
70 | int max; | 70 | int max; |
71 | int step; | 71 | int step; |
72 | void (*formatter)(char*, int, int, const char*); | 72 | void (*formatter)(char*, int, int, const char*); |
73 | }; | 73 | }; |
74 | #define F_INT_SETTING 0x80 | 74 | #define F_INT_SETTING 0x80 |
75 | 75 | ||
76 | struct choice_setting { | 76 | struct choice_setting { |
77 | void (*option_callback)(int); | 77 | void (*option_callback)(int); |
78 | int count; | 78 | int count; |
79 | unsigned char **desc; | 79 | union { |
80 | unsigned char **desc; | ||
81 | int *talks; | ||
82 | }; | ||
80 | }; | 83 | }; |
81 | #define F_CHOICE_SETTING 0x100 | 84 | #define F_CHOICE_SETTING 0x100 |
82 | 85 | #define F_CHOICETALKS 0x200 /* uses .talks in the above struct for the talks */ | |
86 | /* and cfg_vals for the strings to display */ | ||
83 | /* these use the _isfunc_type type for the function */ | 87 | /* these use the _isfunc_type type for the function */ |
84 | /* typedef int (*_isfunc_type)(void); */ | 88 | /* typedef int (*_isfunc_type)(void); */ |
85 | #define F_MIN_ISFUNC 0x100000 /* min(above) is function pointer to above type */ | 89 | #define F_MIN_ISFUNC 0x100000 /* min(above) is function pointer to above type */ |
@@ -96,10 +100,10 @@ struct choice_setting { | |||
96 | - number of bytes for a NVRAM setting is changed | 100 | - number of bytes for a NVRAM setting is changed |
97 | - a NVRAM setting is removed | 101 | - a NVRAM setting is removed |
98 | */ | 102 | */ |
99 | #define F_TEMPVAR 0x200 /* used if the setting should be set using a temp var */ | 103 | #define F_TEMPVAR 0x400 /* used if the setting should be set using a temp var */ |
100 | 104 | ||
101 | struct settings_list { | 105 | struct settings_list { |
102 | uint32_t flags; /* ____ ____ TFFF ____ NNN_ __TC IFRB STTT */ | 106 | uint32_t flags; /* ____ ____ TFFF ____ NNN_ _TVC IFRB STTT */ |
103 | void *setting; | 107 | void *setting; |
104 | int lang_id; /* -1 for none */ | 108 | int lang_id; /* -1 for none */ |
105 | union storage_type default_val; | 109 | 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 @@ | |||
61 | #endif | 61 | #endif |
62 | #include "action.h" | 62 | #include "action.h" |
63 | 63 | ||
64 | static bool volume(void) | ||
65 | { | ||
66 | return set_sound(str(LANG_VOLUME), &global_settings.volume, SOUND_VOLUME); | ||
67 | } | ||
68 | |||
69 | static bool balance(void) | ||
70 | { | ||
71 | return set_sound(str(LANG_BALANCE), &global_settings.balance, | ||
72 | SOUND_BALANCE); | ||
73 | } | ||
74 | |||
75 | #ifndef HAVE_TLV320 | ||
76 | static bool bass(void) | ||
77 | { | ||
78 | return set_sound(str(LANG_BASS), &global_settings.bass, SOUND_BASS); | ||
79 | } | ||
80 | |||
81 | static bool treble(void) | ||
82 | { | ||
83 | return set_sound(str(LANG_TREBLE), &global_settings.treble, SOUND_TREBLE); | ||
84 | } | ||
85 | #endif | ||
86 | |||
87 | #if CONFIG_CODEC == SWCODEC | ||
88 | static void crossfeed_format(char* buffer, int buffer_size, int value, | ||
89 | const char* unit) | ||
90 | { | ||
91 | snprintf(buffer, buffer_size, "%s%d.%d %s", value == 0 ? " " : "-", | ||
92 | value / 10, value % 10, unit); | ||
93 | } | ||
94 | |||
95 | static bool crossfeed_enabled(void) | ||
96 | { | ||
97 | bool result = set_bool_options(str(LANG_CROSSFEED), | ||
98 | &global_settings.crossfeed, | ||
99 | STR(LANG_ON), | ||
100 | STR(LANG_OFF), | ||
101 | NULL); | ||
102 | |||
103 | dsp_set_crossfeed(global_settings.crossfeed); | ||
104 | |||
105 | return result; | ||
106 | } | ||
107 | |||
108 | static bool crossfeed_direct_gain(void) | ||
109 | { | ||
110 | return set_int(str(LANG_CROSSFEED_DIRECT_GAIN), str(LANG_UNIT_DB), | ||
111 | UNIT_DB, &global_settings.crossfeed_direct_gain, | ||
112 | &dsp_set_crossfeed_direct_gain, 5, 0, 60, crossfeed_format); | ||
113 | } | ||
114 | |||
115 | static void crossfeed_cross_gain_helper(int val) | ||
116 | { | ||
117 | dsp_set_crossfeed_cross_params(val, | ||
118 | val + global_settings.crossfeed_hf_attenuation, | ||
119 | global_settings.crossfeed_hf_cutoff); | ||
120 | } | ||
121 | |||
122 | static bool crossfeed_cross_gain(void) | ||
123 | { | ||
124 | return set_int(str(LANG_CROSSFEED_CROSS_GAIN), str(LANG_UNIT_DB), | ||
125 | UNIT_DB, &global_settings.crossfeed_cross_gain, | ||
126 | &crossfeed_cross_gain_helper, 5, 30, 120, crossfeed_format); | ||
127 | } | ||
128 | |||
129 | static void crossfeed_hf_att_helper(int val) | ||
130 | { | ||
131 | dsp_set_crossfeed_cross_params(global_settings.crossfeed_cross_gain, | ||
132 | global_settings.crossfeed_cross_gain + val, | ||
133 | global_settings.crossfeed_hf_cutoff); | ||
134 | } | ||
135 | |||
136 | static bool crossfeed_hf_attenuation(void) | ||
137 | { | ||
138 | return set_int(str(LANG_CROSSFEED_HF_ATTENUATION), str(LANG_UNIT_DB), | ||
139 | UNIT_DB, &global_settings.crossfeed_hf_attenuation, | ||
140 | &crossfeed_hf_att_helper, 5, 60, 240, crossfeed_format); | ||
141 | } | ||
142 | |||
143 | static void crossfeed_hf_cutoff_helper(int val) | ||
144 | { | ||
145 | dsp_set_crossfeed_cross_params(global_settings.crossfeed_cross_gain, | ||
146 | global_settings.crossfeed_cross_gain + global_settings.crossfeed_hf_attenuation, val); | ||
147 | } | ||
148 | |||
149 | static bool crossfeed_hf_cutoff(void) | ||
150 | { | ||
151 | return set_int(str(LANG_CROSSFEED_HF_CUTOFF), str(LANG_UNIT_HERTZ), | ||
152 | UNIT_HERTZ, &global_settings.crossfeed_hf_cutoff, &crossfeed_hf_cutoff_helper, 100, 500, 2000, | ||
153 | NULL); | ||
154 | } | ||
155 | |||
156 | static bool crossfeed_menu(void) | ||
157 | { | ||
158 | int m; | ||
159 | bool result; | ||
160 | static const struct menu_item items[] = { | ||
161 | { ID2P(LANG_CROSSFEED), crossfeed_enabled }, | ||
162 | { ID2P(LANG_CROSSFEED_DIRECT_GAIN), crossfeed_direct_gain }, | ||
163 | { ID2P(LANG_CROSSFEED_CROSS_GAIN), crossfeed_cross_gain }, | ||
164 | { ID2P(LANG_CROSSFEED_HF_ATTENUATION), crossfeed_hf_attenuation }, | ||
165 | { ID2P(LANG_CROSSFEED_HF_CUTOFF), crossfeed_hf_cutoff }, | ||
166 | }; | ||
167 | |||
168 | m=menu_init(items, sizeof(items) / sizeof(*items), NULL, | ||
169 | NULL, NULL, NULL); | ||
170 | result = menu_run(m); | ||
171 | menu_exit(m); | ||
172 | |||
173 | return result; | ||
174 | } | ||
175 | |||
176 | static bool dithering_enable(void) | ||
177 | { | ||
178 | return set_bool_options(str(LANG_DITHERING), | ||
179 | &global_settings.dithering_enabled, | ||
180 | STR(LANG_SET_BOOL_YES), | ||
181 | STR(LANG_SET_BOOL_NO), | ||
182 | dsp_dither_enable); | ||
183 | } | ||
184 | #endif | ||
185 | |||
186 | #if (CONFIG_CODEC == MAS3587F) || (CONFIG_CODEC == MAS3539F) | ||
187 | static bool loudness(void) | ||
188 | { | ||
189 | return set_sound(str(LANG_LOUDNESS), &global_settings.loudness, | ||
190 | SOUND_LOUDNESS); | ||
191 | } | ||
192 | |||
193 | static bool mdb_strength(void) | ||
194 | { | ||
195 | return set_sound(str(LANG_MDB_STRENGTH), &global_settings.mdb_strength, | ||
196 | SOUND_MDB_STRENGTH); | ||
197 | } | ||
198 | |||
199 | static bool mdb_harmonics(void) | ||
200 | { | ||
201 | return set_sound(str(LANG_MDB_HARMONICS), &global_settings.mdb_harmonics, | ||
202 | SOUND_MDB_HARMONICS); | ||
203 | } | ||
204 | |||
205 | static bool mdb_center(void) | ||
206 | { | ||
207 | return set_sound(str(LANG_MDB_CENTER), &global_settings.mdb_center, | ||
208 | SOUND_MDB_CENTER); | ||
209 | } | ||
210 | |||
211 | static bool mdb_shape(void) | ||
212 | { | ||
213 | return set_sound(str(LANG_MDB_SHAPE), &global_settings.mdb_shape, | ||
214 | SOUND_MDB_SHAPE); | ||
215 | } | ||
216 | |||
217 | static void set_mdb_enable(bool value) | ||
218 | { | ||
219 | sound_set_mdb_enable((int)value); | ||
220 | } | ||
221 | |||
222 | static bool mdb_enable(void) | ||
223 | { | ||
224 | return set_bool_options(str(LANG_MDB_ENABLE), | ||
225 | &global_settings.mdb_enable, | ||
226 | STR(LANG_SET_BOOL_YES), | ||
227 | STR(LANG_SET_BOOL_NO), | ||
228 | set_mdb_enable); | ||
229 | } | ||
230 | |||
231 | static void set_superbass(bool value) | ||
232 | { | ||
233 | sound_set_superbass((int)value); | ||
234 | } | ||
235 | |||
236 | static bool superbass(void) | ||
237 | { | ||
238 | return set_bool_options(str(LANG_SUPERBASS), | ||
239 | &global_settings.superbass, | ||
240 | STR(LANG_SET_BOOL_YES), | ||
241 | STR(LANG_SET_BOOL_NO), | ||
242 | set_superbass); | ||
243 | } | ||
244 | |||
245 | static bool avc(void) | ||
246 | { | ||
247 | static const struct opt_items names[] = { | ||
248 | { STR(LANG_OFF) }, | ||
249 | { "20ms", TALK_ID(20, UNIT_MS) }, | ||
250 | { "2s", TALK_ID(2, UNIT_SEC) }, | ||
251 | { "4s", TALK_ID(4, UNIT_SEC) }, | ||
252 | { "8s", TALK_ID(8, UNIT_SEC) } | ||
253 | }; | ||
254 | return set_option(str(LANG_DECAY), &global_settings.avc, INT, | ||
255 | names, 5, sound_set_avc); | ||
256 | } | ||
257 | #endif | ||
258 | |||
259 | #ifdef HAVE_RECORDING | 64 | #ifdef HAVE_RECORDING |
260 | static bool recsource(void) | 65 | static bool recsource(void) |
261 | { | 66 | { |
@@ -684,93 +489,7 @@ static bool agc_cliptime(void) | |||
684 | #endif /* HAVE_AGC */ | 489 | #endif /* HAVE_AGC */ |
685 | #endif /* HAVE_RECORDING */ | 490 | #endif /* HAVE_RECORDING */ |
686 | 491 | ||
687 | static bool chanconf(void) | ||
688 | { | ||
689 | static const struct opt_items names[] = { | ||
690 | { STR(LANG_CHANNEL_STEREO) }, | ||
691 | { STR(LANG_CHANNEL_MONO) }, | ||
692 | { STR(LANG_CHANNEL_CUSTOM) }, | ||
693 | { STR(LANG_CHANNEL_LEFT) }, | ||
694 | { STR(LANG_CHANNEL_RIGHT) }, | ||
695 | { STR(LANG_CHANNEL_KARAOKE) } | ||
696 | }; | ||
697 | #if CONFIG_CODEC == SWCODEC | ||
698 | return set_option(str(LANG_CHANNEL), &global_settings.channel_config, INT, | ||
699 | names, 6, channels_set); | ||
700 | #else | ||
701 | return set_option(str(LANG_CHANNEL), &global_settings.channel_config, INT, | ||
702 | names, 6, sound_set_channels); | ||
703 | #endif | ||
704 | } | ||
705 | |||
706 | static bool stereo_width(void) | ||
707 | { | ||
708 | return set_sound(str(LANG_STEREO_WIDTH), &global_settings.stereo_width, | ||
709 | SOUND_STEREO_WIDTH); | ||
710 | } | ||
711 | |||
712 | bool sound_menu(void) | ||
713 | { | ||
714 | int m; | ||
715 | bool done = false; | ||
716 | int selected; | ||
717 | static const struct menu_item items[] = { | ||
718 | { ID2P(LANG_VOLUME), volume }, | ||
719 | #ifndef HAVE_TLV320 | ||
720 | { ID2P(LANG_BASS), bass }, | ||
721 | { ID2P(LANG_TREBLE), treble }, | ||
722 | #endif | ||
723 | { ID2P(LANG_BALANCE), balance }, | ||
724 | { ID2P(LANG_CHANNEL_MENU), chanconf }, | ||
725 | { ID2P(LANG_STEREO_WIDTH), stereo_width }, | ||
726 | #if CONFIG_CODEC == SWCODEC | ||
727 | { ID2P(LANG_CROSSFEED), crossfeed_menu }, | ||
728 | { ID2P(LANG_EQUALIZER), eq_menu }, | ||
729 | { ID2P(LANG_DITHERING), dithering_enable }, | ||
730 | #endif | ||
731 | #ifdef HAVE_WM8758 | ||
732 | { ID2P(LANG_EQUALIZER_HARDWARE), eq_hw_menu }, | ||
733 | #endif | ||
734 | #if (CONFIG_CODEC == MAS3587F) || (CONFIG_CODEC == MAS3539F) | ||
735 | { ID2P(LANG_LOUDNESS), loudness }, | ||
736 | { ID2P(LANG_AUTOVOL), avc }, | ||
737 | { ID2P(LANG_SUPERBASS), superbass }, | ||
738 | { ID2P(LANG_MDB_ENABLE), mdb_enable }, | ||
739 | { ID2P(LANG_MDB_STRENGTH), mdb_strength }, | ||
740 | { ID2P(LANG_MDB_HARMONICS), mdb_harmonics }, | ||
741 | { ID2P(LANG_MDB_CENTER), mdb_center }, | ||
742 | { ID2P(LANG_MDB_SHAPE), mdb_shape }, | ||
743 | #endif | ||
744 | }; | ||
745 | |||
746 | m=menu_init( items, sizeof(items) / sizeof(*items), NULL, | ||
747 | NULL, NULL, NULL); | ||
748 | while (!done) | ||
749 | { | ||
750 | switch (selected=menu_show(m)) | ||
751 | { | ||
752 | case MENU_SELECTED_EXIT: | ||
753 | case MENU_ATTACHED_USB: | ||
754 | done = true; | ||
755 | break; | ||
756 | default: | ||
757 | #if CONFIG_CODEC == SWCODEC | ||
758 | pcmbuf_set_low_latency(true); | ||
759 | #endif | ||
760 | if (items[selected].function && | ||
761 | items[selected].function()) | ||
762 | done = true; | ||
763 | |||
764 | #if CONFIG_CODEC == SWCODEC | ||
765 | pcmbuf_set_low_latency(false); | ||
766 | #endif | ||
767 | gui_syncstatusbar_draw(&statusbars, true); | ||
768 | } | ||
769 | } | ||
770 | menu_exit(m); | ||
771 | 492 | ||
772 | return selected == MENU_SELECTED_EXIT ? false : true; | ||
773 | } | ||
774 | 493 | ||
775 | #ifdef HAVE_RECORDING | 494 | #ifdef HAVE_RECORDING |
776 | enum trigger_menu_option | 495 | enum trigger_menu_option |