blob: 72c3372b7d72fba14fd4425897dd0eebeef1d6c2 [file] [log] [blame]
Shiv Maliyappanahalli34b585f2013-10-01 15:49:05 -07001/*
Aniket Kumar Lata0e6e1e52019-11-14 21:43:55 -08002 * Copyright (c) 2013-2020, The Linux Foundation. All rights reserved.
Shiv Maliyappanahalli34b585f2013-10-01 15:49:05 -07003 * Not a contribution.
4 *
Shiv Maliyappanahalli8911f282014-01-10 15:56:19 -08005 * Copyright (C) 2013 The Android Open Source Project
Shiv Maliyappanahalli34b585f2013-10-01 15:49:05 -07006 *
7 * Licensed under the Apache License, Version 2.0 (the "License");
8 * you may not use this file except in compliance with the License.
9 * You may obtain a copy of the License at
10 *
11 * http://www.apache.org/licenses/LICENSE-2.0
12 *
13 * Unless required by applicable law or agreed to in writing, software
14 * distributed under the License is distributed on an "AS IS" BASIS,
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 * See the License for the specific language governing permissions and
17 * limitations under the License.
18 */
19
20#define LOG_TAG "voice"
21/*#define LOG_NDEBUG 0*/
22#define LOG_NDDEBUG 0
23
24#include <errno.h>
Sharad Sangleb27354b2015-06-18 15:58:55 +053025#include <stdlib.h>
Shiv Maliyappanahalli34b585f2013-10-01 15:49:05 -070026#include <math.h>
Aalique Grahame22e49102018-12-18 14:23:57 -080027#include <log/log.h>
Shiv Maliyappanahalli34b585f2013-10-01 15:49:05 -070028#include <cutils/str_parms.h>
29
30#include "audio_hw.h"
31#include "voice.h"
32#include "voice_extn/voice_extn.h"
33#include "platform.h"
34#include "platform_api.h"
Kiran Kandi910e1862013-10-29 13:29:42 -070035#include "audio_extn.h"
Shiv Maliyappanahalli34b585f2013-10-01 15:49:05 -070036
Revathi Uddaraju1eac8b02017-05-18 17:13:33 +053037#ifdef DYNAMIC_LOG_ENABLED
38#include <log_xml_parser.h>
39#define LOG_MASK HAL_MOD_FILE_VOICE
40#include <log_utils.h>
41#endif
42
Shiv Maliyappanahalli34b585f2013-10-01 15:49:05 -070043struct pcm_config pcm_config_voice_call = {
44 .channels = 1,
45 .rate = 8000,
46 .period_size = 160,
47 .period_count = 2,
48 .format = PCM_FORMAT_S16_LE,
49};
50
Suprith Malligere Shankaregowda7400b212019-03-22 19:48:44 +053051#ifdef PLATFORM_AUTO
52struct pcm *voice_loopback_tx = NULL;
53struct pcm *voice_loopback_rx = NULL;
54#endif
Shiv Maliyappanahalli34b585f2013-10-01 15:49:05 -070055static struct voice_session *voice_get_session_from_use_case(struct audio_device *adev,
56 audio_usecase_t usecase_id)
57{
58 struct voice_session *session = NULL;
59 int ret = 0;
60
61 ret = voice_extn_get_session_from_use_case(adev, usecase_id, &session);
62 if (ret == -ENOSYS) {
63 session = &adev->voice.session[VOICE_SESS_IDX];
64 }
65
66 return session;
67}
68
Bhalchandra Gajare45fee282015-06-09 22:23:45 -070069static bool voice_is_sidetone_device(snd_device_t out_device,
70 char *mixer_path)
71{
72 bool is_sidetone_dev;
73
74 switch (out_device) {
75 case SND_DEVICE_OUT_VOICE_HANDSET:
76 is_sidetone_dev = true;
77 strlcpy(mixer_path, "sidetone-handset", MIXER_PATH_MAX_LENGTH);
78 break;
79 case SND_DEVICE_OUT_VOICE_HEADPHONES:
Samyak Jainfd24f1e2019-04-30 11:58:43 +053080 case SND_DEVICE_OUT_VOICE_HEADSET:
Bhalchandra Gajare45fee282015-06-09 22:23:45 -070081 case SND_DEVICE_OUT_VOICE_ANC_HEADSET:
82 case SND_DEVICE_OUT_VOICE_ANC_FB_HEADSET:
83 is_sidetone_dev = true;
84 strlcpy(mixer_path, "sidetone-headphones", MIXER_PATH_MAX_LENGTH);
85 break;
Aalique Grahame22e49102018-12-18 14:23:57 -080086 case SND_DEVICE_OUT_VOICE_USB_HEADSET:
Kuirong Wang1cad7142016-05-24 15:21:56 -070087 case SND_DEVICE_OUT_USB_HEADSET:
Aalique Grahame22e49102018-12-18 14:23:57 -080088 // USB does not use a QC mixer.
89 mixer_path[0] = '\0';
Kuirong Wang1cad7142016-05-24 15:21:56 -070090 is_sidetone_dev = true;
91 break;
Bhalchandra Gajare45fee282015-06-09 22:23:45 -070092 default:
Aalique Grahame22e49102018-12-18 14:23:57 -080093 ALOGW("%s: %d is not a sidetone device", __func__, out_device);
Bhalchandra Gajare45fee282015-06-09 22:23:45 -070094 is_sidetone_dev = false;
95 break;
96 }
97
98 return is_sidetone_dev;
99}
100
101void voice_set_sidetone(struct audio_device *adev,
102 snd_device_t out_snd_device, bool enable)
103{
104 char mixer_path[MIXER_PATH_MAX_LENGTH];
Bhalchandra Gajare45fee282015-06-09 22:23:45 -0700105 ALOGD("%s: %s, out_snd_device: %d\n",
106 __func__, (enable ? "enable" : "disable"),
107 out_snd_device);
Kuirong Wang1cad7142016-05-24 15:21:56 -0700108 if (voice_is_sidetone_device(out_snd_device, mixer_path))
109 platform_set_sidetone(adev, out_snd_device, enable, mixer_path);
Bhalchandra Gajare45fee282015-06-09 22:23:45 -0700110 return;
111}
112
Vidyakumar Athotaea269c62016-10-31 09:05:59 -0700113static bool voice_is_aanc_device(snd_device_t out_device,
114 char *mixer_path)
115{
116 bool is_aanc_dev;
117
118 switch (out_device) {
119 case SND_DEVICE_OUT_ANC_HANDSET:
120 is_aanc_dev = true;
121 strlcpy(mixer_path, "aanc-path", MIXER_PATH_MAX_LENGTH);
122 break;
123 default:
124 is_aanc_dev = false;
125 break;
126 }
127
128 return is_aanc_dev;
129}
130
131void voice_check_and_update_aanc_path(struct audio_device *adev,
132 snd_device_t out_snd_device,
133 bool enable)
134{
135 char mixer_path[MIXER_PATH_MAX_LENGTH];
136
137 ALOGV("%s: %s, out_snd_device: %d\n",
138 __func__, (enable ? "enable" : "disable"), out_snd_device);
139
140 if (voice_is_aanc_device(out_snd_device, mixer_path))
141 platform_update_aanc_path(adev, out_snd_device, enable, mixer_path);
142
143 return;
144}
145
Ravi Kumar Alamanda263d80c2014-08-20 16:24:38 -0700146int voice_stop_usecase(struct audio_device *adev, audio_usecase_t usecase_id)
Shiv Maliyappanahalli34b585f2013-10-01 15:49:05 -0700147{
Satya Krishna Pindiprolif1cd92b2016-04-14 19:05:23 +0530148 int ret = 0;
Shiv Maliyappanahalli34b585f2013-10-01 15:49:05 -0700149 struct audio_usecase *uc_info;
150 struct voice_session *session = NULL;
151
Shiv Maliyappanahalli3bb73582013-11-05 12:49:15 -0800152 ALOGD("%s: enter usecase:%s", __func__, use_case_table[usecase_id]);
Shiv Maliyappanahalli34b585f2013-10-01 15:49:05 -0700153
154 session = (struct voice_session *)voice_get_session_from_use_case(adev, usecase_id);
Haynes Mathew Georgeb51ceb12014-06-30 13:56:18 -0700155 if (!session) {
156 ALOGE("stop_call: couldn't find voice session");
157 return -EINVAL;
158 }
159
Bhalchandra Gajare45fee282015-06-09 22:23:45 -0700160 uc_info = get_usecase_from_list(adev, usecase_id);
161 if (uc_info == NULL) {
162 ALOGE("%s: Could not find the usecase (%d) in the list",
163 __func__, usecase_id);
164 return -EINVAL;
165 }
166
Shiv Maliyappanahalli34b585f2013-10-01 15:49:05 -0700167 session->state.current = CALL_INACTIVE;
168
Bhalchandra Gajare45fee282015-06-09 22:23:45 -0700169 /* Disable sidetone only when no calls are active */
Jaideep Sharma477917f2020-03-13 18:13:33 +0530170 if (!voice_is_call_state_active_in_call(adev))
Bhalchandra Gajare45fee282015-06-09 22:23:45 -0700171 voice_set_sidetone(adev, uc_info->out_snd_device, false);
172
Vidyakumar Athotaea269c62016-10-31 09:05:59 -0700173 /* Disable aanc only when no calls are active */
Jaideep Sharma477917f2020-03-13 18:13:33 +0530174 if (!voice_is_call_state_active_in_call(adev))
Vidyakumar Athotaea269c62016-10-31 09:05:59 -0700175 voice_check_and_update_aanc_path(adev, uc_info->out_snd_device, false);
176
Vidyakumar Athotad9d9ff32013-11-13 11:46:52 -0800177 ret = platform_stop_voice_call(adev->platform, session->vsid);
Shiv Maliyappanahalli34b585f2013-10-01 15:49:05 -0700178
179 /* 1. Close the PCM devices */
180 if (session->pcm_rx) {
181 pcm_close(session->pcm_rx);
182 session->pcm_rx = NULL;
183 }
184 if (session->pcm_tx) {
185 pcm_close(session->pcm_tx);
186 session->pcm_tx = NULL;
187 }
188
Suprith Malligere Shankaregowda7400b212019-03-22 19:48:44 +0530189#ifdef PLATFORM_AUTO
190 if(voice_loopback_rx) {
191 pcm_close(voice_loopback_rx);
192 voice_loopback_rx = NULL;
193 }
194 if(voice_loopback_tx) {
195 pcm_close(voice_loopback_tx);
196 voice_loopback_tx = NULL;
197 }
198#endif
Shiv Maliyappanahalli34b585f2013-10-01 15:49:05 -0700199 /* 2. Get and set stream specific mixer controls */
Haynes Mathew George1376ca62014-04-24 11:55:48 -0700200 disable_audio_route(adev, uc_info);
Shiv Maliyappanahalli34b585f2013-10-01 15:49:05 -0700201
202 /* 3. Disable the rx and tx devices */
Haynes Mathew George1376ca62014-04-24 11:55:48 -0700203 disable_snd_device(adev, uc_info->out_snd_device);
204 disable_snd_device(adev, uc_info->in_snd_device);
Shiv Maliyappanahalli34b585f2013-10-01 15:49:05 -0700205
206 list_remove(&uc_info->list);
207 free(uc_info);
208
209 ALOGD("%s: exit: status(%d)", __func__, ret);
210 return ret;
211}
212
Ravi Kumar Alamanda263d80c2014-08-20 16:24:38 -0700213int voice_start_usecase(struct audio_device *adev, audio_usecase_t usecase_id)
Shiv Maliyappanahalli34b585f2013-10-01 15:49:05 -0700214{
Satya Krishna Pindiprolif1cd92b2016-04-14 19:05:23 +0530215 int ret = 0;
Shiv Maliyappanahalli34b585f2013-10-01 15:49:05 -0700216 struct audio_usecase *uc_info;
217 int pcm_dev_rx_id, pcm_dev_tx_id;
Suprith Malligere Shankaregowda7400b212019-03-22 19:48:44 +0530218#ifdef PLATFORM_AUTO
219 int pcm_dev_loopback_rx_id, pcm_dev_loopback_tx_id;
220#endif
Helen Zeng6a16ad72014-02-23 22:04:44 -0800221 uint32_t sample_rate = 8000;
Shiv Maliyappanahalli34b585f2013-10-01 15:49:05 -0700222 struct voice_session *session = NULL;
Shiv Maliyappanahallida107642013-10-17 11:16:13 -0700223 struct pcm_config voice_config = pcm_config_voice_call;
Jaideep Sharma477917f2020-03-13 18:13:33 +0530224 bool is_in_call = (AUDIO_MODE_IN_CALL == adev->mode);
Shiv Maliyappanahalli3bb73582013-11-05 12:49:15 -0800225
226 ALOGD("%s: enter usecase:%s", __func__, use_case_table[usecase_id]);
Shiv Maliyappanahalli34b585f2013-10-01 15:49:05 -0700227
228 session = (struct voice_session *)voice_get_session_from_use_case(adev, usecase_id);
Haynes Mathew Georgeb51ceb12014-06-30 13:56:18 -0700229 if (!session) {
230 ALOGE("start_call: couldn't find voice session");
231 return -EINVAL;
232 }
233
Shiv Maliyappanahalli34b585f2013-10-01 15:49:05 -0700234 uc_info = (struct audio_usecase *)calloc(1, sizeof(struct audio_usecase));
Haynes Mathew Georgeb51ceb12014-06-30 13:56:18 -0700235 if (!uc_info) {
236 ALOGE("start_call: couldn't allocate mem for audio_usecase");
237 return -ENOMEM;
238 }
239
Shiv Maliyappanahalli34b585f2013-10-01 15:49:05 -0700240 uc_info->id = usecase_id;
241 uc_info->type = VOICE_CALL;
kunleiz3251d232017-11-15 16:28:55 +0800242 uc_info->stream.out = adev->current_call_output;
Aniket Kumar Lata0e6e1e52019-11-14 21:43:55 -0800243 list_init(&uc_info->device_list);
244 assign_devices(&uc_info->device_list, &adev->current_call_output->device_list);
kunleiz3251d232017-11-15 16:28:55 +0800245
Jaideep Sharma477917f2020-03-13 18:13:33 +0530246 if (is_in_call && list_length(&uc_info->device_list) == 2) {
kunleiz3251d232017-11-15 16:28:55 +0800247 ALOGE("%s: Invalid combo device(%#x) for voice call", __func__,
Aniket Kumar Lata0e6e1e52019-11-14 21:43:55 -0800248 get_device_types(&uc_info->device_list));
kunleiz3251d232017-11-15 16:28:55 +0800249 ret = -EIO;
250 goto error_start_voice;
251 }
252
Shiv Maliyappanahalli34b585f2013-10-01 15:49:05 -0700253 uc_info->in_snd_device = SND_DEVICE_NONE;
254 uc_info->out_snd_device = SND_DEVICE_NONE;
Arun Mirpurief53ce52018-09-11 18:00:09 -0700255 adev->voice.use_device_mute = false;
Shiv Maliyappanahalli34b585f2013-10-01 15:49:05 -0700256
Aniket Kumar Lata0e6e1e52019-11-14 21:43:55 -0800257 if (is_sco_out_device_type(&uc_info->device_list) && !adev->bt_sco_on) {
kunleizf175f672017-09-12 17:02:52 +0800258 ALOGE("start_call: couldn't find BT SCO, SCO is not ready");
259 adev->voice.in_call = false;
260 ret = -EIO;
261 goto error_start_voice;
262 }
263
Shiv Maliyappanahalli34b585f2013-10-01 15:49:05 -0700264 list_add_tail(&adev->usecase_list, &uc_info->list);
265
266 select_devices(adev, usecase_id);
267
Suprith Malligere Shankaregowda7400b212019-03-22 19:48:44 +0530268#ifdef PLATFORM_AUTO
269 pcm_dev_loopback_rx_id = HOST_LESS_RX_ID;
270 pcm_dev_loopback_tx_id = HOST_LESS_TX_ID;
271#endif
Shiv Maliyappanahalli34b585f2013-10-01 15:49:05 -0700272 pcm_dev_rx_id = platform_get_pcm_device_id(uc_info->id, PCM_PLAYBACK);
273 pcm_dev_tx_id = platform_get_pcm_device_id(uc_info->id, PCM_CAPTURE);
274
275 if (pcm_dev_rx_id < 0 || pcm_dev_tx_id < 0) {
276 ALOGE("%s: Invalid PCM devices (rx: %d tx: %d) for the usecase(%d)",
277 __func__, pcm_dev_rx_id, pcm_dev_tx_id, uc_info->id);
278 ret = -EIO;
279 goto error_start_voice;
280 }
Helen Zeng6a16ad72014-02-23 22:04:44 -0800281 ret = platform_get_sample_rate(adev->platform, &sample_rate);
282 if (ret < 0) {
283 ALOGE("platform_get_sample_rate error %d\n", ret);
284 } else {
285 voice_config.rate = sample_rate;
286 }
287 ALOGD("voice_config.rate %d\n", voice_config.rate);
Shiv Maliyappanahalli34b585f2013-10-01 15:49:05 -0700288
Vidyakumar Athotab000e0b2015-04-09 17:45:20 -0700289 voice_set_mic_mute(adev, adev->voice.mic_mute);
290
Bhalchandra Gajare45fee282015-06-09 22:23:45 -0700291 ALOGV("%s: Opening PCM capture device card_id(%d) device_id(%d)",
292 __func__, adev->snd_card, pcm_dev_tx_id);
293 session->pcm_tx = pcm_open(adev->snd_card,
294 pcm_dev_tx_id,
295 PCM_IN, &voice_config);
296 if (session->pcm_tx && !pcm_is_ready(session->pcm_tx)) {
297 ALOGE("%s: %s", __func__, pcm_get_error(session->pcm_tx));
298 ret = -EIO;
299 goto error_start_voice;
300 }
301
Shiv Maliyappanahalli34b585f2013-10-01 15:49:05 -0700302 ALOGV("%s: Opening PCM playback device card_id(%d) device_id(%d)",
Apoorv Raghuvanshi84fa2fe2013-12-04 11:57:47 -0800303 __func__, adev->snd_card, pcm_dev_rx_id);
304 session->pcm_rx = pcm_open(adev->snd_card,
Shiv Maliyappanahalli34b585f2013-10-01 15:49:05 -0700305 pcm_dev_rx_id,
Shiv Maliyappanahallida107642013-10-17 11:16:13 -0700306 PCM_OUT, &voice_config);
Shiv Maliyappanahalli34b585f2013-10-01 15:49:05 -0700307 if (session->pcm_rx && !pcm_is_ready(session->pcm_rx)) {
308 ALOGE("%s: %s", __func__, pcm_get_error(session->pcm_rx));
309 ret = -EIO;
310 goto error_start_voice;
311 }
312
Suprith Malligere Shankaregowda7400b212019-03-22 19:48:44 +0530313#ifdef PLATFORM_AUTO
314 voice_loopback_rx = pcm_open(adev->snd_card,
315 pcm_dev_loopback_rx_id,
316 PCM_OUT, &voice_config);
317 if (voice_loopback_rx < 0 || !pcm_is_ready(voice_loopback_rx)) {
318 ALOGE("%s: Either could not open pcm_dev_loopback_rx_id %d or %s",
319 __func__, pcm_dev_loopback_rx_id, pcm_get_error(voice_loopback_rx));
320 ret = -EIO;
321 goto error_start_voice;
322 }
323
324 voice_loopback_tx = pcm_open(adev->snd_card,
325 pcm_dev_loopback_tx_id,
326 PCM_IN, &voice_config);
327 if (voice_loopback_tx < 0 || !pcm_is_ready(voice_loopback_tx)) {
Derek Chenf6390242019-06-10 14:45:46 -0700328 ALOGE("%s: Either could not open pcm_dev_loopback_tx_id %d or %s",
Suprith Malligere Shankaregowda7400b212019-03-22 19:48:44 +0530329 __func__, pcm_dev_loopback_tx_id, pcm_get_error(voice_loopback_tx));
330 ret = -EIO;
331 goto error_start_voice;
332 }
333#endif
334
Weiyin Jiang095e4442019-07-15 11:49:15 +0800335 if (adev->mic_break_enabled)
Vignesh Kulothungan7d374312018-02-21 17:12:00 -0800336 platform_set_mic_break_det(adev->platform, true);
337
Vignesh Kulothungancf4b9322019-05-03 13:52:50 -0700338 ret = pcm_start(session->pcm_tx);
339 if (ret != 0) {
340 ALOGE("%s: %s", __func__, pcm_get_error(session->pcm_tx));
341 goto error_start_voice;
342 }
343
344 ret = pcm_start(session->pcm_rx);
345 if (ret != 0) {
346 ALOGE("%s: %s", __func__, pcm_get_error(session->pcm_rx));
347 goto error_start_voice;
348 }
Bhalchandra Gajare45fee282015-06-09 22:23:45 -0700349
Suprith Malligere Shankaregowda7400b212019-03-22 19:48:44 +0530350#ifdef PLATFORM_AUTO
351 ret = pcm_start(voice_loopback_tx);
352 if (ret != 0) {
353 ALOGE("%s: %s", __func__, pcm_get_error(voice_loopback_tx));
354 goto error_start_voice;
355 }
356
357 ret = pcm_start(voice_loopback_rx);
358 if (ret != 0) {
359 ALOGE("%s: %s", __func__, pcm_get_error(voice_loopback_rx));
360 goto error_start_voice;
361 }
362#endif
363
Vidyakumar Athotaea269c62016-10-31 09:05:59 -0700364 /* Enable aanc only when no calls are active */
Jaideep Sharma477917f2020-03-13 18:13:33 +0530365 if (!voice_is_call_state_active_in_call(adev))
Vidyakumar Athotaea269c62016-10-31 09:05:59 -0700366 voice_check_and_update_aanc_path(adev, uc_info->out_snd_device, true);
367
Bhalchandra Gajare45fee282015-06-09 22:23:45 -0700368 /* Enable sidetone only when no calls are already active */
Jaideep Sharma477917f2020-03-13 18:13:33 +0530369 if (!voice_is_call_state_active_in_call(adev))
Bhalchandra Gajare45fee282015-06-09 22:23:45 -0700370 voice_set_sidetone(adev, uc_info->out_snd_device, true);
Shiv Maliyappanahalli34b585f2013-10-01 15:49:05 -0700371
Shruthi Krishnaace10852013-10-25 14:32:12 -0700372 voice_set_volume(adev, adev->voice.volume);
373
Vidyakumar Athotad9d9ff32013-11-13 11:46:52 -0800374 ret = platform_start_voice_call(adev->platform, session->vsid);
Shiv Maliyappanahalli34b585f2013-10-01 15:49:05 -0700375 if (ret < 0) {
376 ALOGE("%s: platform_start_voice_call error %d\n", __func__, ret);
377 goto error_start_voice;
378 }
379
380 session->state.current = CALL_ACTIVE;
Vidyakumar Athotaad34d572014-08-05 18:20:42 -0700381 goto done;
Shiv Maliyappanahalli34b585f2013-10-01 15:49:05 -0700382
383error_start_voice:
Ravi Kumar Alamanda263d80c2014-08-20 16:24:38 -0700384 voice_stop_usecase(adev, usecase_id);
Shiv Maliyappanahalli34b585f2013-10-01 15:49:05 -0700385
Vidyakumar Athotaad34d572014-08-05 18:20:42 -0700386done:
Shiv Maliyappanahalli34b585f2013-10-01 15:49:05 -0700387 ALOGD("%s: exit: status(%d)", __func__, ret);
388 return ret;
389}
390
Jaideep Sharma477917f2020-03-13 18:13:33 +0530391/*
392* helper function to check whether call is active or not.
393*/
394static inline bool voice_is_active(struct audio_device *adev) {
Vidyakumar Athotaad34d572014-08-05 18:20:42 -0700395 bool call_state = false;
Shiv Maliyappanahalli34b585f2013-10-01 15:49:05 -0700396 int ret = 0;
397
Vidyakumar Athotaad34d572014-08-05 18:20:42 -0700398 ret = voice_extn_is_call_state_active(adev, &call_state);
Shiv Maliyappanahalli34b585f2013-10-01 15:49:05 -0700399 if (ret == -ENOSYS) {
Vidyakumar Athotaad34d572014-08-05 18:20:42 -0700400 call_state = (adev->voice.session[VOICE_SESS_IDX].state.current == CALL_ACTIVE) ? true : false;
Shiv Maliyappanahalli34b585f2013-10-01 15:49:05 -0700401 }
402
Vidyakumar Athotaad34d572014-08-05 18:20:42 -0700403 return call_state;
Shiv Maliyappanahalli34b585f2013-10-01 15:49:05 -0700404}
405
Jaideep Sharma477917f2020-03-13 18:13:33 +0530406/*
407* checks if call is active and in IN_CALL mode.
408*/
409bool voice_is_call_state_active_in_call(struct audio_device *adev)
410{
411 bool call_state = voice_is_active(adev);
412 return call_state && adev->mode == AUDIO_MODE_IN_CALL;
413}
414
415/*
416* returns true if call is active no matter what mode is.
417*/
418bool voice_is_call_state_active(struct audio_device *adev)
419{
420 return voice_is_active(adev);
421}
422
Alexy Josephb1379942016-01-29 15:49:38 -0800423bool voice_is_in_call(const struct audio_device *adev)
Ravi Kumar Alamanda060bc5a2014-09-05 13:51:35 -0700424{
Jaideep Sharma477917f2020-03-13 18:13:33 +0530425 return adev->voice.in_call && adev->mode == AUDIO_MODE_IN_CALL;
426}
427
428bool voice_is_in_call_or_call_screen(const struct audio_device *adev)
429{
Ravi Kumar Alamanda060bc5a2014-09-05 13:51:35 -0700430 return adev->voice.in_call;
431}
432
Alexy Josephb1379942016-01-29 15:49:38 -0800433bool voice_is_in_call_rec_stream(const struct stream_in *in)
kunleizc5a639b2014-04-24 18:46:22 +0800434{
435 bool in_call_rec = false;
kunleizc5a639b2014-04-24 18:46:22 +0800436
Anish Kumar50ebcbf2014-12-09 04:01:39 +0530437 if (!in) {
438 ALOGE("%s: input stream is NULL", __func__);
439 return in_call_rec;
440 }
441
Arun Mirpurief53ce52018-09-11 18:00:09 -0700442 if (in->source == AUDIO_SOURCE_VOICE_DOWNLINK ||
443 in->source == AUDIO_SOURCE_VOICE_UPLINK ||
444 in->source == AUDIO_SOURCE_VOICE_CALL) {
445 in_call_rec = true;
kunleizc5a639b2014-04-24 18:46:22 +0800446 }
447
448 return in_call_rec;
449}
450
Shiv Maliyappanahallida107642013-10-17 11:16:13 -0700451uint32_t voice_get_active_session_id(struct audio_device *adev)
452{
453 int ret = 0;
454 uint32_t session_id;
455
456 ret = voice_extn_get_active_session_id(adev, &session_id);
457 if (ret == -ENOSYS) {
458 session_id = VOICE_VSID;
459 }
460 return session_id;
461}
462
Kunlei Zhanga3b3abf2019-06-25 15:42:21 +0800463bool voice_check_voicecall_usecases_active(struct audio_device *adev)
464{
465 struct listnode *node;
466 struct audio_usecase *usecase = NULL;
467
468 list_for_each(node, &adev->usecase_list) {
469 usecase = node_to_item(node, struct audio_usecase, list);
Jaideep Sharma477917f2020-03-13 18:13:33 +0530470 if (usecase->type == VOICE_CALL && adev->mode != AUDIO_MODE_CALL_SCREEN) {
Kunlei Zhanga3b3abf2019-06-25 15:42:21 +0800471 ALOGV("%s: voice usecase:%s is active", __func__,
472 use_case_table[usecase->id]);
473 return true;
474 }
475 }
476 return false;
477}
478
Shiv Maliyappanahallida107642013-10-17 11:16:13 -0700479int voice_check_and_set_incall_rec_usecase(struct audio_device *adev,
Vidyakumar Athota2850d532013-11-19 16:02:12 -0800480 struct stream_in *in)
Shiv Maliyappanahallida107642013-10-17 11:16:13 -0700481{
482 int ret = 0;
483 uint32_t session_id;
Vidyakumar Athota2850d532013-11-19 16:02:12 -0800484 int rec_mode = INCALL_REC_NONE;
Shiv Maliyappanahallida107642013-10-17 11:16:13 -0700485
Vidyakumar Athotaad34d572014-08-05 18:20:42 -0700486 if (voice_is_call_state_active(adev)) {
Shiv Maliyappanahallida107642013-10-17 11:16:13 -0700487 switch (in->source) {
488 case AUDIO_SOURCE_VOICE_UPLINK:
Helen Zenge56b4852013-12-03 16:54:40 -0800489 if (audio_extn_compr_cap_enabled() &&
490 audio_extn_compr_cap_format_supported(in->config.format)) {
491 in->usecase = USECASE_INCALL_REC_UPLINK_COMPRESS;
492 } else
493 in->usecase = USECASE_INCALL_REC_UPLINK;
Vidyakumar Athota2850d532013-11-19 16:02:12 -0800494 rec_mode = INCALL_REC_UPLINK;
Shiv Maliyappanahallida107642013-10-17 11:16:13 -0700495 break;
496 case AUDIO_SOURCE_VOICE_DOWNLINK:
Helen Zenge56b4852013-12-03 16:54:40 -0800497 if (audio_extn_compr_cap_enabled() &&
498 audio_extn_compr_cap_format_supported(in->config.format)) {
499 in->usecase = USECASE_INCALL_REC_DOWNLINK_COMPRESS;
500 } else
501 in->usecase = USECASE_INCALL_REC_DOWNLINK;
Vidyakumar Athota2850d532013-11-19 16:02:12 -0800502 rec_mode = INCALL_REC_DOWNLINK;
Shiv Maliyappanahallida107642013-10-17 11:16:13 -0700503 break;
504 case AUDIO_SOURCE_VOICE_CALL:
Helen Zenge56b4852013-12-03 16:54:40 -0800505 if (audio_extn_compr_cap_enabled() &&
506 audio_extn_compr_cap_format_supported(in->config.format)) {
507 in->usecase = USECASE_INCALL_REC_UPLINK_AND_DOWNLINK_COMPRESS;
508 } else
509 in->usecase = USECASE_INCALL_REC_UPLINK_AND_DOWNLINK;
Vidyakumar Athota2850d532013-11-19 16:02:12 -0800510 rec_mode = INCALL_REC_UPLINK_AND_DOWNLINK;
Shiv Maliyappanahallida107642013-10-17 11:16:13 -0700511 break;
512 default:
513 ALOGV("%s: Source type %d doesnt match incall recording criteria",
514 __func__, in->source);
515 return ret;
516 }
517
Shiv Maliyappanahallida107642013-10-17 11:16:13 -0700518 session_id = voice_get_active_session_id(adev);
Vidyakumar Athota2850d532013-11-19 16:02:12 -0800519 ret = platform_set_incall_recording_session_id(adev->platform,
520 session_id, rec_mode);
Yunfei Zhang3714bd12019-04-11 09:04:28 +0800521 platform_set_incall_recording_session_channels(adev->platform,
522 in->config.channels);
Shiv Maliyappanahallida107642013-10-17 11:16:13 -0700523 ALOGV("%s: Update usecase to %d",__func__, in->usecase);
524 } else {
Venkata Narendra Kumar Gutta76440ba2015-03-30 19:16:14 +0530525 /*
526 * Reject the recording instances, where the recording is started
527 * with In-call voice recording source types but voice call is not
528 * active by the time input is started
529 */
530 if ((in->source == AUDIO_SOURCE_VOICE_UPLINK) ||
531 (in->source == AUDIO_SOURCE_VOICE_DOWNLINK) ||
532 (in->source == AUDIO_SOURCE_VOICE_CALL)) {
533 ret = -EINVAL;
534 ALOGE("%s: As voice call is not active, Incall rec usecase can't be \
535 selected for requested source:%d",__func__, in->source);
536 }
Shiv Maliyappanahallida107642013-10-17 11:16:13 -0700537 ALOGV("%s: voice call not active", __func__);
538 }
539
540 return ret;
541}
542
Vidyakumar Athota2850d532013-11-19 16:02:12 -0800543int voice_check_and_stop_incall_rec_usecase(struct audio_device *adev,
544 struct stream_in *in)
545{
546 int ret = 0;
547
548 if (in->source == AUDIO_SOURCE_VOICE_UPLINK ||
549 in->source == AUDIO_SOURCE_VOICE_DOWNLINK ||
550 in->source == AUDIO_SOURCE_VOICE_CALL) {
551 ret = platform_stop_incall_recording_usecase(adev->platform);
552 ALOGV("%s: Stop In-call recording", __func__);
553 }
554
555 return ret;
556}
557
Divya Narayanan Poojary85d0a592018-02-06 14:25:16 +0530558snd_device_t voice_get_incall_rec_backend_device(struct stream_in *in)
559{
560 snd_device_t incall_record_device = {0};
561
Aditya Bavanari9e957d82019-01-29 17:47:13 +0530562 if (!in) {
563 ALOGE("%s: input stream is NULL", __func__);
564 return 0;
565 }
566
Divya Narayanan Poojary85d0a592018-02-06 14:25:16 +0530567 switch(in->source) {
568 case AUDIO_SOURCE_VOICE_UPLINK:
569 incall_record_device = SND_DEVICE_IN_INCALL_REC_TX;
570 break;
571 case AUDIO_SOURCE_VOICE_DOWNLINK:
572 incall_record_device = SND_DEVICE_IN_INCALL_REC_RX;
573 break;
574 case AUDIO_SOURCE_VOICE_CALL:
575 incall_record_device = SND_DEVICE_IN_INCALL_REC_RX_TX;
576 break;
577 default:
578 ALOGI("Invalid source %d", in->source);
579 }
580
581 return incall_record_device;
582}
583
Narsinga Rao Chella212e2542014-11-17 19:57:04 -0800584snd_device_t voice_get_incall_rec_snd_device(snd_device_t in_snd_device)
585{
586 snd_device_t incall_record_device = in_snd_device;
587
588 /*
589 * For incall recording stream, AUDIO_COPP topology will be picked up
590 * from the calibration data of the input sound device which is nothing
591 * but the voice call's input device. But there are requirements to use
592 * AUDIO_COPP_MONO topology even if the voice call's input device is
593 * different. Hence override the input device with the one which uses
594 * the AUDIO_COPP_MONO topology.
595 */
596 switch(in_snd_device) {
597 case SND_DEVICE_IN_HANDSET_MIC:
598 case SND_DEVICE_IN_VOICE_DMIC:
599 case SND_DEVICE_IN_AANC_HANDSET_MIC:
600 incall_record_device = SND_DEVICE_IN_HANDSET_MIC;
Shiv Maliyappanahalli4d2d97c2015-02-19 14:29:01 -0800601 break;
Narsinga Rao Chella212e2542014-11-17 19:57:04 -0800602 case SND_DEVICE_IN_VOICE_SPEAKER_MIC:
603 case SND_DEVICE_IN_VOICE_SPEAKER_DMIC:
604 case SND_DEVICE_IN_VOICE_SPEAKER_DMIC_BROADSIDE:
605 case SND_DEVICE_IN_VOICE_SPEAKER_QMIC:
606 incall_record_device = SND_DEVICE_IN_VOICE_SPEAKER_MIC;
Shiv Maliyappanahalli4d2d97c2015-02-19 14:29:01 -0800607 break;
Narsinga Rao Chella212e2542014-11-17 19:57:04 -0800608 default:
609 incall_record_device = in_snd_device;
610 }
611
Shiv Maliyappanahalli4d2d97c2015-02-19 14:29:01 -0800612 ALOGD("%s: in_snd_device(%d: %s) incall_record_device(%d: %s)", __func__,
613 in_snd_device, platform_get_snd_device_name(in_snd_device),
614 incall_record_device, platform_get_snd_device_name(incall_record_device));
615
Narsinga Rao Chella212e2542014-11-17 19:57:04 -0800616 return incall_record_device;
617}
618
Shiv Maliyappanahalli34b585f2013-10-01 15:49:05 -0700619int voice_set_mic_mute(struct audio_device *adev, bool state)
620{
621 int err = 0;
622
Narsinga Rao Chella05573b72013-11-15 15:21:40 -0800623 adev->voice.mic_mute = state;
Arun Mirpurief53ce52018-09-11 18:00:09 -0700624
Dhanalakshmi Siddani823dc5a2016-09-28 14:47:26 +0530625 if (audio_extn_hfp_is_active(adev)) {
Arun Mirpurie008ed22019-03-21 11:21:04 -0700626 err = audio_extn_hfp_set_mic_mute2(adev, state);
Dhanalakshmi Siddani823dc5a2016-09-28 14:47:26 +0530627 } else if (adev->mode == AUDIO_MODE_IN_CALL) {
Arun Mirpurief53ce52018-09-11 18:00:09 -0700628 /* Use device mute if incall music delivery usecase is in progress */
629 if (adev->voice.use_device_mute)
630 err = platform_set_device_mute(adev->platform, state, "tx");
631 else
632 err = platform_set_mic_mute(adev->platform, state);
633 ALOGV("%s: voice mute status=%d, use_device_mute flag=%d",
634 __func__, state, adev->voice.use_device_mute);
Dhanalakshmi Siddani823dc5a2016-09-28 14:47:26 +0530635 } else if (adev->mode == AUDIO_MODE_IN_COMMUNICATION) {
Narsinga Rao Chella05573b72013-11-15 15:21:40 -0800636 err = voice_extn_compress_voip_set_mic_mute(adev, state);
Dhanalakshmi Siddani823dc5a2016-09-28 14:47:26 +0530637 }
Arun Mirpurief53ce52018-09-11 18:00:09 -0700638
Shiv Maliyappanahalli34b585f2013-10-01 15:49:05 -0700639 return err;
640}
641
642bool voice_get_mic_mute(struct audio_device *adev)
643{
644 return adev->voice.mic_mute;
645}
646
Arun Mirpurief53ce52018-09-11 18:00:09 -0700647/*
648 * Following function is called when incall music uplink usecase is
649 * created or destroyed while mic is muted. If incall music uplink
650 * usecase is active, apply voice device mute to mute only voice Tx
651 * path and not the mixed voice Tx + inncall-music path. Revert to
652 * voice stream mute once incall music uplink usecase is inactive
653 */
654void voice_set_device_mute_flag(struct audio_device *adev, bool state)
655{
656 if (adev->voice.mic_mute) {
657 if (state) {
658 platform_set_device_mute(adev->platform, true, "tx");
659 platform_set_mic_mute(adev->platform, false);
660 } else {
661 platform_set_mic_mute(adev->platform, true);
662 platform_set_device_mute(adev->platform, false, "tx");
663 }
664 }
665 adev->voice.use_device_mute = state;
666}
667
Shiv Maliyappanahalli34b585f2013-10-01 15:49:05 -0700668int voice_set_volume(struct audio_device *adev, float volume)
669{
670 int vol, err = 0;
671
Shruthi Krishnaace10852013-10-25 14:32:12 -0700672 adev->voice.volume = volume;
Shiv Maliyappanahalli34b585f2013-10-01 15:49:05 -0700673 if (adev->mode == AUDIO_MODE_IN_CALL) {
674 if (volume < 0.0) {
675 volume = 0.0;
676 } else if (volume > 1.0) {
677 volume = 1.0;
678 }
679
680 vol = lrint(volume * 100.0);
681
682 // Voice volume levels from android are mapped to driver volume levels as follows.
683 // 0 -> 5, 20 -> 4, 40 ->3, 60 -> 2, 80 -> 1, 100 -> 0
684 // So adjust the volume to get the correct volume index in driver
685 vol = 100 - vol;
686
687 err = platform_set_voice_volume(adev->platform, vol);
Shiv Maliyappanahalli34b585f2013-10-01 15:49:05 -0700688 }
Narsinga Rao Chella05573b72013-11-15 15:21:40 -0800689 if (adev->mode == AUDIO_MODE_IN_COMMUNICATION)
690 err = voice_extn_compress_voip_set_volume(adev, volume);
691
Shruthi Krishnaace10852013-10-25 14:32:12 -0700692
Shiv Maliyappanahalli34b585f2013-10-01 15:49:05 -0700693 return err;
694}
695
696int voice_start_call(struct audio_device *adev)
697{
698 int ret = 0;
699
Ravi Kumar Alamandabe149392014-10-20 17:07:43 -0700700 adev->voice.in_call = true;
Aalique Grahame22e49102018-12-18 14:23:57 -0800701
702 voice_set_mic_mute(adev, adev->voice.mic_mute);
703
Shiv Maliyappanahalli3bb73582013-11-05 12:49:15 -0800704 ret = voice_extn_start_call(adev);
Shiv Maliyappanahalli34b585f2013-10-01 15:49:05 -0700705 if (ret == -ENOSYS) {
Ravi Kumar Alamanda263d80c2014-08-20 16:24:38 -0700706 ret = voice_start_usecase(adev, USECASE_VOICE_CALL);
Shiv Maliyappanahalli34b585f2013-10-01 15:49:05 -0700707 }
708
709 return ret;
710}
711
712int voice_stop_call(struct audio_device *adev)
713{
714 int ret = 0;
715
Vidyakumar Athotaad34d572014-08-05 18:20:42 -0700716 adev->voice.in_call = false;
Shiv Maliyappanahalli3bb73582013-11-05 12:49:15 -0800717 ret = voice_extn_stop_call(adev);
Shiv Maliyappanahalli34b585f2013-10-01 15:49:05 -0700718 if (ret == -ENOSYS) {
Ravi Kumar Alamanda263d80c2014-08-20 16:24:38 -0700719 ret = voice_stop_usecase(adev, USECASE_VOICE_CALL);
Shiv Maliyappanahalli34b585f2013-10-01 15:49:05 -0700720 }
721
722 return ret;
723}
724
Shiv Maliyappanahallif9308492013-12-12 12:18:09 -0800725void voice_get_parameters(struct audio_device *adev,
726 struct str_parms *query,
727 struct str_parms *reply)
728{
729 voice_extn_get_parameters(adev, query, reply);
730}
731
Shiv Maliyappanahalli34b585f2013-10-01 15:49:05 -0700732int voice_set_parameters(struct audio_device *adev, struct str_parms *parms)
733{
Shiv Maliyappanahalli34b585f2013-10-01 15:49:05 -0700734 char value[32];
Shiv Maliyappanahalli3e064fd2013-12-16 15:54:40 -0800735 int ret = 0, err;
Krishnankutty Kolathappilly061a9492014-01-31 18:12:13 -0800736 char *kv_pairs = str_parms_to_str(parms);
Shiv Maliyappanahalli34b585f2013-10-01 15:49:05 -0700737
Krishnankutty Kolathappilly061a9492014-01-31 18:12:13 -0800738 ALOGV_IF(kv_pairs != NULL, "%s: enter: %s", __func__, kv_pairs);
Shiv Maliyappanahalli34b585f2013-10-01 15:49:05 -0700739
Shiv Maliyappanahalli3e064fd2013-12-16 15:54:40 -0800740 ret = voice_extn_set_parameters(adev, parms);
Vidyakumar Athota8d931f02014-07-21 14:51:44 -0700741 if (ret != 0) {
742 if (ret == -ENOSYS)
743 ret = 0;
744 else
745 goto done;
746 }
Shiv Maliyappanahalli34b585f2013-10-01 15:49:05 -0700747
Shiv Maliyappanahalli3e064fd2013-12-16 15:54:40 -0800748 ret = voice_extn_compress_voip_set_parameters(adev, parms);
Vidyakumar Athota8d931f02014-07-21 14:51:44 -0700749 if (ret != 0) {
750 if (ret == -ENOSYS)
751 ret = 0;
752 else
753 goto done;
754 }
Shiv Maliyappanahalli3e064fd2013-12-16 15:54:40 -0800755
756 err = str_parms_get_str(parms, AUDIO_PARAMETER_KEY_TTY_MODE, value, sizeof(value));
757 if (err >= 0) {
Shiv Maliyappanahalli34b585f2013-10-01 15:49:05 -0700758 int tty_mode;
759 str_parms_del(parms, AUDIO_PARAMETER_KEY_TTY_MODE);
760 if (strcmp(value, AUDIO_PARAMETER_VALUE_TTY_OFF) == 0)
761 tty_mode = TTY_MODE_OFF;
762 else if (strcmp(value, AUDIO_PARAMETER_VALUE_TTY_VCO) == 0)
763 tty_mode = TTY_MODE_VCO;
764 else if (strcmp(value, AUDIO_PARAMETER_VALUE_TTY_HCO) == 0)
765 tty_mode = TTY_MODE_HCO;
766 else if (strcmp(value, AUDIO_PARAMETER_VALUE_TTY_FULL) == 0)
767 tty_mode = TTY_MODE_FULL;
768 else {
769 ret = -EINVAL;
770 goto done;
771 }
772
Shiv Maliyappanahalli34b585f2013-10-01 15:49:05 -0700773 if (tty_mode != adev->voice.tty_mode) {
774 adev->voice.tty_mode = tty_mode;
775 adev->acdb_settings = (adev->acdb_settings & TTY_MODE_CLEAR) | tty_mode;
Jaideep Sharma477917f2020-03-13 18:13:33 +0530776 if (voice_is_call_state_active_in_call(adev))
Narsinga Rao Chella22d8d7a2014-02-06 14:05:14 -0800777 voice_update_devices_for_all_voice_usecases(adev);
Shiv Maliyappanahalli34b585f2013-10-01 15:49:05 -0700778 }
Shiv Maliyappanahalli34b585f2013-10-01 15:49:05 -0700779 }
780
Aalique Grahame22e49102018-12-18 14:23:57 -0800781 err = str_parms_get_str(parms, AUDIO_PARAMETER_KEY_HAC,
782 value, sizeof(value));
783 if (err >= 0) {
784 bool hac = false;
785 str_parms_del(parms, AUDIO_PARAMETER_KEY_HAC);
786 if (strcmp(value, AUDIO_PARAMETER_VALUE_HAC_ON) == 0)
787 hac = true;
788
789 if (hac != adev->voice.hac) {
790 adev->voice.hac = hac;
791 if (voice_is_in_call(adev))
792 voice_update_devices_for_all_voice_usecases(adev);
793 }
794 }
795
Shiv Maliyappanahalli3e064fd2013-12-16 15:54:40 -0800796 err = str_parms_get_str(parms, AUDIO_PARAMETER_KEY_INCALLMUSIC,
Vidyakumar Athota2850d532013-11-19 16:02:12 -0800797 value, sizeof(value));
Shiv Maliyappanahalli3e064fd2013-12-16 15:54:40 -0800798 if (err >= 0) {
Vidyakumar Athota2850d532013-11-19 16:02:12 -0800799 str_parms_del(parms, AUDIO_PARAMETER_KEY_INCALLMUSIC);
800 if (strcmp(value, AUDIO_PARAMETER_VALUE_TRUE) == 0)
801 platform_start_incall_music_usecase(adev->platform);
802 else
803 platform_stop_incall_music_usecase(adev->platform);
Vidyakumar Athota8d931f02014-07-21 14:51:44 -0700804 }
Vidyakumar Athota2850d532013-11-19 16:02:12 -0800805
Shiv Maliyappanahalli34b585f2013-10-01 15:49:05 -0700806done:
807 ALOGV("%s: exit with code(%d)", __func__, ret);
Krishnankutty Kolathappilly061a9492014-01-31 18:12:13 -0800808 free(kv_pairs);
Shiv Maliyappanahalli34b585f2013-10-01 15:49:05 -0700809 return ret;
810}
811
812void voice_init(struct audio_device *adev)
813{
814 int i = 0;
Weiyin Jiang095e4442019-07-15 11:49:15 +0800815 int max_voice_sessions = MAX_VOICE_SESSIONS;
816
817 if (!voice_extn_is_multi_session_supported())
818 max_voice_sessions = 1;
Shiv Maliyappanahalli34b585f2013-10-01 15:49:05 -0700819
820 memset(&adev->voice, 0, sizeof(adev->voice));
821 adev->voice.tty_mode = TTY_MODE_OFF;
Aalique Grahame22e49102018-12-18 14:23:57 -0800822 adev->voice.hac = false;
Shiv Maliyappanahalli34b585f2013-10-01 15:49:05 -0700823 adev->voice.volume = 1.0f;
824 adev->voice.mic_mute = false;
Vidyakumar Athotaad34d572014-08-05 18:20:42 -0700825 adev->voice.in_call = false;
Weiyin Jiang095e4442019-07-15 11:49:15 +0800826 for (i = 0; i < max_voice_sessions; i++) {
Shiv Maliyappanahalli34b585f2013-10-01 15:49:05 -0700827 adev->voice.session[i].pcm_rx = NULL;
828 adev->voice.session[i].pcm_tx = NULL;
829 adev->voice.session[i].state.current = CALL_INACTIVE;
830 adev->voice.session[i].state.new = CALL_INACTIVE;
Ravi Kumar Alamandabdf14162014-09-05 16:14:17 -0700831 adev->voice.session[i].vsid = VOICE_VSID;
Shiv Maliyappanahalli34b585f2013-10-01 15:49:05 -0700832 }
833
834 voice_extn_init(adev);
835}
836
Narsinga Rao Chella22d8d7a2014-02-06 14:05:14 -0800837void voice_update_devices_for_all_voice_usecases(struct audio_device *adev)
838{
839 struct listnode *node;
840 struct audio_usecase *usecase;
841
842 list_for_each(node, &adev->usecase_list) {
843 usecase = node_to_item(node, struct audio_usecase, list);
844 if (usecase->type == VOICE_CALL) {
845 ALOGV("%s: updating device for usecase:%s", __func__,
846 use_case_table[usecase->id]);
Ravi Kumar Alamanda060bc5a2014-09-05 13:51:35 -0700847 usecase->stream.out = adev->current_call_output;
Narsinga Rao Chella22d8d7a2014-02-06 14:05:14 -0800848 select_devices(adev, usecase->id);
849 }
850 }
851}
852
Shiv Maliyappanahalli34b585f2013-10-01 15:49:05 -0700853