blob: 9612eddd197754cbbe9a02f9d10a6ccf85182d51 [file] [log] [blame]
Shiv Maliyappanahalli34b585f2013-10-01 15:49:05 -07001/*
Aalique Grahame22e49102018-12-18 14:23:57 -08002 * Copyright (c) 2013-2019, The Linux Foundation. All rights reserved.
Shiv Maliyappanahalli34b585f2013-10-01 15:49:05 -07003 * Not a contribution.
4 *
5 * Copyright (C) 2013 The Android Open Source Project
6 *
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#ifndef VOICE_H
21#define VOICE_H
22
23#define BASE_SESS_IDX 0
24#define VOICE_SESS_IDX (BASE_SESS_IDX)
25
Vidyakumar Athota0e109352015-02-12 17:38:22 -080026#define MAX_VOICE_SESSIONS 7
Shiv Maliyappanahalli34b585f2013-10-01 15:49:05 -070027
28#define BASE_CALL_STATE 1
29#define CALL_INACTIVE (BASE_CALL_STATE)
30#define CALL_ACTIVE (BASE_CALL_STATE + 1)
31
32#define VOICE_VSID 0x10C01000
33
Vidyakumar Athota2850d532013-11-19 16:02:12 -080034#define AUDIO_PARAMETER_KEY_INCALLMUSIC "incall_music_enabled"
35#define AUDIO_PARAMETER_VALUE_TRUE "true"
36
Shiv Maliyappanahalli34b585f2013-10-01 15:49:05 -070037struct audio_device;
38struct str_parms;
Shiv Maliyappanahallida107642013-10-17 11:16:13 -070039struct stream_in;
Shiv Maliyappanahallif3b9a422013-10-22 16:38:08 -070040struct stream_out;
Ravi Kumar Alamanda263d80c2014-08-20 16:24:38 -070041typedef int audio_usecase_t;
Narsinga Rao Chella212e2542014-11-17 19:57:04 -080042typedef int snd_device_t;
Shiv Maliyappanahalli34b585f2013-10-01 15:49:05 -070043
44struct call_state {
45 int current;
46 int new;
47};
48
49struct voice_session {
50 struct pcm *pcm_rx;
51 struct pcm *pcm_tx;
52 struct call_state state;
53 uint32_t vsid;
54};
55
56struct voice {
57 struct voice_session session[MAX_VOICE_SESSIONS];
58 int tty_mode;
Aalique Grahame22e49102018-12-18 14:23:57 -080059 bool hac;
Shiv Maliyappanahalli34b585f2013-10-01 15:49:05 -070060 bool mic_mute;
Arun Mirpurief53ce52018-09-11 18:00:09 -070061 bool use_device_mute;
Shiv Maliyappanahalli34b585f2013-10-01 15:49:05 -070062 float volume;
Vidyakumar Athotaad34d572014-08-05 18:20:42 -070063 bool in_call;
Shiv Maliyappanahalli34b585f2013-10-01 15:49:05 -070064};
65
Vidyakumar Athota2850d532013-11-19 16:02:12 -080066enum {
67 INCALL_REC_NONE = -1,
68 INCALL_REC_UPLINK,
69 INCALL_REC_DOWNLINK,
70 INCALL_REC_UPLINK_AND_DOWNLINK,
71};
72
Ravi Kumar Alamanda263d80c2014-08-20 16:24:38 -070073int voice_start_usecase(struct audio_device *adev, audio_usecase_t usecase_id);
74int voice_stop_usecase(struct audio_device *adev, audio_usecase_t usecase_id);
75
Shiv Maliyappanahalli34b585f2013-10-01 15:49:05 -070076int voice_start_call(struct audio_device *adev);
77int voice_stop_call(struct audio_device *adev);
78int voice_set_parameters(struct audio_device *adev, struct str_parms *parms);
Shiv Maliyappanahallif9308492013-12-12 12:18:09 -080079void voice_get_parameters(struct audio_device *adev, struct str_parms *query,
80 struct str_parms *reply);
Shiv Maliyappanahalli34b585f2013-10-01 15:49:05 -070081void voice_init(struct audio_device *adev);
Alexy Josephb1379942016-01-29 15:49:38 -080082bool voice_is_in_call(const struct audio_device *adev);
83bool voice_is_in_call_rec_stream(const struct stream_in *in);
Shiv Maliyappanahalli34b585f2013-10-01 15:49:05 -070084int voice_set_mic_mute(struct audio_device *dev, bool state);
85bool voice_get_mic_mute(struct audio_device *dev);
86int voice_set_volume(struct audio_device *adev, float volume);
Shiv Maliyappanahallida107642013-10-17 11:16:13 -070087int voice_check_and_set_incall_rec_usecase(struct audio_device *adev,
Shiv Maliyappanahallif3b9a422013-10-22 16:38:08 -070088 struct stream_in *in);
89int voice_check_and_set_incall_music_usecase(struct audio_device *adev,
90 struct stream_out *out);
Vidyakumar Athota2850d532013-11-19 16:02:12 -080091int voice_check_and_stop_incall_rec_usecase(struct audio_device *adev,
92 struct stream_in *in);
Narsinga Rao Chella22d8d7a2014-02-06 14:05:14 -080093void voice_update_devices_for_all_voice_usecases(struct audio_device *adev);
Narsinga Rao Chella212e2542014-11-17 19:57:04 -080094snd_device_t voice_get_incall_rec_snd_device(snd_device_t in_snd_device);
Bhalchandra Gajare45fee282015-06-09 22:23:45 -070095void voice_set_sidetone(struct audio_device *adev,
96 snd_device_t out_snd_device,
97 bool enable);
Vidyakumar Athotaea269c62016-10-31 09:05:59 -070098void voice_check_and_update_aanc_path(struct audio_device *adev,
99 snd_device_t out_snd_device,
100 bool enable);
Bhalchandra Gajare45fee282015-06-09 22:23:45 -0700101bool voice_is_call_state_active(struct audio_device *adev);
Arun Mirpurief53ce52018-09-11 18:00:09 -0700102void voice_set_device_mute_flag (struct audio_device *adev, bool state);
Divya Narayanan Poojary85d0a592018-02-06 14:25:16 +0530103snd_device_t voice_get_incall_rec_backend_device(struct stream_in *in);
Shiv Maliyappanahalli34b585f2013-10-01 15:49:05 -0700104#endif //VOICE_H