From patchwork Mon Jun 17 01:06:40 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kuninori Morimoto X-Patchwork-Id: 806778 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 8614FC27C77 for ; Mon, 17 Jun 2024 01:07:37 +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 2F458A4D; Mon, 17 Jun 2024 03:07:25 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz 2F458A4D DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1718586455; bh=sM2/TEsKsgQY7U2Ye16OVj3oJI7EvHOe4wd2woO5SLw=; 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=bMdA2jqhM7z/rGAlE9sbQ+jgWw8ow0fp7r6+jRQi/7ovfe6ScGhwUmRHTCoxE5dqX 5WZTZG1vNVpj1Sp0dXyeUOm0KIbscMSK/nB1dJaJb6m3fRgbN5YntZ+A3kvDRfq6WI +NkhD23MWkNu2gmhgjByTf7n/tPdQJR6qG5uJE/8= Received: by alsa1.perex.cz (Postfix, from userid 50401) id 2FB2BF805E8; Mon, 17 Jun 2024 03:06:54 +0200 (CEST) Received: from mailman-core.alsa-project.org (mailman-core.alsa-project.org [10.254.200.10]) by alsa1.perex.cz (Postfix) with ESMTP id A5BE9F805E5; Mon, 17 Jun 2024 03:06:54 +0200 (CEST) Received: by alsa1.perex.cz (Postfix, from userid 50401) id C2C92F805E4; Mon, 17 Jun 2024 03:06:50 +0200 (CEST) Received: from JPN01-OS0-obe.outbound.protection.outlook.com (mail-os0jpn01on20606.outbound.protection.outlook.com [IPv6:2a01:111:f403:201a::606]) (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 09097F805DA for ; Mon, 17 Jun 2024 03:06:46 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz 09097F805DA 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=YqjHfMS5 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=meLACtGGaJhgBmMRb+C7WRdEvWkB+UiGugHwxCh0Y5iQVjbED65OnUm4ZrGMpdYODHnLLDrPzJrs11b4FQ+/C3GzlkLUwLorIGZ7/6pg0ywLhayBMHoQG1Zocy2iD1yxfH4AGyStX3TmPxv2iunFXJeh+5kQfHkvxWssnLtMKMoh8ORt36EyytpFWGyi/XjS4Oa01NA1Gs84ZDPGGPKYgXLzBkQ/GwzWOmW1s5Izy2Gqg3guc6UW7pRbVysloFw7Ma/fxisvqyjUQ+6iuAXV+KKREhYaRINC/FvF0rGCwk5p6ydlqaOyKzckCxvaHw52GaBnWJ20quWyREYEgNaFZw== 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=nx5CGNB8VEr2Dp4JAbHvU0049Du3/hPPWcfh8ch3oT0=; b=nHw5MbmF59eLxDqCo6AlfF2J8vXJV5mDBD+ISbXND6aEJrEDcU5BDet5F+3xCwzbpHDZuf/YUtQO5CO2sOLyWcVGBBJv8W217OBzDW+dzIpFWlyyuXb+0AiEw53mJJx1q+FeP+GslBm0Ihdr2BndZI8yA4esPfegtGSrJEiig6bZ7zhDobEGjUXV743YcTblWjYgPmp5EkOAEJuvSxXf/9EFwe1anB59iyF18IdiaEV0Oxe9ktr9YqgLwbsVbQlo1fytS62llemZe2qUKgzSCayA/IhaiJuWGHO+kIYOkvwP2tcYfBX0lQQMAj1LrmAqgbkIUw6MwDjY5BR3ONs11g== 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=nx5CGNB8VEr2Dp4JAbHvU0049Du3/hPPWcfh8ch3oT0=; b=YqjHfMS5NhTNeCP/gqLVMMRMEUnmn4D5J9HO4rbNtiQHOJpaX+x+hWBZLYWK686POWxJcQKeVBt1Lx3vw+7/ULE/fjfRAGUbaMAqe8mnQsehuWR8E8C+y90u2k5U4kq4T3dRJu35/itV0nPnLklSTX/iYxvqZq8d+nhpJDfHNWQ= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=renesas.com; Received: from TYCPR01MB10914.jpnprd01.prod.outlook.com (2603:1096:400:3a9::11) by TYCPR01MB11912.jpnprd01.prod.outlook.com (2603:1096:400:38c::5) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7677.30; Mon, 17 Jun 2024 01:06:40 +0000 Received: from TYCPR01MB10914.jpnprd01.prod.outlook.com ([fe80::c568:1028:2fd1:6e11]) by TYCPR01MB10914.jpnprd01.prod.outlook.com ([fe80::c568:1028:2fd1:6e11%4]) with mapi id 15.20.7677.030; Mon, 17 Jun 2024 01:06:40 +0000 Message-ID: <87ed8ws7hc.wl-kuninori.morimoto.gx@renesas.com> From: Kuninori Morimoto Subject: [PATCH v2 2/5] ASoC: simple-card-utils: add link-trigger-order support To: Mark Brown , Rob Herring , Krzysztof Kozlowski Cc: Linux-ALSA , devicetree@vger.kernel.org, Maxim Kochetkov In-Reply-To: <87h6dss7i3.wl-kuninori.morimoto.gx@renesas.com> References: <87h6dss7i3.wl-kuninori.morimoto.gx@renesas.com> Date: Mon, 17 Jun 2024 01:06:40 +0000 X-ClientProxiedBy: TYCP286CA0013.JPNP286.PROD.OUTLOOK.COM (2603:1096:400:26c::20) To TYCPR01MB10914.jpnprd01.prod.outlook.com (2603:1096:400:3a9::11) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: TYCPR01MB10914:EE_|TYCPR01MB11912:EE_ X-MS-Office365-Filtering-Correlation-Id: 184b21b4-0744-4bbd-412b-08dc8e69beec X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; ARA:13230037|366013|52116011|1800799021|376011|38350700011; X-Microsoft-Antispam-Message-Info: nfsXrpIYc+lZxxYyNelpEI3dat/6IehvW+PUndSZCTHZc7IcLo+GYuiewNao/ZrD7hR1iBHLO7DlpznCtXRQXwSOiRX2Q+m8KDQ/8uzhCpxFqfjJVzPJ2wsLrCv7UW6ESj2dG7n1u13LBPkeAepPmZTDedW6VshWtfqWsZyfFor7Tl81mvk55mwumIOrEfQEBQvp37yIN9MUC0LPKq0GOnCnNKHyprg0E2bs2h07jc7qanuSDmfaxDvt7vGHM9nzSkheWiidxgntZOlkIPGeaDeTKmIceieK+upBH84A3dVrkv3JlN3pUh+367TQD1Se8lHLQjAqNI2wVlP7NL8jxKexD7fG75LzH7zzytPopRntjhwPw0x0qeI26v/bx73HCfI/ay5OgPLCOxCQlB8W7y6+60ThncOexa5/CNpMDCS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LD+dx5vUmC7n2GhWrg5VH/SkQnVm6KwKQEjcF7FYmBWLFESs5fqIOGDihDOj1TVBhtVloX2G1HtpD/sfElVj3JoZTd5dmVbRW2EM/n5vkzbAasjemARq0n2j8Z5An2jOBsX61DgTrJTd9I+DvsoN+aFslMOXnohaZ0w2fWWbBD9K0oahu3XXD7+kQvh1Dx3ej6MtWCgPJVnnPuNqQR3fSHbEs7hZqoozhpq3xy6NwSEyDVNGFnzn8YGFwkGBzikbAXb7U4w1rJMvJ7+vv3WssochJOMMYVam701vmfWrKdG3Im57fcwKgRACzfhJXCn8BQbKoWiyi/reOqmvSbihPeynD9asOMaO2HgFNFMapO2u0++8iRiG2jqo9SC5VQwibsVHFz4LAevg6J+TqbxHuhamNZKu3FloLhO3i1Z2SGfJbOn9ZNZw9eI6fFU8QxzHc+F57nats/sAPXF4z6xaW/G+loxYL7TquSZnNTWqLB5XE73B7RYIBrIin8d7hBmXwzzvnS9U84lJWJZC5c5QHQG8Pv60tojEFzHMeQOZ79dLQGfcSS8pAfr0Vm8tHEq2dAu40PXciNphl59ZKzrocOzYKUcPzGb/oFe0pyhMftGiaCrZFHj8YDMpKJBryuk14VyVGd7Lvb4qbP1ba4yM/MPzLYV5QA98aq2gRPnKbsRl+jwRKE= X-OriginatorOrg: renesas.com X-MS-Exchange-CrossTenant-Network-Message-Id: 184b21b4-0744-4bbd-412b-08dc8e69beec X-MS-Exchange-CrossTenant-AuthSource: TYCPR01MB10914.jpnprd01.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 17 Jun 2024 01:06:40.6616 (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: pQgfb18K+3S84haoiTEorL6pQ8Su6ZyXX5Zs+rVv/K9yjWRreXbMEDD78WhyqjwtQBEmPokRjA1i33HIw+NYMmcWPchzGDKxMKGE4IXLRTBHwJnz3tkxk+IDFhcQpik1 X-MS-Exchange-Transport-CrossTenantHeadersStamped: TYCPR01MB11912 Message-ID-Hash: BJDCDKT7LCT6HZFYTWJNO4YCDL2ELQPW X-Message-ID-Hash: BJDCDKT7LCT6HZFYTWJNO4YCDL2ELQPW 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.9 Precedence: list List-Id: "Alsa-devel mailing list for ALSA developers - http://www.alsa-project.org" Archived-At: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: Some Sound Card might need special trigger ordering which is based on CPU/Codec connection. It is already supported on ASoC, but Simple Audio Card / Audio Graph Card still not support it. Let's support it. Cc: Maxim Kochetkov Signed-off-by: Kuninori Morimoto --- include/sound/simple_card_utils.h | 4 ++ sound/soc/generic/simple-card-utils.c | 71 +++++++++++++++++++++++++++ 2 files changed, 75 insertions(+) diff --git a/include/sound/simple_card_utils.h b/include/sound/simple_card_utils.h index 0a6435ac5c5fe..3360d9eab068d 100644 --- a/include/sound/simple_card_utils.h +++ b/include/sound/simple_card_utils.h @@ -199,6 +199,10 @@ int graph_util_parse_dai(struct device *dev, struct device_node *ep, void graph_util_parse_link_direction(struct device_node *np, bool *is_playback_only, bool *is_capture_only); +void graph_util_parse_trigger_order(struct simple_util_priv *priv, + struct device_node *np, + enum snd_soc_trigger_order *trigger_start, + enum snd_soc_trigger_order *trigger_stop); #ifdef DEBUG static inline void simple_util_debug_dai(struct simple_util_priv *priv, diff --git a/sound/soc/generic/simple-card-utils.c b/sound/soc/generic/simple-card-utils.c index dcd0569157cef..a18de86b3c882 100644 --- a/sound/soc/generic/simple-card-utils.c +++ b/sound/soc/generic/simple-card-utils.c @@ -4,6 +4,7 @@ // // Copyright (c) 2016 Kuninori Morimoto +#include #include #include #include @@ -1156,6 +1157,76 @@ void graph_util_parse_link_direction(struct device_node *np, } EXPORT_SYMBOL_GPL(graph_util_parse_link_direction); +static enum snd_soc_trigger_order +__graph_util_parse_trigger_order(struct simple_util_priv *priv, + struct device_node *np, + const char *prop) +{ + u32 val[SND_SOC_TRIGGER_SIZE]; + int ret; + + ret = of_property_read_u32_array(np, prop, val, SND_SOC_TRIGGER_SIZE); + if (ret == 0) { + struct device *dev = simple_priv_to_dev(priv); + u32 order = (val[0] << 8) + + (val[1] << 4) + + (val[2]); + + switch (order) { + case (SND_SOC_TRIGGER_LINK << 8) + + (SND_SOC_TRIGGER_COMPONENT << 4) + + (SND_SOC_TRIGGER_DAI): + return SND_SOC_TRIGGER_ORDER_DEFAULT; + + case (SND_SOC_TRIGGER_LINK << 8) + + (SND_SOC_TRIGGER_DAI << 4) + + (SND_SOC_TRIGGER_COMPONENT): + return SND_SOC_TRIGGER_ORDER_LDC; + + default: + dev_err(dev, "unsupported trigger order [0x%x]\n", order); + } + } + + /* SND_SOC_TRIGGER_ORDER_MAX means error */ + return SND_SOC_TRIGGER_ORDER_MAX; +} + +void graph_util_parse_trigger_order(struct simple_util_priv *priv, + struct device_node *np, + enum snd_soc_trigger_order *trigger_start, + enum snd_soc_trigger_order *trigger_stop) +{ + static enum snd_soc_trigger_order order; + + /* + * We can use it like below + * + * #include + * + * link-trigger-order = ; + */ + + order = __graph_util_parse_trigger_order(priv, np, "link-trigger-order"); + if (order < SND_SOC_TRIGGER_ORDER_MAX) { + *trigger_start = order; + *trigger_stop = order; + } + + order = __graph_util_parse_trigger_order(priv, np, "link-trigger-order-start"); + if (order < SND_SOC_TRIGGER_ORDER_MAX) + *trigger_start = order; + + order = __graph_util_parse_trigger_order(priv, np, "link-trigger-order-stop"); + if (order < SND_SOC_TRIGGER_ORDER_MAX) + *trigger_stop = order; + + return; +} +EXPORT_SYMBOL_GPL(graph_util_parse_trigger_order); + /* Module information */ MODULE_AUTHOR("Kuninori Morimoto "); MODULE_DESCRIPTION("ALSA SoC Simple Card Utils");