blob: 5b4004f7e98d88420ef60b3cefaeb5aa59fa8e69 [file] [log] [blame]
Yamit Mehta1d2e4742016-05-18 15:25:12 +05301/*
2 *
3 * Copyright (C) 2013 The Android Open Source Project
4 *
5 * Licensed under the Apache License, Version 2.0 (the "License");
6 * you may not use this file except in compliance with the License.
7 * You may obtain a copy of the License at
8 *
9 * http://www.apache.org/licenses/LICENSE-2.0
10 *
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
16 */
17
18#ifndef QCOM_AUDIO_PLATFORM_H
19#define QCOM_AUDIO_PLATFORM_H
20
21enum {
22 FLUENCE_NONE,
23 FLUENCE_DUAL_MIC = 0x1,
24 FLUENCE_QUAD_MIC = 0x2,
25};
26
27enum {
28 FLUENCE_ENDFIRE = 0x1,
29 FLUENCE_BROADSIDE = 0x2,
30};
31
32/*
33 * Below are the devices for which is back end is same, SLIMBUS_0_RX.
34 * All these devices are handled by the internal HW codec. We can
35 * enable any one of these devices at any time. An exception here is
36 * 44.1k headphone which uses different backend. This is filtered
37 * as different hal internal device in the code but remains same
38 * as standard android device AUDIO_DEVICE_OUT_WIRED_HEADPHONE
39 * for other layers.
40 */
41#define AUDIO_DEVICE_OUT_ALL_CODEC_BACKEND \
42 (AUDIO_DEVICE_OUT_EARPIECE | AUDIO_DEVICE_OUT_SPEAKER | \
43 AUDIO_DEVICE_OUT_WIRED_HEADSET | AUDIO_DEVICE_OUT_WIRED_HEADPHONE|\
44 AUDIO_DEVICE_OUT_LINE)
45
46/* Sound devices specific to the platform
47 * The DEVICE_OUT_* and DEVICE_IN_* should be mapped to these sound
48 * devices to enable corresponding mixer paths
49 */
50enum {
51 SND_DEVICE_NONE = 0,
52
53 /* Playback devices */
54 SND_DEVICE_MIN,
55 SND_DEVICE_OUT_BEGIN = SND_DEVICE_MIN,
56 SND_DEVICE_OUT_HANDSET = SND_DEVICE_OUT_BEGIN,
57 SND_DEVICE_OUT_SPEAKER,
58 SND_DEVICE_OUT_SPEAKER_REVERSE,
David Linfb3c9952018-01-19 14:57:43 -080059 SND_DEVICE_OUT_SPEAKER_SAFE,
Yamit Mehta1d2e4742016-05-18 15:25:12 +053060 SND_DEVICE_OUT_LINE,
61 SND_DEVICE_OUT_HEADPHONES,
62 SND_DEVICE_OUT_SPEAKER_AND_HEADPHONES,
63 SND_DEVICE_OUT_SPEAKER_AND_LINE,
64 SND_DEVICE_OUT_VOICE_HANDSET,
65 SND_DEVICE_OUT_VOICE_HAC_HANDSET,
66 SND_DEVICE_OUT_VOICE_SPEAKER,
Devin Kim152b09a2016-06-23 13:53:04 -070067 SND_DEVICE_OUT_VOICE_SPEAKER_HFP,
Yamit Mehta1d2e4742016-05-18 15:25:12 +053068 SND_DEVICE_OUT_VOICE_HEADPHONES,
69 SND_DEVICE_OUT_VOICE_LINE,
70 SND_DEVICE_OUT_HDMI,
71 SND_DEVICE_OUT_SPEAKER_AND_HDMI,
72 SND_DEVICE_OUT_BT_SCO,
73 SND_DEVICE_OUT_BT_SCO_WB,
Aniket Kumar Lata26483012018-01-31 20:21:42 -080074 SND_DEVICE_OUT_BT_A2DP,
75 SND_DEVICE_OUT_SPEAKER_AND_BT_A2DP,
Aniket Kumar Lata9723a962018-05-16 17:41:55 -070076 SND_DEVICE_OUT_SPEAKER_SAFE_AND_BT_A2DP,
Yamit Mehta1d2e4742016-05-18 15:25:12 +053077 SND_DEVICE_OUT_VOICE_TTY_FULL_HEADPHONES,
78 SND_DEVICE_OUT_VOICE_TTY_VCO_HEADPHONES,
79 SND_DEVICE_OUT_VOICE_TTY_HCO_HANDSET,
80 SND_DEVICE_OUT_VOICE_TX,
juyuchen66c4ecf2018-08-06 15:39:34 +080081 SND_DEVICE_OUT_VOICE_MUSIC_TX,
Yamit Mehta1d2e4742016-05-18 15:25:12 +053082 SND_DEVICE_OUT_AFE_PROXY,
83 SND_DEVICE_OUT_USB_HEADSET,
Eric Laurent36e692d2017-05-18 17:48:59 -070084 SND_DEVICE_OUT_USB_HEADPHONES,
Yamit Mehta1d2e4742016-05-18 15:25:12 +053085 SND_DEVICE_OUT_SPEAKER_AND_USB_HEADSET,
86 SND_DEVICE_OUT_ANC_HEADSET,
87 SND_DEVICE_OUT_ANC_FB_HEADSET,
88 SND_DEVICE_OUT_VOICE_ANC_HEADSET,
89 SND_DEVICE_OUT_VOICE_ANC_FB_HEADSET,
90 SND_DEVICE_OUT_SPEAKER_AND_ANC_HEADSET,
91 SND_DEVICE_OUT_ANC_HANDSET,
92 SND_DEVICE_OUT_SPEAKER_PROTECTED,
93 SND_DEVICE_OUT_VOICE_SPEAKER_PROTECTED,
Eric Laurentb1b07992017-06-29 09:20:02 -070094 SND_DEVICE_OUT_VOICE_USB_HEADSET,
95 SND_DEVICE_OUT_VOICE_USB_HEADPHONES,
Yamit Mehta1d2e4742016-05-18 15:25:12 +053096 SND_DEVICE_OUT_END,
97
98 /*
99 * Note: IN_BEGIN should be same as OUT_END because total number of devices
100 * SND_DEVICES_MAX should not exceed MAX_RX + MAX_TX devices.
101 */
102 /* Capture devices */
103 SND_DEVICE_IN_BEGIN = SND_DEVICE_OUT_END,
104 SND_DEVICE_IN_HANDSET_MIC = SND_DEVICE_IN_BEGIN,
105 SND_DEVICE_IN_HANDSET_MIC_EXTERNAL,
106 SND_DEVICE_IN_HANDSET_MIC_AEC,
107 SND_DEVICE_IN_HANDSET_MIC_NS,
108 SND_DEVICE_IN_HANDSET_MIC_AEC_NS,
109 SND_DEVICE_IN_HANDSET_DMIC,
110 SND_DEVICE_IN_HANDSET_DMIC_AEC,
111 SND_DEVICE_IN_HANDSET_DMIC_NS,
112 SND_DEVICE_IN_HANDSET_DMIC_AEC_NS,
113 SND_DEVICE_IN_SPEAKER_MIC,
114 SND_DEVICE_IN_SPEAKER_MIC_AEC,
115 SND_DEVICE_IN_SPEAKER_MIC_NS,
116 SND_DEVICE_IN_SPEAKER_MIC_AEC_NS,
117 SND_DEVICE_IN_SPEAKER_DMIC,
118 SND_DEVICE_IN_SPEAKER_DMIC_AEC,
119 SND_DEVICE_IN_SPEAKER_DMIC_NS,
120 SND_DEVICE_IN_SPEAKER_DMIC_AEC_NS,
121 SND_DEVICE_IN_HEADSET_MIC,
122 SND_DEVICE_IN_HEADSET_MIC_FLUENCE,
123 SND_DEVICE_IN_VOICE_SPEAKER_MIC,
Devin Kim152b09a2016-06-23 13:53:04 -0700124 SND_DEVICE_IN_VOICE_SPEAKER_MIC_HFP,
Yamit Mehta1d2e4742016-05-18 15:25:12 +0530125 SND_DEVICE_IN_VOICE_HEADSET_MIC,
126 SND_DEVICE_IN_HDMI_MIC,
127 SND_DEVICE_IN_BT_SCO_MIC,
128 SND_DEVICE_IN_BT_SCO_MIC_NREC,
129 SND_DEVICE_IN_BT_SCO_MIC_WB,
130 SND_DEVICE_IN_BT_SCO_MIC_WB_NREC,
131 SND_DEVICE_IN_CAMCORDER_MIC,
132 SND_DEVICE_IN_VOICE_DMIC,
133 SND_DEVICE_IN_VOICE_SPEAKER_DMIC,
134 SND_DEVICE_IN_VOICE_SPEAKER_QMIC,
135 SND_DEVICE_IN_VOICE_TTY_FULL_HEADSET_MIC,
136 SND_DEVICE_IN_VOICE_TTY_VCO_HANDSET_MIC,
137 SND_DEVICE_IN_VOICE_TTY_HCO_HEADSET_MIC,
138 SND_DEVICE_IN_VOICE_REC_MIC,
139 SND_DEVICE_IN_VOICE_REC_MIC_NS,
140 SND_DEVICE_IN_VOICE_REC_DMIC_STEREO,
141 SND_DEVICE_IN_VOICE_REC_DMIC_FLUENCE,
142 SND_DEVICE_IN_VOICE_RX,
143 SND_DEVICE_IN_USB_HEADSET_MIC,
144 SND_DEVICE_IN_CAPTURE_FM,
145 SND_DEVICE_IN_AANC_HANDSET_MIC,
146 SND_DEVICE_IN_QUAD_MIC,
147 SND_DEVICE_IN_HANDSET_STEREO_DMIC,
148 SND_DEVICE_IN_SPEAKER_STEREO_DMIC,
149 SND_DEVICE_IN_CAPTURE_VI_FEEDBACK,
150 SND_DEVICE_IN_VOICE_SPEAKER_DMIC_BROADSIDE,
151 SND_DEVICE_IN_SPEAKER_DMIC_BROADSIDE,
152 SND_DEVICE_IN_SPEAKER_DMIC_AEC_BROADSIDE,
153 SND_DEVICE_IN_SPEAKER_DMIC_NS_BROADSIDE,
154 SND_DEVICE_IN_SPEAKER_DMIC_AEC_NS_BROADSIDE,
155 SND_DEVICE_IN_VOICE_FLUENCE_DMIC_AANC,
156 SND_DEVICE_IN_HANDSET_QMIC,
157 SND_DEVICE_IN_SPEAKER_QMIC_AEC,
158 SND_DEVICE_IN_SPEAKER_QMIC_NS,
159 SND_DEVICE_IN_SPEAKER_QMIC_AEC_NS,
160 SND_DEVICE_IN_END,
161
162 SND_DEVICE_MAX = SND_DEVICE_IN_END,
163
164};
165
166#define DEFAULT_OUTPUT_SAMPLING_RATE 48000
Haynes Mathew Georgee95340e2017-05-24 15:42:06 -0700167#define DEFAULT_INPUT_SAMPLING_RATE 48000
Yamit Mehta1d2e4742016-05-18 15:25:12 +0530168
169#define ALL_SESSION_VSID 0xFFFFFFFF
170#define DEFAULT_MUTE_RAMP_DURATION_MS 20
171#define DEFAULT_VOLUME_RAMP_DURATION_MS 20
172#define MIXER_PATH_MAX_LENGTH 100
173
174#define MAX_VOL_INDEX 5
175#define MIN_VOL_INDEX 0
176#define percent_to_index(val, min, max) \
177 ((val) * ((max) - (min)) * 0.01 + (min) + .5)
178
179/*
180 * tinyAlsa library interprets period size as number of frames
181 * one frame = channel_count * sizeof (pcm sample)
182 * so if format = 16-bit PCM and channels = Stereo, frame size = 2 ch * 2 = 4 bytes
183 * DEEP_BUFFER_OUTPUT_PERIOD_SIZE = 1024 means 1024 * 4 = 4096 bytes
184 * We should take care of returning proper size when AudioFlinger queries for
185 * the buffer size of an input/output stream
186 */
187#define DEEP_BUFFER_OUTPUT_PERIOD_SIZE 1920
188#define DEEP_BUFFER_OUTPUT_PERIOD_COUNT 2
189#define LOW_LATENCY_OUTPUT_PERIOD_SIZE 240
190#define LOW_LATENCY_OUTPUT_PERIOD_COUNT 2
191
192#define LOW_LATENCY_CAPTURE_SAMPLE_RATE 48000
193#define LOW_LATENCY_CAPTURE_PERIOD_SIZE 240
194#define LOW_LATENCY_CAPTURE_USE_CASE 1
195
196#define HDMI_MULTI_PERIOD_SIZE 336
197#define HDMI_MULTI_PERIOD_COUNT 8
198#define HDMI_MULTI_DEFAULT_CHANNEL_COUNT 6
199#define HDMI_MULTI_PERIOD_BYTES (HDMI_MULTI_PERIOD_SIZE * HDMI_MULTI_DEFAULT_CHANNEL_COUNT * 2)
200
201#define AUDIO_CAPTURE_PERIOD_DURATION_MSEC 20
202#define AUDIO_CAPTURE_PERIOD_COUNT 2
203
vivek mehtaa68fea62017-06-08 19:04:02 -0700204#define VOIP_CAPTURE_PERIOD_DURATION_MSEC 20
205#define VOIP_CAPTURE_PERIOD_COUNT 2
206
207#define VOIP_PLAYBACK_PERIOD_DURATION_MSEC 20
208#define VOIP_PLAYBACK_PERIOD_COUNT 2
209
Yamit Mehta1d2e4742016-05-18 15:25:12 +0530210#define LOW_LATENCY_CAPTURE_SAMPLE_RATE 48000
211#define LOW_LATENCY_CAPTURE_PERIOD_SIZE 240
212#define LOW_LATENCY_CAPTURE_USE_CASE 1
213
214#define DEVICE_NAME_MAX_SIZE 128
215#define HW_INFO_ARRAY_MAX_SIZE 32
216
217#define DEEP_BUFFER_PCM_DEVICE 0
218#define AUDIO_RECORD_PCM_DEVICE 0
219#define MULTIMEDIA2_PCM_DEVICE 1
220#define MULTIMEDIA3_PCM_DEVICE 4
221#define FM_PLAYBACK_PCM_DEVICE 5
222#define FM_CAPTURE_PCM_DEVICE 6
223#define HFP_PCM_RX 5
224#define HFP_SCO_RX 17
225#define HFP_ASM_RX_TX 18
226
227#define INCALL_MUSIC_UPLINK_PCM_DEVICE 1
228#define INCALL_MUSIC_UPLINK2_PCM_DEVICE 16
229#define SPKR_PROT_CALIB_RX_PCM_DEVICE 5
230#define SPKR_PROT_CALIB_TX_PCM_DEVICE 26
231#define PLAYBACK_OFFLOAD_DEVICE 9
232#define PLAYBACK_OFFLOAD_DEVICE2 24
233
234/* Define macro for Internal FM volume mixer */
235#define FM_RX_VOLUME "Internal FM RX Volume"
236
237#define LOWLATENCY_PCM_DEVICE 12
238#define EC_REF_RX "I2S_RX"
239
240#define VOICE_CALL_PCM_DEVICE 2
241#define VOICE2_CALL_PCM_DEVICE 13
242#define VOLTE_CALL_PCM_DEVICE 15
243#define QCHAT_CALL_PCM_DEVICE 26
244#define QCHAT_CALL_PCM_DEVICE_OF_EXT_CODEC 28
245#define VOWLAN_CALL_PCM_DEVICE 16
246
247#define AFE_PROXY_PLAYBACK_PCM_DEVICE 7
248#define AFE_PROXY_RECORD_PCM_DEVICE 8
249
jiabin8962a4d2018-03-19 18:21:24 -0700250#define AUDIO_MAKE_STRING_FROM_ENUM(X) { #X, X }
251
Yamit Mehta1d2e4742016-05-18 15:25:12 +0530252#define LIB_CSD_CLIENT "libcsd-client.so"
253/* CSD-CLIENT related functions */
254typedef int (*init_t)();
255typedef int (*deinit_t)();
256typedef int (*disable_device_t)();
257typedef int (*enable_device_config_t)(int, int);
258typedef int (*enable_device_t)(int, int, uint32_t);
259typedef int (*volume_t)(uint32_t, int, uint16_t);
260typedef int (*mic_mute_t)(uint32_t, int, uint16_t);
261typedef int (*slow_talk_t)(uint32_t, uint8_t);
262typedef int (*start_voice_t)(uint32_t);
263typedef int (*stop_voice_t)(uint32_t);
264typedef int (*start_playback_t)(uint32_t);
265typedef int (*stop_playback_t)(uint32_t);
266typedef int (*start_record_t)(uint32_t, int);
267typedef int (*stop_record_t)(uint32_t);
268/* CSD Client structure */
269struct csd_data {
270 void *csd_client;
271 init_t init;
272 deinit_t deinit;
273 disable_device_t disable_device;
274 enable_device_config_t enable_device_config;
275 enable_device_t enable_device;
276 volume_t volume;
277 mic_mute_t mic_mute;
278 slow_talk_t slow_talk;
279 start_voice_t start_voice;
280 stop_voice_t stop_voice;
281 start_playback_t start_playback;
282 stop_playback_t stop_playback;
283 start_record_t start_record;
284 stop_record_t stop_record;
285};
286
Julius D'souza1a2531c2017-10-03 11:08:41 -0700287#define PLATFORM_INFO_XML_PATH "audio_platform_info.xml"
288#define PLATFORM_INFO_XML_BASE_STRING "audio_platform_info"
Yamit Mehta1d2e4742016-05-18 15:25:12 +0530289
290#endif // QCOM_AUDIO_PLATFORM_H