diff options
author | Linux Build Service Account <lnxbuild@localhost> | 2017-01-19 09:52:34 -0800 |
---|---|---|
committer | Gerrit - the friendly Code Review server <code-review@localhost> | 2017-01-19 09:52:33 -0800 |
commit | 8d1bf18c09ed1978b24690440b24f68846d6f823 (patch) | |
tree | 56aa45324b534393f66071080875d7df5a8d80b2 | |
parent | 9f49c83495776f6b49ac21111244d842369bc7d8 (diff) | |
parent | 396b064d4b94c33893be677c8f8feb1e341b6496 (diff) |
Merge "ASoC: msm: qdsp6v2: allow mic selection for multichannel ec"
-rw-r--r-- | include/sound/apr_audio-v2.h | 17 | ||||
-rw-r--r-- | include/sound/q6adm-v2.h | 3 | ||||
-rw-r--r-- | sound/soc/msm/qdsp6v2/msm-qti-pp-config.c | 42 | ||||
-rw-r--r-- | sound/soc/msm/qdsp6v2/q6adm.c | 88 |
4 files changed, 150 insertions, 0 deletions
diff --git a/include/sound/apr_audio-v2.h b/include/sound/apr_audio-v2.h index 06d7a6542177..38d49a2af8be 100644 --- a/include/sound/apr_audio-v2.h +++ b/include/sound/apr_audio-v2.h @@ -10167,4 +10167,21 @@ struct adm_param_fluence_sourcetracking_t { #define AUDPROC_PARAM_ID_AUDIOSPHERE_DESIGN_MULTICHANNEL_INPUT 0x0001091D #define AUDPROC_PARAM_ID_AUDIOSPHERE_OPERATING_INPUT_MEDIA_INFO 0x0001091E + +#define AUDPROC_MODULE_ID_VOICE_TX_SECNS 0x10027059 +#define AUDPROC_PARAM_IDX_SEC_PRIMARY_MIC_CH 0x10014444 + +struct admx_sec_primary_mic_ch { + uint16_t version; + uint16_t reserved; + uint16_t sec_primary_mic_ch; + uint16_t reserved1; +} __packed; + + +struct adm_set_sec_primary_ch_params { + struct adm_cmd_set_pp_params_v5 params; + struct adm_param_data_v5 data; + struct admx_sec_primary_mic_ch sec_primary_mic_ch_data; +} __packed; #endif /*_APR_AUDIO_V2_H_ */ diff --git a/include/sound/q6adm-v2.h b/include/sound/q6adm-v2.h index 47e8e2a73920..8c7da3b9838d 100644 --- a/include/sound/q6adm-v2.h +++ b/include/sound/q6adm-v2.h @@ -138,6 +138,9 @@ int adm_set_softvolume(int port_id, int copp_idx, int adm_set_mic_gain(int port_id, int copp_idx, int volume); +int adm_send_set_multichannel_ec_primary_mic_ch(int port_id, int copp_idx, + int primary_mic_ch); + int adm_param_enable(int port_id, int copp_idx, int module_id, int enable); int adm_send_calibration(int port_id, int copp_idx, int path, int perf_mode, diff --git a/sound/soc/msm/qdsp6v2/msm-qti-pp-config.c b/sound/soc/msm/qdsp6v2/msm-qti-pp-config.c index ccd098d65160..bdbbcfbd56c3 100644 --- a/sound/soc/msm/qdsp6v2/msm-qti-pp-config.c +++ b/sound/soc/msm/qdsp6v2/msm-qti-pp-config.c @@ -93,6 +93,8 @@ static int msm_route_sec_auxpcm_lb_vol_ctrl; static const DECLARE_TLV_DB_LINEAR(sec_auxpcm_lb_vol_gain, 0, INT_RX_VOL_MAX_STEPS); +static int msm_multichannel_ec_primary_mic_ch; + static void msm_qti_pp_send_eq_values_(int eq_idx) { int result; @@ -791,6 +793,43 @@ static int msm_qti_pp_asphere_set(struct snd_kcontrol *kcontrol, return 0; } +static int msm_multichannel_ec_primary_mic_ch_put(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol) +{ + int ret = 0; + int copp_idx = 0; + int port_id = AFE_PORT_ID_QUATERNARY_TDM_TX; + + msm_multichannel_ec_primary_mic_ch = ucontrol->value.integer.value[0]; + pr_debug("%s: msm_multichannel_ec_primary_mic_ch = %u\n", + __func__, msm_multichannel_ec_primary_mic_ch); + copp_idx = adm_get_default_copp_idx(port_id); + if ((copp_idx < 0) || (copp_idx > MAX_COPPS_PER_PORT)) { + pr_err("%s : no active copp to query multichannel ec copp_idx: %u\n", + __func__, copp_idx); + return -EINVAL; + } + adm_send_set_multichannel_ec_primary_mic_ch(port_id, copp_idx, + msm_multichannel_ec_primary_mic_ch); + + return ret; +} + +static int msm_multichannel_ec_primary_mic_ch_get(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol) +{ + ucontrol->value.integer.value[0] = msm_multichannel_ec_primary_mic_ch; + pr_debug("%s: msm_multichannel_ec_primary_mic_ch = %lu\n", + __func__, ucontrol->value.integer.value[0]); + return 0; +} + +static const struct snd_kcontrol_new msm_multichannel_ec_controls[] = { + SOC_SINGLE_EXT("Multichannel EC Primary Mic Ch", SND_SOC_NOPM, 0, + 0xFFFFFFFF, 0, msm_multichannel_ec_primary_mic_ch_get, + msm_multichannel_ec_primary_mic_ch_put), +}; + static const struct snd_kcontrol_new int_fm_vol_mixer_controls[] = { SOC_SINGLE_EXT_TLV("Internal FM RX Volume", SND_SOC_NOPM, 0, INT_RX_VOL_GAIN, 0, msm_qti_pp_get_fm_vol_mixer, @@ -1057,5 +1096,8 @@ void msm_qti_pp_add_controls(struct snd_soc_platform *platform) snd_soc_add_platform_controls(platform, asphere_mixer_controls, ARRAY_SIZE(asphere_mixer_controls)); + + snd_soc_add_platform_controls(platform, msm_multichannel_ec_controls, + ARRAY_SIZE(msm_multichannel_ec_controls)); } #endif /* CONFIG_QTI_PP */ diff --git a/sound/soc/msm/qdsp6v2/q6adm.c b/sound/soc/msm/qdsp6v2/q6adm.c index 04eafdb240f2..f29a84a36a10 100644 --- a/sound/soc/msm/qdsp6v2/q6adm.c +++ b/sound/soc/msm/qdsp6v2/q6adm.c @@ -3668,6 +3668,94 @@ fail_cmd: return rc; } +int adm_send_set_multichannel_ec_primary_mic_ch(int port_id, int copp_idx, + int primary_mic_ch) +{ + struct adm_set_sec_primary_ch_params sec_primary_ch_params; + int rc = 0; + int sz, port_idx; + + pr_debug("%s port_id 0x%x, copp_idx 0x%x, primary_mic_ch %d\n", + __func__, port_id, copp_idx, primary_mic_ch); + port_id = afe_convert_virtual_to_portid(port_id); + port_idx = adm_validate_and_get_port_index(port_id); + if (port_idx < 0) { + pr_err("%s: Invalid port_id 0x%x\n", __func__, port_id); + return -EINVAL; + } + + if (copp_idx < 0 || copp_idx >= MAX_COPPS_PER_PORT) { + pr_err("%s: Invalid copp_idx 0x%x\n", __func__, copp_idx); + return -EINVAL; + } + + sz = sizeof(struct adm_set_sec_primary_ch_params); + + sec_primary_ch_params.params.hdr.hdr_field = + APR_HDR_FIELD(APR_MSG_TYPE_SEQ_CMD, + APR_HDR_LEN(APR_HDR_SIZE), APR_PKT_VER); + sec_primary_ch_params.params.hdr.pkt_size = sz; + sec_primary_ch_params.params.hdr.src_svc = APR_SVC_ADM; + sec_primary_ch_params.params.hdr.src_domain = APR_DOMAIN_APPS; + sec_primary_ch_params.params.hdr.src_port = port_id; + sec_primary_ch_params.params.hdr.dest_svc = APR_SVC_ADM; + sec_primary_ch_params.params.hdr.dest_domain = APR_DOMAIN_ADSP; + sec_primary_ch_params.params.hdr.dest_port = + atomic_read(&this_adm.copp.id[port_idx][copp_idx]); + sec_primary_ch_params.params.hdr.token = port_idx << 16 | copp_idx; + sec_primary_ch_params.params.hdr.opcode = ADM_CMD_SET_PP_PARAMS_V5; + sec_primary_ch_params.params.payload_addr_lsw = 0; + sec_primary_ch_params.params.payload_addr_msw = 0; + sec_primary_ch_params.params.mem_map_handle = 0; + sec_primary_ch_params.params.payload_size = + sizeof(struct adm_param_data_v5) + + sizeof(struct admx_sec_primary_mic_ch); + sec_primary_ch_params.data.module_id = + AUDPROC_MODULE_ID_VOICE_TX_SECNS; + sec_primary_ch_params.data.param_id = + AUDPROC_PARAM_IDX_SEC_PRIMARY_MIC_CH; + sec_primary_ch_params.data.param_size = + sizeof(struct admx_sec_primary_mic_ch); + sec_primary_ch_params.data.reserved = 0; + sec_primary_ch_params.sec_primary_mic_ch_data.version = 0; + sec_primary_ch_params.sec_primary_mic_ch_data.reserved = 0; + sec_primary_ch_params.sec_primary_mic_ch_data.sec_primary_mic_ch = + primary_mic_ch; + sec_primary_ch_params.sec_primary_mic_ch_data.reserved1 = 0; + + atomic_set(&this_adm.copp.stat[port_idx][copp_idx], -1); + rc = apr_send_pkt(this_adm.apr, (uint32_t *)&sec_primary_ch_params); + if (rc < 0) { + pr_err("%s: Set params failed port = %#x\n", + __func__, port_id); + rc = -EINVAL; + goto fail_cmd; + } + /* Wait for the callback */ + rc = wait_event_timeout(this_adm.copp.wait[port_idx][copp_idx], + atomic_read(&this_adm.copp.stat[port_idx][copp_idx]) >= 0, + msecs_to_jiffies(TIMEOUT_MS)); + if (!rc) { + pr_err("%s: Mic Set params timed out port = %#x\n", + __func__, port_id); + rc = -EINVAL; + goto fail_cmd; + } else if (atomic_read(&this_adm.copp.stat + [port_idx][copp_idx]) > 0) { + pr_err("%s: DSP returned error[%s]\n", + __func__, adsp_err_get_err_str( + atomic_read(&this_adm.copp.stat + [port_idx][copp_idx]))); + rc = adsp_err_get_lnx_err_code( + atomic_read(&this_adm.copp.stat + [port_idx][copp_idx])); + goto fail_cmd; + } + rc = 0; +fail_cmd: + return rc; +} + int adm_param_enable(int port_id, int copp_idx, int module_id, int enable) { struct audproc_enable_param_t adm_mod_enable; |