From patchwork Fri Jun 24 02:47:55 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kuninori Morimoto X-Patchwork-Id: 9196457 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 497BF60756 for ; Fri, 24 Jun 2016 02:48:04 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 3DEA228483 for ; Fri, 24 Jun 2016 02:48:04 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 32DFC28487; Fri, 24 Jun 2016 02:48:04 +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 9625028483 for ; Fri, 24 Jun 2016 02:48:03 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752508AbcFXCsC (ORCPT ); Thu, 23 Jun 2016 22:48:02 -0400 Received: from relmlor2.renesas.com ([210.160.252.172]:57584 "EHLO relmlie1.idc.renesas.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1751554AbcFXCsA (ORCPT ); Thu, 23 Jun 2016 22:48:00 -0400 Received: from unknown (HELO relmlir3.idc.renesas.com) ([10.200.68.153]) by relmlie1.idc.renesas.com with ESMTP; 24 Jun 2016 11:47:58 +0900 Received: from relmlac4.idc.renesas.com (relmlac4.idc.renesas.com [10.200.69.24]) by relmlir3.idc.renesas.com (Postfix) with ESMTP id D56954C6CE; Fri, 24 Jun 2016 11:47:58 +0900 (JST) Received: by relmlac4.idc.renesas.com (Postfix, from userid 0) id BD0F4480A4; Fri, 24 Jun 2016 11:47:58 +0900 (JST) Received: from relmlac4.idc.renesas.com (localhost [127.0.0.1]) by relmlac4.idc.renesas.com (Postfix) with ESMTP id B4B69480A3; Fri, 24 Jun 2016 11:47:58 +0900 (JST) Received: from relmlii1.idc.renesas.com [10.200.68.65] by relmlac4.idc.renesas.com with ESMTP id MAH14953; Fri, 24 Jun 2016 11:47:58 +0900 X-IronPort-AV: E=Sophos;i="5.22,559,1449500400"; d="scan'";a="213670956" Received: from mail-pu1apc01lp0021.outbound.protection.outlook.com (HELO APC01-PU1-obe.outbound.protection.outlook.com) ([65.55.88.21]) by relmlii1.idc.renesas.com with ESMTP/TLS/AES256-SHA; 24 Jun 2016 11:47:57 +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=1I4Os7ObpKLWiqc3rKxrCzY+0B4lgqYknNnuRiQ9pIE=; b=G7sbysghFkq409MlBI67pWX0wL+sC4/Ak7cJ++e1Jl64lvbFN9CEysk0RdR8kRS85hzsfnqjOTpth07Wl/p9deL1Hf+T/s2Ad+Skn6DrHf/prIEAZvkFuRoGZj6S6Q5ftwJvHXXdxD+DY2r5wDSMHyVeb3j9tHGIgzLVHyzR96U= 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 02:47:55 +0000 Message-ID: <871t3nxq9t.wl%kuninori.morimoto.gx@renesas.com> From: Kuninori Morimoto Subject: [PATCH 2/3] ASoC: hdmi-codec: callback function will be called with private data User-Agent: Wanderlust/2.15.9 Emacs/24.3 Mule/6.0 To: Mark Brown , David Airlie , Russell King , Fabio Estevam , Daniel Vetter , Koji Matsuoka , Thierry Reding CC: Linux-ALSA , Liam Girdwood , Simon , , , In-Reply-To: <874m8jxqcy.wl%kuninori.morimoto.gx@renesas.com> References: <874m8jxqcy.wl%kuninori.morimoto.gx@renesas.com> MIME-Version: 1.0 (generated by SEMI-EPG 1.14.7 - "Harue") Date: Fri, 24 Jun 2016 02:47:55 +0000 X-Originating-IP: [211.11.155.144] X-ClientProxiedBy: KAWPR01CA0035.jpnprd01.prod.outlook.com (10.165.48.145) To HK2PR06MB1700.apcprd06.prod.outlook.com (10.167.73.14) X-MS-Office365-Filtering-Correlation-Id: 997c9304-f8cb-4d94-8468-08d39bd9f209 X-Microsoft-Exchange-Diagnostics: 1; HK2PR06MB1700; 2:wqlYIAdkd/nQGf93yaA4Uekvt27ra7XAc8xjea43nfT4aIu++1n7S6wAQC0OdmKw3brC5e1dyJnESEEWzFlKz9MOS3cIZV/V1x7DIWY6Kz5YH7SZhgYNjVM+v/nQLqXyNUkEB3gHTpLwHV8ignEXy/n/Uz23EUhKSvXfmPQdhmU87UuAqwCMLZqwHqjemZb4; 3:Alsnbbnk1EzrPMfjxl3BJnNpEd238bJ5c1zOQVw4oFYkxQu/arwZFhNjUaZZxwxdTlgzw5KHVbgPuJHiPj03ipAwR1QAMng+MK3AjN4FSll9Do2C3MQfdZb11RmMD+o6 X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:;SRVR:HK2PR06MB1700; X-Microsoft-Exchange-Diagnostics: 1; HK2PR06MB1700; 25:OiCZHgFpJmYpx3TvcgAJpf8rEK+9/oG13lWwOhS782/6kbjxPk4swy55/+0ZSqNX94eGo9jBIW5g4Wn2iL3NeLqb9Jd6Fz9ZsLnZWcgah1UR0U8w2jYq2nbw1Xzkk02nakP/D648SExBCCGhClNT05TrFfZ7hO+FO1TuPNmWEed1ut8rYhdwTgDndog9GeMnkFNJSxD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DPrvOlEz9ozDtHMbv1Jw1Eg49+mABgtXGqs5pLCEBB2e7s1h2aAJJ9VwZvRUHyPjYWVw6Q2RCMyrqelWbIDLTU6n5FHKa7gSHYftFPufDIK9gey2zL0iZEJr/9pS25LIz/cgftrfQWVBVsLWl/aL+7WrOj32zm2HvKJHjVGIuGYfZNFrYBm+y/0XS/nOv2uUTlLcoCgHF3fS36D59D66L6no4CsWgdBQLGf3smbinc4SEv58a9zE9Ll5gpqZymh6Fha+fClgfdggNaMvZUG6zS02aQq/evVFwdxJlR9ygMNSlYGdqCXnuepd74nsOqchwjsgra6SG3glasgmmwCN4i09feTlyJ+ZgB4fKFLNa2nbZFwKGwG96PT 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)(199003)(189002)(69596002)(46406003)(83506001)(50986999)(101416001)(105586002)(33646002)(76176999)(19580405001)(54356999)(106356001)(50466002)(36756003)(19580395003)(4326007)(7846002)(3846002)(6116002)(2906002)(68736007)(8676002)(81156014)(7736002)(81166006)(8666005)(305945005)(23726003)(2950100001)(586003)(92566002)(47776003)(77096005)(66066001)(4001350100001)(97736004)(189998001)(229853001)(86362001)(5001770100001)(53416004)(42186005)(7059030)(16060500001); DIR:OUT; SFP:1102; SCL:1; SRVR:HK2PR06MB1700; H:morimoto-PC.renesas.com; FPR:; SPF:None; PTR:InfoNoRecords; A:1; MX:1; LANG:en; X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; HK2PR06MB1700; 23:7O3AJiY3nYu5HMslcNCZjSvosDaPKROyqzluH3oGN?= =?us-ascii?Q?zCRqasqz1D6nDnemRe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NcuIkKMgag/TUkJbYJA2bMeD+59BmKl+RKeiG0sH+TEPuSDvPy4dLJlcLL6WoECvpkkK6SOc5as9OyTESL6xbrl6XG2FRgk24sKNYxRmURDUB7N3zbyXHe79ZpQ1HbhoGZ/y5OdWvGNqH1dfqwY1t755mFw7g9h3WBnb4BsIJhx9cjnSRihA/h1+TRePZi2L2HX4IPcSdN3RgxPspEw== SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1; HK2PR06MB1700; 20:5Wm71i/Ngg/NPhufzQVeU9dvg5FJuR6+GJm6J+Rq7sW4iell2Rq8TQrFy5bQcFGPzMBjnRw7hi+s9eBrXk50lq/2s9DMZLP3bleQaMCICi6lDbLKg4SygBVkH7LgXDF3kaARwrpj9wTBLMg3LjApTn1GH3QovarS9EjvvK7Ze9c= X-OriginatorOrg: renesas.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 24 Jun 2016 02:47:55.0772 (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 hdmi-codec driver is assuming that it will be registered from HDMI driver. Because of this assumption, each callback function has struct device pointer which is parent device (= HDMI). Then, it can use dev_get_drvdata() to get private data. OTOH, on some SoC/HDMI case, SoC has VIDEO/SOUND and HDMI IPs. This case, it needs SoC VIDEO, SoC SOUND and HDMI video, HDMI codec driver. In DesignWare HDMI IP case, SoC VIDEO (= DRM/KMS) driver tries to bind DesignWare HDMI video driver, and HDMI codec driver (= hdmi-codec). This case, above "parent device" of HDMI codec driver is DRM/KMS driver and its "device" already has private data. And, from DT and ASoC CPU/Codec/Card binding point of view, HDMI codec (= hdmi-codec) needs to have "parent device" (= DRM/KMS), otherwise, it never detect sound card. Because of these reasons, some driver can't use dev_get_drvdata() to get private data on hdmi-codec driver. This patch add new void pointer on hdmi_codec_pdata for private data, and callback function will be called with it. Signed-off-by: Kuninori Morimoto --- include/sound/hdmi-codec.h | 13 ++++++++----- sound/soc/codecs/hdmi-codec.c | 15 ++++++++------- 2 files changed, 16 insertions(+), 12 deletions(-) diff --git a/include/sound/hdmi-codec.h b/include/sound/hdmi-codec.h index fc3a481..530c57b 100644 --- a/include/sound/hdmi-codec.h +++ b/include/sound/hdmi-codec.h @@ -53,18 +53,19 @@ struct hdmi_codec_params { int channels; }; +struct hdmi_codec_pdata; struct hdmi_codec_ops { /* * Called when ASoC starts an audio stream setup. * Optional */ - int (*audio_startup)(struct device *dev); + int (*audio_startup)(struct device *dev, void *data); /* * Configures HDMI-encoder for audio stream. * Mandatory */ - int (*hw_params)(struct device *dev, + int (*hw_params)(struct device *dev, void *data, struct hdmi_codec_daifmt *fmt, struct hdmi_codec_params *hparms); @@ -72,19 +73,20 @@ struct hdmi_codec_ops { * Shuts down the audio stream. * Mandatory */ - void (*audio_shutdown)(struct device *dev); + void (*audio_shutdown)(struct device *dev, void *data); /* * Mute/unmute HDMI audio stream. * Optional */ - int (*digital_mute)(struct device *dev, bool enable); + int (*digital_mute)(struct device *dev, void *data, bool enable); /* * Provides EDID-Like-Data from connected HDMI device. * Optional */ - int (*get_eld)(struct device *dev, uint8_t *buf, size_t len); + int (*get_eld)(struct device *dev, void *data, + uint8_t *buf, size_t len); }; /* HDMI codec initalization data */ @@ -93,6 +95,7 @@ struct hdmi_codec_pdata { uint i2s:1; uint spdif:1; int max_i2s_channels; + void *data; }; #define HDMI_CODEC_DRV_NAME "hdmi-audio-codec" diff --git a/sound/soc/codecs/hdmi-codec.c b/sound/soc/codecs/hdmi-codec.c index 8e36e88..f27d115 100644 --- a/sound/soc/codecs/hdmi-codec.c +++ b/sound/soc/codecs/hdmi-codec.c @@ -112,7 +112,7 @@ static int hdmi_codec_startup(struct snd_pcm_substream *substream, return ret; if (hcp->hcd.ops->audio_startup) { - ret = hcp->hcd.ops->audio_startup(dai->dev->parent); + ret = hcp->hcd.ops->audio_startup(dai->dev->parent, hcp->hcd.data); if (ret) { mutex_lock(&hcp->current_stream_lock); hcp->current_stream = NULL; @@ -122,8 +122,8 @@ static int hdmi_codec_startup(struct snd_pcm_substream *substream, } if (hcp->hcd.ops->get_eld) { - ret = hcp->hcd.ops->get_eld(dai->dev->parent, hcp->eld, - sizeof(hcp->eld)); + ret = hcp->hcd.ops->get_eld(dai->dev->parent, hcp->hcd.data, + hcp->eld, sizeof(hcp->eld)); if (!ret) { ret = snd_pcm_hw_constraint_eld(substream->runtime, @@ -144,7 +144,7 @@ static void hdmi_codec_shutdown(struct snd_pcm_substream *substream, WARN_ON(hcp->current_stream != substream); - hcp->hcd.ops->audio_shutdown(dai->dev->parent); + hcp->hcd.ops->audio_shutdown(dai->dev->parent, hcp->hcd.data); mutex_lock(&hcp->current_stream_lock); hcp->current_stream = NULL; @@ -195,8 +195,8 @@ static int hdmi_codec_hw_params(struct snd_pcm_substream *substream, hp.sample_rate = params_rate(params); hp.channels = params_channels(params); - return hcp->hcd.ops->hw_params(dai->dev->parent, &hcp->daifmt[dai->id], - &hp); + return hcp->hcd.ops->hw_params(dai->dev->parent, hcp->hcd.data, + &hcp->daifmt[dai->id], &hp); } static int hdmi_codec_set_fmt(struct snd_soc_dai *dai, @@ -280,7 +280,8 @@ static int hdmi_codec_digital_mute(struct snd_soc_dai *dai, int mute) dev_dbg(dai->dev, "%s()\n", __func__); if (hcp->hcd.ops->digital_mute) - return hcp->hcd.ops->digital_mute(dai->dev->parent, mute); + return hcp->hcd.ops->digital_mute(dai->dev->parent, + hcp->hcd.data, mute); return 0; }