[PATCH v2 0/5] Add DisplayPort sound support for Fairphone 5 smartphone

Add the necessary sound card bits and some dts additions to enable sound over DisplayPort-over-USB-C, e.g. to a connected TV or monitor.
The UCM files can be found here: https://gitlab.postmarketos.org/postmarketOS/pmaports/-/tree/master/device/t...
This series - in spirit - depends on the series enabling DisplayPort in the first place, but can land pretty independently, especially the ASoC bits: https://lore.kernel.org/linux-arm-msm/20250312-fp5-pmic-glink-dp-v2-0-a55927...
Signed-off-by: Luca Weiss luca.weiss@fairphone.com --- Changes in v2: - Revamp series based on comments on v1, doesn't have much too much in common anymore - Use sm8250 instead of sc8280xp sndcard file, so port other required changes from sc8280xp.c to sm8250.c - This also changes the sound card compatible to from qcom,qcm6490-sndcard to fairphone,fp5-sndcard - Link to v1: https://lore.kernel.org/r/20240809-fp5-dp-sound-v1-0-d7ba2c24f6b9@fairphone....
--- Luca Weiss (5): ASoC: dt-bindings: qcom,sm8250: Add Fairphone 5 sound card ASoC: qcom: sm8250: set card driver name from match data ASoC: qcom: sm8250: add DisplayPort Jack support ASoC: qcom: sm8250: Add Fairphone 5 soundcard compatible arm64: dts: qcom: qcm6490-fairphone-fp5: Add DisplayPort sound support
.../devicetree/bindings/sound/qcom,sm8250.yaml | 1 + arch/arm64/boot/dts/qcom/qcm6490-fairphone-fp5.dts | 31 ++++++++++++++++++++++ sound/soc/qcom/sm8250.c | 28 +++++++++++-------- 3 files changed, 49 insertions(+), 11 deletions(-) --- base-commit: 7f1dd4e6634d085f3c9652d4e0f1903659fb96f9 change-id: 20240809-fp5-dp-sound-b3768f3019bd
Best regards,

Document the bindings for the sound card on Fairphone 5 which uses the older non-audioreach audio architecture.
Signed-off-by: Luca Weiss luca.weiss@fairphone.com --- Documentation/devicetree/bindings/sound/qcom,sm8250.yaml | 1 + 1 file changed, 1 insertion(+)
diff --git a/Documentation/devicetree/bindings/sound/qcom,sm8250.yaml b/Documentation/devicetree/bindings/sound/qcom,sm8250.yaml index 4e208cb7f6c61adfd4b687227038d275f849480a..57f62a228c262f38e703816efdcf443355052619 100644 --- a/Documentation/devicetree/bindings/sound/qcom,sm8250.yaml +++ b/Documentation/devicetree/bindings/sound/qcom,sm8250.yaml @@ -28,6 +28,7 @@ properties: - qcom,sm8750-sndcard - const: qcom,sm8450-sndcard - enum: + - fairphone,fp5-sndcard - qcom,apq8096-sndcard - qcom,qcm6490-idp-sndcard - qcom,qcs6490-rb3gen2-sndcard

On Fri, 18 Apr 2025 15:13:42 +0200, Luca Weiss wrote:
Document the bindings for the sound card on Fairphone 5 which uses the older non-audioreach audio architecture.
Signed-off-by: Luca Weiss luca.weiss@fairphone.com
Documentation/devicetree/bindings/sound/qcom,sm8250.yaml | 1 + 1 file changed, 1 insertion(+)
Acked-by: Rob Herring (Arm) robh@kernel.org

Sound machine drivers for Qualcomm SoCs can be reused across multiple SoCs. But user space ALSA UCM files depend on the card driver name which should be set per board/SoC.
Allow such customization by using driver match data as sound card driver name.
Also while we're already touching these lines, sort the compatibles alphabetically.
Signed-off-by: Luca Weiss luca.weiss@fairphone.com --- sound/soc/qcom/sm8250.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-)
diff --git a/sound/soc/qcom/sm8250.c b/sound/soc/qcom/sm8250.c index b70b2a5031dfbf69024666f8a1049c263efcde0a..e920b413b762c803cfcc4049f35deba828275478 100644 --- a/sound/soc/qcom/sm8250.c +++ b/sound/soc/qcom/sm8250.c @@ -16,7 +16,6 @@ #include "usb_offload_utils.h" #include "sdw.h"
-#define DRIVER_NAME "sm8250" #define MI2S_BCLK_RATE 1536000
struct sm8250_snd_data { @@ -200,15 +199,15 @@ static int sm8250_platform_probe(struct platform_device *pdev) if (ret) return ret;
- card->driver_name = DRIVER_NAME; + card->driver_name = of_device_get_match_data(dev); sm8250_add_be_ops(card); return devm_snd_soc_register_card(dev, card); }
static const struct of_device_id snd_sm8250_dt_match[] = { - {.compatible = "qcom,sm8250-sndcard"}, - {.compatible = "qcom,qrb4210-rb2-sndcard"}, - {.compatible = "qcom,qrb5165-rb5-sndcard"}, + { .compatible = "qcom,qrb4210-rb2-sndcard", .data = "sm8250" }, + { .compatible = "qcom,qrb5165-rb5-sndcard", .data = "sm8250" }, + { .compatible = "qcom,sm8250-sndcard", .data = "sm8250" }, {} };

