Shiv Maliyappanahalli | 34b585f | 2013-10-01 15:49:05 -0700 | [diff] [blame] | 1 | /* |
Jaideep Sharma | 477917f | 2020-03-13 18:13:33 +0530 | [diff] [blame] | 2 | * Copyright (c) 2013-2020, The Linux Foundation. All rights reserved. |
Shiv Maliyappanahalli | 34b585f | 2013-10-01 15:49:05 -0700 | [diff] [blame] | 3 | * 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 Athota | 0e10935 | 2015-02-12 17:38:22 -0800 | [diff] [blame] | 26 | #define MAX_VOICE_SESSIONS 7 |
Shiv Maliyappanahalli | 34b585f | 2013-10-01 15:49:05 -0700 | [diff] [blame] | 27 | |
| 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 Athota | 2850d53 | 2013-11-19 16:02:12 -0800 | [diff] [blame] | 34 | #define AUDIO_PARAMETER_KEY_INCALLMUSIC "incall_music_enabled" |
| 35 | #define AUDIO_PARAMETER_VALUE_TRUE "true" |
| 36 | |
Shiv Maliyappanahalli | 34b585f | 2013-10-01 15:49:05 -0700 | [diff] [blame] | 37 | struct audio_device; |
| 38 | struct str_parms; |
Shiv Maliyappanahalli | da10764 | 2013-10-17 11:16:13 -0700 | [diff] [blame] | 39 | struct stream_in; |
Shiv Maliyappanahalli | f3b9a42 | 2013-10-22 16:38:08 -0700 | [diff] [blame] | 40 | struct stream_out; |
Ravi Kumar Alamanda | 263d80c | 2014-08-20 16:24:38 -0700 | [diff] [blame] | 41 | typedef int audio_usecase_t; |
Narsinga Rao Chella | 212e254 | 2014-11-17 19:57:04 -0800 | [diff] [blame] | 42 | typedef int snd_device_t; |
Shiv Maliyappanahalli | 34b585f | 2013-10-01 15:49:05 -0700 | [diff] [blame] | 43 | |
| 44 | struct call_state { |
| 45 | int current; |
| 46 | int new; |
| 47 | }; |
| 48 | |
| 49 | struct voice_session { |
| 50 | struct pcm *pcm_rx; |
| 51 | struct pcm *pcm_tx; |
| 52 | struct call_state state; |
| 53 | uint32_t vsid; |
| 54 | }; |
| 55 | |
| 56 | struct voice { |
| 57 | struct voice_session session[MAX_VOICE_SESSIONS]; |
| 58 | int tty_mode; |
Aalique Grahame | 22e4910 | 2018-12-18 14:23:57 -0800 | [diff] [blame] | 59 | bool hac; |
Shiv Maliyappanahalli | 34b585f | 2013-10-01 15:49:05 -0700 | [diff] [blame] | 60 | bool mic_mute; |
Arun Mirpuri | ef53ce5 | 2018-09-11 18:00:09 -0700 | [diff] [blame] | 61 | bool use_device_mute; |
Shiv Maliyappanahalli | 34b585f | 2013-10-01 15:49:05 -0700 | [diff] [blame] | 62 | float volume; |
Vidyakumar Athota | ad34d57 | 2014-08-05 18:20:42 -0700 | [diff] [blame] | 63 | bool in_call; |
Shiv Maliyappanahalli | 34b585f | 2013-10-01 15:49:05 -0700 | [diff] [blame] | 64 | }; |
| 65 | |
Kunlei Zhang | e7cab1a | 2020-05-17 20:31:05 +0800 | [diff] [blame] | 66 | struct power_mode_cfg { |
| 67 | bool enable; |
| 68 | char *mixer_ctl; |
| 69 | }; |
| 70 | |
| 71 | struct island_cfg { |
| 72 | bool enable; |
| 73 | char *mixer_ctl; |
| 74 | }; |
| 75 | |
Vidyakumar Athota | 2850d53 | 2013-11-19 16:02:12 -0800 | [diff] [blame] | 76 | enum { |
| 77 | INCALL_REC_NONE = -1, |
| 78 | INCALL_REC_UPLINK, |
| 79 | INCALL_REC_DOWNLINK, |
| 80 | INCALL_REC_UPLINK_AND_DOWNLINK, |
| 81 | }; |
| 82 | |
Ravi Kumar Alamanda | 263d80c | 2014-08-20 16:24:38 -0700 | [diff] [blame] | 83 | int voice_start_usecase(struct audio_device *adev, audio_usecase_t usecase_id); |
| 84 | int voice_stop_usecase(struct audio_device *adev, audio_usecase_t usecase_id); |
| 85 | |
Shiv Maliyappanahalli | 34b585f | 2013-10-01 15:49:05 -0700 | [diff] [blame] | 86 | int voice_start_call(struct audio_device *adev); |
| 87 | int voice_stop_call(struct audio_device *adev); |
| 88 | int voice_set_parameters(struct audio_device *adev, struct str_parms *parms); |
Shiv Maliyappanahalli | f930849 | 2013-12-12 12:18:09 -0800 | [diff] [blame] | 89 | void voice_get_parameters(struct audio_device *adev, struct str_parms *query, |
| 90 | struct str_parms *reply); |
Shiv Maliyappanahalli | 34b585f | 2013-10-01 15:49:05 -0700 | [diff] [blame] | 91 | void voice_init(struct audio_device *adev); |
Alexy Joseph | b137994 | 2016-01-29 15:49:38 -0800 | [diff] [blame] | 92 | bool voice_is_in_call(const struct audio_device *adev); |
Jaideep Sharma | 477917f | 2020-03-13 18:13:33 +0530 | [diff] [blame] | 93 | bool voice_is_in_call_or_call_screen(const struct audio_device *adev); |
Alexy Joseph | b137994 | 2016-01-29 15:49:38 -0800 | [diff] [blame] | 94 | bool voice_is_in_call_rec_stream(const struct stream_in *in); |
Shiv Maliyappanahalli | 34b585f | 2013-10-01 15:49:05 -0700 | [diff] [blame] | 95 | int voice_set_mic_mute(struct audio_device *dev, bool state); |
| 96 | bool voice_get_mic_mute(struct audio_device *dev); |
| 97 | int voice_set_volume(struct audio_device *adev, float volume); |
Shiv Maliyappanahalli | da10764 | 2013-10-17 11:16:13 -0700 | [diff] [blame] | 98 | int voice_check_and_set_incall_rec_usecase(struct audio_device *adev, |
Shiv Maliyappanahalli | f3b9a42 | 2013-10-22 16:38:08 -0700 | [diff] [blame] | 99 | struct stream_in *in); |
| 100 | int voice_check_and_set_incall_music_usecase(struct audio_device *adev, |
| 101 | struct stream_out *out); |
Vidyakumar Athota | 2850d53 | 2013-11-19 16:02:12 -0800 | [diff] [blame] | 102 | int voice_check_and_stop_incall_rec_usecase(struct audio_device *adev, |
| 103 | struct stream_in *in); |
Narsinga Rao Chella | 22d8d7a | 2014-02-06 14:05:14 -0800 | [diff] [blame] | 104 | void voice_update_devices_for_all_voice_usecases(struct audio_device *adev); |
Narsinga Rao Chella | 212e254 | 2014-11-17 19:57:04 -0800 | [diff] [blame] | 105 | snd_device_t voice_get_incall_rec_snd_device(snd_device_t in_snd_device); |
Bhalchandra Gajare | 45fee28 | 2015-06-09 22:23:45 -0700 | [diff] [blame] | 106 | void voice_set_sidetone(struct audio_device *adev, |
| 107 | snd_device_t out_snd_device, |
| 108 | bool enable); |
Vidyakumar Athota | ea269c6 | 2016-10-31 09:05:59 -0700 | [diff] [blame] | 109 | void voice_check_and_update_aanc_path(struct audio_device *adev, |
| 110 | snd_device_t out_snd_device, |
| 111 | bool enable); |
Bhalchandra Gajare | 45fee28 | 2015-06-09 22:23:45 -0700 | [diff] [blame] | 112 | bool voice_is_call_state_active(struct audio_device *adev); |
Jaideep Sharma | 477917f | 2020-03-13 18:13:33 +0530 | [diff] [blame] | 113 | bool voice_is_call_state_active_in_call(struct audio_device *adev); |
Arun Mirpuri | ef53ce5 | 2018-09-11 18:00:09 -0700 | [diff] [blame] | 114 | void voice_set_device_mute_flag (struct audio_device *adev, bool state); |
Divya Narayanan Poojary | 85d0a59 | 2018-02-06 14:25:16 +0530 | [diff] [blame] | 115 | snd_device_t voice_get_incall_rec_backend_device(struct stream_in *in); |
Kunlei Zhang | a3b3abf | 2019-06-25 15:42:21 +0800 | [diff] [blame] | 116 | bool voice_check_voicecall_usecases_active(struct audio_device *adev); |
Shiv Maliyappanahalli | 34b585f | 2013-10-01 15:49:05 -0700 | [diff] [blame] | 117 | #endif //VOICE_H |