Skip to content

Commit 281ecd1

Browse files
Peter Ujfalusibroonie
authored andcommitted
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>
1 parent 7902621 commit 281ecd1

2 files changed

Lines changed: 33 additions & 3 deletions

File tree

‎include/linux/i2c/twl.h‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -667,7 +667,9 @@ struct twl4030_codec_data {
667667
unsigned int check_defaults:1;
668668
unsigned int reset_registers:1;
669669
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;
671673
};
672674

673675
struct twl4030_vibra_data {

‎sound/soc/codecs/twl4030.c‎

Lines changed: 30 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
#include <linux/platform_device.h>
2929
#include <linux/i2c/twl.h>
3030
#include <linux/slab.h>
31+
#include <linux/gpio.h>
3132
#include <sound/core.h>
3233
#include <sound/pcm.h>
3334
#include <sound/pcm_params.h>
@@ -302,6 +303,22 @@ static void twl4030_init_chip(struct snd_soc_codec *codec)
302303
u8 reg, byte;
303304
int i = 0;
304305

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+
305322
/* Check defaults, if instructed before anything else */
306323
if (pdata && pdata->check_defaults)
307324
twl4030_check_defaults(codec);
@@ -748,7 +765,10 @@ static void headset_ramp(struct snd_soc_codec *codec, int ramp)
748765
/* Enable external mute control, this dramatically reduces
749766
* the pop-noise */
750767
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");
752772
pdata->set_hs_extmute(1);
753773
} else {
754774
hs_pop |= TWL4030_EXTMUTE;
@@ -786,7 +806,10 @@ static void headset_ramp(struct snd_soc_codec *codec, int ramp)
786806

787807
/* Disable external mute */
788808
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");
790813
pdata->set_hs_extmute(0);
791814
} else {
792815
hs_pop &= ~TWL4030_EXTMUTE;
@@ -2236,12 +2259,17 @@ static int twl4030_soc_probe(struct snd_soc_codec *codec)
22362259

22372260
static int twl4030_soc_remove(struct snd_soc_codec *codec)
22382261
{
2262+
struct twl4030_codec_data *pdata = dev_get_platdata(codec->dev);
22392263
struct twl4030_priv *twl4030 = snd_soc_codec_get_drvdata(codec);
22402264

22412265
/* Reset registers to their chip default before leaving */
22422266
twl4030_reset_registers(codec);
22432267
twl4030_set_bias_level(codec, SND_SOC_BIAS_OFF);
22442268
kfree(twl4030);
2269+
2270+
if (pdata && pdata->hs_extmute && gpio_is_valid(pdata->hs_extmute_gpio))
2271+
gpio_free(pdata->hs_extmute_gpio);
2272+
22452273
return 0;
22462274
}
22472275

0 commit comments

Comments
 (0)