From patchwork Fri Sep 17 14:36:48 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: 12502301 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,URIBL_BLOCKED, 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 A7C2FC433F5 for ; Fri, 17 Sep 2021 14:39:18 +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 28F9B60F5B for ; Fri, 17 Sep 2021 14:39:18 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 28F9B60F5B 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 981221797; Fri, 17 Sep 2021 16:38:26 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz 981221797 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1631889556; bh=KjqpQROH2/sDmpoFzHkWTN4ZZqUqSJ/XOO730YEKItE=; h=From:To:Subject:Date:In-Reply-To:References:Cc:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=LZ8SIhAkLfyFWwxR5xRrF+JvdZ0rmY4x22d+BY/oTv7fAMUdIqx+V0Xma7idr94av EQlqVCrr4M+w6KswgXuJWktixQzqbLK1lsDcGF54a3MVaLCRgZe0Iz8HeaCTFR+XhX XDn3Zkkmfzi1qzqf0iZ5dRJ8/oZg3dRlx2PlPxgw= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id D4031F8027C; Fri, 17 Sep 2021 16:37:39 +0200 (CEST) Received: by alsa1.perex.cz (Postfix, from userid 50401) id 7E131F804F1; Fri, 17 Sep 2021 16:37:38 +0200 (CEST) Received: from EUR01-VE1-obe.outbound.protection.outlook.com (mail-eopbgr140047.outbound.protection.outlook.com [40.107.14.47]) (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 600CDF8027C for ; Fri, 17 Sep 2021 16:37:28 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz 600CDF8027C Authentication-Results: alsa1.perex.cz; dkim=pass (1024-bit key) header.d=NXP1.onmicrosoft.com header.i=@NXP1.onmicrosoft.com header.b="JxFX9mQF" ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=gmhfL9Hwk/2ICzdJ8HucnMQHs/GLhtea3hK79+vPrhldw5SChrqPLldKzlBSzBJiZ/3VgLogM3+E9ZglLIIQbJXv0kvn3U6qLR3JMGRMjPEcMYnpuVEiggUOzQ75EWoFliGKntBrNrcVGVIr5y7QBzgIW0bkVTZ0QMLyI2qBoID0/eJp3Fs/5syBYQAFvsJ+XWp7Y41rEG/CqAZRkpRHefenBNPrsyEHf0VTQmOLsdZZUytshnJIlFQMNfHi3BK9Dl8VbLP+2OVWrMY2vWmeeHsuCBuJuT1oTCyybDV+ZYqTPegKB8LOZgv4lraRUSYJguzGjuEJvMdApEq2fNhiYg== 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=zaXfcH5jjNcDuzON9ZVvNIZqwGSnfla8DyzWvwz/VO4=; b=hoNyW+8GhRWaza1Vk91sPb1BEcRMeu4MRsEjNkEl1sA43/y2nZUOLJX3uK8W6W5nCQXIMG4704I7/TVTrqTjISyAd+bJtkXVhnWCGuZcK27Dje0tRLgU0sR8WZuY3vfwlkqTKFtT92nOBZs/loB/Gd32EYUhH/PoU/w58iBC3OjF/EAmOm8OZL6so/DgHaLjkf9qcbAi/Ww1bQrm/fgu48m+W6se6kAEMMoTjfNpYYHizrZv+bvjjwZBlXGqMkE5wOo5Nu3ssYmqtCLoB7HVkFsQ+epkkcCT/xGtEOynD9ouTZRfWRrn17mcCQaLcFL786zSGQrYlvFjfDkn1HAsyQ== 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=zaXfcH5jjNcDuzON9ZVvNIZqwGSnfla8DyzWvwz/VO4=; b=JxFX9mQFht0+HQRYSC4gQ5PdWgRHww+IBkJfkFpzlu7KPyajM0X0vIr8ZXejOK/LkvdUM5W2fycPcsL+ABzzxxxYdVREal6g1prX26XtEg+8QRmfrV/lDAcVJjkkZHSm1bWydvqAy0VeU1P58deHlnB++V4I3XFInjCB5I3x/Gg= 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 AM0PR04MB5140.eurprd04.prod.outlook.com (2603:10a6:208:ca::21) by AM8PR04MB7409.eurprd04.prod.outlook.com (2603:10a6:20b:1c5::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4523.16; Fri, 17 Sep 2021 14:37:20 +0000 Received: from AM0PR04MB5140.eurprd04.prod.outlook.com ([fe80::dd84:b996:1c8:705]) by AM0PR04MB5140.eurprd04.prod.outlook.com ([fe80::dd84:b996:1c8:705%6]) with mapi id 15.20.4523.016; Fri, 17 Sep 2021 14:37:20 +0000 From: Daniel Baluta To: broonie@kernel.org Subject: [PATCH v2 01/12] ASoC: topology: change the complete op in snd_soc_tplg_ops to return int Date: Fri, 17 Sep 2021 17:36:48 +0300 Message-Id: <20210917143659.401102-2-daniel.baluta@oss.nxp.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20210917143659.401102-1-daniel.baluta@oss.nxp.com> References: <20210917143659.401102-1-daniel.baluta@oss.nxp.com> X-ClientProxiedBy: VI1P193CA0022.EURP193.PROD.OUTLOOK.COM (2603:10a6:800:bd::32) To AM0PR04MB5140.eurprd04.prod.outlook.com (2603:10a6:208:ca::21) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from localhost.localdomain (2a02:2f08:5708:8600:8372:c747:541d:bbc9) by VI1P193CA0022.EURP193.PROD.OUTLOOK.COM (2603:10a6:800:bd::32) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4523.14 via Frontend Transport; Fri, 17 Sep 2021 14:37:19 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: d38e0384-feab-4b75-4ce7-08d979e8a7b1 X-MS-TrafficTypeDiagnostic: AM8PR04MB7409: 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: 3RQV+Yd/Ziw44V69kXyESPbtkavIDRRSCKFBRGzpMLOXBy+w5/7caXKjiKT7IqvxzdsxSiQJBJ85bJQlypqvR386/WKhS7iF7m3Uc/jNWr+0pfUYk/FDWHWGSu5TOOnpzEFWrbb0Omr/If9h1w+RQWX4PSJa21znzUiMqhwVBnIrT0wjkdr5f1Z3dGUaS8p1enKM6vRyDGjsu88P1G533BQ55e+HxKDVQGKG3ED6/doXtZ3CMA5PRsmnxl2s/jy3gycLCmFOCMaa3xImhBTCJGNlh5CCPyEpxWxv6d6gDn0SCYGvpyWyhU8AxsnYPP052kgUVEumD1KyF/fZ7DqMIViCOJ3cDDWUrb1IZ+BUHWGjkfEPuJ+MUEOqwRw70ruEv45saNKrqcEOKelaTV8IkEs+UKhdruCsnLQYhH9IE1apKYvsFJvFGM/DAcL5a6M+AySLLEDRBudeZ/pJwsSTYNafiz7PTaGg/XIw1gcKY/FwBzjV1KJw6p5OnoCZmh97WYO5VFrGVUNeEF2q3jOlQSbFM407c8WeO7k10OeTEON1mpV+tzfv/pCHyABAfgwYcaEok2Gvw4j6DmJIa3znBv3VX0SfxAfHZdFepx171du021MLA6k/WnUW5eE12Y4/+ISFfQPA2ZuwjsThrmxCBA== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:AM0PR04MB5140.eurprd04.prod.outlook.com; PTR:; CAT:NONE; SFS:(4636009)(346002)(376002)(136003)(366004)(396003)(39860400002)(5660300002)(8676002)(2906002)(4326008)(38100700002)(8936002)(66476007)(44832011)(1076003)(6666004)(86362001)(66556008)(6512007)(186003)(478600001)(316002)(6486002)(2616005)(6506007)(52116002)(6916009)(66946007)(83380400001); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: IEKVtXLt8VGBXjODK5tsLwfR1VlnHAgFHEJZTK1kUhQBQDBoHLv+HK22zEPXf/jX9P+6SBDJK0mZJQnYkKWHTerWmrq7jxuLDtGyEx5b/+c3GIMgb5gBVf6fpiEPd2cT5nLqyxMNvQ1ao7/CIDeMT3NVlmOAk/NCZ4dUVSyEUFgjIDdouHZ06S5z2ppz5J5JNuTuDjUBQ8Cxpzhq4oY0SR1dBi92HnBhKdioO3/Fa8NuNzXnSJK+HHMk8CIr4PpTs7cgbMkrFbwJWzZW9q4SR1WSTYPVSFQz2xnQkPY7ki0Wl1tlj/rG9K5S/hq5HPDsxxPdRTSVWyqQGC5I1b9OJtp4C2/zYzvOHSg+gc37mai/IeZURkMAyuejZZppWjv0FAev+n7UxXr5+J8PQwnEJDrLJzCP7L3rkhheqnRWoFPK0KXEvg6t2rMfQ0Y7crvCh/9c+xOiHIfGh9VS6V9zv4xbdVWfSr371hC3Ku3C0sF1y1pvQwwmeGYueoblh89aiVsEL2IGkQa91xB019TqsyDtXsMmieFG8KOHeK0/r+BGzS/lIhdHLYegGVGec0VUgfnbs81vlYtGkP1oO3Qt71x89hZZ012154jveP7SXoSrobXZIpuws2c0oJac+6tiqMc11f/+KYxdkTuC9zeFfXIxTIV9bGfFZM9Ix5aNlurRkqVDbnBFmlBFhScK+v7pNxWNsxGZVhNLSxR1+noC+VPLkn4bnxqRKZX+El4l76UcEiLvjM9Brl9Ix3dZTpvBRRFULVMNRPPXLxD+34umAuQ8VsmN8HyQzA2Q0r/oJzViH8E2PJu18eQskaY/WxXw2k+oXVJ2wj7D7MLbu3+BksjMiGwS6rU/sgkSWANwsqwywUyYbiOuPSI3kwGwtebSQtrawvA2CpmUIsVUNEhAJ/W556tYqxqW5QgpZNt28sZgH2mY5UjvI7Nkr743erCqVkdkTJTuIr+WQDbJ9ED+l+4YU0rVMbXX89wRh3qzhhfWyq/sf7vnnZn1BhY+F+2C0nLdT3c9xyuJ6oY+zBfaHxPGXdqZhSBAOnHBvwruyGeqSkzWmCSRH9VJ/9f+gzGkdHmxtxXWlAh0IE7ECQEQbllwRG9akv5Qhe/NQuh3on5/aS1+lTXSa2AYHbSytzVsG9h5Fz+ZYY2j+PFCbh/oj79Rr0cWDt6NFI1SxowoeBIEe6cCK/I7pqNWWCKWx8qNP7iL2lcucSIPp6sUietlVacV3B6dAq++vSzZC1UZXPXyC/MWssZ/ok6Bqs2cGFIadsqT574T2TvyXE/Gwsu4z12OXB1egsxGfXHkqJ/Hv6HNb+/7xRWKCENElALZx6TKX3U1LPxA8soIg2g2MokBsZiEKcC9P6vgx/qV3Bt+G/yHXHQWljzJmqBWU2Z602H1 X-OriginatorOrg: oss.nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: d38e0384-feab-4b75-4ce7-08d979e8a7b1 X-MS-Exchange-CrossTenant-AuthSource: AM0PR04MB5140.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 17 Sep 2021 14:37:20.4243 (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: Ga0f7KMMmpbGH7+l3fnqGoLb/rlBLvc4Cp/WJJzMeVrPwrmFWyfP25Rba0dlqNeXoiDMVQb/q/yvd8O2LRI4mg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM8PR04MB7409 Cc: pierre-louis.bossart@linux.intel.com, alsa-devel@alsa-project.org, kai.vehmanen@linux.intel.com, lgirdwood@gmail.com, linux-kernel@vger.kernel.org, ranjani.sridharan@linux.intel.com, Guennadi Liakhovetski , daniel.baluta@nxp.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 Signed-off-by: Daniel Baluta --- 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 Fri Sep 17 14:36:49 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: 12502299 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,URIBL_BLOCKED, 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 E0633C433EF for ; Fri, 17 Sep 2021 14:39:09 +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 5C6CB60F5B for ; Fri, 17 Sep 2021 14:39:09 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 5C6CB60F5B 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 F3D92176D; Fri, 17 Sep 2021 16:38:17 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz F3D92176D DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1631889548; bh=UrPxQt+jmWAQVogc6GjJqQTGdQvZiMuBjz1lxXfvkgg=; h=From:To:Subject:Date:In-Reply-To:References:Cc:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=sVCGz3p8cOEFrnr2wmCVp8J7Rj7TSGf4QbOfCINXgz/CVNrTpvATBR8fid6vh7GvE mGSAA+o83bnbEfKUAEyyWcvWycFIvM0QtXk21XJjv7XLk3kRxX+SsQSWy2bvaeIdSK D5XtH+85vIdtllGFdnXq12fHb6dwEY2+M2QfPOeE= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id 6637AF804E5; Fri, 17 Sep 2021 16:37:36 +0200 (CEST) Received: by alsa1.perex.cz (Postfix, from userid 50401) id 55382F804AB; Fri, 17 Sep 2021 16:37:33 +0200 (CEST) Received: from EUR01-VE1-obe.outbound.protection.outlook.com (mail-eopbgr140047.outbound.protection.outlook.com [40.107.14.47]) (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 18292F80227 for ; Fri, 17 Sep 2021 16:37:27 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz 18292F80227 Authentication-Results: alsa1.perex.cz; dkim=pass (1024-bit key) header.d=NXP1.onmicrosoft.com header.i=@NXP1.onmicrosoft.com header.b="kTPVPw3D" ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=aEY8IJyct2TyZfWrgesCr6wDBmjZUWA3oGUqDjgt5X5wSOdAUw2KhhSkWYOtv5v2gHQHmYs97+vRNc9CMjlxrRmey1hG8YaxNi3HeKpFmCMuUZRVuCmB8omQQlVJhveHtHmV99+A2//aX7vCGs1u15mWS1NXRkL7twn+8IQqWsq7vyixt68yGKgCLA7oYL1GNHWuEopH02t69fNNqCNnwG4z7UEYM+MW1G9dIiikYsHulc44XcZmk/KxOyyOlsL0mSJ5WTIVihjHPfroiO9cynSbIy2b2+y3qym1UpOjdXQpu6X4AGzVqm6vMfcRfRfqcPGEVzzETCLnGBaQvs5GrA== 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=8gLGWve3UvVd8jvC9XczASUE2rKrgol1jb5xFi620Vk=; b=VWNDiY0/u38ySHyq/wO/MdlangeoeTg5IotlmTxrFGMfKyH9wb7+jMESlPtSnmrdzeCUIwxkG2A6WSufzuJTgEcO8bUfX46zqS1Goy06Mjil4bxvqDZdCgQDisL8fnvO5W+bGrDFgRM8Z5uessfzX7ae4nQBteMTQf/SckmWaPnL8iFxLwZ+FnjyI0ahQP6fkBqFBfKx11o7BiBkgrcYAz8p5uqRxh3QmxODulQtX3omRF8a9it6bAOeE0rX6lyZh5CvH3lOq/oKsDCLNAvkvM5yYkNbc+gvi6ebjwYnfj6SS1sRPQl9vgEmmRoMUFaHZDkisA71c6dtz68R/1ZjJA== 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=8gLGWve3UvVd8jvC9XczASUE2rKrgol1jb5xFi620Vk=; b=kTPVPw3DwVLTvXaX6v+aXkk72rRdN68kHCTDS9k1jl5jcy4nTabVRT8vboLVo475lixj2OupgfJBRvjwssiBe9YiEI1cxvLXYsvN4iQb9e0OFQNiSnpcYgnbY11YyRh4CERvycXkso8bNnHB70M7da07Yxe1wh0rPtwmvjRlD/A= 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 AM0PR04MB5140.eurprd04.prod.outlook.com (2603:10a6:208:ca::21) by AM8PR04MB7409.eurprd04.prod.outlook.com (2603:10a6:20b:1c5::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4523.16; Fri, 17 Sep 2021 14:37:21 +0000 Received: from AM0PR04MB5140.eurprd04.prod.outlook.com ([fe80::dd84:b996:1c8:705]) by AM0PR04MB5140.eurprd04.prod.outlook.com ([fe80::dd84:b996:1c8:705%6]) with mapi id 15.20.4523.016; Fri, 17 Sep 2021 14:37:21 +0000 From: Daniel Baluta To: broonie@kernel.org Subject: [PATCH v2 02/12] ASoC: SOF: control: Add access field in struct snd_sof_control Date: Fri, 17 Sep 2021 17:36:49 +0300 Message-Id: <20210917143659.401102-3-daniel.baluta@oss.nxp.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20210917143659.401102-1-daniel.baluta@oss.nxp.com> References: <20210917143659.401102-1-daniel.baluta@oss.nxp.com> X-ClientProxiedBy: VI1P193CA0022.EURP193.PROD.OUTLOOK.COM (2603:10a6:800:bd::32) To AM0PR04MB5140.eurprd04.prod.outlook.com (2603:10a6:208:ca::21) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from localhost.localdomain (2a02:2f08:5708:8600:8372:c747:541d:bbc9) by VI1P193CA0022.EURP193.PROD.OUTLOOK.COM (2603:10a6:800:bd::32) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4523.14 via Frontend Transport; Fri, 17 Sep 2021 14:37:20 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 78449ff7-341e-4d0b-f7dd-08d979e8a850 X-MS-TrafficTypeDiagnostic: AM8PR04MB7409: 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: +oQXWWRKgQzGtC5GYEbIZzr+M2stQ3xiTSQ4hfmV9UuZBhTBCutUjAkzmwVw37Q4N98Lh3NptPRrgb1d9nt+m8184mJ4w6cl6IqSffvgMzZFWOGeQr6TRBXxoR3E5QLEeFqB/aWoCblmA8WOkMmml56CkLoPn8O5Tzkee7hG8uxwQJemtXR2gTWMa0jckLLjvVtvp5W1Qcq1uUpfeG//PrK4hu0xSD+cz6uvr2RtQByo8Vh4VbNTbmLKDEksTpkFWm5JgxowcPHbe7pte9d/FKJR16awinmEnXXMkbxFoE3V7kyx3iAhbNxhKGF/fCdWXyvGok4Pvrp5ByAyW0RNG7pzm2ADcQHRqOGlJS2N2g94KdC6XjhpHb6LZ9cNUlp1hGawRSAVNdrjgISlhTvJyQ9ti35CiQD3AzwiTKTnS9c7ez2DEn5/ztcXCBEuPds56wxGed1fDplozTvdk+wgklbXn1MZ60l5PwRl7UP8rFR9268oJIKTfO9nn4tBX+LvFfBERjeuaXf+YPAyhmXnWPd6D7KvRkrq6nioj45/Zulb3yuScxQtk2VFKijUhSUCZanl/9psdM/FkpMiIO4DXIjMHEkLWFg1yX+GVWYHILZPO020pgtoVehaWIw1F/yT2xRrY+2/gOjODuIGcTDy8Q== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:AM0PR04MB5140.eurprd04.prod.outlook.com; PTR:; CAT:NONE; SFS:(4636009)(346002)(376002)(136003)(366004)(396003)(39860400002)(5660300002)(8676002)(2906002)(4326008)(38100700002)(8936002)(66476007)(44832011)(1076003)(6666004)(86362001)(66556008)(6512007)(186003)(478600001)(316002)(6486002)(2616005)(6506007)(52116002)(6916009)(66946007)(83380400001); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: 5vIxmjOKrQnf7dvjgWclkmp2hfse8HvRJb0GHP6Pln2IR76ZDN3SOLckG2Mu3miCLFN3X+TZ+ya7JjaCPsHGpeGVi9PbihyWQds+vNDXEikU6E6MB60RIVA6l1WLZEmQbLxYz3hdQrs/ffKCcazMIXqEh1gJU4+0qmcQ9JEsqNGRoYrtfeCTKUDBftgVtFFstkEVme3aDlz/9af1+5N5Z0U5GKwkg0GGBjlv/KttGfkTHdkVl32m6Ddhnco3/3kBECFvMu8BmvSRW/i0slIEbzmJG/nSjNKeENj44tc4SsUhesdlS4cpFHc+ZnPg7RUI4mtVyeA9A+CB9GF7xgOyPvLLmTc8r08JckBw19neqU3Pc+s1fGXhVPCjsOs0vastkiNpO0nLzk8ObRJjIXulcEXTUM0j57Jet2VVywhA/XffLF0mGgaUdU5Iw7C8Fv6z6JGrAW43nS9HyIaq5TAcNMbLXTkd/In2a4OSLiJFPFdNM3gqvgby7HVFlK7IzHwSJv5YCIKXrpyk7pf9P3mo+L0iH87TWlEPji99dlWm+ZRW2frRlYGNctp3u4JAjFLJA/1PkdYWVhISmmM+I+0EoMGd6nKK1VfaIqpzJOcghGdaX93HHPiLLqnwVwr2/SqAa9A/dffvQl6ae9kXK8AjyS1IC4rWwEmHT1Bqh8HGCKGCyBFRomAqrIJH/PKdNgGYwWsot+aIDq0/T6Nmms9oN0obOgAl90VpWaGN0y0vBDi+Yu0x7JGKpLYxnAnaCnfEl2xN111ehGzdbJRV5MHM/JQ5DhgGnquA+iRFSSag4/tLHVecZH1J+kgdCflkQ4MfKCdOSglpGAS1zpXtLhlXvQskpG14CksW2c0WSvu4uxbOnerYzkF130iNSfylFalWb5b/IEOW63Sgp9GWcrgePZUZqm38gpDP+FYeFOKtjSsIFyLCHqLCZtlO/zzqiScNnMh/XhmiFTUxR/ME0bL/8bQuVHmcapMtAILEI07z1EihrInXJJJAqTyfUqG4x6twBufIzGvaOKAoiPq3PCeTKViu0LlMVU2ZrQ6+DbZLzhMzDrwvsweI2VZWtKf9uKLVfRDbIMIjoFJccgG6OrJvFxF66IyahP84zcUL3r2shXuHtwkrh642vTBXVE++eyXrF3QC4n3s2FKrztoRWF+nokKjXqxZbeoCULjjZzOrugSVPeYLWDxgo8La+7aO7rt5QjhhxdtwgFn4XoebwFB2phukTV1d8r/krEUQHHYo3cPxop6gP28ZVWgWDHrXMCngNMKCpB67AFv9vlcKYw52dMqPKEldcwjIxqJwQ/K/mGrUU3VQ/to/SuTriHBdFlfIBK+1mJJRjRmdzhgIgt6LVAhX0fClhGcg0nE6rXWlEbAIz103gKypOfkUpual1K/X X-OriginatorOrg: oss.nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 78449ff7-341e-4d0b-f7dd-08d979e8a850 X-MS-Exchange-CrossTenant-AuthSource: AM0PR04MB5140.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 17 Sep 2021 14:37:21.4517 (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: wqzc4/Qvpe7UNhMFUfWiCfW5hLtlrNKgnPQB2WCWjtgJ1WmeOQaB8+t8WHmTpBwIm8H662JXp184lrWzX4T6Sw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM8PR04MB7409 Cc: pierre-louis.bossart@linux.intel.com, alsa-devel@alsa-project.org, kai.vehmanen@linux.intel.com, lgirdwood@gmail.com, linux-kernel@vger.kernel.org, ranjani.sridharan@linux.intel.com, Guennadi Liakhovetski , daniel.baluta@nxp.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 Signed-off-by: Daniel Baluta --- 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 Fri Sep 17 14:36:50 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: 12502303 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,URIBL_BLOCKED, 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 34187C433EF for ; Fri, 17 Sep 2021 14:39:44 +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 64A0A603E5 for ; Fri, 17 Sep 2021 14:39:43 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 64A0A603E5 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 0E180176A; Fri, 17 Sep 2021 16:38:52 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz 0E180176A DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1631889582; bh=JEqOQqsJxITVg5K9XGI6Yxc+Sf4rke8nuAsyB3zt/0M=; h=From:To:Subject:Date:In-Reply-To:References:Cc:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=OhfxymRVIOwQSSCE3j6J+PV8aGV7Pv05PkQbTeQFGyzCGPAYPu1lbL+/JSxG3DRFg rzU57JtWwKPk2rUYuc3WZC9xIxLJvYytHJilQhps0qS4rL6TLf9uaV5TVT01cFqKKs goQzlD9OcJt7BreOvBde3+YMiLRiwyRau6zQ4fII= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id 7DDDFF804F3; Fri, 17 Sep 2021 16:37:41 +0200 (CEST) Received: by alsa1.perex.cz (Postfix, from userid 50401) id E5B2BF804F1; Fri, 17 Sep 2021 16:37:38 +0200 (CEST) Received: from EUR01-VE1-obe.outbound.protection.outlook.com (mail-eopbgr140047.outbound.protection.outlook.com [40.107.14.47]) (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 A0CB6F80113 for ; Fri, 17 Sep 2021 16:37:29 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz A0CB6F80113 Authentication-Results: alsa1.perex.cz; dkim=pass (1024-bit key) header.d=NXP1.onmicrosoft.com header.i=@NXP1.onmicrosoft.com header.b="ItQcOOou" ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=PCSAQydAdr/jC9pemAVdqr0uL2y8Z+5YkQNZAMgjpjTMnjJaawRr2NCyuJ908s8nGjHyfRaKBVkfGPqTTeDNf/jmu/u1q9h5xRFgi9eX5GyllH0F0YApvl+VREWwxxf/QpC3w02h+svSMXxs3RcmOjelFJpGpR8zjI4/Bu74LK+9Ieqe9vrytrMG6gMpPhSxTllxbskZ7kpISLnqIHlb1RLDL0/4nHNyhwo0/nQeYkqGX2CU+q+EQOC24pDsiD9H+vw+vhFZBPHV6Q5U/v1c5EPk6Is6iUGrueIsADRT3s+MBjZTV8nA57TFJCCJTSG+RAE1+ciYwqhShRjRjQwfgA== 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=/8ZRI26j7frB2LCq91TGHoknL7MYtbwe3z9xQJFgv9c=; b=DB1A1NBkS4Xk/mOMxP3/iICsGNMtoAC/IQufeAAoqahp+Bo/68Fst/shJLc0ehzID+vepUGgdVFozQyMl9AjbYT2HWYlAttkmxiLfaDMZF1Qgco+I8Qv0swyP8D7jkxvHGGIBp7HLhJk3sfv4NHj9Q90x0gtQO1bgyWxa1H3tGr3vZDBPY3kd94ys0D/oLWALEQbEwPAaIarST4pliG/YbRxH9GuCr7GTgfpLJc0d2bpPviPGXvRsTyUntiyxF+Jpi04l4bPgWzNyICtxpghD7X7krStiJRS/f6VUvSwK2O8OZoWEm+gAAO+x8pOn+PdLZljzu/Tvi0YSAA4edDdQA== 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=/8ZRI26j7frB2LCq91TGHoknL7MYtbwe3z9xQJFgv9c=; b=ItQcOOoujCUZbNtkqkhQNg3Pb31sKwVDRiUVtD2g1G/se9Hh2xAIYwH3OG4HdeEHw0dCciajHz61ga1Awj2ILN+KPRtfQSk2ahbwWyz3XcW+/5Uc3IiXIuI5XCG7OGLjsqkxvC21pxYAW4oa2Npo5r1Z6G22xpUJHZUgGtgRPGE= 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 AM0PR04MB5140.eurprd04.prod.outlook.com (2603:10a6:208:ca::21) by AM8PR04MB7409.eurprd04.prod.outlook.com (2603:10a6:20b:1c5::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4523.16; Fri, 17 Sep 2021 14:37:22 +0000 Received: from AM0PR04MB5140.eurprd04.prod.outlook.com ([fe80::dd84:b996:1c8:705]) by AM0PR04MB5140.eurprd04.prod.outlook.com ([fe80::dd84:b996:1c8:705%6]) with mapi id 15.20.4523.016; Fri, 17 Sep 2021 14:37:22 +0000 From: Daniel Baluta To: broonie@kernel.org Subject: [PATCH v2 03/12] ASoC: SOF: topology: Add new token for dynamic pipeline Date: Fri, 17 Sep 2021 17:36:50 +0300 Message-Id: <20210917143659.401102-4-daniel.baluta@oss.nxp.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20210917143659.401102-1-daniel.baluta@oss.nxp.com> References: <20210917143659.401102-1-daniel.baluta@oss.nxp.com> X-ClientProxiedBy: VI1P193CA0022.EURP193.PROD.OUTLOOK.COM (2603:10a6:800:bd::32) To AM0PR04MB5140.eurprd04.prod.outlook.com (2603:10a6:208:ca::21) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from localhost.localdomain (2a02:2f08:5708:8600:8372:c747:541d:bbc9) by VI1P193CA0022.EURP193.PROD.OUTLOOK.COM (2603:10a6:800:bd::32) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4523.14 via Frontend Transport; Fri, 17 Sep 2021 14:37:21 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 4b422785-96e1-4d17-ca76-08d979e8a8e7 X-MS-TrafficTypeDiagnostic: AM8PR04MB7409: 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: DtPjOsGHDOAqu2fxvW/7qtT64XiZJjank9ZyxHqPGYyy4YyCSAZLyndZty2+ZyKmqAuRu62Q9HaNY4QnfcGKw2S/Jf8/5havW5EpXa7DQgG9SFYM+lRxV+x9qtZwwI8HOthFBRC97AwTaVByy0Vpvj9sNFZmFqii4QtuL75VrDK4pqcTqAI6TB5jTZN4Ko182lDWgam5Kj36LIb340fSr1+Qdd+ilOhdZRAzGzGC8M7Vftd/VMwVEJS9t1cn75KCX7OopjnEigO2eCSANshRrObte+qrIT8r0zfTCWpLsr7nden/Cw8CLP2p05PWjC6ZNCOJLXUZn8HTYMa3Q3bH3QBvHEWDEcwKj2f2iPnhzycR33jT9jz/btR/zN5js/btRI6WjUHluO3xmKgxs+H/s2rUpPOKKVjKU6Hz79q6mF4VCKjq7tuer7MlIXKh5wIPbRV0okQOSS3iAYpi9EQYAGbQraBTBEqESlrnDfOMJCahonUyFiPbzpuK6q7NEmWNSoVVqgDuDYGB7POAqBX5BhWWXSHA6eHeRiAXQY2Lico0NQZTkP6xp8XBfvP5kiYx6Qslt+UYqX+Bjhlyc5ru4+XdfhXqL5GuVRdq+GHGea8o+2UKZEHngIUc4TmUDS29oh0DsxREob0ycCsoTwIRow== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:AM0PR04MB5140.eurprd04.prod.outlook.com; PTR:; CAT:NONE; SFS:(4636009)(346002)(376002)(136003)(366004)(396003)(39860400002)(5660300002)(8676002)(2906002)(4326008)(38100700002)(8936002)(66476007)(44832011)(1076003)(6666004)(86362001)(66556008)(6512007)(186003)(478600001)(316002)(6486002)(2616005)(6506007)(52116002)(6916009)(66946007)(83380400001); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: DgeX41P9yR2DSe/FsfyUec6vSg13Bq1Ny7mucsHgNxOtUEvNSNiY4Au5Eu3B/YzyiV2nQRjw0utKhiRnMTaEW65BSljxX0ZvyDyKVnOY+NLkUPVAEN0F0/7sIlMHNO77ufE7XunMsSdSnAcWQDUUZV6JTIkIJl6yvpKPYxa5RR3rI2H3/FZSItNqEDn/5z00L2GXBIBS4iBZxE5wt8NeF/1eNligIqMYg/prCbTrqTR4akRjUUemw8zvn6tq7F2ElzmUz+LgUoZFU997pM6DF86wmujPTNrFPdTouZCt9adoV2Dzp+hXNxKdCK53b/netbtGgvYHpjQRqnbledF9uiVa+tl17Z3iDXaNP/b1klWjyPTtW8UR0jNkoKOK60/sRrg68KUeHcaxQ4371gR/KkGgJYbUauXe2h2gvkO/XTcrJHg3U8O5dtnJWwfOm9kG0XDRT9Yukj4hCXmPs5IalHauB5AwVATJ2I33iviG89V/FdmCYjUz0igDosrqaCIj6tEueIHx5Rc5Fp5CFFyyI+IgxuewRU51jjYIeFJUlaJTfhFRzOl7k0VSTaHtIfdocHcn7Dytn6PiLN4n49x7//a81NJG5YJpzUtZMUCN9XbEpdj+uGaaHSnhVQpDFq4ygVs0joyCu6rQqB8tnuHmTeANUumczun2QAE1Z0rG7C70btHq24FFcN3KD3jHiHEsZtGUg2HW9OaWunzndx0EuB2y2K+sYhgUe6Rt7sfIh6uMYajCQAJCi9XQgl9oEjBdAuoPaWpkaAqffMsSkG4hoT+PAuxBVhUWnV9j8acOMUitz1Yed0o5MLGbnUB4iNHVhJEg1RiAyHDpjuAN0/L1F9Smo22hofIS6OQVYxmSWxKghmJ8ztfIVe6EFiljarc7aZjmRLSIFcKyHaGmenBtzlitNgK8ykmL1fNBMWzKY9hqUSZGcVDGNvUWpN10i2IwFb5HP/eJsrSsK36PLFOPeGgwnTK52UWjJ4GiCXZNYB5/qZuyJXLIs61P70ody2KKmMppWEFtdZ6t/zxSOs7d0eppQutd3uRG/rsVC7R1uT51gbq+hzojwLxYVwVqG08BW6xjrMj2BmAHQMh65vXJY2r/MbFZZx4DBF/0S9wl+OzEwzwGrBwecOvZMhStnl7g+5VCLrm9xwEcfvZ9Uio1ucmrNDKKN4M5AaaKFLqlDBPxQduyEMGXDt1HtuM2a60iNq4Lz5hrC9bPoxvWTAtUR+bjV4B/tiuTgL/DrmhRpD08vfiXzH3MWjAK8/p6in97jlxTSv+ZxuEj7Zg9ToAcU0kc15A4LOEkkQ9P9/EYVSsT0GL6TO9tjoGFAqFkm6snGDwpOcb5CIrShYQ9BO4VZxLivVWDGViMKnsK407+JQSCC73ahy5iBOdBdykl3+V5 X-OriginatorOrg: oss.nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 4b422785-96e1-4d17-ca76-08d979e8a8e7 X-MS-Exchange-CrossTenant-AuthSource: AM0PR04MB5140.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 17 Sep 2021 14:37:22.5091 (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: lqLc77hGz4Z1TvRmZxJUM73v6lR4w99oPXac5NhhWfUapuBMMzyYPxDXCgnwscrVP6FRDVFpso4AqbNWzhSTzw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM8PR04MB7409 Cc: pierre-louis.bossart@linux.intel.com, alsa-devel@alsa-project.org, kai.vehmanen@linux.intel.com, lgirdwood@gmail.com, linux-kernel@vger.kernel.org, ranjani.sridharan@linux.intel.com, Guennadi Liakhovetski , daniel.baluta@nxp.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 Signed-off-by: Daniel Baluta --- 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 Fri Sep 17 14:36:51 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: 12502305 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,URIBL_BLOCKED, 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 41B58C433EF for ; Fri, 17 Sep 2021 14:40:08 +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 BFC57611F2 for ; Fri, 17 Sep 2021 14:40:07 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org BFC57611F2 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 F0E59179D; Fri, 17 Sep 2021 16:39:15 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz F0E59179D DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1631889606; bh=9l1bcZ/sdYj7QGvJx0aWWQuubQ3x5lQ9Ynb+e1f+B2s=; h=From:To:Subject:Date:In-Reply-To:References:Cc:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=Oc6q11d6tcISzY7hJdt6oal6xTJAVlqhoayxEzUWKq0Bzs5UQnYEZWl4TXIzjTza6 aWuUDukcyhoUOt38h+vne8LH5SAim5PgFXVWoQg6PcB3mzUySnCxM+JQEpy6lY/tMi 6XuQXJCtDX0+bVY2pGXewa3pJ24+UWut2mN7SGj0= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id 2539CF804FB; Fri, 17 Sep 2021 16:37:43 +0200 (CEST) Received: by alsa1.perex.cz (Postfix, from userid 50401) id A84C8F804ED; Fri, 17 Sep 2021 16:37:39 +0200 (CEST) Received: from EUR01-VE1-obe.outbound.protection.outlook.com (mail-eopbgr140047.outbound.protection.outlook.com [40.107.14.47]) (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 CDFE0F802E8 for ; Fri, 17 Sep 2021 16:37:30 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz CDFE0F802E8 Authentication-Results: alsa1.perex.cz; dkim=pass (1024-bit key) header.d=NXP1.onmicrosoft.com header.i=@NXP1.onmicrosoft.com header.b="ab2U6SDi" ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=D3WorzLomFbs/74PXeZPG/PH/RCH3Bvz8z38xE/GfCoObLg79Vd+dBuIn7fO4lv0rVv9FK2nVl0DEcGzJdBbo5YSL+ch+TcO4qDTRM45xG4r96aZICIsOKZDnyX6xBd7h/dp5jT7tlDEmKx5DTUPrRqYs2YHAZ+w3xiJkLE2kX2BR92eF8gmipa2YpT3IJN0PCnUe2k8Nr/5F4IGWrZgi8mdsDTAXXhP3F5G6NJNjf82uN9TYxK2su1Ry/iG5+CZGbeAJgAoc0hQ7DMdyrmHzWPs3rId2PX2UwjGEUYE6RbQf3joruDV1Mk6yX7Yjopfv5OsohM2k5PBOACb7G3rbg== 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=cVahSIUErLYZC1mGuWOue0LutrhOaSwRm9hYqLrUeKw=; b=WbTF+PZpRSFFxmj4g7kk4h4dHDYlSwEY4cTzZDrQWIcjd5soM/M9tPA7vwBS021QxptGRAXV3zag5BD9par20Ca+JiIxuGYaoEMJlY+nbHndktpCNqwY25GYste/Fyo6K2Ip1ClP8qYaMWz3mjaA6urQbFy85zbBBGHid7KwZG8WsUZLpWH4HRtq9hzbQvPztyCa5RY2bLTYRVocTy0JU25pLqtEbGA3plOAVbJafg3BSTEWcrCKfvRGsSTBQWRoldB/ZdY+gtU6JAamO0saevA+XevYl+XRBkVhDPzJpIIY33zPqIPm4pi9Hbx9t4TIJ7MEo5LOuquFqnm1SQiplA== 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=cVahSIUErLYZC1mGuWOue0LutrhOaSwRm9hYqLrUeKw=; b=ab2U6SDil9ADoh8zRHipgomUELeW9BOEGIwK0E4p/DmyZMh2Sksj4UxcXT2p48P3g4JGIBxPjzQEt91uXqVxGh0LNFoZL4A/xsWhOMqxR69f6e9IbYslNKPmOtdwt0NVXLR34+WhQT1z8OyXWHkc1IkQOo4drCNi1Ah+D+UibD8= 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 AM0PR04MB5140.eurprd04.prod.outlook.com (2603:10a6:208:ca::21) by AM8PR04MB7409.eurprd04.prod.outlook.com (2603:10a6:20b:1c5::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4523.16; Fri, 17 Sep 2021 14:37:23 +0000 Received: from AM0PR04MB5140.eurprd04.prod.outlook.com ([fe80::dd84:b996:1c8:705]) by AM0PR04MB5140.eurprd04.prod.outlook.com ([fe80::dd84:b996:1c8:705%6]) with mapi id 15.20.4523.016; Fri, 17 Sep 2021 14:37:23 +0000 From: Daniel Baluta To: broonie@kernel.org Subject: [PATCH v2 04/12] ASoC: SOF: sof-audio: add helpers for widgets, kcontrols and dai config set up Date: Fri, 17 Sep 2021 17:36:51 +0300 Message-Id: <20210917143659.401102-5-daniel.baluta@oss.nxp.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20210917143659.401102-1-daniel.baluta@oss.nxp.com> References: <20210917143659.401102-1-daniel.baluta@oss.nxp.com> X-ClientProxiedBy: VI1P193CA0022.EURP193.PROD.OUTLOOK.COM (2603:10a6:800:bd::32) To AM0PR04MB5140.eurprd04.prod.outlook.com (2603:10a6:208:ca::21) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from localhost.localdomain (2a02:2f08:5708:8600:8372:c747:541d:bbc9) by VI1P193CA0022.EURP193.PROD.OUTLOOK.COM (2603:10a6:800:bd::32) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4523.14 via Frontend Transport; Fri, 17 Sep 2021 14:37:22 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 0cdfde8f-40c2-44ba-18a3-08d979e8a99f X-MS-TrafficTypeDiagnostic: AM8PR04MB7409: 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: dq1+Xkxu/pkHN/xTPcDUe0YgBkt2bVZCxINR4faMtTaMdjUk7nxvukepqTt+9IE2xC3pqA3y+6Wul6FpW9A2SslSSVcv2EYxy0FNbw/F1HQkfjyupgJ8C41Cv/Up9LcTLtS5YwXWXHyA9gxURc36y9YF1jNiH1jEz/nwNmU9WgJ6hv3Gs5Y1n8FCiNzeelTPGVKql8oLhJEqFmLpQFqI2Z3i2cmaKp2vNCFIrDZEZkRcYMovx6ObrpVJcqjCjGGmeVbIGKhUUTQj1De6GAC24+pdeTbCjT1U2K+4E4LoxKBo+GdV0vOXed+UvJUM0i3IhKMzTH8X2IRWatdtzEFzUd6RT/nSNsGQwPKPGtNJF5kIRx+YoVarW+125g/jC3XrbCySpWIYVG3ftuIjDS6dCeRhzvnG7UN2lPa/T3YkG+YrjIQ00UfiD8dPJyeH3gTe5ByirO1UV2NnLprTAC136iSrM278T+IQq5xMQKpCtJkGfiQgHn5HUL+GNCqx0h8Dqumb3PBrSQSUBkjXMAV6JNKwlqs0BgJm/LvvtzYRM9EsiPRb3It/ovLNRFagYYuG5PkbAmYyJQRxxWnjUn26PL0LTp33tXFFdfhjuTgPs+TegWLNwfH3o/ZI8jna+GD9EiUIlH2jyp9wtdbYJXruIA== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:AM0PR04MB5140.eurprd04.prod.outlook.com; PTR:; CAT:NONE; SFS:(4636009)(346002)(376002)(136003)(366004)(396003)(39860400002)(5660300002)(8676002)(2906002)(4326008)(38100700002)(8936002)(66476007)(44832011)(1076003)(6666004)(86362001)(66556008)(6512007)(186003)(478600001)(316002)(6486002)(2616005)(6506007)(52116002)(6916009)(66946007)(83380400001); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: 2HSf4Tj1xna/BVa+Ds0HvDAnUA9Fb7emwQVVyO3cyKJaZnrJVrn7LSsg6Q/o7un9Rl8RQCGEX9GArBiwcHdlhtOjHv9w4pDKvRNlswVB+vXLxuWCUuh2gbdI34KX8ArPl3Y2ylGzDfrMTcIrxHcTlSLL/TVl1eZsxOXntYSOGb4j5nUAL7B8M5ri/FtG/vGoohOR3sPaVdpz5KL+XQnnhgCNFgkOyQczLpTOfhT9TQOhTl6zevMMULV2sq9l4ls1fsNYJAwRPje59apE52lAwBeY4zkg3VUE4E7E4mfzv3DCvOa+Sr8gxE4MY4yALlojEexOjxYKty6rBjgFoZp9KnJzqI2RQ0CcZlt/K8Adzjd697RKyQiJ59Lg4wbuJId0bP2jiFEw5H/PsztGxGgaxxNnBYxbjJ1Wkm8NBOde7gCoN34xWpR4d51IrGX/oabASJ1It/4PdWCCxX51xjvyirypPyaO2mVX170N1vrnjlx82nTGUqEloOC8nHop+u5hnDbyPSS8sRhu7NglbXKoeBLp4Vz6PQX1Fnv5FGntWjUOJCq45eMTHhLWeOgi+1MEjXT7U1cl4aprH6bxhv5zADMkeYPZ7lhWVDbmsWoSm133C4vZqjAPcYXeEDYREalGbTXf+iPZ6ByiWGVeA919+ZGda+dcRl1mIYSLKhybpxTp9hXJ4AZaQDgC/ATB1OVZc/Q8d8sZZ8mkIP8S+C0FeWbkmHDDf+ncdxb6/jBGrsINnqACcjxsm6+O2+/j6ZHk999QMtBb4M5Ay3rKP3ePTmGbve7eE8oVc0Gn1INR3+bed3cQAoSc1DemGFOwLPcZqum+yQeikohSu6CxDDyesyZZ7rDi9gPeD5V7VRtxJWjSmgO9tjeRRl1Nm+mhoZ/xpzSx88f1sJf+fwOQCqC4m2ImMnEJCFoi8gva/kgU0ckDNHiFbQxk1Ui7CLPywZDrdWhwrI69baQJKEnna8Eg2An+3UIDLukw9NO1UdO1tsmi4EWKojazvUNvCTdQJXsHn3p+H6NnNaFbTdjqoR19B/el7ZMX67dDFMJQrEpCGawokhm0mPBJluEcMFukn7aq42KaqnuqcO8wbGyT5ic7VC+MqItJO5AUEN7Ml1Ikb6HIXhBwgYH1CZbyhZmr4WIn2BBbtRh/Erv6FaaUxdvX4cgSA2kVscHFWkqfilN4ZcQHBDKOFPZFe7DB+C5ziKNT9d0qjbuhWUP8QKnn44AdYiscwUJevAIwuGPnqQtb/YjSOGUK+x0MJ1A/VvdYwZFFT4Vbe4137jC2V8s85jeeFwIdUe1ySMF5jeezDXMDX8mTdKq19QAss9iZF+Wv5h8NjuLc4FMc7xdSB+0d5y5KC0wO92xTlUdEVWrWXnYG7ZG3ZGBJDjivh7pWc5xQ+hyZ X-OriginatorOrg: oss.nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 0cdfde8f-40c2-44ba-18a3-08d979e8a99f X-MS-Exchange-CrossTenant-AuthSource: AM0PR04MB5140.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 17 Sep 2021 14:37:23.7543 (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: 84RbkMNKzxck1bxYWKNXAGH3Lr8cwjYrsxEeWnboVps6AyTv6/AyaYfRzxietEKjBDQyaI9mAmx3fmesz97NTQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM8PR04MB7409 Cc: pierre-louis.bossart@linux.intel.com, alsa-devel@alsa-project.org, kai.vehmanen@linux.intel.com, lgirdwood@gmail.com, linux-kernel@vger.kernel.org, ranjani.sridharan@linux.intel.com, Guennadi Liakhovetski , daniel.baluta@nxp.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 Signed-off-by: Daniel Baluta --- 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 Fri Sep 17 14:36:52 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: 12502307 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,URIBL_BLOCKED, 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 74658C433EF for ; Fri, 17 Sep 2021 14:40:20 +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 F30E060F6B for ; Fri, 17 Sep 2021 14:40:19 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org F30E060F6B 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 8F6571787; Fri, 17 Sep 2021 16:39:28 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz 8F6571787 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1631889618; bh=cixE2AAWxY97+4ke/CEE588gNpa49NmQGM8HMfsYGeE=; h=From:To:Subject:Date:In-Reply-To:References:Cc:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=TuKlyO1S2PLWxuKmz1/vb5Cige/9xvHoXwAEBJWSROqnv/RSBKPn841gsOHA1jC5R rY8yz5I/OQYgOb5tM7oWPWQVkzrAnQIdFHO3pbDXIyWLY9hDXTKLKn9mHLqaQti+tQ NHjrIlAAkgMhmHZDBhizaB9ALVRZnLdL1726vjhg= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id 2F2F6F804FF; Fri, 17 Sep 2021 16:37:44 +0200 (CEST) Received: by alsa1.perex.cz (Postfix, from userid 50401) id 9B610F804FB; Fri, 17 Sep 2021 16:37:41 +0200 (CEST) Received: from EUR05-VI1-obe.outbound.protection.outlook.com (mail-vi1eur05on2055.outbound.protection.outlook.com [40.107.21.55]) (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 D5B41F8032C for ; Fri, 17 Sep 2021 16:37:27 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz D5B41F8032C Authentication-Results: alsa1.perex.cz; dkim=pass (1024-bit key) header.d=NXP1.onmicrosoft.com header.i=@NXP1.onmicrosoft.com header.b="ftsIYu4D" ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=a5ycMJdtpAEZ29R992MBwsZ6eZMYe4Y56FO4wPkvyr13/zouM1sLfm2AUrqAQ7+PoqtlNIjp9E41ZyENVZI5Kp9MRTxN8tfrzw2OrvoBtLMVz62tdfTbRiftUbiMWGIgELUrax/MkkKKxS1jLKavcTYrqLgJwJineNnXCcnqKq6IOLNAlCLF6iWEf23kjZ28riw9ZgtTd+6C4SjFRrRjHJXeJXGhxVBXqyDTyNVfW8CWzIdbytXIblBsWftkvLaPPgH9ulw7wcKRAlt7aXxw4UeAm9k2CwaEjMcaxx5+5csjBEXtWWubn/TzfaudeenV6EJZguVWxwe60nJb98xDPQ== 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=u9I0bTWeTJRJhAo/bWdeNfgm3cdwkNJBKcDPRlyLCzs=; b=IZ5tcacx2xg+mdNi+ZbvW4HubY2w1TDfTNvONitddy1jMeAn+fqywogEyMSmBmJH4KFf96Xo1YbckbnCasDWn1Hc3pQ6xxTbJE8pg9ulTbQ8mJqmkq6pkfRUoAZNfgszrcffGY8Ywcwics94f1AFMVCR1coRxqrm5R327KtTdgImsxYTxP9Mnn4scTjWgUWDNKJNzxKG+1/FtAZWxtYwhJ2su/0ZLZ/odEfLeTHLVCHWox3DvA1jrRtPY3318cYBN2Hhkn3xaqZqp92pqQ/pr+/m1TUqCyYVzM5C5BFttB7N8Ujv1JsPiEbvK2Sn4tuZvvZPrdIsrC7haA+JcO3f0Q== 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=u9I0bTWeTJRJhAo/bWdeNfgm3cdwkNJBKcDPRlyLCzs=; b=ftsIYu4DtUKK+lFyMAoIX29WqMxBqyBy6EC4QjoGV4Rn/ZWF1EXCLDTo6hX7Nogav/x8dHE3B5nh2R1i77YnNi7rpAGAzceY8IiarJOW+ZUZ+nFoYZlyMB0WhdtMusEZU7wp9RM2z2b8Cqi092h7dCjxMv65vFtEVwhMrfM2alk= 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 AM0PR04MB5140.eurprd04.prod.outlook.com (2603:10a6:208:ca::21) by AM0PR0402MB3506.eurprd04.prod.outlook.com (2603:10a6:208:17::29) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4523.14; Fri, 17 Sep 2021 14:37:25 +0000 Received: from AM0PR04MB5140.eurprd04.prod.outlook.com ([fe80::dd84:b996:1c8:705]) by AM0PR04MB5140.eurprd04.prod.outlook.com ([fe80::dd84:b996:1c8:705%6]) with mapi id 15.20.4523.016; Fri, 17 Sep 2021 14:37:24 +0000 From: Daniel Baluta To: broonie@kernel.org Subject: [PATCH v2 05/12] AsoC: dapm: export a couple of functions Date: Fri, 17 Sep 2021 17:36:52 +0300 Message-Id: <20210917143659.401102-6-daniel.baluta@oss.nxp.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20210917143659.401102-1-daniel.baluta@oss.nxp.com> References: <20210917143659.401102-1-daniel.baluta@oss.nxp.com> X-ClientProxiedBy: VI1P193CA0022.EURP193.PROD.OUTLOOK.COM (2603:10a6:800:bd::32) To AM0PR04MB5140.eurprd04.prod.outlook.com (2603:10a6:208:ca::21) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from localhost.localdomain (2a02:2f08:5708:8600:8372:c747:541d:bbc9) by VI1P193CA0022.EURP193.PROD.OUTLOOK.COM (2603:10a6:800:bd::32) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4523.14 via Frontend Transport; Fri, 17 Sep 2021 14:37:24 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: b11c5c44-260d-4f52-91bb-08d979e8aa5d X-MS-TrafficTypeDiagnostic: AM0PR0402MB3506: 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: IlEuaO/wfeBG715VOOoF+Fx5ua7nbg5Zbxkvn4WsuFH4tw5IFa50aEszM3aTd3M2YYJ3SFoVYpJec9b7Jz4kx5oMNzs9heS4mo2s5B86//lUtZDimmAlWX1YDHzW5DG64An9AEWa5xbGj3OiTFsg9VbGY3ryx3KdraytIdReXznyloyFi0UtWi9h8WCcptF+xFsn1SxV8hoiG4Kiee0HVlBB1Fk+k1lBj9sQ1m7eHHjtIoDWc6tvV2vCDOFIMpdBuSREf94iZ/jcoPIibrPuhprcGCz3dIHMtr3+Vu94ovCmPSlidhoDrGOoJrHIXACrWWjr8u3XGRaZB0lcM0BbNZnBUGLy1N4H+5n7uyXmFj23zXDQUlrpdZ6PLHi73847Nhggv4brPVwMK4jzGoEZs0cW7JMDjO9DKupt6gPWetR+cZMy/m5C4075Gfar/qvoET0c7sfcpJTJ8LpTeZil45dlbMWTkJyD7BA81sjfloRHFSh596cFfk3j1EZZqzre2sQdaa5grau+YkZJOtAIBPSxY8t8kdwh/4q3rP0y9rzZY0UWqtt5A+uplUlbk9xpQazP8ip09DyQjhTubooFvIVc+BO87L4mcIV0EnkfZkj30EC2ZZri3r597pWss/NotyOi4JMN7T3OPMYttPyCbw== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:AM0PR04MB5140.eurprd04.prod.outlook.com; PTR:; CAT:NONE; SFS:(4636009)(346002)(396003)(39860400002)(136003)(366004)(376002)(186003)(316002)(1076003)(66476007)(2906002)(6486002)(5660300002)(38100700002)(2616005)(86362001)(83380400001)(44832011)(478600001)(4326008)(52116002)(6506007)(6666004)(8936002)(6512007)(66946007)(6916009)(8676002)(66556008); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: 7cEICiHH4U6b2IDlKoAegq9OHjPAi6OiLnJnzSOHScoeKG2dmbpuiHimA6AisbqmR6VOrCmUQvh8BvVabmTJ3yphKfOpXKZ/S59rUOAb3s+09P8iAaoBuZQAfNywwr09o2EPqhUjisvpaI8xxuWj3u+TtOHC3scBCmvoQLQuxhPOlvl5ElJ1Lo9xe7/Ke+QwGBCQFRaNQGF0s33ZLfrtMO/qeKOYeFLZYDZvFnVXbMMcBn0sadontbWIkSkdhyesWcbBkrVYwowwmbDrSB+7EC0oJ+xvV07UFQNNj7nZdb/jBqm2Ucecy1FAwEyjlb/XAWOruDle0GV+Eco0f5+gjSNw/wqXwTcD3flHZ7aCb8wj+Yhl3Ohww5MwAlh8RF7KbCd6aZTtG0k2BdQcj5EatKJb1E7ZDkpZ+0Y+L2rx8PRzmeS/Ho3fnupI7jcphNuacvAhR+9Wzb/oki0eyMJ135d2unZFlkFeXzD7SIP3Lfp8nRiARBE3K5Jt4Y9ocWS7SWzXt5ozgmCBco4TuM0p3ycaVnqj5HtwCpy144dI2tEIDepubmer5L1n+OSdWrznMxkj9sVIyET2JUUylA9N2Hak8Z4gympA1jKNuvEVy5PJpKz0ODKS8yTp5K0eZk9n8u2WBa25MhWD4glm1ih5KqIAywRKr3rGKSi7KHRx/uow/D5ImLy7sKX8z7WsBDk7gaPrFYLpIhsvZ8ZFn0rK8fyuIYpz/DwvK81WKj/7B9zwh09Yof/8od4BlLI7Vix5KD9WtOIGvHhj542kNAEGuzVac+kUVVzMKvJ3d7CwqfAEXP/4FZVG5nU9wzOrq5d5l893SLds4l8sIl6Tyx6OvqreFLDXwdhTsz1EI2IskeUAsm5B6QJwX/ulFi78cFbZWGJEls61oQDkpu7HREjfsVZk96Zxq8ZKPGG4I/y9YcLO054pDSEyCR+VSXxZKR83JhlYzIFAYgVOSqi4ETP+Ec3jmhsfRMPVCuUGHaYkLWZg0pY/2EU0TGa1qq7Plu7WKkwXpDNu81I84xF2EBkgfIfcSQG0MPz4usG0iChXne+w0ETmKi8fgOqHbTFXMBiLleXOAAbe/xxOQPFoxi0+LCyMDEUaLwViYj0BPZ3v6rT9z0sULCWIKYjLtYEy3+TWP3B2RCmAB4TKlhfOS+Fkc4L9iJzrLkNoL7tJsA2cfgk0EIGyORyRTlTxg9dAdzkuJVcNb8MtfqdzH1/NcGV0u1zUdOna+gtslwQGvcrlFz8PkSM0vXSGgpNMQvgxsjStGBubq1gjtyrGi+A4SGzjlMcoxGUT5m1OZ8KqHj+vw0A0v9QjwpoPWN5hiKHETYZM6WMX4v2fDXr4rJuWLmyB8kkCysIWktPxihjHiubFjYvk3NMbEMLx1mzinj6d9v5A X-OriginatorOrg: oss.nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: b11c5c44-260d-4f52-91bb-08d979e8aa5d X-MS-Exchange-CrossTenant-AuthSource: AM0PR04MB5140.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 17 Sep 2021 14:37:24.8927 (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: WN3OcuIksCBUmKr49ngq4EN75twbhBLSGz9AkVnBLuiyYQYTdiO/ggGmQ8amqxa563P2pKSQ1bHgHSmswnM8Ow== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM0PR0402MB3506 Cc: pierre-louis.bossart@linux.intel.com, alsa-devel@alsa-project.org, kai.vehmanen@linux.intel.com, lgirdwood@gmail.com, linux-kernel@vger.kernel.org, ranjani.sridharan@linux.intel.com, Guennadi Liakhovetski , daniel.baluta@nxp.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 Signed-off-by: Daniel Baluta --- 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 Fri Sep 17 14:36:53 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: 12502309 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,URIBL_BLOCKED, 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 B8399C433EF for ; Fri, 17 Sep 2021 14:40:59 +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 422D660F5B for ; Fri, 17 Sep 2021 14:40:59 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 422D660F5B 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 CBF231770; Fri, 17 Sep 2021 16:40:07 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz CBF231770 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1631889657; bh=p0fyzhAS9UDqB8CmV8rZsnf/XSWb8WVr6oGaPEKkRdE=; h=From:To:Subject:Date:In-Reply-To:References:Cc:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=iH7e4f4S5s8mVRr/erGRZjSsFnZgyctLzPVMNzjvbwb54D0IQkVTK4ZRJ25UghQ/g G1Fnp67+YWfkSyBAo3jEybfznDR7r10/j6xwHKlOVxYG/ggxFFtBDE9LAvdkmMBrqd 84PSV3RByRmm08gYpWjSWcJbPrlF7NmGKJzt7WCo= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id 79A5EF8051A; Fri, 17 Sep 2021 16:37:49 +0200 (CEST) Received: by alsa1.perex.cz (Postfix, from userid 50401) id 79886F804FB; Fri, 17 Sep 2021 16:37:42 +0200 (CEST) Received: from EUR05-VI1-obe.outbound.protection.outlook.com (mail-vi1eur05on2077.outbound.protection.outlook.com [40.107.21.77]) (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 CFD8CF804E1 for ; Fri, 17 Sep 2021 16:37:33 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz CFD8CF804E1 Authentication-Results: alsa1.perex.cz; dkim=pass (1024-bit key) header.d=NXP1.onmicrosoft.com header.i=@NXP1.onmicrosoft.com header.b="iA1jga7D" ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=edDvYCixkswOXqYnfnOeI+dn86GNZprgd2yEwwfjDJ3gii94t9eQDk3x3eofZIirN3xpkvyrOBwrZbimsO7qrsA+lJKfMBAnCgHq0DfJC2BEwTfHMmzALVHn12t+VLSoz2l3PiidBtYgZIB8P2txdHwHn/dg1u2z99DpiMLVJNs5xlq7DhtY4kOlRm72KbHtJQBSeDIncO11jGLNy9hnzhhuwnS8lgvU9Pjv7U7Z3d08g2HiZBbzzhhMbXGH/N95G+VrlvtWAEbNP2+M04JrXfIim9vADX6Y5esFLKpTV2EUtItGfT+hQzJ5xnKwlIlt8ro8i4UcF/e/p3DM4LDzig== 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=/WQF2bPasBjmZtKnQOGWqlmnVQAyJI9j48QoiDMqmL4=; b=GvQszmZ1XbZqD/Fng0w4C9plZ3TbQtU3F/MsS4I5uRbQrIgKkbSbW3boCrkIwsLOJLi0gYIjZEKLhSYMozfh8vsZqQOnC/ybnOKNBjJjQjspHjaFYh1tV+m80T1iPClWAtYQe534M9VgW7h611dDSPDSKdbdfGMf0vMnQQD6N7oUPyJiDat6Ip2ETRU8oyeqPs6ojElj2gKL2aBWOe117GGh7tEGCiKxWbQUVzD3/lit6WS9kUqqadxNGG+ykjoReDQt5pVPsQNiOQO+Ez+h6wzBhW6uNC7Yv2+3pG7SwmekQolaik+jIsIBaAtyfPAXZqqA+Dsp7BlVGPTWqPjjJA== 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=/WQF2bPasBjmZtKnQOGWqlmnVQAyJI9j48QoiDMqmL4=; b=iA1jga7D2bdSMwXtxyznqMioZCOTEYAODUaCx1hSMpEgAZeLivD1fWEj7+ZstMZUis88zeOhkqS8fJD/dDBEBPDru82vhmRDkm1iXiWKveleTeELY3q+taAs16Lul1BXH4mibBhpkz/7fKegBKw5E0Z9wOS5yzJd9oeIET/vmTw= 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 AM0PR04MB5140.eurprd04.prod.outlook.com (2603:10a6:208:ca::21) by AM0PR0402MB3506.eurprd04.prod.outlook.com (2603:10a6:208:17::29) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4523.14; Fri, 17 Sep 2021 14:37:26 +0000 Received: from AM0PR04MB5140.eurprd04.prod.outlook.com ([fe80::dd84:b996:1c8:705]) by AM0PR04MB5140.eurprd04.prod.outlook.com ([fe80::dd84:b996:1c8:705%6]) with mapi id 15.20.4523.016; Fri, 17 Sep 2021 14:37:26 +0000 From: Daniel Baluta To: broonie@kernel.org Subject: [PATCH v2 06/12] ASoC: SOF: Add new fields to snd_sof_route Date: Fri, 17 Sep 2021 17:36:53 +0300 Message-Id: <20210917143659.401102-7-daniel.baluta@oss.nxp.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20210917143659.401102-1-daniel.baluta@oss.nxp.com> References: <20210917143659.401102-1-daniel.baluta@oss.nxp.com> X-ClientProxiedBy: VI1P193CA0022.EURP193.PROD.OUTLOOK.COM (2603:10a6:800:bd::32) To AM0PR04MB5140.eurprd04.prod.outlook.com (2603:10a6:208:ca::21) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from localhost.localdomain (2a02:2f08:5708:8600:8372:c747:541d:bbc9) by VI1P193CA0022.EURP193.PROD.OUTLOOK.COM (2603:10a6:800:bd::32) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4523.14 via Frontend Transport; Fri, 17 Sep 2021 14:37:25 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: bdec497e-7d66-4b27-e5af-08d979e8ab00 X-MS-TrafficTypeDiagnostic: AM0PR0402MB3506: 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: cuejlCgO5LLgcg8aCBDObKG/YEuWEAguqJq7hNjwKQgJK+bhc38xNpy3eQBRgbPLdRbr65ycYW0R7/ilbrayQZALrhFkJIoodcyp7rDt6eczapyVIzzo/1J3tJT4SkbFQKuAH0PBuBxl/uGhW7E/Gle7W6zaAfE1aTOeuUlMCQgEQ7olMg1BtqOiYYrj7gw244LhOwsyJXsuvGiP1BAmaYvvzu6YiEu4NYvTLp61+74onQJm5hGV8jRvqe+rBaH8Ab/JF846svhtdE+5PfxVWGHBW3m1MYZO82bdo9bQwFs+qm0YbtEa1Hsrd3RqvyVhHmhpHNZQXpzdMyqTLONrpyMidbzHeCokYX3myCi4oO/CB/jWK0FcU09SGWyURGSrSVCIqp4G7NtwpLRRqXHLC5HSBgjNWvbOZNaBKGa4LSL7uYd48TF2jpkODPwY5c+BpHmG1JADTcm23ersgboTwbVJwk5Vjn1Azd1VYlh9OPyCvjuFfMLqbT1Y6ftEtQ7uHmrLenQaGlnzXOFQ7eea9ETxG7Vst3c+i8goikovH8OiMljGfORXiXmchdMSz+eEpPm3Cbx2S9/hbFRS+65/g1vX7OXvVKWbeZS3hnEE9qlOCbik+Yq0E+GtHieabuuQE1EQqEXGEFli4DtUjia3Sw== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:AM0PR04MB5140.eurprd04.prod.outlook.com; PTR:; CAT:NONE; SFS:(4636009)(346002)(396003)(39860400002)(136003)(366004)(376002)(186003)(316002)(1076003)(66476007)(2906002)(6486002)(5660300002)(38100700002)(2616005)(86362001)(83380400001)(44832011)(478600001)(4326008)(52116002)(6506007)(6666004)(8936002)(6512007)(66946007)(6916009)(8676002)(66556008); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: d+zd+WvhStVe01M83JJpnV2atmwf0MIzkcktxwtq746QY/HoJwLAZdylp2IANRFcCcOZRwvJARnZbATTsSddD+QBaJ+q03Y4HgZwqpEN3n2kuVT8c0iFyI4Jrt/8eTd0cdJJWicQsVKvAQ9Xh5WCWsm4ISKk645lRXtRBOPC9NQ84HldAtFyZQHoMq5UKXs1C+EWGfyw25+EOOIwlcF8alKv5lOyfZei4w4uIi08VKi3GscCxoCs6ilWkkC9JoV6IUPWXLGY1iXwW0/JcF7Ns55f4OHYa2kPqsqWR2tduu/Y1WgYIYhF4kErseHvB29EJMHL2+V8L/18FxyxtfopGAzN+uUirOsH9TJBUXFYRQplj14CUmMSz4j5MhvUtCVXBqX698PowWndpV9g93UGeD3nGuMaV5g/QfhJ7TYBS6iWaQVZeXoZeuk5dUxddCimoh6BFLmDtpVko55HrilOFh3krJkxIWNNs3j+7tvp/LhTlEFoDZmy7hqayyAFsJDYwRQAEDbFBeMgm/GWf5bmKv5rc3HQ9qdDKYYC2fvwsrVfHNZFPDKUC6mebG9ejuyUy2WPips5iQIg5D2M1/Sly5NDcA8e+lOCFMrbFNWKrjiAGCljXMZ4Qw8u+qtJcTgabyND4RSfiEzWcvxLEpSXStMsda9Lb3zk03YrW1qmpbvtQVhfnFnAX6FKZi42GI4ngGw0NoIZTG0i2vYobnpZMZ3bgMQ0asjmRBts4cr+ffgOnVfkJsef54PT2aXdkGIy2z4s255FtCzSxyFM+iR6GH4RCiKF1yPMdbKN2DYkSuZMWlg7rRbGgiCFqbXqra0nQStYWbozHQaUeCpzDVV7R5Tfalc7NKXOvgFbCRPqxTWPnTiKj3ROj9VFt9ELuBtkbvqksGF+LF8gR7G5NljylH3o994Qm0Yx6kuJTHfxHLm8kcq1C0a5GxYZooXAOYJKaQUQrd+Pycxq6pxkvwOYbyBP9uRY8572H/fkP5V/oCljfJYD5zqb4mbaBOFEaqObghbN8QsQYBB+zfMFULW+pNIqzfnzbkrdVxKiFFGxjr6+VHHU9SlMTqdwYAhQU0QdIjdDz2tC+Em0YJwfwaI3VCweT/G3/YHAXWJsN/wm6guU3Pre/IRxyHThIQg3R7eXPk7qGHyaLDEOXg+WzfGJYYoGZZ1ndGbsrDSA1C9SeFkhpEG0loWm5sIjf3RS4+SVCm5Oz35xblDFxPuhHsJDdIiyiCtmKvgEogSM44UhfKzdInEQx2rDA8XAZDemZyRX+NCu/YIw7aZQYNj6Qfp70OpDWJFAlEUIoSyyA/ug3ibsWlXSxQaRV9KHaogxJRzMdqIFGRP4ogAXGPomuCPqG9MUVz0dgRLKDI4xOMLPDc/rnyHrwGPjFrElDj1RGDES X-OriginatorOrg: oss.nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: bdec497e-7d66-4b27-e5af-08d979e8ab00 X-MS-Exchange-CrossTenant-AuthSource: AM0PR04MB5140.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 17 Sep 2021 14:37:26.0270 (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: pyYLBYpAVwJv4VKd7wkbOzpx0/xAEvZOy7i4osNZKxajjtZUsC7WMNM4UBXi5DkwKU7wJ+7JjZ8tyIXi+nzdwQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM0PR0402MB3506 Cc: pierre-louis.bossart@linux.intel.com, alsa-devel@alsa-project.org, kai.vehmanen@linux.intel.com, lgirdwood@gmail.com, linux-kernel@vger.kernel.org, ranjani.sridharan@linux.intel.com, Guennadi Liakhovetski , daniel.baluta@nxp.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 Signed-off-by: Daniel Baluta --- 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 Fri Sep 17 14:36:54 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: 12502311 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,URIBL_BLOCKED, 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 58E68C433FE for ; Fri, 17 Sep 2021 14:41:15 +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 D596B60F5B for ; Fri, 17 Sep 2021 14:41:14 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org D596B60F5B 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 7B26817BD; Fri, 17 Sep 2021 16:40:23 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz 7B26817BD DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1631889673; bh=s8gAY7HwJZDe1gye1Io82H4m9te7Gf7hHvmui+oKtWU=; h=From:To:Subject:Date:In-Reply-To:References:Cc:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=DIETaSlhTZDQkhQBKAN+n4MSxX4VF3TwYsnmPKRHNJwpG5wCy/h2s1B++5XgOu3Fv TucKkOfx31S2kgNiB9z6uEvMT0LYB4Nzvf2fEC3e5Le0oPs1ZFnL2d65gtB4J7Hxvr P2IY8tFlCsbDNzwmvByDjSvKOszeDycUNP1QG9F8= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id F1496F8051D; Fri, 17 Sep 2021 16:37:50 +0200 (CEST) Received: by alsa1.perex.cz (Postfix, from userid 50401) id 7496DF80508; Fri, 17 Sep 2021 16:37:44 +0200 (CEST) Received: from EUR05-VI1-obe.outbound.protection.outlook.com (mail-vi1eur05on2055.outbound.protection.outlook.com [40.107.21.55]) (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 25A78F804E2 for ; Fri, 17 Sep 2021 16:37:34 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz 25A78F804E2 Authentication-Results: alsa1.perex.cz; dkim=pass (1024-bit key) header.d=NXP1.onmicrosoft.com header.i=@NXP1.onmicrosoft.com header.b="K1MktcqQ" ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=FdwBKRkDM7XYn5Z8DA+BzAUYA2+gbwBY3w3h/DB7WJ9QRAu+9WHiCmpit8uJ4gJS0UXNhnBHd/tXxq4OMrND31TxCL3FBY123gNwdzriVS+JQNs1BkSjjZa8a71s4e0u6J+dFsyxCrtqkGP9eXAS/ER86C23yk+vuo3RMdyb7vLDwnEOq2kLK+FROcaEE7QJBNfmp9pghTkXMAcEc5r1NdE9gQqXpKeROAmqO0UJ29dzKb16hYbBaiBvdwVjKWW1kk01vY3uqBlyRRvE14xPUmX39e57dqfUEnrBmIV4aBc6Wjn5S5sbrKgOgjPzjUsulOufn3mBZ82iXPwCOu8+Fw== 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=LWD5wI5iOs6NMlLphAnPqTADW6puHMn1kQwbgwbqxHc=; b=StriAxr+nDpF8jG3EyUgfLIZBJnFDFkImBVW31LUbS5/e5cdmoYTvyEopHJGMm1XWDhQ9UBod9cE7yT9icbDk+D+sz+aU2o8bASWkxCDqVnyg3kIeVmERm+bkAz75nDf0IS9In6EjmEQGn/rd1REFJ+L68E8OmMbpH2ZROQ8clFDpofkdZHlukW9PmUx3KHUtEQbONCuGn5QHBlfT1/3kzwcmKfyAnc50Q51FTtaxQm80Fpt73lVUwxhSBCbqE03ZScpEwY41ZbpOsFc3HPxaOujLa43f3nfbsK5B17MRjmwZMHE9j8rGvQm9yt6jTMPvNNCjCTFxkbkw1GWSdEV1g== 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=LWD5wI5iOs6NMlLphAnPqTADW6puHMn1kQwbgwbqxHc=; b=K1MktcqQWK8/51fIYlFVsm08tDx/k4fp7LBo7feV82wFrAPK6pcgdW+EnzA4gapUwFRWCjfvWR2yNe0aYea5L08FyhsvtKqJH/DSpD3rKeX20xszry0anyUPf8cLGiIeZE4aMeVDor9ZxoSYC0qlwgi0PC7reffFVdlr2cN0qPg= 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 AM0PR04MB5140.eurprd04.prod.outlook.com (2603:10a6:208:ca::21) by AM0PR0402MB3506.eurprd04.prod.outlook.com (2603:10a6:208:17::29) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4523.14; Fri, 17 Sep 2021 14:37:27 +0000 Received: from AM0PR04MB5140.eurprd04.prod.outlook.com ([fe80::dd84:b996:1c8:705]) by AM0PR04MB5140.eurprd04.prod.outlook.com ([fe80::dd84:b996:1c8:705%6]) with mapi id 15.20.4523.016; Fri, 17 Sep 2021 14:37:27 +0000 From: Daniel Baluta To: broonie@kernel.org Subject: [PATCH v2 07/12] ASoC: SOF: restore kcontrols for widget during set up Date: Fri, 17 Sep 2021 17:36:54 +0300 Message-Id: <20210917143659.401102-8-daniel.baluta@oss.nxp.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20210917143659.401102-1-daniel.baluta@oss.nxp.com> References: <20210917143659.401102-1-daniel.baluta@oss.nxp.com> X-ClientProxiedBy: VI1P193CA0022.EURP193.PROD.OUTLOOK.COM (2603:10a6:800:bd::32) To AM0PR04MB5140.eurprd04.prod.outlook.com (2603:10a6:208:ca::21) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from localhost.localdomain (2a02:2f08:5708:8600:8372:c747:541d:bbc9) by VI1P193CA0022.EURP193.PROD.OUTLOOK.COM (2603:10a6:800:bd::32) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4523.14 via Frontend Transport; Fri, 17 Sep 2021 14:37:26 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 99efe8d7-ff42-4972-e514-08d979e8abc0 X-MS-TrafficTypeDiagnostic: AM0PR0402MB3506: 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: hrFbFoML3pBbjgMUiYvVATrH/mGH9moIRYFrn3l81m6lPNxxoiuqKZZEfzK++kuRoz+TQyfKAb2kOtxQ+echhPGL89JKxR57sLQeOLWJ3crkm11yWFBMWGb2ChK6rEOmy9Rks2WoowznJbI0pTf0CjnEWb77uV3B1M2yu5O1HW5TViiRcvuigm5lTulteAdwit561TCXxJxiF+Nj8pHxZvhwGQuqrkRcwGiBSk2ed0qDGeGo9W+elMGZivqEeDHO5v7jj9JwVq4AgbKFc1KbKm2kKZWV6vyUnYwneOaEf0mrie2UE293UB3YJHyHVXk/P4DD5tjqeIgTdj+MelWXvcGXa6d3W8zppV3s9InfSjb8endZZ42iRSWXLgSKlmA17mcfX8GZAxnW94wBxG4jNlrQJtGzHZMSLFOd3RArOvcCOQHvC8UYa7ery9DtfKRplNV6WGEqkfR68Dz8Ee/4gfrrJhaHnbA2CE+AEbFAIhX4/jr6iNQfzlSgzIhD6goLRLwE23BGxiP74W2F09WjpZhKQRUjp9wYJjMpB7aDLVPn/y/jlSGgNeh0xWBOD9SUhA6gD85hNWmDxa6SD+10e0GPfhqab6htB3OoRPETq/ewqQKE97bNpRnk3DQZDjGxR1zMU7J9mO6rsB07aD477A== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:AM0PR04MB5140.eurprd04.prod.outlook.com; PTR:; CAT:NONE; SFS:(4636009)(346002)(396003)(39860400002)(136003)(366004)(376002)(186003)(316002)(54906003)(1076003)(7416002)(66476007)(2906002)(6486002)(5660300002)(38100700002)(2616005)(86362001)(66574015)(83380400001)(44832011)(478600001)(4326008)(52116002)(6506007)(6666004)(8936002)(6512007)(66946007)(6916009)(8676002)(66556008); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?q?B59tCMBsD45D3wmytEwJN6DN97Xd?= =?utf-8?q?TjpmMZlacVROnPrYZk0XY3xdeoIokCb+A9F2a5rF3Lw+LlwmPZmRrrAvZAD8YkBPA?= =?utf-8?q?fAget6R4ci/FPWmTbNQJZYcyZrdqCud1ZVPgXHt82cFpZ9o2CdoGWwXzQxq5C7ivZ?= =?utf-8?q?2usVrZ0KVH9Esw1DgM1w3VAOzmngI6jsgT3nCrf24rCGjkE9i0WSm+CtIME3IRGNU?= =?utf-8?q?NPx79vzqBcNROn+l6y7Yh28CnQEfAoYO56zB8QZCcXgFT27UUFdLWgid9ot4DYIIN?= =?utf-8?q?0tp0L1wnwvyI4pbLuglNCLlMX7M8bYDZYPnEamH3UopGbamiNS3sCyswa1yvAkPbj?= =?utf-8?q?l2XAa8p+xAWsOtlfcHVVCdGuwZJ0lJp5Z3umm5evuClhfrK2d2DOuEz8PQ2C4GWpw?= =?utf-8?q?dvSnIuR9/0RnmSc8NK+jwLZ4ofEFB/MmcOGhNLf+9Qh5EZY1ZVqnOqQcoyJ9LRLEF?= =?utf-8?q?YbLR36zSoydGFATo8RAqRYv3WoYeMhCLuoqI0K+WCE1Vg2scecAe7dudF83EqeBan?= =?utf-8?q?qTKEC38cJ5HSPEcUPY1cdSqTjMDoc1NLEXjyfn2iYhIDCDQCnnS9u1c/1foO7iVmf?= =?utf-8?q?Qb41wQ/DOCHEL1rwNG9j/k4FwHnlfXQaunH+Trms6ns7wEHeZDELleG8Oqrm4Cnb6?= =?utf-8?q?l4RQmjPg6nEtsMEuUlQm/Vvj+uY2jLMkTbH5ssl5bs+5sbrLIuIufKNU3LEdWcXOA?= =?utf-8?q?amHWGqmUbzJF40DTmNf+67CakwOVaDCmGMR5F1wegRRcbubGnC0rSQrgVHSXkzwW6?= =?utf-8?q?Qh3SeMjb4uJhZm4DfrI7CIXGwRtwgyD8mSS+ucH3BuKXRvpDpydZsK6hhJzKnw6df?= =?utf-8?q?0ubcMCFGVMxrBKYYq6p+oG4iTiLMadhubv8Ai+6ZdQzAv/ITvIcX+8R2DZralF0/4?= =?utf-8?q?QQJKEm9/oKH7M9KlfSiahvcf59nY2z+YtFvS8u9rCml97bObq4N428FHhOYxm/Yp9?= =?utf-8?q?EQpHuISDKbLZ883ZqAkbMlali/OcL3x2Q3sSxPd1nryNacP8kTCb0WxcRONemTKKa?= =?utf-8?q?L+f7jIz4TRuFraImZ9+TzrsXr6XWxrrSseno8Giq2noxBhqmUs2vV5ihbxtJwRJv3?= =?utf-8?q?TjwZ41KyRjkTHq3K/IOlATq4bSqSml0Xq1NQ5hN/MG31ERkvEGjEcZWNwG5kQK+x3?= =?utf-8?q?SEtx/gqA2jJqqQyFy5LibHDZrZmVLUWVx52T+BaiN49m5/QGsF799OSM1CfEjxdWD?= =?utf-8?q?mgY6Mau04Pw72olTKnSzFB/DPAmCOJdTre8ALTORj2VWZeoL99Dmq5FQ5P4Uk868e?= =?utf-8?q?tPMLKYzDzHel67+EBIYVPMiEBoHwUIJn5UTD4C/SngRg/9DF9jpLr7jK9SEGmkyoH?= =?utf-8?q?kYt46/qIWrAVawU?= X-OriginatorOrg: oss.nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 99efe8d7-ff42-4972-e514-08d979e8abc0 X-MS-Exchange-CrossTenant-AuthSource: AM0PR04MB5140.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 17 Sep 2021 14:37:27.2014 (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: sSBqPNRWcEsodilkstbx/6I58uu3yIlbCeXjhBemLIVeNix1gI+O53LWG3bq41q1nkjksrNkOebdieZJZI/qSA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM0PR0402MB3506 Cc: pierre-louis.bossart@linux.intel.com, alsa-devel@alsa-project.org, Seppo Ingalsuo , kai.vehmanen@linux.intel.com, lgirdwood@gmail.com, linux-kernel@vger.kernel.org, =?utf-8?q?P=C3=A9ter_Ujf?= =?utf-8?q?alusi?= , ranjani.sridharan@linux.intel.com, Guennadi Liakhovetski , daniel.baluta@nxp.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 Signed-off-by: Daniel Baluta --- 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 Fri Sep 17 14:36:55 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: 12502313 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,URIBL_BLOCKED, 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 A44ABC433FE for ; Fri, 17 Sep 2021 14:41:44 +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 30EA9604AC for ; Fri, 17 Sep 2021 14:41:44 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 30EA9604AC 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 A93F2178E; Fri, 17 Sep 2021 16:40:52 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz A93F2178E DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1631889702; bh=vqajXCFSytjLHCFxJLXUYNXQhAI/pU7JAnfdug2E7hQ=; h=From:To:Subject:Date:In-Reply-To:References:Cc:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=gPMVneI7JeXd+nkKR60p4ud9R2qpSO/eK1EMGdlXev/GAAZAqOpfCrwJEfnQsvKYc FFMMJGnCEZ51FXGOZN1FozdO4wo7AzCRQ4wbhQp0nzy38tk+EKTauJScCSbBRliSXm 0J3DpyuRo6PmMf4Vu3ixh/xM/1oEBaqKbYebXkC8= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id 4ED7AF8052D; Fri, 17 Sep 2021 16:37:52 +0200 (CEST) Received: by alsa1.perex.cz (Postfix, from userid 50401) id 44B15F80517; Fri, 17 Sep 2021 16:37:47 +0200 (CEST) Received: from EUR05-VI1-obe.outbound.protection.outlook.com (mail-vi1eur05on2077.outbound.protection.outlook.com [40.107.21.77]) (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 14E46F80152 for ; Fri, 17 Sep 2021 16:37:35 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz 14E46F80152 Authentication-Results: alsa1.perex.cz; dkim=pass (1024-bit key) header.d=NXP1.onmicrosoft.com header.i=@NXP1.onmicrosoft.com header.b="CEdpUVY1" ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=ji4R2+ChPSkQkAYMjHuHs0t0BFieH2LVIQMH9MQx79DqQBOvl1uOqp/ZFAB4+1gzz+H7xCFd8RdBCeOVQdOdL+CXsD19SJk7KpF6ofHm31fUsBdGYKG+2Fj6+8nXihDR/DOMiXiI/XPv8usgVv8VMgmXzP7Qwk0zI9reLzUp15mcd2IDeeefkzGfS1ShIFqTC/gTBDiHZ5uIO6q8P8Z7jZQjHfqFoz/U9Rye41Dfeg7indOV452QyAjCW0d/UCvhOi/OPCVTgSriGBzrs5mGVBn7DLSBrFsnyyMsOgdFYuusl4lzG5V8CVNYUoMxoaCwPrUHVPVqV6OAqC1PddeHrA== 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=HJgweO+E6P8l30vwij3mdxhWvZzkkhGu6buFY+kQgTI=; b=OYj/DPCt0zMZM04YiEMmdztGiulgI9pecjNJCzTCXNC7TURhUjV+QRlBUYJzX9V4SAu1X+1GIbxfL1Gd+UZIlTTrThWmRS7Eyb3kOff4xoGlVZB1QFSnQjpQw4q/RnhnsNAphK7XTK+KGT+W5ZXuCIWUznoUpTGqdSsJNKkDNxBHjSt84syf6HSViJ/RQtHVNHNlBFb+CP3cxQXpXu9Vq62LM9k59KYASgRQZXMBagVGOUP1s47Nzgri/WlHtAKdDrWpZK5yHsdS1xGqqnKEppa5/9VBq6/J2f1N0mYmHcSy7cohyGQXUyeCNTf1twOyDj7Cibz/uTKi2I3lAdzE8Q== 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=HJgweO+E6P8l30vwij3mdxhWvZzkkhGu6buFY+kQgTI=; b=CEdpUVY12Fqbh2aWTKkt9qU5KLk/F0zXT0Zc1/p0fFyEu7G/sb0e7xmcN2XxM8pbn0qUoMT1KO1+TAtZeOE5YePf2FE7aAT4wycBS88q/zixplIhPkiJy5Lo0cOBKyHs5auXTsCm3w4zwC5pvCjjaMXe4C7t9/odE5JIFTSYEE4= 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 AM0PR04MB5140.eurprd04.prod.outlook.com (2603:10a6:208:ca::21) by AM0PR0402MB3506.eurprd04.prod.outlook.com (2603:10a6:208:17::29) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4523.14; Fri, 17 Sep 2021 14:37:28 +0000 Received: from AM0PR04MB5140.eurprd04.prod.outlook.com ([fe80::dd84:b996:1c8:705]) by AM0PR04MB5140.eurprd04.prod.outlook.com ([fe80::dd84:b996:1c8:705%6]) with mapi id 15.20.4523.016; Fri, 17 Sep 2021 14:37:28 +0000 From: Daniel Baluta To: broonie@kernel.org Subject: [PATCH v2 08/12] ASoC: SOF: Don't set up widgets during topology parsing Date: Fri, 17 Sep 2021 17:36:55 +0300 Message-Id: <20210917143659.401102-9-daniel.baluta@oss.nxp.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20210917143659.401102-1-daniel.baluta@oss.nxp.com> References: <20210917143659.401102-1-daniel.baluta@oss.nxp.com> X-ClientProxiedBy: VI1P193CA0022.EURP193.PROD.OUTLOOK.COM (2603:10a6:800:bd::32) To AM0PR04MB5140.eurprd04.prod.outlook.com (2603:10a6:208:ca::21) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from localhost.localdomain (2a02:2f08:5708:8600:8372:c747:541d:bbc9) by VI1P193CA0022.EURP193.PROD.OUTLOOK.COM (2603:10a6:800:bd::32) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4523.14 via Frontend Transport; Fri, 17 Sep 2021 14:37:27 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 8ae335b3-0d93-4aad-0998-08d979e8ac5f X-MS-TrafficTypeDiagnostic: AM0PR0402MB3506: 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: Uq817+mJW2KlvzJy1yBzQxEUm2/e82d9yJ4hGs0J14D7TYmN1D5JnSRc/E6e4xmhr8+f2lwRqarTqU7cnvb3EJbDXI/694m4JuyWaHIItOnbeUhuIOlTbxO+Vl3iymDyL+95ApCHA0k/eKMppKMDIMaW47BGv9guTML1Fx+54srbpyqIf0CHIiTAtL4oHqluSD95gwFULmo720xQGdh3iwPOVQgYY/vH+XxTcXATzRUbHMbp4txklaXWUERJDlHPmx2I7EGFGgWm5DTxEVyM61/ZxHTZXGV4N+I7UxDOLVTkfOtNU8+1MTs7xSXWYd+7BlX6mXIKvMT0Bi+mg62whLhKqw4RdsKiOQo2g8V6NpQMeQoUfBpBK1+Hhj7U82fbB88K+kW+cEn53tHHqfaoe6Dkog9Buo2s1TELiD78zPqREvKJV/bBoCVZ5wS9SnvCtxMOLe+23RxMfttHNdroWwBWPfbTf0PzeI7IKviMcJwqJqpICPaShF9i999zG/XMGJWs9zpk7abE9psGeaJ/Z2B7cNPlgtEnSR+dQRJPcLPD7WK0ZXEWv6HfFiEuZkKTNk1xClnjaPRWT5r5/w7mGQE6DxlXlbrPLXkVOesZ94iECygG7lsZorNDQ45KRaIBSFijylHRQzy1jJSH2HCL2w== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:AM0PR04MB5140.eurprd04.prod.outlook.com; PTR:; CAT:NONE; SFS:(4636009)(346002)(396003)(39860400002)(136003)(366004)(376002)(186003)(316002)(1076003)(66476007)(2906002)(30864003)(6486002)(5660300002)(38100700002)(2616005)(86362001)(83380400001)(44832011)(478600001)(4326008)(52116002)(6506007)(6666004)(8936002)(6512007)(66946007)(6916009)(8676002)(66556008); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: Re3SqUdV3z0UjTZBX2966v3LWnEmuSKvzt6O3N+J3M7rERi/vZ8lqX6SfDvXHERi6RC8wQS5qi17EQwmybw4q1z6l5P5/LCLr1KVr9M6x+OY4ruUR2hd07vXUexx18MfhOun8PgIDywNGUoORt0Tf+D72Wcqci9c6VkYuWO288uMe9jxFRUFz07G+IFPunzU+6BAf+QGNYi5qm1mqX/otzzlAbZ3vG4N3J9kByrkm8QFC9+kXTDbj4CpLKPUkUMTSZ8xSrENaFpvgvBuvq57ZP8rdv3g9rJ7HClRObgsMhdA4B/faRwuWKVSl5DA0C20kfFT8LGbS0J4mDPgwoUzr07AYLmTMjrL85qcqJBbd6EnV4ZARNFm0ISJAMWk9h27RsJOg23ebnquYMwksToXU7WNFgGId+cMjUJ7qCQeewVnC+NF844yKx6Xjnrg1LqPXC4g/RhYUTbo56Mhkr+N+gR9JLa7cD2x0/nXjgQou/XOMbzKnW6HWEEr80f4kBhvAElzXDthMPJoYSIXcXRG1MU/USFU2pcyF6UpXL0paDCCTP+dBlheSbf9n4vMRoxMhVl92qmCoXFgnZbs8KdFn5V5eWIca9+VVLEluc7D54JAQt9CI1UTc0cWzXdQWLUj/6aYrGty0Qtmwp/qnBCNZ/nCq8UWmb0C4f+06n0uUPaTchLQS+EBRwKT/i9r5IM9WoyccVOPh09c3xQa66osJGFHAocHoKp2d/sBsd3vAD9siW9RWV5vpJNLXalmQ5WwhZD2UyItfdQ73Lhmk2cEy7eoitsuUYbDR8JOsuUoE58erRP64YidKJMbSkesnb/qCY6NzYcfRCefb4V7msdAf6Pd6bQ5UoEJ5uqrGU2jXVb5JEolFl4fAxKWvMu+IMMQZNmxBVGlxdgY8vNm7uFtY3Fuu/vbrVhEJKatdFJKWtfuw1PWcqCGuY4g4nlwjD8SeE7nwnvHr1QsnPb7P4ncGhr5KQRzdd6Fx8bGdYKSGmU/VbM3VbTRnN/iQkgHFwKYDfu+w/MmBHZTpRvGrEw121O5AZs4gV1EoFdv5U1vzz5HW9tYTuNq6lSeoSuvAwqsB2dOblJb3q9ZMStiaWO6Dtjkk2E9YNGcLBi4yKYthJAWjtxPWaPH0aVIVifqZWm0hSdDOcf2fe2bgo8oYBt8C0sfl2yrCPgs563/F+9IwCb92uU+0GrhC/pZFgr2smf6sX5jXLO58FhP72/riCAcR4f4LMqA4MdtpzOb/jCKMzDPeofqII2Qe4Lhon4pRSGfRNXMKwg81aDYZm9Sfot6yb/sbeh/7Q7ZbX3xrNIbDsmx7QlSRr0DddohX3lHdRw1+dlUyY6Vof0vBFIWfTJUQd9oDuoWwxdMkQk4pTjVVydW/dw2P0SbR9+jpwhXChnOLgCkCMnb/YlY5bzRzpyUfQ== X-OriginatorOrg: oss.nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 8ae335b3-0d93-4aad-0998-08d979e8ac5f X-MS-Exchange-CrossTenant-AuthSource: AM0PR04MB5140.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 17 Sep 2021 14:37:28.2667 (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: CzOOpL+99YxMcAmBPFEoBr5F2wkJFdhyhKisBI6tajlh2/XJJaZQQVmuPz1lUFKV9TPom3EraKPXecXgJhdjkg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM0PR0402MB3506 Cc: pierre-louis.bossart@linux.intel.com, alsa-devel@alsa-project.org, kai.vehmanen@linux.intel.com, lgirdwood@gmail.com, linux-kernel@vger.kernel.org, ranjani.sridharan@linux.intel.com, Guennadi Liakhovetski , daniel.baluta@nxp.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 Signed-off-by: Daniel Baluta --- 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 Fri Sep 17 14:36:56 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: 12502315 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,URIBL_BLOCKED, 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 022D2C433F5 for ; Fri, 17 Sep 2021 14:42:03 +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 763D060F3A for ; Fri, 17 Sep 2021 14:42:02 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 763D060F3A 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 0E018179D; Fri, 17 Sep 2021 16:41:11 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz 0E018179D DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1631889721; bh=ScX4xCpGBqBIeLCegMfnbuZ5pBdq7whTSBCYmTwho0o=; h=From:To:Subject:Date:In-Reply-To:References:Cc:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=tbGIq1mOJghb52KjccscE6hCwcjNGTzeirBwyAcws+fwSqrMR3SXTsFyg60mNVCqv gw1TaFb9OyjDol/5AKLzdlastWrEFYNEypSKTvWyBba7iH0vcfBF9ZR3hk7Cq9VR8X P3CHUxixFfztTYOJzX+FWknXhonLQs50Sv9FYi5A= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id CA383F8052E; Fri, 17 Sep 2021 16:37:53 +0200 (CEST) Received: by alsa1.perex.cz (Postfix, from userid 50401) id 4DFCAF80516; Fri, 17 Sep 2021 16:37:47 +0200 (CEST) Received: from EUR05-VI1-obe.outbound.protection.outlook.com (mail-vi1eur05on2055.outbound.protection.outlook.com [40.107.21.55]) (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 61567F804E3 for ; Fri, 17 Sep 2021 16:37:35 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz 61567F804E3 Authentication-Results: alsa1.perex.cz; dkim=pass (1024-bit key) header.d=NXP1.onmicrosoft.com header.i=@NXP1.onmicrosoft.com header.b="QvECo/Nd" ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Sf9gIQ4SCV7t/XA/zHUPIBF5bUMc4pW2o+Jeaax+NPQthmIQIuNNkSMoma1678CEfbgQI6nE7PmzG7qKLKQ28RLeUunN9dM6CnyUsKRT9COY7TlDaAwNgo0zN5A4z8Pb9m98y/xboJ6JNJghraQQu2TqtN8rN3D/fdEPIGYnf0XEdVbNyS49Gmq0AzJrJMCP+BzSMFtic6LSO25DW8qDbe3QWkMKYFCaLQrr8fqlLgWP9f2VMJY2B99nYq31dKuNOHjiKwJgp0Eo1YmbP/I4ISiqz3kJmmGVUNJsGASW6HJpvgVFbnBU4ep6spEXBkJczI1Z+1pT1SAbgiLo1e6TYA== 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=VMwkP4aXGxaLC1Drq1sUR0WsLmjziS7Hrag0QbZaLgM=; b=Eq+FuM6jTJVCHkFUXculOs1zlYGs5rfUAekbe1vldVKHFutSC3juSaxf5CfHLp5Dq/iyWrSIXzea9l4th5OgPY6uyWBpqnL88GPXSuFAKoUwhPnyOX3NPe4WzCG0JH7BLj12AfiBxFdI8cXbsNDkbAybxDVhIIupxJFHSF9R1tpT7uUp5y389EgZwO/+pBc9CXRf3uQd3AK85BEmBjXJMNZfqpVJ67hSMKUALb6y7SKSQ8xQyEQ+vNvfTFaXcmRxWuWnhsQokUsxpT/WSAo+YG1rblx87R90P2WF/flr4rUXQi5QV07W3/BNPdtevfh2ClGYk4ebvR96fXu9KTRrmg== 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=VMwkP4aXGxaLC1Drq1sUR0WsLmjziS7Hrag0QbZaLgM=; b=QvECo/NdM7mNSpcXuVDD+EMjcgkyUqXjC9BhMPWmrVC5yNVWODFaaL1qjDNP4V4mprS80EHqoLcnGer73Y4a+Z1eNV2suOKIaXMVu+D1HPfuNrWd1+w6Q1qP8GAr2ABlGBokJCt/12KwAyBflIlOrP1Vbmw+cE2SH6niEugz4x4= 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 AM0PR04MB5140.eurprd04.prod.outlook.com (2603:10a6:208:ca::21) by AM0PR0402MB3506.eurprd04.prod.outlook.com (2603:10a6:208:17::29) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4523.14; Fri, 17 Sep 2021 14:37:29 +0000 Received: from AM0PR04MB5140.eurprd04.prod.outlook.com ([fe80::dd84:b996:1c8:705]) by AM0PR04MB5140.eurprd04.prod.outlook.com ([fe80::dd84:b996:1c8:705%6]) with mapi id 15.20.4523.016; Fri, 17 Sep 2021 14:37:29 +0000 From: Daniel Baluta To: broonie@kernel.org Subject: [PATCH v2 09/12] ASoC: SOF: Introduce widget use_count Date: Fri, 17 Sep 2021 17:36:56 +0300 Message-Id: <20210917143659.401102-10-daniel.baluta@oss.nxp.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20210917143659.401102-1-daniel.baluta@oss.nxp.com> References: <20210917143659.401102-1-daniel.baluta@oss.nxp.com> X-ClientProxiedBy: VI1P193CA0022.EURP193.PROD.OUTLOOK.COM (2603:10a6:800:bd::32) To AM0PR04MB5140.eurprd04.prod.outlook.com (2603:10a6:208:ca::21) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from localhost.localdomain (2a02:2f08:5708:8600:8372:c747:541d:bbc9) by VI1P193CA0022.EURP193.PROD.OUTLOOK.COM (2603:10a6:800:bd::32) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4523.14 via Frontend Transport; Fri, 17 Sep 2021 14:37:28 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 29942ba7-39b7-4e15-5491-08d979e8ad06 X-MS-TrafficTypeDiagnostic: AM0PR0402MB3506: 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: PiXPeIu4ejo0RtAOILgDpeHgZIJGC0Pk0q+HJyt4CTDKSmFDSLVx30/dMTjZrlYABa37dRwjaOr/GkelImlsH05Z8vPeMIU9ahYjcVnaKJGD8A8lSjlJVuxxrBxncKnKIAuITRKdh63FC6GhQe2QRz9w8cPfTQlZP9A2ddcQLIHegzr9MgwfjhpiLsDJaMr+q3gGzl46PUqlyMvZ7FGJ68DLux8EO8Y3bbMQxsKY4gVQX4q+Ahmnj71cG6hxe07dkhNJcxr192fjNxGRpQRF/lg7WrkI9fc6HvH2XRLyCrFm/rdVYNC/6QzbvySvp7Jw0JMQyOy3PBsyihUxUHREuu7qW+uc88qR7mCWfd9AxR3Xuit+lGr3jkhGhpoL21m3UbVnN6X8VqgcwKSSrTdmdzZZuYE/YTyqykqssjhoVAb/eaCoPunAo/qODMd52IBHZN/jgBhp1RwFMOct1x7Q3llAUrYTjW0plPgbGxmL7jGLmHjR8cMeUCvanp5WngOnkX/4VQmJkgSvKjssn8bHdlXDGErWI3HwdTebPfmREHAsv8jt1JrA8PpP5BMh7DvU4WJBV+aFiKfXrrKx5gmXbyQ7eufze0QAeKmERNXLuakvBX7ewtPRmBcZhHyj/DE8STVc35NZ6Ff1B3j5WH8eKg== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:AM0PR04MB5140.eurprd04.prod.outlook.com; PTR:; CAT:NONE; SFS:(4636009)(346002)(396003)(39860400002)(136003)(366004)(376002)(186003)(316002)(1076003)(66476007)(2906002)(6486002)(5660300002)(38100700002)(2616005)(86362001)(83380400001)(44832011)(478600001)(4326008)(52116002)(6506007)(6666004)(8936002)(6512007)(66946007)(6916009)(8676002)(66556008); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: bl8E1WwFr62qK2nnqFvejYj4A6oiSHSm+Y/HCmXRmODm933EypU5xczU05IAikKGxUama7673D8F2whyrcjrWpopFU0esu2fKbmjStjfGEPLuZgPfvUqVXBlK+Ht3a19sPW/f1jfOHeM7q5YqFT6LXBhmgjeQ0os4J0fsGGqnyMokUH8fciQXXgQ2SFqFYAeaGmtKS8v2Xu5wPwNviFh/K4KMVByg79aXw+o+jjDwEuTgak7aIWqisksQzOmiS/FILKvsujr9Xy+v7kiZ7F5HhxKTvXG4N6XGiRuTWDbsnSNXGe5QxWQHFEyJn2wuuvxAlwBMOqT3rsBPyQPWulEVBwMvSU6fFytOLSkBdynm5JSjh6EoXmV4e/d5hOwFX2KjW3q15yI7Pb+qHLAvfhmuMTf2gkaVNgvKEJYQqtnM67nrC6c2oteH0PT96OOvYExQMf7klfTUXz7lCbQnoBOcmsnflMMZ4LRruMwfT584XYXomKFyXmC0B7djr+i/AKRHDO+dkMHtZB9cR3PBeYbYtIPp81sO9muoMygor8F45LEDmluUOg3vpvNygi169PbbKpRBD9txCgWL53bmuuH2vZFDfrtTzmtOsIlXmG9U9I0DUyA/f+6NRgv1CW0/N64TmzHfndGxYeUVHsDFiE5hyvnEYnv/SGu5Q2NdFmWAloex0JyQ88/OFP/elWoojv+4jo7AUcBgrgCC2Q3tP0LxTe0qJMnC9J+VnBQR/Zm0UxVWoIdWabSYI+dSiUMh5ZIN72edPt0NsuSlPqstezi+MkZT7F8PECtnGdy3IOV2mABemU3650n59aRQx/n19calve6gkhth9sFapgNcWPGVjXO7rPUzD8EKqRsfssoy8yI8szHmdBiwBt8EIsK8zOf6v1WJjd6n1sADY479ScYSIWpS/ZEkrjRCJqPKkAkj9dd6JZ5zQg0yBR+H8WeBq83sHkE4hUlXkxGpzasH42F1TQgjB08Xcg3FKHrzd2+7stTqm37g45ihfkQhkh8gqxSCKdBIgTMqiMWs+A2WnTNxysqi6mEtrhwT+sWYI6Af+4L1ejXxtqjc0wAxwZAr+CZPbaa1d6rctzf620YC3NiRuRBcUqxyP3YDb4XPL4mAErulbnNcmsRT2aYc8PL2GQx028fpJUmSp2ETwF2mGz2FMH9jIUDFIqQojeY7Makmt6N9fQuwRWgh6465lMlu6fjf8VNxSZpRzaAG30vqrX+j+y3iLwSmI+WOpG+tl8ywRsAMxuuslQ5bjCB27z9U6e8jN1yJ5SCWiMr8tc0goNUx5uQO9L879Z/4MuvqBjefKG/yxiviVWD0KbX2ZvZYVYBrP4SmtbQ/L/0yz1P+6yjNqL3zBa9pLIgpz8/Qqp+a4Dp4X1oKK3tfQGvJjL5tSnOJclgEe4u6sCZqqrHLZWwOw== X-OriginatorOrg: oss.nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 29942ba7-39b7-4e15-5491-08d979e8ad06 X-MS-Exchange-CrossTenant-AuthSource: AM0PR04MB5140.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 17 Sep 2021 14:37:29.4071 (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: Vz8ihlHKlsZ+Vx0KQoR/+g6dL0FovCmEW5lDkjaDGE9rl3r14Gz35jUrzYSZQycGw3GC4s8c+8Bmfu3ezvJyJw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM0PR0402MB3506 Cc: pierre-louis.bossart@linux.intel.com, alsa-devel@alsa-project.org, kai.vehmanen@linux.intel.com, lgirdwood@gmail.com, linux-kernel@vger.kernel.org, ranjani.sridharan@linux.intel.com, Guennadi Liakhovetski , daniel.baluta@nxp.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 Signed-off-by: Daniel Baluta --- 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 5d41924f37a6..ecb424161e80 100644 --- a/sound/soc/sof/ipc.c +++ b/sound/soc/sof/ipc.c @@ -719,9 +719,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 Fri Sep 17 14:36:57 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: 12502317 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,URIBL_BLOCKED, 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 9DFDCC433F5 for ; Fri, 17 Sep 2021 14:42:16 +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 25C6460F9C for ; Fri, 17 Sep 2021 14:42:16 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 25C6460F9C 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 B010E17C4; Fri, 17 Sep 2021 16:41:24 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz B010E17C4 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1631889734; bh=PZ2T+rBZT7AnFDzrnievbwX8PoJLiYXoBvH99ALl728=; h=From:To:Subject:Date:In-Reply-To:References:Cc:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=hUWXHl5gBtfO8e8oacgbljVYgmewxBOXCGA9MbgcnI+a2LFJLlFksjoWFXBPOQl/j DduYZPgQmxfq+fy1KSDV3GUrfA4mkSs/3iPFVzpT7BdrAa+QrUIAE9fMWMazwf5j6A fVgx9UAMUbVCfGyRTvvxQeIr99CxK/quwlWROyRQ= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id 8E8D4F80538; Fri, 17 Sep 2021 16:37:54 +0200 (CEST) Received: by alsa1.perex.cz (Postfix, from userid 50401) id 4704CF8051E; Fri, 17 Sep 2021 16:37:50 +0200 (CEST) Received: from EUR05-VI1-obe.outbound.protection.outlook.com (mail-vi1eur05on2077.outbound.protection.outlook.com [40.107.21.77]) (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 4A492F804E7 for ; Fri, 17 Sep 2021 16:37:36 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz 4A492F804E7 Authentication-Results: alsa1.perex.cz; dkim=pass (1024-bit key) header.d=NXP1.onmicrosoft.com header.i=@NXP1.onmicrosoft.com header.b="iCqAib40" ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=S2kilXRUWXfea7Fk0QxmPZtqzaYTPwi84XOi5psGdPmIN8dH98aZtrjRI05ikd+YMItf0+a4fmdMbBb+sKrHK02jc5qI8X8Arbp7Xhoi4J7YK8sd9ufmfKuCoiXFgopsmlA/lGGuduFLw5wkmV2k4SaTUYIShlp+dW2rwoG9HaZM+n/Lues8i6zMjMPUo9OR1ADsSURys2mF9nnupwe4olmSHkFZfHC2+W0aG+wyV/gsP+FEtI4rAOaWjwN6b0FyNlRx8AFUmhGVPUXf5Ymw+gnYjNcWYxznYrR6F61zbKoAy8DS7/EhjOJE04V3d4F6DlVGVLgg2Qz5YI9ZcESO/A== 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=ksNcVA02KATYGGBxMlEBAHh4AAZmoZmEtRc90ZiMx3I=; b=M30FE3AL0/aHFKYNP9OdXfxIqDXWpQa+UeOGYXdj1ZKzPsT60/ZaUoV5gM2hHWYpHw4DoNaabV3a+wDsGdvmJKMe0oVyh6/MVPoQtWYVMGSkg7H0g42sRXscJoWBHol3qAZZtsNoHhi6BqNesCslAnHYd5rfD6BWeXzCPDun4k7UegcEfj5XwiCAzmjX1DE7rO20dNCzTWmS/z+yWAu6/Qxx9NjQ+wJhFNA9zqzvccD36veqJ5Av9PY0idInIywIbNxLYamgD5uVTPdfuIFZevEljrNlPy4CD2se4wpLeDoB/qbrFOueqAxFir7KWNnWUXhPq/7YpBhMp7vO0hjBgA== 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=ksNcVA02KATYGGBxMlEBAHh4AAZmoZmEtRc90ZiMx3I=; b=iCqAib40ftuYP7iv0NStDNbEKdrC33YmnsHY0KK89p5mROzkb3uq6FKXYoQEDCKyLWYaQAwrAgQMvueVGidAfccus0S3OUMJ3oQp9Ug8Hk7qIvgp3pxk5ORulsRkdkzsvDG+QqNFcq/FWUGL+pyvTEoQlZNi/OMX6TAAE6dC/jA= 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 AM0PR04MB5140.eurprd04.prod.outlook.com (2603:10a6:208:ca::21) by AM0PR0402MB3506.eurprd04.prod.outlook.com (2603:10a6:208:17::29) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4523.14; Fri, 17 Sep 2021 14:37:30 +0000 Received: from AM0PR04MB5140.eurprd04.prod.outlook.com ([fe80::dd84:b996:1c8:705]) by AM0PR04MB5140.eurprd04.prod.outlook.com ([fe80::dd84:b996:1c8:705%6]) with mapi id 15.20.4523.016; Fri, 17 Sep 2021 14:37:30 +0000 From: Daniel Baluta To: broonie@kernel.org Subject: [PATCH v2 10/12] ASoC: SOF: Intel: hda: make sure DAI widget is set up before IPC Date: Fri, 17 Sep 2021 17:36:57 +0300 Message-Id: <20210917143659.401102-11-daniel.baluta@oss.nxp.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20210917143659.401102-1-daniel.baluta@oss.nxp.com> References: <20210917143659.401102-1-daniel.baluta@oss.nxp.com> X-ClientProxiedBy: VI1P193CA0022.EURP193.PROD.OUTLOOK.COM (2603:10a6:800:bd::32) To AM0PR04MB5140.eurprd04.prod.outlook.com (2603:10a6:208:ca::21) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from localhost.localdomain (2a02:2f08:5708:8600:8372:c747:541d:bbc9) by VI1P193CA0022.EURP193.PROD.OUTLOOK.COM (2603:10a6:800:bd::32) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4523.14 via Frontend Transport; Fri, 17 Sep 2021 14:37:29 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 92e855f5-8ab0-450d-a745-08d979e8adbb X-MS-TrafficTypeDiagnostic: AM0PR0402MB3506: 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: hrFDMa09IKc+IKLFuXAsBS/d7OvpvLhDLjormxAcAfu5ozDvg+EpPgkUqYgg484wDGZZHnSVe/sPndyrrdJuIk2IhzS8vdeWC4fNQJVKaENJLUxd8Cjsm6q8fSEwfo51bquITOODG7C+Ck8N7dB7IhPWHc2YAwgePgyzffN416U6gIj5V3DWzi2gImNTd3XYia1Wy37X6h/HmE9GubRNshVu8ThCpt++wYtkmD/1V39q7Vz+GqN5PrB2n7rNErEuN3jGW+Zup4bgqELbQyovY5yhkrO1QSf06NIECybTpPtiJsfxOHImQGW+f0IF+eqfy08Ky2I64mY0RcMe+ucRDIbv+JH2zjkAkpAq3mZAGNDYl1suHih0XsTAB/M2Pp5EE2nDdGmWcuHbQqI4B0e1OlhRnarWMMMB9yI9XfE4vHHdf/zyQ0yxwKD/bUz12gLH1QnBpaV2QyBlHuj5Gu+bEiKfzzIr5P9r68qu3y0rFQwr9l4zkM2o/t1v1DReflgUVGamFGduDFQxxajhHXmDwOsiD+CO14I9GyDIHyPPskIsUSsg1WKcFfVPrSHm9sEd14xUo2WYromZs+cRIksbMw1lwGASF+VhJbViDmubEu+9jRvgrOnfD3njdPpSqjx0Vzoy6C+iyfQx2f06ZBHuVA== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:AM0PR04MB5140.eurprd04.prod.outlook.com; PTR:; CAT:NONE; SFS:(4636009)(346002)(396003)(39860400002)(136003)(366004)(376002)(186003)(316002)(1076003)(66476007)(2906002)(30864003)(6486002)(5660300002)(38100700002)(2616005)(86362001)(83380400001)(44832011)(478600001)(4326008)(52116002)(6506007)(6666004)(8936002)(6512007)(66946007)(6916009)(8676002)(66556008); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: qZjg/AcOkkdW7k58vJTb/k9XFpumBR7f3FKj0zJjk0LbKZqG1qDQIXj+DCXqProuiBiQ5Cx/6uTcW+f4a3dVKjEEqO2sfMePc1EUm+FQVQPnoOe9T8CQcBwY7jpmGtZ4hKu/qrST4z29gm1Lvx5haaW0RVJp5FjF9NXbn5HAHQ26wfVp8XuPCbDKSeNxMNknarUFNbu2xwmpYMiXXIu6SZ1eWb1CLwCEIowNa3uM+X3vyUxOuY9MTnf+Dtuve6zJKYrvG/Di9KCVTnLeSErP4ZT8PUs4tfeydzwEb5+kZIC1FaZdciSPnS/cOmH8Rxl1e71Q9SbIUz9hICrOsZ2vsJ9VULzmZDU3ruOqJEoPx3ldoRi7lWxfjbmnviE31xK5XK/86qiGCUnzmn8lxBiO1J27h/WuQFFE2+3x9hUokwbTL3sSWYiBI4dJzXLEIujr3ZJ4RAy2qdGaaGke9pH1Dq05pK+NhvChizRrFiRpGLjwPq4b5/LEPyTfk66olOpMHGM2Pw/ng7IVBV2yOg+lHDF2ImLj8BU23rRYWnXjQKurt6Qg/VDztUkg/PpSCBFwqgcpD6ZFMDxWnmFbE6uKcpi+EHTj8AACpAf3DIcTKEEMT/SHvmyFEkm0XO8kWYZfHMRQNLNlzDW9cHvCRpFNgxTWZome40JduV0FBAlZH0IBWgSV37iQoF65+VQt4accl5djkhUSUan9zwDyI5FUpDaCfaKgk7Wa+wUZUGqOPY9boRT4QZWNbi60hmHerhKwmL/HPggunJhg7TJ7YDmqGXIhWRgJ5A8wb++3M20igQoKIZnE9/zoTE0xvBO3GhCQZbMFeRuVwgQQWqPAxDbqezYa5UGFER7KooQALRASlFsWDz6EzhKLbOorlZpgBQ1bVnI2IMhNvvJLsCln7ZpM9AfLg8LccsQqHXf2K4SE4vDQCpZHB8C933fmRJyQkftfXVHQeVZ0vyp+x461rtRpB8KI1SXwagmBTCQJZ9h/SE/BEsursGrgtLr/VpIJAJM0ocrg9YPzPWfVbjzTft3l5JEm7InW2IKtp7ajnaG4dsMZZ+AxDchvC9tssZrgckeLIOOo2tNfIM61gx0PbF9b3sKrb7eBoOs4RRLmp9QB6quBZQGCsZOGKdJmbqnXdTMcxX7zqhZ5fB+Fhc3QFuuhE3CMR3ZgbxgP1Igj2XAcDPwPTomFEgxAT5HjvpPgfZdHS3sIcx3QrcrhkJCOTpvYlzxYEkIdzSLmsOTY5EfTwIM9zWpo6MH0zR+mZkKo/2H1yK76S/02H8IrJklA/D4qO8l/QakSoy8YmKgE70MrGgNHvUABSjkz7F6XKZz7fiXG0asDbfvclF7RZ4B6ft4zFeieMtamfXvN4MtR3gWR7SQgkI8BDLiUHJ6rzKBGMy7ZRTRO5elKqMyRBVfnD1VkkQ== X-OriginatorOrg: oss.nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 92e855f5-8ab0-450d-a745-08d979e8adbb X-MS-Exchange-CrossTenant-AuthSource: AM0PR04MB5140.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 17 Sep 2021 14:37:30.5015 (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: eqIwQR4A8XqdK6y9QKClBlA08H+4gLzFLwu2YXalf0Sb5SydZtpyH9tLuwrXdHOayUrP6dGEftSMaRZ5vVupyA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM0PR0402MB3506 Cc: pierre-louis.bossart@linux.intel.com, alsa-devel@alsa-project.org, kai.vehmanen@linux.intel.com, lgirdwood@gmail.com, linux-kernel@vger.kernel.org, ranjani.sridharan@linux.intel.com, Guennadi Liakhovetski , daniel.baluta@nxp.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 Signed-off-by: Daniel Baluta --- 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 2f54a659b78a..d1ec8bfb6002 100644 --- a/sound/soc/sof/intel/hda-dai.c +++ b/sound/soc/sof/intel/hda-dai.c @@ -155,49 +155,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, @@ -211,6 +232,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; @@ -229,9 +251,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; @@ -287,6 +313,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; @@ -321,12 +348,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; @@ -357,6 +388,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; @@ -372,9 +404,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; @@ -406,47 +442,51 @@ static const struct snd_soc_dai_ops hda_link_dai_ops = { #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 Fri Sep 17 14:36:58 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: 12502319 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,URIBL_BLOCKED, 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 B83E7C43217 for ; Fri, 17 Sep 2021 14:42:40 +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 46A7060F5B for ; Fri, 17 Sep 2021 14:42:40 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 46A7060F5B 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 C1FAA17B9; Fri, 17 Sep 2021 16:41:48 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz C1FAA17B9 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1631889758; bh=fclPWLiJsYbhUabC55az+uFqaJAob0f/y6pXhhwbCfs=; h=From:To:Subject:Date:In-Reply-To:References:Cc:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=QvyjcDkjYdggy0aFv7tcSKjNPM3sr8y7CibJLwBsVPI2FrGh6eD0D0OrS3l4MbU0f XasvIBX5W5V5FExF42XmkGYCGoa7zFMeqUMFER7rXP7FOyGurUSFKAgMllEw/8tV7X wSZX/7QB9NYQU3Bh+n6XF0VVvYE8PIa4NXTYli8M= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id 6F4F3F80539; Fri, 17 Sep 2021 16:37:55 +0200 (CEST) Received: by alsa1.perex.cz (Postfix, from userid 50401) id B4BA8F8051D; Fri, 17 Sep 2021 16:37:50 +0200 (CEST) Received: from EUR05-VI1-obe.outbound.protection.outlook.com (mail-vi1eur05on2055.outbound.protection.outlook.com [40.107.21.55]) (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 8DBF1F804E6 for ; Fri, 17 Sep 2021 16:37:36 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz 8DBF1F804E6 Authentication-Results: alsa1.perex.cz; dkim=pass (1024-bit key) header.d=NXP1.onmicrosoft.com header.i=@NXP1.onmicrosoft.com header.b="GxZpmTfd" ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=XQQwobLke80zb7/rUi95lW+/7BG5yhzdlDkG1Ubzm87TwCTVZFUcybr17W8m1v6ImXYmNSWdHQlGwbqhKvHA+/KVmINlTtN6khWgJch1UMXhfJbq1yiSUx7MAJYdmz2Uk4w/K+jsHc/SV3NzgA71CHTkO6YEpX0ByjJ4eY/ZrM7xT1u8sXNCSQTz8WcT6WyiUrwJOoBHYsK1YM9y2VSdes1xyKn0LfRNGVk+B7QpcNATaGHAH0oyysbNwGHUTYjBB4oQ1BwyOJUZTJSGGr/YiYeswmnPvk3111wxRikqBK6Ygn9I0QprzKKmKbYEWS3XwzWtt8rrKii61s6pA3+Exw== 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=JIKmnZ7mmvQLoGnx8A+NeJlfPdtjLcOHzyy/Qh+0oSE=; b=EdzBmMcNzhEoz9u0RcUBeqOYiUc0DMZgl+RbSgo/LJcreVeKj//Qraj6VtfG69OGk56Cw/p596iToUeIsBLtX+Gv/YxQDZ7q/CWyIhjxUxXRnOwZ4tLB1zRYQCR1d3gPCdnq7jQmLg8XBeruMzAUxhmzwtxNx+IfclR/rrOdNg93k29PsqDj8OV8VuZdX1LeF/jbnALpCjrI7V2ZA9tWoTL9B/MP6p2lUdHwMsBKpVlKEXbazNcDpTIrsO57MYMkMPgQqm4JO1a7LH0JJGd6+LOADMEHPPCq9JYTP7K4TXwJgeFMrVtCoJT23Hs+GmGqHSqVl0azOnV+oi0hs5LIag== 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=JIKmnZ7mmvQLoGnx8A+NeJlfPdtjLcOHzyy/Qh+0oSE=; b=GxZpmTfdZJ/UzviqK94NO4J9pdLiaNzklyUDo43pwok6KgPzvEr0DGBtU0O8+7oE10spj2t5sAmpA8rDmWSwB0F+SMvaUuByFxHXb7wGKUb6tZ+fFVwYE5VHTeyEyLBuD55eCli9uSGnesBB+dIZQ+YyWWr+4AYjIpO2ZJEe6oQ= 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 AM0PR04MB5140.eurprd04.prod.outlook.com (2603:10a6:208:ca::21) by AM0PR0402MB3506.eurprd04.prod.outlook.com (2603:10a6:208:17::29) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4523.14; Fri, 17 Sep 2021 14:37:31 +0000 Received: from AM0PR04MB5140.eurprd04.prod.outlook.com ([fe80::dd84:b996:1c8:705]) by AM0PR04MB5140.eurprd04.prod.outlook.com ([fe80::dd84:b996:1c8:705%6]) with mapi id 15.20.4523.016; Fri, 17 Sep 2021 14:37:31 +0000 From: Daniel Baluta To: broonie@kernel.org Subject: [PATCH v2 11/12] ASoC: SOF: Add support for dynamic pipelines Date: Fri, 17 Sep 2021 17:36:58 +0300 Message-Id: <20210917143659.401102-12-daniel.baluta@oss.nxp.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20210917143659.401102-1-daniel.baluta@oss.nxp.com> References: <20210917143659.401102-1-daniel.baluta@oss.nxp.com> X-ClientProxiedBy: VI1P193CA0022.EURP193.PROD.OUTLOOK.COM (2603:10a6:800:bd::32) To AM0PR04MB5140.eurprd04.prod.outlook.com (2603:10a6:208:ca::21) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from localhost.localdomain (2a02:2f08:5708:8600:8372:c747:541d:bbc9) by VI1P193CA0022.EURP193.PROD.OUTLOOK.COM (2603:10a6:800:bd::32) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4523.14 via Frontend Transport; Fri, 17 Sep 2021 14:37:30 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: bec98576-4745-4c4e-cbb7-08d979e8ae59 X-MS-TrafficTypeDiagnostic: AM0PR0402MB3506: 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: xgDgXHkXpWFi+pDg/VjPKS2737+eNRxNl3/COvdvSB2E//0FCU0UZ/UutqOrh1MaN5zM/WyFu0RlUOHaunXdNwgu1tlf74tmhtfrXufOjQ1Kz9WxaEgEWwpGb2PKPhE6TfhEzkLyqJxcxMFXMkfwRKRfOq0isyzhUaMo6WYrnyrIWXpDMmQrSU1Y2x0Ck0mQoj6lb7RF/+lPTEebjot94agkPwQcCc4ji2Ev6SL5bzxOFL96BARC24h1yX4RIrP49nr5MpAsUKtSaXqRD73WG+99zO5OJeN30OuQmjk5Z32oMPyQUfr12ejKd350KeRuPd70643Shh0z5iy7WeZlOCIfnFTUJuGzaLT7ymXCyvbgJ89+ctV+LA77IvdvTGNwG/8JgGJWv/vnS4OCXX2TE3YvCGy1rl6YE5p3wVG4L7IH6wH65Y/bkrWZfsiUehREq5P+JGPFzZ/s0xyy2G473t3l+VNEhSRod+53UHuu1Igx20S7V4lPDrtTq0hXRCLax7EGBLDQBMWK7AZiG2Db9fxtMcOX5RS7JS+OYfghyseZV9Yxrj2wYzAoNHo0tA8Nrb2wh/0YDRUJYJuOBU+Cm0ZZCqjNGWuSjaKfkAYYf78gC/W7XS4qlN93vh29sfx6rUqOriFNIyaK2zrwB+Eg+g== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:AM0PR04MB5140.eurprd04.prod.outlook.com; PTR:; CAT:NONE; SFS:(4636009)(346002)(396003)(39860400002)(136003)(366004)(376002)(186003)(316002)(1076003)(66476007)(2906002)(30864003)(6486002)(5660300002)(38100700002)(2616005)(86362001)(83380400001)(44832011)(478600001)(4326008)(52116002)(6506007)(6666004)(8936002)(6512007)(66946007)(6916009)(8676002)(66556008); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: s12+q606+6GOKcPJ1WomZ2tSRuuBcJRDGFgyacDjOYVoi8l/WbuP/M0sxz/DPbcx+QvFXPFC2lCuhRGk9SdJjOxJUHSpgyIY1A3bxHmbo3eKsJeHezPI4XjL2g96t88TbmmnG04IzhQIqu+RxIlH2HBAeLEWE8dJru2fX4iT+SPtVRJSn0FtqRKDQoEvbB1kOPLzrz8AoNVN1PsBpS7d3dZemLaWBJ404BmwHgx3TWXJmxlxV1pktC2WQ7N94QgAeep09rq1aS/U3XIQG4HxwqvSfwBUPrSS+i4FUmq2xUH1rH8mXMsfZaewLxgzPSLmN4LlAzKBBuIJlgvOGYPl3defiFoNQ11ONU1kpI1zQi+RB4uakDH13Nm7Ky0HwlgadKjEBNr4mOp31PTeQD3G2I10IQloKTK3MQ2091iLITv9BlJczPo4EzHRseh2tCUSGQiYicLUuecejZhe6aXzr4qEDWlgcimu1+5e8o/WOoEefBqpdOsh4/Momb07f5e+HKJLYrgtKiB45TkQVz9nhavTAdTgPRT1Lp71t3DGhmkQC9FdnkEgJDJ38QKKOY3kuR7uJ6CDcfq2DouD+hxQLy9AwhHu7f68SdGYqpRBNiwXwtww/NMo5hORfyt5EB+pP2am2J5rXwyVYOSqMfiTuDlnwtJ22EKqpM7S3aJaUpXrQy+ruqeyyj9ZvUZ0/+R2WteiMSQ0xzWXtKlKrK5/93SUrHaBl0qjjDwYVMVU2QFHRw2DyqJH9GtOKz3+slD6Ik56dBbUD3D2drL88W1EXQe8BG/vfxiTEiuQcIlnDX9AJxXj5c7+Q7RD2nGord2Zr9hq9ey8WqvRxLRkCAt0u2BO+w6z6rBfAx2kJEwXeKNaI2bwSQ2jmGJQw3FEjhRa+isM/44TA9nwIuJ+PuW5knbL8DROnapZrGzLLdu4NhXe9XVAGf/J1NnfiPB3i+/iiklup27l+9dLrczkKSBMXvnmtUKK58ZE6GLjvXdiGO/usEa81Up2Y54zPaKlwReyw0xNxbT6qx19bfrS6r30caMVsTJY4fVamBir4pFO3RoTNGybRDjFLVZhmUksoBjgMwY4OkQIFfe8tQktSD1dtxbeMYZc/yNKwVwDAjQuGCdZxXH45u1ZiMLbZrm9m0I5Ei0elhmyqvGibFsOuIoXDAwMaw7vFchBMQK1u6ozfh6S+0dUEJzYCiDJhtWtsp7stqD4GnK04BW7lsZG1YcyKlz3PGtiEcnCV7CSDjdA58BQjW4jxJFMJw88rXw/vBFr6ckG+cwz1Rkn2F1WkncK1GKyOYoGL3a4oLz9WjlABBSUPGlsM39j+vM34T2LgeuyXcSr70V0Sa+E/x3GJoceJCaFZDh661S+oOPuvbLRD+SChZMNWUtBsKt1AdqVMopFKY2DaAnKjBoM/BBhODqT4A== X-OriginatorOrg: oss.nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: bec98576-4745-4c4e-cbb7-08d979e8ae59 X-MS-Exchange-CrossTenant-AuthSource: AM0PR04MB5140.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 17 Sep 2021 14:37:31.6918 (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: Mob9OVW30ZPFps8eSz4tL/ppVxbz43DXij5fvmlT+RUNlFAAUoa2OrXQwa7Ml956ethKwaJHW7rFUEI2c2l8sw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM0PR0402MB3506 Cc: pierre-louis.bossart@linux.intel.com, alsa-devel@alsa-project.org, kai.vehmanen@linux.intel.com, lgirdwood@gmail.com, linux-kernel@vger.kernel.org, ranjani.sridharan@linux.intel.com, Guennadi Liakhovetski , daniel.baluta@nxp.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 Signed-off-by: Daniel Baluta --- 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 b4280459e5db..374df2dfa816 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 Fri Sep 17 14:36:59 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: 12502321 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,URIBL_BLOCKED, 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 838CEC433EF for ; Fri, 17 Sep 2021 14:42:58 +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 B1BF261261 for ; Fri, 17 Sep 2021 14:42:57 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org B1BF261261 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 4920D1769; Fri, 17 Sep 2021 16:42:06 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz 4920D1769 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1631889776; bh=qophH7I5EKq7IN+OgVFMXP3kuPPtstCwTjP4CjIXo6I=; h=From:To:Subject:Date:In-Reply-To:References:Cc:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=ufNPpgbrexXUtjogs4mTHF4TZhXEkzQWRiogFA6ECTWVLP1K14dd0w6ZjtJhCjxPM pNLsyJgP1HpQC+wg4EKInLLmjw9IQuHRQUO/V9hNzOOtyzM4FqtG5Td7plWz/NhJLl M6JXQkASsWm17UdEQyO9J5+R03jGzcn0eyO7u4dQ= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id 10B71F80543; Fri, 17 Sep 2021 16:37:57 +0200 (CEST) Received: by alsa1.perex.cz (Postfix, from userid 50401) id 7523BF80533; Fri, 17 Sep 2021 16:37:52 +0200 (CEST) Received: from EUR05-VI1-obe.outbound.protection.outlook.com (mail-vi1eur05on2077.outbound.protection.outlook.com [40.107.21.77]) (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 9FCAAF804EC for ; Fri, 17 Sep 2021 16:37:37 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz 9FCAAF804EC Authentication-Results: alsa1.perex.cz; dkim=pass (1024-bit key) header.d=NXP1.onmicrosoft.com header.i=@NXP1.onmicrosoft.com header.b="iehlx42H" ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=RIMW+qMl0kyTI28BarqhXxPzU5PNbBgPt3RSHvk6vfiVDym5R68ZURDTU8WmscQkCZnZfuLBbjc7FXqL6MRMPhAvhMA+KJtLbSBUzwBRbLE3kG4lCg35F3d5sDJvs+T+4VugWcPbgEXSeQ0cFP1Lwq0Uz3tatOyXGHPebSU49Hg5CP/bC+sYR2eHYupA0gKKhncIZ5jhUpyt3xjq322BwHHbg2kqxhByp3dUnp/WmTSzro1jDY6YcPFnjeKpdQ5aa572hXV9kAkPMKbAMkxYgEasFs4Gh5XMdY1pJYnbiFKaJFfP3T7NL+4uK7OMmb5IHU6Gr9gH6mfGHoyJEKekHQ== 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=BR/g9u8yznQfaAynScsAPeN/fcxxma+I3dEjKi1o3yM=; b=TfZ0AZuBpGTsRnZuqGXAqVX8MEr9eWFBZm8j7Y+LeKe9yepRvDx0LefELGUuy/yxZUli4J2KrbXDwHgqoHTYnkVF+hqNdVTIXRmzpHV0cLQjm2xfgk/Rw8RmHCtJ+eK/9UuKWpoyVqPLV9ymZJnKyi9aXE9qqXEyD9K+19kAC/phkCXqcIsLtzHWHSKEx31Am44WnAR7YQ+x1xZmGqW9YARhI172y4ud0u6FwA2paQQvC0Sp94UzuSNSYt2Jq6qJ3EdQBcwmyYduyB0gT+OpIITLPU+EauOKoFhWW6r+qF3RmcFdJZ/DaUhCH0MAHVH81ssSLKk7DjLN/TIPVVTviQ== 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=BR/g9u8yznQfaAynScsAPeN/fcxxma+I3dEjKi1o3yM=; b=iehlx42HuDrtZmJoSUzx9/kU3wwEieRFZWv7J1BjO+Td5KEULjYee7irb55DgIoXxNYvmUvSdLczaQjduGV4qqN38ZPpIWPcnYCfAFKzJaccpi2E8sYIVTZyIyf/AuHWaJJP8MeQ2Z6716ILJD0xDW8BL9pwpKx5UyMrGHkxYNo= 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 AM0PR04MB5140.eurprd04.prod.outlook.com (2603:10a6:208:ca::21) by AM0PR0402MB3506.eurprd04.prod.outlook.com (2603:10a6:208:17::29) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4523.14; Fri, 17 Sep 2021 14:37:32 +0000 Received: from AM0PR04MB5140.eurprd04.prod.outlook.com ([fe80::dd84:b996:1c8:705]) by AM0PR04MB5140.eurprd04.prod.outlook.com ([fe80::dd84:b996:1c8:705%6]) with mapi id 15.20.4523.016; Fri, 17 Sep 2021 14:37:32 +0000 From: Daniel Baluta To: broonie@kernel.org Subject: [PATCH v2 12/12] ASoC: SOF: topology: Add kernel parameter for topology verification Date: Fri, 17 Sep 2021 17:36:59 +0300 Message-Id: <20210917143659.401102-13-daniel.baluta@oss.nxp.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20210917143659.401102-1-daniel.baluta@oss.nxp.com> References: <20210917143659.401102-1-daniel.baluta@oss.nxp.com> X-ClientProxiedBy: VI1P193CA0022.EURP193.PROD.OUTLOOK.COM (2603:10a6:800:bd::32) To AM0PR04MB5140.eurprd04.prod.outlook.com (2603:10a6:208:ca::21) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from localhost.localdomain (2a02:2f08:5708:8600:8372:c747:541d:bbc9) by VI1P193CA0022.EURP193.PROD.OUTLOOK.COM (2603:10a6:800:bd::32) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4523.14 via Frontend Transport; Fri, 17 Sep 2021 14:37:32 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 1e598da2-d603-4b8a-9bd2-08d979e8af14 X-MS-TrafficTypeDiagnostic: AM0PR0402MB3506: 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: 7lf9ro18ABkpiTatsN0zX1JzFGMst0608VIAPa6vHvRrBg6+OkstetMYGJ9g3jzGIzZqVUA2ZrGRLy7rYJEExsD1cOp8a1rtWoKfLdJnS3cs4eC53VsjMa2eN/nC9w6z50XjJgWit+8jaWx4hAaxX2RiTzuS0F2ORYL5R066txAoCZpXJ4bpFzwP+t92Lhgfn9uSPu8A2i3stEDOZqaxcq1aAXBCxPWYm4/qxJScUZQGQwKyr5KMrV+V9c/HRmx+Mg4mG4NbdTG7uLlk/axT7bsRl0P2YVfOgZ8qm75TatpXfkBMZ6Am7qeYETjBk4t4TdjxYKaad70hpS3T+QX2U4/xx88Nzt6CJst8U1LuuZ3eezDryR/fVlFc38KMexvpoU+fjf+LDTq1l2EwSkTY84JVcveA9Y7vNobNWFQKkcFItMxv3d/ljtv+EqzE4u0IyGL3+L38POjARJQwv1ZuLrh4+mPRgaOtYQ/TWzcWZo3kNQxDKbGRyG6KK4nxOCgezQsaDVJ96Z2zHx9aFFGU+zDZ0GNQDnFv8TRntJqFYaRmQDH+4cKxvAVK68pShXyZd6WFkt7S3k7AtQ5a3+9MgOctP1aIKq0e5XruGwgeH5xCcwRa+3tra0uLOdMo9xv1+ucjK/W/DWqTIWLD2TaPNQ== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:AM0PR04MB5140.eurprd04.prod.outlook.com; PTR:; CAT:NONE; SFS:(4636009)(346002)(396003)(39860400002)(136003)(366004)(376002)(186003)(316002)(1076003)(66476007)(2906002)(15650500001)(6486002)(5660300002)(38100700002)(2616005)(86362001)(83380400001)(44832011)(478600001)(4326008)(52116002)(6506007)(6666004)(8936002)(6512007)(66946007)(6916009)(8676002)(66556008); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: 4UWpo3Y/z6qmBhl0075/IrG81AUhwgB/tS54z86eymGJGlxULrdQ5Zis0TW/T900Y4+fOPsNTLmaktiRSop8unO2rmpncy3RIdbjv2zX2N4q6VKjOeEtpAmLkkJ7+vMWnZzldzqwqRSBHpUCavv+9Y5hsHx3TNKRVPe2lSxHyZUXhP/4arbjZWnsx4sRIioTMc3q2tPR7cjDk67M+iji1OzzRjs+/ZEaKFxNn6Rlbtelfcs3/yETJRVEaOJ2eat/X/hP83NfkV7Bo5kLhlERzZjvNnwEx65y6PrnBgmDC/D4wbJDECizrsuYpXXnNJSXW7iuu7Up4GTsDAHh2oY6/ge1aW/kl5eVeFYFPSqfnf5GST3w6YwnZ9h1pKaTQOW0SPF3+CGXvHnuES28D839Z0LJo9/F4FrNKy1a9XPwoYXL7i/ZG2kLMZ9pZknq+z2OjXoH0wdmUkzQAuLOd8VVNyqiJuyvczMttie3erfRPlMTwrZpjn6xS/+YJXHL4VRRLdyCIw+CL5DNrQKE73Nc+UrXpdFbeF5Bawr/XtzsMQqjgH/Q9xz2aDkxLygJIdLiBDscrKuMGOJOYjJTe8+BvSN3xLLrzNGX92PTlK9h5K8nMsTNmTjTJwgrB5C/63cua6Dkdaha+Mn0+nha07V6XvY74PWE9arLi6g5Dbh7lV1wqlv6Zkj76UufuydbzUo1FyiP8gMDgGMsgv+hMWAZY9A+Z3ecxA7fu4mr0eoysI/f0PsXlzO7YAIjfGIKEsUF4dsOkpZcM625ZT3+CLtDOUXhn570TcKzVS76sYChlIuUQzQfek9AEKPAFOMKMT9/vmp3gJB+msPreX1WQ1m9ein/ij0HHTdWA2AaJpaFtfdwmrOOQi5Q/Ab9C9nn0AajpdMVKIMlwe14rVQuMi8uiiPC+TArNFoETickMRA4vuF6OgalLpcysTpp3WE15CHMgTC3VE/BqVtrNpzYdClCD24TNV3yUjAJQAziJw08SRH3Q/dfqkWI6HfioX23UHLu15AQ97bjCQVw8XuHBrbfjR9NmHuSQKWQjEPe5GRjv9x6ZYJ5Q0HoY525yPSHFBy1GYDR1KymKiZTzoGed7k/XyBtPnDg7HKyEmFcy06qxuwc5unwrS3vBSVZkHcJpphMMgGQzwwlemgTH9f0Ytb+zxiYI1/qW6WUg7cjjtrH1+/GUjxiTNUOcvF+Z1h5zUt04bgd5Jp8zyhcHq6XoHPCXwBCX0jWK9rGV6FRDr+4Y4OM5adIh0f9Hdrf5JA9en3CFQnD+h3p6U7Vrw3UjXhl5EKmIWPO4n/s41mGFhModt+7DnJe45nYWM5i9R+CVMHckBVrkP+xwn0E1DJDB+9NliqFVpFBXlgznotjvVvdV2FPZybxHf8pxGTp86dIX9i05MIsxuPYr9sqM+6u8mHlog== X-OriginatorOrg: oss.nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 1e598da2-d603-4b8a-9bd2-08d979e8af14 X-MS-Exchange-CrossTenant-AuthSource: AM0PR04MB5140.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 17 Sep 2021 14:37:32.7901 (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: ZEwdgLS2b8nAr5RnyDDoVpLz0wSXzkmdBL/LZ8r2x8VeHcnUlp/o/WX2xRTNSfX/RrhsOB8B/6F4unYi/gTNvw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM0PR0402MB3506 Cc: pierre-louis.bossart@linux.intel.com, alsa-devel@alsa-project.org, kai.vehmanen@linux.intel.com, lgirdwood@gmail.com, linux-kernel@vger.kernel.org, ranjani.sridharan@linux.intel.com, Guennadi Liakhovetski , daniel.baluta@nxp.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 Signed-off-by: Daniel Baluta --- 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 9b1bdba15c74..33610c60b57f 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 */