diff options
| author | Linux Build Service Account <lnxbuild@localhost> | 2014-08-05 04:31:40 -0700 |
|---|---|---|
| committer | Gerrit - the friendly Code Review server <code-review@localhost> | 2014-08-05 04:31:40 -0700 |
| commit | cedb4a53b0ac8504cf96633150507823a0a7b139 (patch) | |
| tree | 36c59934601c858b86b0d4c75f201fec119e6a03 | |
| parent | 19901b2c1a54d1c20de019fdb0b2633c1328949d (diff) | |
| parent | 4abc766f35314bb799d66e62a794df0702fc0dbe (diff) | |
Merge "ASoC: msm: qdsp6v2: add support to enable TTY during VoLTE call"
| -rw-r--r-- | sound/soc/msm/qdsp6/q6voice.c | 291 | ||||
| -rw-r--r-- | sound/soc/msm/qdsp6/q6voice.h | 3 |
2 files changed, 154 insertions, 140 deletions
diff --git a/sound/soc/msm/qdsp6/q6voice.c b/sound/soc/msm/qdsp6/q6voice.c index e6fb885e9a4..341ebffea5e 100644 --- a/sound/soc/msm/qdsp6/q6voice.c +++ b/sound/soc/msm/qdsp6/q6voice.c @@ -48,7 +48,6 @@ 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); @@ -799,39 +798,37 @@ 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, - 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; - } + /* 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; @@ -1128,57 +1125,6 @@ fail: 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; @@ -2295,7 +2241,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) + if (v->st_enable && !v->tty_mode) 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, @@ -3151,6 +3097,57 @@ fail: 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; @@ -3189,38 +3186,45 @@ 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); - rtac_remove_voice(voice_get_cvs_handle(v)); - /* send cmd to dsp to disable vocproc */ - ret = voice_send_disable_vocproc_cmd(v); + ret = voice_pause_voice_call(v); if (ret < 0) { - pr_err("%s: disable vocproc failed\n", __func__); - goto fail; + 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)); + /* 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 == true) + if (common.ec_ref_ext) 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); } -fail: mutex_unlock(&v->lock); +done: + mutex_unlock(&v->lock); return ret; } @@ -3231,82 +3235,87 @@ 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 (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 fail; + goto done; } } else { ret = voice_send_set_device_cmd(v); if (ret < 0) { - pr_err("%s: set device failed rc=%x\n", - __func__, ret); - goto fail; + pr_err("%s: Set device failed, ret=%d\n", + __func__, ret); + goto done; } } + /* 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_enable_vocproc_cmd(v); - if (ret < 0) { - pr_err("%s: enable vocproc failed\n", __func__); - goto fail; - - } - /* send tty mode if tty device is used */ - voice_send_tty_mode_cmd(v); - - /* 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__); + 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; } 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); + 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); } - -fail: +done: mutex_unlock(&v->lock); return ret; @@ -3484,7 +3493,8 @@ 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) + 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); @@ -3926,6 +3936,7 @@ 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 a90e1645d2f..4242198b4f2 100644 --- a/sound/soc/msm/qdsp6/q6voice.h +++ b/sound/soc/msm/qdsp6/q6voice.h @@ -153,6 +153,9 @@ 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. |
