* [PATCH 0/2] sc7180: Add qdsp baked soundcard
@ 2023-10-20 15:33 Nikita Travkin
2023-10-20 15:33 ` [PATCH 1/2] ASoC: dt-bindings: qcom,sm8250: Add sc7180-qdsp6-sndcard Nikita Travkin
` (3 more replies)
0 siblings, 4 replies; 8+ messages in thread
From: Nikita Travkin @ 2023-10-20 15:33 UTC (permalink / raw)
To: Andy Gross, Bjorn Andersson, Konrad Dybcio, Srinivas Kandagatla,
Banajit Goswami, Liam Girdwood, Mark Brown, Rob Herring,
Krzysztof Kozlowski, Conor Dooley, Jaroslav Kysela, Takashi Iwai
Cc: jenneron, linux-arm-msm, alsa-devel, linux-sound, devicetree,
linux-kernel, Nikita Travkin
Some devices, such as Acer Aspire 1, can't use lpass dirrectly, but
instead must use adsp core to play sound. Since otherwise the hardware
is, usually, very similar across the devices on the same platform, it
makes sense to reuse the same boardfile.
This series refactors the sc7180.c slightly and adds the functions to
control clocks via adsp instead of controlling the hardware directly.
Existing google devices should experience no change.
Signed-off-by: Nikita Travkin <nikita@trvn.ru>
---
Nikita Travkin (2):
ASoC: dt-bindings: qcom,sm8250: Add sc7180-qdsp6-sndcard
ASoC: qcom: sc7180: Add support for qdsp6 baked sound
.../devicetree/bindings/sound/qcom,sm8250.yaml | 1 +
sound/soc/qcom/sc7180.c | 195 ++++++++++++++++++---
2 files changed, 174 insertions(+), 22 deletions(-)
---
base-commit: 2030579113a1b1b5bfd7ff24c0852847836d8fd1
change-id: 20231020-sc7180-qdsp-sndcard-e8067017eb4c
Best regards,
--
Nikita Travkin <nikita@trvn.ru>
^ permalink raw reply [flat|nested] 8+ messages in thread* [PATCH 1/2] ASoC: dt-bindings: qcom,sm8250: Add sc7180-qdsp6-sndcard 2023-10-20 15:33 [PATCH 0/2] sc7180: Add qdsp baked soundcard Nikita Travkin @ 2023-10-20 15:33 ` Nikita Travkin 2023-10-22 10:00 ` Conor Dooley 2023-10-20 15:33 ` [PATCH 2/2] ASoC: qcom: sc7180: Add support for qdsp6 baked sound Nikita Travkin ` (2 subsequent siblings) 3 siblings, 1 reply; 8+ messages in thread From: Nikita Travkin @ 2023-10-20 15:33 UTC (permalink / raw) To: Andy Gross, Bjorn Andersson, Konrad Dybcio, Srinivas Kandagatla, Banajit Goswami, Liam Girdwood, Mark Brown, Rob Herring, Krzysztof Kozlowski, Conor Dooley, Jaroslav Kysela, Takashi Iwai Cc: jenneron, linux-arm-msm, alsa-devel, linux-sound, devicetree, linux-kernel, Nikita Travkin sc7180 can make use of the adsp-baked soundcard, add relevant compatible to the documentation. Signed-off-by: Nikita Travkin <nikita@trvn.ru> --- 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 262de7a60a73..e082a4fe095d 100644 --- a/Documentation/devicetree/bindings/sound/qcom,sm8250.yaml +++ b/Documentation/devicetree/bindings/sound/qcom,sm8250.yaml @@ -25,6 +25,7 @@ properties: - qcom,apq8016-sbc-sndcard - qcom,msm8916-qdsp6-sndcard - qcom,qrb5165-rb5-sndcard + - qcom,sc7180-qdsp6-sndcard - qcom,sc8280xp-sndcard - qcom,sdm845-sndcard - qcom,sm8250-sndcard -- 2.41.0 ^ permalink raw reply related [flat|nested] 8+ messages in thread
* Re: [PATCH 1/2] ASoC: dt-bindings: qcom,sm8250: Add sc7180-qdsp6-sndcard 2023-10-20 15:33 ` [PATCH 1/2] ASoC: dt-bindings: qcom,sm8250: Add sc7180-qdsp6-sndcard Nikita Travkin @ 2023-10-22 10:00 ` Conor Dooley 0 siblings, 0 replies; 8+ messages in thread From: Conor Dooley @ 2023-10-22 10:00 UTC (permalink / raw) To: Nikita Travkin Cc: Andy Gross, Bjorn Andersson, Konrad Dybcio, Srinivas Kandagatla, Banajit Goswami, Liam Girdwood, Mark Brown, Rob Herring, Krzysztof Kozlowski, Conor Dooley, Jaroslav Kysela, Takashi Iwai, jenneron, linux-arm-msm, alsa-devel, linux-sound, devicetree, linux-kernel [-- Attachment #1: Type: text/plain, Size: 1051 bytes --] On Fri, Oct 20, 2023 at 08:33:46PM +0500, Nikita Travkin wrote: > sc7180 can make use of the adsp-baked soundcard, add relevant compatible > to the documentation. > > Signed-off-by: Nikita Travkin <nikita@trvn.ru> Acked-by: Conor Dooley <conor.dooley@microchip.com> Thanks, COnor. > --- > 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 262de7a60a73..e082a4fe095d 100644 > --- a/Documentation/devicetree/bindings/sound/qcom,sm8250.yaml > +++ b/Documentation/devicetree/bindings/sound/qcom,sm8250.yaml > @@ -25,6 +25,7 @@ properties: > - qcom,apq8016-sbc-sndcard > - qcom,msm8916-qdsp6-sndcard > - qcom,qrb5165-rb5-sndcard > + - qcom,sc7180-qdsp6-sndcard > - qcom,sc8280xp-sndcard > - qcom,sdm845-sndcard > - qcom,sm8250-sndcard > > -- > 2.41.0 > [-- Attachment #2: signature.asc --] [-- Type: application/pgp-signature, Size: 228 bytes --] ^ permalink raw reply [flat|nested] 8+ messages in thread
* [PATCH 2/2] ASoC: qcom: sc7180: Add support for qdsp6 baked sound 2023-10-20 15:33 [PATCH 0/2] sc7180: Add qdsp baked soundcard Nikita Travkin 2023-10-20 15:33 ` [PATCH 1/2] ASoC: dt-bindings: qcom,sm8250: Add sc7180-qdsp6-sndcard Nikita Travkin @ 2023-10-20 15:33 ` Nikita Travkin 2023-10-26 6:46 ` Anton Bambura 2023-10-21 16:17 ` [PATCH 0/2] sc7180: Add qdsp baked soundcard Konrad Dybcio 2023-10-26 17:10 ` Mark Brown 3 siblings, 1 reply; 8+ messages in thread From: Nikita Travkin @ 2023-10-20 15:33 UTC (permalink / raw) To: Andy Gross, Bjorn Andersson, Konrad Dybcio, Srinivas Kandagatla, Banajit Goswami, Liam Girdwood, Mark Brown, Rob Herring, Krzysztof Kozlowski, Conor Dooley, Jaroslav Kysela, Takashi Iwai Cc: jenneron, linux-arm-msm, alsa-devel, linux-sound, devicetree, linux-kernel, Nikita Travkin Some sc7180 devices use audio adsp to play sound. The setup for this adsp is similar to the dirrect lpass usage but requires the use of different link ids and clocks. This commit adds support for the qdsp based audio, reusing the common parts like audio codec setup and jack creation. Since the setup is mostly generic and codec specific setup is guarded behind a check, a generic compatible is added, similar to other platforms. Even though those changes target Acer Aspire 1 as the only user of the adsp audio on this platform present upstream at the moment of the commit, those changes should be either dirrectly compatible or trivially expandable to the other devices that will be added in the future. Signed-off-by: Nikita Travkin <nikita@trvn.ru> --- sound/soc/qcom/sc7180.c | 195 ++++++++++++++++++++++++++++++++++++++++++------ 1 file changed, 173 insertions(+), 22 deletions(-) diff --git a/sound/soc/qcom/sc7180.c b/sound/soc/qcom/sc7180.c index 8e433e309f77..b0320a74d508 100644 --- a/sound/soc/qcom/sc7180.c +++ b/sound/soc/qcom/sc7180.c @@ -5,6 +5,7 @@ // sc7180.c -- ALSA SoC Machine driver for SC7180 #include <dt-bindings/sound/sc7180-lpass.h> +#include <dt-bindings/sound/qcom,q6afe.h> #include <linux/gpio.h> #include <linux/gpio/consumer.h> #include <linux/module.h> @@ -19,8 +20,10 @@ #include "../codecs/rt5682.h" #include "../codecs/rt5682s.h" #include "common.h" +#include "qdsp6/q6afe.h" #define DEFAULT_MCLK_RATE 19200000 +#define MI2S_BCLK_RATE 1536000 #define RT5682_PLL1_FREQ (48000 * 512) #define DRIVER_NAME "SC7180" @@ -133,12 +136,28 @@ static int sc7180_init(struct snd_soc_pcm_runtime *rtd) return 0; } -static int sc7180_snd_startup(struct snd_pcm_substream *substream) +static int sc7180_qdsp_init(struct snd_soc_pcm_runtime *rtd) { - struct snd_soc_pcm_runtime *rtd = substream->private_data; - struct snd_soc_card *card = rtd->card; - struct sc7180_snd_data *data = snd_soc_card_get_drvdata(card); struct snd_soc_dai *cpu_dai = snd_soc_rtd_to_cpu(rtd, 0); + + switch (cpu_dai->id) { + case PRIMARY_MI2S_RX: + return sc7180_headset_init(rtd); + case PRIMARY_MI2S_TX: + case TERTIARY_MI2S_RX: + return 0; + case DISPLAY_PORT_RX: + return sc7180_hdmi_init(rtd); + default: + dev_err(rtd->dev, "%s: invalid dai id 0x%x\n", __func__, + cpu_dai->id); + return -EINVAL; + } + return 0; +} + +static int sc7180_startup_realtek_codec(struct snd_soc_pcm_runtime *rtd) +{ struct snd_soc_dai *codec_dai = snd_soc_rtd_to_codec(rtd, 0); int pll_id, pll_source, pll_in, pll_out, clk_id, ret; @@ -154,8 +173,40 @@ static int sc7180_snd_startup(struct snd_pcm_substream *substream) clk_id = RT5682S_SCLK_S_PLL2; pll_out = RT5682_PLL1_FREQ; pll_in = DEFAULT_MCLK_RATE; + } else { + return 0; + } + snd_soc_dai_set_fmt(codec_dai, + SND_SOC_DAIFMT_BC_FC | + SND_SOC_DAIFMT_NB_NF | + SND_SOC_DAIFMT_I2S); + + /* Configure PLL1 for codec */ + ret = snd_soc_dai_set_pll(codec_dai, pll_id, pll_source, + pll_in, pll_out); + if (ret) { + dev_err(rtd->dev, "can't set codec pll: %d\n", ret); + return ret; } + /* Configure sysclk for codec */ + ret = snd_soc_dai_set_sysclk(codec_dai, clk_id, pll_out, + SND_SOC_CLOCK_IN); + if (ret) + dev_err(rtd->dev, "snd_soc_dai_set_sysclk err = %d\n", + ret); + + return ret; +} + +static int sc7180_snd_startup(struct snd_pcm_substream *substream) +{ + struct snd_soc_pcm_runtime *rtd = substream->private_data; + struct snd_soc_card *card = rtd->card; + struct sc7180_snd_data *data = snd_soc_card_get_drvdata(card); + struct snd_soc_dai *cpu_dai = snd_soc_rtd_to_cpu(rtd, 0); + int ret; + switch (cpu_dai->id) { case MI2S_PRIMARY: if (++data->pri_mi2s_clk_count == 1) { @@ -165,30 +216,66 @@ static int sc7180_snd_startup(struct snd_pcm_substream *substream) SNDRV_PCM_STREAM_PLAYBACK); } - snd_soc_dai_set_fmt(codec_dai, - SND_SOC_DAIFMT_BC_FC | - SND_SOC_DAIFMT_NB_NF | - SND_SOC_DAIFMT_I2S); - - /* Configure PLL1 for codec */ - ret = snd_soc_dai_set_pll(codec_dai, pll_id, pll_source, - pll_in, pll_out); - if (ret) { - dev_err(rtd->dev, "can't set codec pll: %d\n", ret); + ret = sc7180_startup_realtek_codec(rtd); + if (ret) return ret; + + break; + case MI2S_SECONDARY: + break; + case LPASS_DP_RX: + break; + default: + dev_err(rtd->dev, "%s: invalid dai id 0x%x\n", __func__, + cpu_dai->id); + return -EINVAL; + } + return 0; +} + +static int sc7180_qdsp_snd_startup(struct snd_pcm_substream *substream) +{ + struct snd_soc_pcm_runtime *rtd = substream->private_data; + struct snd_soc_card *card = rtd->card; + struct sc7180_snd_data *data = snd_soc_card_get_drvdata(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); + int ret; + + switch (cpu_dai->id) { + case PRIMARY_MI2S_RX: + case PRIMARY_MI2S_TX: + if (++data->pri_mi2s_clk_count == 1) { + snd_soc_dai_set_sysclk(cpu_dai, + Q6AFE_LPASS_CLK_ID_MCLK_1, + DEFAULT_MCLK_RATE, + SNDRV_PCM_STREAM_PLAYBACK); + snd_soc_dai_set_sysclk(cpu_dai, + Q6AFE_LPASS_CLK_ID_PRI_MI2S_IBIT, + MI2S_BCLK_RATE, + SNDRV_PCM_STREAM_PLAYBACK); } - /* Configure sysclk for codec */ - ret = snd_soc_dai_set_sysclk(codec_dai, clk_id, pll_out, - SND_SOC_CLOCK_IN); + snd_soc_dai_set_fmt(cpu_dai, SND_SOC_DAIFMT_BP_FP); + + ret = sc7180_startup_realtek_codec(rtd); if (ret) - dev_err(rtd->dev, "snd_soc_dai_set_sysclk err = %d\n", - ret); + return ret; break; - case MI2S_SECONDARY: + case TERTIARY_MI2S_RX: + snd_soc_dai_set_sysclk(cpu_dai, + Q6AFE_LPASS_CLK_ID_TER_MI2S_IBIT, + MI2S_BCLK_RATE, + SNDRV_PCM_STREAM_PLAYBACK); + + snd_soc_dai_set_fmt(codec_dai, + SND_SOC_DAIFMT_BC_FC | + SND_SOC_DAIFMT_NB_NF | + SND_SOC_DAIFMT_I2S); + snd_soc_dai_set_fmt(cpu_dai, SND_SOC_DAIFMT_BP_FP); break; - case LPASS_DP_RX: + case DISPLAY_PORT_RX: break; default: dev_err(rtd->dev, "%s: invalid dai id 0x%x\n", __func__, @@ -246,6 +333,42 @@ static void sc7180_snd_shutdown(struct snd_pcm_substream *substream) } } +static void sc7180_qdsp_snd_shutdown(struct snd_pcm_substream *substream) +{ + struct snd_soc_pcm_runtime *rtd = substream->private_data; + struct snd_soc_card *card = rtd->card; + struct sc7180_snd_data *data = snd_soc_card_get_drvdata(card); + struct snd_soc_dai *cpu_dai = snd_soc_rtd_to_cpu(rtd, 0); + + switch (cpu_dai->id) { + case PRIMARY_MI2S_RX: + case PRIMARY_MI2S_TX: + if (--data->pri_mi2s_clk_count == 0) { + snd_soc_dai_set_sysclk(cpu_dai, + Q6AFE_LPASS_CLK_ID_MCLK_1, + 0, + SNDRV_PCM_STREAM_PLAYBACK); + snd_soc_dai_set_sysclk(cpu_dai, + Q6AFE_LPASS_CLK_ID_PRI_MI2S_IBIT, + 0, + SNDRV_PCM_STREAM_PLAYBACK); + } + break; + case TERTIARY_MI2S_RX: + snd_soc_dai_set_sysclk(cpu_dai, + Q6AFE_LPASS_CLK_ID_TER_MI2S_IBIT, + 0, + SNDRV_PCM_STREAM_PLAYBACK); + break; + case DISPLAY_PORT_RX: + break; + default: + dev_err(rtd->dev, "%s: invalid dai id 0x%x\n", __func__, + cpu_dai->id); + break; + } +} + static int sc7180_adau7002_init(struct snd_soc_pcm_runtime *rtd) { struct snd_soc_dai *cpu_dai = snd_soc_rtd_to_cpu(rtd, 0); @@ -294,11 +417,30 @@ static int sc7180_adau7002_snd_startup(struct snd_pcm_substream *substream) return 0; } +static int sc7180_qdsp_be_hw_params_fixup(struct snd_soc_pcm_runtime *rtd, + struct snd_pcm_hw_params *params) +{ + struct snd_interval *rate = hw_param_interval(params, + SNDRV_PCM_HW_PARAM_RATE); + struct snd_interval *channels = hw_param_interval(params, + SNDRV_PCM_HW_PARAM_CHANNELS); + + rate->min = rate->max = 48000; + channels->min = channels->max = 2; + + return 0; +} + static const struct snd_soc_ops sc7180_ops = { .startup = sc7180_snd_startup, .shutdown = sc7180_snd_shutdown, }; +static const struct snd_soc_ops sc7180_qdsp_ops = { + .startup = sc7180_qdsp_snd_startup, + .shutdown = sc7180_qdsp_snd_shutdown, +}; + static const struct snd_soc_ops sc7180_adau7002_ops = { .startup = sc7180_adau7002_snd_startup, }; @@ -354,7 +496,7 @@ static int sc7180_snd_platform_probe(struct platform_device *pdev) struct snd_soc_dai_link *link; int ret; int i; - bool no_headphone = false; + bool qdsp = false, no_headphone = false; /* Allocate the private data */ data = devm_kzalloc(dev, sizeof(*data), GFP_KERNEL); @@ -390,6 +532,8 @@ static int sc7180_snd_platform_probe(struct platform_device *pdev) no_headphone = true; card->dapm_widgets = sc7180_adau7002_snd_widgets; card->num_dapm_widgets = ARRAY_SIZE(sc7180_adau7002_snd_widgets); + } else if (of_device_is_compatible(dev->of_node, "qcom,sc7180-qdsp6-sndcard")) { + qdsp = true; } ret = qcom_snd_parse_of(card); @@ -400,6 +544,12 @@ static int sc7180_snd_platform_probe(struct platform_device *pdev) if (no_headphone) { link->ops = &sc7180_adau7002_ops; link->init = sc7180_adau7002_init; + } else if (qdsp) { + if (link->no_pcm == 1) { + link->ops = &sc7180_qdsp_ops; + link->be_hw_params_fixup = sc7180_qdsp_be_hw_params_fixup; + link->init = sc7180_qdsp_init; + } } else { link->ops = &sc7180_ops; link->init = sc7180_init; @@ -412,6 +562,7 @@ static int sc7180_snd_platform_probe(struct platform_device *pdev) static const struct of_device_id sc7180_snd_device_id[] = { {.compatible = "google,sc7180-trogdor"}, {.compatible = "google,sc7180-coachz"}, + {.compatible = "qcom,sc7180-qdsp6-sndcard"}, {}, }; MODULE_DEVICE_TABLE(of, sc7180_snd_device_id); -- 2.41.0 ^ permalink raw reply related [flat|nested] 8+ messages in thread
* Re: [PATCH 2/2] ASoC: qcom: sc7180: Add support for qdsp6 baked sound 2023-10-20 15:33 ` [PATCH 2/2] ASoC: qcom: sc7180: Add support for qdsp6 baked sound Nikita Travkin @ 2023-10-26 6:46 ` Anton Bambura 0 siblings, 0 replies; 8+ messages in thread From: Anton Bambura @ 2023-10-26 6:46 UTC (permalink / raw) To: Nikita Travkin, Andy Gross, Bjorn Andersson, Konrad Dybcio, Srinivas Kandagatla, Banajit Goswami, Liam Girdwood, Mark Brown, Rob Herring, Krzysztof Kozlowski, Conor Dooley, Jaroslav Kysela, Takashi Iwai Cc: linux-arm-msm, alsa-devel, linux-sound, devicetree, linux-kernel On 10/20/23 18:33, Nikita Travkin wrote: > Some sc7180 devices use audio adsp to play sound. The setup for this > adsp is similar to the dirrect lpass usage but requires the use of > different link ids and clocks. > > This commit adds support for the qdsp based audio, reusing the common > parts like audio codec setup and jack creation. > > Since the setup is mostly generic and codec specific setup is guarded > behind a check, a generic compatible is added, similar to other > platforms. Even though those changes target Acer Aspire 1 as the only > user of the adsp audio on this platform present upstream at the moment > of the commit, those changes should be either dirrectly compatible or > trivially expandable to the other devices that will be added in the > future. > > Signed-off-by: Nikita Travkin <nikita@trvn.ru> Tested that sound still works on lazor chromebook Tested-by: Anton Bambura <jenneron@postmarketos.org> > --- > sound/soc/qcom/sc7180.c | 195 ++++++++++++++++++++++++++++++++++++++++++------ > 1 file changed, 173 insertions(+), 22 deletions(-) > > diff --git a/sound/soc/qcom/sc7180.c b/sound/soc/qcom/sc7180.c > index 8e433e309f77..b0320a74d508 100644 > --- a/sound/soc/qcom/sc7180.c > +++ b/sound/soc/qcom/sc7180.c > @@ -5,6 +5,7 @@ > // sc7180.c -- ALSA SoC Machine driver for SC7180 > > #include <dt-bindings/sound/sc7180-lpass.h> > +#include <dt-bindings/sound/qcom,q6afe.h> > #include <linux/gpio.h> > #include <linux/gpio/consumer.h> > #include <linux/module.h> > @@ -19,8 +20,10 @@ > #include "../codecs/rt5682.h" > #include "../codecs/rt5682s.h" > #include "common.h" > +#include "qdsp6/q6afe.h" > > #define DEFAULT_MCLK_RATE 19200000 > +#define MI2S_BCLK_RATE 1536000 > #define RT5682_PLL1_FREQ (48000 * 512) > > #define DRIVER_NAME "SC7180" > @@ -133,12 +136,28 @@ static int sc7180_init(struct snd_soc_pcm_runtime *rtd) > return 0; > } > > -static int sc7180_snd_startup(struct snd_pcm_substream *substream) > +static int sc7180_qdsp_init(struct snd_soc_pcm_runtime *rtd) > { > - struct snd_soc_pcm_runtime *rtd = substream->private_data; > - struct snd_soc_card *card = rtd->card; > - struct sc7180_snd_data *data = snd_soc_card_get_drvdata(card); > struct snd_soc_dai *cpu_dai = snd_soc_rtd_to_cpu(rtd, 0); > + > + switch (cpu_dai->id) { > + case PRIMARY_MI2S_RX: > + return sc7180_headset_init(rtd); > + case PRIMARY_MI2S_TX: > + case TERTIARY_MI2S_RX: > + return 0; > + case DISPLAY_PORT_RX: > + return sc7180_hdmi_init(rtd); > + default: > + dev_err(rtd->dev, "%s: invalid dai id 0x%x\n", __func__, > + cpu_dai->id); > + return -EINVAL; > + } > + return 0; > +} > + > +static int sc7180_startup_realtek_codec(struct snd_soc_pcm_runtime *rtd) > +{ > struct snd_soc_dai *codec_dai = snd_soc_rtd_to_codec(rtd, 0); > int pll_id, pll_source, pll_in, pll_out, clk_id, ret; > > @@ -154,8 +173,40 @@ static int sc7180_snd_startup(struct snd_pcm_substream *substream) > clk_id = RT5682S_SCLK_S_PLL2; > pll_out = RT5682_PLL1_FREQ; > pll_in = DEFAULT_MCLK_RATE; > + } else { > + return 0; > + } > + snd_soc_dai_set_fmt(codec_dai, > + SND_SOC_DAIFMT_BC_FC | > + SND_SOC_DAIFMT_NB_NF | > + SND_SOC_DAIFMT_I2S); > + > + /* Configure PLL1 for codec */ > + ret = snd_soc_dai_set_pll(codec_dai, pll_id, pll_source, > + pll_in, pll_out); > + if (ret) { > + dev_err(rtd->dev, "can't set codec pll: %d\n", ret); > + return ret; > } > > + /* Configure sysclk for codec */ > + ret = snd_soc_dai_set_sysclk(codec_dai, clk_id, pll_out, > + SND_SOC_CLOCK_IN); > + if (ret) > + dev_err(rtd->dev, "snd_soc_dai_set_sysclk err = %d\n", > + ret); > + > + return ret; > +} > + > +static int sc7180_snd_startup(struct snd_pcm_substream *substream) > +{ > + struct snd_soc_pcm_runtime *rtd = substream->private_data; > + struct snd_soc_card *card = rtd->card; > + struct sc7180_snd_data *data = snd_soc_card_get_drvdata(card); > + struct snd_soc_dai *cpu_dai = snd_soc_rtd_to_cpu(rtd, 0); > + int ret; > + > switch (cpu_dai->id) { > case MI2S_PRIMARY: > if (++data->pri_mi2s_clk_count == 1) { > @@ -165,30 +216,66 @@ static int sc7180_snd_startup(struct snd_pcm_substream *substream) > SNDRV_PCM_STREAM_PLAYBACK); > } > > - snd_soc_dai_set_fmt(codec_dai, > - SND_SOC_DAIFMT_BC_FC | > - SND_SOC_DAIFMT_NB_NF | > - SND_SOC_DAIFMT_I2S); > - > - /* Configure PLL1 for codec */ > - ret = snd_soc_dai_set_pll(codec_dai, pll_id, pll_source, > - pll_in, pll_out); > - if (ret) { > - dev_err(rtd->dev, "can't set codec pll: %d\n", ret); > + ret = sc7180_startup_realtek_codec(rtd); > + if (ret) > return ret; > + > + break; > + case MI2S_SECONDARY: > + break; > + case LPASS_DP_RX: > + break; > + default: > + dev_err(rtd->dev, "%s: invalid dai id 0x%x\n", __func__, > + cpu_dai->id); > + return -EINVAL; > + } > + return 0; > +} > + > +static int sc7180_qdsp_snd_startup(struct snd_pcm_substream *substream) > +{ > + struct snd_soc_pcm_runtime *rtd = substream->private_data; > + struct snd_soc_card *card = rtd->card; > + struct sc7180_snd_data *data = snd_soc_card_get_drvdata(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); > + int ret; > + > + switch (cpu_dai->id) { > + case PRIMARY_MI2S_RX: > + case PRIMARY_MI2S_TX: > + if (++data->pri_mi2s_clk_count == 1) { > + snd_soc_dai_set_sysclk(cpu_dai, > + Q6AFE_LPASS_CLK_ID_MCLK_1, > + DEFAULT_MCLK_RATE, > + SNDRV_PCM_STREAM_PLAYBACK); > + snd_soc_dai_set_sysclk(cpu_dai, > + Q6AFE_LPASS_CLK_ID_PRI_MI2S_IBIT, > + MI2S_BCLK_RATE, > + SNDRV_PCM_STREAM_PLAYBACK); > } > > - /* Configure sysclk for codec */ > - ret = snd_soc_dai_set_sysclk(codec_dai, clk_id, pll_out, > - SND_SOC_CLOCK_IN); > + snd_soc_dai_set_fmt(cpu_dai, SND_SOC_DAIFMT_BP_FP); > + > + ret = sc7180_startup_realtek_codec(rtd); > if (ret) > - dev_err(rtd->dev, "snd_soc_dai_set_sysclk err = %d\n", > - ret); > + return ret; > > break; > - case MI2S_SECONDARY: > + case TERTIARY_MI2S_RX: > + snd_soc_dai_set_sysclk(cpu_dai, > + Q6AFE_LPASS_CLK_ID_TER_MI2S_IBIT, > + MI2S_BCLK_RATE, > + SNDRV_PCM_STREAM_PLAYBACK); > + > + snd_soc_dai_set_fmt(codec_dai, > + SND_SOC_DAIFMT_BC_FC | > + SND_SOC_DAIFMT_NB_NF | > + SND_SOC_DAIFMT_I2S); > + snd_soc_dai_set_fmt(cpu_dai, SND_SOC_DAIFMT_BP_FP); > break; > - case LPASS_DP_RX: > + case DISPLAY_PORT_RX: > break; > default: > dev_err(rtd->dev, "%s: invalid dai id 0x%x\n", __func__, > @@ -246,6 +333,42 @@ static void sc7180_snd_shutdown(struct snd_pcm_substream *substream) > } > } > > +static void sc7180_qdsp_snd_shutdown(struct snd_pcm_substream *substream) > +{ > + struct snd_soc_pcm_runtime *rtd = substream->private_data; > + struct snd_soc_card *card = rtd->card; > + struct sc7180_snd_data *data = snd_soc_card_get_drvdata(card); > + struct snd_soc_dai *cpu_dai = snd_soc_rtd_to_cpu(rtd, 0); > + > + switch (cpu_dai->id) { > + case PRIMARY_MI2S_RX: > + case PRIMARY_MI2S_TX: > + if (--data->pri_mi2s_clk_count == 0) { > + snd_soc_dai_set_sysclk(cpu_dai, > + Q6AFE_LPASS_CLK_ID_MCLK_1, > + 0, > + SNDRV_PCM_STREAM_PLAYBACK); > + snd_soc_dai_set_sysclk(cpu_dai, > + Q6AFE_LPASS_CLK_ID_PRI_MI2S_IBIT, > + 0, > + SNDRV_PCM_STREAM_PLAYBACK); > + } > + break; > + case TERTIARY_MI2S_RX: > + snd_soc_dai_set_sysclk(cpu_dai, > + Q6AFE_LPASS_CLK_ID_TER_MI2S_IBIT, > + 0, > + SNDRV_PCM_STREAM_PLAYBACK); > + break; > + case DISPLAY_PORT_RX: > + break; > + default: > + dev_err(rtd->dev, "%s: invalid dai id 0x%x\n", __func__, > + cpu_dai->id); > + break; > + } > +} > + > static int sc7180_adau7002_init(struct snd_soc_pcm_runtime *rtd) > { > struct snd_soc_dai *cpu_dai = snd_soc_rtd_to_cpu(rtd, 0); > @@ -294,11 +417,30 @@ static int sc7180_adau7002_snd_startup(struct snd_pcm_substream *substream) > return 0; > } > > +static int sc7180_qdsp_be_hw_params_fixup(struct snd_soc_pcm_runtime *rtd, > + struct snd_pcm_hw_params *params) > +{ > + struct snd_interval *rate = hw_param_interval(params, > + SNDRV_PCM_HW_PARAM_RATE); > + struct snd_interval *channels = hw_param_interval(params, > + SNDRV_PCM_HW_PARAM_CHANNELS); > + > + rate->min = rate->max = 48000; > + channels->min = channels->max = 2; > + > + return 0; > +} > + > static const struct snd_soc_ops sc7180_ops = { > .startup = sc7180_snd_startup, > .shutdown = sc7180_snd_shutdown, > }; > > +static const struct snd_soc_ops sc7180_qdsp_ops = { > + .startup = sc7180_qdsp_snd_startup, > + .shutdown = sc7180_qdsp_snd_shutdown, > +}; > + > static const struct snd_soc_ops sc7180_adau7002_ops = { > .startup = sc7180_adau7002_snd_startup, > }; > @@ -354,7 +496,7 @@ static int sc7180_snd_platform_probe(struct platform_device *pdev) > struct snd_soc_dai_link *link; > int ret; > int i; > - bool no_headphone = false; > + bool qdsp = false, no_headphone = false; > > /* Allocate the private data */ > data = devm_kzalloc(dev, sizeof(*data), GFP_KERNEL); > @@ -390,6 +532,8 @@ static int sc7180_snd_platform_probe(struct platform_device *pdev) > no_headphone = true; > card->dapm_widgets = sc7180_adau7002_snd_widgets; > card->num_dapm_widgets = ARRAY_SIZE(sc7180_adau7002_snd_widgets); > + } else if (of_device_is_compatible(dev->of_node, "qcom,sc7180-qdsp6-sndcard")) { > + qdsp = true; > } > > ret = qcom_snd_parse_of(card); > @@ -400,6 +544,12 @@ static int sc7180_snd_platform_probe(struct platform_device *pdev) > if (no_headphone) { > link->ops = &sc7180_adau7002_ops; > link->init = sc7180_adau7002_init; > + } else if (qdsp) { > + if (link->no_pcm == 1) { > + link->ops = &sc7180_qdsp_ops; > + link->be_hw_params_fixup = sc7180_qdsp_be_hw_params_fixup; > + link->init = sc7180_qdsp_init; > + } > } else { > link->ops = &sc7180_ops; > link->init = sc7180_init; > @@ -412,6 +562,7 @@ static int sc7180_snd_platform_probe(struct platform_device *pdev) > static const struct of_device_id sc7180_snd_device_id[] = { > {.compatible = "google,sc7180-trogdor"}, > {.compatible = "google,sc7180-coachz"}, > + {.compatible = "qcom,sc7180-qdsp6-sndcard"}, > {}, > }; > MODULE_DEVICE_TABLE(of, sc7180_snd_device_id); > ^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH 0/2] sc7180: Add qdsp baked soundcard 2023-10-20 15:33 [PATCH 0/2] sc7180: Add qdsp baked soundcard Nikita Travkin 2023-10-20 15:33 ` [PATCH 1/2] ASoC: dt-bindings: qcom,sm8250: Add sc7180-qdsp6-sndcard Nikita Travkin 2023-10-20 15:33 ` [PATCH 2/2] ASoC: qcom: sc7180: Add support for qdsp6 baked sound Nikita Travkin @ 2023-10-21 16:17 ` Konrad Dybcio 2023-10-21 16:47 ` Nikita Travkin 2023-10-26 17:10 ` Mark Brown 3 siblings, 1 reply; 8+ messages in thread From: Konrad Dybcio @ 2023-10-21 16:17 UTC (permalink / raw) To: Nikita Travkin, Andy Gross, Bjorn Andersson, Srinivas Kandagatla, Banajit Goswami, Liam Girdwood, Mark Brown, Rob Herring, Krzysztof Kozlowski, Conor Dooley, Jaroslav Kysela, Takashi Iwai Cc: jenneron, linux-arm-msm, alsa-devel, linux-sound, devicetree, linux-kernel On 10/20/23 17:33, Nikita Travkin wrote: > Some devices, such as Acer Aspire 1, can't use lpass dirrectly, but > instead must use adsp core to play sound. Since otherwise the hardware > is, usually, very similar across the devices on the same platform, it > makes sense to reuse the same boardfile. > > This series refactors the sc7180.c slightly and adds the functions to > control clocks via adsp instead of controlling the hardware directly. > > Existing google devices should experience no change. > > Signed-off-by: Nikita Travkin <nikita@trvn.ru> > --- s/baked/backed, unless it's a nice bread :) Konrad ^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH 0/2] sc7180: Add qdsp baked soundcard 2023-10-21 16:17 ` [PATCH 0/2] sc7180: Add qdsp baked soundcard Konrad Dybcio @ 2023-10-21 16:47 ` Nikita Travkin 0 siblings, 0 replies; 8+ messages in thread From: Nikita Travkin @ 2023-10-21 16:47 UTC (permalink / raw) To: Konrad Dybcio Cc: Andy Gross, Bjorn Andersson, Srinivas Kandagatla, Banajit Goswami, Liam Girdwood, Mark Brown, Rob Herring, Krzysztof Kozlowski, Conor Dooley, Jaroslav Kysela, Takashi Iwai, jenneron, linux-arm-msm, alsa-devel, linux-sound, devicetree, linux-kernel Konrad Dybcio писал(а) 21.10.2023 21:17: > On 10/20/23 17:33, Nikita Travkin wrote: >> Some devices, such as Acer Aspire 1, can't use lpass dirrectly, but >> instead must use adsp core to play sound. Since otherwise the hardware >> is, usually, very similar across the devices on the same platform, it >> makes sense to reuse the same boardfile. >> >> This series refactors the sc7180.c slightly and adds the functions to >> control clocks via adsp instead of controlling the hardware directly. >> >> Existing google devices should experience no change. >> >> Signed-off-by: Nikita Travkin <nikita@trvn.ru> >> --- > s/baked/backed, unless it's a nice bread :) At least I was consistent in failing to pick the correct word... If we get to v2, I will try to remember about those, but if not, I guess I will accept the chance, that in a couple of years I may wake up in cold sweat upon realizing that this mistake is forever immortalized in the Linux git history... Thanks for noticing this! Nikita > > Konrad ^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH 0/2] sc7180: Add qdsp baked soundcard 2023-10-20 15:33 [PATCH 0/2] sc7180: Add qdsp baked soundcard Nikita Travkin ` (2 preceding siblings ...) 2023-10-21 16:17 ` [PATCH 0/2] sc7180: Add qdsp baked soundcard Konrad Dybcio @ 2023-10-26 17:10 ` Mark Brown 3 siblings, 0 replies; 8+ messages in thread From: Mark Brown @ 2023-10-26 17:10 UTC (permalink / raw) To: Andy Gross, Bjorn Andersson, Konrad Dybcio, Srinivas Kandagatla, Banajit Goswami, Liam Girdwood, Rob Herring, Krzysztof Kozlowski, Conor Dooley, Jaroslav Kysela, Takashi Iwai, Nikita Travkin Cc: jenneron, linux-arm-msm, alsa-devel, linux-sound, devicetree, linux-kernel On Fri, 20 Oct 2023 20:33:45 +0500, Nikita Travkin wrote: > Some devices, such as Acer Aspire 1, can't use lpass dirrectly, but > instead must use adsp core to play sound. Since otherwise the hardware > is, usually, very similar across the devices on the same platform, it > makes sense to reuse the same boardfile. > > This series refactors the sc7180.c slightly and adds the functions to > control clocks via adsp instead of controlling the hardware directly. > > [...] Applied to https://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound.git for-next Thanks! [1/2] ASoC: dt-bindings: qcom,sm8250: Add sc7180-qdsp6-sndcard commit: 5443d186163c6ab0084a5b23c901e0f9ba792463 [2/2] ASoC: qcom: sc7180: Add support for qdsp6 baked sound commit: 4531f512e3ef147f07d47bceb256c0af5ab130b7 All being well this means that it will be integrated into the linux-next tree (usually sometime in the next 24 hours) and sent to Linus during the next merge window (or sooner if it is a bug fix), however if problems are discovered then the patch may be dropped or reverted. You may get further e-mails resulting from automated or manual testing and review of the tree, please engage with people reporting problems and send followup patches addressing any issues that are reported if needed. If any updates are required or you are submitting further changes they should be sent as incremental updates against current git, existing patches will not be replaced. Please add any relevant lists and maintainers to the CCs when replying to this mail. Thanks, Mark ^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2023-10-26 17:10 UTC | newest] Thread overview: 8+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2023-10-20 15:33 [PATCH 0/2] sc7180: Add qdsp baked soundcard Nikita Travkin 2023-10-20 15:33 ` [PATCH 1/2] ASoC: dt-bindings: qcom,sm8250: Add sc7180-qdsp6-sndcard Nikita Travkin 2023-10-22 10:00 ` Conor Dooley 2023-10-20 15:33 ` [PATCH 2/2] ASoC: qcom: sc7180: Add support for qdsp6 baked sound Nikita Travkin 2023-10-26 6:46 ` Anton Bambura 2023-10-21 16:17 ` [PATCH 0/2] sc7180: Add qdsp baked soundcard Konrad Dybcio 2023-10-21 16:47 ` Nikita Travkin 2023-10-26 17:10 ` Mark Brown
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox