Subhash Chandra Bose Naripeddy | 3eedc00 | 2013-11-12 20:45:15 -0800 | [diff] [blame] | 1 | /* |
Aalique Grahame | 22e4910 | 2018-12-18 14:23:57 -0800 | [diff] [blame] | 2 | * Copyright (c) 2013-2015, 2017-2019, The Linux Foundation. All rights reserved. |
Subhash Chandra Bose Naripeddy | 3eedc00 | 2013-11-12 20:45:15 -0800 | [diff] [blame] | 3 | * Not a Contribution. |
| 4 | * |
| 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 | |
Dhananjay Kumar | 5f15ff9 | 2014-05-19 16:45:08 +0800 | [diff] [blame] | 20 | #define LOG_TAG "offload_effect_bass" |
Subhash Chandra Bose Naripeddy | e40a7cd | 2014-06-03 19:42:41 -0700 | [diff] [blame] | 21 | //#define LOG_NDEBUG 0 |
Subhash Chandra Bose Naripeddy | 3eedc00 | 2013-11-12 20:45:15 -0800 | [diff] [blame] | 22 | |
| 23 | #include <cutils/list.h> |
Aalique Grahame | 22e4910 | 2018-12-18 14:23:57 -0800 | [diff] [blame] | 24 | #include <log/log.h> |
Dhananjay Kumar | 5f15ff9 | 2014-05-19 16:45:08 +0800 | [diff] [blame] | 25 | #include <cutils/properties.h> |
Subhash Chandra Bose Naripeddy | 3eedc00 | 2013-11-12 20:45:15 -0800 | [diff] [blame] | 26 | #include <tinyalsa/asoundlib.h> |
Subhash Chandra Bose Naripeddy | 090a2aa | 2014-01-30 14:03:12 -0800 | [diff] [blame] | 27 | #include <sound/audio_effects.h> |
Subhash Chandra Bose Naripeddy | 3eedc00 | 2013-11-12 20:45:15 -0800 | [diff] [blame] | 28 | #include <audio_effects/effect_bassboost.h> |
Dhananjay Kumar | 5f15ff9 | 2014-05-19 16:45:08 +0800 | [diff] [blame] | 29 | #include <stdlib.h> |
| 30 | #include <dlfcn.h> |
Subhash Chandra Bose Naripeddy | 3eedc00 | 2013-11-12 20:45:15 -0800 | [diff] [blame] | 31 | |
| 32 | #include "effect_api.h" |
| 33 | #include "bass_boost.h" |
| 34 | |
Trinath Thammishetty | 765efd2 | 2018-08-20 13:23:24 +0530 | [diff] [blame] | 35 | #define BASSBOOST_MAX_LATENCY 30 |
| 36 | |
Subhash Chandra Bose Naripeddy | 3eedc00 | 2013-11-12 20:45:15 -0800 | [diff] [blame] | 37 | /* Offload bassboost UUID: 2c4a8c24-1581-487f-94f6-0002a5d5c51b */ |
| 38 | const effect_descriptor_t bassboost_descriptor = { |
| 39 | {0x0634f220, 0xddd4, 0x11db, 0xa0fc, { 0x00, 0x02, 0xa5, 0xd5, 0xc5, 0x1b }}, |
| 40 | {0x2c4a8c24, 0x1581, 0x487f, 0x94f6, { 0x00, 0x02, 0xa5, 0xd5, 0xc5, 0x1b}}, // uuid |
| 41 | EFFECT_CONTROL_API_VERSION, |
Weiyin Jiang | 90ac1ea | 2017-04-13 14:18:23 +0800 | [diff] [blame] | 42 | (EFFECT_FLAG_TYPE_INSERT | EFFECT_FLAG_DEVICE_IND | EFFECT_FLAG_HW_ACC_TUNNEL | |
| 43 | EFFECT_FLAG_VOLUME_CTRL), |
Subhash Chandra Bose Naripeddy | 3eedc00 | 2013-11-12 20:45:15 -0800 | [diff] [blame] | 44 | 0, /* TODO */ |
| 45 | 1, |
| 46 | "MSM offload bassboost", |
| 47 | "The Android Open Source Project", |
| 48 | }; |
| 49 | |
Dhananjay Kumar | 5f15ff9 | 2014-05-19 16:45:08 +0800 | [diff] [blame] | 50 | #define LIB_ACDB_LOADER "libacdbloader.so" |
| 51 | #define PBE_CONF_APP_ID 0x00011134 |
| 52 | |
Vatsal Bucha | c09ae06 | 2018-11-14 13:25:08 +0530 | [diff] [blame] | 53 | #ifdef AUDIO_FEATURE_ENABLED_GCOV |
| 54 | extern void __gcov_flush(); |
| 55 | static void enable_gcov() |
| 56 | { |
| 57 | __gcov_flush(); |
| 58 | } |
| 59 | #else |
| 60 | static void enable_gcov() |
| 61 | { |
| 62 | } |
| 63 | #endif |
| 64 | |
Dhananjay Kumar | 5f15ff9 | 2014-05-19 16:45:08 +0800 | [diff] [blame] | 65 | enum { |
| 66 | AUDIO_DEVICE_CAL_TYPE = 0, |
| 67 | AUDIO_STREAM_CAL_TYPE, |
| 68 | }; |
| 69 | |
| 70 | typedef struct acdb_audio_cal_cfg { |
| 71 | uint32_t persist; |
| 72 | uint32_t snd_dev_id; |
| 73 | uint32_t dev_id; |
| 74 | int32_t acdb_dev_id; |
| 75 | uint32_t app_type; |
| 76 | uint32_t topo_id; |
| 77 | uint32_t sampling_rate; |
| 78 | uint32_t cal_type; |
| 79 | uint32_t module_id; |
Aditya Bavanari | 3db4a29 | 2017-10-04 20:59:41 +0530 | [diff] [blame] | 80 | #ifdef INSTANCE_ID_ENABLED |
| 81 | uint16_t instance_id; |
| 82 | uint16_t reserved; |
| 83 | #endif |
Dhananjay Kumar | 5f15ff9 | 2014-05-19 16:45:08 +0800 | [diff] [blame] | 84 | uint32_t param_id; |
| 85 | } acdb_audio_cal_cfg_t; |
| 86 | |
| 87 | typedef int (*acdb_get_audio_cal_t) (void *, void *, uint32_t*); |
| 88 | static int pbe_load_config(struct pbe_params *params); |
| 89 | |
| 90 | /* |
| 91 | * Bass operations |
| 92 | */ |
| 93 | int bass_get_parameter(effect_context_t *context, effect_param_t *p, |
| 94 | uint32_t *size) |
| 95 | { |
| 96 | bass_context_t *bass_ctxt = (bass_context_t *)context; |
| 97 | int voffset = ((p->psize - 1) / sizeof(int32_t) + 1) * sizeof(int32_t); |
| 98 | int32_t *param_tmp = (int32_t *)p->data; |
| 99 | int32_t param = *param_tmp++; |
| 100 | void *value = p->data + voffset; |
Dhananjay Kumar | 5f15ff9 | 2014-05-19 16:45:08 +0800 | [diff] [blame] | 101 | |
| 102 | ALOGV("%s", __func__); |
| 103 | |
| 104 | p->status = 0; |
| 105 | |
| 106 | switch (param) { |
| 107 | case BASSBOOST_PARAM_STRENGTH_SUPPORTED: |
| 108 | if (p->vsize < sizeof(uint32_t)) |
| 109 | p->status = -EINVAL; |
| 110 | p->vsize = sizeof(uint32_t); |
| 111 | break; |
| 112 | case BASSBOOST_PARAM_STRENGTH: |
| 113 | if (p->vsize < sizeof(int16_t)) |
| 114 | p->status = -EINVAL; |
| 115 | p->vsize = sizeof(int16_t); |
| 116 | break; |
Trinath Thammishetty | 765efd2 | 2018-08-20 13:23:24 +0530 | [diff] [blame] | 117 | case BASSBOOST_PARAM_LATENCY: |
| 118 | if (p->vsize < sizeof(uint32_t)) |
| 119 | p->status = -EINVAL; |
| 120 | p->vsize = sizeof(uint32_t); |
| 121 | break; |
Dhananjay Kumar | 5f15ff9 | 2014-05-19 16:45:08 +0800 | [diff] [blame] | 122 | default: |
| 123 | p->status = -EINVAL; |
| 124 | } |
| 125 | |
| 126 | *size = sizeof(effect_param_t) + voffset + p->vsize; |
| 127 | |
| 128 | if (p->status != 0) |
| 129 | return 0; |
| 130 | |
| 131 | switch (param) { |
| 132 | case BASSBOOST_PARAM_STRENGTH_SUPPORTED: |
| 133 | ALOGV("%s: BASSBOOST_PARAM_STRENGTH_SUPPORTED", __func__); |
| 134 | if (bass_ctxt->active_index == BASS_BOOST) |
| 135 | *(uint32_t *)value = 1; |
| 136 | else |
| 137 | *(uint32_t *)value = 0; |
| 138 | break; |
| 139 | |
| 140 | case BASSBOOST_PARAM_STRENGTH: |
| 141 | ALOGV("%s: BASSBOOST_PARAM_STRENGTH", __func__); |
| 142 | if (bass_ctxt->active_index == BASS_BOOST) |
| 143 | *(int16_t *)value = bassboost_get_strength(&(bass_ctxt->bassboost_ctxt)); |
| 144 | else |
| 145 | *(int16_t *)value = 0; |
| 146 | break; |
| 147 | |
Trinath Thammishetty | 765efd2 | 2018-08-20 13:23:24 +0530 | [diff] [blame] | 148 | case BASSBOOST_PARAM_LATENCY: |
| 149 | *(uint32_t *)value = BASSBOOST_MAX_LATENCY; |
| 150 | break; |
| 151 | |
Dhananjay Kumar | 5f15ff9 | 2014-05-19 16:45:08 +0800 | [diff] [blame] | 152 | default: |
| 153 | p->status = -EINVAL; |
| 154 | break; |
| 155 | } |
| 156 | |
| 157 | return 0; |
| 158 | } |
| 159 | |
| 160 | int bass_set_parameter(effect_context_t *context, effect_param_t *p, |
| 161 | uint32_t size __unused) |
| 162 | { |
| 163 | bass_context_t *bass_ctxt = (bass_context_t *)context; |
| 164 | int voffset = ((p->psize - 1) / sizeof(int32_t) + 1) * sizeof(int32_t); |
| 165 | void *value = p->data + voffset; |
| 166 | int32_t *param_tmp = (int32_t *)p->data; |
| 167 | int32_t param = *param_tmp++; |
| 168 | uint32_t strength; |
| 169 | |
| 170 | ALOGV("%s", __func__); |
| 171 | |
| 172 | p->status = 0; |
| 173 | |
| 174 | switch (param) { |
| 175 | case BASSBOOST_PARAM_STRENGTH: |
| 176 | ALOGV("%s BASSBOOST_PARAM_STRENGTH", __func__); |
| 177 | if (bass_ctxt->active_index == BASS_BOOST) { |
| 178 | strength = (uint32_t)(*(int16_t *)value); |
| 179 | bassboost_set_strength(&(bass_ctxt->bassboost_ctxt), strength); |
| 180 | } else { |
| 181 | /* stength supported only for BB and not for PBE, but do not |
| 182 | * return error for unsupported case, as it fails cts test |
| 183 | */ |
| 184 | ALOGD("%s ignore set strength, index %d", |
| 185 | __func__, bass_ctxt->active_index); |
| 186 | break; |
| 187 | } |
| 188 | break; |
| 189 | default: |
| 190 | p->status = -EINVAL; |
| 191 | break; |
| 192 | } |
| 193 | |
| 194 | return 0; |
| 195 | } |
| 196 | |
| 197 | int bass_set_device(effect_context_t *context, uint32_t device) |
| 198 | { |
| 199 | bass_context_t *bass_ctxt = (bass_context_t *)context; |
| 200 | |
| 201 | if (device == AUDIO_DEVICE_OUT_SPEAKER) { |
| 202 | bass_ctxt->active_index = BASS_PBE; |
| 203 | ALOGV("%s: set PBE mode, device: %x", __func__, device); |
| 204 | } else if (device == AUDIO_DEVICE_OUT_WIRED_HEADSET || |
| 205 | device == AUDIO_DEVICE_OUT_WIRED_HEADPHONE || |
Dhananjay Kumar | 8413788 | 2015-06-05 20:34:50 +0530 | [diff] [blame] | 206 | device == AUDIO_DEVICE_OUT_BLUETOOTH_A2DP || |
Dhananjay Kumar | 5f15ff9 | 2014-05-19 16:45:08 +0800 | [diff] [blame] | 207 | device == AUDIO_DEVICE_OUT_BLUETOOTH_A2DP_HEADPHONES) { |
| 208 | ALOGV("%s: set BB mode, device: %x", __func__, device); |
| 209 | bass_ctxt->active_index = BASS_BOOST; |
| 210 | } else { |
| 211 | ALOGI("%s: disabled by device: %x", __func__, device); |
| 212 | bass_ctxt->active_index = BASS_INVALID; |
| 213 | } |
| 214 | |
| 215 | bassboost_set_device((effect_context_t *)&(bass_ctxt->bassboost_ctxt), device); |
| 216 | pbe_set_device((effect_context_t *)&(bass_ctxt->pbe_ctxt), device); |
| 217 | |
| 218 | return 0; |
| 219 | } |
| 220 | |
| 221 | int bass_reset(effect_context_t *context) |
| 222 | { |
| 223 | bass_context_t *bass_ctxt = (bass_context_t *)context; |
| 224 | |
| 225 | bassboost_reset((effect_context_t *)&(bass_ctxt->bassboost_ctxt)); |
| 226 | pbe_reset((effect_context_t *)&(bass_ctxt->pbe_ctxt)); |
| 227 | |
| 228 | return 0; |
| 229 | } |
| 230 | |
| 231 | int bass_init(effect_context_t *context) |
| 232 | { |
| 233 | bass_context_t *bass_ctxt = (bass_context_t *)context; |
| 234 | |
| 235 | // convery i/o channel config to sub effects |
| 236 | bass_ctxt->bassboost_ctxt.common.config = context->config; |
| 237 | bass_ctxt->pbe_ctxt.common.config = context->config; |
| 238 | |
| 239 | ALOGV("%s", __func__); |
| 240 | |
| 241 | bass_ctxt->active_index = BASS_BOOST; |
| 242 | |
| 243 | |
| 244 | bassboost_init((effect_context_t *)&(bass_ctxt->bassboost_ctxt)); |
| 245 | pbe_init((effect_context_t *)&(bass_ctxt->pbe_ctxt)); |
Vatsal Bucha | c09ae06 | 2018-11-14 13:25:08 +0530 | [diff] [blame] | 246 | enable_gcov(); |
Dhananjay Kumar | 5f15ff9 | 2014-05-19 16:45:08 +0800 | [diff] [blame] | 247 | return 0; |
| 248 | } |
| 249 | |
| 250 | int bass_enable(effect_context_t *context) |
| 251 | { |
| 252 | bass_context_t *bass_ctxt = (bass_context_t *)context; |
| 253 | |
| 254 | ALOGV("%s", __func__); |
| 255 | |
| 256 | bassboost_enable((effect_context_t *)&(bass_ctxt->bassboost_ctxt)); |
| 257 | pbe_enable((effect_context_t *)&(bass_ctxt->pbe_ctxt)); |
| 258 | |
| 259 | return 0; |
| 260 | } |
| 261 | |
| 262 | int bass_disable(effect_context_t *context) |
| 263 | { |
| 264 | bass_context_t *bass_ctxt = (bass_context_t *)context; |
| 265 | |
| 266 | ALOGV("%s", __func__); |
| 267 | |
| 268 | bassboost_disable((effect_context_t *)&(bass_ctxt->bassboost_ctxt)); |
| 269 | pbe_disable((effect_context_t *)&(bass_ctxt->pbe_ctxt)); |
| 270 | |
| 271 | return 0; |
| 272 | } |
| 273 | |
| 274 | int bass_start(effect_context_t *context, output_context_t *output) |
| 275 | { |
| 276 | bass_context_t *bass_ctxt = (bass_context_t *)context; |
| 277 | |
| 278 | ALOGV("%s", __func__); |
| 279 | |
| 280 | bassboost_start((effect_context_t *)&(bass_ctxt->bassboost_ctxt), output); |
| 281 | pbe_start((effect_context_t *)&(bass_ctxt->pbe_ctxt), output); |
| 282 | |
| 283 | return 0; |
| 284 | } |
| 285 | |
| 286 | int bass_stop(effect_context_t *context, output_context_t *output) |
| 287 | { |
| 288 | bass_context_t *bass_ctxt = (bass_context_t *)context; |
| 289 | |
| 290 | ALOGV("%s", __func__); |
| 291 | |
| 292 | bassboost_stop((effect_context_t *)&(bass_ctxt->bassboost_ctxt), output); |
| 293 | pbe_stop((effect_context_t *)&(bass_ctxt->pbe_ctxt), output); |
| 294 | |
| 295 | return 0; |
| 296 | } |
| 297 | |
| 298 | int bass_set_mode(effect_context_t *context, int32_t hw_acc_fd) |
| 299 | { |
| 300 | bass_context_t *bass_ctxt = (bass_context_t *)context; |
| 301 | |
| 302 | ALOGV("%s", __func__); |
| 303 | |
| 304 | bassboost_set_mode((effect_context_t *)&(bass_ctxt->bassboost_ctxt), hw_acc_fd); |
| 305 | pbe_set_mode((effect_context_t *)&(bass_ctxt->pbe_ctxt), hw_acc_fd); |
| 306 | |
| 307 | return 0; |
| 308 | } |
| 309 | |
| 310 | #undef LOG_TAG |
| 311 | #define LOG_TAG "offload_effect_bb" |
Subhash Chandra Bose Naripeddy | 3eedc00 | 2013-11-12 20:45:15 -0800 | [diff] [blame] | 312 | /* |
| 313 | * Bassboost operations |
| 314 | */ |
| 315 | |
| 316 | int bassboost_get_strength(bassboost_context_t *context) |
| 317 | { |
Dhananjay Kumar | 574f392 | 2014-03-25 17:41:44 +0530 | [diff] [blame] | 318 | ALOGV("%s: ctxt %p, strength: %d", __func__, |
| 319 | context, context->strength); |
Subhash Chandra Bose Naripeddy | 3eedc00 | 2013-11-12 20:45:15 -0800 | [diff] [blame] | 320 | return context->strength; |
| 321 | } |
| 322 | |
| 323 | int bassboost_set_strength(bassboost_context_t *context, uint32_t strength) |
| 324 | { |
Dhananjay Kumar | 574f392 | 2014-03-25 17:41:44 +0530 | [diff] [blame] | 325 | ALOGV("%s: ctxt %p, strength: %d", __func__, context, strength); |
Subhash Chandra Bose Naripeddy | 3eedc00 | 2013-11-12 20:45:15 -0800 | [diff] [blame] | 326 | context->strength = strength; |
| 327 | |
| 328 | offload_bassboost_set_strength(&(context->offload_bass), strength); |
| 329 | if (context->ctl) |
Subhash Chandra Bose Naripeddy | e40a7cd | 2014-06-03 19:42:41 -0700 | [diff] [blame] | 330 | offload_bassboost_send_params(context->ctl, &context->offload_bass, |
Subhash Chandra Bose Naripeddy | 3eedc00 | 2013-11-12 20:45:15 -0800 | [diff] [blame] | 331 | OFFLOAD_SEND_BASSBOOST_ENABLE_FLAG | |
| 332 | OFFLOAD_SEND_BASSBOOST_STRENGTH); |
Subhash Chandra Bose Naripeddy | e40a7cd | 2014-06-03 19:42:41 -0700 | [diff] [blame] | 333 | if (context->hw_acc_fd > 0) |
| 334 | hw_acc_bassboost_send_params(context->hw_acc_fd, |
| 335 | &context->offload_bass, |
| 336 | OFFLOAD_SEND_BASSBOOST_ENABLE_FLAG | |
| 337 | OFFLOAD_SEND_BASSBOOST_STRENGTH); |
Subhash Chandra Bose Naripeddy | 3eedc00 | 2013-11-12 20:45:15 -0800 | [diff] [blame] | 338 | return 0; |
| 339 | } |
| 340 | |
Subhash Chandra Bose Naripeddy | 3eedc00 | 2013-11-12 20:45:15 -0800 | [diff] [blame] | 341 | int bassboost_set_device(effect_context_t *context, uint32_t device) |
| 342 | { |
| 343 | bassboost_context_t *bass_ctxt = (bassboost_context_t *)context; |
| 344 | |
Dhananjay Kumar | 574f392 | 2014-03-25 17:41:44 +0530 | [diff] [blame] | 345 | ALOGV("%s: ctxt %p, device 0x%x", __func__, bass_ctxt, device); |
Subhash Chandra Bose Naripeddy | 3eedc00 | 2013-11-12 20:45:15 -0800 | [diff] [blame] | 346 | bass_ctxt->device = device; |
Dhananjay Kumar | 5f15ff9 | 2014-05-19 16:45:08 +0800 | [diff] [blame] | 347 | if (device == AUDIO_DEVICE_OUT_WIRED_HEADSET || |
| 348 | device == AUDIO_DEVICE_OUT_WIRED_HEADPHONE || |
Dhananjay Kumar | 8413788 | 2015-06-05 20:34:50 +0530 | [diff] [blame] | 349 | device == AUDIO_DEVICE_OUT_BLUETOOTH_A2DP || |
Dhananjay Kumar | 5f15ff9 | 2014-05-19 16:45:08 +0800 | [diff] [blame] | 350 | device == AUDIO_DEVICE_OUT_BLUETOOTH_A2DP_HEADPHONES) { |
| 351 | if (bass_ctxt->temp_disabled) { |
| 352 | if (effect_is_active(&bass_ctxt->common)) { |
| 353 | offload_bassboost_set_enable_flag(&(bass_ctxt->offload_bass), true); |
| 354 | if (bass_ctxt->ctl) |
| 355 | offload_bassboost_send_params(bass_ctxt->ctl, |
| 356 | &bass_ctxt->offload_bass, |
| 357 | OFFLOAD_SEND_BASSBOOST_ENABLE_FLAG); |
| 358 | if (bass_ctxt->hw_acc_fd > 0) |
| 359 | hw_acc_bassboost_send_params(bass_ctxt->hw_acc_fd, |
| 360 | &bass_ctxt->offload_bass, |
| 361 | OFFLOAD_SEND_BASSBOOST_ENABLE_FLAG); |
| 362 | } |
| 363 | bass_ctxt->temp_disabled = false; |
| 364 | } |
| 365 | } else { |
wjiang | 50b81f4 | 2014-08-06 08:03:14 +0800 | [diff] [blame] | 366 | if (!bass_ctxt->temp_disabled) { |
| 367 | if (effect_is_active(&bass_ctxt->common)) { |
| 368 | offload_bassboost_set_enable_flag(&(bass_ctxt->offload_bass), false); |
| 369 | if (bass_ctxt->ctl) |
| 370 | offload_bassboost_send_params(bass_ctxt->ctl, |
Subhash Chandra Bose Naripeddy | e40a7cd | 2014-06-03 19:42:41 -0700 | [diff] [blame] | 371 | &bass_ctxt->offload_bass, |
wjiang | 50b81f4 | 2014-08-06 08:03:14 +0800 | [diff] [blame] | 372 | OFFLOAD_SEND_BASSBOOST_ENABLE_FLAG); |
Subhash Chandra Bose Naripeddy | e40a7cd | 2014-06-03 19:42:41 -0700 | [diff] [blame] | 373 | if (bass_ctxt->hw_acc_fd > 0) |
| 374 | hw_acc_bassboost_send_params(bass_ctxt->hw_acc_fd, |
| 375 | &bass_ctxt->offload_bass, |
| 376 | OFFLOAD_SEND_BASSBOOST_ENABLE_FLAG); |
wjiang | 50b81f4 | 2014-08-06 08:03:14 +0800 | [diff] [blame] | 377 | } |
Subhash Chandra Bose Naripeddy | 3eedc00 | 2013-11-12 20:45:15 -0800 | [diff] [blame] | 378 | bass_ctxt->temp_disabled = true; |
| 379 | } |
wjiang | 50b81f4 | 2014-08-06 08:03:14 +0800 | [diff] [blame] | 380 | ALOGI("%s: ctxt %p, disabled based on device", __func__, bass_ctxt); |
Subhash Chandra Bose Naripeddy | 3eedc00 | 2013-11-12 20:45:15 -0800 | [diff] [blame] | 381 | } |
| 382 | offload_bassboost_set_device(&(bass_ctxt->offload_bass), device); |
| 383 | return 0; |
| 384 | } |
| 385 | |
Aalique Grahame | 22e4910 | 2018-12-18 14:23:57 -0800 | [diff] [blame] | 386 | int bassboost_reset(effect_context_t *context __unused) |
Subhash Chandra Bose Naripeddy | 3eedc00 | 2013-11-12 20:45:15 -0800 | [diff] [blame] | 387 | { |
Subhash Chandra Bose Naripeddy | 3eedc00 | 2013-11-12 20:45:15 -0800 | [diff] [blame] | 388 | return 0; |
| 389 | } |
| 390 | |
| 391 | int bassboost_init(effect_context_t *context) |
| 392 | { |
| 393 | bassboost_context_t *bass_ctxt = (bassboost_context_t *)context; |
Dhananjay Kumar | 574f392 | 2014-03-25 17:41:44 +0530 | [diff] [blame] | 394 | ALOGV("%s: ctxt %p", __func__, bass_ctxt); |
Aalique Grahame | 22e4910 | 2018-12-18 14:23:57 -0800 | [diff] [blame] | 395 | |
Subhash Chandra Bose Naripeddy | 3eedc00 | 2013-11-12 20:45:15 -0800 | [diff] [blame] | 396 | context->config.inputCfg.accessMode = EFFECT_BUFFER_ACCESS_READ; |
| 397 | context->config.inputCfg.channels = AUDIO_CHANNEL_OUT_STEREO; |
| 398 | context->config.inputCfg.format = AUDIO_FORMAT_PCM_16_BIT; |
| 399 | context->config.inputCfg.samplingRate = 44100; |
| 400 | context->config.inputCfg.bufferProvider.getBuffer = NULL; |
| 401 | context->config.inputCfg.bufferProvider.releaseBuffer = NULL; |
| 402 | context->config.inputCfg.bufferProvider.cookie = NULL; |
| 403 | context->config.inputCfg.mask = EFFECT_CONFIG_ALL; |
| 404 | context->config.outputCfg.accessMode = EFFECT_BUFFER_ACCESS_ACCUMULATE; |
| 405 | context->config.outputCfg.channels = AUDIO_CHANNEL_OUT_STEREO; |
| 406 | context->config.outputCfg.format = AUDIO_FORMAT_PCM_16_BIT; |
| 407 | context->config.outputCfg.samplingRate = 44100; |
| 408 | context->config.outputCfg.bufferProvider.getBuffer = NULL; |
| 409 | context->config.outputCfg.bufferProvider.releaseBuffer = NULL; |
| 410 | context->config.outputCfg.bufferProvider.cookie = NULL; |
| 411 | context->config.outputCfg.mask = EFFECT_CONFIG_ALL; |
| 412 | |
| 413 | set_config(context, &context->config); |
| 414 | |
Subhash Chandra Bose Naripeddy | e40a7cd | 2014-06-03 19:42:41 -0700 | [diff] [blame] | 415 | bass_ctxt->hw_acc_fd = -1; |
Subhash Chandra Bose Naripeddy | 3eedc00 | 2013-11-12 20:45:15 -0800 | [diff] [blame] | 416 | bass_ctxt->temp_disabled = false; |
| 417 | memset(&(bass_ctxt->offload_bass), 0, sizeof(struct bass_boost_params)); |
| 418 | |
Vatsal Bucha | c09ae06 | 2018-11-14 13:25:08 +0530 | [diff] [blame] | 419 | enable_gcov(); |
Subhash Chandra Bose Naripeddy | 3eedc00 | 2013-11-12 20:45:15 -0800 | [diff] [blame] | 420 | return 0; |
| 421 | } |
| 422 | |
| 423 | int bassboost_enable(effect_context_t *context) |
| 424 | { |
| 425 | bassboost_context_t *bass_ctxt = (bassboost_context_t *)context; |
| 426 | |
Dhananjay Kumar | 574f392 | 2014-03-25 17:41:44 +0530 | [diff] [blame] | 427 | ALOGV("%s: ctxt %p, strength %d", __func__, bass_ctxt, bass_ctxt->strength); |
wjiang | 95d74c2 | 2014-03-28 12:29:58 +0800 | [diff] [blame] | 428 | |
| 429 | if (!offload_bassboost_get_enable_flag(&(bass_ctxt->offload_bass)) && |
| 430 | !(bass_ctxt->temp_disabled)) { |
Subhash Chandra Bose Naripeddy | 3eedc00 | 2013-11-12 20:45:15 -0800 | [diff] [blame] | 431 | offload_bassboost_set_enable_flag(&(bass_ctxt->offload_bass), true); |
wjiang | d45948e | 2014-02-24 22:19:43 +0800 | [diff] [blame] | 432 | if (bass_ctxt->ctl && bass_ctxt->strength) |
| 433 | offload_bassboost_send_params(bass_ctxt->ctl, |
Subhash Chandra Bose Naripeddy | e40a7cd | 2014-06-03 19:42:41 -0700 | [diff] [blame] | 434 | &bass_ctxt->offload_bass, |
wjiang | d45948e | 2014-02-24 22:19:43 +0800 | [diff] [blame] | 435 | OFFLOAD_SEND_BASSBOOST_ENABLE_FLAG | |
| 436 | OFFLOAD_SEND_BASSBOOST_STRENGTH); |
Subhash Chandra Bose Naripeddy | e40a7cd | 2014-06-03 19:42:41 -0700 | [diff] [blame] | 437 | if ((bass_ctxt->hw_acc_fd > 0) && (bass_ctxt->strength)) |
| 438 | hw_acc_bassboost_send_params(bass_ctxt->hw_acc_fd, |
| 439 | &bass_ctxt->offload_bass, |
| 440 | OFFLOAD_SEND_BASSBOOST_ENABLE_FLAG | |
| 441 | OFFLOAD_SEND_BASSBOOST_STRENGTH); |
wjiang | d45948e | 2014-02-24 22:19:43 +0800 | [diff] [blame] | 442 | } |
Subhash Chandra Bose Naripeddy | 3eedc00 | 2013-11-12 20:45:15 -0800 | [diff] [blame] | 443 | return 0; |
| 444 | } |
| 445 | |
| 446 | int bassboost_disable(effect_context_t *context) |
| 447 | { |
| 448 | bassboost_context_t *bass_ctxt = (bassboost_context_t *)context; |
| 449 | |
Dhananjay Kumar | 574f392 | 2014-03-25 17:41:44 +0530 | [diff] [blame] | 450 | ALOGV("%s: ctxt %p", __func__, bass_ctxt); |
Subhash Chandra Bose Naripeddy | 3eedc00 | 2013-11-12 20:45:15 -0800 | [diff] [blame] | 451 | if (offload_bassboost_get_enable_flag(&(bass_ctxt->offload_bass))) { |
| 452 | offload_bassboost_set_enable_flag(&(bass_ctxt->offload_bass), false); |
| 453 | if (bass_ctxt->ctl) |
| 454 | offload_bassboost_send_params(bass_ctxt->ctl, |
Subhash Chandra Bose Naripeddy | e40a7cd | 2014-06-03 19:42:41 -0700 | [diff] [blame] | 455 | &bass_ctxt->offload_bass, |
Subhash Chandra Bose Naripeddy | 3eedc00 | 2013-11-12 20:45:15 -0800 | [diff] [blame] | 456 | OFFLOAD_SEND_BASSBOOST_ENABLE_FLAG); |
Subhash Chandra Bose Naripeddy | e40a7cd | 2014-06-03 19:42:41 -0700 | [diff] [blame] | 457 | if (bass_ctxt->hw_acc_fd > 0) |
| 458 | hw_acc_bassboost_send_params(bass_ctxt->hw_acc_fd, |
| 459 | &bass_ctxt->offload_bass, |
| 460 | OFFLOAD_SEND_BASSBOOST_ENABLE_FLAG); |
Subhash Chandra Bose Naripeddy | 3eedc00 | 2013-11-12 20:45:15 -0800 | [diff] [blame] | 461 | } |
| 462 | return 0; |
| 463 | } |
| 464 | |
| 465 | int bassboost_start(effect_context_t *context, output_context_t *output) |
| 466 | { |
| 467 | bassboost_context_t *bass_ctxt = (bassboost_context_t *)context; |
| 468 | |
Dhananjay Kumar | 574f392 | 2014-03-25 17:41:44 +0530 | [diff] [blame] | 469 | ALOGV("%s: ctxt %p, ctl %p, strength %d", __func__, bass_ctxt, |
| 470 | output->ctl, bass_ctxt->strength); |
Subhash Chandra Bose Naripeddy | 3eedc00 | 2013-11-12 20:45:15 -0800 | [diff] [blame] | 471 | bass_ctxt->ctl = output->ctl; |
Subhash Chandra Bose Naripeddy | e40a7cd | 2014-06-03 19:42:41 -0700 | [diff] [blame] | 472 | if (offload_bassboost_get_enable_flag(&(bass_ctxt->offload_bass))) { |
Amit Shekhar | d02f2cd | 2014-01-16 16:51:43 -0800 | [diff] [blame] | 473 | if (bass_ctxt->ctl) |
Subhash Chandra Bose Naripeddy | e40a7cd | 2014-06-03 19:42:41 -0700 | [diff] [blame] | 474 | offload_bassboost_send_params(bass_ctxt->ctl, &bass_ctxt->offload_bass, |
Amit Shekhar | d02f2cd | 2014-01-16 16:51:43 -0800 | [diff] [blame] | 475 | OFFLOAD_SEND_BASSBOOST_ENABLE_FLAG | |
| 476 | OFFLOAD_SEND_BASSBOOST_STRENGTH); |
Subhash Chandra Bose Naripeddy | e40a7cd | 2014-06-03 19:42:41 -0700 | [diff] [blame] | 477 | if (bass_ctxt->hw_acc_fd > 0) |
| 478 | hw_acc_bassboost_send_params(bass_ctxt->hw_acc_fd, |
| 479 | &bass_ctxt->offload_bass, |
| 480 | OFFLOAD_SEND_BASSBOOST_ENABLE_FLAG | |
| 481 | OFFLOAD_SEND_BASSBOOST_STRENGTH); |
| 482 | } |
Subhash Chandra Bose Naripeddy | 3eedc00 | 2013-11-12 20:45:15 -0800 | [diff] [blame] | 483 | return 0; |
| 484 | } |
| 485 | |
Subhash Chandra Bose Naripeddy | e40a7cd | 2014-06-03 19:42:41 -0700 | [diff] [blame] | 486 | int bassboost_stop(effect_context_t *context, output_context_t *output __unused) |
Subhash Chandra Bose Naripeddy | 3eedc00 | 2013-11-12 20:45:15 -0800 | [diff] [blame] | 487 | { |
| 488 | bassboost_context_t *bass_ctxt = (bassboost_context_t *)context; |
| 489 | |
Dhananjay Kumar | 574f392 | 2014-03-25 17:41:44 +0530 | [diff] [blame] | 490 | ALOGV("%s: ctxt %p", __func__, bass_ctxt); |
Subhash Chandra Bose Naripeddy | e40a7cd | 2014-06-03 19:42:41 -0700 | [diff] [blame] | 491 | if (offload_bassboost_get_enable_flag(&(bass_ctxt->offload_bass)) && |
| 492 | bass_ctxt->ctl) { |
| 493 | struct bass_boost_params bassboost; |
| 494 | bassboost.enable_flag = false; |
| 495 | offload_bassboost_send_params(bass_ctxt->ctl, &bassboost, |
| 496 | OFFLOAD_SEND_BASSBOOST_ENABLE_FLAG); |
| 497 | } |
Subhash Chandra Bose Naripeddy | 3eedc00 | 2013-11-12 20:45:15 -0800 | [diff] [blame] | 498 | bass_ctxt->ctl = NULL; |
| 499 | return 0; |
| 500 | } |
Subhash Chandra Bose Naripeddy | e40a7cd | 2014-06-03 19:42:41 -0700 | [diff] [blame] | 501 | |
| 502 | int bassboost_set_mode(effect_context_t *context, int32_t hw_acc_fd) |
| 503 | { |
| 504 | bassboost_context_t *bass_ctxt = (bassboost_context_t *)context; |
| 505 | |
| 506 | ALOGV("%s: ctxt %p", __func__, bass_ctxt); |
| 507 | bass_ctxt->hw_acc_fd = hw_acc_fd; |
| 508 | if ((bass_ctxt->hw_acc_fd > 0) && |
| 509 | (offload_bassboost_get_enable_flag(&(bass_ctxt->offload_bass)))) |
| 510 | hw_acc_bassboost_send_params(bass_ctxt->hw_acc_fd, |
| 511 | &bass_ctxt->offload_bass, |
| 512 | OFFLOAD_SEND_BASSBOOST_ENABLE_FLAG | |
| 513 | OFFLOAD_SEND_BASSBOOST_STRENGTH); |
| 514 | return 0; |
| 515 | } |
Dhananjay Kumar | 5f15ff9 | 2014-05-19 16:45:08 +0800 | [diff] [blame] | 516 | |
| 517 | #undef LOG_TAG |
| 518 | #define LOG_TAG "offload_effect_pbe" |
| 519 | /* |
| 520 | * PBE operations |
| 521 | */ |
| 522 | |
| 523 | int pbe_set_device(effect_context_t *context, uint32_t device) |
| 524 | { |
| 525 | pbe_context_t *pbe_ctxt = (pbe_context_t *)context; |
| 526 | char propValue[PROPERTY_VALUE_MAX]; |
| 527 | bool pbe_enabled_by_prop = false; |
| 528 | |
| 529 | ALOGV("%s: device: %d", __func__, device); |
| 530 | pbe_ctxt->device = device; |
| 531 | |
Aniket Kumar Lata | 8fc67e6 | 2017-05-02 12:33:46 -0700 | [diff] [blame] | 532 | if (property_get("vendor.audio.safx.pbe.enabled", propValue, NULL)) { |
Dhananjay Kumar | 5f15ff9 | 2014-05-19 16:45:08 +0800 | [diff] [blame] | 533 | pbe_enabled_by_prop = atoi(propValue) || |
| 534 | !strncmp("true", propValue, 4); |
| 535 | } |
| 536 | |
| 537 | if (device == AUDIO_DEVICE_OUT_SPEAKER && pbe_enabled_by_prop == true) { |
| 538 | if (pbe_ctxt->temp_disabled) { |
| 539 | if (effect_is_active(&pbe_ctxt->common)) { |
| 540 | offload_pbe_set_enable_flag(&(pbe_ctxt->offload_pbe), true); |
| 541 | if (pbe_ctxt->ctl) |
| 542 | offload_pbe_send_params(pbe_ctxt->ctl, |
| 543 | &pbe_ctxt->offload_pbe, |
| 544 | OFFLOAD_SEND_PBE_ENABLE_FLAG | |
| 545 | OFFLOAD_SEND_PBE_CONFIG); |
| 546 | if (pbe_ctxt->hw_acc_fd > 0) |
| 547 | hw_acc_pbe_send_params(pbe_ctxt->hw_acc_fd, |
| 548 | &pbe_ctxt->offload_pbe, |
| 549 | OFFLOAD_SEND_PBE_ENABLE_FLAG | |
| 550 | OFFLOAD_SEND_PBE_CONFIG); |
| 551 | } |
| 552 | pbe_ctxt->temp_disabled = false; |
| 553 | } |
| 554 | } else { |
| 555 | if (!pbe_ctxt->temp_disabled) { |
| 556 | if (effect_is_active(&pbe_ctxt->common)) { |
| 557 | offload_pbe_set_enable_flag(&(pbe_ctxt->offload_pbe), false); |
| 558 | if (pbe_ctxt->ctl) |
| 559 | offload_pbe_send_params(pbe_ctxt->ctl, |
| 560 | &pbe_ctxt->offload_pbe, |
| 561 | OFFLOAD_SEND_PBE_ENABLE_FLAG); |
| 562 | if (pbe_ctxt->hw_acc_fd > 0) |
| 563 | hw_acc_pbe_send_params(pbe_ctxt->hw_acc_fd, |
| 564 | &pbe_ctxt->offload_pbe, |
| 565 | OFFLOAD_SEND_PBE_ENABLE_FLAG); |
| 566 | } |
| 567 | pbe_ctxt->temp_disabled = true; |
| 568 | } |
| 569 | } |
| 570 | offload_pbe_set_device(&(pbe_ctxt->offload_pbe), device); |
| 571 | return 0; |
| 572 | } |
| 573 | |
Aalique Grahame | 22e4910 | 2018-12-18 14:23:57 -0800 | [diff] [blame] | 574 | int pbe_reset(effect_context_t *context __unused) |
Dhananjay Kumar | 5f15ff9 | 2014-05-19 16:45:08 +0800 | [diff] [blame] | 575 | { |
Dhananjay Kumar | 5f15ff9 | 2014-05-19 16:45:08 +0800 | [diff] [blame] | 576 | return 0; |
| 577 | } |
| 578 | |
| 579 | int pbe_init(effect_context_t *context) |
| 580 | { |
| 581 | pbe_context_t *pbe_ctxt = (pbe_context_t *)context; |
| 582 | |
| 583 | ALOGV("%s", __func__); |
| 584 | context->config.inputCfg.accessMode = EFFECT_BUFFER_ACCESS_READ; |
| 585 | context->config.inputCfg.channels = AUDIO_CHANNEL_OUT_STEREO; |
| 586 | context->config.inputCfg.format = AUDIO_FORMAT_PCM_16_BIT; |
| 587 | context->config.inputCfg.samplingRate = 44100; |
| 588 | context->config.inputCfg.bufferProvider.getBuffer = NULL; |
| 589 | context->config.inputCfg.bufferProvider.releaseBuffer = NULL; |
| 590 | context->config.inputCfg.bufferProvider.cookie = NULL; |
| 591 | context->config.inputCfg.mask = EFFECT_CONFIG_ALL; |
| 592 | context->config.outputCfg.accessMode = EFFECT_BUFFER_ACCESS_ACCUMULATE; |
| 593 | context->config.outputCfg.channels = AUDIO_CHANNEL_OUT_STEREO; |
| 594 | context->config.outputCfg.format = AUDIO_FORMAT_PCM_16_BIT; |
| 595 | context->config.outputCfg.samplingRate = 44100; |
| 596 | context->config.outputCfg.bufferProvider.getBuffer = NULL; |
| 597 | context->config.outputCfg.bufferProvider.releaseBuffer = NULL; |
| 598 | context->config.outputCfg.bufferProvider.cookie = NULL; |
| 599 | context->config.outputCfg.mask = EFFECT_CONFIG_ALL; |
| 600 | |
| 601 | set_config(context, &context->config); |
| 602 | |
| 603 | pbe_ctxt->hw_acc_fd = -1; |
| 604 | pbe_ctxt->temp_disabled = false; |
| 605 | memset(&(pbe_ctxt->offload_pbe), 0, sizeof(struct pbe_params)); |
| 606 | pbe_load_config(&(pbe_ctxt->offload_pbe)); |
| 607 | |
| 608 | return 0; |
| 609 | } |
| 610 | |
| 611 | int pbe_enable(effect_context_t *context) |
| 612 | { |
| 613 | pbe_context_t *pbe_ctxt = (pbe_context_t *)context; |
| 614 | |
| 615 | ALOGV("%s", __func__); |
| 616 | |
| 617 | if (!offload_pbe_get_enable_flag(&(pbe_ctxt->offload_pbe)) && |
| 618 | !(pbe_ctxt->temp_disabled)) { |
| 619 | offload_pbe_set_enable_flag(&(pbe_ctxt->offload_pbe), true); |
| 620 | if (pbe_ctxt->ctl) |
| 621 | offload_pbe_send_params(pbe_ctxt->ctl, |
| 622 | &pbe_ctxt->offload_pbe, |
| 623 | OFFLOAD_SEND_PBE_ENABLE_FLAG | |
| 624 | OFFLOAD_SEND_PBE_CONFIG); |
| 625 | if (pbe_ctxt->hw_acc_fd > 0) |
| 626 | hw_acc_pbe_send_params(pbe_ctxt->hw_acc_fd, |
| 627 | &pbe_ctxt->offload_pbe, |
| 628 | OFFLOAD_SEND_PBE_ENABLE_FLAG | |
| 629 | OFFLOAD_SEND_PBE_CONFIG); |
| 630 | } |
| 631 | return 0; |
| 632 | } |
| 633 | |
| 634 | int pbe_disable(effect_context_t *context) |
| 635 | { |
| 636 | pbe_context_t *pbe_ctxt = (pbe_context_t *)context; |
| 637 | |
| 638 | ALOGV("%s", __func__); |
| 639 | if (offload_pbe_get_enable_flag(&(pbe_ctxt->offload_pbe))) { |
| 640 | offload_pbe_set_enable_flag(&(pbe_ctxt->offload_pbe), false); |
| 641 | if (pbe_ctxt->ctl) |
| 642 | offload_pbe_send_params(pbe_ctxt->ctl, |
| 643 | &pbe_ctxt->offload_pbe, |
| 644 | OFFLOAD_SEND_PBE_ENABLE_FLAG); |
| 645 | if (pbe_ctxt->hw_acc_fd > 0) |
| 646 | hw_acc_pbe_send_params(pbe_ctxt->hw_acc_fd, |
| 647 | &pbe_ctxt->offload_pbe, |
| 648 | OFFLOAD_SEND_PBE_ENABLE_FLAG); |
| 649 | } |
| 650 | return 0; |
| 651 | } |
| 652 | |
| 653 | int pbe_start(effect_context_t *context, output_context_t *output) |
| 654 | { |
| 655 | pbe_context_t *pbe_ctxt = (pbe_context_t *)context; |
| 656 | |
| 657 | ALOGV("%s", __func__); |
| 658 | pbe_ctxt->ctl = output->ctl; |
| 659 | ALOGV("output->ctl: %p", output->ctl); |
| 660 | if (offload_pbe_get_enable_flag(&(pbe_ctxt->offload_pbe))) { |
| 661 | if (pbe_ctxt->ctl) |
| 662 | offload_pbe_send_params(pbe_ctxt->ctl, &pbe_ctxt->offload_pbe, |
| 663 | OFFLOAD_SEND_PBE_ENABLE_FLAG | |
| 664 | OFFLOAD_SEND_PBE_CONFIG); |
| 665 | if (pbe_ctxt->hw_acc_fd > 0) |
| 666 | hw_acc_pbe_send_params(pbe_ctxt->hw_acc_fd, |
| 667 | &pbe_ctxt->offload_pbe, |
| 668 | OFFLOAD_SEND_PBE_ENABLE_FLAG | |
| 669 | OFFLOAD_SEND_PBE_CONFIG); |
| 670 | } |
| 671 | return 0; |
| 672 | } |
| 673 | |
| 674 | int pbe_stop(effect_context_t *context, output_context_t *output __unused) |
| 675 | { |
| 676 | pbe_context_t *pbe_ctxt = (pbe_context_t *)context; |
| 677 | |
| 678 | ALOGV("%s", __func__); |
| 679 | pbe_ctxt->ctl = NULL; |
| 680 | return 0; |
| 681 | } |
| 682 | |
| 683 | int pbe_set_mode(effect_context_t *context, int32_t hw_acc_fd) |
| 684 | { |
| 685 | pbe_context_t *pbe_ctxt = (pbe_context_t *)context; |
| 686 | |
| 687 | ALOGV("%s: ctxt %p", __func__, pbe_ctxt); |
| 688 | pbe_ctxt->hw_acc_fd = hw_acc_fd; |
| 689 | if ((pbe_ctxt->hw_acc_fd > 0) && |
| 690 | (offload_pbe_get_enable_flag(&(pbe_ctxt->offload_pbe)))) |
| 691 | hw_acc_pbe_send_params(pbe_ctxt->hw_acc_fd, |
| 692 | &pbe_ctxt->offload_pbe, |
| 693 | OFFLOAD_SEND_PBE_ENABLE_FLAG | |
| 694 | OFFLOAD_SEND_PBE_CONFIG); |
| 695 | return 0; |
| 696 | } |
| 697 | |
| 698 | static int pbe_load_config(struct pbe_params *params) |
| 699 | { |
| 700 | int ret = 0; |
| 701 | uint32_t len = 0; |
| 702 | uint32_t propValue = 0; |
| 703 | uint32_t pbe_app_type = PBE_CONF_APP_ID; |
| 704 | char propValueStr[PROPERTY_VALUE_MAX]; |
| 705 | void *acdb_handle = NULL; |
| 706 | acdb_get_audio_cal_t acdb_get_audio_cal = NULL; |
Weiyin Jiang | 90ac1ea | 2017-04-13 14:18:23 +0800 | [diff] [blame] | 707 | acdb_audio_cal_cfg_t cal_cfg; |
| 708 | memset(&cal_cfg, 0, sizeof(acdb_audio_cal_cfg_t)); |
Dhananjay Kumar | 5f15ff9 | 2014-05-19 16:45:08 +0800 | [diff] [blame] | 709 | |
| 710 | acdb_handle = dlopen(LIB_ACDB_LOADER, RTLD_NOW); |
| 711 | if (acdb_handle == NULL) { |
| 712 | ALOGE("%s error opening library %s", __func__, LIB_ACDB_LOADER); |
| 713 | return -EFAULT; |
| 714 | } |
| 715 | |
| 716 | acdb_get_audio_cal = (acdb_get_audio_cal_t)dlsym(acdb_handle, |
| 717 | "acdb_loader_get_audio_cal_v2"); |
| 718 | if (acdb_get_audio_cal == NULL) { |
| 719 | dlclose(acdb_handle); |
| 720 | ALOGE("%s error resolving acdb func symbols", __func__); |
| 721 | return -EFAULT; |
| 722 | } |
Aniket Kumar Lata | 8fc67e6 | 2017-05-02 12:33:46 -0700 | [diff] [blame] | 723 | if (property_get("vendor.audio.safx.pbe.app.type", propValueStr, "0")) { |
Dhananjay Kumar | 5f15ff9 | 2014-05-19 16:45:08 +0800 | [diff] [blame] | 724 | propValue = atoll(propValueStr); |
| 725 | if (propValue != 0) { |
| 726 | pbe_app_type = propValue; |
| 727 | } |
| 728 | } |
| 729 | ALOGD("%s pbe_app_type = 0x%.8x", __func__, pbe_app_type); |
| 730 | |
| 731 | cal_cfg.persist = 1; |
| 732 | cal_cfg.cal_type = AUDIO_STREAM_CAL_TYPE; |
| 733 | cal_cfg.app_type = pbe_app_type; |
| 734 | cal_cfg.module_id = PBE_CONF_MODULE_ID; |
| 735 | cal_cfg.param_id = PBE_CONF_PARAM_ID; |
| 736 | |
| 737 | len = sizeof(params->config); |
| 738 | ret = acdb_get_audio_cal((void *)&cal_cfg, (void*)&(params->config), &len); |
| 739 | ALOGD("%s ret = %d, len = %u", __func__, ret, len); |
| 740 | if (ret == 0) |
| 741 | params->cfg_len = len; |
| 742 | |
| 743 | dlclose(acdb_handle); |
| 744 | return ret; |
| 745 | } |