From: Sylwester Nawrocki <s.nawrocki@samsung.com>
To: broonie@kernel.org
Cc: lgirdwood@gmail.com, krzk@kernel.org, sbkim73@samsung.com,
m.szyprowski@samsung.com, b.zolnierkie@samsung.com,
alsa-devel@alsa-project.org, linux-kernel@vger.kernel.org,
linux-samsung-soc@vger.kernel.org,
Sylwester Nawrocki <s.nawrocki@samsung.com>
Subject: [PATCH 17/22] ASoC: samsung: odroid: Add support for secondary CPU DAI
Date: Thu, 07 Feb 2019 18:00:25 +0100 [thread overview]
Message-ID: <20190207170028.720-18-s.nawrocki@samsung.com> (raw)
In-Reply-To: <20190207170028.720-1-s.nawrocki@samsung.com>
This patch adds DPCM links in order to support the secondary I2S interface.
For the secondary PCM interface to be actually available one more entry
should be added to the sound-dai property in sound/cpu node in DT.
The changes in driver are done in a way so we are backwards compatible with
existing DTS/DTB, i.e. if the cpu sound-dai property contains only one entry
only one PCM will be registered.
Signed-off-by: Sylwester Nawrocki <s.nawrocki@samsung.com>
---
sound/soc/samsung/odroid.c | 132 +++++++++++++++++++++++++++----------
1 file changed, 96 insertions(+), 36 deletions(-)
diff --git a/sound/soc/samsung/odroid.c b/sound/soc/samsung/odroid.c
index e7b371b07230..bab61e8278a0 100644
--- a/sound/soc/samsung/odroid.c
+++ b/sound/soc/samsung/odroid.c
@@ -7,6 +7,7 @@
*/
#include <linux/clk.h>
+#include <linux/clk-provider.h>
#include <linux/of.h>
#include <linux/of_device.h>
#include <linux/module.h>
@@ -17,21 +18,24 @@
struct odroid_priv {
struct snd_soc_card card;
- struct snd_soc_dai_link dai_link;
-
struct clk *clk_i2s_bus;
struct clk *sclk_i2s;
};
-static int odroid_card_startup(struct snd_pcm_substream *substream)
+static int odroid_card_fe_startup(struct snd_pcm_substream *substream)
{
struct snd_pcm_runtime *runtime = substream->runtime;
snd_pcm_hw_constraint_single(runtime, SNDRV_PCM_HW_PARAM_CHANNELS, 2);
+
return 0;
}
-static int odroid_card_hw_params(struct snd_pcm_substream *substream,
+static const struct snd_soc_ops odroid_card_fe_ops = {
+ .startup = odroid_card_fe_startup,
+};
+
+static int odroid_card_be_hw_params(struct snd_pcm_substream *substream,
struct snd_pcm_hw_params *params)
{
struct snd_soc_pcm_runtime *rtd = substream->private_data;
@@ -86,19 +90,56 @@ static int odroid_card_hw_params(struct snd_pcm_substream *substream,
return 0;
}
-static const struct snd_soc_ops odroid_card_ops = {
- .startup = odroid_card_startup,
- .hw_params = odroid_card_hw_params,
+static const struct snd_soc_ops odroid_card_be_ops = {
+ .hw_params = odroid_card_be_hw_params,
+};
+
+static struct snd_soc_dai_link odroid_card_dais[] = {
+ {
+ /* Primary FE <-> BE link */
+ .codec_name = "snd-soc-dummy",
+ .codec_dai_name = "snd-soc-dummy-dai",
+ .ops = &odroid_card_fe_ops,
+ .name = "Primary",
+ .stream_name = "Primary",
+ .platform_name = "3830000.i2s",
+ .dynamic = 1,
+ .dpcm_playback = 1,
+ }, {
+ /* BE <-> CODECs link */
+ .name = "I2S Mixer",
+ .cpu_name = "snd-soc-dummy",
+ .cpu_dai_name = "snd-soc-dummy-dai",
+ .platform_name = "snd-soc-dummy",
+ .ops = &odroid_card_be_ops,
+ .no_pcm = 1,
+ .dpcm_playback = 1,
+ .dai_fmt = SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_NB_NF |
+ SND_SOC_DAIFMT_CBS_CFS,
+ }, {
+ /* Secondary FE <-> BE link */
+ .playback_only = 1,
+ .codec_name = "snd-soc-dummy",
+ .codec_dai_name = "snd-soc-dummy-dai",
+ .ops = &odroid_card_fe_ops,
+ .name = "Secondary",
+ .stream_name = "Secondary",
+ .platform_name = "samsung-i2s-sec",
+ .dynamic = 1,
+ .dpcm_playback = 1,
+ }
};
+
static int odroid_audio_probe(struct platform_device *pdev)
{
struct device *dev = &pdev->dev;
- struct device_node *cpu, *codec;
+ struct device_node *cpu, *cpu_dai, *codec;
struct odroid_priv *priv;
- struct snd_soc_dai_link *link;
struct snd_soc_card *card;
- int ret;
+ struct snd_soc_dai_link *link, *codec_link;
+ int num_pcms, ret, i;
+ struct of_phandle_args args = {};
priv = devm_kzalloc(dev, sizeof(*priv), GFP_KERNEL);
if (!priv)
@@ -130,45 +171,67 @@ static int odroid_audio_probe(struct platform_device *pdev)
return ret;
}
- link = &priv->dai_link;
-
- link->ops = &odroid_card_ops;
- link->dai_fmt = SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_NB_NF |
- SND_SOC_DAIFMT_CBS_CFS;
-
- card->dai_link = &priv->dai_link;
- card->num_links = 1;
+ card->dai_link = odroid_card_dais;
+ card->num_links = ARRAY_SIZE(odroid_card_dais);
cpu = of_get_child_by_name(dev->of_node, "cpu");
codec = of_get_child_by_name(dev->of_node, "codec");
+ link = card->dai_link;
+ codec_link = &card->dai_link[1];
- link->cpu_of_node = of_parse_phandle(cpu, "sound-dai", 0);
- if (!link->cpu_of_node) {
- dev_err(dev, "Failed parsing cpu/sound-dai property\n");
- return -EINVAL;
+ /*
+ * For backwards compatibility create the secondary CPU DAI link only
+ * if there are 2 CPU DAI entries in the cpu sound-dai property in DT.
+ */
+ num_pcms = of_count_phandle_with_args(cpu, "sound-dai",
+ "#sound-dai-cells");
+ if (num_pcms == 1)
+ card->num_links--;
+
+ for (i = 0; i < num_pcms; i++, link += 2) {
+ ret = of_parse_phandle_with_args(cpu, "sound-dai",
+ "#sound-dai-cells", i, &args);
+ if (ret < 0)
+ return ret;
+
+ if (!args.np) {
+ dev_err(dev, "sound-dai property parse error: %d\n", ret);
+ return -EINVAL;
+ }
+
+ ret = snd_soc_get_dai_name(&args, &link->cpu_dai_name);
+ of_node_put(args.np);
+
+ if (ret < 0)
+ return ret;
}
- ret = snd_soc_of_get_dai_link_codecs(dev, codec, link);
+ cpu_dai = of_parse_phandle(cpu, "sound-dai", 0);
+ of_node_put(cpu);
+ of_node_put(codec);
+
+ ret = snd_soc_of_get_dai_link_codecs(dev, codec, codec_link);
if (ret < 0)
goto err_put_codec_n;
- link->platform_of_node = link->cpu_of_node;
-
- link->name = "Primary";
- link->stream_name = link->name;
-
+ /* Set capture capability only for boards with the MAX98090 CODEC */
+ if (codec_link->num_codecs > 1) {
+ card->dai_link[0].dpcm_capture = 1;
+ card->dai_link[1].dpcm_capture = 1;
+ }
- priv->sclk_i2s = of_clk_get_by_name(link->cpu_of_node, "i2s_opclk1");
+ priv->sclk_i2s = of_clk_get_by_name(cpu_dai, "i2s_opclk1");
if (IS_ERR(priv->sclk_i2s)) {
ret = PTR_ERR(priv->sclk_i2s);
- goto err_put_i2s_n;
+ goto err_put_codec_n;
}
- priv->clk_i2s_bus = of_clk_get_by_name(link->cpu_of_node, "iis");
+ priv->clk_i2s_bus = of_clk_get_by_name(cpu_dai, "iis");
if (IS_ERR(priv->clk_i2s_bus)) {
ret = PTR_ERR(priv->clk_i2s_bus);
goto err_put_sclk;
}
+ of_node_put(cpu_dai);
ret = devm_snd_soc_register_card(dev, card);
if (ret < 0) {
@@ -182,10 +245,8 @@ static int odroid_audio_probe(struct platform_device *pdev)
clk_put(priv->clk_i2s_bus);
err_put_sclk:
clk_put(priv->sclk_i2s);
-err_put_i2s_n:
- of_node_put(link->cpu_of_node);
err_put_codec_n:
- snd_soc_of_put_dai_link_codecs(link);
+ snd_soc_of_put_dai_link_codecs(codec_link);
return ret;
}
@@ -193,8 +254,7 @@ static int odroid_audio_remove(struct platform_device *pdev)
{
struct odroid_priv *priv = platform_get_drvdata(pdev);
- of_node_put(priv->dai_link.cpu_of_node);
- snd_soc_of_put_dai_link_codecs(&priv->dai_link);
+ snd_soc_of_put_dai_link_codecs(&priv->card.dai_link[1]);
clk_put(priv->sclk_i2s);
clk_put(priv->clk_i2s_bus);
--
2.20.1
next prev parent reply other threads:[~2019-02-07 17:01 UTC|newest]
Thread overview: 53+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <CGME20190207170044epcas2p3d00762663b971845bc86db84af7d3b23@epcas2p3.samsung.com>
2019-02-07 17:00 ` [PATCH 00/22] ASoC: dmaengine updates, secondary CPU DAI for Odroid boards Sylwester Nawrocki
[not found] ` <CGME20190207170047epcas1p42d7ec4acfd976871c676efa5aecb33bc@epcas1p4.samsung.com>
2019-02-07 17:00 ` [PATCH 01/22] ASoC: dmaengine: Improve of_node test in dmaengine_pcm_request_chan_of() Sylwester Nawrocki
2019-02-11 13:29 ` Krzysztof Kozlowski
2019-02-12 16:58 ` Applied "ASoC: dmaengine: Improve of_node test in dmaengine_pcm_request_chan_of()" to the asoc tree Mark Brown
[not found] ` <CGME20190207170051epcas1p37a1acaef52cffb01af00c8d34dd9b1dd@epcas1p3.samsung.com>
2019-02-07 17:00 ` [PATCH 02/22] ASoC: dmaengine: Extend use of chan_names provided in custom DMA config Sylwester Nawrocki
2019-02-11 13:31 ` Krzysztof Kozlowski
2019-02-12 16:58 ` Applied "ASoC: dmaengine: Extend use of chan_names provided in custom DMA config" to the asoc tree Mark Brown
[not found] ` <CGME20190207170054epcas1p1e61320d308bc5be30187919f3360f501@epcas1p1.samsung.com>
2019-02-07 17:00 ` [PATCH 03/22] ASoC: samsung: dmaengine: Allow to specify custom DMA device Sylwester Nawrocki
2019-02-11 13:31 ` Krzysztof Kozlowski
2019-02-12 16:58 ` Applied "ASoC: samsung: dmaengine: Allow to specify custom DMA device" to the asoc tree Mark Brown
[not found] ` <CGME20190207170058epcas1p4e2fadf4aae2ece3c47c0750a094a4fbb@epcas1p4.samsung.com>
2019-02-07 17:00 ` [PATCH 04/22] ASoC: samsung: i2s: Fix prescaler setting for the secondary DAI Sylwester Nawrocki
2019-02-11 13:37 ` Krzysztof Kozlowski
2019-02-11 14:32 ` Sylwester Nawrocki
2019-02-11 15:03 ` Krzysztof Kozlowski
2019-02-12 16:58 ` Applied "ASoC: samsung: i2s: Fix prescaler setting for the secondary DAI" to the asoc tree Mark Brown
[not found] ` <CGME20190207170102epcas1p445f2a5d8e70bc3a6e42424034c2eb34a@epcas1p4.samsung.com>
2019-02-07 17:00 ` [PATCH 05/22] ASoC: samsung: i2s: Convert to single component with multiple DAIs Sylwester Nawrocki
2019-02-11 13:38 ` Krzysztof Kozlowski
2019-02-12 16:58 ` Applied "ASoC: samsung: i2s: Convert to single component with multiple DAIs" to the asoc tree Mark Brown
[not found] ` <CGME20190207170105epcas1p3d4a1da9ae268f8e95b32fb499e5a1dad@epcas1p3.samsung.com>
2019-02-07 17:00 ` [PATCH 06/22] ASoC: samsung: i2s: Restore support for the secondary PCM Sylwester Nawrocki
2019-02-11 13:41 ` Krzysztof Kozlowski
2019-02-11 14:50 ` Sylwester Nawrocki
[not found] ` <CGME20190207170109epcas1p20929934c01ae67a05cd6a56f13ed8486@epcas1p2.samsung.com>
2019-02-07 17:00 ` [PATCH 07/22] ASoC: samsung: i2s: Move clk supplier data to common driver data structure Sylwester Nawrocki
2019-02-11 13:41 ` Krzysztof Kozlowski
[not found] ` <CGME20190207170112epcas1p31ed740ef43d8a3eb71ca7245fba1bc3d@epcas1p3.samsung.com>
2019-02-07 17:00 ` [PATCH 08/22] ASoC: samsung: i2s: Add widgets and routes for DPCM support Sylwester Nawrocki
2019-02-11 13:42 ` Krzysztof Kozlowski
[not found] ` <CGME20190207170116epcas2p1e0768a74062c8af83842ddb59309850f@epcas2p1.samsung.com>
2019-02-07 17:00 ` [PATCH 09/22] ASoC: samsung: i2s: Move core clk to the driver common data structure Sylwester Nawrocki
2019-02-11 13:44 ` Krzysztof Kozlowski
[not found] ` <CGME20190207170120epcas1p211e1582a6124d6b7d0e33db6c0017480@epcas1p2.samsung.com>
2019-02-07 17:00 ` [PATCH 10/22] ASoC: samsung: i2s: Move opclk data to common driver " Sylwester Nawrocki
2019-02-11 13:44 ` Krzysztof Kozlowski
[not found] ` <CGME20190207170123epcas1p2fae464ba7f102d841548c5a523cc6660@epcas1p2.samsung.com>
2019-02-07 17:00 ` [PATCH 11/22] ASoC: samsung: i2s: Move registers cache " Sylwester Nawrocki
2019-02-11 13:45 ` Krzysztof Kozlowski
[not found] ` <CGME20190207170127epcas2p31da340c3f63e75e7bcb5c9c864a42173@epcas2p3.samsung.com>
2019-02-07 17:00 ` [PATCH 12/22] ASoC: samsung: i2s: Move SFR pointer " Sylwester Nawrocki
2019-02-11 13:46 ` Krzysztof Kozlowski
[not found] ` <CGME20190207170130epcas1p4809b7a8dc797ced2982dc3b305a0991b@epcas1p4.samsung.com>
2019-02-07 17:00 ` [PATCH 13/22] ASoC: samsung: i2s: Drop spinlock pointer from i2s_dai " Sylwester Nawrocki
2019-02-11 13:47 ` Krzysztof Kozlowski
[not found] ` <CGME20190207170134epcas2p1a22a5c2f680f33fe562fa22f3aec9e6a@epcas2p1.samsung.com>
2019-02-07 17:00 ` [PATCH 14/22] ASoC: samsung: i2s: Move IP variant data to common driver " Sylwester Nawrocki
2019-02-11 13:48 ` Krzysztof Kozlowski
[not found] ` <CGME20190207170138epcas2p31134b2beee877922d27fab5c79fdc7b1@epcas2p3.samsung.com>
2019-02-07 17:00 ` [PATCH 15/22] ASoC: samsung: i2s: Move quirks " Sylwester Nawrocki
2019-02-11 13:49 ` Krzysztof Kozlowski
[not found] ` <CGME20190207170141epcas1p29a038bfd0df69df10e916ea8a695a85b@epcas1p2.samsung.com>
2019-02-07 17:00 ` [PATCH 16/22] ASoC: samsung: i2s: Get rid of a static spinlock Sylwester Nawrocki
2019-02-11 13:51 ` Krzysztof Kozlowski
[not found] ` <CGME20190207170145epcas1p465da0715aa629b525c17d263c1b49a68@epcas1p4.samsung.com>
2019-02-07 17:00 ` Sylwester Nawrocki [this message]
2019-02-11 13:57 ` [PATCH 17/22] ASoC: samsung: odroid: Add support for secondary CPU DAI Krzysztof Kozlowski
2019-02-11 15:19 ` Sylwester Nawrocki
2019-02-11 15:34 ` Krzysztof Kozlowski
[not found] ` <CGME20190207170148epcas2p2e0f4a1e154cb8cd52d257978a669e84c@epcas2p2.samsung.com>
2019-02-07 17:00 ` [PATCH 18/22] ASoC: samsung: Specify DMA channel names through custom DMA config Sylwester Nawrocki
2019-02-11 13:58 ` Krzysztof Kozlowski
[not found] ` <CGME20190207170152epcas1p254264a82287a54dc2452f5e73daab13d@epcas1p2.samsung.com>
2019-02-07 17:00 ` [PATCH 19/22] ASoC: samsung: Drop DAI DMA data chan_name assignments Sylwester Nawrocki
2019-02-11 14:03 ` Krzysztof Kozlowski
[not found] ` <CGME20190207170155epcas1p42ba30c540d35290c010b5bfa4645e3b1@epcas1p4.samsung.com>
2019-02-07 17:00 ` [PATCH 20/22] ASoC: dmaengine: Remove unused SND_DMAENGINE_PCM_FLAG_CUSTOM_CHANNEL_NAME flag Sylwester Nawrocki
2019-02-11 14:04 ` Krzysztof Kozlowski
2019-02-12 16:40 ` [PATCH 00/22] ASoC: dmaengine updates, secondary CPU DAI for Odroid boards Mark Brown
2019-02-12 18:17 ` Sylwester Nawrocki
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20190207170028.720-18-s.nawrocki@samsung.com \
--to=s.nawrocki@samsung.com \
--cc=alsa-devel@alsa-project.org \
--cc=b.zolnierkie@samsung.com \
--cc=broonie@kernel.org \
--cc=krzk@kernel.org \
--cc=lgirdwood@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-samsung-soc@vger.kernel.org \
--cc=m.szyprowski@samsung.com \
--cc=sbkim73@samsung.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®