mirror of
https://github.com/armbian/build
synced 2025-09-24 19:47:06 +07:00
98 lines
3.1 KiB
Diff
98 lines
3.1 KiB
Diff
From 7722e6175facbc15e6f9dfb1fc21f7f21a09d1c6 Mon Sep 17 00:00:00 2001
|
|
From: Teguh Sobirin <teguh@sobir.in>
|
|
Date: Fri, 21 Feb 2025 20:13:47 +0800
|
|
Subject: [PATCH] ASoC: qcom: sc8280xp Add support for Primary I2S
|
|
|
|
Signed-off-by: Teguh Sobirin <teguh@sobir.in>
|
|
---
|
|
sound/soc/qcom/sc8280xp.c | 38 +++++++++++++++++++++++++++++++++++++-
|
|
1 file changed, 37 insertions(+), 1 deletion(-)
|
|
|
|
diff --git a/sound/soc/qcom/sc8280xp.c b/sound/soc/qcom/sc8280xp.c
|
|
index 311377317176..f86f3ef42180 100644
|
|
--- a/sound/soc/qcom/sc8280xp.c
|
|
+++ b/sound/soc/qcom/sc8280xp.c
|
|
@@ -2,6 +2,7 @@
|
|
// Copyright (c) 2022, Linaro Limited
|
|
|
|
#include <dt-bindings/sound/qcom,q6afe.h>
|
|
+#include <linux/clk.h>
|
|
#include <linux/module.h>
|
|
#include <linux/platform_device.h>
|
|
#include <sound/soc.h>
|
|
@@ -20,6 +21,7 @@ struct sc8280xp_snd_data {
|
|
struct sdw_stream_runtime *sruntime[AFE_PORT_MAX];
|
|
struct snd_soc_jack jack;
|
|
struct snd_soc_jack dp_jack[8];
|
|
+ struct clk *i2s_clk;
|
|
bool jack_setup;
|
|
};
|
|
|
|
@@ -63,6 +65,28 @@ static int sc8280xp_snd_init(struct snd_soc_pcm_runtime *rtd)
|
|
return qcom_snd_wcd_jack_setup(rtd, &data->jack, &data->jack_setup);
|
|
}
|
|
|
|
+static int sc8280xp_snd_startup(struct snd_pcm_substream *substream)
|
|
+{
|
|
+ unsigned int fmt = SND_SOC_DAIFMT_BP_FP;
|
|
+ unsigned int codec_dai_fmt = SND_SOC_DAIFMT_BC_FC | SND_SOC_DAIFMT_NB_NF | SND_SOC_DAIFMT_I2S;
|
|
+ struct snd_soc_pcm_runtime *rtd = substream->private_data;
|
|
+ struct sc8280xp_snd_data *pdata = snd_soc_card_get_drvdata(rtd->card);
|
|
+ struct snd_soc_dai *cpu_dai = snd_soc_rtd_to_cpu(rtd, 0);
|
|
+ struct snd_soc_dai *codec_dai = snd_soc_rtd_to_codec(rtd, 0);
|
|
+
|
|
+ switch (cpu_dai->id) {
|
|
+ case PRIMARY_MI2S_RX:
|
|
+ clk_prepare_enable(pdata->i2s_clk);
|
|
+ snd_soc_dai_set_fmt(cpu_dai, fmt);
|
|
+ snd_soc_dai_set_fmt(codec_dai, codec_dai_fmt);
|
|
+ break;
|
|
+ default:
|
|
+ break;
|
|
+ }
|
|
+
|
|
+ return qcom_snd_sdw_startup(substream);
|
|
+}
|
|
+
|
|
static void sc8280xp_snd_shutdown(struct snd_pcm_substream *substream)
|
|
{
|
|
struct snd_soc_pcm_runtime *rtd = snd_soc_substream_to_rtd(substream);
|
|
@@ -70,6 +94,14 @@ static void sc8280xp_snd_shutdown(struct snd_pcm_substream *substream)
|
|
struct sc8280xp_snd_data *pdata = snd_soc_card_get_drvdata(rtd->card);
|
|
struct sdw_stream_runtime *sruntime = pdata->sruntime[cpu_dai->id];
|
|
|
|
+ switch (cpu_dai->id) {
|
|
+ case PRIMARY_MI2S_RX:
|
|
+ clk_disable_unprepare(pdata->i2s_clk);
|
|
+ break;
|
|
+ default:
|
|
+ break;
|
|
+ }
|
|
+
|
|
pdata->sruntime[cpu_dai->id] = NULL;
|
|
sdw_release_stream(sruntime);
|
|
}
|
|
@@ -134,7 +166,7 @@ static int sc8280xp_snd_hw_free(struct snd_pcm_substream *substream)
|
|
}
|
|
|
|
static const struct snd_soc_ops sc8280xp_be_ops = {
|
|
- .startup = qcom_snd_sdw_startup,
|
|
+ .startup = sc8280xp_snd_startup,
|
|
.shutdown = sc8280xp_snd_shutdown,
|
|
.hw_params = sc8280xp_snd_hw_params,
|
|
.hw_free = sc8280xp_snd_hw_free,
|
|
@@ -178,6 +210,10 @@ static int sc8280xp_platform_probe(struct platform_device *pdev)
|
|
if (ret)
|
|
return ret;
|
|
|
|
+ data->i2s_clk = devm_clk_get_optional(dev, "i2s_clk");
|
|
+ if (IS_ERR(data->i2s_clk))
|
|
+ return dev_err_probe(dev, PTR_ERR(data->i2s_clk), "unable to get i2s clock\n");
|
|
+
|
|
card->driver_name = of_device_get_match_data(dev);
|
|
sc8280xp_add_be_ops(card);
|
|
return devm_snd_soc_register_card(dev, card);
|
|
--
|
|
2.34.1
|
|
|