diff options
author | Mark Brown <broonie@kernel.org> | 2015-04-08 16:09:54 -0400 |
---|---|---|
committer | Mark Brown <broonie@kernel.org> | 2015-04-08 16:09:54 -0400 |
commit | c77dc2c203908fe03582770b016ffc7c84242939 (patch) | |
tree | c85e844917bb40dbc9f9dc19cdc10af87f5624ea /sound/soc | |
parent | 012baec5c1eaab7ad98b461eb7afae2faf79dbea (diff) | |
parent | 77c71765ef78f87dd901fcb4c751908e835a3b2e (diff) |
Merge branch 'topic/jack' of git://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound into asoc-tegra
Diffstat (limited to 'sound/soc')
30 files changed, 162 insertions, 228 deletions
diff --git a/sound/soc/codecs/sn95031.c b/sound/soc/codecs/sn95031.c index 47b257e41809..1e5d2643c286 100644 --- a/sound/soc/codecs/sn95031.c +++ b/sound/soc/codecs/sn95031.c | |||
@@ -783,19 +783,21 @@ static inline void sn95031_enable_jack_btn(struct snd_soc_codec *codec) | |||
783 | snd_soc_write(codec, SN95031_BTNCTRL2, 0x01); | 783 | snd_soc_write(codec, SN95031_BTNCTRL2, 0x01); |
784 | } | 784 | } |
785 | 785 | ||
786 | static int sn95031_get_headset_state(struct snd_soc_jack *mfld_jack) | 786 | static int sn95031_get_headset_state(struct snd_soc_codec *codec, |
787 | struct snd_soc_jack *mfld_jack) | ||
787 | { | 788 | { |
788 | int micbias = sn95031_get_mic_bias(mfld_jack->codec); | 789 | int micbias = sn95031_get_mic_bias(codec); |
789 | 790 | ||
790 | int jack_type = snd_soc_jack_get_type(mfld_jack, micbias); | 791 | int jack_type = snd_soc_jack_get_type(mfld_jack, micbias); |
791 | 792 | ||
792 | pr_debug("jack type detected = %d\n", jack_type); | 793 | pr_debug("jack type detected = %d\n", jack_type); |
793 | if (jack_type == SND_JACK_HEADSET) | 794 | if (jack_type == SND_JACK_HEADSET) |
794 | sn95031_enable_jack_btn(mfld_jack->codec); | 795 | sn95031_enable_jack_btn(codec); |
795 | return jack_type; | 796 | return jack_type; |
796 | } | 797 | } |
797 | 798 | ||
798 | void sn95031_jack_detection(struct mfld_jack_data *jack_data) | 799 | void sn95031_jack_detection(struct snd_soc_codec *codec, |
800 | struct mfld_jack_data *jack_data) | ||
799 | { | 801 | { |
800 | unsigned int status; | 802 | unsigned int status; |
801 | unsigned int mask = SND_JACK_BTN_0 | SND_JACK_BTN_1 | SND_JACK_HEADSET; | 803 | unsigned int mask = SND_JACK_BTN_0 | SND_JACK_BTN_1 | SND_JACK_HEADSET; |
@@ -809,11 +811,11 @@ void sn95031_jack_detection(struct mfld_jack_data *jack_data) | |||
809 | status = SND_JACK_HEADSET | SND_JACK_BTN_1; | 811 | status = SND_JACK_HEADSET | SND_JACK_BTN_1; |
810 | } else if (jack_data->intr_id & 0x4) { | 812 | } else if (jack_data->intr_id & 0x4) { |
811 | pr_debug("headset or headphones inserted\n"); | 813 | pr_debug("headset or headphones inserted\n"); |
812 | status = sn95031_get_headset_state(jack_data->mfld_jack); | 814 | status = sn95031_get_headset_state(codec, jack_data->mfld_jack); |
813 | } else if (jack_data->intr_id & 0x8) { | 815 | } else if (jack_data->intr_id & 0x8) { |
814 | pr_debug("headset or headphones removed\n"); | 816 | pr_debug("headset or headphones removed\n"); |
815 | status = 0; | 817 | status = 0; |
816 | sn95031_disable_jack_btn(jack_data->mfld_jack->codec); | 818 | sn95031_disable_jack_btn(codec); |
817 | } else { | 819 | } else { |
818 | pr_err("unidentified interrupt\n"); | 820 | pr_err("unidentified interrupt\n"); |
819 | return; | 821 | return; |
diff --git a/sound/soc/codecs/sn95031.h b/sound/soc/codecs/sn95031.h index 20376d234fb8..7651fe4e6a45 100644 --- a/sound/soc/codecs/sn95031.h +++ b/sound/soc/codecs/sn95031.h | |||
@@ -127,6 +127,7 @@ struct mfld_jack_data { | |||
127 | struct snd_soc_jack *mfld_jack; | 127 | struct snd_soc_jack *mfld_jack; |
128 | }; | 128 | }; |
129 | 129 | ||
130 | extern void sn95031_jack_detection(struct mfld_jack_data *jack_data); | 130 | extern void sn95031_jack_detection(struct snd_soc_codec *codec, |
131 | struct mfld_jack_data *jack_data); | ||
131 | 132 | ||
132 | #endif | 133 | #endif |
diff --git a/sound/soc/fsl/imx-es8328.c b/sound/soc/fsl/imx-es8328.c index f8cf10e16ce9..20e7400e2611 100644 --- a/sound/soc/fsl/imx-es8328.c +++ b/sound/soc/fsl/imx-es8328.c | |||
@@ -53,9 +53,9 @@ static int imx_es8328_dai_init(struct snd_soc_pcm_runtime *rtd) | |||
53 | 53 | ||
54 | /* Headphone jack detection */ | 54 | /* Headphone jack detection */ |
55 | if (gpio_is_valid(data->jack_gpio)) { | 55 | if (gpio_is_valid(data->jack_gpio)) { |
56 | ret = snd_soc_jack_new(rtd->codec, "Headphone", | 56 | ret = snd_soc_card_jack_new(rtd->card, "Headphone", |
57 | SND_JACK_HEADPHONE | SND_JACK_BTN_0, | 57 | SND_JACK_HEADPHONE | SND_JACK_BTN_0, |
58 | &headset_jack); | 58 | &headset_jack, NULL, 0); |
59 | if (ret) | 59 | if (ret) |
60 | return ret; | 60 | return ret; |
61 | 61 | ||
diff --git a/sound/soc/fsl/wm1133-ev1.c b/sound/soc/fsl/wm1133-ev1.c index a958937ab405..0653aa83c927 100644 --- a/sound/soc/fsl/wm1133-ev1.c +++ b/sound/soc/fsl/wm1133-ev1.c | |||
@@ -205,16 +205,14 @@ static int wm1133_ev1_init(struct snd_soc_pcm_runtime *rtd) | |||
205 | struct snd_soc_dapm_context *dapm = &codec->dapm; | 205 | struct snd_soc_dapm_context *dapm = &codec->dapm; |
206 | 206 | ||
207 | /* Headphone jack detection */ | 207 | /* Headphone jack detection */ |
208 | snd_soc_jack_new(codec, "Headphone", SND_JACK_HEADPHONE, &hp_jack); | 208 | snd_soc_card_jack_new(rtd->card, "Headphone", SND_JACK_HEADPHONE, |
209 | snd_soc_jack_add_pins(&hp_jack, ARRAY_SIZE(hp_jack_pins), | 209 | &hp_jack, hp_jack_pins, ARRAY_SIZE(hp_jack_pins)); |
210 | hp_jack_pins); | ||
211 | wm8350_hp_jack_detect(codec, WM8350_JDR, &hp_jack, SND_JACK_HEADPHONE); | 210 | wm8350_hp_jack_detect(codec, WM8350_JDR, &hp_jack, SND_JACK_HEADPHONE); |
212 | 211 | ||
213 | /* Microphone jack detection */ | 212 | /* Microphone jack detection */ |
214 | snd_soc_jack_new(codec, "Microphone", | 213 | snd_soc_card_jack_new(rtd->card, "Microphone", |
215 | SND_JACK_MICROPHONE | SND_JACK_BTN_0, &mic_jack); | 214 | SND_JACK_MICROPHONE | SND_JACK_BTN_0, &mic_jack, |
216 | snd_soc_jack_add_pins(&mic_jack, ARRAY_SIZE(mic_jack_pins), | 215 | mic_jack_pins, ARRAY_SIZE(mic_jack_pins)); |
217 | mic_jack_pins); | ||
218 | wm8350_mic_jack_detect(codec, &mic_jack, SND_JACK_MICROPHONE, | 216 | wm8350_mic_jack_detect(codec, &mic_jack, SND_JACK_MICROPHONE, |
219 | SND_JACK_BTN_0); | 217 | SND_JACK_BTN_0); |
220 | 218 | ||
diff --git a/sound/soc/generic/simple-card.c b/sound/soc/generic/simple-card.c index f7c6734bd5da..b8ee47b7ba9c 100644 --- a/sound/soc/generic/simple-card.c +++ b/sound/soc/generic/simple-card.c | |||
@@ -176,11 +176,11 @@ static int asoc_simple_card_dai_init(struct snd_soc_pcm_runtime *rtd) | |||
176 | return ret; | 176 | return ret; |
177 | 177 | ||
178 | if (gpio_is_valid(priv->gpio_hp_det)) { | 178 | if (gpio_is_valid(priv->gpio_hp_det)) { |
179 | snd_soc_jack_new(codec->codec, "Headphones", SND_JACK_HEADPHONE, | 179 | snd_soc_card_jack_new(rtd->card, "Headphones", |
180 | &simple_card_hp_jack); | 180 | SND_JACK_HEADPHONE, |
181 | snd_soc_jack_add_pins(&simple_card_hp_jack, | 181 | &simple_card_hp_jack, |
182 | ARRAY_SIZE(simple_card_hp_jack_pins), | 182 | simple_card_hp_jack_pins, |
183 | simple_card_hp_jack_pins); | 183 | ARRAY_SIZE(simple_card_hp_jack_pins)); |
184 | 184 | ||
185 | simple_card_hp_jack_gpio.gpio = priv->gpio_hp_det; | 185 | simple_card_hp_jack_gpio.gpio = priv->gpio_hp_det; |
186 | simple_card_hp_jack_gpio.invert = priv->gpio_hp_det_invert; | 186 | simple_card_hp_jack_gpio.invert = priv->gpio_hp_det_invert; |
@@ -189,11 +189,11 @@ static int asoc_simple_card_dai_init(struct snd_soc_pcm_runtime *rtd) | |||
189 | } | 189 | } |
190 | 190 | ||
191 | if (gpio_is_valid(priv->gpio_mic_det)) { | 191 | if (gpio_is_valid(priv->gpio_mic_det)) { |
192 | snd_soc_jack_new(codec->codec, "Mic Jack", SND_JACK_MICROPHONE, | 192 | snd_soc_card_jack_new(rtd->card, "Mic Jack", |
193 | &simple_card_mic_jack); | 193 | SND_JACK_MICROPHONE, |
194 | snd_soc_jack_add_pins(&simple_card_mic_jack, | 194 | &simple_card_mic_jack, |
195 | ARRAY_SIZE(simple_card_mic_jack_pins), | 195 | simple_card_mic_jack_pins, |
196 | simple_card_mic_jack_pins); | 196 | ARRAY_SIZE(simple_card_mic_jack_pins)); |
197 | simple_card_mic_jack_gpio.gpio = priv->gpio_mic_det; | 197 | simple_card_mic_jack_gpio.gpio = priv->gpio_mic_det; |
198 | simple_card_mic_jack_gpio.invert = priv->gpio_mic_det_invert; | 198 | simple_card_mic_jack_gpio.invert = priv->gpio_mic_det_invert; |
199 | snd_soc_jack_add_gpios(&simple_card_mic_jack, 1, | 199 | snd_soc_jack_add_gpios(&simple_card_mic_jack, 1, |
diff --git a/sound/soc/intel/broadwell.c b/sound/soc/intel/broadwell.c index 9cf7d01479ad..9effa3da982f 100644 --- a/sound/soc/intel/broadwell.c +++ b/sound/soc/intel/broadwell.c | |||
@@ -80,15 +80,9 @@ static int broadwell_rt286_codec_init(struct snd_soc_pcm_runtime *rtd) | |||
80 | { | 80 | { |
81 | struct snd_soc_codec *codec = rtd->codec; | 81 | struct snd_soc_codec *codec = rtd->codec; |
82 | int ret = 0; | 82 | int ret = 0; |
83 | ret = snd_soc_jack_new(codec, "Headset", | 83 | ret = snd_soc_card_jack_new(rtd->card, "Headset", |
84 | SND_JACK_HEADSET | SND_JACK_BTN_0, &broadwell_headset); | 84 | SND_JACK_HEADSET | SND_JACK_BTN_0, &broadwell_headset, |
85 | 85 | broadwell_headset_pins, ARRAY_SIZE(broadwell_headset_pins)); | |
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) | 86 | if (ret) |
93 | return ret; | 87 | return ret; |
94 | 88 | ||
diff --git a/sound/soc/intel/byt-max98090.c b/sound/soc/intel/byt-max98090.c index 9832afe7d22c..d8b1f038da1c 100644 --- a/sound/soc/intel/byt-max98090.c +++ b/sound/soc/intel/byt-max98090.c | |||
@@ -84,7 +84,6 @@ static struct snd_soc_jack_gpio hs_jack_gpios[] = { | |||
84 | static int byt_max98090_init(struct snd_soc_pcm_runtime *runtime) | 84 | static int byt_max98090_init(struct snd_soc_pcm_runtime *runtime) |
85 | { | 85 | { |
86 | int ret; | 86 | int ret; |
87 | struct snd_soc_codec *codec = runtime->codec; | ||
88 | struct snd_soc_card *card = runtime->card; | 87 | struct snd_soc_card *card = runtime->card; |
89 | struct byt_max98090_private *drv = snd_soc_card_get_drvdata(card); | 88 | struct byt_max98090_private *drv = snd_soc_card_get_drvdata(card); |
90 | struct snd_soc_jack *jack = &drv->jack; | 89 | struct snd_soc_jack *jack = &drv->jack; |
@@ -100,13 +99,9 @@ static int byt_max98090_init(struct snd_soc_pcm_runtime *runtime) | |||
100 | } | 99 | } |
101 | 100 | ||
102 | /* Enable jack detection */ | 101 | /* Enable jack detection */ |
103 | ret = snd_soc_jack_new(codec, "Headset", | 102 | ret = snd_soc_card_jack_new(runtime->card, "Headset", |
104 | SND_JACK_LINEOUT | SND_JACK_HEADSET, jack); | 103 | SND_JACK_LINEOUT | SND_JACK_HEADSET, jack, |
105 | if (ret) | 104 | hs_jack_pins, ARRAY_SIZE(hs_jack_pins)); |
106 | return ret; | ||
107 | |||
108 | ret = snd_soc_jack_add_pins(jack, ARRAY_SIZE(hs_jack_pins), | ||
109 | hs_jack_pins); | ||
110 | if (ret) | 105 | if (ret) |
111 | return ret; | 106 | return ret; |
112 | 107 | ||
diff --git a/sound/soc/intel/cht_bsw_rt5645.c b/sound/soc/intel/cht_bsw_rt5645.c index bd29617a9ab9..0bfca2192ca0 100644 --- a/sound/soc/intel/cht_bsw_rt5645.c +++ b/sound/soc/intel/cht_bsw_rt5645.c | |||
@@ -169,17 +169,17 @@ static int cht_codec_init(struct snd_soc_pcm_runtime *runtime) | |||
169 | return ret; | 169 | return ret; |
170 | } | 170 | } |
171 | 171 | ||
172 | ret = snd_soc_jack_new(codec, "Headphone Jack", | 172 | ret = snd_soc_card_jack_new(runtime->card, "Headphone Jack", |
173 | SND_JACK_HEADPHONE, | 173 | SND_JACK_HEADPHONE, &ctx->hp_jack, |
174 | &ctx->hp_jack); | 174 | NULL, 0); |
175 | if (ret) { | 175 | if (ret) { |
176 | dev_err(runtime->dev, "HP jack creation failed %d\n", ret); | 176 | dev_err(runtime->dev, "HP jack creation failed %d\n", ret); |
177 | return ret; | 177 | return ret; |
178 | } | 178 | } |
179 | 179 | ||
180 | ret = snd_soc_jack_new(codec, "Mic Jack", | 180 | ret = snd_soc_card_jack_new(runtime->card, "Mic Jack", |
181 | SND_JACK_MICROPHONE, | 181 | SND_JACK_MICROPHONE, &ctx->mic_jack, |
182 | &ctx->mic_jack); | 182 | NULL, 0); |
183 | if (ret) { | 183 | if (ret) { |
184 | dev_err(runtime->dev, "Mic jack creation failed %d\n", ret); | 184 | dev_err(runtime->dev, "Mic jack creation failed %d\n", ret); |
185 | return ret; | 185 | return ret; |
diff --git a/sound/soc/intel/mfld_machine.c b/sound/soc/intel/mfld_machine.c index 90b7a57713a0..49c09a0add79 100644 --- a/sound/soc/intel/mfld_machine.c +++ b/sound/soc/intel/mfld_machine.c | |||
@@ -228,10 +228,13 @@ static void mfld_jack_check(unsigned int intr_status) | |||
228 | { | 228 | { |
229 | struct mfld_jack_data jack_data; | 229 | struct mfld_jack_data jack_data; |
230 | 230 | ||
231 | if (!mfld_codec) | ||
232 | return; | ||
233 | |||
231 | jack_data.mfld_jack = &mfld_jack; | 234 | jack_data.mfld_jack = &mfld_jack; |
232 | jack_data.intr_id = intr_status; | 235 | jack_data.intr_id = intr_status; |
233 | 236 | ||
234 | sn95031_jack_detection(&jack_data); | 237 | sn95031_jack_detection(mfld_codec, &jack_data); |
235 | /* TODO: add american headset detection post gpiolib support */ | 238 | /* TODO: add american headset detection post gpiolib support */ |
236 | } | 239 | } |
237 | 240 | ||
@@ -240,8 +243,6 @@ static int mfld_init(struct snd_soc_pcm_runtime *runtime) | |||
240 | struct snd_soc_dapm_context *dapm = &runtime->card->dapm; | 243 | struct snd_soc_dapm_context *dapm = &runtime->card->dapm; |
241 | int ret_val; | 244 | int ret_val; |
242 | 245 | ||
243 | mfld_codec = runtime->codec; | ||
244 | |||
245 | /* default is earpiece pin, userspace sets it explcitly */ | 246 | /* default is earpiece pin, userspace sets it explcitly */ |
246 | snd_soc_dapm_disable_pin(dapm, "Headphones"); | 247 | snd_soc_dapm_disable_pin(dapm, "Headphones"); |
247 | /* default is lineout NC, userspace sets it explcitly */ | 248 | /* default is lineout NC, userspace sets it explcitly */ |
@@ -254,20 +255,15 @@ static int mfld_init(struct snd_soc_pcm_runtime *runtime) | |||
254 | snd_soc_dapm_disable_pin(dapm, "LINEINR"); | 255 | snd_soc_dapm_disable_pin(dapm, "LINEINR"); |
255 | 256 | ||
256 | /* Headset and button jack detection */ | 257 | /* Headset and button jack detection */ |
257 | ret_val = snd_soc_jack_new(mfld_codec, "Intel(R) MID Audio Jack", | 258 | ret_val = snd_soc_card_jack_new(runtime->card, |
258 | SND_JACK_HEADSET | SND_JACK_BTN_0 | | 259 | "Intel(R) MID Audio Jack", SND_JACK_HEADSET | |
259 | SND_JACK_BTN_1, &mfld_jack); | 260 | SND_JACK_BTN_0 | SND_JACK_BTN_1, &mfld_jack, |
261 | mfld_jack_pins, ARRAY_SIZE(mfld_jack_pins)); | ||
260 | if (ret_val) { | 262 | if (ret_val) { |
261 | pr_err("jack creation failed\n"); | 263 | pr_err("jack creation failed\n"); |
262 | return ret_val; | 264 | return ret_val; |
263 | } | 265 | } |
264 | 266 | ||
265 | ret_val = snd_soc_jack_add_pins(&mfld_jack, | ||
266 | ARRAY_SIZE(mfld_jack_pins), mfld_jack_pins); | ||
267 | if (ret_val) { | ||
268 | pr_err("adding jack pins failed\n"); | ||
269 | return ret_val; | ||
270 | } | ||
271 | ret_val = snd_soc_jack_add_zones(&mfld_jack, | 267 | ret_val = snd_soc_jack_add_zones(&mfld_jack, |
272 | ARRAY_SIZE(mfld_zones), mfld_zones); | 268 | ARRAY_SIZE(mfld_zones), mfld_zones); |
273 | if (ret_val) { | 269 | if (ret_val) { |
@@ -275,6 +271,8 @@ static int mfld_init(struct snd_soc_pcm_runtime *runtime) | |||
275 | return ret_val; | 271 | return ret_val; |
276 | } | 272 | } |
277 | 273 | ||
274 | mfld_codec = runtime->codec; | ||
275 | |||
278 | /* we want to check if anything is inserted at boot, | 276 | /* we want to check if anything is inserted at boot, |
279 | * so send a fake event to codec and it will read adc | 277 | * so send a fake event to codec and it will read adc |
280 | * to find if anything is there or not */ | 278 | * to find if anything is there or not */ |
@@ -359,8 +357,6 @@ static irqreturn_t snd_mfld_jack_detection(int irq, void *data) | |||
359 | { | 357 | { |
360 | struct mfld_mc_private *mc_drv_ctx = (struct mfld_mc_private *) data; | 358 | struct mfld_mc_private *mc_drv_ctx = (struct mfld_mc_private *) data; |
361 | 359 | ||
362 | if (mfld_jack.codec == NULL) | ||
363 | return IRQ_HANDLED; | ||
364 | mfld_jack_check(mc_drv_ctx->interrupt_status); | 360 | mfld_jack_check(mc_drv_ctx->interrupt_status); |
365 | 361 | ||
366 | return IRQ_HANDLED; | 362 | return IRQ_HANDLED; |
diff --git a/sound/soc/omap/ams-delta.c b/sound/soc/omap/ams-delta.c index 706613077c15..16cc95fa4573 100644 --- a/sound/soc/omap/ams-delta.c +++ b/sound/soc/omap/ams-delta.c | |||
@@ -479,8 +479,8 @@ static int ams_delta_cx20442_init(struct snd_soc_pcm_runtime *rtd) | |||
479 | 479 | ||
480 | /* Add hook switch - can be used to control the codec from userspace | 480 | /* Add hook switch - can be used to control the codec from userspace |
481 | * even if line discipline fails */ | 481 | * even if line discipline fails */ |
482 | ret = snd_soc_jack_new(rtd->codec, "hook_switch", | 482 | ret = snd_soc_card_jack_new(card, "hook_switch", SND_JACK_HEADSET, |
483 | SND_JACK_HEADSET, &ams_delta_hook_switch); | 483 | &ams_delta_hook_switch, NULL, 0); |
484 | if (ret) | 484 | if (ret) |
485 | dev_warn(card->dev, | 485 | dev_warn(card->dev, |
486 | "Failed to allocate resources for hook switch, " | 486 | "Failed to allocate resources for hook switch, " |
diff --git a/sound/soc/omap/omap-abe-twl6040.c b/sound/soc/omap/omap-abe-twl6040.c index b9c65f1ad5a8..0843a68f277c 100644 --- a/sound/soc/omap/omap-abe-twl6040.c +++ b/sound/soc/omap/omap-abe-twl6040.c | |||
@@ -182,17 +182,17 @@ static int omap_abe_twl6040_init(struct snd_soc_pcm_runtime *rtd) | |||
182 | 182 | ||
183 | /* Headset jack detection only if it is supported */ | 183 | /* Headset jack detection only if it is supported */ |
184 | if (priv->jack_detection) { | 184 | if (priv->jack_detection) { |
185 | ret = snd_soc_jack_new(codec, "Headset Jack", | 185 | ret = snd_soc_card_jack_new(rtd->card, "Headset Jack", |
186 | SND_JACK_HEADSET, &hs_jack); | 186 | SND_JACK_HEADSET, &hs_jack, |
187 | hs_jack_pins, | ||
188 | ARRAY_SIZE(hs_jack_pins)); | ||
187 | if (ret) | 189 | if (ret) |
188 | return ret; | 190 | return ret; |
189 | 191 | ||
190 | ret = snd_soc_jack_add_pins(&hs_jack, ARRAY_SIZE(hs_jack_pins), | ||
191 | hs_jack_pins); | ||
192 | twl6040_hs_jack_detect(codec, &hs_jack, SND_JACK_HEADSET); | 192 | twl6040_hs_jack_detect(codec, &hs_jack, SND_JACK_HEADSET); |
193 | } | 193 | } |
194 | 194 | ||
195 | return ret; | 195 | return 0; |
196 | } | 196 | } |
197 | 197 | ||
198 | static const struct snd_soc_dapm_route dmic_audio_map[] = { | 198 | static const struct snd_soc_dapm_route dmic_audio_map[] = { |
diff --git a/sound/soc/omap/omap-twl4030.c b/sound/soc/omap/omap-twl4030.c index fb1f6bb87cd4..3673ada43bfb 100644 --- a/sound/soc/omap/omap-twl4030.c +++ b/sound/soc/omap/omap-twl4030.c | |||
@@ -170,14 +170,10 @@ static int omap_twl4030_init(struct snd_soc_pcm_runtime *rtd) | |||
170 | if (priv->jack_detect > 0) { | 170 | if (priv->jack_detect > 0) { |
171 | hs_jack_gpios[0].gpio = priv->jack_detect; | 171 | hs_jack_gpios[0].gpio = priv->jack_detect; |
172 | 172 | ||
173 | ret = snd_soc_jack_new(codec, "Headset Jack", SND_JACK_HEADSET, | 173 | ret = snd_soc_card_jack_new(rtd->card, "Headset Jack", |
174 | &priv->hs_jack); | 174 | SND_JACK_HEADSET, &priv->hs_jack, |
175 | if (ret) | 175 | hs_jack_pins, |
176 | return ret; | 176 | ARRAY_SIZE(hs_jack_pins)); |
177 | |||
178 | ret = snd_soc_jack_add_pins(&priv->hs_jack, | ||
179 | ARRAY_SIZE(hs_jack_pins), | ||
180 | hs_jack_pins); | ||
181 | if (ret) | 177 | if (ret) |
182 | return ret; | 178 | return ret; |
183 | 179 | ||
diff --git a/sound/soc/omap/rx51.c b/sound/soc/omap/rx51.c index 7f299357c2d2..c2ddf0fbfa28 100644 --- a/sound/soc/omap/rx51.c +++ b/sound/soc/omap/rx51.c | |||
@@ -311,9 +311,9 @@ static int rx51_aic34_init(struct snd_soc_pcm_runtime *rtd) | |||
311 | } | 311 | } |
312 | 312 | ||
313 | /* AV jack detection */ | 313 | /* AV jack detection */ |
314 | err = snd_soc_jack_new(codec, "AV Jack", | 314 | err = snd_soc_card_jack_new(rtd->card, "AV Jack", |
315 | SND_JACK_HEADSET | SND_JACK_VIDEOOUT, | 315 | SND_JACK_HEADSET | SND_JACK_VIDEOOUT, |
316 | &rx51_av_jack); | 316 | &rx51_av_jack, NULL, 0); |
317 | if (err) { | 317 | if (err) { |
318 | dev_err(card->dev, "Failed to add AV Jack\n"); | 318 | dev_err(card->dev, "Failed to add AV Jack\n"); |
319 | return err; | 319 | return err; |
diff --git a/sound/soc/pxa/hx4700.c b/sound/soc/pxa/hx4700.c index 73eb5ddf9753..9f8be7cd567e 100644 --- a/sound/soc/pxa/hx4700.c +++ b/sound/soc/pxa/hx4700.c | |||
@@ -126,17 +126,12 @@ static const struct snd_soc_dapm_route hx4700_audio_map[] = { | |||
126 | */ | 126 | */ |
127 | static int hx4700_ak4641_init(struct snd_soc_pcm_runtime *rtd) | 127 | static int hx4700_ak4641_init(struct snd_soc_pcm_runtime *rtd) |
128 | { | 128 | { |
129 | struct snd_soc_codec *codec = rtd->codec; | ||
130 | int err; | 129 | int err; |
131 | 130 | ||
132 | /* Jack detection API stuff */ | 131 | /* Jack detection API stuff */ |
133 | err = snd_soc_jack_new(codec, "Headphone Jack", | 132 | err = snd_soc_card_jack_new(rtd->card, "Headphone Jack", |
134 | SND_JACK_HEADPHONE, &hs_jack); | 133 | SND_JACK_HEADPHONE, &hs_jack, hs_jack_pin, |
135 | if (err) | 134 | ARRAY_SIZE(hs_jack_pin)); |
136 | return err; | ||
137 | |||
138 | err = snd_soc_jack_add_pins(&hs_jack, ARRAY_SIZE(hs_jack_pin), | ||
139 | hs_jack_pin); | ||
140 | if (err) | 135 | if (err) |
141 | return err; | 136 | return err; |
142 | 137 | ||
diff --git a/sound/soc/pxa/palm27x.c b/sound/soc/pxa/palm27x.c index 910336c5ebeb..c20bbc042425 100644 --- a/sound/soc/pxa/palm27x.c +++ b/sound/soc/pxa/palm27x.c | |||
@@ -75,17 +75,12 @@ static struct snd_soc_card palm27x_asoc; | |||
75 | 75 | ||
76 | static int palm27x_ac97_init(struct snd_soc_pcm_runtime *rtd) | 76 | static int palm27x_ac97_init(struct snd_soc_pcm_runtime *rtd) |
77 | { | 77 | { |
78 | struct snd_soc_codec *codec = rtd->codec; | ||
79 | int err; | 78 | int err; |
80 | 79 | ||
81 | /* Jack detection API stuff */ | 80 | /* Jack detection API stuff */ |
82 | err = snd_soc_jack_new(codec, "Headphone Jack", | 81 | err = snd_soc_card_jack_new(rtd->card, "Headphone Jack", |
83 | SND_JACK_HEADPHONE, &hs_jack); | 82 | SND_JACK_HEADPHONE, &hs_jack, hs_jack_pins, |
84 | if (err) | 83 | ARRAY_SIZE(hs_jack_pins)); |
85 | return err; | ||
86 | |||
87 | err = snd_soc_jack_add_pins(&hs_jack, ARRAY_SIZE(hs_jack_pins), | ||
88 | hs_jack_pins); | ||
89 | if (err) | 84 | if (err) |
90 | return err; | 85 | return err; |
91 | 86 | ||
diff --git a/sound/soc/pxa/ttc-dkb.c b/sound/soc/pxa/ttc-dkb.c index 5001dbb9b257..1753c7d9e760 100644 --- a/sound/soc/pxa/ttc-dkb.c +++ b/sound/soc/pxa/ttc-dkb.c | |||
@@ -78,15 +78,12 @@ static int ttc_pm860x_init(struct snd_soc_pcm_runtime *rtd) | |||
78 | struct snd_soc_codec *codec = rtd->codec; | 78 | struct snd_soc_codec *codec = rtd->codec; |
79 | 79 | ||
80 | /* Headset jack detection */ | 80 | /* Headset jack detection */ |
81 | snd_soc_jack_new(codec, "Headphone Jack", SND_JACK_HEADPHONE | 81 | snd_soc_card_jack_new(rtd->card, "Headphone Jack", SND_JACK_HEADPHONE | |
82 | | SND_JACK_BTN_0 | SND_JACK_BTN_1 | SND_JACK_BTN_2, | 82 | SND_JACK_BTN_0 | SND_JACK_BTN_1 | SND_JACK_BTN_2, |
83 | &hs_jack); | 83 | &hs_jack, hs_jack_pins, ARRAY_SIZE(hs_jack_pins)); |
84 | snd_soc_jack_add_pins(&hs_jack, ARRAY_SIZE(hs_jack_pins), | 84 | snd_soc_card_jack_new(rtd->card, "Microphone Jack", SND_JACK_MICROPHONE, |
85 | hs_jack_pins); | 85 | &mic_jack, mic_jack_pins, |
86 | snd_soc_jack_new(codec, "Microphone Jack", SND_JACK_MICROPHONE, | 86 | ARRAY_SIZE(mic_jack_pins)); |
87 | &mic_jack); | ||
88 | snd_soc_jack_add_pins(&mic_jack, ARRAY_SIZE(mic_jack_pins), | ||
89 | mic_jack_pins); | ||
90 | 87 | ||
91 | /* headphone, microphone detection & headset short detection */ | 88 | /* headphone, microphone detection & headset short detection */ |
92 | pm860x_hs_jack_detect(codec, &hs_jack, SND_JACK_HEADPHONE, | 89 | pm860x_hs_jack_detect(codec, &hs_jack, SND_JACK_HEADPHONE, |
diff --git a/sound/soc/pxa/z2.c b/sound/soc/pxa/z2.c index 76ccb172d0a7..bcbfbe8303f7 100644 --- a/sound/soc/pxa/z2.c +++ b/sound/soc/pxa/z2.c | |||
@@ -143,13 +143,9 @@ static int z2_wm8750_init(struct snd_soc_pcm_runtime *rtd) | |||
143 | snd_soc_dapm_disable_pin(dapm, "MONO1"); | 143 | snd_soc_dapm_disable_pin(dapm, "MONO1"); |
144 | 144 | ||
145 | /* Jack detection API stuff */ | 145 | /* Jack detection API stuff */ |
146 | ret = snd_soc_jack_new(codec, "Headset Jack", SND_JACK_HEADSET, | 146 | ret = snd_soc_card_jack_new(rtd->card, "Headset Jack", SND_JACK_HEADSET, |
147 | &hs_jack); | 147 | &hs_jack, hs_jack_pins, |
148 | if (ret) | 148 | ARRAY_SIZE(hs_jack_pins)); |
149 | goto err; | ||
150 | |||
151 | ret = snd_soc_jack_add_pins(&hs_jack, ARRAY_SIZE(hs_jack_pins), | ||
152 | hs_jack_pins); | ||
153 | if (ret) | 149 | if (ret) |
154 | goto err; | 150 | goto err; |
155 | 151 | ||
diff --git a/sound/soc/samsung/h1940_uda1380.c b/sound/soc/samsung/h1940_uda1380.c index 59b044255b78..c72e9fb26658 100644 --- a/sound/soc/samsung/h1940_uda1380.c +++ b/sound/soc/samsung/h1940_uda1380.c | |||
@@ -162,13 +162,8 @@ static struct platform_device *s3c24xx_snd_device; | |||
162 | 162 | ||
163 | static int h1940_uda1380_init(struct snd_soc_pcm_runtime *rtd) | 163 | static int h1940_uda1380_init(struct snd_soc_pcm_runtime *rtd) |
164 | { | 164 | { |
165 | struct snd_soc_codec *codec = rtd->codec; | 165 | snd_soc_card_jack_new(rtd->card, "Headphone Jack", SND_JACK_HEADPHONE, |
166 | 166 | &hp_jack, hp_jack_pins, ARRAY_SIZE(hp_jack_pins)); | |
167 | snd_soc_jack_new(codec, "Headphone Jack", SND_JACK_HEADPHONE, | ||
168 | &hp_jack); | ||
169 | |||
170 | snd_soc_jack_add_pins(&hp_jack, ARRAY_SIZE(hp_jack_pins), | ||
171 | hp_jack_pins); | ||
172 | 167 | ||
173 | snd_soc_jack_add_gpios(&hp_jack, ARRAY_SIZE(hp_jack_gpios), | 168 | snd_soc_jack_add_gpios(&hp_jack, ARRAY_SIZE(hp_jack_gpios), |
174 | hp_jack_gpios); | 169 | hp_jack_gpios); |
diff --git a/sound/soc/samsung/littlemill.c b/sound/soc/samsung/littlemill.c index 141519c21e21..31a820eb0ac3 100644 --- a/sound/soc/samsung/littlemill.c +++ b/sound/soc/samsung/littlemill.c | |||
@@ -260,12 +260,12 @@ static int littlemill_late_probe(struct snd_soc_card *card) | |||
260 | if (ret < 0) | 260 | if (ret < 0) |
261 | return ret; | 261 | return ret; |
262 | 262 | ||
263 | ret = snd_soc_jack_new(codec, "Headset", | 263 | ret = snd_soc_card_jack_new(card, "Headset", |
264 | SND_JACK_HEADSET | SND_JACK_MECHANICAL | | 264 | SND_JACK_HEADSET | SND_JACK_MECHANICAL | |
265 | SND_JACK_BTN_0 | SND_JACK_BTN_1 | | 265 | SND_JACK_BTN_0 | SND_JACK_BTN_1 | |
266 | SND_JACK_BTN_2 | SND_JACK_BTN_3 | | 266 | SND_JACK_BTN_2 | SND_JACK_BTN_3 | |
267 | SND_JACK_BTN_4 | SND_JACK_BTN_5, | 267 | SND_JACK_BTN_4 | SND_JACK_BTN_5, |
268 | &littlemill_headset); | 268 | &littlemill_headset, NULL, 0); |
269 | if (ret) | 269 | if (ret) |
270 | return ret; | 270 | return ret; |
271 | 271 | ||
diff --git a/sound/soc/samsung/lowland.c b/sound/soc/samsung/lowland.c index 243dea7ba38f..5f156093101e 100644 --- a/sound/soc/samsung/lowland.c +++ b/sound/soc/samsung/lowland.c | |||
@@ -56,16 +56,10 @@ static int lowland_wm5100_init(struct snd_soc_pcm_runtime *rtd) | |||
56 | return ret; | 56 | return ret; |
57 | } | 57 | } |
58 | 58 | ||
59 | ret = snd_soc_jack_new(codec, "Headset", | 59 | ret = snd_soc_card_jack_new(rtd->card, "Headset", SND_JACK_LINEOUT | |
60 | SND_JACK_LINEOUT | SND_JACK_HEADSET | | 60 | SND_JACK_HEADSET | SND_JACK_BTN_0, |
61 | SND_JACK_BTN_0, | 61 | &lowland_headset, lowland_headset_pins, |
62 | &lowland_headset); | 62 | ARRAY_SIZE(lowland_headset_pins)); |
63 | if (ret) | ||
64 | return ret; | ||
65 | |||
66 | ret = snd_soc_jack_add_pins(&lowland_headset, | ||
67 | ARRAY_SIZE(lowland_headset_pins), | ||
68 | lowland_headset_pins); | ||
69 | if (ret) | 63 | if (ret) |
70 | return ret; | 64 | return ret; |
71 | 65 | ||
diff --git a/sound/soc/samsung/rx1950_uda1380.c b/sound/soc/samsung/rx1950_uda1380.c index 873f2cb4bebe..35e37c457f1f 100644 --- a/sound/soc/samsung/rx1950_uda1380.c +++ b/sound/soc/samsung/rx1950_uda1380.c | |||
@@ -211,13 +211,8 @@ static int rx1950_hw_params(struct snd_pcm_substream *substream, | |||
211 | 211 | ||
212 | static int rx1950_uda1380_init(struct snd_soc_pcm_runtime *rtd) | 212 | static int rx1950_uda1380_init(struct snd_soc_pcm_runtime *rtd) |
213 | { | 213 | { |
214 | struct snd_soc_codec *codec = rtd->codec; | 214 | snd_soc_card_jack_new(rtd->card, "Headphone Jack", SND_JACK_HEADPHONE, |
215 | 215 | &hp_jack, hp_jack_pins, ARRAY_SIZE(hp_jack_pins)); | |
216 | snd_soc_jack_new(codec, "Headphone Jack", SND_JACK_HEADPHONE, | ||
217 | &hp_jack); | ||
218 | |||
219 | snd_soc_jack_add_pins(&hp_jack, ARRAY_SIZE(hp_jack_pins), | ||
220 | hp_jack_pins); | ||
221 | 216 | ||
222 | snd_soc_jack_add_gpios(&hp_jack, ARRAY_SIZE(hp_jack_gpios), | 217 | snd_soc_jack_add_gpios(&hp_jack, ARRAY_SIZE(hp_jack_gpios), |
223 | hp_jack_gpios); | 218 | hp_jack_gpios); |
diff --git a/sound/soc/samsung/smartq_wm8987.c b/sound/soc/samsung/smartq_wm8987.c index 8291d2a5f152..dfbe2db1c407 100644 --- a/sound/soc/samsung/smartq_wm8987.c +++ b/sound/soc/samsung/smartq_wm8987.c | |||
@@ -151,13 +151,10 @@ static int smartq_wm8987_init(struct snd_soc_pcm_runtime *rtd) | |||
151 | snd_soc_dapm_disable_pin(dapm, "Headphone Jack"); | 151 | snd_soc_dapm_disable_pin(dapm, "Headphone Jack"); |
152 | 152 | ||
153 | /* Headphone jack detection */ | 153 | /* Headphone jack detection */ |
154 | err = snd_soc_jack_new(codec, "Headphone Jack", | 154 | err = snd_soc_card_jack_new(rtd->card, "Headphone Jack", |
155 | SND_JACK_HEADPHONE, &smartq_jack); | 155 | SND_JACK_HEADPHONE, &smartq_jack, |
156 | if (err) | 156 | smartq_jack_pins, |
157 | return err; | 157 | ARRAY_SIZE(smartq_jack_pins)); |
158 | |||
159 | err = snd_soc_jack_add_pins(&smartq_jack, ARRAY_SIZE(smartq_jack_pins), | ||
160 | smartq_jack_pins); | ||
161 | if (err) | 158 | if (err) |
162 | return err; | 159 | return err; |
163 | 160 | ||
diff --git a/sound/soc/samsung/speyside.c b/sound/soc/samsung/speyside.c index 5ec7c52282f2..2dcb988bdff2 100644 --- a/sound/soc/samsung/speyside.c +++ b/sound/soc/samsung/speyside.c | |||
@@ -153,16 +153,10 @@ static int speyside_wm8996_init(struct snd_soc_pcm_runtime *rtd) | |||
153 | pr_err("Failed to request HP_SEL GPIO: %d\n", ret); | 153 | pr_err("Failed to request HP_SEL GPIO: %d\n", ret); |
154 | gpio_direction_output(WM8996_HPSEL_GPIO, speyside_jack_polarity); | 154 | gpio_direction_output(WM8996_HPSEL_GPIO, speyside_jack_polarity); |
155 | 155 | ||
156 | ret = snd_soc_jack_new(codec, "Headset", | 156 | ret = snd_soc_card_jack_new(rtd->card, "Headset", SND_JACK_LINEOUT | |
157 | SND_JACK_LINEOUT | SND_JACK_HEADSET | | 157 | SND_JACK_HEADSET | SND_JACK_BTN_0, |
158 | SND_JACK_BTN_0, | 158 | &speyside_headset, speyside_headset_pins, |
159 | &speyside_headset); | 159 | ARRAY_SIZE(speyside_headset_pins)); |
160 | if (ret) | ||
161 | return ret; | ||
162 | |||
163 | ret = snd_soc_jack_add_pins(&speyside_headset, | ||
164 | ARRAY_SIZE(speyside_headset_pins), | ||
165 | speyside_headset_pins); | ||
166 | if (ret) | 160 | if (ret) |
167 | return ret; | 161 | return ret; |
168 | 162 | ||
diff --git a/sound/soc/samsung/tobermory.c b/sound/soc/samsung/tobermory.c index 9c80506527c4..85ccfb7188cb 100644 --- a/sound/soc/samsung/tobermory.c +++ b/sound/soc/samsung/tobermory.c | |||
@@ -179,15 +179,10 @@ static int tobermory_late_probe(struct snd_soc_card *card) | |||
179 | if (ret < 0) | 179 | if (ret < 0) |
180 | return ret; | 180 | return ret; |
181 | 181 | ||
182 | ret = snd_soc_jack_new(codec, "Headset", | 182 | ret = snd_soc_card_jack_new(card, "Headset", SND_JACK_HEADSET | |
183 | SND_JACK_HEADSET | SND_JACK_BTN_0, | 183 | SND_JACK_BTN_0, &tobermory_headset, |
184 | &tobermory_headset); | 184 | tobermory_headset_pins, |
185 | if (ret) | 185 | ARRAY_SIZE(tobermory_headset_pins)); |
186 | return ret; | ||
187 | |||
188 | ret = snd_soc_jack_add_pins(&tobermory_headset, | ||
189 | ARRAY_SIZE(tobermory_headset_pins), | ||
190 | tobermory_headset_pins); | ||
191 | if (ret) | 186 | if (ret) |
192 | return ret; | 187 | return ret; |
193 | 188 | ||
diff --git a/sound/soc/soc-jack.c b/sound/soc/soc-jack.c index 4380dcc064a5..9f60c25c4568 100644 --- a/sound/soc/soc-jack.c +++ b/sound/soc/soc-jack.c | |||
@@ -22,30 +22,42 @@ | |||
22 | #include <trace/events/asoc.h> | 22 | #include <trace/events/asoc.h> |
23 | 23 | ||
24 | /** | 24 | /** |
25 | * snd_soc_jack_new - Create a new jack | 25 | * snd_soc_card_jack_new - Create a new jack |
26 | * @codec: ASoC codec | 26 | * @card: ASoC card |
27 | * @id: an identifying string for this jack | 27 | * @id: an identifying string for this jack |
28 | * @type: a bitmask of enum snd_jack_type values that can be detected by | 28 | * @type: a bitmask of enum snd_jack_type values that can be detected by |
29 | * this jack | 29 | * this jack |
30 | * @jack: structure to use for the jack | 30 | * @jack: structure to use for the jack |
31 | * @pins: Array of jack pins to be added to the jack or NULL | ||
32 | * @num_pins: Number of elements in the @pins array | ||
31 | * | 33 | * |
32 | * Creates a new jack object. | 34 | * Creates a new jack object. |
33 | * | 35 | * |
34 | * Returns zero if successful, or a negative error code on failure. | 36 | * Returns zero if successful, or a negative error code on failure. |
35 | * On success jack will be initialised. | 37 | * On success jack will be initialised. |
36 | */ | 38 | */ |
37 | int snd_soc_jack_new(struct snd_soc_codec *codec, const char *id, int type, | 39 | int snd_soc_card_jack_new(struct snd_soc_card *card, const char *id, int type, |
38 | struct snd_soc_jack *jack) | 40 | struct snd_soc_jack *jack, struct snd_soc_jack_pin *pins, |
41 | unsigned int num_pins) | ||
39 | { | 42 | { |
43 | int ret; | ||
44 | |||
40 | mutex_init(&jack->mutex); | 45 | mutex_init(&jack->mutex); |
41 | jack->codec = codec; | 46 | jack->card = card; |
42 | INIT_LIST_HEAD(&jack->pins); | 47 | INIT_LIST_HEAD(&jack->pins); |
43 | INIT_LIST_HEAD(&jack->jack_zones); | 48 | INIT_LIST_HEAD(&jack->jack_zones); |
44 | BLOCKING_INIT_NOTIFIER_HEAD(&jack->notifier); | 49 | BLOCKING_INIT_NOTIFIER_HEAD(&jack->notifier); |
45 | 50 | ||
46 | return snd_jack_new(codec->component.card->snd_card, id, type, &jack->jack); | 51 | ret = snd_jack_new(card->snd_card, id, type, &jack->jack); |
52 | if (ret) | ||
53 | return ret; | ||
54 | |||
55 | if (num_pins) | ||
56 | return snd_soc_jack_add_pins(jack, num_pins, pins); | ||
57 | |||
58 | return 0; | ||
47 | } | 59 | } |
48 | EXPORT_SYMBOL_GPL(snd_soc_jack_new); | 60 | EXPORT_SYMBOL_GPL(snd_soc_card_jack_new); |
49 | 61 | ||
50 | /** | 62 | /** |
51 | * snd_soc_jack_report - Report the current status for a jack | 63 | * snd_soc_jack_report - Report the current status for a jack |
@@ -63,7 +75,6 @@ EXPORT_SYMBOL_GPL(snd_soc_jack_new); | |||
63 | */ | 75 | */ |
64 | void snd_soc_jack_report(struct snd_soc_jack *jack, int status, int mask) | 76 | void snd_soc_jack_report(struct snd_soc_jack *jack, int status, int mask) |
65 | { | 77 | { |
66 | struct snd_soc_codec *codec; | ||
67 | struct snd_soc_dapm_context *dapm; | 78 | struct snd_soc_dapm_context *dapm; |
68 | struct snd_soc_jack_pin *pin; | 79 | struct snd_soc_jack_pin *pin; |
69 | unsigned int sync = 0; | 80 | unsigned int sync = 0; |
@@ -74,8 +85,7 @@ void snd_soc_jack_report(struct snd_soc_jack *jack, int status, int mask) | |||
74 | if (!jack) | 85 | if (!jack) |
75 | return; | 86 | return; |
76 | 87 | ||
77 | codec = jack->codec; | 88 | dapm = &jack->card->dapm; |
78 | dapm = &codec->dapm; | ||
79 | 89 | ||
80 | mutex_lock(&jack->mutex); | 90 | mutex_lock(&jack->mutex); |
81 | 91 | ||
@@ -175,12 +185,12 @@ int snd_soc_jack_add_pins(struct snd_soc_jack *jack, int count, | |||
175 | 185 | ||
176 | for (i = 0; i < count; i++) { | 186 | for (i = 0; i < count; i++) { |
177 | if (!pins[i].pin) { | 187 | if (!pins[i].pin) { |
178 | dev_err(jack->codec->dev, "ASoC: No name for pin %d\n", | 188 | dev_err(jack->card->dev, "ASoC: No name for pin %d\n", |
179 | i); | 189 | i); |
180 | return -EINVAL; | 190 | return -EINVAL; |
181 | } | 191 | } |
182 | if (!pins[i].mask) { | 192 | if (!pins[i].mask) { |
183 | dev_err(jack->codec->dev, "ASoC: No mask for pin %d" | 193 | dev_err(jack->card->dev, "ASoC: No mask for pin %d" |
184 | " (%s)\n", i, pins[i].pin); | 194 | " (%s)\n", i, pins[i].pin); |
185 | return -EINVAL; | 195 | return -EINVAL; |
186 | } | 196 | } |
@@ -260,7 +270,7 @@ static void snd_soc_jack_gpio_detect(struct snd_soc_jack_gpio *gpio) | |||
260 | static irqreturn_t gpio_handler(int irq, void *data) | 270 | static irqreturn_t gpio_handler(int irq, void *data) |
261 | { | 271 | { |
262 | struct snd_soc_jack_gpio *gpio = data; | 272 | struct snd_soc_jack_gpio *gpio = data; |
263 | struct device *dev = gpio->jack->codec->component.card->dev; | 273 | struct device *dev = gpio->jack->card->dev; |
264 | 274 | ||
265 | trace_snd_soc_jack_irq(gpio->name); | 275 | trace_snd_soc_jack_irq(gpio->name); |
266 | 276 | ||
@@ -299,7 +309,7 @@ int snd_soc_jack_add_gpios(struct snd_soc_jack *jack, int count, | |||
299 | 309 | ||
300 | for (i = 0; i < count; i++) { | 310 | for (i = 0; i < count; i++) { |
301 | if (!gpios[i].name) { | 311 | if (!gpios[i].name) { |
302 | dev_err(jack->codec->dev, | 312 | dev_err(jack->card->dev, |
303 | "ASoC: No name for gpio at index %d\n", i); | 313 | "ASoC: No name for gpio at index %d\n", i); |
304 | ret = -EINVAL; | 314 | ret = -EINVAL; |
305 | goto undo; | 315 | goto undo; |
@@ -320,7 +330,7 @@ int snd_soc_jack_add_gpios(struct snd_soc_jack *jack, int count, | |||
320 | } else { | 330 | } else { |
321 | /* legacy GPIO number */ | 331 | /* legacy GPIO number */ |
322 | if (!gpio_is_valid(gpios[i].gpio)) { | 332 | if (!gpio_is_valid(gpios[i].gpio)) { |
323 | dev_err(jack->codec->dev, | 333 | dev_err(jack->card->dev, |
324 | "ASoC: Invalid gpio %d\n", | 334 | "ASoC: Invalid gpio %d\n", |
325 | gpios[i].gpio); | 335 | gpios[i].gpio); |
326 | ret = -EINVAL; | 336 | ret = -EINVAL; |
@@ -350,7 +360,7 @@ int snd_soc_jack_add_gpios(struct snd_soc_jack *jack, int count, | |||
350 | if (gpios[i].wake) { | 360 | if (gpios[i].wake) { |
351 | ret = irq_set_irq_wake(gpiod_to_irq(gpios[i].desc), 1); | 361 | ret = irq_set_irq_wake(gpiod_to_irq(gpios[i].desc), 1); |
352 | if (ret != 0) | 362 | if (ret != 0) |
353 | dev_err(jack->codec->dev, | 363 | dev_err(jack->card->dev, |
354 | "ASoC: Failed to mark GPIO at index %d as wake source: %d\n", | 364 | "ASoC: Failed to mark GPIO at index %d as wake source: %d\n", |
355 | i, ret); | 365 | i, ret); |
356 | } | 366 | } |
diff --git a/sound/soc/tegra/tegra_alc5632.c b/sound/soc/tegra/tegra_alc5632.c index 769aca2fc5f5..6dcd06a966c7 100644 --- a/sound/soc/tegra/tegra_alc5632.c +++ b/sound/soc/tegra/tegra_alc5632.c | |||
@@ -106,11 +106,10 @@ static int tegra_alc5632_asoc_init(struct snd_soc_pcm_runtime *rtd) | |||
106 | struct snd_soc_dapm_context *dapm = &codec->dapm; | 106 | struct snd_soc_dapm_context *dapm = &codec->dapm; |
107 | struct tegra_alc5632 *machine = snd_soc_card_get_drvdata(rtd->card); | 107 | struct tegra_alc5632 *machine = snd_soc_card_get_drvdata(rtd->card); |
108 | 108 | ||
109 | snd_soc_jack_new(codec, "Headset Jack", SND_JACK_HEADSET, | 109 | snd_soc_card_jack_new(rtd->card, "Headset Jack", SND_JACK_HEADSET, |
110 | &tegra_alc5632_hs_jack); | 110 | &tegra_alc5632_hs_jack, |
111 | snd_soc_jack_add_pins(&tegra_alc5632_hs_jack, | 111 | tegra_alc5632_hs_jack_pins, |
112 | ARRAY_SIZE(tegra_alc5632_hs_jack_pins), | 112 | ARRAY_SIZE(tegra_alc5632_hs_jack_pins)); |
113 | tegra_alc5632_hs_jack_pins); | ||
114 | 113 | ||
115 | if (gpio_is_valid(machine->gpio_hp_det)) { | 114 | if (gpio_is_valid(machine->gpio_hp_det)) { |
116 | tegra_alc5632_hp_jack_gpio.gpio = machine->gpio_hp_det; | 115 | tegra_alc5632_hp_jack_gpio.gpio = machine->gpio_hp_det; |
diff --git a/sound/soc/tegra/tegra_max98090.c b/sound/soc/tegra/tegra_max98090.c index 1f20c2c40a5a..902da36581d1 100644 --- a/sound/soc/tegra/tegra_max98090.c +++ b/sound/soc/tegra/tegra_max98090.c | |||
@@ -145,16 +145,14 @@ static const struct snd_kcontrol_new tegra_max98090_controls[] = { | |||
145 | 145 | ||
146 | static int tegra_max98090_asoc_init(struct snd_soc_pcm_runtime *rtd) | 146 | static int tegra_max98090_asoc_init(struct snd_soc_pcm_runtime *rtd) |
147 | { | 147 | { |
148 | struct snd_soc_dai *codec_dai = rtd->codec_dai; | ||
149 | struct snd_soc_codec *codec = codec_dai->codec; | ||
150 | struct tegra_max98090 *machine = snd_soc_card_get_drvdata(rtd->card); | 148 | struct tegra_max98090 *machine = snd_soc_card_get_drvdata(rtd->card); |
151 | 149 | ||
152 | if (gpio_is_valid(machine->gpio_hp_det)) { | 150 | if (gpio_is_valid(machine->gpio_hp_det)) { |
153 | snd_soc_jack_new(codec, "Headphones", SND_JACK_HEADPHONE, | 151 | snd_soc_card_jack_new(rtd->card, "Headphones", |
154 | &tegra_max98090_hp_jack); | 152 | SND_JACK_HEADPHONE, |
155 | snd_soc_jack_add_pins(&tegra_max98090_hp_jack, | 153 | &tegra_max98090_hp_jack, |
156 | ARRAY_SIZE(tegra_max98090_hp_jack_pins), | 154 | tegra_max98090_hp_jack_pins, |
157 | tegra_max98090_hp_jack_pins); | 155 | ARRAY_SIZE(tegra_max98090_hp_jack_pins)); |
158 | 156 | ||
159 | tegra_max98090_hp_jack_gpio.gpio = machine->gpio_hp_det; | 157 | tegra_max98090_hp_jack_gpio.gpio = machine->gpio_hp_det; |
160 | snd_soc_jack_add_gpios(&tegra_max98090_hp_jack, | 158 | snd_soc_jack_add_gpios(&tegra_max98090_hp_jack, |
@@ -163,11 +161,11 @@ static int tegra_max98090_asoc_init(struct snd_soc_pcm_runtime *rtd) | |||
163 | } | 161 | } |
164 | 162 | ||
165 | if (gpio_is_valid(machine->gpio_mic_det)) { | 163 | if (gpio_is_valid(machine->gpio_mic_det)) { |
166 | snd_soc_jack_new(codec, "Mic Jack", SND_JACK_MICROPHONE, | 164 | snd_soc_card_jack_new(rtd->card, "Mic Jack", |
167 | &tegra_max98090_mic_jack); | 165 | SND_JACK_MICROPHONE, |
168 | snd_soc_jack_add_pins(&tegra_max98090_mic_jack, | 166 | &tegra_max98090_mic_jack, |
169 | ARRAY_SIZE(tegra_max98090_mic_jack_pins), | 167 | tegra_max98090_mic_jack_pins, |
170 | tegra_max98090_mic_jack_pins); | 168 | ARRAY_SIZE(tegra_max98090_mic_jack_pins)); |
171 | 169 | ||
172 | tegra_max98090_mic_jack_gpio.gpio = machine->gpio_mic_det; | 170 | tegra_max98090_mic_jack_gpio.gpio = machine->gpio_mic_det; |
173 | snd_soc_jack_add_gpios(&tegra_max98090_mic_jack, | 171 | snd_soc_jack_add_gpios(&tegra_max98090_mic_jack, |
diff --git a/sound/soc/tegra/tegra_rt5640.c b/sound/soc/tegra/tegra_rt5640.c index ed759a3076b8..773daecaa5e8 100644 --- a/sound/soc/tegra/tegra_rt5640.c +++ b/sound/soc/tegra/tegra_rt5640.c | |||
@@ -108,15 +108,11 @@ static const struct snd_kcontrol_new tegra_rt5640_controls[] = { | |||
108 | 108 | ||
109 | static int tegra_rt5640_asoc_init(struct snd_soc_pcm_runtime *rtd) | 109 | static int tegra_rt5640_asoc_init(struct snd_soc_pcm_runtime *rtd) |
110 | { | 110 | { |
111 | struct snd_soc_dai *codec_dai = rtd->codec_dai; | ||
112 | struct snd_soc_codec *codec = codec_dai->codec; | ||
113 | struct tegra_rt5640 *machine = snd_soc_card_get_drvdata(rtd->card); | 111 | struct tegra_rt5640 *machine = snd_soc_card_get_drvdata(rtd->card); |
114 | 112 | ||
115 | snd_soc_jack_new(codec, "Headphones", SND_JACK_HEADPHONE, | 113 | snd_soc_card_jack_new(rtd->card, "Headphones", SND_JACK_HEADPHONE, |
116 | &tegra_rt5640_hp_jack); | 114 | &tegra_rt5640_hp_jack, tegra_rt5640_hp_jack_pins, |
117 | snd_soc_jack_add_pins(&tegra_rt5640_hp_jack, | 115 | ARRAY_SIZE(tegra_rt5640_hp_jack_pins)); |
118 | ARRAY_SIZE(tegra_rt5640_hp_jack_pins), | ||
119 | tegra_rt5640_hp_jack_pins); | ||
120 | 116 | ||
121 | if (gpio_is_valid(machine->gpio_hp_det)) { | 117 | if (gpio_is_valid(machine->gpio_hp_det)) { |
122 | tegra_rt5640_hp_jack_gpio.gpio = machine->gpio_hp_det; | 118 | tegra_rt5640_hp_jack_gpio.gpio = machine->gpio_hp_det; |
diff --git a/sound/soc/tegra/tegra_rt5677.c b/sound/soc/tegra/tegra_rt5677.c index 4453566405ef..d082882547dd 100644 --- a/sound/soc/tegra/tegra_rt5677.c +++ b/sound/soc/tegra/tegra_rt5677.c | |||
@@ -146,10 +146,9 @@ static int tegra_rt5677_asoc_init(struct snd_soc_pcm_runtime *rtd) | |||
146 | struct snd_soc_dapm_context *dapm = &codec->dapm; | 146 | struct snd_soc_dapm_context *dapm = &codec->dapm; |
147 | struct tegra_rt5677 *machine = snd_soc_card_get_drvdata(rtd->card); | 147 | struct tegra_rt5677 *machine = snd_soc_card_get_drvdata(rtd->card); |
148 | 148 | ||
149 | snd_soc_jack_new(codec, "Headphone Jack", SND_JACK_HEADPHONE, | 149 | snd_soc_card_jack_new(rtd->card, "Headphone Jack", SND_JACK_HEADPHONE, |
150 | &tegra_rt5677_hp_jack); | 150 | &tegra_rt5677_hp_jack, |
151 | snd_soc_jack_add_pins(&tegra_rt5677_hp_jack, 1, | 151 | &tegra_rt5677_hp_jack_pins, 1); |
152 | &tegra_rt5677_hp_jack_pins); | ||
153 | 152 | ||
154 | if (gpio_is_valid(machine->gpio_hp_det)) { | 153 | if (gpio_is_valid(machine->gpio_hp_det)) { |
155 | tegra_rt5677_hp_jack_gpio.gpio = machine->gpio_hp_det; | 154 | tegra_rt5677_hp_jack_gpio.gpio = machine->gpio_hp_det; |
@@ -158,10 +157,9 @@ static int tegra_rt5677_asoc_init(struct snd_soc_pcm_runtime *rtd) | |||
158 | } | 157 | } |
159 | 158 | ||
160 | 159 | ||
161 | snd_soc_jack_new(codec, "Mic Jack", SND_JACK_MICROPHONE, | 160 | snd_soc_card_jack_new(rtd->card, "Mic Jack", SND_JACK_MICROPHONE, |
162 | &tegra_rt5677_mic_jack); | 161 | &tegra_rt5677_mic_jack, |
163 | snd_soc_jack_add_pins(&tegra_rt5677_mic_jack, 1, | 162 | &tegra_rt5677_mic_jack_pins, 1); |
164 | &tegra_rt5677_mic_jack_pins); | ||
165 | 163 | ||
166 | if (gpio_is_valid(machine->gpio_mic_present)) { | 164 | if (gpio_is_valid(machine->gpio_mic_present)) { |
167 | tegra_rt5677_mic_jack_gpio.gpio = machine->gpio_mic_present; | 165 | tegra_rt5677_mic_jack_gpio.gpio = machine->gpio_mic_present; |
diff --git a/sound/soc/tegra/tegra_wm8903.c b/sound/soc/tegra/tegra_wm8903.c index e52420dae2b4..4a95b70f0cf0 100644 --- a/sound/soc/tegra/tegra_wm8903.c +++ b/sound/soc/tegra/tegra_wm8903.c | |||
@@ -177,21 +177,19 @@ static int tegra_wm8903_init(struct snd_soc_pcm_runtime *rtd) | |||
177 | 177 | ||
178 | if (gpio_is_valid(machine->gpio_hp_det)) { | 178 | if (gpio_is_valid(machine->gpio_hp_det)) { |
179 | tegra_wm8903_hp_jack_gpio.gpio = machine->gpio_hp_det; | 179 | tegra_wm8903_hp_jack_gpio.gpio = machine->gpio_hp_det; |
180 | snd_soc_jack_new(codec, "Headphone Jack", SND_JACK_HEADPHONE, | 180 | snd_soc_card_jack_new(rtd->card, "Headphone Jack", |
181 | &tegra_wm8903_hp_jack); | 181 | SND_JACK_HEADPHONE, &tegra_wm8903_hp_jack, |
182 | snd_soc_jack_add_pins(&tegra_wm8903_hp_jack, | 182 | tegra_wm8903_hp_jack_pins, |
183 | ARRAY_SIZE(tegra_wm8903_hp_jack_pins), | 183 | ARRAY_SIZE(tegra_wm8903_hp_jack_pins)); |
184 | tegra_wm8903_hp_jack_pins); | ||
185 | snd_soc_jack_add_gpios(&tegra_wm8903_hp_jack, | 184 | snd_soc_jack_add_gpios(&tegra_wm8903_hp_jack, |
186 | 1, | 185 | 1, |
187 | &tegra_wm8903_hp_jack_gpio); | 186 | &tegra_wm8903_hp_jack_gpio); |
188 | } | 187 | } |
189 | 188 | ||
190 | snd_soc_jack_new(codec, "Mic Jack", SND_JACK_MICROPHONE, | 189 | snd_soc_card_jack_new(rtd->card, "Mic Jack", SND_JACK_MICROPHONE, |
191 | &tegra_wm8903_mic_jack); | 190 | &tegra_wm8903_mic_jack, |
192 | snd_soc_jack_add_pins(&tegra_wm8903_mic_jack, | 191 | tegra_wm8903_mic_jack_pins, |
193 | ARRAY_SIZE(tegra_wm8903_mic_jack_pins), | 192 | ARRAY_SIZE(tegra_wm8903_mic_jack_pins)); |
194 | tegra_wm8903_mic_jack_pins); | ||
195 | wm8903_mic_detect(codec, &tegra_wm8903_mic_jack, SND_JACK_MICROPHONE, | 193 | wm8903_mic_detect(codec, &tegra_wm8903_mic_jack, SND_JACK_MICROPHONE, |
196 | 0); | 194 | 0); |
197 | 195 | ||