diff --git a/sound/soc/msm/qdsp6/q6voice.c b/sound/soc/msm/qdsp6/q6voice.c index 341ebffea5e5..e6fb885e9a42 100644 --- a/sound/soc/msm/qdsp6/q6voice.c +++ b/sound/soc/msm/qdsp6/q6voice.c @@ -48,6 +48,7 @@ static int voice_send_enable_vocproc_cmd(struct voice_data *v); static int voice_send_netid_timing_cmd(struct voice_data *v); static int voice_send_attach_vocproc_cmd(struct voice_data *v); static int voice_send_set_device_cmd(struct voice_data *v); +static int voice_send_disable_vocproc_cmd(struct voice_data *v); static int voice_send_vol_index_cmd(struct voice_data *v); static int voice_send_cvp_map_memory_cmd(struct voice_data *v); static int voice_send_cvp_unmap_memory_cmd(struct voice_data *v); @@ -798,37 +799,39 @@ static int voice_send_tty_mode_cmd(struct voice_data *v) } mvm_handle = voice_get_mvm_handle(v); - /* send tty mode cmd to mvm */ - mvm_tty_mode_cmd.hdr.hdr_field = APR_HDR_FIELD( - APR_MSG_TYPE_SEQ_CMD, - APR_HDR_LEN(APR_HDR_SIZE), - APR_PKT_VER); - mvm_tty_mode_cmd.hdr.pkt_size = APR_PKT_SIZE(APR_HDR_SIZE, - sizeof(mvm_tty_mode_cmd) - - APR_HDR_SIZE); - pr_debug("%s: pkt size = %d\n", - __func__, mvm_tty_mode_cmd.hdr.pkt_size); - mvm_tty_mode_cmd.hdr.src_port = v->session_id; - mvm_tty_mode_cmd.hdr.dest_port = mvm_handle; - mvm_tty_mode_cmd.hdr.token = 0; - mvm_tty_mode_cmd.hdr.opcode = VSS_ISTREAM_CMD_SET_TTY_MODE; - mvm_tty_mode_cmd.tty_mode.mode = v->tty_mode; - pr_debug("tty mode =%d\n", mvm_tty_mode_cmd.tty_mode.mode); - v->mvm_state = CMD_STATUS_FAIL; - ret = apr_send_pkt(apr_mvm, (uint32_t *) &mvm_tty_mode_cmd); - if (ret < 0) { - pr_err("%s: Error %d sending SET_TTY_MODE\n", - __func__, ret); - goto fail; - } - ret = wait_event_timeout(v->mvm_wait, - (v->mvm_state == CMD_STATUS_SUCCESS), - msecs_to_jiffies(TIMEOUT_MS)); - if (!ret) { - pr_err("%s: wait_event timeout\n", __func__); - goto fail; - } + 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, + APR_HDR_LEN(APR_HDR_SIZE), + APR_PKT_VER); + mvm_tty_mode_cmd.hdr.pkt_size = APR_PKT_SIZE(APR_HDR_SIZE, + sizeof(mvm_tty_mode_cmd) - + APR_HDR_SIZE); + pr_debug("%s: pkt size = %d\n", + __func__, mvm_tty_mode_cmd.hdr.pkt_size); + mvm_tty_mode_cmd.hdr.src_port = v->session_id; + mvm_tty_mode_cmd.hdr.dest_port = mvm_handle; + mvm_tty_mode_cmd.hdr.token = 0; + mvm_tty_mode_cmd.hdr.opcode = VSS_ISTREAM_CMD_SET_TTY_MODE; + mvm_tty_mode_cmd.tty_mode.mode = v->tty_mode; + pr_debug("tty mode =%d\n", mvm_tty_mode_cmd.tty_mode.mode); + v->mvm_state = CMD_STATUS_FAIL; + ret = apr_send_pkt(apr_mvm, (uint32_t *) &mvm_tty_mode_cmd); + if (ret < 0) { + pr_err("%s: Error %d sending SET_TTY_MODE\n", + __func__, ret); + goto fail; + } + ret = wait_event_timeout(v->mvm_wait, + (v->mvm_state == CMD_STATUS_SUCCESS), + msecs_to_jiffies(TIMEOUT_MS)); + if (!ret) { + pr_err("%s: wait_event timeout\n", __func__); + goto fail; + } + } return 0; fail: return -EINVAL; @@ -1125,6 +1128,57 @@ static int voice_send_start_voice_cmd(struct voice_data *v) return -EINVAL; } +static int voice_send_disable_vocproc_cmd(struct voice_data *v) +{ + struct apr_hdr cvp_disable_cmd; + int ret = 0; + void *apr_cvp; + u16 cvp_handle; + + if (v == NULL) { + pr_err("%s: v is NULL\n", __func__); + return -EINVAL; + } + apr_cvp = common.apr_q6_cvp; + + if (!apr_cvp) { + pr_err("%s: apr regist failed\n", __func__); + return -EINVAL; + } + cvp_handle = voice_get_cvp_handle(v); + + /* disable vocproc and wait for respose */ + cvp_disable_cmd.hdr_field = APR_HDR_FIELD(APR_MSG_TYPE_SEQ_CMD, + APR_HDR_LEN(APR_HDR_SIZE), + APR_PKT_VER); + cvp_disable_cmd.pkt_size = APR_PKT_SIZE(APR_HDR_SIZE, + sizeof(cvp_disable_cmd) - APR_HDR_SIZE); + pr_debug("cvp_disable_cmd pkt size = %d, cvp_handle=%d\n", + cvp_disable_cmd.pkt_size, cvp_handle); + cvp_disable_cmd.src_port = v->session_id; + cvp_disable_cmd.dest_port = cvp_handle; + cvp_disable_cmd.token = 0; + cvp_disable_cmd.opcode = VSS_IVOCPROC_CMD_DISABLE; + + v->cvp_state = CMD_STATUS_FAIL; + ret = apr_send_pkt(apr_cvp, (uint32_t *) &cvp_disable_cmd); + if (ret < 0) { + pr_err("Fail in sending VSS_IVOCPROC_CMD_DISABLE\n"); + goto fail; + } + ret = wait_event_timeout(v->cvp_wait, + (v->cvp_state == CMD_STATUS_SUCCESS), + msecs_to_jiffies(TIMEOUT_MS)); + if (!ret) { + pr_err("%s: wait_event timeout\n", __func__); + goto fail; + } + + return 0; +fail: + return -EINVAL; +} + static int voice_send_set_device_cmd(struct voice_data *v) { struct cvp_set_device_cmd cvp_setdev_cmd; @@ -2241,7 +2295,7 @@ static int voice_setup_vocproc(struct voice_data *v) voice_send_set_widevoice_enable_cmd(v); /* enable slowtalk if st_enable is set */ - if (v->st_enable && !v->tty_mode) + if (v->st_enable) voice_send_set_pp_enable_cmd(v, MODULE_ID_VOICE_MODULE_ST, v->st_enable); voice_send_set_pp_enable_cmd(v, MODULE_ID_VOICE_MODULE_FENS, @@ -3097,57 +3151,6 @@ static int voice_cvs_stop_playback(struct voice_data *v) return ret; } -static int voice_pause_voice_call(struct voice_data *v) -{ - struct apr_hdr mvm_pause_voice_cmd; - void *apr_mvm; - int ret = 0; - - if (v == NULL) { - pr_err("%s: Voice data is NULL\n", __func__); - ret = -EINVAL; - goto done; - } - - apr_mvm = common.apr_q6_mvm; - if (!apr_mvm) { - pr_err("%s: apr_mvm is NULL.\n", __func__); - ret = -EINVAL; - goto done; - } - - mvm_pause_voice_cmd.hdr_field = APR_HDR_FIELD(APR_MSG_TYPE_SEQ_CMD, - APR_HDR_LEN(APR_HDR_SIZE), APR_PKT_VER); - mvm_pause_voice_cmd.pkt_size = APR_PKT_SIZE(APR_HDR_SIZE, - sizeof(mvm_pause_voice_cmd) - APR_HDR_SIZE); - mvm_pause_voice_cmd.src_port = v->session_id; - mvm_pause_voice_cmd.dest_port = voice_get_mvm_handle(v); - mvm_pause_voice_cmd.token = 0; - mvm_pause_voice_cmd.opcode = VSS_IMVM_CMD_PAUSE_VOICE; - v->mvm_state = CMD_STATUS_FAIL; - pr_debug("%s: send mvm_pause_voice_cmd pkt size = %d\n", - __func__, mvm_pause_voice_cmd.pkt_size); - - ret = apr_send_pkt(apr_mvm, (uint32_t *)&mvm_pause_voice_cmd); - - if (ret < 0) { - pr_err("Fail in sending VSS_IMVM_CMD_PAUSE_VOICE\n"); - ret = -EINVAL; - goto done; - } - - ret = wait_event_timeout(v->mvm_wait, - (v->mvm_state == CMD_STATUS_SUCCESS), - msecs_to_jiffies(TIMEOUT_MS)); - if (!ret) { - pr_err("%s: Command timeout\n", __func__); - ret = -EINVAL; - goto done; - } -done: - return ret; -} - int voc_start_playback(uint32_t set) { int ret = 0; @@ -3186,45 +3189,38 @@ int voc_disable_cvp(uint16_t session_id) struct voice_data *v = voice_get_session(session_id); int ret = 0; - pr_debug("%s: voc state=%d, session_id=0x%x\n", __func__, - v->voc_state, session_id); - if (v == NULL) { pr_err("%s: invalid session_id 0x%x\n", __func__, session_id); + return -EINVAL; } mutex_lock(&v->lock); + if (v->voc_state == VOC_RUN) { if (v->dev_tx.port_id != RT_PROXY_PORT_001_TX && v->dev_rx.port_id != RT_PROXY_PORT_001_RX) afe_sidetone(v->dev_tx.port_id, v->dev_rx.port_id, 0, 0); - ret = voice_pause_voice_call(v); + rtac_remove_voice(voice_get_cvs_handle(v)); + /* send cmd to dsp to disable vocproc */ + ret = voice_send_disable_vocproc_cmd(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; + pr_err("%s: disable vocproc failed\n", __func__); + goto fail; } - rtac_remove_voice(voice_get_cvs_handle(v)); - /* deregister cvp and vol cal */ voice_send_cvp_deregister_vol_cal_table_cmd(v); voice_send_cvp_deregister_cal_cmd(v); voice_send_cvp_unmap_memory_cmd(v); - if (common.ec_ref_ext) + if (common.ec_ref_ext == true) voc_set_ext_ec_ref(AFE_PORT_INVALID, false); - v->voc_state = VOC_CHANGE; - } else { - pr_debug("%s: called in voc state=%d, No_OP\n", - __func__, v->voc_state); } -done: - mutex_unlock(&v->lock); +fail: mutex_unlock(&v->lock); return ret; } @@ -3235,87 +3231,82 @@ int voc_enable_cvp(uint16_t session_id) struct sidetone_cal sidetone_cal_data; int ret = 0; - pr_debug("%s: voc state=%d, session_id= 0x%x\n", - __func__, v->voc_state, session_id); if (v == NULL) { pr_err("%s: invalid session_id 0x%x\n", __func__, session_id); + 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); - } - get_sidetone_cal(&sidetone_cal_data); - if (v->dev_tx.port_id != RT_PROXY_PORT_001_TX && - v->dev_rx.port_id != RT_PROXY_PORT_001_RX) { - ret = afe_sidetone(v->dev_tx.port_id, - v->dev_rx.port_id, - sidetone_cal_data.enable, - sidetone_cal_data.gain); - if (ret < 0) - pr_err("%s: AFE command sidetone failed\n", - __func__); - } + if (v->voc_state == VOC_CHANGE) { if (common.ec_ref_ext == true) { ret = voice_send_set_device_cmd_v2(v); if (ret < 0) { pr_err("%s: set device V2 failed\n" "rc =%x\n", __func__, ret); - goto done; + goto fail; } } else { ret = voice_send_set_device_cmd(v); if (ret < 0) { - pr_err("%s: Set device failed, ret=%d\n", - __func__, ret); - goto done; + pr_err("%s: set device failed rc=%x\n", + __func__, ret); + goto fail; } } - /* send cvp and vol cal */ ret = voice_send_cvp_map_memory_cmd(v); if (!ret) { voice_send_cvp_register_cal_cmd(v); voice_send_cvp_register_vol_cal_table_cmd(v); } - - ret = voice_send_start_voice_cmd(v); + ret = voice_send_enable_vocproc_cmd(v); if (ret < 0) { - pr_err("%s: Fail in sending START_VOICE, ret=%d\n", - __func__, ret); - goto done; + pr_err("%s: enable vocproc failed\n", __func__); + goto fail; + } + /* send tty mode if tty device is used */ + voice_send_tty_mode_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); + /* enable widevoice if wv_enable is set */ + if (v->wv_enable) + voice_send_set_widevoice_enable_cmd(v); + + /* enable slowtalk */ + if (v->st_enable) + voice_send_set_pp_enable_cmd(v, + MODULE_ID_VOICE_MODULE_ST, + v->st_enable); + /* enable FENS */ + if (v->fens_enable) + voice_send_set_pp_enable_cmd(v, + MODULE_ID_VOICE_MODULE_FENS, + v->fens_enable); + + get_sidetone_cal(&sidetone_cal_data); + if (v->dev_tx.port_id != RT_PROXY_PORT_001_TX && + v->dev_rx.port_id != RT_PROXY_PORT_001_RX) { + ret = afe_sidetone(v->dev_tx.port_id, + v->dev_rx.port_id, + sidetone_cal_data.enable, + sidetone_cal_data.gain); + if (ret < 0) + pr_err("%s: AFE command sidetone failed\n", + __func__); + } + + 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); v->voc_state = VOC_RUN; - } else { - pr_debug("%s: called in voc state=%d, No_OP\n", - __func__, v->voc_state); } -done: + +fail: mutex_unlock(&v->lock); return ret; @@ -3493,8 +3484,7 @@ int voc_set_pp_enable(uint16_t session_id, uint32_t module_id, uint32_t enable) v->fens_enable = enable; if (v->voc_state == VOC_RUN) { - if ((module_id == MODULE_ID_VOICE_MODULE_ST) && - (!v->tty_mode)) + if (module_id == MODULE_ID_VOICE_MODULE_ST) ret = voice_send_set_pp_enable_cmd(v, MODULE_ID_VOICE_MODULE_ST, enable); @@ -3936,7 +3926,6 @@ static int32_t qdsp_mvm_callback(struct apr_client_data *data, void *priv) case VSS_IWIDEVOICE_CMD_SET_WIDEVOICE: case VSS_IMVM_CMD_SET_POLICY_DUAL_CONTROL: case VSS_IMVM_CMD_STANDBY_VOICE: - case VSS_IMVM_CMD_PAUSE_VOICE: pr_debug("%s: cmd = 0x%x\n", __func__, ptr[0]); v->mvm_state = CMD_STATUS_SUCCESS; wake_up(&v->mvm_wait); diff --git a/sound/soc/msm/qdsp6/q6voice.h b/sound/soc/msm/qdsp6/q6voice.h index 4242198b4f28..a90e1645d2f1 100644 --- a/sound/soc/msm/qdsp6/q6voice.h +++ b/sound/soc/msm/qdsp6/q6voice.h @@ -153,9 +153,6 @@ struct vss_unmap_memory_cmd { * vocproc from all the streams to which it is currently attached. */ -#define VSS_IMVM_CMD_PAUSE_VOICE 0x0001137D -/* No payload. Wait for APRV2_IBASIC_RSP_RESULT response. */ - #define VSS_IMVM_CMD_START_VOICE 0x00011190 /* * Start Voice call command.