@@ -194,10 +194,12 @@ &sound {
"Headphone", "Headphone Jack";
/* Board level routing. First 2 routes copied from SoC level */
simple-audio-card,routing =
- "Left DAC", "AIF1 Slot 0 Left",
- "Right DAC", "AIF1 Slot 0 Right",
"HP", "HPCOM",
"Headphone Jack", "HP",
+ "Left DAC", "DAC Left",
+ "Right DAC", "DAC Right",
+ "ADC Left", "Left ADC",
+ "ADC Right", "Right ADC",
"MIC1", "Microphone Jack",
"Microphone Jack", "MBIAS";
status = "okay";
@@ -189,8 +189,10 @@ sound: sound {
simple-audio-card,mclk-fs = <128>;
simple-audio-card,aux-devs = <&codec_analog>;
simple-audio-card,routing =
- "Left DAC", "AIF1 Slot 0 Left",
- "Right DAC", "AIF1 Slot 0 Right";
+ "Left DAC", "DAC Left",
+ "Right DAC", "DAC Right",
+ "ADC Left", "Left ADC",
+ "ADC Right", "Right ADC";
status = "disabled";
simple-audio-card,cpu {
@@ -353,11 +353,11 @@ &sound {
"Microphone", "Microphone Jack",
"Microphone", "Onboard Microphone";
simple-audio-card,routing =
- "Left DAC", "AIF1 Slot 0 Left",
- "Right DAC", "AIF1 Slot 0 Right",
- "AIF1 Slot 0 Left ADC", "Left ADC",
- "AIF1 Slot 0 Right ADC", "Right ADC",
"Headphone Jack", "HP",
+ "Left DAC", "DAC Left",
+ "Right DAC", "DAC Right",
+ "ADC Left", "Left ADC",
+ "ADC Right", "Right ADC",
"MIC2", "Microphone Jack",
"Onboard Microphone", "MBIAS",
"MIC1", "Onboard Microphone";
@@ -352,11 +352,11 @@ &sound {
"Microphone", "Microphone Jack",
"Microphone", "Onboard Microphone";
simple-audio-card,routing =
- "Left DAC", "AIF1 Slot 0 Left",
- "Right DAC", "AIF1 Slot 0 Right",
- "AIF1 Slot 0 Left ADC", "Left ADC",
- "AIF1 Slot 0 Right ADC", "Right ADC",
"Headphone Jack", "HP",
+ "Left DAC", "DAC Left",
+ "Right DAC", "DAC Right",
+ "ADC Left", "Left ADC",
+ "ADC Right", "Right ADC",
"MIC2", "Microphone Jack",
"Onboard Microphone", "MBIAS",
"MIC1", "Onboard Microphone";
@@ -283,11 +283,11 @@ &sound {
simple-audio-card,widgets = "Microphone", "Microphone Jack",
"Headphone", "Headphone Jack";
simple-audio-card,routing =
- "Left DAC", "AIF1 Slot 0 Left",
- "Right DAC", "AIF1 Slot 0 Right",
"Headphone Jack", "HP",
- "AIF1 Slot 0 Left ADC", "Left ADC",
- "AIF1 Slot 0 Right ADC", "Right ADC",
+ "Left DAC", "DAC Left",
+ "Right DAC", "DAC Right",
+ "ADC Left", "Left ADC",
+ "ADC Right", "Right ADC",
"MIC2", "Microphone Jack";
status = "okay";
};
@@ -319,15 +319,15 @@ &sound {
"Headphone", "Headphone Jack",
"Speaker", "Internal Speaker";
simple-audio-card,routing =
- "Left DAC", "AIF1 Slot 0 Left",
- "Right DAC", "AIF1 Slot 0 Right",
"Speaker Amp INL", "LINEOUT",
"Speaker Amp INR", "LINEOUT",
"Internal Speaker", "Speaker Amp OUTL",
"Internal Speaker", "Speaker Amp OUTR",
"Headphone Jack", "HP",
- "AIF1 Slot 0 Left ADC", "Left ADC",
- "AIF1 Slot 0 Right ADC", "Right ADC",
+ "Left DAC", "DAC Left",
+ "Right DAC", "DAC Right",
+ "ADC Left", "Left ADC",
+ "ADC Right", "Right ADC",
"Internal Microphone Left", "MBIAS",
"MIC1", "Internal Microphone Left",
"Internal Microphone Right", "HBIAS",
@@ -421,15 +421,15 @@ &sound {
"Headphone", "Headphone Jack",
"Speaker", "Internal Speaker";
simple-audio-card,routing =
- "Left DAC", "AIF1 Slot 0 Left",
- "Right DAC", "AIF1 Slot 0 Right",
- "Speaker Amp INL", "LINEOUT",
- "Speaker Amp INR", "LINEOUT",
+ "Headphone Jack", "HP",
"Internal Speaker", "Speaker Amp OUTL",
"Internal Speaker", "Speaker Amp OUTR",
- "Headphone Jack", "HP",
- "AIF1 Slot 0 Left ADC", "Left ADC",
- "AIF1 Slot 0 Right ADC", "Right ADC",
+ "Speaker Amp INL", "LINEOUT",
+ "Speaker Amp INR", "LINEOUT",
+ "Left DAC", "DAC Left",
+ "Right DAC", "DAC Right",
+ "ADC Left", "Left ADC",
+ "ADC Right", "Right ADC",
"Internal Microphone Left", "MBIAS",
"MIC1", "Internal Microphone Left",
"Internal Microphone Right", "HBIAS",
@@ -199,11 +199,11 @@ &sound {
simple-audio-card,widgets = "Microphone", "Microphone Jack",
"Headphone", "Headphone Jack";
simple-audio-card,routing =
- "Left DAC", "AIF1 Slot 0 Left",
- "Right DAC", "AIF1 Slot 0 Right",
"Headphone Jack", "HP",
- "AIF1 Slot 0 Left ADC", "Left ADC",
- "AIF1 Slot 0 Right ADC", "Right ADC",
+ "Left DAC", "DAC Left",
+ "Right DAC", "DAC Right",
+ "ADC Left", "Left ADC",
+ "ADC Right", "Right ADC",
"MIC2", "Microphone Jack";
status = "okay";
};
@@ -326,15 +326,15 @@ &sound {
"Microphone", "Internal Microphone",
"Speaker", "Internal Speaker";
simple-audio-card,routing =
- "Left DAC", "AIF1 Slot 0 Left",
- "Right DAC", "AIF1 Slot 0 Right",
- "AIF1 Slot 0 Left ADC", "Left ADC",
- "AIF1 Slot 0 Right ADC", "Right ADC",
"Headphone Jack", "HP",
"Speaker Amp INL", "LINEOUT",
"Speaker Amp INR", "LINEOUT",
"Internal Speaker", "Speaker Amp OUTL",
"Internal Speaker", "Speaker Amp OUTR",
+ "Left DAC", "DAC Left",
+ "Right DAC", "DAC Right",
+ "ADC Left", "Left ADC",
+ "ADC Right", "Right ADC",
"Internal Microphone", "MBIAS",
"MIC1", "Internal Microphone",
"Headset Microphone", "HBIAS",
@@ -165,10 +165,10 @@ sound: sound {
simple-audio-card,mclk-fs = <128>;
simple-audio-card,aux-devs = <&codec_analog>;
simple-audio-card,routing =
- "Left DAC", "AIF1 Slot 0 Left",
- "Right DAC", "AIF1 Slot 0 Right",
- "AIF1 Slot 0 Left ADC", "Left ADC",
- "AIF1 Slot 0 Right ADC", "Right ADC";
+ "Left DAC", "DAC Left",
+ "Right DAC", "DAC Right",
+ "ADC Left", "Left ADC",
+ "ADC Right", "Right ADC";
status = "disabled";
cpudai: simple-audio-card,cpu {
@@ -406,6 +406,10 @@ static const struct snd_soc_dapm_widget sun8i_codec_dapm_widgets[] = {
SUN8I_AIF1_ADCDAT_CTRL,
SUN8I_AIF1_ADCDAT_CTRL_AIF1_DA0R_ENA, 0),
+ /* Main DAC Outputs (connected to analog codec DAPM context) */
+ SND_SOC_DAPM_PGA("DAC Left", SND_SOC_NOPM, 0, 0, NULL, 0),
+ SND_SOC_DAPM_PGA("DAC Right", SND_SOC_NOPM, 0, 0, NULL, 0),
+
/* DAC and ADC Mixers */
SOC_MIXER_ARRAY("Left Digital DAC Mixer", SND_SOC_NOPM, 0, 0,
sun8i_dac_mixer_controls),
@@ -416,6 +420,10 @@ static const struct snd_soc_dapm_widget sun8i_codec_dapm_widgets[] = {
SOC_MIXER_ARRAY("Right Digital ADC Mixer", SND_SOC_NOPM, 0, 0,
sun8i_input_mixer_controls),
+ /* Main ADC Inputs (connected to analog codec DAPM context) */
+ SND_SOC_DAPM_PGA("ADC Left", SND_SOC_NOPM, 0, 0, NULL, 0),
+ SND_SOC_DAPM_PGA("ADC Right", SND_SOC_NOPM, 0, 0, NULL, 0),
+
/* Clocks */
SND_SOC_DAPM_SUPPLY("MODCLK AFI1", SUN8I_MOD_CLK_ENA,
SUN8I_MOD_CLK_ENA_AIF1, 0, NULL, 0),
@@ -460,9 +468,23 @@ static const struct snd_soc_dapm_route sun8i_codec_dapm_routes[] = {
{ "MODCLK ADC", NULL, "RST ADC" },
{ "ADC", NULL, "MODCLK ADC" },
+ /* AIF "ADC" Output Routes */
+ { "AIF1 Slot 0 Left ADC", NULL, "Left Digital ADC Mixer" },
+ { "AIF1 Slot 0 Right ADC", NULL, "Right Digital ADC Mixer" },
+
+ { "AIF1 Slot 0 Left ADC", NULL, "MODCLK AIF1" },
+ { "AIF1 Slot 0 Right ADC", NULL, "MODCLK AIF1" },
+
+ /* AIF "DAC" Input Routes */
+ { "AIF1 Slot 0 Left", NULL, "MODCLK AIF1" },
+ { "AIF1 Slot 0 Right", NULL, "MODCLK AIF1" },
+
/* DAC Routes */
- { "AIF1 Slot 0 Right", NULL, "DAC" },
- { "AIF1 Slot 0 Left", NULL, "DAC" },
+ { "DAC Left", NULL, "Left Digital DAC Mixer" },
+ { "DAC Right", NULL, "Right Digital DAC Mixer" },
+
+ { "DAC Left", NULL, "DAC" },
+ { "DAC Right", NULL, "DAC" },
/* DAC Mixer Routes */
{ "Left Digital DAC Mixer", "AIF1 Slot 0 Digital DAC Playback Switch",
@@ -471,14 +493,14 @@ static const struct snd_soc_dapm_route sun8i_codec_dapm_routes[] = {
"AIF1 Slot 0 Right"},
/* ADC Routes */
- { "AIF1 Slot 0 Right ADC", NULL, "ADC" },
- { "AIF1 Slot 0 Left ADC", NULL, "ADC" },
+ { "ADC Left", NULL, "ADC" },
+ { "ADC Right", NULL, "ADC" },
/* ADC Mixer Routes */
{ "Left Digital ADC Mixer", "AIF1 Data Digital ADC Capture Switch",
- "AIF1 Slot 0 Left ADC" },
+ "ADC Left" },
{ "Right Digital ADC Mixer", "AIF1 Data Digital ADC Capture Switch",
- "AIF1 Slot 0 Right ADC" },
+ "ADC Right" },
};
static const struct snd_soc_dai_ops sun8i_codec_dai_ops = {
The A33/A64 digital codec has 4 physical inputs and 4 physical outputs: 3 AIFs (DAIs) and one ADC/DAC pair. Every input and output has a volume control for each channel in that connection. Furthermore, every input and output has a mono/stereo mux of some sort. Internal routing is accomplished by a 4-channel mixer connected to each output. This commit provides the minimal necessary changes to the driver's device tree ABI, so that the driver can begin to describe the full hardware topology. Currently the driver works mostly by accident. The DAPM routes currently in the various device trees specify the AIF1 widgets, not the ADC or DAC widgets they should have. For Playback, the correct topology is: (CPU) -> AIF1 DA0 -> DAC Mixer -> DAC (digital) -> DAC (analog) but the driver and device trees currently describe: (CPU) -> AIF1 DA0 -> DAC (analog) \--> DAC Mixer -> ??? For Capture, the situation is worse, because the Mixer route is backward. The topology should be: ADC (analog) -> ADC (digital) -> AIF1 AD0 Mixer -> AIF1 AD0 -> (CPU) but the driver and device trees currently describe: ADC (analog) -> AIF1 AD0 -> (CPU) \--> ADC Mixer -> ??? The reason that DAPM powers on the ADC/DAC at all is the supply routes that make AIF1 AD0 depend on the ADC running, and AIF1 DA0 depend on the DAC running. However, neither of these supplies are correct based on the hardware topology: there is a route directly from the ADC to the DAC, controlled by the "ADC Digital DAC Playback Switch". It doesn't work (and wouldn't work if a route was added in the device tree), because AIF1 isn't used in the route: ADC (analog) -> ADC (dig) -> DAC Mixer -> DAC (dig) -> DAC (analog) so neither the ADC nor the DAC are powered up. Similarly, there are routes between AIF2/3 and the ADC/DAC (and each other) that should work without involving AIF1. DAPM needs to represent the real hardware topology so the driver can be extended to support AIF2 and AIF3 and the other codec features. To do this, new ADC and DAC widgets are added. Only the minimal necessary routes for AIF1 -> DAC playback and ADC -> AIF1 capture are included, to keep this commit easier to backport. Cc: stable@kernel.org Fixes: 36c684936fae ("ASoC: Add sun8i digital audio codec") Fixes: eda85d1fee05 ("ASoC: sun8i-codec: Add ADC support for a33") Fixes: 9ee325d029c4 ("ASoC: sun8i-codec: add missing route for ADC") Signed-off-by: Samuel Holland <samuel@sholland.org> --- arch/arm/boot/dts/sun8i-a33-olinuxino.dts | 6 ++-- arch/arm/boot/dts/sun8i-a33.dtsi | 6 ++-- .../dts/allwinner/sun50i-a64-bananapi-m64.dts | 8 ++--- .../dts/allwinner/sun50i-a64-orangepi-win.dts | 8 ++--- .../boot/dts/allwinner/sun50i-a64-pine64.dts | 8 ++--- .../dts/allwinner/sun50i-a64-pinebook.dts | 8 ++--- .../boot/dts/allwinner/sun50i-a64-pinetab.dts | 14 ++++---- .../allwinner/sun50i-a64-sopine-baseboard.dts | 8 ++--- .../boot/dts/allwinner/sun50i-a64-teres-i.dts | 8 ++--- arch/arm64/boot/dts/allwinner/sun50i-a64.dtsi | 8 ++--- sound/soc/sunxi/sun8i-codec.c | 34 +++++++++++++++---- 11 files changed, 71 insertions(+), 45 deletions(-)