From patchwork Tue Jul 1 07:47:59 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Benoit Cousson X-Patchwork-Id: 4457001 Return-Path: X-Original-To: patchwork-alsa-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 4784D9F26C for ; Tue, 1 Jul 2014 07:52:25 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 5CF2F2020F for ; Tue, 1 Jul 2014 07:52:24 +0000 (UTC) Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) by mail.kernel.org (Postfix) with ESMTP id 0E2912017D for ; Tue, 1 Jul 2014 07:52:23 +0000 (UTC) Received: by alsa0.perex.cz (Postfix, from userid 1000) id 117A82657A2; Tue, 1 Jul 2014 09:52:22 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,NO_DNS_FOR_FROM, UNPARSEABLE_RELAY autolearn=no version=3.3.1 Received: from alsa0.perex.cz (localhost [IPv6:::1]) by alsa0.perex.cz (Postfix) with ESMTP id 91ACD26571D; Tue, 1 Jul 2014 09:49:26 +0200 (CEST) X-Original-To: alsa-devel@alsa-project.org Delivered-To: alsa-devel@alsa-project.org Received: by alsa0.perex.cz (Postfix, from userid 1000) id 5BA69265713; Tue, 1 Jul 2014 09:49:23 +0200 (CEST) Received: from mail-wg0-f43.google.com (mail-wg0-f43.google.com [74.125.82.43]) by alsa0.perex.cz (Postfix) with ESMTP id 795ED2656B4 for ; Tue, 1 Jul 2014 09:49:04 +0200 (CEST) Received: by mail-wg0-f43.google.com with SMTP id k14so341217wgh.2 for ; Tue, 01 Jul 2014 00:49:04 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=UTKmako7QYJJWVgbLz6lU2zxJjvjFyDio2RdgX/QGqQ=; b=LF+1N2DM29RqH+/PRBU1LzikmdXtLUo3uX3h/DFMlOrq/OULxWxZYtkEibBd8+eX0P FrYoZyRUt3QKyomI0UUIZRpe/VH4pvS62cInZ22v7wQi01NhhIte5NkdCmeBnmqBSt14 My1+wxvWrslq4l3svHyZzgp9HvUBH3kakp8zlhfQ2EWB8ydIL4+/2WhGV0Ao9gcOx8rb A0xZ96l3hK9G30zmYQyZt0FfEZ4PxfbSQlrYUaQbKdWczuus8MMNNbBlMLEAKRPqWaH5 aWic07fknT6VrwR1mdpkwbzSQFSZmzoJgTrwTDVCGvcnlEMySJgN/N+lw3lOjX4vq7s4 UqHw== X-Gm-Message-State: ALoCoQmXMGTQV0ZhOqAhDLH7vxfcyrL7ZNumBEw5eEgVamRqXGIIZHCZJCRQXlL0dm1/UsnuSPdr X-Received: by 10.194.92.148 with SMTP id cm20mr50802003wjb.57.1404200944235; Tue, 01 Jul 2014 00:49:04 -0700 (PDT) Received: from localhost.localdomain (lau06-1-82-228-246-9.fbx.proxad.net. [82.228.246.9]) by mx.google.com with ESMTPSA id bq7sm40353720wib.7.2014.07.01.00.49.02 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 01 Jul 2014 00:49:03 -0700 (PDT) From: Benoit Cousson To: broonie@kernel.org, lgirdwood@gmail.com, lars@metafoo.de Date: Tue, 1 Jul 2014 09:47:59 +0200 Message-Id: <1404200881-32253-7-git-send-email-bcousson@baylibre.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1404200881-32253-1-git-send-email-bcousson@baylibre.com> References: <1404200881-32253-1-git-send-email-bcousson@baylibre.com> Cc: misael.lopez@ti.com, alsa-devel@alsa-project.org, Benoit Cousson Subject: [alsa-devel] [PATCH v4 6/8] ASoC: compress: Add support for DAI multicodec X-BeenThere: alsa-devel@alsa-project.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "Alsa-devel mailing list for ALSA developers - http://www.alsa-project.org" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: alsa-devel-bounces@alsa-project.org Sender: alsa-devel-bounces@alsa-project.org X-Virus-Scanned: ClamAV using ClamSMTP Add multicodec support in soc-compress.c Signed-off-by: Benoit Cousson Cc: Misael Lopez Cruz --- 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: