Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 318556e6 authored by Aditya Bavanari's avatar Aditya Bavanari
Browse files

dsp: voice: Vote for BMS power state during voice call



In PM8916, battery monitoring system(BMS) goes into a low power
state when APSS is suspended. This can cause loss of BMS accuracy,
if APSS goes to suspend during a voice call.
Fix this by setting BMS power state to high/low during start/end
of voice call.

CRs-Fixed: 2356600
Change-Id: I0c1ffedeca544f13805505311598dbdc311f5b90
Signed-off-by: default avatarAditya Bavanari <abavanar@codeaurora.org>
parent ff55cd46
Loading
Loading
Loading
Loading
+51 −0
Original line number Diff line number Diff line
@@ -141,6 +141,8 @@ static int voice_send_get_sound_focus_cmd(struct voice_data *v,
static int voice_send_get_source_tracking_cmd(struct voice_data *v,
			struct source_tracking_param *sourceTrackingData);

static void voice_vote_powerstate_to_bms(struct voice_data *v, bool state);

static void voice_itr_init(struct voice_session_itr *itr,
			   u32 session_id)
{
@@ -1949,6 +1951,47 @@ void voc_set_destroy_cvd_flag(bool is_destroy_cvd)
}
EXPORT_SYMBOL(voc_set_destroy_cvd_flag);

/**
 * voc_set_vote_bms_flag -
 *      set flag for BMS voting
 *
 * @is_destroy_cvd: bool value used to indicate
 *                  to vote for BMS or not in voice call.
 *
 */
void voc_set_vote_bms_flag(bool is_vote_bms)
{
	pr_debug("%s: flag value: %d\n", __func__, is_vote_bms);
	common.is_vote_bms = is_vote_bms;
}
EXPORT_SYMBOL(voc_set_vote_bms_flag);

static void voice_vote_powerstate_to_bms(struct voice_data *v, bool state)
{
	union power_supply_propval psp_val;

	if (!v->psy)
		v->psy = power_supply_get_by_name("bms");

	psp_val.intval = VMBMS_VOICE_CALL_BIT;
	if (v->psy && !(is_voip_session(v->session_id) ||
			is_vowlan_session(v->session_id))) {
		if (state) {
			pr_debug("%s : Vote High power to BMS\n",
				__func__);
			power_supply_set_property(v->psy,
					POWER_SUPPLY_PROP_HI_POWER, &psp_val);
		} else {
			pr_debug("%s: Vote low power to BMS\n",
				__func__);
			power_supply_set_property(v->psy,
					POWER_SUPPLY_PROP_LOW_POWER, &psp_val);
		}
	} else {
		pr_debug("%s: No OP", __func__);
	}
}

/**
 * voc_alloc_cal_shared_memory -
 *       Alloc mem map table for calibration
@@ -2422,6 +2465,10 @@ static int voice_send_start_voice_cmd(struct voice_data *v)
				v->async_err);
		goto fail;
	}
	if (common.is_vote_bms) {
		/* vote high power to BMS during call start */
		voice_vote_powerstate_to_bms(v, true);
	}
	return 0;
fail:
	return ret;
@@ -6873,6 +6920,10 @@ int voc_end_voice_call(uint32_t session_id)

		voice_destroy_mvm_cvs_session(v);
		v->voc_state = VOC_RELEASE;
		if (common.is_vote_bms) {
			/* vote low power to BMS during call stop */
			voice_vote_powerstate_to_bms(v, false);
		}
	} else {
		pr_err("%s: Error: End voice called in state %d\n",
			__func__, v->voc_state);
+6 −0
Original line number Diff line number Diff line
@@ -13,6 +13,8 @@
#define __QDSP6VOICE_H__

#include <linux/msm_ion.h>
#include <linux/power_supply.h>
#include <uapi/linux/vm_bms.h>
#include <sound/voice_params.h>
#include <dsp/rtac.h>
#include <dsp/q6core.h>
@@ -1916,6 +1918,8 @@ struct voice_data {

	bool mic_break_status;
	struct work_struct voice_mic_break_work;

	struct power_supply *psy;
};

struct cal_mem {
@@ -1980,6 +1984,7 @@ struct common_data {
	bool sidetone_enable;
	bool mic_break_enable;
	struct audio_uevent_data *uevent_data;
	bool is_vote_bms;
};

struct voice_session_itr {
@@ -2107,6 +2112,7 @@ int voc_update_amr_vocoder_rate(uint32_t session_id);
int voc_disable_device(uint32_t session_id);
int voc_enable_device(uint32_t session_id);
void voc_set_destroy_cvd_flag(bool is_destroy_cvd);
void voc_set_vote_bms_flag(bool is_vote_bms);
int voc_disable_topology(uint32_t session_id, uint32_t disable);
int voc_set_device_config(uint32_t session_id, uint8_t path_dir,
			  struct media_format_info *finfo);