Skip to contentSkip to conversation

ASoC: soc-pcm: Allow to specify unidirectional dai_link

PATCH Applied Fabio Estevam 2 participants 3 messages Aug 29, 2013 – Sep 1, 2013

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/2 ASoC: soc-pcm: Allow to specify unidirectional dai_link

Add 'playback_only' and 'capture_only' fields that can be used for specifying that a dai_link has a unidirectional capability.

The motivation for this is for the cases of systems, such as Freescale MX28, that has two unidirectional DAIs.

---
 include/sound/soc.h |  4 ++++
 sound/soc/soc-pcm.c | 10 ++++++++++
 2 files changed, 14 insertions(+)
include/sound/soc.h +4 -0
index 8e2ad52..774d3be 100644
@@ -934,6 +934,10 @@ struct snd_soc_dai_link {
 	/* machine stream operations */
 	const struct snd_soc_ops *ops;
 	const struct snd_soc_compr_ops *compr_ops;
+
+	/* For unidirectional dai links */
+	bool playback_only;
+	bool capture_only;
 };
 
 struct snd_soc_codec_conf {
sound/soc/soc-pcm.c +10 -0
index fb70fbe..5e44863 100644
@@ -2020,6 +2020,16 @@ int soc_new_pcm(struct snd_soc_pcm_runtime *rtd, int num)
 			capture = 1;
 	}
 
+	if (rtd->dai_link->playback_only) {
+		playback = 1;
+		capture = 0;
+	}
+
+	if (rtd->dai_link->capture_only) {
+		playback = 0;
+		capture = 1;
+	}
+
 	/* create the PCM */
 	if (rtd->dai_link->no_pcm) {
 		snprintf(new_name, sizeof(new_name), "(%s)",
Signature · 1 line
1.8.1.2
#1 lore raw

PATCH 2/2 ASoC: mxs-sgtl5000: Configure the dai_links as unidirectional

On a mx28 board, running "aplay -l" and "arecord -l" results in the following:

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

,which is not correct because we got a capture device listed in aplay and a playback device listed in arecord.

On mx28 there are two serial audio interface ports (SAIF0 and SAIF1) and each one of them are unidirectional.

Allow to specify a dai link as 'playback_only' or 'capture_only', which suits well for this case.

After this change we can correctly report the capabilities as follows:

$ 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
$ arecord -l
**** List of CAPTURE Hardware Devices ****
card 0: mxssgtl5000 [mxs_sgtl5000], device 1: HiFi Capture sgtl5000-1 []
  Subdevices: 1/1
  Subdevice #0: subdevice #0

Also tested playback and capture on the mx28evk board.

---
 sound/soc/mxs/mxs-sgtl5000.c | 2 ++
 1 file changed, 2 insertions(+)
sound/soc/mxs/mxs-sgtl5000.c +2 -0
index ce084eb..4bb2737 100644
@@ -105,11 +105,13 @@ static struct snd_soc_dai_link mxs_sgtl5000_dai[] = {
 		.stream_name	= "HiFi Playback",
 		.codec_dai_name	= "sgtl5000",
 		.ops		= &mxs_sgtl5000_hifi_ops,
+		.playback_only	= true,
 	}, {
 		.name		= "HiFi Rx",
 		.stream_name	= "HiFi Capture",
 		.codec_dai_name	= "sgtl5000",
 		.ops		= &mxs_sgtl5000_hifi_ops,
+		.capture_only	= true,
 	},
 };
 
Signature · 1 line
1.8.1.2
maintainer Applied
#2 lore raw
In reply to Fabio Estevam
Quoted 2 lines · Fabio Estevam

Add 'playback_only' and 'capture_only' fields that can be used for specifying that a dai_link has a unidirectional capability.

Applied both, thanks.