From 4ede989f2c3bc141f1c43749592cb46d9db2faaa Mon Sep 17 00:00:00 2001 From: Paolo Sabatino Date: Sun, 1 Dec 2024 21:54:10 +0100 Subject: [PATCH] rockchip: fix asound.conf for rk322x-box and xt-q8l-v10 boards sound node in device trees have been migrated to audio-graph-card2 to overcome limitations and configuration mayhems in ALSA userland libraries --- packages/bsp/rockchip/asound.conf | 56 ++++----- .../archive/rockchip-6.12/dt/rk322x-box.dts | 119 +++++++++++------- .../rockchip-6.12/dt/rk3288-xt-q8l-v10.dts | 75 ++++++----- .../general-rockchip-various-fixes.patch | 23 ---- .../archive/rockchip-6.6/dt/rk322x-box.dts | 119 +++++++++++------- .../rockchip-6.6/dt/rk3288-xt-q8l-v10.dts | 75 ++++++----- .../general-rockchip-various-fixes.patch | 2 +- 7 files changed, 242 insertions(+), 227 deletions(-) diff --git a/packages/bsp/rockchip/asound.conf b/packages/bsp/rockchip/asound.conf index 6559665239..4aec50abab 100644 --- a/packages/bsp/rockchip/asound.conf +++ b/packages/bsp/rockchip/asound.conf @@ -1,27 +1,3 @@ -pcm.OnBoard_D0 { - - type hw - card OnBoard - device 0 - -} - -pcm.OnBoard_D1 { - - type hw - card OnBoard - device 1 - -} - -pcm.OnBoard_D2 { - - type hw - card OnBoard - device 2 - -} - # Configuration to expose the SPDIF device of RK3288 to ALSA. # The device tree must describe a simple-audio-card device named "SPDIF" # for this to work properly @@ -53,24 +29,18 @@ cards.SPDIF.pcm.iec958.0 { } # Configuration to expose the HDMI device of RK3288 to ALSA. -# The device tree must describe a simple-audio-card device named "DW-I2S-HDMI" +# The device tree must describe a simple-audio-card device named "HDMI" # for this to work properly # This percolates to PulseAudio, which will eventually show the proper # labels to the audio device -cards.DW-I2S-HDMI.pcm.hdmi.0 { - @args [ CARD DEVICE CTLINDEX AES0 AES1 AES2 AES3 ] +cards.HDMI.pcm.hdmi.0 { + @args [ CARD AES0 AES1 AES2 AES3 ] @args.CARD { type string } - @args.DEVICE { - type integer - } - @args.CTLINDEX { - type integer - } @args.AES0 { type integer } @@ -83,6 +53,22 @@ cards.DW-I2S-HDMI.pcm.hdmi.0 { @args.AES3 { type integer } - type hw - card $CARD + type hooks + slave.pcm { + type hw + card $CARD + } + hooks.0 { + type ctl_elems + hook_args [ + { + interface PCM + name "IEC958 Playback Default" + lock true + preserve true + value [ $AES0 $AES1 $AES2 $AES3 ] + } + ] + } } + diff --git a/patch/kernel/archive/rockchip-6.12/dt/rk322x-box.dts b/patch/kernel/archive/rockchip-6.12/dt/rk322x-box.dts index ddc25ec77f..1382c432b6 100644 --- a/patch/kernel/archive/rockchip-6.12/dt/rk322x-box.dts +++ b/patch/kernel/archive/rockchip-6.12/dt/rk322x-box.dts @@ -24,7 +24,7 @@ /delete-node/ opp-table-0; /* - * Rebuild the thermal zones and cooling maps ourselved + * Rebuild the thermal zones and cooling maps ourselves */ /delete-node/ thermal-zones; @@ -37,20 +37,6 @@ mmc2 = &emmc; }; - analog-sound { - compatible = "simple-audio-card"; - simple-audio-card,format = "i2s"; - simple-audio-card,mclk-fs = <256>; - simple-audio-card,name = "analog"; - simple-audio-card,cpu { - sound-dai = <&i2s1>; - }; - - simple-audio-card,codec { - sound-dai = <&codec>; - }; - }; - chosen { bootargs = "earlyprintk=uart8250,mmio32,0x11030000"; }; @@ -142,25 +128,6 @@ reset-gpios = <&gpio2 RK_PD2 GPIO_ACTIVE_LOW>; }; - - spdif_out: spdif-out { - status = "okay"; - compatible = "linux,spdif-dit"; - #sound-dai-cells = <0>; - }; - - spdif-sound { - status = "okay"; - compatible = "simple-audio-card"; - simple-audio-card,name = "SPDIF"; - simple-audio-card,cpu { - sound-dai = <&spdif>; - }; - simple-audio-card,codec { - sound-dai = <&spdif_out>; - }; - }; - vcc_sys: vcc-sys-regulator { compatible = "regulator-fixed"; regulator-name = "vcc_sys"; @@ -318,11 +285,35 @@ }; }; -}; + hdmi-sound { + compatible = "audio-graph-card2"; + label = "HDMI"; + links = <&i2s0_port>; + }; + + analog-sound { + compatible = "audio-graph-card2"; + label = "analog"; + links = <&i2s1_port>; + }; + + spdif-sound { + compatible = "audio-graph-card2"; + label = "SPDIF"; + links = <&spdif_port>; + }; + + spdif_out: spdif-out { + status = "okay"; + compatible = "linux,spdif-dit"; + #sound-dai-cells = <0>; + spdif_out_port: port { + spdif_out_ep: endpoint { + remote-endpoint = <&spdif_ep>; + }; + }; + }; -&codec { - #sound-dai-cells = <0>; - status = "okay"; }; &cpu0 { @@ -460,23 +451,63 @@ &hdmi { status = "okay"; -}; - -&hdmi_sound { - status = "okay"; + hdmi_port: port { + hdmi_ep: endpoint { + remote-endpoint = <&i2s0_ep>; + }; + }; }; &hdmi_phy { status = "okay"; }; +&codec { + #sound-dai-cells = <0>; + status = "okay"; + codec_port: port { + codec_ep: endpoint { + remote-endpoint = <&i2s1_ep>; + }; + }; +}; + +&spdif { + status = "okay"; + spdif_port: port { + spdif_ep: endpoint { + remote-endpoint = <&spdif_out_ep>; + }; + }; +}; + &i2s0 { status = "okay"; + i2s0_port: port { + i2s0_ep: endpoint { + system-clock-direction-out; + frame-master; + bitclock-master; + mclk-fs = <256>; + dai-format = "i2s"; + remote-endpoint = <&hdmi_ep>; + }; + }; }; &i2s1 { #sound-dai-cells = <0>; status = "okay"; + i2s1_port: port { + i2s1_ep: endpoint { + system-clock-direction-out; + frame-master; + bitclock-master; + mclk-fs = <256>; + dai-format = "i2s"; + remote-endpoint = <&codec_ep>; + }; + }; }; /** Integration to pin controller */ @@ -742,10 +773,6 @@ status = "okay"; }; -&spdif { - status = "okay"; -}; - &tsadc { rockchip,grf = <&grf>; rockchip,hw-tshut-mode = <0>; diff --git a/patch/kernel/archive/rockchip-6.12/dt/rk3288-xt-q8l-v10.dts b/patch/kernel/archive/rockchip-6.12/dt/rk3288-xt-q8l-v10.dts index b715818fe6..a26e0c4c75 100644 --- a/patch/kernel/archive/rockchip-6.12/dt/rk3288-xt-q8l-v10.dts +++ b/patch/kernel/archive/rockchip-6.12/dt/rk3288-xt-q8l-v10.dts @@ -202,7 +202,7 @@ * Required power sequence to properly enable the wireless/bluetooth * module connected to sdio0 */ - sdio0_pwrseq: sdio0_pwrseq { + sdio0_pwrseq: sdio0-pwrseq { compatible = "mmc-pwrseq-simple"; pinctrl-names = "default"; pinctrl-0 = <&wifi_enable_h>; @@ -220,43 +220,26 @@ }; */ - /* - * Sound taken from tinkerboard device tree, adapted to q8. - */ - soundcard-hdmi { - compatible = "simple-audio-card"; - simple-audio-card,format = "i2s"; - simple-audio-card,name = "DW-I2S-HDMI"; - simple-audio-card,mclk-fs = <512>; - - simple-audio-card,codec { - sound-dai = <&hdmi>; - }; - - simple-audio-card,cpu { - sound-dai = <&i2s>; - }; + hdmi-sound { + compatible = "audio-graph-card2"; + label = "HDMI"; + links = <&i2s_port>; }; - soundcard-spdif { - compatible = "simple-audio-card"; - simple-audio-card,name = "SPDIF"; - simple-audio-card,dai-link@1 { - - cpu { - sound-dai = <&spdif>; - }; - - codec { - sound-dai = <&spdif_out>; - }; - - }; + spdif-sound { + compatible = "audio-graph-card2"; + label = "SPDIF"; + links = <&spdif_port>; }; spdif_out: spdif-out { compatible = "linux,spdif-dit"; #sound-dai-cells = <0>; + spdif_out_port: port { + spdif_out_ep: endpoint { + remote-endpoint = <&spdif_ep>; + }; + }; }; }; @@ -300,6 +283,11 @@ &hdmi { ddc-i2c-bus = <&i2c5>; status = "ok"; + hdmi_port: port { + hdmi_ep: endpoint { + remote-endpoint = <&i2s_ep>; + }; + }; }; &gpu { @@ -758,7 +746,7 @@ sdio0 { wifi_enable_h: wifienable-h { - rockchip,pins = <4 28 RK_FUNC_GPIO &pcfg_output_high>; + rockchip,pins = <4 28 RK_FUNC_GPIO &pcfg_pull_down>; }; }; @@ -868,9 +856,6 @@ vqmmc-supply = <&vcc_18>; // This must be the same as in io_domains, // otherwise the mmc1 device won't be detected properly - // clock-frequency = <50000000>; - // max-frequency = <50000000>; - pinctrl-names = "default"; pinctrl-0 = <&sdio0_bus4>, <&sdio0_cmd>, <&sdio0_clk>, <&sdio0_int>; @@ -884,6 +869,8 @@ keep-power-in-suspend; disable-wp; + //sd-uhs-sdr50; // required to be enabled, otherwise the device gets + // detected, but there is no communication status = "okay"; @@ -896,9 +883,6 @@ status = "okay"; }; - //sd-uhs-sdr104; // required to be disabled, otherwise the device get - // detected, but there is no communication - }; &spi0 { @@ -1053,11 +1037,26 @@ &i2s { #sound-dai-cells = <0>; status = "okay"; + i2s_port: port { + i2s_ep: endpoint { + system-clock-direction-out; + frame-master; + bitclock-master; + mclk-fs = <512>; + dai-format = "i2s"; + remote-endpoint = <&hdmi_ep>; + }; + }; }; // spdif is present on q8 device, enable it &spdif { status = "okay"; + spdif_port: port { + spdif_ep: endpoint { + remote-endpoint = <&spdif_out_ep>; + }; + }; }; /* diff --git a/patch/kernel/archive/rockchip-6.12/patches.armbian/general-rockchip-various-fixes.patch b/patch/kernel/archive/rockchip-6.12/patches.armbian/general-rockchip-various-fixes.patch index 1a0d56418b..00d644bde4 100644 --- a/patch/kernel/archive/rockchip-6.12/patches.armbian/general-rockchip-various-fixes.patch +++ b/patch/kernel/archive/rockchip-6.12/patches.armbian/general-rockchip-various-fixes.patch @@ -26,29 +26,6 @@ index 831561fc1814..24e963b01d87 100644 serial0 = &uart0; serial1 = &uart1; serial2 = &uart2; -@@ -105,6 +106,22 @@ arm-pmu { - interrupt-affinity = <&cpu0>, <&cpu1>, <&cpu2>, <&cpu3>; - }; - -+ hdmi_sound: hdmi-sound { -+ compatible = "simple-audio-card"; -+ simple-audio-card,name = "hdmi-sound"; -+ simple-audio-card,format = "i2s"; -+ simple-audio-card,mclk-fs = <256>; -+ status = "disabled"; -+ -+ simple-audio-card,cpu { -+ sound-dai = <&i2s0>; -+ }; -+ -+ simple-audio-card,codec { -+ sound-dai = <&hdmi>; -+ }; -+ }; -+ - psci { - compatible = "arm,psci-1.0", "arm,psci-0.2"; - method = "smc"; @@ -132,6 +149,17 @@ display_subsystem: display-subsystem { ports = <&vop_out>; }; diff --git a/patch/kernel/archive/rockchip-6.6/dt/rk322x-box.dts b/patch/kernel/archive/rockchip-6.6/dt/rk322x-box.dts index ddc25ec77f..1382c432b6 100644 --- a/patch/kernel/archive/rockchip-6.6/dt/rk322x-box.dts +++ b/patch/kernel/archive/rockchip-6.6/dt/rk322x-box.dts @@ -24,7 +24,7 @@ /delete-node/ opp-table-0; /* - * Rebuild the thermal zones and cooling maps ourselved + * Rebuild the thermal zones and cooling maps ourselves */ /delete-node/ thermal-zones; @@ -37,20 +37,6 @@ mmc2 = &emmc; }; - analog-sound { - compatible = "simple-audio-card"; - simple-audio-card,format = "i2s"; - simple-audio-card,mclk-fs = <256>; - simple-audio-card,name = "analog"; - simple-audio-card,cpu { - sound-dai = <&i2s1>; - }; - - simple-audio-card,codec { - sound-dai = <&codec>; - }; - }; - chosen { bootargs = "earlyprintk=uart8250,mmio32,0x11030000"; }; @@ -142,25 +128,6 @@ reset-gpios = <&gpio2 RK_PD2 GPIO_ACTIVE_LOW>; }; - - spdif_out: spdif-out { - status = "okay"; - compatible = "linux,spdif-dit"; - #sound-dai-cells = <0>; - }; - - spdif-sound { - status = "okay"; - compatible = "simple-audio-card"; - simple-audio-card,name = "SPDIF"; - simple-audio-card,cpu { - sound-dai = <&spdif>; - }; - simple-audio-card,codec { - sound-dai = <&spdif_out>; - }; - }; - vcc_sys: vcc-sys-regulator { compatible = "regulator-fixed"; regulator-name = "vcc_sys"; @@ -318,11 +285,35 @@ }; }; -}; + hdmi-sound { + compatible = "audio-graph-card2"; + label = "HDMI"; + links = <&i2s0_port>; + }; + + analog-sound { + compatible = "audio-graph-card2"; + label = "analog"; + links = <&i2s1_port>; + }; + + spdif-sound { + compatible = "audio-graph-card2"; + label = "SPDIF"; + links = <&spdif_port>; + }; + + spdif_out: spdif-out { + status = "okay"; + compatible = "linux,spdif-dit"; + #sound-dai-cells = <0>; + spdif_out_port: port { + spdif_out_ep: endpoint { + remote-endpoint = <&spdif_ep>; + }; + }; + }; -&codec { - #sound-dai-cells = <0>; - status = "okay"; }; &cpu0 { @@ -460,23 +451,63 @@ &hdmi { status = "okay"; -}; - -&hdmi_sound { - status = "okay"; + hdmi_port: port { + hdmi_ep: endpoint { + remote-endpoint = <&i2s0_ep>; + }; + }; }; &hdmi_phy { status = "okay"; }; +&codec { + #sound-dai-cells = <0>; + status = "okay"; + codec_port: port { + codec_ep: endpoint { + remote-endpoint = <&i2s1_ep>; + }; + }; +}; + +&spdif { + status = "okay"; + spdif_port: port { + spdif_ep: endpoint { + remote-endpoint = <&spdif_out_ep>; + }; + }; +}; + &i2s0 { status = "okay"; + i2s0_port: port { + i2s0_ep: endpoint { + system-clock-direction-out; + frame-master; + bitclock-master; + mclk-fs = <256>; + dai-format = "i2s"; + remote-endpoint = <&hdmi_ep>; + }; + }; }; &i2s1 { #sound-dai-cells = <0>; status = "okay"; + i2s1_port: port { + i2s1_ep: endpoint { + system-clock-direction-out; + frame-master; + bitclock-master; + mclk-fs = <256>; + dai-format = "i2s"; + remote-endpoint = <&codec_ep>; + }; + }; }; /** Integration to pin controller */ @@ -742,10 +773,6 @@ status = "okay"; }; -&spdif { - status = "okay"; -}; - &tsadc { rockchip,grf = <&grf>; rockchip,hw-tshut-mode = <0>; diff --git a/patch/kernel/archive/rockchip-6.6/dt/rk3288-xt-q8l-v10.dts b/patch/kernel/archive/rockchip-6.6/dt/rk3288-xt-q8l-v10.dts index b715818fe6..a26e0c4c75 100644 --- a/patch/kernel/archive/rockchip-6.6/dt/rk3288-xt-q8l-v10.dts +++ b/patch/kernel/archive/rockchip-6.6/dt/rk3288-xt-q8l-v10.dts @@ -202,7 +202,7 @@ * Required power sequence to properly enable the wireless/bluetooth * module connected to sdio0 */ - sdio0_pwrseq: sdio0_pwrseq { + sdio0_pwrseq: sdio0-pwrseq { compatible = "mmc-pwrseq-simple"; pinctrl-names = "default"; pinctrl-0 = <&wifi_enable_h>; @@ -220,43 +220,26 @@ }; */ - /* - * Sound taken from tinkerboard device tree, adapted to q8. - */ - soundcard-hdmi { - compatible = "simple-audio-card"; - simple-audio-card,format = "i2s"; - simple-audio-card,name = "DW-I2S-HDMI"; - simple-audio-card,mclk-fs = <512>; - - simple-audio-card,codec { - sound-dai = <&hdmi>; - }; - - simple-audio-card,cpu { - sound-dai = <&i2s>; - }; + hdmi-sound { + compatible = "audio-graph-card2"; + label = "HDMI"; + links = <&i2s_port>; }; - soundcard-spdif { - compatible = "simple-audio-card"; - simple-audio-card,name = "SPDIF"; - simple-audio-card,dai-link@1 { - - cpu { - sound-dai = <&spdif>; - }; - - codec { - sound-dai = <&spdif_out>; - }; - - }; + spdif-sound { + compatible = "audio-graph-card2"; + label = "SPDIF"; + links = <&spdif_port>; }; spdif_out: spdif-out { compatible = "linux,spdif-dit"; #sound-dai-cells = <0>; + spdif_out_port: port { + spdif_out_ep: endpoint { + remote-endpoint = <&spdif_ep>; + }; + }; }; }; @@ -300,6 +283,11 @@ &hdmi { ddc-i2c-bus = <&i2c5>; status = "ok"; + hdmi_port: port { + hdmi_ep: endpoint { + remote-endpoint = <&i2s_ep>; + }; + }; }; &gpu { @@ -758,7 +746,7 @@ sdio0 { wifi_enable_h: wifienable-h { - rockchip,pins = <4 28 RK_FUNC_GPIO &pcfg_output_high>; + rockchip,pins = <4 28 RK_FUNC_GPIO &pcfg_pull_down>; }; }; @@ -868,9 +856,6 @@ vqmmc-supply = <&vcc_18>; // This must be the same as in io_domains, // otherwise the mmc1 device won't be detected properly - // clock-frequency = <50000000>; - // max-frequency = <50000000>; - pinctrl-names = "default"; pinctrl-0 = <&sdio0_bus4>, <&sdio0_cmd>, <&sdio0_clk>, <&sdio0_int>; @@ -884,6 +869,8 @@ keep-power-in-suspend; disable-wp; + //sd-uhs-sdr50; // required to be enabled, otherwise the device gets + // detected, but there is no communication status = "okay"; @@ -896,9 +883,6 @@ status = "okay"; }; - //sd-uhs-sdr104; // required to be disabled, otherwise the device get - // detected, but there is no communication - }; &spi0 { @@ -1053,11 +1037,26 @@ &i2s { #sound-dai-cells = <0>; status = "okay"; + i2s_port: port { + i2s_ep: endpoint { + system-clock-direction-out; + frame-master; + bitclock-master; + mclk-fs = <512>; + dai-format = "i2s"; + remote-endpoint = <&hdmi_ep>; + }; + }; }; // spdif is present on q8 device, enable it &spdif { status = "okay"; + spdif_port: port { + spdif_ep: endpoint { + remote-endpoint = <&spdif_out_ep>; + }; + }; }; /* diff --git a/patch/kernel/archive/rockchip-6.6/patches.armbian/general-rockchip-various-fixes.patch b/patch/kernel/archive/rockchip-6.6/patches.armbian/general-rockchip-various-fixes.patch index 7b442be360..64da12bfef 100644 --- a/patch/kernel/archive/rockchip-6.6/patches.armbian/general-rockchip-various-fixes.patch +++ b/patch/kernel/archive/rockchip-6.6/patches.armbian/general-rockchip-various-fixes.patch @@ -32,7 +32,7 @@ index 75af99c76..c50b2ccd7 100644 + hdmi_sound: hdmi-sound { + compatible = "simple-audio-card"; -+ simple-audio-card,name = "hdmi-sound"; ++ simple-audio-card,name = "HDMI"; + simple-audio-card,format = "i2s"; + simple-audio-card,mclk-fs = <256>; + status = "disabled";