From patchwork Fri Jun 24 01:15:43 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kuninori Morimoto X-Patchwork-Id: 9196265 X-Patchwork-Delegate: geert@linux-m68k.org Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 50B626075A for ; Fri, 24 Jun 2016 01:15:51 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 3D23D2847D for ; Fri, 24 Jun 2016 01:15:51 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 2ED7128483; Fri, 24 Jun 2016 01:15:51 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 925972847D for ; Fri, 24 Jun 2016 01:15:50 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751400AbcFXBPu (ORCPT ); Thu, 23 Jun 2016 21:15:50 -0400 Received: from relmlor1.renesas.com ([210.160.252.171]:9524 "EHLO relmlie4.idc.renesas.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1751396AbcFXBPt (ORCPT ); Thu, 23 Jun 2016 21:15:49 -0400 Received: from unknown (HELO relmlir1.idc.renesas.com) ([10.200.68.151]) by relmlie4.idc.renesas.com with ESMTP; 24 Jun 2016 10:15:46 +0900 Received: from relmlac4.idc.renesas.com (relmlac4.idc.renesas.com [10.200.69.24]) by relmlir1.idc.renesas.com (Postfix) with ESMTP id DD1F146E15; Fri, 24 Jun 2016 10:15:46 +0900 (JST) Received: by relmlac4.idc.renesas.com (Postfix, from userid 0) id D9C6A480A4; Fri, 24 Jun 2016 10:15:46 +0900 (JST) Received: from relmlac4.idc.renesas.com (localhost [127.0.0.1]) by relmlac4.idc.renesas.com (Postfix) with ESMTP id A9ACE480A3; Fri, 24 Jun 2016 10:15:46 +0900 (JST) Received: from relmlii1.idc.renesas.com [10.200.68.65] by relmlac4.idc.renesas.com with ESMTP id LAQ16255; Fri, 24 Jun 2016 10:15:46 +0900 X-IronPort-AV: E=Sophos;i="5.22,559,1449500400"; d="scan'";a="213663609" Received: from mail-hk2apc01lp0215.outbound.protection.outlook.com (HELO APC01-HK2-obe.outbound.protection.outlook.com) ([65.55.88.215]) by relmlii1.idc.renesas.com with ESMTP/TLS/AES256-SHA; 24 Jun 2016 10:15:45 +0900 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=renesasgroup.onmicrosoft.com; s=selector1-renesas-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version; bh=l+JiDzuiXdy118FHwi8G/KyeirQzqFjC/evjlUICjR8=; b=FVNaNns3IwT7ZxuppmXQBz8N2TfPptnbEkTfm5Zc/N15BsAN8ZfipnExLlAabyPsN+NeqvXbuzem85neA1U67+ZIb6dzZO+niS2YJa4TmL0GzKbw7LjPWqfnXXOYKNS9hD6e6OxUX6F4FM2RKfLTN64fTz409KW2G6VboQVAY2k= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=kuninori.morimoto.gx@renesas.com; Received: from morimoto-PC.renesas.com (211.11.155.144) by KL1PR06MB1703.apcprd06.prod.outlook.com (10.167.63.17) with Microsoft SMTP Server (TLS) id 15.1.523.12; Fri, 24 Jun 2016 01:15:43 +0000 Message-ID: <87vb0zxujj.wl%kuninori.morimoto.gx@renesas.com> From: Kuninori Morimoto Subject: [PATCH 01/11] ASoC: add new simple-card-utils.c User-Agent: Wanderlust/2.15.9 Emacs/24.3 Mule/6.0 To: Mark Brown CC: Linux-ALSA , Liam Girdwood , Simon , In-Reply-To: <87wplfxumi.wl%kuninori.morimoto.gx@renesas.com> References: <87wplfxumi.wl%kuninori.morimoto.gx@renesas.com> MIME-Version: 1.0 (generated by SEMI-EPG 1.14.7 - "Harue") Date: Fri, 24 Jun 2016 01:15:43 +0000 X-Originating-IP: [211.11.155.144] X-ClientProxiedBy: KAWPR01CA0028.jpnprd01.prod.outlook.com (10.165.48.138) To KL1PR06MB1703.apcprd06.prod.outlook.com (10.167.63.17) X-MS-Office365-Filtering-Correlation-Id: 12e4b4c5-5570-4758-d589-08d39bcd10d0 X-Microsoft-Exchange-Diagnostics: 1; KL1PR06MB1703; 2:957fjOlSf07My3Ij2Ne7bF4jOb7DEUyS6XsmlDMg7gb/LnQLSqXcnv0KJG7ANRObGuHkTAxAQNTr6PRHh1/MNkB5qR4en7cw6i7nS0j4qbE9ZWsy8BWPH1cfnAQ0+Yfu/A5qD0hAUAsB5Uo66QipptFdH1gCLVHmHYiJ00X2c6POnoLsq2cC4IBhWM6oL9gP; 3:fAy+rstURNG9k5wVlmnyZ4eIOV/G+r44xy8kA5mgC8voDq+ovF9BrqeH9409E9LO0lh2B684QVWAVXU7NqDJQDJD4/gpXYzpsP8feo5icKRH2I+cgQTo1NzFfpcBqhfK; 25:WFELzHIp2RIpV+WGM5mXlOcDhmwWJ0ye8FSaiOqpFrTcwAj+e+2CjFYZqB3sHYNateCg2fCUYe8PEinJY8nAaldVpio8Ieh/SHGZFkASwfHulnDOJBts5p8PLsOCKqbFSxUQaRV46J5l4oYtBudGZCFPN30Mtsufl7JaAQLZsUAPtCxBybOtH6KcCHob6kmWAGyqMBgItEPveRPcJ1DsYoAlokCthqYfHH+yauEWzwZ7YqORl30ixa7bU1sUAHPCK9sfrjoo7w3PnMMmOS1NeBfvDP5YlPhXcFM99PJ6wY5vJV5dNlJPrsyqXdzDno/PH68W3ZWdmahUeC1ha/I5c1PVDW7zt6RyjZE4k/4Xpw/D5mbz1mPyw5FGZZixxO7JEctNiyHSaOima6xSY0EXAreolPdjHsXuIwVudg9sp7A= X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:;SRVR:KL1PR06MB1703; X-Microsoft-Exchange-Diagnostics: 1; KL1PR06MB1703; 20:kaFs+kBf6e+6adIso3qRvMfatT9nWYNu//Wwc7hGN500PRoVz1YkmDTCMCcgo8I/IIg2PoqE0/CBf6AkLEGfjRUBnodFo2UvKcFaRliQq9AoB+pc3p5ISPKwumKB2vErx4x02x/wUVAvoBhADQjNuNbcpH523RP3ukprtRNTyu8cwzy1qpK9Sg8EAlvmbscd/VwEFM8EnpJ9E+swQoK8FnwMdfgshCeAOcTEGNH7tEtmBE62LnrWnoH8K6zkXNvRXxOT4soxYlgFJolUaRQtlDVYB2SyZFUx87bRNTUMvQYeiQK+IVybH+Rp9DIgM6pRRoKJzPHg7UCUfnQ4AmQYIWpgHZElAYXSR9msglQEVkanGA2u66Q9btwf6TtWNBw7CuuTD2bFi0f9kUwT90pszh+aY/Dd3224RuJZUU33uLr/19B4oulV5Kph3lgCrwZfhnoaEODvUlAoIhhUGAD39iMwJOV0xtHwT8C0bEzokC0QA69EbWv+peKCIRxH4Tja; 4:1AKtC4CP7bIU9kVeiPDlK5Q9mej4n2xnYjShiO9gM+Qg7p3kAwYq5MaVbxfq7G1W+078MuQ55jxSrE77cH7YasmlkO33yCz5l4++Oomcirgc1mbJhoF3Pc9paa4RRzyQ/KuLcmxs02lqe3FYAC6fRWEVxolQduA0uMNrBuKzWIjeRljIshU81uEe1+tykz9q8TYj35l1jDAJO0vgzkgHp8xEKerBMZDPMn41sBSNpVQPblCAhGhPSb/R6yg9x0fsD6culwVwHCOaTfmVNZxs+lzhDRDInRc1V7qsnrDdzmXzfVfPnDBeFU1K8GurZMQ7Ju+o9eGCIIDML5GeggI+Gc2xd9EysbjGdGZT+s/INj9P475ckWU+Nbc6Pagd8KfhrWjSoW8SGDWiB/rcLgHWGA== X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:; X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(601004)(2401047)(5005006)(8121501046)(10201501046)(3002001)(6055026); SRVR:KL1PR06MB1703; BCL:0; PCL:0; RULEID:; SRVR:KL1PR06MB1703; X-Forefront-PRVS: 0983EAD6B2 X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10019020)(4630300001)(6009001)(7916002)(189002)(199003)(2906002)(47776003)(92566002)(68736007)(189998001)(4001350100001)(4326007)(110136002)(97736004)(66066001)(50466002)(19580395003)(83506001)(53416004)(23726003)(2950100001)(81166006)(6116002)(19580405001)(81156014)(33646002)(77096005)(42186005)(586003)(8676002)(46406003)(305945005)(230783001)(7846002)(101416001)(7736002)(69596002)(229853001)(54356999)(76176999)(3846002)(36756003)(105586002)(86362001)(106356001)(50986999)(2004002)(16060500001); DIR:OUT; SFP:1102; SCL:1; SRVR:KL1PR06MB1703; H:morimoto-PC.renesas.com; FPR:; SPF:None; PTR:InfoNoRecords; MX:1; A:1; LANG:en; X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; KL1PR06MB1703; 23:26JA+3mBpEV2P5oEjaxmyL0b964tgMMIyk0xXUuhE?= =?us-ascii?Q?GSmkPceQTWpDnawKHpqxbCJbahxb9ms1eLUYoeeFNJ4vrKAe3mLMXPyRkWgM?= =?us-ascii?Q?bc+BckJfnUfp3dKhiTG3kdpkp20FUDnypS99nOabhhG6Mk9srqr2gXYFcZe0?= =?us-ascii?Q?WUlnFvYMlaBmZJ6CLcZ5rKTwj8Ci3sq/FX+R7Sp0u+8pLAnWGGfEw/vWzIz1?= =?us-ascii?Q?yPqVP5irUoZpc3imSFpwsp7rjBbbj+lZefy//M0gCcSV73rG7JHGAs/Svh9f?= =?us-ascii?Q?FEO95Es4F7gfExApR+VbPhQzrPrjlv+yNJLQEyQrADQ2EZCLIch5MrO717BX?= =?us-ascii?Q?D+foDv/Am7V2Yg2gVL8Ifi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diagnostics: 1; KL1PR06MB1703; 6:3lRpPmW7tR5Xdo88o9WtJnof220+c849wBwzSk062NunjeEZlMCFoovz56ZJuB0Qh9ZRwzncg956gKZM/unbaeMnLDcgMcsFMlA4cuXlLa9+ChNCYjmcBuxZpuKLtZOPpp7v7PQCmWGTIW/SqoNY3KITFBub+icrJR1yCh1ChoJ2KVeDuks5BDPXrxna6CB45hNzZPOezdG+MMXZ/SqqBp4AIOmssrSEloCwT5V1c0aeM0SxKmyNN6jLC403XXClxvFUmLKbTPB4f00nh/OfwhittRHLYZiwo33f2uavxg9Fdau01L5Cvder35I4+wo5hcnMujnsqsyffIFpdMrNC1+CWExZ1HJyqQrx3MMb9N0=; 5:qnQu7AbxKAJrEI2jb9jl1Lp12R4tR6MKtS/JJDIDGRGc6zbplBbu7iFMUg+8dm/jIsjo+G2tjJEXanp1eLJV9DJ3gdhx1zWtgQdViLfObDr7XRuLm1EIbaCwm8aNJbv+OK+3XAojmjEP5quTprzYJg==; 24:aqd3r2r6uHvgxDZQS0W7jk+rs9d7OgqxOvO5GWSN7c5o1sABRExo8tfrbATXStuh+STRImowC4xNNTrX0EvDWM4MYljYY/WvWgmLhWObEOU=; 7:S9E6U1tDu8POczhkeWmNb/GZT+v7JQ5LQJcNf/lS+SIaN15F7NC5y4Q/E/5YN64xHbjr3igBdJRJ/1MqVrhnujBwf5LdarIeKM6u2DqTzrUs1weC53wfn27IDDK2r3Ksa1BYP0VgpSh9ue+wfD4wJ8xce7guzthIeH/BXEM2gP2Tmvbd+kqJNazfESaDQFcaf41DUpS0hoPtbeBQ0GDAMFjzQrBrW678+qusCYsr+XYg1mxUtWNfUBIg7yShxhwW2IVAAE9RmdeV+EdIRiaBNA== SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1; KL1PR06MB1703; 20:viyIkAUMNykM/Gvx6R1QColMxBwR2ITWuG/xwDCQqbd6Elz/X/NyNZIcPCx7puUJZr/2eutnpK3TQclRI3WxAwxNHDC2bBBaHOmO+YDfziUO/RRsjt5dXxXSql1/uVTIiDZNXPodA+BA3QS88gIWaysEEuFMMehBGv0wCILzaXE= X-OriginatorOrg: renesas.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 24 Jun 2016 01:15:43.5839 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-Transport-CrossTenantHeadersStamped: KL1PR06MB1703 Sender: linux-renesas-soc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-renesas-soc@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Kuninori Morimoto Current ALSA SoC has simple-card driver which is supporting both platform and DT probe. Now, some sound cards driver are created based on simple-card. They have similar feature or function, but implemented separately on each drivers. This is a waste of code. OTOH, merging these driver into same driver is highly risk, because it will be very difficult to keep compatibility. More over, ALSA SoC want to have graph base of DT feature in the future. Maybe it want to use simple-card like feature / function. Because of these background, this patch creates simple-card helper utils, and provides common function to each drivers. 1st is asoc_simple_card_parse_daifmt() Signed-off-by: Kuninori Morimoto --- include/sound/simple_card_utils.h | 21 ++++++++++++++ sound/soc/generic/Kconfig | 3 ++ sound/soc/generic/Makefile | 2 ++ sound/soc/generic/simple-card-utils.c | 54 +++++++++++++++++++++++++++++++++++ 4 files changed, 80 insertions(+) create mode 100644 include/sound/simple_card_utils.h create mode 100644 sound/soc/generic/simple-card-utils.c diff --git a/include/sound/simple_card_utils.h b/include/sound/simple_card_utils.h new file mode 100644 index 0000000..7acc798 --- /dev/null +++ b/include/sound/simple_card_utils.h @@ -0,0 +1,21 @@ +/* + * simple_card_core.h + * + * Copyright (c) 2016 Kuninori Morimoto + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation. + */ +#ifndef __SIMPLE_CARD_CORE_H +#define __SIMPLE_CARD_CORE_H + +#include + +int asoc_simple_card_parse_daifmt(struct device *dev, + struct device_node *node, + struct device_node *codec, + char *prefix, + unsigned int *retfmt); + +#endif /* __SIMPLE_CARD_CORE_H */ diff --git a/sound/soc/generic/Kconfig b/sound/soc/generic/Kconfig index 610f612..26c2fe6 100644 --- a/sound/soc/generic/Kconfig +++ b/sound/soc/generic/Kconfig @@ -1,3 +1,6 @@ +config SND_SIMPLE_CARD_UTILS + tristate + config SND_SIMPLE_CARD tristate "ASoC Simple sound card support" help diff --git a/sound/soc/generic/Makefile b/sound/soc/generic/Makefile index 9c3b246..45602ca 100644 --- a/sound/soc/generic/Makefile +++ b/sound/soc/generic/Makefile @@ -1,3 +1,5 @@ +obj-$(CONFIG_SND_SIMPLE_CARD_UTILS) := simple-card-utils.o + snd-soc-simple-card-objs := simple-card.o obj-$(CONFIG_SND_SIMPLE_CARD) += snd-soc-simple-card.o diff --git a/sound/soc/generic/simple-card-utils.c b/sound/soc/generic/simple-card-utils.c new file mode 100644 index 0000000..3f6b725 --- /dev/null +++ b/sound/soc/generic/simple-card-utils.c @@ -0,0 +1,54 @@ +/* + * simple-card-core.c + * + * Copyright (c) 2016 Kuninori Morimoto + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation. + */ +#include +#include + +int asoc_simple_card_parse_daifmt(struct device *dev, + struct device_node *node, + struct device_node *codec, + char *prefix, + unsigned int *retfmt) +{ + struct device_node *bitclkmaster = NULL; + struct device_node *framemaster = NULL; + int prefix_len = prefix ? strlen(prefix) : 0; + unsigned int daifmt; + + daifmt = snd_soc_of_parse_daifmt(node, prefix, + &bitclkmaster, &framemaster); + daifmt &= ~SND_SOC_DAIFMT_MASTER_MASK; + + if (prefix_len && !bitclkmaster && !framemaster) { + /* + * No dai-link level and master setting was not found from + * sound node level, revert back to legacy DT parsing and + * take the settings from codec node. + */ + dev_dbg(dev, "Revert to legacy daifmt parsing\n"); + + daifmt = snd_soc_of_parse_daifmt(codec, NULL, NULL, NULL) | + (daifmt & ~SND_SOC_DAIFMT_CLOCK_MASK); + } else { + if (codec == bitclkmaster) + daifmt |= (codec == framemaster) ? + SND_SOC_DAIFMT_CBM_CFM : SND_SOC_DAIFMT_CBM_CFS; + else + daifmt |= (codec == framemaster) ? + SND_SOC_DAIFMT_CBS_CFM : SND_SOC_DAIFMT_CBS_CFS; + } + + of_node_put(bitclkmaster); + of_node_put(framemaster); + + *retfmt = daifmt; + + return 0; +} +EXPORT_SYMBOL_GPL(asoc_simple_card_parse_daifmt);