[alsa-devel] [PATCH v4 0/4] Add support for audio on SDM845 SoC
This provides initial patchset to support audio on Qualcomm Techonologies Inc. SDM845 SoC. Currently, it supports audio playback/capture over Primary MI2S and Quaternary TDM ports.
Changes since v3: - Added Module_license in common.c - Merged apq8096.c machine driver change with common api patch - Addressed comments by Srinivas, Mark and Vinod.
Rohit kumar (4): ASoC: qcom: dt-bindings: Add sdm845 machine bindings ASoC: dt-bindings: Update dt binding name for apq8096 ASoC: qcom: Add support to parse common audio device nodes ASoC: qcom: add sdm845 sound card support
.../devicetree/bindings/sound/qcom,apq8096.txt | 15 +- .../devicetree/bindings/sound/qcom,sdm845.txt | 80 ++++++ sound/soc/qcom/Kconfig | 8 + sound/soc/qcom/Makefile | 4 +- sound/soc/qcom/apq8096.c | 111 +------- sound/soc/qcom/common.c | 112 ++++++++ sound/soc/qcom/common.h | 12 + sound/soc/qcom/sdm845.c | 286 +++++++++++++++++++++ 8 files changed, 525 insertions(+), 103 deletions(-) create mode 100644 Documentation/devicetree/bindings/sound/qcom,sdm845.txt create mode 100644 sound/soc/qcom/common.c create mode 100644 sound/soc/qcom/common.h create mode 100644 sound/soc/qcom/sdm845.c
Add devicetree bindings documentation file for SDM845 sound card.
Signed-off-by: Rohit kumar rohitkr@codeaurora.org --- .../devicetree/bindings/sound/qcom,sdm845.txt | 80 ++++++++++++++++++++++ 1 file changed, 80 insertions(+) create mode 100644 Documentation/devicetree/bindings/sound/qcom,sdm845.txt
diff --git a/Documentation/devicetree/bindings/sound/qcom,sdm845.txt b/Documentation/devicetree/bindings/sound/qcom,sdm845.txt new file mode 100644 index 0000000..408c483 --- /dev/null +++ b/Documentation/devicetree/bindings/sound/qcom,sdm845.txt @@ -0,0 +1,80 @@ +* Qualcomm Technologies Inc. SDM845 ASoC sound card driver + +This binding describes the SDM845 sound card, which uses qdsp for audio. + +- compatible: + Usage: required + Value type: <stringlist> + Definition: must be "qcom,sdm845-sndcard" + +- audio-routing: + Usage: Optional + Value type: <stringlist> + Definition: A list of the connections between audio components. + Each entry is a pair of strings, the first being the + connection's sink, the second being the connection's + source. Valid names could be power supplies, MicBias + of codec and the jacks on the board. + +- model: + Usage: required + Value type: <stringlist> + Definition: The user-visible name of this sound card. + += dailinks +Each subnode of sndcard represents either a dailink, and subnodes of each +dailinks would be cpu/codec/platform dais. + +- link-name: + Usage: required + Value type: <string> + Definition: User friendly name for dai link + += CPU, PLATFORM, CODEC dais subnodes +- cpu: + Usage: required + Value type: <subnode> + Definition: cpu dai sub-node + +- codec: + Usage: required + Value type: <subnode> + Definition: codec dai sub-node + +- platform: + Usage: Optional + Value type: <subnode> + Definition: platform dai sub-node + +- sound-dai: + Usage: required + Value type: <phandle> + Definition: dai phandle/s and port of CPU/CODEC/PLATFORM node. + +Example: + +audio { + compatible = "qcom,sdm845-sndcard"; + model = "sdm845-snd-card"; + pinctrl-names = "default", "sleep"; + pinctrl-0 = <&pri_mi2s_active &pri_mi2s_ws_active>; + pinctrl-1 = <&pri_mi2s_sleep &pri_mi2s_ws_sleep>; + + mm1-dai-link { + link-name = "MultiMedia1"; + cpu { + sound-dai = <&q6asmdai MSM_FRONTEND_DAI_MULTIMEDIA1>; + }; + }; + + pri-mi2s-dai-link { + link-name = "PRI MI2S Playback"; + cpu { + sound-dai = <&q6afedai PRIMARY_MI2S_RX>; + }; + + platform { + sound-dai = <&q6routing>; + }; + }; +};
On Mon, Jul 30, 2018 at 03:40:51PM +0530, Rohit kumar wrote:
Add devicetree bindings documentation file for SDM845 sound card.
Signed-off-by: Rohit kumar rohitkr@codeaurora.org
.../devicetree/bindings/sound/qcom,sdm845.txt | 80 ++++++++++++++++++++++ 1 file changed, 80 insertions(+) create mode 100644 Documentation/devicetree/bindings/sound/qcom,sdm845.txt
Reviewed-by: Rob Herring robh@kernel.org
Remove qcom prefix from machine driver dt bindings of apq8096 SoC.
Acked-by: Srinivas Kandagatla srinivas.kandagatla@linaro.org Signed-off-by: Rohit kumar rohitkr@codeaurora.org --- Documentation/devicetree/bindings/sound/qcom,apq8096.txt | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-)
diff --git a/Documentation/devicetree/bindings/sound/qcom,apq8096.txt b/Documentation/devicetree/bindings/sound/qcom,apq8096.txt index c7600a9..c814e86 100644 --- a/Documentation/devicetree/bindings/sound/qcom,apq8096.txt +++ b/Documentation/devicetree/bindings/sound/qcom,apq8096.txt @@ -7,7 +7,7 @@ This binding describes the APQ8096 sound card, which uses qdsp for audio. Value type: <stringlist> Definition: must be "qcom,apq8096-sndcard"
-- qcom,audio-routing: +- audio-routing: Usage: Optional Value type: <stringlist> Definition: A list of the connections between audio components. @@ -49,6 +49,12 @@ This binding describes the APQ8096 sound card, which uses qdsp for audio. "DMIC1" "DMIC2" "DMIC3" + +- model: + Usage: required + Value type: <stringlist> + Definition: The user-visible name of this sound card. + = dailinks Each subnode of sndcard represents either a dailink, and subnodes of each dailinks would be cpu/codec/platform dais. @@ -79,11 +85,16 @@ dailinks would be cpu/codec/platform dais. Value type: <phandle with arguments> Definition: dai phandle/s and port of CPU/CODEC/PLATFORM node.
+Obsolete: + qcom,model: String for soundcard name (Use model instead) + qcom,audio-routing: A list of the connections between audio components. + (Use audio-routing instead) + Example:
audio { compatible = "qcom,apq8096-sndcard"; - qcom,model = "DB820c"; + model = "DB820c";
mm1-dai-link { link-name = "MultiMedia1";
On Mon, Jul 30, 2018 at 03:40:52PM +0530, Rohit kumar wrote:
Remove qcom prefix from machine driver dt bindings of apq8096 SoC.
Acked-by: Srinivas Kandagatla srinivas.kandagatla@linaro.org Signed-off-by: Rohit kumar rohitkr@codeaurora.org
Documentation/devicetree/bindings/sound/qcom,apq8096.txt | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-)
Reviewed-by: Rob Herring robh@kernel.org
This adds support to parse cpu, platform and codec device nodes and add them in dai-links. Also, update apq8096 machine driver to use the common API.
Acked-by: Srinivas Kandagatla srinivas.kandagatla@linaro.org Signed-off-by: Rohit kumar rohitkr@codeaurora.org --- sound/soc/qcom/Makefile | 2 +- sound/soc/qcom/apq8096.c | 111 +++++----------------------------------------- sound/soc/qcom/common.c | 112 +++++++++++++++++++++++++++++++++++++++++++++++ sound/soc/qcom/common.h | 12 +++++ 4 files changed, 136 insertions(+), 101 deletions(-) create mode 100644 sound/soc/qcom/common.c create mode 100644 sound/soc/qcom/common.h
diff --git a/sound/soc/qcom/Makefile b/sound/soc/qcom/Makefile index 206945b..fefecc0 100644 --- a/sound/soc/qcom/Makefile +++ b/sound/soc/qcom/Makefile @@ -13,7 +13,7 @@ obj-$(CONFIG_SND_SOC_LPASS_APQ8016) += snd-soc-lpass-apq8016.o # Machine snd-soc-storm-objs := storm.o snd-soc-apq8016-sbc-objs := apq8016_sbc.o -snd-soc-apq8096-objs := apq8096.o +snd-soc-apq8096-objs := apq8096.o common.o
obj-$(CONFIG_SND_SOC_STORM) += snd-soc-storm.o obj-$(CONFIG_SND_SOC_APQ8016_SBC) += snd-soc-apq8016-sbc.o diff --git a/sound/soc/qcom/apq8096.c b/sound/soc/qcom/apq8096.c index a561562..1e4a90d 100644 --- a/sound/soc/qcom/apq8096.c +++ b/sound/soc/qcom/apq8096.c @@ -9,6 +9,7 @@ #include <sound/soc.h> #include <sound/soc-dapm.h> #include <sound/pcm.h> +#include "common.h"
static int apq8096_be_hw_params_fixup(struct snd_soc_pcm_runtime *rtd, struct snd_pcm_hw_params *params) @@ -24,109 +25,16 @@ static int apq8096_be_hw_params_fixup(struct snd_soc_pcm_runtime *rtd, return 0; }
-static int apq8096_sbc_parse_of(struct snd_soc_card *card) +static void apq8096_add_be_ops(struct snd_soc_card *card) { - struct device_node *np; - struct device_node *codec = NULL; - struct device_node *platform = NULL; - struct device_node *cpu = NULL; - struct device *dev = card->dev; - struct snd_soc_dai_link *link; - int ret, num_links; - - ret = snd_soc_of_parse_card_name(card, "qcom,model"); - if (ret) { - dev_err(dev, "Error parsing card name: %d\n", ret); - return ret; - } - - /* DAPM routes */ - if (of_property_read_bool(dev->of_node, "qcom,audio-routing")) { - ret = snd_soc_of_parse_audio_routing(card, - "qcom,audio-routing"); - if (ret) - return ret; - } - - /* Populate links */ - num_links = of_get_child_count(dev->of_node); - - /* Allocate the DAI link array */ - card->dai_link = kcalloc(num_links, sizeof(*link), GFP_KERNEL); - if (!card->dai_link) - return -ENOMEM; + struct snd_soc_dai_link *link = card->dai_link; + int i, num_links = card->num_links;
- card->num_links = num_links; - link = card->dai_link; - - for_each_child_of_node(dev->of_node, np) { - cpu = of_get_child_by_name(np, "cpu"); - if (!cpu) { - dev_err(dev, "Can't find cpu DT node\n"); - ret = -EINVAL; - goto err; - } - - link->cpu_of_node = of_parse_phandle(cpu, "sound-dai", 0); - if (!link->cpu_of_node) { - dev_err(card->dev, "error getting cpu phandle\n"); - ret = -EINVAL; - goto err; - } - - ret = snd_soc_of_get_dai_name(cpu, &link->cpu_dai_name); - if (ret) { - dev_err(card->dev, "error getting cpu dai name\n"); - goto err; - } - - platform = of_get_child_by_name(np, "platform"); - codec = of_get_child_by_name(np, "codec"); - if (codec && platform) { - link->platform_of_node = of_parse_phandle(platform, - "sound-dai", - 0); - if (!link->platform_of_node) { - dev_err(card->dev, "platform dai not found\n"); - ret = -EINVAL; - goto err; - } - - ret = snd_soc_of_get_dai_link_codecs(dev, codec, link); - if (ret < 0) { - dev_err(card->dev, "codec dai not found\n"); - goto err; - } - link->no_pcm = 1; - link->ignore_pmdown_time = 1; + for (i = 0; i < num_links; i++) { + if (link->no_pcm == 1) link->be_hw_params_fixup = apq8096_be_hw_params_fixup; - } else { - link->platform_of_node = link->cpu_of_node; - link->codec_dai_name = "snd-soc-dummy-dai"; - link->codec_name = "snd-soc-dummy"; - link->dynamic = 1; - } - - link->ignore_suspend = 1; - ret = of_property_read_string(np, "link-name", &link->name); - if (ret) { - dev_err(card->dev, "error getting codec dai_link name\n"); - goto err; - } - - link->dpcm_playback = 1; - link->dpcm_capture = 1; - link->stream_name = link->name; link++; } - - return 0; -err: - of_node_put(cpu); - of_node_put(codec); - of_node_put(platform); - kfree(card->dai_link); - return ret; }
static int apq8096_platform_probe(struct platform_device *pdev) @@ -142,18 +50,21 @@ static int apq8096_platform_probe(struct platform_device *pdev) card->dev = dev; card->auto_bind = true; dev_set_drvdata(dev, card); - ret = apq8096_sbc_parse_of(card); + ret = qcom_snd_parse_of(card); if (ret) { dev_err(dev, "Error parsing OF data\n"); goto err; }
+ apq8096_add_be_ops(card); ret = snd_soc_register_card(card); if (ret) - goto err; + goto err_card_register;
return 0;
+err_card_register: + kfree(card->dai_link); err: kfree(card); return ret; diff --git a/sound/soc/qcom/common.c b/sound/soc/qcom/common.c new file mode 100644 index 0000000..eb1b9da --- /dev/null +++ b/sound/soc/qcom/common.c @@ -0,0 +1,112 @@ +// SPDX-License-Identifier: GPL-2.0 +// Copyright (c) 2018, Linaro Limited. +// Copyright (c) 2018, The Linux Foundation. All rights reserved. + +#include <linux/module.h> +#include "common.h" + +int qcom_snd_parse_of(struct snd_soc_card *card) +{ + struct device_node *np; + struct device_node *codec = NULL; + struct device_node *platform = NULL; + struct device_node *cpu = NULL; + struct device *dev = card->dev; + struct snd_soc_dai_link *link; + int ret, num_links; + + ret = snd_soc_of_parse_card_name(card, "model"); + if (ret) { + dev_err(dev, "Error parsing card name: %d\n", ret); + return ret; + } + + /* DAPM routes */ + if (of_property_read_bool(dev->of_node, "audio-routing")) { + ret = snd_soc_of_parse_audio_routing(card, + "audio-routing"); + if (ret) + return ret; + } + + /* Populate links */ + num_links = of_get_child_count(dev->of_node); + + /* Allocate the DAI link array */ + card->dai_link = kcalloc(num_links, sizeof(*link), GFP_KERNEL); + if (!card->dai_link) + return -ENOMEM; + + card->num_links = num_links; + link = card->dai_link; + for_each_child_of_node(dev->of_node, np) { + cpu = of_get_child_by_name(np, "cpu"); + if (!cpu) { + dev_err(dev, "Can't find cpu DT node\n"); + ret = -EINVAL; + goto err; + } + + link->cpu_of_node = of_parse_phandle(cpu, "sound-dai", 0); + if (!link->cpu_of_node) { + dev_err(card->dev, "error getting cpu phandle\n"); + ret = -EINVAL; + goto err; + } + + ret = snd_soc_of_get_dai_name(cpu, &link->cpu_dai_name); + if (ret) { + dev_err(card->dev, "error getting cpu dai name\n"); + goto err; + } + + platform = of_get_child_by_name(np, "platform"); + codec = of_get_child_by_name(np, "codec"); + if (codec && platform) { + link->platform_of_node = of_parse_phandle(platform, + "sound-dai", + 0); + if (!link->platform_of_node) { + dev_err(card->dev, "platform dai not found\n"); + ret = -EINVAL; + goto err; + } + + ret = snd_soc_of_get_dai_link_codecs(dev, codec, link); + if (ret < 0) { + dev_err(card->dev, "codec dai not found\n"); + goto err; + } + link->no_pcm = 1; + link->ignore_pmdown_time = 1; + } else { + link->platform_of_node = link->cpu_of_node; + link->codec_dai_name = "snd-soc-dummy-dai"; + link->codec_name = "snd-soc-dummy"; + link->dynamic = 1; + } + + link->ignore_suspend = 1; + ret = of_property_read_string(np, "link-name", &link->name); + if (ret) { + dev_err(card->dev, "error getting codec dai_link name\n"); + goto err; + } + + link->dpcm_playback = 1; + link->dpcm_capture = 1; + link->stream_name = link->name; + link++; + } + + return 0; +err: + of_node_put(cpu); + of_node_put(codec); + of_node_put(platform); + kfree(card->dai_link); + return ret; +} +EXPORT_SYMBOL(qcom_snd_parse_of); + +MODULE_LICENSE("GPL v2"); diff --git a/sound/soc/qcom/common.h b/sound/soc/qcom/common.h new file mode 100644 index 0000000..ad5d2cf --- /dev/null +++ b/sound/soc/qcom/common.h @@ -0,0 +1,12 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +// Copyright (c) 2018, The Linux Foundation. All rights reserved. + +#ifndef __QCOM_SND_COMMON_H__ +#define __QCOM_SND_COMMON_H__ + +#include <linux/component.h> +#include <sound/soc.h> + +int qcom_snd_parse_of(struct snd_soc_card *card); + +#endif
This patch adds sdm845 audio machine driver support.
Acked-by: Srinivas Kandagatla srinivas.kandagatla@linaro.org Signed-off-by: Rohit kumar rohitkr@codeaurora.org --- sound/soc/qcom/Kconfig | 8 ++ sound/soc/qcom/Makefile | 2 + sound/soc/qcom/sdm845.c | 286 ++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 296 insertions(+) create mode 100644 sound/soc/qcom/sdm845.c
diff --git a/sound/soc/qcom/Kconfig b/sound/soc/qcom/Kconfig index 87838fa..3507308 100644 --- a/sound/soc/qcom/Kconfig +++ b/sound/soc/qcom/Kconfig @@ -90,3 +90,11 @@ config SND_SOC_MSM8996 Support for Qualcomm Technologies LPASS audio block in APQ8096 SoC-based systems. Say Y if you want to use audio device on this SoCs + +config SND_SOC_SDM845 + tristate "SoC Machine driver for SDM845 boards" + select SND_SOC_QDSP6 + help + To add support for audio on Qualcomm Technologies Inc. + SDM845 SoC-based systems. + Say Y if you want to use audio device on this SoCs. diff --git a/sound/soc/qcom/Makefile b/sound/soc/qcom/Makefile index fefecc0..f0e94d4 100644 --- a/sound/soc/qcom/Makefile +++ b/sound/soc/qcom/Makefile @@ -14,10 +14,12 @@ obj-$(CONFIG_SND_SOC_LPASS_APQ8016) += snd-soc-lpass-apq8016.o snd-soc-storm-objs := storm.o snd-soc-apq8016-sbc-objs := apq8016_sbc.o snd-soc-apq8096-objs := apq8096.o common.o +snd-soc-sdm845-objs := sdm845.o common.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_SDM845) += snd-soc-sdm845.o
#DSP lib obj-$(CONFIG_SND_SOC_QDSP6) += qdsp6/ diff --git a/sound/soc/qcom/sdm845.c b/sound/soc/qcom/sdm845.c new file mode 100644 index 0000000..a4fbcf5 --- /dev/null +++ b/sound/soc/qcom/sdm845.c @@ -0,0 +1,286 @@ +// SPDX-License-Identifier: GPL-2.0 +/* + * Copyright (c) 2018, The Linux Foundation. All rights reserved. + */ + +#include <linux/module.h> +#include <linux/platform_device.h> +#include <linux/atomic.h> +#include <linux/of_device.h> +#include <sound/pcm.h> +#include <sound/pcm_params.h> +#include <linux/soc/qcom/apr.h> +#include "common.h" +#include "qdsp6/q6afe.h" + +#define DEFAULT_SAMPLE_RATE_48K 48000 +#define DEFAULT_MCLK_RATE 24576000 +#define DEFAULT_BCLK_RATE 12288000 + +struct sdm845_snd_data { + struct snd_soc_card *card; + uint32_t pri_mi2s_clk_count; + uint32_t quat_tdm_clk_count; +}; + +static unsigned int tdm_slot_offset[8] = {0, 4, 8, 12, 16, 20, 24, 28}; + +static int sdm845_tdm_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 = rtd->cpu_dai; + int ret = 0; + int channels, slot_width; + + switch (params_format(params)) { + case SNDRV_PCM_FORMAT_S16_LE: + slot_width = 32; + break; + default: + dev_err(rtd->dev, "%s: invalid param format 0x%x\n", + __func__, params_format(params)); + return -EINVAL; + } + + channels = params_channels(params); + if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) { + ret = snd_soc_dai_set_tdm_slot(cpu_dai, 0, 0x3, + 8, slot_width); + if (ret < 0) { + dev_err(rtd->dev, "%s: failed to set tdm slot, err:%d\n", + __func__, ret); + goto end; + } + + ret = snd_soc_dai_set_channel_map(cpu_dai, 0, NULL, + channels, tdm_slot_offset); + if (ret < 0) { + dev_err(rtd->dev, "%s: failed to set channel map, err:%d\n", + __func__, ret); + goto end; + } + } else { + ret = snd_soc_dai_set_tdm_slot(cpu_dai, 0xf, 0, + 8, slot_width); + if (ret < 0) { + dev_err(rtd->dev, "%s: failed to set tdm slot, err:%d\n", + __func__, ret); + goto end; + } + + ret = snd_soc_dai_set_channel_map(cpu_dai, channels, + tdm_slot_offset, 0, NULL); + if (ret < 0) { + dev_err(rtd->dev, "%s: failed to set channel map, err:%d\n", + __func__, ret); + goto end; + } + } +end: + return ret; +} + +static int sdm845_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 = rtd->cpu_dai; + int ret = 0; + + switch (cpu_dai->id) { + case QUATERNARY_TDM_RX_0: + case QUATERNARY_TDM_TX_0: + ret = sdm845_tdm_snd_hw_params(substream, params); + break; + default: + pr_err("%s: invalid dai id 0x%x\n", __func__, cpu_dai->id); + break; + } + return ret; +} + +static int sdm845_snd_startup(struct snd_pcm_substream *substream) +{ + unsigned int fmt = SND_SOC_DAIFMT_CBS_CFS; + struct snd_soc_pcm_runtime *rtd = substream->private_data; + struct snd_soc_card *card = rtd->card; + struct sdm845_snd_data *data = snd_soc_card_get_drvdata(card); + struct snd_soc_dai *cpu_dai = rtd->cpu_dai; + + 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, + DEFAULT_BCLK_RATE, SNDRV_PCM_STREAM_PLAYBACK); + } + snd_soc_dai_set_fmt(cpu_dai, fmt); + break; + + case QUATERNARY_TDM_RX_0: + case QUATERNARY_TDM_TX_0: + if (++(data->quat_tdm_clk_count) == 1) { + snd_soc_dai_set_sysclk(cpu_dai, + Q6AFE_LPASS_CLK_ID_QUAD_TDM_IBIT, + DEFAULT_BCLK_RATE, SNDRV_PCM_STREAM_PLAYBACK); + } + break; + + default: + pr_err("%s: invalid dai id 0x%x\n", __func__, cpu_dai->id); + break; + } + return 0; +} + +static void sdm845_snd_shutdown(struct snd_pcm_substream *substream) +{ + struct snd_soc_pcm_runtime *rtd = substream->private_data; + struct snd_soc_card *card = rtd->card; + struct sdm845_snd_data *data = snd_soc_card_get_drvdata(card); + struct snd_soc_dai *cpu_dai = rtd->cpu_dai; + + 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 QUATERNARY_TDM_RX_0: + case QUATERNARY_TDM_TX_0: + if (--(data->quat_tdm_clk_count) == 0) { + snd_soc_dai_set_sysclk(cpu_dai, + Q6AFE_LPASS_CLK_ID_QUAD_TDM_IBIT, + 0, SNDRV_PCM_STREAM_PLAYBACK); + } + break; + + default: + pr_err("%s: invalid dai id 0x%x\n", __func__, cpu_dai->id); + break; + } +} + +static struct snd_soc_ops sdm845_be_ops = { + .hw_params = sdm845_snd_hw_params, + .startup = sdm845_snd_startup, + .shutdown = sdm845_snd_shutdown, +}; + +static int sdm845_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); + struct snd_mask *fmt = hw_param_mask(params, SNDRV_PCM_HW_PARAM_FORMAT); + + rate->min = rate->max = DEFAULT_SAMPLE_RATE_48K; + channels->min = channels->max = 2; + snd_mask_set(fmt, SNDRV_PCM_FORMAT_S16_LE); + + return 0; +} + +static void sdm845_add_be_ops(struct snd_soc_card *card) +{ + struct snd_soc_dai_link *link = card->dai_link; + int i, num_links = card->num_links; + + for (i = 0; i < num_links; i++) { + if (link->no_pcm == 1) { + link->ops = &sdm845_be_ops; + link->be_hw_params_fixup = sdm845_be_hw_params_fixup; + } + link++; + } +} + +static int sdm845_snd_platform_probe(struct platform_device *pdev) +{ + struct snd_soc_card *card; + struct sdm845_snd_data *data; + struct device *dev = &pdev->dev; + int ret; + + card = kzalloc(sizeof(*card), GFP_KERNEL); + if (!card) + return -ENOMEM; + + /* Allocate the private data */ + data = kzalloc(sizeof(*data), GFP_KERNEL); + if (!data) + return -ENOMEM; + + card->dev = dev; + card->auto_bind = true; + dev_set_drvdata(dev, card); + ret = qcom_snd_parse_of(card); + if (ret) { + dev_err(dev, "Error parsing OF data\n"); + goto parse_dt_fail; + } + + data->card = card; + snd_soc_card_set_drvdata(card, data); + + sdm845_add_be_ops(card); + ret = snd_soc_register_card(card); + if (ret) { + dev_err(dev, "Sound card registration failed\n"); + goto register_card_fail; + } + return ret; + +register_card_fail: + kfree(card->dai_link); +parse_dt_fail: + kfree(data); + kfree(card); + return ret; +} + +static int sdm845_snd_platform_remove(struct platform_device *pdev) +{ + struct snd_soc_card *card = dev_get_drvdata(&pdev->dev); + struct sdm845_snd_data *data = snd_soc_card_get_drvdata(card); + + card->auto_bind = false; + snd_soc_unregister_card(card); + kfree(card->dai_link); + kfree(data); + kfree(card); + return 0; +} + +static const struct of_device_id sdm845_snd_device_id[] = { + { .compatible = "qcom,sdm845-sndcard" }, + {}, +}; +MODULE_DEVICE_TABLE(of, sdm845_snd_device_id); + +static struct platform_driver sdm845_snd_driver = { + .probe = sdm845_snd_platform_probe, + .remove = sdm845_snd_platform_remove, + .driver = { + .name = "msm-snd-sdm845", + .of_match_table = sdm845_snd_device_id, + }, +}; +module_platform_driver(sdm845_snd_driver); + +MODULE_DESCRIPTION("sdm845 ASoC Machine Driver"); +MODULE_LICENSE("GPL v2");
Hi Rohit,
Thank you for the patch! Perhaps something to improve:
[auto build test WARNING on asoc/for-next] [also build test WARNING on next-20180731] [cannot apply to v4.18-rc7] [if your patch is applied to the wrong git tree, please drop us a note to help improve the system]
url: https://github.com/0day-ci/linux/commits/Rohit-kumar/Add-support-for-audio-o... base: https://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound.git for-next reproduce: # apt-get install sparse make ARCH=x86_64 allmodconfig make C=1 CF=-D__CHECK_ENDIAN__
sparse warnings: (new ones prefixed by >>)
sound/soc/qcom/sdm845.c:193:27: sparse: incorrect type in argument 2 (different base types) @@ expected unsigned int [unsigned] val @@ got restricted snd_unsigned int [unsigned] val @@
sound/soc/qcom/sdm845.c:193:27: expected unsigned int [unsigned] val sound/soc/qcom/sdm845.c:193:27: got restricted snd_pcm_format_t [usertype] <noident>
vim +193 sound/soc/qcom/sdm845.c
181 182 static int sdm845_be_hw_params_fixup(struct snd_soc_pcm_runtime *rtd, 183 struct snd_pcm_hw_params *params) 184 { 185 struct snd_interval *rate = hw_param_interval(params, 186 SNDRV_PCM_HW_PARAM_RATE); 187 struct snd_interval *channels = hw_param_interval(params, 188 SNDRV_PCM_HW_PARAM_CHANNELS); 189 struct snd_mask *fmt = hw_param_mask(params, SNDRV_PCM_HW_PARAM_FORMAT); 190 191 rate->min = rate->max = DEFAULT_SAMPLE_RATE_48K; 192 channels->min = channels->max = 2;
193 snd_mask_set(fmt, SNDRV_PCM_FORMAT_S16_LE);
194 195 return 0; 196 } 197
--- 0-DAY kernel test infrastructure Open Source Technology Center https://lists.01.org/pipermail/kbuild-all Intel Corporation
On Wed, 01 Aug 2018 05:46:48 +0200, kbuild test robot wrote:
Hi Rohit,
Thank you for the patch! Perhaps something to improve:
[auto build test WARNING on asoc/for-next] [also build test WARNING on next-20180731] [cannot apply to v4.18-rc7] [if your patch is applied to the wrong git tree, please drop us a note to help improve the system]
url: https://github.com/0day-ci/linux/commits/Rohit-kumar/Add-support-for-audio-o... base: https://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound.git for-next reproduce: # apt-get install sparse make ARCH=x86_64 allmodconfig make C=1 CF=-D__CHECK_ENDIAN__
sparse warnings: (new ones prefixed by >>)
sound/soc/qcom/sdm845.c:193:27: sparse: incorrect type in argument 2 (different base types) @@ expected unsigned int [unsigned] val @@ got restricted snd_unsigned int [unsigned] val @@
sound/soc/qcom/sdm845.c:193:27: expected unsigned int [unsigned] val sound/soc/qcom/sdm845.c:193:27: got restricted snd_pcm_format_t [usertype] <noident>
vim +193 sound/soc/qcom/sdm845.c
181 182 static int sdm845_be_hw_params_fixup(struct snd_soc_pcm_runtime *rtd, 183 struct snd_pcm_hw_params *params) 184 { 185 struct snd_interval *rate = hw_param_interval(params, 186 SNDRV_PCM_HW_PARAM_RATE); 187 struct snd_interval *channels = hw_param_interval(params, 188 SNDRV_PCM_HW_PARAM_CHANNELS); 189 struct snd_mask *fmt = hw_param_mask(params, SNDRV_PCM_HW_PARAM_FORMAT); 190 191 rate->min = rate->max = DEFAULT_SAMPLE_RATE_48K; 192 channels->min = channels->max = 2;
193 snd_mask_set(fmt, SNDRV_PCM_FORMAT_S16_LE);
FYI, we have introduced a new helper, snd_mask_set_format(), just for avoiding this sparse warning. It's already in Mark's for-next tree.
thanks,
Takashi
On 8/1/2018 10:20 AM, Takashi Iwai wrote:
On Wed, 01 Aug 2018 05:46:48 +0200, kbuild test robot wrote:
Hi Rohit,
Thank you for the patch! Perhaps something to improve:
[auto build test WARNING on asoc/for-next] [also build test WARNING on next-20180731] [cannot apply to v4.18-rc7] [if your patch is applied to the wrong git tree, please drop us a note to help improve the system]
url: https://github.com/0day-ci/linux/commits/Rohit-kumar/Add-support-for-audio-o... base: https://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound.git for-next reproduce: # apt-get install sparse make ARCH=x86_64 allmodconfig make C=1 CF=-D__CHECK_ENDIAN__
sparse warnings: (new ones prefixed by >>)
sound/soc/qcom/sdm845.c:193:27: sparse: incorrect type in argument 2 (different base types) @@ expected unsigned int [unsigned] val @@ got restricted snd_unsigned int [unsigned] val @@
sound/soc/qcom/sdm845.c:193:27: expected unsigned int [unsigned] val sound/soc/qcom/sdm845.c:193:27: got restricted snd_pcm_format_t [usertype] <noident>
vim +193 sound/soc/qcom/sdm845.c
181 182 static int sdm845_be_hw_params_fixup(struct snd_soc_pcm_runtime *rtd, 183 struct snd_pcm_hw_params *params) 184 { 185 struct snd_interval *rate = hw_param_interval(params, 186 SNDRV_PCM_HW_PARAM_RATE); 187 struct snd_interval *channels = hw_param_interval(params, 188 SNDRV_PCM_HW_PARAM_CHANNELS); 189 struct snd_mask *fmt = hw_param_mask(params, SNDRV_PCM_HW_PARAM_FORMAT); 190 191 rate->min = rate->max = DEFAULT_SAMPLE_RATE_48K; 192 channels->min = channels->max = 2;
193 snd_mask_set(fmt, SNDRV_PCM_FORMAT_S16_LE);
FYI, we have introduced a new helper, snd_mask_set_format(), just for avoiding this sparse warning. It's already in Mark's for-next tree.
Thanks Takashi for API suggestion. I will update in next spin.
thanks,
Takashi
participants (4)
-
kbuild test robot
-
Rob Herring
-
Rohit kumar
-
Takashi Iwai