On 18/04/2025 15:13, Luca Weiss wrote:
Sound machine drivers for Qualcomm SoCs can be reused across multiple SoCs. But user space ALSA UCM files depend on the card driver name which should be set per board/SoC.
Allow such customization by using driver match data as sound card driver name.
Also while we're already touching these lines, sort the compatibles alphabetically.
Signed-off-by: Luca Weiss luca.weiss@fairphone.com
sound/soc/qcom/sm8250.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-)
diff --git a/sound/soc/qcom/sm8250.c b/sound/soc/qcom/sm8250.c index b70b2a5031dfbf69024666f8a1049c263efcde0a..e920b413b762c803cfcc4049f35deba828275478 100644 --- a/sound/soc/qcom/sm8250.c +++ b/sound/soc/qcom/sm8250.c @@ -16,7 +16,6 @@ #include "usb_offload_utils.h" #include "sdw.h"
-#define DRIVER_NAME "sm8250" #define MI2S_BCLK_RATE 1536000
struct sm8250_snd_data { @@ -200,15 +199,15 @@ static int sm8250_platform_probe(struct platform_device *pdev) if (ret) return ret;
- card->driver_name = DRIVER_NAME;
card->driver_name = of_device_get_match_data(dev); sm8250_add_be_ops(card); return devm_snd_soc_register_card(dev, card); }
static const struct of_device_id snd_sm8250_dt_match[] = {
- {.compatible = "qcom,sm8250-sndcard"},
- {.compatible = "qcom,qrb4210-rb2-sndcard"},
- {.compatible = "qcom,qrb5165-rb5-sndcard"},
- { .compatible = "qcom,qrb4210-rb2-sndcard", .data = "sm8250" },
- { .compatible = "qcom,qrb5165-rb5-sndcard", .data = "sm8250" },
- { .compatible = "qcom,sm8250-sndcard", .data = "sm8250" }, {} };
Thanks :-)
Reviewed-by: Neil Armstrong neil.armstrong@linaro.org

On Fri, Apr 18, 2025 at 03:13:43PM +0200, Luca Weiss wrote:
Sound machine drivers for Qualcomm SoCs can be reused across multiple SoCs. But user space ALSA UCM files depend on the card driver name which should be set per board/SoC.
Allow such customization by using driver match data as sound card driver name.
Also while we're already touching these lines, sort the compatibles alphabetically.
Signed-off-by: Luca Weiss luca.weiss@fairphone.com
sound/soc/qcom/sm8250.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-)
Reviewed-by: Dmitry Baryshkov dmitry.baryshkov@oss.qualcomm.com

Add support for DisplayPort Jack events, so that user space can configure the audio routing correctly.
Signed-off-by: Luca Weiss luca.weiss@fairphone.com --- sound/soc/qcom/sm8250.c | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-)
diff --git a/sound/soc/qcom/sm8250.c b/sound/soc/qcom/sm8250.c index e920b413b762c803cfcc4049f35deba828275478..aa3b4bc3fcc7b8a8dccc75ef1309bb26a2a8105a 100644 --- a/sound/soc/qcom/sm8250.c +++ b/sound/soc/qcom/sm8250.c @@ -25,6 +25,7 @@ struct sm8250_snd_data { struct snd_soc_jack jack; struct snd_soc_jack usb_offload_jack; bool usb_offload_jack_setup; + struct snd_soc_jack dp_jack; bool jack_setup; };
@@ -34,12 +35,17 @@ static int sm8250_snd_init(struct snd_soc_pcm_runtime *rtd) struct snd_soc_dai *cpu_dai = snd_soc_rtd_to_cpu(rtd, 0); int ret;
- if (cpu_dai->id == USB_RX) - ret = qcom_snd_usb_offload_jack_setup(rtd, &data->usb_offload_jack, - &data->usb_offload_jack_setup); - else - ret = qcom_snd_wcd_jack_setup(rtd, &data->jack, &data->jack_setup); - return ret; + switch (cpu_dai->id) { + case DISPLAY_PORT_RX: + return qcom_snd_dp_jack_setup(rtd, &data->dp_jack, 0); + case USB_RX: + return qcom_snd_usb_offload_jack_setup(rtd, &data->usb_offload_jack, + &data->usb_offload_jack_setup); + default: + break; + } + + return qcom_snd_wcd_jack_setup(rtd, &data->jack, &data->jack_setup); }
static void sm8250_snd_exit(struct snd_soc_pcm_runtime *rtd)

