Message ID | 20240327113228.1706975-3-quic_mohs@quicinc.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | ASoC: qcom: add support for qcm6490 machine | expand |
On 27/03/2024 12:32, Mohammad Rafi Shaik wrote: > + > +static int qcm6490_snd_hw_free(struct snd_pcm_substream *substream) > +{ > + struct snd_soc_pcm_runtime *rtd = substream->private_data; > + struct qcm6490_snd_data *data = snd_soc_card_get_drvdata(rtd->card); > + struct snd_soc_dai *cpu_dai = snd_soc_rtd_to_cpu(rtd, 0); > + struct sdw_stream_runtime *sruntime = data->sruntime[cpu_dai->id]; > + > + return qcom_snd_sdw_hw_free(substream, sruntime, > + &data->stream_prepared[cpu_dai->id]); > +} > + > +static const struct snd_soc_ops qcm6490_be_ops = { > + .hw_params = qcm6490_snd_hw_params, > + .hw_free = qcm6490_snd_hw_free, > + .prepare = qcm6490_snd_prepare, > +}; I think you leak sdw_stream, because of missing shutdown. Except that everything looks like sc8280xp, except the snd_init(), so I wonder how important that difference is? Cannot be combined into sc8280xp? Best regards, Krzysztof
On Wed, 27 Mar 2024 at 13:34, Mohammad Rafi Shaik <quic_mohs@quicinc.com> wrote: > > Add machine driver for qcm6490 SoC. > > This initial supports which includes WSA883x Speakers with onboard DMIC > connected to internal LPASS codec via VA macros respectively and also > WCD937x based headset. > > Add compatible for sound card on Qualcomm qcs6490 boards. Granted that qcm6490 is similar to sc7280, is there any reason why you can not use one of the existing sound card drivers? Like sc7280.c or sc8280xp.c? > > Signed-off-by: Mohammad Rafi Shaik <quic_mohs@quicinc.com> > --- > sound/soc/qcom/Kconfig | 13 +++ > sound/soc/qcom/Makefile | 2 + > sound/soc/qcom/qcm6490.c | 173 +++++++++++++++++++++++++++++++++++++++ > 3 files changed, 188 insertions(+) > create mode 100644 sound/soc/qcom/qcm6490.c > > diff --git a/sound/soc/qcom/Kconfig b/sound/soc/qcom/Kconfig > index 762491d6f2f2..0bc536766872 100644 > --- a/sound/soc/qcom/Kconfig > +++ b/sound/soc/qcom/Kconfig > @@ -151,6 +151,19 @@ config SND_SOC_MSM8996 > APQ8096 SoC-based systems. > Say Y if you want to use audio device on this SoCs > > +config SND_SOC_QCM6490 > + tristate "SoC Machine driver for QCM6490 boards" > + depends on QCOM_APR && SOUNDWIRE > + depends on COMMON_CLK > + select SND_SOC_QDSP6 > + select SND_SOC_QCOM_COMMON > + select SND_SOC_QCOM_SDW > + help > + Add support for audio on Qualcomm Technologies Inc. > + QCM6490 SoC-based systems. > + To compile this driver say Y or M if you want to > + use audio device on this SoCs. > + > config SND_SOC_SDM845 > tristate "SoC Machine driver for SDM845 boards" > depends on QCOM_APR && I2C && SOUNDWIRE > diff --git a/sound/soc/qcom/Makefile b/sound/soc/qcom/Makefile > index 34f3fcb8ee9a..feb2c164be69 100644 > --- a/sound/soc/qcom/Makefile > +++ b/sound/soc/qcom/Makefile > @@ -22,6 +22,7 @@ obj-$(CONFIG_SND_SOC_LPASS_SC7280) += snd-soc-lpass-sc7280.o > snd-soc-storm-objs := storm.o > snd-soc-apq8016-sbc-objs := apq8016_sbc.o > snd-soc-apq8096-objs := apq8096.o > +snd-soc-qcm6490-objs := qcm6490.o > snd-soc-sc7180-objs := sc7180.o > snd-soc-sc7280-objs := sc7280.o > snd-soc-sdm845-objs := sdm845.o > @@ -34,6 +35,7 @@ snd-soc-x1e80100-objs := x1e80100.o > obj-$(CONFIG_SND_SOC_STORM) += snd-soc-storm.o > obj-$(CONFIG_SND_SOC_APQ8016_SBC) += snd-soc-apq8016-sbc.o > obj-$(CONFIG_SND_SOC_MSM8996) += snd-soc-apq8096.o > +obj-$(CONFIG_SND_SOC_QCM6490) += snd-soc-qcm6490.o > obj-$(CONFIG_SND_SOC_SC7180) += snd-soc-sc7180.o > obj-$(CONFIG_SND_SOC_SC7280) += snd-soc-sc7280.o > obj-$(CONFIG_SND_SOC_SC8280XP) += snd-soc-sc8280xp.o > diff --git a/sound/soc/qcom/qcm6490.c b/sound/soc/qcom/qcm6490.c > new file mode 100644 > index 000000000000..5b0dc95963f5 > --- /dev/null > +++ b/sound/soc/qcom/qcm6490.c > @@ -0,0 +1,173 @@ > +// SPDX-License-Identifier: GPL-2.0-only > +// Copyright (c) 2024 Qualcomm Innovation Center, Inc. All rights reserved. > + > +#include <dt-bindings/sound/qcom,q6afe.h> > +#include <linux/input.h> > +#include <linux/module.h> > +#include <linux/platform_device.h> > +#include <linux/of_device.h> > +#include <sound/core.h> > +#include <sound/soc.h> > +#include <sound/soc-dapm.h> > +#include <sound/pcm.h> > +#include <linux/soundwire/sdw.h> > +#include <sound/jack.h> > +#include <sound/pcm_params.h> > +#include "lpass.h" > +#include "qdsp6/q6afe.h" > +#include "common.h" > +#include "sdw.h" > + > +struct qcm6490_snd_data { > + bool stream_prepared[AFE_PORT_MAX]; > + struct snd_soc_card *card; > + struct sdw_stream_runtime *sruntime[AFE_PORT_MAX]; > + struct snd_soc_jack jack; > + bool jack_setup; > +}; > + > +static int qcm6490_snd_init(struct snd_soc_pcm_runtime *rtd) > +{ > + struct qcm6490_snd_data *data = snd_soc_card_get_drvdata(rtd->card); > + struct snd_soc_dai *cpu_dai = snd_soc_rtd_to_cpu(rtd, 0); > + > + switch (cpu_dai->id) { > + case TX_CODEC_DMA_TX_3: > + case LPASS_CDC_DMA_TX3: > + case RX_CODEC_DMA_RX_0: > + return qcom_snd_wcd_jack_setup(rtd, &data->jack, &data->jack_setup); > + case VA_CODEC_DMA_TX_0: > + case WSA_CODEC_DMA_RX_0: > + return 0; > + default: > + dev_err(rtd->dev, "%s: invalid dai id 0x%x\n", __func__, cpu_dai->id); > + } > + > + return -EINVAL; > +} > + > +static int qcm6490_be_hw_params_fixup(struct snd_soc_pcm_runtime *rtd, > + struct snd_pcm_hw_params *params) > +{ > + struct snd_soc_dai *cpu_dai = snd_soc_rtd_to_cpu(rtd, 0); > + 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 = 48000; > + rate->max = 48000; > + channels->min = 2; > + channels->max = 2; > + switch (cpu_dai->id) { > + case TX_CODEC_DMA_TX_0: > + case TX_CODEC_DMA_TX_1: > + case TX_CODEC_DMA_TX_2: > + case TX_CODEC_DMA_TX_3: > + channels->min = 1; > + break; > + default: > + break; > + } > + > + return 0; > +} > + > +static int qcm6490_snd_hw_params(struct snd_pcm_substream *substream, > + struct snd_pcm_hw_params *params) > +{ > + struct snd_soc_pcm_runtime *rtd = substream->private_data; > + struct snd_soc_dai *cpu_dai = snd_soc_rtd_to_cpu(rtd, 0); > + struct qcm6490_snd_data *pdata = snd_soc_card_get_drvdata(rtd->card); > + > + return qcom_snd_sdw_hw_params(substream, params, &pdata->sruntime[cpu_dai->id]); > +} > + > +static int qcm6490_snd_prepare(struct snd_pcm_substream *substream) > +{ > + struct snd_soc_pcm_runtime *rtd = substream->private_data; > + struct snd_soc_dai *cpu_dai = snd_soc_rtd_to_cpu(rtd, 0); > + struct qcm6490_snd_data *data = snd_soc_card_get_drvdata(rtd->card); > + struct sdw_stream_runtime *sruntime = data->sruntime[cpu_dai->id]; > + > + return qcom_snd_sdw_prepare(substream, sruntime, > + &data->stream_prepared[cpu_dai->id]); > +} > + > +static int qcm6490_snd_hw_free(struct snd_pcm_substream *substream) > +{ > + struct snd_soc_pcm_runtime *rtd = substream->private_data; > + struct qcm6490_snd_data *data = snd_soc_card_get_drvdata(rtd->card); > + struct snd_soc_dai *cpu_dai = snd_soc_rtd_to_cpu(rtd, 0); > + struct sdw_stream_runtime *sruntime = data->sruntime[cpu_dai->id]; > + > + return qcom_snd_sdw_hw_free(substream, sruntime, > + &data->stream_prepared[cpu_dai->id]); > +} > + > +static const struct snd_soc_ops qcm6490_be_ops = { > + .hw_params = qcm6490_snd_hw_params, > + .hw_free = qcm6490_snd_hw_free, > + .prepare = qcm6490_snd_prepare, > +}; > + > +static void qcm6490_add_be_ops(struct snd_soc_card *card) > +{ > + struct snd_soc_dai_link *link; > + int i; > + > + for_each_card_prelinks(card, i, link) { > + if (link->no_pcm == 1) { > + link->init = qcm6490_snd_init; > + link->be_hw_params_fixup = qcm6490_be_hw_params_fixup; > + link->ops = &qcm6490_be_ops; > + } > + } > +} > + > +static int qcm6490_platform_probe(struct platform_device *pdev) > +{ > + struct snd_soc_card *card; > + struct qcm6490_snd_data *data; > + struct device *dev = &pdev->dev; > + int ret; > + > + card = devm_kzalloc(dev, sizeof(*card), GFP_KERNEL); > + if (!card) > + return -ENOMEM; > + card->owner = THIS_MODULE; > + /* Allocate the private data */ > + data = devm_kzalloc(dev, sizeof(*data), GFP_KERNEL); > + if (!data) > + return -ENOMEM; > + > + card->dev = dev; > + dev_set_drvdata(dev, card); > + snd_soc_card_set_drvdata(card, data); > + ret = qcom_snd_parse_of(card); > + if (ret) > + return ret; > + > + card->driver_name = of_device_get_match_data(dev); > + qcm6490_add_be_ops(card); > + return devm_snd_soc_register_card(dev, card); > +} > + > +static const struct of_device_id snd_qcm6490_dt_match[] = { > + {.compatible = "qcom,qcm6490-sndcard", "qcm6490"}, > + {.compatible = "qcom,qcs6490-sndcard", "qcs6490"}, > + {} > +}; > + > +MODULE_DEVICE_TABLE(of, snd_qcm6490_dt_match); > + > +static struct platform_driver snd_qcm6490_driver = { > + .probe = qcm6490_platform_probe, > + .driver = { > + .name = "snd-qcm6490", > + .of_match_table = snd_qcm6490_dt_match, > + }, > +}; > +module_platform_driver(snd_qcm6490_driver); > +MODULE_DESCRIPTION("qcm6490 ASoC Machine Driver"); > +MODULE_LICENSE("GPL"); > -- > 2.25.1 > >
On 3/27/2024 6:39 PM, Dmitry Baryshkov wrote: > On Wed, 27 Mar 2024 at 13:34, Mohammad Rafi Shaik<quic_mohs@quicinc.com> wrote: >> Add machine driver for qcm6490 SoC. >> >> This initial supports which includes WSA883x Speakers with onboard DMIC >> connected to internal LPASS codec via VA macros respectively and also >> WCD937x based headset. >> >> Add compatible for sound card on Qualcomm qcs6490 boards. > Granted that qcm6490 is similar to sc7280, is there any reason why you > can not use one of the existing sound card drivers? Like sc7280.c or > sc8280xp.c? The qcs6490/qcm6490 has additional interfaces like MI2S, which requires additional machine driver modification. Example : Required new DAPM widget change in machine driver for MI2S interface which is specific to qcs6490/qcm6490. So, using new qcm6490 machine driver. Will try to use existing sc8280xp.c machine driver. Thanks Rafi. >> Signed-off-by: Mohammad Rafi Shaik<quic_mohs@quicinc.com> >> --- >> sound/soc/qcom/Kconfig | 13 +++ >> sound/soc/qcom/Makefile | 2 + >> sound/soc/qcom/qcm6490.c | 173 +++++++++++++++++++++++++++++++++++++++ >> 3 files changed, 188 insertions(+) >> create mode 100644 sound/soc/qcom/qcm6490.c >> >> diff --git a/sound/soc/qcom/Kconfig b/sound/soc/qcom/Kconfig >> index 762491d6f2f2..0bc536766872 100644 >> --- a/sound/soc/qcom/Kconfig >> +++ b/sound/soc/qcom/Kconfig >> @@ -151,6 +151,19 @@ config SND_SOC_MSM8996 >> APQ8096 SoC-based systems. >> Say Y if you want to use audio device on this SoCs >> >> +config SND_SOC_QCM6490 >> + tristate "SoC Machine driver for QCM6490 boards" >> + depends on QCOM_APR && SOUNDWIRE >> + depends on COMMON_CLK >> + select SND_SOC_QDSP6 >> + select SND_SOC_QCOM_COMMON >> + select SND_SOC_QCOM_SDW >> + help >> + Add support for audio on Qualcomm Technologies Inc. >> + QCM6490 SoC-based systems. >> + To compile this driver say Y or M if you want to >> + use audio device on this SoCs. >> + >> config SND_SOC_SDM845 >> tristate "SoC Machine driver for SDM845 boards" >> depends on QCOM_APR && I2C && SOUNDWIRE >> diff --git a/sound/soc/qcom/Makefile b/sound/soc/qcom/Makefile >> index 34f3fcb8ee9a..feb2c164be69 100644 >> --- a/sound/soc/qcom/Makefile >> +++ b/sound/soc/qcom/Makefile >> @@ -22,6 +22,7 @@ obj-$(CONFIG_SND_SOC_LPASS_SC7280) += snd-soc-lpass-sc7280.o >> snd-soc-storm-objs := storm.o >> snd-soc-apq8016-sbc-objs := apq8016_sbc.o >> snd-soc-apq8096-objs := apq8096.o >> +snd-soc-qcm6490-objs := qcm6490.o >> snd-soc-sc7180-objs := sc7180.o >> snd-soc-sc7280-objs := sc7280.o >> snd-soc-sdm845-objs := sdm845.o >> @@ -34,6 +35,7 @@ snd-soc-x1e80100-objs := x1e80100.o >> obj-$(CONFIG_SND_SOC_STORM) += snd-soc-storm.o >> obj-$(CONFIG_SND_SOC_APQ8016_SBC) += snd-soc-apq8016-sbc.o >> obj-$(CONFIG_SND_SOC_MSM8996) += snd-soc-apq8096.o >> +obj-$(CONFIG_SND_SOC_QCM6490) += snd-soc-qcm6490.o >> obj-$(CONFIG_SND_SOC_SC7180) += snd-soc-sc7180.o >> obj-$(CONFIG_SND_SOC_SC7280) += snd-soc-sc7280.o >> obj-$(CONFIG_SND_SOC_SC8280XP) += snd-soc-sc8280xp.o >> diff --git a/sound/soc/qcom/qcm6490.c b/sound/soc/qcom/qcm6490.c >> new file mode 100644 >> index 000000000000..5b0dc95963f5 >> --- /dev/null >> +++ b/sound/soc/qcom/qcm6490.c >> @@ -0,0 +1,173 @@ >> +// SPDX-License-Identifier: GPL-2.0-only >> +// Copyright (c) 2024 Qualcomm Innovation Center, Inc. All rights reserved. >> + >> +#include <dt-bindings/sound/qcom,q6afe.h> >> +#include <linux/input.h> >> +#include <linux/module.h> >> +#include <linux/platform_device.h> >> +#include <linux/of_device.h> >> +#include <sound/core.h> >> +#include <sound/soc.h> >> +#include <sound/soc-dapm.h> >> +#include <sound/pcm.h> >> +#include <linux/soundwire/sdw.h> >> +#include <sound/jack.h> >> +#include <sound/pcm_params.h> >> +#include "lpass.h" >> +#include "qdsp6/q6afe.h" >> +#include "common.h" >> +#include "sdw.h" >> + >> +struct qcm6490_snd_data { >> + bool stream_prepared[AFE_PORT_MAX]; >> + struct snd_soc_card *card; >> + struct sdw_stream_runtime *sruntime[AFE_PORT_MAX]; >> + struct snd_soc_jack jack; >> + bool jack_setup; >> +}; >> + >> +static int qcm6490_snd_init(struct snd_soc_pcm_runtime *rtd) >> +{ >> + struct qcm6490_snd_data *data = snd_soc_card_get_drvdata(rtd->card); >> + struct snd_soc_dai *cpu_dai = snd_soc_rtd_to_cpu(rtd, 0); >> + >> + switch (cpu_dai->id) { >> + case TX_CODEC_DMA_TX_3: >> + case LPASS_CDC_DMA_TX3: >> + case RX_CODEC_DMA_RX_0: >> + return qcom_snd_wcd_jack_setup(rtd, &data->jack, &data->jack_setup); >> + case VA_CODEC_DMA_TX_0: >> + case WSA_CODEC_DMA_RX_0: >> + return 0; >> + default: >> + dev_err(rtd->dev, "%s: invalid dai id 0x%x\n", __func__, cpu_dai->id); >> + } >> + >> + return -EINVAL; >> +} >> + >> +static int qcm6490_be_hw_params_fixup(struct snd_soc_pcm_runtime *rtd, >> + struct snd_pcm_hw_params *params) >> +{ >> + struct snd_soc_dai *cpu_dai = snd_soc_rtd_to_cpu(rtd, 0); >> + 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 = 48000; >> + rate->max = 48000; >> + channels->min = 2; >> + channels->max = 2; >> + switch (cpu_dai->id) { >> + case TX_CODEC_DMA_TX_0: >> + case TX_CODEC_DMA_TX_1: >> + case TX_CODEC_DMA_TX_2: >> + case TX_CODEC_DMA_TX_3: >> + channels->min = 1; >> + break; >> + default: >> + break; >> + } >> + >> + return 0; >> +} >> + >> +static int qcm6490_snd_hw_params(struct snd_pcm_substream *substream, >> + struct snd_pcm_hw_params *params) >> +{ >> + struct snd_soc_pcm_runtime *rtd = substream->private_data; >> + struct snd_soc_dai *cpu_dai = snd_soc_rtd_to_cpu(rtd, 0); >> + struct qcm6490_snd_data *pdata = snd_soc_card_get_drvdata(rtd->card); >> + >> + return qcom_snd_sdw_hw_params(substream, params, &pdata->sruntime[cpu_dai->id]); >> +} >> + >> +static int qcm6490_snd_prepare(struct snd_pcm_substream *substream) >> +{ >> + struct snd_soc_pcm_runtime *rtd = substream->private_data; >> + struct snd_soc_dai *cpu_dai = snd_soc_rtd_to_cpu(rtd, 0); >> + struct qcm6490_snd_data *data = snd_soc_card_get_drvdata(rtd->card); >> + struct sdw_stream_runtime *sruntime = data->sruntime[cpu_dai->id]; >> + >> + return qcom_snd_sdw_prepare(substream, sruntime, >> + &data->stream_prepared[cpu_dai->id]); >> +} >> + >> +static int qcm6490_snd_hw_free(struct snd_pcm_substream *substream) >> +{ >> + struct snd_soc_pcm_runtime *rtd = substream->private_data; >> + struct qcm6490_snd_data *data = snd_soc_card_get_drvdata(rtd->card); >> + struct snd_soc_dai *cpu_dai = snd_soc_rtd_to_cpu(rtd, 0); >> + struct sdw_stream_runtime *sruntime = data->sruntime[cpu_dai->id]; >> + >> + return qcom_snd_sdw_hw_free(substream, sruntime, >> + &data->stream_prepared[cpu_dai->id]); >> +} >> + >> +static const struct snd_soc_ops qcm6490_be_ops = { >> + .hw_params = qcm6490_snd_hw_params, >> + .hw_free = qcm6490_snd_hw_free, >> + .prepare = qcm6490_snd_prepare, >> +}; >> + >> +static void qcm6490_add_be_ops(struct snd_soc_card *card) >> +{ >> + struct snd_soc_dai_link *link; >> + int i; >> + >> + for_each_card_prelinks(card, i, link) { >> + if (link->no_pcm == 1) { >> + link->init = qcm6490_snd_init; >> + link->be_hw_params_fixup = qcm6490_be_hw_params_fixup; >> + link->ops = &qcm6490_be_ops; >> + } >> + } >> +} >> + >> +static int qcm6490_platform_probe(struct platform_device *pdev) >> +{ >> + struct snd_soc_card *card; >> + struct qcm6490_snd_data *data; >> + struct device *dev = &pdev->dev; >> + int ret; >> + >> + card = devm_kzalloc(dev, sizeof(*card), GFP_KERNEL); >> + if (!card) >> + return -ENOMEM; >> + card->owner = THIS_MODULE; >> + /* Allocate the private data */ >> + data = devm_kzalloc(dev, sizeof(*data), GFP_KERNEL); >> + if (!data) >> + return -ENOMEM; >> + >> + card->dev = dev; >> + dev_set_drvdata(dev, card); >> + snd_soc_card_set_drvdata(card, data); >> + ret = qcom_snd_parse_of(card); >> + if (ret) >> + return ret; >> + >> + card->driver_name = of_device_get_match_data(dev); >> + qcm6490_add_be_ops(card); >> + return devm_snd_soc_register_card(dev, card); >> +} >> + >> +static const struct of_device_id snd_qcm6490_dt_match[] = { >> + {.compatible = "qcom,qcm6490-sndcard", "qcm6490"}, >> + {.compatible = "qcom,qcs6490-sndcard", "qcs6490"}, >> + {} >> +}; >> + >> +MODULE_DEVICE_TABLE(of, snd_qcm6490_dt_match); >> + >> +static struct platform_driver snd_qcm6490_driver = { >> + .probe = qcm6490_platform_probe, >> + .driver = { >> + .name = "snd-qcm6490", >> + .of_match_table = snd_qcm6490_dt_match, >> + }, >> +}; >> +module_platform_driver(snd_qcm6490_driver); >> +MODULE_DESCRIPTION("qcm6490 ASoC Machine Driver"); >> +MODULE_LICENSE("GPL"); >> -- >> 2.25.1 >> >> >
On 29/03/2024 16:19, Mohammad Rafi Shaik wrote: > > On 3/27/2024 6:39 PM, Dmitry Baryshkov wrote: >> On Wed, 27 Mar 2024 at 13:34, Mohammad Rafi Shaik<quic_mohs@quicinc.com> wrote: >>> Add machine driver for qcm6490 SoC. >>> >>> This initial supports which includes WSA883x Speakers with onboard DMIC >>> connected to internal LPASS codec via VA macros respectively and also >>> WCD937x based headset. >>> >>> Add compatible for sound card on Qualcomm qcs6490 boards. >> Granted that qcm6490 is similar to sc7280, is there any reason why you >> can not use one of the existing sound card drivers? Like sc7280.c or >> sc8280xp.c? > > The qcs6490/qcm6490 has additional interfaces like MI2S, which requires > additional machine driver modification. > > Example : Required new DAPM widget change in machine driver for MI2S > interface which is specific to qcs6490/qcm6490. > > So, using new qcm6490 machine driver. > > Will try to use existing sc8280xp.c machine driver. In that case, if it does not fit into sc8280xp, it looks fine for a new driver. Maybe just mention this in commit msg. Best regards, Krzysztof
Hi, On Fri, 29 Mar 2024 at 17:20, Mohammad Rafi Shaik <quic_mohs@quicinc.com> wrote: > > > On 3/27/2024 6:39 PM, Dmitry Baryshkov wrote: > > On Wed, 27 Mar 2024 at 13:34, Mohammad Rafi Shaik <quic_mohs@quicinc.com> wrote: Please turn off HTML mail composition and never ever send HTML email to OSS mailing lists. Now quotation levels are broken... > > Add machine driver for qcm6490 SoC. > > This initial supports which includes WSA883x Speakers with onboard DMIC > connected to internal LPASS codec via VA macros respectively and also > WCD937x based headset. > > Add compatible for sound card on Qualcomm qcs6490 boards. > > Granted that qcm6490 is similar to sc7280, is there any reason why you > can not use one of the existing sound card drivers? Like sc7280.c or > sc8280xp.c? > > The qcs6490/qcm6490 has additional interfaces like MI2S, which requires additional machine driver modification. > > Example : Required new DAPM widget change in machine driver for MI2S interface which is specific to qcs6490/qcm6490. > > So, using new qcm6490 machine driver. > > Will try to use existing sc8280xp.c machine driver. What about sc7280? In the end, qcm6490 is sc7280 with different firmware / spin.
On 3/30/2024 12:09 AM, Dmitry Baryshkov wrote: > Hi, > > On Fri, 29 Mar 2024 at 17:20, Mohammad Rafi Shaik <quic_mohs@quicinc.com> wrote: >> >> >> On 3/27/2024 6:39 PM, Dmitry Baryshkov wrote: >> >> On Wed, 27 Mar 2024 at 13:34, Mohammad Rafi Shaik <quic_mohs@quicinc.com> wrote: > > Please turn off HTML mail composition and never ever send HTML email > to OSS mailing lists. > Now quotation levels are broken... > >> >> Add machine driver for qcm6490 SoC. >> >> This initial supports which includes WSA883x Speakers with onboard DMIC >> connected to internal LPASS codec via VA macros respectively and also >> WCD937x based headset. >> >> Add compatible for sound card on Qualcomm qcs6490 boards. >> >> Granted that qcm6490 is similar to sc7280, is there any reason why you >> can not use one of the existing sound card drivers? Like sc7280.c or >> sc8280xp.c? >> >> The qcs6490/qcm6490 has additional interfaces like MI2S, which requires additional machine driver modification. >> >> Example : Required new DAPM widget change in machine driver for MI2S interface which is specific to qcs6490/qcm6490. >> >> So, using new qcm6490 machine driver. >> >> Will try to use existing sc8280xp.c machine driver. > > What about sc7280? In the end, qcm6490 is sc7280 with different firmware / spin. > > The sc7280 is tightly linked with realtek codec. which will only support for chrome. The sc8280xp.c machine driver is more suitable for qcm6490, will use same sc8280xp.
On 4/2/24 11:20, Mohammad Rafi Shaik wrote: > On 3/30/2024 12:09 AM, Dmitry Baryshkov wrote: >> Hi, >> >> On Fri, 29 Mar 2024 at 17:20, Mohammad Rafi Shaik <quic_mohs@quicinc.com> wrote: >>> >>> >>> On 3/27/2024 6:39 PM, Dmitry Baryshkov wrote: >>> >>> On Wed, 27 Mar 2024 at 13:34, Mohammad Rafi Shaik <quic_mohs@quicinc.com> wrote: >> >> Please turn off HTML mail composition and never ever send HTML email >> to OSS mailing lists. >> Now quotation levels are broken... >> >>> >>> Add machine driver for qcm6490 SoC. >>> >>> This initial supports which includes WSA883x Speakers with onboard DMIC >>> connected to internal LPASS codec via VA macros respectively and also >>> WCD937x based headset. >>> >>> Add compatible for sound card on Qualcomm qcs6490 boards. >>> >>> Granted that qcm6490 is similar to sc7280, is there any reason why you >>> can not use one of the existing sound card drivers? Like sc7280.c or >>> sc8280xp.c? >>> >>> The qcs6490/qcm6490 has additional interfaces like MI2S, which requires additional machine driver modification. >>> >>> Example : Required new DAPM widget change in machine driver for MI2S interface which is specific to qcs6490/qcm6490. >>> >>> So, using new qcm6490 machine driver. >>> >>> Will try to use existing sc8280xp.c machine driver. >> >> What about sc7280? In the end, qcm6490 is sc7280 with different firmware / spin. >> >> > > The sc7280 is tightly linked with realtek codec. which will only support for chrome. Perhaps we should rename it and stop suggesting it's for all 7280-like platforms then.. > The sc8280xp.c machine driver is more suitable for qcm6490, will use same sc8280xp. This in turn, should it become something like snd-qcom-audioreach? Konrad
diff --git a/sound/soc/qcom/Kconfig b/sound/soc/qcom/Kconfig index 762491d6f2f2..0bc536766872 100644 --- a/sound/soc/qcom/Kconfig +++ b/sound/soc/qcom/Kconfig @@ -151,6 +151,19 @@ config SND_SOC_MSM8996 APQ8096 SoC-based systems. Say Y if you want to use audio device on this SoCs +config SND_SOC_QCM6490 + tristate "SoC Machine driver for QCM6490 boards" + depends on QCOM_APR && SOUNDWIRE + depends on COMMON_CLK + select SND_SOC_QDSP6 + select SND_SOC_QCOM_COMMON + select SND_SOC_QCOM_SDW + help + Add support for audio on Qualcomm Technologies Inc. + QCM6490 SoC-based systems. + To compile this driver say Y or M if you want to + use audio device on this SoCs. + config SND_SOC_SDM845 tristate "SoC Machine driver for SDM845 boards" depends on QCOM_APR && I2C && SOUNDWIRE diff --git a/sound/soc/qcom/Makefile b/sound/soc/qcom/Makefile index 34f3fcb8ee9a..feb2c164be69 100644 --- a/sound/soc/qcom/Makefile +++ b/sound/soc/qcom/Makefile @@ -22,6 +22,7 @@ obj-$(CONFIG_SND_SOC_LPASS_SC7280) += snd-soc-lpass-sc7280.o snd-soc-storm-objs := storm.o snd-soc-apq8016-sbc-objs := apq8016_sbc.o snd-soc-apq8096-objs := apq8096.o +snd-soc-qcm6490-objs := qcm6490.o snd-soc-sc7180-objs := sc7180.o snd-soc-sc7280-objs := sc7280.o snd-soc-sdm845-objs := sdm845.o @@ -34,6 +35,7 @@ snd-soc-x1e80100-objs := x1e80100.o obj-$(CONFIG_SND_SOC_STORM) += snd-soc-storm.o obj-$(CONFIG_SND_SOC_APQ8016_SBC) += snd-soc-apq8016-sbc.o obj-$(CONFIG_SND_SOC_MSM8996) += snd-soc-apq8096.o +obj-$(CONFIG_SND_SOC_QCM6490) += snd-soc-qcm6490.o obj-$(CONFIG_SND_SOC_SC7180) += snd-soc-sc7180.o obj-$(CONFIG_SND_SOC_SC7280) += snd-soc-sc7280.o obj-$(CONFIG_SND_SOC_SC8280XP) += snd-soc-sc8280xp.o diff --git a/sound/soc/qcom/qcm6490.c b/sound/soc/qcom/qcm6490.c new file mode 100644 index 000000000000..5b0dc95963f5 --- /dev/null +++ b/sound/soc/qcom/qcm6490.c @@ -0,0 +1,173 @@ +// SPDX-License-Identifier: GPL-2.0-only +// Copyright (c) 2024 Qualcomm Innovation Center, Inc. All rights reserved. + +#include <dt-bindings/sound/qcom,q6afe.h> +#include <linux/input.h> +#include <linux/module.h> +#include <linux/platform_device.h> +#include <linux/of_device.h> +#include <sound/core.h> +#include <sound/soc.h> +#include <sound/soc-dapm.h> +#include <sound/pcm.h> +#include <linux/soundwire/sdw.h> +#include <sound/jack.h> +#include <sound/pcm_params.h> +#include "lpass.h" +#include "qdsp6/q6afe.h" +#include "common.h" +#include "sdw.h" + +struct qcm6490_snd_data { + bool stream_prepared[AFE_PORT_MAX]; + struct snd_soc_card *card; + struct sdw_stream_runtime *sruntime[AFE_PORT_MAX]; + struct snd_soc_jack jack; + bool jack_setup; +}; + +static int qcm6490_snd_init(struct snd_soc_pcm_runtime *rtd) +{ + struct qcm6490_snd_data *data = snd_soc_card_get_drvdata(rtd->card); + struct snd_soc_dai *cpu_dai = snd_soc_rtd_to_cpu(rtd, 0); + + switch (cpu_dai->id) { + case TX_CODEC_DMA_TX_3: + case LPASS_CDC_DMA_TX3: + case RX_CODEC_DMA_RX_0: + return qcom_snd_wcd_jack_setup(rtd, &data->jack, &data->jack_setup); + case VA_CODEC_DMA_TX_0: + case WSA_CODEC_DMA_RX_0: + return 0; + default: + dev_err(rtd->dev, "%s: invalid dai id 0x%x\n", __func__, cpu_dai->id); + } + + return -EINVAL; +} + +static int qcm6490_be_hw_params_fixup(struct snd_soc_pcm_runtime *rtd, + struct snd_pcm_hw_params *params) +{ + struct snd_soc_dai *cpu_dai = snd_soc_rtd_to_cpu(rtd, 0); + 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 = 48000; + rate->max = 48000; + channels->min = 2; + channels->max = 2; + switch (cpu_dai->id) { + case TX_CODEC_DMA_TX_0: + case TX_CODEC_DMA_TX_1: + case TX_CODEC_DMA_TX_2: + case TX_CODEC_DMA_TX_3: + channels->min = 1; + break; + default: + break; + } + + return 0; +} + +static int qcm6490_snd_hw_params(struct snd_pcm_substream *substream, + struct snd_pcm_hw_params *params) +{ + struct snd_soc_pcm_runtime *rtd = substream->private_data; + struct snd_soc_dai *cpu_dai = snd_soc_rtd_to_cpu(rtd, 0); + struct qcm6490_snd_data *pdata = snd_soc_card_get_drvdata(rtd->card); + + return qcom_snd_sdw_hw_params(substream, params, &pdata->sruntime[cpu_dai->id]); +} + +static int qcm6490_snd_prepare(struct snd_pcm_substream *substream) +{ + struct snd_soc_pcm_runtime *rtd = substream->private_data; + struct snd_soc_dai *cpu_dai = snd_soc_rtd_to_cpu(rtd, 0); + struct qcm6490_snd_data *data = snd_soc_card_get_drvdata(rtd->card); + struct sdw_stream_runtime *sruntime = data->sruntime[cpu_dai->id]; + + return qcom_snd_sdw_prepare(substream, sruntime, + &data->stream_prepared[cpu_dai->id]); +} + +static int qcm6490_snd_hw_free(struct snd_pcm_substream *substream) +{ + struct snd_soc_pcm_runtime *rtd = substream->private_data; + struct qcm6490_snd_data *data = snd_soc_card_get_drvdata(rtd->card); + struct snd_soc_dai *cpu_dai = snd_soc_rtd_to_cpu(rtd, 0); + struct sdw_stream_runtime *sruntime = data->sruntime[cpu_dai->id]; + + return qcom_snd_sdw_hw_free(substream, sruntime, + &data->stream_prepared[cpu_dai->id]); +} + +static const struct snd_soc_ops qcm6490_be_ops = { + .hw_params = qcm6490_snd_hw_params, + .hw_free = qcm6490_snd_hw_free, + .prepare = qcm6490_snd_prepare, +}; + +static void qcm6490_add_be_ops(struct snd_soc_card *card) +{ + struct snd_soc_dai_link *link; + int i; + + for_each_card_prelinks(card, i, link) { + if (link->no_pcm == 1) { + link->init = qcm6490_snd_init; + link->be_hw_params_fixup = qcm6490_be_hw_params_fixup; + link->ops = &qcm6490_be_ops; + } + } +} + +static int qcm6490_platform_probe(struct platform_device *pdev) +{ + struct snd_soc_card *card; + struct qcm6490_snd_data *data; + struct device *dev = &pdev->dev; + int ret; + + card = devm_kzalloc(dev, sizeof(*card), GFP_KERNEL); + if (!card) + return -ENOMEM; + card->owner = THIS_MODULE; + /* Allocate the private data */ + data = devm_kzalloc(dev, sizeof(*data), GFP_KERNEL); + if (!data) + return -ENOMEM; + + card->dev = dev; + dev_set_drvdata(dev, card); + snd_soc_card_set_drvdata(card, data); + ret = qcom_snd_parse_of(card); + if (ret) + return ret; + + card->driver_name = of_device_get_match_data(dev); + qcm6490_add_be_ops(card); + return devm_snd_soc_register_card(dev, card); +} + +static const struct of_device_id snd_qcm6490_dt_match[] = { + {.compatible = "qcom,qcm6490-sndcard", "qcm6490"}, + {.compatible = "qcom,qcs6490-sndcard", "qcs6490"}, + {} +}; + +MODULE_DEVICE_TABLE(of, snd_qcm6490_dt_match); + +static struct platform_driver snd_qcm6490_driver = { + .probe = qcm6490_platform_probe, + .driver = { + .name = "snd-qcm6490", + .of_match_table = snd_qcm6490_dt_match, + }, +}; +module_platform_driver(snd_qcm6490_driver); +MODULE_DESCRIPTION("qcm6490 ASoC Machine Driver"); +MODULE_LICENSE("GPL");
Add machine driver for qcm6490 SoC. This initial supports which includes WSA883x Speakers with onboard DMIC connected to internal LPASS codec via VA macros respectively and also WCD937x based headset. Add compatible for sound card on Qualcomm qcs6490 boards. Signed-off-by: Mohammad Rafi Shaik <quic_mohs@quicinc.com> --- sound/soc/qcom/Kconfig | 13 +++ sound/soc/qcom/Makefile | 2 + sound/soc/qcom/qcm6490.c | 173 +++++++++++++++++++++++++++++++++++++++ 3 files changed, 188 insertions(+) create mode 100644 sound/soc/qcom/qcm6490.c