aboutsummaryrefslogtreecommitdiffstats
path: root/sound/soc/omap/omap-abe-twl6040.c
diff options
context:
space:
mode:
Diffstat (limited to 'sound/soc/omap/omap-abe-twl6040.c')
-rw-r--r--sound/soc/omap/omap-abe-twl6040.c44
1 files changed, 32 insertions, 12 deletions
diff --git a/sound/soc/omap/omap-abe-twl6040.c b/sound/soc/omap/omap-abe-twl6040.c
index 5b781f904cd7..1da26031e26d 100644
--- a/sound/soc/omap/omap-abe-twl6040.c
+++ b/sound/soc/omap/omap-abe-twl6040.c
@@ -157,10 +157,32 @@ static const struct snd_soc_dapm_route audio_map[] = {
157 {"AFMR", NULL, "Line In"}, 157 {"AFMR", NULL, "Line In"},
158}; 158};
159 159
160static inline void twl6040_disconnect_pin(struct snd_soc_dapm_context *dapm,
161 int connected, char *pin)
162{
163 if (!connected)
164 snd_soc_dapm_disable_pin(dapm, pin);
165}
166
160static int omap_abe_twl6040_init(struct snd_soc_pcm_runtime *rtd) 167static int omap_abe_twl6040_init(struct snd_soc_pcm_runtime *rtd)
161{ 168{
162 struct snd_soc_codec *codec = rtd->codec; 169 struct snd_soc_codec *codec = rtd->codec;
163 int ret, hs_trim; 170 struct snd_soc_card *card = codec->card;
171 struct snd_soc_dapm_context *dapm = &codec->dapm;
172 struct omap_abe_twl6040_data *pdata = dev_get_platdata(card->dev);
173 int hs_trim;
174 int ret = 0;
175
176 /* Disable not connected paths if not used */
177 twl6040_disconnect_pin(dapm, pdata->has_hs, "Headset Stereophone");
178 twl6040_disconnect_pin(dapm, pdata->has_hf, "Ext Spk");
179 twl6040_disconnect_pin(dapm, pdata->has_ep, "Earphone Spk");
180 twl6040_disconnect_pin(dapm, pdata->has_aux, "Line Out");
181 twl6040_disconnect_pin(dapm, pdata->has_vibra, "Vinrator");
182 twl6040_disconnect_pin(dapm, pdata->has_hsmic, "Headset Mic");
183 twl6040_disconnect_pin(dapm, pdata->has_mainmic, "Main Handset Mic");
184 twl6040_disconnect_pin(dapm, pdata->has_submic, "Sub Handset Mic");
185 twl6040_disconnect_pin(dapm, pdata->has_afm, "Line In");
164 186
165 /* 187 /*
166 * Configure McPDM offset cancellation based on the HSOTRIM value from 188 * Configure McPDM offset cancellation based on the HSOTRIM value from
@@ -170,19 +192,17 @@ static int omap_abe_twl6040_init(struct snd_soc_pcm_runtime *rtd)
170 omap_mcpdm_configure_dn_offsets(rtd, TWL6040_HSF_TRIM_LEFT(hs_trim), 192 omap_mcpdm_configure_dn_offsets(rtd, TWL6040_HSF_TRIM_LEFT(hs_trim),
171 TWL6040_HSF_TRIM_RIGHT(hs_trim)); 193 TWL6040_HSF_TRIM_RIGHT(hs_trim));
172 194
173 /* Headset jack detection */ 195 /* Headset jack detection only if it is supported */
174 ret = snd_soc_jack_new(codec, "Headset Jack", 196 if (pdata->jack_detection) {
175 SND_JACK_HEADSET, &hs_jack); 197 ret = snd_soc_jack_new(codec, "Headset Jack",
176 if (ret) 198 SND_JACK_HEADSET, &hs_jack);
177 return ret; 199 if (ret)
178 200 return ret;
179 ret = snd_soc_jack_add_pins(&hs_jack, ARRAY_SIZE(hs_jack_pins),
180 hs_jack_pins);
181 201
182 if (machine_is_omap_4430sdp()) 202 ret = snd_soc_jack_add_pins(&hs_jack, ARRAY_SIZE(hs_jack_pins),
203 hs_jack_pins);
183 twl6040_hs_jack_detect(codec, &hs_jack, SND_JACK_HEADSET); 204 twl6040_hs_jack_detect(codec, &hs_jack, SND_JACK_HEADSET);
184 else 205 }
185 snd_soc_jack_report(&hs_jack, SND_JACK_HEADSET, SND_JACK_HEADSET);
186 206
187 return ret; 207 return ret;
188} 208}