Home | History | Annotate | Download | only in hal
      1 /*
      2  * Copyright (C) 2014 The Android Open Source Project
      3  *
      4  * Licensed under the Apache License, Version 2.0 (the "License");
      5  * you may not use this file except in compliance with the License.
      6  * You may obtain a copy of the License at
      7  *
      8  *      http://www.apache.org/licenses/LICENSE-2.0
      9  *
     10  * Unless required by applicable law or agreed to in writing, software
     11  * distributed under the License is distributed on an "AS IS" BASIS,
     12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     13  * See the License for the specific language governing permissions and
     14  * limitations under the License.
     15  */
     16 
     17 #ifndef VOICE_H
     18 #define VOICE_H
     19 
     20 #define BASE_SESS_IDX       0
     21 #define VOICE_SESS_IDX     (BASE_SESS_IDX)
     22 
     23 #ifdef MULTI_VOICE_SESSION_ENABLED
     24 #define MAX_VOICE_SESSIONS 5
     25 #else
     26 #define MAX_VOICE_SESSIONS 1
     27 #endif
     28 
     29 #define BASE_CALL_STATE     1
     30 #define CALL_INACTIVE       (BASE_CALL_STATE)
     31 #define CALL_ACTIVE         (BASE_CALL_STATE + 1)
     32 
     33 #define VOICE_VSID  0x10C01000
     34 
     35 #define AUDIO_PARAMETER_KEY_INCALLMUSIC "incall_music_enabled"
     36 #define AUDIO_PARAMETER_VALUE_TRUE "true"
     37 
     38 struct audio_device;
     39 struct str_parms;
     40 struct stream_in;
     41 struct stream_out;
     42 typedef int audio_usecase_t;
     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;
     59     bool hac;
     60     bool mic_mute;
     61     float volume;
     62     bool in_call;
     63 };
     64 
     65 enum {
     66     INCALL_REC_NONE = -1,
     67     INCALL_REC_UPLINK,
     68     INCALL_REC_DOWNLINK,
     69     INCALL_REC_UPLINK_AND_DOWNLINK,
     70 };
     71 
     72 int voice_start_usecase(struct audio_device *adev, audio_usecase_t usecase_id);
     73 int voice_stop_usecase(struct audio_device *adev, audio_usecase_t usecase_id);
     74 
     75 int voice_start_call(struct audio_device *adev);
     76 int voice_stop_call(struct audio_device *adev);
     77 int voice_set_parameters(struct audio_device *adev, struct str_parms *parms);
     78 void voice_get_parameters(struct audio_device *adev, struct str_parms *query,
     79                           struct str_parms *reply);
     80 void voice_init(struct audio_device *adev);
     81 bool voice_is_in_call(struct audio_device *adev);
     82 bool voice_is_in_call_rec_stream(struct stream_in *in);
     83 int voice_set_mic_mute(struct audio_device *dev, bool state);
     84 bool voice_get_mic_mute(struct audio_device *dev);
     85 int voice_set_volume(struct audio_device *adev, float volume);
     86 int voice_check_and_set_incall_rec_usecase(struct audio_device *adev,
     87                                            struct stream_in *in);
     88 int voice_check_and_set_incall_music_usecase(struct audio_device *adev,
     89                                              struct stream_out *out);
     90 int voice_check_and_stop_incall_rec_usecase(struct audio_device *adev,
     91                                             struct stream_in *in);
     92 void voice_update_devices_for_all_voice_usecases(struct audio_device *adev);
     93 #endif //VOICE_H
     94