From patchwork Thu Dec 19 00:35:37 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kuninori Morimoto X-Patchwork-Id: 13914311 Received: from TY3P286CU002.outbound.protection.outlook.com (mail-japaneastazon11010013.outbound.protection.outlook.com [52.101.229.13]) (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 428D3320F for ; Thu, 19 Dec 2024 00:35:38 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=52.101.229.13 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1734568541; cv=fail; b=rMKDuo1AmEGb0RKAyVoe0lqymAu6ikwfLz9eBCtT2za6VkIOJkD7Fqw7WEERVvJu3WQvZ/NBFNRrE5ghT+0NQ5AFKAhDdlCZxiD0K2/Pijj3OGGFd2Lw3Nsc7R3r0GSyHTjzeKAAjRjb3I+mWVlhP3z1Wb5IH+wlJolVEvMoCVo= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1734568541; c=relaxed/simple; bh=P3lBIYceFZvtGODMe5E2CFfedsXcVN8l9R42YlMN/GY=; h=Message-ID:In-Reply-To:References:To:From:Subject:Content-Type: Date:MIME-Version; b=iXi1OSN6u7YOB4wWnPtpQHLrra2K93V6T33Hf200/useS8sWhTRC+jYvfr9sJiO1cIGgGuGDbrks/WJBuMM8UoWJHFQYKhEXu+v3kQtYGZ7tadHr8nt54CgIG54Y87xepCBGbIyi8TGlcBnkpy/a3zrug8uNokXjvJVc5nyb6Y0= 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=FHh+mUFq; arc=fail smtp.client-ip=52.101.229.13 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="FHh+mUFq" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=AWTrGp9ZeoRm3fjuVE8nktEBlBGvrwdD6/bCcfXBT/GWZupLSVVKYAOwrqliPntsHdzl6efeyh6dVHdZ41/Qy0SUoGuk3koss90iHSgXcJF/PkIvconHOG5eFu7lDw6BIFjNg8na0+DwrfsIWLW+iUEbso9fjU/X8KwRiRC8S4yV2g0WVmdsGyyEm447NfkGNtuXdXzN8P4u62GBLj7wZTXP0Pb42mFVHcj986axnhzdiSszroljB/943N5mSa6z/hpIna19ml1n5U+DeGepe4Zwmt4xkRi6bSlnRKsC0eP+/5q6VSav/2kJagd9X50Oo0LXeSDHRE6uT3j13oEPbQ== 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=kuCgUJ7m8x4OJ5JOyR1yfTHr5Sq5ZMi3KEIz9qHS2lxi39bUIO1R4yhK8tMDQ+RNy9Bz8EaOMh/4YigS6b0Xcl4eraZLApOf+YnlArJrmbdCnl8apVCYkZnaTBif7imuNCON60V2QIOc6eBS/PEzKl8T25Z89eTyayULePbIkWJjbQF+tu9hYSc8yiA5cz4GlUs2/KI+7KjDrhJV1pARbYONm+hPYUeECuH3T7pLrxUsFbV3oGPpW01ZQ3FgdH9egFa1NjwEh8PnIMv4gxPeiYI6sWcUEDyYGSaVf67tE2yHHlsd65wpqYvUgUA9hm/Jy++t9DjaRr56w10MfV/Q4g== 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=FHh+mUFq//x2JZ7NjjZyGDWSPCn5ZHPONFHnR0Qhc3HemktRvf69Xy5GBM7yHsjmw/pHYAQJb42ACfxxEfkUWw45O8waS+U1AdnRGtZEqs4Fhsx4rM29U9q3I47R30Xin+i7PFxRsv+f761AB4+bO2QB0V4dVZuE3KQeWmuOKI8= 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 TYRPR01MB14144.jpnprd01.prod.outlook.com (2603:1096:405:221::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8272.13; Thu, 19 Dec 2024 00:35:37 +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.8272.005; Thu, 19 Dec 2024 00:35:37 +0000 Message-ID: <87jzbwcxwm.wl-kuninori.morimoto.gx@renesas.com> In-Reply-To: <87r064cxym.wl-kuninori.morimoto.gx@renesas.com> References: <87r064cxym.wl-kuninori.morimoto.gx@renesas.com> To: Jaroslav Kysela , Liam Girdwood , Mark Brown , Takashi Iwai , linux-sound@vger.kernel.org From: Kuninori Morimoto Subject: [PATCH v2 5/6] ASoC: soc-core: Enable to use extra format on each DAI Date: Thu, 19 Dec 2024 00:35:37 +0000 X-ClientProxiedBy: TYCPR01CA0043.jpnprd01.prod.outlook.com (2603:1096:405:1::31) 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_|TYRPR01MB14144:EE_ X-MS-Office365-Filtering-Correlation-Id: 8916638e-b2aa-446e-1447-08dd1fc50ee0 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|52116014|376014|1800799024|366016|38350700014; X-Microsoft-Antispam-Message-Info: //i2vttovlpssYj9Srd6XTGXzZZi/0YJGQgaXxd0g+SExtSSwZPpEGewIaIeuvdzZHtco2L3zFxezhsIEMVCzeMz4kJy+x4pjIj037kT/A0PqfewSwmAr9d9mgTS18vh1olPl00/E/UoyrxQMNdgXXPwRCS1mhpEKoqa5IC4Y+ULqt8ZRtg/9ga0IHQFJ4bln4RbTkzyD4Bo/KDTXDp76IBKK60iCdqQrEB1ZCG+u8C5yu2j6+e6l4D/c9BvBJKCe/0D2pfHVk8B2KawJpufIf4lBAzixUVLoVFq7jL63/jSX6FehpZbzszMhNcCfyZxr0mHlRyIO1I9cOCJ+S220w9e6f69uT/V/fq6UMLBLFH1M/NUmksnQUUAvUEix7q8dqBWSqlG3I9OPc4M9BFHCnsh3xr210sMjcusxucoJ96aEshC9Mitm3u90yRlijLn/s00qmT72kAD6rUyNbqKdleh8lsl5pdxj2inbq0K/WjQSa6n8BSLumk8/AYGmb8v/7CKx2KKkrRgwPpYjieZSzOh0ockCwI5gkP7/Qpc3I7+LbxMlHyXsLJnj99HjyKQhL9BL3QP6+L/7QOMgXyxJnw4FweNf2HHDKtyKdPZVq3xJtTJJ2FbCkcnmIMXxMBIOAcgN2neWvQiYg6mvcwZVbzKjoMCymKDGAHbKupRgFSu945bRyoPUHrT16YFyEiZtmJE5BPehQea2/Mm5K0fcmhrNW2MDEpMC6iy0hwdsRFSzTOdyI8ABbAIgNK7X2Y/TaTvKh2ZEe086w/MU2C+8UZr0flCsc8S5BtzMeIelJtJZkntmUPB+BL8MbCDaBkzUUZkl8Xb17L/fPoNYJ7n/0awp2haR95NfAifFARi9q18BRRaXaul4bmQjseHiij3gPS8Tf9+ckRWeLAzWp7XA0ycZuPbA1E+pBUaca7QIhLTz5Nj9sZ1dM5SirP3qp6y47gxwkVMM1v5CNTRHR6r1zXk0p3smAdpRJxGv77ZtUc2l5jpvsBZQyoFjqM+/wRudd3Vi+nUBmrkYEhjKQecyTMmQeHMtRVmIQuEqidk6EtZE2RtH68cXkf3P8yNPk9WqCEW5FA9xh3u9oiIhTvMkRLlm8NDUrryfu59FR/95AtR2o54gPUaFJOoiADURO8CyiLMiWpihW1KFQOPcY7YFFoj3K/XF4RRbimxYrmhjFHsvO17zJpys6zjqERI8u72uDQk9gAOamLoSGvB+pzQ1qAGGxa2YxDo/1L8IzfTQm0nK4nHe2JsQLJiHquGv3xsdw24Kg0TUozJJM6AjVrnBmj4P/Qt1uHLU0xWcOYNmq8fKYJvx/HktU/dT/siKoJ6j5tFlvyF7y+OpzXMdzHPt2p8ieQ9fy8yN3bgnWekQdZGmPjsK7z78FutmOB+gDeMm7V3vSbx2PsW/kLze8rB2uhKh9c7ZXClF42SP4RkKFrbDF8E1ccMGvGYEE1rKnbA 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)(52116014)(376014)(1800799024)(366016)(38350700014);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: NsoUFLb+GyTnIQ0lFuA6KNs+d9zWi66mRGA5FvqfYLw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gPwm9sNv+2+o4gV0DJIT8wIMtT6sSrIFJVfPEkpCForUUdzgGgQuUzUiUJH3x9BeTOkRFOKLi7w5P5MIQjEfkDXTTbyiC9CZsoV9t++h0irKEmccWKGfjyDh6oalrRNu/46lxS8LE587NOy0NlejzU1a2cNkSpPyYEVhK4gUUPldbAMszTiWoek38JxCh8He8i7WqYfe0sio5i7PMKbBLMtSq2b4qkrSUnAx6HPIHj1T3msgsYRxK5ayydABD3cAo2KqC7x8zYy086xUumapOmD3syrLf4qCwF1OcX6Jx4z+Rvy+IZ5f98nRVhB4MlFl2d3+zkZ1k7ZP2+Gq/xd4K4y/yPqQxLJJGCY9RczcMc9CkDgRMugFhcxZXrH6aT73/1Ccdex7lGDKb7ovnLXihiWC7mrBch/cI/AjAS1Jm2JgoD0t6x89EC/VlXXDHtkLTw574wZAaw6zxOKqS54En7NzWW9jmwwf1BS0IKVb9DOqWOzMGVhVCkkjlboA+2/SDO1uRIU3RPPVT2jGXRoA= X-OriginatorOrg: renesas.com X-MS-Exchange-CrossTenant-Network-Message-Id: 8916638e-b2aa-446e-1447-08dd1fc50ee0 X-MS-Exchange-CrossTenant-AuthSource: TYCPR01MB10914.jpnprd01.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 19 Dec 2024 00:35:37.5918 (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: ZBBhih3HuhmJxugKKqqguUCZlsxQG9j9/Bgqc9BW6TWVrLlZPIZdLmvJJ5MiJ/i9ULCsnGEidlefZbT5nkqNhFJarcwHEJedN1OX8rRAoUX75TvRV4seiZOnrBjJioFr X-MS-Exchange-Transport-CrossTenantHeadersStamped: TYRPR01MB14144 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; }