From patchwork Tue May 31 09:01:09 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kuninori Morimoto X-Patchwork-Id: 9143847 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 E3F4960757 for ; Tue, 31 May 2016 09:01:21 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D87F327BF1 for ; Tue, 31 May 2016 09:01:21 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id CD6202821C; Tue, 31 May 2016 09:01:21 +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 664E427BF1 for ; Tue, 31 May 2016 09:01:17 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756816AbcEaJBQ (ORCPT ); Tue, 31 May 2016 05:01:16 -0400 Received: from relmlor3.renesas.com ([210.160.252.173]:36312 "EHLO relmlie2.idc.renesas.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1756609AbcEaJBO (ORCPT ); Tue, 31 May 2016 05:01:14 -0400 Received: from unknown (HELO relmlir2.idc.renesas.com) ([10.200.68.152]) by relmlie2.idc.renesas.com with ESMTP; 31 May 2016 18:01:12 +0900 Received: from relmlac3.idc.renesas.com (relmlac3.idc.renesas.com [10.200.69.23]) by relmlir2.idc.renesas.com (Postfix) with ESMTP id 75BF450043; Tue, 31 May 2016 18:01:12 +0900 (JST) Received: by relmlac3.idc.renesas.com (Postfix, from userid 0) id 564411806F; Tue, 31 May 2016 18:01:12 +0900 (JST) Received: from relmlac3.idc.renesas.com (localhost [127.0.0.1]) by relmlac3.idc.renesas.com (Postfix) with ESMTP id 4DBC91800A; Tue, 31 May 2016 18:01:12 +0900 (JST) Received: from relmlii2.idc.renesas.com [10.200.68.66] by relmlac3.idc.renesas.com with ESMTP id UAE08325; Tue, 31 May 2016 18:01:12 +0900 X-IronPort-AV: E=Sophos;i="5.22,559,1449500400"; d="scan'";a="212431643" Received: from mail-pu1apc01lp0024.outbound.protection.outlook.com (HELO APC01-PU1-obe.outbound.protection.outlook.com) ([65.55.88.24]) by relmlii2.idc.renesas.com with ESMTP/TLS/AES256-SHA; 31 May 2016 18:01:11 +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=I9T0f6cyMc5EaUAvuppw6EPRzu2n1sZK0OR7EAo2rzM=; b=luMJhqb7UfHQcB+cKJpWCycP0TrahA7kk8e7tmYU1jm+tWARo7YP9nOY/HiHVSIPu8Hynk+9BwI7mC56WP7EMLhFQNosR7EfliGc6NySFmJTykOxxczZ0XfRVrktiHi5AAIJEcwMwrxuPVxZA9al+JWa1FO99UfanFt4B/nRfMY= 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 KL1PR06MB1702.apcprd06.prod.outlook.com (10.167.63.16) with Microsoft SMTP Server (TLS) id 15.1.506.9; Tue, 31 May 2016 09:01:09 +0000 Message-ID: <877feasj3i.wl%kuninori.morimoto.gx@renesas.com> From: Kuninori Morimoto Subject: [PATCH 06/39 v2] 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: <87fusysjam.wl%kuninori.morimoto.gx@renesas.com> References: <87fusysjam.wl%kuninori.morimoto.gx@renesas.com> MIME-Version: 1.0 (generated by SEMI-EPG 1.14.7 - "Harue") Date: Tue, 31 May 2016 09:01:09 +0000 X-Originating-IP: [211.11.155.144] X-ClientProxiedBy: TY1PR01CA0003.jpnprd01.prod.outlook.com (10.161.131.141) To KL1PR06MB1702.apcprd06.prod.outlook.com (10.167.63.16) X-MS-Office365-Filtering-Correlation-Id: 75c29e75-48a6-4e42-d684-08d389321c07 X-Microsoft-Exchange-Diagnostics: 1; KL1PR06MB1702; 2:AWhVlOQ8VUkx0dMYgRZchatsVEvaqw/oU9midaI1r7aHph2hURI5YIaLmvT2XHmqc3hwHgrHGGsDS0wdOP1Wv/RpE4I/r+uFpP/SeJ4U1GVng+q2nCJ3ABVsb5L1yIUnipptGKuPtV4KgITfgfKp781W6dxaFpzDOunjUfGOn+nNN+vxpn/u0npvihChAUJv; 3:RLdRVod4ehiCnVSQiupa3YwngW2/zKorbvvgA9QqL4eQQIOwlH0WUU1wbigaPeNrJhxfjjoKqKcAzlrGddOKRUjPui50r5h7bqvFgJgRJStUCRWNLc5ujWkgnm87xdKu X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:;SRVR:KL1PR06MB1702; X-Microsoft-Exchange-Diagnostics: 1; KL1PR06MB1702; 25:1nueLgNEI11lZ2gvxsOYAO1lOZWCQ0DUth0ns2aoIqpJNXR+6X556ogcQVNip9sirI2oCQkdqOxNJkOTJfag+wWuOhbJALOC0+gy1GrDHLwkoxiwWsgexsb0INveTc/dS8sUWcMHe+e1K2Y1AtNdNDBRVmOcA1c8zcr+JB4iNamvBSspADIqPsNJLdkkzj+wP7bIMZvcl43XIMoDnrqo/0A6tTMjmFcYgR6HPaHJfCblRLcQ00a6uJQzTREoZWm+FYFiCgI9i2PVny2oTQiTQvgdQw1Mjs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qb2CBV5tPla1wKrltQurmmR3SL2hqe9EusZuKBM9Z1uDwSnYa+2KcSXCJPPkfAqSPVCRH6GlcLvCBFUR6zJu4rvZbmYrfoQdV9wWHA7jkh6s66gpgMzgafz1DxF3FAUBr9iQnTOKXr2T1yqnLxPNHUdH1uTaY2822BxH3EpscmgpSoqG4ToP4Bjfn/qPVyWaAQFAnqcGPzzMtF2RLQLwXKvD9l3JFpagFbrj7jWn7V7KTcyL3ig7Q+g8fpdeyZooM8XBJFvQ90neqww+FnQ6x4hHW4PQhIl8A1jN+SU1uA== 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:KL1PR06MB1702; BCL:0; PCL:0; RULEID:; SRVR:KL1PR06MB1702; X-Forefront-PRVS: 095972DF2F X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10019020)(4630300001)(6009001)(33646002)(5004730100002)(110136002)(36756003)(77096005)(42186005)(92566002)(53416004)(19580405001)(8676002)(5008740100001)(189998001)(66066001)(83506001)(230783001)(46406003)(229853001)(19580395003)(4001350100001)(2950100001)(81166006)(3846002)(586003)(47776003)(23726003)(6116002)(4326007)(2906002)(54356999)(50986999)(76176999)(86362001)(50466002)(16060500001); DIR:OUT; SFP:1102; SCL:1; SRVR:KL1PR06MB1702; H:morimoto-PC.renesas.com; FPR:; SPF:None; MLV:sfv; LANG:en; X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; KL1PR06MB1702; 23:8oz5N5okTcggmX6v/s64xHyGinVLdzMEjlmlKpBiK?= =?us-ascii?Q?9DeqvrAdxl4mpcLabE2C3F5CRPoIhJ2l0x4V9/0Z03S+Snq/avLfr/ij6sjM?= =?us-ascii?Q?ysteBrfF/pPfoMSqlddJqqbrm0lVckBWIXfLZuanTMnvGVG+C2Nq6ZvjwwX8?= =?us-ascii?Q?geOwFlJOcHkrgKMeOD9wHxOQM1gSaNtpmLCxz9Bd1S4rPWsqZCyv5newmDtT?= =?us-ascii?Q?zg02vY8cXIYu+CvAJq6c/t3fqHAMJN4B4bFU/m/j/9MaoSIh9DkcVTdfP1ug?= =?us-ascii?Q?jh+twNJ81N+8U7w7Z9al6L3ok6E4sxI9WRFW1S31E4+rDu2K3oYvVxUp3HVv?= =?us-ascii?Q?HB/SW0gQRXS+w4o6hQlYbmEU6V1r23u3GK+0Eg/aDThOQ/M8Hldl5YAi7dV2?= =?us-ascii?Q?spFk1GkqUA2H7024OFcc1AMGdZuf9N/DZaQigXxiJPTKxspFP9VSDEFNGDON?= =?us-ascii?Q?RtT6rlup5AWwfRIgqSfEEtxavUn+jZtJaf/qGsplT75EzYoiwgkuv7mRDJSm?= =?us-ascii?Q?rIkBm8vFlDeN6GaMxX91VSVJnPlZq874/kY8Yg4zVsp8lHsySeh+PoObdBcy?= =?us-ascii?Q?UIYWKxeo2JA18Dl9pIJ5xYw+mO7BoxwruJs+iyyHIr3Li7zQjXNiEzsTFaoM?= =?us-ascii?Q?aqVCGZvayeCQ+WcvzLmMWKx0BIlB4XO0vwtsz915vmrfZPZd/sfWdxKqircv?= =?us-ascii?Q?WegNp2BWa+j69EiePaT6VbJyspy9pzWVdg96Gs7xFKkzn6oVepTlBtUm5a+O?= =?us-ascii?Q?ZI4i6S+rNpBqSH2lqQYRMGP5BwS3EVnkvwbGdh87hf1vi8PkcnXymXqr/3d0?= =?us-ascii?Q?l5WlrIbvniPATReOdQY9r9Vc1tC8cQol2xPUomMcRvBtSH5dfNe5bmB0pb8V?= =?us-ascii?Q?6GFG3q1FakaQHQ0RK04isNaYaau0046+tfNqSX93GOvBCV3/qz+ISf/EgoAN?= =?us-ascii?Q?Ft3939MSN54r4zFB4KZmRun+GnmilT53E0UZArEY3zrnzT8NrtthHj9Ml+zU?= =?us-ascii?Q?r4=3D?= X-Microsoft-Exchange-Diagnostics: 1; KL1PR06MB1702; 5:Jog9U3pcs2u2v6qcPXDTALUM8rOcWXfUNtIfLax6ZOoVwnZO+DLkCbMTpwyWzRAExKxXPv0c9aoPGEUX11mawbOqmG6AVUbypNMxZzCyQC3IdqFDbguL0eNWoYV+ZQq0bfMBGuzps8UP19CQOb9xbw==; 24:UJQxJYGBaRaWSRYKA0npX0P69BgRSBso6cjqu78CxCyPn0VYhcanu+iAVEjcFtSN/LftvFqepSr+bXEkgB9v5xtJm3VYWLS1tEi90MRML5A=; 7:LKuEBXJ+2Ydt64fDnwTvb3LrwF2zcQjr0xeL7fjR4OJy4/XU3clLr5krqDSZzb6QHAYgeLs9/mNUV6hLEi4oxv6oLMoyQKYat9QCzyvfLOnAB2rwDWlnP8o1EGBt80rPvXEoPjjSfKZimcj0lHIA18Xy3RrY90yY5C6Xqmxnsb5JdTwrpohlxUNihd77FQja; 20:tzc3vGTwp2c47WTxpH8Id9HjvIqeBXNgBxImgcvVbZDmM/9yLb76MZxTVHiqgcmFjRL3FBZLW5tcrQ+zCftGU+7Ln1UG/wI/qd89Nq7CSre//BcgXODrCpp3mbPvH6Yd6jWm2laDNZm9X7ic7rfhHKKJVpvU/0tNHG/s9kjK/to= SpamDiagnosticOutput: 1:23 SpamDiagnosticMetadata: NSPM X-OriginatorOrg: renesas.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 31 May 2016 09:01:09.4767 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-Transport-CrossTenantHeadersStamped: KL1PR06MB1702 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);