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>