blob: 139a8c8d8fb27d0dea9cd48b580031edb6926f2f [file] [log] [blame]
Shiv Maliyappanahalli34b585f2013-10-01 15:49:05 -07001/*
Vidyakumar Athota0e109352015-02-12 17:38:22 -08002 * Copyright (c) 2013-2015, 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
26#ifdef MULTI_VOICE_SESSION_ENABLED
Vidyakumar Athota0e109352015-02-12 17:38:22 -080027#define MAX_VOICE_SESSIONS 7
Shiv Maliyappanahalli34b585f2013-10-01 15:49:05 -070028#else
29#define MAX_VOICE_SESSIONS 1
30#endif
31
32#define BASE_CALL_STATE 1
33#define CALL_INACTIVE (BASE_CALL_STATE)
34#define CALL_ACTIVE (BASE_CALL_STATE + 1)
35
36#define VOICE_VSID 0x10C01000
37
Vidyakumar Athota2850d532013-11-19 16:02:12 -080038#define AUDIO_PARAMETER_KEY_INCALLMUSIC "incall_music_enabled"
39#define AUDIO_PARAMETER_VALUE_TRUE "true"
40
Shiv Maliyappanahalli34b585f2013-10-01 15:49:05 -070041struct audio_device;
42struct str_parms;
Shiv Maliyappanahallida107642013-10-17 11:16:13 -070043struct stream_in;
Shiv Maliyappanahallif3b9a422013-10-22 16:38:08 -070044struct stream_out;
Ravi Kumar Alamanda263d80c2014-08-20 16:24:38 -070045typedef int audio_usecase_t;
Narsinga Rao Chella212e2542014-11-17 19:57:04 -080046typedef int snd_device_t;
Shiv Maliyappanahalli34b585f2013-10-01 15:49:05 -070047
48struct call_state {
49 int current;
50 int new;
51};
52
53struct voice_session {
54 struct pcm *pcm_rx;
55 struct pcm *pcm_tx;
56 struct call_state state;
57 uint32_t vsid;
58};
59
60struct voice {
61 struct voice_session session[MAX_VOICE_SESSIONS];
62 int tty_mode;
63 bool mic_mute;
64 float volume;
Venkata Narendra Kumar Gutta5f64eea2014-05-28 17:42:10 +053065 bool is_in_call;
Vidyakumar Athotaad34d572014-08-05 18:20:42 -070066 bool in_call;
Shiv Maliyappanahalli34b585f2013-10-01 15:49:05 -070067};
68
Vidyakumar Athota2850d532013-11-19 16:02:12 -080069enum {
70 INCALL_REC_NONE = -1,
71 INCALL_REC_UPLINK,
72 INCALL_REC_DOWNLINK,
73 INCALL_REC_UPLINK_AND_DOWNLINK,
74};
75
Ravi Kumar Alamanda263d80c2014-08-20 16:24:38 -070076int voice_start_usecase(struct audio_device *adev, audio_usecase_t usecase_id);
77int voice_stop_usecase(struct audio_device *adev, audio_usecase_t usecase_id);
78
Shiv Maliyappanahalli34b585f2013-10-01 15:49:05 -070079int voice_start_call(struct audio_device *adev);
80int voice_stop_call(struct audio_device *adev);
81int voice_set_parameters(struct audio_device *adev, struct str_parms *parms);
Shiv Maliyappanahallif9308492013-12-12 12:18:09 -080082void voice_get_parameters(struct audio_device *adev, struct str_parms *query,
83 struct str_parms *reply);
Shiv Maliyappanahalli34b585f2013-10-01 15:49:05 -070084void voice_init(struct audio_device *adev);
Ravi Kumar Alamandabdf14162014-09-05 16:14:17 -070085bool voice_is_in_call(struct audio_device *adev);
kunleizc5a639b2014-04-24 18:46:22 +080086bool voice_is_in_call_rec_stream(struct stream_in *in);
Shiv Maliyappanahalli34b585f2013-10-01 15:49:05 -070087int voice_set_mic_mute(struct audio_device *dev, bool state);
88bool voice_get_mic_mute(struct audio_device *dev);
89int voice_set_volume(struct audio_device *adev, float volume);
Shiv Maliyappanahallida107642013-10-17 11:16:13 -070090int voice_check_and_set_incall_rec_usecase(struct audio_device *adev,
Shiv Maliyappanahallif3b9a422013-10-22 16:38:08 -070091 struct stream_in *in);
92int voice_check_and_set_incall_music_usecase(struct audio_device *adev,
93 struct stream_out *out);
Vidyakumar Athota2850d532013-11-19 16:02:12 -080094int voice_check_and_stop_incall_rec_usecase(struct audio_device *adev,
95 struct stream_in *in);
Narsinga Rao Chella22d8d7a2014-02-06 14:05:14 -080096void voice_update_devices_for_all_voice_usecases(struct audio_device *adev);
Narsinga Rao Chella212e2542014-11-17 19:57:04 -080097snd_device_t voice_get_incall_rec_snd_device(snd_device_t in_snd_device);
Bhalchandra Gajare45fee282015-06-09 22:23:45 -070098void voice_set_sidetone(struct audio_device *adev,
99 snd_device_t out_snd_device,
100 bool enable);
101bool voice_is_call_state_active(struct audio_device *adev);
Shiv Maliyappanahalli34b585f2013-10-01 15:49:05 -0700102#endif //VOICE_H