From patchwork Fri May 20 09:56: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: 9129089 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 225406048B for ; Fri, 20 May 2016 09:57:16 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 10D2B2793B for ; Fri, 20 May 2016 09:57:16 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 02D8127BF1; Fri, 20 May 2016 09:57:15 +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 5B8642793B for ; Fri, 20 May 2016 09:57:14 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755323AbcETJ5I (ORCPT ); Fri, 20 May 2016 05:57:08 -0400 Received: from relmlor4.renesas.com ([210.160.252.174]:63953 "EHLO relmlie3.idc.renesas.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1755231AbcETJ5F (ORCPT ); Fri, 20 May 2016 05:57:05 -0400 Received: from unknown (HELO relmlir2.idc.renesas.com) ([10.200.68.152]) by relmlie3.idc.renesas.com with ESMTP; 20 May 2016 18:57:03 +0900 Received: from relmlac2.idc.renesas.com (relmlac2.idc.renesas.com [10.200.69.22]) by relmlir2.idc.renesas.com (Postfix) with ESMTP id 9874152FCE; Fri, 20 May 2016 18:57:03 +0900 (JST) Received: by relmlac2.idc.renesas.com (Postfix, from userid 0) id 77DD52806E; Fri, 20 May 2016 18:57:03 +0900 (JST) Received: from relmlac2.idc.renesas.com (localhost [127.0.0.1]) by relmlac2.idc.renesas.com (Postfix) with ESMTP id 7229A2806D; Fri, 20 May 2016 18:57:03 +0900 (JST) Received: from relmlii2.idc.renesas.com [10.200.68.66] by relmlac2.idc.renesas.com with ESMTP id UAV21122; Fri, 20 May 2016 18:57:03 +0900 X-IronPort-AV: E=Sophos;i="5.22,559,1449500400"; d="scan'";a="211715285" Received: from mail-hk2apc01lp0212.outbound.protection.outlook.com (HELO APC01-HK2-obe.outbound.protection.outlook.com) ([65.55.88.212]) by relmlii2.idc.renesas.com with ESMTP/TLS/AES256-SHA; 20 May 2016 18:57:02 +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=7Sv5RyCITJQDcMmFpTEzQED0ybOu3cO4RPyBRdngzVk=; b=EYbtQ+v3lWdlOyDAsyvwpba+C08GbIxnrrL13/t1uIO9iJkbQq6QApm7SFSXU1WMX5OOg77l7zYKk/aP3u61Chc8lxbKoC64x3G9j/iHRBoY1MZ69a9fN9Oit3Ht5rbrX1Md1SLOntskUelNkV1osG5hpkjOMYGLFB5Timz3Vp8= 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 SG2PR06MB1712.apcprd06.prod.outlook.com (10.167.82.142) with Microsoft SMTP Server (TLS) id 15.1.497.12; Fri, 20 May 2016 09:56:55 +0000 Message-ID: <87futdqcqy.wl%kuninori.morimoto.gx@renesas.com> From: Kuninori Morimoto Subject: [PATCH 28/49] ASoC: simple-card: use asoc_simple_card_init_jack() User-Agent: Wanderlust/2.15.9 Emacs/24.3 Mule/6.0 To: Mark Brown CC: Linux-ALSA , Liam Girdwood , Simon , In-Reply-To: <87lh35rs8w.wl%kuninori.morimoto.gx@renesas.com> References: <87lh35rs8w.wl%kuninori.morimoto.gx@renesas.com> MIME-Version: 1.0 (generated by SEMI-EPG 1.14.7 - "Harue") Date: Fri, 20 May 2016 09:56:55 +0000 X-Originating-IP: [211.11.155.144] X-ClientProxiedBy: TYXPR01CA0027.jpnprd01.prod.outlook.com (10.168.40.37) To SG2PR06MB1712.apcprd06.prod.outlook.com (10.167.82.142) X-MS-Office365-Filtering-Correlation-Id: 67648e3f-13e1-4725-e2f4-08d3809513d7 X-Microsoft-Exchange-Diagnostics: 1; SG2PR06MB1712; 2:8EGHvGxIaIXXXEpCTvtttlnwCAMco3wBO9fMOVsOxySnOsTRkc+1S/V+cwO3MiiRN8b6TquVgB0d2iplOHuU5nJalnfSGHi5Jb6O+cZLqy/+Drw8kDgeix80GeTYkfgZFFu5DmpwS+ePfExYPojzQ6UqYs5Kz7ACJhF6XTnv9TmzPAQKFnjT273iXwl1Q+oy; 3:wBPITP0iBlv0oqAlfeSDFrsGMRbThkaI0a5XRg+7cPNnm+hDATON/4Gxlyidlsu97YLzc/v2zHxWbDk6AqREzB0wUVGOWdlFuThPgbsPLNF6Ynfg6itnfwaD1tUBaUkL; 25:349+p7PKdlZEaDcpcZDJtpzERUaUpdPf3Bc+2/rWjZHkfmvzUdss9ycowUSQs/vXKTAIYh2e+n6ycmNjjmJkaMb8oDpTWCAfcApE33jsWyKcuGhqtIDIjqHsHG+MVcnACASYCnhex4xG9E8MCJUV7ryCZirEH02JwcolgQQwmPwPAepzsOhziFLARwL4pv12+gv+aCUVWX/5w88rl7WANaIrnJOun9yramJujzD3z7nuR6dKz0FQ8BKHycFd+yAjTvNWaITB2BpjPykntfe6r5MX6P+RMNjrpWnDS6p/CMArPzwg6TAoS5/fnp9ZBFUkG9WpY534C8zxzpswsaPntBO1UUgZ5RjyyErHuAraARG1MUsS/42qyX4zHgu5e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X-Exchange-Antispam-Report-Test: UriScan:; X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(601004)(2401047)(5005006)(8121501046)(3002001)(10201501046)(6055026); SRVR:SG2PR06MB1712; BCL:0; PCL:0; RULEID:; SRVR:SG2PR06MB1712; X-Forefront-PRVS: 09480768F8 X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10019020)(6009001)(229853001)(4326007)(2906002)(86362001)(23726003)(19580405001)(66066001)(19580395003)(76176999)(54356999)(42186005)(3846002)(6116002)(53416004)(50466002)(33646002)(83506001)(47776003)(81166006)(586003)(50986999)(5004730100002)(92566002)(189998001)(5008740100001)(77096005)(36756003)(110136002)(46406003)(2950100001)(8676002)(16060500001); DIR:OUT; SFP:1102; SCL:1; SRVR:SG2PR06MB1712; H:morimoto-PC.renesas.com; FPR:; SPF:None; MLV:sfv; LANG:en; X-Microsoft-Exchange-Diagnostics: 1; SG2PR06MB1712; 23:4lu5rCJ3Qwh63zuf8ljsMZuwJJLR1QGhVMWW0xap4ZAWH3xgVyg9Rww93BkHsXpfwRlWBssdaueMAVwC9iq1wbSKZCr8OGDM7Ij5fZ+hCsCv1x/Wgl6eM5JMSv+ZsGRQoF6ngBYbJYIAB6KYObqRQ4FVD2MhNLq0Z0gfEePkQFKaD+SwGaoVXNTiyCHY6gcmPsH1Gz7ydq0XfSv/jTsS86qHg1g/oy9Sr4OoHV0xdS1kkG/yo5lTOtLaB4t0eTt1g7fU0oU+m0oKE3Uof69m27p+O45HNndF/jgVHjnz5I6FMMUEPWZhhKcw7Rtrl12uLm0v8MNyvowepRu9cO+SU03Z4Nx564qF6ts40O0eNiFv+QaXPn9FnplcnpRst+CwPSr4FdUM382rho2vDwzTdYE26Kdb0VU0EBpwCrUpRtprO/esCvFRPBVplqXd3R+g+u6ZOgu6cXrKu5qyYeMZ9XdT7GwFYJGYNTABbuux/piwTsIc4L5FqcVrgsyawbvj9sfNCryLZIo2FxocagEtli5y/xPn0bhhEGYCWPb1oTw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orOrg: renesas.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 20 May 2016 09:56:55.4988 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-Transport-CrossTenantHeadersStamped: SG2PR06MB1712 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 Signed-off-by: Kuninori Morimoto --- sound/soc/generic/simple-card.c | 86 ++++++----------------------------------- 1 file changed, 11 insertions(+), 75 deletions(-) diff --git a/sound/soc/generic/simple-card.c b/sound/soc/generic/simple-card.c index 45c8ccc..2aacff7 100644 --- a/sound/soc/generic/simple-card.c +++ b/sound/soc/generic/simple-card.c @@ -27,10 +27,8 @@ struct simple_card_data { unsigned int mclk_fs; } *dai_props; unsigned int mclk_fs; - int gpio_hp_det; - int gpio_hp_det_invert; - int gpio_mic_det; - int gpio_mic_det_invert; + struct asoc_simple_jack hp_jack; + struct asoc_simple_jack mic_jack; struct snd_soc_dai_link dai_link[]; /* dynamically allocated */ }; @@ -112,32 +110,6 @@ static struct snd_soc_ops asoc_simple_card_ops = { .hw_params = asoc_simple_card_hw_params, }; -static struct snd_soc_jack simple_card_hp_jack; -static struct snd_soc_jack_pin simple_card_hp_jack_pins[] = { - { - .pin = "Headphones", - .mask = SND_JACK_HEADPHONE, - }, -}; -static struct snd_soc_jack_gpio simple_card_hp_jack_gpio = { - .name = "Headphone detection", - .report = SND_JACK_HEADPHONE, - .debounce_time = 150, -}; - -static struct snd_soc_jack simple_card_mic_jack; -static struct snd_soc_jack_pin simple_card_mic_jack_pins[] = { - { - .pin = "Mic Jack", - .mask = SND_JACK_MICROPHONE, - }, -}; -static struct snd_soc_jack_gpio simple_card_mic_jack_gpio = { - .name = "Mic detection", - .report = SND_JACK_MICROPHONE, - .debounce_time = 150, -}; - static int __asoc_simple_card_dai_init(struct snd_soc_dai *dai, struct asoc_simple_dai *set) { @@ -186,30 +158,14 @@ static int asoc_simple_card_dai_init(struct snd_soc_pcm_runtime *rtd) if (ret < 0) return ret; - if (gpio_is_valid(priv->gpio_hp_det)) { - snd_soc_card_jack_new(rtd->card, "Headphones", - SND_JACK_HEADPHONE, - &simple_card_hp_jack, - simple_card_hp_jack_pins, - ARRAY_SIZE(simple_card_hp_jack_pins)); - - simple_card_hp_jack_gpio.gpio = priv->gpio_hp_det; - simple_card_hp_jack_gpio.invert = priv->gpio_hp_det_invert; - snd_soc_jack_add_gpios(&simple_card_hp_jack, 1, - &simple_card_hp_jack_gpio); - } + ret = asoc_simple_card_init_hp(rtd->card, &priv->hp_jack, PREFIX); + if (ret < 0) + return ret; + + ret = asoc_simple_card_init_mic(rtd->card, &priv->hp_jack, PREFIX); + if (ret < 0) + return ret; - if (gpio_is_valid(priv->gpio_mic_det)) { - snd_soc_card_jack_new(rtd->card, "Mic Jack", - SND_JACK_MICROPHONE, - &simple_card_mic_jack, - simple_card_mic_jack_pins, - ARRAY_SIZE(simple_card_mic_jack_pins)); - simple_card_mic_jack_gpio.gpio = priv->gpio_mic_det; - simple_card_mic_jack_gpio.invert = priv->gpio_mic_det_invert; - snd_soc_jack_add_gpios(&simple_card_mic_jack, 1, - &simple_card_mic_jack_gpio); - } return 0; } @@ -336,7 +292,6 @@ static int asoc_simple_card_parse_of(struct device_node *node, { struct device *dev = simple_priv_to_dev(priv); struct snd_soc_card *card = &priv->snd_card; - enum of_gpio_flags flags; u32 val; int ret; @@ -370,18 +325,6 @@ static int asoc_simple_card_parse_of(struct device_node *node, return ret; } - priv->gpio_hp_det = of_get_named_gpio_flags(node, - "simple-audio-card,hp-det-gpio", 0, &flags); - priv->gpio_hp_det_invert = !!(flags & OF_GPIO_ACTIVE_LOW); - if (priv->gpio_hp_det == -EPROBE_DEFER) - return -EPROBE_DEFER; - - priv->gpio_mic_det = of_get_named_gpio_flags(node, - "simple-audio-card,mic-det-gpio", 0, &flags); - priv->gpio_mic_det_invert = !!(flags & OF_GPIO_ACTIVE_LOW); - if (priv->gpio_mic_det == -EPROBE_DEFER) - return -EPROBE_DEFER; - ret = asoc_simple_card_parse_card_widgets(card, PREFIX); if (ret) return ret; @@ -440,9 +383,6 @@ static int asoc_simple_card_probe(struct platform_device *pdev) priv->snd_card.dai_link = dai_link; priv->snd_card.num_links = num_links; - priv->gpio_hp_det = -ENOENT; - priv->gpio_mic_det = -ENOENT; - /* Get room for the other properties */ priv->dai_props = devm_kzalloc(dev, sizeof(*priv->dai_props) * num_links, @@ -509,12 +449,8 @@ static int asoc_simple_card_remove(struct platform_device *pdev) struct snd_soc_card *card = platform_get_drvdata(pdev); struct simple_card_data *priv = snd_soc_card_get_drvdata(card); - if (gpio_is_valid(priv->gpio_hp_det)) - snd_soc_jack_free_gpios(&simple_card_hp_jack, 1, - &simple_card_hp_jack_gpio); - if (gpio_is_valid(priv->gpio_mic_det)) - snd_soc_jack_free_gpios(&simple_card_mic_jack, 1, - &simple_card_mic_jack_gpio); + asoc_simple_card_remove_jack(&priv->hp_jack); + asoc_simple_card_remove_jack(&priv->mic_jack); return asoc_simple_card_unref(card); }