From patchwork Tue Dec 28 18:09:31 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Carl Philipp Klemm X-Patchwork-Id: 528971 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id C23ACC433EF for ; Wed, 29 Dec 2021 14:24:57 +0000 (UTC) Received: from alsa1.perex.cz (alsa1.perex.cz [207.180.221.201]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by alsa0.perex.cz (Postfix) with ESMTPS id 0F22617E0; Wed, 29 Dec 2021 15:24:06 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz 0F22617E0 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1640787896; bh=mJZbUJwRHeDPtocpi2IbwMtnDzzMO+WSDhY8NDfn1kc=; h=Date:From:To:Subject:Cc:List-Id:List-Unsubscribe:List-Archive: List-Post:List-Help:List-Subscribe:From; b=o+FI3fkenTxLKlwVavJ4yxrHDlh4GuEk+a4j9vtuALiBHXwgk5KmIh/5TT9umSTof St56hJUaLtRdD7R7UKV14eQZYLpm2BaKehXAbed6DLTWuzVJl0q40QJJFRMbKt8F1U ftyBhFWHpcnFghyqKcqlt5bcuvsBivW217inV55I= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id F1082F80534; Wed, 29 Dec 2021 15:20:52 +0100 (CET) Received: by alsa1.perex.cz (Postfix, from userid 50401) id EF591F80224; Tue, 28 Dec 2021 19:10:00 +0100 (CET) Received: from sender11-of-o51.zoho.eu (sender11-of-o51.zoho.eu [31.186.226.237]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by alsa1.perex.cz (Postfix) with ESMTPS id 347ECF800D1 for ; Tue, 28 Dec 2021 19:09:53 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz 347ECF800D1 ARC-Seal: i=1; a=rsa-sha256; t=1640714974; cv=none; d=zohomail.eu; s=zohoarc; b=b+2at6/dS3v78Y4eHWBZ+2wS9KgpDxcfg90OGlhKXFSnZpa1Iy7LrzS41PAghefXVdxUWhrLSlgAajpDxXVhVk3gkwA8uVLGCfG6PjhGbFJD/EBYmvyrbMIduCYJuvbsbWov3l6VjuRUPcDNSFUjT5QGFvY82Ej5fimGi4sHVY8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.eu; s=zohoarc; t=1640714974; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:MIME-Version:Message-ID:Subject:To; bh=oynB9R8k0PLl1IH46elp4NZHwnEBnjiXaZcMGJZ+cRY=; b=EJoBw4b5ePgr40U5SjGlpKS2nEGxPrKIrV9RZRwOx6vYwkXJBvzGcTfOnR/ql9qzKm03QSDuUyDX+q4gBupGbpVEhS+Nr78rE/z+Yi4Lez7GOxkjl7S3jJDLB5eEZ7+1gUJ0IuPgnLcTBqsIzHZONcEkCu4dYY18zcH22VY+f30= ARC-Authentication-Results: i=1; mx.zohomail.eu; spf=pass smtp.mailfrom=philipp@uvos.xyz; dmarc=pass header.from= Received: from UVOSLinux (aftr-37-201-192-113.unity-media.net [37.201.192.113]) by mx.zoho.eu with SMTPS id 1640714972300267.32556141033467; Tue, 28 Dec 2021 19:09:32 +0100 (CET) Date: Tue, 28 Dec 2021 19:09:31 +0100 From: Carl Philipp Klemm To: alsa-devel@alsa-project.org Subject: [RFC PATCH 1/3] ASoC: simple-card-utils: add support for componants provideing jack events via set_jack Message-Id: <20211228190931.df5d518220080a734532ebfd@uvos.xyz> X-Mailer: Sylpheed 3.7.0 (GTK+ 2.24.33; x86_64-unknown-linux-gnu) Mime-Version: 1.0 X-ZohoMailClient: External X-Mailman-Approved-At: Wed, 29 Dec 2021 15:20:41 +0100 Cc: tony@atomide.com, merlijn@wizzup.org, linux-omap@vger.kernel.org, sre@kernel.org, kuninori.morimoto.gx@renesas.com X-BeenThere: alsa-devel@alsa-project.org X-Mailman-Version: 2.1.15 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: , Errors-To: alsa-devel-bounces@alsa-project.org Sender: "Alsa-devel" This allows componants that want a jack to report state on to do so by calling set_jack on components implementing this function. Im not entirely sure this is the right way to do this so RFC Signed-off-by: Carl Philipp Klemm Reported-by: Carl Philipp Klemm Signed-off-by: Kuninori Morimoto --- include/sound/simple_card_utils.h | 6 ++-- sound/soc/generic/simple-card-utils.c | 47 +++++++++++++++++++-------- 2 files changed, 36 insertions(+), 17 deletions(-) diff --git a/include/sound/simple_card_utils.h b/include/sound/simple_card_utils.h index 51b3b485a92e..547ad537613d 100644 --- a/include/sound/simple_card_utils.h +++ b/include/sound/simple_card_utils.h @@ -57,8 +57,8 @@ struct asoc_simple_priv { struct prop_nums num; unsigned int mclk_fs; } *dai_props; - struct asoc_simple_jack hp_jack; - struct asoc_simple_jack mic_jack; + struct asoc_simple_jack *hp_jack; + struct asoc_simple_jack *mic_jack; struct snd_soc_dai_link *dai_link; struct asoc_simple_dai *dais; struct snd_soc_dai_link_component *dlcs; @@ -173,7 +173,7 @@ int asoc_simple_parse_pin_switches(struct snd_soc_card *card, char *prefix); int asoc_simple_init_jack(struct snd_soc_card *card, - struct asoc_simple_jack *sjack, + struct asoc_simple_jack **sjack, int is_hp, char *prefix, char *pin); int asoc_simple_init_priv(struct asoc_simple_priv *priv, struct link_info *li); diff --git a/sound/soc/generic/simple-card-utils.c b/sound/soc/generic/simple-card-utils.c index 10c63b73900c..1899feba16cc 100644 --- a/sound/soc/generic/simple-card-utils.c +++ b/sound/soc/generic/simple-card-utils.c @@ -395,6 +395,7 @@ int asoc_simple_dai_init(struct snd_soc_pcm_runtime *rtd) struct asoc_simple_priv *priv = snd_soc_card_get_drvdata(rtd->card); struct simple_dai_props *props = simple_priv_to_props(priv, rtd->num); struct asoc_simple_dai *dai; + struct snd_soc_component *component; int i, ret; for_each_prop_dai_codec(props, i, dai) { @@ -412,6 +413,21 @@ int asoc_simple_dai_init(struct snd_soc_pcm_runtime *rtd) if (ret < 0) return ret; + for_each_rtd_components(rtd, i, component) { + if (component->driver->set_jack) { + if (!priv->hp_jack) { + priv->hp_jack = devm_kzalloc(priv->snd_card.dev, + sizeof(*priv->hp_jack), GFP_KERNEL); + snd_soc_card_jack_new(&priv->snd_card, + "Headphones", + SND_JACK_HEADPHONE, + &priv->hp_jack->jack, + NULL, 0); + } + snd_soc_component_set_jack(component, &priv->hp_jack->jack, NULL); + } + } + return 0; } EXPORT_SYMBOL_GPL(asoc_simple_dai_init); @@ -554,7 +570,7 @@ int asoc_simple_parse_pin_switches(struct snd_soc_card *card, EXPORT_SYMBOL_GPL(asoc_simple_parse_pin_switches); int asoc_simple_init_jack(struct snd_soc_card *card, - struct asoc_simple_jack *sjack, + struct asoc_simple_jack **sjack, int is_hp, char *prefix, char *pin) { @@ -569,8 +585,6 @@ int asoc_simple_init_jack(struct snd_soc_card *card, if (!prefix) prefix = ""; - sjack->gpio.gpio = -ENOENT; - if (is_hp) { snprintf(prop, sizeof(prop), "%shp-det-gpio", prefix); pin_name = pin ? pin : "Headphones"; @@ -588,21 +602,26 @@ int asoc_simple_init_jack(struct snd_soc_card *card, return -EPROBE_DEFER; if (gpio_is_valid(det)) { - sjack->pin.pin = pin_name; - sjack->pin.mask = mask; + struct asoc_simple_jack *sjack_d; + + sjack = devm_kzalloc(dev, sizeof(*(*sjack)), GFP_KERNEL); + sjack_d = *sjack; + + sjack_d->pin.pin = pin_name; + sjack_d->pin.mask = mask; - sjack->gpio.name = gpio_name; - sjack->gpio.report = mask; - sjack->gpio.gpio = det; - sjack->gpio.invert = !!(flags & OF_GPIO_ACTIVE_LOW); - sjack->gpio.debounce_time = 150; + sjack_d->gpio.name = gpio_name; + sjack_d->gpio.report = mask; + sjack_d->gpio.gpio = det; + sjack_d->gpio.invert = !!(flags & OF_GPIO_ACTIVE_LOW); + sjack_d->gpio.debounce_time = 150; snd_soc_card_jack_new(card, pin_name, mask, - &sjack->jack, - &sjack->pin, 1); + &sjack_d->jack, + &sjack_d->pin, 1); - snd_soc_jack_add_gpios(&sjack->jack, 1, - &sjack->gpio); + snd_soc_jack_add_gpios(&sjack_d->jack, 1, + &sjack_d->gpio); } return 0; From patchwork Tue Dec 28 18:11:04 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Carl Philipp Klemm X-Patchwork-Id: 528812 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 7D503C433EF for ; Wed, 29 Dec 2021 14:25:13 +0000 (UTC) Received: from alsa1.perex.cz (alsa1.perex.cz [207.180.221.201]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by alsa0.perex.cz (Postfix) with ESMTPS id B8B3E17B8; Wed, 29 Dec 2021 15:24:21 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz B8B3E17B8 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1640787911; bh=Ei+lXkPbIaHpS0txYCFNixqmQqcdQQaWmqFXnMYH2oM=; h=Date:From:To:Subject:In-Reply-To:References:Cc:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=JzFVK57thndvJemTYOB29kbVg6iLqXQ9zJAU/xLe6wcssVgm2Dejur27138LAzpan NfPuyAXqLdFsN9PSMNPT2DPnnMRfZKZFzjzAHQCmP9+bIWRcAdmjfmoxGNCScwRid4 046bzWdEpuLl45iPuslZYHQExxvQnjPRTIuWn4dc= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id 8BFF5F8053B; Wed, 29 Dec 2021 15:20:53 +0100 (CET) Received: by alsa1.perex.cz (Postfix, from userid 50401) id CE235F800D1; Tue, 28 Dec 2021 19:11:26 +0100 (CET) Received: from sender11-of-o51.zoho.eu (sender11-of-o51.zoho.eu [31.186.226.237]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by alsa1.perex.cz (Postfix) with ESMTPS id A70B8F800D1 for ; Tue, 28 Dec 2021 19:11:20 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz A70B8F800D1 ARC-Seal: i=1; a=rsa-sha256; t=1640715068; cv=none; d=zohomail.eu; s=zohoarc; b=Wt4GPHKEWTIIBDsTgNxtbBUanAmIzXlQAGfi67OhlnkxyM8ynFgb5G8lZ0HueEDgS6a4AO6Sms/y6KQ7sp/ctATMR0Ashng04Fte1gmd6DTZti+q4eOFJkSd0eweR6i7IJyZIs66YqqfKXDJpE9YYejmrbpHO2jiRyjgUHyznOo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.eu; s=zohoarc; t=1640715068; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:MIME-Version:Message-ID:References:Subject:To; bh=/fwc56FAKMG1LNYNd43a5rhbPAtQvSgiuBH2beg1ceg=; b=IZI7NDm96uvJ5rxdpdXuN3SFghnG7I68C4EH3OahWfsj27uH0+r2rsawHpGrVRhATvTORyTdxwxyWu7WImOquG/RhKJkD7c+VPcKAGbsldCmOudM6N2p+oOgWSGO1FSVy2AX+4HUbWCatzG3Ua2QE3qTB0ILTDVSuqsQt1GRkTc= ARC-Authentication-Results: i=1; mx.zohomail.eu; spf=pass smtp.mailfrom=philipp@uvos.xyz; dmarc=pass header.from= Received: from UVOSLinux (aftr-37-201-192-113.unity-media.net [37.201.192.113]) by mx.zoho.eu with SMTPS id 1640715065616408.4636139419308; Tue, 28 Dec 2021 19:11:05 +0100 (CET) Date: Tue, 28 Dec 2021 19:11:04 +0100 From: Carl Philipp Klemm To: alsa-devel@alsa-project.org Subject: [RFC PATCH 2/3] ARM: dts: motorola-mapphone: add interrupt for headphone detection Message-Id: <20211228191104.631d126f13ac0bb09e91ca13@uvos.xyz> In-Reply-To: <20211228190931.df5d518220080a734532ebfd@uvos.xyz> References: <20211228190931.df5d518220080a734532ebfd@uvos.xyz> X-Mailer: Sylpheed 3.7.0 (GTK+ 2.24.33; x86_64-unknown-linux-gnu) Mime-Version: 1.0 X-ZohoMailClient: External X-Mailman-Approved-At: Wed, 29 Dec 2021 15:20:41 +0100 Cc: tony@atomide.com, merlijn@wizzup.org, linux-omap@vger.kernel.org, sre@kernel.org, kuninori.morimoto.gx@renesas.com X-BeenThere: alsa-devel@alsa-project.org X-Mailman-Version: 2.1.15 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: , Errors-To: alsa-devel-bounces@alsa-project.org Sender: "Alsa-devel" Signed-off-by: Carl Philipp Klemm --- arch/arm/boot/dts/motorola-cpcap-mapphone.dtsi | 3 +++ 1 file changed, 3 insertions(+) diff --git a/arch/arm/boot/dts/motorola-cpcap-mapphone.dtsi b/arch/arm/boot/dts/motorola-cpcap-mapphone.dtsi index 0aff0d306d06..e164169bf820 100644 --- a/arch/arm/boot/dts/motorola-cpcap-mapphone.dtsi +++ b/arch/arm/boot/dts/motorola-cpcap-mapphone.dtsi @@ -72,6 +72,9 @@ cpcap_audio: audio-codec { #address-cells = <1>; #size-cells = <0>; + interrupts-extended = <&cpcap 9 0>; + interrupt-names = "hpplugged"; + port@0 { reg = <0>; cpcap_audio_codec0: endpoint { From patchwork Tue Dec 28 18:15:18 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Carl Philipp Klemm X-Patchwork-Id: 528970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id F3903C433F5 for ; Wed, 29 Dec 2021 14:25:30 +0000 (UTC) Received: from alsa1.perex.cz (alsa1.perex.cz [207.180.221.201]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by alsa0.perex.cz (Postfix) with ESMTPS id 30942181D; Wed, 29 Dec 2021 15:24:39 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz 30942181D DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1640787929; bh=mfWJY8agmyxXqGSoLe/CpbM9pXFi+yQJdZOhFyoynzY=; h=Date:From:To:Subject:In-Reply-To:References:Cc:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=B8qhYiy5uyxqUsAuOKL/3ZJn/UfI/uuL2CTnmZCj4RL+WwMQIP9UB44LvwvYADzwT dr3v3agqZqnagx6oZ8FndAMmBDhXrE/eJ4tjpZRCBpjqgDf2+lshVvisvJ1o1gX8xb l5z/A0I1WVA6z9Y03cpFlix8mLAslOBaUVV/ZOUI= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id 22B5EF8053D; Wed, 29 Dec 2021 15:20:54 +0100 (CET) Received: by alsa1.perex.cz (Postfix, from userid 50401) id 6FED5F80224; Tue, 28 Dec 2021 19:15:43 +0100 (CET) Received: from sender11-of-o51.zoho.eu (sender11-of-o51.zoho.eu [31.186.226.237]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by alsa1.perex.cz (Postfix) with ESMTPS id E60C9F800D3 for ; Tue, 28 Dec 2021 19:15:40 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz E60C9F800D3 ARC-Seal: i=1; a=rsa-sha256; t=1640715322; cv=none; d=zohomail.eu; s=zohoarc; b=Ddru0NXj+J2ndHGcfGeZRminW6D0zON1QVpQGwNnigMB9DSW+CBz7a+c2Jhl3CBW8NePFzWng4BzCrJnokwqPxkTjWkYoyBK3YX92Y1ekOuTji9Qe/0nmp8Oi21VpBNcq3uidoDnOLbf08d0Hk96OySDo06Ckz6pT9ueG8b+dGM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.eu; s=zohoarc; t=1640715322; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:MIME-Version:Message-ID:References:Subject:To; bh=Bbx/C9sptTUAAKFS7EmRKe2vRI5sURdnxAWXT3CLNhI=; b=BT4fND3yfgxgK9FQng/wBKgGrEep5usQSye19zD2xbPGGNaekriWeZuXbkb/FSJn4LCCp9Ptl9ATGMpXBlFsVja5yoX4eSCNrFo9Z5QLp+zrc30brt6T1BK2HqhH4ZJhLSvymZdsedlboe1YDpRuRewf77OGriYt8czvCPeEWcw= ARC-Authentication-Results: i=1; mx.zohomail.eu; spf=pass smtp.mailfrom=philipp@uvos.xyz; dmarc=pass header.from= Received: from UVOSLinux (aftr-37-201-192-113.unity-media.net [37.201.192.113]) by mx.zoho.eu with SMTPS id 1640715320133654.0409791956471; Tue, 28 Dec 2021 19:15:20 +0100 (CET) Date: Tue, 28 Dec 2021 19:15:18 +0100 From: Carl Philipp Klemm To: alsa-devel@alsa-project.org Subject: [RFC PATCH 3/3] ASoC: cpcap: add headphone jack plug detection support Message-Id: <20211228191518.bb4fafff9439d42cf542375a@uvos.xyz> In-Reply-To: <20211228191104.631d126f13ac0bb09e91ca13@uvos.xyz> References: <20211228190931.df5d518220080a734532ebfd@uvos.xyz> <20211228191104.631d126f13ac0bb09e91ca13@uvos.xyz> X-Mailer: Sylpheed 3.7.0 (GTK+ 2.24.33; x86_64-unknown-linux-gnu) Mime-Version: 1.0 X-ZohoMailClient: External X-Mailman-Approved-At: Wed, 29 Dec 2021 15:20:41 +0100 Cc: tony@atomide.com, merlijn@wizzup.org, linux-omap@vger.kernel.org, sre@kernel.org, kuninori.morimoto.gx@renesas.com X-BeenThere: alsa-devel@alsa-project.org X-Mailman-Version: 2.1.15 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: , Errors-To: alsa-devel-bounces@alsa-project.org Sender: "Alsa-devel" Implements an interrupt handler that fires when a headphone is inserted. A jack must be provided to the codec via snd_soc_component_driver .set_jack This patch currently also reports on "Headphones" pin. this correctly causes a warning as this pin dose not exist, however reporting on any other pin causes userspace (pulse audio) to not react to the change, im not sure how pulseaudio is supposed to be configured to avoid this deliemma "Headphones" apears to be hard-coded, please do lmk if someone knows how to resolve this. --- sound/soc/codecs/cpcap.c | 104 +++++++++++++++++++++++++++++++++++---- 1 file changed, 94 insertions(+), 10 deletions(-) static int cpcap_audio_reset(struct snd_soc_component *component, bool swap_dai_configuration) { @@ -1628,13 +1686,9 @@ static int cpcap_audio_reset(struct snd_soc_component *component, static int cpcap_soc_probe(struct snd_soc_component *component) { - struct cpcap_audio *cpcap; + struct cpcap_audio *cpcap = snd_soc_component_get_drvdata(component); int err; - cpcap = devm_kzalloc(component->dev, sizeof(*cpcap), GFP_KERNEL); - if (!cpcap) - return -ENOMEM; - snd_soc_component_set_drvdata(component, cpcap); cpcap->component = component; cpcap->regmap = dev_get_regmap(component->dev->parent, NULL); @@ -1657,6 +1711,7 @@ static struct snd_soc_component_driver soc_codec_dev_cpcap = { .num_dapm_widgets = ARRAY_SIZE(cpcap_dapm_widgets), .dapm_routes = intercon, .num_dapm_routes = ARRAY_SIZE(intercon), + .set_jack = cpcap_set_jack_detect, .idle_bias_on = 1, .use_pmdown_time = 1, .endianness = 1, @@ -1665,13 +1720,42 @@ static struct snd_soc_component_driver soc_codec_dev_cpcap = { static int cpcap_codec_probe(struct platform_device *pdev) { - struct device_node *codec_node = - of_get_child_by_name(pdev->dev.parent->of_node, "audio-codec"); + struct cpcap_audio *cpcap; + struct device_node *codec_node; + int ret; + codec_node = of_get_child_by_name(pdev->dev.parent->of_node, "audio-codec"); pdev->dev.of_node = codec_node; - return devm_snd_soc_register_component(&pdev->dev, &soc_codec_dev_cpcap, + cpcap = devm_kzalloc(&pdev->dev, sizeof(*cpcap), GFP_KERNEL); + if (!cpcap) + return -ENOMEM; + dev_set_drvdata(&pdev->dev, cpcap); + + ret = devm_snd_soc_register_component(&pdev->dev, &soc_codec_dev_cpcap, cpcap_dai, ARRAY_SIZE(cpcap_dai)); + if (ret < 0) + return ret; + + cpcap->hp_irq = platform_get_irq_byname(pdev, "hpplugged"); + if (cpcap->hp_irq < 0) + return -ENODEV; + + cpcap->dev = &pdev->dev; + + ret = devm_request_threaded_irq(&pdev->dev, cpcap->hp_irq, NULL, + cpcap_hp_irq_thread, + IRQF_TRIGGER_RISING | + IRQF_TRIGGER_FALLING | + IRQF_ONESHOT, + "cpcap-codec-headphone", cpcap); + if (ret) { + dev_err(&pdev->dev, "could not get irq: %i\n", + ret); + return ret; + } + + return 0; } static struct platform_driver cpcap_codec_driver = { diff --git a/sound/soc/codecs/cpcap.c b/sound/soc/codecs/cpcap.c index 3c2bc98031b5..ed418ac75eca 100644 --- a/sound/soc/codecs/cpcap.c +++ b/sound/soc/codecs/cpcap.c @@ -15,6 +15,7 @@ #include #include #include +#include /* Register 512 CPCAP_REG_VAUDIOC --- Audio Regulator and Bias Voltage */ #define CPCAP_BIT_AUDIO_LOW_PWR 6 @@ -252,8 +253,14 @@ enum cpcap_dai { }; struct cpcap_audio { + struct device *dev; struct snd_soc_component *component; struct regmap *regmap; + struct snd_soc_jack *hp_jack; + + struct delayed_work jack_detect_work; + + int hp_irq; u16 vendor; @@ -603,6 +610,21 @@ static int cpcap_input_left_mux_put_enum(struct snd_kcontrol *kcontrol, return 0; } +static struct snd_soc_jack_pin headset_jack_pins[] = { + { + .pin = "Headset Right Playback Route", + .mask = SND_JACK_HEADPHONE, + }, + { + .pin = "Headset Left Playback Route", + .mask = SND_JACK_HEADPHONE, + }, + { + .pin = "Headphones", + .mask = SND_JACK_HEADPHONE, + } +}; + static const struct snd_kcontrol_new cpcap_input_left_mux = SOC_DAPM_ENUM_EXT("Input Left", cpcap_input_left_mux_enum, cpcap_input_left_mux_get_enum, @@ -1561,8 +1583,6 @@ static int cpcap_dai_mux(struct cpcap_audio *cpcap, bool swap_dai_configuration) u16 voice_mask = BIT(CPCAP_BIT_DIG_AUD_IN); int err; - - if (!swap_dai_configuration) { /* Codec on DAI0, HiFi on DAI1 */ voice_val = 0; @@ -1586,6 +1606,44 @@ static int cpcap_dai_mux(struct cpcap_audio *cpcap, bool swap_dai_configuration) return 0; } +static irqreturn_t cpcap_hp_irq_thread(int irq, void *arg) +{ + struct cpcap_audio *cpcap = arg; + int val = -1; + bool plugged; + + regmap_read(cpcap->regmap, CPCAP_REG_INTS1, &val); + plugged = val & (1<<9); + + if (!cpcap->component) { + dev_warn(cpcap->dev, "%s called before component is ready.", __func__); + return IRQ_HANDLED; + } + + if (!cpcap->hp_jack) { + dev_warn(cpcap->dev, "%s called before jack is ready.", __func__); + return IRQ_HANDLED; + } + + snd_soc_jack_report(cpcap->hp_jack, plugged ? 0 : SND_JACK_HEADPHONE, SND_JACK_HEADPHONE); + + return IRQ_HANDLED; +} + +static int cpcap_set_jack_detect(struct snd_soc_component *component, + struct snd_soc_jack *hp_jack, void *data) +{ + struct cpcap_audio *cpcap = snd_soc_component_get_drvdata(component); + + if (!cpcap->hp_jack) { + dev_info(cpcap->dev, "registering jack"); + cpcap->hp_jack = hp_jack; + snd_soc_jack_add_pins(hp_jack, ARRAY_SIZE(headset_jack_pins), headset_jack_pins); + } + + return 0; +} + From patchwork Sun Feb 20 00:15:59 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Carl Philipp Klemm X-Patchwork-Id: 544279 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 8FBD3C433EF for ; Sun, 20 Feb 2022 00:17:49 +0000 (UTC) Received: from alsa1.perex.cz (alsa1.perex.cz [207.180.221.201]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by alsa0.perex.cz (Postfix) with ESMTPS id 92B2116DC; Sun, 20 Feb 2022 01:16:57 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz 92B2116DC DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1645316267; bh=l0xCggp3Yorfo51MhNJ5eHrZulTF5l9FLnm8udQmpJU=; h=Date:From:To:Subject:In-Reply-To:References:Cc:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=Qsao5D6HrJDs+c78n3/ao8k55+umz60ZRBbt4Xl+fDHWS3p+bAhwGHqkKXjX+88eB SY8MmQehdSPAejTfLcaFt4azkH9nA2U/EWP0GcD3e0ZIUeOZ0ce/BVcHQDODTqGVON EYcX56YbNGnastt7gK3WT6rmanccljg6DgRsxb00= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id 25E31F8051D; Sun, 20 Feb 2022 01:16:20 +0100 (CET) Received: by alsa1.perex.cz (Postfix, from userid 50401) id 254B1F80518; Sun, 20 Feb 2022 01:16:18 +0100 (CET) Received: from sender11-of-o51.zoho.eu (sender11-of-o51.zoho.eu [31.186.226.237]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by alsa1.perex.cz (Postfix) with ESMTPS id 0F69CF804AA for ; Sun, 20 Feb 2022 01:16:12 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz 0F69CF804AA ARC-Seal: i=1; a=rsa-sha256; t=1645316162; cv=none; d=zohomail.eu; s=zohoarc; b=BpN+CjmxVbFd5iL6o3ttWjd6VLBrUp8QsteaPHo/XeNSDzCisLhxM/VT0d4J2x74fNOYf/G6iYJTBJmsD2YLlCrTBj2b0uIs6ePznBpuMXGWzbPzAXnVGjJ33jV2sdtyygCpaPScMpaIkPcplCpp8Dzd+H0BfJN21cmulH6DHco= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.eu; s=zohoarc; t=1645316162; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:MIME-Version:Message-ID:References:Subject:To; bh=SS8zOxqh5kA3jFU2G4euNrkYb3yGEgk+OrxXHHhdCYg=; b=Fh+YYavSUi7RcaBNxvCmYl5ppYu3aSYMZVQ8olmOqNaEkb5iiskpTwCbrtAC9ApXabQYNdaa2JZ6ttYbWkrdHoRL40HTv8cBpCHYd1wE/2/cU6NeqX776otHh8o8dhKPBKH/+AIOoBI5HZyj2p+77bPWo7S0VSZL6LtIdAgIfao= ARC-Authentication-Results: i=1; mx.zohomail.eu; spf=pass smtp.mailfrom=philipp@uvos.xyz; dmarc=pass header.from= Received: from UVOSLinux (ip-037-201-192-120.um10.pools.vodafone-ip.de [37.201.192.120]) by mx.zoho.eu with SMTPS id 16453161602811012.2654051731125; Sun, 20 Feb 2022 01:16:00 +0100 (CET) Date: Sun, 20 Feb 2022 01:15:59 +0100 From: Carl Philipp Klemm To: Kuninori Morimoto Subject: [PATCH 5/6] ARM: dts: motorola-mapphone: add has-hp-jack for audio-graph-card Message-Id: <20220220011559.474b4f7cacdef2865a6780f3@uvos.xyz> In-Reply-To: References: <20211228190931.df5d518220080a734532ebfd@uvos.xyz> <87a6gawxpe.wl-kuninori.morimoto.gx@gmail.com> <20220105101028.620b7f2cb7727eedfccd933e@uvos.xyz> <87r19ld48v.wl-kuninori.morimoto.gx@gmail.com> <20220108145749.f55500222b049f344415a5c3@uvos.xyz> X-Mailer: Sylpheed 3.7.0 (GTK+ 2.24.33; x86_64-unknown-linux-gnu) Mime-Version: 1.0 X-ZohoMailClient: External Cc: "alsa-devel@alsa-project.org" , "tony@atomide.com" , "merlijn@wizzup.org" , "sre@kernel.org" , "linux-omap@vger.kernel.org" , "kuninori.morimoto.gx@gmail.com" X-BeenThere: alsa-devel@alsa-project.org X-Mailman-Version: 2.1.15 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: , Errors-To: alsa-devel-bounces@alsa-project.org Sender: "Alsa-devel" Signed-off-by: Carl Philipp Klemm --- arch/arm/boot/dts/motorola-mapphone-common.dtsi | 2 ++ 1 file changed, 2 insertions(+) diff --git a/arch/arm/boot/dts/motorola-mapphone-common.dtsi b/arch/arm/boot/dts/motorola-mapphone-common.dtsi index e26950d8ca85..800017ce096f 100644 --- a/arch/arm/boot/dts/motorola-mapphone-common.dtsi +++ b/arch/arm/boot/dts/motorola-mapphone-common.dtsi @@ -150,6 +150,8 @@ soundcard { "Headphone Jack", "HSR", "MICR", "Internal Mic"; + has-hp-jack; + dais = <&mcbsp2_port>, <&mcbsp3_port>; }; From patchwork Sun Feb 20 00:18:58 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Carl Philipp Klemm X-Patchwork-Id: 544278 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 97DCDC433EF for ; Sun, 20 Feb 2022 00:20:16 +0000 (UTC) Received: from alsa1.perex.cz (alsa1.perex.cz [207.180.221.201]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by alsa0.perex.cz (Postfix) with ESMTPS id DD89916B9; Sun, 20 Feb 2022 01:19:24 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz DD89916B9 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1645316415; bh=CjW1qSeHC9/OWs28PAMcgi7i8z5QAYnN2OeQMhwRnhQ=; h=Date:From:To:Subject:In-Reply-To:References:Cc:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=DfRONvukajKh159i7RWCXjQMVS7aOyiQWSJBcmT4Xhf3wJbDB+x0yz3NMILra6sCM 0AtJneXcps7abJf6EOnB/JYYEluphWbvMIhDc21j0o0VKGUTrZFPboKE7c9Na8g49L 4MubUyycPCx2DUxiQzgHA7MfXWfkWntJmltuN9g8= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id 821A9F800EB; Sun, 20 Feb 2022 01:19:24 +0100 (CET) Received: by alsa1.perex.cz (Postfix, from userid 50401) id CBB23F8016A; Sun, 20 Feb 2022 01:19:22 +0100 (CET) Received: from sender11-of-o51.zoho.eu (sender11-of-o51.zoho.eu [31.186.226.237]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by alsa1.perex.cz (Postfix) with ESMTPS id B426FF800EB for ; Sun, 20 Feb 2022 01:19:16 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz B426FF800EB ARC-Seal: i=1; a=rsa-sha256; t=1645316342; cv=none; d=zohomail.eu; s=zohoarc; b=ANJbQkDemwckzFSq+2xpdp8T2cyPG9vn8p476qj5LWOs51BQPu3EzGnJ92NVZTu21KcC/vByCKjifnFIglMzop/se9/LdkUBuLBnnaPEPB/5GGzhN/9jrXsZY/NTLtIetHi1SsLVPvvRwLyv2d0tCxDbBOk2pI/MkRNFTDDr7Ms= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.eu; s=zohoarc; t=1645316342; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:MIME-Version:Message-ID:References:Subject:To; bh=3HCff0o6L0WKF7HPzVEAjwajRGUlkG9L5kSxZwlqVrk=; b=fUbKkdkQ+biq2Ebzk9Cm94OeWoaFS3WVf0B1Ezkke+8HdDxD72n+uv/SV6qvAhfc71P23TgvMBKQWxhYmwWwZuQAgIb0E/xI749twmEWMxrUL4G8/LtVAZkK/jTsa4vr5s4U0YHcqkDIn8pgi0bVL3cjYnHDnb8EFZjpcmsxhCY= ARC-Authentication-Results: i=1; mx.zohomail.eu; spf=pass smtp.mailfrom=philipp@uvos.xyz; dmarc=pass header.from= Received: from UVOSLinux (ip-037-201-192-120.um10.pools.vodafone-ip.de [37.201.192.120]) by mx.zoho.eu with SMTPS id 1645316339280515.4397359881773; Sun, 20 Feb 2022 01:18:59 +0100 (CET) Date: Sun, 20 Feb 2022 01:18:58 +0100 From: Carl Philipp Klemm To: Kuninori Morimoto Subject: [PATCH 6/6] Documentation: sound: audio-graph-card: update dts bindings to add has-hp-jack Message-Id: <20220220011858.d07e957747d22299a1c37df8@uvos.xyz> In-Reply-To: References: <20211228190931.df5d518220080a734532ebfd@uvos.xyz> <87a6gawxpe.wl-kuninori.morimoto.gx@gmail.com> <20220105101028.620b7f2cb7727eedfccd933e@uvos.xyz> <87r19ld48v.wl-kuninori.morimoto.gx@gmail.com> <20220108145749.f55500222b049f344415a5c3@uvos.xyz> X-Mailer: Sylpheed 3.7.0 (GTK+ 2.24.33; x86_64-unknown-linux-gnu) Mime-Version: 1.0 X-ZohoMailClient: External Cc: "alsa-devel@alsa-project.org" , "tony@atomide.com" , "merlijn@wizzup.org" , "sre@kernel.org" , "linux-omap@vger.kernel.org" , "kuninori.morimoto.gx@gmail.com" X-BeenThere: alsa-devel@alsa-project.org X-Mailman-Version: 2.1.15 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: , Errors-To: alsa-devel-bounces@alsa-project.org Sender: "Alsa-devel" Signed-off-by: Carl Philipp Klemm --- Documentation/devicetree/bindings/sound/audio-graph.yaml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Documentation/devicetree/bindings/sound/audio-graph.yaml b/Documentation/devicetree/bindings/sound/audio-graph.yaml index 4b46794e5153..5844b900789a 100644 --- a/Documentation/devicetree/bindings/sound/audio-graph.yaml +++ b/Documentation/devicetree/bindings/sound/audio-graph.yaml @@ -38,6 +38,8 @@ properties: maxItems: 1 mic-det-gpio: maxItems: 1 + hp-det-gpio: + description: Set this properties if the device has a headphone jack to be reported on by a snd_soc_component required: - dais