ASoC: wcd9310: fix TRRS override
The debugfs TRRS entry is for overriding headset button polling.
Fix regression not to start button polling when this flag is set.
CRs-fixed: 386038
Change-Id: I469c366bc111f37ecbb46708d2800200dd3d7584
Signed-off-by: Joonwoo Park <joonwoop@codeaurora.org>
diff --git a/sound/soc/codecs/wcd9310.c b/sound/soc/codecs/wcd9310.c
index 706963d..4758829 100644
--- a/sound/soc/codecs/wcd9310.c
+++ b/sound/soc/codecs/wcd9310.c
@@ -2244,26 +2244,26 @@
}
snd_soc_write(codec, TABLA_A_MBHC_SCALING_MUX_1, 0x84);
- if (!tabla->no_mic_headset_override) {
- if (mbhc_state == MBHC_STATE_POTENTIAL) {
- pr_debug("%s recovering MBHC state macine\n", __func__);
- tabla->mbhc_state = MBHC_STATE_POTENTIAL_RECOVERY;
- /* set to max button press threshold */
- snd_soc_write(codec, TABLA_A_CDC_MBHC_VOLT_B2_CTL,
- 0x7F);
- snd_soc_write(codec, TABLA_A_CDC_MBHC_VOLT_B1_CTL,
- 0xFF);
- snd_soc_write(codec, TABLA_A_CDC_MBHC_VOLT_B4_CTL,
- (TABLA_IS_1_X(tabla_core->version) ?
- 0x07 : 0x7F));
- snd_soc_write(codec, TABLA_A_CDC_MBHC_VOLT_B3_CTL,
- 0xFF);
- /* set to max */
- snd_soc_write(codec, TABLA_A_CDC_MBHC_VOLT_B6_CTL,
- 0x7F);
- snd_soc_write(codec, TABLA_A_CDC_MBHC_VOLT_B5_CTL,
- 0xFF);
- }
+ if (tabla->no_mic_headset_override) {
+ pr_debug("%s setting button threshold to min", __func__);
+ /* set to min */
+ snd_soc_write(codec, TABLA_A_CDC_MBHC_VOLT_B4_CTL, 0x80);
+ snd_soc_write(codec, TABLA_A_CDC_MBHC_VOLT_B3_CTL, 0x00);
+ snd_soc_write(codec, TABLA_A_CDC_MBHC_VOLT_B6_CTL, 0x80);
+ snd_soc_write(codec, TABLA_A_CDC_MBHC_VOLT_B5_CTL, 0x00);
+ } else if (unlikely(mbhc_state == MBHC_STATE_POTENTIAL)) {
+ pr_debug("%s recovering MBHC state machine\n", __func__);
+ tabla->mbhc_state = MBHC_STATE_POTENTIAL_RECOVERY;
+ /* set to max button press threshold */
+ snd_soc_write(codec, TABLA_A_CDC_MBHC_VOLT_B2_CTL, 0x7F);
+ snd_soc_write(codec, TABLA_A_CDC_MBHC_VOLT_B1_CTL, 0xFF);
+ snd_soc_write(codec, TABLA_A_CDC_MBHC_VOLT_B4_CTL,
+ (TABLA_IS_1_X(tabla_core->version) ?
+ 0x07 : 0x7F));
+ snd_soc_write(codec, TABLA_A_CDC_MBHC_VOLT_B3_CTL, 0xFF);
+ /* set to max */
+ snd_soc_write(codec, TABLA_A_CDC_MBHC_VOLT_B6_CTL, 0x7F);
+ snd_soc_write(codec, TABLA_A_CDC_MBHC_VOLT_B5_CTL, 0xFF);
}
snd_soc_write(codec, TABLA_A_CDC_MBHC_EN_CTL, 0x1);
@@ -7782,9 +7782,15 @@
lbuf[cnt] = '\0';
buf = (char *)lbuf;
- tabla->no_mic_headset_override = (*strsep(&buf, " ") == '0') ?
- false : true;
- return rc;
+ TABLA_ACQUIRE_LOCK(tabla->codec_resource_lock);
+ tabla->no_mic_headset_override =
+ (*strsep(&buf, " ") == '0') ? false : true;
+ if (tabla->no_mic_headset_override && tabla->mbhc_polling_active) {
+ tabla_codec_pause_hs_polling(tabla->codec);
+ tabla_codec_start_hs_polling(tabla->codec);
+ }
+ TABLA_RELEASE_LOCK(tabla->codec_resource_lock);
+ return cnt;
}
static ssize_t codec_mbhc_debug_read(struct file *file, char __user *buf,