blob: 09cb926f50bb3c81b6569e69cf7be3c3b9d5c1a5 [file] [log] [blame]
Vineeta Srivastava4b89e372014-06-19 14:21:42 -07001/*
2 * Copyright (C) 2014 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17#define LOG_TAG "voice"
18/*#define LOG_NDEBUG 0*/
19#define LOG_NDDEBUG 0
20
Vineeta Srivastava7c685a12015-03-20 15:34:33 -070021#include <stdlib.h>
Vineeta Srivastava4b89e372014-06-19 14:21:42 -070022#include <errno.h>
23#include <math.h>
Haynes Mathew Georgee6e2d442018-02-22 18:51:56 -080024#include <log/log.h>
Vineeta Srivastava4b89e372014-06-19 14:21:42 -070025#include <cutils/str_parms.h>
26
27#include "audio_hw.h"
28#include "voice.h"
29#include "voice_extn/voice_extn.h"
30#include "platform.h"
31#include "platform_api.h"
Alain Vongsouvanh13f26e82016-11-18 14:39:11 -080032#include "audio_extn/tfa_98xx.h"
Vineeta Srivastava4b89e372014-06-19 14:21:42 -070033
34struct pcm_config pcm_config_voice_call = {
35 .channels = 1,
36 .rate = 8000,
37 .period_size = 160,
38 .period_count = 2,
39 .format = PCM_FORMAT_S16_LE,
40};
41
Vineeta Srivastava4b89e372014-06-19 14:21:42 -070042static struct voice_session *voice_get_session_from_use_case(struct audio_device *adev,
43 audio_usecase_t usecase_id)
44{
45 struct voice_session *session = NULL;
46 int ret = 0;
47
48 ret = voice_extn_get_session_from_use_case(adev, usecase_id, &session);
49 if (ret == -ENOSYS) {
50 session = &adev->voice.session[VOICE_SESS_IDX];
51 }
52
53 return session;
54}
55
vivek mehta765eb642015-08-07 19:46:06 -070056static bool voice_is_sidetone_device(snd_device_t out_device,
57 char *mixer_path)
58{
59 bool is_sidetone_dev = true;
60
61 switch (out_device) {
62 case SND_DEVICE_OUT_VOICE_HAC_HANDSET:
63 strlcpy(mixer_path, "sidetone-hac-handset", MIXER_PATH_MAX_LENGTH);
64 break;
65 case SND_DEVICE_OUT_VOICE_HANDSET:
66 strlcpy(mixer_path, "sidetone-handset", MIXER_PATH_MAX_LENGTH);
67 break;
68 case SND_DEVICE_OUT_VOICE_HEADPHONES:
yixuanjiang9536e672018-09-06 18:43:36 +080069 case SND_DEVICE_OUT_VOICE_HEADSET:
vivek mehta765eb642015-08-07 19:46:06 -070070 strlcpy(mixer_path, "sidetone-headphones", MIXER_PATH_MAX_LENGTH);
71 break;
vivek mehta90933872017-06-15 18:04:39 -070072 case SND_DEVICE_OUT_VOICE_USB_HEADSET:
73 case SND_DEVICE_OUT_USB_HEADSET:
74 // USB does not use a QC mixer.
75 mixer_path[0] = '\0';
76 break;
vivek mehta765eb642015-08-07 19:46:06 -070077 default:
vivek mehta90933872017-06-15 18:04:39 -070078 ALOGW("%s: %d is not a sidetone device", __func__, out_device);
vivek mehta765eb642015-08-07 19:46:06 -070079 is_sidetone_dev = false;
80 break;
81 }
82
83 return is_sidetone_dev;
84}
85
86void voice_set_sidetone(struct audio_device *adev,
87 snd_device_t out_snd_device, bool enable)
88{
89 char mixer_path[MIXER_PATH_MAX_LENGTH];
90 bool is_sidetone_dev;
91
92 ALOGD("%s: %s, out_snd_device: %d\n",
93 __func__, (enable ? "enable" : "disable"),
94 out_snd_device);
95
vivek mehta90933872017-06-15 18:04:39 -070096 if (voice_is_sidetone_device(out_snd_device, mixer_path))
97 platform_set_sidetone(adev, out_snd_device, enable, mixer_path);
vivek mehta765eb642015-08-07 19:46:06 -070098
99 return;
100}
101
Ravi Kumar Alamanda08dbcfc2014-08-20 16:24:38 -0700102int voice_stop_usecase(struct audio_device *adev, audio_usecase_t usecase_id)
Vineeta Srivastava4b89e372014-06-19 14:21:42 -0700103{
104 int i, ret = 0;
105 struct audio_usecase *uc_info;
106 struct voice_session *session = NULL;
107
108 ALOGD("%s: enter usecase:%s", __func__, use_case_table[usecase_id]);
109
110 session = (struct voice_session *)voice_get_session_from_use_case(adev, usecase_id);
vivek mehta765eb642015-08-07 19:46:06 -0700111
112 uc_info = get_usecase_from_list(adev, usecase_id);
113 if (uc_info == NULL) {
114 ALOGE("%s: Could not find the usecase (%d) in the list",
115 __func__, usecase_id);
116 return -EINVAL;
117 }
118
Vineeta Srivastava4b89e372014-06-19 14:21:42 -0700119 session->state.current = CALL_INACTIVE;
120
vivek mehta765eb642015-08-07 19:46:06 -0700121 /* Disable sidetone only when no calls are active */
Vineeta Srivastava6ed310d2016-08-03 11:56:35 -0700122 if (!voice_is_call_state_active(adev))
vivek mehta765eb642015-08-07 19:46:06 -0700123 voice_set_sidetone(adev, uc_info->out_snd_device, false);
124
Vineeta Srivastava4b89e372014-06-19 14:21:42 -0700125 ret = platform_stop_voice_call(adev->platform, session->vsid);
126
127 /* 1. Close the PCM devices */
128 if (session->pcm_rx) {
129 pcm_close(session->pcm_rx);
130 session->pcm_rx = NULL;
131 }
132 if (session->pcm_tx) {
133 pcm_close(session->pcm_tx);
134 session->pcm_tx = NULL;
135 }
136
Vineeta Srivastava4b89e372014-06-19 14:21:42 -0700137 /* 2. Get and set stream specific mixer controls */
138 disable_audio_route(adev, uc_info);
139
140 /* 3. Disable the rx and tx devices */
141 disable_snd_device(adev, uc_info->out_snd_device);
142 disable_snd_device(adev, uc_info->in_snd_device);
143
Alain Vongsouvanh13f26e82016-11-18 14:39:11 -0800144 if (audio_extn_tfa_98xx_is_supported() && voice_get_mic_mute(adev)) {
145 voice_set_mic_mute(adev, false);
146 ALOGD("%s: unMute voice Tx", __func__);
147 }
148
Vineeta Srivastava4b89e372014-06-19 14:21:42 -0700149 list_remove(&uc_info->list);
150 free(uc_info);
151
152 ALOGD("%s: exit: status(%d)", __func__, ret);
153 return ret;
154}
155
Eric Laurent75a2e1d2014-08-29 12:38:47 -0700156int voice_start_usecase(struct audio_device *adev, audio_usecase_t usecase_id)
Vineeta Srivastava4b89e372014-06-19 14:21:42 -0700157{
158 int i, ret = 0;
159 struct audio_usecase *uc_info;
160 int pcm_dev_rx_id, pcm_dev_tx_id;
Vineeta Srivastava4b89e372014-06-19 14:21:42 -0700161 struct voice_session *session = NULL;
162 struct pcm_config voice_config = pcm_config_voice_call;
163
164 ALOGD("%s: enter usecase:%s", __func__, use_case_table[usecase_id]);
165
166 session = (struct voice_session *)voice_get_session_from_use_case(adev, usecase_id);
167 uc_info = (struct audio_usecase *)calloc(1, sizeof(struct audio_usecase));
168 uc_info->id = usecase_id;
169 uc_info->type = VOICE_CALL;
Eric Laurent75a2e1d2014-08-29 12:38:47 -0700170 uc_info->stream.out = adev->current_call_output ;
171 uc_info->devices = adev->current_call_output ->devices;
Vineeta Srivastava4b89e372014-06-19 14:21:42 -0700172 uc_info->in_snd_device = SND_DEVICE_NONE;
173 uc_info->out_snd_device = SND_DEVICE_NONE;
174
175 list_add_tail(&adev->usecase_list, &uc_info->list);
176
177 select_devices(adev, usecase_id);
178
179 pcm_dev_rx_id = platform_get_pcm_device_id(uc_info->id, PCM_PLAYBACK);
180 pcm_dev_tx_id = platform_get_pcm_device_id(uc_info->id, PCM_CAPTURE);
181
182 if (pcm_dev_rx_id < 0 || pcm_dev_tx_id < 0) {
183 ALOGE("%s: Invalid PCM devices (rx: %d tx: %d) for the usecase(%d)",
184 __func__, pcm_dev_rx_id, pcm_dev_tx_id, uc_info->id);
185 ret = -EIO;
186 goto error_start_voice;
187 }
Vineeta Srivastava4b89e372014-06-19 14:21:42 -0700188
vivek mehta765eb642015-08-07 19:46:06 -0700189 ALOGV("%s: Opening PCM capture device card_id(%d) device_id(%d)",
190 __func__, adev->snd_card, pcm_dev_tx_id);
191 session->pcm_tx = pcm_open(adev->snd_card,
192 pcm_dev_tx_id,
193 PCM_IN, &voice_config);
194 if (session->pcm_tx && !pcm_is_ready(session->pcm_tx)) {
195 ALOGE("%s: %s", __func__, pcm_get_error(session->pcm_tx));
196 ret = -EIO;
197 goto error_start_voice;
198 }
199
Vineeta Srivastava4b89e372014-06-19 14:21:42 -0700200 ALOGV("%s: Opening PCM playback device card_id(%d) device_id(%d)",
201 __func__, adev->snd_card, pcm_dev_rx_id);
202 session->pcm_rx = pcm_open(adev->snd_card,
203 pcm_dev_rx_id,
204 PCM_OUT, &voice_config);
205 if (session->pcm_rx && !pcm_is_ready(session->pcm_rx)) {
206 ALOGE("%s: %s", __func__, pcm_get_error(session->pcm_rx));
207 ret = -EIO;
208 goto error_start_voice;
209 }
210
Vignesh Kulothunganb6f0a9c2018-03-22 13:50:22 -0700211 if (adev->mic_break_enabled)
212 platform_set_mic_break_det(adev->platform, true);
213
Vineeta Srivastava4b89e372014-06-19 14:21:42 -0700214 pcm_start(session->pcm_tx);
vivek mehta765eb642015-08-07 19:46:06 -0700215 pcm_start(session->pcm_rx);
216
Alain Vongsouvanh13f26e82016-11-18 14:39:11 -0800217 audio_extn_tfa_98xx_enable_speaker();
218
vivek mehta765eb642015-08-07 19:46:06 -0700219 /* Enable sidetone only when no calls are already active */
220 if (!voice_is_call_state_active(adev))
221 voice_set_sidetone(adev, uc_info->out_snd_device, true);
Vineeta Srivastava4b89e372014-06-19 14:21:42 -0700222
223 voice_set_volume(adev, adev->voice.volume);
224
225 ret = platform_start_voice_call(adev->platform, session->vsid);
226 if (ret < 0) {
227 ALOGE("%s: platform_start_voice_call error %d\n", __func__, ret);
228 goto error_start_voice;
229 }
230
231 session->state.current = CALL_ACTIVE;
Ravi Kumar Alamandaf1819242014-08-05 18:20:42 -0700232 goto done;
Vineeta Srivastava4b89e372014-06-19 14:21:42 -0700233
234error_start_voice:
Ravi Kumar Alamanda08dbcfc2014-08-20 16:24:38 -0700235 voice_stop_usecase(adev, usecase_id);
Vineeta Srivastava4b89e372014-06-19 14:21:42 -0700236
Ravi Kumar Alamandaf1819242014-08-05 18:20:42 -0700237done:
Vineeta Srivastava4b89e372014-06-19 14:21:42 -0700238 ALOGD("%s: exit: status(%d)", __func__, ret);
239 return ret;
240}
241
Ravi Kumar Alamandaf1819242014-08-05 18:20:42 -0700242bool voice_is_call_state_active(struct audio_device *adev)
Vineeta Srivastava4b89e372014-06-19 14:21:42 -0700243{
Ravi Kumar Alamandaf1819242014-08-05 18:20:42 -0700244 bool call_state = false;
Vineeta Srivastava4b89e372014-06-19 14:21:42 -0700245 int ret = 0;
246
Ravi Kumar Alamandaf1819242014-08-05 18:20:42 -0700247 ret = voice_extn_is_call_state_active(adev, &call_state);
Vineeta Srivastava4b89e372014-06-19 14:21:42 -0700248 if (ret == -ENOSYS) {
Ravi Kumar Alamandaf1819242014-08-05 18:20:42 -0700249 call_state = (adev->voice.session[VOICE_SESS_IDX].state.current == CALL_ACTIVE) ? true : false;
Vineeta Srivastava4b89e372014-06-19 14:21:42 -0700250 }
251
Ravi Kumar Alamandaf1819242014-08-05 18:20:42 -0700252 return call_state;
253}
254
255bool voice_is_in_call(struct audio_device *adev)
256{
257 return adev->voice.in_call;
Vineeta Srivastava4b89e372014-06-19 14:21:42 -0700258}
259
260bool voice_is_in_call_rec_stream(struct stream_in *in)
261{
262 bool in_call_rec = false;
263 int ret = 0;
264
265 ret = voice_extn_is_in_call_rec_stream(in, &in_call_rec);
266 if (ret == -ENOSYS) {
267 in_call_rec = false;
268 }
269
270 return in_call_rec;
271}
272
273uint32_t voice_get_active_session_id(struct audio_device *adev)
274{
275 int ret = 0;
276 uint32_t session_id;
277
278 ret = voice_extn_get_active_session_id(adev, &session_id);
279 if (ret == -ENOSYS) {
280 session_id = VOICE_VSID;
281 }
282 return session_id;
283}
284
285int voice_check_and_set_incall_rec_usecase(struct audio_device *adev,
286 struct stream_in *in)
287{
288 int ret = 0;
289 uint32_t session_id;
290 int usecase_id;
291 int rec_mode = INCALL_REC_NONE;
292
Ravi Kumar Alamandaf1819242014-08-05 18:20:42 -0700293 if (voice_is_call_state_active(adev)) {
Vineeta Srivastava4b89e372014-06-19 14:21:42 -0700294 switch (in->source) {
295 case AUDIO_SOURCE_VOICE_UPLINK:
296 in->usecase = USECASE_INCALL_REC_UPLINK;
297 rec_mode = INCALL_REC_UPLINK;
298 break;
299 case AUDIO_SOURCE_VOICE_DOWNLINK:
300 in->usecase = USECASE_INCALL_REC_DOWNLINK;
301 rec_mode = INCALL_REC_DOWNLINK;
302 break;
303 case AUDIO_SOURCE_VOICE_CALL:
304 in->usecase = USECASE_INCALL_REC_UPLINK_AND_DOWNLINK;
305 rec_mode = INCALL_REC_UPLINK_AND_DOWNLINK;
306 break;
307 default:
308 ALOGV("%s: Source type %d doesnt match incall recording criteria",
309 __func__, in->source);
310 return ret;
311 }
312
313 session_id = voice_get_active_session_id(adev);
314 ret = platform_set_incall_recording_session_id(adev->platform,
315 session_id, rec_mode);
Arun Mirpuriba2749a2018-04-17 14:32:24 -0700316#ifdef INCALL_STEREO_CAPTURE_ENABLED
317 ret = platform_set_incall_recording_session_channels(adev->platform,
318 in->config.channels);
319#endif
Vineeta Srivastava4b89e372014-06-19 14:21:42 -0700320 ALOGV("%s: Update usecase to %d",__func__, in->usecase);
321 } else {
322 ALOGV("%s: voice call not active", __func__);
323 }
324
325 return ret;
326}
327
328int voice_check_and_stop_incall_rec_usecase(struct audio_device *adev,
329 struct stream_in *in)
330{
331 int ret = 0;
332
333 if (in->source == AUDIO_SOURCE_VOICE_UPLINK ||
334 in->source == AUDIO_SOURCE_VOICE_DOWNLINK ||
335 in->source == AUDIO_SOURCE_VOICE_CALL) {
336 ret = platform_stop_incall_recording_usecase(adev->platform);
337 ALOGV("%s: Stop In-call recording", __func__);
338 }
339
340 return ret;
341}
342
343int voice_check_and_set_incall_music_usecase(struct audio_device *adev,
344 struct stream_out *out)
345{
346 int ret = 0;
347
348 ret = voice_extn_check_and_set_incall_music_usecase(adev, out);
349 if (ret == -ENOSYS) {
350 /* Incall music delivery is used only for LCH call state */
351 ret = -EINVAL;
352 }
353
354 return ret;
355}
356
357int voice_set_mic_mute(struct audio_device *adev, bool state)
358{
359 int err = 0;
360
361 adev->voice.mic_mute = state;
Uday Kishore Pasupuletia1f48052015-09-08 22:49:18 +0900362 if (adev->mode == AUDIO_MODE_IN_CALL ||
363 adev->mode == AUDIO_MODE_IN_COMMUNICATION)
Vineeta Srivastava4b89e372014-06-19 14:21:42 -0700364 err = platform_set_mic_mute(adev->platform, state);
365
366 return err;
367}
368
369bool voice_get_mic_mute(struct audio_device *adev)
370{
371 return adev->voice.mic_mute;
372}
373
374int voice_set_volume(struct audio_device *adev, float volume)
375{
376 int vol, err = 0;
377
378 adev->voice.volume = volume;
379 if (adev->mode == AUDIO_MODE_IN_CALL) {
380 if (volume < 0.0) {
381 volume = 0.0;
382 } else if (volume > 1.0) {
383 volume = 1.0;
384 }
385
386 vol = lrint(volume * 100.0);
387
388 // Voice volume levels from android are mapped to driver volume levels as follows.
389 // 0 -> 5, 20 -> 4, 40 ->3, 60 -> 2, 80 -> 1, 100 -> 0
390 // So adjust the volume to get the correct volume index in driver
391 vol = 100 - vol;
392
393 err = platform_set_voice_volume(adev->platform, vol);
394 }
395
396 return err;
397}
398
Eric Laurent75a2e1d2014-08-29 12:38:47 -0700399int voice_start_call(struct audio_device *adev)
Vineeta Srivastava4b89e372014-06-19 14:21:42 -0700400{
401 int ret = 0;
402
Ravi Kumar Alamandab09e4a02014-10-20 17:07:43 -0700403 adev->voice.in_call = true;
Ravi Kumar Alamandaeecfa9a2015-03-20 17:31:46 -0700404
405 voice_set_mic_mute(adev, adev->voice.mic_mute);
406
Vineeta Srivastava4b89e372014-06-19 14:21:42 -0700407 ret = voice_extn_start_call(adev);
408 if (ret == -ENOSYS) {
Eric Laurent75a2e1d2014-08-29 12:38:47 -0700409 ret = voice_start_usecase(adev, USECASE_VOICE_CALL);
Vineeta Srivastava4b89e372014-06-19 14:21:42 -0700410 }
411
412 return ret;
413}
414
415int voice_stop_call(struct audio_device *adev)
416{
417 int ret = 0;
418
Ravi Kumar Alamandaf1819242014-08-05 18:20:42 -0700419 adev->voice.in_call = false;
Vineeta Srivastava4b89e372014-06-19 14:21:42 -0700420 ret = voice_extn_stop_call(adev);
421 if (ret == -ENOSYS) {
Ravi Kumar Alamanda08dbcfc2014-08-20 16:24:38 -0700422 ret = voice_stop_usecase(adev, USECASE_VOICE_CALL);
Vineeta Srivastava4b89e372014-06-19 14:21:42 -0700423 }
424
425 return ret;
426}
427
428void voice_get_parameters(struct audio_device *adev,
429 struct str_parms *query,
430 struct str_parms *reply)
431{
432 voice_extn_get_parameters(adev, query, reply);
433}
434
435int voice_set_parameters(struct audio_device *adev, struct str_parms *parms)
436{
437 char *str;
438 char value[32];
439 int val;
440 int ret = 0, err;
441 char *kv_pairs = str_parms_to_str(parms);
442
443 ALOGV_IF(kv_pairs != NULL, "%s: enter: %s", __func__, kv_pairs);
444
445 ret = voice_extn_set_parameters(adev, parms);
Haynes Mathew Georgeff5d6512014-07-18 15:31:44 -0700446 if (ret != 0) {
447 if (ret == -ENOSYS) {
448 ret = 0; /* ignore error */
449 } else {
450 goto done;
451 }
452 }
Vineeta Srivastava4b89e372014-06-19 14:21:42 -0700453
454 err = str_parms_get_str(parms, AUDIO_PARAMETER_KEY_TTY_MODE, value, sizeof(value));
455 if (err >= 0) {
456 int tty_mode;
457 str_parms_del(parms, AUDIO_PARAMETER_KEY_TTY_MODE);
458 if (strcmp(value, AUDIO_PARAMETER_VALUE_TTY_OFF) == 0)
459 tty_mode = TTY_MODE_OFF;
460 else if (strcmp(value, AUDIO_PARAMETER_VALUE_TTY_VCO) == 0)
461 tty_mode = TTY_MODE_VCO;
462 else if (strcmp(value, AUDIO_PARAMETER_VALUE_TTY_HCO) == 0)
463 tty_mode = TTY_MODE_HCO;
464 else if (strcmp(value, AUDIO_PARAMETER_VALUE_TTY_FULL) == 0)
465 tty_mode = TTY_MODE_FULL;
466 else {
467 ret = -EINVAL;
468 goto done;
469 }
470
471 if (tty_mode != adev->voice.tty_mode) {
472 adev->voice.tty_mode = tty_mode;
473 adev->acdb_settings = (adev->acdb_settings & TTY_MODE_CLEAR) | tty_mode;
Ravi Kumar Alamandaf1819242014-08-05 18:20:42 -0700474 if (voice_is_call_state_active(adev))
Vineeta Srivastava4b89e372014-06-19 14:21:42 -0700475 voice_update_devices_for_all_voice_usecases(adev);
476 }
477 }
478
Eric Laurent9d0d3f12014-07-25 12:40:29 -0500479 err = str_parms_get_str(parms, AUDIO_PARAMETER_KEY_HAC,
480 value, sizeof(value));
481 if (err >= 0) {
482 bool hac = false;
483 str_parms_del(parms, AUDIO_PARAMETER_KEY_HAC);
484 if (strcmp(value, AUDIO_PARAMETER_VALUE_HAC_ON) == 0)
485 hac = true;
486
487 if (hac != adev->voice.hac) {
488 adev->voice.hac = hac;
489 if (voice_is_in_call(adev))
490 voice_update_devices_for_all_voice_usecases(adev);
491 }
492 }
493
Vineeta Srivastava4b89e372014-06-19 14:21:42 -0700494 err = str_parms_get_str(parms, AUDIO_PARAMETER_KEY_INCALLMUSIC,
495 value, sizeof(value));
496 if (err >= 0) {
497 str_parms_del(parms, AUDIO_PARAMETER_KEY_INCALLMUSIC);
498 if (strcmp(value, AUDIO_PARAMETER_VALUE_TRUE) == 0)
499 platform_start_incall_music_usecase(adev->platform);
500 else
501 platform_stop_incall_music_usecase(adev->platform);
502 }
503
504done:
505 ALOGV("%s: exit with code(%d)", __func__, ret);
506 free(kv_pairs);
507 return ret;
508}
509
510void voice_init(struct audio_device *adev)
511{
512 int i = 0;
513
514 memset(&adev->voice, 0, sizeof(adev->voice));
515 adev->voice.tty_mode = TTY_MODE_OFF;
Eric Laurent9d0d3f12014-07-25 12:40:29 -0500516 adev->voice.hac = false;
Vineeta Srivastava4b89e372014-06-19 14:21:42 -0700517 adev->voice.volume = 1.0f;
518 adev->voice.mic_mute = false;
Ravi Kumar Alamandaf1819242014-08-05 18:20:42 -0700519 adev->voice.in_call = false;
Vineeta Srivastava4b89e372014-06-19 14:21:42 -0700520 for (i = 0; i < MAX_VOICE_SESSIONS; i++) {
521 adev->voice.session[i].pcm_rx = NULL;
522 adev->voice.session[i].pcm_tx = NULL;
523 adev->voice.session[i].state.current = CALL_INACTIVE;
524 adev->voice.session[i].state.new = CALL_INACTIVE;
525 adev->voice.session[i].vsid = VOICE_VSID;
526 }
527
528 voice_extn_init(adev);
529}
530
531void voice_update_devices_for_all_voice_usecases(struct audio_device *adev)
532{
533 struct listnode *node;
534 struct audio_usecase *usecase;
535
536 list_for_each(node, &adev->usecase_list) {
537 usecase = node_to_item(node, struct audio_usecase, list);
538 if (usecase->type == VOICE_CALL) {
539 ALOGV("%s: updating device for usecase:%s", __func__,
540 use_case_table[usecase->id]);
Ravi Kumar Alamandaa4fc9022014-10-08 18:57:46 -0700541 usecase->stream.out = adev->current_call_output;
Vineeta Srivastava4b89e372014-06-19 14:21:42 -0700542 select_devices(adev, usecase->id);
Alain Vongsouvanh13f26e82016-11-18 14:39:11 -0800543 audio_extn_tfa_98xx_update();
Vineeta Srivastava4b89e372014-06-19 14:21:42 -0700544 }
545 }
546}
547
548