From patchwork Thu May 25 01:18:29 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Kuninori Morimoto X-Patchwork-Id: 685676 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 917D6C7EE32 for ; Thu, 25 May 2023 04:56:56 +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 A5D77843; Thu, 25 May 2023 06:56:03 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz A5D77843 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1684990613; bh=YiI3tRn85eD6KpplZsDhUwiwfnCxv5kel7AB17xB5wE=; h=From:To:Cc:Subject:In-Reply-To:References:Date:List-Id: List-Archive:List-Help:List-Owner:List-Post:List-Subscribe: List-Unsubscribe:From; b=J21EQiIto02OFrLBcRDDu63rPnY+AMKx7leg5bZZZfQFqJkBQJ0odz+SjVI8ayway giBEs9HNt9wWZKw6GjrRh3bHePrMBlPs68wXdbHcC4DKfqpszBXvfxZka5h8K/2lIg LfhP+WxRJzcff0G+hidyjztjsJSprWQgY19OMgy8= Received: by alsa1.perex.cz (Postfix, from userid 50401) id 0B056F80602; Thu, 25 May 2023 03:18:42 +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 68A0AF805FA; Thu, 25 May 2023 03:18:42 +0200 (CEST) Received: by alsa1.perex.cz (Postfix, from userid 50401) id 7E2E3F805FE; Thu, 25 May 2023 03:18:38 +0200 (CEST) Received: from JPN01-TYC-obe.outbound.protection.outlook.com (mail-tycjpn01on20716.outbound.protection.outlook.com [IPv6:2a01:111:f403:7010::716]) (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 21CD4F805FA for ; Thu, 25 May 2023 03:18:34 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz 21CD4F805FA 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=GCp6Dn82 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=ffUBf/QW7+sfjBfoB1QJAIJlRq0tAa/kBvlfTiYCp3lyPn5upZK9shko9Qh7Pe0d2rkYhsNesQ0U5EIekoP2669suJ21WA3HOAS5G0NpRMuPE9/KHqrIqEgEbbqrFOZU+wg8c+Nqz/Osb96EoCB7fcQ+FkN97ERVuAd+pOS04AlPlhfOnhQVh34JJlx//66wvOqwtcx3zZUvMa1OdAixzA/vh5LtmSlkldg3cGYuT87gJ0L17QtyrsAHWHUNmsmT8+Pcb5onuIkz5VT3GSzOvNvh8+GmiVgAs7XDU9oM+8oA02hoNYsc2QZ80MJk84jvpecI5a4ht09ZvINP7jZnxw== 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=itmeBOoEMeNqWziCPjkXUADA7QwjNWbFTHTwQH2AXQ4=; b=IY7zGpj07TurU4rDjgNve//IUXNAOwY2dMSTW/SUe7dUG+s3kCk00891A61jR652OwAR8R0P51030aPnqWt2SLSNh1gj2ZQjf+IMHmhqt7WqPvhDE7uQFnRrXpq4dochL3I6vP48/5eYKvB49HYiMQJjEoeNWNHrkfqHWC0yhcxddRdyyUXPtpFwRlrCHrFZsW/YKxv2d+t60exaCOSI7v7IYYNRerqaCKd/9LrHbEUr/ATel+DSNyNBuLzpFHbQVCH1SuLyx/99d5BkV56NjCGUKQdzgj8dSrMtLue6OfzNlxh4sETI9hEfCSpiWdvQqi69sI0Epkw/ZdoIBZ+fMA== 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=itmeBOoEMeNqWziCPjkXUADA7QwjNWbFTHTwQH2AXQ4=; b=GCp6Dn82PhP+O7t7oETXkL3Sn9klUF9c7hIurFrqnkt3CjnEML6OW3IAThbCj9TOTEReZh5uARIGIeleSViWClF90BN6kMiVBJav/V6lqJL4ElHYzGsUYRYoWGDrRvldlZDXjBvRwKUm154K940lWaXT213cdAhIhVAYiWUPLoY= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=renesas.com; Received: from TYCPR01MB8440.jpnprd01.prod.outlook.com (2603:1096:400:15d::5) by TYCPR01MB8485.jpnprd01.prod.outlook.com (2603:1096:400:156::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6433.15; Thu, 25 May 2023 01:18:29 +0000 Received: from TYCPR01MB8440.jpnprd01.prod.outlook.com ([fe80::6c36:5ff9:24c9:e4f7]) by TYCPR01MB8440.jpnprd01.prod.outlook.com ([fe80::6c36:5ff9:24c9:e4f7%6]) with mapi id 15.20.6433.016; Thu, 25 May 2023 01:18:29 +0000 Message-ID: <87lehdgqe3.wl-kuninori.morimoto.gx@renesas.com> From: Kuninori Morimoto To: Jaroslav Kysela , Liam Girdwood , Mark Brown , Takashi Iwai Cc: alsa-devel@alsa-project.org Subject: [PATCH v2 06/21] ASoC: soc-pcm.c: cleanup normal connection loop at soc_get_playback_capture() part1 User-Agent: Wanderlust/2.15.9 Emacs/27.1 Mule/6.0 In-Reply-To: <87ttw1gqgn.wl-kuninori.morimoto.gx@renesas.com> References: <87ttw1gqgn.wl-kuninori.morimoto.gx@renesas.com> Date: Thu, 25 May 2023 01:18:29 +0000 X-ClientProxiedBy: TYAPR01CA0188.jpnprd01.prod.outlook.com (2603:1096:404:ba::32) To TYCPR01MB8440.jpnprd01.prod.outlook.com (2603:1096:400:15d::5) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: TYCPR01MB8440:EE_|TYCPR01MB8485:EE_ X-MS-Office365-Filtering-Correlation-Id: 8013b3c8-ca48-45c5-dd9d-08db5cbdf28c X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: wkM1xxifyDluPwoCeGp6ZwwQ4ObimKeUZYM8uIksAwDD/SGN/WazaTh+JVt7yVlyfXQ71arUKz3/oIzzLWPvR5LTHeQ2PffdNshFqntySLfGF1oga8595PDX+/daqnX4qnOh99nwJG8nqM9ZM0wWUdbSDufXamLE8l/TVuHbXBPxjG+W5tHMyWqaXbJ6fwtyrfyEvkzk7E2gkjfdaShdb+wPp52lWn0N81m0cvAYzZstzu5jsYZVW56Tbb0ayesCbZWyIyB0QW6yZIEJVXsJPqqekklvLp390zoSSmmJkx5roy7rjYc7uQWZv2fEyLRMH1SbZINrE4hvp1XpB+ycYK4L5Rb371KRjK4jNtdux8wQbbWlly0L9c8RJOyj5I1pYIS/FuFLSoCcGdzkNfbsz68bkYEOEGSyMVq800zztu/+A4NFROl4Y+A/lR5MS7dhNBKxxwLDrgYaWoy/xDnvnqmS9lHCNOVlHBDqYjoKAVECxJA2kCSNXmy3wgAo7Q3UrMQgrQUeTp1S2fF1OsvMsm/8QqdTnZVwsEq7ZaNMm2fYR5KdR/IkFuHFEtedifdrmX9gV4RUPor8uDwy4C4xNQIG6mXXcYJ15wSIPJZFOxwkC58lWh10BLhnU3PuAxLPJMWl6qSLG8XhIItMstMomQ== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:TYCPR01MB8440.jpnprd01.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230028)(4636009)(396003)(136003)(376002)(39860400002)(366004)(346002)(451199021)(4326008)(83380400001)(66556008)(52116002)(66476007)(66946007)(6486002)(110136005)(2616005)(6512007)(26005)(6506007)(186003)(86362001)(2906002)(478600001)(8676002)(8936002)(5660300002)(36756003)(38350700002)(41300700001)(38100700002)(316002)(21314003); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?iso-8859-2?q?7fMDjpZ6aZXHbcJgIcT+Xid?= =?iso-8859-2?q?AB8a/xJEtEQifKspe9p+Y7dBd7rvz1121NEMBW12RLTHeajQB8D9UH9R9jM6?= =?iso-8859-2?q?t2KINzPJXdr3N/7RJN+Ep9XVb55Y4beyOj5f3BloeeakCRU49LqpENOGmADM?= =?iso-8859-2?q?0BZORKuhC0tx/+TWS9SP42dKMZ9Rflnw9RZxXKSo/vcedONLlzFHFB1kg4YG?= =?iso-8859-2?q?EG1CEyHzIAR86LWCE68O4hp61jOgLCIZbJVA0jX3JkKZ90/NRB4G6gpuh0xU?= =?iso-8859-2?q?Irqtjrfgef26ycaFqr6gIEbVy66IbeIQg4zY0vSR/p/ss5ijJsW1VZTL7o/i?= =?iso-8859-2?q?/WsLiXSskcFuPsYLQVVzham6DvCjxT2Lu2Dtmx/0B7FZmjewzfz5tetZsfh3?= =?iso-8859-2?q?kLyY6BvfZFlS3IiHihsU1rU1xsvK1Nvf+6tUil6fkO1+FG70ROt3OHKpknYS?= =?iso-8859-2?q?+BHBoH6eBnfdR4HBitkkUFAkofkHWwNxtV1y9CRcr/fO5TsbcPb5B3ueIcwo?= =?iso-8859-2?q?2RNwWuEyrokAgKNFGsQ9F0qGg+XJfFOwHWO2MDVsOwWzKrOwucEApYAd0ENe?= =?iso-8859-2?q?d+jafHTY59Hg58v6yCrfko8TJjTyZfOPNcFephZcAPUy+BECc1UO+IWHotmR?= =?iso-8859-2?q?L4R3SHymJ1HlNHsSRYda6vFL4/xuKjkAzZD1juilrgqiFyZc+5MjBXEUWuow?= =?iso-8859-2?q?dHzd0pMefHf6VFuNeOuBfSZ8S5x842g1DHVXv3dCZICbtG6x/pmGnsRNb6rH?= =?iso-8859-2?q?IxJ5OpIsWheNAKx7/uh96WtECI1MfSoHbLjEhgC3qVAH6922231GswFqZYuG?= =?iso-8859-2?q?F7KW665q5/OhtRzEC/9sXpplArDrIsgEFoAQ9xZ5wm3g9UjVGoONAj8ms224?= =?iso-8859-2?q?pwLAQAYmusnsIu2n5oN9mFn2/uAHIa0PyIiAHed55hHngwD72JsQV9NvxdrC?= =?iso-8859-2?q?9UoQrBEcRXR+/mM+SffGw00mFx0g5dsJZEO+lgDZhD2qwTfPZHQiomUqAESZ?= =?iso-8859-2?q?kx9oExxEbSr2ok2U8N5SoItfb2U3sYCFxS/9JW5GrHWTGouUCJrsic3ohWjF?= =?iso-8859-2?q?8XF36HK3aUNBkdbeGwSTHoaVBV2Zf68GqMJxbrOpsa779zifMmsCyJhwHhqc?= =?iso-8859-2?q?tOamZFRr4bC3tDDn2/vopL0S+8uO3vvFchaHeeF1L6gQUDyMZ5cuk4Zto4UC?= =?iso-8859-2?q?Ac/RC+qcWgZOQnzWeD2nLO2UZckIKWQ8FH8yFBqAZGvJZ83bUqPxTpj9BoDZ?= =?iso-8859-2?q?9yv7sUjKjVxmNoh7uYcPLEd6015j/T+Nj3hBpxFkVDe6J638Tv+q/+csDVdV?= =?iso-8859-2?q?RTxXE4m1o1PpnyFZ+VhntvR8L9aZeuM6K/cnWxZIp1yuOv74+zp+88rEXowU?= =?iso-8859-2?q?GEy+zQc3Y6RLTRpMj0+DOZBELhw7Iv1y0yNNkqa2KQrDzcHMQ+rwSRXCMpWl?= =?iso-8859-2?q?sFO7POmIV12Zm1MoLhrUxRz9rnH5Q0mJE0mTp40YhGoO059OfUnk/mUkpTE5?= =?iso-8859-2?q?Q/aFEaNsKVTwVUMx3TMCBk9gHYXRymQzO/ROJ2n95UN8DuOqukkINaq8nQ4W?= =?iso-8859-2?q?/soJ9bD14lvzpOoXirGUCjFaqbugrP6PfF6cTXekvqjRWvYj8txhnZmG076S?= =?iso-8859-2?q?oIIKgF4xEJ3HAaLpbCUQRgHeyvje+7HjTL/WahU6gUj6/L8Hcq+xQVrW3FVo?= =?iso-8859-2?q?=3D?= X-OriginatorOrg: renesas.com X-MS-Exchange-CrossTenant-Network-Message-Id: 8013b3c8-ca48-45c5-dd9d-08db5cbdf28c X-MS-Exchange-CrossTenant-AuthSource: TYCPR01MB8440.jpnprd01.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 25 May 2023 01:18:29.2589 (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: KumGboTpzwjxYxmXcXHcZVfSYEE6g2U7A1WKgirBMgattN2xFQB/C1yZSTMja0r18kLQv3+Ptr6F5fWGU1AoGub8A/VevrtXRBAjrHkP57ujj8ahVAFB3KKpMAnBmIoG X-MS-Exchange-Transport-CrossTenantHeadersStamped: TYCPR01MB8485 Message-ID-Hash: CQEKONN36YHCMR2KDFUAFB6PVEW33CYE X-Message-ID-Hash: CQEKONN36YHCMR2KDFUAFB6PVEW33CYE 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: soc_get_playback_capture() (A) is handling both DPCM (X) / Normal (Y) connection. (A) static int soc_get_playback_capture(...) { ... ^ if (dai_link->dynamic || dai_link->no_pcm) { (X) ... v ^ } else { | ... |(@) for_each_rtd_codec_dais(rtd, i, codec_dai) { | if (dai_link->num_cpus == 1) { |(a) cpu_dai = ... (Y) } else if (dai_link->num_cpus == dai_link->num_codecs) { |(b) cpu_dai = ... | } else { |(c) dev_err(...); | } | ... | } | ... v } ... } In Normal connection case (Y), it is checking number of CPU / Codec. (a) is for Single CPU case (b) is for Multi CPU case (c) is for other case (error) Because this loop (@) is not related to dai_link->num_xxx, we can judge (c) before entering this loop. And it is needed not only for Normal connection case (Y), but DPCM connection case (X) too. This patch moves (c) to top side. Signed-off-by: Kuninori Morimoto Reviewed-by: Amadeusz Sławiński --- sound/soc/soc-pcm.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/sound/soc/soc-pcm.c b/sound/soc/soc-pcm.c index 159670612de3..c95adf59cfe8 100644 --- a/sound/soc/soc-pcm.c +++ b/sound/soc/soc-pcm.c @@ -2742,6 +2742,12 @@ static int soc_get_playback_capture(struct snd_soc_pcm_runtime *rtd, return -EINVAL; } + if (dai_link->num_cpus != dai_link->num_codecs) { + dev_err(rtd->dev, "%s: %d cpus to %d codecs link is not supported yet\n", + dai_link->name, dai_link->num_cpus, dai_link->num_codecs); + return -EINVAL; + } + if (dai_link->dynamic || dai_link->no_pcm) { int stream; @@ -2792,10 +2798,6 @@ static int soc_get_playback_capture(struct snd_soc_pcm_runtime *rtd, cpu_dai = asoc_rtd_to_cpu(rtd, 0); } else if (dai_link->num_cpus == dai_link->num_codecs) { cpu_dai = asoc_rtd_to_cpu(rtd, i); - } else { - dev_err(rtd->card->dev, - "N cpus to M codecs link is not supported yet\n"); - return -EINVAL; } if (snd_soc_dai_stream_valid(codec_dai, SNDRV_PCM_STREAM_PLAYBACK) &&