blob: 1c4aa55f0a5896600291cf77c2e0493e6bdf9a2e [file] [log] [blame]
Apoorv Raghuvanshi9eaf94e2013-10-04 16:13:44 -07001/*
Subhash Chandra Bose Naripeddye0a07122013-12-14 00:34:53 -08002 * Copyright (c) 2013-2014, The Linux Foundation. All rights reserved.
Apoorv Raghuvanshi9eaf94e2013-10-04 16:13:44 -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 AUDIO_EXTN_H
21#define AUDIO_EXTN_H
22
23#include <cutils/str_parms.h>
24
Steve Kondik3abbbc82014-11-29 14:14:43 -080025#if 0
Mingming Yin78541282014-05-16 12:10:55 -070026#define AUDIO_FORMAT_PCM_OFFLOAD 0x17000000UL
27#define AUDIO_FORMAT_PCM_16_BIT_OFFLOAD (AUDIO_FORMAT_PCM_OFFLOAD | AUDIO_FORMAT_PCM_SUB_16_BIT)
28#define AUDIO_FORMAT_PCM_24_BIT_OFFLOAD (AUDIO_FORMAT_PCM_OFFLOAD | AUDIO_FORMAT_PCM_SUB_8_24_BIT)
29#define AUDIO_OFFLOAD_CODEC_FORMAT "music_offload_codec_format"
30#define audio_is_offload_pcm(format) (0)
Mingming Yind48310a2015-06-10 16:28:10 -070031#else
32#define OFFLOAD_USE_SMALL_BUFFER ((info->format & AUDIO_FORMAT_PCM_OFFLOAD) == AUDIO_FORMAT_PCM_OFFLOAD)
Mingming Yin78541282014-05-16 12:10:55 -070033#endif
34
35#ifndef AFE_PROXY_ENABLED
36#define AUDIO_DEVICE_OUT_PROXY 0x40000
37#endif
38
39#ifndef COMPRESS_VOIP_ENABLED
40#define AUDIO_OUTPUT_FLAG_VOIP_RX 0x4000
41#endif
42
43#ifndef INCALL_MUSIC_ENABLED
44#define AUDIO_OUTPUT_FLAG_INCALL_MUSIC 0x8000
45#endif
46
Ramjee Singhfd4323f2015-11-18 13:26:59 +053047#ifndef AUDIO_DEVICE_OUT_FM_TX
48#define AUDIO_DEVICE_OUT_FM_TX 0x8000000
Mingming Yin78541282014-05-16 12:10:55 -070049#endif
50
51
Amit Shekharfaefb322014-09-08 14:08:19 -070052#ifdef AUDIO_EXTN_FORMATS_ENABLED
53#define AUDIO_OUTPUT_BIT_WIDTH ((config->offload_info.bit_width == 32) ? 24\
54 :config->offload_info.bit_width)
55#else
56#define AUDIO_OUTPUT_BIT_WIDTH (CODEC_BACKEND_DEFAULT_BIT_WIDTH)
57#endif
58
Mingming Yin78541282014-05-16 12:10:55 -070059#define MAX_LENGTH_MIXER_CONTROL_IN_INT (128)
60
Apoorv Raghuvanshi9eaf94e2013-10-04 16:13:44 -070061void audio_extn_set_parameters(struct audio_device *adev,
62 struct str_parms *parms);
63
Shiv Maliyappanahalli34b585f2013-10-01 15:49:05 -070064void audio_extn_get_parameters(const struct audio_device *adev,
65 struct str_parms *query,
66 struct str_parms *reply);
Apoorv Raghuvanshi9eaf94e2013-10-04 16:13:44 -070067
68#ifndef ANC_HEADSET_ENABLED
69#define audio_extn_get_anc_enabled() (0)
70#define audio_extn_should_use_fb_anc() (0)
71#define audio_extn_should_use_handset_anc(in_channels) (0)
72#else
73bool audio_extn_get_anc_enabled(void);
74bool audio_extn_should_use_fb_anc(void);
75bool audio_extn_should_use_handset_anc(int in_channels);
76#endif
77
Venkata Narendra Kumar Gutta9c38b182014-03-27 17:39:57 +053078#ifndef FLUENCE_ENABLED
79#define audio_extn_set_fluence_parameters(adev, parms) (0)
80#define audio_extn_get_fluence_parameters(adev, query, reply) (0)
81#else
82void audio_extn_set_fluence_parameters(struct audio_device *adev,
83 struct str_parms *parms);
Divya Narayanan Poojarybd9f33f2014-09-17 17:35:59 +053084int audio_extn_get_fluence_parameters(const struct audio_device *adev,
Venkata Narendra Kumar Gutta9c38b182014-03-27 17:39:57 +053085 struct str_parms *query, struct str_parms *reply);
86#endif
87
Apoorv Raghuvanshi9eaf94e2013-10-04 16:13:44 -070088#ifndef AFE_PROXY_ENABLED
Mingming Yin5bdb7052014-03-05 17:45:03 -080089#define audio_extn_set_afe_proxy_channel_mixer(adev,channel_count) (0)
90#define audio_extn_read_afe_proxy_channel_masks(out) (0)
91#define audio_extn_get_afe_proxy_channel_count() (0)
Apoorv Raghuvanshi9eaf94e2013-10-04 16:13:44 -070092#else
Mingming Yin5bdb7052014-03-05 17:45:03 -080093int32_t audio_extn_set_afe_proxy_channel_mixer(struct audio_device *adev,
94 int channel_count);
Apoorv Raghuvanshi947cb902013-12-09 13:45:39 -080095int32_t audio_extn_read_afe_proxy_channel_masks(struct stream_out *out);
Mingming Yin5bdb7052014-03-05 17:45:03 -080096int32_t audio_extn_get_afe_proxy_channel_count();
97
Apoorv Raghuvanshi9eaf94e2013-10-04 16:13:44 -070098#endif
99
Apoorv Raghuvanshi5792d4b2013-10-07 18:40:05 -0700100#ifndef USB_HEADSET_ENABLED
101#define audio_extn_usb_init(adev) (0)
102#define audio_extn_usb_deinit() (0)
103#define audio_extn_usb_start_playback(adev) (0)
104#define audio_extn_usb_stop_playback() (0)
105#define audio_extn_usb_start_capture(adev) (0)
106#define audio_extn_usb_stop_capture() (0)
107#define audio_extn_usb_set_proxy_sound_card(sndcard_idx) (0)
108#define audio_extn_usb_is_proxy_inuse() (0)
109#else
Satish Babu Patakokilaf6d3c552014-03-26 15:02:12 +0530110void initPlaybackVolume();
Apoorv Raghuvanshi5792d4b2013-10-07 18:40:05 -0700111void audio_extn_usb_init(void *adev);
112void audio_extn_usb_deinit();
113void audio_extn_usb_start_playback(void *adev);
114void audio_extn_usb_stop_playback();
115void audio_extn_usb_start_capture(void *adev);
116void audio_extn_usb_stop_capture();
117void audio_extn_usb_set_proxy_sound_card(uint32_t sndcard_idx);
118bool audio_extn_usb_is_proxy_inuse();
119#endif
120
Apoorv Raghuvanshi6178a3f2013-10-19 12:38:54 -0700121#ifndef SSR_ENABLED
Divya Narayanan Poojarybd9f33f2014-09-17 17:35:59 +0530122#define audio_extn_ssr_init(in) (0)
Apoorv Raghuvanshi6178a3f2013-10-19 12:38:54 -0700123#define audio_extn_ssr_deinit() (0)
Mingming Yin49be8032013-12-19 12:51:25 -0800124#define audio_extn_ssr_update_enabled() (0)
Apoorv Raghuvanshi6178a3f2013-10-19 12:38:54 -0700125#define audio_extn_ssr_get_enabled() (0)
126#define audio_extn_ssr_read(stream, buffer, bytes) (0)
127#else
Divya Narayanan Poojarybd9f33f2014-09-17 17:35:59 +0530128int32_t audio_extn_ssr_init(struct stream_in *in);
Apoorv Raghuvanshi6178a3f2013-10-19 12:38:54 -0700129int32_t audio_extn_ssr_deinit();
Mingming Yin49be8032013-12-19 12:51:25 -0800130void audio_extn_ssr_update_enabled();
Apoorv Raghuvanshi6178a3f2013-10-19 12:38:54 -0700131bool audio_extn_ssr_get_enabled();
132int32_t audio_extn_ssr_read(struct audio_stream_in *stream,
133 void *buffer, size_t bytes);
134#endif
135
Ravi Kumar Alamanda48c921d2013-10-29 06:07:44 -0700136#ifndef HW_VARIANTS_ENABLED
137#define hw_info_init(snd_card_name) (0)
138#define hw_info_deinit(hw_info) (0)
139#define hw_info_append_hw_type(hw_info,\
140 snd_device, device_name) (0)
141#else
142void *hw_info_init(const char *snd_card_name);
143void hw_info_deinit(void *hw_info);
144void hw_info_append_hw_type(void *hw_info, snd_device_t snd_device,
145 char *device_name);
146#endif
147
Kiran Kandi910e1862013-10-29 13:29:42 -0700148#ifndef AUDIO_LISTEN_ENABLED
Kiran Kandide144c82013-11-20 15:58:32 -0800149#define audio_extn_listen_init(adev, snd_card) (0)
Kiran Kandi910e1862013-10-29 13:29:42 -0700150#define audio_extn_listen_deinit(adev) (0)
Steve Kondikad1a08a2015-11-11 16:26:25 +0100151#define audio_extn_listen_update_status(uc_info, event) (0)
Kiran Kandi910e1862013-10-29 13:29:42 -0700152#define audio_extn_listen_set_parameters(adev, parms) (0)
Kiran Kandi910e1862013-10-29 13:29:42 -0700153#else
Kiran Kandi910e1862013-10-29 13:29:42 -0700154enum listen_event_type {
Kiran Kandide144c82013-11-20 15:58:32 -0800155 LISTEN_EVENT_SND_DEVICE_FREE,
Steve Kondikad1a08a2015-11-11 16:26:25 +0100156 LISTEN_EVENT_SND_DEVICE_BUSY
Kiran Kandi910e1862013-10-29 13:29:42 -0700157};
158typedef enum listen_event_type listen_event_type_t;
159
Kiran Kandide144c82013-11-20 15:58:32 -0800160int audio_extn_listen_init(struct audio_device *adev, unsigned int snd_card);
Kiran Kandi910e1862013-10-29 13:29:42 -0700161void audio_extn_listen_deinit(struct audio_device *adev);
Steve Kondikad1a08a2015-11-11 16:26:25 +0100162void audio_extn_listen_update_status(snd_device_t snd_device,
Kiran Kandide144c82013-11-20 15:58:32 -0800163 listen_event_type_t event);
Kiran Kandi910e1862013-10-29 13:29:42 -0700164void audio_extn_listen_set_parameters(struct audio_device *adev,
Kiran Kandide144c82013-11-20 15:58:32 -0800165 struct str_parms *parms);
Kiran Kandi910e1862013-10-29 13:29:42 -0700166#endif /* AUDIO_LISTEN_ENABLED */
167
Damir Didjustof1d46c72013-11-06 17:59:04 -0800168#ifndef AUXPCM_BT_ENABLED
Apoorv Raghuvanshi84fa2fe2013-12-04 11:57:47 -0800169#define audio_extn_read_xml(adev, mixer_card, MIXER_XML_PATH, \
Damir Didjustof1d46c72013-11-06 17:59:04 -0800170 MIXER_XML_PATH_AUXPCM) (-ENOSYS)
171#else
172int32_t audio_extn_read_xml(struct audio_device *adev, uint32_t mixer_card,
173 const char* mixer_xml_path,
174 const char* mixer_xml_path_auxpcm);
175#endif /* AUXPCM_BT_ENABLED */
Gopikrishnaiah Anandanf538cef2013-10-28 14:06:03 -0700176#ifndef SPKR_PROT_ENABLED
177#define audio_extn_spkr_prot_init(adev) (0)
178#define audio_extn_spkr_prot_start_processing(snd_device) (-EINVAL)
179#define audio_extn_spkr_prot_stop_processing() (0)
180#define audio_extn_spkr_prot_is_enabled() (false)
181#else
182void audio_extn_spkr_prot_init(void *adev);
183int audio_extn_spkr_prot_start_processing(snd_device_t snd_device);
184void audio_extn_spkr_prot_stop_processing();
185bool audio_extn_spkr_prot_is_enabled();
186#endif
187
Mingming Yine62d7842013-10-25 16:26:03 -0700188#ifndef COMPRESS_CAPTURE_ENABLED
Divya Narayanan Poojarybd9f33f2014-09-17 17:35:59 +0530189#define audio_extn_compr_cap_init(in) (0)
Mingming Yine62d7842013-10-25 16:26:03 -0700190#define audio_extn_compr_cap_enabled() (0)
191#define audio_extn_compr_cap_format_supported(format) (0)
192#define audio_extn_compr_cap_usecase_supported(usecase) (0)
193#define audio_extn_compr_cap_get_buffer_size(format) (0)
194#define audio_extn_compr_cap_read(in, buffer, bytes) (0)
195#define audio_extn_compr_cap_deinit() (0)
196#else
Divya Narayanan Poojarybd9f33f2014-09-17 17:35:59 +0530197void audio_extn_compr_cap_init(struct stream_in *in);
Mingming Yine62d7842013-10-25 16:26:03 -0700198bool audio_extn_compr_cap_enabled();
199bool audio_extn_compr_cap_format_supported(audio_format_t format);
200bool audio_extn_compr_cap_usecase_supported(audio_usecase_t usecase);
201size_t audio_extn_compr_cap_get_buffer_size(audio_format_t format);
202size_t audio_extn_compr_cap_read(struct stream_in *in,
203 void *buffer, size_t bytes);
204void audio_extn_compr_cap_deinit();
205#endif
206
Subhash Chandra Bose Naripeddye0a07122013-12-14 00:34:53 -0800207#if defined(DS1_DOLBY_DDP_ENABLED) || defined(DS1_DOLBY_DAP_ENABLED)
208void audio_extn_dolby_set_dmid(struct audio_device *adev);
Mingming Yin90310102013-11-13 16:57:00 -0800209#else
Subhash Chandra Bose Naripeddye0a07122013-12-14 00:34:53 -0800210#define audio_extn_dolby_set_dmid(adev) (0)
211#endif
212
213#ifndef DS1_DOLBY_DDP_ENABLED
Ravi Kumar Alamanda0c9194f2014-03-21 17:33:03 -0700214#define audio_extn_dolby_set_endpoint(adev) (0)
Subhash Chandra Bose Naripeddye0a07122013-12-14 00:34:53 -0800215#else
216void audio_extn_dolby_set_endpoint(struct audio_device *adev);
217#endif
218
219#ifndef DS1_DOLBY_DDP_ENABLED
220#define audio_extn_ddp_set_parameters(adev, parms) (0)
221#define audio_extn_is_dolby_format(format) (0)
Ravi Kumar Alamanda0c9194f2014-03-21 17:33:03 -0700222#define audio_extn_dolby_get_snd_codec_id(adev, out, format) (0)
Subhash Chandra Bose Naripeddye0a07122013-12-14 00:34:53 -0800223#define audio_extn_dolby_send_ddp_endp_params(adev) (0)
224#else
225bool audio_extn_is_dolby_format(audio_format_t format);
226int audio_extn_dolby_get_snd_codec_id(struct audio_device *adev,
227 struct stream_out *out,
228 audio_format_t format);
229void audio_extn_ddp_set_parameters(struct audio_device *adev,
230 struct str_parms *parms);
231void audio_extn_dolby_send_ddp_endp_params(struct audio_device *adev);
Mingming Yin90310102013-11-13 16:57:00 -0800232#endif
233
Eric Laurentda46bfb2014-08-25 22:39:29 -0500234#ifndef EXTERNAL_SPEAKER_ENABLED
235#define audio_extn_extspk_init(adev) NULL
236#define audio_extn_extspk_deinit(extn) 0
237#define audio_extn_extspk_update(extn) 0
238#define audio_extn_extspk_set_mode(extn, mode) 0
Eric Laurent321b96d2014-09-10 13:21:01 -0500239#define audio_extn_extspk_set_voice_vol(extn, vol) 0
Eric Laurentda46bfb2014-08-25 22:39:29 -0500240#else
241void *audio_extn_extspk_init(struct audio_device *adev);
242void audio_extn_extspk_deinit(void *extn);
243void audio_extn_extspk_update(void* extn);
244void audio_extn_extspk_set_mode(void* extn, audio_mode_t mode);
Eric Laurent321b96d2014-09-10 13:21:01 -0500245void audio_extn_extspk_set_voice_vol(void* extn, float vol);
Eric Laurentda46bfb2014-08-25 22:39:29 -0500246#endif
247
Vimal Puthanveed37b4a1c2014-01-07 16:47:47 -0800248#ifndef HFP_ENABLED
249#define audio_extn_hfp_is_active(adev) (0)
Divya Narayanan Poojarybd9f33f2014-09-17 17:35:59 +0530250#define audio_extn_hfp_get_usecase() (-1)
Vimal Puthanveed37b4a1c2014-01-07 16:47:47 -0800251#else
252bool audio_extn_hfp_is_active(struct audio_device *adev);
Vimal Puthanveed739e7152014-01-23 15:56:53 -0800253audio_usecase_t audio_extn_hfp_get_usecase();
Vimal Puthanveed37b4a1c2014-01-07 16:47:47 -0800254#endif
255
Vimal Puthanveed8fa9eab2014-01-07 16:47:47 -0800256#ifndef HFP_ENABLED
257#define audio_extn_hfp_is_active(adev) (0)
258#else
259bool audio_extn_hfp_is_active(struct audio_device *adev);
260#endif
261
Ravi Kumar Alamandad995c592015-09-23 13:47:03 -0700262#ifndef KPI_OPTIMIZE_ENABLED
263#define audio_extn_perf_lock_init() (0)
264#define audio_extn_perf_lock_acquire() (0)
265#define audio_extn_perf_lock_release() (0)
266#else
267int audio_extn_perf_lock_init(void);
268void audio_extn_perf_lock_acquire(void);
269void audio_extn_perf_lock_release(void);
270#endif /* KPI_OPTIMIZE_ENABLED */
Apoorv Raghuvanshi9eaf94e2013-10-04 16:13:44 -0700271#endif /* AUDIO_EXTN_H */