From patchwork Wed Mar 4 17:39:12 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Lopez Cruz, Misael" X-Patchwork-Id: 9866 Received: from vger.kernel.org (vger.kernel.org [209.132.176.167]) by demeter.kernel.org (8.14.2/8.14.2) with ESMTP id n24He7Y5014872 for ; Wed, 4 Mar 2009 17:40:07 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753896AbZCDRjp (ORCPT ); Wed, 4 Mar 2009 12:39:45 -0500 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1754456AbZCDRjp (ORCPT ); Wed, 4 Mar 2009 12:39:45 -0500 Received: from arroyo.ext.ti.com ([192.94.94.40]:44532 "EHLO arroyo.ext.ti.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754328AbZCDRjo convert rfc822-to-8bit (ORCPT ); Wed, 4 Mar 2009 12:39:44 -0500 Received: from dlep95.itg.ti.com ([157.170.170.107]) by arroyo.ext.ti.com (8.13.7/8.13.7) with ESMTP id n24HdNdS029170; Wed, 4 Mar 2009 11:39:28 -0600 Received: from dlee75.ent.ti.com (localhost [127.0.0.1]) by dlep95.itg.ti.com (8.13.8/8.13.8) with ESMTP id n24HdNDh023273; Wed, 4 Mar 2009 11:39:23 -0600 (CST) Received: from dlee07.ent.ti.com ([157.170.170.80]) by dlee75.ent.ti.com ([157.170.170.72]) with mapi; Wed, 4 Mar 2009 11:39:23 -0600 From: "Lopez Cruz, Misael" To: "alsa-devel@alsa-project.org" , "linux-omap@vger.kernel.org" CC: Mark Brown Date: Wed, 4 Mar 2009 11:39:12 -0600 Subject: [PATCH 2/2] ASoC: Add headset jack detection for SDP3430 machine driver Thread-Topic: [PATCH 2/2] ASoC: Add headset jack detection for SDP3430 machine driver Thread-Index: Acmc8CFZSem8CqxETmmfWRhxdARBcg== Message-ID: <2C7D3DF36ADFFC479B44490D912B616705ECD6E1B6@dlee07.ent.ti.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: acceptlanguage: en-US MIME-Version: 1.0 Sender: linux-omap-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-omap@vger.kernel.org Add headset jack detection for SDP3430 boards using SoC jack reporting interface. Headset detection on SDP3430 board is achieved through TWL4030 GPIO_2 pin. Signed-off-by: Misael Lopez Cruz --- sound/soc/omap/sdp3430.c | 49 ++++++++++++++++++++++++++++++++++++++++++++- 1 files changed, 47 insertions(+), 2 deletions(-) diff --git a/sound/soc/omap/sdp3430.c b/sound/soc/omap/sdp3430.c index 4eab4b4..b595aa4 100644 --- a/sound/soc/omap/sdp3430.c +++ b/sound/soc/omap/sdp3430.c @@ -28,6 +28,7 @@ #include #include #include +#include #include #include @@ -122,7 +123,7 @@ static int sdp3430_twl4030_init(struct snd_soc_codec *codec) /* SDP3430 connected pins */ snd_soc_dapm_enable_pin(codec, "Ext Mic"); snd_soc_dapm_enable_pin(codec, "Ext Spk"); - snd_soc_dapm_enable_pin(codec, "Headset Jack"); + snd_soc_dapm_disable_pin(codec, "Headset Jack"); /* TWL4030 not connected pins */ snd_soc_dapm_nc_pin(codec, "AUXL"); @@ -144,6 +145,29 @@ static int sdp3430_twl4030_init(struct snd_soc_codec *codec) return ret; } +/* Headset jack */ +struct snd_soc_jack *hs_jack; + +/* Headset jack DAPM pins */ +struct snd_soc_jack_pin hs_jack_pins[] = { + { + .pin = "Headset Jack", + .mask = SND_JACK_HEADSET, + .invert = 0, + }, +}; + +/* Headset jack gpios */ +struct snd_soc_jack_gpio hs_jack_gpios[] = { + { + .gpio = (OMAP_MAX_GPIO_LINES + 2), + .name = "hsdet-gpio", + .report = SND_JACK_HEADSET, + .invert = 0, + .debounce_time = 200, + }, +}; + /* Digital audio interface glue - connects codec <--> CPU */ static struct snd_soc_dai_link sdp3430_dai = { .name = "TWL4030", @@ -194,8 +218,25 @@ static int __init sdp3430_soc_init(void) if (ret) goto err1; - return 0; + /* Headset jack detection */ + hs_jack = kzalloc(sizeof(struct snd_soc_jack), GFP_KERNEL); + if (!hs_jack) + return -ENOMEM; + + ret = snd_soc_jack_new(&snd_soc_sdp3430, "SDP3430 headset jack", + SND_JACK_HEADSET, hs_jack); + if (ret) + return ret; + + ret = snd_soc_jack_add_pins(hs_jack, ARRAY_SIZE(hs_jack_pins), + hs_jack_pins); + if (ret) + return ret; + + ret = snd_soc_jack_add_gpios(hs_jack, ARRAY_SIZE(hs_jack_gpios), + hs_jack_gpios); + return ret; err1: printk(KERN_ERR "Unable to add platform device\n"); platform_device_put(sdp3430_snd_device); @@ -206,6 +247,10 @@ module_init(sdp3430_soc_init); static void __exit sdp3430_soc_exit(void) { + snd_soc_jack_free_gpios(hs_jack, ARRAY_SIZE(hs_jack_gpios), + hs_jack_gpios); + kfree(hs_jack); + platform_device_unregister(sdp3430_snd_device); } module_exit(sdp3430_soc_exit);