From patchwork Wed Jul 24 16:24:00 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jerome Brunet X-Patchwork-Id: 169618 Delivered-To: patch@linaro.org Received: by 2002:a92:4782:0:0:0:0:0 with SMTP id e2csp10465018ilk; Wed, 24 Jul 2019 09:24:33 -0700 (PDT) X-Google-Smtp-Source: APXvYqwMfrWMfJM5Xg/0WUJy+kA4jNMm3K71B1PSp8aPlZa6x/FMEa/E6QDS1A0/9YdiGUg/nlcM X-Received: by 2002:a17:902:16f:: with SMTP id 102mr83514742plb.94.1563985473560; Wed, 24 Jul 2019 09:24:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1563985473; cv=none; d=google.com; s=arc-20160816; b=q9OM1zYEjieF5p92rysJ4GbYMxLyFC+/k6h+gQR3tAbcpwGXMETwwpzoOg3vB5VR3w JZ8GCIpln/PvugtP/nNsa1+JIRtw37llCiiq/zoN0O0s6YhbDyr5kCU9rIeKOIe+ydWk RgLEUnb+BNYNzj/OKLe4XWshR2Rn9J/Qw+YzXyN9Yua+7xFUuXH90YlOGHiquGfgoQMU 78qO6R/tAtC01lZy/TJ95FuofT/0NQtJREkYjy8XKIfWlElXQrM7TmyNFzz/GH4BFSK8 Qjn8396EkX/AxPw1ssQbGjUW34wfI8N3TvcSgIubxK7GvdC67fyalRyAjUzNcJmrymlD xwuQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=ocUEQSXynTuFhR8u/rePjf3f/sB3eXLVGjV4BtMdyVs=; b=TD7Mb3cjIOOFMlauZMEzscjyKodVe4+0BPgs+YVuBr1hiI+yRkuXcGSRKrRyBty1gu W7sQaNnjfNSvv/jNqBt6XqPFd0PYiCp9TbKE3KLSsX+bZHyEzgztntr2H+qhaxDmtUK1 T8fOFGD4o4OYqDCV9FsfYJDnqzwkmapNvBmxGfKnazhYZYidjvRz04rJ2+XVzea86zYc YkGIB4fPVRFW3Ld358gl089kUPp7I0AgGeNV+plW5QICBu0XGRV98p0eshJ7q9zI/3BD TOpoS9vK9uImJjce9+VA0pvlQpLj1g1Zmwd2MHtNEjFiVFCATl4N+0B+HXqn4K+hgfE8 tDgw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@baylibre-com.20150623.gappssmtp.com header.s=20150623 header.b=T0XHmH7f; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id k14si12860870pjq.53.2019.07.24.09.24.33; Wed, 24 Jul 2019 09:24:33 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@baylibre-com.20150623.gappssmtp.com header.s=20150623 header.b=T0XHmH7f; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728787AbfGXQYQ (ORCPT + 29 others); Wed, 24 Jul 2019 12:24:16 -0400 Received: from mail-wm1-f66.google.com ([209.85.128.66]:39215 "EHLO mail-wm1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728749AbfGXQYN (ORCPT ); Wed, 24 Jul 2019 12:24:13 -0400 Received: by mail-wm1-f66.google.com with SMTP id u25so31815946wmc.4 for ; Wed, 24 Jul 2019 09:24:11 -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:in-reply-to:references :mime-version:content-transfer-encoding; bh=ocUEQSXynTuFhR8u/rePjf3f/sB3eXLVGjV4BtMdyVs=; b=T0XHmH7fMTKgxRE+sBpYoKeEOwc7aBtGRsTgi4fQxLrOEfcW0U1YUrrDIw3Rn8GfcX lhkdzqNgssqMuQEo4DlEKUn+PqiRDTIY4NzwiQSGNCWQYJT4nWBscmNenvtx/y77qByz O8J4L/61kEPly3Vt5mbDYBXjERECUfgji3eBFFbA6oDgkOQBZ8258HWGNKxps1E1ytBc yhcCI72ckTJOjSU/9LYbSvhgbXuhl++XmTvK3k18dhhjOxg4/KAzDMeMlj+t7BdxUBl4 j/DDcIcHQnT2kaq7UbX8BV78x4zpvLXHqdaoHZc5oUhkEUtplY4+LLtmUNuYSRCw2Q2N fe6g== 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:in-reply-to :references:mime-version:content-transfer-encoding; bh=ocUEQSXynTuFhR8u/rePjf3f/sB3eXLVGjV4BtMdyVs=; b=MvlD32upCuzfc3n6Vci8W8jQzOjsYeOBsZOA5DX8DyYUkx24h/LrXnJWrxiFcqvt9p CMK34vqFQs7wxvZ/nG6etQpK/eWCtuZyf3AFX2PNtUhqWKDyXEY0NuHPHZSPgEvArTP3 EuuURSmub22TM7JYLmn4kvUjjdecnlC6BMTvK48oG/mNTRd0ZcLt9jNfEcyxQZMJW63f /eutasOWAaiOb/wu3LgcTvAE5a8AAbRyIMY6c+3+saG8MU1Pt6yz9btWGlMr+TyIK+60 hMAlsgpmu/aB5tGO3bvaVQhJRk3nl90usmvRPM7jPQpZJ11r/RbSOJk3nV5PqfDf/Yke ECCA== X-Gm-Message-State: APjAAAUs18wUklQBH6zUZyLIItsu4cbsty5RPI8ohVLU5nU4U6fy0sBF ynUgEYFKsfdkmqkUmGMa59/Idg== X-Received: by 2002:a1c:f409:: with SMTP id z9mr4986239wma.176.1563985450593; Wed, 24 Jul 2019 09:24:10 -0700 (PDT) Received: from starbuck.baylibre.local (lmontsouris-657-1-212-31.w90-63.abo.wanadoo.fr. [90.63.244.31]) by smtp.googlemail.com with ESMTPSA id f70sm55688960wme.22.2019.07.24.09.24.09 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Wed, 24 Jul 2019 09:24:09 -0700 (PDT) From: Jerome Brunet To: Mark Brown , Liam Girdwood , Kevin Hilman Cc: Jerome Brunet , alsa-devel@alsa-project.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-amlogic@lists.infradead.org Subject: [PATCH 1/6] ASoC: codec2codec: run callbacks in order Date: Wed, 24 Jul 2019 18:24:00 +0200 Message-Id: <20190724162405.6574-2-jbrunet@baylibre.com> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190724162405.6574-1-jbrunet@baylibre.com> References: <20190724162405.6574-1-jbrunet@baylibre.com> MIME-Version: 1.0 X-Patchwork-Bot: notify Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org When handling dai_link events on codec to codec links, run all .startup() callbacks on sinks and sources before running any .hw_params(). Same goes for hw_free() and shutdown(). This is closer to the behavior of regular dai links Signed-off-by: Jerome Brunet --- sound/soc/soc-dapm.c | 38 ++++++++++++++++++++++++++++---------- 1 file changed, 28 insertions(+), 10 deletions(-) -- 2.21.0 diff --git a/sound/soc/soc-dapm.c b/sound/soc/soc-dapm.c index 1d04612601ad..5348abda7ce2 100644 --- a/sound/soc/soc-dapm.c +++ b/sound/soc/soc-dapm.c @@ -3835,11 +3835,6 @@ static int snd_soc_dai_link_event(struct snd_soc_dapm_widget *w, goto out; } source->active++; - ret = snd_soc_dai_hw_params(source, &substream, params); - if (ret < 0) - goto out; - - dapm_update_dai_unlocked(&substream, params, source); } substream.stream = SNDRV_PCM_STREAM_PLAYBACK; @@ -3853,7 +3848,24 @@ static int snd_soc_dai_link_event(struct snd_soc_dapm_widget *w, goto out; } sink->active++; - ret = snd_soc_dai_hw_params(sink, &substream, params); + } + + substream.stream = SNDRV_PCM_STREAM_CAPTURE; + snd_soc_dapm_widget_for_each_source_path(w, path) { + source = path->source->priv; + + ret = soc_dai_hw_params(&substream, params, source); + if (ret < 0) + goto out; + + dapm_update_dai_unlocked(&substream, params, source); + } + + substream.stream = SNDRV_PCM_STREAM_PLAYBACK; + snd_soc_dapm_widget_for_each_sink_path(w, path) { + sink = path->sink->priv; + + ret = soc_dai_hw_params(&substream, params, sink); if (ret < 0) goto out; @@ -3889,9 +3901,18 @@ static int snd_soc_dai_link_event(struct snd_soc_dapm_widget *w, substream.stream = SNDRV_PCM_STREAM_CAPTURE; snd_soc_dapm_widget_for_each_source_path(w, path) { source = path->source->priv; - snd_soc_dai_hw_free(source, &substream); + } + substream.stream = SNDRV_PCM_STREAM_PLAYBACK; + snd_soc_dapm_widget_for_each_sink_path(w, path) { + sink = path->sink->priv; + snd_soc_dai_hw_free(sink, &substream); + } + + substream.stream = SNDRV_PCM_STREAM_CAPTURE; + snd_soc_dapm_widget_for_each_source_path(w, path) { + source = path->source->priv; source->active--; snd_soc_dai_shutdown(source, &substream); } @@ -3899,9 +3920,6 @@ static int snd_soc_dai_link_event(struct snd_soc_dapm_widget *w, substream.stream = SNDRV_PCM_STREAM_PLAYBACK; snd_soc_dapm_widget_for_each_sink_path(w, path) { sink = path->sink->priv; - - snd_soc_dai_hw_free(sink, &substream); - sink->active--; snd_soc_dai_shutdown(sink, &substream); } From patchwork Wed Jul 24 16:24:01 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jerome Brunet X-Patchwork-Id: 169617 Delivered-To: patch@linaro.org Received: by 2002:a92:4782:0:0:0:0:0 with SMTP id e2csp10464956ilk; Wed, 24 Jul 2019 09:24:30 -0700 (PDT) X-Google-Smtp-Source: APXvYqz3mlkjGpfHJqfhRBUbJbgbqhOiOA7ex3lgSqbIeeyhmPme8hi5fSlvQgDCkHhUh0Fc9jOt X-Received: by 2002:a63:6904:: with SMTP id e4mr21634333pgc.321.1563985470383; Wed, 24 Jul 2019 09:24:30 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1563985470; cv=none; d=google.com; s=arc-20160816; b=VWOfpOnk7NRJIpG4nvBeX+7J/OqHbux3+kbYiM8qDcfErM2kiWVnEGUhmfUYgEYT1Q MIzkMEqaU/Qmr986IAobUk0CCEPa51BVU61w7L3GMYqH2ODNBNXPHWqsFptCKutk8c+G QSFergUGp0y6gj+FplAwWe1meqVW7ODV//N/bumiGmIf39y3sA7XsBOCOF7WZtnLzHyV MbXxiJCrxLxgJRMns3K0rS9MmCMieKyFh0cPJDONE4F+v1ASiDAV3cEuEB5tLo8U/cax pCFiUyauwAR+OLsahM07I0VBvhq2NfB9QInKrkFPEwqnl5/CqMJ5rpb9209Y15AkRpoN +gyQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=Npvt6BnLoRE+ITNaKiuWjMdj+Jqxi0Z7NGG0xDY8eZY=; b=DU8NK1icPKfddU5oAL6jhFkYGhV6E4+1QmTNaw1AtMHyk9IEYEziYmaL2Grhr/FcZ2 M6hKhxsu0LI4To0ZZ1MOImr2T42gDRAQU4jJqKv9teCSuLTmKlPs796vPJYoKRO2vp5b p21FjQhc64M/EcGVA/OqseOuNRkxJjG6okTAF54JNJEzHTplXvl991wA9VQPRXTFpvAE rl5l4g7V6d2vNsDtPUzL1lhdC+3voCuXisPbNMbwNkjZ9vd82CHDT+VenmKRGacJsyG2 LPQpe/+WIJITn8ezlTcydk14e4m+vpNaUmLMGYiNcUEzc19k+kb82DhxfRPljxk6NIQ3 OnBg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@baylibre-com.20150623.gappssmtp.com header.s=20150623 header.b=PPUpu2Uk; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id k14si12860870pjq.53.2019.07.24.09.24.30; Wed, 24 Jul 2019 09:24:30 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@baylibre-com.20150623.gappssmtp.com header.s=20150623 header.b=PPUpu2Uk; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728799AbfGXQYS (ORCPT + 29 others); Wed, 24 Jul 2019 12:24:18 -0400 Received: from mail-wm1-f65.google.com ([209.85.128.65]:33504 "EHLO mail-wm1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728766AbfGXQYN (ORCPT ); Wed, 24 Jul 2019 12:24:13 -0400 Received: by mail-wm1-f65.google.com with SMTP id h19so33829681wme.0 for ; Wed, 24 Jul 2019 09:24:12 -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:in-reply-to:references :mime-version:content-transfer-encoding; bh=Npvt6BnLoRE+ITNaKiuWjMdj+Jqxi0Z7NGG0xDY8eZY=; b=PPUpu2UkVrvoFD58jMMOxwF8SwBcLWeMm6AdGHu32jkbpMAD7Eg35djpLxCBi2fMDx 0CxgU2P1kCEHKkMn4Elyn5ujwm+PeMd5CTF6eojwwGsHXP/nL1EgGvFdUZkSoRs+Bp96 MJMh/rpOXNtt8dBM2uXRtqixTB9f3Tb6SH+Ece61kAKLtRkjJbWWEpr6s2ux2PaxDuD9 Ea0i5p5nEreZOyRnnnuE4yReUMaDmvpktXnpAlZh38dcRK5DBm0tFgNZMijZkSebyinJ HkKCoSQfh9IXQEQn1eJ+qGqfov17Vww7kyvlbGqMUjXDEWdm4dIRP/IUI265UeYG4cEH 79YQ== 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:in-reply-to :references:mime-version:content-transfer-encoding; bh=Npvt6BnLoRE+ITNaKiuWjMdj+Jqxi0Z7NGG0xDY8eZY=; b=ptoRi8kbDTZZwpTvOU6SMrDa5UJyXEKpoajS+Op9nEIMr0i5Td6f8VMjMJpA2AU0nr nQWNfSyWFFkuMmf+HBYEv/hRqfI7/4pHEUZVdilmwoqrdIlKHmLJ4u7DWjFbUa5G3CiP XTQgD8ubJDAuFo8SXQvBgms7tOB55Y/40rVZC5mUWSL8EVf+redD0xW0i2FtX+yned8p v9w+sqNsSP3Cz4sQk+askurkYyh90HV+PFBK5cqumAHHfjft4rG0pzBwbIPyhCCQLnHs IPBwo3a4vxGmY1edsmWg8z6JnOgtZl6E9dcRxul6wz6WBMGKQvNRth+qszsxOTjof6SF vVGg== X-Gm-Message-State: APjAAAWgAsJlkLKRGxloWQJ5N2a50YZiSHz4rJvFOMhDbDqjnyvVtaVY iVEXwdxS+Wftd06E0baUrQMCMg== X-Received: by 2002:a1c:a101:: with SMTP id k1mr76948104wme.98.1563985451734; Wed, 24 Jul 2019 09:24:11 -0700 (PDT) Received: from starbuck.baylibre.local (lmontsouris-657-1-212-31.w90-63.abo.wanadoo.fr. [90.63.244.31]) by smtp.googlemail.com with ESMTPSA id f70sm55688960wme.22.2019.07.24.09.24.10 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Wed, 24 Jul 2019 09:24:11 -0700 (PDT) From: Jerome Brunet To: Mark Brown , Liam Girdwood , Kevin Hilman Cc: Jerome Brunet , alsa-devel@alsa-project.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-amlogic@lists.infradead.org Subject: [PATCH 2/6] ASoC: codec2codec: name link using stream direction Date: Wed, 24 Jul 2019 18:24:01 +0200 Message-Id: <20190724162405.6574-3-jbrunet@baylibre.com> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190724162405.6574-1-jbrunet@baylibre.com> References: <20190724162405.6574-1-jbrunet@baylibre.com> MIME-Version: 1.0 X-Patchwork-Bot: notify Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org At the moment, codec to codec dai link widgets are named after the cpu dai and the 1st codec valid on the link. This might be confusing if there is multiple valid codecs on the link for one stream direction. Instead, use the dai link name and the stream direction to name the the dai link widget Signed-off-by: Jerome Brunet --- sound/soc/soc-dapm.c | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) -- 2.21.0 diff --git a/sound/soc/soc-dapm.c b/sound/soc/soc-dapm.c index 5348abda7ce2..d20cd89513a4 100644 --- a/sound/soc/soc-dapm.c +++ b/sound/soc/soc-dapm.c @@ -4056,8 +4056,7 @@ snd_soc_dapm_alloc_kcontrol(struct snd_soc_card *card, static struct snd_soc_dapm_widget * snd_soc_dapm_new_dai(struct snd_soc_card *card, struct snd_soc_pcm_runtime *rtd, - struct snd_soc_dapm_widget *source, - struct snd_soc_dapm_widget *sink) + char *id) { struct snd_soc_dapm_widget template; struct snd_soc_dapm_widget *w; @@ -4067,7 +4066,7 @@ snd_soc_dapm_new_dai(struct snd_soc_card *card, struct snd_soc_pcm_runtime *rtd, int ret; link_name = devm_kasprintf(card->dev, GFP_KERNEL, "%s-%s", - source->name, sink->name); + rtd->dai_link->name, id); if (!link_name) return ERR_PTR(-ENOMEM); @@ -4247,15 +4246,13 @@ static void dapm_connect_dai_link_widgets(struct snd_soc_card *card, } for_each_rtd_codec_dai(rtd, i, codec_dai) { - /* connect BE DAI playback if widgets are valid */ codec = codec_dai->playback_widget; if (playback_cpu && codec) { if (!playback) { playback = snd_soc_dapm_new_dai(card, rtd, - playback_cpu, - codec); + "playback"); if (IS_ERR(playback)) { dev_err(rtd->dev, "ASoC: Failed to create DAI %s: %ld\n", @@ -4284,8 +4281,7 @@ static void dapm_connect_dai_link_widgets(struct snd_soc_card *card, if (codec && capture_cpu) { if (!capture) { capture = snd_soc_dapm_new_dai(card, rtd, - codec, - capture_cpu); + "capture"); if (IS_ERR(capture)) { dev_err(rtd->dev, "ASoC: Failed to create DAI %s: %ld\n", From patchwork Wed Jul 24 16:24:03 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jerome Brunet X-Patchwork-Id: 169619 Delivered-To: patch@linaro.org Received: by 2002:a92:4782:0:0:0:0:0 with SMTP id e2csp10465120ilk; Wed, 24 Jul 2019 09:24:38 -0700 (PDT) X-Google-Smtp-Source: APXvYqzPvmfB/KmluWz+9Xkvhk4DUPDZtjhw5uacandTZsGIxW0I7lR+pfVgrij0RiUwl3GNZv7D X-Received: by 2002:a05:6a00:4c:: with SMTP id i12mr12232334pfk.134.1563985478841; Wed, 24 Jul 2019 09:24:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1563985478; cv=none; d=google.com; s=arc-20160816; b=0q4WJH40CVUqsHgA9Fh4ju6KqdmBIOa2qnfLh3+UiWdigKfORQKV3X3vYHFpmt5tC9 ziC+QODnjAAMzcTfxBUY5lWiJBk9dWUTeyeruHUjoqAsu6lwVOVs83wvIazG8AMevSOJ OJ9cDiZa5fEdVNIaquZaO7mvgRr7BNzkTmEd2RHqnJLN7bDMMnj3AifpblRhTJ+xeYaT mNAgIG0UiXqTQnudyIGoFFzBWcAi8bU5RvCW9Gf0YdDmYBMjVhIBjFCSMV7HK8FapVpv GlRVzUlHjJpOMyZIqn5MEcmrIXaHrRf6NqGLe3pVfMIv2yje4HB6Mfw5w1EpISsXjTe+ K8Ww== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=ZSaABRSxmdPUIlgGnW2e+CGetJdVeG6KV5A9m/NM03Q=; b=DJlmUXV73aALfr4TtzGoeGCDCERpUDdtbSSq8e/n/KoKZk2o6R+jJjazKelDxJqVMm k8oixvnLmisOTAdgid0bHmiBh6nwZ1waFWfRcyNCe0NADXkZPM+xSMr9WKktyn4eVKhT 5At547l4ESfhdRdEFikQuvur1EBcym2jeDCp1sUxDCanOayF2lvYJIQbQYsKg46VduMu f+0OICPqXOIePuLfSCXQFR+UlknompPYk8V4mJ3CaoGzBNYtAevwgVTR7OcsPUhiWCWC jIEPKBOqy/LHgzEJst9e/eXhDknOXyF0Z7al9ump7ywQbeg6ijyamZBdpcxdcEvom92Y QXGQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@baylibre-com.20150623.gappssmtp.com header.s=20150623 header.b=0pshrWOR; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 64si15955669plw.379.2019.07.24.09.24.38; Wed, 24 Jul 2019 09:24:38 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@baylibre-com.20150623.gappssmtp.com header.s=20150623 header.b=0pshrWOR; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728840AbfGXQYh (ORCPT + 29 others); Wed, 24 Jul 2019 12:24:37 -0400 Received: from mail-wr1-f67.google.com ([209.85.221.67]:39646 "EHLO mail-wr1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728769AbfGXQYP (ORCPT ); Wed, 24 Jul 2019 12:24:15 -0400 Received: by mail-wr1-f67.google.com with SMTP id x4so47618313wrt.6 for ; Wed, 24 Jul 2019 09:24:14 -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:in-reply-to:references :mime-version:content-transfer-encoding; bh=ZSaABRSxmdPUIlgGnW2e+CGetJdVeG6KV5A9m/NM03Q=; b=0pshrWORbtR9bwGpPO/MJfAdOn47cpmS7uHac8G6OKoOKp2ZPIni0pWdFjRnSmwsJf W6BdvldykF0q8NBQvlSe/iRUgyDrBKncnSgKIziL/9tRU60SwhO2eyi6FoLTjyFFz9px vq7W3LDd7u0bkk/5pt8Dm69MPaEjimSoSWColk3ocsvSAfkwSbMgQBtE4r+O2Umi2o6Y k+nL159AfkGDIoB0+EoO9XgUxV/t3tHYp7BWUhb22rj2U7GUO+lYhk1tyHx3/kB//XED JRkpaIhqP375b6vvq55uSwqVGpAtICIP8Q0mRBH2kY0+wPkycv7lWs10T0WKC2ZYEs0Q cqag== 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:in-reply-to :references:mime-version:content-transfer-encoding; bh=ZSaABRSxmdPUIlgGnW2e+CGetJdVeG6KV5A9m/NM03Q=; b=PiUyvukqier38ieWlOqkAn5nxhl0foAM8YvTu1cpakcp/O4eV46T+vu9eEbaZBsb/e wLQCj0cmHbLgLOUYrz5xcV/wDZOev2lu1KANE4hbMV0eezUGCv5Z3NMtpU3S2O4tOY9y 7UMIj39D+ptIu1dqFHJLgvFlc9yFdR4UorfyDCLdizi4AEIGAkdSHCGJq22Dypj4kAW3 OorMB8ejmeIS0eqJ8MSWQyxGxPsF6zG2VESoeu6ar8JtkkjG3K2U7SjniWLi9Na2i1aq 8k+j4fiz7vvG5LE9Z+uvLLoA/bCHf9L9fsd46UGGCGlrx5mCky5Qvk1iqEXzGX368/YZ Iarw== X-Gm-Message-State: APjAAAWwMrJEGim4CACWZzJ35AL+CHtiIlpyhQezJ7/sUK8PMttpu/DW Fm9TcmR3gY4QvtsNYxfC9RsZ8dpfee8= X-Received: by 2002:adf:e843:: with SMTP id d3mr40668799wrn.249.1563985453480; Wed, 24 Jul 2019 09:24:13 -0700 (PDT) Received: from starbuck.baylibre.local (lmontsouris-657-1-212-31.w90-63.abo.wanadoo.fr. [90.63.244.31]) by smtp.googlemail.com with ESMTPSA id f70sm55688960wme.22.2019.07.24.09.24.12 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Wed, 24 Jul 2019 09:24:13 -0700 (PDT) From: Jerome Brunet To: Mark Brown , Liam Girdwood , Kevin Hilman Cc: Jerome Brunet , alsa-devel@alsa-project.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-amlogic@lists.infradead.org Subject: [PATCH 4/6] ASoC: create pcm for codec2codec links as well Date: Wed, 24 Jul 2019 18:24:03 +0200 Message-Id: <20190724162405.6574-5-jbrunet@baylibre.com> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190724162405.6574-1-jbrunet@baylibre.com> References: <20190724162405.6574-1-jbrunet@baylibre.com> MIME-Version: 1.0 X-Patchwork-Bot: notify Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org At the moment, codec to codec links uses an ephemeral variable for the struct snd_pcm_substream. Also the struct snd_soc_pcm_runtime does not have real struct snd_pcm. This might a problem if the functions used by a codec on codec to codec link expect these structures to exist, and keep on existing during the life of the codec. For example, it is the case of the hdmi-codec, which uses snd_pcm_add_chmap_ctls(). For the controls to works, the pcm and substream must to exist. This change is first step, it create pcm (and substreams) for codec to codec links, in the same way as dpcm backend links. Signed-off-by: Jerome Brunet --- sound/soc/soc-core.c | 42 ++++++++++++------------------------------ sound/soc/soc-pcm.c | 35 ++++++++++++++++++++++++++++++++--- 2 files changed, 44 insertions(+), 33 deletions(-) -- 2.21.0 diff --git a/sound/soc/soc-core.c b/sound/soc/soc-core.c index 7ecfe641ca46..9e8eb93c8a3f 100644 --- a/sound/soc/soc-core.c +++ b/sound/soc/soc-core.c @@ -447,16 +447,6 @@ static void snd_soc_flush_all_delayed_work(struct snd_soc_card *card) flush_delayed_work(&rtd->delayed_work); } -static void codec2codec_close_delayed_work(struct work_struct *work) -{ - /* - * Currently nothing to do for c2c links - * Since c2c links are internal nodes in the DAPM graph and - * don't interface with the outside world or application layer - * we don't have to do any special handling on close. - */ -} - #ifdef CONFIG_PM_SLEEP /* powers down audio subsystem for suspend */ int snd_soc_suspend(struct device *dev) @@ -1552,27 +1542,19 @@ static int soc_probe_link_dais(struct snd_soc_card *card, return ret; } - if (!dai_link->params) { - /* create the pcm */ - ret = soc_new_pcm(rtd, num); - if (ret < 0) { - dev_err(card->dev, "ASoC: can't create pcm %s :%d\n", - dai_link->stream_name, ret); - return ret; - } - ret = soc_link_dai_pcm_new(&cpu_dai, 1, rtd); - if (ret < 0) - return ret; - ret = soc_link_dai_pcm_new(rtd->codec_dais, - rtd->num_codecs, rtd); - if (ret < 0) - return ret; - } else { - INIT_DELAYED_WORK(&rtd->delayed_work, - codec2codec_close_delayed_work); + /* create the pcm */ + ret = soc_new_pcm(rtd, num); + if (ret < 0) { + dev_err(card->dev, "ASoC: can't create pcm %s :%d\n", + dai_link->stream_name, ret); + return ret; } - - return 0; + ret = soc_link_dai_pcm_new(&cpu_dai, 1, rtd); + if (ret < 0) + return ret; + ret = soc_link_dai_pcm_new(rtd->codec_dais, + rtd->num_codecs, rtd); + return ret; } static int soc_bind_aux_dev(struct snd_soc_card *card, int num) diff --git a/sound/soc/soc-pcm.c b/sound/soc/soc-pcm.c index fabeac164a6c..30264bc592f6 100644 --- a/sound/soc/soc-pcm.c +++ b/sound/soc/soc-pcm.c @@ -678,6 +678,16 @@ static void close_delayed_work(struct work_struct *work) mutex_unlock(&rtd->pcm_mutex); } +static void codec2codec_close_delayed_work(struct work_struct *work) +{ + /* + * Currently nothing to do for c2c links + * Since c2c links are internal nodes in the DAPM graph and + * don't interface with the outside world or application layer + * we don't have to do any special handling on close. + */ +} + /* * Called by ALSA when a PCM substream is closed. Private data can be * freed here. The cpu DAI, codec DAI, machine and components are also @@ -3011,6 +3021,12 @@ int soc_new_pcm(struct snd_soc_pcm_runtime *rtd, int num) playback = rtd->dai_link->dpcm_playback; capture = rtd->dai_link->dpcm_capture; } else { + /* Adapt stream for codec2codec links */ + struct snd_soc_pcm_stream *cpu_capture = rtd->dai_link->params ? + &cpu_dai->driver->playback : &cpu_dai->driver->capture; + struct snd_soc_pcm_stream *cpu_playback = rtd->dai_link->params ? + &cpu_dai->driver->capture : &cpu_dai->driver->playback; + for_each_rtd_codec_dai(rtd, i, codec_dai) { if (snd_soc_dai_stream_valid(codec_dai, SNDRV_PCM_STREAM_PLAYBACK) && snd_soc_dai_stream_valid(cpu_dai, SNDRV_PCM_STREAM_PLAYBACK)) @@ -3019,6 +3035,9 @@ int soc_new_pcm(struct snd_soc_pcm_runtime *rtd, int num) snd_soc_dai_stream_valid(cpu_dai, SNDRV_PCM_STREAM_CAPTURE)) capture = 1; } + + capture = capture && cpu_capture->channels_min; + playback = playback && cpu_playback->channels_min; } if (rtd->dai_link->playback_only) { @@ -3032,7 +3051,13 @@ int soc_new_pcm(struct snd_soc_pcm_runtime *rtd, int num) } /* create the PCM */ - if (rtd->dai_link->no_pcm) { + if (rtd->dai_link->params) { + snprintf(new_name, sizeof(new_name), "codec2codec(%s)", + rtd->dai_link->stream_name); + + ret = snd_pcm_new_internal(rtd->card->snd_card, new_name, num, + playback, capture, &pcm); + } else if (rtd->dai_link->no_pcm) { snprintf(new_name, sizeof(new_name), "(%s)", rtd->dai_link->stream_name); @@ -3059,13 +3084,17 @@ int soc_new_pcm(struct snd_soc_pcm_runtime *rtd, int num) dev_dbg(rtd->card->dev, "ASoC: registered pcm #%d %s\n",num, new_name); /* DAPM dai link stream work */ - INIT_DELAYED_WORK(&rtd->delayed_work, close_delayed_work); + if (rtd->dai_link->params) + INIT_DELAYED_WORK(&rtd->delayed_work, + codec2codec_close_delayed_work); + else + INIT_DELAYED_WORK(&rtd->delayed_work, close_delayed_work); pcm->nonatomic = rtd->dai_link->nonatomic; rtd->pcm = pcm; pcm->private_data = rtd; - if (rtd->dai_link->no_pcm) { + if (rtd->dai_link->no_pcm || rtd->dai_link->params) { if (playback) pcm->streams[SNDRV_PCM_STREAM_PLAYBACK].substream->private_data = rtd; if (capture) From patchwork Wed Jul 24 16:24:04 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jerome Brunet X-Patchwork-Id: 169615 Delivered-To: patch@linaro.org Received: by 2002:a92:4782:0:0:0:0:0 with SMTP id e2csp10464802ilk; Wed, 24 Jul 2019 09:24:20 -0700 (PDT) X-Google-Smtp-Source: APXvYqxfz6HrVHqVQGvacaYpB1PzkYeqGXZbRzFCLEZHHrD7ulmPVysQtxGytg7yKL6hx8rSdYXm X-Received: by 2002:a62:1bca:: with SMTP id b193mr11837276pfb.57.1563985460644; Wed, 24 Jul 2019 09:24:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1563985460; cv=none; d=google.com; s=arc-20160816; b=uoiKSeJSiuTp1IXqj0ZnEENpVxmSgHSFUTDpGm4iZAOkX+0SxW/zBZu4LMi/V3IL5d L7FKE9+gttjtBd7YVJpFHDu0zp2+2lFHMUsuBs+taycMcRNmqifdH2/U/NFoPGYjA0Af +G2Sl2vUF9aI+bxlxzyrF4VMpP6x0mJAi5qDcGkzRVM2OIlKerng+MtQ4Wqh7dPZQMfB N/cs2UXQMuVkPZUvfm386I3Q6UjQqXm17TcRZBHXKURcPbeC/Vod8yUlQSTpSiyUeC6c Gmc9Roib9gRlzqwpLoN1JD0LTlKj3KjMXVgl/xrxKqeEUxs7HfIz/ssisNh4GX7QG8kY lyLg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=fEqbgC4ffyUrLuttzgUt5FRl7sGgCywNMcNCDLVp0IE=; b=FLxVohY5lLKqj6B1Db+2v1yOenEDvvNnP23qWYFv1YkgHRxvT8EM2ybQFQr2eL2Brc vNTVH9oRiuSUuMrGR+ZllU5RGqTS56im0OeZ3qmkByE7joOwdrsy9+nxLlrdc6DapV28 loBNxB3csoWbHLnTjoBAxYpu62kck7JhIZRQe8hH5dxu002UrW6O+uDLd8sRe/pFUQxw 8QP+mMl5Fn5lrIAD2IFMDLDst4YcqmG6r/tLrq31G+I0LUSLfhOcIwBMHmOcT0XXg6D+ TKGK4TO9RejvQZyzn94SW1v6VZ06g6riBLMf33LLPYx4ku+tiAKkaSs8CALTuFKdfgd1 aHqA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@baylibre-com.20150623.gappssmtp.com header.s=20150623 header.b=rlHioeG5; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id y92si13499528plb.209.2019.07.24.09.24.20; Wed, 24 Jul 2019 09:24:20 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@baylibre-com.20150623.gappssmtp.com header.s=20150623 header.b=rlHioeG5; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728825AbfGXQYT (ORCPT + 29 others); Wed, 24 Jul 2019 12:24:19 -0400 Received: from mail-wm1-f65.google.com ([209.85.128.65]:51554 "EHLO mail-wm1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728768AbfGXQYR (ORCPT ); Wed, 24 Jul 2019 12:24:17 -0400 Received: by mail-wm1-f65.google.com with SMTP id 207so42394976wma.1 for ; Wed, 24 Jul 2019 09:24:15 -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:in-reply-to:references :mime-version:content-transfer-encoding; bh=fEqbgC4ffyUrLuttzgUt5FRl7sGgCywNMcNCDLVp0IE=; b=rlHioeG5qyt3yeoOQxhVWAqMVyPP0n2aMILs+ua+NsbJkQeFpxaNCtsES2nnR1WgcL u1dWYguZGuirOq5oqOQ20cGCnv3YHT98dSsztpl90vskstO72I7GdzdsiaT4Ji3EnNVo AVjULroRg0dNK9ZU5nAtvBiziiO8Mgn3AxNB1UCLKArUeTvi/99lA4FgHqtxoO25kK+l LJYrbc3Rzc5mm5C4EDSAcqBQ5lPLeluJ9uTv+tEtZePrPS3oT1ZjURDImzU3qi6GUM13 XTuW56+4SQx01QA1Qs0DgZe7vftG5O8TkpUBFlUnfhT45c5EkUpf/EMeGEUSWxe+aMmK +a9Q== 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:in-reply-to :references:mime-version:content-transfer-encoding; bh=fEqbgC4ffyUrLuttzgUt5FRl7sGgCywNMcNCDLVp0IE=; b=tjv9jdAo5HPiZCExSToBJeNwX2U8qigallELXtnCu/zzo++lLgEhM6cF3TYZ8kDNlZ ZZiTahTDrCquah3Sve6iJ0PEoWKRSFieRsJ2waD9pZGB9f13/Q4TrlEy9JinXCk3YszU kI4n3tLaAYjfo7c27APLdlPmVIOi+8GLOI3e+nrQjksdvy1+nynC2UyTQU+N7MSxUPKO DejXcVbGW6LhWOGI9Igdruus5K41q1zc4zin+sTbF64OSmkl0CvASf7PrJNxATW1yjQn gZhmun4DXQY1B0Q8zRfAImMTjABlFtWPnwCsBb/CAy5Xvb7PO/Q3dDtYUC9yIjI9Pwfq 1tmg== X-Gm-Message-State: APjAAAVm02vMWwp4/yHhOxQgmk5BbOluU3UoM3fLxMvr1zrs4RO12Q8P +6JSoUuLKyy2WYSLoas0cKIQaQ== X-Received: by 2002:a7b:cc09:: with SMTP id f9mr77497784wmh.68.1563985454615; Wed, 24 Jul 2019 09:24:14 -0700 (PDT) Received: from starbuck.baylibre.local (lmontsouris-657-1-212-31.w90-63.abo.wanadoo.fr. [90.63.244.31]) by smtp.googlemail.com with ESMTPSA id f70sm55688960wme.22.2019.07.24.09.24.13 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Wed, 24 Jul 2019 09:24:13 -0700 (PDT) From: Jerome Brunet To: Mark Brown , Liam Girdwood , Kevin Hilman Cc: Jerome Brunet , alsa-devel@alsa-project.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-amlogic@lists.infradead.org Subject: [PATCH 5/6] ASoC: codec2codec: remove ephemeral variables Date: Wed, 24 Jul 2019 18:24:04 +0200 Message-Id: <20190724162405.6574-6-jbrunet@baylibre.com> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190724162405.6574-1-jbrunet@baylibre.com> References: <20190724162405.6574-1-jbrunet@baylibre.com> MIME-Version: 1.0 X-Patchwork-Bot: notify Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Now that codec to codec links struct snd_soc_pcm_runtime have lasting pcm and substreams, let's use them. Alsa allocate and keep the struct snd_pcm_runtime as long as the link is powered. Signed-off-by: Jerome Brunet --- sound/soc/soc-dapm.c | 86 ++++++++++++++++++++++++-------------------- 1 file changed, 48 insertions(+), 38 deletions(-) -- 2.21.0 diff --git a/sound/soc/soc-dapm.c b/sound/soc/soc-dapm.c index aa6e47beaec3..e0eedff5fe94 100644 --- a/sound/soc/soc-dapm.c +++ b/sound/soc/soc-dapm.c @@ -3802,48 +3802,45 @@ static int snd_soc_dai_link_event(struct snd_soc_dapm_widget *w, { struct snd_soc_dapm_path *path; struct snd_soc_dai *source, *sink; - struct snd_soc_pcm_runtime *rtd = w->priv; const struct snd_soc_pcm_stream *config; - struct snd_pcm_substream substream; + struct snd_pcm_substream *substream = w->priv; + struct snd_soc_pcm_runtime *rtd = substream->private_data; struct snd_pcm_hw_params params; struct snd_pcm_runtime *runtime = NULL; - int ret = 0; + int ret = 0, saved_stream = substream->stream; if (WARN_ON(list_empty(&w->edges[SND_SOC_DAPM_DIR_OUT]) || list_empty(&w->edges[SND_SOC_DAPM_DIR_IN]))) return -EINVAL; - memset(&substream, 0, sizeof(substream)); - - /* Allocate a dummy snd_pcm_runtime for startup() and other ops() */ - runtime = kzalloc(sizeof(*runtime), GFP_KERNEL); - if (!runtime) { - ret = -ENOMEM; - goto out; - } - substream.runtime = runtime; - substream.private_data = rtd; - switch (event) { case SND_SOC_DAPM_PRE_PMU: - substream.stream = SNDRV_PCM_STREAM_CAPTURE; + runtime = kzalloc(sizeof(*runtime), GFP_KERNEL); + if (!runtime) { + ret = -ENOMEM; + goto out; + } + substream->runtime = runtime; + + substream->stream = SNDRV_PCM_STREAM_CAPTURE; snd_soc_dapm_widget_for_each_source_path(w, path) { source = path->source->priv; - ret = snd_soc_dai_startup(source, &substream); + ret = snd_soc_dai_startup(source, substream); if (ret < 0) { dev_err(source->dev, "ASoC: startup() failed: %d\n", ret); goto out; + } source->active++; } - substream.stream = SNDRV_PCM_STREAM_PLAYBACK; + substream->stream = SNDRV_PCM_STREAM_PLAYBACK; snd_soc_dapm_widget_for_each_sink_path(w, path) { sink = path->sink->priv; - ret = snd_soc_dai_startup(sink, &substream); + ret = snd_soc_dai_startup(sink, substream); if (ret < 0) { dev_err(sink->dev, "ASoC: startup() failed: %d\n", ret); @@ -3852,6 +3849,8 @@ static int snd_soc_dai_link_event(struct snd_soc_dapm_widget *w, sink->active++; } + substream->hw_opened = 1; + /* * Note: getting the config after .startup() gives a chance to * either party on the link to alter the configuration if @@ -3871,26 +3870,26 @@ static int snd_soc_dai_link_event(struct snd_soc_dapm_widget *w, goto out; } - substream.stream = SNDRV_PCM_STREAM_CAPTURE; + substream->stream = SNDRV_PCM_STREAM_CAPTURE; snd_soc_dapm_widget_for_each_source_path(w, path) { source = path->source->priv; - ret = soc_dai_hw_params(&substream, ¶ms, source); + ret = soc_dai_hw_params(substream, ¶ms, source); if (ret < 0) goto out; - dapm_update_dai_unlocked(&substream, ¶ms, source); + dapm_update_dai_unlocked(substream, ¶ms, source); } - substream.stream = SNDRV_PCM_STREAM_PLAYBACK; + substream->stream = SNDRV_PCM_STREAM_PLAYBACK; snd_soc_dapm_widget_for_each_sink_path(w, path) { sink = path->sink->priv; - ret = soc_dai_hw_params(&substream, ¶ms, sink); + ret = soc_dai_hw_params(substream, ¶ms, sink); if (ret < 0) goto out; - dapm_update_dai_unlocked(&substream, ¶ms, sink); + dapm_update_dai_unlocked(substream, ¶ms, sink); } break; @@ -3920,40 +3919,45 @@ static int snd_soc_dai_link_event(struct snd_soc_dapm_widget *w, ret = 0; } - substream.stream = SNDRV_PCM_STREAM_CAPTURE; + substream->stream = SNDRV_PCM_STREAM_CAPTURE; snd_soc_dapm_widget_for_each_source_path(w, path) { source = path->source->priv; - snd_soc_dai_hw_free(source, &substream); + snd_soc_dai_hw_free(source, substream); } - substream.stream = SNDRV_PCM_STREAM_PLAYBACK; + substream->stream = SNDRV_PCM_STREAM_PLAYBACK; snd_soc_dapm_widget_for_each_sink_path(w, path) { sink = path->sink->priv; - snd_soc_dai_hw_free(sink, &substream); + snd_soc_dai_hw_free(sink, substream); } - substream.stream = SNDRV_PCM_STREAM_CAPTURE; + substream->stream = SNDRV_PCM_STREAM_CAPTURE; snd_soc_dapm_widget_for_each_source_path(w, path) { source = path->source->priv; source->active--; - snd_soc_dai_shutdown(source, &substream); + snd_soc_dai_shutdown(source, substream); } - substream.stream = SNDRV_PCM_STREAM_PLAYBACK; + substream->stream = SNDRV_PCM_STREAM_PLAYBACK; snd_soc_dapm_widget_for_each_sink_path(w, path) { sink = path->sink->priv; sink->active--; - snd_soc_dai_shutdown(sink, &substream); + snd_soc_dai_shutdown(sink, substream); } break; + case SND_SOC_DAPM_POST_PMD: + kfree(substream->runtime); + break; + default: WARN(1, "Unknown event %d\n", event); ret = -EINVAL; } out: - kfree(runtime); + /* Restore the substream direction */ + substream->stream = saved_stream; return ret; } @@ -4076,9 +4080,11 @@ snd_soc_dapm_alloc_kcontrol(struct snd_soc_card *card, } static struct snd_soc_dapm_widget * -snd_soc_dapm_new_dai(struct snd_soc_card *card, struct snd_soc_pcm_runtime *rtd, +snd_soc_dapm_new_dai(struct snd_soc_card *card, + struct snd_pcm_substream *substream, char *id) { + struct snd_soc_pcm_runtime *rtd = substream->private_data; struct snd_soc_dapm_widget template; struct snd_soc_dapm_widget *w; const char **w_param_text; @@ -4097,7 +4103,7 @@ snd_soc_dapm_new_dai(struct snd_soc_card *card, struct snd_soc_pcm_runtime *rtd, template.name = link_name; template.event = snd_soc_dai_link_event; template.event_flags = SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMU | - SND_SOC_DAPM_PRE_PMD; + SND_SOC_DAPM_PRE_PMD | SND_SOC_DAPM_POST_PMD; template.kcontrol_news = NULL; /* allocate memory for control, only in case of multiple configs */ @@ -4132,7 +4138,7 @@ snd_soc_dapm_new_dai(struct snd_soc_card *card, struct snd_soc_pcm_runtime *rtd, goto outfree_kcontrol_news; } - w->priv = rtd; + w->priv = substream; return w; @@ -4254,6 +4260,8 @@ static void dapm_connect_dai_link_widgets(struct snd_soc_card *card, struct snd_soc_dai *codec_dai; struct snd_soc_dapm_widget *playback = NULL, *capture = NULL; struct snd_soc_dapm_widget *codec, *playback_cpu, *capture_cpu; + struct snd_pcm_substream *substream; + struct snd_pcm_str *streams = rtd->pcm->streams; int i; if (rtd->dai_link->params) { @@ -4272,7 +4280,8 @@ static void dapm_connect_dai_link_widgets(struct snd_soc_card *card, if (playback_cpu && codec) { if (!playback) { - playback = snd_soc_dapm_new_dai(card, rtd, + substream = streams[SNDRV_PCM_STREAM_PLAYBACK].substream; + playback = snd_soc_dapm_new_dai(card, substream, "playback"); if (IS_ERR(playback)) { dev_err(rtd->dev, @@ -4301,7 +4310,8 @@ static void dapm_connect_dai_link_widgets(struct snd_soc_card *card, if (codec && capture_cpu) { if (!capture) { - capture = snd_soc_dapm_new_dai(card, rtd, + substream = streams[SNDRV_PCM_STREAM_CAPTURE].substream; + capture = snd_soc_dapm_new_dai(card, substream, "capture"); if (IS_ERR(capture)) { dev_err(rtd->dev, From patchwork Wed Jul 24 16:24:05 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jerome Brunet X-Patchwork-Id: 169616 Delivered-To: patch@linaro.org Received: by 2002:a92:4782:0:0:0:0:0 with SMTP id e2csp10464841ilk; Wed, 24 Jul 2019 09:24:23 -0700 (PDT) X-Google-Smtp-Source: APXvYqyWMVCtEcbrav0XEo0GW2J2+4R8X8J58duInniS0sSfdqWQ0ph04wXNRPYxVwcPcnjiSBVG X-Received: by 2002:a17:90a:b011:: with SMTP id x17mr89141602pjq.113.1563985463404; Wed, 24 Jul 2019 09:24:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1563985463; cv=none; d=google.com; s=arc-20160816; b=JlQpewPUIQODIPOO7sHNBBBC4q+mqR92FYwVuIuu7/VPypL/GVhsJSlwP7ljlCSj99 KO1jh6BX9kfJ5bm9hrNkp9RbpW/5s/JJRDDIXmweOXvsYQdnCRpFGy/goa6stYbOFV0K duANRv8oExkcl/7e5/UczlMgD6bka1fHGCJfsgC/xYtKFt5Psub08ZUSamaPdrBr1yrs nObDWP/HwXdebSQDBBXIN249BKOkP3kqYDQl/nHddfViML+9TePhxgXjOyzNNaptE2/m 3tw+zsaAnp64R7/763sbJopzI+LHPzLDv2UbK5EW7cHdddRaVxt7qNmVekGmX6QjYTQe BJ8A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=UJ9KDGBOl8aIUqKuxRToZa5/dKJVoJYKCqFTu5LeV1A=; b=By1XcuqZ/0e2K8oKst+waSQ4t3YjpodbfngLqezsFaA2onneMYnMNXcRluWp/348uf 3Kf9b+lpmJIBBoLoQug+0MtYbqJezRTyQZKsYUknEgL7m7ew/yGtj2LaxVK+8C2GEabp v4srNlNuA9qfDlXvpOAnJ0q2IOQwxpgoIer/DaXVokTPaGG8OKdszjGaZjAcY7uupvIg ILAWV0wTSy/EU7vePBUnSsE6g6gQWORngvCIkqQmERP50v1gQUAufnWYcCCaXzozVWsN rjkCqnI6e0wA5FnlbqlQNehgsKZyoJSjxA9Kla2ESJCJCjdedOdQzbWbdxB9OeLB9FVp WSRg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@baylibre-com.20150623.gappssmtp.com header.s=20150623 header.b=tU0u8Kzo; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id k14si12860870pjq.53.2019.07.24.09.24.23; Wed, 24 Jul 2019 09:24:23 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@baylibre-com.20150623.gappssmtp.com header.s=20150623 header.b=tU0u8Kzo; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728838AbfGXQYV (ORCPT + 29 others); Wed, 24 Jul 2019 12:24:21 -0400 Received: from mail-wr1-f68.google.com ([209.85.221.68]:44028 "EHLO mail-wr1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728780AbfGXQYR (ORCPT ); Wed, 24 Jul 2019 12:24:17 -0400 Received: by mail-wr1-f68.google.com with SMTP id p13so47623852wru.10 for ; Wed, 24 Jul 2019 09:24:16 -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:in-reply-to:references :mime-version:content-transfer-encoding; bh=UJ9KDGBOl8aIUqKuxRToZa5/dKJVoJYKCqFTu5LeV1A=; b=tU0u8Kzo4EqYFk+S/PB7XaSJUsAodzLIXYMpL2tWf18qebqFw73F789ZMYL9or9SsK dqKPqCfMrQm/8qtBnymmETaftmj2gXdDTqbZeXG94Gcn5Fb8vfeZiMuiL+siIEU4EZO/ chX0PSxfTCfqr/6ho4HEP9cQJ2OvcSntdppRHBL7xpC02MhR5YZN537v2LeeBKtn3aS6 B5HCEKhe4Bsa/xsFrKapjdoaJaoSFK7pS35WXAQ5rGtDx/6F5GLO3/LdkR2T/9mTXY2o RR5rolvIqI94A16zqWHC8eg7NqWQBgxATiaOGRqNE18Pf+VU9hDDWW9yyNX5nK4rWcRh S24Q== 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:in-reply-to :references:mime-version:content-transfer-encoding; bh=UJ9KDGBOl8aIUqKuxRToZa5/dKJVoJYKCqFTu5LeV1A=; b=l8/tM+fn1FffhGBz+xVgprYiEspM2qXdRcUu7i19Zrg0XS78u1ZrAHwnJzJpaiUr4V ELQTXKktzb6PtpijR4fA8cRRL7RHnXX4WZzaGnFhlNRJz/ntm2t6VUGmYDPWviobKl+g BYJy9wQj3QfpFda3foa2drtUHPLOr73btVd+To3xo3gKFVPZ2Gy44ffsIBKLbMFQ9R8r VFF65CJ1hUlgi/TLsQqgL1OKXaj55mMCaz7PAwJbelSl8vMrUw6F4ca4Nye39yuKB+Fl byoZ6S+zYifImKst2SXeS76lqtCRgd4YZwP5005HV6uGmtpmenckzggUyQu3ZEpkeq9f JlFQ== X-Gm-Message-State: APjAAAWLx2H/QaQ4k5DilpfsGSGqLSqL6ITo9argbfod4o00tedxt/x6 CnhZMQIbvU00xqkXLtA9eIQDmA== X-Received: by 2002:adf:da4d:: with SMTP id r13mr57578825wrl.281.1563985455657; Wed, 24 Jul 2019 09:24:15 -0700 (PDT) Received: from starbuck.baylibre.local (lmontsouris-657-1-212-31.w90-63.abo.wanadoo.fr. [90.63.244.31]) by smtp.googlemail.com with ESMTPSA id f70sm55688960wme.22.2019.07.24.09.24.14 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Wed, 24 Jul 2019 09:24:15 -0700 (PDT) From: Jerome Brunet To: Mark Brown , Liam Girdwood , Kevin Hilman Cc: Jerome Brunet , alsa-devel@alsa-project.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-amlogic@lists.infradead.org Subject: [PATCH 6/6] ASoC: codec2codec: fill some of the runtime stream parameters Date: Wed, 24 Jul 2019 18:24:05 +0200 Message-Id: <20190724162405.6574-7-jbrunet@baylibre.com> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190724162405.6574-1-jbrunet@baylibre.com> References: <20190724162405.6574-1-jbrunet@baylibre.com> MIME-Version: 1.0 X-Patchwork-Bot: notify Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Set the information provided struct snd_soc_pcm_stream in the struct snd_pcm_runtime of the codec to codec link. Signed-off-by: Jerome Brunet --- sound/soc/soc-dapm.c | 5 +++++ 1 file changed, 5 insertions(+) -- 2.21.0 diff --git a/sound/soc/soc-dapm.c b/sound/soc/soc-dapm.c index e0eedff5fe94..a6bc3eda275d 100644 --- a/sound/soc/soc-dapm.c +++ b/sound/soc/soc-dapm.c @@ -3892,6 +3892,11 @@ static int snd_soc_dai_link_event(struct snd_soc_dapm_widget *w, dapm_update_dai_unlocked(substream, ¶ms, sink); } + runtime->format = params_format(¶ms); + runtime->subformat = params_subformat(¶ms); + runtime->channels = params_channels(¶ms); + runtime->rate = params_rate(¶ms); + break; case SND_SOC_DAPM_POST_PMU: