161e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti/*
261e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti * Copyright (c) 2013-2014, The Linux Foundation. All rights reserved.
361e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti * Not a contribution.
461e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti *
561e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti * Copyright (C) 2013 The Android Open Source Project
661e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti *
761e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti * Licensed under the Apache License, Version 2.0 (the "License");
861e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti * you may not use this file except in compliance with the License.
961e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti * You may obtain a copy of the License at
1061e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti *
1161e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti *      http://www.apache.org/licenses/LICENSE-2.0
1261e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti *
1361e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti * Unless required by applicable law or agreed to in writing, software
1461e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti * distributed under the License is distributed on an "AS IS" BASIS,
1561e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1661e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti * See the License for the specific language governing permissions and
1761e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti * limitations under the License.
1861e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti */
1961e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti
2061e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti#ifndef VOICE_H
2161e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti#define VOICE_H
2261e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti
2361e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti#define BASE_SESS_IDX       0
2461e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti#define VOICE_SESS_IDX     (BASE_SESS_IDX)
2561e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti
2661e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti#ifdef MULTI_VOICE_SESSION_ENABLED
2761e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti#define MAX_VOICE_SESSIONS 5
2861e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti#else
2961e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti#define MAX_VOICE_SESSIONS 1
3061e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti#endif
3161e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti
3261e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti#define BASE_CALL_STATE     1
3361e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti#define CALL_INACTIVE       (BASE_CALL_STATE)
3461e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti#define CALL_ACTIVE         (BASE_CALL_STATE + 1)
3561e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti
3661e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti#define VOICE_VSID  0x10C01000
3761e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti
3861e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti#define AUDIO_PARAMETER_KEY_INCALLMUSIC "incall_music_enabled"
3961e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti#define AUDIO_PARAMETER_VALUE_TRUE "true"
4061e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti
4161e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuletistruct audio_device;
4261e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuletistruct str_parms;
4361e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuletistruct stream_in;
4461e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuletistruct stream_out;
4561e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuletitypedef int audio_usecase_t;
4661e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti
4761e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuletistruct call_state {
4861e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti    int current;
4961e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti    int new;
5061e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti};
5161e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti
5261e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuletistruct voice_session {
5361e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti    struct pcm *pcm_rx;
5461e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti    struct pcm *pcm_tx;
5561e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti    struct call_state state;
5661e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti    uint32_t vsid;
5761e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti};
5861e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti
5961e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuletistruct voice {
6061e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti    struct voice_session session[MAX_VOICE_SESSIONS];
6161e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti    int tty_mode;
6261e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti    bool mic_mute;
6361e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti    float volume;
6461e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti    bool is_in_call;
6561e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti    bool in_call;
6661e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti};
6761e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti
6861e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuletienum {
6961e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti    INCALL_REC_NONE = -1,
7061e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti    INCALL_REC_UPLINK,
7161e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti    INCALL_REC_DOWNLINK,
7261e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti    INCALL_REC_UPLINK_AND_DOWNLINK,
7361e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti};
7461e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti
7561e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuletiint voice_start_usecase(struct audio_device *adev, audio_usecase_t usecase_id);
7661e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuletiint voice_stop_usecase(struct audio_device *adev, audio_usecase_t usecase_id);
7761e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti
7861e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuletiint voice_start_call(struct audio_device *adev);
7961e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuletiint voice_stop_call(struct audio_device *adev);
8061e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuletiint voice_set_parameters(struct audio_device *adev, struct str_parms *parms);
8161e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuletivoid voice_get_parameters(struct audio_device *adev, struct str_parms *query,
8261e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti                          struct str_parms *reply);
8361e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuletivoid voice_init(struct audio_device *adev);
8461e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuletibool voice_is_in_call(struct audio_device *adev);
8561e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuletibool voice_is_in_call_rec_stream(struct stream_in *in);
8661e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuletiint voice_set_mic_mute(struct audio_device *dev, bool state);
8761e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuletibool voice_get_mic_mute(struct audio_device *dev);
8861e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuletiint voice_set_volume(struct audio_device *adev, float volume);
8961e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuletiint voice_check_and_set_incall_rec_usecase(struct audio_device *adev,
9061e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti                                           struct stream_in *in);
9161e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuletiint voice_check_and_set_incall_music_usecase(struct audio_device *adev,
9261e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti                                             struct stream_out *out);
9361e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuletiint voice_check_and_stop_incall_rec_usecase(struct audio_device *adev,
9461e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti                                            struct stream_in *in);
9561e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuletivoid voice_update_devices_for_all_voice_usecases(struct audio_device *adev);
9661e21a4fe27118141afc13323807f83b733cf426Uday Kishore Pasupuleti#endif //VOICE_H
97