|
14 | 14 | #include "Driver/es8388/es8388.h"
|
15 | 15 | #include "Driver/tas5805m/tas5805m.h"
|
16 | 16 | #include "Driver/wm8960/mtb_wm8960.h"
|
17 |
| -#include "Driver/wm8994/wm8994.h" |
18 | 17 | #include "Driver/wm8978/WM8978.h"
|
| 18 | +#include "Driver/wm8994/wm8994.h" |
19 | 19 | #include "DriverPins.h"
|
20 | 20 |
|
21 | 21 | namespace audio_driver {
|
@@ -1081,7 +1081,7 @@ class AudioDriverWM8960Class : public AudioDriver {
|
1081 | 1081 | */
|
1082 | 1082 | class AudioDriverWM8978Class : public AudioDriver {
|
1083 | 1083 | public:
|
1084 |
| - AudioDriverWM8978Class() {} |
| 1084 | + AudioDriverWM8978Class() = default; |
1085 | 1085 |
|
1086 | 1086 | bool begin(CodecConfig codecCfg, DriverPins &pins) override {
|
1087 | 1087 | bool rc = true;
|
@@ -1124,12 +1124,29 @@ class AudioDriverWM8978Class : public AudioDriver {
|
1124 | 1124 | return true;
|
1125 | 1125 | }
|
1126 | 1126 |
|
| 1127 | + /// Mute line 0 = speaker, line 1 = headphones |
| 1128 | + bool setMute(bool mute, int line) override { |
| 1129 | + int scaled = mute ? 0 : map(volume, 0, 100, 0, 63); |
| 1130 | + switch (line) { |
| 1131 | + case 0: |
| 1132 | + wm8078.setSPKvol(scaled); |
| 1133 | + return true; |
| 1134 | + case 1: |
| 1135 | + wm8078.setHPvol(scaled, scaled); |
| 1136 | + return true; |
| 1137 | + default: |
| 1138 | + return false; |
| 1139 | + } |
| 1140 | + return false; |
| 1141 | + } |
| 1142 | + |
1127 | 1143 | bool setMute(bool mute) override {
|
1128 | 1144 | if (mute) {
|
1129 |
| - int tmp = volume; |
1130 |
| - setVolume(0); |
1131 |
| - volume = tmp; |
| 1145 | + // set volume to 0 |
| 1146 | + wm8078.setSPKvol(0); |
| 1147 | + wm8078.setHPvol(0, 0); |
1132 | 1148 | } else {
|
| 1149 | + // restore volume |
1133 | 1150 | setVolume(volume);
|
1134 | 1151 | }
|
1135 | 1152 | return true;
|
@@ -1157,9 +1174,7 @@ class AudioDriverWM8978Class : public AudioDriver {
|
1157 | 1174 |
|
1158 | 1175 | bool isInputVolumeSupported() override { return true; }
|
1159 | 1176 |
|
1160 |
| - WM8978& driver() { |
1161 |
| - return wm8078; |
1162 |
| - } |
| 1177 | + WM8978 &driver() { return wm8078; } |
1163 | 1178 |
|
1164 | 1179 | protected:
|
1165 | 1180 | WM8978 wm8078;
|
|
0 commit comments