From patchwork Thu Sep 16 11:16:35 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Daniel Baluta (OSS)" X-Patchwork-Id: 12498711 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,MSGID_FROM_MTA_HEADER,SPF_HELO_NONE,SPF_PASS, USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 8AE61C433F5 for ; Thu, 16 Sep 2021 11:18:50 +0000 (UTC) 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 mail.kernel.org (Postfix) with ESMTPS id 1198061130 for ; Thu, 16 Sep 2021 11:18:50 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 1198061130 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=oss.nxp.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=alsa-project.org Received: from alsa1.perex.cz (alsa1.perex.cz [207.180.221.201]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by alsa0.perex.cz (Postfix) with ESMTPS id 9830B18A4; Thu, 16 Sep 2021 13:17:58 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz 9830B18A4 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1631791128; bh=x6276OcAilao5zmcu2v3C8YCyELle0sGhB7npKVTCq0=; h=From:To:Subject:Date:In-Reply-To:References:Cc:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=UoLp+714EHcyiWOir0eQ8nFJtCcDTXtQg3vaRFVknumdxzMXabWZfh+3haRpXpzMw bTbvufuLpaA9C43/UHPeZASOjp5zo8jiDhdJx8pNnH/sYl126PMGgk7ygP6ZR0bWTO oARMO2XRbrfbrEg2Tcr7YnbtbSI1tSPDpf03EBQk= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id 2485FF804E6; Thu, 16 Sep 2021 13:17:22 +0200 (CEST) Received: by alsa1.perex.cz (Postfix, from userid 50401) id 41476F804E4; Thu, 16 Sep 2021 13:17:20 +0200 (CEST) Received: from EUR03-VE1-obe.outbound.protection.outlook.com (mail-eopbgr50050.outbound.protection.outlook.com [40.107.5.50]) (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 05C76F80271 for ; Thu, 16 Sep 2021 13:17:08 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz 05C76F80271 Authentication-Results: alsa1.perex.cz; dkim=pass (1024-bit key) header.d=NXP1.onmicrosoft.com header.i=@NXP1.onmicrosoft.com header.b="hd6PB/zN" ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=hC9KUFnu9wlFgRH7gfYXOv8ypg6z/oLtFGFavaX94Seb5I4tffGmoZjNy9dVSevYoSeJlFoGZbmTraAUFI/d2ToYOs+iqEFQVC493sPyH2EjTBZWttWNtKYBRunRt9j6rzeCTC1/Se+M/4gg4DM6jdtpCoRyo/xwy0RN1E734JhojWTWRUt1YpLrRBD0VMWmyjudhUucgEf0SGvTFvWNdfGRrzEpqAtQaOsqtmHP0RTHvXIpb0rw7jq6HRQMDJvFk3x3afrFU7NYujofatryCfZA6dMKX720qWWRC5b5PpdtkZ77A1EeQFh62R1vM0twgHCvdMRB1A2nkiZRjhfSKQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version; bh=sONQX65mjIEZ+QiPOFwwnnYmBdbhC1Ic1kXlU3cxiWM=; b=CahXxO1978DZOSfZWMbGS2c+SRESFg2xUY3JRMkleM8sMafcp7Zs3wuP7IUJEJjsBhE+J48sQYOh3IaZWAZW4PX/WxVwulHHy54RJ5zBq/YkgXt1hn7TGFE4Tzz52b1j/FJSjrwivKKon7sOHBE5QFz9sAUWMdn7TVzG+TbXCKqA6G2T6/8J7tHNV2hvhow2i4KnBkINg2jj+YSQoQgVeBGeyJDw2CLSneM9fBQEcfhAMo7UyDHgRWSkD7vBuBKVwQ4gmu+LCkE8ZCKCN5rNxf1oJ4P9LYBoMhEF5VyzlIgVQBPxJmM6SiHQKK3Y6sQw0cdnrLW7gtOpsp+vHuX4PA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=oss.nxp.com; dmarc=pass action=none header.from=oss.nxp.com; dkim=pass header.d=oss.nxp.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=NXP1.onmicrosoft.com; s=selector2-NXP1-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=sONQX65mjIEZ+QiPOFwwnnYmBdbhC1Ic1kXlU3cxiWM=; b=hd6PB/zNyXUA2c9lJp8xA1u+P9X/4FXeEvtCSsXtBWUtJJLJSMc8hRpYN2tQsyOagm+11EuAGC6heuxn4n0X+xf3mT14L/MZQCnZ8CTTJ4emuwsNLELGABCUUJAIqlRXDFBFeD3dAzxtmAYLHmHGO3dK0/VyCbldAOcghX9Py00= Authentication-Results: kernel.org; dkim=none (message not signed) header.d=none;kernel.org; dmarc=none action=none header.from=oss.nxp.com; Received: from VI1PR04MB5151.eurprd04.prod.outlook.com (2603:10a6:803:61::28) by VI1PR04MB4926.eurprd04.prod.outlook.com (2603:10a6:803:51::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4500.18; Thu, 16 Sep 2021 11:17:06 +0000 Received: from VI1PR04MB5151.eurprd04.prod.outlook.com ([fe80::499b:ba92:db2e:3f28]) by VI1PR04MB5151.eurprd04.prod.outlook.com ([fe80::499b:ba92:db2e:3f28%7]) with mapi id 15.20.4500.020; Thu, 16 Sep 2021 11:17:05 +0000 From: Daniel Baluta To: broonie@kernel.org Subject: [PATCH 01/12] ASoC: topology: change the complete op in snd_soc_tplg_ops to return int Date: Thu, 16 Sep 2021 14:16:35 +0300 Message-Id: <20210916111646.367133-2-daniel.baluta@oss.nxp.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20210916111646.367133-1-daniel.baluta@oss.nxp.com> References: <20210916111646.367133-1-daniel.baluta@oss.nxp.com> X-ClientProxiedBy: AM0PR04CA0037.eurprd04.prod.outlook.com (2603:10a6:208:1::14) To VI1PR04MB5151.eurprd04.prod.outlook.com (2603:10a6:803:61::28) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from localhost.localdomain (2a02:2f08:5708:8600:b29c:ccfa:a961:8ebd) by AM0PR04CA0037.eurprd04.prod.outlook.com (2603:10a6:208:1::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4523.14 via Frontend Transport; Thu, 16 Sep 2021 11:17:04 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 7c19b68e-7be5-4698-bf66-08d979038401 X-MS-TrafficTypeDiagnostic: VI1PR04MB4926: X-MS-Exchange-SharedMailbox-RoutingAgent-Processed: True X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:8273; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: mAywM+ltEo91jmwa+PjliRW9hviLZCuiwiUZvPgGgSE0GMuOwqBKwxU+w9MlkY+P2v0XLAU7jtC6xsC8vHyIrv3qHr+rOxs1FHOgriw+lIwvJzJ7FjoCEeS6egtDUokaBP/OctUlVaXb9hVeYXOSuRafm0BFnhT4UlBsUcT4aUk6HjcRpbCcsWLlyznKI9rrWMq5xSnEjUYEXtIJHsYxDEF4+Jl8134R4OGZ9AJp3jdSMk+gC9vuW19tIKdDfB8A6RzNi2NjyI1PgT47lS/tSK8aIOdrfOQrl1SHwpKmrjCOdVmbuAEjoFd6oIc2YWBSaTJvn0w8Hj8aRyvJDEua0Uzb/kUZ5UoKMhGreALCH2ZkhX21Px81FHkRbjvKH4ThSHVaG1qWi+mErD4ulOHh61+bzU0tX6ZxobUUIxHOfwvJcHzB8f0ZV5THNDssfhnolVMLyuc9BGY52lXicVWCYAs26KSgsLsXyJx7JE8iVytkRyoAnTEoOWUBioVa4QiDedk1PHepgoDSh1SizY/yLkp5IxuGycrqKGWHjtG8oKqNiBqq/gscZS45AeQ0Fm1R6ET+19XwEnBFKIniD0Qh1Ykj+if19ZlmEpb0ptMVBVJREwelQ8k/oJZIEumwHa0JGZ11zyN9erSqM+uymD8n+w== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:VI1PR04MB5151.eurprd04.prod.outlook.com; PTR:; CAT:NONE; SFS:(4636009)(39860400002)(366004)(136003)(376002)(346002)(396003)(4326008)(8936002)(6486002)(186003)(83380400001)(6916009)(2616005)(5660300002)(66946007)(52116002)(478600001)(8676002)(6512007)(6506007)(86362001)(2906002)(44832011)(66476007)(66556008)(316002)(1076003)(38100700002)(6666004); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: SjRm2Ds/9QEMOjaAVQt7ik2yfXzHMkmLmOhBcV5kqMvllh6O6/8t6wXXPbEzcy2/yOOyMgoI2BcgS+8QxXLHKdSgYJ5sCfanhGQr6hIfZVozsKo1PoQH/Isk4BEwuHm0VKbMGzWG0ihf+UtE7u7tUrga2D6y2JQxcZeZrnqJtUmVYaOekt4pZ1JFbiZcoBg9cwwnLZr3SgkxNAg5RDEPu5KVBfAb6TJ4XR46xpWwfFTUd8Bdd0ET7O10s/wBgRCVQWCcoKlIcvtPaVKIsJ9CTFRCQIeYTmLwJ97XHo3shyzavREAVOvC1FxcJrn7ZXZB+17Ym91B4RlaO7yWYJ6plS2WKTE0UgyfK3h+UMJ8MVl3EPoHqonG6vZGHmnF57GYg7mi30/4732toRck6tNhggR5oFehZOzgCikLM2YLH9s1XDGmvliA6Rmdl5JzS9Lll+rcG95f4Vb8RnHq31m8OZpTLCkbkgb6pclxSRawvL2vAG+jSKuu0hfAAQuv6z+hOWGt65sKCSeWiVB/G8sr2++K+HxOdn2kJ73SkUmfcNXrM0FL59yIazrxwTxLhBz+/3yW2ZESP4vOkJTReOuS9khYa8/yOjDWH4ve7tl6AArwcN1Bz6J4OMypM5Wruac6m5AkkerPxQJZVADSW8XWlhQ5jn/E9/ocQ72oaU7+gWu37rC5X/nAvoiF9CZVSHFY9AyGTgeN7gPb6pKwR1f0eWA2t4OGKeYHJRSqyTXNihMRDP5zlO+NqokRE41ir/hJ2zFqe2PbeS4rVSs0u3fmPOv5yhfyKbHG+sovK/3VjVzPPM32wDfarMCwZeDNEa/0vXzoec/u9qqIwDig6YZUGgHiXThQ0lq1+PpIRklioT4bpSbBnfZ+AaBWXDSFaa67dZlF+JTYJyRDpDLiYTb62O4i6Ehvbtbm76NHTvHDzAo9Ux4iXg8IirkbMN10TNvNqb6q2RCbHJH7ih6NQdmBV5To0qhPb4V0YXNXM01OeLwtkV0zkEXFJKsthuC7kI8QF8vm0ZCizu+UZ94JfANmUy1YM95afUIU/RzZ6T6w5NmYIF7VpVnOqbHF95nOzIugdLciBCq7KdjtxGkJz1IAQXn6n3tgqX7YzkDlIe5J/nB6POv3OAyW+ewCkPluOjd7f3AqGmYJDRgLgfkd3qhq+KsRgrc3khryvwP3xh5xshdpeqgQPOuIchGBPWlSDWNIpWzL20EjKP145qogef7le/HyIPplmLGWx6PpFTkKONe0WWLltjetkki5XUniUmXojtItYvbFqUU9ksxioFHrgpDIF4QPxVpmaCvXKIHLB87JPxUR61SrvoL+CQzf6kXema9bfGFvX7lm7ol21XQSgnPwodFB7ElggezxVKQy457GxoHuR2+DOLqK0wJ2nIyj X-OriginatorOrg: oss.nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 7c19b68e-7be5-4698-bf66-08d979038401 X-MS-Exchange-CrossTenant-AuthSource: VI1PR04MB5151.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 16 Sep 2021 11:17:05.7924 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: baU2tlfjI8B2QgXZRakwdgj7C7VrsxgKBvyr1rsU01LG1PChtuk67FwjdtK6H8aOhwq+fxV9eafHZqaSDm19KQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR04MB4926 Cc: pierre-louis.bossart@linux.intel.com, alsa-devel@alsa-project.org, kai.vehmanen@linux.intel.com, lgirdwood@gmail.com, daniel.baluta@nxp.com, linux-kernel@vger.kernel.org, ranjani.sridharan@linux.intel.com, Guennadi Liakhovetski , peter.ujfalusi@linux.intel.com X-BeenThere: alsa-devel@alsa-project.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: "Alsa-devel mailing list for ALSA developers - http://www.alsa-project.org" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: alsa-devel-bounces@alsa-project.org Sender: "Alsa-devel" From: Ranjani Sridharan In the SOF driver, the operations performed in the complete callback can fail and therefore topology loading should return an error in such cases. So, change the signature of the complete op in struct snd_soc_tplg_ops to return an int to return the error. Also, amend the complete callback functions in the SOF driver and the SKL driver to conform with the new signature. Signed-off-by: Ranjani Sridharan Reviewed-by: Guennadi Liakhovetski Reviewed-by: Pierre-Louis Bossart Reviewed-by: Kai Vehmanen --- include/sound/soc-topology.h | 2 +- sound/soc/intel/skylake/skl-topology.c | 6 ++++-- sound/soc/soc-topology.c | 10 ++++++---- sound/soc/sof/topology.c | 12 ++++++++---- 4 files changed, 19 insertions(+), 11 deletions(-) diff --git a/include/sound/soc-topology.h b/include/sound/soc-topology.h index 4afd667e124c..7f33de8ffd95 100644 --- a/include/sound/soc-topology.h +++ b/include/sound/soc-topology.h @@ -151,7 +151,7 @@ struct snd_soc_tplg_ops { struct snd_soc_tplg_hdr *); /* completion - called at completion of firmware loading */ - void (*complete)(struct snd_soc_component *); + int (*complete)(struct snd_soc_component *comp); /* manifest - optional to inform component of manifest */ int (*manifest)(struct snd_soc_component *, int index, diff --git a/sound/soc/intel/skylake/skl-topology.c b/sound/soc/intel/skylake/skl-topology.c index b036852d6889..89e4231304dd 100644 --- a/sound/soc/intel/skylake/skl-topology.c +++ b/sound/soc/intel/skylake/skl-topology.c @@ -3637,7 +3637,7 @@ static int skl_manifest_load(struct snd_soc_component *cmpnt, int index, return 0; } -static void skl_tplg_complete(struct snd_soc_component *component) +static int skl_tplg_complete(struct snd_soc_component *component) { struct snd_soc_dobj *dobj; struct snd_soc_acpi_mach *mach; @@ -3646,7 +3646,7 @@ static void skl_tplg_complete(struct snd_soc_component *component) val = kmalloc(sizeof(*val), GFP_KERNEL); if (!val) - return; + return -ENOMEM; mach = dev_get_platdata(component->card->dev); list_for_each_entry(dobj, &component->dobj_list, list) { @@ -3671,7 +3671,9 @@ static void skl_tplg_complete(struct snd_soc_component *component) } } } + kfree(val); + return 0; } static struct snd_soc_tplg_ops skl_tplg_ops = { diff --git a/sound/soc/soc-topology.c b/sound/soc/soc-topology.c index 73e1b7b48ce9..88f849b119da 100644 --- a/sound/soc/soc-topology.c +++ b/sound/soc/soc-topology.c @@ -78,7 +78,7 @@ struct soc_tplg { }; static int soc_tplg_process_headers(struct soc_tplg *tplg); -static void soc_tplg_complete(struct soc_tplg *tplg); +static int soc_tplg_complete(struct soc_tplg *tplg); /* check we dont overflow the data for this control chunk */ static int soc_tplg_check_elem_count(struct soc_tplg *tplg, size_t elem_size, @@ -312,10 +312,12 @@ static int soc_tplg_dai_link_load(struct soc_tplg *tplg, } /* tell the component driver that all firmware has been loaded in this request */ -static void soc_tplg_complete(struct soc_tplg *tplg) +static int soc_tplg_complete(struct soc_tplg *tplg) { if (tplg->ops && tplg->ops->complete) - tplg->ops->complete(tplg->comp); + return tplg->ops->complete(tplg->comp); + + return 0; } /* add a dynamic kcontrol */ @@ -2625,7 +2627,7 @@ static int soc_tplg_load(struct soc_tplg *tplg) ret = soc_tplg_process_headers(tplg); if (ret == 0) - soc_tplg_complete(tplg); + return soc_tplg_complete(tplg); return ret; } diff --git a/sound/soc/sof/topology.c b/sound/soc/sof/topology.c index cc9585bfa4e9..96b8791f7cc1 100644 --- a/sound/soc/sof/topology.c +++ b/sound/soc/sof/topology.c @@ -3567,10 +3567,11 @@ int snd_sof_complete_pipeline(struct device *dev, } /* completion - called at completion of firmware loading */ -static void sof_complete(struct snd_soc_component *scomp) +static int sof_complete(struct snd_soc_component *scomp) { struct snd_sof_dev *sdev = snd_soc_component_get_drvdata(scomp); struct snd_sof_widget *swidget; + int ret; /* some widget types require completion notificattion */ list_for_each_entry(swidget, &sdev->widget_list, list) { @@ -3579,8 +3580,11 @@ static void sof_complete(struct snd_soc_component *scomp) switch (swidget->id) { case snd_soc_dapm_scheduler: - swidget->complete = - snd_sof_complete_pipeline(scomp->dev, swidget); + ret = snd_sof_complete_pipeline(scomp->dev, swidget); + if (ret < 0) + return ret; + + swidget->complete = ret; break; default: break; @@ -3590,7 +3594,7 @@ static void sof_complete(struct snd_soc_component *scomp) * cache initial values of SOF kcontrols by reading DSP value over * IPC. It may be overwritten by alsa-mixer after booting up */ - snd_sof_cache_kcontrol_val(scomp); + return snd_sof_cache_kcontrol_val(scomp); } /* manifest - optional to inform component of manifest */ From patchwork Thu Sep 16 11:16:36 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Daniel Baluta (OSS)" X-Patchwork-Id: 12498727 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,MSGID_FROM_MTA_HEADER,SPF_HELO_NONE,SPF_PASS, USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id BC198C433EF for ; Thu, 16 Sep 2021 11:19:48 +0000 (UTC) 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 mail.kernel.org (Postfix) with ESMTPS id 443AE60F6D for ; Thu, 16 Sep 2021 11:19:48 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 443AE60F6D Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=oss.nxp.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=alsa-project.org Received: from alsa1.perex.cz (alsa1.perex.cz [207.180.221.201]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by alsa0.perex.cz (Postfix) with ESMTPS id D4E1118B8; Thu, 16 Sep 2021 13:18:56 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz D4E1118B8 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1631791186; bh=eTYh75Ca/iGrss1wJxEMBwswT0B7XbGQFdS1/U7zUww=; h=From:To:Subject:Date:In-Reply-To:References:Cc:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=EuM1FSNa7rU767XdUFDji0lBhXnPWqfueiIyDWx36nnMUPBenYqdXS5J3GfY+CaA7 LZ00k+31KfQKSKWGcukN+9c1I9yJoWVnbybaXBsF5/gydd+wSEfpUVK4iE6zI1cu22 7ulTAtLhUbnNkP8VdTrhzSjWgXfu5OS/rsNveE3A= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id DCCE4F80117; Thu, 16 Sep 2021 13:17:30 +0200 (CEST) Received: by alsa1.perex.cz (Postfix, from userid 50401) id 76D94F80506; Thu, 16 Sep 2021 13:17:28 +0200 (CEST) Received: from EUR03-VE1-obe.outbound.protection.outlook.com (mail-eopbgr50058.outbound.protection.outlook.com [40.107.5.58]) (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 051C4F8032B for ; Thu, 16 Sep 2021 13:17:14 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz 051C4F8032B Authentication-Results: alsa1.perex.cz; dkim=pass (1024-bit key) header.d=NXP1.onmicrosoft.com header.i=@NXP1.onmicrosoft.com header.b="LFsPTf+s" ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=d5GDMwWuP8JDaOCaoJ0PIGLCCMSujfVspdMzdYbCCCbi/HSummpEOFVZVMsTd2AF5n1ZWg0oN4Xa845kXpR0ekd/O8V3yOmaYn7f1sou/5T+ohHtX39luomQMbPxWq74IjRt6VXQ4BDrn1R3E2iihsNAQM2DjH6+8Fpk9DkxumCpWRkO+cLqtFQS3GoQ5TN6j9OotBTUcDM6GMX0du3MOgMJcGBH8zr+ijw+l5urfrULmPmnrisI86roIYMUtGFdkb+GJl/rkKVrAPMgE3DuMo1SmLx7J9QXmZM2DElLiXqulPOTeMbNvY1+8BojVouzS7SY6jrKCu0LQVJZmG1D/Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version; bh=csW/yYh/r6kn83Zw6ySLSt1MgRqzlApyNL6RclkmXCE=; b=EvdclVVOMY3xxRn8zxDiIMj2ZjvzNdIH2B+BHK9kC9W8K2NxtJi8az0rCOQpVrmpZAEZjW2dA5MXhxWUsmsIir6R909wRTlEtuqqqtgTnmCZhGAzHMcoEWVWJ0jB1RE59O1pjzWOXDZ+De50wxFNo0fd6NNAgL/H2FTqwFTUwW78Zs952mmiYRWRUYHNGmurQD4PwgHRayMyxXEhXVJu4ImbaDe4vmejRcotKwE2ayM1H7NSgKvTT7GsEl5kCwi1+1/pCoNzV21WwfOCZ0C8GQ/RSRJQULVFQm17KhCuLSXmu1mpUWTmlT0N/ya740+MMr/s+h7B8//cKqU5OSbY4w== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=oss.nxp.com; dmarc=pass action=none header.from=oss.nxp.com; dkim=pass header.d=oss.nxp.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=NXP1.onmicrosoft.com; s=selector2-NXP1-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=csW/yYh/r6kn83Zw6ySLSt1MgRqzlApyNL6RclkmXCE=; b=LFsPTf+sqRWhF1GYtY+A0GrcAuSpfMHwx4O1ljzxAktVnG9qoZkHPc5Q52xW0mq2gi6GeCw3iGmXDw5SAbsjEI7ai/LMjvn0eTmIjymZ4YaMNHd1wNv9oyYm1gEU4+0SVVKcxG6dj4O/key/sqUct8n4aKx+NWKMjHji1JL31+c= Authentication-Results: kernel.org; dkim=none (message not signed) header.d=none;kernel.org; dmarc=none action=none header.from=oss.nxp.com; Received: from VI1PR04MB5151.eurprd04.prod.outlook.com (2603:10a6:803:61::28) by VI1PR04MB4926.eurprd04.prod.outlook.com (2603:10a6:803:51::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4500.18; Thu, 16 Sep 2021 11:17:07 +0000 Received: from VI1PR04MB5151.eurprd04.prod.outlook.com ([fe80::499b:ba92:db2e:3f28]) by VI1PR04MB5151.eurprd04.prod.outlook.com ([fe80::499b:ba92:db2e:3f28%7]) with mapi id 15.20.4500.020; Thu, 16 Sep 2021 11:17:07 +0000 From: Daniel Baluta To: broonie@kernel.org Subject: [PATCH 02/12] ASoC: SOF: control: Add access field in struct snd_sof_control Date: Thu, 16 Sep 2021 14:16:36 +0300 Message-Id: <20210916111646.367133-3-daniel.baluta@oss.nxp.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20210916111646.367133-1-daniel.baluta@oss.nxp.com> References: <20210916111646.367133-1-daniel.baluta@oss.nxp.com> X-ClientProxiedBy: AM0PR04CA0037.eurprd04.prod.outlook.com (2603:10a6:208:1::14) To VI1PR04MB5151.eurprd04.prod.outlook.com (2603:10a6:803:61::28) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from localhost.localdomain (2a02:2f08:5708:8600:b29c:ccfa:a961:8ebd) by AM0PR04CA0037.eurprd04.prod.outlook.com (2603:10a6:208:1::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4523.14 via Frontend Transport; Thu, 16 Sep 2021 11:17:06 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 9462247e-ba0a-4cb8-56af-08d9790384c4 X-MS-TrafficTypeDiagnostic: VI1PR04MB4926: X-MS-Exchange-SharedMailbox-RoutingAgent-Processed: True X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:5236; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: USDaUA/ZcLB8Bw0EflkB+SPywQm5LnuOsHsk2bciom03p5P1aUImMGdh7RKTQnwmwcPR5Iqz3txi+MjUD0ZvAyP1KNiC+uQzhHW19KWO/7icIEtPiId6o7bKsRW/0Sao8H4VDv2fdC7Fqs5Xh6B9fQKcYXSd4I0soxwcwmDfxth+5Msk+EEjGdThcPivLZ75TenZLnXNSKAjXXZN7Kveo5OiSQ42Qwm+NOJCoUO3WcgdZvzKLjEu4L4FFVGQrAcMdpQCfsBqRykuj/cb6+mEFdGo7buz+RW5Mcstv3AsYPqz1SHd17zuswwVkrCaGLytpXBElaB5wIk7qvBIp7O6EvgG6X0fKqyMgfDjKdayMfSbIzYKoRI8k2TXovi3CflPFnUATxcw6r4j0jdyjpH/+1SJeFq7VsBtZXUvAvtbRjileqLc/FY3J00j7LManqYIQ21Ii4yYfwXOorDhfaYSNy3d2bvgartP3XhCBzejPyRkC/PSvY6R41SPSJtL5d7tAcNOlVBqbp0vDgHBH3urxRlWihx+cE1Rkaemt1tzPoUhCa/fgrsvZ0v4j5YIKAqXA1HehcPakIkXsjeSouBr1o4fk7y/zlkeG6fnK+NV9IQ/Qt/o0whOXRmHlwijt/ViuMMXdNqAP1TZGTf74UtkGg== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:VI1PR04MB5151.eurprd04.prod.outlook.com; PTR:; CAT:NONE; SFS:(4636009)(39860400002)(366004)(136003)(376002)(346002)(396003)(4326008)(8936002)(6486002)(186003)(83380400001)(6916009)(2616005)(5660300002)(66946007)(52116002)(478600001)(8676002)(6512007)(6506007)(86362001)(2906002)(44832011)(66476007)(66556008)(316002)(1076003)(38100700002)(6666004); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: 1J5CV7Up3IDIjLP36QAZlgaE37P5wyxkb49aZQiIojde/F+9UptPiuO+iUgXlv0hzqHUfpkxRhzmXWleodckrX9stroTd/IHRU9iqpqW36zShE3YWvFNdwvl9RHrpm2b2GTstuenNw74I+2dsunC9Pjnyy25W9rpZKLL9xJkP4XqwoTSoCdbkimRS5afzgJCed4U/jbYaY6cz6HvJeANfUXrYXoHRf2j90/T2/hhHOCygjNEVk9kBC2rWKBY/ZJSgl1Yh2gn/t9tVZ3xK0cFMFF5qY0og40M8Nbo2SCCx07npWwRbaRV5VLkMosO7Z1prtIUUXLlTAjX9CXSyvGFPI+RH6uuwsJAwAHSEq8Wo6CMqY4IDypFHO+YyDPs86x8bD5K+n0t02xLXoUPf/3Mahecob2qQeZQk0s0MiX2z1Rq/DHuwf/c9C9PDCtjeLQJuocIFistkrO5CRRMH5/x7YEp4sHsfYqKBbFmB/TrV3c7PFktPtyV38IoPuMafyjeNBXiEAGUrz4kHShq0HlqB4dCjCOMs4S7aebezEEKrioiySwQqOKty2+fH053CJFeVfYVgYxDIlujazl8nWQC388NRjGH8LJ/gDJDebFIC25PEJ1F6tRf3ld7v5WClXVUrQPwBNlqLQdCBH8cffvg+zeI0CzouGZ2Kug3UKrskon7Lwkg/OBBWcnah+TMQKQqztkua5Zppu+uFeUYNkKvAW+vUFaOqcfV9WImoXDPK4sKXwJ1PZp/3XrnOaSxxKX1y0CNRdhbaI6vq5a9sH49zB6Shes8rf2C5Lr5mdBm6/LaEFH2cM5Jrh64K0oNxl/2yaUpZS4joUYiXxrFMcUubUNgNEq1D/p80QcSmsHuaQxlaUDZWQISA6Xa/KJW3ZqrRpf79sSYX8QXhYuHDtqNzM8JoEen6/QWHeJdzVF+yjyAtjsaRj6NqHIOg7/doZGkCsSnELf1iUp4Lfbv2Syq1vgkfPW7EYpw7dNkd9nzUO2yJWmvO+wO5upACTsSRTTUVVJABsnyDQr7k5lMSp16RVagj+Wh5DxWChK1WaKtnvWxTnNKfCUlSTw7N/FzNvjsFAeBOfBBjd/m3UjAc7eEy76YEW90PcA3ttC6vsFh0eVyMoie4AyofGpItTtpizkFMTJ/Wn6JFtkmcuxWHRwBbT3mffvc2dc4uhNOdPceIGW5PQ2UbDGfZeK1eIimJ8Pp6KZfkdw75b6DrPMQLDHk2fz0ZWxbgwuTiLJnljNC/iRbGtIqnGiiwqB8qLVGZtQF8u0vf1biaglgA2Ptn75hcghbThvNKH4mMyMy59t66uKVa9ZFK6TBnHi6b5DGGXwsJJ9FIGqib9X3X4IBsIjWFdD1LMBbybdLx0c5V5rR8JKmTBLN6o1IO24QWXF6BZrN X-OriginatorOrg: oss.nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 9462247e-ba0a-4cb8-56af-08d9790384c4 X-MS-Exchange-CrossTenant-AuthSource: VI1PR04MB5151.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 16 Sep 2021 11:17:07.1067 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: uysVH6W3g5QWlN9if3xBuTQg1I5Qlto3vDgBgW/YJwEnsrpXf6+TIeA4l+u8OKjZYvb8BW61SnnaMXBcHBZqtg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR04MB4926 Cc: pierre-louis.bossart@linux.intel.com, alsa-devel@alsa-project.org, kai.vehmanen@linux.intel.com, lgirdwood@gmail.com, daniel.baluta@nxp.com, linux-kernel@vger.kernel.org, ranjani.sridharan@linux.intel.com, Guennadi Liakhovetski , peter.ujfalusi@linux.intel.com X-BeenThere: alsa-devel@alsa-project.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: "Alsa-devel mailing list for ALSA developers - http://www.alsa-project.org" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: alsa-devel-bounces@alsa-project.org Sender: "Alsa-devel" From: Ranjani Sridharan Add a new field to save the access setting for all controls in struct snd_sof_control. This will be used to ensure that only widgets belonging to static pipelines have volatile controls. Signed-off-by: Ranjani Sridharan Reviewed-by: Guennadi Liakhovetski Reviewed-by: Pierre-Louis Bossart Reviewed-by: Kai Vehmanen --- sound/soc/sof/sof-audio.h | 1 + sound/soc/sof/topology.c | 1 + 2 files changed, 2 insertions(+) diff --git a/sound/soc/sof/sof-audio.h b/sound/soc/sof/sof-audio.h index 9a8d005e75a0..78a4a0c90a29 100644 --- a/sound/soc/sof/sof-audio.h +++ b/sound/soc/sof/sof-audio.h @@ -66,6 +66,7 @@ struct snd_sof_control { int min_volume_step; /* min volume step for volume_table */ int max_volume_step; /* max volume step for volume_table */ int num_channels; + unsigned int access; u32 readback_offset; /* offset to mmapped data if used */ struct sof_ipc_ctrl_data *control_data; u32 size; /* cdata size */ diff --git a/sound/soc/sof/topology.c b/sound/soc/sof/topology.c index 96b8791f7cc1..d8f7b1edefc3 100644 --- a/sound/soc/sof/topology.c +++ b/sound/soc/sof/topology.c @@ -1250,6 +1250,7 @@ static int sof_control_load(struct snd_soc_component *scomp, int index, return -ENOMEM; scontrol->scomp = scomp; + scontrol->access = kc->access; switch (le32_to_cpu(hdr->ops.info)) { case SND_SOC_TPLG_CTL_VOLSW: From patchwork Thu Sep 16 11:16:37 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Daniel Baluta (OSS)" X-Patchwork-Id: 12498723 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,MSGID_FROM_MTA_HEADER,SPF_HELO_NONE,SPF_PASS, USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 106FEC433EF for ; Thu, 16 Sep 2021 11:19:06 +0000 (UTC) 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 mail.kernel.org (Postfix) with ESMTPS id 88C966103B for ; Thu, 16 Sep 2021 11:19:05 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 88C966103B Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=oss.nxp.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=alsa-project.org Received: from alsa1.perex.cz (alsa1.perex.cz [207.180.221.201]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by alsa0.perex.cz (Postfix) with ESMTPS id 272DB18AC; Thu, 16 Sep 2021 13:18:14 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz 272DB18AC DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1631791144; bh=p0bmxiDjoLX+FFsnMPt6ZhPkbosmWKqugGFN2Yfmtfw=; h=From:To:Subject:Date:In-Reply-To:References:Cc:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=fi2fIpqqYyhRgwMqeWS6NqlXkKmWTaDOcBTuRk8rd0JYCAXnBj0SnBygtp+yTCcj7 fHpEnB+IoB1XU62eNW0jYQsmnMO18ijwkDbKsB/mYKrA/1+BrJ6g3ir61NLfnejX8l AKP+twQFxnUmPxGlYgGnTas/UAfoCmjwHGbmobqQ= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id 7B4CDF804FD; Thu, 16 Sep 2021 13:17:25 +0200 (CEST) Received: by alsa1.perex.cz (Postfix, from userid 50401) id 36D82F804E5; Thu, 16 Sep 2021 13:17:21 +0200 (CEST) Received: from EUR03-VE1-obe.outbound.protection.outlook.com (mail-eopbgr50050.outbound.protection.outlook.com [40.107.5.50]) (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 42B89F8025E for ; Thu, 16 Sep 2021 13:17:15 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz 42B89F8025E Authentication-Results: alsa1.perex.cz; dkim=pass (1024-bit key) header.d=NXP1.onmicrosoft.com header.i=@NXP1.onmicrosoft.com header.b="A0Evo2wt" ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=WfmJ87fOyMAazo/rvrGl5oEkC4T5AirECQirGXq+AqJvuHuC7ak2p0qoqGMpBhFvSAb4blfAtspvCoMRUzcmlu3bnSyvFsXvK88wgvp6qDQkEpvd0TDQV3wV+xe9tW0bpyY6XVS7Q29PbKyEeN/ntkSVazneQT6gU7iEY35RUvc498UhcZQpG4UiILqTKkKOOPDnIC7cez0kdbGNFoiB6aN1SWcseQKbKQM7H7JucsScle3/k19APsXIGQKuyW3EVs7Be0T3Ji9NCzGBuTtrr0A/HvEH6r7TqXYwY2D7f0wFH/bBAR+DrUjY8+NDUhp0nBFqP0c5G6hLypxOOTd9Ig== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version; bh=gyQXmCoYlPRtflYEvYyHscr0QIizGnIzCCCDHf3TuTo=; b=n5tgDoC0K+gkGln3O4nQBTtvroORqnvw2CWf6G+PyBDK+mF+kUZ+UjPvgHBKeWL0mzlqB61oiXSxMLrrZnyEnWlbAW7Zq59z1bFeDPvYrQLwE2TE1BhZ4xLtpHUVkYUiKz+0YNsXSVnxrGkglz0ORTcpWjNS3OxOa7GBybcdH4r6F9YGDKgtrJD6sDPXpZyVLw7O5LmjAgsq2O1q3gUhr/yXBomQM97g0zdoKed53QmbyNIs+rCI2100w3efAPNLDG9TQqlctosj70VKQ0JnaGRt/eMHOi1RBHlN3Ze4wSLJiM2d1fV1wUHq6W0Ew9PNk3bMifivhdrbNskCQnTWUg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=oss.nxp.com; dmarc=pass action=none header.from=oss.nxp.com; dkim=pass header.d=oss.nxp.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=NXP1.onmicrosoft.com; s=selector2-NXP1-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=gyQXmCoYlPRtflYEvYyHscr0QIizGnIzCCCDHf3TuTo=; b=A0Evo2wttVaGbukPTVm/mUtYN4zchQknHuFg7mPnbyeVQ//2HfpaqgmJaxjdU6x++PbcuHSBP2gc2UGHHq/ltDoK6WkjiIGQ1ziIXcMggZlrofskB46BRRJUMcydRhhktP969ZasinfEFn8UFYZ4T+TcdqfEc+pS19VxP/oKaAU= Authentication-Results: kernel.org; dkim=none (message not signed) header.d=none;kernel.org; dmarc=none action=none header.from=oss.nxp.com; Received: from VI1PR04MB5151.eurprd04.prod.outlook.com (2603:10a6:803:61::28) by VI1PR04MB4926.eurprd04.prod.outlook.com (2603:10a6:803:51::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4500.18; Thu, 16 Sep 2021 11:17:08 +0000 Received: from VI1PR04MB5151.eurprd04.prod.outlook.com ([fe80::499b:ba92:db2e:3f28]) by VI1PR04MB5151.eurprd04.prod.outlook.com ([fe80::499b:ba92:db2e:3f28%7]) with mapi id 15.20.4500.020; Thu, 16 Sep 2021 11:17:08 +0000 From: Daniel Baluta To: broonie@kernel.org Subject: [PATCH 03/12] ASoC: SOF: topology: Add new token for dynamic pipeline Date: Thu, 16 Sep 2021 14:16:37 +0300 Message-Id: <20210916111646.367133-4-daniel.baluta@oss.nxp.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20210916111646.367133-1-daniel.baluta@oss.nxp.com> References: <20210916111646.367133-1-daniel.baluta@oss.nxp.com> X-ClientProxiedBy: AM0PR04CA0037.eurprd04.prod.outlook.com (2603:10a6:208:1::14) To VI1PR04MB5151.eurprd04.prod.outlook.com (2603:10a6:803:61::28) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from localhost.localdomain (2a02:2f08:5708:8600:b29c:ccfa:a961:8ebd) by AM0PR04CA0037.eurprd04.prod.outlook.com (2603:10a6:208:1::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4523.14 via Frontend Transport; Thu, 16 Sep 2021 11:17:07 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: b07b3132-e285-4d6d-5091-08d979038598 X-MS-TrafficTypeDiagnostic: VI1PR04MB4926: X-MS-Exchange-SharedMailbox-RoutingAgent-Processed: True X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:826; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: QifbsPsf3t6YlUC13VobwEaLOjq8dKzphsG2uO/vm/qGWk+Ri90YHcfRgTK/Qh6KKhlItrgiXTd+k5LUMJjG6fzSIAelUmPu9QAb5lOiwBnK/hnqTfNvHnTLyRtG1PodSVLcLCVKnC5LxF+vaI8rfqAdLtpJJv7D8yUqNCL0eL8Wid5L/co4RGgagLnPQ41YMLsM+r/iTTAT5b6dGBzdSLzluqKpq9Pj3OpUXZeNtTOs9ZdgdLcoGyFawOEV+jY7dVHINMnSZrdfq4fsE7kNujvGXfdwWifN6f4lYeI9iEQTMdlrBmNYWw7BBOIVwykJykZUvz66c0MpltH9weGS+KIoCvN/W7b9uUiXY1D0TUPmePv7rdmZONlvsE7fTu8u2wubrVCuC/sp7d8lcNHqBR4bJ6XRIhgNtCLkfN/NCUhbjSS0G51XfaEF6ZsytLd0mGST9n80VqFgGaP4kCoUy6gYOMFqPKkLg4M0vdM7AaPsT8vddEDHYqpj1fc+rzo66CBrbFOUhjJ+9zlJgu6rmEIIVhmHGBMKCp9QmenPbOReAnX9ByVTxBU30vHnPcgbnKzJ1cgzgaQSSl0QjwLn5ZHJPumY+kYWspJeDqLqmYjZS8kZNbDTE0evnQ/oWZOrmq3DDrUmXv1kqT0QqcTBpA== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:VI1PR04MB5151.eurprd04.prod.outlook.com; PTR:; CAT:NONE; SFS:(4636009)(39860400002)(366004)(136003)(376002)(346002)(396003)(4326008)(8936002)(6486002)(186003)(83380400001)(6916009)(2616005)(5660300002)(66946007)(52116002)(478600001)(8676002)(6512007)(6506007)(86362001)(2906002)(44832011)(66476007)(66556008)(316002)(1076003)(38100700002)(6666004); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: FFMiHrruEi3nbuY/oK3hvGVK8kj/nJmTnqdL8CHwPchRSmJIIkdc/X43EsPzqk03KFRbXD/d7xBHUxCm9zXq8RGeCK4WxNJjsSt7uuBVApRzg/BaLxU+CiekOoHH/fgsrNAb41o8tlkDGi2mV5mZ+KlCFkPh0fvhA6lfQXLqPv4R9Vrf77PF86/COwmE7d9ugkKNS+GAPbsbjKWnGsvJe2OObnCgDj+LW/O3M3Mj9FSIEVAcq/CBegpPWKWDCfGCnia34MxMaKqRlW2gB46Fv4+OpErZsjMeQX6d/EooTpv7HeHgOZqQ6y0H93mvq55tnFy8ci22LRF5UQTMlXs4uzRMYGPvwVfZMZMdVF5aY7rxWIvQ/pFqRsv17g7bU7mrYX2zAclsFlkVm73arc+g0kTA/Nx+NMTTf3Hus3nIcHigA/UfhGYf0vmlSQXvL+7557jWL+ZDjB+nssCypu4/hEgfbP1Cis6gb93PUqao1yL8tDeJO8RC9gpU0IuW1f6BilsISRMprBqiMEJPJy5JmFGgokHUxHUelkcmh6NEL+P4gy1ko5vLAY3MM6Ehc23xasuckNiwXoGbbPyUKPqkNcwRrzxuJCyYz1ECfr0K7/sv5aA7D6mPrK5biC9eQeSzLtKyTRM6WW7+Oz+UzfVvMAITkQqBWQArkjFvOkSWF2rpEUSJXX96QK0ZRJEgYOLXf/EgxiCHyDuVRNyzZBFHWsHondefRzTSEfvnRNE+QgiFaIKm5+Vq1D4qrgZC13YXa+DRDgcEATK+XL6ISWxJK9IJ12twWOoAwr7/LndxuBIIIGtIzyyaOjk0to4rqe2EHxKxby4Ay/EvLpe5YMy29pKZ6s6AHiTbHvBaj2ZUoeHM0286U75vvj2zlQ5umtyi+0i9Km2bAbEgyy0VBe7DpYrD/9XIz7UK8wjuz5yQgFZEpxfGtDVApvNUOHcHl4EnCcG36cVz/SBUVaykTVP4Ofb+FCwgrLf7HdC+Wp3/ESdznQFQgUQxQu4kcuRJrVDEiE6DNxke2IJeznNV/WFFF4f1qgBqit7P3D3NlnLzWnw/CMhHVgVVqtKoi9crxqnt59UWeOlfH5ga0mJ0sIgCpjf5pMn3wBuLcKxq7Jc276Haw5UBFKLsWxNqDlIyYT12KJn2bQ9cWbQM/2ZpcpFizrAiTWl2ZEVRljpkhYIiCGV07mxPzro5l483g+swrFusnC9e0kZwANQ9ZpkuMD2yyUPqYH0auwM7F9J/bzm8whMac+t7FhuXscyFPkpLAakqZh8dM49T3yqxXQ9Uf3EXeMwrDAtRpZDAO2didwz4gn68SwYlbSLwcIjHDYjaqspuiMaUl91/onulgMsQJdHFR5kIQ36EWPwKN6AWyLmvzeI97Uh0Uqzgd0xQmKWuDR5J X-OriginatorOrg: oss.nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: b07b3132-e285-4d6d-5091-08d979038598 X-MS-Exchange-CrossTenant-AuthSource: VI1PR04MB5151.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 16 Sep 2021 11:17:08.4579 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: nwsQtZaEPOkYCWgLcHhp64vtmYwRgxDsD6TdspUNmY5IoEfPzmbrfKpiEzkEHirEptkBKjJU0WGdO70/iVnhag== X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR04MB4926 Cc: pierre-louis.bossart@linux.intel.com, alsa-devel@alsa-project.org, kai.vehmanen@linux.intel.com, lgirdwood@gmail.com, daniel.baluta@nxp.com, linux-kernel@vger.kernel.org, ranjani.sridharan@linux.intel.com, Guennadi Liakhovetski , peter.ujfalusi@linux.intel.com X-BeenThere: alsa-devel@alsa-project.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: "Alsa-devel mailing list for ALSA developers - http://www.alsa-project.org" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: alsa-devel-bounces@alsa-project.org Sender: "Alsa-devel" From: Ranjani Sridharan Today, we set up all widgets required for all PCM streams at the time of topology parsing even if they are not used. An optimization would be to only set up the widgets required for currently active PCM streams. This would give the FW the opportunity to power gate unused memory blocks, thereby saving power. For dynamic pipelines, the widgets in the connected DAPM path for each PCM will need to be set up at runtime. This patch introduces a new token, DYNAMIC_PIPELINE, for scheduler type widgets that indicate whether a pipeline should be set up statically during topology load or at runtime when the PCM is opened. Introduce a new field called dynamic_pipeline_widget in struct snd_sof_widget to save the value of the parsed token. The token is set only for the pipeline (scheduler type) widget and must be propagated to all widgets in the same pipeline during topology load. Introduce another field called pipe_widget in struct snd_sof_widget that saves the pointer to the scheduler widget with the same pipeline ID as that of the widget. This field is populated when the pipeline completion callback is invoked during topology loading. Signed-off-by: Ranjani Sridharan Reviewed-by: Guennadi Liakhovetski Reviewed-by: Pierre-Louis Bossart Reviewed-by: Kai Vehmanen --- include/uapi/sound/sof/tokens.h | 1 + sound/soc/sof/sof-audio.h | 13 +++++++ sound/soc/sof/topology.c | 62 ++++++++++++++++++++++++++++++++- 3 files changed, 75 insertions(+), 1 deletion(-) diff --git a/include/uapi/sound/sof/tokens.h b/include/uapi/sound/sof/tokens.h index a642bf30c027..02b71a8deea4 100644 --- a/include/uapi/sound/sof/tokens.h +++ b/include/uapi/sound/sof/tokens.h @@ -51,6 +51,7 @@ #define SOF_TKN_SCHED_CORE 203 #define SOF_TKN_SCHED_FRAMES 204 #define SOF_TKN_SCHED_TIME_DOMAIN 205 +#define SOF_TKN_SCHED_DYNAMIC_PIPELINE 206 /* volume */ #define SOF_TKN_VOLUME_RAMP_STEP_TYPE 250 diff --git a/sound/soc/sof/sof-audio.h b/sound/soc/sof/sof-audio.h index 78a4a0c90a29..4a1c38c5618d 100644 --- a/sound/soc/sof/sof-audio.h +++ b/sound/soc/sof/sof-audio.h @@ -81,6 +81,8 @@ struct snd_sof_control { bool comp_data_dirty; }; +struct snd_sof_widget; + /* ASoC SOF DAPM widget */ struct snd_sof_widget { struct snd_soc_component *scomp; @@ -90,8 +92,19 @@ struct snd_sof_widget { int core; int id; + /* + * Flag indicating if the widget should be set up dynamically when a PCM is opened. + * This flag is only set for the scheduler type widget in topology. During topology + * loading, this flag is propagated to all the widgets belonging to the same pipeline. + * When this flag is not set, a widget is set up at the time of topology loading + * and retained until the DSP enters D3. It will need to be set up again when resuming + * from D3. + */ + bool dynamic_pipeline_widget; + struct snd_soc_dapm_widget *widget; struct list_head list; /* list in sdev widget list */ + struct snd_sof_widget *pipe_widget; /* extended data for UUID components */ struct sof_ipc_comp_ext comp_ext; diff --git a/sound/soc/sof/topology.c b/sound/soc/sof/topology.c index d8f7b1edefc3..60d1db6a9193 100644 --- a/sound/soc/sof/topology.c +++ b/sound/soc/sof/topology.c @@ -572,6 +572,12 @@ static const struct sof_topology_token sched_tokens[] = { offsetof(struct sof_ipc_pipe_new, time_domain), 0}, }; +static const struct sof_topology_token pipeline_tokens[] = { + {SOF_TKN_SCHED_DYNAMIC_PIPELINE, SND_SOC_TPLG_TUPLE_TYPE_BOOL, get_token_u16, + offsetof(struct snd_sof_widget, dynamic_pipeline_widget), 0}, + +}; + /* volume */ static const struct sof_topology_token volume_tokens[] = { {SOF_TKN_VOLUME_RAMP_STEP_TYPE, SND_SOC_TPLG_TUPLE_TYPE_WORD, @@ -1765,6 +1771,15 @@ static int sof_widget_load_pipeline(struct snd_soc_component *scomp, int index, goto err; } + ret = sof_parse_tokens(scomp, swidget, pipeline_tokens, + ARRAY_SIZE(pipeline_tokens), private->array, + le32_to_cpu(private->size)); + if (ret != 0) { + dev_err(scomp->dev, "error: parse dynamic pipeline token failed %d\n", + private->size); + goto err; + } + dev_dbg(scomp->dev, "pipeline %s: period %d pri %d mips %d core %d frames %d\n", swidget->widget->name, pipeline->period, pipeline->priority, pipeline->period_mips, pipeline->core, pipeline->frames_per_sched); @@ -3567,11 +3582,45 @@ int snd_sof_complete_pipeline(struct device *dev, return 1; } +/** + * sof_set_pipe_widget - Set pipe_widget for a component + * @sdev: pointer to struct snd_sof_dev + * @pipe_widget: pointer to struct snd_sof_widget of type snd_soc_dapm_scheduler + * @swidget: pointer to struct snd_sof_widget that has the same pipeline ID as @pipe_widget + * + * Return: 0 if successful, -EINVAL on error. + * The function checks if @swidget is associated with any volatile controls. If so, setting + * the dynamic_pipeline_widget is disallowed. + */ +static int sof_set_pipe_widget(struct snd_sof_dev *sdev, struct snd_sof_widget *pipe_widget, + struct snd_sof_widget *swidget) +{ + struct snd_sof_control *scontrol; + + if (pipe_widget->dynamic_pipeline_widget) { + /* dynamic widgets cannot have volatile kcontrols */ + list_for_each_entry(scontrol, &sdev->kcontrol_list, list) + if (scontrol->comp_id == swidget->comp_id && + (scontrol->access & SNDRV_CTL_ELEM_ACCESS_VOLATILE)) { + dev_err(sdev->dev, + "error: volatile control found for dynamic widget %s\n", + swidget->widget->name); + return -EINVAL; + } + } + + /* set the pipe_widget and apply the dynamic_pipeline_widget_flag */ + swidget->pipe_widget = pipe_widget; + swidget->dynamic_pipeline_widget = pipe_widget->dynamic_pipeline_widget; + + return 0; +} + /* completion - called at completion of firmware loading */ static int sof_complete(struct snd_soc_component *scomp) { struct snd_sof_dev *sdev = snd_soc_component_get_drvdata(scomp); - struct snd_sof_widget *swidget; + struct snd_sof_widget *swidget, *comp_swidget; int ret; /* some widget types require completion notificattion */ @@ -3586,6 +3635,17 @@ static int sof_complete(struct snd_soc_component *scomp) return ret; swidget->complete = ret; + + /* + * Apply the dynamic_pipeline_widget flag and set the pipe_widget field + * for all widgets that have the same pipeline ID as the scheduler widget + */ + list_for_each_entry_reverse(comp_swidget, &sdev->widget_list, list) + if (comp_swidget->pipeline_id == swidget->pipeline_id) { + ret = sof_set_pipe_widget(sdev, swidget, comp_swidget); + if (ret < 0) + return ret; + } break; default: break; From patchwork Thu Sep 16 11:16:38 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Daniel Baluta (OSS)" X-Patchwork-Id: 12498731 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,MSGID_FROM_MTA_HEADER,SPF_HELO_NONE,SPF_PASS, USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id DD708C433F5 for ; Thu, 16 Sep 2021 11:20:24 +0000 (UTC) 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 mail.kernel.org (Postfix) with ESMTPS id 5C9936103B for ; Thu, 16 Sep 2021 11:20:24 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 5C9936103B Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=oss.nxp.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=alsa-project.org Received: from alsa1.perex.cz (alsa1.perex.cz [207.180.221.201]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by alsa0.perex.cz (Postfix) with ESMTPS id E84F418BF; Thu, 16 Sep 2021 13:19:32 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz E84F418BF DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1631791223; bh=pVr738od7nhaZorwg+55M6UXmDSAcicyoX5qwBjl8GM=; h=From:To:Subject:Date:In-Reply-To:References:Cc:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=aY9DowEZXpn0Ohv/h3sIcC21xDH7MMMX12gwRVxjfWggUPuVwXXqv0VonutJDWt8Z LTDcpAW5ysJ+m4iNwqEjyZKWN582LaNTwhXHDAyheG13oIyn+yRCvP6UdbqUziGDot IgAyMazWZ6NnF0vOCJeGozh/npDgOmHc1PArcMPg= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id B01C5F80516; Thu, 16 Sep 2021 13:17:34 +0200 (CEST) Received: by alsa1.perex.cz (Postfix, from userid 50401) id CA620F8050F; Thu, 16 Sep 2021 13:17:30 +0200 (CEST) Received: from EUR03-VE1-obe.outbound.protection.outlook.com (mail-eopbgr50050.outbound.protection.outlook.com [40.107.5.50]) (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 706F7F80117 for ; Thu, 16 Sep 2021 13:17:16 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz 706F7F80117 Authentication-Results: alsa1.perex.cz; dkim=pass (1024-bit key) header.d=NXP1.onmicrosoft.com header.i=@NXP1.onmicrosoft.com header.b="E+Zq/Lkj" ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Jp980PaTSyeATvjBHgTkcSEAMGkxk1VdNq2K+lvfzJBrf5HtZPcA0R44PpAzLusD3GR2rhSXGmcrb7XL0lH/VpSvBjbJ23s6+Yl+YnWhBK+MKJeY1WgV7hRSz0RQkq8V6eUNzWB0+QJy7YCiBcVAqkClf6FvFWRSrxy6CqwFvhPm5bHT7Z+ApU8LjuOT1+bTQGmqFFFvOJZ1eLbwGa5T2wsx+UwCFQKHYv2Rym0LcvQzLGp/etHHXvtrRotnWO6MUbl/iGKPsIWc7fKSo5uWrAUURKEMl56Rzh3X1K5fL0C2yA54ExX4cvVYDVZaAR6msPVnxl+t80YCKURJMuVKZg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version; bh=5s88We5d6A32KwV7UZlK/DFf/rJ4FNd5g6SxpJZHw3o=; b=VhG949Aszp6M5XVEL7Utvlo/v4I0h0nifgZlgWlAeAnUXUcSz+EhnuB7XMzBzbWPAjX65iiENyyTMJ43iZUrbQggIUNKI7shfnTIUfUI+A8H8xq5pwdIijEonUQFk3InFK/EBQsC6Y6iYIADBzR5NNREwIVPVBlpgy0oG94Y4IhYbkNUhI1fcnA8UgpKRRGFFwtt88MH9AtThoWqY2tPWZhimvBTXbRP7I0N1PRQrPhHY6oafXWnBBkqJUxqSJLGKkCkpYMoCz9wQGIQb+vBcLs0eniLcco4/4Pgelz0BsHlG4CC1lJamXLJEu7UuDY3/BJdV18cS6lg7wS18IZrcQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=oss.nxp.com; dmarc=pass action=none header.from=oss.nxp.com; dkim=pass header.d=oss.nxp.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=NXP1.onmicrosoft.com; s=selector2-NXP1-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=5s88We5d6A32KwV7UZlK/DFf/rJ4FNd5g6SxpJZHw3o=; b=E+Zq/Lkjj/Vtl9oG3Xb+k2W2Eh/gVr36XMgPX6sf4J4vPG+jbmv5/2IKrqLivK2bBJS8l5W7TH3OqDEtsk4t+LIGVYGKpI7Z/EyGexcvZE3gTU01N7C/f22rUgMrst0Wk3s/6kag+dgUHHjFN2B3bHm0n+u+AIbRsNv4XwHRYgc= Authentication-Results: kernel.org; dkim=none (message not signed) header.d=none;kernel.org; dmarc=none action=none header.from=oss.nxp.com; Received: from VI1PR04MB5151.eurprd04.prod.outlook.com (2603:10a6:803:61::28) by VI1PR04MB4926.eurprd04.prod.outlook.com (2603:10a6:803:51::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4500.18; Thu, 16 Sep 2021 11:17:10 +0000 Received: from VI1PR04MB5151.eurprd04.prod.outlook.com ([fe80::499b:ba92:db2e:3f28]) by VI1PR04MB5151.eurprd04.prod.outlook.com ([fe80::499b:ba92:db2e:3f28%7]) with mapi id 15.20.4500.020; Thu, 16 Sep 2021 11:17:09 +0000 From: Daniel Baluta To: broonie@kernel.org Subject: [PATCH 04/12] ASoC: SOF: sof-audio: add helpers for widgets, kcontrols and dai config set up Date: Thu, 16 Sep 2021 14:16:38 +0300 Message-Id: <20210916111646.367133-5-daniel.baluta@oss.nxp.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20210916111646.367133-1-daniel.baluta@oss.nxp.com> References: <20210916111646.367133-1-daniel.baluta@oss.nxp.com> X-ClientProxiedBy: AM0PR04CA0037.eurprd04.prod.outlook.com (2603:10a6:208:1::14) To VI1PR04MB5151.eurprd04.prod.outlook.com (2603:10a6:803:61::28) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from localhost.localdomain (2a02:2f08:5708:8600:b29c:ccfa:a961:8ebd) by AM0PR04CA0037.eurprd04.prod.outlook.com (2603:10a6:208:1::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4523.14 via Frontend Transport; Thu, 16 Sep 2021 11:17:08 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 8d0493af-55ae-4d0e-3181-08d97903865d X-MS-TrafficTypeDiagnostic: VI1PR04MB4926: X-MS-Exchange-SharedMailbox-RoutingAgent-Processed: True X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:3383; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: bY1xBlnjknyhIFWud/lvgD+HJtt2Q4UjUngZ6wnbHeHnR7aZD8zRaVaiKXoB+YLf+U602TAVAJi5p8Os7wThDuM5mhx1XjsXV4yw81LduA76DWPzi8QyN9RqcIgF+mboANAXFUo5qwni9tVPMog24ceeA87XG2PADAwDJMQuo4324wefVR72QoklEXt86J13VGOBX0nh3Ta3cnMvmAaK4qgz9JNJGWZjbhdtcl4FPfRY5OxA1PU48uay20MdcsDB7isRNp10+o6y2aRMlkGmnkF/nef4nSU588LCMvD6W5iaNUCUUnCiVTavzlsfUTF2aplZA7GmXic8hWMUPvzEXhL3HTMf94eQ6egEY9zThoITp4PFORMKOC+DwGMbPLfDtxt4v4chfNhMyOUWFFbmYsY8lN67LIZipt0MpQOJz1dud2sk+8ZIkvcLSyZGzjpNc6t3TErzU6zh7SpijvFcFsbC7rJmS13hazIicaI63GuOHqyx6KLitMYycqU0f0niCQvsfB+OlpWmWaTz0VtOhWAZ2LP6y4cuU/2Kvj3Z0H8lymz83jh/McXF4M6uK7k8/aynVI64DGZV3Vglm6hvW7+D5CeNsi2NqqcjcrKHOj9pDR4dGhdDTszxTv0teP0NHM23YPmO1wqYJpVyde+znw== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:VI1PR04MB5151.eurprd04.prod.outlook.com; PTR:; CAT:NONE; SFS:(4636009)(39860400002)(366004)(136003)(376002)(346002)(396003)(4326008)(8936002)(6486002)(186003)(83380400001)(6916009)(2616005)(5660300002)(66946007)(52116002)(478600001)(8676002)(6512007)(6506007)(86362001)(2906002)(44832011)(66476007)(66556008)(316002)(1076003)(38100700002)(6666004); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: 9YyFytoGIZvBB42EA+0K1uJiNcWgYLe925j4fP/Km95hCHIc68+wRKSZnAMRhQeBaTRsI7b+7tdYbtOTI3HjQH7HVmJ3MZQFNqSmGofrEx0dJIvpnXvyGJ4SWEXRm9umGuebDpajwB+1v79pnuYkZq//H2XEfyf7XAN2nJHaKGKa5j2Df/ggdXJEmcoJQIEm81HdAZiekpejl4p7GLra/DYMPCKTkoRuRGmqnmKbk5gmgGBOjlbLMsSYwuiTXA2V4krC56TZ4FLvauQq8kaJSFQbxcR6j5GxJuS5bvpXDSuNLJ4U5irSA7kAulJKS6Q3Eh4CLq+fbkzRKY7ynCmHB1jVFgFPs1lkw8pb5xpWnOqZ/dmRo4UQrtIOneWVk/gREm8/cCnTWOfOUYQKkz0i1eqJp/iIoXfWUQ5kMcRyFUscu2jCJgQa+wLXEBQX7Zvbf5dxRhfdQJWXcTDFhlyTFo/+Bjelh49JQUoixMotW5IaWlNUNDYDoHzwA+OzDP8atV8FlYsG/DxzBW8dJvBberxQQ6sC1RrrmZTdFcz+Y/wgnZW3xXYk+R5HIf2GGrM6/UTsj7zDaFYPegHiOAKMlvhpTitcP/QVhfdt0mwGT4VKmA2mSq+GF/ths8DuRurI2erTv5N3qM7mIfAvXgMOSvvUNsmld4XGhsriWR2V20QcUsrYxnHOYVjDywdc2HdJR1fyBaXKJfD5LEYFBAtTCBuZWay82LclpQtvvqIaGQkG1zHujnL5SV4nxZLGFRqYyYffHZZn9iGk8fu9IR6Pt29Y+roBSII8b7+CjLziyE1cSx6UKeW0O4fbJS+KlWLRwI4ggaYfquERw/+WagN0bKyvgwxsnbsL9xvbtJF6nqYzY93V+8Z+k4ZKdjhahpjMtK7/t5b3pka6qRkRSD9onatepZtEb7NcxgtHf55LNDzp5uhS/OLe1MPuqVC3Bt5b9WtvP125cBXyxUPEb9xusESV5gFZ5c8lkN3Byy0AL6M9G7tn3dSO4bdxeJ5C5czZnCr5nFNUlydfCOYxFou9DoApbDNU9oLOhFPIifhsO2ywXxJRgyYRf6XcGCCPvEXqKl3swpe49oiRA74SFUzGg3iViKDq1ATVeO0456HbrQGvvYIlDULyKRzEsOLn7xGrv6uszPlY5B+NEeWeoZRQwlSS8lQVvmStOkxc2Q11NEvQMfBfpFC33eCQu1Be5ZZgo26EO6/4Vfca0Gz1ZiLXCkbt/4RyQkPFYcn29o8dr66cCCSFSsNBn0ellA9bZLOhwmplcBozeP8NLVd3sL44qXkAOEmsU1pwtOackiIe55HlV2zh/s8MjiF2hqBB53lDKzy3bOJtxd/laO4qFJcAo5aHlLVQ5PRQL8YgBP4A5SBQzeYuKeM9tmTYfzeqQNxl X-OriginatorOrg: oss.nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 8d0493af-55ae-4d0e-3181-08d97903865d X-MS-Exchange-CrossTenant-AuthSource: VI1PR04MB5151.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 16 Sep 2021 11:17:09.8391 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: i+LyBsmEgZNjs7qC2w12xZn+4IGX2YuD8Y1v/NCSbvIiigrztraI6mtaR0W7CYUzQZ2H7Sh0loD9FKpgjlWGZQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR04MB4926 Cc: pierre-louis.bossart@linux.intel.com, alsa-devel@alsa-project.org, kai.vehmanen@linux.intel.com, lgirdwood@gmail.com, daniel.baluta@nxp.com, linux-kernel@vger.kernel.org, ranjani.sridharan@linux.intel.com, Guennadi Liakhovetski , peter.ujfalusi@linux.intel.com X-BeenThere: alsa-devel@alsa-project.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: "Alsa-devel mailing list for ALSA developers - http://www.alsa-project.org" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: alsa-devel-bounces@alsa-project.org Sender: "Alsa-devel" From: Ranjani Sridharan Refactor the existing code to use helper functions to set up/free widgets, send dai config and set up kcontrols for widgets. These will be reused later on for setting up widgets in the connected DAPM widgets list for a particular PCM when the dynamic pipeline feature is implemented. Signed-off-by: Ranjani Sridharan Reviewed-by: Guennadi Liakhovetski Reviewed-by: Pierre-Louis Bossart Reviewed-by: Kai Vehmanen --- sound/soc/sof/sof-audio.c | 234 +++++++++++++++++++------------------- 1 file changed, 116 insertions(+), 118 deletions(-) diff --git a/sound/soc/sof/sof-audio.c b/sound/soc/sof/sof-audio.c index 989912f2b739..a4b9bb99bced 100644 --- a/sound/soc/sof/sof-audio.c +++ b/sound/soc/sof/sof-audio.c @@ -11,6 +11,116 @@ #include "sof-audio.h" #include "ops.h" +static int sof_kcontrol_setup(struct snd_sof_dev *sdev, struct snd_sof_control *scontrol) +{ + int ipc_cmd, ctrl_type; + int ret; + + /* reset readback offset for scontrol */ + scontrol->readback_offset = 0; + + /* notify DSP of kcontrol values */ + switch (scontrol->cmd) { + case SOF_CTRL_CMD_VOLUME: + case SOF_CTRL_CMD_ENUM: + case SOF_CTRL_CMD_SWITCH: + ipc_cmd = SOF_IPC_COMP_SET_VALUE; + ctrl_type = SOF_CTRL_TYPE_VALUE_CHAN_SET; + break; + case SOF_CTRL_CMD_BINARY: + ipc_cmd = SOF_IPC_COMP_SET_DATA; + ctrl_type = SOF_CTRL_TYPE_DATA_SET; + break; + default: + return 0; + } + + ret = snd_sof_ipc_set_get_comp_data(scontrol, ipc_cmd, ctrl_type, scontrol->cmd, true); + if (ret < 0) + dev_err(sdev->dev, "error: failed kcontrol value set for widget: %d\n", + scontrol->comp_id); + + return ret; +} + +static int sof_dai_config_setup(struct snd_sof_dev *sdev, struct snd_sof_dai *dai) +{ + struct sof_ipc_dai_config *config; + struct sof_ipc_reply reply; + int ret; + + config = &dai->dai_config[dai->current_config]; + if (!config) { + dev_err(sdev->dev, "error: no config for DAI %s\n", dai->name); + return -EINVAL; + } + + ret = sof_ipc_tx_message(sdev->ipc, config->hdr.cmd, config, config->hdr.size, + &reply, sizeof(reply)); + + if (ret < 0) + dev_err(sdev->dev, "error: failed to set dai config for %s\n", dai->name); + + return ret; +} + +static int sof_widget_setup(struct snd_sof_dev *sdev, struct snd_sof_widget *swidget) +{ + struct sof_ipc_pipe_new *pipeline; + struct sof_ipc_comp_reply r; + struct sof_ipc_cmd_hdr *hdr; + struct sof_ipc_comp *comp; + struct snd_sof_dai *dai; + size_t ipc_size; + int ret; + + /* skip if there is no private data */ + if (!swidget->private) + return 0; + + ret = sof_pipeline_core_enable(sdev, swidget); + if (ret < 0) { + dev_err(sdev->dev, "error: failed to enable target core: %d for widget %s\n", + ret, swidget->widget->name); + return ret; + } + + switch (swidget->id) { + case snd_soc_dapm_dai_in: + case snd_soc_dapm_dai_out: + ipc_size = sizeof(struct sof_ipc_comp_dai) + sizeof(struct sof_ipc_comp_ext); + comp = kzalloc(ipc_size, GFP_KERNEL); + if (!comp) + return -ENOMEM; + + dai = swidget->private; + memcpy(comp, &dai->comp_dai, sizeof(struct sof_ipc_comp_dai)); + + /* append extended data to the end of the component */ + memcpy((u8 *)comp + sizeof(struct sof_ipc_comp_dai), &swidget->comp_ext, + sizeof(swidget->comp_ext)); + + ret = sof_ipc_tx_message(sdev->ipc, comp->hdr.cmd, comp, ipc_size, &r, sizeof(r)); + kfree(comp); + break; + case snd_soc_dapm_scheduler: + pipeline = swidget->private; + ret = sof_load_pipeline_ipc(sdev->dev, pipeline, &r); + break; + default: + hdr = swidget->private; + ret = sof_ipc_tx_message(sdev->ipc, hdr->cmd, swidget->private, hdr->size, + &r, sizeof(r)); + break; + } + if (ret < 0) + dev_err(sdev->dev, "error: failed to load widget %s\n", swidget->widget->name); + else + dev_dbg(sdev->dev, "widget %s setup complete\n", swidget->widget->name); + + return ret; +} + /* * helper to determine if there are only D0i3 compatible * streams active @@ -97,46 +207,13 @@ static int sof_restore_kcontrols(struct device *dev) { struct snd_sof_dev *sdev = dev_get_drvdata(dev); struct snd_sof_control *scontrol; - int ipc_cmd, ctrl_type; int ret = 0; /* restore kcontrol values */ list_for_each_entry(scontrol, &sdev->kcontrol_list, list) { - /* reset readback offset for scontrol after resuming */ - scontrol->readback_offset = 0; - - /* notify DSP of kcontrol values */ - switch (scontrol->cmd) { - case SOF_CTRL_CMD_VOLUME: - case SOF_CTRL_CMD_ENUM: - case SOF_CTRL_CMD_SWITCH: - ipc_cmd = SOF_IPC_COMP_SET_VALUE; - ctrl_type = SOF_CTRL_TYPE_VALUE_CHAN_SET; - ret = snd_sof_ipc_set_get_comp_data(scontrol, - ipc_cmd, ctrl_type, - scontrol->cmd, - true); - break; - case SOF_CTRL_CMD_BINARY: - ipc_cmd = SOF_IPC_COMP_SET_DATA; - ctrl_type = SOF_CTRL_TYPE_DATA_SET; - ret = snd_sof_ipc_set_get_comp_data(scontrol, - ipc_cmd, ctrl_type, - scontrol->cmd, - true); - break; - - default: - break; - } - - if (ret < 0) { - dev_err(dev, - "error: failed kcontrol value set for widget: %d\n", - scontrol->comp_id); - + ret = sof_kcontrol_setup(sdev, scontrol); + if (ret < 0) return ret; - } } return 0; @@ -163,77 +240,14 @@ int sof_restore_pipelines(struct device *dev) struct snd_sof_dev *sdev = dev_get_drvdata(dev); struct snd_sof_widget *swidget; struct snd_sof_route *sroute; - struct sof_ipc_pipe_new *pipeline; struct snd_sof_dai *dai; - struct sof_ipc_cmd_hdr *hdr; - struct sof_ipc_comp *comp; - size_t ipc_size; int ret; /* restore pipeline components */ list_for_each_entry_reverse(swidget, &sdev->widget_list, list) { - struct sof_ipc_comp_reply r; - - /* skip if there is no private data */ - if (!swidget->private) - continue; - - ret = sof_pipeline_core_enable(sdev, swidget); - if (ret < 0) { - dev_err(dev, - "error: failed to enable target core: %d\n", - ret); - - return ret; - } - - switch (swidget->id) { - case snd_soc_dapm_dai_in: - case snd_soc_dapm_dai_out: - ipc_size = sizeof(struct sof_ipc_comp_dai) + - sizeof(struct sof_ipc_comp_ext); - comp = kzalloc(ipc_size, GFP_KERNEL); - if (!comp) - return -ENOMEM; - - dai = swidget->private; - memcpy(comp, &dai->comp_dai, - sizeof(struct sof_ipc_comp_dai)); - - /* append extended data to the end of the component */ - memcpy((u8 *)comp + sizeof(struct sof_ipc_comp_dai), - &swidget->comp_ext, sizeof(swidget->comp_ext)); - - ret = sof_ipc_tx_message(sdev->ipc, comp->hdr.cmd, - comp, ipc_size, - &r, sizeof(r)); - kfree(comp); - break; - case snd_soc_dapm_scheduler: - - /* - * During suspend, all DSP cores are powered off. - * Therefore upon resume, create the pipeline comp - * and power up the core that the pipeline is - * scheduled on. - */ - pipeline = swidget->private; - ret = sof_load_pipeline_ipc(dev, pipeline, &r); - break; - default: - hdr = swidget->private; - ret = sof_ipc_tx_message(sdev->ipc, hdr->cmd, - swidget->private, hdr->size, - &r, sizeof(r)); - break; - } - if (ret < 0) { - dev_err(dev, - "error: failed to load widget type %d with ID: %d\n", - swidget->widget->id, swidget->comp_id); - + ret = sof_widget_setup(sdev, swidget); + if (ret < 0) return ret; - } } /* restore pipeline connections */ @@ -266,15 +280,8 @@ int sof_restore_pipelines(struct device *dev) /* restore dai links */ list_for_each_entry_reverse(dai, &sdev->dai_list, list) { - struct sof_ipc_reply reply; struct sof_ipc_dai_config *config = &dai->dai_config[dai->current_config]; - if (!config) { - dev_err(dev, "error: no config for DAI %s\n", - dai->name); - continue; - } - /* * The link DMA channel would be invalidated for running * streams but not for streams that were in the PAUSED @@ -284,18 +291,9 @@ int sof_restore_pipelines(struct device *dev) if (config->type == SOF_DAI_INTEL_HDA) config->hda.link_dma_ch = DMA_CHAN_INVALID; - ret = sof_ipc_tx_message(sdev->ipc, - config->hdr.cmd, config, - config->hdr.size, - &reply, sizeof(reply)); - - if (ret < 0) { - dev_err(dev, - "error: failed to set dai config for %s\n", - dai->name); - + ret = sof_dai_config_setup(sdev, dai); + if (ret < 0) return ret; - } } /* complete pipeline */ From patchwork Thu Sep 16 11:16:39 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Daniel Baluta (OSS)" X-Patchwork-Id: 12498729 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,MSGID_FROM_MTA_HEADER,SPF_HELO_NONE,SPF_PASS, USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 602C0C433EF for ; Thu, 16 Sep 2021 11:20:04 +0000 (UTC) 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 mail.kernel.org (Postfix) with ESMTPS id 9479A60F6D for ; Thu, 16 Sep 2021 11:20:03 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 9479A60F6D Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=oss.nxp.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=alsa-project.org Received: from alsa1.perex.cz (alsa1.perex.cz [207.180.221.201]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by alsa0.perex.cz (Postfix) with ESMTPS id 336D318A7; Thu, 16 Sep 2021 13:19:12 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz 336D318A7 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1631791202; bh=v1KjnTzl4qOxoIUsNGgtzOD/w/VVMQ+fz3ojAe7AIU4=; h=From:To:Subject:Date:In-Reply-To:References:Cc:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=eU+pv+aBmqb7MwPpHntk81kVcHkjYXcKkKpa4GcLdKDWBmb4tDFQRH7OByJRT5KGf I0oOxuj/Zq+XT/bsl+ac//4mDOL9u3gY0aw5f8Yn+Ha+6YzzzMau8F3goF1tiJugwP rnLfi3HbPoBr6ZcaKNUoW4ysDWIIxDY6d59MG8uE= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id 8C869F804FB; Thu, 16 Sep 2021 13:17:33 +0200 (CEST) Received: by alsa1.perex.cz (Postfix, from userid 50401) id 5ECDEF80508; Thu, 16 Sep 2021 13:17:29 +0200 (CEST) Received: from EUR03-VE1-obe.outbound.protection.outlook.com (mail-eopbgr50050.outbound.protection.outlook.com [40.107.5.50]) (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 B0DCFF804AE for ; Thu, 16 Sep 2021 13:17:17 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz B0DCFF804AE Authentication-Results: alsa1.perex.cz; dkim=pass (1024-bit key) header.d=NXP1.onmicrosoft.com header.i=@NXP1.onmicrosoft.com header.b="R7khKUrC" ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=jJ72Dr2lHI/a8CkMh5nzMg9BTGaeOBDG8cbGsXQmJCahONBwod13oEuq3pIIQUsyeBBrnpbZZNC2OjXMsRjLu1m5peUTpCrZ6lVJDS01kjySDND2dqDZzCcJVjemVJPIy+V/nK4P3wlfGaVgkUT0r0X8H/8rasmkHuDiSFwL+kQushwnr5zA9TbhGtUC4FcLeCyHXWOPQp8y7Au7cJW7FTkwH5ldZIpUDr2YuIpIpeimxmcXKLh2UuHj/YBUzwXcsuftFc6DnElEthT0VScA308qYk/Cnh3vnKx59QVWJ0XWW8hpTykjxwKJx3ECBomFL76A2AFzIS76Ar7NiqKYWw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version; bh=s4gSGFdBQikU5ekOST9Axn3JdIYo1AnQE4w5NId+WHM=; b=oIYShRrbbIaTkUMSmIBU0rX+D/03tK6mbtGU4fwQR4Lpww6VdMN3onPWICHUS8s6dgf6Zba9EQli5qVHpjSflKKJ1cDOIIIABFJBUimqHcm1S33xAPtaBEkZgIr1hceZjX/8K3sNi2BDlDQHovqKlUyESnCNYXS2d2iUEo+sKk3n/kpVus2bB6FvF6DrztZR1+66MMznrI4DbApsCmG8X0Si1Tk+V8YGhDOfTQaiA1AB0hugIaHdWvGPCeh6AFlsNB9eQDRKt3FlPLI/IGMsFOdj2BbksGXzXeksxF5ZEKOmGxNGtexoYgJXSE7RU7LaLtiEUHeb9010DYKfzEtaOA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=oss.nxp.com; dmarc=pass action=none header.from=oss.nxp.com; dkim=pass header.d=oss.nxp.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=NXP1.onmicrosoft.com; s=selector2-NXP1-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=s4gSGFdBQikU5ekOST9Axn3JdIYo1AnQE4w5NId+WHM=; b=R7khKUrCzdEFptFn2WF5mjct2Znr4pN3+NZpzXPu02KAKxvXCBZyoILKRS+0TYz7VUuZcKYgjooyUi+z8zHYG5r1CVs4FdGbsQCzQwLS1cAEHllBzss+on8QWpvd1d9G7gIGXJb6LAF2bp2c4aaLCbEGlgHuJOAxruGPZLEb0v4= Authentication-Results: kernel.org; dkim=none (message not signed) header.d=none;kernel.org; dmarc=none action=none header.from=oss.nxp.com; Received: from VI1PR04MB5151.eurprd04.prod.outlook.com (2603:10a6:803:61::28) by VI1PR04MB4926.eurprd04.prod.outlook.com (2603:10a6:803:51::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4500.18; Thu, 16 Sep 2021 11:17:11 +0000 Received: from VI1PR04MB5151.eurprd04.prod.outlook.com ([fe80::499b:ba92:db2e:3f28]) by VI1PR04MB5151.eurprd04.prod.outlook.com ([fe80::499b:ba92:db2e:3f28%7]) with mapi id 15.20.4500.020; Thu, 16 Sep 2021 11:17:11 +0000 From: Daniel Baluta To: broonie@kernel.org Subject: [PATCH 05/12] AsoC: dapm: export a couple of functions Date: Thu, 16 Sep 2021 14:16:39 +0300 Message-Id: <20210916111646.367133-6-daniel.baluta@oss.nxp.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20210916111646.367133-1-daniel.baluta@oss.nxp.com> References: <20210916111646.367133-1-daniel.baluta@oss.nxp.com> X-ClientProxiedBy: AM0PR04CA0037.eurprd04.prod.outlook.com (2603:10a6:208:1::14) To VI1PR04MB5151.eurprd04.prod.outlook.com (2603:10a6:803:61::28) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from localhost.localdomain (2a02:2f08:5708:8600:b29c:ccfa:a961:8ebd) by AM0PR04CA0037.eurprd04.prod.outlook.com (2603:10a6:208:1::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4523.14 via Frontend Transport; Thu, 16 Sep 2021 11:17:10 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: ef094a39-6457-4cfa-21d2-08d97903873e X-MS-TrafficTypeDiagnostic: VI1PR04MB4926: X-MS-Exchange-SharedMailbox-RoutingAgent-Processed: True X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:2512; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: v1xzJeisueNgJhlZ82tMibSdrwAvj3VvUivnyAV+a+P9R9c53lfpybPK4QLk1ayt3R/mDrCBERlzxz/XahiLnMByxZFQXc3/IdOLNInJLklO/TmwTpfYeqe95JPFndTF8A0tr8YVkDmG2R6AIxw8GP7ujjkueBIVpEzZqzUs1bIxfJUDiGYFoiuKTxaAJz8i2EgfPr090mggGw5DVFpbUrBO8E8Gg4JbSgrJRl74TAtpGj8qgDLGUqdIknkvXGkiWa7AWesSmtJJIDTDMcdTzVQ4wxiazb54Ulf9JpAxmR/CjqC7Z55Cetbyb/3KlkWHEc189sijBFrXW187jjLvEl8ITJNqJW4Z9IMl7hIBdB2M1RtoImWLh6289xPqEopjBdjQdul8FHoO8vmtF+bM6b78k9qmD1TdJcTOj/uxvS1fDk8UZL130zCUNW5YrktJ7YUUpUdGaVNyvDezpEidpg36e6zFk3LK47YgfUIm+atWsax1iVOzEeHQEO2lgVN29x6yWnmvknDXZlybJiI1En5+uV2xCp9OT3FQAhLb3yzRE+xwiAeRIeFBGU7XGECamgeMCs5qdjI27SfWZsUDlr+Kwlp6ccmI43QLqg0BfcAhNWkIoSRiw/uLdOgt4ldwu+L9zr0Tlw9hhToX4Em6dA== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:VI1PR04MB5151.eurprd04.prod.outlook.com; PTR:; CAT:NONE; SFS:(4636009)(39860400002)(366004)(136003)(376002)(346002)(396003)(4326008)(8936002)(6486002)(186003)(83380400001)(6916009)(2616005)(5660300002)(66946007)(52116002)(478600001)(8676002)(6512007)(6506007)(86362001)(2906002)(44832011)(66476007)(66556008)(316002)(1076003)(38100700002)(6666004); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: csUrKDvwkv/kdTcc8YibPSfOGPcSgIBIhp/wJ2NEhSEE664Iu+f3H15Od49FsXLRSwhM7snzOBCADC0oH6AqYy2POVaNsHlynnyE9RDaRyugLYAQmYpY+9ZeRjPtCB3MTbUNpyfGuvcmiOApKv8zD2b3xDfevBwGrF+uTCZzlSDLzZ4uuc+HnSuEDD9LbJo7hypq11aQAeW6QTcR5HGYFp+5eQ3SznattftStiT4/xwNHyNgAeB9fYpzz1roSGowuPAs6RYoJZ/IDzJPBqOHErLp/FSwvJiCMAusdhrMCbYlaEnPdhSs9Pz5PlXNgqKorvAcucp8KR0hRvuPYrlNl0MPcy3FC9IYs+YDxQeQLvyUiubZI/EGIVigNduf0PVbwkGlnoOXCLFxPtfmnwRIh0pAk0XyxDb76T1W8Wh9Q1s/xTUnElTdQHoM00S0VQTIGBOYOOfhPcE2q/cJ3TadOtgLJ23LzZFRa9CuSYglEbjx9eHhtYcW/Dvxit7JqO3DxzpjaAVQzeaO2Y2tHPSb1ukx+XfDziwZ/IbiN4AohBys6c/JeKzY7fvQRpHMHRdihWEH+t05lOANC7hHULYESHA53mQIvc8XnHH+FLmzeJncFcXT4tkA2wM4H2EislTTB9zipJHRIMktp8/IhOin/EGhO09oUI6g7A/ZmjB+n+XPsY9u1jH8gUpHcIkMqlzz6VNXH/LGuAnvqsEaV2ijWdOnGKU5Jt19RR/cj10xQFRUfo+V5D9fMBNRavnj/xOgpT2Zx8kKcL5uWWkmrvs91SIDpsZqhOBVnEBU4c851ZX0cHP06/sg7GBNMqWhrdpPRQLkCTTr3L39wyslO0W6ZT865kPozPxomMuxeWxVY/10LZDQKi5uddByMCGFtRfqZoZq8JltJKKPYaUYtLeRtXHxRjRD/HlzYTQ4YfjpYrrVq2zYHaVZeAeSCqvp2/RQofBvKL+2HyJcBad1MwCTsRqQcIPdWejl5TY9vitOXc/mAOeTAocbF4tel9o/W8yLvaesz/c94VmquJuBcVAdqis4/+od9djqlm6TvelUrGrUc8PZX97BUPF3LAbOjuOSWQd3DQVD/eh9/Yi7SzOQ8WPCGp8c17WnTAQAa2XYf99rqSX6zMqA/ytWkngYWwwzXBYl19/oSc5qjef08/ugML22XH6mp9rqOxC5DUXMrv69gSCJqgKE23H2NzS01IvWE4eHZlcv4pantfUgxrtfg+HOM8o9faonR4ac82MU5dBYQ5hyJQkz9MJTvqbNKIcA1vaOyQsDGQSW3AeVdXcdSQm35+cf6h8W7BXPY/gM9oi/x2yFYC+xNP46EWGmtxWRlyQtPXrtl21mpBQjZTp+rUj4f3iAo7bib1DIHSJQkPp6/afRYDfxrSREv39NaQsd X-OriginatorOrg: oss.nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: ef094a39-6457-4cfa-21d2-08d97903873e X-MS-Exchange-CrossTenant-AuthSource: VI1PR04MB5151.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 16 Sep 2021 11:17:11.1993 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: 8J6UT7qz3mCk90j5hPqAhapQH1+yd1sGO5PUeGEc1LtY6HPt9R1xET+szzncqU72xxVAieIUlzucnpdTfEOv/A== X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR04MB4926 Cc: pierre-louis.bossart@linux.intel.com, alsa-devel@alsa-project.org, kai.vehmanen@linux.intel.com, lgirdwood@gmail.com, daniel.baluta@nxp.com, linux-kernel@vger.kernel.org, ranjani.sridharan@linux.intel.com, Guennadi Liakhovetski , peter.ujfalusi@linux.intel.com X-BeenThere: alsa-devel@alsa-project.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: "Alsa-devel mailing list for ALSA developers - http://www.alsa-project.org" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: alsa-devel-bounces@alsa-project.org Sender: "Alsa-devel" From: Ranjani Sridharan Export a couple of DAPM functions that can be used by ASoC drivers to determine connected widgets when a PCM is started. Signed-off-by: Ranjani Sridharan Reviewed-by: Guennadi Liakhovetski Reviewed-by: Pierre-Louis Bossart Reviewed-by: Kai Vehmanen --- include/sound/soc-dpcm.h | 1 + sound/soc/soc-dapm.c | 2 ++ sound/soc/soc-pcm.c | 4 ++-- 3 files changed, 5 insertions(+), 2 deletions(-) diff --git a/include/sound/soc-dpcm.h b/include/sound/soc-dpcm.h index e296a3949b18..bc7af90099a8 100644 --- a/include/sound/soc-dpcm.h +++ b/include/sound/soc-dpcm.h @@ -159,6 +159,7 @@ int dpcm_be_dai_trigger(struct snd_soc_pcm_runtime *fe, int stream, int cmd); int dpcm_be_dai_prepare(struct snd_soc_pcm_runtime *fe, int stream); int dpcm_dapm_stream_event(struct snd_soc_pcm_runtime *fe, int dir, int event); +bool dpcm_end_walk_at_be(struct snd_soc_dapm_widget *widget, enum snd_soc_dapm_direction dir); #define dpcm_be_dai_startup_rollback(fe, stream, last) \ dpcm_be_dai_stop(fe, stream, 0, last) diff --git a/sound/soc/soc-dapm.c b/sound/soc/soc-dapm.c index 7b67f1e19ae9..44c4d105ffdb 100644 --- a/sound/soc/soc-dapm.c +++ b/sound/soc/soc-dapm.c @@ -1331,11 +1331,13 @@ int snd_soc_dapm_dai_get_connected_widgets(struct snd_soc_dai *dai, int stream, return paths; } +EXPORT_SYMBOL_GPL(snd_soc_dapm_dai_get_connected_widgets); void snd_soc_dapm_dai_free_widgets(struct snd_soc_dapm_widget_list **list) { dapm_widget_list_free(list); } +EXPORT_SYMBOL_GPL(snd_soc_dapm_dai_free_widgets); /* * Handler for regulator supply widget. diff --git a/sound/soc/soc-pcm.c b/sound/soc/soc-pcm.c index 48f71bb81a2f..fc1854e3e43f 100644 --- a/sound/soc/soc-pcm.c +++ b/sound/soc/soc-pcm.c @@ -1262,8 +1262,7 @@ static int widget_in_list(struct snd_soc_dapm_widget_list *list, return 0; } -static bool dpcm_end_walk_at_be(struct snd_soc_dapm_widget *widget, - enum snd_soc_dapm_direction dir) +bool dpcm_end_walk_at_be(struct snd_soc_dapm_widget *widget, enum snd_soc_dapm_direction dir) { struct snd_soc_card *card = widget->dapm->card; struct snd_soc_pcm_runtime *rtd; @@ -1281,6 +1280,7 @@ static bool dpcm_end_walk_at_be(struct snd_soc_dapm_widget *widget, return false; } +EXPORT_SYMBOL_GPL(dpcm_end_walk_at_be); int dpcm_path_get(struct snd_soc_pcm_runtime *fe, int stream, struct snd_soc_dapm_widget_list **list) From patchwork Thu Sep 16 11:16:40 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Daniel Baluta (OSS)" X-Patchwork-Id: 12498725 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,MSGID_FROM_MTA_HEADER,SPF_HELO_NONE,SPF_PASS, USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 43141C433F5 for ; Thu, 16 Sep 2021 11:19:26 +0000 (UTC) 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 mail.kernel.org (Postfix) with ESMTPS id B78726103B for ; Thu, 16 Sep 2021 11:19:25 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org B78726103B Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=oss.nxp.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=alsa-project.org Received: from alsa1.perex.cz (alsa1.perex.cz [207.180.221.201]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by alsa0.perex.cz (Postfix) with ESMTPS id 4FB7318AE; Thu, 16 Sep 2021 13:18:34 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz 4FB7318AE DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1631791164; bh=YDcAco6+2z3hSzMZ03vb/m3o/bODu4kFdsSeOoMyVVo=; h=From:To:Subject:Date:In-Reply-To:References:Cc:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=qEaKFnPNE8mEf2l8rdjX1oXvjGkg/Vw07f4ARvz33x2HJxjmIltXWbequ6jQlNB1m OR6VHfancoDmMT5DtuHskTBDsnE+i3r43cCk3+g1U79hnOBz9a94MoxH5Hbp+R6zvz jk8g4cmx68URUDfy2DEwCElpKfcLON3BzH9OWkCc= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id DBD2EF8032B; Thu, 16 Sep 2021 13:17:28 +0200 (CEST) Received: by alsa1.perex.cz (Postfix, from userid 50401) id 19C4CF80507; Thu, 16 Sep 2021 13:17:27 +0200 (CEST) Received: from EUR03-VE1-obe.outbound.protection.outlook.com (mail-eopbgr50058.outbound.protection.outlook.com [40.107.5.58]) (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 3202EF804B0 for ; Thu, 16 Sep 2021 13:17:18 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz 3202EF804B0 Authentication-Results: alsa1.perex.cz; dkim=pass (1024-bit key) header.d=NXP1.onmicrosoft.com header.i=@NXP1.onmicrosoft.com header.b="X6HgEE+W" ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=aEiZiu8/asj++LQxSnS8gGGnhgDFy/N1UAkeiUPQyiqxKznIv7NRJeQ13R3s/P6yVkwHtpyex9LOTuykkukjs9/6BtHgrUO+rjKHc8uah0WEwFAHKuGjP19Er6i/i+B1cHNL5JIjvDXjiaOrfhUDoJySFX8wce696YGesSqE01jhzvL9MTOd7IEdivxLX5zgHNvu/9ASlH1oP1ZxkIqbee6FxdlLGKCLz/94Z1fAAHI1PcRp0y8E5+3rOVwcu6nHeTTj+U35g/8mGHbzy1i6P5f2TYS0Ora31WSHDu5H82Y+Bqy8ihra+X3sUNoGCExr3vVfuLUiDMX+1gn00Na8VQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version; bh=9F6N7Pj6vo69zc/ttEoJKiruQrqXNdVgT/jVWK7imMo=; b=OolH5jumsXW8RlBwtjABDXzQv8QKHkVCLnRixwqx1PERQ+l8LoCPVWbBtaPhvXBY+lhaVXkKGj8Y+Q7HrF4FFttiyTyyjW5l9XTLt8p8xllX1SqO4Zw/uG/wK0QOmMI6jCOqmn1oTNrrs/DbVaOnVzSItISHGyVfDlT2X2l+u7Ie0/LjXc+JdGgSqBexGenppPW8XhRbmAF2Cu4wo0AFg8l3+NxeDT6m6ZPGTdRXJtlsl0Dpz7A0NzjNTJCE2qUmF9yZ/XiTfeTkknaMQWmPXHMxxRY34AYiz5zYa4J/sxqjqT3ibxDiN3iz0Dsx78zxxhrf9Cd+Wmv1xPxyuFl7EQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=oss.nxp.com; dmarc=pass action=none header.from=oss.nxp.com; dkim=pass header.d=oss.nxp.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=NXP1.onmicrosoft.com; s=selector2-NXP1-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=9F6N7Pj6vo69zc/ttEoJKiruQrqXNdVgT/jVWK7imMo=; b=X6HgEE+Wp9nFAnlFP6UFc2PRjLPpH+JYuSlH8VgHy8q4NURnQzgrFsufKgqbMfttAi8Wpkbt9xUsC6SkuhNuWsLjJlhEH0o3R99llKBsCwBMoy36LHFqAsPnR5JAWzpio9FI1U6iCwZ7Ibb/l1PIh+J7EjUvGVhjBsvkBFIJd3U= Authentication-Results: kernel.org; dkim=none (message not signed) header.d=none;kernel.org; dmarc=none action=none header.from=oss.nxp.com; Received: from VI1PR04MB5151.eurprd04.prod.outlook.com (2603:10a6:803:61::28) by VI1PR04MB4926.eurprd04.prod.outlook.com (2603:10a6:803:51::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4500.18; Thu, 16 Sep 2021 11:17:12 +0000 Received: from VI1PR04MB5151.eurprd04.prod.outlook.com ([fe80::499b:ba92:db2e:3f28]) by VI1PR04MB5151.eurprd04.prod.outlook.com ([fe80::499b:ba92:db2e:3f28%7]) with mapi id 15.20.4500.020; Thu, 16 Sep 2021 11:17:12 +0000 From: Daniel Baluta To: broonie@kernel.org Subject: [PATCH 06/12] ASoC: SOF: Add new fields to snd_sof_route Date: Thu, 16 Sep 2021 14:16:40 +0300 Message-Id: <20210916111646.367133-7-daniel.baluta@oss.nxp.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20210916111646.367133-1-daniel.baluta@oss.nxp.com> References: <20210916111646.367133-1-daniel.baluta@oss.nxp.com> X-ClientProxiedBy: AM0PR04CA0037.eurprd04.prod.outlook.com (2603:10a6:208:1::14) To VI1PR04MB5151.eurprd04.prod.outlook.com (2603:10a6:803:61::28) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from localhost.localdomain (2a02:2f08:5708:8600:b29c:ccfa:a961:8ebd) by AM0PR04CA0037.eurprd04.prod.outlook.com (2603:10a6:208:1::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4523.14 via Frontend Transport; Thu, 16 Sep 2021 11:17:11 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 27493ac8-0ed2-4ffc-25ee-08d9790387fc X-MS-TrafficTypeDiagnostic: VI1PR04MB4926: X-MS-Exchange-SharedMailbox-RoutingAgent-Processed: True X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:6790; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: P9lennv0wCYFwZq4cZwRRPOgZR6WE6BUupHGfiAk9n2uCiNE/f3QS7iPxGL5inLPPHAYIycAtnHbgXaDdzmHKXvRtpSUmAG9mZQWoJw6EK9kxoL8dt0gndBXvFdWXXxwu3avAcqjRxwcecD0Dt5+jPIytayLSnQ9VUau6Pit1mCS5/Yg37lUmUGknwggQuwu6HYwnuLdlw1VEIFXb787uYMuRWbPJWaqlto9CYEdDzcSasyyPCQJIsefgKPKIm4WGqmn6az2bb4D2xQjWrQfk4FbNuJVI4ekTL+vQYMXsFUHXCMzdA8W9FIu0fru64iuCGsqrnOSQxCZb5H9SifHqzKtPSpQBDa945mHc6PZAy5YxSrrkzKKtjqREqLGsNaYF7AipVfkEq34PoM+rklFlQDEMUei0dq1C5OwGtrj889uyH+wZI1j5K2/n6k2IAb0aEcN4C4OGiDr2uKVa6jsJ65yAtcAcTWpvIZVYq13VwAPe2gL3B5Fr1gUC7ffDGT1BQclGY81bESFtncFQgMiu+Ksv4ibK8J7iRERxrtHNf+Py4VqEuF7qJm3AVmUfL3pDaLI1FWwhRCvytDclAUsY31400wMOSu8s2vVQHNMxZ74OFx2sEY7MkkUKfNhT67aIJk3M0LVqL+clmtOz7k84w== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:VI1PR04MB5151.eurprd04.prod.outlook.com; PTR:; CAT:NONE; SFS:(4636009)(39860400002)(366004)(136003)(376002)(346002)(396003)(4326008)(8936002)(6486002)(186003)(83380400001)(6916009)(2616005)(5660300002)(66946007)(52116002)(478600001)(8676002)(6512007)(6506007)(86362001)(2906002)(44832011)(66476007)(66556008)(316002)(1076003)(38100700002)(6666004); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: 9wMxM702sl2V+sj6V7xguZlPfOe4QnIaB8fNWE3o1+xm/2zQo2uZJ+mzWIYZdpmChmDfniH8QG8gxOzCMsNa4qnO7hP12ZrKAZAmDxj+J4o2pk8RHoZY3QosvJh+g9fruO9PlZtpG0yZAAY51N33Qhy11l55zm/LrgRTYgBERk2OsoFKRbzBP+VTTPb0emKWzAaEbx+xHDjbeFlXfdpqyX4aisanTaR5qySeGHFxgyt60YbSD/FxEGdSGN7Z8ZjrfWSI8h9BWSH2M27MIShjJReFbUsF1bB//I1j/EjDcnGEL6i4OOGOSyHh5GJ8+t+dt9BDqVAyVrP2FWGWHLPod9MFzCslw8JgNzlEH1pkX4thWoCkMi5Lrc3gkWR5HOjKkwigkG/2SCAkYi7eULmXAC01S0dZxnxX+GkXBbxm9szzHXHJrIGJFeiR7YNa5dnNJDC6GlGKawcweLhlWWRxKQ5iyzdgO8PP0rsgo1snAOMUpFc2lLJ4yVD9j98T0aUqa5DvVmt0OZY5BUT7a2mwQFrVkkWTb8J77LGwSF8lKNlHwe8Ff+DOrpQpASqA9S/uiA+z6vLCwTlUwMYeI3GSmXmYz2F0ZGMrBW05mNh+aizFZZrG4aXqz3xx7gG7RlmKGCbiMza3+MLhvjLJgPRRcZvjdXqo+l8urXkjni+lgqK1uwZjk5UH4kVuARqlf9XaN4tDFZm4ndE1rCpxk7lDs8m/eEA5tWNYSqRaQXUnvpzqg+gpuTS3LR+dB/jJ1o2ko8/wYzAntCfVXg1/+zhRF48cUeFs9vU0bncSfui5PPSB4JQzIUXoSaVATwKxD4UjX3c6kwPnG8V3GdzFA4TLqfoSBQI9I5NOTP1JtzfuX7X1EwgI98W4qq4Z/9vGeHcqQ+XIaSPDeGTzN8Tj6YSyuBgHutms3OMb7E5hv4+WvGoItyyIAiwdG/Ly0KgUNEBwKeIVTGhpc1oEsr+mHwI1HIpRVX0SXCMsObPtc6ScKBO8Z+kedS2qPEEB8GqXfwkofTSLnMmLgDjNaWWvWQIKrRatZeJxYMO/h1u14Yf27peOcn8AKTWasL7KFLatnEXKhkhGcd6lRTk2rsgousGlyrN4s+egU1VoveVX6f+hXNhjeD3iTnY0d475rKfCJWxpDHgZgs8bJe/nx9dZLgy9Jxl33C7yI2Fo6G4DiuNvaTh1ioH8ognkmnGaDKIsalBjdKGbHX5oUdINBTSh7+bE7nsBOvyGJYPz0HTuT7sSCHsc8UrJQ/EXlZ+cE0dohdGilNDxSoBXjUNJG6gB/wI4RfeEeb1UbJ81oSl85MtML8pIrCf0VEnFM30DEXbEkybLCmk97bHuTgghr7AmQb29XxzXB0hn7D8xBPoapXdQu78IOoS+gxiG9VLtJ9exGietv90D0KL9UPXwG7VWLb2WpA== X-OriginatorOrg: oss.nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 27493ac8-0ed2-4ffc-25ee-08d9790387fc X-MS-Exchange-CrossTenant-AuthSource: VI1PR04MB5151.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 16 Sep 2021 11:17:12.4656 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: XTK5hAVukmZL1hl9cdSdGkm2WGW2QhTQICxNiJk1xVd8tIbYAb3iKYOWT+rO1LZyt36W4fVocxiqCeFu5DM7gg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR04MB4926 Cc: pierre-louis.bossart@linux.intel.com, alsa-devel@alsa-project.org, kai.vehmanen@linux.intel.com, lgirdwood@gmail.com, daniel.baluta@nxp.com, linux-kernel@vger.kernel.org, ranjani.sridharan@linux.intel.com, Guennadi Liakhovetski , peter.ujfalusi@linux.intel.com X-BeenThere: alsa-devel@alsa-project.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: "Alsa-devel mailing list for ALSA developers - http://www.alsa-project.org" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: alsa-devel-bounces@alsa-project.org Sender: "Alsa-devel" From: Ranjani Sridharan Add two new fields to save the source widget and sink widget pointers in struct snd_sof_route to make it easier to look up routes by source/sink widget. Also, add a flag to indicate if the route has been set up in the DSP. These will be used when the dynamic pipeline feature is implemented and routes will have to be set up at run time. Also, add a new sof_tear_down_pipelines() callback, that will used to reset the set up status for all routes during suspend. Signed-off-by: Ranjani Sridharan Reviewed-by: Guennadi Liakhovetski Reviewed-by: Pierre-Louis Bossart Reviewed-by: Kai Vehmanen --- sound/soc/sof/pm.c | 2 ++ sound/soc/sof/sof-audio.c | 15 +++++++++++++++ sound/soc/sof/sof-audio.h | 4 ++++ sound/soc/sof/topology.c | 3 +++ 4 files changed, 24 insertions(+) diff --git a/sound/soc/sof/pm.c b/sound/soc/sof/pm.c index c83fb6255961..ce922227c4c6 100644 --- a/sound/soc/sof/pm.c +++ b/sound/soc/sof/pm.c @@ -208,6 +208,8 @@ static int sof_suspend(struct device *dev, bool runtime_suspend) if (target_state == SOF_DSP_PM_D0) goto suspend; + sof_tear_down_pipelines(dev); + /* release trace */ snd_sof_release_trace(sdev); diff --git a/sound/soc/sof/sof-audio.c b/sound/soc/sof/sof-audio.c index a4b9bb99bced..b52a453ae9d7 100644 --- a/sound/soc/sof/sof-audio.c +++ b/sound/soc/sof/sof-audio.c @@ -276,6 +276,7 @@ int sof_restore_pipelines(struct device *dev) return ret; } + sroute->setup = true; } /* restore dai links */ @@ -317,6 +318,20 @@ int sof_restore_pipelines(struct device *dev) return ret; } +/* This function doesn't free widgets. It only resets the set up status for all routes */ +void sof_tear_down_pipelines(struct device *dev) +{ + struct snd_sof_dev *sdev = dev_get_drvdata(dev); + struct snd_sof_route *sroute; + + /* + * No need to protect sroute->setup as this function is called only during the suspend + * callback and all streams should be suspended by then + */ + list_for_each_entry(sroute, &sdev->route_list, list) + sroute->setup = false; +} + /* * Generic object lookup APIs. */ diff --git a/sound/soc/sof/sof-audio.h b/sound/soc/sof/sof-audio.h index 4a1c38c5618d..fe997a80a847 100644 --- a/sound/soc/sof/sof-audio.h +++ b/sound/soc/sof/sof-audio.h @@ -118,6 +118,9 @@ struct snd_sof_route { struct snd_soc_dapm_route *route; struct list_head list; /* list in sdev route list */ + struct snd_sof_widget *src_widget; + struct snd_sof_widget *sink_widget; + bool setup; void *private; }; @@ -240,6 +243,7 @@ int sof_pcm_dai_link_fixup(struct snd_soc_pcm_runtime *rtd, struct snd_pcm_hw_pa /* PM */ int sof_restore_pipelines(struct device *dev); +void sof_tear_down_pipelines(struct device *dev); int sof_set_hw_params_upon_resume(struct device *dev); bool snd_sof_stream_suspend_ignored(struct snd_sof_dev *sdev); bool snd_sof_dsp_only_d0i3_compatible_stream_active(struct snd_sof_dev *sdev); diff --git a/sound/soc/sof/topology.c b/sound/soc/sof/topology.c index 60d1db6a9193..58f966ab2e81 100644 --- a/sound/soc/sof/topology.c +++ b/sound/soc/sof/topology.c @@ -3501,6 +3501,9 @@ static int sof_route_load(struct snd_soc_component *scomp, int index, sroute->route = route; dobj->private = sroute; sroute->private = connect; + sroute->src_widget = source_swidget; + sroute->sink_widget = sink_swidget; + sroute->setup = true; /* add route to route list */ list_add(&sroute->list, &sdev->route_list); From patchwork Thu Sep 16 11:16:41 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: "Daniel Baluta (OSS)" X-Patchwork-Id: 12498733 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,MSGID_FROM_MTA_HEADER,SPF_HELO_NONE,SPF_PASS, USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 311E7C433EF for ; Thu, 16 Sep 2021 11:20:43 +0000 (UTC) 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 mail.kernel.org (Postfix) with ESMTPS id A797460F6D for ; Thu, 16 Sep 2021 11:20:42 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org A797460F6D Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=oss.nxp.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=alsa-project.org Received: from alsa1.perex.cz (alsa1.perex.cz [207.180.221.201]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by alsa0.perex.cz (Postfix) with ESMTPS id 41EC718AB; Thu, 16 Sep 2021 13:19:51 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz 41EC718AB DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1631791241; bh=p0eQnZFTrLARXBAjbtsO+KJY25qNLRMvLKylKhIhSoE=; h=From:To:Subject:Date:In-Reply-To:References:Cc:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=OgZ5uNfm69qTAtw7OPeQJEwhu3PH2Tk3npN79uiEY59CXAIgfcP8AjEMa/kBz2nqM DCDvez0uY53RZYVx61N1Xh4ADlbifeYboo0J7nybwOWb0+nZiIFibPuaCS62JHczpe jaQ5gteIr9Mvc+jDu7WTecr0aqQOWOJtF9Y/j4nk= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id BBD5BF80519; Thu, 16 Sep 2021 13:17:36 +0200 (CEST) Received: by alsa1.perex.cz (Postfix, from userid 50401) id 2B34EF80510; Thu, 16 Sep 2021 13:17:32 +0200 (CEST) Received: from EUR03-VE1-obe.outbound.protection.outlook.com (mail-eopbgr50050.outbound.protection.outlook.com [40.107.5.50]) (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 D05ECF804CA for ; Thu, 16 Sep 2021 13:17:18 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz D05ECF804CA Authentication-Results: alsa1.perex.cz; dkim=pass (1024-bit key) header.d=NXP1.onmicrosoft.com header.i=@NXP1.onmicrosoft.com header.b="lfM6eHzn" ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Tf3ANdliIJGoHmoNpuhD2tQ0eyAGbPEPNT8nbB/zv2v5ZQKK5+V3y6YHz7YsOSzzd4lYmbf/9S/r5+H39D41U+M/98l4rDFki2/N3iw5C6qQKptNY3rAFISeJUQZeJhHn79QivnNJMWF8T5N1Y0vwqATfYDvP/IT7XAK0z4mpP+Ewfipt7H+1G8bOj3NxvSrx030JzZox0kF1+cMiMxELmRmEY1Oee0gOdfWcYUxUClZltgmzw4/T75SW3CAvKxbCeUcDYW4pJ8fJmUVY/tccDEkQuB2u4t9xlPCIdPX+7GyiDxTxVjmuQ6Wi8WaYGpZO4qJ07Q4CP5gg0u4/pqm3g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version; bh=qtCBUgXbw0Jm/D+hAyrYpV07ZReay7t/+4NPNz5XDgA=; b=Oj2VDHXgxTIsbU1ElWGZ4z+z/EXOqOaI6TMaCHBbzbs0jK209UV46l8IITPZ3iiLiFVLyAk1LnOgxLPUozs+tAJoBtPDYbDQnr8ATebwoT4Ij91cmHyBB8yASrFoohabjeJ+tXmYJWP3mb4rLZhUJUd5v1VPjlIxky5pRKr15Px6iZzHad65a0vgOe15UYVUgU1vkkZdE3SS31DRmRPSVMExar52GKzsU4QpirlIrk8yIHy75zQHTb5onwXZEfR3ag0yKxfN8tiliMHAttiEWhYRKS1JIRFStNglsNI5mI7xi8QRD4BuZHuO14Z5wiDrqY6zvopcWUPkeHGDGmSH3g== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=oss.nxp.com; dmarc=pass action=none header.from=oss.nxp.com; dkim=pass header.d=oss.nxp.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=NXP1.onmicrosoft.com; s=selector2-NXP1-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=qtCBUgXbw0Jm/D+hAyrYpV07ZReay7t/+4NPNz5XDgA=; b=lfM6eHznp2F2Y/jKlQFe86Aeh4ZTggjKe6O2XrE1bgTZw5/NoAkEMhgJ/5WEFyH4+9cZJVnEgv8s6+i3k0Wqz/wt5T+DY90Vh2w3E71JUEyHLm2vCLS94laD+tYc3t3gotK5Oo90b2j1FYNMSjVIu3W2h435e2uSmgl/N0J3K8k= Authentication-Results: kernel.org; dkim=none (message not signed) header.d=none;kernel.org; dmarc=none action=none header.from=oss.nxp.com; Received: from VI1PR04MB5151.eurprd04.prod.outlook.com (2603:10a6:803:61::28) by VI1PR04MB4926.eurprd04.prod.outlook.com (2603:10a6:803:51::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4500.18; Thu, 16 Sep 2021 11:17:14 +0000 Received: from VI1PR04MB5151.eurprd04.prod.outlook.com ([fe80::499b:ba92:db2e:3f28]) by VI1PR04MB5151.eurprd04.prod.outlook.com ([fe80::499b:ba92:db2e:3f28%7]) with mapi id 15.20.4500.020; Thu, 16 Sep 2021 11:17:14 +0000 From: Daniel Baluta To: broonie@kernel.org Subject: [PATCH 07/12] ASoC: SOF: restore kcontrols for widget during set up Date: Thu, 16 Sep 2021 14:16:41 +0300 Message-Id: <20210916111646.367133-8-daniel.baluta@oss.nxp.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20210916111646.367133-1-daniel.baluta@oss.nxp.com> References: <20210916111646.367133-1-daniel.baluta@oss.nxp.com> X-ClientProxiedBy: AM0PR04CA0037.eurprd04.prod.outlook.com (2603:10a6:208:1::14) To VI1PR04MB5151.eurprd04.prod.outlook.com (2603:10a6:803:61::28) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from localhost.localdomain (2a02:2f08:5708:8600:b29c:ccfa:a961:8ebd) by AM0PR04CA0037.eurprd04.prod.outlook.com (2603:10a6:208:1::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4523.14 via Frontend Transport; Thu, 16 Sep 2021 11:17:12 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 64e140bc-1185-45da-a63e-08d9790388d1 X-MS-TrafficTypeDiagnostic: VI1PR04MB4926: X-MS-Exchange-SharedMailbox-RoutingAgent-Processed: True X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:669; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 1a8uFkoRfN6aiPGn5ArN6x3TBtYQnVfb7HhlqZfz+XvOVf/+CedljUUF/Ivr1Ya5pksoXXpdO8cMVOJOkT+/sYp8lcFsH4qPyFitMNHq+kUeEy1d64fO0thGf7ITHMEZqiyX+76yaofXCTmW84t4LDNh6iyKhoEbhVFKoMDziSITodEBIO+7i1LzmnIqbpYmbvCBD/CjBZ7k7H+sKRpOjUTz0D2d0OUW/ERyeNzPe7nPDycIMvTWHxsgVK/fbxkRXDyLuj5F5tQQrsbBmjRxkjMI+MwYnYVOA+o8HtOckBvfqS8uFgedRAMaaEYs5TC6qUeG7DDT3qM4j4kJRnObajUu72GvQibtB+473ep9u6+1vjdL5KCxQqfG1ET/vWzOuWnE7QJdQuzEIrYpg6EG3Ytvgd1ABIEZnZGPl4T7rQBijwwGz8+h+sSZYtEKxh0oU2DT1zr6vgcWyvMNtRZ4v47x4l+yXfQCKKjAibc1ksCnGoL+DjP56vwrcSLhbwvQ3C/YuMXqX5zI6IzkP+UCP6IwKaiAJqHIo30+TcjxiFkwPVYfmYBmf2eNwAJvBYrRy9yT81DWjgzDzpZYAW3xkq5K9D2JjzzK8/9UgEsWaxZwlIIs5pTqje02Ij9ON7B3/Q7qtyanchnbmvcJXGEemQ== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:VI1PR04MB5151.eurprd04.prod.outlook.com; PTR:; CAT:NONE; SFS:(4636009)(39860400002)(366004)(136003)(376002)(346002)(396003)(4326008)(8936002)(7416002)(6486002)(186003)(83380400001)(6916009)(2616005)(5660300002)(66946007)(52116002)(478600001)(8676002)(6512007)(6506007)(54906003)(86362001)(2906002)(66574015)(44832011)(66476007)(66556008)(316002)(1076003)(38100700002)(6666004); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?q?5IxGbk15YLT/+3Ck3UH4RRioRwMx?= =?utf-8?q?AnE0mi/GaTxZxemgLOPHu38lzTbXRTh2RZAsawZlQuBXAGtys8GI+bltoLYW7gtAs?= =?utf-8?q?UVabnuxrZMkeaiPj5LZroHdd33VbcCoro+iNLz5AT9YPlph2oDv0GAoVbbvgrLPKo?= =?utf-8?q?R1Fm9C1mPKdO524SWh6toR9guRCNd5AAcKAZyrIAzlaeBe1d6G+eJ+hlRdn3AnT2K?= =?utf-8?q?Mcq+cHtOe74EPFZRIaJFiKFWRq1iWpZbf5p78b/tR/A8vxuk1B4xZr0/VhKraeInd?= =?utf-8?q?dq0b5UqDAmp+l6i3m2BiPm/wRlJZbc9pfRkoFXX32Jd2okCVgDjRxEQJTM+zz6s4y?= =?utf-8?q?UzjTnCmzsW0nAl+8A/qcKXs9PpVD9pLpZ+VFAsQZJkbBFO6XreDqEvmNnO0jah2eq?= =?utf-8?q?/DDNEYjlR3u7kgJsxp/+aw919KwP7iZxn9BY3C6Ico01qGRts9qJBBEQVCh3SjdbC?= =?utf-8?q?dVEn9C60yB1iIv9oTwmAQLE7Ibhg+u4WkVUGAHOCAkDS7qKam7kVrkR5F/pfoms7q?= =?utf-8?q?wMDvlk+1sP7y9XCpEQrfwncHGUXXFzldcx/337am9MeNPW6vSANkvd9urMRs58SnQ?= =?utf-8?q?9PPgHU2cCHCzY+tsGV9wKzRbchNZ8ti62WStW+j9BMGFrhIcGs9c2mDeupyINfgXz?= =?utf-8?q?25P9MXFNK88HbJ79mP1gvD4y/YmShhAYb1X3g9koWBplQW0twuVOQBGw8cj/vX3QK?= =?utf-8?q?QarTkmbSRHJrk6hVVdxjvV6elqhgDxLtCUT9OyGv0qtk8BhyDdz8wfINO/L7K54EI?= =?utf-8?q?bD0uc5y1/o71tho/8rDJ115yNX7tVdlc1ZhrHWh2XGqksmQ73uAtTMzk9Ku0X/RIC?= =?utf-8?q?x5VZMLolhgCcgujkWLEox1hk87LnNQuhpdV1uAS5ko7BcdF8o/i6TCKk36+wR/Rdz?= =?utf-8?q?a4uyPiVoJfrv1uPiFg1E/33qkm7AQ/XNAEGEr+jjrTwc6qH2xA4M91vc+rNBUxW1e?= =?utf-8?q?mbWJ24TA3vOzZjqDeZPJYBVjrd1XbnKN6CQDPCSeaftFKQKZZ3ZJnxjYzwN8G/I16?= =?utf-8?q?Aqujhe+oFwvNppfBsy4GIoiTFqpwbsqau/A8pBMT+CSTXqMR4qCZCRC71gmioqjjO?= =?utf-8?q?dy7w0DCAw9X563jsmtR0GhtlXftit4plbsIchuiRB/lNLvhhtwaJ+tS7oaTwzaIW7?= =?utf-8?q?vTYqH57+yymXaHYIzXtV0cHTRXuXNssHHYHyzUUTTqFSvOSji9sjoNk2WKBgXhx2I?= =?utf-8?q?urgQq0vnII3bFN/kn5OdjX+/ljdTmmRgrCJgiRtKQCn6ThpYqZxdLOWFs2Bu6pRWf?= =?utf-8?q?6R+YsNGcBDIW0Zn+rpwy22p31qihUDy+38UyOF0JkPsGga96WVvdn036iXfkQKdGq?= =?utf-8?q?xeSCBsyZ5yhTdqFy24dXfLtVKzMlqviBGJdQg=3D=3D?= X-OriginatorOrg: oss.nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 64e140bc-1185-45da-a63e-08d9790388d1 X-MS-Exchange-CrossTenant-AuthSource: VI1PR04MB5151.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 16 Sep 2021 11:17:13.9907 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: KN4m427d8OCaSOgH9mmaiFlFh/LEYYMV2CbxA9Eh/xJy2O72sHSQkHjVvv6HVZocOlXJGbvhHdR4ctzCVHe3OA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR04MB4926 Cc: pierre-louis.bossart@linux.intel.com, alsa-devel@alsa-project.org, Seppo Ingalsuo , kai.vehmanen@linux.intel.com, lgirdwood@gmail.com, daniel.baluta@nxp.com, linux-kernel@vger.kernel.org, =?utf-8?q?P=C3=A9ter_Ujfalusi?= , ranjani.sridharan@linux.intel.com, Guennadi Liakhovetski , peter.ujfalusi@linux.intel.com X-BeenThere: alsa-devel@alsa-project.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: "Alsa-devel mailing list for ALSA developers - http://www.alsa-project.org" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: alsa-devel-bounces@alsa-project.org Sender: "Alsa-devel" From: Ranjani Sridharan Restore kcontrols for each widget after it has been set up successfully. Signed-off-by: Ranjani Sridharan Signed-off-by: Kai Vehmanen Reviewed-by: Guennadi Liakhovetski Reviewed-by: Pierre-Louis Bossart Reviewed-by: Péter Ujfalusi Reviewed-by: Seppo Ingalsuo --- sound/soc/sof/sof-audio.c | 59 ++++++++++++++++++++++----------------- 1 file changed, 33 insertions(+), 26 deletions(-) diff --git a/sound/soc/sof/sof-audio.c b/sound/soc/sof/sof-audio.c index b52a453ae9d7..b27760208a4b 100644 --- a/sound/soc/sof/sof-audio.c +++ b/sound/soc/sof/sof-audio.c @@ -64,6 +64,25 @@ static int sof_dai_config_setup(struct snd_sof_dev *sdev, struct snd_sof_dai *da return ret; } +static int sof_widget_kcontrol_setup(struct snd_sof_dev *sdev, struct snd_sof_widget *swidget) +{ + struct snd_sof_control *scontrol; + int ret; + + /* set up all controls for the widget */ + list_for_each_entry(scontrol, &sdev->kcontrol_list, list) + if (scontrol->comp_id == swidget->comp_id) { + ret = sof_kcontrol_setup(sdev, scontrol); + if (ret < 0) { + dev_err(sdev->dev, "error: fail to set up kcontrols for widget %s\n", + swidget->widget->name); + return ret; + } + } + + return 0; +} + static int sof_widget_setup(struct snd_sof_dev *sdev, struct snd_sof_widget *swidget) { struct sof_ipc_pipe_new *pipeline; @@ -113,10 +132,20 @@ static int sof_widget_setup(struct snd_sof_dev *sdev, struct snd_sof_widget *swi &r, sizeof(r)); break; } - if (ret < 0) + if (ret < 0) { dev_err(sdev->dev, "error: failed to load widget %s\n", swidget->widget->name); - else - dev_dbg(sdev->dev, "widget %s setup complete\n", swidget->widget->name); + return ret; + } + + /* restore kcontrols for widget */ + ret = sof_widget_kcontrol_setup(sdev, swidget); + if (ret < 0) { + dev_err(sdev->dev, "error: failed to restore kcontrols for widget %s\n", + swidget->widget->name); + return ret; + } + + dev_dbg(sdev->dev, "widget %s setup complete\n", swidget->widget->name); return ret; } @@ -203,22 +232,6 @@ int sof_set_hw_params_upon_resume(struct device *dev) return snd_sof_dsp_hw_params_upon_resume(sdev); } -static int sof_restore_kcontrols(struct device *dev) -{ - struct snd_sof_dev *sdev = dev_get_drvdata(dev); - struct snd_sof_control *scontrol; - int ret = 0; - - /* restore kcontrol values */ - list_for_each_entry(scontrol, &sdev->kcontrol_list, list) { - ret = sof_kcontrol_setup(sdev, scontrol); - if (ret < 0) - return ret; - } - - return 0; -} - const struct sof_ipc_pipe_new *snd_sof_pipeline_find(struct snd_sof_dev *sdev, int pipeline_id) { @@ -309,13 +322,7 @@ int sof_restore_pipelines(struct device *dev) } } - /* restore pipeline kcontrols */ - ret = sof_restore_kcontrols(dev); - if (ret < 0) - dev_err(dev, - "error: restoring kcontrols after resume\n"); - - return ret; + return 0; } /* This function doesn't free widgets. It only resets the set up status for all routes */ From patchwork Thu Sep 16 11:16:42 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Daniel Baluta (OSS)" X-Patchwork-Id: 12498735 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,MSGID_FROM_MTA_HEADER,SPF_HELO_NONE,SPF_PASS, USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 46E0EC433EF for ; Thu, 16 Sep 2021 11:21:01 +0000 (UTC) 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 mail.kernel.org (Postfix) with ESMTPS id C0FD560F6D for ; Thu, 16 Sep 2021 11:21:00 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org C0FD560F6D Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=oss.nxp.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=alsa-project.org Received: from alsa1.perex.cz (alsa1.perex.cz [207.180.221.201]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by alsa0.perex.cz (Postfix) with ESMTPS id 4F53C18C5; Thu, 16 Sep 2021 13:20:09 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz 4F53C18C5 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1631791259; bh=uE/1IXllWFgdbLRJVDWsBejUGX7lbISyGxqfDzHUw7U=; h=From:To:Subject:Date:In-Reply-To:References:Cc:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=WswvACGN6UK4UpZMbYWSe8eh79IrhnxzO/IP4WkT5VrqVD69kv0tlP1sQVBdv7ppU sYjC9yAhjVMzNzMtIjRPQgyppIQyUxs239+Bk8E1IpzUANba0Km3zpYxWXcqx2aigK 16ZjcibZqZDhvUZrTT2qZqGfUqr/yNocfwL9/WOo= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id 9A91BF8051D; Thu, 16 Sep 2021 13:17:37 +0200 (CEST) Received: by alsa1.perex.cz (Postfix, from userid 50401) id AB288F80271; Thu, 16 Sep 2021 13:17:34 +0200 (CEST) Received: from EUR03-VE1-obe.outbound.protection.outlook.com (mail-eopbgr50058.outbound.protection.outlook.com [40.107.5.58]) (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 5EA0BF80271 for ; Thu, 16 Sep 2021 13:17:19 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz 5EA0BF80271 Authentication-Results: alsa1.perex.cz; dkim=pass (1024-bit key) header.d=NXP1.onmicrosoft.com header.i=@NXP1.onmicrosoft.com header.b="OmH5190D" ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=GPhu6ZGpTTCiUpDN7cbPOPynRZASwoimo2BdjnH1qw3jwtu0BoyOf3M8NADyjSDx4PRudQn6iJVGhR9nmuAjLIf0lNDHzjJOfLs9MPi9VZddQ3EC2lmSW8gyNPAcGqoCNinGDtrIJMVcQXflp7lC8xba6F4OmOgzJZP36eW6/VHTJsoGFFy8bF3hjbe6Szj55ksj2AykN6zMW9nYdihaDURD2JmAfXNPRwadhmz5FcZbpMSVYHH/SYT0Qm8acrWyLydxhcWAgza6QRnstGZnAx2MfXZ047LTcV0WwVMVZ+v+ChFDq9cQQxdy8yywREmOq9hsD1bB9NkHlflHKlyFJA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version; bh=s15B+547NrBh751FmvBNcnKJalu3MwH1IF1VIixTN7U=; b=Ip3yrYnZsZkYqtqoMY2o/eblhyjH4spjAbUCVR9L/FqtVqWxlo3R7D1MtpfOg+2ILbtujy2GIjEEjn5AJHP6XsHRWO5nUTQeeYaPjvrXTeF1Fh8C4ZhqWgCPHl+JQb0VO1axTncPeEsBGAinwypKVtxGPNQxfALl5lecnMj7OM8bLoABn4+0MkI0tM9akAnq93GuCJkZizAbuYtvKJef6wsVrOPdAozqoEgP4durfnQWEKRjYMhlljkClu5rWEZpHO5Xj+jmR79GHjNrIcweKPjysAMkH/hhJelhVIeRfoTz5tUI7ooUtRk2EqUhVENTFxVwPSL6S1rsJgOm3BA5wg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=oss.nxp.com; dmarc=pass action=none header.from=oss.nxp.com; dkim=pass header.d=oss.nxp.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=NXP1.onmicrosoft.com; s=selector2-NXP1-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=s15B+547NrBh751FmvBNcnKJalu3MwH1IF1VIixTN7U=; b=OmH5190DKeat9rGSs9t/U0/iCxMiFv+R7luyV8DOTcb+bQOYoqhKdb5KBs56sJZ2kDR9lOKnqMIqQhmLX5XnE2VYbmssIIZQGpF4V0Afqt+/aJshjmusSJ21kYWuXq0iXOXTyyWADd1at9fFo3N56eXDpERub4D2iGVuliLH1eM= Authentication-Results: kernel.org; dkim=none (message not signed) header.d=none;kernel.org; dmarc=none action=none header.from=oss.nxp.com; Received: from VI1PR04MB5151.eurprd04.prod.outlook.com (2603:10a6:803:61::28) by VI1PR04MB4926.eurprd04.prod.outlook.com (2603:10a6:803:51::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4500.18; Thu, 16 Sep 2021 11:17:15 +0000 Received: from VI1PR04MB5151.eurprd04.prod.outlook.com ([fe80::499b:ba92:db2e:3f28]) by VI1PR04MB5151.eurprd04.prod.outlook.com ([fe80::499b:ba92:db2e:3f28%7]) with mapi id 15.20.4500.020; Thu, 16 Sep 2021 11:17:15 +0000 From: Daniel Baluta To: broonie@kernel.org Subject: [PATCH 08/12] ASoC: SOF: Don't set up widgets during topology parsing Date: Thu, 16 Sep 2021 14:16:42 +0300 Message-Id: <20210916111646.367133-9-daniel.baluta@oss.nxp.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20210916111646.367133-1-daniel.baluta@oss.nxp.com> References: <20210916111646.367133-1-daniel.baluta@oss.nxp.com> X-ClientProxiedBy: AM0PR04CA0037.eurprd04.prod.outlook.com (2603:10a6:208:1::14) To VI1PR04MB5151.eurprd04.prod.outlook.com (2603:10a6:803:61::28) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from localhost.localdomain (2a02:2f08:5708:8600:b29c:ccfa:a961:8ebd) by AM0PR04CA0037.eurprd04.prod.outlook.com (2603:10a6:208:1::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4523.14 via Frontend Transport; Thu, 16 Sep 2021 11:17:14 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 0f246453-70dc-415b-c692-08d9790389ae X-MS-TrafficTypeDiagnostic: VI1PR04MB4926: X-MS-Exchange-SharedMailbox-RoutingAgent-Processed: True X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:546; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: JVpKoXQFlpIHIbluxqNdfgR8TaI96I3gWzPpXIL+xOz2Ur/qvUQbCwTA7aUbwO+S2D/2rUjKtgPg0n33FsEJqvtLvfmgFiInHwt0xoEwoFLUoKR5vgj93xdPqd31jsWPQIbqdvrEl0lV1glrVzsTuwIHuECY2TLndyMAiA7TwkH0c+XA5JXbF5FZUcOaP/j6sK8Uv+qBFGNtNdCsXs5fyGeTIez5K18qAeZ9Q2LScl3TsqvBKqYgUuWAdlNdKhg+5Qmgg7Uxr4GGXBNB4mmM9c/thMpsblbMYrLYKOaiiP9khVjm7KBERr3i8Qvyr5UbbR0cuYYk9/9j5Dc9nNGAUPkTQmiv9SF5uv0qTPopcn/9C8a9HsGnPEdF45pddgqKSXrfQooHgivq9ijDNNQjvlvryzm7jRDUXqOjuji/DePKKZ6tihF/NRSHEhwdXkNTqkZ4K5732wNc9eSIkBGof34QWZ3wJi42i02YGlgX/R1RgGkX5vAi7tuhlOjJnOtX57IIw/ThdlJ13/yFnZ9UKVM9EUiT5wuC0n5imrMfldXitNV1TuCN8GHQYjkI3Y5XYsuZoJdCsu3L4JOHV8+APcZB8eVUiNIAIjv3Iw3LIXVWjpR2uBIvSXoUh2Z10g0taVSBrPzmpEt+3MXaXbkg/g== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:VI1PR04MB5151.eurprd04.prod.outlook.com; PTR:; CAT:NONE; SFS:(4636009)(39860400002)(366004)(136003)(376002)(346002)(396003)(4326008)(8936002)(30864003)(6486002)(186003)(83380400001)(6916009)(2616005)(5660300002)(66946007)(52116002)(478600001)(8676002)(6512007)(6506007)(86362001)(2906002)(44832011)(66476007)(66556008)(316002)(1076003)(38100700002)(6666004); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: az5BqDKRCA/Hlaofftp1qcQtyuVPyC7LapEIFULpz7ZjaNreuFvwNNXeEgzhlDmqwCDsipymXK/nV2y2AbSLSiIAlAtW2eWudG336vL1QNAMs9Rwb6Bf2Eo61ZrmT0vAIV+/FGZTRICOx81NRyRKiUPembfjW1rcIiI22tsbEDY/nc3bK4RgDGA/IXoOIOqkhtPPPChVxflnGAEBQmIoN/cO7a98xqLYBub8fHgddtfvbG3qdKSLYr0oV7Y9uB+UwMXF9uwDt98QjDE58SK+2kZe09FYsKswuXneRXOJLAYn7LNK+kNEpDzoFcxMattmm84uTkV+1+TN24u6Z+LNMeao/fGB/InrpvP/hsSi1oBp5bq3Mbs+tgE99EHwhAkQc4oQZl7xVWlQ5j6Vr2NOgiFWD3Fmpny7TokEj4U0q5Fmns+U2RkmmGfkoDDRUU0/2xI/6MAYOw9VuQ9I9zOByf2/9wvI0LGZRAK6BlkwdemZd2sHGZbxQGJ1pl5CwDO4wtU9IqPds7enSz1PAEVAqyx3jbwDb5YJ1mhUJKB4p7ivS08pjhSTQquF4SyPMRgvbjNWbA2bZmzUvTAeRCE46iqyEk2xQRMtGUOqiGfp0Wj584cUlNrtjtPi/BDDtaOwpz3fo3lFuwruTfLVoR2vH3ofFu9iVXr4hudg2Qx6RHgK3kou75RHo61hXSP0Vbxav/gj4w+SCh1y9VTumNcB4JKJXcNwhQ2lTnWwqjazj2s7ZD4yLEy1heljntFlW6yWhXgRkCf/2R+N8vkwh3lcOHbqvqTV2W+U1wcU40rMVRo7AVcx4bydLNYLNuhze+2b+f9cOZ8XdoRD1Tp/PgnCgHTtb4mBQz/PvJDDsJMvUjZAppuah+6AtXitDhGgrslk4+TY/No/ZEX77BgPnut0PKaVQ4+UxfHN0gCDSbm/HHJ/tuAD8G/PRx95xazCxk8Q9cN6rizXUC1zvo8EW65tYpAHO7DBYzmKymVoe0FYsvwSgVr/vFqPG83xtfn2tlMIjrUdy/8tjmXdk2+H6hPF77UOVSiPBhWtdFf/PfBwDpfZujYrurp+8wqfE31wISgpqdK0VCMC2SK8uzHDbMn1aYFQPE3QKM6e2Ry7ZBO8tvVQvAZKhFhwGPe5a3+t98WJT0S+rEJQ9pxUEkJCVciqhsLYLl9nPnAnDAB8mBLW0HpdpDNJrOcy+afosSyB5kZxXmaPkDdo3ns/Rel6uT1RwqbE2e+Hr4PCqltMl82SEMXr2sjbj3rhWMzi+pwvNjgSpiQu3GCxkYwVedRWBfahH7Uq5d6mbrO3JBy7RQGuwAKwl99hN5Jsiu1lnv7RqHMsEt8pHwY4OHlh5pjf30d77QRXQuFV2F63d2t7XpV7inrtilSsSpRKPL68WDCyczetAbHJLuNxODA7gq8NADkxlA== X-OriginatorOrg: oss.nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 0f246453-70dc-415b-c692-08d9790389ae X-MS-Exchange-CrossTenant-AuthSource: VI1PR04MB5151.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 16 Sep 2021 11:17:15.4079 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: 1UO9sHDcW3DCbf5XZu/wcdegeW0izSHzWFkl+aF6Ji6Pdwpi7xTRrHGczzGATqdWw/fqemDu1GARCzjFiiHmQA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR04MB4926 Cc: pierre-louis.bossart@linux.intel.com, alsa-devel@alsa-project.org, kai.vehmanen@linux.intel.com, lgirdwood@gmail.com, daniel.baluta@nxp.com, linux-kernel@vger.kernel.org, ranjani.sridharan@linux.intel.com, Guennadi Liakhovetski , peter.ujfalusi@linux.intel.com X-BeenThere: alsa-devel@alsa-project.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: "Alsa-devel mailing list for ALSA developers - http://www.alsa-project.org" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: alsa-devel-bounces@alsa-project.org Sender: "Alsa-devel" From: Ranjani Sridharan In preparation for supporting dynamic pipelines, move the widget setup, DAI config IPCs to the complete callback during topology loading. For current topology where all the pipelines are static, all the pipelines will be set up during complete. For topologies with dynamic and static pipelines, this will enable setting up only the static ones during topology loading. Reuse the sof_restore_pipelines() function for this purpose and rename it to sof_set_up_pipelines(). Signed-off-by: Ranjani Sridharan Reviewed-by: Guennadi Liakhovetski Reviewed-by: Pierre-Louis Bossart Reviewed-by: Kai Vehmanen --- sound/soc/sof/pm.c | 2 +- sound/soc/sof/sof-audio.c | 2 +- sound/soc/sof/sof-audio.h | 2 +- sound/soc/sof/topology.c | 282 ++++++-------------------------------- 4 files changed, 43 insertions(+), 245 deletions(-) diff --git a/sound/soc/sof/pm.c b/sound/soc/sof/pm.c index ce922227c4c6..ea27567d2fe4 100644 --- a/sound/soc/sof/pm.c +++ b/sound/soc/sof/pm.c @@ -157,7 +157,7 @@ static int sof_resume(struct device *dev, bool runtime_resume) } /* restore pipelines */ - ret = sof_restore_pipelines(sdev->dev); + ret = sof_set_up_pipelines(sdev->dev); if (ret < 0) { dev_err(sdev->dev, "error: failed to restore pipeline after resume %d\n", diff --git a/sound/soc/sof/sof-audio.c b/sound/soc/sof/sof-audio.c index b27760208a4b..4bed50847f1d 100644 --- a/sound/soc/sof/sof-audio.c +++ b/sound/soc/sof/sof-audio.c @@ -248,7 +248,7 @@ const struct sof_ipc_pipe_new *snd_sof_pipeline_find(struct snd_sof_dev *sdev, return NULL; } -int sof_restore_pipelines(struct device *dev) +int sof_set_up_pipelines(struct device *dev) { struct snd_sof_dev *sdev = dev_get_drvdata(dev); struct snd_sof_widget *swidget; diff --git a/sound/soc/sof/sof-audio.h b/sound/soc/sof/sof-audio.h index fe997a80a847..f1f630028c21 100644 --- a/sound/soc/sof/sof-audio.h +++ b/sound/soc/sof/sof-audio.h @@ -242,7 +242,7 @@ int snd_sof_ipc_set_get_comp_data(struct snd_sof_control *scontrol, int sof_pcm_dai_link_fixup(struct snd_soc_pcm_runtime *rtd, struct snd_pcm_hw_params *params); /* PM */ -int sof_restore_pipelines(struct device *dev); +int sof_set_up_pipelines(struct device *dev); void sof_tear_down_pipelines(struct device *dev); int sof_set_hw_params_upon_resume(struct device *dev); bool snd_sof_stream_suspend_ignored(struct snd_sof_dev *sdev); diff --git a/sound/soc/sof/topology.c b/sound/soc/sof/topology.c index 58f966ab2e81..b996b89f2920 100644 --- a/sound/soc/sof/topology.c +++ b/sound/soc/sof/topology.c @@ -1519,10 +1519,8 @@ static struct sof_ipc_comp *sof_comp_alloc(struct snd_sof_widget *swidget, static int sof_widget_load_dai(struct snd_soc_component *scomp, int index, struct snd_sof_widget *swidget, struct snd_soc_tplg_dapm_widget *tw, - struct sof_ipc_comp_reply *r, struct snd_sof_dai *dai) { - struct snd_sof_dev *sdev = snd_soc_component_get_drvdata(scomp); struct snd_soc_tplg_private *private = &tw->priv; struct sof_ipc_comp_dai *comp_dai; size_t ipc_size = sizeof(*comp_dai); @@ -1559,10 +1557,7 @@ static int sof_widget_load_dai(struct snd_soc_component *scomp, int index, swidget->widget->name, comp_dai->type, comp_dai->dai_index); sof_dbg_comp_config(scomp, &comp_dai->config); - ret = sof_ipc_tx_message(sdev->ipc, comp_dai->comp.hdr.cmd, - comp_dai, ipc_size, r, sizeof(*r)); - - if (ret == 0 && dai) { + if (dai) { dai->scomp = scomp; /* @@ -1584,10 +1579,8 @@ static int sof_widget_load_dai(struct snd_soc_component *scomp, int index, static int sof_widget_load_buffer(struct snd_soc_component *scomp, int index, struct snd_sof_widget *swidget, - struct snd_soc_tplg_dapm_widget *tw, - struct sof_ipc_comp_reply *r) + struct snd_soc_tplg_dapm_widget *tw) { - struct snd_sof_dev *sdev = snd_soc_component_get_drvdata(scomp); struct snd_soc_tplg_private *private = &tw->priv; struct sof_ipc_buffer *buffer; int ret; @@ -1619,15 +1612,7 @@ static int sof_widget_load_buffer(struct snd_soc_component *scomp, int index, swidget->private = buffer; - ret = sof_ipc_tx_message(sdev->ipc, buffer->comp.hdr.cmd, buffer, - sizeof(*buffer), r, sizeof(*r)); - if (ret < 0) { - dev_err(scomp->dev, "error: buffer %s load failed\n", - swidget->widget->name); - kfree(buffer); - } - - return ret; + return 0; } /* bind PCM ID to host component ID */ @@ -1656,10 +1641,8 @@ static int spcm_bind(struct snd_soc_component *scomp, struct snd_sof_pcm *spcm, static int sof_widget_load_pcm(struct snd_soc_component *scomp, int index, struct snd_sof_widget *swidget, enum sof_ipc_stream_direction dir, - struct snd_soc_tplg_dapm_widget *tw, - struct sof_ipc_comp_reply *r) + struct snd_soc_tplg_dapm_widget *tw) { - struct snd_sof_dev *sdev = snd_soc_component_get_drvdata(scomp); struct snd_soc_tplg_private *private = &tw->priv; struct sof_ipc_comp_host *host; size_t ipc_size = sizeof(*host); @@ -1698,10 +1681,7 @@ static int sof_widget_load_pcm(struct snd_soc_component *scomp, int index, swidget->private = host; - ret = sof_ipc_tx_message(sdev->ipc, host->comp.hdr.cmd, host, - ipc_size, r, sizeof(*r)); - if (ret >= 0) - return ret; + return 0; err: kfree(host); return ret; @@ -1730,8 +1710,7 @@ int sof_load_pipeline_ipc(struct device *dev, static int sof_widget_load_pipeline(struct snd_soc_component *scomp, int index, struct snd_sof_widget *swidget, - struct snd_soc_tplg_dapm_widget *tw, - struct sof_ipc_comp_reply *r) + struct snd_soc_tplg_dapm_widget *tw) { struct snd_soc_tplg_private *private = &tw->priv; struct sof_ipc_pipe_new *pipeline; @@ -1786,10 +1765,7 @@ static int sof_widget_load_pipeline(struct snd_soc_component *scomp, int index, swidget->private = pipeline; - /* send ipc's to create pipeline comp and power up schedule core */ - ret = sof_load_pipeline_ipc(scomp->dev, pipeline, r); - if (ret >= 0) - return ret; + return 0; err: kfree(pipeline); return ret; @@ -1801,10 +1777,8 @@ static int sof_widget_load_pipeline(struct snd_soc_component *scomp, int index, static int sof_widget_load_mixer(struct snd_soc_component *scomp, int index, struct snd_sof_widget *swidget, - struct snd_soc_tplg_dapm_widget *tw, - struct sof_ipc_comp_reply *r) + struct snd_soc_tplg_dapm_widget *tw) { - struct snd_sof_dev *sdev = snd_soc_component_get_drvdata(scomp); struct snd_soc_tplg_private *private = &tw->priv; struct sof_ipc_comp_mixer *mixer; size_t ipc_size = sizeof(*mixer); @@ -1833,12 +1807,7 @@ static int sof_widget_load_mixer(struct snd_soc_component *scomp, int index, swidget->private = mixer; - ret = sof_ipc_tx_message(sdev->ipc, mixer->comp.hdr.cmd, mixer, - ipc_size, r, sizeof(*r)); - if (ret < 0) - kfree(mixer); - - return ret; + return 0; } /* @@ -1846,10 +1815,8 @@ static int sof_widget_load_mixer(struct snd_soc_component *scomp, int index, */ static int sof_widget_load_mux(struct snd_soc_component *scomp, int index, struct snd_sof_widget *swidget, - struct snd_soc_tplg_dapm_widget *tw, - struct sof_ipc_comp_reply *r) + struct snd_soc_tplg_dapm_widget *tw) { - struct snd_sof_dev *sdev = snd_soc_component_get_drvdata(scomp); struct snd_soc_tplg_private *private = &tw->priv; struct sof_ipc_comp_mux *mux; size_t ipc_size = sizeof(*mux); @@ -1878,12 +1845,7 @@ static int sof_widget_load_mux(struct snd_soc_component *scomp, int index, swidget->private = mux; - ret = sof_ipc_tx_message(sdev->ipc, mux->comp.hdr.cmd, mux, - ipc_size, r, sizeof(*r)); - if (ret < 0) - kfree(mux); - - return ret; + return 0; } /* @@ -1892,8 +1854,7 @@ static int sof_widget_load_mux(struct snd_soc_component *scomp, int index, static int sof_widget_load_pga(struct snd_soc_component *scomp, int index, struct snd_sof_widget *swidget, - struct snd_soc_tplg_dapm_widget *tw, - struct sof_ipc_comp_reply *r) + struct snd_soc_tplg_dapm_widget *tw) { struct snd_sof_dev *sdev = snd_soc_component_get_drvdata(scomp); struct snd_soc_tplg_private *private = &tw->priv; @@ -1953,10 +1914,7 @@ static int sof_widget_load_pga(struct snd_soc_component *scomp, int index, } } - ret = sof_ipc_tx_message(sdev->ipc, volume->comp.hdr.cmd, volume, - ipc_size, r, sizeof(*r)); - if (ret >= 0) - return ret; + return 0; err: kfree(volume); return ret; @@ -1968,10 +1926,8 @@ static int sof_widget_load_pga(struct snd_soc_component *scomp, int index, static int sof_widget_load_src(struct snd_soc_component *scomp, int index, struct snd_sof_widget *swidget, - struct snd_soc_tplg_dapm_widget *tw, - struct sof_ipc_comp_reply *r) + struct snd_soc_tplg_dapm_widget *tw) { - struct snd_sof_dev *sdev = snd_soc_component_get_drvdata(scomp); struct snd_soc_tplg_private *private = &tw->priv; struct sof_ipc_comp_src *src; size_t ipc_size = sizeof(*src); @@ -2010,10 +1966,7 @@ static int sof_widget_load_src(struct snd_soc_component *scomp, int index, swidget->private = src; - ret = sof_ipc_tx_message(sdev->ipc, src->comp.hdr.cmd, src, - ipc_size, r, sizeof(*r)); - if (ret >= 0) - return ret; + return 0; err: kfree(src); return ret; @@ -2025,10 +1978,8 @@ static int sof_widget_load_src(struct snd_soc_component *scomp, int index, static int sof_widget_load_asrc(struct snd_soc_component *scomp, int index, struct snd_sof_widget *swidget, - struct snd_soc_tplg_dapm_widget *tw, - struct sof_ipc_comp_reply *r) + struct snd_soc_tplg_dapm_widget *tw) { - struct snd_sof_dev *sdev = snd_soc_component_get_drvdata(scomp); struct snd_soc_tplg_private *private = &tw->priv; struct sof_ipc_comp_asrc *asrc; size_t ipc_size = sizeof(*asrc); @@ -2069,10 +2020,7 @@ static int sof_widget_load_asrc(struct snd_soc_component *scomp, int index, swidget->private = asrc; - ret = sof_ipc_tx_message(sdev->ipc, asrc->comp.hdr.cmd, asrc, - ipc_size, r, sizeof(*r)); - if (ret >= 0) - return ret; + return 0; err: kfree(asrc); return ret; @@ -2084,10 +2032,8 @@ static int sof_widget_load_asrc(struct snd_soc_component *scomp, int index, static int sof_widget_load_siggen(struct snd_soc_component *scomp, int index, struct snd_sof_widget *swidget, - struct snd_soc_tplg_dapm_widget *tw, - struct sof_ipc_comp_reply *r) + struct snd_soc_tplg_dapm_widget *tw) { - struct snd_sof_dev *sdev = snd_soc_component_get_drvdata(scomp); struct snd_soc_tplg_private *private = &tw->priv; struct sof_ipc_comp_tone *tone; size_t ipc_size = sizeof(*tone); @@ -2126,10 +2072,7 @@ static int sof_widget_load_siggen(struct snd_soc_component *scomp, int index, swidget->private = tone; - ret = sof_ipc_tx_message(sdev->ipc, tone->comp.hdr.cmd, tone, - ipc_size, r, sizeof(*r)); - if (ret >= 0) - return ret; + return 0; err: kfree(tone); return ret; @@ -2211,10 +2154,8 @@ static int sof_get_control_data(struct snd_soc_component *scomp, static int sof_process_load(struct snd_soc_component *scomp, int index, struct snd_sof_widget *swidget, struct snd_soc_tplg_dapm_widget *tw, - struct sof_ipc_comp_reply *r, int type) { - struct snd_sof_dev *sdev = snd_soc_component_get_drvdata(scomp); struct snd_soc_dapm_widget *widget = swidget->widget; struct snd_soc_tplg_private *private = &tw->priv; struct sof_ipc_comp_process *process; @@ -2288,33 +2229,6 @@ static int sof_process_load(struct snd_soc_component *scomp, int index, process->size = ipc_data_size; swidget->private = process; - - ret = sof_ipc_tx_message(sdev->ipc, process->comp.hdr.cmd, process, - ipc_size, r, sizeof(*r)); - - if (ret < 0) { - dev_err(scomp->dev, "error: create process failed\n"); - goto err; - } - - /* we sent the data in single message so return */ - if (ipc_data_size) - goto out; - - /* send control data with large message supported method */ - for (i = 0; i < widget->num_kcontrols; i++) { - wdata[i].control->readback_offset = 0; - ret = snd_sof_ipc_set_get_comp_data(wdata[i].control, - wdata[i].ipc_cmd, - wdata[i].ctrl_type, - wdata[i].control->cmd, - true); - if (ret != 0) { - dev_err(scomp->dev, "error: send control failed\n"); - break; - } - } - err: if (ret < 0) kfree(process); @@ -2330,8 +2244,7 @@ static int sof_process_load(struct snd_soc_component *scomp, int index, static int sof_widget_load_process(struct snd_soc_component *scomp, int index, struct snd_sof_widget *swidget, - struct snd_soc_tplg_dapm_widget *tw, - struct sof_ipc_comp_reply *r) + struct snd_soc_tplg_dapm_widget *tw) { struct snd_soc_tplg_private *private = &tw->priv; struct sof_ipc_comp_process config; @@ -2357,8 +2270,7 @@ static int sof_widget_load_process(struct snd_soc_component *scomp, int index, } /* now load process specific data and send IPC */ - ret = sof_process_load(scomp, index, swidget, tw, r, - find_process_comp_type(config.type)); + ret = sof_process_load(scomp, index, swidget, tw, find_process_comp_type(config.type)); if (ret < 0) { dev_err(scomp->dev, "error: process loading failed\n"); return ret; @@ -2407,8 +2319,6 @@ static int sof_widget_ready(struct snd_soc_component *scomp, int index, struct snd_sof_dev *sdev = snd_soc_component_get_drvdata(scomp); struct snd_sof_widget *swidget; struct snd_sof_dai *dai; - struct sof_ipc_comp_reply reply; - struct snd_sof_control *scontrol; struct sof_ipc_comp comp = { .core = SOF_DSP_PRIMARY_CORE, }; @@ -2425,7 +2335,6 @@ static int sof_widget_ready(struct snd_soc_component *scomp, int index, swidget->id = w->id; swidget->pipeline_id = index; swidget->private = NULL; - memset(&reply, 0, sizeof(reply)); dev_dbg(scomp->dev, "tplg: ready widget id %d pipe %d type %d name : %s stream %s\n", swidget->comp_id, index, swidget->id, tw->name, @@ -2444,14 +2353,6 @@ static int sof_widget_ready(struct snd_soc_component *scomp, int index, swidget->core = comp.core; - /* default is primary core, safe to call for already enabled cores */ - ret = sof_core_enable(sdev, comp.core); - if (ret < 0) { - dev_err(scomp->dev, "error: enable core: %d\n", ret); - kfree(swidget); - return ret; - } - ret = sof_parse_tokens(scomp, &swidget->comp_ext, comp_ext_tokens, ARRAY_SIZE(comp_ext_tokens), tw->priv.array, le32_to_cpu(tw->priv.size)); @@ -2472,7 +2373,7 @@ static int sof_widget_ready(struct snd_soc_component *scomp, int index, return -ENOMEM; } - ret = sof_widget_load_dai(scomp, index, swidget, tw, &reply, dai); + ret = sof_widget_load_dai(scomp, index, swidget, tw, dai); if (ret == 0) { sof_connect_dai_widget(scomp, w, tw, dai); list_add(&dai->list, &sdev->dai_list); @@ -2482,47 +2383,40 @@ static int sof_widget_ready(struct snd_soc_component *scomp, int index, } break; case snd_soc_dapm_mixer: - ret = sof_widget_load_mixer(scomp, index, swidget, tw, &reply); + ret = sof_widget_load_mixer(scomp, index, swidget, tw); break; case snd_soc_dapm_pga: - ret = sof_widget_load_pga(scomp, index, swidget, tw, &reply); - /* Find scontrol for this pga and set readback offset*/ - list_for_each_entry(scontrol, &sdev->kcontrol_list, list) { - if (scontrol->comp_id == swidget->comp_id) { - scontrol->readback_offset = reply.offset; - break; - } - } + ret = sof_widget_load_pga(scomp, index, swidget, tw); break; case snd_soc_dapm_buffer: - ret = sof_widget_load_buffer(scomp, index, swidget, tw, &reply); + ret = sof_widget_load_buffer(scomp, index, swidget, tw); break; case snd_soc_dapm_scheduler: - ret = sof_widget_load_pipeline(scomp, index, swidget, tw, &reply); + ret = sof_widget_load_pipeline(scomp, index, swidget, tw); break; case snd_soc_dapm_aif_out: ret = sof_widget_load_pcm(scomp, index, swidget, - SOF_IPC_STREAM_CAPTURE, tw, &reply); + SOF_IPC_STREAM_CAPTURE, tw); break; case snd_soc_dapm_aif_in: ret = sof_widget_load_pcm(scomp, index, swidget, - SOF_IPC_STREAM_PLAYBACK, tw, &reply); + SOF_IPC_STREAM_PLAYBACK, tw); break; case snd_soc_dapm_src: - ret = sof_widget_load_src(scomp, index, swidget, tw, &reply); + ret = sof_widget_load_src(scomp, index, swidget, tw); break; case snd_soc_dapm_asrc: - ret = sof_widget_load_asrc(scomp, index, swidget, tw, &reply); + ret = sof_widget_load_asrc(scomp, index, swidget, tw); break; case snd_soc_dapm_siggen: - ret = sof_widget_load_siggen(scomp, index, swidget, tw, &reply); + ret = sof_widget_load_siggen(scomp, index, swidget, tw); break; case snd_soc_dapm_effect: - ret = sof_widget_load_process(scomp, index, swidget, tw, &reply); + ret = sof_widget_load_process(scomp, index, swidget, tw); break; case snd_soc_dapm_mux: case snd_soc_dapm_demux: - ret = sof_widget_load_mux(scomp, index, swidget, tw, &reply); + ret = sof_widget_load_mux(scomp, index, swidget, tw); break; case snd_soc_dapm_switch: case snd_soc_dapm_dai_link: @@ -2533,12 +2427,12 @@ static int sof_widget_ready(struct snd_soc_component *scomp, int index, } /* check IPC reply */ - if (ret < 0 || reply.rhdr.error < 0) { + if (ret < 0) { dev_err(scomp->dev, - "error: DSP failed to add widget id %d type %d name : %s stream %s reply %d\n", + "error: failed to add widget id %d type %d name : %s stream %s\n", tw->shift, swidget->id, tw->name, strnlen(tw->sname, SNDRV_CTL_ELEM_ID_NAME_MAXLEN) > 0 - ? tw->sname : "none", reply.rhdr.error); + ? tw->sname : "none"); kfree(swidget); return ret; } @@ -2844,9 +2738,6 @@ static int sof_set_dai_config_multi(struct snd_sof_dev *sdev, u32 size, continue; if (strcmp(link->name, dai->name) == 0) { - struct sof_ipc_reply reply; - int ret; - /* * the same dai config will be applied to all DAIs in * the same dai link. We have to ensure that the ipc @@ -2858,18 +2749,6 @@ static int sof_set_dai_config_multi(struct snd_sof_dev *sdev, u32 size, dev_dbg(sdev->dev, "set DAI config for %s index %d\n", dai->name, config[curr_conf].dai_index); - /* send message to DSP */ - ret = sof_ipc_tx_message(sdev->ipc, - config[curr_conf].hdr.cmd, - &config[curr_conf], size, - &reply, sizeof(reply)); - - if (ret < 0) { - dev_err(sdev->dev, - "error: failed to set DAI config for %s index %d\n", - dai->name, config[curr_conf].dai_index); - return ret; - } dai->number_configs = num_conf; dai->current_config = curr_conf; @@ -3399,7 +3278,6 @@ static int sof_route_load(struct snd_soc_component *scomp, int index, struct snd_sof_widget *source_swidget, *sink_swidget; struct snd_soc_dobj *dobj = &route->dobj; struct snd_sof_route *sroute; - struct sof_ipc_reply reply; int ret = 0; /* allocate memory for sroute and connect */ @@ -3474,36 +3352,11 @@ static int sof_route_load(struct snd_soc_component *scomp, int index, route->source, route->sink); goto err; } else { - ret = sof_ipc_tx_message(sdev->ipc, - connect->hdr.cmd, - connect, sizeof(*connect), - &reply, sizeof(reply)); - - /* check IPC return value */ - if (ret < 0) { - dev_err(scomp->dev, "error: failed to add route sink %s control %s source %s\n", - route->sink, - route->control ? route->control : "none", - route->source); - goto err; - } - - /* check IPC reply */ - if (reply.error < 0) { - dev_err(scomp->dev, "error: DSP failed to add route sink %s control %s source %s result %d\n", - route->sink, - route->control ? route->control : "none", - route->source, reply.error); - ret = reply.error; - goto err; - } - sroute->route = route; dobj->private = sroute; sroute->private = connect; sroute->src_widget = source_swidget; sroute->sink_widget = sink_swidget; - sroute->setup = true; /* add route to route list */ list_add(&sroute->list, &sdev->route_list); @@ -3517,50 +3370,6 @@ static int sof_route_load(struct snd_soc_component *scomp, int index, return ret; } -/* Function to set the initial value of SOF kcontrols. - * The value will be stored in scontrol->control_data - */ -static int snd_sof_cache_kcontrol_val(struct snd_soc_component *scomp) -{ - struct snd_sof_dev *sdev = snd_soc_component_get_drvdata(scomp); - struct snd_sof_control *scontrol = NULL; - int ipc_cmd, ctrl_type; - int ret = 0; - - list_for_each_entry(scontrol, &sdev->kcontrol_list, list) { - - /* notify DSP of kcontrol values */ - switch (scontrol->cmd) { - case SOF_CTRL_CMD_VOLUME: - case SOF_CTRL_CMD_ENUM: - case SOF_CTRL_CMD_SWITCH: - ipc_cmd = SOF_IPC_COMP_GET_VALUE; - ctrl_type = SOF_CTRL_TYPE_VALUE_CHAN_GET; - break; - case SOF_CTRL_CMD_BINARY: - ipc_cmd = SOF_IPC_COMP_GET_DATA; - ctrl_type = SOF_CTRL_TYPE_DATA_GET; - break; - default: - dev_err(scomp->dev, - "error: Invalid scontrol->cmd: %d\n", - scontrol->cmd); - return -EINVAL; - } - ret = snd_sof_ipc_set_get_comp_data(scontrol, - ipc_cmd, ctrl_type, - scontrol->cmd, - false); - if (ret < 0) { - dev_warn(scomp->dev, - "error: kcontrol value get for widget: %d\n", - scontrol->comp_id); - } - } - - return ret; -} - int snd_sof_complete_pipeline(struct device *dev, struct snd_sof_widget *swidget) { @@ -3626,19 +3435,10 @@ static int sof_complete(struct snd_soc_component *scomp) struct snd_sof_widget *swidget, *comp_swidget; int ret; - /* some widget types require completion notificattion */ + /* set the pipe_widget and apply the dynamic_pipeline_widget_flag */ list_for_each_entry(swidget, &sdev->widget_list, list) { - if (swidget->complete) - continue; - switch (swidget->id) { case snd_soc_dapm_scheduler: - ret = snd_sof_complete_pipeline(scomp->dev, swidget); - if (ret < 0) - return ret; - - swidget->complete = ret; - /* * Apply the dynamic_pipeline_widget flag and set the pipe_widget field * for all widgets that have the same pipeline ID as the scheduler widget @@ -3654,11 +3454,9 @@ static int sof_complete(struct snd_soc_component *scomp) break; } } - /* - * cache initial values of SOF kcontrols by reading DSP value over - * IPC. It may be overwritten by alsa-mixer after booting up - */ - return snd_sof_cache_kcontrol_val(scomp); + + /* set up static pipelines */ + return sof_set_up_pipelines(scomp->dev); } /* manifest - optional to inform component of manifest */ From patchwork Thu Sep 16 11:16:43 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Daniel Baluta (OSS)" X-Patchwork-Id: 12498737 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,MSGID_FROM_MTA_HEADER,SPF_HELO_NONE,SPF_PASS, USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id D0F4DC433EF for ; Thu, 16 Sep 2021 11:21:22 +0000 (UTC) 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 mail.kernel.org (Postfix) with ESMTPS id 30F3A6103B for ; Thu, 16 Sep 2021 11:21:22 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 30F3A6103B Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=oss.nxp.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=alsa-project.org Received: from alsa1.perex.cz (alsa1.perex.cz [207.180.221.201]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by alsa0.perex.cz (Postfix) with ESMTPS id D1C0F18BB; Thu, 16 Sep 2021 13:20:30 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz D1C0F18BB DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1631791280; bh=vGAgxNWqrfK4/j0MTVECMPwvHW43ZfhnaYd9QZrOkg4=; h=From:To:Subject:Date:In-Reply-To:References:Cc:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=o9wshyrYLuFg6pdK6Tv4NKxMpQ4Os80gVqzVvHpqvcRYfXXgyuUyhO0pNVzLzwvrj 5dxrXfPZeD4GRcoceraxqVcd/mnQX99aGfEscHdoPITOQBd0OhQXkr/bF5nPAXBHLo HwwWihLvhu8Q2VmamVlfLQ++XehhlVx9gDm4/SG0= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id 7483EF80524; Thu, 16 Sep 2021 13:17:38 +0200 (CEST) Received: by alsa1.perex.cz (Postfix, from userid 50401) id 5B19FF80518; Thu, 16 Sep 2021 13:17:35 +0200 (CEST) Received: from EUR03-VE1-obe.outbound.protection.outlook.com (mail-eopbgr50050.outbound.protection.outlook.com [40.107.5.50]) (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 F05B5F804E3 for ; Thu, 16 Sep 2021 13:17:19 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz F05B5F804E3 Authentication-Results: alsa1.perex.cz; dkim=pass (1024-bit key) header.d=NXP1.onmicrosoft.com header.i=@NXP1.onmicrosoft.com header.b="BGw6/Lu1" ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=gmornN+6ieDGm5Og1A3qx/lzukNT7tIA6TJdYRHaEk7bSaoNkv6lncxR66r8bpw1LfQ2H9nOozv6Pf6IXRAAqXii71le8/zJLOWzB1ufPMw47ewBeR4j9OZ6K47d5xbtyqkRaQwXLXwyk21Rp2pxmsjsQrbYQW8Le+OV8BZxGbvkDDgHk9tWSwUf3E4vwc9K1Px/oFzXCsSsxNwr2C14z5CQPQFomqMjaaP2c5Uakk5Itc45Ty6trnOlDAWUe8UmdEQJRbMzcnJ8g3QKPjByO4FiPFMPaZyZZE9EjUasJ1AuSFSimmnxNJHLyxQImxGxkO40yefuQ5dUP+qHqMzU8w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version; bh=zKidOw5pr7Z2gD9CecNVZHqnBlv8Y0SLirBrQmqtvag=; b=NYvpNNQgEBfshotsolBXVDEI+ADsg7X5Ze0zQWNKvnza2XhgywE3FdSKaai3iHeYgVtogLiuOAJ389wek1s/X9dmCCrnWLJOo+ey7qwtUh37gW8It8fGnVwX73eleAFaW2eArxcdrX7fzQQEgOvbfHqksABE1RGoNkIzYc2sNwGhTzhrBIGsMdWGVIeJmKxFsTguUclzPN2bYAeIFYzHZ2JL1NtrEyZ34EKn4EwNjy0C/zBeA1f81IoqL6fcg7jcVdCzBJ06JL/jyIaFCkfcvofuhcYoAkQeaLIgLImk0WkxspJUvECZiizgjAYbtSaXBaRKwnre2P5vPj5OmzIg8Q== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=oss.nxp.com; dmarc=pass action=none header.from=oss.nxp.com; dkim=pass header.d=oss.nxp.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=NXP1.onmicrosoft.com; s=selector2-NXP1-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=zKidOw5pr7Z2gD9CecNVZHqnBlv8Y0SLirBrQmqtvag=; b=BGw6/Lu1lYtZnxwkfYrHm7/eYrFfunDvJFqPC7Dp8wdSPHUlqQ5rqbeHrGLv59qAoTO5yzvc95euzd8d6VUxbDV2KkMqf2Nqns18mTTcafeJvztoMLdPPm0I7lkfN4p2yNCigCu61rDdjIlCcgICC9p/RhNqOxv7m7sYQ9xPGk8= Authentication-Results: kernel.org; dkim=none (message not signed) header.d=none;kernel.org; dmarc=none action=none header.from=oss.nxp.com; Received: from VI1PR04MB5151.eurprd04.prod.outlook.com (2603:10a6:803:61::28) by VI1PR04MB4926.eurprd04.prod.outlook.com (2603:10a6:803:51::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4500.18; Thu, 16 Sep 2021 11:17:17 +0000 Received: from VI1PR04MB5151.eurprd04.prod.outlook.com ([fe80::499b:ba92:db2e:3f28]) by VI1PR04MB5151.eurprd04.prod.outlook.com ([fe80::499b:ba92:db2e:3f28%7]) with mapi id 15.20.4500.020; Thu, 16 Sep 2021 11:17:17 +0000 From: Daniel Baluta To: broonie@kernel.org Subject: [PATCH 09/12] ASoC: SOF: Introduce widget use_count Date: Thu, 16 Sep 2021 14:16:43 +0300 Message-Id: <20210916111646.367133-10-daniel.baluta@oss.nxp.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20210916111646.367133-1-daniel.baluta@oss.nxp.com> References: <20210916111646.367133-1-daniel.baluta@oss.nxp.com> X-ClientProxiedBy: AM0PR04CA0037.eurprd04.prod.outlook.com (2603:10a6:208:1::14) To VI1PR04MB5151.eurprd04.prod.outlook.com (2603:10a6:803:61::28) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from localhost.localdomain (2a02:2f08:5708:8600:b29c:ccfa:a961:8ebd) by AM0PR04CA0037.eurprd04.prod.outlook.com (2603:10a6:208:1::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4523.14 via Frontend Transport; Thu, 16 Sep 2021 11:17:15 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 08bf1355-7789-4a9f-5f36-08d979038a9c X-MS-TrafficTypeDiagnostic: VI1PR04MB4926: X-MS-Exchange-SharedMailbox-RoutingAgent-Processed: True X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:3173; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: ku+e7NSe+CwFyS17lLvcLgE+z6opwUi4EZH91vEboislFFIwhbGE2refDi7Vvj99AtKl6qJQwOROT3ZfG2gGyLpmHtQEqtDZHlwnFk5QkFmstaZEVZXnH2mLPEAK/WxfTsLnF4ADOcjDtNbrHbDPFgTnOEqXcfVT1jV8t7S7IZ0G9zIVPi2QPvumhwI3JJ5rBc68kVkniS7Iq5jJR48in6OeGj7POnZ86b/XvcU7Q4G4KtOyp4ZkJVh0Kj8iDSGamfzFOGr8SZzuLK5dd/SBUJlURJHpbg7SNk40F/MEw5GjvpYCaZ9OmAeFFuPInVm/CAgpjEn3sRln2K/J3YCEf/d9iz/f9Wojw1w9/HA1em4+WRKjEQCRGFgGhTYfJh3ZAT42t1KykDXVldjFczkiYT/Un3ricusuxaHhfV9PCAEIJfOw5jDN7MvxPEbf86KadtCzzInF6qSlV8O2HclMUJk/aM1PaZcDZgP7wTbYoDY5JnJraIYS/mBoJatcZggIvx0ZmOFJJyEkhSm1tQCtLIWkzHkM6o3fB29oPEvX4w3GFDDZ3YphaUZvQAk9I4pQz0N1aiZl5bb+FWW2Wd59HFEKgChgDq/Sys8fbWWRm098fWrxeIXtpU175osV1KJvWNrXKCYaH8B5UtNw+BppJg== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:VI1PR04MB5151.eurprd04.prod.outlook.com; PTR:; CAT:NONE; SFS:(4636009)(39860400002)(366004)(136003)(376002)(346002)(396003)(4326008)(8936002)(6486002)(186003)(83380400001)(6916009)(2616005)(5660300002)(66946007)(52116002)(478600001)(8676002)(6512007)(6506007)(86362001)(2906002)(44832011)(66476007)(66556008)(316002)(1076003)(38100700002)(6666004); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: CkH5K2EJ1bWt0tBKxTdS7pe79h8+dNEn5is21Q4z+kaRzEh3xApjGiUb7/n4TgfsKbW9dvtbbwl8acpSJLQ587SHTxk535XXNN5BFDa0VFOSJZD7JY67TJKCj4AWJc3nsXCwAYOHxUZ/k8JfH9dEjTjUl7MuFP66ezTlHF0kQ646rT1syAPQuU0BLPsbI8O55IAonJ4LLpqDdtNPvfASx7fNer7evkdQwtmQR7SPGIEtL5QONdwhlk+TmBWla4l13NNfCsHvaXTHl6xZBVbfvz6plEUgoEPwl2sdhcJESG9i4pej9lwM5UfjFtm3UCcpY2FVRuVSdqhWuVD4+xWfFd4R8LrSb3qkSMv8n02vwqzU9OAtobxLvOID1FzY828FWoprY51dIacXpvTAcpLkpRUkshddwfBCNUalfZuja4W3XnRokJFgMCIdyPIHR7pxwXXXAisX77dmxJDbfUPGDEzWtCIz5CTjtK37D6C/SYL6xv/CwWjAFUanRI3wGMZZMX542mjfMTNteOkVXYXulXjZuR3XmTBVKP6F0MqOcryehD/WnNrAkooZbMT70PYEuRZjRcQbfcLBHi81MpYOgADL5W7DhXJt1VHMDwUkiA8h5l5rPqMkxFoMCPiSbFeKfHR6frdk6bm9txK5W+2PfDy9WWDOQw2oGM8SGJa6hyu07EZSkAzQoYJ2IhdlSWBtp/GsgF1lzQSnb1/UBoVydDc+5BdzZmdjtaFONymT2u1uPiTtFbJHyABiPv1caTI41Gv4/uiQtMRsfpS/DJ1tt3qR8UcqCyghR9UOkYUzIjH2+UoPLwdHOi597Dsi932mMv9d+nBV7ceVMJ/y2MNXDG65Z54H/VZRMFzO0igeS9Xuft2asuoFnVPpVJsqQ8yKflIeXr7HxtmhC6q4oEgAVhKl/WdtzmF1QTAqjj6fHSQUCg3BlE++U+SSq60Ya3WVR7B1ROqkr1ZHyVQnfHY+RIC2+FPF0sM3bFrDzlw2e//KNjFs1Ih0AxCcHbEoXmRKHNQwxcRKYVwJ8uku1AElfB6bK8nrOJk4BtiTb7Z+/Wavyq1HXX4W7l4ilrj39A+OwPvZPoMDxr6hjaIYf6xLwoxZWcmem3I8DvVjb2VpLRFPkeh8Hcq6K0k6agCHp0wUG19e3ejR+SFa4rC0aFfFoBdfmQBIISQx4deIJfIZXAnk8TGUXZQY1toj8a9QV8v/XlCQrgQlPIC8R7dMBh8eXMVZ46T9NoUxvmlRbDTfCNazGJw2RuzWOk8f4V45L/fBmgUC8WT1MfXF95Ft+RBuwEMkKgTz2fXMyEFCXQgItV3zPTvVGvB7Grq3ZoJCZj9CKf4fXqAXYsDjNwMmOkaF9JBjN2BC++Um+/P2KesSJt/pX0BwlepICuk3b0Ib/pPB/lTI6HdhMj1gaoUOt0bzhg== X-OriginatorOrg: oss.nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 08bf1355-7789-4a9f-5f36-08d979038a9c X-MS-Exchange-CrossTenant-AuthSource: VI1PR04MB5151.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 16 Sep 2021 11:17:16.8551 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: 4M33SwcJYp8OxiUIpLTh/dGXJ9gG5ge9vR3yfmdCZy0+EDfGnyD3h4i0Lrr+3rskJay5Mn614VEsCxDusSnkSA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR04MB4926 Cc: pierre-louis.bossart@linux.intel.com, alsa-devel@alsa-project.org, kai.vehmanen@linux.intel.com, lgirdwood@gmail.com, daniel.baluta@nxp.com, linux-kernel@vger.kernel.org, ranjani.sridharan@linux.intel.com, Guennadi Liakhovetski , peter.ujfalusi@linux.intel.com X-BeenThere: alsa-devel@alsa-project.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: "Alsa-devel mailing list for ALSA developers - http://www.alsa-project.org" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: alsa-devel-bounces@alsa-project.org Sender: "Alsa-devel" From: Ranjani Sridharan Add a new field, use_count to struct snd_sof_widget to keep track of the usage count for each widget. Since widgets can belong to multiple pipelines, this field will ensure that the widget is setup only when the first pipeline that needs it is started and freed when the last pipeline that needs it is stopped. There is no need to protect the widget use_count access as the core already handles mutual exclusion at the PCM level. Add a new helper sof_widget_free() to handle freeing the SOF widgets and export the sof_widget_setup/free() functions. Signed-off-by: Ranjani Sridharan Reviewed-by: Guennadi Liakhovetski Reviewed-by: Pierre-Louis Bossart Reviewed-by: Kai Vehmanen --- sound/soc/sof/ipc.c | 22 +++++++++++ sound/soc/sof/sof-audio.c | 77 ++++++++++++++++++++++++++++++++++++--- sound/soc/sof/sof-audio.h | 4 ++ 3 files changed, 97 insertions(+), 6 deletions(-) diff --git a/sound/soc/sof/ipc.c b/sound/soc/sof/ipc.c index 18e0bfc1d8a9..33c94c7a5913 100644 --- a/sound/soc/sof/ipc.c +++ b/sound/soc/sof/ipc.c @@ -700,9 +700,31 @@ int snd_sof_ipc_set_get_comp_data(struct snd_sof_control *scontrol, struct sof_ipc_fw_ready *ready = &sdev->fw_ready; struct sof_ipc_fw_version *v = &ready->version; struct sof_ipc_ctrl_data_params sparams; + struct snd_sof_widget *swidget; + bool widget_found = false; size_t send_bytes; int err; + list_for_each_entry(swidget, &sdev->widget_list, list) { + if (swidget->comp_id == scontrol->comp_id) { + widget_found = true; + break; + } + } + + if (!widget_found) { + dev_err(sdev->dev, "error: can't find widget with id %d\n", scontrol->comp_id); + return -EINVAL; + } + + /* + * Volatile controls should always be part of static pipelines and the widget use_count + * would always be > 0 in this case. For the others, just return the cached value if the + * widget is not set up. + */ + if (!swidget->use_count) + return 0; + /* read or write firmware volume */ if (scontrol->readback_offset != 0) { /* write/read value header via mmaped region */ diff --git a/sound/soc/sof/sof-audio.c b/sound/soc/sof/sof-audio.c index 4bed50847f1d..7a4aaabf091e 100644 --- a/sound/soc/sof/sof-audio.c +++ b/sound/soc/sof/sof-audio.c @@ -83,7 +83,53 @@ static int sof_widget_kcontrol_setup(struct snd_sof_dev *sdev, struct snd_sof_wi return 0; } -static int sof_widget_setup(struct snd_sof_dev *sdev, struct snd_sof_widget *swidget) +int sof_widget_free(struct snd_sof_dev *sdev, struct snd_sof_widget *swidget) +{ + struct sof_ipc_free ipc_free = { + .hdr = { + .size = sizeof(ipc_free), + .cmd = SOF_IPC_GLB_TPLG_MSG, + }, + .id = swidget->comp_id, + }; + struct sof_ipc_reply reply; + int ret; + + if (!swidget->private) + return 0; + + /* only free when use_count is 0 */ + if (--swidget->use_count) + return 0; + + switch (swidget->id) { + case snd_soc_dapm_scheduler: + ipc_free.hdr.cmd |= SOF_IPC_TPLG_PIPE_FREE; + break; + case snd_soc_dapm_buffer: + ipc_free.hdr.cmd |= SOF_IPC_TPLG_BUFFER_FREE; + break; + default: + ipc_free.hdr.cmd |= SOF_IPC_TPLG_COMP_FREE; + break; + } + + ret = sof_ipc_tx_message(sdev->ipc, ipc_free.hdr.cmd, &ipc_free, sizeof(ipc_free), + &reply, sizeof(reply)); + if (ret < 0) { + dev_err(sdev->dev, "error: failed to free widget %s\n", swidget->widget->name); + swidget->use_count++; + return ret; + } + + swidget->complete = 0; + dev_dbg(sdev->dev, "widget %s freed\n", swidget->widget->name); + + return 0; +} +EXPORT_SYMBOL(sof_widget_free); + +int sof_widget_setup(struct snd_sof_dev *sdev, struct snd_sof_widget *swidget) { struct sof_ipc_pipe_new *pipeline; struct sof_ipc_comp_reply r; @@ -97,11 +143,15 @@ static int sof_widget_setup(struct snd_sof_dev *sdev, struct snd_sof_widget *swi if (!swidget->private) return 0; + /* widget already set up */ + if (++swidget->use_count > 1) + return 0; + ret = sof_pipeline_core_enable(sdev, swidget); if (ret < 0) { dev_err(sdev->dev, "error: failed to enable target core: %d for widget %s\n", ret, swidget->widget->name); - return ret; + goto use_count_dec; } switch (swidget->id) { @@ -134,7 +184,7 @@ static int sof_widget_setup(struct snd_sof_dev *sdev, struct snd_sof_widget *swi } if (ret < 0) { dev_err(sdev->dev, "error: failed to load widget %s\n", swidget->widget->name); - return ret; + goto use_count_dec; } /* restore kcontrols for widget */ @@ -147,8 +197,13 @@ static int sof_widget_setup(struct snd_sof_dev *sdev, struct snd_sof_widget *swi dev_dbg(sdev->dev, "widget %s setup complete\n", swidget->widget->name); + return 0; + +use_count_dec: + swidget->use_count--; return ret; } +EXPORT_SYMBOL(sof_widget_setup); /* * helper to determine if there are only D0i3 compatible @@ -258,6 +313,9 @@ int sof_set_up_pipelines(struct device *dev) /* restore pipeline components */ list_for_each_entry_reverse(swidget, &sdev->widget_list, list) { + /* reset widget use_count after resuming */ + swidget->use_count = 0; + ret = sof_widget_setup(sdev, swidget); if (ret < 0) return ret; @@ -325,16 +383,23 @@ int sof_set_up_pipelines(struct device *dev) return 0; } -/* This function doesn't free widgets. It only resets the set up status for all routes */ +/* + * This function doesn't free widgets. It only resets the set up status for all routes and + * use_count for all widgets. + */ void sof_tear_down_pipelines(struct device *dev) { struct snd_sof_dev *sdev = dev_get_drvdata(dev); + struct snd_sof_widget *swidget; struct snd_sof_route *sroute; /* - * No need to protect sroute->setup as this function is called only during the suspend - * callback and all streams should be suspended by then + * No need to protect swidget->use_count and sroute->setup as this function is called only + * during the suspend callback and all streams should be suspended by then */ + list_for_each_entry(swidget, &sdev->widget_list, list) + swidget->use_count = 0; + list_for_each_entry(sroute, &sdev->route_list, list) sroute->setup = false; } diff --git a/sound/soc/sof/sof-audio.h b/sound/soc/sof/sof-audio.h index f1f630028c21..6ac623137026 100644 --- a/sound/soc/sof/sof-audio.h +++ b/sound/soc/sof/sof-audio.h @@ -89,6 +89,7 @@ struct snd_sof_widget { int comp_id; int pipeline_id; int complete; + int use_count; /* use_count will be protected by the PCM mutex held by the core */ int core; int id; @@ -252,4 +253,7 @@ bool snd_sof_dsp_only_d0i3_compatible_stream_active(struct snd_sof_dev *sdev); int sof_machine_register(struct snd_sof_dev *sdev, void *pdata); void sof_machine_unregister(struct snd_sof_dev *sdev, void *pdata); +int sof_widget_setup(struct snd_sof_dev *sdev, struct snd_sof_widget *swidget); +int sof_widget_free(struct snd_sof_dev *sdev, struct snd_sof_widget *swidget); + #endif From patchwork Thu Sep 16 11:16:44 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Daniel Baluta (OSS)" X-Patchwork-Id: 12498741 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,MSGID_FROM_MTA_HEADER,SPF_HELO_NONE,SPF_PASS, USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 5E11BC433EF for ; Thu, 16 Sep 2021 11:22:21 +0000 (UTC) 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 mail.kernel.org (Postfix) with ESMTPS id DE6D861130 for ; Thu, 16 Sep 2021 11:22:20 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org DE6D861130 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=oss.nxp.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=alsa-project.org Received: from alsa1.perex.cz (alsa1.perex.cz [207.180.221.201]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by alsa0.perex.cz (Postfix) with ESMTPS id 81C8718CE; Thu, 16 Sep 2021 13:21:29 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz 81C8718CE DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1631791339; bh=0lbl+0a/EZ+s0FiBUHXD16bXJ4a/DB5tzTZEeRM6fws=; h=From:To:Subject:Date:In-Reply-To:References:Cc:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=dOxMfFwovBqYR8uv/2bDTNTTHA3vk+d+y9qaQEpCjYFGjoupo4xZBe5e/DDPN6r+4 3H0/3rW3YzMiVy3IrBZCJkAgughQJR58kIlGaLmznzX0cmtRjHIpXv1bJ8acBko9Xx WW0X4makve/SXL4pR30dXFz2DzLKQTl3Jj+Ybt5o= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id 59319F80549; Thu, 16 Sep 2021 13:17:44 +0200 (CEST) Received: by alsa1.perex.cz (Postfix, from userid 50401) id 36EEAF804E4; Thu, 16 Sep 2021 13:17:40 +0200 (CEST) Received: from EUR03-VE1-obe.outbound.protection.outlook.com (mail-eopbgr50058.outbound.protection.outlook.com [40.107.5.58]) (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 8E606F8025E for ; Thu, 16 Sep 2021 13:17:20 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz 8E606F8025E Authentication-Results: alsa1.perex.cz; dkim=pass (1024-bit key) header.d=NXP1.onmicrosoft.com header.i=@NXP1.onmicrosoft.com header.b="MzxxExJe" ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=BWxIrj5IY5LdeGPGtlvZnjYyRRHyEppwpcF7caENIUzc9O0iWKQNBN5Gb3+hWQT7Er7P0WkvyfmwckbMV9HeKZkE28QvtmxVl5DlEO5bBbY7N7KcffV1QLrMLIS2IXc5RiSFzdgpl+Wo69I6m5HHiHttWslH3gpvYhL7fX0vsjZob9FLnttBE/UeKLPGOqiaw38TKLdGxE3Mzq+ua4c3esXrBrNO2cysNaQoy7qSx/KfIX49Cl6VI8rXl3d/l9gxw/xUaVYUqoe60XmWztfF3c/RKGsUlAoDnizUBr7HZudkHv1ab2Bj6tFHztN/6/09abwahOrjf1KX447fE+bBCg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version; bh=WGTu4FC1Vty5d47glpMeaHEc8IYgxJcBUeCdzK0LeLE=; b=L5kNG8AX3COa5aHoPwaZGY48S4JJrATra0YdoTYa6ir1ic/I3tL708fRX+gTlX2HVXwlGHjOAnZcRo647LP/zedX0/QKzm475rdw1tQLvnp4aZrHd6W90pKskkBAYxN1hgEtyvacd6NEWfStQ+1VJ10eOiPM6RUTAdeFwV+wwps+Zz4I27BZ8J730NX6F+Z2OUtj3UBdxSfpDrXNiwOprGI2lWgzbDDHkXyZWv2U0WPon+HySflG6Qb2tTMI5/2mLnFKSQY0w7541H0B/UepQVjLBgdGDBPJzieoj6otYY1zQ4UtT4ihc0w/GDZ3GTzKt8+x7irKK2/7rsKDbeRf1g== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=oss.nxp.com; dmarc=pass action=none header.from=oss.nxp.com; dkim=pass header.d=oss.nxp.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=NXP1.onmicrosoft.com; s=selector2-NXP1-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=WGTu4FC1Vty5d47glpMeaHEc8IYgxJcBUeCdzK0LeLE=; b=MzxxExJenAE2MafxzrWjX0ow3AsciMB4mscgi6EqPPUHvg1ZQsYFy5X2sqKtHps/tzM/pt+9Bf3T8N6GBoxF61PHiGp5Rxe1MzDZQcVrs0zzAl7/9NVhEntaJfHyU70o8DrDaTY//LZ8W611NIKkshnBlBMnEfcjF0CN8EUfMdQ= Authentication-Results: kernel.org; dkim=none (message not signed) header.d=none;kernel.org; dmarc=none action=none header.from=oss.nxp.com; Received: from VI1PR04MB5151.eurprd04.prod.outlook.com (2603:10a6:803:61::28) by VI1PR04MB4926.eurprd04.prod.outlook.com (2603:10a6:803:51::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4500.18; Thu, 16 Sep 2021 11:17:18 +0000 Received: from VI1PR04MB5151.eurprd04.prod.outlook.com ([fe80::499b:ba92:db2e:3f28]) by VI1PR04MB5151.eurprd04.prod.outlook.com ([fe80::499b:ba92:db2e:3f28%7]) with mapi id 15.20.4500.020; Thu, 16 Sep 2021 11:17:18 +0000 From: Daniel Baluta To: broonie@kernel.org Subject: [PATCH 10/12] ASoC: SOF: Intel: hda: make sure DAI widget is set up before IPC Date: Thu, 16 Sep 2021 14:16:44 +0300 Message-Id: <20210916111646.367133-11-daniel.baluta@oss.nxp.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20210916111646.367133-1-daniel.baluta@oss.nxp.com> References: <20210916111646.367133-1-daniel.baluta@oss.nxp.com> X-ClientProxiedBy: AM0PR04CA0037.eurprd04.prod.outlook.com (2603:10a6:208:1::14) To VI1PR04MB5151.eurprd04.prod.outlook.com (2603:10a6:803:61::28) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from localhost.localdomain (2a02:2f08:5708:8600:b29c:ccfa:a961:8ebd) by AM0PR04CA0037.eurprd04.prod.outlook.com (2603:10a6:208:1::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4523.14 via Frontend Transport; Thu, 16 Sep 2021 11:17:17 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 136bcf5b-b0ba-4f59-e919-08d979038b64 X-MS-TrafficTypeDiagnostic: VI1PR04MB4926: X-MS-Exchange-SharedMailbox-RoutingAgent-Processed: True X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:208; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: xPzkglONUtzi13XVHDb4cV1Jbbl/tnIEVjJjT0VgZHtTIF4pN51AUMbj1lH0w2McT67+bYtyavptd5f4IqQI6dPY8OY6V9dKsyAXtImh0BgRbfY4IjrchsG+m2g0THRc8J9BxYuppiu/nSL5NEhF9pU9F+YQLmGbWNnUOSeqn0QPnFBtwWhwuxHwicL+xLWPRZ/y/iLPtK3Gzh736SmOOdhoKO2tczZ6cAoAR8ToiKiePsHuLqZU+LixFlKA/5UsWNJaGaxt6W6CRaSdVjmW9hCA+NaHqvmEdxyWe95sczfv8cQjrl8EpVQIwdN3O5bAWiNMq+DHTMHh/SdfkA/ObStTPbdPR01R9m1dtDSypeuBpQ96tGkSV9K8Z39HYXkRI6sU2uuJRYgVBk4DgwO6IdC9v3Pu+G2sdvyZDOXBichHgFBWDOZAlxk81vLhvEVUeovBSbFvLvBOgtOau/ROrdj+Uejn2/9A5T1g67T/UUw+FaMxTdddLYco9p7Z9h/VsoQq/vJyF7khZcrGHicsQbGbwGQbYt2GzeyAziTNe4/JmK+T9NtrqSKsQlzgtRKf0pRELq7Ai5JzGnJb4n5JgqCQ0B6At7RQ/cyCQl9cB+DujU8AKNM/Zdc3uG42Z7J+TC2KJTJ4KuJsI7OVQDCX+g== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:VI1PR04MB5151.eurprd04.prod.outlook.com; PTR:; CAT:NONE; SFS:(4636009)(39860400002)(366004)(136003)(376002)(346002)(396003)(4326008)(8936002)(30864003)(6486002)(186003)(83380400001)(6916009)(2616005)(5660300002)(66946007)(52116002)(478600001)(8676002)(6512007)(6506007)(86362001)(2906002)(44832011)(66476007)(66556008)(316002)(1076003)(38100700002)(6666004); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: lg1sA3AIlCUtpAr3M46Y/dl6TzOD/g8vWVGoiozkWEPomxp4iwt/LN5+AxFLSjNsGrCeqiVa2i4EsJfdEvV9/bM/WExYb1vrvGsekWr/50tSglhEXN6e7EABhTU8qXHrLSJdZN/zqibo0TEvKraye3Ee4DGZiQihukEjDBE9qackr6cN4vNhfsIZ2IMtVRRBre5L2L26/1K/vjDZcBTIo/7avvv5y+K3Nv7t6ClDbcoX7ZXQMbL9k02HHp4BdZmKpJY9rfp+zLdo6UutM0jOBnlks1+1qK8/BSGTzvPIYDBF/rUhuXuUpST+W/PKBK3KPxuUNosyuXfxF8JChhdfYJXd1cPm5KR9o+nJ+mN4oS0QAteY/7ayp2cIa1HEfGwVu49EqTGJxIQ83fLaZBbJIeTflGbe/A2uP+7ci0O3gS2FVBw8QH5fPqo7e/AafwJncfd1Z4yQrPbAy2wZUHf9cyEv8SIg7SMMIbsyapYRSMYdetOYs3bLFQPfk9+Lfe/kG1udDsqeJkGxzuiMIuO3/IHF9xeR4EuCT3YO0p9LA1gP3Gzb9r0i6gCM3D2Wn/phNSqqE1ADGwAhbUA2CMDKSYPE142J69gOwqd6ZzuTqRqoBbdcQ9wLfzRFQpct4b6ZpvMhMEDAkyVHAyUQFy588+awKBDWY43BaUsGKZaI4ruOzEVMS36ZLfR3lbrA4dt/O1T9PIgPGd3yuhXP+xhozI/sDOT6xXAh9a5W6Jp9n1ScX+t6Ny134qMr24+ku/eKZAdSvhG689gGaLW00n7QwHdKkdMQtXWDw8vtp1Yrz0gYfu+h3JnNfKgTDok25W4JzrRLj0NpPHBe94ftHcmvTmmzBKV1DdUD+pCZah1L5SHMPeeyU9GNSXLzRgoHIuPpv8hAxLeQwjVNfqBS/CDhRcPDD+PkrPKxr5b8f53hudBiiHrwR2q9m8y0gWm670f0Tz6oZoeYg8vVUNTgeBMTzGiNHs71L8xRoDA+LgsMaqQvtby3rdC8zN2bjGUeaZ0JARRbLQZW5s8O0/dbU73YSvhto+uq8WIlu+tkmRSU0l1VPdBLt2Mbf59pIqmSj2Sw4Z7eB2JS3uUAwWlY4/dKcTvdazpT1JIV9tzorpoXB2FzNCrGAB24n0kJ2gHGPEta+i964coZGl6GNvkro82Qrx2K9a252Xd8nl95jrOLlLXM5D0rjfkcJL2et8TR+voAuk0tPe/XC9MiLyYmIjRMnxIHS91CQRfUFXlT6k5sCjNrMyKkkHqTQ14G3r7so8iclr0Xifhx5Pg+imEjya/TDlAwa43NryiYj868dR5TUcVqN5FPVEAn8j6dpnl4jaRcPklAuX/Imy+yjgKJ6sp9Fi0kaGknJLHD1mc0qDbfnp1m2+SFAZG3B7rhM8frCc4m4ICjcK4TzfXreQ6D8McAiQ== X-OriginatorOrg: oss.nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 136bcf5b-b0ba-4f59-e919-08d979038b64 X-MS-Exchange-CrossTenant-AuthSource: VI1PR04MB5151.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 16 Sep 2021 11:17:18.2093 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: j6hQMkFgwS0knvQ0em+tcWy3XMBplcBFGM3lcVC1ishdBbM6O53YWy/0wZt9LR7R+jcHsHf6JjLg4SguD4+Ojw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR04MB4926 Cc: pierre-louis.bossart@linux.intel.com, alsa-devel@alsa-project.org, kai.vehmanen@linux.intel.com, lgirdwood@gmail.com, daniel.baluta@nxp.com, linux-kernel@vger.kernel.org, ranjani.sridharan@linux.intel.com, Guennadi Liakhovetski , peter.ujfalusi@linux.intel.com X-BeenThere: alsa-devel@alsa-project.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: "Alsa-devel mailing list for ALSA developers - http://www.alsa-project.org" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: alsa-devel-bounces@alsa-project.org Sender: "Alsa-devel" From: Ranjani Sridharan With the implementation of the dynamic pipeline feature, widgets will only be setup when a PCM is opened during the hw_params ioctl. The BE hw_params callback is responsible for sending the DAI_CONFIG for the DAI widgets in the DSP. With dynamic pipelines, the DAI widgets will need to set up first before sending the DAI_CONFIG IPC in the BE hw_params. Update the BE hw_params/hw_free callbacks for all ALH, HDA and SSP DAIs to set up/free the DAI widget before/after DAI_CONFIG IPC. Signed-off-by: Ranjani Sridharan Reviewed-by: Guennadi Liakhovetski Reviewed-by: Pierre-Louis Bossart Reviewed-by: Kai Vehmanen --- sound/soc/sof/intel/hda-dai.c | 176 ++++++++++++++++++++------------- sound/soc/sof/intel/hda.c | 177 +++++++++++++++++++++++++--------- sound/soc/sof/intel/hda.h | 5 + sound/soc/sof/sof-audio.c | 1 + sound/soc/sof/sof-audio.h | 2 +- sound/soc/sof/topology.c | 3 - 6 files changed, 245 insertions(+), 119 deletions(-) diff --git a/sound/soc/sof/intel/hda-dai.c b/sound/soc/sof/intel/hda-dai.c index c1f9f0f58464..fb1b429cc451 100644 --- a/sound/soc/sof/intel/hda-dai.c +++ b/sound/soc/sof/intel/hda-dai.c @@ -151,49 +151,70 @@ static int hda_link_dma_params(struct hdac_ext_stream *stream, return 0; } -/* Send DAI_CONFIG IPC to the DAI that matches the dai_name and direction */ -static int hda_link_config_ipc(struct sof_intel_hda_stream *hda_stream, - const char *dai_name, int channel, int dir) +/* Update config for the DAI widget */ +static struct sof_ipc_dai_config *hda_dai_update_config(struct snd_soc_dapm_widget *w, + int channel) { + struct snd_sof_widget *swidget = w->dobj.private; struct sof_ipc_dai_config *config; struct snd_sof_dai *sof_dai; - struct sof_ipc_reply reply; - int ret = 0; - list_for_each_entry(sof_dai, &hda_stream->sdev->dai_list, list) { - if (!sof_dai->cpu_dai_name) - continue; + if (!swidget) { + dev_err(swidget->scomp->dev, "error: No private data for widget %s\n", w->name); + return NULL; + } - if (!strcmp(dai_name, sof_dai->cpu_dai_name) && - dir == sof_dai->comp_dai.direction) { - config = sof_dai->dai_config; + sof_dai = swidget->private; - if (!config) { - dev_err(hda_stream->sdev->dev, - "error: no config for DAI %s\n", - sof_dai->name); - return -EINVAL; - } + if (!sof_dai || !sof_dai->dai_config) { + dev_err(swidget->scomp->dev, "error: No config for DAI %s\n", w->name); + return NULL; + } - /* update config with stream tag */ - config->hda.link_dma_ch = channel; + config = &sof_dai->dai_config[sof_dai->current_config]; - /* send IPC */ - ret = sof_ipc_tx_message(hda_stream->sdev->ipc, - config->hdr.cmd, - config, - config->hdr.size, - &reply, sizeof(reply)); + /* update config with stream tag */ + config->hda.link_dma_ch = channel; - if (ret < 0) - dev_err(hda_stream->sdev->dev, - "error: failed to set dai config for %s\n", - sof_dai->name); - return ret; - } + return config; +} + +static int hda_link_config_ipc(struct sof_intel_hda_stream *hda_stream, + struct snd_soc_dapm_widget *w, int channel) +{ + struct snd_sof_dev *sdev = hda_stream->sdev; + struct sof_ipc_dai_config *config; + struct sof_ipc_reply reply; + + config = hda_dai_update_config(w, channel); + if (!config) { + dev_err(sdev->dev, "error: no config for DAI %s\n", w->name); + return -ENOENT; + } + + /* send DAI_CONFIG IPC */ + return sof_ipc_tx_message(sdev->ipc, config->hdr.cmd, config, config->hdr.size, + &reply, sizeof(reply)); +} + +static int hda_link_dai_widget_update(struct sof_intel_hda_stream *hda_stream, + struct snd_soc_dapm_widget *w, + int channel, bool widget_setup) +{ + struct snd_sof_dev *sdev = hda_stream->sdev; + struct sof_ipc_dai_config *config; + + config = hda_dai_update_config(w, channel); + if (!config) { + dev_err(sdev->dev, "error: no config for DAI %s\n", w->name); + return -ENOENT; } - return -EINVAL; + /* set up/free DAI widget and send DAI_CONFIG IPC */ + if (widget_setup) + return hda_ctrl_dai_widget_setup(w); + + return hda_ctrl_dai_widget_free(w); } static int hda_link_hw_params(struct snd_pcm_substream *substream, @@ -207,6 +228,7 @@ static int hda_link_hw_params(struct snd_pcm_substream *substream, struct snd_soc_dai *codec_dai = asoc_rtd_to_codec(rtd, 0); struct sof_intel_hda_stream *hda_stream; struct hda_pipe_params p_params = {0}; + struct snd_soc_dapm_widget *w; struct hdac_ext_link *link; int stream_tag; int ret; @@ -225,9 +247,13 @@ static int hda_link_hw_params(struct snd_pcm_substream *substream, hda_stream = hstream_to_sof_hda_stream(link_dev); - /* update the DSP with the new tag */ - ret = hda_link_config_ipc(hda_stream, dai->name, stream_tag - 1, - substream->stream); + if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) + w = dai->playback_widget; + else + w = dai->capture_widget; + + /* set up the DAI widget and send the DAI_CONFIG with the new tag */ + ret = hda_link_dai_widget_update(hda_stream, w, stream_tag - 1, true); if (ret < 0) return ret; @@ -283,6 +309,7 @@ static int hda_link_pcm_trigger(struct snd_pcm_substream *substream, snd_soc_dai_get_dma_data(dai, substream); struct sof_intel_hda_stream *hda_stream; struct snd_soc_pcm_runtime *rtd; + struct snd_soc_dapm_widget *w; struct hdac_ext_link *link; struct hdac_stream *hstream; struct hdac_bus *bus; @@ -317,12 +344,16 @@ static int hda_link_pcm_trigger(struct snd_pcm_substream *substream, break; case SNDRV_PCM_TRIGGER_SUSPEND: case SNDRV_PCM_TRIGGER_STOP: + if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) + w = dai->playback_widget; + else + w = dai->capture_widget; + /* * clear link DMA channel. It will be assigned when * hw_params is set up again after resume. */ - ret = hda_link_config_ipc(hda_stream, dai->name, - DMA_CHAN_INVALID, substream->stream); + ret = hda_link_config_ipc(hda_stream, w, DMA_CHAN_INVALID); if (ret < 0) return ret; @@ -353,6 +384,7 @@ static int hda_link_hw_free(struct snd_pcm_substream *substream, struct hdac_stream *hstream; struct snd_soc_pcm_runtime *rtd; struct hdac_ext_stream *link_dev; + struct snd_soc_dapm_widget *w; int ret; hstream = substream->runtime->private_data; @@ -368,9 +400,13 @@ static int hda_link_hw_free(struct snd_pcm_substream *substream, hda_stream = hstream_to_sof_hda_stream(link_dev); - /* free the link DMA channel in the FW */ - ret = hda_link_config_ipc(hda_stream, dai->name, DMA_CHAN_INVALID, - substream->stream); + if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) + w = dai->playback_widget; + else + w = dai->capture_widget; + + /* free the link DMA channel in the FW and the DAI widget */ + ret = hda_link_dai_widget_update(hda_stream, w, DMA_CHAN_INVALID, false); if (ret < 0) return ret; @@ -414,47 +450,51 @@ static struct snd_soc_cdai_ops sof_probe_compr_ops = { #endif #endif -static int ssp_dai_hw_params(struct snd_pcm_substream *substream, - struct snd_pcm_hw_params *params, - struct snd_soc_dai *dai) +static int ssp_dai_setup_or_free(struct snd_pcm_substream *substream, struct snd_soc_dai *dai, + bool setup) { - struct snd_soc_pcm_runtime *rtd = asoc_substream_to_rtd(substream); - struct snd_soc_component *component = snd_soc_rtdcom_lookup(rtd, SOF_AUDIO_PCM_DRV_NAME); - struct snd_sof_dev *sdev = snd_soc_component_get_drvdata(component); - struct sof_ipc_fw_version *v = &sdev->fw_ready.version; - struct sof_ipc_dai_config *config; - struct snd_sof_dai *sof_dai; - struct sof_ipc_reply reply; - int ret; + struct snd_soc_component *component; + struct snd_sof_widget *swidget; + struct snd_soc_dapm_widget *w; + struct sof_ipc_fw_version *v; + struct snd_sof_dev *sdev; + + if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) + w = dai->playback_widget; + else + w = dai->capture_widget; + + swidget = w->dobj.private; + component = swidget->scomp; + sdev = snd_soc_component_get_drvdata(component); + v = &sdev->fw_ready.version; /* DAI_CONFIG IPC during hw_params is not supported in older firmware */ if (v->abi_version < SOF_ABI_VER(3, 18, 0)) return 0; - list_for_each_entry(sof_dai, &sdev->dai_list, list) { - if (!sof_dai->cpu_dai_name || !sof_dai->dai_config) - continue; - - if (!strcmp(dai->name, sof_dai->cpu_dai_name) && - substream->stream == sof_dai->comp_dai.direction) { - config = &sof_dai->dai_config[sof_dai->current_config]; + if (setup) + return hda_ctrl_dai_widget_setup(w); - /* send IPC */ - ret = sof_ipc_tx_message(sdev->ipc, config->hdr.cmd, config, - config->hdr.size, &reply, sizeof(reply)); + return hda_ctrl_dai_widget_free(w); +} - if (ret < 0) - dev_err(sdev->dev, "error: failed to set DAI config for %s\n", - sof_dai->name); - return ret; - } - } +static int ssp_dai_hw_params(struct snd_pcm_substream *substream, + struct snd_pcm_hw_params *params, + struct snd_soc_dai *dai) +{ + return ssp_dai_setup_or_free(substream, dai, true); +} - return 0; +static int ssp_dai_hw_free(struct snd_pcm_substream *substream, + struct snd_soc_dai *dai) +{ + return ssp_dai_setup_or_free(substream, dai, false); } static const struct snd_soc_dai_ops ssp_dai_ops = { .hw_params = ssp_dai_hw_params, + .hw_free = ssp_dai_hw_free, }; /* diff --git a/sound/soc/sof/intel/hda.c b/sound/soc/sof/intel/hda.c index c11e4c14d875..93305d389ff6 100644 --- a/sound/soc/sof/intel/hda.c +++ b/sound/soc/sof/intel/hda.c @@ -52,6 +52,86 @@ static const struct sof_intel_dsp_desc return chip_info; } +int hda_ctrl_dai_widget_setup(struct snd_soc_dapm_widget *w) +{ + struct snd_sof_widget *swidget = w->dobj.private; + struct snd_soc_component *component = swidget->scomp; + struct snd_sof_dev *sdev = snd_soc_component_get_drvdata(component); + struct sof_ipc_dai_config *config; + struct snd_sof_dai *sof_dai; + struct sof_ipc_reply reply; + int ret; + + sof_dai = swidget->private; + + if (!sof_dai || !sof_dai->dai_config) { + dev_err(sdev->dev, "No config for DAI %s\n", w->name); + return -EINVAL; + } + + config = &sof_dai->dai_config[sof_dai->current_config]; + + /* + * For static pipelines, the DAI widget would already be set up and calling + * sof_widget_setup() simply returns without doing anything. + * For dynamic pipelines, the DAI widget will be set up now. + */ + ret = sof_widget_setup(sdev, swidget); + if (ret < 0) { + dev_err(sdev->dev, "error: failed setting up DAI widget %s\n", w->name); + return ret; + } + + /* send DAI_CONFIG IPC */ + ret = sof_ipc_tx_message(sdev->ipc, config->hdr.cmd, config, config->hdr.size, + &reply, sizeof(reply)); + if (ret < 0) { + dev_err(sdev->dev, "error: failed setting DAI config for %s\n", w->name); + return ret; + } + + sof_dai->configured = true; + + return 0; +} + +int hda_ctrl_dai_widget_free(struct snd_soc_dapm_widget *w) +{ + struct snd_sof_widget *swidget = w->dobj.private; + struct snd_soc_component *component = swidget->scomp; + struct snd_sof_dev *sdev = snd_soc_component_get_drvdata(component); + struct sof_ipc_dai_config *config; + struct snd_sof_dai *sof_dai; + struct sof_ipc_reply reply; + int ret; + + sof_dai = swidget->private; + + if (!sof_dai || !sof_dai->dai_config) { + dev_err(sdev->dev, "error: No config to free DAI %s\n", w->name); + return -EINVAL; + } + + /* nothing to do if hw_free() is called without restarting the stream after resume. */ + if (!sof_dai->configured) + return 0; + + config = &sof_dai->dai_config[sof_dai->current_config]; + + ret = sof_ipc_tx_message(sdev->ipc, config->hdr.cmd, config, config->hdr.size, + &reply, sizeof(reply)); + if (ret < 0) + dev_err(sdev->dev, "error: failed resetting DAI config for %s\n", w->name); + + /* + * Reset the configured_flag and free the widget even if the IPC fails to keep + * the widget use_count balanced + */ + sof_dai->configured = false; + + return sof_widget_free(sdev, swidget); +} + #if IS_ENABLED(CONFIG_SND_SOC_SOF_INTEL_SOUNDWIRE) /* @@ -64,67 +144,70 @@ static int sdw_clock_stop_quirks = SDW_INTEL_CLK_STOP_BUS_RESET; module_param(sdw_clock_stop_quirks, int, 0444); MODULE_PARM_DESC(sdw_clock_stop_quirks, "SOF SoundWire clock stop quirks"); +static int sdw_dai_config_ipc(struct snd_sof_dev *sdev, + struct snd_soc_dapm_widget *w, + int link_id, int alh_stream_id, int dai_id, bool setup) +{ + struct snd_sof_widget *swidget = w->dobj.private; + struct sof_ipc_dai_config *config; + struct snd_sof_dai *sof_dai; + + if (!swidget) { + dev_err(sdev->dev, "error: No private data for widget %s\n", w->name); + return -EINVAL; + } + + sof_dai = swidget->private; + + if (!sof_dai || !sof_dai->dai_config) { + dev_err(sdev->dev, "error: No config for DAI %s\n", w->name); + return -EINVAL; + } + + config = &sof_dai->dai_config[sof_dai->current_config]; + + /* update config with link and stream ID */ + config->dai_index = (link_id << 8) | dai_id; + config->alh.stream_id = alh_stream_id; + + if (setup) + return hda_ctrl_dai_widget_setup(w); + + return hda_ctrl_dai_widget_free(w); +} + static int sdw_params_stream(struct device *dev, struct sdw_intel_stream_params_data *params_data) { + struct snd_pcm_substream *substream = params_data->substream; struct snd_sof_dev *sdev = dev_get_drvdata(dev); struct snd_soc_dai *d = params_data->dai; - struct sof_ipc_dai_config config; - struct sof_ipc_reply reply; - int link_id = params_data->link_id; - int alh_stream_id = params_data->alh_stream_id; - int ret; - u32 size = sizeof(config); - - memset(&config, 0, size); - config.hdr.size = size; - config.hdr.cmd = SOF_IPC_GLB_DAI_MSG | SOF_IPC_DAI_CONFIG; - config.type = SOF_DAI_INTEL_ALH; - config.dai_index = (link_id << 8) | (d->id); - config.alh.stream_id = alh_stream_id; - - /* send message to DSP */ - ret = sof_ipc_tx_message(sdev->ipc, - config.hdr.cmd, &config, size, &reply, - sizeof(reply)); - if (ret < 0) { - dev_err(sdev->dev, - "error: failed to set DAI hw_params for link %d dai->id %d ALH %d\n", - link_id, d->id, alh_stream_id); - } + struct snd_soc_dapm_widget *w; - return ret; + if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) + w = d->playback_widget; + else + w = d->capture_widget; + + return sdw_dai_config_ipc(sdev, w, params_data->link_id, params_data->alh_stream_id, + d->id, true); } static int sdw_free_stream(struct device *dev, struct sdw_intel_stream_free_data *free_data) { + struct snd_pcm_substream *substream = free_data->substream; struct snd_sof_dev *sdev = dev_get_drvdata(dev); struct snd_soc_dai *d = free_data->dai; - struct sof_ipc_dai_config config; - struct sof_ipc_reply reply; - int link_id = free_data->link_id; - int ret; - u32 size = sizeof(config); - - memset(&config, 0, size); - config.hdr.size = size; - config.hdr.cmd = SOF_IPC_GLB_DAI_MSG | SOF_IPC_DAI_CONFIG; - config.type = SOF_DAI_INTEL_ALH; - config.dai_index = (link_id << 8) | d->id; - config.alh.stream_id = 0xFFFF; /* invalid value on purpose */ - - /* send message to DSP */ - ret = sof_ipc_tx_message(sdev->ipc, - config.hdr.cmd, &config, size, &reply, - sizeof(reply)); - if (ret < 0) { - dev_err(sdev->dev, - "error: failed to free stream for link %d dai->id %d\n", - link_id, d->id); - } + struct snd_soc_dapm_widget *w; - return ret; + if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) + w = d->playback_widget; + else + w = d->capture_widget; + + /* send invalid stream_id */ + return sdw_dai_config_ipc(sdev, w, free_data->link_id, 0xFFFF, d->id, false); } static const struct sdw_intel_ops sdw_callback = { diff --git a/sound/soc/sof/intel/hda.h b/sound/soc/sof/intel/hda.h index 087fa06d5210..9da8ba0ed38d 100644 --- a/sound/soc/sof/intel/hda.h +++ b/sound/soc/sof/intel/hda.h @@ -733,4 +733,9 @@ void hda_set_mach_params(const struct snd_soc_acpi_mach *mach, /* PCI driver selection and probe */ int hda_pci_intel_probe(struct pci_dev *pci, const struct pci_device_id *pci_id); +struct snd_sof_dai; +struct sof_ipc_dai_config; +int hda_ctrl_dai_widget_setup(struct snd_soc_dapm_widget *w); +int hda_ctrl_dai_widget_free(struct snd_soc_dapm_widget *w); + #endif diff --git a/sound/soc/sof/sof-audio.c b/sound/soc/sof/sof-audio.c index 7a4aaabf091e..bf5e7c7019a5 100644 --- a/sound/soc/sof/sof-audio.c +++ b/sound/soc/sof/sof-audio.c @@ -163,6 +163,7 @@ int sof_widget_setup(struct snd_sof_dev *sdev, struct snd_sof_widget *swidget) return -ENOMEM; dai = swidget->private; + dai->configured = false; memcpy(comp, &dai->comp_dai, sizeof(struct sof_ipc_comp_dai)); /* append extended data to the end of the component */ diff --git a/sound/soc/sof/sof-audio.h b/sound/soc/sof/sof-audio.h index 6ac623137026..d358d455da1e 100644 --- a/sound/soc/sof/sof-audio.h +++ b/sound/soc/sof/sof-audio.h @@ -130,11 +130,11 @@ struct snd_sof_route { struct snd_sof_dai { struct snd_soc_component *scomp; const char *name; - const char *cpu_dai_name; struct sof_ipc_comp_dai comp_dai; int number_configs; int current_config; + bool configured; /* DAI configured during BE hw_params */ struct sof_ipc_dai_config *dai_config; struct list_head list; /* list in sdev dai list */ }; diff --git a/sound/soc/sof/topology.c b/sound/soc/sof/topology.c index b996b89f2920..d8eb238e5229 100644 --- a/sound/soc/sof/topology.c +++ b/sound/soc/sof/topology.c @@ -2756,9 +2756,6 @@ static int sof_set_dai_config_multi(struct snd_sof_dev *sdev, u32 size, if (!dai->dai_config) return -ENOMEM; - /* set cpu_dai_name */ - dai->cpu_dai_name = link->cpus->dai_name; - found = 1; } } From patchwork Thu Sep 16 11:16:45 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Daniel Baluta (OSS)" X-Patchwork-Id: 12498743 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,MSGID_FROM_MTA_HEADER,SPF_HELO_NONE,SPF_PASS, USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id AEEF6C433F5 for ; Thu, 16 Sep 2021 11:22:54 +0000 (UTC) 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 mail.kernel.org (Postfix) with ESMTPS id 30F6061185 for ; Thu, 16 Sep 2021 11:22:54 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 30F6061185 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=oss.nxp.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=alsa-project.org Received: from alsa1.perex.cz (alsa1.perex.cz [207.180.221.201]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by alsa0.perex.cz (Postfix) with ESMTPS id BDB3A18C6; Thu, 16 Sep 2021 13:22:02 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz BDB3A18C6 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1631791372; bh=qmp+2SNFBh+NhKWrZlGOGRZOcKRpiTVSKT1XAUEpdKQ=; h=From:To:Subject:Date:In-Reply-To:References:Cc:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=Z7Gduzd3sidXv6P54lfO74qmikYeFpJLQ/KF4H10u+bZrPmBE9fpGgdAcep9akPiR CaC9sj9D28pInVWTw8MpSOPLoqRtYagQe9J573wOpQNZaxFpQDgNv9EWOqQ2rD182g Mw11d1U48lobBhFDnsnRLakGTcIY/623gekwz9YQ= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id AB471F80558; Thu, 16 Sep 2021 13:17:47 +0200 (CEST) Received: by alsa1.perex.cz (Postfix, from userid 50401) id 4D7D6F8025E; Thu, 16 Sep 2021 13:17:40 +0200 (CEST) Received: from EUR03-VE1-obe.outbound.protection.outlook.com (mail-eopbgr50050.outbound.protection.outlook.com [40.107.5.50]) (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 1E168F804E4 for ; Thu, 16 Sep 2021 13:17:21 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz 1E168F804E4 Authentication-Results: alsa1.perex.cz; dkim=pass (1024-bit key) header.d=NXP1.onmicrosoft.com header.i=@NXP1.onmicrosoft.com header.b="iums5hms" ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=fh8ATRMslnwmtWHKRnwueIX2mQQGy1vPMHJNXOQEBKbWn2gFaTRo9iJJ8qZbcHfcIQjvce9E/mzleENJfTR0GnwvwbztWNgfI2YVXvti8TVvX2E/8SFTMEakUqfb2MOECBG8KEA4gHps8Z5F39wI6aDqpVRgSQZdnQB/kl6ht6NcizSgAV1PX+pBAg0YOxyOXers9+zcgy5+yjRKg6nqWrmaXVnqsrC26jMmo33UgPiGXqUwJTYxUhgyxO2TQ2+InnmC58l4FXJzX0/kag/oV2bklLBSetqW/tsisZRIwHb5LlvDgeW6216ybGkjlkUrBH4w/vKZveTv/0zN0JEQFg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version; bh=er7ZIhstytlbr4Fw+vwvxX46adHmT5K1Mclwb2FDIsI=; b=iPSeFXutwP0kSv7SZaxLTMVwoW2Ldy75kQq1duMxcPVw5917cGdRYJKmji1Ul2G9QWS1J89jLScKqJa/T9lv1/NPClDcQahWsUFs+j3oqbvqusa0PJLCUT/5FhbG/crPjFF4ZcQuyxujalHpJGOstDh1wjy7QUkJ4+lKK9K+BtBWpJJCe3264+saMs4j/gAEz5d+ATOPbIXAo8om7XvFLHzJ0gNIYmJwY+E+1b3XOP5M999YmR2XDFXKiLIWy/ORMi+pfAMnm8Gb/Dgm9wti3hpCHHU9FQW+cBa/Z9h8w5dU1zst2nNszgq/vyYrBB6/xs926IKgzRMZrEQ+UD66IQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=oss.nxp.com; dmarc=pass action=none header.from=oss.nxp.com; dkim=pass header.d=oss.nxp.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=NXP1.onmicrosoft.com; s=selector2-NXP1-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=er7ZIhstytlbr4Fw+vwvxX46adHmT5K1Mclwb2FDIsI=; b=iums5hmsccn3M6Em6zFgt4mVU7AlIOzrCop7JSmzW8KYDHKCvTIHqcCeY2s6uxZ+/O2DulcvRsvg5xfw64C+KYFjf04kS/6YQsPwu4jB0w2baWVWRdYon5Reo8aMsLsZOc4IBMx8G+nBhJF9KLRQ02L+2A9t98wPxvfJ9uoycKU= Authentication-Results: kernel.org; dkim=none (message not signed) header.d=none;kernel.org; dmarc=none action=none header.from=oss.nxp.com; Received: from VI1PR04MB5151.eurprd04.prod.outlook.com (2603:10a6:803:61::28) by VI1PR04MB4926.eurprd04.prod.outlook.com (2603:10a6:803:51::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4500.18; Thu, 16 Sep 2021 11:17:19 +0000 Received: from VI1PR04MB5151.eurprd04.prod.outlook.com ([fe80::499b:ba92:db2e:3f28]) by VI1PR04MB5151.eurprd04.prod.outlook.com ([fe80::499b:ba92:db2e:3f28%7]) with mapi id 15.20.4500.020; Thu, 16 Sep 2021 11:17:19 +0000 From: Daniel Baluta To: broonie@kernel.org Subject: [PATCH 11/12] ASoC: SOF: Add support for dynamic pipelines Date: Thu, 16 Sep 2021 14:16:45 +0300 Message-Id: <20210916111646.367133-12-daniel.baluta@oss.nxp.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20210916111646.367133-1-daniel.baluta@oss.nxp.com> References: <20210916111646.367133-1-daniel.baluta@oss.nxp.com> X-ClientProxiedBy: AM0PR04CA0037.eurprd04.prod.outlook.com (2603:10a6:208:1::14) To VI1PR04MB5151.eurprd04.prod.outlook.com (2603:10a6:803:61::28) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from localhost.localdomain (2a02:2f08:5708:8600:b29c:ccfa:a961:8ebd) by AM0PR04CA0037.eurprd04.prod.outlook.com (2603:10a6:208:1::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4523.14 via Frontend Transport; Thu, 16 Sep 2021 11:17:18 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 8bf17b06-1653-4ecd-7fca-08d979038c30 X-MS-TrafficTypeDiagnostic: VI1PR04MB4926: X-MS-Exchange-SharedMailbox-RoutingAgent-Processed: True X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:1824; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: uy8cyl+bpYMSjebxpZGLASSWc4KlaOBjxM0EjOyWFxXO1aqMcqBoInUS5onRrCAY1Qg0glIGJd+M0daeEVq/abJ8iSs3iMSA0MeCd3TSh4fqP86qqgTafCwSwXXIxa68tftielboMGNwqJZWPN2DWr7CLRkEDo7XLUtsJ864zI/HGKa0oNf22IPO6LZNh+cOIHEE+GDZx1sjMmHHnER/jJb1kLaKazJRVmmWJtADxlETyi4LAzxx5PAvdSe1boJkyVnS3ZdDcVj/RWUILRxDqjBjLjYWkl4QKAfzj8lyDb/eBFjzi3lmtDUIF40Woojwfn1epkvYFI+QJBn8utkxLt1OWFCisREIjuHQn63iZR4fnRprCM0Uw3flwoiYM0zgC+PeB3lrbvNfCDNHDT7kHEZ2TIE3oyuI/MQUSN36sDAOEoA4PFvbS0ogdLsyivN7S3kAg/ruFq0kOgDGGJGLQ+GpxJ8mac9CYMglBKKTLu5ip7KZo9CYJQuR5whZjOjQc3iYOaSKxQg6W/UmbjeQUcaKJZAUzCN3QKwhzfv8r90EdCdSs1Y8RQOg/dOxoRORTgUCuFepzhSh+BmwAHr2ay8RqaTb4nRGp9KpXwKl/RW7/QV928+HHYsKZ9nvIXKb673bb4OX95oxh2amraiy+g== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:VI1PR04MB5151.eurprd04.prod.outlook.com; PTR:; CAT:NONE; SFS:(4636009)(39860400002)(366004)(136003)(376002)(346002)(396003)(4326008)(8936002)(30864003)(6486002)(186003)(83380400001)(6916009)(2616005)(5660300002)(66946007)(52116002)(478600001)(8676002)(6512007)(6506007)(86362001)(2906002)(44832011)(66476007)(66556008)(316002)(1076003)(38100700002)(6666004); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: ts8UP2j2623592gAvj9tcUCcZ/YrPiAuG15rcCuGOikvjgjTVycX9bF3/1aZNIZAfpTVYlq6pgm0bEMMqyYZqwZXAANwvcb8BT24iTRqMrSdg94i/QAghauvh/FdlyJfz4vK3tCJgBwf0e1tyIfeRXj+B703QVuM1ZRARdk7WyCrUu094cNzx2dgSLv4oJ0o+5pampRmvndtEeBM3T/lZhGK5a1eupd7X9sIM2BzBTm5pvM3tdwO3OO1gpOhJ1kgA19QD9coMk2I1IvYQDCXuTp/7dXfTXQadVT8IMV0jaUNx8kmtQDfs/MAhPgobU099H0VUDS7OpoxCPOaSRFjgD0XLhuuC0a5ZX8jGno9hJc/qqQAw30/FXj03bmQ5ozHMLATlulqvX4+xWLAqaQLEfXjAt5a9qQ2bAuvL6ErJjhVP5tcuovkBBrp1E2D+PhKuXKOQrEeQILYVFwN8UPBCnQZCCVO6AWnTNVUrSSQnMAUEAD9kEJimkAnEYJMERBUoeLLW3JR+1hVpWrLI1iIyKthXm6KAEhbVa7S1qTs7BsvzijZSHQno5O2ZnlAhXXt/t1a3iu5bEtUEM2c6EdH1z+uEHODGj1n4iSVn+7wOceUK/yLS7PQEQNayOQ/We9Zxar5z9iEeEjL0vc22xvBsjMavbMb2GqxJsZPpkGf8evyuy0r/NbwlsqJ4IiftFxywiOJFDDjVf9PJVb+4CAiikKVoJKC3RH1JBlAHOXOZz1nlypNOoCLcs3VQh7PMCfzOfEX4iXPxdH5/gU3KQ0UBKc5veaImCRvRaRX26xYbGWVYHEPHyjsobe4rCEUCZgE0t1ipa1YyZw+Rnu+Qj3JQSPugmp0nIpppAZPJSv48CnXgAa81H8qy3XqafNuB5qJ3V/Ch8KplFAONT1Cb1WuMnU5Ya9M4fyCtTNFBp5UmPSEbFpLUQ4LEwXIVoLwkBqLK6e39DkHht0tpkc8/vWbZCf5NrenKVj8zjY3l417QKK+Mt+5GHl+6ks5NyAjjElsfpQK0kMu7b0PclZy9mtd9ibjjtg/pBeHjMFpRkI4JdEjwMsXGGyxLNAeqxS+KEldZSptWAUBSf3cAt4XVHZkaDzdzdYWPWoKP/kZc5z08pgJ+Y5O5V59TIo9C5YIL1p3ly2VsapYLTWnF8pdi7aKb83f+Za8E6/s9qOuBQYZxNxUndv3/opKPWZF0m5odphub4pMzjVl8GUh6HwlC7TOBYtQe65KIRxECFivd0YNqzr0cGQv/NloZ3hjY+MFxiXi7FJv1AGar37R7lKkyl+Hs96ctQKMn0bbZHYg5tHeUYJJAmOM2/5guWX8cYHuZEuLEIhAXB9PDw01/Pq0nC9jCRxfZDL0llxiVS9/FCSCKJ+f41xcOY++NbtCXiJbM+8AX7d0zB7IHQSYId/bDE1rzw== X-OriginatorOrg: oss.nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 8bf17b06-1653-4ecd-7fca-08d979038c30 X-MS-Exchange-CrossTenant-AuthSource: VI1PR04MB5151.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 16 Sep 2021 11:17:19.5106 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: Ml0oUwwiBnf7gUJJgWXvTM4xGD7xY/WJGUqmY59oI/uWG+pWvUL9rLg27L0gpU6wRWuA1wIrG9AemtAzfu5j2g== X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR04MB4926 Cc: pierre-louis.bossart@linux.intel.com, alsa-devel@alsa-project.org, kai.vehmanen@linux.intel.com, lgirdwood@gmail.com, daniel.baluta@nxp.com, linux-kernel@vger.kernel.org, ranjani.sridharan@linux.intel.com, Guennadi Liakhovetski , peter.ujfalusi@linux.intel.com X-BeenThere: alsa-devel@alsa-project.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: "Alsa-devel mailing list for ALSA developers - http://www.alsa-project.org" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: alsa-devel-bounces@alsa-project.org Sender: "Alsa-devel" From: Ranjani Sridharan Add support for dynamic pipelines by modifying the PCM hw_params ioctl implementation to determine the widgets required for a PCM stream by querying the list of connected DAPM widgets. This list is saved as part of snd_sof_pcm_stream struct and will be used to setup the widgets. The sof_widget_list_setup/free routines setup and free connected DAPM widgets when a PCM is opened/closed. These routines accept a list of connected DAPM widgets as input and determine the SOF widgets, their corresponding pipeline widgets and connections between them that need to be setup before the PCM is triggered. Please note that the dynamic pipeline feature will only be enabled for those pipelines whose dynamic_pipeline_widget flag is set in topologies. Add a new token called SOF_TKN_SCHED_DYNAMIC_PIPELINE that when set in topology will be applied to the dynamic_pipeline_widget flag of the pipeline widget. Signed-off-by: Ranjani Sridharan Reviewed-by: Guennadi Liakhovetski Reviewed-by: Pierre-Louis Bossart Reviewed-by: Kai Vehmanen --- sound/soc/sof/intel/hda.c | 22 +-- sound/soc/sof/pcm.c | 58 +++++- sound/soc/sof/sof-audio.c | 358 +++++++++++++++++++++++++++++++++----- sound/soc/sof/sof-audio.h | 6 + 4 files changed, 390 insertions(+), 54 deletions(-) diff --git a/sound/soc/sof/intel/hda.c b/sound/soc/sof/intel/hda.c index 93305d389ff6..c0bdc5c36043 100644 --- a/sound/soc/sof/intel/hda.c +++ b/sound/soc/sof/intel/hda.c @@ -41,17 +41,6 @@ #define EXCEPT_MAX_HDR_SIZE 0x400 #define HDA_EXT_ROM_STATUS_SIZE 8 -static const struct sof_intel_dsp_desc - *get_chip_info(struct snd_sof_pdata *pdata) -{ - const struct sof_dev_desc *desc = pdata->desc; - const struct sof_intel_dsp_desc *chip_info; - - chip_info = desc->chip_info; - - return chip_info; -} - int hda_ctrl_dai_widget_setup(struct snd_soc_dapm_widget *w) { struct snd_sof_widget *swidget = w->dobj.private; @@ -132,6 +121,17 @@ int hda_ctrl_dai_widget_free(struct snd_soc_dapm_widget *w) return sof_widget_free(sdev, swidget); } +static const struct sof_intel_dsp_desc + *get_chip_info(struct snd_sof_pdata *pdata) +{ + const struct sof_dev_desc *desc = pdata->desc; + const struct sof_intel_dsp_desc *chip_info; + + chip_info = desc->chip_info; + + return chip_info; +} + #if IS_ENABLED(CONFIG_SND_SOC_SOF_INTEL_SOUNDWIRE) /* diff --git a/sound/soc/sof/pcm.c b/sound/soc/sof/pcm.c index 9893b182da43..7cf6b18be240 100644 --- a/sound/soc/sof/pcm.c +++ b/sound/soc/sof/pcm.c @@ -116,6 +116,40 @@ static int sof_pcm_dsp_pcm_free(struct snd_pcm_substream *substream, return ret; } +static int sof_pcm_setup_connected_widgets(struct snd_sof_dev *sdev, + struct snd_soc_pcm_runtime *rtd, + struct snd_sof_pcm *spcm, int dir) +{ + struct snd_soc_dai *dai; + int ret, j; + + /* query DAPM for list of connected widgets and set them up */ + for_each_rtd_cpu_dais(rtd, j, dai) { + struct snd_soc_dapm_widget_list *list; + + ret = snd_soc_dapm_dai_get_connected_widgets(dai, dir, &list, + dpcm_end_walk_at_be); + if (ret < 0) { + dev_err(sdev->dev, "error: dai %s has no valid %s path\n", dai->name, + dir == SNDRV_PCM_STREAM_PLAYBACK ? "playback" : "capture"); + return ret; + } + + spcm->stream[dir].list = list; + + ret = sof_widget_list_setup(sdev, spcm, dir); + if (ret < 0) { + dev_err(sdev->dev, "error: failed widget list set up for pcm %d dir %d\n", + spcm->pcm.pcm_id, dir); + spcm->stream[dir].list = NULL; + snd_soc_dapm_dai_free_widgets(&list); + return ret; + } + } + + return 0; +} + static int sof_pcm_hw_params(struct snd_soc_component *component, struct snd_pcm_substream *substream, struct snd_pcm_hw_params *params) @@ -213,7 +247,14 @@ static int sof_pcm_hw_params(struct snd_soc_component *component, dev_dbg(component->dev, "stream_tag %d", pcm.params.stream_tag); - /* send IPC to the DSP */ + /* if this is a repeated hw_params without hw_free, skip setting up widgets */ + if (!spcm->stream[substream->stream].list) { + ret = sof_pcm_setup_connected_widgets(sdev, rtd, spcm, substream->stream); + if (ret < 0) + return ret; + } + + /* send hw_params IPC to the DSP */ ret = sof_ipc_tx_message(sdev->ipc, pcm.hdr.cmd, &pcm, sizeof(pcm), &ipc_params_reply, sizeof(ipc_params_reply)); if (ret < 0) { @@ -259,6 +300,10 @@ static int sof_pcm_hw_free(struct snd_soc_component *component, err = ret; } + ret = sof_widget_list_free(sdev, spcm, substream->stream); + if (ret < 0) + err = ret; + cancel_work_sync(&spcm->stream[substream->stream].period_elapsed_work); ret = snd_sof_pcm_platform_hw_free(sdev, substream); @@ -316,6 +361,7 @@ static int sof_pcm_trigger(struct snd_soc_component *component, struct sof_ipc_stream stream; struct sof_ipc_reply reply; bool reset_hw_params = false; + bool free_widget_list = false; bool ipc_first = false; int ret; @@ -386,6 +432,7 @@ static int sof_pcm_trigger(struct snd_soc_component *component, spcm->stream[substream->stream].suspend_ignored = true; return 0; } + free_widget_list = true; fallthrough; case SNDRV_PCM_TRIGGER_STOP: stream.hdr.cmd |= SOF_IPC_STREAM_TRIG_STOP; @@ -414,8 +461,15 @@ static int sof_pcm_trigger(struct snd_soc_component *component, snd_sof_pcm_platform_trigger(sdev, substream, cmd); /* free PCM if reset_hw_params is set and the STOP IPC is successful */ - if (!ret && reset_hw_params) + if (!ret && reset_hw_params) { ret = sof_pcm_dsp_pcm_free(substream, sdev, spcm); + if (ret < 0) + return ret; + + /* free widget list only for SUSPEND trigger */ + if (free_widget_list) + ret = sof_widget_list_free(sdev, spcm, substream->stream); + } return ret; } diff --git a/sound/soc/sof/sof-audio.c b/sound/soc/sof/sof-audio.c index bf5e7c7019a5..7b4dd64576fa 100644 --- a/sound/soc/sof/sof-audio.c +++ b/sound/soc/sof/sof-audio.c @@ -83,6 +83,15 @@ static int sof_widget_kcontrol_setup(struct snd_sof_dev *sdev, struct snd_sof_wi return 0; } +static void sof_reset_route_setup_status(struct snd_sof_dev *sdev, struct snd_sof_widget *widget) +{ + struct snd_sof_route *sroute; + + list_for_each_entry(sroute, &sdev->route_list, list) + if (sroute->src_widget == widget || sroute->sink_widget == widget) + sroute->setup = false; +} + int sof_widget_free(struct snd_sof_dev *sdev, struct snd_sof_widget *swidget) { struct sof_ipc_free ipc_free = { @@ -122,6 +131,8 @@ int sof_widget_free(struct snd_sof_dev *sdev, struct snd_sof_widget *swidget) return ret; } + /* reset route setup status for all routes that contain this widget */ + sof_reset_route_setup_status(sdev, swidget); swidget->complete = 0; dev_dbg(sdev->dev, "widget %s freed\n", swidget->widget->name); @@ -172,6 +183,19 @@ int sof_widget_setup(struct snd_sof_dev *sdev, struct snd_sof_widget *swidget) ret = sof_ipc_tx_message(sdev->ipc, comp->hdr.cmd, comp, ipc_size, &r, sizeof(r)); kfree(comp); + if (ret < 0) { + dev_err(sdev->dev, "error: failed to load widget %s\n", + swidget->widget->name); + goto use_count_dec; + } + + ret = sof_dai_config_setup(sdev, dai); + if (ret < 0) { + dev_err(sdev->dev, "error: failed to load dai config for DAI %s\n", + swidget->widget->name); + sof_widget_free(sdev, swidget); + return ret; + } break; case snd_soc_dapm_scheduler: pipeline = swidget->private; @@ -193,6 +217,7 @@ int sof_widget_setup(struct snd_sof_dev *sdev, struct snd_sof_widget *swidget) if (ret < 0) { dev_err(sdev->dev, "error: failed to restore kcontrols for widget %s\n", swidget->widget->name); + sof_widget_free(sdev, swidget); return ret; } @@ -206,6 +231,266 @@ int sof_widget_setup(struct snd_sof_dev *sdev, struct snd_sof_widget *swidget) } EXPORT_SYMBOL(sof_widget_setup); +static int sof_route_setup_ipc(struct snd_sof_dev *sdev, struct snd_sof_route *sroute) +{ + struct sof_ipc_pipe_comp_connect *connect; + struct sof_ipc_reply reply; + int ret; + + /* skip if there's no private data */ + if (!sroute->private) + return 0; + + /* nothing to do if route is already set up */ + if (sroute->setup) + return 0; + + connect = sroute->private; + + dev_dbg(sdev->dev, "setting up route %s -> %s\n", + sroute->src_widget->widget->name, + sroute->sink_widget->widget->name); + + /* send ipc */ + ret = sof_ipc_tx_message(sdev->ipc, + connect->hdr.cmd, + connect, sizeof(*connect), + &reply, sizeof(reply)); + if (ret < 0) { + dev_err(sdev->dev, "%s: route setup failed %d\n", __func__, ret); + return ret; + } + + sroute->setup = true; + + return 0; +} + +static int sof_route_setup(struct snd_sof_dev *sdev, struct snd_soc_dapm_widget *wsource, + struct snd_soc_dapm_widget *wsink) +{ + struct snd_sof_widget *src_widget = wsource->dobj.private; + struct snd_sof_widget *sink_widget = wsink->dobj.private; + struct snd_sof_route *sroute; + bool route_found = false; + + /* ignore routes involving virtual widgets in topology */ + switch (src_widget->id) { + case snd_soc_dapm_out_drv: + case snd_soc_dapm_output: + case snd_soc_dapm_input: + return 0; + default: + break; + } + + switch (sink_widget->id) { + case snd_soc_dapm_out_drv: + case snd_soc_dapm_output: + case snd_soc_dapm_input: + return 0; + default: + break; + } + + /* find route matching source and sink widgets */ + list_for_each_entry(sroute, &sdev->route_list, list) + if (sroute->src_widget == src_widget && sroute->sink_widget == sink_widget) { + route_found = true; + break; + } + + if (!route_found) { + dev_err(sdev->dev, "error: cannot find SOF route for source %s -> %s sink\n", + wsource->name, wsink->name); + return -EINVAL; + } + + return sof_route_setup_ipc(sdev, sroute); +} + +static int sof_setup_pipeline_connections(struct snd_sof_dev *sdev, + struct snd_soc_dapm_widget_list *list, int dir) +{ + struct snd_soc_dapm_widget *widget; + struct snd_soc_dapm_path *p; + int ret; + int i; + + /* + * Set up connections between widgets in the sink/source paths based on direction. + * Some non-SOF widgets exist in topology either for compatibility or for the + * purpose of connecting a pipeline from a host to a DAI in order to receive the DAPM + * events. But they are not handled by the firmware. So ignore them. + */ + if (dir == SNDRV_PCM_STREAM_PLAYBACK) { + for_each_dapm_widgets(list, i, widget) { + if (!widget->dobj.private) + continue; + + snd_soc_dapm_widget_for_each_sink_path(widget, p) + if (p->sink->dobj.private) { + ret = sof_route_setup(sdev, widget, p->sink); + if (ret < 0) + return ret; + } + } + } else { + for_each_dapm_widgets(list, i, widget) { + if (!widget->dobj.private) + continue; + + snd_soc_dapm_widget_for_each_source_path(widget, p) + if (p->source->dobj.private) { + ret = sof_route_setup(sdev, p->source, widget); + if (ret < 0) + return ret; + } + } + } + + return 0; +} + +int sof_widget_list_setup(struct snd_sof_dev *sdev, struct snd_sof_pcm *spcm, int dir) +{ + struct snd_soc_dapm_widget_list *list = spcm->stream[dir].list; + struct snd_soc_dapm_widget *widget; + int i, ret, num_widgets; + + /* nothing to set up */ + if (!list) + return 0; + + /* set up widgets in the list */ + for_each_dapm_widgets(list, num_widgets, widget) { + struct snd_sof_widget *swidget = widget->dobj.private; + struct snd_sof_widget *pipe_widget; + + if (!swidget) + continue; + + /* + * The scheduler widget for a pipeline is not part of the connected DAPM + * widget list and it needs to be set up before the widgets in the pipeline + * are set up. The use_count for the scheduler widget is incremented for every + * widget in a given pipeline to ensure that it is freed only after the last + * widget in the pipeline is freed. + */ + pipe_widget = swidget->pipe_widget; + if (!pipe_widget) { + dev_err(sdev->dev, "error: no pipeline widget found for %s\n", + swidget->widget->name); + ret = -EINVAL; + goto widget_free; + } + + ret = sof_widget_setup(sdev, pipe_widget); + if (ret < 0) + goto widget_free; + + /* set up the widget */ + ret = sof_widget_setup(sdev, swidget); + if (ret < 0) { + sof_widget_free(sdev, pipe_widget); + goto widget_free; + } + } + + /* + * error in setting pipeline connections will result in route status being reset for + * routes that were successfully set up when the widgets are freed. + */ + ret = sof_setup_pipeline_connections(sdev, list, dir); + if (ret < 0) + goto widget_free; + + /* complete pipelines */ + for_each_dapm_widgets(list, i, widget) { + struct snd_sof_widget *swidget = widget->dobj.private; + struct snd_sof_widget *pipe_widget; + + if (!swidget) + continue; + + pipe_widget = swidget->pipe_widget; + if (!pipe_widget) { + dev_err(sdev->dev, "error: no pipeline widget found for %s\n", + swidget->widget->name); + ret = -EINVAL; + goto widget_free; + } + + if (pipe_widget->complete) + continue; + + pipe_widget->complete = snd_sof_complete_pipeline(sdev->dev, pipe_widget); + if (pipe_widget->complete < 0) { + ret = pipe_widget->complete; + goto widget_free; + } + } + + return 0; + +widget_free: + /* free all widgets that have been set up successfully */ + for_each_dapm_widgets(list, i, widget) { + struct snd_sof_widget *swidget = widget->dobj.private; + + if (!swidget) + continue; + + if (!num_widgets--) + break; + + sof_widget_free(sdev, swidget); + sof_widget_free(sdev, swidget->pipe_widget); + } + + return ret; +} + +int sof_widget_list_free(struct snd_sof_dev *sdev, struct snd_sof_pcm *spcm, int dir) +{ + struct snd_soc_dapm_widget_list *list = spcm->stream[dir].list; + struct snd_soc_dapm_widget *widget; + int i, ret; + int ret1 = 0; + + /* nothing to free */ + if (!list) + return 0; + + /* + * Free widgets in the list. This can fail but continue freeing other widgets to keep + * use_counts balanced. + */ + for_each_dapm_widgets(list, i, widget) { + struct snd_sof_widget *swidget = widget->dobj.private; + + if (!swidget) + continue; + + /* + * free widget and its pipe_widget. Either of these can fail, but free as many as + * possible before freeing the list and returning the error. + */ + ret = sof_widget_free(sdev, swidget); + if (ret < 0) + ret1 = ret; + + ret = sof_widget_free(sdev, swidget->pipe_widget); + if (ret < 0) + ret1 = ret; + } + + snd_soc_dapm_dai_free_widgets(&list); + spcm->stream[dir].list = NULL; + + return ret1; +} + /* * helper to determine if there are only D0i3 compatible * streams active @@ -309,13 +594,32 @@ int sof_set_up_pipelines(struct device *dev) struct snd_sof_dev *sdev = dev_get_drvdata(dev); struct snd_sof_widget *swidget; struct snd_sof_route *sroute; - struct snd_sof_dai *dai; int ret; /* restore pipeline components */ list_for_each_entry_reverse(swidget, &sdev->widget_list, list) { - /* reset widget use_count after resuming */ - swidget->use_count = 0; + /* only set up the widgets belonging to static pipelines */ + if (swidget->dynamic_pipeline_widget) + continue; + + /* update DAI config. The IPC will be sent in sof_widget_setup() */ + if (WIDGET_IS_DAI(swidget->id)) { + struct snd_sof_dai *dai = swidget->private; + struct sof_ipc_dai_config *config; + + if (!dai || !dai->dai_config) + continue; + + config = dai->dai_config; + /* + * The link DMA channel would be invalidated for running + * streams but not for streams that were in the PAUSED + * state during suspend. So invalidate it here before setting + * the dai config in the DSP. + */ + if (config->type == SOF_DAI_INTEL_HDA) + config->hda.link_dma_ch = DMA_CHAN_INVALID; + } ret = sof_widget_setup(sdev, swidget); if (ret < 0) @@ -323,56 +627,28 @@ int sof_set_up_pipelines(struct device *dev) } /* restore pipeline connections */ - list_for_each_entry_reverse(sroute, &sdev->route_list, list) { - struct sof_ipc_pipe_comp_connect *connect; - struct sof_ipc_reply reply; + list_for_each_entry(sroute, &sdev->route_list, list) { - /* skip if there's no private data */ - if (!sroute->private) + /* only set up routes belonging to static pipelines */ + if (sroute->src_widget->dynamic_pipeline_widget || + sroute->sink_widget->dynamic_pipeline_widget) continue; - connect = sroute->private; - - /* send ipc */ - ret = sof_ipc_tx_message(sdev->ipc, - connect->hdr.cmd, - connect, sizeof(*connect), - &reply, sizeof(reply)); + ret = sof_route_setup_ipc(sdev, sroute); if (ret < 0) { - dev_err(dev, - "error: failed to load route sink %s control %s source %s\n", - sroute->route->sink, - sroute->route->control ? sroute->route->control - : "none", - sroute->route->source); - + dev_err(sdev->dev, "%s: restore pipeline connections failed\n", __func__); return ret; } - sroute->setup = true; - } - - /* restore dai links */ - list_for_each_entry_reverse(dai, &sdev->dai_list, list) { - struct sof_ipc_dai_config *config = &dai->dai_config[dai->current_config]; - - /* - * The link DMA channel would be invalidated for running - * streams but not for streams that were in the PAUSED - * state during suspend. So invalidate it here before setting - * the dai config in the DSP. - */ - if (config->type == SOF_DAI_INTEL_HDA) - config->hda.link_dma_ch = DMA_CHAN_INVALID; - - ret = sof_dai_config_setup(sdev, dai); - if (ret < 0) - return ret; } /* complete pipeline */ list_for_each_entry(swidget, &sdev->widget_list, list) { switch (swidget->id) { case snd_soc_dapm_scheduler: + /* only complete static pipelines */ + if (swidget->dynamic_pipeline_widget) + continue; + swidget->complete = snd_sof_complete_pipeline(dev, swidget); break; diff --git a/sound/soc/sof/sof-audio.h b/sound/soc/sof/sof-audio.h index d358d455da1e..8d1fc6a8d7d0 100644 --- a/sound/soc/sof/sof-audio.h +++ b/sound/soc/sof/sof-audio.h @@ -28,6 +28,8 @@ #define DMA_CHAN_INVALID 0xFFFFFFFF +#define WIDGET_IS_DAI(id) ((id) == snd_soc_dapm_dai_in || (id) == snd_soc_dapm_dai_out) + /* PCM stream, mapped to FW component */ struct snd_sof_pcm_stream { u32 comp_id; @@ -35,6 +37,7 @@ struct snd_sof_pcm_stream { struct sof_ipc_stream_posn posn; struct snd_pcm_substream *substream; struct work_struct period_elapsed_work; + struct snd_soc_dapm_widget_list *list; /* list of connected DAPM widgets */ bool d0i3_compatible; /* DSP can be in D0I3 when this pcm is opened */ /* * flag to indicate that the DSP pipelines should be kept @@ -256,4 +259,7 @@ void sof_machine_unregister(struct snd_sof_dev *sdev, void *pdata); int sof_widget_setup(struct snd_sof_dev *sdev, struct snd_sof_widget *swidget); int sof_widget_free(struct snd_sof_dev *sdev, struct snd_sof_widget *swidget); +/* PCM */ +int sof_widget_list_setup(struct snd_sof_dev *sdev, struct snd_sof_pcm *spcm, int dir); +int sof_widget_list_free(struct snd_sof_dev *sdev, struct snd_sof_pcm *spcm, int dir); #endif From patchwork Thu Sep 16 11:16:46 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Daniel Baluta (OSS)" X-Patchwork-Id: 12498739 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,MSGID_FROM_MTA_HEADER,SPF_HELO_NONE,SPF_PASS, USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id A6C02C433EF for ; Thu, 16 Sep 2021 11:22:07 +0000 (UTC) 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 mail.kernel.org (Postfix) with ESMTPS id 2C20F61185 for ; Thu, 16 Sep 2021 11:22:07 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 2C20F61185 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=oss.nxp.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=alsa-project.org Received: from alsa1.perex.cz (alsa1.perex.cz [207.180.221.201]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by alsa0.perex.cz (Postfix) with ESMTPS id BAC4A18C2; Thu, 16 Sep 2021 13:21:15 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz BAC4A18C2 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1631791325; bh=Wmuy1RcELX3LRvha9F0iKq5B+aTkqw7qMSGi66PqFZ8=; h=From:To:Subject:Date:In-Reply-To:References:Cc:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=ivWJp7K+HMJTt/yYGo1a50TGAayxXoSV5dvbgMsV0q/tmhtJYOQgizhiFpcywsipH eBkUlJgTqaeYj8Gv0Q0RtSpLzd6QHSNqJ0kcaB6DRX9Gj0HOnD5fnSoYkkKbSHuH5J /jiq+5WwNSCG8lV0UaHoMT8orNUc4Lp7s96GSj14= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id AF607F80542; Thu, 16 Sep 2021 13:17:42 +0200 (CEST) Received: by alsa1.perex.cz (Postfix, from userid 50401) id 1A4D8F80536; Thu, 16 Sep 2021 13:17:40 +0200 (CEST) Received: from EUR03-VE1-obe.outbound.protection.outlook.com (mail-eopbgr50050.outbound.protection.outlook.com [40.107.5.50]) (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 43E0FF804EB for ; Thu, 16 Sep 2021 13:17:22 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz 43E0FF804EB Authentication-Results: alsa1.perex.cz; dkim=pass (1024-bit key) header.d=NXP1.onmicrosoft.com header.i=@NXP1.onmicrosoft.com header.b="iabjGb7c" ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=LAHMeblbOJKvCPIo2vMr59M7IVnAgUSKDUpAUhIUxqVSIJoyINvtGddqGG4SEfLba6/ZTa/HedsK/Pal51hr6mUQWMPa4gOJAzoMSeXyeBi+KjIZYHkzS6I30mB11UIdDVI8laSrg/9rEyQQXq1HDzjBAMkSldmnTskBrmFmA4HeygEq0ADdaS5LsOCESpskKuSmhkr946Hpa5LV5MU3LfZWJmVUg5y7cWTZDTp1ptXcu6EhaUdGPJcjGu1V8hhp7JEdWzbgQOjcMcQpga4yWkzpo7I/pYGTkPz4hpUU4oAK/JbkO8HX4m3v92SlrXFCPFLrdzJnQYW595ZMdRf4Gw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version; bh=r33LpVf5TasNOfyqMtcxuG9Sf+2Ff/371JeRpRovvoA=; b=mItNc2pTgmfnePn6qnoC34YEQZsFs5EB5fqir1nM1RLJ/E9Czyx97r5p3FE160KPGr+XCNSiUyHv6bVtexPB8mzqxI9laxl5uwY6HKL8Yf9wLcWpk+JpWRq4AbyobA0C0auqalYK9tn+HBpBJVCxkdxYFDc9EzaKQgnVRHj1iXSi5bzUCGg5b6eoMxIkA8HG2fG1TkkpocpE25gOBpuBzJX5m0pLCYeKTjl/vOtAbbBZJkgcBsjJqTSMgVnCHRenK7KJUSxD3+iiY8sA9HNNzl910yI0N1PQ1Sj7yi5s0t+T0xqQ1A8Vq0+k/gTawaIdvZzYjIpG5xOhUGY43x0YRw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=oss.nxp.com; dmarc=pass action=none header.from=oss.nxp.com; dkim=pass header.d=oss.nxp.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=NXP1.onmicrosoft.com; s=selector2-NXP1-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=r33LpVf5TasNOfyqMtcxuG9Sf+2Ff/371JeRpRovvoA=; b=iabjGb7cZ6OSfpkJnEBjvTpdzsB3b85vN50FxG9zzHcjd3Za2J/YE7riiHv5/3ibi0jYCJIeOINinMGrkVuSUPWs5OQzUGkGWJwA1NddgyvtcdVRLKS0/vLWFZk572K/R3ymt1jadt0V+hnlODvYwXTiLLKsksMg4DduiHOmNMs= Authentication-Results: kernel.org; dkim=none (message not signed) header.d=none;kernel.org; dmarc=none action=none header.from=oss.nxp.com; Received: from VI1PR04MB5151.eurprd04.prod.outlook.com (2603:10a6:803:61::28) by VI1PR04MB4926.eurprd04.prod.outlook.com (2603:10a6:803:51::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4500.18; Thu, 16 Sep 2021 11:17:21 +0000 Received: from VI1PR04MB5151.eurprd04.prod.outlook.com ([fe80::499b:ba92:db2e:3f28]) by VI1PR04MB5151.eurprd04.prod.outlook.com ([fe80::499b:ba92:db2e:3f28%7]) with mapi id 15.20.4500.020; Thu, 16 Sep 2021 11:17:20 +0000 From: Daniel Baluta To: broonie@kernel.org Subject: [PATCH 12/12] ASoC: SOF: topology: Add kernel parameter for topology verification Date: Thu, 16 Sep 2021 14:16:46 +0300 Message-Id: <20210916111646.367133-13-daniel.baluta@oss.nxp.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20210916111646.367133-1-daniel.baluta@oss.nxp.com> References: <20210916111646.367133-1-daniel.baluta@oss.nxp.com> X-ClientProxiedBy: AM0PR04CA0037.eurprd04.prod.outlook.com (2603:10a6:208:1::14) To VI1PR04MB5151.eurprd04.prod.outlook.com (2603:10a6:803:61::28) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from localhost.localdomain (2a02:2f08:5708:8600:b29c:ccfa:a961:8ebd) by AM0PR04CA0037.eurprd04.prod.outlook.com (2603:10a6:208:1::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4523.14 via Frontend Transport; Thu, 16 Sep 2021 11:17:19 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: da409bb6-8407-430b-87c3-08d979038cf5 X-MS-TrafficTypeDiagnostic: VI1PR04MB4926: X-MS-Exchange-SharedMailbox-RoutingAgent-Processed: True X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:8273; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: tjAfh6V47/dSUC3sA+tByyKaE5hRNGCB4e0JUqw6wNuPThs07BS9aLTTnutUdLPbA0TPFz/NUksxoxQ9OnblJ25EU9ERP+4R4wEQVSIWUCTG8SFHju88h0E/GUI1xNoMgZAoY2BoG1CipdZduwEfVR9d7Y2Dxw3P/qULcFZoJy69aOGmiM3YPhRNNXL9ibavSWo3mLCgrIuMIP+7gVMhbeI8Oe4wu1xBaoHbqlzPWjNwLMQGz0Ueo5bzpGCP3FCCXumT39Wed0OpgRf+ouA2M3FSmze4QIvou4bdjpL4QpXj7b9j34hv5UH2YKm20FdtUGx7QiphBowEhQL62n/nGbpRwGR3BMWcoXMCgzkyw3ssKvikKn3Zd6e3BNN419C9QVpF7oHcE+BhFgOsGtSmSLRdYHoamSH3EK1NSkGIVdml+QO4dtrb6VJcNmWZP0o5Ae0U6kFdLbfceiaWdJbe/uxqcEdaDeojvb6ImOFemm92l5MNuaVHkCOk1xbK+XTkKxNCEMAS57UKvKlR1ii5pkWYNerQwTOeMMk853eHUHJ0L3V9FB9RK46zRxrkG6q5vCDKjCAQBXDUgsYgLJXtHkGwxU0is9ldW12tKkOZ0XWJKpCzA4taDtz5piFasdEjW5I8IlvlI0h3NlJQB4H9Xw== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:VI1PR04MB5151.eurprd04.prod.outlook.com; PTR:; CAT:NONE; SFS:(4636009)(39860400002)(366004)(136003)(376002)(346002)(396003)(4326008)(8936002)(15650500001)(6486002)(186003)(83380400001)(6916009)(2616005)(5660300002)(66946007)(52116002)(478600001)(8676002)(6512007)(6506007)(86362001)(2906002)(44832011)(66476007)(66556008)(316002)(1076003)(38100700002)(6666004); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: qNZl2AwUlY83h6VY26ZjLsyzPSsUt083DxnKVyDWOKXhJ+J/23RS0wz+nYSDUFvqgMnNm0emaihAyAn/BVmHjL2RxQnSFignNKQtuymiCFcRzzr2LXOC4vLxNQYrErzFdcXdDyildWrufBPgxyYi0+10Pp7gTuaG+Zv4tO0AjDkcVuosW9+Sgm6Hy6FIFU8I8GDoiuOzoj4AUymkryCv+SCHP3XCo7JayltO+7I9TvRxm9Uy5uVfor+nVG06FsRA/5FfcieYEO9YZiccYrPqwbDDBy8NCgY7RBSWQ+/FWJ1bkXpKqzGL/Rt+MgXffYaaU9zGDc9PKGO/FF6T1MkZ+q9Ytyulb3B71R9NTvQK0otsJ+PCF/Ab4eUDjhMJXpTX3n1IMaXbEFAslpSBfJqiHuLEWUmT6ezNHtjDcpvGj8r46vqF3BbBDN7m5M3CrZ0DKxqKlLPi3TMCpJG0laCUqBP4rH6oTMiOtBcQj0yHRTrrB6Rdiz5TMo79qyoRWY3xfKp394VxndZlG22/2zNwVgV1tBLoc3hjMwmozcejZgBbiSTIo2wbr8ln4LK7pnS8jk1WBKsmuw/yvc9X5gOIi+OtMsb0UKM4RUYdnGK+v7LiFwxFk3TN1+0SjrW73iFdSsgj0HvpHIHteBGoPUleAQ96jZBG6fytH8Hs7gO1oFGjQ0sIbiYUWic42vmgblY/Qj+cl+k+LMHFBjXIN2WHvTIaJIm0wj3u71iuFnpx6E5NJlkFM+lsbMVZ4BD2tH8waKylYcRi6Uu6TMTvwjaxGv+lRqHmWxrxjEWRhZ0WLgMZKO8n0wPv+X1SRALKpO7eJT9y2+rtEZz5qwe7v+aFz8n2x0w/05c2VesMJhXkdQ/AGi1qcWUVBhZynnFKaRVO/KbqJeQlkBN0T4kh/AqO7K7limZNttAHMdx0PIJZXgnvzEbgKqEDez+eh0lJgApyVaQBPuorEdgs8/WA0FHZwv+536AbBAxisPy5pJbC04oKudj/JhvSnwiURjJzLDaCSFPhB/JLgw3iidQ0b50AzDQpCmV6Kqn9ZSpAcBxv9ZHc296PCGkPgnnelbJ7Gdvsndx1y6WYekk2wQt2n/drSwG9776eibxUUAxTgyjOpm2H91ZaN2BhPyrCoh0wi0/4wfN7bXQHDjDIlUaoi5P6vDdPgtn4it5SDHv3FPzWlfGzFwSbwUnirKzsaC2Cgt1Nfh4hESP5jXFejHu3Vb9EYHh6eo4/aSfW3SqPnijxF5h5LdsxG2fLk2SDoi2kJPfQY9nBQtCvp1s06mLyjapvsVKt0eTyLYL6GsaySCw3G2qC2YKfDgEtcgJIgi8CFTgEMzYwLZ6r6tyjfgGvXf3TIHQD23Unfa48eAQB//cSLtc5ZZgDRYGlo+JUWe8JAZvfgfv4CcVKzOMuswXlLmLG5A== X-OriginatorOrg: oss.nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: da409bb6-8407-430b-87c3-08d979038cf5 X-MS-Exchange-CrossTenant-AuthSource: VI1PR04MB5151.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 16 Sep 2021 11:17:20.8039 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: sOD0spoJ6fTzZKEdwmHEZfxvFD+6B8EAKeOeM2PtDj07e0TRlROIY56DKp56OZnAPnQmUXn/MmjAKduM8lsDSw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR04MB4926 Cc: pierre-louis.bossart@linux.intel.com, alsa-devel@alsa-project.org, kai.vehmanen@linux.intel.com, lgirdwood@gmail.com, daniel.baluta@nxp.com, linux-kernel@vger.kernel.org, ranjani.sridharan@linux.intel.com, Guennadi Liakhovetski , peter.ujfalusi@linux.intel.com X-BeenThere: alsa-devel@alsa-project.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: "Alsa-devel mailing list for ALSA developers - http://www.alsa-project.org" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: alsa-devel-bounces@alsa-project.org Sender: "Alsa-devel" From: Ranjani Sridharan Add a kernel debug flag to enable a one-shot topology verification for all pipelines including the dynamic ones. If the debug flag is set, all the topology component loading will be verified during the complete callback. Signed-off-by: Ranjani Sridharan Reviewed-by: Guennadi Liakhovetski Reviewed-by: Pierre-Louis Bossart Reviewed-by: Kai Vehmanen --- sound/soc/sof/pm.c | 4 ++-- sound/soc/sof/sof-audio.c | 37 +++++++++++++++++++++++++------------ sound/soc/sof/sof-audio.h | 4 ++-- sound/soc/sof/sof-priv.h | 1 + sound/soc/sof/topology.c | 17 ++++++++++++++++- 5 files changed, 46 insertions(+), 17 deletions(-) diff --git a/sound/soc/sof/pm.c b/sound/soc/sof/pm.c index ea27567d2fe4..9ec091130323 100644 --- a/sound/soc/sof/pm.c +++ b/sound/soc/sof/pm.c @@ -157,7 +157,7 @@ static int sof_resume(struct device *dev, bool runtime_resume) } /* restore pipelines */ - ret = sof_set_up_pipelines(sdev->dev); + ret = sof_set_up_pipelines(sdev->dev, false); if (ret < 0) { dev_err(sdev->dev, "error: failed to restore pipeline after resume %d\n", @@ -208,7 +208,7 @@ static int sof_suspend(struct device *dev, bool runtime_suspend) if (target_state == SOF_DSP_PM_D0) goto suspend; - sof_tear_down_pipelines(dev); + sof_tear_down_pipelines(dev, false); /* release trace */ snd_sof_release_trace(sdev); diff --git a/sound/soc/sof/sof-audio.c b/sound/soc/sof/sof-audio.c index 7b4dd64576fa..c4cabe26b157 100644 --- a/sound/soc/sof/sof-audio.c +++ b/sound/soc/sof/sof-audio.c @@ -589,7 +589,7 @@ const struct sof_ipc_pipe_new *snd_sof_pipeline_find(struct snd_sof_dev *sdev, return NULL; } -int sof_set_up_pipelines(struct device *dev) +int sof_set_up_pipelines(struct device *dev, bool verify) { struct snd_sof_dev *sdev = dev_get_drvdata(dev); struct snd_sof_widget *swidget; @@ -599,7 +599,7 @@ int sof_set_up_pipelines(struct device *dev) /* restore pipeline components */ list_for_each_entry_reverse(swidget, &sdev->widget_list, list) { /* only set up the widgets belonging to static pipelines */ - if (swidget->dynamic_pipeline_widget) + if (!verify && swidget->dynamic_pipeline_widget) continue; /* update DAI config. The IPC will be sent in sof_widget_setup() */ @@ -630,8 +630,8 @@ int sof_set_up_pipelines(struct device *dev) list_for_each_entry(sroute, &sdev->route_list, list) { /* only set up routes belonging to static pipelines */ - if (sroute->src_widget->dynamic_pipeline_widget || - sroute->sink_widget->dynamic_pipeline_widget) + if (!verify && (sroute->src_widget->dynamic_pipeline_widget || + sroute->sink_widget->dynamic_pipeline_widget)) continue; ret = sof_route_setup_ipc(sdev, sroute); @@ -646,7 +646,7 @@ int sof_set_up_pipelines(struct device *dev) switch (swidget->id) { case snd_soc_dapm_scheduler: /* only complete static pipelines */ - if (swidget->dynamic_pipeline_widget) + if (!verify && swidget->dynamic_pipeline_widget) continue; swidget->complete = @@ -661,24 +661,37 @@ int sof_set_up_pipelines(struct device *dev) } /* - * This function doesn't free widgets. It only resets the set up status for all routes and - * use_count for all widgets. + * This function doesn't free widgets during suspend. It only resets the set up status for all + * routes and use_count for all widgets. */ -void sof_tear_down_pipelines(struct device *dev) +int sof_tear_down_pipelines(struct device *dev, bool verify) { struct snd_sof_dev *sdev = dev_get_drvdata(dev); struct snd_sof_widget *swidget; struct snd_sof_route *sroute; + int ret; /* - * No need to protect swidget->use_count and sroute->setup as this function is called only - * during the suspend callback and all streams should be suspended by then + * This function is called during suspend and for one-time topology verification during + * first boot. In both cases, there is no need to protect swidget->use_count and + * sroute->setup because during suspend all streams are suspended and during topology + * loading the sound card unavailable to open PCMs. */ - list_for_each_entry(swidget, &sdev->widget_list, list) - swidget->use_count = 0; + list_for_each_entry_reverse(swidget, &sdev->widget_list, list) { + if (!verify) { + swidget->use_count = 0; + continue; + } + + ret = sof_widget_free(sdev, swidget); + if (ret < 0) + return ret; + } list_for_each_entry(sroute, &sdev->route_list, list) sroute->setup = false; + + return 0; } /* diff --git a/sound/soc/sof/sof-audio.h b/sound/soc/sof/sof-audio.h index 8d1fc6a8d7d0..149b3dbcddd1 100644 --- a/sound/soc/sof/sof-audio.h +++ b/sound/soc/sof/sof-audio.h @@ -246,8 +246,8 @@ int snd_sof_ipc_set_get_comp_data(struct snd_sof_control *scontrol, int sof_pcm_dai_link_fixup(struct snd_soc_pcm_runtime *rtd, struct snd_pcm_hw_params *params); /* PM */ -int sof_set_up_pipelines(struct device *dev); -void sof_tear_down_pipelines(struct device *dev); +int sof_set_up_pipelines(struct device *dev, bool verify); +int sof_tear_down_pipelines(struct device *dev, bool verify); int sof_set_hw_params_upon_resume(struct device *dev); bool snd_sof_stream_suspend_ignored(struct snd_sof_dev *sdev); bool snd_sof_dsp_only_d0i3_compatible_stream_active(struct snd_sof_dev *sdev); diff --git a/sound/soc/sof/sof-priv.h b/sound/soc/sof/sof-priv.h index 80e4a8c29280..d950157feebe 100644 --- a/sound/soc/sof/sof-priv.h +++ b/sound/soc/sof/sof-priv.h @@ -23,6 +23,7 @@ /* debug flags */ #define SOF_DBG_ENABLE_TRACE BIT(0) #define SOF_DBG_RETAIN_CTX BIT(1) /* prevent DSP D3 on FW exception */ +#define SOF_DBG_VERIFY_TPLG BIT(2) /* verify topology during load */ #define SOF_DBG_DUMP_REGS BIT(0) #define SOF_DBG_DUMP_MBOX BIT(1) diff --git a/sound/soc/sof/topology.c b/sound/soc/sof/topology.c index d8eb238e5229..44d60081bc26 100644 --- a/sound/soc/sof/topology.c +++ b/sound/soc/sof/topology.c @@ -3452,8 +3452,23 @@ static int sof_complete(struct snd_soc_component *scomp) } } + /* verify topology components loading including dynamic pipelines */ + if (sof_core_debug & SOF_DBG_VERIFY_TPLG) { + ret = sof_set_up_pipelines(scomp->dev, true); + if (ret < 0) { + dev_err(sdev->dev, "error: topology verification failed %d\n", ret); + return ret; + } + + ret = sof_tear_down_pipelines(scomp->dev, true); + if (ret < 0) { + dev_err(sdev->dev, "error: topology tear down pipelines failed %d\n", ret); + return ret; + } + } + /* set up static pipelines */ - return sof_set_up_pipelines(scomp->dev); + return sof_set_up_pipelines(scomp->dev, false); } /* manifest - optional to inform component of manifest */