On Fri, Apr 18, 2025 at 03:13:44PM +0200, Luca Weiss wrote:
Add support for DisplayPort Jack events, so that user space can configure the audio routing correctly.
Signed-off-by: Luca Weiss luca.weiss@fairphone.com
sound/soc/qcom/sm8250.c | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-)
diff --git a/sound/soc/qcom/sm8250.c b/sound/soc/qcom/sm8250.c index e920b413b762c803cfcc4049f35deba828275478..aa3b4bc3fcc7b8a8dccc75ef1309bb26a2a8105a 100644 --- a/sound/soc/qcom/sm8250.c +++ b/sound/soc/qcom/sm8250.c @@ -25,6 +25,7 @@ struct sm8250_snd_data { struct snd_soc_jack jack; struct snd_soc_jack usb_offload_jack; bool usb_offload_jack_setup;
- struct snd_soc_jack dp_jack; bool jack_setup;
};
@@ -34,12 +35,17 @@ static int sm8250_snd_init(struct snd_soc_pcm_runtime *rtd) struct snd_soc_dai *cpu_dai = snd_soc_rtd_to_cpu(rtd, 0); int ret;
- if (cpu_dai->id == USB_RX)
ret = qcom_snd_usb_offload_jack_setup(rtd, &data->usb_offload_jack,
&data->usb_offload_jack_setup);
- else
ret = qcom_snd_wcd_jack_setup(rtd, &data->jack, &data->jack_setup);
- return ret;
- switch (cpu_dai->id) {
- case DISPLAY_PORT_RX:
return qcom_snd_dp_jack_setup(rtd, &data->dp_jack, 0);
- case USB_RX:
return qcom_snd_usb_offload_jack_setup(rtd, &data->usb_offload_jack,
&data->usb_offload_jack_setup);
- default:
break;
I'd say, just move return qcom_snd_wcd_jack_setup here.
- }
- return qcom_snd_wcd_jack_setup(rtd, &data->jack, &data->jack_setup);
}
static void sm8250_snd_exit(struct snd_soc_pcm_runtime *rtd)
-- 2.49.0

