Michael Sevakis | 80d0d15 | 2010-05-15 13:09:45 +0000 | [diff] [blame] | 1 | /*************************************************************************** |
| 2 | * __________ __ ___. |
| 3 | * Open \______ \ ____ ____ | | _\_ |__ _______ ___ |
| 4 | * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / |
| 5 | * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < |
| 6 | * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ |
| 7 | * \/ \/ \/ \/ \/ |
| 8 | * $Id$ |
| 9 | * |
| 10 | * Copyright (C) 2010 Michael Sevakis |
| 11 | * |
| 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. |
| 16 | * |
| 17 | * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY |
| 18 | * KIND, either express or implied. |
| 19 | * |
| 20 | ****************************************************************************/ |
| 21 | #include <stdio.h> |
| 22 | #include "config.h" |
| 23 | #include "sound.h" |
| 24 | #include "settings.h" |
| 25 | #include "lang.h" |
| 26 | #include "menu.h" |
| 27 | #include "talk.h" |
| 28 | |
| 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)) |
| 32 | |
| 33 | static unsigned short hw_eq_setting_lang_ids[AUDIOHW_EQ_SETTING_NUM] = |
| 34 | { |
| 35 | LANG_HW_EQ_GAIN, |
| 36 | #ifdef AUDIOHW_HAVE_EQ_FREQUENCY |
| 37 | LANG_HW_EQ_FREQUENCY, |
| 38 | #endif |
| 39 | #ifdef AUDIOHW_HAVE_EQ_WIDTH |
| 40 | LANG_HW_EQ_WIDTH, |
| 41 | #endif |
| 42 | }; |
| 43 | |
William Wilgus | 10e5e56 | 2019-09-20 03:07:29 -0500 | [diff] [blame^] | 44 | static char * hw_eq_get_name(int selected_item, void * data, |
| 45 | char *buffer, size_t buffer_len) |
Michael Sevakis | 80d0d15 | 2010-05-15 13:09:45 +0000 | [diff] [blame] | 46 | { |
William Wilgus | 10e5e56 | 2019-09-20 03:07:29 -0500 | [diff] [blame^] | 47 | snprintf(buffer, buffer_len, |
Michael Sevakis | 80d0d15 | 2010-05-15 13:09:45 +0000 | [diff] [blame] | 48 | str(hw_eq_setting_lang_ids[HW_EQ_IDX_SETTING(data)]), |
| 49 | HW_EQ_IDX_BAND(data) + 1); |
| 50 | return buffer; |
| 51 | (void)selected_item; |
| 52 | } |
| 53 | |
| 54 | static int hw_eq_speak_item(int selected_item, void * data) |
| 55 | { |
| 56 | talk_id(hw_eq_setting_lang_ids[HW_EQ_IDX_SETTING(data)], false); |
| 57 | talk_number(HW_EQ_IDX_BAND(data) + 1, true); |
| 58 | return 0; |
| 59 | (void)selected_item; |
| 60 | } |
| 61 | |
| 62 | static int hw_eq_do_band_setting(void *param) |
| 63 | { |
| 64 | int band = HW_EQ_IDX_BAND(param); |
| 65 | int setting = HW_EQ_IDX_SETTING(param); |
| 66 | char desc[MAX_PATH]; |
| 67 | struct menu_callback_with_desc cbwdesc = |
| 68 | { |
| 69 | .menu_callback = NULL, |
| 70 | .desc = hw_eq_get_name(0, param, desc), |
| 71 | .icon_id = Icon_NOICON |
| 72 | }; |
| 73 | struct menu_item_ex item = |
| 74 | { |
| 75 | .flags = MT_SETTING_W_TEXT | MENU_HAS_DESC, |
| 76 | { .variable = (void*)(&global_settings.hw_eq_bands[band].gain + setting) }, |
| 77 | { .callback_and_desc = &cbwdesc } |
| 78 | }; |
| 79 | do_setting_from_menu(&item, NULL); |
| 80 | return 0; |
| 81 | } |
| 82 | |
| 83 | MENUITEM_FUNCTION_DYNTEXT(hw_eq_band1_gain, MENU_FUNC_USEPARAM, |
| 84 | hw_eq_do_band_setting, |
| 85 | HW_EQ_IDX(AUDIOHW_EQ_BAND1, AUDIOHW_EQ_GAIN), |
| 86 | hw_eq_get_name, hw_eq_speak_item, |
| 87 | HW_EQ_IDX(AUDIOHW_EQ_BAND1, AUDIOHW_EQ_GAIN), |
| 88 | NULL, Icon_Menu_setting); |
| 89 | #ifdef AUDIOHW_HAVE_EQ_BAND1_FREQUENCY |
| 90 | MENUITEM_FUNCTION_DYNTEXT(hw_eq_band1_frequency, MENU_FUNC_USEPARAM, |
| 91 | hw_eq_do_band_setting, |
| 92 | HW_EQ_IDX(AUDIOHW_EQ_BAND1, AUDIOHW_EQ_FREQUENCY), |
| 93 | hw_eq_get_name, hw_eq_speak_item, |
| 94 | HW_EQ_IDX(AUDIOHW_EQ_BAND1, AUDIOHW_EQ_FREQUENCY), |
| 95 | NULL, Icon_NOICON); |
| 96 | #endif |
| 97 | #ifdef AUDIOHW_HAVE_EQ_BAND2 |
| 98 | MENUITEM_FUNCTION_DYNTEXT(hw_eq_band2_gain, MENU_FUNC_USEPARAM, |
| 99 | hw_eq_do_band_setting, |
| 100 | HW_EQ_IDX(AUDIOHW_EQ_BAND2, AUDIOHW_EQ_GAIN), |
| 101 | hw_eq_get_name, hw_eq_speak_item, |
| 102 | HW_EQ_IDX(AUDIOHW_EQ_BAND2, AUDIOHW_EQ_GAIN), |
| 103 | NULL, Icon_Menu_setting); |
| 104 | #ifdef AUDIOHW_HAVE_EQ_BAND2_FREQUENCY |
| 105 | MENUITEM_FUNCTION_DYNTEXT(hw_eq_band2_frequency, MENU_FUNC_USEPARAM, |
| 106 | hw_eq_do_band_setting, |
| 107 | HW_EQ_IDX(AUDIOHW_EQ_BAND2, AUDIOHW_EQ_FREQUENCY), |
| 108 | hw_eq_get_name, hw_eq_speak_item, |
| 109 | HW_EQ_IDX(AUDIOHW_EQ_BAND2, AUDIOHW_EQ_FREQUENCY), |
| 110 | NULL, Icon_NOICON); |
| 111 | #endif |
| 112 | #ifdef AUDIOHW_HAVE_EQ_BAND2_WIDTH |
| 113 | MENUITEM_FUNCTION_DYNTEXT(hw_eq_band2_width, MENU_FUNC_USEPARAM, |
| 114 | hw_eq_do_band_setting, |
| 115 | HW_EQ_IDX(AUDIOHW_EQ_BAND2, AUDIOHW_EQ_WIDTH), |
| 116 | hw_eq_get_name, hw_eq_speak_item, |
| 117 | HW_EQ_IDX(AUDIOHW_EQ_BAND2, AUDIOHW_EQ_WIDTH), |
| 118 | NULL, Icon_NOICON); |
| 119 | #endif |
| 120 | #endif /* AUDIOHW_HAVE_EQ_BAND2 */ |
| 121 | #ifdef AUDIOHW_HAVE_EQ_BAND3 |
| 122 | MENUITEM_FUNCTION_DYNTEXT(hw_eq_band3_gain, MENU_FUNC_USEPARAM, |
| 123 | hw_eq_do_band_setting, |
| 124 | HW_EQ_IDX(AUDIOHW_EQ_BAND3, AUDIOHW_EQ_GAIN), |
| 125 | hw_eq_get_name, hw_eq_speak_item, |
| 126 | HW_EQ_IDX(AUDIOHW_EQ_BAND3, AUDIOHW_EQ_GAIN), |
| 127 | NULL, Icon_Menu_setting); |
| 128 | #ifdef AUDIOHW_HAVE_EQ_BAND3_FREQUENCY |
| 129 | MENUITEM_FUNCTION_DYNTEXT(hw_eq_band3_frequency, MENU_FUNC_USEPARAM, |
| 130 | hw_eq_do_band_setting, |
| 131 | HW_EQ_IDX(AUDIOHW_EQ_BAND3, AUDIOHW_EQ_FREQUENCY), |
| 132 | hw_eq_get_name, hw_eq_speak_item, |
| 133 | HW_EQ_IDX(AUDIOHW_EQ_BAND3, AUDIOHW_EQ_FREQUENCY), |
| 134 | NULL, Icon_NOICON); |
| 135 | #endif |
| 136 | #ifdef AUDIOHW_HAVE_EQ_BAND3_WIDTH |
| 137 | MENUITEM_FUNCTION_DYNTEXT(hw_eq_band3_width, MENU_FUNC_USEPARAM, |
| 138 | hw_eq_do_band_setting, |
| 139 | HW_EQ_IDX(AUDIOHW_EQ_BAND3, AUDIOHW_EQ_WIDTH), |
| 140 | hw_eq_get_name, hw_eq_speak_item, |
| 141 | HW_EQ_IDX(AUDIOHW_EQ_BAND3, AUDIOHW_EQ_WIDTH), |
| 142 | NULL, Icon_NOICON); |
| 143 | #endif |
| 144 | #endif /* AUDIOHW_HAVE_EQ_BAND3 */ |
| 145 | #ifdef AUDIOHW_HAVE_EQ_BAND4 |
| 146 | MENUITEM_FUNCTION_DYNTEXT(hw_eq_band4_gain, MENU_FUNC_USEPARAM, |
| 147 | hw_eq_do_band_setting, |
| 148 | HW_EQ_IDX(AUDIOHW_EQ_BAND4, AUDIOHW_EQ_GAIN), |
| 149 | hw_eq_get_name, hw_eq_speak_item, |
| 150 | HW_EQ_IDX(AUDIOHW_EQ_BAND4, AUDIOHW_EQ_GAIN), |
| 151 | NULL, Icon_Menu_setting); |
| 152 | #ifdef AUDIOHW_HAVE_EQ_BAND4_FREQUENCY |
| 153 | MENUITEM_FUNCTION_DYNTEXT(hw_eq_band4_frequency, MENU_FUNC_USEPARAM, |
| 154 | hw_eq_do_band_setting, |
| 155 | HW_EQ_IDX(AUDIOHW_EQ_BAND4, AUDIOHW_EQ_FREQUENCY), |
| 156 | hw_eq_get_name, hw_eq_speak_item, |
| 157 | HW_EQ_IDX(AUDIOHW_EQ_BAND4, AUDIOHW_EQ_FREQUENCY), |
| 158 | NULL, Icon_NOICON); |
| 159 | #endif |
| 160 | #ifdef AUDIOHW_HAVE_EQ_BAND4_WIDTH |
| 161 | MENUITEM_FUNCTION_DYNTEXT(hw_eq_band4_width, MENU_FUNC_USEPARAM, |
| 162 | hw_eq_do_band_setting, |
| 163 | HW_EQ_IDX(AUDIOHW_EQ_BAND4, AUDIOHW_EQ_WIDTH), |
| 164 | hw_eq_get_name, hw_eq_speak_item, |
| 165 | HW_EQ_IDX(AUDIOHW_EQ_BAND4, AUDIOHW_EQ_WIDTH), |
| 166 | NULL, Icon_NOICON); |
| 167 | #endif |
| 168 | #endif /* AUDIOHW_HAVE_EQ_BAND4 */ |
| 169 | #ifdef AUDIOHW_HAVE_EQ_BAND5 |
| 170 | MENUITEM_FUNCTION_DYNTEXT(hw_eq_band5_gain, MENU_FUNC_USEPARAM, |
| 171 | hw_eq_do_band_setting, |
| 172 | HW_EQ_IDX(AUDIOHW_EQ_BAND5, AUDIOHW_EQ_GAIN), |
| 173 | hw_eq_get_name, hw_eq_speak_item, |
| 174 | HW_EQ_IDX(AUDIOHW_EQ_BAND5, AUDIOHW_EQ_GAIN), |
| 175 | NULL, Icon_Menu_setting); |
| 176 | #ifdef AUDIOHW_HAVE_EQ_BAND5_FREQUENCY |
| 177 | MENUITEM_FUNCTION_DYNTEXT(hw_eq_band5_frequency, MENU_FUNC_USEPARAM, |
| 178 | hw_eq_do_band_setting, |
| 179 | HW_EQ_IDX(AUDIOHW_EQ_BAND5, AUDIOHW_EQ_FREQUENCY), |
| 180 | hw_eq_get_name, hw_eq_speak_item, |
| 181 | HW_EQ_IDX(AUDIOHW_EQ_BAND5, AUDIOHW_EQ_FREQUENCY), |
| 182 | NULL, Icon_NOICON); |
| 183 | #endif |
| 184 | #endif /* AUDIOHW_HAVE_EQ_BAND5 */ |
| 185 | |
| 186 | /* Submenu for multiple "tone controls". Gain + all advanced settings. */ |
| 187 | MAKE_MENU(hardware_eq_tone_controls_advanced, ID2P(LANG_HW_EQ_TONE_CONTROLS_ADVANCED), |
| 188 | NULL, Icon_NOICON |
| 189 | ,&hw_eq_band1_gain |
| 190 | #ifdef AUDIOHW_HAVE_EQ_BAND1_FREQUENCY |
| 191 | ,&hw_eq_band1_frequency |
| 192 | #endif |
| 193 | #ifdef AUDIOHW_HAVE_EQ_BAND2 |
| 194 | ,&hw_eq_band2_gain |
| 195 | #ifdef AUDIOHW_HAVE_EQ_BAND2_FREQUENCY |
| 196 | ,&hw_eq_band2_frequency |
| 197 | #endif |
| 198 | #ifdef AUDIOHW_HAVE_EQ_BAND2_WIDTH |
| 199 | ,&hw_eq_band2_width |
| 200 | #endif |
| 201 | #endif /* AUDIOHW_HAVE_EQ_BAND2 */ |
| 202 | #ifdef AUDIOHW_HAVE_EQ_BAND3 |
| 203 | ,&hw_eq_band3_gain |
| 204 | #ifdef AUDIOHW_HAVE_EQ_BAND3_FREQUENCY |
| 205 | ,&hw_eq_band3_frequency |
| 206 | #endif |
| 207 | #ifdef AUDIOHW_HAVE_EQ_BAND3_WIDTH |
| 208 | ,&hw_eq_band3_width |
| 209 | #endif |
| 210 | #endif /* AUDIOHW_HAVE_EQ_BAND3 */ |
| 211 | #ifdef AUDIOHW_HAVE_EQ_BAND4 |
| 212 | ,&hw_eq_band4_gain |
| 213 | #ifdef AUDIOHW_HAVE_EQ_BAND4_FREQUENCY |
| 214 | ,&hw_eq_band4_frequency |
| 215 | #endif |
| 216 | #ifdef AUDIOHW_HAVE_EQ_BAND4_WIDTH |
| 217 | ,&hw_eq_band4_width |
| 218 | #endif |
| 219 | #endif /* AUDIOHW_HAVE_EQ_BAND4 */ |
| 220 | #ifdef AUDIOHW_HAVE_EQ_BAND5 |
| 221 | ,&hw_eq_band5_gain |
| 222 | #ifdef AUDIOHW_HAVE_EQ_BAND5_FREQUENCY |
| 223 | ,&hw_eq_band5_frequency |
| 224 | #endif |
| 225 | #endif /* AUDIOHW_HAVE_EQ_BAND5 */ |
| 226 | ); |
| 227 | /* Shows only the gains + advanced settings submenu */ |
| 228 | MAKE_MENU(audiohw_eq_tone_controls, ID2P(LANG_HW_EQ_TONE_CONTROLS), |
| 229 | NULL, Icon_NOICON |
| 230 | ,&hw_eq_band1_gain |
| 231 | #ifdef AUDIOHW_HAVE_EQ_BAND2 |
| 232 | ,&hw_eq_band2_gain |
| 233 | #endif |
| 234 | #ifdef AUDIOHW_HAVE_EQ_BAND3 |
| 235 | ,&hw_eq_band3_gain |
| 236 | #endif |
| 237 | #ifdef AUDIOHW_HAVE_EQ_BAND4 |
| 238 | ,&hw_eq_band4_gain |
| 239 | #endif |
| 240 | #ifdef AUDIOHW_HAVE_EQ_BAND5 |
| 241 | ,&hw_eq_band5_gain |
| 242 | #endif |
| 243 | ,&hardware_eq_tone_controls_advanced |
| 244 | ); |
| 245 | |