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