jasmine cha | 75fa6f0 | 2018-03-30 15:41:33 +0800 | [diff] [blame] | 1 | /* |
Vatsal Bucha | 7fe95a8 | 2019-05-06 15:25:58 +0530 | [diff] [blame] | 2 | * Copyright (C) 2018 The Android Open Source Project |
jasmine cha | 75fa6f0 | 2018-03-30 15:41:33 +0800 | [diff] [blame] | 3 | * |
| 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | * you may not use this file except in compliance with the License. |
| 6 | * You may obtain a copy of the License at |
| 7 | * |
| 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | * |
| 10 | * Unless required by applicable law or agreed to in writing, software |
| 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | * See the License for the specific language governing permissions and |
| 14 | * limitations under the License. |
| 15 | */ |
| 16 | |
| 17 | #define LOG_TAG "audio_hw_waves" |
| 18 | /*#define LOG_NDEBUG 0*/ |
| 19 | |
jasmine cha | 75fa6f0 | 2018-03-30 15:41:33 +0800 | [diff] [blame] | 20 | #include <audio_hw.h> |
Aalique Grahame | 5ce7fbe | 2019-01-28 12:08:13 -0800 | [diff] [blame] | 21 | #include <cutils/str_parms.h> |
| 22 | #include <dlfcn.h> |
| 23 | #include <log/log.h> |
jasmine cha | 75fa6f0 | 2018-03-30 15:41:33 +0800 | [diff] [blame] | 24 | #include <math.h> |
Aalique Grahame | 5ce7fbe | 2019-01-28 12:08:13 -0800 | [diff] [blame] | 25 | #include <platform_api.h> |
| 26 | #include <pthread.h> |
| 27 | #include <stdlib.h> |
| 28 | #include <string.h> |
| 29 | #include <system/audio.h> |
| 30 | #include <unistd.h> |
| 31 | |
jasmine cha | 75fa6f0 | 2018-03-30 15:41:33 +0800 | [diff] [blame] | 32 | #include "audio_extn.h" |
| 33 | #include "maxxaudio.h" |
| 34 | |
Aalique Grahame | 5ce7fbe | 2019-01-28 12:08:13 -0800 | [diff] [blame] | 35 | #define LIB_MA_PARAM "libmaxxaudioqdsp.so" |
jasmine cha | 75fa6f0 | 2018-03-30 15:41:33 +0800 | [diff] [blame] | 36 | #define LIB_MA_PATH "vendor/lib/" |
Aalique Grahame | 5ce7fbe | 2019-01-28 12:08:13 -0800 | [diff] [blame] | 37 | #define PRESET_PATH "/vendor/etc" |
| 38 | #define MPS_BASE_STRING "default" |
jasmine cha | 75fa6f0 | 2018-03-30 15:41:33 +0800 | [diff] [blame] | 39 | #define USER_PRESET_PATH "" |
Aalique Grahame | 5ce7fbe | 2019-01-28 12:08:13 -0800 | [diff] [blame] | 40 | #define CONFIG_BASE_STRING "maxx_conf" |
jasmine cha | 75fa6f0 | 2018-03-30 15:41:33 +0800 | [diff] [blame] | 41 | #define CAL_PRESIST_STR "cal_persist" |
| 42 | #define CAL_SAMPLERATE_STR "cal_samplerate" |
| 43 | |
Arun Mirpuri | b1bec9c | 2019-01-29 16:42:45 -0800 | [diff] [blame] | 44 | #define MA_QDSP_PARAM_INIT "maxxaudio_qdsp_initialize" |
| 45 | #define MA_QDSP_PARAM_DEINIT "maxxaudio_qdsp_uninitialize" |
justinweng | bbffa62 | 2019-01-11 14:38:06 +0800 | [diff] [blame] | 46 | #define MA_QDSP_IS_FEATURE_USED "maxxaudio_qdsp_is_feature_supported" |
Arun Mirpuri | b1bec9c | 2019-01-29 16:42:45 -0800 | [diff] [blame] | 47 | #define MA_QDSP_SET_LR_SWAP "maxxaudio_qdsp_set_lr_swap" |
justinweng | bbffa62 | 2019-01-11 14:38:06 +0800 | [diff] [blame] | 48 | #define MA_QDSP_SET_ORIENTATION "maxxaudio_qdsp_set_orientation" |
Arun Mirpuri | b1bec9c | 2019-01-29 16:42:45 -0800 | [diff] [blame] | 49 | #define MA_QDSP_SET_MODE "maxxaudio_qdsp_set_sound_mode" |
| 50 | #define MA_QDSP_SET_VOL "maxxaudio_qdsp_set_volume" |
| 51 | #define MA_QDSP_SET_VOLT "maxxaudio_qdsp_set_volume_table" |
| 52 | #define MA_QDSP_SET_PARAM "maxxaudio_qdsp_set_parameter" |
justinweng | d539515 | 2019-11-04 12:23:09 +0800 | [diff] [blame] | 53 | #define MA_QDSP_SET_COMMAND "maxxaudio_qdsp_set_command" |
| 54 | #define MA_QDSP_GET_COMMAND "maxxaudio_qdsp_get_command" |
jasmine cha | 75fa6f0 | 2018-03-30 15:41:33 +0800 | [diff] [blame] | 55 | |
Arun Mirpuri | b1bec9c | 2019-01-29 16:42:45 -0800 | [diff] [blame] | 56 | #define SUPPORT_DEV "18d1:5033" // Blackbird usbid |
Aalique Grahame | 5ce7fbe | 2019-01-28 12:08:13 -0800 | [diff] [blame] | 57 | #define SUPPORTED_USB 0x01 |
jasmine cha | 75fa6f0 | 2018-03-30 15:41:33 +0800 | [diff] [blame] | 58 | |
justinweng | d539515 | 2019-11-04 12:23:09 +0800 | [diff] [blame] | 59 | #define WAVES_COMMAND_SIZE 10240 |
| 60 | |
Arun Mirpuri | b1bec9c | 2019-01-29 16:42:45 -0800 | [diff] [blame] | 61 | typedef unsigned int effective_scope_flag_t; |
| 62 | const effective_scope_flag_t EFFECTIVE_SCOPE_RTC = 1 << 0; /* RTC */ |
| 63 | const effective_scope_flag_t EFFECTIVE_SCOPE_ACDB = 1 << 1; /* ACDB */ |
| 64 | const effective_scope_flag_t EFFECTIVE_SCOPE_ALL = EFFECTIVE_SCOPE_RTC | EFFECTIVE_SCOPE_ACDB; |
| 65 | const effective_scope_flag_t EFFECTIVE_SCOPE_NONE = 0; |
| 66 | const effective_scope_flag_t EFFECTIVE_SCOPE_DEFAULT = EFFECTIVE_SCOPE_NONE; |
jasmine cha | 75fa6f0 | 2018-03-30 15:41:33 +0800 | [diff] [blame] | 67 | |
Arun Mirpuri | b1bec9c | 2019-01-29 16:42:45 -0800 | [diff] [blame] | 68 | const unsigned int AUDIO_CAL_SETTINGS_VERSION_MAJOR = 2; |
| 69 | const unsigned int AUDIO_CAL_SETTINGS_VERSION_MINOR = 0; |
| 70 | const unsigned int AUDIO_CAL_SETTINGS_VERSION_MAJOR_DEFAULT = AUDIO_CAL_SETTINGS_VERSION_MAJOR; |
| 71 | const unsigned int AUDIO_CAL_SETTINGS_VERSION_MINOR_DEFAULT = AUDIO_CAL_SETTINGS_VERSION_MINOR; |
| 72 | |
| 73 | const unsigned int VALUE_AUTO = 0xFFFFFFFF; |
| 74 | const unsigned int APP_TYPE_AUTO = VALUE_AUTO; |
| 75 | const unsigned int APP_TYPE_DEFAULT = APP_TYPE_AUTO; |
| 76 | const unsigned int DEVICE_AUTO = VALUE_AUTO; |
| 77 | const unsigned int DEVICE_DEFAULT = DEVICE_AUTO; |
| 78 | |
| 79 | const unsigned int MAAP_OUTPUT_GAIN = 27; |
jasmine cha | 75fa6f0 | 2018-03-30 15:41:33 +0800 | [diff] [blame] | 80 | |
| 81 | typedef enum MA_STREAM_TYPE { |
Arun Mirpuri | b1bec9c | 2019-01-29 16:42:45 -0800 | [diff] [blame] | 82 | STREAM_MIN_TYPES = 0, |
| 83 | STREAM_VOICE = STREAM_MIN_TYPES, |
jasmine cha | 75fa6f0 | 2018-03-30 15:41:33 +0800 | [diff] [blame] | 84 | STREAM_SYSTEM, |
| 85 | STREAM_RING, |
| 86 | STREAM_MUSIC, |
| 87 | STREAM_ALARM, |
| 88 | STREAM_NOTIFICATION , |
| 89 | STREAM_MAX_TYPES, |
| 90 | } ma_stream_type_t; |
| 91 | |
| 92 | typedef enum MA_CMD { |
| 93 | MA_CMD_VOL, |
| 94 | MA_CMD_SWAP_ENABLE, |
| 95 | MA_CMD_SWAP_DISABLE, |
justinweng | bbffa62 | 2019-01-11 14:38:06 +0800 | [diff] [blame] | 96 | MA_CMD_ROTATE_ENABLE, |
| 97 | MA_CMD_ROTATE_DISABLE, |
jasmine cha | 75fa6f0 | 2018-03-30 15:41:33 +0800 | [diff] [blame] | 98 | } ma_cmd_t; |
| 99 | |
Arun Mirpuri | b1bec9c | 2019-01-29 16:42:45 -0800 | [diff] [blame] | 100 | typedef struct ma_audio_cal_version { |
| 101 | unsigned int major; |
| 102 | unsigned int minor; |
| 103 | } ma_audio_cal_version_t; |
| 104 | |
| 105 | typedef struct ma_audio_cal_common_settings { |
| 106 | unsigned int app_type; |
Aniket Kumar Lata | 0e6e1e5 | 2019-11-14 21:43:55 -0800 | [diff] [blame] | 107 | struct listnode devices; |
Arun Mirpuri | b1bec9c | 2019-01-29 16:42:45 -0800 | [diff] [blame] | 108 | } ma_audio_cal_common_settings_t; |
| 109 | |
| 110 | struct ma_audio_cal_settings { |
| 111 | ma_audio_cal_version_t version; |
| 112 | ma_audio_cal_common_settings_t common; |
| 113 | effective_scope_flag_t effect_scope_flag; |
| 114 | }; |
| 115 | |
| 116 | struct ma_state { |
| 117 | float vol; |
| 118 | bool active; |
| 119 | }; |
| 120 | |
jasmine cha | 75fa6f0 | 2018-03-30 15:41:33 +0800 | [diff] [blame] | 121 | typedef void *ma_audio_cal_handle_t; |
Aalique Grahame | 5ce7fbe | 2019-01-28 12:08:13 -0800 | [diff] [blame] | 122 | typedef int (*set_audio_cal_t)(const char *); |
jasmine cha | 75fa6f0 | 2018-03-30 15:41:33 +0800 | [diff] [blame] | 123 | |
Aalique Grahame | 5ce7fbe | 2019-01-28 12:08:13 -0800 | [diff] [blame] | 124 | typedef bool (*ma_param_init_t)(ma_audio_cal_handle_t *, const char *, |
| 125 | const char *, const char *, set_audio_cal_t); |
jasmine cha | 75fa6f0 | 2018-03-30 15:41:33 +0800 | [diff] [blame] | 126 | |
Aalique Grahame | 5ce7fbe | 2019-01-28 12:08:13 -0800 | [diff] [blame] | 127 | typedef bool (*ma_param_deinit_t)(ma_audio_cal_handle_t *); |
jasmine cha | 75fa6f0 | 2018-03-30 15:41:33 +0800 | [diff] [blame] | 128 | |
justinweng | bbffa62 | 2019-01-11 14:38:06 +0800 | [diff] [blame] | 129 | typedef bool (*ma_is_feature_used_t)(ma_audio_cal_handle_t, const char *); |
| 130 | |
Aalique Grahame | 5ce7fbe | 2019-01-28 12:08:13 -0800 | [diff] [blame] | 131 | typedef bool (*ma_set_lr_swap_t)(ma_audio_cal_handle_t, |
| 132 | const struct ma_audio_cal_settings *, bool); |
jasmine cha | 75fa6f0 | 2018-03-30 15:41:33 +0800 | [diff] [blame] | 133 | |
justinweng | bbffa62 | 2019-01-11 14:38:06 +0800 | [diff] [blame] | 134 | typedef bool (*ma_set_orientation_t)(ma_audio_cal_handle_t, |
| 135 | const struct ma_audio_cal_settings *, int); |
| 136 | |
Aalique Grahame | 5ce7fbe | 2019-01-28 12:08:13 -0800 | [diff] [blame] | 137 | typedef bool (*ma_set_sound_mode_t)(ma_audio_cal_handle_t, |
| 138 | const struct ma_audio_cal_settings *, |
| 139 | unsigned int); |
jasmine cha | 75fa6f0 | 2018-03-30 15:41:33 +0800 | [diff] [blame] | 140 | |
Aalique Grahame | 5ce7fbe | 2019-01-28 12:08:13 -0800 | [diff] [blame] | 141 | typedef bool (*ma_set_volume_t)(ma_audio_cal_handle_t, |
| 142 | const struct ma_audio_cal_settings *, double); |
jasmine cha | 75fa6f0 | 2018-03-30 15:41:33 +0800 | [diff] [blame] | 143 | |
Aalique Grahame | 5ce7fbe | 2019-01-28 12:08:13 -0800 | [diff] [blame] | 144 | typedef bool (*ma_set_volume_table_t)(ma_audio_cal_handle_t, |
| 145 | const struct ma_audio_cal_settings *, |
| 146 | size_t, struct ma_state *); |
jasmine cha | 75fa6f0 | 2018-03-30 15:41:33 +0800 | [diff] [blame] | 147 | |
Arun Mirpuri | b1bec9c | 2019-01-29 16:42:45 -0800 | [diff] [blame] | 148 | typedef bool (*ma_set_param_t)(ma_audio_cal_handle_t, |
| 149 | const struct ma_audio_cal_settings *, |
| 150 | unsigned int, double); |
| 151 | |
justinweng | d539515 | 2019-11-04 12:23:09 +0800 | [diff] [blame] | 152 | typedef bool (*ma_set_cmd_t)(ma_audio_cal_handle_t handle, |
| 153 | const struct ma_audio_cal_settings *, |
| 154 | const char*); |
| 155 | |
| 156 | typedef bool (*ma_get_cmd_t)(ma_audio_cal_handle_t handle, |
| 157 | const struct ma_audio_cal_settings *, |
| 158 | const char *, |
| 159 | char *, |
| 160 | uint32_t); |
| 161 | |
jasmine cha | 75fa6f0 | 2018-03-30 15:41:33 +0800 | [diff] [blame] | 162 | struct ma_platform_data { |
| 163 | void *waves_handle; |
Aalique Grahame | 5ce7fbe | 2019-01-28 12:08:13 -0800 | [diff] [blame] | 164 | void *platform; |
jasmine cha | 75fa6f0 | 2018-03-30 15:41:33 +0800 | [diff] [blame] | 165 | pthread_mutex_t lock; |
| 166 | ma_param_init_t ma_param_init; |
| 167 | ma_param_deinit_t ma_param_deinit; |
justinweng | bbffa62 | 2019-01-11 14:38:06 +0800 | [diff] [blame] | 168 | ma_is_feature_used_t ma_is_feature_used; |
jasmine cha | 75fa6f0 | 2018-03-30 15:41:33 +0800 | [diff] [blame] | 169 | ma_set_lr_swap_t ma_set_lr_swap; |
justinweng | bbffa62 | 2019-01-11 14:38:06 +0800 | [diff] [blame] | 170 | ma_set_orientation_t ma_set_orientation; |
jasmine cha | 75fa6f0 | 2018-03-30 15:41:33 +0800 | [diff] [blame] | 171 | ma_set_sound_mode_t ma_set_sound_mode; |
| 172 | ma_set_volume_t ma_set_volume; |
| 173 | ma_set_volume_table_t ma_set_volume_table; |
Arun Mirpuri | b1bec9c | 2019-01-29 16:42:45 -0800 | [diff] [blame] | 174 | ma_set_param_t ma_set_param; |
justinweng | d539515 | 2019-11-04 12:23:09 +0800 | [diff] [blame] | 175 | ma_set_cmd_t ma_set_cmd; |
| 176 | ma_get_cmd_t ma_get_cmd; |
Arun Mirpuri | b1bec9c | 2019-01-29 16:42:45 -0800 | [diff] [blame] | 177 | bool speaker_lr_swap; |
justinweng | bbffa62 | 2019-01-11 14:38:06 +0800 | [diff] [blame] | 178 | bool orientation_used; |
| 179 | int dispaly_orientation; |
jasmine cha | 75fa6f0 | 2018-03-30 15:41:33 +0800 | [diff] [blame] | 180 | }; |
| 181 | |
| 182 | ma_audio_cal_handle_t g_ma_audio_cal_handle = NULL; |
| 183 | static uint16_t g_supported_dev = 0; |
| 184 | static struct ma_state ma_cur_state_table[STREAM_MAX_TYPES]; |
| 185 | static struct ma_platform_data *my_data = NULL; |
justinweng | d539515 | 2019-11-04 12:23:09 +0800 | [diff] [blame] | 186 | static char ma_command_data[WAVES_COMMAND_SIZE]; |
| 187 | static char ma_reply_data[WAVES_COMMAND_SIZE]; |
| 188 | |
Arun Mirpuri | d750ac5 | 2019-04-12 18:33:55 -0700 | [diff] [blame] | 189 | // --- external function dependency --- |
| 190 | fp_platform_set_parameters_t fp_platform_set_parameters; |
| 191 | fp_audio_extn_get_snd_card_split_t fp_audio_extn_get_snd_card_split; |
jasmine cha | 75fa6f0 | 2018-03-30 15:41:33 +0800 | [diff] [blame] | 192 | |
Aalique Grahame | 5ce7fbe | 2019-01-28 12:08:13 -0800 | [diff] [blame] | 193 | static int set_audio_cal(const char *audio_cal) |
jasmine cha | 75fa6f0 | 2018-03-30 15:41:33 +0800 | [diff] [blame] | 194 | { |
| 195 | ALOGV("set_audio_cal: %s", audio_cal); |
| 196 | |
Arun Mirpuri | d750ac5 | 2019-04-12 18:33:55 -0700 | [diff] [blame] | 197 | return fp_platform_set_parameters(my_data->platform, |
jasmine cha | 75fa6f0 | 2018-03-30 15:41:33 +0800 | [diff] [blame] | 198 | str_parms_create_str(audio_cal)); |
| 199 | } |
| 200 | |
| 201 | static bool ma_set_lr_swap_l( |
Aalique Grahame | 5ce7fbe | 2019-01-28 12:08:13 -0800 | [diff] [blame] | 202 | const struct ma_audio_cal_settings *audio_cal_settings, bool swap) |
jasmine cha | 75fa6f0 | 2018-03-30 15:41:33 +0800 | [diff] [blame] | 203 | { |
Aalique Grahame | 5ce7fbe | 2019-01-28 12:08:13 -0800 | [diff] [blame] | 204 | return my_data->ma_set_lr_swap(g_ma_audio_cal_handle, |
| 205 | audio_cal_settings, swap); |
jasmine cha | 75fa6f0 | 2018-03-30 15:41:33 +0800 | [diff] [blame] | 206 | } |
| 207 | |
justinweng | bbffa62 | 2019-01-11 14:38:06 +0800 | [diff] [blame] | 208 | static bool ma_set_orientation_l( |
| 209 | const struct ma_audio_cal_settings *audio_cal_settings, int orientation) |
| 210 | { |
| 211 | return my_data->ma_set_orientation(g_ma_audio_cal_handle, |
| 212 | audio_cal_settings, orientation); |
| 213 | } |
| 214 | |
jasmine cha | 75fa6f0 | 2018-03-30 15:41:33 +0800 | [diff] [blame] | 215 | static bool ma_set_volume_table_l( |
Aalique Grahame | 5ce7fbe | 2019-01-28 12:08:13 -0800 | [diff] [blame] | 216 | const struct ma_audio_cal_settings *audio_cal_settings, |
| 217 | size_t num_streams, struct ma_state *volume_table) |
jasmine cha | 75fa6f0 | 2018-03-30 15:41:33 +0800 | [diff] [blame] | 218 | { |
Aalique Grahame | 5ce7fbe | 2019-01-28 12:08:13 -0800 | [diff] [blame] | 219 | return my_data->ma_set_volume_table(g_ma_audio_cal_handle, |
| 220 | audio_cal_settings, num_streams, |
| 221 | volume_table); |
jasmine cha | 75fa6f0 | 2018-03-30 15:41:33 +0800 | [diff] [blame] | 222 | } |
| 223 | |
Arun Mirpuri | b1bec9c | 2019-01-29 16:42:45 -0800 | [diff] [blame] | 224 | static bool ma_set_param_l( |
| 225 | const struct ma_audio_cal_settings *audio_cal_settings, |
| 226 | unsigned int index, double value) |
| 227 | { |
| 228 | return my_data->ma_set_param(g_ma_audio_cal_handle, |
| 229 | audio_cal_settings, index, value); |
| 230 | } |
| 231 | |
Jasmine Cha | 0ad0977 | 2019-02-25 20:09:34 +0800 | [diff] [blame] | 232 | static void print_state_log() |
| 233 | { |
| 234 | ALOGD("%s: send volume table -(%i,%f,%s),(%i,%f,%s),(%i,%f,%s),(%i,%f,%s)," |
| 235 | "(%i,%f,%s),(%i,%f,%s)", __func__, |
| 236 | STREAM_VOICE, ma_cur_state_table[STREAM_VOICE].vol, |
| 237 | ma_cur_state_table[STREAM_VOICE].active ? "T" : "F", |
| 238 | STREAM_SYSTEM, ma_cur_state_table[STREAM_SYSTEM].vol, |
| 239 | ma_cur_state_table[STREAM_SYSTEM].active ? "T" : "F", |
| 240 | STREAM_RING, ma_cur_state_table[STREAM_RING].vol, |
| 241 | ma_cur_state_table[STREAM_RING].active ? "T" : "F", |
| 242 | STREAM_MUSIC, ma_cur_state_table[STREAM_MUSIC].vol, |
| 243 | ma_cur_state_table[STREAM_MUSIC].active ? "T" : "F", |
| 244 | STREAM_ALARM, ma_cur_state_table[STREAM_ALARM].vol, |
| 245 | ma_cur_state_table[STREAM_ALARM].active ? "T" : "F", |
| 246 | STREAM_NOTIFICATION, ma_cur_state_table[STREAM_NOTIFICATION].vol, |
| 247 | ma_cur_state_table[STREAM_NOTIFICATION].active ? "T" : "F"); |
| 248 | |
| 249 | } |
| 250 | |
jasmine cha | 75fa6f0 | 2018-03-30 15:41:33 +0800 | [diff] [blame] | 251 | static inline bool valid_usecase(struct audio_usecase *usecase) |
| 252 | { |
| 253 | if ((usecase->type == PCM_PLAYBACK) && |
| 254 | /* supported usecases */ |
| 255 | ((usecase->id == USECASE_AUDIO_PLAYBACK_DEEP_BUFFER) || |
| 256 | (usecase->id == USECASE_AUDIO_PLAYBACK_LOW_LATENCY) || |
| 257 | (usecase->id == USECASE_AUDIO_PLAYBACK_OFFLOAD)) && |
| 258 | /* support devices */ |
Aniket Kumar Lata | 0e6e1e5 | 2019-11-14 21:43:55 -0800 | [diff] [blame] | 259 | (compare_device_type(&usecase->device_list, AUDIO_DEVICE_OUT_SPEAKER) || |
| 260 | compare_device_type(&usecase->device_list, AUDIO_DEVICE_OUT_SPEAKER_SAFE) || |
| 261 | (is_usb_out_device_type(&usecase->device_list) && |
Arun Mirpuri | d750ac5 | 2019-04-12 18:33:55 -0700 | [diff] [blame] | 262 | ma_supported_usb()))) |
Arun Mirpuri | b1bec9c | 2019-01-29 16:42:45 -0800 | [diff] [blame] | 263 | /* TODO: enable A2DP when it is ready */ |
jasmine cha | 75fa6f0 | 2018-03-30 15:41:33 +0800 | [diff] [blame] | 264 | |
| 265 | return true; |
| 266 | |
| 267 | ALOGV("%s: not support type %d usecase %d device %d", |
Aniket Kumar Lata | 0e6e1e5 | 2019-11-14 21:43:55 -0800 | [diff] [blame] | 268 | __func__, usecase->type, usecase->id, get_device_types(&usecase->device_list)); |
jasmine cha | 75fa6f0 | 2018-03-30 15:41:33 +0800 | [diff] [blame] | 269 | |
| 270 | return false; |
| 271 | } |
| 272 | |
| 273 | // already hold lock |
| 274 | static inline bool is_active() |
| 275 | { |
| 276 | ma_stream_type_t i = 0; |
| 277 | |
| 278 | for (i = 0; i < STREAM_MAX_TYPES; i++) |
Arun Mirpuri | b1bec9c | 2019-01-29 16:42:45 -0800 | [diff] [blame] | 279 | if (ma_cur_state_table[i].active) |
jasmine cha | 75fa6f0 | 2018-03-30 15:41:33 +0800 | [diff] [blame] | 280 | return true; |
| 281 | |
| 282 | return false; |
| 283 | } |
| 284 | |
Arun Mirpuri | b1bec9c | 2019-01-29 16:42:45 -0800 | [diff] [blame] | 285 | static void ma_cal_init(struct ma_audio_cal_settings *ma_cal) |
| 286 | { |
| 287 | ma_cal->version.major = AUDIO_CAL_SETTINGS_VERSION_MAJOR_DEFAULT; |
| 288 | ma_cal->version.minor = AUDIO_CAL_SETTINGS_VERSION_MINOR_DEFAULT; |
| 289 | ma_cal->common.app_type = APP_TYPE_DEFAULT; |
Aniket Kumar Lata | 0e6e1e5 | 2019-11-14 21:43:55 -0800 | [diff] [blame] | 290 | list_init(&ma_cal->common.devices); |
| 291 | update_device_list(&ma_cal->common.devices, DEVICE_DEFAULT, |
| 292 | "", true); |
Arun Mirpuri | b1bec9c | 2019-01-29 16:42:45 -0800 | [diff] [blame] | 293 | ma_cal->effect_scope_flag = EFFECTIVE_SCOPE_ALL; |
| 294 | } |
| 295 | |
jasmine cha | 75fa6f0 | 2018-03-30 15:41:33 +0800 | [diff] [blame] | 296 | static bool check_and_send_all_audio_cal(struct audio_device *adev, ma_cmd_t cmd) |
| 297 | { |
jasmine cha | 75fa6f0 | 2018-03-30 15:41:33 +0800 | [diff] [blame] | 298 | bool ret = false; |
jasmine cha | 75fa6f0 | 2018-03-30 15:41:33 +0800 | [diff] [blame] | 299 | struct listnode *node; |
| 300 | struct audio_usecase *usecase; |
Arun Mirpuri | b1bec9c | 2019-01-29 16:42:45 -0800 | [diff] [blame] | 301 | struct ma_audio_cal_settings ma_cal; |
jasmine cha | 75fa6f0 | 2018-03-30 15:41:33 +0800 | [diff] [blame] | 302 | |
Arun Mirpuri | b1bec9c | 2019-01-29 16:42:45 -0800 | [diff] [blame] | 303 | ma_cal_init(&ma_cal); |
jasmine cha | 75fa6f0 | 2018-03-30 15:41:33 +0800 | [diff] [blame] | 304 | |
| 305 | list_for_each(node, &adev->usecase_list) { |
| 306 | usecase = node_to_item(node, struct audio_usecase, list); |
Sujin Panicker | 390724d | 2019-04-26 10:43:36 +0530 | [diff] [blame] | 307 | if (usecase->stream.out && valid_usecase(usecase)) { |
Arun Mirpuri | b1bec9c | 2019-01-29 16:42:45 -0800 | [diff] [blame] | 308 | ma_cal.common.app_type = usecase->stream.out->app_type_cfg.app_type; |
Aniket Kumar Lata | 0e6e1e5 | 2019-11-14 21:43:55 -0800 | [diff] [blame] | 309 | assign_devices(&ma_cal.common.devices, &usecase->stream.out->device_list); |
jasmine cha | 75fa6f0 | 2018-03-30 15:41:33 +0800 | [diff] [blame] | 310 | ALOGV("%s: send usecase(%d) app_type(%d) device(%d)", |
Arun Mirpuri | b1bec9c | 2019-01-29 16:42:45 -0800 | [diff] [blame] | 311 | __func__, usecase->id, ma_cal.common.app_type, |
Aniket Kumar Lata | 0e6e1e5 | 2019-11-14 21:43:55 -0800 | [diff] [blame] | 312 | get_device_types(&ma_cal.common.devices)); |
jasmine cha | 75fa6f0 | 2018-03-30 15:41:33 +0800 | [diff] [blame] | 313 | |
| 314 | switch (cmd) { |
| 315 | case MA_CMD_VOL: |
Arun Mirpuri | b1bec9c | 2019-01-29 16:42:45 -0800 | [diff] [blame] | 316 | ret = ma_set_volume_table_l(&ma_cal, STREAM_MAX_TYPES, |
Aalique Grahame | 5ce7fbe | 2019-01-28 12:08:13 -0800 | [diff] [blame] | 317 | ma_cur_state_table); |
jasmine cha | 75fa6f0 | 2018-03-30 15:41:33 +0800 | [diff] [blame] | 318 | if (ret) |
Arun Mirpuri | b1bec9c | 2019-01-29 16:42:45 -0800 | [diff] [blame] | 319 | ALOGV("ma_set_volume_table_l success"); |
jasmine cha | 75fa6f0 | 2018-03-30 15:41:33 +0800 | [diff] [blame] | 320 | else |
Arun Mirpuri | b1bec9c | 2019-01-29 16:42:45 -0800 | [diff] [blame] | 321 | ALOGE("ma_set_volume_table_l returned with error."); |
Jasmine Cha | 0ad0977 | 2019-02-25 20:09:34 +0800 | [diff] [blame] | 322 | print_state_log(); |
jasmine cha | 75fa6f0 | 2018-03-30 15:41:33 +0800 | [diff] [blame] | 323 | break; |
Arun Mirpuri | b1bec9c | 2019-01-29 16:42:45 -0800 | [diff] [blame] | 324 | |
jasmine cha | 75fa6f0 | 2018-03-30 15:41:33 +0800 | [diff] [blame] | 325 | case MA_CMD_SWAP_ENABLE: |
Arun Mirpuri | b1bec9c | 2019-01-29 16:42:45 -0800 | [diff] [blame] | 326 | /* lr swap only enable for speaker path */ |
Aniket Kumar Lata | 0e6e1e5 | 2019-11-14 21:43:55 -0800 | [diff] [blame] | 327 | if (compare_device_type(&ma_cal.common.devices, |
| 328 | AUDIO_DEVICE_OUT_SPEAKER)) { |
Arun Mirpuri | b1bec9c | 2019-01-29 16:42:45 -0800 | [diff] [blame] | 329 | ret = ma_set_lr_swap_l(&ma_cal, true); |
| 330 | if (ret) |
| 331 | ALOGV("ma_set_lr_swap_l enable returned with success."); |
| 332 | else |
| 333 | ALOGE("ma_set_lr_swap_l enable returned with error."); |
| 334 | } |
jasmine cha | 75fa6f0 | 2018-03-30 15:41:33 +0800 | [diff] [blame] | 335 | break; |
Arun Mirpuri | b1bec9c | 2019-01-29 16:42:45 -0800 | [diff] [blame] | 336 | |
jasmine cha | 75fa6f0 | 2018-03-30 15:41:33 +0800 | [diff] [blame] | 337 | case MA_CMD_SWAP_DISABLE: |
Arun Mirpuri | b1bec9c | 2019-01-29 16:42:45 -0800 | [diff] [blame] | 338 | ret = ma_set_lr_swap_l(&ma_cal, false); |
jasmine cha | 75fa6f0 | 2018-03-30 15:41:33 +0800 | [diff] [blame] | 339 | if (ret) |
Arun Mirpuri | b1bec9c | 2019-01-29 16:42:45 -0800 | [diff] [blame] | 340 | ALOGV("ma_set_lr_swap_l disable returned with success."); |
jasmine cha | 75fa6f0 | 2018-03-30 15:41:33 +0800 | [diff] [blame] | 341 | else |
Arun Mirpuri | b1bec9c | 2019-01-29 16:42:45 -0800 | [diff] [blame] | 342 | ALOGE("ma_set_lr_swap_l disable returned with error."); |
jasmine cha | 75fa6f0 | 2018-03-30 15:41:33 +0800 | [diff] [blame] | 343 | break; |
Arun Mirpuri | b1bec9c | 2019-01-29 16:42:45 -0800 | [diff] [blame] | 344 | |
justinweng | bbffa62 | 2019-01-11 14:38:06 +0800 | [diff] [blame] | 345 | case MA_CMD_ROTATE_ENABLE: |
Aniket Kumar Lata | 0e6e1e5 | 2019-11-14 21:43:55 -0800 | [diff] [blame] | 346 | if (compare_device_type(&ma_cal.common.devices, |
| 347 | AUDIO_DEVICE_OUT_SPEAKER)) { |
justinweng | bbffa62 | 2019-01-11 14:38:06 +0800 | [diff] [blame] | 348 | ret = ma_set_orientation_l(&ma_cal, my_data->dispaly_orientation); |
| 349 | if (ret) |
Jasmine Cha | 0ad0977 | 2019-02-25 20:09:34 +0800 | [diff] [blame] | 350 | ALOGV("ma_set_orientation_l %d returned with success.", |
| 351 | my_data->dispaly_orientation); |
justinweng | bbffa62 | 2019-01-11 14:38:06 +0800 | [diff] [blame] | 352 | else |
Jasmine Cha | 0ad0977 | 2019-02-25 20:09:34 +0800 | [diff] [blame] | 353 | ALOGE("ma_set_orientation_l %d returned with error.", |
| 354 | my_data->dispaly_orientation); |
justinweng | bbffa62 | 2019-01-11 14:38:06 +0800 | [diff] [blame] | 355 | } |
| 356 | break; |
| 357 | |
| 358 | case MA_CMD_ROTATE_DISABLE: |
| 359 | ret = ma_set_orientation_l(&ma_cal, 0); |
| 360 | if (ret) |
| 361 | ALOGV("ma_set_orientation_l 0 returned with success."); |
| 362 | else |
| 363 | ALOGE("ma_set_orientation_l 0 returned with error."); |
| 364 | break; |
| 365 | |
jasmine cha | 75fa6f0 | 2018-03-30 15:41:33 +0800 | [diff] [blame] | 366 | default: |
| 367 | ALOGE("%s: unsupported cmd %d", __func__, cmd); |
| 368 | } |
jasmine cha | 75fa6f0 | 2018-03-30 15:41:33 +0800 | [diff] [blame] | 369 | } |
| 370 | } |
jasmine cha | 75fa6f0 | 2018-03-30 15:41:33 +0800 | [diff] [blame] | 371 | |
| 372 | return ret; |
| 373 | } |
| 374 | |
| 375 | static bool find_sup_dev(char *name) |
| 376 | { |
Weiyin Jiang | 0d98587 | 2019-06-13 15:47:21 +0800 | [diff] [blame] | 377 | char *token, *saveptr = NULL; |
jasmine cha | 75fa6f0 | 2018-03-30 15:41:33 +0800 | [diff] [blame] | 378 | const char s[2] = ","; |
| 379 | bool ret = false; |
| 380 | char sup_devs[128]; |
| 381 | |
| 382 | // the rule of comforming suppored dev's name |
| 383 | // 1. Both string len are equal |
| 384 | // 2. Both string content are equal |
| 385 | |
| 386 | strncpy(sup_devs, SUPPORT_DEV, sizeof(sup_devs)); |
Weiyin Jiang | 0d98587 | 2019-06-13 15:47:21 +0800 | [diff] [blame] | 387 | token = strtok_r(sup_devs, s, &saveptr); |
jasmine cha | 75fa6f0 | 2018-03-30 15:41:33 +0800 | [diff] [blame] | 388 | while (token != NULL) { |
| 389 | if (strncmp(token, name, strlen(token)) == 0 && |
| 390 | strlen(token) == strlen(name)) { |
| 391 | ALOGD("%s: support dev %s", __func__, token); |
| 392 | ret = true; |
| 393 | break; |
| 394 | } |
Weiyin Jiang | 0d98587 | 2019-06-13 15:47:21 +0800 | [diff] [blame] | 395 | token = strtok_r(NULL, s, &saveptr); |
jasmine cha | 75fa6f0 | 2018-03-30 15:41:33 +0800 | [diff] [blame] | 396 | } |
| 397 | |
| 398 | return ret; |
| 399 | } |
| 400 | |
| 401 | static void ma_set_swap_l(struct audio_device *adev, bool enable) |
| 402 | { |
jasmine cha | 75fa6f0 | 2018-03-30 15:41:33 +0800 | [diff] [blame] | 403 | if (enable) |
| 404 | check_and_send_all_audio_cal(adev, MA_CMD_SWAP_ENABLE); |
| 405 | else |
| 406 | check_and_send_all_audio_cal(adev, MA_CMD_SWAP_DISABLE); |
| 407 | } |
| 408 | |
justinweng | bbffa62 | 2019-01-11 14:38:06 +0800 | [diff] [blame] | 409 | static void ma_set_rotation_l(struct audio_device *adev, int orientation) |
| 410 | { |
| 411 | if (orientation != 0) |
| 412 | check_and_send_all_audio_cal(adev, MA_CMD_ROTATE_ENABLE); |
| 413 | else |
| 414 | check_and_send_all_audio_cal(adev, MA_CMD_ROTATE_DISABLE); |
| 415 | } |
| 416 | |
jasmine cha | 75fa6f0 | 2018-03-30 15:41:33 +0800 | [diff] [blame] | 417 | static void ma_support_usb(bool enable, int card) |
| 418 | { |
| 419 | char path[128]; |
| 420 | char id[32]; |
| 421 | int ret = 0; |
| 422 | int32_t fd = -1; |
| 423 | char *idd; |
Weiyin Jiang | 0d98587 | 2019-06-13 15:47:21 +0800 | [diff] [blame] | 424 | char *saveptr = NULL; |
jasmine cha | 75fa6f0 | 2018-03-30 15:41:33 +0800 | [diff] [blame] | 425 | |
| 426 | if (enable) { |
Arun Mirpuri | b1bec9c | 2019-01-29 16:42:45 -0800 | [diff] [blame] | 427 | ret = snprintf(path, sizeof(path), "/proc/asound/card%u/usbid", card); |
jasmine cha | 75fa6f0 | 2018-03-30 15:41:33 +0800 | [diff] [blame] | 428 | if (ret < 0) { |
| 429 | ALOGE("%s: failed on snprintf (%d) to path %s\n", |
Aalique Grahame | 5ce7fbe | 2019-01-28 12:08:13 -0800 | [diff] [blame] | 430 | __func__, ret, path); |
jasmine cha | 75fa6f0 | 2018-03-30 15:41:33 +0800 | [diff] [blame] | 431 | goto done; |
| 432 | } |
| 433 | fd = open(path, O_RDONLY); |
| 434 | if (fd < 0) { |
| 435 | ALOGE("%s: error failed to open id file %s error: %d\n", |
| 436 | __func__, path, errno); |
| 437 | goto done; |
| 438 | } |
| 439 | if (read(fd, id, sizeof(id)) < 0) { |
| 440 | ALOGE("%s: file read error", __func__); |
| 441 | goto done; |
| 442 | } |
| 443 | //replace '\n' to '\0' |
Weiyin Jiang | 0d98587 | 2019-06-13 15:47:21 +0800 | [diff] [blame] | 444 | idd = strtok_r(id, "\n", &saveptr); |
jasmine cha | 75fa6f0 | 2018-03-30 15:41:33 +0800 | [diff] [blame] | 445 | |
| 446 | if (find_sup_dev(idd)) { |
Arun Mirpuri | b1bec9c | 2019-01-29 16:42:45 -0800 | [diff] [blame] | 447 | ALOGV("%s: support usbid is %s", __func__, id); |
jasmine cha | 75fa6f0 | 2018-03-30 15:41:33 +0800 | [diff] [blame] | 448 | g_supported_dev |= SUPPORTED_USB; |
| 449 | } else |
Arun Mirpuri | b1bec9c | 2019-01-29 16:42:45 -0800 | [diff] [blame] | 450 | ALOGV("%s: usbid %s isn't found from %s", __func__, id, SUPPORT_DEV); |
jasmine cha | 75fa6f0 | 2018-03-30 15:41:33 +0800 | [diff] [blame] | 451 | } else { |
| 452 | g_supported_dev &= ~SUPPORTED_USB; |
| 453 | } |
| 454 | |
| 455 | done: |
| 456 | if (fd >= 0) close(fd); |
| 457 | } |
| 458 | |
| 459 | // adev_init lock held |
Arun Mirpuri | d750ac5 | 2019-04-12 18:33:55 -0700 | [diff] [blame] | 460 | void ma_init(void *platform, maxx_audio_init_config_t init_config) |
jasmine cha | 75fa6f0 | 2018-03-30 15:41:33 +0800 | [diff] [blame] | 461 | { |
| 462 | ma_stream_type_t i = 0; |
| 463 | int ret = 0; |
Aalique Grahame | 5ce7fbe | 2019-01-28 12:08:13 -0800 | [diff] [blame] | 464 | char lib_path[128] = {0}; |
| 465 | char mps_path[128] = {0}; |
| 466 | char cnf_path[128] = {0}; |
| 467 | struct snd_card_split *snd_split_handle = NULL; |
Arun Mirpuri | d750ac5 | 2019-04-12 18:33:55 -0700 | [diff] [blame] | 468 | |
| 469 | fp_platform_set_parameters = init_config.fp_platform_set_parameters; |
| 470 | fp_audio_extn_get_snd_card_split = init_config.fp_audio_extn_get_snd_card_split; |
| 471 | |
| 472 | snd_split_handle = fp_audio_extn_get_snd_card_split(); |
jasmine cha | 75fa6f0 | 2018-03-30 15:41:33 +0800 | [diff] [blame] | 473 | |
| 474 | if (platform == NULL) { |
| 475 | ALOGE("%s: platform is NULL", __func__); |
| 476 | goto error; |
| 477 | } |
| 478 | |
| 479 | if (my_data) { free(my_data); } |
| 480 | my_data = calloc(1, sizeof(struct ma_platform_data)); |
| 481 | if (my_data == NULL) { |
| 482 | ALOGE("%s: ma_cal alloct fail", __func__); |
| 483 | goto error; |
| 484 | } |
| 485 | |
| 486 | pthread_mutex_init(&my_data->lock, NULL); |
| 487 | |
Aalique Grahame | 5ce7fbe | 2019-01-28 12:08:13 -0800 | [diff] [blame] | 488 | my_data->platform = platform; |
jasmine cha | 75fa6f0 | 2018-03-30 15:41:33 +0800 | [diff] [blame] | 489 | ret = snprintf(lib_path, sizeof(lib_path), "%s/%s", LIB_MA_PATH, LIB_MA_PARAM); |
| 490 | if (ret < 0) { |
| 491 | ALOGE("%s: snprintf failed for lib %s, ret %d", __func__, LIB_MA_PARAM, ret); |
| 492 | goto error; |
| 493 | } |
| 494 | |
| 495 | my_data->waves_handle = dlopen(lib_path, RTLD_NOW); |
| 496 | if (my_data->waves_handle == NULL) { |
justinweng | d539515 | 2019-11-04 12:23:09 +0800 | [diff] [blame] | 497 | ALOGE("%s: DLOPEN failed for %s, %s", __func__, LIB_MA_PARAM, dlerror()); |
| 498 | goto error; |
jasmine cha | 75fa6f0 | 2018-03-30 15:41:33 +0800 | [diff] [blame] | 499 | } else { |
justinweng | d539515 | 2019-11-04 12:23:09 +0800 | [diff] [blame] | 500 | ALOGV("%s: DLOPEN successful for %s", __func__, LIB_MA_PARAM); |
jasmine cha | 75fa6f0 | 2018-03-30 15:41:33 +0800 | [diff] [blame] | 501 | |
justinweng | d539515 | 2019-11-04 12:23:09 +0800 | [diff] [blame] | 502 | my_data->ma_param_init = (ma_param_init_t)dlsym(my_data->waves_handle, MA_QDSP_PARAM_INIT); |
| 503 | if (!my_data->ma_param_init) { |
| 504 | ALOGE("%s: dlsym error %s for ma_param_init", __func__, dlerror()); |
| 505 | goto error; |
| 506 | } |
jasmine cha | 75fa6f0 | 2018-03-30 15:41:33 +0800 | [diff] [blame] | 507 | |
justinweng | d539515 | 2019-11-04 12:23:09 +0800 | [diff] [blame] | 508 | my_data->ma_param_deinit = (ma_param_deinit_t)dlsym(my_data->waves_handle, |
| 509 | MA_QDSP_PARAM_DEINIT); |
| 510 | if (!my_data->ma_param_deinit) { |
| 511 | ALOGE("%s: dlsym error %s for ma_param_deinit", __func__, dlerror()); |
| 512 | goto error; |
| 513 | } |
jasmine cha | 75fa6f0 | 2018-03-30 15:41:33 +0800 | [diff] [blame] | 514 | |
justinweng | bbffa62 | 2019-01-11 14:38:06 +0800 | [diff] [blame] | 515 | my_data->ma_is_feature_used = (ma_is_feature_used_t)dlsym(my_data->waves_handle, |
justinweng | d539515 | 2019-11-04 12:23:09 +0800 | [diff] [blame] | 516 | MA_QDSP_IS_FEATURE_USED); |
justinweng | bbffa62 | 2019-01-11 14:38:06 +0800 | [diff] [blame] | 517 | if (!my_data->ma_is_feature_used) { |
| 518 | ALOGV("%s: dlsym error %s for ma_is_feature_used", __func__, dlerror()); |
| 519 | } |
| 520 | |
| 521 | my_data->ma_set_orientation = (ma_set_orientation_t)dlsym(my_data->waves_handle, |
justinweng | d539515 | 2019-11-04 12:23:09 +0800 | [diff] [blame] | 522 | MA_QDSP_SET_ORIENTATION); |
justinweng | bbffa62 | 2019-01-11 14:38:06 +0800 | [diff] [blame] | 523 | if (!my_data->ma_set_orientation) { |
| 524 | ALOGV("%s: dlsym error %s for ma_set_orientation", __func__, dlerror()); |
| 525 | } |
| 526 | |
justinweng | d539515 | 2019-11-04 12:23:09 +0800 | [diff] [blame] | 527 | my_data->ma_set_lr_swap = (ma_set_lr_swap_t)dlsym(my_data->waves_handle, |
| 528 | MA_QDSP_SET_LR_SWAP); |
| 529 | if (!my_data->ma_set_lr_swap) { |
| 530 | ALOGE("%s: dlsym error %s for ma_set_lr_swap", __func__, dlerror()); |
| 531 | goto error; |
| 532 | } |
jasmine cha | 75fa6f0 | 2018-03-30 15:41:33 +0800 | [diff] [blame] | 533 | |
justinweng | d539515 | 2019-11-04 12:23:09 +0800 | [diff] [blame] | 534 | my_data->ma_set_sound_mode = (ma_set_sound_mode_t)dlsym(my_data->waves_handle, |
| 535 | MA_QDSP_SET_MODE); |
| 536 | if (!my_data->ma_set_sound_mode) { |
| 537 | ALOGE("%s: dlsym error %s for ma_set_sound_mode", __func__, dlerror()); |
| 538 | goto error; |
| 539 | } |
jasmine cha | 75fa6f0 | 2018-03-30 15:41:33 +0800 | [diff] [blame] | 540 | |
justinweng | d539515 | 2019-11-04 12:23:09 +0800 | [diff] [blame] | 541 | my_data->ma_set_volume = (ma_set_volume_t)dlsym(my_data->waves_handle, MA_QDSP_SET_VOL); |
| 542 | if (!my_data->ma_set_volume) { |
| 543 | ALOGE("%s: dlsym error %s for ma_set_volume", __func__, dlerror()); |
| 544 | goto error; |
| 545 | } |
jasmine cha | 75fa6f0 | 2018-03-30 15:41:33 +0800 | [diff] [blame] | 546 | |
justinweng | d539515 | 2019-11-04 12:23:09 +0800 | [diff] [blame] | 547 | my_data->ma_set_volume_table = (ma_set_volume_table_t)dlsym(my_data->waves_handle, |
| 548 | MA_QDSP_SET_VOLT); |
| 549 | if (!my_data->ma_set_volume_table) { |
| 550 | ALOGE("%s: dlsym error %s for ma_set_volume_table", __func__, dlerror()); |
| 551 | goto error; |
| 552 | } |
Arun Mirpuri | b1bec9c | 2019-01-29 16:42:45 -0800 | [diff] [blame] | 553 | |
justinweng | d539515 | 2019-11-04 12:23:09 +0800 | [diff] [blame] | 554 | my_data->ma_set_param = (ma_set_param_t)dlsym(my_data->waves_handle, MA_QDSP_SET_PARAM); |
| 555 | if (!my_data->ma_set_param) { |
| 556 | ALOGE("%s: dlsym error %s for ma_set_param", __func__, dlerror()); |
| 557 | goto error; |
| 558 | } |
| 559 | |
| 560 | my_data->ma_set_cmd = (ma_set_cmd_t)dlsym(my_data->waves_handle, MA_QDSP_SET_COMMAND); |
| 561 | if (!my_data->ma_set_cmd) { |
| 562 | ALOGE("%s: dlsym error %s for ma_set_cmd", __func__, dlerror()); |
| 563 | } |
| 564 | |
| 565 | my_data->ma_get_cmd = (ma_get_cmd_t)dlsym(my_data->waves_handle, MA_QDSP_GET_COMMAND); |
| 566 | if (!my_data->ma_get_cmd) { |
| 567 | ALOGE("%s: dlsym error %s for ma_get_cmd", __func__, dlerror()); |
| 568 | } |
jasmine cha | 75fa6f0 | 2018-03-30 15:41:33 +0800 | [diff] [blame] | 569 | } |
| 570 | |
Aalique Grahame | 5ce7fbe | 2019-01-28 12:08:13 -0800 | [diff] [blame] | 571 | /* get preset table */ |
| 572 | if (snd_split_handle == NULL) { |
| 573 | snprintf(mps_path, sizeof(mps_path), "%s/%s.mps", |
| 574 | PRESET_PATH, MPS_BASE_STRING); |
| 575 | } else { |
| 576 | snprintf(mps_path, sizeof(mps_path), "%s/%s_%s.mps", |
| 577 | PRESET_PATH, MPS_BASE_STRING, snd_split_handle->form_factor); |
jasmine cha | 75fa6f0 | 2018-03-30 15:41:33 +0800 | [diff] [blame] | 578 | } |
Aalique Grahame | 5ce7fbe | 2019-01-28 12:08:13 -0800 | [diff] [blame] | 579 | |
| 580 | /* get config files */ |
| 581 | if (snd_split_handle == NULL) { |
| 582 | snprintf(cnf_path, sizeof(cnf_path), "%s/%s.ini", |
| 583 | PRESET_PATH, CONFIG_BASE_STRING); |
| 584 | } else { |
| 585 | snprintf(cnf_path, sizeof(cnf_path), "%s/%s_%s.ini", |
| 586 | PRESET_PATH, CONFIG_BASE_STRING, snd_split_handle->form_factor); |
| 587 | } |
| 588 | |
| 589 | /* check file */ |
| 590 | if (access(mps_path, R_OK) < 0) { |
| 591 | ALOGW("%s: file %s isn't existed.", __func__, mps_path); |
| 592 | goto error; |
| 593 | } else |
| 594 | ALOGD("%s: Loading mps file: %s", __func__, mps_path); |
| 595 | |
jasmine cha | 75fa6f0 | 2018-03-30 15:41:33 +0800 | [diff] [blame] | 596 | /* TODO: check user preset table once the feature is enabled |
| 597 | if (access(USER_PRESET_PATH, F_OK) < 0 ){ |
| 598 | ALOGW("%s: file %s isn't existed.", __func__, USER_PRESET_PATH); |
| 599 | goto error; |
| 600 | } |
| 601 | */ |
Aalique Grahame | 5ce7fbe | 2019-01-28 12:08:13 -0800 | [diff] [blame] | 602 | |
| 603 | if (access(cnf_path, R_OK) < 0) { |
| 604 | ALOGW("%s: file %s isn't existed.", __func__, cnf_path); |
jasmine cha | 75fa6f0 | 2018-03-30 15:41:33 +0800 | [diff] [blame] | 605 | goto error; |
Aalique Grahame | 5ce7fbe | 2019-01-28 12:08:13 -0800 | [diff] [blame] | 606 | } else |
| 607 | ALOGD("%s: Loading ini file: %s", __func__, cnf_path); |
jasmine cha | 75fa6f0 | 2018-03-30 15:41:33 +0800 | [diff] [blame] | 608 | |
| 609 | /* init ma parameter */ |
| 610 | if (my_data->ma_param_init(&g_ma_audio_cal_handle, |
Aalique Grahame | 5ce7fbe | 2019-01-28 12:08:13 -0800 | [diff] [blame] | 611 | mps_path, |
| 612 | USER_PRESET_PATH, /* unused */ |
| 613 | cnf_path, |
| 614 | &set_audio_cal)) { |
jasmine cha | 75fa6f0 | 2018-03-30 15:41:33 +0800 | [diff] [blame] | 615 | if (!g_ma_audio_cal_handle) { |
| 616 | ALOGE("%s: ma parameters initialize failed", __func__); |
| 617 | my_data->ma_param_deinit(&g_ma_audio_cal_handle); |
| 618 | goto error; |
| 619 | } |
| 620 | ALOGD("%s: ma parameters initialize successful", __func__); |
| 621 | } else { |
| 622 | ALOGE("%s: ma parameters initialize failed", __func__); |
| 623 | goto error; |
| 624 | } |
| 625 | |
| 626 | /* init volume table */ |
| 627 | for (i = 0; i < STREAM_MAX_TYPES; i++) { |
| 628 | ma_cur_state_table[i].vol = 0.0; |
| 629 | ma_cur_state_table[i].active = false; |
| 630 | } |
| 631 | |
Arun Mirpuri | b1bec9c | 2019-01-29 16:42:45 -0800 | [diff] [blame] | 632 | my_data->speaker_lr_swap = false; |
justinweng | bbffa62 | 2019-01-11 14:38:06 +0800 | [diff] [blame] | 633 | my_data->orientation_used = false; |
| 634 | my_data->dispaly_orientation = 0; |
| 635 | |
| 636 | if (g_ma_audio_cal_handle && my_data->ma_is_feature_used) { |
Jasmine Cha | 0ad0977 | 2019-02-25 20:09:34 +0800 | [diff] [blame] | 637 | my_data->orientation_used = my_data->ma_is_feature_used( |
| 638 | g_ma_audio_cal_handle, "SET_ORIENTATION"); |
justinweng | bbffa62 | 2019-01-11 14:38:06 +0800 | [diff] [blame] | 639 | } |
Arun Mirpuri | b1bec9c | 2019-01-29 16:42:45 -0800 | [diff] [blame] | 640 | |
jasmine cha | 75fa6f0 | 2018-03-30 15:41:33 +0800 | [diff] [blame] | 641 | return; |
| 642 | |
| 643 | error: |
| 644 | if (my_data) { free(my_data); } |
| 645 | my_data = NULL; |
| 646 | } |
| 647 | |
| 648 | //adev_init lock held |
Arun Mirpuri | d750ac5 | 2019-04-12 18:33:55 -0700 | [diff] [blame] | 649 | void ma_deinit() |
jasmine cha | 75fa6f0 | 2018-03-30 15:41:33 +0800 | [diff] [blame] | 650 | { |
| 651 | if (my_data) { |
| 652 | /* deinit ma parameter */ |
| 653 | if (my_data->ma_param_deinit && |
| 654 | my_data->ma_param_deinit(&g_ma_audio_cal_handle)) |
| 655 | ALOGD("%s: ma parameters uninitialize successful", __func__); |
| 656 | else |
| 657 | ALOGD("%s: ma parameters uninitialize failed", __func__); |
| 658 | |
| 659 | pthread_mutex_destroy(&my_data->lock); |
| 660 | free(my_data); |
| 661 | my_data = NULL; |
| 662 | } |
| 663 | } |
| 664 | |
| 665 | // adev_init and adev lock held |
Arun Mirpuri | d750ac5 | 2019-04-12 18:33:55 -0700 | [diff] [blame] | 666 | bool ma_set_state(struct audio_device *adev, int stream_type, |
Aalique Grahame | 5ce7fbe | 2019-01-28 12:08:13 -0800 | [diff] [blame] | 667 | float vol, bool active) |
jasmine cha | 75fa6f0 | 2018-03-30 15:41:33 +0800 | [diff] [blame] | 668 | { |
| 669 | bool ret = false; |
Arun Mirpuri | b1bec9c | 2019-01-29 16:42:45 -0800 | [diff] [blame] | 670 | struct ma_state pr_mstate; |
jasmine cha | 75fa6f0 | 2018-03-30 15:41:33 +0800 | [diff] [blame] | 671 | |
Arun Mirpuri | b1bec9c | 2019-01-29 16:42:45 -0800 | [diff] [blame] | 672 | if (stream_type >= STREAM_MAX_TYPES || |
| 673 | stream_type < STREAM_MIN_TYPES) { |
| 674 | ALOGE("%s: stream_type %d out of range.", __func__, stream_type); |
| 675 | return ret; |
| 676 | } |
jasmine cha | 75fa6f0 | 2018-03-30 15:41:33 +0800 | [diff] [blame] | 677 | |
| 678 | if (!my_data) { |
Aalique Grahame | 5ce7fbe | 2019-01-28 12:08:13 -0800 | [diff] [blame] | 679 | ALOGV("%s: maxxaudio isn't initialized.", __func__); |
jasmine cha | 75fa6f0 | 2018-03-30 15:41:33 +0800 | [diff] [blame] | 680 | return ret; |
| 681 | } |
| 682 | |
Arun Mirpuri | b1bec9c | 2019-01-29 16:42:45 -0800 | [diff] [blame] | 683 | ALOGV("%s: stream[%d] vol[%f] active[%s]", |
| 684 | __func__, stream_type, vol, active ? "true" : "false"); |
jasmine cha | 75fa6f0 | 2018-03-30 15:41:33 +0800 | [diff] [blame] | 685 | |
Arun Mirpuri | b1bec9c | 2019-01-29 16:42:45 -0800 | [diff] [blame] | 686 | pr_mstate.vol = ma_cur_state_table[(ma_stream_type_t)stream_type].vol; |
| 687 | pr_mstate.active = ma_cur_state_table[(ma_stream_type_t)stream_type].active; |
| 688 | |
| 689 | // update condition: vol or active state changes |
| 690 | if (pr_mstate.vol != vol || pr_mstate.active != active) { |
| 691 | |
| 692 | pthread_mutex_lock(&my_data->lock); |
Arun Mirpuri | b1bec9c | 2019-01-29 16:42:45 -0800 | [diff] [blame] | 693 | |
| 694 | ma_cur_state_table[(ma_stream_type_t)stream_type].vol = vol; |
| 695 | ma_cur_state_table[(ma_stream_type_t)stream_type].active = active; |
| 696 | |
Arun Mirpuri | b1bec9c | 2019-01-29 16:42:45 -0800 | [diff] [blame] | 697 | ret = check_and_send_all_audio_cal(adev, MA_CMD_VOL); |
jasmine cha | 75fa6f0 | 2018-03-30 15:41:33 +0800 | [diff] [blame] | 698 | |
| 699 | pthread_mutex_unlock(&my_data->lock); |
| 700 | } |
| 701 | |
| 702 | return ret; |
| 703 | } |
| 704 | |
Arun Mirpuri | d750ac5 | 2019-04-12 18:33:55 -0700 | [diff] [blame] | 705 | void ma_set_device(struct audio_usecase *usecase) |
jasmine cha | 75fa6f0 | 2018-03-30 15:41:33 +0800 | [diff] [blame] | 706 | { |
Arun Mirpuri | b1bec9c | 2019-01-29 16:42:45 -0800 | [diff] [blame] | 707 | struct ma_audio_cal_settings ma_cal; |
jasmine cha | 75fa6f0 | 2018-03-30 15:41:33 +0800 | [diff] [blame] | 708 | |
| 709 | if (!my_data) { |
| 710 | ALOGV("%s: maxxaudio isn't initialized.", __func__); |
| 711 | return; |
| 712 | } |
| 713 | |
| 714 | if (!valid_usecase(usecase)) { |
| 715 | ALOGV("%s: %d is not supported usecase", __func__, usecase->id); |
| 716 | return; |
| 717 | } |
| 718 | |
Arun Mirpuri | b1bec9c | 2019-01-29 16:42:45 -0800 | [diff] [blame] | 719 | ma_cal_init(&ma_cal); |
jasmine cha | 75fa6f0 | 2018-03-30 15:41:33 +0800 | [diff] [blame] | 720 | |
| 721 | /* update audio_cal and send it */ |
Arun Mirpuri | b1bec9c | 2019-01-29 16:42:45 -0800 | [diff] [blame] | 722 | ma_cal.common.app_type = usecase->stream.out->app_type_cfg.app_type; |
Aniket Kumar Lata | 0e6e1e5 | 2019-11-14 21:43:55 -0800 | [diff] [blame] | 723 | assign_devices(&ma_cal.common.devices, &usecase->stream.out->device_list); |
Arun Mirpuri | b1bec9c | 2019-01-29 16:42:45 -0800 | [diff] [blame] | 724 | ALOGV("%s: send usecase(%d) app_type(%d) device(%d)", |
| 725 | __func__, usecase->id, ma_cal.common.app_type, |
Aniket Kumar Lata | 0e6e1e5 | 2019-11-14 21:43:55 -0800 | [diff] [blame] | 726 | get_device_types(&ma_cal.common.devices)); |
jasmine cha | 75fa6f0 | 2018-03-30 15:41:33 +0800 | [diff] [blame] | 727 | |
Arun Mirpuri | b1bec9c | 2019-01-29 16:42:45 -0800 | [diff] [blame] | 728 | pthread_mutex_lock(&my_data->lock); |
jasmine cha | 75fa6f0 | 2018-03-30 15:41:33 +0800 | [diff] [blame] | 729 | |
Arun Mirpuri | b1bec9c | 2019-01-29 16:42:45 -0800 | [diff] [blame] | 730 | if (is_active()) { |
justinweng | bbffa62 | 2019-01-11 14:38:06 +0800 | [diff] [blame] | 731 | |
Aniket Kumar Lata | 0e6e1e5 | 2019-11-14 21:43:55 -0800 | [diff] [blame] | 732 | if (compare_device_type(&ma_cal.common.devices, |
| 733 | AUDIO_DEVICE_OUT_SPEAKER)) { |
justinweng | bbffa62 | 2019-01-11 14:38:06 +0800 | [diff] [blame] | 734 | if (my_data->orientation_used) |
Jasmine Cha | 0ad0977 | 2019-02-25 20:09:34 +0800 | [diff] [blame] | 735 | ma_set_rotation_l(usecase->stream.out->dev, |
| 736 | my_data->dispaly_orientation); |
justinweng | bbffa62 | 2019-01-11 14:38:06 +0800 | [diff] [blame] | 737 | else |
| 738 | ma_set_swap_l(usecase->stream.out->dev, my_data->speaker_lr_swap); |
| 739 | } else { |
| 740 | if (my_data->orientation_used) |
| 741 | ma_set_rotation_l(usecase->stream.out->dev, 0); |
| 742 | else |
| 743 | ma_set_swap_l(usecase->stream.out->dev, false); |
| 744 | } |
jasmine cha | 75fa6f0 | 2018-03-30 15:41:33 +0800 | [diff] [blame] | 745 | |
Arun Mirpuri | b1bec9c | 2019-01-29 16:42:45 -0800 | [diff] [blame] | 746 | if (!ma_set_volume_table_l(&ma_cal, |
| 747 | STREAM_MAX_TYPES, |
| 748 | ma_cur_state_table)) |
| 749 | ALOGE("ma_set_volume_table_l returned with error."); |
| 750 | else |
| 751 | ALOGV("ma_set_volume_table_l success"); |
Jasmine Cha | 0ad0977 | 2019-02-25 20:09:34 +0800 | [diff] [blame] | 752 | print_state_log(); |
Arun Mirpuri | b1bec9c | 2019-01-29 16:42:45 -0800 | [diff] [blame] | 753 | |
jasmine cha | 75fa6f0 | 2018-03-30 15:41:33 +0800 | [diff] [blame] | 754 | } |
Arun Mirpuri | b1bec9c | 2019-01-29 16:42:45 -0800 | [diff] [blame] | 755 | pthread_mutex_unlock(&my_data->lock); |
jasmine cha | 75fa6f0 | 2018-03-30 15:41:33 +0800 | [diff] [blame] | 756 | } |
| 757 | |
justinweng | d539515 | 2019-11-04 12:23:09 +0800 | [diff] [blame] | 758 | static bool ma_set_command(struct ma_audio_cal_settings *audio_cal_settings, char *cmd_data) |
| 759 | { |
| 760 | if (my_data->ma_set_cmd) |
| 761 | return my_data->ma_set_cmd(g_ma_audio_cal_handle, audio_cal_settings, cmd_data); |
| 762 | return false; |
| 763 | } |
| 764 | |
| 765 | static bool ma_get_command(struct ma_audio_cal_settings *audio_cal_settings, char *cmd_data, |
| 766 | char *reply_data, uint32_t reply_size) |
| 767 | { |
| 768 | if (my_data->ma_get_cmd) |
| 769 | return my_data->ma_get_cmd(g_ma_audio_cal_handle, audio_cal_settings, cmd_data, reply_data, |
| 770 | reply_size); |
| 771 | return false; |
| 772 | } |
| 773 | |
| 774 | static bool ma_fill_apptype_and_device_from_params(struct str_parms *parms, uint32_t *app_type, |
| 775 | struct listnode *devices) |
| 776 | { |
| 777 | int ret; |
| 778 | char value[128]; |
| 779 | |
| 780 | ret = str_parms_get_str(parms, "cal_apptype", value, sizeof(value)); |
| 781 | |
| 782 | if (ret >= 0) { |
| 783 | *app_type = (uint32_t)atoi(value); |
| 784 | ret = str_parms_get_str(parms, "cal_devid", value, sizeof(value)); |
| 785 | if (ret >= 0) { |
| 786 | update_device_list(devices, (uint32_t)atoi(value), "", true); |
| 787 | return true; |
| 788 | } |
| 789 | } |
| 790 | return false; |
| 791 | } |
| 792 | |
| 793 | static bool ma_add_apptype_and_device_to_params(struct str_parms *parms, uint32_t app_type, |
| 794 | struct listnode *devices) |
| 795 | { |
| 796 | if (0 <= str_parms_add_int(parms, "cal_apptype", app_type)) { |
| 797 | if (0 <= str_parms_add_int(parms, "cal_devid", get_device_types(devices))) { |
| 798 | return true; |
| 799 | } |
| 800 | } |
| 801 | return false; |
| 802 | } |
| 803 | |
| 804 | static bool ma_get_command_parameters(struct str_parms *query, struct str_parms *reply) |
| 805 | { |
| 806 | struct ma_audio_cal_settings ma_cal; |
| 807 | int ret; |
| 808 | |
| 809 | ret = str_parms_get_str(query, "waves_data", ma_command_data, sizeof(ma_command_data)); |
| 810 | if (ret >= 0) { |
| 811 | ma_cal_init(&ma_cal); |
| 812 | if (ma_fill_apptype_and_device_from_params(query, &ma_cal.common.app_type, |
| 813 | &ma_cal.common.devices)) { |
| 814 | ma_add_apptype_and_device_to_params(reply, ma_cal.common.app_type, |
| 815 | &ma_cal.common.devices); |
| 816 | ALOGV("%s: before - command=%s", __func__, (char *)ma_command_data); |
| 817 | if (ma_get_command(&ma_cal, ma_command_data, ma_reply_data, sizeof(ma_reply_data))) { |
| 818 | str_parms_add_str(reply, "waves_data", ma_reply_data); |
| 819 | ALOGV("%s: after - command=%s", __func__, (char *)ma_reply_data); |
| 820 | return true; |
| 821 | } else { |
| 822 | str_parms_add_str(reply, "waves_data", ""); |
| 823 | } |
| 824 | } |
| 825 | } |
| 826 | return false; |
| 827 | } |
| 828 | |
| 829 | static bool ma_set_command_parameters(struct str_parms *parms) |
| 830 | { |
| 831 | struct ma_audio_cal_settings ma_cal; |
| 832 | int ret; |
| 833 | |
| 834 | ret = str_parms_get_str(parms, "waves_data", ma_command_data, sizeof(ma_command_data)); |
| 835 | if (ret >= 0) { |
| 836 | ma_cal_init(&ma_cal); |
| 837 | if (ma_fill_apptype_and_device_from_params(parms, &ma_cal.common.app_type, |
| 838 | &ma_cal.common.devices)) { |
| 839 | return ma_set_command(&ma_cal, ma_command_data); |
| 840 | } |
| 841 | } |
| 842 | return false; |
| 843 | } |
| 844 | |
| 845 | void ma_get_parameters(struct audio_device *adev, struct str_parms *query, |
| 846 | struct str_parms *reply) |
| 847 | { |
| 848 | (void)adev; |
| 849 | ma_get_command_parameters(query, reply); |
| 850 | } |
| 851 | |
| 852 | void ma_set_parameters(struct audio_device *adev, struct str_parms *parms) |
jasmine cha | 75fa6f0 | 2018-03-30 15:41:33 +0800 | [diff] [blame] | 853 | { |
| 854 | int ret; |
jasmine cha | 75fa6f0 | 2018-03-30 15:41:33 +0800 | [diff] [blame] | 855 | int val; |
| 856 | char value[128]; |
| 857 | |
| 858 | // do LR swap and usb recognition |
| 859 | ret = str_parms_get_int(parms, "rotation", &val); |
| 860 | if (ret >= 0) { |
Arun Mirpuri | b1bec9c | 2019-01-29 16:42:45 -0800 | [diff] [blame] | 861 | if (!my_data) { |
| 862 | ALOGV("%s: maxxaudio isn't initialized.", __func__); |
| 863 | return; |
| 864 | } |
| 865 | |
jasmine cha | 75fa6f0 | 2018-03-30 15:41:33 +0800 | [diff] [blame] | 866 | switch (val) { |
| 867 | case 270: |
Arun Mirpuri | b1bec9c | 2019-01-29 16:42:45 -0800 | [diff] [blame] | 868 | my_data->speaker_lr_swap = true; |
jasmine cha | 75fa6f0 | 2018-03-30 15:41:33 +0800 | [diff] [blame] | 869 | break; |
| 870 | case 0: |
| 871 | case 90: |
| 872 | case 180: |
Arun Mirpuri | b1bec9c | 2019-01-29 16:42:45 -0800 | [diff] [blame] | 873 | my_data->speaker_lr_swap = false; |
jasmine cha | 75fa6f0 | 2018-03-30 15:41:33 +0800 | [diff] [blame] | 874 | break; |
| 875 | } |
justinweng | bbffa62 | 2019-01-11 14:38:06 +0800 | [diff] [blame] | 876 | my_data->dispaly_orientation = val; |
| 877 | |
| 878 | if (my_data->orientation_used) |
| 879 | ma_set_rotation_l(adev, my_data->dispaly_orientation); |
| 880 | else |
| 881 | ma_set_swap_l(adev, my_data->speaker_lr_swap); |
jasmine cha | 75fa6f0 | 2018-03-30 15:41:33 +0800 | [diff] [blame] | 882 | } |
| 883 | |
| 884 | // check connect status |
Aalique Grahame | 5ce7fbe | 2019-01-28 12:08:13 -0800 | [diff] [blame] | 885 | ret = str_parms_get_str(parms, AUDIO_PARAMETER_DEVICE_CONNECT, value, |
| 886 | sizeof(value)); |
jasmine cha | 75fa6f0 | 2018-03-30 15:41:33 +0800 | [diff] [blame] | 887 | if (ret >= 0) { |
| 888 | audio_devices_t device = (audio_devices_t)strtoul(value, NULL, 10); |
| 889 | if (audio_is_usb_out_device(device)) { |
| 890 | ret = str_parms_get_str(parms, "card", value, sizeof(value)); |
| 891 | if (ret >= 0) { |
| 892 | const int card = atoi(value); |
| 893 | ma_support_usb(true, card); |
| 894 | } |
| 895 | } |
| 896 | } |
| 897 | |
| 898 | // check disconnect status |
Aalique Grahame | 5ce7fbe | 2019-01-28 12:08:13 -0800 | [diff] [blame] | 899 | ret = str_parms_get_str(parms, AUDIO_PARAMETER_DEVICE_DISCONNECT, value, |
| 900 | sizeof(value)); |
jasmine cha | 75fa6f0 | 2018-03-30 15:41:33 +0800 | [diff] [blame] | 901 | if (ret >= 0) { |
| 902 | audio_devices_t device = (audio_devices_t)strtoul(value, NULL, 10); |
| 903 | if (audio_is_usb_out_device(device)) { |
| 904 | ret = str_parms_get_str(parms, "card", value, sizeof(value)); |
| 905 | if (ret >= 0) { |
| 906 | const int card = atoi(value); |
| 907 | ma_support_usb(false, card /*useless*/); |
| 908 | } |
| 909 | } |
| 910 | } |
justinweng | d539515 | 2019-11-04 12:23:09 +0800 | [diff] [blame] | 911 | |
| 912 | ma_set_command_parameters(parms); |
jasmine cha | 75fa6f0 | 2018-03-30 15:41:33 +0800 | [diff] [blame] | 913 | } |
| 914 | |
Arun Mirpuri | d750ac5 | 2019-04-12 18:33:55 -0700 | [diff] [blame] | 915 | bool ma_supported_usb() |
jasmine cha | 75fa6f0 | 2018-03-30 15:41:33 +0800 | [diff] [blame] | 916 | { |
| 917 | ALOGV("%s: current support 0x%x", __func__, g_supported_dev); |
| 918 | return (g_supported_dev & SUPPORTED_USB) ? true : false; |
| 919 | } |