aboutsummaryrefslogtreecommitdiffstats
path: root/sound/soc/sunxi (follow)
AgeCommit message (Collapse)AuthorFilesLines
2020-10-26ASoC: sun8i-codec: Round up the LRCK divisorSamuel Holland1-10/+12
The codec supports only power-of-two BCLK/LRCK divisors. If either the slot width or the number of slots is not a power of two, the LRCK divisor must be rounded up to provide enough space. To do that, use order_base_2 (instead of ilog2, which rounds down). Since the rounded divisor is also needed for setting the SYSCLK/BCLK divisor, return the order base 2 instead of fully calculating the hardware register encoding. Acked-by: Maxime Ripard <mripard@kernel.org> Signed-off-by: Samuel Holland <samuel@sholland.org> Link: https://lore.kernel.org/r/20201014061941.4306-6-samuel@sholland.org Signed-off-by: Mark Brown <broonie@kernel.org>
2020-10-26ASoC: sun8i-codec: Use the provided word sizeSamuel Holland1-7/+20
The hardware supports 8 to 24-bit word sizes on all three of its DAIs, only one of which is connected to the CPU DAI. Program the word size based on the actual selected format, instead of assuming limitations from another driver (which, incedentally, has patches pending to remove that limitation). Acked-by: Maxime Ripard <mripard@kernel.org> Signed-off-by: Samuel Holland <samuel@sholland.org> Link: https://lore.kernel.org/r/20201014061941.4306-5-samuel@sholland.org Signed-off-by: Mark Brown <broonie@kernel.org>
2020-10-26ASoC: sun8i-codec: Enable all supported clock inversionsSamuel Holland1-22/+39
When using the I2S, LEFT_J, or RIGHT_J format, the hardware supports independent BCLK and LRCK inversion control. When using DSP_A or DSP_B, LRCK inversion is not supported. The register bit is repurposed to select between DSP_A and DSP_B. Extend the driver to support this. Signed-off-by: Samuel Holland <samuel@sholland.org> Acked-by: Maxime Ripard <mripard@kernel.org> Link: https://lore.kernel.org/r/20201014061941.4306-4-samuel@sholland.org Signed-off-by: Mark Brown <broonie@kernel.org>
2020-10-26ASoC: sun8i-codec: Program DAI format before clock inversionSamuel Holland1-23/+23
The LRCK inversion bit has a different meaning in DSP mode: it selects between the DSP A and DSP B formats. To support this, we need to know if the selected format is a DSP format. One easy way to do this is to set the format field before the clock inversion fields. Acked-by: Maxime Ripard <mripard@kernel.org> Signed-off-by: Samuel Holland <samuel@sholland.org> Link: https://lore.kernel.org/r/20201014061941.4306-3-samuel@sholland.org Signed-off-by: Mark Brown <broonie@kernel.org>
2020-10-26ASoC: sun8i-codec: Prepare to extend the DAI driverSamuel Holland1-34/+42
In preparation for adding additional DAIs to this component, convert the DAI driver definition to an array. Since this changes all of the lines in the definition anyway, let's move it closer to the ops function definitions, instead of on the far side of the DAPM arrays. And while moving the DAI driver ops, rename the set_fmt hook to match the usual naming scheme. Give the existing DAI an explicit ID and more meaningful stream names, so it will remain unique as more DAIs are added. The AIF widget streams must be updated to match. Acked-by: Maxime Ripard <mripard@kernel.org> Signed-off-by: Samuel Holland <samuel@sholland.org> Link: https://lore.kernel.org/r/20201014061941.4306-2-samuel@sholland.org Signed-off-by: Mark Brown <broonie@kernel.org>
2020-10-05ASoC: sun8i-codec: Use snd_soc_dai_get_drvdataSamuel Holland1-2/+2
Remove a level of indirection by getting the device directly from the passed-in struct snd_soc_dai, instead of going through its component. Signed-off-by: Samuel Holland <samuel@sholland.org> Acked-by: Maxime Ripard <mripard@kernel.org> Link: https://lore.kernel.org/r/20201001021148.15852-9-samuel@sholland.org Signed-off-by: Mark Brown <broonie@kernel.org>
2020-10-05ASoC: sun8i-codec: Enable AIF mono/stereo controlSamuel Holland1-6/+76
Each left/right pair of AIF input/output channels can be swapped or combined. This is useful for sending a mono audio source to both sides of a stereo sink, or for creating complex mixing scenarios. Add the support to control this feature from userspace. Signed-off-by: Samuel Holland <samuel@sholland.org> Acked-by: Maxime Ripard <mripard@kernel.org> Link: https://lore.kernel.org/r/20201001021148.15852-8-samuel@sholland.org Signed-off-by: Mark Brown <broonie@kernel.org>
2020-10-05ASoC: sun8i-codec: Fix AIF widget channel referencesSamuel Holland1-2/+2
Both the left and right side widgets referenced channel 0. This would unnecessarily power on the right side widget (and its associated path) when a mono stream was active. Signed-off-by: Samuel Holland <samuel@sholland.org> Acked-by: Maxime Ripard <mripard@kernel.org> Link: https://lore.kernel.org/r/20201001021148.15852-7-samuel@sholland.org Signed-off-by: Mark Brown <broonie@kernel.org>
2020-10-05ASoC: sun8i-codec: Correct DAPM widget typesSamuel Holland1-6/+6
Whie the aif_in and aif_out widget types are handled exactly the same in the core DAPM code, a future widget event hook will need the correct widget type to derive the associated substream. Clean up the widget type for that reason, and so these widgets will match newly-added widgets for the other AIFs. Signed-off-by: Samuel Holland <samuel@sholland.org> Acked-by: Maxime Ripard <mripard@kernel.org> Link: https://lore.kernel.org/r/20201001021148.15852-6-samuel@sholland.org Signed-off-by: Mark Brown <broonie@kernel.org>
2020-10-05ASoC: sun8i-codec: Consistently name DAPM widgets and routesSamuel Holland1-16/+16
This cleans up the mixer widget names. The AIF1 AD0 Mixer names were previously wrong -- they do not control the digital side of the ADC. The DAC mixer widgets were not wrong, but they were verbose and did not match the naming scheme of the other widgets. The mixer controls are not renamed because they are exposed to userspace. Signed-off-by: Samuel Holland <samuel@sholland.org> Acked-by: Maxime Ripard <mripard@kernel.org> Link: https://lore.kernel.org/r/20201001021148.15852-5-samuel@sholland.org Signed-off-by: Mark Brown <broonie@kernel.org>
2020-10-05ASoC: sun8i-codec: Sort DAPM controls, widgets, and routesSamuel Holland1-48/+53
Sort the remaining pieces of the DAPM driver so that they are all in the same order among controls/widgets/routes, and so they roughly match the register word and bit order of the hardware. This nicely separates the AIF-related widgets from the ADC/DAC widgets, which allows the AIF widgets to stay in a logical order as more AIFs are added to the driver. No widgets are renamed, to ease verification that this commit makes no functional change. Signed-off-by: Samuel Holland <samuel@sholland.org> Acked-by: Maxime Ripard <mripard@kernel.org> Link: https://lore.kernel.org/r/20201001021148.15852-4-samuel@sholland.org Signed-off-by: Mark Brown <broonie@kernel.org>
2020-10-05ASoC: sun8i-codec: Swap module clock/reset dependenciesSamuel Holland1-33/+39
This matches the module power-up/down sequence from the vendor's driver. While updating these widgets/routes, reorder them to match the register and bit layout of the hardware. This puts them in the same place in the widget and route arrays (previously they were at opposite ends), and it makes it easier to track which parts of which registers are implemented. Signed-off-by: Samuel Holland <samuel@sholland.org> Acked-by: Maxime Ripard <mripard@kernel.org> Link: https://lore.kernel.org/r/20201001021148.15852-3-samuel@sholland.org Signed-off-by: Mark Brown <broonie@kernel.org>
2020-10-05ASoC: sun8i-codec: Set up clock tree at probe timeSamuel Holland1-19/+35
The sun8i codec is effectively an on-die variant of the X-Powers AC100 codec. The AC100 can derive its clocks from either of two I2S master clocks or an internal PLL. For the on-die variant, Allwinner replaced the codec's own PLL with a connection to SoC's existing PLL_AUDIO, and they connected both I2S MCLK inputs to the same source -- which happens to be an integer divider from the same PLL_AUDIO. So there's actually no clocking flexibility. To run SYSCLK at the required rate, it must be run straight from the PLL. The only choice is whether it goes through AIF1CLK or AIF2CLK. Since both run at the same rate, the only effect of that choice is which field in SYS_SR_CTRL (AIF1_FS or AIF2_FS) controls the system sample rate. Since AIFnCLK is required to bring up the corresponding DAI, and AIF1 (connected to the CPU) is used most often, let's use AIF1CLK as the SYSCLK parent. That means we no longer need to set AIF2_FS. Since this clock tree never changes, we can program it from the component probe function, instead of using DAPM widgets. The DAPM widgets unnecessarily change clock parents when the codec goes in/out of idle and the supply widgets are powered up/down. Signed-off-by: Samuel Holland <samuel@sholland.org> Acked-by: Maxime Ripard <mripard@kernel.org> Link: https://lore.kernel.org/r/20201001021148.15852-2-samuel@sholland.org Signed-off-by: Mark Brown <broonie@kernel.org>
2020-09-07ASoC: sun8i-codec: Manage module clock via DAPMSamuel Holland1-14/+5
By representing the module clock as a DAPM widget, we ensure that the clock is only enabled when the module is actually in use, without additional code in runtime PM hooks. Signed-off-by: Samuel Holland <samuel@sholland.org> Acked-by: Maxime Ripard <mripard@kernel.org> Link: https://lore.kernel.org/r/20200831034852.18841-10-samuel@sholland.org Signed-off-by: Mark Brown <broonie@kernel.org>
2020-09-07ASoC: sun8i-codec: Attach the bus clock to the regmapSamuel Holland1-19/+2
When attached to the regmap, the bus clock is automatically enabled as needed to access device registers. This avoids needing code to manage it separately in the driver. Signed-off-by: Samuel Holland <samuel@sholland.org> Acked-by: Maxime Ripard <mripard@kernel.org> Link: https://lore.kernel.org/r/20200831034852.18841-9-samuel@sholland.org Signed-off-by: Mark Brown <broonie@kernel.org>
2020-09-07ASoC: sun8i-codec: Sort masks in a consistent orderSamuel Holland1-3/+3
All other definitions are sorted from largest to smallest bit number. This makes the AIF1CLK_CTRL mask constants consistent with them. Acked-by: Chen-Yu Tsai <wens@csie.org> Signed-off-by: Samuel Holland <samuel@sholland.org> Link: https://lore.kernel.org/r/20200831034852.18841-8-samuel@sholland.org Signed-off-by: Mark Brown <broonie@kernel.org>
2020-09-07ASoC: sun8i-codec: Fix field bit number indentationSamuel Holland1-7/+7
Several fields have inconsistent indentation, presumably because the patch "looked correct" due to the additional "+" character at the beginning of the line. Acked-by: Chen-Yu Tsai <wens@csie.org> Signed-off-by: Samuel Holland <samuel@sholland.org> Link: https://lore.kernel.org/r/20200831034852.18841-7-samuel@sholland.org Signed-off-by: Mark Brown <broonie@kernel.org>
2020-09-07ASoC: sun8i-codec: Fix ADC_DIG_CTRL field nameSamuel Holland1-2/+2
This is the enable bit for the "AD"C, not the "DA"C. Acked-by: Chen-Yu Tsai <wens@csie.org> Signed-off-by: Samuel Holland <samuel@sholland.org> Link: https://lore.kernel.org/r/20200831034852.18841-6-samuel@sholland.org Signed-off-by: Mark Brown <broonie@kernel.org>
2020-09-07ASoC: sun8i-codec: Fix AIF1_MXR_SRC field namesSamuel Holland1-8/+8
Even though they are for the left channel mixer, they are documented as "MXR_SRC". This matches the naming scheme used for the main DAC. The "R" is part of the abbreviation for "mixer", not a reference to the channel. Acked-by: Chen-Yu Tsai <wens@csie.org> Signed-off-by: Samuel Holland <samuel@sholland.org> Link: https://lore.kernel.org/r/20200831034852.18841-5-samuel@sholland.org Signed-off-by: Mark Brown <broonie@kernel.org>
2020-09-07ASoC: sun8i-codec: Fix AIF1_ADCDAT_CTRL field namesSamuel Holland1-4/+4
They are controlling "AD0" (AIF1 slot 0 ADC), not "DA0". Acked-by: Chen-Yu Tsai <wens@csie.org> Signed-off-by: Samuel Holland <samuel@sholland.org> Link: https://lore.kernel.org/r/20200831034852.18841-4-samuel@sholland.org Signed-off-by: Mark Brown <broonie@kernel.org>
2020-09-07ASoC: sun8i-codec: Fix AIF1 MODCLK widget nameSamuel Holland1-6/+6
The name should reference "AIF1", not "AFI1". Acked-by: Chen-Yu Tsai <wens@csie.org> Signed-off-by: Samuel Holland <samuel@sholland.org> Link: https://lore.kernel.org/r/20200831034852.18841-3-samuel@sholland.org Signed-off-by: Mark Brown <broonie@kernel.org>
2020-09-07ASoC: sun8i-codec: Remove extraneous widgetsSamuel Holland1-4/+0
This driver is for the digital part of the codec only. The analog part, including the microphone inputs, is managed by a separate driver. These widgets look like they were copied from sun4i-codec. Since they do not perform any function in this driver, remove them. Reviewed-by: Chen-Yu Tsai <wens@csie.org> Signed-off-by: Samuel Holland <samuel@sholland.org> Link: https://lore.kernel.org/r/20200831034852.18841-2-samuel@sholland.org Signed-off-by: Mark Brown <broonie@kernel.org>
2020-08-19ASoC: sun8i-codec: Hook up component probe functionSamuel Holland1-0/+1
Due to a mistake made while reordering patches, commit 90cac932976e ("ASoC: sun8i-codec: Fix DAPM to match the hardware topology") added the sun8i_codec_component_probe function without referencing it from the component definition. Add the reference so the probe function gets called as expected. Fixes: 90cac932976e ("ASoC: sun8i-codec: Fix DAPM to match the hardware topology") Reported-by: Stephen Rothwell <sfr@canb.auug.org.au> Signed-off-by: Samuel Holland <samuel@sholland.org> Link: https://lore.kernel.org/r/20200819034038.46418-1-samuel@sholland.org Signed-off-by: Mark Brown <broonie@kernel.org>
2020-08-18Merge series "ASoC: sun50i-codec-analog: Cleanup and power management" from Samuel Holland <samuel@sholland.org>:Mark Brown1-65/+111
This series performs some minor cleanup on the driver for the analog codec in the Allwinner A64, and hooks up the existing mute switches to DAPM widgets, in order to provide improved power management. Changes since v1: - Collected Acked-by/Reviewed-by tags - Used SOC_MIXER_NAMED_CTL_ARRAY to avoid naming a widget "Earpiece" Samuel Holland (8): ASoC: sun50i-codec-analog: Fix duplicate use of ADC enable bits ASoC: sun50i-codec-analog: Gate the amplifier clock during suspend ASoC: sun50i-codec-analog: Group and sort mixer routes ASoC: sun50i-codec-analog: Make headphone routes stereo ASoC: sun50i-codec-analog: Enable DAPM for headphone switch ASoC: sun50i-codec-analog: Make line out routes stereo ASoC: sun50i-codec-analog: Enable DAPM for line out switch ASoC: sun50i-codec-analog: Enable DAPM for earpiece switch sound/soc/sunxi/sun50i-codec-analog.c | 176 ++++++++++++++++---------- 1 file changed, 111 insertions(+), 65 deletions(-) -- 2.26.2
2020-08-18Merge series "Allwinner A64 digital audio codec fixes" from Samuel Holland <samuel@sholland.org>:Mark Brown1-29/+108
This series fixes a couple of issues with the digital audio codec in the Allwinner A64 SoC: 1) Left/right channels were swapped when playing/recording audio 2) DAPM topology was wrong, breaking some kcontrols This is the minimum set of changes necessary to fix these issues in a backward-compatible way. For that reason, some DAPM widgets still have incorrect or confusing names; those and other issues will be fixed in later patch sets. Samuel Holland (7): ASoC: dt-bindings: Add a new compatible for the A64 codec ASoC: sun8i-codec: Fix DAPM to match the hardware topology ASoC: sun8i-codec: Add missing mixer routes ASoC: sun8i-codec: Add a quirk for LRCK inversion ARM: dts: sun8i: a33: Update codec widget names arm64: dts: allwinner: a64: Update codec widget names arm64: dts: allwinner: a64: Update the audio codec compatible .../sound/allwinner,sun8i-a33-codec.yaml | 6 +- arch/arm/boot/dts/sun8i-a33-olinuxino.dts | 4 +- arch/arm/boot/dts/sun8i-a33.dtsi | 4 +- .../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 +- .../dts/allwinner/sun50i-a64-pinephone.dtsi | 8 +- .../boot/dts/allwinner/sun50i-a64-pinetab.dts | 8 +- .../allwinner/sun50i-a64-sopine-baseboard.dts | 8 +- .../boot/dts/allwinner/sun50i-a64-teres-i.dts | 8 +- arch/arm64/boot/dts/allwinner/sun50i-a64.dtsi | 11 +- sound/soc/sunxi/sun8i-codec.c | 137 ++++++++++++++---- 13 files changed, 155 insertions(+), 71 deletions(-) -- 2.26.2
2020-08-18ASoC: various vendors: delete repeated words in commentsRandy Dunlap1-1/+1
Drop the repeated words {related, we, is, the} in comments. Signed-off-by: Randy Dunlap <rdunlap@infradead.org> Cc: Liam Girdwood <lgirdwood@gmail.com> Cc: Mark Brown <broonie@kernel.org> Cc: alsa-devel@alsa-project.org Link: https://lore.kernel.org/r/20200808012209.10880-1-rdunlap@infradead.org Signed-off-by: Mark Brown <broonie@kernel.org>
2020-08-17ASoC: sun50i-codec-analog: Enable DAPM for earpiece switchSamuel Holland1-6/+11
By including the earpiece mute switch in the DAPM graph, both the earpiece amplifier and the Mixer/DAC inputs can be powered off when the earpiece is muted. While the widget is really just a simple switch, it is represented as a "mixer with named controls" to avoid including the widget name in the kcontrol name. Otherwise, it is not possible to give the widget an accurate, descriptive name without changing the kcontrol name seen by userspace (which should be stable). The mute switch is between the source selection and the amplifier, as per the diagram in the SoC manual. Signed-off-by: Samuel Holland <samuel@sholland.org> Link: https://lore.kernel.org/r/20200726025334.59931-9-samuel@sholland.org Signed-off-by: Mark Brown <broonie@kernel.org>
2020-08-17ASoC: sun50i-codec-analog: Enable DAPM for line out switchSamuel Holland1-8/+15
By including the line out mute switch in the DAPM graph, the Mixer/DAC inputs can be powered off when the line output is muted. The line outputs have an unusual routing scheme. The left side mute switch is between the source selection and the amplifier, as usual. The right side source selection comes *after* its amplifier (and after the left side amplifier), and its mute switch controls whichever source is currently selected. This matches the diagram in the SoC manual. Signed-off-by: Samuel Holland <samuel@sholland.org> Reviewed-by: Chen-Yu Tsai <wens@csie.org> Link: https://lore.kernel.org/r/20200726025334.59931-8-samuel@sholland.org Signed-off-by: Mark Brown <broonie@kernel.org>
2020-08-17ASoC: sun50i-codec-analog: Make line out routes stereoSamuel Holland1-7/+11
This matches the hardware more accurately, and is necessary for including the (stereo) line out mute switch in the DAPM graph. Signed-off-by: Samuel Holland <samuel@sholland.org> Reviewed-by: Chen-Yu Tsai <wens@csie.org> Link: https://lore.kernel.org/r/20200726025334.59931-7-samuel@sholland.org Signed-off-by: Mark Brown <broonie@kernel.org>
2020-08-17ASoC: sun50i-codec-analog: Enable DAPM for headphone switchSamuel Holland1-7/+14
By including the headphone mute switch to the DAPM graph, both the headphone amplifier and the Mixer/DAC inputs can be powered off when the headphones are muted. The mute switch is between the source selection and the amplifier, as per the diagram in the SoC manual. Signed-off-by: Samuel Holland <samuel@sholland.org> Reviewed-by: Chen-Yu Tsai <wens@csie.org> Link: https://lore.kernel.org/r/20200726025334.59931-6-samuel@sholland.org Signed-off-by: Mark Brown <broonie@kernel.org>
2020-08-17ASoC: sun50i-codec-analog: Make headphone routes stereoSamuel Holland1-8/+20
This matches the hardware more accurately, and is necessary for including the (stereo) headphone mute switch in the DAPM graph. Signed-off-by: Samuel Holland <samuel@sholland.org> Reviewed-by: Chen-Yu Tsai <wens@csie.org> Link: https://lore.kernel.org/r/20200726025334.59931-5-samuel@sholland.org Signed-off-by: Mark Brown <broonie@kernel.org>
2020-08-17ASoC: sun50i-codec-analog: Group and sort mixer routesSamuel Holland1-30/+28
Sort the controls in the same order as the bits in the register. Then group the routes by sink, and sort them in the same order as the controls. This makes it much easier to verify that all mixer inputs are accounted for. Signed-off-by: Samuel Holland <samuel@sholland.org> Acked-by: Chen-Yu Tsai <wens@csie.org> Link: https://lore.kernel.org/r/20200726025334.59931-4-samuel@sholland.org Signed-off-by: Mark Brown <broonie@kernel.org>
2020-08-17ASoC: sun50i-codec-analog: Gate the amplifier clock during suspendSamuel Holland1-0/+15
The clock must be running for the zero-crossing mute functionality. However, it must be gated for VDD-SYS to be turned off during system suspend. Disable it in the suspend callback, after everything has already been muted, to avoid pops when muting/unmuting outputs. Signed-off-by: Samuel Holland <samuel@sholland.org> Acked-by: Chen-Yu Tsai <wens@csie.org> Link: https://lore.kernel.org/r/20200726025334.59931-3-samuel@sholland.org Signed-off-by: Mark Brown <broonie@kernel.org>
2020-08-17ASoC: sun50i-codec-analog: Fix duplicate use of ADC enable bitsSamuel Holland1-4/+2
The same enable bits are currently used for both the "Left/Right ADC" and the "Left/Right ADC Mixer" widgets. This happens to work in practice because the widgets are always enabled/disabled at the same time, but each register bit should only be associated with a single widget. To keep symmetry with the DAC widgets, keep the bits on the ADC widgets, and remove them from the ADC Mixer widgets. Fixes: 42371f327df0 ("ASoC: sunxi: Add new driver for Allwinner A64 codec's analog path controls") Reported-by: Ondrej Jirman <megous@megous.com> Signed-off-by: Samuel Holland <samuel@sholland.org> Acked-by: Chen-Yu Tsai <wens@csie.org> Link: https://lore.kernel.org/r/20200726025334.59931-2-samuel@sholland.org Signed-off-by: Mark Brown <broonie@kernel.org>
2020-08-17ASoC: sun8i-codec: Add a quirk for LRCK inversionSamuel Holland1-4/+7
On the A64, as tested using the PinePhone, the current code causes the left/right channels to be swapped during I2S playback from the CPU on AIF1, and breaks DSP_A communication with the modem on AIF2. Both of these are fixed when LRCK is no longer inverted. Trusting that the comment in the code is correct, the existing behavior is kept for the A33. Signed-off-by: Samuel Holland <samuel@sholland.org> Link: https://lore.kernel.org/r/20200726012557.38282-5-samuel@sholland.org Signed-off-by: Mark Brown <broonie@kernel.org>
2020-08-17ASoC: sun8i-codec: Add missing mixer routesSamuel Holland1-0/+6
The sun8i-codec driver provides ALSA controls for enabling/disabling each of the inputs to the AIF1 Slot 0 and DAC mixers. For two of these inputs (ADC->DAC and AIF1 DA0->AIF1 AD0), the audio source is implemented, so the mixer inputs can be used. However, because the DAPM routes are missing, these mixer inputs only work when both the source and the mixer happen to be part of other active audio paths. Adding the appropriate routes makes these ALSA controls function all of the time. Signed-off-by: Samuel Holland <samuel@sholland.org> Link: https://lore.kernel.org/r/20200726012557.38282-4-samuel@sholland.org Signed-off-by: Mark Brown <broonie@kernel.org>
2020-08-17ASoC: sun8i-codec: Fix DAPM to match the hardware topologySamuel Holland1-25/+95
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>
2020-07-23ASoC: sunxi: use asoc_substream_to_rtd()Kuninori Morimoto2-7/+7
Now we can use asoc_substream_to_rtd() macro, let's use it. Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com> Link: https://lore.kernel.org/r/87r1t70yuw.wl-kuninori.morimoto.gx@renesas.com Signed-off-by: Mark Brown <broonie@kernel.org>
2020-07-10ASoC: sunxi: sun4i-spdif: Fix misspelling of 'reg_dac_txdata' in kernel-docLee Jones1-1/+1
Property name descriptions need to match exactly. Fixes the following W=1 kernel build warning(s): sound/soc/sunxi/sun4i-spdif.c:178: warning: Function parameter or member 'reg_dac_txdata' not described in 'sun4i_spdif_quirks' Signed-off-by: Lee Jones <lee.jones@linaro.org> Signed-off-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com> Cc: Maxime Ripard <mripard@kernel.org> Cc: Chen-Yu Tsai <wens@csie.org> Cc: Philipp Zabel <p.zabel@pengutronix.de> Cc: Andrea Venturi <be17068@iperbole.bo.it> Cc: Marcus Cooper <codekipper@gmail.com> Link: https://lore.kernel.org/r/20200709162328.259586-5-pierre-louis.bossart@linux.intel.com Signed-off-by: Mark Brown <broonie@kernel.org>
2020-07-10ASoC: sunxi: sun4i-i2s: add missing clock and format arguments in kernel-docPierre-Louis Bossart1-1/+9
Fix W=1 warnings - missing fields in description sound/soc/sunxi/sun4i-i2s.c:160: warning: Function parameter or member 'bclk_dividers' not described in 'sun4i_i2s_quirks' sound/soc/sunxi/sun4i-i2s.c:160: warning: Function parameter or member 'num_bclk_dividers' not described in 'sun4i_i2s_quirks' sound/soc/sunxi/sun4i-i2s.c:160: warning: Function parameter or member 'mclk_dividers' not described in 'sun4i_i2s_quirks' sound/soc/sunxi/sun4i-i2s.c:160: warning: Function parameter or member 'num_mclk_dividers' not described in 'sun4i_i2s_quirks' sound/soc/sunxi/sun4i-i2s.c:160: warning: Function parameter or member 'get_bclk_parent_rate' not described in 'sun4i_i2s_quirks' sound/soc/sunxi/sun4i-i2s.c:160: warning: Function parameter or member 'get_sr' not described in 'sun4i_i2s_quirks' sound/soc/sunxi/sun4i-i2s.c:160: warning: Function parameter or member 'get_wss' not described in 'sun4i_i2s_quirks' sound/soc/sunxi/sun4i-i2s.c:160: warning: Function parameter or member 'set_chan_cfg' not described in 'sun4i_i2s_quirks' sound/soc/sunxi/sun4i-i2s.c:160: warning: Function parameter or member 'set_fmt' not described in 'sun4i_i2s_quirks' Signed-off-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com> Cc: Maxime Ripard <mripard@kernel.org> Cc: Chen-Yu Tsai <wens@csie.org> Cc: Philipp Zabel <p.zabel@pengutronix.de> Cc: Andrea Venturi <be17068@iperbole.bo.it> Link: https://lore.kernel.org/r/20200709162328.259586-4-pierre-louis.bossart@linux.intel.com Signed-off-by: Mark Brown <broonie@kernel.org>
2020-03-27ASoC: sunxi: use asoc_rtd_to_cpu() / asoc_rtd_to_codec() macro for DAI pointerKuninori Morimoto1-1/+1
Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com> Tested-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com> Link: https://lore.kernel.org/r/878sjrir43.wl-kuninori.morimoto.gx@renesas.com Signed-off-by: Mark Brown <broonie@kernel.org>
2020-02-24Merge branch 'for-5.6' of https://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound into asoc-5.7Mark Brown1-1/+2
2020-02-21ASoC: sun8i-codec: Remove unused dev from codec structSamuel Holland1-3/+0
This field is not used anywhere in the driver, so remove it. Fixes: 36c684936fae ("ASoC: Add sun8i digital audio codec") Signed-off-by: Samuel Holland <samuel@sholland.org> Acked-by: Chen-Yu Tsai <wens@csie.org> Link: https://lore.kernel.org/r/20200217064250.15516-5-samuel@sholland.org Signed-off-by: Mark Brown <broonie@kernel.org>
2020-02-17ASoC: sun8i-codec: Fix setting DAI data formatSamuel Holland1-1/+2
Use the correct mask for this two-bit field. This fixes setting the DAI data format to RIGHT_J or DSP_A. Fixes: 36c684936fae ("ASoC: Add sun8i digital audio codec") Signed-off-by: Samuel Holland <samuel@sholland.org> Acked-by: Chen-Yu Tsai <wens@csie.org> Cc: stable@kernel.org Link: https://lore.kernel.org/r/20200217064250.15516-7-samuel@sholland.org Signed-off-by: Mark Brown <broonie@kernel.org>
2020-02-04treewide: remove redundant IS_ERR() before error code checkMasahiro Yamada1-1/+1
'PTR_ERR(p) == -E*' is a stronger condition than IS_ERR(p). Hence, IS_ERR(p) is unneeded. The semantic patch that generates this commit is as follows: // <smpl> @@ expression ptr; constant error_code; @@ -IS_ERR(ptr) && (PTR_ERR(ptr) == - error_code) +PTR_ERR(ptr) == - error_code // </smpl> Link: http://lkml.kernel.org/r/20200106045833.1725-1-masahiroy@kernel.org Signed-off-by: Masahiro Yamada <masahiroy@kernel.org> Cc: Julia Lawall <julia.lawall@lip6.fr> Acked-by: Stephen Boyd <sboyd@kernel.org> [drivers/clk/clk.c] Acked-by: Bartosz Golaszewski <bgolaszewski@baylibre.com> [GPIO] Acked-by: Wolfram Sang <wsa@the-dreams.de> [drivers/i2c] Acked-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com> [acpi/scan.c] Acked-by: Rob Herring <robh@kernel.org> Cc: Eric Biggers <ebiggers@kernel.org> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2019-10-28ASoC: sunxi: sun4i-codec: remove unneeded semicolonYueHaibing1-3/+3
remove unneeded semicolon. Signed-off-by: YueHaibing <yuehaibing@huawei.com> Link: https://lore.kernel.org/r/20191025120801.16236-1-yuehaibing@huawei.com Signed-off-by: Mark Brown <broonie@kernel.org>
2019-08-27ASoC: sun4i: Revert A83t descriptionMaxime Ripard1-12/+12
The last set of reworks included some fixes to change the A83t behaviour and "fix" it. It turns out that the controller described in the datasheet and the one supported here are not the same, yet the A83t has the two of them, and the one supported in the driver wasn't the one described in the datasheet. Fix this by reintroducing the proper quirks. Fixes: 69e450e50ca6 ("ASoC: sun4i-i2s: Fix the LRCK period on A83t") Fixes: bf943d527987 ("ASoC: sun4i-i2s: Fix MCLK Enable bit offset on A83t") Fixes: 2e04fc4dbf50 ("ASoC: sun4i-i2s: Fix WSS and SR fields for the A83t") Fixes: 515fcfbc7736 ("ASoC: sun4i-i2s: Fix LRCK and BCLK polarity offsets on newer SoCs") Fixes: c1d3a921d72b ("ASoC: sun4i-i2s: Fix the MCLK and BCLK dividers on newer SoCs") Fixes: fb19739d7f68 ("ASoC: sun4i-i2s: Use module clock as BCLK parent on newer SoCs") Fixes: 71137bcd0a9a ("ASoC: sun4i-i2s: Move the format configuration to a callback") Fixes: d70be625f25a ("ASoC: sun4i-i2s: Move the channel configuration to a callback") Reported-by: Chen-Yu Tsai <wens@csie.org> Tested-by: Chen-Yu Tsai <wens@csie.org> Signed-off-by: Maxime Ripard <maxime.ripard@bootlin.com> Link: https://lore.kernel.org/r/20190827123131.29129-2-mripard@kernel.org Signed-off-by: Mark Brown <broonie@kernel.org>
2019-08-27ASoC: sunxi: Revert initial A83t supportMaxime Ripard1-1/+24
This reverts commit 3e9acd7ac6933c (ASoC: sun4i-i2s: Remove duplicated quirks structure"). It turns out that while one I2S controller is described in the A83t datasheet, the driver supports another, undocumented, one that has been inherited from the older SoCs, while the documented one uses the new design. Fixes: 3e9acd7ac693 ("ASoC: sun4i-i2s: Remove duplicated quirks structure") Signed-off-by: Maxime Ripard <maxime.ripard@bootlin.com> Link: https://lore.kernel.org/r/20190827093206.17919-1-mripard@kernel.org Signed-off-by: Mark Brown <broonie@kernel.org>
2019-08-21ASoC: sun4i-i2s: Add support for DSP formatsMaxime Ripard1-9/+35
In addition to the I2S format, the controller also supports the DSP_* formats. This requires some extra care on the LRCK period calculation, since the controller, with the PCM formats, require that the value set is no longer the periods of LRCK for a single channel, but for all of them. Let's add the code to deal with this, and support the DSP_A and DSP_B formats. Signed-off-by: Maxime Ripard <maxime.ripard@bootlin.com> Link: https://lore.kernel.org/r/5562db1ac8759f12b1b87c3258223eed629ef771.1566392800.git-series.maxime.ripard@bootlin.com Signed-off-by: Mark Brown <broonie@kernel.org>
2019-08-21ASoC: sun4i-i2s: Replace call to params_width by local variableMaxime Ripard1-1/+1
The sun4i_i2s_hw_params function already has a variable holding the value returned by params_width, so let's just use that variable instead of calling params_width multiple times. Signed-off-by: Maxime Ripard <maxime.ripard@bootlin.com> Link: https://lore.kernel.org/r/f85a1c1e014080a4bbc3abd19bc8fdcb86f0981a.1566392800.git-series.maxime.ripard@bootlin.com Signed-off-by: Mark Brown <broonie@kernel.org>