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