Eric Laurent | b23d528 | 2013-05-14 15:27:20 -0700 | [diff] [blame] | 1 | /* |
Dhananjay Kumar | 429eb45 | 2018-12-10 22:26:53 +0530 | [diff] [blame] | 2 | * Copyright (c) 2013-2019, 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> |
Weiyin Jiang | 2995f66 | 2019-04-17 14:25:12 +0800 | [diff] [blame] | 26 | #include <log/log.h> |
Eric Laurent | b23d528 | 2013-05-14 15:27:20 -0700 | [diff] [blame] | 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 | |
Aniket Kumar Lata | 8fc67e6 | 2017-05-02 12:33:46 -0700 | [diff] [blame] | 260 | property_get("ro.vendor.audio.sdk.fluencetype", value, ""); |
Mingming Yin | 8e5a4f6 | 2013-10-07 15:23:41 -0700 | [diff] [blame] | 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) { |
Aniket Kumar Lata | 8fc67e6 | 2017-05-02 12:33:46 -0700 | [diff] [blame] | 270 | property_get("persist.vendor.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 | |
Aniket Kumar Lata | 8fc67e6 | 2017-05-02 12:33:46 -0700 | [diff] [blame] | 275 | property_get("persist.vendor.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 | |
Aniket Kumar Lata | 8fc67e6 | 2017-05-02 12:33:46 -0700 | [diff] [blame] | 280 | property_get("persist.vendor.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 | |
Dhananjay Kumar | 429eb45 | 2018-12-10 22:26:53 +0530 | [diff] [blame] | 356 | struct audio_custom_mtmx_params * |
| 357 | platform_get_custom_mtmx_params |
| 358 | ( |
| 359 | void *platform __unused, |
Chaithanya Krishna Bacharaju | 3e94c91 | 2019-05-27 11:25:44 +0530 | [diff] [blame] | 360 | struct audio_custom_mtmx_params_info *info __unused, |
| 361 | uint32_t *idx __unused |
Dhananjay Kumar | 429eb45 | 2018-12-10 22:26:53 +0530 | [diff] [blame] | 362 | ) |
| 363 | { |
| 364 | ALOGW("%s: not implemented!", __func__); |
| 365 | return NULL; |
| 366 | } |
| 367 | |
| 368 | int platform_add_custom_mtmx_params |
| 369 | ( |
| 370 | void *platform __unused, |
| 371 | struct audio_custom_mtmx_params_info *info __unused |
| 372 | ) |
| 373 | { |
| 374 | ALOGW("%s: not implemented!", __func__); |
| 375 | return -ENOSYS; |
| 376 | } |
| 377 | |
Chaithanya Krishna Bacharaju | c9f9971 | 2019-04-16 15:32:52 +0530 | [diff] [blame] | 378 | struct audio_custom_mtmx_in_params *platform_get_custom_mtmx_in_params(void *platform, |
| 379 | struct audio_custom_mtmx_in_params_info *info) |
| 380 | { |
| 381 | ALOGW("%s: not implemented!", __func__); |
| 382 | return -ENOSYS; |
| 383 | } |
| 384 | |
| 385 | int platform_add_custom_mtmx_in_params(void *platform, |
| 386 | struct audio_custom_mtmx_in_params_info *info) |
| 387 | { |
| 388 | ALOGW("%s: not implemented!", __func__); |
| 389 | return -ENOSYS; |
| 390 | } |
| 391 | |
Eric Laurent | b23d528 | 2013-05-14 15:27:20 -0700 | [diff] [blame] | 392 | void platform_deinit(void *platform) |
| 393 | { |
Ravi Kumar Alamanda | 48c921d | 2013-10-29 06:07:44 -0700 | [diff] [blame] | 394 | struct platform_data *my_data = (struct platform_data *)platform; |
| 395 | |
Eric Laurent | b23d528 | 2013-05-14 15:27:20 -0700 | [diff] [blame] | 396 | free(platform); |
| 397 | } |
| 398 | |
| 399 | const char *platform_get_snd_device_name(snd_device_t snd_device) |
| 400 | { |
| 401 | if (snd_device >= SND_DEVICE_MIN && snd_device < SND_DEVICE_MAX) |
| 402 | return device_table[snd_device]; |
| 403 | else |
| 404 | return ""; |
| 405 | } |
| 406 | |
Ravi Kumar Alamanda | 48c921d | 2013-10-29 06:07:44 -0700 | [diff] [blame] | 407 | int platform_get_snd_device_name_extn(void *platform, snd_device_t snd_device, |
| 408 | char *device_name) |
| 409 | { |
| 410 | struct platform_data *my_data = (struct platform_data *)platform; |
| 411 | |
| 412 | if (snd_device >= SND_DEVICE_MIN && snd_device < SND_DEVICE_MAX) { |
| 413 | strlcpy(device_name, device_table[snd_device], DEVICE_NAME_MAX_SIZE); |
Ravi Kumar Alamanda | 48c921d | 2013-10-29 06:07:44 -0700 | [diff] [blame] | 414 | } else { |
| 415 | strlcpy(device_name, "", DEVICE_NAME_MAX_SIZE); |
| 416 | return -EINVAL; |
| 417 | } |
| 418 | |
| 419 | return 0; |
| 420 | } |
| 421 | |
Banajit Goswami | 20cdd21 | 2015-09-11 01:11:30 -0700 | [diff] [blame] | 422 | 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] | 423 | struct audio_usecase *usecase __unused) |
Eric Laurent | b23d528 | 2013-05-14 15:27:20 -0700 | [diff] [blame] | 424 | { |
| 425 | if (snd_device == SND_DEVICE_IN_BT_SCO_MIC) |
Shiv Maliyappanahalli | 34b585f | 2013-10-01 15:49:05 -0700 | [diff] [blame] | 426 | strlcat(mixer_path, " bt-sco", MIXER_PATH_MAX_LENGTH); |
| 427 | else if (snd_device == SND_DEVICE_IN_BT_SCO_MIC_WB) |
| 428 | strlcat(mixer_path, " bt-sco-wb", MIXER_PATH_MAX_LENGTH); |
Eric Laurent | b23d528 | 2013-05-14 15:27:20 -0700 | [diff] [blame] | 429 | else if(snd_device == SND_DEVICE_OUT_BT_SCO) |
Shiv Maliyappanahalli | 34b585f | 2013-10-01 15:49:05 -0700 | [diff] [blame] | 430 | strlcat(mixer_path, " bt-sco", MIXER_PATH_MAX_LENGTH); |
| 431 | else if(snd_device == SND_DEVICE_OUT_BT_SCO_WB) |
| 432 | strlcat(mixer_path, " bt-sco-wb", MIXER_PATH_MAX_LENGTH); |
Eric Laurent | b23d528 | 2013-05-14 15:27:20 -0700 | [diff] [blame] | 433 | else if (snd_device == SND_DEVICE_OUT_HDMI) |
Shiv Maliyappanahalli | 34b585f | 2013-10-01 15:49:05 -0700 | [diff] [blame] | 434 | strlcat(mixer_path, " hdmi", MIXER_PATH_MAX_LENGTH); |
Eric Laurent | b23d528 | 2013-05-14 15:27:20 -0700 | [diff] [blame] | 435 | else if (snd_device == SND_DEVICE_OUT_SPEAKER_AND_HDMI) |
Shiv Maliyappanahalli | 34b585f | 2013-10-01 15:49:05 -0700 | [diff] [blame] | 436 | strlcat(mixer_path, " speaker-and-hdmi", MIXER_PATH_MAX_LENGTH); |
Eric Laurent | b23d528 | 2013-05-14 15:27:20 -0700 | [diff] [blame] | 437 | } |
| 438 | |
| 439 | int platform_get_pcm_device_id(audio_usecase_t usecase, int device_type) |
| 440 | { |
Mingshu Pang | 1513f97 | 2019-05-24 12:43:51 +0800 | [diff] [blame] | 441 | int device_id = -1; |
| 442 | |
| 443 | if ((usecase >= AUDIO_USECASE_MAX) || (usecase <= USECASE_INVALID)) { |
| 444 | ALOGE("%s: invalid usecase case idx %d", __func__, usecase); |
| 445 | return device_id; |
| 446 | } |
Eric Laurent | b23d528 | 2013-05-14 15:27:20 -0700 | [diff] [blame] | 447 | if (device_type == PCM_PLAYBACK) |
| 448 | device_id = pcm_device_table[usecase][0]; |
| 449 | else |
| 450 | device_id = pcm_device_table[usecase][1]; |
| 451 | return device_id; |
| 452 | } |
| 453 | |
Ravi Kumar Alamanda | bdf1416 | 2014-09-05 16:14:17 -0700 | [diff] [blame] | 454 | int platform_get_snd_device_index(char *snd_device_index_name __unused) |
Ben Romberger | 61764e3 | 2014-01-10 13:49:02 -0800 | [diff] [blame] | 455 | { |
| 456 | return -ENODEV; |
| 457 | } |
| 458 | |
Ravi Kumar Alamanda | bdf1416 | 2014-09-05 16:14:17 -0700 | [diff] [blame] | 459 | int platform_set_snd_device_acdb_id(snd_device_t snd_device __unused, |
| 460 | unsigned int acdb_id __unused) |
Ben Romberger | 5588688 | 2014-01-10 13:49:02 -0800 | [diff] [blame] | 461 | { |
| 462 | return -ENODEV; |
| 463 | } |
| 464 | |
Ravi Kumar Alamanda | bdf1416 | 2014-09-05 16:14:17 -0700 | [diff] [blame] | 465 | uint32_t platform_get_compress_offload_buffer_size(audio_offload_info_t* info __unused) |
| 466 | { |
| 467 | ALOGE("%s: Not implemented", __func__); |
| 468 | return -ENOSYS; |
| 469 | } |
| 470 | |
| 471 | int platform_get_snd_device_acdb_id(snd_device_t snd_device __unused) |
| 472 | { |
| 473 | ALOGE("%s: Not implemented", __func__); |
| 474 | return -ENOSYS; |
| 475 | } |
| 476 | |
Carter Hsu | 32a6236 | 2018-10-15 15:01:42 -0700 | [diff] [blame] | 477 | void platform_add_external_specific_device(snd_device_t snd_device __unused, |
| 478 | const char *name __unused, |
| 479 | unsigned int acdb_id __unused) |
| 480 | { |
| 481 | return; |
| 482 | } |
| 483 | |
Pradnya Chaphekar | 4403bd7 | 2014-09-09 09:50:01 -0700 | [diff] [blame] | 484 | int platform_set_snd_device_bit_width(snd_device_t snd_device __unused, |
| 485 | unsigned int bit_width __unused) |
Amit Shekhar | 5a39c91 | 2014-10-14 15:39:30 -0700 | [diff] [blame] | 486 | { |
| 487 | ALOGE("%s: Not implemented", __func__); |
| 488 | return -ENOSYS; |
| 489 | } |
| 490 | |
Pradnya Chaphekar | 4403bd7 | 2014-09-09 09:50:01 -0700 | [diff] [blame] | 491 | 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] | 492 | { |
| 493 | ALOGE("%s: Not implemented", __func__); |
| 494 | return -ENOSYS; |
| 495 | } |
| 496 | |
Ravi Kumar Alamanda | bdf1416 | 2014-09-05 16:14:17 -0700 | [diff] [blame] | 497 | int platform_switch_voice_call_enable_device_config(void *platform __unused, |
| 498 | snd_device_t out_snd_device __unused, |
| 499 | snd_device_t in_snd_device __unused) |
| 500 | { |
| 501 | ALOGE("%s: Not implemented", __func__); |
| 502 | return -ENOSYS; |
| 503 | } |
| 504 | |
| 505 | int platform_switch_voice_call_usecase_route_post(void *platform __unused, |
| 506 | snd_device_t out_snd_device __unused, |
| 507 | snd_device_t in_snd_device __unused) |
| 508 | { |
| 509 | ALOGE("%s: Not implemented", __func__); |
| 510 | return -ENOSYS; |
| 511 | } |
| 512 | |
| 513 | int platform_set_incall_recording_session_id(void *platform __unused, |
| 514 | uint32_t session_id __unused, |
| 515 | int rec_mode __unused) |
| 516 | { |
| 517 | ALOGE("%s: Not implemented", __func__); |
| 518 | return -ENOSYS; |
| 519 | } |
| 520 | |
| 521 | int platform_stop_incall_recording_usecase(void *platform __unused) |
| 522 | { |
| 523 | ALOGE("%s: Not implemented", __func__); |
| 524 | return -ENOSYS; |
| 525 | } |
| 526 | |
| 527 | int platform_get_sample_rate(void *platform __unused, uint32_t *rate __unused) |
| 528 | { |
| 529 | ALOGE("%s: Not implemented", __func__); |
| 530 | return -ENOSYS; |
| 531 | } |
| 532 | |
| 533 | int platform_get_default_app_type(void *platform __unused) |
| 534 | { |
| 535 | ALOGE("%s: Not implemented", __func__); |
| 536 | return -ENOSYS; |
| 537 | } |
| 538 | |
Preetam Singh Ranawat | 2d0e463 | 2015-02-02 12:40:59 +0530 | [diff] [blame] | 539 | int platform_send_audio_calibration(void *platform, struct audio_usecase *usecase, |
Zhou Song | 06761dd | 2019-04-28 18:08:17 +0800 | [diff] [blame] | 540 | int app_type __unused) |
Eric Laurent | b23d528 | 2013-05-14 15:27:20 -0700 | [diff] [blame] | 541 | { |
| 542 | struct platform_data *my_data = (struct platform_data *)platform; |
| 543 | int acdb_dev_id, acdb_dev_type; |
Preetam Singh Ranawat | 2d0e463 | 2015-02-02 12:40:59 +0530 | [diff] [blame] | 544 | struct audio_device *adev = my_data->adev; |
| 545 | int snd_device = SND_DEVICE_OUT_SPEAKER; |
Eric Laurent | b23d528 | 2013-05-14 15:27:20 -0700 | [diff] [blame] | 546 | |
Preetam Singh Ranawat | 2d0e463 | 2015-02-02 12:40:59 +0530 | [diff] [blame] | 547 | if (usecase->type == PCM_PLAYBACK) |
| 548 | snd_device = platform_get_output_snd_device(adev->platform, |
| 549 | usecase->stream.out->devices); |
Karthik Reddy Katta | 81c4261 | 2015-11-13 17:49:07 +0530 | [diff] [blame] | 550 | else if ((usecase->type == PCM_CAPTURE) && |
| 551 | voice_is_in_call_rec_stream(usecase->stream.in)) |
| 552 | 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] | 553 | else if ((usecase->type == PCM_HFP_CALL) || (usecase->type == PCM_CAPTURE)) |
Eric Laurent | 637e2d4 | 2018-11-15 12:24:31 -0800 | [diff] [blame] | 554 | snd_device = platform_get_input_snd_device(adev->platform, NULL, |
Preetam Singh Ranawat | 2d0e463 | 2015-02-02 12:40:59 +0530 | [diff] [blame] | 555 | adev->primary_output->devices); |
Eric Laurent | b23d528 | 2013-05-14 15:27:20 -0700 | [diff] [blame] | 556 | acdb_dev_id = acdb_device_table[snd_device]; |
| 557 | if (acdb_dev_id < 0) { |
| 558 | ALOGE("%s: Could not find acdb id for device(%d)", |
| 559 | __func__, snd_device); |
| 560 | return -EINVAL; |
| 561 | } |
Weiyin Jiang | 27dd145 | 2019-07-12 23:46:06 +0800 | [diff] [blame] | 562 | |
| 563 | /* Notify device change info to effect clients registered */ |
| 564 | if (usecase->type == PCM_PLAYBACK) { |
| 565 | audio_extn_gef_notify_device_config( |
| 566 | usecase->stream.out->devices, |
| 567 | usecase->stream.out->channel_mask, |
| 568 | usecase->stream.out->app_type_cfg.sample_rate, |
| 569 | acdb_dev_id, |
| 570 | usecase->stream.out->app_type_cfg.app_type); |
| 571 | } |
| 572 | |
Eric Laurent | b23d528 | 2013-05-14 15:27:20 -0700 | [diff] [blame] | 573 | if (my_data->acdb_send_audio_cal) { |
Eric Laurent | 994a693 | 2013-07-17 11:51:42 -0700 | [diff] [blame] | 574 | ("%s: sending audio calibration for snd_device(%d) acdb_id(%d)", |
Eric Laurent | b23d528 | 2013-05-14 15:27:20 -0700 | [diff] [blame] | 575 | __func__, snd_device, acdb_dev_id); |
| 576 | if (snd_device >= SND_DEVICE_OUT_BEGIN && |
| 577 | snd_device < SND_DEVICE_OUT_END) |
| 578 | acdb_dev_type = ACDB_DEV_TYPE_OUT; |
| 579 | else |
| 580 | acdb_dev_type = ACDB_DEV_TYPE_IN; |
| 581 | my_data->acdb_send_audio_cal(acdb_dev_id, acdb_dev_type); |
| 582 | } |
| 583 | return 0; |
| 584 | } |
| 585 | |
| 586 | int platform_switch_voice_call_device_pre(void *platform) |
| 587 | { |
| 588 | struct platform_data *my_data = (struct platform_data *)platform; |
| 589 | int ret = 0; |
| 590 | |
Ravi Kumar Alamanda | be14939 | 2014-10-20 17:07:43 -0700 | [diff] [blame] | 591 | if (my_data->csd_client != NULL && |
| 592 | voice_is_in_call(my_data->adev)) { |
Eric Laurent | b23d528 | 2013-05-14 15:27:20 -0700 | [diff] [blame] | 593 | /* This must be called before disabling the mixer controls on APQ side */ |
| 594 | if (my_data->csd_disable_device == NULL) { |
| 595 | ALOGE("%s: dlsym error for csd_disable_device", __func__); |
| 596 | } else { |
| 597 | ret = my_data->csd_disable_device(); |
| 598 | if (ret < 0) { |
| 599 | ALOGE("%s: csd_client_disable_device, failed, error %d", |
| 600 | __func__, ret); |
| 601 | } |
| 602 | } |
| 603 | } |
| 604 | return ret; |
| 605 | } |
| 606 | |
| 607 | int platform_switch_voice_call_device_post(void *platform, |
| 608 | snd_device_t out_snd_device, |
| 609 | snd_device_t in_snd_device) |
| 610 | { |
| 611 | struct platform_data *my_data = (struct platform_data *)platform; |
| 612 | int acdb_rx_id, acdb_tx_id; |
| 613 | int ret = 0; |
| 614 | |
| 615 | if (my_data->csd_client) { |
| 616 | if (my_data->csd_enable_device == NULL) { |
| 617 | ALOGE("%s: dlsym error for csd_enable_device", |
| 618 | __func__); |
| 619 | } else { |
| 620 | acdb_rx_id = acdb_device_table[out_snd_device]; |
| 621 | acdb_tx_id = acdb_device_table[in_snd_device]; |
| 622 | |
| 623 | if (acdb_rx_id > 0 || acdb_tx_id > 0) { |
| 624 | ret = my_data->csd_enable_device(acdb_rx_id, acdb_tx_id, |
| 625 | my_data->adev->acdb_settings); |
| 626 | if (ret < 0) { |
| 627 | ALOGE("%s: csd_enable_device, failed, error %d", |
| 628 | __func__, ret); |
| 629 | } |
| 630 | } else { |
| 631 | ALOGE("%s: Incorrect ACDB IDs (rx: %d tx: %d)", __func__, |
| 632 | acdb_rx_id, acdb_tx_id); |
| 633 | } |
| 634 | } |
| 635 | } |
| 636 | |
| 637 | return ret; |
| 638 | } |
| 639 | |
Ravi Kumar Alamanda | bdf1416 | 2014-09-05 16:14:17 -0700 | [diff] [blame] | 640 | int platform_start_voice_call(void *platform, uint32_t vsid __unused) |
Eric Laurent | b23d528 | 2013-05-14 15:27:20 -0700 | [diff] [blame] | 641 | { |
| 642 | struct platform_data *my_data = (struct platform_data *)platform; |
| 643 | int ret = 0; |
| 644 | |
| 645 | if (my_data->csd_client) { |
| 646 | if (my_data->csd_start_voice == NULL) { |
| 647 | ALOGE("dlsym error for csd_client_start_voice"); |
| 648 | ret = -ENOSYS; |
| 649 | } else { |
| 650 | ret = my_data->csd_start_voice(); |
| 651 | if (ret < 0) { |
| 652 | ALOGE("%s: csd_start_voice error %d\n", __func__, ret); |
| 653 | } |
| 654 | } |
| 655 | } |
| 656 | |
| 657 | return ret; |
| 658 | } |
| 659 | |
Ravi Kumar Alamanda | bdf1416 | 2014-09-05 16:14:17 -0700 | [diff] [blame] | 660 | int platform_stop_voice_call(void *platform, uint32_t vsid __unused) |
Eric Laurent | b23d528 | 2013-05-14 15:27:20 -0700 | [diff] [blame] | 661 | { |
| 662 | struct platform_data *my_data = (struct platform_data *)platform; |
| 663 | int ret = 0; |
| 664 | |
| 665 | if (my_data->csd_client) { |
| 666 | if (my_data->csd_stop_voice == NULL) { |
| 667 | ALOGE("dlsym error for csd_stop_voice"); |
| 668 | } else { |
| 669 | ret = my_data->csd_stop_voice(); |
| 670 | if (ret < 0) { |
| 671 | ALOGE("%s: csd_stop_voice error %d\n", __func__, ret); |
| 672 | } |
| 673 | } |
| 674 | } |
| 675 | |
| 676 | return ret; |
| 677 | } |
| 678 | |
| 679 | int platform_set_voice_volume(void *platform, int volume) |
| 680 | { |
| 681 | struct platform_data *my_data = (struct platform_data *)platform; |
| 682 | int ret = 0; |
| 683 | |
| 684 | if (my_data->csd_client) { |
| 685 | if (my_data->csd_volume == NULL) { |
| 686 | ALOGE("%s: dlsym error for csd_volume", __func__); |
| 687 | } else { |
| 688 | ret = my_data->csd_volume(volume); |
| 689 | if (ret < 0) { |
| 690 | ALOGE("%s: csd_volume error %d", __func__, ret); |
| 691 | } |
| 692 | } |
| 693 | } else { |
| 694 | ALOGE("%s: No CSD Client present", __func__); |
| 695 | } |
| 696 | |
| 697 | return ret; |
| 698 | } |
| 699 | |
| 700 | int platform_set_mic_mute(void *platform, bool state) |
| 701 | { |
| 702 | struct platform_data *my_data = (struct platform_data *)platform; |
| 703 | int ret = 0; |
| 704 | |
| 705 | if (my_data->adev->mode == AUDIO_MODE_IN_CALL) { |
| 706 | if (my_data->csd_client) { |
| 707 | if (my_data->csd_mic_mute == NULL) { |
| 708 | ALOGE("%s: dlsym error for csd_mic_mute", __func__); |
| 709 | } else { |
| 710 | ret = my_data->csd_mic_mute(state); |
| 711 | if (ret < 0) { |
| 712 | ALOGE("%s: csd_mic_mute error %d", __func__, ret); |
| 713 | } |
| 714 | } |
| 715 | } else { |
| 716 | ALOGE("%s: No CSD Client present", __func__); |
| 717 | } |
| 718 | } |
| 719 | |
| 720 | return ret; |
| 721 | } |
| 722 | |
Ravi Kumar Alamanda | bdf1416 | 2014-09-05 16:14:17 -0700 | [diff] [blame] | 723 | 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] | 724 | { |
Ravi Kumar Alamanda | bdf1416 | 2014-09-05 16:14:17 -0700 | [diff] [blame] | 725 | ALOGE("%s: Not implemented", __func__); |
Shiv Maliyappanahalli | c6fd8ee | 2014-03-07 15:31:55 -0800 | [diff] [blame] | 726 | return -ENOSYS; |
| 727 | } |
| 728 | |
Shiv Maliyappanahalli | c065640 | 2016-09-03 14:13:26 -0700 | [diff] [blame] | 729 | int platform_get_ext_disp_type(void *platform) |
| 730 | { |
| 731 | return EXT_DISPLAY_TYPE_HDMI; |
| 732 | } |
| 733 | |
Eric Laurent | b23d528 | 2013-05-14 15:27:20 -0700 | [diff] [blame] | 734 | snd_device_t platform_get_output_snd_device(void *platform, audio_devices_t devices) |
| 735 | { |
| 736 | struct platform_data *my_data = (struct platform_data *)platform; |
| 737 | struct audio_device *adev = my_data->adev; |
| 738 | audio_mode_t mode = adev->mode; |
| 739 | snd_device_t snd_device = SND_DEVICE_NONE; |
| 740 | |
| 741 | ALOGV("%s: enter: output devices(%#x)", __func__, devices); |
| 742 | if (devices == AUDIO_DEVICE_NONE || |
| 743 | devices & AUDIO_DEVICE_BIT_IN) { |
| 744 | ALOGV("%s: Invalid output devices (%#x)", __func__, devices); |
| 745 | goto exit; |
| 746 | } |
| 747 | |
Venkata Narendra Kumar Gutta | bfdfa15 | 2015-06-22 14:25:35 +0530 | [diff] [blame] | 748 | if (mode == AUDIO_MODE_IN_CALL) { |
Eric Laurent | b23d528 | 2013-05-14 15:27:20 -0700 | [diff] [blame] | 749 | if (devices & AUDIO_DEVICE_OUT_WIRED_HEADPHONE || |
| 750 | devices & AUDIO_DEVICE_OUT_WIRED_HEADSET) { |
Ravi Kumar Alamanda | bdf1416 | 2014-09-05 16:14:17 -0700 | [diff] [blame] | 751 | if (adev->voice.tty_mode == TTY_MODE_FULL) |
Eric Laurent | b23d528 | 2013-05-14 15:27:20 -0700 | [diff] [blame] | 752 | snd_device = SND_DEVICE_OUT_VOICE_TTY_FULL_HEADPHONES; |
Ravi Kumar Alamanda | bdf1416 | 2014-09-05 16:14:17 -0700 | [diff] [blame] | 753 | else if (adev->voice.tty_mode == TTY_MODE_VCO) |
Eric Laurent | b23d528 | 2013-05-14 15:27:20 -0700 | [diff] [blame] | 754 | snd_device = SND_DEVICE_OUT_VOICE_TTY_VCO_HEADPHONES; |
Ravi Kumar Alamanda | bdf1416 | 2014-09-05 16:14:17 -0700 | [diff] [blame] | 755 | else if (adev->voice.tty_mode == TTY_MODE_HCO) |
Eric Laurent | b23d528 | 2013-05-14 15:27:20 -0700 | [diff] [blame] | 756 | snd_device = SND_DEVICE_OUT_VOICE_TTY_HCO_HANDSET; |
| 757 | else |
| 758 | snd_device = SND_DEVICE_OUT_VOICE_HEADPHONES; |
| 759 | } else if (devices & AUDIO_DEVICE_OUT_ALL_SCO) { |
Mingming Yin | 514a8bc | 2014-07-29 15:22:21 -0700 | [diff] [blame] | 760 | if (adev->bt_wb_speech_enabled) |
| 761 | snd_device = SND_DEVICE_OUT_BT_SCO_WB; |
| 762 | else |
| 763 | snd_device = SND_DEVICE_OUT_BT_SCO; |
Eric Laurent | b23d528 | 2013-05-14 15:27:20 -0700 | [diff] [blame] | 764 | } else if (devices & AUDIO_DEVICE_OUT_SPEAKER) { |
| 765 | snd_device = SND_DEVICE_OUT_VOICE_SPEAKER; |
| 766 | } else if (devices & AUDIO_DEVICE_OUT_EARPIECE) { |
Ravi Kumar Alamanda | ceb4082 | 2013-11-06 11:01:47 -0800 | [diff] [blame] | 767 | snd_device = SND_DEVICE_OUT_HANDSET; |
Eric Laurent | b23d528 | 2013-05-14 15:27:20 -0700 | [diff] [blame] | 768 | } |
| 769 | if (snd_device != SND_DEVICE_NONE) { |
| 770 | goto exit; |
| 771 | } |
| 772 | } |
| 773 | |
| 774 | if (popcount(devices) == 2) { |
| 775 | if (devices == (AUDIO_DEVICE_OUT_WIRED_HEADPHONE | |
| 776 | AUDIO_DEVICE_OUT_SPEAKER)) { |
| 777 | snd_device = SND_DEVICE_OUT_SPEAKER_AND_HEADPHONES; |
| 778 | } else if (devices == (AUDIO_DEVICE_OUT_WIRED_HEADSET | |
| 779 | AUDIO_DEVICE_OUT_SPEAKER)) { |
| 780 | snd_device = SND_DEVICE_OUT_SPEAKER_AND_HEADPHONES; |
| 781 | } else if (devices == (AUDIO_DEVICE_OUT_AUX_DIGITAL | |
| 782 | AUDIO_DEVICE_OUT_SPEAKER)) { |
| 783 | snd_device = SND_DEVICE_OUT_SPEAKER_AND_HDMI; |
| 784 | } else { |
| 785 | ALOGE("%s: Invalid combo device(%#x)", __func__, devices); |
| 786 | goto exit; |
| 787 | } |
| 788 | if (snd_device != SND_DEVICE_NONE) { |
| 789 | goto exit; |
| 790 | } |
| 791 | } |
| 792 | |
| 793 | if (popcount(devices) != 1) { |
| 794 | ALOGE("%s: Invalid output devices(%#x)", __func__, devices); |
| 795 | goto exit; |
| 796 | } |
| 797 | |
| 798 | if (devices & AUDIO_DEVICE_OUT_WIRED_HEADPHONE || |
| 799 | devices & AUDIO_DEVICE_OUT_WIRED_HEADSET) { |
| 800 | snd_device = SND_DEVICE_OUT_HEADPHONES; |
| 801 | } else if (devices & AUDIO_DEVICE_OUT_SPEAKER) { |
| 802 | if (adev->speaker_lr_swap) |
| 803 | snd_device = SND_DEVICE_OUT_SPEAKER_REVERSE; |
| 804 | else |
| 805 | snd_device = SND_DEVICE_OUT_SPEAKER; |
| 806 | } else if (devices & AUDIO_DEVICE_OUT_ALL_SCO) { |
Mingming Yin | 514a8bc | 2014-07-29 15:22:21 -0700 | [diff] [blame] | 807 | if (adev->bt_wb_speech_enabled) |
| 808 | snd_device = SND_DEVICE_OUT_BT_SCO_WB; |
| 809 | else |
| 810 | snd_device = SND_DEVICE_OUT_BT_SCO; |
Eric Laurent | b23d528 | 2013-05-14 15:27:20 -0700 | [diff] [blame] | 811 | } else if (devices & AUDIO_DEVICE_OUT_AUX_DIGITAL) { |
| 812 | snd_device = SND_DEVICE_OUT_HDMI ; |
| 813 | } else if (devices & AUDIO_DEVICE_OUT_EARPIECE) { |
| 814 | snd_device = SND_DEVICE_OUT_HANDSET; |
| 815 | } else { |
| 816 | ALOGE("%s: Unknown device(s) %#x", __func__, devices); |
| 817 | } |
| 818 | exit: |
| 819 | ALOGV("%s: exit: snd_device(%s)", __func__, device_table[snd_device]); |
| 820 | return snd_device; |
| 821 | } |
| 822 | |
Eric Laurent | 637e2d4 | 2018-11-15 12:24:31 -0800 | [diff] [blame] | 823 | snd_device_t platform_get_input_snd_device(void *platform, |
| 824 | struct stream_in *in, |
| 825 | audio_devices_t out_device) |
Eric Laurent | b23d528 | 2013-05-14 15:27:20 -0700 | [diff] [blame] | 826 | { |
| 827 | struct platform_data *my_data = (struct platform_data *)platform; |
| 828 | struct audio_device *adev = my_data->adev; |
Eric Laurent | 637e2d4 | 2018-11-15 12:24:31 -0800 | [diff] [blame] | 829 | audio_mode_t mode = adev->mode; |
Eric Laurent | b23d528 | 2013-05-14 15:27:20 -0700 | [diff] [blame] | 830 | snd_device_t snd_device = SND_DEVICE_NONE; |
| 831 | |
Eric Laurent | 637e2d4 | 2018-11-15 12:24:31 -0800 | [diff] [blame] | 832 | if (in == NULL) |
| 833 | in = adev_get_active_input(adev); |
| 834 | |
| 835 | audio_source_t source = (in == NULL) ? AUDIO_SOURCE_DEFAULT : in->source; |
| 836 | audio_devices_t in_device = |
| 837 | ((in == NULL) ? AUDIO_DEVICE_NONE : in->device) & ~AUDIO_DEVICE_BIT_IN; |
| 838 | audio_channel_mask_t channel_mask = (in == NULL) ? AUDIO_CHANNEL_IN_MONO : in->channel_mask; |
| 839 | |
Eric Laurent | b23d528 | 2013-05-14 15:27:20 -0700 | [diff] [blame] | 840 | ALOGV("%s: enter: out_device(%#x) in_device(%#x)", |
| 841 | __func__, out_device, in_device); |
Venkata Narendra Kumar Gutta | bfdfa15 | 2015-06-22 14:25:35 +0530 | [diff] [blame] | 842 | if ((out_device != AUDIO_DEVICE_NONE) && (mode == AUDIO_MODE_IN_CALL)) { |
Ravi Kumar Alamanda | bdf1416 | 2014-09-05 16:14:17 -0700 | [diff] [blame] | 843 | if (adev->voice.tty_mode != TTY_MODE_OFF) { |
Eric Laurent | b23d528 | 2013-05-14 15:27:20 -0700 | [diff] [blame] | 844 | if (out_device & AUDIO_DEVICE_OUT_WIRED_HEADPHONE || |
| 845 | out_device & AUDIO_DEVICE_OUT_WIRED_HEADSET) { |
Ravi Kumar Alamanda | bdf1416 | 2014-09-05 16:14:17 -0700 | [diff] [blame] | 846 | switch (adev->voice.tty_mode) { |
Eric Laurent | b23d528 | 2013-05-14 15:27:20 -0700 | [diff] [blame] | 847 | case TTY_MODE_FULL: |
| 848 | snd_device = SND_DEVICE_IN_VOICE_TTY_FULL_HEADSET_MIC; |
| 849 | break; |
| 850 | case TTY_MODE_VCO: |
| 851 | snd_device = SND_DEVICE_IN_VOICE_TTY_VCO_HANDSET_MIC; |
| 852 | break; |
| 853 | case TTY_MODE_HCO: |
| 854 | snd_device = SND_DEVICE_IN_VOICE_TTY_HCO_HEADSET_MIC; |
| 855 | break; |
| 856 | default: |
Ravi Kumar Alamanda | bdf1416 | 2014-09-05 16:14:17 -0700 | [diff] [blame] | 857 | ALOGE("%s: Invalid TTY mode (%#x)", __func__, adev->voice.tty_mode); |
Eric Laurent | b23d528 | 2013-05-14 15:27:20 -0700 | [diff] [blame] | 858 | } |
| 859 | goto exit; |
| 860 | } |
| 861 | } |
| 862 | if (out_device & AUDIO_DEVICE_OUT_EARPIECE || |
| 863 | out_device & AUDIO_DEVICE_OUT_WIRED_HEADPHONE) { |
Mingming Yin | 8e5a4f6 | 2013-10-07 15:23:41 -0700 | [diff] [blame] | 864 | if (my_data->fluence_type == FLUENCE_NONE || |
| 865 | my_data->fluence_in_voice_call == false) { |
Eric Laurent | b23d528 | 2013-05-14 15:27:20 -0700 | [diff] [blame] | 866 | snd_device = SND_DEVICE_IN_HANDSET_MIC; |
| 867 | } else { |
Ravi Kumar Alamanda | ceb4082 | 2013-11-06 11:01:47 -0800 | [diff] [blame] | 868 | snd_device = SND_DEVICE_IN_VOICE_DMIC; |
Mingming Yin | 8e5a4f6 | 2013-10-07 15:23:41 -0700 | [diff] [blame] | 869 | adev->acdb_settings |= DMIC_FLAG; |
Eric Laurent | b23d528 | 2013-05-14 15:27:20 -0700 | [diff] [blame] | 870 | } |
| 871 | } else if (out_device & AUDIO_DEVICE_OUT_WIRED_HEADSET) { |
| 872 | snd_device = SND_DEVICE_IN_VOICE_HEADSET_MIC; |
| 873 | } else if (out_device & AUDIO_DEVICE_OUT_ALL_SCO) { |
Mingming Yin | 514a8bc | 2014-07-29 15:22:21 -0700 | [diff] [blame] | 874 | if (adev->bt_wb_speech_enabled) |
| 875 | snd_device = SND_DEVICE_IN_BT_SCO_MIC_WB; |
| 876 | else |
| 877 | snd_device = SND_DEVICE_IN_BT_SCO_MIC; |
Eric Laurent | b23d528 | 2013-05-14 15:27:20 -0700 | [diff] [blame] | 878 | } else if (out_device & AUDIO_DEVICE_OUT_SPEAKER) { |
Mingming Yin | 8e5a4f6 | 2013-10-07 15:23:41 -0700 | [diff] [blame] | 879 | if (my_data->fluence_type != FLUENCE_NONE && |
| 880 | my_data->fluence_in_voice_call && |
| 881 | my_data->fluence_in_spkr_mode) { |
| 882 | if(my_data->fluence_type == FLUENCE_DUAL_MIC) { |
| 883 | adev->acdb_settings |= DMIC_FLAG; |
| 884 | snd_device = SND_DEVICE_IN_VOICE_SPEAKER_DMIC; |
| 885 | } else { |
| 886 | adev->acdb_settings |= QMIC_FLAG; |
| 887 | snd_device = SND_DEVICE_IN_VOICE_SPEAKER_QMIC; |
| 888 | } |
Eric Laurent | b23d528 | 2013-05-14 15:27:20 -0700 | [diff] [blame] | 889 | } else { |
| 890 | snd_device = SND_DEVICE_IN_VOICE_SPEAKER_MIC; |
| 891 | } |
| 892 | } |
| 893 | } else if (source == AUDIO_SOURCE_CAMCORDER) { |
| 894 | if (in_device & AUDIO_DEVICE_IN_BUILTIN_MIC || |
| 895 | in_device & AUDIO_DEVICE_IN_BACK_MIC) { |
| 896 | snd_device = SND_DEVICE_IN_CAMCORDER_MIC; |
| 897 | } |
| 898 | } else if (source == AUDIO_SOURCE_VOICE_RECOGNITION) { |
| 899 | if (in_device & AUDIO_DEVICE_IN_BUILTIN_MIC) { |
Mingming Yin | 8e5a4f6 | 2013-10-07 15:23:41 -0700 | [diff] [blame] | 900 | if (channel_mask == AUDIO_CHANNEL_IN_FRONT_BACK) |
| 901 | snd_device = SND_DEVICE_IN_VOICE_REC_DMIC; |
| 902 | else if (my_data->fluence_in_voice_rec) |
| 903 | snd_device = SND_DEVICE_IN_VOICE_REC_DMIC_FLUENCE; |
Eric Laurent | b23d528 | 2013-05-14 15:27:20 -0700 | [diff] [blame] | 904 | |
Mingming Yin | 8e5a4f6 | 2013-10-07 15:23:41 -0700 | [diff] [blame] | 905 | if (snd_device == SND_DEVICE_NONE) |
Eric Laurent | b23d528 | 2013-05-14 15:27:20 -0700 | [diff] [blame] | 906 | snd_device = SND_DEVICE_IN_VOICE_REC_MIC; |
Mingming Yin | 8e5a4f6 | 2013-10-07 15:23:41 -0700 | [diff] [blame] | 907 | else |
| 908 | adev->acdb_settings |= DMIC_FLAG; |
Eric Laurent | b23d528 | 2013-05-14 15:27:20 -0700 | [diff] [blame] | 909 | } |
| 910 | } else if (source == AUDIO_SOURCE_VOICE_COMMUNICATION) { |
| 911 | if (out_device & AUDIO_DEVICE_OUT_SPEAKER) |
| 912 | in_device = AUDIO_DEVICE_IN_BACK_MIC; |
Eric Laurent | 637e2d4 | 2018-11-15 12:24:31 -0800 | [diff] [blame] | 913 | if (in) { |
| 914 | if (in->enable_aec) { |
Eric Laurent | b23d528 | 2013-05-14 15:27:20 -0700 | [diff] [blame] | 915 | if (in_device & AUDIO_DEVICE_IN_BACK_MIC) { |
| 916 | snd_device = SND_DEVICE_IN_SPEAKER_MIC_AEC; |
| 917 | } else if (in_device & AUDIO_DEVICE_IN_BUILTIN_MIC) { |
| 918 | snd_device = SND_DEVICE_IN_HANDSET_MIC_AEC; |
| 919 | } else if (in_device & AUDIO_DEVICE_IN_WIRED_HEADSET) { |
| 920 | snd_device = SND_DEVICE_IN_HEADSET_MIC_AEC; |
| 921 | } |
Venkata Narendra Kumar Gutta | 1bbbf54 | 2014-09-04 19:11:25 +0530 | [diff] [blame] | 922 | platform_set_echo_reference(adev->platform, true); |
Eric Laurent | b23d528 | 2013-05-14 15:27:20 -0700 | [diff] [blame] | 923 | } else |
Venkata Narendra Kumar Gutta | 1bbbf54 | 2014-09-04 19:11:25 +0530 | [diff] [blame] | 924 | platform_set_echo_reference(adev->platform, false); |
Eric Laurent | b23d528 | 2013-05-14 15:27:20 -0700 | [diff] [blame] | 925 | } |
| 926 | } else if (source == AUDIO_SOURCE_DEFAULT) { |
| 927 | goto exit; |
| 928 | } |
| 929 | |
| 930 | |
| 931 | if (snd_device != SND_DEVICE_NONE) { |
| 932 | goto exit; |
| 933 | } |
| 934 | |
| 935 | if (in_device != AUDIO_DEVICE_NONE && |
| 936 | !(in_device & AUDIO_DEVICE_IN_VOICE_CALL) && |
| 937 | !(in_device & AUDIO_DEVICE_IN_COMMUNICATION)) { |
| 938 | if (in_device & AUDIO_DEVICE_IN_BUILTIN_MIC) { |
| 939 | snd_device = SND_DEVICE_IN_HANDSET_MIC; |
| 940 | } else if (in_device & AUDIO_DEVICE_IN_BACK_MIC) { |
| 941 | snd_device = SND_DEVICE_IN_SPEAKER_MIC; |
| 942 | } else if (in_device & AUDIO_DEVICE_IN_WIRED_HEADSET) { |
| 943 | snd_device = SND_DEVICE_IN_HEADSET_MIC; |
| 944 | } else if (in_device & AUDIO_DEVICE_IN_BLUETOOTH_SCO_HEADSET) { |
Mingming Yin | 514a8bc | 2014-07-29 15:22:21 -0700 | [diff] [blame] | 945 | if (adev->bt_wb_speech_enabled) |
| 946 | snd_device = SND_DEVICE_IN_BT_SCO_MIC_WB; |
| 947 | else |
| 948 | snd_device = SND_DEVICE_IN_BT_SCO_MIC; |
Eric Laurent | b23d528 | 2013-05-14 15:27:20 -0700 | [diff] [blame] | 949 | } else if (in_device & AUDIO_DEVICE_IN_AUX_DIGITAL) { |
| 950 | snd_device = SND_DEVICE_IN_HDMI_MIC; |
| 951 | } else { |
| 952 | ALOGE("%s: Unknown input device(s) %#x", __func__, in_device); |
| 953 | ALOGW("%s: Using default handset-mic", __func__); |
| 954 | snd_device = SND_DEVICE_IN_HANDSET_MIC; |
| 955 | } |
| 956 | } else { |
| 957 | if (out_device & AUDIO_DEVICE_OUT_EARPIECE) { |
| 958 | snd_device = SND_DEVICE_IN_HANDSET_MIC; |
| 959 | } else if (out_device & AUDIO_DEVICE_OUT_WIRED_HEADSET) { |
| 960 | snd_device = SND_DEVICE_IN_HEADSET_MIC; |
| 961 | } else if (out_device & AUDIO_DEVICE_OUT_SPEAKER) { |
| 962 | snd_device = SND_DEVICE_IN_SPEAKER_MIC; |
| 963 | } else if (out_device & AUDIO_DEVICE_OUT_WIRED_HEADPHONE) { |
| 964 | snd_device = SND_DEVICE_IN_HANDSET_MIC; |
| 965 | } else if (out_device & AUDIO_DEVICE_OUT_BLUETOOTH_SCO_HEADSET) { |
Mingming Yin | 514a8bc | 2014-07-29 15:22:21 -0700 | [diff] [blame] | 966 | if (adev->bt_wb_speech_enabled) |
| 967 | snd_device = SND_DEVICE_IN_BT_SCO_MIC_WB; |
| 968 | else |
| 969 | snd_device = SND_DEVICE_IN_BT_SCO_MIC; |
Eric Laurent | b23d528 | 2013-05-14 15:27:20 -0700 | [diff] [blame] | 970 | } else if (out_device & AUDIO_DEVICE_OUT_AUX_DIGITAL) { |
| 971 | snd_device = SND_DEVICE_IN_HDMI_MIC; |
| 972 | } else { |
| 973 | ALOGE("%s: Unknown output device(s) %#x", __func__, out_device); |
| 974 | ALOGW("%s: Using default handset-mic", __func__); |
| 975 | snd_device = SND_DEVICE_IN_HANDSET_MIC; |
| 976 | } |
| 977 | } |
| 978 | exit: |
| 979 | ALOGV("%s: exit: in_snd_device(%s)", __func__, device_table[snd_device]); |
| 980 | return snd_device; |
| 981 | } |
| 982 | |
| 983 | int platform_set_hdmi_channels(void *platform, int channel_count) |
| 984 | { |
| 985 | struct platform_data *my_data = (struct platform_data *)platform; |
| 986 | struct audio_device *adev = my_data->adev; |
| 987 | struct mixer_ctl *ctl; |
| 988 | const char *channel_cnt_str = NULL; |
| 989 | const char *mixer_ctl_name = "HDMI_RX Channels"; |
| 990 | switch (channel_count) { |
| 991 | case 8: |
| 992 | channel_cnt_str = "Eight"; break; |
| 993 | case 7: |
| 994 | channel_cnt_str = "Seven"; break; |
| 995 | case 6: |
| 996 | channel_cnt_str = "Six"; break; |
| 997 | case 5: |
| 998 | channel_cnt_str = "Five"; break; |
| 999 | case 4: |
| 1000 | channel_cnt_str = "Four"; break; |
| 1001 | case 3: |
| 1002 | channel_cnt_str = "Three"; break; |
| 1003 | default: |
| 1004 | channel_cnt_str = "Two"; break; |
| 1005 | } |
| 1006 | ctl = mixer_get_ctl_by_name(adev->mixer, mixer_ctl_name); |
| 1007 | if (!ctl) { |
| 1008 | ALOGE("%s: Could not get ctl for mixer cmd - %s", |
| 1009 | __func__, mixer_ctl_name); |
| 1010 | return -EINVAL; |
| 1011 | } |
| 1012 | ALOGV("HDMI channel count: %s", channel_cnt_str); |
| 1013 | mixer_ctl_set_enum_by_string(ctl, channel_cnt_str); |
| 1014 | return 0; |
| 1015 | } |
| 1016 | |
Ravi Kumar Alamanda | bdf1416 | 2014-09-05 16:14:17 -0700 | [diff] [blame] | 1017 | int platform_edid_get_max_channels(void *platform __unused) |
Eric Laurent | b23d528 | 2013-05-14 15:27:20 -0700 | [diff] [blame] | 1018 | { |
| 1019 | FILE *file; |
| 1020 | struct audio_block_header header; |
| 1021 | char block[MAX_SAD_BLOCKS * SAD_BLOCK_SIZE]; |
| 1022 | char *sad = block; |
| 1023 | int num_audio_blocks; |
| 1024 | int channel_count; |
| 1025 | int max_channels = 0; |
| 1026 | int i; |
| 1027 | |
| 1028 | file = fopen(AUDIO_DATA_BLOCK_PATH, "rb"); |
| 1029 | if (file == NULL) { |
| 1030 | ALOGE("Unable to open '%s'", AUDIO_DATA_BLOCK_PATH); |
| 1031 | return 0; |
| 1032 | } |
| 1033 | |
| 1034 | /* Read audio block header */ |
| 1035 | fread(&header, 1, sizeof(header), file); |
| 1036 | |
| 1037 | /* Read SAD blocks, clamping the maximum size for safety */ |
| 1038 | if (header.length > (int)sizeof(block)) |
| 1039 | header.length = (int)sizeof(block); |
| 1040 | fread(&block, header.length, 1, file); |
| 1041 | |
| 1042 | fclose(file); |
| 1043 | |
| 1044 | /* Calculate the number of SAD blocks */ |
| 1045 | num_audio_blocks = header.length / SAD_BLOCK_SIZE; |
| 1046 | |
| 1047 | for (i = 0; i < num_audio_blocks; i++) { |
| 1048 | /* Only consider LPCM blocks */ |
| 1049 | if ((sad[0] >> 3) != EDID_FORMAT_LPCM) |
| 1050 | continue; |
| 1051 | |
| 1052 | channel_count = (sad[0] & 0x7) + 1; |
| 1053 | if (channel_count > max_channels) |
| 1054 | max_channels = channel_count; |
| 1055 | |
| 1056 | /* Advance to next block */ |
| 1057 | sad += 3; |
| 1058 | } |
| 1059 | |
| 1060 | return max_channels; |
| 1061 | } |
Shiv Maliyappanahalli | 34b585f | 2013-10-01 15:49:05 -0700 | [diff] [blame] | 1062 | |
Ravi Kumar Alamanda | bdf1416 | 2014-09-05 16:14:17 -0700 | [diff] [blame] | 1063 | void platform_get_parameters(void *platform __unused, |
| 1064 | struct str_parms *query __unused, |
| 1065 | struct str_parms *reply __unused) |
Shiv Maliyappanahalli | 34b585f | 2013-10-01 15:49:05 -0700 | [diff] [blame] | 1066 | { |
Ravi Kumar Alamanda | bdf1416 | 2014-09-05 16:14:17 -0700 | [diff] [blame] | 1067 | ALOGE("%s: Not implemented", __func__); |
Shiv Maliyappanahalli | 34b585f | 2013-10-01 15:49:05 -0700 | [diff] [blame] | 1068 | } |
| 1069 | |
Ravi Kumar Alamanda | bdf1416 | 2014-09-05 16:14:17 -0700 | [diff] [blame] | 1070 | int platform_set_parameters(void *platform __unused, struct str_parms *parms __unused) |
Shiv Maliyappanahalli | 34b585f | 2013-10-01 15:49:05 -0700 | [diff] [blame] | 1071 | { |
Ravi Kumar Alamanda | bdf1416 | 2014-09-05 16:14:17 -0700 | [diff] [blame] | 1072 | ALOGE("%s: Not implemented", __func__); |
Shiv Maliyappanahalli | 34b585f | 2013-10-01 15:49:05 -0700 | [diff] [blame] | 1073 | return -ENOSYS; |
| 1074 | } |
Shiv Maliyappanahalli | da10764 | 2013-10-17 11:16:13 -0700 | [diff] [blame] | 1075 | |
Ravi Kumar Alamanda | bdf1416 | 2014-09-05 16:14:17 -0700 | [diff] [blame] | 1076 | int platform_set_incall_recoding_session_id(void *platform __unused, |
| 1077 | uint32_t session_id __unused) |
Shiv Maliyappanahalli | da10764 | 2013-10-17 11:16:13 -0700 | [diff] [blame] | 1078 | { |
Ravi Kumar Alamanda | bdf1416 | 2014-09-05 16:14:17 -0700 | [diff] [blame] | 1079 | ALOGE("%s: Not implemented", __func__); |
Shiv Maliyappanahalli | da10764 | 2013-10-17 11:16:13 -0700 | [diff] [blame] | 1080 | return -ENOSYS; |
| 1081 | } |
Shruthi Krishna | ace1085 | 2013-10-25 14:32:12 -0700 | [diff] [blame] | 1082 | |
Vidyakumar Athota | 21b3bb9 | 2014-04-25 11:08:08 -0700 | [diff] [blame] | 1083 | int platform_update_lch(void *platform __unused, |
| 1084 | struct voice_session *session __unused, |
| 1085 | enum voice_lch_mode lch_mode __unused) |
| 1086 | { |
Ravi Kumar Alamanda | bdf1416 | 2014-09-05 16:14:17 -0700 | [diff] [blame] | 1087 | ALOGE("%s: Not implemented", __func__); |
| 1088 | return -ENOSYS; |
| 1089 | } |
| 1090 | |
| 1091 | int platform_start_incall_music_usecase(void *platform __unused) |
| 1092 | { |
| 1093 | ALOGE("%s: Not implemented", __func__); |
| 1094 | return -ENOSYS; |
| 1095 | } |
| 1096 | |
| 1097 | int platform_stop_incall_music_usecase(void *platform __unused) |
| 1098 | { |
| 1099 | ALOGE("%s: Not implemented", __func__); |
Vidyakumar Athota | 21b3bb9 | 2014-04-25 11:08:08 -0700 | [diff] [blame] | 1100 | return -ENOSYS; |
| 1101 | } |
| 1102 | |
Lakshman Chaluvaraju | 22ba9f1 | 2016-09-12 11:42:10 +0530 | [diff] [blame] | 1103 | unsigned char* platform_get_license(void *platform, int *size) |
| 1104 | { |
| 1105 | ALOGE("%s: Not implemented", __func__); |
| 1106 | return NULL; |
| 1107 | } |
| 1108 | |
Haynes Mathew George | 7ff216f | 2013-09-11 19:51:41 -0700 | [diff] [blame] | 1109 | /* Delay in Us */ |
| 1110 | int64_t platform_render_latency(audio_usecase_t usecase) |
| 1111 | { |
| 1112 | switch (usecase) { |
| 1113 | case USECASE_AUDIO_PLAYBACK_DEEP_BUFFER: |
| 1114 | return DEEP_BUFFER_PLATFORM_DELAY; |
| 1115 | case USECASE_AUDIO_PLAYBACK_LOW_LATENCY: |
| 1116 | return LOW_LATENCY_PLATFORM_DELAY; |
| 1117 | default: |
| 1118 | return 0; |
| 1119 | } |
| 1120 | } |
Mingming Yin | e62d784 | 2013-10-25 16:26:03 -0700 | [diff] [blame] | 1121 | |
| 1122 | int platform_update_usecase_from_source(int source, int usecase) |
| 1123 | { |
| 1124 | ALOGV("%s: input source :%d", __func__, source); |
| 1125 | return usecase; |
| 1126 | } |
Kiran Kandi | de144c8 | 2013-11-20 15:58:32 -0800 | [diff] [blame] | 1127 | |
Ravi Kumar Alamanda | bdf1416 | 2014-09-05 16:14:17 -0700 | [diff] [blame] | 1128 | bool platform_listen_device_needs_event(snd_device_t snd_device __unused) |
Kiran Kandi | de144c8 | 2013-11-20 15:58:32 -0800 | [diff] [blame] | 1129 | { |
Dhananjay Kumar | 45b7174 | 2014-05-29 21:47:27 +0530 | [diff] [blame] | 1130 | return false; |
| 1131 | } |
| 1132 | |
Ravi Kumar Alamanda | bdf1416 | 2014-09-05 16:14:17 -0700 | [diff] [blame] | 1133 | bool platform_listen_usecase_needs_event(audio_usecase_t uc_id __unused) |
Dhananjay Kumar | 45b7174 | 2014-05-29 21:47:27 +0530 | [diff] [blame] | 1134 | { |
| 1135 | return false; |
Kiran Kandi | de144c8 | 2013-11-20 15:58:32 -0800 | [diff] [blame] | 1136 | } |
Mingming Yin | 3ee55c6 | 2014-08-04 14:23:35 -0700 | [diff] [blame] | 1137 | |
Ravi Kumar Alamanda | bdf1416 | 2014-09-05 16:14:17 -0700 | [diff] [blame] | 1138 | bool platform_check_and_set_codec_backend_cfg(struct audio_device* adev __unused, |
| 1139 | struct audio_usecase *usecase __unused) |
| 1140 | { |
Mingming Yin | 3ee55c6 | 2014-08-04 14:23:35 -0700 | [diff] [blame] | 1141 | return false; |
| 1142 | } |
| 1143 | |
Manish Dewangan | ba9fcfa | 2016-03-24 16:20:06 +0530 | [diff] [blame] | 1144 | bool platform_check_and_set_capture_codec_backend_cfg(struct audio_device* adev __unused, |
| 1145 | struct audio_usecase *usecase __unused) |
| 1146 | { |
| 1147 | return false; |
| 1148 | } |
| 1149 | |
Haynes Mathew George | f4da6fe | 2014-06-20 19:14:25 -0700 | [diff] [blame] | 1150 | int platform_get_usecase_index(const char * usecase __unused) |
| 1151 | { |
| 1152 | return -ENOSYS; |
| 1153 | } |
| 1154 | |
| 1155 | int platform_set_usecase_pcm_id(audio_usecase_t usecase __unused, int32_t type __unused, |
| 1156 | int32_t pcm_id __unused) |
| 1157 | { |
| 1158 | return -ENOSYS; |
| 1159 | } |
| 1160 | |
Sidipotu Ashok | 9f0b16e | 2016-04-28 13:48:28 +0530 | [diff] [blame] | 1161 | int platform_set_snd_device_backend(snd_device_t device __unused, |
| 1162 | const char *backend __unused, |
| 1163 | const char *hw_interface __unused) |
Haynes Mathew George | f4da6fe | 2014-06-20 19:14:25 -0700 | [diff] [blame] | 1164 | { |
| 1165 | return -ENOSYS; |
| 1166 | } |
Ravi Kumar Alamanda | 8fa6b19 | 2014-09-09 16:06:42 -0700 | [diff] [blame] | 1167 | |
Siena Richard | 7c2db77 | 2016-12-21 11:32:34 -0800 | [diff] [blame] | 1168 | int platform_get_snd_device_backend_index(snd_device_t device) |
| 1169 | { |
| 1170 | return -ENOSYS; |
| 1171 | } |
| 1172 | |
Ravi Kumar Alamanda | 8fa6b19 | 2014-09-09 16:06:42 -0700 | [diff] [blame] | 1173 | bool platform_sound_trigger_device_needs_event(snd_device_t snd_device __unused) |
| 1174 | { |
| 1175 | return false; |
| 1176 | } |
| 1177 | |
| 1178 | bool platform_sound_trigger_usecase_needs_event(audio_usecase_t uc_id __unused) |
| 1179 | { |
| 1180 | return false; |
| 1181 | } |
Ravi Kumar Alamanda | bdf1416 | 2014-09-05 16:14:17 -0700 | [diff] [blame] | 1182 | |
| 1183 | int platform_set_fluence_type(void *platform __unused, char *value __unused) |
| 1184 | { |
| 1185 | return -ENOSYS; |
| 1186 | } |
| 1187 | |
| 1188 | int platform_get_fluence_type(void *platform __unused, char *value __unused, |
| 1189 | uint32_t len __unused) |
| 1190 | { |
| 1191 | return -ENOSYS; |
| 1192 | } |
| 1193 | |
| 1194 | uint32_t platform_get_pcm_offload_buffer_size(audio_offload_info_t* info __unused) |
| 1195 | { |
| 1196 | return 0; |
| 1197 | } |
Pradnya Chaphekar | 4403bd7 | 2014-09-09 09:50:01 -0700 | [diff] [blame] | 1198 | |
| 1199 | int platform_get_edid_info(void *platform __unused) |
| 1200 | { |
| 1201 | return -ENOSYS; |
| 1202 | } |
| 1203 | |
| 1204 | int platform_set_channel_map(void *platform __unused, int ch_count __unused, |
| 1205 | char *ch_map __unused, int snd_id __unused) |
| 1206 | { |
| 1207 | return -ENOSYS; |
| 1208 | } |
| 1209 | |
| 1210 | int platform_set_stream_channel_map(void *platform __unused, |
| 1211 | audio_channel_mask_t channel_mask __unused, |
Naresh Tanniru | 29bce4e | 2017-04-27 17:54:30 +0530 | [diff] [blame] | 1212 | int snd_id __unused |
| 1213 | uint8_t *input_channel_map __unused) |
Pradnya Chaphekar | 4403bd7 | 2014-09-09 09:50:01 -0700 | [diff] [blame] | 1214 | { |
| 1215 | return -ENOSYS; |
| 1216 | } |
| 1217 | |
| 1218 | int platform_set_edid_channels_configuration(void *platform __unused, |
Weiyin Jiang | ff72f81 | 2018-04-13 15:02:33 +0800 | [diff] [blame] | 1219 | int channels __unused, |
| 1220 | int backend_idx __unused) |
Pradnya Chaphekar | 4403bd7 | 2014-09-09 09:50:01 -0700 | [diff] [blame] | 1221 | { |
| 1222 | return 0; |
| 1223 | } |
| 1224 | |
| 1225 | unsigned char platform_map_to_edid_format(int format __unused) |
| 1226 | { |
| 1227 | return 0; |
| 1228 | } |
Pradnya Chaphekar | 80a8cfb | 2014-10-20 16:17:01 -0700 | [diff] [blame] | 1229 | |
Pradnya Chaphekar | 4403bd7 | 2014-09-09 09:50:01 -0700 | [diff] [blame] | 1230 | bool platform_is_edid_supported_format(void *platform __unused, |
| 1231 | int format __unused) |
| 1232 | { |
| 1233 | return false; |
| 1234 | } |
| 1235 | |
Mingming Yin | 3a941d4 | 2016-02-17 18:08:05 -0800 | [diff] [blame] | 1236 | bool platform_is_edid_supported_sample_rate(void *platform __unused, |
| 1237 | int sample_rate __unused) |
| 1238 | { |
| 1239 | return false; |
| 1240 | } |
| 1241 | |
Pradnya Chaphekar | 4403bd7 | 2014-09-09 09:50:01 -0700 | [diff] [blame] | 1242 | void platform_cache_edid(void * platform __unused) |
| 1243 | { |
| 1244 | |
| 1245 | } |
| 1246 | |
Mingming Yin | ddd610b | 2016-01-20 17:09:32 -0800 | [diff] [blame] | 1247 | void platform_invalidate_hdmi_config(void * platform __unused) |
Pradnya Chaphekar | 4403bd7 | 2014-09-09 09:50:01 -0700 | [diff] [blame] | 1248 | { |
| 1249 | |
| 1250 | } |
Pradnya Chaphekar | 80a8cfb | 2014-10-20 16:17:01 -0700 | [diff] [blame] | 1251 | |
Mingming Yin | 2185465 | 2016-04-13 11:54:02 -0700 | [diff] [blame] | 1252 | int platform_set_hdmi_config(void *platform __unused, |
| 1253 | uint32_t channel_count __unused, |
| 1254 | uint32_t sample_rate __unused, |
| 1255 | bool enable_passthrough __unused) |
Pradnya Chaphekar | 80a8cfb | 2014-10-20 16:17:01 -0700 | [diff] [blame] | 1256 | { |
| 1257 | return 0; |
| 1258 | } |
| 1259 | |
| 1260 | int platform_set_device_params(struct stream_out *out __unused, |
| 1261 | int param __unused, int value __unused) |
| 1262 | { |
| 1263 | return 0; |
| 1264 | } |
Narsinga Rao Chella | f928a98 | 2015-03-06 14:57:35 -0800 | [diff] [blame] | 1265 | |
| 1266 | int platform_set_audio_device_interface(const char * device_name __unused, |
Karthik Reddy Katta | 508eca4 | 2015-05-11 13:43:18 +0530 | [diff] [blame] | 1267 | const char *intf_name __unused, |
| 1268 | const char *codec_type __unused) |
Narsinga Rao Chella | f928a98 | 2015-03-06 14:57:35 -0800 | [diff] [blame] | 1269 | { |
| 1270 | return -ENOSYS; |
| 1271 | } |
Laxminath Kasam | 8225243 | 2015-05-29 18:37:11 +0530 | [diff] [blame] | 1272 | |
vivek mehta | a76401a | 2015-04-24 14:12:15 -0700 | [diff] [blame] | 1273 | bool platform_send_gain_dep_cal(void *platform __unused, |
| 1274 | int level __unused) |
| 1275 | { |
| 1276 | return 0; |
| 1277 | } |
Banajit Goswami | 4dc87fb | 2015-10-11 21:46:07 -0700 | [diff] [blame] | 1278 | |
| 1279 | void platform_set_gsm_mode(void *platform __unused, bool enable __unused) |
| 1280 | { |
| 1281 | ALOGE("%s: Not implemented", __func__); |
| 1282 | } |
Xiaojun Sang | 040cc9f | 2015-08-03 19:38:28 +0800 | [diff] [blame] | 1283 | |
Ethan Chen | 97564d4 | 2014-09-05 13:01:26 -0700 | [diff] [blame] | 1284 | int platform_set_snd_device_name(snd_device_t snd_device __unused, |
| 1285 | const char * name __unused) |
| 1286 | { |
| 1287 | return -ENOSYS; |
| 1288 | } |
| 1289 | |
Xiaojun Sang | 040cc9f | 2015-08-03 19:38:28 +0800 | [diff] [blame] | 1290 | bool platform_can_enable_spkr_prot_on_device(snd_device_t snd_device __unused) |
| 1291 | { |
| 1292 | /* speaker protection not implemented for this platform*/ |
| 1293 | return false; |
| 1294 | } |
| 1295 | |
| 1296 | int platform_get_spkr_prot_acdb_id(snd_device_t snd_device __unused) |
| 1297 | { |
| 1298 | return -ENOSYS; |
| 1299 | } |
| 1300 | |
| 1301 | int platform_get_spkr_prot_snd_device(snd_device_t snd_device __unused) |
| 1302 | { |
| 1303 | return -ENOSYS; |
| 1304 | } |
Venkata Narendra Kumar Gutta | 7f4817f | 2016-01-29 14:15:53 +0530 | [diff] [blame] | 1305 | |
Rohit kumar | f412040 | 2016-08-05 19:19:48 +0530 | [diff] [blame] | 1306 | int platform_get_vi_feedback_snd_device(snd_device_t snd_device __unused) |
| 1307 | { |
| 1308 | return -ENOSYS; |
| 1309 | } |
| 1310 | |
Venkata Narendra Kumar Gutta | 7f4817f | 2016-01-29 14:15:53 +0530 | [diff] [blame] | 1311 | int platform_spkr_prot_is_wsa_analog_mode(void *adev __unused) |
| 1312 | { |
| 1313 | return 0; |
Haynes Mathew George | bfe8ff4 | 2016-09-22 17:38:16 -0700 | [diff] [blame] | 1314 | |
| 1315 | } |
| 1316 | |
| 1317 | int platform_can_split_snd_device(snd_device_t in_snd_device __unused, |
| 1318 | int *num_devices __unused, |
| 1319 | snd_device_t *out_snd_devices __unused) |
Sidipotu Ashok | 9f0b16e | 2016-04-28 13:48:28 +0530 | [diff] [blame] | 1320 | { |
Haynes Mathew George | bfe8ff4 | 2016-09-22 17:38:16 -0700 | [diff] [blame] | 1321 | return -ENOSYS; |
Sidipotu Ashok | 9f0b16e | 2016-04-28 13:48:28 +0530 | [diff] [blame] | 1322 | } |
| 1323 | |
| 1324 | bool platform_check_backends_match(snd_device_t snd_device1 __unused, |
| 1325 | snd_device_t snd_device2 __unused) |
| 1326 | { |
Weiyin Jiang | aa80acd | 2016-09-21 16:42:11 +0800 | [diff] [blame] | 1327 | return -ENOSYS; |
| 1328 | } |
| 1329 | |
| 1330 | int platform_send_audio_cal(void* platform __unused, |
Aditya Bavanari | 29bcea2 | 2017-10-03 20:10:35 +0530 | [diff] [blame] | 1331 | acdb_audio_cal_cfg_t* cal __unused, void* data __unused, |
Weiyin Jiang | aa80acd | 2016-09-21 16:42:11 +0800 | [diff] [blame] | 1332 | int length __unused, bool persist __unused) |
| 1333 | { |
| 1334 | return -ENOSYS; |
| 1335 | } |
| 1336 | |
| 1337 | int platform_get_audio_cal(void* platform __unused, |
Aditya Bavanari | 29bcea2 | 2017-10-03 20:10:35 +0530 | [diff] [blame] | 1338 | acdb_audio_cal_cfg_t* cal __unused, void* data __unused, |
Weiyin Jiang | aa80acd | 2016-09-21 16:42:11 +0800 | [diff] [blame] | 1339 | int* length __unused, bool persist __unused) |
| 1340 | { |
| 1341 | return -ENOSYS; |
| 1342 | } |
| 1343 | |
| 1344 | int platform_store_audio_cal(void* platform __unused, |
Aditya Bavanari | 29bcea2 | 2017-10-03 20:10:35 +0530 | [diff] [blame] | 1345 | acdb_audio_cal_cfg_t* cal __unused, void* data __unused, |
Weiyin Jiang | aa80acd | 2016-09-21 16:42:11 +0800 | [diff] [blame] | 1346 | int length __unused) |
| 1347 | { |
| 1348 | return -ENOSYS; |
| 1349 | } |
| 1350 | |
| 1351 | |
| 1352 | int platform_retrieve_audio_cal(void* platform __unused, |
Aditya Bavanari | 29bcea2 | 2017-10-03 20:10:35 +0530 | [diff] [blame] | 1353 | acdb_audio_cal_cfg_t* cal __unused, void* data __unused, |
Weiyin Jiang | aa80acd | 2016-09-21 16:42:11 +0800 | [diff] [blame] | 1354 | int* length __unused) |
| 1355 | { |
| 1356 | return -ENOSYS; |
Venkata Narendra Kumar Gutta | 7f4817f | 2016-01-29 14:15:53 +0530 | [diff] [blame] | 1357 | } |
Kuirong Wang | 1cad714 | 2016-05-24 15:21:56 -0700 | [diff] [blame] | 1358 | |
| 1359 | int platform_set_sidetone(struct audio_device *adev, |
| 1360 | snd_device_t out_snd_device, |
| 1361 | bool enable, |
| 1362 | char *str) |
| 1363 | { |
| 1364 | int ret; |
| 1365 | if (out_snd_device == SND_DEVICE_OUT_USB_HEADSET) { |
| 1366 | ret = audio_extn_usb_enable_sidetone(out_snd_device, enable); |
| 1367 | if (ret) |
| 1368 | ALOGI("%s: usb device %d does not support device sidetone\n", |
| 1369 | __func__, out_snd_device); |
| 1370 | } else { |
| 1371 | ALOGV("%s: sidetone out device(%d) mixer cmd = %s\n", |
| 1372 | __func__, out_snd_device, str); |
| 1373 | |
| 1374 | if (enable) |
| 1375 | audio_route_apply_and_update_path(adev->audio_route, str); |
| 1376 | else |
| 1377 | audio_route_reset_and_update_path(adev->audio_route, str); |
| 1378 | } |
| 1379 | return 0; |
| 1380 | } |
Preetam Singh Ranawat | cb6212e | 2016-07-19 18:33:53 +0530 | [diff] [blame] | 1381 | |
Vidyakumar Athota | ea269c6 | 2016-10-31 09:05:59 -0700 | [diff] [blame] | 1382 | void platform_update_aanc_path(struct audio_device *adev __unused, |
| 1383 | snd_device_t out_snd_device __unused, |
| 1384 | bool enable __unused, |
| 1385 | char *str __unused) |
| 1386 | { |
| 1387 | return; |
| 1388 | } |
| 1389 | |
Preetam Singh Ranawat | cb6212e | 2016-07-19 18:33:53 +0530 | [diff] [blame] | 1390 | bool platform_check_codec_dsd_support(void *platform __unused) |
| 1391 | { |
| 1392 | return false; |
| 1393 | } |
| 1394 | |
| 1395 | int platform_get_backend_index(snd_device_t snd_device __unused); |
| 1396 | { |
| 1397 | return 0; |
Preetam Singh Ranawat | b0c0dd7 | 2016-08-18 00:32:06 +0530 | [diff] [blame] | 1398 | } |
| 1399 | |
| 1400 | bool platform_check_codec_asrc_support(void *platform __unused) |
| 1401 | { |
| 1402 | return false; |
| 1403 | } |
| 1404 | |
Aniket Kumar Lata | f56b640 | 2016-10-27 12:03:18 -0700 | [diff] [blame] | 1405 | bool platform_add_gain_level_mapping(struct amp_db_and_gain_table *tbl_entry __unused) |
| 1406 | { |
| 1407 | return false; |
| 1408 | } |
| 1409 | |
| 1410 | int platform_get_gain_level_mapping(struct amp_db_and_gain_table *mapping_tbl __unused, |
| 1411 | int table_size __unused) |
| 1412 | { |
| 1413 | return 0; |
| 1414 | } |
Dhanalakshmi Siddani | 21be3ac | 2016-12-29 14:31:08 +0530 | [diff] [blame] | 1415 | |
| 1416 | int platform_get_meta_info_key_from_list(void *platform __unused, |
| 1417 | char *mod_name __unused) |
| 1418 | { |
| 1419 | return 0; |
| 1420 | } |
| 1421 | |
| 1422 | int platform_set_acdb_metainfo_key(void *platform __unused, char *name __unused, |
| 1423 | int key __unused) |
| 1424 | { |
| 1425 | return 0; |
| 1426 | } |
Haynes Mathew George | ef51488 | 2017-05-01 17:46:23 -0700 | [diff] [blame] | 1427 | |
| 1428 | int platform_get_mmap_data_fd(void *platform, int fe_dev, int dir, int *fd, |
| 1429 | uint32_t *size) |
| 1430 | { |
| 1431 | return -ENOSYS; |
| 1432 | } |
Naresh Tanniru | dcb47c5 | 2018-06-25 16:23:32 +0530 | [diff] [blame] | 1433 | |
| 1434 | bool platform_set_microphone_characteristic(void *platform __unused, |
| 1435 | struct audio_microphone_characteristic_t mic __unused) { |
| 1436 | return -ENOSYS; |
| 1437 | } |
| 1438 | |
| 1439 | int platform_get_microphones(void *platform __unused, |
| 1440 | struct audio_microphone_characteristic_t *mic_array __unused, |
| 1441 | size_t *mic_count __unused) { |
| 1442 | return -ENOSYS; |
| 1443 | } |
| 1444 | |
| 1445 | int platform_get_active_microphones(void *platform __unused, unsigned int channels __unused, |
| 1446 | audio_usecase_t usecase __unused, |
| 1447 | struct audio_microphone_characteristic_t *mic_array __unused, |
| 1448 | size_t *mic_count __unused) { |
| 1449 | return -ENOSYS; |
| 1450 | } |