From patchwork Tue Jul 10 18:16:36 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mark Brown X-Patchwork-Id: 141642 Delivered-To: patch@linaro.org Received: by 2002:a2e:9754:0:0:0:0:0 with SMTP id f20-v6csp4202774ljj; Tue, 10 Jul 2018 11:17:26 -0700 (PDT) X-Google-Smtp-Source: AAOMgpeYQdgGrb54ZdX92tizWUUWDsbDhpe8cCT/OZOWIEZ08KRc4T7mEyJLjHg+2GxobLNZ7gI8 X-Received: by 2002:a1c:6d1c:: with SMTP id i28-v6mr16887589wmc.97.1531246646580; Tue, 10 Jul 2018 11:17:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1531246646; cv=none; d=google.com; s=arc-20160816; b=B71nF9VhLuJdZWbn88Cxf0SMRHASc4EvkEsEniv70KDCNEYdoJJ6l0GaM2gb8XMNAS h6jwEq/cOJQglNd9HMPgjXd5obnFoqZ++DtQyTMzf2oDFH7SRt+QbR2SSrHRcWDenOxZ YazgdEtWahNymbH+ygV0+T3hFdO5BklhV6Mv4D0HEfHynA/8fEhGVVSVIwnyvOHD1/RK xx0rKDNOjS8DdU6fEfYtH347hZu4DRf1+6uK/SVr9J1Jv8HxnTKzv9RoSqcRDuXKIt7P bNqlm9Rdec3KEBpRZZ4kODrMfDurFsyJ4tVnWUvb1n/HugeLbbvXojV+4XlPnDaC9zu7 u39w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:mime-version :list-subscribe:list-help:list-post:list-archive:list-unsubscribe :list-id:precedence:subject:cc:date:message-id:in-reply-to:to:from :dkim-signature:delivered-to:arc-authentication-results; bh=MNClNwBiAEZHXt8F7phhq7l3LkvbiC6zE3C6et2kykg=; b=NrGHaucTQyeuwJ9OjJdEfWaFn2zNzGzoe23c0JF6dXsdyCF1IWsc465JgYKsIBJi65 Xji1JCxG/4iXY92AeGv0Ib8RufManWcWGCC6PcgQMLHqVh+bvblJxa1kHkN26P8RxzE/ POxuUbZ7oHnHsvA3VKDEEM7RJMk6ZC9PzsJEV96jnwoqMIOS/MQMJjosbfGT8JPE0X4M yH1kp9npEnnQ3HIx/4lPEJ4R+tYCo9h4tJ/a0uZvlw7ctEv3RYNUKcTS+OZQ2C3RmM5O 7/MOCsUKernQ3vn0eul41lrcEDMYY3Bublz1VMx5eJmuu3Ua2oivjjdH7/mdMwrn5xXb Ue3g== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@sirena.org.uk header.s=20170815-heliosphere header.b=EyoA7N2j; spf=pass (google.com: domain of alsa-devel-bounces@alsa-project.org designates 77.48.224.243 as permitted sender) smtp.mailfrom=alsa-devel-bounces@alsa-project.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from alsa0.perex.cz (alsa0.perex.cz. [77.48.224.243]) by mx.google.com with ESMTP id p3-v6si8791467wmp.134.2018.07.10.11.17.26; Tue, 10 Jul 2018 11:17:26 -0700 (PDT) Received-SPF: pass (google.com: domain of alsa-devel-bounces@alsa-project.org designates 77.48.224.243 as permitted sender) client-ip=77.48.224.243; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@sirena.org.uk header.s=20170815-heliosphere header.b=EyoA7N2j; spf=pass (google.com: domain of alsa-devel-bounces@alsa-project.org designates 77.48.224.243 as permitted sender) smtp.mailfrom=alsa-devel-bounces@alsa-project.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from alsa0.perex.cz (localhost [127.0.0.1]) by alsa0.perex.cz (Postfix) with ESMTP id 2FCFC267732; Tue, 10 Jul 2018 20:16:55 +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 84A1526771D; Tue, 10 Jul 2018 20:16:48 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on mail1.perex.cz X-Spam-Level: X-Spam-Status: No, score=0.2 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, HEADER_FROM_DIFFERENT_DOMAINS, RCVD_IN_DNSWL_NONE, SPF_PASS autolearn=disabled version=3.4.0 Received: from heliosphere.sirena.org.uk (heliosphere.sirena.org.uk [172.104.155.198]) by alsa0.perex.cz (Postfix) with ESMTP id 6CF22267716 for ; Tue, 10 Jul 2018 20:16:42 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sirena.org.uk; s=20170815-heliosphere; h=Date:Message-Id:In-Reply-To: Subject:Cc:To:From:Sender:Reply-To:MIME-Version:Content-Type: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:References: List-Id:List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner: List-Archive; bh=VI09026uOb89vgQqaFTTfwpiqMHzPrP+B1yVbP3sA7Q=; b=EyoA7N2jSrLW XEl0vIIUqk3KHnBQvmyXLBkgu1GZLCKT4g097UFjAogrH2XQUEa3y6Fq/8O811e9QTiIOsq5r8bso sJG0sqpPF3ayvVmXgv3ZGDe0O24f6A9rFOoOvgTb75YXgMSzu7wV4bnQDf8h7LMqtZ0UUQXy6+CoT 9irxc=; Received: from debutante.sirena.org.uk ([2001:470:1f1d:6b5::3] helo=debutante) by heliosphere.sirena.org.uk with esmtpsa (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.89) (envelope-from ) id 1fcxBl-00029A-34; Tue, 10 Jul 2018 18:16:37 +0000 Received: from broonie by debutante with local (Exim 4.91) (envelope-from ) id 1fcxBk-0001iP-Kh; Tue, 10 Jul 2018 19:16:36 +0100 From: Mark Brown To: Hans de Goede In-Reply-To: <20180704225935.7902-2-hdegoede@redhat.com> Message-Id: Date: Tue, 10 Jul 2018 19:16:36 +0100 Cc: Oder Chiou , alsa-devel@alsa-project.org, Pierre-Louis Bossart , Liam Girdwood , Mark Brown , Carlo Caione , Bard Liao Subject: [alsa-devel] Applied "ASoC: rt5651: Allow disabling jack-detect by calling set_jack(NULL)" to the asoc tree 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 The patch ASoC: rt5651: Allow disabling jack-detect by calling set_jack(NULL) has been applied to the asoc tree at https://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound.git All being well this means that it will be integrated into the linux-next tree (usually sometime in the next 24 hours) and sent to Linus during the next merge window (or sooner if it is a bug fix), however if problems are discovered then the patch may be dropped or reverted. You may get further e-mails resulting from automated or manual testing and review of the tree, please engage with people reporting problems and send followup patches addressing any issues that are reported if needed. If any updates are required or you are submitting further changes they should be sent as incremental updates against current git, existing patches will not be replaced. Please add any relevant lists and maintainers to the CCs when replying to this mail. Thanks, Mark >From 34c906ddacd237511808fb2bbd941e6b91e9095a Mon Sep 17 00:00:00 2001 From: Hans de Goede Date: Thu, 5 Jul 2018 00:59:32 +0200 Subject: [PATCH] ASoC: rt5651: Allow disabling jack-detect by calling set_jack(NULL) Allow the machine driver to disable jack-detect over a suspend/resume by calling snd_soc_component_set_jack(NULL). Note this renames rt5651_set_jack, where all the jack-enable work was done to rt5651_enable_jack_detect. This function can now no longer fail as it does not request the IRQ anymore. It can still be passed an invalid jack source, but that should never happen, so this is now logged and treated as no jack source. Cc: Carlo Caione Signed-off-by: Hans de Goede Signed-off-by: Mark Brown --- sound/soc/codecs/rt5651.c | 55 +++++++++++++++++++++++++-------------- 1 file changed, 36 insertions(+), 19 deletions(-) -- 2.18.0.rc2 _______________________________________________ Alsa-devel mailing list Alsa-devel@alsa-project.org http://mailman.alsa-project.org/mailman/listinfo/alsa-devel diff --git a/sound/soc/codecs/rt5651.c b/sound/soc/codecs/rt5651.c index 39d2c67cd064..40bd1e70fee7 100644 --- a/sound/soc/codecs/rt5651.c +++ b/sound/soc/codecs/rt5651.c @@ -1703,14 +1703,10 @@ static void rt5651_cancel_work(void *data) cancel_work_sync(&rt5651->jack_detect_work); } -static int rt5651_set_jack(struct snd_soc_component *component, - struct snd_soc_jack *hp_jack, void *data) +static void rt5651_enable_jack_detect(struct snd_soc_component *component, + struct snd_soc_jack *hp_jack) { struct rt5651_priv *rt5651 = snd_soc_component_get_drvdata(component); - int ret; - - if (!rt5651->irq) - return -EINVAL; /* IRQ output on GPIO1 */ snd_soc_component_update_bits(component, RT5651_GPIO_CTRL1, @@ -1737,10 +1733,10 @@ static int rt5651_set_jack(struct snd_soc_component *component, RT5651_JD2_IRQ_EN, RT5651_JD2_IRQ_EN); break; case RT5651_JD_NULL: - return 0; + return; default: dev_err(component->dev, "Currently only JD1_1 / JD1_2 / JD2 are supported\n"); - return -EINVAL; + return; } /* Enable jack detect power */ @@ -1774,19 +1770,28 @@ static int rt5651_set_jack(struct snd_soc_component *component, RT5651_MB1_OC_STKY_MASK, RT5651_MB1_OC_STKY_EN); rt5651->hp_jack = hp_jack; - - ret = devm_request_threaded_irq(component->dev, rt5651->irq, NULL, - rt5651_irq, - IRQF_TRIGGER_RISING | - IRQF_TRIGGER_FALLING | - IRQF_ONESHOT, "rt5651", rt5651); - if (ret) { - dev_err(component->dev, "Failed to reguest IRQ: %d\n", ret); - return ret; - } - + enable_irq(rt5651->irq); /* sync initial jack state */ queue_work(system_power_efficient_wq, &rt5651->jack_detect_work); +} + +static void rt5651_disable_jack_detect(struct snd_soc_component *component) +{ + struct rt5651_priv *rt5651 = snd_soc_component_get_drvdata(component); + + disable_irq(rt5651->irq); + rt5651_cancel_work(rt5651); + + rt5651->hp_jack = NULL; +} + +static int rt5651_set_jack(struct snd_soc_component *component, + struct snd_soc_jack *jack, void *data) +{ + if (jack) + rt5651_enable_jack_detect(component, jack); + else + rt5651_disable_jack_detect(component); return 0; } @@ -2048,6 +2053,18 @@ static int rt5651_i2c_probe(struct i2c_client *i2c, if (ret) return ret; + ret = devm_request_irq(&i2c->dev, rt5651->irq, rt5651_irq, + IRQF_TRIGGER_RISING | IRQF_TRIGGER_FALLING + | IRQF_ONESHOT, "rt5651", rt5651); + if (ret == 0) { + /* Gets re-enabled by rt5651_set_jack() */ + disable_irq(rt5651->irq); + } else { + dev_warn(&i2c->dev, "Failed to reguest IRQ %d: %d\n", + rt5651->irq, ret); + rt5651->irq = -ENXIO; + } + ret = devm_snd_soc_register_component(&i2c->dev, &soc_component_dev_rt5651, rt5651_dai, ARRAY_SIZE(rt5651_dai));