Subhash Chandra Bose Naripeddy | 3eedc00 | 2013-11-12 20:45:15 -0800 | [diff] [blame] | 1 | /* |
wjiang | ee2ff96 | 2014-03-18 06:49:46 +0800 | [diff] [blame] | 2 | * Copyright (c) 2013-2014, 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 | |
| 20 | #define LOG_TAG "offload_effect_bass_boost" |
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> |
| 24 | #include <cutils/log.h> |
| 25 | #include <tinyalsa/asoundlib.h> |
Subhash Chandra Bose Naripeddy | 090a2aa | 2014-01-30 14:03:12 -0800 | [diff] [blame] | 26 | #include <sound/audio_effects.h> |
Subhash Chandra Bose Naripeddy | 3eedc00 | 2013-11-12 20:45:15 -0800 | [diff] [blame] | 27 | #include <audio_effects/effect_bassboost.h> |
| 28 | |
| 29 | #include "effect_api.h" |
| 30 | #include "bass_boost.h" |
| 31 | |
| 32 | /* Offload bassboost UUID: 2c4a8c24-1581-487f-94f6-0002a5d5c51b */ |
| 33 | const effect_descriptor_t bassboost_descriptor = { |
| 34 | {0x0634f220, 0xddd4, 0x11db, 0xa0fc, { 0x00, 0x02, 0xa5, 0xd5, 0xc5, 0x1b }}, |
| 35 | {0x2c4a8c24, 0x1581, 0x487f, 0x94f6, { 0x00, 0x02, 0xa5, 0xd5, 0xc5, 0x1b}}, // uuid |
| 36 | EFFECT_CONTROL_API_VERSION, |
| 37 | (EFFECT_FLAG_TYPE_INSERT | EFFECT_FLAG_DEVICE_IND | EFFECT_FLAG_HW_ACC_TUNNEL), |
| 38 | 0, /* TODO */ |
| 39 | 1, |
| 40 | "MSM offload bassboost", |
| 41 | "The Android Open Source Project", |
| 42 | }; |
| 43 | |
| 44 | /* |
| 45 | * Bassboost operations |
| 46 | */ |
| 47 | |
| 48 | int bassboost_get_strength(bassboost_context_t *context) |
| 49 | { |
Dhananjay Kumar | 574f392 | 2014-03-25 17:41:44 +0530 | [diff] [blame] | 50 | ALOGV("%s: ctxt %p, strength: %d", __func__, |
| 51 | context, context->strength); |
Subhash Chandra Bose Naripeddy | 3eedc00 | 2013-11-12 20:45:15 -0800 | [diff] [blame] | 52 | return context->strength; |
| 53 | } |
| 54 | |
| 55 | int bassboost_set_strength(bassboost_context_t *context, uint32_t strength) |
| 56 | { |
Dhananjay Kumar | 574f392 | 2014-03-25 17:41:44 +0530 | [diff] [blame] | 57 | ALOGV("%s: ctxt %p, strength: %d", __func__, context, strength); |
Subhash Chandra Bose Naripeddy | 3eedc00 | 2013-11-12 20:45:15 -0800 | [diff] [blame] | 58 | context->strength = strength; |
| 59 | |
| 60 | offload_bassboost_set_strength(&(context->offload_bass), strength); |
| 61 | if (context->ctl) |
Subhash Chandra Bose Naripeddy | e40a7cd | 2014-06-03 19:42:41 -0700 | [diff] [blame^] | 62 | offload_bassboost_send_params(context->ctl, &context->offload_bass, |
Subhash Chandra Bose Naripeddy | 3eedc00 | 2013-11-12 20:45:15 -0800 | [diff] [blame] | 63 | OFFLOAD_SEND_BASSBOOST_ENABLE_FLAG | |
| 64 | OFFLOAD_SEND_BASSBOOST_STRENGTH); |
Subhash Chandra Bose Naripeddy | e40a7cd | 2014-06-03 19:42:41 -0700 | [diff] [blame^] | 65 | if (context->hw_acc_fd > 0) |
| 66 | hw_acc_bassboost_send_params(context->hw_acc_fd, |
| 67 | &context->offload_bass, |
| 68 | OFFLOAD_SEND_BASSBOOST_ENABLE_FLAG | |
| 69 | OFFLOAD_SEND_BASSBOOST_STRENGTH); |
Subhash Chandra Bose Naripeddy | 3eedc00 | 2013-11-12 20:45:15 -0800 | [diff] [blame] | 70 | return 0; |
| 71 | } |
| 72 | |
| 73 | int bassboost_get_parameter(effect_context_t *context, effect_param_t *p, |
| 74 | uint32_t *size) |
| 75 | { |
| 76 | bassboost_context_t *bass_ctxt = (bassboost_context_t *)context; |
| 77 | int voffset = ((p->psize - 1) / sizeof(int32_t) + 1) * sizeof(int32_t); |
| 78 | int32_t *param_tmp = (int32_t *)p->data; |
| 79 | int32_t param = *param_tmp++; |
| 80 | void *value = p->data + voffset; |
| 81 | int i; |
| 82 | |
Dhananjay Kumar | 574f392 | 2014-03-25 17:41:44 +0530 | [diff] [blame] | 83 | ALOGV("%s: ctxt %p, param %d", __func__, bass_ctxt, param); |
Subhash Chandra Bose Naripeddy | 3eedc00 | 2013-11-12 20:45:15 -0800 | [diff] [blame] | 84 | |
| 85 | p->status = 0; |
| 86 | |
| 87 | switch (param) { |
| 88 | case BASSBOOST_PARAM_STRENGTH_SUPPORTED: |
| 89 | if (p->vsize < sizeof(uint32_t)) |
| 90 | p->status = -EINVAL; |
| 91 | p->vsize = sizeof(uint32_t); |
| 92 | break; |
| 93 | case BASSBOOST_PARAM_STRENGTH: |
| 94 | if (p->vsize < sizeof(int16_t)) |
| 95 | p->status = -EINVAL; |
| 96 | p->vsize = sizeof(int16_t); |
| 97 | break; |
| 98 | default: |
| 99 | p->status = -EINVAL; |
| 100 | } |
| 101 | |
| 102 | *size = sizeof(effect_param_t) + voffset + p->vsize; |
| 103 | |
| 104 | if (p->status != 0) |
| 105 | return 0; |
| 106 | |
| 107 | switch (param) { |
| 108 | case BASSBOOST_PARAM_STRENGTH_SUPPORTED: |
Subhash Chandra Bose Naripeddy | 3eedc00 | 2013-11-12 20:45:15 -0800 | [diff] [blame] | 109 | *(uint32_t *)value = 1; |
| 110 | break; |
| 111 | |
| 112 | case BASSBOOST_PARAM_STRENGTH: |
Subhash Chandra Bose Naripeddy | 3eedc00 | 2013-11-12 20:45:15 -0800 | [diff] [blame] | 113 | *(int16_t *)value = bassboost_get_strength(bass_ctxt); |
| 114 | break; |
| 115 | |
| 116 | default: |
| 117 | p->status = -EINVAL; |
| 118 | break; |
| 119 | } |
| 120 | |
| 121 | return 0; |
| 122 | } |
| 123 | |
| 124 | int bassboost_set_parameter(effect_context_t *context, effect_param_t *p, |
Subhash Chandra Bose Naripeddy | e40a7cd | 2014-06-03 19:42:41 -0700 | [diff] [blame^] | 125 | uint32_t size __unused) |
Subhash Chandra Bose Naripeddy | 3eedc00 | 2013-11-12 20:45:15 -0800 | [diff] [blame] | 126 | { |
| 127 | bassboost_context_t *bass_ctxt = (bassboost_context_t *)context; |
| 128 | int voffset = ((p->psize - 1) / sizeof(int32_t) + 1) * sizeof(int32_t); |
| 129 | void *value = p->data + voffset; |
| 130 | int32_t *param_tmp = (int32_t *)p->data; |
| 131 | int32_t param = *param_tmp++; |
| 132 | uint32_t strength; |
| 133 | |
Dhananjay Kumar | 574f392 | 2014-03-25 17:41:44 +0530 | [diff] [blame] | 134 | ALOGV("%s: ctxt %p, param %d", __func__, bass_ctxt, param); |
Subhash Chandra Bose Naripeddy | 3eedc00 | 2013-11-12 20:45:15 -0800 | [diff] [blame] | 135 | |
| 136 | p->status = 0; |
| 137 | |
| 138 | switch (param) { |
| 139 | case BASSBOOST_PARAM_STRENGTH: |
Subhash Chandra Bose Naripeddy | 3eedc00 | 2013-11-12 20:45:15 -0800 | [diff] [blame] | 140 | strength = (uint32_t)(*(int16_t *)value); |
| 141 | bassboost_set_strength(bass_ctxt, strength); |
| 142 | break; |
| 143 | default: |
| 144 | p->status = -EINVAL; |
| 145 | break; |
| 146 | } |
| 147 | |
| 148 | return 0; |
| 149 | } |
| 150 | |
| 151 | int bassboost_set_device(effect_context_t *context, uint32_t device) |
| 152 | { |
| 153 | bassboost_context_t *bass_ctxt = (bassboost_context_t *)context; |
| 154 | |
Dhananjay Kumar | 574f392 | 2014-03-25 17:41:44 +0530 | [diff] [blame] | 155 | 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] | 156 | bass_ctxt->device = device; |
| 157 | if((device == AUDIO_DEVICE_OUT_SPEAKER) || |
| 158 | (device == AUDIO_DEVICE_OUT_BLUETOOTH_SCO_CARKIT) || |
wjiang | ee2ff96 | 2014-03-18 06:49:46 +0800 | [diff] [blame] | 159 | (device == AUDIO_DEVICE_OUT_BLUETOOTH_A2DP_SPEAKER) || |
Mingming Yin | 67e3451 | 2014-04-03 17:47:22 -0700 | [diff] [blame] | 160 | #ifdef AFE_PROXY_ENABLED |
wjiang | ee2ff96 | 2014-03-18 06:49:46 +0800 | [diff] [blame] | 161 | (device == AUDIO_DEVICE_OUT_PROXY) || |
Mingming Yin | 67e3451 | 2014-04-03 17:47:22 -0700 | [diff] [blame] | 162 | #endif |
wjiang | ee2ff96 | 2014-03-18 06:49:46 +0800 | [diff] [blame] | 163 | (device == AUDIO_DEVICE_OUT_AUX_DIGITAL) || |
Dhananjay Kumar | fd00bef | 2014-05-06 16:48:17 +0530 | [diff] [blame] | 164 | (device == AUDIO_DEVICE_OUT_USB_ACCESSORY) || |
wjiang | ee2ff96 | 2014-03-18 06:49:46 +0800 | [diff] [blame] | 165 | (device == AUDIO_DEVICE_OUT_ANLG_DOCK_HEADSET)) { |
wjiang | 50b81f4 | 2014-08-06 08:03:14 +0800 | [diff] [blame] | 166 | if (!bass_ctxt->temp_disabled) { |
| 167 | if (effect_is_active(&bass_ctxt->common)) { |
| 168 | offload_bassboost_set_enable_flag(&(bass_ctxt->offload_bass), false); |
| 169 | if (bass_ctxt->ctl) |
| 170 | offload_bassboost_send_params(bass_ctxt->ctl, |
Subhash Chandra Bose Naripeddy | e40a7cd | 2014-06-03 19:42:41 -0700 | [diff] [blame^] | 171 | &bass_ctxt->offload_bass, |
wjiang | 50b81f4 | 2014-08-06 08:03:14 +0800 | [diff] [blame] | 172 | OFFLOAD_SEND_BASSBOOST_ENABLE_FLAG); |
Subhash Chandra Bose Naripeddy | e40a7cd | 2014-06-03 19:42:41 -0700 | [diff] [blame^] | 173 | if (bass_ctxt->hw_acc_fd > 0) |
| 174 | hw_acc_bassboost_send_params(bass_ctxt->hw_acc_fd, |
| 175 | &bass_ctxt->offload_bass, |
| 176 | OFFLOAD_SEND_BASSBOOST_ENABLE_FLAG); |
wjiang | 50b81f4 | 2014-08-06 08:03:14 +0800 | [diff] [blame] | 177 | } |
Subhash Chandra Bose Naripeddy | 3eedc00 | 2013-11-12 20:45:15 -0800 | [diff] [blame] | 178 | bass_ctxt->temp_disabled = true; |
| 179 | } |
wjiang | 50b81f4 | 2014-08-06 08:03:14 +0800 | [diff] [blame] | 180 | 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] | 181 | } else { |
wjiang | 50b81f4 | 2014-08-06 08:03:14 +0800 | [diff] [blame] | 182 | if (bass_ctxt->temp_disabled) { |
| 183 | if (effect_is_active(&bass_ctxt->common)) { |
| 184 | offload_bassboost_set_enable_flag(&(bass_ctxt->offload_bass), true); |
| 185 | if (bass_ctxt->ctl) |
| 186 | offload_bassboost_send_params(bass_ctxt->ctl, |
Subhash Chandra Bose Naripeddy | e40a7cd | 2014-06-03 19:42:41 -0700 | [diff] [blame^] | 187 | &bass_ctxt->offload_bass, |
wjiang | 50b81f4 | 2014-08-06 08:03:14 +0800 | [diff] [blame] | 188 | OFFLOAD_SEND_BASSBOOST_ENABLE_FLAG); |
Subhash Chandra Bose Naripeddy | e40a7cd | 2014-06-03 19:42:41 -0700 | [diff] [blame^] | 189 | if (bass_ctxt->hw_acc_fd > 0) |
| 190 | hw_acc_bassboost_send_params(bass_ctxt->hw_acc_fd, |
| 191 | &bass_ctxt->offload_bass, |
| 192 | OFFLOAD_SEND_BASSBOOST_ENABLE_FLAG); |
wjiang | 50b81f4 | 2014-08-06 08:03:14 +0800 | [diff] [blame] | 193 | } |
Subhash Chandra Bose Naripeddy | 3eedc00 | 2013-11-12 20:45:15 -0800 | [diff] [blame] | 194 | bass_ctxt->temp_disabled = false; |
| 195 | } |
| 196 | } |
| 197 | offload_bassboost_set_device(&(bass_ctxt->offload_bass), device); |
| 198 | return 0; |
| 199 | } |
| 200 | |
| 201 | int bassboost_reset(effect_context_t *context) |
| 202 | { |
| 203 | bassboost_context_t *bass_ctxt = (bassboost_context_t *)context; |
| 204 | |
| 205 | return 0; |
| 206 | } |
| 207 | |
| 208 | int bassboost_init(effect_context_t *context) |
| 209 | { |
| 210 | bassboost_context_t *bass_ctxt = (bassboost_context_t *)context; |
| 211 | |
Dhananjay Kumar | 574f392 | 2014-03-25 17:41:44 +0530 | [diff] [blame] | 212 | ALOGV("%s: ctxt %p", __func__, bass_ctxt); |
Subhash Chandra Bose Naripeddy | 3eedc00 | 2013-11-12 20:45:15 -0800 | [diff] [blame] | 213 | context->config.inputCfg.accessMode = EFFECT_BUFFER_ACCESS_READ; |
| 214 | context->config.inputCfg.channels = AUDIO_CHANNEL_OUT_STEREO; |
| 215 | context->config.inputCfg.format = AUDIO_FORMAT_PCM_16_BIT; |
| 216 | context->config.inputCfg.samplingRate = 44100; |
| 217 | context->config.inputCfg.bufferProvider.getBuffer = NULL; |
| 218 | context->config.inputCfg.bufferProvider.releaseBuffer = NULL; |
| 219 | context->config.inputCfg.bufferProvider.cookie = NULL; |
| 220 | context->config.inputCfg.mask = EFFECT_CONFIG_ALL; |
| 221 | context->config.outputCfg.accessMode = EFFECT_BUFFER_ACCESS_ACCUMULATE; |
| 222 | context->config.outputCfg.channels = AUDIO_CHANNEL_OUT_STEREO; |
| 223 | context->config.outputCfg.format = AUDIO_FORMAT_PCM_16_BIT; |
| 224 | context->config.outputCfg.samplingRate = 44100; |
| 225 | context->config.outputCfg.bufferProvider.getBuffer = NULL; |
| 226 | context->config.outputCfg.bufferProvider.releaseBuffer = NULL; |
| 227 | context->config.outputCfg.bufferProvider.cookie = NULL; |
| 228 | context->config.outputCfg.mask = EFFECT_CONFIG_ALL; |
| 229 | |
| 230 | set_config(context, &context->config); |
| 231 | |
Subhash Chandra Bose Naripeddy | e40a7cd | 2014-06-03 19:42:41 -0700 | [diff] [blame^] | 232 | bass_ctxt->hw_acc_fd = -1; |
Subhash Chandra Bose Naripeddy | 3eedc00 | 2013-11-12 20:45:15 -0800 | [diff] [blame] | 233 | bass_ctxt->temp_disabled = false; |
| 234 | memset(&(bass_ctxt->offload_bass), 0, sizeof(struct bass_boost_params)); |
| 235 | |
| 236 | return 0; |
| 237 | } |
| 238 | |
| 239 | int bassboost_enable(effect_context_t *context) |
| 240 | { |
| 241 | bassboost_context_t *bass_ctxt = (bassboost_context_t *)context; |
| 242 | |
Dhananjay Kumar | 574f392 | 2014-03-25 17:41:44 +0530 | [diff] [blame] | 243 | ALOGV("%s: ctxt %p, strength %d", __func__, bass_ctxt, bass_ctxt->strength); |
wjiang | 95d74c2 | 2014-03-28 12:29:58 +0800 | [diff] [blame] | 244 | |
| 245 | if (!offload_bassboost_get_enable_flag(&(bass_ctxt->offload_bass)) && |
| 246 | !(bass_ctxt->temp_disabled)) { |
Subhash Chandra Bose Naripeddy | 3eedc00 | 2013-11-12 20:45:15 -0800 | [diff] [blame] | 247 | offload_bassboost_set_enable_flag(&(bass_ctxt->offload_bass), true); |
wjiang | d45948e | 2014-02-24 22:19:43 +0800 | [diff] [blame] | 248 | if (bass_ctxt->ctl && bass_ctxt->strength) |
| 249 | offload_bassboost_send_params(bass_ctxt->ctl, |
Subhash Chandra Bose Naripeddy | e40a7cd | 2014-06-03 19:42:41 -0700 | [diff] [blame^] | 250 | &bass_ctxt->offload_bass, |
wjiang | d45948e | 2014-02-24 22:19:43 +0800 | [diff] [blame] | 251 | OFFLOAD_SEND_BASSBOOST_ENABLE_FLAG | |
| 252 | OFFLOAD_SEND_BASSBOOST_STRENGTH); |
Subhash Chandra Bose Naripeddy | e40a7cd | 2014-06-03 19:42:41 -0700 | [diff] [blame^] | 253 | if ((bass_ctxt->hw_acc_fd > 0) && (bass_ctxt->strength)) |
| 254 | hw_acc_bassboost_send_params(bass_ctxt->hw_acc_fd, |
| 255 | &bass_ctxt->offload_bass, |
| 256 | OFFLOAD_SEND_BASSBOOST_ENABLE_FLAG | |
| 257 | OFFLOAD_SEND_BASSBOOST_STRENGTH); |
wjiang | d45948e | 2014-02-24 22:19:43 +0800 | [diff] [blame] | 258 | } |
Subhash Chandra Bose Naripeddy | 3eedc00 | 2013-11-12 20:45:15 -0800 | [diff] [blame] | 259 | return 0; |
| 260 | } |
| 261 | |
| 262 | int bassboost_disable(effect_context_t *context) |
| 263 | { |
| 264 | bassboost_context_t *bass_ctxt = (bassboost_context_t *)context; |
| 265 | |
Dhananjay Kumar | 574f392 | 2014-03-25 17:41:44 +0530 | [diff] [blame] | 266 | ALOGV("%s: ctxt %p", __func__, bass_ctxt); |
Subhash Chandra Bose Naripeddy | 3eedc00 | 2013-11-12 20:45:15 -0800 | [diff] [blame] | 267 | if (offload_bassboost_get_enable_flag(&(bass_ctxt->offload_bass))) { |
| 268 | offload_bassboost_set_enable_flag(&(bass_ctxt->offload_bass), false); |
| 269 | if (bass_ctxt->ctl) |
| 270 | offload_bassboost_send_params(bass_ctxt->ctl, |
Subhash Chandra Bose Naripeddy | e40a7cd | 2014-06-03 19:42:41 -0700 | [diff] [blame^] | 271 | &bass_ctxt->offload_bass, |
Subhash Chandra Bose Naripeddy | 3eedc00 | 2013-11-12 20:45:15 -0800 | [diff] [blame] | 272 | OFFLOAD_SEND_BASSBOOST_ENABLE_FLAG); |
Subhash Chandra Bose Naripeddy | e40a7cd | 2014-06-03 19:42:41 -0700 | [diff] [blame^] | 273 | if (bass_ctxt->hw_acc_fd > 0) |
| 274 | hw_acc_bassboost_send_params(bass_ctxt->hw_acc_fd, |
| 275 | &bass_ctxt->offload_bass, |
| 276 | OFFLOAD_SEND_BASSBOOST_ENABLE_FLAG); |
Subhash Chandra Bose Naripeddy | 3eedc00 | 2013-11-12 20:45:15 -0800 | [diff] [blame] | 277 | } |
| 278 | return 0; |
| 279 | } |
| 280 | |
| 281 | int bassboost_start(effect_context_t *context, output_context_t *output) |
| 282 | { |
| 283 | bassboost_context_t *bass_ctxt = (bassboost_context_t *)context; |
| 284 | |
Dhananjay Kumar | 574f392 | 2014-03-25 17:41:44 +0530 | [diff] [blame] | 285 | ALOGV("%s: ctxt %p, ctl %p, strength %d", __func__, bass_ctxt, |
| 286 | output->ctl, bass_ctxt->strength); |
Subhash Chandra Bose Naripeddy | 3eedc00 | 2013-11-12 20:45:15 -0800 | [diff] [blame] | 287 | bass_ctxt->ctl = output->ctl; |
Subhash Chandra Bose Naripeddy | e40a7cd | 2014-06-03 19:42:41 -0700 | [diff] [blame^] | 288 | if (offload_bassboost_get_enable_flag(&(bass_ctxt->offload_bass))) { |
Amit Shekhar | d02f2cd | 2014-01-16 16:51:43 -0800 | [diff] [blame] | 289 | if (bass_ctxt->ctl) |
Subhash Chandra Bose Naripeddy | e40a7cd | 2014-06-03 19:42:41 -0700 | [diff] [blame^] | 290 | offload_bassboost_send_params(bass_ctxt->ctl, &bass_ctxt->offload_bass, |
Amit Shekhar | d02f2cd | 2014-01-16 16:51:43 -0800 | [diff] [blame] | 291 | OFFLOAD_SEND_BASSBOOST_ENABLE_FLAG | |
| 292 | OFFLOAD_SEND_BASSBOOST_STRENGTH); |
Subhash Chandra Bose Naripeddy | e40a7cd | 2014-06-03 19:42:41 -0700 | [diff] [blame^] | 293 | if (bass_ctxt->hw_acc_fd > 0) |
| 294 | hw_acc_bassboost_send_params(bass_ctxt->hw_acc_fd, |
| 295 | &bass_ctxt->offload_bass, |
| 296 | OFFLOAD_SEND_BASSBOOST_ENABLE_FLAG | |
| 297 | OFFLOAD_SEND_BASSBOOST_STRENGTH); |
| 298 | } |
Subhash Chandra Bose Naripeddy | 3eedc00 | 2013-11-12 20:45:15 -0800 | [diff] [blame] | 299 | return 0; |
| 300 | } |
| 301 | |
Subhash Chandra Bose Naripeddy | e40a7cd | 2014-06-03 19:42:41 -0700 | [diff] [blame^] | 302 | 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] | 303 | { |
| 304 | bassboost_context_t *bass_ctxt = (bassboost_context_t *)context; |
| 305 | |
Dhananjay Kumar | 574f392 | 2014-03-25 17:41:44 +0530 | [diff] [blame] | 306 | ALOGV("%s: ctxt %p", __func__, bass_ctxt); |
Subhash Chandra Bose Naripeddy | e40a7cd | 2014-06-03 19:42:41 -0700 | [diff] [blame^] | 307 | if (offload_bassboost_get_enable_flag(&(bass_ctxt->offload_bass)) && |
| 308 | bass_ctxt->ctl) { |
| 309 | struct bass_boost_params bassboost; |
| 310 | bassboost.enable_flag = false; |
| 311 | offload_bassboost_send_params(bass_ctxt->ctl, &bassboost, |
| 312 | OFFLOAD_SEND_BASSBOOST_ENABLE_FLAG); |
| 313 | } |
Subhash Chandra Bose Naripeddy | 3eedc00 | 2013-11-12 20:45:15 -0800 | [diff] [blame] | 314 | bass_ctxt->ctl = NULL; |
| 315 | return 0; |
| 316 | } |
Subhash Chandra Bose Naripeddy | e40a7cd | 2014-06-03 19:42:41 -0700 | [diff] [blame^] | 317 | |
| 318 | int bassboost_set_mode(effect_context_t *context, int32_t hw_acc_fd) |
| 319 | { |
| 320 | bassboost_context_t *bass_ctxt = (bassboost_context_t *)context; |
| 321 | |
| 322 | ALOGV("%s: ctxt %p", __func__, bass_ctxt); |
| 323 | bass_ctxt->hw_acc_fd = hw_acc_fd; |
| 324 | if ((bass_ctxt->hw_acc_fd > 0) && |
| 325 | (offload_bassboost_get_enable_flag(&(bass_ctxt->offload_bass)))) |
| 326 | hw_acc_bassboost_send_params(bass_ctxt->hw_acc_fd, |
| 327 | &bass_ctxt->offload_bass, |
| 328 | OFFLOAD_SEND_BASSBOOST_ENABLE_FLAG | |
| 329 | OFFLOAD_SEND_BASSBOOST_STRENGTH); |
| 330 | return 0; |
| 331 | } |