From patchwork Mon Jan 6 14:13:15 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Martin Blumenstingl X-Patchwork-Id: 13927508 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id E8C17E77198 for ; Mon, 6 Jan 2025 14:13:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-ID:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=oYueXExZY+XWFtWrsXszL2y+lpkV53zCD19to52jarQ=; b=kU212ndUbFFViv Zrf+nZtcbAKBVN91srmlzyEUmRcQaM7ZfLr4tb1sIfVXBbtRh4XHGJ2FyTc6ULCiFtQDQPs4eEFty TEQX4R4wqFk4rYcDZKiAifuKZo3Rf9gb2PQmjiGQ2y3OfelMqV2gzrvf5pa3Li+XoUuWmo/0ucTro zewFnw5NfKKMNiZokzWYHhbJxvz+lEHPa+R/vmsB0KsdWX8BDhwW+0+pPaAot0RJspIjL81qLlIaB qv/gM7PxtX+bOLxLu7Bt44DhVhyKnT49+ZO/eKK7gLNMpN9dIpF3Y2Cjk9wfb+2iFe/k9ccz4IdFI 6oF9dLqB44n9NPwv9saA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98 #2 (Red Hat Linux)) id 1tUnrZ-00000001WnG-0UpH; Mon, 06 Jan 2025 14:13:49 +0000 Received: from mail-ed1-x530.google.com ([2a00:1450:4864:20::530]) by bombadil.infradead.org with esmtps (Exim 4.98 #2 (Red Hat Linux)) id 1tUnrW-00000001Wm5-3ENg for linux-amlogic@lists.infradead.org; Mon, 06 Jan 2025 14:13:47 +0000 Received: by mail-ed1-x530.google.com with SMTP id 4fb4d7f45d1cf-5d34030ebb2so9225861a12.1 for ; Mon, 06 Jan 2025 06:13:46 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlemail.com; s=20230601; t=1736172825; x=1736777625; darn=lists.infradead.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=ue4Bu5Xm3aSnr3aDQKCmaVaK/VUPDoH9ftWxJfeazzw=; b=nEp5+fcIN4jq+Hl8p2Bb/Q9pJeciO3u1JLsZmbxF9Jxz1XkvIU9LrA2UqYkNp6uNaH TSvpZ5ol+TEz5TZGFwKSNOnphMYKwh4R69wpFe821iKSX2CRi+QszfipCOG/3ZdlRgyE yxCuPHyGEdNjPEgXvFgg9Npg/y8JMRr3InmGQmU0mA6eeCb8rrGkmK3Jx4/7zh/bko3Z UWMDh8CS6yQOrR/NVcfRXvdR7VQSGyTZRY/d2ojuereEAagmbtX75nVxFsQ4mLOMN/03 qjQKwLwaSbt3t2QatO47rMooex82teBgQtDTbSBeQUB9uwxTXgsYE2IGnka7n/A32dst Ew+w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1736172825; x=1736777625; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=ue4Bu5Xm3aSnr3aDQKCmaVaK/VUPDoH9ftWxJfeazzw=; b=iWb1RF+2Br8F+ya1ZtF6PlYediyZi5+7w8YoqPSCtBg0PLCSfOzJ/JCNxniTOhRaZr /Zs0Gv9MsYSbBQMYElcXcsahp+f3Zo8jv3cO5FWglRKJ7xl1ztUaeaVRPpDFfW0GpVHi NbKv2/kOIzostMOxzAyxExtVD8WTqRpjyVK066JygMVxkXuZe6yb9ZiqLImFNfcH+ta3 jpwI9mmLB27whQJ2rGU9okdMWMVK3yAmUOVa86fjOWtsiwhnUwqPKJmNenW1frd5h8oH kADg04wgVyn8QPADHHRP33pLZXtXdlIcQZFEkkd1duJAB6qytQVYOLc97fSdSJ2TOuty iQhg== X-Forwarded-Encrypted: i=1; AJvYcCV2CO0gx2Q1qBfmCG9jDrL3sdViRPs50YVrPlxlCSOARN7oxhqXtxBkgQrrUHNJ6Ok/8FesAPS1iwE5+uQP@lists.infradead.org X-Gm-Message-State: AOJu0Yxo2klF16zrvJjkk9T8adwSMawahsN+2wpkL3s6NnD5yPZGQLYN NDPWxgfmmkLjuxFNHAetAcssocki+JhZJeA/PnIeI5/o4YvtvFcB X-Gm-Gg: ASbGncs97daDEl+gITawaIf8ou7goezL+viqspz8N3CXKpCbusEjnw0oEoWBPZGWgfd 0OK+uH9kTnvTWnE97R7BvaVH5+zIr97OBJQKQ0D2plyTCavHDqeEtzDrOceEBsux2f7HrC63Cl6 dH3boUNeB7803N/kSJUd1hnskkTve08IYVy1VwbZjmdbmMlZBZr2DspS4D5irGJuoQra478O0k9 H+rBCEfi/JAnXEqbJXSErM3BN4yQlY9OK3otOa0NnOVHLZWFrVIGf/hCClVGPAotcqBKEhaq0/w eY9j+g1MsupCXhQNUJHhjDfrEKgL91kxAMG2FVuVpsz4Ht1vENrSnrtyeIW5SzK+2bjPnSgIxOp KdDWQAw== X-Google-Smtp-Source: AGHT+IEnu2WBqAc4ZLV2zVb1tutjBgjXj2jnmiXy8Gw+WqDg3zTtAv3hDkZ3fUD63mUvDPlmvBph2w== X-Received: by 2002:a17:907:7da8:b0:aa6:8676:3b3d with SMTP id a640c23a62f3a-aac2ba3c134mr5574351166b.29.1736172825126; Mon, 06 Jan 2025 06:13:45 -0800 (PST) Received: from localhost.localdomain (dynamic-2a02-3100-a9f2-7d00-0000-0000-0000-0e63.310.pool.telefonica.de. [2a02:3100:a9f2:7d00::e63]) by smtp.googlemail.com with ESMTPSA id a640c23a62f3a-aaede7ef3cfsm1811342766b.77.2025.01.06.06.13.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 06 Jan 2025 06:13:44 -0800 (PST) From: Martin Blumenstingl To: linux-sound@vger.kernel.org, linux-amlogic@lists.infradead.org Cc: s.nawrocki@samsung.com, lgirdwood@gmail.com, broonie@kernel.org, linux-kernel@vger.kernel.org, jbrunet@baylibre.com, Martin Blumenstingl Subject: [RFC PATCH v1 1/2] ASoC: soc-dai: add snd_soc_dai_prepare() and use it internally Date: Mon, 6 Jan 2025 15:13:15 +0100 Message-ID: <20250106141316.375984-2-martin.blumenstingl@googlemail.com> X-Mailer: git-send-email 2.47.1 In-Reply-To: <20250106141316.375984-1-martin.blumenstingl@googlemail.com> References: <20250106141316.375984-1-martin.blumenstingl@googlemail.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20250106_061346_808211_DDAA69C1 X-CRM114-Status: GOOD ( 14.46 ) X-BeenThere: linux-amlogic@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-amlogic" Errors-To: linux-amlogic-bounces+linux-amlogic=archiver.kernel.org@lists.infradead.org Add a new snd_soc_dai_prepare() which can be used (in an upcoming patch) by soc-dapm.c. Use this new function internally in snd_soc_pcm_dai_prepare() to avoid duplicating code. Suggested-by: Jerome Brunet Signed-off-by: Martin Blumenstingl --- include/sound/soc-dai.h | 3 +++ sound/soc/soc-dai.c | 27 +++++++++++++++++++-------- 2 files changed, 22 insertions(+), 8 deletions(-) diff --git a/include/sound/soc-dai.h b/include/sound/soc-dai.h index aab57c19f62b..a11501752637 100644 --- a/include/sound/soc-dai.h +++ b/include/sound/soc-dai.h @@ -193,6 +193,9 @@ int snd_soc_dai_set_channel_map(struct snd_soc_dai *dai, int snd_soc_dai_set_tristate(struct snd_soc_dai *dai, int tristate); +int snd_soc_dai_prepare(struct snd_soc_dai *dai, + struct snd_pcm_substream *substream); + /* Digital Audio Interface mute */ int snd_soc_dai_digital_mute(struct snd_soc_dai *dai, int mute, int direction); diff --git a/sound/soc/soc-dai.c b/sound/soc/soc-dai.c index 34ba1a93a4c9..ca0308f6d41c 100644 --- a/sound/soc/soc-dai.c +++ b/sound/soc/soc-dai.c @@ -360,6 +360,22 @@ int snd_soc_dai_set_tristate(struct snd_soc_dai *dai, int tristate) } EXPORT_SYMBOL_GPL(snd_soc_dai_set_tristate); +int snd_soc_dai_prepare(struct snd_soc_dai *dai, + struct snd_pcm_substream *substream) +{ + int ret = 0; + + if (!snd_soc_dai_stream_valid(dai, substream->stream)) + return 0; + + if (dai->driver->ops && + dai->driver->ops->prepare) + ret = dai->driver->ops->prepare(substream, dai); + + return soc_dai_ret(dai, ret); +} +EXPORT_SYMBOL_GPL(snd_soc_dai_prepare); + /** * snd_soc_dai_digital_mute - configure DAI system or master clock. * @dai: DAI @@ -577,14 +593,9 @@ int snd_soc_pcm_dai_prepare(struct snd_pcm_substream *substream) int i, ret; for_each_rtd_dais(rtd, i, dai) { - if (!snd_soc_dai_stream_valid(dai, substream->stream)) - continue; - if (dai->driver->ops && - dai->driver->ops->prepare) { - ret = dai->driver->ops->prepare(substream, dai); - if (ret < 0) - return soc_dai_ret(dai, ret); - } + ret = snd_soc_dai_prepare(dai, substream); + if (ret < 0) + return ret; } return 0; From patchwork Mon Jan 6 14:13:16 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Martin Blumenstingl X-Patchwork-Id: 13927506 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 84124E77188 for ; Mon, 6 Jan 2025 14:13:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-ID:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=rfDMq5qvtk6flxNSGrNFe12MQPqkc4cUWG681Nfnz8I=; b=F6EEK/cbBO3t4X 6diS7AN1hjzP8CY8Q1DcJPzKrdgUt2AORqDtdmeY/iQujTBdLctOlSd5G4kb658sZdwjbyxq/fncN blpxhehqZ6XFYGP+ba486wAcjhyDx/1+OZQXuPUP9eIPo4Hk3HJRvAXYJh/StkBlOEQmu60Otaony KkB2A8q/EPCwfH38Ze3Kb54AFQLzl/x8xJQsbnv6r6ALhTlxbcu5AtEgLTfG6w13fJpC0XbXG3rLq ee543hIUY23IaW9uMGCux6++TNnCFKaikClgm0nhGbgpYn4SvnrJ5wlHtlZAIJ8XOWJCdkmsO5E2g k8L1Fi7L87Hd8B8tIK9g==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98 #2 (Red Hat Linux)) id 1tUnra-00000001WnQ-1sNC; Mon, 06 Jan 2025 14:13:50 +0000 Received: from mail-ej1-x632.google.com ([2a00:1450:4864:20::632]) by bombadil.infradead.org with esmtps (Exim 4.98 #2 (Red Hat Linux)) id 1tUnrX-00000001Wmc-3RHp for linux-amlogic@lists.infradead.org; Mon, 06 Jan 2025 14:13:48 +0000 Received: by mail-ej1-x632.google.com with SMTP id a640c23a62f3a-aaee2c5ee6eso1641065266b.1 for ; Mon, 06 Jan 2025 06:13:47 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlemail.com; s=20230601; t=1736172826; x=1736777626; darn=lists.infradead.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=TJsdF/HqDSazQeuRYtol4zBsSURNokKA1EzOunr3pJI=; b=FdGLsNXmFS0JfpP2NC/aNf2y6I9eQwLJRvXdkRlTjAc/qwwqFeiKwYrXzE1ae6+qqh dBW7y3/HAzFpivKQl0+fNnlZtuHLXWHZpHCmW0DOtL1Ozipr+N4XmWGha3/dkGncgpx8 cJ/kpnrR+4RBX6jBXqvVG8N1brdXH2T5JVM8nUv5H2SIecEpt8bSMECMhF3rDleW1oZy ssTr/pwRRcQUiNlHhuDiig3F/h6OXg+PtdKslCIhIYOYA2qi0fC5QSBcS8lU6oV6TD5L 9Y9VyhJHvSyVkZHahlL5QyrUpToSNpDEqp+FJlXrJMGun5ZDUz7/cLslPcTGrAHtrFsO Nxpg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1736172826; x=1736777626; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=TJsdF/HqDSazQeuRYtol4zBsSURNokKA1EzOunr3pJI=; b=MYDYpyTNO/EuTeinuppyI7liCx0iY9p4RlV8Kt97ihILrF9mmtKaTqoOcfENHM/q7z stl+3SAmkbUOnYO/rHgpfwYHnuJRUSlZcjm93J35EYcrdC/JPBMepsHc0GnkCqK+B9d2 pIslSi56lethQ0dPsBmj89VTCs/0Ic+2Mkq+WmXW7lVIcir/gDScHbYrpIgZNVkZbAHC k/8e3/oGHPOPIq6oGAQf7JbVUTxdLKuxqrFc+R3CImiZsYAXQ54F9SwLwiz5+5V38wXn 8qx2CZVkbr8kJV30ky4gEmlZOqbRc/SFzK3aAmZBrkv8g10zpZBkx7B+gb9M0Sugi5rj DN4g== X-Forwarded-Encrypted: i=1; AJvYcCXXn4uPuazwQ2aVwN0X5yI3OpbbowpTpHD9B7Gs8lOlgB4U17aQ8zduhsQbxfINejItCOpWuRPsEAYozGE9@lists.infradead.org X-Gm-Message-State: AOJu0YxSKXTX1BSDzaZZYLvgpqbkYylX+03SPT4dfvsDazxfi20jPhLq tvwUNep+WoyD9TYRJO2gVzKaV09IbazPTLh/lOOsWn7nvCjkaD/5 X-Gm-Gg: ASbGncvni/pZ++8MrTPqSJYznU2U9eYmaT3q0zIyDqY9plR9fK7Tj19XsQPgXplTGZF Dg/Nk839veQRbxxvAQ09knCxNHmtQAhaxH4Ql8R9so8wADvz3eP+VcayO2rcQJcCJmH2SDQVHo0 Iy1xzoQwBD44gIi+bCV5JPEROy01/V9D5oKHVR+bfuhFc9MZmlxb8JVJGl/fuqM3Yi8B7KhxWNk bNZ+/MCZYdzZ6O74vCNffXrgKQiBkh1FA8ZZuL3mHIVdeVWKNIqmeyyAJZv1q0wNjHbDSbMj6cP Lves8oFIph7Mi+vJgDzADPQytRvTDauVlBw6G3xcd2cu0AyuXpPH/6m2MxgwuRE4P8j/TOvvb4d bFkm84w== X-Google-Smtp-Source: AGHT+IHIuepFynI4A05OgDhT0oqn0GIfPBMm7sdjUOMILAaYgE1oj9VYbYzk1jxK2bfrwjvAPu4g8Q== X-Received: by 2002:a17:907:6e90:b0:aa6:5d30:d974 with SMTP id a640c23a62f3a-aac2d3286bfmr6068129366b.28.1736172826189; Mon, 06 Jan 2025 06:13:46 -0800 (PST) Received: from localhost.localdomain (dynamic-2a02-3100-a9f2-7d00-0000-0000-0000-0e63.310.pool.telefonica.de. [2a02:3100:a9f2:7d00::e63]) by smtp.googlemail.com with ESMTPSA id a640c23a62f3a-aaede7ef3cfsm1811342766b.77.2025.01.06.06.13.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 06 Jan 2025 06:13:45 -0800 (PST) From: Martin Blumenstingl To: linux-sound@vger.kernel.org, linux-amlogic@lists.infradead.org Cc: s.nawrocki@samsung.com, lgirdwood@gmail.com, broonie@kernel.org, linux-kernel@vger.kernel.org, jbrunet@baylibre.com, Martin Blumenstingl Subject: [RFC PATCH v1 2/2] ASoC: dapm: add support for preparing streams Date: Mon, 6 Jan 2025 15:13:16 +0100 Message-ID: <20250106141316.375984-3-martin.blumenstingl@googlemail.com> X-Mailer: git-send-email 2.47.1 In-Reply-To: <20250106141316.375984-1-martin.blumenstingl@googlemail.com> References: <20250106141316.375984-1-martin.blumenstingl@googlemail.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20250106_061347_868448_F893E5BF X-CRM114-Status: GOOD ( 11.74 ) X-BeenThere: linux-amlogic@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-amlogic" Errors-To: linux-amlogic-bounces+linux-amlogic=archiver.kernel.org@lists.infradead.org Codec driver can implement .hw_params and/or .prepare from struct snd_soc_dai_ops. For codec-to-codec links only the former (.hw_params) callback has been called. On platforms like Amlogic Meson8/8b/8m2 the SoC's sound card (sound/soc/meson/gx-card.c) uses a codec-to-codec link for the HDMI codec output because further digital routing is required after the backend. The new DRM HDMI (audio) codec framework (which internally uses sound/soc/codecs/hdmi-codec.c) relies on the .prepare callback of the hdmi-codec to be called. Implement a call to snd_soc_dai_prepare() so the .prepare callback of the hdmi-codec is called on those platforms. For platforms or sound cards without a codec-to-codec link with additional parameters (which applies to most hardware) this changes nothing as the .prepare callback is already called via snd_pcm_do_prepare() (as well as dpcm_fe_dai_prepare() and dpcm_be_dai_prepare()) on those. Suggested-by: Jerome Brunet Signed-off-by: Martin Blumenstingl --- sound/soc/soc-dapm.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/sound/soc/soc-dapm.c b/sound/soc/soc-dapm.c index 99521c784a9b..ac8eef217dc4 100644 --- a/sound/soc/soc-dapm.c +++ b/sound/soc/soc-dapm.c @@ -4013,6 +4013,13 @@ static int snd_soc_dai_link_event(struct snd_soc_dapm_widget *w, break; case SND_SOC_DAPM_POST_PMU: + snd_soc_dapm_widget_for_each_sink_path(w, path) { + sink = path->sink->priv; + + snd_soc_dai_prepare(sink, substream); + ret = 0; + } + snd_soc_dapm_widget_for_each_sink_path(w, path) { sink = path->sink->priv;