From patchwork Mon Jan 6 05:49:45 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kuninori Morimoto X-Patchwork-Id: 13926973 Received: from TY3P286CU002.outbound.protection.outlook.com (mail-japaneastazon11010016.outbound.protection.outlook.com [52.101.229.16]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 1F00A17C for ; Mon, 6 Jan 2025 05:49:46 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=52.101.229.16 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736142588; cv=fail; b=CkQ4iQ3oQBVeD1nA8TR122ws4erIiRGaxGNjjX+DpanqyK3JJw+uVICL0t96HdEJ61pI5Cxvt6JExKHF4S+EtZWMMrhOHpZ2eck6h7wfP/CGPYBUgvWIw3RDdyNuupJxLXfPnpJLfhE67BvSSZyfP/o5fD64z4Qq7FCY0NAXvDg= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736142588; c=relaxed/simple; bh=P3lBIYceFZvtGODMe5E2CFfedsXcVN8l9R42YlMN/GY=; h=Message-ID:To:In-Reply-To:References:From:Subject:Content-Type: Date:MIME-Version; b=TR51hvKVabUopZtkMKzKOe6SymJutSVhuXa6q9Bokb2cUqRu4uUrbSyXeswpd9ExhxFNS+hl28aslcvkaOz/tc7+YGH/qoFgiWQpbOcbwLvXgZPKCaB5pGqxaFK+idD1zub8VqcCB6QcCZpmuGyziPvgBep497yAvYPJW3qAxjM= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=renesas.com; spf=pass smtp.mailfrom=renesas.com; dkim=pass (1024-bit key) header.d=renesas.com header.i=@renesas.com header.b=BqCwGn9h; arc=fail smtp.client-ip=52.101.229.16 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=renesas.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=renesas.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=renesas.com header.i=@renesas.com header.b="BqCwGn9h" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=bKEpwB1ZXX/dFpo2mNPK/eJVxqikk11TUnj2VCzHB5jlt3B8DgppN08Htzo8Ce5tPjtpPV+oFPpwn4r2dr2wWosJM2BjTELG3Sok3Oyclb5e3F4bMRfHK/8OWxr9kR0T+Dh0e6+V73wgTNiki4mbS0WfY1OzM6/ensJbPg43o00mMWBQdue7O0HMTAJWceouzIW3zGzHHXOIJ9S+tDzwkls+7kAOH9cfRoVhbGrtn1ukm4Pp8JowvFlw1VCimH2oOdSTPiYOXc/zvsVZSqRfrdBMPXvrwWfp2zeVjnV6CVThngLYHfZ0l14+wRnGjLY/AjDQMMtgXnMl9pPhIEsE9g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; 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=ptxx4KlXPLr54EzR49exvE5r06t9J/AL/yfOPW20bxc=; b=d4oTSdLAsrIKh9gqCjSuDBTklpp39UTXWvXWfBAaGMA4SYU16hSTH7y3d5KvPjBMSyD8gpBiDfBo+KiE/BpuHaE9P9CawjVv2ufpKgLKGleMJ6ZVYfpB8L4gnthHT8fz7LTuf1Mqet+nLc+K0AIv7vPpSfNT6CxWGjAA4UKLyL78O/BQ8hic1KZyoIQPUcxN3r7c0dwBsPlOHjS5QjpniXbqPyniIxQeTsfHI81SYTlRRlMUqj0gLvbWL4ttGh62FwYcn3JaLDF4YvyOweJeDxQGRbyQ60LwjpE5XNATJiokdfp7FqTmCGuagi1VSOgnVRkAj75JV9cshbDLDDHtgg== 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=ptxx4KlXPLr54EzR49exvE5r06t9J/AL/yfOPW20bxc=; b=BqCwGn9hGuCzCWxzwy/bsvBdLxJJAnzbvj3+dadEGdK0yX6lZ/7rlFjAjoPU6zERlVI02e15+SH+ubFd6kiKFzNLflLkw10AtS1VY4sDrTwNOAO3IFpg4e481g8c2EQvK60aSIL207Y49S4JFQWXNgmWzmmrFq54jcmY79TC5pk= 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 OSZPR01MB6247.jpnprd01.prod.outlook.com (2603:1096:604:ed::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8314.17; Mon, 6 Jan 2025 05:49:45 +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.8314.015; Mon, 6 Jan 2025 05:49:45 +0000 Message-ID: <87r05go5ja.wl-kuninori.morimoto.gx@renesas.com> To: Jaroslav Kysela , Stephen Gordon , Liam Girdwood , Mark Brown , Takashi Iwai , linux-sound@vger.kernel.org In-Reply-To: <87zfk4o5l2.wl-kuninori.morimoto.gx@renesas.com> References: <87zfk4o5l2.wl-kuninori.morimoto.gx@renesas.com> From: Kuninori Morimoto Subject: [PATCH v3 6/7] ASoC: soc-core: Enable to use extra format on each DAI Date: Mon, 6 Jan 2025 05:49:45 +0000 X-ClientProxiedBy: TYCPR01CA0139.jpnprd01.prod.outlook.com (2603:1096:400:2b7::16) To TYCPR01MB10914.jpnprd01.prod.outlook.com (2603:1096:400:3a9::11) Precedence: bulk X-Mailing-List: linux-sound@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: TYCPR01MB10914:EE_|OSZPR01MB6247:EE_ X-MS-Office365-Filtering-Correlation-Id: 7da932a3-8675-484e-553d-08dd2e15ec79 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|376014|366016|1800799024|52116014|38350700014; X-Microsoft-Antispam-Message-Info: G0NgG2BiDKN2CoRewWDR4/gf+jwe6w88iI6nFlvll6iuXGZoZ7LsCLX8tZxeEvC5Mz19fr7Ub79c55BeRO+ndXDa+9QdZu49ar7LRUL4nbzXP/nvH9/hczaaO9jpP/7l0Ihzq5HZbgBH/Cxa5rghX+pd1f2YnCEai5Nk7VRdMOk04+XwxqUrpt3C+pmoIajhqEqSPgCSx7ReXBFylTF1bRVT/yZtLVm4F2sl+QMXHTtj9VPZrMxddk++jouSwsydlK8aIcsH5vHVs8rhVSCB0LfvS68a2b0pkJdDudx+lvqp2pQs/u74IFG1MTQZ38S0eQMWncfKkKejR+SzHY50i2CJalco407T3+voJdb3rxrL2QMt+XgVw0RroYo0q0oEm7Huo4B0aztvrHUK/LgjbpCb3p+ZAe3UICpKMa16Pfcz6Pel9pTvY0jiqQmNXyzc1aeVXUOigcjRoJHneIqR6BR0ykmMpTHVYQrb8sXEJegLzwBSWuIhXl5oFSlmyiv8d+xB3mikA2eD5RoxLDwaXNu7YBxgDz5lmNG922fffKwkhpMepWDyorwRcfevKH9qZdPci0KW60A7vw67l/89JDJEkxNHw3FHv+dfd4/9oGuPZ0c7cIg/q+SdZHJxiYZoUUeZsuY725DZLHEm59Od3atL8kZ+5GYqlAsz+Md+nX5eHihIY9Znpg71enzH7/vs7ptWmbh97ggzwhrFjbvENlfjRw6P8S62gvXOCHhUVceMNW2C0b1ExWQGvTkFf8RJ39Ljsw0uMS29EjJf83CmoBMQI7Y633TkWKqIrar901xvgpnXvPT4ZpFSPL8YMmbh0vseQLkYUTV3eRfXaIk3uIAEmr8Pl8PNFjsbteHOFSKI6APa41TyLB5ZLEe0W5MRMnVzU+wiSuE4UQ8CCFTediWw8UST2W1jpjivq/5wzWR/JQq3OHMBuLGXwOJgogDnIPvetUYIFyNPaEBcUyLAv1eOWqqS45BykrEe+7XfOVcQH0tWORSweAUvNyXmhER7nm9PLsaVypKFDQV42b87yfJh1LxCC6+j/jZtD4SlaR070E9YaqXnazrKafXQPBFcBCqh4alCC4E7sFFwgJ/eyq98ssQnGWgJEVOS6h2WqA4QE6i4TmGPNE9w8hgTQrYGQY7WqLbko5cWdy/SXUI+/91kMqLkZikXPhJ9gCqDADFb+0Cu1KhMWs+paeles3ghXO3gZN1eVp5Xrz3JDZm9q5LF8/HNGGaDhpx18VA4Sr7J2UIa3HostwyJo4kXUK65BSK5arm4NaGS/Rg1MyBK5aw2nEzvrVTq77cxy0iOWCsBdnnH+T/j9Byuxv/oVfwBSKQQM2OcGtw982HF5iPzKiejVhZR1ki5io56x+9dkDULplC88C0i1aeJe6B79IwaI+sIRY0J8oFIzDOXaSdALiaaLiMkr1xZWck+CxJrEmtTynTlJAdF46fkxT6M/mKD X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:TYCPR01MB10914.jpnprd01.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230040)(376014)(366016)(1800799024)(52116014)(38350700014);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: +Y4GjCJ7kbO5IK8COs7VAb0ZwwmLV7vxExxY0Vk31XyZSguXpj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57XLdKCuUSAKBbuRiUDS0IIRR/UCOkAD5cgaCsk23ja8eePqWbxZcKugrCHfC6A9aEO9FvJQ1ApyxcXwHEI4LRC7d+ImbJzAq6p56OGH6kyCYew2D+hYBRWrCfRSYaP0UTtid70JNnjvpsAte6wV6EaeRgnMavW3/ab7l8PsAD14t0w+0W8aBHznanjdM9jcjWR3hNvBfTKv+w9xJ+c+8hNJ/0c8dS4H1ZhkgU7ojy1MaOzZazPrusTAmJAY4K4WrfPlvuvmthug2/Krcpxi2lmHfW770XbUHcevAnJUClQtp6pViuwijo/26DAM15EuyGqqVlgpacHXipXt0cf80rwlMNOyeZDnNxqErYqyLG+xPJKU54peegmS3OhGjQrx4YpfEE0WGoNvd3eNVUN2I5KLVY87uZtQic9bUSjKW1hd4CxenMIYLb3sEtZ15L1PcW/m4Owoh9jiJIfUBIE/YDm+sGEErQ8xfFi4kZcpFzZx4B0ldYbPJQymdJu4nIALmLReoNlZk4uXqBdw= X-OriginatorOrg: renesas.com X-MS-Exchange-CrossTenant-Network-Message-Id: 7da932a3-8675-484e-553d-08dd2e15ec79 X-MS-Exchange-CrossTenant-AuthSource: TYCPR01MB10914.jpnprd01.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 06 Jan 2025 05:49:45.3912 (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: cYzMPIuUGxBoqh7GHr94FtUNh2CvSi/vikLyGGaaSOoL1F/PNqxvw5dGN4an0ze6sfRoVuwipmCPKM/4cE3f5MvspDn4lRYxN9his6m+qxX6tOnjZ71FdWlIehxOVn58 X-MS-Exchange-Transport-CrossTenantHeadersStamped: OSZPR01MB6247 Current ASoC is using dai_link->dai_fmt to set DAI format for both CPU/Codec. But because it is using same settings, and SND_SOC_DAIFMT_CLOCK_PROVIDER is flipped for CPU, we can't set both CPU/Codec as clock consumer, for example. To solve this issue, this patch enable to use extra format for each DAI which can keep compatibility with legacy system, 1. SND_SOC_DAIFMT_FORMAT_MASK 2. SND_SOC_DAIFMT_CLOCK 3. SND_SOC_DAIFMT_INV 4. SND_SOC_DAIFMT_CLOCK_PROVIDER Legacy dai_fmt includes 1, 2, 3, 4 New idea dai_fmt includes 1, 2, 3 ext_fmt includes 4 Signed-off-by: Kuninori Morimoto --- include/sound/soc.h | 11 +++++++++++ sound/soc/soc-core.c | 27 +++++++++++++++++++++++++-- 2 files changed, 36 insertions(+), 2 deletions(-) diff --git a/include/sound/soc.h b/include/sound/soc.h index 4f5d411e3823f..61eee40da12ad 100644 --- a/include/sound/soc.h +++ b/include/sound/soc.h @@ -681,6 +681,17 @@ struct snd_soc_dai_link_component { struct device_node *of_node; const char *dai_name; const struct of_phandle_args *dai_args; + + /* + * Extra format = SND_SOC_DAIFMT_Bx_Fx + * + * [Note] it is Bx_Fx base, not CBx_CFx + * + * It will be used with dai_link->dai_fmt + * see + * snd_soc_runtime_set_dai_fmt() + */ + unsigned int ext_fmt; }; /* diff --git a/sound/soc/soc-core.c b/sound/soc/soc-core.c index 31cf499e3e79d..bd16b3fe59c8f 100644 --- a/sound/soc/soc-core.c +++ b/sound/soc/soc-core.c @@ -1449,23 +1449,46 @@ int snd_soc_runtime_set_dai_fmt(struct snd_soc_pcm_runtime *rtd, { struct snd_soc_dai *cpu_dai; struct snd_soc_dai *codec_dai; + unsigned int ext_fmt; unsigned int i; int ret; if (!dai_fmt) return 0; + /* + * dai_fmt has 4 types + * 1. SND_SOC_DAIFMT_FORMAT_MASK + * 2. SND_SOC_DAIFMT_CLOCK + * 3. SND_SOC_DAIFMT_INV + * 4. SND_SOC_DAIFMT_CLOCK_PROVIDER + * + * 4. CLOCK_PROVIDER is set from Codec perspective in dai_fmt. So it will be flipped + * when this function calls set_fmt() for CPU (CBx_CFx -> Bx_Cx). see below. + * This mean, we can't set CPU/Codec both are clock consumer for example. + * New idea handles 4. in each dai->ext_fmt. It can keep compatibility. + * + * Legacy + * dai_fmt includes 1, 2, 3, 4 + * + * New idea + * dai_fmt includes 1, 2, 3 + * ext_fmt includes 4 + */ for_each_rtd_codec_dais(rtd, i, codec_dai) { - ret = snd_soc_dai_set_fmt(codec_dai, dai_fmt); + ext_fmt = rtd->dai_link->codecs[i].ext_fmt; + ret = snd_soc_dai_set_fmt(codec_dai, dai_fmt | ext_fmt); if (ret != 0 && ret != -ENOTSUPP) return ret; } /* Flip the polarity for the "CPU" end of link */ + /* Will effect only for 4. SND_SOC_DAIFMT_CLOCK_PROVIDER */ dai_fmt = snd_soc_daifmt_clock_provider_flipped(dai_fmt); for_each_rtd_cpu_dais(rtd, i, cpu_dai) { - ret = snd_soc_dai_set_fmt(cpu_dai, dai_fmt); + ext_fmt = rtd->dai_link->cpus[i].ext_fmt; + ret = snd_soc_dai_set_fmt(cpu_dai, dai_fmt | ext_fmt); if (ret != 0 && ret != -ENOTSUPP) return ret; }