blob: 8793ae3641ca452fc3fadff8948172a8038e5321 [file] [log] [blame]
Eric Laurentb23d5282013-05-14 15:27:20 -07001/*
Vineeta Srivastava4b89e372014-06-19 14:21:42 -07002 * Copyright (C) 2013-2014 The Android Open Source Project
Eric Laurentb23d5282013-05-14 15:27:20 -07003 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17#define LOG_TAG "msm8960_platform"
18/*#define LOG_NDEBUG 0*/
19#define LOG_NDDEBUG 0
20
21#include <stdlib.h>
22#include <dlfcn.h>
Haynes Mathew Georgee6e2d442018-02-22 18:51:56 -080023#include <log/log.h>
Eric Laurentb23d5282013-05-14 15:27:20 -070024#include <cutils/properties.h>
25#include <audio_hw.h>
26#include <platform_api.h>
27#include "platform.h"
David Lind6229bd2017-07-06 15:28:55 -070028#include "audio_extn.h"
Eric Laurentb23d5282013-05-14 15:27:20 -070029
30#define LIB_ACDB_LOADER "libacdbloader.so"
31#define LIB_CSD_CLIENT "libcsd-client.so"
32
33#define DUALMIC_CONFIG_NONE 0 /* Target does not contain 2 mics */
34#define DUALMIC_CONFIG_ENDFIRE 1
35#define DUALMIC_CONFIG_BROADSIDE 2
36
37/*
38 * This is the sysfs path for the HDMI audio data block
39 */
40#define AUDIO_DATA_BLOCK_PATH "/sys/class/graphics/fb1/audio_data_block"
Artem Borisov68909612017-12-02 20:19:25 +030041#define MIXER_XML_PATH "mixer_paths.xml"
Eric Laurentb23d5282013-05-14 15:27:20 -070042
43/*
44 * This file will have a maximum of 38 bytes:
45 *
46 * 4 bytes: number of audio blocks
47 * 4 bytes: total length of Short Audio Descriptor (SAD) blocks
48 * Maximum 10 * 3 bytes: SAD blocks
49 */
50#define MAX_SAD_BLOCKS 10
51#define SAD_BLOCK_SIZE 3
52
53/* EDID format ID for LPCM audio */
54#define EDID_FORMAT_LPCM 1
55
56struct audio_block_header
57{
58 int reserved;
59 int length;
60};
61
62
63typedef void (*acdb_deallocate_t)();
64typedef int (*acdb_init_t)();
65typedef void (*acdb_send_audio_cal_t)(int, int);
66typedef void (*acdb_send_voice_cal_t)(int, int);
67
68typedef int (*csd_client_init_t)();
69typedef int (*csd_client_deinit_t)();
70typedef int (*csd_disable_device_t)();
71typedef int (*csd_enable_device_t)(int, int, uint32_t);
72typedef int (*csd_volume_t)(int);
73typedef int (*csd_mic_mute_t)(int);
74typedef int (*csd_start_voice_t)();
75typedef int (*csd_stop_voice_t)();
76
77
78/* Audio calibration related functions */
79struct platform_data {
80 struct audio_device *adev;
81 bool fluence_in_spkr_mode;
82 bool fluence_in_voice_call;
83 bool fluence_in_voice_rec;
84 int dualmic_config;
Ravi Kumar Alamanda1f60cf82015-04-23 19:45:17 -070085 bool speaker_lr_swap;
Eric Laurentb23d5282013-05-14 15:27:20 -070086
87 void *acdb_handle;
88 acdb_init_t acdb_init;
89 acdb_deallocate_t acdb_deallocate;
90 acdb_send_audio_cal_t acdb_send_audio_cal;
91 acdb_send_voice_cal_t acdb_send_voice_cal;
92
93 /* CSD Client related functions for voice call */
94 void *csd_client;
95 csd_client_init_t csd_client_init;
96 csd_client_deinit_t csd_client_deinit;
97 csd_disable_device_t csd_disable_device;
98 csd_enable_device_t csd_enable_device;
99 csd_volume_t csd_volume;
100 csd_mic_mute_t csd_mic_mute;
101 csd_start_voice_t csd_start_voice;
102 csd_stop_voice_t csd_stop_voice;
103};
104
105static const int pcm_device_table[AUDIO_USECASE_MAX][2] = {
106 [USECASE_AUDIO_PLAYBACK_DEEP_BUFFER] = {0, 0},
107 [USECASE_AUDIO_PLAYBACK_LOW_LATENCY] = {14, 14},
David Lind6229bd2017-07-06 15:28:55 -0700108 [USECASE_AUDIO_PLAYBACK_HIFI] = {1, 1},
Eric Laurentb23d5282013-05-14 15:27:20 -0700109 [USECASE_AUDIO_RECORD] = {0, 0},
110 [USECASE_AUDIO_RECORD_LOW_LATENCY] = {14, 14},
111 [USECASE_VOICE_CALL] = {12, 12},
112};
113
114/* Array to store sound devices */
115static const char * const device_table[SND_DEVICE_MAX] = {
116 [SND_DEVICE_NONE] = "none",
117 /* Playback sound devices */
118 [SND_DEVICE_OUT_HANDSET] = "handset",
119 [SND_DEVICE_OUT_SPEAKER] = "speaker",
120 [SND_DEVICE_OUT_SPEAKER_REVERSE] = "speaker-reverse",
David Linfb3c9952018-01-19 14:57:43 -0800121 [SND_DEVICE_OUT_SPEAKER_SAFE] = "speaker-safe",
Eric Laurentb23d5282013-05-14 15:27:20 -0700122 [SND_DEVICE_OUT_HEADPHONES] = "headphones",
123 [SND_DEVICE_OUT_SPEAKER_AND_HEADPHONES] = "speaker-and-headphones",
124 [SND_DEVICE_OUT_VOICE_SPEAKER] = "voice-speaker",
125 [SND_DEVICE_OUT_VOICE_HEADPHONES] = "voice-headphones",
yixuanjiang9536e672018-09-06 18:43:36 +0800126 [SND_DEVICE_OUT_VOICE_HEADSET] = "voice-headphones",
Eric Laurentb23d5282013-05-14 15:27:20 -0700127 [SND_DEVICE_OUT_HDMI] = "hdmi",
128 [SND_DEVICE_OUT_SPEAKER_AND_HDMI] = "speaker-and-hdmi",
129 [SND_DEVICE_OUT_BT_SCO] = "bt-sco-headset",
Ravi Kumar Alamanda9f306542014-04-02 15:11:49 -0700130 [SND_DEVICE_OUT_BT_SCO_WB] = "bt-sco-headset-wb",
Eric Laurentb23d5282013-05-14 15:27:20 -0700131 [SND_DEVICE_OUT_VOICE_HANDSET_TMUS] = "voice-handset-tmus",
Eric Laurent788f41f2015-08-24 12:21:50 -0700132 [SND_DEVICE_OUT_VOICE_HANDSET] = "voice-handset-tmus",
133 [SND_DEVICE_OUT_VOICE_HAC_HANDSET] = "voice-handset-tmus",
Eric Laurentb23d5282013-05-14 15:27:20 -0700134 [SND_DEVICE_OUT_VOICE_TTY_FULL_HEADPHONES] = "voice-tty-full-headphones",
135 [SND_DEVICE_OUT_VOICE_TTY_VCO_HEADPHONES] = "voice-tty-vco-headphones",
136 [SND_DEVICE_OUT_VOICE_TTY_HCO_HANDSET] = "voice-tty-hco-handset",
voron00e1cdfc72019-03-12 06:06:18 +0300137 [SND_DEVICE_OUT_VOICE_MUSIC_TX] = "voice-music-tx",
Eric Laurentb1b07992017-06-29 09:20:02 -0700138 [SND_DEVICE_OUT_USB_HEADSET] = "usb-headset",
139 [SND_DEVICE_OUT_USB_HEADPHONES] = "usb-headphones",
140 [SND_DEVICE_OUT_VOICE_USB_HEADSET] = "usb-headset",
141 [SND_DEVICE_OUT_VOICE_USB_HEADPHONES] = "usb-headphones",
142
Eric Laurentb23d5282013-05-14 15:27:20 -0700143
144 /* Capture sound devices */
145 [SND_DEVICE_IN_HANDSET_MIC] = "handset-mic",
146 [SND_DEVICE_IN_SPEAKER_MIC] = "speaker-mic",
147 [SND_DEVICE_IN_HEADSET_MIC] = "headset-mic",
148 [SND_DEVICE_IN_HANDSET_MIC_AEC] = "handset-mic",
149 [SND_DEVICE_IN_SPEAKER_MIC_AEC] = "voice-speaker-mic",
150 [SND_DEVICE_IN_HEADSET_MIC_AEC] = "headset-mic",
151 [SND_DEVICE_IN_VOICE_SPEAKER_MIC] = "voice-speaker-mic",
152 [SND_DEVICE_IN_VOICE_HEADSET_MIC] = "voice-headset-mic",
153 [SND_DEVICE_IN_HDMI_MIC] = "hdmi-mic",
154 [SND_DEVICE_IN_BT_SCO_MIC] = "bt-sco-mic",
Ravi Kumar Alamanda9f306542014-04-02 15:11:49 -0700155 [SND_DEVICE_IN_BT_SCO_MIC_WB] = "bt-sco-mic-wb",
Eric Laurentb23d5282013-05-14 15:27:20 -0700156 [SND_DEVICE_IN_CAMCORDER_MIC] = "camcorder-mic",
157 [SND_DEVICE_IN_VOICE_DMIC_EF] = "voice-dmic-ef",
158 [SND_DEVICE_IN_VOICE_DMIC_BS] = "voice-dmic-bs",
159 [SND_DEVICE_IN_VOICE_DMIC_EF_TMUS] = "voice-dmic-ef-tmus",
160 [SND_DEVICE_IN_VOICE_SPEAKER_DMIC_EF] = "voice-speaker-dmic-ef",
161 [SND_DEVICE_IN_VOICE_SPEAKER_DMIC_BS] = "voice-speaker-dmic-bs",
162 [SND_DEVICE_IN_VOICE_TTY_FULL_HEADSET_MIC] = "voice-tty-full-headset-mic",
163 [SND_DEVICE_IN_VOICE_TTY_VCO_HANDSET_MIC] = "voice-tty-vco-handset-mic",
164 [SND_DEVICE_IN_VOICE_TTY_HCO_HEADSET_MIC] = "voice-tty-hco-headset-mic",
165 [SND_DEVICE_IN_VOICE_REC_MIC] = "voice-rec-mic",
166 [SND_DEVICE_IN_VOICE_REC_DMIC_EF] = "voice-rec-dmic-ef",
167 [SND_DEVICE_IN_VOICE_REC_DMIC_BS] = "voice-rec-dmic-bs",
168 [SND_DEVICE_IN_VOICE_REC_DMIC_EF_FLUENCE] = "voice-rec-dmic-ef-fluence",
169 [SND_DEVICE_IN_VOICE_REC_DMIC_BS_FLUENCE] = "voice-rec-dmic-bs-fluence",
170};
171
172/* ACDB IDs (audio DSP path configuration IDs) for each sound device */
173static const int acdb_device_table[SND_DEVICE_MAX] = {
174 [SND_DEVICE_NONE] = -1,
175 [SND_DEVICE_OUT_HANDSET] = 7,
176 [SND_DEVICE_OUT_SPEAKER] = 14,
177 [SND_DEVICE_OUT_SPEAKER_REVERSE] = 14,
David Linfb3c9952018-01-19 14:57:43 -0800178 [SND_DEVICE_OUT_SPEAKER_SAFE] = 14,
Eric Laurentb23d5282013-05-14 15:27:20 -0700179 [SND_DEVICE_OUT_HEADPHONES] = 10,
180 [SND_DEVICE_OUT_SPEAKER_AND_HEADPHONES] = 10,
181 [SND_DEVICE_OUT_VOICE_SPEAKER] = 14,
182 [SND_DEVICE_OUT_VOICE_HEADPHONES] = 10,
yixuanjiang9536e672018-09-06 18:43:36 +0800183 [SND_DEVICE_OUT_VOICE_HEADSET] = 10,
Eric Laurentb23d5282013-05-14 15:27:20 -0700184 [SND_DEVICE_OUT_HDMI] = 18,
185 [SND_DEVICE_OUT_SPEAKER_AND_HDMI] = 14,
186 [SND_DEVICE_OUT_BT_SCO] = 22,
Ravi Kumar Alamanda9f306542014-04-02 15:11:49 -0700187 [SND_DEVICE_OUT_BT_SCO_WB] = 39,
Eric Laurentb23d5282013-05-14 15:27:20 -0700188 [SND_DEVICE_OUT_VOICE_HANDSET_TMUS] = 81,
Eric Laurent788f41f2015-08-24 12:21:50 -0700189 [SND_DEVICE_OUT_VOICE_HANDSET] = 81,
190 [SND_DEVICE_OUT_VOICE_HAC_HANDSET] = 81,
Eric Laurentb23d5282013-05-14 15:27:20 -0700191 [SND_DEVICE_OUT_VOICE_TTY_FULL_HEADPHONES] = 17,
192 [SND_DEVICE_OUT_VOICE_TTY_VCO_HEADPHONES] = 17,
193 [SND_DEVICE_OUT_VOICE_TTY_HCO_HANDSET] = 37,
voron00e1cdfc72019-03-12 06:06:18 +0300194 [SND_DEVICE_OUT_VOICE_MUSIC_TX] = 3,
Eric Laurentb1b07992017-06-29 09:20:02 -0700195 [SND_DEVICE_OUT_USB_HEADSET] = 45,
196 [SND_DEVICE_OUT_USB_HEADPHONES] = 45,
197 [SND_DEVICE_OUT_VOICE_USB_HEADSET] = 45,
198 [SND_DEVICE_OUT_VOICE_USB_HEADPHONES] = 45,
Eric Laurentb23d5282013-05-14 15:27:20 -0700199
200 [SND_DEVICE_IN_HANDSET_MIC] = 4,
201 [SND_DEVICE_IN_SPEAKER_MIC] = 4,
202 [SND_DEVICE_IN_HEADSET_MIC] = 8,
203 [SND_DEVICE_IN_HANDSET_MIC_AEC] = 40,
204 [SND_DEVICE_IN_SPEAKER_MIC_AEC] = 42,
205 [SND_DEVICE_IN_HEADSET_MIC_AEC] = 47,
206 [SND_DEVICE_IN_VOICE_SPEAKER_MIC] = 11,
207 [SND_DEVICE_IN_VOICE_HEADSET_MIC] = 8,
208 [SND_DEVICE_IN_HDMI_MIC] = 4,
209 [SND_DEVICE_IN_BT_SCO_MIC] = 21,
Ravi Kumar Alamanda9f306542014-04-02 15:11:49 -0700210 [SND_DEVICE_IN_BT_SCO_MIC_WB] = 38,
Eric Laurentb23d5282013-05-14 15:27:20 -0700211 [SND_DEVICE_IN_CAMCORDER_MIC] = 61,
212 [SND_DEVICE_IN_VOICE_DMIC_EF] = 6,
213 [SND_DEVICE_IN_VOICE_DMIC_BS] = 5,
214 [SND_DEVICE_IN_VOICE_DMIC_EF_TMUS] = 91,
215 [SND_DEVICE_IN_VOICE_SPEAKER_DMIC_EF] = 13,
216 [SND_DEVICE_IN_VOICE_SPEAKER_DMIC_BS] = 12,
217 [SND_DEVICE_IN_VOICE_TTY_FULL_HEADSET_MIC] = 16,
218 [SND_DEVICE_IN_VOICE_TTY_VCO_HANDSET_MIC] = 36,
219 [SND_DEVICE_IN_VOICE_TTY_HCO_HEADSET_MIC] = 16,
220 [SND_DEVICE_IN_VOICE_REC_MIC] = 62,
221 /* TODO: Update with proper acdb ids */
222 [SND_DEVICE_IN_VOICE_REC_DMIC_EF] = 62,
223 [SND_DEVICE_IN_VOICE_REC_DMIC_BS] = 62,
224 [SND_DEVICE_IN_VOICE_REC_DMIC_EF_FLUENCE] = 6,
225 [SND_DEVICE_IN_VOICE_REC_DMIC_BS_FLUENCE] = 5,
226};
227
Haynes Mathew George7ff216f2013-09-11 19:51:41 -0700228#define DEEP_BUFFER_PLATFORM_DELAY (29*1000LL)
229#define LOW_LATENCY_PLATFORM_DELAY (13*1000LL)
230
Eric Laurentb23d5282013-05-14 15:27:20 -0700231static pthread_once_t check_op_once_ctl = PTHREAD_ONCE_INIT;
232static bool is_tmus = false;
233
234static void check_operator()
235{
236 char value[PROPERTY_VALUE_MAX];
237 int mccmnc;
238 property_get("gsm.sim.operator.numeric",value,"0");
239 mccmnc = atoi(value);
240 ALOGD("%s: tmus mccmnc %d", __func__, mccmnc);
241 switch(mccmnc) {
242 /* TMUS MCC(310), MNC(490, 260, 026) */
243 case 310490:
244 case 310260:
245 case 310026:
246 is_tmus = true;
247 break;
248 }
249}
250
251bool is_operator_tmus()
252{
253 pthread_once(&check_op_once_ctl, check_operator);
254 return is_tmus;
255}
256
257static int set_echo_reference(struct mixer *mixer, const char* ec_ref)
258{
259 struct mixer_ctl *ctl;
260 const char *mixer_ctl_name = "EC_REF_RX";
261
262 ctl = mixer_get_ctl_by_name(mixer, mixer_ctl_name);
263 if (!ctl) {
264 ALOGE("%s: Could not get ctl for mixer cmd - %s",
265 __func__, mixer_ctl_name);
266 return -EINVAL;
267 }
268 ALOGV("Setting EC Reference: %s", ec_ref);
269 mixer_ctl_set_enum_by_string(ctl, ec_ref);
270 return 0;
271}
272
Artem Borisov68909612017-12-02 20:19:25 +0300273// Treblized config files will be located in /odm/etc or /vendor/etc.
274static const char *kConfigLocationList[] =
275 {"/odm/etc", "/vendor/etc", "/system/etc"};
276static const int kConfigLocationListSize =
277 (sizeof(kConfigLocationList) / sizeof(kConfigLocationList[0]));
278
279bool resolveConfigFile(char file_name[MIXER_PATH_MAX_LENGTH]) {
280 char full_config_path[MIXER_PATH_MAX_LENGTH];
281 for (int i = 0; i < kConfigLocationListSize; i++) {
282 snprintf(full_config_path,
283 MIXER_PATH_MAX_LENGTH,
284 "%s/%s",
285 kConfigLocationList[i],
286 file_name);
287 if (F_OK == access(full_config_path, 0)) {
288 strcpy(file_name, full_config_path);
289 return true;
290 }
291 }
292 return false;
293}
294
Eric Laurentb23d5282013-05-14 15:27:20 -0700295void *platform_init(struct audio_device *adev)
296{
297 char platform[PROPERTY_VALUE_MAX];
298 char baseband[PROPERTY_VALUE_MAX];
299 char value[PROPERTY_VALUE_MAX];
300 struct platform_data *my_data;
Artem Borisov68909612017-12-02 20:19:25 +0300301 char mixer_xml_file[MIXER_PATH_MAX_LENGTH] = MIXER_XML_PATH;
Eric Laurentb23d5282013-05-14 15:27:20 -0700302
sangwoo1b9f4b32013-06-21 18:22:55 -0700303 adev->mixer = mixer_open(MIXER_CARD);
304
305 if (!adev->mixer) {
306 ALOGE("Unable to open the mixer, aborting.");
307 return NULL;
308 }
309
Artem Borisov68909612017-12-02 20:19:25 +0300310 resolveConfigFile(mixer_xml_file);
311 adev->audio_route = audio_route_init(MIXER_CARD, mixer_xml_file);
sangwoo1b9f4b32013-06-21 18:22:55 -0700312 if (!adev->audio_route) {
313 ALOGE("%s: Failed to init audio route controls, aborting.", __func__);
314 return NULL;
315 }
316
Eric Laurentb23d5282013-05-14 15:27:20 -0700317 my_data = calloc(1, sizeof(struct platform_data));
318
319 my_data->adev = adev;
320 my_data->dualmic_config = DUALMIC_CONFIG_NONE;
321 my_data->fluence_in_spkr_mode = false;
322 my_data->fluence_in_voice_call = false;
323 my_data->fluence_in_voice_rec = false;
324
325 property_get("persist.audio.dualmic.config",value,"");
326 if (!strcmp("broadside", value)) {
327 my_data->dualmic_config = DUALMIC_CONFIG_BROADSIDE;
328 adev->acdb_settings |= DMIC_FLAG;
329 } else if (!strcmp("endfire", value)) {
330 my_data->dualmic_config = DUALMIC_CONFIG_ENDFIRE;
331 adev->acdb_settings |= DMIC_FLAG;
332 }
333
334 if (my_data->dualmic_config != DUALMIC_CONFIG_NONE) {
335 property_get("persist.audio.fluence.voicecall",value,"");
336 if (!strcmp("true", value)) {
337 my_data->fluence_in_voice_call = true;
338 }
339
340 property_get("persist.audio.fluence.voicerec",value,"");
341 if (!strcmp("true", value)) {
342 my_data->fluence_in_voice_rec = true;
343 }
344
345 property_get("persist.audio.fluence.speaker",value,"");
346 if (!strcmp("true", value)) {
347 my_data->fluence_in_spkr_mode = true;
348 }
349 }
350
351 my_data->acdb_handle = dlopen(LIB_ACDB_LOADER, RTLD_NOW);
352 if (my_data->acdb_handle == NULL) {
353 ALOGE("%s: DLOPEN failed for %s", __func__, LIB_ACDB_LOADER);
354 } else {
355 ALOGV("%s: DLOPEN successful for %s", __func__, LIB_ACDB_LOADER);
356 my_data->acdb_deallocate = (acdb_deallocate_t)dlsym(my_data->acdb_handle,
357 "acdb_loader_deallocate_ACDB");
358 my_data->acdb_send_audio_cal = (acdb_send_audio_cal_t)dlsym(my_data->acdb_handle,
359 "acdb_loader_send_audio_cal");
360 if (!my_data->acdb_send_audio_cal)
361 ALOGW("%s: Could not find the symbol acdb_send_audio_cal from %s",
362 __func__, LIB_ACDB_LOADER);
363 my_data->acdb_send_voice_cal = (acdb_send_voice_cal_t)dlsym(my_data->acdb_handle,
364 "acdb_loader_send_voice_cal");
365 my_data->acdb_init = (acdb_init_t)dlsym(my_data->acdb_handle,
366 "acdb_loader_init_ACDB");
367 if (my_data->acdb_init == NULL)
368 ALOGE("%s: dlsym error %s for acdb_loader_init_ACDB", __func__, dlerror());
369 else
370 my_data->acdb_init();
371 }
372
373 /* If platform is Fusion3, load CSD Client specific symbols
374 * Voice call is handled by MDM and apps processor talks to
375 * MDM through CSD Client
376 */
377 property_get("ro.board.platform", platform, "");
378 property_get("ro.baseband", baseband, "");
379 if (!strcmp("msm8960", platform) && !strcmp("mdm", baseband)) {
380 my_data->csd_client = dlopen(LIB_CSD_CLIENT, RTLD_NOW);
381 if (my_data->csd_client == NULL)
382 ALOGE("%s: DLOPEN failed for %s", __func__, LIB_CSD_CLIENT);
383 }
384
385 if (my_data->csd_client) {
386 ALOGV("%s: DLOPEN successful for %s", __func__, LIB_CSD_CLIENT);
387 my_data->csd_client_deinit = (csd_client_deinit_t)dlsym(my_data->csd_client,
388 "csd_client_deinit");
389 my_data->csd_disable_device = (csd_disable_device_t)dlsym(my_data->csd_client,
390 "csd_client_disable_device");
391 my_data->csd_enable_device = (csd_enable_device_t)dlsym(my_data->csd_client,
392 "csd_client_enable_device");
393 my_data->csd_start_voice = (csd_start_voice_t)dlsym(my_data->csd_client,
394 "csd_client_start_voice");
395 my_data->csd_stop_voice = (csd_stop_voice_t)dlsym(my_data->csd_client,
396 "csd_client_stop_voice");
397 my_data->csd_volume = (csd_volume_t)dlsym(my_data->csd_client,
398 "csd_client_volume");
399 my_data->csd_mic_mute = (csd_mic_mute_t)dlsym(my_data->csd_client,
400 "csd_client_mic_mute");
401 my_data->csd_client_init = (csd_client_init_t)dlsym(my_data->csd_client,
402 "csd_client_init");
403
404 if (my_data->csd_client_init == NULL) {
405 ALOGE("%s: dlsym error %s for csd_client_init", __func__, dlerror());
406 } else {
407 my_data->csd_client_init();
408 }
409 }
410
411 return my_data;
412}
413
414void platform_deinit(void *platform)
415{
416 free(platform);
417}
418
419const char *platform_get_snd_device_name(snd_device_t snd_device)
420{
421 if (snd_device >= SND_DEVICE_MIN && snd_device < SND_DEVICE_MAX)
422 return device_table[snd_device];
423 else
Ravi Kumar Alamanda64026462014-09-15 00:08:58 -0700424 return "none";
Eric Laurentb23d5282013-05-14 15:27:20 -0700425}
426
Ravi Kumar Alamanda299760a2013-11-01 17:29:09 -0500427void platform_add_backend_name(void *platform __unused, char *mixer_path,
428 snd_device_t snd_device)
Eric Laurentb23d5282013-05-14 15:27:20 -0700429{
430 if (snd_device == SND_DEVICE_IN_BT_SCO_MIC)
431 strcat(mixer_path, " bt-sco");
432 else if(snd_device == SND_DEVICE_OUT_BT_SCO)
433 strcat(mixer_path, " bt-sco");
434 else if (snd_device == SND_DEVICE_OUT_HDMI)
435 strcat(mixer_path, " hdmi");
436 else if (snd_device == SND_DEVICE_OUT_SPEAKER_AND_HDMI)
437 strcat(mixer_path, " speaker-and-hdmi");
Ravi Kumar Alamanda9f306542014-04-02 15:11:49 -0700438 else if (snd_device == SND_DEVICE_OUT_BT_SCO_WB ||
439 snd_device == SND_DEVICE_IN_BT_SCO_MIC_WB)
440 strcat(mixer_path, " bt-sco-wb");
Eric Laurentb23d5282013-05-14 15:27:20 -0700441}
442
443int platform_get_pcm_device_id(audio_usecase_t usecase, int device_type)
444{
445 int device_id;
446 if (device_type == PCM_PLAYBACK)
447 device_id = pcm_device_table[usecase][0];
448 else
449 device_id = pcm_device_table[usecase][1];
450 return device_id;
451}
452
Vignesh Kulothungan019d19b2019-01-23 11:09:18 -0800453int platform_get_haptics_pcm_device_id()
454{
455 return -1;
456}
457
Haynes Mathew George98c95622014-06-20 19:14:25 -0700458int platform_get_snd_device_index(char *snd_device_index_name __unused)
Haynes Mathew George5bc18842014-06-16 16:36:20 -0700459{
460 return -ENODEV;
461}
462
Haynes Mathew George98c95622014-06-20 19:14:25 -0700463int platform_set_snd_device_acdb_id(snd_device_t snd_device __unused,
464 unsigned int acdb_id __unused)
Haynes Mathew George5bc18842014-06-16 16:36:20 -0700465{
466 return -ENODEV;
467}
468
David Lind6229bd2017-07-06 15:28:55 -0700469int platform_get_default_app_type_v2(void *platform __unused, usecase_type_t type __unused,
Yamit Mehtae3b99562016-09-16 22:44:00 +0530470 int *app_type __unused)
471{
472 ALOGE("%s: Not implemented", __func__);
473 return -ENOSYS;
474}
475
Ravi Kumar Alamanda63863002015-04-22 11:15:25 -0700476int platform_get_snd_device_acdb_id(snd_device_t snd_device __unused)
477{
478 ALOGE("%s: Not implemented", __func__);
479 return -ENOSYS;
480}
481
Carter Hsu017c63a2018-10-15 15:01:42 -0700482void platform_add_external_specific_device(snd_device_t snd_device __unused,
483 const char *name __unused,
484 unsigned int acdb_id __unused)
485{
486 return;
487}
488
Eric Laurent788f41f2015-08-24 12:21:50 -0700489void platform_add_operator_specific_device(snd_device_t snd_device __unused,
490 const char *operator __unused,
491 const char *mixer_path __unused,
492 unsigned int acdb_id __unused)
keunhui.park2f7306a2015-07-16 16:48:06 +0900493{
494}
495
Eric Laurentb23d5282013-05-14 15:27:20 -0700496int platform_send_audio_calibration(void *platform, snd_device_t snd_device)
497{
498 struct platform_data *my_data = (struct platform_data *)platform;
499 int acdb_dev_id, acdb_dev_type;
500
501 acdb_dev_id = acdb_device_table[snd_device];
502 if (acdb_dev_id < 0) {
503 ALOGE("%s: Could not find acdb id for device(%d)",
504 __func__, snd_device);
505 return -EINVAL;
506 }
507 if (my_data->acdb_send_audio_cal) {
Eric Laurent994a6932013-07-17 11:51:42 -0700508 ("%s: sending audio calibration for snd_device(%d) acdb_id(%d)",
Eric Laurentb23d5282013-05-14 15:27:20 -0700509 __func__, snd_device, acdb_dev_id);
510 if (snd_device >= SND_DEVICE_OUT_BEGIN &&
511 snd_device < SND_DEVICE_OUT_END)
512 acdb_dev_type = ACDB_DEV_TYPE_OUT;
513 else
514 acdb_dev_type = ACDB_DEV_TYPE_IN;
515 my_data->acdb_send_audio_cal(acdb_dev_id, acdb_dev_type);
516 }
517 return 0;
518}
519
520int platform_switch_voice_call_device_pre(void *platform)
521{
522 struct platform_data *my_data = (struct platform_data *)platform;
523 int ret = 0;
524
Ravi Kumar Alamandab09e4a02014-10-20 17:07:43 -0700525 if (my_data->csd_client != NULL &&
526 voice_is_in_call(my_data->adev)) {
Eric Laurentb23d5282013-05-14 15:27:20 -0700527 /* This must be called before disabling the mixer controls on APQ side */
528 if (my_data->csd_disable_device == NULL) {
529 ALOGE("%s: dlsym error for csd_disable_device", __func__);
530 } else {
531 ret = my_data->csd_disable_device();
532 if (ret < 0) {
533 ALOGE("%s: csd_client_disable_device, failed, error %d",
534 __func__, ret);
535 }
536 }
537 }
538 return ret;
539}
540
541int platform_switch_voice_call_device_post(void *platform,
542 snd_device_t out_snd_device,
543 snd_device_t in_snd_device)
544{
545 struct platform_data *my_data = (struct platform_data *)platform;
546 int acdb_rx_id, acdb_tx_id;
547 int ret = 0;
548
549 if (my_data->csd_client) {
550 if (my_data->csd_enable_device == NULL) {
551 ALOGE("%s: dlsym error for csd_enable_device",
552 __func__);
553 } else {
554 acdb_rx_id = acdb_device_table[out_snd_device];
555 acdb_tx_id = acdb_device_table[in_snd_device];
556
557 if (acdb_rx_id > 0 || acdb_tx_id > 0) {
558 ret = my_data->csd_enable_device(acdb_rx_id, acdb_tx_id,
559 my_data->adev->acdb_settings);
560 if (ret < 0) {
561 ALOGE("%s: csd_enable_device, failed, error %d",
562 __func__, ret);
563 }
564 } else {
565 ALOGE("%s: Incorrect ACDB IDs (rx: %d tx: %d)", __func__,
566 acdb_rx_id, acdb_tx_id);
567 }
568 }
569 }
570
571 return ret;
572}
573
Vineeta Srivastava4b89e372014-06-19 14:21:42 -0700574int platform_start_voice_call(void *platform, uint32_t vsid __unused)
Eric Laurentb23d5282013-05-14 15:27:20 -0700575{
576 struct platform_data *my_data = (struct platform_data *)platform;
577 int ret = 0;
578
579 if (my_data->csd_client) {
580 if (my_data->csd_start_voice == NULL) {
581 ALOGE("dlsym error for csd_client_start_voice");
582 ret = -ENOSYS;
583 } else {
584 ret = my_data->csd_start_voice();
585 if (ret < 0) {
586 ALOGE("%s: csd_start_voice error %d\n", __func__, ret);
587 }
588 }
589 }
590
591 return ret;
592}
593
Vineeta Srivastava4b89e372014-06-19 14:21:42 -0700594int platform_stop_voice_call(void *platform, uint32_t vsid __unused)
Eric Laurentb23d5282013-05-14 15:27:20 -0700595{
596 struct platform_data *my_data = (struct platform_data *)platform;
597 int ret = 0;
598
599 if (my_data->csd_client) {
600 if (my_data->csd_stop_voice == NULL) {
601 ALOGE("dlsym error for csd_stop_voice");
602 } else {
603 ret = my_data->csd_stop_voice();
604 if (ret < 0) {
605 ALOGE("%s: csd_stop_voice error %d\n", __func__, ret);
606 }
607 }
608 }
609
610 return ret;
611}
612
Artem Borisov0b782612018-08-20 20:59:06 +0000613int platform_set_mic_break_det(void *platform __unused, bool enable __unused)
614{
615 return 0;
616}
617
vivek mehtab6506412015-08-07 16:55:17 -0700618void platform_set_speaker_gain_in_combo(struct audio_device *adev __unused,
Eric Laurent788f41f2015-08-24 12:21:50 -0700619 snd_device_t snd_device __unused,
vivek mehtab6506412015-08-07 16:55:17 -0700620 bool enable __unused) {
621}
622
Eric Laurentb23d5282013-05-14 15:27:20 -0700623int platform_set_voice_volume(void *platform, int volume)
624{
625 struct platform_data *my_data = (struct platform_data *)platform;
626 int ret = 0;
627
628 if (my_data->csd_client) {
629 if (my_data->csd_volume == NULL) {
630 ALOGE("%s: dlsym error for csd_volume", __func__);
631 } else {
632 ret = my_data->csd_volume(volume);
633 if (ret < 0) {
634 ALOGE("%s: csd_volume error %d", __func__, ret);
635 }
636 }
637 } else {
638 ALOGE("%s: No CSD Client present", __func__);
639 }
640
641 return ret;
642}
643
644int platform_set_mic_mute(void *platform, bool state)
645{
646 struct platform_data *my_data = (struct platform_data *)platform;
647 int ret = 0;
648
649 if (my_data->adev->mode == AUDIO_MODE_IN_CALL) {
650 if (my_data->csd_client) {
651 if (my_data->csd_mic_mute == NULL) {
652 ALOGE("%s: dlsym error for csd_mic_mute", __func__);
653 } else {
654 ret = my_data->csd_mic_mute(state);
655 if (ret < 0) {
656 ALOGE("%s: csd_mic_mute error %d", __func__, ret);
657 }
658 }
659 } else {
660 ALOGE("%s: No CSD Client present", __func__);
661 }
662 }
663
664 return ret;
665}
666
Vineeta Srivastava4b89e372014-06-19 14:21:42 -0700667int platform_set_device_mute(void *platform __unused, bool state __unused, char *dir __unused)
668{
Haynes Mathew George24ca9ad2014-06-18 15:14:18 -0700669 ALOGE("%s: Not implemented", __func__);
Vineeta Srivastava4b89e372014-06-19 14:21:42 -0700670 return -ENOSYS;
671}
672
Eric Laurentb23d5282013-05-14 15:27:20 -0700673snd_device_t platform_get_output_snd_device(void *platform, audio_devices_t devices)
674{
675 struct platform_data *my_data = (struct platform_data *)platform;
676 struct audio_device *adev = my_data->adev;
677 audio_mode_t mode = adev->mode;
678 snd_device_t snd_device = SND_DEVICE_NONE;
679
680 ALOGV("%s: enter: output devices(%#x)", __func__, devices);
681 if (devices == AUDIO_DEVICE_NONE ||
682 devices & AUDIO_DEVICE_BIT_IN) {
683 ALOGV("%s: Invalid output devices (%#x)", __func__, devices);
684 goto exit;
685 }
686
Ravi Kumar Alamandab09e4a02014-10-20 17:07:43 -0700687 if (voice_is_in_call(adev)) {
Eric Laurentb23d5282013-05-14 15:27:20 -0700688 if (devices & AUDIO_DEVICE_OUT_WIRED_HEADPHONE ||
689 devices & AUDIO_DEVICE_OUT_WIRED_HEADSET) {
Haynes Mathew George24ca9ad2014-06-18 15:14:18 -0700690 if (adev->voice.tty_mode == TTY_MODE_FULL)
Eric Laurentb23d5282013-05-14 15:27:20 -0700691 snd_device = SND_DEVICE_OUT_VOICE_TTY_FULL_HEADPHONES;
Haynes Mathew George24ca9ad2014-06-18 15:14:18 -0700692 else if (adev->voice.tty_mode == TTY_MODE_VCO)
Eric Laurentb23d5282013-05-14 15:27:20 -0700693 snd_device = SND_DEVICE_OUT_VOICE_TTY_VCO_HEADPHONES;
Haynes Mathew George24ca9ad2014-06-18 15:14:18 -0700694 else if (adev->voice.tty_mode == TTY_MODE_HCO)
Eric Laurentb23d5282013-05-14 15:27:20 -0700695 snd_device = SND_DEVICE_OUT_VOICE_TTY_HCO_HANDSET;
yixuanjiang9536e672018-09-06 18:43:36 +0800696 else if (devices & AUDIO_DEVICE_OUT_WIRED_HEADSET)
697 snd_device = SND_DEVICE_OUT_VOICE_HEADSET;
Eric Laurentb23d5282013-05-14 15:27:20 -0700698 else
699 snd_device = SND_DEVICE_OUT_VOICE_HEADPHONES;
700 } else if (devices & AUDIO_DEVICE_OUT_ALL_SCO) {
Ravi Kumar Alamanda9f306542014-04-02 15:11:49 -0700701 if (adev->bt_wb_speech_enabled) {
702 snd_device = SND_DEVICE_OUT_BT_SCO_WB;
703 } else {
704 snd_device = SND_DEVICE_OUT_BT_SCO;
705 }
Eric Laurentb23d5282013-05-14 15:27:20 -0700706 } else if (devices & AUDIO_DEVICE_OUT_SPEAKER) {
707 snd_device = SND_DEVICE_OUT_VOICE_SPEAKER;
708 } else if (devices & AUDIO_DEVICE_OUT_EARPIECE) {
709 if (is_operator_tmus())
710 snd_device = SND_DEVICE_OUT_VOICE_HANDSET_TMUS;
711 else
712 snd_device = SND_DEVICE_OUT_HANDSET;
713 }
714 if (snd_device != SND_DEVICE_NONE) {
715 goto exit;
716 }
717 }
718
719 if (popcount(devices) == 2) {
720 if (devices == (AUDIO_DEVICE_OUT_WIRED_HEADPHONE |
721 AUDIO_DEVICE_OUT_SPEAKER)) {
722 snd_device = SND_DEVICE_OUT_SPEAKER_AND_HEADPHONES;
723 } else if (devices == (AUDIO_DEVICE_OUT_WIRED_HEADSET |
724 AUDIO_DEVICE_OUT_SPEAKER)) {
725 snd_device = SND_DEVICE_OUT_SPEAKER_AND_HEADPHONES;
726 } else if (devices == (AUDIO_DEVICE_OUT_AUX_DIGITAL |
727 AUDIO_DEVICE_OUT_SPEAKER)) {
728 snd_device = SND_DEVICE_OUT_SPEAKER_AND_HDMI;
729 } else {
730 ALOGE("%s: Invalid combo device(%#x)", __func__, devices);
731 goto exit;
732 }
733 if (snd_device != SND_DEVICE_NONE) {
734 goto exit;
735 }
736 }
737
738 if (popcount(devices) != 1) {
739 ALOGE("%s: Invalid output devices(%#x)", __func__, devices);
740 goto exit;
741 }
742
743 if (devices & AUDIO_DEVICE_OUT_WIRED_HEADPHONE ||
744 devices & AUDIO_DEVICE_OUT_WIRED_HEADSET) {
745 snd_device = SND_DEVICE_OUT_HEADPHONES;
746 } else if (devices & AUDIO_DEVICE_OUT_SPEAKER) {
andysu5b30b062018-04-20 16:34:06 +0800747 /*
748 * Perform device switch only if acdb tuning is different between SPEAKER & SPEAKER_REVERSE,
749 * Or there will be a small pause while performing device switch.
750 */
751 if (my_data->speaker_lr_swap &&
752 (acdb_device_table[SND_DEVICE_OUT_SPEAKER] !=
753 acdb_device_table[SND_DEVICE_OUT_SPEAKER_REVERSE]))
Eric Laurentb23d5282013-05-14 15:27:20 -0700754 snd_device = SND_DEVICE_OUT_SPEAKER_REVERSE;
755 else
756 snd_device = SND_DEVICE_OUT_SPEAKER;
757 } else if (devices & AUDIO_DEVICE_OUT_ALL_SCO) {
Ravi Kumar Alamanda9f306542014-04-02 15:11:49 -0700758 if (adev->bt_wb_speech_enabled) {
759 snd_device = SND_DEVICE_OUT_BT_SCO_WB;
760 } else {
761 snd_device = SND_DEVICE_OUT_BT_SCO;
762 }
Eric Laurentb23d5282013-05-14 15:27:20 -0700763 } else if (devices & AUDIO_DEVICE_OUT_AUX_DIGITAL) {
764 snd_device = SND_DEVICE_OUT_HDMI ;
765 } else if (devices & AUDIO_DEVICE_OUT_EARPIECE) {
766 snd_device = SND_DEVICE_OUT_HANDSET;
767 } else {
768 ALOGE("%s: Unknown device(s) %#x", __func__, devices);
769 }
770exit:
771 ALOGV("%s: exit: snd_device(%s)", __func__, device_table[snd_device]);
772 return snd_device;
773}
774
Eric Laurentd1b7a9b2018-11-15 12:24:31 -0800775snd_device_t platform_get_input_snd_device(void *platform,
776 struct stream_in *in,
777 audio_devices_t out_device)
Eric Laurentb23d5282013-05-14 15:27:20 -0700778{
779 struct platform_data *my_data = (struct platform_data *)platform;
780 struct audio_device *adev = my_data->adev;
Eric Laurentd1b7a9b2018-11-15 12:24:31 -0800781 audio_mode_t mode = adev->mode;
Eric Laurentb23d5282013-05-14 15:27:20 -0700782 snd_device_t snd_device = SND_DEVICE_NONE;
783
Eric Laurentd1b7a9b2018-11-15 12:24:31 -0800784 if (in == NULL) {
785 in = adev_get_active_input(adev);
786 }
787
788 audio_source_t source = (in == NULL) ? AUDIO_SOURCE_DEFAULT : in->source;
789 audio_devices_t in_device =
790 ((in == NULL) ? AUDIO_DEVICE_NONE : in->device) & ~AUDIO_DEVICE_BIT_IN;
791 audio_channel_mask_t channel_mask = (in == NULL) ? AUDIO_CHANNEL_IN_MONO : in->channel_mask;
792
Eric Laurentb23d5282013-05-14 15:27:20 -0700793 ALOGV("%s: enter: out_device(%#x) in_device(%#x)",
794 __func__, out_device, in_device);
Ravi Kumar Alamandab09e4a02014-10-20 17:07:43 -0700795 if ((out_device != AUDIO_DEVICE_NONE) && voice_is_in_call(adev)) {
Vineeta Srivastava4b89e372014-06-19 14:21:42 -0700796 if (adev->voice.tty_mode != TTY_MODE_OFF) {
Eric Laurentb23d5282013-05-14 15:27:20 -0700797 if (out_device & AUDIO_DEVICE_OUT_WIRED_HEADPHONE ||
798 out_device & AUDIO_DEVICE_OUT_WIRED_HEADSET) {
Vineeta Srivastava4b89e372014-06-19 14:21:42 -0700799 switch (adev->voice.tty_mode) {
Eric Laurentb23d5282013-05-14 15:27:20 -0700800 case TTY_MODE_FULL:
801 snd_device = SND_DEVICE_IN_VOICE_TTY_FULL_HEADSET_MIC;
802 break;
803 case TTY_MODE_VCO:
804 snd_device = SND_DEVICE_IN_VOICE_TTY_VCO_HANDSET_MIC;
805 break;
806 case TTY_MODE_HCO:
807 snd_device = SND_DEVICE_IN_VOICE_TTY_HCO_HEADSET_MIC;
808 break;
809 default:
Vineeta Srivastava4b89e372014-06-19 14:21:42 -0700810 ALOGE("%s: Invalid TTY mode (%#x)", __func__, adev->voice.tty_mode);
Eric Laurentb23d5282013-05-14 15:27:20 -0700811 }
812 goto exit;
813 }
814 }
815 if (out_device & AUDIO_DEVICE_OUT_EARPIECE ||
816 out_device & AUDIO_DEVICE_OUT_WIRED_HEADPHONE) {
817 if (my_data->fluence_in_voice_call == false) {
818 snd_device = SND_DEVICE_IN_HANDSET_MIC;
819 } else {
820 if (my_data->dualmic_config == DUALMIC_CONFIG_ENDFIRE) {
821 if (is_operator_tmus())
822 snd_device = SND_DEVICE_IN_VOICE_DMIC_EF_TMUS;
823 else
824 snd_device = SND_DEVICE_IN_VOICE_DMIC_EF;
825 } else if(my_data->dualmic_config == DUALMIC_CONFIG_BROADSIDE)
826 snd_device = SND_DEVICE_IN_VOICE_DMIC_BS;
827 else
828 snd_device = SND_DEVICE_IN_HANDSET_MIC;
829 }
830 } else if (out_device & AUDIO_DEVICE_OUT_WIRED_HEADSET) {
831 snd_device = SND_DEVICE_IN_VOICE_HEADSET_MIC;
832 } else if (out_device & AUDIO_DEVICE_OUT_ALL_SCO) {
Ravi Kumar Alamanda9f306542014-04-02 15:11:49 -0700833 if (adev->bt_wb_speech_enabled) {
834 snd_device = SND_DEVICE_IN_BT_SCO_MIC_WB;
835 } else {
836 snd_device = SND_DEVICE_IN_BT_SCO_MIC;
837 }
Eric Laurentb23d5282013-05-14 15:27:20 -0700838 } else if (out_device & AUDIO_DEVICE_OUT_SPEAKER) {
839 if (my_data->fluence_in_voice_call && my_data->fluence_in_spkr_mode &&
840 my_data->dualmic_config == DUALMIC_CONFIG_ENDFIRE) {
841 snd_device = SND_DEVICE_IN_VOICE_SPEAKER_DMIC_EF;
842 } else if (my_data->fluence_in_voice_call && my_data->fluence_in_spkr_mode &&
843 my_data->dualmic_config == DUALMIC_CONFIG_BROADSIDE) {
844 snd_device = SND_DEVICE_IN_VOICE_SPEAKER_DMIC_BS;
845 } else {
846 snd_device = SND_DEVICE_IN_VOICE_SPEAKER_MIC;
847 }
848 }
849 } else if (source == AUDIO_SOURCE_CAMCORDER) {
850 if (in_device & AUDIO_DEVICE_IN_BUILTIN_MIC ||
851 in_device & AUDIO_DEVICE_IN_BACK_MIC) {
852 snd_device = SND_DEVICE_IN_CAMCORDER_MIC;
853 }
854 } else if (source == AUDIO_SOURCE_VOICE_RECOGNITION) {
855 if (in_device & AUDIO_DEVICE_IN_BUILTIN_MIC) {
856 if (my_data->dualmic_config == DUALMIC_CONFIG_ENDFIRE) {
857 if (channel_mask == AUDIO_CHANNEL_IN_FRONT_BACK)
858 snd_device = SND_DEVICE_IN_VOICE_REC_DMIC_EF;
859 else if (my_data->fluence_in_voice_rec)
860 snd_device = SND_DEVICE_IN_VOICE_REC_DMIC_EF_FLUENCE;
861 } else if (my_data->dualmic_config == DUALMIC_CONFIG_BROADSIDE) {
862 if (channel_mask == AUDIO_CHANNEL_IN_FRONT_BACK)
863 snd_device = SND_DEVICE_IN_VOICE_REC_DMIC_BS;
864 else if (my_data->fluence_in_voice_rec)
865 snd_device = SND_DEVICE_IN_VOICE_REC_DMIC_BS_FLUENCE;
866 }
867
868 if (snd_device == SND_DEVICE_NONE) {
869 snd_device = SND_DEVICE_IN_VOICE_REC_MIC;
870 }
871 }
Eric Laurent50a38ed2015-10-14 18:48:06 -0700872 } else if (source == AUDIO_SOURCE_VOICE_COMMUNICATION ||
873 mode == AUDIO_MODE_IN_COMMUNICATION) {
Eric Laurentb23d5282013-05-14 15:27:20 -0700874 if (out_device & AUDIO_DEVICE_OUT_SPEAKER)
875 in_device = AUDIO_DEVICE_IN_BACK_MIC;
Eric Laurentd1b7a9b2018-11-15 12:24:31 -0800876 if (in) {
877 if (in != NULL && in->enable_aec) {
Eric Laurentb23d5282013-05-14 15:27:20 -0700878 if (in_device & AUDIO_DEVICE_IN_BACK_MIC) {
879 snd_device = SND_DEVICE_IN_SPEAKER_MIC_AEC;
880 } else if (in_device & AUDIO_DEVICE_IN_BUILTIN_MIC) {
881 snd_device = SND_DEVICE_IN_HANDSET_MIC_AEC;
882 } else if (in_device & AUDIO_DEVICE_IN_WIRED_HEADSET) {
883 snd_device = SND_DEVICE_IN_HEADSET_MIC_AEC;
884 }
885 set_echo_reference(adev->mixer, "SLIM_RX");
886 } else
887 set_echo_reference(adev->mixer, "NONE");
888 }
889 } else if (source == AUDIO_SOURCE_DEFAULT) {
890 goto exit;
891 }
892
893
894 if (snd_device != SND_DEVICE_NONE) {
895 goto exit;
896 }
897
898 if (in_device != AUDIO_DEVICE_NONE &&
899 !(in_device & AUDIO_DEVICE_IN_VOICE_CALL) &&
900 !(in_device & AUDIO_DEVICE_IN_COMMUNICATION)) {
901 if (in_device & AUDIO_DEVICE_IN_BUILTIN_MIC) {
902 snd_device = SND_DEVICE_IN_HANDSET_MIC;
903 } else if (in_device & AUDIO_DEVICE_IN_BACK_MIC) {
904 snd_device = SND_DEVICE_IN_SPEAKER_MIC;
905 } else if (in_device & AUDIO_DEVICE_IN_WIRED_HEADSET) {
906 snd_device = SND_DEVICE_IN_HEADSET_MIC;
907 } else if (in_device & AUDIO_DEVICE_IN_BLUETOOTH_SCO_HEADSET) {
Ravi Kumar Alamanda9f306542014-04-02 15:11:49 -0700908 if (adev->bt_wb_speech_enabled) {
909 snd_device = SND_DEVICE_IN_BT_SCO_MIC_WB;
910 } else {
911 snd_device = SND_DEVICE_IN_BT_SCO_MIC;
912 }
Eric Laurentb23d5282013-05-14 15:27:20 -0700913 } else if (in_device & AUDIO_DEVICE_IN_AUX_DIGITAL) {
914 snd_device = SND_DEVICE_IN_HDMI_MIC;
915 } else {
916 ALOGE("%s: Unknown input device(s) %#x", __func__, in_device);
917 ALOGW("%s: Using default handset-mic", __func__);
918 snd_device = SND_DEVICE_IN_HANDSET_MIC;
919 }
920 } else {
921 if (out_device & AUDIO_DEVICE_OUT_EARPIECE) {
922 snd_device = SND_DEVICE_IN_HANDSET_MIC;
923 } else if (out_device & AUDIO_DEVICE_OUT_WIRED_HEADSET) {
924 snd_device = SND_DEVICE_IN_HEADSET_MIC;
925 } else if (out_device & AUDIO_DEVICE_OUT_SPEAKER) {
926 snd_device = SND_DEVICE_IN_SPEAKER_MIC;
927 } else if (out_device & AUDIO_DEVICE_OUT_WIRED_HEADPHONE) {
928 snd_device = SND_DEVICE_IN_HANDSET_MIC;
929 } else if (out_device & AUDIO_DEVICE_OUT_BLUETOOTH_SCO_HEADSET) {
Ravi Kumar Alamanda9f306542014-04-02 15:11:49 -0700930 if (adev->bt_wb_speech_enabled) {
931 snd_device = SND_DEVICE_IN_BT_SCO_MIC_WB;
932 } else {
933 snd_device = SND_DEVICE_IN_BT_SCO_MIC;
934 }
Eric Laurentb23d5282013-05-14 15:27:20 -0700935 } else if (out_device & AUDIO_DEVICE_OUT_AUX_DIGITAL) {
936 snd_device = SND_DEVICE_IN_HDMI_MIC;
937 } else {
938 ALOGE("%s: Unknown output device(s) %#x", __func__, out_device);
939 ALOGW("%s: Using default handset-mic", __func__);
940 snd_device = SND_DEVICE_IN_HANDSET_MIC;
941 }
942 }
943exit:
944 ALOGV("%s: exit: in_snd_device(%s)", __func__, device_table[snd_device]);
945 return snd_device;
946}
947
948int platform_set_hdmi_channels(void *platform, int channel_count)
949{
950 struct platform_data *my_data = (struct platform_data *)platform;
951 struct audio_device *adev = my_data->adev;
952 struct mixer_ctl *ctl;
953 const char *channel_cnt_str = NULL;
954 const char *mixer_ctl_name = "HDMI_RX Channels";
955 switch (channel_count) {
956 case 8:
957 channel_cnt_str = "Eight"; break;
958 case 7:
959 channel_cnt_str = "Seven"; break;
960 case 6:
961 channel_cnt_str = "Six"; break;
962 case 5:
963 channel_cnt_str = "Five"; break;
964 case 4:
965 channel_cnt_str = "Four"; break;
966 case 3:
967 channel_cnt_str = "Three"; break;
968 default:
969 channel_cnt_str = "Two"; break;
970 }
971 ctl = mixer_get_ctl_by_name(adev->mixer, mixer_ctl_name);
972 if (!ctl) {
973 ALOGE("%s: Could not get ctl for mixer cmd - %s",
974 __func__, mixer_ctl_name);
975 return -EINVAL;
976 }
977 ALOGV("HDMI channel count: %s", channel_cnt_str);
978 mixer_ctl_set_enum_by_string(ctl, channel_cnt_str);
979 return 0;
980}
981
Haynes Mathew George24ca9ad2014-06-18 15:14:18 -0700982int platform_edid_get_max_channels(void *platform __unused)
Eric Laurentb23d5282013-05-14 15:27:20 -0700983{
984 FILE *file;
985 struct audio_block_header header;
986 char block[MAX_SAD_BLOCKS * SAD_BLOCK_SIZE];
987 char *sad = block;
988 int num_audio_blocks;
989 int channel_count;
990 int max_channels = 0;
991 int i;
992
993 file = fopen(AUDIO_DATA_BLOCK_PATH, "rb");
994 if (file == NULL) {
995 ALOGE("Unable to open '%s'", AUDIO_DATA_BLOCK_PATH);
996 return 0;
997 }
998
999 /* Read audio block header */
1000 fread(&header, 1, sizeof(header), file);
1001
1002 /* Read SAD blocks, clamping the maximum size for safety */
1003 if (header.length > (int)sizeof(block))
1004 header.length = (int)sizeof(block);
1005 fread(&block, header.length, 1, file);
1006
1007 fclose(file);
1008
1009 /* Calculate the number of SAD blocks */
1010 num_audio_blocks = header.length / SAD_BLOCK_SIZE;
1011
1012 for (i = 0; i < num_audio_blocks; i++) {
1013 /* Only consider LPCM blocks */
1014 if ((sad[0] >> 3) != EDID_FORMAT_LPCM)
1015 continue;
1016
1017 channel_count = (sad[0] & 0x7) + 1;
1018 if (channel_count > max_channels)
1019 max_channels = channel_count;
1020
1021 /* Advance to next block */
1022 sad += 3;
1023 }
1024
1025 return max_channels;
1026}
Haynes Mathew George7ff216f2013-09-11 19:51:41 -07001027
Vineeta Srivastava4b89e372014-06-19 14:21:42 -07001028int platform_set_incall_recording_session_id(void *platform __unused,
1029 uint32_t session_id __unused, int rec_mode __unused)
1030{
Haynes Mathew George24ca9ad2014-06-18 15:14:18 -07001031 ALOGE("%s: Not implemented", __func__);
Vineeta Srivastava4b89e372014-06-19 14:21:42 -07001032 return -ENOSYS;
1033}
1034
1035int platform_stop_incall_recording_usecase(void *platform __unused)
1036{
Haynes Mathew George24ca9ad2014-06-18 15:14:18 -07001037 ALOGE("%s: Not implemented", __func__);
Vineeta Srivastava4b89e372014-06-19 14:21:42 -07001038 return -ENOSYS;
1039}
1040
1041int platform_start_incall_music_usecase(void *platform __unused)
1042{
Haynes Mathew George24ca9ad2014-06-18 15:14:18 -07001043 ALOGE("%s: Not implemented", __func__);
Vineeta Srivastava4b89e372014-06-19 14:21:42 -07001044 return -ENOSYS;
1045}
1046
1047int platform_stop_incall_music_usecase(void *platform __unused)
1048{
Haynes Mathew George24ca9ad2014-06-18 15:14:18 -07001049 ALOGE("%s: Not implemented", __func__);
Vineeta Srivastava4b89e372014-06-19 14:21:42 -07001050 return -ENOSYS;
1051}
1052
Ravi Kumar Alamandac4f57312015-06-26 17:41:02 -07001053int platform_set_parameters(void *platform __unused,
1054 struct str_parms *parms __unused)
1055{
1056 ALOGE("%s: Not implemented", __func__);
1057 return -ENOSYS;
1058}
1059
Haynes Mathew George7ff216f2013-09-11 19:51:41 -07001060/* Delay in Us */
1061int64_t platform_render_latency(audio_usecase_t usecase)
1062{
1063 switch (usecase) {
1064 case USECASE_AUDIO_PLAYBACK_DEEP_BUFFER:
1065 return DEEP_BUFFER_PLATFORM_DELAY;
1066 case USECASE_AUDIO_PLAYBACK_LOW_LATENCY:
1067 return LOW_LATENCY_PLATFORM_DELAY;
1068 default:
1069 return 0;
1070 }
1071}
Ravi Kumar Alamanda83281a92014-05-19 18:14:57 -07001072
Haynes Mathew George24ca9ad2014-06-18 15:14:18 -07001073int platform_switch_voice_call_enable_device_config(void *platform __unused,
1074 snd_device_t out_snd_device __unused,
1075 snd_device_t in_snd_device __unused)
Ravi Kumar Alamanda83281a92014-05-19 18:14:57 -07001076{
1077 return 0;
1078}
1079
Haynes Mathew George24ca9ad2014-06-18 15:14:18 -07001080int platform_switch_voice_call_usecase_route_post(void *platform __unused,
1081 snd_device_t out_snd_device __unused,
1082 snd_device_t in_snd_device __unused)
Ravi Kumar Alamanda83281a92014-05-19 18:14:57 -07001083{
1084 return 0;
1085}
Haynes Mathew George24ca9ad2014-06-18 15:14:18 -07001086
1087int platform_get_sample_rate(void *platform __unused, uint32_t *rate __unused)
1088{
1089 return -ENOSYS;
1090}
Haynes Mathew George98c95622014-06-20 19:14:25 -07001091
1092int platform_get_usecase_index(const char * usecase __unused)
1093{
1094 return -ENOSYS;
1095}
1096
1097int platform_set_usecase_pcm_id(audio_usecase_t usecase __unused, int32_t type __unused,
1098 int32_t pcm_id __unused)
1099{
1100 return -ENOSYS;
1101}
1102
1103int platform_set_snd_device_backend(snd_device_t device __unused,
Ravi Kumar Alamandab7ea4f52015-06-08 16:44:05 -07001104 const char *backend __unused,
1105 const char *hw_interface __unused)
Haynes Mathew George98c95622014-06-20 19:14:25 -07001106{
1107 return -ENOSYS;
1108}
Eric Laurentcefbbac2014-09-04 13:54:10 -05001109
vivek mehta1a9b7c02015-06-25 11:49:38 -07001110void platform_set_echo_reference(struct audio_device *adev __unused,
1111 bool enable __unused,
1112 audio_devices_t out_device __unused)
Eric Laurentcefbbac2014-09-04 13:54:10 -05001113{
1114 return;
1115}
Ravi Kumar Alamanda1f60cf82015-04-23 19:45:17 -07001116
vivek mehtae59cfb22017-06-16 15:57:11 -07001117#define DEFAULT_NOMINAL_SPEAKER_GAIN 20
1118int ramp_speaker_gain(struct audio_device *adev, bool ramp_up, int target_ramp_up_gain) {
1119 // backup_gain: gain to try to set in case of an error during ramp
1120 int start_gain, end_gain, step, backup_gain, i;
1121 bool error = false;
1122 const struct mixer_ctl *ctl;
1123 const char *mixer_ctl_name_gain_left = "Left Speaker Gain";
1124 const char *mixer_ctl_name_gain_right = "Right Speaker Gain";
1125 struct mixer_ctl *ctl_left = mixer_get_ctl_by_name(adev->mixer, mixer_ctl_name_gain_left);
1126 struct mixer_ctl *ctl_right = mixer_get_ctl_by_name(adev->mixer, mixer_ctl_name_gain_right);
1127 if (!ctl_left || !ctl_right) {
1128 ALOGE("%s: Could not get ctl for mixer cmd - %s or %s, not applying speaker gain ramp",
1129 __func__, mixer_ctl_name_gain_left, mixer_ctl_name_gain_right);
1130 return -EINVAL;
1131 } else if ((mixer_ctl_get_num_values(ctl_left) != 1)
1132 || (mixer_ctl_get_num_values(ctl_right) != 1)) {
1133 ALOGE("%s: Unexpected num values for mixer cmd - %s or %s, not applying speaker gain ramp",
1134 __func__, mixer_ctl_name_gain_left, mixer_ctl_name_gain_right);
1135 return -EINVAL;
1136 }
1137 if (ramp_up) {
1138 start_gain = 0;
1139 end_gain = target_ramp_up_gain > 0 ? target_ramp_up_gain : DEFAULT_NOMINAL_SPEAKER_GAIN;
1140 step = +1;
1141 backup_gain = end_gain;
1142 } else {
1143 // using same gain on left and right
1144 const int left_gain = mixer_ctl_get_value(ctl_left, 0);
1145 start_gain = left_gain > 0 ? left_gain : DEFAULT_NOMINAL_SPEAKER_GAIN;
1146 end_gain = 0;
1147 step = -1;
1148 backup_gain = start_gain;
1149 }
1150 for (i = start_gain ; i != (end_gain + step) ; i += step) {
1151 //ALOGV("setting speaker gain to %d", i);
1152 if (mixer_ctl_set_value(ctl_left, 0, i)) {
1153 ALOGE("%s: error setting %s to %d during gain ramp",
1154 __func__, mixer_ctl_name_gain_left, i);
1155 error = true;
1156 break;
1157 }
1158 if (mixer_ctl_set_value(ctl_right, 0, i)) {
1159 ALOGE("%s: error setting %s to %d during gain ramp",
1160 __func__, mixer_ctl_name_gain_right, i);
1161 error = true;
1162 break;
1163 }
1164 usleep(1000);
1165 }
1166 if (error) {
1167 // an error occured during the ramp, let's still try to go back to a safe volume
1168 if (mixer_ctl_set_value(ctl_left, 0, backup_gain)) {
1169 ALOGE("%s: error restoring left gain to %d", __func__, backup_gain);
1170 }
1171 if (mixer_ctl_set_value(ctl_right, 0, backup_gain)) {
1172 ALOGE("%s: error restoring right gain to %d", __func__, backup_gain);
1173 }
1174 }
1175 return start_gain;
1176}
1177
1178int platform_set_swap_mixer(struct audio_device *adev, bool swap_channels)
Ravi Kumar Alamanda1f60cf82015-04-23 19:45:17 -07001179{
vivek mehtae59cfb22017-06-16 15:57:11 -07001180 const char *mixer_ctl_name = "Swap channel";
1181 struct mixer_ctl *ctl;
1182 const char *mixer_path;
1183 struct platform_data *my_data = (struct platform_data *)adev->platform;
1184
1185 // forced to set to swap, but device not rotated ... ignore set
1186 if (swap_channels && !my_data->speaker_lr_swap)
1187 return 0;
1188
1189 ALOGV("%s:", __func__);
1190
1191 if (swap_channels) {
1192 mixer_path = platform_get_snd_device_name(SND_DEVICE_OUT_SPEAKER_REVERSE);
1193 audio_route_apply_and_update_path(adev->audio_route, mixer_path);
1194 } else {
1195 mixer_path = platform_get_snd_device_name(SND_DEVICE_OUT_SPEAKER);
1196 audio_route_apply_and_update_path(adev->audio_route, mixer_path);
1197 }
1198
1199 ctl = mixer_get_ctl_by_name(adev->mixer, mixer_ctl_name);
1200 if (!ctl) {
1201 ALOGE("%s: Could not get ctl for mixer cmd - %s",__func__, mixer_ctl_name);
1202 return -EINVAL;
1203 }
1204
1205 if (mixer_ctl_set_value(ctl, 0, swap_channels) < 0) {
1206 ALOGE("%s: Could not set reverse cotrol %d",__func__, swap_channels);
1207 return -EINVAL;
1208 }
1209
1210 ALOGV("platfor_force_swap_channel :: Channel orientation ( %s ) ",
1211 swap_channels?"R --> L":"L --> R");
1212
1213 return 0;
1214}
1215
1216int platform_check_and_set_swap_lr_channels(struct audio_device *adev, bool swap_channels)
1217{
1218 // only update if there is active pcm playback on speaker
Ravi Kumar Alamanda1f60cf82015-04-23 19:45:17 -07001219 struct audio_usecase *usecase;
1220 struct listnode *node;
1221 struct platform_data *my_data = (struct platform_data *)adev->platform;
Ravi Kumar Alamanda1f60cf82015-04-23 19:45:17 -07001222
vivek mehtae59cfb22017-06-16 15:57:11 -07001223 my_data->speaker_lr_swap = swap_channels;
Ravi Kumar Alamanda1f60cf82015-04-23 19:45:17 -07001224
vivek mehtae59cfb22017-06-16 15:57:11 -07001225 return platform_set_swap_channels(adev, swap_channels);
1226}
1227
1228int platform_set_swap_channels(struct audio_device *adev, bool swap_channels)
1229{
1230 // only update if there is active pcm playback on speaker
1231 struct audio_usecase *usecase;
1232 struct listnode *node;
1233 struct platform_data *my_data = (struct platform_data *)adev->platform;
1234
1235 // do not swap channels in audio modes with concurrent capture and playback
1236 // as this may break the echo reference
1237 if ((adev->mode == AUDIO_MODE_IN_COMMUNICATION) || (adev->mode == AUDIO_MODE_IN_CALL)) {
1238 ALOGV("%s: will not swap due to audio mode %d", __func__, adev->mode);
1239 return 0;
1240 }
1241
1242 list_for_each(node, &adev->usecase_list) {
1243 usecase = node_to_item(node, struct audio_usecase, list);
1244 if (usecase->type == PCM_PLAYBACK &&
Ravi Kumar Alamanda1f60cf82015-04-23 19:45:17 -07001245 usecase->stream.out->devices & AUDIO_DEVICE_OUT_SPEAKER) {
vivek mehtae59cfb22017-06-16 15:57:11 -07001246 /*
1247 * If acdb tuning is different for SPEAKER_REVERSE, it is must
1248 * to perform device switch to disable the current backend to
1249 * enable it with new acdb data.
1250 */
1251 if (acdb_device_table[SND_DEVICE_OUT_SPEAKER] !=
1252 acdb_device_table[SND_DEVICE_OUT_SPEAKER_REVERSE]) {
1253 const int initial_skpr_gain = ramp_speaker_gain(adev, false /*ramp_up*/, -1);
1254 select_devices(adev, usecase->id);
1255 if (initial_skpr_gain != -EINVAL)
1256 ramp_speaker_gain(adev, true /*ramp_up*/, initial_skpr_gain);
1257
1258 } else {
1259 platform_set_swap_mixer(adev, swap_channels);
Ravi Kumar Alamanda1f60cf82015-04-23 19:45:17 -07001260 }
vivek mehtae59cfb22017-06-16 15:57:11 -07001261 break;
Ravi Kumar Alamanda1f60cf82015-04-23 19:45:17 -07001262 }
1263 }
vivek mehtae59cfb22017-06-16 15:57:11 -07001264
1265 return 0;
Ravi Kumar Alamanda1f60cf82015-04-23 19:45:17 -07001266}
Ravi Kumar Alamandab7ea4f52015-06-08 16:44:05 -07001267
1268bool platform_send_gain_dep_cal(void *platform __unused,
1269 int level __unused)
1270{
vivek mehtafb4d7bd2016-04-29 03:16:47 -07001271 return true;
Ravi Kumar Alamandab7ea4f52015-06-08 16:44:05 -07001272}
1273
Haynes Mathew George2d809e02016-09-22 17:38:16 -07001274int platform_can_split_snd_device(snd_device_t in_snd_device __unused,
Ravi Kumar Alamandab7ea4f52015-06-08 16:44:05 -07001275 int *num_devices __unused,
1276 snd_device_t *out_snd_devices __unused)
1277{
Haynes Mathew George2d809e02016-09-22 17:38:16 -07001278 return -ENOSYS;
Ravi Kumar Alamandab7ea4f52015-06-08 16:44:05 -07001279}
1280
1281bool platform_check_backends_match(snd_device_t snd_device1 __unused,
1282 snd_device_t snd_device2 __unused)
1283{
1284 return true;
1285}
vivek mehtade4849c2016-03-03 17:23:38 -08001286
1287int platform_get_snd_device_name_extn(void *platform __unused,
1288 snd_device_t snd_device,
1289 char *device_name)
1290{
David Benjamin1565f992016-09-21 12:10:34 -04001291 strlcpy(device_name, platform_get_snd_device_name(snd_device),
1292 DEVICE_NAME_MAX_SIZE);
vivek mehtade4849c2016-03-03 17:23:38 -08001293 return 0;
1294}
1295
David Linee3fe402017-03-13 10:00:42 -07001296bool platform_check_and_set_playback_backend_cfg(struct audio_device* adev __unused,
1297 struct audio_usecase *usecase __unused,
1298 snd_device_t snd_device __unused)
1299{
1300 return false;
1301}
1302
vivek mehta4ed66e62016-04-15 23:33:34 -07001303bool platform_check_and_set_capture_backend_cfg(struct audio_device* adev __unused,
David Lind6229bd2017-07-06 15:28:55 -07001304 struct audio_usecase *usecase __unused, snd_device_t snd_device __unused)
vivek mehta4ed66e62016-04-15 23:33:34 -07001305{
1306 return false;
1307}
1308
vivek mehtaa8d7c922016-05-25 14:40:44 -07001309bool platform_add_gain_level_mapping(struct amp_db_and_gain_table *tbl_entry __unused)
1310{
1311 return false;
1312}
1313
1314int platform_get_gain_level_mapping(struct amp_db_and_gain_table *mapping_tbl __unused,
1315 int table_size __unused)
1316{
1317 return 0;
1318}
Haynes Mathew Georgec735fb02016-06-30 18:00:28 -07001319
Tom Cherry8721b4d2016-07-14 16:12:23 -07001320int platform_snd_card_update(void *platform __unused,
Haynes Mathew Georgec735fb02016-06-30 18:00:28 -07001321 card_status_t status __unused)
1322{
1323 return -1;
1324}
Haynes Mathew Georgee5ff0fc2017-02-16 20:33:38 -08001325
David Lind6229bd2017-07-06 15:28:55 -07001326int platform_get_snd_device_backend_index(snd_device_t snd_device __unused)
Haynes Mathew Georgee5ff0fc2017-02-16 20:33:38 -08001327{
1328 return -ENOSYS;
1329}
1330
David Lind6229bd2017-07-06 15:28:55 -07001331void platform_check_and_update_copp_sample_rate(void* platform __unused, snd_device_t snd_device __unused,
1332 unsigned int stream_sr __unused, int* sample_rate __unused)
Haynes Mathew Georgee5ff0fc2017-02-16 20:33:38 -08001333{
1334
1335}
1336
David Lind6229bd2017-07-06 15:28:55 -07001337int platform_send_audio_calibration_v2(void *platform __unused, struct audio_usecase *usecase __unused,
1338 int app_type __unused, int sample_rate __unused)
Haynes Mathew Georgee5ff0fc2017-02-16 20:33:38 -08001339{
1340 return -ENOSYS;
1341}
1342
1343bool platform_supports_app_type_cfg() { return false; }
1344
vivek mehtaa68fea62017-06-08 19:04:02 -07001345void platform_add_app_type(const char *uc_type __unused,
1346 const char *mode __unused,
1347 int bw __unused, int app_type __unused,
1348 int max_sr __unused) {}
Haynes Mathew Georgee5ff0fc2017-02-16 20:33:38 -08001349
vivek mehtaa68fea62017-06-08 19:04:02 -07001350int platform_get_app_type_v2(void *platform __unused,
1351 enum usecase_type_t type __unused,
1352 const char *mode __unused,
1353 int bw __unused, int sr __unused,
1354 int *app_type __unused) {
1355 return -ENOSYS;
1356}
Haynes Mathew Georgee5ff0fc2017-02-16 20:33:38 -08001357
vivek mehta90933872017-06-15 18:04:39 -07001358int platform_set_sidetone(struct audio_device *adev,
1359 snd_device_t out_snd_device,
1360 bool enable, char *str)
1361{
1362 int ret;
1363 if (out_snd_device == SND_DEVICE_OUT_USB_HEADSET ||
1364 out_snd_device == SND_DEVICE_OUT_VOICE_USB_HEADSET) {
1365 ret = audio_extn_usb_enable_sidetone(out_snd_device, enable);
1366 if (ret)
1367 ALOGI("%s: usb device %d does not support device sidetone\n",
1368 __func__, out_snd_device);
1369 } else {
1370 ALOGV("%s: sidetone out device(%d) mixer cmd = %s\n",
1371 __func__, out_snd_device, str);
1372 if (enable)
1373 audio_route_apply_and_update_path(adev->audio_route, str);
1374 else
1375 audio_route_reset_and_update_path(adev->audio_route, str);
1376 }
1377 return 0;
1378}
Haynes Mathew George96483a22017-03-28 14:52:47 -07001379
1380int platform_get_mmap_data_fd(void *platform __unused, int fe_dev __unused, int dir __unused,
1381 int *fd __unused, uint32_t *size __unused)
1382{
1383 return -ENOSYS;
1384}
Mikhail Naganov4ee6e3e2018-03-21 16:28:35 +00001385
1386bool platform_sound_trigger_usecase_needs_event(audio_usecase_t uc_id __unused)
1387{
1388 return false;
1389}
1390
1391bool platform_snd_device_has_speaker(snd_device_t dev __unused) {
1392 return false;
1393}
jiabin8962a4d2018-03-19 18:21:24 -07001394
1395bool platform_set_microphone_characteristic(void *platform __unused,
1396 struct audio_microphone_characteristic_t mic __unused) {
1397 return -ENOSYS;
1398}
1399
1400int platform_get_microphones(void *platform __unused,
1401 struct audio_microphone_characteristic_t *mic_array __unused,
1402 size_t *mic_count __unused) {
1403 return -ENOSYS;
1404}
1405
Artem Borisov0b782612018-08-20 20:59:06 +00001406bool platform_set_microphone_map(void *platform __unused, snd_device_t in_snd_device __unused,
1407 const struct mic_info *info __unused) {
1408 return false;
1409}
1410
jiabin2276a702018-05-11 09:36:38 -07001411int platform_get_active_microphones(void *platform __unused, unsigned int channels __unused,
1412 audio_usecase_t usecase __unused,
jiabin8962a4d2018-03-19 18:21:24 -07001413 struct audio_microphone_characteristic_t *mic_array __unused,
1414 size_t *mic_count __unused) {
1415 return -ENOSYS;
1416}
Haynes Mathew George65f6b432018-02-27 17:44:55 -08001417
1418int platform_set_usb_service_interval(void *platform __unused,
1419 bool playback __unused,
1420 unsigned long service_interval __unused,
1421 bool *reconfig)
1422{
1423 *reconfig = false;
1424 return 0;
1425}
1426
Eric Laurentca7724d2018-05-08 09:08:28 -07001427int platform_set_backend_cfg(const struct audio_device* adev __unused,
1428 snd_device_t snd_device __unused,
1429 const struct audio_backend_cfg *backend_cfg __unused)
Haynes Mathew George65f6b432018-02-27 17:44:55 -08001430{
1431 return -1;
1432}
Ashish Jain1c849702018-05-11 20:11:55 +05301433
1434int platform_set_acdb_metainfo_key(void *platform __unused,
1435 char *name __unused,
1436 int key __unused) {
1437 return -ENOSYS;
1438}