aboutsummaryrefslogtreecommitdiffstats
path: root/sound/soc/intel
diff options
context:
space:
mode:
authorJie Yang <yang.jie@intel.com>2014-10-30 09:16:23 -0400
committerMark Brown <broonie@kernel.org>2014-10-31 12:59:41 -0400
commitc1e99c913be4294e63b5e74b197b8a8c86e6e67b (patch)
treebc0f842cd3e1a3adbe5c4c67f5b8123feb8069db /sound/soc/intel
parent7fb73c74ffee65bda3b6d3b00c1b841f557a1191 (diff)
ASoC: Intel: Add jack detection for Broadwell
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 <yang.jie@intel.com> Signed-off-by: Mark Brown <broonie@kernel.org>
Diffstat (limited to 'sound/soc/intel')
-rw-r--r--sound/soc/intel/broadwell.c49
1 files changed, 46 insertions, 3 deletions
diff --git a/sound/soc/intel/broadwell.c b/sound/soc/intel/broadwell.c
index 0e550f14028f..52cb7645fa83 100644
--- a/sound/soc/intel/broadwell.c
+++ b/sound/soc/intel/broadwell.c
@@ -19,6 +19,7 @@
19#include <sound/core.h> 19#include <sound/core.h>
20#include <sound/pcm.h> 20#include <sound/pcm.h>
21#include <sound/soc.h> 21#include <sound/soc.h>
22#include <sound/jack.h>
22#include <sound/pcm_params.h> 23#include <sound/pcm_params.h>
23 24
24#include "sst-dsp.h" 25#include "sst-dsp.h"
@@ -26,8 +27,26 @@
26 27
27#include "../codecs/rt286.h" 28#include "../codecs/rt286.h"
28 29
30static struct snd_soc_jack broadwell_headset;
31/* Headset jack detection DAPM pins */
32static struct snd_soc_jack_pin broadwell_headset_pins[] = {
33 {
34 .pin = "Mic Jack",
35 .mask = SND_JACK_MICROPHONE,
36 },
37 {
38 .pin = "Headphone Jack",
39 .mask = SND_JACK_HEADPHONE,
40 },
41};
42
43static const struct snd_kcontrol_new broadwell_controls[] = {
44 SOC_DAPM_PIN_SWITCH("Speaker"),
45 SOC_DAPM_PIN_SWITCH("Headphone Jack"),
46};
47
29static const struct snd_soc_dapm_widget broadwell_widgets[] = { 48static const struct snd_soc_dapm_widget broadwell_widgets[] = {
30 SND_SOC_DAPM_HP("Headphones", NULL), 49 SND_SOC_DAPM_HP("Headphone Jack", NULL),
31 SND_SOC_DAPM_SPK("Speaker", NULL), 50 SND_SOC_DAPM_SPK("Speaker", NULL),
32 SND_SOC_DAPM_MIC("Mic Jack", NULL), 51 SND_SOC_DAPM_MIC("Mic Jack", NULL),
33 SND_SOC_DAPM_MIC("DMIC1", NULL), 52 SND_SOC_DAPM_MIC("DMIC1", NULL),
@@ -42,7 +61,7 @@ static const struct snd_soc_dapm_route broadwell_rt286_map[] = {
42 {"Speaker", NULL, "SPOL"}, 61 {"Speaker", NULL, "SPOL"},
43 62
44 /* HP jack connectors - unknown if we have jack deteck */ 63 /* HP jack connectors - unknown if we have jack deteck */
45 {"Headphones", NULL, "HPO Pin"}, 64 {"Headphone Jack", NULL, "HPO Pin"},
46 65
47 /* other jacks */ 66 /* other jacks */
48 {"MIC1", NULL, "Mic Jack"}, 67 {"MIC1", NULL, "Mic Jack"},
@@ -57,6 +76,27 @@ static const struct snd_soc_dapm_route broadwell_rt286_map[] = {
57 {"AIF1 Playback", NULL, "SSP0 CODEC OUT"}, 76 {"AIF1 Playback", NULL, "SSP0 CODEC OUT"},
58}; 77};
59 78
79static int broadwell_rt286_codec_init(struct snd_soc_pcm_runtime *rtd)
80{
81 struct snd_soc_codec *codec = rtd->codec;
82 int ret = 0;
83 ret = snd_soc_jack_new(codec, "Headset",
84 SND_JACK_HEADSET | SND_JACK_BTN_0, &broadwell_headset);
85
86 if (ret)
87 return ret;
88
89 ret = snd_soc_jack_add_pins(&broadwell_headset,
90 ARRAY_SIZE(broadwell_headset_pins),
91 broadwell_headset_pins);
92 if (ret)
93 return ret;
94
95 rt286_mic_detect(codec, &broadwell_headset);
96 return 0;
97}
98
99
60static int broadwell_ssp0_fixup(struct snd_soc_pcm_runtime *rtd, 100static int broadwell_ssp0_fixup(struct snd_soc_pcm_runtime *rtd,
61 struct snd_pcm_hw_params *params) 101 struct snd_pcm_hw_params *params)
62{ 102{
@@ -116,7 +156,7 @@ static int broadwell_rtd_init(struct snd_soc_pcm_runtime *rtd)
116 } 156 }
117 157
118 /* always connected - check HP for jack detect */ 158 /* always connected - check HP for jack detect */
119 snd_soc_dapm_enable_pin(dapm, "Headphones"); 159 snd_soc_dapm_enable_pin(dapm, "Headphone Jack");
120 snd_soc_dapm_enable_pin(dapm, "Speaker"); 160 snd_soc_dapm_enable_pin(dapm, "Speaker");
121 snd_soc_dapm_enable_pin(dapm, "Mic Jack"); 161 snd_soc_dapm_enable_pin(dapm, "Mic Jack");
122 snd_soc_dapm_enable_pin(dapm, "Line Jack"); 162 snd_soc_dapm_enable_pin(dapm, "Line Jack");
@@ -196,6 +236,7 @@ static struct snd_soc_dai_link broadwell_rt286_dais[] = {
196 .no_pcm = 1, 236 .no_pcm = 1,
197 .codec_name = "i2c-INT343A:00", 237 .codec_name = "i2c-INT343A:00",
198 .codec_dai_name = "rt286-aif1", 238 .codec_dai_name = "rt286-aif1",
239 .init = broadwell_rt286_codec_init,
199 .dai_fmt = SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_NB_NF | 240 .dai_fmt = SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_NB_NF |
200 SND_SOC_DAIFMT_CBS_CFS, 241 SND_SOC_DAIFMT_CBS_CFS,
201 .ignore_suspend = 1, 242 .ignore_suspend = 1,
@@ -213,6 +254,8 @@ static struct snd_soc_card broadwell_rt286 = {
213 .owner = THIS_MODULE, 254 .owner = THIS_MODULE,
214 .dai_link = broadwell_rt286_dais, 255 .dai_link = broadwell_rt286_dais,
215 .num_links = ARRAY_SIZE(broadwell_rt286_dais), 256 .num_links = ARRAY_SIZE(broadwell_rt286_dais),
257 .controls = broadwell_controls,
258 .num_controls = ARRAY_SIZE(broadwell_controls),
216 .dapm_widgets = broadwell_widgets, 259 .dapm_widgets = broadwell_widgets,
217 .num_dapm_widgets = ARRAY_SIZE(broadwell_widgets), 260 .num_dapm_widgets = ARRAY_SIZE(broadwell_widgets),
218 .dapm_routes = broadwell_rt286_map, 261 .dapm_routes = broadwell_rt286_map,