-
Notifications
You must be signed in to change notification settings - Fork 0
/
oldjackfix.patch
469 lines (440 loc) · 17 KB
/
oldjackfix.patch
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
From dfbd7e8c75c1c48b092167a052a0548f62a38407 Mon Sep 17 00:00:00 2001
From: psndna88 <psndna88@gmail.com>
Date: Mon, 23 Oct 2017 21:15:04 +0530
Subject: [PATCH] wcd-mbhc-v2: fix jack detection issues and unwanted music
resume on removal
- fix wrong logic for reporting button press to software interrupt handler
- include fixes from SONY 3.18 wcd-mbhc-v2 driver
- add debugging tunables for testing and tuned driver variables for faster detection
Signed-off-by: psndna88 <psndna88@gmail.com>
Signed-off-by: AmolAmrit <amol.amrit03@outlook.com>
---
AnyKernel3/anykernel.sh | 2 +-
build.sh | 2 +-
sound/soc/codecs/wcd-mbhc-v2.c | 168 ++++++++++++++++++++++++---------
sound/soc/codecs/wcd-mbhc-v2.h | 3 +-
4 files changed, 128 insertions(+), 47 deletions(-)
diff --git a/AnyKernel3/anykernel.sh b/AnyKernel3/anykernel.sh
index 654ab2df7fca..0f8e9fe0b828 100755
--- a/AnyKernel3/anykernel.sh
+++ b/AnyKernel3/anykernel.sh
@@ -4,7 +4,7 @@
## AnyKernel setup
# begin properties
properties() { '
-kernel.string=Escrima-X28-Kamui-LightningBlade-PurpleLightning
+kernel.string=Escrima-X28-Kamui-LightningBlade-PurpleLightning-OldJackFix
do.devicecheck=1
do.modules=0
do.cleanup=1
diff --git a/build.sh b/build.sh
index 5a155859a845..1764de80eec3 100644
--- a/build.sh
+++ b/build.sh
@@ -2,7 +2,7 @@ KERNEL_DIR=$PWD
Anykernel_DIR=$KERNEL_DIR/AnyKernel3/
DATE=$(date +"%d%m%Y")
TIME=$(date +"-%H.%M.%S")
-KERNEL_NAME="Escrima-X28-Kamui-LightningBlade-PurpleLightning"
+KERNEL_NAME="Escrima-X28-Kamui-LightningBlade-PurpleLightning-OldJackFix"
DEVICE="-kenzo-"
FINAL_ZIP="$KERNEL_NAME""$DEVICE""$DATE""$TIME"
diff --git a/sound/soc/codecs/wcd-mbhc-v2.c b/sound/soc/codecs/wcd-mbhc-v2.c
index 46033079347e..bad91d899a60 100644
--- a/sound/soc/codecs/wcd-mbhc-v2.c
+++ b/sound/soc/codecs/wcd-mbhc-v2.c
@@ -27,6 +27,8 @@
#include <linux/firmware.h>
#include <linux/completion.h>
#include <glink_private.h>
+#include <linux/switch.h>
+#include <linux/moduleparam.h>
#include <sound/soc.h>
#include <sound/jack.h>
#include "wcd-mbhc-v2.h"
@@ -42,20 +44,12 @@
SND_JACK_BTN_4 | SND_JACK_BTN_5 | \
SND_JACK_BTN_6 | SND_JACK_BTN_7)
#define OCP_ATTEMPT 1
-#define HS_DETECT_PLUG_TIME_MS (3 * 1000)
-#define SPECIAL_HS_DETECT_TIME_MS (2 * 1000)
-#define MBHC_BUTTON_PRESS_THRESHOLD_MIN 250
#define GND_MIC_SWAP_THRESHOLD 4
-#define WCD_FAKE_REMOVAL_MIN_PERIOD_MS 100
#define HS_VREF_MIN_VAL 1400
#define FW_READ_ATTEMPTS 15
#define FW_READ_TIMEOUT 4000000
-#define FAKE_REM_RETRY_ATTEMPTS 3
-#define MAX_IMPED 60000
-#define WCD_MBHC_BTN_PRESS_COMPL_TIMEOUT_MS 50
#define ANC_DETECT_RETRY_CNT 7
-#define WCD_MBHC_SPL_HS_CNT 1
/* ASUS_BSP Paul +++ */
int g_jack_det_invert = 0;
@@ -72,6 +66,22 @@ module_param(det_extn_cable_en, int,
S_IRUGO | S_IWUSR | S_IWGRP);
MODULE_PARM_DESC(det_extn_cable_en, "enable/disable extn cable detect");
+/* AGNi Audio Jack Testing & Debuging (psndna88@gmail.com) */
+int hs_detect_plug_time_ms = (1 * 1000);
+int special_hs_detect_time_ms = (2 * 1000);
+int mbhc_button_press_threshold_min = 250;
+int wcd_fake_removal_min_period_ms = 100;
+int fake_rem_retry_attempts = 10;
+int wcd_mbhc_spl_hs_cnt = 1;
+int wcd_mbhc_btn_press_compl_timeout_ms = 50;
+module_param_named(hs_detect_plug_time_ms, hs_detect_plug_time_ms, int, 0664);
+module_param_named(mbhc_button_press_threshold_min_ms, mbhc_button_press_threshold_min, int, 0664);
+module_param_named(wcd_fake_removal_min_period_ms, wcd_fake_removal_min_period_ms, int, 0664);
+module_param_named(fake_remove_retry_attempts, fake_rem_retry_attempts, int, 0664);
+module_param_named(special_hs_detect_time_ms, special_hs_detect_time_ms, int, 0664);
+module_param_named(wcd_mbhc_spl_hs_cnt, wcd_mbhc_spl_hs_cnt, int, 0664);
+module_param_named(wcd_mbhc_btn_press_compl_timeout_ms, wcd_mbhc_btn_press_compl_timeout_ms, int, 0664);
+
enum wcd_mbhc_cs_mb_en_flag {
WCD_MBHC_EN_CS = 0,
WCD_MBHC_EN_MB,
@@ -79,6 +89,10 @@ enum wcd_mbhc_cs_mb_en_flag {
WCD_MBHC_EN_NONE,
};
+static bool skip_impdet_retry;
+static bool lineout_detected;
+
+
static void wcd_mbhc_jack_report(struct wcd_mbhc *mbhc,
struct snd_soc_jack *jack, int status, int mask)
{
@@ -542,6 +556,8 @@ static void wcd_mbhc_hs_elec_irq(struct wcd_mbhc *mbhc, int irq_type,
static void wcd_mbhc_report_plug(struct wcd_mbhc *mbhc, int insertion,
enum snd_jack_types jack_type)
{
+ bool skip_report = false;
+
WCD_MBHC_RSC_ASSERT_LOCKED(mbhc);
pr_debug("%s: enter insertion %d hph_status %x\n",
@@ -573,12 +589,19 @@ static void wcd_mbhc_report_plug(struct wcd_mbhc *mbhc, int insertion,
mbhc->mbhc_cb->mbhc_micb_ctrl_thr_mic(
mbhc->codec,
MIC_BIAS_2, false);
+ if (mbhc->mbhc_cb->set_micbias_value) {
+ mbhc->mbhc_cb->set_micbias_value(mbhc->codec);
+ WCD_MBHC_REG_UPDATE_BITS(WCD_MBHC_MICB_CTRL, 0);
+ }
mbhc->micbias_enable = false;
}
mbhc->hph_type = WCD_MBHC_HPH_NONE;
- mbhc->zl = mbhc->zr = 0;
- pr_debug("%s: Reporting removal %d(%x)\n", __func__,
+ mbhc->extn_cable_inserted = false;
+ lineout_detected = false;
+ if (!skip_impdet_retry)
+ mbhc->zl = mbhc->zr = 0;
+ pr_info("%s: Reporting removal %d(%x)\n", __func__,
jack_type, mbhc->hph_status);
wcd_mbhc_jack_report(mbhc, &mbhc->headset_jack,
mbhc->hph_status, WCD_MBHC_JACK_MASK);
@@ -606,10 +629,18 @@ static void wcd_mbhc_report_plug(struct wcd_mbhc *mbhc, int insertion,
mbhc->mbhc_cb->mbhc_micb_ctrl_thr_mic(
mbhc->codec,
MIC_BIAS_2, false);
+ if (mbhc->mbhc_cb->set_micbias_value) {
+ mbhc->mbhc_cb->set_micbias_value(
+ mbhc->codec);
+ WCD_MBHC_REG_UPDATE_BITS(
+ WCD_MBHC_MICB_CTRL, 0);
+ }
mbhc->micbias_enable = false;
}
mbhc->hph_type = WCD_MBHC_HPH_NONE;
- mbhc->zl = mbhc->zr = 0;
+ lineout_detected = false;
+ if (!skip_impdet_retry)
+ mbhc->zl = mbhc->zr = 0;
pr_debug("%s: Reporting removal (%x)\n",
__func__, mbhc->hph_status);
wcd_mbhc_jack_report(mbhc, &mbhc->headset_jack,
@@ -650,12 +681,16 @@ static void wcd_mbhc_report_plug(struct wcd_mbhc *mbhc, int insertion,
mbhc->jiffies_atreport = jiffies;
} else if (jack_type == SND_JACK_LINEOUT) {
mbhc->current_plug = MBHC_PLUG_TYPE_HIGH_HPH;
+ skip_report = true;
+ pr_info("%s: extension cable detected\n", __func__);
} else if (jack_type == SND_JACK_ANC_HEADPHONE)
mbhc->current_plug = MBHC_PLUG_TYPE_ANC_HEADPHONE;
if (mbhc->impedance_detect &&
mbhc->mbhc_cb->compute_impedance &&
- (mbhc->mbhc_cfg->linein_th != 0)) {
+ (mbhc->mbhc_cfg->linein_th != 0) &&
+ (mbhc->mbhc_cb->hph_pa_on_status(mbhc->codec) == false)) {
+ if (!skip_impdet_retry) {
mbhc->mbhc_cb->compute_impedance(mbhc,
&mbhc->zl, &mbhc->zr);
/* ASUS_BSP Eric +++*/
@@ -664,14 +699,32 @@ static void wcd_mbhc_report_plug(struct wcd_mbhc *mbhc, int insertion,
printk("wcd_mbhc_v2 : print hs_imp_val : LL = %d , RR = %d\n",g_ZL, g_ZR);
/* ASUS_BSP Eric ---*/
- if ((mbhc->zl > mbhc->mbhc_cfg->linein_th &&
- mbhc->zl < MAX_IMPED) &&
- (mbhc->zr > mbhc->mbhc_cfg->linein_th &&
- mbhc->zr < MAX_IMPED) &&
- (jack_type == SND_JACK_HEADPHONE)) {
- jack_type = SND_JACK_LINEOUT;
+ pr_info("%s: impedance L:%d R:%d\n", __func__,
+ mbhc->zl, mbhc->zr);
+ } else {
+ pr_debug("%s: skip impedance detection\n",
+ __func__);
+ }
+
+ if (jack_type == SND_JACK_HEADPHONE)
+ skip_impdet_retry = true;
+ else
+ skip_impdet_retry = false;
+
+ if (mbhc->zl > mbhc->mbhc_cfg->linein_th &&
+ jack_type == SND_JACK_ANC_HEADPHONE) {
+ if(!wcd_mbhc_is_hph_pa_on(mbhc)) {
+ pr_debug("%s: Skip Stereo microphone reporting\n",
+ __func__);
+ }
+ } else if (mbhc->zl > mbhc->mbhc_cfg->linein_th &&
+ mbhc->zr > mbhc->mbhc_cfg->linein_th &&
+ jack_type == SND_JACK_HEADPHONE) {
+ jack_type = SND_JACK_LINEOUT;
mbhc->current_plug = MBHC_PLUG_TYPE_HIGH_HPH;
- if (mbhc->hph_status) {
+ lineout_detected = true;
+ if (mbhc->hph_status &&
+ mbhc->hph_status != SND_JACK_LINEOUT) {
mbhc->hph_status &= ~(SND_JACK_HEADSET |
SND_JACK_LINEOUT |
SND_JACK_UNSUPPORTED);
@@ -687,11 +740,16 @@ static void wcd_mbhc_report_plug(struct wcd_mbhc *mbhc, int insertion,
mbhc->hph_status |= jack_type;
- pr_debug("%s: Reporting insertion %d(%x)\n", __func__,
- jack_type, mbhc->hph_status);
- wcd_mbhc_jack_report(mbhc, &mbhc->headset_jack,
- (mbhc->hph_status | SND_JACK_MECHANICAL),
- WCD_MBHC_JACK_MASK);
+ if (!skip_report) {
+ pr_info("%s: Reporting insertion %d(%x)\n", __func__,
+ jack_type, mbhc->hph_status);
+ wcd_mbhc_jack_report(mbhc, &mbhc->headset_jack,
+ (mbhc->hph_status |
+ SND_JACK_MECHANICAL),
+ WCD_MBHC_JACK_MASK);
+ } else {
+ pr_debug("%s: Skip reporting insertion\n", __func__);
+ }
wcd_mbhc_clr_and_turnon_hph_padac(mbhc);
}
pr_debug("%s: leave hph_status %x\n", __func__, mbhc->hph_status);
@@ -972,7 +1030,7 @@ static bool wcd_is_special_headset(struct wcd_mbhc *mbhc)
__func__, (delay * 2));
is_spl_hs = true;
}
- if (delay == SPECIAL_HS_DETECT_TIME_MS) {
+ if (delay == special_hs_detect_time_ms) {
pr_debug("%s: Spl headset didnt get detect in 4 sec\n",
__func__);
break;
@@ -1096,7 +1154,7 @@ static bool wcd_mbhc_check_for_spl_headset(struct wcd_mbhc *mbhc,
*spl_hs_cnt += 1;
/* MB2 back to 1.8v */
- if (*spl_hs_cnt != WCD_MBHC_SPL_HS_CNT) {
+ if (*spl_hs_cnt != wcd_mbhc_spl_hs_cnt) {
mbhc->mbhc_cb->mbhc_micb_ctrl_thr_mic(mbhc->codec,
mbhc->mbhc_cfg->mbhc_micbias, false);
WCD_MBHC_REG_UPDATE_BITS(WCD_MBHC_FSM_EN, 0);
@@ -1134,6 +1192,10 @@ static void wcd_correct_swch_plug(struct work_struct *work)
mbhc = container_of(work, struct wcd_mbhc, correct_plug_swch);
codec = mbhc->codec;
+ /* Wait for debounce time 200ms for extension cable */
+ if (mbhc->extn_cable_inserted)
+ msleep(200);
+
/*
* Enable micbias/pullup for detection in correct work.
* This work will get scheduled from detect_plug_type which
@@ -1152,7 +1214,7 @@ static void wcd_correct_swch_plug(struct work_struct *work)
* loop.
*/
rc = wait_for_completion_timeout(&mbhc->btn_press_compl,
- msecs_to_jiffies(WCD_MBHC_BTN_PRESS_COMPL_TIMEOUT_MS));
+ msecs_to_jiffies(wcd_mbhc_btn_press_compl_timeout_ms));
WCD_MBHC_REG_READ(WCD_MBHC_BTN_RESULT, btn_result);
WCD_MBHC_REG_READ(WCD_MBHC_HS_COMP_RESULT, hs_comp_res);
@@ -1192,7 +1254,7 @@ static void wcd_correct_swch_plug(struct work_struct *work)
if ((plug_type == MBHC_PLUG_TYPE_HEADSET ||
plug_type == MBHC_PLUG_TYPE_HEADPHONE) &&
(!wcd_swch_level_remove(mbhc)) &&
- (!mbhc->btn_press_intr)) {
+ (!mbhc->btn_press_intr)) { // AGNi Testing
WCD_MBHC_RSC_LOCK(mbhc);
wcd_mbhc_find_plug_and_report(mbhc, plug_type);
WCD_MBHC_RSC_UNLOCK(mbhc);
@@ -1200,7 +1262,7 @@ static void wcd_correct_swch_plug(struct work_struct *work)
correct_plug_type:
- timeout = jiffies + msecs_to_jiffies(HS_DETECT_PLUG_TIME_MS);
+ timeout = jiffies + msecs_to_jiffies(hs_detect_plug_time_ms);
while (!time_after(jiffies, timeout)) {
if (mbhc->hs_detect_work_stop) {
pr_debug("%s: stop requested: %d\n", __func__,
@@ -1247,11 +1309,12 @@ static void wcd_correct_swch_plug(struct work_struct *work)
* sometime and re-check stop request again.
*/
msleep(180);
- if (hs_comp_res && (spl_hs_count < WCD_MBHC_SPL_HS_CNT)) {
+ if (hs_comp_res && (spl_hs_count < wcd_mbhc_spl_hs_cnt)) {
+
spl_hs = wcd_mbhc_check_for_spl_headset(mbhc,
&spl_hs_count);
- if (spl_hs_count == WCD_MBHC_SPL_HS_CNT) {
+ if (spl_hs_count == wcd_mbhc_spl_hs_cnt) {
hs_comp_res = 0;
spl_hs = true;
mbhc->micbias_enable = true;
@@ -1288,7 +1351,7 @@ static void wcd_correct_swch_plug(struct work_struct *work)
plug_type = MBHC_PLUG_TYPE_HEADSET;
if ((no_gnd_mic_swap_cnt <
GND_MIC_SWAP_THRESHOLD) &&
- (spl_hs_count != WCD_MBHC_SPL_HS_CNT)) {
+ (spl_hs_count != wcd_mbhc_spl_hs_cnt)) {
continue;
} else {
no_gnd_mic_swap_cnt = 0;
@@ -1329,11 +1392,12 @@ static void wcd_correct_swch_plug(struct work_struct *work)
MBHC_PLUG_TYPE_HEADSET) &&
(mbhc->current_plug !=
MBHC_PLUG_TYPE_ANC_HEADPHONE)) &&
+ !wcd_swch_level_remove(mbhc) &&
!mbhc->btn_press_intr) {
pr_debug("%s: cable is %sheadset\n",
__func__,
((spl_hs_count ==
- WCD_MBHC_SPL_HS_CNT) ?
+ wcd_mbhc_spl_hs_cnt) ?
"special ":""));
goto report;
}
@@ -1344,7 +1408,10 @@ static void wcd_correct_swch_plug(struct work_struct *work)
if (!wrk_complete && mbhc->btn_press_intr) {
pr_debug("%s: Can be slow insertion of headphone\n", __func__);
wcd_cancel_btn_work(mbhc);
- plug_type = MBHC_PLUG_TYPE_HEADPHONE;
+ if (lineout_detected)
+ plug_type = MBHC_PLUG_TYPE_HIGH_HPH;
+ else
+ plug_type = MBHC_PLUG_TYPE_HEADPHONE;
}
/*
* If plug_tye is headset, we might have already reported either in
@@ -1358,7 +1425,7 @@ static void wcd_correct_swch_plug(struct work_struct *work)
}
if (plug_type == MBHC_PLUG_TYPE_HIGH_HPH &&
- (!det_extn_cable_en)) {
+ (!det_extn_cable_en) && (!lineout_detected)) {
if (wcd_is_special_headset(mbhc)) {
pr_debug("%s: Special headset found %d\n",
__func__, plug_type);
@@ -1403,6 +1470,8 @@ static void wcd_correct_swch_plug(struct work_struct *work)
if (mbhc->mbhc_cb->hph_pull_down_ctrl)
mbhc->mbhc_cb->hph_pull_down_ctrl(codec, true);
+ skip_impdet_retry = false;
+
mbhc->mbhc_cb->lock_sleep(mbhc, false);
pr_debug("%s: leave\n", __func__);
}
@@ -1519,12 +1588,11 @@ static void wcd_mbhc_swch_irq_handler(struct wcd_mbhc *mbhc)
mbhc->btn_press_intr = false;
if (mbhc->current_plug == MBHC_PLUG_TYPE_HEADPHONE) {
- wcd_mbhc_hs_elec_irq(mbhc, WCD_MBHC_ELEC_HS_REM,
- false);
- wcd_mbhc_hs_elec_irq(mbhc, WCD_MBHC_ELEC_HS_INS,
- false);
- WCD_MBHC_REG_UPDATE_BITS(WCD_MBHC_ELECT_DETECTION_TYPE,
- 1);
+
+ wcd_mbhc_hs_elec_irq(mbhc, WCD_MBHC_ELEC_HS_REM, false);
+ wcd_mbhc_hs_elec_irq(mbhc, WCD_MBHC_ELEC_HS_INS, false);
+ WCD_MBHC_REG_UPDATE_BITS(WCD_MBHC_ELECT_DETECTION_TYPE, 1);
+
WCD_MBHC_REG_UPDATE_BITS(WCD_MBHC_ELECT_SCHMT_ISRC, 0);
wcd_mbhc_report_plug(mbhc, 0, SND_JACK_HEADPHONE);
} else if (mbhc->current_plug == MBHC_PLUG_TYPE_GND_MIC_SWAP) {
@@ -1755,6 +1823,7 @@ static irqreturn_t wcd_mbhc_hs_ins_irq(int irq, void *data)
hphl_trigerred = 0;
mic_trigerred = 0;
mbhc->is_extn_cable = true;
+ mbhc->extn_cable_inserted = true;
mbhc->btn_press_intr = false;
wcd_mbhc_detect_plug_type(mbhc);
WCD_MBHC_RSC_UNLOCK(mbhc);
@@ -1777,7 +1846,7 @@ static irqreturn_t wcd_mbhc_hs_rem_irq(int irq, void *data)
WCD_MBHC_RSC_LOCK(mbhc);
timeout = jiffies +
- msecs_to_jiffies(WCD_FAKE_REMOVAL_MIN_PERIOD_MS);
+ msecs_to_jiffies(wcd_fake_removal_min_period_ms);
do {
retry++;
/*
@@ -1789,7 +1858,7 @@ static irqreturn_t wcd_mbhc_hs_rem_irq(int irq, void *data)
pr_debug("%s: Check result reg for fake removal: hs_comp_res %x\n",
__func__, hs_comp_result);
if ((!hs_comp_result) &&
- retry > FAKE_REM_RETRY_ATTEMPTS) {
+ retry > fake_rem_retry_attempts) {
removed = false;
break;
}
@@ -1943,9 +2012,16 @@ static irqreturn_t wcd_mbhc_btn_press_handler(int irq, void *data)
msec_val = jiffies_to_msecs(jiffies - mbhc->jiffies_atreport);
pr_debug("%s: msec_val = %ld\n", __func__, msec_val);
- if (msec_val < MBHC_BUTTON_PRESS_THRESHOLD_MIN) {
+ if (msec_val < mbhc_button_press_threshold_min) {
pr_debug("%s: Too short, ignore button press\n", __func__);
goto done;
+ } else {
+ /* send event to sw intr handler
+ *
+ * Fixes unwanted music playback resume on removal of earphone
+ * AGNi (psndna88@gmail.com)
+ */
+ mbhc->is_btn_press = true;
}
/* If switch interrupt already kicked in, ignore button press */
@@ -2125,6 +2201,9 @@ static int wcd_mbhc_initialise(struct wcd_mbhc *mbhc)
/* Button Debounce set to 16ms */
WCD_MBHC_REG_UPDATE_BITS(WCD_MBHC_BTN_DBNC, 2);
+ /* Enable micbias ramp */
+ if (mbhc->mbhc_cb->mbhc_micb_ramp_control)
+ mbhc->mbhc_cb->mbhc_micb_ramp_control(codec, true);
/* enable bias */
mbhc->mbhc_cb->mbhc_bias(codec, true);
/* enable MBHC clock */
@@ -2392,6 +2471,7 @@ int wcd_mbhc_init(struct wcd_mbhc *mbhc, struct snd_soc_codec *codec,
mbhc->btn_press_intr = false;
mbhc->is_hs_recording = false;
mbhc->is_extn_cable = false;
+ mbhc->extn_cable_inserted = false;
mbhc->hph_type = WCD_MBHC_HPH_NONE;
mbhc->wcd_mbhc_regs = wcd_mbhc_regs;
diff --git a/sound/soc/codecs/wcd-mbhc-v2.h b/sound/soc/codecs/wcd-mbhc-v2.h
index be1e38090ff4..fdbb21db9faf 100644
--- a/sound/soc/codecs/wcd-mbhc-v2.h
+++ b/sound/soc/codecs/wcd-mbhc-v2.h
@@ -21,7 +21,7 @@
#define WCD_MBHC_DEF_BUTTONS 8
#define WCD_MBHC_KEYCODE_NUM 8
#define WCD_MBHC_USLEEP_RANGE_MARGIN_US 100
-#define WCD_MBHC_THR_HS_MICB_MV 2700
+#define WCD_MBHC_THR_HS_MICB_MV 2450
/* z value defined in Ohms */
#define WCD_MONO_HS_MIN_THR 2
#define WCD_MBHC_STRINGIFY(s) __stringify(s)
@@ -390,6 +390,7 @@ struct wcd_mbhc {
bool btn_press_intr;
bool is_hs_recording;
bool is_extn_cable;
+ bool extn_cable_inserted;
bool skip_imped_detection;
bool is_btn_already_regd;