All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] ASoC: Fail card instantiation if DAI format setup fails
@ 2019-07-24  9:38 Ricard Wanderlof
  2019-07-24 19:17 ` Applied "ASoC: Fail card instantiation if DAI format setup fails" to the asoc tree Mark Brown
  0 siblings, 1 reply; 2+ messages in thread
From: Ricard Wanderlof @ 2019-07-24  9:38 UTC (permalink / raw)
  To: Mark Brown, Liam Girdwood; +Cc: alsa-devel


If the DAI format setup fails, there is no valid communication format
between CPU and CODEC, so fail card instantiation, rather than continue
with a card that will most likely not function properly.

Signed-off-by: Ricard Wanderlof <ricardw@axis.com>
---

I've had the problem of a sound card coming up even though an incorrect 
DAI format was selected in the devicetree, apparently caused by not 
checking the return value of snd_soc_runtime_set_dai_fmt() when the card 
is instantiated, with the result in this particular case that that the 
audio data was not transferred correctly (capture data was shifted one bit 
up).

I'm unsure though if this is intentional, I can't think why it should be, 
since the DAI format is only set up at this time and not for instance 
later when a stream is enabled, but perhaps I'm missing something here.

At any rate, with this patch, the card does not come up under these 
circumstances. The error message from snd_soc_runtime_set_dai_fmt() is 
still printed to the kernel log so it's possible to see what the reason 
is.

/Ricard

 sound/soc/soc-core.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/sound/soc/soc-core.c b/sound/soc/soc-core.c
index 7ecfe641ca46..06697b2d96b1 100644
--- a/sound/soc/soc-core.c
+++ b/sound/soc/soc-core.c
@@ -1511,8 +1511,11 @@ static int soc_probe_link_dais(struct snd_soc_card *card,
 		}
 	}
 
-	if (dai_link->dai_fmt)
-		snd_soc_runtime_set_dai_fmt(rtd, dai_link->dai_fmt);
+	if (dai_link->dai_fmt) {
+		ret = snd_soc_runtime_set_dai_fmt(rtd, dai_link->dai_fmt);
+		if (ret)
+			return ret;
+	}
 
 	ret = soc_post_component_init(rtd, dai_link->name);
 	if (ret)
-- 
2.11.0


-- 
Ricard Wolf Wanderlof                           ricardw(at)axis.com
Axis Communications AB, Lund, Sweden            www.axis.com
Phone +46 46 272 2016                           Fax +46 46 13 61 30

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Applied "ASoC: Fail card instantiation if DAI format setup fails" to the asoc tree
  2019-07-24  9:38 [PATCH] ASoC: Fail card instantiation if DAI format setup fails Ricard Wanderlof
@ 2019-07-24 19:17 ` Mark Brown
  0 siblings, 0 replies; 2+ messages in thread
From: Mark Brown @ 2019-07-24 19:17 UTC (permalink / raw)
  To: Ricard Wanderlof; +Cc: alsa-devel, Mark Brown, Liam Girdwood, Ricard Wanderlof

The patch

   ASoC: Fail card instantiation if DAI format setup fails

has been applied to the asoc tree at

   https://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound.git for-5.3

All being well this means that it will be integrated into the linux-next
tree (usually sometime in the next 24 hours) and sent to Linus during
the next merge window (or sooner if it is a bug fix), however if
problems are discovered then the patch may be dropped or reverted.  

You may get further e-mails resulting from automated or manual testing
and review of the tree, please engage with people reporting problems and
send followup patches addressing any issues that are reported if needed.

If any updates are required or you are submitting further changes they
should be sent as incremental updates against current git, existing
patches will not be replaced.

Please add any relevant lists and maintainers to the CCs when replying
to this mail.

Thanks,
Mark

>From 40aa5383e393d72f6aa3943a4e7b1aae25a1e43b Mon Sep 17 00:00:00 2001
From: Ricard Wanderlof <ricard.wanderlof@axis.com>
Date: Wed, 24 Jul 2019 11:38:44 +0200
Subject: [PATCH] ASoC: Fail card instantiation if DAI format setup fails

If the DAI format setup fails, there is no valid communication format
between CPU and CODEC, so fail card instantiation, rather than continue
with a card that will most likely not function properly.

Signed-off-by: Ricard Wanderlof <ricardw@axis.com>
Link: https://lore.kernel.org/r/alpine.DEB.2.20.1907241132350.6338@lnxricardw1.se.axis.com
Signed-off-by: Mark Brown <broonie@kernel.org>
---
 sound/soc/soc-core.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/sound/soc/soc-core.c b/sound/soc/soc-core.c
index c0a774d0a5ff..1486fb2eb921 100644
--- a/sound/soc/soc-core.c
+++ b/sound/soc/soc-core.c
@@ -1511,8 +1511,11 @@ static int soc_probe_link_dais(struct snd_soc_card *card,
 		}
 	}
 
-	if (dai_link->dai_fmt)
-		snd_soc_runtime_set_dai_fmt(rtd, dai_link->dai_fmt);
+	if (dai_link->dai_fmt) {
+		ret = snd_soc_runtime_set_dai_fmt(rtd, dai_link->dai_fmt);
+		if (ret)
+			return ret;
+	}
 
 	ret = soc_post_component_init(rtd, dai_link->name);
 	if (ret)
-- 
2.20.1

^ permalink raw reply related	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2019-07-24 19:17 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-07-24  9:38 [PATCH] ASoC: Fail card instantiation if DAI format setup fails Ricard Wanderlof
2019-07-24 19:17 ` Applied "ASoC: Fail card instantiation if DAI format setup fails" to the asoc tree Mark Brown

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.