All of lore.kernel.org
 help / color / mirror / Atom feed
From: Benoit Cousson <bcousson@baylibre.com>
To: broonie@kernel.org, lgirdwood@gmail.com, lars@metafoo.de
Cc: misael.lopez@ti.com, alsa-devel@alsa-project.org,
	Benoit Cousson <bcousson@baylibre.com>
Subject: [PATCH v4 6/8] ASoC: compress: Add support for DAI multicodec
Date: Tue,  1 Jul 2014 09:47:59 +0200	[thread overview]
Message-ID: <1404200881-32253-7-git-send-email-bcousson@baylibre.com> (raw)
In-Reply-To: <1404200881-32253-1-git-send-email-bcousson@baylibre.com>

Add multicodec support in soc-compress.c

Signed-off-by: Benoit Cousson <bcousson@baylibre.com>
Cc: Misael Lopez Cruz <misael.lopez@ti.com>
---
 sound/soc/soc-compress.c | 94 ++++++++++++++++++++++++++++++------------------
 1 file changed, 59 insertions(+), 35 deletions(-)

diff --git a/sound/soc/soc-compress.c b/sound/soc/soc-compress.c
index f96fb96..cd65b12 100644
--- a/sound/soc/soc-compress.c
+++ b/sound/soc/soc-compress.c
@@ -155,14 +155,17 @@ static void close_delayed_work(struct work_struct *work)
 {
 	struct snd_soc_pcm_runtime *rtd =
 			container_of(work, struct snd_soc_pcm_runtime, delayed_work.work);
-	struct snd_soc_dai *codec_dai = rtd->codec_dai;
+	int i;
 
 	mutex_lock_nested(&rtd->pcm_mutex, rtd->pcm_subclass);
 
-	dev_dbg(rtd->dev, "ASoC: pop wq checking: %s status: %s waiting: %s\n",
-		 codec_dai->driver->playback.stream_name,
-		 codec_dai->playback_active ? "active" : "inactive",
-		 rtd->pop_wait ? "yes" : "no");
+	for (i = 0; i < rtd->num_codecs; i++) {
+		struct snd_soc_dai *codec_dai = rtd->codec_dais[i];
+		dev_dbg(rtd->dev, "ASoC: pop wq checking: %s status: %s waiting: %s\n",
+			 codec_dai->driver->playback.stream_name,
+			 codec_dai->playback_active ? "active" : "inactive",
+			 rtd->pop_wait ? "yes" : "no");
+	}
 
 	/* are we waiting on this codec DAI stream */
 	if (rtd->pop_wait == 1) {
@@ -179,8 +182,7 @@ static int soc_compr_free(struct snd_compr_stream *cstream)
 	struct snd_soc_pcm_runtime *rtd = cstream->private_data;
 	struct snd_soc_platform *platform = rtd->platform;
 	struct snd_soc_dai *cpu_dai = rtd->cpu_dai;
-	struct snd_soc_dai *codec_dai = rtd->codec_dai;
-	int stream;
+	int stream, i;
 
 	mutex_lock_nested(&rtd->pcm_mutex, rtd->pcm_subclass);
 
@@ -191,14 +193,18 @@ static int soc_compr_free(struct snd_compr_stream *cstream)
 
 	snd_soc_runtime_deactivate(rtd, stream);
 
-	snd_soc_dai_digital_mute(codec_dai, 1, cstream->direction);
+	for (i = 0; i < rtd->num_codecs; i++) {
+		struct snd_soc_dai *codec_dai = rtd->codec_dais[i];
+
+		snd_soc_dai_digital_mute(codec_dai, 1, cstream->direction);
+
+		if (!codec_dai->active)
+			codec_dai->rate = 0;
+	}
 
 	if (!cpu_dai->active)
 		cpu_dai->rate = 0;
 
-	if (!codec_dai->active)
-		codec_dai->rate = 0;
-
 
 	if (rtd->dai_link->compr_ops && rtd->dai_link->compr_ops->shutdown)
 		rtd->dai_link->compr_ops->shutdown(cstream);
@@ -283,8 +289,7 @@ static int soc_compr_trigger(struct snd_compr_stream *cstream, int cmd)
 
 	struct snd_soc_pcm_runtime *rtd = cstream->private_data;
 	struct snd_soc_platform *platform = rtd->platform;
-	struct snd_soc_dai *codec_dai = rtd->codec_dai;
-	int ret = 0;
+	int i, ret = 0;
 
 	mutex_lock_nested(&rtd->pcm_mutex, rtd->pcm_subclass);
 
@@ -294,13 +299,19 @@ static int soc_compr_trigger(struct snd_compr_stream *cstream, int cmd)
 			goto out;
 	}
 
-	switch (cmd) {
-	case SNDRV_PCM_TRIGGER_START:
-		snd_soc_dai_digital_mute(codec_dai, 0, cstream->direction);
-		break;
-	case SNDRV_PCM_TRIGGER_STOP:
-		snd_soc_dai_digital_mute(codec_dai, 1, cstream->direction);
-		break;
+	for (i = 0; i < rtd->num_codecs; i++) {
+		struct snd_soc_dai *codec_dai = rtd->codec_dais[i];
+
+		switch (cmd) {
+		case SNDRV_PCM_TRIGGER_START:
+			snd_soc_dai_digital_mute(codec_dai, 0,
+						 cstream->direction);
+			break;
+		case SNDRV_PCM_TRIGGER_STOP:
+			snd_soc_dai_digital_mute(codec_dai, 1,
+						 cstream->direction);
+			break;
+		}
 	}
 
 out:
@@ -622,23 +633,33 @@ int soc_new_compress(struct snd_soc_pcm_runtime *rtd, int num)
 {
 	struct snd_soc_codec *codec = rtd->codec;
 	struct snd_soc_platform *platform = rtd->platform;
-	struct snd_soc_dai *codec_dai = rtd->codec_dai;
 	struct snd_soc_dai *cpu_dai = rtd->cpu_dai;
 	struct snd_compr *compr;
 	struct snd_pcm *be_pcm;
 	char new_name[64];
-	int ret = 0, direction = 0;
-
-	/* check client and interface hw capabilities */
-	snprintf(new_name, sizeof(new_name), "%s %s-%d",
-			rtd->dai_link->stream_name, codec_dai->name, num);
-
-	if (codec_dai->driver->playback.channels_min)
-		direction = SND_COMPRESS_PLAYBACK;
-	else if (codec_dai->driver->capture.channels_min)
-		direction = SND_COMPRESS_CAPTURE;
-	else
-		return -EINVAL;
+	int i, ret = 0, direction = -1;
+
+	for (i = 0; i < rtd->num_codecs; i++) {
+		struct snd_soc_dai *codec_dai = rtd->codec_dais[i];
+		/* check client and interface hw capabilities */
+		snprintf(new_name, sizeof(new_name), "%s %s-%d",
+			 rtd->dai_link->stream_name, codec_dai->name, num);
+
+		if (direction < 0) {
+			if (codec_dai->driver->playback.channels_min)
+				direction = SND_COMPRESS_PLAYBACK;
+			else if (codec_dai->driver->capture.channels_min)
+				direction = SND_COMPRESS_CAPTURE;
+			else
+				return -EINVAL;
+		} else {
+			if ((codec_dai->driver->playback.channels_min &&
+					direction != SND_COMPRESS_PLAYBACK) ||
+			    (codec_dai->driver->capture.channels_min &&
+					direction != SND_COMPRESS_CAPTURE))
+				return -EINVAL;
+		}
+	}
 
 	compr = kzalloc(sizeof(*compr), GFP_KERNEL);
 	if (compr == NULL) {
@@ -692,8 +713,11 @@ int soc_new_compress(struct snd_soc_pcm_runtime *rtd, int num)
 	rtd->compr = compr;
 	compr->private_data = rtd;
 
-	printk(KERN_INFO "compress asoc: %s <-> %s mapping ok\n", codec_dai->name,
-		cpu_dai->name);
+	for (i = 0; i < rtd->num_codecs; i++) {
+		struct snd_soc_dai *codec_dai = rtd->codec_dais[i];
+		printk(KERN_INFO "compress asoc: %s <-> %s mapping ok\n",
+		       codec_dai->name, cpu_dai->name);
+	}
 	return ret;
 
 compr_err:
-- 
1.9.1

  parent reply	other threads:[~2014-07-01  7:49 UTC|newest]

Thread overview: 43+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-07-01  7:47 [PATCH v4 0/8] ASoC: core: Add support for DAI multicodec Benoit Cousson
2014-07-01  7:47 ` [PATCH v4 1/8] ASoC: core: Change soc_link_dai_widgets signature for multiple codecs Benoit Cousson
2014-07-01 17:17   ` Mark Brown
2014-07-04 16:13     ` Benoit Cousson
2014-07-04 16:51       ` Mark Brown
2014-07-01  7:47 ` [PATCH v4 2/8] ASoC: pcm: Refactor soc_pcm_apply_msb for multicodecs Benoit Cousson
2014-07-01 17:20   ` Mark Brown
2014-07-01 17:31     ` Benoit Cousson
2014-07-01  7:47 ` [PATCH v4 3/8] ASoC: core: Add initial support for DAI multicodec Benoit Cousson
2014-07-01 13:19   ` Lars-Peter Clausen
2014-07-01 17:27     ` Benoit Cousson
2014-07-01  7:47 ` [PATCH v4 4/8] ASoC: pcm: Add " Benoit Cousson
2014-07-01 13:32   ` Lars-Peter Clausen
2014-07-01  7:47 ` [PATCH v4 5/8] ASoC: dapm: " Benoit Cousson
2014-07-01 13:40   ` Lars-Peter Clausen
2014-07-01  7:47 ` Benoit Cousson [this message]
2014-07-01 13:49   ` [PATCH v4 6/8] ASoC: compress: " Lars-Peter Clausen
2014-07-01 16:25     ` Vinod Koul
2014-07-01 16:42       ` Lars-Peter Clausen
2014-07-01 16:45         ` Vinod Koul
2014-07-01 17:32       ` Benoit Cousson
2014-07-01 16:41   ` Vinod Koul
2014-07-01 17:41     ` Mark Brown
2014-07-03  6:39       ` Vinod Koul
2014-07-02 12:53     ` Benoit Cousson
2014-07-03  6:41       ` Vinod Koul
2014-07-03 11:09         ` Benoit Cousson
2014-07-03 11:16           ` Mark Brown
2014-07-03 11:20           ` Lars-Peter Clausen
2014-07-03 11:39             ` Benoit Cousson
2014-07-03 11:43               ` Lars-Peter Clausen
2014-07-03 11:46                 ` Benoit Cousson
2014-07-03 12:06                   ` Vinod Koul
2014-07-03 12:18                     ` Mark Brown
2014-07-03 16:15                       ` Vinod Koul
2014-07-03 18:23                         ` Lars-Peter Clausen
2014-07-04 13:55                           ` Benoit Cousson
2014-07-03 18:38                         ` Mark Brown
2014-07-03 19:09                           ` Pierre-Louis Bossart
2014-07-01  7:48 ` [PATCH v4 7/8] ASoC: pcm: Add soc_dai_hw_params helper Benoit Cousson
2014-07-01 13:43   ` Lars-Peter Clausen
2014-07-01  7:48 ` [PATCH v4 8/8] ASoC: core: Add a warning for link_dai_widget in the multicodec case Benoit Cousson
2014-07-01 13:41   ` Lars-Peter Clausen

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=1404200881-32253-7-git-send-email-bcousson@baylibre.com \
    --to=bcousson@baylibre.com \
    --cc=alsa-devel@alsa-project.org \
    --cc=broonie@kernel.org \
    --cc=lars@metafoo.de \
    --cc=lgirdwood@gmail.com \
    --cc=misael.lopez@ti.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.