platform.c revision 4b89e37ad290ef955abf8ac1d151728303311345
1b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent/*
24b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava * Copyright (C) 2013-2014 The Android Open Source Project
3b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent *
4b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent * Licensed under the Apache License, Version 2.0 (the "License");
5b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent * you may not use this file except in compliance with the License.
6b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent * You may obtain a copy of the License at
7b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent *
8b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent *      http://www.apache.org/licenses/LICENSE-2.0
9b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent *
10b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent * Unless required by applicable law or agreed to in writing, software
11b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent * distributed under the License is distributed on an "AS IS" BASIS,
12b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent * See the License for the specific language governing permissions and
14b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent * limitations under the License.
15b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent */
16b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent
17b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent#define LOG_TAG "msm8960_platform"
18b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent/*#define LOG_NDEBUG 0*/
19b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent#define LOG_NDDEBUG 0
20b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent
21b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent#include <stdlib.h>
22b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent#include <dlfcn.h>
23b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent#include <cutils/log.h>
24b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent#include <cutils/properties.h>
25b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent#include <audio_hw.h>
26b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent#include <platform_api.h>
27b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent#include "platform.h"
28b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent
29b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent#define LIB_ACDB_LOADER "libacdbloader.so"
30b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent#define LIB_CSD_CLIENT "libcsd-client.so"
31b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent
32b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent#define DUALMIC_CONFIG_NONE 0      /* Target does not contain 2 mics */
33b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent#define DUALMIC_CONFIG_ENDFIRE 1
34b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent#define DUALMIC_CONFIG_BROADSIDE 2
35b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent
36b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent/*
37b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent * This is the sysfs path for the HDMI audio data block
38b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent */
39b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent#define AUDIO_DATA_BLOCK_PATH "/sys/class/graphics/fb1/audio_data_block"
401b9f4b3708d1ed1204bdb1dec370ad2e9db7a779sangwoo#define MIXER_XML_PATH "/system/etc/mixer_paths.xml"
41b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent
42b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent/*
43b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent * This file will have a maximum of 38 bytes:
44b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent *
45b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent * 4 bytes: number of audio blocks
46b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent * 4 bytes: total length of Short Audio Descriptor (SAD) blocks
47b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent * Maximum 10 * 3 bytes: SAD blocks
48b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent */
49b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent#define MAX_SAD_BLOCKS      10
50b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent#define SAD_BLOCK_SIZE      3
51b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent
52b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent/* EDID format ID for LPCM audio */
53b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent#define EDID_FORMAT_LPCM    1
54b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent
55b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurentstruct audio_block_header
56b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent{
57b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent    int reserved;
58b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent    int length;
59b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent};
60b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent
61b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent
62b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurenttypedef void (*acdb_deallocate_t)();
63b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurenttypedef int  (*acdb_init_t)();
64b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurenttypedef void (*acdb_send_audio_cal_t)(int, int);
65b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurenttypedef void (*acdb_send_voice_cal_t)(int, int);
66b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent
67b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurenttypedef int (*csd_client_init_t)();
68b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurenttypedef int (*csd_client_deinit_t)();
69b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurenttypedef int (*csd_disable_device_t)();
70b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurenttypedef int (*csd_enable_device_t)(int, int, uint32_t);
71b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurenttypedef int (*csd_volume_t)(int);
72b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurenttypedef int (*csd_mic_mute_t)(int);
73b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurenttypedef int (*csd_start_voice_t)();
74b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurenttypedef int (*csd_stop_voice_t)();
75b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent
76b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent
77b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent/* Audio calibration related functions */
78b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurentstruct platform_data {
79b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent    struct audio_device *adev;
80b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent    bool fluence_in_spkr_mode;
81b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent    bool fluence_in_voice_call;
82b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent    bool fluence_in_voice_rec;
83b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent    int  dualmic_config;
84b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent
85b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent    void *acdb_handle;
86b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent    acdb_init_t acdb_init;
87b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent    acdb_deallocate_t acdb_deallocate;
88b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent    acdb_send_audio_cal_t acdb_send_audio_cal;
89b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent    acdb_send_voice_cal_t acdb_send_voice_cal;
90b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent
91b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent    /* CSD Client related functions for voice call */
92b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent    void *csd_client;
93b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent    csd_client_init_t csd_client_init;
94b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent    csd_client_deinit_t csd_client_deinit;
95b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent    csd_disable_device_t csd_disable_device;
96b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent    csd_enable_device_t csd_enable_device;
97b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent    csd_volume_t csd_volume;
98b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent    csd_mic_mute_t csd_mic_mute;
99b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent    csd_start_voice_t csd_start_voice;
100b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent    csd_stop_voice_t csd_stop_voice;
101b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent};
102b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent
103b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurentstatic const int pcm_device_table[AUDIO_USECASE_MAX][2] = {
104b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent    [USECASE_AUDIO_PLAYBACK_DEEP_BUFFER] = {0, 0},
105b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent    [USECASE_AUDIO_PLAYBACK_LOW_LATENCY] = {14, 14},
106b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent    [USECASE_AUDIO_PLAYBACK_MULTI_CH] = {1, 1},
107b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent    [USECASE_AUDIO_RECORD] = {0, 0},
108b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent    [USECASE_AUDIO_RECORD_LOW_LATENCY] = {14, 14},
109b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent    [USECASE_VOICE_CALL] = {12, 12},
110b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent};
111b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent
112b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent/* Array to store sound devices */
113b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurentstatic const char * const device_table[SND_DEVICE_MAX] = {
114b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent    [SND_DEVICE_NONE] = "none",
115b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent    /* Playback sound devices */
116b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent    [SND_DEVICE_OUT_HANDSET] = "handset",
117b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent    [SND_DEVICE_OUT_SPEAKER] = "speaker",
118b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent    [SND_DEVICE_OUT_SPEAKER_REVERSE] = "speaker-reverse",
119b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent    [SND_DEVICE_OUT_HEADPHONES] = "headphones",
120b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent    [SND_DEVICE_OUT_SPEAKER_AND_HEADPHONES] = "speaker-and-headphones",
121b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent    [SND_DEVICE_OUT_VOICE_SPEAKER] = "voice-speaker",
122b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent    [SND_DEVICE_OUT_VOICE_HEADPHONES] = "voice-headphones",
123b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent    [SND_DEVICE_OUT_HDMI] = "hdmi",
124b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent    [SND_DEVICE_OUT_SPEAKER_AND_HDMI] = "speaker-and-hdmi",
125b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent    [SND_DEVICE_OUT_BT_SCO] = "bt-sco-headset",
1269f3065480c81bf01d3af65bfd3da09e1fb74b520Ravi Kumar Alamanda    [SND_DEVICE_OUT_BT_SCO_WB] = "bt-sco-headset-wb",
127b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent    [SND_DEVICE_OUT_VOICE_HANDSET_TMUS] = "voice-handset-tmus",
128b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent    [SND_DEVICE_OUT_VOICE_TTY_FULL_HEADPHONES] = "voice-tty-full-headphones",
129b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent    [SND_DEVICE_OUT_VOICE_TTY_VCO_HEADPHONES] = "voice-tty-vco-headphones",
130b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent    [SND_DEVICE_OUT_VOICE_TTY_HCO_HANDSET] = "voice-tty-hco-handset",
131b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent
132b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent    /* Capture sound devices */
133b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent    [SND_DEVICE_IN_HANDSET_MIC] = "handset-mic",
134b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent    [SND_DEVICE_IN_SPEAKER_MIC] = "speaker-mic",
135b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent    [SND_DEVICE_IN_HEADSET_MIC] = "headset-mic",
136b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent    [SND_DEVICE_IN_HANDSET_MIC_AEC] = "handset-mic",
137b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent    [SND_DEVICE_IN_SPEAKER_MIC_AEC] = "voice-speaker-mic",
138b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent    [SND_DEVICE_IN_HEADSET_MIC_AEC] = "headset-mic",
139b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent    [SND_DEVICE_IN_VOICE_SPEAKER_MIC] = "voice-speaker-mic",
140b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent    [SND_DEVICE_IN_VOICE_HEADSET_MIC] = "voice-headset-mic",
141b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent    [SND_DEVICE_IN_HDMI_MIC] = "hdmi-mic",
142b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent    [SND_DEVICE_IN_BT_SCO_MIC] = "bt-sco-mic",
1439f3065480c81bf01d3af65bfd3da09e1fb74b520Ravi Kumar Alamanda    [SND_DEVICE_IN_BT_SCO_MIC_WB] = "bt-sco-mic-wb",
144b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent    [SND_DEVICE_IN_CAMCORDER_MIC] = "camcorder-mic",
145b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent    [SND_DEVICE_IN_VOICE_DMIC_EF] = "voice-dmic-ef",
146b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent    [SND_DEVICE_IN_VOICE_DMIC_BS] = "voice-dmic-bs",
147b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent    [SND_DEVICE_IN_VOICE_DMIC_EF_TMUS] = "voice-dmic-ef-tmus",
148b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent    [SND_DEVICE_IN_VOICE_SPEAKER_DMIC_EF] = "voice-speaker-dmic-ef",
149b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent    [SND_DEVICE_IN_VOICE_SPEAKER_DMIC_BS] = "voice-speaker-dmic-bs",
150b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent    [SND_DEVICE_IN_VOICE_TTY_FULL_HEADSET_MIC] = "voice-tty-full-headset-mic",
151b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent    [SND_DEVICE_IN_VOICE_TTY_VCO_HANDSET_MIC] = "voice-tty-vco-handset-mic",
152b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent    [SND_DEVICE_IN_VOICE_TTY_HCO_HEADSET_MIC] = "voice-tty-hco-headset-mic",
153b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent    [SND_DEVICE_IN_VOICE_REC_MIC] = "voice-rec-mic",
154b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent    [SND_DEVICE_IN_VOICE_REC_DMIC_EF] = "voice-rec-dmic-ef",
155b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent    [SND_DEVICE_IN_VOICE_REC_DMIC_BS] = "voice-rec-dmic-bs",
156b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent    [SND_DEVICE_IN_VOICE_REC_DMIC_EF_FLUENCE] = "voice-rec-dmic-ef-fluence",
157b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent    [SND_DEVICE_IN_VOICE_REC_DMIC_BS_FLUENCE] = "voice-rec-dmic-bs-fluence",
158b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent};
159b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent
160b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent/* ACDB IDs (audio DSP path configuration IDs) for each sound device */
161b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurentstatic const int acdb_device_table[SND_DEVICE_MAX] = {
162b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent    [SND_DEVICE_NONE] = -1,
163b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent    [SND_DEVICE_OUT_HANDSET] = 7,
164b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent    [SND_DEVICE_OUT_SPEAKER] = 14,
165b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent    [SND_DEVICE_OUT_SPEAKER_REVERSE] = 14,
166b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent    [SND_DEVICE_OUT_HEADPHONES] = 10,
167b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent    [SND_DEVICE_OUT_SPEAKER_AND_HEADPHONES] = 10,
168b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent    [SND_DEVICE_OUT_VOICE_SPEAKER] = 14,
169b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent    [SND_DEVICE_OUT_VOICE_HEADPHONES] = 10,
170b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent    [SND_DEVICE_OUT_HDMI] = 18,
171b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent    [SND_DEVICE_OUT_SPEAKER_AND_HDMI] = 14,
172b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent    [SND_DEVICE_OUT_BT_SCO] = 22,
1739f3065480c81bf01d3af65bfd3da09e1fb74b520Ravi Kumar Alamanda    [SND_DEVICE_OUT_BT_SCO_WB] = 39,
174b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent    [SND_DEVICE_OUT_VOICE_HANDSET_TMUS] = 81,
175b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent    [SND_DEVICE_OUT_VOICE_TTY_FULL_HEADPHONES] = 17,
176b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent    [SND_DEVICE_OUT_VOICE_TTY_VCO_HEADPHONES] = 17,
177b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent    [SND_DEVICE_OUT_VOICE_TTY_HCO_HANDSET] = 37,
178b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent
179b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent    [SND_DEVICE_IN_HANDSET_MIC] = 4,
180b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent    [SND_DEVICE_IN_SPEAKER_MIC] = 4,
181b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent    [SND_DEVICE_IN_HEADSET_MIC] = 8,
182b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent    [SND_DEVICE_IN_HANDSET_MIC_AEC] = 40,
183b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent    [SND_DEVICE_IN_SPEAKER_MIC_AEC] = 42,
184b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent    [SND_DEVICE_IN_HEADSET_MIC_AEC] = 47,
185b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent    [SND_DEVICE_IN_VOICE_SPEAKER_MIC] = 11,
186b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent    [SND_DEVICE_IN_VOICE_HEADSET_MIC] = 8,
187b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent    [SND_DEVICE_IN_HDMI_MIC] = 4,
188b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent    [SND_DEVICE_IN_BT_SCO_MIC] = 21,
1899f3065480c81bf01d3af65bfd3da09e1fb74b520Ravi Kumar Alamanda    [SND_DEVICE_IN_BT_SCO_MIC_WB] = 38,
190b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent    [SND_DEVICE_IN_CAMCORDER_MIC] = 61,
191b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent    [SND_DEVICE_IN_VOICE_DMIC_EF] = 6,
192b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent    [SND_DEVICE_IN_VOICE_DMIC_BS] = 5,
193b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent    [SND_DEVICE_IN_VOICE_DMIC_EF_TMUS] = 91,
194b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent    [SND_DEVICE_IN_VOICE_SPEAKER_DMIC_EF] = 13,
195b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent    [SND_DEVICE_IN_VOICE_SPEAKER_DMIC_BS] = 12,
196b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent    [SND_DEVICE_IN_VOICE_TTY_FULL_HEADSET_MIC] = 16,
197b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent    [SND_DEVICE_IN_VOICE_TTY_VCO_HANDSET_MIC] = 36,
198b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent    [SND_DEVICE_IN_VOICE_TTY_HCO_HEADSET_MIC] = 16,
199b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent    [SND_DEVICE_IN_VOICE_REC_MIC] = 62,
200b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent    /* TODO: Update with proper acdb ids */
201b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent    [SND_DEVICE_IN_VOICE_REC_DMIC_EF] = 62,
202b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent    [SND_DEVICE_IN_VOICE_REC_DMIC_BS] = 62,
203b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent    [SND_DEVICE_IN_VOICE_REC_DMIC_EF_FLUENCE] = 6,
204b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent    [SND_DEVICE_IN_VOICE_REC_DMIC_BS_FLUENCE] = 5,
205b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent};
206b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent
2077ff216f80f6e53235b4239c6fb7da9b0d5127738Haynes Mathew George#define DEEP_BUFFER_PLATFORM_DELAY (29*1000LL)
2087ff216f80f6e53235b4239c6fb7da9b0d5127738Haynes Mathew George#define LOW_LATENCY_PLATFORM_DELAY (13*1000LL)
2097ff216f80f6e53235b4239c6fb7da9b0d5127738Haynes Mathew George
210b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurentstatic pthread_once_t check_op_once_ctl = PTHREAD_ONCE_INIT;
211b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurentstatic bool is_tmus = false;
212b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent
213b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurentstatic void check_operator()
214b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent{
215b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent    char value[PROPERTY_VALUE_MAX];
216b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent    int mccmnc;
217b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent    property_get("gsm.sim.operator.numeric",value,"0");
218b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent    mccmnc = atoi(value);
219b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent    ALOGD("%s: tmus mccmnc %d", __func__, mccmnc);
220b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent    switch(mccmnc) {
221b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent    /* TMUS MCC(310), MNC(490, 260, 026) */
222b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent    case 310490:
223b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent    case 310260:
224b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent    case 310026:
225b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent        is_tmus = true;
226b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent        break;
227b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent    }
228b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent}
229b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent
230b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurentbool is_operator_tmus()
231b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent{
232b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent    pthread_once(&check_op_once_ctl, check_operator);
233b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent    return is_tmus;
234b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent}
235b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent
236b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurentstatic int set_echo_reference(struct mixer *mixer, const char* ec_ref)
237b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent{
238b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent    struct mixer_ctl *ctl;
239b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent    const char *mixer_ctl_name = "EC_REF_RX";
240b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent
241b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent    ctl = mixer_get_ctl_by_name(mixer, mixer_ctl_name);
242b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent    if (!ctl) {
243b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent        ALOGE("%s: Could not get ctl for mixer cmd - %s",
244b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent              __func__, mixer_ctl_name);
245b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent        return -EINVAL;
246b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent    }
247b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent    ALOGV("Setting EC Reference: %s", ec_ref);
248b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent    mixer_ctl_set_enum_by_string(ctl, ec_ref);
249b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent    return 0;
250b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent}
251b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent
252b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurentvoid *platform_init(struct audio_device *adev)
253b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent{
254b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent    char platform[PROPERTY_VALUE_MAX];
255b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent    char baseband[PROPERTY_VALUE_MAX];
256b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent    char value[PROPERTY_VALUE_MAX];
257b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent    struct platform_data *my_data;
258b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent
2591b9f4b3708d1ed1204bdb1dec370ad2e9db7a779sangwoo    adev->mixer = mixer_open(MIXER_CARD);
2601b9f4b3708d1ed1204bdb1dec370ad2e9db7a779sangwoo
2611b9f4b3708d1ed1204bdb1dec370ad2e9db7a779sangwoo    if (!adev->mixer) {
2621b9f4b3708d1ed1204bdb1dec370ad2e9db7a779sangwoo        ALOGE("Unable to open the mixer, aborting.");
2631b9f4b3708d1ed1204bdb1dec370ad2e9db7a779sangwoo        return NULL;
2641b9f4b3708d1ed1204bdb1dec370ad2e9db7a779sangwoo    }
2651b9f4b3708d1ed1204bdb1dec370ad2e9db7a779sangwoo
2661b9f4b3708d1ed1204bdb1dec370ad2e9db7a779sangwoo    adev->audio_route = audio_route_init(MIXER_CARD, MIXER_XML_PATH);
2671b9f4b3708d1ed1204bdb1dec370ad2e9db7a779sangwoo    if (!adev->audio_route) {
2681b9f4b3708d1ed1204bdb1dec370ad2e9db7a779sangwoo        ALOGE("%s: Failed to init audio route controls, aborting.", __func__);
2691b9f4b3708d1ed1204bdb1dec370ad2e9db7a779sangwoo        return NULL;
2701b9f4b3708d1ed1204bdb1dec370ad2e9db7a779sangwoo    }
2711b9f4b3708d1ed1204bdb1dec370ad2e9db7a779sangwoo
272b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent    my_data = calloc(1, sizeof(struct platform_data));
273b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent
274b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent    my_data->adev = adev;
275b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent    my_data->dualmic_config = DUALMIC_CONFIG_NONE;
276b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent    my_data->fluence_in_spkr_mode = false;
277b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent    my_data->fluence_in_voice_call = false;
278b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent    my_data->fluence_in_voice_rec = false;
279b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent
280b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent    property_get("persist.audio.dualmic.config",value,"");
281b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent    if (!strcmp("broadside", value)) {
282b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent        my_data->dualmic_config = DUALMIC_CONFIG_BROADSIDE;
283b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent        adev->acdb_settings |= DMIC_FLAG;
284b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent    } else if (!strcmp("endfire", value)) {
285b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent        my_data->dualmic_config = DUALMIC_CONFIG_ENDFIRE;
286b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent        adev->acdb_settings |= DMIC_FLAG;
287b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent    }
288b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent
289b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent    if (my_data->dualmic_config != DUALMIC_CONFIG_NONE) {
290b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent        property_get("persist.audio.fluence.voicecall",value,"");
291b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent        if (!strcmp("true", value)) {
292b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent            my_data->fluence_in_voice_call = true;
293b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent        }
294b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent
295b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent        property_get("persist.audio.fluence.voicerec",value,"");
296b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent        if (!strcmp("true", value)) {
297b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent            my_data->fluence_in_voice_rec = true;
298b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent        }
299b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent
300b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent        property_get("persist.audio.fluence.speaker",value,"");
301b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent        if (!strcmp("true", value)) {
302b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent            my_data->fluence_in_spkr_mode = true;
303b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent        }
304b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent    }
305b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent
306b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent    my_data->acdb_handle = dlopen(LIB_ACDB_LOADER, RTLD_NOW);
307b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent    if (my_data->acdb_handle == NULL) {
308b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent        ALOGE("%s: DLOPEN failed for %s", __func__, LIB_ACDB_LOADER);
309b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent    } else {
310b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent        ALOGV("%s: DLOPEN successful for %s", __func__, LIB_ACDB_LOADER);
311b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent        my_data->acdb_deallocate = (acdb_deallocate_t)dlsym(my_data->acdb_handle,
312b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent                                                    "acdb_loader_deallocate_ACDB");
313b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent        my_data->acdb_send_audio_cal = (acdb_send_audio_cal_t)dlsym(my_data->acdb_handle,
314b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent                                                    "acdb_loader_send_audio_cal");
315b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent        if (!my_data->acdb_send_audio_cal)
316b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent            ALOGW("%s: Could not find the symbol acdb_send_audio_cal from %s",
317b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent                  __func__, LIB_ACDB_LOADER);
318b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent        my_data->acdb_send_voice_cal = (acdb_send_voice_cal_t)dlsym(my_data->acdb_handle,
319b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent                                                    "acdb_loader_send_voice_cal");
320b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent        my_data->acdb_init = (acdb_init_t)dlsym(my_data->acdb_handle,
321b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent                                                    "acdb_loader_init_ACDB");
322b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent        if (my_data->acdb_init == NULL)
323b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent            ALOGE("%s: dlsym error %s for acdb_loader_init_ACDB", __func__, dlerror());
324b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent        else
325b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent            my_data->acdb_init();
326b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent    }
327b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent
328b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent    /* If platform is Fusion3, load CSD Client specific symbols
329b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent     * Voice call is handled by MDM and apps processor talks to
330b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent     * MDM through CSD Client
331b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent     */
332b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent    property_get("ro.board.platform", platform, "");
333b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent    property_get("ro.baseband", baseband, "");
334b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent    if (!strcmp("msm8960", platform) && !strcmp("mdm", baseband)) {
335b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent        my_data->csd_client = dlopen(LIB_CSD_CLIENT, RTLD_NOW);
336b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent        if (my_data->csd_client == NULL)
337b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent            ALOGE("%s: DLOPEN failed for %s", __func__, LIB_CSD_CLIENT);
338b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent    }
339b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent
340b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent    if (my_data->csd_client) {
341b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent        ALOGV("%s: DLOPEN successful for %s", __func__, LIB_CSD_CLIENT);
342b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent        my_data->csd_client_deinit = (csd_client_deinit_t)dlsym(my_data->csd_client,
343b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent                                                    "csd_client_deinit");
344b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent        my_data->csd_disable_device = (csd_disable_device_t)dlsym(my_data->csd_client,
345b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent                                                    "csd_client_disable_device");
346b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent        my_data->csd_enable_device = (csd_enable_device_t)dlsym(my_data->csd_client,
347b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent                                                    "csd_client_enable_device");
348b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent        my_data->csd_start_voice = (csd_start_voice_t)dlsym(my_data->csd_client,
349b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent                                                    "csd_client_start_voice");
350b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent        my_data->csd_stop_voice = (csd_stop_voice_t)dlsym(my_data->csd_client,
351b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent                                                    "csd_client_stop_voice");
352b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent        my_data->csd_volume = (csd_volume_t)dlsym(my_data->csd_client,
353b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent                                                    "csd_client_volume");
354b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent        my_data->csd_mic_mute = (csd_mic_mute_t)dlsym(my_data->csd_client,
355b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent                                                    "csd_client_mic_mute");
356b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent        my_data->csd_client_init = (csd_client_init_t)dlsym(my_data->csd_client,
357b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent                                                    "csd_client_init");
358b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent
359b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent        if (my_data->csd_client_init == NULL) {
360b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent            ALOGE("%s: dlsym error %s for csd_client_init", __func__, dlerror());
361b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent        } else {
362b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent            my_data->csd_client_init();
363b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent        }
364b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent    }
365b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent
366b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent    return my_data;
367b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent}
368b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent
369b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurentvoid platform_deinit(void *platform)
370b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent{
371b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent    free(platform);
372b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent}
373b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent
374b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurentconst char *platform_get_snd_device_name(snd_device_t snd_device)
375b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent{
376b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent    if (snd_device >= SND_DEVICE_MIN && snd_device < SND_DEVICE_MAX)
377b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent        return device_table[snd_device];
378b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent    else
379b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent        return "";
380b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent}
381b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent
382299760a41231bd0f6d9991fb189977347365c72bRavi Kumar Alamandavoid platform_add_backend_name(void *platform __unused, char *mixer_path,
383299760a41231bd0f6d9991fb189977347365c72bRavi Kumar Alamanda                               snd_device_t snd_device)
384b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent{
385b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent    if (snd_device == SND_DEVICE_IN_BT_SCO_MIC)
386b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent        strcat(mixer_path, " bt-sco");
387b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent    else if(snd_device == SND_DEVICE_OUT_BT_SCO)
388b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent        strcat(mixer_path, " bt-sco");
389b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent    else if (snd_device == SND_DEVICE_OUT_HDMI)
390b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent        strcat(mixer_path, " hdmi");
391b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent    else if (snd_device == SND_DEVICE_OUT_SPEAKER_AND_HDMI)
392b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent        strcat(mixer_path, " speaker-and-hdmi");
3939f3065480c81bf01d3af65bfd3da09e1fb74b520Ravi Kumar Alamanda    else if (snd_device == SND_DEVICE_OUT_BT_SCO_WB ||
3949f3065480c81bf01d3af65bfd3da09e1fb74b520Ravi Kumar Alamanda             snd_device == SND_DEVICE_IN_BT_SCO_MIC_WB)
3959f3065480c81bf01d3af65bfd3da09e1fb74b520Ravi Kumar Alamanda        strcat(mixer_path, " bt-sco-wb");
396b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent}
397b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent
398b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurentint platform_get_pcm_device_id(audio_usecase_t usecase, int device_type)
399b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent{
400b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent    int device_id;
401b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent    if (device_type == PCM_PLAYBACK)
402b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent        device_id = pcm_device_table[usecase][0];
403b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent    else
404b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent        device_id = pcm_device_table[usecase][1];
405b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent    return device_id;
406b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent}
407b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent
408b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurentint platform_send_audio_calibration(void *platform, snd_device_t snd_device)
409b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent{
410b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent    struct platform_data *my_data = (struct platform_data *)platform;
411b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent    int acdb_dev_id, acdb_dev_type;
412b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent
413b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent    acdb_dev_id = acdb_device_table[snd_device];
414b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent    if (acdb_dev_id < 0) {
415b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent        ALOGE("%s: Could not find acdb id for device(%d)",
416b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent              __func__, snd_device);
417b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent        return -EINVAL;
418b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent    }
419b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent    if (my_data->acdb_send_audio_cal) {
420994a693158202488516c48c22534ae2035b5c8faEric Laurent        ("%s: sending audio calibration for snd_device(%d) acdb_id(%d)",
421b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent              __func__, snd_device, acdb_dev_id);
422b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent        if (snd_device >= SND_DEVICE_OUT_BEGIN &&
423b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent                snd_device < SND_DEVICE_OUT_END)
424b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent            acdb_dev_type = ACDB_DEV_TYPE_OUT;
425b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent        else
426b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent            acdb_dev_type = ACDB_DEV_TYPE_IN;
427b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent        my_data->acdb_send_audio_cal(acdb_dev_id, acdb_dev_type);
428b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent    }
429b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent    return 0;
430b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent}
431b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent
432b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurentint platform_switch_voice_call_device_pre(void *platform)
433b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent{
434b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent    struct platform_data *my_data = (struct platform_data *)platform;
435b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent    int ret = 0;
436b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent
437b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent    if (my_data->csd_client != NULL) {
438b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent        /* This must be called before disabling the mixer controls on APQ side */
439b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent        if (my_data->csd_disable_device == NULL) {
440b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent            ALOGE("%s: dlsym error for csd_disable_device", __func__);
441b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent        } else {
442b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent            ret = my_data->csd_disable_device();
443b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent            if (ret < 0) {
444b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent                ALOGE("%s: csd_client_disable_device, failed, error %d",
445b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent                      __func__, ret);
446b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent            }
447b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent        }
448b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent    }
449b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent    return ret;
450b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent}
451b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent
452b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurentint platform_switch_voice_call_device_post(void *platform,
453b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent                                           snd_device_t out_snd_device,
454b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent                                           snd_device_t in_snd_device)
455b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent{
456b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent    struct platform_data *my_data = (struct platform_data *)platform;
457b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent    int acdb_rx_id, acdb_tx_id;
458b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent    int ret = 0;
459b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent
460b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent    if (my_data->csd_client) {
461b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent        if (my_data->csd_enable_device == NULL) {
462b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent            ALOGE("%s: dlsym error for csd_enable_device",
463b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent                  __func__);
464b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent        } else {
465b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent            acdb_rx_id = acdb_device_table[out_snd_device];
466b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent            acdb_tx_id = acdb_device_table[in_snd_device];
467b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent
468b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent            if (acdb_rx_id > 0 || acdb_tx_id > 0) {
469b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent                ret = my_data->csd_enable_device(acdb_rx_id, acdb_tx_id,
470b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent                                                    my_data->adev->acdb_settings);
471b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent                if (ret < 0) {
472b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent                    ALOGE("%s: csd_enable_device, failed, error %d",
473b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent                          __func__, ret);
474b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent                }
475b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent            } else {
476b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent                ALOGE("%s: Incorrect ACDB IDs (rx: %d tx: %d)", __func__,
477b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent                      acdb_rx_id, acdb_tx_id);
478b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent            }
479b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent        }
480b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent    }
481b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent
482b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent    return ret;
483b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent}
484b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent
4854b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastavaint platform_start_voice_call(void *platform, uint32_t vsid __unused)
486b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent{
487b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent    struct platform_data *my_data = (struct platform_data *)platform;
488b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent    int ret = 0;
489b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent
490b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent    if (my_data->csd_client) {
491b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent        if (my_data->csd_start_voice == NULL) {
492b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent            ALOGE("dlsym error for csd_client_start_voice");
493b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent            ret = -ENOSYS;
494b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent        } else {
495b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent            ret = my_data->csd_start_voice();
496b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent            if (ret < 0) {
497b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent                ALOGE("%s: csd_start_voice error %d\n", __func__, ret);
498b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent            }
499b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent        }
500b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent    }
501b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent
502b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent    return ret;
503b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent}
504b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent
5054b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastavaint platform_stop_voice_call(void *platform, uint32_t vsid __unused)
506b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent{
507b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent    struct platform_data *my_data = (struct platform_data *)platform;
508b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent    int ret = 0;
509b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent
510b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent    if (my_data->csd_client) {
511b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent        if (my_data->csd_stop_voice == NULL) {
512b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent            ALOGE("dlsym error for csd_stop_voice");
513b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent        } else {
514b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent            ret = my_data->csd_stop_voice();
515b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent            if (ret < 0) {
516b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent                ALOGE("%s: csd_stop_voice error %d\n", __func__, ret);
517b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent            }
518b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent        }
519b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent    }
520b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent
521b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent    return ret;
522b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent}
523b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent
524b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurentint platform_set_voice_volume(void *platform, int volume)
525b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent{
526b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent    struct platform_data *my_data = (struct platform_data *)platform;
527b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent    int ret = 0;
528b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent
529b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent    if (my_data->csd_client) {
530b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent        if (my_data->csd_volume == NULL) {
531b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent            ALOGE("%s: dlsym error for csd_volume", __func__);
532b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent        } else {
533b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent            ret = my_data->csd_volume(volume);
534b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent            if (ret < 0) {
535b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent                ALOGE("%s: csd_volume error %d", __func__, ret);
536b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent            }
537b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent        }
538b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent    } else {
539b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent        ALOGE("%s: No CSD Client present", __func__);
540b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent    }
541b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent
542b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent    return ret;
543b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent}
544b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent
545b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurentint platform_set_mic_mute(void *platform, bool state)
546b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent{
547b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent    struct platform_data *my_data = (struct platform_data *)platform;
548b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent    int ret = 0;
549b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent
550b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent    if (my_data->adev->mode == AUDIO_MODE_IN_CALL) {
551b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent        if (my_data->csd_client) {
552b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent            if (my_data->csd_mic_mute == NULL) {
553b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent                ALOGE("%s: dlsym error for csd_mic_mute", __func__);
554b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent            } else {
555b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent                ret = my_data->csd_mic_mute(state);
556b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent                if (ret < 0) {
557b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent                    ALOGE("%s: csd_mic_mute error %d", __func__, ret);
558b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent                }
559b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent            }
560b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent        } else {
561b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent            ALOGE("%s: No CSD Client present", __func__);
562b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent        }
563b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent    }
564b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent
565b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent    return ret;
566b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent}
567b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent
5684b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastavaint platform_set_device_mute(void *platform __unused, bool state __unused, char *dir __unused)
5694b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava{
5704b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava    LOGE("%s: Not implemented", __func__);
5714b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava    return -ENOSYS;
5724b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava}
5734b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava
574b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurentsnd_device_t platform_get_output_snd_device(void *platform, audio_devices_t devices)
575b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent{
576b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent    struct platform_data *my_data = (struct platform_data *)platform;
577b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent    struct audio_device *adev = my_data->adev;
578b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent    audio_mode_t mode = adev->mode;
579b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent    snd_device_t snd_device = SND_DEVICE_NONE;
580b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent
581b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent    ALOGV("%s: enter: output devices(%#x)", __func__, devices);
582b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent    if (devices == AUDIO_DEVICE_NONE ||
583b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent        devices & AUDIO_DEVICE_BIT_IN) {
584b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent        ALOGV("%s: Invalid output devices (%#x)", __func__, devices);
585b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent        goto exit;
586b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent    }
587b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent
588b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent    if (mode == AUDIO_MODE_IN_CALL) {
589b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent        if (devices & AUDIO_DEVICE_OUT_WIRED_HEADPHONE ||
590b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent            devices & AUDIO_DEVICE_OUT_WIRED_HEADSET) {
591b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent            if (adev->tty_mode == TTY_MODE_FULL)
592b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent                snd_device = SND_DEVICE_OUT_VOICE_TTY_FULL_HEADPHONES;
593b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent            else if (adev->tty_mode == TTY_MODE_VCO)
594b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent                snd_device = SND_DEVICE_OUT_VOICE_TTY_VCO_HEADPHONES;
595b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent            else if (adev->tty_mode == TTY_MODE_HCO)
596b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent                snd_device = SND_DEVICE_OUT_VOICE_TTY_HCO_HANDSET;
597b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent            else
598b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent                snd_device = SND_DEVICE_OUT_VOICE_HEADPHONES;
599b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent        } else if (devices & AUDIO_DEVICE_OUT_ALL_SCO) {
6009f3065480c81bf01d3af65bfd3da09e1fb74b520Ravi Kumar Alamanda            if (adev->bt_wb_speech_enabled) {
6019f3065480c81bf01d3af65bfd3da09e1fb74b520Ravi Kumar Alamanda                snd_device = SND_DEVICE_OUT_BT_SCO_WB;
6029f3065480c81bf01d3af65bfd3da09e1fb74b520Ravi Kumar Alamanda            } else {
6039f3065480c81bf01d3af65bfd3da09e1fb74b520Ravi Kumar Alamanda                snd_device = SND_DEVICE_OUT_BT_SCO;
6049f3065480c81bf01d3af65bfd3da09e1fb74b520Ravi Kumar Alamanda            }
605b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent        } else if (devices & AUDIO_DEVICE_OUT_SPEAKER) {
606b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent            snd_device = SND_DEVICE_OUT_VOICE_SPEAKER;
607b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent        } else if (devices & AUDIO_DEVICE_OUT_EARPIECE) {
608b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent            if (is_operator_tmus())
609b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent                snd_device = SND_DEVICE_OUT_VOICE_HANDSET_TMUS;
610b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent            else
611b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent                snd_device = SND_DEVICE_OUT_HANDSET;
612b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent        }
613b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent        if (snd_device != SND_DEVICE_NONE) {
614b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent            goto exit;
615b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent        }
616b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent    }
617b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent
618b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent    if (popcount(devices) == 2) {
619b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent        if (devices == (AUDIO_DEVICE_OUT_WIRED_HEADPHONE |
620b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent                        AUDIO_DEVICE_OUT_SPEAKER)) {
621b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent            snd_device = SND_DEVICE_OUT_SPEAKER_AND_HEADPHONES;
622b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent        } else if (devices == (AUDIO_DEVICE_OUT_WIRED_HEADSET |
623b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent                               AUDIO_DEVICE_OUT_SPEAKER)) {
624b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent            snd_device = SND_DEVICE_OUT_SPEAKER_AND_HEADPHONES;
625b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent        } else if (devices == (AUDIO_DEVICE_OUT_AUX_DIGITAL |
626b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent                               AUDIO_DEVICE_OUT_SPEAKER)) {
627b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent            snd_device = SND_DEVICE_OUT_SPEAKER_AND_HDMI;
628b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent        } else {
629b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent            ALOGE("%s: Invalid combo device(%#x)", __func__, devices);
630b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent            goto exit;
631b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent        }
632b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent        if (snd_device != SND_DEVICE_NONE) {
633b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent            goto exit;
634b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent        }
635b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent    }
636b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent
637b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent    if (popcount(devices) != 1) {
638b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent        ALOGE("%s: Invalid output devices(%#x)", __func__, devices);
639b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent        goto exit;
640b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent    }
641b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent
642b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent    if (devices & AUDIO_DEVICE_OUT_WIRED_HEADPHONE ||
643b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent        devices & AUDIO_DEVICE_OUT_WIRED_HEADSET) {
644b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent        snd_device = SND_DEVICE_OUT_HEADPHONES;
645b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent    } else if (devices & AUDIO_DEVICE_OUT_SPEAKER) {
646b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent        if (adev->speaker_lr_swap)
647b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent            snd_device = SND_DEVICE_OUT_SPEAKER_REVERSE;
648b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent        else
649b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent            snd_device = SND_DEVICE_OUT_SPEAKER;
650b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent    } else if (devices & AUDIO_DEVICE_OUT_ALL_SCO) {
6519f3065480c81bf01d3af65bfd3da09e1fb74b520Ravi Kumar Alamanda        if (adev->bt_wb_speech_enabled) {
6529f3065480c81bf01d3af65bfd3da09e1fb74b520Ravi Kumar Alamanda            snd_device = SND_DEVICE_OUT_BT_SCO_WB;
6539f3065480c81bf01d3af65bfd3da09e1fb74b520Ravi Kumar Alamanda        } else {
6549f3065480c81bf01d3af65bfd3da09e1fb74b520Ravi Kumar Alamanda            snd_device = SND_DEVICE_OUT_BT_SCO;
6559f3065480c81bf01d3af65bfd3da09e1fb74b520Ravi Kumar Alamanda        }
656b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent    } else if (devices & AUDIO_DEVICE_OUT_AUX_DIGITAL) {
657b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent        snd_device = SND_DEVICE_OUT_HDMI ;
658b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent    } else if (devices & AUDIO_DEVICE_OUT_EARPIECE) {
659b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent        snd_device = SND_DEVICE_OUT_HANDSET;
660b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent    } else {
661b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent        ALOGE("%s: Unknown device(s) %#x", __func__, devices);
662b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent    }
663b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurentexit:
664b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent    ALOGV("%s: exit: snd_device(%s)", __func__, device_table[snd_device]);
665b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent    return snd_device;
666b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent}
667b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent
668b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurentsnd_device_t platform_get_input_snd_device(void *platform, audio_devices_t out_device)
669b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent{
670b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent    struct platform_data *my_data = (struct platform_data *)platform;
671b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent    struct audio_device *adev = my_data->adev;
672b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent    audio_source_t  source = (adev->active_input == NULL) ?
673b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent                                AUDIO_SOURCE_DEFAULT : adev->active_input->source;
674b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent
675b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent    audio_mode_t    mode   = adev->mode;
676b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent    audio_devices_t in_device = ((adev->active_input == NULL) ?
677b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent                                    AUDIO_DEVICE_NONE : adev->active_input->device)
678b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent                                & ~AUDIO_DEVICE_BIT_IN;
679b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent    audio_channel_mask_t channel_mask = (adev->active_input == NULL) ?
680b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent                                AUDIO_CHANNEL_IN_MONO : adev->active_input->channel_mask;
681b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent    snd_device_t snd_device = SND_DEVICE_NONE;
682b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent
683b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent    ALOGV("%s: enter: out_device(%#x) in_device(%#x)",
684b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent          __func__, out_device, in_device);
685b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent    if (mode == AUDIO_MODE_IN_CALL) {
686b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent        if (out_device == AUDIO_DEVICE_NONE) {
687b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent            ALOGE("%s: No output device set for voice call", __func__);
688b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent            goto exit;
689b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent        }
6904b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava        if (adev->voice.tty_mode != TTY_MODE_OFF) {
691b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent            if (out_device & AUDIO_DEVICE_OUT_WIRED_HEADPHONE ||
692b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent                out_device & AUDIO_DEVICE_OUT_WIRED_HEADSET) {
6934b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava                switch (adev->voice.tty_mode) {
694b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent                case TTY_MODE_FULL:
695b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent                    snd_device = SND_DEVICE_IN_VOICE_TTY_FULL_HEADSET_MIC;
696b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent                    break;
697b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent                case TTY_MODE_VCO:
698b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent                    snd_device = SND_DEVICE_IN_VOICE_TTY_VCO_HANDSET_MIC;
699b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent                    break;
700b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent                case TTY_MODE_HCO:
701b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent                    snd_device = SND_DEVICE_IN_VOICE_TTY_HCO_HEADSET_MIC;
702b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent                    break;
703b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent                default:
7044b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava                    ALOGE("%s: Invalid TTY mode (%#x)", __func__, adev->voice.tty_mode);
705b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent                }
706b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent                goto exit;
707b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent            }
708b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent        }
709b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent        if (out_device & AUDIO_DEVICE_OUT_EARPIECE ||
710b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent            out_device & AUDIO_DEVICE_OUT_WIRED_HEADPHONE) {
711b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent            if (my_data->fluence_in_voice_call == false) {
712b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent                snd_device = SND_DEVICE_IN_HANDSET_MIC;
713b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent            } else {
714b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent                if (my_data->dualmic_config == DUALMIC_CONFIG_ENDFIRE) {
715b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent                    if (is_operator_tmus())
716b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent                        snd_device = SND_DEVICE_IN_VOICE_DMIC_EF_TMUS;
717b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent                    else
718b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent                        snd_device = SND_DEVICE_IN_VOICE_DMIC_EF;
719b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent                } else if(my_data->dualmic_config == DUALMIC_CONFIG_BROADSIDE)
720b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent                    snd_device = SND_DEVICE_IN_VOICE_DMIC_BS;
721b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent                else
722b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent                    snd_device = SND_DEVICE_IN_HANDSET_MIC;
723b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent            }
724b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent        } else if (out_device & AUDIO_DEVICE_OUT_WIRED_HEADSET) {
725b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent            snd_device = SND_DEVICE_IN_VOICE_HEADSET_MIC;
726b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent        } else if (out_device & AUDIO_DEVICE_OUT_ALL_SCO) {
7279f3065480c81bf01d3af65bfd3da09e1fb74b520Ravi Kumar Alamanda            if (adev->bt_wb_speech_enabled) {
7289f3065480c81bf01d3af65bfd3da09e1fb74b520Ravi Kumar Alamanda                snd_device = SND_DEVICE_IN_BT_SCO_MIC_WB;
7299f3065480c81bf01d3af65bfd3da09e1fb74b520Ravi Kumar Alamanda            } else {
7309f3065480c81bf01d3af65bfd3da09e1fb74b520Ravi Kumar Alamanda                snd_device = SND_DEVICE_IN_BT_SCO_MIC;
7319f3065480c81bf01d3af65bfd3da09e1fb74b520Ravi Kumar Alamanda            }
732b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent        } else if (out_device & AUDIO_DEVICE_OUT_SPEAKER) {
733b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent            if (my_data->fluence_in_voice_call && my_data->fluence_in_spkr_mode &&
734b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent                    my_data->dualmic_config == DUALMIC_CONFIG_ENDFIRE) {
735b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent                snd_device = SND_DEVICE_IN_VOICE_SPEAKER_DMIC_EF;
736b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent            } else if (my_data->fluence_in_voice_call && my_data->fluence_in_spkr_mode &&
737b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent                    my_data->dualmic_config == DUALMIC_CONFIG_BROADSIDE) {
738b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent                snd_device = SND_DEVICE_IN_VOICE_SPEAKER_DMIC_BS;
739b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent            } else {
740b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent                snd_device = SND_DEVICE_IN_VOICE_SPEAKER_MIC;
741b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent            }
742b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent        }
743b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent    } else if (source == AUDIO_SOURCE_CAMCORDER) {
744b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent        if (in_device & AUDIO_DEVICE_IN_BUILTIN_MIC ||
745b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent            in_device & AUDIO_DEVICE_IN_BACK_MIC) {
746b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent            snd_device = SND_DEVICE_IN_CAMCORDER_MIC;
747b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent        }
748b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent    } else if (source == AUDIO_SOURCE_VOICE_RECOGNITION) {
749b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent        if (in_device & AUDIO_DEVICE_IN_BUILTIN_MIC) {
750b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent            if (my_data->dualmic_config == DUALMIC_CONFIG_ENDFIRE) {
751b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent                if (channel_mask == AUDIO_CHANNEL_IN_FRONT_BACK)
752b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent                    snd_device = SND_DEVICE_IN_VOICE_REC_DMIC_EF;
753b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent                else if (my_data->fluence_in_voice_rec)
754b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent                    snd_device = SND_DEVICE_IN_VOICE_REC_DMIC_EF_FLUENCE;
755b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent            } else if (my_data->dualmic_config == DUALMIC_CONFIG_BROADSIDE) {
756b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent                if (channel_mask == AUDIO_CHANNEL_IN_FRONT_BACK)
757b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent                    snd_device = SND_DEVICE_IN_VOICE_REC_DMIC_BS;
758b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent                else if (my_data->fluence_in_voice_rec)
759b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent                    snd_device = SND_DEVICE_IN_VOICE_REC_DMIC_BS_FLUENCE;
760b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent            }
761b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent
762b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent            if (snd_device == SND_DEVICE_NONE) {
763b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent                snd_device = SND_DEVICE_IN_VOICE_REC_MIC;
764b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent            }
765b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent        }
766b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent    } else if (source == AUDIO_SOURCE_VOICE_COMMUNICATION) {
767b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent        if (out_device & AUDIO_DEVICE_OUT_SPEAKER)
768b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent            in_device = AUDIO_DEVICE_IN_BACK_MIC;
769b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent        if (adev->active_input) {
770b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent            if (adev->active_input->enable_aec) {
771b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent                if (in_device & AUDIO_DEVICE_IN_BACK_MIC) {
772b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent                    snd_device = SND_DEVICE_IN_SPEAKER_MIC_AEC;
773b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent                } else if (in_device & AUDIO_DEVICE_IN_BUILTIN_MIC) {
774b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent                    snd_device = SND_DEVICE_IN_HANDSET_MIC_AEC;
775b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent                } else if (in_device & AUDIO_DEVICE_IN_WIRED_HEADSET) {
776b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent                    snd_device = SND_DEVICE_IN_HEADSET_MIC_AEC;
777b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent                }
778b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent                set_echo_reference(adev->mixer, "SLIM_RX");
779b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent            } else
780b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent                set_echo_reference(adev->mixer, "NONE");
781b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent        }
782b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent    } else if (source == AUDIO_SOURCE_DEFAULT) {
783b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent        goto exit;
784b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent    }
785b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent
786b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent
787b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent    if (snd_device != SND_DEVICE_NONE) {
788b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent        goto exit;
789b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent    }
790b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent
791b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent    if (in_device != AUDIO_DEVICE_NONE &&
792b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent            !(in_device & AUDIO_DEVICE_IN_VOICE_CALL) &&
793b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent            !(in_device & AUDIO_DEVICE_IN_COMMUNICATION)) {
794b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent        if (in_device & AUDIO_DEVICE_IN_BUILTIN_MIC) {
795b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent            snd_device = SND_DEVICE_IN_HANDSET_MIC;
796b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent        } else if (in_device & AUDIO_DEVICE_IN_BACK_MIC) {
797b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent            snd_device = SND_DEVICE_IN_SPEAKER_MIC;
798b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent        } else if (in_device & AUDIO_DEVICE_IN_WIRED_HEADSET) {
799b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent            snd_device = SND_DEVICE_IN_HEADSET_MIC;
800b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent        } else if (in_device & AUDIO_DEVICE_IN_BLUETOOTH_SCO_HEADSET) {
8019f3065480c81bf01d3af65bfd3da09e1fb74b520Ravi Kumar Alamanda            if (adev->bt_wb_speech_enabled) {
8029f3065480c81bf01d3af65bfd3da09e1fb74b520Ravi Kumar Alamanda                snd_device = SND_DEVICE_IN_BT_SCO_MIC_WB;
8039f3065480c81bf01d3af65bfd3da09e1fb74b520Ravi Kumar Alamanda            } else {
8049f3065480c81bf01d3af65bfd3da09e1fb74b520Ravi Kumar Alamanda                snd_device = SND_DEVICE_IN_BT_SCO_MIC;
8059f3065480c81bf01d3af65bfd3da09e1fb74b520Ravi Kumar Alamanda            }
806b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent        } else if (in_device & AUDIO_DEVICE_IN_AUX_DIGITAL) {
807b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent            snd_device = SND_DEVICE_IN_HDMI_MIC;
808b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent        } else {
809b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent            ALOGE("%s: Unknown input device(s) %#x", __func__, in_device);
810b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent            ALOGW("%s: Using default handset-mic", __func__);
811b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent            snd_device = SND_DEVICE_IN_HANDSET_MIC;
812b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent        }
813b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent    } else {
814b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent        if (out_device & AUDIO_DEVICE_OUT_EARPIECE) {
815b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent            snd_device = SND_DEVICE_IN_HANDSET_MIC;
816b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent        } else if (out_device & AUDIO_DEVICE_OUT_WIRED_HEADSET) {
817b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent            snd_device = SND_DEVICE_IN_HEADSET_MIC;
818b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent        } else if (out_device & AUDIO_DEVICE_OUT_SPEAKER) {
819b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent            snd_device = SND_DEVICE_IN_SPEAKER_MIC;
820b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent        } else if (out_device & AUDIO_DEVICE_OUT_WIRED_HEADPHONE) {
821b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent            snd_device = SND_DEVICE_IN_HANDSET_MIC;
822b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent        } else if (out_device & AUDIO_DEVICE_OUT_BLUETOOTH_SCO_HEADSET) {
8239f3065480c81bf01d3af65bfd3da09e1fb74b520Ravi Kumar Alamanda            if (adev->bt_wb_speech_enabled) {
8249f3065480c81bf01d3af65bfd3da09e1fb74b520Ravi Kumar Alamanda                snd_device = SND_DEVICE_IN_BT_SCO_MIC_WB;
8259f3065480c81bf01d3af65bfd3da09e1fb74b520Ravi Kumar Alamanda            } else {
8269f3065480c81bf01d3af65bfd3da09e1fb74b520Ravi Kumar Alamanda                snd_device = SND_DEVICE_IN_BT_SCO_MIC;
8279f3065480c81bf01d3af65bfd3da09e1fb74b520Ravi Kumar Alamanda            }
828b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent        } else if (out_device & AUDIO_DEVICE_OUT_AUX_DIGITAL) {
829b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent            snd_device = SND_DEVICE_IN_HDMI_MIC;
830b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent        } else {
831b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent            ALOGE("%s: Unknown output device(s) %#x", __func__, out_device);
832b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent            ALOGW("%s: Using default handset-mic", __func__);
833b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent            snd_device = SND_DEVICE_IN_HANDSET_MIC;
834b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent        }
835b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent    }
836b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurentexit:
837b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent    ALOGV("%s: exit: in_snd_device(%s)", __func__, device_table[snd_device]);
838b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent    return snd_device;
839b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent}
840b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent
841b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurentint platform_set_hdmi_channels(void *platform,  int channel_count)
842b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent{
843b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent    struct platform_data *my_data = (struct platform_data *)platform;
844b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent    struct audio_device *adev = my_data->adev;
845b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent    struct mixer_ctl *ctl;
846b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent    const char *channel_cnt_str = NULL;
847b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent    const char *mixer_ctl_name = "HDMI_RX Channels";
848b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent    switch (channel_count) {
849b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent    case 8:
850b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent        channel_cnt_str = "Eight"; break;
851b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent    case 7:
852b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent        channel_cnt_str = "Seven"; break;
853b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent    case 6:
854b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent        channel_cnt_str = "Six"; break;
855b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent    case 5:
856b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent        channel_cnt_str = "Five"; break;
857b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent    case 4:
858b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent        channel_cnt_str = "Four"; break;
859b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent    case 3:
860b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent        channel_cnt_str = "Three"; break;
861b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent    default:
862b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent        channel_cnt_str = "Two"; break;
863b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent    }
864b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent    ctl = mixer_get_ctl_by_name(adev->mixer, mixer_ctl_name);
865b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent    if (!ctl) {
866b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent        ALOGE("%s: Could not get ctl for mixer cmd - %s",
867b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent              __func__, mixer_ctl_name);
868b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent        return -EINVAL;
869b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent    }
870b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent    ALOGV("HDMI channel count: %s", channel_cnt_str);
871b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent    mixer_ctl_set_enum_by_string(ctl, channel_cnt_str);
872b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent    return 0;
873b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent}
874b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent
87547cd4cbdb19543338d5c887e3d7bcd2513c5c3adHaynes Mathew Georgeint platform_edid_get_max_channels(void *platform)
876b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent{
877b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent    FILE *file;
878b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent    struct audio_block_header header;
879b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent    char block[MAX_SAD_BLOCKS * SAD_BLOCK_SIZE];
880b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent    char *sad = block;
881b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent    int num_audio_blocks;
882b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent    int channel_count;
883b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent    int max_channels = 0;
884b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent    int i;
885b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent
886b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent    file = fopen(AUDIO_DATA_BLOCK_PATH, "rb");
887b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent    if (file == NULL) {
888b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent        ALOGE("Unable to open '%s'", AUDIO_DATA_BLOCK_PATH);
889b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent        return 0;
890b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent    }
891b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent
892b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent    /* Read audio block header */
893b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent    fread(&header, 1, sizeof(header), file);
894b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent
895b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent    /* Read SAD blocks, clamping the maximum size for safety */
896b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent    if (header.length > (int)sizeof(block))
897b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent        header.length = (int)sizeof(block);
898b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent    fread(&block, header.length, 1, file);
899b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent
900b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent    fclose(file);
901b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent
902b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent    /* Calculate the number of SAD blocks */
903b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent    num_audio_blocks = header.length / SAD_BLOCK_SIZE;
904b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent
905b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent    for (i = 0; i < num_audio_blocks; i++) {
906b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent        /* Only consider LPCM blocks */
907b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent        if ((sad[0] >> 3) != EDID_FORMAT_LPCM)
908b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent            continue;
909b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent
910b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent        channel_count = (sad[0] & 0x7) + 1;
911b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent        if (channel_count > max_channels)
912b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent            max_channels = channel_count;
913b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent
914b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent        /* Advance to next block */
915b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent        sad += 3;
916b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent    }
917b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent
918b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent    return max_channels;
919b23d5286490ad2dc0edf919d52428fa02dc2b2dcEric Laurent}
9207ff216f80f6e53235b4239c6fb7da9b0d5127738Haynes Mathew George
9214b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastavaint platform_set_incall_recording_session_id(void *platform __unused,
9224b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava                                             uint32_t session_id __unused, int rec_mode __unused)
9234b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava{
9244b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava    LOGE("%s: Not implemented", __func__);
9254b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava    return -ENOSYS;
9264b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava}
9274b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava
9284b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastavaint platform_stop_incall_recording_usecase(void *platform __unused)
9294b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava{
9304b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava    LOGE("%s: Not implemented", __func__);
9314b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava    return -ENOSYS;
9324b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava}
9334b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava
9344b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastavaint platform_start_incall_music_usecase(void *platform __unused)
9354b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava{
9364b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava    LOGE("%s: Not implemented", __func__);
9374b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava    return -ENOSYS;
9384b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava}
9394b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava
9404b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastavaint platform_stop_incall_music_usecase(void *platform __unused)
9414b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava{
9424b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava    LOGE("%s: Not implemented", __func__);
9434b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava    return -ENOSYS;
9444b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava}
9454b89e37ad290ef955abf8ac1d151728303311345Vineeta Srivastava
9467ff216f80f6e53235b4239c6fb7da9b0d5127738Haynes Mathew George/* Delay in Us */
9477ff216f80f6e53235b4239c6fb7da9b0d5127738Haynes Mathew Georgeint64_t platform_render_latency(audio_usecase_t usecase)
9487ff216f80f6e53235b4239c6fb7da9b0d5127738Haynes Mathew George{
9497ff216f80f6e53235b4239c6fb7da9b0d5127738Haynes Mathew George    switch (usecase) {
9507ff216f80f6e53235b4239c6fb7da9b0d5127738Haynes Mathew George        case USECASE_AUDIO_PLAYBACK_DEEP_BUFFER:
9517ff216f80f6e53235b4239c6fb7da9b0d5127738Haynes Mathew George            return DEEP_BUFFER_PLATFORM_DELAY;
9527ff216f80f6e53235b4239c6fb7da9b0d5127738Haynes Mathew George        case USECASE_AUDIO_PLAYBACK_LOW_LATENCY:
9537ff216f80f6e53235b4239c6fb7da9b0d5127738Haynes Mathew George            return LOW_LATENCY_PLATFORM_DELAY;
9547ff216f80f6e53235b4239c6fb7da9b0d5127738Haynes Mathew George        default:
9557ff216f80f6e53235b4239c6fb7da9b0d5127738Haynes Mathew George            return 0;
9567ff216f80f6e53235b4239c6fb7da9b0d5127738Haynes Mathew George    }
9577ff216f80f6e53235b4239c6fb7da9b0d5127738Haynes Mathew George}
95883281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda
95983281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamandaint platform_switch_voice_call_enable_device_config(void *platform,
96083281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda                                                    snd_device_t out_snd_device,
96183281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda                                                    snd_device_t in_snd_device)
96283281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda{
96383281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda    return 0;
96483281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda}
96583281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda
96683281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamandaint platform_switch_voice_call_usecase_route_post(void *platform,
96783281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda                                                  snd_device_t out_snd_device,
96883281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda                                                  snd_device_t in_snd_device)
96983281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda{
97083281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda    return 0;
97183281a951af159ca00517f6132fab39727b293f5Ravi Kumar Alamanda}
972