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
This commit is contained in:
fei tong 2021-12-14 15:59:47 +08:00 committed by ftong
parent c30a0cf98d
commit 31c3028f79
7 changed files with 133 additions and 0 deletions

View File

@ -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(&param_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,

View File

@ -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))

View File

@ -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(&param_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;

View File

@ -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)

16
include/dsp/apr_audio-v2.h Normal file → Executable file
View File

@ -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_ */

View File

@ -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,

View File

@ -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,
};