From patchwork Fri Jun 24 01:16:32 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kuninori Morimoto X-Patchwork-Id: 9196271 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 BEF866075A for ; Fri, 24 Jun 2016 01:16:38 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id ADBAA2847D for ; Fri, 24 Jun 2016 01:16:38 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id A210228483; Fri, 24 Jun 2016 01:16:38 +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 20B1C2847D for ; Fri, 24 Jun 2016 01:16:38 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751260AbcFXBQh (ORCPT ); Thu, 23 Jun 2016 21:16:37 -0400 Received: from relmlor2.renesas.com ([210.160.252.172]:61451 "EHLO relmlie1.idc.renesas.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1750971AbcFXBQg (ORCPT ); Thu, 23 Jun 2016 21:16:36 -0400 Received: from unknown (HELO relmlir2.idc.renesas.com) ([10.200.68.152]) by relmlie1.idc.renesas.com with ESMTP; 24 Jun 2016 10:16:34 +0900 Received: from relmlac1.idc.renesas.com (relmlac1.idc.renesas.com [10.200.69.21]) by relmlir2.idc.renesas.com (Postfix) with ESMTP id D33954589B; Fri, 24 Jun 2016 10:16:34 +0900 (JST) Received: by relmlac1.idc.renesas.com (Postfix, from userid 0) id CE84C8002E; Fri, 24 Jun 2016 10:16:34 +0900 (JST) Received: from relmlac1.idc.renesas.com (localhost [127.0.0.1]) by relmlac1.idc.renesas.com (Postfix) with ESMTP id C63A88002D; Fri, 24 Jun 2016 10:16:34 +0900 (JST) Received: from relmlii2.idc.renesas.com [10.200.68.66] by relmlac1.idc.renesas.com with ESMTP id LAD21030; Fri, 24 Jun 2016 10:16:34 +0900 X-IronPort-AV: E=Sophos;i="5.22,559,1449500400"; d="scan'";a="214136568" Received: from mail-pu1apc01lp0016.outbound.protection.outlook.com (HELO APC01-PU1-obe.outbound.protection.outlook.com) ([65.55.88.16]) by relmlii2.idc.renesas.com with ESMTP/TLS/AES256-SHA; 24 Jun 2016 10:16:34 +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=I9T0f6cyMc5EaUAvuppw6EPRzu2n1sZK0OR7EAo2rzM=; b=lcoFxDvz/lnZd5DIErt5bTiOsPlJYYr4YReSzHTdbvQjh6T6l4yY5UsTGotUuR7GRKMKOiFLNx88ymOdeP8JDhmpoNTG7e4vjVUEP69RnYVaYRDWnmT0lPgxJFuepHSD+jcWUmz/er0XiggliWbAqLZP36NAMaYcSKlZCrU+t2Q= 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 HK2PR06MB1700.apcprd06.prod.outlook.com (10.167.73.14) with Microsoft SMTP Server (TLS) id 15.1.523.12; Fri, 24 Jun 2016 01:16:32 +0000 Message-ID: <87shw3xui4.wl%kuninori.morimoto.gx@renesas.com> From: Kuninori Morimoto Subject: [PATCH 03/11] ASoC: simple-card-utils: add asoc_simple_card_parse_dailink_name() 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:16:32 +0000 X-Originating-IP: [211.11.155.144] X-ClientProxiedBy: KAWPR01CA0045.jpnprd01.prod.outlook.com (10.165.48.155) To HK2PR06MB1700.apcprd06.prod.outlook.com (10.167.73.14) X-MS-Office365-Filtering-Correlation-Id: 00d90c6c-2d55-4f1c-a3d6-08d39bcd2dc6 X-Microsoft-Exchange-Diagnostics: 1; HK2PR06MB1700; 2:jH1CiIGSSy8vuVxEyy/gbrEvlAQcFBUSFi1b6Y5QIiZdSKofKTdqBMqMnHPI3CA0/t6wSn9t0RhYi0naz6Ow1SCouL2bX/otrg+XRx2qoYj5djNtLP7ZAPLAo2Ou0HTpMS/ser85BUauFvFWCBqmCURV1dCqBA8jmKJWFAUv4wfPeHYHcYVr1iqnkP2ddnVo; 3:ktH/+bTD/5wkxwOrynTfCvNl7DWS1HLVD/JugZzZBKjFnpOOp/28Oe47q9icluUX1ZhGxRj9/RO6w4nWxafpELIc3nCuUFlGqYWVInxUblsSpUIMWMvEzIhQk8+8rdq1; 25:+vAtX7NqwXbkhm4uTtSYjxVBHfc0e/p21naEoOQcvoGrQPfwqGzPHIrjuo7fCSEDHMPHI5nf10EiRKthUCpYt2vn5cd4txm0WBDUKlcXJDEN9RAvk4pq4bn1PBbUogA6K+ywcx20LDQTM0KPmUUbMxU81IuUL5PLjxiNnCCY8K1Gn0CUnKVTxfJHn//1u3NDVs9SAXhKzGqh9SBLH+Jn1qpUOj0NiGE7pAVr0gpbw7958/f+1aU3DlwiU9yGwqPgXo2yz52uc9GDnITa1KFIYjyukJHylo1onh86MnhA8p9wSADr8eFnLtM3evaN4vQpwgdS4fXR9UQwX6tR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gDxPxDLDMeSWjiyzQrK9gmw== 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:HK2PR06MB1700; BCL:0; PCL:0; RULEID:; SRVR:HK2PR06MB1700; X-Forefront-PRVS: 0983EAD6B2 X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10019020)(4630300001)(6009001)(7916002)(189002)(199003)(66066001)(92566002)(77096005)(47776003)(53416004)(42186005)(110136002)(97736004)(4001350100001)(86362001)(189998001)(229853001)(106356001)(230783001)(19580405001)(19580395003)(50466002)(36756003)(50986999)(83506001)(69596002)(46406003)(33646002)(54356999)(105586002)(76176999)(101416001)(305945005)(81156014)(2950100001)(81166006)(7736002)(586003)(23726003)(6116002)(3846002)(7846002)(4326007)(68736007)(2906002)(8676002)(16060500001); DIR:OUT; SFP:1102; SCL:1; SRVR:HK2PR06MB1700; H:morimoto-PC.renesas.com; FPR:; SPF:None; PTR:InfoNoRecords; MX:1; A:1; LANG:en; X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; HK2PR06MB1700; 23:GsYQZpYmtjkXhfoRoq0un+ITuNqIFUYGe2FLbP8GN?= =?us-ascii?Q?71kWJScISf5Nc4tPTJ19PjG20s/u1z2rsXuV5V7wyFJfN47BuhRBHXGH2ioD?= =?us-ascii?Q?H6vLpKORokSHbpJO5mgoq7CYqBw6npmi8gnMKd/5q+4k4Rxz5bXUk0AN1N1R?= =?us-ascii?Q?tK5Q13B6d+0ZaA9JAb7WbusV1gz1Qf3B9l0yPqDLmV6+RKBu2KrlDmZp8urm?= =?us-ascii?Q?QF9NUZBhv22IkGQvyUiHMiStkG9/sSTUysSlfL8prF1Yh8Kxheq1+NrFbIDy?= =?us-ascii?Q?QzQdVHTPXc4PFTzV4qN9ox1R0nWOXBud5Uw/esuNKGgWqbpcrSZe+oR6zViS?= =?us-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sDVkOXLxliyW/zkaJVtSwAHQ3AkEhrRKLajhFXBgfHmef2pCeA4pXVqrl7C7YL+voRZYW3LIiIB5eF/lvNtX/5Q9E+FOcNuXc12bfTog/tUyvbK26flRmcnaLZvs= X-OriginatorOrg: renesas.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 24 Jun 2016 01:16:32.3441 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-Transport-CrossTenantHeadersStamped: HK2PR06MB1700 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 simple-card is creating dai_link->name / dai_link->stream_name. These are based on CPU + Codec name. It can be "fe.CPU" or "be.Codec" if it was DPCM. This patch adds simple card common function for it. Signed-off-by: Kuninori Morimoto --- include/sound/simple_card_utils.h | 2 ++ sound/soc/generic/simple-card-utils.c | 42 +++++++++++++++++++++++++++++++++++ 2 files changed, 44 insertions(+) diff --git a/include/sound/simple_card_utils.h b/include/sound/simple_card_utils.h index 6bb2c5f..41e567b 100644 --- a/include/sound/simple_card_utils.h +++ b/include/sound/simple_card_utils.h @@ -29,5 +29,7 @@ int asoc_simple_card_parse_daifmt(struct device *dev, unsigned int *retfmt); int asoc_simple_card_parse_tdm(struct device_node *port_np, struct asoc_simple_dai *simple_dai); +int asoc_simple_card_parse_dailink_name(struct device *dev, + struct snd_soc_dai_link *dai_link); #endif /* __SIMPLE_CARD_CORE_H */ diff --git a/sound/soc/generic/simple-card-utils.c b/sound/soc/generic/simple-card-utils.c index 86fb2cf..9b49b5a 100644 --- a/sound/soc/generic/simple-card-utils.c +++ b/sound/soc/generic/simple-card-utils.c @@ -63,3 +63,45 @@ int asoc_simple_card_parse_tdm(struct device_node *port_np, &simple_dai->slot_width); } EXPORT_SYMBOL_GPL(asoc_simple_card_parse_tdm); + +int asoc_simple_card_parse_dailink_name(struct device *dev, + struct snd_soc_dai_link *dai_link) +{ + char *name = NULL; + int ret = -ENOMEM; + + if (dai_link->dynamic && dai_link->cpu_dai_name) { + name = devm_kzalloc(dev, + strlen(dai_link->cpu_dai_name) + 4, + GFP_KERNEL); + if (name) + sprintf(name, "fe.%s", dai_link->cpu_dai_name); + + } else if (dai_link->no_pcm && dai_link->codec_dai_name) { + name = devm_kzalloc(dev, + strlen(dai_link->codec_dai_name) + 4, + GFP_KERNEL); + if (name) + sprintf(name, "be.%s", dai_link->codec_dai_name); + } else if (dai_link->cpu_dai_name && dai_link->codec_dai_name) { + name = devm_kzalloc(dev, + strlen(dai_link->cpu_dai_name) + + strlen(dai_link->codec_dai_name) + 2, + GFP_KERNEL); + if (name) { + sprintf(name, "%s-%s", + dai_link->cpu_dai_name, + dai_link->codec_dai_name); + } + } + + if (name) { + ret = 0; + + dai_link->name = + dai_link->stream_name = name; + } + + return ret; +} +EXPORT_SYMBOL_GPL(asoc_simple_card_parse_dailink_name);