[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20200217064250.15516-29-samuel@sholland.org>
Date: Mon, 17 Feb 2020 00:42:44 -0600
From: Samuel Holland <samuel@...lland.org>
To: Mark Brown <broonie@...nel.org>,
Liam Girdwood <lgirdwood@...il.com>,
Rob Herring <robh+dt@...nel.org>,
Mark Rutland <mark.rutland@....com>,
Maxime Ripard <mripard@...nel.org>,
Chen-Yu Tsai <wens@...e.org>,
Vasily Khoruzhick <anarsoul@...il.com>,
Mylène Josserand
<mylene.josserand@...e-electrons.com>,
Jaroslav Kysela <perex@...ex.cz>, Takashi Iwai <tiwai@...e.com>
Cc: alsa-devel@...a-project.org, devicetree@...r.kernel.org,
linux-arm-kernel@...ts.infradead.org, linux-kernel@...r.kernel.org,
Samuel Holland <samuel@...lland.org>
Subject: [RFC PATCH 28/34] ASoC: sun8i-codec: Add AIF loopback controls
This allows controlling the loopback flag for each AIF. This is useful
for developing/testing complicated audio routing scenarios (such as
recording a phone call while using a BT headset for mic/earpiece)
without needing to involve the devices on the other end of the DAI
links.
Signed-off-by: Samuel Holland <samuel@...lland.org>
---
sound/soc/sunxi/sun8i-codec.c | 48 +++++++++++++++++++++++++++++++++++
1 file changed, 48 insertions(+)
diff --git a/sound/soc/sunxi/sun8i-codec.c b/sound/soc/sunxi/sun8i-codec.c
index fdb9bf346cc2..245145e36357 100644
--- a/sound/soc/sunxi/sun8i-codec.c
+++ b/sound/soc/sunxi/sun8i-codec.c
@@ -63,6 +63,7 @@
#define SUN8I_AIF1_DACDAT_CTRL_AIF1_DA0R_ENA 14
#define SUN8I_AIF1_DACDAT_CTRL_AIF1_DA0L_SRC 10
#define SUN8I_AIF1_DACDAT_CTRL_AIF1_DA0R_SRC 8
+#define SUN8I_AIF1_DACDAT_CTRL_AIF1_LOOP_ENA 0
#define SUN8I_AIF1_MXR_SRC 0x04c
#define SUN8I_AIF1_MXR_SRC_AD0L_MXR_SRC_AIF1DA0L 15
#define SUN8I_AIF1_MXR_SRC_AD0L_MXR_SRC_AIF2DACL 14
@@ -82,6 +83,7 @@
#define SUN8I_AIF2_DACDAT_CTRL_AIF2_DACR_ENA 14
#define SUN8I_AIF2_DACDAT_CTRL_AIF2_DACL_SRC 10
#define SUN8I_AIF2_DACDAT_CTRL_AIF2_DACR_SRC 8
+#define SUN8I_AIF2_DACDAT_CTRL_AIF2_LOOP_ENA 0
#define SUN8I_AIF2_MXR_SRC 0x08c
#define SUN8I_AIF2_MXR_SRC_ADCL_MXR_SRC_AIF1DA0L 15
#define SUN8I_AIF2_MXR_SRC_ADCL_MXR_SRC_AIF1DA1L 14
@@ -519,6 +521,21 @@ static struct snd_soc_dai_driver sun8i_codec_dais[] = {
},
};
+static const struct snd_kcontrol_new sun8i_aif1_loopback_switch =
+ SOC_DAPM_SINGLE("AIF1 Loopback Switch",
+ SUN8I_AIF1_DACDAT_CTRL,
+ SUN8I_AIF1_DACDAT_CTRL_AIF1_LOOP_ENA, 1, 0);
+
+static const struct snd_kcontrol_new sun8i_aif2_loopback_switch =
+ SOC_DAPM_SINGLE("AIF2 Loopback Switch",
+ SUN8I_AIF2_DACDAT_CTRL,
+ SUN8I_AIF2_DACDAT_CTRL_AIF2_LOOP_ENA, 1, 0);
+
+static const struct snd_kcontrol_new sun8i_aif3_loopback_switch =
+ SOC_DAPM_SINGLE("Switch",
+ SUN8I_AIF3_DACDAT_CTRL,
+ SUN8I_AIF3_DACDAT_CTRL_AIF3_LOOP_ENA, 1, 0);
+
static const char *const sun8i_aif_stereo_mux_enum_names[] = {
"Stereo", "Reverse Stereo", "Sum Mono", "Mix Mono"
};
@@ -643,6 +660,20 @@ static const struct snd_kcontrol_new sun8i_dac_mixer_controls[] = {
};
static const struct snd_soc_dapm_widget sun8i_codec_dapm_widgets[] = {
+ /* AIF Loopback Switches */
+ SND_SOC_DAPM_SWITCH("AIF1 Slot 0 Left Loopback", SND_SOC_NOPM, 0, 0,
+ &sun8i_aif1_loopback_switch),
+ SND_SOC_DAPM_SWITCH("AIF1 Slot 0 Right Loopback", SND_SOC_NOPM, 0, 0,
+ &sun8i_aif1_loopback_switch),
+
+ SND_SOC_DAPM_SWITCH("AIF2 Left Loopback", SND_SOC_NOPM, 0, 0,
+ &sun8i_aif2_loopback_switch),
+ SND_SOC_DAPM_SWITCH("AIF2 Right Loopback", SND_SOC_NOPM, 0, 0,
+ &sun8i_aif2_loopback_switch),
+
+ SND_SOC_DAPM_SWITCH("AIF3 Loopback", SND_SOC_NOPM, 0, 0,
+ &sun8i_aif3_loopback_switch),
+
/* AIF "ADC" Outputs */
SND_SOC_DAPM_AIF_OUT("AIF1 AD0 Left", "AIF1 Capture", 0,
SUN8I_AIF1_ADCDAT_CTRL,
@@ -776,6 +807,15 @@ static const struct snd_soc_dapm_widget sun8i_codec_dapm_widgets[] = {
};
static const struct snd_soc_dapm_route sun8i_codec_dapm_routes[] = {
+ /* AIF Loopback Routes */
+ { "AIF1 Slot 0 Left Loopback", "AIF1 Loopback Switch", "AIF1 AD0 Left" },
+ { "AIF1 Slot 0 Right Loopback", "AIF1 Loopback Switch", "AIF1 AD0 Right" },
+
+ { "AIF2 Left Loopback", "AIF2 Loopback Switch", "AIF2 ADC Left" },
+ { "AIF2 Right Loopback", "AIF2 Loopback Switch", "AIF2 ADC Right" },
+
+ { "AIF3 Loopback", "Switch", "AIF3 ADC" },
+
/* AIF "ADC" Output Routes */
{ "AIF1 AD0 Left", NULL, "AIF1 AD0 Left Stereo Mux" },
{ "AIF1 AD0 Right", NULL, "AIF1 AD0 Right Stereo Mux" },
@@ -882,12 +922,20 @@ static const struct snd_soc_dapm_route sun8i_codec_dapm_routes[] = {
{ "AIF2 DAC Right Stereo Mux", "Mix Mono", "AIF2 DAC Right" },
/* AIF "DAC" Input Routes */
+ { "AIF1 DA0 Left", NULL, "AIF1 Slot 0 Left Loopback" },
+ { "AIF1 DA0 Right", NULL, "AIF1 Slot 0 Right Loopback" },
+
{ "AIF1 DA0 Left", NULL, "AIF1CLK" },
{ "AIF1 DA0 Right", NULL, "AIF1CLK" },
+ { "AIF2 DAC Left", NULL, "AIF2 Left Loopback" },
+ { "AIF2 DAC Right", NULL, "AIF2 Right Loopback" },
+
{ "AIF2 DAC Left", NULL, "AIF2CLK" },
{ "AIF2 DAC Right", NULL, "AIF2CLK" },
+ { "AIF3 DAC", NULL, "AIF3 Loopback" },
+
/* Main DAC Output Routes */
{ "DAC Left", NULL, "DAC Left Mixer" },
{ "DAC Right", NULL, "DAC Right Mixer" },
--
2.24.1
Powered by blists - more mailing lists