update megiaudioroute.c for 5.9 kernel

When combined with Sam's audio patch, this fixes audio calls on 5.9
kernel.

Source: https://xnux.eu/devices/feature/audio-pp.html
Signed-off-by: Anjandev Momi <anjan@momi.ca>
master
Anjandev Momi 4 years ago
parent c8ca9e850b
commit 55887d9afe
  1. 51
      programs/sxmo_megiaudioroute.c

@ -15,6 +15,8 @@
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>. * along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* 2020-09-29: Updated for the new Samuel's digital codec driver
*/ */
#include <assert.h> #include <assert.h>
@ -205,7 +207,6 @@ struct audio_setup {
bool spk_on; bool spk_on;
bool hp_on; bool hp_on;
bool ear_on; bool ear_on;
bool hpmic_on;
// when sending audio to modem from AIF1 R, also play that back // when sending audio to modem from AIF1 R, also play that back
// to me locally (just like AIF1 L plays just to me) // to me locally (just like AIF1 L plays just to me)
@ -224,7 +225,6 @@ struct audio_setup {
bool dai2_en; bool dai2_en;
int mic_gain; int mic_gain;
int hpmic_gain;
int spk_vol; int spk_vol;
int ear_vol; int ear_vol;
int hp_vol; int hp_vol;
@ -241,7 +241,7 @@ static void audio_set_controls(struct audio_setup* s)
{ .name = "Mic1 Boost Volume", .vals.i = { s->mic_gain } }, { .name = "Mic1 Boost Volume", .vals.i = { s->mic_gain } },
// Mic 2 (headphones) // Mic 2 (headphones)
{ .name = "Mic2 Boost Volume", .vals.i = { s->hpmic_gain } }, { .name = "Mic2 Boost Volume", .vals.i = { 0 } },
// Line in (unused on PP) // Line in (unused on PP)
// no controls yet // no controls yet
@ -249,7 +249,7 @@ static void audio_set_controls(struct audio_setup* s)
// Input mixers before ADC // Input mixers before ADC
{ .name = "Mic1 Capture Switch", .vals.i = { !!s->mic_on, !!s->mic_on } }, { .name = "Mic1 Capture Switch", .vals.i = { !!s->mic_on, !!s->mic_on } },
{ .name = "Mic2 Capture Switch", .vals.i = { !!s->hpmic_on, !!s->hpmic_on } }, { .name = "Mic2 Capture Switch", .vals.i = { 0, 0 } },
{ .name = "Line In Capture Switch", .vals.i = { 0, 0 } }, // Out Mix -> In Mix { .name = "Line In Capture Switch", .vals.i = { 0, 0 } }, // Out Mix -> In Mix
{ .name = "Mixer Capture Switch", .vals.i = { 0, 0 } }, { .name = "Mixer Capture Switch", .vals.i = { 0, 0 } },
{ .name = "Mixer Reversed Capture Switch", .vals.i = { 0, 0 } }, { .name = "Mixer Reversed Capture Switch", .vals.i = { 0, 0 } },
@ -265,11 +265,10 @@ static void audio_set_controls(struct audio_setup* s)
// AIF1 (SoC) // AIF1 (SoC)
// AIF1 slot0 capture mixer sources // AIF1 slot0 capture mixer sources
{ .name = "AIF1 AD0 Mixer ADC Capture Switch", .vals.i = { 1, 0 } }, { .name = "AIF1 Data Digital ADC Capture Switch", .vals.i = { 1, 0 } },
{ .name = "AIF1 AD0 Mixer AIF1 DA0 Capture Switch", .vals.i = { 0, 0 } }, { .name = "AIF1 Slot 0 Digital ADC Capture Switch", .vals.i = { 0, 0 } },
{ .name = "AIF1 AD0 Mixer AIF2 DAC Capture Switch", .vals.i = { 0, 1 } }, { .name = "AIF2 Digital ADC Capture Switch", .vals.i = { 0, 1 } },
{ .name = "AIF1 AD0 Mixer AIF2 DAC Rev Capture Switch", .vals.i = { 0, 0 } }, //XXX: capture right from the left AIF2? { .name = "AIF2 Inv Digital ADC Capture Switch", .vals.i = { 0, 0 } }, //XXX: capture right from the left AIF2?
{ .name = "AIF1 Loopback Switch", .vals.i = { 0 } },
// AIF1 slot0 capture/playback mono mixing/digital volume // AIF1 slot0 capture/playback mono mixing/digital volume
{ .name = "AIF1 AD0 Capture Volume", .vals.i = { 160, 160 } }, { .name = "AIF1 AD0 Capture Volume", .vals.i = { 160, 160 } },
@ -283,7 +282,6 @@ static void audio_set_controls(struct audio_setup* s)
{ .name = "AIF2 ADC Mixer ADC Capture Switch", .vals.i = { !!s->to_modem_on && !!s->dai2_en, 0 } }, // from adc/mic { .name = "AIF2 ADC Mixer ADC Capture Switch", .vals.i = { !!s->to_modem_on && !!s->dai2_en, 0 } }, // from adc/mic
{ .name = "AIF2 ADC Mixer AIF1 DA0 Capture Switch", .vals.i = { 0, 1 } }, // from aif1 R { .name = "AIF2 ADC Mixer AIF1 DA0 Capture Switch", .vals.i = { 0, 1 } }, // from aif1 R
{ .name = "AIF2 ADC Mixer AIF2 DAC Rev Capture Switch", .vals.i = { 0, 0 } }, { .name = "AIF2 ADC Mixer AIF2 DAC Rev Capture Switch", .vals.i = { 0, 0 } },
{ .name = "AIF2 Loopback Switch", .vals.i = { 0 } },
// AIF2 capture/playback mono mixing/digital volume // AIF2 capture/playback mono mixing/digital volume
{ .name = "AIF2 ADC Capture Volume", .vals.i = { 160, 160 } }, { .name = "AIF2 ADC Capture Volume", .vals.i = { 160, 160 } },
@ -293,16 +291,15 @@ static void audio_set_controls(struct audio_setup* s)
// AIF3 (bluetooth) // AIF3 (bluetooth)
{ .name = "AIF3 Loopback Switch", .vals.i = { 0 } }, { .name = "AIF3 ADC Source Capture Route", .vals.e = { "None" } },
{ .name = "AIF3 ADC Capture Route", .vals.e = { "None" } }, { .name = "AIF2 DAC Source Playback Route", .vals.e = { "AIF2" } },
{ .name = "AIF3 DAC Playback Route", .vals.e = { "None" } },
// DAC // DAC
// DAC input mixers (sources from ADC, and AIF1/2) // DAC input mixers (sources from ADC, and AIF1/2)
{ .name = "DAC Mixer ADC Playback Switch", .vals.i = { 0, 0 } }, // we don't play our mic to ourselves { .name = "ADC Digital DAC Playback Switch", .vals.i = { 0, 0 } }, // we don't play our mic to ourselves
{ .name = "DAC Mixer AIF1 DA0 Playback Switch", .vals.i = { 1, !!s->modem_playback_monitor } }, { .name = "AIF1 Slot 0 Digital DAC Playback Switch", .vals.i = { 1, !!s->modem_playback_monitor } },
{ .name = "DAC Mixer AIF2 DAC Playback Switch", .vals.i = { 0, !!s->dai2_en && !!s->from_modem_on } }, { .name = "AIF2 Digital DAC Playback Switch", .vals.i = { 0, !!s->dai2_en && !!s->from_modem_on } },
// //
// Analog output: // Analog output:
@ -340,8 +337,8 @@ static void audio_set_controls(struct audio_setup* s)
} }
static struct audio_setup audio_setup = { static struct audio_setup audio_setup = {
.mic_on = false, .mic_on = true,
.ear_on = false, .ear_on = true,
.spk_on = false, .spk_on = false,
.hp_on = false, .hp_on = false,
@ -351,18 +348,17 @@ static struct audio_setup audio_setup = {
.dai2_en = false, .dai2_en = false,
.hp_vol = 25, .hp_vol = 15,
.spk_vol = 25, .spk_vol = 15,
.ear_vol = 25, .ear_vol = 31,
.mic_gain = 1, .mic_gain = 1,
.hpmic_gain = 1,
}; };
int main(int ac, char* av[]) int main(int ac, char* av[])
{ {
int opt; int opt;
while ((opt = getopt(ac, av, "smhlez2")) != -1) { while ((opt = getopt(ac, av, "smhe2")) != -1) {
switch (opt) { switch (opt) {
case 's': case 's':
audio_setup.spk_on = 1; audio_setup.spk_on = 1;
@ -373,20 +369,14 @@ int main(int ac, char* av[])
case 'h': case 'h':
audio_setup.hp_on = 1; audio_setup.hp_on = 1;
break; break;
case 'l':
audio_setup.hpmic_on = 1;
break;
case 'e': case 'e':
audio_setup.ear_on = 1; audio_setup.ear_on = 1;
break; break;
case 'z':
audio_setup.modem_playback_monitor = 1;
break;
case '2': case '2':
audio_setup.dai2_en = 1; audio_setup.dai2_en = 1;
break; break;
default: /* '?' */ default: /* '?' */
fprintf(stderr, "Usage: %s [-s] [-m] [-h] [-l] [-e] [-2] [-z]\n", av[0]); fprintf(stderr, "Usage: %s [-s] [-m] [-h] [-e] [-2]\n", av[0]);
exit(EXIT_FAILURE); exit(EXIT_FAILURE);
} }
} }
@ -394,4 +384,3 @@ int main(int ac, char* av[])
audio_set_controls(&audio_setup); audio_set_controls(&audio_setup);
return 0; return 0;
} }

Loading…
Cancel
Save