diff options
author | Dan Everton <dan@iocaine.org> | 2006-08-14 10:52:05 +0000 |
---|---|---|
committer | Dan Everton <dan@iocaine.org> | 2006-08-14 10:52:05 +0000 |
commit | 8030c804adf4df4a45eeecb3d93e983f58b0c9a0 (patch) | |
tree | 75496afcd5a267a5b7786882f3e3e899a778df57 | |
parent | 6ffe02b27c36acf4c74f31f7fc838d2fe3222e09 (diff) | |
download | rockbox-8030c804adf4df4a45eeecb3d93e983f58b0c9a0.tar.gz rockbox-8030c804adf4df4a45eeecb3d93e983f58b0c9a0.zip |
Add support for the iPod Video hardware equalizer. You can access it from Sound Settings -> Equalizer -> Hardware Equalizer. Note that the peak filters are reported not to work. Based on FS#5791 from Snyper.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@10568 a1c6a512-1295-4272-9138-f99709370657
-rw-r--r-- | apps/eq_menu.c | 419 | ||||
-rw-r--r-- | apps/lang/english.lang | 70 | ||||
-rw-r--r-- | apps/settings.c | 22 | ||||
-rw-r--r-- | apps/settings.h | 22 | ||||
-rw-r--r-- | docs/CREDITS | 1 | ||||
-rw-r--r-- | firmware/drivers/wm8758.c | 25 | ||||
-rw-r--r-- | firmware/export/wm8758.h | 8 |
7 files changed, 558 insertions, 9 deletions
diff --git a/apps/eq_menu.c b/apps/eq_menu.c index 1712469a1d..b863e45926 100644 --- a/apps/eq_menu.c +++ b/apps/eq_menu.c | |||
@@ -45,6 +45,9 @@ | |||
45 | #include "screen_access.h" | 45 | #include "screen_access.h" |
46 | #include "keyboard.h" | 46 | #include "keyboard.h" |
47 | #include "gui/scrollbar.h" | 47 | #include "gui/scrollbar.h" |
48 | #ifdef HAVE_WM8758 | ||
49 | #include "wm8758.h" | ||
50 | #endif | ||
48 | 51 | ||
49 | /* Key definitions */ | 52 | /* Key definitions */ |
50 | #if (CONFIG_KEYPAD == IRIVER_H100_PAD || \ | 53 | #if (CONFIG_KEYPAD == IRIVER_H100_PAD || \ |
@@ -272,7 +275,7 @@ static bool eq_gain_menu(void) | |||
272 | setting += 3; | 275 | setting += 3; |
273 | } | 276 | } |
274 | 277 | ||
275 | m=menu_init( items, sizeof(items) / sizeof(*items), NULL, | 278 | m = menu_init( items, sizeof(items) / sizeof(*items), NULL, |
276 | NULL, NULL, NULL); | 279 | NULL, NULL, NULL); |
277 | result = menu_run(m); | 280 | result = menu_run(m); |
278 | menu_exit(m); | 281 | menu_exit(m); |
@@ -290,7 +293,7 @@ static bool eq_set_band0(void) | |||
290 | { ID2P(LANG_EQUALIZER_BAND_GAIN), eq_set_band0_gain }, | 293 | { ID2P(LANG_EQUALIZER_BAND_GAIN), eq_set_band0_gain }, |
291 | }; | 294 | }; |
292 | 295 | ||
293 | m=menu_init( items, sizeof(items) / sizeof(*items), NULL, | 296 | m = menu_init( items, sizeof(items) / sizeof(*items), NULL, |
294 | NULL, NULL, NULL); | 297 | NULL, NULL, NULL); |
295 | result = menu_run(m); | 298 | result = menu_run(m); |
296 | menu_exit(m); | 299 | menu_exit(m); |
@@ -308,7 +311,7 @@ static bool eq_set_band1(void) | |||
308 | { ID2P(LANG_EQUALIZER_BAND_GAIN), eq_set_band1_gain }, | 311 | { ID2P(LANG_EQUALIZER_BAND_GAIN), eq_set_band1_gain }, |
309 | }; | 312 | }; |
310 | 313 | ||
311 | m=menu_init( items, sizeof(items) / sizeof(*items), NULL, | 314 | m = menu_init( items, sizeof(items) / sizeof(*items), NULL, |
312 | NULL, NULL, NULL); | 315 | NULL, NULL, NULL); |
313 | result = menu_run(m); | 316 | result = menu_run(m); |
314 | menu_exit(m); | 317 | menu_exit(m); |
@@ -326,7 +329,7 @@ static bool eq_set_band2(void) | |||
326 | { ID2P(LANG_EQUALIZER_BAND_GAIN), eq_set_band2_gain }, | 329 | { ID2P(LANG_EQUALIZER_BAND_GAIN), eq_set_band2_gain }, |
327 | }; | 330 | }; |
328 | 331 | ||
329 | m=menu_init( items, sizeof(items) / sizeof(*items), NULL, | 332 | m = menu_init( items, sizeof(items) / sizeof(*items), NULL, |
330 | NULL, NULL, NULL); | 333 | NULL, NULL, NULL); |
331 | result = menu_run(m); | 334 | result = menu_run(m); |
332 | menu_exit(m); | 335 | menu_exit(m); |
@@ -344,7 +347,7 @@ static bool eq_set_band3(void) | |||
344 | { ID2P(LANG_EQUALIZER_BAND_GAIN), eq_set_band3_gain }, | 347 | { ID2P(LANG_EQUALIZER_BAND_GAIN), eq_set_band3_gain }, |
345 | }; | 348 | }; |
346 | 349 | ||
347 | m=menu_init( items, sizeof(items) / sizeof(*items), NULL, | 350 | m = menu_init( items, sizeof(items) / sizeof(*items), NULL, |
348 | NULL, NULL, NULL); | 351 | NULL, NULL, NULL); |
349 | result = menu_run(m); | 352 | result = menu_run(m); |
350 | menu_exit(m); | 353 | menu_exit(m); |
@@ -362,7 +365,7 @@ static bool eq_set_band4(void) | |||
362 | { ID2P(LANG_EQUALIZER_BAND_GAIN), eq_set_band4_gain }, | 365 | { ID2P(LANG_EQUALIZER_BAND_GAIN), eq_set_band4_gain }, |
363 | }; | 366 | }; |
364 | 367 | ||
365 | m=menu_init( items, sizeof(items) / sizeof(*items), NULL, | 368 | m = menu_init( items, sizeof(items) / sizeof(*items), NULL, |
366 | NULL, NULL, NULL); | 369 | NULL, NULL, NULL); |
367 | result = menu_run(m); | 370 | result = menu_run(m); |
368 | menu_exit(m); | 371 | menu_exit(m); |
@@ -390,7 +393,7 @@ static bool eq_advanced_menu(void) | |||
390 | items[i].desc = peak_band_label[i-1]; | 393 | items[i].desc = peak_band_label[i-1]; |
391 | } | 394 | } |
392 | 395 | ||
393 | m=menu_init( items, sizeof(items) / sizeof(*items), NULL, | 396 | m = menu_init( items, sizeof(items) / sizeof(*items), NULL, |
394 | NULL, NULL, NULL); | 397 | NULL, NULL, NULL); |
395 | result = menu_run(m); | 398 | result = menu_run(m); |
396 | menu_exit(m); | 399 | menu_exit(m); |
@@ -845,6 +848,403 @@ bool eq_browse_presets(void) | |||
845 | return rockbox_browse(EQS_DIR, SHOW_CFG); | 848 | return rockbox_browse(EQS_DIR, SHOW_CFG); |
846 | } | 849 | } |
847 | 850 | ||
851 | #ifdef HAVE_WM8758 | ||
852 | |||
853 | /* WM8758 equalizer supports -12 to +12 dB gain in 1 dB increments. */ | ||
854 | #define EQ_HW_GAIN_STEP 1 | ||
855 | #define EQ_HW_GAIN_MIN -12 | ||
856 | #define EQ_HW_GAIN_MAX 12 | ||
857 | |||
858 | static const struct opt_items BANDWIDTH_NAMES[] = { | ||
859 | { STR(LANG_EQUALIZER_HARDWARE_BANDWIDTH_NARROW) }, | ||
860 | { STR(LANG_EQUALIZER_HARDWARE_BANDWIDTH_WIDE) }, | ||
861 | }; | ||
862 | |||
863 | static const int BANDWIDTH_NAMES_SIZE = sizeof(BANDWIDTH_NAMES) / | ||
864 | sizeof(*BANDWIDTH_NAMES); | ||
865 | |||
866 | static void eq_hw_gain_format(char* buffer, int buffer_size, int value, | ||
867 | const char* unit) | ||
868 | { | ||
869 | snprintf(buffer, buffer_size, "%d %s", value, unit); | ||
870 | } | ||
871 | |||
872 | static bool eq_hw_set_band0_cutoff(void) | ||
873 | { | ||
874 | static const struct opt_items names[] = { | ||
875 | { (unsigned char *)"80 Hz", TALK_ID(80, UNIT_HERTZ) }, | ||
876 | { (unsigned char *)"105 Hz", TALK_ID(105, UNIT_HERTZ) }, | ||
877 | { (unsigned char *)"135 Hz", TALK_ID(135, UNIT_HERTZ) }, | ||
878 | { (unsigned char *)"175 Hz", TALK_ID(175, UNIT_HERTZ) }, | ||
879 | }; | ||
880 | |||
881 | bool result = set_option(str(LANG_EQUALIZER_BANDWIDTH), | ||
882 | &global_settings.eq_hw_band0_cutoff, INT, names, | ||
883 | sizeof(names) / sizeof(*names), NULL); | ||
884 | |||
885 | #ifndef SIMULATOR | ||
886 | wmcodec_set_equalizer_band(0, global_settings.eq_hw_band0_cutoff, 0, | ||
887 | global_settings.eq_hw_band0_gain); | ||
888 | #endif | ||
889 | |||
890 | return result; | ||
891 | } | ||
892 | |||
893 | static bool eq_hw_set_band0_gain(void) | ||
894 | { | ||
895 | bool result = set_int(str(LANG_EQUALIZER_BAND_GAIN), str(LANG_UNIT_DB), UNIT_DB, | ||
896 | &global_settings.eq_hw_band0_gain, NULL, | ||
897 | EQ_HW_GAIN_STEP, EQ_HW_GAIN_MIN, EQ_HW_GAIN_MAX, | ||
898 | eq_hw_gain_format); | ||
899 | |||
900 | #ifndef SIMULATOR | ||
901 | wmcodec_set_equalizer_band(0, global_settings.eq_hw_band0_cutoff, 0, | ||
902 | global_settings.eq_hw_band0_gain); | ||
903 | #endif | ||
904 | |||
905 | return result; | ||
906 | } | ||
907 | |||
908 | static bool eq_hw_set_band1_center(void) | ||
909 | { | ||
910 | static const struct opt_items names[] = { | ||
911 | { (unsigned char *)"230 Hz", TALK_ID(230, UNIT_HERTZ) }, | ||
912 | { (unsigned char *)"300 Hz", TALK_ID(300, UNIT_HERTZ) }, | ||
913 | { (unsigned char *)"385 Hz", TALK_ID(385, UNIT_HERTZ) }, | ||
914 | { (unsigned char *)"500 Hz", TALK_ID(500, UNIT_HERTZ) }, | ||
915 | }; | ||
916 | |||
917 | bool result = set_option(str(LANG_EQUALIZER_BAND_CENTER), | ||
918 | &global_settings.eq_hw_band1_center, INT, names, | ||
919 | sizeof(names) / sizeof(*names), NULL); | ||
920 | |||
921 | #ifndef SIMULATOR | ||
922 | wmcodec_set_equalizer_band(1, global_settings.eq_hw_band1_center, | ||
923 | global_settings.eq_hw_band1_bandwidth, | ||
924 | global_settings.eq_hw_band1_gain); | ||
925 | #endif | ||
926 | |||
927 | return result; | ||
928 | } | ||
929 | |||
930 | static bool eq_hw_set_band1_bandwidth(void) | ||
931 | { | ||
932 | bool result = set_option(str(LANG_EQUALIZER_BANDWIDTH), | ||
933 | &global_settings.eq_hw_band1_bandwidth, INT, BANDWIDTH_NAMES, | ||
934 | BANDWIDTH_NAMES_SIZE, NULL); | ||
935 | |||
936 | #ifndef SIMULATOR | ||
937 | wmcodec_set_equalizer_band(1, global_settings.eq_hw_band1_center, | ||
938 | global_settings.eq_hw_band1_bandwidth, | ||
939 | global_settings.eq_hw_band1_gain); | ||
940 | #endif | ||
941 | |||
942 | return result; | ||
943 | } | ||
944 | |||
945 | static bool eq_hw_set_band1_gain(void) | ||
946 | { | ||
947 | bool result = set_int(str(LANG_EQUALIZER_BAND_GAIN), str(LANG_UNIT_DB), UNIT_DB, | ||
948 | &global_settings.eq_hw_band1_gain, NULL, | ||
949 | EQ_HW_GAIN_STEP, EQ_HW_GAIN_MIN, EQ_HW_GAIN_MAX, | ||
950 | eq_hw_gain_format); | ||
951 | |||
952 | #ifndef SIMULATOR | ||
953 | wmcodec_set_equalizer_band(1, global_settings.eq_hw_band1_center, | ||
954 | global_settings.eq_hw_band1_bandwidth, | ||
955 | global_settings.eq_hw_band1_gain); | ||
956 | #endif | ||
957 | |||
958 | return result; | ||
959 | } | ||
960 | |||
961 | static bool eq_hw_set_band2_center(void) | ||
962 | { | ||
963 | static const struct opt_items names[] = { | ||
964 | { (unsigned char *)"650 Hz", TALK_ID(650, UNIT_HERTZ) }, | ||
965 | { (unsigned char *)"850 Hz", TALK_ID(850, UNIT_HERTZ) }, | ||
966 | { (unsigned char *)"1.1 kHz", TALK_ID(1100, UNIT_HERTZ) }, | ||
967 | { (unsigned char *)"1.4 kHz", TALK_ID(1400, UNIT_HERTZ) }, | ||
968 | }; | ||
969 | |||
970 | bool result = set_option(str(LANG_EQUALIZER_BAND_CENTER), | ||
971 | &global_settings.eq_hw_band2_center, INT, names, | ||
972 | sizeof(names) / sizeof(*names), NULL); | ||
973 | |||
974 | #ifndef SIMULATOR | ||
975 | wmcodec_set_equalizer_band(2, global_settings.eq_hw_band2_center, | ||
976 | global_settings.eq_hw_band2_bandwidth, | ||
977 | global_settings.eq_hw_band2_gain); | ||
978 | #endif | ||
979 | |||
980 | return result; | ||
981 | } | ||
982 | |||
983 | static bool eq_hw_set_band2_bandwidth(void) | ||
984 | { | ||
985 | bool result = set_option(str(LANG_EQUALIZER_BANDWIDTH), | ||
986 | &global_settings.eq_hw_band2_bandwidth, INT, BANDWIDTH_NAMES, | ||
987 | BANDWIDTH_NAMES_SIZE, NULL); | ||
988 | |||
989 | #ifndef SIMULATOR | ||
990 | wmcodec_set_equalizer_band(2, global_settings.eq_hw_band2_center, | ||
991 | global_settings.eq_hw_band2_bandwidth, | ||
992 | global_settings.eq_hw_band2_gain); | ||
993 | #endif | ||
994 | |||
995 | return result; | ||
996 | } | ||
997 | |||
998 | static bool eq_hw_set_band2_gain(void) | ||
999 | { | ||
1000 | bool result = set_int(str(LANG_EQUALIZER_BAND_GAIN), str(LANG_UNIT_DB), UNIT_DB, | ||
1001 | &global_settings.eq_hw_band2_gain, NULL, | ||
1002 | EQ_HW_GAIN_STEP, EQ_HW_GAIN_MIN, EQ_HW_GAIN_MAX, | ||
1003 | eq_hw_gain_format); | ||
1004 | |||
1005 | #ifndef SIMULATOR | ||
1006 | wmcodec_set_equalizer_band(2, global_settings.eq_hw_band2_center, | ||
1007 | global_settings.eq_hw_band2_bandwidth, | ||
1008 | global_settings.eq_hw_band2_gain); | ||
1009 | #endif | ||
1010 | |||
1011 | return result; | ||
1012 | } | ||
1013 | |||
1014 | static bool eq_hw_set_band3_center(void) | ||
1015 | { | ||
1016 | static const struct opt_items names[] = { | ||
1017 | { (unsigned char *)"1.8 kHz", TALK_ID(1800, UNIT_HERTZ) }, | ||
1018 | { (unsigned char *)"2.4 kHz", TALK_ID(2400, UNIT_HERTZ) }, | ||
1019 | { (unsigned char *)"3.2 kHz", TALK_ID(3200, UNIT_HERTZ) }, | ||
1020 | { (unsigned char *)"4.1 kHz", TALK_ID(4100, UNIT_HERTZ) }, | ||
1021 | }; | ||
1022 | |||
1023 | bool result = set_option(str(LANG_EQUALIZER_BAND_CENTER), | ||
1024 | &global_settings.eq_hw_band3_center, INT, names, | ||
1025 | sizeof(names) / sizeof(*names), NULL); | ||
1026 | |||
1027 | #ifndef SIMULATOR | ||
1028 | wmcodec_set_equalizer_band(3, global_settings.eq_hw_band3_center, | ||
1029 | global_settings.eq_hw_band3_bandwidth, | ||
1030 | global_settings.eq_hw_band3_gain); | ||
1031 | #endif | ||
1032 | |||
1033 | return result; | ||
1034 | } | ||
1035 | |||
1036 | static bool eq_hw_set_band3_bandwidth(void) | ||
1037 | { | ||
1038 | bool result = set_option(str(LANG_EQUALIZER_BANDWIDTH), | ||
1039 | &global_settings.eq_hw_band3_bandwidth, INT, BANDWIDTH_NAMES, | ||
1040 | BANDWIDTH_NAMES_SIZE, NULL); | ||
1041 | |||
1042 | #ifndef SIMULATOR | ||
1043 | wmcodec_set_equalizer_band(3, global_settings.eq_hw_band3_center, | ||
1044 | global_settings.eq_hw_band3_bandwidth, | ||
1045 | global_settings.eq_hw_band3_gain); | ||
1046 | #endif | ||
1047 | |||
1048 | return result; | ||
1049 | } | ||
1050 | |||
1051 | static bool eq_hw_set_band3_gain(void) | ||
1052 | { | ||
1053 | bool result = set_int(str(LANG_EQUALIZER_BAND_GAIN), str(LANG_UNIT_DB), UNIT_DB, | ||
1054 | &global_settings.eq_hw_band3_gain, NULL, | ||
1055 | EQ_HW_GAIN_STEP, EQ_HW_GAIN_MIN, EQ_HW_GAIN_MAX, | ||
1056 | eq_hw_gain_format); | ||
1057 | |||
1058 | #ifndef SIMULATOR | ||
1059 | wmcodec_set_equalizer_band(3, global_settings.eq_hw_band3_center, | ||
1060 | global_settings.eq_hw_band3_bandwidth, | ||
1061 | global_settings.eq_hw_band3_gain); | ||
1062 | #endif | ||
1063 | |||
1064 | return result; | ||
1065 | } | ||
1066 | |||
1067 | static bool eq_hw_set_band4_cutoff(void) | ||
1068 | { | ||
1069 | static const struct opt_items names[] = { | ||
1070 | { (unsigned char *)"5.3 kHz", TALK_ID(5300, UNIT_HERTZ) }, | ||
1071 | { (unsigned char *)"6.9 kHz", TALK_ID(6900, UNIT_HERTZ) }, | ||
1072 | { (unsigned char *)"9.0 kHz", TALK_ID(9000, UNIT_HERTZ) }, | ||
1073 | { (unsigned char *)"11.7 kHz", TALK_ID(11700, UNIT_HERTZ) }, | ||
1074 | }; | ||
1075 | |||
1076 | bool result = set_option(str(LANG_EQUALIZER_BAND_CUTOFF), | ||
1077 | &global_settings.eq_hw_band4_cutoff, INT, names, | ||
1078 | sizeof(names) / sizeof(*names), NULL); | ||
1079 | |||
1080 | #ifndef SIMULATOR | ||
1081 | wmcodec_set_equalizer_band(4, global_settings.eq_hw_band4_cutoff, 0, | ||
1082 | global_settings.eq_hw_band4_gain); | ||
1083 | #endif | ||
1084 | |||
1085 | return result; | ||
1086 | } | ||
1087 | |||
1088 | static bool eq_hw_set_band4_gain(void) | ||
1089 | { | ||
1090 | bool result = set_int(str(LANG_EQUALIZER_BAND_GAIN), str(LANG_UNIT_DB), UNIT_DB, | ||
1091 | &global_settings.eq_hw_band4_gain, NULL, | ||
1092 | EQ_HW_GAIN_STEP, EQ_HW_GAIN_MIN, EQ_HW_GAIN_MAX, | ||
1093 | eq_hw_gain_format); | ||
1094 | |||
1095 | #ifndef SIMULATOR | ||
1096 | wmcodec_set_equalizer_band(4, global_settings.eq_hw_band4_cutoff, 0, | ||
1097 | global_settings.eq_hw_band4_gain); | ||
1098 | #endif | ||
1099 | |||
1100 | return result; | ||
1101 | } | ||
1102 | |||
1103 | static bool eq_hw_enabled(void) | ||
1104 | { | ||
1105 | bool result = set_bool(str(LANG_EQUALIZER_HARDWARE_ENABLED), | ||
1106 | &global_settings.eq_hw_enabled); | ||
1107 | |||
1108 | #ifndef SIMULATOR | ||
1109 | if (global_settings.eq_hw_enabled) { | ||
1110 | wmcodec_set_equalizer_band(0, global_settings.eq_hw_band0_cutoff, | ||
1111 | 0, global_settings.eq_hw_band0_gain); | ||
1112 | wmcodec_set_equalizer_band(1, global_settings.eq_hw_band1_center, | ||
1113 | global_settings.eq_hw_band1_bandwidth, | ||
1114 | global_settings.eq_hw_band1_gain); | ||
1115 | wmcodec_set_equalizer_band(2, global_settings.eq_hw_band2_center, | ||
1116 | global_settings.eq_hw_band2_bandwidth, | ||
1117 | global_settings.eq_hw_band2_gain); | ||
1118 | wmcodec_set_equalizer_band(3, global_settings.eq_hw_band3_center, | ||
1119 | global_settings.eq_hw_band3_bandwidth, | ||
1120 | global_settings.eq_hw_band3_gain); | ||
1121 | wmcodec_set_equalizer_band(4, global_settings.eq_hw_band4_cutoff, | ||
1122 | 0, global_settings.eq_hw_band4_gain); | ||
1123 | } else { | ||
1124 | wmcodec_set_equalizer_band(0, global_settings.eq_hw_band0_cutoff, 0, 0); | ||
1125 | wmcodec_set_equalizer_band(1, global_settings.eq_hw_band1_center, | ||
1126 | global_settings.eq_hw_band1_bandwidth, 0); | ||
1127 | wmcodec_set_equalizer_band(2, global_settings.eq_hw_band2_center, | ||
1128 | global_settings.eq_hw_band2_bandwidth, 0); | ||
1129 | wmcodec_set_equalizer_band(3, global_settings.eq_hw_band3_center, | ||
1130 | global_settings.eq_hw_band3_bandwidth, 0); | ||
1131 | wmcodec_set_equalizer_band(4, global_settings.eq_hw_band4_cutoff, 0, 0); | ||
1132 | } | ||
1133 | #endif | ||
1134 | |||
1135 | return result; | ||
1136 | } | ||
1137 | |||
1138 | static bool eq_hw_set_band0(void) | ||
1139 | { | ||
1140 | int m; | ||
1141 | bool result; | ||
1142 | static const struct menu_item items[] = { | ||
1143 | { ID2P(LANG_EQUALIZER_BAND_CUTOFF), eq_hw_set_band0_cutoff }, | ||
1144 | { ID2P(LANG_EQUALIZER_BAND_GAIN), eq_hw_set_band0_gain }, | ||
1145 | }; | ||
1146 | |||
1147 | m = menu_init( items, sizeof(items) / sizeof(*items), NULL, | ||
1148 | NULL, NULL, NULL); | ||
1149 | result = menu_run(m); | ||
1150 | menu_exit(m); | ||
1151 | |||
1152 | return result; | ||
1153 | } | ||
1154 | |||
1155 | static bool eq_hw_set_band1(void) | ||
1156 | { | ||
1157 | int m; | ||
1158 | bool result; | ||
1159 | static const struct menu_item items[] = { | ||
1160 | { ID2P(LANG_EQUALIZER_BAND_CENTER), eq_hw_set_band1_center }, | ||
1161 | { ID2P(LANG_EQUALIZER_BANDWIDTH), eq_hw_set_band1_bandwidth }, | ||
1162 | { ID2P(LANG_EQUALIZER_BAND_GAIN), eq_hw_set_band1_gain }, | ||
1163 | }; | ||
1164 | |||
1165 | m = menu_init( items, sizeof(items) / sizeof(*items), NULL, | ||
1166 | NULL, NULL, NULL); | ||
1167 | result = menu_run(m); | ||
1168 | menu_exit(m); | ||
1169 | |||
1170 | return result; | ||
1171 | } | ||
1172 | |||
1173 | static bool eq_hw_set_band2(void) | ||
1174 | { | ||
1175 | int m; | ||
1176 | bool result; | ||
1177 | static const struct menu_item items[] = { | ||
1178 | { ID2P(LANG_EQUALIZER_BAND_CENTER), eq_hw_set_band2_center }, | ||
1179 | { ID2P(LANG_EQUALIZER_BANDWIDTH), eq_hw_set_band2_bandwidth }, | ||
1180 | { ID2P(LANG_EQUALIZER_BAND_GAIN), eq_hw_set_band2_gain }, | ||
1181 | }; | ||
1182 | |||
1183 | m = menu_init( items, sizeof(items) / sizeof(*items), NULL, | ||
1184 | NULL, NULL, NULL); | ||
1185 | result = menu_run(m); | ||
1186 | menu_exit(m); | ||
1187 | |||
1188 | return result; | ||
1189 | } | ||
1190 | |||
1191 | static bool eq_hw_set_band3(void) | ||
1192 | { | ||
1193 | int m; | ||
1194 | bool result; | ||
1195 | static const struct menu_item items[] = { | ||
1196 | { ID2P(LANG_EQUALIZER_BAND_CENTER), eq_hw_set_band3_center }, | ||
1197 | { ID2P(LANG_EQUALIZER_BANDWIDTH), eq_hw_set_band3_bandwidth }, | ||
1198 | { ID2P(LANG_EQUALIZER_BAND_GAIN), eq_hw_set_band3_gain }, | ||
1199 | }; | ||
1200 | |||
1201 | m = menu_init( items, sizeof(items) / sizeof(*items), NULL, | ||
1202 | NULL, NULL, NULL); | ||
1203 | result = menu_run(m); | ||
1204 | menu_exit(m); | ||
1205 | |||
1206 | return result; | ||
1207 | } | ||
1208 | |||
1209 | static bool eq_hw_set_band4(void) | ||
1210 | { | ||
1211 | int m; | ||
1212 | bool result; | ||
1213 | static const struct menu_item items[] = { | ||
1214 | { ID2P(LANG_EQUALIZER_BAND_CUTOFF), eq_hw_set_band4_cutoff }, | ||
1215 | { ID2P(LANG_EQUALIZER_BAND_GAIN), eq_hw_set_band4_gain }, | ||
1216 | }; | ||
1217 | |||
1218 | m = menu_init( items, sizeof(items) / sizeof(*items), NULL, | ||
1219 | NULL, NULL, NULL); | ||
1220 | result = menu_run(m); | ||
1221 | menu_exit(m); | ||
1222 | |||
1223 | return result; | ||
1224 | } | ||
1225 | |||
1226 | static bool eq_hw_menu(void) | ||
1227 | { | ||
1228 | int m; | ||
1229 | bool result; | ||
1230 | static const struct menu_item items[] = { | ||
1231 | { ID2P(LANG_EQUALIZER_HARDWARE_ENABLED), eq_hw_enabled }, | ||
1232 | { ID2P(LANG_EQUALIZER_BAND_LOW_SHELF), eq_hw_set_band0 }, | ||
1233 | { "Peak Filter 1", eq_hw_set_band1 }, | ||
1234 | { "Peak Filter 2", eq_hw_set_band2 }, | ||
1235 | { "Peak Filter 3", eq_hw_set_band3 }, | ||
1236 | { ID2P(LANG_EQUALIZER_BAND_HIGH_SHELF), eq_hw_set_band4 }, | ||
1237 | }; | ||
1238 | |||
1239 | m = menu_init( items, sizeof(items) / sizeof(*items), NULL, | ||
1240 | NULL, NULL, NULL); | ||
1241 | result = menu_run(m); | ||
1242 | menu_exit(m); | ||
1243 | |||
1244 | return result; | ||
1245 | } | ||
1246 | #endif | ||
1247 | |||
848 | /* Full equalizer menu */ | 1248 | /* Full equalizer menu */ |
849 | bool eq_menu(void) | 1249 | bool eq_menu(void) |
850 | { | 1250 | { |
@@ -856,11 +1256,14 @@ bool eq_menu(void) | |||
856 | { ID2P(LANG_EQUALIZER_PRECUT), eq_precut }, | 1256 | { ID2P(LANG_EQUALIZER_PRECUT), eq_precut }, |
857 | { ID2P(LANG_EQUALIZER_GAIN), eq_gain_menu }, | 1257 | { ID2P(LANG_EQUALIZER_GAIN), eq_gain_menu }, |
858 | { ID2P(LANG_EQUALIZER_ADVANCED), eq_advanced_menu }, | 1258 | { ID2P(LANG_EQUALIZER_ADVANCED), eq_advanced_menu }, |
1259 | #ifdef HAVE_WM8758 | ||
1260 | { ID2P(LANG_EQUALIZER_HARDWARE), eq_hw_menu }, | ||
1261 | #endif | ||
859 | { ID2P(LANG_EQUALIZER_SAVE), eq_save_preset }, | 1262 | { ID2P(LANG_EQUALIZER_SAVE), eq_save_preset }, |
860 | { ID2P(LANG_EQUALIZER_BROWSE), eq_browse_presets }, | 1263 | { ID2P(LANG_EQUALIZER_BROWSE), eq_browse_presets }, |
861 | }; | 1264 | }; |
862 | 1265 | ||
863 | m=menu_init( items, sizeof(items) / sizeof(*items), NULL, | 1266 | m = menu_init( items, sizeof(items) / sizeof(*items), NULL, |
864 | NULL, NULL, NULL); | 1267 | NULL, NULL, NULL); |
865 | result = menu_run(m); | 1268 | result = menu_run(m); |
866 | menu_exit(m); | 1269 | menu_exit(m); |
diff --git a/apps/lang/english.lang b/apps/lang/english.lang index 88b24ec567..b11b996570 100644 --- a/apps/lang/english.lang +++ b/apps/lang/english.lang | |||
@@ -9548,3 +9548,73 @@ | |||
9548 | *: "" | 9548 | *: "" |
9549 | </voice> | 9549 | </voice> |
9550 | </phrase> | 9550 | </phrase> |
9551 | <phrase> | ||
9552 | id: LANG_EQUALIZER_HARDWARE | ||
9553 | desc: in the sound settings menu | ||
9554 | user: | ||
9555 | <source> | ||
9556 | *: "Hardware Equalizer" | ||
9557 | </source> | ||
9558 | <dest> | ||
9559 | *: "Hardware Equalizer" | ||
9560 | </dest> | ||
9561 | <voice> | ||
9562 | *: "Hardware equalizer" | ||
9563 | </voice> | ||
9564 | </phrase> | ||
9565 | <phrase> | ||
9566 | id: LANG_EQUALIZER_HARDWARE_ENABLED | ||
9567 | desc: in the equalizer settings menu | ||
9568 | user: | ||
9569 | <source> | ||
9570 | *: "Enable Hardware EQ" | ||
9571 | </source> | ||
9572 | <dest> | ||
9573 | *: "Enable Hardware EQ" | ||
9574 | </dest> | ||
9575 | <voice> | ||
9576 | *: "Enable hardware equalizer" | ||
9577 | </voice> | ||
9578 | </phrase> | ||
9579 | <phrase> | ||
9580 | id: LANG_EQUALIZER_BANDWIDTH | ||
9581 | desc: in the equalizer settings menu | ||
9582 | user: | ||
9583 | <source> | ||
9584 | *: "Bandwidth" | ||
9585 | </source> | ||
9586 | <dest> | ||
9587 | *: "Bandwidth" | ||
9588 | </dest> | ||
9589 | <voice> | ||
9590 | *: "Bandwidth" | ||
9591 | </voice> | ||
9592 | </phrase> | ||
9593 | <phrase> | ||
9594 | id: LANG_EQUALIZER_HARDWARE_BANDWIDTH_NARROW | ||
9595 | desc: in the equalizer settings menu | ||
9596 | user: | ||
9597 | <source> | ||
9598 | *: "Narrow" | ||
9599 | </source> | ||
9600 | <dest> | ||
9601 | *: "Narrow" | ||
9602 | </dest> | ||
9603 | <voice> | ||
9604 | *: "Narrow" | ||
9605 | </voice> | ||
9606 | </phrase> | ||
9607 | <phrase> | ||
9608 | id: LANG_EQUALIZER_HARDWARE_BANDWIDTH_WIDE | ||
9609 | desc: in the equalizer settings menu | ||
9610 | user: | ||
9611 | <source> | ||
9612 | *: "Wide" | ||
9613 | </source> | ||
9614 | <dest> | ||
9615 | *: "Wide" | ||
9616 | </dest> | ||
9617 | <voice> | ||
9618 | *: "Wide" | ||
9619 | </voice> | ||
9620 | </phrase> | ||
diff --git a/apps/settings.c b/apps/settings.c index 0901095dd6..2a232764fb 100644 --- a/apps/settings.c +++ b/apps/settings.c | |||
@@ -592,8 +592,28 @@ static const struct bit_entry hd_bits[] = | |||
592 | #endif | 592 | #endif |
593 | #endif /* CONFIG_BACKLIGHT */ | 593 | #endif /* CONFIG_BACKLIGHT */ |
594 | 594 | ||
595 | 595 | #ifdef HAVE_WM8758 | |
596 | {1, S_O(eq_hw_enabled), false, "eq hardware enabled", off_on }, | ||
596 | 597 | ||
598 | {2, S_O(eq_hw_band0_cutoff), 1, "eq hardware band 0 cutoff", "80Hz,105Hz,135Hz,175Hz" }, | ||
599 | {6|SIGNED, S_O(eq_hw_band0_gain), 12, "eq hardware band 0 gain", NULL }, | ||
600 | |||
601 | {2, S_O(eq_hw_band1_center), 1, "eq hardware band 1 center", "230Hz,300Hz,385Hz,500Hz" }, | ||
602 | {1, S_O(eq_hw_band1_bandwidth), 0, "eq hardware band 1 bandwidth", "narrow,wide" }, | ||
603 | {6|SIGNED, S_O(eq_hw_band1_gain), 12, "eq hardware band 1 gain", NULL }, | ||
604 | |||
605 | {2, S_O(eq_hw_band2_center), 1, "eq hardware band 2 center", "650Hz,850Hz,1.1kHz,1.4kHz" }, | ||
606 | {1, S_O(eq_hw_band2_bandwidth), 0, "eq hardware band 2 bandwidth", "narrow,wide" }, | ||
607 | {6|SIGNED, S_O(eq_hw_band2_gain), 12, "eq hardware band 2 gain", NULL }, | ||
608 | |||
609 | {2, S_O(eq_hw_band3_center), 1, "eq hardware band 3 center", "1.8kHz,2.4kHz,3.2kHz,4.1kHz" }, | ||
610 | {1, S_O(eq_hw_band3_bandwidth), 0, "eq hardware band 3 bandwidth", "narrow,wide" }, | ||
611 | {6|SIGNED, S_O(eq_hw_band3_gain), 12, "eq hardware band 3 gain", NULL }, | ||
612 | |||
613 | {2, S_O(eq_hw_band4_cutoff), 1, "eq hardware band 4 cutoff", "5.3kHz,6.9kHz,9kHz,11.7kHz" }, | ||
614 | {6|SIGNED, S_O(eq_hw_band4_gain), 12, "eq hardware band 4 gain", NULL }, | ||
615 | #endif | ||
616 | |||
597 | /* If values are just added to the end, no need to bump the version. */ | 617 | /* If values are just added to the end, no need to bump the version. */ |
598 | /* new stuff to be added at the end */ | 618 | /* new stuff to be added at the end */ |
599 | 619 | ||
diff --git a/apps/settings.h b/apps/settings.h index 369e1ebd6b..2d2c125721 100644 --- a/apps/settings.h +++ b/apps/settings.h | |||
@@ -542,6 +542,28 @@ struct user_settings | |||
542 | #ifdef HAVE_LCD_BITMAP | 542 | #ifdef HAVE_LCD_BITMAP |
543 | unsigned char kbd_file[MAX_FILENAME+1]; /* last keyboard */ | 543 | unsigned char kbd_file[MAX_FILENAME+1]; /* last keyboard */ |
544 | #endif | 544 | #endif |
545 | |||
546 | #ifdef HAVE_WM8758 | ||
547 | bool eq_hw_enabled; /* Enable hardware equalizer */ | ||
548 | |||
549 | int eq_hw_band0_cutoff; | ||
550 | int eq_hw_band0_gain; | ||
551 | |||
552 | int eq_hw_band1_center; | ||
553 | int eq_hw_band1_bandwidth; | ||
554 | int eq_hw_band1_gain; | ||
555 | |||
556 | int eq_hw_band2_center; | ||
557 | int eq_hw_band2_bandwidth; | ||
558 | int eq_hw_band2_gain; | ||
559 | |||
560 | int eq_hw_band3_center; | ||
561 | int eq_hw_band3_bandwidth; | ||
562 | int eq_hw_band3_gain; | ||
563 | |||
564 | int eq_hw_band4_cutoff; | ||
565 | int eq_hw_band4_gain; | ||
566 | #endif | ||
545 | }; | 567 | }; |
546 | 568 | ||
547 | enum optiontype { INT, BOOL }; | 569 | enum optiontype { INT, BOOL }; |
diff --git a/docs/CREDITS b/docs/CREDITS index 4029cebe2a..b62608d6c9 100644 --- a/docs/CREDITS +++ b/docs/CREDITS | |||
@@ -224,3 +224,4 @@ Barry Wardell | |||
224 | Lars van de Klomp | 224 | Lars van de Klomp |
225 | Philippe Miossec | 225 | Philippe Miossec |
226 | Jochen Kemnade | 226 | Jochen Kemnade |
227 | Corry Lazarowitz | ||
diff --git a/firmware/drivers/wm8758.c b/firmware/drivers/wm8758.c index f3310f3ed6..b7894e66b7 100644 --- a/firmware/drivers/wm8758.c +++ b/firmware/drivers/wm8758.c | |||
@@ -272,3 +272,28 @@ void wmcodec_set_monitor(int enable) { | |||
272 | 272 | ||
273 | (void)enable; | 273 | (void)enable; |
274 | } | 274 | } |
275 | |||
276 | void wmcodec_set_equalizer_band(int band, int freq, int bw, int gain) | ||
277 | { | ||
278 | unsigned int eq = 0; | ||
279 | |||
280 | /* Band 1..3 are peak filters */ | ||
281 | if (band >= 1 && band <= 3) { | ||
282 | eq |= (bw << 8); | ||
283 | } | ||
284 | |||
285 | eq |= (freq << 5); | ||
286 | eq |= 12 - gain; | ||
287 | |||
288 | if (band == 0) { | ||
289 | wm8758_write(EQ0, eq); | ||
290 | } else if (band == 1) { | ||
291 | wm8758_write(EQ1, eq); | ||
292 | } else if (band == 2) { | ||
293 | wm8758_write(EQ2, eq); | ||
294 | } else if (band == 3) { | ||
295 | wm8758_write(EQ3, eq); | ||
296 | } else if (band == 4) { | ||
297 | wm8758_write(EQ4, eq); | ||
298 | } | ||
299 | } | ||
diff --git a/firmware/export/wm8758.h b/firmware/export/wm8758.h index 13eccb9763..5630a93b1b 100644 --- a/firmware/export/wm8758.h +++ b/firmware/export/wm8758.h | |||
@@ -38,6 +38,8 @@ extern void wmcodec_disable_recording(void); | |||
38 | extern void wmcodec_set_recvol(int left, int right, int type); | 38 | extern void wmcodec_set_recvol(int left, int right, int type); |
39 | extern void wmcodec_set_monitor(int enable); | 39 | extern void wmcodec_set_monitor(int enable); |
40 | 40 | ||
41 | extern void wmcodec_set_equalizer_band(int band, int freq, int bw, int gain); | ||
42 | |||
41 | #define RESET 0x00 | 43 | #define RESET 0x00 |
42 | #define PWRMGMT1 0x01 | 44 | #define PWRMGMT1 0x01 |
43 | #define PWRMGMT2 0x02 | 45 | #define PWRMGMT2 0x02 |
@@ -60,6 +62,12 @@ extern void wmcodec_set_monitor(int enable); | |||
60 | #define PLLK2 0x26 | 62 | #define PLLK2 0x26 |
61 | #define PLLK3 0x27 | 63 | #define PLLK3 0x27 |
62 | 64 | ||
65 | #define EQ0 0x12 | ||
66 | #define EQ1 0x13 | ||
67 | #define EQ2 0x14 | ||
68 | #define EQ3 0x15 | ||
69 | #define EQ4 0x16 | ||
70 | |||
63 | /* Register settings for the supported samplerates: */ | 71 | /* Register settings for the supported samplerates: */ |
64 | #define WM8758_8000HZ 0x4d | 72 | #define WM8758_8000HZ 0x4d |
65 | #define WM8758_12000HZ 0x61 | 73 | #define WM8758_12000HZ 0x61 |