blob: fb9a7fa26e0e27e2eb74380f9515de7964921f7e [file] [log] [blame]
Jonathan Gordon4718a1e2007-02-08 04:33:41 +00001/***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
Jonathan Gordon4e73b532007-02-13 00:32:17 +00008 * $Id$
Jonathan Gordon4718a1e2007-02-08 04:33:41 +00009 *
10 * Copyright (C) 2007 Jonathan Gordon
11 *
Daniel Stenberg2acc0ac2008-06-28 18:10:04 +000012 * This program is free software; you can redistribute it and/or
13 * modify it under the terms of the GNU General Public License
14 * as published by the Free Software Foundation; either version 2
15 * of the License, or (at your option) any later version.
Jonathan Gordon4718a1e2007-02-08 04:33:41 +000016 *
17 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
18 * KIND, either express or implied.
19 *
20 ****************************************************************************/
21
22#include <stdbool.h>
23#include <stddef.h>
24#include <limits.h>
25#include "config.h"
Michael Sevakis80d0d152010-05-15 13:09:45 +000026#include "sound.h"
Jonathan Gordon4718a1e2007-02-08 04:33:41 +000027#include "lang.h"
28#include "action.h"
29#include "settings.h"
30#include "menu.h"
31#include "sound_menu.h"
Jonathan Gordonfe3cfcc2007-02-08 10:28:42 +000032#include "eq_menu.h"
Jonathan Gordon2801a872007-02-19 02:14:51 +000033#include "exported_menus.h"
Dan Everton04663192008-03-03 11:06:04 +000034#include "menu_common.h"
Steve Bavinfb238072009-06-12 07:20:50 +000035#include "splash.h"
36#include "kernel.h"
PurlingNayukif0bec022013-12-21 21:33:54 +080037#include "talk.h"
38#include "option_select.h"
39#include "misc.h"
40
PurlingNayukif0bec022013-12-21 21:33:54 +080041static int volume_limit_callback(int action,const struct menu_item_ex *this_item)
42{
43 (void)this_item;
44
45 static struct int_setting volume_limit_int_setting;
46 volume_limit_int_setting.option_callback = NULL;
47 volume_limit_int_setting.unit = UNIT_DB;
48 volume_limit_int_setting.min = sound_min(SOUND_VOLUME);
49 volume_limit_int_setting.max = sound_max(SOUND_VOLUME);
50 volume_limit_int_setting.step = sound_steps(SOUND_VOLUME);
51 volume_limit_int_setting.formatter = NULL;
Solomon Peachye73ef012019-07-21 09:01:58 -040052 volume_limit_int_setting.get_talk_id = NULL;
PurlingNayukif0bec022013-12-21 21:33:54 +080053
54 struct settings_list setting;
55 setting.flags = F_BANFROMQS|F_INT_SETTING|F_T_INT|F_NO_WRAP;
56 setting.lang_id = LANG_VOLUME_LIMIT;
57 setting.default_val.int_ = sound_max(SOUND_VOLUME);
58 setting.int_setting = &volume_limit_int_setting;
59
60 switch (action)
61 {
62 case ACTION_ENTER_MENUITEM:
63 setting.setting = &global_settings.volume_limit;
64 option_screen(&setting, NULL, false, ID2P(LANG_VOLUME_LIMIT));
65 case ACTION_EXIT_MENUITEM: /* on exit */
66 setvol();
67 break;
68 }
69 return action;
70}
Jonathan Gordon4718a1e2007-02-08 04:33:41 +000071
Jonathan Gordonfe3cfcc2007-02-08 10:28:42 +000072/***********************************/
73/* SOUND MENU */
Dan Everton04663192008-03-03 11:06:04 +000074MENUITEM_SETTING(volume, &global_settings.volume, NULL);
PurlingNayukif0bec022013-12-21 21:33:54 +080075MENUITEM_SETTING(volume_limit, &global_settings.volume_limit, volume_limit_callback);
Michael Sevakis80d0d152010-05-15 13:09:45 +000076#ifdef AUDIOHW_HAVE_BASS
Dan Everton04663192008-03-03 11:06:04 +000077MENUITEM_SETTING(bass, &global_settings.bass,
78#ifdef HAVE_SW_TONE_CONTROLS
79 lowlatency_callback
Jonathan Gordonfe3cfcc2007-02-08 10:28:42 +000080#else
Dan Everton04663192008-03-03 11:06:04 +000081 NULL
Jonathan Gordonfe3cfcc2007-02-08 10:28:42 +000082#endif
Dan Everton04663192008-03-03 11:06:04 +000083);
Michael Sevakis80d0d152010-05-15 13:09:45 +000084
85#ifdef AUDIOHW_HAVE_BASS_CUTOFF
Michael Sevakis5508d402010-05-15 13:30:01 +000086MENUITEM_SETTING(bass_cutoff, &global_settings.bass_cutoff, NULL);
Dan Evertond7e1f772007-11-24 07:51:00 +000087#endif
Michael Sevakis80d0d152010-05-15 13:09:45 +000088#endif /* AUDIOHW_HAVE_BASS */
89
90
91#ifdef AUDIOHW_HAVE_TREBLE
Dan Everton04663192008-03-03 11:06:04 +000092MENUITEM_SETTING(treble, &global_settings.treble,
93#ifdef HAVE_SW_TONE_CONTROLS
94 lowlatency_callback
95#else
96 NULL
97#endif
98);
Michael Sevakis80d0d152010-05-15 13:09:45 +000099
100#ifdef AUDIOHW_HAVE_TREBLE_CUTOFF
Dan Everton04663192008-03-03 11:06:04 +0000101MENUITEM_SETTING(treble_cutoff, &global_settings.treble_cutoff, NULL);
Dan Evertond7e1f772007-11-24 07:51:00 +0000102#endif
Michael Sevakis80d0d152010-05-15 13:09:45 +0000103#endif /* AUDIOHW_HAVE_TREBLE */
104
105
Dan Everton04663192008-03-03 11:06:04 +0000106MENUITEM_SETTING(balance, &global_settings.balance, NULL);
Steve Bavinfb238072009-06-12 07:20:50 +0000107MENUITEM_SETTING(channel_config, &global_settings.channel_config,
Dan Everton04663192008-03-03 11:06:04 +0000108#if CONFIG_CODEC == SWCODEC
109 lowlatency_callback
110#else
111 NULL
112#endif
113);
Steve Bavinfb238072009-06-12 07:20:50 +0000114MENUITEM_SETTING(stereo_width, &global_settings.stereo_width,
Dan Everton04663192008-03-03 11:06:04 +0000115#if CONFIG_CODEC == SWCODEC
116 lowlatency_callback
117#else
118 NULL
119#endif
120);
Jonathan Gordonfe3cfcc2007-02-08 10:28:42 +0000121
Michael Sevakis80d0d152010-05-15 13:09:45 +0000122#ifdef AUDIOHW_HAVE_DEPTH_3D
123MENUITEM_SETTING(depth_3d, &global_settings.depth_3d, NULL);
124#endif
125
Andrew Ryabinin0519f7e2013-05-12 23:23:45 +0400126#ifdef AUDIOHW_HAVE_FILTER_ROLL_OFF
127MENUITEM_SETTING(roll_off, &global_settings.roll_off, NULL);
128#endif
129
Solomon Peachy06627932018-06-28 06:24:26 -0400130#ifdef AUDIOHW_HAVE_FUNCTIONAL_MODE
131MENUITEM_SETTING(func_mode, &global_settings.func_mode, NULL);
132#endif
133
Jonathan Gordonfe3cfcc2007-02-08 10:28:42 +0000134#if CONFIG_CODEC == SWCODEC
135 /* Crossfeed Submenu */
Dan Everton04663192008-03-03 11:06:04 +0000136 MENUITEM_SETTING(crossfeed, &global_settings.crossfeed, lowlatency_callback);
Jonathan Gordonfe3cfcc2007-02-08 10:28:42 +0000137 MENUITEM_SETTING(crossfeed_direct_gain,
Dan Everton04663192008-03-03 11:06:04 +0000138 &global_settings.crossfeed_direct_gain, lowlatency_callback);
Jonathan Gordonfe3cfcc2007-02-08 10:28:42 +0000139 MENUITEM_SETTING(crossfeed_cross_gain,
Dan Everton04663192008-03-03 11:06:04 +0000140 &global_settings.crossfeed_cross_gain, lowlatency_callback);
Jonathan Gordonfe3cfcc2007-02-08 10:28:42 +0000141 MENUITEM_SETTING(crossfeed_hf_attenuation,
Dan Everton04663192008-03-03 11:06:04 +0000142 &global_settings.crossfeed_hf_attenuation, lowlatency_callback);
Jonathan Gordonfe3cfcc2007-02-08 10:28:42 +0000143 MENUITEM_SETTING(crossfeed_hf_cutoff,
Dan Everton04663192008-03-03 11:06:04 +0000144 &global_settings.crossfeed_hf_cutoff, lowlatency_callback);
Jonathan Gordon02a87172007-03-03 13:52:14 +0000145 MAKE_MENU(crossfeed_menu,ID2P(LANG_CROSSFEED), NULL, Icon_NOICON,
Jonathan Gordonfe3cfcc2007-02-08 10:28:42 +0000146 &crossfeed, &crossfeed_direct_gain, &crossfeed_cross_gain,
147 &crossfeed_hf_attenuation, &crossfeed_hf_cutoff);
Steve Bavinfb238072009-06-12 07:20:50 +0000148
Nils Wallméniusd29a11b2012-05-08 16:34:26 +0200149#ifdef HAVE_PITCHCONTROL
Steve Bavinfb238072009-06-12 07:20:50 +0000150static int timestretch_callback(int action,const struct menu_item_ex *this_item)
151{
152 switch (action)
153 {
154 case ACTION_EXIT_MENUITEM: /* on exit */
Steve Bavind6ad0192009-06-16 07:10:05 +0000155 if (global_settings.timestretch_enabled && !dsp_timestretch_available())
Steve Bavinfb238072009-06-12 07:20:50 +0000156 splash(HZ*2, ID2P(LANG_PLEASE_REBOOT));
157 break;
158 }
159 lowlatency_callback(action, this_item);
160 return action;
161}
162 MENUITEM_SETTING(timestretch_enabled,
163 &global_settings.timestretch_enabled, timestretch_callback);
Frank Gevaertsf3660902010-09-17 20:28:47 +0000164#endif
165
Jonathan Gordonfe3cfcc2007-02-08 10:28:42 +0000166 MENUITEM_SETTING(dithering_enabled,
Dan Everton04663192008-03-03 11:06:04 +0000167 &global_settings.dithering_enabled, lowlatency_callback);
Chiwen Chang3ae0f322014-08-22 23:30:35 +1000168 MENUITEM_SETTING(afr_enabled,
169 &global_settings.afr_enabled, lowlatency_callback);
170 MENUITEM_SETTING(pbe,
171 &global_settings.pbe, lowlatency_callback);
172 MENUITEM_SETTING(pbe_precut,
173 &global_settings.pbe_precut, lowlatency_callback);
174 MAKE_MENU(pbe_menu,ID2P(LANG_PBE), NULL, Icon_NOICON,
175 &pbe,&pbe_precut);
176 MENUITEM_SETTING(surround_enabled,
177 &global_settings.surround_enabled, lowlatency_callback);
178 MENUITEM_SETTING(surround_balance,
179 &global_settings.surround_balance, lowlatency_callback);
180 MENUITEM_SETTING(surround_fx1,
181 &global_settings.surround_fx1, lowlatency_callback);
182 MENUITEM_SETTING(surround_fx2,
183 &global_settings.surround_fx2, lowlatency_callback);
184 MENUITEM_SETTING(surround_method2,
185 &global_settings.surround_method2, lowlatency_callback);
186 MENUITEM_SETTING(surround_mix,
187 &global_settings.surround_mix, lowlatency_callback);
188 MAKE_MENU(surround_menu,ID2P(LANG_SURROUND), NULL, Icon_NOICON,
189 &surround_enabled,&surround_balance,&surround_fx1,&surround_fx2,&surround_method2,&surround_mix);
Jeffrey Goodecf19ba52009-09-25 15:46:38 +0000190
191 /* compressor submenu */
192 MENUITEM_SETTING(compressor_threshold,
Michael Sevakis0842d7f2012-04-26 17:19:16 -0400193 &global_settings.compressor_settings.threshold,
194 lowlatency_callback);
Jeffrey Goodecf19ba52009-09-25 15:46:38 +0000195 MENUITEM_SETTING(compressor_gain,
Michael Sevakis0842d7f2012-04-26 17:19:16 -0400196 &global_settings.compressor_settings.makeup_gain,
197 lowlatency_callback);
Jeffrey Goode95e2d722009-11-04 18:14:36 +0000198 MENUITEM_SETTING(compressor_ratio,
Michael Sevakis0842d7f2012-04-26 17:19:16 -0400199 &global_settings.compressor_settings.ratio,
200 lowlatency_callback);
Jeffrey Goodecf19ba52009-09-25 15:46:38 +0000201 MENUITEM_SETTING(compressor_knee,
Michael Sevakis0842d7f2012-04-26 17:19:16 -0400202 &global_settings.compressor_settings.knee,
203 lowlatency_callback);
Ryan Billingd0918b92013-10-04 01:57:00 +1300204 MENUITEM_SETTING(compressor_attack,
205 &global_settings.compressor_settings.attack_time,
206 lowlatency_callback);
Jeffrey Goodecf19ba52009-09-25 15:46:38 +0000207 MENUITEM_SETTING(compressor_release,
Michael Sevakis0842d7f2012-04-26 17:19:16 -0400208 &global_settings.compressor_settings.release_time,
209 lowlatency_callback);
Jeffrey Goodecf19ba52009-09-25 15:46:38 +0000210 MAKE_MENU(compressor_menu,ID2P(LANG_COMPRESSOR), NULL, Icon_NOICON,
Jeffrey Goode95e2d722009-11-04 18:14:36 +0000211 &compressor_threshold, &compressor_gain, &compressor_ratio,
Ryan Billingd0918b92013-10-04 01:57:00 +1300212 &compressor_knee, &compressor_attack, &compressor_release);
Jonathan Gordonfe3cfcc2007-02-08 10:28:42 +0000213#endif
214
215#if (CONFIG_CODEC == MAS3587F) || (CONFIG_CODEC == MAS3539F)
216 MENUITEM_SETTING(loudness, &global_settings.loudness, NULL);
217 MENUITEM_SETTING(avc, &global_settings.avc, NULL);
218 MENUITEM_SETTING(superbass, &global_settings.superbass, NULL);
219 MENUITEM_SETTING(mdb_enable, &global_settings.mdb_enable, NULL);
220 MENUITEM_SETTING(mdb_strength, &global_settings.mdb_strength, NULL);
221 MENUITEM_SETTING(mdb_harmonics, &global_settings.mdb_harmonics, NULL);
222 MENUITEM_SETTING(mdb_center, &global_settings.mdb_center, NULL);
223 MENUITEM_SETTING(mdb_shape, &global_settings.mdb_shape, NULL);
224#endif
225
Maurus Cuelenaere6c252a62009-03-02 18:18:24 +0000226#ifdef HAVE_SPEAKER
Amaury Pouly1245c5f2017-01-14 01:40:12 +0100227 MENUITEM_SETTING(speaker_mode, &global_settings.speaker_mode, NULL);
Maurus Cuelenaere6c252a62009-03-02 18:18:24 +0000228#endif
229
Michael Sevakis80d0d152010-05-15 13:09:45 +0000230#ifdef AUDIOHW_HAVE_EQ
231#endif /* AUDIOHW_HAVE_EQ */
Jonathan Gordonfe3cfcc2007-02-08 10:28:42 +0000232
Jonathan Gordon02a87172007-03-03 13:52:14 +0000233MAKE_MENU(sound_settings, ID2P(LANG_SOUND_SETTINGS), NULL, Icon_Audio,
Michael Sevakis80d0d152010-05-15 13:09:45 +0000234 &volume
PurlingNayukif0bec022013-12-21 21:33:54 +0800235 ,&volume_limit
Michael Sevakis80d0d152010-05-15 13:09:45 +0000236#ifdef AUDIOHW_HAVE_BASS
237 ,&bass
Dan Evertond7e1f772007-11-24 07:51:00 +0000238#endif
Michael Sevakis80d0d152010-05-15 13:09:45 +0000239#ifdef AUDIOHW_HAVE_BASS_CUTOFF
240 ,&bass_cutoff
Dan Evertond7e1f772007-11-24 07:51:00 +0000241#endif
Michael Sevakis80d0d152010-05-15 13:09:45 +0000242#ifdef AUDIOHW_HAVE_TREBLE
243 ,&treble
244#endif
245#ifdef AUDIOHW_HAVE_TREBLE_CUTOFF
246 ,&treble_cutoff
247#endif
248#ifdef AUDIOHW_HAVE_EQ
249 ,&audiohw_eq_tone_controls
250#endif
251 ,&balance,&channel_config,&stereo_width
252#ifdef AUDIOHW_HAVE_DEPTH_3D
253 ,&depth_3d
254#endif
Andrew Ryabinin0519f7e2013-05-12 23:23:45 +0400255#ifdef AUDIOHW_HAVE_FILTER_ROLL_OFF
256 ,&roll_off
257#endif
Solomon Peachy06627932018-06-28 06:24:26 -0400258#ifdef AUDIOHW_HAVE_FUNCTIONAL_MODE
259 ,&func_mode
260#endif
Jonathan Gordonfe3cfcc2007-02-08 10:28:42 +0000261#if CONFIG_CODEC == SWCODEC
Steve Bavinfb238072009-06-12 07:20:50 +0000262 ,&crossfeed_menu, &equalizer_menu, &dithering_enabled
Chiwen Chang3ae0f322014-08-22 23:30:35 +1000263 ,&surround_menu, &pbe_menu, &afr_enabled
Nils Wallméniusd29a11b2012-05-08 16:34:26 +0200264#ifdef HAVE_PITCHCONTROL
Steve Bavinfb238072009-06-12 07:20:50 +0000265 ,&timestretch_enabled
Frank Gevaertsf3660902010-09-17 20:28:47 +0000266#endif
Jeffrey Goodecf19ba52009-09-25 15:46:38 +0000267 ,&compressor_menu
Jonathan Gordonfe3cfcc2007-02-08 10:28:42 +0000268#endif
Jonathan Gordonfe3cfcc2007-02-08 10:28:42 +0000269#if (CONFIG_CODEC == MAS3587F) || (CONFIG_CODEC == MAS3539F)
270 ,&loudness,&avc,&superbass,&mdb_enable,&mdb_strength
271 ,&mdb_harmonics,&mdb_center,&mdb_shape
272#endif
Maurus Cuelenaere6c252a62009-03-02 18:18:24 +0000273#ifdef HAVE_SPEAKER
Amaury Pouly1245c5f2017-01-14 01:40:12 +0100274 ,&speaker_mode
Maurus Cuelenaere6c252a62009-03-02 18:18:24 +0000275#endif
Jonathan Gordonfe3cfcc2007-02-08 10:28:42 +0000276 );
Jonathan Gordonfe3cfcc2007-02-08 10:28:42 +0000277