diff --git a/sound/soc/codecs/wcd9330.c b/sound/soc/codecs/wcd9330.c index 385d0f9396be..cc500cad033d 100644 --- a/sound/soc/codecs/wcd9330.c +++ b/sound/soc/codecs/wcd9330.c @@ -7803,8 +7803,10 @@ int tomtom_hs_detect(struct snd_soc_codec *codec, snd_soc_update_bits(codec, TOMTOM_A_MICB_CFILT_2_CTL, 0x01, 0x00); tomtom->mbhc.mbhc_cfg = NULL; + tomtom->mbhc_started = false; rc = 0; } + wcd9xxx_clsh_post_init(&tomtom->clsh_d, tomtom->mbhc_started); return rc; } EXPORT_SYMBOL(tomtom_hs_detect); diff --git a/sound/soc/codecs/wcd9xxx-common.c b/sound/soc/codecs/wcd9xxx-common.c index b205754f2650..b21f88b72eed 100644 --- a/sound/soc/codecs/wcd9xxx-common.c +++ b/sound/soc/codecs/wcd9xxx-common.c @@ -1,4 +1,4 @@ -/* Copyright (c) 2013-2014, The Linux Foundation. All rights reserved. +/* Copyright (c) 2013-2015, The Linux Foundation. All rights reserved. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 and @@ -657,16 +657,29 @@ static void wcd9xxx_clsh_comp_req(struct snd_soc_codec *codec, return; } - if (on) - wcd9xxx_resmgr_add_cond_update_bits(clsh_d->resmgr, + if (on) { + if (clsh_d->mbhc_started) + wcd9xxx_resmgr_add_cond_update_bits( + clsh_d->resmgr, WCD9XXX_COND_HPH, WCD9XXX_A_CDC_CLSH_B1_CTL, shift, false); - else - wcd9xxx_resmgr_rm_cond_update_bits(clsh_d->resmgr, + else + snd_soc_update_bits(codec, + WCD9XXX_A_CDC_CLSH_B1_CTL, + 1 << shift, 1 << shift); + } else { + if (clsh_d->mbhc_started) + wcd9xxx_resmgr_rm_cond_update_bits( + clsh_d->resmgr, WCD9XXX_COND_HPH, WCD9XXX_A_CDC_CLSH_B1_CTL, shift, false); + else + snd_soc_update_bits(codec, + WCD9XXX_A_CDC_CLSH_B1_CTL, + 1 << shift, 0 << shift); + } } } @@ -1425,6 +1438,19 @@ void wcd9xxx_clsh_fsm(struct snd_soc_codec *codec, } EXPORT_SYMBOL_GPL(wcd9xxx_clsh_fsm); + +void wcd9xxx_clsh_post_init(struct wcd9xxx_clsh_cdc_data *clsh, + bool is_mbhc_started) +{ + if (!clsh) { + pr_err("%s: Class-H memory is NULL\n", __func__); + return; + } + + clsh->mbhc_started = is_mbhc_started; +} +EXPORT_SYMBOL(wcd9xxx_clsh_post_init); + void wcd9xxx_clsh_init(struct wcd9xxx_clsh_cdc_data *clsh, struct wcd9xxx_resmgr *resmgr) { @@ -1461,6 +1487,7 @@ void wcd9xxx_clsh_init(struct wcd9xxx_clsh_cdc_data *clsh, clsh_state_fp[WCD9XXX_CLSH_STATE_HPH_ST_EAR_LO] = wcd9xxx_clsh_state_hph_ear_lo; + clsh->mbhc_started = true; } EXPORT_SYMBOL_GPL(wcd9xxx_clsh_init); diff --git a/sound/soc/codecs/wcd9xxx-common.h b/sound/soc/codecs/wcd9xxx-common.h index 5c0c4a98f3fc..89c7283e6d61 100644 --- a/sound/soc/codecs/wcd9xxx-common.h +++ b/sound/soc/codecs/wcd9xxx-common.h @@ -1,4 +1,4 @@ -/* Copyright (c) 2013-2014, The Linux Foundation. All rights reserved. +/* Copyright (c) 2013-2015, The Linux Foundation. All rights reserved. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 and @@ -115,6 +115,7 @@ struct wcd9xxx_clsh_cdc_data { int buck_users; int ncp_users[NCP_FCLK_LEVEL_MAX]; struct wcd9xxx_resmgr *resmgr; + bool mbhc_started; }; struct wcd9xxx_anc_header { @@ -193,6 +194,9 @@ extern void wcd9xxx_clsh_init(struct wcd9xxx_clsh_cdc_data *clsh, extern void wcd9xxx_clsh_imped_config(struct snd_soc_codec *codec, int imped); +void wcd9xxx_clsh_post_init(struct wcd9xxx_clsh_cdc_data *clsh, + bool is_mbhc_started); + enum wcd9xxx_codec_event { WCD9XXX_CODEC_EVENT_CODEC_UP = 0, };