From patchwork Thu Apr 14 05:47:43 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kuninori Morimoto X-Patchwork-Id: 8831761 X-Patchwork-Delegate: geert@linux-m68k.org Return-Path: X-Original-To: patchwork-linux-renesas-soc@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id E0F7BC0553 for ; Thu, 14 Apr 2016 05:47:58 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 43971202EC for ; Thu, 14 Apr 2016 05:47:58 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 7DB4920114 for ; Thu, 14 Apr 2016 05:47:57 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752754AbcDNFr5 (ORCPT ); Thu, 14 Apr 2016 01:47:57 -0400 Received: from relmlor1.renesas.com ([210.160.252.171]:24915 "EHLO relmlie4.idc.renesas.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1752327AbcDNFrz (ORCPT ); Thu, 14 Apr 2016 01:47:55 -0400 Received: from unknown (HELO relmlir1.idc.renesas.com) ([10.200.68.151]) by relmlie4.idc.renesas.com with ESMTP; 14 Apr 2016 14:47:48 +0900 Received: from relmlac3.idc.renesas.com (relmlac3.idc.renesas.com [10.200.69.23]) by relmlir1.idc.renesas.com (Postfix) with ESMTP id 3437C4CAFF; Thu, 14 Apr 2016 14:47:48 +0900 (JST) Received: by relmlac3.idc.renesas.com (Postfix, from userid 0) id 1ABB51806F; Thu, 14 Apr 2016 14:47:48 +0900 (JST) Received: from relmlac3.idc.renesas.com (localhost [127.0.0.1]) by relmlac3.idc.renesas.com (Postfix) with ESMTP id 0D5DB1800A; Thu, 14 Apr 2016 14:47:48 +0900 (JST) Received: from relmlii2.idc.renesas.com [10.200.68.66] by relmlac3.idc.renesas.com with ESMTP id QAY25371; Thu, 14 Apr 2016 14:47:47 +0900 X-IronPort-AV: E=Sophos;i="5.22,559,1449500400"; d="scan'";a="209318843" Received: from mail-sg2apc01lp0240.outbound.protection.outlook.com (HELO APC01-SG2-obe.outbound.protection.outlook.com) ([65.55.88.240]) by relmlii2.idc.renesas.com with ESMTP/TLS/AES256-SHA; 14 Apr 2016 14:47:46 +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=BNw4D48lTIB/668/71MHdWYgsmMDIl6RkfuzCrqmQ5k=; b=F4BvBM9S8ZinhPPHc1QO9p+hBKGa2SZ6+YunuziovgZEHXzDLGgbassvdi9M5QU+0utIlwj1uKdPiQVzbjIi1q9VRue+SnVm0fh5gRbAHbZd8poErvXqyoD1TMcEI23jWK6mIzRBmzkiB1pOJkM1/xf0HBOTvbM8v9ch8OnSQZ8= 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 HK2PR06MB1698.apcprd06.prod.outlook.com (10.167.73.12) with Microsoft SMTP Server (TLS) id 15.1.453.26; Thu, 14 Apr 2016 05:47:43 +0000 Message-ID: <87y48gvj9i.wl%kuninori.morimoto.gx@renesas.com> From: Kuninori Morimoto Subject: [PATCH 2/4] ASoC: add of_parse_snd_connection_with_args() for sound-dai/graph connection User-Agent: Wanderlust/2.15.9 Emacs/24.3 Mule/6.0 To: Mark Brown , Laurent , Lars-Peter Clausen CC: Simon , Linux-Renesas , Linux-DT , Linux-ALSA , Liam Girdwood , Jose Abreu In-Reply-To: <871t68wxxe.wl%kuninori.morimoto.gx@renesas.com> References: <871t68wxxe.wl%kuninori.morimoto.gx@renesas.com> MIME-Version: 1.0 (generated by SEMI-EPG 1.14.7 - "Harue") Date: Thu, 14 Apr 2016 05:47:43 +0000 X-Originating-IP: [211.11.155.144] X-ClientProxiedBy: TY1PR01CA0032.jpnprd01.prod.outlook.com (10.164.162.142) To HK2PR06MB1698.apcprd06.prod.outlook.com (10.167.73.12) X-MS-Office365-Filtering-Correlation-Id: c06dea0a-71fd-4860-75a1-08d364284d23 X-Microsoft-Exchange-Diagnostics: 1; HK2PR06MB1698; 2:YReIvy42ul1pSQBaG7+MX+B+eHpApEPQcYm0oKEoF2IkNx5Ok+KWagMxHpJYQHXN+DvUrdQfaH1UmcZzc4OWxljvwXiOi4W0hJymf8dlb7DwYH7Jfgpjw+gnEZ6p8p8N+SKYCMSEUX9wWgy3qJunopVLTlVcD3YnsAKhTUspOtdhJh8tFTeQDnLWYcCaA+qZ; 3:Ax0yYop9j6oh3BVZv8Cd21BCNh1+3OmhyCoATvkkcc2di4eTZx6M+rUiz17cZIYbC1Y4F8LDtBYzRVYhkdov11bihgxgWqJBYTodep8ORP4In2oHC/bLn7px4XFGmCv1 X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:;SRVR:HK2PR06MB1698; X-Microsoft-Exchange-Diagnostics: 1; HK2PR06MB1698; 25:QPPRaywrmnJ4HcTRutwK8f4DQjichE2KGrcqxxEJSD5HpmR8CkBHGy8lt61dJc+ZYkcrP1Rpbt83wSaqV6JUYO0JVTfvEEg92FnsnHWmXvUyzjQ/qZR+E9lOSStGnKPU7EuB/UIhYgM09U0NYjV2NpM3oN+Z7iYfgx2C0vPJdRDcFx3XWH8Dm4//QwPiSDQKl/63YlDMMyiMvpTYhBJZEvQy0DXvHEsnyf+pJ6uOiOBpeFHlcH6UJc0fUPmhjX/Dr2f4WU+84rZ7UzrsoW79jc5jsZneCJRLUWqpWII+YRgkqZviL5Xw+VL+I5gPmP5Anrmq9ggwhrzvJD4DSWIHhrtLm5oOzt+vjLwmyjuOMSzaPWxvFFbtCfHcOuPfc1XEf3B/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/s7FWovvLbFW4ir7ALN0vfGSYglMbSnHD1eaqZkTsz0PesrnbzsLheQPvupyLQmms0tMyZtKTJMpJ9p2F3SG7QFD97QIhHKbhCtw8r5miYeAyL4y0vcH0GFbq+Sqyj34+A7ecQwyp77FvBuqS4Zmh+PzTdBPgXWwJozwTwBRhbTDi3gyA== 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:HK2PR06MB1698; BCL:0; PCL:0; RULEID:; SRVR:HK2PR06MB1698; X-Forefront-PRVS: 0912297777 X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10019020)(4630300001)(6009001)(4001350100001)(81166005)(50466002)(54356999)(50986999)(76176999)(42186005)(53416004)(5001770100001)(189998001)(19580405001)(83506001)(19580395003)(229853001)(46406003)(33646002)(5004730100002)(1096002)(2906002)(6116002)(23726003)(3846002)(66066001)(77096005)(2950100001)(5008740100001)(586003)(86362001)(4326007)(92566002)(47776003)(36756003)(16060500001); DIR:OUT; SFP:1102; SCL:1; SRVR:HK2PR06MB1698; H:morimoto-PC.renesas.com; FPR:; SPF:None; MLV:sfv; LANG:en; X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; HK2PR06MB1698; 23:EQ/catwYnw45z+2tfnKv8y7ud3B08q8fnbzlsFc71?= =?us-ascii?Q?AjRtFTjbTicXr3zMkLRc6md7H6mRC6BXXirzzWOipFQmqhkwJYRzHST5gW2e?= =?us-ascii?Q?iHllV3LT7mzvLKggtAGWr8kX+Y3wf2SrG8xTFAh/LmkEg0u6phWbNH5F+VvN?= =?us-ascii?Q?zWgI6/JeF53iJUzcE8k7tX6wTu0w43VDQMnsHRbzs4xSVJNcCED3/rr07tUH?= =?us-ascii?Q?qKl9UxWLE+Wb1D9HLy1CWGFH504t9eP13R5OUHdKf1wn2xa/lDUg7Ns+Stde?= =?us-asc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GStQvYa45Teng8zMLz7FEL6UsqDAi+e7904AsZdM94dxQqB8bZGQVoFgZptJJEQjCQQJ0Wc7ovPl7CzXOpPA=; 20:SotXXpGtSPyTmPStrBpxSMr9AqHZvH07zP/0MAHHEuZ1TnSwvBJVsr4HgliEVr8wKTny65UyC4h2ySPOLfWRjr5hMLO9qi7sYxQI+sWhEXQtGe46UeKSKXF5+qQ8okake9CplCrob4mJ5J8l76NDhRIMpbFmLMGp9AqKN5kWOts= SpamDiagnosticOutput: 1:23 SpamDiagnosticMetadata: NSPM X-OriginatorOrg: renesas.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 14 Apr 2016 05:47:43.8291 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-Transport-CrossTenantHeadersStamped: HK2PR06MB1698 Sender: linux-renesas-soc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-renesas-soc@vger.kernel.org X-Spam-Status: No, score=-7.9 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,RCVD_IN_DNSWL_HI,RP_MATCHES_RCVD,UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Kuninori Morimoto Current ASoC card connection is based on "sound-dai" on DT, but V4L2 connection is using graph base. This patch adds common function which can detect both connection. Signed-off-by: Kuninori Morimoto --- include/sound/soc.h | 2 ++ sound/soc/soc-core.c | 42 ++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 44 insertions(+) diff --git a/include/sound/soc.h b/include/sound/soc.h index 02b4a21..17ddc25 100644 --- a/include/sound/soc.h +++ b/include/sound/soc.h @@ -1669,6 +1669,8 @@ unsigned int snd_soc_of_parse_daifmt(struct device_node *np, const char *prefix, struct device_node **bitclkmaster, struct device_node **framemaster); +int of_parse_snd_soc_connection_with_args(const struct device_node *np, + struct of_phandle_args *out_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 d2e62b15..643b244 100644 --- a/sound/soc/soc-core.c +++ b/sound/soc/soc-core.c @@ -34,6 +34,7 @@ #include #include #include +#include #include #include #include @@ -3839,6 +3840,47 @@ static int snd_soc_get_dai_name(struct of_phandle_args *args, return ret; } +int of_parse_snd_soc_connection_with_args(const struct device_node *np, + struct of_phandle_args *out_args) +{ + int ret; + + ret = of_parse_phandle_with_args(np, "sound-dai", + "#sound-dai-cells", 0, out_args); + if (ret) { + struct device_node *p_node = NULL; + struct device_node *ep_node = NULL; + struct of_endpoint ep; + + /* try graph base parse */ + p_node = of_graph_get_remote_port_parent(np); + if (!p_node) + return -EINVAL; + + ep_node = of_graph_get_remote_port(np); + if (!p_node) { + ret = -EINVAL; + goto graph_err_parent; + } + + ret = of_graph_parse_endpoint(ep_node, &ep); + if (ret < 0) + goto graph_err_endpoint; + + out_args->np = p_node; + out_args->args_count = (1 != of_graph_get_endpoint_count(p_node)); + out_args->args[0] = ep.port; + +graph_err_endpoint: + of_node_put(ep_node); +graph_err_parent: + of_node_put(p_node); + } + + return ret; +} +EXPORT_SYMBOL_GPL(of_parse_snd_soc_connection_with_args); + int snd_soc_of_get_dai_name(struct device_node *of_node, const char **dai_name) {