1 /***************************************************************************
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
10 * Copyright (C) 2010 Michael Sevakis
12 * 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.
17 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
18 * KIND, either express or implied.
20 ****************************************************************************/
29 #define HW_EQ_IDX(band, setting) ((void *)(((setting) << 8) | (band)))
30 #define HW_EQ_IDX_BAND(data) ((uint8_t)(uintptr_t)(data))
31 #define HW_EQ_IDX_SETTING(data) ((uint8_t)((uintptr_t)(data) >> 8))
33 static unsigned short hw_eq_setting_lang_ids
[AUDIOHW_EQ_SETTING_NUM
] =
36 #ifdef AUDIOHW_HAVE_EQ_FREQUENCY
39 #ifdef AUDIOHW_HAVE_EQ_WIDTH
44 static char * hw_eq_get_name(int selected_item
, void * data
, char *buffer
)
46 snprintf(buffer
, MAX_PATH
,
47 str(hw_eq_setting_lang_ids
[HW_EQ_IDX_SETTING(data
)]),
48 HW_EQ_IDX_BAND(data
) + 1);
53 static int hw_eq_speak_item(int selected_item
, void * data
)
55 talk_id(hw_eq_setting_lang_ids
[HW_EQ_IDX_SETTING(data
)], false);
56 talk_number(HW_EQ_IDX_BAND(data
) + 1, true);
61 static int hw_eq_do_band_setting(void *param
)
63 int band
= HW_EQ_IDX_BAND(param
);
64 int setting
= HW_EQ_IDX_SETTING(param
);
66 struct menu_callback_with_desc cbwdesc
=
68 .menu_callback
= NULL
,
69 .desc
= hw_eq_get_name(0, param
, desc
),
70 .icon_id
= Icon_NOICON
72 struct menu_item_ex item
=
74 .flags
= MT_SETTING_W_TEXT
| MENU_HAS_DESC
,
75 { .variable
= (void*)(&global_settings
.hw_eq_bands
[band
].gain
+ setting
) },
76 { .callback_and_desc
= &cbwdesc
}
78 do_setting_from_menu(&item
, NULL
);
82 MENUITEM_FUNCTION_DYNTEXT(hw_eq_band1_gain
, MENU_FUNC_USEPARAM
,
83 hw_eq_do_band_setting
,
84 HW_EQ_IDX(AUDIOHW_EQ_BAND1
, AUDIOHW_EQ_GAIN
),
85 hw_eq_get_name
, hw_eq_speak_item
,
86 HW_EQ_IDX(AUDIOHW_EQ_BAND1
, AUDIOHW_EQ_GAIN
),
87 NULL
, Icon_Menu_setting
);
88 #ifdef AUDIOHW_HAVE_EQ_BAND1_FREQUENCY
89 MENUITEM_FUNCTION_DYNTEXT(hw_eq_band1_frequency
, MENU_FUNC_USEPARAM
,
90 hw_eq_do_band_setting
,
91 HW_EQ_IDX(AUDIOHW_EQ_BAND1
, AUDIOHW_EQ_FREQUENCY
),
92 hw_eq_get_name
, hw_eq_speak_item
,
93 HW_EQ_IDX(AUDIOHW_EQ_BAND1
, AUDIOHW_EQ_FREQUENCY
),
96 #ifdef AUDIOHW_HAVE_EQ_BAND2
97 MENUITEM_FUNCTION_DYNTEXT(hw_eq_band2_gain
, MENU_FUNC_USEPARAM
,
98 hw_eq_do_band_setting
,
99 HW_EQ_IDX(AUDIOHW_EQ_BAND2
, AUDIOHW_EQ_GAIN
),
100 hw_eq_get_name
, hw_eq_speak_item
,
101 HW_EQ_IDX(AUDIOHW_EQ_BAND2
, AUDIOHW_EQ_GAIN
),
102 NULL
, Icon_Menu_setting
);
103 #ifdef AUDIOHW_HAVE_EQ_BAND2_FREQUENCY
104 MENUITEM_FUNCTION_DYNTEXT(hw_eq_band2_frequency
, MENU_FUNC_USEPARAM
,
105 hw_eq_do_band_setting
,
106 HW_EQ_IDX(AUDIOHW_EQ_BAND2
, AUDIOHW_EQ_FREQUENCY
),
107 hw_eq_get_name
, hw_eq_speak_item
,
108 HW_EQ_IDX(AUDIOHW_EQ_BAND2
, AUDIOHW_EQ_FREQUENCY
),
111 #ifdef AUDIOHW_HAVE_EQ_BAND2_WIDTH
112 MENUITEM_FUNCTION_DYNTEXT(hw_eq_band2_width
, MENU_FUNC_USEPARAM
,
113 hw_eq_do_band_setting
,
114 HW_EQ_IDX(AUDIOHW_EQ_BAND2
, AUDIOHW_EQ_WIDTH
),
115 hw_eq_get_name
, hw_eq_speak_item
,
116 HW_EQ_IDX(AUDIOHW_EQ_BAND2
, AUDIOHW_EQ_WIDTH
),
119 #endif /* AUDIOHW_HAVE_EQ_BAND2 */
120 #ifdef AUDIOHW_HAVE_EQ_BAND3
121 MENUITEM_FUNCTION_DYNTEXT(hw_eq_band3_gain
, MENU_FUNC_USEPARAM
,
122 hw_eq_do_band_setting
,
123 HW_EQ_IDX(AUDIOHW_EQ_BAND3
, AUDIOHW_EQ_GAIN
),
124 hw_eq_get_name
, hw_eq_speak_item
,
125 HW_EQ_IDX(AUDIOHW_EQ_BAND3
, AUDIOHW_EQ_GAIN
),
126 NULL
, Icon_Menu_setting
);
127 #ifdef AUDIOHW_HAVE_EQ_BAND3_FREQUENCY
128 MENUITEM_FUNCTION_DYNTEXT(hw_eq_band3_frequency
, MENU_FUNC_USEPARAM
,
129 hw_eq_do_band_setting
,
130 HW_EQ_IDX(AUDIOHW_EQ_BAND3
, AUDIOHW_EQ_FREQUENCY
),
131 hw_eq_get_name
, hw_eq_speak_item
,
132 HW_EQ_IDX(AUDIOHW_EQ_BAND3
, AUDIOHW_EQ_FREQUENCY
),
135 #ifdef AUDIOHW_HAVE_EQ_BAND3_WIDTH
136 MENUITEM_FUNCTION_DYNTEXT(hw_eq_band3_width
, MENU_FUNC_USEPARAM
,
137 hw_eq_do_band_setting
,
138 HW_EQ_IDX(AUDIOHW_EQ_BAND3
, AUDIOHW_EQ_WIDTH
),
139 hw_eq_get_name
, hw_eq_speak_item
,
140 HW_EQ_IDX(AUDIOHW_EQ_BAND3
, AUDIOHW_EQ_WIDTH
),
143 #endif /* AUDIOHW_HAVE_EQ_BAND3 */
144 #ifdef AUDIOHW_HAVE_EQ_BAND4
145 MENUITEM_FUNCTION_DYNTEXT(hw_eq_band4_gain
, MENU_FUNC_USEPARAM
,
146 hw_eq_do_band_setting
,
147 HW_EQ_IDX(AUDIOHW_EQ_BAND4
, AUDIOHW_EQ_GAIN
),
148 hw_eq_get_name
, hw_eq_speak_item
,
149 HW_EQ_IDX(AUDIOHW_EQ_BAND4
, AUDIOHW_EQ_GAIN
),
150 NULL
, Icon_Menu_setting
);
151 #ifdef AUDIOHW_HAVE_EQ_BAND4_FREQUENCY
152 MENUITEM_FUNCTION_DYNTEXT(hw_eq_band4_frequency
, MENU_FUNC_USEPARAM
,
153 hw_eq_do_band_setting
,
154 HW_EQ_IDX(AUDIOHW_EQ_BAND4
, AUDIOHW_EQ_FREQUENCY
),
155 hw_eq_get_name
, hw_eq_speak_item
,
156 HW_EQ_IDX(AUDIOHW_EQ_BAND4
, AUDIOHW_EQ_FREQUENCY
),
159 #ifdef AUDIOHW_HAVE_EQ_BAND4_WIDTH
160 MENUITEM_FUNCTION_DYNTEXT(hw_eq_band4_width
, MENU_FUNC_USEPARAM
,
161 hw_eq_do_band_setting
,
162 HW_EQ_IDX(AUDIOHW_EQ_BAND4
, AUDIOHW_EQ_WIDTH
),
163 hw_eq_get_name
, hw_eq_speak_item
,
164 HW_EQ_IDX(AUDIOHW_EQ_BAND4
, AUDIOHW_EQ_WIDTH
),
167 #endif /* AUDIOHW_HAVE_EQ_BAND4 */
168 #ifdef AUDIOHW_HAVE_EQ_BAND5
169 MENUITEM_FUNCTION_DYNTEXT(hw_eq_band5_gain
, MENU_FUNC_USEPARAM
,
170 hw_eq_do_band_setting
,
171 HW_EQ_IDX(AUDIOHW_EQ_BAND5
, AUDIOHW_EQ_GAIN
),
172 hw_eq_get_name
, hw_eq_speak_item
,
173 HW_EQ_IDX(AUDIOHW_EQ_BAND5
, AUDIOHW_EQ_GAIN
),
174 NULL
, Icon_Menu_setting
);
175 #ifdef AUDIOHW_HAVE_EQ_BAND5_FREQUENCY
176 MENUITEM_FUNCTION_DYNTEXT(hw_eq_band5_frequency
, MENU_FUNC_USEPARAM
,
177 hw_eq_do_band_setting
,
178 HW_EQ_IDX(AUDIOHW_EQ_BAND5
, AUDIOHW_EQ_FREQUENCY
),
179 hw_eq_get_name
, hw_eq_speak_item
,
180 HW_EQ_IDX(AUDIOHW_EQ_BAND5
, AUDIOHW_EQ_FREQUENCY
),
183 #endif /* AUDIOHW_HAVE_EQ_BAND5 */
185 /* Submenu for multiple "tone controls". Gain + all advanced settings. */
186 MAKE_MENU(hardware_eq_tone_controls_advanced
, ID2P(LANG_HW_EQ_TONE_CONTROLS_ADVANCED
),
189 #ifdef AUDIOHW_HAVE_EQ_BAND1_FREQUENCY
190 ,&hw_eq_band1_frequency
192 #ifdef AUDIOHW_HAVE_EQ_BAND2
194 #ifdef AUDIOHW_HAVE_EQ_BAND2_FREQUENCY
195 ,&hw_eq_band2_frequency
197 #ifdef AUDIOHW_HAVE_EQ_BAND2_WIDTH
200 #endif /* AUDIOHW_HAVE_EQ_BAND2 */
201 #ifdef AUDIOHW_HAVE_EQ_BAND3
203 #ifdef AUDIOHW_HAVE_EQ_BAND3_FREQUENCY
204 ,&hw_eq_band3_frequency
206 #ifdef AUDIOHW_HAVE_EQ_BAND3_WIDTH
209 #endif /* AUDIOHW_HAVE_EQ_BAND3 */
210 #ifdef AUDIOHW_HAVE_EQ_BAND4
212 #ifdef AUDIOHW_HAVE_EQ_BAND4_FREQUENCY
213 ,&hw_eq_band4_frequency
215 #ifdef AUDIOHW_HAVE_EQ_BAND4_WIDTH
218 #endif /* AUDIOHW_HAVE_EQ_BAND4 */
219 #ifdef AUDIOHW_HAVE_EQ_BAND5
221 #ifdef AUDIOHW_HAVE_EQ_BAND5_FREQUENCY
222 ,&hw_eq_band5_frequency
224 #endif /* AUDIOHW_HAVE_EQ_BAND5 */
226 /* Shows only the gains + advanced settings submenu */
227 MAKE_MENU(audiohw_eq_tone_controls
, ID2P(LANG_HW_EQ_TONE_CONTROLS
),
230 #ifdef AUDIOHW_HAVE_EQ_BAND2
233 #ifdef AUDIOHW_HAVE_EQ_BAND3
236 #ifdef AUDIOHW_HAVE_EQ_BAND4
239 #ifdef AUDIOHW_HAVE_EQ_BAND5
242 ,&hardware_eq_tone_controls_advanced