Skip to contentSkip to conversation

ASoC: pcm: Require both CODEC and CPU support when declaring stream caps

PATCH In review Mark Brown 4 participants 5 messages Jun 1, 2013 – Jun 3, 2013

Subsystems (3)
lore
Share & tools
lore

Mark Brown

author
#0 lore raw

PATCH 1/1 ASoC: pcm: Require both CODEC and CPU support when declaring stream caps

When declaring playback and capture capabilities check for both CODEC side and CPU side support rather than only checking for CODEC side support. While it is unusual some CPUs do have unidirectional DAIs.

---
 sound/soc/soc-pcm.c |    6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)
sound/soc/soc-pcm.c +4 -2
index 73bb8ee..a9fddf0 100644
@@ -2011,9 +2011,11 @@ int soc_new_pcm(struct snd_soc_pcm_runtime *rtd, int num)
 		if (cpu_dai->driver->capture.channels_min)
 			capture = 1;
 	} else {
-		if (codec_dai->driver->playback.channels_min)
+		if (codec_dai->driver->playback.channels_min &&
+		    cpu_dai->driver->playback.channels_min)
 			playback = 1;
-		if (codec_dai->driver->capture.channels_min)
+		if (codec_dai->driver->capture.channels_min &&
+		    cpu_dai->driver->capture.channels_min)
 			capture = 1;
 	}
 
Signature · 1 line
1.7.10.4
reviewer
#1 lore raw

Hi Mark,

Quoted 5 lines · Mark Brown

When declaring playback and capture capabilities check for both CODEC side and CPU side support rather than only checking for CODEC side support. While it is unusual some CPUs do have unidirectional DAIs.

Thanks for the patch, but I still got the same output:

$ aplay -l
**** List of PLAYBACK Hardware Devices ****
card 0: mxssgtl5000 [mxs_sgtl5000], device 0: HiFi Playback sgtl5000-0 []
  Subdevices: 1/1
  Subdevice #0: subdevice #0
card 0: mxssgtl5000 [mxs_sgtl5000], device 1: HiFi Capture sgtl5000-1 []
  Subdevices: 1/1
  Subdevice #0: subdevice #0

I also tried:

sound/soc/mxs/mxs-saif.c +11 -12
index 365d9d2..b4a527d 100644
@@ -601,24 +601,21 @@ static const struct snd_soc_dai_ops mxs_saif_dai_ops = {
 	.set_fmt = mxs_saif_set_dai_fmt,
 };
 
-static int mxs_saif_dai_probe(struct snd_soc_dai *dai)
+static struct snd_soc_dai_driver mxs_saif_dai[] = {
 {
-	struct mxs_saif *saif = dev_get_drvdata(dai->dev);
-
-	snd_soc_dai_set_drvdata(dai, saif);
-
-	return 0;
-}
-
-static struct snd_soc_dai_driver mxs_saif_dai = {
-	.name = "mxs-saif",
-	.probe = mxs_saif_dai_probe,
+	.name = "saif0",
+	.id = 0,
 	.playback = {
 		.channels_min = 2,
 		.channels_max = 2,
 		.rates = MXS_SAIF_RATES,
 		.formats = MXS_SAIF_FORMATS,
 	},
+	.ops = &mxs_saif_dai_ops,
+},
+{
+	.name = "saif1",
+	.id = 1,
 	.capture = {
 		.channels_min = 2,
 		.channels_max = 2,
@@ -626,6 +623,7 @@ static struct snd_soc_dai_driver mxs_saif_dai = {
 		.formats = MXS_SAIF_FORMATS,
 	},
 	.ops = &mxs_saif_dai_ops,
+},
 };
 
 static irqreturn_t mxs_saif_irq(int irq, void *dev_id)
@@ -772,7 +770,8 @@ static int mxs_saif_probe(struct platform_device *pdev)
 
 	platform_set_drvdata(pdev, saif);
 
-	ret = snd_soc_register_dai(&pdev->dev, &mxs_saif_dai);
+	ret = snd_soc_register_dais(&pdev->dev, mxs_saif_dai,
+						ARRAY_SIZE(mxs_saif_dai));
 	if (ret) {
 		dev_err(&pdev->dev, "register DAI failed\n");
 		return ret;
Signature · 9 lines
1.8.1.2

,but this did not work either.

I will have to debug more.

Thanks,

Fabio Estevam
reviewer Tested-by on v1 1/1
#2 lore raw
In reply to Mark Brown

Hi Mark,

Quoted 5 lines · Mark Brown

When declaring playback and capture capabilities check for both CODEC side and CPU side support rather than only checking for CODEC side support. While it is unusual some CPUs do have unidirectional DAIs.

Now I got it working and your patch does fix the "aplay -l/arecord -l" issue that I reported earlier:

I also need to patch sound/soc/mxs/mxs-saif.c and will send a separate patch for this.

Thanks a lot, really appreaciated!

Fabio Estevam

maintainer
#3 lore raw
Quoted 2 lines · Fabio Estevam

Now I got it working and your patch does fix the "aplay -l/arecord -l" issue that I reported earlier:

Ah, excellent - thanks for testing!