diff options
author | Peter Ujfalusi <peter.ujfalusi@ti.com> | 2012-09-10 06:46:27 -0400 |
---|---|---|
committer | Mark Brown <broonie@opensource.wolfsonmicro.com> | 2012-09-22 11:18:24 -0400 |
commit | 281ecd1611654cdcdec0ffcb55e8f285b8199727 (patch) | |
tree | 840f6d17d56fc02f2f19d36e775f5d8197360a1f | |
parent | 79026219588a8102a831ec682e11696fee35797d (diff) |
ASoC: twl4030: Move hs_extmute GPIO handling to driver
The external mute (if it is in use) is handled by a GPIO line. Prepare to
remove the set_hs_extmute callback and replace it with:
hs_extmute_gpio: the GPIO number to use for external mute
When the users of set_hs_extmute has been converted the callback can be removed.
Signed-off-by: Peter Ujfalusi <peter.ujfalusi@ti.com>
Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
-rw-r--r-- | include/linux/i2c/twl.h | 4 | ||||
-rw-r--r-- | sound/soc/codecs/twl4030.c | 32 |
2 files changed, 33 insertions, 3 deletions
diff --git a/include/linux/i2c/twl.h b/include/linux/i2c/twl.h index ac6488c9f250..2040309a46b7 100644 --- a/include/linux/i2c/twl.h +++ b/include/linux/i2c/twl.h | |||
@@ -667,7 +667,9 @@ struct twl4030_codec_data { | |||
667 | unsigned int check_defaults:1; | 667 | unsigned int check_defaults:1; |
668 | unsigned int reset_registers:1; | 668 | unsigned int reset_registers:1; |
669 | unsigned int hs_extmute:1; | 669 | unsigned int hs_extmute:1; |
670 | void (*set_hs_extmute)(int mute); | 670 | void (*set_hs_extmute)(int mute); /* Deprecated, use hs_extmute_gpio and |
671 | hs_extmute_disable_level */ | ||
672 | int hs_extmute_gpio; | ||
671 | }; | 673 | }; |
672 | 674 | ||
673 | struct twl4030_vibra_data { | 675 | struct twl4030_vibra_data { |
diff --git a/sound/soc/codecs/twl4030.c b/sound/soc/codecs/twl4030.c index 962341df7ddc..0c83c9263f4f 100644 --- a/sound/soc/codecs/twl4030.c +++ b/sound/soc/codecs/twl4030.c | |||
@@ -28,6 +28,7 @@ | |||
28 | #include <linux/platform_device.h> | 28 | #include <linux/platform_device.h> |
29 | #include <linux/i2c/twl.h> | 29 | #include <linux/i2c/twl.h> |
30 | #include <linux/slab.h> | 30 | #include <linux/slab.h> |
31 | #include <linux/gpio.h> | ||
31 | #include <sound/core.h> | 32 | #include <sound/core.h> |
32 | #include <sound/pcm.h> | 33 | #include <sound/pcm.h> |
33 | #include <sound/pcm_params.h> | 34 | #include <sound/pcm_params.h> |
@@ -302,6 +303,22 @@ static void twl4030_init_chip(struct snd_soc_codec *codec) | |||
302 | u8 reg, byte; | 303 | u8 reg, byte; |
303 | int i = 0; | 304 | int i = 0; |
304 | 305 | ||
306 | if (pdata && pdata->hs_extmute && | ||
307 | gpio_is_valid(pdata->hs_extmute_gpio)) { | ||
308 | int ret; | ||
309 | |||
310 | if (!pdata->hs_extmute_gpio) | ||
311 | dev_warn(codec->dev, | ||
312 | "Extmute GPIO is 0 is this correct?\n"); | ||
313 | |||
314 | ret = gpio_request_one(pdata->hs_extmute_gpio, | ||
315 | GPIOF_OUT_INIT_LOW, "hs_extmute"); | ||
316 | if (ret) { | ||
317 | dev_err(codec->dev, "Failed to get hs_extmute GPIO\n"); | ||
318 | pdata->hs_extmute_gpio = -1; | ||
319 | } | ||
320 | } | ||
321 | |||
305 | /* Check defaults, if instructed before anything else */ | 322 | /* Check defaults, if instructed before anything else */ |
306 | if (pdata && pdata->check_defaults) | 323 | if (pdata && pdata->check_defaults) |
307 | twl4030_check_defaults(codec); | 324 | twl4030_check_defaults(codec); |
@@ -748,7 +765,10 @@ static void headset_ramp(struct snd_soc_codec *codec, int ramp) | |||
748 | /* Enable external mute control, this dramatically reduces | 765 | /* Enable external mute control, this dramatically reduces |
749 | * the pop-noise */ | 766 | * the pop-noise */ |
750 | if (pdata && pdata->hs_extmute) { | 767 | if (pdata && pdata->hs_extmute) { |
751 | if (pdata->set_hs_extmute) { | 768 | if (gpio_is_valid(pdata->hs_extmute_gpio)) { |
769 | gpio_set_value(pdata->hs_extmute_gpio, 1); | ||
770 | } else if (pdata->set_hs_extmute) { | ||
771 | dev_warn(codec->dev, "set_hs_extmute is deprecated\n"); | ||
752 | pdata->set_hs_extmute(1); | 772 | pdata->set_hs_extmute(1); |
753 | } else { | 773 | } else { |
754 | hs_pop |= TWL4030_EXTMUTE; | 774 | hs_pop |= TWL4030_EXTMUTE; |
@@ -786,7 +806,10 @@ static void headset_ramp(struct snd_soc_codec *codec, int ramp) | |||
786 | 806 | ||
787 | /* Disable external mute */ | 807 | /* Disable external mute */ |
788 | if (pdata && pdata->hs_extmute) { | 808 | if (pdata && pdata->hs_extmute) { |
789 | if (pdata->set_hs_extmute) { | 809 | if (gpio_is_valid(pdata->hs_extmute_gpio)) { |
810 | gpio_set_value(pdata->hs_extmute_gpio, 0); | ||
811 | } else if (pdata->set_hs_extmute) { | ||
812 | dev_warn(codec->dev, "set_hs_extmute is deprecated\n"); | ||
790 | pdata->set_hs_extmute(0); | 813 | pdata->set_hs_extmute(0); |
791 | } else { | 814 | } else { |
792 | hs_pop &= ~TWL4030_EXTMUTE; | 815 | hs_pop &= ~TWL4030_EXTMUTE; |
@@ -2236,12 +2259,17 @@ static int twl4030_soc_probe(struct snd_soc_codec *codec) | |||
2236 | 2259 | ||
2237 | static int twl4030_soc_remove(struct snd_soc_codec *codec) | 2260 | static int twl4030_soc_remove(struct snd_soc_codec *codec) |
2238 | { | 2261 | { |
2262 | struct twl4030_codec_data *pdata = dev_get_platdata(codec->dev); | ||
2239 | struct twl4030_priv *twl4030 = snd_soc_codec_get_drvdata(codec); | 2263 | struct twl4030_priv *twl4030 = snd_soc_codec_get_drvdata(codec); |
2240 | 2264 | ||
2241 | /* Reset registers to their chip default before leaving */ | 2265 | /* Reset registers to their chip default before leaving */ |
2242 | twl4030_reset_registers(codec); | 2266 | twl4030_reset_registers(codec); |
2243 | twl4030_set_bias_level(codec, SND_SOC_BIAS_OFF); | 2267 | twl4030_set_bias_level(codec, SND_SOC_BIAS_OFF); |
2244 | kfree(twl4030); | 2268 | kfree(twl4030); |
2269 | |||
2270 | if (pdata && pdata->hs_extmute && gpio_is_valid(pdata->hs_extmute_gpio)) | ||
2271 | gpio_free(pdata->hs_extmute_gpio); | ||
2272 | |||
2245 | return 0; | 2273 | return 0; |
2246 | } | 2274 | } |
2247 | 2275 | ||