Add a compatible for the QCM6490-based Fairphone 5 which can use this machine driver.
As a note, QCM6490 RB3 board is using audioreach architecture while Fairphone 5 uses pre-audioreach.
Signed-off-by: Luca Weiss luca.weiss@fairphone.com --- sound/soc/qcom/sm8250.c | 1 + 1 file changed, 1 insertion(+)
diff --git a/sound/soc/qcom/sm8250.c b/sound/soc/qcom/sm8250.c index aa3b4bc3fcc7b8a8dccc75ef1309bb26a2a8105a..ec5372e18a9c9bc6a80412adcc5ec473e9730620 100644 --- a/sound/soc/qcom/sm8250.c +++ b/sound/soc/qcom/sm8250.c @@ -211,6 +211,7 @@ static int sm8250_platform_probe(struct platform_device *pdev) }
static const struct of_device_id snd_sm8250_dt_match[] = { + { .compatible = "fairphone,fp5-sndcard", .data = "qcm6490" }, { .compatible = "qcom,qrb4210-rb2-sndcard", .data = "sm8250" }, { .compatible = "qcom,qrb5165-rb5-sndcard", .data = "sm8250" }, { .compatible = "qcom,sm8250-sndcard", .data = "sm8250" },

On 18/04/2025 15:13, Luca Weiss wrote:
Add a compatible for the QCM6490-based Fairphone 5 which can use this machine driver.
As a note, QCM6490 RB3 board is using audioreach architecture while Fairphone 5 uses pre-audioreach.
Signed-off-by: Luca Weiss luca.weiss@fairphone.com
sound/soc/qcom/sm8250.c | 1 + 1 file changed, 1 insertion(+)
diff --git a/sound/soc/qcom/sm8250.c b/sound/soc/qcom/sm8250.c index aa3b4bc3fcc7b8a8dccc75ef1309bb26a2a8105a..ec5372e18a9c9bc6a80412adcc5ec473e9730620 100644 --- a/sound/soc/qcom/sm8250.c +++ b/sound/soc/qcom/sm8250.c @@ -211,6 +211,7 @@ static int sm8250_platform_probe(struct platform_device *pdev) }
static const struct of_device_id snd_sm8250_dt_match[] = {
- { .compatible = "fairphone,fp5-sndcard", .data = "qcm6490" }, { .compatible = "qcom,qrb4210-rb2-sndcard", .data = "sm8250" }, { .compatible = "qcom,qrb5165-rb5-sndcard", .data = "sm8250" }, { .compatible = "qcom,sm8250-sndcard", .data = "sm8250" },
Reviewed-by: Neil Armstrong neil.armstrong@linaro.org

On Fri, Apr 18, 2025 at 03:13:45PM +0200, Luca Weiss wrote:
Add a compatible for the QCM6490-based Fairphone 5 which can use this machine driver.
As a note, QCM6490 RB3 board is using audioreach architecture while Fairphone 5 uses pre-audioreach.
Signed-off-by: Luca Weiss luca.weiss@fairphone.com
sound/soc/qcom/sm8250.c | 1 + 1 file changed, 1 insertion(+)
Reviewed-by: Dmitry Baryshkov dmitry.baryshkov@oss.qualcomm.com

Add the required nodes for sound playback via a connected external display (DisplayPort over USB-C).
In user space just the following route needs to be set (e.g. using ALSA UCM):
amixer -c0 cset name='DISPLAY_PORT_RX Audio Mixer MultiMedia1' 1
Afterwards one can play audio on the MultiMedia1 sound device, e.g.:
aplay -D plughw:0,0 test.wav
Signed-off-by: Luca Weiss luca.weiss@fairphone.com --- arch/arm64/boot/dts/qcom/qcm6490-fairphone-fp5.dts | 31 ++++++++++++++++++++++ 1 file changed, 31 insertions(+)
diff --git a/arch/arm64/boot/dts/qcom/qcm6490-fairphone-fp5.dts b/arch/arm64/boot/dts/qcom/qcm6490-fairphone-fp5.dts index 9e8f9fb57c4723a24704a8239a86c6081910916b..e115b6a52b299ef663ccfb614785f8f89091f39d 100644 --- a/arch/arm64/boot/dts/qcom/qcm6490-fairphone-fp5.dts +++ b/arch/arm64/boot/dts/qcom/qcm6490-fairphone-fp5.dts @@ -14,6 +14,8 @@ #include <dt-bindings/leds/common.h> #include <dt-bindings/pinctrl/qcom,pmic-gpio.h> #include <dt-bindings/regulator/qcom,rpmh-regulator.h> +#include <dt-bindings/sound/qcom,q6asm.h> +#include <dt-bindings/sound/qcom,q6dsp-lpass-ports.h> #include "sc7280.dtsi" #include "pm7250b.dtsi" #include "pm7325.dtsi" @@ -1147,6 +1149,35 @@ &sdhc_2 { status = "okay"; };
+&sound { + compatible = "fairphone,fp5-sndcard"; + model = "Fairphone 5"; + + mm1-dai-link { + link-name = "MultiMedia1"; + + cpu { + sound-dai = <&q6asmdai MSM_FRONTEND_DAI_MULTIMEDIA1>; + }; + }; + + displayport-rx-dai-link { + link-name = "DisplayPort Playback"; + + codec { + sound-dai = <&mdss_dp>; + }; + + cpu { + sound-dai = <&q6afedai DISPLAY_PORT_RX>; + }; + + platform { + sound-dai = <&q6routing>; + }; + }; +}; + &spi13 { status = "okay";

On Fri, Apr 18, 2025 at 03:13:46PM +0200, Luca Weiss wrote:
Add the required nodes for sound playback via a connected external display (DisplayPort over USB-C).
In user space just the following route needs to be set (e.g. using ALSA UCM):
amixer -c0 cset name='DISPLAY_PORT_RX Audio Mixer MultiMedia1' 1
Afterwards one can play audio on the MultiMedia1 sound device, e.g.:
aplay -D plughw:0,0 test.wav
Signed-off-by: Luca Weiss luca.weiss@fairphone.com
arch/arm64/boot/dts/qcom/qcm6490-fairphone-fp5.dts | 31 ++++++++++++++++++++++ 1 file changed, 31 insertions(+)
Reviewed-by: Dmitry Baryshkov dmitry.baryshkov@oss.qualcomm.com
participants (4)
-
Dmitry Baryshkov
-
Luca Weiss
-
neil.armstrong@linaro.org
-
Rob Herring (Arm)