From patchwork Wed Jun 27 09:48:18 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jerome Brunet X-Patchwork-Id: 10491087 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 03D0A60230 for ; Wed, 27 Jun 2018 09:48:43 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E490F28B11 for ; Wed, 27 Jun 2018 09:48:42 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id D8AC428B2D; Wed, 27 Jun 2018 09:48:42 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE,T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 1846228B11 for ; Wed, 27 Jun 2018 09:48:42 +0000 (UTC) Received: from alsa0.perex.cz (localhost [127.0.0.1]) by alsa0.perex.cz (Postfix) with ESMTP id 9A199267961; Wed, 27 Jun 2018 11:48:40 +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 D1D64267962; Wed, 27 Jun 2018 11:48:37 +0200 (CEST) Received: from mail-wr0-f195.google.com (mail-wr0-f195.google.com [209.85.128.195]) by alsa0.perex.cz (Postfix) with ESMTP id 475E52677C9 for ; Wed, 27 Jun 2018 11:48:34 +0200 (CEST) Received: by mail-wr0-f195.google.com with SMTP id t6-v6so1335793wrq.13 for ; Wed, 27 Jun 2018 02:48:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre-com.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id; bh=ZOZL8sv6qCH03Q+wXqoFv8CXlSKcTxDgCU0PUbCkIic=; b=TBiRB1rCC/H8kM1vnWAQMiCOAIHPgMJz0tRaVVSr6L4S57D/tsegWUDDtO5CW1MPNB lTPmZXPw3nU0fb7JrCX2mnVgpqLZszNf5MXH6SQ10LC19zc9h0nnOIhX6FT/EdXgPqeS Z7mDXAvtnYyinvG/tiwqyeL5/SKHR8x2O4Ukl5S45BgHG7pjONh19WXTWAyBXVM8CfKG 7pIjrK5lPvdaGuKFHqsx4AjQxqXTfQJHlhngq6erLD+jaODRiMLOGHMUvjuVP3R2QdoG mo8+Aa4bfvnqmNxxyBJ118iSR/Xd2DV0UbdfAg5li+OnrKFtZ8ib2MQAoWHI5bHD21rl nDOQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=ZOZL8sv6qCH03Q+wXqoFv8CXlSKcTxDgCU0PUbCkIic=; b=pB4Vdv3hl0/dw0ytbSEsl4rhrgHi98tYwoLcNUWmXr8YCXkmefrenAVuWGggtw8TMQ OtJQOH8DZ1TpKiJV1Xaj09wQ6w09qTlpAFaCqS4rWY74Kczg2XxiXaLLlRVZgbJwj0Mz NRG8rl9JiVcyEmyP82p3eUQ7hmAd1jKC+TKpXgPKcMlMsBpgXNicsJkOa5nUTTshxleT HFwyoX884s7draxO/AZP0ZwfSwUfTiDeg+zB6Ynhupm9jtjst3KuzoiQRe+elRfcDS77 UkYB7PAO1WhAHEqZ2InYDMBEaxVf0Xpr+OYfWdjEKi/D1xhLKF0rp64JcS9hN40un9/Q Y/zw== X-Gm-Message-State: APt69E33DygWVP6IH2MRIWsLaUywlONk7sqMd7AM0VqIpBSmYgAtYXkk lO0faTPq+hbt4ZD3ihEsXcxf5L0Y X-Google-Smtp-Source: AAOMgpdhgBK3wnyJOXkYq7fhKcQnTQRFUyymminQE4m5Nz87VYIdZuzJa2Rfm1QWCo+FpDG140Ebpg== X-Received: by 2002:adf:9226:: with SMTP id 35-v6mr1331238wrj.44.1530092913769; Wed, 27 Jun 2018 02:48:33 -0700 (PDT) Received: from boomer.baylibre.local ([90.63.244.31]) by smtp.googlemail.com with ESMTPSA id e13-v6sm5576824wrm.45.2018.06.27.02.48.32 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Wed, 27 Jun 2018 02:48:33 -0700 (PDT) From: Jerome Brunet To: Liam Girdwood , Mark Brown Date: Wed, 27 Jun 2018 11:48:18 +0200 Message-Id: <20180627094818.5885-1-jbrunet@baylibre.com> X-Mailer: git-send-email 2.14.4 Cc: Jiada Wang , alsa-devel@alsa-project.org, linux-kernel@vger.kernel.org, Jerome Brunet Subject: [alsa-devel] [PATCH] ASoC: dpcm: extend channel merging to the backend cpu dai 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 Extend dpcm_merge_chan to also check backend cpu dai channels capabilities. Apply the same policy as soc_pcm_init_runtime_hw() for multicodec links and only check cpu dai in this case. Cc: Jiada Wang Signed-off-by: Jerome Brunet --- Hi Mark, As you've probably noticed, this patch applies on top Jiada's patch pf4c277b817cc ("ASoC: soc-pcm: DPCM cares BE channel constraint") Regards. Jerome sound/soc/soc-pcm.c | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/sound/soc/soc-pcm.c b/sound/soc/soc-pcm.c index b82d9ff1f47e..5141409ccaed 100644 --- a/sound/soc/soc-pcm.c +++ b/sound/soc/soc-pcm.c @@ -1728,12 +1728,26 @@ static void dpcm_runtime_base_chan(struct snd_pcm_substream *substream, list_for_each_entry(dpcm, &fe->dpcm[stream].be_clients, list_be) { struct snd_soc_pcm_runtime *be = dpcm->be; + struct snd_soc_dai_driver *cpu_dai_drv = be->cpu_dai->driver; struct snd_soc_dai_driver *codec_dai_drv; struct snd_soc_pcm_stream *codec_stream; - int i; + struct snd_soc_pcm_stream *cpu_stream; + + if (stream == SNDRV_PCM_STREAM_PLAYBACK) + cpu_stream = &cpu_dai_drv->playback; + else + cpu_stream = &cpu_dai_drv->capture; + + *channels_min = max(*channels_min, cpu_stream->channels_min); + *channels_max = min(*channels_max, cpu_stream->channels_max); + + /* + * chan min/max cannot be enforced if there are multiple CODEC + * DAIs connected to a single CPU DAI, use CPU DAI's directly + */ + if (be->num_codecs == 1) { + codec_dai_drv = be->codec_dais[0]->driver; - for (i = 0; i < be->num_codecs; i++) { - codec_dai_drv = be->codec_dais[i]->driver; if (stream == SNDRV_PCM_STREAM_PLAYBACK) codec_stream = &codec_dai_drv->playback; else