From 31c3028f7937e4693aa5b6879dca5edb7fa0959b Mon Sep 17 00:00:00 2001 From: fei tong Date: Tue, 14 Dec 2021 15:59:47 +0800 Subject: [PATCH] asoc: add afe limiter disable kcontrol and fix ULLPP index mismatch add afe limiter control to enable/disable afe limiter module and fix ULLPP index not match issue. Change-Id: I1820a2a270b4a8aaff3e0043b26d993224c0d33f --- asoc/msm-dai-q6-v2.c | 85 ++++++++++++++++++++++++++++++++++++++ dsp/q6adm.c | 2 + dsp/q6afe.c | 25 +++++++++++ dsp/q6asm.c | 2 + include/dsp/apr_audio-v2.h | 16 +++++++ include/dsp/q6afe-v2.h | 2 + include/dsp/q6audio-v2.h | 1 + 7 files changed, 133 insertions(+) mode change 100644 => 100755 include/dsp/apr_audio-v2.h diff --git a/asoc/msm-dai-q6-v2.c b/asoc/msm-dai-q6-v2.c index d39ef1e49b3f..82dbb73cc206 100755 --- a/asoc/msm-dai-q6-v2.c +++ b/asoc/msm-dai-q6-v2.c @@ -481,6 +481,8 @@ static bool afe_port_logging_item[IDX_TDM_MAX]; static int afe_port_loggging_control_added; +static int afe_port_limiter_control_added; + static int afe_dyn_mclk_control_added; static DEFINE_MUTEX(tdm_mutex); @@ -10572,6 +10574,78 @@ int jitter_cleaner_afe_enable_mclk_and_get_info_cb_func(void *private_data, return 0; } +static int msm_pcm_afe_limiter_param_ctl_info(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_info* ucontrol) +{ + ucontrol->type = SNDRV_CTL_ELEM_TYPE_INTEGER; + /* two int values: port_id and enable/disable */ + ucontrol->count = 2; + /* Valid range is all positive values to support above controls */ + ucontrol->value.integer.min = 0; + ucontrol->value.integer.max = INT_MAX; + return 0; +} + +static int msm_pcm_afe_limiter_param_ctl_get(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol) +{ + return 0; +} + +static int msm_pcm_afe_limiter_param_ctl_put(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol) +{ + u16 port_id; + struct afe_param_id_port_afe_limiter_disable_t afe_limiter_disable; + struct param_hdr_v3 param_hdr; + int ret = -EINVAL; + + pr_debug("%s: enter\n", __func__); + memset(¶m_hdr, 0, sizeof(param_hdr)); + + port_id = ucontrol->value.integer.value[0]; + afe_limiter_disable.disable_afe_limiter = ucontrol->value.integer.value[1]; + + ret = afe_port_send_afe_limiter_param(port_id, &afe_limiter_disable); + if (ret) + pr_err("%s: AFE port logging setting for port 0x%x failed %d\n", + __func__, port_id, ret); + + return ret; +} + +static int msm_pcm_add_afe_port_limiter_control(struct snd_soc_dai *dai) +{ + const char* afe_port_limiter_ctl_name = "AFE_port_limiter_disable"; + int rc = 0; + struct snd_kcontrol_new *knew = NULL; + struct snd_kcontrol* kctl = NULL; + + /* Add AFE port logging controls */ + knew = kzalloc(sizeof(struct snd_kcontrol_new), GFP_KERNEL); + if (!knew) { + return -ENOMEM; + } + knew->iface = SNDRV_CTL_ELEM_IFACE_MIXER; + knew->info = msm_pcm_afe_limiter_param_ctl_info; + knew->get = msm_pcm_afe_limiter_param_ctl_get; + knew->put = msm_pcm_afe_limiter_param_ctl_put; + knew->name = afe_port_limiter_ctl_name; + knew->private_value = dai->id; + kctl = snd_ctl_new1(knew, knew); + if (!kctl) { + kfree(knew); + return -ENOMEM; + } + + rc = snd_ctl_add(dai->component->card->snd_card, kctl); + if (rc < 0) + pr_err("%s: err add AFE port limiter disable control, DAI = %s\n", + __func__, dai->name); + + return rc; +} + static int msm_dai_q6_dai_tdm_probe(struct snd_soc_dai *dai) { int rc = 0; @@ -10680,6 +10754,17 @@ static int msm_dai_q6_dai_tdm_probe(struct snd_soc_dai *dai) } } + if (!afe_port_limiter_control_added) { + rc = msm_pcm_add_afe_port_limiter_control(dai); + if (rc < 0) { + dev_err(dai->dev, "%s: add AFE port logging control failed DAI: %s\n", + __func__, dai->name); + goto rtn; + } + + afe_port_limiter_control_added = 1; + } + if (tdm_dai_data->is_island_dai) rc = msm_dai_q6_add_island_mx_ctls( dai->component->card->snd_card, diff --git a/dsp/q6adm.c b/dsp/q6adm.c index 53a70d396ab2..3c5895edee2a 100755 --- a/dsp/q6adm.c +++ b/dsp/q6adm.c @@ -3290,6 +3290,8 @@ int adm_open_v2(int port_id, int path, int rate, int channel_mode, int topology, (topology == DS2_ADM_COPP_TOPOLOGY_ID) || (topology == SRS_TRUMEDIA_TOPOLOGY_ID)) topology = DEFAULT_COPP_TOPOLOGY; + } else if (perf_mode == LOW_LATENCY_PCM_NOPROC_MODE) { + flags = ADM_LOW_LATENCY_NPROC_DEVICE_SESSION; } else { if ((path == ADM_PATH_COMPRESSED_RX) || (path == ADM_PATH_COMPRESSED_TX)) diff --git a/dsp/q6afe.c b/dsp/q6afe.c index 9334d4c2972f..30fc3a95be48 100755 --- a/dsp/q6afe.c +++ b/dsp/q6afe.c @@ -4876,6 +4876,31 @@ int afe_port_send_logging_cfg(u16 port_id, } EXPORT_SYMBOL(afe_port_send_logging_cfg); +int afe_port_send_afe_limiter_param(u16 port_id, + struct afe_param_id_port_afe_limiter_disable_t *disable_limiter) +{ + struct param_hdr_v3 param_hdr; + int ret = -EINVAL; + + pr_debug("%s: enter, port: 0x%x logging flag: %x\n", __func__, port_id, + disable_limiter->disable_afe_limiter); + memset(¶m_hdr, 0, sizeof(param_hdr)); + + param_hdr.module_id = AFE_MODULE_LIMITER; + param_hdr.instance_id = INSTANCE_ID_0; + param_hdr.param_id = AFE_PARAM_ID_ENABLE; + param_hdr.param_size = sizeof(struct afe_param_id_port_afe_limiter_disable_t); + + ret = q6afe_pack_and_set_param_in_band(port_id, + q6audio_get_port_index(port_id), param_hdr, (u8*)disable_limiter); + if (ret) + pr_err("%s: AFE port logging setting for port 0x%x failed %d\n", + __func__, port_id, ret); + + return ret; +} +EXPORT_SYMBOL(afe_port_send_afe_limiter_param); + int afe_port_send_usb_dev_param(u16 port_id, union afe_port_config *afe_config) { struct afe_param_id_usb_audio_dev_params usb_dev; diff --git a/dsp/q6asm.c b/dsp/q6asm.c index d39ec0f94478..c04b216364c2 100755 --- a/dsp/q6asm.c +++ b/dsp/q6asm.c @@ -3734,6 +3734,8 @@ static int __q6asm_open_write(struct audio_client *ac, uint32_t format, open.mode_flags |= ASM_ULTRA_LOW_LATENCY_STREAM_SESSION; else if (ac->perf_mode == LOW_LATENCY_PCM_MODE) open.mode_flags |= ASM_LOW_LATENCY_STREAM_SESSION; + else if (ac->perf_mode == LOW_LATENCY_PCM_NOPROC_MODE) + open.mode_flags |= ASM_ULTRA_LOW_LATENCY_NPROC_STREAM_SESSION; else { open.mode_flags |= ASM_LEGACY_STREAM_SESSION; if (is_gapless_mode) diff --git a/include/dsp/apr_audio-v2.h b/include/dsp/apr_audio-v2.h old mode 100644 new mode 100755 index b70670c04d2b..c742d20aea54 --- a/include/dsp/apr_audio-v2.h +++ b/include/dsp/apr_audio-v2.h @@ -223,6 +223,8 @@ struct adm_cmd_matrix_map_routings_v5 { /* Definition for a low latency stream session. */ #define ADM_LOW_LATENCY_DEVICE_SESSION 0x2000 +#define ADM_LOW_LATENCY_NPROC_DEVICE_SESSION 0x6000 + /* Definition for a ultra low latency stream session. */ #define ADM_ULTRA_LOW_LATENCY_DEVICE_SESSION 0x4000 @@ -8100,6 +8102,8 @@ struct asm_session_cmdrsp_get_path_delay_v2 { #define ASM_ULTRA_LOW_LATENCY_STREAM_SESSION 0x20000000 +#define ASM_ULTRA_LOW_LATENCY_NPROC_STREAM_SESSION 0x30000000 + #define ASM_ULL_POST_PROCESSING_STREAM_SESSION 0x40000000 #define ASM_LEGACY_STREAM_SESSION 0 @@ -13635,4 +13639,16 @@ struct afe_param_id_port_data_log_disable_t */ } __packed; +#define AFE_MODULE_LIMITER 0x000102A8 +#define AFE_PARAM_ID_ENABLE 0x00010203 +struct afe_param_id_port_afe_limiter_disable_t +{ + uint16_t disable_afe_limiter; + /** Flag for enabling or disabling data logging. + * @values + * - AFE_PORT_DATA_LOGGING_ENABLE - enable data logging. + * - AFE_PORT_DATA_LOGGING_DISABLE - disable data logging. + */ + uint16_t reserved; +} __packed; #endif /*_APR_AUDIO_V2_H_ */ diff --git a/include/dsp/q6afe-v2.h b/include/dsp/q6afe-v2.h index 016996e3bb67..cd8e0132709d 100644 --- a/include/dsp/q6afe-v2.h +++ b/include/dsp/q6afe-v2.h @@ -591,6 +591,8 @@ int afe_tdm_port_start(u16 port_id, struct afe_tdm_port_config *tdm_port, void afe_set_routing_callback(routing_cb cb); int afe_port_send_logging_cfg(u16 port_id, struct afe_param_id_port_data_log_disable_t *log_disable); +int afe_port_send_afe_limiter_param(u16 port_id, + struct afe_param_id_port_afe_limiter_disable_t *disable_limiter); int afe_get_av_dev_drift(struct afe_param_id_dev_timing_stats *timing_stats, u16 port); int afe_set_lpass_clk_cfg_ext_mclk_v2(int index, diff --git a/include/dsp/q6audio-v2.h b/include/dsp/q6audio-v2.h index 079d0b14b585..48eceb89bdff 100644 --- a/include/dsp/q6audio-v2.h +++ b/include/dsp/q6audio-v2.h @@ -12,6 +12,7 @@ enum { LEGACY_PCM_MODE = 0, LOW_LATENCY_PCM_MODE, ULTRA_LOW_LATENCY_PCM_MODE, + LOW_LATENCY_PCM_NOPROC_MODE, ULL_POST_PROCESSING_PCM_MODE, };