From 5a79ff4cba1b982a16454db013a949183eec079a Mon Sep 17 00:00:00 2001 From: Sugar Zhang Date: Tue, 21 Apr 2015 10:12:24 +0800 Subject: [PATCH] es8316: fix spk no sound. Signed-off-by: Sugar Zhang --- sound/soc/codecs/es8316.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/sound/soc/codecs/es8316.c b/sound/soc/codecs/es8316.c index e6f982691b2a..f0d5f151223c 100644 --- a/sound/soc/codecs/es8316.c +++ b/sound/soc/codecs/es8316.c @@ -159,7 +159,7 @@ static irqreturn_t hp_det_irq_handler(int irq, void *dev_id) return -1; } - if (type == IRQ_TYPE_EDGE_FALLING) + if (es8316->hp_det_level != gpio_get_value(es8316->hp_det_gpio)) hp_irq_flag = 0; else hp_irq_flag = 1; @@ -1202,6 +1202,7 @@ static int es8316_i2c_probe(struct i2c_client *i2c_client, int ret = -1; unsigned long irq_flag = 0; int hp_irq = 0; + int val = 0; enum of_gpio_flags flags; struct device_node *np = i2c_client->dev.of_node; @@ -1257,6 +1258,14 @@ static int es8316_i2c_probe(struct i2c_client *i2c_client, irq_flag = IRQF_TRIGGER_LOW | IRQF_ONESHOT; hp_irq = gpio_to_irq(es8316->hp_det_gpio); + val = gpio_get_value(es8316->hp_det_gpio); + if (val == es8316->hp_det_level) { + pr_info("hp inserted.\n"); + hp_irq_flag = 1; + es8316_set_gpio(ES8316_CODEC_SET_SPK, + !es8316->spk_gpio_level); + } + if (hp_irq) ret = request_threaded_irq(hp_irq, NULL, hp_det_irq_handler, irq_flag, "ES8316", NULL); -- 2.34.1