From patchwork Thu Oct 30 13:16:23 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Jie, Yang" X-Patchwork-Id: 5197601 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.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id EF2099F30B for ; Thu, 30 Oct 2014 13:16:57 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 31950201EC for ; Thu, 30 Oct 2014 13:16:56 +0000 (UTC) Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) by mail.kernel.org (Postfix) with ESMTP id E94B420179 for ; Thu, 30 Oct 2014 13:16:53 +0000 (UTC) Received: by alsa0.perex.cz (Postfix, from userid 1000) id 9FECE26062E; Thu, 30 Oct 2014 14:16:52 +0100 (CET) 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,NO_DNS_FOR_FROM, RCVD_IN_DNSWL_NONE,UNPARSEABLE_RELAY autolearn=no version=3.3.1 Received: from alsa0.perex.cz (localhost [IPv6:::1]) by alsa0.perex.cz (Postfix) with ESMTP id A1385260622; Thu, 30 Oct 2014 14:16:35 +0100 (CET) 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 B528426064F; Thu, 30 Oct 2014 14:16:34 +0100 (CET) Received: from mga14.intel.com (mga14.intel.com [192.55.52.115]) by alsa0.perex.cz (Postfix) with ESMTP id 25194265191 for ; Thu, 30 Oct 2014 14:16:12 +0100 (CET) Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by fmsmga103.fm.intel.com with ESMTP; 30 Oct 2014 06:10:09 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="4.97,862,1389772800"; d="scan'208";a="408485662" Received: from keyon-u1310.sh.intel.com ([10.239.13.7]) by FMSMGA003.fm.intel.com with ESMTP; 30 Oct 2014 06:08:01 -0700 From: Jie Yang To: broonie@kernel.org Date: Thu, 30 Oct 2014 21:16:23 +0800 Message-Id: <1414674983-7459-1-git-send-email-yang.jie@intel.com> X-Mailer: git-send-email 1.9.1 Cc: alsa-devel@alsa-project.org, liam.r.girdwood@intel.com Subject: [alsa-devel] [PATCH] ASoC: Intel: Add jack detection for Broadwell 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 jack dectection and event reporting for Broadwell. It use combo jack on BDW platform, which including Mic Jack pin and Headphone jack pin. Signed-off-by: Jie Yang --- sound/soc/intel/broadwell.c | 49 ++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 46 insertions(+), 3 deletions(-) diff --git a/sound/soc/intel/broadwell.c b/sound/soc/intel/broadwell.c index 0e550f1..52cb764 100644 --- a/sound/soc/intel/broadwell.c +++ b/sound/soc/intel/broadwell.c @@ -19,6 +19,7 @@ #include #include #include +#include #include #include "sst-dsp.h" @@ -26,8 +27,26 @@ #include "../codecs/rt286.h" +static struct snd_soc_jack broadwell_headset; +/* Headset jack detection DAPM pins */ +static struct snd_soc_jack_pin broadwell_headset_pins[] = { + { + .pin = "Mic Jack", + .mask = SND_JACK_MICROPHONE, + }, + { + .pin = "Headphone Jack", + .mask = SND_JACK_HEADPHONE, + }, +}; + +static const struct snd_kcontrol_new broadwell_controls[] = { + SOC_DAPM_PIN_SWITCH("Speaker"), + SOC_DAPM_PIN_SWITCH("Headphone Jack"), +}; + static const struct snd_soc_dapm_widget broadwell_widgets[] = { - SND_SOC_DAPM_HP("Headphones", NULL), + SND_SOC_DAPM_HP("Headphone Jack", NULL), SND_SOC_DAPM_SPK("Speaker", NULL), SND_SOC_DAPM_MIC("Mic Jack", NULL), SND_SOC_DAPM_MIC("DMIC1", NULL), @@ -42,7 +61,7 @@ static const struct snd_soc_dapm_route broadwell_rt286_map[] = { {"Speaker", NULL, "SPOL"}, /* HP jack connectors - unknown if we have jack deteck */ - {"Headphones", NULL, "HPO Pin"}, + {"Headphone Jack", NULL, "HPO Pin"}, /* other jacks */ {"MIC1", NULL, "Mic Jack"}, @@ -57,6 +76,27 @@ static const struct snd_soc_dapm_route broadwell_rt286_map[] = { {"AIF1 Playback", NULL, "SSP0 CODEC OUT"}, }; +static int broadwell_rt286_codec_init(struct snd_soc_pcm_runtime *rtd) +{ + struct snd_soc_codec *codec = rtd->codec; + int ret = 0; + ret = snd_soc_jack_new(codec, "Headset", + SND_JACK_HEADSET | SND_JACK_BTN_0, &broadwell_headset); + + if (ret) + return ret; + + ret = snd_soc_jack_add_pins(&broadwell_headset, + ARRAY_SIZE(broadwell_headset_pins), + broadwell_headset_pins); + if (ret) + return ret; + + rt286_mic_detect(codec, &broadwell_headset); + return 0; +} + + static int broadwell_ssp0_fixup(struct snd_soc_pcm_runtime *rtd, struct snd_pcm_hw_params *params) { @@ -116,7 +156,7 @@ static int broadwell_rtd_init(struct snd_soc_pcm_runtime *rtd) } /* always connected - check HP for jack detect */ - snd_soc_dapm_enable_pin(dapm, "Headphones"); + snd_soc_dapm_enable_pin(dapm, "Headphone Jack"); snd_soc_dapm_enable_pin(dapm, "Speaker"); snd_soc_dapm_enable_pin(dapm, "Mic Jack"); snd_soc_dapm_enable_pin(dapm, "Line Jack"); @@ -196,6 +236,7 @@ static struct snd_soc_dai_link broadwell_rt286_dais[] = { .no_pcm = 1, .codec_name = "i2c-INT343A:00", .codec_dai_name = "rt286-aif1", + .init = broadwell_rt286_codec_init, .dai_fmt = SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_NB_NF | SND_SOC_DAIFMT_CBS_CFS, .ignore_suspend = 1, @@ -213,6 +254,8 @@ static struct snd_soc_card broadwell_rt286 = { .owner = THIS_MODULE, .dai_link = broadwell_rt286_dais, .num_links = ARRAY_SIZE(broadwell_rt286_dais), + .controls = broadwell_controls, + .num_controls = ARRAY_SIZE(broadwell_controls), .dapm_widgets = broadwell_widgets, .num_dapm_widgets = ARRAY_SIZE(broadwell_widgets), .dapm_routes = broadwell_rt286_map,