From patchwork Thu May 18 01:39:25 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kuninori Morimoto X-Patchwork-Id: 9734821 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 BDA8A601A1 for ; Thu, 18 May 2017 16:58:22 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id ACCB228898 for ; Thu, 18 May 2017 16:58:22 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 9FC4F288B9; Thu, 18 May 2017 16:58:22 +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=-4.1 required=2.0 tests=BAD_ENC_HEADER,BAYES_00, DKIM_SIGNED, RCVD_IN_DNSWL_MED, T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id EDA2C28898 for ; Thu, 18 May 2017 16:58:21 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id C76936E0FB; Thu, 18 May 2017 16:58:17 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from relmlie3.idc.renesas.com (relmlor4.renesas.com [210.160.252.174]) by gabe.freedesktop.org (Postfix) with ESMTP id 8965D6E104 for ; Thu, 18 May 2017 01:44:33 +0000 (UTC) Received: from unknown (HELO relmlir1.idc.renesas.com) ([10.200.68.151]) by relmlie3.idc.renesas.com with ESMTP; 18 May 2017 10:39:30 +0900 Received: from relmlii2.idc.renesas.com (relmlii2.idc.renesas.com [10.200.68.66]) by relmlir1.idc.renesas.com (Postfix) with ESMTP id 885AA60423; Thu, 18 May 2017 10:39:30 +0900 (JST) X-IronPort-AV: E=Sophos;i="5.38,356,1491231600"; d="scan'208";a="244224427" Received: from mail-sg2apc01lp0246.outbound.protection.outlook.com (HELO APC01-SG2-obe.outbound.protection.outlook.com) ([65.55.88.246]) by relmlii2.idc.renesas.com with ESMTP/TLS/AES256-SHA256; 18 May 2017 10:39:28 +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=EbDr0k/01oipPqSQgqdfaDW/Msm30ldor4pYChkZJp0=; b=CLSJwD6F4ZUb0gC2x22dGGlg4ItToENcuOFmGxawqU4lEbpaRi8ppjH5en5myQKWsXdkEW2IHi4nAkuny7IdCyKu5ZP0l82dNMddmezNyZxtubnNmjqeH/bb0F06Zim6tks2JcouUjN0J4k4UwViI3OlVF3PDegAoiQOZVIuDgg= 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 HK2PR0601MB1873.apcprd06.prod.outlook.com (2603:1096:202:a::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1101.14; Thu, 18 May 2017 01:39:25 +0000 Message-ID: <87d1b7oslu.wl%kuninori.morimoto.gx@renesas.com> From: Kuninori Morimoto Subject: [PATCH 1/5] ASoC: add snd_soc_get_dai_id() function User-Agent: Wanderlust/2.15.9 Emacs/24.3 Mule/6.0 To: Mark Brown , Archit Taneja In-Reply-To: <87efvnosnb.wl%kuninori.morimoto.gx@renesas.com> References: <87efvnosnb.wl%kuninori.morimoto.gx@renesas.com> MIME-Version: 1.0 (generated by SEMI-EPG 1.14.7 - "Harue") Date: Thu, 18 May 2017 01:39:25 +0000 X-Originating-IP: [211.11.155.144] X-ClientProxiedBy: KL1PR02CA0075.apcprd02.prod.outlook.com (2603:1096:800:1::43) To HK2PR0601MB1873.apcprd06.prod.outlook.com (2603:1096:202:a::17) X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: HK2PR0601MB1873: X-MS-Office365-Filtering-Correlation-Id: 643385f2-19c5-4d8d-b4f7-08d49d8eb858 X-MS-Office365-Filtering-HT: Tenant X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(22001)(48565401081)(201703131423075)(201703031133081); SRVR:HK2PR0601MB1873; X-Microsoft-Exchange-Diagnostics: 1; HK2PR0601MB1873; 3:Py76TTdQIL4HGR+0OQrKnbCPv7IUnZOhTqitvHLPbLKVcxoXwwK0gNk8nJrdnx/DXdvrk2AWEl/10rkcasr5E0VC/QTHZgBcMP3lzZt9pY/drk9S5nwcpB17+2s1wXvu1kDLt7kc5NHSi5MGa5cN0PmZ+VvnIuIxe+08sVUrREVc7cQkSMyBRkaQrUDUI6LWfHH5T0hBKIk0pRmPUTK/k49pU2a9z3ZrMmU4SctshI5TSl6MYNuE8wu9JuNwQmet4wvrK6WfCv78q841WU13afp00LPxDgYkQGrTsTuvWah5EvKF+OQX/NMFTFbGCzAPsfKvqrioSfextDeWZce6mManvV36pBqhOThZ4sgp0LE=; 25:/IFmdc8uXEQXcmOj0fBDdXmjs/dX5u/LBImQ4rPEU5g65Qvm1oaJwWpBvLfEVOvLnioyZ/GQEyWZFUPeVey0oYft3IFI3ddsK4eSVL8EIgSfFFRHNB8cdHFTmWPFEA28YIL1ehlAOFlJtFVXTgV7PU2tj20XYKceuUiuXW6ZQ2575EumW4JyG+fus1wRyxhfQ0qDeVgguCS3OZV355ZVZf9Gwvg3c8AKRWHP5sPQNSWUZ4cDAaY48q4ZxpQcDjr0Zyp3RqERLuwgsUVGZdALTEsylQLot+kwXGFJVAgFca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Exchange-Antispam-Report-Test: UriScan:; X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(6040450)(601004)(2401047)(8121501046)(5005006)(10201501046)(3002001)(93006095)(93001095)(6055026)(6041248)(201703131423075)(201702281528075)(201703061421075)(201703061406153)(20161123564025)(20161123562025)(20161123560025)(20161123558100)(20161123555025)(6072148); SRVR:HK2PR0601MB1873; BCL:0; PCL:0; RULEID:; SRVR:HK2PR0601MB1873; X-Microsoft-Exchange-Diagnostics: 1; HK2PR0601MB1873; 4:0ehFGxLrraha/XSn+d/0mmVgooGqn+XDrdxtYXqYeTN+qhKU0VIN5qxxV2lAekmFZgyi34oOZ5B2OdxcMFXUskw8e7NufOWpTFxX1aFXexF7Y511U+BGSGR4LVhVO6omiryltqz7KvvyU5xT5fMxIwsdC+7m7j2egQOCgRHtx4yfso8WSkm8xtOxTQCpfHUW7L1Br719pTZDdYSmtMk+90D7iAfnVu2Qs0FnIJU0ITqfxaMksmQM8saGacg1HD7ehFCQ+Zosfw21SFRemI6rdw2j3J8ODW0UMlAd37X92bwxM9/nlCGjQX3X3KRVZ91nZPjxKAGum+57d2LdZ7oBAXGnnrSVAJPh/x26iY+Aa3YzG9LbIyZV+jm3N66GrfeTo+uox7rF9KlA9jaNMo5U+9tm5ScHqWKiq56B72T/MzBi7xUn1Uzg0q7JQzSA0CMOFLo10M3LvTmeU178qtWjGf43mEuzVaFriVxjTXeTs+6YczYYD5xXby+7YPwGJwmCaZeU0x3FljxUWW6ZYanTQdIkxrBX/tOF0ZWuxSH5i9Q7XZtNqHsYKj+MUkLWr9R0emnfx62oA67WkuRBfRPhQAZSM96inAFVOmyV621p+9MVVpldCM7NhDu2ebXm9TLxgEhEn67aB9TEPc12XKxYJKvi7KQ2JwBB+fHN/S/+99I+oFw3Gz9vntzN9va3cwXSac3F2lawwy/PBib14labTSHi6HaYaI3JhkAAPJ6nQWYqhb3pA2f0Q65pLBpJRT0e1k2ADfzHmiyT6ELCQXyU3EfoqzPskBi+Mgcxk7yTGb/M3Bq1lo46zfEyPbyn+9DB X-Forefront-PRVS: 0311124FA9 X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10019020)(4630300001)(6009001)(39840400002)(39450400003)(39850400002)(39400400002)(39410400002)(39860400002)(83506001)(25786009)(66066001)(50986999)(4326008)(33646002)(53936002)(47776003)(7416002)(76176999)(54356999)(54906002)(8676002)(50466002)(81166006)(478600001)(6486002)(3846002)(23726003)(36756003)(305945005)(86362001)(53416004)(38730400002)(189998001)(2950100002)(5660300001)(42186005)(7736002)(6116002)(4001350100001)(16060500001); DIR:OUT; SFP:1102; SCL:1; SRVR:HK2PR0601MB1873; H:morimoto-PC.renesas.com; FPR:; SPF:None; MLV:sfv; LANG:en; X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; HK2PR0601MB1873; 23:B056gm8gf7jTUjHruVu9cwTKNSS4EkGJbquBKP2?= =?us-ascii?Q?7zaz8aAwyxtHWcDheebbNi2LGX247W8hyVLye9/uogwOK9oEybsqiFgL32Dh?= =?us-ascii?Q?FEydAUMGoXy1iCs4dcxp7rFjHrLGgblV9HwExvLhrtsVOfYoeA7ZE53SCMHV?= =?us-ascii?Q?OhOJyRtUytKJ51Y//3GpGyqfriLFgf8dE/ZjKR5iq+GXNPti+g4ShWBg20o7?= =?us-ascii?Q?mI+q6spX2ZdOLRy4QTcXwg3nzQgnkg20bqF6q+1Kc+F3AxyMo7FwZffzj4PS?= =?us-ascii?Q?Y2LvHYoAIQMjQa+QeCbRKGGojeDJnwCH8obyYigPyF06OTih972TOCV6Dohj?= =?us-ascii?Q?Z6x2Lb7TqmMWsWB5TcmoAZM7N9lMaoxKqBJJm+Bz20O+RIOEZ+hiDgapw+vy?= =?us-ascii?Q?XfkZOgcVHvInxVH5NHDXI0PZ1I5IU3LTGpLt7drI0hIA+CQ69GEJI4hH7wsm?= =?us-ascii?Q?A9rmxrGHCQQOD5ABgtrZ7cfET/OXEVhklfU43pv1PWknxDaHZTgx3SkNtP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ak= X-OriginatorOrg: renesas.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 18 May 2017 01:39:25.2736 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-Transport-CrossTenantHeadersStamped: HK2PR0601MB1873 X-Mailman-Approved-At: Thu, 18 May 2017 16:58:16 +0000 Cc: Jose Abreu , Linux-ALSA , Laurent Pinchart , linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org, linux-renesas-soc@vger.kernel.org, Russell King , Simon X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" X-Virus-Scanned: ClamAV using ClamSMTP From: Kuninori Morimoto ALSA SoC needs to know connected DAI ID for detecting. It is not a big problem if device/driver was only for sound, but getting DAI ID will be difficult if device includes both Video/Sound, like HDMI. To solve this issue, this patch adds new snd_soc_get_dai_id() and its related .of_xlate_dai_id callback on component driver. In below case, we can handle Sound port (= port@2) as ID = 0 if .of_xlate_dai_id has its support. hdmi { port@0 { /* VIDEO */ }; port@1 { /* VIDEO */ }; port@2 { /* SOUND */ }; }; Signed-off-by: Kuninori Morimoto --- include/sound/soc.h | 3 +++ sound/soc/soc-core.c | 37 +++++++++++++++++++++++++++++++++++++ 2 files changed, 40 insertions(+) diff --git a/include/sound/soc.h b/include/sound/soc.h index 5170fd8..9c94b97 100644 --- a/include/sound/soc.h +++ b/include/sound/soc.h @@ -803,6 +803,8 @@ struct snd_soc_component_driver { int (*of_xlate_dai_name)(struct snd_soc_component *component, struct of_phandle_args *args, const char **dai_name); + int (*of_xlate_dai_id)(struct snd_soc_component *comment, + struct device_node *endpoint); void (*seq_notifier)(struct snd_soc_component *, enum snd_soc_dapm_type, int subseq); int (*stream_event)(struct snd_soc_component *, int event); @@ -1676,6 +1678,7 @@ unsigned int snd_soc_of_parse_daifmt(struct device_node *np, const char *prefix, struct device_node **bitclkmaster, struct device_node **framemaster); +int snd_soc_get_dai_id(struct device_node *ep); int snd_soc_get_dai_name(struct of_phandle_args *args, const char **dai_name); int snd_soc_of_get_dai_name(struct device_node *of_node, diff --git a/sound/soc/soc-core.c b/sound/soc/soc-core.c index ab7a07f..9ba1837 100644 --- a/sound/soc/soc-core.c +++ b/sound/soc/soc-core.c @@ -34,6 +34,7 @@ #include #include #include +#include #include #include #include @@ -4048,6 +4049,42 @@ unsigned int snd_soc_of_parse_daifmt(struct device_node *np, } EXPORT_SYMBOL_GPL(snd_soc_of_parse_daifmt); +int snd_soc_get_dai_id(struct device_node *ep) +{ + struct snd_soc_component *pos; + struct device_node *node; + int ret; + + node = of_graph_get_port_parent(ep); + + /* + * For example HDMI case, HDMI has video/sound port, + * but ALSA SoC needs sound port number only. + * Thus counting HDMI DT port/endpoint doesn't work. + * Then, it should have .of_xlate_dai_id + */ + ret = -ENOTSUPP; + mutex_lock(&client_mutex); + list_for_each_entry(pos, &component_list, list) { + struct device_node *component_of_node = pos->dev->of_node; + + if (!component_of_node && pos->dev->parent) + component_of_node = pos->dev->parent->of_node; + + if (component_of_node != node) + continue; + + if (pos->driver->of_xlate_dai_id) + ret = pos->driver->of_xlate_dai_id(pos, ep); + + break; + } + mutex_unlock(&client_mutex); + + return ret; +} +EXPORT_SYMBOL_GPL(snd_soc_get_dai_id); + int snd_soc_get_dai_name(struct of_phandle_args *args, const char **dai_name) {