All of lore.kernel.org
 help / color / mirror / Atom feed
From: Matt Flax <flatmax@flatmax.org>
To: lgirdwood@gmail.com, broonie@kernel.org, lars@metafoo.de,
	pierre-louis.bossart@linux.intel.com,
	alsa-devel@alsa-project.org
Cc: Matt Flax <flatmax@flatmax.org>
Subject: [PATCH] ASoC: snd_soc_dai_set_fmt add substream independence.
Date: Sat, 28 Mar 2020 12:58:31 +1100	[thread overview]
Message-ID: <20200328015831.6230-1-flatmax@flatmax.org> (raw)

This patch is aims to start a stronger discussion on allowing both CPU
and Codec dais to set formats independently based on direction.

Currently it is very difficult to change stream formats because there
is no way to specify it independently.

A previous discussion w.r.t. a codec's stream dependent format setting
required a codec's dai to be split. See here :
https://mailman.alsa-project.org/pipermail/alsa-devel/2020-March/164492.html

A previous discussion w.r.t. changing format based on the stream direction
w.r.t. a CPU's dai showed the difficulty in setting fmt based on
direection in thw hw_params function. See here :
https://mailman.alsa-project.org/pipermail/alsa-devel/2020-March/165101.html

It seems that it may be necessary to allow the stream direction as an
input argument to snd_soc_dai_set_fmt.

This patch is not complete, as there are many codecs and cpus which would
require this change. However this patch is aimed as a discussion point.

One example of a sound card which requires independent stream formats is
an isolated sound card, such as the Audio Injector Isolated sound card.
The magnetic isolation chips on the sound card require stream fomats to
be different because of digital latency variations on the I2S lines.

Signed-off-by: Matt Flax <flatmax@flatmax.org>
---
 include/sound/soc-dai.h | 4 ++--
 sound/soc/soc-core.c    | 5 +++--
 sound/soc/soc-dai.c     | 4 ++--
 3 files changed, 7 insertions(+), 6 deletions(-)

diff --git a/include/sound/soc-dai.h b/include/sound/soc-dai.h
index eaaeb00e9e84..5071e006389b 100644
--- a/include/sound/soc-dai.h
+++ b/include/sound/soc-dai.h
@@ -123,7 +123,7 @@ int snd_soc_dai_set_pll(struct snd_soc_dai *dai,
 int snd_soc_dai_set_bclk_ratio(struct snd_soc_dai *dai, unsigned int ratio);
 
 /* Digital Audio interface formatting */
-int snd_soc_dai_set_fmt(struct snd_soc_dai *dai, unsigned int fmt);
+int snd_soc_dai_set_fmt(struct snd_soc_dai *dai, unsigned int fmt, int stream);
 
 int snd_soc_dai_set_tdm_slot(struct snd_soc_dai *dai,
 	unsigned int tx_mask, unsigned int rx_mask, int slots, int slot_width);
@@ -186,7 +186,7 @@ struct snd_soc_dai_ops {
 	 * DAI format configuration
 	 * Called by soc_card drivers, normally in their hw_params.
 	 */
-	int (*set_fmt)(struct snd_soc_dai *dai, unsigned int fmt);
+	int (*set_fmt)(struct snd_soc_dai *dai, unsigned int fmt, int stream);
 	int (*xlate_tdm_slot_mask)(unsigned int slots,
 		unsigned int *tx_mask, unsigned int *rx_mask);
 	int (*set_tdm_slot)(struct snd_soc_dai *dai,
diff --git a/sound/soc/soc-core.c b/sound/soc/soc-core.c
index 068d809c349a..27a6f01dc2d3 100644
--- a/sound/soc/soc-core.c
+++ b/sound/soc/soc-core.c
@@ -1474,10 +1474,11 @@ int snd_soc_runtime_set_dai_fmt(struct snd_soc_pcm_runtime *rtd,
 	struct snd_soc_dai *cpu_dai = rtd->cpu_dai;
 	struct snd_soc_dai *codec_dai;
 	unsigned int i;
-	int ret;
+	int ret, stream;
 
 	for_each_rtd_codec_dai(rtd, i, codec_dai) {
-		ret = snd_soc_dai_set_fmt(codec_dai, dai_fmt);
+		int stream = 0;
+		ret = snd_soc_dai_set_fmt(codec_dai, dai_fmt, stream);
 		if (ret != 0 && ret != -ENOTSUPP) {
 			dev_warn(codec_dai->dev,
 				 "ASoC: Failed to set DAI format: %d\n", ret);
diff --git a/sound/soc/soc-dai.c b/sound/soc/soc-dai.c
index 51031e330179..1f8ee7875656 100644
--- a/sound/soc/soc-dai.c
+++ b/sound/soc/soc-dai.c
@@ -94,11 +94,11 @@ EXPORT_SYMBOL_GPL(snd_soc_dai_set_bclk_ratio);
  *
  * Configures the DAI hardware format and clocking.
  */
-int snd_soc_dai_set_fmt(struct snd_soc_dai *dai, unsigned int fmt)
+int snd_soc_dai_set_fmt(struct snd_soc_dai *dai, unsigned int fmt, int stream)
 {
 	if (dai->driver->ops->set_fmt == NULL)
 		return -ENOTSUPP;
-	return dai->driver->ops->set_fmt(dai, fmt);
+	return dai->driver->ops->set_fmt(dai, fmt, stream);
 }
 EXPORT_SYMBOL_GPL(snd_soc_dai_set_fmt);
 
-- 
2.20.1


             reply	other threads:[~2020-03-28  2:00 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-03-28  1:58 Matt Flax [this message]
2020-03-28  3:31 ` [PATCH] ASoC: snd_soc_dai_set_fmt add substream independence kbuild test robot
2020-03-28  3:44 ` kbuild test robot
2020-03-30 10:32 ` Mark Brown
2020-03-30 12:28   ` Matt Flax
2020-03-30 16:31     ` Mark Brown
2020-03-31  7:40       ` Matt Flax
2020-03-31 11:13         ` Mark Brown
2020-03-31 11:52           ` Matt Flax

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=20200328015831.6230-1-flatmax@flatmax.org \
    --to=flatmax@flatmax.org \
    --cc=alsa-devel@alsa-project.org \
    --cc=broonie@kernel.org \
    --cc=lars@metafoo.de \
    --cc=lgirdwood@gmail.com \
    --cc=pierre-louis.bossart@linux.intel.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.