From 8ee756edf11390b483632e06b8b7e57b5423d399 Mon Sep 17 00:00:00 2001 From: Anver sadhique Date: Tue, 16 Feb 2021 11:35:57 +0530 Subject: [PATCH 1/3] asoc: add code change for pseudo playback and capture BE DAIs. Pseudo AFE port based BE DAIs can be used for various use cases, including but not limited to voice call. Add support for BE DAI link based on pseudo port and add machine driver changes for proxy port changes. Change-Id: I755a5fbffb6739fab433984a0a43c61590828a31 Signed-off-by: Anver sadhique --- asoc/msm-dai-q6-v2.c | 49 ++++++++++++++++++++++++++++++++++++-- asoc/msm-pcm-routing-v2.c | 39 ++++++++++++++++++++++++++++-- asoc/msm-pcm-routing-v2.h | 6 ++++- asoc/sdm845.c | 29 +++++++++++++++++++++- dsp/q6afe.c | 14 ++++++++++- dsp/q6audio-v2.c | 14 ++++++++++- include/dsp/apr_audio-v2.h | 12 +++++++++- include/dsp/q6afe-v2.h | 5 +++- 8 files changed, 158 insertions(+), 10 deletions(-) diff --git a/asoc/msm-dai-q6-v2.c b/asoc/msm-dai-q6-v2.c index 2ab7da5e3d15..1540f1610c98 100644 --- a/asoc/msm-dai-q6-v2.c +++ b/asoc/msm-dai-q6-v2.c @@ -1,4 +1,4 @@ -/* Copyright (c) 2012-2019, The Linux Foundation. All rights reserved. +/* Copyright (c) 2012-2019, 2021, The Linux Foundation. All rights reserved. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 and @@ -1926,6 +1926,8 @@ static int msm_dai_q6_hw_params(struct snd_pcm_substream *substream, case RT_PROXY_DAI_001_RX: case RT_PROXY_DAI_002_TX: case RT_PROXY_DAI_002_RX: + case RT_PROXY_PORT_002_TX: + case RT_PROXY_PORT_002_RX: rc = msm_dai_q6_afe_rtproxy_hw_params(params, dai); break; case VOICE_PLAYBACK_TX: @@ -3124,6 +3126,42 @@ static struct snd_soc_dai_driver msm_dai_q6_incall_record_dai[] = { }, }; +static struct snd_soc_dai_driver msm_dai_q6_proxy_tx_dai = { + .capture = { + .stream_name = "Proxy Capture", + .aif_name = "PROXY_TX", + .rates = SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_8000 | + SNDRV_PCM_RATE_16000, + .formats = SNDRV_PCM_FMTBIT_S16_LE, + .channels_min = 1, + .channels_max = 2, + .rate_min = 8000, + .rate_max = 48000, + }, + .ops = &msm_dai_q6_ops, + .id = RT_PROXY_PORT_002_TX, + .probe = msm_dai_q6_dai_probe, + .remove = msm_dai_q6_dai_remove, +}; + +static struct snd_soc_dai_driver msm_dai_q6_proxy_rx_dai = { + .playback = { + .stream_name = "Proxy Playback", + .aif_name = "PROXY_RX", + .rates = SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_8000 | + SNDRV_PCM_RATE_16000, + .formats = SNDRV_PCM_FMTBIT_S16_LE, + .channels_min = 1, + .channels_max = 2, + .rate_min = 8000, + .rate_max = 48000, + }, + .ops = &msm_dai_q6_ops, + .id = RT_PROXY_PORT_002_RX, + .probe = msm_dai_q6_dai_probe, + .remove = msm_dai_q6_dai_remove, +}; + static struct snd_soc_dai_driver msm_dai_q6_usb_rx_dai = { .playback = { .stream_name = "USB Audio Playback", @@ -5205,7 +5243,14 @@ register_uplink_capture: pr_err("%s: Device not found stream name %s\n", __func__, stream_name); break; - + case RT_PROXY_PORT_002_RX: + rc = snd_soc_register_component(&pdev->dev, + &msm_dai_q6_component, &msm_dai_q6_proxy_rx_dai, 1); + break; + case RT_PROXY_PORT_002_TX: + rc = snd_soc_register_component(&pdev->dev, + &msm_dai_q6_component, &msm_dai_q6_proxy_tx_dai, 1); + break; default: rc = -ENODEV; break; diff --git a/asoc/msm-pcm-routing-v2.c b/asoc/msm-pcm-routing-v2.c index cbe1905a9ecc..d59f420a63fc 100644 --- a/asoc/msm-pcm-routing-v2.c +++ b/asoc/msm-pcm-routing-v2.c @@ -1,4 +1,4 @@ -/* Copyright (c) 2012-2020, The Linux Foundation. All rights reserved. +/* Copyright (c) 2012-2021, The Linux Foundation. All rights reserved. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 and @@ -579,6 +579,8 @@ struct msm_pcm_routing_bdai_data msm_bedais[MSM_BACKEND_DAI_MAX] = { LPASS_BE_INT6_MI2S_RX}, { AFE_PORT_ID_INT6_MI2S_TX, 0, {0}, {0}, 0, 0, 0, 0, {0}, LPASS_BE_INT6_MI2S_TX}, + { RT_PROXY_PORT_002_RX, 0, {0}, {0}, 0, 0, 0, 0, {0}, LPASS_BE_PROXY_RX}, + { RT_PROXY_PORT_002_TX, 0, {0}, {0}, 0, 0, 0, 0, {0}, LPASS_BE_PROXY_TX}, }; /* Track ASM playback & capture sessions of DAI @@ -2908,7 +2910,7 @@ static const char *const be_name[] = { "INT0_MI2S_RX", "INT0_MI2S_TX", "INT1_MI2S_RX", "INT1_MI2S_TX", "INT2_MI2S_RX", "INT2_MI2S_TX", "INT3_MI2S_RX", "INT3_MI2S_TX", "INT4_MI2S_RX", "INT4_MI2S_TX", "INT5_MI2S_RX", "INT5_MI2S_TX", -"INT6_MI2S_RX", "INT6_MI2S_TX" +"INT6_MI2S_RX", "INT6_MI2S_TX", "PROXY_RX", "PROXY_TX" }; static SOC_ENUM_SINGLE_DECL(mm1_channel_mux, @@ -10243,6 +10245,17 @@ static const struct snd_kcontrol_new slimbus_3_rx_mixer_controls[] = { msm_routing_put_voice_mixer), }; +static const struct snd_kcontrol_new proxy_rx_voice_mixer_controls[] = { + SOC_DOUBLE_EXT("VoiceMMode1", SND_SOC_NOPM, + MSM_BACKEND_DAI_PROXY_RX, + MSM_FRONTEND_DAI_VOICEMMODE1, 1, 0, msm_routing_get_voice_mixer, + msm_routing_put_voice_mixer), + SOC_DOUBLE_EXT("VoiceMMode2", SND_SOC_NOPM, + MSM_BACKEND_DAI_PROXY_RX, + MSM_FRONTEND_DAI_VOICEMMODE2, 1, 0, msm_routing_get_voice_mixer, + msm_routing_put_voice_mixer), +}; + static const struct snd_kcontrol_new tx_voicemmode1_mixer_controls[] = { SOC_DOUBLE_EXT("PRI_TX_MMode1", SND_SOC_NOPM, MSM_BACKEND_DAI_PRI_I2S_TX, @@ -10304,6 +10317,9 @@ static const struct snd_kcontrol_new tx_voicemmode1_mixer_controls[] = { SOC_DOUBLE_EXT("QUIN_MI2S_TX_MMode1", SND_SOC_NOPM, MSM_BACKEND_DAI_QUINARY_MI2S_TX, MSM_FRONTEND_DAI_VOICEMMODE1, 1, 0, msm_routing_get_voice_mixer, msm_routing_put_voice_mixer), + SOC_DOUBLE_EXT("PROXY_TX_MMode1", SND_SOC_NOPM, + MSM_BACKEND_DAI_PROXY_TX, MSM_FRONTEND_DAI_VOICEMMODE1, + 1, 0, msm_routing_get_voice_mixer, msm_routing_put_voice_mixer), }; static const struct snd_kcontrol_new tx_voicemmode2_mixer_controls[] = { @@ -10363,6 +10379,9 @@ static const struct snd_kcontrol_new tx_voicemmode2_mixer_controls[] = { SOC_DOUBLE_EXT("QUIN_MI2S_TX_MMode2", SND_SOC_NOPM, MSM_BACKEND_DAI_QUINARY_MI2S_TX, MSM_FRONTEND_DAI_VOICEMMODE2, 1, 0, msm_routing_get_voice_mixer, msm_routing_put_voice_mixer), + SOC_DOUBLE_EXT("PROXY_TX_MMode2", SND_SOC_NOPM, + MSM_BACKEND_DAI_PROXY_TX, MSM_FRONTEND_DAI_VOICEMMODE2, + 1, 0, msm_routing_get_voice_mixer, msm_routing_put_voice_mixer), }; static const struct snd_kcontrol_new tx_voip_mixer_controls[] = { @@ -15518,6 +15537,8 @@ static const struct snd_soc_dapm_widget msm_qdsp6_widgets[] = { SND_SOC_DAPM_AIF_IN("SLIMBUS_8_TX", "Slimbus8 Capture", 0, 0, 0, 0), SND_SOC_DAPM_AIF_OUT("USB_AUDIO_RX", "USB Audio Playback", 0, 0, 0, 0), SND_SOC_DAPM_AIF_IN("USB_AUDIO_TX", "USB Audio Capture", 0, 0, 0, 0), + SND_SOC_DAPM_AIF_OUT("PROXY_RX", "Proxy Playback", 0, 0, 0, 0), + SND_SOC_DAPM_AIF_IN("PROXY_TX", "Proxy Capture", 0, 0, 0, 0), /* Switch Definitions */ SND_SOC_DAPM_SWITCH("SLIMBUS_DL_HL", SND_SOC_NOPM, 0, 0, @@ -15823,6 +15844,10 @@ static const struct snd_soc_dapm_widget msm_qdsp6_widgets[] = { SND_SOC_NOPM, 0, 0, quat_tdm_rx_2_voice_mixer_controls, ARRAY_SIZE(quat_tdm_rx_2_voice_mixer_controls)), + SND_SOC_DAPM_MIXER("PROXY_RX_Voice Mixer", + SND_SOC_NOPM, 0, 0, + proxy_rx_voice_mixer_controls, + ARRAY_SIZE(proxy_rx_voice_mixer_controls)), SND_SOC_DAPM_MIXER("Voip_Tx Mixer", SND_SOC_NOPM, 0, 0, tx_voip_mixer_controls, ARRAY_SIZE(tx_voip_mixer_controls)), @@ -17632,6 +17657,12 @@ static const struct snd_soc_dapm_route intercon[] = { {"QUAT_TDM_RX_2_Voice Mixer", "VoiceMMode1", "VOICEMMODE1_DL"}, {"QUAT_TDM_RX_2", NULL, "QUAT_TDM_RX_2_Voice Mixer"}, + {"PROXY_RX_Voice Mixer", "VoiceMMode1", "VOICEMMODE1_DL"}, + {"PROXY_RX", NULL, "PROXY_RX_Voice Mixer"}, + + {"PROXY_RX_Voice Mixer", "VoiceMMode2", "VOICEMMODE2_DL"}, + {"PROXY_RX", NULL, "PROXY_RX_Voice Mixer"}, + {"VOC_EXT_EC MUX", "PRI_MI2S_TX", "PRI_MI2S_TX"}, {"VOC_EXT_EC MUX", "SEC_MI2S_TX", "SEC_MI2S_TX"}, {"VOC_EXT_EC MUX", "TERT_MI2S_TX", "TERT_MI2S_TX"}, @@ -17773,6 +17804,7 @@ static const struct snd_soc_dapm_route intercon[] = { {"VoiceMMode1_Tx Mixer", "QUAT_TDM_TX_0_MMode1", "QUAT_TDM_TX_0"}, {"VoiceMMode1_Tx Mixer", "QUAT_MI2S_TX_MMode1", "QUAT_MI2S_TX"}, {"VoiceMMode1_Tx Mixer", "QUIN_MI2S_TX_MMode1", "QUIN_MI2S_TX"}, + {"VoiceMMode1_Tx Mixer", "PROXY_TX_MMode1", "PROXY_TX"}, {"VOICEMMODE1_UL", NULL, "VoiceMMode1_Tx Mixer"}, {"VoiceMMode2_Tx Mixer", "PRI_TX_MMode2", "PRI_I2S_TX"}, @@ -17793,6 +17825,7 @@ static const struct snd_soc_dapm_route intercon[] = { {"VoiceMMode2_Tx Mixer", "QUIN_AUX_PCM_TX_MMode2", "QUIN_AUX_PCM_TX"}, {"VoiceMMode2_Tx Mixer", "QUAT_MI2S_TX_MMode2", "QUAT_MI2S_TX"}, {"VoiceMMode2_Tx Mixer", "QUIN_MI2S_TX_MMode2", "QUIN_MI2S_TX"}, + {"VoiceMMode2_Tx Mixer", "PROXY_TX_MMode2", "PROXY_TX"}, {"VOICEMMODE2_UL", NULL, "VoiceMMode2_Tx Mixer"}, {"Voip_Tx Mixer", "PRI_TX_Voip", "PRI_I2S_TX"}, @@ -18770,6 +18803,7 @@ static const struct snd_soc_dapm_route intercon[] = { {"BE_OUT", NULL, "QUIN_TDM_RX_1"}, {"BE_OUT", NULL, "QUIN_TDM_RX_2"}, {"BE_OUT", NULL, "QUIN_TDM_RX_3"}, + {"BE_OUT", NULL, "PROXY_RX"}, {"PRI_I2S_TX", NULL, "BE_IN"}, {"MI2S_TX", NULL, "BE_IN"}, @@ -18838,6 +18872,7 @@ static const struct snd_soc_dapm_route intercon[] = { {"QUIN_TDM_TX_1", NULL, "BE_IN"}, {"QUIN_TDM_TX_2", NULL, "BE_IN"}, {"QUIN_TDM_TX_3", NULL, "BE_IN"}, + {"PROXY_TX", NULL, "BE_IN"}, }; static int msm_pcm_routing_hw_params(struct snd_pcm_substream *substream, diff --git a/asoc/msm-pcm-routing-v2.h b/asoc/msm-pcm-routing-v2.h index e25c256eb024..59905937a20f 100644 --- a/asoc/msm-pcm-routing-v2.h +++ b/asoc/msm-pcm-routing-v2.h @@ -1,4 +1,4 @@ -/* Copyright (c) 2012-2019, The Linux Foundation. All rights reserved. +/* Copyright (c) 2012-2019, 2021, The Linux Foundation. All rights reserved. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 and @@ -46,6 +46,8 @@ #define LPASS_BE_VOICE2_PLAYBACK_TX "VOICE2_PLAYBACK_TX" #define LPASS_BE_INCALL_RECORD_RX "INCALL_RECORD_RX" #define LPASS_BE_INCALL_RECORD_TX "INCALL_RECORD_TX" +#define LPASS_BE_PROXY_RX "PROXY_RX" +#define LPASS_BE_PROXY_TX "PROXY_TX" #define LPASS_BE_SEC_I2S_RX "SECONDARY_I2S_RX" #define LPASS_BE_SPDIF_RX "SPDIF_RX" @@ -399,6 +401,8 @@ enum { MSM_BACKEND_DAI_INT5_MI2S_TX, MSM_BACKEND_DAI_INT6_MI2S_RX, MSM_BACKEND_DAI_INT6_MI2S_TX, + MSM_BACKEND_DAI_PROXY_RX, + MSM_BACKEND_DAI_PROXY_TX, MSM_BACKEND_DAI_MAX, }; diff --git a/asoc/sdm845.c b/asoc/sdm845.c index 79acd46436c1..030f5fc5d835 100644 --- a/asoc/sdm845.c +++ b/asoc/sdm845.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016-2019, The Linux Foundation. All rights reserved. + * Copyright (c) 2016-2019, 2021, The Linux Foundation. All rights reserved. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 and @@ -5780,6 +5780,33 @@ static struct snd_soc_dai_link msm_common_be_dai_links[] = { .be_hw_params_fixup = msm_be_hw_params_fixup, .ignore_suspend = 1, }, + /* Proxy Tx BACK END DAI Link */ + { + .name = LPASS_BE_PROXY_TX, + .stream_name = "Proxy Capture", + .cpu_dai_name = "msm-dai-q6-dev.8195", + .platform_name = "msm-pcm-routing", + .codec_name = "msm-stub-codec.1", + .codec_dai_name = "msm-stub-tx", + .no_pcm = 1, + .dpcm_capture = 1, + .id = MSM_BACKEND_DAI_PROXY_TX, + .ignore_suspend = 1, + }, + /* Proxy Rx BACK END DAI Link */ + { + .name = LPASS_BE_PROXY_RX, + .stream_name = "Proxy Playback", + .cpu_dai_name = "msm-dai-q6-dev.8194", + .platform_name = "msm-pcm-routing", + .codec_name = "msm-stub-codec.1", + .codec_dai_name = "msm-stub-rx", + .no_pcm = 1, + .dpcm_playback = 1, + .id = MSM_BACKEND_DAI_PROXY_RX, + .ignore_pmdown_time = 1, + .ignore_suspend = 1, + }, { .name = LPASS_BE_USB_AUDIO_RX, .stream_name = "USB Audio Playback", diff --git a/dsp/q6afe.c b/dsp/q6afe.c index 2d3447a1eea2..24f64a32e958 100644 --- a/dsp/q6afe.c +++ b/dsp/q6afe.c @@ -1,4 +1,4 @@ -/* Copyright (c) 2012-2019, The Linux Foundation. All rights reserved. +/* Copyright (c) 2012-2019, 2021, The Linux Foundation. All rights reserved. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 and @@ -598,6 +598,8 @@ int afe_get_port_type(u16 port_id) case VOICE_RECORD_RX: case INT_BT_SCO_TX: case RT_PROXY_PORT_001_TX: + case RT_PROXY_PORT_002_RX: + case RT_PROXY_PORT_002_TX: case AFE_PORT_ID_PRIMARY_MI2S_TX: case AFE_PORT_ID_SECONDARY_MI2S_TX: case AFE_PORT_ID_TERTIARY_MI2S_TX: @@ -3522,6 +3524,9 @@ static int __afe_port_start(u16 port_id, union afe_port_config *afe_config, break; case RT_PROXY_PORT_001_RX: case RT_PROXY_PORT_001_TX: + case RT_PROXY_PORT_002_RX: + case RT_PROXY_PORT_002_TX: + cfg_type = AFE_PARAM_ID_RT_PROXY_CONFIG; break; case INT_BT_SCO_RX: @@ -3953,6 +3958,10 @@ int afe_get_port_index(u16 port_id) return IDX_AFE_PORT_ID_INT6_MI2S_RX; case AFE_PORT_ID_INT6_MI2S_TX: return IDX_AFE_PORT_ID_INT6_MI2S_TX; + case RT_PROXY_PORT_002_RX: + return IDX_RT_PROXY_PORT_002_RX; + case RT_PROXY_PORT_002_TX: + return IDX_RT_PROXY_PORT_002_TX; default: pr_err("%s: port 0x%x\n", __func__, port_id); return -EINVAL; @@ -5856,6 +5865,9 @@ int afe_validate_port(u16 port_id) case AFE_PORT_ID_INT4_MI2S_TX: case AFE_PORT_ID_INT5_MI2S_TX: case AFE_PORT_ID_INT6_MI2S_TX: + case RT_PROXY_PORT_002_RX: + case RT_PROXY_PORT_002_TX: + { ret = 0; break; diff --git a/dsp/q6audio-v2.c b/dsp/q6audio-v2.c index 088d9b279759..93a306fe8eb1 100644 --- a/dsp/q6audio-v2.c +++ b/dsp/q6audio-v2.c @@ -1,4 +1,4 @@ -/* Copyright (c) 2012-2017, The Linux Foundation. All rights reserved. +/* Copyright (c) 2012-2017, 2021, The Linux Foundation. All rights reserved. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 and @@ -301,6 +301,10 @@ int q6audio_get_port_index(u16 port_id) return IDX_AFE_PORT_ID_INT6_MI2S_RX; case AFE_PORT_ID_INT6_MI2S_TX: return IDX_AFE_PORT_ID_INT6_MI2S_TX; + case RT_PROXY_PORT_002_RX: + return IDX_RT_PROXY_PORT_002_RX; + case RT_PROXY_PORT_002_TX: + return IDX_RT_PROXY_PORT_002_TX; default: return -EINVAL; } } @@ -588,6 +592,11 @@ int q6audio_get_port_id(u16 port_id) return AFE_PORT_ID_INT6_MI2S_RX; case AFE_PORT_ID_INT6_MI2S_TX: return AFE_PORT_ID_INT6_MI2S_TX; + case RT_PROXY_PORT_002_RX: + return RT_PROXY_PORT_002_RX; + case RT_PROXY_PORT_002_TX: + return RT_PROXY_PORT_002_TX; + default: pr_warn("%s: Invalid port_id %d\n", __func__, port_id); return -EINVAL; @@ -914,6 +923,9 @@ int q6audio_validate_port(u16 port_id) case AFE_PORT_ID_INT5_MI2S_TX: case AFE_PORT_ID_INT6_MI2S_RX: case AFE_PORT_ID_INT6_MI2S_TX: + case RT_PROXY_PORT_002_RX: + case RT_PROXY_PORT_002_TX: + { ret = 0; break; diff --git a/include/dsp/apr_audio-v2.h b/include/dsp/apr_audio-v2.h index 7e0dfeec3cf9..1b4c89d3673f 100644 --- a/include/dsp/apr_audio-v2.h +++ b/include/dsp/apr_audio-v2.h @@ -1001,7 +1001,7 @@ struct adm_cmd_connect_afe_port_v5 { #define AFE_PORT_ID_SLIMBUS_RANGE_SIZE 0xA /* Size of the range of port IDs for real-time proxy ports. */ -#define AFE_PORT_ID_RT_PROXY_PORT_RANGE_SIZE 0x2 +#define AFE_PORT_ID_RT_PROXY_PORT_RANGE_SIZE 0x4 /* Size of the range of port IDs for pseudoports. */ #define AFE_PORT_ID_PSEUDOPORT_RANGE_SIZE 0x5 @@ -1197,6 +1197,16 @@ struct adm_cmd_connect_afe_port_v5 { #define AFE_PORT_ID_VOICE2_PLAYBACK_TX 0x8002 #define AFE_PORT_ID_VOICE_PLAYBACK_TX 0x8005 +/* + * Proxyport used for voice call data processing. + * In cases like call-screening feature, where user can communicate + * with caller with the help of "call screen" mode, and without + * connecting the call with any HW input/output devices in the phon, + * voice call can use Pseudo port to start voice data processing. + */ +#define RT_PROXY_PORT_002_TX 0x2003 +#define RT_PROXY_PORT_002_RX 0x2002 + #define AFE_PORT_ID_PRIMARY_TDM_RX \ (AFE_PORT_ID_TDM_PORT_RANGE_START + 0x00) #define AFE_PORT_ID_PRIMARY_TDM_RX_1 \ diff --git a/include/dsp/q6afe-v2.h b/include/dsp/q6afe-v2.h index 3a61f7627b67..af3cc8bffe0b 100644 --- a/include/dsp/q6afe-v2.h +++ b/include/dsp/q6afe-v2.h @@ -1,4 +1,4 @@ -/* Copyright (c) 2012-2018, The Linux Foundation. All rights reserved. +/* Copyright (c) 2012-2018, 2021, The Linux Foundation. All rights reserved. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 and @@ -224,6 +224,9 @@ enum { IDX_AFE_PORT_ID_QUINARY_TDM_TX_6, IDX_AFE_PORT_ID_QUINARY_TDM_RX_7, IDX_AFE_PORT_ID_QUINARY_TDM_TX_7, + /* IDX 161 -> 162 */ + IDX_RT_PROXY_PORT_002_RX, + IDX_RT_PROXY_PORT_002_TX, AFE_MAX_PORTS }; From 045d42ca606152ff5ec73b8c2b1bcafc99811e3e Mon Sep 17 00:00:00 2001 From: Lakshman Chaluvaraju Date: Tue, 8 Jun 2021 10:43:20 +0530 Subject: [PATCH 2/3] Asoc: check for invalid voice session id Add check to return if session id is invalid. Change-Id: Ida0e07b78657102a3bf6e73a1ca23c44ad112426 Signed-off-by: Lakshman Chaluvaraju --- asoc/msm-pcm-routing-v2.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/asoc/msm-pcm-routing-v2.c b/asoc/msm-pcm-routing-v2.c index d59f420a63fc..eefaeef98743 100644 --- a/asoc/msm-pcm-routing-v2.c +++ b/asoc/msm-pcm-routing-v2.c @@ -1894,6 +1894,11 @@ static void msm_pcm_routing_process_voice(u16 reg, u16 val, int set) session_id = msm_pcm_routing_get_voc_sessionid(val); + if (!session_id) { + pr_err("%s: Invalid session_id %x\n", __func__, session_id); + return; + } + pr_debug("%s: FE DAI 0x%x session_id 0x%x\n", __func__, val, session_id); From bfddbbe6246bfa2354559f55a8bef623c144573c Mon Sep 17 00:00:00 2001 From: Shashi Kant Maurya Date: Tue, 23 Feb 2021 17:30:16 +0530 Subject: [PATCH 3/3] dsp: adm: add to check output/input channel To avoid out of bound value of output/input channel add the check. Change-Id: I25b7616d6fc08c2d0bb530dfb1457471dc25861c Signed-off-by: Shashi Kant Maurya --- asoc/msm-pcm-routing-v2.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/asoc/msm-pcm-routing-v2.c b/asoc/msm-pcm-routing-v2.c index eefaeef98743..6a69ce9b91d9 100644 --- a/asoc/msm-pcm-routing-v2.c +++ b/asoc/msm-pcm-routing-v2.c @@ -1342,6 +1342,11 @@ static int msm_pcm_routing_channel_mixer(int fe_id, bool perf_mode, for (i = 0; i < ADM_MAX_CHANNELS && channel_input[fe_id][i] > 0; ++i) { be_id = channel_input[fe_id][i] - 1; + if (be_id < 0 || be_id >= MSM_BACKEND_DAI_MAX) { + pr_err("%s: Received out of bounds be_id %d\n", + __func__, be_id); + return -EINVAL; + } channel_mixer[fe_id].input_channels[i] = msm_bedais[be_id].channel; @@ -2853,10 +2858,10 @@ static int msm_pcm_get_out_chs(struct snd_kcontrol *kcontrol, static int msm_pcm_put_out_chs(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - u16 fe_id = 0; - + u16 fe_id = 0, out_ch = 0; fe_id = ((struct soc_multi_mixer_control *) kcontrol->private_value)->shift; + out_ch = ucontrol->value.integer.value[0]; if (fe_id >= MSM_FRONTEND_DAI_MM_SIZE) { pr_err("%s: invalid FE %d\n", __func__, fe_id); return -EINVAL; @@ -2865,6 +2870,12 @@ static int msm_pcm_put_out_chs(struct snd_kcontrol *kcontrol, pr_debug("%s: fe_id is %d, output channels = %d\n", __func__, fe_id, (unsigned int)(ucontrol->value.integer.value[0])); + if (out_ch < 0 || + out_ch > ADM_MAX_CHANNELS) { + pr_err("%s: invalid output channel %d\n", __func__, + out_ch); + return -EINVAL; + } channel_mixer[fe_id].output_channel = (unsigned int)(ucontrol->value.integer.value[0]);