blob: 3c945321cc1dfeab012e18108cb6121f7036bdec [file] [log] [blame]
Naresh Tannirue3b18452014-03-04 14:44:27 +05301/*
Chaithanya Krishna Bacharajuc9f99712019-04-16 15:32:52 +05302 * Copyright (c) 2013-2019, The Linux Foundation. All rights reserved.
Naresh Tannirudb72d1e2014-03-05 17:33:47 +05303 * Not a Contribution.
4 *
Naresh Tannirue3b18452014-03-04 14:44:27 +05305 * 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 QCOM_AUDIO_PLATFORM_H
21#define QCOM_AUDIO_PLATFORM_H
Vidyakumar Athota21b3bb92014-04-25 11:08:08 -070022#include <sound/voice_params.h>
Naresh Tannirue3b18452014-03-04 14:44:27 +053023
Naresh Tannirudb72d1e2014-03-05 17:33:47 +053024enum {
25 FLUENCE_NONE,
26 FLUENCE_DUAL_MIC = 0x1,
Vikram Pandurangaf0ca0b12018-05-04 16:00:07 -070027 FLUENCE_TRI_MIC = 0x2,
28 FLUENCE_QUAD_MIC = 0x4,
29 FLUENCE_HEX_MIC = 0x8,
Naresh Tannirudb72d1e2014-03-05 17:33:47 +053030};
31
Karthik Reddy Kattad9fff862014-07-21 21:07:21 +053032enum {
33 FLUENCE_ENDFIRE = 0x1,
34 FLUENCE_BROADSIDE = 0x2,
35};
36
Chaithanya Krishna Bacharaju9955b162016-05-25 16:25:53 +053037enum {
38 SOURCE_MONO_MIC = 0x1, /* Target contains 1 mic */
39 SOURCE_DUAL_MIC = 0x2, /* Target contains 2 mics */
40 SOURCE_THREE_MIC = 0x4, /* Target contains 3 mics */
41 SOURCE_QUAD_MIC = 0x8, /* Target contains 4 mics */
Garmond Leunge2433c32017-09-28 21:51:22 -070042 SOURCE_HEX_MIC = 0x16, /* Target contains 6 mics */
Chaithanya Krishna Bacharaju9955b162016-05-25 16:25:53 +053043};
44
Rohit kumarf4120402016-08-05 19:19:48 +053045enum {
46 SPKR_1,
47 SPKR_2
48};
49
Preetam Singh Ranawat2d0e4632015-02-02 12:40:59 +053050#define PLATFORM_IMAGE_NAME "modem"
51
Naresh Tannirue3b18452014-03-04 14:44:27 +053052/*
53 * Below are the devices for which is back end is same, SLIMBUS_0_RX.
54 * All these devices are handled by the internal HW codec. We can
Preetam Singh Ranawatc61f8672015-06-18 23:20:28 +053055 * enable any one of these devices at any time. An exception here is
56 * 44.1k headphone which uses different backend. This is filtered
57 * as different hal internal device in the code but remains same
58 * as standard android device AUDIO_DEVICE_OUT_WIRED_HEADPHONE
59 * for other layers.
Naresh Tannirue3b18452014-03-04 14:44:27 +053060 */
61#define AUDIO_DEVICE_OUT_ALL_CODEC_BACKEND \
62 (AUDIO_DEVICE_OUT_EARPIECE | AUDIO_DEVICE_OUT_SPEAKER | \
Naresh Tanniru9c4ba542015-11-06 18:01:09 +053063 AUDIO_DEVICE_OUT_WIRED_HEADSET | AUDIO_DEVICE_OUT_WIRED_HEADPHONE|\
64 AUDIO_DEVICE_OUT_LINE)
Naresh Tannirue3b18452014-03-04 14:44:27 +053065
Narsinga Rao Chellaf99003c2015-07-08 19:38:38 -070066/*
67 * Below are the input devices for which back end is same, SLIMBUS_0_TX.
68 * All these devices are handled by the internal HW codec. We can
69 * enable any one of these devices at any time
70 */
71#define AUDIO_DEVICE_IN_ALL_CODEC_BACKEND \
72 (AUDIO_DEVICE_IN_BUILTIN_MIC | AUDIO_DEVICE_IN_BACK_MIC | \
73 AUDIO_DEVICE_IN_WIRED_HEADSET | AUDIO_DEVICE_IN_VOICE_CALL) & ~AUDIO_DEVICE_BIT_IN
74
Naresh Tannirue3b18452014-03-04 14:44:27 +053075/* Sound devices specific to the platform
76 * The DEVICE_OUT_* and DEVICE_IN_* should be mapped to these sound
77 * devices to enable corresponding mixer paths
78 */
79enum {
80 SND_DEVICE_NONE = 0,
81
82 /* Playback devices */
83 SND_DEVICE_MIN,
84 SND_DEVICE_OUT_BEGIN = SND_DEVICE_MIN,
85 SND_DEVICE_OUT_HANDSET = SND_DEVICE_OUT_BEGIN,
86 SND_DEVICE_OUT_SPEAKER,
Preetam Singh Ranawat8bde2c52015-03-20 12:00:49 +053087 SND_DEVICE_OUT_SPEAKER_EXTERNAL_1,
88 SND_DEVICE_OUT_SPEAKER_EXTERNAL_2,
Naresh Tannirue3b18452014-03-04 14:44:27 +053089 SND_DEVICE_OUT_SPEAKER_REVERSE,
Preetam Singh Ranawatc7f7f5c2015-04-02 12:19:58 +053090 SND_DEVICE_OUT_SPEAKER_WSA,
Banajit Goswami20cdd212015-09-11 01:11:30 -070091 SND_DEVICE_OUT_SPEAKER_VBAT,
Naresh Tanniru9c4ba542015-11-06 18:01:09 +053092 SND_DEVICE_OUT_LINE,
Naresh Tannirue3b18452014-03-04 14:44:27 +053093 SND_DEVICE_OUT_HEADPHONES,
Preetam Singh Ranawat3e5b9e72016-11-10 16:12:25 +053094 SND_DEVICE_OUT_HEADPHONES_DSD,
Apoorv Raghuvanshi21492162015-02-19 18:19:36 -080095 SND_DEVICE_OUT_HEADPHONES_44_1,
Naresh Tannirue3b18452014-03-04 14:44:27 +053096 SND_DEVICE_OUT_SPEAKER_AND_HEADPHONES,
Naresh Tanniru9c4ba542015-11-06 18:01:09 +053097 SND_DEVICE_OUT_SPEAKER_AND_LINE,
Preetam Singh Ranawat8bde2c52015-03-20 12:00:49 +053098 SND_DEVICE_OUT_SPEAKER_AND_HEADPHONES_EXTERNAL_1,
99 SND_DEVICE_OUT_SPEAKER_AND_HEADPHONES_EXTERNAL_2,
Naresh Tannirue3b18452014-03-04 14:44:27 +0530100 SND_DEVICE_OUT_VOICE_HANDSET,
101 SND_DEVICE_OUT_VOICE_SPEAKER,
Vikram Panduranga8c68e862018-04-27 12:59:42 -0700102 SND_DEVICE_OUT_VOICE_SPEAKER_STEREO,
Preetam Singh Ranawatc7f7f5c2015-04-02 12:19:58 +0530103 SND_DEVICE_OUT_VOICE_SPEAKER_WSA,
Banajit Goswami20cdd212015-09-11 01:11:30 -0700104 SND_DEVICE_OUT_VOICE_SPEAKER_VBAT,
Rohit kumarf4120402016-08-05 19:19:48 +0530105 SND_DEVICE_OUT_VOICE_SPEAKER_2,
106 SND_DEVICE_OUT_VOICE_SPEAKER_2_WSA,
107 SND_DEVICE_OUT_VOICE_SPEAKER_2_VBAT,
Naresh Tannirue3b18452014-03-04 14:44:27 +0530108 SND_DEVICE_OUT_VOICE_HEADPHONES,
Naresh Tanniru9c4ba542015-11-06 18:01:09 +0530109 SND_DEVICE_OUT_VOICE_LINE,
Naresh Tannirue3b18452014-03-04 14:44:27 +0530110 SND_DEVICE_OUT_HDMI,
111 SND_DEVICE_OUT_SPEAKER_AND_HDMI,
Shiv Maliyappanahallic0656402016-09-03 14:13:26 -0700112 SND_DEVICE_OUT_DISPLAY_PORT,
113 SND_DEVICE_OUT_SPEAKER_AND_DISPLAY_PORT,
Naresh Tannirue3b18452014-03-04 14:44:27 +0530114 SND_DEVICE_OUT_BT_SCO,
Naresh Tannirudb72d1e2014-03-05 17:33:47 +0530115 SND_DEVICE_OUT_BT_SCO_WB,
Naresh Tanniru9d027a62015-03-13 01:32:10 +0530116 SND_DEVICE_OUT_BT_A2DP,
117 SND_DEVICE_OUT_SPEAKER_AND_BT_A2DP,
kunleizbe6a8442017-08-08 17:11:35 +0800118 SND_DEVICE_OUT_SPEAKER_AND_BT_SCO,
119 SND_DEVICE_OUT_SPEAKER_AND_BT_SCO_WB,
kunleize114ec72018-05-18 11:24:23 +0800120 SND_DEVICE_OUT_SPEAKER_WSA_AND_BT_SCO,
121 SND_DEVICE_OUT_SPEAKER_WSA_AND_BT_SCO_WB,
Naresh Tannirue3b18452014-03-04 14:44:27 +0530122 SND_DEVICE_OUT_VOICE_TTY_FULL_HEADPHONES,
123 SND_DEVICE_OUT_VOICE_TTY_VCO_HEADPHONES,
124 SND_DEVICE_OUT_VOICE_TTY_HCO_HANDSET,
Preetam Singh Ranawat7112f3b2015-02-26 16:51:58 +0530125 SND_DEVICE_OUT_VOICE_TX,
Naresh Tannirudb72d1e2014-03-05 17:33:47 +0530126 SND_DEVICE_OUT_AFE_PROXY,
127 SND_DEVICE_OUT_USB_HEADSET,
Ashish Jain3e37a702016-11-25 12:27:15 +0530128 SND_DEVICE_OUT_USB_HEADPHONES,
Naresh Tannirudb72d1e2014-03-05 17:33:47 +0530129 SND_DEVICE_OUT_SPEAKER_AND_USB_HEADSET,
Aniket Kumar Lata3e2e1232017-06-16 17:25:07 -0700130 SND_DEVICE_OUT_VOICE_USB_HEADPHONES,
131 SND_DEVICE_OUT_VOICE_USB_HEADSET,
Naresh Tannirudb72d1e2014-03-05 17:33:47 +0530132 SND_DEVICE_OUT_TRANSMISSION_FM,
133 SND_DEVICE_OUT_ANC_HEADSET,
134 SND_DEVICE_OUT_ANC_FB_HEADSET,
135 SND_DEVICE_OUT_VOICE_ANC_HEADSET,
136 SND_DEVICE_OUT_VOICE_ANC_FB_HEADSET,
137 SND_DEVICE_OUT_SPEAKER_AND_ANC_HEADSET,
138 SND_DEVICE_OUT_ANC_HANDSET,
139 SND_DEVICE_OUT_SPEAKER_PROTECTED,
Preetam Singh Ranawat8bde2c52015-03-20 12:00:49 +0530140 SND_DEVICE_OUT_VOICE_SPEAKER_PROTECTED,
Rohit kumarf4120402016-08-05 19:19:48 +0530141 SND_DEVICE_OUT_VOICE_SPEAKER_2_PROTECTED,
Vikram Panduranga8c68e862018-04-27 12:59:42 -0700142 SND_DEVICE_OUT_VOICE_SPEAKER_STEREO_PROTECTED,
Banajit Goswami20cdd212015-09-11 01:11:30 -0700143 SND_DEVICE_OUT_SPEAKER_PROTECTED_VBAT,
144 SND_DEVICE_OUT_VOICE_SPEAKER_PROTECTED_VBAT,
Rohit kumarf4120402016-08-05 19:19:48 +0530145 SND_DEVICE_OUT_VOICE_SPEAKER_2_PROTECTED_VBAT,
Rohit Kumarbe6935f2017-01-20 14:58:34 +0530146 SND_DEVICE_OUT_SPEAKER_PROTECTED_RAS,
147 SND_DEVICE_OUT_SPEAKER_PROTECTED_VBAT_RAS,
Naresh Tanniruc0517bc2014-10-26 15:30:55 +0530148#ifdef RECORD_PLAY_CONCURRENCY
149 SND_DEVICE_OUT_VOIP_HANDSET,
150 SND_DEVICE_OUT_VOIP_SPEAKER,
151 SND_DEVICE_OUT_VOIP_HEADPHONES,
152#endif
Preetam Singh Ranawat91132162017-03-13 20:32:03 +0530153 SND_DEVICE_OUT_VOICE_SPEAKER_AND_VOICE_HEADPHONES,
154 SND_DEVICE_OUT_VOICE_SPEAKER_AND_VOICE_ANC_HEADSET,
Vikram Panduranga8c68e862018-04-27 12:59:42 -0700155 SND_DEVICE_OUT_VOICE_SPEAKER_STEREO_AND_VOICE_HEADPHONES,
156 SND_DEVICE_OUT_VOICE_SPEAKER_STEREO_AND_VOICE_ANC_HEADSET,
Naresh Tannirue3b18452014-03-04 14:44:27 +0530157 SND_DEVICE_OUT_END,
158
159 /*
160 * Note: IN_BEGIN should be same as OUT_END because total number of devices
161 * SND_DEVICES_MAX should not exceed MAX_RX + MAX_TX devices.
162 */
163 /* Capture devices */
164 SND_DEVICE_IN_BEGIN = SND_DEVICE_OUT_END,
165 SND_DEVICE_IN_HANDSET_MIC = SND_DEVICE_IN_BEGIN,
Preetam Singh Ranawat8bde2c52015-03-20 12:00:49 +0530166 SND_DEVICE_IN_HANDSET_MIC_EXTERNAL,
Naresh Tannirue3b18452014-03-04 14:44:27 +0530167 SND_DEVICE_IN_HANDSET_MIC_AEC,
Naresh Tannirudb72d1e2014-03-05 17:33:47 +0530168 SND_DEVICE_IN_HANDSET_MIC_NS,
169 SND_DEVICE_IN_HANDSET_MIC_AEC_NS,
170 SND_DEVICE_IN_HANDSET_DMIC,
171 SND_DEVICE_IN_HANDSET_DMIC_AEC,
172 SND_DEVICE_IN_HANDSET_DMIC_NS,
173 SND_DEVICE_IN_HANDSET_DMIC_AEC_NS,
174 SND_DEVICE_IN_SPEAKER_MIC,
Naresh Tannirue3b18452014-03-04 14:44:27 +0530175 SND_DEVICE_IN_SPEAKER_MIC_AEC,
Naresh Tannirudb72d1e2014-03-05 17:33:47 +0530176 SND_DEVICE_IN_SPEAKER_MIC_NS,
177 SND_DEVICE_IN_SPEAKER_MIC_AEC_NS,
178 SND_DEVICE_IN_SPEAKER_DMIC,
179 SND_DEVICE_IN_SPEAKER_DMIC_AEC,
180 SND_DEVICE_IN_SPEAKER_DMIC_NS,
181 SND_DEVICE_IN_SPEAKER_DMIC_AEC_NS,
182 SND_DEVICE_IN_HEADSET_MIC,
183 SND_DEVICE_IN_HEADSET_MIC_FLUENCE,
Naresh Tannirue3b18452014-03-04 14:44:27 +0530184 SND_DEVICE_IN_VOICE_SPEAKER_MIC,
185 SND_DEVICE_IN_VOICE_HEADSET_MIC,
186 SND_DEVICE_IN_HDMI_MIC,
187 SND_DEVICE_IN_BT_SCO_MIC,
Vicky Sehrawate240e5d2014-08-12 17:17:04 -0700188 SND_DEVICE_IN_BT_SCO_MIC_NREC,
Naresh Tannirudb72d1e2014-03-05 17:33:47 +0530189 SND_DEVICE_IN_BT_SCO_MIC_WB,
Vicky Sehrawate240e5d2014-08-12 17:17:04 -0700190 SND_DEVICE_IN_BT_SCO_MIC_WB_NREC,
Florian Pfister1a84f312018-07-19 14:38:18 +0200191 SND_DEVICE_IN_BT_A2DP,
Naresh Tannirue3b18452014-03-04 14:44:27 +0530192 SND_DEVICE_IN_CAMCORDER_MIC,
Naresh Tannirudb72d1e2014-03-05 17:33:47 +0530193 SND_DEVICE_IN_VOICE_DMIC,
194 SND_DEVICE_IN_VOICE_SPEAKER_DMIC,
Vikram Pandurangaf0ca0b12018-05-04 16:00:07 -0700195 SND_DEVICE_IN_VOICE_SPEAKER_TMIC,
Naresh Tannirudb72d1e2014-03-05 17:33:47 +0530196 SND_DEVICE_IN_VOICE_SPEAKER_QMIC,
Naresh Tannirue3b18452014-03-04 14:44:27 +0530197 SND_DEVICE_IN_VOICE_TTY_FULL_HEADSET_MIC,
198 SND_DEVICE_IN_VOICE_TTY_VCO_HANDSET_MIC,
199 SND_DEVICE_IN_VOICE_TTY_HCO_HEADSET_MIC,
200 SND_DEVICE_IN_VOICE_REC_MIC,
Naresh Tannirudb72d1e2014-03-05 17:33:47 +0530201 SND_DEVICE_IN_VOICE_REC_MIC_NS,
202 SND_DEVICE_IN_VOICE_REC_DMIC_STEREO,
203 SND_DEVICE_IN_VOICE_REC_DMIC_FLUENCE,
Preetam Singh Ranawat7112f3b2015-02-26 16:51:58 +0530204 SND_DEVICE_IN_VOICE_RX,
Naresh Tannirudb72d1e2014-03-05 17:33:47 +0530205 SND_DEVICE_IN_USB_HEADSET_MIC,
Aniket Kumar Lata3e2e1232017-06-16 17:25:07 -0700206 SND_DEVICE_IN_USB_HEADSET_MIC_AEC,
207 SND_DEVICE_IN_VOICE_USB_HEADSET_MIC,
208 SND_DEVICE_IN_UNPROCESSED_USB_HEADSET_MIC,
209 SND_DEVICE_IN_VOICE_RECOG_USB_HEADSET_MIC,
Naresh Tannirudb72d1e2014-03-05 17:33:47 +0530210 SND_DEVICE_IN_CAPTURE_FM,
211 SND_DEVICE_IN_AANC_HANDSET_MIC,
212 SND_DEVICE_IN_QUAD_MIC,
213 SND_DEVICE_IN_HANDSET_STEREO_DMIC,
214 SND_DEVICE_IN_SPEAKER_STEREO_DMIC,
215 SND_DEVICE_IN_CAPTURE_VI_FEEDBACK,
Rohit kumarf4120402016-08-05 19:19:48 +0530216 SND_DEVICE_IN_CAPTURE_VI_FEEDBACK_MONO_1,
217 SND_DEVICE_IN_CAPTURE_VI_FEEDBACK_MONO_2,
Karthik Reddy Kattad9fff862014-07-21 21:07:21 +0530218 SND_DEVICE_IN_VOICE_SPEAKER_DMIC_BROADSIDE,
219 SND_DEVICE_IN_SPEAKER_DMIC_BROADSIDE,
220 SND_DEVICE_IN_SPEAKER_DMIC_AEC_BROADSIDE,
221 SND_DEVICE_IN_SPEAKER_DMIC_NS_BROADSIDE,
222 SND_DEVICE_IN_SPEAKER_DMIC_AEC_NS_BROADSIDE,
Sidipotu Ashok3bcca232014-11-07 14:41:58 +0530223 SND_DEVICE_IN_VOICE_FLUENCE_DMIC_AANC,
Karthik Reddy Kattad71b94b2015-01-19 14:06:53 +0530224 SND_DEVICE_IN_HANDSET_QMIC,
225 SND_DEVICE_IN_SPEAKER_QMIC_AEC,
226 SND_DEVICE_IN_SPEAKER_QMIC_NS,
227 SND_DEVICE_IN_SPEAKER_QMIC_AEC_NS,
Shiv Maliyappanahalli5a10aea2015-07-02 10:36:23 -0700228 SND_DEVICE_IN_THREE_MIC,
Vikram Pandurangab1e26aa2018-06-21 17:28:20 -0700229 SND_DEVICE_IN_HANDSET_TMIC_FLUENCE_PRO,
Chaithanya Krishna Bacharaju9955b162016-05-25 16:25:53 +0530230 SND_DEVICE_IN_HANDSET_TMIC,
Vikram Pandurangaf0ca0b12018-05-04 16:00:07 -0700231 SND_DEVICE_IN_SPEAKER_TMIC_AEC,
232 SND_DEVICE_IN_SPEAKER_TMIC_NS,
233 SND_DEVICE_IN_SPEAKER_TMIC_AEC_NS,
Ben Rombergera4d76db2016-10-13 15:26:02 -0700234 SND_DEVICE_IN_VOICE_REC_TMIC,
Chaithanya Krishna Bacharaju24f86f32016-05-26 16:34:53 +0530235 SND_DEVICE_IN_UNPROCESSED_MIC,
236 SND_DEVICE_IN_UNPROCESSED_STEREO_MIC,
237 SND_DEVICE_IN_UNPROCESSED_THREE_MIC,
238 SND_DEVICE_IN_UNPROCESSED_QUAD_MIC,
239 SND_DEVICE_IN_UNPROCESSED_HEADSET_MIC,
Garmond Leunge2433c32017-09-28 21:51:22 -0700240 SND_DEVICE_IN_HANDSET_6MIC,
241 SND_DEVICE_IN_HANDSET_8MIC,
242 SND_DEVICE_IN_EC_REF_LOOPBACK_MONO,
243 SND_DEVICE_IN_EC_REF_LOOPBACK_STEREO,
Dhananjay Kumar704ce6f2017-09-28 22:08:00 +0530244 SND_DEVICE_IN_HANDSET_GENERIC_QMIC,
Divya Narayanan Poojary85d0a592018-02-06 14:25:16 +0530245 SND_DEVICE_IN_INCALL_REC_RX,
246 SND_DEVICE_IN_INCALL_REC_TX,
247 SND_DEVICE_IN_INCALL_REC_RX_TX,
Ramu Gottipati813ae982018-07-25 14:14:48 +0530248 SND_DEVICE_IN_LINE,
Chaithanya Krishna Bacharajuc9f99712019-04-16 15:32:52 +0530249 SND_DEVICE_IN_EC_REF_LOOPBACK,
250 SND_DEVICE_IN_HANDSET_DMIC_AND_EC_REF_LOOPBACK,
251 SND_DEVICE_IN_HANDSET_QMIC_AND_EC_REF_LOOPBACK,
252 SND_DEVICE_IN_HANDSET_6MIC_AND_EC_REF_LOOPBACK,
253 SND_DEVICE_IN_HANDSET_8MIC_AND_EC_REF_LOOPBACK,
Naresh Tannirue3b18452014-03-04 14:44:27 +0530254 SND_DEVICE_IN_END,
255
256 SND_DEVICE_MAX = SND_DEVICE_IN_END,
257
258};
Preetam Singh Ranawatcb6212e2016-07-19 18:33:53 +0530259#define INPUT_SAMPLING_RATE_DSD64 2822400
260#define INPUT_SAMPLING_RATE_DSD128 5644800
Naresh Tannirue3b18452014-03-04 14:44:27 +0530261#define DEFAULT_OUTPUT_SAMPLING_RATE 48000
Preetam Singh Ranawatc61f8672015-06-18 23:20:28 +0530262#define OUTPUT_SAMPLING_RATE_44100 44100
Preetam Singh Ranawatcb6212e2016-07-19 18:33:53 +0530263#define OUTPUT_SAMPLING_RATE_DSD64 176400
264#define OUTPUT_SAMPLING_RATE_DSD128 352800
Preetam Singh Ranawatc61f8672015-06-18 23:20:28 +0530265#define MAX_PORT 6
266#define ALL_CODEC_BACKEND_PORT 0
267#define HEADPHONE_44_1_BACKEND_PORT 5
Apoorv Raghuvanshi21492162015-02-19 18:19:36 -0800268enum {
269 DEFAULT_CODEC_BACKEND,
Sidipotu Ashok9f0b16e2016-04-28 13:48:28 +0530270 SLIMBUS_0_RX = DEFAULT_CODEC_BACKEND,
Preetam Singh Ranawatcb6212e2016-07-19 18:33:53 +0530271 DSD_NATIVE_BACKEND,
272 SLIMBUS_2_RX = DSD_NATIVE_BACKEND,
Apoorv Raghuvanshi21492162015-02-19 18:19:36 -0800273 HEADPHONE_44_1_BACKEND,
Sidipotu Ashok9f0b16e2016-04-28 13:48:28 +0530274 SLIMBUS_5_RX = HEADPHONE_44_1_BACKEND,
275 HEADPHONE_BACKEND,
276 SLIMBUS_6_RX = HEADPHONE_BACKEND,
277 HDMI_RX_BACKEND,
Shiv Maliyappanahallic0656402016-09-03 14:13:26 -0700278 DISP_PORT_RX_BACKEND,
Kuirong Wanga9f7cee2016-03-07 11:21:52 -0800279 USB_AUDIO_RX_BACKEND,
Kuirong Wang0b947f72016-09-29 11:03:09 -0700280 MAX_RX_CODEC_BACKENDS = USB_AUDIO_RX_BACKEND,
281 /* TX BE follows RX BE */
282 SLIMBUS_0_TX,
283 DEFAULT_CODEC_TX_BACKEND = SLIMBUS_0_TX,
284 USB_AUDIO_TX_BACKEND,
Dhanalakshmi Siddanib678a802016-12-03 11:51:41 +0530285 BT_SCO_TX_BACKEND,
Siddartha Shaik44dd7702017-06-14 12:13:25 +0530286 HDMI_TX_BACKEND,
Apoorv Raghuvanshi21492162015-02-19 18:19:36 -0800287 MAX_CODEC_BACKENDS
288};
Kuirong Wang0b947f72016-09-29 11:03:09 -0700289
Preetam Singh Ranawatc61f8672015-06-18 23:20:28 +0530290#define AUDIO_PARAMETER_KEY_NATIVE_AUDIO "audio.nat.codec.enabled"
Sidipotu Ashoke6f78cb2015-11-05 14:42:20 +0530291#define AUDIO_PARAMETER_KEY_NATIVE_AUDIO_MODE "native_audio_mode"
Naresh Tannirue3b18452014-03-04 14:44:27 +0530292
Ashish Jainf1eaa582016-05-23 20:54:24 +0530293#define AUDIO_PARAMETER_KEY_TRUE_32_BIT "true_32_bit"
294
Naresh Tannirudb72d1e2014-03-05 17:33:47 +0530295#define ALL_SESSION_VSID 0xFFFFFFFF
Preetam Singh Ranawat8bde2c52015-03-20 12:00:49 +0530296#define DEFAULT_MUTE_RAMP_DURATION_MS 20
Naresh Tannirudb72d1e2014-03-05 17:33:47 +0530297#define DEFAULT_VOLUME_RAMP_DURATION_MS 20
298#define MIXER_PATH_MAX_LENGTH 100
Sidipotu Ashoke6f78cb2015-11-05 14:42:20 +0530299#define SND_CARD_MAX_LENGTH 100
300#define CODEC_VERSION_MAX_LENGTH 100
Naresh Tannirudb72d1e2014-03-05 17:33:47 +0530301
302#define MAX_VOL_INDEX 5
303#define MIN_VOL_INDEX 0
304#define percent_to_index(val, min, max) \
305 ((val) * ((max) - (min)) * 0.01 + (min) + .5)
306
Naresh Tannirue3b18452014-03-04 14:44:27 +0530307/*
308 * tinyAlsa library interprets period size as number of frames
309 * one frame = channel_count * sizeof (pcm sample)
310 * so if format = 16-bit PCM and channels = Stereo, frame size = 2 ch * 2 = 4 bytes
311 * DEEP_BUFFER_OUTPUT_PERIOD_SIZE = 1024 means 1024 * 4 = 4096 bytes
312 * We should take care of returning proper size when AudioFlinger queries for
313 * the buffer size of an input/output stream
314 */
Alexy Joseph029faa22015-06-18 14:22:14 -0700315#define DEEP_BUFFER_OUTPUT_PERIOD_SIZE 1920
Ashish Jain058165c2016-09-28 23:18:48 +0530316#define DEEP_BUFFER_OUTPUT_PERIOD_DURATION 40 /* 40 millisecs */
Alexy Joseph029faa22015-06-18 14:22:14 -0700317#define DEEP_BUFFER_OUTPUT_PERIOD_COUNT 2
Naresh Tannirudb72d1e2014-03-05 17:33:47 +0530318#define LOW_LATENCY_OUTPUT_PERIOD_SIZE 240
Naresh Tannirue3b18452014-03-04 14:44:27 +0530319#define LOW_LATENCY_OUTPUT_PERIOD_COUNT 2
320
Ravi Kumar Alamandadc9bb152014-09-08 15:59:58 -0700321#define LOW_LATENCY_CAPTURE_SAMPLE_RATE 48000
322#define LOW_LATENCY_CAPTURE_PERIOD_SIZE 240
Sharad Sangle896e7b12014-11-07 17:06:29 +0530323#define LOW_LATENCY_CAPTURE_USE_CASE 1
Ravi Kumar Alamandadc9bb152014-09-08 15:59:58 -0700324
Haynes Mathew George484e8d22017-07-31 18:55:17 -0700325#define HIFI_BUFFER_OUTPUT_PERIOD_SIZE 1920
326#define HIFI_BUFFER_OUTPUT_PERIOD_DURATION 40 /* 40 millisecs */
327#define HIFI_BUFFER_OUTPUT_PERIOD_COUNT 2
328
Naresh Tannirue3b18452014-03-04 14:44:27 +0530329#define HDMI_MULTI_PERIOD_SIZE 336
330#define HDMI_MULTI_PERIOD_COUNT 8
331#define HDMI_MULTI_DEFAULT_CHANNEL_COUNT 6
332#define HDMI_MULTI_PERIOD_BYTES (HDMI_MULTI_PERIOD_SIZE * HDMI_MULTI_DEFAULT_CHANNEL_COUNT * 2)
333
Ashish Jainf1eaa582016-05-23 20:54:24 +0530334
335/* Used in calculating fragment size for pcm offload */
336#define PCM_OFFLOAD_BUFFER_DURATION 40 /* 40 millisecs */
337
338/* MAX PCM fragment size cannot be increased further due
339 * to flinger's cblk size of 1mb,and it has to be a multiple of
340 * 24 - lcm of channels supported by DSP
341 */
342#define MAX_PCM_OFFLOAD_FRAGMENT_SIZE (240 * 1024)
343#define MIN_PCM_OFFLOAD_FRAGMENT_SIZE 512
344
Naresh Tannirudb72d1e2014-03-05 17:33:47 +0530345#define AUDIO_CAPTURE_PERIOD_DURATION_MSEC 20
346#define AUDIO_CAPTURE_PERIOD_COUNT 2
347
348#define DEVICE_NAME_MAX_SIZE 128
349#define HW_INFO_ARRAY_MAX_SIZE 32
350
351#define DEEP_BUFFER_PCM_DEVICE 0
352#define AUDIO_RECORD_PCM_DEVICE 0
353#define MULTIMEDIA2_PCM_DEVICE 1
Naresh Tanniru3a7dbe72015-06-25 20:08:01 -0700354#define MULTIMEDIA3_PCM_DEVICE 4
Shiv Maliyappanahallic0656402016-09-03 14:13:26 -0700355#define MULTIMEDIA9_PCM_DEVICE 32
Naresh Tannirudb72d1e2014-03-05 17:33:47 +0530356#define FM_PLAYBACK_PCM_DEVICE 5
357#define FM_CAPTURE_PCM_DEVICE 6
358#define HFP_PCM_RX 5
Satya Krishna Pindiproli640c91e2014-03-14 11:09:09 +0530359#define HFP_SCO_RX 17
360#define HFP_ASM_RX_TX 18
Naresh Tannirudb72d1e2014-03-05 17:33:47 +0530361
362#define INCALL_MUSIC_UPLINK_PCM_DEVICE 1
363#define INCALL_MUSIC_UPLINK2_PCM_DEVICE 16
364#define SPKR_PROT_CALIB_RX_PCM_DEVICE 5
Laxminath Kasam999caa42015-05-08 18:17:23 +0530365#define SPKR_PROT_CALIB_TX_PCM_DEVICE 26
Naresh Tannirudb72d1e2014-03-05 17:33:47 +0530366#define PLAYBACK_OFFLOAD_DEVICE 9
Naresh Tanniru06f99432015-08-26 14:01:20 -0700367#define PLAYBACK_OFFLOAD_DEVICE2 24
Naresh Tannirudb72d1e2014-03-05 17:33:47 +0530368#define COMPRESS_VOIP_CALL_PCM_DEVICE 3
Vikram Panduranga93f080e2017-06-07 18:16:14 -0700369#define AUDIO_PLAYBACK_VOIP_PCM_DEVICE 16
370#define AUDIO_RECORD_VOIP_PCM_DEVICE 16
Naresh Tannirudb72d1e2014-03-05 17:33:47 +0530371
Banajit Goswami88d6cc52014-04-10 17:59:02 -0700372/* Define macro for Internal FM volume mixer */
Dhananjay Kumard3ab9f42016-07-20 17:05:47 +0530373#ifdef PLATFORM_MSMFALCON
374#define FM_RX_VOLUME "SLIMBUS_8 LOOPBACK Volume"
375#else
Banajit Goswami88d6cc52014-04-10 17:59:02 -0700376#define FM_RX_VOLUME "Internal FM RX Volume"
Dhananjay Kumard3ab9f42016-07-20 17:05:47 +0530377#endif
Naresh Tannirudb72d1e2014-03-05 17:33:47 +0530378
379#define LOWLATENCY_PCM_DEVICE 12
380#define EC_REF_RX "I2S_RX"
381#define COMPRESS_CAPTURE_DEVICE 19
382
383#define VOICE_CALL_PCM_DEVICE 2
384#define VOICE2_CALL_PCM_DEVICE 13
385#define VOLTE_CALL_PCM_DEVICE 15
Karthik Reddy Katta561d4ba2016-06-23 13:41:18 +0530386#define QCHAT_CALL_PCM_DEVICE 37
Karthik Reddy Katta3b0a60c2014-04-06 14:52:37 +0530387#define VOWLAN_CALL_PCM_DEVICE 16
Haynes Mathew George16081042017-05-31 17:16:49 -0700388#define MMAP_PLAYBACK_PCM_DEVICE 2 // XXX: This must be overwritten
389#define MMAP_RECORD_PCM_DEVICE 2 // XXX: This must be overwritten
Naresh Tannirudb72d1e2014-03-05 17:33:47 +0530390
Preetam Singh Ranawat7112f3b2015-02-26 16:51:58 +0530391#define AFE_PROXY_PLAYBACK_PCM_DEVICE 7
392#define AFE_PROXY_RECORD_PCM_DEVICE 8
393
Siddartha Shaik31b530e2017-05-19 15:26:33 +0530394#define TRANSCODE_LOOPBACK_RX_DEV_ID 43
395#define TRANSCODE_LOOPBACK_TX_DEV_ID 44
396
Varun Balaraje49253e2017-07-06 19:48:56 +0530397#define PLAYBACK_INTERACTIVE_STRM_DEVICE1 0
398#define PLAYBACK_INTERACTIVE_STRM_DEVICE2 1
399#define PLAYBACK_INTERACTIVE_STRM_DEVICE3 27
400#define PLAYBACK_INTERACTIVE_STRM_DEVICE4 45
401#define PLAYBACK_INTERACTIVE_STRM_DEVICE5 46
402#define PLAYBACK_INTERACTIVE_STRM_DEVICE6 47
403#define PLAYBACK_INTERACTIVE_STRM_DEVICE7 48
404#define PLAYBACK_INTERACTIVE_STRM_DEVICE8 49
405
Chaithanya Krishna Bacharaju9955b162016-05-25 16:25:53 +0530406#define PLATFORM_MAX_MIC_COUNT "input_mic_max_count"
407#define PLATFORM_DEFAULT_MIC_COUNT 2
408
Vikram Pandurangadf59cae2017-08-03 18:04:55 -0700409#define TX_VOICE_FLUENCE_PROV2 0x10F17
Vignesh Kulothungan80d87ee2018-07-17 11:59:25 -0700410#define TX_VOICE_TM_FLUENCE_PRO_VC 0x10F35
Vikram Pandurangadf59cae2017-08-03 18:04:55 -0700411#define TX_VOICE_DM_FV5_BROADSIDE 0x10F18
412#define TX_VOICE_FV5ECNS_SM 0x10F09
413#define TX_VOICE_FV5ECNS_DM 0x10F0A
Vignesh Kulothungan033c7cb2018-07-12 11:35:57 -0700414#define TX_VOICE_SMECNS_V2 0x10F31
Vikram Pandurangadf59cae2017-08-03 18:04:55 -0700415
Naresh Tannirudcb47c52018-06-25 16:23:32 +0530416#define AUDIO_MAKE_STRING_FROM_ENUM(X) { #X, X }
417
Naresh Tannirudb72d1e2014-03-05 17:33:47 +0530418#define LIB_CSD_CLIENT "libcsd-client.so"
419/* CSD-CLIENT related functions */
420typedef int (*init_t)();
421typedef int (*deinit_t)();
422typedef int (*disable_device_t)();
423typedef int (*enable_device_config_t)(int, int);
424typedef int (*enable_device_t)(int, int, uint32_t);
Preetam Singh Ranawat8bde2c52015-03-20 12:00:49 +0530425typedef int (*volume_t)(uint32_t, int, uint16_t);
426typedef int (*mic_mute_t)(uint32_t, int, uint16_t);
Naresh Tannirudb72d1e2014-03-05 17:33:47 +0530427typedef int (*slow_talk_t)(uint32_t, uint8_t);
428typedef int (*start_voice_t)(uint32_t);
429typedef int (*stop_voice_t)(uint32_t);
430typedef int (*start_playback_t)(uint32_t);
431typedef int (*stop_playback_t)(uint32_t);
Vidyakumar Athota21b3bb92014-04-25 11:08:08 -0700432typedef int (*set_lch_t)(uint32_t, enum voice_lch_mode);
Naresh Tannirudb72d1e2014-03-05 17:33:47 +0530433typedef int (*start_record_t)(uint32_t, int);
434typedef int (*stop_record_t)(uint32_t);
435/* CSD Client structure */
436struct csd_data {
437 void *csd_client;
438 init_t init;
439 deinit_t deinit;
440 disable_device_t disable_device;
441 enable_device_config_t enable_device_config;
442 enable_device_t enable_device;
443 volume_t volume;
444 mic_mute_t mic_mute;
445 slow_talk_t slow_talk;
446 start_voice_t start_voice;
447 stop_voice_t stop_voice;
448 start_playback_t start_playback;
449 stop_playback_t stop_playback;
Vidyakumar Athota21b3bb92014-04-25 11:08:08 -0700450 set_lch_t set_lch;
Naresh Tannirudb72d1e2014-03-05 17:33:47 +0530451 start_record_t start_record;
452 stop_record_t stop_record;
453};
Naresh Tannirue3b18452014-03-04 14:44:27 +0530454
Preetam Singh Ranawat2d0e4632015-02-02 12:40:59 +0530455int platform_get_subsys_image_name (char *buf);
456
Preetam Singh Ranawat8bde2c52015-03-20 12:00:49 +0530457/* HDMI Passthrough defines */
458enum {
459 LEGACY_PCM = 0,
460 PASSTHROUGH,
Preetam Singh Ranawatcb6212e2016-07-19 18:33:53 +0530461 PASSTHROUGH_CONVERT,
Naresh Tanniru928f0862017-04-07 16:44:23 -0700462 PASSTHROUGH_DSD,
463 LISTEN,
464 PASSTHROUGH_GEN,
465 PASSTHROUGH_IEC61937
Preetam Singh Ranawat8bde2c52015-03-20 12:00:49 +0530466};
467/*
468 * ID for setting mute and lateny on the device side
469 * through Device PP Params mixer control.
470 */
471#define DEVICE_PARAM_MUTE_ID 0
472#define DEVICE_PARAM_LATENCY_ID 1
Ben Romberger6c4d3812017-06-13 17:46:45 -0700473#define DEVICE_PARAM_LIMITER_ID 2
Karthik Reddy Kattae4078ed2015-04-21 11:46:15 +0530474
475#define ENUM_TO_STRING(X) #X
476
477struct audio_device_to_audio_interface {
478 audio_devices_t device;
479 char device_name[100];
480 char interface_name[100];
481};
Ashish Jaind84fd6a2016-07-27 12:33:25 +0530482
Naresh Tannirue3b18452014-03-04 14:44:27 +0530483#endif // QCOM_AUDIO_PLATFORM_H