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

Commit 772b1d25 authored by Linux Build Service Account's avatar Linux Build Service Account Committed by Gerrit - the friendly Code Review server
Browse files

Merge "ASoC: msm: qdsp6v2: add support for dynamic TTY mode change"

parents b0178b91 1b14f7f4
Loading
Loading
Loading
Loading
+4 −4
Original line number Diff line number Diff line
@@ -699,9 +699,9 @@ static void msm_pcm_routing_process_voice(u16 reg, u16 val, int set)

			if (voc_get_route_flag(session_id, RX_PATH) &&
			   voc_get_route_flag(session_id, TX_PATH))
				voc_enable_cvp(session_id);
				voc_enable_device(session_id);
		} else {
			voc_disable_cvp(session_id);
			voc_disable_device(session_id);
		}
	} else {
		voc_set_route_flag(session_id, TX_PATH, set);
@@ -710,9 +710,9 @@ static void msm_pcm_routing_process_voice(u16 reg, u16 val, int set)
				msm_bedais[reg].port_id, DEV_TX);
			if (voc_get_route_flag(session_id, RX_PATH) &&
			   voc_get_route_flag(session_id, TX_PATH))
				voc_enable_cvp(session_id);
				voc_enable_device(session_id);
		} else {
			voc_disable_cvp(session_id);
			voc_disable_device(session_id);
		}
	}
}
+142 −41
Original line number Diff line number Diff line
@@ -94,6 +94,8 @@ static int voice_free_oob_shared_mem(void);
static int voice_alloc_oob_mem_table(void);
static int voice_alloc_and_map_cal_mem(struct voice_data *v);
static int voice_alloc_and_map_oob_mem(struct voice_data *v);
static int voc_disable_cvp(uint32_t session_id);
static int voc_enable_cvp(uint32_t session_id);

static struct voice_data *voice_get_session_by_idx(int idx);

@@ -1089,7 +1091,6 @@ static int voice_send_tty_mode_cmd(struct voice_data *v)
	}
	mvm_handle = voice_get_mvm_handle(v);

	if (v->tty_mode) {
	/* send tty mode cmd to mvm */
	mvm_tty_mode_cmd.hdr.hdr_field = APR_HDR_FIELD(
					APR_MSG_TYPE_SEQ_CMD,
@@ -1122,7 +1123,6 @@ static int voice_send_tty_mode_cmd(struct voice_data *v)
		pr_err("%s: wait_event timeout\n", __func__);
		goto fail;
	}
	}
	return 0;
fail:
	return -EINVAL;
@@ -3156,8 +3156,7 @@ static int voice_setup_vocproc(struct voice_data *v)
		voice_send_netid_timing_cmd(v);
	}

	/* enable slowtalk if st_enable is set */
	if (v->st_enable)
	if (v->st_enable && !v->tty_mode)
		voice_send_set_pp_enable_cmd(v,
					     MODULE_ID_VOICE_MODULE_ST,
					     v->st_enable);
@@ -4369,7 +4368,7 @@ int voc_start_playback(uint32_t set, uint16_t port_id)
	return ret;
}

int voc_disable_cvp(uint32_t session_id)
static int voc_disable_cvp(uint32_t session_id)
{
	struct voice_data *v = voice_get_session(session_id);
	int ret = 0;
@@ -4404,7 +4403,7 @@ fail: mutex_unlock(&v->lock);
	return ret;
}

int voc_enable_cvp(uint32_t session_id)
static int voc_enable_cvp(uint32_t session_id)
{
	struct voice_data *v = voice_get_session(session_id);
	int ret = 0;
@@ -4476,10 +4475,8 @@ int voc_enable_cvp(uint32_t session_id)
			goto fail;
		}

		/* Send tty mode if tty device is used */
		voice_send_tty_mode_cmd(v);
		/* enable slowtalk */
		if (v->st_enable)
		if (v->st_enable && !v->tty_mode)
			voice_send_set_pp_enable_cmd(v,
					     MODULE_ID_VOICE_MODULE_ST,
					     v->st_enable);
@@ -4680,8 +4677,8 @@ int voc_set_pp_enable(uint32_t session_id, uint32_t module_id, uint32_t enable)
				v->st_enable = enable;

			if (v->voc_state == VOC_RUN) {
				if (module_id ==
				    MODULE_ID_VOICE_MODULE_ST)
				if ((module_id == MODULE_ID_VOICE_MODULE_ST) &&
				    (!v->tty_mode))
					ret = voice_send_set_pp_enable_cmd(v,
						MODULE_ID_VOICE_MODULE_ST,
						enable);
@@ -4904,6 +4901,110 @@ fail:
	return ret;
}

