[PATCH 0/7] PinePhone BT audio bringup
This series makes use of the additional DAIs recently added to the sun8i-codec driver to add hardware routing for BT SCO (headset) audio on the PinePhone.
The BT audio connection is represented by the "dummy" bt-sco codec. The connection to the Quectel EG-25G modem via AIF2 works as well, but I do not include it here because there is no appropriate codec driver in tree. We have been using an out-of-tree "dummy" codec driver similar to bt-sco, and I'm not sure if such a driver would be desired upstream.
The modem has a similar amount of configurability as the rtl8723cs BT chip. For the BT chip, the DAI format and PCM parameters are set in a configuration firmware file and loaded at driver load time. For the modem, the DAI format and PCM parameters are set by (and can be queried from) an AT command. However, this AT command requires a modem restart to take effect, so the parameters cannot feasibly be changed at runtime.
With a dummy driver, we pick some "standard" set of PCM parameters, e.g. 16 bit mono at 8 or 16 kHz, and assume the hardware agrees. Similarly, we assume the DAI format pre-programmed in the remote hardware matches what is configured in the DAI link (in this case, in the device tree).
Is that the right way to model this? Or does the modem (and maybe even the BT chip) deserve a more featureful driver that reads and/or programs the format and params at probe time?
Because of those unanswered questions, I'm sending BT SCO support first/only.
Regards, Samuel
Arnaud Ferraris (1): arm64: dts: allwinner: pinephone: Set audio card name
Samuel Holland (6): ASoC: dt-bindings: sun8i-codec: Increase #sound-dai-cells ARM: dts: sun8i-a33: Allow using multiple codec DAIs arm64: dts: allwinner: a64: Allow using multiple codec DAIs arm64: dts: allwinner: a64: Add pinmux nodes for AIF2/AIF3 arm64: dts: allwinner: a64: Allow multiple DAI links arm64: dts: allwinner: pinephone: Add support for Bluetooth audio
.../sound/allwinner,sun8i-a33-codec.yaml | 2 +- arch/arm/boot/dts/sun8i-a33.dtsi | 4 +- .../dts/allwinner/sun50i-a64-pinephone.dtsi | 25 +++++++++++++ arch/arm64/boot/dts/allwinner/sun50i-a64.dtsi | 37 ++++++++++++++----- 4 files changed, 55 insertions(+), 13 deletions(-)
Increase sound-dai-cells to 1 to allow using the DAIs in the codec corresponding to AIF2 and AIF3.
The generic ASoC OF code supports a #sound-dai-cells value of 0 or 1 with no impact to the driver, so this is a backward-compatible change.
Signed-off-by: Samuel Holland samuel@sholland.org --- .../devicetree/bindings/sound/allwinner,sun8i-a33-codec.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/Documentation/devicetree/bindings/sound/allwinner,sun8i-a33-codec.yaml b/Documentation/devicetree/bindings/sound/allwinner,sun8i-a33-codec.yaml index 67405e6d8168..1a2590f54b9b 100644 --- a/Documentation/devicetree/bindings/sound/allwinner,sun8i-a33-codec.yaml +++ b/Documentation/devicetree/bindings/sound/allwinner,sun8i-a33-codec.yaml @@ -12,7 +12,7 @@ maintainers:
properties: "#sound-dai-cells": - const: 0 + const: 1
compatible: oneOf:
On Thu, 05 Nov 2020 22:15:07 -0600, Samuel Holland wrote:
Increase sound-dai-cells to 1 to allow using the DAIs in the codec corresponding to AIF2 and AIF3.
The generic ASoC OF code supports a #sound-dai-cells value of 0 or 1 with no impact to the driver, so this is a backward-compatible change.
Signed-off-by: Samuel Holland samuel@sholland.org
.../devicetree/bindings/sound/allwinner,sun8i-a33-codec.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
My bot found errors running 'make dt_binding_check' on your patch:
yamllint warnings/errors:
dtschema/dtc warnings/errors: /builds/robherring/linux-dt-review/Documentation/devicetree/bindings/sound/allwinner,sun8i-a33-codec.example.dt.yaml: audio-codec@1c22e00: #sound-dai-cells:0:0: 1 was expected From schema: /builds/robherring/linux-dt-review/Documentation/devicetree/bindings/sound/allwinner,sun8i-a33-codec.yaml
See https://patchwork.ozlabs.org/patch/1395481
The base for the patch is generally the last rc1. Any dependencies should be noted.
If you already ran 'make dt_binding_check' and didn't see the above error(s), then make sure 'yamllint' is installed and dt-schema is up to date:
pip3 install dtschema --upgrade
Please check and re-submit.
Increase #sound-dai-cells on the digital codec to allow using the other DAIs provided by the codec for AIF2 and AIF3.
Signed-off-by: Samuel Holland samuel@sholland.org --- arch/arm/boot/dts/sun8i-a33.dtsi | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/arch/arm/boot/dts/sun8i-a33.dtsi b/arch/arm/boot/dts/sun8i-a33.dtsi index c458f5fb124f..0b38f9f35074 100644 --- a/arch/arm/boot/dts/sun8i-a33.dtsi +++ b/arch/arm/boot/dts/sun8i-a33.dtsi @@ -198,7 +198,7 @@ simple-audio-card,cpu { };
link_codec: simple-audio-card,codec { - sound-dai = <&codec>; + sound-dai = <&codec 0>; }; };
@@ -238,7 +238,7 @@ dai: dai@1c22c00 { };
codec: codec@1c22e00 { - #sound-dai-cells = <0>; + #sound-dai-cells = <1>; compatible = "allwinner,sun8i-a33-codec"; reg = <0x01c22e00 0x400>; interrupts = <GIC_SPI 29 IRQ_TYPE_LEVEL_HIGH>;
Increase #sound-dai-cells on the digital codec to allow using the other DAIs provided by the codec for AIF2 and AIF3.
Signed-off-by: Samuel Holland samuel@sholland.org --- arch/arm64/boot/dts/allwinner/sun50i-a64.dtsi | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/arch/arm64/boot/dts/allwinner/sun50i-a64.dtsi b/arch/arm64/boot/dts/allwinner/sun50i-a64.dtsi index dc238814013c..b70596c06c4f 100644 --- a/arch/arm64/boot/dts/allwinner/sun50i-a64.dtsi +++ b/arch/arm64/boot/dts/allwinner/sun50i-a64.dtsi @@ -150,7 +150,7 @@ cpudai: simple-audio-card,cpu { };
link_codec: simple-audio-card,codec { - sound-dai = <&codec>; + sound-dai = <&codec 0>; }; };
@@ -860,7 +860,7 @@ dai: dai@1c22c00 { };
codec: codec@1c22e00 { - #sound-dai-cells = <0>; + #sound-dai-cells = <1>; compatible = "allwinner,sun50i-a64-codec", "allwinner,sun8i-a33-codec"; reg = <0x01c22e00 0x600>;
Now that the sun8i-codec driver supports AIF2 and AIF3, boards can use them in DAI links. Add the necessary pinmux nodes.
Signed-off-by: Samuel Holland samuel@sholland.org --- arch/arm64/boot/dts/allwinner/sun50i-a64.dtsi | 12 ++++++++++++ 1 file changed, 12 insertions(+)
diff --git a/arch/arm64/boot/dts/allwinner/sun50i-a64.dtsi b/arch/arm64/boot/dts/allwinner/sun50i-a64.dtsi index b70596c06c4f..97334e25ddd3 100644 --- a/arch/arm64/boot/dts/allwinner/sun50i-a64.dtsi +++ b/arch/arm64/boot/dts/allwinner/sun50i-a64.dtsi @@ -654,6 +654,18 @@ pio: pinctrl@1c20800 { interrupt-controller; #interrupt-cells = <3>;
+ /omit-if-no-ref/ + aif2_pins: aif2-pins { + pins = "PB4", "PB5", "PB6", "PB7"; + function = "aif2"; + }; + + /omit-if-no-ref/ + aif3_pins: aif3-pins { + pins = "PG10", "PG11", "PG12", "PG13"; + function = "aif3"; + }; + csi_pins: csi-pins { pins = "PE0", "PE2", "PE3", "PE4", "PE5", "PE6", "PE7", "PE8", "PE9", "PE10", "PE11";
simple-audio-card supports either a single DAI link at the top level, or subnodes with one or more DAI links. To use the secondary AIFs on the codec, we need to add additional DAI links to the same sound card, so we need to use the other binding.
Signed-off-by: Samuel Holland samuel@sholland.org --- arch/arm64/boot/dts/allwinner/sun50i-a64.dtsi | 23 +++++++++++-------- 1 file changed, 14 insertions(+), 9 deletions(-)
diff --git a/arch/arm64/boot/dts/allwinner/sun50i-a64.dtsi b/arch/arm64/boot/dts/allwinner/sun50i-a64.dtsi index 97334e25ddd3..06c2b355d80f 100644 --- a/arch/arm64/boot/dts/allwinner/sun50i-a64.dtsi +++ b/arch/arm64/boot/dts/allwinner/sun50i-a64.dtsi @@ -131,12 +131,10 @@ psci { };
sound: sound { + #address-cells = <1>; + #size-cells = <0>; compatible = "simple-audio-card"; simple-audio-card,name = "sun50i-a64-audio"; - simple-audio-card,format = "i2s"; - simple-audio-card,frame-master = <&cpudai>; - simple-audio-card,bitclock-master = <&cpudai>; - simple-audio-card,mclk-fs = <128>; simple-audio-card,aux-devs = <&codec_analog>; simple-audio-card,routing = "Left DAC", "DACL", @@ -145,12 +143,19 @@ sound: sound { "ADCR", "Right ADC"; status = "disabled";
- cpudai: simple-audio-card,cpu { - sound-dai = <&dai>; - }; + simple-audio-card,dai-link@0 { + format = "i2s"; + frame-master = <&link0_cpu>; + bitclock-master = <&link0_cpu>; + mclk-fs = <128>;
- link_codec: simple-audio-card,codec { - sound-dai = <&codec 0>; + link0_cpu: cpu { + sound-dai = <&dai>; + }; + + link0_codec: codec { + sound-dai = <&codec 0>; + }; }; };
The PinePhone has a Bluetooth chip with its PCM interface connected to AIF3. Add the DAI link so headeset audio can be routed in hardware.
Even though the link is mono, configuring the link for 2 slots is required for compatibility with AIF2, which also uses 2 slots, and which shares clock dividers with AIF3. Using equal clock frequencies allows the modem and headset to be used at the same time.
Signed-off-by: Samuel Holland samuel@sholland.org --- .../dts/allwinner/sun50i-a64-pinephone.dtsi | 24 +++++++++++++++++++ 1 file changed, 24 insertions(+)
diff --git a/arch/arm64/boot/dts/allwinner/sun50i-a64-pinephone.dtsi b/arch/arm64/boot/dts/allwinner/sun50i-a64-pinephone.dtsi index 5780713b0dba..6125910d29db 100644 --- a/arch/arm64/boot/dts/allwinner/sun50i-a64-pinephone.dtsi +++ b/arch/arm64/boot/dts/allwinner/sun50i-a64-pinephone.dtsi @@ -23,6 +23,11 @@ backlight: backlight { /* Backlight configuration differs per PinePhone revision. */ };
+ bt_sco_codec: bt-sco-codec { + #sound-dai-cells = <1>; + compatible = "linux,bt-sco"; + }; + chosen { stdout-path = "serial0:115200n8"; }; @@ -63,6 +68,8 @@ vibrator { };
&codec { + pinctrl-names = "default"; + pinctrl-0 = <&aif3_pins>; status = "okay"; };
@@ -400,6 +407,23 @@ &sound { "MIC1", "Internal Microphone", "Headset Microphone", "HBIAS", "MIC2", "Headset Microphone"; + + simple-audio-card,dai-link@2 { + format = "dsp_a"; + frame-master = <&link2_codec>; + bitclock-master = <&link2_codec>; + bitclock-inversion; + + link2_cpu: cpu { + sound-dai = <&bt_sco_codec 0>; + }; + + link2_codec: codec { + sound-dai = <&codec 2>; + dai-tdm-slot-num = <2>; + dai-tdm-slot-width = <16>; + }; + }; };
&uart0 {
From: Arnaud Ferraris arnaud.ferraris@collabora.com
Add the "PinePhone" name to the sound card: this will make upstreaming an ALSA UCM config easier as we can use a unique name.
It also avoids an issue where the default card name is truncated.
Signed-off-by: Arnaud Ferraris arnaud.ferraris@collabora.com [Samuel: Split out change, updated commit message] Signed-off-by: Samuel Holland samuel@sholland.org --- arch/arm64/boot/dts/allwinner/sun50i-a64-pinephone.dtsi | 1 + 1 file changed, 1 insertion(+)
diff --git a/arch/arm64/boot/dts/allwinner/sun50i-a64-pinephone.dtsi b/arch/arm64/boot/dts/allwinner/sun50i-a64-pinephone.dtsi index 6125910d29db..fca6310df6c3 100644 --- a/arch/arm64/boot/dts/allwinner/sun50i-a64-pinephone.dtsi +++ b/arch/arm64/boot/dts/allwinner/sun50i-a64-pinephone.dtsi @@ -386,6 +386,7 @@ ®_rtc_ldo {
&sound { status = "okay"; + simple-audio-card,name = "PinePhone"; simple-audio-card,aux-devs = <&codec_analog>, <&speaker_amp>; simple-audio-card,widgets = "Microphone", "Headset Microphone", "Microphone", "Internal Microphone",
Hi,
On Fri, Nov 6, 2020 at 12:15 PM Samuel Holland samuel@sholland.org wrote:
This series makes use of the additional DAIs recently added to the sun8i-codec driver to add hardware routing for BT SCO (headset) audio on the PinePhone.
The BT audio connection is represented by the "dummy" bt-sco codec. The connection to the Quectel EG-25G modem via AIF2 works as well, but I do not include it here because there is no appropriate codec driver in tree. We have been using an out-of-tree "dummy" codec driver similar to bt-sco, and I'm not sure if such a driver would be desired upstream.
The modem has a similar amount of configurability as the rtl8723cs BT chip. For the BT chip, the DAI format and PCM parameters are set in a configuration firmware file and loaded at driver load time. For the modem, the DAI format and PCM parameters are set by (and can be queried from) an AT command. However, this AT command requires a modem restart to take effect, so the parameters cannot feasibly be changed at runtime.
With a dummy driver, we pick some "standard" set of PCM parameters, e.g. 16 bit mono at 8 or 16 kHz, and assume the hardware agrees. Similarly, we assume the DAI format pre-programmed in the remote hardware matches what is configured in the DAI link (in this case, in the device tree).
Is that the right way to model this? Or does the modem (and maybe even the BT chip) deserve a more featureful driver that reads and/or programs the format and params at probe time?
FYI there's a "Bluetooth: Allow to use configure SCO socket codec parameters" thread on the bluetooth mailing list which is still unresolved AFAICT.
You might want to take a look at it.
ChenYu
Because of those unanswered questions, I'm sending BT SCO support first/only.
Regards, Samuel
Arnaud Ferraris (1): arm64: dts: allwinner: pinephone: Set audio card name
Samuel Holland (6): ASoC: dt-bindings: sun8i-codec: Increase #sound-dai-cells ARM: dts: sun8i-a33: Allow using multiple codec DAIs arm64: dts: allwinner: a64: Allow using multiple codec DAIs arm64: dts: allwinner: a64: Add pinmux nodes for AIF2/AIF3 arm64: dts: allwinner: a64: Allow multiple DAI links arm64: dts: allwinner: pinephone: Add support for Bluetooth audio
.../sound/allwinner,sun8i-a33-codec.yaml | 2 +- arch/arm/boot/dts/sun8i-a33.dtsi | 4 +- .../dts/allwinner/sun50i-a64-pinephone.dtsi | 25 +++++++++++++ arch/arm64/boot/dts/allwinner/sun50i-a64.dtsi | 37 ++++++++++++++----- 4 files changed, 55 insertions(+), 13 deletions(-)
-- 2.26.2
participants (3)
-
Chen-Yu Tsai
-
Rob Herring
-
Samuel Holland