Naresh Tanniru | e3b1845 | 2014-03-04 14:44:27 +0530 | [diff] [blame] | 1 | /* |
Venkata Narendra Kumar Gutta | e071e5a | 2016-01-11 18:08:26 +0530 | [diff] [blame] | 2 | * Copyright (c) 2013-2016, The Linux Foundation. All rights reserved. |
Naresh Tanniru | db72d1e | 2014-03-05 17:33:47 +0530 | [diff] [blame] | 3 | * Not a Contribution. |
| 4 | * |
Naresh Tanniru | e3b1845 | 2014-03-04 14:44:27 +0530 | [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 | |
Naresh Tanniru | db72d1e | 2014-03-05 17:33:47 +0530 | [diff] [blame] | 20 | #define LOG_TAG "msm8916_platform" |
Naresh Tanniru | e3b1845 | 2014-03-04 14:44:27 +0530 | [diff] [blame] | 21 | /*#define LOG_NDEBUG 0*/ |
| 22 | #define LOG_NDDEBUG 0 |
| 23 | |
| 24 | #include <stdlib.h> |
| 25 | #include <dlfcn.h> |
Srikanth Uyyala | cae4aa3 | 2014-10-17 13:44:09 +0530 | [diff] [blame] | 26 | #include <fcntl.h> |
Vidyakumar Athota | 21b3bb9 | 2014-04-25 11:08:08 -0700 | [diff] [blame] | 27 | #include <sys/ioctl.h> |
Naresh Tanniru | e3b1845 | 2014-03-04 14:44:27 +0530 | [diff] [blame] | 28 | #include <cutils/log.h> |
| 29 | #include <cutils/properties.h> |
Naresh Tanniru | db72d1e | 2014-03-05 17:33:47 +0530 | [diff] [blame] | 30 | #include <cutils/str_parms.h> |
Naresh Tanniru | e3b1845 | 2014-03-04 14:44:27 +0530 | [diff] [blame] | 31 | #include <audio_hw.h> |
| 32 | #include <platform_api.h> |
| 33 | #include "platform.h" |
Naresh Tanniru | db72d1e | 2014-03-05 17:33:47 +0530 | [diff] [blame] | 34 | #include "audio_extn.h" |
| 35 | #include "voice_extn.h" |
Preetam Singh Ranawat | 8bde2c5 | 2015-03-20 12:00:49 +0530 | [diff] [blame] | 36 | #include "edid.h" |
| 37 | #include "sound/compress_params.h" |
Srikanth Uyyala | cae4aa3 | 2014-10-17 13:44:09 +0530 | [diff] [blame] | 38 | #include "sound/msmcal-hwdep.h" |
Preetam Singh Ranawat | c7f7f5c | 2015-04-02 12:19:58 +0530 | [diff] [blame] | 39 | #include <dirent.h> |
Srikanth Uyyala | cae4aa3 | 2014-10-17 13:44:09 +0530 | [diff] [blame] | 40 | #define SOUND_TRIGGER_DEVICE_HANDSET_MONO_LOW_POWER_ACDB_ID (100) |
Preetam Singh Ranawat | 9519e9c | 2015-11-18 16:05:55 +0530 | [diff] [blame] | 41 | #define MAX_MIXER_XML_PATH 100 |
Naresh Tanniru | db72d1e | 2014-03-05 17:33:47 +0530 | [diff] [blame] | 42 | #define MIXER_XML_PATH "/system/etc/mixer_paths.xml" |
Asish Bhattacharya | 4ff2480 | 2014-04-24 17:46:54 +0530 | [diff] [blame] | 43 | #define MIXER_XML_PATH_MTP "/system/etc/mixer_paths_mtp.xml" |
Tanya Finkel | dd78e06 | 2015-05-26 04:29:56 -0700 | [diff] [blame] | 44 | #define MIXER_XML_PATH_SBC "/system/etc/mixer_paths_sbc.xml" |
Preetam Singh Ranawat | 2d0e463 | 2015-02-02 12:40:59 +0530 | [diff] [blame] | 45 | #define MIXER_XML_PATH_MSM8909_PM8916 "/system/etc/mixer_paths_msm8909_pm8916.xml" |
Walter Yang | 7ca90d9 | 2014-05-06 17:48:02 +0800 | [diff] [blame] | 46 | #define MIXER_XML_PATH_QRD_SKUH "/system/etc/mixer_paths_qrd_skuh.xml" |
| 47 | #define MIXER_XML_PATH_QRD_SKUI "/system/etc/mixer_paths_qrd_skui.xml" |
Walter Yang | 19f244a | 2014-06-17 13:30:08 +0800 | [diff] [blame] | 48 | #define MIXER_XML_PATH_QRD_SKUHF "/system/etc/mixer_paths_qrd_skuhf.xml" |
Meng Wang | f00485b | 2014-06-03 19:44:38 +0800 | [diff] [blame] | 49 | #define MIXER_XML_PATH_SKUK "/system/etc/mixer_paths_skuk.xml" |
Walter Yang | 42886c5 | 2014-10-23 14:31:48 +0800 | [diff] [blame] | 50 | #define MIXER_XML_PATH_SKUA "/system/etc/mixer_paths_skua.xml" |
| 51 | #define MIXER_XML_PATH_SKUC "/system/etc/mixer_paths_skuc.xml" |
Preetam Singh Ranawat | 2d0e463 | 2015-02-02 12:40:59 +0530 | [diff] [blame] | 52 | #define MIXER_XML_PATH_SKUE "/system/etc/mixer_paths_skue.xml" |
Meng Wang | cfefb8b | 2014-12-05 14:35:55 +0800 | [diff] [blame] | 53 | #define MIXER_XML_PATH_SKUL "/system/etc/mixer_paths_skul.xml" |
Walter Yang | cd13272 | 2015-04-08 16:04:30 +0800 | [diff] [blame] | 54 | #define MIXER_XML_PATH_SKUM "/system/etc/mixer_paths_qrd_skum.xml" |
Xiaojun Sang | 68b3944 | 2015-09-23 16:29:43 +0800 | [diff] [blame] | 55 | #define MIXER_XML_PATH_SKU1 "/system/etc/mixer_paths_qrd_sku1.xml" |
| 56 | #define MIXER_XML_PATH_SKU2 "/system/etc/mixer_paths_qrd_sku2.xml" |
Meng Wang | 2d74762 | 2015-08-07 10:11:41 +0800 | [diff] [blame] | 57 | #define MIXER_XML_PATH_SKUN_CAJON "/system/etc/mixer_paths_qrd_skun_cajon.xml" |
Xiaojun Sang | 9cd237a | 2015-11-20 15:30:18 +0800 | [diff] [blame] | 58 | #define MIXER_XML_PATH_SKU3 "/system/etc/mixer_paths_qrd_sku3.xml" |
Meng Wang | f00485b | 2014-06-03 19:44:38 +0800 | [diff] [blame] | 59 | #define MIXER_XML_PATH_AUXPCM "/system/etc/mixer_paths_auxpcm.xml" |
Naresh Tanniru | db72d1e | 2014-03-05 17:33:47 +0530 | [diff] [blame] | 60 | #define MIXER_XML_PATH_AUXPCM "/system/etc/mixer_paths_auxpcm.xml" |
Preetam Singh Ranawat | 8bde2c5 | 2015-03-20 12:00:49 +0530 | [diff] [blame] | 61 | #define MIXER_XML_PATH_I2S "/system/etc/mixer_paths_i2s.xml" |
Asish Bhattacharya | cb8e6d0 | 2014-06-19 12:32:25 +0530 | [diff] [blame] | 62 | #define MIXER_XML_PATH_WCD9306 "/system/etc/mixer_paths_wcd9306.xml" |
Aviral Gupta | 8ed0eec | 2014-08-25 10:22:11 +0530 | [diff] [blame] | 63 | #define MIXER_XML_PATH_WCD9330 "/system/etc/mixer_paths_wcd9330.xml" |
Preetam Singh Ranawat | 9519e9c | 2015-11-18 16:05:55 +0530 | [diff] [blame] | 64 | #define MIXER_XML_PATH_WCD9335 "/system/etc/mixer_paths_wcd9335.xml" |
| 65 | #define MIXER_XML_PATH_WCD9326 "/system/etc/mixer_paths_wcd9326.xml" |
Meng Wang | f1ec20c | 2015-06-26 10:32:32 +0800 | [diff] [blame] | 66 | #define MIXER_XML_PATH_SKUN "/system/etc/mixer_paths_qrd_skun.xml" |
Naresh Tanniru | db72d1e | 2014-03-05 17:33:47 +0530 | [diff] [blame] | 67 | #define PLATFORM_INFO_XML_PATH "/system/etc/audio_platform_info.xml" |
Dhananjay Kumar | a68d7af | 2015-05-25 19:11:30 +0530 | [diff] [blame] | 68 | #define PLATFORM_INFO_XML_PATH_EXTCODEC "/system/etc/audio_platform_info_extcodec.xml" |
Preetam Singh Ranawat | 8bde2c5 | 2015-03-20 12:00:49 +0530 | [diff] [blame] | 69 | |
Naresh Tanniru | e3b1845 | 2014-03-04 14:44:27 +0530 | [diff] [blame] | 70 | #define LIB_ACDB_LOADER "libacdbloader.so" |
Naresh Tanniru | db72d1e | 2014-03-05 17:33:47 +0530 | [diff] [blame] | 71 | #define AUDIO_DATA_BLOCK_MIXER_CTL "HDMI EDID" |
Avinash Vaish | 71c066d | 2014-08-27 12:32:35 +0530 | [diff] [blame] | 72 | #define CVD_VERSION_MIXER_CTL "CVD Version" |
Naresh Tanniru | e3b1845 | 2014-03-04 14:44:27 +0530 | [diff] [blame] | 73 | |
Naresh Tanniru | db72d1e | 2014-03-05 17:33:47 +0530 | [diff] [blame] | 74 | #define MAX_COMPRESS_OFFLOAD_FRAGMENT_SIZE (256 * 1024) |
| 75 | #define MIN_COMPRESS_OFFLOAD_FRAGMENT_SIZE (2 * 1024) |
| 76 | #define COMPRESS_OFFLOAD_FRAGMENT_SIZE_FOR_AV_STREAMING (2 * 1024) |
| 77 | #define COMPRESS_OFFLOAD_FRAGMENT_SIZE (32 * 1024) |
Preetam Singh Ranawat | 8bde2c5 | 2015-03-20 12:00:49 +0530 | [diff] [blame] | 78 | |
| 79 | /* |
| 80 | * Offload buffer size for compress passthrough |
| 81 | */ |
| 82 | #define MIN_COMPRESS_PASSTHROUGH_FRAGMENT_SIZE (2 * 1024) |
| 83 | #define MAX_COMPRESS_PASSTHROUGH_FRAGMENT_SIZE (8 * 1024) |
Naresh Tanniru | e3b1845 | 2014-03-04 14:44:27 +0530 | [diff] [blame] | 84 | |
| 85 | /* |
| 86 | * This file will have a maximum of 38 bytes: |
| 87 | * |
| 88 | * 4 bytes: number of audio blocks |
| 89 | * 4 bytes: total length of Short Audio Descriptor (SAD) blocks |
| 90 | * Maximum 10 * 3 bytes: SAD blocks |
| 91 | */ |
| 92 | #define MAX_SAD_BLOCKS 10 |
| 93 | #define SAD_BLOCK_SIZE 3 |
Avinash Vaish | 71c066d | 2014-08-27 12:32:35 +0530 | [diff] [blame] | 94 | #define MAX_CVD_VERSION_STRING_SIZE 100 |
Karthik Reddy Katta | 8513f43 | 2016-04-12 14:29:27 +0530 | [diff] [blame] | 95 | #define MAX_SND_CARD_STRING_SIZE 100 |
Naresh Tanniru | e3b1845 | 2014-03-04 14:44:27 +0530 | [diff] [blame] | 96 | |
| 97 | /* EDID format ID for LPCM audio */ |
| 98 | #define EDID_FORMAT_LPCM 1 |
| 99 | |
Subhash Chandra Bose Naripeddy | 5427467 | 2014-03-10 14:51:02 -0700 | [diff] [blame] | 100 | /* fallback app type if the default app type from acdb loader fails */ |
| 101 | #define DEFAULT_APP_TYPE 0x11130 |
Naresh Tanniru | 2727f82 | 2015-05-11 15:27:08 +0530 | [diff] [blame] | 102 | #define DEFAULT_APP_TYPE_RX_PATH 0x11130 |
| 103 | #define DEFAULT_APP_TYPE_TX_PATH 0x11132 |
Subhash Chandra Bose Naripeddy | 5427467 | 2014-03-10 14:51:02 -0700 | [diff] [blame] | 104 | |
Naresh Tanniru | db72d1e | 2014-03-05 17:33:47 +0530 | [diff] [blame] | 105 | /* Retry for delay in FW loading*/ |
| 106 | #define RETRY_NUMBER 20 |
| 107 | #define RETRY_US 500000 |
| 108 | #define MAX_SND_CARD 8 |
| 109 | |
| 110 | #define SAMPLE_RATE_8KHZ 8000 |
| 111 | #define SAMPLE_RATE_16KHZ 16000 |
| 112 | |
Preetam Singh Ranawat | 8bde2c5 | 2015-03-20 12:00:49 +0530 | [diff] [blame] | 113 | #define MAX_SET_CAL_BYTE_SIZE 65536 |
| 114 | |
Naresh Tanniru | db72d1e | 2014-03-05 17:33:47 +0530 | [diff] [blame] | 115 | #define AUDIO_PARAMETER_KEY_FLUENCE_TYPE "fluence" |
Naresh Tanniru | db72d1e | 2014-03-05 17:33:47 +0530 | [diff] [blame] | 116 | #define AUDIO_PARAMETER_KEY_SLOWTALK "st_enable" |
Avinash Vaish | d5fa457 | 2014-09-15 14:41:14 +0530 | [diff] [blame] | 117 | #define AUDIO_PARAMETER_KEY_HD_VOICE "hd_voice" |
Naresh Tanniru | db72d1e | 2014-03-05 17:33:47 +0530 | [diff] [blame] | 118 | #define AUDIO_PARAMETER_KEY_VOLUME_BOOST "volume_boost" |
Preetam Singh Ranawat | 8bde2c5 | 2015-03-20 12:00:49 +0530 | [diff] [blame] | 119 | #define AUDIO_PARAMETER_KEY_AUD_CALDATA "cal_data" |
| 120 | #define AUDIO_PARAMETER_KEY_AUD_CALRESULT "cal_result" |
| 121 | |
Karthik Reddy Katta | 8513f43 | 2016-04-12 14:29:27 +0530 | [diff] [blame] | 122 | /* Reload ACDB files from specified path */ |
| 123 | #define AUDIO_PARAMETER_KEY_RELOAD_ACDB "reload_acdb" |
Preetam Singh Ranawat | 8bde2c5 | 2015-03-20 12:00:49 +0530 | [diff] [blame] | 124 | |
| 125 | /* Query external audio device connection status */ |
| 126 | #define AUDIO_PARAMETER_KEY_EXT_AUDIO_DEVICE "ext_audio_device" |
| 127 | |
| 128 | #define EVENT_EXTERNAL_SPK_1 "qc_ext_spk_1" |
| 129 | #define EVENT_EXTERNAL_SPK_2 "qc_ext_spk_2" |
| 130 | #define EVENT_EXTERNAL_MIC "qc_ext_mic" |
Srikanth Uyyala | cae4aa3 | 2014-10-17 13:44:09 +0530 | [diff] [blame] | 131 | #define MAX_CAL_NAME 20 |
Naresh Tanniru | 34a303c | 2016-01-27 17:26:41 +0530 | [diff] [blame] | 132 | #define MAX_MIME_TYPE_LENGTH 30 |
Srikanth Uyyala | cae4aa3 | 2014-10-17 13:44:09 +0530 | [diff] [blame] | 133 | |
| 134 | char cal_name_info[WCD9XXX_MAX_CAL][MAX_CAL_NAME] = { |
| 135 | [WCD9XXX_ANC_CAL] = "anc_cal", |
| 136 | [WCD9XXX_MBHC_CAL] = "mbhc_cal", |
Banajit Goswami | 20cdd21 | 2015-09-11 01:11:30 -0700 | [diff] [blame] | 137 | [WCD9XXX_VBAT_CAL] = "vbat_cal", |
Srikanth Uyyala | cae4aa3 | 2014-10-17 13:44:09 +0530 | [diff] [blame] | 138 | }; |
| 139 | |
Naresh Tanniru | c0517bc | 2014-10-26 15:30:55 +0530 | [diff] [blame] | 140 | #define AUDIO_PARAMETER_KEY_REC_PLAY_CONC "rec_play_conc_on" |
Naresh Tanniru | db72d1e | 2014-03-05 17:33:47 +0530 | [diff] [blame] | 141 | |
Sidipotu Ashok | f490be5 | 2015-10-20 10:41:34 +0530 | [diff] [blame] | 142 | #define AUDIO_PARAMETER_IS_HW_DECODER_SESSION_AVAILABLE "is_hw_dec_session_available" |
Sidipotu Ashok | 42483b6 | 2015-09-08 10:21:44 +0530 | [diff] [blame] | 143 | |
Naresh Tanniru | 34a303c | 2016-01-27 17:26:41 +0530 | [diff] [blame] | 144 | char dsp_only_decoders_mime[][MAX_MIME_TYPE_LENGTH] = { |
Sidipotu Ashok | 42483b6 | 2015-09-08 10:21:44 +0530 | [diff] [blame] | 145 | "audio/x-ms-wma" /* wma*/ , |
| 146 | "audio/x-ms-wma-lossless" /* wma lossless */ , |
| 147 | "audio/x-ms-wma-pro" /* wma prop */ , |
| 148 | "audio/amr-wb-plus" /* amr wb plus */ , |
| 149 | "audio/alac" /*alac */ , |
| 150 | "audio/x-ape" /*ape */, |
| 151 | }; |
| 152 | |
Naresh Tanniru | db72d1e | 2014-03-05 17:33:47 +0530 | [diff] [blame] | 153 | enum { |
| 154 | VOICE_FEATURE_SET_DEFAULT, |
| 155 | VOICE_FEATURE_SET_VOLUME_BOOST |
| 156 | }; |
| 157 | |
Naresh Tanniru | e3b1845 | 2014-03-04 14:44:27 +0530 | [diff] [blame] | 158 | struct audio_block_header |
| 159 | { |
| 160 | int reserved; |
| 161 | int length; |
| 162 | }; |
| 163 | |
Preetam Singh Ranawat | 8bde2c5 | 2015-03-20 12:00:49 +0530 | [diff] [blame] | 164 | typedef struct acdb_audio_cal_cfg { |
| 165 | uint32_t persist; |
| 166 | uint32_t snd_dev_id; |
| 167 | audio_devices_t dev_id; |
| 168 | int32_t acdb_dev_id; |
| 169 | uint32_t app_type; |
| 170 | uint32_t topo_id; |
| 171 | uint32_t sampling_rate; |
| 172 | uint32_t cal_type; |
| 173 | uint32_t module_id; |
| 174 | uint32_t param_id; |
| 175 | } acdb_audio_cal_cfg_t; |
| 176 | |
Naresh Tanniru | db72d1e | 2014-03-05 17:33:47 +0530 | [diff] [blame] | 177 | /* Audio calibration related functions */ |
Naresh Tanniru | e3b1845 | 2014-03-04 14:44:27 +0530 | [diff] [blame] | 178 | typedef void (*acdb_deallocate_t)(); |
Preetam Singh Ranawat | 8bde2c5 | 2015-03-20 12:00:49 +0530 | [diff] [blame] | 179 | typedef int (*acdb_init_t)(const char *, char *, int); |
| 180 | typedef void (*acdb_send_audio_cal_t)(int, int, int , int); |
Naresh Tanniru | e3b1845 | 2014-03-04 14:44:27 +0530 | [diff] [blame] | 181 | typedef void (*acdb_send_voice_cal_t)(int, int); |
Naresh Tanniru | db72d1e | 2014-03-05 17:33:47 +0530 | [diff] [blame] | 182 | typedef int (*acdb_reload_vocvoltable_t)(int); |
Subhash Chandra Bose Naripeddy | 5427467 | 2014-03-10 14:51:02 -0700 | [diff] [blame] | 183 | typedef int (*acdb_get_default_app_type_t)(void); |
Srikanth Uyyala | cae4aa3 | 2014-10-17 13:44:09 +0530 | [diff] [blame] | 184 | typedef int (*acdb_loader_get_calibration_t)(char *attr, int size, void *data); |
| 185 | acdb_loader_get_calibration_t acdb_loader_get_calibration; |
Preetam Singh Ranawat | 8bde2c5 | 2015-03-20 12:00:49 +0530 | [diff] [blame] | 186 | typedef int (*acdb_set_audio_cal_t) (void *, void *, uint32_t); |
| 187 | typedef int (*acdb_get_audio_cal_t) (void *, void *, uint32_t*); |
Ben Romberger | feca4b8 | 2015-07-07 20:40:44 -0700 | [diff] [blame] | 188 | typedef int (*acdb_send_common_top_t) (void); |
Banajit Goswami | 20cdd21 | 2015-09-11 01:11:30 -0700 | [diff] [blame] | 189 | typedef int (*acdb_set_codec_data_t) (void *, char *); |
Karthik Reddy Katta | 8513f43 | 2016-04-12 14:29:27 +0530 | [diff] [blame] | 190 | typedef int (*acdb_reload_t) (char *, char *, char *, int); |
Naresh Tanniru | e3b1845 | 2014-03-04 14:44:27 +0530 | [diff] [blame] | 191 | |
Preetam Singh Ranawat | c61f867 | 2015-06-18 23:20:28 +0530 | [diff] [blame] | 192 | typedef struct codec_backend_cfg { |
| 193 | uint32_t sample_rate; |
| 194 | uint32_t bit_width; |
| 195 | char *bitwidth_mixer_ctl; |
| 196 | char *samplerate_mixer_ctl; |
| 197 | } codec_backend_cfg_t; |
| 198 | |
Sidipotu Ashok | e6f78cb | 2015-11-05 14:42:20 +0530 | [diff] [blame] | 199 | static native_audio_prop na_props = {0, 0, 0}; |
Ashish Jain | f1eaa58 | 2016-05-23 20:54:24 +0530 | [diff] [blame] | 200 | static bool supports_true_32_bit = false; |
Preetam Singh Ranawat | c61f867 | 2015-06-18 23:20:28 +0530 | [diff] [blame] | 201 | |
Naresh Tanniru | e3b1845 | 2014-03-04 14:44:27 +0530 | [diff] [blame] | 202 | struct platform_data { |
| 203 | struct audio_device *adev; |
| 204 | bool fluence_in_spkr_mode; |
| 205 | bool fluence_in_voice_call; |
| 206 | bool fluence_in_voice_rec; |
Naresh Tanniru | db72d1e | 2014-03-05 17:33:47 +0530 | [diff] [blame] | 207 | bool fluence_in_audio_rec; |
Preetam Singh Ranawat | 8bde2c5 | 2015-03-20 12:00:49 +0530 | [diff] [blame] | 208 | bool external_spk_1; |
| 209 | bool external_spk_2; |
| 210 | bool external_mic; |
Naresh Tanniru | db72d1e | 2014-03-05 17:33:47 +0530 | [diff] [blame] | 211 | int fluence_type; |
Venkata Narendra Kumar Gutta | 88fd0bc | 2014-03-27 19:47:56 +0530 | [diff] [blame] | 212 | char fluence_cap[PROPERTY_VALUE_MAX]; |
Karthik Reddy Katta | d9fff86 | 2014-07-21 21:07:21 +0530 | [diff] [blame] | 213 | int fluence_mode; |
Naresh Tanniru | db72d1e | 2014-03-05 17:33:47 +0530 | [diff] [blame] | 214 | bool slowtalk; |
Avinash Vaish | d5fa457 | 2014-09-15 14:41:14 +0530 | [diff] [blame] | 215 | bool hd_voice; |
Venkata Narendra Kumar Gutta | 1bbbf54 | 2014-09-04 19:11:25 +0530 | [diff] [blame] | 216 | bool ec_ref_enabled; |
Preetam Singh Ranawat | c7f7f5c | 2015-04-02 12:19:58 +0530 | [diff] [blame] | 217 | bool is_wsa_speaker; |
Ramjee Singh | 203473b | 2015-06-09 15:18:42 +0530 | [diff] [blame] | 218 | bool is_acdb_initialized; |
Venkata Narendra Kumar Gutta | 4bd09d0 | 2016-01-29 15:31:04 +0530 | [diff] [blame] | 219 | bool hifi_audio; |
Banajit Goswami | 20cdd21 | 2015-09-11 01:11:30 -0700 | [diff] [blame] | 220 | /* Vbat monitor related flags */ |
| 221 | bool is_vbat_speaker; |
| 222 | bool gsm_mode_enabled; |
Naresh Tanniru | db72d1e | 2014-03-05 17:33:47 +0530 | [diff] [blame] | 223 | /* Audio calibration related functions */ |
| 224 | void *acdb_handle; |
| 225 | int voice_feature_set; |
| 226 | acdb_init_t acdb_init; |
| 227 | acdb_deallocate_t acdb_deallocate; |
| 228 | acdb_send_audio_cal_t acdb_send_audio_cal; |
Preetam Singh Ranawat | 8bde2c5 | 2015-03-20 12:00:49 +0530 | [diff] [blame] | 229 | acdb_set_audio_cal_t acdb_set_audio_cal; |
| 230 | acdb_get_audio_cal_t acdb_get_audio_cal; |
Naresh Tanniru | db72d1e | 2014-03-05 17:33:47 +0530 | [diff] [blame] | 231 | acdb_send_voice_cal_t acdb_send_voice_cal; |
| 232 | acdb_reload_vocvoltable_t acdb_reload_vocvoltable; |
Subhash Chandra Bose Naripeddy | 5427467 | 2014-03-10 14:51:02 -0700 | [diff] [blame] | 233 | acdb_get_default_app_type_t acdb_get_default_app_type; |
Ben Romberger | feca4b8 | 2015-07-07 20:40:44 -0700 | [diff] [blame] | 234 | acdb_send_common_top_t acdb_send_common_top; |
Banajit Goswami | 20cdd21 | 2015-09-11 01:11:30 -0700 | [diff] [blame] | 235 | acdb_set_codec_data_t acdb_set_codec_data; |
Karthik Reddy Katta | 8513f43 | 2016-04-12 14:29:27 +0530 | [diff] [blame] | 236 | acdb_reload_t acdb_reload; |
Naresh Tanniru | c0517bc | 2014-10-26 15:30:55 +0530 | [diff] [blame] | 237 | #ifdef RECORD_PLAY_CONCURRENCY |
| 238 | bool rec_play_conc_set; |
| 239 | #endif |
Naresh Tanniru | db72d1e | 2014-03-05 17:33:47 +0530 | [diff] [blame] | 240 | void *hw_info; |
| 241 | struct csd_data *csd; |
Preetam Singh Ranawat | 8bde2c5 | 2015-03-20 12:00:49 +0530 | [diff] [blame] | 242 | void *edid_info; |
| 243 | bool edid_valid; |
Preetam Singh Ranawat | c61f867 | 2015-06-18 23:20:28 +0530 | [diff] [blame] | 244 | codec_backend_cfg_t current_backend_cfg[MAX_CODEC_BACKENDS]; |
Manish Dewangan | ba9fcfa | 2016-03-24 16:20:06 +0530 | [diff] [blame] | 245 | codec_backend_cfg_t current_tx_backend_cfg[MAX_CODEC_TX_BACKENDS]; |
Apoorv Raghuvanshi | 924b302 | 2015-07-06 15:07:14 -0700 | [diff] [blame] | 246 | char ec_ref_mixer_path[64]; |
Sidipotu Ashok | e6f78cb | 2015-11-05 14:42:20 +0530 | [diff] [blame] | 247 | char codec_version[CODEC_VERSION_MAX_LENGTH]; |
Venkata Narendra Kumar Gutta | e071e5a | 2016-01-11 18:08:26 +0530 | [diff] [blame] | 248 | int hw_dep_fd; |
Karthik Reddy Katta | 8513f43 | 2016-04-12 14:29:27 +0530 | [diff] [blame] | 249 | char cvd_version[MAX_CVD_VERSION_STRING_SIZE]; |
| 250 | char snd_card_name[MAX_SND_CARD_STRING_SIZE]; |
| 251 | int metainfo_key; |
Chaithanya Krishna Bacharaju | 9955b16 | 2016-05-25 16:25:53 +0530 | [diff] [blame] | 252 | int source_mic_type; |
| 253 | int max_mic_count; |
Naresh Tanniru | e3b1845 | 2014-03-04 14:44:27 +0530 | [diff] [blame] | 254 | }; |
| 255 | |
Venkata Narendra Kumar Gutta | ed408a1 | 2015-03-31 20:24:04 +0530 | [diff] [blame] | 256 | static bool is_external_codec = false; |
Venkata Narendra Kumar Gutta | ed408a1 | 2015-03-31 20:24:04 +0530 | [diff] [blame] | 257 | |
Preetam Singh Ranawat | 8bde2c5 | 2015-03-20 12:00:49 +0530 | [diff] [blame] | 258 | int pcm_device_table[AUDIO_USECASE_MAX][2] = { |
Naresh Tanniru | db72d1e | 2014-03-05 17:33:47 +0530 | [diff] [blame] | 259 | [USECASE_AUDIO_PLAYBACK_DEEP_BUFFER] = {DEEP_BUFFER_PCM_DEVICE, |
| 260 | DEEP_BUFFER_PCM_DEVICE}, |
| 261 | [USECASE_AUDIO_PLAYBACK_LOW_LATENCY] = {LOWLATENCY_PCM_DEVICE, |
| 262 | LOWLATENCY_PCM_DEVICE}, |
| 263 | [USECASE_AUDIO_PLAYBACK_MULTI_CH] = {MULTIMEDIA2_PCM_DEVICE, |
| 264 | MULTIMEDIA2_PCM_DEVICE}, |
| 265 | [USECASE_AUDIO_PLAYBACK_OFFLOAD] = |
| 266 | {PLAYBACK_OFFLOAD_DEVICE, PLAYBACK_OFFLOAD_DEVICE}, |
Dhananjay Kumar | a68d7af | 2015-05-25 19:11:30 +0530 | [diff] [blame] | 267 | /* Below entries are initialized with invalid values |
| 268 | * Valid values should be updated from fnc platform_info_init() |
| 269 | * based on pcm ids defined in audio_platform_info.xml. |
| 270 | */ |
| 271 | [USECASE_AUDIO_PLAYBACK_OFFLOAD2] = {-1, -1}, |
| 272 | [USECASE_AUDIO_PLAYBACK_OFFLOAD3] = {-1, -1}, |
| 273 | [USECASE_AUDIO_PLAYBACK_OFFLOAD4] = {-1, -1}, |
| 274 | [USECASE_AUDIO_PLAYBACK_OFFLOAD5] = {-1, -1}, |
| 275 | [USECASE_AUDIO_PLAYBACK_OFFLOAD6] = {-1, -1}, |
| 276 | [USECASE_AUDIO_PLAYBACK_OFFLOAD7] = {-1, -1}, |
| 277 | [USECASE_AUDIO_PLAYBACK_OFFLOAD8] = {-1, -1}, |
| 278 | [USECASE_AUDIO_PLAYBACK_OFFLOAD9] = {-1, -1}, |
Naresh Tanniru | 3a7dbe7 | 2015-06-25 20:08:01 -0700 | [diff] [blame] | 279 | [USECASE_AUDIO_PLAYBACK_ULL] = {MULTIMEDIA3_PCM_DEVICE, MULTIMEDIA3_PCM_DEVICE}, |
Naresh Tanniru | db72d1e | 2014-03-05 17:33:47 +0530 | [diff] [blame] | 280 | [USECASE_AUDIO_RECORD] = {AUDIO_RECORD_PCM_DEVICE, AUDIO_RECORD_PCM_DEVICE}, |
| 281 | [USECASE_AUDIO_RECORD_COMPRESS] = {COMPRESS_CAPTURE_DEVICE, COMPRESS_CAPTURE_DEVICE}, |
| 282 | [USECASE_AUDIO_RECORD_LOW_LATENCY] = {LOWLATENCY_PCM_DEVICE, |
| 283 | LOWLATENCY_PCM_DEVICE}, |
| 284 | [USECASE_AUDIO_RECORD_FM_VIRTUAL] = {MULTIMEDIA2_PCM_DEVICE, |
| 285 | MULTIMEDIA2_PCM_DEVICE}, |
| 286 | [USECASE_AUDIO_PLAYBACK_FM] = {FM_PLAYBACK_PCM_DEVICE, FM_CAPTURE_PCM_DEVICE}, |
| 287 | [USECASE_AUDIO_HFP_SCO] = {HFP_PCM_RX, HFP_SCO_RX}, |
| 288 | [USECASE_AUDIO_HFP_SCO_WB] = {HFP_PCM_RX, HFP_SCO_RX}, |
| 289 | [USECASE_VOICE_CALL] = {VOICE_CALL_PCM_DEVICE, VOICE_CALL_PCM_DEVICE}, |
| 290 | [USECASE_VOICE2_CALL] = {VOICE2_CALL_PCM_DEVICE, VOICE2_CALL_PCM_DEVICE}, |
| 291 | [USECASE_VOLTE_CALL] = {VOLTE_CALL_PCM_DEVICE, VOLTE_CALL_PCM_DEVICE}, |
| 292 | [USECASE_QCHAT_CALL] = {QCHAT_CALL_PCM_DEVICE, QCHAT_CALL_PCM_DEVICE}, |
Karthik Reddy Katta | 3b0a60c | 2014-04-06 14:52:37 +0530 | [diff] [blame] | 293 | [USECASE_VOWLAN_CALL] = {VOWLAN_CALL_PCM_DEVICE, VOWLAN_CALL_PCM_DEVICE}, |
Venkata Narendra Kumar Gutta | 0d29336 | 2015-12-18 15:52:27 +0530 | [diff] [blame] | 294 | [USECASE_VOICEMMODE1_CALL] = {-1, -1}, /* pcm ids updated from platform info file */ |
| 295 | [USECASE_VOICEMMODE2_CALL] = {-1, -1}, /* pcm ids updated from platform info file */ |
Naresh Tanniru | db72d1e | 2014-03-05 17:33:47 +0530 | [diff] [blame] | 296 | [USECASE_COMPRESS_VOIP_CALL] = {COMPRESS_VOIP_CALL_PCM_DEVICE, COMPRESS_VOIP_CALL_PCM_DEVICE}, |
| 297 | [USECASE_INCALL_REC_UPLINK] = {AUDIO_RECORD_PCM_DEVICE, |
| 298 | AUDIO_RECORD_PCM_DEVICE}, |
| 299 | [USECASE_INCALL_REC_DOWNLINK] = {AUDIO_RECORD_PCM_DEVICE, |
| 300 | AUDIO_RECORD_PCM_DEVICE}, |
| 301 | [USECASE_INCALL_REC_UPLINK_AND_DOWNLINK] = {AUDIO_RECORD_PCM_DEVICE, |
| 302 | AUDIO_RECORD_PCM_DEVICE}, |
| 303 | [USECASE_INCALL_REC_UPLINK_COMPRESS] = {COMPRESS_CAPTURE_DEVICE, |
| 304 | COMPRESS_CAPTURE_DEVICE}, |
| 305 | [USECASE_INCALL_REC_DOWNLINK_COMPRESS] = {COMPRESS_CAPTURE_DEVICE, |
| 306 | COMPRESS_CAPTURE_DEVICE}, |
| 307 | [USECASE_INCALL_REC_UPLINK_AND_DOWNLINK_COMPRESS] = {COMPRESS_CAPTURE_DEVICE, |
| 308 | COMPRESS_CAPTURE_DEVICE}, |
| 309 | [USECASE_INCALL_MUSIC_UPLINK] = {INCALL_MUSIC_UPLINK_PCM_DEVICE, |
| 310 | INCALL_MUSIC_UPLINK_PCM_DEVICE}, |
| 311 | [USECASE_INCALL_MUSIC_UPLINK2] = {INCALL_MUSIC_UPLINK2_PCM_DEVICE, |
| 312 | INCALL_MUSIC_UPLINK2_PCM_DEVICE}, |
| 313 | [USECASE_AUDIO_SPKR_CALIB_RX] = {SPKR_PROT_CALIB_RX_PCM_DEVICE, -1}, |
| 314 | [USECASE_AUDIO_SPKR_CALIB_TX] = {-1, SPKR_PROT_CALIB_TX_PCM_DEVICE}, |
Preetam Singh Ranawat | 7112f3b | 2015-02-26 16:51:58 +0530 | [diff] [blame] | 315 | [USECASE_AUDIO_PLAYBACK_AFE_PROXY] = {AFE_PROXY_PLAYBACK_PCM_DEVICE, |
| 316 | AFE_PROXY_RECORD_PCM_DEVICE}, |
| 317 | [USECASE_AUDIO_RECORD_AFE_PROXY] = {AFE_PROXY_PLAYBACK_PCM_DEVICE, |
| 318 | AFE_PROXY_RECORD_PCM_DEVICE}, |
Naresh Tanniru | e3b1845 | 2014-03-04 14:44:27 +0530 | [diff] [blame] | 319 | }; |
| 320 | |
| 321 | /* Array to store sound devices */ |
| 322 | static const char * const device_table[SND_DEVICE_MAX] = { |
| 323 | [SND_DEVICE_NONE] = "none", |
| 324 | /* Playback sound devices */ |
| 325 | [SND_DEVICE_OUT_HANDSET] = "handset", |
| 326 | [SND_DEVICE_OUT_SPEAKER] = "speaker", |
Preetam Singh Ranawat | 8bde2c5 | 2015-03-20 12:00:49 +0530 | [diff] [blame] | 327 | [SND_DEVICE_OUT_SPEAKER_EXTERNAL_1] = "speaker-ext-1", |
| 328 | [SND_DEVICE_OUT_SPEAKER_EXTERNAL_2] = "speaker-ext-2", |
Preetam Singh Ranawat | c7f7f5c | 2015-04-02 12:19:58 +0530 | [diff] [blame] | 329 | [SND_DEVICE_OUT_SPEAKER_WSA] = "wsa-speaker", |
Venkata Narendra Kumar Gutta | 55def54 | 2015-06-16 13:59:08 +0530 | [diff] [blame] | 330 | [SND_DEVICE_OUT_SPEAKER_VBAT] = "vbat-speaker", |
Naresh Tanniru | e3b1845 | 2014-03-04 14:44:27 +0530 | [diff] [blame] | 331 | [SND_DEVICE_OUT_SPEAKER_REVERSE] = "speaker-reverse", |
| 332 | [SND_DEVICE_OUT_HEADPHONES] = "headphones", |
Preetam Singh Ranawat | c61f867 | 2015-06-18 23:20:28 +0530 | [diff] [blame] | 333 | [SND_DEVICE_OUT_HEADPHONES_44_1] = "headphones-44.1", |
Naresh Tanniru | 9c4ba54 | 2015-11-06 18:01:09 +0530 | [diff] [blame] | 334 | [SND_DEVICE_OUT_LINE] = "line", |
Naresh Tanniru | e3b1845 | 2014-03-04 14:44:27 +0530 | [diff] [blame] | 335 | [SND_DEVICE_OUT_SPEAKER_AND_HEADPHONES] = "speaker-and-headphones", |
Naresh Tanniru | 9c4ba54 | 2015-11-06 18:01:09 +0530 | [diff] [blame] | 336 | [SND_DEVICE_OUT_SPEAKER_AND_LINE] = "speaker-and-line", |
Preetam Singh Ranawat | 8bde2c5 | 2015-03-20 12:00:49 +0530 | [diff] [blame] | 337 | [SND_DEVICE_OUT_SPEAKER_AND_HEADPHONES_EXTERNAL_1] = "speaker-and-headphones-ext-1", |
| 338 | [SND_DEVICE_OUT_SPEAKER_AND_HEADPHONES_EXTERNAL_2] = "speaker-and-headphones-ext-2", |
Naresh Tanniru | e3b1845 | 2014-03-04 14:44:27 +0530 | [diff] [blame] | 339 | [SND_DEVICE_OUT_VOICE_HANDSET] = "voice-handset", |
| 340 | [SND_DEVICE_OUT_VOICE_SPEAKER] = "voice-speaker", |
Preetam Singh Ranawat | c7f7f5c | 2015-04-02 12:19:58 +0530 | [diff] [blame] | 341 | [SND_DEVICE_OUT_VOICE_SPEAKER_WSA] = "wsa-voice-speaker", |
Venkata Narendra Kumar Gutta | 55def54 | 2015-06-16 13:59:08 +0530 | [diff] [blame] | 342 | [SND_DEVICE_OUT_VOICE_SPEAKER_VBAT] = "vbat-voice-speaker", |
Naresh Tanniru | e3b1845 | 2014-03-04 14:44:27 +0530 | [diff] [blame] | 343 | [SND_DEVICE_OUT_VOICE_HEADPHONES] = "voice-headphones", |
Naresh Tanniru | 9c4ba54 | 2015-11-06 18:01:09 +0530 | [diff] [blame] | 344 | [SND_DEVICE_OUT_VOICE_LINE] = "voice-line", |
Naresh Tanniru | e3b1845 | 2014-03-04 14:44:27 +0530 | [diff] [blame] | 345 | [SND_DEVICE_OUT_HDMI] = "hdmi", |
| 346 | [SND_DEVICE_OUT_SPEAKER_AND_HDMI] = "speaker-and-hdmi", |
| 347 | [SND_DEVICE_OUT_BT_SCO] = "bt-sco-headset", |
Naresh Tanniru | db72d1e | 2014-03-05 17:33:47 +0530 | [diff] [blame] | 348 | [SND_DEVICE_OUT_BT_SCO_WB] = "bt-sco-headset-wb", |
Naresh Tanniru | e3b1845 | 2014-03-04 14:44:27 +0530 | [diff] [blame] | 349 | [SND_DEVICE_OUT_VOICE_TTY_FULL_HEADPHONES] = "voice-tty-full-headphones", |
| 350 | [SND_DEVICE_OUT_VOICE_TTY_VCO_HEADPHONES] = "voice-tty-vco-headphones", |
| 351 | [SND_DEVICE_OUT_VOICE_TTY_HCO_HANDSET] = "voice-tty-hco-handset", |
Preetam Singh Ranawat | 7112f3b | 2015-02-26 16:51:58 +0530 | [diff] [blame] | 352 | [SND_DEVICE_OUT_VOICE_TX] = "voice-tx", |
Naresh Tanniru | db72d1e | 2014-03-05 17:33:47 +0530 | [diff] [blame] | 353 | [SND_DEVICE_OUT_AFE_PROXY] = "afe-proxy", |
| 354 | [SND_DEVICE_OUT_USB_HEADSET] = "usb-headphones", |
| 355 | [SND_DEVICE_OUT_SPEAKER_AND_USB_HEADSET] = "speaker-and-usb-headphones", |
| 356 | [SND_DEVICE_OUT_TRANSMISSION_FM] = "transmission-fm", |
| 357 | [SND_DEVICE_OUT_ANC_HEADSET] = "anc-headphones", |
| 358 | [SND_DEVICE_OUT_ANC_FB_HEADSET] = "anc-fb-headphones", |
| 359 | [SND_DEVICE_OUT_VOICE_ANC_HEADSET] = "voice-anc-headphones", |
| 360 | [SND_DEVICE_OUT_VOICE_ANC_FB_HEADSET] = "voice-anc-fb-headphones", |
| 361 | [SND_DEVICE_OUT_SPEAKER_AND_ANC_HEADSET] = "speaker-and-anc-headphones", |
| 362 | [SND_DEVICE_OUT_ANC_HANDSET] = "anc-handset", |
| 363 | [SND_DEVICE_OUT_SPEAKER_PROTECTED] = "speaker-protected", |
Preetam Singh Ranawat | 8bde2c5 | 2015-03-20 12:00:49 +0530 | [diff] [blame] | 364 | [SND_DEVICE_OUT_VOICE_SPEAKER_PROTECTED] = "voice-speaker-protected", |
Banajit Goswami | 20cdd21 | 2015-09-11 01:11:30 -0700 | [diff] [blame] | 365 | [SND_DEVICE_OUT_SPEAKER_PROTECTED_VBAT] = "speaker-protected-vbat", |
| 366 | [SND_DEVICE_OUT_VOICE_SPEAKER_PROTECTED_VBAT] = "voice-speaker-protected-vbat", |
Naresh Tanniru | c0517bc | 2014-10-26 15:30:55 +0530 | [diff] [blame] | 367 | #ifdef RECORD_PLAY_CONCURRENCY |
| 368 | [SND_DEVICE_OUT_VOIP_HANDSET] = "voip-handset", |
| 369 | [SND_DEVICE_OUT_VOIP_SPEAKER] = "voip-speaker", |
| 370 | [SND_DEVICE_OUT_VOIP_HEADPHONES] = "voip-headphones", |
| 371 | #endif |
Naresh Tanniru | e3b1845 | 2014-03-04 14:44:27 +0530 | [diff] [blame] | 372 | |
| 373 | /* Capture sound devices */ |
| 374 | [SND_DEVICE_IN_HANDSET_MIC] = "handset-mic", |
Preetam Singh Ranawat | 8bde2c5 | 2015-03-20 12:00:49 +0530 | [diff] [blame] | 375 | [SND_DEVICE_IN_HANDSET_MIC_EXTERNAL] = "handset-mic-ext", |
Naresh Tanniru | e3b1845 | 2014-03-04 14:44:27 +0530 | [diff] [blame] | 376 | [SND_DEVICE_IN_HANDSET_MIC_AEC] = "handset-mic", |
Naresh Tanniru | db72d1e | 2014-03-05 17:33:47 +0530 | [diff] [blame] | 377 | [SND_DEVICE_IN_HANDSET_MIC_NS] = "handset-mic", |
| 378 | [SND_DEVICE_IN_HANDSET_MIC_AEC_NS] = "handset-mic", |
| 379 | [SND_DEVICE_IN_HANDSET_DMIC] = "dmic-endfire", |
| 380 | [SND_DEVICE_IN_HANDSET_DMIC_AEC] = "dmic-endfire", |
| 381 | [SND_DEVICE_IN_HANDSET_DMIC_NS] = "dmic-endfire", |
| 382 | [SND_DEVICE_IN_HANDSET_DMIC_AEC_NS] = "dmic-endfire", |
| 383 | [SND_DEVICE_IN_SPEAKER_MIC] = "speaker-mic", |
| 384 | [SND_DEVICE_IN_SPEAKER_MIC_AEC] = "speaker-mic", |
| 385 | [SND_DEVICE_IN_SPEAKER_MIC_NS] = "speaker-mic", |
| 386 | [SND_DEVICE_IN_SPEAKER_MIC_AEC_NS] = "speaker-mic", |
| 387 | [SND_DEVICE_IN_SPEAKER_DMIC] = "speaker-dmic-endfire", |
| 388 | [SND_DEVICE_IN_SPEAKER_DMIC_AEC] = "speaker-dmic-endfire", |
| 389 | [SND_DEVICE_IN_SPEAKER_DMIC_NS] = "speaker-dmic-endfire", |
| 390 | [SND_DEVICE_IN_SPEAKER_DMIC_AEC_NS] = "speaker-dmic-endfire", |
| 391 | [SND_DEVICE_IN_HEADSET_MIC] = "headset-mic", |
| 392 | [SND_DEVICE_IN_HEADSET_MIC_FLUENCE] = "headset-mic", |
Naresh Tanniru | e3b1845 | 2014-03-04 14:44:27 +0530 | [diff] [blame] | 393 | [SND_DEVICE_IN_VOICE_SPEAKER_MIC] = "voice-speaker-mic", |
| 394 | [SND_DEVICE_IN_VOICE_HEADSET_MIC] = "voice-headset-mic", |
| 395 | [SND_DEVICE_IN_HDMI_MIC] = "hdmi-mic", |
| 396 | [SND_DEVICE_IN_BT_SCO_MIC] = "bt-sco-mic", |
Vicky Sehrawat | e240e5d | 2014-08-12 17:17:04 -0700 | [diff] [blame] | 397 | [SND_DEVICE_IN_BT_SCO_MIC_NREC] = "bt-sco-mic", |
Naresh Tanniru | db72d1e | 2014-03-05 17:33:47 +0530 | [diff] [blame] | 398 | [SND_DEVICE_IN_BT_SCO_MIC_WB] = "bt-sco-mic-wb", |
Vicky Sehrawat | e240e5d | 2014-08-12 17:17:04 -0700 | [diff] [blame] | 399 | [SND_DEVICE_IN_BT_SCO_MIC_WB_NREC] = "bt-sco-mic-wb", |
Naresh Tanniru | e3b1845 | 2014-03-04 14:44:27 +0530 | [diff] [blame] | 400 | [SND_DEVICE_IN_CAMCORDER_MIC] = "camcorder-mic", |
Naresh Tanniru | db72d1e | 2014-03-05 17:33:47 +0530 | [diff] [blame] | 401 | [SND_DEVICE_IN_VOICE_DMIC] = "voice-dmic-ef", |
| 402 | [SND_DEVICE_IN_VOICE_SPEAKER_DMIC] = "voice-speaker-dmic-ef", |
| 403 | [SND_DEVICE_IN_VOICE_SPEAKER_QMIC] = "voice-speaker-qmic", |
Naresh Tanniru | e3b1845 | 2014-03-04 14:44:27 +0530 | [diff] [blame] | 404 | [SND_DEVICE_IN_VOICE_TTY_FULL_HEADSET_MIC] = "voice-tty-full-headset-mic", |
| 405 | [SND_DEVICE_IN_VOICE_TTY_VCO_HANDSET_MIC] = "voice-tty-vco-handset-mic", |
| 406 | [SND_DEVICE_IN_VOICE_TTY_HCO_HEADSET_MIC] = "voice-tty-hco-headset-mic", |
| 407 | [SND_DEVICE_IN_VOICE_REC_MIC] = "voice-rec-mic", |
Naresh Tanniru | db72d1e | 2014-03-05 17:33:47 +0530 | [diff] [blame] | 408 | [SND_DEVICE_IN_VOICE_REC_MIC_NS] = "voice-rec-mic", |
| 409 | [SND_DEVICE_IN_VOICE_REC_DMIC_STEREO] = "voice-rec-dmic-ef", |
| 410 | [SND_DEVICE_IN_VOICE_REC_DMIC_FLUENCE] = "voice-rec-dmic-ef-fluence", |
Preetam Singh Ranawat | 7112f3b | 2015-02-26 16:51:58 +0530 | [diff] [blame] | 411 | [SND_DEVICE_IN_VOICE_RX] = "voice-rx", |
Naresh Tanniru | db72d1e | 2014-03-05 17:33:47 +0530 | [diff] [blame] | 412 | [SND_DEVICE_IN_USB_HEADSET_MIC] = "usb-headset-mic", |
| 413 | [SND_DEVICE_IN_CAPTURE_FM] = "capture-fm", |
| 414 | [SND_DEVICE_IN_AANC_HANDSET_MIC] = "aanc-handset-mic", |
| 415 | [SND_DEVICE_IN_QUAD_MIC] = "quad-mic", |
| 416 | [SND_DEVICE_IN_HANDSET_STEREO_DMIC] = "handset-stereo-dmic-ef", |
| 417 | [SND_DEVICE_IN_SPEAKER_STEREO_DMIC] = "speaker-stereo-dmic-ef", |
| 418 | [SND_DEVICE_IN_CAPTURE_VI_FEEDBACK] = "vi-feedback", |
Karthik Reddy Katta | d9fff86 | 2014-07-21 21:07:21 +0530 | [diff] [blame] | 419 | [SND_DEVICE_IN_VOICE_SPEAKER_DMIC_BROADSIDE] = "voice-speaker-dmic-broadside", |
| 420 | [SND_DEVICE_IN_SPEAKER_DMIC_BROADSIDE] = "speaker-dmic-broadside", |
| 421 | [SND_DEVICE_IN_SPEAKER_DMIC_AEC_BROADSIDE] = "speaker-dmic-broadside", |
| 422 | [SND_DEVICE_IN_SPEAKER_DMIC_NS_BROADSIDE] = "speaker-dmic-broadside", |
| 423 | [SND_DEVICE_IN_SPEAKER_DMIC_AEC_NS_BROADSIDE] = "speaker-dmic-broadside", |
Sidipotu Ashok | 3bcca23 | 2014-11-07 14:41:58 +0530 | [diff] [blame] | 424 | [SND_DEVICE_IN_VOICE_FLUENCE_DMIC_AANC] = "aanc-fluence-dmic-handset", |
Karthik Reddy Katta | d71b94b | 2015-01-19 14:06:53 +0530 | [diff] [blame] | 425 | [SND_DEVICE_IN_HANDSET_QMIC] = "quad-mic", |
| 426 | [SND_DEVICE_IN_SPEAKER_QMIC_AEC] = "quad-mic", |
| 427 | [SND_DEVICE_IN_SPEAKER_QMIC_NS] = "quad-mic", |
| 428 | [SND_DEVICE_IN_SPEAKER_QMIC_AEC_NS] = "quad-mic", |
Shiv Maliyappanahalli | 5a10aea | 2015-07-02 10:36:23 -0700 | [diff] [blame] | 429 | [SND_DEVICE_IN_THREE_MIC] = "three-mic", |
Chaithanya Krishna Bacharaju | 9955b16 | 2016-05-25 16:25:53 +0530 | [diff] [blame] | 430 | [SND_DEVICE_IN_HANDSET_TMIC] = "three-mic", |
Chaithanya Krishna Bacharaju | 24f86f3 | 2016-05-26 16:34:53 +0530 | [diff] [blame] | 431 | [SND_DEVICE_IN_UNPROCESSED_MIC] = "unprocessed-mic", |
| 432 | [SND_DEVICE_IN_UNPROCESSED_STEREO_MIC] = "voice-rec-dmic-ef", |
| 433 | [SND_DEVICE_IN_UNPROCESSED_THREE_MIC] = "three-mic", |
| 434 | [SND_DEVICE_IN_UNPROCESSED_QUAD_MIC] = "quad-mic", |
| 435 | [SND_DEVICE_IN_UNPROCESSED_HEADSET_MIC] = "headset-mic", |
Naresh Tanniru | e3b1845 | 2014-03-04 14:44:27 +0530 | [diff] [blame] | 436 | }; |
| 437 | |
Preetam Singh Ranawat | 8bde2c5 | 2015-03-20 12:00:49 +0530 | [diff] [blame] | 438 | // Platform specific backend bit width table |
| 439 | static int backend_bit_width_table[SND_DEVICE_MAX] = {0}; |
| 440 | |
Naresh Tanniru | e3b1845 | 2014-03-04 14:44:27 +0530 | [diff] [blame] | 441 | /* ACDB IDs (audio DSP path configuration IDs) for each sound device */ |
Naresh Tanniru | db72d1e | 2014-03-05 17:33:47 +0530 | [diff] [blame] | 442 | static int acdb_device_table[SND_DEVICE_MAX] = { |
Naresh Tanniru | e3b1845 | 2014-03-04 14:44:27 +0530 | [diff] [blame] | 443 | [SND_DEVICE_NONE] = -1, |
| 444 | [SND_DEVICE_OUT_HANDSET] = 7, |
Srikanth Uyyala | a675cd1 | 2014-10-15 14:48:11 +0530 | [diff] [blame] | 445 | [SND_DEVICE_OUT_SPEAKER] = 14, |
Preetam Singh Ranawat | 8bde2c5 | 2015-03-20 12:00:49 +0530 | [diff] [blame] | 446 | [SND_DEVICE_OUT_SPEAKER_EXTERNAL_1] = 14, |
| 447 | [SND_DEVICE_OUT_SPEAKER_EXTERNAL_2] = 14, |
Preetam Singh Ranawat | c7f7f5c | 2015-04-02 12:19:58 +0530 | [diff] [blame] | 448 | [SND_DEVICE_OUT_SPEAKER_WSA] = 135, |
Banajit Goswami | 20cdd21 | 2015-09-11 01:11:30 -0700 | [diff] [blame] | 449 | [SND_DEVICE_OUT_SPEAKER_VBAT] = 135, |
Srikanth Uyyala | a675cd1 | 2014-10-15 14:48:11 +0530 | [diff] [blame] | 450 | [SND_DEVICE_OUT_SPEAKER_REVERSE] = 14, |
Naresh Tanniru | 9c4ba54 | 2015-11-06 18:01:09 +0530 | [diff] [blame] | 451 | [SND_DEVICE_OUT_LINE] = 10, |
Naresh Tanniru | e3b1845 | 2014-03-04 14:44:27 +0530 | [diff] [blame] | 452 | [SND_DEVICE_OUT_HEADPHONES] = 10, |
Preetam Singh Ranawat | c61f867 | 2015-06-18 23:20:28 +0530 | [diff] [blame] | 453 | [SND_DEVICE_OUT_HEADPHONES_44_1] = 10, |
Naresh Tanniru | e3b1845 | 2014-03-04 14:44:27 +0530 | [diff] [blame] | 454 | [SND_DEVICE_OUT_SPEAKER_AND_HEADPHONES] = 10, |
Naresh Tanniru | 9c4ba54 | 2015-11-06 18:01:09 +0530 | [diff] [blame] | 455 | [SND_DEVICE_OUT_SPEAKER_AND_LINE] = 10, |
Preetam Singh Ranawat | 8bde2c5 | 2015-03-20 12:00:49 +0530 | [diff] [blame] | 456 | [SND_DEVICE_OUT_SPEAKER_AND_HEADPHONES_EXTERNAL_1] = 10, |
| 457 | [SND_DEVICE_OUT_SPEAKER_AND_HEADPHONES_EXTERNAL_2] = 10, |
Naresh Tanniru | e3b1845 | 2014-03-04 14:44:27 +0530 | [diff] [blame] | 458 | [SND_DEVICE_OUT_VOICE_HANDSET] = 7, |
Naresh Tanniru | 9c4ba54 | 2015-11-06 18:01:09 +0530 | [diff] [blame] | 459 | [SND_DEVICE_OUT_VOICE_LINE] = 10, |
Naresh Tanniru | db72d1e | 2014-03-05 17:33:47 +0530 | [diff] [blame] | 460 | [SND_DEVICE_OUT_VOICE_SPEAKER] = 14, |
Preetam Singh Ranawat | c7f7f5c | 2015-04-02 12:19:58 +0530 | [diff] [blame] | 461 | [SND_DEVICE_OUT_VOICE_SPEAKER_WSA] = 135, |
Banajit Goswami | 20cdd21 | 2015-09-11 01:11:30 -0700 | [diff] [blame] | 462 | [SND_DEVICE_OUT_VOICE_SPEAKER_VBAT] = 135, |
Naresh Tanniru | e3b1845 | 2014-03-04 14:44:27 +0530 | [diff] [blame] | 463 | [SND_DEVICE_OUT_VOICE_HEADPHONES] = 10, |
| 464 | [SND_DEVICE_OUT_HDMI] = 18, |
Srikanth Uyyala | a675cd1 | 2014-10-15 14:48:11 +0530 | [diff] [blame] | 465 | [SND_DEVICE_OUT_SPEAKER_AND_HDMI] = 14, |
Naresh Tanniru | e3b1845 | 2014-03-04 14:44:27 +0530 | [diff] [blame] | 466 | [SND_DEVICE_OUT_BT_SCO] = 22, |
Naresh Tanniru | db72d1e | 2014-03-05 17:33:47 +0530 | [diff] [blame] | 467 | [SND_DEVICE_OUT_BT_SCO_WB] = 39, |
Naresh Tanniru | e3b1845 | 2014-03-04 14:44:27 +0530 | [diff] [blame] | 468 | [SND_DEVICE_OUT_VOICE_TTY_FULL_HEADPHONES] = 17, |
| 469 | [SND_DEVICE_OUT_VOICE_TTY_VCO_HEADPHONES] = 17, |
| 470 | [SND_DEVICE_OUT_VOICE_TTY_HCO_HANDSET] = 37, |
Preetam Singh Ranawat | 7112f3b | 2015-02-26 16:51:58 +0530 | [diff] [blame] | 471 | [SND_DEVICE_OUT_VOICE_TX] = 45, |
Naresh Tanniru | db72d1e | 2014-03-05 17:33:47 +0530 | [diff] [blame] | 472 | [SND_DEVICE_OUT_AFE_PROXY] = 0, |
| 473 | [SND_DEVICE_OUT_USB_HEADSET] = 45, |
Srikanth Uyyala | a675cd1 | 2014-10-15 14:48:11 +0530 | [diff] [blame] | 474 | [SND_DEVICE_OUT_SPEAKER_AND_USB_HEADSET] = 14, |
Naresh Tanniru | db72d1e | 2014-03-05 17:33:47 +0530 | [diff] [blame] | 475 | [SND_DEVICE_OUT_TRANSMISSION_FM] = 0, |
| 476 | [SND_DEVICE_OUT_ANC_HEADSET] = 26, |
| 477 | [SND_DEVICE_OUT_ANC_FB_HEADSET] = 27, |
| 478 | [SND_DEVICE_OUT_VOICE_ANC_HEADSET] = 26, |
| 479 | [SND_DEVICE_OUT_VOICE_ANC_FB_HEADSET] = 27, |
| 480 | [SND_DEVICE_OUT_SPEAKER_AND_ANC_HEADSET] = 26, |
| 481 | [SND_DEVICE_OUT_ANC_HANDSET] = 103, |
Preetam Singh Ranawat | 8bde2c5 | 2015-03-20 12:00:49 +0530 | [diff] [blame] | 482 | [SND_DEVICE_OUT_SPEAKER_PROTECTED] = 124, |
| 483 | [SND_DEVICE_OUT_VOICE_SPEAKER_PROTECTED] = 101, |
Banajit Goswami | 20cdd21 | 2015-09-11 01:11:30 -0700 | [diff] [blame] | 484 | [SND_DEVICE_OUT_SPEAKER_PROTECTED_VBAT] = 124, |
| 485 | [SND_DEVICE_OUT_VOICE_SPEAKER_PROTECTED_VBAT] = 101, |
Naresh Tanniru | c0517bc | 2014-10-26 15:30:55 +0530 | [diff] [blame] | 486 | #ifdef RECORD_PLAY_CONCURRENCY |
| 487 | [SND_DEVICE_OUT_VOIP_HANDSET] = 133, |
| 488 | [SND_DEVICE_OUT_VOIP_SPEAKER] = 132, |
| 489 | [SND_DEVICE_OUT_VOIP_HEADPHONES] = 134, |
| 490 | #endif |
Naresh Tanniru | e3b1845 | 2014-03-04 14:44:27 +0530 | [diff] [blame] | 491 | |
| 492 | [SND_DEVICE_IN_HANDSET_MIC] = 4, |
Preetam Singh Ranawat | 8bde2c5 | 2015-03-20 12:00:49 +0530 | [diff] [blame] | 493 | [SND_DEVICE_IN_HANDSET_MIC_EXTERNAL] = 4, |
Naresh Tanniru | db72d1e | 2014-03-05 17:33:47 +0530 | [diff] [blame] | 494 | [SND_DEVICE_IN_HANDSET_MIC_AEC] = 106, |
| 495 | [SND_DEVICE_IN_HANDSET_MIC_NS] = 107, |
| 496 | [SND_DEVICE_IN_HANDSET_MIC_AEC_NS] = 108, |
| 497 | [SND_DEVICE_IN_HANDSET_DMIC] = 41, |
| 498 | [SND_DEVICE_IN_HANDSET_DMIC_AEC] = 109, |
| 499 | [SND_DEVICE_IN_HANDSET_DMIC_NS] = 110, |
| 500 | [SND_DEVICE_IN_HANDSET_DMIC_AEC_NS] = 111, |
| 501 | [SND_DEVICE_IN_SPEAKER_MIC] = 11, |
| 502 | [SND_DEVICE_IN_SPEAKER_MIC_AEC] = 112, |
| 503 | [SND_DEVICE_IN_SPEAKER_MIC_NS] = 113, |
| 504 | [SND_DEVICE_IN_SPEAKER_MIC_AEC_NS] = 114, |
| 505 | [SND_DEVICE_IN_SPEAKER_DMIC] = 43, |
| 506 | [SND_DEVICE_IN_SPEAKER_DMIC_AEC] = 115, |
| 507 | [SND_DEVICE_IN_SPEAKER_DMIC_NS] = 116, |
| 508 | [SND_DEVICE_IN_SPEAKER_DMIC_AEC_NS] = 117, |
Naresh Tanniru | e3b1845 | 2014-03-04 14:44:27 +0530 | [diff] [blame] | 509 | [SND_DEVICE_IN_HEADSET_MIC] = 8, |
Naresh Tanniru | db72d1e | 2014-03-05 17:33:47 +0530 | [diff] [blame] | 510 | [SND_DEVICE_IN_HEADSET_MIC_FLUENCE] = 47, |
Naresh Tanniru | e3b1845 | 2014-03-04 14:44:27 +0530 | [diff] [blame] | 511 | [SND_DEVICE_IN_VOICE_SPEAKER_MIC] = 11, |
| 512 | [SND_DEVICE_IN_VOICE_HEADSET_MIC] = 8, |
| 513 | [SND_DEVICE_IN_HDMI_MIC] = 4, |
| 514 | [SND_DEVICE_IN_BT_SCO_MIC] = 21, |
Vicky Sehrawat | e240e5d | 2014-08-12 17:17:04 -0700 | [diff] [blame] | 515 | [SND_DEVICE_IN_BT_SCO_MIC_NREC] = 122, |
Naresh Tanniru | db72d1e | 2014-03-05 17:33:47 +0530 | [diff] [blame] | 516 | [SND_DEVICE_IN_BT_SCO_MIC_WB] = 38, |
Vicky Sehrawat | e240e5d | 2014-08-12 17:17:04 -0700 | [diff] [blame] | 517 | [SND_DEVICE_IN_BT_SCO_MIC_WB_NREC] = 123, |
Naresh Tanniru | db72d1e | 2014-03-05 17:33:47 +0530 | [diff] [blame] | 518 | [SND_DEVICE_IN_CAMCORDER_MIC] = 4, |
| 519 | [SND_DEVICE_IN_VOICE_DMIC] = 41, |
| 520 | [SND_DEVICE_IN_VOICE_SPEAKER_DMIC] = 43, |
| 521 | [SND_DEVICE_IN_VOICE_SPEAKER_QMIC] = 19, |
Naresh Tanniru | e3b1845 | 2014-03-04 14:44:27 +0530 | [diff] [blame] | 522 | [SND_DEVICE_IN_VOICE_TTY_FULL_HEADSET_MIC] = 16, |
| 523 | [SND_DEVICE_IN_VOICE_TTY_VCO_HANDSET_MIC] = 36, |
| 524 | [SND_DEVICE_IN_VOICE_TTY_HCO_HEADSET_MIC] = 16, |
Naresh Tanniru | db72d1e | 2014-03-05 17:33:47 +0530 | [diff] [blame] | 525 | [SND_DEVICE_IN_VOICE_REC_MIC] = 4, |
| 526 | [SND_DEVICE_IN_VOICE_REC_MIC_NS] = 107, |
| 527 | [SND_DEVICE_IN_VOICE_REC_DMIC_STEREO] = 34, |
| 528 | [SND_DEVICE_IN_VOICE_REC_DMIC_FLUENCE] = 41, |
Preetam Singh Ranawat | 7112f3b | 2015-02-26 16:51:58 +0530 | [diff] [blame] | 529 | [SND_DEVICE_IN_VOICE_RX] = 44, |
Naresh Tanniru | db72d1e | 2014-03-05 17:33:47 +0530 | [diff] [blame] | 530 | [SND_DEVICE_IN_USB_HEADSET_MIC] = 44, |
| 531 | [SND_DEVICE_IN_CAPTURE_FM] = 0, |
| 532 | [SND_DEVICE_IN_AANC_HANDSET_MIC] = 104, |
| 533 | [SND_DEVICE_IN_QUAD_MIC] = 46, |
| 534 | [SND_DEVICE_IN_HANDSET_STEREO_DMIC] = 34, |
| 535 | [SND_DEVICE_IN_SPEAKER_STEREO_DMIC] = 35, |
| 536 | [SND_DEVICE_IN_CAPTURE_VI_FEEDBACK] = 102, |
Karthik Reddy Katta | d9fff86 | 2014-07-21 21:07:21 +0530 | [diff] [blame] | 537 | [SND_DEVICE_IN_VOICE_SPEAKER_DMIC_BROADSIDE] = 12, |
| 538 | [SND_DEVICE_IN_SPEAKER_DMIC_BROADSIDE] = 12, |
| 539 | [SND_DEVICE_IN_SPEAKER_DMIC_AEC_BROADSIDE] = 119, |
| 540 | [SND_DEVICE_IN_SPEAKER_DMIC_NS_BROADSIDE] = 121, |
| 541 | [SND_DEVICE_IN_SPEAKER_DMIC_AEC_NS_BROADSIDE] = 120, |
Venkata Narendra Kumar Gutta | 9bb5af6 | 2015-06-05 11:53:06 +0530 | [diff] [blame] | 542 | [SND_DEVICE_IN_VOICE_FLUENCE_DMIC_AANC] = 105, |
Karthik Reddy Katta | d71b94b | 2015-01-19 14:06:53 +0530 | [diff] [blame] | 543 | [SND_DEVICE_IN_HANDSET_QMIC] = 125, |
| 544 | [SND_DEVICE_IN_SPEAKER_QMIC_AEC] = 126, |
| 545 | [SND_DEVICE_IN_SPEAKER_QMIC_NS] = 127, |
| 546 | [SND_DEVICE_IN_SPEAKER_QMIC_AEC_NS] = 129, |
Chaithanya Krishna Bacharaju | 9955b16 | 2016-05-25 16:25:53 +0530 | [diff] [blame] | 547 | [SND_DEVICE_IN_THREE_MIC] = 46, /* for APSS Surround Sound Recording */ |
| 548 | [SND_DEVICE_IN_HANDSET_TMIC] = 125, /* for 3mic recording with fluence */ |
Chaithanya Krishna Bacharaju | 24f86f3 | 2016-05-26 16:34:53 +0530 | [diff] [blame] | 549 | [SND_DEVICE_IN_UNPROCESSED_MIC] = 143, |
| 550 | [SND_DEVICE_IN_UNPROCESSED_STEREO_MIC] = 144, |
| 551 | [SND_DEVICE_IN_UNPROCESSED_THREE_MIC] = 145, |
| 552 | [SND_DEVICE_IN_UNPROCESSED_QUAD_MIC] = 146, |
| 553 | [SND_DEVICE_IN_UNPROCESSED_HEADSET_MIC] = 147, |
Naresh Tanniru | e3b1845 | 2014-03-04 14:44:27 +0530 | [diff] [blame] | 554 | }; |
| 555 | |
Preetam Singh Ranawat | 8bde2c5 | 2015-03-20 12:00:49 +0530 | [diff] [blame] | 556 | struct name_to_index { |
Naresh Tanniru | db72d1e | 2014-03-05 17:33:47 +0530 | [diff] [blame] | 557 | char name[100]; |
| 558 | unsigned int index; |
| 559 | }; |
Naresh Tanniru | e3b1845 | 2014-03-04 14:44:27 +0530 | [diff] [blame] | 560 | |
Naresh Tanniru | db72d1e | 2014-03-05 17:33:47 +0530 | [diff] [blame] | 561 | #define TO_NAME_INDEX(X) #X, X |
Naresh Tanniru | e3b1845 | 2014-03-04 14:44:27 +0530 | [diff] [blame] | 562 | |
Naresh Tanniru | db72d1e | 2014-03-05 17:33:47 +0530 | [diff] [blame] | 563 | /* Used to get index from parsed sting */ |
Preetam Singh Ranawat | 8bde2c5 | 2015-03-20 12:00:49 +0530 | [diff] [blame] | 564 | static struct name_to_index snd_device_name_index[SND_DEVICE_MAX] = { |
Naresh Tanniru | db72d1e | 2014-03-05 17:33:47 +0530 | [diff] [blame] | 565 | {TO_NAME_INDEX(SND_DEVICE_OUT_HANDSET)}, |
| 566 | {TO_NAME_INDEX(SND_DEVICE_OUT_SPEAKER)}, |
Preetam Singh Ranawat | 8bde2c5 | 2015-03-20 12:00:49 +0530 | [diff] [blame] | 567 | {TO_NAME_INDEX(SND_DEVICE_OUT_SPEAKER_EXTERNAL_1)}, |
| 568 | {TO_NAME_INDEX(SND_DEVICE_OUT_SPEAKER_EXTERNAL_2)}, |
Preetam Singh Ranawat | c7f7f5c | 2015-04-02 12:19:58 +0530 | [diff] [blame] | 569 | {TO_NAME_INDEX(SND_DEVICE_OUT_SPEAKER_WSA)}, |
Banajit Goswami | 20cdd21 | 2015-09-11 01:11:30 -0700 | [diff] [blame] | 570 | {TO_NAME_INDEX(SND_DEVICE_OUT_SPEAKER_VBAT)}, |
Naresh Tanniru | db72d1e | 2014-03-05 17:33:47 +0530 | [diff] [blame] | 571 | {TO_NAME_INDEX(SND_DEVICE_OUT_SPEAKER_REVERSE)}, |
| 572 | {TO_NAME_INDEX(SND_DEVICE_OUT_HEADPHONES)}, |
Preetam Singh Ranawat | c61f867 | 2015-06-18 23:20:28 +0530 | [diff] [blame] | 573 | {TO_NAME_INDEX(SND_DEVICE_OUT_HEADPHONES_44_1)}, |
Naresh Tanniru | 9c4ba54 | 2015-11-06 18:01:09 +0530 | [diff] [blame] | 574 | {TO_NAME_INDEX(SND_DEVICE_OUT_LINE)}, |
Naresh Tanniru | db72d1e | 2014-03-05 17:33:47 +0530 | [diff] [blame] | 575 | {TO_NAME_INDEX(SND_DEVICE_OUT_SPEAKER_AND_HEADPHONES)}, |
Naresh Tanniru | 9c4ba54 | 2015-11-06 18:01:09 +0530 | [diff] [blame] | 576 | {TO_NAME_INDEX(SND_DEVICE_OUT_SPEAKER_AND_LINE)}, |
Preetam Singh Ranawat | 8bde2c5 | 2015-03-20 12:00:49 +0530 | [diff] [blame] | 577 | {TO_NAME_INDEX(SND_DEVICE_OUT_SPEAKER_AND_HEADPHONES_EXTERNAL_1)}, |
| 578 | {TO_NAME_INDEX(SND_DEVICE_OUT_SPEAKER_AND_HEADPHONES_EXTERNAL_2)}, |
Naresh Tanniru | db72d1e | 2014-03-05 17:33:47 +0530 | [diff] [blame] | 579 | {TO_NAME_INDEX(SND_DEVICE_OUT_VOICE_HANDSET)}, |
| 580 | {TO_NAME_INDEX(SND_DEVICE_OUT_VOICE_SPEAKER)}, |
Preetam Singh Ranawat | c7f7f5c | 2015-04-02 12:19:58 +0530 | [diff] [blame] | 581 | {TO_NAME_INDEX(SND_DEVICE_OUT_VOICE_SPEAKER_WSA)}, |
Banajit Goswami | 20cdd21 | 2015-09-11 01:11:30 -0700 | [diff] [blame] | 582 | {TO_NAME_INDEX(SND_DEVICE_OUT_VOICE_SPEAKER_VBAT)}, |
Naresh Tanniru | db72d1e | 2014-03-05 17:33:47 +0530 | [diff] [blame] | 583 | {TO_NAME_INDEX(SND_DEVICE_OUT_VOICE_HEADPHONES)}, |
Naresh Tanniru | 9c4ba54 | 2015-11-06 18:01:09 +0530 | [diff] [blame] | 584 | {TO_NAME_INDEX(SND_DEVICE_OUT_VOICE_LINE)}, |
Naresh Tanniru | db72d1e | 2014-03-05 17:33:47 +0530 | [diff] [blame] | 585 | {TO_NAME_INDEX(SND_DEVICE_OUT_HDMI)}, |
| 586 | {TO_NAME_INDEX(SND_DEVICE_OUT_SPEAKER_AND_HDMI)}, |
| 587 | {TO_NAME_INDEX(SND_DEVICE_OUT_BT_SCO)}, |
| 588 | {TO_NAME_INDEX(SND_DEVICE_OUT_BT_SCO_WB)}, |
| 589 | {TO_NAME_INDEX(SND_DEVICE_OUT_VOICE_TTY_FULL_HEADPHONES)}, |
| 590 | {TO_NAME_INDEX(SND_DEVICE_OUT_VOICE_TTY_VCO_HEADPHONES)}, |
| 591 | {TO_NAME_INDEX(SND_DEVICE_OUT_VOICE_TTY_HCO_HANDSET)}, |
Preetam Singh Ranawat | 7112f3b | 2015-02-26 16:51:58 +0530 | [diff] [blame] | 592 | {TO_NAME_INDEX(SND_DEVICE_OUT_VOICE_TX)}, |
Naresh Tanniru | db72d1e | 2014-03-05 17:33:47 +0530 | [diff] [blame] | 593 | {TO_NAME_INDEX(SND_DEVICE_OUT_AFE_PROXY)}, |
| 594 | {TO_NAME_INDEX(SND_DEVICE_OUT_USB_HEADSET)}, |
| 595 | {TO_NAME_INDEX(SND_DEVICE_OUT_SPEAKER_AND_USB_HEADSET)}, |
| 596 | {TO_NAME_INDEX(SND_DEVICE_OUT_TRANSMISSION_FM)}, |
| 597 | {TO_NAME_INDEX(SND_DEVICE_OUT_ANC_HEADSET)}, |
| 598 | {TO_NAME_INDEX(SND_DEVICE_OUT_ANC_FB_HEADSET)}, |
| 599 | {TO_NAME_INDEX(SND_DEVICE_OUT_VOICE_ANC_HEADSET)}, |
| 600 | {TO_NAME_INDEX(SND_DEVICE_OUT_VOICE_ANC_FB_HEADSET)}, |
| 601 | {TO_NAME_INDEX(SND_DEVICE_OUT_SPEAKER_AND_ANC_HEADSET)}, |
| 602 | {TO_NAME_INDEX(SND_DEVICE_OUT_ANC_HANDSET)}, |
| 603 | {TO_NAME_INDEX(SND_DEVICE_OUT_SPEAKER_PROTECTED)}, |
Preetam Singh Ranawat | 8bde2c5 | 2015-03-20 12:00:49 +0530 | [diff] [blame] | 604 | {TO_NAME_INDEX(SND_DEVICE_OUT_VOICE_SPEAKER_PROTECTED)}, |
Banajit Goswami | 20cdd21 | 2015-09-11 01:11:30 -0700 | [diff] [blame] | 605 | {TO_NAME_INDEX(SND_DEVICE_OUT_SPEAKER_PROTECTED_VBAT)}, |
| 606 | {TO_NAME_INDEX(SND_DEVICE_OUT_VOICE_SPEAKER_PROTECTED_VBAT)}, |
Naresh Tanniru | c0517bc | 2014-10-26 15:30:55 +0530 | [diff] [blame] | 607 | #ifdef RECORD_PLAY_CONCURRENCY |
| 608 | {TO_NAME_INDEX(SND_DEVICE_OUT_VOIP_HANDSET)}, |
| 609 | {TO_NAME_INDEX(SND_DEVICE_OUT_VOIP_SPEAKER)}, |
| 610 | {TO_NAME_INDEX(SND_DEVICE_OUT_VOIP_HEADPHONES)}, |
| 611 | #endif |
Naresh Tanniru | db72d1e | 2014-03-05 17:33:47 +0530 | [diff] [blame] | 612 | {TO_NAME_INDEX(SND_DEVICE_IN_HANDSET_MIC)}, |
Preetam Singh Ranawat | 8bde2c5 | 2015-03-20 12:00:49 +0530 | [diff] [blame] | 613 | {TO_NAME_INDEX(SND_DEVICE_IN_HANDSET_MIC_EXTERNAL)}, |
Naresh Tanniru | db72d1e | 2014-03-05 17:33:47 +0530 | [diff] [blame] | 614 | {TO_NAME_INDEX(SND_DEVICE_IN_HANDSET_MIC_AEC)}, |
| 615 | {TO_NAME_INDEX(SND_DEVICE_IN_HANDSET_MIC_NS)}, |
| 616 | {TO_NAME_INDEX(SND_DEVICE_IN_HANDSET_MIC_AEC_NS)}, |
| 617 | {TO_NAME_INDEX(SND_DEVICE_IN_HANDSET_DMIC)}, |
| 618 | {TO_NAME_INDEX(SND_DEVICE_IN_HANDSET_DMIC_AEC)}, |
| 619 | {TO_NAME_INDEX(SND_DEVICE_IN_HANDSET_DMIC_NS)}, |
| 620 | {TO_NAME_INDEX(SND_DEVICE_IN_HANDSET_DMIC_AEC_NS)}, |
| 621 | {TO_NAME_INDEX(SND_DEVICE_IN_SPEAKER_MIC)}, |
| 622 | {TO_NAME_INDEX(SND_DEVICE_IN_SPEAKER_MIC_AEC)}, |
| 623 | {TO_NAME_INDEX(SND_DEVICE_IN_SPEAKER_MIC_NS)}, |
| 624 | {TO_NAME_INDEX(SND_DEVICE_IN_SPEAKER_MIC_AEC_NS)}, |
| 625 | {TO_NAME_INDEX(SND_DEVICE_IN_SPEAKER_DMIC)}, |
| 626 | {TO_NAME_INDEX(SND_DEVICE_IN_SPEAKER_DMIC_AEC)}, |
| 627 | {TO_NAME_INDEX(SND_DEVICE_IN_SPEAKER_DMIC_NS)}, |
| 628 | {TO_NAME_INDEX(SND_DEVICE_IN_SPEAKER_DMIC_AEC_NS)}, |
| 629 | {TO_NAME_INDEX(SND_DEVICE_IN_HEADSET_MIC)}, |
| 630 | {TO_NAME_INDEX(SND_DEVICE_IN_HEADSET_MIC_FLUENCE)}, |
| 631 | {TO_NAME_INDEX(SND_DEVICE_IN_VOICE_SPEAKER_MIC)}, |
| 632 | {TO_NAME_INDEX(SND_DEVICE_IN_VOICE_HEADSET_MIC)}, |
| 633 | {TO_NAME_INDEX(SND_DEVICE_IN_HDMI_MIC)}, |
| 634 | {TO_NAME_INDEX(SND_DEVICE_IN_BT_SCO_MIC)}, |
Vicky Sehrawat | e240e5d | 2014-08-12 17:17:04 -0700 | [diff] [blame] | 635 | {TO_NAME_INDEX(SND_DEVICE_IN_BT_SCO_MIC_NREC)}, |
Naresh Tanniru | db72d1e | 2014-03-05 17:33:47 +0530 | [diff] [blame] | 636 | {TO_NAME_INDEX(SND_DEVICE_IN_BT_SCO_MIC_WB)}, |
Vicky Sehrawat | e240e5d | 2014-08-12 17:17:04 -0700 | [diff] [blame] | 637 | {TO_NAME_INDEX(SND_DEVICE_IN_BT_SCO_MIC_WB_NREC)}, |
Naresh Tanniru | db72d1e | 2014-03-05 17:33:47 +0530 | [diff] [blame] | 638 | {TO_NAME_INDEX(SND_DEVICE_IN_CAMCORDER_MIC)}, |
| 639 | {TO_NAME_INDEX(SND_DEVICE_IN_VOICE_DMIC)}, |
| 640 | {TO_NAME_INDEX(SND_DEVICE_IN_VOICE_SPEAKER_DMIC)}, |
| 641 | {TO_NAME_INDEX(SND_DEVICE_IN_VOICE_SPEAKER_QMIC)}, |
| 642 | {TO_NAME_INDEX(SND_DEVICE_IN_VOICE_TTY_FULL_HEADSET_MIC)}, |
| 643 | {TO_NAME_INDEX(SND_DEVICE_IN_VOICE_TTY_VCO_HANDSET_MIC)}, |
| 644 | {TO_NAME_INDEX(SND_DEVICE_IN_VOICE_TTY_HCO_HEADSET_MIC)}, |
| 645 | {TO_NAME_INDEX(SND_DEVICE_IN_VOICE_REC_MIC)}, |
| 646 | {TO_NAME_INDEX(SND_DEVICE_IN_VOICE_REC_MIC_NS)}, |
| 647 | {TO_NAME_INDEX(SND_DEVICE_IN_VOICE_REC_DMIC_STEREO)}, |
| 648 | {TO_NAME_INDEX(SND_DEVICE_IN_VOICE_REC_DMIC_FLUENCE)}, |
Preetam Singh Ranawat | 7112f3b | 2015-02-26 16:51:58 +0530 | [diff] [blame] | 649 | {TO_NAME_INDEX(SND_DEVICE_IN_VOICE_RX)}, |
Naresh Tanniru | db72d1e | 2014-03-05 17:33:47 +0530 | [diff] [blame] | 650 | {TO_NAME_INDEX(SND_DEVICE_IN_USB_HEADSET_MIC)}, |
| 651 | {TO_NAME_INDEX(SND_DEVICE_IN_CAPTURE_FM)}, |
| 652 | {TO_NAME_INDEX(SND_DEVICE_IN_AANC_HANDSET_MIC)}, |
| 653 | {TO_NAME_INDEX(SND_DEVICE_IN_QUAD_MIC)}, |
| 654 | {TO_NAME_INDEX(SND_DEVICE_IN_HANDSET_STEREO_DMIC)}, |
| 655 | {TO_NAME_INDEX(SND_DEVICE_IN_SPEAKER_STEREO_DMIC)}, |
| 656 | {TO_NAME_INDEX(SND_DEVICE_IN_CAPTURE_VI_FEEDBACK)}, |
Sidipotu Ashok | 3bcca23 | 2014-11-07 14:41:58 +0530 | [diff] [blame] | 657 | {TO_NAME_INDEX(SND_DEVICE_IN_VOICE_FLUENCE_DMIC_AANC)}, |
Preetam Singh Ranawat | 8bde2c5 | 2015-03-20 12:00:49 +0530 | [diff] [blame] | 658 | {TO_NAME_INDEX(SND_DEVICE_IN_VOICE_SPEAKER_DMIC_BROADSIDE)}, |
| 659 | {TO_NAME_INDEX(SND_DEVICE_IN_SPEAKER_DMIC_BROADSIDE)}, |
| 660 | {TO_NAME_INDEX(SND_DEVICE_IN_SPEAKER_DMIC_AEC_BROADSIDE)}, |
| 661 | {TO_NAME_INDEX(SND_DEVICE_IN_SPEAKER_DMIC_NS_BROADSIDE)}, |
| 662 | {TO_NAME_INDEX(SND_DEVICE_IN_SPEAKER_DMIC_AEC_NS_BROADSIDE)}, |
Karthik Reddy Katta | d71b94b | 2015-01-19 14:06:53 +0530 | [diff] [blame] | 663 | {TO_NAME_INDEX(SND_DEVICE_IN_HANDSET_QMIC)}, |
| 664 | {TO_NAME_INDEX(SND_DEVICE_IN_SPEAKER_QMIC_AEC)}, |
| 665 | {TO_NAME_INDEX(SND_DEVICE_IN_SPEAKER_QMIC_NS)}, |
| 666 | {TO_NAME_INDEX(SND_DEVICE_IN_SPEAKER_QMIC_AEC_NS)}, |
Chaithanya Krishna Bacharaju | 9955b16 | 2016-05-25 16:25:53 +0530 | [diff] [blame] | 667 | {TO_NAME_INDEX(SND_DEVICE_IN_THREE_MIC)}, |
| 668 | {TO_NAME_INDEX(SND_DEVICE_IN_HANDSET_TMIC)}, |
Chaithanya Krishna Bacharaju | 24f86f3 | 2016-05-26 16:34:53 +0530 | [diff] [blame] | 669 | {TO_NAME_INDEX(SND_DEVICE_IN_UNPROCESSED_MIC)}, |
| 670 | {TO_NAME_INDEX(SND_DEVICE_IN_UNPROCESSED_STEREO_MIC)}, |
| 671 | {TO_NAME_INDEX(SND_DEVICE_IN_UNPROCESSED_THREE_MIC)}, |
| 672 | {TO_NAME_INDEX(SND_DEVICE_IN_UNPROCESSED_QUAD_MIC)}, |
| 673 | {TO_NAME_INDEX(SND_DEVICE_IN_UNPROCESSED_HEADSET_MIC)}, |
Naresh Tanniru | db72d1e | 2014-03-05 17:33:47 +0530 | [diff] [blame] | 674 | }; |
| 675 | |
Sidipotu Ashok | 9f0b16e | 2016-04-28 13:48:28 +0530 | [diff] [blame] | 676 | static char * backend_tag_table[SND_DEVICE_MAX] = {0}; |
| 677 | static char * hw_interface_table[SND_DEVICE_MAX] = {0}; |
Preetam Singh Ranawat | 8bde2c5 | 2015-03-20 12:00:49 +0530 | [diff] [blame] | 678 | |
| 679 | static struct name_to_index usecase_name_index[AUDIO_USECASE_MAX] = { |
| 680 | {TO_NAME_INDEX(USECASE_AUDIO_PLAYBACK_DEEP_BUFFER)}, |
| 681 | {TO_NAME_INDEX(USECASE_AUDIO_PLAYBACK_LOW_LATENCY)}, |
| 682 | {TO_NAME_INDEX(USECASE_AUDIO_PLAYBACK_MULTI_CH)}, |
| 683 | {TO_NAME_INDEX(USECASE_AUDIO_PLAYBACK_OFFLOAD)}, |
Preetam Singh Ranawat | 8bde2c5 | 2015-03-20 12:00:49 +0530 | [diff] [blame] | 684 | {TO_NAME_INDEX(USECASE_AUDIO_PLAYBACK_OFFLOAD2)}, |
| 685 | {TO_NAME_INDEX(USECASE_AUDIO_PLAYBACK_OFFLOAD3)}, |
| 686 | {TO_NAME_INDEX(USECASE_AUDIO_PLAYBACK_OFFLOAD4)}, |
| 687 | {TO_NAME_INDEX(USECASE_AUDIO_PLAYBACK_OFFLOAD5)}, |
| 688 | {TO_NAME_INDEX(USECASE_AUDIO_PLAYBACK_OFFLOAD6)}, |
| 689 | {TO_NAME_INDEX(USECASE_AUDIO_PLAYBACK_OFFLOAD7)}, |
| 690 | {TO_NAME_INDEX(USECASE_AUDIO_PLAYBACK_OFFLOAD8)}, |
| 691 | {TO_NAME_INDEX(USECASE_AUDIO_PLAYBACK_OFFLOAD9)}, |
Naresh Tanniru | 3a7dbe7 | 2015-06-25 20:08:01 -0700 | [diff] [blame] | 692 | {TO_NAME_INDEX(USECASE_AUDIO_PLAYBACK_ULL)}, |
Preetam Singh Ranawat | 8bde2c5 | 2015-03-20 12:00:49 +0530 | [diff] [blame] | 693 | {TO_NAME_INDEX(USECASE_AUDIO_RECORD)}, |
| 694 | {TO_NAME_INDEX(USECASE_AUDIO_RECORD_LOW_LATENCY)}, |
| 695 | {TO_NAME_INDEX(USECASE_VOICE_CALL)}, |
| 696 | {TO_NAME_INDEX(USECASE_VOICE2_CALL)}, |
| 697 | {TO_NAME_INDEX(USECASE_VOLTE_CALL)}, |
| 698 | {TO_NAME_INDEX(USECASE_QCHAT_CALL)}, |
| 699 | {TO_NAME_INDEX(USECASE_VOWLAN_CALL)}, |
Avinash Vaish | 306e607 | 2015-05-13 16:58:18 +0530 | [diff] [blame] | 700 | {TO_NAME_INDEX(USECASE_VOICEMMODE1_CALL)}, |
| 701 | {TO_NAME_INDEX(USECASE_VOICEMMODE2_CALL)}, |
Preetam Singh Ranawat | 8bde2c5 | 2015-03-20 12:00:49 +0530 | [diff] [blame] | 702 | {TO_NAME_INDEX(USECASE_INCALL_REC_UPLINK)}, |
| 703 | {TO_NAME_INDEX(USECASE_INCALL_REC_DOWNLINK)}, |
| 704 | {TO_NAME_INDEX(USECASE_INCALL_REC_UPLINK_AND_DOWNLINK)}, |
| 705 | {TO_NAME_INDEX(USECASE_AUDIO_HFP_SCO)}, |
Xiaojun Sang | b112f88 | 2015-08-03 19:38:28 +0800 | [diff] [blame] | 706 | {TO_NAME_INDEX(USECASE_AUDIO_SPKR_CALIB_TX)}, |
Preetam Singh Ranawat | 8bde2c5 | 2015-03-20 12:00:49 +0530 | [diff] [blame] | 707 | }; |
| 708 | |
Pradnya Chaphekar | 8a9dcd8 | 2014-09-09 09:49:10 -0700 | [diff] [blame] | 709 | #define NO_COLS 2 |
| 710 | static int msm_be_id_array_len; |
| 711 | static int (*msm_device_to_be_id)[]; |
| 712 | |
| 713 | /* Below table lists output device to BE_ID mapping*/ |
| 714 | /* Update the table based on the board configuration*/ |
| 715 | |
| 716 | static int msm_device_to_be_id_internal_codec [][NO_COLS] = { |
| 717 | {AUDIO_DEVICE_OUT_EARPIECE , 34}, |
| 718 | {AUDIO_DEVICE_OUT_SPEAKER , 34}, |
| 719 | {AUDIO_DEVICE_OUT_WIRED_HEADSET , 34}, |
| 720 | {AUDIO_DEVICE_OUT_WIRED_HEADPHONE , 34}, |
| 721 | {AUDIO_DEVICE_OUT_BLUETOOTH_SCO , 11}, |
| 722 | {AUDIO_DEVICE_OUT_BLUETOOTH_SCO_HEADSET , 11}, |
| 723 | {AUDIO_DEVICE_OUT_BLUETOOTH_SCO_CARKIT , 11}, |
| 724 | {AUDIO_DEVICE_OUT_BLUETOOTH_A2DP , -1}, |
| 725 | {AUDIO_DEVICE_OUT_BLUETOOTH_A2DP_HEADPHONES , -1}, |
| 726 | {AUDIO_DEVICE_OUT_BLUETOOTH_A2DP_SPEAKER , -1}, |
| 727 | {AUDIO_DEVICE_OUT_AUX_DIGITAL , 4}, |
| 728 | {AUDIO_DEVICE_OUT_ANLG_DOCK_HEADSET , 9}, |
| 729 | {AUDIO_DEVICE_OUT_DGTL_DOCK_HEADSET , 9}, |
| 730 | {AUDIO_DEVICE_OUT_USB_ACCESSORY , -1}, |
| 731 | {AUDIO_DEVICE_OUT_USB_DEVICE , -1}, |
| 732 | {AUDIO_DEVICE_OUT_REMOTE_SUBMIX , 9}, |
| 733 | {AUDIO_DEVICE_OUT_PROXY , 9}, |
| 734 | {AUDIO_DEVICE_OUT_FM , 7}, |
| 735 | {AUDIO_DEVICE_OUT_FM_TX , 8}, |
| 736 | {AUDIO_DEVICE_OUT_ALL , -1}, |
| 737 | {AUDIO_DEVICE_NONE , -1}, |
| 738 | {AUDIO_DEVICE_OUT_DEFAULT , -1}, |
| 739 | }; |
| 740 | |
| 741 | static int msm_device_to_be_id_external_codec [][NO_COLS] = { |
| 742 | {AUDIO_DEVICE_OUT_EARPIECE , 2}, |
| 743 | {AUDIO_DEVICE_OUT_SPEAKER , 2}, |
| 744 | {AUDIO_DEVICE_OUT_WIRED_HEADSET , 2}, |
| 745 | {AUDIO_DEVICE_OUT_WIRED_HEADPHONE , 2}, |
| 746 | {AUDIO_DEVICE_OUT_BLUETOOTH_SCO , 11}, |
| 747 | {AUDIO_DEVICE_OUT_BLUETOOTH_SCO_HEADSET , 11}, |
| 748 | {AUDIO_DEVICE_OUT_BLUETOOTH_SCO_CARKIT , 11}, |
| 749 | {AUDIO_DEVICE_OUT_BLUETOOTH_A2DP , -1}, |
| 750 | {AUDIO_DEVICE_OUT_BLUETOOTH_A2DP_HEADPHONES , -1}, |
| 751 | {AUDIO_DEVICE_OUT_BLUETOOTH_A2DP_SPEAKER , -1}, |
| 752 | {AUDIO_DEVICE_OUT_AUX_DIGITAL , 4}, |
| 753 | {AUDIO_DEVICE_OUT_ANLG_DOCK_HEADSET , 9}, |
| 754 | {AUDIO_DEVICE_OUT_DGTL_DOCK_HEADSET , 9}, |
| 755 | {AUDIO_DEVICE_OUT_USB_ACCESSORY , -1}, |
| 756 | {AUDIO_DEVICE_OUT_USB_DEVICE , -1}, |
| 757 | {AUDIO_DEVICE_OUT_REMOTE_SUBMIX , 9}, |
| 758 | {AUDIO_DEVICE_OUT_PROXY , 9}, |
| 759 | {AUDIO_DEVICE_OUT_FM , 7}, |
| 760 | {AUDIO_DEVICE_OUT_FM_TX , 8}, |
| 761 | {AUDIO_DEVICE_OUT_ALL , -1}, |
| 762 | {AUDIO_DEVICE_NONE , -1}, |
| 763 | {AUDIO_DEVICE_OUT_DEFAULT , -1}, |
| 764 | }; |
| 765 | |
| 766 | |
Naresh Tanniru | db72d1e | 2014-03-05 17:33:47 +0530 | [diff] [blame] | 767 | #define DEEP_BUFFER_PLATFORM_DELAY (29*1000LL) |
Ashish Jain | 5106d36 | 2016-05-11 19:23:33 +0530 | [diff] [blame] | 768 | #define PCM_OFFLOAD_PLATFORM_DELAY (30*1000LL) |
Naresh Tanniru | db72d1e | 2014-03-05 17:33:47 +0530 | [diff] [blame] | 769 | #define LOW_LATENCY_PLATFORM_DELAY (13*1000LL) |
Naresh Tanniru | e3b1845 | 2014-03-04 14:44:27 +0530 | [diff] [blame] | 770 | |
Venkata Narendra Kumar Gutta | ed408a1 | 2015-03-31 20:24:04 +0530 | [diff] [blame] | 771 | static void update_codec_type(const char *snd_card_name) { |
| 772 | |
| 773 | if (!strncmp(snd_card_name, "msm8939-tapan-snd-card", |
| 774 | sizeof("msm8939-tapan-snd-card")) || |
| 775 | !strncmp(snd_card_name, "msm8939-tapan9302-snd-card", |
Avinash Vaish | 306e607 | 2015-05-13 16:58:18 +0530 | [diff] [blame] | 776 | sizeof("msm8939-tapan9302-snd-card")) || |
Venkata Narendra Kumar Gutta | ed408a1 | 2015-03-31 20:24:04 +0530 | [diff] [blame] | 777 | !strncmp(snd_card_name, "msm8939-tomtom9330-snd-card", |
Karthik Reddy Katta | 508eca4 | 2015-05-11 13:43:18 +0530 | [diff] [blame] | 778 | sizeof("msm8939-tomtom9330-snd-card")) || |
| 779 | !strncmp(snd_card_name, "msm8952-tomtom-snd-card", |
Preetam Singh Ranawat | 9519e9c | 2015-11-18 16:05:55 +0530 | [diff] [blame] | 780 | sizeof("msm8952-tomtom-snd-card")) || |
Xiaojun Sang | 9cd237a | 2015-11-20 15:30:18 +0800 | [diff] [blame] | 781 | !strncmp(snd_card_name, "msm8953-sku3-tasha-snd-card", |
| 782 | sizeof("msm8953-sku3-tasha-snd-card")) || |
Preetam Singh Ranawat | 9519e9c | 2015-11-18 16:05:55 +0530 | [diff] [blame] | 783 | !strncmp(snd_card_name, "msm8952-tasha-snd-card", |
| 784 | sizeof("msm8952-tasha-snd-card")) || |
| 785 | !strncmp(snd_card_name, "msm8952-tashalite-snd-card", |
| 786 | sizeof("msm8952-tashalite-snd-card")) || |
| 787 | !strncmp(snd_card_name, "msm8952-tasha-skun-snd-card", |
Preetam Singh Ranawat | 61716b1 | 2015-12-14 11:55:24 +0530 | [diff] [blame] | 788 | sizeof("msm8952-tasha-skun-snd-card")) || |
Aravind Kumar | d769174 | 2015-05-13 13:10:51 +0530 | [diff] [blame] | 789 | !strncmp(snd_card_name, "msm8976-tasha-snd-card", |
Meng Wang | f1ec20c | 2015-06-26 10:32:32 +0800 | [diff] [blame] | 790 | sizeof("msm8976-tasha-snd-card")) || |
Yeleswarapu Nagaradhesh | 09f30be | 2015-07-22 14:11:03 +0530 | [diff] [blame] | 791 | !strncmp(snd_card_name, "msm8976-tashalite-snd-card", |
| 792 | sizeof("msm8976-tashalite-snd-card")) || |
Meng Wang | f1ec20c | 2015-06-26 10:32:32 +0800 | [diff] [blame] | 793 | !strncmp(snd_card_name, "msm8976-tasha-skun-snd-card", |
Naresh Tanniru | 4d1e1a1 | 2015-12-16 19:37:50 +0530 | [diff] [blame] | 794 | sizeof("msm8976-tasha-skun-snd-card")) || |
| 795 | !strncmp(snd_card_name, "msm8937-tasha-snd-card", |
| 796 | sizeof("msm8937-tasha-snd-card")) || |
| 797 | !strncmp(snd_card_name, "msm8937-tashalite-snd-card", |
| 798 | sizeof("msm8937-tashalite-snd-card")) || |
| 799 | !strncmp(snd_card_name, "msm8953-tasha-snd-card", |
| 800 | sizeof("msm8953-tasha-snd-card")) || |
| 801 | !strncmp(snd_card_name, "msm8953-tashalite-snd-card", |
Dhananjay Kumar | d3ab9f4 | 2016-07-20 17:05:47 +0530 | [diff] [blame] | 802 | sizeof("msm8953-tashalite-snd-card")) || |
| 803 | !strncmp(snd_card_name, "msmfalcon-tasha-snd-card", |
| 804 | sizeof("msmfalcon-tasha-snd-card"))) |
Preetam Singh Ranawat | 9519e9c | 2015-11-18 16:05:55 +0530 | [diff] [blame] | 805 | { |
Venkata Narendra Kumar Gutta | ed408a1 | 2015-03-31 20:24:04 +0530 | [diff] [blame] | 806 | ALOGI("%s: snd_card_name: %s",__func__,snd_card_name); |
| 807 | is_external_codec = true; |
| 808 | } |
| 809 | } |
Asish Bhattacharya | 4ff2480 | 2014-04-24 17:46:54 +0530 | [diff] [blame] | 810 | static void query_platform(const char *snd_card_name, |
| 811 | char *mixer_xml_path) |
| 812 | { |
| 813 | if (!strncmp(snd_card_name, "msm8x16-snd-card-mtp", |
| 814 | sizeof("msm8x16-snd-card-mtp"))) { |
| 815 | strlcpy(mixer_xml_path, MIXER_XML_PATH_MTP, |
| 816 | sizeof(MIXER_XML_PATH_MTP)); |
Pradnya Chaphekar | 8a9dcd8 | 2014-09-09 09:49:10 -0700 | [diff] [blame] | 817 | |
| 818 | msm_device_to_be_id = msm_device_to_be_id_internal_codec; |
| 819 | msm_be_id_array_len = |
| 820 | sizeof(msm_device_to_be_id_internal_codec) / sizeof(msm_device_to_be_id_internal_codec[0]); |
| 821 | |
Tanya Finkel | dd78e06 | 2015-05-26 04:29:56 -0700 | [diff] [blame] | 822 | } else if (!strncmp(snd_card_name, "msm8x16-snd-card-sbc", |
| 823 | sizeof("msm8x16-snd-card-sbc"))) { |
| 824 | strlcpy(mixer_xml_path, MIXER_XML_PATH_SBC, |
| 825 | sizeof(mixer_xml_path)); |
| 826 | |
| 827 | msm_device_to_be_id = msm_device_to_be_id_internal_codec; |
| 828 | msm_be_id_array_len = |
| 829 | sizeof(msm_device_to_be_id_internal_codec) / sizeof(msm_device_to_be_id_internal_codec[0]); |
| 830 | |
Walter Yang | 7ca90d9 | 2014-05-06 17:48:02 +0800 | [diff] [blame] | 831 | } else if (!strncmp(snd_card_name, "msm8x16-skuh-snd-card", |
| 832 | sizeof("msm8x16-skuh-snd-card"))) { |
| 833 | strlcpy(mixer_xml_path, MIXER_XML_PATH_QRD_SKUH, |
| 834 | sizeof(MIXER_XML_PATH_QRD_SKUH)); |
Pradnya Chaphekar | 8a9dcd8 | 2014-09-09 09:49:10 -0700 | [diff] [blame] | 835 | |
| 836 | msm_device_to_be_id = msm_device_to_be_id_internal_codec; |
| 837 | msm_be_id_array_len = |
| 838 | sizeof(msm_device_to_be_id_internal_codec) / sizeof(msm_device_to_be_id_internal_codec[0]); |
| 839 | |
Walter Yang | 7ca90d9 | 2014-05-06 17:48:02 +0800 | [diff] [blame] | 840 | } else if (!strncmp(snd_card_name, "msm8x16-skui-snd-card", |
| 841 | sizeof("msm8x16-skui-snd-card"))) { |
| 842 | strlcpy(mixer_xml_path, MIXER_XML_PATH_QRD_SKUI, |
| 843 | sizeof(MIXER_XML_PATH_QRD_SKUI)); |
Pradnya Chaphekar | 8a9dcd8 | 2014-09-09 09:49:10 -0700 | [diff] [blame] | 844 | |
| 845 | msm_device_to_be_id = msm_device_to_be_id_internal_codec; |
| 846 | msm_be_id_array_len = |
| 847 | sizeof(msm_device_to_be_id_internal_codec) / sizeof(msm_device_to_be_id_internal_codec[0]); |
| 848 | |
Walter Yang | 19f244a | 2014-06-17 13:30:08 +0800 | [diff] [blame] | 849 | } else if (!strncmp(snd_card_name, "msm8x16-skuhf-snd-card", |
| 850 | sizeof("msm8x16-skuhf-snd-card"))) { |
| 851 | strlcpy(mixer_xml_path, MIXER_XML_PATH_QRD_SKUHF, |
| 852 | sizeof(MIXER_XML_PATH_QRD_SKUHF)); |
Pradnya Chaphekar | 8a9dcd8 | 2014-09-09 09:49:10 -0700 | [diff] [blame] | 853 | |
| 854 | msm_device_to_be_id = msm_device_to_be_id_internal_codec; |
| 855 | msm_be_id_array_len = |
| 856 | sizeof(msm_device_to_be_id_internal_codec) / sizeof(msm_device_to_be_id_internal_codec[0]); |
| 857 | |
Walter Yang | c899d57 | 2014-05-27 21:52:17 +0800 | [diff] [blame] | 858 | } else if (!strncmp(snd_card_name, "msm8939-snd-card-mtp", |
Yamit Mehta | c6003e2 | 2014-05-19 10:26:02 +0530 | [diff] [blame] | 859 | sizeof("msm8939-snd-card-mtp"))) { |
Aravind Kumar | 71ba22b | 2014-06-23 15:18:50 +0530 | [diff] [blame] | 860 | strlcpy(mixer_xml_path, MIXER_XML_PATH_MTP, |
| 861 | sizeof(MIXER_XML_PATH_MTP)); |
Pradnya Chaphekar | 8a9dcd8 | 2014-09-09 09:49:10 -0700 | [diff] [blame] | 862 | |
| 863 | msm_device_to_be_id = msm_device_to_be_id_internal_codec; |
| 864 | msm_be_id_array_len = |
| 865 | sizeof(msm_device_to_be_id_internal_codec) / sizeof(msm_device_to_be_id_internal_codec[0]); |
| 866 | |
Meng Wang | f00485b | 2014-06-03 19:44:38 +0800 | [diff] [blame] | 867 | } else if (!strncmp(snd_card_name, "msm8939-snd-card-skuk", |
| 868 | sizeof("msm8939-snd-card-skuk"))) { |
| 869 | strlcpy(mixer_xml_path, MIXER_XML_PATH_SKUK, |
| 870 | sizeof(MIXER_XML_PATH_SKUK)); |
Pradnya Chaphekar | 8a9dcd8 | 2014-09-09 09:49:10 -0700 | [diff] [blame] | 871 | msm_device_to_be_id = msm_device_to_be_id_internal_codec; |
| 872 | msm_be_id_array_len = |
| 873 | sizeof(msm_device_to_be_id_internal_codec) / sizeof(msm_device_to_be_id_internal_codec[0]); |
| 874 | |
Asish Bhattacharya | cb8e6d0 | 2014-06-19 12:32:25 +0530 | [diff] [blame] | 875 | } else if (!strncmp(snd_card_name, "msm8939-tapan-snd-card", |
| 876 | sizeof("msm8939-tapan-snd-card"))) { |
| 877 | strlcpy(mixer_xml_path, MIXER_XML_PATH_WCD9306, |
| 878 | sizeof(MIXER_XML_PATH_WCD9306)); |
Pradnya Chaphekar | 8a9dcd8 | 2014-09-09 09:49:10 -0700 | [diff] [blame] | 879 | msm_device_to_be_id = msm_device_to_be_id_external_codec; |
| 880 | msm_be_id_array_len = |
| 881 | sizeof(msm_device_to_be_id_external_codec) / sizeof(msm_device_to_be_id_external_codec[0]); |
| 882 | |
Asish Bhattacharya | cb8e6d0 | 2014-06-19 12:32:25 +0530 | [diff] [blame] | 883 | } else if (!strncmp(snd_card_name, "msm8939-tapan9302-snd-card", |
| 884 | sizeof("msm8939-tapan9302-snd-card"))) { |
| 885 | strlcpy(mixer_xml_path, MIXER_XML_PATH_WCD9306, |
| 886 | sizeof(MIXER_XML_PATH_WCD9306)); |
Pradnya Chaphekar | 8a9dcd8 | 2014-09-09 09:49:10 -0700 | [diff] [blame] | 887 | |
| 888 | msm_device_to_be_id = msm_device_to_be_id_external_codec; |
| 889 | msm_be_id_array_len = |
| 890 | sizeof(msm_device_to_be_id_external_codec) / sizeof(msm_device_to_be_id_external_codec[0]); |
| 891 | |
Aviral Gupta | 8ed0eec | 2014-08-25 10:22:11 +0530 | [diff] [blame] | 892 | } else if (!strncmp(snd_card_name, "msm8939-tomtom9330-snd-card", |
| 893 | sizeof("msm8939-tomtom9330-snd-card"))) { |
| 894 | strlcpy(mixer_xml_path, MIXER_XML_PATH_WCD9330, |
| 895 | sizeof(MIXER_XML_PATH_WCD9330)); |
Pradnya Chaphekar | 8a9dcd8 | 2014-09-09 09:49:10 -0700 | [diff] [blame] | 896 | msm_device_to_be_id = msm_device_to_be_id_external_codec; |
| 897 | msm_be_id_array_len = |
| 898 | sizeof(msm_device_to_be_id_external_codec) / sizeof(msm_device_to_be_id_external_codec[0]); |
| 899 | |
Aravind Kumar | d769174 | 2015-05-13 13:10:51 +0530 | [diff] [blame] | 900 | } else if (!strncmp(snd_card_name, "msm8976-tasha-snd-card", |
| 901 | sizeof("msm8976-tasha-snd-card"))) { |
| 902 | strlcpy(mixer_xml_path, MIXER_XML_PATH_WCD9335, |
| 903 | sizeof(MIXER_XML_PATH_WCD9335)); |
| 904 | msm_device_to_be_id = msm_device_to_be_id_external_codec; |
| 905 | msm_be_id_array_len = |
| 906 | sizeof(msm_device_to_be_id_external_codec) / sizeof(msm_device_to_be_id_external_codec[0]); |
| 907 | |
Yeleswarapu Nagaradhesh | 09f30be | 2015-07-22 14:11:03 +0530 | [diff] [blame] | 908 | } else if (!strncmp(snd_card_name, "msm8976-tashalite-snd-card", |
| 909 | sizeof("msm8976-tashalite-snd-card"))) { |
| 910 | strlcpy(mixer_xml_path, MIXER_XML_PATH_WCD9326, |
| 911 | MAX_MIXER_XML_PATH); |
| 912 | msm_device_to_be_id = msm_device_to_be_id_external_codec; |
| 913 | msm_be_id_array_len = |
| 914 | sizeof(msm_device_to_be_id_external_codec) / sizeof(msm_device_to_be_id_external_codec[0]); |
| 915 | |
Meng Wang | f1ec20c | 2015-06-26 10:32:32 +0800 | [diff] [blame] | 916 | } else if (!strncmp(snd_card_name, "msm8976-tasha-skun-snd-card", |
| 917 | sizeof("msm8976-tasha-skun-snd-card"))) { |
| 918 | strlcpy(mixer_xml_path, MIXER_XML_PATH_SKUN, |
| 919 | sizeof(MIXER_XML_PATH_SKUN)); |
| 920 | msm_device_to_be_id = msm_device_to_be_id_external_codec; |
| 921 | msm_be_id_array_len = |
| 922 | sizeof(msm_device_to_be_id_external_codec) / sizeof(msm_device_to_be_id_external_codec[0]); |
| 923 | |
Walter Yang | 42886c5 | 2014-10-23 14:31:48 +0800 | [diff] [blame] | 924 | } else if (!strncmp(snd_card_name, "msm8909-skua-snd-card", |
| 925 | sizeof("msm8909-skua-snd-card"))) { |
| 926 | strlcpy(mixer_xml_path, MIXER_XML_PATH_SKUA, |
| 927 | sizeof(MIXER_XML_PATH_SKUA)); |
Walter Yang | 42886c5 | 2014-10-23 14:31:48 +0800 | [diff] [blame] | 928 | msm_device_to_be_id = msm_device_to_be_id_internal_codec; |
| 929 | msm_be_id_array_len = |
| 930 | sizeof(msm_device_to_be_id_internal_codec) / sizeof(msm_device_to_be_id_internal_codec[0]); |
Preetam Singh Ranawat | 2d0e463 | 2015-02-02 12:40:59 +0530 | [diff] [blame] | 931 | |
Walter Yang | 42886c5 | 2014-10-23 14:31:48 +0800 | [diff] [blame] | 932 | } else if (!strncmp(snd_card_name, "msm8909-skuc-snd-card", |
| 933 | sizeof("msm8909-skuc-snd-card"))) { |
| 934 | strlcpy(mixer_xml_path, MIXER_XML_PATH_SKUC, |
| 935 | sizeof(MIXER_XML_PATH_SKUC)); |
Preetam Singh Ranawat | 2d0e463 | 2015-02-02 12:40:59 +0530 | [diff] [blame] | 936 | msm_device_to_be_id = msm_device_to_be_id_internal_codec; |
| 937 | msm_be_id_array_len = |
| 938 | sizeof(msm_device_to_be_id_internal_codec) / sizeof(msm_device_to_be_id_internal_codec[0]); |
| 939 | |
| 940 | } else if (!strncmp(snd_card_name, "msm8909-pm8916-snd-card", |
| 941 | sizeof("msm8909-pm8916-snd-card"))) { |
| 942 | strlcpy(mixer_xml_path, MIXER_XML_PATH_MSM8909_PM8916, |
| 943 | sizeof(MIXER_XML_PATH_MSM8909_PM8916)); |
Walter Yang | 42886c5 | 2014-10-23 14:31:48 +0800 | [diff] [blame] | 944 | |
| 945 | msm_device_to_be_id = msm_device_to_be_id_internal_codec; |
| 946 | msm_be_id_array_len = |
| 947 | sizeof(msm_device_to_be_id_internal_codec) / sizeof(msm_device_to_be_id_internal_codec[0]); |
Preetam Singh Ranawat | 2d0e463 | 2015-02-02 12:40:59 +0530 | [diff] [blame] | 948 | |
| 949 | } else if (!strncmp(snd_card_name, "msm8909-skue-snd-card", |
| 950 | sizeof("msm8909-skue-snd-card"))) { |
| 951 | strlcpy(mixer_xml_path, MIXER_XML_PATH_SKUE, |
| 952 | sizeof(MIXER_XML_PATH_SKUE)); |
| 953 | msm_device_to_be_id = msm_device_to_be_id_internal_codec; |
| 954 | msm_be_id_array_len = |
| 955 | sizeof(msm_device_to_be_id_internal_codec) / sizeof(msm_device_to_be_id_internal_codec[0]); |
| 956 | |
Meng Wang | cfefb8b | 2014-12-05 14:35:55 +0800 | [diff] [blame] | 957 | } else if (!strncmp(snd_card_name, "msm8939-snd-card-skul", |
| 958 | sizeof("msm8939-snd-card-skul"))) { |
| 959 | strlcpy(mixer_xml_path, MIXER_XML_PATH_SKUL, |
| 960 | sizeof(MIXER_XML_PATH_SKUL)); |
| 961 | msm_device_to_be_id = msm_device_to_be_id_internal_codec; |
| 962 | msm_be_id_array_len = |
| 963 | sizeof(msm_device_to_be_id_external_codec) / sizeof(msm_device_to_be_id_internal_codec[0]); |
Naresh Tanniru | 0d28b4a | 2015-03-23 00:58:49 +0530 | [diff] [blame] | 964 | } else if (!strncmp(snd_card_name, "msm8952-snd-card-mtp", |
Avinash Vaish | 306e607 | 2015-05-13 16:58:18 +0530 | [diff] [blame] | 965 | sizeof("msm8952-snd-card-mtp"))) { |
Naresh Tanniru | 0d28b4a | 2015-03-23 00:58:49 +0530 | [diff] [blame] | 966 | strlcpy(mixer_xml_path, MIXER_XML_PATH_MTP, |
| 967 | sizeof(MIXER_XML_PATH_MTP)); |
| 968 | msm_device_to_be_id = msm_device_to_be_id_internal_codec; |
| 969 | msm_be_id_array_len = |
| 970 | sizeof(msm_device_to_be_id_internal_codec) / sizeof(msm_device_to_be_id_internal_codec[0]); |
| 971 | } else if (!strncmp(snd_card_name, "msm8952-tomtom-snd-card", |
| 972 | sizeof("msm8952-tomtom-snd-card"))) { |
| 973 | strlcpy(mixer_xml_path, MIXER_XML_PATH_WCD9330, |
| 974 | sizeof(MIXER_XML_PATH_WCD9330)); |
| 975 | msm_device_to_be_id = msm_device_to_be_id_external_codec; |
| 976 | msm_be_id_array_len = |
| 977 | sizeof(msm_device_to_be_id_external_codec) / sizeof(msm_device_to_be_id_external_codec[0]); |
Xiaojun Sang | 68b3944 | 2015-09-23 16:29:43 +0800 | [diff] [blame] | 978 | } else if (!strncmp(snd_card_name, "msm8952-sku1-snd-card", |
| 979 | sizeof("msm8952-sku1-snd-card"))) { |
| 980 | strlcpy(mixer_xml_path, MIXER_XML_PATH_SKU1, |
| 981 | sizeof(MIXER_XML_PATH_SKU1)); |
| 982 | msm_device_to_be_id = msm_device_to_be_id_internal_codec; |
| 983 | msm_be_id_array_len = |
| 984 | sizeof(msm_device_to_be_id_internal_codec) / sizeof(msm_device_to_be_id_internal_codec[0]); |
| 985 | } else if (!strncmp(snd_card_name, "msm8952-sku2-snd-card", |
| 986 | sizeof("msm8952-sku2-snd-card"))) { |
| 987 | strlcpy(mixer_xml_path, MIXER_XML_PATH_SKU2, |
| 988 | sizeof(MIXER_XML_PATH_SKU2)); |
| 989 | msm_device_to_be_id = msm_device_to_be_id_internal_codec; |
| 990 | msm_be_id_array_len = |
| 991 | sizeof(msm_device_to_be_id_internal_codec) / sizeof(msm_device_to_be_id_internal_codec[0]); |
Xiaojun Sang | 9cd237a | 2015-11-20 15:30:18 +0800 | [diff] [blame] | 992 | } else if (!strncmp(snd_card_name, "msm8953-sku3-tasha-snd-card", |
| 993 | sizeof("msm8953-sku3-tasha-snd-card"))) { |
| 994 | strlcpy(mixer_xml_path, MIXER_XML_PATH_SKU3, |
| 995 | sizeof(MIXER_XML_PATH_SKU3)); |
| 996 | msm_device_to_be_id = msm_device_to_be_id_external_codec; |
| 997 | msm_be_id_array_len = |
| 998 | sizeof(msm_device_to_be_id_external_codec) / sizeof(msm_device_to_be_id_external_codec[0]); |
Walter Yang | cd13272 | 2015-04-08 16:04:30 +0800 | [diff] [blame] | 999 | } else if (!strncmp(snd_card_name, "msm8952-skum-snd-card", |
| 1000 | sizeof("msm8952-skum-snd-card"))) { |
| 1001 | strlcpy(mixer_xml_path, MIXER_XML_PATH_SKUM, |
| 1002 | sizeof(MIXER_XML_PATH_SKUM)); |
| 1003 | msm_device_to_be_id = msm_device_to_be_id_internal_codec; |
| 1004 | msm_be_id_array_len = |
| 1005 | sizeof(msm_device_to_be_id_internal_codec) / sizeof(msm_device_to_be_id_internal_codec[0]); |
Preetam Singh Ranawat | 9519e9c | 2015-11-18 16:05:55 +0530 | [diff] [blame] | 1006 | } else if (!strncmp(snd_card_name, "msm8952-tasha-snd-card", |
| 1007 | sizeof("msm8952-tasha-snd-card"))) { |
| 1008 | strlcpy(mixer_xml_path, MIXER_XML_PATH_WCD9335, |
| 1009 | sizeof(MIXER_XML_PATH_WCD9335)); |
| 1010 | msm_device_to_be_id = msm_device_to_be_id_external_codec; |
| 1011 | msm_be_id_array_len = |
| 1012 | sizeof(msm_device_to_be_id_external_codec) / sizeof(msm_device_to_be_id_external_codec[0]); |
Naresh Tanniru | 0d28b4a | 2015-03-23 00:58:49 +0530 | [diff] [blame] | 1013 | |
Preetam Singh Ranawat | 9519e9c | 2015-11-18 16:05:55 +0530 | [diff] [blame] | 1014 | } else if (!strncmp(snd_card_name, "msm8952-tashalite-snd-card", |
| 1015 | sizeof("msm8952-tashalite-snd-card"))) { |
| 1016 | strlcpy(mixer_xml_path, MIXER_XML_PATH_WCD9326, |
| 1017 | MAX_MIXER_XML_PATH); |
| 1018 | msm_device_to_be_id = msm_device_to_be_id_external_codec; |
| 1019 | msm_be_id_array_len = |
| 1020 | sizeof(msm_device_to_be_id_external_codec) / sizeof(msm_device_to_be_id_external_codec[0]); |
Meng Wang | 2d74762 | 2015-08-07 10:11:41 +0800 | [diff] [blame] | 1021 | } else if (!strncmp(snd_card_name, "msm8976-skun-snd-card", |
| 1022 | sizeof("msm8976-skun-snd-card"))) { |
| 1023 | strlcpy(mixer_xml_path, MIXER_XML_PATH_SKUN_CAJON, |
| 1024 | sizeof(MIXER_XML_PATH_SKUN_CAJON)); |
| 1025 | msm_device_to_be_id = msm_device_to_be_id_internal_codec; |
| 1026 | msm_be_id_array_len = |
| 1027 | sizeof(msm_device_to_be_id_internal_codec) / sizeof(msm_device_to_be_id_internal_codec[0]); |
Naresh Tanniru | 4d1e1a1 | 2015-12-16 19:37:50 +0530 | [diff] [blame] | 1028 | |
| 1029 | } else if (!strncmp(snd_card_name, "msm8937-snd-card-mtp", |
| 1030 | sizeof("msm8937-snd-card-mtp"))) { |
| 1031 | strlcpy(mixer_xml_path, MIXER_XML_PATH_MTP, |
| 1032 | sizeof(MIXER_XML_PATH_MTP)); |
| 1033 | msm_device_to_be_id = msm_device_to_be_id_internal_codec; |
| 1034 | msm_be_id_array_len = |
| 1035 | sizeof(msm_device_to_be_id_internal_codec) / sizeof(msm_device_to_be_id_internal_codec[0]); |
| 1036 | } else if (!strncmp(snd_card_name, "msm8937-tasha-snd-card", |
| 1037 | sizeof("msm8937-tasha-snd-card"))) { |
| 1038 | strlcpy(mixer_xml_path, MIXER_XML_PATH_WCD9335, |
| 1039 | sizeof(MIXER_XML_PATH_WCD9335)); |
| 1040 | msm_device_to_be_id = msm_device_to_be_id_external_codec; |
| 1041 | msm_be_id_array_len = |
| 1042 | sizeof(msm_device_to_be_id_external_codec) / sizeof(msm_device_to_be_id_external_codec[0]); |
| 1043 | } else if (!strncmp(snd_card_name, "msm8937-tashalite-snd-card", |
| 1044 | sizeof("msm8937-tashalite-snd-card"))) { |
| 1045 | strlcpy(mixer_xml_path, MIXER_XML_PATH_WCD9326, |
| 1046 | MAX_MIXER_XML_PATH); |
| 1047 | msm_device_to_be_id = msm_device_to_be_id_external_codec; |
| 1048 | msm_be_id_array_len = |
| 1049 | sizeof(msm_device_to_be_id_external_codec) / sizeof(msm_device_to_be_id_external_codec[0]); |
| 1050 | } else if (!strncmp(snd_card_name, "msm8953-snd-card-mtp", |
| 1051 | sizeof("msm8953-snd-card-mtp"))) { |
| 1052 | strlcpy(mixer_xml_path, MIXER_XML_PATH_MTP, |
| 1053 | sizeof(MIXER_XML_PATH_MTP)); |
| 1054 | msm_device_to_be_id = msm_device_to_be_id_internal_codec; |
| 1055 | msm_be_id_array_len = |
| 1056 | sizeof(msm_device_to_be_id_internal_codec) / sizeof(msm_device_to_be_id_internal_codec[0]); |
| 1057 | } else if (!strncmp(snd_card_name, "msm8953-tasha-snd-card", |
| 1058 | sizeof("msm8953-tasha-snd-card"))) { |
| 1059 | strlcpy(mixer_xml_path, MIXER_XML_PATH_WCD9335, |
| 1060 | sizeof(MIXER_XML_PATH_WCD9335)); |
| 1061 | msm_device_to_be_id = msm_device_to_be_id_external_codec; |
| 1062 | msm_be_id_array_len = |
| 1063 | sizeof(msm_device_to_be_id_external_codec) / sizeof(msm_device_to_be_id_external_codec[0]); |
| 1064 | } else if (!strncmp(snd_card_name, "msm8953-tashalite-snd-card", |
| 1065 | sizeof("msm8937-tashalite-snd-card"))) { |
| 1066 | strlcpy(mixer_xml_path, MIXER_XML_PATH_WCD9326, |
| 1067 | MAX_MIXER_XML_PATH); |
| 1068 | msm_device_to_be_id = msm_device_to_be_id_external_codec; |
| 1069 | msm_be_id_array_len = |
| 1070 | sizeof(msm_device_to_be_id_external_codec) / sizeof(msm_device_to_be_id_external_codec[0]); |
Meng Wang | c527450 | 2016-04-12 16:20:41 +0800 | [diff] [blame] | 1071 | } else if (!strncmp(snd_card_name, "msm8917-tmo-snd-card", |
| 1072 | sizeof("msm8917-tmo-snd-card"))) { |
| 1073 | strlcpy(mixer_xml_path, MIXER_XML_PATH_SKU2, |
| 1074 | MAX_MIXER_XML_PATH); |
| 1075 | msm_device_to_be_id = msm_device_to_be_id_internal_codec; |
| 1076 | msm_be_id_array_len = |
| 1077 | sizeof(msm_device_to_be_id_internal_codec) / sizeof(msm_device_to_be_id_internal_codec[0]); |
| 1078 | } else if (!strncmp(snd_card_name, "msm8917-sku5-snd-card", |
| 1079 | sizeof("msm8917-sku5-snd-card"))) { |
| 1080 | strlcpy(mixer_xml_path, MIXER_XML_PATH_SKU2, |
| 1081 | MAX_MIXER_XML_PATH); |
| 1082 | msm_device_to_be_id = msm_device_to_be_id_internal_codec; |
| 1083 | msm_be_id_array_len = |
| 1084 | sizeof(msm_device_to_be_id_internal_codec) / sizeof(msm_device_to_be_id_internal_codec[0]); |
| 1085 | } else if (!strncmp(snd_card_name, "msm8940-sku6-snd-card", |
| 1086 | sizeof("msm8940-sku6-snd-card"))) { |
| 1087 | strlcpy(mixer_xml_path, MIXER_XML_PATH_SKU1, |
| 1088 | MAX_MIXER_XML_PATH); |
| 1089 | msm_device_to_be_id = msm_device_to_be_id_internal_codec; |
| 1090 | msm_be_id_array_len = |
| 1091 | sizeof(msm_device_to_be_id_internal_codec) / sizeof(msm_device_to_be_id_internal_codec[0]); |
Dhananjay Kumar | d3ab9f4 | 2016-07-20 17:05:47 +0530 | [diff] [blame] | 1092 | } else if (!strncmp(snd_card_name, "msmfalcon-tasha-snd-card", |
| 1093 | sizeof("msmfalcon-tasha-snd-card"))) { |
| 1094 | strlcpy(mixer_xml_path, MIXER_XML_PATH_WCD9335, |
| 1095 | sizeof(MIXER_XML_PATH_WCD9335)); |
| 1096 | msm_device_to_be_id = msm_device_to_be_id_external_codec; |
| 1097 | msm_be_id_array_len = |
| 1098 | sizeof(msm_device_to_be_id_external_codec) / sizeof(msm_device_to_be_id_external_codec[0]); |
Xiaojun Sang | c30f028 | 2016-07-18 11:22:09 +0800 | [diff] [blame^] | 1099 | } else if (!strncmp(snd_card_name, "msm8920-sku7-snd-card", |
| 1100 | sizeof("msm8920-sku7-snd-card"))) { |
| 1101 | strlcpy(mixer_xml_path, MIXER_XML_PATH_SKU1, |
| 1102 | MAX_MIXER_XML_PATH); |
| 1103 | msm_device_to_be_id = msm_device_to_be_id_internal_codec; |
| 1104 | msm_be_id_array_len = |
| 1105 | sizeof(msm_device_to_be_id_internal_codec) / sizeof(msm_device_to_be_id_internal_codec[0]); |
Asish Bhattacharya | 4ff2480 | 2014-04-24 17:46:54 +0530 | [diff] [blame] | 1106 | } else { |
| 1107 | strlcpy(mixer_xml_path, MIXER_XML_PATH, |
| 1108 | sizeof(MIXER_XML_PATH)); |
Pradnya Chaphekar | 8a9dcd8 | 2014-09-09 09:49:10 -0700 | [diff] [blame] | 1109 | |
| 1110 | msm_device_to_be_id = msm_device_to_be_id_internal_codec; |
| 1111 | msm_be_id_array_len = |
| 1112 | sizeof(msm_device_to_be_id_internal_codec) / sizeof(msm_device_to_be_id_internal_codec[0]); |
| 1113 | |
Asish Bhattacharya | 4ff2480 | 2014-04-24 17:46:54 +0530 | [diff] [blame] | 1114 | } |
| 1115 | } |
| 1116 | |
Apoorv Raghuvanshi | 9533335 | 2015-07-06 15:07:14 -0700 | [diff] [blame] | 1117 | void platform_set_echo_reference(struct audio_device *adev, bool enable, |
Satya Krishna Pindiproli | f1cd92b | 2016-04-14 19:05:23 +0530 | [diff] [blame] | 1118 | audio_devices_t out_device __unused) |
Apoorv Raghuvanshi | 9533335 | 2015-07-06 15:07:14 -0700 | [diff] [blame] | 1119 | { |
| 1120 | struct platform_data *my_data = (struct platform_data *)adev->platform; |
Apoorv Raghuvanshi | 9533335 | 2015-07-06 15:07:14 -0700 | [diff] [blame] | 1121 | |
| 1122 | if (strcmp(my_data->ec_ref_mixer_path, "")) { |
| 1123 | ALOGV("%s: disabling %s", __func__, my_data->ec_ref_mixer_path); |
| 1124 | audio_route_reset_and_update_path(adev->audio_route, |
| 1125 | my_data->ec_ref_mixer_path); |
| 1126 | } |
| 1127 | |
| 1128 | if (enable) { |
Apoorv Raghuvanshi | 9533335 | 2015-07-06 15:07:14 -0700 | [diff] [blame] | 1129 | if (adev->snd_dev_ref_cnt[SND_DEVICE_OUT_HEADPHONES_44_1] > 0) |
| 1130 | strlcpy(my_data->ec_ref_mixer_path, "echo-reference headphones-44.1", |
| 1131 | sizeof(my_data->ec_ref_mixer_path)); |
Leena Winterrowd | d7a04cd | 2016-01-07 11:50:02 -0800 | [diff] [blame] | 1132 | else if (adev->snd_dev_ref_cnt[SND_DEVICE_OUT_SPEAKER_VBAT] > 0) |
Apoorv Raghuvanshi | 9533335 | 2015-07-06 15:07:14 -0700 | [diff] [blame] | 1133 | strlcpy(my_data->ec_ref_mixer_path, "vbat-speaker echo-reference", |
| 1134 | sizeof(my_data->ec_ref_mixer_path)); |
| 1135 | else |
| 1136 | strlcpy(my_data->ec_ref_mixer_path, "echo-reference", |
| 1137 | sizeof(my_data->ec_ref_mixer_path)); |
| 1138 | |
| 1139 | |
| 1140 | ALOGD("%s: enabling %s", __func__, my_data->ec_ref_mixer_path); |
| 1141 | audio_route_apply_and_update_path(adev->audio_route, |
| 1142 | my_data->ec_ref_mixer_path); |
| 1143 | } |
| 1144 | } |
Banajit Goswami | 20cdd21 | 2015-09-11 01:11:30 -0700 | [diff] [blame] | 1145 | void platform_set_gsm_mode(void *platform, bool enable) |
| 1146 | { |
| 1147 | struct platform_data *my_data = (struct platform_data *)platform; |
| 1148 | struct audio_device *adev = my_data->adev; |
| 1149 | |
| 1150 | if (my_data->gsm_mode_enabled) { |
| 1151 | my_data->gsm_mode_enabled = false; |
| 1152 | ALOGV("%s: disabling gsm mode", __func__); |
| 1153 | audio_route_reset_and_update_path(adev->audio_route, "gsm-mode"); |
| 1154 | } |
| 1155 | |
| 1156 | if (enable) { |
| 1157 | my_data->gsm_mode_enabled = true; |
| 1158 | ALOGD("%s: enabling gsm mode", __func__); |
| 1159 | audio_route_apply_and_update_path(adev->audio_route, "gsm-mode"); |
| 1160 | } |
| 1161 | } |
| 1162 | |
Naresh Tanniru | db72d1e | 2014-03-05 17:33:47 +0530 | [diff] [blame] | 1163 | void close_csd_client(struct csd_data *csd) |
| 1164 | { |
| 1165 | if (csd != NULL) { |
| 1166 | csd->deinit(); |
| 1167 | dlclose(csd->csd_client); |
| 1168 | free(csd); |
| 1169 | csd = NULL; |
| 1170 | } |
| 1171 | } |
| 1172 | |
Preetam Singh Ranawat | 8bde2c5 | 2015-03-20 12:00:49 +0530 | [diff] [blame] | 1173 | |
Chaithanya Krishna Bacharaju | 9955b16 | 2016-05-25 16:25:53 +0530 | [diff] [blame] | 1174 | static void set_platform_defaults(struct platform_data * my_data) |
Preetam Singh Ranawat | 8bde2c5 | 2015-03-20 12:00:49 +0530 | [diff] [blame] | 1175 | { |
Naresh Tanniru | 34a303c | 2016-01-27 17:26:41 +0530 | [diff] [blame] | 1176 | int32_t dev, count = 0; |
Naresh Tanniru | 34a303c | 2016-01-27 17:26:41 +0530 | [diff] [blame] | 1177 | const char *MEDIA_MIMETYPE_AUDIO_ALAC = "audio/alac"; |
| 1178 | const char *MEDIA_MIMETYPE_AUDIO_APE = "audio/x-ape"; |
| 1179 | |
Preetam Singh Ranawat | 8bde2c5 | 2015-03-20 12:00:49 +0530 | [diff] [blame] | 1180 | for (dev = 0; dev < SND_DEVICE_MAX; dev++) { |
Sidipotu Ashok | 9f0b16e | 2016-04-28 13:48:28 +0530 | [diff] [blame] | 1181 | backend_tag_table[dev] = NULL; |
| 1182 | hw_interface_table[dev] = NULL; |
Preetam Singh Ranawat | 8bde2c5 | 2015-03-20 12:00:49 +0530 | [diff] [blame] | 1183 | } |
| 1184 | for (dev = 0; dev < SND_DEVICE_MAX; dev++) { |
Preetam Singh Ranawat | c61f867 | 2015-06-18 23:20:28 +0530 | [diff] [blame] | 1185 | backend_bit_width_table[dev] = CODEC_BACKEND_DEFAULT_BIT_WIDTH; |
Preetam Singh Ranawat | 8bde2c5 | 2015-03-20 12:00:49 +0530 | [diff] [blame] | 1186 | } |
| 1187 | |
Sidipotu Ashok | 9f0b16e | 2016-04-28 13:48:28 +0530 | [diff] [blame] | 1188 | // To overwrite these go to the audio_platform_info.xml file. |
| 1189 | backend_tag_table[SND_DEVICE_IN_BT_SCO_MIC] = strdup("bt-sco"); |
| 1190 | backend_tag_table[SND_DEVICE_IN_BT_SCO_MIC_WB] = strdup("bt-sco-wb"); |
| 1191 | backend_tag_table[SND_DEVICE_IN_BT_SCO_MIC_NREC] = strdup("bt-sco"); |
| 1192 | backend_tag_table[SND_DEVICE_IN_BT_SCO_MIC_WB_NREC] = strdup("bt-sco-wb"); |
| 1193 | backend_tag_table[SND_DEVICE_OUT_BT_SCO] = strdup("bt-sco"); |
| 1194 | backend_tag_table[SND_DEVICE_OUT_BT_SCO_WB] = strdup("bt-sco-wb"); |
| 1195 | backend_tag_table[SND_DEVICE_OUT_HDMI] = strdup("hdmi"); |
| 1196 | backend_tag_table[SND_DEVICE_OUT_SPEAKER_AND_HDMI] = strdup("speaker-and-hdmi"); |
| 1197 | backend_tag_table[SND_DEVICE_OUT_VOICE_TX] = strdup("afe-proxy"); |
| 1198 | backend_tag_table[SND_DEVICE_IN_VOICE_RX] = strdup("afe-proxy"); |
| 1199 | backend_tag_table[SND_DEVICE_OUT_AFE_PROXY] = strdup("afe-proxy"); |
| 1200 | backend_tag_table[SND_DEVICE_OUT_USB_HEADSET] = strdup("usb-headphones"); |
| 1201 | backend_tag_table[SND_DEVICE_OUT_SPEAKER_AND_USB_HEADSET] = |
Preetam Singh Ranawat | 8bde2c5 | 2015-03-20 12:00:49 +0530 | [diff] [blame] | 1202 | strdup("speaker-and-usb-headphones"); |
Sidipotu Ashok | 9f0b16e | 2016-04-28 13:48:28 +0530 | [diff] [blame] | 1203 | backend_tag_table[SND_DEVICE_IN_USB_HEADSET_MIC] = strdup("usb-headset-mic"); |
| 1204 | backend_tag_table[SND_DEVICE_IN_CAPTURE_FM] = strdup("capture-fm"); |
| 1205 | backend_tag_table[SND_DEVICE_OUT_TRANSMISSION_FM] = strdup("transmission-fm"); |
| 1206 | backend_tag_table[SND_DEVICE_OUT_HEADPHONES_44_1] = strdup("headphones-44.1"); |
| 1207 | backend_tag_table[SND_DEVICE_OUT_VOICE_SPEAKER_VBAT] = strdup("vbat-voice-speaker"); |
| 1208 | |
| 1209 | hw_interface_table[SND_DEVICE_OUT_HDMI] = strdup("HDMI_RX"); |
| 1210 | hw_interface_table[SND_DEVICE_OUT_SPEAKER_AND_HDMI] = strdup("SLIMBUS_0_RX-and-HDMI_RX"); |
| 1211 | hw_interface_table[SND_DEVICE_OUT_VOICE_TX] = strdup("AFE_PCM_RX"); |
Naresh Tanniru | 34a303c | 2016-01-27 17:26:41 +0530 | [diff] [blame] | 1212 | |
Chaithanya Krishna Bacharaju | 9955b16 | 2016-05-25 16:25:53 +0530 | [diff] [blame] | 1213 | my_data->max_mic_count = PLATFORM_DEFAULT_MIC_COUNT; |
Naresh Tanniru | 34a303c | 2016-01-27 17:26:41 +0530 | [diff] [blame] | 1214 | /*remove ALAC & APE from DSP decoder list based on software decoder availability*/ |
Alexy Joseph | b137994 | 2016-01-29 15:49:38 -0800 | [diff] [blame] | 1215 | for (count = 0; count < (int32_t) (sizeof(dsp_only_decoders_mime)/sizeof(dsp_only_decoders_mime[0])); |
Naresh Tanniru | 34a303c | 2016-01-27 17:26:41 +0530 | [diff] [blame] | 1216 | count++) { |
| 1217 | |
| 1218 | if (!strncmp(MEDIA_MIMETYPE_AUDIO_ALAC, dsp_only_decoders_mime[count], |
| 1219 | strlen(dsp_only_decoders_mime[count]))) { |
| 1220 | |
| 1221 | if(property_get_bool("use.qti.sw.alac.decoder", false)) { |
| 1222 | ALOGD("Alac software decoder is available...removing alac from DSP decoder list"); |
Preetam Singh Ranawat | 5319430 | 2016-03-15 16:37:42 +0530 | [diff] [blame] | 1223 | strlcpy(dsp_only_decoders_mime[count],"none",5); |
Naresh Tanniru | 34a303c | 2016-01-27 17:26:41 +0530 | [diff] [blame] | 1224 | } |
| 1225 | } else if (!strncmp(MEDIA_MIMETYPE_AUDIO_APE, dsp_only_decoders_mime[count], |
| 1226 | strlen(dsp_only_decoders_mime[count]))) { |
| 1227 | |
| 1228 | if(property_get_bool("use.qti.sw.ape.decoder", false)) { |
| 1229 | ALOGD("APE software decoder is available...removing ape from DSP decoder list"); |
Preetam Singh Ranawat | 5319430 | 2016-03-15 16:37:42 +0530 | [diff] [blame] | 1230 | strlcpy(dsp_only_decoders_mime[count],"none",5); |
Naresh Tanniru | 34a303c | 2016-01-27 17:26:41 +0530 | [diff] [blame] | 1231 | } |
| 1232 | } |
| 1233 | } |
Preetam Singh Ranawat | 8bde2c5 | 2015-03-20 12:00:49 +0530 | [diff] [blame] | 1234 | } |
| 1235 | |
Avinash Vaish | 71c066d | 2014-08-27 12:32:35 +0530 | [diff] [blame] | 1236 | void get_cvd_version(char *cvd_version, struct audio_device *adev) |
| 1237 | { |
| 1238 | struct mixer_ctl *ctl; |
| 1239 | int count; |
| 1240 | int ret = 0; |
| 1241 | |
| 1242 | ctl = mixer_get_ctl_by_name(adev->mixer, CVD_VERSION_MIXER_CTL); |
| 1243 | if (!ctl) { |
| 1244 | ALOGE("%s: Could not get ctl for mixer cmd - %s", __func__, CVD_VERSION_MIXER_CTL); |
| 1245 | goto done; |
| 1246 | } |
| 1247 | mixer_ctl_update(ctl); |
| 1248 | |
| 1249 | count = mixer_ctl_get_num_values(ctl); |
| 1250 | if (count > MAX_CVD_VERSION_STRING_SIZE) |
| 1251 | count = MAX_CVD_VERSION_STRING_SIZE; |
| 1252 | |
| 1253 | ret = mixer_ctl_get_array(ctl, cvd_version, count); |
| 1254 | if (ret != 0) { |
| 1255 | ALOGE("%s: ERROR! mixer_ctl_get_array() failed to get CVD Version", __func__); |
| 1256 | goto done; |
| 1257 | } |
| 1258 | |
| 1259 | done: |
| 1260 | return; |
| 1261 | } |
| 1262 | |
Srikanth Uyyala | cae4aa3 | 2014-10-17 13:44:09 +0530 | [diff] [blame] | 1263 | static int hw_util_open(int card_no) |
| 1264 | { |
| 1265 | int fd = -1; |
| 1266 | char dev_name[256]; |
| 1267 | |
| 1268 | snprintf(dev_name, sizeof(dev_name), "/dev/snd/hwC%uD%u", |
| 1269 | card_no, WCD9XXX_CODEC_HWDEP_NODE); |
| 1270 | ALOGD("%s Opening device %s\n", __func__, dev_name); |
| 1271 | fd = open(dev_name, O_WRONLY); |
| 1272 | if (fd < 0) { |
| 1273 | ALOGE("%s: cannot open device '%s'\n", __func__, dev_name); |
| 1274 | return fd; |
| 1275 | } |
| 1276 | ALOGD("%s success", __func__); |
| 1277 | return fd; |
| 1278 | } |
| 1279 | |
| 1280 | struct param_data { |
| 1281 | int use_case; |
| 1282 | int acdb_id; |
| 1283 | int get_size; |
| 1284 | int buff_size; |
| 1285 | int data_size; |
| 1286 | void *buff; |
| 1287 | }; |
| 1288 | |
Banajit Goswami | 20cdd21 | 2015-09-11 01:11:30 -0700 | [diff] [blame] | 1289 | static int send_vbat_adc_data_to_acdb(struct platform_data *plat_data, char *cal_type) |
| 1290 | { |
| 1291 | int ret = 0; |
| 1292 | struct mixer_ctl *ctl; |
| 1293 | uint16_t vbat_adc_data[2]; |
| 1294 | struct platform_data *my_data = plat_data; |
| 1295 | struct audio_device *adev = my_data->adev; |
| 1296 | |
| 1297 | const char *mixer_ctl_name = "Vbat ADC data"; |
| 1298 | |
| 1299 | ctl = mixer_get_ctl_by_name(adev->mixer, mixer_ctl_name); |
| 1300 | if (!ctl) { |
| 1301 | ALOGE("%s: Could not get ctl for mixer ctl name - %s", |
| 1302 | __func__, mixer_ctl_name); |
| 1303 | ret = -EINVAL; |
| 1304 | goto done; |
| 1305 | } |
| 1306 | |
| 1307 | vbat_adc_data[0] = mixer_ctl_get_value(ctl, 0); |
| 1308 | vbat_adc_data[1] = mixer_ctl_get_value(ctl, 1); |
| 1309 | |
| 1310 | ALOGD("%s: Vbat ADC output values: Dcp1: %d , Dcp2: %d", |
| 1311 | __func__, vbat_adc_data[0], vbat_adc_data[1]); |
| 1312 | |
| 1313 | ret = my_data->acdb_set_codec_data(&vbat_adc_data[0], cal_type); |
| 1314 | |
| 1315 | done: |
| 1316 | return ret; |
| 1317 | } |
| 1318 | |
Venkata Narendra Kumar Gutta | e071e5a | 2016-01-11 18:08:26 +0530 | [diff] [blame] | 1319 | static void send_codec_cal(acdb_loader_get_calibration_t acdb_loader_get_calibration, |
Banajit Goswami | 20cdd21 | 2015-09-11 01:11:30 -0700 | [diff] [blame] | 1320 | struct platform_data *plat_data, int fd) |
Srikanth Uyyala | cae4aa3 | 2014-10-17 13:44:09 +0530 | [diff] [blame] | 1321 | { |
Venkata Narendra Kumar Gutta | e071e5a | 2016-01-11 18:08:26 +0530 | [diff] [blame] | 1322 | int type; |
Srikanth Uyyala | cae4aa3 | 2014-10-17 13:44:09 +0530 | [diff] [blame] | 1323 | |
| 1324 | for (type = WCD9XXX_ANC_CAL; type < WCD9XXX_MAX_CAL; type++) { |
| 1325 | struct wcdcal_ioctl_buffer codec_buffer; |
| 1326 | struct param_data calib; |
Venkata Narendra Kumar Gutta | e071e5a | 2016-01-11 18:08:26 +0530 | [diff] [blame] | 1327 | int ret; |
Srikanth Uyyala | cae4aa3 | 2014-10-17 13:44:09 +0530 | [diff] [blame] | 1328 | |
Bharath Ramachandramurthy | 63a47ef | 2015-08-31 17:41:46 -0700 | [diff] [blame] | 1329 | /* MAD calibration is handled by sound trigger HAL, skip here */ |
| 1330 | if (type == WCD9XXX_MAD_CAL) |
| 1331 | continue; |
| 1332 | |
Banajit Goswami | 20cdd21 | 2015-09-11 01:11:30 -0700 | [diff] [blame] | 1333 | if((plat_data->is_vbat_speaker) && (WCD9XXX_VBAT_CAL == type)) { |
| 1334 | ret = send_vbat_adc_data_to_acdb(plat_data, cal_name_info[type]); |
| 1335 | if (ret < 0) |
| 1336 | ALOGE("%s error in sending vbat adc data to acdb", __func__); |
| 1337 | } |
| 1338 | |
Srikanth Uyyala | cae4aa3 | 2014-10-17 13:44:09 +0530 | [diff] [blame] | 1339 | calib.get_size = 1; |
| 1340 | ret = acdb_loader_get_calibration(cal_name_info[type], sizeof(struct param_data), |
| 1341 | &calib); |
| 1342 | if (ret < 0) { |
| 1343 | ALOGE("%s get_calibration failed\n", __func__); |
Venkata Narendra Kumar Gutta | e071e5a | 2016-01-11 18:08:26 +0530 | [diff] [blame] | 1344 | continue; |
Srikanth Uyyala | cae4aa3 | 2014-10-17 13:44:09 +0530 | [diff] [blame] | 1345 | } |
| 1346 | calib.get_size = 0; |
| 1347 | calib.buff = malloc(calib.buff_size); |
Sidipotu Ashok | 04ab3d3 | 2014-12-30 10:28:31 +0530 | [diff] [blame] | 1348 | if(calib.buff == NULL) { |
| 1349 | ALOGE("%s mem allocation for %d bytes for %s failed\n" |
| 1350 | , __func__, calib.buff_size, cal_name_info[type]); |
Venkata Narendra Kumar Gutta | e071e5a | 2016-01-11 18:08:26 +0530 | [diff] [blame] | 1351 | continue; |
Sidipotu Ashok | 04ab3d3 | 2014-12-30 10:28:31 +0530 | [diff] [blame] | 1352 | } |
Srikanth Uyyala | cae4aa3 | 2014-10-17 13:44:09 +0530 | [diff] [blame] | 1353 | ret = acdb_loader_get_calibration(cal_name_info[type], |
| 1354 | sizeof(struct param_data), &calib); |
| 1355 | if (ret < 0) { |
Sidipotu Ashok | 04ab3d3 | 2014-12-30 10:28:31 +0530 | [diff] [blame] | 1356 | ALOGE("%s get_calibration failed type=%s calib.size=%d\n" |
Preetam Singh Ranawat | 5319430 | 2016-03-15 16:37:42 +0530 | [diff] [blame] | 1357 | , __func__, cal_name_info[type], calib.buff_size); |
Srikanth Uyyala | cae4aa3 | 2014-10-17 13:44:09 +0530 | [diff] [blame] | 1358 | free(calib.buff); |
Venkata Narendra Kumar Gutta | e071e5a | 2016-01-11 18:08:26 +0530 | [diff] [blame] | 1359 | continue; |
Srikanth Uyyala | cae4aa3 | 2014-10-17 13:44:09 +0530 | [diff] [blame] | 1360 | } |
| 1361 | codec_buffer.buffer = calib.buff; |
| 1362 | codec_buffer.size = calib.data_size; |
| 1363 | codec_buffer.cal_type = type; |
| 1364 | if (ioctl(fd, SNDRV_CTL_IOCTL_HWDEP_CAL_TYPE, &codec_buffer) < 0) |
Sidipotu Ashok | 04ab3d3 | 2014-12-30 10:28:31 +0530 | [diff] [blame] | 1365 | ALOGE("Failed to call ioctl for %s err=%d calib.size=%d", |
| 1366 | cal_name_info[type], errno, codec_buffer.size); |
| 1367 | ALOGD("%s cal sent for %s calib.size=%d" |
| 1368 | , __func__, cal_name_info[type], codec_buffer.size); |
Srikanth Uyyala | cae4aa3 | 2014-10-17 13:44:09 +0530 | [diff] [blame] | 1369 | free(calib.buff); |
| 1370 | } |
Srikanth Uyyala | cae4aa3 | 2014-10-17 13:44:09 +0530 | [diff] [blame] | 1371 | } |
| 1372 | |
| 1373 | static void audio_hwdep_send_cal(struct platform_data *plat_data) |
| 1374 | { |
Venkata Narendra Kumar Gutta | e071e5a | 2016-01-11 18:08:26 +0530 | [diff] [blame] | 1375 | int fd = plat_data->hw_dep_fd; |
Srikanth Uyyala | cae4aa3 | 2014-10-17 13:44:09 +0530 | [diff] [blame] | 1376 | |
Venkata Narendra Kumar Gutta | e071e5a | 2016-01-11 18:08:26 +0530 | [diff] [blame] | 1377 | if (fd < 0) |
| 1378 | fd = hw_util_open(plat_data->adev->snd_card); |
Srikanth Uyyala | cae4aa3 | 2014-10-17 13:44:09 +0530 | [diff] [blame] | 1379 | if (fd == -1) { |
| 1380 | ALOGE("%s error open\n", __func__); |
| 1381 | return; |
| 1382 | } |
| 1383 | |
| 1384 | acdb_loader_get_calibration = (acdb_loader_get_calibration_t) |
| 1385 | dlsym(plat_data->acdb_handle, "acdb_loader_get_calibration"); |
| 1386 | |
| 1387 | if (acdb_loader_get_calibration == NULL) { |
| 1388 | ALOGE("%s: ERROR. dlsym Error:%s acdb_loader_get_calibration", __func__, |
| 1389 | dlerror()); |
Venkata Narendra Kumar Gutta | e071e5a | 2016-01-11 18:08:26 +0530 | [diff] [blame] | 1390 | if (fd >= 0) { |
| 1391 | close(fd); |
| 1392 | plat_data->hw_dep_fd = -1; |
| 1393 | } |
Srikanth Uyyala | cae4aa3 | 2014-10-17 13:44:09 +0530 | [diff] [blame] | 1394 | return; |
| 1395 | } |
Venkata Narendra Kumar Gutta | e071e5a | 2016-01-11 18:08:26 +0530 | [diff] [blame] | 1396 | |
| 1397 | send_codec_cal(acdb_loader_get_calibration, plat_data, fd); |
| 1398 | plat_data->hw_dep_fd = fd; |
Srikanth Uyyala | cae4aa3 | 2014-10-17 13:44:09 +0530 | [diff] [blame] | 1399 | } |
| 1400 | |
Naresh Tanniru | 516c245 | 2015-08-14 12:58:24 +0530 | [diff] [blame] | 1401 | const char * get_snd_card_name_for_acdb_loader(const char *snd_card_name) { |
| 1402 | |
| 1403 | if(snd_card_name == NULL) |
| 1404 | return NULL; |
| 1405 | |
| 1406 | // Both tasha & tasha-lite uses tasha ACDB files |
| 1407 | // simulate sound card name for tasha lite, so that |
| 1408 | // ACDB module loads tasha ACDB files for tasha lite |
| 1409 | if(!strncmp(snd_card_name, "msm8976-tashalite-snd-card", |
| 1410 | sizeof("msm8976-tashalite-snd-card"))) { |
Naresh Tanniru | 4d1e1a1 | 2015-12-16 19:37:50 +0530 | [diff] [blame] | 1411 | ALOGD("using tasha ACDB files for tasha-lite"); |
| 1412 | return "msm8976-tasha-snd-card"; |
| 1413 | } |
| 1414 | |
| 1415 | if(!strncmp(snd_card_name, "msm8952-tashalite-snd-card", |
| 1416 | sizeof("msm8952-tashalite-snd-card"))) { |
| 1417 | ALOGD("using tasha ACDB files for tasha-lite"); |
| 1418 | return "msm8952-tasha-snd-card"; |
| 1419 | } |
| 1420 | |
| 1421 | if(!strncmp(snd_card_name, "msm8937-tashalite-snd-card", |
| 1422 | sizeof("msm8937-tashalite-snd-card"))) { |
| 1423 | ALOGD("using tasha ACDB files for tasha-lite"); |
| 1424 | return "msm8937-tasha-snd-card"; |
| 1425 | } |
| 1426 | |
| 1427 | if(!strncmp(snd_card_name, "msm8953-tashalite-snd-card", |
| 1428 | sizeof("msm8953-tashalite-snd-card"))) { |
| 1429 | ALOGD("using tasha ACDB files for tasha-lite"); |
| 1430 | return "msm8953-tasha-snd-card"; |
| 1431 | } |
| 1432 | |
| 1433 | return snd_card_name; |
Naresh Tanniru | 516c245 | 2015-08-14 12:58:24 +0530 | [diff] [blame] | 1434 | } |
| 1435 | |
| 1436 | |
| 1437 | int platform_acdb_init(void *platform) |
Ramjee Singh | 203473b | 2015-06-09 15:18:42 +0530 | [diff] [blame] | 1438 | { |
| 1439 | struct platform_data *my_data = (struct platform_data *)platform; |
| 1440 | char *cvd_version = NULL; |
| 1441 | int key = 0; |
Naresh Tanniru | 516c245 | 2015-08-14 12:58:24 +0530 | [diff] [blame] | 1442 | const char *snd_card_name, *acdb_snd_card_name; |
Ramjee Singh | 203473b | 2015-06-09 15:18:42 +0530 | [diff] [blame] | 1443 | int result; |
| 1444 | char value[PROPERTY_VALUE_MAX]; |
| 1445 | cvd_version = calloc(1, MAX_CVD_VERSION_STRING_SIZE); |
Preetam Singh Ranawat | 6746b7a | 2016-07-18 16:40:24 +0530 | [diff] [blame] | 1446 | if (!cvd_version) { |
Ramjee Singh | 203473b | 2015-06-09 15:18:42 +0530 | [diff] [blame] | 1447 | ALOGE("Failed to allocate cvd version"); |
Preetam Singh Ranawat | 6746b7a | 2016-07-18 16:40:24 +0530 | [diff] [blame] | 1448 | return -1; |
| 1449 | } else { |
Ramjee Singh | 203473b | 2015-06-09 15:18:42 +0530 | [diff] [blame] | 1450 | get_cvd_version(cvd_version, my_data->adev); |
Preetam Singh Ranawat | 6746b7a | 2016-07-18 16:40:24 +0530 | [diff] [blame] | 1451 | } |
Ramjee Singh | 203473b | 2015-06-09 15:18:42 +0530 | [diff] [blame] | 1452 | |
| 1453 | property_get("audio.ds1.metainfo.key",value,"0"); |
| 1454 | key = atoi(value); |
| 1455 | snd_card_name = mixer_get_name(my_data->adev->mixer); |
Naresh Tanniru | 516c245 | 2015-08-14 12:58:24 +0530 | [diff] [blame] | 1456 | acdb_snd_card_name = get_snd_card_name_for_acdb_loader(snd_card_name); |
| 1457 | |
| 1458 | result = my_data->acdb_init(acdb_snd_card_name, cvd_version, key); |
| 1459 | |
Karthik Reddy Katta | 8513f43 | 2016-04-12 14:29:27 +0530 | [diff] [blame] | 1460 | /* Save these variables in platform_data. These will be used |
| 1461 | while reloading ACDB files during run time. */ |
| 1462 | strlcpy(my_data->cvd_version, cvd_version, MAX_CVD_VERSION_STRING_SIZE); |
| 1463 | strlcpy(my_data->snd_card_name, acdb_snd_card_name, |
| 1464 | MAX_SND_CARD_STRING_SIZE); |
| 1465 | my_data->metainfo_key = key; |
| 1466 | |
Ramjee Singh | 203473b | 2015-06-09 15:18:42 +0530 | [diff] [blame] | 1467 | if (cvd_version) |
| 1468 | free(cvd_version); |
| 1469 | if (!result) { |
| 1470 | my_data->is_acdb_initialized = true; |
| 1471 | ALOGD("ACDB initialized"); |
| 1472 | audio_hwdep_send_cal(my_data); |
| 1473 | } else { |
| 1474 | my_data->is_acdb_initialized = false; |
| 1475 | ALOGD("ACDB initialization failed"); |
| 1476 | } |
| 1477 | return result; |
| 1478 | } |
| 1479 | |
Preetam Singh Ranawat | 9519e9c | 2015-11-18 16:05:55 +0530 | [diff] [blame] | 1480 | #define MAX_PATH (256) |
| 1481 | #define THERMAL_SYSFS "/sys/class/thermal" |
| 1482 | #define TZ_TYPE "/sys/class/thermal/thermal_zone%d/type" |
| 1483 | #define TZ_WSA "/sys/class/thermal/thermal_zone%d/temp" |
| 1484 | |
Naresh Tanniru | 74a2eee | 2016-02-10 13:38:19 +0530 | [diff] [blame] | 1485 | static bool check_and_get_wsa_info(char *snd_card_name, int *wsaCount, |
| 1486 | bool *is_wsa_combo_supported) |
Preetam Singh Ranawat | 9519e9c | 2015-11-18 16:05:55 +0530 | [diff] [blame] | 1487 | { |
| 1488 | DIR *tdir = NULL; |
| 1489 | struct dirent *tdirent = NULL; |
| 1490 | int tzn = 0; |
| 1491 | char name[MAX_PATH] = {0}; |
| 1492 | char cwd[MAX_PATH] = {0}; |
| 1493 | char file[10] = "wsa"; |
| 1494 | bool found = false; |
| 1495 | int wsa_count = 0; |
| 1496 | |
| 1497 | if (!getcwd(cwd, sizeof(cwd))) |
| 1498 | return false; |
| 1499 | |
| 1500 | chdir(THERMAL_SYSFS); /* Change dir to read the entries. Doesnt work |
| 1501 | otherwise */ |
| 1502 | tdir = opendir(THERMAL_SYSFS); |
| 1503 | if (!tdir) { |
| 1504 | ALOGE("Unable to open %s\n", THERMAL_SYSFS); |
| 1505 | return false; |
| 1506 | } |
| 1507 | |
| 1508 | while ((tdirent = readdir(tdir))) { |
| 1509 | char buf[50]; |
| 1510 | struct dirent *tzdirent; |
| 1511 | DIR *tzdir = NULL; |
| 1512 | |
| 1513 | tzdir = opendir(tdirent->d_name); |
| 1514 | if (!tzdir) |
| 1515 | continue; |
| 1516 | while ((tzdirent = readdir(tzdir))) { |
| 1517 | if (strcmp(tzdirent->d_name, "type")) |
| 1518 | continue; |
| 1519 | snprintf(name, MAX_PATH, TZ_TYPE, tzn); |
| 1520 | ALOGD("Opening %s\n", name); |
| 1521 | read_line_from_file(name, buf, sizeof(buf)); |
| 1522 | if (strstr(buf, file)) { |
| 1523 | wsa_count++; |
| 1524 | /*We support max only two WSA speakers*/ |
| 1525 | if (wsa_count == 2) |
| 1526 | break; |
| 1527 | } |
| 1528 | tzn++; |
| 1529 | } |
| 1530 | closedir(tzdir); |
| 1531 | } |
| 1532 | if (wsa_count > 0){ |
| 1533 | ALOGD("Found %d WSA present on the platform", wsa_count); |
| 1534 | found = true; |
| 1535 | *wsaCount = wsa_count; |
Naresh Tanniru | 74a2eee | 2016-02-10 13:38:19 +0530 | [diff] [blame] | 1536 | |
| 1537 | /* update wsa combo supported flag based on sound card name */ |
| 1538 | /* wsa combo flag needs to be set to true only for hardware |
| 1539 | combinations which has support for both wsa and non-wsa speaker */ |
Preetam Singh Ranawat | 5319430 | 2016-03-15 16:37:42 +0530 | [diff] [blame] | 1540 | *is_wsa_combo_supported = false; |
| 1541 | if(snd_card_name) { |
| 1542 | if ((!strncmp(snd_card_name, "msm8953-snd-card-mtp", |
| 1543 | sizeof("msm8953-snd-card-mtp")) || |
| 1544 | (!strncmp(snd_card_name, "msm8952-skum-snd-card", |
| 1545 | sizeof("msm8952-skum-snd-card"))))) { |
| 1546 | *is_wsa_combo_supported = true; |
| 1547 | } |
Naresh Tanniru | 74a2eee | 2016-02-10 13:38:19 +0530 | [diff] [blame] | 1548 | } |
Preetam Singh Ranawat | 9519e9c | 2015-11-18 16:05:55 +0530 | [diff] [blame] | 1549 | } |
| 1550 | closedir(tdir); |
| 1551 | chdir(cwd); /* Restore current working dir */ |
| 1552 | return found; |
| 1553 | } |
| 1554 | |
Chaithanya Krishna Bacharaju | 9955b16 | 2016-05-25 16:25:53 +0530 | [diff] [blame] | 1555 | static void get_source_mic_type(struct platform_data * my_data) |
| 1556 | { |
| 1557 | // support max to mono, example if max count is 3, usecase supports Three, dual and mono mic |
| 1558 | switch (my_data->max_mic_count) { |
| 1559 | case 4: |
| 1560 | my_data->source_mic_type |= SOURCE_QUAD_MIC; |
| 1561 | case 3: |
| 1562 | my_data->source_mic_type |= SOURCE_THREE_MIC;; |
| 1563 | case 2: |
| 1564 | my_data->source_mic_type |= SOURCE_DUAL_MIC; |
| 1565 | case 1: |
| 1566 | my_data->source_mic_type |= SOURCE_MONO_MIC; |
| 1567 | break; |
| 1568 | default: |
| 1569 | ALOGE("%s: max_mic_count (%d), is not supported, setting to default", |
| 1570 | __func__, my_data->max_mic_count); |
| 1571 | my_data->source_mic_type = SOURCE_MONO_MIC | SOURCE_DUAL_MIC; |
| 1572 | break; |
| 1573 | } |
| 1574 | } |
| 1575 | |
Naresh Tanniru | e3b1845 | 2014-03-04 14:44:27 +0530 | [diff] [blame] | 1576 | void *platform_init(struct audio_device *adev) |
| 1577 | { |
| 1578 | char value[PROPERTY_VALUE_MAX]; |
Naresh Tanniru | db72d1e | 2014-03-05 17:33:47 +0530 | [diff] [blame] | 1579 | struct platform_data *my_data = NULL; |
Satya Krishna Pindiproli | f1cd92b | 2016-04-14 19:05:23 +0530 | [diff] [blame] | 1580 | int retry_num = 0, snd_card_num = 0; |
Naresh Tanniru | db72d1e | 2014-03-05 17:33:47 +0530 | [diff] [blame] | 1581 | const char *snd_card_name; |
Yeleswarapu Nagaradhesh | 09f30be | 2015-07-22 14:11:03 +0530 | [diff] [blame] | 1582 | char mixer_xml_path[MAX_MIXER_XML_PATH],ffspEnable[PROPERTY_VALUE_MAX]; |
Satish Babu Patakokila | bbd4e9d | 2015-05-13 22:08:06 +0530 | [diff] [blame] | 1583 | const char *mixer_ctl_name = "Set HPX ActiveBe"; |
| 1584 | struct mixer_ctl *ctl = NULL; |
Naveen Kumar | 70e2735 | 2015-07-22 21:07:10 +0530 | [diff] [blame] | 1585 | int idx; |
Preetam Singh Ranawat | 9519e9c | 2015-11-18 16:05:55 +0530 | [diff] [blame] | 1586 | int wsaCount =0; |
Naresh Tanniru | 74a2eee | 2016-02-10 13:38:19 +0530 | [diff] [blame] | 1587 | bool is_wsa_combo_supported = false; |
Naveen Kumar | 70e2735 | 2015-07-22 21:07:10 +0530 | [diff] [blame] | 1588 | |
| 1589 | my_data = calloc(1, sizeof(struct platform_data)); |
| 1590 | |
Chaithanya Krishna Bacharaju | db6236a | 2015-01-30 10:08:33 +0530 | [diff] [blame] | 1591 | if (!my_data) { |
| 1592 | ALOGE("failed to allocate platform data"); |
| 1593 | return NULL; |
| 1594 | } |
Naresh Tanniru | e3b1845 | 2014-03-04 14:44:27 +0530 | [diff] [blame] | 1595 | |
Naresh Tanniru | db72d1e | 2014-03-05 17:33:47 +0530 | [diff] [blame] | 1596 | while (snd_card_num < MAX_SND_CARD) { |
| 1597 | adev->mixer = mixer_open(snd_card_num); |
| 1598 | |
| 1599 | while (!adev->mixer && retry_num < RETRY_NUMBER) { |
| 1600 | usleep(RETRY_US); |
| 1601 | adev->mixer = mixer_open(snd_card_num); |
| 1602 | retry_num++; |
| 1603 | } |
| 1604 | |
| 1605 | if (!adev->mixer) { |
| 1606 | ALOGE("%s: Unable to open the mixer card: %d", __func__, |
| 1607 | snd_card_num); |
| 1608 | retry_num = 0; |
| 1609 | snd_card_num++; |
| 1610 | continue; |
| 1611 | } |
| 1612 | |
| 1613 | snd_card_name = mixer_get_name(adev->mixer); |
Sidipotu Ashok | e6f78cb | 2015-11-05 14:42:20 +0530 | [diff] [blame] | 1614 | ALOGD("%s: snd_card_name: %s", __func__, snd_card_name); |
Naresh Tanniru | db72d1e | 2014-03-05 17:33:47 +0530 | [diff] [blame] | 1615 | |
| 1616 | my_data->hw_info = hw_info_init(snd_card_name); |
| 1617 | if (!my_data->hw_info) { |
| 1618 | ALOGE("%s: Failed to init hardware info", __func__); |
| 1619 | } else { |
Asish Bhattacharya | 4ff2480 | 2014-04-24 17:46:54 +0530 | [diff] [blame] | 1620 | query_platform(snd_card_name, mixer_xml_path); |
| 1621 | ALOGD("%s: mixer path file is %s", __func__, |
| 1622 | mixer_xml_path); |
| 1623 | if (audio_extn_read_xml(adev, snd_card_num, mixer_xml_path, |
| 1624 | MIXER_XML_PATH_AUXPCM) == -ENOSYS) { |
Naresh Tanniru | db72d1e | 2014-03-05 17:33:47 +0530 | [diff] [blame] | 1625 | adev->audio_route = audio_route_init(snd_card_num, |
Asish Bhattacharya | 4ff2480 | 2014-04-24 17:46:54 +0530 | [diff] [blame] | 1626 | mixer_xml_path); |
| 1627 | } |
Naresh Tanniru | db72d1e | 2014-03-05 17:33:47 +0530 | [diff] [blame] | 1628 | if (!adev->audio_route) { |
| 1629 | ALOGE("%s: Failed to init audio route controls, aborting.", |
| 1630 | __func__); |
| 1631 | free(my_data); |
Mingming Yin | dda29e6 | 2015-12-02 18:02:28 -0800 | [diff] [blame] | 1632 | mixer_close(adev->mixer); |
Naresh Tanniru | db72d1e | 2014-03-05 17:33:47 +0530 | [diff] [blame] | 1633 | return NULL; |
| 1634 | } |
| 1635 | adev->snd_card = snd_card_num; |
Venkata Narendra Kumar Gutta | ed408a1 | 2015-03-31 20:24:04 +0530 | [diff] [blame] | 1636 | update_codec_type(snd_card_name); |
Naresh Tanniru | db72d1e | 2014-03-05 17:33:47 +0530 | [diff] [blame] | 1637 | ALOGD("%s: Opened sound card:%d", __func__, snd_card_num); |
| 1638 | break; |
| 1639 | } |
| 1640 | retry_num = 0; |
| 1641 | snd_card_num++; |
Mingming Yin | dda29e6 | 2015-12-02 18:02:28 -0800 | [diff] [blame] | 1642 | mixer_close(adev->mixer); |
Naresh Tanniru | db72d1e | 2014-03-05 17:33:47 +0530 | [diff] [blame] | 1643 | } |
| 1644 | |
| 1645 | if (snd_card_num >= MAX_SND_CARD) { |
| 1646 | ALOGE("%s: Unable to find correct sound card, aborting.", __func__); |
| 1647 | free(my_data); |
| 1648 | return NULL; |
| 1649 | } |
| 1650 | |
Naresh Tanniru | e3b1845 | 2014-03-04 14:44:27 +0530 | [diff] [blame] | 1651 | my_data->adev = adev; |
Naresh Tanniru | e3b1845 | 2014-03-04 14:44:27 +0530 | [diff] [blame] | 1652 | my_data->fluence_in_spkr_mode = false; |
| 1653 | my_data->fluence_in_voice_call = false; |
| 1654 | my_data->fluence_in_voice_rec = false; |
Naresh Tanniru | db72d1e | 2014-03-05 17:33:47 +0530 | [diff] [blame] | 1655 | my_data->fluence_in_audio_rec = false; |
Preetam Singh Ranawat | 8bde2c5 | 2015-03-20 12:00:49 +0530 | [diff] [blame] | 1656 | my_data->external_spk_1 = false; |
| 1657 | my_data->external_spk_2 = false; |
| 1658 | my_data->external_mic = false; |
Naresh Tanniru | db72d1e | 2014-03-05 17:33:47 +0530 | [diff] [blame] | 1659 | my_data->fluence_type = FLUENCE_NONE; |
Karthik Reddy Katta | d9fff86 | 2014-07-21 21:07:21 +0530 | [diff] [blame] | 1660 | my_data->fluence_mode = FLUENCE_ENDFIRE; |
Avinash Vaish | d5fa457 | 2014-09-15 14:41:14 +0530 | [diff] [blame] | 1661 | my_data->slowtalk = false; |
| 1662 | my_data->hd_voice = false; |
Preetam Singh Ranawat | 8bde2c5 | 2015-03-20 12:00:49 +0530 | [diff] [blame] | 1663 | my_data->edid_info = NULL; |
Preetam Singh Ranawat | c7f7f5c | 2015-04-02 12:19:58 +0530 | [diff] [blame] | 1664 | my_data->is_wsa_speaker = false; |
Venkata Narendra Kumar Gutta | e071e5a | 2016-01-11 18:08:26 +0530 | [diff] [blame] | 1665 | my_data->hw_dep_fd = -1; |
Naresh Tanniru | e3b1845 | 2014-03-04 14:44:27 +0530 | [diff] [blame] | 1666 | |
Venkata Narendra Kumar Gutta | 88fd0bc | 2014-03-27 19:47:56 +0530 | [diff] [blame] | 1667 | property_get("ro.qc.sdk.audio.fluencetype", my_data->fluence_cap, ""); |
| 1668 | if (!strncmp("fluencepro", my_data->fluence_cap, sizeof("fluencepro"))) { |
Naresh Tanniru | db72d1e | 2014-03-05 17:33:47 +0530 | [diff] [blame] | 1669 | my_data->fluence_type = FLUENCE_QUAD_MIC | FLUENCE_DUAL_MIC; |
Venkata Narendra Kumar Gutta | 88fd0bc | 2014-03-27 19:47:56 +0530 | [diff] [blame] | 1670 | } else if (!strncmp("fluence", my_data->fluence_cap, sizeof("fluence"))) { |
Naresh Tanniru | db72d1e | 2014-03-05 17:33:47 +0530 | [diff] [blame] | 1671 | my_data->fluence_type = FLUENCE_DUAL_MIC; |
| 1672 | } else { |
| 1673 | my_data->fluence_type = FLUENCE_NONE; |
Naresh Tanniru | e3b1845 | 2014-03-04 14:44:27 +0530 | [diff] [blame] | 1674 | } |
| 1675 | |
Naresh Tanniru | db72d1e | 2014-03-05 17:33:47 +0530 | [diff] [blame] | 1676 | if (my_data->fluence_type != FLUENCE_NONE) { |
Naresh Tanniru | e3b1845 | 2014-03-04 14:44:27 +0530 | [diff] [blame] | 1677 | property_get("persist.audio.fluence.voicecall",value,""); |
Naresh Tanniru | db72d1e | 2014-03-05 17:33:47 +0530 | [diff] [blame] | 1678 | if (!strncmp("true", value, sizeof("true"))) { |
Naresh Tanniru | e3b1845 | 2014-03-04 14:44:27 +0530 | [diff] [blame] | 1679 | my_data->fluence_in_voice_call = true; |
| 1680 | } |
| 1681 | |
| 1682 | property_get("persist.audio.fluence.voicerec",value,""); |
Naresh Tanniru | db72d1e | 2014-03-05 17:33:47 +0530 | [diff] [blame] | 1683 | if (!strncmp("true", value, sizeof("true"))) { |
Naresh Tanniru | e3b1845 | 2014-03-04 14:44:27 +0530 | [diff] [blame] | 1684 | my_data->fluence_in_voice_rec = true; |
| 1685 | } |
| 1686 | |
Naresh Tanniru | db72d1e | 2014-03-05 17:33:47 +0530 | [diff] [blame] | 1687 | property_get("persist.audio.fluence.audiorec",value,""); |
| 1688 | if (!strncmp("true", value, sizeof("true"))) { |
| 1689 | my_data->fluence_in_audio_rec = true; |
| 1690 | } |
| 1691 | |
Naresh Tanniru | e3b1845 | 2014-03-04 14:44:27 +0530 | [diff] [blame] | 1692 | property_get("persist.audio.fluence.speaker",value,""); |
Naresh Tanniru | db72d1e | 2014-03-05 17:33:47 +0530 | [diff] [blame] | 1693 | if (!strncmp("true", value, sizeof("true"))) { |
Naresh Tanniru | e3b1845 | 2014-03-04 14:44:27 +0530 | [diff] [blame] | 1694 | my_data->fluence_in_spkr_mode = true; |
| 1695 | } |
Karthik Reddy Katta | d9fff86 | 2014-07-21 21:07:21 +0530 | [diff] [blame] | 1696 | |
| 1697 | property_get("persist.audio.fluence.mode",value,""); |
| 1698 | if (!strncmp("broadside", value, sizeof("broadside"))) { |
| 1699 | my_data->fluence_mode = FLUENCE_BROADSIDE; |
| 1700 | } |
Naresh Tanniru | e3b1845 | 2014-03-04 14:44:27 +0530 | [diff] [blame] | 1701 | } |
Preetam Singh Ranawat | 9519e9c | 2015-11-18 16:05:55 +0530 | [diff] [blame] | 1702 | |
Alexy Joseph | b137994 | 2016-01-29 15:49:38 -0800 | [diff] [blame] | 1703 | if (check_and_get_wsa_info((char *)snd_card_name, &wsaCount, &is_wsa_combo_supported)) { |
Preetam Singh Ranawat | 9519e9c | 2015-11-18 16:05:55 +0530 | [diff] [blame] | 1704 | /*Set ACDB ID of Stereo speaker if two WSAs are present*/ |
| 1705 | /*Default ACDB ID for wsa speaker is that for mono*/ |
| 1706 | if (wsaCount == 2) { |
| 1707 | platform_set_snd_device_acdb_id(SND_DEVICE_OUT_SPEAKER_WSA, 15); |
| 1708 | platform_set_snd_device_acdb_id(SND_DEVICE_OUT_SPEAKER_VBAT, 15); |
| 1709 | } |
Naresh Tanniru | 74a2eee | 2016-02-10 13:38:19 +0530 | [diff] [blame] | 1710 | |
Preetam Singh Ranawat | 9519e9c | 2015-11-18 16:05:55 +0530 | [diff] [blame] | 1711 | my_data->is_wsa_speaker = true; |
Naresh Tanniru | 74a2eee | 2016-02-10 13:38:19 +0530 | [diff] [blame] | 1712 | |
| 1713 | if (is_wsa_combo_supported) |
| 1714 | hw_info_enable_wsa_combo_usecase_support(my_data->hw_info); |
| 1715 | |
Preetam Singh Ranawat | 9519e9c | 2015-11-18 16:05:55 +0530 | [diff] [blame] | 1716 | } |
| 1717 | |
Srikanth Uyyala | a675cd1 | 2014-10-15 14:48:11 +0530 | [diff] [blame] | 1718 | property_get("persist.audio.FFSP.enable", ffspEnable, ""); |
| 1719 | if (!strncmp("true", ffspEnable, sizeof("true"))) { |
| 1720 | acdb_device_table[SND_DEVICE_OUT_SPEAKER] = 131; |
Preetam Singh Ranawat | c7f7f5c | 2015-04-02 12:19:58 +0530 | [diff] [blame] | 1721 | acdb_device_table[SND_DEVICE_OUT_SPEAKER_WSA] = 131; |
Srikanth Uyyala | a675cd1 | 2014-10-15 14:48:11 +0530 | [diff] [blame] | 1722 | acdb_device_table[SND_DEVICE_OUT_SPEAKER_REVERSE] = 131; |
| 1723 | acdb_device_table[SND_DEVICE_OUT_SPEAKER_AND_HDMI] = 131; |
| 1724 | acdb_device_table[SND_DEVICE_OUT_SPEAKER_AND_USB_HEADSET] = 131; |
| 1725 | } |
Dhananjay Kumar | a3565b3 | 2014-07-23 01:12:48 +0530 | [diff] [blame] | 1726 | |
Banajit Goswami | 20cdd21 | 2015-09-11 01:11:30 -0700 | [diff] [blame] | 1727 | /* Check if Vbat speaker enabled property is set, this should be done before acdb init */ |
| 1728 | bool ret = false; |
| 1729 | ret = audio_extn_can_use_vbat(); |
| 1730 | if (ret) |
| 1731 | my_data->is_vbat_speaker = true; |
| 1732 | |
Venkata Narendra Kumar Gutta | 4bd09d0 | 2016-01-29 15:31:04 +0530 | [diff] [blame] | 1733 | /* |
| 1734 | * Check if hifi audio( i.e. 96, 192 KHZ) is enabled for this platform, |
| 1735 | * enable hifi audio by default for external codec targets |
| 1736 | */ |
| 1737 | ret = audio_extn_is_hifi_audio_supported(); |
| 1738 | if (ret || is_external_codec) |
| 1739 | my_data->hifi_audio = true; |
| 1740 | |
Naresh Tanniru | db72d1e | 2014-03-05 17:33:47 +0530 | [diff] [blame] | 1741 | my_data->voice_feature_set = VOICE_FEATURE_SET_DEFAULT; |
Naresh Tanniru | e3b1845 | 2014-03-04 14:44:27 +0530 | [diff] [blame] | 1742 | my_data->acdb_handle = dlopen(LIB_ACDB_LOADER, RTLD_NOW); |
| 1743 | if (my_data->acdb_handle == NULL) { |
| 1744 | ALOGE("%s: DLOPEN failed for %s", __func__, LIB_ACDB_LOADER); |
| 1745 | } else { |
| 1746 | ALOGV("%s: DLOPEN successful for %s", __func__, LIB_ACDB_LOADER); |
| 1747 | my_data->acdb_deallocate = (acdb_deallocate_t)dlsym(my_data->acdb_handle, |
| 1748 | "acdb_loader_deallocate_ACDB"); |
Naresh Tanniru | db72d1e | 2014-03-05 17:33:47 +0530 | [diff] [blame] | 1749 | if (!my_data->acdb_deallocate) |
| 1750 | ALOGE("%s: Could not find the symbol acdb_loader_deallocate_ACDB from %s", |
| 1751 | __func__, LIB_ACDB_LOADER); |
| 1752 | |
Naresh Tanniru | e3b1845 | 2014-03-04 14:44:27 +0530 | [diff] [blame] | 1753 | my_data->acdb_send_audio_cal = (acdb_send_audio_cal_t)dlsym(my_data->acdb_handle, |
Subhash Chandra Bose Naripeddy | 5427467 | 2014-03-10 14:51:02 -0700 | [diff] [blame] | 1754 | "acdb_loader_send_audio_cal_v2"); |
Naresh Tanniru | e3b1845 | 2014-03-04 14:44:27 +0530 | [diff] [blame] | 1755 | if (!my_data->acdb_send_audio_cal) |
Naresh Tanniru | db72d1e | 2014-03-05 17:33:47 +0530 | [diff] [blame] | 1756 | ALOGE("%s: Could not find the symbol acdb_send_audio_cal from %s", |
Naresh Tanniru | e3b1845 | 2014-03-04 14:44:27 +0530 | [diff] [blame] | 1757 | __func__, LIB_ACDB_LOADER); |
Naresh Tanniru | db72d1e | 2014-03-05 17:33:47 +0530 | [diff] [blame] | 1758 | |
Preetam Singh Ranawat | 8bde2c5 | 2015-03-20 12:00:49 +0530 | [diff] [blame] | 1759 | my_data->acdb_set_audio_cal = (acdb_set_audio_cal_t)dlsym(my_data->acdb_handle, |
| 1760 | "acdb_loader_set_audio_cal_v2"); |
| 1761 | if (!my_data->acdb_set_audio_cal) |
| 1762 | ALOGE("%s: Could not find the symbol acdb_set_audio_cal_v2 from %s", |
| 1763 | __func__, LIB_ACDB_LOADER); |
| 1764 | |
| 1765 | my_data->acdb_get_audio_cal = (acdb_get_audio_cal_t)dlsym(my_data->acdb_handle, |
| 1766 | "acdb_loader_get_audio_cal_v2"); |
| 1767 | if (!my_data->acdb_get_audio_cal) |
| 1768 | ALOGE("%s: Could not find the symbol acdb_get_audio_cal_v2 from %s", |
| 1769 | __func__, LIB_ACDB_LOADER); |
| 1770 | |
Naresh Tanniru | e3b1845 | 2014-03-04 14:44:27 +0530 | [diff] [blame] | 1771 | my_data->acdb_send_voice_cal = (acdb_send_voice_cal_t)dlsym(my_data->acdb_handle, |
| 1772 | "acdb_loader_send_voice_cal"); |
Naresh Tanniru | db72d1e | 2014-03-05 17:33:47 +0530 | [diff] [blame] | 1773 | if (!my_data->acdb_send_voice_cal) |
| 1774 | ALOGE("%s: Could not find the symbol acdb_loader_send_voice_cal from %s", |
| 1775 | __func__, LIB_ACDB_LOADER); |
| 1776 | |
| 1777 | my_data->acdb_reload_vocvoltable = (acdb_reload_vocvoltable_t)dlsym(my_data->acdb_handle, |
| 1778 | "acdb_loader_reload_vocvoltable"); |
| 1779 | if (!my_data->acdb_reload_vocvoltable) |
| 1780 | ALOGE("%s: Could not find the symbol acdb_loader_reload_vocvoltable from %s", |
| 1781 | __func__, LIB_ACDB_LOADER); |
| 1782 | |
Subhash Chandra Bose Naripeddy | 5427467 | 2014-03-10 14:51:02 -0700 | [diff] [blame] | 1783 | my_data->acdb_get_default_app_type = (acdb_get_default_app_type_t)dlsym( |
| 1784 | my_data->acdb_handle, |
| 1785 | "acdb_loader_get_default_app_type"); |
| 1786 | if (!my_data->acdb_get_default_app_type) |
| 1787 | ALOGE("%s: Could not find the symbol acdb_get_default_app_type from %s", |
| 1788 | __func__, LIB_ACDB_LOADER); |
| 1789 | |
Ben Romberger | feca4b8 | 2015-07-07 20:40:44 -0700 | [diff] [blame] | 1790 | my_data->acdb_send_common_top = (acdb_send_common_top_t)dlsym( |
| 1791 | my_data->acdb_handle, |
| 1792 | "acdb_loader_send_common_custom_topology"); |
| 1793 | if (!my_data->acdb_send_common_top) |
| 1794 | ALOGE("%s: Could not find the symbol acdb_get_default_app_type from %s", |
| 1795 | __func__, LIB_ACDB_LOADER); |
| 1796 | |
Banajit Goswami | 20cdd21 | 2015-09-11 01:11:30 -0700 | [diff] [blame] | 1797 | my_data->acdb_set_codec_data = (acdb_set_codec_data_t)dlsym( |
| 1798 | my_data->acdb_handle, |
| 1799 | "acdb_loader_set_codec_data"); |
| 1800 | if (!my_data->acdb_set_codec_data) |
| 1801 | ALOGE("%s: Could not find the symbol acdb_get_default_app_type from %s", |
| 1802 | __func__, LIB_ACDB_LOADER); |
| 1803 | |
| 1804 | |
Naresh Tanniru | e3b1845 | 2014-03-04 14:44:27 +0530 | [diff] [blame] | 1805 | my_data->acdb_init = (acdb_init_t)dlsym(my_data->acdb_handle, |
Naresh Tanniru | db72d1e | 2014-03-05 17:33:47 +0530 | [diff] [blame] | 1806 | "acdb_loader_init_v2"); |
Avinash Vaish | 71c066d | 2014-08-27 12:32:35 +0530 | [diff] [blame] | 1807 | if (my_data->acdb_init == NULL) { |
Naresh Tanniru | db72d1e | 2014-03-05 17:33:47 +0530 | [diff] [blame] | 1808 | ALOGE("%s: dlsym error %s for acdb_loader_init_v2", __func__, dlerror()); |
Avinash Vaish | 71c066d | 2014-08-27 12:32:35 +0530 | [diff] [blame] | 1809 | goto acdb_init_fail; |
| 1810 | } |
Karthik Reddy Katta | 8513f43 | 2016-04-12 14:29:27 +0530 | [diff] [blame] | 1811 | |
| 1812 | my_data->acdb_reload = (acdb_reload_t)dlsym(my_data->acdb_handle, |
| 1813 | "acdb_loader_reload_acdb_files"); |
| 1814 | if (my_data->acdb_reload == NULL) { |
| 1815 | ALOGE("%s: dlsym error %s for acdb_loader_reload_acdb_files", __func__, dlerror()); |
| 1816 | goto acdb_init_fail; |
| 1817 | } |
Ramjee Singh | 203473b | 2015-06-09 15:18:42 +0530 | [diff] [blame] | 1818 | platform_acdb_init(my_data); |
Naresh Tanniru | e3b1845 | 2014-03-04 14:44:27 +0530 | [diff] [blame] | 1819 | } |
Preetam Singh Ranawat | 2d0e463 | 2015-02-02 12:40:59 +0530 | [diff] [blame] | 1820 | audio_extn_pm_vote(); |
Naresh Tanniru | e3b1845 | 2014-03-04 14:44:27 +0530 | [diff] [blame] | 1821 | |
Satish Babu Patakokila | bbd4e9d | 2015-05-13 22:08:06 +0530 | [diff] [blame] | 1822 | /* Configure active back end for HPX*/ |
| 1823 | ctl = mixer_get_ctl_by_name(adev->mixer, mixer_ctl_name); |
| 1824 | if (ctl) { |
| 1825 | ALOGE(" sending HPX Active BE information "); |
| 1826 | mixer_ctl_set_value(ctl, 0, is_external_codec); |
Preetam Singh Ranawat | c7f7f5c | 2015-04-02 12:19:58 +0530 | [diff] [blame] | 1827 | } |
| 1828 | |
Avinash Vaish | 71c066d | 2014-08-27 12:32:35 +0530 | [diff] [blame] | 1829 | acdb_init_fail: |
Preetam Singh Ranawat | 8bde2c5 | 2015-03-20 12:00:49 +0530 | [diff] [blame] | 1830 | |
Chaithanya Krishna Bacharaju | 9955b16 | 2016-05-25 16:25:53 +0530 | [diff] [blame] | 1831 | set_platform_defaults(my_data); |
Preetam Singh Ranawat | 8bde2c5 | 2015-03-20 12:00:49 +0530 | [diff] [blame] | 1832 | |
Dhananjay Kumar | a68d7af | 2015-05-25 19:11:30 +0530 | [diff] [blame] | 1833 | /* Initialize ACDB and PCM ID's */ |
| 1834 | if (is_external_codec) |
Ravi Kumar Alamanda | 14b0f2d | 2015-06-28 21:04:09 -0700 | [diff] [blame] | 1835 | platform_info_init(PLATFORM_INFO_XML_PATH_EXTCODEC, my_data); |
Dhananjay Kumar | a68d7af | 2015-05-25 19:11:30 +0530 | [diff] [blame] | 1836 | else |
Ravi Kumar Alamanda | 14b0f2d | 2015-06-28 21:04:09 -0700 | [diff] [blame] | 1837 | platform_info_init(PLATFORM_INFO_XML_PATH, my_data); |
Naresh Tanniru | db72d1e | 2014-03-05 17:33:47 +0530 | [diff] [blame] | 1838 | |
Chaithanya Krishna Bacharaju | 9955b16 | 2016-05-25 16:25:53 +0530 | [diff] [blame] | 1839 | /* obtain source mic type from max mic count*/ |
| 1840 | get_source_mic_type(my_data); |
| 1841 | ALOGD("%s: Fluence_Type(%d) max_mic_count(%d) mic_type(0x%x) fluence_in_voice_call(%d)" |
| 1842 | " fluence_in_voice_rec(%d) fluence_in_spkr_mode(%d) ", |
| 1843 | __func__, my_data->fluence_type, my_data->max_mic_count, my_data->source_mic_type, |
| 1844 | my_data->fluence_in_voice_call, my_data->fluence_in_voice_rec, |
| 1845 | my_data->fluence_in_spkr_mode); |
| 1846 | |
Naresh Tanniru | db72d1e | 2014-03-05 17:33:47 +0530 | [diff] [blame] | 1847 | /* init usb */ |
| 1848 | audio_extn_usb_init(adev); |
Naresh Tanniru | db72d1e | 2014-03-05 17:33:47 +0530 | [diff] [blame] | 1849 | |
| 1850 | /* Read one time ssr property */ |
| 1851 | audio_extn_ssr_update_enabled(); |
| 1852 | audio_extn_spkr_prot_init(adev); |
Dhananjay Kumar | 89ea3bd | 2014-04-29 15:45:57 +0530 | [diff] [blame] | 1853 | |
Ashish Jain | 8ec5047 | 2014-10-16 13:56:28 +0530 | [diff] [blame] | 1854 | /* init dap hal */ |
| 1855 | audio_extn_dap_hal_init(adev->snd_card); |
| 1856 | |
Dhananjay Kumar | 89ea3bd | 2014-04-29 15:45:57 +0530 | [diff] [blame] | 1857 | audio_extn_dolby_set_license(adev); |
| 1858 | |
Preetam Singh Ranawat | 8bde2c5 | 2015-03-20 12:00:49 +0530 | [diff] [blame] | 1859 | /* init audio device arbitration */ |
| 1860 | audio_extn_dev_arbi_init(); |
| 1861 | |
| 1862 | my_data->edid_info = NULL; |
Preetam Singh Ranawat | c61f867 | 2015-06-18 23:20:28 +0530 | [diff] [blame] | 1863 | |
| 1864 | /* initialize backend config */ |
| 1865 | for (idx = 0; idx < MAX_CODEC_BACKENDS; idx++) { |
| 1866 | my_data->current_backend_cfg[idx].sample_rate = CODEC_BACKEND_DEFAULT_SAMPLE_RATE; |
| 1867 | if (idx == HEADPHONE_44_1_BACKEND) |
| 1868 | my_data->current_backend_cfg[idx].sample_rate = OUTPUT_SAMPLING_RATE_44100; |
| 1869 | my_data->current_backend_cfg[idx].bit_width = CODEC_BACKEND_DEFAULT_BIT_WIDTH; |
| 1870 | } |
| 1871 | |
Manish Dewangan | ba9fcfa | 2016-03-24 16:20:06 +0530 | [diff] [blame] | 1872 | my_data->current_tx_backend_cfg[DEFAULT_CODEC_BACKEND].sample_rate = |
| 1873 | CODEC_BACKEND_DEFAULT_SAMPLE_RATE; |
| 1874 | my_data->current_tx_backend_cfg[DEFAULT_CODEC_BACKEND].bit_width = |
| 1875 | CODEC_BACKEND_DEFAULT_BIT_WIDTH; |
| 1876 | |
Venkata Narendra Kumar Gutta | 4bd09d0 | 2016-01-29 15:31:04 +0530 | [diff] [blame] | 1877 | if (is_external_codec) { |
| 1878 | my_data->current_backend_cfg[DEFAULT_CODEC_BACKEND].bitwidth_mixer_ctl = |
| 1879 | strdup("SLIM_0_RX Format"); |
| 1880 | my_data->current_backend_cfg[DEFAULT_CODEC_BACKEND].samplerate_mixer_ctl = |
| 1881 | strdup("SLIM_0_RX SampleRate"); |
Preetam Singh Ranawat | c61f867 | 2015-06-18 23:20:28 +0530 | [diff] [blame] | 1882 | |
Venkata Narendra Kumar Gutta | 4bd09d0 | 2016-01-29 15:31:04 +0530 | [diff] [blame] | 1883 | my_data->current_backend_cfg[HEADPHONE_44_1_BACKEND].bitwidth_mixer_ctl = |
| 1884 | strdup("SLIM_5_RX Format"); |
| 1885 | my_data->current_backend_cfg[HEADPHONE_44_1_BACKEND].samplerate_mixer_ctl = |
| 1886 | strdup("SLIM_5_RX SampleRate"); |
Sidipotu Ashok | 9f0b16e | 2016-04-28 13:48:28 +0530 | [diff] [blame] | 1887 | |
| 1888 | my_data->current_backend_cfg[HEADPHONE_BACKEND].bitwidth_mixer_ctl = |
| 1889 | strdup("SLIM_6_RX Format"); |
| 1890 | my_data->current_backend_cfg[HEADPHONE_BACKEND].samplerate_mixer_ctl = |
| 1891 | strdup("SLIM_6_RX SampleRate"); |
Manish Dewangan | ba9fcfa | 2016-03-24 16:20:06 +0530 | [diff] [blame] | 1892 | |
| 1893 | my_data->current_tx_backend_cfg[DEFAULT_CODEC_BACKEND].bitwidth_mixer_ctl = |
| 1894 | strdup("SLIM_0_TX Format"); |
| 1895 | my_data->current_tx_backend_cfg[DEFAULT_CODEC_BACKEND].samplerate_mixer_ctl = |
| 1896 | strdup("SLIM_0_TX SampleRate"); |
Venkata Narendra Kumar Gutta | 4bd09d0 | 2016-01-29 15:31:04 +0530 | [diff] [blame] | 1897 | } else { |
| 1898 | my_data->current_backend_cfg[DEFAULT_CODEC_BACKEND].bitwidth_mixer_ctl = |
| 1899 | strdup("MI2S_RX Format"); |
| 1900 | my_data->current_backend_cfg[DEFAULT_CODEC_BACKEND].samplerate_mixer_ctl = |
| 1901 | strdup("MI2S_RX SampleRate"); |
Manish Dewangan | ba9fcfa | 2016-03-24 16:20:06 +0530 | [diff] [blame] | 1902 | |
| 1903 | my_data->current_tx_backend_cfg[DEFAULT_CODEC_BACKEND].bitwidth_mixer_ctl = |
| 1904 | strdup("MI2S_TX Format"); |
| 1905 | my_data->current_tx_backend_cfg[DEFAULT_CODEC_BACKEND].samplerate_mixer_ctl = |
| 1906 | strdup("MI2S_TX SampleRate"); |
Venkata Narendra Kumar Gutta | 4bd09d0 | 2016-01-29 15:31:04 +0530 | [diff] [blame] | 1907 | } |
Sidipotu Ashok | cf87773 | 2015-09-22 14:58:48 +0530 | [diff] [blame] | 1908 | |
Kuirong Wang | a9f7cee | 2016-03-07 11:21:52 -0800 | [diff] [blame] | 1909 | my_data->current_backend_cfg[USB_AUDIO_RX_BACKEND].bitwidth_mixer_ctl = |
| 1910 | strdup("USB_AUDIO_RX Format"); |
| 1911 | my_data->current_backend_cfg[USB_AUDIO_RX_BACKEND].samplerate_mixer_ctl = |
| 1912 | strdup("USB_AUDIO_RX SampleRate"); |
| 1913 | |
Mingming Yin | ddd610b | 2016-01-20 17:09:32 -0800 | [diff] [blame] | 1914 | my_data->current_backend_cfg[HDMI_RX_BACKEND].bitwidth_mixer_ctl = |
| 1915 | strdup("HDMI_RX Bit Format"); |
| 1916 | my_data->current_backend_cfg[HDMI_RX_BACKEND].samplerate_mixer_ctl = |
| 1917 | strdup("HDMI_RX SampleRate"); |
| 1918 | |
Sidipotu Ashok | e6f78cb | 2015-11-05 14:42:20 +0530 | [diff] [blame] | 1919 | ret = audio_extn_utils_get_codec_version(snd_card_name, |
| 1920 | my_data->adev->snd_card, |
| 1921 | my_data->codec_version); |
Sidipotu Ashok | cf87773 | 2015-09-22 14:58:48 +0530 | [diff] [blame] | 1922 | |
Sidipotu Ashok | e6f78cb | 2015-11-05 14:42:20 +0530 | [diff] [blame] | 1923 | if (NATIVE_AUDIO_MODE_INVALID != platform_get_native_support()) { |
| 1924 | /* |
| 1925 | * Native playback is enabled from the UI. |
| 1926 | */ |
| 1927 | if(strstr(snd_card_name, "tasha")) { |
| 1928 | if (strstr(my_data->codec_version, "WCD9335_1_0") || |
| 1929 | strstr(my_data->codec_version, "WCD9335_1_1")) { |
| 1930 | ALOGD("%s:napb: TASHA 1.0 or 1.1 only SRC mode is supported", |
| 1931 | __func__); |
| 1932 | platform_set_native_support(NATIVE_AUDIO_MODE_SRC); |
| 1933 | } |
| 1934 | } else { |
| 1935 | platform_set_native_support(NATIVE_AUDIO_MODE_INVALID); |
Sidipotu Ashok | cf87773 | 2015-09-22 14:58:48 +0530 | [diff] [blame] | 1936 | } |
| 1937 | } |
| 1938 | |
Preetam Singh Ranawat | c61f867 | 2015-06-18 23:20:28 +0530 | [diff] [blame] | 1939 | my_data->edid_info = NULL; |
Naresh Tanniru | e3b1845 | 2014-03-04 14:44:27 +0530 | [diff] [blame] | 1940 | return my_data; |
| 1941 | } |
| 1942 | |
| 1943 | void platform_deinit(void *platform) |
| 1944 | { |
Naresh Tanniru | db72d1e | 2014-03-05 17:33:47 +0530 | [diff] [blame] | 1945 | struct platform_data *my_data = (struct platform_data *)platform; |
| 1946 | |
Preetam Singh Ranawat | 8bde2c5 | 2015-03-20 12:00:49 +0530 | [diff] [blame] | 1947 | if (my_data->edid_info) { |
| 1948 | free(my_data->edid_info); |
| 1949 | my_data->edid_info = NULL; |
| 1950 | } |
| 1951 | |
Venkata Narendra Kumar Gutta | e071e5a | 2016-01-11 18:08:26 +0530 | [diff] [blame] | 1952 | if (my_data->hw_dep_fd >= 0) { |
| 1953 | close(my_data->hw_dep_fd); |
| 1954 | my_data->hw_dep_fd = -1; |
| 1955 | } |
| 1956 | |
Naresh Tanniru | db72d1e | 2014-03-05 17:33:47 +0530 | [diff] [blame] | 1957 | hw_info_deinit(my_data->hw_info); |
| 1958 | close_csd_client(my_data->csd); |
| 1959 | |
Preetam Singh Ranawat | 8bde2c5 | 2015-03-20 12:00:49 +0530 | [diff] [blame] | 1960 | int32_t dev; |
| 1961 | for (dev = 0; dev < SND_DEVICE_MAX; dev++) { |
Sidipotu Ashok | 9f0b16e | 2016-04-28 13:48:28 +0530 | [diff] [blame] | 1962 | if (backend_tag_table[dev]) { |
| 1963 | free(backend_tag_table[dev]); |
| 1964 | backend_tag_table[dev]= NULL; |
Preetam Singh Ranawat | 8bde2c5 | 2015-03-20 12:00:49 +0530 | [diff] [blame] | 1965 | } |
| 1966 | } |
| 1967 | |
| 1968 | /* deinit audio device arbitration */ |
| 1969 | audio_extn_dev_arbi_deinit(); |
| 1970 | |
| 1971 | if (my_data->edid_info) { |
| 1972 | free(my_data->edid_info); |
| 1973 | my_data->edid_info = NULL; |
| 1974 | } |
| 1975 | |
Naresh Tanniru | e3b1845 | 2014-03-04 14:44:27 +0530 | [diff] [blame] | 1976 | free(platform); |
Naresh Tanniru | db72d1e | 2014-03-05 17:33:47 +0530 | [diff] [blame] | 1977 | /* deinit usb */ |
| 1978 | audio_extn_usb_deinit(); |
Ashish Jain | 8ec5047 | 2014-10-16 13:56:28 +0530 | [diff] [blame] | 1979 | audio_extn_dap_hal_deinit(); |
Naresh Tanniru | e3b1845 | 2014-03-04 14:44:27 +0530 | [diff] [blame] | 1980 | } |
| 1981 | |
Ben Romberger | feca4b8 | 2015-07-07 20:40:44 -0700 | [diff] [blame] | 1982 | static int platform_is_acdb_initialized(void *platform) |
Ramjee Singh | 203473b | 2015-06-09 15:18:42 +0530 | [diff] [blame] | 1983 | { |
| 1984 | struct platform_data *my_data = (struct platform_data *)platform; |
| 1985 | ALOGD("%s: acdb initialized %d\n", __func__, my_data->is_acdb_initialized); |
| 1986 | return my_data->is_acdb_initialized; |
| 1987 | } |
| 1988 | |
Ben Romberger | feca4b8 | 2015-07-07 20:40:44 -0700 | [diff] [blame] | 1989 | void platform_snd_card_update(void *platform, int snd_scard_state) |
| 1990 | { |
| 1991 | struct platform_data *my_data = (struct platform_data *)platform; |
| 1992 | |
| 1993 | if (snd_scard_state == SND_CARD_STATE_ONLINE) { |
| 1994 | if (!platform_is_acdb_initialized(my_data)) { |
| 1995 | if(platform_acdb_init(my_data)) |
| 1996 | ALOGE("%s: acdb initialization is failed", __func__); |
| 1997 | } else if (my_data->acdb_send_common_top() < 0) { |
| 1998 | ALOGD("%s: acdb did not set common topology", __func__); |
| 1999 | } |
| 2000 | } |
| 2001 | } |
| 2002 | |
Naresh Tanniru | e3b1845 | 2014-03-04 14:44:27 +0530 | [diff] [blame] | 2003 | const char *platform_get_snd_device_name(snd_device_t snd_device) |
| 2004 | { |
| 2005 | if (snd_device >= SND_DEVICE_MIN && snd_device < SND_DEVICE_MAX) |
| 2006 | return device_table[snd_device]; |
| 2007 | else |
| 2008 | return ""; |
| 2009 | } |
| 2010 | |
Naresh Tanniru | db72d1e | 2014-03-05 17:33:47 +0530 | [diff] [blame] | 2011 | int platform_get_snd_device_name_extn(void *platform, snd_device_t snd_device, |
| 2012 | char *device_name) |
| 2013 | { |
| 2014 | struct platform_data *my_data = (struct platform_data *)platform; |
| 2015 | |
| 2016 | if (snd_device >= SND_DEVICE_MIN && snd_device < SND_DEVICE_MAX) { |
| 2017 | strlcpy(device_name, device_table[snd_device], DEVICE_NAME_MAX_SIZE); |
| 2018 | hw_info_append_hw_type(my_data->hw_info, snd_device, device_name); |
| 2019 | } else { |
| 2020 | strlcpy(device_name, "", DEVICE_NAME_MAX_SIZE); |
| 2021 | return -EINVAL; |
| 2022 | } |
| 2023 | |
| 2024 | return 0; |
| 2025 | } |
| 2026 | |
Banajit Goswami | 20cdd21 | 2015-09-11 01:11:30 -0700 | [diff] [blame] | 2027 | void platform_add_backend_name(char *mixer_path, snd_device_t snd_device, |
| 2028 | struct audio_usecase *usecase) |
Naresh Tanniru | e3b1845 | 2014-03-04 14:44:27 +0530 | [diff] [blame] | 2029 | { |
Preetam Singh Ranawat | 8bde2c5 | 2015-03-20 12:00:49 +0530 | [diff] [blame] | 2030 | if ((snd_device < SND_DEVICE_MIN) || (snd_device >= SND_DEVICE_MAX)) { |
| 2031 | ALOGE("%s: Invalid snd_device = %d", __func__, snd_device); |
| 2032 | return; |
| 2033 | } |
| 2034 | |
Banajit Goswami | 20cdd21 | 2015-09-11 01:11:30 -0700 | [diff] [blame] | 2035 | if((snd_device == SND_DEVICE_OUT_VOICE_SPEAKER_VBAT) && |
| 2036 | !(usecase->type == VOICE_CALL || usecase->type == VOIP_CALL)) { |
| 2037 | ALOGI("%s: Not adding vbat speaker device to non voice use cases", __func__); |
| 2038 | return; |
| 2039 | } |
| 2040 | |
Sidipotu Ashok | 9f0b16e | 2016-04-28 13:48:28 +0530 | [diff] [blame] | 2041 | const char * suffix = backend_tag_table[snd_device]; |
Preetam Singh Ranawat | 8bde2c5 | 2015-03-20 12:00:49 +0530 | [diff] [blame] | 2042 | |
| 2043 | if (suffix != NULL) { |
| 2044 | strlcat(mixer_path, " ", MIXER_PATH_MAX_LENGTH); |
| 2045 | strlcat(mixer_path, suffix, MIXER_PATH_MAX_LENGTH); |
| 2046 | } |
Naresh Tanniru | e3b1845 | 2014-03-04 14:44:27 +0530 | [diff] [blame] | 2047 | } |
| 2048 | |
Sidipotu Ashok | 9f0b16e | 2016-04-28 13:48:28 +0530 | [diff] [blame] | 2049 | bool platform_check_backends_match(snd_device_t snd_device1, snd_device_t snd_device2) |
| 2050 | { |
| 2051 | bool result = true; |
| 2052 | |
| 2053 | ALOGV("%s: snd_device1 = %s, snd_device2 = %s", __func__, |
| 2054 | platform_get_snd_device_name(snd_device1), |
| 2055 | platform_get_snd_device_name(snd_device2)); |
| 2056 | |
| 2057 | if ((snd_device1 < SND_DEVICE_MIN) || (snd_device1 >= SND_DEVICE_OUT_END)) { |
| 2058 | ALOGE("%s: Invalid snd_device = %s", __func__, |
| 2059 | platform_get_snd_device_name(snd_device1)); |
| 2060 | return false; |
| 2061 | } |
| 2062 | if ((snd_device2 < SND_DEVICE_MIN) || (snd_device2 >= SND_DEVICE_OUT_END)) { |
| 2063 | ALOGE("%s: Invalid snd_device = %s", __func__, |
| 2064 | platform_get_snd_device_name(snd_device2)); |
| 2065 | return false; |
| 2066 | } |
| 2067 | const char * be_itf1 = hw_interface_table[snd_device1]; |
| 2068 | const char * be_itf2 = hw_interface_table[snd_device2]; |
| 2069 | |
| 2070 | if (NULL != be_itf1 && NULL != be_itf2) { |
Kuirong Wang | b9fbb1e | 2016-05-03 18:36:39 -0700 | [diff] [blame] | 2071 | if ((NULL == strstr(be_itf2, be_itf1)) && (NULL == strstr(be_itf1, be_itf2))) |
Sidipotu Ashok | 9f0b16e | 2016-04-28 13:48:28 +0530 | [diff] [blame] | 2072 | result = false; |
| 2073 | } else if (NULL == be_itf1 && NULL != be_itf2) { |
| 2074 | result = false; |
| 2075 | } else if (NULL != be_itf1 && NULL == be_itf2) { |
| 2076 | result = false; |
| 2077 | } |
| 2078 | |
| 2079 | ALOGV("%s: be_itf1 = %s, be_itf2 = %s, match %d", __func__, be_itf1, be_itf2, result); |
| 2080 | return result; |
| 2081 | } |
| 2082 | |
Naresh Tanniru | e3b1845 | 2014-03-04 14:44:27 +0530 | [diff] [blame] | 2083 | int platform_get_pcm_device_id(audio_usecase_t usecase, int device_type) |
| 2084 | { |
Venkata Narendra Kumar Gutta | ed408a1 | 2015-03-31 20:24:04 +0530 | [diff] [blame] | 2085 | int device_id = -1; |
| 2086 | |
Karthik Reddy Katta | 561d4ba | 2016-06-23 13:41:18 +0530 | [diff] [blame] | 2087 | if (device_type == PCM_PLAYBACK) |
| 2088 | device_id = pcm_device_table[usecase][0]; |
| 2089 | else |
| 2090 | device_id = pcm_device_table[usecase][1]; |
Naresh Tanniru | e3b1845 | 2014-03-04 14:44:27 +0530 | [diff] [blame] | 2091 | return device_id; |
| 2092 | } |
| 2093 | |
Preetam Singh Ranawat | 8bde2c5 | 2015-03-20 12:00:49 +0530 | [diff] [blame] | 2094 | static int find_index(struct name_to_index * table, int32_t len, const char * name) |
Naresh Tanniru | db72d1e | 2014-03-05 17:33:47 +0530 | [diff] [blame] | 2095 | { |
| 2096 | int ret = 0; |
Preetam Singh Ranawat | 8bde2c5 | 2015-03-20 12:00:49 +0530 | [diff] [blame] | 2097 | int32_t i; |
Naresh Tanniru | db72d1e | 2014-03-05 17:33:47 +0530 | [diff] [blame] | 2098 | |
Preetam Singh Ranawat | 8bde2c5 | 2015-03-20 12:00:49 +0530 | [diff] [blame] | 2099 | if (table == NULL) { |
| 2100 | ALOGE("%s: table is NULL", __func__); |
Naresh Tanniru | db72d1e | 2014-03-05 17:33:47 +0530 | [diff] [blame] | 2101 | ret = -ENODEV; |
| 2102 | goto done; |
| 2103 | } |
| 2104 | |
Preetam Singh Ranawat | 8bde2c5 | 2015-03-20 12:00:49 +0530 | [diff] [blame] | 2105 | if (name == NULL) { |
| 2106 | ALOGE("null key"); |
| 2107 | ret = -ENODEV; |
| 2108 | goto done; |
| 2109 | } |
| 2110 | |
| 2111 | for (i=0; i < len; i++) { |
| 2112 | const char* tn = table[i].name; |
| 2113 | size_t len = strlen(tn); |
| 2114 | if (strncmp(tn, name, len) == 0) { |
| 2115 | if (strlen(name) != len) { |
| 2116 | continue; // substring |
| 2117 | } |
| 2118 | ret = table[i].index; |
Naresh Tanniru | db72d1e | 2014-03-05 17:33:47 +0530 | [diff] [blame] | 2119 | goto done; |
| 2120 | } |
| 2121 | } |
Preetam Singh Ranawat | 8bde2c5 | 2015-03-20 12:00:49 +0530 | [diff] [blame] | 2122 | ALOGE("%s: Could not find index for name = %s", |
| 2123 | __func__, name); |
Naresh Tanniru | db72d1e | 2014-03-05 17:33:47 +0530 | [diff] [blame] | 2124 | ret = -ENODEV; |
| 2125 | done: |
| 2126 | return ret; |
| 2127 | } |
| 2128 | |
Venkata Narendra Kumar Gutta | 88fd0bc | 2014-03-27 19:47:56 +0530 | [diff] [blame] | 2129 | int platform_set_fluence_type(void *platform, char *value) |
| 2130 | { |
| 2131 | int ret = 0; |
| 2132 | int fluence_type = FLUENCE_NONE; |
| 2133 | int fluence_flag = NONE_FLAG; |
| 2134 | struct platform_data *my_data = (struct platform_data *)platform; |
| 2135 | struct audio_device *adev = my_data->adev; |
| 2136 | |
| 2137 | ALOGV("%s: fluence type:%d", __func__, my_data->fluence_type); |
| 2138 | |
| 2139 | /* only dual mic turn on and off is supported as of now through setparameters */ |
| 2140 | if (!strncmp(AUDIO_PARAMETER_VALUE_DUALMIC,value, sizeof(AUDIO_PARAMETER_VALUE_DUALMIC))) { |
| 2141 | if (!strncmp("fluencepro", my_data->fluence_cap, sizeof("fluencepro")) || |
| 2142 | !strncmp("fluence", my_data->fluence_cap, sizeof("fluence"))) { |
| 2143 | ALOGV("fluence dualmic feature enabled \n"); |
| 2144 | fluence_type = FLUENCE_DUAL_MIC; |
| 2145 | fluence_flag = DMIC_FLAG; |
| 2146 | } else { |
| 2147 | ALOGE("%s: Failed to set DUALMIC", __func__); |
| 2148 | ret = -1; |
| 2149 | goto done; |
| 2150 | } |
| 2151 | } else if (!strncmp(AUDIO_PARAMETER_KEY_NO_FLUENCE, value, sizeof(AUDIO_PARAMETER_KEY_NO_FLUENCE))) { |
| 2152 | ALOGV("fluence disabled"); |
| 2153 | fluence_type = FLUENCE_NONE; |
| 2154 | } else { |
| 2155 | ALOGE("Invalid fluence value : %s",value); |
| 2156 | ret = -1; |
| 2157 | goto done; |
| 2158 | } |
| 2159 | |
| 2160 | if (fluence_type != my_data->fluence_type) { |
| 2161 | ALOGV("%s: Updating fluence_type to :%d", __func__, fluence_type); |
| 2162 | my_data->fluence_type = fluence_type; |
| 2163 | adev->acdb_settings = (adev->acdb_settings & FLUENCE_MODE_CLEAR) | fluence_flag; |
| 2164 | } |
| 2165 | done: |
| 2166 | return ret; |
| 2167 | } |
| 2168 | |
| 2169 | int platform_get_fluence_type(void *platform, char *value, uint32_t len) |
| 2170 | { |
| 2171 | int ret = 0; |
| 2172 | struct platform_data *my_data = (struct platform_data *)platform; |
| 2173 | |
| 2174 | if (my_data->fluence_type == FLUENCE_QUAD_MIC) { |
| 2175 | strlcpy(value, "quadmic", len); |
| 2176 | } else if (my_data->fluence_type == FLUENCE_DUAL_MIC) { |
| 2177 | strlcpy(value, "dualmic", len); |
| 2178 | } else if (my_data->fluence_type == FLUENCE_NONE) { |
| 2179 | strlcpy(value, "none", len); |
| 2180 | } else |
| 2181 | ret = -1; |
| 2182 | |
| 2183 | return ret; |
| 2184 | } |
| 2185 | |
Preetam Singh Ranawat | 8bde2c5 | 2015-03-20 12:00:49 +0530 | [diff] [blame] | 2186 | int platform_get_snd_device_index(char *device_name) |
| 2187 | { |
| 2188 | return find_index(snd_device_name_index, SND_DEVICE_MAX, device_name); |
| 2189 | } |
| 2190 | |
| 2191 | int platform_get_usecase_index(const char *usecase_name) |
| 2192 | { |
| 2193 | return find_index(usecase_name_index, AUDIO_USECASE_MAX, usecase_name); |
| 2194 | } |
| 2195 | |
Naresh Tanniru | db72d1e | 2014-03-05 17:33:47 +0530 | [diff] [blame] | 2196 | int platform_set_snd_device_acdb_id(snd_device_t snd_device, unsigned int acdb_id) |
| 2197 | { |
| 2198 | int ret = 0; |
| 2199 | |
| 2200 | if ((snd_device < SND_DEVICE_MIN) || (snd_device >= SND_DEVICE_MAX)) { |
| 2201 | ALOGE("%s: Invalid snd_device = %d", |
| 2202 | __func__, snd_device); |
| 2203 | ret = -EINVAL; |
| 2204 | goto done; |
| 2205 | } |
| 2206 | |
Sidipotu Ashok | 9f0b16e | 2016-04-28 13:48:28 +0530 | [diff] [blame] | 2207 | ALOGV("%s: acdb_device_table[%s]: old = %d new = %d", __func__, |
| 2208 | platform_get_snd_device_name(snd_device), acdb_device_table[snd_device], acdb_id); |
Naresh Tanniru | db72d1e | 2014-03-05 17:33:47 +0530 | [diff] [blame] | 2209 | acdb_device_table[snd_device] = acdb_id; |
| 2210 | done: |
| 2211 | return ret; |
| 2212 | } |
| 2213 | |
Subhash Chandra Bose Naripeddy | 5427467 | 2014-03-10 14:51:02 -0700 | [diff] [blame] | 2214 | int platform_get_default_app_type(void *platform) |
| 2215 | { |
| 2216 | struct platform_data *my_data = (struct platform_data *)platform; |
| 2217 | |
| 2218 | if (my_data->acdb_get_default_app_type) |
| 2219 | return my_data->acdb_get_default_app_type(); |
| 2220 | else |
| 2221 | return DEFAULT_APP_TYPE; |
| 2222 | } |
| 2223 | |
Satya Krishna Pindiproli | f1cd92b | 2016-04-14 19:05:23 +0530 | [diff] [blame] | 2224 | int platform_get_default_app_type_v2(void *platform __unused, |
| 2225 | usecase_type_t type __unused) |
Srikanth Uyyala | a1e3235 | 2015-10-09 14:48:04 +0530 | [diff] [blame] | 2226 | { |
| 2227 | if(type == PCM_CAPTURE) |
| 2228 | return DEFAULT_APP_TYPE_TX_PATH; |
| 2229 | else |
| 2230 | return DEFAULT_APP_TYPE_RX_PATH; |
| 2231 | } |
| 2232 | |
Subhash Chandra Bose Naripeddy | 19dc03b | 2014-03-10 14:43:05 -0700 | [diff] [blame] | 2233 | int platform_get_snd_device_acdb_id(snd_device_t snd_device) |
| 2234 | { |
| 2235 | if ((snd_device < SND_DEVICE_MIN) || (snd_device >= SND_DEVICE_MAX)) { |
| 2236 | ALOGE("%s: Invalid snd_device = %d", __func__, snd_device); |
| 2237 | return -EINVAL; |
| 2238 | } |
| 2239 | return acdb_device_table[snd_device]; |
| 2240 | } |
Preetam Singh Ranawat | 8bde2c5 | 2015-03-20 12:00:49 +0530 | [diff] [blame] | 2241 | |
| 2242 | int platform_set_snd_device_bit_width(snd_device_t snd_device, unsigned int bit_width) |
Amit Shekhar | 5a39c91 | 2014-10-14 15:39:30 -0700 | [diff] [blame] | 2243 | { |
Preetam Singh Ranawat | 8bde2c5 | 2015-03-20 12:00:49 +0530 | [diff] [blame] | 2244 | int ret = 0; |
| 2245 | |
| 2246 | if ((snd_device < SND_DEVICE_MIN) || (snd_device >= SND_DEVICE_MAX)) { |
| 2247 | ALOGE("%s: Invalid snd_device = %d", |
| 2248 | __func__, snd_device); |
| 2249 | ret = -EINVAL; |
| 2250 | goto done; |
| 2251 | } |
| 2252 | |
| 2253 | backend_bit_width_table[snd_device] = bit_width; |
| 2254 | done: |
| 2255 | return ret; |
Amit Shekhar | 5a39c91 | 2014-10-14 15:39:30 -0700 | [diff] [blame] | 2256 | } |
| 2257 | |
Preetam Singh Ranawat | 8bde2c5 | 2015-03-20 12:00:49 +0530 | [diff] [blame] | 2258 | int platform_get_snd_device_bit_width(snd_device_t snd_device) |
Amit Shekhar | 5a39c91 | 2014-10-14 15:39:30 -0700 | [diff] [blame] | 2259 | { |
Preetam Singh Ranawat | 8bde2c5 | 2015-03-20 12:00:49 +0530 | [diff] [blame] | 2260 | if ((snd_device < SND_DEVICE_MIN) || (snd_device >= SND_DEVICE_MAX)) { |
| 2261 | ALOGE("%s: Invalid snd_device = %d", __func__, snd_device); |
Ashish Jain | b449be3 | 2015-07-19 05:39:23 -0700 | [diff] [blame] | 2262 | return CODEC_BACKEND_DEFAULT_BIT_WIDTH; |
Preetam Singh Ranawat | 8bde2c5 | 2015-03-20 12:00:49 +0530 | [diff] [blame] | 2263 | } |
| 2264 | return backend_bit_width_table[snd_device]; |
Amit Shekhar | 5a39c91 | 2014-10-14 15:39:30 -0700 | [diff] [blame] | 2265 | } |
Sidipotu Ashok | e6f78cb | 2015-11-05 14:42:20 +0530 | [diff] [blame] | 2266 | int platform_set_native_support(int na_mode) |
Apoorv Raghuvanshi | 2149216 | 2015-02-19 18:19:36 -0800 | [diff] [blame] | 2267 | { |
Sidipotu Ashok | e6f78cb | 2015-11-05 14:42:20 +0530 | [diff] [blame] | 2268 | if (NATIVE_AUDIO_MODE_SRC == na_mode || NATIVE_AUDIO_MODE_TRUE_44_1 == na_mode) { |
| 2269 | na_props.platform_na_prop_enabled = na_props.ui_na_prop_enabled = true; |
| 2270 | na_props.na_mode = na_mode; |
Sidipotu Ashok | 9f0b16e | 2016-04-28 13:48:28 +0530 | [diff] [blame] | 2271 | ALOGD("%s:napb: native audio playback enabled in (%s) mode v2.0", __func__, |
Sidipotu Ashok | e6f78cb | 2015-11-05 14:42:20 +0530 | [diff] [blame] | 2272 | ((na_mode == NATIVE_AUDIO_MODE_SRC)?"SRC mode":"True 44.1 mode")); |
| 2273 | } else { |
| 2274 | na_props.platform_na_prop_enabled = false; |
| 2275 | na_props.na_mode = NATIVE_AUDIO_MODE_INVALID; |
| 2276 | ALOGD("%s:napb: native audio playback disabled", __func__); |
| 2277 | } |
| 2278 | |
Apoorv Raghuvanshi | 2149216 | 2015-02-19 18:19:36 -0800 | [diff] [blame] | 2279 | return 0; |
| 2280 | } |
| 2281 | |
Preetam Singh Ranawat | c61f867 | 2015-06-18 23:20:28 +0530 | [diff] [blame] | 2282 | int platform_get_native_support() |
Apoorv Raghuvanshi | 2149216 | 2015-02-19 18:19:36 -0800 | [diff] [blame] | 2283 | { |
Sidipotu Ashok | e6f78cb | 2015-11-05 14:42:20 +0530 | [diff] [blame] | 2284 | int ret = NATIVE_AUDIO_MODE_INVALID; |
| 2285 | if (na_props.platform_na_prop_enabled && |
| 2286 | na_props.ui_na_prop_enabled) { |
| 2287 | ret = na_props.na_mode; |
Preetam Singh Ranawat | c61f867 | 2015-06-18 23:20:28 +0530 | [diff] [blame] | 2288 | } |
Sidipotu Ashok | e6f78cb | 2015-11-05 14:42:20 +0530 | [diff] [blame] | 2289 | ALOGV("%s:napb: ui Prop enabled(%d) version(%d)", __func__, |
| 2290 | na_props.ui_na_prop_enabled, na_props.na_mode); |
Preetam Singh Ranawat | c61f867 | 2015-06-18 23:20:28 +0530 | [diff] [blame] | 2291 | return ret; |
| 2292 | } |
| 2293 | |
| 2294 | void native_audio_get_params(struct str_parms *query, |
| 2295 | struct str_parms *reply, |
| 2296 | char *value, int len) |
| 2297 | { |
| 2298 | int ret; |
| 2299 | ret = str_parms_get_str(query, AUDIO_PARAMETER_KEY_NATIVE_AUDIO, |
| 2300 | value, len); |
| 2301 | if (ret >= 0) { |
| 2302 | if (na_props.platform_na_prop_enabled) { |
| 2303 | str_parms_add_str(reply, AUDIO_PARAMETER_KEY_NATIVE_AUDIO, |
| 2304 | na_props.ui_na_prop_enabled ? "true" : "false"); |
Sidipotu Ashok | e6f78cb | 2015-11-05 14:42:20 +0530 | [diff] [blame] | 2305 | ALOGV("%s:napb: na_props.ui_na_prop_enabled: %d", __func__, |
| 2306 | na_props.ui_na_prop_enabled); |
Preetam Singh Ranawat | c61f867 | 2015-06-18 23:20:28 +0530 | [diff] [blame] | 2307 | } else { |
| 2308 | str_parms_add_str(reply, AUDIO_PARAMETER_KEY_NATIVE_AUDIO, |
| 2309 | "false"); |
Sidipotu Ashok | e6f78cb | 2015-11-05 14:42:20 +0530 | [diff] [blame] | 2310 | ALOGV("%s:napb: native audio not supported: %d", __func__, |
| 2311 | na_props.platform_na_prop_enabled); |
Preetam Singh Ranawat | c61f867 | 2015-06-18 23:20:28 +0530 | [diff] [blame] | 2312 | } |
| 2313 | } |
| 2314 | } |
| 2315 | |
| 2316 | int native_audio_set_params(struct platform_data *platform, |
| 2317 | struct str_parms *parms, char *value, int len) |
| 2318 | { |
Preetam Singh Ranawat | 5319430 | 2016-03-15 16:37:42 +0530 | [diff] [blame] | 2319 | int ret = -1; |
Preetam Singh Ranawat | c61f867 | 2015-06-18 23:20:28 +0530 | [diff] [blame] | 2320 | struct audio_usecase *usecase; |
| 2321 | struct listnode *node; |
Sidipotu Ashok | e6f78cb | 2015-11-05 14:42:20 +0530 | [diff] [blame] | 2322 | int mode = NATIVE_AUDIO_MODE_INVALID; |
| 2323 | |
Preetam Singh Ranawat | 6746b7a | 2016-07-18 16:40:24 +0530 | [diff] [blame] | 2324 | if (!value || !parms) |
Preetam Singh Ranawat | 5319430 | 2016-03-15 16:37:42 +0530 | [diff] [blame] | 2325 | return ret; |
| 2326 | |
Sidipotu Ashok | e6f78cb | 2015-11-05 14:42:20 +0530 | [diff] [blame] | 2327 | ret = str_parms_get_str(parms, AUDIO_PARAMETER_KEY_NATIVE_AUDIO_MODE, |
| 2328 | value, len); |
| 2329 | if (ret >= 0) { |
| 2330 | if (value && !strncmp(value, "src", sizeof("src"))) |
| 2331 | mode = NATIVE_AUDIO_MODE_SRC; |
| 2332 | else if (value && !strncmp(value, "true", sizeof("true"))) |
| 2333 | mode = NATIVE_AUDIO_MODE_TRUE_44_1; |
| 2334 | else { |
| 2335 | mode = NATIVE_AUDIO_MODE_INVALID; |
| 2336 | ALOGE("%s:napb:native_audio_mode in platform info xml,invalid mode string", |
| 2337 | __func__); |
| 2338 | } |
| 2339 | ALOGD("%s:napb updating mode (%d) from XML",__func__, mode); |
| 2340 | platform_set_native_support(mode); |
| 2341 | } |
| 2342 | |
| 2343 | |
Preetam Singh Ranawat | c61f867 | 2015-06-18 23:20:28 +0530 | [diff] [blame] | 2344 | |
| 2345 | ret = str_parms_get_str(parms, AUDIO_PARAMETER_KEY_NATIVE_AUDIO, |
| 2346 | value, len); |
| 2347 | if (ret >= 0) { |
| 2348 | if (na_props.platform_na_prop_enabled) { |
Sidipotu Ashok | 894644d | 2015-07-06 18:35:03 +0530 | [diff] [blame] | 2349 | if (!strncmp("true", value, sizeof("true"))) { |
Preetam Singh Ranawat | c61f867 | 2015-06-18 23:20:28 +0530 | [diff] [blame] | 2350 | na_props.ui_na_prop_enabled = true; |
Sidipotu Ashok | e6f78cb | 2015-11-05 14:42:20 +0530 | [diff] [blame] | 2351 | ALOGD("%s:napb: native audio feature enabled from UI", |
| 2352 | __func__); |
Sidipotu Ashok | 894644d | 2015-07-06 18:35:03 +0530 | [diff] [blame] | 2353 | } |
| 2354 | else { |
Preetam Singh Ranawat | c61f867 | 2015-06-18 23:20:28 +0530 | [diff] [blame] | 2355 | na_props.ui_na_prop_enabled = false; |
Sidipotu Ashok | e6f78cb | 2015-11-05 14:42:20 +0530 | [diff] [blame] | 2356 | ALOGD("%s:napb: native audio feature disabled from UI", |
| 2357 | __func__); |
Sidipotu Ashok | 894644d | 2015-07-06 18:35:03 +0530 | [diff] [blame] | 2358 | } |
Preetam Singh Ranawat | c61f867 | 2015-06-18 23:20:28 +0530 | [diff] [blame] | 2359 | |
| 2360 | str_parms_del(parms, AUDIO_PARAMETER_KEY_NATIVE_AUDIO); |
| 2361 | |
Sidipotu Ashok | e6f78cb | 2015-11-05 14:42:20 +0530 | [diff] [blame] | 2362 | /* |
| 2363 | * Iterate through the usecase list and trigger device switch for |
| 2364 | * all the appropriate usecases |
| 2365 | */ |
Preetam Singh Ranawat | c61f867 | 2015-06-18 23:20:28 +0530 | [diff] [blame] | 2366 | list_for_each(node, &(platform->adev)->usecase_list) { |
| 2367 | usecase = node_to_item(node, struct audio_usecase, list); |
| 2368 | |
| 2369 | if (is_offload_usecase(usecase->id) && |
| 2370 | (usecase->stream.out->devices & AUDIO_DEVICE_OUT_WIRED_HEADPHONE || |
| 2371 | usecase->stream.out->devices & AUDIO_DEVICE_OUT_WIRED_HEADSET) && |
| 2372 | OUTPUT_SAMPLING_RATE_44100 == usecase->stream.out->sample_rate) { |
Sidipotu Ashok | e6f78cb | 2015-11-05 14:42:20 +0530 | [diff] [blame] | 2373 | ALOGD("%s:napb: triggering dynamic device switch for usecase(%d: %s)" |
Sidipotu Ashok | 894644d | 2015-07-06 18:35:03 +0530 | [diff] [blame] | 2374 | " stream(%p), device(%d)", __func__, usecase->id, |
Alexy Joseph | b137994 | 2016-01-29 15:49:38 -0800 | [diff] [blame] | 2375 | use_case_table[usecase->id], (void*) usecase->stream.out, |
Preetam Singh Ranawat | c61f867 | 2015-06-18 23:20:28 +0530 | [diff] [blame] | 2376 | usecase->stream.out->devices); |
Sidipotu Ashok | 894644d | 2015-07-06 18:35:03 +0530 | [diff] [blame] | 2377 | select_devices(platform->adev, usecase->id); |
Preetam Singh Ranawat | c61f867 | 2015-06-18 23:20:28 +0530 | [diff] [blame] | 2378 | } |
| 2379 | } |
Sidipotu Ashok | e6f78cb | 2015-11-05 14:42:20 +0530 | [diff] [blame] | 2380 | } else |
| 2381 | ALOGD("%s:napb: native audio cannot be enabled from UI", |
| 2382 | __func__); |
Preetam Singh Ranawat | c61f867 | 2015-06-18 23:20:28 +0530 | [diff] [blame] | 2383 | } |
| 2384 | return ret; |
| 2385 | } |
| 2386 | |
Ashish Jain | f1eaa58 | 2016-05-23 20:54:24 +0530 | [diff] [blame] | 2387 | static void true_32_bit_set_params(struct str_parms *parms, |
| 2388 | char *value, int len) |
| 2389 | { |
| 2390 | int ret = 0; |
| 2391 | |
| 2392 | ret = str_parms_get_str(parms, AUDIO_PARAMETER_KEY_TRUE_32_BIT, |
| 2393 | value,len); |
| 2394 | if (ret >= 0) { |
| 2395 | if (value && !strncmp(value, "true", sizeof("src"))) |
| 2396 | supports_true_32_bit = true; |
| 2397 | else |
| 2398 | supports_true_32_bit = false; |
| 2399 | str_parms_del(parms, AUDIO_PARAMETER_KEY_TRUE_32_BIT); |
| 2400 | } |
| 2401 | |
| 2402 | } |
| 2403 | |
| 2404 | bool platform_supports_true_32bit() |
| 2405 | { |
| 2406 | return supports_true_32_bit; |
| 2407 | } |
| 2408 | |
Sidipotu Ashok | ad8fff8 | 2016-02-02 10:48:42 +0530 | [diff] [blame] | 2409 | int check_hdset_combo_device(snd_device_t snd_device) |
Sidipotu Ashok | e6f78cb | 2015-11-05 14:42:20 +0530 | [diff] [blame] | 2410 | { |
| 2411 | int ret = false; |
Sidipotu Ashok | e6f78cb | 2015-11-05 14:42:20 +0530 | [diff] [blame] | 2412 | |
Sidipotu Ashok | ad8fff8 | 2016-02-02 10:48:42 +0530 | [diff] [blame] | 2413 | if (SND_DEVICE_OUT_SPEAKER_AND_HEADPHONES == snd_device || |
| 2414 | SND_DEVICE_OUT_SPEAKER_AND_LINE == snd_device || |
| 2415 | SND_DEVICE_OUT_SPEAKER_AND_HEADPHONES_EXTERNAL_1 == snd_device || |
| 2416 | SND_DEVICE_OUT_SPEAKER_AND_HEADPHONES_EXTERNAL_2 == snd_device || |
| 2417 | SND_DEVICE_OUT_SPEAKER_AND_ANC_HEADSET == snd_device) |
Sidipotu Ashok | e6f78cb | 2015-11-05 14:42:20 +0530 | [diff] [blame] | 2418 | ret = true; |
Sidipotu Ashok | e6f78cb | 2015-11-05 14:42:20 +0530 | [diff] [blame] | 2419 | |
| 2420 | return ret; |
| 2421 | } |
| 2422 | |
| 2423 | |
Sidipotu Ashok | 9f0b16e | 2016-04-28 13:48:28 +0530 | [diff] [blame] | 2424 | static int platform_get_backend_index(snd_device_t snd_device) |
Preetam Singh Ranawat | c61f867 | 2015-06-18 23:20:28 +0530 | [diff] [blame] | 2425 | { |
| 2426 | int32_t port = DEFAULT_CODEC_BACKEND; |
| 2427 | |
| 2428 | if (snd_device >= SND_DEVICE_MIN && snd_device < SND_DEVICE_MAX) { |
Sidipotu Ashok | 9f0b16e | 2016-04-28 13:48:28 +0530 | [diff] [blame] | 2429 | if (backend_tag_table[snd_device] != NULL) { |
| 2430 | if (strncmp(backend_tag_table[snd_device], "headphones-44.1", |
| 2431 | sizeof("headphones-44.1")) == 0) |
| 2432 | port = HEADPHONE_44_1_BACKEND; |
| 2433 | else if (strncmp(backend_tag_table[snd_device], "headphones", |
| 2434 | sizeof("headphones")) == 0) |
| 2435 | port = HEADPHONE_BACKEND; |
| 2436 | else if (strcmp(backend_tag_table[snd_device], "hdmi") == 0) |
| 2437 | port = HDMI_RX_BACKEND; |
Kuirong Wang | a9f7cee | 2016-03-07 11:21:52 -0800 | [diff] [blame] | 2438 | else if (strcmp(backend_tag_table[snd_device], "usb-headphones") == 0) |
| 2439 | port = USB_AUDIO_RX_BACKEND; |
Sidipotu Ashok | 9f0b16e | 2016-04-28 13:48:28 +0530 | [diff] [blame] | 2440 | } |
Preetam Singh Ranawat | c61f867 | 2015-06-18 23:20:28 +0530 | [diff] [blame] | 2441 | } else { |
Sidipotu Ashok | e6f78cb | 2015-11-05 14:42:20 +0530 | [diff] [blame] | 2442 | ALOGV("%s:napb: Invalid device - %d ", __func__, snd_device); |
Preetam Singh Ranawat | c61f867 | 2015-06-18 23:20:28 +0530 | [diff] [blame] | 2443 | } |
| 2444 | |
Sidipotu Ashok | 9f0b16e | 2016-04-28 13:48:28 +0530 | [diff] [blame] | 2445 | ALOGV("%s:napb: backend port - %d device - %d ", __func__, port, |
| 2446 | snd_device); |
Preetam Singh Ranawat | c61f867 | 2015-06-18 23:20:28 +0530 | [diff] [blame] | 2447 | return port; |
Apoorv Raghuvanshi | 2149216 | 2015-02-19 18:19:36 -0800 | [diff] [blame] | 2448 | } |
| 2449 | |
Preetam Singh Ranawat | 2d0e463 | 2015-02-02 12:40:59 +0530 | [diff] [blame] | 2450 | int platform_send_audio_calibration(void *platform, struct audio_usecase *usecase, |
Subhash Chandra Bose Naripeddy | 5427467 | 2014-03-10 14:51:02 -0700 | [diff] [blame] | 2451 | int app_type, int sample_rate) |
Naresh Tanniru | e3b1845 | 2014-03-04 14:44:27 +0530 | [diff] [blame] | 2452 | { |
| 2453 | struct platform_data *my_data = (struct platform_data *)platform; |
| 2454 | int acdb_dev_id, acdb_dev_type; |
Preetam Singh Ranawat | 2d0e463 | 2015-02-02 12:40:59 +0530 | [diff] [blame] | 2455 | int snd_device = SND_DEVICE_OUT_SPEAKER; |
Sidipotu Ashok | 9f0b16e | 2016-04-28 13:48:28 +0530 | [diff] [blame] | 2456 | int new_snd_device[SND_DEVICE_OUT_END]; |
| 2457 | int i, num_devices = 1; |
Preetam Singh Ranawat | 2d0e463 | 2015-02-02 12:40:59 +0530 | [diff] [blame] | 2458 | |
Preetam Singh Ranawat | 8bde2c5 | 2015-03-20 12:00:49 +0530 | [diff] [blame] | 2459 | if (usecase->type == PCM_PLAYBACK) |
Naresh Tanniru | cc7c4de | 2015-03-10 16:19:23 +0530 | [diff] [blame] | 2460 | snd_device = usecase->out_snd_device; |
Karthik Reddy Katta | 81c4261 | 2015-11-13 17:49:07 +0530 | [diff] [blame] | 2461 | else if ((usecase->type == PCM_CAPTURE) && |
| 2462 | voice_is_in_call_rec_stream(usecase->stream.in)) |
| 2463 | snd_device = voice_get_incall_rec_snd_device(usecase->in_snd_device); |
Preetam Singh Ranawat | 8bde2c5 | 2015-03-20 12:00:49 +0530 | [diff] [blame] | 2464 | else if ((usecase->type == PCM_HFP_CALL) || (usecase->type == PCM_CAPTURE)) |
Naresh Tanniru | cc7c4de | 2015-03-10 16:19:23 +0530 | [diff] [blame] | 2465 | snd_device = usecase->in_snd_device; |
Xiaojun Sang | 040cc9f | 2015-08-03 19:38:28 +0800 | [diff] [blame] | 2466 | acdb_dev_id = acdb_device_table[platform_get_spkr_prot_snd_device(snd_device)]; |
Naresh Tanniru | e3b1845 | 2014-03-04 14:44:27 +0530 | [diff] [blame] | 2467 | |
Sidipotu Ashok | 9f0b16e | 2016-04-28 13:48:28 +0530 | [diff] [blame] | 2468 | if(!platform_can_split_snd_device(platform, snd_device, &num_devices, new_snd_device)) { |
| 2469 | new_snd_device[0] = snd_device; |
Naresh Tanniru | 2727f82 | 2015-05-11 15:27:08 +0530 | [diff] [blame] | 2470 | } |
Sidipotu Ashok | 9f0b16e | 2016-04-28 13:48:28 +0530 | [diff] [blame] | 2471 | |
| 2472 | for (i = 0; i < num_devices; i++) { |
| 2473 | acdb_dev_id = acdb_device_table[platform_get_spkr_prot_snd_device(new_snd_device[i])]; |
| 2474 | |
| 2475 | // Do not use Rx path default app type for TX path |
| 2476 | if ((usecase->type == PCM_CAPTURE) && (app_type == DEFAULT_APP_TYPE_RX_PATH)) { |
| 2477 | ALOGD("Resetting app type for Tx path to default"); |
| 2478 | app_type = DEFAULT_APP_TYPE_TX_PATH; |
| 2479 | } |
| 2480 | if (acdb_dev_id < 0) { |
| 2481 | ALOGE("%s: Could not find acdb id for device(%d)", |
| 2482 | __func__, new_snd_device[i]); |
| 2483 | return -EINVAL; |
| 2484 | } |
| 2485 | if (my_data->acdb_send_audio_cal) { |
| 2486 | ALOGV("%s: sending audio calibration for snd_device(%d) acdb_id(%d)", |
| 2487 | __func__, new_snd_device[i], acdb_dev_id); |
| 2488 | if (new_snd_device[i] >= SND_DEVICE_OUT_BEGIN && |
| 2489 | new_snd_device[i] < SND_DEVICE_OUT_END) |
| 2490 | acdb_dev_type = ACDB_DEV_TYPE_OUT; |
| 2491 | else |
| 2492 | acdb_dev_type = ACDB_DEV_TYPE_IN; |
| 2493 | my_data->acdb_send_audio_cal(acdb_dev_id, acdb_dev_type, app_type, |
| 2494 | sample_rate); |
| 2495 | } |
Naresh Tanniru | e3b1845 | 2014-03-04 14:44:27 +0530 | [diff] [blame] | 2496 | } |
| 2497 | return 0; |
| 2498 | } |
| 2499 | |
| 2500 | int platform_switch_voice_call_device_pre(void *platform) |
| 2501 | { |
Naresh Tanniru | db72d1e | 2014-03-05 17:33:47 +0530 | [diff] [blame] | 2502 | struct platform_data *my_data = (struct platform_data *)platform; |
| 2503 | int ret = 0; |
| 2504 | |
| 2505 | if (my_data->csd != NULL && |
Ravi Kumar Alamanda | be14939 | 2014-10-20 17:07:43 -0700 | [diff] [blame] | 2506 | voice_is_in_call(my_data->adev)) { |
Naresh Tanniru | db72d1e | 2014-03-05 17:33:47 +0530 | [diff] [blame] | 2507 | /* This must be called before disabling mixer controls on APQ side */ |
| 2508 | ret = my_data->csd->disable_device(); |
| 2509 | if (ret < 0) { |
| 2510 | ALOGE("%s: csd_client_disable_device, failed, error %d", |
| 2511 | __func__, ret); |
| 2512 | } |
| 2513 | } |
| 2514 | return ret; |
Naresh Tanniru | e3b1845 | 2014-03-04 14:44:27 +0530 | [diff] [blame] | 2515 | } |
Preetam Singh Ranawat | 8bde2c5 | 2015-03-20 12:00:49 +0530 | [diff] [blame] | 2516 | |
Naresh Tanniru | db72d1e | 2014-03-05 17:33:47 +0530 | [diff] [blame] | 2517 | int platform_switch_voice_call_enable_device_config(void *platform, |
| 2518 | snd_device_t out_snd_device, |
| 2519 | snd_device_t in_snd_device) |
| 2520 | { |
| 2521 | struct platform_data *my_data = (struct platform_data *)platform; |
| 2522 | int acdb_rx_id, acdb_tx_id; |
| 2523 | int ret = 0; |
| 2524 | |
Preetam Singh Ranawat | 8bde2c5 | 2015-03-20 12:00:49 +0530 | [diff] [blame] | 2525 | if (my_data->csd == NULL) |
| 2526 | return ret; |
| 2527 | |
Banajit Goswami | 20cdd21 | 2015-09-11 01:11:30 -0700 | [diff] [blame] | 2528 | if ((out_snd_device == SND_DEVICE_OUT_VOICE_SPEAKER || |
| 2529 | out_snd_device == SND_DEVICE_OUT_VOICE_SPEAKER_VBAT) && |
| 2530 | audio_extn_spkr_prot_is_enabled()) { |
| 2531 | if (my_data->is_vbat_speaker) |
| 2532 | acdb_rx_id = acdb_device_table[SND_DEVICE_OUT_SPEAKER_PROTECTED_VBAT]; |
| 2533 | else |
| 2534 | acdb_rx_id = acdb_device_table[SND_DEVICE_OUT_SPEAKER_PROTECTED]; |
| 2535 | } else |
Preetam Singh Ranawat | 8bde2c5 | 2015-03-20 12:00:49 +0530 | [diff] [blame] | 2536 | acdb_rx_id = acdb_device_table[out_snd_device]; |
| 2537 | |
Naresh Tanniru | db72d1e | 2014-03-05 17:33:47 +0530 | [diff] [blame] | 2538 | acdb_tx_id = acdb_device_table[in_snd_device]; |
| 2539 | |
Preetam Singh Ranawat | 8bde2c5 | 2015-03-20 12:00:49 +0530 | [diff] [blame] | 2540 | if (acdb_rx_id > 0 && acdb_tx_id > 0) { |
| 2541 | ret = my_data->csd->enable_device_config(acdb_rx_id, acdb_tx_id); |
| 2542 | if (ret < 0) { |
| 2543 | ALOGE("%s: csd_enable_device_config, failed, error %d", |
| 2544 | __func__, ret); |
Naresh Tanniru | db72d1e | 2014-03-05 17:33:47 +0530 | [diff] [blame] | 2545 | } |
Preetam Singh Ranawat | 8bde2c5 | 2015-03-20 12:00:49 +0530 | [diff] [blame] | 2546 | } else { |
| 2547 | ALOGE("%s: Incorrect ACDB IDs (rx: %d tx: %d)", __func__, |
| 2548 | acdb_rx_id, acdb_tx_id); |
Naresh Tanniru | db72d1e | 2014-03-05 17:33:47 +0530 | [diff] [blame] | 2549 | } |
Preetam Singh Ranawat | 8bde2c5 | 2015-03-20 12:00:49 +0530 | [diff] [blame] | 2550 | |
Naresh Tanniru | db72d1e | 2014-03-05 17:33:47 +0530 | [diff] [blame] | 2551 | return ret; |
| 2552 | } |
| 2553 | |
Naresh Tanniru | e3b1845 | 2014-03-04 14:44:27 +0530 | [diff] [blame] | 2554 | int platform_switch_voice_call_device_post(void *platform, |
| 2555 | snd_device_t out_snd_device, |
| 2556 | snd_device_t in_snd_device) |
| 2557 | { |
| 2558 | struct platform_data *my_data = (struct platform_data *)platform; |
| 2559 | int acdb_rx_id, acdb_tx_id; |
| 2560 | |
| 2561 | if (my_data->acdb_send_voice_cal == NULL) { |
| 2562 | ALOGE("%s: dlsym error for acdb_send_voice_call", __func__); |
| 2563 | } else { |
Preetam Singh Ranawat | 8bde2c5 | 2015-03-20 12:00:49 +0530 | [diff] [blame] | 2564 | if (out_snd_device == SND_DEVICE_OUT_VOICE_SPEAKER && |
| 2565 | audio_extn_spkr_prot_is_enabled()) |
| 2566 | out_snd_device = SND_DEVICE_OUT_VOICE_SPEAKER_PROTECTED; |
| 2567 | |
Naresh Tanniru | e3b1845 | 2014-03-04 14:44:27 +0530 | [diff] [blame] | 2568 | acdb_rx_id = acdb_device_table[out_snd_device]; |
| 2569 | acdb_tx_id = acdb_device_table[in_snd_device]; |
| 2570 | |
| 2571 | if (acdb_rx_id > 0 && acdb_tx_id > 0) |
| 2572 | my_data->acdb_send_voice_cal(acdb_rx_id, acdb_tx_id); |
| 2573 | else |
| 2574 | ALOGE("%s: Incorrect ACDB IDs (rx: %d tx: %d)", __func__, |
| 2575 | acdb_rx_id, acdb_tx_id); |
| 2576 | } |
| 2577 | |
| 2578 | return 0; |
| 2579 | } |
| 2580 | |
Naresh Tanniru | db72d1e | 2014-03-05 17:33:47 +0530 | [diff] [blame] | 2581 | int platform_switch_voice_call_usecase_route_post(void *platform, |
| 2582 | snd_device_t out_snd_device, |
| 2583 | snd_device_t in_snd_device) |
Naresh Tanniru | e3b1845 | 2014-03-04 14:44:27 +0530 | [diff] [blame] | 2584 | { |
Naresh Tanniru | db72d1e | 2014-03-05 17:33:47 +0530 | [diff] [blame] | 2585 | struct platform_data *my_data = (struct platform_data *)platform; |
| 2586 | int acdb_rx_id, acdb_tx_id; |
| 2587 | int ret = 0; |
| 2588 | |
Preetam Singh Ranawat | 8bde2c5 | 2015-03-20 12:00:49 +0530 | [diff] [blame] | 2589 | if (my_data->csd == NULL) |
| 2590 | return ret; |
| 2591 | |
Banajit Goswami | 20cdd21 | 2015-09-11 01:11:30 -0700 | [diff] [blame] | 2592 | if ((out_snd_device == SND_DEVICE_OUT_VOICE_SPEAKER || |
| 2593 | out_snd_device == SND_DEVICE_OUT_VOICE_SPEAKER_VBAT) && |
| 2594 | audio_extn_spkr_prot_is_enabled()) { |
| 2595 | if (my_data->is_vbat_speaker) |
| 2596 | acdb_rx_id = acdb_device_table[SND_DEVICE_OUT_SPEAKER_PROTECTED_VBAT]; |
| 2597 | else |
| 2598 | acdb_rx_id = acdb_device_table[SND_DEVICE_OUT_SPEAKER_PROTECTED]; |
| 2599 | } else |
Preetam Singh Ranawat | 8bde2c5 | 2015-03-20 12:00:49 +0530 | [diff] [blame] | 2600 | acdb_rx_id = acdb_device_table[out_snd_device]; |
| 2601 | |
Naresh Tanniru | db72d1e | 2014-03-05 17:33:47 +0530 | [diff] [blame] | 2602 | acdb_tx_id = acdb_device_table[in_snd_device]; |
| 2603 | |
Preetam Singh Ranawat | 8bde2c5 | 2015-03-20 12:00:49 +0530 | [diff] [blame] | 2604 | if (acdb_rx_id > 0 && acdb_tx_id > 0) { |
| 2605 | ret = my_data->csd->enable_device(acdb_rx_id, acdb_tx_id, |
| 2606 | my_data->adev->acdb_settings); |
| 2607 | if (ret < 0) { |
| 2608 | ALOGE("%s: csd_enable_device, failed, error %d", __func__, ret); |
Naresh Tanniru | db72d1e | 2014-03-05 17:33:47 +0530 | [diff] [blame] | 2609 | } |
Preetam Singh Ranawat | 8bde2c5 | 2015-03-20 12:00:49 +0530 | [diff] [blame] | 2610 | } else { |
| 2611 | ALOGE("%s: Incorrect ACDB IDs (rx: %d tx: %d)", __func__, |
| 2612 | acdb_rx_id, acdb_tx_id); |
Naresh Tanniru | db72d1e | 2014-03-05 17:33:47 +0530 | [diff] [blame] | 2613 | } |
Preetam Singh Ranawat | 8bde2c5 | 2015-03-20 12:00:49 +0530 | [diff] [blame] | 2614 | |
Naresh Tanniru | db72d1e | 2014-03-05 17:33:47 +0530 | [diff] [blame] | 2615 | return ret; |
Naresh Tanniru | e3b1845 | 2014-03-04 14:44:27 +0530 | [diff] [blame] | 2616 | } |
| 2617 | |
Naresh Tanniru | db72d1e | 2014-03-05 17:33:47 +0530 | [diff] [blame] | 2618 | int platform_start_voice_call(void *platform, uint32_t vsid) |
| 2619 | { |
| 2620 | struct platform_data *my_data = (struct platform_data *)platform; |
| 2621 | int ret = 0; |
| 2622 | |
| 2623 | if (my_data->csd != NULL) { |
| 2624 | ret = my_data->csd->start_voice(vsid); |
| 2625 | if (ret < 0) { |
| 2626 | ALOGE("%s: csd_start_voice error %d\n", __func__, ret); |
| 2627 | } |
| 2628 | } |
| 2629 | return ret; |
| 2630 | } |
| 2631 | |
| 2632 | int platform_stop_voice_call(void *platform, uint32_t vsid) |
| 2633 | { |
| 2634 | struct platform_data *my_data = (struct platform_data *)platform; |
| 2635 | int ret = 0; |
| 2636 | |
| 2637 | if (my_data->csd != NULL) { |
| 2638 | ret = my_data->csd->stop_voice(vsid); |
| 2639 | if (ret < 0) { |
| 2640 | ALOGE("%s: csd_stop_voice error %d\n", __func__, ret); |
| 2641 | } |
| 2642 | } |
| 2643 | return ret; |
| 2644 | } |
Ravi Kumar Alamanda | bdf1416 | 2014-09-05 16:14:17 -0700 | [diff] [blame] | 2645 | |
Satya Krishna Pindiproli | f1cd92b | 2016-04-14 19:05:23 +0530 | [diff] [blame] | 2646 | int platform_get_sample_rate(void *platform __unused, |
| 2647 | uint32_t *rate __unused) |
Naresh Tanniru | e3b1845 | 2014-03-04 14:44:27 +0530 | [diff] [blame] | 2648 | { |
| 2649 | return 0; |
| 2650 | } |
| 2651 | |
| 2652 | int platform_set_voice_volume(void *platform, int volume) |
| 2653 | { |
| 2654 | struct platform_data *my_data = (struct platform_data *)platform; |
| 2655 | struct audio_device *adev = my_data->adev; |
| 2656 | struct mixer_ctl *ctl; |
Naresh Tanniru | db72d1e | 2014-03-05 17:33:47 +0530 | [diff] [blame] | 2657 | const char *mixer_ctl_name = "Voice Rx Gain"; |
| 2658 | int vol_index = 0, ret = 0; |
| 2659 | uint32_t set_values[ ] = {0, |
| 2660 | ALL_SESSION_VSID, |
| 2661 | DEFAULT_VOLUME_RAMP_DURATION_MS}; |
Naresh Tanniru | e3b1845 | 2014-03-04 14:44:27 +0530 | [diff] [blame] | 2662 | |
| 2663 | // Voice volume levels are mapped to adsp volume levels as follows. |
| 2664 | // 100 -> 5, 80 -> 4, 60 -> 3, 40 -> 2, 20 -> 1 0 -> 0 |
| 2665 | // But this values don't changed in kernel. So, below change is need. |
Naresh Tanniru | db72d1e | 2014-03-05 17:33:47 +0530 | [diff] [blame] | 2666 | vol_index = (int)percent_to_index(volume, MIN_VOL_INDEX, MAX_VOL_INDEX); |
| 2667 | set_values[0] = vol_index; |
Naresh Tanniru | e3b1845 | 2014-03-04 14:44:27 +0530 | [diff] [blame] | 2668 | |
| 2669 | ctl = mixer_get_ctl_by_name(adev->mixer, mixer_ctl_name); |
| 2670 | if (!ctl) { |
| 2671 | ALOGE("%s: Could not get ctl for mixer cmd - %s", |
| 2672 | __func__, mixer_ctl_name); |
| 2673 | return -EINVAL; |
| 2674 | } |
Naresh Tanniru | db72d1e | 2014-03-05 17:33:47 +0530 | [diff] [blame] | 2675 | ALOGV("Setting voice volume index: %d", set_values[0]); |
| 2676 | mixer_ctl_set_array(ctl, set_values, ARRAY_SIZE(set_values)); |
Naresh Tanniru | e3b1845 | 2014-03-04 14:44:27 +0530 | [diff] [blame] | 2677 | |
Naresh Tanniru | db72d1e | 2014-03-05 17:33:47 +0530 | [diff] [blame] | 2678 | if (my_data->csd != NULL) { |
Preetam Singh Ranawat | 8bde2c5 | 2015-03-20 12:00:49 +0530 | [diff] [blame] | 2679 | ret = my_data->csd->volume(ALL_SESSION_VSID, volume, |
| 2680 | DEFAULT_VOLUME_RAMP_DURATION_MS); |
Naresh Tanniru | db72d1e | 2014-03-05 17:33:47 +0530 | [diff] [blame] | 2681 | if (ret < 0) { |
| 2682 | ALOGE("%s: csd_volume error %d", __func__, ret); |
| 2683 | } |
| 2684 | } |
| 2685 | return ret; |
Naresh Tanniru | e3b1845 | 2014-03-04 14:44:27 +0530 | [diff] [blame] | 2686 | } |
| 2687 | |
| 2688 | int platform_set_mic_mute(void *platform, bool state) |
| 2689 | { |
| 2690 | struct platform_data *my_data = (struct platform_data *)platform; |
| 2691 | struct audio_device *adev = my_data->adev; |
| 2692 | struct mixer_ctl *ctl; |
| 2693 | const char *mixer_ctl_name = "Voice Tx Mute"; |
Naresh Tanniru | db72d1e | 2014-03-05 17:33:47 +0530 | [diff] [blame] | 2694 | int ret = 0; |
| 2695 | uint32_t set_values[ ] = {0, |
| 2696 | ALL_SESSION_VSID, |
Preetam Singh Ranawat | 8bde2c5 | 2015-03-20 12:00:49 +0530 | [diff] [blame] | 2697 | DEFAULT_MUTE_RAMP_DURATION_MS}; |
Naresh Tanniru | e3b1845 | 2014-03-04 14:44:27 +0530 | [diff] [blame] | 2698 | |
Naresh Tanniru | db72d1e | 2014-03-05 17:33:47 +0530 | [diff] [blame] | 2699 | set_values[0] = state; |
| 2700 | ctl = mixer_get_ctl_by_name(adev->mixer, mixer_ctl_name); |
| 2701 | if (!ctl) { |
| 2702 | ALOGE("%s: Could not get ctl for mixer cmd - %s", |
| 2703 | __func__, mixer_ctl_name); |
| 2704 | return -EINVAL; |
Naresh Tanniru | e3b1845 | 2014-03-04 14:44:27 +0530 | [diff] [blame] | 2705 | } |
Naresh Tanniru | db72d1e | 2014-03-05 17:33:47 +0530 | [diff] [blame] | 2706 | ALOGV("Setting voice mute state: %d", state); |
| 2707 | mixer_ctl_set_array(ctl, set_values, ARRAY_SIZE(set_values)); |
Naresh Tanniru | e3b1845 | 2014-03-04 14:44:27 +0530 | [diff] [blame] | 2708 | |
Naresh Tanniru | db72d1e | 2014-03-05 17:33:47 +0530 | [diff] [blame] | 2709 | if (my_data->csd != NULL) { |
Preetam Singh Ranawat | 8bde2c5 | 2015-03-20 12:00:49 +0530 | [diff] [blame] | 2710 | ret = my_data->csd->mic_mute(ALL_SESSION_VSID, state, |
| 2711 | DEFAULT_MUTE_RAMP_DURATION_MS); |
Naresh Tanniru | db72d1e | 2014-03-05 17:33:47 +0530 | [diff] [blame] | 2712 | if (ret < 0) { |
| 2713 | ALOGE("%s: csd_mic_mute error %d", __func__, ret); |
| 2714 | } |
| 2715 | } |
| 2716 | return ret; |
Naresh Tanniru | e3b1845 | 2014-03-04 14:44:27 +0530 | [diff] [blame] | 2717 | } |
| 2718 | |
Shiv Maliyappanahalli | c6fd8ee | 2014-03-07 15:31:55 -0800 | [diff] [blame] | 2719 | int platform_set_device_mute(void *platform, bool state, char *dir) |
| 2720 | { |
| 2721 | struct platform_data *my_data = (struct platform_data *)platform; |
| 2722 | struct audio_device *adev = my_data->adev; |
| 2723 | struct mixer_ctl *ctl; |
| 2724 | char *mixer_ctl_name = NULL; |
| 2725 | int ret = 0; |
| 2726 | uint32_t set_values[ ] = {0, |
| 2727 | ALL_SESSION_VSID, |
| 2728 | 0}; |
| 2729 | if(dir == NULL) { |
| 2730 | ALOGE("%s: Invalid direction:%s", __func__, dir); |
| 2731 | return -EINVAL; |
| 2732 | } |
| 2733 | |
| 2734 | if (!strncmp("rx", dir, sizeof("rx"))) { |
| 2735 | mixer_ctl_name = "Voice Rx Device Mute"; |
| 2736 | } else if (!strncmp("tx", dir, sizeof("tx"))) { |
| 2737 | mixer_ctl_name = "Voice Tx Device Mute"; |
| 2738 | } else { |
| 2739 | return -EINVAL; |
| 2740 | } |
| 2741 | |
| 2742 | set_values[0] = state; |
| 2743 | ctl = mixer_get_ctl_by_name(adev->mixer, mixer_ctl_name); |
| 2744 | if (!ctl) { |
| 2745 | ALOGE("%s: Could not get ctl for mixer cmd - %s", |
| 2746 | __func__, mixer_ctl_name); |
| 2747 | return -EINVAL; |
| 2748 | } |
| 2749 | |
| 2750 | ALOGV("%s: Setting device mute state: %d, mixer ctrl:%s", |
| 2751 | __func__,state, mixer_ctl_name); |
| 2752 | mixer_ctl_set_array(ctl, set_values, ARRAY_SIZE(set_values)); |
| 2753 | |
| 2754 | return ret; |
| 2755 | } |
| 2756 | |
Sidipotu Ashok | 9f0b16e | 2016-04-28 13:48:28 +0530 | [diff] [blame] | 2757 | bool platform_can_split_snd_device(void *platform, |
| 2758 | snd_device_t snd_device, |
| 2759 | int *num_devices, |
| 2760 | snd_device_t *new_snd_devices) |
| 2761 | { |
| 2762 | bool status = false; |
| 2763 | struct platform_data *my_data = (struct platform_data *)platform; |
| 2764 | |
| 2765 | if (NULL == num_devices || NULL == new_snd_devices) { |
| 2766 | ALOGE("%s: NULL pointer ..", __func__); |
| 2767 | return false; |
| 2768 | } |
| 2769 | |
| 2770 | /* |
| 2771 | * If wired headset/headphones/line devices share the same backend |
| 2772 | * with speaker/earpiece this routine returns false. |
| 2773 | */ |
| 2774 | if (snd_device == SND_DEVICE_OUT_SPEAKER_AND_HEADPHONES && |
| 2775 | !platform_check_backends_match(SND_DEVICE_OUT_SPEAKER, SND_DEVICE_OUT_HEADPHONES)) { |
| 2776 | *num_devices = 2; |
| 2777 | |
| 2778 | if (my_data->is_vbat_speaker) |
| 2779 | new_snd_devices[0] = SND_DEVICE_OUT_SPEAKER_VBAT; |
| 2780 | else if (my_data->is_wsa_speaker) |
| 2781 | new_snd_devices[0] = SND_DEVICE_OUT_SPEAKER_WSA; |
| 2782 | else |
| 2783 | new_snd_devices[0] = SND_DEVICE_OUT_SPEAKER; |
| 2784 | |
| 2785 | new_snd_devices[1] = SND_DEVICE_OUT_HEADPHONES; |
| 2786 | status = true; |
| 2787 | } else if (snd_device == SND_DEVICE_OUT_SPEAKER_AND_HDMI && |
| 2788 | !platform_check_backends_match(SND_DEVICE_OUT_SPEAKER, SND_DEVICE_OUT_HDMI)) { |
| 2789 | *num_devices = 2; |
| 2790 | |
| 2791 | if (my_data->is_vbat_speaker) |
| 2792 | new_snd_devices[0] = SND_DEVICE_OUT_SPEAKER_VBAT; |
| 2793 | else if (my_data->is_wsa_speaker) |
| 2794 | new_snd_devices[0] = SND_DEVICE_OUT_SPEAKER_WSA; |
| 2795 | else |
| 2796 | new_snd_devices[0] = SND_DEVICE_OUT_SPEAKER; |
| 2797 | |
| 2798 | new_snd_devices[1] = SND_DEVICE_OUT_HDMI; |
| 2799 | status = true; |
Kuirong Wang | a9f7cee | 2016-03-07 11:21:52 -0800 | [diff] [blame] | 2800 | } else if (snd_device == SND_DEVICE_OUT_SPEAKER_AND_USB_HEADSET && |
| 2801 | !platform_check_backends_match(SND_DEVICE_OUT_SPEAKER, SND_DEVICE_OUT_USB_HEADSET)) { |
| 2802 | *num_devices = 2; |
| 2803 | new_snd_devices[0] = SND_DEVICE_OUT_SPEAKER; |
| 2804 | new_snd_devices[1] = SND_DEVICE_OUT_USB_HEADSET; |
| 2805 | status = true; |
Sidipotu Ashok | 9f0b16e | 2016-04-28 13:48:28 +0530 | [diff] [blame] | 2806 | } |
| 2807 | |
| 2808 | ALOGD("%s: snd_device(%d) num devices(%d) new_snd_devices(%d)", __func__, |
| 2809 | snd_device, *num_devices, *new_snd_devices); |
| 2810 | |
| 2811 | return status; |
| 2812 | } |
| 2813 | |
Apoorv Raghuvanshi | 2149216 | 2015-02-19 18:19:36 -0800 | [diff] [blame] | 2814 | snd_device_t platform_get_output_snd_device(void *platform, struct stream_out *out) |
Naresh Tanniru | e3b1845 | 2014-03-04 14:44:27 +0530 | [diff] [blame] | 2815 | { |
| 2816 | struct platform_data *my_data = (struct platform_data *)platform; |
| 2817 | struct audio_device *adev = my_data->adev; |
| 2818 | audio_mode_t mode = adev->mode; |
| 2819 | snd_device_t snd_device = SND_DEVICE_NONE; |
Apoorv Raghuvanshi | 2149216 | 2015-02-19 18:19:36 -0800 | [diff] [blame] | 2820 | audio_devices_t devices = out->devices; |
Preetam Singh Ranawat | c61f867 | 2015-06-18 23:20:28 +0530 | [diff] [blame] | 2821 | unsigned int sample_rate = out->sample_rate; |
Sidipotu Ashok | e6f78cb | 2015-11-05 14:42:20 +0530 | [diff] [blame] | 2822 | int na_mode = platform_get_native_support(); |
Naresh Tanniru | c0517bc | 2014-10-26 15:30:55 +0530 | [diff] [blame] | 2823 | #ifdef RECORD_PLAY_CONCURRENCY |
| 2824 | bool use_voip_out_devices = false; |
| 2825 | bool prop_rec_play_enabled = false; |
| 2826 | char recConcPropValue[PROPERTY_VALUE_MAX]; |
| 2827 | |
| 2828 | if (property_get("rec.playback.conc.disabled", recConcPropValue, NULL)) { |
| 2829 | prop_rec_play_enabled = atoi(recConcPropValue) || !strncmp("true", recConcPropValue, 4); |
| 2830 | } |
| 2831 | use_voip_out_devices = prop_rec_play_enabled && |
| 2832 | (my_data->rec_play_conc_set || adev->mode == AUDIO_MODE_IN_COMMUNICATION); |
| 2833 | ALOGV("platform_get_output_snd_device use_voip_out_devices : %d",use_voip_out_devices); |
| 2834 | #endif |
Naresh Tanniru | e3b1845 | 2014-03-04 14:44:27 +0530 | [diff] [blame] | 2835 | |
Naresh Tanniru | db72d1e | 2014-03-05 17:33:47 +0530 | [diff] [blame] | 2836 | audio_channel_mask_t channel_mask = (adev->active_input == NULL) ? |
| 2837 | AUDIO_CHANNEL_IN_MONO : adev->active_input->channel_mask; |
| 2838 | int channel_count = popcount(channel_mask); |
| 2839 | |
Naresh Tanniru | e3b1845 | 2014-03-04 14:44:27 +0530 | [diff] [blame] | 2840 | ALOGV("%s: enter: output devices(%#x)", __func__, devices); |
| 2841 | if (devices == AUDIO_DEVICE_NONE || |
| 2842 | devices & AUDIO_DEVICE_BIT_IN) { |
| 2843 | ALOGV("%s: Invalid output devices (%#x)", __func__, devices); |
| 2844 | goto exit; |
| 2845 | } |
| 2846 | |
Shiv Maliyappanahalli | bd40126 | 2015-08-17 11:02:21 -0700 | [diff] [blame] | 2847 | if (popcount(devices) == 2) { |
Naresh Tanniru | e3b1845 | 2014-03-04 14:44:27 +0530 | [diff] [blame] | 2848 | if (devices == (AUDIO_DEVICE_OUT_WIRED_HEADPHONE | |
| 2849 | AUDIO_DEVICE_OUT_SPEAKER)) { |
Preetam Singh Ranawat | 8bde2c5 | 2015-03-20 12:00:49 +0530 | [diff] [blame] | 2850 | if (my_data->external_spk_1) |
| 2851 | snd_device = SND_DEVICE_OUT_SPEAKER_AND_HEADPHONES_EXTERNAL_1; |
| 2852 | else if (my_data->external_spk_2) |
| 2853 | snd_device = SND_DEVICE_OUT_SPEAKER_AND_HEADPHONES_EXTERNAL_2; |
| 2854 | else |
| 2855 | snd_device = SND_DEVICE_OUT_SPEAKER_AND_HEADPHONES; |
Naresh Tanniru | 9c4ba54 | 2015-11-06 18:01:09 +0530 | [diff] [blame] | 2856 | } else if (devices == (AUDIO_DEVICE_OUT_LINE | |
| 2857 | AUDIO_DEVICE_OUT_SPEAKER)) { |
| 2858 | snd_device = SND_DEVICE_OUT_SPEAKER_AND_LINE; |
Naresh Tanniru | e3b1845 | 2014-03-04 14:44:27 +0530 | [diff] [blame] | 2859 | } else if (devices == (AUDIO_DEVICE_OUT_WIRED_HEADSET | |
| 2860 | AUDIO_DEVICE_OUT_SPEAKER)) { |
Naresh Tanniru | db72d1e | 2014-03-05 17:33:47 +0530 | [diff] [blame] | 2861 | if (audio_extn_get_anc_enabled()) |
| 2862 | snd_device = SND_DEVICE_OUT_SPEAKER_AND_ANC_HEADSET; |
Preetam Singh Ranawat | 8bde2c5 | 2015-03-20 12:00:49 +0530 | [diff] [blame] | 2863 | else if (my_data->external_spk_1) |
| 2864 | snd_device = SND_DEVICE_OUT_SPEAKER_AND_HEADPHONES_EXTERNAL_1; |
| 2865 | else if (my_data->external_spk_2) |
| 2866 | snd_device = SND_DEVICE_OUT_SPEAKER_AND_HEADPHONES_EXTERNAL_2; |
Naresh Tanniru | db72d1e | 2014-03-05 17:33:47 +0530 | [diff] [blame] | 2867 | else |
| 2868 | snd_device = SND_DEVICE_OUT_SPEAKER_AND_HEADPHONES; |
Naresh Tanniru | e3b1845 | 2014-03-04 14:44:27 +0530 | [diff] [blame] | 2869 | } else if (devices == (AUDIO_DEVICE_OUT_AUX_DIGITAL | |
| 2870 | AUDIO_DEVICE_OUT_SPEAKER)) { |
| 2871 | snd_device = SND_DEVICE_OUT_SPEAKER_AND_HDMI; |
Naresh Tanniru | db72d1e | 2014-03-05 17:33:47 +0530 | [diff] [blame] | 2872 | } else if (devices == (AUDIO_DEVICE_OUT_ANLG_DOCK_HEADSET | |
| 2873 | AUDIO_DEVICE_OUT_SPEAKER)) { |
| 2874 | snd_device = SND_DEVICE_OUT_SPEAKER_AND_USB_HEADSET; |
Kuirong Wang | a9f7cee | 2016-03-07 11:21:52 -0800 | [diff] [blame] | 2875 | } else if (devices == (AUDIO_DEVICE_OUT_USB_DEVICE | |
| 2876 | AUDIO_DEVICE_OUT_SPEAKER)) { |
| 2877 | snd_device = SND_DEVICE_OUT_SPEAKER_AND_USB_HEADSET; |
Naresh Tanniru | e3b1845 | 2014-03-04 14:44:27 +0530 | [diff] [blame] | 2878 | } else { |
| 2879 | ALOGE("%s: Invalid combo device(%#x)", __func__, devices); |
| 2880 | goto exit; |
| 2881 | } |
| 2882 | if (snd_device != SND_DEVICE_NONE) { |
| 2883 | goto exit; |
| 2884 | } |
| 2885 | } |
| 2886 | |
| 2887 | if (popcount(devices) != 1) { |
| 2888 | ALOGE("%s: Invalid output devices(%#x)", __func__, devices); |
| 2889 | goto exit; |
| 2890 | } |
| 2891 | |
Venkata Narendra Kumar Gutta | bfdfa15 | 2015-06-22 14:25:35 +0530 | [diff] [blame] | 2892 | if ((mode == AUDIO_MODE_IN_CALL) || |
| 2893 | voice_extn_compress_voip_is_active(adev)) { |
Naresh Tanniru | db72d1e | 2014-03-05 17:33:47 +0530 | [diff] [blame] | 2894 | if (devices & AUDIO_DEVICE_OUT_WIRED_HEADPHONE || |
Naresh Tanniru | 9c4ba54 | 2015-11-06 18:01:09 +0530 | [diff] [blame] | 2895 | devices & AUDIO_DEVICE_OUT_WIRED_HEADSET || |
| 2896 | devices & AUDIO_DEVICE_OUT_LINE) { |
Naresh Tanniru | db72d1e | 2014-03-05 17:33:47 +0530 | [diff] [blame] | 2897 | if ((adev->voice.tty_mode != TTY_MODE_OFF) && |
| 2898 | !voice_extn_compress_voip_is_active(adev)) { |
| 2899 | switch (adev->voice.tty_mode) { |
| 2900 | case TTY_MODE_FULL: |
| 2901 | snd_device = SND_DEVICE_OUT_VOICE_TTY_FULL_HEADPHONES; |
| 2902 | break; |
| 2903 | case TTY_MODE_VCO: |
| 2904 | snd_device = SND_DEVICE_OUT_VOICE_TTY_VCO_HEADPHONES; |
| 2905 | break; |
| 2906 | case TTY_MODE_HCO: |
| 2907 | snd_device = SND_DEVICE_OUT_VOICE_TTY_HCO_HANDSET; |
| 2908 | break; |
| 2909 | default: |
| 2910 | ALOGE("%s: Invalid TTY mode (%#x)", |
| 2911 | __func__, adev->voice.tty_mode); |
| 2912 | } |
Naresh Tanniru | 9c4ba54 | 2015-11-06 18:01:09 +0530 | [diff] [blame] | 2913 | } else if (devices & AUDIO_DEVICE_OUT_LINE) { |
| 2914 | snd_device = SND_DEVICE_OUT_VOICE_LINE; |
Naresh Tanniru | db72d1e | 2014-03-05 17:33:47 +0530 | [diff] [blame] | 2915 | } else if (audio_extn_get_anc_enabled()) { |
| 2916 | if (audio_extn_should_use_fb_anc()) |
| 2917 | snd_device = SND_DEVICE_OUT_VOICE_ANC_FB_HEADSET; |
| 2918 | else |
| 2919 | snd_device = SND_DEVICE_OUT_VOICE_ANC_HEADSET; |
| 2920 | } else { |
| 2921 | snd_device = SND_DEVICE_OUT_VOICE_HEADPHONES; |
| 2922 | } |
| 2923 | } else if (devices & AUDIO_DEVICE_OUT_ALL_SCO) { |
Mingming Yin | 514a8bc | 2014-07-29 15:22:21 -0700 | [diff] [blame] | 2924 | if (adev->bt_wb_speech_enabled) |
Naresh Tanniru | db72d1e | 2014-03-05 17:33:47 +0530 | [diff] [blame] | 2925 | snd_device = SND_DEVICE_OUT_BT_SCO_WB; |
| 2926 | else |
| 2927 | snd_device = SND_DEVICE_OUT_BT_SCO; |
| 2928 | } else if (devices & AUDIO_DEVICE_OUT_SPEAKER) { |
Banajit Goswami | 20cdd21 | 2015-09-11 01:11:30 -0700 | [diff] [blame] | 2929 | if (my_data->is_vbat_speaker) |
| 2930 | snd_device = SND_DEVICE_OUT_VOICE_SPEAKER_VBAT; |
| 2931 | else if (my_data->is_wsa_speaker) |
Preetam Singh Ranawat | c7f7f5c | 2015-04-02 12:19:58 +0530 | [diff] [blame] | 2932 | snd_device = SND_DEVICE_OUT_VOICE_SPEAKER_WSA; |
| 2933 | else |
| 2934 | snd_device = SND_DEVICE_OUT_VOICE_SPEAKER; |
Naresh Tanniru | db72d1e | 2014-03-05 17:33:47 +0530 | [diff] [blame] | 2935 | } else if (devices & AUDIO_DEVICE_OUT_ANLG_DOCK_HEADSET || |
| 2936 | devices & AUDIO_DEVICE_OUT_DGTL_DOCK_HEADSET) { |
| 2937 | snd_device = SND_DEVICE_OUT_USB_HEADSET; |
| 2938 | } else if (devices & AUDIO_DEVICE_OUT_FM_TX) { |
| 2939 | snd_device = SND_DEVICE_OUT_TRANSMISSION_FM; |
| 2940 | } else if (devices & AUDIO_DEVICE_OUT_EARPIECE) { |
| 2941 | if (audio_extn_should_use_handset_anc(channel_count)) |
| 2942 | snd_device = SND_DEVICE_OUT_ANC_HANDSET; |
| 2943 | else |
| 2944 | snd_device = SND_DEVICE_OUT_VOICE_HANDSET; |
Preetam Singh Ranawat | 7112f3b | 2015-02-26 16:51:58 +0530 | [diff] [blame] | 2945 | } else if (devices & AUDIO_DEVICE_OUT_TELEPHONY_TX) |
| 2946 | snd_device = SND_DEVICE_OUT_VOICE_TX; |
| 2947 | |
Naresh Tanniru | db72d1e | 2014-03-05 17:33:47 +0530 | [diff] [blame] | 2948 | if (snd_device != SND_DEVICE_NONE) { |
| 2949 | goto exit; |
| 2950 | } |
| 2951 | } |
| 2952 | |
Naresh Tanniru | e3b1845 | 2014-03-04 14:44:27 +0530 | [diff] [blame] | 2953 | if (devices & AUDIO_DEVICE_OUT_WIRED_HEADPHONE || |
| 2954 | devices & AUDIO_DEVICE_OUT_WIRED_HEADSET) { |
Preetam Singh Ranawat | c61f867 | 2015-06-18 23:20:28 +0530 | [diff] [blame] | 2955 | if (OUTPUT_SAMPLING_RATE_44100 == sample_rate && |
Sidipotu Ashok | e6f78cb | 2015-11-05 14:42:20 +0530 | [diff] [blame] | 2956 | NATIVE_AUDIO_MODE_SRC == na_mode && |
Sidipotu Ashok | bffd220 | 2015-08-20 14:06:55 +0530 | [diff] [blame] | 2957 | !audio_extn_get_anc_enabled()) { |
Sidipotu Ashok | e6f78cb | 2015-11-05 14:42:20 +0530 | [diff] [blame] | 2958 | |
Preetam Singh Ranawat | c61f867 | 2015-06-18 23:20:28 +0530 | [diff] [blame] | 2959 | snd_device = SND_DEVICE_OUT_HEADPHONES_44_1; |
Sidipotu Ashok | e6f78cb | 2015-11-05 14:42:20 +0530 | [diff] [blame] | 2960 | |
| 2961 | } else if (devices & AUDIO_DEVICE_OUT_WIRED_HEADSET |
Naresh Tanniru | db72d1e | 2014-03-05 17:33:47 +0530 | [diff] [blame] | 2962 | && audio_extn_get_anc_enabled()) { |
Naresh Tanniru | c0517bc | 2014-10-26 15:30:55 +0530 | [diff] [blame] | 2963 | #ifdef RECORD_PLAY_CONCURRENCY |
| 2964 | if (use_voip_out_devices) { |
| 2965 | // ANC should be disabled for voip concurrency |
| 2966 | snd_device = SND_DEVICE_OUT_VOIP_HEADPHONES; |
| 2967 | } else |
| 2968 | #endif |
| 2969 | { |
| 2970 | if (audio_extn_should_use_fb_anc()) |
| 2971 | snd_device = SND_DEVICE_OUT_ANC_FB_HEADSET; |
| 2972 | else |
| 2973 | snd_device = SND_DEVICE_OUT_ANC_HEADSET; |
| 2974 | } |
| 2975 | } else { |
| 2976 | #ifdef RECORD_PLAY_CONCURRENCY |
| 2977 | if (use_voip_out_devices) |
| 2978 | snd_device = SND_DEVICE_OUT_VOIP_HEADPHONES; |
Naresh Tanniru | db72d1e | 2014-03-05 17:33:47 +0530 | [diff] [blame] | 2979 | else |
Naresh Tanniru | c0517bc | 2014-10-26 15:30:55 +0530 | [diff] [blame] | 2980 | #endif |
| 2981 | snd_device = SND_DEVICE_OUT_HEADPHONES; |
Naresh Tanniru | db72d1e | 2014-03-05 17:33:47 +0530 | [diff] [blame] | 2982 | } |
Naresh Tanniru | 9c4ba54 | 2015-11-06 18:01:09 +0530 | [diff] [blame] | 2983 | } else if (devices & AUDIO_DEVICE_OUT_LINE) { |
| 2984 | snd_device = SND_DEVICE_OUT_LINE; |
Naresh Tanniru | e3b1845 | 2014-03-04 14:44:27 +0530 | [diff] [blame] | 2985 | } else if (devices & AUDIO_DEVICE_OUT_SPEAKER) { |
Naresh Tanniru | c0517bc | 2014-10-26 15:30:55 +0530 | [diff] [blame] | 2986 | #ifdef RECORD_PLAY_CONCURRENCY |
| 2987 | if (use_voip_out_devices) { |
| 2988 | snd_device = SND_DEVICE_OUT_VOIP_SPEAKER; |
| 2989 | } else |
| 2990 | #endif |
| 2991 | { |
| 2992 | if (adev->speaker_lr_swap) |
| 2993 | snd_device = SND_DEVICE_OUT_SPEAKER_REVERSE; |
| 2994 | else |
Preetam Singh Ranawat | c7f7f5c | 2015-04-02 12:19:58 +0530 | [diff] [blame] | 2995 | { |
Banajit Goswami | 20cdd21 | 2015-09-11 01:11:30 -0700 | [diff] [blame] | 2996 | if (my_data->is_vbat_speaker) |
| 2997 | snd_device = SND_DEVICE_OUT_SPEAKER_VBAT; |
| 2998 | else if (my_data->is_wsa_speaker) |
Preetam Singh Ranawat | c7f7f5c | 2015-04-02 12:19:58 +0530 | [diff] [blame] | 2999 | snd_device = SND_DEVICE_OUT_SPEAKER_WSA; |
| 3000 | else |
| 3001 | snd_device = SND_DEVICE_OUT_SPEAKER; |
| 3002 | } |
Naresh Tanniru | c0517bc | 2014-10-26 15:30:55 +0530 | [diff] [blame] | 3003 | } |
Naresh Tanniru | e3b1845 | 2014-03-04 14:44:27 +0530 | [diff] [blame] | 3004 | } else if (devices & AUDIO_DEVICE_OUT_ALL_SCO) { |
Mingming Yin | 514a8bc | 2014-07-29 15:22:21 -0700 | [diff] [blame] | 3005 | if (adev->bt_wb_speech_enabled) |
Naresh Tanniru | db72d1e | 2014-03-05 17:33:47 +0530 | [diff] [blame] | 3006 | snd_device = SND_DEVICE_OUT_BT_SCO_WB; |
| 3007 | else |
| 3008 | snd_device = SND_DEVICE_OUT_BT_SCO; |
Naresh Tanniru | e3b1845 | 2014-03-04 14:44:27 +0530 | [diff] [blame] | 3009 | } else if (devices & AUDIO_DEVICE_OUT_AUX_DIGITAL) { |
| 3010 | snd_device = SND_DEVICE_OUT_HDMI ; |
Naresh Tanniru | db72d1e | 2014-03-05 17:33:47 +0530 | [diff] [blame] | 3011 | } else if (devices & AUDIO_DEVICE_OUT_ANLG_DOCK_HEADSET || |
| 3012 | devices & AUDIO_DEVICE_OUT_DGTL_DOCK_HEADSET) { |
Mingming Yin | 5a7c5d6 | 2014-03-05 17:45:03 -0800 | [diff] [blame] | 3013 | ALOGD("%s: setting USB hadset channel capability(2) for Proxy", __func__); |
| 3014 | audio_extn_set_afe_proxy_channel_mixer(adev, 2); |
Naresh Tanniru | db72d1e | 2014-03-05 17:33:47 +0530 | [diff] [blame] | 3015 | snd_device = SND_DEVICE_OUT_USB_HEADSET; |
Kuirong Wang | a9f7cee | 2016-03-07 11:21:52 -0800 | [diff] [blame] | 3016 | } else if (devices & AUDIO_DEVICE_OUT_USB_DEVICE) { |
| 3017 | snd_device = SND_DEVICE_OUT_USB_HEADSET; |
Naresh Tanniru | db72d1e | 2014-03-05 17:33:47 +0530 | [diff] [blame] | 3018 | } else if (devices & AUDIO_DEVICE_OUT_FM_TX) { |
| 3019 | snd_device = SND_DEVICE_OUT_TRANSMISSION_FM; |
Naresh Tanniru | e3b1845 | 2014-03-04 14:44:27 +0530 | [diff] [blame] | 3020 | } else if (devices & AUDIO_DEVICE_OUT_EARPIECE) { |
Naresh Tanniru | c0517bc | 2014-10-26 15:30:55 +0530 | [diff] [blame] | 3021 | #ifdef RECORD_PLAY_CONCURRENCY |
| 3022 | if (use_voip_out_devices) |
| 3023 | snd_device = SND_DEVICE_OUT_VOIP_HANDSET; |
| 3024 | else |
| 3025 | #endif |
| 3026 | snd_device = SND_DEVICE_OUT_HANDSET; |
Naresh Tanniru | db72d1e | 2014-03-05 17:33:47 +0530 | [diff] [blame] | 3027 | } else if (devices & AUDIO_DEVICE_OUT_PROXY) { |
Mingming Yin | 5a7c5d6 | 2014-03-05 17:45:03 -0800 | [diff] [blame] | 3028 | channel_count = audio_extn_get_afe_proxy_channel_count(); |
| 3029 | ALOGD("%s: setting sink capability(%d) for Proxy", __func__, channel_count); |
| 3030 | audio_extn_set_afe_proxy_channel_mixer(adev, channel_count); |
Naresh Tanniru | db72d1e | 2014-03-05 17:33:47 +0530 | [diff] [blame] | 3031 | snd_device = SND_DEVICE_OUT_AFE_PROXY; |
Naresh Tanniru | e3b1845 | 2014-03-04 14:44:27 +0530 | [diff] [blame] | 3032 | } else { |
| 3033 | ALOGE("%s: Unknown device(s) %#x", __func__, devices); |
| 3034 | } |
| 3035 | exit: |
| 3036 | ALOGV("%s: exit: snd_device(%s)", __func__, device_table[snd_device]); |
| 3037 | return snd_device; |
| 3038 | } |
| 3039 | |
| 3040 | snd_device_t platform_get_input_snd_device(void *platform, audio_devices_t out_device) |
| 3041 | { |
| 3042 | struct platform_data *my_data = (struct platform_data *)platform; |
| 3043 | struct audio_device *adev = my_data->adev; |
| 3044 | audio_source_t source = (adev->active_input == NULL) ? |
| 3045 | AUDIO_SOURCE_DEFAULT : adev->active_input->source; |
| 3046 | |
| 3047 | audio_mode_t mode = adev->mode; |
| 3048 | audio_devices_t in_device = ((adev->active_input == NULL) ? |
| 3049 | AUDIO_DEVICE_NONE : adev->active_input->device) |
| 3050 | & ~AUDIO_DEVICE_BIT_IN; |
| 3051 | audio_channel_mask_t channel_mask = (adev->active_input == NULL) ? |
| 3052 | AUDIO_CHANNEL_IN_MONO : adev->active_input->channel_mask; |
| 3053 | snd_device_t snd_device = SND_DEVICE_NONE; |
Naresh Tanniru | db72d1e | 2014-03-05 17:33:47 +0530 | [diff] [blame] | 3054 | int channel_count = popcount(channel_mask); |
Naresh Tanniru | e3b1845 | 2014-03-04 14:44:27 +0530 | [diff] [blame] | 3055 | |
Chaithanya Krishna Bacharaju | 9955b16 | 2016-05-25 16:25:53 +0530 | [diff] [blame] | 3056 | ALOGV("%s: enter: out_device(%#x) in_device(%#x) channel_count (%d) channel_mask (0x%x)", |
| 3057 | __func__, out_device, in_device, channel_count, channel_mask); |
Preetam Singh Ranawat | 8bde2c5 | 2015-03-20 12:00:49 +0530 | [diff] [blame] | 3058 | if (my_data->external_mic) { |
Venkata Narendra Kumar Gutta | bfdfa15 | 2015-06-22 14:25:35 +0530 | [diff] [blame] | 3059 | if ((out_device != AUDIO_DEVICE_NONE) && ((mode == AUDIO_MODE_IN_CALL) || |
| 3060 | voice_extn_compress_voip_is_active(adev) || audio_extn_hfp_is_active(adev))) { |
Preetam Singh Ranawat | 8bde2c5 | 2015-03-20 12:00:49 +0530 | [diff] [blame] | 3061 | if (out_device & AUDIO_DEVICE_OUT_WIRED_HEADPHONE || |
| 3062 | out_device & AUDIO_DEVICE_OUT_EARPIECE || |
| 3063 | out_device & AUDIO_DEVICE_OUT_SPEAKER ) |
| 3064 | snd_device = SND_DEVICE_IN_HANDSET_MIC_EXTERNAL; |
| 3065 | } else if (in_device & AUDIO_DEVICE_IN_BUILTIN_MIC || |
| 3066 | in_device & AUDIO_DEVICE_IN_BACK_MIC) { |
| 3067 | snd_device = SND_DEVICE_IN_HANDSET_MIC_EXTERNAL; |
| 3068 | } |
| 3069 | } |
| 3070 | |
| 3071 | if (snd_device != AUDIO_DEVICE_NONE) |
| 3072 | goto exit; |
| 3073 | |
Venkata Narendra Kumar Gutta | bfdfa15 | 2015-06-22 14:25:35 +0530 | [diff] [blame] | 3074 | if ((out_device != AUDIO_DEVICE_NONE) && ((mode == AUDIO_MODE_IN_CALL) || |
Satya Krishna Pindiproli | 2aaa615 | 2014-05-21 15:05:22 +0530 | [diff] [blame] | 3075 | voice_extn_compress_voip_is_active(adev) || audio_extn_hfp_is_active(adev))) { |
Naresh Tanniru | db72d1e | 2014-03-05 17:33:47 +0530 | [diff] [blame] | 3076 | if ((adev->voice.tty_mode != TTY_MODE_OFF) && |
| 3077 | !voice_extn_compress_voip_is_active(adev)) { |
Naresh Tanniru | e3b1845 | 2014-03-04 14:44:27 +0530 | [diff] [blame] | 3078 | if (out_device & AUDIO_DEVICE_OUT_WIRED_HEADPHONE || |
Naresh Tanniru | 9c4ba54 | 2015-11-06 18:01:09 +0530 | [diff] [blame] | 3079 | out_device & AUDIO_DEVICE_OUT_WIRED_HEADSET || |
| 3080 | out_device & AUDIO_DEVICE_OUT_LINE) { |
Naresh Tanniru | db72d1e | 2014-03-05 17:33:47 +0530 | [diff] [blame] | 3081 | switch (adev->voice.tty_mode) { |
Naresh Tanniru | e3b1845 | 2014-03-04 14:44:27 +0530 | [diff] [blame] | 3082 | case TTY_MODE_FULL: |
| 3083 | snd_device = SND_DEVICE_IN_VOICE_TTY_FULL_HEADSET_MIC; |
| 3084 | break; |
| 3085 | case TTY_MODE_VCO: |
| 3086 | snd_device = SND_DEVICE_IN_VOICE_TTY_VCO_HANDSET_MIC; |
| 3087 | break; |
| 3088 | case TTY_MODE_HCO: |
| 3089 | snd_device = SND_DEVICE_IN_VOICE_TTY_HCO_HEADSET_MIC; |
| 3090 | break; |
| 3091 | default: |
Naresh Tanniru | db72d1e | 2014-03-05 17:33:47 +0530 | [diff] [blame] | 3092 | ALOGE("%s: Invalid TTY mode (%#x)", |
| 3093 | __func__, adev->voice.tty_mode); |
Naresh Tanniru | e3b1845 | 2014-03-04 14:44:27 +0530 | [diff] [blame] | 3094 | } |
| 3095 | goto exit; |
| 3096 | } |
| 3097 | } |
| 3098 | if (out_device & AUDIO_DEVICE_OUT_EARPIECE || |
Naresh Tanniru | 9c4ba54 | 2015-11-06 18:01:09 +0530 | [diff] [blame] | 3099 | out_device & AUDIO_DEVICE_OUT_WIRED_HEADPHONE || |
| 3100 | out_device & AUDIO_DEVICE_OUT_LINE) { |
Naresh Tanniru | db72d1e | 2014-03-05 17:33:47 +0530 | [diff] [blame] | 3101 | if (out_device & AUDIO_DEVICE_OUT_EARPIECE && |
Sidipotu Ashok | 3bcca23 | 2014-11-07 14:41:58 +0530 | [diff] [blame] | 3102 | audio_extn_should_use_handset_anc(channel_count) && |
Chaithanya Krishna Bacharaju | 9955b16 | 2016-05-25 16:25:53 +0530 | [diff] [blame] | 3103 | my_data->fluence_type != FLUENCE_NONE && |
| 3104 | my_data->source_mic_type & SOURCE_DUAL_MIC) { |
Sidipotu Ashok | 3bcca23 | 2014-11-07 14:41:58 +0530 | [diff] [blame] | 3105 | snd_device = SND_DEVICE_IN_VOICE_FLUENCE_DMIC_AANC; |
| 3106 | adev->acdb_settings |= DMIC_FLAG; |
| 3107 | ALOGD("Selecting AANC, Fluence combo device"); |
| 3108 | } else if (out_device & AUDIO_DEVICE_OUT_EARPIECE && |
Naresh Tanniru | db72d1e | 2014-03-05 17:33:47 +0530 | [diff] [blame] | 3109 | audio_extn_should_use_handset_anc(channel_count)) { |
| 3110 | snd_device = SND_DEVICE_IN_AANC_HANDSET_MIC; |
Preetam Singh Ranawat | 8bde2c5 | 2015-03-20 12:00:49 +0530 | [diff] [blame] | 3111 | adev->acdb_settings |= ANC_FLAG; |
Naresh Tanniru | db72d1e | 2014-03-05 17:33:47 +0530 | [diff] [blame] | 3112 | } else if (my_data->fluence_type == FLUENCE_NONE || |
| 3113 | my_data->fluence_in_voice_call == false) { |
Naresh Tanniru | e3b1845 | 2014-03-04 14:44:27 +0530 | [diff] [blame] | 3114 | snd_device = SND_DEVICE_IN_HANDSET_MIC; |
Venkata Narendra Kumar Gutta | 1bbbf54 | 2014-09-04 19:11:25 +0530 | [diff] [blame] | 3115 | if (audio_extn_hfp_is_active(adev)) |
Apoorv Raghuvanshi | 924b302 | 2015-07-06 15:07:14 -0700 | [diff] [blame] | 3116 | platform_set_echo_reference(adev, true, out_device); |
Naresh Tanniru | e3b1845 | 2014-03-04 14:44:27 +0530 | [diff] [blame] | 3117 | } else { |
Naresh Tanniru | db72d1e | 2014-03-05 17:33:47 +0530 | [diff] [blame] | 3118 | snd_device = SND_DEVICE_IN_VOICE_DMIC; |
| 3119 | adev->acdb_settings |= DMIC_FLAG; |
Naresh Tanniru | e3b1845 | 2014-03-04 14:44:27 +0530 | [diff] [blame] | 3120 | } |
| 3121 | } else if (out_device & AUDIO_DEVICE_OUT_WIRED_HEADSET) { |
| 3122 | snd_device = SND_DEVICE_IN_VOICE_HEADSET_MIC; |
Preetam Singh Ranawat | 8bde2c5 | 2015-03-20 12:00:49 +0530 | [diff] [blame] | 3123 | if (audio_extn_hfp_is_active(adev)) |
Apoorv Raghuvanshi | 924b302 | 2015-07-06 15:07:14 -0700 | [diff] [blame] | 3124 | platform_set_echo_reference(adev, true, out_device); |
Naresh Tanniru | e3b1845 | 2014-03-04 14:44:27 +0530 | [diff] [blame] | 3125 | } else if (out_device & AUDIO_DEVICE_OUT_ALL_SCO) { |
Vicky Sehrawat | e240e5d | 2014-08-12 17:17:04 -0700 | [diff] [blame] | 3126 | if (adev->bt_wb_speech_enabled) { |
| 3127 | if (adev->bluetooth_nrec) |
| 3128 | snd_device = SND_DEVICE_IN_BT_SCO_MIC_WB_NREC; |
| 3129 | else |
| 3130 | snd_device = SND_DEVICE_IN_BT_SCO_MIC_WB; |
| 3131 | } else { |
| 3132 | if (adev->bluetooth_nrec) |
| 3133 | snd_device = SND_DEVICE_IN_BT_SCO_MIC_NREC; |
| 3134 | else |
| 3135 | snd_device = SND_DEVICE_IN_BT_SCO_MIC; |
| 3136 | } |
Naresh Tanniru | e3b1845 | 2014-03-04 14:44:27 +0530 | [diff] [blame] | 3137 | } else if (out_device & AUDIO_DEVICE_OUT_SPEAKER) { |
Naresh Tanniru | db72d1e | 2014-03-05 17:33:47 +0530 | [diff] [blame] | 3138 | if (my_data->fluence_type != FLUENCE_NONE && |
| 3139 | my_data->fluence_in_voice_call && |
| 3140 | my_data->fluence_in_spkr_mode) { |
Chaithanya Krishna Bacharaju | 9955b16 | 2016-05-25 16:25:53 +0530 | [diff] [blame] | 3141 | if((my_data->fluence_type & FLUENCE_QUAD_MIC) && |
| 3142 | (my_data->source_mic_type & SOURCE_QUAD_MIC)) { |
Naresh Tanniru | db72d1e | 2014-03-05 17:33:47 +0530 | [diff] [blame] | 3143 | adev->acdb_settings |= QMIC_FLAG; |
| 3144 | snd_device = SND_DEVICE_IN_VOICE_SPEAKER_QMIC; |
| 3145 | } else { |
| 3146 | adev->acdb_settings |= DMIC_FLAG; |
Karthik Reddy Katta | d9fff86 | 2014-07-21 21:07:21 +0530 | [diff] [blame] | 3147 | if (my_data->fluence_mode == FLUENCE_BROADSIDE) |
| 3148 | snd_device = SND_DEVICE_IN_VOICE_SPEAKER_DMIC_BROADSIDE; |
| 3149 | else |
| 3150 | snd_device = SND_DEVICE_IN_VOICE_SPEAKER_DMIC; |
Naresh Tanniru | db72d1e | 2014-03-05 17:33:47 +0530 | [diff] [blame] | 3151 | } |
Naresh Tanniru | e3b1845 | 2014-03-04 14:44:27 +0530 | [diff] [blame] | 3152 | } else { |
| 3153 | snd_device = SND_DEVICE_IN_VOICE_SPEAKER_MIC; |
Venkata Narendra Kumar Gutta | 1bbbf54 | 2014-09-04 19:11:25 +0530 | [diff] [blame] | 3154 | if (audio_extn_hfp_is_active(adev)) |
Apoorv Raghuvanshi | 924b302 | 2015-07-06 15:07:14 -0700 | [diff] [blame] | 3155 | platform_set_echo_reference(adev, true, out_device); |
Naresh Tanniru | e3b1845 | 2014-03-04 14:44:27 +0530 | [diff] [blame] | 3156 | } |
Preetam Singh Ranawat | 7112f3b | 2015-02-26 16:51:58 +0530 | [diff] [blame] | 3157 | } else if (out_device & AUDIO_DEVICE_OUT_TELEPHONY_TX) |
| 3158 | snd_device = SND_DEVICE_IN_VOICE_RX; |
Naresh Tanniru | e3b1845 | 2014-03-04 14:44:27 +0530 | [diff] [blame] | 3159 | } else if (source == AUDIO_SOURCE_CAMCORDER) { |
| 3160 | if (in_device & AUDIO_DEVICE_IN_BUILTIN_MIC || |
| 3161 | in_device & AUDIO_DEVICE_IN_BACK_MIC) { |
Chaithanya Krishna Bacharaju | 9955b16 | 2016-05-25 16:25:53 +0530 | [diff] [blame] | 3162 | if ((my_data->fluence_type & FLUENCE_DUAL_MIC) && |
| 3163 | (my_data->source_mic_type & SOURCE_DUAL_MIC) && |
| 3164 | (channel_count == 2)) |
kunleiz | 8f7e9e2 | 2014-06-24 15:12:02 +0800 | [diff] [blame] | 3165 | snd_device = SND_DEVICE_IN_HANDSET_STEREO_DMIC; |
kunleiz | 18a3330 | 2014-05-30 09:52:25 +0800 | [diff] [blame] | 3166 | else |
| 3167 | snd_device = SND_DEVICE_IN_CAMCORDER_MIC; |
Naresh Tanniru | e3b1845 | 2014-03-04 14:44:27 +0530 | [diff] [blame] | 3168 | } |
| 3169 | } else if (source == AUDIO_SOURCE_VOICE_RECOGNITION) { |
| 3170 | if (in_device & AUDIO_DEVICE_IN_BUILTIN_MIC) { |
Chaithanya Krishna Bacharaju | 9955b16 | 2016-05-25 16:25:53 +0530 | [diff] [blame] | 3171 | if (my_data->fluence_in_voice_rec && channel_count == 1) { |
| 3172 | if ((my_data->fluence_type & FLUENCE_QUAD_MIC) && |
| 3173 | (my_data->source_mic_type & SOURCE_QUAD_MIC)) { |
| 3174 | snd_device = SND_DEVICE_IN_HANDSET_QMIC; |
| 3175 | } else if ((my_data->fluence_type & FLUENCE_QUAD_MIC) && |
| 3176 | (my_data->source_mic_type & SOURCE_THREE_MIC)) { |
| 3177 | snd_device = SND_DEVICE_IN_HANDSET_TMIC; |
| 3178 | } else if ((my_data->fluence_type & FLUENCE_DUAL_MIC) && |
| 3179 | (my_data->source_mic_type & SOURCE_DUAL_MIC)) { |
| 3180 | snd_device = SND_DEVICE_IN_VOICE_REC_DMIC_FLUENCE; |
| 3181 | } |
| 3182 | platform_set_echo_reference(adev, true, out_device); |
| 3183 | } else if (((channel_mask == AUDIO_CHANNEL_IN_FRONT_BACK) || |
| 3184 | (channel_mask == AUDIO_CHANNEL_IN_STEREO)) && |
| 3185 | (my_data->source_mic_type & SOURCE_DUAL_MIC)) { |
Naresh Tanniru | db72d1e | 2014-03-05 17:33:47 +0530 | [diff] [blame] | 3186 | snd_device = SND_DEVICE_IN_VOICE_REC_DMIC_STEREO; |
Chaithanya Krishna Bacharaju | 9955b16 | 2016-05-25 16:25:53 +0530 | [diff] [blame] | 3187 | } else if (((int)channel_mask == AUDIO_CHANNEL_INDEX_MASK_3) && |
| 3188 | (my_data->source_mic_type & SOURCE_THREE_MIC)) { |
| 3189 | snd_device = SND_DEVICE_IN_THREE_MIC; |
| 3190 | } else if (((int)channel_mask == AUDIO_CHANNEL_INDEX_MASK_4) && |
| 3191 | (my_data->source_mic_type & SOURCE_QUAD_MIC)) { |
| 3192 | snd_device = SND_DEVICE_IN_QUAD_MIC; |
Naresh Tanniru | e3b1845 | 2014-03-04 14:44:27 +0530 | [diff] [blame] | 3193 | } |
Chaithanya Krishna Bacharaju | 9955b16 | 2016-05-25 16:25:53 +0530 | [diff] [blame] | 3194 | if (snd_device == SND_DEVICE_NONE) { |
| 3195 | if (adev->active_input->enable_ns) |
| 3196 | snd_device = SND_DEVICE_IN_VOICE_REC_MIC_NS; |
| 3197 | else |
| 3198 | snd_device = SND_DEVICE_IN_VOICE_REC_MIC; |
| 3199 | } |
| 3200 | } |
Chaithanya Krishna Bacharaju | 24f86f3 | 2016-05-26 16:34:53 +0530 | [diff] [blame] | 3201 | } else if (source == AUDIO_SOURCE_UNPROCESSED) { |
| 3202 | if (in_device & AUDIO_DEVICE_IN_BUILTIN_MIC) { |
| 3203 | if (((channel_mask == AUDIO_CHANNEL_IN_FRONT_BACK) || |
| 3204 | (channel_mask == AUDIO_CHANNEL_IN_STEREO)) && |
| 3205 | (my_data->source_mic_type & SOURCE_DUAL_MIC)) { |
| 3206 | snd_device = SND_DEVICE_IN_UNPROCESSED_STEREO_MIC; |
| 3207 | } else if (((int)channel_mask == AUDIO_CHANNEL_INDEX_MASK_3) && |
| 3208 | (my_data->source_mic_type & SOURCE_THREE_MIC)) { |
| 3209 | snd_device = SND_DEVICE_IN_UNPROCESSED_THREE_MIC; |
| 3210 | } else if (((int)channel_mask == AUDIO_CHANNEL_INDEX_MASK_4) && |
| 3211 | (my_data->source_mic_type & SOURCE_QUAD_MIC)) { |
| 3212 | snd_device = SND_DEVICE_IN_UNPROCESSED_QUAD_MIC; |
| 3213 | } else { |
| 3214 | snd_device = SND_DEVICE_IN_UNPROCESSED_MIC; |
| 3215 | } |
| 3216 | } else if (in_device & AUDIO_DEVICE_IN_WIRED_HEADSET) { |
| 3217 | snd_device = SND_DEVICE_IN_UNPROCESSED_HEADSET_MIC; |
| 3218 | } |
Karthik Reddy Katta | f621ec7 | 2014-11-21 16:37:38 +0530 | [diff] [blame] | 3219 | } else if ((source == AUDIO_SOURCE_VOICE_COMMUNICATION) || |
| 3220 | (mode == AUDIO_MODE_IN_COMMUNICATION)) { |
Naresh Tanniru | e3b1845 | 2014-03-04 14:44:27 +0530 | [diff] [blame] | 3221 | if (out_device & AUDIO_DEVICE_OUT_SPEAKER) |
| 3222 | in_device = AUDIO_DEVICE_IN_BACK_MIC; |
| 3223 | if (adev->active_input) { |
Venkata Narendra Kumar Gutta | 35b5cc5 | 2015-05-25 15:32:03 +0530 | [diff] [blame] | 3224 | if (my_data->fluence_type != FLUENCE_NONE && |
| 3225 | adev->active_input->enable_aec && |
| 3226 | adev->active_input->enable_ns) { |
Naresh Tanniru | e3b1845 | 2014-03-04 14:44:27 +0530 | [diff] [blame] | 3227 | if (in_device & AUDIO_DEVICE_IN_BACK_MIC) { |
Karthik Reddy Katta | d71b94b | 2015-01-19 14:06:53 +0530 | [diff] [blame] | 3228 | if (my_data->fluence_in_spkr_mode) { |
Chaithanya Krishna Bacharaju | 9955b16 | 2016-05-25 16:25:53 +0530 | [diff] [blame] | 3229 | if ((my_data->fluence_type & FLUENCE_QUAD_MIC) && |
| 3230 | (my_data->source_mic_type & SOURCE_QUAD_MIC)) { |
Karthik Reddy Katta | d71b94b | 2015-01-19 14:06:53 +0530 | [diff] [blame] | 3231 | snd_device = SND_DEVICE_IN_SPEAKER_QMIC_AEC_NS; |
Chaithanya Krishna Bacharaju | 9955b16 | 2016-05-25 16:25:53 +0530 | [diff] [blame] | 3232 | } else if ((my_data->fluence_type & FLUENCE_DUAL_MIC) && |
| 3233 | (my_data->source_mic_type & SOURCE_DUAL_MIC)) { |
Karthik Reddy Katta | d71b94b | 2015-01-19 14:06:53 +0530 | [diff] [blame] | 3234 | if (my_data->fluence_mode == FLUENCE_BROADSIDE) |
| 3235 | snd_device = SND_DEVICE_IN_SPEAKER_DMIC_AEC_NS_BROADSIDE; |
| 3236 | else |
| 3237 | snd_device = SND_DEVICE_IN_SPEAKER_DMIC_AEC_NS; |
| 3238 | } |
Naresh Tanniru | db72d1e | 2014-03-05 17:33:47 +0530 | [diff] [blame] | 3239 | adev->acdb_settings |= DMIC_FLAG; |
| 3240 | } else |
| 3241 | snd_device = SND_DEVICE_IN_SPEAKER_MIC_AEC_NS; |
Naresh Tanniru | e3b1845 | 2014-03-04 14:44:27 +0530 | [diff] [blame] | 3242 | } else if (in_device & AUDIO_DEVICE_IN_BUILTIN_MIC) { |
Chaithanya Krishna Bacharaju | 9955b16 | 2016-05-25 16:25:53 +0530 | [diff] [blame] | 3243 | if ((my_data->fluence_type & FLUENCE_DUAL_MIC) && |
| 3244 | (my_data->source_mic_type & SOURCE_DUAL_MIC)) { |
Naresh Tanniru | db72d1e | 2014-03-05 17:33:47 +0530 | [diff] [blame] | 3245 | snd_device = SND_DEVICE_IN_HANDSET_DMIC_AEC_NS; |
| 3246 | adev->acdb_settings |= DMIC_FLAG; |
| 3247 | } else |
| 3248 | snd_device = SND_DEVICE_IN_HANDSET_MIC_AEC_NS; |
Naresh Tanniru | e3b1845 | 2014-03-04 14:44:27 +0530 | [diff] [blame] | 3249 | } else if (in_device & AUDIO_DEVICE_IN_WIRED_HEADSET) { |
Naresh Tanniru | db72d1e | 2014-03-05 17:33:47 +0530 | [diff] [blame] | 3250 | snd_device = SND_DEVICE_IN_HEADSET_MIC_FLUENCE; |
Naresh Tanniru | e3b1845 | 2014-03-04 14:44:27 +0530 | [diff] [blame] | 3251 | } |
Apoorv Raghuvanshi | 924b302 | 2015-07-06 15:07:14 -0700 | [diff] [blame] | 3252 | platform_set_echo_reference(adev, true, out_device); |
Venkata Narendra Kumar Gutta | 35b5cc5 | 2015-05-25 15:32:03 +0530 | [diff] [blame] | 3253 | } else if (my_data->fluence_type != FLUENCE_NONE && |
| 3254 | adev->active_input->enable_aec) { |
Naresh Tanniru | db72d1e | 2014-03-05 17:33:47 +0530 | [diff] [blame] | 3255 | if (in_device & AUDIO_DEVICE_IN_BACK_MIC) { |
Karthik Reddy Katta | d71b94b | 2015-01-19 14:06:53 +0530 | [diff] [blame] | 3256 | if (my_data->fluence_in_spkr_mode) { |
Chaithanya Krishna Bacharaju | 9955b16 | 2016-05-25 16:25:53 +0530 | [diff] [blame] | 3257 | if ((my_data->fluence_type & FLUENCE_QUAD_MIC) && |
| 3258 | (my_data->source_mic_type & SOURCE_QUAD_MIC)) { |
Karthik Reddy Katta | d71b94b | 2015-01-19 14:06:53 +0530 | [diff] [blame] | 3259 | snd_device = SND_DEVICE_IN_SPEAKER_QMIC_AEC; |
Chaithanya Krishna Bacharaju | 9955b16 | 2016-05-25 16:25:53 +0530 | [diff] [blame] | 3260 | } else if ((my_data->fluence_type & FLUENCE_DUAL_MIC) && |
| 3261 | (my_data->source_mic_type & SOURCE_DUAL_MIC)) { |
Karthik Reddy Katta | d71b94b | 2015-01-19 14:06:53 +0530 | [diff] [blame] | 3262 | if (my_data->fluence_mode == FLUENCE_BROADSIDE) |
| 3263 | snd_device = SND_DEVICE_IN_SPEAKER_DMIC_AEC_BROADSIDE; |
| 3264 | else |
| 3265 | snd_device = SND_DEVICE_IN_SPEAKER_DMIC_AEC; |
| 3266 | } |
Naresh Tanniru | db72d1e | 2014-03-05 17:33:47 +0530 | [diff] [blame] | 3267 | adev->acdb_settings |= DMIC_FLAG; |
| 3268 | } else |
| 3269 | snd_device = SND_DEVICE_IN_SPEAKER_MIC_AEC; |
| 3270 | } else if (in_device & AUDIO_DEVICE_IN_BUILTIN_MIC) { |
Chaithanya Krishna Bacharaju | 9955b16 | 2016-05-25 16:25:53 +0530 | [diff] [blame] | 3271 | if ((my_data->fluence_type & FLUENCE_DUAL_MIC) && |
| 3272 | (my_data->source_mic_type & SOURCE_DUAL_MIC)) { |
Naresh Tanniru | db72d1e | 2014-03-05 17:33:47 +0530 | [diff] [blame] | 3273 | snd_device = SND_DEVICE_IN_HANDSET_DMIC_AEC; |
| 3274 | adev->acdb_settings |= DMIC_FLAG; |
| 3275 | } else |
| 3276 | snd_device = SND_DEVICE_IN_HANDSET_MIC_AEC; |
| 3277 | } else if (in_device & AUDIO_DEVICE_IN_WIRED_HEADSET) { |
| 3278 | snd_device = SND_DEVICE_IN_HEADSET_MIC_FLUENCE; |
| 3279 | } |
Apoorv Raghuvanshi | 924b302 | 2015-07-06 15:07:14 -0700 | [diff] [blame] | 3280 | platform_set_echo_reference(adev, true, out_device); |
Venkata Narendra Kumar Gutta | 35b5cc5 | 2015-05-25 15:32:03 +0530 | [diff] [blame] | 3281 | } else if (my_data->fluence_type != FLUENCE_NONE && |
| 3282 | adev->active_input->enable_ns) { |
Naresh Tanniru | db72d1e | 2014-03-05 17:33:47 +0530 | [diff] [blame] | 3283 | if (in_device & AUDIO_DEVICE_IN_BACK_MIC) { |
Karthik Reddy Katta | d71b94b | 2015-01-19 14:06:53 +0530 | [diff] [blame] | 3284 | if (my_data->fluence_in_spkr_mode) { |
Chaithanya Krishna Bacharaju | 9955b16 | 2016-05-25 16:25:53 +0530 | [diff] [blame] | 3285 | if ((my_data->fluence_type & FLUENCE_QUAD_MIC) && |
| 3286 | (my_data->source_mic_type & SOURCE_QUAD_MIC)) { |
Karthik Reddy Katta | d71b94b | 2015-01-19 14:06:53 +0530 | [diff] [blame] | 3287 | snd_device = SND_DEVICE_IN_SPEAKER_QMIC_NS; |
Chaithanya Krishna Bacharaju | 9955b16 | 2016-05-25 16:25:53 +0530 | [diff] [blame] | 3288 | } else if ((my_data->fluence_type & FLUENCE_DUAL_MIC) && |
| 3289 | (my_data->source_mic_type & SOURCE_DUAL_MIC)) { |
Karthik Reddy Katta | d71b94b | 2015-01-19 14:06:53 +0530 | [diff] [blame] | 3290 | if (my_data->fluence_mode == FLUENCE_BROADSIDE) |
| 3291 | snd_device = SND_DEVICE_IN_SPEAKER_DMIC_NS_BROADSIDE; |
| 3292 | else |
| 3293 | snd_device = SND_DEVICE_IN_SPEAKER_DMIC_NS; |
| 3294 | } |
Naresh Tanniru | db72d1e | 2014-03-05 17:33:47 +0530 | [diff] [blame] | 3295 | adev->acdb_settings |= DMIC_FLAG; |
| 3296 | } else |
| 3297 | snd_device = SND_DEVICE_IN_SPEAKER_MIC_NS; |
| 3298 | } else if (in_device & AUDIO_DEVICE_IN_BUILTIN_MIC) { |
Chaithanya Krishna Bacharaju | 9955b16 | 2016-05-25 16:25:53 +0530 | [diff] [blame] | 3299 | if ((my_data->fluence_type & FLUENCE_DUAL_MIC) && |
| 3300 | (my_data->source_mic_type & SOURCE_DUAL_MIC)) { |
Naresh Tanniru | db72d1e | 2014-03-05 17:33:47 +0530 | [diff] [blame] | 3301 | snd_device = SND_DEVICE_IN_HANDSET_DMIC_NS; |
| 3302 | adev->acdb_settings |= DMIC_FLAG; |
| 3303 | } else |
| 3304 | snd_device = SND_DEVICE_IN_HANDSET_MIC_NS; |
| 3305 | } else if (in_device & AUDIO_DEVICE_IN_WIRED_HEADSET) { |
| 3306 | snd_device = SND_DEVICE_IN_HEADSET_MIC_FLUENCE; |
| 3307 | } |
Apoorv Raghuvanshi | 924b302 | 2015-07-06 15:07:14 -0700 | [diff] [blame] | 3308 | platform_set_echo_reference(adev, false, out_device); |
Naresh Tanniru | e3b1845 | 2014-03-04 14:44:27 +0530 | [diff] [blame] | 3309 | } else |
Apoorv Raghuvanshi | 924b302 | 2015-07-06 15:07:14 -0700 | [diff] [blame] | 3310 | platform_set_echo_reference(adev, false, out_device); |
Naresh Tanniru | e3b1845 | 2014-03-04 14:44:27 +0530 | [diff] [blame] | 3311 | } |
Naresh Tanniru | db72d1e | 2014-03-05 17:33:47 +0530 | [diff] [blame] | 3312 | } else if (source == AUDIO_SOURCE_MIC) { |
| 3313 | if (in_device & AUDIO_DEVICE_IN_BUILTIN_MIC && |
| 3314 | channel_count == 1 ) { |
Karthik Reddy Katta | d71b94b | 2015-01-19 14:06:53 +0530 | [diff] [blame] | 3315 | if(my_data->fluence_in_audio_rec) { |
Chaithanya Krishna Bacharaju | 9955b16 | 2016-05-25 16:25:53 +0530 | [diff] [blame] | 3316 | if ((my_data->fluence_type & FLUENCE_QUAD_MIC) && |
| 3317 | (my_data->source_mic_type & SOURCE_QUAD_MIC)) { |
Karthik Reddy Katta | d71b94b | 2015-01-19 14:06:53 +0530 | [diff] [blame] | 3318 | snd_device = SND_DEVICE_IN_HANDSET_QMIC; |
Apoorv Raghuvanshi | 924b302 | 2015-07-06 15:07:14 -0700 | [diff] [blame] | 3319 | platform_set_echo_reference(adev, true, out_device); |
Chaithanya Krishna Bacharaju | 9955b16 | 2016-05-25 16:25:53 +0530 | [diff] [blame] | 3320 | } else if ((my_data->fluence_type & FLUENCE_QUAD_MIC) && |
| 3321 | (my_data->source_mic_type & SOURCE_THREE_MIC)) { |
| 3322 | snd_device = SND_DEVICE_IN_HANDSET_TMIC; |
| 3323 | } else if ((my_data->fluence_type & FLUENCE_DUAL_MIC) && |
| 3324 | (my_data->source_mic_type & SOURCE_DUAL_MIC)) { |
Karthik Reddy Katta | d71b94b | 2015-01-19 14:06:53 +0530 | [diff] [blame] | 3325 | snd_device = SND_DEVICE_IN_HANDSET_DMIC; |
Apoorv Raghuvanshi | 924b302 | 2015-07-06 15:07:14 -0700 | [diff] [blame] | 3326 | platform_set_echo_reference(adev, true, out_device); |
Karthik Reddy Katta | d71b94b | 2015-01-19 14:06:53 +0530 | [diff] [blame] | 3327 | } |
| 3328 | } |
Naresh Tanniru | db72d1e | 2014-03-05 17:33:47 +0530 | [diff] [blame] | 3329 | } |
Mingming Yin | 12125e8 | 2015-10-26 20:40:36 -0700 | [diff] [blame] | 3330 | } else if (source == AUDIO_SOURCE_FM_TUNER) { |
Naresh Tanniru | db72d1e | 2014-03-05 17:33:47 +0530 | [diff] [blame] | 3331 | snd_device = SND_DEVICE_IN_CAPTURE_FM; |
Naresh Tanniru | e3b1845 | 2014-03-04 14:44:27 +0530 | [diff] [blame] | 3332 | } else if (source == AUDIO_SOURCE_DEFAULT) { |
| 3333 | goto exit; |
| 3334 | } |
| 3335 | |
Shiv Maliyappanahalli | 5a10aea | 2015-07-02 10:36:23 -0700 | [diff] [blame] | 3336 | if (adev->active_input && (audio_extn_ssr_get_stream() == adev->active_input)) |
| 3337 | snd_device = SND_DEVICE_IN_THREE_MIC; |
Naresh Tanniru | e3b1845 | 2014-03-04 14:44:27 +0530 | [diff] [blame] | 3338 | |
| 3339 | if (snd_device != SND_DEVICE_NONE) { |
| 3340 | goto exit; |
| 3341 | } |
| 3342 | |
| 3343 | if (in_device != AUDIO_DEVICE_NONE && |
| 3344 | !(in_device & AUDIO_DEVICE_IN_VOICE_CALL) && |
| 3345 | !(in_device & AUDIO_DEVICE_IN_COMMUNICATION)) { |
| 3346 | if (in_device & AUDIO_DEVICE_IN_BUILTIN_MIC) { |
Shiv Maliyappanahalli | 5a10aea | 2015-07-02 10:36:23 -0700 | [diff] [blame] | 3347 | if (adev->active_input && (audio_extn_ssr_get_stream() == adev->active_input)) |
Naresh Tanniru | db72d1e | 2014-03-05 17:33:47 +0530 | [diff] [blame] | 3348 | snd_device = SND_DEVICE_IN_QUAD_MIC; |
Chaithanya Krishna Bacharaju | 9955b16 | 2016-05-25 16:25:53 +0530 | [diff] [blame] | 3349 | else if ((my_data->fluence_type & (FLUENCE_DUAL_MIC | FLUENCE_QUAD_MIC)) && |
| 3350 | (channel_count == 2) && (my_data->source_mic_type & SOURCE_DUAL_MIC)) |
Naresh Tanniru | db72d1e | 2014-03-05 17:33:47 +0530 | [diff] [blame] | 3351 | snd_device = SND_DEVICE_IN_HANDSET_STEREO_DMIC; |
| 3352 | else |
| 3353 | snd_device = SND_DEVICE_IN_HANDSET_MIC; |
Naresh Tanniru | e3b1845 | 2014-03-04 14:44:27 +0530 | [diff] [blame] | 3354 | } else if (in_device & AUDIO_DEVICE_IN_BACK_MIC) { |
| 3355 | snd_device = SND_DEVICE_IN_SPEAKER_MIC; |
| 3356 | } else if (in_device & AUDIO_DEVICE_IN_WIRED_HEADSET) { |
| 3357 | snd_device = SND_DEVICE_IN_HEADSET_MIC; |
| 3358 | } else if (in_device & AUDIO_DEVICE_IN_BLUETOOTH_SCO_HEADSET) { |
Vicky Sehrawat | e240e5d | 2014-08-12 17:17:04 -0700 | [diff] [blame] | 3359 | if (adev->bt_wb_speech_enabled) { |
| 3360 | if (adev->bluetooth_nrec) |
| 3361 | snd_device = SND_DEVICE_IN_BT_SCO_MIC_WB_NREC; |
| 3362 | else |
| 3363 | snd_device = SND_DEVICE_IN_BT_SCO_MIC_WB; |
| 3364 | } else { |
| 3365 | if (adev->bluetooth_nrec) |
| 3366 | snd_device = SND_DEVICE_IN_BT_SCO_MIC_NREC; |
| 3367 | else |
| 3368 | snd_device = SND_DEVICE_IN_BT_SCO_MIC; |
| 3369 | } |
Naresh Tanniru | e3b1845 | 2014-03-04 14:44:27 +0530 | [diff] [blame] | 3370 | } else if (in_device & AUDIO_DEVICE_IN_AUX_DIGITAL) { |
| 3371 | snd_device = SND_DEVICE_IN_HDMI_MIC; |
Naresh Tanniru | db72d1e | 2014-03-05 17:33:47 +0530 | [diff] [blame] | 3372 | } else if (in_device & AUDIO_DEVICE_IN_ANLG_DOCK_HEADSET || |
| 3373 | in_device & AUDIO_DEVICE_IN_DGTL_DOCK_HEADSET) { |
| 3374 | snd_device = SND_DEVICE_IN_USB_HEADSET_MIC; |
Mingming Yin | 12125e8 | 2015-10-26 20:40:36 -0700 | [diff] [blame] | 3375 | } else if (in_device & AUDIO_DEVICE_IN_FM_TUNER) { |
Naresh Tanniru | db72d1e | 2014-03-05 17:33:47 +0530 | [diff] [blame] | 3376 | snd_device = SND_DEVICE_IN_CAPTURE_FM; |
Kuirong Wang | a9f7cee | 2016-03-07 11:21:52 -0800 | [diff] [blame] | 3377 | } else if (in_device & AUDIO_DEVICE_IN_USB_DEVICE ) { |
| 3378 | snd_device = SND_DEVICE_IN_USB_HEADSET_MIC; |
Naresh Tanniru | e3b1845 | 2014-03-04 14:44:27 +0530 | [diff] [blame] | 3379 | } else { |
| 3380 | ALOGE("%s: Unknown input device(s) %#x", __func__, in_device); |
| 3381 | ALOGW("%s: Using default handset-mic", __func__); |
| 3382 | snd_device = SND_DEVICE_IN_HANDSET_MIC; |
| 3383 | } |
| 3384 | } else { |
| 3385 | if (out_device & AUDIO_DEVICE_OUT_EARPIECE) { |
| 3386 | snd_device = SND_DEVICE_IN_HANDSET_MIC; |
| 3387 | } else if (out_device & AUDIO_DEVICE_OUT_WIRED_HEADSET) { |
| 3388 | snd_device = SND_DEVICE_IN_HEADSET_MIC; |
| 3389 | } else if (out_device & AUDIO_DEVICE_OUT_SPEAKER) { |
Chaithanya Krishna Bacharaju | 9955b16 | 2016-05-25 16:25:53 +0530 | [diff] [blame] | 3390 | if ((channel_count > 1) && (my_data->source_mic_type & SOURCE_DUAL_MIC)) |
Naresh Tanniru | db72d1e | 2014-03-05 17:33:47 +0530 | [diff] [blame] | 3391 | snd_device = SND_DEVICE_IN_SPEAKER_STEREO_DMIC; |
| 3392 | else |
| 3393 | snd_device = SND_DEVICE_IN_SPEAKER_MIC; |
Naresh Tanniru | 9c4ba54 | 2015-11-06 18:01:09 +0530 | [diff] [blame] | 3394 | } else if (out_device & AUDIO_DEVICE_OUT_WIRED_HEADPHONE || |
| 3395 | out_device & AUDIO_DEVICE_OUT_LINE) { |
Naresh Tanniru | e3b1845 | 2014-03-04 14:44:27 +0530 | [diff] [blame] | 3396 | snd_device = SND_DEVICE_IN_HANDSET_MIC; |
| 3397 | } else if (out_device & AUDIO_DEVICE_OUT_BLUETOOTH_SCO_HEADSET) { |
Vicky Sehrawat | e240e5d | 2014-08-12 17:17:04 -0700 | [diff] [blame] | 3398 | if (adev->bt_wb_speech_enabled) { |
| 3399 | if (adev->bluetooth_nrec) |
| 3400 | snd_device = SND_DEVICE_IN_BT_SCO_MIC_WB_NREC; |
| 3401 | else |
| 3402 | snd_device = SND_DEVICE_IN_BT_SCO_MIC_WB; |
| 3403 | } else { |
| 3404 | if (adev->bluetooth_nrec) |
| 3405 | snd_device = SND_DEVICE_IN_BT_SCO_MIC_NREC; |
| 3406 | else |
| 3407 | snd_device = SND_DEVICE_IN_BT_SCO_MIC; |
| 3408 | } |
Naresh Tanniru | e3b1845 | 2014-03-04 14:44:27 +0530 | [diff] [blame] | 3409 | } else if (out_device & AUDIO_DEVICE_OUT_AUX_DIGITAL) { |
| 3410 | snd_device = SND_DEVICE_IN_HDMI_MIC; |
Naresh Tanniru | db72d1e | 2014-03-05 17:33:47 +0530 | [diff] [blame] | 3411 | } else if (out_device & AUDIO_DEVICE_OUT_ANLG_DOCK_HEADSET || |
| 3412 | out_device & AUDIO_DEVICE_OUT_DGTL_DOCK_HEADSET) { |
| 3413 | snd_device = SND_DEVICE_IN_USB_HEADSET_MIC; |
Kuirong Wang | a9f7cee | 2016-03-07 11:21:52 -0800 | [diff] [blame] | 3414 | } else if (out_device & AUDIO_DEVICE_OUT_USB_DEVICE) { |
| 3415 | snd_device = SND_DEVICE_IN_USB_HEADSET_MIC; |
Naresh Tanniru | e3b1845 | 2014-03-04 14:44:27 +0530 | [diff] [blame] | 3416 | } else { |
| 3417 | ALOGE("%s: Unknown output device(s) %#x", __func__, out_device); |
| 3418 | ALOGW("%s: Using default handset-mic", __func__); |
| 3419 | snd_device = SND_DEVICE_IN_HANDSET_MIC; |
| 3420 | } |
| 3421 | } |
| 3422 | exit: |
| 3423 | ALOGV("%s: exit: in_snd_device(%s)", __func__, device_table[snd_device]); |
| 3424 | return snd_device; |
| 3425 | } |
| 3426 | |
| 3427 | int platform_set_hdmi_channels(void *platform, int channel_count) |
| 3428 | { |
| 3429 | struct platform_data *my_data = (struct platform_data *)platform; |
| 3430 | struct audio_device *adev = my_data->adev; |
| 3431 | struct mixer_ctl *ctl; |
| 3432 | const char *channel_cnt_str = NULL; |
| 3433 | const char *mixer_ctl_name = "HDMI_RX Channels"; |
| 3434 | switch (channel_count) { |
| 3435 | case 8: |
| 3436 | channel_cnt_str = "Eight"; break; |
| 3437 | case 7: |
| 3438 | channel_cnt_str = "Seven"; break; |
| 3439 | case 6: |
| 3440 | channel_cnt_str = "Six"; break; |
| 3441 | case 5: |
| 3442 | channel_cnt_str = "Five"; break; |
| 3443 | case 4: |
| 3444 | channel_cnt_str = "Four"; break; |
| 3445 | case 3: |
| 3446 | channel_cnt_str = "Three"; break; |
| 3447 | default: |
| 3448 | channel_cnt_str = "Two"; break; |
| 3449 | } |
| 3450 | ctl = mixer_get_ctl_by_name(adev->mixer, mixer_ctl_name); |
| 3451 | if (!ctl) { |
| 3452 | ALOGE("%s: Could not get ctl for mixer cmd - %s", |
| 3453 | __func__, mixer_ctl_name); |
| 3454 | return -EINVAL; |
| 3455 | } |
| 3456 | ALOGV("HDMI channel count: %s", channel_cnt_str); |
| 3457 | mixer_ctl_set_enum_by_string(ctl, channel_cnt_str); |
| 3458 | return 0; |
| 3459 | } |
| 3460 | |
Naresh Tanniru | db72d1e | 2014-03-05 17:33:47 +0530 | [diff] [blame] | 3461 | int platform_edid_get_max_channels(void *platform) |
Naresh Tanniru | e3b1845 | 2014-03-04 14:44:27 +0530 | [diff] [blame] | 3462 | { |
Preetam Singh Ranawat | 8bde2c5 | 2015-03-20 12:00:49 +0530 | [diff] [blame] | 3463 | int channel_count; |
| 3464 | int max_channels = 2; |
| 3465 | int i = 0, ret = 0; |
Naresh Tanniru | db72d1e | 2014-03-05 17:33:47 +0530 | [diff] [blame] | 3466 | struct platform_data *my_data = (struct platform_data *)platform; |
Preetam Singh Ranawat | 8bde2c5 | 2015-03-20 12:00:49 +0530 | [diff] [blame] | 3467 | edid_audio_info *info = NULL; |
| 3468 | ret = platform_get_edid_info(platform); |
| 3469 | info = (edid_audio_info *)my_data->edid_info; |
Naresh Tanniru | e3b1845 | 2014-03-04 14:44:27 +0530 | [diff] [blame] | 3470 | |
Preetam Singh Ranawat | 8bde2c5 | 2015-03-20 12:00:49 +0530 | [diff] [blame] | 3471 | if(ret == 0 && info != NULL) { |
| 3472 | for (i = 0; i < info->audio_blocks && i < MAX_EDID_BLOCKS; i++) { |
| 3473 | ALOGV("%s:format %d channel %d", __func__, |
| 3474 | info->audio_blocks_array[i].format_id, |
| 3475 | info->audio_blocks_array[i].channels); |
| 3476 | if (info->audio_blocks_array[i].format_id == LPCM) { |
| 3477 | channel_count = info->audio_blocks_array[i].channels; |
| 3478 | if (channel_count > max_channels) { |
| 3479 | max_channels = channel_count; |
| 3480 | } |
| 3481 | } |
Naresh Tanniru | db72d1e | 2014-03-05 17:33:47 +0530 | [diff] [blame] | 3482 | } |
Naresh Tanniru | e3b1845 | 2014-03-04 14:44:27 +0530 | [diff] [blame] | 3483 | } |
| 3484 | |
| 3485 | return max_channels; |
| 3486 | } |
Naresh Tanniru | db72d1e | 2014-03-05 17:33:47 +0530 | [diff] [blame] | 3487 | |
| 3488 | static int platform_set_slowtalk(struct platform_data *my_data, bool state) |
| 3489 | { |
| 3490 | int ret = 0; |
| 3491 | struct audio_device *adev = my_data->adev; |
| 3492 | struct mixer_ctl *ctl; |
| 3493 | const char *mixer_ctl_name = "Slowtalk Enable"; |
| 3494 | uint32_t set_values[ ] = {0, |
| 3495 | ALL_SESSION_VSID}; |
| 3496 | |
| 3497 | set_values[0] = state; |
| 3498 | ctl = mixer_get_ctl_by_name(adev->mixer, mixer_ctl_name); |
| 3499 | if (!ctl) { |
| 3500 | ALOGE("%s: Could not get ctl for mixer cmd - %s", |
| 3501 | __func__, mixer_ctl_name); |
| 3502 | ret = -EINVAL; |
| 3503 | } else { |
| 3504 | ALOGV("Setting slowtalk state: %d", state); |
| 3505 | ret = mixer_ctl_set_array(ctl, set_values, ARRAY_SIZE(set_values)); |
| 3506 | my_data->slowtalk = state; |
| 3507 | } |
| 3508 | |
| 3509 | if (my_data->csd != NULL) { |
| 3510 | ret = my_data->csd->slow_talk(ALL_SESSION_VSID, state); |
| 3511 | if (ret < 0) { |
| 3512 | ALOGE("%s: csd_client_disable_device, failed, error %d", |
| 3513 | __func__, ret); |
| 3514 | } |
| 3515 | } |
| 3516 | return ret; |
| 3517 | } |
| 3518 | |
Avinash Vaish | d5fa457 | 2014-09-15 14:41:14 +0530 | [diff] [blame] | 3519 | static int set_hd_voice(struct platform_data *my_data, bool state) |
| 3520 | { |
| 3521 | struct audio_device *adev = my_data->adev; |
| 3522 | struct mixer_ctl *ctl; |
| 3523 | const char *mixer_ctl_name = "HD Voice Enable"; |
| 3524 | int ret = 0; |
| 3525 | uint32_t set_values[ ] = {0, |
| 3526 | ALL_SESSION_VSID}; |
| 3527 | |
| 3528 | set_values[0] = state; |
| 3529 | ctl = mixer_get_ctl_by_name(adev->mixer, mixer_ctl_name); |
| 3530 | if (!ctl) { |
| 3531 | ALOGE("%s: Could not get ctl for mixer cmd - %s", |
| 3532 | __func__, mixer_ctl_name); |
| 3533 | ret = -EINVAL; |
| 3534 | } else { |
| 3535 | ALOGV("Setting HD Voice state: %d", state); |
| 3536 | ret = mixer_ctl_set_array(ctl, set_values, ARRAY_SIZE(set_values)); |
| 3537 | my_data->hd_voice = state; |
| 3538 | } |
| 3539 | |
| 3540 | return ret; |
| 3541 | } |
| 3542 | |
Naresh Tanniru | db72d1e | 2014-03-05 17:33:47 +0530 | [diff] [blame] | 3543 | int platform_set_parameters(void *platform, struct str_parms *parms) |
| 3544 | { |
| 3545 | struct platform_data *my_data = (struct platform_data *)platform; |
Naresh Tanniru | db72d1e | 2014-03-05 17:33:47 +0530 | [diff] [blame] | 3546 | char value[256] = {0}; |
Satya Krishna Pindiproli | f1cd92b | 2016-04-14 19:05:23 +0530 | [diff] [blame] | 3547 | int len; |
Naresh Tanniru | db72d1e | 2014-03-05 17:33:47 +0530 | [diff] [blame] | 3548 | int ret = 0, err; |
Karthik Reddy Katta | bfe193d | 2014-08-14 17:58:18 +0530 | [diff] [blame] | 3549 | char *kv_pairs = NULL; |
Naresh Tanniru | db72d1e | 2014-03-05 17:33:47 +0530 | [diff] [blame] | 3550 | |
Karthik Reddy Katta | bfe193d | 2014-08-14 17:58:18 +0530 | [diff] [blame] | 3551 | kv_pairs = str_parms_to_str(parms); |
Venkata Narendra Kumar Gutta | 7c131ef | 2015-11-17 14:15:57 +0530 | [diff] [blame] | 3552 | len = strlen(kv_pairs); |
Karthik Reddy Katta | bfe193d | 2014-08-14 17:58:18 +0530 | [diff] [blame] | 3553 | ALOGV("%s: enter: - %s", __func__, kv_pairs); |
| 3554 | free(kv_pairs); |
Naresh Tanniru | db72d1e | 2014-03-05 17:33:47 +0530 | [diff] [blame] | 3555 | |
Naresh Tanniru | db72d1e | 2014-03-05 17:33:47 +0530 | [diff] [blame] | 3556 | err = str_parms_get_str(parms, AUDIO_PARAMETER_KEY_SLOWTALK, value, sizeof(value)); |
| 3557 | if (err >= 0) { |
| 3558 | bool state = false; |
| 3559 | if (!strncmp("true", value, sizeof("true"))) { |
| 3560 | state = true; |
| 3561 | } |
| 3562 | |
| 3563 | str_parms_del(parms, AUDIO_PARAMETER_KEY_SLOWTALK); |
| 3564 | ret = platform_set_slowtalk(my_data, state); |
| 3565 | if (ret) |
| 3566 | ALOGE("%s: Failed to set slow talk err: %d", __func__, ret); |
| 3567 | } |
| 3568 | |
Avinash Vaish | d5fa457 | 2014-09-15 14:41:14 +0530 | [diff] [blame] | 3569 | err = str_parms_get_str(parms, AUDIO_PARAMETER_KEY_HD_VOICE, value, sizeof(value)); |
| 3570 | if (err >= 0) { |
| 3571 | bool state = false; |
| 3572 | if (!strncmp("true", value, sizeof("true"))) { |
| 3573 | state = true; |
| 3574 | } |
| 3575 | |
| 3576 | str_parms_del(parms, AUDIO_PARAMETER_KEY_HD_VOICE); |
| 3577 | if (my_data->hd_voice != state) { |
| 3578 | ret = set_hd_voice(my_data, state); |
| 3579 | if (ret) |
| 3580 | ALOGE("%s: Failed to set HD voice err: %d", __func__, ret); |
| 3581 | } else { |
| 3582 | ALOGV("%s: HD Voice already set to %d", __func__, state); |
| 3583 | } |
| 3584 | } |
| 3585 | |
Naresh Tanniru | db72d1e | 2014-03-05 17:33:47 +0530 | [diff] [blame] | 3586 | err = str_parms_get_str(parms, AUDIO_PARAMETER_KEY_VOLUME_BOOST, |
| 3587 | value, sizeof(value)); |
| 3588 | if (err >= 0) { |
| 3589 | str_parms_del(parms, AUDIO_PARAMETER_KEY_VOLUME_BOOST); |
| 3590 | |
| 3591 | if (my_data->acdb_reload_vocvoltable == NULL) { |
| 3592 | ALOGE("%s: acdb_reload_vocvoltable is NULL", __func__); |
| 3593 | } else if (!strcmp(value, "on")) { |
| 3594 | if (!my_data->acdb_reload_vocvoltable(VOICE_FEATURE_SET_VOLUME_BOOST)) { |
| 3595 | my_data->voice_feature_set = 1; |
| 3596 | } |
| 3597 | } else { |
| 3598 | if (!my_data->acdb_reload_vocvoltable(VOICE_FEATURE_SET_DEFAULT)) { |
| 3599 | my_data->voice_feature_set = 0; |
| 3600 | } |
| 3601 | } |
| 3602 | } |
| 3603 | |
Karthik Reddy Katta | 8513f43 | 2016-04-12 14:29:27 +0530 | [diff] [blame] | 3604 | err = str_parms_get_str(parms, AUDIO_PARAMETER_KEY_RELOAD_ACDB, |
| 3605 | value, sizeof(value)); |
| 3606 | if (err >= 0) { |
| 3607 | str_parms_del(parms, AUDIO_PARAMETER_KEY_RELOAD_ACDB); |
| 3608 | |
| 3609 | my_data->acdb_reload(value, my_data->snd_card_name, |
| 3610 | my_data->cvd_version, my_data->metainfo_key); |
| 3611 | |
| 3612 | } |
| 3613 | |
Naresh Tanniru | c0517bc | 2014-10-26 15:30:55 +0530 | [diff] [blame] | 3614 | #ifdef RECORD_PLAY_CONCURRENCY |
| 3615 | err = str_parms_get_str(parms, AUDIO_PARAMETER_KEY_REC_PLAY_CONC, value, sizeof(value)); |
| 3616 | if (err >= 0) { |
| 3617 | if (!strncmp("true", value, sizeof("true"))) { |
| 3618 | ALOGD("setting record playback concurrency to true"); |
| 3619 | my_data->rec_play_conc_set = true; |
| 3620 | } else { |
| 3621 | ALOGD("setting record playback concurrency to false"); |
| 3622 | my_data->rec_play_conc_set = false; |
| 3623 | } |
Naresh Tanniru | c0517bc | 2014-10-26 15:30:55 +0530 | [diff] [blame] | 3624 | } |
| 3625 | #endif |
Chaithanya Krishna Bacharaju | 9955b16 | 2016-05-25 16:25:53 +0530 | [diff] [blame] | 3626 | |
| 3627 | err = str_parms_get_str(parms, PLATFORM_MAX_MIC_COUNT, |
| 3628 | value, sizeof(value)); |
| 3629 | if (err >= 0) { |
| 3630 | str_parms_del(parms, PLATFORM_MAX_MIC_COUNT); |
| 3631 | my_data->max_mic_count = atoi(value); |
| 3632 | ALOGV("%s: max_mic_count %d", __func__, my_data->max_mic_count); |
| 3633 | } |
| 3634 | |
Preetam Singh Ranawat | c61f867 | 2015-06-18 23:20:28 +0530 | [diff] [blame] | 3635 | native_audio_set_params(platform, parms, value, sizeof(value)); |
Venkata Narendra Kumar Gutta | 7c131ef | 2015-11-17 14:15:57 +0530 | [diff] [blame] | 3636 | audio_extn_spkr_prot_set_parameters(parms, value, len); |
Ashish Jain | f1eaa58 | 2016-05-23 20:54:24 +0530 | [diff] [blame] | 3637 | true_32_bit_set_params(parms, value, len); |
Naresh Tanniru | db72d1e | 2014-03-05 17:33:47 +0530 | [diff] [blame] | 3638 | ALOGV("%s: exit with code(%d)", __func__, ret); |
| 3639 | return ret; |
| 3640 | } |
| 3641 | |
| 3642 | int platform_set_incall_recording_session_id(void *platform, |
| 3643 | uint32_t session_id, int rec_mode) |
| 3644 | { |
| 3645 | int ret = 0; |
| 3646 | struct platform_data *my_data = (struct platform_data *)platform; |
| 3647 | struct audio_device *adev = my_data->adev; |
| 3648 | struct mixer_ctl *ctl; |
| 3649 | const char *mixer_ctl_name = "Voc VSID"; |
| 3650 | int num_ctl_values; |
| 3651 | int i; |
| 3652 | |
| 3653 | ctl = mixer_get_ctl_by_name(adev->mixer, mixer_ctl_name); |
| 3654 | if (!ctl) { |
| 3655 | ALOGE("%s: Could not get ctl for mixer cmd - %s", |
| 3656 | __func__, mixer_ctl_name); |
| 3657 | ret = -EINVAL; |
| 3658 | } else { |
| 3659 | num_ctl_values = mixer_ctl_get_num_values(ctl); |
| 3660 | for (i = 0; i < num_ctl_values; i++) { |
| 3661 | if (mixer_ctl_set_value(ctl, i, session_id)) { |
| 3662 | ALOGV("Error: invalid session_id: %x", session_id); |
| 3663 | ret = -EINVAL; |
| 3664 | break; |
| 3665 | } |
| 3666 | } |
| 3667 | } |
| 3668 | |
| 3669 | if (my_data->csd != NULL) { |
| 3670 | ret = my_data->csd->start_record(ALL_SESSION_VSID, rec_mode); |
| 3671 | if (ret < 0) { |
| 3672 | ALOGE("%s: csd_client_start_record failed, error %d", |
| 3673 | __func__, ret); |
| 3674 | } |
| 3675 | } |
| 3676 | |
| 3677 | return ret; |
| 3678 | } |
| 3679 | |
| 3680 | int platform_stop_incall_recording_usecase(void *platform) |
| 3681 | { |
| 3682 | int ret = 0; |
| 3683 | struct platform_data *my_data = (struct platform_data *)platform; |
| 3684 | |
| 3685 | if (my_data->csd != NULL) { |
| 3686 | ret = my_data->csd->stop_record(ALL_SESSION_VSID); |
| 3687 | if (ret < 0) { |
| 3688 | ALOGE("%s: csd_client_stop_record failed, error %d", |
| 3689 | __func__, ret); |
| 3690 | } |
| 3691 | } |
| 3692 | |
| 3693 | return ret; |
| 3694 | } |
| 3695 | |
| 3696 | int platform_start_incall_music_usecase(void *platform) |
| 3697 | { |
| 3698 | int ret = 0; |
| 3699 | struct platform_data *my_data = (struct platform_data *)platform; |
| 3700 | |
| 3701 | if (my_data->csd != NULL) { |
| 3702 | ret = my_data->csd->start_playback(ALL_SESSION_VSID); |
| 3703 | if (ret < 0) { |
| 3704 | ALOGE("%s: csd_client_start_playback failed, error %d", |
| 3705 | __func__, ret); |
| 3706 | } |
| 3707 | } |
| 3708 | |
| 3709 | return ret; |
| 3710 | } |
| 3711 | |
| 3712 | int platform_stop_incall_music_usecase(void *platform) |
| 3713 | { |
| 3714 | int ret = 0; |
| 3715 | struct platform_data *my_data = (struct platform_data *)platform; |
| 3716 | |
| 3717 | if (my_data->csd != NULL) { |
| 3718 | ret = my_data->csd->stop_playback(ALL_SESSION_VSID); |
| 3719 | if (ret < 0) { |
| 3720 | ALOGE("%s: csd_client_stop_playback failed, error %d", |
| 3721 | __func__, ret); |
| 3722 | } |
| 3723 | } |
| 3724 | |
| 3725 | return ret; |
| 3726 | } |
| 3727 | |
Vidyakumar Athota | 21b3bb9 | 2014-04-25 11:08:08 -0700 | [diff] [blame] | 3728 | int platform_update_lch(void *platform, struct voice_session *session, |
| 3729 | enum voice_lch_mode lch_mode) |
| 3730 | { |
| 3731 | int ret = 0; |
| 3732 | struct platform_data *my_data = (struct platform_data *)platform; |
| 3733 | |
| 3734 | if ((my_data->csd != NULL) && (my_data->csd->set_lch != NULL)) |
| 3735 | ret = my_data->csd->set_lch(session->vsid, lch_mode); |
| 3736 | else |
| 3737 | ret = pcm_ioctl(session->pcm_tx, SNDRV_VOICE_IOCTL_LCH, &lch_mode); |
| 3738 | |
| 3739 | return ret; |
| 3740 | } |
| 3741 | |
Naresh Tanniru | db72d1e | 2014-03-05 17:33:47 +0530 | [diff] [blame] | 3742 | void platform_get_parameters(void *platform, |
| 3743 | struct str_parms *query, |
| 3744 | struct str_parms *reply) |
| 3745 | { |
| 3746 | struct platform_data *my_data = (struct platform_data *)platform; |
Preetam Singh Ranawat | 8bde2c5 | 2015-03-20 12:00:49 +0530 | [diff] [blame] | 3747 | char value[512] = {0}; |
Naresh Tanniru | db72d1e | 2014-03-05 17:33:47 +0530 | [diff] [blame] | 3748 | int ret; |
Karthik Reddy Katta | bfe193d | 2014-08-14 17:58:18 +0530 | [diff] [blame] | 3749 | char *kv_pairs = NULL; |
Sidipotu Ashok | 42483b6 | 2015-09-08 10:21:44 +0530 | [diff] [blame] | 3750 | char propValue[PROPERTY_VALUE_MAX]={0}; |
| 3751 | bool prop_playback_enabled = false; |
Naresh Tanniru | db72d1e | 2014-03-05 17:33:47 +0530 | [diff] [blame] | 3752 | |
Naresh Tanniru | db72d1e | 2014-03-05 17:33:47 +0530 | [diff] [blame] | 3753 | ret = str_parms_get_str(query, AUDIO_PARAMETER_KEY_SLOWTALK, |
| 3754 | value, sizeof(value)); |
| 3755 | if (ret >= 0) { |
| 3756 | str_parms_add_str(reply, AUDIO_PARAMETER_KEY_SLOWTALK, |
| 3757 | my_data->slowtalk?"true":"false"); |
| 3758 | } |
| 3759 | |
Avinash Vaish | d5fa457 | 2014-09-15 14:41:14 +0530 | [diff] [blame] | 3760 | ret = str_parms_get_str(query, AUDIO_PARAMETER_KEY_HD_VOICE, |
| 3761 | value, sizeof(value)); |
| 3762 | if (ret >= 0) { |
| 3763 | str_parms_add_str(reply, AUDIO_PARAMETER_KEY_HD_VOICE, |
| 3764 | my_data->hd_voice?"true":"false"); |
| 3765 | } |
| 3766 | |
Naresh Tanniru | db72d1e | 2014-03-05 17:33:47 +0530 | [diff] [blame] | 3767 | ret = str_parms_get_str(query, AUDIO_PARAMETER_KEY_VOLUME_BOOST, |
| 3768 | value, sizeof(value)); |
| 3769 | if (ret >= 0) { |
| 3770 | if (my_data->voice_feature_set == VOICE_FEATURE_SET_VOLUME_BOOST) { |
| 3771 | strlcpy(value, "on", sizeof(value)); |
| 3772 | } else { |
| 3773 | strlcpy(value, "off", sizeof(value)); |
| 3774 | } |
| 3775 | |
| 3776 | str_parms_add_str(reply, AUDIO_PARAMETER_KEY_VOLUME_BOOST, value); |
| 3777 | } |
Preetam Singh Ranawat | c61f867 | 2015-06-18 23:20:28 +0530 | [diff] [blame] | 3778 | native_audio_get_params(query, reply, value, sizeof(value)); |
Naresh Tanniru | db72d1e | 2014-03-05 17:33:47 +0530 | [diff] [blame] | 3779 | |
Sidipotu Ashok | f490be5 | 2015-10-20 10:41:34 +0530 | [diff] [blame] | 3780 | ret = str_parms_get_str(query, AUDIO_PARAMETER_IS_HW_DECODER_SESSION_AVAILABLE, |
Sidipotu Ashok | 42483b6 | 2015-09-08 10:21:44 +0530 | [diff] [blame] | 3781 | value, sizeof(value)); |
| 3782 | if (ret >= 0) { |
| 3783 | int isallowed = 1; /*true*/ |
| 3784 | |
| 3785 | if (property_get("voice.playback.conc.disabled", propValue, NULL)) { |
| 3786 | prop_playback_enabled = atoi(propValue) || |
| 3787 | !strncmp("true", propValue, 4); |
| 3788 | } |
| 3789 | |
| 3790 | if (prop_playback_enabled && (voice_is_in_call(my_data->adev) || |
| 3791 | (SND_CARD_STATE_OFFLINE == get_snd_card_state(my_data->adev)))) { |
| 3792 | char *decoder_mime_type = value; |
| 3793 | |
| 3794 | //check if unsupported mime type or not |
| 3795 | if(decoder_mime_type) { |
Alexy Joseph | b137994 | 2016-01-29 15:49:38 -0800 | [diff] [blame] | 3796 | unsigned int i = 0; |
Sidipotu Ashok | 42483b6 | 2015-09-08 10:21:44 +0530 | [diff] [blame] | 3797 | for (i = 0; i < sizeof(dsp_only_decoders_mime)/sizeof(dsp_only_decoders_mime[0]); i++) { |
| 3798 | if (!strncmp(decoder_mime_type, dsp_only_decoders_mime[i], |
| 3799 | strlen(dsp_only_decoders_mime[i]))) { |
| 3800 | ALOGD("Rejecting request for DSP only session from HAL during voice call/SSR state"); |
| 3801 | isallowed = 0; |
| 3802 | break; |
| 3803 | } |
| 3804 | } |
| 3805 | } |
| 3806 | } |
Sidipotu Ashok | f490be5 | 2015-10-20 10:41:34 +0530 | [diff] [blame] | 3807 | str_parms_add_int(reply, AUDIO_PARAMETER_IS_HW_DECODER_SESSION_AVAILABLE, isallowed); |
Sidipotu Ashok | 42483b6 | 2015-09-08 10:21:44 +0530 | [diff] [blame] | 3808 | } |
| 3809 | |
| 3810 | |
Preetam Singh Ranawat | 8bde2c5 | 2015-03-20 12:00:49 +0530 | [diff] [blame] | 3811 | /* Handle audio calibration keys */ |
Karthik Reddy Katta | bfe193d | 2014-08-14 17:58:18 +0530 | [diff] [blame] | 3812 | kv_pairs = str_parms_to_str(reply); |
| 3813 | ALOGV("%s: exit: returns - %s", __func__, kv_pairs); |
| 3814 | free(kv_pairs); |
Naresh Tanniru | db72d1e | 2014-03-05 17:33:47 +0530 | [diff] [blame] | 3815 | } |
| 3816 | |
Ashish Jain | 5106d36 | 2016-05-11 19:23:33 +0530 | [diff] [blame] | 3817 | /* Delay in Us, only to be used for PCM formats */ |
Naresh Tanniru | db72d1e | 2014-03-05 17:33:47 +0530 | [diff] [blame] | 3818 | int64_t platform_render_latency(audio_usecase_t usecase) |
| 3819 | { |
| 3820 | switch (usecase) { |
| 3821 | case USECASE_AUDIO_PLAYBACK_DEEP_BUFFER: |
| 3822 | return DEEP_BUFFER_PLATFORM_DELAY; |
| 3823 | case USECASE_AUDIO_PLAYBACK_LOW_LATENCY: |
| 3824 | return LOW_LATENCY_PLATFORM_DELAY; |
Ashish Jain | 5106d36 | 2016-05-11 19:23:33 +0530 | [diff] [blame] | 3825 | case USECASE_AUDIO_PLAYBACK_OFFLOAD: |
| 3826 | case USECASE_AUDIO_PLAYBACK_OFFLOAD2: |
| 3827 | return PCM_OFFLOAD_PLATFORM_DELAY; |
Naresh Tanniru | db72d1e | 2014-03-05 17:33:47 +0530 | [diff] [blame] | 3828 | default: |
| 3829 | return 0; |
| 3830 | } |
| 3831 | } |
| 3832 | |
| 3833 | int platform_update_usecase_from_source(int source, int usecase) |
| 3834 | { |
| 3835 | ALOGV("%s: input source :%d", __func__, source); |
Mingming Yin | 12125e8 | 2015-10-26 20:40:36 -0700 | [diff] [blame] | 3836 | if (source == AUDIO_SOURCE_FM_TUNER) |
Naresh Tanniru | db72d1e | 2014-03-05 17:33:47 +0530 | [diff] [blame] | 3837 | usecase = USECASE_AUDIO_RECORD_FM_VIRTUAL; |
| 3838 | return usecase; |
| 3839 | } |
| 3840 | |
Dhananjay Kumar | 45b7174 | 2014-05-29 21:47:27 +0530 | [diff] [blame] | 3841 | bool platform_listen_device_needs_event(snd_device_t snd_device) |
Naresh Tanniru | db72d1e | 2014-03-05 17:33:47 +0530 | [diff] [blame] | 3842 | { |
Dhananjay Kumar | 45b7174 | 2014-05-29 21:47:27 +0530 | [diff] [blame] | 3843 | bool needs_event = false; |
| 3844 | |
Naresh Tanniru | db72d1e | 2014-03-05 17:33:47 +0530 | [diff] [blame] | 3845 | if ((snd_device >= SND_DEVICE_IN_BEGIN) && |
| 3846 | (snd_device < SND_DEVICE_IN_END) && |
| 3847 | (snd_device != SND_DEVICE_IN_CAPTURE_FM) && |
| 3848 | (snd_device != SND_DEVICE_IN_CAPTURE_VI_FEEDBACK)) |
Dhananjay Kumar | 45b7174 | 2014-05-29 21:47:27 +0530 | [diff] [blame] | 3849 | needs_event = true; |
| 3850 | |
| 3851 | return needs_event; |
| 3852 | } |
| 3853 | |
| 3854 | bool platform_listen_usecase_needs_event(audio_usecase_t uc_id) |
| 3855 | { |
| 3856 | bool needs_event = false; |
| 3857 | |
| 3858 | switch(uc_id){ |
| 3859 | /* concurrent playback usecases needs event */ |
| 3860 | case USECASE_AUDIO_PLAYBACK_DEEP_BUFFER: |
| 3861 | case USECASE_AUDIO_PLAYBACK_MULTI_CH: |
| 3862 | case USECASE_AUDIO_PLAYBACK_OFFLOAD: |
| 3863 | needs_event = true; |
| 3864 | break; |
| 3865 | /* concurrent playback in low latency allowed */ |
| 3866 | case USECASE_AUDIO_PLAYBACK_LOW_LATENCY: |
| 3867 | break; |
| 3868 | /* concurrent playback FM needs event */ |
| 3869 | case USECASE_AUDIO_PLAYBACK_FM: |
| 3870 | needs_event = true; |
| 3871 | break; |
| 3872 | |
| 3873 | /* concurrent capture usecases, no event, capture handled by device |
| 3874 | * USECASE_AUDIO_RECORD: |
| 3875 | * USECASE_AUDIO_RECORD_COMPRESS: |
| 3876 | * USECASE_AUDIO_RECORD_LOW_LATENCY: |
| 3877 | |
| 3878 | * USECASE_VOICE_CALL: |
| 3879 | * USECASE_VOICE2_CALL: |
| 3880 | * USECASE_VOLTE_CALL: |
| 3881 | * USECASE_QCHAT_CALL: |
| 3882 | * USECASE_VOWLAN_CALL: |
Avinash Vaish | 306e607 | 2015-05-13 16:58:18 +0530 | [diff] [blame] | 3883 | * USECASE_VOICEMMODE1_CALL: |
| 3884 | * USECASE_VOICEMMODE2_CALL: |
Dhananjay Kumar | 45b7174 | 2014-05-29 21:47:27 +0530 | [diff] [blame] | 3885 | * USECASE_COMPRESS_VOIP_CALL: |
| 3886 | * USECASE_AUDIO_RECORD_FM_VIRTUAL: |
| 3887 | * USECASE_INCALL_REC_UPLINK: |
| 3888 | * USECASE_INCALL_REC_DOWNLINK: |
| 3889 | * USECASE_INCALL_REC_UPLINK_AND_DOWNLINK: |
| 3890 | * USECASE_INCALL_REC_UPLINK_COMPRESS: |
| 3891 | * USECASE_INCALL_REC_DOWNLINK_COMPRESS: |
| 3892 | * USECASE_INCALL_REC_UPLINK_AND_DOWNLINK_COMPRESS: |
| 3893 | * USECASE_INCALL_MUSIC_UPLINK: |
| 3894 | * USECASE_INCALL_MUSIC_UPLINK2: |
| 3895 | * USECASE_AUDIO_SPKR_CALIB_RX: |
| 3896 | * USECASE_AUDIO_SPKR_CALIB_TX: |
| 3897 | */ |
| 3898 | default: |
| 3899 | ALOGV("%s:usecase_id[%d} no need to raise event.", __func__, uc_id); |
| 3900 | } |
| 3901 | return needs_event; |
Naresh Tanniru | db72d1e | 2014-03-05 17:33:47 +0530 | [diff] [blame] | 3902 | } |
| 3903 | |
Ravi Kumar Alamanda | 8fa6b19 | 2014-09-09 16:06:42 -0700 | [diff] [blame] | 3904 | bool platform_sound_trigger_device_needs_event(snd_device_t snd_device) |
| 3905 | { |
| 3906 | bool needs_event = false; |
| 3907 | |
| 3908 | if ((snd_device >= SND_DEVICE_IN_BEGIN) && |
| 3909 | (snd_device < SND_DEVICE_IN_END) && |
| 3910 | (snd_device != SND_DEVICE_IN_CAPTURE_FM) && |
| 3911 | (snd_device != SND_DEVICE_IN_CAPTURE_VI_FEEDBACK)) |
| 3912 | needs_event = true; |
| 3913 | |
| 3914 | return needs_event; |
| 3915 | } |
| 3916 | |
| 3917 | bool platform_sound_trigger_usecase_needs_event(audio_usecase_t uc_id) |
| 3918 | { |
| 3919 | bool needs_event = false; |
| 3920 | |
| 3921 | switch(uc_id){ |
| 3922 | /* concurrent playback usecases needs event */ |
| 3923 | case USECASE_AUDIO_PLAYBACK_DEEP_BUFFER: |
| 3924 | case USECASE_AUDIO_PLAYBACK_MULTI_CH: |
| 3925 | case USECASE_AUDIO_PLAYBACK_OFFLOAD: |
| 3926 | needs_event = true; |
| 3927 | break; |
| 3928 | /* concurrent playback in low latency allowed */ |
| 3929 | case USECASE_AUDIO_PLAYBACK_LOW_LATENCY: |
| 3930 | break; |
| 3931 | /* concurrent playback FM needs event */ |
| 3932 | case USECASE_AUDIO_PLAYBACK_FM: |
| 3933 | needs_event = true; |
| 3934 | break; |
| 3935 | |
| 3936 | /* concurrent capture usecases, no event, capture handled by device |
| 3937 | * USECASE_AUDIO_RECORD: |
| 3938 | * USECASE_AUDIO_RECORD_COMPRESS: |
| 3939 | * USECASE_AUDIO_RECORD_LOW_LATENCY: |
| 3940 | |
| 3941 | * USECASE_VOICE_CALL: |
| 3942 | * USECASE_VOICE2_CALL: |
| 3943 | * USECASE_VOLTE_CALL: |
| 3944 | * USECASE_QCHAT_CALL: |
| 3945 | * USECASE_VOWLAN_CALL: |
Avinash Vaish | 306e607 | 2015-05-13 16:58:18 +0530 | [diff] [blame] | 3946 | * USECASE_VOICEMMODE1_CALL: |
| 3947 | * USECASE_VOICEMMODE2_CALL: |
Ravi Kumar Alamanda | 8fa6b19 | 2014-09-09 16:06:42 -0700 | [diff] [blame] | 3948 | * USECASE_COMPRESS_VOIP_CALL: |
| 3949 | * USECASE_AUDIO_RECORD_FM_VIRTUAL: |
| 3950 | * USECASE_INCALL_REC_UPLINK: |
| 3951 | * USECASE_INCALL_REC_DOWNLINK: |
| 3952 | * USECASE_INCALL_REC_UPLINK_AND_DOWNLINK: |
| 3953 | * USECASE_INCALL_REC_UPLINK_COMPRESS: |
| 3954 | * USECASE_INCALL_REC_DOWNLINK_COMPRESS: |
| 3955 | * USECASE_INCALL_REC_UPLINK_AND_DOWNLINK_COMPRESS: |
| 3956 | * USECASE_INCALL_MUSIC_UPLINK: |
| 3957 | * USECASE_INCALL_MUSIC_UPLINK2: |
| 3958 | * USECASE_AUDIO_SPKR_CALIB_RX: |
| 3959 | * USECASE_AUDIO_SPKR_CALIB_TX: |
| 3960 | */ |
| 3961 | default: |
| 3962 | ALOGV("%s:usecase_id[%d] no need to raise event.", __func__, uc_id); |
| 3963 | } |
| 3964 | return needs_event; |
| 3965 | } |
| 3966 | |
Naresh Tanniru | db72d1e | 2014-03-05 17:33:47 +0530 | [diff] [blame] | 3967 | /* Read offload buffer size from a property. |
| 3968 | * If value is not power of 2 round it to |
| 3969 | * power of 2. |
| 3970 | */ |
| 3971 | uint32_t platform_get_compress_offload_buffer_size(audio_offload_info_t* info) |
| 3972 | { |
| 3973 | char value[PROPERTY_VALUE_MAX] = {0}; |
| 3974 | uint32_t fragment_size = COMPRESS_OFFLOAD_FRAGMENT_SIZE; |
| 3975 | if((property_get("audio.offload.buffer.size.kb", value, "")) && |
| 3976 | atoi(value)) { |
| 3977 | fragment_size = atoi(value) * 1024; |
| 3978 | } |
| 3979 | |
vivek mehta | 80a4429 | 2015-08-10 12:58:10 -0700 | [diff] [blame] | 3980 | /* Use incoming offload buffer size if default buffer size is less */ |
| 3981 | if ((info != NULL) && (fragment_size < info->offload_buffer_size)) { |
| 3982 | ALOGI("%s:: Overwriting offload buffer size default:%d new:%d", __func__, |
| 3983 | fragment_size, |
| 3984 | info->offload_buffer_size); |
| 3985 | fragment_size = info->offload_buffer_size; |
| 3986 | } |
| 3987 | |
Preetam Singh Ranawat | 8bde2c5 | 2015-03-20 12:00:49 +0530 | [diff] [blame] | 3988 | // For FLAC use max size since it is loss less, and has sampling rates |
| 3989 | // upto 192kHZ |
| 3990 | if (info != NULL && !info->has_video && |
| 3991 | info->format == AUDIO_FORMAT_FLAC) { |
| 3992 | fragment_size = MAX_COMPRESS_OFFLOAD_FRAGMENT_SIZE; |
| 3993 | ALOGV("FLAC fragment size %d", fragment_size); |
| 3994 | } |
| 3995 | |
Naresh Tanniru | db72d1e | 2014-03-05 17:33:47 +0530 | [diff] [blame] | 3996 | if (info != NULL && info->has_video && info->is_streaming) { |
| 3997 | fragment_size = COMPRESS_OFFLOAD_FRAGMENT_SIZE_FOR_AV_STREAMING; |
| 3998 | ALOGV("%s: offload fragment size reduced for AV streaming to %d", |
Apoorv Raghuvanshi | 44bd917 | 2014-05-28 14:50:07 -0700 | [diff] [blame] | 3999 | __func__, fragment_size); |
Naresh Tanniru | db72d1e | 2014-03-05 17:33:47 +0530 | [diff] [blame] | 4000 | } |
| 4001 | |
| 4002 | fragment_size = ALIGN( fragment_size, 1024); |
| 4003 | |
| 4004 | if(fragment_size < MIN_COMPRESS_OFFLOAD_FRAGMENT_SIZE) |
| 4005 | fragment_size = MIN_COMPRESS_OFFLOAD_FRAGMENT_SIZE; |
| 4006 | else if(fragment_size > MAX_COMPRESS_OFFLOAD_FRAGMENT_SIZE) |
| 4007 | fragment_size = MAX_COMPRESS_OFFLOAD_FRAGMENT_SIZE; |
| 4008 | ALOGV("%s: fragment_size %d", __func__, fragment_size); |
| 4009 | return fragment_size; |
| 4010 | } |
| 4011 | |
Naresh Tanniru | db72d1e | 2014-03-05 17:33:47 +0530 | [diff] [blame] | 4012 | |
Sidipotu Ashok | e6f78cb | 2015-11-05 14:42:20 +0530 | [diff] [blame] | 4013 | /* |
| 4014 | * configures afe with bit width and Sample Rate |
| 4015 | */ |
Sidipotu Ashok | 9f0b16e | 2016-04-28 13:48:28 +0530 | [diff] [blame] | 4016 | static int platform_set_codec_backend_cfg(struct audio_device* adev, |
Ashish Jain | 5106d36 | 2016-05-11 19:23:33 +0530 | [diff] [blame] | 4017 | snd_device_t snd_device, unsigned int bit_width, |
| 4018 | unsigned int sample_rate, audio_format_t format) |
Preetam Singh Ranawat | 8bde2c5 | 2015-03-20 12:00:49 +0530 | [diff] [blame] | 4019 | { |
Preetam Singh Ranawat | 8bde2c5 | 2015-03-20 12:00:49 +0530 | [diff] [blame] | 4020 | int ret = 0; |
Preetam Singh Ranawat | c61f867 | 2015-06-18 23:20:28 +0530 | [diff] [blame] | 4021 | int backend_idx = DEFAULT_CODEC_BACKEND; |
| 4022 | struct platform_data *my_data = (struct platform_data *)adev->platform; |
Preetam Singh Ranawat | c61f867 | 2015-06-18 23:20:28 +0530 | [diff] [blame] | 4023 | |
| 4024 | backend_idx = platform_get_backend_index(snd_device); |
Sidipotu Ashok | e6f78cb | 2015-11-05 14:42:20 +0530 | [diff] [blame] | 4025 | ALOGI("%s:becf: afe: bitwidth %d, samplerate %d, backend_idx %d device (%s)", |
| 4026 | __func__, bit_width, sample_rate, backend_idx, |
| 4027 | platform_get_snd_device_name(snd_device)); |
Preetam Singh Ranawat | c61f867 | 2015-06-18 23:20:28 +0530 | [diff] [blame] | 4028 | |
| 4029 | if (bit_width != |
| 4030 | my_data->current_backend_cfg[backend_idx].bit_width) { |
| 4031 | |
Preetam Singh Ranawat | 8bde2c5 | 2015-03-20 12:00:49 +0530 | [diff] [blame] | 4032 | struct mixer_ctl *ctl; |
Venkata Narendra Kumar Gutta | 4bd09d0 | 2016-01-29 15:31:04 +0530 | [diff] [blame] | 4033 | ctl = mixer_get_ctl_by_name(adev->mixer, |
Preetam Singh Ranawat | c61f867 | 2015-06-18 23:20:28 +0530 | [diff] [blame] | 4034 | my_data->current_backend_cfg[backend_idx].bitwidth_mixer_ctl); |
Preetam Singh Ranawat | 8bde2c5 | 2015-03-20 12:00:49 +0530 | [diff] [blame] | 4035 | if (!ctl) { |
Sidipotu Ashok | e6f78cb | 2015-11-05 14:42:20 +0530 | [diff] [blame] | 4036 | ALOGE("%s:becf: afe: Could not get ctl for mixer command - %s", |
| 4037 | __func__, |
| 4038 | my_data->current_backend_cfg[backend_idx].bitwidth_mixer_ctl); |
Preetam Singh Ranawat | 8bde2c5 | 2015-03-20 12:00:49 +0530 | [diff] [blame] | 4039 | return -EINVAL; |
| 4040 | } |
| 4041 | |
| 4042 | if (bit_width == 24) { |
Ashish Jain | 5106d36 | 2016-05-11 19:23:33 +0530 | [diff] [blame] | 4043 | if (format == AUDIO_FORMAT_PCM_24_BIT_PACKED) |
| 4044 | mixer_ctl_set_enum_by_string(ctl, "S24_3LE"); |
| 4045 | else |
Preetam Singh Ranawat | 8bde2c5 | 2015-03-20 12:00:49 +0530 | [diff] [blame] | 4046 | mixer_ctl_set_enum_by_string(ctl, "S24_LE"); |
Kuirong Wang | a9f7cee | 2016-03-07 11:21:52 -0800 | [diff] [blame] | 4047 | } else if (bit_width == 32) { |
| 4048 | mixer_ctl_set_enum_by_string(ctl, "S24_LE"); |
Preetam Singh Ranawat | 8bde2c5 | 2015-03-20 12:00:49 +0530 | [diff] [blame] | 4049 | } else { |
| 4050 | mixer_ctl_set_enum_by_string(ctl, "S16_LE"); |
Preetam Singh Ranawat | 8bde2c5 | 2015-03-20 12:00:49 +0530 | [diff] [blame] | 4051 | } |
Preetam Singh Ranawat | c61f867 | 2015-06-18 23:20:28 +0530 | [diff] [blame] | 4052 | my_data->current_backend_cfg[backend_idx].bit_width = bit_width; |
Ashish Jain | 5106d36 | 2016-05-11 19:23:33 +0530 | [diff] [blame] | 4053 | ALOGD("%s:becf: afe: %s mixer set to %d bit for %x format", __func__, |
| 4054 | my_data->current_backend_cfg[backend_idx].bitwidth_mixer_ctl, |
| 4055 | bit_width, format); |
Preetam Singh Ranawat | 8bde2c5 | 2015-03-20 12:00:49 +0530 | [diff] [blame] | 4056 | } |
| 4057 | |
| 4058 | /* |
| 4059 | * Backend sample rate configuration follows: |
| 4060 | * 16 bit playback - 48khz for streams at any valid sample rate |
| 4061 | * 24 bit playback - 48khz for stream sample rate less than 48khz |
| 4062 | * 24 bit playback - 96khz for sample rate range of 48khz to 96khz |
| 4063 | * 24 bit playback - 192khz for sample rate range of 96khz to 192 khz |
| 4064 | * Upper limit is inclusive in the sample rate range. |
| 4065 | */ |
| 4066 | // TODO: This has to be more dynamic based on policy file |
Preetam Singh Ranawat | c61f867 | 2015-06-18 23:20:28 +0530 | [diff] [blame] | 4067 | |
| 4068 | if ((sample_rate != my_data->current_backend_cfg[(int)backend_idx].sample_rate) && |
Venkata Narendra Kumar Gutta | 4bd09d0 | 2016-01-29 15:31:04 +0530 | [diff] [blame] | 4069 | (my_data->hifi_audio)) { |
| 4070 | /* |
| 4071 | * sample rate update is needed only for hifi audio enabled platforms |
| 4072 | */ |
Preetam Singh Ranawat | 8bde2c5 | 2015-03-20 12:00:49 +0530 | [diff] [blame] | 4073 | char *rate_str = NULL; |
Preetam Singh Ranawat | 8bde2c5 | 2015-03-20 12:00:49 +0530 | [diff] [blame] | 4074 | struct mixer_ctl *ctl; |
| 4075 | |
| 4076 | switch (sample_rate) { |
| 4077 | case 8000: |
| 4078 | case 11025: |
| 4079 | case 16000: |
| 4080 | case 22050: |
| 4081 | case 32000: |
Preetam Singh Ranawat | 8bde2c5 | 2015-03-20 12:00:49 +0530 | [diff] [blame] | 4082 | case 48000: |
| 4083 | rate_str = "KHZ_48"; |
| 4084 | break; |
Preetam Singh Ranawat | c61f867 | 2015-06-18 23:20:28 +0530 | [diff] [blame] | 4085 | case 44100: |
| 4086 | rate_str = "KHZ_44P1"; |
| 4087 | break; |
Preetam Singh Ranawat | 8bde2c5 | 2015-03-20 12:00:49 +0530 | [diff] [blame] | 4088 | case 64000: |
| 4089 | case 88200: |
| 4090 | case 96000: |
| 4091 | rate_str = "KHZ_96"; |
| 4092 | break; |
| 4093 | case 176400: |
| 4094 | case 192000: |
| 4095 | rate_str = "KHZ_192"; |
| 4096 | break; |
| 4097 | default: |
| 4098 | rate_str = "KHZ_48"; |
| 4099 | break; |
| 4100 | } |
| 4101 | |
Preetam Singh Ranawat | c61f867 | 2015-06-18 23:20:28 +0530 | [diff] [blame] | 4102 | ctl = mixer_get_ctl_by_name(adev->mixer, |
| 4103 | my_data->current_backend_cfg[backend_idx].samplerate_mixer_ctl); |
Sidipotu Ashok | e6f78cb | 2015-11-05 14:42:20 +0530 | [diff] [blame] | 4104 | |
| 4105 | if (!ctl) { |
| 4106 | ALOGE("%s:becf: afe: Could not get ctl to set the Sample Rate for mixer command - %s", |
| 4107 | __func__, |
| 4108 | my_data->current_backend_cfg[backend_idx].samplerate_mixer_ctl); |
Preetam Singh Ranawat | 8bde2c5 | 2015-03-20 12:00:49 +0530 | [diff] [blame] | 4109 | return -EINVAL; |
| 4110 | } |
| 4111 | |
Sidipotu Ashok | e6f78cb | 2015-11-05 14:42:20 +0530 | [diff] [blame] | 4112 | ALOGD("%s:becf: afe: %s set to %s", __func__, |
| 4113 | my_data->current_backend_cfg[backend_idx].samplerate_mixer_ctl, |
| 4114 | rate_str); |
Preetam Singh Ranawat | 8bde2c5 | 2015-03-20 12:00:49 +0530 | [diff] [blame] | 4115 | mixer_ctl_set_enum_by_string(ctl, rate_str); |
Preetam Singh Ranawat | c61f867 | 2015-06-18 23:20:28 +0530 | [diff] [blame] | 4116 | my_data->current_backend_cfg[backend_idx].sample_rate = sample_rate; |
Preetam Singh Ranawat | 8bde2c5 | 2015-03-20 12:00:49 +0530 | [diff] [blame] | 4117 | } |
| 4118 | |
| 4119 | return ret; |
| 4120 | } |
| 4121 | |
Sidipotu Ashok | e6f78cb | 2015-11-05 14:42:20 +0530 | [diff] [blame] | 4122 | /* |
| 4123 | * goes through all the current usecases and picks the highest |
| 4124 | * bitwidth & samplerate |
| 4125 | */ |
Sidipotu Ashok | 9f0b16e | 2016-04-28 13:48:28 +0530 | [diff] [blame] | 4126 | static bool platform_check_codec_backend_cfg(struct audio_device* adev, |
Preetam Singh Ranawat | c61f867 | 2015-06-18 23:20:28 +0530 | [diff] [blame] | 4127 | struct audio_usecase* usecase, |
| 4128 | snd_device_t snd_device, |
Preetam Singh Ranawat | 8bde2c5 | 2015-03-20 12:00:49 +0530 | [diff] [blame] | 4129 | unsigned int* new_bit_width, |
| 4130 | unsigned int* new_sample_rate) |
| 4131 | { |
| 4132 | bool backend_change = false; |
| 4133 | struct listnode *node; |
| 4134 | struct stream_out *out = NULL; |
Preetam Singh Ranawat | c61f867 | 2015-06-18 23:20:28 +0530 | [diff] [blame] | 4135 | char value[PROPERTY_VALUE_MAX] = {0}; |
| 4136 | unsigned int bit_width; |
| 4137 | unsigned int sample_rate; |
| 4138 | int backend_idx = DEFAULT_CODEC_BACKEND; |
Preetam Singh Ranawat | c61f867 | 2015-06-18 23:20:28 +0530 | [diff] [blame] | 4139 | struct platform_data *my_data = (struct platform_data *)adev->platform; |
Sidipotu Ashok | e6f78cb | 2015-11-05 14:42:20 +0530 | [diff] [blame] | 4140 | int na_mode = platform_get_native_support(); |
Mingming Yin | ddd610b | 2016-01-20 17:09:32 -0800 | [diff] [blame] | 4141 | edid_audio_info *edid_info = (edid_audio_info *)my_data->edid_info; |
Preetam Singh Ranawat | c61f867 | 2015-06-18 23:20:28 +0530 | [diff] [blame] | 4142 | |
| 4143 | backend_idx = platform_get_backend_index(snd_device); |
| 4144 | |
| 4145 | bit_width = *new_bit_width; |
| 4146 | sample_rate = *new_sample_rate; |
| 4147 | |
Sidipotu Ashok | e6f78cb | 2015-11-05 14:42:20 +0530 | [diff] [blame] | 4148 | ALOGI("%s:becf: afe: Codec selected backend: %d current bit width: %d and sample rate: %d", |
Sidipotu Ashok | 9f0b16e | 2016-04-28 13:48:28 +0530 | [diff] [blame] | 4149 | __func__, backend_idx, bit_width, sample_rate); |
Preetam Singh Ranawat | 8bde2c5 | 2015-03-20 12:00:49 +0530 | [diff] [blame] | 4150 | |
Apoorv Raghuvanshi | 924b302 | 2015-07-06 15:07:14 -0700 | [diff] [blame] | 4151 | // For voice calls use default configuration i.e. 16b/48K, only applicable to |
| 4152 | // default backend |
Preetam Singh Ranawat | 8bde2c5 | 2015-03-20 12:00:49 +0530 | [diff] [blame] | 4153 | // force routing is not required here, caller will do it anyway |
Apoorv Raghuvanshi | 924b302 | 2015-07-06 15:07:14 -0700 | [diff] [blame] | 4154 | if ((voice_is_in_call(adev) || adev->mode == AUDIO_MODE_IN_COMMUNICATION) && |
| 4155 | backend_idx == DEFAULT_CODEC_BACKEND) { |
Sidipotu Ashok | e6f78cb | 2015-11-05 14:42:20 +0530 | [diff] [blame] | 4156 | ALOGW("%s:becf: afe:Use default bw and sr for voice/voip calls ", |
| 4157 | __func__); |
Preetam Singh Ranawat | 8bde2c5 | 2015-03-20 12:00:49 +0530 | [diff] [blame] | 4158 | bit_width = CODEC_BACKEND_DEFAULT_BIT_WIDTH; |
| 4159 | sample_rate = CODEC_BACKEND_DEFAULT_SAMPLE_RATE; |
| 4160 | } else { |
| 4161 | /* |
| 4162 | * The backend should be configured at highest bit width and/or |
| 4163 | * sample rate amongst all playback usecases. |
| 4164 | * If the selected sample rate and/or bit width differ with |
| 4165 | * current backend sample rate and/or bit width, then, we set the |
| 4166 | * backend re-configuration flag. |
| 4167 | * |
Sidipotu Ashok | e6f78cb | 2015-11-05 14:42:20 +0530 | [diff] [blame] | 4168 | * Exception: 16 bit playbacks is allowed through 16 bit/48/44.1 khz backend only |
Preetam Singh Ranawat | 8bde2c5 | 2015-03-20 12:00:49 +0530 | [diff] [blame] | 4169 | */ |
Sidipotu Ashok | e6f78cb | 2015-11-05 14:42:20 +0530 | [diff] [blame] | 4170 | int i =0; |
Preetam Singh Ranawat | 8bde2c5 | 2015-03-20 12:00:49 +0530 | [diff] [blame] | 4171 | list_for_each(node, &adev->usecase_list) { |
Sidipotu Ashok | e6f78cb | 2015-11-05 14:42:20 +0530 | [diff] [blame] | 4172 | struct audio_usecase *uc; |
| 4173 | uc = node_to_item(node, struct audio_usecase, list); |
| 4174 | struct stream_out *out = (struct stream_out*) uc->stream.out; |
| 4175 | if (uc->type == PCM_PLAYBACK && out && usecase != uc) { |
Preetam Singh Ranawat | c61f867 | 2015-06-18 23:20:28 +0530 | [diff] [blame] | 4176 | |
Sidipotu Ashok | e6f78cb | 2015-11-05 14:42:20 +0530 | [diff] [blame] | 4177 | ALOGD("%s:napb: (%d) - (%s)id (%d) sr %d bw " |
| 4178 | "(%d) device %s", __func__, i++, use_case_table[uc->id], |
| 4179 | uc->id, out->sample_rate, |
| 4180 | out->bit_width, |
| 4181 | platform_get_snd_device_name(uc->out_snd_device)); |
| 4182 | |
Sidipotu Ashok | 9f0b16e | 2016-04-28 13:48:28 +0530 | [diff] [blame] | 4183 | if (platform_check_backends_match(snd_device, uc->out_snd_device)) { |
Preetam Singh Ranawat | 8bde2c5 | 2015-03-20 12:00:49 +0530 | [diff] [blame] | 4184 | if (bit_width < out->bit_width) |
| 4185 | bit_width = out->bit_width; |
| 4186 | if (sample_rate < out->sample_rate) |
| 4187 | sample_rate = out->sample_rate; |
Preetam Singh Ranawat | c61f867 | 2015-06-18 23:20:28 +0530 | [diff] [blame] | 4188 | if (out->sample_rate < OUTPUT_SAMPLING_RATE_44100) |
| 4189 | sample_rate = CODEC_BACKEND_DEFAULT_SAMPLE_RATE; |
Preetam Singh Ranawat | 8bde2c5 | 2015-03-20 12:00:49 +0530 | [diff] [blame] | 4190 | } |
| 4191 | } |
| 4192 | } |
| 4193 | } |
| 4194 | |
Sidipotu Ashok | e6f78cb | 2015-11-05 14:42:20 +0530 | [diff] [blame] | 4195 | if (audio_is_true_native_stream_active(adev)) { |
Sidipotu Ashok | ad8fff8 | 2016-02-02 10:48:42 +0530 | [diff] [blame] | 4196 | if (check_hdset_combo_device(snd_device)) { |
Sidipotu Ashok | e6f78cb | 2015-11-05 14:42:20 +0530 | [diff] [blame] | 4197 | /* |
| 4198 | * In true native mode Tasha has a limitation that one port at 44.1 khz |
| 4199 | * cannot drive both spkr and hdset, to simiplify the solution lets |
| 4200 | * move the AFE to 48khzwhen a ring tone selects combo device. |
| 4201 | */ |
Preetam Singh Ranawat | c61f867 | 2015-06-18 23:20:28 +0530 | [diff] [blame] | 4202 | sample_rate = CODEC_BACKEND_DEFAULT_SAMPLE_RATE; |
Sidipotu Ashok | e6f78cb | 2015-11-05 14:42:20 +0530 | [diff] [blame] | 4203 | bit_width = CODEC_BACKEND_DEFAULT_BIT_WIDTH; |
| 4204 | ALOGD("%s:becf: afe: port has to run at 48k for a combo device", |
| 4205 | __func__); |
| 4206 | } else { |
| 4207 | /* |
| 4208 | * in single BE mode, if native audio playback |
| 4209 | * is active then it will take priority |
| 4210 | */ |
| 4211 | sample_rate = OUTPUT_SAMPLING_RATE_44100; |
| 4212 | ALOGD("%s:becf: afe: napb active set rate to 44.1 khz", |
| 4213 | __func__); |
Preetam Singh Ranawat | c61f867 | 2015-06-18 23:20:28 +0530 | [diff] [blame] | 4214 | } |
Preetam Singh Ranawat | 8bde2c5 | 2015-03-20 12:00:49 +0530 | [diff] [blame] | 4215 | } |
Ashish Jain | b449be3 | 2015-07-19 05:39:23 -0700 | [diff] [blame] | 4216 | |
Sidipotu Ashok | e6f78cb | 2015-11-05 14:42:20 +0530 | [diff] [blame] | 4217 | /* |
Sidipotu Ashok | fdd505a | 2016-02-11 10:31:38 +0530 | [diff] [blame] | 4218 | * hifi playback not supported on spkr devices, limit the Sample Rate |
| 4219 | * to 48 khz. |
Sidipotu Ashok | e6f78cb | 2015-11-05 14:42:20 +0530 | [diff] [blame] | 4220 | */ |
Sidipotu Ashok | 9f0b16e | 2016-04-28 13:48:28 +0530 | [diff] [blame] | 4221 | if (SND_DEVICE_OUT_SPEAKER == snd_device || |
| 4222 | SND_DEVICE_OUT_SPEAKER_WSA == snd_device || |
| 4223 | SND_DEVICE_OUT_SPEAKER_VBAT == snd_device) { |
Sidipotu Ashok | e6f78cb | 2015-11-05 14:42:20 +0530 | [diff] [blame] | 4224 | sample_rate = CODEC_BACKEND_DEFAULT_SAMPLE_RATE; |
Sidipotu Ashok | 9f0b16e | 2016-04-28 13:48:28 +0530 | [diff] [blame] | 4225 | ALOGD("%s:becf: afe: playback on speaker device Configure afe to " |
| 4226 | "default Sample Rate(48k)", __func__); |
Sidipotu Ashok | e6f78cb | 2015-11-05 14:42:20 +0530 | [diff] [blame] | 4227 | } |
| 4228 | |
| 4229 | /* |
| 4230 | * native playback is not enabled.Configure afe to default Sample Rate(48k) |
| 4231 | */ |
| 4232 | if (NATIVE_AUDIO_MODE_INVALID == na_mode && |
| 4233 | OUTPUT_SAMPLING_RATE_44100 == sample_rate) { |
| 4234 | sample_rate = CODEC_BACKEND_DEFAULT_SAMPLE_RATE; |
| 4235 | ALOGD("%s:becf: afe: napb not active - set (48k) default rate", |
| 4236 | __func__); |
| 4237 | } |
| 4238 | |
Ashish Jain | b449be3 | 2015-07-19 05:39:23 -0700 | [diff] [blame] | 4239 | /* |
Venkata Narendra Kumar Gutta | 4bd09d0 | 2016-01-29 15:31:04 +0530 | [diff] [blame] | 4240 | * reset the sample rate to default value(48K), if hifi audio is not supported |
Ashish Jain | b449be3 | 2015-07-19 05:39:23 -0700 | [diff] [blame] | 4241 | */ |
Venkata Narendra Kumar Gutta | 4bd09d0 | 2016-01-29 15:31:04 +0530 | [diff] [blame] | 4242 | if (!my_data->hifi_audio) { |
Sidipotu Ashok | 9f0b16e | 2016-04-28 13:48:28 +0530 | [diff] [blame] | 4243 | ALOGD("%s:becf: afe: only 48KHZ sample rate is supported " |
| 4244 | "Configure afe to default Sample Rate(48k)", __func__); |
Venkata Narendra Kumar Gutta | 4bd09d0 | 2016-01-29 15:31:04 +0530 | [diff] [blame] | 4245 | sample_rate = CODEC_BACKEND_DEFAULT_SAMPLE_RATE; |
Sidipotu Ashok | e6f78cb | 2015-11-05 14:42:20 +0530 | [diff] [blame] | 4246 | } |
Ashish Jain | b449be3 | 2015-07-19 05:39:23 -0700 | [diff] [blame] | 4247 | |
Mingming Yin | ddd610b | 2016-01-20 17:09:32 -0800 | [diff] [blame] | 4248 | if (backend_idx == HDMI_RX_BACKEND) { |
| 4249 | //Check EDID info for supported samplerate |
| 4250 | if (!edid_is_supported_sr(edid_info,sample_rate)) { |
| 4251 | //reset to current sample rate |
| 4252 | sample_rate = my_data->current_backend_cfg[backend_idx].sample_rate; |
| 4253 | } |
| 4254 | //Check EDID info for supported bit widhth |
| 4255 | if (!edid_is_supported_bps(edid_info,bit_width)) { |
| 4256 | //reset to current sample rate |
| 4257 | bit_width = my_data->current_backend_cfg[backend_idx].bit_width; |
| 4258 | } |
| 4259 | } |
| 4260 | |
Manish Dewangan | 837dc46 | 2015-05-27 10:17:41 +0530 | [diff] [blame] | 4261 | //check if mulitchannel clip needs to be down sampled to 48k |
| 4262 | property_get("audio.playback.mch.downsample",value,""); |
| 4263 | if (!strncmp("true", value, sizeof("true"))) { |
| 4264 | out = usecase->stream.out; |
| 4265 | if ((popcount(out->channel_mask) > 2) && |
| 4266 | (out->sample_rate > CODEC_BACKEND_DEFAULT_SAMPLE_RATE) && |
| 4267 | !(out->flags & AUDIO_OUTPUT_FLAG_COMPRESS_PASSTHROUGH)) { |
| 4268 | sample_rate = CODEC_BACKEND_DEFAULT_SAMPLE_RATE; |
| 4269 | /* update out sample rate to reflect current backend sample rate */ |
| 4270 | out->sample_rate = sample_rate; |
| 4271 | ALOGD("%s: MCH session defaulting sample rate to %d", |
| 4272 | __func__, sample_rate); |
| 4273 | } |
| 4274 | } |
| 4275 | |
Kuirong Wang | a9f7cee | 2016-03-07 11:21:52 -0800 | [diff] [blame] | 4276 | if (backend_idx == USB_AUDIO_RX_BACKEND) { |
| 4277 | unsigned int channels = audio_channel_count_from_out_mask(usecase->stream.out->channel_mask); |
| 4278 | audio_extn_usb_is_config_supported(&bit_width, &sample_rate, channels); |
| 4279 | ALOGV("%s: USB BE configured as bit_width(%d)sample_rate(%d)channels(%d)", |
| 4280 | __func__, bit_width, sample_rate, channels); |
| 4281 | } |
| 4282 | |
Sidipotu Ashok | e6f78cb | 2015-11-05 14:42:20 +0530 | [diff] [blame] | 4283 | ALOGI("%s:becf: afe: Codec selected backend: %d updated bit width: %d and sample rate: %d", |
| 4284 | __func__, |
| 4285 | backend_idx, bit_width, sample_rate); |
Preetam Singh Ranawat | 8bde2c5 | 2015-03-20 12:00:49 +0530 | [diff] [blame] | 4286 | // Force routing if the expected bitwdith or samplerate |
| 4287 | // is not same as current backend comfiguration |
Preetam Singh Ranawat | c61f867 | 2015-06-18 23:20:28 +0530 | [diff] [blame] | 4288 | if ((bit_width != my_data->current_backend_cfg[backend_idx].bit_width) || |
| 4289 | (sample_rate != my_data->current_backend_cfg[backend_idx].sample_rate)) { |
Preetam Singh Ranawat | 8bde2c5 | 2015-03-20 12:00:49 +0530 | [diff] [blame] | 4290 | *new_bit_width = bit_width; |
| 4291 | *new_sample_rate = sample_rate; |
| 4292 | backend_change = true; |
Sidipotu Ashok | e6f78cb | 2015-11-05 14:42:20 +0530 | [diff] [blame] | 4293 | ALOGI("%s:becf: afe: Codec backend needs to be updated. new bit width: %d new sample rate: %d", |
| 4294 | __func__, |
| 4295 | *new_bit_width, *new_sample_rate); |
Preetam Singh Ranawat | 8bde2c5 | 2015-03-20 12:00:49 +0530 | [diff] [blame] | 4296 | } |
| 4297 | |
| 4298 | return backend_change; |
| 4299 | } |
| 4300 | |
Apoorv Raghuvanshi | 2149216 | 2015-02-19 18:19:36 -0800 | [diff] [blame] | 4301 | bool platform_check_and_set_codec_backend_cfg(struct audio_device* adev, |
Preetam Singh Ranawat | c61f867 | 2015-06-18 23:20:28 +0530 | [diff] [blame] | 4302 | struct audio_usecase *usecase, snd_device_t snd_device) |
Preetam Singh Ranawat | 8bde2c5 | 2015-03-20 12:00:49 +0530 | [diff] [blame] | 4303 | { |
Preetam Singh Ranawat | c61f867 | 2015-06-18 23:20:28 +0530 | [diff] [blame] | 4304 | unsigned int new_bit_width; |
| 4305 | unsigned int new_sample_rate; |
| 4306 | int backend_idx = DEFAULT_CODEC_BACKEND; |
Sidipotu Ashok | 9f0b16e | 2016-04-28 13:48:28 +0530 | [diff] [blame] | 4307 | int new_snd_devices[SND_DEVICE_OUT_END]; |
| 4308 | int i, num_devices = 1; |
| 4309 | bool ret = false; |
Ashish Jain | 5106d36 | 2016-05-11 19:23:33 +0530 | [diff] [blame] | 4310 | audio_format_t format; |
Preetam Singh Ranawat | 8bde2c5 | 2015-03-20 12:00:49 +0530 | [diff] [blame] | 4311 | |
Preetam Singh Ranawat | c61f867 | 2015-06-18 23:20:28 +0530 | [diff] [blame] | 4312 | backend_idx = platform_get_backend_index(snd_device); |
Preetam Singh Ranawat | 8bde2c5 | 2015-03-20 12:00:49 +0530 | [diff] [blame] | 4313 | |
Preetam Singh Ranawat | c61f867 | 2015-06-18 23:20:28 +0530 | [diff] [blame] | 4314 | new_bit_width = usecase->stream.out->bit_width; |
| 4315 | new_sample_rate = usecase->stream.out->sample_rate; |
Ashish Jain | 5106d36 | 2016-05-11 19:23:33 +0530 | [diff] [blame] | 4316 | format = usecase->stream.out->format; |
Preetam Singh Ranawat | c61f867 | 2015-06-18 23:20:28 +0530 | [diff] [blame] | 4317 | |
Sidipotu Ashok | e6f78cb | 2015-11-05 14:42:20 +0530 | [diff] [blame] | 4318 | ALOGI("%s:becf: afe: bitwidth %d, samplerate %d" |
| 4319 | ", backend_idx %d usecase = %d device (%s)", __func__, new_bit_width, |
| 4320 | new_sample_rate, backend_idx, usecase->id, |
| 4321 | platform_get_snd_device_name(snd_device)); |
Sidipotu Ashok | 9f0b16e | 2016-04-28 13:48:28 +0530 | [diff] [blame] | 4322 | |
| 4323 | if (!platform_can_split_snd_device(adev->platform, snd_device, |
| 4324 | &num_devices, new_snd_devices)) |
| 4325 | new_snd_devices[0] = snd_device; |
| 4326 | |
| 4327 | for (i = 0; i < num_devices; i++) { |
| 4328 | ALOGI("%s: becf: new_snd_devices[%d] is %s", __func__, i, |
| 4329 | platform_get_snd_device_name(new_snd_devices[i])); |
| 4330 | if (platform_check_codec_backend_cfg(adev, usecase, new_snd_devices[i], |
| 4331 | &new_bit_width, &new_sample_rate)) { |
| 4332 | platform_set_codec_backend_cfg(adev, new_snd_devices[i], |
Ashish Jain | 5106d36 | 2016-05-11 19:23:33 +0530 | [diff] [blame] | 4333 | new_bit_width, new_sample_rate, format); |
Sidipotu Ashok | 9f0b16e | 2016-04-28 13:48:28 +0530 | [diff] [blame] | 4334 | ret = true; |
| 4335 | } |
Preetam Singh Ranawat | 8bde2c5 | 2015-03-20 12:00:49 +0530 | [diff] [blame] | 4336 | } |
| 4337 | |
Sidipotu Ashok | 9f0b16e | 2016-04-28 13:48:28 +0530 | [diff] [blame] | 4338 | return ret; |
Preetam Singh Ranawat | 8bde2c5 | 2015-03-20 12:00:49 +0530 | [diff] [blame] | 4339 | } |
| 4340 | |
Manish Dewangan | ba9fcfa | 2016-03-24 16:20:06 +0530 | [diff] [blame] | 4341 | /* |
| 4342 | * configures afe with bit width and Sample Rate |
| 4343 | */ |
| 4344 | |
| 4345 | int platform_set_capture_codec_backend_cfg(struct audio_device* adev, |
| 4346 | snd_device_t snd_device, |
| 4347 | unsigned int bit_width, unsigned int sample_rate, |
| 4348 | audio_format_t format) |
| 4349 | { |
| 4350 | int ret = 0; |
| 4351 | int backend_idx = DEFAULT_CODEC_BACKEND; |
| 4352 | struct platform_data *my_data = (struct platform_data *)adev->platform; |
| 4353 | |
| 4354 | ALOGI("%s:txbecf: afe: bitwidth %d, samplerate %d, backend_idx %d device (%s)", |
| 4355 | __func__, bit_width, sample_rate, backend_idx, |
| 4356 | platform_get_snd_device_name(snd_device)); |
| 4357 | |
| 4358 | if (bit_width != |
| 4359 | my_data->current_tx_backend_cfg[backend_idx].bit_width) { |
| 4360 | |
| 4361 | struct mixer_ctl *ctl = NULL; |
| 4362 | ctl = mixer_get_ctl_by_name(adev->mixer, |
| 4363 | my_data->current_tx_backend_cfg[backend_idx].bitwidth_mixer_ctl); |
| 4364 | if (!ctl) { |
| 4365 | ALOGE("%s:txbecf: afe: Could not get ctl for mixer command - %s", |
| 4366 | __func__, |
| 4367 | my_data->current_tx_backend_cfg[backend_idx].bitwidth_mixer_ctl); |
| 4368 | return -EINVAL; |
| 4369 | } |
| 4370 | |
| 4371 | if (bit_width == 24) { |
| 4372 | if (format == AUDIO_FORMAT_PCM_24_BIT_PACKED) |
| 4373 | ret = mixer_ctl_set_enum_by_string(ctl, "S24_3LE"); |
| 4374 | else |
| 4375 | ret = mixer_ctl_set_enum_by_string(ctl, "S24_LE"); |
| 4376 | } else { |
| 4377 | ret = mixer_ctl_set_enum_by_string(ctl, "S16_LE"); |
| 4378 | } |
| 4379 | |
| 4380 | if (ret < 0) { |
| 4381 | ALOGE("%s:txbecf: afe: Could not set ctl for mixer command - %s", |
| 4382 | __func__, |
| 4383 | my_data->current_tx_backend_cfg[backend_idx].bitwidth_mixer_ctl); |
| 4384 | return -EINVAL; |
| 4385 | } |
| 4386 | |
| 4387 | my_data->current_tx_backend_cfg[backend_idx].bit_width = bit_width; |
| 4388 | ALOGD("%s:txbecf: afe: %s mixer set to %d bit", __func__, |
| 4389 | my_data->current_tx_backend_cfg[backend_idx].bitwidth_mixer_ctl, bit_width); |
| 4390 | } |
| 4391 | |
| 4392 | /* |
| 4393 | * Backend sample rate configuration follows: |
| 4394 | * 16 bit record - 48khz for streams at any valid sample rate |
| 4395 | * 24 bit record - 48khz for stream sample rate less than 48khz |
| 4396 | * 24 bit record - 96khz for sample rate range of 48khz to 96khz |
| 4397 | * 24 bit record - 192khz for sample rate range of 96khz to 192 khz |
| 4398 | * Upper limit is inclusive in the sample rate range. |
| 4399 | */ |
| 4400 | // TODO: This has to be more dynamic based on policy file |
| 4401 | |
| 4402 | if (sample_rate != my_data->current_tx_backend_cfg[(int)backend_idx].sample_rate) { |
| 4403 | /* |
| 4404 | * sample rate update is needed only for hifi audio enabled platforms |
| 4405 | */ |
| 4406 | char *rate_str = NULL; |
| 4407 | struct mixer_ctl *ctl = NULL; |
| 4408 | |
| 4409 | switch (sample_rate) { |
| 4410 | case 8000: |
| 4411 | case 11025: |
| 4412 | case 16000: |
| 4413 | case 22050: |
| 4414 | case 32000: |
| 4415 | case 44100: |
| 4416 | case 48000: |
| 4417 | rate_str = "KHZ_48"; |
| 4418 | break; |
| 4419 | case 64000: |
| 4420 | case 88200: |
| 4421 | case 96000: |
| 4422 | rate_str = "KHZ_96"; |
| 4423 | break; |
| 4424 | case 176400: |
| 4425 | case 192000: |
| 4426 | rate_str = "KHZ_192"; |
| 4427 | break; |
| 4428 | default: |
| 4429 | rate_str = "KHZ_48"; |
| 4430 | break; |
| 4431 | } |
| 4432 | |
| 4433 | ctl = mixer_get_ctl_by_name(adev->mixer, |
| 4434 | my_data->current_tx_backend_cfg[backend_idx].samplerate_mixer_ctl); |
| 4435 | |
| 4436 | if (ctl < 0) { |
| 4437 | ALOGE("%s:txbecf: afe: Could not get ctl to set the Sample Rate for mixer command - %s", |
| 4438 | __func__, |
| 4439 | my_data->current_tx_backend_cfg[backend_idx].samplerate_mixer_ctl); |
| 4440 | return -EINVAL; |
| 4441 | } |
| 4442 | |
| 4443 | ALOGD("%s:txbecf: afe: %s set to %s", __func__, |
| 4444 | my_data->current_tx_backend_cfg[backend_idx].samplerate_mixer_ctl, |
| 4445 | rate_str); |
| 4446 | ret = mixer_ctl_set_enum_by_string(ctl, rate_str); |
| 4447 | if (ret < 0) { |
| 4448 | ALOGE("%s:txbecf: afe: Could not set ctl for mixer command - %s", |
| 4449 | __func__, |
| 4450 | my_data->current_tx_backend_cfg[backend_idx].samplerate_mixer_ctl); |
| 4451 | return -EINVAL; |
| 4452 | } |
| 4453 | |
| 4454 | my_data->current_tx_backend_cfg[backend_idx].sample_rate = sample_rate; |
| 4455 | } |
| 4456 | |
| 4457 | return ret; |
| 4458 | } |
| 4459 | |
| 4460 | /* |
| 4461 | * goes through all the current usecases and picks the highest |
| 4462 | * bitwidth & samplerate |
| 4463 | */ |
| 4464 | bool platform_check_capture_codec_backend_cfg(struct audio_device* adev, |
| 4465 | unsigned int* new_bit_width, |
| 4466 | unsigned int* new_sample_rate) |
| 4467 | { |
| 4468 | bool backend_change = false; |
| 4469 | unsigned int bit_width; |
| 4470 | unsigned int sample_rate; |
| 4471 | int backend_idx = DEFAULT_CODEC_BACKEND; |
| 4472 | struct platform_data *my_data = (struct platform_data *)adev->platform; |
| 4473 | |
| 4474 | bit_width = *new_bit_width; |
| 4475 | sample_rate = *new_sample_rate; |
| 4476 | |
| 4477 | ALOGI("%s:txbecf: afe: Codec selected backend: %d current bit width: %d and " |
| 4478 | "sample rate: %d",__func__,backend_idx, bit_width, sample_rate); |
| 4479 | |
| 4480 | // For voice calls use default configuration i.e. 16b/48K, only applicable to |
| 4481 | // default backend |
| 4482 | // force routing is not required here, caller will do it anyway |
| 4483 | if ((voice_is_in_call(adev) || adev->mode == AUDIO_MODE_IN_COMMUNICATION) || |
| 4484 | (!is_external_codec)) { |
| 4485 | ALOGW("%s:txbecf: afe:Use default bw and sr for voice/voip calls", |
| 4486 | __func__); |
| 4487 | bit_width = CODEC_BACKEND_DEFAULT_BIT_WIDTH; |
| 4488 | sample_rate = CODEC_BACKEND_DEFAULT_SAMPLE_RATE; |
| 4489 | } |
| 4490 | |
| 4491 | ALOGI("%s:txbecf: afe: Codec selected backend: %d updated bit width: %d and " |
| 4492 | "sample rate: %d", __func__, backend_idx, bit_width, sample_rate); |
| 4493 | // Force routing if the expected bitwdith or samplerate |
| 4494 | // is not same as current backend comfiguration |
| 4495 | if ((bit_width != my_data->current_tx_backend_cfg[backend_idx].bit_width) || |
| 4496 | (sample_rate != my_data->current_tx_backend_cfg[backend_idx].sample_rate)) { |
| 4497 | *new_bit_width = bit_width; |
| 4498 | *new_sample_rate = sample_rate; |
| 4499 | backend_change = true; |
| 4500 | ALOGI("%s:txbecf: afe: Codec backend needs to be updated. new bit width: %d " |
| 4501 | "new sample rate: %d", __func__, *new_bit_width, *new_sample_rate); |
| 4502 | } |
| 4503 | |
| 4504 | return backend_change; |
| 4505 | } |
| 4506 | |
| 4507 | bool platform_check_and_set_capture_codec_backend_cfg(struct audio_device* adev, |
| 4508 | struct audio_usecase *usecase, snd_device_t snd_device) |
| 4509 | { |
| 4510 | unsigned int new_bit_width; |
| 4511 | unsigned int new_sample_rate; |
| 4512 | audio_format_t format = AUDIO_FORMAT_PCM_16_BIT; |
| 4513 | int backend_idx = DEFAULT_CODEC_BACKEND; |
| 4514 | int ret = 0; |
| 4515 | |
| 4516 | if(usecase->type == PCM_CAPTURE) { |
| 4517 | new_sample_rate = usecase->stream.in->sample_rate; |
| 4518 | new_bit_width = usecase->stream.in->bit_width; |
| 4519 | format = usecase->stream.in->format; |
| 4520 | } else { |
| 4521 | new_bit_width = CODEC_BACKEND_DEFAULT_BIT_WIDTH; |
| 4522 | new_sample_rate = CODEC_BACKEND_DEFAULT_SAMPLE_RATE; |
| 4523 | } |
| 4524 | |
| 4525 | ALOGI("%s:txbecf: afe: bitwidth %d, samplerate %d" |
| 4526 | ", backend_idx %d usecase = %d device (%s)", __func__, new_bit_width, |
| 4527 | new_sample_rate, backend_idx, usecase->id, |
| 4528 | platform_get_snd_device_name(snd_device)); |
| 4529 | if (platform_check_capture_codec_backend_cfg(adev, &new_bit_width, |
| 4530 | &new_sample_rate)) { |
| 4531 | ret = platform_set_capture_codec_backend_cfg(adev, snd_device, |
| 4532 | new_bit_width, new_sample_rate, format); |
| 4533 | if(!ret) |
| 4534 | return true; |
| 4535 | } |
| 4536 | |
| 4537 | return false; |
| 4538 | } |
| 4539 | |
Sidipotu Ashok | 9f0b16e | 2016-04-28 13:48:28 +0530 | [diff] [blame] | 4540 | int platform_set_snd_device_backend(snd_device_t device, const char *backend_tag, |
| 4541 | const char * hw_interface) |
Preetam Singh Ranawat | 8bde2c5 | 2015-03-20 12:00:49 +0530 | [diff] [blame] | 4542 | { |
| 4543 | int ret = 0; |
| 4544 | |
| 4545 | if ((device < SND_DEVICE_MIN) || (device >= SND_DEVICE_MAX)) { |
| 4546 | ALOGE("%s: Invalid snd_device = %d", |
| 4547 | __func__, device); |
| 4548 | ret = -EINVAL; |
| 4549 | goto done; |
| 4550 | } |
| 4551 | |
Sidipotu Ashok | 9f0b16e | 2016-04-28 13:48:28 +0530 | [diff] [blame] | 4552 | ALOGD("%s: backend_tag_table[%s]: old = %s new = %s", __func__, |
| 4553 | platform_get_snd_device_name(device), |
| 4554 | backend_tag_table[device] != NULL ? backend_tag_table[device]: "null", |
| 4555 | backend_tag); |
| 4556 | if (backend_tag_table[device]) { |
| 4557 | free(backend_tag_table[device]); |
Preetam Singh Ranawat | 8bde2c5 | 2015-03-20 12:00:49 +0530 | [diff] [blame] | 4558 | } |
Sidipotu Ashok | 9f0b16e | 2016-04-28 13:48:28 +0530 | [diff] [blame] | 4559 | backend_tag_table[device] = strdup(backend_tag); |
| 4560 | |
| 4561 | if (hw_interface != NULL) { |
| 4562 | if (hw_interface_table[device]) |
| 4563 | free(hw_interface_table[device]); |
| 4564 | |
| 4565 | ALOGD("%s: hw_interface_table[%d] = %s", __func__, device, hw_interface); |
| 4566 | hw_interface_table[device] = strdup(hw_interface); |
| 4567 | } |
Preetam Singh Ranawat | 8bde2c5 | 2015-03-20 12:00:49 +0530 | [diff] [blame] | 4568 | done: |
| 4569 | return ret; |
| 4570 | } |
| 4571 | |
| 4572 | int platform_set_usecase_pcm_id(audio_usecase_t usecase, int32_t type, int32_t pcm_id) |
| 4573 | { |
| 4574 | int ret = 0; |
| 4575 | if ((usecase <= USECASE_INVALID) || (usecase >= AUDIO_USECASE_MAX)) { |
| 4576 | ALOGE("%s: invalid usecase case idx %d", __func__, usecase); |
| 4577 | ret = -EINVAL; |
| 4578 | goto done; |
| 4579 | } |
| 4580 | |
| 4581 | if ((type != 0) && (type != 1)) { |
| 4582 | ALOGE("%s: invalid usecase type", __func__); |
| 4583 | ret = -EINVAL; |
| 4584 | } |
Sidipotu Ashok | 9f0b16e | 2016-04-28 13:48:28 +0530 | [diff] [blame] | 4585 | ALOGV("%s: pcm_device_table[%d][%d] = %d", __func__, usecase, type, pcm_id); |
Preetam Singh Ranawat | 8bde2c5 | 2015-03-20 12:00:49 +0530 | [diff] [blame] | 4586 | pcm_device_table[usecase][type] = pcm_id; |
| 4587 | done: |
| 4588 | return ret; |
| 4589 | } |
| 4590 | |
Pradnya Chaphekar | 8a9dcd8 | 2014-09-09 09:49:10 -0700 | [diff] [blame] | 4591 | void platform_get_device_to_be_id_map(int **device_to_be_id, int *length) |
| 4592 | { |
Alexy Joseph | b137994 | 2016-01-29 15:49:38 -0800 | [diff] [blame] | 4593 | *device_to_be_id = (int*) msm_device_to_be_id; |
Pradnya Chaphekar | 8a9dcd8 | 2014-09-09 09:49:10 -0700 | [diff] [blame] | 4594 | *length = msm_be_id_array_len; |
| 4595 | } |
Preetam Singh Ranawat | 8bde2c5 | 2015-03-20 12:00:49 +0530 | [diff] [blame] | 4596 | int platform_set_stream_channel_map(void *platform, audio_channel_mask_t channel_mask, int snd_id) |
| 4597 | { |
| 4598 | int ret = 0; |
| 4599 | int channels = audio_channel_count_from_out_mask(channel_mask); |
Pradnya Chaphekar | 8a9dcd8 | 2014-09-09 09:49:10 -0700 | [diff] [blame] | 4600 | |
Preetam Singh Ranawat | 8bde2c5 | 2015-03-20 12:00:49 +0530 | [diff] [blame] | 4601 | char channel_map[8]; |
| 4602 | memset(channel_map, 0, sizeof(channel_map)); |
| 4603 | /* Following are all most common standard WAV channel layouts |
| 4604 | overridden by channel mask if its allowed and different */ |
| 4605 | switch (channels) { |
| 4606 | case 1: |
| 4607 | /* AUDIO_CHANNEL_OUT_MONO */ |
| 4608 | channel_map[0] = PCM_CHANNEL_FC; |
| 4609 | break; |
| 4610 | case 2: |
| 4611 | /* AUDIO_CHANNEL_OUT_STEREO */ |
| 4612 | channel_map[0] = PCM_CHANNEL_FL; |
| 4613 | channel_map[1] = PCM_CHANNEL_FR; |
| 4614 | break; |
| 4615 | case 3: |
| 4616 | /* AUDIO_CHANNEL_OUT_2POINT1 */ |
| 4617 | channel_map[0] = PCM_CHANNEL_FL; |
| 4618 | channel_map[1] = PCM_CHANNEL_FR; |
| 4619 | channel_map[2] = PCM_CHANNEL_FC; |
| 4620 | break; |
| 4621 | case 4: |
| 4622 | /* AUDIO_CHANNEL_OUT_QUAD_SIDE */ |
| 4623 | channel_map[0] = PCM_CHANNEL_FL; |
| 4624 | channel_map[1] = PCM_CHANNEL_FR; |
| 4625 | channel_map[2] = PCM_CHANNEL_LS; |
| 4626 | channel_map[3] = PCM_CHANNEL_RS; |
| 4627 | if (channel_mask == AUDIO_CHANNEL_OUT_QUAD_BACK) |
| 4628 | { |
| 4629 | channel_map[2] = PCM_CHANNEL_LB; |
| 4630 | channel_map[3] = PCM_CHANNEL_RB; |
| 4631 | } |
| 4632 | if (channel_mask == AUDIO_CHANNEL_OUT_SURROUND) |
| 4633 | { |
| 4634 | channel_map[2] = PCM_CHANNEL_FC; |
| 4635 | channel_map[3] = PCM_CHANNEL_CS; |
| 4636 | } |
| 4637 | break; |
| 4638 | case 5: |
| 4639 | /* AUDIO_CHANNEL_OUT_PENTA */ |
| 4640 | channel_map[0] = PCM_CHANNEL_FL; |
| 4641 | channel_map[1] = PCM_CHANNEL_FR; |
| 4642 | channel_map[2] = PCM_CHANNEL_FC; |
| 4643 | channel_map[3] = PCM_CHANNEL_LB; |
| 4644 | channel_map[4] = PCM_CHANNEL_RB; |
| 4645 | break; |
| 4646 | case 6: |
| 4647 | /* AUDIO_CHANNEL_OUT_5POINT1 */ |
| 4648 | channel_map[0] = PCM_CHANNEL_FL; |
| 4649 | channel_map[1] = PCM_CHANNEL_FR; |
| 4650 | channel_map[2] = PCM_CHANNEL_FC; |
| 4651 | channel_map[3] = PCM_CHANNEL_LFE; |
| 4652 | channel_map[4] = PCM_CHANNEL_LB; |
| 4653 | channel_map[5] = PCM_CHANNEL_RB; |
| 4654 | if (channel_mask == AUDIO_CHANNEL_OUT_5POINT1_SIDE) |
| 4655 | { |
| 4656 | channel_map[4] = PCM_CHANNEL_LS; |
| 4657 | channel_map[5] = PCM_CHANNEL_RS; |
| 4658 | } |
| 4659 | break; |
| 4660 | case 7: |
| 4661 | /* AUDIO_CHANNEL_OUT_6POINT1 */ |
| 4662 | channel_map[0] = PCM_CHANNEL_FL; |
| 4663 | channel_map[1] = PCM_CHANNEL_FR; |
| 4664 | channel_map[2] = PCM_CHANNEL_FC; |
| 4665 | channel_map[3] = PCM_CHANNEL_LFE; |
| 4666 | channel_map[4] = PCM_CHANNEL_LB; |
| 4667 | channel_map[5] = PCM_CHANNEL_RB; |
| 4668 | channel_map[6] = PCM_CHANNEL_CS; |
| 4669 | break; |
| 4670 | case 8: |
| 4671 | /* AUDIO_CHANNEL_OUT_7POINT1 */ |
| 4672 | channel_map[0] = PCM_CHANNEL_FL; |
| 4673 | channel_map[1] = PCM_CHANNEL_FR; |
| 4674 | channel_map[2] = PCM_CHANNEL_FC; |
| 4675 | channel_map[3] = PCM_CHANNEL_LFE; |
| 4676 | channel_map[4] = PCM_CHANNEL_LB; |
| 4677 | channel_map[5] = PCM_CHANNEL_RB; |
| 4678 | channel_map[6] = PCM_CHANNEL_LS; |
| 4679 | channel_map[7] = PCM_CHANNEL_RS; |
| 4680 | break; |
| 4681 | default: |
| 4682 | ALOGE("unsupported channels %d for setting channel map", channels); |
| 4683 | return -1; |
| 4684 | } |
| 4685 | ret = platform_set_channel_map(platform, channels, channel_map, snd_id); |
| 4686 | return ret; |
| 4687 | } |
| 4688 | |
| 4689 | int platform_get_edid_info(void *platform) |
| 4690 | { |
| 4691 | struct platform_data *my_data = (struct platform_data *)platform; |
| 4692 | struct audio_device *adev = my_data->adev; |
| 4693 | char block[MAX_SAD_BLOCKS * SAD_BLOCK_SIZE]; |
Satya Krishna Pindiproli | f1cd92b | 2016-04-14 19:05:23 +0530 | [diff] [blame] | 4694 | int ret, count; |
Preetam Singh Ranawat | 8bde2c5 | 2015-03-20 12:00:49 +0530 | [diff] [blame] | 4695 | |
| 4696 | struct mixer_ctl *ctl; |
| 4697 | char edid_data[MAX_SAD_BLOCKS * SAD_BLOCK_SIZE + 1] = {0}; |
| 4698 | edid_audio_info *info; |
| 4699 | |
| 4700 | if (my_data->edid_valid) { |
| 4701 | /* use cached edid */ |
| 4702 | return 0; |
| 4703 | } |
| 4704 | |
| 4705 | if (my_data->edid_info == NULL) { |
| 4706 | my_data->edid_info = |
| 4707 | (struct edid_audio_info *)calloc(1, sizeof(struct edid_audio_info)); |
| 4708 | } |
| 4709 | |
| 4710 | info = my_data->edid_info; |
| 4711 | |
| 4712 | ctl = mixer_get_ctl_by_name(adev->mixer, AUDIO_DATA_BLOCK_MIXER_CTL); |
| 4713 | if (!ctl) { |
| 4714 | ALOGE("%s: Could not get ctl for mixer cmd - %s", |
| 4715 | __func__, AUDIO_DATA_BLOCK_MIXER_CTL); |
| 4716 | goto fail; |
| 4717 | } |
| 4718 | |
| 4719 | mixer_ctl_update(ctl); |
| 4720 | |
| 4721 | count = mixer_ctl_get_num_values(ctl); |
| 4722 | |
| 4723 | /* Read SAD blocks, clamping the maximum size for safety */ |
| 4724 | if (count > (int)sizeof(block)) |
| 4725 | count = (int)sizeof(block); |
| 4726 | |
| 4727 | ret = mixer_ctl_get_array(ctl, block, count); |
| 4728 | if (ret != 0) { |
| 4729 | ALOGE("%s: mixer_ctl_get_array() failed to get EDID info", __func__); |
| 4730 | goto fail; |
| 4731 | } |
| 4732 | edid_data[0] = count; |
| 4733 | memcpy(&edid_data[1], block, count); |
Preetam Singh Ranawat | 8bde2c5 | 2015-03-20 12:00:49 +0530 | [diff] [blame] | 4734 | if (!edid_get_sink_caps(info, edid_data)) { |
| 4735 | ALOGE("%s: Failed to get HDMI sink capabilities", __func__); |
| 4736 | goto fail; |
| 4737 | } |
| 4738 | my_data->edid_valid = true; |
| 4739 | return 0; |
Preetam Singh Ranawat | 8bde2c5 | 2015-03-20 12:00:49 +0530 | [diff] [blame] | 4740 | fail: |
| 4741 | if (my_data->edid_info) { |
| 4742 | free(my_data->edid_info); |
| 4743 | my_data->edid_info = NULL; |
| 4744 | my_data->edid_valid = false; |
| 4745 | } |
| 4746 | ALOGE("%s: return -EINVAL", __func__); |
| 4747 | return -EINVAL; |
| 4748 | } |
| 4749 | |
| 4750 | |
| 4751 | int platform_set_channel_allocation(void *platform, int channel_alloc) |
| 4752 | { |
| 4753 | struct mixer_ctl *ctl; |
| 4754 | const char *mixer_ctl_name = "HDMI RX CA"; |
| 4755 | int ret; |
| 4756 | struct platform_data *my_data = (struct platform_data *)platform; |
| 4757 | struct audio_device *adev = my_data->adev; |
| 4758 | |
| 4759 | ctl = mixer_get_ctl_by_name(adev->mixer, mixer_ctl_name); |
| 4760 | if (!ctl) { |
| 4761 | ALOGE("%s: Could not get ctl for mixer cmd - %s", |
| 4762 | __func__, mixer_ctl_name); |
| 4763 | ret = EINVAL; |
| 4764 | } |
| 4765 | ALOGD(":%s channel allocation = 0x%x", __func__, channel_alloc); |
| 4766 | ret = mixer_ctl_set_value(ctl, 0, channel_alloc); |
| 4767 | |
| 4768 | if (ret < 0) { |
| 4769 | ALOGE("%s: Could not set ctl, error:%d ", __func__, ret); |
| 4770 | } |
| 4771 | |
| 4772 | return ret; |
| 4773 | } |
| 4774 | |
| 4775 | int platform_set_channel_map(void *platform, int ch_count, char *ch_map, int snd_id) |
| 4776 | { |
| 4777 | struct mixer_ctl *ctl; |
| 4778 | char mixer_ctl_name[44]; // max length of name is 44 as defined |
| 4779 | int ret; |
| 4780 | unsigned int i; |
| 4781 | int set_values[8] = {0}; |
Preetam Singh Ranawat | 8bde2c5 | 2015-03-20 12:00:49 +0530 | [diff] [blame] | 4782 | struct platform_data *my_data = (struct platform_data *)platform; |
| 4783 | struct audio_device *adev = my_data->adev; |
| 4784 | ALOGV("%s channel_count:%d",__func__, ch_count); |
| 4785 | if (NULL == ch_map) { |
| 4786 | ALOGE("%s: Invalid channel mapping used", __func__); |
| 4787 | return -EINVAL; |
| 4788 | } |
Satish Babu Patakokila | 624cc92 | 2015-06-17 21:21:06 +0530 | [diff] [blame] | 4789 | |
| 4790 | /* |
| 4791 | * If snd_id is greater than 0, stream channel mapping |
| 4792 | * If snd_id is below 0, typically -1, device channel mapping |
| 4793 | */ |
Preetam Singh Ranawat | 8bde2c5 | 2015-03-20 12:00:49 +0530 | [diff] [blame] | 4794 | if (snd_id >= 0) { |
Satish Babu Patakokila | 624cc92 | 2015-06-17 21:21:06 +0530 | [diff] [blame] | 4795 | snprintf(mixer_ctl_name, sizeof(mixer_ctl_name), "Playback Channel Map%d", snd_id); |
| 4796 | } else { |
| 4797 | strlcpy(mixer_ctl_name, "Playback Device Channel Map", sizeof(mixer_ctl_name)); |
Preetam Singh Ranawat | 8bde2c5 | 2015-03-20 12:00:49 +0530 | [diff] [blame] | 4798 | } |
| 4799 | |
| 4800 | ALOGD("%s mixer_ctl_name:%s", __func__, mixer_ctl_name); |
| 4801 | |
| 4802 | ctl = mixer_get_ctl_by_name(adev->mixer, mixer_ctl_name); |
| 4803 | if (!ctl) { |
| 4804 | ALOGE("%s: Could not get ctl for mixer cmd - %s", |
| 4805 | __func__, mixer_ctl_name); |
| 4806 | return -EINVAL; |
| 4807 | } |
| 4808 | for (i = 0; i< ARRAY_SIZE(set_values); i++) { |
| 4809 | set_values[i] = ch_map[i]; |
| 4810 | } |
| 4811 | |
| 4812 | ALOGD("%s: set mapping(%d %d %d %d %d %d %d %d) for channel:%d", __func__, |
| 4813 | set_values[0], set_values[1], set_values[2], set_values[3], set_values[4], |
| 4814 | set_values[5], set_values[6], set_values[7], ch_count); |
| 4815 | |
| 4816 | ret = mixer_ctl_set_array(ctl, set_values, ch_count); |
| 4817 | if (ret < 0) { |
| 4818 | ALOGE("%s: Could not set ctl, error:%d ch_count:%d", |
| 4819 | __func__, ret, ch_count); |
| 4820 | } |
| 4821 | return ret; |
| 4822 | } |
| 4823 | |
| 4824 | unsigned char platform_map_to_edid_format(int audio_format) |
| 4825 | { |
| 4826 | unsigned char format; |
| 4827 | switch (audio_format & AUDIO_FORMAT_MAIN_MASK) { |
| 4828 | case AUDIO_FORMAT_AC3: |
| 4829 | ALOGV("%s: AC3", __func__); |
| 4830 | format = AC3; |
| 4831 | break; |
| 4832 | case AUDIO_FORMAT_AAC: |
| 4833 | ALOGV("%s:AAC", __func__); |
| 4834 | format = AAC; |
| 4835 | break; |
Manish Dewangan | a6fc544 | 2015-08-24 20:30:31 +0530 | [diff] [blame] | 4836 | case AUDIO_FORMAT_AAC_ADTS: |
| 4837 | ALOGV("%s:AAC_ADTS", __func__); |
| 4838 | format = AAC; |
| 4839 | break; |
Preetam Singh Ranawat | 8bde2c5 | 2015-03-20 12:00:49 +0530 | [diff] [blame] | 4840 | case AUDIO_FORMAT_E_AC3: |
| 4841 | ALOGV("%s:E_AC3", __func__); |
| 4842 | format = DOLBY_DIGITAL_PLUS; |
| 4843 | break; |
Mingming Yin | 3a941d4 | 2016-02-17 18:08:05 -0800 | [diff] [blame] | 4844 | case AUDIO_FORMAT_DTS: |
| 4845 | ALOGV("%s:DTS", __func__); |
| 4846 | format = DTS; |
| 4847 | break; |
| 4848 | case AUDIO_FORMAT_DTS_HD: |
| 4849 | ALOGV("%s:DTS_HD", __func__); |
| 4850 | format = DTS_HD; |
| 4851 | break; |
Preetam Singh Ranawat | 8bde2c5 | 2015-03-20 12:00:49 +0530 | [diff] [blame] | 4852 | case AUDIO_FORMAT_PCM_16_BIT: |
Ashish Jain | 5106d36 | 2016-05-11 19:23:33 +0530 | [diff] [blame] | 4853 | case AUDIO_FORMAT_PCM_24_BIT_PACKED: |
| 4854 | case AUDIO_FORMAT_PCM_8_24_BIT: |
Preetam Singh Ranawat | 8bde2c5 | 2015-03-20 12:00:49 +0530 | [diff] [blame] | 4855 | ALOGV("%s:PCM", __func__); |
Mingming Yin | 3a941d4 | 2016-02-17 18:08:05 -0800 | [diff] [blame] | 4856 | format = LPCM; |
| 4857 | break; |
| 4858 | default: |
Mingming Yin | 3a941d4 | 2016-02-17 18:08:05 -0800 | [diff] [blame] | 4859 | format = -1; |
Naresh Tanniru | 20e8b02 | 2016-04-28 16:54:17 +0530 | [diff] [blame] | 4860 | ALOGE("%s:invalid format:%d", __func__,format); |
Preetam Singh Ranawat | 8bde2c5 | 2015-03-20 12:00:49 +0530 | [diff] [blame] | 4861 | break; |
| 4862 | } |
| 4863 | return format; |
| 4864 | } |
| 4865 | |
| 4866 | uint32_t platform_get_compress_passthrough_buffer_size( |
| 4867 | audio_offload_info_t* info) |
| 4868 | { |
| 4869 | uint32_t fragment_size = MIN_COMPRESS_PASSTHROUGH_FRAGMENT_SIZE; |
| 4870 | if (!info->has_video) |
| 4871 | fragment_size = MIN_COMPRESS_PASSTHROUGH_FRAGMENT_SIZE; |
| 4872 | |
| 4873 | return fragment_size; |
| 4874 | } |
| 4875 | |
| 4876 | void platform_reset_edid_info(void *platform) { |
| 4877 | |
| 4878 | ALOGV("%s:", __func__); |
| 4879 | struct platform_data *my_data = (struct platform_data *)platform; |
| 4880 | if (my_data->edid_info) { |
| 4881 | ALOGV("%s :free edid", __func__); |
| 4882 | free(my_data->edid_info); |
| 4883 | my_data->edid_info = NULL; |
| 4884 | } |
| 4885 | } |
| 4886 | |
| 4887 | bool platform_is_edid_supported_format(void *platform, int format) |
| 4888 | { |
| 4889 | struct platform_data *my_data = (struct platform_data *)platform; |
Preetam Singh Ranawat | 8bde2c5 | 2015-03-20 12:00:49 +0530 | [diff] [blame] | 4890 | edid_audio_info *info = NULL; |
Satya Krishna Pindiproli | f1cd92b | 2016-04-14 19:05:23 +0530 | [diff] [blame] | 4891 | int i, ret; |
Preetam Singh Ranawat | 8bde2c5 | 2015-03-20 12:00:49 +0530 | [diff] [blame] | 4892 | unsigned char format_id = platform_map_to_edid_format(format); |
| 4893 | |
Mingming Yin | 3a941d4 | 2016-02-17 18:08:05 -0800 | [diff] [blame] | 4894 | if (format_id <= 0) { |
| 4895 | ALOGE("%s invalid edid format mappting for :%x" ,__func__, format); |
| 4896 | return false; |
| 4897 | } |
| 4898 | |
Preetam Singh Ranawat | 8bde2c5 | 2015-03-20 12:00:49 +0530 | [diff] [blame] | 4899 | ret = platform_get_edid_info(platform); |
| 4900 | info = (edid_audio_info *)my_data->edid_info; |
| 4901 | if (ret == 0 && info != NULL) { |
| 4902 | for (i = 0; i < info->audio_blocks && i < MAX_EDID_BLOCKS; i++) { |
| 4903 | /* |
| 4904 | * To check |
| 4905 | * is there any special for CONFIG_HDMI_PASSTHROUGH_CONVERT |
| 4906 | * & DOLBY_DIGITAL_PLUS |
| 4907 | */ |
| 4908 | if (info->audio_blocks_array[i].format_id == format_id) { |
Mingming Yin | 3a941d4 | 2016-02-17 18:08:05 -0800 | [diff] [blame] | 4909 | ALOGV("%s:returns true %x", |
Preetam Singh Ranawat | 8bde2c5 | 2015-03-20 12:00:49 +0530 | [diff] [blame] | 4910 | __func__, format); |
| 4911 | return true; |
| 4912 | } |
| 4913 | } |
| 4914 | } |
Mingming Yin | 3a941d4 | 2016-02-17 18:08:05 -0800 | [diff] [blame] | 4915 | ALOGV("%s:returns false %x", |
Preetam Singh Ranawat | 8bde2c5 | 2015-03-20 12:00:49 +0530 | [diff] [blame] | 4916 | __func__, format); |
Pradnya Chaphekar | 8a9dcd8 | 2014-09-09 09:49:10 -0700 | [diff] [blame] | 4917 | return false; |
| 4918 | } |
| 4919 | |
Mingming Yin | 3a941d4 | 2016-02-17 18:08:05 -0800 | [diff] [blame] | 4920 | bool platform_is_edid_supported_sample_rate(void *platform, int sample_rate) |
| 4921 | { |
| 4922 | struct platform_data *my_data = (struct platform_data *)platform; |
Mingming Yin | 3a941d4 | 2016-02-17 18:08:05 -0800 | [diff] [blame] | 4923 | edid_audio_info *info = NULL; |
Naresh Tanniru | 20e8b02 | 2016-04-28 16:54:17 +0530 | [diff] [blame] | 4924 | int i, ret; |
Mingming Yin | 3a941d4 | 2016-02-17 18:08:05 -0800 | [diff] [blame] | 4925 | |
| 4926 | ret = platform_get_edid_info(platform); |
| 4927 | info = (edid_audio_info *)my_data->edid_info; |
| 4928 | if (ret == 0 && info != NULL) { |
| 4929 | for (i = 0; i < info->audio_blocks && i < MAX_EDID_BLOCKS; i++) { |
| 4930 | /* |
| 4931 | * To check |
| 4932 | * is there any special for CONFIG_HDMI_PASSTHROUGH_CONVERT |
| 4933 | * & DOLBY_DIGITAL_PLUS |
| 4934 | */ |
| 4935 | if (info->audio_blocks_array[i].sampling_freq == sample_rate) { |
| 4936 | ALOGV("%s: returns true %d", __func__, sample_rate); |
| 4937 | return true; |
| 4938 | } |
| 4939 | } |
| 4940 | } |
| 4941 | ALOGV("%s: returns false %d", __func__, sample_rate); |
| 4942 | |
| 4943 | return false; |
| 4944 | } |
| 4945 | |
Preetam Singh Ranawat | 8bde2c5 | 2015-03-20 12:00:49 +0530 | [diff] [blame] | 4946 | int platform_set_edid_channels_configuration(void *platform, int channels) { |
Haynes Mathew George | f4da6fe | 2014-06-20 19:14:25 -0700 | [diff] [blame] | 4947 | |
Preetam Singh Ranawat | 8bde2c5 | 2015-03-20 12:00:49 +0530 | [diff] [blame] | 4948 | struct platform_data *my_data = (struct platform_data *)platform; |
Preetam Singh Ranawat | 8bde2c5 | 2015-03-20 12:00:49 +0530 | [diff] [blame] | 4949 | edid_audio_info *info = NULL; |
Preetam Singh Ranawat | 8bde2c5 | 2015-03-20 12:00:49 +0530 | [diff] [blame] | 4950 | int channel_count = 2; |
Satya Krishna Pindiproli | f1cd92b | 2016-04-14 19:05:23 +0530 | [diff] [blame] | 4951 | int i, ret; |
Preetam Singh Ranawat | 8bde2c5 | 2015-03-20 12:00:49 +0530 | [diff] [blame] | 4952 | char default_channelMap[MAX_CHANNELS_SUPPORTED] = {0}; |
Haynes Mathew George | f4da6fe | 2014-06-20 19:14:25 -0700 | [diff] [blame] | 4953 | |
Preetam Singh Ranawat | 8bde2c5 | 2015-03-20 12:00:49 +0530 | [diff] [blame] | 4954 | ret = platform_get_edid_info(platform); |
| 4955 | info = (edid_audio_info *)my_data->edid_info; |
| 4956 | if(ret == 0 && info != NULL) { |
| 4957 | if (channels > 2) { |
Haynes Mathew George | f4da6fe | 2014-06-20 19:14:25 -0700 | [diff] [blame] | 4958 | |
Preetam Singh Ranawat | 8bde2c5 | 2015-03-20 12:00:49 +0530 | [diff] [blame] | 4959 | ALOGV("%s:able to get HDMI sink capabilities multi channel playback", |
| 4960 | __func__); |
| 4961 | for (i = 0; i < info->audio_blocks && i < MAX_EDID_BLOCKS; i++) { |
| 4962 | if (info->audio_blocks_array[i].format_id == LPCM && |
| 4963 | info->audio_blocks_array[i].channels > channel_count && |
| 4964 | info->audio_blocks_array[i].channels <= MAX_HDMI_CHANNEL_CNT) { |
| 4965 | channel_count = info->audio_blocks_array[i].channels; |
| 4966 | } |
| 4967 | } |
| 4968 | ALOGV("%s:channel_count:%d", __func__, channel_count); |
| 4969 | /* |
| 4970 | * Channel map is set for supported hdmi max channel count even |
| 4971 | * though the input channel count set on adm is less than or equal to |
| 4972 | * max supported channel count |
| 4973 | */ |
| 4974 | platform_set_channel_map(platform, channel_count, info->channel_map, -1); |
| 4975 | platform_set_channel_allocation(platform, info->channel_allocation); |
| 4976 | } else { |
| 4977 | default_channelMap[0] = PCM_CHANNEL_FL; |
| 4978 | default_channelMap[1] = PCM_CHANNEL_FR; |
| 4979 | platform_set_channel_map(platform,2,default_channelMap,-1); |
| 4980 | platform_set_channel_allocation(platform,0); |
| 4981 | } |
| 4982 | } |
Pradnya Chaphekar | 4403bd7 | 2014-09-09 09:50:01 -0700 | [diff] [blame] | 4983 | |
Pradnya Chaphekar | 4403bd7 | 2014-09-09 09:50:01 -0700 | [diff] [blame] | 4984 | return 0; |
| 4985 | } |
| 4986 | |
Preetam Singh Ranawat | 8bde2c5 | 2015-03-20 12:00:49 +0530 | [diff] [blame] | 4987 | void platform_cache_edid(void * platform) |
Pradnya Chaphekar | 4403bd7 | 2014-09-09 09:50:01 -0700 | [diff] [blame] | 4988 | { |
Preetam Singh Ranawat | 8bde2c5 | 2015-03-20 12:00:49 +0530 | [diff] [blame] | 4989 | platform_get_edid_info(platform); |
Pradnya Chaphekar | 4403bd7 | 2014-09-09 09:50:01 -0700 | [diff] [blame] | 4990 | } |
| 4991 | |
Mingming Yin | ddd610b | 2016-01-20 17:09:32 -0800 | [diff] [blame] | 4992 | void platform_invalidate_hdmi_config(void * platform) |
Pradnya Chaphekar | 4403bd7 | 2014-09-09 09:50:01 -0700 | [diff] [blame] | 4993 | { |
Preetam Singh Ranawat | 8bde2c5 | 2015-03-20 12:00:49 +0530 | [diff] [blame] | 4994 | struct platform_data *my_data = (struct platform_data *)platform; |
| 4995 | my_data->edid_valid = false; |
| 4996 | if (my_data->edid_info) { |
| 4997 | memset(my_data->edid_info, 0, sizeof(struct edid_audio_info)); |
| 4998 | } |
Mingming Yin | ddd610b | 2016-01-20 17:09:32 -0800 | [diff] [blame] | 4999 | |
| 5000 | //reset HDMI_RX_BACKEND to default values |
| 5001 | my_data->current_backend_cfg[HDMI_RX_BACKEND].sample_rate = CODEC_BACKEND_DEFAULT_SAMPLE_RATE; |
| 5002 | my_data->current_backend_cfg[HDMI_RX_BACKEND].bit_width = CODEC_BACKEND_DEFAULT_BIT_WIDTH; |
Pradnya Chaphekar | 4403bd7 | 2014-09-09 09:50:01 -0700 | [diff] [blame] | 5003 | } |
Preetam Singh Ranawat | 8bde2c5 | 2015-03-20 12:00:49 +0530 | [diff] [blame] | 5004 | |
| 5005 | int platform_set_mixer_control(struct stream_out *out, const char * mixer_ctl_name, |
| 5006 | const char *mixer_val) |
| 5007 | { |
| 5008 | struct audio_device *adev = out->dev; |
| 5009 | struct mixer_ctl *ctl = NULL; |
| 5010 | ALOGD("setting mixer ctl %s with value %s", mixer_ctl_name, mixer_val); |
| 5011 | ctl = mixer_get_ctl_by_name(adev->mixer, mixer_ctl_name); |
| 5012 | if (!ctl) { |
| 5013 | ALOGE("%s: could not get ctl for mixer cmd - %s", |
| 5014 | __func__, mixer_ctl_name); |
| 5015 | return -EINVAL; |
| 5016 | } |
| 5017 | |
| 5018 | return mixer_ctl_set_enum_by_string(ctl, mixer_val); |
| 5019 | } |
| 5020 | |
Naresh Tanniru | 20e8b02 | 2016-04-28 16:54:17 +0530 | [diff] [blame] | 5021 | static int set_mixer_control(struct mixer *mixer, |
| 5022 | const char * mixer_ctl_name, |
| 5023 | const char *mixer_val) |
| 5024 | { |
| 5025 | struct mixer_ctl *ctl; |
| 5026 | ALOGD("setting mixer ctl %s with value %s", mixer_ctl_name, mixer_val); |
| 5027 | ctl = mixer_get_ctl_by_name(mixer, mixer_ctl_name); |
| 5028 | if (!ctl) { |
| 5029 | ALOGE("%s: could not get ctl for mixer cmd - %s", |
| 5030 | __func__, mixer_ctl_name); |
| 5031 | return -EINVAL; |
| 5032 | } |
| 5033 | |
| 5034 | return mixer_ctl_set_enum_by_string(ctl, mixer_val); |
| 5035 | } |
| 5036 | |
Mingming Yin | 2185465 | 2016-04-13 11:54:02 -0700 | [diff] [blame] | 5037 | int platform_set_hdmi_config(void *platform, uint32_t channel_count, |
| 5038 | uint32_t sample_rate, bool enable_passthrough) |
Preetam Singh Ranawat | 8bde2c5 | 2015-03-20 12:00:49 +0530 | [diff] [blame] | 5039 | { |
Mingming Yin | 2185465 | 2016-04-13 11:54:02 -0700 | [diff] [blame] | 5040 | struct platform_data *my_data = (struct platform_data *)platform; |
| 5041 | struct audio_device *adev = my_data->adev; |
Preetam Singh Ranawat | 8bde2c5 | 2015-03-20 12:00:49 +0530 | [diff] [blame] | 5042 | const char *hdmi_format_ctrl = "HDMI RX Format"; |
Mingming Yin | 2185465 | 2016-04-13 11:54:02 -0700 | [diff] [blame] | 5043 | const char *hdmi_rate_ctrl = "HDMI_RX SampleRate"; |
| 5044 | const char *hdmi_chans_ctrl = "HDMI_RX Channels"; |
| 5045 | const char *channel_cnt_str = NULL; |
| 5046 | |
| 5047 | ALOGI("%s ch[%d] sr[%d], pthru[%d]", __func__, |
| 5048 | channel_count, sample_rate, enable_passthrough); |
| 5049 | |
| 5050 | switch (channel_count) { |
| 5051 | case 8: |
| 5052 | channel_cnt_str = "Eight"; break; |
| 5053 | case 7: |
| 5054 | channel_cnt_str = "Seven"; break; |
| 5055 | case 6: |
| 5056 | channel_cnt_str = "Six"; break; |
| 5057 | case 5: |
| 5058 | channel_cnt_str = "Five"; break; |
| 5059 | case 4: |
| 5060 | channel_cnt_str = "Four"; break; |
| 5061 | case 3: |
| 5062 | channel_cnt_str = "Three"; break; |
| 5063 | default: |
| 5064 | channel_cnt_str = "Two"; break; |
| 5065 | } |
| 5066 | ALOGV("%s: HDMI channel count: %s", __func__, channel_cnt_str); |
| 5067 | set_mixer_control(adev->mixer, hdmi_chans_ctrl, channel_cnt_str); |
| 5068 | |
| 5069 | if (enable_passthrough) { |
| 5070 | ALOGD("%s:HDMI compress format", __func__); |
| 5071 | set_mixer_control(adev->mixer, hdmi_format_ctrl, "Compr"); |
Preetam Singh Ranawat | 8bde2c5 | 2015-03-20 12:00:49 +0530 | [diff] [blame] | 5072 | } else { |
Mingming Yin | 2185465 | 2016-04-13 11:54:02 -0700 | [diff] [blame] | 5073 | ALOGD("%s: HDMI PCM format", __func__); |
| 5074 | set_mixer_control(adev->mixer, hdmi_format_ctrl, "LPCM"); |
Preetam Singh Ranawat | 8bde2c5 | 2015-03-20 12:00:49 +0530 | [diff] [blame] | 5075 | } |
| 5076 | |
Mingming Yin | 2185465 | 2016-04-13 11:54:02 -0700 | [diff] [blame] | 5077 | switch (sample_rate) { |
| 5078 | case 32000: |
| 5079 | set_mixer_control(adev->mixer, hdmi_rate_ctrl, "KHZ_32"); |
| 5080 | break; |
| 5081 | case 44100: |
| 5082 | set_mixer_control(adev->mixer, hdmi_rate_ctrl, "KHZ_44P1"); |
| 5083 | break; |
| 5084 | case 96000: |
| 5085 | set_mixer_control(adev->mixer, hdmi_rate_ctrl, "KHZ_96"); |
| 5086 | break; |
| 5087 | case 128000: |
| 5088 | set_mixer_control(adev->mixer, hdmi_rate_ctrl, "KHZ_128"); |
| 5089 | break; |
| 5090 | case 176400: |
| 5091 | set_mixer_control(adev->mixer, hdmi_rate_ctrl, "KHZ_176_4"); |
| 5092 | break; |
| 5093 | case 192000: |
| 5094 | set_mixer_control(adev->mixer, hdmi_rate_ctrl, "KHZ_192"); |
| 5095 | break; |
| 5096 | default: |
| 5097 | case 48000: |
| 5098 | set_mixer_control(adev->mixer, hdmi_rate_ctrl, "KHZ_48"); |
| 5099 | break; |
Preetam Singh Ranawat | 8bde2c5 | 2015-03-20 12:00:49 +0530 | [diff] [blame] | 5100 | } |
| 5101 | |
| 5102 | return 0; |
| 5103 | } |
| 5104 | |
Mingming Yin | 2185465 | 2016-04-13 11:54:02 -0700 | [diff] [blame] | 5105 | |
Preetam Singh Ranawat | 8bde2c5 | 2015-03-20 12:00:49 +0530 | [diff] [blame] | 5106 | int platform_set_device_params(struct stream_out *out, int param, int value) |
| 5107 | { |
| 5108 | struct audio_device *adev = out->dev; |
| 5109 | struct mixer_ctl *ctl; |
| 5110 | char *mixer_ctl_name = "Device PP Params"; |
| 5111 | int ret = 0; |
| 5112 | uint32_t set_values[] = {0,0}; |
| 5113 | |
| 5114 | set_values[0] = param; |
| 5115 | set_values[1] = value; |
| 5116 | |
| 5117 | ctl = mixer_get_ctl_by_name(adev->mixer, mixer_ctl_name); |
| 5118 | if (!ctl) { |
| 5119 | ALOGE("%s: Could not get ctl for mixer cmd - %s", |
| 5120 | __func__, mixer_ctl_name); |
| 5121 | ret = -EINVAL; |
| 5122 | goto end; |
| 5123 | } |
| 5124 | |
| 5125 | ALOGV("%s: Setting device pp params param: %d, value %d mixer ctrl:%s", |
| 5126 | __func__,param, value, mixer_ctl_name); |
| 5127 | mixer_ctl_set_array(ctl, set_values, ARRAY_SIZE(set_values)); |
| 5128 | |
| 5129 | end: |
| 5130 | return ret; |
| 5131 | } |
| 5132 | |
Preetam Singh Ranawat | 2d0e463 | 2015-02-02 12:40:59 +0530 | [diff] [blame] | 5133 | int platform_get_subsys_image_name(char *buf) |
| 5134 | { |
| 5135 | strlcpy(buf, PLATFORM_IMAGE_NAME, sizeof(PLATFORM_IMAGE_NAME)); |
| 5136 | return 0; |
| 5137 | } |
Narsinga Rao Chella | f928a98 | 2015-03-06 14:57:35 -0800 | [diff] [blame] | 5138 | |
Karthik Reddy Katta | e4078ed | 2015-04-21 11:46:15 +0530 | [diff] [blame] | 5139 | /* |
| 5140 | * This is a lookup table to map android audio input device to audio h/w interface (backend). |
| 5141 | * The table can be extended for other input devices by adding appropriate entries. |
Karthik Reddy Katta | 508eca4 | 2015-05-11 13:43:18 +0530 | [diff] [blame] | 5142 | * The audio interface for a particular input device need to be added in |
| 5143 | * audio_platform_info.xml file. |
Karthik Reddy Katta | e4078ed | 2015-04-21 11:46:15 +0530 | [diff] [blame] | 5144 | */ |
| 5145 | struct audio_device_to_audio_interface audio_device_to_interface_table[] = { |
Karthik Reddy Katta | 508eca4 | 2015-05-11 13:43:18 +0530 | [diff] [blame] | 5146 | {AUDIO_DEVICE_IN_BUILTIN_MIC, ENUM_TO_STRING(AUDIO_DEVICE_IN_BUILTIN_MIC), ""}, |
| 5147 | {AUDIO_DEVICE_IN_BACK_MIC, ENUM_TO_STRING(AUDIO_DEVICE_IN_BACK_MIC), ""}, |
Karthik Reddy Katta | e4078ed | 2015-04-21 11:46:15 +0530 | [diff] [blame] | 5148 | }; |
| 5149 | |
| 5150 | int audio_device_to_interface_table_len = |
| 5151 | sizeof(audio_device_to_interface_table) / sizeof(audio_device_to_interface_table[0]); |
| 5152 | |
Karthik Reddy Katta | e4078ed | 2015-04-21 11:46:15 +0530 | [diff] [blame] | 5153 | int platform_set_audio_device_interface(const char * device_name, |
Karthik Reddy Katta | 508eca4 | 2015-05-11 13:43:18 +0530 | [diff] [blame] | 5154 | const char *intf_name, |
| 5155 | const char *codec_type) |
Narsinga Rao Chella | f928a98 | 2015-03-06 14:57:35 -0800 | [diff] [blame] | 5156 | { |
Karthik Reddy Katta | e4078ed | 2015-04-21 11:46:15 +0530 | [diff] [blame] | 5157 | int ret = 0; |
| 5158 | int i; |
| 5159 | |
Karthik Reddy Katta | 508eca4 | 2015-05-11 13:43:18 +0530 | [diff] [blame] | 5160 | if (device_name == NULL || intf_name == NULL || codec_type == NULL) { |
Karthik Reddy Katta | e4078ed | 2015-04-21 11:46:15 +0530 | [diff] [blame] | 5161 | ALOGE("%s: Invalid input", __func__); |
| 5162 | |
| 5163 | ret = -EINVAL; |
| 5164 | goto done; |
| 5165 | } |
| 5166 | |
Karthik Reddy Katta | 508eca4 | 2015-05-11 13:43:18 +0530 | [diff] [blame] | 5167 | ALOGD("%s: Enter, device name:%s, intf name:%s, codec_type:%s", __func__, |
| 5168 | device_name, intf_name, codec_type); |
Karthik Reddy Katta | e4078ed | 2015-04-21 11:46:15 +0530 | [diff] [blame] | 5169 | |
| 5170 | size_t device_name_len = strlen(device_name); |
| 5171 | for (i = 0; i < audio_device_to_interface_table_len; i++) { |
| 5172 | char* name = audio_device_to_interface_table[i].device_name; |
| 5173 | size_t name_len = strlen(name); |
| 5174 | if ((name_len == device_name_len) && |
| 5175 | (strncmp(device_name, name, name_len) == 0)) { |
Karthik Reddy Katta | 508eca4 | 2015-05-11 13:43:18 +0530 | [diff] [blame] | 5176 | if (is_external_codec && |
| 5177 | (strncmp(codec_type, "external", strlen(codec_type)) == 0)) { |
| 5178 | ALOGD("%s: Matched device name:%s, overwrite intf name with %s", |
Karthik Reddy Katta | e4078ed | 2015-04-21 11:46:15 +0530 | [diff] [blame] | 5179 | __func__, device_name, intf_name); |
| 5180 | |
Karthik Reddy Katta | 508eca4 | 2015-05-11 13:43:18 +0530 | [diff] [blame] | 5181 | strlcpy(audio_device_to_interface_table[i].interface_name, intf_name, |
Karthik Reddy Katta | e4078ed | 2015-04-21 11:46:15 +0530 | [diff] [blame] | 5182 | sizeof(audio_device_to_interface_table[i].interface_name)); |
Karthik Reddy Katta | 508eca4 | 2015-05-11 13:43:18 +0530 | [diff] [blame] | 5183 | } else if (!is_external_codec && |
| 5184 | (strncmp(codec_type, "internal", strlen(codec_type)) == 0)) { |
| 5185 | ALOGD("%s: Matched device name:%s, overwrite intf name with %s", |
| 5186 | __func__, device_name, intf_name); |
| 5187 | |
| 5188 | strlcpy(audio_device_to_interface_table[i].interface_name, intf_name, |
| 5189 | sizeof(audio_device_to_interface_table[i].interface_name)); |
| 5190 | } else |
| 5191 | ALOGE("Invalid codec_type specified. Ignoring this interface entry."); |
Karthik Reddy Katta | e4078ed | 2015-04-21 11:46:15 +0530 | [diff] [blame] | 5192 | goto done; |
| 5193 | } |
| 5194 | } |
| 5195 | ALOGE("%s: Could not find matching device name %s", |
| 5196 | __func__, device_name); |
| 5197 | |
| 5198 | ret = -EINVAL; |
| 5199 | |
| 5200 | done: |
| 5201 | return ret; |
Narsinga Rao Chella | f928a98 | 2015-03-06 14:57:35 -0800 | [diff] [blame] | 5202 | } |
Laxminath Kasam | 8225243 | 2015-05-29 18:37:11 +0530 | [diff] [blame] | 5203 | |
Venkata Narendra Kumar Gutta | 7f4817f | 2016-01-29 14:15:53 +0530 | [diff] [blame] | 5204 | int platform_spkr_prot_is_wsa_analog_mode(void *adev) |
Preetam Singh Ranawat | 9519e9c | 2015-11-18 16:05:55 +0530 | [diff] [blame] | 5205 | { |
| 5206 | struct audio_device *adev_h = adev; |
Alexy Joseph | b137994 | 2016-01-29 15:49:38 -0800 | [diff] [blame] | 5207 | const char *snd_card_name; |
Preetam Singh Ranawat | 9519e9c | 2015-11-18 16:05:55 +0530 | [diff] [blame] | 5208 | |
Venkata Narendra Kumar Gutta | 7f4817f | 2016-01-29 14:15:53 +0530 | [diff] [blame] | 5209 | /* |
| 5210 | * wsa analog mode is decided based on the sound card name |
| 5211 | */ |
Preetam Singh Ranawat | 9519e9c | 2015-11-18 16:05:55 +0530 | [diff] [blame] | 5212 | snd_card_name = mixer_get_name(adev_h->mixer); |
| 5213 | if ((!strcmp(snd_card_name, "msm8952-skum-snd-card")) || |
| 5214 | (!strcmp(snd_card_name, "msm8952-snd-card")) || |
| 5215 | (!strcmp(snd_card_name, "msm8952-snd-card-mtp")) || |
Venkata Narendra Kumar Gutta | 7f4817f | 2016-01-29 14:15:53 +0530 | [diff] [blame] | 5216 | (!strcmp(snd_card_name, "msm8976-skun-snd-card")) || |
| 5217 | (!strcmp(snd_card_name, "msm8953-snd-card-mtp"))) |
Preetam Singh Ranawat | 9519e9c | 2015-11-18 16:05:55 +0530 | [diff] [blame] | 5218 | return 1; |
| 5219 | else |
| 5220 | return 0; |
| 5221 | } |
Preetam Singh Ranawat | 61716b1 | 2015-12-14 11:55:24 +0530 | [diff] [blame] | 5222 | |
| 5223 | bool platform_send_gain_dep_cal(void *platform __unused, |
| 5224 | int level __unused) |
| 5225 | { |
| 5226 | return 0; |
| 5227 | } |
Xiaojun Sang | 040cc9f | 2015-08-03 19:38:28 +0800 | [diff] [blame] | 5228 | |
| 5229 | bool platform_can_enable_spkr_prot_on_device(snd_device_t snd_device) |
| 5230 | { |
| 5231 | bool ret = false; |
| 5232 | |
| 5233 | if (snd_device == SND_DEVICE_OUT_SPEAKER || |
| 5234 | snd_device == SND_DEVICE_OUT_SPEAKER_WSA || |
| 5235 | snd_device == SND_DEVICE_OUT_SPEAKER_VBAT || |
| 5236 | snd_device == SND_DEVICE_OUT_VOICE_SPEAKER_VBAT || |
| 5237 | snd_device == SND_DEVICE_OUT_VOICE_SPEAKER || |
| 5238 | snd_device == SND_DEVICE_OUT_VOICE_SPEAKER_WSA) { |
| 5239 | ret = true; |
| 5240 | } |
| 5241 | |
| 5242 | return ret; |
| 5243 | } |
| 5244 | |
| 5245 | int platform_get_spkr_prot_acdb_id(snd_device_t snd_device) |
| 5246 | { |
| 5247 | int acdb_id; |
| 5248 | |
| 5249 | switch(snd_device) { |
| 5250 | case SND_DEVICE_OUT_SPEAKER: |
| 5251 | case SND_DEVICE_OUT_SPEAKER_WSA: |
| 5252 | acdb_id = platform_get_snd_device_acdb_id(SND_DEVICE_OUT_SPEAKER_PROTECTED); |
| 5253 | break; |
| 5254 | case SND_DEVICE_OUT_VOICE_SPEAKER: |
| 5255 | case SND_DEVICE_OUT_VOICE_SPEAKER_WSA: |
| 5256 | acdb_id = platform_get_snd_device_acdb_id(SND_DEVICE_OUT_VOICE_SPEAKER_PROTECTED); |
| 5257 | break; |
| 5258 | case SND_DEVICE_OUT_SPEAKER_VBAT: |
| 5259 | acdb_id = platform_get_snd_device_acdb_id(SND_DEVICE_OUT_SPEAKER_PROTECTED_VBAT); |
| 5260 | break; |
| 5261 | case SND_DEVICE_OUT_VOICE_SPEAKER_VBAT: |
| 5262 | acdb_id = platform_get_snd_device_acdb_id(SND_DEVICE_OUT_VOICE_SPEAKER_PROTECTED_VBAT); |
| 5263 | break; |
| 5264 | default: |
| 5265 | acdb_id = -EINVAL; |
| 5266 | break; |
| 5267 | } |
| 5268 | return acdb_id; |
| 5269 | } |
| 5270 | |
| 5271 | int platform_get_spkr_prot_snd_device(snd_device_t snd_device) |
| 5272 | { |
| 5273 | if (!audio_extn_spkr_prot_is_enabled()) |
| 5274 | return snd_device; |
| 5275 | |
| 5276 | switch(snd_device) { |
| 5277 | case SND_DEVICE_OUT_SPEAKER: |
| 5278 | case SND_DEVICE_OUT_SPEAKER_WSA: |
| 5279 | return SND_DEVICE_OUT_SPEAKER_PROTECTED; |
| 5280 | case SND_DEVICE_OUT_VOICE_SPEAKER: |
| 5281 | case SND_DEVICE_OUT_VOICE_SPEAKER_WSA: |
| 5282 | return SND_DEVICE_OUT_VOICE_SPEAKER_PROTECTED; |
| 5283 | case SND_DEVICE_OUT_SPEAKER_VBAT: |
| 5284 | return SND_DEVICE_OUT_SPEAKER_PROTECTED_VBAT; |
| 5285 | case SND_DEVICE_OUT_VOICE_SPEAKER_VBAT: |
| 5286 | return SND_DEVICE_OUT_VOICE_SPEAKER_PROTECTED_VBAT; |
| 5287 | default: |
| 5288 | return snd_device; |
| 5289 | } |
| 5290 | } |
Kuirong Wang | 1cad714 | 2016-05-24 15:21:56 -0700 | [diff] [blame] | 5291 | |
| 5292 | int platform_set_sidetone(struct audio_device *adev, |
| 5293 | snd_device_t out_snd_device, |
| 5294 | bool enable, |
| 5295 | char *str) |
| 5296 | { |
| 5297 | int ret; |
| 5298 | if (out_snd_device == SND_DEVICE_OUT_USB_HEADSET) { |
| 5299 | ret = audio_extn_usb_enable_sidetone(out_snd_device, enable); |
| 5300 | if (ret) |
| 5301 | ALOGI("%s: usb device %d does not support device sidetone\n", |
| 5302 | __func__, out_snd_device); |
| 5303 | } else { |
| 5304 | ALOGV("%s: sidetone out device(%d) mixer cmd = %s\n", |
| 5305 | __func__, out_snd_device, str); |
| 5306 | |
| 5307 | if (enable) |
| 5308 | audio_route_apply_and_update_path(adev->audio_route, str); |
| 5309 | else |
| 5310 | audio_route_reset_and_update_path(adev->audio_route, str); |
| 5311 | } |
| 5312 | return 0; |
| 5313 | } |