blob: 691a8337435960fbef819868023edd3c424a759a [file] [log] [blame]
Eric Laurentb23d5282013-05-14 15:27:20 -07001/*
Apoorv Raghuvanshi9eaf94e2013-10-04 16:13:44 -07002 * Copyright (c) 2013, The Linux Foundation. All rights reserved.
3 * Not a Contribution.
4 *
Eric Laurentb23d5282013-05-14 15:27:20 -07005 * Copyright (C) 2013 The Android Open Source Project
6 *
7 * Licensed under the Apache License, Version 2.0 (the "License");
8 * you may not use this file except in compliance with the License.
9 * You may obtain a copy of the License at
10 *
11 * http://www.apache.org/licenses/LICENSE-2.0
12 *
13 * Unless required by applicable law or agreed to in writing, software
14 * distributed under the License is distributed on an "AS IS" BASIS,
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 * See the License for the specific language governing permissions and
17 * limitations under the License.
18 */
19
20#define LOG_TAG "msm8974_platform"
21/*#define LOG_NDEBUG 0*/
22#define LOG_NDDEBUG 0
23
24#include <stdlib.h>
25#include <dlfcn.h>
26#include <cutils/log.h>
27#include <cutils/properties.h>
Shiv Maliyappanahalli34b585f2013-10-01 15:49:05 -070028#include <cutils/str_parms.h>
Eric Laurentb23d5282013-05-14 15:27:20 -070029#include <audio_hw.h>
30#include <platform_api.h>
31#include "platform.h"
Apoorv Raghuvanshi9eaf94e2013-10-04 16:13:44 -070032#include "audio_extn.h"
Eric Laurentb23d5282013-05-14 15:27:20 -070033
Haynes Mathew George47cd4cb2013-07-19 11:58:50 -070034#define MIXER_XML_PATH "/system/etc/mixer_paths.xml"
Eric Laurentb23d5282013-05-14 15:27:20 -070035#define LIB_ACDB_LOADER "libacdbloader.so"
Haynes Mathew George47cd4cb2013-07-19 11:58:50 -070036#define AUDIO_DATA_BLOCK_MIXER_CTL "HDMI EDID"
Eric Laurentb23d5282013-05-14 15:27:20 -070037
Eric Laurentb23d5282013-05-14 15:27:20 -070038/*
Eric Laurentb23d5282013-05-14 15:27:20 -070039 * This file will have a maximum of 38 bytes:
40 *
41 * 4 bytes: number of audio blocks
42 * 4 bytes: total length of Short Audio Descriptor (SAD) blocks
43 * Maximum 10 * 3 bytes: SAD blocks
44 */
45#define MAX_SAD_BLOCKS 10
46#define SAD_BLOCK_SIZE 3
47
48/* EDID format ID for LPCM audio */
49#define EDID_FORMAT_LPCM 1
50
sangwoo1b9f4b32013-06-21 18:22:55 -070051/* Retry for delay in FW loading*/
52#define RETRY_NUMBER 10
53#define RETRY_US 500000
54
Shiv Maliyappanahalli34b585f2013-10-01 15:49:05 -070055#define SAMPLE_RATE_8KHZ 8000
56#define SAMPLE_RATE_16KHZ 16000
57
sangwoo53b2cf02013-07-25 19:18:44 -070058#define MAX_VOL_INDEX 5
59#define MIN_VOL_INDEX 0
60#define percent_to_index(val, min, max) \
Shiv Maliyappanahalli34b585f2013-10-01 15:49:05 -070061 ((val) * ((max) - (min)) * 0.01 + (min) + .5)
62
63#define AUDIO_PARAMETER_KEY_FLUENCE_TYPE "fluence"
64#define AUDIO_PARAMETER_KEY_BTSCO "bt_samplerate"
65#define AUDIO_PARAMETER_KEY_SLOWTALK "st_enable"
sangwoo53b2cf02013-07-25 19:18:44 -070066
Eric Laurentb23d5282013-05-14 15:27:20 -070067struct audio_block_header
68{
69 int reserved;
70 int length;
71};
72
73typedef void (*acdb_deallocate_t)();
74typedef int (*acdb_init_t)();
75typedef void (*acdb_send_audio_cal_t)(int, int);
76typedef void (*acdb_send_voice_cal_t)(int, int);
77
Eric Laurentb23d5282013-05-14 15:27:20 -070078struct platform_data {
79 struct audio_device *adev;
80 bool fluence_in_spkr_mode;
81 bool fluence_in_voice_call;
82 bool fluence_in_voice_rec;
Mingming Yin8e5a4f62013-10-07 15:23:41 -070083 int fluence_type;
Shiv Maliyappanahalli34b585f2013-10-01 15:49:05 -070084 int btsco_sample_rate;
85 bool slowtalk;
Eric Laurentb23d5282013-05-14 15:27:20 -070086
Ravi Kumar Alamanda48c921d2013-10-29 06:07:44 -070087 /* Audio calibration related functions */
Eric Laurentb23d5282013-05-14 15:27:20 -070088 void *acdb_handle;
89 acdb_init_t acdb_init;
90 acdb_deallocate_t acdb_deallocate;
91 acdb_send_audio_cal_t acdb_send_audio_cal;
92 acdb_send_voice_cal_t acdb_send_voice_cal;
Ravi Kumar Alamanda48c921d2013-10-29 06:07:44 -070093
94 void *hw_info;
Eric Laurentb23d5282013-05-14 15:27:20 -070095};
96
97static const int pcm_device_table[AUDIO_USECASE_MAX][2] = {
Mingming Yin8e5a4f62013-10-07 15:23:41 -070098 [USECASE_AUDIO_PLAYBACK_DEEP_BUFFER] = {DEEP_BUFFER_PCM_DEVICE,
99 DEEP_BUFFER_PCM_DEVICE},
100 [USECASE_AUDIO_PLAYBACK_LOW_LATENCY] = {LOWLATENCY_PCM_DEVICE,
Preetam Singh Ranawatde84f1a2013-11-01 14:58:16 -0700101 LOWLATENCY_PCM_DEVICE},
102 [USECASE_AUDIO_PLAYBACK_MULTI_CH] = {MULTIMEDIA2_PCM_DEVICE,
103 MULTIMEDIA2_PCM_DEVICE},
Krishnankutty Kolathappillya43f96e2013-11-01 12:17:53 -0700104 [USECASE_AUDIO_PLAYBACK_OFFLOAD] =
105 {PLAYBACK_OFFLOAD_DEVICE, PLAYBACK_OFFLOAD_DEVICE},
Shiv Maliyappanahallida107642013-10-17 11:16:13 -0700106 [USECASE_AUDIO_RECORD] = {AUDIO_RECORD_PCM_DEVICE, AUDIO_RECORD_PCM_DEVICE},
Mingming Yin8e5a4f62013-10-07 15:23:41 -0700107 [USECASE_AUDIO_RECORD_LOW_LATENCY] = {LOWLATENCY_PCM_DEVICE,
108 LOWLATENCY_PCM_DEVICE},
Preetam Singh Ranawatde84f1a2013-11-01 14:58:16 -0700109 [USECASE_AUDIO_RECORD_FM_VIRTUAL] = {MULTIMEDIA2_PCM_DEVICE,
110 MULTIMEDIA2_PCM_DEVICE},
Apoorv Raghuvanshi6e262842013-10-06 14:39:35 -0700111 [USECASE_AUDIO_PLAYBACK_FM] = {FM_PLAYBACK_PCM_DEVICE, FM_CAPTURE_PCM_DEVICE},
Shiv Maliyappanahalli34b585f2013-10-01 15:49:05 -0700112 [USECASE_VOICE_CALL] = {VOICE_CALL_PCM_DEVICE, VOICE_CALL_PCM_DEVICE},
113 [USECASE_VOICE2_CALL] = {VOICE2_CALL_PCM_DEVICE, VOICE2_CALL_PCM_DEVICE},
114 [USECASE_VOLTE_CALL] = {VOLTE_CALL_PCM_DEVICE, VOLTE_CALL_PCM_DEVICE},
115 [USECASE_QCHAT_CALL] = {QCHAT_CALL_PCM_DEVICE, QCHAT_CALL_PCM_DEVICE},
Shiv Maliyappanahallida107642013-10-17 11:16:13 -0700116 [USECASE_INCALL_REC_UPLINK] = {AUDIO_RECORD_PCM_DEVICE,
117 AUDIO_RECORD_PCM_DEVICE},
118 [USECASE_INCALL_REC_DOWNLINK] = {AUDIO_RECORD_PCM_DEVICE,
119 AUDIO_RECORD_PCM_DEVICE},
120 [USECASE_INCALL_REC_UPLINK_AND_DOWNLINK] = {AUDIO_RECORD_PCM_DEVICE,
121 AUDIO_RECORD_PCM_DEVICE},
Shiv Maliyappanahallif3b9a422013-10-22 16:38:08 -0700122 [USECASE_INCALL_MUSIC_UPLINK] = {INCALL_MUSIC_UPLINK_PCM_DEVICE,
123 INCALL_MUSIC_UPLINK_PCM_DEVICE},
124 [USECASE_INCALL_MUSIC_UPLINK2] = {INCALL_MUSIC_UPLINK2_PCM_DEVICE,
125 INCALL_MUSIC_UPLINK2_PCM_DEVICE},
Eric Laurentb23d5282013-05-14 15:27:20 -0700126};
127
128/* Array to store sound devices */
129static const char * const device_table[SND_DEVICE_MAX] = {
130 [SND_DEVICE_NONE] = "none",
131 /* Playback sound devices */
132 [SND_DEVICE_OUT_HANDSET] = "handset",
133 [SND_DEVICE_OUT_SPEAKER] = "speaker",
134 [SND_DEVICE_OUT_SPEAKER_REVERSE] = "speaker-reverse",
135 [SND_DEVICE_OUT_HEADPHONES] = "headphones",
136 [SND_DEVICE_OUT_SPEAKER_AND_HEADPHONES] = "speaker-and-headphones",
137 [SND_DEVICE_OUT_VOICE_HANDSET] = "voice-handset",
138 [SND_DEVICE_OUT_VOICE_SPEAKER] = "voice-speaker",
139 [SND_DEVICE_OUT_VOICE_HEADPHONES] = "voice-headphones",
140 [SND_DEVICE_OUT_HDMI] = "hdmi",
141 [SND_DEVICE_OUT_SPEAKER_AND_HDMI] = "speaker-and-hdmi",
142 [SND_DEVICE_OUT_BT_SCO] = "bt-sco-headset",
Shiv Maliyappanahalli34b585f2013-10-01 15:49:05 -0700143 [SND_DEVICE_OUT_BT_SCO_WB] = "bt-sco-headset-wb",
Eric Laurentb23d5282013-05-14 15:27:20 -0700144 [SND_DEVICE_OUT_VOICE_HANDSET_TMUS] = "voice-handset-tmus",
145 [SND_DEVICE_OUT_VOICE_TTY_FULL_HEADPHONES] = "voice-tty-full-headphones",
146 [SND_DEVICE_OUT_VOICE_TTY_VCO_HEADPHONES] = "voice-tty-vco-headphones",
147 [SND_DEVICE_OUT_VOICE_TTY_HCO_HANDSET] = "voice-tty-hco-handset",
Apoorv Raghuvanshi5792d4b2013-10-07 18:40:05 -0700148 [SND_DEVICE_OUT_AFE_PROXY] = "afe-proxy",
149 [SND_DEVICE_OUT_USB_HEADSET] = "usb-headphones",
150 [SND_DEVICE_OUT_SPEAKER_AND_USB_HEADSET] = "speaker-and-usb-headphones",
Apoorv Raghuvanshi6e262842013-10-06 14:39:35 -0700151 [SND_DEVICE_OUT_TRANSMISSION_FM] = "transmission-fm",
Apoorv Raghuvanshi9eaf94e2013-10-04 16:13:44 -0700152 [SND_DEVICE_OUT_ANC_HEADSET] = "anc-headphones",
153 [SND_DEVICE_OUT_ANC_FB_HEADSET] = "anc-fb-headphones",
154 [SND_DEVICE_OUT_VOICE_ANC_HEADSET] = "voice-anc-headphones",
155 [SND_DEVICE_OUT_VOICE_ANC_FB_HEADSET] = "voice-anc-fb-headphones",
156 [SND_DEVICE_OUT_SPEAKER_AND_ANC_HEADSET] = "speaker-and-anc-headphones",
157 [SND_DEVICE_OUT_ANC_HANDSET] = "anc-handset",
Eric Laurentb23d5282013-05-14 15:27:20 -0700158
159 /* Capture sound devices */
160 [SND_DEVICE_IN_HANDSET_MIC] = "handset-mic",
161 [SND_DEVICE_IN_SPEAKER_MIC] = "speaker-mic",
162 [SND_DEVICE_IN_HEADSET_MIC] = "headset-mic",
163 [SND_DEVICE_IN_HANDSET_MIC_AEC] = "handset-mic",
164 [SND_DEVICE_IN_SPEAKER_MIC_AEC] = "voice-speaker-mic",
165 [SND_DEVICE_IN_HEADSET_MIC_AEC] = "headset-mic",
166 [SND_DEVICE_IN_VOICE_SPEAKER_MIC] = "voice-speaker-mic",
167 [SND_DEVICE_IN_VOICE_HEADSET_MIC] = "voice-headset-mic",
168 [SND_DEVICE_IN_HDMI_MIC] = "hdmi-mic",
169 [SND_DEVICE_IN_BT_SCO_MIC] = "bt-sco-mic",
Shiv Maliyappanahalli34b585f2013-10-01 15:49:05 -0700170 [SND_DEVICE_IN_BT_SCO_MIC_WB] = "bt-sco-mic-wb",
Eric Laurentb23d5282013-05-14 15:27:20 -0700171 [SND_DEVICE_IN_CAMCORDER_MIC] = "camcorder-mic",
Mingming Yin8e5a4f62013-10-07 15:23:41 -0700172 [SND_DEVICE_IN_VOICE_DMIC] = "voice-dmic-ef",
173 [SND_DEVICE_IN_VOICE_DMIC_TMUS] = "voice-dmic-ef-tmus",
174 [SND_DEVICE_IN_VOICE_SPEAKER_DMIC] = "voice-speaker-dmic-ef",
Eric Laurentb23d5282013-05-14 15:27:20 -0700175 [SND_DEVICE_IN_VOICE_TTY_FULL_HEADSET_MIC] = "voice-tty-full-headset-mic",
176 [SND_DEVICE_IN_VOICE_TTY_VCO_HANDSET_MIC] = "voice-tty-vco-handset-mic",
177 [SND_DEVICE_IN_VOICE_TTY_HCO_HEADSET_MIC] = "voice-tty-hco-headset-mic",
178 [SND_DEVICE_IN_VOICE_REC_MIC] = "voice-rec-mic",
Mingming Yin8e5a4f62013-10-07 15:23:41 -0700179 [SND_DEVICE_IN_VOICE_REC_DMIC] = "voice-rec-dmic-ef",
180 [SND_DEVICE_IN_VOICE_REC_DMIC_FLUENCE] = "voice-rec-dmic-ef-fluence",
Apoorv Raghuvanshi5792d4b2013-10-07 18:40:05 -0700181 [SND_DEVICE_IN_USB_HEADSET_MIC] = "usb-headset-mic",
Apoorv Raghuvanshi6e262842013-10-06 14:39:35 -0700182 [SND_DEVICE_IN_CAPTURE_FM] = "capture-fm",
Apoorv Raghuvanshi9eaf94e2013-10-04 16:13:44 -0700183 [SND_DEVICE_IN_AANC_HANDSET_MIC] = "aanc-handset-mic",
Apoorv Raghuvanshi6178a3f2013-10-19 12:38:54 -0700184 [SND_DEVICE_IN_QUAD_MIC] = "quad-mic",
Apoorv Raghuvanshi6bd8dbf2013-10-19 18:37:52 -0700185 [SND_DEVICE_IN_HANDSET_STEREO_DMIC] = "handset-stereo-dmic-ef",
186 [SND_DEVICE_IN_SPEAKER_STEREO_DMIC] = "speaker-stereo-dmic-ef",
Eric Laurentb23d5282013-05-14 15:27:20 -0700187};
188
189/* ACDB IDs (audio DSP path configuration IDs) for each sound device */
190static const int acdb_device_table[SND_DEVICE_MAX] = {
191 [SND_DEVICE_NONE] = -1,
192 [SND_DEVICE_OUT_HANDSET] = 7,
193 [SND_DEVICE_OUT_SPEAKER] = 15,
194 [SND_DEVICE_OUT_SPEAKER_REVERSE] = 15,
195 [SND_DEVICE_OUT_HEADPHONES] = 10,
196 [SND_DEVICE_OUT_SPEAKER_AND_HEADPHONES] = 10,
197 [SND_DEVICE_OUT_VOICE_HANDSET] = 7,
198 [SND_DEVICE_OUT_VOICE_SPEAKER] = 15,
199 [SND_DEVICE_OUT_VOICE_HEADPHONES] = 10,
200 [SND_DEVICE_OUT_HDMI] = 18,
201 [SND_DEVICE_OUT_SPEAKER_AND_HDMI] = 15,
202 [SND_DEVICE_OUT_BT_SCO] = 22,
Shiv Maliyappanahalli34b585f2013-10-01 15:49:05 -0700203 [SND_DEVICE_OUT_BT_SCO_WB] = 39,
sangwooc69476f2013-07-26 16:57:26 -0700204 [SND_DEVICE_OUT_VOICE_HANDSET_TMUS] = 88,
Eric Laurentb23d5282013-05-14 15:27:20 -0700205 [SND_DEVICE_OUT_VOICE_TTY_FULL_HEADPHONES] = 17,
206 [SND_DEVICE_OUT_VOICE_TTY_VCO_HEADPHONES] = 17,
207 [SND_DEVICE_OUT_VOICE_TTY_HCO_HANDSET] = 37,
Apoorv Raghuvanshi5792d4b2013-10-07 18:40:05 -0700208 [SND_DEVICE_OUT_AFE_PROXY] = 0,
209 [SND_DEVICE_OUT_USB_HEADSET] = 0,
210 [SND_DEVICE_OUT_SPEAKER_AND_USB_HEADSET] = 14,
Apoorv Raghuvanshi6e262842013-10-06 14:39:35 -0700211 [SND_DEVICE_OUT_TRANSMISSION_FM] = 0,
Apoorv Raghuvanshi9eaf94e2013-10-04 16:13:44 -0700212 [SND_DEVICE_OUT_ANC_HEADSET] = 26,
Ravi Kumar Alamanda48c921d2013-10-29 06:07:44 -0700213 [SND_DEVICE_OUT_ANC_FB_HEADSET] = 27,
Apoorv Raghuvanshi9eaf94e2013-10-04 16:13:44 -0700214 [SND_DEVICE_OUT_VOICE_ANC_HEADSET] = 26,
Ravi Kumar Alamanda48c921d2013-10-29 06:07:44 -0700215 [SND_DEVICE_OUT_VOICE_ANC_FB_HEADSET] = 27,
Apoorv Raghuvanshi9eaf94e2013-10-04 16:13:44 -0700216 [SND_DEVICE_OUT_SPEAKER_AND_ANC_HEADSET] = 26,
217 [SND_DEVICE_OUT_ANC_HANDSET] = 103,
Eric Laurentb23d5282013-05-14 15:27:20 -0700218
219 [SND_DEVICE_IN_HANDSET_MIC] = 4,
220 [SND_DEVICE_IN_SPEAKER_MIC] = 4, /* ToDo: Check if this needs to changed to 11 */
221 [SND_DEVICE_IN_HEADSET_MIC] = 8,
222 [SND_DEVICE_IN_HANDSET_MIC_AEC] = 40,
223 [SND_DEVICE_IN_SPEAKER_MIC_AEC] = 42,
224 [SND_DEVICE_IN_HEADSET_MIC_AEC] = 47,
225 [SND_DEVICE_IN_VOICE_SPEAKER_MIC] = 11,
226 [SND_DEVICE_IN_VOICE_HEADSET_MIC] = 8,
227 [SND_DEVICE_IN_HDMI_MIC] = 4,
228 [SND_DEVICE_IN_BT_SCO_MIC] = 21,
Shiv Maliyappanahalli34b585f2013-10-01 15:49:05 -0700229 [SND_DEVICE_IN_BT_SCO_MIC_WB] = 38,
Eric Laurentb23d5282013-05-14 15:27:20 -0700230 [SND_DEVICE_IN_CAMCORDER_MIC] = 61,
Mingming Yin8e5a4f62013-10-07 15:23:41 -0700231 [SND_DEVICE_IN_VOICE_DMIC] = 41,
232 [SND_DEVICE_IN_VOICE_DMIC_TMUS] = 89,
233 [SND_DEVICE_IN_VOICE_SPEAKER_DMIC] = 43,
Eric Laurentb23d5282013-05-14 15:27:20 -0700234 [SND_DEVICE_IN_VOICE_TTY_FULL_HEADSET_MIC] = 16,
235 [SND_DEVICE_IN_VOICE_TTY_VCO_HANDSET_MIC] = 36,
236 [SND_DEVICE_IN_VOICE_TTY_HCO_HEADSET_MIC] = 16,
237 [SND_DEVICE_IN_VOICE_REC_MIC] = 62,
Apoorv Raghuvanshi5792d4b2013-10-07 18:40:05 -0700238 [SND_DEVICE_IN_USB_HEADSET_MIC] = 44,
Apoorv Raghuvanshi6e262842013-10-06 14:39:35 -0700239 [SND_DEVICE_IN_CAPTURE_FM] = 0,
Apoorv Raghuvanshi9eaf94e2013-10-04 16:13:44 -0700240 [SND_DEVICE_IN_AANC_HANDSET_MIC] = 104,
Apoorv Raghuvanshi6178a3f2013-10-19 12:38:54 -0700241 [SND_DEVICE_IN_QUAD_MIC] = 46,
Apoorv Raghuvanshi6bd8dbf2013-10-19 18:37:52 -0700242 [SND_DEVICE_IN_HANDSET_STEREO_DMIC] = 34,
243 [SND_DEVICE_IN_SPEAKER_STEREO_DMIC] = 35,
Eric Laurentb23d5282013-05-14 15:27:20 -0700244 /* TODO: Update with proper acdb ids */
Mingming Yin8e5a4f62013-10-07 15:23:41 -0700245 [SND_DEVICE_IN_VOICE_REC_DMIC] = 62,
246 [SND_DEVICE_IN_VOICE_REC_DMIC_FLUENCE] = 6,
Eric Laurentb23d5282013-05-14 15:27:20 -0700247};
248
Haynes Mathew George7ff216f2013-09-11 19:51:41 -0700249#define DEEP_BUFFER_PLATFORM_DELAY (29*1000LL)
250#define LOW_LATENCY_PLATFORM_DELAY (13*1000LL)
251
Eric Laurentb23d5282013-05-14 15:27:20 -0700252static pthread_once_t check_op_once_ctl = PTHREAD_ONCE_INIT;
253static bool is_tmus = false;
254
255static void check_operator()
256{
257 char value[PROPERTY_VALUE_MAX];
258 int mccmnc;
259 property_get("gsm.sim.operator.numeric",value,"0");
260 mccmnc = atoi(value);
261 ALOGD("%s: tmus mccmnc %d", __func__, mccmnc);
262 switch(mccmnc) {
263 /* TMUS MCC(310), MNC(490, 260, 026) */
264 case 310490:
265 case 310260:
266 case 310026:
sangwon.jeonb891db52013-09-14 17:39:15 +0900267 /* Add new TMUS MNC(800, 660, 580, 310, 270, 250, 240, 230, 220, 210, 200, 160) */
268 case 310800:
269 case 310660:
270 case 310580:
271 case 310310:
272 case 310270:
273 case 310250:
274 case 310240:
275 case 310230:
276 case 310220:
277 case 310210:
278 case 310200:
279 case 310160:
Eric Laurentb23d5282013-05-14 15:27:20 -0700280 is_tmus = true;
281 break;
282 }
283}
284
285bool is_operator_tmus()
286{
287 pthread_once(&check_op_once_ctl, check_operator);
288 return is_tmus;
289}
290
291static int set_echo_reference(struct mixer *mixer, const char* ec_ref)
292{
293 struct mixer_ctl *ctl;
294 const char *mixer_ctl_name = "EC_REF_RX";
295
296 ctl = mixer_get_ctl_by_name(mixer, mixer_ctl_name);
297 if (!ctl) {
298 ALOGE("%s: Could not get ctl for mixer cmd - %s",
299 __func__, mixer_ctl_name);
300 return -EINVAL;
301 }
302 ALOGV("Setting EC Reference: %s", ec_ref);
303 mixer_ctl_set_enum_by_string(ctl, ec_ref);
304 return 0;
305}
306
307void *platform_init(struct audio_device *adev)
308{
309 char value[PROPERTY_VALUE_MAX];
310 struct platform_data *my_data;
Ravi Kumar Alamanda48c921d2013-10-29 06:07:44 -0700311 int retry_num = 0;
312 const char *snd_card_name;
sangwoo1b9f4b32013-06-21 18:22:55 -0700313
314 adev->mixer = mixer_open(MIXER_CARD);
315
316 while (!adev->mixer && retry_num < RETRY_NUMBER) {
317 usleep(RETRY_US);
318 adev->mixer = mixer_open(MIXER_CARD);
319 retry_num++;
320 }
321
322 if (!adev->mixer) {
323 ALOGE("Unable to open the mixer, aborting.");
324 return NULL;
325 }
326
327 adev->audio_route = audio_route_init(MIXER_CARD, MIXER_XML_PATH);
328 if (!adev->audio_route) {
329 ALOGE("%s: Failed to init audio route controls, aborting.", __func__);
330 return NULL;
331 }
Eric Laurentb23d5282013-05-14 15:27:20 -0700332
333 my_data = calloc(1, sizeof(struct platform_data));
334
Ravi Kumar Alamanda48c921d2013-10-29 06:07:44 -0700335 snd_card_name = mixer_get_name(adev->mixer);
336 my_data->hw_info = hw_info_init(snd_card_name);
337 if (!my_data->hw_info) {
338 ALOGE("%s: Failed to init hardware info", __func__);
339 }
340
Eric Laurentb23d5282013-05-14 15:27:20 -0700341 my_data->adev = adev;
Shiv Maliyappanahalli34b585f2013-10-01 15:49:05 -0700342 my_data->btsco_sample_rate = SAMPLE_RATE_8KHZ;
Eric Laurentb23d5282013-05-14 15:27:20 -0700343 my_data->fluence_in_spkr_mode = false;
344 my_data->fluence_in_voice_call = false;
345 my_data->fluence_in_voice_rec = false;
Mingming Yin8e5a4f62013-10-07 15:23:41 -0700346 my_data->fluence_type = FLUENCE_NONE;
Eric Laurentb23d5282013-05-14 15:27:20 -0700347
Mingming Yin8e5a4f62013-10-07 15:23:41 -0700348 property_get("ro.qc.sdk.audio.fluencetype", value, "");
349 if (!strncmp("fluencepro", value, sizeof("fluencepro"))) {
350 my_data->fluence_type = FLUENCE_QUAD_MIC;
351 } else if (!strncmp("fluence", value, sizeof("fluence"))) {
352 my_data->fluence_type = FLUENCE_DUAL_MIC;
353 } else {
354 my_data->fluence_type = FLUENCE_NONE;
Eric Laurentb23d5282013-05-14 15:27:20 -0700355 }
356
Mingming Yin8e5a4f62013-10-07 15:23:41 -0700357 if (my_data->fluence_type != FLUENCE_NONE) {
Eric Laurentb23d5282013-05-14 15:27:20 -0700358 property_get("persist.audio.fluence.voicecall",value,"");
Mingming Yin8e5a4f62013-10-07 15:23:41 -0700359 if (!strncmp("true", value, sizeof("true"))) {
Eric Laurentb23d5282013-05-14 15:27:20 -0700360 my_data->fluence_in_voice_call = true;
361 }
362
363 property_get("persist.audio.fluence.voicerec",value,"");
Mingming Yin8e5a4f62013-10-07 15:23:41 -0700364 if (!strncmp("true", value, sizeof("true"))) {
Eric Laurentb23d5282013-05-14 15:27:20 -0700365 my_data->fluence_in_voice_rec = true;
366 }
367
368 property_get("persist.audio.fluence.speaker",value,"");
Mingming Yin8e5a4f62013-10-07 15:23:41 -0700369 if (!strncmp("true", value, sizeof("true"))) {
Eric Laurentb23d5282013-05-14 15:27:20 -0700370 my_data->fluence_in_spkr_mode = true;
371 }
372 }
373
374 my_data->acdb_handle = dlopen(LIB_ACDB_LOADER, RTLD_NOW);
375 if (my_data->acdb_handle == NULL) {
376 ALOGE("%s: DLOPEN failed for %s", __func__, LIB_ACDB_LOADER);
377 } else {
378 ALOGV("%s: DLOPEN successful for %s", __func__, LIB_ACDB_LOADER);
379 my_data->acdb_deallocate = (acdb_deallocate_t)dlsym(my_data->acdb_handle,
380 "acdb_loader_deallocate_ACDB");
381 my_data->acdb_send_audio_cal = (acdb_send_audio_cal_t)dlsym(my_data->acdb_handle,
382 "acdb_loader_send_audio_cal");
383 if (!my_data->acdb_send_audio_cal)
384 ALOGW("%s: Could not find the symbol acdb_send_audio_cal from %s",
385 __func__, LIB_ACDB_LOADER);
386 my_data->acdb_send_voice_cal = (acdb_send_voice_cal_t)dlsym(my_data->acdb_handle,
387 "acdb_loader_send_voice_cal");
388 my_data->acdb_init = (acdb_init_t)dlsym(my_data->acdb_handle,
389 "acdb_loader_init_ACDB");
390 if (my_data->acdb_init == NULL)
391 ALOGE("%s: dlsym error %s for acdb_loader_init_ACDB", __func__, dlerror());
392 else
393 my_data->acdb_init();
394 }
395
Apoorv Raghuvanshi5792d4b2013-10-07 18:40:05 -0700396 /* init usb */
397 audio_extn_usb_init(adev);
398
Apoorv Raghuvanshi6178a3f2013-10-19 12:38:54 -0700399 /* Read one time ssr property */
400 audio_extn_ssr_update_enabled(adev);
401
Eric Laurentb23d5282013-05-14 15:27:20 -0700402 return my_data;
403}
404
405void platform_deinit(void *platform)
406{
Ravi Kumar Alamanda48c921d2013-10-29 06:07:44 -0700407 struct platform_data *my_data = (struct platform_data *)platform;
408
409 hw_info_deinit(my_data->hw_info);
Eric Laurentb23d5282013-05-14 15:27:20 -0700410 free(platform);
Apoorv Raghuvanshi5792d4b2013-10-07 18:40:05 -0700411 /* deinit usb */
412 audio_extn_usb_deinit();
Eric Laurentb23d5282013-05-14 15:27:20 -0700413}
414
415const char *platform_get_snd_device_name(snd_device_t snd_device)
416{
417 if (snd_device >= SND_DEVICE_MIN && snd_device < SND_DEVICE_MAX)
418 return device_table[snd_device];
419 else
420 return "";
421}
422
Ravi Kumar Alamanda48c921d2013-10-29 06:07:44 -0700423int platform_get_snd_device_name_extn(void *platform, snd_device_t snd_device,
424 char *device_name)
425{
426 struct platform_data *my_data = (struct platform_data *)platform;
427
428 if (snd_device >= SND_DEVICE_MIN && snd_device < SND_DEVICE_MAX) {
429 strlcpy(device_name, device_table[snd_device], DEVICE_NAME_MAX_SIZE);
430 hw_info_append_hw_type(my_data->hw_info, snd_device, device_name);
431 } else {
432 strlcpy(device_name, "", DEVICE_NAME_MAX_SIZE);
433 return -EINVAL;
434 }
435
436 return 0;
437}
438
Eric Laurentb23d5282013-05-14 15:27:20 -0700439void platform_add_backend_name(char *mixer_path, snd_device_t snd_device)
440{
441 if (snd_device == SND_DEVICE_IN_BT_SCO_MIC)
Shiv Maliyappanahalli34b585f2013-10-01 15:49:05 -0700442 strlcat(mixer_path, " bt-sco", MIXER_PATH_MAX_LENGTH);
443 else if (snd_device == SND_DEVICE_IN_BT_SCO_MIC_WB)
444 strlcat(mixer_path, " bt-sco-wb", MIXER_PATH_MAX_LENGTH);
Eric Laurentb23d5282013-05-14 15:27:20 -0700445 else if(snd_device == SND_DEVICE_OUT_BT_SCO)
Shiv Maliyappanahalli34b585f2013-10-01 15:49:05 -0700446 strlcat(mixer_path, " bt-sco", MIXER_PATH_MAX_LENGTH);
447 else if(snd_device == SND_DEVICE_OUT_BT_SCO_WB)
448 strlcat(mixer_path, " bt-sco-wb", MIXER_PATH_MAX_LENGTH);
Eric Laurentb23d5282013-05-14 15:27:20 -0700449 else if (snd_device == SND_DEVICE_OUT_HDMI)
Shiv Maliyappanahalli34b585f2013-10-01 15:49:05 -0700450 strlcat(mixer_path, " hdmi", MIXER_PATH_MAX_LENGTH);
Eric Laurentb23d5282013-05-14 15:27:20 -0700451 else if (snd_device == SND_DEVICE_OUT_SPEAKER_AND_HDMI)
452 strcat(mixer_path, " speaker-and-hdmi");
Apoorv Raghuvanshi5792d4b2013-10-07 18:40:05 -0700453 else if (snd_device == SND_DEVICE_OUT_AFE_PROXY)
454 strlcat(mixer_path, " afe-proxy", MIXER_PATH_MAX_LENGTH);
455 else if (snd_device == SND_DEVICE_OUT_USB_HEADSET)
456 strlcat(mixer_path, " usb-headphones", MIXER_PATH_MAX_LENGTH);
457 else if (snd_device == SND_DEVICE_OUT_SPEAKER_AND_USB_HEADSET)
458 strlcat(mixer_path, " speaker-and-usb-headphones",
459 MIXER_PATH_MAX_LENGTH);
460 else if (snd_device == SND_DEVICE_IN_USB_HEADSET_MIC)
461 strlcat(mixer_path, " usb-headset-mic", MIXER_PATH_MAX_LENGTH);
Apoorv Raghuvanshi6e262842013-10-06 14:39:35 -0700462 else if (snd_device == SND_DEVICE_IN_CAPTURE_FM)
463 strlcat(mixer_path, " capture-fm", MIXER_PATH_MAX_LENGTH);
464 else if (snd_device == SND_DEVICE_OUT_TRANSMISSION_FM)
465 strlcat(mixer_path, " transmission-fm", MIXER_PATH_MAX_LENGTH);
Eric Laurentb23d5282013-05-14 15:27:20 -0700466}
467
468int platform_get_pcm_device_id(audio_usecase_t usecase, int device_type)
469{
470 int device_id;
471 if (device_type == PCM_PLAYBACK)
472 device_id = pcm_device_table[usecase][0];
473 else
474 device_id = pcm_device_table[usecase][1];
475 return device_id;
476}
477
478int platform_send_audio_calibration(void *platform, snd_device_t snd_device)
479{
480 struct platform_data *my_data = (struct platform_data *)platform;
481 int acdb_dev_id, acdb_dev_type;
482
483 acdb_dev_id = acdb_device_table[snd_device];
484 if (acdb_dev_id < 0) {
485 ALOGE("%s: Could not find acdb id for device(%d)",
486 __func__, snd_device);
487 return -EINVAL;
488 }
489 if (my_data->acdb_send_audio_cal) {
Eric Laurent994a6932013-07-17 11:51:42 -0700490 ("%s: sending audio calibration for snd_device(%d) acdb_id(%d)",
Eric Laurentb23d5282013-05-14 15:27:20 -0700491 __func__, snd_device, acdb_dev_id);
492 if (snd_device >= SND_DEVICE_OUT_BEGIN &&
493 snd_device < SND_DEVICE_OUT_END)
494 acdb_dev_type = ACDB_DEV_TYPE_OUT;
495 else
496 acdb_dev_type = ACDB_DEV_TYPE_IN;
497 my_data->acdb_send_audio_cal(acdb_dev_id, acdb_dev_type);
498 }
499 return 0;
500}
501
502int platform_switch_voice_call_device_pre(void *platform)
503{
504 return 0;
505}
506
507int platform_switch_voice_call_device_post(void *platform,
508 snd_device_t out_snd_device,
509 snd_device_t in_snd_device)
510{
511 struct platform_data *my_data = (struct platform_data *)platform;
512 int acdb_rx_id, acdb_tx_id;
513
514 if (my_data->acdb_send_voice_cal == NULL) {
515 ALOGE("%s: dlsym error for acdb_send_voice_call", __func__);
516 } else {
517 acdb_rx_id = acdb_device_table[out_snd_device];
518 acdb_tx_id = acdb_device_table[in_snd_device];
519
520 if (acdb_rx_id > 0 && acdb_tx_id > 0)
521 my_data->acdb_send_voice_cal(acdb_rx_id, acdb_tx_id);
522 else
523 ALOGE("%s: Incorrect ACDB IDs (rx: %d tx: %d)", __func__,
524 acdb_rx_id, acdb_tx_id);
525 }
526
527 return 0;
528}
529
530int platform_start_voice_call(void *platform)
531{
532 return 0;
533}
534
535int platform_stop_voice_call(void *platform)
536{
537 return 0;
538}
539
540int platform_set_voice_volume(void *platform, int volume)
541{
542 struct platform_data *my_data = (struct platform_data *)platform;
543 struct audio_device *adev = my_data->adev;
544 struct mixer_ctl *ctl;
sangwoo53b2cf02013-07-25 19:18:44 -0700545 const char *mixer_ctl_name = "Voice Rx Gain";
Shiv Maliyappanahalli34b585f2013-10-01 15:49:05 -0700546 int vol_index = 0;
547 uint32_t set_values[ ] = {0,
548 ALL_SESSION_VSID,
549 DEFAULT_VOLUME_RAMP_DURATION_MS};
Eric Laurentb23d5282013-05-14 15:27:20 -0700550
551 // Voice volume levels are mapped to adsp volume levels as follows.
552 // 100 -> 5, 80 -> 4, 60 -> 3, 40 -> 2, 20 -> 1 0 -> 0
553 // But this values don't changed in kernel. So, below change is need.
Shiv Maliyappanahalli34b585f2013-10-01 15:49:05 -0700554 vol_index = (int)percent_to_index(volume, MIN_VOL_INDEX, MAX_VOL_INDEX);
555 set_values[0] = vol_index;
Eric Laurentb23d5282013-05-14 15:27:20 -0700556
557 ctl = mixer_get_ctl_by_name(adev->mixer, mixer_ctl_name);
558 if (!ctl) {
559 ALOGE("%s: Could not get ctl for mixer cmd - %s",
560 __func__, mixer_ctl_name);
561 return -EINVAL;
562 }
Shiv Maliyappanahalli34b585f2013-10-01 15:49:05 -0700563 ALOGV("Setting voice volume index: %d", set_values[0]);
564 mixer_ctl_set_array(ctl, set_values, ARRAY_SIZE(set_values));
Eric Laurentb23d5282013-05-14 15:27:20 -0700565
566 return 0;
567}
568
569int platform_set_mic_mute(void *platform, bool state)
570{
571 struct platform_data *my_data = (struct platform_data *)platform;
572 struct audio_device *adev = my_data->adev;
573 struct mixer_ctl *ctl;
574 const char *mixer_ctl_name = "Voice Tx Mute";
Shiv Maliyappanahalli34b585f2013-10-01 15:49:05 -0700575 uint32_t set_values[ ] = {0,
576 ALL_SESSION_VSID,
577 DEFAULT_VOLUME_RAMP_DURATION_MS};
Eric Laurentb23d5282013-05-14 15:27:20 -0700578
579 if (adev->mode == AUDIO_MODE_IN_CALL) {
Shiv Maliyappanahalli34b585f2013-10-01 15:49:05 -0700580 set_values[0] = state;
Eric Laurentb23d5282013-05-14 15:27:20 -0700581 ctl = mixer_get_ctl_by_name(adev->mixer, mixer_ctl_name);
582 if (!ctl) {
583 ALOGE("%s: Could not get ctl for mixer cmd - %s",
584 __func__, mixer_ctl_name);
585 return -EINVAL;
586 }
Shiv Maliyappanahalli34b585f2013-10-01 15:49:05 -0700587 ALOGV("Setting voice mute state: %d", state);
588 mixer_ctl_set_array(ctl, set_values, ARRAY_SIZE(set_values));
Eric Laurentb23d5282013-05-14 15:27:20 -0700589 }
590
591 return 0;
592}
593
594snd_device_t platform_get_output_snd_device(void *platform, audio_devices_t devices)
595{
596 struct platform_data *my_data = (struct platform_data *)platform;
597 struct audio_device *adev = my_data->adev;
598 audio_mode_t mode = adev->mode;
599 snd_device_t snd_device = SND_DEVICE_NONE;
600
Apoorv Raghuvanshi9eaf94e2013-10-04 16:13:44 -0700601 audio_channel_mask_t channel_mask = (adev->active_input == NULL) ?
602 AUDIO_CHANNEL_IN_MONO : adev->active_input->channel_mask;
603 int channel_count = popcount(channel_mask);
604
Eric Laurentb23d5282013-05-14 15:27:20 -0700605 ALOGV("%s: enter: output devices(%#x)", __func__, devices);
606 if (devices == AUDIO_DEVICE_NONE ||
607 devices & AUDIO_DEVICE_BIT_IN) {
608 ALOGV("%s: Invalid output devices (%#x)", __func__, devices);
609 goto exit;
610 }
611
612 if (mode == AUDIO_MODE_IN_CALL) {
613 if (devices & AUDIO_DEVICE_OUT_WIRED_HEADPHONE ||
614 devices & AUDIO_DEVICE_OUT_WIRED_HEADSET) {
Shiv Maliyappanahalli34b585f2013-10-01 15:49:05 -0700615 if (adev->voice.tty_mode == TTY_MODE_FULL) {
Eric Laurentb23d5282013-05-14 15:27:20 -0700616 snd_device = SND_DEVICE_OUT_VOICE_TTY_FULL_HEADPHONES;
Shiv Maliyappanahalli34b585f2013-10-01 15:49:05 -0700617 } else if (adev->voice.tty_mode == TTY_MODE_VCO) {
Eric Laurentb23d5282013-05-14 15:27:20 -0700618 snd_device = SND_DEVICE_OUT_VOICE_TTY_VCO_HEADPHONES;
Shiv Maliyappanahalli34b585f2013-10-01 15:49:05 -0700619 } else if (adev->voice.tty_mode == TTY_MODE_HCO) {
Eric Laurentb23d5282013-05-14 15:27:20 -0700620 snd_device = SND_DEVICE_OUT_VOICE_TTY_HCO_HANDSET;
Shiv Maliyappanahalli34b585f2013-10-01 15:49:05 -0700621 } else if (audio_extn_get_anc_enabled()) {
Apoorv Raghuvanshi9eaf94e2013-10-04 16:13:44 -0700622 if (audio_extn_should_use_fb_anc())
623 snd_device = SND_DEVICE_OUT_VOICE_ANC_FB_HEADSET;
624 else
625 snd_device = SND_DEVICE_OUT_VOICE_ANC_HEADSET;
Shiv Maliyappanahalli34b585f2013-10-01 15:49:05 -0700626 } else {
Eric Laurentb23d5282013-05-14 15:27:20 -0700627 snd_device = SND_DEVICE_OUT_VOICE_HEADPHONES;
Shiv Maliyappanahalli34b585f2013-10-01 15:49:05 -0700628 }
Eric Laurentb23d5282013-05-14 15:27:20 -0700629 } else if (devices & AUDIO_DEVICE_OUT_ALL_SCO) {
Shiv Maliyappanahalli34b585f2013-10-01 15:49:05 -0700630 if (my_data->btsco_sample_rate == SAMPLE_RATE_16KHZ)
631 snd_device = SND_DEVICE_OUT_BT_SCO_WB;
632 else
633 snd_device = SND_DEVICE_OUT_BT_SCO;
Eric Laurentb23d5282013-05-14 15:27:20 -0700634 } else if (devices & AUDIO_DEVICE_OUT_SPEAKER) {
635 snd_device = SND_DEVICE_OUT_VOICE_SPEAKER;
Apoorv Raghuvanshi5792d4b2013-10-07 18:40:05 -0700636 } else if (devices & AUDIO_DEVICE_OUT_ANLG_DOCK_HEADSET ||
637 devices & AUDIO_DEVICE_OUT_DGTL_DOCK_HEADSET) {
638 snd_device = SND_DEVICE_OUT_USB_HEADSET;
Apoorv Raghuvanshi6e262842013-10-06 14:39:35 -0700639 } else if (devices & AUDIO_DEVICE_OUT_FM_TX) {
640 snd_device = SND_DEVICE_OUT_TRANSMISSION_FM;
Eric Laurentb23d5282013-05-14 15:27:20 -0700641 } else if (devices & AUDIO_DEVICE_OUT_EARPIECE) {
642 if (is_operator_tmus())
643 snd_device = SND_DEVICE_OUT_VOICE_HANDSET_TMUS;
Apoorv Raghuvanshi9eaf94e2013-10-04 16:13:44 -0700644 else if (audio_extn_should_use_handset_anc(channel_count))
645 snd_device = SND_DEVICE_OUT_ANC_HANDSET;
Eric Laurentb23d5282013-05-14 15:27:20 -0700646 else
Mingming Yin8e5a4f62013-10-07 15:23:41 -0700647 snd_device = SND_DEVICE_OUT_VOICE_HANDSET;
Eric Laurentb23d5282013-05-14 15:27:20 -0700648 }
649 if (snd_device != SND_DEVICE_NONE) {
650 goto exit;
651 }
652 }
653
654 if (popcount(devices) == 2) {
655 if (devices == (AUDIO_DEVICE_OUT_WIRED_HEADPHONE |
656 AUDIO_DEVICE_OUT_SPEAKER)) {
657 snd_device = SND_DEVICE_OUT_SPEAKER_AND_HEADPHONES;
658 } else if (devices == (AUDIO_DEVICE_OUT_WIRED_HEADSET |
659 AUDIO_DEVICE_OUT_SPEAKER)) {
Apoorv Raghuvanshi9eaf94e2013-10-04 16:13:44 -0700660 if (audio_extn_get_anc_enabled())
661 snd_device = SND_DEVICE_OUT_SPEAKER_AND_ANC_HEADSET;
662 else
663 snd_device = SND_DEVICE_OUT_SPEAKER_AND_HEADPHONES;
Eric Laurentb23d5282013-05-14 15:27:20 -0700664 } else if (devices == (AUDIO_DEVICE_OUT_AUX_DIGITAL |
665 AUDIO_DEVICE_OUT_SPEAKER)) {
666 snd_device = SND_DEVICE_OUT_SPEAKER_AND_HDMI;
Apoorv Raghuvanshi5792d4b2013-10-07 18:40:05 -0700667 } else if (devices == (AUDIO_DEVICE_OUT_ANLG_DOCK_HEADSET |
668 AUDIO_DEVICE_OUT_SPEAKER)) {
669 snd_device = SND_DEVICE_OUT_SPEAKER_AND_USB_HEADSET;
Eric Laurentb23d5282013-05-14 15:27:20 -0700670 } else {
671 ALOGE("%s: Invalid combo device(%#x)", __func__, devices);
672 goto exit;
673 }
674 if (snd_device != SND_DEVICE_NONE) {
675 goto exit;
676 }
677 }
678
679 if (popcount(devices) != 1) {
680 ALOGE("%s: Invalid output devices(%#x)", __func__, devices);
681 goto exit;
682 }
683
684 if (devices & AUDIO_DEVICE_OUT_WIRED_HEADPHONE ||
685 devices & AUDIO_DEVICE_OUT_WIRED_HEADSET) {
Apoorv Raghuvanshi9eaf94e2013-10-04 16:13:44 -0700686 if (devices & AUDIO_DEVICE_OUT_WIRED_HEADSET
687 && audio_extn_get_anc_enabled()) {
688 if (audio_extn_should_use_fb_anc())
689 snd_device = SND_DEVICE_OUT_ANC_FB_HEADSET;
690 else
691 snd_device = SND_DEVICE_OUT_ANC_HEADSET;
692 }
693 else
694 snd_device = SND_DEVICE_OUT_HEADPHONES;
Eric Laurentb23d5282013-05-14 15:27:20 -0700695 } else if (devices & AUDIO_DEVICE_OUT_SPEAKER) {
696 if (adev->speaker_lr_swap)
697 snd_device = SND_DEVICE_OUT_SPEAKER_REVERSE;
698 else
699 snd_device = SND_DEVICE_OUT_SPEAKER;
700 } else if (devices & AUDIO_DEVICE_OUT_ALL_SCO) {
Shiv Maliyappanahalli34b585f2013-10-01 15:49:05 -0700701 if (my_data->btsco_sample_rate == SAMPLE_RATE_16KHZ)
702 snd_device = SND_DEVICE_OUT_BT_SCO_WB;
703 else
704 snd_device = SND_DEVICE_OUT_BT_SCO;
Eric Laurentb23d5282013-05-14 15:27:20 -0700705 } else if (devices & AUDIO_DEVICE_OUT_AUX_DIGITAL) {
706 snd_device = SND_DEVICE_OUT_HDMI ;
Apoorv Raghuvanshi5792d4b2013-10-07 18:40:05 -0700707 } else if (devices & AUDIO_DEVICE_OUT_ANLG_DOCK_HEADSET ||
708 devices & AUDIO_DEVICE_OUT_DGTL_DOCK_HEADSET) {
709 snd_device = SND_DEVICE_OUT_USB_HEADSET;
Apoorv Raghuvanshi6e262842013-10-06 14:39:35 -0700710 } else if (devices & AUDIO_DEVICE_OUT_FM_TX) {
711 snd_device = SND_DEVICE_OUT_TRANSMISSION_FM;
Eric Laurentb23d5282013-05-14 15:27:20 -0700712 } else if (devices & AUDIO_DEVICE_OUT_EARPIECE) {
713 snd_device = SND_DEVICE_OUT_HANDSET;
Apoorv Raghuvanshi5792d4b2013-10-07 18:40:05 -0700714 } else if (devices & AUDIO_DEVICE_OUT_PROXY) {
715 ALOGD("%s: setting sink capability for Proxy", __func__);
716 audio_extn_set_afe_proxy_channel_mixer(adev);
717 snd_device = SND_DEVICE_OUT_AFE_PROXY;
Eric Laurentb23d5282013-05-14 15:27:20 -0700718 } else {
719 ALOGE("%s: Unknown device(s) %#x", __func__, devices);
720 }
721exit:
722 ALOGV("%s: exit: snd_device(%s)", __func__, device_table[snd_device]);
723 return snd_device;
724}
725
726snd_device_t platform_get_input_snd_device(void *platform, audio_devices_t out_device)
727{
728 struct platform_data *my_data = (struct platform_data *)platform;
729 struct audio_device *adev = my_data->adev;
730 audio_source_t source = (adev->active_input == NULL) ?
731 AUDIO_SOURCE_DEFAULT : adev->active_input->source;
732
733 audio_mode_t mode = adev->mode;
734 audio_devices_t in_device = ((adev->active_input == NULL) ?
735 AUDIO_DEVICE_NONE : adev->active_input->device)
736 & ~AUDIO_DEVICE_BIT_IN;
737 audio_channel_mask_t channel_mask = (adev->active_input == NULL) ?
738 AUDIO_CHANNEL_IN_MONO : adev->active_input->channel_mask;
739 snd_device_t snd_device = SND_DEVICE_NONE;
Apoorv Raghuvanshi9eaf94e2013-10-04 16:13:44 -0700740 int channel_count = popcount(channel_mask);
Eric Laurentb23d5282013-05-14 15:27:20 -0700741
742 ALOGV("%s: enter: out_device(%#x) in_device(%#x)",
743 __func__, out_device, in_device);
744 if (mode == AUDIO_MODE_IN_CALL) {
745 if (out_device == AUDIO_DEVICE_NONE) {
746 ALOGE("%s: No output device set for voice call", __func__);
747 goto exit;
748 }
Shiv Maliyappanahalli34b585f2013-10-01 15:49:05 -0700749 if (adev->voice.tty_mode != TTY_MODE_OFF) {
Eric Laurentb23d5282013-05-14 15:27:20 -0700750 if (out_device & AUDIO_DEVICE_OUT_WIRED_HEADPHONE ||
751 out_device & AUDIO_DEVICE_OUT_WIRED_HEADSET) {
Shiv Maliyappanahalli34b585f2013-10-01 15:49:05 -0700752 switch (adev->voice.tty_mode) {
Eric Laurentb23d5282013-05-14 15:27:20 -0700753 case TTY_MODE_FULL:
754 snd_device = SND_DEVICE_IN_VOICE_TTY_FULL_HEADSET_MIC;
755 break;
756 case TTY_MODE_VCO:
757 snd_device = SND_DEVICE_IN_VOICE_TTY_VCO_HANDSET_MIC;
758 break;
759 case TTY_MODE_HCO:
760 snd_device = SND_DEVICE_IN_VOICE_TTY_HCO_HEADSET_MIC;
761 break;
762 default:
Shiv Maliyappanahalli34b585f2013-10-01 15:49:05 -0700763 ALOGE("%s: Invalid TTY mode (%#x)",
764 __func__, adev->voice.tty_mode);
Eric Laurentb23d5282013-05-14 15:27:20 -0700765 }
766 goto exit;
767 }
768 }
769 if (out_device & AUDIO_DEVICE_OUT_EARPIECE ||
770 out_device & AUDIO_DEVICE_OUT_WIRED_HEADPHONE) {
Apoorv Raghuvanshi9eaf94e2013-10-04 16:13:44 -0700771 if (out_device & AUDIO_DEVICE_OUT_EARPIECE &&
772 audio_extn_should_use_handset_anc(channel_count)) {
773 snd_device = SND_DEVICE_IN_AANC_HANDSET_MIC;
774 } else if (my_data->fluence_type == FLUENCE_NONE ||
Mingming Yin8e5a4f62013-10-07 15:23:41 -0700775 my_data->fluence_in_voice_call == false) {
Eric Laurentb23d5282013-05-14 15:27:20 -0700776 snd_device = SND_DEVICE_IN_HANDSET_MIC;
777 } else {
Mingming Yin8e5a4f62013-10-07 15:23:41 -0700778 if (is_operator_tmus())
779 snd_device = SND_DEVICE_IN_VOICE_DMIC_TMUS;
Eric Laurentb23d5282013-05-14 15:27:20 -0700780 else
Mingming Yin8e5a4f62013-10-07 15:23:41 -0700781 snd_device = SND_DEVICE_IN_VOICE_DMIC;
782 adev->acdb_settings |= DMIC_FLAG;
Eric Laurentb23d5282013-05-14 15:27:20 -0700783 }
784 } else if (out_device & AUDIO_DEVICE_OUT_WIRED_HEADSET) {
785 snd_device = SND_DEVICE_IN_VOICE_HEADSET_MIC;
786 } else if (out_device & AUDIO_DEVICE_OUT_ALL_SCO) {
Shiv Maliyappanahalli34b585f2013-10-01 15:49:05 -0700787 if (my_data->btsco_sample_rate == SAMPLE_RATE_16KHZ)
788 snd_device = SND_DEVICE_IN_BT_SCO_MIC_WB;
789 else
790 snd_device = SND_DEVICE_IN_BT_SCO_MIC;
Eric Laurentb23d5282013-05-14 15:27:20 -0700791 } else if (out_device & AUDIO_DEVICE_OUT_SPEAKER) {
Mingming Yin8e5a4f62013-10-07 15:23:41 -0700792 if (my_data->fluence_type != FLUENCE_NONE &&
793 my_data->fluence_in_voice_call &&
794 my_data->fluence_in_spkr_mode) {
795 if(my_data->fluence_type == FLUENCE_DUAL_MIC) {
796 adev->acdb_settings |= DMIC_FLAG;
797 snd_device = SND_DEVICE_IN_VOICE_SPEAKER_DMIC;
798 } else {
799 adev->acdb_settings |= QMIC_FLAG;
800 snd_device = SND_DEVICE_IN_VOICE_SPEAKER_QMIC;
801 }
Eric Laurentb23d5282013-05-14 15:27:20 -0700802 } else {
803 snd_device = SND_DEVICE_IN_VOICE_SPEAKER_MIC;
804 }
805 }
806 } else if (source == AUDIO_SOURCE_CAMCORDER) {
807 if (in_device & AUDIO_DEVICE_IN_BUILTIN_MIC ||
808 in_device & AUDIO_DEVICE_IN_BACK_MIC) {
809 snd_device = SND_DEVICE_IN_CAMCORDER_MIC;
810 }
811 } else if (source == AUDIO_SOURCE_VOICE_RECOGNITION) {
812 if (in_device & AUDIO_DEVICE_IN_BUILTIN_MIC) {
Mingming Yin8e5a4f62013-10-07 15:23:41 -0700813 if (channel_mask == AUDIO_CHANNEL_IN_FRONT_BACK)
814 snd_device = SND_DEVICE_IN_VOICE_REC_DMIC;
815 else if (my_data->fluence_in_voice_rec)
816 snd_device = SND_DEVICE_IN_VOICE_REC_DMIC_FLUENCE;
Eric Laurentb23d5282013-05-14 15:27:20 -0700817
Mingming Yin8e5a4f62013-10-07 15:23:41 -0700818 if (snd_device == SND_DEVICE_NONE)
Eric Laurentb23d5282013-05-14 15:27:20 -0700819 snd_device = SND_DEVICE_IN_VOICE_REC_MIC;
Mingming Yin8e5a4f62013-10-07 15:23:41 -0700820 else
821 adev->acdb_settings |= DMIC_FLAG;
Eric Laurentb23d5282013-05-14 15:27:20 -0700822 }
823 } else if (source == AUDIO_SOURCE_VOICE_COMMUNICATION) {
824 if (out_device & AUDIO_DEVICE_OUT_SPEAKER)
825 in_device = AUDIO_DEVICE_IN_BACK_MIC;
826 if (adev->active_input) {
827 if (adev->active_input->enable_aec) {
828 if (in_device & AUDIO_DEVICE_IN_BACK_MIC) {
829 snd_device = SND_DEVICE_IN_SPEAKER_MIC_AEC;
830 } else if (in_device & AUDIO_DEVICE_IN_BUILTIN_MIC) {
831 snd_device = SND_DEVICE_IN_HANDSET_MIC_AEC;
832 } else if (in_device & AUDIO_DEVICE_IN_WIRED_HEADSET) {
833 snd_device = SND_DEVICE_IN_HEADSET_MIC_AEC;
834 }
835 set_echo_reference(adev->mixer, "SLIM_RX");
836 } else
837 set_echo_reference(adev->mixer, "NONE");
838 }
Preetam Singh Ranawatde84f1a2013-11-01 14:58:16 -0700839 } else if (source == AUDIO_SOURCE_FM_RX || AUDIO_SOURCE_FM_RX_A2DP) {
840 snd_device = SND_DEVICE_IN_CAPTURE_FM;
Eric Laurentb23d5282013-05-14 15:27:20 -0700841 } else if (source == AUDIO_SOURCE_DEFAULT) {
842 goto exit;
843 }
844
845
846 if (snd_device != SND_DEVICE_NONE) {
847 goto exit;
848 }
849
850 if (in_device != AUDIO_DEVICE_NONE &&
851 !(in_device & AUDIO_DEVICE_IN_VOICE_CALL) &&
852 !(in_device & AUDIO_DEVICE_IN_COMMUNICATION)) {
853 if (in_device & AUDIO_DEVICE_IN_BUILTIN_MIC) {
Apoorv Raghuvanshi6178a3f2013-10-19 12:38:54 -0700854 if (audio_extn_ssr_get_enabled() && channel_count == 6)
855 snd_device = SND_DEVICE_IN_QUAD_MIC;
Apoorv Raghuvanshi6bd8dbf2013-10-19 18:37:52 -0700856 else if (channel_count > 1)
857 snd_device = SND_DEVICE_IN_HANDSET_STEREO_DMIC;
Apoorv Raghuvanshi6178a3f2013-10-19 12:38:54 -0700858 else
859 snd_device = SND_DEVICE_IN_HANDSET_MIC;
Eric Laurentb23d5282013-05-14 15:27:20 -0700860 } else if (in_device & AUDIO_DEVICE_IN_BACK_MIC) {
861 snd_device = SND_DEVICE_IN_SPEAKER_MIC;
862 } else if (in_device & AUDIO_DEVICE_IN_WIRED_HEADSET) {
863 snd_device = SND_DEVICE_IN_HEADSET_MIC;
864 } else if (in_device & AUDIO_DEVICE_IN_BLUETOOTH_SCO_HEADSET) {
Shiv Maliyappanahalli34b585f2013-10-01 15:49:05 -0700865 if (my_data->btsco_sample_rate == SAMPLE_RATE_16KHZ)
866 snd_device = SND_DEVICE_IN_BT_SCO_MIC_WB;
867 else
868 snd_device = SND_DEVICE_IN_BT_SCO_MIC;
Eric Laurentb23d5282013-05-14 15:27:20 -0700869 } else if (in_device & AUDIO_DEVICE_IN_AUX_DIGITAL) {
870 snd_device = SND_DEVICE_IN_HDMI_MIC;
Apoorv Raghuvanshi5792d4b2013-10-07 18:40:05 -0700871 } else if (in_device & AUDIO_DEVICE_IN_ANLG_DOCK_HEADSET ||
872 in_device & AUDIO_DEVICE_IN_DGTL_DOCK_HEADSET) {
873 snd_device = SND_DEVICE_IN_USB_HEADSET_MIC;
Apoorv Raghuvanshi6e262842013-10-06 14:39:35 -0700874 } else if (in_device & AUDIO_DEVICE_IN_FM_RX) {
875 snd_device = SND_DEVICE_IN_CAPTURE_FM;
Eric Laurentb23d5282013-05-14 15:27:20 -0700876 } else {
877 ALOGE("%s: Unknown input device(s) %#x", __func__, in_device);
878 ALOGW("%s: Using default handset-mic", __func__);
879 snd_device = SND_DEVICE_IN_HANDSET_MIC;
880 }
881 } else {
882 if (out_device & AUDIO_DEVICE_OUT_EARPIECE) {
883 snd_device = SND_DEVICE_IN_HANDSET_MIC;
884 } else if (out_device & AUDIO_DEVICE_OUT_WIRED_HEADSET) {
885 snd_device = SND_DEVICE_IN_HEADSET_MIC;
886 } else if (out_device & AUDIO_DEVICE_OUT_SPEAKER) {
Apoorv Raghuvanshi6bd8dbf2013-10-19 18:37:52 -0700887 if (channel_count > 1)
888 snd_device = SND_DEVICE_IN_SPEAKER_STEREO_DMIC;
889 else
890 snd_device = SND_DEVICE_IN_SPEAKER_MIC;
Eric Laurentb23d5282013-05-14 15:27:20 -0700891 } else if (out_device & AUDIO_DEVICE_OUT_WIRED_HEADPHONE) {
892 snd_device = SND_DEVICE_IN_HANDSET_MIC;
893 } else if (out_device & AUDIO_DEVICE_OUT_BLUETOOTH_SCO_HEADSET) {
Shiv Maliyappanahalli34b585f2013-10-01 15:49:05 -0700894 if (my_data->btsco_sample_rate == SAMPLE_RATE_16KHZ)
895 snd_device = SND_DEVICE_IN_BT_SCO_MIC_WB;
896 else
897 snd_device = SND_DEVICE_IN_BT_SCO_MIC;
Eric Laurentb23d5282013-05-14 15:27:20 -0700898 } else if (out_device & AUDIO_DEVICE_OUT_AUX_DIGITAL) {
899 snd_device = SND_DEVICE_IN_HDMI_MIC;
Apoorv Raghuvanshi5792d4b2013-10-07 18:40:05 -0700900 } else if (out_device & AUDIO_DEVICE_OUT_ANLG_DOCK_HEADSET ||
901 out_device & AUDIO_DEVICE_OUT_DGTL_DOCK_HEADSET) {
902 snd_device = SND_DEVICE_IN_USB_HEADSET_MIC;
Eric Laurentb23d5282013-05-14 15:27:20 -0700903 } else {
904 ALOGE("%s: Unknown output device(s) %#x", __func__, out_device);
905 ALOGW("%s: Using default handset-mic", __func__);
906 snd_device = SND_DEVICE_IN_HANDSET_MIC;
907 }
908 }
909exit:
910 ALOGV("%s: exit: in_snd_device(%s)", __func__, device_table[snd_device]);
911 return snd_device;
912}
913
914int platform_set_hdmi_channels(void *platform, int channel_count)
915{
916 struct platform_data *my_data = (struct platform_data *)platform;
917 struct audio_device *adev = my_data->adev;
918 struct mixer_ctl *ctl;
919 const char *channel_cnt_str = NULL;
920 const char *mixer_ctl_name = "HDMI_RX Channels";
921 switch (channel_count) {
922 case 8:
923 channel_cnt_str = "Eight"; break;
924 case 7:
925 channel_cnt_str = "Seven"; break;
926 case 6:
927 channel_cnt_str = "Six"; break;
928 case 5:
929 channel_cnt_str = "Five"; break;
930 case 4:
931 channel_cnt_str = "Four"; break;
932 case 3:
933 channel_cnt_str = "Three"; break;
934 default:
935 channel_cnt_str = "Two"; break;
936 }
937 ctl = mixer_get_ctl_by_name(adev->mixer, mixer_ctl_name);
938 if (!ctl) {
939 ALOGE("%s: Could not get ctl for mixer cmd - %s",
940 __func__, mixer_ctl_name);
941 return -EINVAL;
942 }
943 ALOGV("HDMI channel count: %s", channel_cnt_str);
944 mixer_ctl_set_enum_by_string(ctl, channel_cnt_str);
945 return 0;
946}
947
Haynes Mathew George47cd4cb2013-07-19 11:58:50 -0700948int platform_edid_get_max_channels(void *platform)
Eric Laurentb23d5282013-05-14 15:27:20 -0700949{
Haynes Mathew George47cd4cb2013-07-19 11:58:50 -0700950 struct platform_data *my_data = (struct platform_data *)platform;
951 struct audio_device *adev = my_data->adev;
Eric Laurentb23d5282013-05-14 15:27:20 -0700952 char block[MAX_SAD_BLOCKS * SAD_BLOCK_SIZE];
953 char *sad = block;
954 int num_audio_blocks;
955 int channel_count;
956 int max_channels = 0;
Haynes Mathew George47cd4cb2013-07-19 11:58:50 -0700957 int i, ret, count;
Eric Laurentb23d5282013-05-14 15:27:20 -0700958
Haynes Mathew George47cd4cb2013-07-19 11:58:50 -0700959 struct mixer_ctl *ctl;
960
961 ctl = mixer_get_ctl_by_name(adev->mixer, AUDIO_DATA_BLOCK_MIXER_CTL);
962 if (!ctl) {
963 ALOGE("%s: Could not get ctl for mixer cmd - %s",
964 __func__, AUDIO_DATA_BLOCK_MIXER_CTL);
Eric Laurentb23d5282013-05-14 15:27:20 -0700965 return 0;
966 }
967
Haynes Mathew George47cd4cb2013-07-19 11:58:50 -0700968 mixer_ctl_update(ctl);
969
970 count = mixer_ctl_get_num_values(ctl);
Eric Laurentb23d5282013-05-14 15:27:20 -0700971
972 /* Read SAD blocks, clamping the maximum size for safety */
Haynes Mathew George47cd4cb2013-07-19 11:58:50 -0700973 if (count > (int)sizeof(block))
974 count = (int)sizeof(block);
Eric Laurentb23d5282013-05-14 15:27:20 -0700975
Haynes Mathew George47cd4cb2013-07-19 11:58:50 -0700976 ret = mixer_ctl_get_array(ctl, block, count);
977 if (ret != 0) {
978 ALOGE("%s: mixer_ctl_get_array() failed to get EDID info", __func__);
979 return 0;
980 }
Eric Laurentb23d5282013-05-14 15:27:20 -0700981
982 /* Calculate the number of SAD blocks */
Haynes Mathew George47cd4cb2013-07-19 11:58:50 -0700983 num_audio_blocks = count / SAD_BLOCK_SIZE;
Eric Laurentb23d5282013-05-14 15:27:20 -0700984
985 for (i = 0; i < num_audio_blocks; i++) {
986 /* Only consider LPCM blocks */
Haynes Mathew George47cd4cb2013-07-19 11:58:50 -0700987 if ((sad[0] >> 3) != EDID_FORMAT_LPCM) {
988 sad += 3;
Eric Laurentb23d5282013-05-14 15:27:20 -0700989 continue;
Haynes Mathew George47cd4cb2013-07-19 11:58:50 -0700990 }
Eric Laurentb23d5282013-05-14 15:27:20 -0700991
992 channel_count = (sad[0] & 0x7) + 1;
993 if (channel_count > max_channels)
994 max_channels = channel_count;
995
996 /* Advance to next block */
997 sad += 3;
998 }
999
1000 return max_channels;
1001}
Shiv Maliyappanahalli34b585f2013-10-01 15:49:05 -07001002
1003static int platform_set_slowtalk(struct platform_data *my_data, bool state)
1004{
1005 int ret = 0;
1006 struct audio_device *adev = my_data->adev;
1007 struct mixer_ctl *ctl;
1008 const char *mixer_ctl_name = "Slowtalk Enable";
1009 uint32_t set_values[ ] = {0,
1010 ALL_SESSION_VSID};
1011
1012 set_values[0] = state;
1013 ctl = mixer_get_ctl_by_name(adev->mixer, mixer_ctl_name);
1014 if (!ctl) {
1015 ALOGE("%s: Could not get ctl for mixer cmd - %s",
1016 __func__, mixer_ctl_name);
1017 ret = -EINVAL;
1018 } else {
1019 ALOGV("Setting slowtalk state: %d", state);
1020 ret = mixer_ctl_set_array(ctl, set_values, ARRAY_SIZE(set_values));
1021 my_data->slowtalk = state;
1022 }
1023
1024 return ret;
1025}
1026
1027int platform_set_parameters(void *platform, struct str_parms *parms)
1028{
1029 struct platform_data *my_data = (struct platform_data *)platform;
1030 char *str;
1031 char value[32];
1032 int val;
1033 int ret = 0;
1034
1035 ALOGV("%s: enter: %s", __func__, str_parms_to_str(parms));
1036
1037 ret = str_parms_get_int(parms, AUDIO_PARAMETER_KEY_BTSCO, &val);
1038 if (ret >= 0) {
1039 str_parms_del(parms, AUDIO_PARAMETER_KEY_BTSCO);
1040 pthread_mutex_lock(&my_data->adev->lock);
1041 my_data->btsco_sample_rate = val;
1042 pthread_mutex_unlock(&my_data->adev->lock);
1043 }
1044
1045 ret = str_parms_get_int(parms, AUDIO_PARAMETER_KEY_SLOWTALK, &val);
1046 if (ret >= 0) {
1047 str_parms_del(parms, AUDIO_PARAMETER_KEY_SLOWTALK);
1048 pthread_mutex_lock(&my_data->adev->lock);
1049 ret = platform_set_slowtalk(my_data, val);
1050 if (ret)
1051 ALOGE("%s: Failed to set slow talk err: %d", __func__, ret);
1052 pthread_mutex_unlock(&my_data->adev->lock);
1053 }
1054
1055 ALOGV("%s: exit with code(%d)", __func__, ret);
1056 return ret;
1057}
1058
Shiv Maliyappanahallida107642013-10-17 11:16:13 -07001059int platform_set_incall_recoding_session_id(void *platform,
1060 uint32_t session_id)
1061{
1062 int ret = 0;
1063 struct platform_data *my_data = (struct platform_data *)platform;
1064 struct audio_device *adev = my_data->adev;
1065 struct mixer_ctl *ctl;
1066 const char *mixer_ctl_name = "Voc VSID";
1067 int num_ctl_values;
1068 int i;
1069
1070 ctl = mixer_get_ctl_by_name(adev->mixer, mixer_ctl_name);
1071 if (!ctl) {
1072 ALOGE("%s: Could not get ctl for mixer cmd - %s",
1073 __func__, mixer_ctl_name);
1074 ret = -EINVAL;
1075 } else {
1076 num_ctl_values = mixer_ctl_get_num_values(ctl);
1077 for (i = 0; i < num_ctl_values; i++) {
1078 if (mixer_ctl_set_value(ctl, i, session_id)) {
1079 ALOGV("Error: invalid session_id: %x", session_id);
1080 ret = -EINVAL;
1081 break;
1082 }
1083 }
1084 }
1085
1086 return ret;
1087}
1088
Shiv Maliyappanahalli34b585f2013-10-01 15:49:05 -07001089void platform_get_parameters(void *platform,
1090 struct str_parms *query,
1091 struct str_parms *reply)
1092{
1093 struct platform_data *my_data = (struct platform_data *)platform;
1094 char *str = NULL;
1095 char value[256] = {0};
1096 int ret;
1097 int fluence_type;
1098
1099 ret = str_parms_get_str(query, AUDIO_PARAMETER_KEY_FLUENCE_TYPE,
1100 value, sizeof(value));
1101 if (ret >= 0) {
1102 pthread_mutex_lock(&my_data->adev->lock);
1103 if (my_data->fluence_type == FLUENCE_QUAD_MIC) {
1104 strlcpy(value, "fluencepro", sizeof(value));
1105 } else if (my_data->fluence_type == FLUENCE_DUAL_MIC) {
1106 strlcpy(value, "fluence", sizeof(value));
1107 } else {
1108 strlcpy(value, "none", sizeof(value));
1109 }
1110 pthread_mutex_unlock(&my_data->adev->lock);
1111
1112 str_parms_add_str(reply, AUDIO_PARAMETER_KEY_FLUENCE_TYPE, value);
1113 }
1114
1115 ALOGV("%s: exit: returns - %s", __func__, str_parms_to_str(reply));
1116}
1117
Haynes Mathew George7ff216f2013-09-11 19:51:41 -07001118/* Delay in Us */
1119int64_t platform_render_latency(audio_usecase_t usecase)
1120{
1121 switch (usecase) {
1122 case USECASE_AUDIO_PLAYBACK_DEEP_BUFFER:
1123 return DEEP_BUFFER_PLATFORM_DELAY;
1124 case USECASE_AUDIO_PLAYBACK_LOW_LATENCY:
1125 return LOW_LATENCY_PLATFORM_DELAY;
1126 default:
1127 return 0;
1128 }
1129}
Preetam Singh Ranawatde84f1a2013-11-01 14:58:16 -07001130
1131int platform_get_usecase_from_source(int source)
1132{
1133 ALOGV("%s: input source ", __func__, source);
1134 if(AUDIO_SOURCE_FM_RX_A2DP)
1135 return USECASE_AUDIO_RECORD_FM_VIRTUAL;
1136 else
1137 return USECASE_AUDIO_RECORD;
1138}