From patchwork Sat Apr 30 21:15:35 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Robert Jarzmik X-Patchwork-Id: 8987371 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 2AF719F372 for ; Sat, 30 Apr 2016 21:18:44 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 42C6120154 for ; Sat, 30 Apr 2016 21:18:43 +0000 (UTC) Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) by mail.kernel.org (Postfix) with ESMTP id 15C9F2013D for ; Sat, 30 Apr 2016 21:18:42 +0000 (UTC) Received: by alsa0.perex.cz (Postfix, from userid 1000) id 3FA47265705; Sat, 30 Apr 2016 23:18:41 +0200 (CEST) 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,FREEMAIL_FROM, RCVD_IN_DNSWL_NONE, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 Received: from alsa0.perex.cz (localhost [127.0.0.1]) by alsa0.perex.cz (Postfix) with ESMTP id 5ACEA265232; Sat, 30 Apr 2016 23:16:57 +0200 (CEST) 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 DDDBD265056; Sat, 30 Apr 2016 23:16:54 +0200 (CEST) Received: from smtp.smtpout.orange.fr (smtp02.smtpout.orange.fr [80.12.242.124]) by alsa0.perex.cz (Postfix) with ESMTP id E253026509E for ; Sat, 30 Apr 2016 23:16:46 +0200 (CEST) Received: from belgarion.home ([109.220.176.123]) by mwinf5d03 with ME id olGe1s00A2g7MCD03lGmrE; Sat, 30 Apr 2016 23:16:46 +0200 X-ME-Helo: belgarion.home X-ME-Date: Sat, 30 Apr 2016 23:16:46 +0200 X-ME-IP: 109.220.176.123 From: Robert Jarzmik To: Robert Jarzmik , Daniel Mack , Haojian Zhuang , Jaroslav Kysela , Takashi Iwai , Liam Girdwood , Mark Brown Date: Sat, 30 Apr 2016 23:15:35 +0200 Message-Id: <1462050939-27940-4-git-send-email-robert.jarzmik@free.fr> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1462050939-27940-1-git-send-email-robert.jarzmik@free.fr> References: <1462050939-27940-1-git-send-email-robert.jarzmik@free.fr> Cc: alsa-devel@alsa-project.org, patches@opensource.wolfsonmicro.com, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org Subject: [alsa-devel] [RFC PATCH 3/7] ASoC: wm9713: add ac97 new bus support 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: , MIME-Version: 1.0 Errors-To: alsa-devel-bounces@alsa-project.org Sender: alsa-devel-bounces@alsa-project.org X-Virus-Scanned: ClamAV using ClamSMTP Add support for the new ac97 bus model, where devices are automatically discovered on AC-Links. Signed-off-by: Robert Jarzmik --- sound/soc/codecs/wm9713.c | 62 ++++++++++++++++++++++++++++++++++++++++++----- 1 file changed, 56 insertions(+), 6 deletions(-) diff --git a/sound/soc/codecs/wm9713.c b/sound/soc/codecs/wm9713.c index 9849643ef809..bd5229236a8a 100644 --- a/sound/soc/codecs/wm9713.c +++ b/sound/soc/codecs/wm9713.c @@ -22,7 +22,8 @@ #include #include #include -#include +#include +#include #include #include #include @@ -1207,14 +1208,13 @@ static int wm9713_soc_probe(struct snd_soc_codec *codec) struct wm9713_priv *wm9713 = snd_soc_codec_get_drvdata(codec); struct regmap *regmap; - wm9713->ac97 = snd_soc_new_ac97_codec(codec, WM9713_VENDOR_ID, - WM9713_VENDOR_ID_MASK); + wm9713->ac97 = compat_alloc_snd_ac97_codec(codec); if (IS_ERR(wm9713->ac97)) return PTR_ERR(wm9713->ac97); regmap = regmap_init_ac97(wm9713->ac97, &wm9713_regmap_config); if (IS_ERR(regmap)) { - snd_soc_free_ac97_codec(wm9713->ac97); + compat_release_snd_ac97_codec(wm9713->ac97); return PTR_ERR(regmap); } @@ -1231,7 +1231,7 @@ static int wm9713_soc_remove(struct snd_soc_codec *codec) struct wm9713_priv *wm9713 = snd_soc_codec_get_drvdata(codec); snd_soc_codec_exit_regmap(codec); - snd_soc_free_ac97_codec(wm9713->ac97); + compat_release_snd_ac97_codec(wm9713->ac97); return 0; } @@ -1281,7 +1281,57 @@ static struct platform_driver wm9713_codec_driver = { .remove = wm9713_remove, }; -module_platform_driver(wm9713_codec_driver); +static int wm9713_ac97_probe(struct ac97_codec_device *adev) +{ + struct wm9713_priv *wm9713; + + wm9713 = devm_kzalloc(ac97_codec_dev2dev(adev), + sizeof(*wm9713), GFP_KERNEL); + if (wm9713 == NULL) + return -ENOMEM; + + mutex_init(&wm9713->lock); + + ac97_set_drvdata(adev, wm9713); + + return snd_soc_register_codec(ac97_codec_dev2dev(adev), + &soc_codec_dev_wm9713, wm9713_dai, + ARRAY_SIZE(wm9713_dai)); +} + +static int wm9713_ac97_remove(struct ac97_codec_device *adev) +{ + snd_soc_unregister_codec(ac97_codec_dev2dev(adev)); + return 0; +} + +static struct ac97_id wm9713_ac97_ids[] = { + { .id = WM9713_VENDOR_ID, .mask = WM9713_VENDOR_ID_MASK }, + { } +}; + +static struct ac97_codec_driver wm9713_ac97_driver = { + .driver = { + .name = "wm9713-codec", + }, + .probe = wm9713_ac97_probe, + .remove = wm9713_ac97_remove, + .id_table = wm9713_ac97_ids, +}; + +static int __init wm9713_init(void) +{ + ac97_codec_driver_register(&wm9713_ac97_driver); + return platform_driver_register(&wm9713_codec_driver); +} +module_init(wm9713_init); + +static void __exit wm9713_exit(void) +{ + ac97_codec_driver_unregister(&wm9713_ac97_driver); + return platform_driver_unregister(&wm9713_codec_driver); +} +module_exit(wm9713_exit); MODULE_DESCRIPTION("ASoC WM9713/WM9714 driver"); MODULE_AUTHOR("Liam Girdwood");