blob: 1f0978a8de1f984d770f99e85c3bcc7eec288b81 [file] [log] [blame]
Shiv Maliyappanahalli34b585f2013-10-01 15:49:05 -07001/*
Jaideep Sharma477917f2020-03-13 18:13:33 +05302 * Copyright (c) 2013-2020, 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
Kunlei Zhange7cab1a2020-05-17 20:31:05 +080066struct power_mode_cfg {
67 bool enable;
68 char *mixer_ctl;
69};
70
71struct island_cfg {
72 bool enable;
73 char *mixer_ctl;
74};
75
Vidyakumar Athota2850d532013-11-19 16:02:12 -080076enum {
77 INCALL_REC_NONE = -1,
78 INCALL_REC_UPLINK,
79 INCALL_REC_DOWNLINK,
80 INCALL_REC_UPLINK_AND_DOWNLINK,
81};
82
Ravi Kumar Alamanda263d80c2014-08-20 16:24:38 -070083int voice_start_usecase(struct audio_device *adev, audio_usecase_t usecase_id);
84int voice_stop_usecase(struct audio_device *adev, audio_usecase_t usecase_id);
85
Shiv Maliyappanahalli34b585f2013-10-01 15:49:05 -070086int voice_start_call(struct audio_device *adev);
87int voice_stop_call(struct audio_device *adev);
88int voice_set_parameters(struct audio_device *adev, struct str_parms *parms);
Shiv Maliyappanahallif9308492013-12-12 12:18:09 -080089void voice_get_parameters(struct audio_device *adev, struct str_parms *query,
90 struct str_parms *reply);
Shiv Maliyappanahalli34b585f2013-10-01 15:49:05 -070091void voice_init(struct audio_device *adev);
Alexy Josephb1379942016-01-29 15:49:38 -080092bool voice_is_in_call(const struct audio_device *adev);
Jaideep Sharma477917f2020-03-13 18:13:33 +053093bool voice_is_in_call_or_call_screen(const struct audio_device *adev);
Alexy Josephb1379942016-01-29 15:49:38 -080094bool voice_is_in_call_rec_stream(const struct stream_in *in);
Shiv Maliyappanahalli34b585f2013-10-01 15:49:05 -070095int voice_set_mic_mute(struct audio_device *dev, bool state);
96bool voice_get_mic_mute(struct audio_device *dev);
97int voice_set_volume(struct audio_device *adev, float volume);
Shiv Maliyappanahallida107642013-10-17 11:16:13 -070098int voice_check_and_set_incall_rec_usecase(struct audio_device *adev,
Shiv Maliyappanahallif3b9a422013-10-22 16:38:08 -070099 struct stream_in *in);
100int voice_check_and_set_incall_music_usecase(struct audio_device *adev,
101 struct stream_out *out);
Vidyakumar Athota2850d532013-11-19 16:02:12 -0800102int voice_check_and_stop_incall_rec_usecase(struct audio_device *adev,
103 struct stream_in *in);
Narsinga Rao Chella22d8d7a2014-02-06 14:05:14 -0800104void voice_update_devices_for_all_voice_usecases(struct audio_device *adev);
Narsinga Rao Chella212e2542014-11-17 19:57:04 -0800105snd_device_t voice_get_incall_rec_snd_device(snd_device_t in_snd_device);
Bhalchandra Gajare45fee282015-06-09 22:23:45 -0700106void voice_set_sidetone(struct audio_device *adev,
107 snd_device_t out_snd_device,
108 bool enable);
Vidyakumar Athotaea269c62016-10-31 09:05:59 -0700109void voice_check_and_update_aanc_path(struct audio_device *adev,
110 snd_device_t out_snd_device,
111 bool enable);
Bhalchandra Gajare45fee282015-06-09 22:23:45 -0700112bool voice_is_call_state_active(struct audio_device *adev);
Jaideep Sharma477917f2020-03-13 18:13:33 +0530113bool voice_is_call_state_active_in_call(struct audio_device *adev);
Arun Mirpurief53ce52018-09-11 18:00:09 -0700114void voice_set_device_mute_flag (struct audio_device *adev, bool state);
Divya Narayanan Poojary85d0a592018-02-06 14:25:16 +0530115snd_device_t voice_get_incall_rec_backend_device(struct stream_in *in);
Kunlei Zhanga3b3abf2019-06-25 15:42:21 +0800116bool voice_check_voicecall_usecases_active(struct audio_device *adev);
Shiv Maliyappanahalli34b585f2013-10-01 15:49:05 -0700117#endif //VOICE_H