From patchwork Fri May 20 09:42:25 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kuninori Morimoto X-Patchwork-Id: 9129033 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 4899E60762 for ; Fri, 20 May 2016 09:42:35 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 3BCE81FF6C for ; Fri, 20 May 2016 09:42:35 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 3081C25D91; Fri, 20 May 2016 09:42:35 +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 501BB1FF6C for ; Fri, 20 May 2016 09:42:34 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751971AbcETJme (ORCPT ); Fri, 20 May 2016 05:42:34 -0400 Received: from relmlor4.renesas.com ([210.160.252.174]:43830 "EHLO relmlie3.idc.renesas.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1753772AbcETJmb (ORCPT ); Fri, 20 May 2016 05:42:31 -0400 Received: from unknown (HELO relmlir4.idc.renesas.com) ([10.200.68.154]) by relmlie3.idc.renesas.com with ESMTP; 20 May 2016 18:42:30 +0900 Received: from relmlac4.idc.renesas.com (relmlac4.idc.renesas.com [10.200.69.24]) by relmlir4.idc.renesas.com (Postfix) with ESMTP id 7ACC05046A; Fri, 20 May 2016 18:42:29 +0900 (JST) Received: by relmlac4.idc.renesas.com (Postfix, from userid 0) id 64545480A4; Fri, 20 May 2016 18:42:29 +0900 (JST) Received: from relmlac4.idc.renesas.com (localhost [127.0.0.1]) by relmlac4.idc.renesas.com (Postfix) with ESMTP id 5C038480A3; Fri, 20 May 2016 18:42:29 +0900 (JST) Received: from relmlii1.idc.renesas.com [10.200.68.65] by relmlac4.idc.renesas.com with ESMTP id UAN02068; Fri, 20 May 2016 18:42:29 +0900 X-IronPort-AV: E=Sophos;i="5.22,559,1449500400"; d="scan'";a="211272369" Received: from mail-sg2apc01lp0247.outbound.protection.outlook.com (HELO APC01-SG2-obe.outbound.protection.outlook.com) ([65.55.88.247]) by relmlii1.idc.renesas.com with ESMTP/TLS/AES256-SHA; 20 May 2016 18:42:28 +0900 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=renesasgroup.onmicrosoft.com; s=selector1-renesas-com; h=From:To:Date:Subject:Message-ID:Content-Type:MIME-Version; bh=5TsL45XjysMOQ1BkKS8d3ClIRVqDecTn/ZGXrLR8Dpw=; b=iYV0CntFGoZhaedt4SBnamXwyyY5csyw2/1kAxG1hn0pLSp4Ao5Pcrt3w0Ji5mtBMiY2aaajiZ/Xys7sTIlmBs3bFk1opVSTte+BbPNqZWIr8fE/8CkKuq+mgBrUaQamZTak3+KDEC9dSTifEIGgtG5UetSjoCgla+s2Vdss+Cs= Authentication-Results: kernel.org; dkim=none (message not signed) header.d=none; kernel.org; dmarc=none action=none header.from=renesas.com; Received: from morimoto-PC.renesas.com (211.11.155.144) by PS1PR06MB1705.apcprd06.prod.outlook.com (10.167.53.15) with Microsoft SMTP Server (TLS) id 15.1.501.7; Fri, 20 May 2016 09:42:25 +0000 Message-ID: <87eg8xrrzm.wl%kuninori.morimoto.gx@renesas.com> From: Kuninori Morimoto Subject: [PATCH 05/49] ASoC: add new simple-card-core.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: <87lh35rs8w.wl%kuninori.morimoto.gx@renesas.com> References: <87lh35rs8w.wl%kuninori.morimoto.gx@renesas.com> MIME-Version: 1.0 (generated by SEMI-EPG 1.14.7 - "Harue") Date: Fri, 20 May 2016 09:42:25 +0000 X-Originating-IP: [211.11.155.144] X-ClientProxiedBy: TY1PR0201CA0012.apcprd02.prod.outlook.com (10.164.90.150) To PS1PR06MB1705.apcprd06.prod.outlook.com (10.167.53.15) X-MS-Office365-Filtering-Correlation-Id: abfc7bf1-72f8-46ab-5a2c-08d380930d40 X-Microsoft-Exchange-Diagnostics: 1; PS1PR06MB1705; 2:vh4dZyLR7HTwxPyWiF9C604tb9yJ8vPa3Mx6kyFT1BwAGjF9w+uOfwS6gDycyzRJzJA0U8Votk+YUgdxNIgDKf8jPM/oniwpr/XcmoOzt8gB7F5vEyfTNipQ2szbA9kzsS2lhh52pCSiWFT2bPQCUA7TaaT8xkaYUKkwr71u6A/ivG+m0kxeTzh3f59PHXi/; 3:kLppIwvMjgB2baThO52pNsNHLfYZS6KqPWrWislPE66Qr2/yRrxLaSrU1JIQgvJ8/hdkNykNmcaz0a0G545TdnBVqhRTz0rawTiPhVIiAAkgTJ4snBrNXNu5Mmrd3MVN X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:;SRVR:PS1PR06MB1705; X-Microsoft-Exchange-Diagnostics: 1; PS1PR06MB1705; 25:k4iGwQo6hP6eD6gRDoo1L2o2m/ynvrQlCzPpdR+q/KNaIzSphDdVFWrVLRw2R+D/CvUHpW/WkokL7FDCagHGPStIYXiSLnzkLqmVCuuOZmZLjH1MvouYUUKY37AmwiPGTe/k9rwyByy8I+A3WZ7VKTZmshY0uWDtuvqCMQ1LTXcmAdf1vwgnLdRm+2ckLUZCAgavLm9Akv1nOviZPeNMouJH7DmKGwEbp1t/5Tv4zWg2munK8xHeQ+sLlT4lkVgs6SSLIKm//i/YRIMOBO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PbfJHjU0fD7AAZhGMuvO177nkG8OrCqwfIQvCAy1Pv7JhPJ8AFOpyJXcc9+uqUUU5Wgchukl+htvhMn4anH0Rhuan2AoxXGiySOv285ajpSRVj5hpmbz6OckWg0IRvtVV4B2rTAl2o1pzQmfZdxQY6U52IyeCmqZ0bGZOaPhNx21aekyPcyhmnV+rE+KjFFMoDkBFmfSxW9voRhqpn78pdhp3xA+93BOoZUN8SnGdYjgv8IpjzPxYmKAnN5XX4jqVmmgHDrL82XYIdjrcJ6krtvu6q0eg4a4ZcZXtVa1TiABpmELsmw0kdRR+dC1C88znW44Rlnsw X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:; X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(601004)(2401047)(8121501046)(5005006)(10201501046)(3002001)(6055026); SRVR:PS1PR06MB1705; BCL:0; PCL:0; RULEID:; SRVR:PS1PR06MB1705; X-Forefront-PRVS: 09480768F8 X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10019020)(6009001)(46406003)(4326007)(5004730100002)(5008740100001)(229853001)(83506001)(33646002)(23726003)(2906002)(3846002)(6116002)(50466002)(586003)(230783001)(66066001)(47776003)(36756003)(2950100001)(81166006)(53416004)(8676002)(77096005)(42186005)(110136002)(189998001)(92566002)(86362001)(19580405001)(19580395003)(54356999)(76176999)(50986999)(16060500001); DIR:OUT; SFP:1102; SCL:1; SRVR:PS1PR06MB1705; H:morimoto-PC.renesas.com; FPR:; SPF:None; MLV:sfv; LANG:en; X-Microsoft-Exchange-Diagnostics: 1; PS1PR06MB1705; 23:I+rmtY4mIuvwjVthPdENJEPSQM2hgSkunm+hPaIR2OEUWacQfDzah2oGZI1FPI64B4VGyF4jqEfXBi0mIxtP/kjHFVP713x5a2p+XbdBISp7br6L70obdut+FDiKfy/oIY9NXcqvR1bTCjYPpRmJtMdlI289l4q16BojVZKQSBkJ1ECq0gc42t+r93hafeFK1I5rNpHo7GHtLSTZMLI/BgePZ1n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9crtB5d2GqbCxde3YjUrsuY9cS3lJLdBIIws9P49mQiFnxn1t3bjpZkvAjgjhAKZNYd8ZOKxo7OdGYcLdppo+B3YOXn3l3HzIsvrXuOQiJz3g1EFowB9BiSbY+xPeAshtu5H+kx; 20:yOOkx3FHhbsuJme3K1q4EiCD3Irsu0zkkxz5VjdPNOb0Ar370ARV8eUQl9uXGnxBGCUDc0GEVgelqHeQ3A/saa7Ar42CYnlXFgJG1eW0XJfaDJhDHNhVqm0dddRESOxv6RszW3JsNOrnv0iv144tkfr8rycQQBjBKJ8/Q8LGCPQ= SpamDiagnosticOutput: 1:23 SpamDiagnosticMetadata: NSPM X-OriginatorOrg: renesas.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 20 May 2016 09:42:25.6490 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-Transport-CrossTenantHeadersStamped: PS1PR06MB1705 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 keeping compatibility will be very difficult. 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 tries to create new simple-card-core, and provides common function to each drivers. 1st is asoc_simple_card_parse_daifmt() Signed-off-by: Kuninori Morimoto --- include/sound/simple_card_core.h | 21 ++++++++++++++ sound/soc/generic/Kconfig | 3 ++ sound/soc/generic/Makefile | 2 ++ sound/soc/generic/simple-card-core.c | 54 ++++++++++++++++++++++++++++++++++++ 4 files changed, 80 insertions(+) create mode 100644 include/sound/simple_card_core.h create mode 100644 sound/soc/generic/simple-card-core.c diff --git a/include/sound/simple_card_core.h b/include/sound/simple_card_core.h new file mode 100644 index 0000000..7acc798 --- /dev/null +++ b/include/sound/simple_card_core.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..59c2e66 100644 --- a/sound/soc/generic/Kconfig +++ b/sound/soc/generic/Kconfig @@ -1,3 +1,6 @@ +config SND_SIMPLE_CARD_CORE + 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..d8a982d 100644 --- a/sound/soc/generic/Makefile +++ b/sound/soc/generic/Makefile @@ -1,3 +1,5 @@ +obj-$(CONFIG_SND_SIMPLE_CARD_CORE) := simple-card-core.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-core.c b/sound/soc/generic/simple-card-core.c new file mode 100644 index 0000000..ddef5d1 --- /dev/null +++ b/sound/soc/generic/simple-card-core.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);