Eric Laurent | b23d528 | 2013-05-14 15:27:20 -0700 | [diff] [blame] | 1 | /* |
Ben Romberger | 5588688 | 2014-01-10 13:49:02 -0800 | [diff] [blame] | 2 | * Copyright (c) 2013-2014, The Linux Foundation. All rights reserved. |
Shiv Maliyappanahalli | 34b585f | 2013-10-01 15:49:05 -0700 | [diff] [blame] | 3 | * Not a contribution. |
| 4 | * |
Eric Laurent | b23d528 | 2013-05-14 15:27:20 -0700 | [diff] [blame] | 5 | * 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 "msm8960_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> |
| 28 | #include <audio_hw.h> |
| 29 | #include <platform_api.h> |
| 30 | #include "platform.h" |
| 31 | |
| 32 | #define LIB_ACDB_LOADER "libacdbloader.so" |
| 33 | #define LIB_CSD_CLIENT "libcsd-client.so" |
| 34 | |
Eric Laurent | b23d528 | 2013-05-14 15:27:20 -0700 | [diff] [blame] | 35 | /* |
| 36 | * This is the sysfs path for the HDMI audio data block |
| 37 | */ |
| 38 | #define AUDIO_DATA_BLOCK_PATH "/sys/class/graphics/fb1/audio_data_block" |
sangwoo | 1b9f4b3 | 2013-06-21 18:22:55 -0700 | [diff] [blame] | 39 | #define MIXER_XML_PATH "/system/etc/mixer_paths.xml" |
Eric Laurent | b23d528 | 2013-05-14 15:27:20 -0700 | [diff] [blame] | 40 | |
| 41 | /* |
| 42 | * This file will have a maximum of 38 bytes: |
| 43 | * |
| 44 | * 4 bytes: number of audio blocks |
| 45 | * 4 bytes: total length of Short Audio Descriptor (SAD) blocks |
| 46 | * Maximum 10 * 3 bytes: SAD blocks |
| 47 | */ |
| 48 | #define MAX_SAD_BLOCKS 10 |
| 49 | #define SAD_BLOCK_SIZE 3 |
| 50 | |
| 51 | /* EDID format ID for LPCM audio */ |
| 52 | #define EDID_FORMAT_LPCM 1 |
| 53 | |
| 54 | struct audio_block_header |
| 55 | { |
| 56 | int reserved; |
| 57 | int length; |
| 58 | }; |
| 59 | |
| 60 | |
| 61 | typedef void (*acdb_deallocate_t)(); |
| 62 | typedef int (*acdb_init_t)(); |
| 63 | typedef void (*acdb_send_audio_cal_t)(int, int); |
| 64 | typedef void (*acdb_send_voice_cal_t)(int, int); |
| 65 | |
| 66 | typedef int (*csd_client_init_t)(); |
| 67 | typedef int (*csd_client_deinit_t)(); |
| 68 | typedef int (*csd_disable_device_t)(); |
| 69 | typedef int (*csd_enable_device_t)(int, int, uint32_t); |
| 70 | typedef int (*csd_volume_t)(int); |
| 71 | typedef int (*csd_mic_mute_t)(int); |
| 72 | typedef int (*csd_start_voice_t)(); |
| 73 | typedef int (*csd_stop_voice_t)(); |
| 74 | |
| 75 | |
Eric Laurent | b23d528 | 2013-05-14 15:27:20 -0700 | [diff] [blame] | 76 | struct platform_data { |
| 77 | struct audio_device *adev; |
| 78 | bool fluence_in_spkr_mode; |
| 79 | bool fluence_in_voice_call; |
| 80 | bool fluence_in_voice_rec; |
Mingming Yin | 8e5a4f6 | 2013-10-07 15:23:41 -0700 | [diff] [blame] | 81 | int fluence_type; |
Eric Laurent | b23d528 | 2013-05-14 15:27:20 -0700 | [diff] [blame] | 82 | int dualmic_config; |
Venkata Narendra Kumar Gutta | 1bbbf54 | 2014-09-04 19:11:25 +0530 | [diff] [blame] | 83 | bool ec_ref_enabled; |
Eric Laurent | b23d528 | 2013-05-14 15:27:20 -0700 | [diff] [blame] | 84 | |
Ravi Kumar Alamanda | 48c921d | 2013-10-29 06:07:44 -0700 | [diff] [blame] | 85 | /* Audio calibration related functions */ |
Eric Laurent | b23d528 | 2013-05-14 15:27:20 -0700 | [diff] [blame] | 86 | void *acdb_handle; |
| 87 | acdb_init_t acdb_init; |
| 88 | acdb_deallocate_t acdb_deallocate; |
| 89 | acdb_send_audio_cal_t acdb_send_audio_cal; |
| 90 | acdb_send_voice_cal_t acdb_send_voice_cal; |
| 91 | |
| 92 | /* CSD Client related functions for voice call */ |
| 93 | void *csd_client; |
| 94 | csd_client_init_t csd_client_init; |
| 95 | csd_client_deinit_t csd_client_deinit; |
| 96 | csd_disable_device_t csd_disable_device; |
| 97 | csd_enable_device_t csd_enable_device; |
| 98 | csd_volume_t csd_volume; |
| 99 | csd_mic_mute_t csd_mic_mute; |
| 100 | csd_start_voice_t csd_start_voice; |
| 101 | csd_stop_voice_t csd_stop_voice; |
| 102 | }; |
| 103 | |
| 104 | static const int pcm_device_table[AUDIO_USECASE_MAX][2] = { |
| 105 | [USECASE_AUDIO_PLAYBACK_DEEP_BUFFER] = {0, 0}, |
| 106 | [USECASE_AUDIO_PLAYBACK_LOW_LATENCY] = {14, 14}, |
| 107 | [USECASE_AUDIO_PLAYBACK_MULTI_CH] = {1, 1}, |
| 108 | [USECASE_AUDIO_RECORD] = {0, 0}, |
| 109 | [USECASE_AUDIO_RECORD_LOW_LATENCY] = {14, 14}, |
| 110 | [USECASE_VOICE_CALL] = {12, 12}, |
| 111 | }; |
| 112 | |
| 113 | /* Array to store sound devices */ |
| 114 | static const char * const device_table[SND_DEVICE_MAX] = { |
| 115 | [SND_DEVICE_NONE] = "none", |
| 116 | /* Playback sound devices */ |
| 117 | [SND_DEVICE_OUT_HANDSET] = "handset", |
| 118 | [SND_DEVICE_OUT_SPEAKER] = "speaker", |
| 119 | [SND_DEVICE_OUT_SPEAKER_REVERSE] = "speaker-reverse", |
| 120 | [SND_DEVICE_OUT_HEADPHONES] = "headphones", |
| 121 | [SND_DEVICE_OUT_SPEAKER_AND_HEADPHONES] = "speaker-and-headphones", |
| 122 | [SND_DEVICE_OUT_VOICE_SPEAKER] = "voice-speaker", |
| 123 | [SND_DEVICE_OUT_VOICE_HEADPHONES] = "voice-headphones", |
| 124 | [SND_DEVICE_OUT_HDMI] = "hdmi", |
| 125 | [SND_DEVICE_OUT_SPEAKER_AND_HDMI] = "speaker-and-hdmi", |
| 126 | [SND_DEVICE_OUT_BT_SCO] = "bt-sco-headset", |
Mingming Yin | 514a8bc | 2014-07-29 15:22:21 -0700 | [diff] [blame] | 127 | [SND_DEVICE_OUT_BT_SCO_WB] = "bt-sco-headset-wb", |
Eric Laurent | b23d528 | 2013-05-14 15:27:20 -0700 | [diff] [blame] | 128 | [SND_DEVICE_OUT_VOICE_TTY_FULL_HEADPHONES] = "voice-tty-full-headphones", |
| 129 | [SND_DEVICE_OUT_VOICE_TTY_VCO_HEADPHONES] = "voice-tty-vco-headphones", |
| 130 | [SND_DEVICE_OUT_VOICE_TTY_HCO_HANDSET] = "voice-tty-hco-handset", |
Ravi Kumar Alamanda | bdf1416 | 2014-09-05 16:14:17 -0700 | [diff] [blame] | 131 | [SND_DEVICE_OUT_USB_HEADSET] = "usb-headphones", |
| 132 | [SND_DEVICE_OUT_SPEAKER_AND_USB_HEADSET] = "speaker-and-usb-headphones", |
Eric Laurent | b23d528 | 2013-05-14 15:27:20 -0700 | [diff] [blame] | 133 | |
| 134 | /* Capture sound devices */ |
| 135 | [SND_DEVICE_IN_HANDSET_MIC] = "handset-mic", |
| 136 | [SND_DEVICE_IN_SPEAKER_MIC] = "speaker-mic", |
| 137 | [SND_DEVICE_IN_HEADSET_MIC] = "headset-mic", |
| 138 | [SND_DEVICE_IN_HANDSET_MIC_AEC] = "handset-mic", |
| 139 | [SND_DEVICE_IN_SPEAKER_MIC_AEC] = "voice-speaker-mic", |
| 140 | [SND_DEVICE_IN_HEADSET_MIC_AEC] = "headset-mic", |
| 141 | [SND_DEVICE_IN_VOICE_SPEAKER_MIC] = "voice-speaker-mic", |
| 142 | [SND_DEVICE_IN_VOICE_HEADSET_MIC] = "voice-headset-mic", |
| 143 | [SND_DEVICE_IN_HDMI_MIC] = "hdmi-mic", |
| 144 | [SND_DEVICE_IN_BT_SCO_MIC] = "bt-sco-mic", |
Mingming Yin | 514a8bc | 2014-07-29 15:22:21 -0700 | [diff] [blame] | 145 | [SND_DEVICE_IN_BT_SCO_MIC_WB] = "bt-sco-mic-wb", |
Eric Laurent | b23d528 | 2013-05-14 15:27:20 -0700 | [diff] [blame] | 146 | [SND_DEVICE_IN_CAMCORDER_MIC] = "camcorder-mic", |
Mingming Yin | 8e5a4f6 | 2013-10-07 15:23:41 -0700 | [diff] [blame] | 147 | [SND_DEVICE_IN_VOICE_DMIC] = "voice-dmic-ef", |
Mingming Yin | 8e5a4f6 | 2013-10-07 15:23:41 -0700 | [diff] [blame] | 148 | [SND_DEVICE_IN_VOICE_SPEAKER_DMIC] = "voice-speaker-dmic-ef", |
Eric Laurent | b23d528 | 2013-05-14 15:27:20 -0700 | [diff] [blame] | 149 | [SND_DEVICE_IN_VOICE_TTY_FULL_HEADSET_MIC] = "voice-tty-full-headset-mic", |
| 150 | [SND_DEVICE_IN_VOICE_TTY_VCO_HANDSET_MIC] = "voice-tty-vco-handset-mic", |
| 151 | [SND_DEVICE_IN_VOICE_TTY_HCO_HEADSET_MIC] = "voice-tty-hco-headset-mic", |
| 152 | [SND_DEVICE_IN_VOICE_REC_MIC] = "voice-rec-mic", |
Mingming Yin | 8e5a4f6 | 2013-10-07 15:23:41 -0700 | [diff] [blame] | 153 | [SND_DEVICE_IN_VOICE_REC_DMIC] = "voice-rec-dmic-ef", |
| 154 | [SND_DEVICE_IN_VOICE_REC_DMIC_FLUENCE] = "voice-rec-dmic-ef-fluence", |
Ravi Kumar Alamanda | bdf1416 | 2014-09-05 16:14:17 -0700 | [diff] [blame] | 155 | [SND_DEVICE_IN_USB_HEADSET_MIC] = "usb-headset-mic", |
Eric Laurent | b23d528 | 2013-05-14 15:27:20 -0700 | [diff] [blame] | 156 | }; |
| 157 | |
| 158 | /* ACDB IDs (audio DSP path configuration IDs) for each sound device */ |
| 159 | static const int acdb_device_table[SND_DEVICE_MAX] = { |
| 160 | [SND_DEVICE_NONE] = -1, |
| 161 | [SND_DEVICE_OUT_HANDSET] = 7, |
| 162 | [SND_DEVICE_OUT_SPEAKER] = 14, |
| 163 | [SND_DEVICE_OUT_SPEAKER_REVERSE] = 14, |
| 164 | [SND_DEVICE_OUT_HEADPHONES] = 10, |
| 165 | [SND_DEVICE_OUT_SPEAKER_AND_HEADPHONES] = 10, |
| 166 | [SND_DEVICE_OUT_VOICE_SPEAKER] = 14, |
| 167 | [SND_DEVICE_OUT_VOICE_HEADPHONES] = 10, |
| 168 | [SND_DEVICE_OUT_HDMI] = 18, |
| 169 | [SND_DEVICE_OUT_SPEAKER_AND_HDMI] = 14, |
| 170 | [SND_DEVICE_OUT_BT_SCO] = 22, |
Mingming Yin | 514a8bc | 2014-07-29 15:22:21 -0700 | [diff] [blame] | 171 | [SND_DEVICE_OUT_BT_SCO_WB] = 39, |
Eric Laurent | b23d528 | 2013-05-14 15:27:20 -0700 | [diff] [blame] | 172 | [SND_DEVICE_OUT_VOICE_TTY_FULL_HEADPHONES] = 17, |
| 173 | [SND_DEVICE_OUT_VOICE_TTY_VCO_HEADPHONES] = 17, |
| 174 | [SND_DEVICE_OUT_VOICE_TTY_HCO_HANDSET] = 37, |
Ravi Kumar Alamanda | bdf1416 | 2014-09-05 16:14:17 -0700 | [diff] [blame] | 175 | [SND_DEVICE_OUT_USB_HEADSET] = 45, |
| 176 | [SND_DEVICE_OUT_SPEAKER_AND_USB_HEADSET] = 14, |
Eric Laurent | b23d528 | 2013-05-14 15:27:20 -0700 | [diff] [blame] | 177 | |
| 178 | [SND_DEVICE_IN_HANDSET_MIC] = 4, |
| 179 | [SND_DEVICE_IN_SPEAKER_MIC] = 4, |
| 180 | [SND_DEVICE_IN_HEADSET_MIC] = 8, |
| 181 | [SND_DEVICE_IN_HANDSET_MIC_AEC] = 40, |
| 182 | [SND_DEVICE_IN_SPEAKER_MIC_AEC] = 42, |
| 183 | [SND_DEVICE_IN_HEADSET_MIC_AEC] = 47, |
| 184 | [SND_DEVICE_IN_VOICE_SPEAKER_MIC] = 11, |
| 185 | [SND_DEVICE_IN_VOICE_HEADSET_MIC] = 8, |
| 186 | [SND_DEVICE_IN_HDMI_MIC] = 4, |
| 187 | [SND_DEVICE_IN_BT_SCO_MIC] = 21, |
Mingming Yin | 514a8bc | 2014-07-29 15:22:21 -0700 | [diff] [blame] | 188 | [SND_DEVICE_IN_BT_SCO_MIC_WB] = 38, |
Eric Laurent | b23d528 | 2013-05-14 15:27:20 -0700 | [diff] [blame] | 189 | [SND_DEVICE_IN_CAMCORDER_MIC] = 61, |
Mingming Yin | 8e5a4f6 | 2013-10-07 15:23:41 -0700 | [diff] [blame] | 190 | [SND_DEVICE_IN_VOICE_DMIC] = 6, |
Mingming Yin | 8e5a4f6 | 2013-10-07 15:23:41 -0700 | [diff] [blame] | 191 | [SND_DEVICE_IN_VOICE_SPEAKER_DMIC] = 13, |
Eric Laurent | b23d528 | 2013-05-14 15:27:20 -0700 | [diff] [blame] | 192 | [SND_DEVICE_IN_VOICE_TTY_FULL_HEADSET_MIC] = 16, |
| 193 | [SND_DEVICE_IN_VOICE_TTY_VCO_HANDSET_MIC] = 36, |
| 194 | [SND_DEVICE_IN_VOICE_TTY_HCO_HEADSET_MIC] = 16, |
| 195 | [SND_DEVICE_IN_VOICE_REC_MIC] = 62, |
Ravi Kumar Alamanda | bdf1416 | 2014-09-05 16:14:17 -0700 | [diff] [blame] | 196 | [SND_DEVICE_IN_USB_HEADSET_MIC] = 44, |
Eric Laurent | b23d528 | 2013-05-14 15:27:20 -0700 | [diff] [blame] | 197 | /* TODO: Update with proper acdb ids */ |
Mingming Yin | 8e5a4f6 | 2013-10-07 15:23:41 -0700 | [diff] [blame] | 198 | [SND_DEVICE_IN_VOICE_REC_DMIC] = 62, |
| 199 | [SND_DEVICE_IN_VOICE_REC_DMIC_FLUENCE] = 6, |
Eric Laurent | b23d528 | 2013-05-14 15:27:20 -0700 | [diff] [blame] | 200 | }; |
| 201 | |
Haynes Mathew George | 7ff216f | 2013-09-11 19:51:41 -0700 | [diff] [blame] | 202 | #define DEEP_BUFFER_PLATFORM_DELAY (29*1000LL) |
| 203 | #define LOW_LATENCY_PLATFORM_DELAY (13*1000LL) |
| 204 | |
Venkata Narendra Kumar Gutta | 1bbbf54 | 2014-09-04 19:11:25 +0530 | [diff] [blame] | 205 | void platform_set_echo_reference(void *platform, bool enable) |
Eric Laurent | b23d528 | 2013-05-14 15:27:20 -0700 | [diff] [blame] | 206 | { |
Venkata Narendra Kumar Gutta | 1bbbf54 | 2014-09-04 19:11:25 +0530 | [diff] [blame] | 207 | struct platform_data *my_data = (struct platform_data *)platform; |
| 208 | struct audio_device *adev = my_data->adev; |
| 209 | |
| 210 | if (enable) { |
| 211 | my_data->ec_ref_enabled = enable; |
Anish Kumar | 4980fa1 | 2014-04-17 12:42:20 -0700 | [diff] [blame] | 212 | audio_route_apply_and_update_path(adev->audio_route, "echo-reference"); |
Venkata Narendra Kumar Gutta | 1bbbf54 | 2014-09-04 19:11:25 +0530 | [diff] [blame] | 213 | } else { |
| 214 | if (my_data->ec_ref_enabled) { |
| 215 | audio_route_reset_and_update_path(adev->audio_route, "echo-reference"); |
| 216 | my_data->ec_ref_enabled = enable; |
| 217 | } else { |
| 218 | ALOGV("EC Reference is already disabled: %d", my_data->ec_ref_enabled); |
| 219 | } |
| 220 | } |
Eric Laurent | b23d528 | 2013-05-14 15:27:20 -0700 | [diff] [blame] | 221 | |
Anish Kumar | 4980fa1 | 2014-04-17 12:42:20 -0700 | [diff] [blame] | 222 | ALOGV("Setting EC Reference: %d", enable); |
Eric Laurent | b23d528 | 2013-05-14 15:27:20 -0700 | [diff] [blame] | 223 | } |
| 224 | |
| 225 | void *platform_init(struct audio_device *adev) |
| 226 | { |
| 227 | char platform[PROPERTY_VALUE_MAX]; |
| 228 | char baseband[PROPERTY_VALUE_MAX]; |
| 229 | char value[PROPERTY_VALUE_MAX]; |
| 230 | struct platform_data *my_data; |
Ravi Kumar Alamanda | 48c921d | 2013-10-29 06:07:44 -0700 | [diff] [blame] | 231 | const char *snd_card_name; |
Eric Laurent | b23d528 | 2013-05-14 15:27:20 -0700 | [diff] [blame] | 232 | |
sangwoo | 1b9f4b3 | 2013-06-21 18:22:55 -0700 | [diff] [blame] | 233 | adev->mixer = mixer_open(MIXER_CARD); |
| 234 | |
| 235 | if (!adev->mixer) { |
| 236 | ALOGE("Unable to open the mixer, aborting."); |
| 237 | return NULL; |
| 238 | } |
| 239 | |
| 240 | adev->audio_route = audio_route_init(MIXER_CARD, MIXER_XML_PATH); |
| 241 | if (!adev->audio_route) { |
| 242 | ALOGE("%s: Failed to init audio route controls, aborting.", __func__); |
| 243 | return NULL; |
| 244 | } |
| 245 | |
Eric Laurent | b23d528 | 2013-05-14 15:27:20 -0700 | [diff] [blame] | 246 | my_data = calloc(1, sizeof(struct platform_data)); |
| 247 | |
Ravi Kumar Alamanda | 48c921d | 2013-10-29 06:07:44 -0700 | [diff] [blame] | 248 | snd_card_name = mixer_get_name(adev->mixer); |
Ravi Kumar Alamanda | 48c921d | 2013-10-29 06:07:44 -0700 | [diff] [blame] | 249 | |
Eric Laurent | b23d528 | 2013-05-14 15:27:20 -0700 | [diff] [blame] | 250 | my_data->adev = adev; |
Eric Laurent | b23d528 | 2013-05-14 15:27:20 -0700 | [diff] [blame] | 251 | my_data->fluence_in_spkr_mode = false; |
| 252 | my_data->fluence_in_voice_call = false; |
| 253 | my_data->fluence_in_voice_rec = false; |
Mingming Yin | 8e5a4f6 | 2013-10-07 15:23:41 -0700 | [diff] [blame] | 254 | my_data->fluence_type = FLUENCE_NONE; |
Eric Laurent | b23d528 | 2013-05-14 15:27:20 -0700 | [diff] [blame] | 255 | |
Mingming Yin | 8e5a4f6 | 2013-10-07 15:23:41 -0700 | [diff] [blame] | 256 | property_get("ro.qc.sdk.audio.fluencetype", value, ""); |
| 257 | if (!strncmp("fluencepro", value, sizeof("fluencepro"))) { |
| 258 | my_data->fluence_type = FLUENCE_QUAD_MIC; |
| 259 | } else if (!strncmp("fluence", value, sizeof("fluence"))) { |
| 260 | my_data->fluence_type = FLUENCE_DUAL_MIC; |
| 261 | } else { |
| 262 | my_data->fluence_type = FLUENCE_NONE; |
Eric Laurent | b23d528 | 2013-05-14 15:27:20 -0700 | [diff] [blame] | 263 | } |
| 264 | |
Mingming Yin | 8e5a4f6 | 2013-10-07 15:23:41 -0700 | [diff] [blame] | 265 | if (my_data->fluence_type != FLUENCE_NONE) { |
Eric Laurent | b23d528 | 2013-05-14 15:27:20 -0700 | [diff] [blame] | 266 | property_get("persist.audio.fluence.voicecall",value,""); |
Mingming Yin | 8e5a4f6 | 2013-10-07 15:23:41 -0700 | [diff] [blame] | 267 | if (!strncmp("true", value, sizeof("true"))) { |
Eric Laurent | b23d528 | 2013-05-14 15:27:20 -0700 | [diff] [blame] | 268 | my_data->fluence_in_voice_call = true; |
| 269 | } |
| 270 | |
| 271 | property_get("persist.audio.fluence.voicerec",value,""); |
Mingming Yin | 8e5a4f6 | 2013-10-07 15:23:41 -0700 | [diff] [blame] | 272 | if (!strncmp("true", value, sizeof("true"))) { |
Eric Laurent | b23d528 | 2013-05-14 15:27:20 -0700 | [diff] [blame] | 273 | my_data->fluence_in_voice_rec = true; |
| 274 | } |
| 275 | |
| 276 | property_get("persist.audio.fluence.speaker",value,""); |
Mingming Yin | 8e5a4f6 | 2013-10-07 15:23:41 -0700 | [diff] [blame] | 277 | if (!strncmp("true", value, sizeof("true"))) { |
Eric Laurent | b23d528 | 2013-05-14 15:27:20 -0700 | [diff] [blame] | 278 | my_data->fluence_in_spkr_mode = true; |
| 279 | } |
| 280 | } |
| 281 | |
| 282 | my_data->acdb_handle = dlopen(LIB_ACDB_LOADER, RTLD_NOW); |
| 283 | if (my_data->acdb_handle == NULL) { |
| 284 | ALOGE("%s: DLOPEN failed for %s", __func__, LIB_ACDB_LOADER); |
| 285 | } else { |
| 286 | ALOGV("%s: DLOPEN successful for %s", __func__, LIB_ACDB_LOADER); |
| 287 | my_data->acdb_deallocate = (acdb_deallocate_t)dlsym(my_data->acdb_handle, |
| 288 | "acdb_loader_deallocate_ACDB"); |
| 289 | my_data->acdb_send_audio_cal = (acdb_send_audio_cal_t)dlsym(my_data->acdb_handle, |
| 290 | "acdb_loader_send_audio_cal"); |
| 291 | if (!my_data->acdb_send_audio_cal) |
| 292 | ALOGW("%s: Could not find the symbol acdb_send_audio_cal from %s", |
| 293 | __func__, LIB_ACDB_LOADER); |
| 294 | my_data->acdb_send_voice_cal = (acdb_send_voice_cal_t)dlsym(my_data->acdb_handle, |
| 295 | "acdb_loader_send_voice_cal"); |
| 296 | my_data->acdb_init = (acdb_init_t)dlsym(my_data->acdb_handle, |
| 297 | "acdb_loader_init_ACDB"); |
| 298 | if (my_data->acdb_init == NULL) |
| 299 | ALOGE("%s: dlsym error %s for acdb_loader_init_ACDB", __func__, dlerror()); |
| 300 | else |
| 301 | my_data->acdb_init(); |
| 302 | } |
| 303 | |
| 304 | /* If platform is Fusion3, load CSD Client specific symbols |
| 305 | * Voice call is handled by MDM and apps processor talks to |
| 306 | * MDM through CSD Client |
| 307 | */ |
| 308 | property_get("ro.board.platform", platform, ""); |
| 309 | property_get("ro.baseband", baseband, ""); |
| 310 | if (!strcmp("msm8960", platform) && !strcmp("mdm", baseband)) { |
| 311 | my_data->csd_client = dlopen(LIB_CSD_CLIENT, RTLD_NOW); |
| 312 | if (my_data->csd_client == NULL) |
| 313 | ALOGE("%s: DLOPEN failed for %s", __func__, LIB_CSD_CLIENT); |
| 314 | } |
| 315 | |
| 316 | if (my_data->csd_client) { |
| 317 | ALOGV("%s: DLOPEN successful for %s", __func__, LIB_CSD_CLIENT); |
| 318 | my_data->csd_client_deinit = (csd_client_deinit_t)dlsym(my_data->csd_client, |
| 319 | "csd_client_deinit"); |
| 320 | my_data->csd_disable_device = (csd_disable_device_t)dlsym(my_data->csd_client, |
| 321 | "csd_client_disable_device"); |
| 322 | my_data->csd_enable_device = (csd_enable_device_t)dlsym(my_data->csd_client, |
| 323 | "csd_client_enable_device"); |
| 324 | my_data->csd_start_voice = (csd_start_voice_t)dlsym(my_data->csd_client, |
| 325 | "csd_client_start_voice"); |
| 326 | my_data->csd_stop_voice = (csd_stop_voice_t)dlsym(my_data->csd_client, |
| 327 | "csd_client_stop_voice"); |
| 328 | my_data->csd_volume = (csd_volume_t)dlsym(my_data->csd_client, |
| 329 | "csd_client_volume"); |
| 330 | my_data->csd_mic_mute = (csd_mic_mute_t)dlsym(my_data->csd_client, |
| 331 | "csd_client_mic_mute"); |
| 332 | my_data->csd_client_init = (csd_client_init_t)dlsym(my_data->csd_client, |
| 333 | "csd_client_init"); |
| 334 | |
| 335 | if (my_data->csd_client_init == NULL) { |
| 336 | ALOGE("%s: dlsym error %s for csd_client_init", __func__, dlerror()); |
| 337 | } else { |
| 338 | my_data->csd_client_init(); |
| 339 | } |
| 340 | } |
| 341 | |
| 342 | return my_data; |
| 343 | } |
| 344 | |
| 345 | void platform_deinit(void *platform) |
| 346 | { |
Ravi Kumar Alamanda | 48c921d | 2013-10-29 06:07:44 -0700 | [diff] [blame] | 347 | struct platform_data *my_data = (struct platform_data *)platform; |
| 348 | |
Eric Laurent | b23d528 | 2013-05-14 15:27:20 -0700 | [diff] [blame] | 349 | free(platform); |
| 350 | } |
| 351 | |
| 352 | const char *platform_get_snd_device_name(snd_device_t snd_device) |
| 353 | { |
| 354 | if (snd_device >= SND_DEVICE_MIN && snd_device < SND_DEVICE_MAX) |
| 355 | return device_table[snd_device]; |
| 356 | else |
| 357 | return ""; |
| 358 | } |
| 359 | |
Ravi Kumar Alamanda | 48c921d | 2013-10-29 06:07:44 -0700 | [diff] [blame] | 360 | int platform_get_snd_device_name_extn(void *platform, snd_device_t snd_device, |
| 361 | char *device_name) |
| 362 | { |
| 363 | struct platform_data *my_data = (struct platform_data *)platform; |
| 364 | |
| 365 | if (snd_device >= SND_DEVICE_MIN && snd_device < SND_DEVICE_MAX) { |
| 366 | strlcpy(device_name, device_table[snd_device], DEVICE_NAME_MAX_SIZE); |
Ravi Kumar Alamanda | 48c921d | 2013-10-29 06:07:44 -0700 | [diff] [blame] | 367 | } else { |
| 368 | strlcpy(device_name, "", DEVICE_NAME_MAX_SIZE); |
| 369 | return -EINVAL; |
| 370 | } |
| 371 | |
| 372 | return 0; |
| 373 | } |
| 374 | |
Eric Laurent | b23d528 | 2013-05-14 15:27:20 -0700 | [diff] [blame] | 375 | void platform_add_backend_name(char *mixer_path, snd_device_t snd_device) |
| 376 | { |
| 377 | if (snd_device == SND_DEVICE_IN_BT_SCO_MIC) |
Shiv Maliyappanahalli | 34b585f | 2013-10-01 15:49:05 -0700 | [diff] [blame] | 378 | strlcat(mixer_path, " bt-sco", MIXER_PATH_MAX_LENGTH); |
| 379 | else if (snd_device == SND_DEVICE_IN_BT_SCO_MIC_WB) |
| 380 | strlcat(mixer_path, " bt-sco-wb", MIXER_PATH_MAX_LENGTH); |
Eric Laurent | b23d528 | 2013-05-14 15:27:20 -0700 | [diff] [blame] | 381 | else if(snd_device == SND_DEVICE_OUT_BT_SCO) |
Shiv Maliyappanahalli | 34b585f | 2013-10-01 15:49:05 -0700 | [diff] [blame] | 382 | strlcat(mixer_path, " bt-sco", MIXER_PATH_MAX_LENGTH); |
| 383 | else if(snd_device == SND_DEVICE_OUT_BT_SCO_WB) |
| 384 | strlcat(mixer_path, " bt-sco-wb", MIXER_PATH_MAX_LENGTH); |
Eric Laurent | b23d528 | 2013-05-14 15:27:20 -0700 | [diff] [blame] | 385 | else if (snd_device == SND_DEVICE_OUT_HDMI) |
Shiv Maliyappanahalli | 34b585f | 2013-10-01 15:49:05 -0700 | [diff] [blame] | 386 | strlcat(mixer_path, " hdmi", MIXER_PATH_MAX_LENGTH); |
Eric Laurent | b23d528 | 2013-05-14 15:27:20 -0700 | [diff] [blame] | 387 | else if (snd_device == SND_DEVICE_OUT_SPEAKER_AND_HDMI) |
Shiv Maliyappanahalli | 34b585f | 2013-10-01 15:49:05 -0700 | [diff] [blame] | 388 | strlcat(mixer_path, " speaker-and-hdmi", MIXER_PATH_MAX_LENGTH); |
Eric Laurent | b23d528 | 2013-05-14 15:27:20 -0700 | [diff] [blame] | 389 | } |
| 390 | |
| 391 | int platform_get_pcm_device_id(audio_usecase_t usecase, int device_type) |
| 392 | { |
| 393 | int device_id; |
| 394 | if (device_type == PCM_PLAYBACK) |
| 395 | device_id = pcm_device_table[usecase][0]; |
| 396 | else |
| 397 | device_id = pcm_device_table[usecase][1]; |
| 398 | return device_id; |
| 399 | } |
| 400 | |
Ravi Kumar Alamanda | bdf1416 | 2014-09-05 16:14:17 -0700 | [diff] [blame] | 401 | int platform_get_snd_device_index(char *snd_device_index_name __unused) |
Ben Romberger | 61764e3 | 2014-01-10 13:49:02 -0800 | [diff] [blame] | 402 | { |
| 403 | return -ENODEV; |
| 404 | } |
| 405 | |
Ravi Kumar Alamanda | bdf1416 | 2014-09-05 16:14:17 -0700 | [diff] [blame] | 406 | int platform_set_snd_device_acdb_id(snd_device_t snd_device __unused, |
| 407 | unsigned int acdb_id __unused) |
Ben Romberger | 5588688 | 2014-01-10 13:49:02 -0800 | [diff] [blame] | 408 | { |
| 409 | return -ENODEV; |
| 410 | } |
| 411 | |
Ravi Kumar Alamanda | bdf1416 | 2014-09-05 16:14:17 -0700 | [diff] [blame] | 412 | uint32_t platform_get_compress_offload_buffer_size(audio_offload_info_t* info __unused) |
| 413 | { |
| 414 | ALOGE("%s: Not implemented", __func__); |
| 415 | return -ENOSYS; |
| 416 | } |
| 417 | |
| 418 | int platform_get_snd_device_acdb_id(snd_device_t snd_device __unused) |
| 419 | { |
| 420 | ALOGE("%s: Not implemented", __func__); |
| 421 | return -ENOSYS; |
| 422 | } |
| 423 | |
Amit Shekhar | 5a39c91 | 2014-10-14 15:39:30 -0700 | [diff] [blame] | 424 | int platform_set_snd_device_bit_width(snd_device_t snd_device, unsigned int bit_width) |
| 425 | { |
| 426 | ALOGE("%s: Not implemented", __func__); |
| 427 | return -ENOSYS; |
| 428 | } |
| 429 | |
| 430 | int platform_get_snd_device_bit_width(snd_device_t snd_device) |
| 431 | { |
| 432 | ALOGE("%s: Not implemented", __func__); |
| 433 | return -ENOSYS; |
| 434 | } |
| 435 | |
Ravi Kumar Alamanda | bdf1416 | 2014-09-05 16:14:17 -0700 | [diff] [blame] | 436 | int platform_switch_voice_call_enable_device_config(void *platform __unused, |
| 437 | snd_device_t out_snd_device __unused, |
| 438 | snd_device_t in_snd_device __unused) |
| 439 | { |
| 440 | ALOGE("%s: Not implemented", __func__); |
| 441 | return -ENOSYS; |
| 442 | } |
| 443 | |
| 444 | int platform_switch_voice_call_usecase_route_post(void *platform __unused, |
| 445 | snd_device_t out_snd_device __unused, |
| 446 | snd_device_t in_snd_device __unused) |
| 447 | { |
| 448 | ALOGE("%s: Not implemented", __func__); |
| 449 | return -ENOSYS; |
| 450 | } |
| 451 | |
| 452 | int platform_set_incall_recording_session_id(void *platform __unused, |
| 453 | uint32_t session_id __unused, |
| 454 | int rec_mode __unused) |
| 455 | { |
| 456 | ALOGE("%s: Not implemented", __func__); |
| 457 | return -ENOSYS; |
| 458 | } |
| 459 | |
| 460 | int platform_stop_incall_recording_usecase(void *platform __unused) |
| 461 | { |
| 462 | ALOGE("%s: Not implemented", __func__); |
| 463 | return -ENOSYS; |
| 464 | } |
| 465 | |
| 466 | int platform_get_sample_rate(void *platform __unused, uint32_t *rate __unused) |
| 467 | { |
| 468 | ALOGE("%s: Not implemented", __func__); |
| 469 | return -ENOSYS; |
| 470 | } |
| 471 | |
| 472 | int platform_get_default_app_type(void *platform __unused) |
| 473 | { |
| 474 | ALOGE("%s: Not implemented", __func__); |
| 475 | return -ENOSYS; |
| 476 | } |
| 477 | |
| 478 | int platform_send_audio_calibration(void *platform, snd_device_t snd_device, |
| 479 | int app_type __unused, int sample_rate __unused) |
Eric Laurent | b23d528 | 2013-05-14 15:27:20 -0700 | [diff] [blame] | 480 | { |
| 481 | struct platform_data *my_data = (struct platform_data *)platform; |
| 482 | int acdb_dev_id, acdb_dev_type; |
| 483 | |
| 484 | acdb_dev_id = acdb_device_table[snd_device]; |
| 485 | if (acdb_dev_id < 0) { |
| 486 | ALOGE("%s: Could not find acdb id for device(%d)", |
| 487 | __func__, snd_device); |
| 488 | return -EINVAL; |
| 489 | } |
| 490 | if (my_data->acdb_send_audio_cal) { |
Eric Laurent | 994a693 | 2013-07-17 11:51:42 -0700 | [diff] [blame] | 491 | ("%s: sending audio calibration for snd_device(%d) acdb_id(%d)", |
Eric Laurent | b23d528 | 2013-05-14 15:27:20 -0700 | [diff] [blame] | 492 | __func__, snd_device, acdb_dev_id); |
| 493 | if (snd_device >= SND_DEVICE_OUT_BEGIN && |
| 494 | snd_device < SND_DEVICE_OUT_END) |
| 495 | acdb_dev_type = ACDB_DEV_TYPE_OUT; |
| 496 | else |
| 497 | acdb_dev_type = ACDB_DEV_TYPE_IN; |
| 498 | my_data->acdb_send_audio_cal(acdb_dev_id, acdb_dev_type); |
| 499 | } |
| 500 | return 0; |
| 501 | } |
| 502 | |
| 503 | int platform_switch_voice_call_device_pre(void *platform) |
| 504 | { |
| 505 | struct platform_data *my_data = (struct platform_data *)platform; |
| 506 | int ret = 0; |
| 507 | |
Ravi Kumar Alamanda | be14939 | 2014-10-20 17:07:43 -0700 | [diff] [blame] | 508 | if (my_data->csd_client != NULL && |
| 509 | voice_is_in_call(my_data->adev)) { |
Eric Laurent | b23d528 | 2013-05-14 15:27:20 -0700 | [diff] [blame] | 510 | /* This must be called before disabling the mixer controls on APQ side */ |
| 511 | if (my_data->csd_disable_device == NULL) { |
| 512 | ALOGE("%s: dlsym error for csd_disable_device", __func__); |
| 513 | } else { |
| 514 | ret = my_data->csd_disable_device(); |
| 515 | if (ret < 0) { |
| 516 | ALOGE("%s: csd_client_disable_device, failed, error %d", |
| 517 | __func__, ret); |
| 518 | } |
| 519 | } |
| 520 | } |
| 521 | return ret; |
| 522 | } |
| 523 | |
| 524 | int platform_switch_voice_call_device_post(void *platform, |
| 525 | snd_device_t out_snd_device, |
| 526 | snd_device_t in_snd_device) |
| 527 | { |
| 528 | struct platform_data *my_data = (struct platform_data *)platform; |
| 529 | int acdb_rx_id, acdb_tx_id; |
| 530 | int ret = 0; |
| 531 | |
| 532 | if (my_data->csd_client) { |
| 533 | if (my_data->csd_enable_device == NULL) { |
| 534 | ALOGE("%s: dlsym error for csd_enable_device", |
| 535 | __func__); |
| 536 | } else { |
| 537 | acdb_rx_id = acdb_device_table[out_snd_device]; |
| 538 | acdb_tx_id = acdb_device_table[in_snd_device]; |
| 539 | |
| 540 | if (acdb_rx_id > 0 || acdb_tx_id > 0) { |
| 541 | ret = my_data->csd_enable_device(acdb_rx_id, acdb_tx_id, |
| 542 | my_data->adev->acdb_settings); |
| 543 | if (ret < 0) { |
| 544 | ALOGE("%s: csd_enable_device, failed, error %d", |
| 545 | __func__, ret); |
| 546 | } |
| 547 | } else { |
| 548 | ALOGE("%s: Incorrect ACDB IDs (rx: %d tx: %d)", __func__, |
| 549 | acdb_rx_id, acdb_tx_id); |
| 550 | } |
| 551 | } |
| 552 | } |
| 553 | |
| 554 | return ret; |
| 555 | } |
| 556 | |
Ravi Kumar Alamanda | bdf1416 | 2014-09-05 16:14:17 -0700 | [diff] [blame] | 557 | int platform_start_voice_call(void *platform, uint32_t vsid __unused) |
Eric Laurent | b23d528 | 2013-05-14 15:27:20 -0700 | [diff] [blame] | 558 | { |
| 559 | struct platform_data *my_data = (struct platform_data *)platform; |
| 560 | int ret = 0; |
| 561 | |
| 562 | if (my_data->csd_client) { |
| 563 | if (my_data->csd_start_voice == NULL) { |
| 564 | ALOGE("dlsym error for csd_client_start_voice"); |
| 565 | ret = -ENOSYS; |
| 566 | } else { |
| 567 | ret = my_data->csd_start_voice(); |
| 568 | if (ret < 0) { |
| 569 | ALOGE("%s: csd_start_voice error %d\n", __func__, ret); |
| 570 | } |
| 571 | } |
| 572 | } |
| 573 | |
| 574 | return ret; |
| 575 | } |
| 576 | |
Ravi Kumar Alamanda | bdf1416 | 2014-09-05 16:14:17 -0700 | [diff] [blame] | 577 | int platform_stop_voice_call(void *platform, uint32_t vsid __unused) |
Eric Laurent | b23d528 | 2013-05-14 15:27:20 -0700 | [diff] [blame] | 578 | { |
| 579 | struct platform_data *my_data = (struct platform_data *)platform; |
| 580 | int ret = 0; |
| 581 | |
| 582 | if (my_data->csd_client) { |
| 583 | if (my_data->csd_stop_voice == NULL) { |
| 584 | ALOGE("dlsym error for csd_stop_voice"); |
| 585 | } else { |
| 586 | ret = my_data->csd_stop_voice(); |
| 587 | if (ret < 0) { |
| 588 | ALOGE("%s: csd_stop_voice error %d\n", __func__, ret); |
| 589 | } |
| 590 | } |
| 591 | } |
| 592 | |
| 593 | return ret; |
| 594 | } |
| 595 | |
| 596 | int platform_set_voice_volume(void *platform, int volume) |
| 597 | { |
| 598 | struct platform_data *my_data = (struct platform_data *)platform; |
| 599 | int ret = 0; |
| 600 | |
| 601 | if (my_data->csd_client) { |
| 602 | if (my_data->csd_volume == NULL) { |
| 603 | ALOGE("%s: dlsym error for csd_volume", __func__); |
| 604 | } else { |
| 605 | ret = my_data->csd_volume(volume); |
| 606 | if (ret < 0) { |
| 607 | ALOGE("%s: csd_volume error %d", __func__, ret); |
| 608 | } |
| 609 | } |
| 610 | } else { |
| 611 | ALOGE("%s: No CSD Client present", __func__); |
| 612 | } |
| 613 | |
| 614 | return ret; |
| 615 | } |
| 616 | |
| 617 | int platform_set_mic_mute(void *platform, bool state) |
| 618 | { |
| 619 | struct platform_data *my_data = (struct platform_data *)platform; |
| 620 | int ret = 0; |
| 621 | |
| 622 | if (my_data->adev->mode == AUDIO_MODE_IN_CALL) { |
| 623 | if (my_data->csd_client) { |
| 624 | if (my_data->csd_mic_mute == NULL) { |
| 625 | ALOGE("%s: dlsym error for csd_mic_mute", __func__); |
| 626 | } else { |
| 627 | ret = my_data->csd_mic_mute(state); |
| 628 | if (ret < 0) { |
| 629 | ALOGE("%s: csd_mic_mute error %d", __func__, ret); |
| 630 | } |
| 631 | } |
| 632 | } else { |
| 633 | ALOGE("%s: No CSD Client present", __func__); |
| 634 | } |
| 635 | } |
| 636 | |
| 637 | return ret; |
| 638 | } |
| 639 | |
Ravi Kumar Alamanda | bdf1416 | 2014-09-05 16:14:17 -0700 | [diff] [blame] | 640 | int platform_set_device_mute(void *platform __unused, bool state __unused, char *dir __unused) |
Shiv Maliyappanahalli | c6fd8ee | 2014-03-07 15:31:55 -0800 | [diff] [blame] | 641 | { |
Ravi Kumar Alamanda | bdf1416 | 2014-09-05 16:14:17 -0700 | [diff] [blame] | 642 | ALOGE("%s: Not implemented", __func__); |
Shiv Maliyappanahalli | c6fd8ee | 2014-03-07 15:31:55 -0800 | [diff] [blame] | 643 | return -ENOSYS; |
| 644 | } |
| 645 | |
Eric Laurent | b23d528 | 2013-05-14 15:27:20 -0700 | [diff] [blame] | 646 | snd_device_t platform_get_output_snd_device(void *platform, audio_devices_t devices) |
| 647 | { |
| 648 | struct platform_data *my_data = (struct platform_data *)platform; |
| 649 | struct audio_device *adev = my_data->adev; |
| 650 | audio_mode_t mode = adev->mode; |
| 651 | snd_device_t snd_device = SND_DEVICE_NONE; |
| 652 | |
| 653 | ALOGV("%s: enter: output devices(%#x)", __func__, devices); |
| 654 | if (devices == AUDIO_DEVICE_NONE || |
| 655 | devices & AUDIO_DEVICE_BIT_IN) { |
| 656 | ALOGV("%s: Invalid output devices (%#x)", __func__, devices); |
| 657 | goto exit; |
| 658 | } |
| 659 | |
Ravi Kumar Alamanda | be14939 | 2014-10-20 17:07:43 -0700 | [diff] [blame] | 660 | if (voice_is_in_call(adev)) { |
Eric Laurent | b23d528 | 2013-05-14 15:27:20 -0700 | [diff] [blame] | 661 | if (devices & AUDIO_DEVICE_OUT_WIRED_HEADPHONE || |
| 662 | devices & AUDIO_DEVICE_OUT_WIRED_HEADSET) { |
Ravi Kumar Alamanda | bdf1416 | 2014-09-05 16:14:17 -0700 | [diff] [blame] | 663 | if (adev->voice.tty_mode == TTY_MODE_FULL) |
Eric Laurent | b23d528 | 2013-05-14 15:27:20 -0700 | [diff] [blame] | 664 | snd_device = SND_DEVICE_OUT_VOICE_TTY_FULL_HEADPHONES; |
Ravi Kumar Alamanda | bdf1416 | 2014-09-05 16:14:17 -0700 | [diff] [blame] | 665 | else if (adev->voice.tty_mode == TTY_MODE_VCO) |
Eric Laurent | b23d528 | 2013-05-14 15:27:20 -0700 | [diff] [blame] | 666 | snd_device = SND_DEVICE_OUT_VOICE_TTY_VCO_HEADPHONES; |
Ravi Kumar Alamanda | bdf1416 | 2014-09-05 16:14:17 -0700 | [diff] [blame] | 667 | else if (adev->voice.tty_mode == TTY_MODE_HCO) |
Eric Laurent | b23d528 | 2013-05-14 15:27:20 -0700 | [diff] [blame] | 668 | snd_device = SND_DEVICE_OUT_VOICE_TTY_HCO_HANDSET; |
| 669 | else |
| 670 | snd_device = SND_DEVICE_OUT_VOICE_HEADPHONES; |
| 671 | } else if (devices & AUDIO_DEVICE_OUT_ALL_SCO) { |
Mingming Yin | 514a8bc | 2014-07-29 15:22:21 -0700 | [diff] [blame] | 672 | if (adev->bt_wb_speech_enabled) |
| 673 | snd_device = SND_DEVICE_OUT_BT_SCO_WB; |
| 674 | else |
| 675 | snd_device = SND_DEVICE_OUT_BT_SCO; |
Eric Laurent | b23d528 | 2013-05-14 15:27:20 -0700 | [diff] [blame] | 676 | } else if (devices & AUDIO_DEVICE_OUT_SPEAKER) { |
| 677 | snd_device = SND_DEVICE_OUT_VOICE_SPEAKER; |
| 678 | } else if (devices & AUDIO_DEVICE_OUT_EARPIECE) { |
Ravi Kumar Alamanda | ceb4082 | 2013-11-06 11:01:47 -0800 | [diff] [blame] | 679 | snd_device = SND_DEVICE_OUT_HANDSET; |
Eric Laurent | b23d528 | 2013-05-14 15:27:20 -0700 | [diff] [blame] | 680 | } |
| 681 | if (snd_device != SND_DEVICE_NONE) { |
| 682 | goto exit; |
| 683 | } |
| 684 | } |
| 685 | |
| 686 | if (popcount(devices) == 2) { |
| 687 | if (devices == (AUDIO_DEVICE_OUT_WIRED_HEADPHONE | |
| 688 | AUDIO_DEVICE_OUT_SPEAKER)) { |
| 689 | snd_device = SND_DEVICE_OUT_SPEAKER_AND_HEADPHONES; |
| 690 | } else if (devices == (AUDIO_DEVICE_OUT_WIRED_HEADSET | |
| 691 | AUDIO_DEVICE_OUT_SPEAKER)) { |
| 692 | snd_device = SND_DEVICE_OUT_SPEAKER_AND_HEADPHONES; |
| 693 | } else if (devices == (AUDIO_DEVICE_OUT_AUX_DIGITAL | |
| 694 | AUDIO_DEVICE_OUT_SPEAKER)) { |
| 695 | snd_device = SND_DEVICE_OUT_SPEAKER_AND_HDMI; |
| 696 | } else { |
| 697 | ALOGE("%s: Invalid combo device(%#x)", __func__, devices); |
| 698 | goto exit; |
| 699 | } |
| 700 | if (snd_device != SND_DEVICE_NONE) { |
| 701 | goto exit; |
| 702 | } |
| 703 | } |
| 704 | |
| 705 | if (popcount(devices) != 1) { |
| 706 | ALOGE("%s: Invalid output devices(%#x)", __func__, devices); |
| 707 | goto exit; |
| 708 | } |
| 709 | |
| 710 | if (devices & AUDIO_DEVICE_OUT_WIRED_HEADPHONE || |
| 711 | devices & AUDIO_DEVICE_OUT_WIRED_HEADSET) { |
| 712 | snd_device = SND_DEVICE_OUT_HEADPHONES; |
| 713 | } else if (devices & AUDIO_DEVICE_OUT_SPEAKER) { |
| 714 | if (adev->speaker_lr_swap) |
| 715 | snd_device = SND_DEVICE_OUT_SPEAKER_REVERSE; |
| 716 | else |
| 717 | snd_device = SND_DEVICE_OUT_SPEAKER; |
| 718 | } else if (devices & AUDIO_DEVICE_OUT_ALL_SCO) { |
Mingming Yin | 514a8bc | 2014-07-29 15:22:21 -0700 | [diff] [blame] | 719 | if (adev->bt_wb_speech_enabled) |
| 720 | snd_device = SND_DEVICE_OUT_BT_SCO_WB; |
| 721 | else |
| 722 | snd_device = SND_DEVICE_OUT_BT_SCO; |
Eric Laurent | b23d528 | 2013-05-14 15:27:20 -0700 | [diff] [blame] | 723 | } else if (devices & AUDIO_DEVICE_OUT_AUX_DIGITAL) { |
| 724 | snd_device = SND_DEVICE_OUT_HDMI ; |
| 725 | } else if (devices & AUDIO_DEVICE_OUT_EARPIECE) { |
| 726 | snd_device = SND_DEVICE_OUT_HANDSET; |
| 727 | } else { |
| 728 | ALOGE("%s: Unknown device(s) %#x", __func__, devices); |
| 729 | } |
| 730 | exit: |
| 731 | ALOGV("%s: exit: snd_device(%s)", __func__, device_table[snd_device]); |
| 732 | return snd_device; |
| 733 | } |
| 734 | |
| 735 | snd_device_t platform_get_input_snd_device(void *platform, audio_devices_t out_device) |
| 736 | { |
| 737 | struct platform_data *my_data = (struct platform_data *)platform; |
| 738 | struct audio_device *adev = my_data->adev; |
| 739 | audio_source_t source = (adev->active_input == NULL) ? |
| 740 | AUDIO_SOURCE_DEFAULT : adev->active_input->source; |
| 741 | |
| 742 | audio_mode_t mode = adev->mode; |
| 743 | audio_devices_t in_device = ((adev->active_input == NULL) ? |
| 744 | AUDIO_DEVICE_NONE : adev->active_input->device) |
| 745 | & ~AUDIO_DEVICE_BIT_IN; |
| 746 | audio_channel_mask_t channel_mask = (adev->active_input == NULL) ? |
| 747 | AUDIO_CHANNEL_IN_MONO : adev->active_input->channel_mask; |
| 748 | snd_device_t snd_device = SND_DEVICE_NONE; |
| 749 | |
| 750 | ALOGV("%s: enter: out_device(%#x) in_device(%#x)", |
| 751 | __func__, out_device, in_device); |
Ravi Kumar Alamanda | be14939 | 2014-10-20 17:07:43 -0700 | [diff] [blame] | 752 | if ((out_device != AUDIO_DEVICE_NONE) && voice_is_in_call(adev)) { |
Ravi Kumar Alamanda | bdf1416 | 2014-09-05 16:14:17 -0700 | [diff] [blame] | 753 | if (adev->voice.tty_mode != TTY_MODE_OFF) { |
Eric Laurent | b23d528 | 2013-05-14 15:27:20 -0700 | [diff] [blame] | 754 | if (out_device & AUDIO_DEVICE_OUT_WIRED_HEADPHONE || |
| 755 | out_device & AUDIO_DEVICE_OUT_WIRED_HEADSET) { |
Ravi Kumar Alamanda | bdf1416 | 2014-09-05 16:14:17 -0700 | [diff] [blame] | 756 | switch (adev->voice.tty_mode) { |
Eric Laurent | b23d528 | 2013-05-14 15:27:20 -0700 | [diff] [blame] | 757 | case TTY_MODE_FULL: |
| 758 | snd_device = SND_DEVICE_IN_VOICE_TTY_FULL_HEADSET_MIC; |
| 759 | break; |
| 760 | case TTY_MODE_VCO: |
| 761 | snd_device = SND_DEVICE_IN_VOICE_TTY_VCO_HANDSET_MIC; |
| 762 | break; |
| 763 | case TTY_MODE_HCO: |
| 764 | snd_device = SND_DEVICE_IN_VOICE_TTY_HCO_HEADSET_MIC; |
| 765 | break; |
| 766 | default: |
Ravi Kumar Alamanda | bdf1416 | 2014-09-05 16:14:17 -0700 | [diff] [blame] | 767 | ALOGE("%s: Invalid TTY mode (%#x)", __func__, adev->voice.tty_mode); |
Eric Laurent | b23d528 | 2013-05-14 15:27:20 -0700 | [diff] [blame] | 768 | } |
| 769 | goto exit; |
| 770 | } |
| 771 | } |
| 772 | if (out_device & AUDIO_DEVICE_OUT_EARPIECE || |
| 773 | out_device & AUDIO_DEVICE_OUT_WIRED_HEADPHONE) { |
Mingming Yin | 8e5a4f6 | 2013-10-07 15:23:41 -0700 | [diff] [blame] | 774 | if (my_data->fluence_type == FLUENCE_NONE || |
| 775 | my_data->fluence_in_voice_call == false) { |
Eric Laurent | b23d528 | 2013-05-14 15:27:20 -0700 | [diff] [blame] | 776 | snd_device = SND_DEVICE_IN_HANDSET_MIC; |
| 777 | } else { |
Ravi Kumar Alamanda | ceb4082 | 2013-11-06 11:01:47 -0800 | [diff] [blame] | 778 | snd_device = SND_DEVICE_IN_VOICE_DMIC; |
Mingming Yin | 8e5a4f6 | 2013-10-07 15:23:41 -0700 | [diff] [blame] | 779 | adev->acdb_settings |= DMIC_FLAG; |
Eric Laurent | b23d528 | 2013-05-14 15:27:20 -0700 | [diff] [blame] | 780 | } |
| 781 | } else if (out_device & AUDIO_DEVICE_OUT_WIRED_HEADSET) { |
| 782 | snd_device = SND_DEVICE_IN_VOICE_HEADSET_MIC; |
| 783 | } else if (out_device & AUDIO_DEVICE_OUT_ALL_SCO) { |
Mingming Yin | 514a8bc | 2014-07-29 15:22:21 -0700 | [diff] [blame] | 784 | if (adev->bt_wb_speech_enabled) |
| 785 | snd_device = SND_DEVICE_IN_BT_SCO_MIC_WB; |
| 786 | else |
| 787 | snd_device = SND_DEVICE_IN_BT_SCO_MIC; |
Eric Laurent | b23d528 | 2013-05-14 15:27:20 -0700 | [diff] [blame] | 788 | } else if (out_device & AUDIO_DEVICE_OUT_SPEAKER) { |
Mingming Yin | 8e5a4f6 | 2013-10-07 15:23:41 -0700 | [diff] [blame] | 789 | if (my_data->fluence_type != FLUENCE_NONE && |
| 790 | my_data->fluence_in_voice_call && |
| 791 | my_data->fluence_in_spkr_mode) { |
| 792 | if(my_data->fluence_type == FLUENCE_DUAL_MIC) { |
| 793 | adev->acdb_settings |= DMIC_FLAG; |
| 794 | snd_device = SND_DEVICE_IN_VOICE_SPEAKER_DMIC; |
| 795 | } else { |
| 796 | adev->acdb_settings |= QMIC_FLAG; |
| 797 | snd_device = SND_DEVICE_IN_VOICE_SPEAKER_QMIC; |
| 798 | } |
Eric Laurent | b23d528 | 2013-05-14 15:27:20 -0700 | [diff] [blame] | 799 | } else { |
| 800 | snd_device = SND_DEVICE_IN_VOICE_SPEAKER_MIC; |
| 801 | } |
| 802 | } |
| 803 | } else if (source == AUDIO_SOURCE_CAMCORDER) { |
| 804 | if (in_device & AUDIO_DEVICE_IN_BUILTIN_MIC || |
| 805 | in_device & AUDIO_DEVICE_IN_BACK_MIC) { |
| 806 | snd_device = SND_DEVICE_IN_CAMCORDER_MIC; |
| 807 | } |
| 808 | } else if (source == AUDIO_SOURCE_VOICE_RECOGNITION) { |
| 809 | if (in_device & AUDIO_DEVICE_IN_BUILTIN_MIC) { |
Mingming Yin | 8e5a4f6 | 2013-10-07 15:23:41 -0700 | [diff] [blame] | 810 | if (channel_mask == AUDIO_CHANNEL_IN_FRONT_BACK) |
| 811 | snd_device = SND_DEVICE_IN_VOICE_REC_DMIC; |
| 812 | else if (my_data->fluence_in_voice_rec) |
| 813 | snd_device = SND_DEVICE_IN_VOICE_REC_DMIC_FLUENCE; |
Eric Laurent | b23d528 | 2013-05-14 15:27:20 -0700 | [diff] [blame] | 814 | |
Mingming Yin | 8e5a4f6 | 2013-10-07 15:23:41 -0700 | [diff] [blame] | 815 | if (snd_device == SND_DEVICE_NONE) |
Eric Laurent | b23d528 | 2013-05-14 15:27:20 -0700 | [diff] [blame] | 816 | snd_device = SND_DEVICE_IN_VOICE_REC_MIC; |
Mingming Yin | 8e5a4f6 | 2013-10-07 15:23:41 -0700 | [diff] [blame] | 817 | else |
| 818 | adev->acdb_settings |= DMIC_FLAG; |
Eric Laurent | b23d528 | 2013-05-14 15:27:20 -0700 | [diff] [blame] | 819 | } |
| 820 | } else if (source == AUDIO_SOURCE_VOICE_COMMUNICATION) { |
| 821 | if (out_device & AUDIO_DEVICE_OUT_SPEAKER) |
| 822 | in_device = AUDIO_DEVICE_IN_BACK_MIC; |
| 823 | if (adev->active_input) { |
| 824 | if (adev->active_input->enable_aec) { |
| 825 | if (in_device & AUDIO_DEVICE_IN_BACK_MIC) { |
| 826 | snd_device = SND_DEVICE_IN_SPEAKER_MIC_AEC; |
| 827 | } else if (in_device & AUDIO_DEVICE_IN_BUILTIN_MIC) { |
| 828 | snd_device = SND_DEVICE_IN_HANDSET_MIC_AEC; |
| 829 | } else if (in_device & AUDIO_DEVICE_IN_WIRED_HEADSET) { |
| 830 | snd_device = SND_DEVICE_IN_HEADSET_MIC_AEC; |
| 831 | } |
Venkata Narendra Kumar Gutta | 1bbbf54 | 2014-09-04 19:11:25 +0530 | [diff] [blame] | 832 | platform_set_echo_reference(adev->platform, true); |
Eric Laurent | b23d528 | 2013-05-14 15:27:20 -0700 | [diff] [blame] | 833 | } else |
Venkata Narendra Kumar Gutta | 1bbbf54 | 2014-09-04 19:11:25 +0530 | [diff] [blame] | 834 | platform_set_echo_reference(adev->platform, false); |
Eric Laurent | b23d528 | 2013-05-14 15:27:20 -0700 | [diff] [blame] | 835 | } |
| 836 | } else if (source == AUDIO_SOURCE_DEFAULT) { |
| 837 | goto exit; |
| 838 | } |
| 839 | |
| 840 | |
| 841 | if (snd_device != SND_DEVICE_NONE) { |
| 842 | goto exit; |
| 843 | } |
| 844 | |
| 845 | if (in_device != AUDIO_DEVICE_NONE && |
| 846 | !(in_device & AUDIO_DEVICE_IN_VOICE_CALL) && |
| 847 | !(in_device & AUDIO_DEVICE_IN_COMMUNICATION)) { |
| 848 | if (in_device & AUDIO_DEVICE_IN_BUILTIN_MIC) { |
| 849 | snd_device = SND_DEVICE_IN_HANDSET_MIC; |
| 850 | } else if (in_device & AUDIO_DEVICE_IN_BACK_MIC) { |
| 851 | snd_device = SND_DEVICE_IN_SPEAKER_MIC; |
| 852 | } else if (in_device & AUDIO_DEVICE_IN_WIRED_HEADSET) { |
| 853 | snd_device = SND_DEVICE_IN_HEADSET_MIC; |
| 854 | } else if (in_device & AUDIO_DEVICE_IN_BLUETOOTH_SCO_HEADSET) { |
Mingming Yin | 514a8bc | 2014-07-29 15:22:21 -0700 | [diff] [blame] | 855 | if (adev->bt_wb_speech_enabled) |
| 856 | snd_device = SND_DEVICE_IN_BT_SCO_MIC_WB; |
| 857 | else |
| 858 | snd_device = SND_DEVICE_IN_BT_SCO_MIC; |
Eric Laurent | b23d528 | 2013-05-14 15:27:20 -0700 | [diff] [blame] | 859 | } else if (in_device & AUDIO_DEVICE_IN_AUX_DIGITAL) { |
| 860 | snd_device = SND_DEVICE_IN_HDMI_MIC; |
| 861 | } else { |
| 862 | ALOGE("%s: Unknown input device(s) %#x", __func__, in_device); |
| 863 | ALOGW("%s: Using default handset-mic", __func__); |
| 864 | snd_device = SND_DEVICE_IN_HANDSET_MIC; |
| 865 | } |
| 866 | } else { |
| 867 | if (out_device & AUDIO_DEVICE_OUT_EARPIECE) { |
| 868 | snd_device = SND_DEVICE_IN_HANDSET_MIC; |
| 869 | } else if (out_device & AUDIO_DEVICE_OUT_WIRED_HEADSET) { |
| 870 | snd_device = SND_DEVICE_IN_HEADSET_MIC; |
| 871 | } else if (out_device & AUDIO_DEVICE_OUT_SPEAKER) { |
| 872 | snd_device = SND_DEVICE_IN_SPEAKER_MIC; |
| 873 | } else if (out_device & AUDIO_DEVICE_OUT_WIRED_HEADPHONE) { |
| 874 | snd_device = SND_DEVICE_IN_HANDSET_MIC; |
| 875 | } else if (out_device & AUDIO_DEVICE_OUT_BLUETOOTH_SCO_HEADSET) { |
Mingming Yin | 514a8bc | 2014-07-29 15:22:21 -0700 | [diff] [blame] | 876 | if (adev->bt_wb_speech_enabled) |
| 877 | snd_device = SND_DEVICE_IN_BT_SCO_MIC_WB; |
| 878 | else |
| 879 | snd_device = SND_DEVICE_IN_BT_SCO_MIC; |
Eric Laurent | b23d528 | 2013-05-14 15:27:20 -0700 | [diff] [blame] | 880 | } else if (out_device & AUDIO_DEVICE_OUT_AUX_DIGITAL) { |
| 881 | snd_device = SND_DEVICE_IN_HDMI_MIC; |
| 882 | } else { |
| 883 | ALOGE("%s: Unknown output device(s) %#x", __func__, out_device); |
| 884 | ALOGW("%s: Using default handset-mic", __func__); |
| 885 | snd_device = SND_DEVICE_IN_HANDSET_MIC; |
| 886 | } |
| 887 | } |
| 888 | exit: |
| 889 | ALOGV("%s: exit: in_snd_device(%s)", __func__, device_table[snd_device]); |
| 890 | return snd_device; |
| 891 | } |
| 892 | |
| 893 | int platform_set_hdmi_channels(void *platform, int channel_count) |
| 894 | { |
| 895 | struct platform_data *my_data = (struct platform_data *)platform; |
| 896 | struct audio_device *adev = my_data->adev; |
| 897 | struct mixer_ctl *ctl; |
| 898 | const char *channel_cnt_str = NULL; |
| 899 | const char *mixer_ctl_name = "HDMI_RX Channels"; |
| 900 | switch (channel_count) { |
| 901 | case 8: |
| 902 | channel_cnt_str = "Eight"; break; |
| 903 | case 7: |
| 904 | channel_cnt_str = "Seven"; break; |
| 905 | case 6: |
| 906 | channel_cnt_str = "Six"; break; |
| 907 | case 5: |
| 908 | channel_cnt_str = "Five"; break; |
| 909 | case 4: |
| 910 | channel_cnt_str = "Four"; break; |
| 911 | case 3: |
| 912 | channel_cnt_str = "Three"; break; |
| 913 | default: |
| 914 | channel_cnt_str = "Two"; break; |
| 915 | } |
| 916 | ctl = mixer_get_ctl_by_name(adev->mixer, mixer_ctl_name); |
| 917 | if (!ctl) { |
| 918 | ALOGE("%s: Could not get ctl for mixer cmd - %s", |
| 919 | __func__, mixer_ctl_name); |
| 920 | return -EINVAL; |
| 921 | } |
| 922 | ALOGV("HDMI channel count: %s", channel_cnt_str); |
| 923 | mixer_ctl_set_enum_by_string(ctl, channel_cnt_str); |
| 924 | return 0; |
| 925 | } |
| 926 | |
Ravi Kumar Alamanda | bdf1416 | 2014-09-05 16:14:17 -0700 | [diff] [blame] | 927 | int platform_edid_get_max_channels(void *platform __unused) |
Eric Laurent | b23d528 | 2013-05-14 15:27:20 -0700 | [diff] [blame] | 928 | { |
| 929 | FILE *file; |
| 930 | struct audio_block_header header; |
| 931 | char block[MAX_SAD_BLOCKS * SAD_BLOCK_SIZE]; |
| 932 | char *sad = block; |
| 933 | int num_audio_blocks; |
| 934 | int channel_count; |
| 935 | int max_channels = 0; |
| 936 | int i; |
| 937 | |
| 938 | file = fopen(AUDIO_DATA_BLOCK_PATH, "rb"); |
| 939 | if (file == NULL) { |
| 940 | ALOGE("Unable to open '%s'", AUDIO_DATA_BLOCK_PATH); |
| 941 | return 0; |
| 942 | } |
| 943 | |
| 944 | /* Read audio block header */ |
| 945 | fread(&header, 1, sizeof(header), file); |
| 946 | |
| 947 | /* Read SAD blocks, clamping the maximum size for safety */ |
| 948 | if (header.length > (int)sizeof(block)) |
| 949 | header.length = (int)sizeof(block); |
| 950 | fread(&block, header.length, 1, file); |
| 951 | |
| 952 | fclose(file); |
| 953 | |
| 954 | /* Calculate the number of SAD blocks */ |
| 955 | num_audio_blocks = header.length / SAD_BLOCK_SIZE; |
| 956 | |
| 957 | for (i = 0; i < num_audio_blocks; i++) { |
| 958 | /* Only consider LPCM blocks */ |
| 959 | if ((sad[0] >> 3) != EDID_FORMAT_LPCM) |
| 960 | continue; |
| 961 | |
| 962 | channel_count = (sad[0] & 0x7) + 1; |
| 963 | if (channel_count > max_channels) |
| 964 | max_channels = channel_count; |
| 965 | |
| 966 | /* Advance to next block */ |
| 967 | sad += 3; |
| 968 | } |
| 969 | |
| 970 | return max_channels; |
| 971 | } |
Shiv Maliyappanahalli | 34b585f | 2013-10-01 15:49:05 -0700 | [diff] [blame] | 972 | |
Ravi Kumar Alamanda | bdf1416 | 2014-09-05 16:14:17 -0700 | [diff] [blame] | 973 | void platform_get_parameters(void *platform __unused, |
| 974 | struct str_parms *query __unused, |
| 975 | struct str_parms *reply __unused) |
Shiv Maliyappanahalli | 34b585f | 2013-10-01 15:49:05 -0700 | [diff] [blame] | 976 | { |
Ravi Kumar Alamanda | bdf1416 | 2014-09-05 16:14:17 -0700 | [diff] [blame] | 977 | ALOGE("%s: Not implemented", __func__); |
Shiv Maliyappanahalli | 34b585f | 2013-10-01 15:49:05 -0700 | [diff] [blame] | 978 | } |
| 979 | |
Ravi Kumar Alamanda | bdf1416 | 2014-09-05 16:14:17 -0700 | [diff] [blame] | 980 | int platform_set_parameters(void *platform __unused, struct str_parms *parms __unused) |
Shiv Maliyappanahalli | 34b585f | 2013-10-01 15:49:05 -0700 | [diff] [blame] | 981 | { |
Ravi Kumar Alamanda | bdf1416 | 2014-09-05 16:14:17 -0700 | [diff] [blame] | 982 | ALOGE("%s: Not implemented", __func__); |
Shiv Maliyappanahalli | 34b585f | 2013-10-01 15:49:05 -0700 | [diff] [blame] | 983 | return -ENOSYS; |
| 984 | } |
Shiv Maliyappanahalli | da10764 | 2013-10-17 11:16:13 -0700 | [diff] [blame] | 985 | |
Ravi Kumar Alamanda | bdf1416 | 2014-09-05 16:14:17 -0700 | [diff] [blame] | 986 | int platform_set_incall_recoding_session_id(void *platform __unused, |
| 987 | uint32_t session_id __unused) |
Shiv Maliyappanahalli | da10764 | 2013-10-17 11:16:13 -0700 | [diff] [blame] | 988 | { |
Ravi Kumar Alamanda | bdf1416 | 2014-09-05 16:14:17 -0700 | [diff] [blame] | 989 | ALOGE("%s: Not implemented", __func__); |
Shiv Maliyappanahalli | da10764 | 2013-10-17 11:16:13 -0700 | [diff] [blame] | 990 | return -ENOSYS; |
| 991 | } |
Shruthi Krishna | ace1085 | 2013-10-25 14:32:12 -0700 | [diff] [blame] | 992 | |
Vidyakumar Athota | 21b3bb9 | 2014-04-25 11:08:08 -0700 | [diff] [blame] | 993 | int platform_update_lch(void *platform __unused, |
| 994 | struct voice_session *session __unused, |
| 995 | enum voice_lch_mode lch_mode __unused) |
| 996 | { |
Ravi Kumar Alamanda | bdf1416 | 2014-09-05 16:14:17 -0700 | [diff] [blame] | 997 | ALOGE("%s: Not implemented", __func__); |
| 998 | return -ENOSYS; |
| 999 | } |
| 1000 | |
| 1001 | int platform_start_incall_music_usecase(void *platform __unused) |
| 1002 | { |
| 1003 | ALOGE("%s: Not implemented", __func__); |
| 1004 | return -ENOSYS; |
| 1005 | } |
| 1006 | |
| 1007 | int platform_stop_incall_music_usecase(void *platform __unused) |
| 1008 | { |
| 1009 | ALOGE("%s: Not implemented", __func__); |
Vidyakumar Athota | 21b3bb9 | 2014-04-25 11:08:08 -0700 | [diff] [blame] | 1010 | return -ENOSYS; |
| 1011 | } |
| 1012 | |
Haynes Mathew George | 7ff216f | 2013-09-11 19:51:41 -0700 | [diff] [blame] | 1013 | /* Delay in Us */ |
| 1014 | int64_t platform_render_latency(audio_usecase_t usecase) |
| 1015 | { |
| 1016 | switch (usecase) { |
| 1017 | case USECASE_AUDIO_PLAYBACK_DEEP_BUFFER: |
| 1018 | return DEEP_BUFFER_PLATFORM_DELAY; |
| 1019 | case USECASE_AUDIO_PLAYBACK_LOW_LATENCY: |
| 1020 | return LOW_LATENCY_PLATFORM_DELAY; |
| 1021 | default: |
| 1022 | return 0; |
| 1023 | } |
| 1024 | } |
Mingming Yin | e62d784 | 2013-10-25 16:26:03 -0700 | [diff] [blame] | 1025 | |
| 1026 | int platform_update_usecase_from_source(int source, int usecase) |
| 1027 | { |
| 1028 | ALOGV("%s: input source :%d", __func__, source); |
| 1029 | return usecase; |
| 1030 | } |
Kiran Kandi | de144c8 | 2013-11-20 15:58:32 -0800 | [diff] [blame] | 1031 | |
Ravi Kumar Alamanda | bdf1416 | 2014-09-05 16:14:17 -0700 | [diff] [blame] | 1032 | bool platform_listen_device_needs_event(snd_device_t snd_device __unused) |
Kiran Kandi | de144c8 | 2013-11-20 15:58:32 -0800 | [diff] [blame] | 1033 | { |
Dhananjay Kumar | 45b7174 | 2014-05-29 21:47:27 +0530 | [diff] [blame] | 1034 | return false; |
| 1035 | } |
| 1036 | |
Ravi Kumar Alamanda | bdf1416 | 2014-09-05 16:14:17 -0700 | [diff] [blame] | 1037 | bool platform_listen_usecase_needs_event(audio_usecase_t uc_id __unused) |
Dhananjay Kumar | 45b7174 | 2014-05-29 21:47:27 +0530 | [diff] [blame] | 1038 | { |
| 1039 | return false; |
Kiran Kandi | de144c8 | 2013-11-20 15:58:32 -0800 | [diff] [blame] | 1040 | } |
Mingming Yin | 3ee55c6 | 2014-08-04 14:23:35 -0700 | [diff] [blame] | 1041 | |
Ravi Kumar Alamanda | bdf1416 | 2014-09-05 16:14:17 -0700 | [diff] [blame] | 1042 | bool platform_check_and_set_codec_backend_cfg(struct audio_device* adev __unused, |
| 1043 | struct audio_usecase *usecase __unused) |
| 1044 | { |
Mingming Yin | 3ee55c6 | 2014-08-04 14:23:35 -0700 | [diff] [blame] | 1045 | return false; |
| 1046 | } |
| 1047 | |
Haynes Mathew George | f4da6fe | 2014-06-20 19:14:25 -0700 | [diff] [blame] | 1048 | int platform_get_usecase_index(const char * usecase __unused) |
| 1049 | { |
| 1050 | return -ENOSYS; |
| 1051 | } |
| 1052 | |
| 1053 | int platform_set_usecase_pcm_id(audio_usecase_t usecase __unused, int32_t type __unused, |
| 1054 | int32_t pcm_id __unused) |
| 1055 | { |
| 1056 | return -ENOSYS; |
| 1057 | } |
| 1058 | |
| 1059 | int platform_set_snd_device_backend(snd_device_t snd_device __unused, |
| 1060 | const char * backend __unused) |
| 1061 | { |
| 1062 | return -ENOSYS; |
| 1063 | } |
Ravi Kumar Alamanda | 8fa6b19 | 2014-09-09 16:06:42 -0700 | [diff] [blame] | 1064 | |
| 1065 | bool platform_sound_trigger_device_needs_event(snd_device_t snd_device __unused) |
| 1066 | { |
| 1067 | return false; |
| 1068 | } |
| 1069 | |
| 1070 | bool platform_sound_trigger_usecase_needs_event(audio_usecase_t uc_id __unused) |
| 1071 | { |
| 1072 | return false; |
| 1073 | } |
Ravi Kumar Alamanda | bdf1416 | 2014-09-05 16:14:17 -0700 | [diff] [blame] | 1074 | |
| 1075 | int platform_set_fluence_type(void *platform __unused, char *value __unused) |
| 1076 | { |
| 1077 | return -ENOSYS; |
| 1078 | } |
| 1079 | |
| 1080 | int platform_get_fluence_type(void *platform __unused, char *value __unused, |
| 1081 | uint32_t len __unused) |
| 1082 | { |
| 1083 | return -ENOSYS; |
| 1084 | } |
| 1085 | |
| 1086 | uint32_t platform_get_pcm_offload_buffer_size(audio_offload_info_t* info __unused) |
| 1087 | { |
| 1088 | return 0; |
| 1089 | } |