int voc_disable_device(uint32_t session_id)
{
	struct voice_data *v = voice_get_session(session_id);
	int ret = 0;

	pr_debug("%s: voc state=%d\n", __func__, v->voc_state);
	if (v == NULL) {
		pr_err("%s: v is NULL\n", __func__);
		return -EINVAL;
	}

	mutex_lock(&v->lock);
	if (v->voc_state == VOC_RUN) {
		ret = voice_pause_voice_call(v);
		if (ret < 0) {
			pr_err("%s: Pause Voice Call failed for session 0x%x, err %d!\n",
			       __func__, v->session_id, ret);
			goto done;
		}
		rtac_remove_voice(voice_get_cvs_handle(v));
		voice_send_cvp_deregister_vol_cal_cmd(v);
		voice_send_cvp_deregister_cal_cmd(v);
		voice_send_cvp_deregister_dev_cfg_cmd(v);

		v->voc_state = VOC_CHANGE;
	} else {
		pr_debug("%s: called in voc state=%d, No_OP\n",
			 __func__, v->voc_state);
	}

	if (common.ec_ref_ext)
		voc_set_ext_ec_ref(AFE_PORT_INVALID, false);
done:
	mutex_unlock(&v->lock);

	return ret;
}

int voc_enable_device(uint32_t session_id)
{
	struct voice_data *v = voice_get_session(session_id);
	int ret = 0;

	pr_debug("%s: voc state=%d\n", __func__, v->voc_state);
	if (v == NULL) {
		pr_err("%s: v is NULL\n", __func__);
		return -EINVAL;
	}

	mutex_lock(&v->lock);
	if (v->voc_state == VOC_CHANGE) {
		ret = voice_send_tty_mode_cmd(v);
		if (ret < 0) {
			pr_err("%s: Sending TTY mode failed, ret=%d\n",
			       __func__, ret);
			/* Not a critical error, allow voice call to continue */
		}

		if (v->tty_mode) {
			/* disable slowtalk */
			voice_send_set_pp_enable_cmd(v,
						     MODULE_ID_VOICE_MODULE_ST,
						     0);
		} else {
			/* restore slowtalk */
			voice_send_set_pp_enable_cmd(v,
						     MODULE_ID_VOICE_MODULE_ST,
						     v->st_enable);
		}

		ret = voice_send_set_device_cmd(v);
		if (ret < 0) {
			pr_err("%s: Set device failed, ret=%d\n",
			       __func__, ret);
			goto done;
		}

		voice_send_cvp_register_dev_cfg_cmd(v);
		voice_send_cvp_register_cal_cmd(v);
		voice_send_cvp_register_vol_cal_cmd(v);

		rtac_add_voice(voice_get_cvs_handle(v),
			       voice_get_cvp_handle(v),
			       v->dev_rx.port_id, v->dev_tx.port_id,
			       v->session_id);

		ret = voice_send_start_voice_cmd(v);
		if (ret < 0) {
			pr_err("%s: Fail in sending START_VOICE, ret=%d\n",
			       __func__, ret);
			goto done;
		}
		v->voc_state = VOC_RUN;
	} else {
		pr_debug("%s: called in voc state=%d, No_OP\n",
			 __func__, v->voc_state);
	}

done:
	mutex_unlock(&v->lock);

	return ret;
}

int voc_set_lch(uint32_t session_id, enum voice_lch_mode lch_mode)
{
	struct voice_data *v = voice_get_session(session_id);
+2 −2
Original line number Diff line number Diff line
@@ -1565,8 +1565,6 @@ int voc_set_tx_mute(uint32_t session_id, uint32_t dir, uint32_t mute,
int voc_set_device_mute(uint32_t session_id, uint32_t dir, uint32_t mute,
			uint32_t ramp_duration);
int voc_get_rx_device_mute(uint32_t session_id);
int voc_disable_cvp(uint32_t session_id);
int voc_enable_cvp(uint32_t session_id);
int voc_set_route_flag(uint32_t session_id, uint8_t path_dir, uint8_t set);
uint8_t voc_get_route_flag(uint32_t session_id, uint8_t path_dir);
int voc_enable_dtmf_rx_detection(uint32_t session_id, uint32_t enable);
@@ -1601,5 +1599,7 @@ int voc_start_record(uint32_t port_id, uint32_t set, uint32_t session_id);
int voice_get_idx_for_session(u32 session_id);
int voc_set_ext_ec_ref(uint16_t port_id, bool state);
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);

#endif