OSDN Git Service

ASoC: sun8i-codec: Fix DAPM to match the hardware topology
authorSamuel Holland <samuel@sholland.org>
Sun, 26 Jul 2020 01:25:52 +0000 (20:25 -0500)
committerMark Brown <broonie@kernel.org>
Mon, 17 Aug 2020 14:21:55 +0000 (15:21 +0100)
commit90cac932976e93b17203b4216ba83bdcd68e0ed0
treee52a683e461f4db2dabd557a266234c420bd42bf
parentcef305d4eb0733f25215793ed30b056a7db9bb62
ASoC: sun8i-codec: Fix DAPM to match the hardware topology

The A33/A64 digital codec has 4 physical inputs and 4 physical outputs:
3 AIFs/DAIs and one ADC/DAC pair. Internal routing is accomplished by
a 4-channel mixer connected to each output.

The analog and digital sides of the ADC/DAC are in separate ASoC
components, so card-level DAPM routes (provided in the device tree) are
necessary to connect them together. Currently, these routes are wrong.

For AIF1 Playback, the correct topology is:

         ||<<============ sun8i-codec ===========>>||
         ||                                        ||
 CPU DAI -> AIF1 DA0 -> DAC Mixer -> DAC (digital) -> DAC (analog)
         ||                                        ||

but the driver and device trees currently describe:

         ||                                        ||
 CPU DAI -> AIF1 DA0 -------------------------------> DAC (analog)
         ||     \--> DAC Mixer -> ??? [dead end]   ||

For AIF1 Capture, there is an additional problem, because the Mixer
route is backward. The topology should be:

              ||                                             ||
 ADC (analog) -> ADC (digital) -> AIF1 AD0 Mixer -> AIF1 AD0 -> CPU DAI
              ||                                             ||

but the driver and device trees currently describe:

              ||                                             ||
 ADC (analog) -> AIF1 AD0 ------------------------------------> CPU DAI
              ||     \--> ADC Mixer -> ??? [dead end]        ||

The ADC/DAC are only powered because AIF1 AD0 (capture) has supply
routes from the ADC, and AIF1 DA0 (playback) has supply routes from the
DAC. However, neither set of supply routes matches the hardware
topology. Audio can be routed among AIF1/2/3 without using the ADC or
DAC at all; and audio can be routed from the ADC to the DAC without
using any AIFs (via the "ADC Digital DAC Playback Switch"). Because the
DAPM routes are wrong, both of these use cases are currently broken.

This commit adds the necessary widgets and routes to represent the real
hardware topology, with functionality equivalent to the current driver.

For the existing "allwinner,sun8i-a33-codec" compatible, widgets with
the old names are kept as wrappers around the new widgets, so existing
device trees will continue to work. For "allwinner,sun50i-a64-codec",
the old widgets can be omitted, because no device trees yet use that
compatible.

Signed-off-by: Samuel Holland <samuel@sholland.org>
Link: https://lore.kernel.org/r/20200726012557.38282-3-samuel@sholland.org
Signed-off-by: Mark Brown <broonie@kernel.org>
sound/soc/sunxi/sun8i-codec.c