From patchwork Mon Oct 23 05:35:49 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kuninori Morimoto X-Patchwork-Id: 13432403 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id A6359C001E0 for ; Mon, 23 Oct 2023 05:49:15 +0000 (UTC) Received: from alsa1.perex.cz (alsa1.perex.cz [207.180.221.201]) (using TLSv1.2 with cipher ADH-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by alsa0.perex.cz (Postfix) with ESMTPS id BAC2F82A; Mon, 23 Oct 2023 07:48:23 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz BAC2F82A DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1698040153; bh=KvY+Ra7PhCfLJdZiuGWKPEDaQICxE5+EeSd1CDbAbrM=; h=From:Subject:To:Cc:In-Reply-To:References:Date:List-Id: List-Archive:List-Help:List-Owner:List-Post:List-Subscribe: List-Unsubscribe:From; b=Pugaou7jCHCDpthqBJfw3zf1d1CpR9yx/hD2MsjhywjT8glryELKqC016YYwl2zgF HvXCXrtdxNoBbgWPSM0tqVXKq1k3jrPoqfHlbgkUBBkG8lrs5Rt+VWHI+FslB0NArN EiWHDRbIQY4akchOWNsZHvkwjuAv5IWxsttTSYw8= Received: by alsa1.perex.cz (Postfix, from userid 50401) id D2676F8055C; Mon, 23 Oct 2023 07:47:33 +0200 (CEST) Received: from mailman-core.alsa-project.org (mailman-core.alsa-project.org [10.254.200.10]) by alsa1.perex.cz (Postfix) with ESMTP id 42B50F80557; Mon, 23 Oct 2023 07:47:33 +0200 (CEST) Received: by alsa1.perex.cz (Postfix, from userid 50401) id 9EB8FF80537; Mon, 23 Oct 2023 07:37:51 +0200 (CEST) Received: from JPN01-TYC-obe.outbound.protection.outlook.com (mail-tycjpn01on20700.outbound.protection.outlook.com [IPv6:2a01:111:f403:2019::700]) (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 D1C6AF8032D for ; Mon, 23 Oct 2023 07:35:51 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz D1C6AF8032D Authentication-Results: alsa1.perex.cz; dkim=pass (1024-bit key, unprotected) header.d=renesas.com header.i=@renesas.com header.a=rsa-sha256 header.s=selector1 header.b=JJKBKg84 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=MAgWjeVsF9U1NAGaYuYF+4FxbkIXIYKGw24Nt3nFhOxu5oGdeotfe7/rP9W9AnJF5PjfivDTLjfQmzSHLwLAbzRu6oV2Cd0dh+ttuTJL8UckRy6hmaZXTAGqKo5OKL86lLaHiqDpW6rGBO935OatdaXIYmGH1Ihfm7nouedPTA58l1OxLrky3nby+0bGRKVMTOzMlbvV0NYN2tMR0HDcp2+LkZT3EFyM3XlRzPnJl6sFLN5wz784AazhPK1H254R50yiIz/7whZ0Zszuc0GtpEtSZ+ccprILWwKMH+UeusHnH+q3e3ibbBAUZILwzga3CrvlhsP6R11SY6ZtcqHtDA== 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:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=wNdyrb5/z883L9GmbevbxH3TILEOnEt7MpzuuvoQtnQ=; b=kZaTbZbfl6FxfFIqURI2h4OcNSM6QphYo9/3dM+5T0iMYKSTmZaDSXztCrKazvsFcuRfpLksLa6osIZy1Mm34DOYE/bl3Of0Qjg35i8wr+PIHbfI09C/+KvH415JHEjo6IXAd2KvrmTJuE62yLOLvnSfNrV18VPXRgbzlb8ajK6UmFhfkhbvnR7Ao3F7rz2NmEamI0ubbfE5aonxEzWu39738HmJGx8uEMWXwbrZTxrvUGR91m0Ewrf1YWSTWkZ5fYXm2yGDz6wW9sfQGz7tXup+fd+rXMenQwYVAp8GSswevNTlWFqApnWlDVkD97vCmcRRSEEeUULpMJ6VySI1/w== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=renesas.com; dmarc=pass action=none header.from=renesas.com; dkim=pass header.d=renesas.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=renesas.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=wNdyrb5/z883L9GmbevbxH3TILEOnEt7MpzuuvoQtnQ=; b=JJKBKg84V9e04uVRGjuIkDdaQH6BBmk/srge/x+iqBkMI81ZZh9ZI5kPTN4xWMF4ThVe+7P2PqSSlKokQKKGtCbTNyviiwRnk0JbMzc5AbTJEyc/hSYp9yMTQwWZeK30XLK8EOFNu3MzAh5fQ67lvy4PQYTFGqX/ws3sfKDZfnI= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=renesas.com; Received: from OS3PR01MB8426.jpnprd01.prod.outlook.com (2603:1096:604:194::10) by OS3PR01MB8242.jpnprd01.prod.outlook.com (2603:1096:604:174::5) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6907.24; Mon, 23 Oct 2023 05:35:50 +0000 Received: from OS3PR01MB8426.jpnprd01.prod.outlook.com ([fe80::be8:b648:c989:8e7f]) by OS3PR01MB8426.jpnprd01.prod.outlook.com ([fe80::be8:b648:c989:8e7f%4]) with mapi id 15.20.6907.032; Mon, 23 Oct 2023 05:35:50 +0000 Message-ID: <871qdllx3e.wl-kuninori.morimoto.gx@renesas.com> From: Kuninori Morimoto Subject: [PATCH v5 2/5] ASoC: audio-graph-card2: add CPU:Codec = N:M support User-Agent: Wanderlust/2.15.9 Emacs/27.1 Mule/6.0 To: Pierre-Louis Bossart , Mark Brown , Bard Liao , bard.liao@intel.com, Conor Dooley , Krzysztof Kozlowski , Rob Herring , Jerome Brunet Cc: alsa-devel@alsa-project.org, devicetree@vger.kernel.org In-Reply-To: <874jihlx44.wl-kuninori.morimoto.gx@renesas.com> References: <874jihlx44.wl-kuninori.morimoto.gx@renesas.com> Date: Mon, 23 Oct 2023 05:35:49 +0000 X-ClientProxiedBy: TYCP286CA0287.JPNP286.PROD.OUTLOOK.COM (2603:1096:400:3c8::9) To OS3PR01MB8426.jpnprd01.prod.outlook.com (2603:1096:604:194::10) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: OS3PR01MB8426:EE_|OS3PR01MB8242:EE_ X-MS-Office365-Filtering-Correlation-Id: 86334d97-4eb7-4b17-b357-08dbd389ea6c X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 3+1AoJ980fO8351Py/vpod1kIOGf5kwQLneNPkrwg5iljJJhFXJfHX8FCLYGODJfh1f3CSLX2sA0SRQ1pFfKLiUTNnOc1j+u93PeLwFMQ3iLTMq7hqP6vLc06xb92P++QuoD31t9s9/yCWGES/xx5uan9O7oEukVCFij4AWY1hJNTtS90ny73ZR+vN/jyJgWGmOLV1x/IB+O5n0NmP6y5G1pH53rfXrhle9XDJp1xorrHfGQaNF/9drs9cm3UsewkRI/Kq+6xk0FpJwCihQjI3BdsYonz3Q/BSItptcuspIGWQqSAE8IQoURq0ImmEhGN5oq4uNEBgOx6vyEE8JNcORdXFZSao2LETqGkx/EfWM2KtMSTUl/+Pb5Rd4s17ChUlbntZyy5PaelYvpKrubg/yqvR3aVjQuYbsvZ6mYyuk4QMcsZ49Ux9JRiikL2ms41n4fbYZH+j1F8GLDCBFjkV/sA4s32SMTHtf5hse6/oCip7OzFdezqs/20+8R0jsU+IPEA6tEi85ZtPsfYGln8vK+u25U4sf2vPGm0E/H70ztX3+5YUhxXihCjardyQooJgQH9SnxZLJ9n0ajtdR71xdkjLdg1MC8BpHc0Xo5YqNOrsneG8zkKzETGf+9i8CWcxXyA6uriF1uX48YNC7new== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:OS3PR01MB8426.jpnprd01.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230031)(136003)(366004)(396003)(346002)(39860400002)(376002)(230922051799003)(186009)(451199024)(64100799003)(1800799009)(38350700005)(36756003)(38100700002)(66476007)(66946007)(66556008)(2013699003)(110136005)(6512007)(86362001)(2616005)(26005)(52116002)(83380400001)(6506007)(2906002)(6486002)(7416002)(316002)(478600001)(8676002)(41300700001)(8936002)(4326008)(5660300002);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: cVS6WlmwXEMKKwAGqoyj7YT/isw5EfzWKEWAcwly4CDQy8nsuxrfhcCao5iE48RZBpm1f8PJ6h7AnL91dLmS4w+6pCBIW34coVU9R9QC7oYY0PyktuCQ4eoFfha4xBVMLxRKcA2CXOxvSRwm5gmywClLpPbmPcPwNZ8vZYsg0N90QstJcMkuEiuQU8iMB3bcx8tpwHCINQ7outmS1UyM5SzJSHCyiaMsCAk+r+pxykwmX+aRAUB5hBj8Wk2uYMspGGlbjYS9+WpksFzdpT6EqlH14a4Z+wxonU/LjREe/7AonvTVopRxZBtJXMAs9H2iWfROsW4iYbw+BoMsxS7Y0IlKKP3cagqLh1rRm96owEFNuheQC4snppEcM0W+sOOq8CsgIubk+SDM3/7TplCeMv5EltYR+njuK/LuzkeIXlwbJzJS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FPJUWl4QWeFyEXMKLOakxke+uLNQlvcxV+u0NAOlM28p+NLKhL5fpWyXT78PiqyxQBAQxn+Lq+AS2xqbuYakdasSm8FwgfUIxj2lI4vtjnvmA3PjigIhk= X-OriginatorOrg: renesas.com X-MS-Exchange-CrossTenant-Network-Message-Id: 86334d97-4eb7-4b17-b357-08dbd389ea6c X-MS-Exchange-CrossTenant-AuthSource: OS3PR01MB8426.jpnprd01.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 23 Oct 2023 05:35:50.1041 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 53d82571-da19-47e4-9cb4-625a166a4a2a X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: MMYDqTOc4AZYApT7w2Rj9HIr+57N29Nmzy4yXE13NM49SlLeiI0F+Ot5bDlNHSixtOe63gH+K1MXuIEuCJ1pv6/lyjWIcNI3S9Utq/ZalT8SO3iFXi/YXfVoGlkxpnap X-MS-Exchange-Transport-CrossTenantHeadersStamped: OS3PR01MB8242 Message-ID-Hash: 3CSJ7HSAIEQF3N2X7HQP4XWBE4CPWGOR X-Message-ID-Hash: 3CSJ7HSAIEQF3N2X7HQP4XWBE4CPWGOR X-MailFrom: kuninori.morimoto.gx@renesas.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; header-match-alsa-devel.alsa-project.org-0; header-match-alsa-devel.alsa-project.org-1; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header X-Mailman-Version: 3.3.8 Precedence: list List-Id: "Alsa-devel mailing list for ALSA developers - http://www.alsa-project.org" Archived-At: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: Now ASoC is supporting CPU:Codec = N:M support. This patch enables it on Audio Graph Card2. Signed-off-by: Kuninori Morimoto --- sound/soc/generic/audio-graph-card2.c | 49 +++++++++++++++++++++++++++ 1 file changed, 49 insertions(+) diff --git a/sound/soc/generic/audio-graph-card2.c b/sound/soc/generic/audio-graph-card2.c index 5d856942bcae..bef7ef5e408c 100644 --- a/sound/soc/generic/audio-graph-card2.c +++ b/sound/soc/generic/audio-graph-card2.c @@ -506,6 +506,7 @@ static int __graph_parse_node(struct simple_util_priv *priv, return 0; } +#define MAX_PROP 7 static int graph_parse_node(struct simple_util_priv *priv, enum graph_type gtype, struct device_node *port, @@ -515,10 +516,31 @@ static int graph_parse_node(struct simple_util_priv *priv, int ret = 0; if (graph_lnk_is_multi(port)) { + struct snd_soc_dai_link *dai_link = simple_priv_to_link(priv, li->link); + struct device_node *ports = of_get_parent(port); + struct device *dev = simple_priv_to_dev(priv); int idx; + int num; of_node_get(port); + /* + * create ch_maps if CPU:Codec = N:M + * DPCM is out of scope + */ + if (gtype != GRAPH_DPCM && !dai_link->ch_maps && + dai_link->num_cpus > 1 && dai_link->num_codecs > 1 && + dai_link->num_cpus != dai_link->num_codecs) { + num = max (dai_link->num_cpus, dai_link->num_codecs); + + dai_link->ch_maps = devm_kcalloc(dev, num, + sizeof(struct snd_soc_dai_link_ch_map), GFP_KERNEL); + if (!dai_link->ch_maps) { + ret = -ENOMEM; + goto multi_end; + } + } + for (idx = 0;; idx++) { ep = graph_get_next_multi_ep(&port); if (!ep) @@ -529,7 +551,34 @@ static int graph_parse_node(struct simple_util_priv *priv, of_node_put(ep); if (ret < 0) break; + + /* CPU:Codec = N:M */ + if (dai_link->ch_maps) { + const char *props = "ch-map-idx"; + u32 num_array[MAX_PROP]; + int i; + + num = of_property_count_elems_of_size(ep, props, sizeof(u32)); + if (num > MAX_PROP) { + dev_err(dev, "need update MAX_PROP (%d)\n", num); + ret = -EINVAL; + goto multi_end; + } + + ret = of_property_read_u32_array(ep, props, num_array, num); + if (ret < 0) + goto multi_end; + + for (i = 0; i < num; i++) { + if (is_cpu) + dai_link->ch_maps[num_array[i]].cpu = idx; + else + dai_link->ch_maps[num_array[i]].codec = idx; + } + } } +multi_end: + of_node_put(ports); } else { /* Single CPU / Codec */ ep = port_to_endpoint(port);