From b6ef9e0377bbaf6a342ea230b6349b3fb6ff4d34 Mon Sep 17 00:00:00 2001 From: Ramlal Karra Date: Wed, 14 Aug 2019 17:53:29 +0530 Subject: [PATCH] asoc: Add HiFi Filter support in driver Open adm with 32 bit-width when HiFi Filter control is set Change-Id: I2c4c4c732b15b26b42d8169ae4c945356bf2bfa6 Signed-off-by: Ramlal Karra --- asoc/msm-pcm-routing-v2.c | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) diff --git a/asoc/msm-pcm-routing-v2.c b/asoc/msm-pcm-routing-v2.c index 854774a0f1..abbb5bd566 100644 --- a/asoc/msm-pcm-routing-v2.c +++ b/asoc/msm-pcm-routing-v2.c @@ -80,6 +80,7 @@ static int msm_route_ext_ec_ref; static bool is_custom_stereo_on; static bool is_ds2_on; static bool swap_ch; +static bool hifi_filter_enabled; static int aanc_level; static int num_app_cfg_types; static int msm_ec_ref_port_id; @@ -1517,6 +1518,9 @@ int msm_pcm_routing_reg_phy_compr_stream(int fe_id, int perf_mode, topology = COMPRESSED_PASSTHROUGH_NONE_TOPOLOGY; pr_debug("%s: Before adm open topology %d\n", __func__, topology); + if (hifi_filter_enabled) + bit_width = msm_routing_get_bit_width( + SNDRV_PCM_FORMAT_S32_LE); copp_idx = adm_open(port_id, path_type, sample_rate, @@ -1862,6 +1866,9 @@ int msm_pcm_routing_reg_phy_stream(int fedai_id, int perf_mode, topology = msm_routing_get_adm_topology(fedai_id, session_type, i); + if (hifi_filter_enabled) + bits_per_sample = msm_routing_get_bit_width( + SNDRV_PCM_FORMAT_S32_LE); copp_idx = adm_open(port_id, path_type, sample_rate, channels, topology, perf_mode, bits_per_sample, @@ -2129,6 +2136,9 @@ static void msm_pcm_routing_process_audio(u16 reg, u16 val, int set) reg); acdb_dev_id = fe_dai_app_type_cfg[val][session_type][reg].acdb_dev_id; + if (hifi_filter_enabled) + bits_per_sample = msm_routing_get_bit_width( + SNDRV_PCM_FORMAT_S32_LE); copp_idx = adm_open(port_id, path_type, sample_rate, channels, topology, fdai->perf_mode, bits_per_sample, @@ -21379,6 +21389,28 @@ static const struct snd_kcontrol_new use_ds1_or_ds2_controls[] = { msm_routing_put_use_ds1_or_ds2_control), }; +static int msm_routing_get_hifi_filter_control( + struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol) +{ + ucontrol->value.integer.value[0] = hifi_filter_enabled; + return 0; +} + +static int msm_routing_put_hifi_filter_control( + struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol) +{ + hifi_filter_enabled = ucontrol->value.integer.value[0]; + return 0; +} + +static const struct snd_kcontrol_new hifi_filter_controls[] = { + SOC_SINGLE_EXT("HiFi Filter", SND_SOC_NOPM, 0, + 1, 0, msm_routing_get_hifi_filter_control, + msm_routing_put_hifi_filter_control), +}; + int msm_routing_get_rms_value_control(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { int rc = 0; @@ -27979,6 +28011,9 @@ static int msm_pcm_routing_prepare(struct snd_pcm_substream *substream) || (fdai->passthr_mode == COMPRESSED_PASSTHROUGH_IEC61937)) topology = COMPRESSED_PASSTHROUGH_NONE_TOPOLOGY; + if (hifi_filter_enabled) + bits_per_sample = msm_routing_get_bit_width( + SNDRV_PCM_FORMAT_S32_LE); copp_idx = adm_open(port_id, path_type, sample_rate, channels, topology, fdai->perf_mode, bits_per_sample, @@ -28578,6 +28613,10 @@ static int msm_routing_probe(struct snd_soc_component *component) use_ds1_or_ds2_controls, ARRAY_SIZE(use_ds1_or_ds2_controls)); + snd_soc_add_component_controls(component, + hifi_filter_controls, + ARRAY_SIZE(hifi_filter_controls)); + snd_soc_add_component_controls(component, device_pp_params_mixer_controls, ARRAY_SIZE(device_pp_params_mixer_controls));