blob: 44842b5c6245e48984b315dd116a8be090ca9c7a [file] [log] [blame]
Eric Laurentb23d5282013-05-14 15:27:20 -07001/*
Apoorv Raghuvanshi9eaf94e2013-10-04 16:13:44 -07002 * Copyright (c) 2013, The Linux Foundation. All rights reserved.
3 * Not a Contribution.
4 *
Eric Laurentb23d5282013-05-14 15:27:20 -07005 * 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#define LOG_TAG "msm8974_platform"
21/*#define LOG_NDEBUG 0*/
22#define LOG_NDDEBUG 0
23
24#include <stdlib.h>
25#include <dlfcn.h>
26#include <cutils/log.h>
27#include <cutils/properties.h>
Shiv Maliyappanahalli34b585f2013-10-01 15:49:05 -070028#include <cutils/str_parms.h>
Eric Laurentb23d5282013-05-14 15:27:20 -070029#include <audio_hw.h>
30#include <platform_api.h>
31#include "platform.h"
Apoorv Raghuvanshi9eaf94e2013-10-04 16:13:44 -070032#include "audio_extn.h"
Eric Laurentb23d5282013-05-14 15:27:20 -070033
Haynes Mathew George47cd4cb2013-07-19 11:58:50 -070034#define MIXER_XML_PATH "/system/etc/mixer_paths.xml"
Eric Laurentb23d5282013-05-14 15:27:20 -070035#define LIB_ACDB_LOADER "libacdbloader.so"
Haynes Mathew George47cd4cb2013-07-19 11:58:50 -070036#define AUDIO_DATA_BLOCK_MIXER_CTL "HDMI EDID"
Eric Laurentb23d5282013-05-14 15:27:20 -070037
Eric Laurentb23d5282013-05-14 15:27:20 -070038/*
Eric Laurentb23d5282013-05-14 15:27:20 -070039 * This file will have a maximum of 38 bytes:
40 *
41 * 4 bytes: number of audio blocks
42 * 4 bytes: total length of Short Audio Descriptor (SAD) blocks
43 * Maximum 10 * 3 bytes: SAD blocks
44 */
45#define MAX_SAD_BLOCKS 10
46#define SAD_BLOCK_SIZE 3
47
48/* EDID format ID for LPCM audio */
49#define EDID_FORMAT_LPCM 1
50
sangwoo1b9f4b32013-06-21 18:22:55 -070051/* Retry for delay in FW loading*/
52#define RETRY_NUMBER 10
53#define RETRY_US 500000
54
Shiv Maliyappanahalli34b585f2013-10-01 15:49:05 -070055#define SAMPLE_RATE_8KHZ 8000
56#define SAMPLE_RATE_16KHZ 16000
57
sangwoo53b2cf02013-07-25 19:18:44 -070058#define MAX_VOL_INDEX 5
59#define MIN_VOL_INDEX 0
60#define percent_to_index(val, min, max) \
Shiv Maliyappanahalli34b585f2013-10-01 15:49:05 -070061 ((val) * ((max) - (min)) * 0.01 + (min) + .5)
62
63#define AUDIO_PARAMETER_KEY_FLUENCE_TYPE "fluence"
64#define AUDIO_PARAMETER_KEY_BTSCO "bt_samplerate"
65#define AUDIO_PARAMETER_KEY_SLOWTALK "st_enable"
sangwoo53b2cf02013-07-25 19:18:44 -070066
Eric Laurentb23d5282013-05-14 15:27:20 -070067struct audio_block_header
68{
69 int reserved;
70 int length;
71};
72
73typedef void (*acdb_deallocate_t)();
74typedef int (*acdb_init_t)();
75typedef void (*acdb_send_audio_cal_t)(int, int);
76typedef void (*acdb_send_voice_cal_t)(int, int);
77
Eric Laurentb23d5282013-05-14 15:27:20 -070078struct platform_data {
79 struct audio_device *adev;
80 bool fluence_in_spkr_mode;
81 bool fluence_in_voice_call;
82 bool fluence_in_voice_rec;
Mingming Yin8e5a4f62013-10-07 15:23:41 -070083 int fluence_type;
Shiv Maliyappanahalli34b585f2013-10-01 15:49:05 -070084 int btsco_sample_rate;
85 bool slowtalk;
Eric Laurentb23d5282013-05-14 15:27:20 -070086
Ravi Kumar Alamanda48c921d2013-10-29 06:07:44 -070087 /* Audio calibration related functions */
Eric Laurentb23d5282013-05-14 15:27:20 -070088 void *acdb_handle;
89 acdb_init_t acdb_init;
90 acdb_deallocate_t acdb_deallocate;
91 acdb_send_audio_cal_t acdb_send_audio_cal;
92 acdb_send_voice_cal_t acdb_send_voice_cal;
Ravi Kumar Alamanda48c921d2013-10-29 06:07:44 -070093
94 void *hw_info;
Eric Laurentb23d5282013-05-14 15:27:20 -070095};
96
97static const int pcm_device_table[AUDIO_USECASE_MAX][2] = {
Mingming Yin8e5a4f62013-10-07 15:23:41 -070098 [USECASE_AUDIO_PLAYBACK_DEEP_BUFFER] = {DEEP_BUFFER_PCM_DEVICE,
99 DEEP_BUFFER_PCM_DEVICE},
100 [USECASE_AUDIO_PLAYBACK_LOW_LATENCY] = {LOWLATENCY_PCM_DEVICE,
101 LOWLATENCY_PCM_DEVICE},
102 [USECASE_AUDIO_PLAYBACK_MULTI_CH] = {MULTI_CHANNEL_PCM_DEVICE,
103 MULTI_CHANNEL_PCM_DEVICE},
Krishnankutty Kolathappillya43f96e2013-11-01 12:17:53 -0700104 [USECASE_AUDIO_PLAYBACK_OFFLOAD] =
105 {PLAYBACK_OFFLOAD_DEVICE, PLAYBACK_OFFLOAD_DEVICE},
Shiv Maliyappanahallida107642013-10-17 11:16:13 -0700106 [USECASE_AUDIO_RECORD] = {AUDIO_RECORD_PCM_DEVICE, AUDIO_RECORD_PCM_DEVICE},
Mingming Yin8e5a4f62013-10-07 15:23:41 -0700107 [USECASE_AUDIO_RECORD_LOW_LATENCY] = {LOWLATENCY_PCM_DEVICE,
108 LOWLATENCY_PCM_DEVICE},
Apoorv Raghuvanshi6e262842013-10-06 14:39:35 -0700109 [USECASE_AUDIO_PLAYBACK_FM] = {FM_PLAYBACK_PCM_DEVICE, FM_CAPTURE_PCM_DEVICE},
Shiv Maliyappanahalli34b585f2013-10-01 15:49:05 -0700110 [USECASE_VOICE_CALL] = {VOICE_CALL_PCM_DEVICE, VOICE_CALL_PCM_DEVICE},
111 [USECASE_VOICE2_CALL] = {VOICE2_CALL_PCM_DEVICE, VOICE2_CALL_PCM_DEVICE},
112 [USECASE_VOLTE_CALL] = {VOLTE_CALL_PCM_DEVICE, VOLTE_CALL_PCM_DEVICE},
113 [USECASE_QCHAT_CALL] = {QCHAT_CALL_PCM_DEVICE, QCHAT_CALL_PCM_DEVICE},
Shiv Maliyappanahallida107642013-10-17 11:16:13 -0700114 [USECASE_INCALL_REC_UPLINK] = {AUDIO_RECORD_PCM_DEVICE,
115 AUDIO_RECORD_PCM_DEVICE},
116 [USECASE_INCALL_REC_DOWNLINK] = {AUDIO_RECORD_PCM_DEVICE,
117 AUDIO_RECORD_PCM_DEVICE},
118 [USECASE_INCALL_REC_UPLINK_AND_DOWNLINK] = {AUDIO_RECORD_PCM_DEVICE,
119 AUDIO_RECORD_PCM_DEVICE},
Shiv Maliyappanahallif3b9a422013-10-22 16:38:08 -0700120 [USECASE_INCALL_MUSIC_UPLINK] = {INCALL_MUSIC_UPLINK_PCM_DEVICE,
121 INCALL_MUSIC_UPLINK_PCM_DEVICE},
122 [USECASE_INCALL_MUSIC_UPLINK2] = {INCALL_MUSIC_UPLINK2_PCM_DEVICE,
123 INCALL_MUSIC_UPLINK2_PCM_DEVICE},
Eric Laurentb23d5282013-05-14 15:27:20 -0700124};
125
126/* Array to store sound devices */
127static const char * const device_table[SND_DEVICE_MAX] = {
128 [SND_DEVICE_NONE] = "none",
129 /* Playback sound devices */
130 [SND_DEVICE_OUT_HANDSET] = "handset",
131 [SND_DEVICE_OUT_SPEAKER] = "speaker",
132 [SND_DEVICE_OUT_SPEAKER_REVERSE] = "speaker-reverse",
133 [SND_DEVICE_OUT_HEADPHONES] = "headphones",
134 [SND_DEVICE_OUT_SPEAKER_AND_HEADPHONES] = "speaker-and-headphones",
135 [SND_DEVICE_OUT_VOICE_HANDSET] = "voice-handset",
136 [SND_DEVICE_OUT_VOICE_SPEAKER] = "voice-speaker",
137 [SND_DEVICE_OUT_VOICE_HEADPHONES] = "voice-headphones",
138 [SND_DEVICE_OUT_HDMI] = "hdmi",
139 [SND_DEVICE_OUT_SPEAKER_AND_HDMI] = "speaker-and-hdmi",
140 [SND_DEVICE_OUT_BT_SCO] = "bt-sco-headset",
Shiv Maliyappanahalli34b585f2013-10-01 15:49:05 -0700141 [SND_DEVICE_OUT_BT_SCO_WB] = "bt-sco-headset-wb",
Eric Laurentb23d5282013-05-14 15:27:20 -0700142 [SND_DEVICE_OUT_VOICE_HANDSET_TMUS] = "voice-handset-tmus",
143 [SND_DEVICE_OUT_VOICE_TTY_FULL_HEADPHONES] = "voice-tty-full-headphones",
144 [SND_DEVICE_OUT_VOICE_TTY_VCO_HEADPHONES] = "voice-tty-vco-headphones",
145 [SND_DEVICE_OUT_VOICE_TTY_HCO_HANDSET] = "voice-tty-hco-handset",
Apoorv Raghuvanshi5792d4b2013-10-07 18:40:05 -0700146 [SND_DEVICE_OUT_AFE_PROXY] = "afe-proxy",
147 [SND_DEVICE_OUT_USB_HEADSET] = "usb-headphones",
148 [SND_DEVICE_OUT_SPEAKER_AND_USB_HEADSET] = "speaker-and-usb-headphones",
Apoorv Raghuvanshi6e262842013-10-06 14:39:35 -0700149 [SND_DEVICE_OUT_TRANSMISSION_FM] = "transmission-fm",
Apoorv Raghuvanshi9eaf94e2013-10-04 16:13:44 -0700150 [SND_DEVICE_OUT_ANC_HEADSET] = "anc-headphones",
151 [SND_DEVICE_OUT_ANC_FB_HEADSET] = "anc-fb-headphones",
152 [SND_DEVICE_OUT_VOICE_ANC_HEADSET] = "voice-anc-headphones",
153 [SND_DEVICE_OUT_VOICE_ANC_FB_HEADSET] = "voice-anc-fb-headphones",
154 [SND_DEVICE_OUT_SPEAKER_AND_ANC_HEADSET] = "speaker-and-anc-headphones",
155 [SND_DEVICE_OUT_ANC_HANDSET] = "anc-handset",
Eric Laurentb23d5282013-05-14 15:27:20 -0700156
157 /* Capture sound devices */
158 [SND_DEVICE_IN_HANDSET_MIC] = "handset-mic",
159 [SND_DEVICE_IN_SPEAKER_MIC] = "speaker-mic",
160 [SND_DEVICE_IN_HEADSET_MIC] = "headset-mic",
161 [SND_DEVICE_IN_HANDSET_MIC_AEC] = "handset-mic",
162 [SND_DEVICE_IN_SPEAKER_MIC_AEC] = "voice-speaker-mic",
163 [SND_DEVICE_IN_HEADSET_MIC_AEC] = "headset-mic",
164 [SND_DEVICE_IN_VOICE_SPEAKER_MIC] = "voice-speaker-mic",
165 [SND_DEVICE_IN_VOICE_HEADSET_MIC] = "voice-headset-mic",
166 [SND_DEVICE_IN_HDMI_MIC] = "hdmi-mic",
167 [SND_DEVICE_IN_BT_SCO_MIC] = "bt-sco-mic",
Shiv Maliyappanahalli34b585f2013-10-01 15:49:05 -0700168 [SND_DEVICE_IN_BT_SCO_MIC_WB] = "bt-sco-mic-wb",
Eric Laurentb23d5282013-05-14 15:27:20 -0700169 [SND_DEVICE_IN_CAMCORDER_MIC] = "camcorder-mic",
Mingming Yin8e5a4f62013-10-07 15:23:41 -0700170 [SND_DEVICE_IN_VOICE_DMIC] = "voice-dmic-ef",
171 [SND_DEVICE_IN_VOICE_DMIC_TMUS] = "voice-dmic-ef-tmus",
172 [SND_DEVICE_IN_VOICE_SPEAKER_DMIC] = "voice-speaker-dmic-ef",
Eric Laurentb23d5282013-05-14 15:27:20 -0700173 [SND_DEVICE_IN_VOICE_TTY_FULL_HEADSET_MIC] = "voice-tty-full-headset-mic",
174 [SND_DEVICE_IN_VOICE_TTY_VCO_HANDSET_MIC] = "voice-tty-vco-handset-mic",
175 [SND_DEVICE_IN_VOICE_TTY_HCO_HEADSET_MIC] = "voice-tty-hco-headset-mic",
176 [SND_DEVICE_IN_VOICE_REC_MIC] = "voice-rec-mic",
Mingming Yin8e5a4f62013-10-07 15:23:41 -0700177 [SND_DEVICE_IN_VOICE_REC_DMIC] = "voice-rec-dmic-ef",
178 [SND_DEVICE_IN_VOICE_REC_DMIC_FLUENCE] = "voice-rec-dmic-ef-fluence",
Apoorv Raghuvanshi5792d4b2013-10-07 18:40:05 -0700179 [SND_DEVICE_IN_USB_HEADSET_MIC] = "usb-headset-mic",
Apoorv Raghuvanshi6e262842013-10-06 14:39:35 -0700180 [SND_DEVICE_IN_CAPTURE_FM] = "capture-fm",
Apoorv Raghuvanshi9eaf94e2013-10-04 16:13:44 -0700181 [SND_DEVICE_IN_AANC_HANDSET_MIC] = "aanc-handset-mic",
Apoorv Raghuvanshi6178a3f2013-10-19 12:38:54 -0700182 [SND_DEVICE_IN_QUAD_MIC] = "quad-mic",
Apoorv Raghuvanshi6bd8dbf2013-10-19 18:37:52 -0700183 [SND_DEVICE_IN_HANDSET_STEREO_DMIC] = "handset-stereo-dmic-ef",
184 [SND_DEVICE_IN_SPEAKER_STEREO_DMIC] = "speaker-stereo-dmic-ef",
Eric Laurentb23d5282013-05-14 15:27:20 -0700185};
186
187/* ACDB IDs (audio DSP path configuration IDs) for each sound device */
188static const int acdb_device_table[SND_DEVICE_MAX] = {
189 [SND_DEVICE_NONE] = -1,
190 [SND_DEVICE_OUT_HANDSET] = 7,
191 [SND_DEVICE_OUT_SPEAKER] = 15,
192 [SND_DEVICE_OUT_SPEAKER_REVERSE] = 15,
193 [SND_DEVICE_OUT_HEADPHONES] = 10,
194 [SND_DEVICE_OUT_SPEAKER_AND_HEADPHONES] = 10,
195 [SND_DEVICE_OUT_VOICE_HANDSET] = 7,
196 [SND_DEVICE_OUT_VOICE_SPEAKER] = 15,
197 [SND_DEVICE_OUT_VOICE_HEADPHONES] = 10,
198 [SND_DEVICE_OUT_HDMI] = 18,
199 [SND_DEVICE_OUT_SPEAKER_AND_HDMI] = 15,
200 [SND_DEVICE_OUT_BT_SCO] = 22,
Shiv Maliyappanahalli34b585f2013-10-01 15:49:05 -0700201 [SND_DEVICE_OUT_BT_SCO_WB] = 39,
sangwooc69476f2013-07-26 16:57:26 -0700202 [SND_DEVICE_OUT_VOICE_HANDSET_TMUS] = 88,
Eric Laurentb23d5282013-05-14 15:27:20 -0700203 [SND_DEVICE_OUT_VOICE_TTY_FULL_HEADPHONES] = 17,
204 [SND_DEVICE_OUT_VOICE_TTY_VCO_HEADPHONES] = 17,
205 [SND_DEVICE_OUT_VOICE_TTY_HCO_HANDSET] = 37,
Apoorv Raghuvanshi5792d4b2013-10-07 18:40:05 -0700206 [SND_DEVICE_OUT_AFE_PROXY] = 0,
207 [SND_DEVICE_OUT_USB_HEADSET] = 0,
208 [SND_DEVICE_OUT_SPEAKER_AND_USB_HEADSET] = 14,
Apoorv Raghuvanshi6e262842013-10-06 14:39:35 -0700209 [SND_DEVICE_OUT_TRANSMISSION_FM] = 0,
Apoorv Raghuvanshi9eaf94e2013-10-04 16:13:44 -0700210 [SND_DEVICE_OUT_ANC_HEADSET] = 26,
Ravi Kumar Alamanda48c921d2013-10-29 06:07:44 -0700211 [SND_DEVICE_OUT_ANC_FB_HEADSET] = 27,
Apoorv Raghuvanshi9eaf94e2013-10-04 16:13:44 -0700212 [SND_DEVICE_OUT_VOICE_ANC_HEADSET] = 26,
Ravi Kumar Alamanda48c921d2013-10-29 06:07:44 -0700213 [SND_DEVICE_OUT_VOICE_ANC_FB_HEADSET] = 27,
Apoorv Raghuvanshi9eaf94e2013-10-04 16:13:44 -0700214 [SND_DEVICE_OUT_SPEAKER_AND_ANC_HEADSET] = 26,
215 [SND_DEVICE_OUT_ANC_HANDSET] = 103,
Eric Laurentb23d5282013-05-14 15:27:20 -0700216
217 [SND_DEVICE_IN_HANDSET_MIC] = 4,
218 [SND_DEVICE_IN_SPEAKER_MIC] = 4, /* ToDo: Check if this needs to changed to 11 */
219 [SND_DEVICE_IN_HEADSET_MIC] = 8,
220 [SND_DEVICE_IN_HANDSET_MIC_AEC] = 40,
221 [SND_DEVICE_IN_SPEAKER_MIC_AEC] = 42,
222 [SND_DEVICE_IN_HEADSET_MIC_AEC] = 47,
223 [SND_DEVICE_IN_VOICE_SPEAKER_MIC] = 11,
224 [SND_DEVICE_IN_VOICE_HEADSET_MIC] = 8,
225 [SND_DEVICE_IN_HDMI_MIC] = 4,
226 [SND_DEVICE_IN_BT_SCO_MIC] = 21,
Shiv Maliyappanahalli34b585f2013-10-01 15:49:05 -0700227 [SND_DEVICE_IN_BT_SCO_MIC_WB] = 38,
Eric Laurentb23d5282013-05-14 15:27:20 -0700228 [SND_DEVICE_IN_CAMCORDER_MIC] = 61,
Mingming Yin8e5a4f62013-10-07 15:23:41 -0700229 [SND_DEVICE_IN_VOICE_DMIC] = 41,
230 [SND_DEVICE_IN_VOICE_DMIC_TMUS] = 89,
231 [SND_DEVICE_IN_VOICE_SPEAKER_DMIC] = 43,
Eric Laurentb23d5282013-05-14 15:27:20 -0700232 [SND_DEVICE_IN_VOICE_TTY_FULL_HEADSET_MIC] = 16,
233 [SND_DEVICE_IN_VOICE_TTY_VCO_HANDSET_MIC] = 36,
234 [SND_DEVICE_IN_VOICE_TTY_HCO_HEADSET_MIC] = 16,
235 [SND_DEVICE_IN_VOICE_REC_MIC] = 62,
Apoorv Raghuvanshi5792d4b2013-10-07 18:40:05 -0700236 [SND_DEVICE_IN_USB_HEADSET_MIC] = 44,
Apoorv Raghuvanshi6e262842013-10-06 14:39:35 -0700237 [SND_DEVICE_IN_CAPTURE_FM] = 0,
Apoorv Raghuvanshi9eaf94e2013-10-04 16:13:44 -0700238 [SND_DEVICE_IN_AANC_HANDSET_MIC] = 104,
Apoorv Raghuvanshi6178a3f2013-10-19 12:38:54 -0700239 [SND_DEVICE_IN_QUAD_MIC] = 46,
Apoorv Raghuvanshi6bd8dbf2013-10-19 18:37:52 -0700240 [SND_DEVICE_IN_HANDSET_STEREO_DMIC] = 34,
241 [SND_DEVICE_IN_SPEAKER_STEREO_DMIC] = 35,
Eric Laurentb23d5282013-05-14 15:27:20 -0700242 /* TODO: Update with proper acdb ids */
Mingming Yin8e5a4f62013-10-07 15:23:41 -0700243 [SND_DEVICE_IN_VOICE_REC_DMIC] = 62,
244 [SND_DEVICE_IN_VOICE_REC_DMIC_FLUENCE] = 6,
Eric Laurentb23d5282013-05-14 15:27:20 -0700245};
246
Haynes Mathew George7ff216f2013-09-11 19:51:41 -0700247#define DEEP_BUFFER_PLATFORM_DELAY (29*1000LL)
248#define LOW_LATENCY_PLATFORM_DELAY (13*1000LL)
249
Eric Laurentb23d5282013-05-14 15:27:20 -0700250static pthread_once_t check_op_once_ctl = PTHREAD_ONCE_INIT;
251static bool is_tmus = false;
252
253static void check_operator()
254{
255 char value[PROPERTY_VALUE_MAX];
256 int mccmnc;
257 property_get("gsm.sim.operator.numeric",value,"0");
258 mccmnc = atoi(value);
259 ALOGD("%s: tmus mccmnc %d", __func__, mccmnc);
260 switch(mccmnc) {
261 /* TMUS MCC(310), MNC(490, 260, 026) */
262 case 310490:
263 case 310260:
264 case 310026:
sangwon.jeonb891db52013-09-14 17:39:15 +0900265 /* Add new TMUS MNC(800, 660, 580, 310, 270, 250, 240, 230, 220, 210, 200, 160) */
266 case 310800:
267 case 310660:
268 case 310580:
269 case 310310:
270 case 310270:
271 case 310250:
272 case 310240:
273 case 310230:
274 case 310220:
275 case 310210:
276 case 310200:
277 case 310160:
Eric Laurentb23d5282013-05-14 15:27:20 -0700278 is_tmus = true;
279 break;
280 }
281}
282
283bool is_operator_tmus()
284{
285 pthread_once(&check_op_once_ctl, check_operator);
286 return is_tmus;
287}
288
289static int set_echo_reference(struct mixer *mixer, const char* ec_ref)
290{
291 struct mixer_ctl *ctl;
292 const char *mixer_ctl_name = "EC_REF_RX";
293
294 ctl = mixer_get_ctl_by_name(mixer, mixer_ctl_name);
295 if (!ctl) {
296 ALOGE("%s: Could not get ctl for mixer cmd - %s",
297 __func__, mixer_ctl_name);
298 return -EINVAL;
299 }
300 ALOGV("Setting EC Reference: %s", ec_ref);
301 mixer_ctl_set_enum_by_string(ctl, ec_ref);
302 return 0;
303}
304
305void *platform_init(struct audio_device *adev)
306{
307 char value[PROPERTY_VALUE_MAX];
308 struct platform_data *my_data;
Ravi Kumar Alamanda48c921d2013-10-29 06:07:44 -0700309 int retry_num = 0;
310 const char *snd_card_name;
sangwoo1b9f4b32013-06-21 18:22:55 -0700311
312 adev->mixer = mixer_open(MIXER_CARD);
313
314 while (!adev->mixer && retry_num < RETRY_NUMBER) {
315 usleep(RETRY_US);
316 adev->mixer = mixer_open(MIXER_CARD);
317 retry_num++;
318 }
319
320 if (!adev->mixer) {
321 ALOGE("Unable to open the mixer, aborting.");
322 return NULL;
323 }
324
325 adev->audio_route = audio_route_init(MIXER_CARD, MIXER_XML_PATH);
326 if (!adev->audio_route) {
327 ALOGE("%s: Failed to init audio route controls, aborting.", __func__);
328 return NULL;
329 }
Eric Laurentb23d5282013-05-14 15:27:20 -0700330
331 my_data = calloc(1, sizeof(struct platform_data));
332
Ravi Kumar Alamanda48c921d2013-10-29 06:07:44 -0700333 snd_card_name = mixer_get_name(adev->mixer);
334 my_data->hw_info = hw_info_init(snd_card_name);
335 if (!my_data->hw_info) {
336 ALOGE("%s: Failed to init hardware info", __func__);
337 }
338
Eric Laurentb23d5282013-05-14 15:27:20 -0700339 my_data->adev = adev;
Shiv Maliyappanahalli34b585f2013-10-01 15:49:05 -0700340 my_data->btsco_sample_rate = SAMPLE_RATE_8KHZ;
Eric Laurentb23d5282013-05-14 15:27:20 -0700341 my_data->fluence_in_spkr_mode = false;
342 my_data->fluence_in_voice_call = false;
343 my_data->fluence_in_voice_rec = false;
Mingming Yin8e5a4f62013-10-07 15:23:41 -0700344 my_data->fluence_type = FLUENCE_NONE;
Eric Laurentb23d5282013-05-14 15:27:20 -0700345
Mingming Yin8e5a4f62013-10-07 15:23:41 -0700346 property_get("ro.qc.sdk.audio.fluencetype", value, "");
347 if (!strncmp("fluencepro", value, sizeof("fluencepro"))) {
348 my_data->fluence_type = FLUENCE_QUAD_MIC;
349 } else if (!strncmp("fluence", value, sizeof("fluence"))) {
350 my_data->fluence_type = FLUENCE_DUAL_MIC;
351 } else {
352 my_data->fluence_type = FLUENCE_NONE;
Eric Laurentb23d5282013-05-14 15:27:20 -0700353 }
354
Mingming Yin8e5a4f62013-10-07 15:23:41 -0700355 if (my_data->fluence_type != FLUENCE_NONE) {
Eric Laurentb23d5282013-05-14 15:27:20 -0700356 property_get("persist.audio.fluence.voicecall",value,"");
Mingming Yin8e5a4f62013-10-07 15:23:41 -0700357 if (!strncmp("true", value, sizeof("true"))) {
Eric Laurentb23d5282013-05-14 15:27:20 -0700358 my_data->fluence_in_voice_call = true;
359 }
360
361 property_get("persist.audio.fluence.voicerec",value,"");
Mingming Yin8e5a4f62013-10-07 15:23:41 -0700362 if (!strncmp("true", value, sizeof("true"))) {
Eric Laurentb23d5282013-05-14 15:27:20 -0700363 my_data->fluence_in_voice_rec = true;
364 }
365
366 property_get("persist.audio.fluence.speaker",value,"");
Mingming Yin8e5a4f62013-10-07 15:23:41 -0700367 if (!strncmp("true", value, sizeof("true"))) {
Eric Laurentb23d5282013-05-14 15:27:20 -0700368 my_data->fluence_in_spkr_mode = true;
369 }
370 }
371
372 my_data->acdb_handle = dlopen(LIB_ACDB_LOADER, RTLD_NOW);
373 if (my_data->acdb_handle == NULL) {
374 ALOGE("%s: DLOPEN failed for %s", __func__, LIB_ACDB_LOADER);
375 } else {
376 ALOGV("%s: DLOPEN successful for %s", __func__, LIB_ACDB_LOADER);
377 my_data->acdb_deallocate = (acdb_deallocate_t)dlsym(my_data->acdb_handle,
378 "acdb_loader_deallocate_ACDB");
379 my_data->acdb_send_audio_cal = (acdb_send_audio_cal_t)dlsym(my_data->acdb_handle,
380 "acdb_loader_send_audio_cal");
381 if (!my_data->acdb_send_audio_cal)
382 ALOGW("%s: Could not find the symbol acdb_send_audio_cal from %s",
383 __func__, LIB_ACDB_LOADER);
384 my_data->acdb_send_voice_cal = (acdb_send_voice_cal_t)dlsym(my_data->acdb_handle,
385 "acdb_loader_send_voice_cal");
386 my_data->acdb_init = (acdb_init_t)dlsym(my_data->acdb_handle,
387 "acdb_loader_init_ACDB");
388 if (my_data->acdb_init == NULL)
389 ALOGE("%s: dlsym error %s for acdb_loader_init_ACDB", __func__, dlerror());
390 else
391 my_data->acdb_init();
392 }
393
Apoorv Raghuvanshi5792d4b2013-10-07 18:40:05 -0700394 /* init usb */
395 audio_extn_usb_init(adev);
396
Apoorv Raghuvanshi6178a3f2013-10-19 12:38:54 -0700397 /* Read one time ssr property */
398 audio_extn_ssr_update_enabled(adev);
399
Eric Laurentb23d5282013-05-14 15:27:20 -0700400 return my_data;
401}
402
403void platform_deinit(void *platform)
404{
Ravi Kumar Alamanda48c921d2013-10-29 06:07:44 -0700405 struct platform_data *my_data = (struct platform_data *)platform;
406
407 hw_info_deinit(my_data->hw_info);
Eric Laurentb23d5282013-05-14 15:27:20 -0700408 free(platform);
Apoorv Raghuvanshi5792d4b2013-10-07 18:40:05 -0700409 /* deinit usb */
410 audio_extn_usb_deinit();
Eric Laurentb23d5282013-05-14 15:27:20 -0700411}
412
413const char *platform_get_snd_device_name(snd_device_t snd_device)
414{
415 if (snd_device >= SND_DEVICE_MIN && snd_device < SND_DEVICE_MAX)
416 return device_table[snd_device];
417 else
418 return "";
419}
420
Ravi Kumar Alamanda48c921d2013-10-29 06:07:44 -0700421int platform_get_snd_device_name_extn(void *platform, snd_device_t snd_device,
422 char *device_name)
423{
424 struct platform_data *my_data = (struct platform_data *)platform;
425
426 if (snd_device >= SND_DEVICE_MIN && snd_device < SND_DEVICE_MAX) {
427 strlcpy(device_name, device_table[snd_device], DEVICE_NAME_MAX_SIZE);
428 hw_info_append_hw_type(my_data->hw_info, snd_device, device_name);
429 } else {
430 strlcpy(device_name, "", DEVICE_NAME_MAX_SIZE);
431 return -EINVAL;
432 }
433
434 return 0;
435}
436
Eric Laurentb23d5282013-05-14 15:27:20 -0700437void platform_add_backend_name(char *mixer_path, snd_device_t snd_device)
438{
439 if (snd_device == SND_DEVICE_IN_BT_SCO_MIC)
Shiv Maliyappanahalli34b585f2013-10-01 15:49:05 -0700440 strlcat(mixer_path, " bt-sco", MIXER_PATH_MAX_LENGTH);
441 else if (snd_device == SND_DEVICE_IN_BT_SCO_MIC_WB)
442 strlcat(mixer_path, " bt-sco-wb", MIXER_PATH_MAX_LENGTH);
Eric Laurentb23d5282013-05-14 15:27:20 -0700443 else if(snd_device == SND_DEVICE_OUT_BT_SCO)
Shiv Maliyappanahalli34b585f2013-10-01 15:49:05 -0700444 strlcat(mixer_path, " bt-sco", MIXER_PATH_MAX_LENGTH);
445 else if(snd_device == SND_DEVICE_OUT_BT_SCO_WB)
446 strlcat(mixer_path, " bt-sco-wb", MIXER_PATH_MAX_LENGTH);
Eric Laurentb23d5282013-05-14 15:27:20 -0700447 else if (snd_device == SND_DEVICE_OUT_HDMI)
Shiv Maliyappanahalli34b585f2013-10-01 15:49:05 -0700448 strlcat(mixer_path, " hdmi", MIXER_PATH_MAX_LENGTH);
Eric Laurentb23d5282013-05-14 15:27:20 -0700449 else if (snd_device == SND_DEVICE_OUT_SPEAKER_AND_HDMI)
450 strcat(mixer_path, " speaker-and-hdmi");
Apoorv Raghuvanshi5792d4b2013-10-07 18:40:05 -0700451 else if (snd_device == SND_DEVICE_OUT_AFE_PROXY)
452 strlcat(mixer_path, " afe-proxy", MIXER_PATH_MAX_LENGTH);
453 else if (snd_device == SND_DEVICE_OUT_USB_HEADSET)
454 strlcat(mixer_path, " usb-headphones", MIXER_PATH_MAX_LENGTH);
455 else if (snd_device == SND_DEVICE_OUT_SPEAKER_AND_USB_HEADSET)
456 strlcat(mixer_path, " speaker-and-usb-headphones",
457 MIXER_PATH_MAX_LENGTH);
458 else if (snd_device == SND_DEVICE_IN_USB_HEADSET_MIC)
459 strlcat(mixer_path, " usb-headset-mic", MIXER_PATH_MAX_LENGTH);
Apoorv Raghuvanshi6e262842013-10-06 14:39:35 -0700460 else if (snd_device == SND_DEVICE_IN_CAPTURE_FM)
461 strlcat(mixer_path, " capture-fm", MIXER_PATH_MAX_LENGTH);
462 else if (snd_device == SND_DEVICE_OUT_TRANSMISSION_FM)
463 strlcat(mixer_path, " transmission-fm", MIXER_PATH_MAX_LENGTH);
Eric Laurentb23d5282013-05-14 15:27:20 -0700464}
465
466int platform_get_pcm_device_id(audio_usecase_t usecase, int device_type)
467{
468 int device_id;
469 if (device_type == PCM_PLAYBACK)
470 device_id = pcm_device_table[usecase][0];
471 else
472 device_id = pcm_device_table[usecase][1];
473 return device_id;
474}
475
476int platform_send_audio_calibration(void *platform, snd_device_t snd_device)
477{
478 struct platform_data *my_data = (struct platform_data *)platform;
479 int acdb_dev_id, acdb_dev_type;
480
481 acdb_dev_id = acdb_device_table[snd_device];
482 if (acdb_dev_id < 0) {
483 ALOGE("%s: Could not find acdb id for device(%d)",
484 __func__, snd_device);
485 return -EINVAL;
486 }
487 if (my_data->acdb_send_audio_cal) {
Eric Laurent994a6932013-07-17 11:51:42 -0700488 ("%s: sending audio calibration for snd_device(%d) acdb_id(%d)",
Eric Laurentb23d5282013-05-14 15:27:20 -0700489 __func__, snd_device, acdb_dev_id);
490 if (snd_device >= SND_DEVICE_OUT_BEGIN &&
491 snd_device < SND_DEVICE_OUT_END)
492 acdb_dev_type = ACDB_DEV_TYPE_OUT;
493 else
494 acdb_dev_type = ACDB_DEV_TYPE_IN;
495 my_data->acdb_send_audio_cal(acdb_dev_id, acdb_dev_type);
496 }
497 return 0;
498}
499
500int platform_switch_voice_call_device_pre(void *platform)
501{
502 return 0;
503}
504
505int platform_switch_voice_call_device_post(void *platform,
506 snd_device_t out_snd_device,
507 snd_device_t in_snd_device)
508{
509 struct platform_data *my_data = (struct platform_data *)platform;
510 int acdb_rx_id, acdb_tx_id;
511
512 if (my_data->acdb_send_voice_cal == NULL) {
513 ALOGE("%s: dlsym error for acdb_send_voice_call", __func__);
514 } else {
515 acdb_rx_id = acdb_device_table[out_snd_device];
516 acdb_tx_id = acdb_device_table[in_snd_device];
517
518 if (acdb_rx_id > 0 && acdb_tx_id > 0)
519 my_data->acdb_send_voice_cal(acdb_rx_id, acdb_tx_id);
520 else
521 ALOGE("%s: Incorrect ACDB IDs (rx: %d tx: %d)", __func__,
522 acdb_rx_id, acdb_tx_id);
523 }
524
525 return 0;
526}
527
528int platform_start_voice_call(void *platform)
529{
530 return 0;
531}
532
533int platform_stop_voice_call(void *platform)
534{
535 return 0;
536}
537
538int platform_set_voice_volume(void *platform, int volume)
539{
540 struct platform_data *my_data = (struct platform_data *)platform;
541 struct audio_device *adev = my_data->adev;
542 struct mixer_ctl *ctl;
sangwoo53b2cf02013-07-25 19:18:44 -0700543 const char *mixer_ctl_name = "Voice Rx Gain";
Shiv Maliyappanahalli34b585f2013-10-01 15:49:05 -0700544 int vol_index = 0;
545 uint32_t set_values[ ] = {0,
546 ALL_SESSION_VSID,
547 DEFAULT_VOLUME_RAMP_DURATION_MS};
Eric Laurentb23d5282013-05-14 15:27:20 -0700548
549 // Voice volume levels are mapped to adsp volume levels as follows.
550 // 100 -> 5, 80 -> 4, 60 -> 3, 40 -> 2, 20 -> 1 0 -> 0
551 // But this values don't changed in kernel. So, below change is need.
Shiv Maliyappanahalli34b585f2013-10-01 15:49:05 -0700552 vol_index = (int)percent_to_index(volume, MIN_VOL_INDEX, MAX_VOL_INDEX);
553 set_values[0] = vol_index;
Eric Laurentb23d5282013-05-14 15:27:20 -0700554
555 ctl = mixer_get_ctl_by_name(adev->mixer, mixer_ctl_name);
556 if (!ctl) {
557 ALOGE("%s: Could not get ctl for mixer cmd - %s",
558 __func__, mixer_ctl_name);
559 return -EINVAL;
560 }
Shiv Maliyappanahalli34b585f2013-10-01 15:49:05 -0700561 ALOGV("Setting voice volume index: %d", set_values[0]);
562 mixer_ctl_set_array(ctl, set_values, ARRAY_SIZE(set_values));
Eric Laurentb23d5282013-05-14 15:27:20 -0700563
564 return 0;
565}
566
567int platform_set_mic_mute(void *platform, bool state)
568{
569 struct platform_data *my_data = (struct platform_data *)platform;
570 struct audio_device *adev = my_data->adev;
571 struct mixer_ctl *ctl;
572 const char *mixer_ctl_name = "Voice Tx Mute";
Shiv Maliyappanahalli34b585f2013-10-01 15:49:05 -0700573 uint32_t set_values[ ] = {0,
574 ALL_SESSION_VSID,
575 DEFAULT_VOLUME_RAMP_DURATION_MS};
Eric Laurentb23d5282013-05-14 15:27:20 -0700576
577 if (adev->mode == AUDIO_MODE_IN_CALL) {
Shiv Maliyappanahalli34b585f2013-10-01 15:49:05 -0700578 set_values[0] = state;
Eric Laurentb23d5282013-05-14 15:27:20 -0700579 ctl = mixer_get_ctl_by_name(adev->mixer, mixer_ctl_name);
580 if (!ctl) {
581 ALOGE("%s: Could not get ctl for mixer cmd - %s",
582 __func__, mixer_ctl_name);
583 return -EINVAL;
584 }
Shiv Maliyappanahalli34b585f2013-10-01 15:49:05 -0700585 ALOGV("Setting voice mute state: %d", state);
586 mixer_ctl_set_array(ctl, set_values, ARRAY_SIZE(set_values));
Eric Laurentb23d5282013-05-14 15:27:20 -0700587 }
588
589 return 0;
590}
591
592snd_device_t platform_get_output_snd_device(void *platform, audio_devices_t devices)
593{
594 struct platform_data *my_data = (struct platform_data *)platform;
595 struct audio_device *adev = my_data->adev;
596 audio_mode_t mode = adev->mode;
597 snd_device_t snd_device = SND_DEVICE_NONE;
598
Apoorv Raghuvanshi9eaf94e2013-10-04 16:13:44 -0700599 audio_channel_mask_t channel_mask = (adev->active_input == NULL) ?
600 AUDIO_CHANNEL_IN_MONO : adev->active_input->channel_mask;
601 int channel_count = popcount(channel_mask);
602
Eric Laurentb23d5282013-05-14 15:27:20 -0700603 ALOGV("%s: enter: output devices(%#x)", __func__, devices);
604 if (devices == AUDIO_DEVICE_NONE ||
605 devices & AUDIO_DEVICE_BIT_IN) {
606 ALOGV("%s: Invalid output devices (%#x)", __func__, devices);
607 goto exit;
608 }
609
610 if (mode == AUDIO_MODE_IN_CALL) {
611 if (devices & AUDIO_DEVICE_OUT_WIRED_HEADPHONE ||
612 devices & AUDIO_DEVICE_OUT_WIRED_HEADSET) {
Shiv Maliyappanahalli34b585f2013-10-01 15:49:05 -0700613 if (adev->voice.tty_mode == TTY_MODE_FULL) {
Eric Laurentb23d5282013-05-14 15:27:20 -0700614 snd_device = SND_DEVICE_OUT_VOICE_TTY_FULL_HEADPHONES;
Shiv Maliyappanahalli34b585f2013-10-01 15:49:05 -0700615 } else if (adev->voice.tty_mode == TTY_MODE_VCO) {
Eric Laurentb23d5282013-05-14 15:27:20 -0700616 snd_device = SND_DEVICE_OUT_VOICE_TTY_VCO_HEADPHONES;
Shiv Maliyappanahalli34b585f2013-10-01 15:49:05 -0700617 } else if (adev->voice.tty_mode == TTY_MODE_HCO) {
Eric Laurentb23d5282013-05-14 15:27:20 -0700618 snd_device = SND_DEVICE_OUT_VOICE_TTY_HCO_HANDSET;
Shiv Maliyappanahalli34b585f2013-10-01 15:49:05 -0700619 } else if (audio_extn_get_anc_enabled()) {
Apoorv Raghuvanshi9eaf94e2013-10-04 16:13:44 -0700620 if (audio_extn_should_use_fb_anc())
621 snd_device = SND_DEVICE_OUT_VOICE_ANC_FB_HEADSET;
622 else
623 snd_device = SND_DEVICE_OUT_VOICE_ANC_HEADSET;
Shiv Maliyappanahalli34b585f2013-10-01 15:49:05 -0700624 } else {
Eric Laurentb23d5282013-05-14 15:27:20 -0700625 snd_device = SND_DEVICE_OUT_VOICE_HEADPHONES;
Shiv Maliyappanahalli34b585f2013-10-01 15:49:05 -0700626 }
Eric Laurentb23d5282013-05-14 15:27:20 -0700627 } else if (devices & AUDIO_DEVICE_OUT_ALL_SCO) {
Shiv Maliyappanahalli34b585f2013-10-01 15:49:05 -0700628 if (my_data->btsco_sample_rate == SAMPLE_RATE_16KHZ)
629 snd_device = SND_DEVICE_OUT_BT_SCO_WB;
630 else
631 snd_device = SND_DEVICE_OUT_BT_SCO;
Eric Laurentb23d5282013-05-14 15:27:20 -0700632 } else if (devices & AUDIO_DEVICE_OUT_SPEAKER) {
633 snd_device = SND_DEVICE_OUT_VOICE_SPEAKER;
Apoorv Raghuvanshi5792d4b2013-10-07 18:40:05 -0700634 } else if (devices & AUDIO_DEVICE_OUT_ANLG_DOCK_HEADSET ||
635 devices & AUDIO_DEVICE_OUT_DGTL_DOCK_HEADSET) {
636 snd_device = SND_DEVICE_OUT_USB_HEADSET;
Apoorv Raghuvanshi6e262842013-10-06 14:39:35 -0700637 } else if (devices & AUDIO_DEVICE_OUT_FM_TX) {
638 snd_device = SND_DEVICE_OUT_TRANSMISSION_FM;
Eric Laurentb23d5282013-05-14 15:27:20 -0700639 } else if (devices & AUDIO_DEVICE_OUT_EARPIECE) {
640 if (is_operator_tmus())
641 snd_device = SND_DEVICE_OUT_VOICE_HANDSET_TMUS;
Apoorv Raghuvanshi9eaf94e2013-10-04 16:13:44 -0700642 else if (audio_extn_should_use_handset_anc(channel_count))
643 snd_device = SND_DEVICE_OUT_ANC_HANDSET;
Eric Laurentb23d5282013-05-14 15:27:20 -0700644 else
Mingming Yin8e5a4f62013-10-07 15:23:41 -0700645 snd_device = SND_DEVICE_OUT_VOICE_HANDSET;
Eric Laurentb23d5282013-05-14 15:27:20 -0700646 }
647 if (snd_device != SND_DEVICE_NONE) {
648 goto exit;
649 }
650 }
651
652 if (popcount(devices) == 2) {
653 if (devices == (AUDIO_DEVICE_OUT_WIRED_HEADPHONE |
654 AUDIO_DEVICE_OUT_SPEAKER)) {
655 snd_device = SND_DEVICE_OUT_SPEAKER_AND_HEADPHONES;
656 } else if (devices == (AUDIO_DEVICE_OUT_WIRED_HEADSET |
657 AUDIO_DEVICE_OUT_SPEAKER)) {
Apoorv Raghuvanshi9eaf94e2013-10-04 16:13:44 -0700658 if (audio_extn_get_anc_enabled())
659 snd_device = SND_DEVICE_OUT_SPEAKER_AND_ANC_HEADSET;
660 else
661 snd_device = SND_DEVICE_OUT_SPEAKER_AND_HEADPHONES;
Eric Laurentb23d5282013-05-14 15:27:20 -0700662 } else if (devices == (AUDIO_DEVICE_OUT_AUX_DIGITAL |
663 AUDIO_DEVICE_OUT_SPEAKER)) {
664 snd_device = SND_DEVICE_OUT_SPEAKER_AND_HDMI;
Apoorv Raghuvanshi5792d4b2013-10-07 18:40:05 -0700665 } else if (devices == (AUDIO_DEVICE_OUT_ANLG_DOCK_HEADSET |
666 AUDIO_DEVICE_OUT_SPEAKER)) {
667 snd_device = SND_DEVICE_OUT_SPEAKER_AND_USB_HEADSET;
Eric Laurentb23d5282013-05-14 15:27:20 -0700668 } else {
669 ALOGE("%s: Invalid combo device(%#x)", __func__, devices);
670 goto exit;
671 }
672 if (snd_device != SND_DEVICE_NONE) {
673 goto exit;
674 }
675 }
676
677 if (popcount(devices) != 1) {
678 ALOGE("%s: Invalid output devices(%#x)", __func__, devices);
679 goto exit;
680 }
681
682 if (devices & AUDIO_DEVICE_OUT_WIRED_HEADPHONE ||
683 devices & AUDIO_DEVICE_OUT_WIRED_HEADSET) {
Apoorv Raghuvanshi9eaf94e2013-10-04 16:13:44 -0700684 if (devices & AUDIO_DEVICE_OUT_WIRED_HEADSET
685 && audio_extn_get_anc_enabled()) {
686 if (audio_extn_should_use_fb_anc())
687 snd_device = SND_DEVICE_OUT_ANC_FB_HEADSET;
688 else
689 snd_device = SND_DEVICE_OUT_ANC_HEADSET;
690 }
691 else
692 snd_device = SND_DEVICE_OUT_HEADPHONES;
Eric Laurentb23d5282013-05-14 15:27:20 -0700693 } else if (devices & AUDIO_DEVICE_OUT_SPEAKER) {
694 if (adev->speaker_lr_swap)
695 snd_device = SND_DEVICE_OUT_SPEAKER_REVERSE;
696 else
697 snd_device = SND_DEVICE_OUT_SPEAKER;
698 } else if (devices & AUDIO_DEVICE_OUT_ALL_SCO) {
Shiv Maliyappanahalli34b585f2013-10-01 15:49:05 -0700699 if (my_data->btsco_sample_rate == SAMPLE_RATE_16KHZ)
700 snd_device = SND_DEVICE_OUT_BT_SCO_WB;
701 else
702 snd_device = SND_DEVICE_OUT_BT_SCO;
Eric Laurentb23d5282013-05-14 15:27:20 -0700703 } else if (devices & AUDIO_DEVICE_OUT_AUX_DIGITAL) {
704 snd_device = SND_DEVICE_OUT_HDMI ;
Apoorv Raghuvanshi5792d4b2013-10-07 18:40:05 -0700705 } else if (devices & AUDIO_DEVICE_OUT_ANLG_DOCK_HEADSET ||
706 devices & AUDIO_DEVICE_OUT_DGTL_DOCK_HEADSET) {
707 snd_device = SND_DEVICE_OUT_USB_HEADSET;
Apoorv Raghuvanshi6e262842013-10-06 14:39:35 -0700708 } else if (devices & AUDIO_DEVICE_OUT_FM_TX) {
709 snd_device = SND_DEVICE_OUT_TRANSMISSION_FM;
Eric Laurentb23d5282013-05-14 15:27:20 -0700710 } else if (devices & AUDIO_DEVICE_OUT_EARPIECE) {
711 snd_device = SND_DEVICE_OUT_HANDSET;
Apoorv Raghuvanshi5792d4b2013-10-07 18:40:05 -0700712 } else if (devices & AUDIO_DEVICE_OUT_PROXY) {
713 ALOGD("%s: setting sink capability for Proxy", __func__);
714 audio_extn_set_afe_proxy_channel_mixer(adev);
715 snd_device = SND_DEVICE_OUT_AFE_PROXY;
Eric Laurentb23d5282013-05-14 15:27:20 -0700716 } else {
717 ALOGE("%s: Unknown device(s) %#x", __func__, devices);
718 }
719exit:
720 ALOGV("%s: exit: snd_device(%s)", __func__, device_table[snd_device]);
721 return snd_device;
722}
723
724snd_device_t platform_get_input_snd_device(void *platform, audio_devices_t out_device)
725{
726 struct platform_data *my_data = (struct platform_data *)platform;
727 struct audio_device *adev = my_data->adev;
728 audio_source_t source = (adev->active_input == NULL) ?
729 AUDIO_SOURCE_DEFAULT : adev->active_input->source;
730
731 audio_mode_t mode = adev->mode;
732 audio_devices_t in_device = ((adev->active_input == NULL) ?
733 AUDIO_DEVICE_NONE : adev->active_input->device)
734 & ~AUDIO_DEVICE_BIT_IN;
735 audio_channel_mask_t channel_mask = (adev->active_input == NULL) ?
736 AUDIO_CHANNEL_IN_MONO : adev->active_input->channel_mask;
737 snd_device_t snd_device = SND_DEVICE_NONE;
Apoorv Raghuvanshi9eaf94e2013-10-04 16:13:44 -0700738 int channel_count = popcount(channel_mask);
Eric Laurentb23d5282013-05-14 15:27:20 -0700739
740 ALOGV("%s: enter: out_device(%#x) in_device(%#x)",
741 __func__, out_device, in_device);
742 if (mode == AUDIO_MODE_IN_CALL) {
743 if (out_device == AUDIO_DEVICE_NONE) {
744 ALOGE("%s: No output device set for voice call", __func__);
745 goto exit;
746 }
Shiv Maliyappanahalli34b585f2013-10-01 15:49:05 -0700747 if (adev->voice.tty_mode != TTY_MODE_OFF) {
Eric Laurentb23d5282013-05-14 15:27:20 -0700748 if (out_device & AUDIO_DEVICE_OUT_WIRED_HEADPHONE ||
749 out_device & AUDIO_DEVICE_OUT_WIRED_HEADSET) {
Shiv Maliyappanahalli34b585f2013-10-01 15:49:05 -0700750 switch (adev->voice.tty_mode) {
Eric Laurentb23d5282013-05-14 15:27:20 -0700751 case TTY_MODE_FULL:
752 snd_device = SND_DEVICE_IN_VOICE_TTY_FULL_HEADSET_MIC;
753 break;
754 case TTY_MODE_VCO:
755 snd_device = SND_DEVICE_IN_VOICE_TTY_VCO_HANDSET_MIC;
756 break;
757 case TTY_MODE_HCO:
758 snd_device = SND_DEVICE_IN_VOICE_TTY_HCO_HEADSET_MIC;
759 break;
760 default:
Shiv Maliyappanahalli34b585f2013-10-01 15:49:05 -0700761 ALOGE("%s: Invalid TTY mode (%#x)",
762 __func__, adev->voice.tty_mode);
Eric Laurentb23d5282013-05-14 15:27:20 -0700763 }
764 goto exit;
765 }
766 }
767 if (out_device & AUDIO_DEVICE_OUT_EARPIECE ||
768 out_device & AUDIO_DEVICE_OUT_WIRED_HEADPHONE) {
Apoorv Raghuvanshi9eaf94e2013-10-04 16:13:44 -0700769 if (out_device & AUDIO_DEVICE_OUT_EARPIECE &&
770 audio_extn_should_use_handset_anc(channel_count)) {
771 snd_device = SND_DEVICE_IN_AANC_HANDSET_MIC;
772 } else if (my_data->fluence_type == FLUENCE_NONE ||
Mingming Yin8e5a4f62013-10-07 15:23:41 -0700773 my_data->fluence_in_voice_call == false) {
Eric Laurentb23d5282013-05-14 15:27:20 -0700774 snd_device = SND_DEVICE_IN_HANDSET_MIC;
775 } else {
Mingming Yin8e5a4f62013-10-07 15:23:41 -0700776 if (is_operator_tmus())
777 snd_device = SND_DEVICE_IN_VOICE_DMIC_TMUS;
Eric Laurentb23d5282013-05-14 15:27:20 -0700778 else
Mingming Yin8e5a4f62013-10-07 15:23:41 -0700779 snd_device = SND_DEVICE_IN_VOICE_DMIC;
780 adev->acdb_settings |= DMIC_FLAG;
Eric Laurentb23d5282013-05-14 15:27:20 -0700781 }
782 } else if (out_device & AUDIO_DEVICE_OUT_WIRED_HEADSET) {
783 snd_device = SND_DEVICE_IN_VOICE_HEADSET_MIC;
784 } else if (out_device & AUDIO_DEVICE_OUT_ALL_SCO) {
Shiv Maliyappanahalli34b585f2013-10-01 15:49:05 -0700785 if (my_data->btsco_sample_rate == SAMPLE_RATE_16KHZ)
786 snd_device = SND_DEVICE_IN_BT_SCO_MIC_WB;
787 else
788 snd_device = SND_DEVICE_IN_BT_SCO_MIC;
Eric Laurentb23d5282013-05-14 15:27:20 -0700789 } else if (out_device & AUDIO_DEVICE_OUT_SPEAKER) {
Mingming Yin8e5a4f62013-10-07 15:23:41 -0700790 if (my_data->fluence_type != FLUENCE_NONE &&
791 my_data->fluence_in_voice_call &&
792 my_data->fluence_in_spkr_mode) {
793 if(my_data->fluence_type == FLUENCE_DUAL_MIC) {
794 adev->acdb_settings |= DMIC_FLAG;
795 snd_device = SND_DEVICE_IN_VOICE_SPEAKER_DMIC;
796 } else {
797 adev->acdb_settings |= QMIC_FLAG;
798 snd_device = SND_DEVICE_IN_VOICE_SPEAKER_QMIC;
799 }
Eric Laurentb23d5282013-05-14 15:27:20 -0700800 } else {
801 snd_device = SND_DEVICE_IN_VOICE_SPEAKER_MIC;
802 }
803 }
804 } else if (source == AUDIO_SOURCE_CAMCORDER) {
805 if (in_device & AUDIO_DEVICE_IN_BUILTIN_MIC ||
806 in_device & AUDIO_DEVICE_IN_BACK_MIC) {
807 snd_device = SND_DEVICE_IN_CAMCORDER_MIC;
808 }
809 } else if (source == AUDIO_SOURCE_VOICE_RECOGNITION) {
810 if (in_device & AUDIO_DEVICE_IN_BUILTIN_MIC) {
Mingming Yin8e5a4f62013-10-07 15:23:41 -0700811 if (channel_mask == AUDIO_CHANNEL_IN_FRONT_BACK)
812 snd_device = SND_DEVICE_IN_VOICE_REC_DMIC;
813 else if (my_data->fluence_in_voice_rec)
814 snd_device = SND_DEVICE_IN_VOICE_REC_DMIC_FLUENCE;
Eric Laurentb23d5282013-05-14 15:27:20 -0700815
Mingming Yin8e5a4f62013-10-07 15:23:41 -0700816 if (snd_device == SND_DEVICE_NONE)
Eric Laurentb23d5282013-05-14 15:27:20 -0700817 snd_device = SND_DEVICE_IN_VOICE_REC_MIC;
Mingming Yin8e5a4f62013-10-07 15:23:41 -0700818 else
819 adev->acdb_settings |= DMIC_FLAG;
Eric Laurentb23d5282013-05-14 15:27:20 -0700820 }
821 } else if (source == AUDIO_SOURCE_VOICE_COMMUNICATION) {
822 if (out_device & AUDIO_DEVICE_OUT_SPEAKER)
823 in_device = AUDIO_DEVICE_IN_BACK_MIC;
824 if (adev->active_input) {
825 if (adev->active_input->enable_aec) {
826 if (in_device & AUDIO_DEVICE_IN_BACK_MIC) {
827 snd_device = SND_DEVICE_IN_SPEAKER_MIC_AEC;
828 } else if (in_device & AUDIO_DEVICE_IN_BUILTIN_MIC) {
829 snd_device = SND_DEVICE_IN_HANDSET_MIC_AEC;
830 } else if (in_device & AUDIO_DEVICE_IN_WIRED_HEADSET) {
831 snd_device = SND_DEVICE_IN_HEADSET_MIC_AEC;
832 }
833 set_echo_reference(adev->mixer, "SLIM_RX");
834 } else
835 set_echo_reference(adev->mixer, "NONE");
836 }
Apoorv Raghuvanshi6e262842013-10-06 14:39:35 -0700837 } else if (source == AUDIO_SOURCE_FM_RX) {
838 if (in_device & AUDIO_DEVICE_IN_FM_RX) {
839 snd_device = SND_DEVICE_IN_CAPTURE_FM;
840 }
Eric Laurentb23d5282013-05-14 15:27:20 -0700841 } else if (source == AUDIO_SOURCE_DEFAULT) {
842 goto exit;
843 }
844
845
846 if (snd_device != SND_DEVICE_NONE) {
847 goto exit;
848 }
849
850 if (in_device != AUDIO_DEVICE_NONE &&
851 !(in_device & AUDIO_DEVICE_IN_VOICE_CALL) &&
852 !(in_device & AUDIO_DEVICE_IN_COMMUNICATION)) {
853 if (in_device & AUDIO_DEVICE_IN_BUILTIN_MIC) {
Apoorv Raghuvanshi6178a3f2013-10-19 12:38:54 -0700854 if (audio_extn_ssr_get_enabled() && channel_count == 6)
855 snd_device = SND_DEVICE_IN_QUAD_MIC;
Apoorv Raghuvanshi6bd8dbf2013-10-19 18:37:52 -0700856 else if (channel_count > 1)
857 snd_device = SND_DEVICE_IN_HANDSET_STEREO_DMIC;
Apoorv Raghuvanshi6178a3f2013-10-19 12:38:54 -0700858 else
859 snd_device = SND_DEVICE_IN_HANDSET_MIC;
Eric Laurentb23d5282013-05-14 15:27:20 -0700860 } else if (in_device & AUDIO_DEVICE_IN_BACK_MIC) {
861 snd_device = SND_DEVICE_IN_SPEAKER_MIC;
862 } else if (in_device & AUDIO_DEVICE_IN_WIRED_HEADSET) {
863 snd_device = SND_DEVICE_IN_HEADSET_MIC;
864 } else if (in_device & AUDIO_DEVICE_IN_BLUETOOTH_SCO_HEADSET) {
Shiv Maliyappanahalli34b585f2013-10-01 15:49:05 -0700865 if (my_data->btsco_sample_rate == SAMPLE_RATE_16KHZ)
866 snd_device = SND_DEVICE_IN_BT_SCO_MIC_WB;
867 else
868 snd_device = SND_DEVICE_IN_BT_SCO_MIC;
Eric Laurentb23d5282013-05-14 15:27:20 -0700869 } else if (in_device & AUDIO_DEVICE_IN_AUX_DIGITAL) {
870 snd_device = SND_DEVICE_IN_HDMI_MIC;
Apoorv Raghuvanshi5792d4b2013-10-07 18:40:05 -0700871 } else if (in_device & AUDIO_DEVICE_IN_ANLG_DOCK_HEADSET ||
872 in_device & AUDIO_DEVICE_IN_DGTL_DOCK_HEADSET) {
873 snd_device = SND_DEVICE_IN_USB_HEADSET_MIC;
Apoorv Raghuvanshi6e262842013-10-06 14:39:35 -0700874 } else if (in_device & AUDIO_DEVICE_IN_FM_RX) {
875 snd_device = SND_DEVICE_IN_CAPTURE_FM;
Eric Laurentb23d5282013-05-14 15:27:20 -0700876 } else {
877 ALOGE("%s: Unknown input device(s) %#x", __func__, in_device);
878 ALOGW("%s: Using default handset-mic", __func__);
879 snd_device = SND_DEVICE_IN_HANDSET_MIC;
880 }
881 } else {
882 if (out_device & AUDIO_DEVICE_OUT_EARPIECE) {
883 snd_device = SND_DEVICE_IN_HANDSET_MIC;
884 } else if (out_device & AUDIO_DEVICE_OUT_WIRED_HEADSET) {
885 snd_device = SND_DEVICE_IN_HEADSET_MIC;
886 } else if (out_device & AUDIO_DEVICE_OUT_SPEAKER) {
Apoorv Raghuvanshi6bd8dbf2013-10-19 18:37:52 -0700887 if (channel_count > 1)
888 snd_device = SND_DEVICE_IN_SPEAKER_STEREO_DMIC;
889 else
890 snd_device = SND_DEVICE_IN_SPEAKER_MIC;
Eric Laurentb23d5282013-05-14 15:27:20 -0700891 } else if (out_device & AUDIO_DEVICE_OUT_WIRED_HEADPHONE) {
892 snd_device = SND_DEVICE_IN_HANDSET_MIC;
893 } else if (out_device & AUDIO_DEVICE_OUT_BLUETOOTH_SCO_HEADSET) {
Shiv Maliyappanahalli34b585f2013-10-01 15:49:05 -0700894 if (my_data->btsco_sample_rate == SAMPLE_RATE_16KHZ)
895 snd_device = SND_DEVICE_IN_BT_SCO_MIC_WB;
896 else
897 snd_device = SND_DEVICE_IN_BT_SCO_MIC;
Eric Laurentb23d5282013-05-14 15:27:20 -0700898 } else if (out_device & AUDIO_DEVICE_OUT_AUX_DIGITAL) {
899 snd_device = SND_DEVICE_IN_HDMI_MIC;
Apoorv Raghuvanshi5792d4b2013-10-07 18:40:05 -0700900 } else if (out_device & AUDIO_DEVICE_OUT_ANLG_DOCK_HEADSET ||
901 out_device & AUDIO_DEVICE_OUT_DGTL_DOCK_HEADSET) {
902 snd_device = SND_DEVICE_IN_USB_HEADSET_MIC;
Eric Laurentb23d5282013-05-14 15:27:20 -0700903 } else {
904 ALOGE("%s: Unknown output device(s) %#x", __func__, out_device);
905 ALOGW("%s: Using default handset-mic", __func__);
906 snd_device = SND_DEVICE_IN_HANDSET_MIC;
907 }
908 }
909exit:
910 ALOGV("%s: exit: in_snd_device(%s)", __func__, device_table[snd_device]);
911 return snd_device;
912}
913
914int platform_set_hdmi_channels(void *platform, int channel_count)
915{
916 struct platform_data *my_data = (struct platform_data *)platform;
917 struct audio_device *adev = my_data->adev;
918 struct mixer_ctl *ctl;
919 const char *channel_cnt_str = NULL;
920 const char *mixer_ctl_name = "HDMI_RX Channels";
921 switch (channel_count) {
922 case 8:
923 channel_cnt_str = "Eight"; break;
924 case 7:
925 channel_cnt_str = "Seven"; break;
926 case 6:
927 channel_cnt_str = "Six"; break;
928 case 5:
929 channel_cnt_str = "Five"; break;
930 case 4:
931 channel_cnt_str = "Four"; break;
932 case 3:
933 channel_cnt_str = "Three"; break;
934 default:
935 channel_cnt_str = "Two"; break;
936 }
937 ctl = mixer_get_ctl_by_name(adev->mixer, mixer_ctl_name);
938 if (!ctl) {
939 ALOGE("%s: Could not get ctl for mixer cmd - %s",
940 __func__, mixer_ctl_name);
941 return -EINVAL;
942 }
943 ALOGV("HDMI channel count: %s", channel_cnt_str);
944 mixer_ctl_set_enum_by_string(ctl, channel_cnt_str);
945 return 0;
946}
947
Haynes Mathew George47cd4cb2013-07-19 11:58:50 -0700948int platform_edid_get_max_channels(void *platform)
Eric Laurentb23d5282013-05-14 15:27:20 -0700949{
Haynes Mathew George47cd4cb2013-07-19 11:58:50 -0700950 struct platform_data *my_data = (struct platform_data *)platform;
951 struct audio_device *adev = my_data->adev;
Eric Laurentb23d5282013-05-14 15:27:20 -0700952 char block[MAX_SAD_BLOCKS * SAD_BLOCK_SIZE];
953 char *sad = block;
954 int num_audio_blocks;
955 int channel_count;
956 int max_channels = 0;
Haynes Mathew George47cd4cb2013-07-19 11:58:50 -0700957 int i, ret, count;
Eric Laurentb23d5282013-05-14 15:27:20 -0700958
Haynes Mathew George47cd4cb2013-07-19 11:58:50 -0700959 struct mixer_ctl *ctl;
960
961 ctl = mixer_get_ctl_by_name(adev->mixer, AUDIO_DATA_BLOCK_MIXER_CTL);
962 if (!ctl) {
963 ALOGE("%s: Could not get ctl for mixer cmd - %s",
964 __func__, AUDIO_DATA_BLOCK_MIXER_CTL);
Eric Laurentb23d5282013-05-14 15:27:20 -0700965 return 0;
966 }
967
Haynes Mathew George47cd4cb2013-07-19 11:58:50 -0700968 mixer_ctl_update(ctl);
969
970 count = mixer_ctl_get_num_values(ctl);
Eric Laurentb23d5282013-05-14 15:27:20 -0700971
972 /* Read SAD blocks, clamping the maximum size for safety */
Haynes Mathew George47cd4cb2013-07-19 11:58:50 -0700973 if (count > (int)sizeof(block))
974 count = (int)sizeof(block);
Eric Laurentb23d5282013-05-14 15:27:20 -0700975
Haynes Mathew George47cd4cb2013-07-19 11:58:50 -0700976 ret = mixer_ctl_get_array(ctl, block, count);
977 if (ret != 0) {
978 ALOGE("%s: mixer_ctl_get_array() failed to get EDID info", __func__);
979 return 0;
980 }
Eric Laurentb23d5282013-05-14 15:27:20 -0700981
982 /* Calculate the number of SAD blocks */
Haynes Mathew George47cd4cb2013-07-19 11:58:50 -0700983 num_audio_blocks = count / SAD_BLOCK_SIZE;
Eric Laurentb23d5282013-05-14 15:27:20 -0700984
985 for (i = 0; i < num_audio_blocks; i++) {
986 /* Only consider LPCM blocks */
Haynes Mathew George47cd4cb2013-07-19 11:58:50 -0700987 if ((sad[0] >> 3) != EDID_FORMAT_LPCM) {
988 sad += 3;
Eric Laurentb23d5282013-05-14 15:27:20 -0700989 continue;
Haynes Mathew George47cd4cb2013-07-19 11:58:50 -0700990 }
Eric Laurentb23d5282013-05-14 15:27:20 -0700991
992 channel_count = (sad[0] & 0x7) + 1;
993 if (channel_count > max_channels)
994 max_channels = channel_count;
995
996 /* Advance to next block */
997 sad += 3;
998 }
999
1000 return max_channels;
1001}
Shiv Maliyappanahalli34b585f2013-10-01 15:49:05 -07001002
1003static int platform_set_slowtalk(struct platform_data *my_data, bool state)
1004{
1005 int ret = 0;
1006 struct audio_device *adev = my_data->adev;
1007 struct mixer_ctl *ctl;
1008 const char *mixer_ctl_name = "Slowtalk Enable";
1009 uint32_t set_values[ ] = {0,
1010 ALL_SESSION_VSID};
1011
1012 set_values[0] = state;
1013 ctl = mixer_get_ctl_by_name(adev->mixer, mixer_ctl_name);
1014 if (!ctl) {
1015 ALOGE("%s: Could not get ctl for mixer cmd - %s",
1016 __func__, mixer_ctl_name);
1017 ret = -EINVAL;
1018 } else {
1019 ALOGV("Setting slowtalk state: %d", state);
1020 ret = mixer_ctl_set_array(ctl, set_values, ARRAY_SIZE(set_values));
1021 my_data->slowtalk = state;
1022 }
1023
1024 return ret;
1025}
1026
1027int platform_set_parameters(void *platform, struct str_parms *parms)
1028{
1029 struct platform_data *my_data = (struct platform_data *)platform;
1030 char *str;
1031 char value[32];
1032 int val;
1033 int ret = 0;
1034
1035 ALOGV("%s: enter: %s", __func__, str_parms_to_str(parms));
1036
1037 ret = str_parms_get_int(parms, AUDIO_PARAMETER_KEY_BTSCO, &val);
1038 if (ret >= 0) {
1039 str_parms_del(parms, AUDIO_PARAMETER_KEY_BTSCO);
1040 pthread_mutex_lock(&my_data->adev->lock);
1041 my_data->btsco_sample_rate = val;
1042 pthread_mutex_unlock(&my_data->adev->lock);
1043 }
1044
1045 ret = str_parms_get_int(parms, AUDIO_PARAMETER_KEY_SLOWTALK, &val);
1046 if (ret >= 0) {
1047 str_parms_del(parms, AUDIO_PARAMETER_KEY_SLOWTALK);
1048 pthread_mutex_lock(&my_data->adev->lock);
1049 ret = platform_set_slowtalk(my_data, val);
1050 if (ret)
1051 ALOGE("%s: Failed to set slow talk err: %d", __func__, ret);
1052 pthread_mutex_unlock(&my_data->adev->lock);
1053 }
1054
1055 ALOGV("%s: exit with code(%d)", __func__, ret);
1056 return ret;
1057}
1058
Shiv Maliyappanahallida107642013-10-17 11:16:13 -07001059int platform_set_incall_recoding_session_id(void *platform,
1060 uint32_t session_id)
1061{
1062 int ret = 0;
1063 struct platform_data *my_data = (struct platform_data *)platform;
1064 struct audio_device *adev = my_data->adev;
1065 struct mixer_ctl *ctl;
1066 const char *mixer_ctl_name = "Voc VSID";
1067 int num_ctl_values;
1068 int i;
1069
1070 ctl = mixer_get_ctl_by_name(adev->mixer, mixer_ctl_name);
1071 if (!ctl) {
1072 ALOGE("%s: Could not get ctl for mixer cmd - %s",
1073 __func__, mixer_ctl_name);
1074 ret = -EINVAL;
1075 } else {
1076 num_ctl_values = mixer_ctl_get_num_values(ctl);
1077 for (i = 0; i < num_ctl_values; i++) {
1078 if (mixer_ctl_set_value(ctl, i, session_id)) {
1079 ALOGV("Error: invalid session_id: %x", session_id);
1080 ret = -EINVAL;
1081 break;
1082 }
1083 }
1084 }
1085
1086 return ret;
1087}
1088
Shiv Maliyappanahalli34b585f2013-10-01 15:49:05 -07001089void platform_get_parameters(void *platform,
1090 struct str_parms *query,
1091 struct str_parms *reply)
1092{
1093 struct platform_data *my_data = (struct platform_data *)platform;
1094 char *str = NULL;
1095 char value[256] = {0};
1096 int ret;
1097 int fluence_type;
1098
1099 ret = str_parms_get_str(query, AUDIO_PARAMETER_KEY_FLUENCE_TYPE,
1100 value, sizeof(value));
1101 if (ret >= 0) {
1102 pthread_mutex_lock(&my_data->adev->lock);
1103 if (my_data->fluence_type == FLUENCE_QUAD_MIC) {
1104 strlcpy(value, "fluencepro", sizeof(value));
1105 } else if (my_data->fluence_type == FLUENCE_DUAL_MIC) {
1106 strlcpy(value, "fluence", sizeof(value));
1107 } else {
1108 strlcpy(value, "none", sizeof(value));
1109 }
1110 pthread_mutex_unlock(&my_data->adev->lock);
1111
1112 str_parms_add_str(reply, AUDIO_PARAMETER_KEY_FLUENCE_TYPE, value);
1113 }
1114
1115 ALOGV("%s: exit: returns - %s", __func__, str_parms_to_str(reply));
1116}
1117
Haynes Mathew George7ff216f2013-09-11 19:51:41 -07001118/* Delay in Us */
1119int64_t platform_render_latency(audio_usecase_t usecase)
1120{
1121 switch (usecase) {
1122 case USECASE_AUDIO_PLAYBACK_DEEP_BUFFER:
1123 return DEEP_BUFFER_PLATFORM_DELAY;
1124 case USECASE_AUDIO_PLAYBACK_LOW_LATENCY:
1125 return LOW_LATENCY_PLATFORM_DELAY;
1126 default:
1127 return 0;
1128 }
1129}