From: Daniel Baluta <daniel.baluta@oss.nxp.com>
To: broonie@kernel.org, alsa-devel@alsa-project.org, robh+dt@kernel.org
Cc: kuninori.morimoto.gx@renesas.com, spujar@nvidia.com,
tiwai@suse.com, perex@perex.cz, linux-kernel@vger.kernel.org,
linux-imx@nxp.com, devicetree@vger.kernel.org,
daniel.baluta@gmail.com
Subject: [PATCH 1/2] ASoC: simple-card: Introduce playback-only/capture only DAI link flags
Date: Tue, 1 Aug 2023 11:24:32 +0300 [thread overview]
Message-ID: <20230801082433.548206-2-daniel.baluta@oss.nxp.com> (raw)
In-Reply-To: <20230801082433.548206-1-daniel.baluta@oss.nxp.com>
From: Daniel Baluta <daniel.baluta@nxp.com>
We need this to signal that DAI link supports only 1 direction that
can only be either playback or capture.
Signed-off-by: Daniel Baluta <daniel.baluta@nxp.com>
---
include/sound/simple_card_utils.h | 5 +++++
sound/soc/generic/simple-card-utils.c | 27 +++++++++++++++++++++++++++
sound/soc/generic/simple-card.c | 10 ++++++++++
3 files changed, 42 insertions(+)
diff --git a/include/sound/simple_card_utils.h b/include/sound/simple_card_utils.h
index d1a95bc33c56..47d90edaf6fe 100644
--- a/include/sound/simple_card_utils.h
+++ b/include/sound/simple_card_utils.h
@@ -135,6 +135,11 @@ int asoc_simple_parse_daifmt(struct device *dev,
struct device_node *codec,
char *prefix,
unsigned int *retfmt);
+int asoc_simple_parse_link_direction(struct device *dev,
+ struct device_node *node,
+ char *prefix,
+ bool *is_playback_only,
+ bool *is_capture_only);
int asoc_simple_parse_tdm_width_map(struct device *dev, struct device_node *np,
struct asoc_simple_dai *dai);
diff --git a/sound/soc/generic/simple-card-utils.c b/sound/soc/generic/simple-card-utils.c
index 5b18a4af022f..e04d2995cf0b 100644
--- a/sound/soc/generic/simple-card-utils.c
+++ b/sound/soc/generic/simple-card-utils.c
@@ -115,6 +115,33 @@ int asoc_simple_parse_daifmt(struct device *dev,
}
EXPORT_SYMBOL_GPL(asoc_simple_parse_daifmt);
+int asoc_simple_parse_link_direction(struct device *dev, struct device_node *node, char *prefix,
+ bool *playback_only, bool *capture_only)
+{
+ bool is_playback_only = false;
+ bool is_capture_only = false;
+
+ if (!prefix)
+ prefix = "";
+
+ if (of_property_read_bool(node, "playback-only"))
+ is_playback_only = true;
+
+ if (of_property_read_bool(node, "capture-only"))
+ is_capture_only = true;
+
+ if (is_playback_only && is_capture_only) {
+ dev_err(dev, "Invalid configuration, both playback-only / capture-only are set\n");
+ return -EINVAL;
+ }
+
+ *playback_only = is_playback_only;
+ *capture_only = is_capture_only;
+
+ return 0;
+}
+EXPORT_SYMBOL_GPL(asoc_simple_parse_link_direction);
+
int asoc_simple_parse_tdm_width_map(struct device *dev, struct device_node *np,
struct asoc_simple_dai *dai)
{
diff --git a/sound/soc/generic/simple-card.c b/sound/soc/generic/simple-card.c
index 190f11366e84..1fb34a51636d 100644
--- a/sound/soc/generic/simple-card.c
+++ b/sound/soc/generic/simple-card.c
@@ -195,6 +195,7 @@ static int simple_link_init(struct asoc_simple_priv *priv,
{
struct device *dev = simple_priv_to_dev(priv);
struct snd_soc_dai_link *dai_link = simple_priv_to_link(priv, li->link);
+ bool is_playback_only, is_capture_only;
int ret;
ret = asoc_simple_parse_daifmt(dev, node, codec,
@@ -202,6 +203,15 @@ static int simple_link_init(struct asoc_simple_priv *priv,
if (ret < 0)
return 0;
+ ret = asoc_simple_parse_link_direction(dev, node, prefix,
+ &is_playback_only,
+ &is_capture_only);
+ if (ret < 0)
+ return 0;
+
+ dai_link->playback_only = is_playback_only;
+ dai_link->capture_only = is_capture_only;
+
dai_link->init = asoc_simple_dai_init;
dai_link->ops = &simple_ops;
--
2.25.1
next prev parent reply other threads:[~2023-08-01 8:25 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-08-01 8:24 [PATCH 0/2] ASoC: simple-card: Introduce playback-only/capture-only DAI link flags Daniel Baluta
2023-08-01 8:24 ` Daniel Baluta [this message]
2023-08-01 23:31 ` [PATCH 1/2] ASoC: simple-card: Introduce playback-only/capture only " Kuninori Morimoto
2023-08-02 7:54 ` Daniel Baluta
2023-08-01 8:24 ` [PATCH 2/2] ASoC: dt-bindings: simple-card: Document new DAI flags playback-only/capture-only Daniel Baluta
2023-08-01 19:09 ` Mark Brown
2023-08-11 19:12 ` Rob Herring
2023-08-13 17:25 ` Mark Brown
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=20230801082433.548206-2-daniel.baluta@oss.nxp.com \
--to=daniel.baluta@oss.nxp.com \
--cc=alsa-devel@alsa-project.org \
--cc=broonie@kernel.org \
--cc=daniel.baluta@gmail.com \
--cc=devicetree@vger.kernel.org \
--cc=kuninori.morimoto.gx@renesas.com \
--cc=linux-imx@nxp.com \
--cc=linux-kernel@vger.kernel.org \
--cc=perex@perex.cz \
--cc=robh+dt@kernel.org \
--cc=spujar@nvidia.com \
--cc=tiwai@suse.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;
as well as URLs for NNTP newsgroup(s).