diff options
author | Peter Ujfalusi <peter.ujfalusi@ti.com> | 2011-12-22 11:58:01 (GMT) |
---|---|---|
committer | Peter Ujfalusi <peter.ujfalusi@ti.com> | 2012-01-26 13:40:52 (GMT) |
commit | 4ca07cb0cf698151a21e9a9e68a67ca9656d3632 (patch) | |
tree | f1ff7031a6d1a804de9ef6c5a041c350fd8e1f64 /sound/soc/omap/omap-abe-twl6040.c | |
parent | 8d946dd7dc5cc3f0eae3d6df2c9e927497e38850 (diff) | |
download | linux-4ca07cb0cf698151a21e9a9e68a67ca9656d3632.tar.xz |
ASoC: omap-abe-twl6040: Configure card according to platform data
Disable the not connected pins on the board based on the
received platform data.
DO not register the jack function on boards, which does not have
means to detect it (jack is always connected).
Signed-off-by: Peter Ujfalusi <peter.ujfalusi@ti.com>
Acked-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
Diffstat (limited to 'sound/soc/omap/omap-abe-twl6040.c')
-rw-r--r-- | sound/soc/omap/omap-abe-twl6040.c | 44 |
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 5b781f9..1da2603 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[] = { {"AFMR", NULL, "Line In"}, }; +static inline void twl6040_disconnect_pin(struct snd_soc_dapm_context *dapm, + int connected, char *pin) +{ + if (!connected) + snd_soc_dapm_disable_pin(dapm, pin); +} + static int omap_abe_twl6040_init(struct snd_soc_pcm_runtime *rtd) { struct snd_soc_codec *codec = rtd->codec; - int ret, hs_trim; + struct snd_soc_card *card = codec->card; + struct snd_soc_dapm_context *dapm = &codec->dapm; + struct omap_abe_twl6040_data *pdata = dev_get_platdata(card->dev); + int hs_trim; + int ret = 0; + + /* Disable not connected paths if not used */ + twl6040_disconnect_pin(dapm, pdata->has_hs, "Headset Stereophone"); + twl6040_disconnect_pin(dapm, pdata->has_hf, "Ext Spk"); + twl6040_disconnect_pin(dapm, pdata->has_ep, "Earphone Spk"); + twl6040_disconnect_pin(dapm, pdata->has_aux, "Line Out"); + twl6040_disconnect_pin(dapm, pdata->has_vibra, "Vinrator"); + twl6040_disconnect_pin(dapm, pdata->has_hsmic, "Headset Mic"); + twl6040_disconnect_pin(dapm, pdata->has_mainmic, "Main Handset Mic"); + twl6040_disconnect_pin(dapm, pdata->has_submic, "Sub Handset Mic"); + twl6040_disconnect_pin(dapm, pdata->has_afm, "Line In"); /* * 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) omap_mcpdm_configure_dn_offsets(rtd, TWL6040_HSF_TRIM_LEFT(hs_trim), TWL6040_HSF_TRIM_RIGHT(hs_trim)); - /* Headset jack detection */ - ret = snd_soc_jack_new(codec, "Headset Jack", - SND_JACK_HEADSET, &hs_jack); - if (ret) - return ret; - - ret = snd_soc_jack_add_pins(&hs_jack, ARRAY_SIZE(hs_jack_pins), - hs_jack_pins); + /* Headset jack detection only if it is supported */ + if (pdata->jack_detection) { + ret = snd_soc_jack_new(codec, "Headset Jack", + SND_JACK_HEADSET, &hs_jack); + if (ret) + return ret; - if (machine_is_omap_4430sdp()) + ret = snd_soc_jack_add_pins(&hs_jack, ARRAY_SIZE(hs_jack_pins), + hs_jack_pins); twl6040_hs_jack_detect(codec, &hs_jack, SND_JACK_HEADSET); - else - snd_soc_jack_report(&hs_jack, SND_JACK_HEADSET, SND_JACK_HEADSET); + } return ret; } |