• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 AUDIO_EXTN_H
18 #define AUDIO_EXTN_H
19 
20 #include <cutils/str_parms.h>
21 
22 #define HW_INFO_ARRAY_MAX_SIZE 32
23 
24 struct snd_card_split {
25     char device[HW_INFO_ARRAY_MAX_SIZE];
26     char snd_card[HW_INFO_ARRAY_MAX_SIZE];
27     char form_factor[HW_INFO_ARRAY_MAX_SIZE];
28 };
29 
30 void *audio_extn_extspk_init(struct audio_device *adev);
31 void audio_extn_extspk_deinit(void *extn);
32 void audio_extn_extspk_update(void* extn);
33 void audio_extn_extspk_set_mode(void* extn, audio_mode_t mode);
34 void audio_extn_extspk_set_voice_vol(void* extn, float vol);
35 struct snd_card_split *audio_extn_get_snd_card_split();
36 void audio_extn_set_snd_card_split(const char* in_snd_card_name);
37 
38 #ifndef SPKR_PROT_ENABLED
39 #define audio_extn_spkr_prot_init(adev)       (0)
40 #define audio_extn_spkr_prot_start_processing(snd_device)    (-EINVAL)
41 #define audio_extn_spkr_prot_calib_cancel(adev) (0)
42 #define audio_extn_spkr_prot_stop_processing(snd_device)     (0)
43 #define audio_extn_spkr_prot_is_enabled() (false)
44 #define audio_extn_get_spkr_prot_snd_device(snd_device) (snd_device)
45 #define audio_extn_spkr_prot_deinit(adev)       (0)
46 #else
47 void audio_extn_spkr_prot_init(void *adev);
48 int audio_extn_spkr_prot_start_processing(snd_device_t snd_device);
49 void audio_extn_spkr_prot_stop_processing(snd_device_t snd_device);
50 bool audio_extn_spkr_prot_is_enabled();
51 int audio_extn_get_spkr_prot_snd_device(snd_device_t snd_device);
52 void audio_extn_spkr_prot_calib_cancel(void *adev);
53 void audio_extn_spkr_prot_deinit(void *adev);
54 
55 #endif
56 
57 #ifndef HFP_ENABLED
58 #define audio_extn_hfp_is_active(adev)                  (0)
59 #define audio_extn_hfp_get_usecase()                    (-1)
60 #define audio_extn_hfp_set_parameters(adev, params)     (0)
61 #define audio_extn_hfp_set_mic_mute(adev, state)        (0)
62 
63 #else
64 bool audio_extn_hfp_is_active(struct audio_device *adev);
65 
66 audio_usecase_t audio_extn_hfp_get_usecase();
67 
68 void audio_extn_hfp_set_parameters(struct audio_device *adev,
69                                     struct str_parms *parms);
70 int audio_extn_hfp_set_mic_mute(struct audio_device *adev, bool state);
71 
72 #endif
73 
74 #ifndef USB_TUNNEL_ENABLED
75 #define audio_extn_usb_init(adev)                                      (0)
76 #define audio_extn_usb_deinit()                                        (0)
77 #define audio_extn_usb_add_device(device, card)                        (0)
78 #define audio_extn_usb_remove_device(device, card)                     (0)
79 #define audio_extn_usb_is_config_supported(bit_width, sample_rate, ch, pb) (false)
80 #define audio_extn_usb_enable_sidetone(device, enable)                 (0)
81 #define audio_extn_usb_set_sidetone_gain(parms, value, len)            (0)
82 #define audio_extn_usb_is_capture_supported()                          (false)
83 #define audio_extn_usb_get_max_channels(dir)                           (0)
84 #define audio_extn_usb_get_max_bit_width(dir)                          (0)
85 #define audio_extn_usb_sup_sample_rates(t, s, l)        ((t), (s), (l), 0) /* fix unused warn */
86 #define audio_extn_usb_alive(adev)                                     (false)
87 #define audio_extn_usb_find_service_interval(m, p)      ((m), (p), 0) /* fix unused warn */
88 #define audio_extn_usb_altset_for_service_interval(p, si, bw, sr, ch) (-1)
89 #define audio_extn_usb_usbid()                                         (NULL)
90 #else
91 void audio_extn_usb_init(void *adev);
92 void audio_extn_usb_deinit();
93 void audio_extn_usb_add_device(audio_devices_t device, int card);
94 void audio_extn_usb_remove_device(audio_devices_t device, int card);
95 bool audio_extn_usb_is_config_supported(unsigned int *bit_width,
96                                         unsigned int *sample_rate,
97                                         unsigned int *ch,
98                                         bool is_playback);
99 int audio_extn_usb_enable_sidetone(int device, bool enable);
100 int audio_extn_usb_set_sidetone_gain(struct str_parms *parms,
101                                      char *value, int len);
102 bool audio_extn_usb_is_capture_supported();
103 int audio_extn_usb_get_max_channels(bool is_playback);
104 int audio_extn_usb_get_max_bit_width(bool is_playback);
105 int audio_extn_usb_sup_sample_rates(bool is_playback, uint32_t *sr, uint32_t l);
106 bool audio_extn_usb_alive(int card);
107 unsigned long audio_extn_usb_find_service_interval(bool min, bool playback);
108 int audio_extn_usb_altset_for_service_interval(bool is_playback,
109                                                unsigned long service_interval,
110                                                uint32_t *bit_width,
111                                                uint32_t *sample_rate,
112                                                uint32_t *channel_count);
113 char *audio_extn_usb_usbid(void);
114 #endif
115 
116 
117 #ifndef SOUND_TRIGGER_ENABLED
118 #define audio_extn_sound_trigger_init(adev)                            (0)
119 #define audio_extn_sound_trigger_deinit(adev)                          (0)
120 #define audio_extn_sound_trigger_update_device_status(snd_dev, event)  (0)
121 #define audio_extn_sound_trigger_update_stream_status(uc_info, event)  (0)
122 #define audio_extn_sound_trigger_set_parameters(adev, parms)           (0)
123 #define audio_extn_sound_trigger_check_and_get_session(in)             (0)
124 #define audio_extn_sound_trigger_stop_lab(in)                          (0)
125 #define audio_extn_sound_trigger_read(in, buffer, bytes)               (0)
126 
127 #else
128 
129 enum st_event_type {
130     ST_EVENT_SND_DEVICE_FREE,
131     ST_EVENT_SND_DEVICE_BUSY,
132     ST_EVENT_STREAM_FREE,
133     ST_EVENT_STREAM_BUSY
134 };
135 typedef enum st_event_type st_event_type_t;
136 
137 int audio_extn_sound_trigger_init(struct audio_device *adev);
138 void audio_extn_sound_trigger_deinit(struct audio_device *adev);
139 void audio_extn_sound_trigger_update_device_status(snd_device_t snd_device,
140                                      st_event_type_t event);
141 void audio_extn_sound_trigger_update_stream_status(struct audio_usecase *uc_info,
142                                      st_event_type_t event);
143 void audio_extn_sound_trigger_set_parameters(struct audio_device *adev,
144                                              struct str_parms *parms);
145 void audio_extn_sound_trigger_check_and_get_session(struct stream_in *in);
146 void audio_extn_sound_trigger_stop_lab(struct stream_in *in);
147 int audio_extn_sound_trigger_read(struct stream_in *in, void *buffer,
148                                   size_t bytes);
149 #endif
150 
151 #ifndef A2DP_OFFLOAD_ENABLED
152 #define audio_extn_a2dp_init(adev)                       (0)
153 #define audio_extn_a2dp_start_playback()                 (0)
154 #define audio_extn_a2dp_stop_playback()                  (0)
155 #define audio_extn_a2dp_set_parameters(parms, reconfig)  (0)
156 #define audio_extn_a2dp_get_parameters(query, reply)     (0)
157 #define audio_extn_a2dp_is_force_device_switch()         (0)
158 #define audio_extn_a2dp_set_handoff_mode(is_on)          (0)
159 #define audio_extn_a2dp_get_sample_rate(sample_rate)     (0)
160 #define audio_extn_a2dp_get_encoder_latency()            (0)
161 #define audio_extn_a2dp_is_ready()                       (0)
162 #define audio_extn_a2dp_is_suspended()                   (0)
163 #else
164 void audio_extn_a2dp_init(void *adev);
165 int audio_extn_a2dp_start_playback();
166 int audio_extn_a2dp_stop_playback();
167 int audio_extn_a2dp_set_parameters(struct str_parms *parms, bool *reconfig);
168 int audio_extn_a2dp_get_parameters(struct str_parms *query,
169                                    struct str_parms *reply);
170 bool audio_extn_a2dp_is_force_device_switch();
171 void audio_extn_a2dp_set_handoff_mode(bool is_on);
172 void audio_extn_a2dp_get_sample_rate(int *sample_rate);
173 uint32_t audio_extn_a2dp_get_encoder_latency();
174 bool audio_extn_a2dp_is_ready();
175 bool audio_extn_a2dp_is_suspended();
176 #endif
177 
178 #ifndef DSM_FEEDBACK_ENABLED
179 #define audio_extn_dsm_feedback_enable(adev, snd_device, benable)                (0)
180 #else
181 void audio_extn_dsm_feedback_enable(struct audio_device *adev,
182                          snd_device_t snd_device,
183                          bool benable);
184 #endif
185 
186 void audio_extn_utils_send_default_app_type_cfg(void *platform, struct mixer *mixer);
187 int audio_extn_utils_send_app_type_cfg(struct audio_device *adev,
188                                        struct audio_usecase *usecase);
189 void audio_extn_utils_send_audio_calibration(struct audio_device *adev,
190                                              struct audio_usecase *usecase);
191 int audio_extn_utils_send_app_type_gain(struct audio_device *adev,
192                                         int app_type,
193                                         int *gain);
194 #ifndef HWDEP_CAL_ENABLED
195 #define  audio_extn_hwdep_cal_send(snd_card, acdb_handle) (0)
196 #else
197 void audio_extn_hwdep_cal_send(int snd_card, void *acdb_handle);
198 #endif
199 
200 #ifndef KPI_OPTIMIZE_ENABLED
201 #define audio_extn_perf_lock_init() (0)
202 #define audio_extn_perf_lock_acquire() (0)
203 #define audio_extn_perf_lock_release() (0)
204 #else
205 int audio_extn_perf_lock_init(void);
206 void audio_extn_perf_lock_acquire(void);
207 void audio_extn_perf_lock_release(void);
208 #endif /* KPI_OPTIMIZE_ENABLED */
209 
210 #ifndef HW_VARIANTS_ENABLED
211 #define hw_info_init(snd_card_name)                  (0)
212 #define hw_info_deinit(hw_info)                      (0)
213 #define hw_info_append_hw_type(hw_info,\
214         snd_device, device_name)                     (0)
215 #else
216 void *hw_info_init(const char *snd_card_name);
217 void hw_info_deinit(void *hw_info);
218 void hw_info_append_hw_type(void *hw_info, snd_device_t snd_device,
219                              char *device_name);
220 #endif /* HW_VARIANTS_ENABLED */
221 
222 typedef void (* snd_mon_cb)(void * stream, struct str_parms * parms);
223 #ifndef SND_MONITOR_ENABLED
224 #define audio_extn_snd_mon_init()           (0)
225 #define audio_extn_snd_mon_deinit()         (0)
226 #define audio_extn_snd_mon_register_listener(stream, cb) (0)
227 #define audio_extn_snd_mon_unregister_listener(stream) (0)
228 #else
229 int audio_extn_snd_mon_init();
230 int audio_extn_snd_mon_deinit();
231 int audio_extn_snd_mon_register_listener(void *stream, snd_mon_cb cb);
232 int audio_extn_snd_mon_unregister_listener(void *stream);
233 #endif
234 
235 bool audio_extn_utils_resolve_config_file(char[]);
236 int audio_extn_utils_get_platform_info(const char* snd_card_name,
237                                        char* platform_info_file);
238 int audio_extn_utils_get_snd_card_num();
239 #endif /* AUDIO_EXTN_H */
240