Subhash Chandra Bose Naripeddy | 3eedc00 | 2013-11-12 20:45:15 -0800 | [diff] [blame] | 1 | /* |
Subhash Chandra Bose Naripeddy | e40a7cd | 2014-06-03 19:42:41 -0700 | [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_reverb" |
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_environmentalreverb.h> |
| 28 | #include <audio_effects/effect_presetreverb.h> |
| 29 | |
| 30 | #include "effect_api.h" |
| 31 | #include "reverb.h" |
| 32 | |
| 33 | /* Offload auxiliary environmental reverb UUID: 79a18026-18fd-4185-8233-0002a5d5c51b */ |
| 34 | const effect_descriptor_t aux_env_reverb_descriptor = { |
| 35 | { 0xc2e5d5f0, 0x94bd, 0x4763, 0x9cac, { 0x4e, 0x23, 0x4d, 0x06, 0x83, 0x9e } }, |
| 36 | { 0x79a18026, 0x18fd, 0x4185, 0x8233, { 0x00, 0x02, 0xa5, 0xd5, 0xc5, 0x1b } }, |
| 37 | EFFECT_CONTROL_API_VERSION, |
| 38 | (EFFECT_FLAG_TYPE_AUXILIARY | EFFECT_FLAG_HW_ACC_TUNNEL), |
| 39 | 0, /* TODO */ |
| 40 | 1, |
| 41 | "MSM offload Auxiliary Environmental Reverb", |
| 42 | "The Android Open Source Project", |
| 43 | }; |
| 44 | |
| 45 | /* Offload insert environmental reverb UUID: eb64ea04-973b-43d2-8f5e-0002a5d5c51b */ |
| 46 | const effect_descriptor_t ins_env_reverb_descriptor = { |
| 47 | {0xc2e5d5f0, 0x94bd, 0x4763, 0x9cac, {0x4e, 0x23, 0x4d, 0x06, 0x83, 0x9e}}, |
| 48 | {0xeb64ea04, 0x973b, 0x43d2, 0x8f5e, {0x00, 0x02, 0xa5, 0xd5, 0xc5, 0x1b}}, |
| 49 | EFFECT_CONTROL_API_VERSION, |
| 50 | (EFFECT_FLAG_TYPE_INSERT | EFFECT_FLAG_INSERT_FIRST | EFFECT_FLAG_HW_ACC_TUNNEL), |
| 51 | 0, /* TODO */ |
| 52 | 1, |
| 53 | "MSM offload Insert Environmental Reverb", |
| 54 | "The Android Open Source Project", |
| 55 | }; |
| 56 | |
| 57 | // Offload auxiliary preset reverb UUID: 6987be09-b142-4b41-9056-0002a5d5c51b */ |
| 58 | const effect_descriptor_t aux_preset_reverb_descriptor = { |
| 59 | {0x47382d60, 0xddd8, 0x11db, 0xbf3a, {0x00, 0x02, 0xa5, 0xd5, 0xc5, 0x1b}}, |
| 60 | {0x6987be09, 0xb142, 0x4b41, 0x9056, {0x00, 0x02, 0xa5, 0xd5, 0xc5, 0x1b}}, |
| 61 | EFFECT_CONTROL_API_VERSION, |
| 62 | (EFFECT_FLAG_TYPE_AUXILIARY | EFFECT_FLAG_HW_ACC_TUNNEL), |
| 63 | 0, /* TODO */ |
| 64 | 1, |
| 65 | "MSM offload Auxiliary Preset Reverb", |
| 66 | "The Android Open Source Project", |
| 67 | }; |
| 68 | |
| 69 | // Offload insert preset reverb UUID: aa2bebf6-47cf-4613-9bca-0002a5d5c51b */ |
| 70 | const effect_descriptor_t ins_preset_reverb_descriptor = { |
| 71 | {0x47382d60, 0xddd8, 0x11db, 0xbf3a, {0x00, 0x02, 0xa5, 0xd5, 0xc5, 0x1b}}, |
| 72 | {0xaa2bebf6, 0x47cf, 0x4613, 0x9bca, {0x00, 0x02, 0xa5, 0xd5, 0xc5, 0x1b}}, |
| 73 | EFFECT_CONTROL_API_VERSION, |
| 74 | (EFFECT_FLAG_TYPE_INSERT | EFFECT_FLAG_INSERT_FIRST | EFFECT_FLAG_HW_ACC_TUNNEL), |
| 75 | 0, /* TODO */ |
| 76 | 1, |
| 77 | "MSM offload Insert Preset Reverb", |
| 78 | "The Android Open Source Project", |
| 79 | }; |
| 80 | |
| 81 | static const reverb_settings_t reverb_presets[] = { |
| 82 | // REVERB_PRESET_NONE: values are unused |
| 83 | {0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, |
| 84 | // REVERB_PRESET_SMALLROOM |
| 85 | {-400, -600, 1100, 830, -400, 5, 500, 10, 1000, 1000}, |
| 86 | // REVERB_PRESET_MEDIUMROOM |
| 87 | {-400, -600, 1300, 830, -1000, 20, -200, 20, 1000, 1000}, |
| 88 | // REVERB_PRESET_LARGEROOM |
| 89 | {-400, -600, 1500, 830, -1600, 5, -1000, 40, 1000, 1000}, |
| 90 | // REVERB_PRESET_MEDIUMHALL |
| 91 | {-400, -600, 1800, 700, -1300, 15, -800, 30, 1000, 1000}, |
| 92 | // REVERB_PRESET_LARGEHALL |
| 93 | {-400, -600, 1800, 700, -2000, 30, -1400, 60, 1000, 1000}, |
| 94 | // REVERB_PRESET_PLATE |
| 95 | {-400, -200, 1300, 900, 0, 2, 0, 10, 1000, 750}, |
| 96 | }; |
| 97 | |
| 98 | |
| 99 | void reverb_auxiliary_init(reverb_context_t *context) |
| 100 | { |
| 101 | context->auxiliary = true; |
| 102 | context->preset = false; |
| 103 | } |
| 104 | |
Subhash Chandra Bose Naripeddy | e40a7cd | 2014-06-03 19:42:41 -0700 | [diff] [blame] | 105 | void reverb_insert_init(reverb_context_t *context) |
| 106 | { |
| 107 | context->auxiliary = false; |
| 108 | context->preset = true; |
| 109 | context->cur_preset = REVERB_PRESET_LAST + 1; |
| 110 | context->next_preset = REVERB_DEFAULT_PRESET; |
| 111 | } |
| 112 | |
Subhash Chandra Bose Naripeddy | 3eedc00 | 2013-11-12 20:45:15 -0800 | [diff] [blame] | 113 | void reverb_preset_init(reverb_context_t *context) |
| 114 | { |
| 115 | context->auxiliary = false; |
| 116 | context->preset = true; |
| 117 | context->cur_preset = REVERB_PRESET_LAST + 1; |
| 118 | context->next_preset = REVERB_DEFAULT_PRESET; |
| 119 | } |
| 120 | |
| 121 | /* |
| 122 | * Reverb operations |
| 123 | */ |
| 124 | int16_t reverb_get_room_level(reverb_context_t *context) |
| 125 | { |
Dhananjay Kumar | 574f392 | 2014-03-25 17:41:44 +0530 | [diff] [blame] | 126 | ALOGV("%s: ctxt %p, room level: %d", __func__, context, context->reverb_settings.roomLevel); |
Subhash Chandra Bose Naripeddy | 3eedc00 | 2013-11-12 20:45:15 -0800 | [diff] [blame] | 127 | return context->reverb_settings.roomLevel; |
| 128 | } |
| 129 | |
| 130 | void reverb_set_room_level(reverb_context_t *context, int16_t room_level) |
| 131 | { |
Dhananjay Kumar | 574f392 | 2014-03-25 17:41:44 +0530 | [diff] [blame] | 132 | ALOGV("%s: ctxt %p, room level: %d", __func__, context, room_level); |
Subhash Chandra Bose Naripeddy | 3eedc00 | 2013-11-12 20:45:15 -0800 | [diff] [blame] | 133 | context->reverb_settings.roomLevel = room_level; |
| 134 | offload_reverb_set_room_level(&(context->offload_reverb), room_level); |
| 135 | if (context->ctl) |
Subhash Chandra Bose Naripeddy | e40a7cd | 2014-06-03 19:42:41 -0700 | [diff] [blame] | 136 | offload_reverb_send_params(context->ctl, &context->offload_reverb, |
Subhash Chandra Bose Naripeddy | 3eedc00 | 2013-11-12 20:45:15 -0800 | [diff] [blame] | 137 | OFFLOAD_SEND_REVERB_ENABLE_FLAG | |
| 138 | OFFLOAD_SEND_REVERB_ROOM_LEVEL); |
Subhash Chandra Bose Naripeddy | e40a7cd | 2014-06-03 19:42:41 -0700 | [diff] [blame] | 139 | if (context->hw_acc_fd > 0) |
| 140 | hw_acc_reverb_send_params(context->hw_acc_fd, &context->offload_reverb, |
| 141 | OFFLOAD_SEND_REVERB_ENABLE_FLAG | |
| 142 | OFFLOAD_SEND_REVERB_ROOM_LEVEL); |
Subhash Chandra Bose Naripeddy | 3eedc00 | 2013-11-12 20:45:15 -0800 | [diff] [blame] | 143 | } |
| 144 | |
| 145 | int16_t reverb_get_room_hf_level(reverb_context_t *context) |
| 146 | { |
Dhananjay Kumar | 574f392 | 2014-03-25 17:41:44 +0530 | [diff] [blame] | 147 | ALOGV("%s: ctxt %p, room hf level: %d", __func__, context, |
Subhash Chandra Bose Naripeddy | 3eedc00 | 2013-11-12 20:45:15 -0800 | [diff] [blame] | 148 | context->reverb_settings.roomHFLevel); |
| 149 | return context->reverb_settings.roomHFLevel; |
| 150 | } |
| 151 | |
| 152 | void reverb_set_room_hf_level(reverb_context_t *context, int16_t room_hf_level) |
| 153 | { |
Dhananjay Kumar | 574f392 | 2014-03-25 17:41:44 +0530 | [diff] [blame] | 154 | ALOGV("%s: ctxt %p, room hf level: %d", __func__, context, room_hf_level); |
Subhash Chandra Bose Naripeddy | 3eedc00 | 2013-11-12 20:45:15 -0800 | [diff] [blame] | 155 | context->reverb_settings.roomHFLevel = room_hf_level; |
| 156 | offload_reverb_set_room_hf_level(&(context->offload_reverb), room_hf_level); |
| 157 | if (context->ctl) |
Subhash Chandra Bose Naripeddy | e40a7cd | 2014-06-03 19:42:41 -0700 | [diff] [blame] | 158 | offload_reverb_send_params(context->ctl, &context->offload_reverb, |
Subhash Chandra Bose Naripeddy | 3eedc00 | 2013-11-12 20:45:15 -0800 | [diff] [blame] | 159 | OFFLOAD_SEND_REVERB_ENABLE_FLAG | |
| 160 | OFFLOAD_SEND_REVERB_ROOM_HF_LEVEL); |
Subhash Chandra Bose Naripeddy | e40a7cd | 2014-06-03 19:42:41 -0700 | [diff] [blame] | 161 | if (context->hw_acc_fd > 0) |
| 162 | hw_acc_reverb_send_params(context->hw_acc_fd, &context->offload_reverb, |
| 163 | OFFLOAD_SEND_REVERB_ENABLE_FLAG | |
| 164 | OFFLOAD_SEND_REVERB_ROOM_HF_LEVEL); |
Subhash Chandra Bose Naripeddy | 3eedc00 | 2013-11-12 20:45:15 -0800 | [diff] [blame] | 165 | } |
| 166 | |
| 167 | uint32_t reverb_get_decay_time(reverb_context_t *context) |
| 168 | { |
Dhananjay Kumar | 574f392 | 2014-03-25 17:41:44 +0530 | [diff] [blame] | 169 | ALOGV("%s: ctxt %p, decay time: %d", __func__, context, |
| 170 | context->reverb_settings.decayTime); |
Subhash Chandra Bose Naripeddy | 3eedc00 | 2013-11-12 20:45:15 -0800 | [diff] [blame] | 171 | return context->reverb_settings.decayTime; |
| 172 | } |
| 173 | |
| 174 | void reverb_set_decay_time(reverb_context_t *context, uint32_t decay_time) |
| 175 | { |
Dhananjay Kumar | 574f392 | 2014-03-25 17:41:44 +0530 | [diff] [blame] | 176 | ALOGV("%s: ctxt %p, decay_time: %d", __func__, context, decay_time); |
Subhash Chandra Bose Naripeddy | 3eedc00 | 2013-11-12 20:45:15 -0800 | [diff] [blame] | 177 | context->reverb_settings.decayTime = decay_time; |
| 178 | offload_reverb_set_decay_time(&(context->offload_reverb), decay_time); |
| 179 | if (context->ctl) |
Subhash Chandra Bose Naripeddy | e40a7cd | 2014-06-03 19:42:41 -0700 | [diff] [blame] | 180 | offload_reverb_send_params(context->ctl, &context->offload_reverb, |
Subhash Chandra Bose Naripeddy | 3eedc00 | 2013-11-12 20:45:15 -0800 | [diff] [blame] | 181 | OFFLOAD_SEND_REVERB_ENABLE_FLAG | |
| 182 | OFFLOAD_SEND_REVERB_DECAY_TIME); |
Subhash Chandra Bose Naripeddy | e40a7cd | 2014-06-03 19:42:41 -0700 | [diff] [blame] | 183 | if (context->hw_acc_fd > 0) |
| 184 | hw_acc_reverb_send_params(context->hw_acc_fd, &context->offload_reverb, |
| 185 | OFFLOAD_SEND_REVERB_ENABLE_FLAG | |
| 186 | OFFLOAD_SEND_REVERB_DECAY_TIME); |
Subhash Chandra Bose Naripeddy | 3eedc00 | 2013-11-12 20:45:15 -0800 | [diff] [blame] | 187 | } |
| 188 | |
| 189 | int16_t reverb_get_decay_hf_ratio(reverb_context_t *context) |
| 190 | { |
Dhananjay Kumar | 574f392 | 2014-03-25 17:41:44 +0530 | [diff] [blame] | 191 | ALOGV("%s: ctxt %p, decay hf ratio: %d", __func__, context, |
Subhash Chandra Bose Naripeddy | 3eedc00 | 2013-11-12 20:45:15 -0800 | [diff] [blame] | 192 | context->reverb_settings.decayHFRatio); |
| 193 | return context->reverb_settings.decayHFRatio; |
| 194 | } |
| 195 | |
| 196 | void reverb_set_decay_hf_ratio(reverb_context_t *context, int16_t decay_hf_ratio) |
| 197 | { |
Dhananjay Kumar | 574f392 | 2014-03-25 17:41:44 +0530 | [diff] [blame] | 198 | ALOGV("%s: ctxt %p, decay_hf_ratio: %d", __func__, context, decay_hf_ratio); |
Subhash Chandra Bose Naripeddy | 3eedc00 | 2013-11-12 20:45:15 -0800 | [diff] [blame] | 199 | context->reverb_settings.decayHFRatio = decay_hf_ratio; |
| 200 | offload_reverb_set_decay_hf_ratio(&(context->offload_reverb), decay_hf_ratio); |
| 201 | if (context->ctl) |
Subhash Chandra Bose Naripeddy | e40a7cd | 2014-06-03 19:42:41 -0700 | [diff] [blame] | 202 | offload_reverb_send_params(context->ctl, &context->offload_reverb, |
Subhash Chandra Bose Naripeddy | 3eedc00 | 2013-11-12 20:45:15 -0800 | [diff] [blame] | 203 | OFFLOAD_SEND_REVERB_ENABLE_FLAG | |
| 204 | OFFLOAD_SEND_REVERB_DECAY_HF_RATIO); |
Subhash Chandra Bose Naripeddy | e40a7cd | 2014-06-03 19:42:41 -0700 | [diff] [blame] | 205 | if (context->hw_acc_fd > 0) |
| 206 | hw_acc_reverb_send_params(context->hw_acc_fd, &context->offload_reverb, |
| 207 | OFFLOAD_SEND_REVERB_ENABLE_FLAG | |
| 208 | OFFLOAD_SEND_REVERB_DECAY_HF_RATIO); |
Subhash Chandra Bose Naripeddy | 3eedc00 | 2013-11-12 20:45:15 -0800 | [diff] [blame] | 209 | } |
| 210 | |
| 211 | int16_t reverb_get_reverb_level(reverb_context_t *context) |
| 212 | { |
Dhananjay Kumar | 574f392 | 2014-03-25 17:41:44 +0530 | [diff] [blame] | 213 | ALOGV("%s: ctxt %p, reverb level: %d", __func__, context, |
| 214 | context->reverb_settings.reverbLevel); |
Subhash Chandra Bose Naripeddy | 3eedc00 | 2013-11-12 20:45:15 -0800 | [diff] [blame] | 215 | return context->reverb_settings.reverbLevel; |
| 216 | } |
| 217 | |
| 218 | void reverb_set_reverb_level(reverb_context_t *context, int16_t reverb_level) |
| 219 | { |
Dhananjay Kumar | 574f392 | 2014-03-25 17:41:44 +0530 | [diff] [blame] | 220 | ALOGV("%s: ctxt %p, reverb level: %d", __func__, context, reverb_level); |
Subhash Chandra Bose Naripeddy | 3eedc00 | 2013-11-12 20:45:15 -0800 | [diff] [blame] | 221 | context->reverb_settings.reverbLevel = reverb_level; |
| 222 | offload_reverb_set_reverb_level(&(context->offload_reverb), reverb_level); |
| 223 | if (context->ctl) |
Subhash Chandra Bose Naripeddy | e40a7cd | 2014-06-03 19:42:41 -0700 | [diff] [blame] | 224 | offload_reverb_send_params(context->ctl, &context->offload_reverb, |
Subhash Chandra Bose Naripeddy | 3eedc00 | 2013-11-12 20:45:15 -0800 | [diff] [blame] | 225 | OFFLOAD_SEND_REVERB_ENABLE_FLAG | |
| 226 | OFFLOAD_SEND_REVERB_LEVEL); |
Subhash Chandra Bose Naripeddy | e40a7cd | 2014-06-03 19:42:41 -0700 | [diff] [blame] | 227 | if (context->hw_acc_fd > 0) |
| 228 | hw_acc_reverb_send_params(context->hw_acc_fd, &context->offload_reverb, |
| 229 | OFFLOAD_SEND_REVERB_ENABLE_FLAG | |
| 230 | OFFLOAD_SEND_REVERB_LEVEL); |
Subhash Chandra Bose Naripeddy | 3eedc00 | 2013-11-12 20:45:15 -0800 | [diff] [blame] | 231 | } |
| 232 | |
| 233 | int16_t reverb_get_diffusion(reverb_context_t *context) |
| 234 | { |
Dhananjay Kumar | 574f392 | 2014-03-25 17:41:44 +0530 | [diff] [blame] | 235 | ALOGV("%s: ctxt %p, diffusion: %d", __func__, context, |
| 236 | context->reverb_settings.diffusion); |
Subhash Chandra Bose Naripeddy | 3eedc00 | 2013-11-12 20:45:15 -0800 | [diff] [blame] | 237 | return context->reverb_settings.diffusion; |
| 238 | } |
| 239 | |
| 240 | void reverb_set_diffusion(reverb_context_t *context, int16_t diffusion) |
| 241 | { |
Dhananjay Kumar | 574f392 | 2014-03-25 17:41:44 +0530 | [diff] [blame] | 242 | ALOGV("%s: ctxt %p, diffusion: %d", __func__, context, diffusion); |
Subhash Chandra Bose Naripeddy | 3eedc00 | 2013-11-12 20:45:15 -0800 | [diff] [blame] | 243 | context->reverb_settings.diffusion = diffusion; |
| 244 | offload_reverb_set_diffusion(&(context->offload_reverb), diffusion); |
| 245 | if (context->ctl) |
Subhash Chandra Bose Naripeddy | e40a7cd | 2014-06-03 19:42:41 -0700 | [diff] [blame] | 246 | offload_reverb_send_params(context->ctl, &context->offload_reverb, |
Subhash Chandra Bose Naripeddy | 3eedc00 | 2013-11-12 20:45:15 -0800 | [diff] [blame] | 247 | OFFLOAD_SEND_REVERB_ENABLE_FLAG | |
| 248 | OFFLOAD_SEND_REVERB_DIFFUSION); |
Subhash Chandra Bose Naripeddy | e40a7cd | 2014-06-03 19:42:41 -0700 | [diff] [blame] | 249 | if (context->hw_acc_fd > 0) |
| 250 | hw_acc_reverb_send_params(context->hw_acc_fd, &context->offload_reverb, |
| 251 | OFFLOAD_SEND_REVERB_ENABLE_FLAG | |
| 252 | OFFLOAD_SEND_REVERB_DIFFUSION); |
Subhash Chandra Bose Naripeddy | 3eedc00 | 2013-11-12 20:45:15 -0800 | [diff] [blame] | 253 | } |
| 254 | |
| 255 | int16_t reverb_get_density(reverb_context_t *context) |
| 256 | { |
Dhananjay Kumar | 574f392 | 2014-03-25 17:41:44 +0530 | [diff] [blame] | 257 | ALOGV("%s: ctxt %p, density: %d", __func__, context, |
| 258 | context->reverb_settings.density); |
Subhash Chandra Bose Naripeddy | 3eedc00 | 2013-11-12 20:45:15 -0800 | [diff] [blame] | 259 | return context->reverb_settings.density; |
| 260 | } |
| 261 | |
| 262 | void reverb_set_density(reverb_context_t *context, int16_t density) |
| 263 | { |
wjiang | 50b81f4 | 2014-08-06 08:03:14 +0800 | [diff] [blame] | 264 | ALOGV("%s: ctxt %p, density: %d", __func__, context, density); |
Subhash Chandra Bose Naripeddy | 3eedc00 | 2013-11-12 20:45:15 -0800 | [diff] [blame] | 265 | context->reverb_settings.density = density; |
| 266 | offload_reverb_set_density(&(context->offload_reverb), density); |
| 267 | if (context->ctl) |
Subhash Chandra Bose Naripeddy | e40a7cd | 2014-06-03 19:42:41 -0700 | [diff] [blame] | 268 | offload_reverb_send_params(context->ctl, &context->offload_reverb, |
Subhash Chandra Bose Naripeddy | 3eedc00 | 2013-11-12 20:45:15 -0800 | [diff] [blame] | 269 | OFFLOAD_SEND_REVERB_ENABLE_FLAG | |
| 270 | OFFLOAD_SEND_REVERB_DENSITY); |
Subhash Chandra Bose Naripeddy | e40a7cd | 2014-06-03 19:42:41 -0700 | [diff] [blame] | 271 | if (context->hw_acc_fd > 0) |
| 272 | hw_acc_reverb_send_params(context->hw_acc_fd, &context->offload_reverb, |
| 273 | OFFLOAD_SEND_REVERB_ENABLE_FLAG | |
| 274 | OFFLOAD_SEND_REVERB_DENSITY); |
Subhash Chandra Bose Naripeddy | 3eedc00 | 2013-11-12 20:45:15 -0800 | [diff] [blame] | 275 | } |
| 276 | |
| 277 | void reverb_set_preset(reverb_context_t *context, int16_t preset) |
| 278 | { |
wjiang | b27e25f | 2014-01-22 13:24:26 +0800 | [diff] [blame] | 279 | bool enable; |
Dhananjay Kumar | 574f392 | 2014-03-25 17:41:44 +0530 | [diff] [blame] | 280 | ALOGV("%s: ctxt %p, preset: %d", __func__, context, preset); |
Subhash Chandra Bose Naripeddy | 3eedc00 | 2013-11-12 20:45:15 -0800 | [diff] [blame] | 281 | context->next_preset = preset; |
| 282 | offload_reverb_set_preset(&(context->offload_reverb), preset); |
wjiang | b27e25f | 2014-01-22 13:24:26 +0800 | [diff] [blame] | 283 | |
| 284 | enable = (preset == REVERB_PRESET_NONE) ? false: true; |
| 285 | offload_reverb_set_enable_flag(&(context->offload_reverb), enable); |
| 286 | |
Subhash Chandra Bose Naripeddy | 3eedc00 | 2013-11-12 20:45:15 -0800 | [diff] [blame] | 287 | if (context->ctl) |
Subhash Chandra Bose Naripeddy | e40a7cd | 2014-06-03 19:42:41 -0700 | [diff] [blame] | 288 | offload_reverb_send_params(context->ctl, &context->offload_reverb, |
Subhash Chandra Bose Naripeddy | 3eedc00 | 2013-11-12 20:45:15 -0800 | [diff] [blame] | 289 | OFFLOAD_SEND_REVERB_ENABLE_FLAG | |
| 290 | OFFLOAD_SEND_REVERB_PRESET); |
Subhash Chandra Bose Naripeddy | e40a7cd | 2014-06-03 19:42:41 -0700 | [diff] [blame] | 291 | if (context->hw_acc_fd > 0) |
| 292 | hw_acc_reverb_send_params(context->hw_acc_fd, &context->offload_reverb, |
| 293 | OFFLOAD_SEND_REVERB_ENABLE_FLAG | |
| 294 | OFFLOAD_SEND_REVERB_PRESET); |
Subhash Chandra Bose Naripeddy | 3eedc00 | 2013-11-12 20:45:15 -0800 | [diff] [blame] | 295 | } |
| 296 | |
| 297 | void reverb_set_all_properties(reverb_context_t *context, |
| 298 | reverb_settings_t *reverb_settings) |
| 299 | { |
Dhananjay Kumar | 574f392 | 2014-03-25 17:41:44 +0530 | [diff] [blame] | 300 | ALOGV("%s: ctxt %p", __func__, context); |
Subhash Chandra Bose Naripeddy | 3eedc00 | 2013-11-12 20:45:15 -0800 | [diff] [blame] | 301 | context->reverb_settings.roomLevel = reverb_settings->roomLevel; |
| 302 | context->reverb_settings.roomHFLevel = reverb_settings->roomHFLevel; |
| 303 | context->reverb_settings.decayTime = reverb_settings->decayTime; |
| 304 | context->reverb_settings.decayHFRatio = reverb_settings->decayHFRatio; |
| 305 | context->reverb_settings.reverbLevel = reverb_settings->reverbLevel; |
| 306 | context->reverb_settings.diffusion = reverb_settings->diffusion; |
| 307 | context->reverb_settings.density = reverb_settings->density; |
| 308 | if (context->ctl) |
Subhash Chandra Bose Naripeddy | e40a7cd | 2014-06-03 19:42:41 -0700 | [diff] [blame] | 309 | offload_reverb_send_params(context->ctl, &context->offload_reverb, |
Subhash Chandra Bose Naripeddy | 3eedc00 | 2013-11-12 20:45:15 -0800 | [diff] [blame] | 310 | OFFLOAD_SEND_REVERB_ENABLE_FLAG | |
| 311 | OFFLOAD_SEND_REVERB_ROOM_LEVEL | |
| 312 | OFFLOAD_SEND_REVERB_ROOM_HF_LEVEL | |
| 313 | OFFLOAD_SEND_REVERB_DECAY_TIME | |
| 314 | OFFLOAD_SEND_REVERB_DECAY_HF_RATIO | |
| 315 | OFFLOAD_SEND_REVERB_LEVEL | |
| 316 | OFFLOAD_SEND_REVERB_DIFFUSION | |
| 317 | OFFLOAD_SEND_REVERB_DENSITY); |
Subhash Chandra Bose Naripeddy | e40a7cd | 2014-06-03 19:42:41 -0700 | [diff] [blame] | 318 | if (context->hw_acc_fd > 0) |
| 319 | hw_acc_reverb_send_params(context->hw_acc_fd, &context->offload_reverb, |
| 320 | OFFLOAD_SEND_REVERB_ENABLE_FLAG | |
| 321 | OFFLOAD_SEND_REVERB_ROOM_LEVEL | |
| 322 | OFFLOAD_SEND_REVERB_ROOM_HF_LEVEL | |
| 323 | OFFLOAD_SEND_REVERB_DECAY_TIME | |
| 324 | OFFLOAD_SEND_REVERB_DECAY_HF_RATIO | |
| 325 | OFFLOAD_SEND_REVERB_LEVEL | |
| 326 | OFFLOAD_SEND_REVERB_DIFFUSION | |
| 327 | OFFLOAD_SEND_REVERB_DENSITY); |
Subhash Chandra Bose Naripeddy | 3eedc00 | 2013-11-12 20:45:15 -0800 | [diff] [blame] | 328 | } |
| 329 | |
| 330 | void reverb_load_preset(reverb_context_t *context) |
| 331 | { |
| 332 | context->cur_preset = context->next_preset; |
| 333 | |
| 334 | if (context->cur_preset != REVERB_PRESET_NONE) { |
| 335 | const reverb_settings_t *preset = &reverb_presets[context->cur_preset]; |
| 336 | reverb_set_room_level(context, preset->roomLevel); |
| 337 | reverb_set_room_hf_level(context, preset->roomHFLevel); |
| 338 | reverb_set_decay_time(context, preset->decayTime); |
| 339 | reverb_set_decay_hf_ratio(context, preset->decayHFRatio); |
| 340 | reverb_set_reverb_level(context, preset->reverbLevel); |
| 341 | reverb_set_diffusion(context, preset->diffusion); |
| 342 | reverb_set_density(context, preset->density); |
| 343 | } |
| 344 | } |
| 345 | |
| 346 | int reverb_get_parameter(effect_context_t *context, effect_param_t *p, |
| 347 | uint32_t *size) |
| 348 | { |
| 349 | reverb_context_t *reverb_ctxt = (reverb_context_t *)context; |
| 350 | int voffset = ((p->psize - 1) / sizeof(int32_t) + 1) * sizeof(int32_t); |
| 351 | int32_t *param_tmp = (int32_t *)p->data; |
| 352 | int32_t param = *param_tmp++; |
| 353 | void *value = p->data + voffset; |
| 354 | reverb_settings_t *reverb_settings; |
| 355 | int i; |
| 356 | |
Dhananjay Kumar | 574f392 | 2014-03-25 17:41:44 +0530 | [diff] [blame] | 357 | ALOGV("%s: ctxt %p, param %d", __func__, reverb_ctxt, param); |
Subhash Chandra Bose Naripeddy | 3eedc00 | 2013-11-12 20:45:15 -0800 | [diff] [blame] | 358 | |
| 359 | p->status = 0; |
| 360 | |
| 361 | if (reverb_ctxt->preset) { |
| 362 | if (param != REVERB_PARAM_PRESET || p->vsize < sizeof(uint16_t)) |
| 363 | return -EINVAL; |
| 364 | *(uint16_t *)value = reverb_ctxt->next_preset; |
| 365 | ALOGV("get REVERB_PARAM_PRESET, preset %d", reverb_ctxt->next_preset); |
wjiang | c37c260 | 2014-03-24 23:43:09 +0800 | [diff] [blame] | 366 | return 0; |
Subhash Chandra Bose Naripeddy | 3eedc00 | 2013-11-12 20:45:15 -0800 | [diff] [blame] | 367 | } |
| 368 | switch (param) { |
| 369 | case REVERB_PARAM_ROOM_LEVEL: |
| 370 | if (p->vsize < sizeof(uint16_t)) |
| 371 | p->status = -EINVAL; |
| 372 | p->vsize = sizeof(uint16_t); |
| 373 | break; |
| 374 | case REVERB_PARAM_ROOM_HF_LEVEL: |
| 375 | if (p->vsize < sizeof(uint16_t)) |
| 376 | p->status = -EINVAL; |
| 377 | p->vsize = sizeof(uint16_t); |
| 378 | break; |
| 379 | case REVERB_PARAM_DECAY_TIME: |
| 380 | if (p->vsize < sizeof(uint32_t)) |
| 381 | p->status = -EINVAL; |
| 382 | p->vsize = sizeof(uint32_t); |
| 383 | break; |
| 384 | case REVERB_PARAM_DECAY_HF_RATIO: |
| 385 | if (p->vsize < sizeof(uint16_t)) |
| 386 | p->status = -EINVAL; |
| 387 | p->vsize = sizeof(uint16_t); |
| 388 | break; |
| 389 | case REVERB_PARAM_REFLECTIONS_LEVEL: |
| 390 | if (p->vsize < sizeof(uint16_t)) |
| 391 | p->status = -EINVAL; |
| 392 | p->vsize = sizeof(uint16_t); |
| 393 | break; |
| 394 | case REVERB_PARAM_REFLECTIONS_DELAY: |
| 395 | if (p->vsize < sizeof(uint32_t)) |
| 396 | p->status = -EINVAL; |
| 397 | p->vsize = sizeof(uint32_t); |
| 398 | break; |
| 399 | case REVERB_PARAM_REVERB_LEVEL: |
| 400 | if (p->vsize < sizeof(uint16_t)) |
| 401 | p->status = -EINVAL; |
| 402 | p->vsize = sizeof(uint16_t); |
| 403 | break; |
| 404 | case REVERB_PARAM_REVERB_DELAY: |
| 405 | if (p->vsize < sizeof(uint32_t)) |
| 406 | p->status = -EINVAL; |
| 407 | p->vsize = sizeof(uint32_t); |
| 408 | break; |
| 409 | case REVERB_PARAM_DIFFUSION: |
| 410 | if (p->vsize < sizeof(uint16_t)) |
| 411 | p->status = -EINVAL; |
| 412 | p->vsize = sizeof(uint16_t); |
| 413 | break; |
| 414 | case REVERB_PARAM_DENSITY: |
| 415 | if (p->vsize < sizeof(uint16_t)) |
| 416 | p->status = -EINVAL; |
| 417 | p->vsize = sizeof(uint16_t); |
| 418 | break; |
| 419 | case REVERB_PARAM_PROPERTIES: |
| 420 | if (p->vsize < sizeof(reverb_settings_t)) |
| 421 | p->status = -EINVAL; |
| 422 | p->vsize = sizeof(reverb_settings_t); |
| 423 | break; |
| 424 | default: |
| 425 | p->status = -EINVAL; |
| 426 | } |
| 427 | |
| 428 | *size = sizeof(effect_param_t) + voffset + p->vsize; |
| 429 | |
| 430 | if (p->status != 0) |
| 431 | return 0; |
| 432 | |
| 433 | switch (param) { |
| 434 | case REVERB_PARAM_PROPERTIES: |
Subhash Chandra Bose Naripeddy | 3eedc00 | 2013-11-12 20:45:15 -0800 | [diff] [blame] | 435 | reverb_settings = (reverb_settings_t *)value; |
| 436 | reverb_settings->roomLevel = reverb_get_room_level(reverb_ctxt); |
| 437 | reverb_settings->roomHFLevel = reverb_get_room_hf_level(reverb_ctxt); |
| 438 | reverb_settings->decayTime = reverb_get_decay_time(reverb_ctxt); |
| 439 | reverb_settings->decayHFRatio = reverb_get_decay_hf_ratio(reverb_ctxt); |
| 440 | reverb_settings->reflectionsLevel = 0; |
| 441 | reverb_settings->reflectionsDelay = 0; |
| 442 | reverb_settings->reverbDelay = 0; |
| 443 | reverb_settings->reverbLevel = reverb_get_reverb_level(reverb_ctxt); |
| 444 | reverb_settings->diffusion = reverb_get_diffusion(reverb_ctxt); |
| 445 | reverb_settings->density = reverb_get_density(reverb_ctxt); |
| 446 | break; |
| 447 | case REVERB_PARAM_ROOM_LEVEL: |
Subhash Chandra Bose Naripeddy | 3eedc00 | 2013-11-12 20:45:15 -0800 | [diff] [blame] | 448 | *(int16_t *)value = reverb_get_room_level(reverb_ctxt); |
| 449 | break; |
| 450 | case REVERB_PARAM_ROOM_HF_LEVEL: |
Subhash Chandra Bose Naripeddy | 3eedc00 | 2013-11-12 20:45:15 -0800 | [diff] [blame] | 451 | *(int16_t *)value = reverb_get_room_hf_level(reverb_ctxt); |
| 452 | break; |
| 453 | case REVERB_PARAM_DECAY_TIME: |
Subhash Chandra Bose Naripeddy | 3eedc00 | 2013-11-12 20:45:15 -0800 | [diff] [blame] | 454 | *(uint32_t *)value = reverb_get_decay_time(reverb_ctxt); |
| 455 | break; |
| 456 | case REVERB_PARAM_DECAY_HF_RATIO: |
Subhash Chandra Bose Naripeddy | 3eedc00 | 2013-11-12 20:45:15 -0800 | [diff] [blame] | 457 | *(int16_t *)value = reverb_get_decay_hf_ratio(reverb_ctxt); |
| 458 | break; |
| 459 | case REVERB_PARAM_REVERB_LEVEL: |
Subhash Chandra Bose Naripeddy | 3eedc00 | 2013-11-12 20:45:15 -0800 | [diff] [blame] | 460 | *(int16_t *)value = reverb_get_reverb_level(reverb_ctxt); |
| 461 | break; |
| 462 | case REVERB_PARAM_DIFFUSION: |
Subhash Chandra Bose Naripeddy | 3eedc00 | 2013-11-12 20:45:15 -0800 | [diff] [blame] | 463 | *(int16_t *)value = reverb_get_diffusion(reverb_ctxt); |
| 464 | break; |
| 465 | case REVERB_PARAM_DENSITY: |
Subhash Chandra Bose Naripeddy | 3eedc00 | 2013-11-12 20:45:15 -0800 | [diff] [blame] | 466 | *(int16_t *)value = reverb_get_density(reverb_ctxt); |
| 467 | break; |
| 468 | case REVERB_PARAM_REFLECTIONS_LEVEL: |
Subhash Chandra Bose Naripeddy | 3eedc00 | 2013-11-12 20:45:15 -0800 | [diff] [blame] | 469 | *(uint16_t *)value = 0; |
| 470 | break; |
| 471 | case REVERB_PARAM_REFLECTIONS_DELAY: |
Subhash Chandra Bose Naripeddy | 3eedc00 | 2013-11-12 20:45:15 -0800 | [diff] [blame] | 472 | *(uint32_t *)value = 0; |
| 473 | break; |
| 474 | case REVERB_PARAM_REVERB_DELAY: |
Subhash Chandra Bose Naripeddy | 3eedc00 | 2013-11-12 20:45:15 -0800 | [diff] [blame] | 475 | *(uint32_t *)value = 0; |
| 476 | break; |
| 477 | default: |
| 478 | p->status = -EINVAL; |
| 479 | break; |
| 480 | } |
| 481 | |
| 482 | return 0; |
| 483 | } |
| 484 | |
| 485 | int reverb_set_parameter(effect_context_t *context, effect_param_t *p, |
Subhash Chandra Bose Naripeddy | e40a7cd | 2014-06-03 19:42:41 -0700 | [diff] [blame] | 486 | uint32_t size __unused) |
Subhash Chandra Bose Naripeddy | 3eedc00 | 2013-11-12 20:45:15 -0800 | [diff] [blame] | 487 | { |
| 488 | reverb_context_t *reverb_ctxt = (reverb_context_t *)context; |
| 489 | int voffset = ((p->psize - 1) / sizeof(int32_t) + 1) * sizeof(int32_t); |
| 490 | void *value = p->data + voffset; |
| 491 | int32_t *param_tmp = (int32_t *)p->data; |
| 492 | int32_t param = *param_tmp++; |
| 493 | reverb_settings_t *reverb_settings; |
| 494 | int16_t level; |
| 495 | int16_t ratio; |
| 496 | uint32_t time; |
| 497 | |
Dhananjay Kumar | 574f392 | 2014-03-25 17:41:44 +0530 | [diff] [blame] | 498 | ALOGV("%s: ctxt %p, param %d", __func__, reverb_ctxt, param); |
Subhash Chandra Bose Naripeddy | 3eedc00 | 2013-11-12 20:45:15 -0800 | [diff] [blame] | 499 | |
| 500 | p->status = 0; |
| 501 | |
| 502 | if (reverb_ctxt->preset) { |
| 503 | if (param != REVERB_PARAM_PRESET) |
| 504 | return -EINVAL; |
| 505 | uint16_t preset = *(uint16_t *)value; |
| 506 | ALOGV("set REVERB_PARAM_PRESET, preset %d", preset); |
| 507 | if (preset > REVERB_PRESET_LAST) { |
| 508 | return -EINVAL; |
| 509 | } |
| 510 | reverb_set_preset(reverb_ctxt, preset); |
wjiang | c37c260 | 2014-03-24 23:43:09 +0800 | [diff] [blame] | 511 | return 0; |
Subhash Chandra Bose Naripeddy | 3eedc00 | 2013-11-12 20:45:15 -0800 | [diff] [blame] | 512 | } |
| 513 | switch (param) { |
| 514 | case REVERB_PARAM_PROPERTIES: |
Subhash Chandra Bose Naripeddy | 3eedc00 | 2013-11-12 20:45:15 -0800 | [diff] [blame] | 515 | reverb_settings = (reverb_settings_t *)value; |
| 516 | break; |
| 517 | case REVERB_PARAM_ROOM_LEVEL: |
Subhash Chandra Bose Naripeddy | 3eedc00 | 2013-11-12 20:45:15 -0800 | [diff] [blame] | 518 | level = *(int16_t *)value; |
| 519 | reverb_set_room_level(reverb_ctxt, level); |
| 520 | break; |
| 521 | case REVERB_PARAM_ROOM_HF_LEVEL: |
Subhash Chandra Bose Naripeddy | 3eedc00 | 2013-11-12 20:45:15 -0800 | [diff] [blame] | 522 | level = *(int16_t *)value; |
| 523 | reverb_set_room_hf_level(reverb_ctxt, level); |
| 524 | break; |
| 525 | case REVERB_PARAM_DECAY_TIME: |
Subhash Chandra Bose Naripeddy | 3eedc00 | 2013-11-12 20:45:15 -0800 | [diff] [blame] | 526 | time = *(uint32_t *)value; |
| 527 | reverb_set_decay_time(reverb_ctxt, time); |
| 528 | break; |
| 529 | case REVERB_PARAM_DECAY_HF_RATIO: |
Subhash Chandra Bose Naripeddy | 3eedc00 | 2013-11-12 20:45:15 -0800 | [diff] [blame] | 530 | ratio = *(int16_t *)value; |
| 531 | reverb_set_decay_hf_ratio(reverb_ctxt, ratio); |
| 532 | break; |
| 533 | case REVERB_PARAM_REVERB_LEVEL: |
Subhash Chandra Bose Naripeddy | 3eedc00 | 2013-11-12 20:45:15 -0800 | [diff] [blame] | 534 | level = *(int16_t *)value; |
| 535 | reverb_set_reverb_level(reverb_ctxt, level); |
| 536 | break; |
| 537 | case REVERB_PARAM_DIFFUSION: |
Subhash Chandra Bose Naripeddy | 3eedc00 | 2013-11-12 20:45:15 -0800 | [diff] [blame] | 538 | ratio = *(int16_t *)value; |
| 539 | reverb_set_diffusion(reverb_ctxt, ratio); |
| 540 | break; |
| 541 | case REVERB_PARAM_DENSITY: |
Subhash Chandra Bose Naripeddy | 3eedc00 | 2013-11-12 20:45:15 -0800 | [diff] [blame] | 542 | ratio = *(int16_t *)value; |
| 543 | reverb_set_density(reverb_ctxt, ratio); |
| 544 | break; |
| 545 | case REVERB_PARAM_REFLECTIONS_LEVEL: |
| 546 | case REVERB_PARAM_REFLECTIONS_DELAY: |
| 547 | case REVERB_PARAM_REVERB_DELAY: |
| 548 | break; |
| 549 | default: |
| 550 | p->status = -EINVAL; |
| 551 | break; |
| 552 | } |
| 553 | |
| 554 | return 0; |
| 555 | } |
| 556 | |
| 557 | int reverb_set_device(effect_context_t *context, uint32_t device) |
| 558 | { |
| 559 | reverb_context_t *reverb_ctxt = (reverb_context_t *)context; |
| 560 | |
Dhananjay Kumar | 574f392 | 2014-03-25 17:41:44 +0530 | [diff] [blame] | 561 | ALOGV("%s: ctxt %p, device: 0x%x", __func__, reverb_ctxt, device); |
Subhash Chandra Bose Naripeddy | 3eedc00 | 2013-11-12 20:45:15 -0800 | [diff] [blame] | 562 | reverb_ctxt->device = device; |
| 563 | offload_reverb_set_device(&(reverb_ctxt->offload_reverb), device); |
| 564 | return 0; |
| 565 | } |
| 566 | |
| 567 | int reverb_reset(effect_context_t *context) |
| 568 | { |
| 569 | reverb_context_t *reverb_ctxt = (reverb_context_t *)context; |
| 570 | |
| 571 | return 0; |
| 572 | } |
| 573 | |
| 574 | int reverb_init(effect_context_t *context) |
| 575 | { |
| 576 | reverb_context_t *reverb_ctxt = (reverb_context_t *)context; |
| 577 | |
Dhananjay Kumar | 574f392 | 2014-03-25 17:41:44 +0530 | [diff] [blame] | 578 | ALOGV("%s: ctxt %p", __func__, reverb_ctxt); |
Subhash Chandra Bose Naripeddy | 3eedc00 | 2013-11-12 20:45:15 -0800 | [diff] [blame] | 579 | context->config.inputCfg.accessMode = EFFECT_BUFFER_ACCESS_READ; |
| 580 | /* |
| 581 | FIXME: channel mode is mono for auxiliary. is it needed for offload ? |
| 582 | If so, this set config needs to be updated accordingly |
| 583 | */ |
| 584 | context->config.inputCfg.channels = AUDIO_CHANNEL_OUT_STEREO; |
| 585 | context->config.inputCfg.format = AUDIO_FORMAT_PCM_16_BIT; |
| 586 | context->config.inputCfg.samplingRate = 44100; |
| 587 | context->config.inputCfg.bufferProvider.getBuffer = NULL; |
| 588 | context->config.inputCfg.bufferProvider.releaseBuffer = NULL; |
| 589 | context->config.inputCfg.bufferProvider.cookie = NULL; |
| 590 | context->config.inputCfg.mask = EFFECT_CONFIG_ALL; |
| 591 | context->config.outputCfg.accessMode = EFFECT_BUFFER_ACCESS_ACCUMULATE; |
| 592 | context->config.outputCfg.channels = AUDIO_CHANNEL_OUT_STEREO; |
| 593 | context->config.outputCfg.format = AUDIO_FORMAT_PCM_16_BIT; |
| 594 | context->config.outputCfg.samplingRate = 44100; |
| 595 | context->config.outputCfg.bufferProvider.getBuffer = NULL; |
| 596 | context->config.outputCfg.bufferProvider.releaseBuffer = NULL; |
| 597 | context->config.outputCfg.bufferProvider.cookie = NULL; |
| 598 | context->config.outputCfg.mask = EFFECT_CONFIG_ALL; |
| 599 | |
| 600 | set_config(context, &context->config); |
| 601 | |
Subhash Chandra Bose Naripeddy | e40a7cd | 2014-06-03 19:42:41 -0700 | [diff] [blame] | 602 | reverb_ctxt->hw_acc_fd = -1; |
Subhash Chandra Bose Naripeddy | 3eedc00 | 2013-11-12 20:45:15 -0800 | [diff] [blame] | 603 | memset(&(reverb_ctxt->reverb_settings), 0, sizeof(reverb_settings_t)); |
| 604 | memset(&(reverb_ctxt->offload_reverb), 0, sizeof(struct reverb_params)); |
| 605 | |
| 606 | if (reverb_ctxt->preset && |
| 607 | reverb_ctxt->next_preset != reverb_ctxt->cur_preset) |
| 608 | reverb_load_preset(reverb_ctxt); |
| 609 | |
| 610 | return 0; |
| 611 | } |
| 612 | |
| 613 | int reverb_enable(effect_context_t *context) |
| 614 | { |
| 615 | reverb_context_t *reverb_ctxt = (reverb_context_t *)context; |
| 616 | |
Dhananjay Kumar | 574f392 | 2014-03-25 17:41:44 +0530 | [diff] [blame] | 617 | ALOGV("%s: ctxt %p", __func__, reverb_ctxt); |
Subhash Chandra Bose Naripeddy | 3eedc00 | 2013-11-12 20:45:15 -0800 | [diff] [blame] | 618 | |
| 619 | if (!offload_reverb_get_enable_flag(&(reverb_ctxt->offload_reverb))) |
| 620 | offload_reverb_set_enable_flag(&(reverb_ctxt->offload_reverb), true); |
| 621 | return 0; |
| 622 | } |
| 623 | |
| 624 | int reverb_disable(effect_context_t *context) |
| 625 | { |
| 626 | reverb_context_t *reverb_ctxt = (reverb_context_t *)context; |
| 627 | |
Dhananjay Kumar | 574f392 | 2014-03-25 17:41:44 +0530 | [diff] [blame] | 628 | ALOGV("%s: ctxt %p", __func__, reverb_ctxt); |
Subhash Chandra Bose Naripeddy | 3eedc00 | 2013-11-12 20:45:15 -0800 | [diff] [blame] | 629 | if (offload_reverb_get_enable_flag(&(reverb_ctxt->offload_reverb))) { |
| 630 | offload_reverb_set_enable_flag(&(reverb_ctxt->offload_reverb), false); |
| 631 | if (reverb_ctxt->ctl) |
| 632 | offload_reverb_send_params(reverb_ctxt->ctl, |
Subhash Chandra Bose Naripeddy | e40a7cd | 2014-06-03 19:42:41 -0700 | [diff] [blame] | 633 | &reverb_ctxt->offload_reverb, |
Subhash Chandra Bose Naripeddy | 3eedc00 | 2013-11-12 20:45:15 -0800 | [diff] [blame] | 634 | OFFLOAD_SEND_REVERB_ENABLE_FLAG); |
Subhash Chandra Bose Naripeddy | e40a7cd | 2014-06-03 19:42:41 -0700 | [diff] [blame] | 635 | if (reverb_ctxt->hw_acc_fd > 0) |
| 636 | hw_acc_reverb_send_params(reverb_ctxt->hw_acc_fd, |
| 637 | &reverb_ctxt->offload_reverb, |
| 638 | OFFLOAD_SEND_REVERB_ENABLE_FLAG); |
Subhash Chandra Bose Naripeddy | 3eedc00 | 2013-11-12 20:45:15 -0800 | [diff] [blame] | 639 | } |
| 640 | return 0; |
| 641 | } |
| 642 | |
| 643 | int reverb_start(effect_context_t *context, output_context_t *output) |
| 644 | { |
| 645 | reverb_context_t *reverb_ctxt = (reverb_context_t *)context; |
| 646 | |
Dhananjay Kumar | 574f392 | 2014-03-25 17:41:44 +0530 | [diff] [blame] | 647 | ALOGV("%s: ctxt %p, ctl %p", __func__, reverb_ctxt, output->ctl); |
Subhash Chandra Bose Naripeddy | 3eedc00 | 2013-11-12 20:45:15 -0800 | [diff] [blame] | 648 | reverb_ctxt->ctl = output->ctl; |
wjiang | c37c260 | 2014-03-24 23:43:09 +0800 | [diff] [blame] | 649 | if (offload_reverb_get_enable_flag(&(reverb_ctxt->offload_reverb))) { |
| 650 | if (reverb_ctxt->ctl && reverb_ctxt->preset) { |
Subhash Chandra Bose Naripeddy | e40a7cd | 2014-06-03 19:42:41 -0700 | [diff] [blame] | 651 | offload_reverb_send_params(reverb_ctxt->ctl, &reverb_ctxt->offload_reverb, |
wjiang | c37c260 | 2014-03-24 23:43:09 +0800 | [diff] [blame] | 652 | OFFLOAD_SEND_REVERB_ENABLE_FLAG | |
| 653 | OFFLOAD_SEND_REVERB_PRESET); |
| 654 | } |
Subhash Chandra Bose Naripeddy | e40a7cd | 2014-06-03 19:42:41 -0700 | [diff] [blame] | 655 | if ((reverb_ctxt->hw_acc_fd > 0) && reverb_ctxt->preset) { |
| 656 | hw_acc_reverb_send_params(reverb_ctxt->hw_acc_fd, |
| 657 | &reverb_ctxt->offload_reverb, |
| 658 | OFFLOAD_SEND_REVERB_ENABLE_FLAG | |
| 659 | OFFLOAD_SEND_REVERB_PRESET); |
| 660 | } |
wjiang | c37c260 | 2014-03-24 23:43:09 +0800 | [diff] [blame] | 661 | } |
| 662 | |
Subhash Chandra Bose Naripeddy | 3eedc00 | 2013-11-12 20:45:15 -0800 | [diff] [blame] | 663 | return 0; |
| 664 | } |
| 665 | |
Subhash Chandra Bose Naripeddy | e40a7cd | 2014-06-03 19:42:41 -0700 | [diff] [blame] | 666 | int reverb_stop(effect_context_t *context, output_context_t *output __unused) |
Subhash Chandra Bose Naripeddy | 3eedc00 | 2013-11-12 20:45:15 -0800 | [diff] [blame] | 667 | { |
| 668 | reverb_context_t *reverb_ctxt = (reverb_context_t *)context; |
| 669 | |
Dhananjay Kumar | 574f392 | 2014-03-25 17:41:44 +0530 | [diff] [blame] | 670 | ALOGV("%s: ctxt %p", __func__, reverb_ctxt); |
Subhash Chandra Bose Naripeddy | e40a7cd | 2014-06-03 19:42:41 -0700 | [diff] [blame] | 671 | if (offload_reverb_get_enable_flag(&(reverb_ctxt->offload_reverb)) && |
| 672 | reverb_ctxt->ctl) { |
| 673 | struct reverb_params reverb; |
| 674 | reverb.enable_flag = false; |
| 675 | offload_reverb_send_params(reverb_ctxt->ctl, &reverb, |
| 676 | OFFLOAD_SEND_REVERB_ENABLE_FLAG); |
| 677 | } |
Subhash Chandra Bose Naripeddy | 3eedc00 | 2013-11-12 20:45:15 -0800 | [diff] [blame] | 678 | reverb_ctxt->ctl = NULL; |
| 679 | return 0; |
| 680 | } |
| 681 | |
Subhash Chandra Bose Naripeddy | e40a7cd | 2014-06-03 19:42:41 -0700 | [diff] [blame] | 682 | int reverb_set_mode(effect_context_t *context, int32_t hw_acc_fd) |
| 683 | { |
| 684 | reverb_context_t *reverb_ctxt = (reverb_context_t *)context; |
| 685 | |
| 686 | ALOGV("%s: ctxt %p", __func__, reverb_ctxt); |
| 687 | reverb_ctxt->hw_acc_fd = hw_acc_fd; |
| 688 | if ((reverb_ctxt->hw_acc_fd > 0) && |
| 689 | (offload_reverb_get_enable_flag(&(reverb_ctxt->offload_reverb)))) |
| 690 | hw_acc_reverb_send_params(reverb_ctxt->hw_acc_fd, |
| 691 | &reverb_ctxt->offload_reverb, |
| 692 | OFFLOAD_SEND_BASSBOOST_ENABLE_FLAG | |
| 693 | OFFLOAD_SEND_BASSBOOST_STRENGTH); |
| 694 | return 0; |
| 695 | } |