aboutsummaryrefslogtreecommitdiffstats
path: root/sound/soc
diff options
context:
space:
mode:
authorLars-Peter Clausen <lars@metafoo.de>2015-03-04 04:33:16 -0500
committerMark Brown <broonie@kernel.org>2015-03-04 12:09:51 -0500
commitc472b93990e02c31f02322ddf0fdd9d571169310 (patch)
tree18fb840cb3f42e5be3d5a638c5d4d9674a252f53 /sound/soc
parentc517d838eb7d07bbe9507871fab3931deccff539 (diff)
ASoC: sn95031: Pass CODEC to sn95031_jack_detection()
The sn95031 driver currently gets the CODEC implicitly from the jack that is passed to sn95031_jack_detection(). But the codec field is going to be removed from the snd_soc_jack struct, so refactor things to pass the CODEC explicitly. Signed-off-by: Lars-Peter Clausen <lars@metafoo.de> Signed-off-by: Mark Brown <broonie@kernel.org>
Diffstat (limited to 'sound/soc')
-rw-r--r--sound/soc/codecs/sn95031.c14
-rw-r--r--sound/soc/codecs/sn95031.h3
-rw-r--r--sound/soc/intel/mfld_machine.c13
3 files changed, 17 insertions, 13 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
786static int sn95031_get_headset_state(struct snd_soc_jack *mfld_jack) 786static 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
798void sn95031_jack_detection(struct mfld_jack_data *jack_data) 799void 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
130extern void sn95031_jack_detection(struct mfld_jack_data *jack_data); 130extern 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/intel/mfld_machine.c b/sound/soc/intel/mfld_machine.c
index 90b7a57713a0..d22b44db824e 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,7 +255,7 @@ 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_jack_new(runtime->codec, "Intel(R) MID Audio Jack",
258 SND_JACK_HEADSET | SND_JACK_BTN_0 | 259 SND_JACK_HEADSET | SND_JACK_BTN_0 |
259 SND_JACK_BTN_1, &mfld_jack); 260 SND_JACK_BTN_1, &mfld_jack);
260 if (ret_val) { 261 if (ret_val) {
@@ -275,6 +276,8 @@ static int mfld_init(struct snd_soc_pcm_runtime *runtime)
275 return ret_val; 276 return ret_val;
276 } 277 }
277 278
279 mfld_codec = runtime->codec;
280
278 /* we want to check if anything is inserted at boot, 281 /* we want to check if anything is inserted at boot,
279 * so send a fake event to codec and it will read adc 282 * so send a fake event to codec and it will read adc
280 * to find if anything is there or not */ 283 * to find if anything is there or not */
@@ -359,8 +362,6 @@ static irqreturn_t snd_mfld_jack_detection(int irq, void *data)
359{ 362{
360 struct mfld_mc_private *mc_drv_ctx = (struct mfld_mc_private *) data; 363 struct mfld_mc_private *mc_drv_ctx = (struct mfld_mc_private *) data;
361 364
362 if (mfld_jack.codec == NULL)
363 return IRQ_HANDLED;
364 mfld_jack_check(mc_drv_ctx->interrupt_status); 365 mfld_jack_check(mc_drv_ctx->interrupt_status);
365 366
366 return IRQ_HANDLED; 367 return IRQ_HANDLED;