From patchwork Tue Sep 2 09:26:06 2014
Content-Type: text/plain; charset="utf-8"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
X-Patchwork-Submitter: Xiubo Li
X-Patchwork-Id: 4824141
Return-Path:
X-Original-To: patchwork-alsa-devel@patchwork.kernel.org
Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org
Received: from mail.kernel.org (mail.kernel.org [198.145.19.201])
by patchwork2.web.kernel.org (Postfix) with ESMTP id 41B30C0338
for ;
Tue, 2 Sep 2014 10:18:05 +0000 (UTC)
Received: from mail.kernel.org (localhost [127.0.0.1])
by mail.kernel.org (Postfix) with ESMTP id 0E123201BB
for ;
Tue, 2 Sep 2014 10:18:04 +0000 (UTC)
Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243])
by mail.kernel.org (Postfix) with ESMTP id 6CF16200E6
for ;
Tue, 2 Sep 2014 10:18:02 +0000 (UTC)
Received: by alsa0.perex.cz (Postfix, from userid 1000)
id 9004F265388; Tue, 2 Sep 2014 12:18:00 +0200 (CEST)
X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org
X-Spam-Level:
X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,NO_DNS_FOR_FROM,
UNPARSEABLE_RELAY autolearn=no version=3.3.1
Received: from alsa0.perex.cz (localhost [IPv6:::1])
by alsa0.perex.cz (Postfix) with ESMTP id 193C92652E4;
Tue, 2 Sep 2014 12:17:49 +0200 (CEST)
X-Original-To: alsa-devel@alsa-project.org
Delivered-To: alsa-devel@alsa-project.org
Received: by alsa0.perex.cz (Postfix, from userid 1000)
id 4C9AB26530D; Tue, 2 Sep 2014 12:17:48 +0200 (CEST)
Received: from na01-bn1-obe.outbound.protection.outlook.com
(mail-bn1blp0190.outbound.protection.outlook.com [207.46.163.190])
by alsa0.perex.cz (Postfix) with ESMTP id C322426523B
for ;
Tue, 2 Sep 2014 12:17:39 +0200 (CEST)
Received: from CH1PR03CA010.namprd03.prod.outlook.com (10.255.156.155) by
DM2PR0301MB0623.namprd03.prod.outlook.com (25.160.95.27) with
Microsoft SMTP
Server (TLS) id 15.0.1015.19; Tue, 2 Sep 2014 10:17:36 +0000
Received: from BY2FFO11FD041.protection.gbl (10.255.156.132) by
CH1PR03CA010.outlook.office365.com (10.255.156.155) with Microsoft
SMTP Server (TLS) id 15.0.1019.16 via Frontend Transport;
Tue, 2 Sep 2014 10:17:35 +0000
Received: from az84smr01.freescale.net (192.88.158.2) by
BY2FFO11FD041.mail.protection.outlook.com (10.1.14.226) with
Microsoft SMTP Server (TLS) id 15.0.1010.11 via Frontend Transport;
Tue, 2 Sep 2014 10:17:35 +0000
Received: from rock.ap.freescale.net (rock.ap.freescale.net [10.193.20.106])
by az84smr01.freescale.net (8.14.3/8.14.0) with ESMTP id
s82AHMfX032512; Tue, 2 Sep 2014 03:17:30 -0700
From: Xiubo Li
To: , , ,
, , ,
, ,
, ,
, , ,
,
Date: Tue, 2 Sep 2014 17:26:06 +0800
Message-ID: <1409649969-15759-2-git-send-email-Li.Xiubo@freescale.com>
X-Mailer: git-send-email 1.8.4
In-Reply-To: <1409649969-15759-1-git-send-email-Li.Xiubo@freescale.com>
References: <1409649969-15759-1-git-send-email-Li.Xiubo@freescale.com>
X-EOPAttributedMessage: 0
X-Forefront-Antispam-Report: CIP:192.88.158.2; CTRY:US; IPV:CAL; IPV:NLI;
EFV:NLI; SFV:NSPM;
SFS:(6009001)(189002)(199003)(47776003)(20776003)(84676001)(87286001)(64706001)(80022001)(26826002)(83072002)(86362001)(92566001)(88136002)(89996001)(85306004)(2201001)(85852003)(62966002)(77156001)(21056001)(36756003)(93916002)(102836001)(104016003)(92726001)(104166001)(50986999)(81342001)(46102001)(76176999)(99396002)(50466002)(48376002)(6806004)(44976005)(4396001)(50226001)(83322001)(19580405001)(19580395003)(68736004)(69596002)(97736001)(106466001)(31966008)(76482001)(107046002)(77982001)(79102001)(87936001)(74662001)(90102001)(81156004)(74502001)(81542001)(105606002)(229853001)(95666004)(921003)(1121002);
DIR:OUT; SFP:; SCL:1; SRVR:DM2PR0301MB0623; H:az84smr01.freescale.net;
FPR:;
MLV:ovrnspm; PTR:InfoDomainNonexistent; MX:1; A:1; LANG:en;
MIME-Version: 1.0
X-Microsoft-Antispam: BCL:0;PCL:0;RULEID:;UriScan:;
X-Forefront-PRVS: 0322B4EDE1
Received-SPF: Fail (protection.outlook.com: domain of freescale.com does not
designate 192.88.158.2 as permitted sender)
receiver=protection.outlook.com;
client-ip=192.88.158.2; helo=az84smr01.freescale.net;
Authentication-Results: spf=fail (sender IP is 192.88.158.2)
smtp.mailfrom=Li.Xiubo@freescale.com;
X-OriginatorOrg: freescale.com
Cc: Xiubo Li , linux-kernel@vger.kernel.org
Subject: [alsa-devel] [PATCHv2 1/4] ASoC: simple-card: add
asoc_simple_card_fmt_master() to simplify the code.
X-BeenThere: alsa-devel@alsa-project.org
X-Mailman-Version: 2.1.14
Precedence: list
List-Id: "Alsa-devel mailing list for ALSA developers -
http://www.alsa-project.org"
List-Unsubscribe:
,
List-Archive:
List-Post:
List-Help:
List-Subscribe: ,
Errors-To: alsa-devel-bounces@alsa-project.org
Sender: alsa-devel-bounces@alsa-project.org
X-Virus-Scanned: ClamAV using ClamSMTP
Signed-off-by: Xiubo Li
---
sound/soc/generic/simple-card.c | 61 ++++++++++++++++++++---------------------
1 file changed, 29 insertions(+), 32 deletions(-)
diff --git a/sound/soc/generic/simple-card.c b/sound/soc/generic/simple-card.c
index 986d2c7..cad2b30 100644
--- a/sound/soc/generic/simple-card.c
+++ b/sound/soc/generic/simple-card.c
@@ -163,6 +163,26 @@ asoc_simple_card_sub_parse_of(struct device_node *np,
return 0;
}
+static inline unsigned int
+asoc_simple_card_fmt_master(struct device_node *np,
+ struct device_node *bitclkmaster,
+ struct device_node *framemaster)
+{
+ switch (((np == bitclkmaster) << 4) | (np == framemaster)) {
+ case 0x11:
+ return SND_SOC_DAIFMT_CBS_CFS;
+ case 0x10:
+ return SND_SOC_DAIFMT_CBS_CFM;
+ case 0x01:
+ return SND_SOC_DAIFMT_CBM_CFS;
+ default:
+ return SND_SOC_DAIFMT_CBM_CFM;
+ }
+
+ /* Shouldn't be here */
+ return -EINVAL;
+}
+
static int asoc_simple_card_dai_link_of(struct device_node *node,
struct device *dev,
struct snd_soc_dai_link *dai_link,
@@ -172,7 +192,7 @@ static int asoc_simple_card_dai_link_of(struct device_node *node,
struct device_node *np = NULL;
struct device_node *bitclkmaster = NULL;
struct device_node *framemaster = NULL;
- unsigned int daifmt;
+ unsigned int daifmt, fmt;
char *name;
char prop[128];
char *prefix = "";
@@ -185,6 +205,7 @@ static int asoc_simple_card_dai_link_of(struct device_node *node,
&bitclkmaster, &framemaster);
daifmt &= ~SND_SOC_DAIFMT_MASTER_MASK;
+ /* Parse CPU DAI sub-node */
snprintf(prop, sizeof(prop), "%scpu", prefix);
np = of_get_child_by_name(node, prop);
if (!np) {
@@ -199,23 +220,11 @@ static int asoc_simple_card_dai_link_of(struct device_node *node,
if (ret < 0)
goto dai_link_of_err;
- dai_props->cpu_dai.fmt = daifmt;
- switch (((np == bitclkmaster) << 4) | (np == framemaster)) {
- case 0x11:
- dai_props->cpu_dai.fmt |= SND_SOC_DAIFMT_CBS_CFS;
- break;
- case 0x10:
- dai_props->cpu_dai.fmt |= SND_SOC_DAIFMT_CBS_CFM;
- break;
- case 0x01:
- dai_props->cpu_dai.fmt |= SND_SOC_DAIFMT_CBM_CFS;
- break;
- default:
- dai_props->cpu_dai.fmt |= SND_SOC_DAIFMT_CBM_CFM;
- break;
- }
-
+ fmt = asoc_simple_card_fmt_master(np, bitclkmaster, framemaster);
+ dai_props->cpu_dai.fmt = daifmt | fmt;
of_node_put(np);
+
+ /* Parse CODEC DAI sub-node */
snprintf(prop, sizeof(prop), "%scodec", prefix);
np = of_get_child_by_name(node, prop);
if (!np) {
@@ -240,21 +249,9 @@ static int asoc_simple_card_dai_link_of(struct device_node *node,
snd_soc_of_parse_daifmt(np, NULL, NULL, NULL) |
(daifmt & ~SND_SOC_DAIFMT_CLOCK_MASK);
} else {
- dai_props->codec_dai.fmt = daifmt;
- switch (((np == bitclkmaster) << 4) | (np == framemaster)) {
- case 0x11:
- dai_props->codec_dai.fmt |= SND_SOC_DAIFMT_CBM_CFM;
- break;
- case 0x10:
- dai_props->codec_dai.fmt |= SND_SOC_DAIFMT_CBM_CFS;
- break;
- case 0x01:
- dai_props->codec_dai.fmt |= SND_SOC_DAIFMT_CBS_CFM;
- break;
- default:
- dai_props->codec_dai.fmt |= SND_SOC_DAIFMT_CBS_CFS;
- break;
- }
+ fmt = asoc_simple_card_fmt_master(np, bitclkmaster,
+ framemaster);
+ dai_props->codec_dai.fmt = daifmt | fmt;
}
if (!dai_link->cpu_dai_name || !dai_link->codec_dai_name) {