From patchwork Fri Apr 26 09:57:26 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Cezary Rojewski X-Patchwork-Id: 792711 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 alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) (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 B9507C4345F for ; Fri, 26 Apr 2024 10:00:58 +0000 (UTC) Received: from alsa1.perex.cz (alsa1.perex.cz [207.180.221.201]) (using TLSv1.2 with cipher ADH-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by alsa0.perex.cz (Postfix) with ESMTPS id DB430844; Fri, 26 Apr 2024 12:00:46 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz DB430844 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1714125656; bh=DUVgDs0/gvFlo4f+lMztb4TNTC7UqT0l2BjujtY77hY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-Id: List-Archive:List-Help:List-Owner:List-Post:List-Subscribe: List-Unsubscribe:From; b=Ry35HmHwyahM53eti3q0nqPYZ2vdeNJMb/qeft/sU4FiwJuuQydQrhF/JuxAuFl4N 2Z/Uy+jhzQ2Xqt7UMmizUdraA4yy6Cy9KgnTrSMjizTrXBiyQXqYH3RA2fHEo27/OQ PiIQpMYSEPcbirjY7er1aOZ2sB/cFXvfgPm84fW4= Received: by alsa1.perex.cz (Postfix, from userid 50401) id 7D3E6F805DF; Fri, 26 Apr 2024 11:59:50 +0200 (CEST) Received: from mailman-core.alsa-project.org (mailman-core.alsa-project.org [10.254.200.10]) by alsa1.perex.cz (Postfix) with ESMTP id ABDF8F805F7; Fri, 26 Apr 2024 11:59:49 +0200 (CEST) Received: by alsa1.perex.cz (Postfix, from userid 50401) id C3ACDF80423; Fri, 26 Apr 2024 11:57:11 +0200 (CEST) Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.11]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by alsa1.perex.cz (Postfix) with ESMTPS id 4D47DF8003C for ; Fri, 26 Apr 2024 11:56:54 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz 4D47DF8003C Authentication-Results: alsa1.perex.cz; dkim=pass (2048-bit key, unprotected) header.d=intel.com header.i=@intel.com header.a=rsa-sha256 header.s=Intel header.b=HMndcyhK DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1714125417; x=1745661417; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=DUVgDs0/gvFlo4f+lMztb4TNTC7UqT0l2BjujtY77hY=; b=HMndcyhK2IOJhANSSkyr9LkASu+EPmC5oXWubDjHTfpB8c7VRc88McWV CQwsNMlcei36IVXJ7RfxDHmmK53y+eGghnbtQrNMYg8mjoWQTcYCYIlZB LX2QX7eEq3mjdAfD5kojmp8Qv9428stiGIVUaSdfQMgDO3CqCaXywYLMp Fwlrnu6zLoDtCN4UMBeAgHe6bdYSRPQsWhdF1S6O9iPtb5AE6wbanHMpt c9/YMoKcDzLms5LIIRzK3PH6uStAK6sDxZEuAMxioeVZfY8/YQuOoJ49a qG7gWRCBKE38mBAsUUdqxs2dU1m11kFlR9mw9HGF+1Z9G4mWeoXHb4hps Q==; X-CSE-ConnectionGUID: 6J3Q5j/xRZeM2G4HqG9fJw== X-CSE-MsgGUID: rFtrjQJYQPKHg1xbFeESoQ== X-IronPort-AV: E=McAfee;i="6600,9927,11055"; a="20409184" X-IronPort-AV: E=Sophos;i="6.07,232,1708416000"; d="scan'208";a="20409184" Received: from fmviesa010.fm.intel.com ([10.60.135.150]) by orvoesa103.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 26 Apr 2024 02:56:51 -0700 X-CSE-ConnectionGUID: JimNMcCbRmCgssMA9AEfhQ== X-CSE-MsgGUID: VXfDG88vQIuOE7DecZbNLQ== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.07,232,1708416000"; d="scan'208";a="25460546" Received: from crojewsk-ctrl.igk.intel.com ([10.102.9.28]) by fmviesa010.fm.intel.com with ESMTP; 26 Apr 2024 02:56:49 -0700 From: Cezary Rojewski To: broonie@kernel.org Cc: alsa-devel@alsa-project.org, linux-sound@vger.kernel.org, tiwai@suse.com, perex@perex.cz, amadeuszx.slawinski@linux.intel.com, Cezary Rojewski Subject: [PATCH 1/8] ASoC: pcm: Reverse iterate DAIs when shutting them down Date: Fri, 26 Apr 2024 11:57:26 +0200 Message-Id: <20240426095733.3946951-2-cezary.rojewski@intel.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20240426095733.3946951-1-cezary.rojewski@intel.com> References: <20240426095733.3946951-1-cezary.rojewski@intel.com> MIME-Version: 1.0 Message-ID-Hash: D7XTR5F3LRDSDJRWEY7KJLPYZA535UAU X-Message-ID-Hash: D7XTR5F3LRDSDJRWEY7KJLPYZA535UAU X-MailFrom: cezary.rojewski@intel.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; header-match-alsa-devel.alsa-project.org-0; header-match-alsa-devel.alsa-project.org-1; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header X-Mailman-Version: 3.3.9 Precedence: list List-Id: "Alsa-devel mailing list for ALSA developers - http://www.alsa-project.org" Archived-At: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: During startup snd_soc_dai_startup() is launched in ascending order and the exact same thing is done during shutdown procedure. Reverse the order in the latter so that it is symmetric to the former. Signed-off-by: Cezary Rojewski --- include/sound/soc.h | 4 ++++ sound/soc/soc-pcm.c | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/include/sound/soc.h b/include/sound/soc.h index 0376f7e4c15d..a4747c3d0856 100644 --- a/include/sound/soc.h +++ b/include/sound/soc.h @@ -1225,6 +1225,10 @@ struct snd_soc_pcm_runtime { ((i) < (rtd)->dai_link->num_cpus + (rtd)->dai_link->num_codecs) && \ ((dai) = (rtd)->dais[i]); \ (i)++) +#define for_each_rtd_dais_reverse(rtd, i, dai) \ + for ((i) = (rtd)->dai_link->num_cpus + (rtd)->dai_link->num_codecs - 1; \ + (i) >= 0 && ((dai) = (rtd)->dais[i]); \ + (i)--) #define for_each_rtd_ch_maps(rtd, i, ch_maps) for_each_link_ch_maps(rtd->dai_link, i, ch_maps) void snd_soc_close_delayed_work(struct snd_soc_pcm_runtime *rtd); diff --git a/sound/soc/soc-pcm.c b/sound/soc/soc-pcm.c index b0e1bd7f588b..711b2f49ed88 100644 --- a/sound/soc/soc-pcm.c +++ b/sound/soc/soc-pcm.c @@ -724,7 +724,7 @@ static int soc_pcm_clean(struct snd_soc_pcm_runtime *rtd, } } - for_each_rtd_dais(rtd, i, dai) + for_each_rtd_dais_reverse(rtd, i, dai) snd_soc_dai_shutdown(dai, substream, rollback); snd_soc_link_shutdown(substream, rollback); From patchwork Fri Apr 26 09:57:27 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Cezary Rojewski X-Patchwork-Id: 792712 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 alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) (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 AEEC3C4345F for ; Fri, 26 Apr 2024 10:00:24 +0000 (UTC) Received: from alsa1.perex.cz (alsa1.perex.cz [207.180.221.201]) (using TLSv1.2 with cipher ADH-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by alsa0.perex.cz (Postfix) with ESMTPS id 6887886F; Fri, 26 Apr 2024 12:00:07 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz 6887886F DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1714125617; bh=aT40F+YO05hp/H238joGV3KbhgSHr4J7qmCIqNioPjc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-Id: List-Archive:List-Help:List-Owner:List-Post:List-Subscribe: List-Unsubscribe:From; b=szYVlUSeN/ZgBhtQA+rr8refVPcJ/u0LYy9OihduvSibSHybl+VPg/9MpMxzMJTXn +/n7ijIUYocv1yMmV3JhVrAzmgucczCHtI2Y/OjzXBxAoDBkbuj+U+4I6bM3UTbf31 jhYtzc0wek4IOKbEotvH2q6l869TQu3fkSZsaFSQ= Received: by alsa1.perex.cz (Postfix, from userid 50401) id E53AFF805A8; Fri, 26 Apr 2024 11:59:46 +0200 (CEST) Received: from mailman-core.alsa-project.org (mailman-core.alsa-project.org [10.254.200.10]) by alsa1.perex.cz (Postfix) with ESMTP id 05622F8057C; Fri, 26 Apr 2024 11:59:46 +0200 (CEST) Received: by alsa1.perex.cz (Postfix, from userid 50401) id 13EBCF80571; Fri, 26 Apr 2024 11:57:08 +0200 (CEST) Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.11]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by alsa1.perex.cz (Postfix) with ESMTPS id A70A4F80423 for ; Fri, 26 Apr 2024 11:56:55 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz A70A4F80423 Authentication-Results: alsa1.perex.cz; dkim=pass (2048-bit key, unprotected) header.d=intel.com header.i=@intel.com header.a=rsa-sha256 header.s=Intel header.b=SrT2q4Gs DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1714125417; x=1745661417; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=aT40F+YO05hp/H238joGV3KbhgSHr4J7qmCIqNioPjc=; b=SrT2q4GsJg1TJO1/w9pBkK+t+oSZQQGmCqOlFu5sy//yF/NMR8opH5oD CfAmBr4Ar5VMCrnEZOb2XEWz9NHSFpdidRq2gpNxfsL3LyEpP8+M/oU7v j4lUy1E3NkY6mIHG4enx2G+etRHcS8H+ZhVKgqDP1D4kutl2uS69cD1bV 9BJBiw3JG6VRGfWtKaQ2Xp7JeY4metkde+MWf4w/xTuKwcEMvug0kEKl+ cOehBQ0Q2yjbVocwoh3rTFBH8GuErzRobItp1zRU78n49XueKicsldm29 mhl/U6f9qRGuPMB/47QM/QDJ4X3/shvhCqNQtwyxW0cKYSOCWtSDPq1pZ w==; X-CSE-ConnectionGUID: nENsjHPcSxaVrzIaNSOoSQ== X-CSE-MsgGUID: gXJzdUbFTRq3wd1ovZGrvQ== X-IronPort-AV: E=McAfee;i="6600,9927,11055"; a="20409191" X-IronPort-AV: E=Sophos;i="6.07,232,1708416000"; d="scan'208";a="20409191" Received: from fmviesa010.fm.intel.com ([10.60.135.150]) by orvoesa103.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 26 Apr 2024 02:56:53 -0700 X-CSE-ConnectionGUID: MAMBGvDDSg2mnyUh2qhitw== X-CSE-MsgGUID: STkHw4WIRxqxfl/tXNneag== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.07,232,1708416000"; d="scan'208";a="25460560" Received: from crojewsk-ctrl.igk.intel.com ([10.102.9.28]) by fmviesa010.fm.intel.com with ESMTP; 26 Apr 2024 02:56:51 -0700 From: Cezary Rojewski To: broonie@kernel.org Cc: alsa-devel@alsa-project.org, linux-sound@vger.kernel.org, tiwai@suse.com, perex@perex.cz, amadeuszx.slawinski@linux.intel.com, Cezary Rojewski Subject: [PATCH 2/8] ASoC: Intel: avs: Relocate HDA BE DAI specific operations Date: Fri, 26 Apr 2024 11:57:27 +0200 Message-Id: <20240426095733.3946951-3-cezary.rojewski@intel.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20240426095733.3946951-1-cezary.rojewski@intel.com> References: <20240426095733.3946951-1-cezary.rojewski@intel.com> MIME-Version: 1.0 Message-ID-Hash: GKPDRPO5XVX7IK3AMP6L3XVHBMHIDMOP X-Message-ID-Hash: GKPDRPO5XVX7IK3AMP6L3XVHBMHIDMOP X-MailFrom: cezary.rojewski@intel.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; header-match-alsa-devel.alsa-project.org-0; header-match-alsa-devel.alsa-project.org-1; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header X-Mailman-Version: 3.3.9 Precedence: list List-Id: "Alsa-devel mailing list for ALSA developers - http://www.alsa-project.org" Archived-At: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: DAI's startup()/shutdown() shall deal with allocation and freeing of resources needed to facilitate streaming over it. Currently for HDAudio BE DAIs some of that task is done in component->open()/close(). Relocate the relevant pieces to address that. Signed-off-by: Cezary Rojewski --- sound/soc/intel/avs/pcm.c | 55 ++++++++++++++++++--------------------- 1 file changed, 26 insertions(+), 29 deletions(-) diff --git a/sound/soc/intel/avs/pcm.c b/sound/soc/intel/avs/pcm.c index 77a7e8f93951..f3cd54f355ef 100644 --- a/sound/soc/intel/avs/pcm.c +++ b/sound/soc/intel/avs/pcm.c @@ -277,12 +277,36 @@ static const struct snd_soc_dai_ops avs_dai_hda_be_ops; static int avs_dai_hda_be_startup(struct snd_pcm_substream *substream, struct snd_soc_dai *dai) { - return avs_dai_startup(substream, dai, false, &avs_dai_hda_be_ops); + struct snd_soc_pcm_runtime *rtd = snd_soc_substream_to_rtd(substream); + struct hdac_ext_stream *link_stream; + struct hda_codec *codec; + int ret; + + ret = avs_dai_startup(substream, dai, false, &avs_dai_hda_be_ops); + if (ret) + return ret; + + codec = dev_to_hda_codec(snd_soc_rtd_to_codec(rtd, 0)->dev); + link_stream = snd_hdac_ext_stream_assign(&codec->bus->core, substream, + HDAC_EXT_STREAM_TYPE_LINK); + if (!link_stream) { + avs_dai_nonhda_be_shutdown(substream, dai); + return -EBUSY; + } + + substream->runtime->private_data = link_stream; + return 0; } static void avs_dai_hda_be_shutdown(struct snd_pcm_substream *substream, struct snd_soc_dai *dai) { - return avs_dai_nonhda_be_shutdown(substream, dai); + struct hdac_ext_stream *link_stream; + + link_stream = substream->runtime->private_data; + snd_hdac_ext_stream_release(link_stream, HDAC_EXT_STREAM_TYPE_LINK); + substream->runtime->private_data = NULL; + + avs_dai_nonhda_be_shutdown(substream, dai); } static int avs_dai_hda_be_hw_params(struct snd_pcm_substream *substream, @@ -1576,8 +1600,6 @@ static int avs_component_hda_open(struct snd_soc_component *component, struct snd_pcm_substream *substream) { struct snd_soc_pcm_runtime *rtd = snd_soc_substream_to_rtd(substream); - struct hdac_ext_stream *link_stream; - struct hda_codec *codec; if (!rtd->dai_link->no_pcm) { struct snd_pcm_hardware hwparams = avs_pcm_hardware; @@ -1609,30 +1631,6 @@ static int avs_component_hda_open(struct snd_soc_component *component, return snd_soc_set_runtime_hwparams(substream, &hwparams); } - codec = dev_to_hda_codec(snd_soc_rtd_to_codec(rtd, 0)->dev); - link_stream = snd_hdac_ext_stream_assign(&codec->bus->core, substream, - HDAC_EXT_STREAM_TYPE_LINK); - if (!link_stream) - return -EBUSY; - - substream->runtime->private_data = link_stream; - return 0; -} - -static int avs_component_hda_close(struct snd_soc_component *component, - struct snd_pcm_substream *substream) -{ - struct snd_soc_pcm_runtime *rtd = snd_soc_substream_to_rtd(substream); - struct hdac_ext_stream *link_stream; - - /* only BE DAI links are handled here */ - if (!rtd->dai_link->no_pcm) - return 0; - - link_stream = substream->runtime->private_data; - snd_hdac_ext_stream_release(link_stream, HDAC_EXT_STREAM_TYPE_LINK); - substream->runtime->private_data = NULL; - return 0; } @@ -1643,7 +1641,6 @@ static const struct snd_soc_component_driver avs_hda_component_driver = { .suspend = avs_component_suspend, .resume = avs_component_resume, .open = avs_component_hda_open, - .close = avs_component_hda_close, .pointer = avs_component_pointer, .mmap = avs_component_mmap, .pcm_construct = avs_component_construct, From patchwork Fri Apr 26 09:57:28 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Cezary Rojewski X-Patchwork-Id: 792414 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 alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) (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 20FA3C4345F for ; Fri, 26 Apr 2024 10:01:46 +0000 (UTC) Received: from alsa1.perex.cz (alsa1.perex.cz [207.180.221.201]) (using TLSv1.2 with cipher ADH-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by alsa0.perex.cz (Postfix) with ESMTPS id 1DDB2857; Fri, 26 Apr 2024 12:01:34 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz 1DDB2857 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1714125704; bh=/OpGaXKLK/xKmfeJNxX3PuUmLBLHR9is3aONCN7HtOU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-Id: List-Archive:List-Help:List-Owner:List-Post:List-Subscribe: List-Unsubscribe:From; b=RDKYEhfbQiVYn43XBFvN+Cht3pgZV6a70TnSlKIkobYDjWLaWxncylWIRYUuCAMD5 ziWpioY1BaRY4G0yF9RXoU9CHJ1sKuuWrHVZY5Mac3W68XjvJm0pUD5QdEV0nxD0p2 Rp0WkFvCjk8/U1uZVGZbvs7T4I7Y+a4Iu8/eSvsY= Received: by alsa1.perex.cz (Postfix, from userid 50401) id 39F51F80673; Fri, 26 Apr 2024 11:59:55 +0200 (CEST) Received: from mailman-core.alsa-project.org (mailman-core.alsa-project.org [10.254.200.10]) by alsa1.perex.cz (Postfix) with ESMTP id D24BAF80680; Fri, 26 Apr 2024 11:59:54 +0200 (CEST) Received: by alsa1.perex.cz (Postfix, from userid 50401) id D3BD9F802E8; Fri, 26 Apr 2024 11:57:14 +0200 (CEST) Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.11]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by alsa1.perex.cz (Postfix) with ESMTPS id DDE30F80548 for ; Fri, 26 Apr 2024 11:56:56 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz DDE30F80548 Authentication-Results: alsa1.perex.cz; dkim=pass (2048-bit key, unprotected) header.d=intel.com header.i=@intel.com header.a=rsa-sha256 header.s=Intel header.b=lv4UUZDv DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1714125421; x=1745661421; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=/OpGaXKLK/xKmfeJNxX3PuUmLBLHR9is3aONCN7HtOU=; b=lv4UUZDvH82a3DjzI8t+fE6wki6dMc32QiTh7PWw+DZX0pIarnLoB8px JIcJmsReWvNMUzJ3lgN+LjKEONsWBnw/EFY72Otdg1AagFypBN+f+gri5 9xViPxLjnWvghS1a/9RqsU4D2qP/bMKFAEn9DCj1YX37ldiCkPlxroIMU RJgP6i7fX9kn6/rZiW0UcQelp3rOXz1DkR9tb37kOns0pzbgS7GvKDkMX QLLUNv9O8C6d5h2vZBi3qAsHuxXraTtO1qC2fHzb13lV3tAEAgw+rrjMp yUvwVddecVgxEgIQkq5ZvyJ4HkNA3yAH2MwevI6Plam9tCCmDuwcRNcH1 g==; X-CSE-ConnectionGUID: RJDWW5KFQmmok7qOyG9TEA== X-CSE-MsgGUID: iLAmkRHvQzerQqNu7P5iZg== X-IronPort-AV: E=McAfee;i="6600,9927,11055"; a="20409199" X-IronPort-AV: E=Sophos;i="6.07,232,1708416000"; d="scan'208";a="20409199" Received: from fmviesa010.fm.intel.com ([10.60.135.150]) by orvoesa103.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 26 Apr 2024 02:56:55 -0700 X-CSE-ConnectionGUID: Ie1GZPzITB+CkM5Yut6EyA== X-CSE-MsgGUID: l5cldLv6RrCbbDwW43KaZA== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.07,232,1708416000"; d="scan'208";a="25460573" Received: from crojewsk-ctrl.igk.intel.com ([10.102.9.28]) by fmviesa010.fm.intel.com with ESMTP; 26 Apr 2024 02:56:53 -0700 From: Cezary Rojewski To: broonie@kernel.org Cc: alsa-devel@alsa-project.org, linux-sound@vger.kernel.org, tiwai@suse.com, perex@perex.cz, amadeuszx.slawinski@linux.intel.com, Cezary Rojewski Subject: [PATCH 3/8] ASoC: Intel: avs: Remove redundancy around DAI shutdown Date: Fri, 26 Apr 2024 11:57:28 +0200 Message-Id: <20240426095733.3946951-4-cezary.rojewski@intel.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20240426095733.3946951-1-cezary.rojewski@intel.com> References: <20240426095733.3946951-1-cezary.rojewski@intel.com> MIME-Version: 1.0 Message-ID-Hash: PZE65RJWILRZ5KC5CON7AV7MOJTL2QOF X-Message-ID-Hash: PZE65RJWILRZ5KC5CON7AV7MOJTL2QOF X-MailFrom: cezary.rojewski@intel.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; header-match-alsa-devel.alsa-project.org-0; header-match-alsa-devel.alsa-project.org-1; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header X-Mailman-Version: 3.3.9 Precedence: list List-Id: "Alsa-devel mailing list for ALSA developers - http://www.alsa-project.org" Archived-At: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: Move avs_dai_nonhda_be_shutdown() to avs_dai_shutdown() as the function is common for all transfer types, not just non-HDAudio ones. Use it to simplify avs_dai_fe_shutdown(). While at it, fix explicit kfree(data) and use the destructor instead. Signed-off-by: Cezary Rojewski --- sound/soc/intel/avs/pcm.c | 44 +++++++++++++++++---------------------- 1 file changed, 19 insertions(+), 25 deletions(-) diff --git a/sound/soc/intel/avs/pcm.c b/sound/soc/intel/avs/pcm.c index f3cd54f355ef..23f7e0fae817 100644 --- a/sound/soc/intel/avs/pcm.c +++ b/sound/soc/intel/avs/pcm.c @@ -85,6 +85,21 @@ static int avs_dai_startup(struct snd_pcm_substream *substream, struct snd_soc_d return 0; } +static void avs_dai_shutdown(struct snd_pcm_substream *substream, struct snd_soc_dai *dai) +{ + struct snd_soc_pcm_runtime *rtd = snd_soc_substream_to_rtd(substream); + struct avs_dev *adev = to_avs_dev(dai->dev); + struct avs_dma_data *data; + + data = snd_soc_dai_get_dma_data(dai, substream); + + if (rtd->dai_link->ignore_suspend) + adev->num_lp_paths--; + + snd_soc_dai_set_dma_data(dai, substream, NULL); + kfree(data); +} + static int avs_dai_hw_params(struct snd_pcm_substream *substream, struct snd_pcm_hw_params *fe_hw_params, struct snd_pcm_hw_params *be_hw_params, struct snd_soc_dai *dai, @@ -166,21 +181,6 @@ static int avs_dai_nonhda_be_startup(struct snd_pcm_substream *substream, struct return avs_dai_startup(substream, dai, false, &avs_dai_nonhda_be_ops); } -static void avs_dai_nonhda_be_shutdown(struct snd_pcm_substream *substream, struct snd_soc_dai *dai) -{ - struct snd_soc_pcm_runtime *rtd = snd_soc_substream_to_rtd(substream); - struct avs_dev *adev = to_avs_dev(dai->dev); - struct avs_dma_data *data; - - if (rtd->dai_link->ignore_suspend) - adev->num_lp_paths--; - - data = snd_soc_dai_get_dma_data(dai, substream); - - snd_soc_dai_set_dma_data(dai, substream, NULL); - kfree(data); -} - static int avs_dai_nonhda_be_hw_params(struct snd_pcm_substream *substream, struct snd_pcm_hw_params *hw_params, struct snd_soc_dai *dai) { @@ -266,7 +266,7 @@ static int avs_dai_nonhda_be_trigger(struct snd_pcm_substream *substream, int cm static const struct snd_soc_dai_ops avs_dai_nonhda_be_ops = { .startup = avs_dai_nonhda_be_startup, - .shutdown = avs_dai_nonhda_be_shutdown, + .shutdown = avs_dai_shutdown, .hw_params = avs_dai_nonhda_be_hw_params, .hw_free = avs_dai_nonhda_be_hw_free, .prepare = avs_dai_nonhda_be_prepare, @@ -290,7 +290,7 @@ static int avs_dai_hda_be_startup(struct snd_pcm_substream *substream, struct sn link_stream = snd_hdac_ext_stream_assign(&codec->bus->core, substream, HDAC_EXT_STREAM_TYPE_LINK); if (!link_stream) { - avs_dai_nonhda_be_shutdown(substream, dai); + avs_dai_shutdown(substream, dai); return -EBUSY; } @@ -306,7 +306,7 @@ static void avs_dai_hda_be_shutdown(struct snd_pcm_substream *substream, struct snd_hdac_ext_stream_release(link_stream, HDAC_EXT_STREAM_TYPE_LINK); substream->runtime->private_data = NULL; - avs_dai_nonhda_be_shutdown(substream, dai); + avs_dai_shutdown(substream, dai); } static int avs_dai_hda_be_hw_params(struct snd_pcm_substream *substream, @@ -558,18 +558,12 @@ static int avs_dai_fe_startup(struct snd_pcm_substream *substream, struct snd_so static void avs_dai_fe_shutdown(struct snd_pcm_substream *substream, struct snd_soc_dai *dai) { - struct snd_soc_pcm_runtime *rtd = snd_soc_substream_to_rtd(substream); - struct avs_dev *adev = to_avs_dev(dai->dev); struct avs_dma_data *data; - if (rtd->dai_link->ignore_suspend) - adev->num_lp_paths--; - data = snd_soc_dai_get_dma_data(dai, substream); - snd_soc_dai_set_dma_data(dai, substream, NULL); snd_hdac_ext_stream_release(data->host_stream, HDAC_EXT_STREAM_TYPE_HOST); - kfree(data); + avs_dai_shutdown(substream, dai); } static int avs_dai_fe_hw_params(struct snd_pcm_substream *substream, From patchwork Fri Apr 26 09:57:29 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Cezary Rojewski X-Patchwork-Id: 792416 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 alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) (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 27323C4345F for ; Fri, 26 Apr 2024 10:00:42 +0000 (UTC) Received: from alsa1.perex.cz (alsa1.perex.cz [207.180.221.201]) (using TLSv1.2 with cipher ADH-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by alsa0.perex.cz (Postfix) with ESMTPS id 5DC1CE0F; Fri, 26 Apr 2024 12:00:30 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz 5DC1CE0F DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1714125640; bh=T4nHsF9OKK9PpS+tpyMCag09I+TatdAfIymTICQ28jw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-Id: List-Archive:List-Help:List-Owner:List-Post:List-Subscribe: List-Unsubscribe:From; b=p7WaW73WucuwL/3mE/6JRKC8EZvgPJ1rVChmIF+FaOu+qbFy6yOy+1NwB3WyqFDI8 BmEvtUG/N4e7zJcKZuriHvlln13auVXBefULHIXP8rnWnv//kK0Lhk/n48MnQ7y1g6 HqBeLCt/LusKcM14ze4o6Q7IBYxlvNBERP2SF16c= Received: by alsa1.perex.cz (Postfix, from userid 50401) id 22580F805B4; Fri, 26 Apr 2024 11:59:47 +0200 (CEST) Received: from mailman-core.alsa-project.org (mailman-core.alsa-project.org [10.254.200.10]) by alsa1.perex.cz (Postfix) with ESMTP id 788E3F805C6; Fri, 26 Apr 2024 11:59:47 +0200 (CEST) Received: by alsa1.perex.cz (Postfix, from userid 50401) id 5DB0CF80570; Fri, 26 Apr 2024 11:57:10 +0200 (CEST) Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.11]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by alsa1.perex.cz (Postfix) with ESMTPS id 81A1CF802E8 for ; Fri, 26 Apr 2024 11:56:57 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz 81A1CF802E8 Authentication-Results: alsa1.perex.cz; dkim=pass (2048-bit key, unprotected) header.d=intel.com header.i=@intel.com header.a=rsa-sha256 header.s=Intel header.b=BlL5rZAH DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1714125419; x=1745661419; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=T4nHsF9OKK9PpS+tpyMCag09I+TatdAfIymTICQ28jw=; b=BlL5rZAH+aVwMqQ23hzgRsHlNcW9+RDWg2ACjahmGVcCS8pJfxlO8Oak G7oS1QoXpr+FMv2oBmW+ivWfc0qpJr1Z6qlLg4YPpQR8ygTGCoFZNFLnl yxoh03lU54kWrcZ3PbedX9C2XE9Jxdl4EPrmSb8LGwRwpPA11GKx5c4pc 4RGm+IGzN5clGiPTdPtqz/yGDRwmNG94rBfSAtJ+RCRuONYfeuk8+2zMp yWz858WF0G0wFx1rmOcKZBJN1hMvvYTJ4fkrvVYOOMSkRoyuQBpzhthGy HiSMjCNCCGOngG+oXgrEUbgLOOV/XPK8QX3Yeo8AHpuCt0soVrFPvJ+MV g==; X-CSE-ConnectionGUID: GKlkjQQuRQejQyhfPyDFMw== X-CSE-MsgGUID: nr/J5IriT6GHlMXS59WR3Q== X-IronPort-AV: E=McAfee;i="6600,9927,11055"; a="20409204" X-IronPort-AV: E=Sophos;i="6.07,232,1708416000"; d="scan'208";a="20409204" Received: from fmviesa010.fm.intel.com ([10.60.135.150]) by orvoesa103.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 26 Apr 2024 02:56:57 -0700 X-CSE-ConnectionGUID: eGWsMj9aTv2AUPXSi/+nxw== X-CSE-MsgGUID: 29Vqh8b6StOyno+65ujRbQ== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.07,232,1708416000"; d="scan'208";a="25460588" Received: from crojewsk-ctrl.igk.intel.com ([10.102.9.28]) by fmviesa010.fm.intel.com with ESMTP; 26 Apr 2024 02:56:55 -0700 From: Cezary Rojewski To: broonie@kernel.org Cc: alsa-devel@alsa-project.org, linux-sound@vger.kernel.org, tiwai@suse.com, perex@perex.cz, amadeuszx.slawinski@linux.intel.com, Cezary Rojewski Subject: [PATCH 4/8] ASoC: Intel: avs: Store pointer to adev in DAI dma_data Date: Fri, 26 Apr 2024 11:57:29 +0200 Message-Id: <20240426095733.3946951-5-cezary.rojewski@intel.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20240426095733.3946951-1-cezary.rojewski@intel.com> References: <20240426095733.3946951-1-cezary.rojewski@intel.com> MIME-Version: 1.0 Message-ID-Hash: 4GMER2UJOV6H6WDFRXBULUUVR2K4327L X-Message-ID-Hash: 4GMER2UJOV6H6WDFRXBULUUVR2K4327L X-MailFrom: cezary.rojewski@intel.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; header-match-alsa-devel.alsa-project.org-0; header-match-alsa-devel.alsa-project.org-1; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header X-Mailman-Version: 3.3.9 Precedence: list List-Id: "Alsa-devel mailing list for ALSA developers - http://www.alsa-project.org" Archived-At: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: Reduce the number of to_avs_dev() casts by storing the driver context in DAI's dma_data. Signed-off-by: Cezary Rojewski --- sound/soc/intel/avs/pcm.c | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/sound/soc/intel/avs/pcm.c b/sound/soc/intel/avs/pcm.c index 23f7e0fae817..a3a04115216c 100644 --- a/sound/soc/intel/avs/pcm.c +++ b/sound/soc/intel/avs/pcm.c @@ -22,6 +22,7 @@ struct avs_dma_data { struct avs_tplg_path_template *template; struct avs_path *path; + struct avs_dev *adev; /* * link stream is stored within substream's runtime * private_data to fulfill the needs of codec BE path @@ -60,7 +61,7 @@ static int avs_dai_startup(struct snd_pcm_substream *substream, struct snd_soc_d const struct snd_soc_dai_ops *ops) { struct snd_soc_pcm_runtime *rtd = snd_soc_substream_to_rtd(substream); - struct avs_dev *adev = to_avs_dev(dai->dev); + struct avs_dev *adev = to_avs_dev(dai->component->dev); struct avs_tplg_path_template *template; struct avs_dma_data *data; @@ -77,6 +78,7 @@ static int avs_dai_startup(struct snd_pcm_substream *substream, struct snd_soc_d data->substream = substream; data->template = template; + data->adev = adev; snd_soc_dai_set_dma_data(dai, substream, data); if (rtd->dai_link->ignore_suspend) @@ -88,13 +90,12 @@ static int avs_dai_startup(struct snd_pcm_substream *substream, struct snd_soc_d static void avs_dai_shutdown(struct snd_pcm_substream *substream, struct snd_soc_dai *dai) { struct snd_soc_pcm_runtime *rtd = snd_soc_substream_to_rtd(substream); - struct avs_dev *adev = to_avs_dev(dai->dev); struct avs_dma_data *data; data = snd_soc_dai_get_dma_data(dai, substream); if (rtd->dai_link->ignore_suspend) - adev->num_lp_paths--; + data->adev->num_lp_paths--; snd_soc_dai_set_dma_data(dai, substream, NULL); kfree(data); @@ -107,7 +108,6 @@ static int avs_dai_hw_params(struct snd_pcm_substream *substream, { struct avs_dma_data *data; struct avs_path *path; - struct avs_dev *adev = to_avs_dev(dai->dev); int ret; data = snd_soc_dai_get_dma_data(dai, substream); @@ -124,7 +124,7 @@ static int avs_dai_hw_params(struct snd_pcm_substream *substream, params_rate(be_hw_params), params_channels(be_hw_params), params_width(be_hw_params), params_physical_width(be_hw_params)); - path = avs_path_create(adev, dma_id, data->template, fe_hw_params, be_hw_params); + path = avs_path_create(data->adev, dma_id, data->template, fe_hw_params, be_hw_params); if (IS_ERR(path)) { ret = PTR_ERR(path); dev_err(dai->dev, "create path failed: %d\n", ret); @@ -505,8 +505,7 @@ static int avs_dai_fe_startup(struct snd_pcm_substream *substream, struct snd_so { struct snd_pcm_runtime *runtime = substream->runtime; struct avs_dma_data *data; - struct avs_dev *adev = to_avs_dev(dai->dev); - struct hdac_bus *bus = &adev->base.core; + struct hdac_bus *bus; struct hdac_ext_stream *host_stream; int ret; @@ -515,6 +514,7 @@ static int avs_dai_fe_startup(struct snd_pcm_substream *substream, struct snd_so return ret; data = snd_soc_dai_get_dma_data(dai, substream); + bus = &data->adev->base.core; host_stream = snd_hdac_ext_stream_assign(bus, substream, HDAC_EXT_STREAM_TYPE_HOST); if (!host_stream) { @@ -655,7 +655,6 @@ static int avs_dai_fe_prepare(struct snd_pcm_substream *substream, struct snd_so struct snd_pcm_runtime *runtime = substream->runtime; struct snd_soc_pcm_stream *stream_info; struct avs_dma_data *data; - struct avs_dev *adev = to_avs_dev(dai->dev); struct hdac_ext_stream *host_stream; unsigned int format_val; struct hdac_bus *bus; @@ -685,7 +684,7 @@ static int avs_dai_fe_prepare(struct snd_pcm_substream *substream, struct snd_so if (ret < 0) return ret; - ret = avs_dai_prepare(adev, substream, dai); + ret = avs_dai_prepare(data->adev, substream, dai); if (ret) return ret; From patchwork Fri Apr 26 09:57:30 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Cezary Rojewski X-Patchwork-Id: 792415 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 alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) (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 83540C4345F for ; Fri, 26 Apr 2024 10:01:10 +0000 (UTC) Received: from alsa1.perex.cz (alsa1.perex.cz [207.180.221.201]) (using TLSv1.2 with cipher ADH-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by alsa0.perex.cz (Postfix) with ESMTPS id 87D6A84D; Fri, 26 Apr 2024 12:00:58 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz 87D6A84D DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1714125668; bh=p6C6SKzHWunPyU/UTVA3+lQ7OyWR4ICR+xObO73m00o=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-Id: List-Archive:List-Help:List-Owner:List-Post:List-Subscribe: List-Unsubscribe:From; b=NBcHQdzoJT3/pfE6Y4CPpYK8yWzOPTYiSeTeVbWxh7CRvN2tgxl8rWRU0FYtGo7H1 cUSS8KlJNdNW2WD/H08leYlN0kUIni8pWWH13+0jspxgwom0ydh82FcfhJharcLLYc v9j2yH/GlZtrTJ4xy4ROaTIaG0xSw4VOoCF1RQoA= Received: by alsa1.perex.cz (Postfix, from userid 50401) id 6C45BF8060F; Fri, 26 Apr 2024 11:59:52 +0200 (CEST) Received: from mailman-core.alsa-project.org (mailman-core.alsa-project.org [10.254.200.10]) by alsa1.perex.cz (Postfix) with ESMTP id CB6E9F80610; Fri, 26 Apr 2024 11:59:51 +0200 (CEST) Received: by alsa1.perex.cz (Postfix, from userid 50401) id 42C57F802E8; Fri, 26 Apr 2024 11:57:12 +0200 (CEST) Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.11]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by alsa1.perex.cz (Postfix) with ESMTPS id 6D0C9F8045D for ; Fri, 26 Apr 2024 11:56:59 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz 6D0C9F8045D Authentication-Results: alsa1.perex.cz; dkim=pass (2048-bit key, unprotected) header.d=intel.com header.i=@intel.com header.a=rsa-sha256 header.s=Intel header.b=aGdX4+zk DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1714125421; x=1745661421; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=p6C6SKzHWunPyU/UTVA3+lQ7OyWR4ICR+xObO73m00o=; b=aGdX4+zkc7Z/CEjtsZMvsscbWNedlL243/IDGM5zr3Nq/p5gU58rXN1A 2vZeYLI7p3dJuPrn18UUzQ7AYUL9GOP7a8VjqKGZPcQgFQV+RNsUdmpim CQgZURQmhp69Ulz2O7w2qcNAYkmcmDp0Th3z4Iu6MVFc3WiLuocLzxhYR D22xGwrJ84eUGjLm9hIwVeMMy6uTWPWogby8RLlCHlOlrIQcOHmKhMc30 oquXfPT3OSJaYsVKwYyfW/ZBz45fcgz6126jsdWMm6M0JvU4hT9TAGUIf ZHuKGoIS7XIpfezbAp+he34sMZF7zVpLLL5lggOiFRblXgmZsbwdcJ3RW A==; X-CSE-ConnectionGUID: id1wIZbZQGCb8ii9kub4yA== X-CSE-MsgGUID: JWNb/IklQVmlGygMgazG0A== X-IronPort-AV: E=McAfee;i="6600,9927,11055"; a="20409212" X-IronPort-AV: E=Sophos;i="6.07,232,1708416000"; d="scan'208";a="20409212" Received: from fmviesa010.fm.intel.com ([10.60.135.150]) by orvoesa103.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 26 Apr 2024 02:56:59 -0700 X-CSE-ConnectionGUID: lOAyboRJSJqCs86Mt7mWQQ== X-CSE-MsgGUID: qgvNodMGR8yWTZe/5iWcmQ== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.07,232,1708416000"; d="scan'208";a="25460600" Received: from crojewsk-ctrl.igk.intel.com ([10.102.9.28]) by fmviesa010.fm.intel.com with ESMTP; 26 Apr 2024 02:56:57 -0700 From: Cezary Rojewski To: broonie@kernel.org Cc: alsa-devel@alsa-project.org, linux-sound@vger.kernel.org, tiwai@suse.com, perex@perex.cz, amadeuszx.slawinski@linux.intel.com, Cezary Rojewski Subject: [PATCH 5/8] ASoC: Intel: avs: Remove redundancy around DAI startup Date: Fri, 26 Apr 2024 11:57:30 +0200 Message-Id: <20240426095733.3946951-6-cezary.rojewski@intel.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20240426095733.3946951-1-cezary.rojewski@intel.com> References: <20240426095733.3946951-1-cezary.rojewski@intel.com> MIME-Version: 1.0 Message-ID-Hash: E3LYXMZNY4IQERZV2R7IMDKOTAAUY36A X-Message-ID-Hash: E3LYXMZNY4IQERZV2R7IMDKOTAAUY36A X-MailFrom: cezary.rojewski@intel.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; header-match-alsa-devel.alsa-project.org-0; header-match-alsa-devel.alsa-project.org-1; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header X-Mailman-Version: 3.3.9 Precedence: list List-Id: "Alsa-devel mailing list for ALSA developers - http://www.alsa-project.org" Archived-At: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: Half of the arguments in avs_dai_startup() are unused and can be dropped. With the function updated, it matches its template in snd_soc_dai_ops and can be referenced throughout the pcm.c file without need of any wrappers. Signed-off-by: Cezary Rojewski --- sound/soc/intel/avs/pcm.c | 22 +++++----------------- 1 file changed, 5 insertions(+), 17 deletions(-) diff --git a/sound/soc/intel/avs/pcm.c b/sound/soc/intel/avs/pcm.c index a3a04115216c..0771a9716f4b 100644 --- a/sound/soc/intel/avs/pcm.c +++ b/sound/soc/intel/avs/pcm.c @@ -57,15 +57,14 @@ avs_dai_find_path_template(struct snd_soc_dai *dai, bool is_fe, int direction) return dw->priv; } -static int avs_dai_startup(struct snd_pcm_substream *substream, struct snd_soc_dai *dai, bool is_fe, - const struct snd_soc_dai_ops *ops) +static int avs_dai_startup(struct snd_pcm_substream *substream, struct snd_soc_dai *dai) { struct snd_soc_pcm_runtime *rtd = snd_soc_substream_to_rtd(substream); struct avs_dev *adev = to_avs_dev(dai->component->dev); struct avs_tplg_path_template *template; struct avs_dma_data *data; - template = avs_dai_find_path_template(dai, is_fe, substream->stream); + template = avs_dai_find_path_template(dai, !rtd->dai_link->no_pcm, substream->stream); if (!template) { dev_err(dai->dev, "no %s path for dai %s, invalid tplg?\n", snd_pcm_stream_str(substream), dai->name); @@ -174,13 +173,6 @@ static int avs_dai_prepare(struct avs_dev *adev, struct snd_pcm_substream *subst return ret; } -static const struct snd_soc_dai_ops avs_dai_nonhda_be_ops; - -static int avs_dai_nonhda_be_startup(struct snd_pcm_substream *substream, struct snd_soc_dai *dai) -{ - return avs_dai_startup(substream, dai, false, &avs_dai_nonhda_be_ops); -} - static int avs_dai_nonhda_be_hw_params(struct snd_pcm_substream *substream, struct snd_pcm_hw_params *hw_params, struct snd_soc_dai *dai) { @@ -265,7 +257,7 @@ static int avs_dai_nonhda_be_trigger(struct snd_pcm_substream *substream, int cm } static const struct snd_soc_dai_ops avs_dai_nonhda_be_ops = { - .startup = avs_dai_nonhda_be_startup, + .startup = avs_dai_startup, .shutdown = avs_dai_shutdown, .hw_params = avs_dai_nonhda_be_hw_params, .hw_free = avs_dai_nonhda_be_hw_free, @@ -273,8 +265,6 @@ static const struct snd_soc_dai_ops avs_dai_nonhda_be_ops = { .trigger = avs_dai_nonhda_be_trigger, }; -static const struct snd_soc_dai_ops avs_dai_hda_be_ops; - static int avs_dai_hda_be_startup(struct snd_pcm_substream *substream, struct snd_soc_dai *dai) { struct snd_soc_pcm_runtime *rtd = snd_soc_substream_to_rtd(substream); @@ -282,7 +272,7 @@ static int avs_dai_hda_be_startup(struct snd_pcm_substream *substream, struct sn struct hda_codec *codec; int ret; - ret = avs_dai_startup(substream, dai, false, &avs_dai_hda_be_ops); + ret = avs_dai_startup(substream, dai); if (ret) return ret; @@ -479,8 +469,6 @@ static const struct snd_pcm_hw_constraint_list hw_rates = { .mask = 0, }; -const struct snd_soc_dai_ops avs_dai_fe_ops; - static int hw_rule_param_size(struct snd_pcm_hw_params *params, struct snd_pcm_hw_rule *rule) { struct snd_interval *interval = hw_param_interval(params, rule->var); @@ -509,7 +497,7 @@ static int avs_dai_fe_startup(struct snd_pcm_substream *substream, struct snd_so struct hdac_ext_stream *host_stream; int ret; - ret = avs_dai_startup(substream, dai, true, &avs_dai_fe_ops); + ret = avs_dai_startup(substream, dai); if (ret) return ret; From patchwork Fri Apr 26 09:57:31 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Cezary Rojewski X-Patchwork-Id: 792710 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 alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) (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 676C5C4345F for ; Fri, 26 Apr 2024 10:01:35 +0000 (UTC) Received: from alsa1.perex.cz (alsa1.perex.cz [207.180.221.201]) (using TLSv1.2 with cipher ADH-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by alsa0.perex.cz (Postfix) with ESMTPS id 27BFFE0D; Fri, 26 Apr 2024 12:01:23 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz 27BFFE0D DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1714125693; bh=cJfd0VnFG9YhYzSbRGhfArwkT7UjXbxFfPxrSep4Cqo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-Id: List-Archive:List-Help:List-Owner:List-Post:List-Subscribe: List-Unsubscribe:From; b=CRy93asM2MIIue8NM/c6I2Bmp2ffp4IlVwFyePV+B5zaFOn6ehEBtp5p18Ghft20s 12Zjm6Q/OixujYuoXG/G5czu34YiNHEz82YxtZbPl3lPWoV3JUFAuI64zqi6sGd3Ch ZXrAbJ3hJTW84IMUFnAoNg9hUgDaXWe2XI9uOjyI= Received: by alsa1.perex.cz (Postfix, from userid 50401) id 899F0F80623; Fri, 26 Apr 2024 11:59:54 +0200 (CEST) Received: from mailman-core.alsa-project.org (mailman-core.alsa-project.org [10.254.200.10]) by alsa1.perex.cz (Postfix) with ESMTP id A8709F80649; Fri, 26 Apr 2024 11:59:53 +0200 (CEST) Received: by alsa1.perex.cz (Postfix, from userid 50401) id 495FDF802E8; Fri, 26 Apr 2024 11:57:13 +0200 (CEST) Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.11]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by alsa1.perex.cz (Postfix) with ESMTPS id 2E9EBF804B0 for ; Fri, 26 Apr 2024 11:57:00 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz 2E9EBF804B0 Authentication-Results: alsa1.perex.cz; dkim=pass (2048-bit key, unprotected) header.d=intel.com header.i=@intel.com header.a=rsa-sha256 header.s=Intel header.b=ai4Ix6ke DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1714125422; x=1745661422; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=cJfd0VnFG9YhYzSbRGhfArwkT7UjXbxFfPxrSep4Cqo=; b=ai4Ix6keApFb78PBg9kBfvv7DqYObeubByNCJSCLlpP9XkC/nh6T+JvC qSdgCPJRcX8JlWYRV5xJQAkAB375MjtX5itLGbyawKa4nOYCEc+SdMmjU n/myW0TF9JEQ8KSgGm0IiXl3N6jepdPoSOs4UYZKm9sOeRzL7xGukvtV0 4cjmb/7arWoI/peky1fycJfDHYIrcX4NW18j9L4ESjFb95UvA5dmPxLxh 4r2VWe4cmgz/ZWhJVStdOhXXM3CMXZujR/p+s9dpsMD3f4KBl06gR5K2y TwK4uQQgVCSXOMVZdqf9Su5/K1nF0WJ5E90ebSsVrZvIJxg7yVUDhj+sc w==; X-CSE-ConnectionGUID: +wxr/gJ7R+ultXU8lIpOFQ== X-CSE-MsgGUID: oktz+YdcTqKibfI6LTfdsA== X-IronPort-AV: E=McAfee;i="6600,9927,11055"; a="20409219" X-IronPort-AV: E=Sophos;i="6.07,232,1708416000"; d="scan'208";a="20409219" Received: from fmviesa010.fm.intel.com ([10.60.135.150]) by orvoesa103.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 26 Apr 2024 02:57:01 -0700 X-CSE-ConnectionGUID: M4cu62lWSBC3dDGtRsxc1w== X-CSE-MsgGUID: BYxq9KG7QBKbrSV8+KE7uQ== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.07,232,1708416000"; d="scan'208";a="25460615" Received: from crojewsk-ctrl.igk.intel.com ([10.102.9.28]) by fmviesa010.fm.intel.com with ESMTP; 26 Apr 2024 02:56:59 -0700 From: Cezary Rojewski To: broonie@kernel.org Cc: alsa-devel@alsa-project.org, linux-sound@vger.kernel.org, tiwai@suse.com, perex@perex.cz, amadeuszx.slawinski@linux.intel.com, Cezary Rojewski Subject: [PATCH 6/8] ASoC: Intel: avs: Remove redundancy around DAI prepare Date: Fri, 26 Apr 2024 11:57:31 +0200 Message-Id: <20240426095733.3946951-7-cezary.rojewski@intel.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20240426095733.3946951-1-cezary.rojewski@intel.com> References: <20240426095733.3946951-1-cezary.rojewski@intel.com> MIME-Version: 1.0 Message-ID-Hash: 6QHFTIHY43CTMOQL5XDZG35U6NEISQCU X-Message-ID-Hash: 6QHFTIHY43CTMOQL5XDZG35U6NEISQCU X-MailFrom: cezary.rojewski@intel.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; header-match-alsa-devel.alsa-project.org-0; header-match-alsa-devel.alsa-project.org-1; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header X-Mailman-Version: 3.3.9 Precedence: list List-Id: "Alsa-devel mailing list for ALSA developers - http://www.alsa-project.org" Archived-At: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: Drop unused arguments in the avs_dai_prepare() function. With the function updated, it matches its template in snd_soc_dai_ops and can be referenced throughout the pcm.c file without need of any wrappers. Signed-off-by: Cezary Rojewski --- sound/soc/intel/avs/pcm.c | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) diff --git a/sound/soc/intel/avs/pcm.c b/sound/soc/intel/avs/pcm.c index 0771a9716f4b..d4557b7b1c6c 100644 --- a/sound/soc/intel/avs/pcm.c +++ b/sound/soc/intel/avs/pcm.c @@ -151,8 +151,7 @@ static int avs_dai_be_hw_params(struct snd_pcm_substream *substream, return avs_dai_hw_params(substream, fe_hw_params, be_hw_params, dai, dma_id); } -static int avs_dai_prepare(struct avs_dev *adev, struct snd_pcm_substream *substream, - struct snd_soc_dai *dai) +static int avs_dai_prepare(struct snd_pcm_substream *substream, struct snd_soc_dai *dai) { struct avs_dma_data *data; int ret; @@ -201,11 +200,6 @@ static int avs_dai_nonhda_be_hw_free(struct snd_pcm_substream *substream, struct return 0; } -static int avs_dai_nonhda_be_prepare(struct snd_pcm_substream *substream, struct snd_soc_dai *dai) -{ - return avs_dai_prepare(to_avs_dev(dai->dev), substream, dai); -} - static int avs_dai_nonhda_be_trigger(struct snd_pcm_substream *substream, int cmd, struct snd_soc_dai *dai) { @@ -261,7 +255,7 @@ static const struct snd_soc_dai_ops avs_dai_nonhda_be_ops = { .shutdown = avs_dai_shutdown, .hw_params = avs_dai_nonhda_be_hw_params, .hw_free = avs_dai_nonhda_be_hw_free, - .prepare = avs_dai_nonhda_be_prepare, + .prepare = avs_dai_prepare, .trigger = avs_dai_nonhda_be_trigger, }; @@ -381,7 +375,7 @@ static int avs_dai_hda_be_prepare(struct snd_pcm_substream *substream, struct sn if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) snd_hdac_ext_bus_link_set_stream_id(link, hdac_stream(link_stream)->stream_tag); - ret = avs_dai_prepare(to_avs_dev(dai->dev), substream, dai); + ret = avs_dai_prepare(substream, dai); if (ret) return ret; @@ -672,7 +666,7 @@ static int avs_dai_fe_prepare(struct snd_pcm_substream *substream, struct snd_so if (ret < 0) return ret; - ret = avs_dai_prepare(data->adev, substream, dai); + ret = avs_dai_prepare(substream, dai); if (ret) return ret; From patchwork Fri Apr 26 09:57:32 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Cezary Rojewski X-Patchwork-Id: 792413 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 alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) (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 9C28FC4345F for ; Fri, 26 Apr 2024 10:02:18 +0000 (UTC) Received: from alsa1.perex.cz (alsa1.perex.cz [207.180.221.201]) (using TLSv1.2 with cipher ADH-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by alsa0.perex.cz (Postfix) with ESMTPS id EF7ECDEC; Fri, 26 Apr 2024 12:02:06 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz EF7ECDEC DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1714125737; bh=HlGJubqfkIRgU0Aeu+B9moA7xbvwpSC/vQ/7n6B7G14=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-Id: List-Archive:List-Help:List-Owner:List-Post:List-Subscribe: List-Unsubscribe:From; b=n+8i3USrB6IX5oHXfG1apsZ85XJBgEIbuZ0nlgdnmQKeMZ2yGipCVxdyigrvO92x8 VZltTYzUjjS3ggfTPaF55+exTNtFIEazWMY/3kTywyUVLglXIXzsY/CJKHeFn32hzw BzOl0gRQyQ31NYcqz1xpCtD41q777kYS5J20w2ZY= Received: by alsa1.perex.cz (Postfix, from userid 50401) id E85BBF806BE; Fri, 26 Apr 2024 11:59:59 +0200 (CEST) Received: from mailman-core.alsa-project.org (mailman-core.alsa-project.org [10.254.200.10]) by alsa1.perex.cz (Postfix) with ESMTP id 6A2CFF806BD; Fri, 26 Apr 2024 11:59:59 +0200 (CEST) Received: by alsa1.perex.cz (Postfix, from userid 50401) id E21C2F802E8; Fri, 26 Apr 2024 11:57:17 +0200 (CEST) Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.11]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by alsa1.perex.cz (Postfix) with ESMTPS id 346D0F80568 for ; Fri, 26 Apr 2024 11:57:03 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz 346D0F80568 Authentication-Results: alsa1.perex.cz; dkim=pass (2048-bit key, unprotected) header.d=intel.com header.i=@intel.com header.a=rsa-sha256 header.s=Intel header.b=bTNNZ5jx DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1714125424; x=1745661424; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=HlGJubqfkIRgU0Aeu+B9moA7xbvwpSC/vQ/7n6B7G14=; b=bTNNZ5jxDjcsEEDtB+DzJlSGD2sWR5SeG7v9neSjGoL/eAYu6qkFRJp0 h+pI5a8Jgqs2BqXigkuvToCSrl57n7i5bQ/EEzrfjooFUEM6QKrYjUDfy ZGfFziwFv/CgyYO2B+4yaK8vboS/deUvZ18g2gEV/h6EWgyLaax5ECK7o lMVoMrD82fd2pXvQQ2BtNj8doL4jNxZ3JEvKwXdfitN1PCIq/hGIr4eIL 5qhCspfv9bwa3lCC3yqrR9S5dxnvaswjgTj/QO+d5OaMBnlyB+Bd2bIho 8QoqPetSmc2ueN02LFdt55D5ACc7oi1Fit6TTOK7/mIZwdi0o3E6sQb8h Q==; X-CSE-ConnectionGUID: LrVWS3lfTV6Qk5+wTkTKOA== X-CSE-MsgGUID: ywcFLu9VRaGfAkVVMfepng== X-IronPort-AV: E=McAfee;i="6600,9927,11055"; a="20409228" X-IronPort-AV: E=Sophos;i="6.07,232,1708416000"; d="scan'208";a="20409228" Received: from fmviesa010.fm.intel.com ([10.60.135.150]) by orvoesa103.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 26 Apr 2024 02:57:03 -0700 X-CSE-ConnectionGUID: S4q3g+JSQxKtyJq+NaF/mg== X-CSE-MsgGUID: mkAr/ahCRF+rt2XpJa8naw== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.07,232,1708416000"; d="scan'208";a="25460623" Received: from crojewsk-ctrl.igk.intel.com ([10.102.9.28]) by fmviesa010.fm.intel.com with ESMTP; 26 Apr 2024 02:57:00 -0700 From: Cezary Rojewski To: broonie@kernel.org Cc: alsa-devel@alsa-project.org, linux-sound@vger.kernel.org, tiwai@suse.com, perex@perex.cz, amadeuszx.slawinski@linux.intel.com, Cezary Rojewski Subject: [PATCH 7/8] ASoC: Intel: avs: Store pointer to link_stream in dma_data Date: Fri, 26 Apr 2024 11:57:32 +0200 Message-Id: <20240426095733.3946951-8-cezary.rojewski@intel.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20240426095733.3946951-1-cezary.rojewski@intel.com> References: <20240426095733.3946951-1-cezary.rojewski@intel.com> MIME-Version: 1.0 Message-ID-Hash: H7RJ4MOSRZLIJQD35BPGMQF3VSGLMM4I X-Message-ID-Hash: H7RJ4MOSRZLIJQD35BPGMQF3VSGLMM4I X-MailFrom: cezary.rojewski@intel.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; header-match-alsa-devel.alsa-project.org-0; header-match-alsa-devel.alsa-project.org-1; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header X-Mailman-Version: 3.3.9 Precedence: list List-Id: "Alsa-devel mailing list for ALSA developers - http://www.alsa-project.org" Archived-At: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: While the HDAudio codec driver expectations must be met - store valid pointer to HDAudio LINK stream in substream->runtime->private_data - the code is more readable and easier to maintain if dma_data stores pointers to both HOST and LINK stream. DAI BE operations can refer to the LINK stream with data->link_stream, similarly to how DAI FE operations access the HOST stream with data->host_stream. Signed-off-by: Cezary Rojewski --- sound/soc/intel/avs/pcm.c | 40 +++++++++++++++++++-------------------- 1 file changed, 19 insertions(+), 21 deletions(-) diff --git a/sound/soc/intel/avs/pcm.c b/sound/soc/intel/avs/pcm.c index d4557b7b1c6c..168e16e82116 100644 --- a/sound/soc/intel/avs/pcm.c +++ b/sound/soc/intel/avs/pcm.c @@ -23,13 +23,12 @@ struct avs_dma_data { struct avs_tplg_path_template *template; struct avs_path *path; struct avs_dev *adev; - /* - * link stream is stored within substream's runtime - * private_data to fulfill the needs of codec BE path - * - * host stream assigned - */ - struct hdac_ext_stream *host_stream; + + /* LINK-stream utilized in BE operations while HOST in FE ones. */ + union { + struct hdac_ext_stream *link_stream; + struct hdac_ext_stream *host_stream; + }; struct snd_pcm_substream *substream; }; @@ -263,6 +262,7 @@ static int avs_dai_hda_be_startup(struct snd_pcm_substream *substream, struct sn { struct snd_soc_pcm_runtime *rtd = snd_soc_substream_to_rtd(substream); struct hdac_ext_stream *link_stream; + struct avs_dma_data *data; struct hda_codec *codec; int ret; @@ -278,18 +278,18 @@ static int avs_dai_hda_be_startup(struct snd_pcm_substream *substream, struct sn return -EBUSY; } + data = snd_soc_dai_get_dma_data(dai, substream); + data->link_stream = link_stream; substream->runtime->private_data = link_stream; return 0; } static void avs_dai_hda_be_shutdown(struct snd_pcm_substream *substream, struct snd_soc_dai *dai) { - struct hdac_ext_stream *link_stream; + struct avs_dma_data *data = snd_soc_dai_get_dma_data(dai, substream); - link_stream = substream->runtime->private_data; - snd_hdac_ext_stream_release(link_stream, HDAC_EXT_STREAM_TYPE_LINK); + snd_hdac_ext_stream_release(data->link_stream, HDAC_EXT_STREAM_TYPE_LINK); substream->runtime->private_data = NULL; - avs_dai_shutdown(substream, dai); } @@ -297,16 +297,13 @@ static int avs_dai_hda_be_hw_params(struct snd_pcm_substream *substream, struct snd_pcm_hw_params *hw_params, struct snd_soc_dai *dai) { struct avs_dma_data *data; - struct hdac_ext_stream *link_stream; data = snd_soc_dai_get_dma_data(dai, substream); if (data->path) return 0; - link_stream = substream->runtime->private_data; - return avs_dai_be_hw_params(substream, hw_params, dai, - hdac_stream(link_stream)->stream_tag - 1); + hdac_stream(data->link_stream)->stream_tag - 1); } static int avs_dai_hda_be_hw_free(struct snd_pcm_substream *substream, struct snd_soc_dai *dai) @@ -323,7 +320,7 @@ static int avs_dai_hda_be_hw_free(struct snd_pcm_substream *substream, struct sn if (!data->path) return 0; - link_stream = substream->runtime->private_data; + link_stream = data->link_stream; link_stream->link_prepared = false; avs_path_free(data->path); data->path = NULL; @@ -347,13 +344,16 @@ static int avs_dai_hda_be_prepare(struct snd_pcm_substream *substream, struct sn struct snd_soc_pcm_stream *stream_info; struct hdac_ext_stream *link_stream; struct hdac_ext_link *link; + struct avs_dma_data *data; struct hda_codec *codec; struct hdac_bus *bus; unsigned int format_val; unsigned int bits; int ret; - link_stream = runtime->private_data; + data = snd_soc_dai_get_dma_data(dai, substream); + link_stream = data->link_stream; + if (link_stream->link_prepared) return 0; @@ -387,14 +387,12 @@ static int avs_dai_hda_be_trigger(struct snd_pcm_substream *substream, int cmd, struct snd_soc_dai *dai) { struct snd_soc_pcm_runtime *rtd = snd_soc_substream_to_rtd(substream); - struct hdac_ext_stream *link_stream; struct avs_dma_data *data; int ret = 0; dev_dbg(dai->dev, "entry %s cmd=%d\n", __func__, cmd); data = snd_soc_dai_get_dma_data(dai, substream); - link_stream = substream->runtime->private_data; switch (cmd) { case SNDRV_PCM_TRIGGER_RESUME: @@ -403,7 +401,7 @@ static int avs_dai_hda_be_trigger(struct snd_pcm_substream *substream, int cmd, fallthrough; case SNDRV_PCM_TRIGGER_START: case SNDRV_PCM_TRIGGER_PAUSE_RELEASE: - snd_hdac_ext_stream_start(link_stream); + snd_hdac_ext_stream_start(data->link_stream); ret = avs_path_pause(data->path); if (ret < 0) { @@ -426,7 +424,7 @@ static int avs_dai_hda_be_trigger(struct snd_pcm_substream *substream, int cmd, if (ret < 0) dev_err(dai->dev, "pause BE path failed: %d\n", ret); - snd_hdac_ext_stream_clear(link_stream); + snd_hdac_ext_stream_clear(data->link_stream); ret = avs_path_reset(data->path); if (ret < 0) From patchwork Fri Apr 26 09:57:33 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Cezary Rojewski X-Patchwork-Id: 792709 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 alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) (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 AF548C4345F for ; Fri, 26 Apr 2024 10:01:59 +0000 (UTC) Received: from alsa1.perex.cz (alsa1.perex.cz [207.180.221.201]) (using TLSv1.2 with cipher ADH-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by alsa0.perex.cz (Postfix) with ESMTPS id AABE6E7F; Fri, 26 Apr 2024 12:01:47 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz AABE6E7F DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1714125717; bh=WvPxcJCAnFWnb26FV2ZBZGxjnmSM3tYTZTkWyMv25OM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-Id: List-Archive:List-Help:List-Owner:List-Post:List-Subscribe: List-Unsubscribe:From; b=LCMMRQcZ5VW1GOeSANZJKPwBt72pLbevuDro96SL0PeRxZ6hwBR2NOP88m1hD/ODj /zz8fD2I3AuTiY3YAHup4I5u4hUz0SZilTR1fEPkr6YrnwX3MUTuGdGfOzsJNLoGWX zghg7gDXgrg3bIeJfRzGU+ZGcB2NFIbwRWCmZQdA= Received: by alsa1.perex.cz (Postfix, from userid 50401) id A3EBBF80699; Fri, 26 Apr 2024 11:59:57 +0200 (CEST) Received: from mailman-core.alsa-project.org (mailman-core.alsa-project.org [10.254.200.10]) by alsa1.perex.cz (Postfix) with ESMTP id B1478F80681; Fri, 26 Apr 2024 11:59:56 +0200 (CEST) Received: by alsa1.perex.cz (Postfix, from userid 50401) id 7AFB0F802E8; Fri, 26 Apr 2024 11:57:15 +0200 (CEST) Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.11]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by alsa1.perex.cz (Postfix) with ESMTPS id 003FCF8056F for ; Fri, 26 Apr 2024 11:57:04 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz 003FCF8056F Authentication-Results: alsa1.perex.cz; dkim=pass (2048-bit key, unprotected) header.d=intel.com header.i=@intel.com header.a=rsa-sha256 header.s=Intel header.b=f9YogoKO DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1714125426; x=1745661426; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=WvPxcJCAnFWnb26FV2ZBZGxjnmSM3tYTZTkWyMv25OM=; b=f9YogoKO6VL9iUEB1trvlYDopcV80HztE6CSlO9XMS2nNkPAH68OuctU Xdo9UtLwNkjWdFB406I5wLW1ImB4iPKvClqQiqy1kLCeUU/TkRGw8SXig n0BLewsiaB6IYCR67Djf0AGfaSOLbTF4IlJck+Bbvj8DmSWVpau4TWMV3 3QF+DqR0EcU8ViUJ6kp8cVrGUw0rzU2wAgA2IcotAIHKff4xo4eL25TMQ bCZRY1jsTBaJqNsbxUbguN3IXeTS5DAEmmZrZHPtptN2F9piRTmpDMtaz 9dtBx3UF4N5J5NFrDH+FnjMHwvDUwyXKNv7KyXlUjR72z3scYmPJr2ujY g==; X-CSE-ConnectionGUID: RLOah4LlQw6FNoo15xc/UQ== X-CSE-MsgGUID: azNlrvuRS9+RLSMkMGaVGw== X-IronPort-AV: E=McAfee;i="6600,9927,11055"; a="20409234" X-IronPort-AV: E=Sophos;i="6.07,232,1708416000"; d="scan'208";a="20409234" Received: from fmviesa010.fm.intel.com ([10.60.135.150]) by orvoesa103.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 26 Apr 2024 02:57:05 -0700 X-CSE-ConnectionGUID: AqEiny2qSouGxqljEvUXcQ== X-CSE-MsgGUID: Lo7qdTGzR26njZq/LEbXBA== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.07,232,1708416000"; d="scan'208";a="25460633" Received: from crojewsk-ctrl.igk.intel.com ([10.102.9.28]) by fmviesa010.fm.intel.com with ESMTP; 26 Apr 2024 02:57:02 -0700 From: Cezary Rojewski To: broonie@kernel.org Cc: alsa-devel@alsa-project.org, linux-sound@vger.kernel.org, tiwai@suse.com, perex@perex.cz, amadeuszx.slawinski@linux.intel.com, Cezary Rojewski Subject: [PATCH 8/8] ASoC: Intel: avs: Clean up hw constraints initialization Date: Fri, 26 Apr 2024 11:57:33 +0200 Message-Id: <20240426095733.3946951-9-cezary.rojewski@intel.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20240426095733.3946951-1-cezary.rojewski@intel.com> References: <20240426095733.3946951-1-cezary.rojewski@intel.com> MIME-Version: 1.0 Message-ID-Hash: 53RDXCCPKVCKKSXDLI3P7ZTHNNG4W4QX X-Message-ID-Hash: 53RDXCCPKVCKKSXDLI3P7ZTHNNG4W4QX X-MailFrom: cezary.rojewski@intel.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; header-match-alsa-devel.alsa-project.org-0; header-match-alsa-devel.alsa-project.org-1; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header X-Mailman-Version: 3.3.9 Precedence: list List-Id: "Alsa-devel mailing list for ALSA developers - http://www.alsa-project.org" Archived-At: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: Provide a separate function that initializes all PCM hardware constraints for the driver. No functional changes. Signed-off-by: Cezary Rojewski --- sound/soc/intel/avs/pcm.c | 84 ++++++++++++++++++++------------------- 1 file changed, 44 insertions(+), 40 deletions(-) diff --git a/sound/soc/intel/avs/pcm.c b/sound/soc/intel/avs/pcm.c index 168e16e82116..845b5ed9eb1b 100644 --- a/sound/soc/intel/avs/pcm.c +++ b/sound/soc/intel/avs/pcm.c @@ -448,19 +448,6 @@ static const struct snd_soc_dai_ops avs_dai_hda_be_ops = { .trigger = avs_dai_hda_be_trigger, }; -static const unsigned int rates[] = { - 8000, 11025, 12000, 16000, - 22050, 24000, 32000, 44100, - 48000, 64000, 88200, 96000, - 128000, 176400, 192000, -}; - -static const struct snd_pcm_hw_constraint_list hw_rates = { - .count = ARRAY_SIZE(rates), - .list = rates, - .mask = 0, -}; - static int hw_rule_param_size(struct snd_pcm_hw_params *params, struct snd_pcm_hw_rule *rule) { struct snd_interval *interval = hw_param_interval(params, rule->var); @@ -481,40 +468,33 @@ static int hw_rule_param_size(struct snd_pcm_hw_params *params, struct snd_pcm_h return snd_interval_refine(interval, &to); } -static int avs_dai_fe_startup(struct snd_pcm_substream *substream, struct snd_soc_dai *dai) +static int avs_pcm_hw_constraints_init(struct snd_pcm_substream *substream) { struct snd_pcm_runtime *runtime = substream->runtime; - struct avs_dma_data *data; - struct hdac_bus *bus; - struct hdac_ext_stream *host_stream; + static const unsigned int rates[] = { + 8000, 11025, 12000, 16000, + 22050, 24000, 32000, 44100, + 48000, 64000, 88200, 96000, + 128000, 176400, 192000, + }; + static const struct snd_pcm_hw_constraint_list rate_list = { + .count = ARRAY_SIZE(rates), + .list = rates, + }; int ret; - ret = avs_dai_startup(substream, dai); - if (ret) - return ret; - - data = snd_soc_dai_get_dma_data(dai, substream); - bus = &data->adev->base.core; - - host_stream = snd_hdac_ext_stream_assign(bus, substream, HDAC_EXT_STREAM_TYPE_HOST); - if (!host_stream) { - ret = -EBUSY; - goto err; - } - - data->host_stream = host_stream; ret = snd_pcm_hw_constraint_integer(runtime, SNDRV_PCM_HW_PARAM_PERIODS); if (ret < 0) - goto err; + return ret; - /* avoid wrap-around with wall-clock */ + /* Avoid wrap-around with wall-clock. */ ret = snd_pcm_hw_constraint_minmax(runtime, SNDRV_PCM_HW_PARAM_BUFFER_TIME, 20, 178000000); if (ret < 0) - goto err; + return ret; - ret = snd_pcm_hw_constraint_list(runtime, 0, SNDRV_PCM_HW_PARAM_RATE, &hw_rates); + ret = snd_pcm_hw_constraint_list(runtime, 0, SNDRV_PCM_HW_PARAM_RATE, &rate_list); if (ret < 0) - goto err; + return ret; /* Adjust buffer and period size based on the audio format. */ snd_pcm_hw_rule_add(runtime, 0, SNDRV_PCM_HW_PARAM_BUFFER_SIZE, hw_rule_param_size, NULL, @@ -524,16 +504,40 @@ static int avs_dai_fe_startup(struct snd_pcm_substream *substream, struct snd_so SNDRV_PCM_HW_PARAM_FORMAT, SNDRV_PCM_HW_PARAM_CHANNELS, SNDRV_PCM_HW_PARAM_RATE, -1); + return ret; +} + +static int avs_dai_fe_startup(struct snd_pcm_substream *substream, struct snd_soc_dai *dai) +{ + struct hdac_ext_stream *host_stream; + struct avs_dma_data *data; + struct hdac_bus *bus; + int ret; + + ret = avs_pcm_hw_constraints_init(substream); + if (ret) + return ret; + + ret = avs_dai_startup(substream, dai); + if (ret) + return ret; + + data = snd_soc_dai_get_dma_data(dai, substream); + bus = &data->adev->base.core; + + host_stream = snd_hdac_ext_stream_assign(bus, substream, HDAC_EXT_STREAM_TYPE_HOST); + if (!host_stream) { + avs_dai_shutdown(substream, dai); + return -EBUSY; + } + + data->host_stream = host_stream; snd_pcm_set_sync(substream); dev_dbg(dai->dev, "%s fe STARTUP tag %d str %p", __func__, hdac_stream(host_stream)->stream_tag, substream); return 0; - -err: - kfree(data); - return ret; } static void avs_dai_fe_shutdown(struct snd_pcm_substream *substream, struct snd_soc_dai *dai)