blob: 454221eb32df40580549d349aa89a69590b4adf1 [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>
23#include <cutils/log.h>
24#include <cutils/properties.h>
25#include <audio_hw.h>
26#include <platform_api.h>
27#include "platform.h"
28
29#define LIB_ACDB_LOADER "libacdbloader.so"
30#define LIB_CSD_CLIENT "libcsd-client.so"
31
32#define DUALMIC_CONFIG_NONE 0 /* Target does not contain 2 mics */
33#define DUALMIC_CONFIG_ENDFIRE 1
34#define DUALMIC_CONFIG_BROADSIDE 2
35
36/*
37 * This is the sysfs path for the HDMI audio data block
38 */
39#define AUDIO_DATA_BLOCK_PATH "/sys/class/graphics/fb1/audio_data_block"
sangwoo1b9f4b32013-06-21 18:22:55 -070040#define MIXER_XML_PATH "/system/etc/mixer_paths.xml"
Eric Laurentb23d5282013-05-14 15:27:20 -070041
42/*
43 * This file will have a maximum of 38 bytes:
44 *
45 * 4 bytes: number of audio blocks
46 * 4 bytes: total length of Short Audio Descriptor (SAD) blocks
47 * Maximum 10 * 3 bytes: SAD blocks
48 */
49#define MAX_SAD_BLOCKS 10
50#define SAD_BLOCK_SIZE 3
51
52/* EDID format ID for LPCM audio */
53#define EDID_FORMAT_LPCM 1
54
55struct audio_block_header
56{
57 int reserved;
58 int length;
59};
60
61
62typedef void (*acdb_deallocate_t)();
63typedef int (*acdb_init_t)();
64typedef void (*acdb_send_audio_cal_t)(int, int);
65typedef void (*acdb_send_voice_cal_t)(int, int);
66
67typedef int (*csd_client_init_t)();
68typedef int (*csd_client_deinit_t)();
69typedef int (*csd_disable_device_t)();
70typedef int (*csd_enable_device_t)(int, int, uint32_t);
71typedef int (*csd_volume_t)(int);
72typedef int (*csd_mic_mute_t)(int);
73typedef int (*csd_start_voice_t)();
74typedef int (*csd_stop_voice_t)();
75
76
77/* Audio calibration related functions */
78struct 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;
83 int dualmic_config;
Ravi Kumar Alamanda1f60cf82015-04-23 19:45:17 -070084 bool speaker_lr_swap;
Eric Laurentb23d5282013-05-14 15:27:20 -070085
86 void *acdb_handle;
87 acdb_init_t acdb_init;
88 acdb_deallocate_t acdb_deallocate;
89 acdb_send_audio_cal_t acdb_send_audio_cal;
90 acdb_send_voice_cal_t acdb_send_voice_cal;
91
92 /* CSD Client related functions for voice call */
93 void *csd_client;
94 csd_client_init_t csd_client_init;
95 csd_client_deinit_t csd_client_deinit;
96 csd_disable_device_t csd_disable_device;
97 csd_enable_device_t csd_enable_device;
98 csd_volume_t csd_volume;
99 csd_mic_mute_t csd_mic_mute;
100 csd_start_voice_t csd_start_voice;
101 csd_stop_voice_t csd_stop_voice;
102};
103
104static const int pcm_device_table[AUDIO_USECASE_MAX][2] = {
105 [USECASE_AUDIO_PLAYBACK_DEEP_BUFFER] = {0, 0},
106 [USECASE_AUDIO_PLAYBACK_LOW_LATENCY] = {14, 14},
107 [USECASE_AUDIO_PLAYBACK_MULTI_CH] = {1, 1},
108 [USECASE_AUDIO_RECORD] = {0, 0},
109 [USECASE_AUDIO_RECORD_LOW_LATENCY] = {14, 14},
110 [USECASE_VOICE_CALL] = {12, 12},
111};
112
113/* Array to store sound devices */
114static const char * const device_table[SND_DEVICE_MAX] = {
115 [SND_DEVICE_NONE] = "none",
116 /* Playback sound devices */
117 [SND_DEVICE_OUT_HANDSET] = "handset",
118 [SND_DEVICE_OUT_SPEAKER] = "speaker",
119 [SND_DEVICE_OUT_SPEAKER_REVERSE] = "speaker-reverse",
120 [SND_DEVICE_OUT_HEADPHONES] = "headphones",
121 [SND_DEVICE_OUT_SPEAKER_AND_HEADPHONES] = "speaker-and-headphones",
122 [SND_DEVICE_OUT_VOICE_SPEAKER] = "voice-speaker",
123 [SND_DEVICE_OUT_VOICE_HEADPHONES] = "voice-headphones",
124 [SND_DEVICE_OUT_HDMI] = "hdmi",
125 [SND_DEVICE_OUT_SPEAKER_AND_HDMI] = "speaker-and-hdmi",
126 [SND_DEVICE_OUT_BT_SCO] = "bt-sco-headset",
Ravi Kumar Alamanda9f306542014-04-02 15:11:49 -0700127 [SND_DEVICE_OUT_BT_SCO_WB] = "bt-sco-headset-wb",
Eric Laurentb23d5282013-05-14 15:27:20 -0700128 [SND_DEVICE_OUT_VOICE_HANDSET_TMUS] = "voice-handset-tmus",
129 [SND_DEVICE_OUT_VOICE_TTY_FULL_HEADPHONES] = "voice-tty-full-headphones",
130 [SND_DEVICE_OUT_VOICE_TTY_VCO_HEADPHONES] = "voice-tty-vco-headphones",
131 [SND_DEVICE_OUT_VOICE_TTY_HCO_HANDSET] = "voice-tty-hco-handset",
132
133 /* Capture sound devices */
134 [SND_DEVICE_IN_HANDSET_MIC] = "handset-mic",
135 [SND_DEVICE_IN_SPEAKER_MIC] = "speaker-mic",
136 [SND_DEVICE_IN_HEADSET_MIC] = "headset-mic",
137 [SND_DEVICE_IN_HANDSET_MIC_AEC] = "handset-mic",
138 [SND_DEVICE_IN_SPEAKER_MIC_AEC] = "voice-speaker-mic",
139 [SND_DEVICE_IN_HEADSET_MIC_AEC] = "headset-mic",
140 [SND_DEVICE_IN_VOICE_SPEAKER_MIC] = "voice-speaker-mic",
141 [SND_DEVICE_IN_VOICE_HEADSET_MIC] = "voice-headset-mic",
142 [SND_DEVICE_IN_HDMI_MIC] = "hdmi-mic",
143 [SND_DEVICE_IN_BT_SCO_MIC] = "bt-sco-mic",
Ravi Kumar Alamanda9f306542014-04-02 15:11:49 -0700144 [SND_DEVICE_IN_BT_SCO_MIC_WB] = "bt-sco-mic-wb",
Eric Laurentb23d5282013-05-14 15:27:20 -0700145 [SND_DEVICE_IN_CAMCORDER_MIC] = "camcorder-mic",
146 [SND_DEVICE_IN_VOICE_DMIC_EF] = "voice-dmic-ef",
147 [SND_DEVICE_IN_VOICE_DMIC_BS] = "voice-dmic-bs",
148 [SND_DEVICE_IN_VOICE_DMIC_EF_TMUS] = "voice-dmic-ef-tmus",
149 [SND_DEVICE_IN_VOICE_SPEAKER_DMIC_EF] = "voice-speaker-dmic-ef",
150 [SND_DEVICE_IN_VOICE_SPEAKER_DMIC_BS] = "voice-speaker-dmic-bs",
151 [SND_DEVICE_IN_VOICE_TTY_FULL_HEADSET_MIC] = "voice-tty-full-headset-mic",
152 [SND_DEVICE_IN_VOICE_TTY_VCO_HANDSET_MIC] = "voice-tty-vco-handset-mic",
153 [SND_DEVICE_IN_VOICE_TTY_HCO_HEADSET_MIC] = "voice-tty-hco-headset-mic",
154 [SND_DEVICE_IN_VOICE_REC_MIC] = "voice-rec-mic",
155 [SND_DEVICE_IN_VOICE_REC_DMIC_EF] = "voice-rec-dmic-ef",
156 [SND_DEVICE_IN_VOICE_REC_DMIC_BS] = "voice-rec-dmic-bs",
157 [SND_DEVICE_IN_VOICE_REC_DMIC_EF_FLUENCE] = "voice-rec-dmic-ef-fluence",
158 [SND_DEVICE_IN_VOICE_REC_DMIC_BS_FLUENCE] = "voice-rec-dmic-bs-fluence",
159};
160
161/* ACDB IDs (audio DSP path configuration IDs) for each sound device */
162static const int acdb_device_table[SND_DEVICE_MAX] = {
163 [SND_DEVICE_NONE] = -1,
164 [SND_DEVICE_OUT_HANDSET] = 7,
165 [SND_DEVICE_OUT_SPEAKER] = 14,
166 [SND_DEVICE_OUT_SPEAKER_REVERSE] = 14,
167 [SND_DEVICE_OUT_HEADPHONES] = 10,
168 [SND_DEVICE_OUT_SPEAKER_AND_HEADPHONES] = 10,
169 [SND_DEVICE_OUT_VOICE_SPEAKER] = 14,
170 [SND_DEVICE_OUT_VOICE_HEADPHONES] = 10,
171 [SND_DEVICE_OUT_HDMI] = 18,
172 [SND_DEVICE_OUT_SPEAKER_AND_HDMI] = 14,
173 [SND_DEVICE_OUT_BT_SCO] = 22,
Ravi Kumar Alamanda9f306542014-04-02 15:11:49 -0700174 [SND_DEVICE_OUT_BT_SCO_WB] = 39,
Eric Laurentb23d5282013-05-14 15:27:20 -0700175 [SND_DEVICE_OUT_VOICE_HANDSET_TMUS] = 81,
176 [SND_DEVICE_OUT_VOICE_TTY_FULL_HEADPHONES] = 17,
177 [SND_DEVICE_OUT_VOICE_TTY_VCO_HEADPHONES] = 17,
178 [SND_DEVICE_OUT_VOICE_TTY_HCO_HANDSET] = 37,
179
180 [SND_DEVICE_IN_HANDSET_MIC] = 4,
181 [SND_DEVICE_IN_SPEAKER_MIC] = 4,
182 [SND_DEVICE_IN_HEADSET_MIC] = 8,
183 [SND_DEVICE_IN_HANDSET_MIC_AEC] = 40,
184 [SND_DEVICE_IN_SPEAKER_MIC_AEC] = 42,
185 [SND_DEVICE_IN_HEADSET_MIC_AEC] = 47,
186 [SND_DEVICE_IN_VOICE_SPEAKER_MIC] = 11,
187 [SND_DEVICE_IN_VOICE_HEADSET_MIC] = 8,
188 [SND_DEVICE_IN_HDMI_MIC] = 4,
189 [SND_DEVICE_IN_BT_SCO_MIC] = 21,
Ravi Kumar Alamanda9f306542014-04-02 15:11:49 -0700190 [SND_DEVICE_IN_BT_SCO_MIC_WB] = 38,
Eric Laurentb23d5282013-05-14 15:27:20 -0700191 [SND_DEVICE_IN_CAMCORDER_MIC] = 61,
192 [SND_DEVICE_IN_VOICE_DMIC_EF] = 6,
193 [SND_DEVICE_IN_VOICE_DMIC_BS] = 5,
194 [SND_DEVICE_IN_VOICE_DMIC_EF_TMUS] = 91,
195 [SND_DEVICE_IN_VOICE_SPEAKER_DMIC_EF] = 13,
196 [SND_DEVICE_IN_VOICE_SPEAKER_DMIC_BS] = 12,
197 [SND_DEVICE_IN_VOICE_TTY_FULL_HEADSET_MIC] = 16,
198 [SND_DEVICE_IN_VOICE_TTY_VCO_HANDSET_MIC] = 36,
199 [SND_DEVICE_IN_VOICE_TTY_HCO_HEADSET_MIC] = 16,
200 [SND_DEVICE_IN_VOICE_REC_MIC] = 62,
201 /* TODO: Update with proper acdb ids */
202 [SND_DEVICE_IN_VOICE_REC_DMIC_EF] = 62,
203 [SND_DEVICE_IN_VOICE_REC_DMIC_BS] = 62,
204 [SND_DEVICE_IN_VOICE_REC_DMIC_EF_FLUENCE] = 6,
205 [SND_DEVICE_IN_VOICE_REC_DMIC_BS_FLUENCE] = 5,
206};
207
Haynes Mathew George7ff216f2013-09-11 19:51:41 -0700208#define DEEP_BUFFER_PLATFORM_DELAY (29*1000LL)
209#define LOW_LATENCY_PLATFORM_DELAY (13*1000LL)
210
Eric Laurentb23d5282013-05-14 15:27:20 -0700211static pthread_once_t check_op_once_ctl = PTHREAD_ONCE_INIT;
212static bool is_tmus = false;
213
214static void check_operator()
215{
216 char value[PROPERTY_VALUE_MAX];
217 int mccmnc;
218 property_get("gsm.sim.operator.numeric",value,"0");
219 mccmnc = atoi(value);
220 ALOGD("%s: tmus mccmnc %d", __func__, mccmnc);
221 switch(mccmnc) {
222 /* TMUS MCC(310), MNC(490, 260, 026) */
223 case 310490:
224 case 310260:
225 case 310026:
226 is_tmus = true;
227 break;
228 }
229}
230
231bool is_operator_tmus()
232{
233 pthread_once(&check_op_once_ctl, check_operator);
234 return is_tmus;
235}
236
237static int set_echo_reference(struct mixer *mixer, const char* ec_ref)
238{
239 struct mixer_ctl *ctl;
240 const char *mixer_ctl_name = "EC_REF_RX";
241
242 ctl = mixer_get_ctl_by_name(mixer, mixer_ctl_name);
243 if (!ctl) {
244 ALOGE("%s: Could not get ctl for mixer cmd - %s",
245 __func__, mixer_ctl_name);
246 return -EINVAL;
247 }
248 ALOGV("Setting EC Reference: %s", ec_ref);
249 mixer_ctl_set_enum_by_string(ctl, ec_ref);
250 return 0;
251}
252
253void *platform_init(struct audio_device *adev)
254{
255 char platform[PROPERTY_VALUE_MAX];
256 char baseband[PROPERTY_VALUE_MAX];
257 char value[PROPERTY_VALUE_MAX];
258 struct platform_data *my_data;
259
sangwoo1b9f4b32013-06-21 18:22:55 -0700260 adev->mixer = mixer_open(MIXER_CARD);
261
262 if (!adev->mixer) {
263 ALOGE("Unable to open the mixer, aborting.");
264 return NULL;
265 }
266
267 adev->audio_route = audio_route_init(MIXER_CARD, MIXER_XML_PATH);
268 if (!adev->audio_route) {
269 ALOGE("%s: Failed to init audio route controls, aborting.", __func__);
270 return NULL;
271 }
272
Eric Laurentb23d5282013-05-14 15:27:20 -0700273 my_data = calloc(1, sizeof(struct platform_data));
274
275 my_data->adev = adev;
276 my_data->dualmic_config = DUALMIC_CONFIG_NONE;
277 my_data->fluence_in_spkr_mode = false;
278 my_data->fluence_in_voice_call = false;
279 my_data->fluence_in_voice_rec = false;
280
281 property_get("persist.audio.dualmic.config",value,"");
282 if (!strcmp("broadside", value)) {
283 my_data->dualmic_config = DUALMIC_CONFIG_BROADSIDE;
284 adev->acdb_settings |= DMIC_FLAG;
285 } else if (!strcmp("endfire", value)) {
286 my_data->dualmic_config = DUALMIC_CONFIG_ENDFIRE;
287 adev->acdb_settings |= DMIC_FLAG;
288 }
289
290 if (my_data->dualmic_config != DUALMIC_CONFIG_NONE) {
291 property_get("persist.audio.fluence.voicecall",value,"");
292 if (!strcmp("true", value)) {
293 my_data->fluence_in_voice_call = true;
294 }
295
296 property_get("persist.audio.fluence.voicerec",value,"");
297 if (!strcmp("true", value)) {
298 my_data->fluence_in_voice_rec = true;
299 }
300
301 property_get("persist.audio.fluence.speaker",value,"");
302 if (!strcmp("true", value)) {
303 my_data->fluence_in_spkr_mode = true;
304 }
305 }
306
307 my_data->acdb_handle = dlopen(LIB_ACDB_LOADER, RTLD_NOW);
308 if (my_data->acdb_handle == NULL) {
309 ALOGE("%s: DLOPEN failed for %s", __func__, LIB_ACDB_LOADER);
310 } else {
311 ALOGV("%s: DLOPEN successful for %s", __func__, LIB_ACDB_LOADER);
312 my_data->acdb_deallocate = (acdb_deallocate_t)dlsym(my_data->acdb_handle,
313 "acdb_loader_deallocate_ACDB");
314 my_data->acdb_send_audio_cal = (acdb_send_audio_cal_t)dlsym(my_data->acdb_handle,
315 "acdb_loader_send_audio_cal");
316 if (!my_data->acdb_send_audio_cal)
317 ALOGW("%s: Could not find the symbol acdb_send_audio_cal from %s",
318 __func__, LIB_ACDB_LOADER);
319 my_data->acdb_send_voice_cal = (acdb_send_voice_cal_t)dlsym(my_data->acdb_handle,
320 "acdb_loader_send_voice_cal");
321 my_data->acdb_init = (acdb_init_t)dlsym(my_data->acdb_handle,
322 "acdb_loader_init_ACDB");
323 if (my_data->acdb_init == NULL)
324 ALOGE("%s: dlsym error %s for acdb_loader_init_ACDB", __func__, dlerror());
325 else
326 my_data->acdb_init();
327 }
328
329 /* If platform is Fusion3, load CSD Client specific symbols
330 * Voice call is handled by MDM and apps processor talks to
331 * MDM through CSD Client
332 */
333 property_get("ro.board.platform", platform, "");
334 property_get("ro.baseband", baseband, "");
335 if (!strcmp("msm8960", platform) && !strcmp("mdm", baseband)) {
336 my_data->csd_client = dlopen(LIB_CSD_CLIENT, RTLD_NOW);
337 if (my_data->csd_client == NULL)
338 ALOGE("%s: DLOPEN failed for %s", __func__, LIB_CSD_CLIENT);
339 }
340
341 if (my_data->csd_client) {
342 ALOGV("%s: DLOPEN successful for %s", __func__, LIB_CSD_CLIENT);
343 my_data->csd_client_deinit = (csd_client_deinit_t)dlsym(my_data->csd_client,
344 "csd_client_deinit");
345 my_data->csd_disable_device = (csd_disable_device_t)dlsym(my_data->csd_client,
346 "csd_client_disable_device");
347 my_data->csd_enable_device = (csd_enable_device_t)dlsym(my_data->csd_client,
348 "csd_client_enable_device");
349 my_data->csd_start_voice = (csd_start_voice_t)dlsym(my_data->csd_client,
350 "csd_client_start_voice");
351 my_data->csd_stop_voice = (csd_stop_voice_t)dlsym(my_data->csd_client,
352 "csd_client_stop_voice");
353 my_data->csd_volume = (csd_volume_t)dlsym(my_data->csd_client,
354 "csd_client_volume");
355 my_data->csd_mic_mute = (csd_mic_mute_t)dlsym(my_data->csd_client,
356 "csd_client_mic_mute");
357 my_data->csd_client_init = (csd_client_init_t)dlsym(my_data->csd_client,
358 "csd_client_init");
359
360 if (my_data->csd_client_init == NULL) {
361 ALOGE("%s: dlsym error %s for csd_client_init", __func__, dlerror());
362 } else {
363 my_data->csd_client_init();
364 }
365 }
366
367 return my_data;
368}
369
370void platform_deinit(void *platform)
371{
372 free(platform);
373}
374
375const char *platform_get_snd_device_name(snd_device_t snd_device)
376{
377 if (snd_device >= SND_DEVICE_MIN && snd_device < SND_DEVICE_MAX)
378 return device_table[snd_device];
379 else
Ravi Kumar Alamanda64026462014-09-15 00:08:58 -0700380 return "none";
Eric Laurentb23d5282013-05-14 15:27:20 -0700381}
382
Ravi Kumar Alamanda299760a2013-11-01 17:29:09 -0500383void platform_add_backend_name(void *platform __unused, char *mixer_path,
384 snd_device_t snd_device)
Eric Laurentb23d5282013-05-14 15:27:20 -0700385{
386 if (snd_device == SND_DEVICE_IN_BT_SCO_MIC)
387 strcat(mixer_path, " bt-sco");
388 else if(snd_device == SND_DEVICE_OUT_BT_SCO)
389 strcat(mixer_path, " bt-sco");
390 else if (snd_device == SND_DEVICE_OUT_HDMI)
391 strcat(mixer_path, " hdmi");
392 else if (snd_device == SND_DEVICE_OUT_SPEAKER_AND_HDMI)
393 strcat(mixer_path, " speaker-and-hdmi");
Ravi Kumar Alamanda9f306542014-04-02 15:11:49 -0700394 else if (snd_device == SND_DEVICE_OUT_BT_SCO_WB ||
395 snd_device == SND_DEVICE_IN_BT_SCO_MIC_WB)
396 strcat(mixer_path, " bt-sco-wb");
Eric Laurentb23d5282013-05-14 15:27:20 -0700397}
398
399int platform_get_pcm_device_id(audio_usecase_t usecase, int device_type)
400{
401 int device_id;
402 if (device_type == PCM_PLAYBACK)
403 device_id = pcm_device_table[usecase][0];
404 else
405 device_id = pcm_device_table[usecase][1];
406 return device_id;
407}
408
Haynes Mathew George98c95622014-06-20 19:14:25 -0700409int platform_get_snd_device_index(char *snd_device_index_name __unused)
Haynes Mathew George5bc18842014-06-16 16:36:20 -0700410{
411 return -ENODEV;
412}
413
Haynes Mathew George98c95622014-06-20 19:14:25 -0700414int platform_set_snd_device_acdb_id(snd_device_t snd_device __unused,
415 unsigned int acdb_id __unused)
Haynes Mathew George5bc18842014-06-16 16:36:20 -0700416{
417 return -ENODEV;
418}
419
Eric Laurentb23d5282013-05-14 15:27:20 -0700420int platform_send_audio_calibration(void *platform, snd_device_t snd_device)
421{
422 struct platform_data *my_data = (struct platform_data *)platform;
423 int acdb_dev_id, acdb_dev_type;
424
425 acdb_dev_id = acdb_device_table[snd_device];
426 if (acdb_dev_id < 0) {
427 ALOGE("%s: Could not find acdb id for device(%d)",
428 __func__, snd_device);
429 return -EINVAL;
430 }
431 if (my_data->acdb_send_audio_cal) {
Eric Laurent994a6932013-07-17 11:51:42 -0700432 ("%s: sending audio calibration for snd_device(%d) acdb_id(%d)",
Eric Laurentb23d5282013-05-14 15:27:20 -0700433 __func__, snd_device, acdb_dev_id);
434 if (snd_device >= SND_DEVICE_OUT_BEGIN &&
435 snd_device < SND_DEVICE_OUT_END)
436 acdb_dev_type = ACDB_DEV_TYPE_OUT;
437 else
438 acdb_dev_type = ACDB_DEV_TYPE_IN;
439 my_data->acdb_send_audio_cal(acdb_dev_id, acdb_dev_type);
440 }
441 return 0;
442}
443
444int platform_switch_voice_call_device_pre(void *platform)
445{
446 struct platform_data *my_data = (struct platform_data *)platform;
447 int ret = 0;
448
Ravi Kumar Alamandab09e4a02014-10-20 17:07:43 -0700449 if (my_data->csd_client != NULL &&
450 voice_is_in_call(my_data->adev)) {
Eric Laurentb23d5282013-05-14 15:27:20 -0700451 /* This must be called before disabling the mixer controls on APQ side */
452 if (my_data->csd_disable_device == NULL) {
453 ALOGE("%s: dlsym error for csd_disable_device", __func__);
454 } else {
455 ret = my_data->csd_disable_device();
456 if (ret < 0) {
457 ALOGE("%s: csd_client_disable_device, failed, error %d",
458 __func__, ret);
459 }
460 }
461 }
462 return ret;
463}
464
465int platform_switch_voice_call_device_post(void *platform,
466 snd_device_t out_snd_device,
467 snd_device_t in_snd_device)
468{
469 struct platform_data *my_data = (struct platform_data *)platform;
470 int acdb_rx_id, acdb_tx_id;
471 int ret = 0;
472
473 if (my_data->csd_client) {
474 if (my_data->csd_enable_device == NULL) {
475 ALOGE("%s: dlsym error for csd_enable_device",
476 __func__);
477 } else {
478 acdb_rx_id = acdb_device_table[out_snd_device];
479 acdb_tx_id = acdb_device_table[in_snd_device];
480
481 if (acdb_rx_id > 0 || acdb_tx_id > 0) {
482 ret = my_data->csd_enable_device(acdb_rx_id, acdb_tx_id,
483 my_data->adev->acdb_settings);
484 if (ret < 0) {
485 ALOGE("%s: csd_enable_device, failed, error %d",
486 __func__, ret);
487 }
488 } else {
489 ALOGE("%s: Incorrect ACDB IDs (rx: %d tx: %d)", __func__,
490 acdb_rx_id, acdb_tx_id);
491 }
492 }
493 }
494
495 return ret;
496}
497
Vineeta Srivastava4b89e372014-06-19 14:21:42 -0700498int platform_start_voice_call(void *platform, uint32_t vsid __unused)
Eric Laurentb23d5282013-05-14 15:27:20 -0700499{
500 struct platform_data *my_data = (struct platform_data *)platform;
501 int ret = 0;
502
503 if (my_data->csd_client) {
504 if (my_data->csd_start_voice == NULL) {
505 ALOGE("dlsym error for csd_client_start_voice");
506 ret = -ENOSYS;
507 } else {
508 ret = my_data->csd_start_voice();
509 if (ret < 0) {
510 ALOGE("%s: csd_start_voice error %d\n", __func__, ret);
511 }
512 }
513 }
514
515 return ret;
516}
517
Vineeta Srivastava4b89e372014-06-19 14:21:42 -0700518int platform_stop_voice_call(void *platform, uint32_t vsid __unused)
Eric Laurentb23d5282013-05-14 15:27:20 -0700519{
520 struct platform_data *my_data = (struct platform_data *)platform;
521 int ret = 0;
522
523 if (my_data->csd_client) {
524 if (my_data->csd_stop_voice == NULL) {
525 ALOGE("dlsym error for csd_stop_voice");
526 } else {
527 ret = my_data->csd_stop_voice();
528 if (ret < 0) {
529 ALOGE("%s: csd_stop_voice error %d\n", __func__, ret);
530 }
531 }
532 }
533
534 return ret;
535}
536
537int platform_set_voice_volume(void *platform, int volume)
538{
539 struct platform_data *my_data = (struct platform_data *)platform;
540 int ret = 0;
541
542 if (my_data->csd_client) {
543 if (my_data->csd_volume == NULL) {
544 ALOGE("%s: dlsym error for csd_volume", __func__);
545 } else {
546 ret = my_data->csd_volume(volume);
547 if (ret < 0) {
548 ALOGE("%s: csd_volume error %d", __func__, ret);
549 }
550 }
551 } else {
552 ALOGE("%s: No CSD Client present", __func__);
553 }
554
555 return ret;
556}
557
558int platform_set_mic_mute(void *platform, bool state)
559{
560 struct platform_data *my_data = (struct platform_data *)platform;
561 int ret = 0;
562
563 if (my_data->adev->mode == AUDIO_MODE_IN_CALL) {
564 if (my_data->csd_client) {
565 if (my_data->csd_mic_mute == NULL) {
566 ALOGE("%s: dlsym error for csd_mic_mute", __func__);
567 } else {
568 ret = my_data->csd_mic_mute(state);
569 if (ret < 0) {
570 ALOGE("%s: csd_mic_mute error %d", __func__, ret);
571 }
572 }
573 } else {
574 ALOGE("%s: No CSD Client present", __func__);
575 }
576 }
577
578 return ret;
579}
580
Vineeta Srivastava4b89e372014-06-19 14:21:42 -0700581int platform_set_device_mute(void *platform __unused, bool state __unused, char *dir __unused)
582{
Haynes Mathew George24ca9ad2014-06-18 15:14:18 -0700583 ALOGE("%s: Not implemented", __func__);
Vineeta Srivastava4b89e372014-06-19 14:21:42 -0700584 return -ENOSYS;
585}
586
Eric Laurentb23d5282013-05-14 15:27:20 -0700587snd_device_t platform_get_output_snd_device(void *platform, audio_devices_t devices)
588{
589 struct platform_data *my_data = (struct platform_data *)platform;
590 struct audio_device *adev = my_data->adev;
591 audio_mode_t mode = adev->mode;
592 snd_device_t snd_device = SND_DEVICE_NONE;
593
594 ALOGV("%s: enter: output devices(%#x)", __func__, devices);
595 if (devices == AUDIO_DEVICE_NONE ||
596 devices & AUDIO_DEVICE_BIT_IN) {
597 ALOGV("%s: Invalid output devices (%#x)", __func__, devices);
598 goto exit;
599 }
600
Ravi Kumar Alamandab09e4a02014-10-20 17:07:43 -0700601 if (voice_is_in_call(adev)) {
Eric Laurentb23d5282013-05-14 15:27:20 -0700602 if (devices & AUDIO_DEVICE_OUT_WIRED_HEADPHONE ||
603 devices & AUDIO_DEVICE_OUT_WIRED_HEADSET) {
Haynes Mathew George24ca9ad2014-06-18 15:14:18 -0700604 if (adev->voice.tty_mode == TTY_MODE_FULL)
Eric Laurentb23d5282013-05-14 15:27:20 -0700605 snd_device = SND_DEVICE_OUT_VOICE_TTY_FULL_HEADPHONES;
Haynes Mathew George24ca9ad2014-06-18 15:14:18 -0700606 else if (adev->voice.tty_mode == TTY_MODE_VCO)
Eric Laurentb23d5282013-05-14 15:27:20 -0700607 snd_device = SND_DEVICE_OUT_VOICE_TTY_VCO_HEADPHONES;
Haynes Mathew George24ca9ad2014-06-18 15:14:18 -0700608 else if (adev->voice.tty_mode == TTY_MODE_HCO)
Eric Laurentb23d5282013-05-14 15:27:20 -0700609 snd_device = SND_DEVICE_OUT_VOICE_TTY_HCO_HANDSET;
610 else
611 snd_device = SND_DEVICE_OUT_VOICE_HEADPHONES;
612 } else if (devices & AUDIO_DEVICE_OUT_ALL_SCO) {
Ravi Kumar Alamanda9f306542014-04-02 15:11:49 -0700613 if (adev->bt_wb_speech_enabled) {
614 snd_device = SND_DEVICE_OUT_BT_SCO_WB;
615 } else {
616 snd_device = SND_DEVICE_OUT_BT_SCO;
617 }
Eric Laurentb23d5282013-05-14 15:27:20 -0700618 } else if (devices & AUDIO_DEVICE_OUT_SPEAKER) {
619 snd_device = SND_DEVICE_OUT_VOICE_SPEAKER;
620 } else if (devices & AUDIO_DEVICE_OUT_EARPIECE) {
621 if (is_operator_tmus())
622 snd_device = SND_DEVICE_OUT_VOICE_HANDSET_TMUS;
623 else
624 snd_device = SND_DEVICE_OUT_HANDSET;
625 }
626 if (snd_device != SND_DEVICE_NONE) {
627 goto exit;
628 }
629 }
630
631 if (popcount(devices) == 2) {
632 if (devices == (AUDIO_DEVICE_OUT_WIRED_HEADPHONE |
633 AUDIO_DEVICE_OUT_SPEAKER)) {
634 snd_device = SND_DEVICE_OUT_SPEAKER_AND_HEADPHONES;
635 } else if (devices == (AUDIO_DEVICE_OUT_WIRED_HEADSET |
636 AUDIO_DEVICE_OUT_SPEAKER)) {
637 snd_device = SND_DEVICE_OUT_SPEAKER_AND_HEADPHONES;
638 } else if (devices == (AUDIO_DEVICE_OUT_AUX_DIGITAL |
639 AUDIO_DEVICE_OUT_SPEAKER)) {
640 snd_device = SND_DEVICE_OUT_SPEAKER_AND_HDMI;
641 } else {
642 ALOGE("%s: Invalid combo device(%#x)", __func__, devices);
643 goto exit;
644 }
645 if (snd_device != SND_DEVICE_NONE) {
646 goto exit;
647 }
648 }
649
650 if (popcount(devices) != 1) {
651 ALOGE("%s: Invalid output devices(%#x)", __func__, devices);
652 goto exit;
653 }
654
655 if (devices & AUDIO_DEVICE_OUT_WIRED_HEADPHONE ||
656 devices & AUDIO_DEVICE_OUT_WIRED_HEADSET) {
657 snd_device = SND_DEVICE_OUT_HEADPHONES;
658 } else if (devices & AUDIO_DEVICE_OUT_SPEAKER) {
Ravi Kumar Alamanda1f60cf82015-04-23 19:45:17 -0700659 if (my_data->speaker_lr_swap)
Eric Laurentb23d5282013-05-14 15:27:20 -0700660 snd_device = SND_DEVICE_OUT_SPEAKER_REVERSE;
661 else
662 snd_device = SND_DEVICE_OUT_SPEAKER;
663 } else if (devices & AUDIO_DEVICE_OUT_ALL_SCO) {
Ravi Kumar Alamanda9f306542014-04-02 15:11:49 -0700664 if (adev->bt_wb_speech_enabled) {
665 snd_device = SND_DEVICE_OUT_BT_SCO_WB;
666 } else {
667 snd_device = SND_DEVICE_OUT_BT_SCO;
668 }
Eric Laurentb23d5282013-05-14 15:27:20 -0700669 } else if (devices & AUDIO_DEVICE_OUT_AUX_DIGITAL) {
670 snd_device = SND_DEVICE_OUT_HDMI ;
671 } else if (devices & AUDIO_DEVICE_OUT_EARPIECE) {
672 snd_device = SND_DEVICE_OUT_HANDSET;
673 } else {
674 ALOGE("%s: Unknown device(s) %#x", __func__, devices);
675 }
676exit:
677 ALOGV("%s: exit: snd_device(%s)", __func__, device_table[snd_device]);
678 return snd_device;
679}
680
681snd_device_t platform_get_input_snd_device(void *platform, audio_devices_t out_device)
682{
683 struct platform_data *my_data = (struct platform_data *)platform;
684 struct audio_device *adev = my_data->adev;
685 audio_source_t source = (adev->active_input == NULL) ?
686 AUDIO_SOURCE_DEFAULT : adev->active_input->source;
687
688 audio_mode_t mode = adev->mode;
689 audio_devices_t in_device = ((adev->active_input == NULL) ?
690 AUDIO_DEVICE_NONE : adev->active_input->device)
691 & ~AUDIO_DEVICE_BIT_IN;
692 audio_channel_mask_t channel_mask = (adev->active_input == NULL) ?
693 AUDIO_CHANNEL_IN_MONO : adev->active_input->channel_mask;
694 snd_device_t snd_device = SND_DEVICE_NONE;
695
696 ALOGV("%s: enter: out_device(%#x) in_device(%#x)",
697 __func__, out_device, in_device);
Ravi Kumar Alamandab09e4a02014-10-20 17:07:43 -0700698 if ((out_device != AUDIO_DEVICE_NONE) && voice_is_in_call(adev)) {
Vineeta Srivastava4b89e372014-06-19 14:21:42 -0700699 if (adev->voice.tty_mode != TTY_MODE_OFF) {
Eric Laurentb23d5282013-05-14 15:27:20 -0700700 if (out_device & AUDIO_DEVICE_OUT_WIRED_HEADPHONE ||
701 out_device & AUDIO_DEVICE_OUT_WIRED_HEADSET) {
Vineeta Srivastava4b89e372014-06-19 14:21:42 -0700702 switch (adev->voice.tty_mode) {
Eric Laurentb23d5282013-05-14 15:27:20 -0700703 case TTY_MODE_FULL:
704 snd_device = SND_DEVICE_IN_VOICE_TTY_FULL_HEADSET_MIC;
705 break;
706 case TTY_MODE_VCO:
707 snd_device = SND_DEVICE_IN_VOICE_TTY_VCO_HANDSET_MIC;
708 break;
709 case TTY_MODE_HCO:
710 snd_device = SND_DEVICE_IN_VOICE_TTY_HCO_HEADSET_MIC;
711 break;
712 default:
Vineeta Srivastava4b89e372014-06-19 14:21:42 -0700713 ALOGE("%s: Invalid TTY mode (%#x)", __func__, adev->voice.tty_mode);
Eric Laurentb23d5282013-05-14 15:27:20 -0700714 }
715 goto exit;
716 }
717 }
718 if (out_device & AUDIO_DEVICE_OUT_EARPIECE ||
719 out_device & AUDIO_DEVICE_OUT_WIRED_HEADPHONE) {
720 if (my_data->fluence_in_voice_call == false) {
721 snd_device = SND_DEVICE_IN_HANDSET_MIC;
722 } else {
723 if (my_data->dualmic_config == DUALMIC_CONFIG_ENDFIRE) {
724 if (is_operator_tmus())
725 snd_device = SND_DEVICE_IN_VOICE_DMIC_EF_TMUS;
726 else
727 snd_device = SND_DEVICE_IN_VOICE_DMIC_EF;
728 } else if(my_data->dualmic_config == DUALMIC_CONFIG_BROADSIDE)
729 snd_device = SND_DEVICE_IN_VOICE_DMIC_BS;
730 else
731 snd_device = SND_DEVICE_IN_HANDSET_MIC;
732 }
733 } else if (out_device & AUDIO_DEVICE_OUT_WIRED_HEADSET) {
734 snd_device = SND_DEVICE_IN_VOICE_HEADSET_MIC;
735 } else if (out_device & AUDIO_DEVICE_OUT_ALL_SCO) {
Ravi Kumar Alamanda9f306542014-04-02 15:11:49 -0700736 if (adev->bt_wb_speech_enabled) {
737 snd_device = SND_DEVICE_IN_BT_SCO_MIC_WB;
738 } else {
739 snd_device = SND_DEVICE_IN_BT_SCO_MIC;
740 }
Eric Laurentb23d5282013-05-14 15:27:20 -0700741 } else if (out_device & AUDIO_DEVICE_OUT_SPEAKER) {
742 if (my_data->fluence_in_voice_call && my_data->fluence_in_spkr_mode &&
743 my_data->dualmic_config == DUALMIC_CONFIG_ENDFIRE) {
744 snd_device = SND_DEVICE_IN_VOICE_SPEAKER_DMIC_EF;
745 } else if (my_data->fluence_in_voice_call && my_data->fluence_in_spkr_mode &&
746 my_data->dualmic_config == DUALMIC_CONFIG_BROADSIDE) {
747 snd_device = SND_DEVICE_IN_VOICE_SPEAKER_DMIC_BS;
748 } else {
749 snd_device = SND_DEVICE_IN_VOICE_SPEAKER_MIC;
750 }
751 }
752 } else if (source == AUDIO_SOURCE_CAMCORDER) {
753 if (in_device & AUDIO_DEVICE_IN_BUILTIN_MIC ||
754 in_device & AUDIO_DEVICE_IN_BACK_MIC) {
755 snd_device = SND_DEVICE_IN_CAMCORDER_MIC;
756 }
757 } else if (source == AUDIO_SOURCE_VOICE_RECOGNITION) {
758 if (in_device & AUDIO_DEVICE_IN_BUILTIN_MIC) {
759 if (my_data->dualmic_config == DUALMIC_CONFIG_ENDFIRE) {
760 if (channel_mask == AUDIO_CHANNEL_IN_FRONT_BACK)
761 snd_device = SND_DEVICE_IN_VOICE_REC_DMIC_EF;
762 else if (my_data->fluence_in_voice_rec)
763 snd_device = SND_DEVICE_IN_VOICE_REC_DMIC_EF_FLUENCE;
764 } else if (my_data->dualmic_config == DUALMIC_CONFIG_BROADSIDE) {
765 if (channel_mask == AUDIO_CHANNEL_IN_FRONT_BACK)
766 snd_device = SND_DEVICE_IN_VOICE_REC_DMIC_BS;
767 else if (my_data->fluence_in_voice_rec)
768 snd_device = SND_DEVICE_IN_VOICE_REC_DMIC_BS_FLUENCE;
769 }
770
771 if (snd_device == SND_DEVICE_NONE) {
772 snd_device = SND_DEVICE_IN_VOICE_REC_MIC;
773 }
774 }
775 } else if (source == AUDIO_SOURCE_VOICE_COMMUNICATION) {
776 if (out_device & AUDIO_DEVICE_OUT_SPEAKER)
777 in_device = AUDIO_DEVICE_IN_BACK_MIC;
778 if (adev->active_input) {
779 if (adev->active_input->enable_aec) {
780 if (in_device & AUDIO_DEVICE_IN_BACK_MIC) {
781 snd_device = SND_DEVICE_IN_SPEAKER_MIC_AEC;
782 } else if (in_device & AUDIO_DEVICE_IN_BUILTIN_MIC) {
783 snd_device = SND_DEVICE_IN_HANDSET_MIC_AEC;
784 } else if (in_device & AUDIO_DEVICE_IN_WIRED_HEADSET) {
785 snd_device = SND_DEVICE_IN_HEADSET_MIC_AEC;
786 }
787 set_echo_reference(adev->mixer, "SLIM_RX");
788 } else
789 set_echo_reference(adev->mixer, "NONE");
790 }
791 } else if (source == AUDIO_SOURCE_DEFAULT) {
792 goto exit;
793 }
794
795
796 if (snd_device != SND_DEVICE_NONE) {
797 goto exit;
798 }
799
800 if (in_device != AUDIO_DEVICE_NONE &&
801 !(in_device & AUDIO_DEVICE_IN_VOICE_CALL) &&
802 !(in_device & AUDIO_DEVICE_IN_COMMUNICATION)) {
803 if (in_device & AUDIO_DEVICE_IN_BUILTIN_MIC) {
804 snd_device = SND_DEVICE_IN_HANDSET_MIC;
805 } else if (in_device & AUDIO_DEVICE_IN_BACK_MIC) {
806 snd_device = SND_DEVICE_IN_SPEAKER_MIC;
807 } else if (in_device & AUDIO_DEVICE_IN_WIRED_HEADSET) {
808 snd_device = SND_DEVICE_IN_HEADSET_MIC;
809 } else if (in_device & AUDIO_DEVICE_IN_BLUETOOTH_SCO_HEADSET) {
Ravi Kumar Alamanda9f306542014-04-02 15:11:49 -0700810 if (adev->bt_wb_speech_enabled) {
811 snd_device = SND_DEVICE_IN_BT_SCO_MIC_WB;
812 } else {
813 snd_device = SND_DEVICE_IN_BT_SCO_MIC;
814 }
Eric Laurentb23d5282013-05-14 15:27:20 -0700815 } else if (in_device & AUDIO_DEVICE_IN_AUX_DIGITAL) {
816 snd_device = SND_DEVICE_IN_HDMI_MIC;
817 } else {
818 ALOGE("%s: Unknown input device(s) %#x", __func__, in_device);
819 ALOGW("%s: Using default handset-mic", __func__);
820 snd_device = SND_DEVICE_IN_HANDSET_MIC;
821 }
822 } else {
823 if (out_device & AUDIO_DEVICE_OUT_EARPIECE) {
824 snd_device = SND_DEVICE_IN_HANDSET_MIC;
825 } else if (out_device & AUDIO_DEVICE_OUT_WIRED_HEADSET) {
826 snd_device = SND_DEVICE_IN_HEADSET_MIC;
827 } else if (out_device & AUDIO_DEVICE_OUT_SPEAKER) {
828 snd_device = SND_DEVICE_IN_SPEAKER_MIC;
829 } else if (out_device & AUDIO_DEVICE_OUT_WIRED_HEADPHONE) {
830 snd_device = SND_DEVICE_IN_HANDSET_MIC;
831 } else if (out_device & AUDIO_DEVICE_OUT_BLUETOOTH_SCO_HEADSET) {
Ravi Kumar Alamanda9f306542014-04-02 15:11:49 -0700832 if (adev->bt_wb_speech_enabled) {
833 snd_device = SND_DEVICE_IN_BT_SCO_MIC_WB;
834 } else {
835 snd_device = SND_DEVICE_IN_BT_SCO_MIC;
836 }
Eric Laurentb23d5282013-05-14 15:27:20 -0700837 } else if (out_device & AUDIO_DEVICE_OUT_AUX_DIGITAL) {
838 snd_device = SND_DEVICE_IN_HDMI_MIC;
839 } else {
840 ALOGE("%s: Unknown output device(s) %#x", __func__, out_device);
841 ALOGW("%s: Using default handset-mic", __func__);
842 snd_device = SND_DEVICE_IN_HANDSET_MIC;
843 }
844 }
845exit:
846 ALOGV("%s: exit: in_snd_device(%s)", __func__, device_table[snd_device]);
847 return snd_device;
848}
849
850int platform_set_hdmi_channels(void *platform, int channel_count)
851{
852 struct platform_data *my_data = (struct platform_data *)platform;
853 struct audio_device *adev = my_data->adev;
854 struct mixer_ctl *ctl;
855 const char *channel_cnt_str = NULL;
856 const char *mixer_ctl_name = "HDMI_RX Channels";
857 switch (channel_count) {
858 case 8:
859 channel_cnt_str = "Eight"; break;
860 case 7:
861 channel_cnt_str = "Seven"; break;
862 case 6:
863 channel_cnt_str = "Six"; break;
864 case 5:
865 channel_cnt_str = "Five"; break;
866 case 4:
867 channel_cnt_str = "Four"; break;
868 case 3:
869 channel_cnt_str = "Three"; break;
870 default:
871 channel_cnt_str = "Two"; break;
872 }
873 ctl = mixer_get_ctl_by_name(adev->mixer, mixer_ctl_name);
874 if (!ctl) {
875 ALOGE("%s: Could not get ctl for mixer cmd - %s",
876 __func__, mixer_ctl_name);
877 return -EINVAL;
878 }
879 ALOGV("HDMI channel count: %s", channel_cnt_str);
880 mixer_ctl_set_enum_by_string(ctl, channel_cnt_str);
881 return 0;
882}
883
Haynes Mathew George24ca9ad2014-06-18 15:14:18 -0700884int platform_edid_get_max_channels(void *platform __unused)
Eric Laurentb23d5282013-05-14 15:27:20 -0700885{
886 FILE *file;
887 struct audio_block_header header;
888 char block[MAX_SAD_BLOCKS * SAD_BLOCK_SIZE];
889 char *sad = block;
890 int num_audio_blocks;
891 int channel_count;
892 int max_channels = 0;
893 int i;
894
895 file = fopen(AUDIO_DATA_BLOCK_PATH, "rb");
896 if (file == NULL) {
897 ALOGE("Unable to open '%s'", AUDIO_DATA_BLOCK_PATH);
898 return 0;
899 }
900
901 /* Read audio block header */
902 fread(&header, 1, sizeof(header), file);
903
904 /* Read SAD blocks, clamping the maximum size for safety */
905 if (header.length > (int)sizeof(block))
906 header.length = (int)sizeof(block);
907 fread(&block, header.length, 1, file);
908
909 fclose(file);
910
911 /* Calculate the number of SAD blocks */
912 num_audio_blocks = header.length / SAD_BLOCK_SIZE;
913
914 for (i = 0; i < num_audio_blocks; i++) {
915 /* Only consider LPCM blocks */
916 if ((sad[0] >> 3) != EDID_FORMAT_LPCM)
917 continue;
918
919 channel_count = (sad[0] & 0x7) + 1;
920 if (channel_count > max_channels)
921 max_channels = channel_count;
922
923 /* Advance to next block */
924 sad += 3;
925 }
926
927 return max_channels;
928}
Haynes Mathew George7ff216f2013-09-11 19:51:41 -0700929
Vineeta Srivastava4b89e372014-06-19 14:21:42 -0700930int platform_set_incall_recording_session_id(void *platform __unused,
931 uint32_t session_id __unused, int rec_mode __unused)
932{
Haynes Mathew George24ca9ad2014-06-18 15:14:18 -0700933 ALOGE("%s: Not implemented", __func__);
Vineeta Srivastava4b89e372014-06-19 14:21:42 -0700934 return -ENOSYS;
935}
936
937int platform_stop_incall_recording_usecase(void *platform __unused)
938{
Haynes Mathew George24ca9ad2014-06-18 15:14:18 -0700939 ALOGE("%s: Not implemented", __func__);
Vineeta Srivastava4b89e372014-06-19 14:21:42 -0700940 return -ENOSYS;
941}
942
943int platform_start_incall_music_usecase(void *platform __unused)
944{
Haynes Mathew George24ca9ad2014-06-18 15:14:18 -0700945 ALOGE("%s: Not implemented", __func__);
Vineeta Srivastava4b89e372014-06-19 14:21:42 -0700946 return -ENOSYS;
947}
948
949int platform_stop_incall_music_usecase(void *platform __unused)
950{
Haynes Mathew George24ca9ad2014-06-18 15:14:18 -0700951 ALOGE("%s: Not implemented", __func__);
Vineeta Srivastava4b89e372014-06-19 14:21:42 -0700952 return -ENOSYS;
953}
954
Haynes Mathew George7ff216f2013-09-11 19:51:41 -0700955/* Delay in Us */
956int64_t platform_render_latency(audio_usecase_t usecase)
957{
958 switch (usecase) {
959 case USECASE_AUDIO_PLAYBACK_DEEP_BUFFER:
960 return DEEP_BUFFER_PLATFORM_DELAY;
961 case USECASE_AUDIO_PLAYBACK_LOW_LATENCY:
962 return LOW_LATENCY_PLATFORM_DELAY;
963 default:
964 return 0;
965 }
966}
Ravi Kumar Alamanda83281a92014-05-19 18:14:57 -0700967
Haynes Mathew George24ca9ad2014-06-18 15:14:18 -0700968int platform_switch_voice_call_enable_device_config(void *platform __unused,
969 snd_device_t out_snd_device __unused,
970 snd_device_t in_snd_device __unused)
Ravi Kumar Alamanda83281a92014-05-19 18:14:57 -0700971{
972 return 0;
973}
974
Haynes Mathew George24ca9ad2014-06-18 15:14:18 -0700975int platform_switch_voice_call_usecase_route_post(void *platform __unused,
976 snd_device_t out_snd_device __unused,
977 snd_device_t in_snd_device __unused)
Ravi Kumar Alamanda83281a92014-05-19 18:14:57 -0700978{
979 return 0;
980}
Haynes Mathew George24ca9ad2014-06-18 15:14:18 -0700981
982int platform_get_sample_rate(void *platform __unused, uint32_t *rate __unused)
983{
984 return -ENOSYS;
985}
Haynes Mathew George98c95622014-06-20 19:14:25 -0700986
987int platform_get_usecase_index(const char * usecase __unused)
988{
989 return -ENOSYS;
990}
991
992int platform_set_usecase_pcm_id(audio_usecase_t usecase __unused, int32_t type __unused,
993 int32_t pcm_id __unused)
994{
995 return -ENOSYS;
996}
997
998int platform_set_snd_device_backend(snd_device_t device __unused,
999 const char *backend __unused)
1000{
1001 return -ENOSYS;
1002}
Eric Laurentcefbbac2014-09-04 13:54:10 -05001003
1004void platform_set_echo_reference(struct audio_device *adev, bool enable, audio_devices_t out_device)
1005{
1006 return;
1007}
Ravi Kumar Alamanda1f60cf82015-04-23 19:45:17 -07001008
1009int platform_swap_lr_channels(struct audio_device *adev, bool swap_channels)
1010{
1011 // only update the selected device if there is active pcm playback
1012 struct audio_usecase *usecase;
1013 struct listnode *node;
1014 struct platform_data *my_data = (struct platform_data *)adev->platform;
1015 int status = 0;
1016
1017 if (my_data->speaker_lr_swap != swap_channels) {
1018 my_data->speaker_lr_swap = swap_channels;
1019
1020 list_for_each(node, &adev->usecase_list) {
1021 usecase = node_to_item(node, struct audio_usecase, list);
1022 if (usecase->type == PCM_PLAYBACK &&
1023 usecase->stream.out->devices & AUDIO_DEVICE_OUT_SPEAKER) {
1024 const char *mixer_path;
1025 if (swap_channels) {
1026 mixer_path = platform_get_snd_device_name(SND_DEVICE_OUT_SPEAKER_REVERSE);
1027 audio_route_apply_and_update_path(adev->audio_route, mixer_path);
1028 } else {
1029 mixer_path = platform_get_snd_device_name(SND_DEVICE_OUT_SPEAKER);
1030 audio_route_apply_and_update_path(adev->audio_route, mixer_path);
1031 }
1032 break;
1033 }
1034 }
1035 }
1036 return status;
1037}