From patchwork Thu Mar 19 04:12:50 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kuninori Morimoto X-Patchwork-Id: 6045591 Return-Path: X-Original-To: patchwork-alsa-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id AC49F9F440 for ; Thu, 19 Mar 2015 04:13:30 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id C5201204D5 for ; Thu, 19 Mar 2015 04:13:29 +0000 (UTC) Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) by mail.kernel.org (Postfix) with ESMTP id A08E3202F2 for ; Thu, 19 Mar 2015 04:13:28 +0000 (UTC) Received: by alsa0.perex.cz (Postfix, from userid 1000) id B71BD265341; Thu, 19 Mar 2015 05:13:27 +0100 (CET) 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 D82ED260560; Thu, 19 Mar 2015 05:13:16 +0100 (CET) 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 85B6B260560; Thu, 19 Mar 2015 05:13:15 +0100 (CET) Received: from relmlie3.idc.renesas.com (relmlor4.renesas.com [210.160.252.174]) by alsa0.perex.cz (Postfix) with ESMTP id C17D926533B for ; Thu, 19 Mar 2015 05:12:55 +0100 (CET) Received: from unknown (HELO relmlir4.idc.renesas.com) ([10.200.68.154]) by relmlie3.idc.renesas.com with ESMTP; 19 Mar 2015 13:12:53 +0900 Received: from relmlac2.idc.renesas.com (relmlac2.idc.renesas.com [10.200.69.22]) by relmlir4.idc.renesas.com (Postfix) with ESMTP id 8624B4D026; Thu, 19 Mar 2015 13:12:53 +0900 (JST) Received: by relmlac2.idc.renesas.com (Postfix, from userid 0) id 842002806E; Thu, 19 Mar 2015 13:12:53 +0900 (JST) Received: from relmlac2.idc.renesas.com (localhost [127.0.0.1]) by relmlac2.idc.renesas.com (Postfix) with ESMTP id 801D42806D; Thu, 19 Mar 2015 13:12:53 +0900 (JST) Received: from relmlii2.idc.renesas.com [10.200.68.66] by relmlac2.idc.renesas.com with ESMTP id PAY11469; Thu, 19 Mar 2015 13:12:53 +0900 X-IronPort-AV: E=Sophos;i="5.11,427,1422889200"; d="scan'208";a="183430594" Received: from mail-hk1lp0121.outbound.protection.outlook.com (HELO APAC01-HK1-obe.outbound.protection.outlook.com) ([207.46.51.121]) by relmlii2.idc.renesas.com with ESMTP/TLS/AES256-SHA; 19 Mar 2015 13:12:52 +0900 Received: from morimoto-PC.renesas.com (211.11.155.132) by SIXPR06MB320.apcprd06.prod.outlook.com (10.141.125.150) with Microsoft SMTP Server (TLS) id 15.1.118.21; Thu, 19 Mar 2015 04:12:50 +0000 Message-ID: <87lhiteic9.wl%kuninori.morimoto.gx@renesas.com> From: Kuninori Morimoto User-Agent: Wanderlust/2.15.9 Emacs/24.3 Mule/6.0 MIME-Version: 1.0 (generated by SEMI-EPG 1.14.7 - "Harue") To: Mark Brown In-Reply-To: <87mw39eide.wl%kuninori.morimoto.gx@renesas.com> References: <87mw39eide.wl%kuninori.morimoto.gx@renesas.com> Date: Thu, 19 Mar 2015 04:12:50 +0000 X-Originating-IP: [211.11.155.132] X-ClientProxiedBy: OS2PR01CA0008.jpnprd01.prod.outlook.com (25.161.74.146) To SIXPR06MB320.apcprd06.prod.outlook.com (10.141.125.150) Authentication-Results: kernel.org; dkim=none (message not signed) header.d=none; X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:;SRVR:SIXPR06MB320; X-Microsoft-Antispam-PRVS: X-Forefront-Antispam-Report: BMV:1; SFV:NSPM; SFS:(10019020)(6009001)(19580395003)(19580405001)(33646002)(83506001)(23726002)(229853001)(46102003)(110136001)(40100003)(77096005)(122386002)(77156002)(62966003)(42186005)(53416004)(87976001)(66066001)(47776003)(50986999)(46406003)(2950100001)(54356999)(86362001)(92566002)(50466002)(36756003); DIR:OUT; SFP:1102; SCL:1; SRVR:SIXPR06MB320; H:morimoto-PC.renesas.com; FPR:; SPF:None; MLV:sfv; LANG:en; X-Exchange-Antispam-Report-Test: UriScan:; X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(601004)(5005006)(5002010); SRVR:SIXPR06MB320; BCL:0; PCL:0; RULEID:; SRVR:SIXPR06MB320; X-Forefront-PRVS: 052017CAF1 X-OriginatorOrg: renesas.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 19 Mar 2015 04:12:50.8397 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-Transport-CrossTenantHeadersStamped: SIXPR06MB320 Cc: Linux-ALSA , Simon , shiiba , Liam Girdwood , Das Biju Subject: [alsa-devel] [PATCH 01/10 v3] ASoC: core: add snd_soc_get_dai_drv() to get DAI driver 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 From: Kuninori Morimoto Sometimes sound card driver want to get cpu/codec driver. This patch adds snd_soc_get_dai_drv() and enable it. Signed-off-by: Kuninori Morimoto --- v2 -> v3 - keep .of_xlate_dai_name include/sound/soc.h | 1 + sound/soc/soc-core.c | 69 ++++++++++++++++++++++++++++++++++++---------------- 2 files changed, 49 insertions(+), 21 deletions(-) diff --git a/include/sound/soc.h b/include/sound/soc.h index bc6cfab..35f7aa5c 100644 --- a/include/sound/soc.h +++ b/include/sound/soc.h @@ -1508,6 +1508,7 @@ unsigned int snd_soc_of_parse_daifmt(struct device_node *np, const char *prefix, struct device_node **bitclkmaster, struct device_node **framemaster); +struct snd_soc_dai_driver *snd_soc_get_dai_drv(struct of_phandle_args *args); int snd_soc_of_get_dai_name(struct device_node *of_node, const char **dai_name); int snd_soc_of_get_dai_link_codecs(struct device *dev, diff --git a/sound/soc/soc-core.c b/sound/soc/soc-core.c index a85bd42..89eac2b 100644 --- a/sound/soc/soc-core.c +++ b/sound/soc/soc-core.c @@ -3454,6 +3454,47 @@ unsigned int snd_soc_of_parse_daifmt(struct device_node *np, } EXPORT_SYMBOL_GPL(snd_soc_of_parse_daifmt); +static struct snd_soc_dai_driver +*_snd_soc_get_dai_drv(struct of_phandle_args *args, + struct snd_soc_component *pos) +{ + int id = -1; + + switch (args->args_count) { + case 0: + id = 0; /* same as dai_drv[0] */ + break; + case 1: + id = args->args[0]; + break; + } + + if (id < 0 || id >= pos->num_dai) + return NULL; + + return pos->dai_drv + id; +} + +struct snd_soc_dai_driver +*snd_soc_get_dai_drv(struct of_phandle_args *args) +{ + struct snd_soc_dai_driver *drv = NULL; + struct snd_soc_component *pos; + + mutex_lock(&client_mutex); + list_for_each_entry(pos, &component_list, list) { + if (pos->dev->of_node != args->np) + continue; + + drv = _snd_soc_get_dai_drv(args, pos); + break; + } + mutex_unlock(&client_mutex); + + return drv; +} +EXPORT_SYMBOL_GPL(snd_soc_get_dai_drv); + static int snd_soc_get_dai_name(struct of_phandle_args *args, const char **dai_name) { @@ -3470,30 +3511,16 @@ static int snd_soc_get_dai_name(struct of_phandle_args *args, args, dai_name); } else { - int id = -1; + struct snd_soc_dai_driver *drv; - switch (args->args_count) { - case 0: - id = 0; /* same as dai_drv[0] */ - break; - case 1: - id = args->args[0]; - break; - default: - /* not supported */ - break; - } + drv = _snd_soc_get_dai_drv(args, pos); + if (drv) { + ret = 0; - if (id < 0 || id >= pos->num_dai) { - ret = -EINVAL; - continue; + *dai_name = drv->name; + if (!*dai_name) + *dai_name = pos->name; } - - ret = 0; - - *dai_name = pos->dai_drv[id].name; - if (!*dai_name) - *dai_name = pos->name; } break;