Subhash Chandra Bose Naripeddy | 3eedc00 | 2013-11-12 20:45:15 -0800 | [diff] [blame] | 1 | /* |
Dhananjay Kumar | 5f15ff9 | 2014-05-19 16:45:08 +0800 | [diff] [blame] | 2 | * Copyright (c) 2013-2015, The Linux Foundation. All rights reserved. |
Subhash Chandra Bose Naripeddy | 3eedc00 | 2013-11-12 20:45:15 -0800 | [diff] [blame] | 3 | |
| 4 | * Redistribution and use in source and binary forms, with or without |
| 5 | * modification, are permitted provided that the following conditions are |
| 6 | * met: |
| 7 | * * Redistributions of source code must retain the above copyright |
| 8 | * notice, this list of conditions and the following disclaimer. |
| 9 | * * Redistributions in binary form must reproduce the above |
| 10 | * copyright notice, this list of conditions and the following |
| 11 | * disclaimer in the documentation and/or other materials provided |
| 12 | * with the distribution. |
| 13 | * * Neither the name of The Linux Foundation nor the names of its |
| 14 | * contributors may be used to endorse or promote products derived |
| 15 | * from this software without specific prior written permission. |
| 16 | * |
| 17 | * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED |
| 18 | * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF |
| 19 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT |
| 20 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS |
| 21 | * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR |
| 22 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF |
| 23 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR |
| 24 | * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, |
| 25 | * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE |
| 26 | * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN |
| 27 | * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
Jitendra Naruka | 1b6513f | 2014-11-22 19:34:13 -0800 | [diff] [blame] | 28 | * |
| 29 | * This file was modified by DTS, Inc. The portions of the |
| 30 | * code modified by DTS, Inc are copyrighted and |
| 31 | * licensed separately, as follows: |
| 32 | * |
| 33 | * (C) 2014 DTS, Inc. |
| 34 | * |
| 35 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 36 | * you may not use this file except in compliance with the License. |
| 37 | * You may obtain a copy of the License at |
| 38 | * |
| 39 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 40 | * |
| 41 | * Unless required by applicable law or agreed to in writing, software |
| 42 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 43 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 44 | * See the License for the specific language governing permissions and |
| 45 | * limitations under the License. |
Subhash Chandra Bose Naripeddy | 3eedc00 | 2013-11-12 20:45:15 -0800 | [diff] [blame] | 46 | */ |
| 47 | |
| 48 | #define LOG_TAG "offload_effect_api" |
Subhash Chandra Bose Naripeddy | e40a7cd | 2014-06-03 19:42:41 -0700 | [diff] [blame] | 49 | //#define LOG_NDEBUG 0 |
Dhananjay Kumar | 574f392 | 2014-03-25 17:41:44 +0530 | [diff] [blame] | 50 | //#define VERY_VERY_VERBOSE_LOGGING |
| 51 | #ifdef VERY_VERY_VERBOSE_LOGGING |
| 52 | #define ALOGVV ALOGV |
| 53 | #else |
| 54 | #define ALOGVV(a...) do { } while(0) |
| 55 | #endif |
Subhash Chandra Bose Naripeddy | 3eedc00 | 2013-11-12 20:45:15 -0800 | [diff] [blame] | 56 | |
| 57 | #include <stdbool.h> |
| 58 | #include <cutils/log.h> |
| 59 | #include <tinyalsa/asoundlib.h> |
Subhash Chandra Bose Naripeddy | 090a2aa | 2014-01-30 14:03:12 -0800 | [diff] [blame] | 60 | #include <sound/audio_effects.h> |
Jitendra Naruka | 1b6513f | 2014-11-22 19:34:13 -0800 | [diff] [blame] | 61 | #include <sound/devdep_params.h> |
Subhash Chandra Bose Naripeddy | e40a7cd | 2014-06-03 19:42:41 -0700 | [diff] [blame] | 62 | #include <linux/msm_audio.h> |
| 63 | |
Subhash Chandra Bose Naripeddy | 3eedc00 | 2013-11-12 20:45:15 -0800 | [diff] [blame] | 64 | #include "effect_api.h" |
| 65 | |
Jitendra Naruka | 1b6513f | 2014-11-22 19:34:13 -0800 | [diff] [blame] | 66 | #ifdef DTS_EAGLE |
| 67 | #include "effect_util.h" |
| 68 | #endif |
| 69 | |
Subhash Chandra Bose Naripeddy | 3eedc00 | 2013-11-12 20:45:15 -0800 | [diff] [blame] | 70 | #define ARRAY_SIZE(array) (sizeof array / sizeof array[0]) |
Subhash Chandra Bose Naripeddy | e40a7cd | 2014-06-03 19:42:41 -0700 | [diff] [blame] | 71 | typedef enum eff_mode { |
| 72 | OFFLOAD, |
| 73 | HW_ACCELERATOR |
| 74 | } eff_mode_t; |
Subhash Chandra Bose Naripeddy | 3eedc00 | 2013-11-12 20:45:15 -0800 | [diff] [blame] | 75 | |
| 76 | #define OFFLOAD_PRESET_START_OFFSET_FOR_OPENSL 19 |
| 77 | const int map_eq_opensl_preset_2_offload_preset[] = { |
| 78 | OFFLOAD_PRESET_START_OFFSET_FOR_OPENSL, /* Normal Preset */ |
| 79 | OFFLOAD_PRESET_START_OFFSET_FOR_OPENSL+1, /* Classical Preset */ |
| 80 | OFFLOAD_PRESET_START_OFFSET_FOR_OPENSL+2, /* Dance Preset */ |
| 81 | OFFLOAD_PRESET_START_OFFSET_FOR_OPENSL+3, /* Flat Preset */ |
| 82 | OFFLOAD_PRESET_START_OFFSET_FOR_OPENSL+4, /* Folk Preset */ |
| 83 | OFFLOAD_PRESET_START_OFFSET_FOR_OPENSL+5, /* Heavy Metal Preset */ |
| 84 | OFFLOAD_PRESET_START_OFFSET_FOR_OPENSL+6, /* Hip Hop Preset */ |
| 85 | OFFLOAD_PRESET_START_OFFSET_FOR_OPENSL+7, /* Jazz Preset */ |
| 86 | OFFLOAD_PRESET_START_OFFSET_FOR_OPENSL+8, /* Pop Preset */ |
| 87 | OFFLOAD_PRESET_START_OFFSET_FOR_OPENSL+9, /* Rock Preset */ |
| 88 | OFFLOAD_PRESET_START_OFFSET_FOR_OPENSL+10 /* FX Booster */ |
| 89 | }; |
| 90 | |
| 91 | const int map_reverb_opensl_preset_2_offload_preset |
| 92 | [NUM_OSL_REVERB_PRESETS_SUPPORTED][2] = { |
| 93 | {1, 15}, |
| 94 | {2, 16}, |
| 95 | {3, 17}, |
| 96 | {4, 18}, |
| 97 | {5, 3}, |
| 98 | {6, 20} |
| 99 | }; |
| 100 | |
| 101 | int offload_update_mixer_and_effects_ctl(int card, int device_id, |
Subhash Chandra Bose Naripeddy | e40a7cd | 2014-06-03 19:42:41 -0700 | [diff] [blame] | 102 | struct mixer **mixer, |
| 103 | struct mixer_ctl **ctl) |
Subhash Chandra Bose Naripeddy | 3eedc00 | 2013-11-12 20:45:15 -0800 | [diff] [blame] | 104 | { |
| 105 | char mixer_string[128]; |
| 106 | |
| 107 | snprintf(mixer_string, sizeof(mixer_string), |
| 108 | "%s %d", "Audio Effects Config", device_id); |
| 109 | ALOGV("%s: mixer_string: %s", __func__, mixer_string); |
Subhash Chandra Bose Naripeddy | e40a7cd | 2014-06-03 19:42:41 -0700 | [diff] [blame] | 110 | *mixer = mixer_open(card); |
| 111 | if (!(*mixer)) { |
Subhash Chandra Bose Naripeddy | 3eedc00 | 2013-11-12 20:45:15 -0800 | [diff] [blame] | 112 | ALOGE("Failed to open mixer"); |
Apoorv Raghuvanshi | 8880cac | 2015-02-06 15:33:49 -0800 | [diff] [blame^] | 113 | *ctl = NULL; |
Subhash Chandra Bose Naripeddy | 3eedc00 | 2013-11-12 20:45:15 -0800 | [diff] [blame] | 114 | return -EINVAL; |
| 115 | } else { |
Subhash Chandra Bose Naripeddy | e40a7cd | 2014-06-03 19:42:41 -0700 | [diff] [blame] | 116 | *ctl = mixer_get_ctl_by_name(*mixer, mixer_string); |
Apoorv Raghuvanshi | 8880cac | 2015-02-06 15:33:49 -0800 | [diff] [blame^] | 117 | if (!*ctl) { |
Subhash Chandra Bose Naripeddy | 3eedc00 | 2013-11-12 20:45:15 -0800 | [diff] [blame] | 118 | ALOGE("mixer_get_ctl_by_name failed"); |
Subhash Chandra Bose Naripeddy | e40a7cd | 2014-06-03 19:42:41 -0700 | [diff] [blame] | 119 | mixer_close(*mixer); |
| 120 | *mixer = NULL; |
Subhash Chandra Bose Naripeddy | 3eedc00 | 2013-11-12 20:45:15 -0800 | [diff] [blame] | 121 | return -EINVAL; |
| 122 | } |
| 123 | } |
Subhash Chandra Bose Naripeddy | e40a7cd | 2014-06-03 19:42:41 -0700 | [diff] [blame] | 124 | ALOGV("mixer: %p, ctl: %p", *mixer, *ctl); |
Subhash Chandra Bose Naripeddy | 3eedc00 | 2013-11-12 20:45:15 -0800 | [diff] [blame] | 125 | return 0; |
| 126 | } |
| 127 | |
Subhash Chandra Bose Naripeddy | e40a7cd | 2014-06-03 19:42:41 -0700 | [diff] [blame] | 128 | void offload_close_mixer(struct mixer **mixer) |
Subhash Chandra Bose Naripeddy | 3eedc00 | 2013-11-12 20:45:15 -0800 | [diff] [blame] | 129 | { |
Subhash Chandra Bose Naripeddy | e40a7cd | 2014-06-03 19:42:41 -0700 | [diff] [blame] | 130 | mixer_close(*mixer); |
Subhash Chandra Bose Naripeddy | 3eedc00 | 2013-11-12 20:45:15 -0800 | [diff] [blame] | 131 | } |
| 132 | |
| 133 | void offload_bassboost_set_device(struct bass_boost_params *bassboost, |
| 134 | uint32_t device) |
| 135 | { |
Dhananjay Kumar | 574f392 | 2014-03-25 17:41:44 +0530 | [diff] [blame] | 136 | ALOGVV("%s: device 0x%x", __func__, device); |
Subhash Chandra Bose Naripeddy | 3eedc00 | 2013-11-12 20:45:15 -0800 | [diff] [blame] | 137 | bassboost->device = device; |
| 138 | } |
| 139 | |
| 140 | void offload_bassboost_set_enable_flag(struct bass_boost_params *bassboost, |
| 141 | bool enable) |
| 142 | { |
Dhananjay Kumar | 574f392 | 2014-03-25 17:41:44 +0530 | [diff] [blame] | 143 | ALOGVV("%s: enable=%d", __func__, (int)enable); |
Subhash Chandra Bose Naripeddy | 3eedc00 | 2013-11-12 20:45:15 -0800 | [diff] [blame] | 144 | bassboost->enable_flag = enable; |
Jitendra Naruka | 1b6513f | 2014-11-22 19:34:13 -0800 | [diff] [blame] | 145 | |
| 146 | #ifdef DTS_EAGLE |
| 147 | update_effects_node(PCM_DEV_ID, EFFECT_TYPE_BB, EFFECT_ENABLE_PARAM, enable, EFFECT_NO_OP, EFFECT_NO_OP, EFFECT_NO_OP); |
| 148 | #endif |
Subhash Chandra Bose Naripeddy | 3eedc00 | 2013-11-12 20:45:15 -0800 | [diff] [blame] | 149 | } |
| 150 | |
| 151 | int offload_bassboost_get_enable_flag(struct bass_boost_params *bassboost) |
| 152 | { |
Dhananjay Kumar | 574f392 | 2014-03-25 17:41:44 +0530 | [diff] [blame] | 153 | ALOGVV("%s: enable=%d", __func__, (int)bassboost->enable_flag); |
Subhash Chandra Bose Naripeddy | 3eedc00 | 2013-11-12 20:45:15 -0800 | [diff] [blame] | 154 | return bassboost->enable_flag; |
| 155 | } |
| 156 | |
| 157 | void offload_bassboost_set_strength(struct bass_boost_params *bassboost, |
| 158 | int strength) |
| 159 | { |
Dhananjay Kumar | 574f392 | 2014-03-25 17:41:44 +0530 | [diff] [blame] | 160 | ALOGVV("%s: strength %d", __func__, strength); |
Subhash Chandra Bose Naripeddy | 3eedc00 | 2013-11-12 20:45:15 -0800 | [diff] [blame] | 161 | bassboost->strength = strength; |
Jitendra Naruka | 1b6513f | 2014-11-22 19:34:13 -0800 | [diff] [blame] | 162 | |
| 163 | #ifdef DTS_EAGLE |
| 164 | update_effects_node(PCM_DEV_ID, EFFECT_TYPE_BB, EFFECT_SET_PARAM, EFFECT_NO_OP, strength, EFFECT_NO_OP, EFFECT_NO_OP); |
| 165 | #endif |
Subhash Chandra Bose Naripeddy | 3eedc00 | 2013-11-12 20:45:15 -0800 | [diff] [blame] | 166 | } |
| 167 | |
| 168 | void offload_bassboost_set_mode(struct bass_boost_params *bassboost, |
| 169 | int mode) |
| 170 | { |
Dhananjay Kumar | 574f392 | 2014-03-25 17:41:44 +0530 | [diff] [blame] | 171 | ALOGVV("%s: mode %d", __func__, mode); |
Subhash Chandra Bose Naripeddy | 3eedc00 | 2013-11-12 20:45:15 -0800 | [diff] [blame] | 172 | bassboost->mode = mode; |
| 173 | } |
| 174 | |
Subhash Chandra Bose Naripeddy | e40a7cd | 2014-06-03 19:42:41 -0700 | [diff] [blame] | 175 | static int bassboost_send_params(eff_mode_t mode, void *ctl, |
| 176 | struct bass_boost_params *bassboost, |
| 177 | unsigned param_send_flags) |
Subhash Chandra Bose Naripeddy | 3eedc00 | 2013-11-12 20:45:15 -0800 | [diff] [blame] | 178 | { |
| 179 | int param_values[128] = {0}; |
| 180 | int *p_param_values = param_values; |
| 181 | |
Dhananjay Kumar | 574f392 | 2014-03-25 17:41:44 +0530 | [diff] [blame] | 182 | ALOGV("%s: flags 0x%x", __func__, param_send_flags); |
Subhash Chandra Bose Naripeddy | 3eedc00 | 2013-11-12 20:45:15 -0800 | [diff] [blame] | 183 | *p_param_values++ = BASS_BOOST_MODULE; |
Subhash Chandra Bose Naripeddy | e40a7cd | 2014-06-03 19:42:41 -0700 | [diff] [blame] | 184 | *p_param_values++ = bassboost->device; |
Subhash Chandra Bose Naripeddy | 3eedc00 | 2013-11-12 20:45:15 -0800 | [diff] [blame] | 185 | *p_param_values++ = 0; /* num of commands*/ |
| 186 | if (param_send_flags & OFFLOAD_SEND_BASSBOOST_ENABLE_FLAG) { |
| 187 | *p_param_values++ = BASS_BOOST_ENABLE; |
| 188 | *p_param_values++ = CONFIG_SET; |
| 189 | *p_param_values++ = 0; /* start offset if param size if greater than 128 */ |
| 190 | *p_param_values++ = BASS_BOOST_ENABLE_PARAM_LEN; |
Subhash Chandra Bose Naripeddy | e40a7cd | 2014-06-03 19:42:41 -0700 | [diff] [blame] | 191 | *p_param_values++ = bassboost->enable_flag; |
Subhash Chandra Bose Naripeddy | 3eedc00 | 2013-11-12 20:45:15 -0800 | [diff] [blame] | 192 | param_values[2] += 1; |
| 193 | } |
| 194 | if (param_send_flags & OFFLOAD_SEND_BASSBOOST_STRENGTH) { |
| 195 | *p_param_values++ = BASS_BOOST_STRENGTH; |
| 196 | *p_param_values++ = CONFIG_SET; |
| 197 | *p_param_values++ = 0; /* start offset if param size if greater than 128 */ |
| 198 | *p_param_values++ = BASS_BOOST_STRENGTH_PARAM_LEN; |
Subhash Chandra Bose Naripeddy | e40a7cd | 2014-06-03 19:42:41 -0700 | [diff] [blame] | 199 | *p_param_values++ = bassboost->strength; |
Subhash Chandra Bose Naripeddy | 3eedc00 | 2013-11-12 20:45:15 -0800 | [diff] [blame] | 200 | param_values[2] += 1; |
| 201 | } |
| 202 | if (param_send_flags & OFFLOAD_SEND_BASSBOOST_MODE) { |
| 203 | *p_param_values++ = BASS_BOOST_MODE; |
| 204 | *p_param_values++ = CONFIG_SET; |
| 205 | *p_param_values++ = 0; /* start offset if param size if greater than 128 */ |
| 206 | *p_param_values++ = BASS_BOOST_MODE_PARAM_LEN; |
Subhash Chandra Bose Naripeddy | e40a7cd | 2014-06-03 19:42:41 -0700 | [diff] [blame] | 207 | *p_param_values++ = bassboost->mode; |
Subhash Chandra Bose Naripeddy | 3eedc00 | 2013-11-12 20:45:15 -0800 | [diff] [blame] | 208 | param_values[2] += 1; |
| 209 | } |
| 210 | |
Subhash Chandra Bose Naripeddy | e40a7cd | 2014-06-03 19:42:41 -0700 | [diff] [blame] | 211 | if ((mode == OFFLOAD) && param_values[2] && ctl) { |
| 212 | mixer_ctl_set_array((struct mixer_ctl *)ctl, param_values, |
| 213 | ARRAY_SIZE(param_values)); |
| 214 | } else if ((mode == HW_ACCELERATOR) && param_values[2] && |
| 215 | ctl && *(int *)ctl) { |
| 216 | if (ioctl(*(int *)ctl, AUDIO_EFFECTS_SET_PP_PARAMS, param_values) < 0) |
| 217 | ALOGE("%s: sending h/w acc effects params fail[%d]", __func__, errno); |
| 218 | } |
Subhash Chandra Bose Naripeddy | 3eedc00 | 2013-11-12 20:45:15 -0800 | [diff] [blame] | 219 | |
| 220 | return 0; |
| 221 | } |
| 222 | |
Subhash Chandra Bose Naripeddy | e40a7cd | 2014-06-03 19:42:41 -0700 | [diff] [blame] | 223 | int offload_bassboost_send_params(struct mixer_ctl *ctl, |
| 224 | struct bass_boost_params *bassboost, |
| 225 | unsigned param_send_flags) |
| 226 | { |
| 227 | return bassboost_send_params(OFFLOAD, (void *)ctl, bassboost, |
| 228 | param_send_flags); |
| 229 | } |
| 230 | |
| 231 | int hw_acc_bassboost_send_params(int fd, struct bass_boost_params *bassboost, |
| 232 | unsigned param_send_flags) |
| 233 | { |
| 234 | return bassboost_send_params(HW_ACCELERATOR, (void *)&fd, |
| 235 | bassboost, param_send_flags); |
| 236 | } |
| 237 | |
Dhananjay Kumar | 5f15ff9 | 2014-05-19 16:45:08 +0800 | [diff] [blame] | 238 | void offload_pbe_set_device(struct pbe_params *pbe, |
| 239 | uint32_t device) |
| 240 | { |
| 241 | ALOGV("%s: device=%d", __func__, device); |
| 242 | pbe->device = device; |
| 243 | } |
| 244 | |
| 245 | void offload_pbe_set_enable_flag(struct pbe_params *pbe, |
| 246 | bool enable) |
| 247 | { |
| 248 | ALOGV("%s: enable=%d", __func__, enable); |
| 249 | pbe->enable_flag = enable; |
| 250 | } |
| 251 | |
| 252 | int offload_pbe_get_enable_flag(struct pbe_params *pbe) |
| 253 | { |
| 254 | ALOGV("%s: enabled=%d", __func__, pbe->enable_flag); |
| 255 | return pbe->enable_flag; |
| 256 | } |
| 257 | |
| 258 | static int pbe_send_params(eff_mode_t mode, void *ctl, |
| 259 | struct pbe_params *pbe, |
| 260 | unsigned param_send_flags) |
| 261 | { |
| 262 | int param_values[128] = {0}; |
| 263 | int i, *p_param_values = param_values, *cfg = NULL; |
| 264 | |
| 265 | ALOGV("%s: enabled=%d", __func__, pbe->enable_flag); |
| 266 | *p_param_values++ = PBE_MODULE; |
| 267 | *p_param_values++ = pbe->device; |
| 268 | *p_param_values++ = 0; /* num of commands*/ |
| 269 | if (param_send_flags & OFFLOAD_SEND_PBE_ENABLE_FLAG) { |
| 270 | *p_param_values++ = PBE_ENABLE; |
| 271 | *p_param_values++ = CONFIG_SET; |
| 272 | *p_param_values++ = 0; /* start offset if param size if greater than 128 */ |
| 273 | *p_param_values++ = PBE_ENABLE_PARAM_LEN; |
| 274 | *p_param_values++ = pbe->enable_flag; |
| 275 | param_values[2] += 1; |
| 276 | } |
| 277 | if (param_send_flags & OFFLOAD_SEND_PBE_CONFIG) { |
| 278 | *p_param_values++ = PBE_CONFIG; |
| 279 | *p_param_values++ = CONFIG_SET; |
| 280 | *p_param_values++ = 0; /* start offset if param size if greater than 128 */ |
| 281 | *p_param_values++ = pbe->cfg_len; |
| 282 | cfg = (int *)&pbe->config; |
| 283 | for (i = 0; i < (int)pbe->cfg_len ; i+= sizeof(*p_param_values)) |
| 284 | *p_param_values++ = *cfg++; |
| 285 | param_values[2] += 1; |
| 286 | } |
| 287 | |
| 288 | if ((mode == OFFLOAD) && param_values[2] && ctl) { |
| 289 | mixer_ctl_set_array((struct mixer_ctl *)ctl, param_values, |
| 290 | ARRAY_SIZE(param_values)); |
| 291 | } else if ((mode == HW_ACCELERATOR) && param_values[2] && |
| 292 | ctl && *(int *)ctl) { |
| 293 | if (ioctl(*(int *)ctl, AUDIO_EFFECTS_SET_PP_PARAMS, param_values) < 0) |
| 294 | ALOGE("%s: sending h/w acc effects params fail[%d]", __func__, errno); |
| 295 | } |
| 296 | |
| 297 | return 0; |
| 298 | } |
| 299 | |
| 300 | int offload_pbe_send_params(struct mixer_ctl *ctl, |
| 301 | struct pbe_params *pbe, |
| 302 | unsigned param_send_flags) |
| 303 | { |
| 304 | return pbe_send_params(OFFLOAD, (void *)ctl, pbe, |
| 305 | param_send_flags); |
| 306 | } |
| 307 | |
| 308 | int hw_acc_pbe_send_params(int fd, struct pbe_params *pbe, |
| 309 | unsigned param_send_flags) |
| 310 | { |
| 311 | return pbe_send_params(HW_ACCELERATOR, (void *)&fd, |
| 312 | pbe, param_send_flags); |
| 313 | } |
| 314 | |
Subhash Chandra Bose Naripeddy | 3eedc00 | 2013-11-12 20:45:15 -0800 | [diff] [blame] | 315 | void offload_virtualizer_set_device(struct virtualizer_params *virtualizer, |
| 316 | uint32_t device) |
| 317 | { |
Dhananjay Kumar | 574f392 | 2014-03-25 17:41:44 +0530 | [diff] [blame] | 318 | ALOGVV("%s: device=0x%x", __func__, device); |
Subhash Chandra Bose Naripeddy | 3eedc00 | 2013-11-12 20:45:15 -0800 | [diff] [blame] | 319 | virtualizer->device = device; |
| 320 | } |
| 321 | |
| 322 | void offload_virtualizer_set_enable_flag(struct virtualizer_params *virtualizer, |
| 323 | bool enable) |
| 324 | { |
Dhananjay Kumar | 574f392 | 2014-03-25 17:41:44 +0530 | [diff] [blame] | 325 | ALOGVV("%s: enable=%d", __func__, (int)enable); |
Subhash Chandra Bose Naripeddy | 3eedc00 | 2013-11-12 20:45:15 -0800 | [diff] [blame] | 326 | virtualizer->enable_flag = enable; |
Jitendra Naruka | 1b6513f | 2014-11-22 19:34:13 -0800 | [diff] [blame] | 327 | |
| 328 | #ifdef DTS_EAGLE |
| 329 | update_effects_node(PCM_DEV_ID, EFFECT_TYPE_VIRT, EFFECT_ENABLE_PARAM, enable, EFFECT_NO_OP, EFFECT_NO_OP, EFFECT_NO_OP); |
| 330 | #endif |
Subhash Chandra Bose Naripeddy | 3eedc00 | 2013-11-12 20:45:15 -0800 | [diff] [blame] | 331 | } |
| 332 | |
| 333 | int offload_virtualizer_get_enable_flag(struct virtualizer_params *virtualizer) |
| 334 | { |
Dhananjay Kumar | 574f392 | 2014-03-25 17:41:44 +0530 | [diff] [blame] | 335 | ALOGVV("%s: enabled %d", __func__, (int)virtualizer->enable_flag); |
Subhash Chandra Bose Naripeddy | 3eedc00 | 2013-11-12 20:45:15 -0800 | [diff] [blame] | 336 | return virtualizer->enable_flag; |
| 337 | } |
| 338 | |
| 339 | void offload_virtualizer_set_strength(struct virtualizer_params *virtualizer, |
| 340 | int strength) |
| 341 | { |
Dhananjay Kumar | 574f392 | 2014-03-25 17:41:44 +0530 | [diff] [blame] | 342 | ALOGVV("%s: strength %d", __func__, strength); |
Subhash Chandra Bose Naripeddy | 3eedc00 | 2013-11-12 20:45:15 -0800 | [diff] [blame] | 343 | virtualizer->strength = strength; |
Jitendra Naruka | 1b6513f | 2014-11-22 19:34:13 -0800 | [diff] [blame] | 344 | |
| 345 | #ifdef DTS_EAGLE |
| 346 | update_effects_node(PCM_DEV_ID, EFFECT_TYPE_VIRT, EFFECT_SET_PARAM, EFFECT_NO_OP, strength, EFFECT_NO_OP, EFFECT_NO_OP); |
| 347 | #endif |
Subhash Chandra Bose Naripeddy | 3eedc00 | 2013-11-12 20:45:15 -0800 | [diff] [blame] | 348 | } |
| 349 | |
| 350 | void offload_virtualizer_set_out_type(struct virtualizer_params *virtualizer, |
| 351 | int out_type) |
| 352 | { |
Dhananjay Kumar | 574f392 | 2014-03-25 17:41:44 +0530 | [diff] [blame] | 353 | ALOGVV("%s: out_type %d", __func__, out_type); |
Subhash Chandra Bose Naripeddy | 3eedc00 | 2013-11-12 20:45:15 -0800 | [diff] [blame] | 354 | virtualizer->out_type = out_type; |
| 355 | } |
| 356 | |
| 357 | void offload_virtualizer_set_gain_adjust(struct virtualizer_params *virtualizer, |
| 358 | int gain_adjust) |
| 359 | { |
Dhananjay Kumar | 574f392 | 2014-03-25 17:41:44 +0530 | [diff] [blame] | 360 | ALOGVV("%s: gain %d", __func__, gain_adjust); |
Subhash Chandra Bose Naripeddy | 3eedc00 | 2013-11-12 20:45:15 -0800 | [diff] [blame] | 361 | virtualizer->gain_adjust = gain_adjust; |
| 362 | } |
| 363 | |
Subhash Chandra Bose Naripeddy | e40a7cd | 2014-06-03 19:42:41 -0700 | [diff] [blame] | 364 | static int virtualizer_send_params(eff_mode_t mode, void *ctl, |
| 365 | struct virtualizer_params *virtualizer, |
| 366 | unsigned param_send_flags) |
Subhash Chandra Bose Naripeddy | 3eedc00 | 2013-11-12 20:45:15 -0800 | [diff] [blame] | 367 | { |
| 368 | int param_values[128] = {0}; |
| 369 | int *p_param_values = param_values; |
| 370 | |
Dhananjay Kumar | 574f392 | 2014-03-25 17:41:44 +0530 | [diff] [blame] | 371 | ALOGV("%s: flags 0x%x", __func__, param_send_flags); |
Subhash Chandra Bose Naripeddy | 3eedc00 | 2013-11-12 20:45:15 -0800 | [diff] [blame] | 372 | *p_param_values++ = VIRTUALIZER_MODULE; |
Subhash Chandra Bose Naripeddy | e40a7cd | 2014-06-03 19:42:41 -0700 | [diff] [blame] | 373 | *p_param_values++ = virtualizer->device; |
Subhash Chandra Bose Naripeddy | 3eedc00 | 2013-11-12 20:45:15 -0800 | [diff] [blame] | 374 | *p_param_values++ = 0; /* num of commands*/ |
| 375 | if (param_send_flags & OFFLOAD_SEND_VIRTUALIZER_ENABLE_FLAG) { |
| 376 | *p_param_values++ = VIRTUALIZER_ENABLE; |
| 377 | *p_param_values++ = CONFIG_SET; |
| 378 | *p_param_values++ = 0; /* start offset if param size if greater than 128 */ |
| 379 | *p_param_values++ = VIRTUALIZER_ENABLE_PARAM_LEN; |
Subhash Chandra Bose Naripeddy | e40a7cd | 2014-06-03 19:42:41 -0700 | [diff] [blame] | 380 | *p_param_values++ = virtualizer->enable_flag; |
Subhash Chandra Bose Naripeddy | 3eedc00 | 2013-11-12 20:45:15 -0800 | [diff] [blame] | 381 | param_values[2] += 1; |
| 382 | } |
| 383 | if (param_send_flags & OFFLOAD_SEND_VIRTUALIZER_STRENGTH) { |
| 384 | *p_param_values++ = VIRTUALIZER_STRENGTH; |
| 385 | *p_param_values++ = CONFIG_SET; |
| 386 | *p_param_values++ = 0; /* start offset if param size if greater than 128 */ |
| 387 | *p_param_values++ = VIRTUALIZER_STRENGTH_PARAM_LEN; |
Subhash Chandra Bose Naripeddy | e40a7cd | 2014-06-03 19:42:41 -0700 | [diff] [blame] | 388 | *p_param_values++ = virtualizer->strength; |
Subhash Chandra Bose Naripeddy | 3eedc00 | 2013-11-12 20:45:15 -0800 | [diff] [blame] | 389 | param_values[2] += 1; |
| 390 | } |
| 391 | if (param_send_flags & OFFLOAD_SEND_VIRTUALIZER_OUT_TYPE) { |
| 392 | *p_param_values++ = VIRTUALIZER_OUT_TYPE; |
| 393 | *p_param_values++ = CONFIG_SET; |
| 394 | *p_param_values++ = 0; /* start offset if param size if greater than 128 */ |
| 395 | *p_param_values++ = VIRTUALIZER_OUT_TYPE_PARAM_LEN; |
Subhash Chandra Bose Naripeddy | e40a7cd | 2014-06-03 19:42:41 -0700 | [diff] [blame] | 396 | *p_param_values++ = virtualizer->out_type; |
Subhash Chandra Bose Naripeddy | 3eedc00 | 2013-11-12 20:45:15 -0800 | [diff] [blame] | 397 | param_values[2] += 1; |
| 398 | } |
| 399 | if (param_send_flags & OFFLOAD_SEND_VIRTUALIZER_GAIN_ADJUST) { |
| 400 | *p_param_values++ = VIRTUALIZER_GAIN_ADJUST; |
| 401 | *p_param_values++ = CONFIG_SET; |
| 402 | *p_param_values++ = 0; /* start offset if param size if greater than 128 */ |
| 403 | *p_param_values++ = VIRTUALIZER_GAIN_ADJUST_PARAM_LEN; |
Subhash Chandra Bose Naripeddy | e40a7cd | 2014-06-03 19:42:41 -0700 | [diff] [blame] | 404 | *p_param_values++ = virtualizer->gain_adjust; |
Subhash Chandra Bose Naripeddy | 3eedc00 | 2013-11-12 20:45:15 -0800 | [diff] [blame] | 405 | param_values[2] += 1; |
| 406 | } |
| 407 | |
Subhash Chandra Bose Naripeddy | e40a7cd | 2014-06-03 19:42:41 -0700 | [diff] [blame] | 408 | if ((mode == OFFLOAD) && param_values[2] && ctl) { |
| 409 | mixer_ctl_set_array((struct mixer_ctl *)ctl, param_values, |
| 410 | ARRAY_SIZE(param_values)); |
| 411 | } else if ((mode == HW_ACCELERATOR) && param_values[2] && |
| 412 | ctl && *(int *)ctl) { |
| 413 | if (ioctl(*(int *)ctl, AUDIO_EFFECTS_SET_PP_PARAMS, param_values) < 0) |
| 414 | ALOGE("%s: sending h/w acc effects params fail[%d]", __func__, errno); |
| 415 | } |
Subhash Chandra Bose Naripeddy | 3eedc00 | 2013-11-12 20:45:15 -0800 | [diff] [blame] | 416 | |
| 417 | return 0; |
| 418 | } |
| 419 | |
Subhash Chandra Bose Naripeddy | e40a7cd | 2014-06-03 19:42:41 -0700 | [diff] [blame] | 420 | int offload_virtualizer_send_params(struct mixer_ctl *ctl, |
| 421 | struct virtualizer_params *virtualizer, |
| 422 | unsigned param_send_flags) |
| 423 | { |
| 424 | return virtualizer_send_params(OFFLOAD, (void *)ctl, virtualizer, |
| 425 | param_send_flags); |
| 426 | } |
| 427 | |
| 428 | int hw_acc_virtualizer_send_params(int fd, |
| 429 | struct virtualizer_params *virtualizer, |
| 430 | unsigned param_send_flags) |
| 431 | { |
| 432 | return virtualizer_send_params(HW_ACCELERATOR, (void *)&fd, |
| 433 | virtualizer, param_send_flags); |
| 434 | } |
| 435 | |
Subhash Chandra Bose Naripeddy | 3eedc00 | 2013-11-12 20:45:15 -0800 | [diff] [blame] | 436 | void offload_eq_set_device(struct eq_params *eq, uint32_t device) |
| 437 | { |
Dhananjay Kumar | 574f392 | 2014-03-25 17:41:44 +0530 | [diff] [blame] | 438 | ALOGVV("%s: device 0x%x", __func__, device); |
Subhash Chandra Bose Naripeddy | 3eedc00 | 2013-11-12 20:45:15 -0800 | [diff] [blame] | 439 | eq->device = device; |
| 440 | } |
| 441 | |
| 442 | void offload_eq_set_enable_flag(struct eq_params *eq, bool enable) |
| 443 | { |
Dhananjay Kumar | 574f392 | 2014-03-25 17:41:44 +0530 | [diff] [blame] | 444 | ALOGVV("%s: enable=%d", __func__, (int)enable); |
Subhash Chandra Bose Naripeddy | 3eedc00 | 2013-11-12 20:45:15 -0800 | [diff] [blame] | 445 | eq->enable_flag = enable; |
Jitendra Naruka | 1b6513f | 2014-11-22 19:34:13 -0800 | [diff] [blame] | 446 | |
| 447 | #ifdef DTS_EAGLE |
| 448 | update_effects_node(PCM_DEV_ID, EFFECT_TYPE_EQ, EFFECT_ENABLE_PARAM, enable, EFFECT_NO_OP, EFFECT_NO_OP, EFFECT_NO_OP); |
| 449 | #endif |
Subhash Chandra Bose Naripeddy | 3eedc00 | 2013-11-12 20:45:15 -0800 | [diff] [blame] | 450 | } |
| 451 | |
| 452 | int offload_eq_get_enable_flag(struct eq_params *eq) |
| 453 | { |
Dhananjay Kumar | 574f392 | 2014-03-25 17:41:44 +0530 | [diff] [blame] | 454 | ALOGVV("%s: enabled=%d", __func__, (int)eq->enable_flag); |
Subhash Chandra Bose Naripeddy | 3eedc00 | 2013-11-12 20:45:15 -0800 | [diff] [blame] | 455 | return eq->enable_flag; |
| 456 | } |
| 457 | |
| 458 | void offload_eq_set_preset(struct eq_params *eq, int preset) |
| 459 | { |
Dhananjay Kumar | 574f392 | 2014-03-25 17:41:44 +0530 | [diff] [blame] | 460 | ALOGVV("%s: preset %d", __func__, preset); |
Subhash Chandra Bose Naripeddy | 3eedc00 | 2013-11-12 20:45:15 -0800 | [diff] [blame] | 461 | eq->config.preset_id = preset; |
| 462 | eq->config.eq_pregain = Q27_UNITY; |
| 463 | } |
| 464 | |
| 465 | void offload_eq_set_bands_level(struct eq_params *eq, int num_bands, |
| 466 | const uint16_t *band_freq_list, |
| 467 | int *band_gain_list) |
| 468 | { |
| 469 | int i; |
Dhananjay Kumar | 574f392 | 2014-03-25 17:41:44 +0530 | [diff] [blame] | 470 | ALOGVV("%s", __func__); |
Subhash Chandra Bose Naripeddy | 3eedc00 | 2013-11-12 20:45:15 -0800 | [diff] [blame] | 471 | eq->config.num_bands = num_bands; |
| 472 | for (i=0; i<num_bands; i++) { |
| 473 | eq->per_band_cfg[i].band_idx = i; |
| 474 | eq->per_band_cfg[i].filter_type = EQ_BAND_BOOST; |
| 475 | eq->per_band_cfg[i].freq_millihertz = band_freq_list[i] * 1000; |
| 476 | eq->per_band_cfg[i].gain_millibels = band_gain_list[i] * 100; |
| 477 | eq->per_band_cfg[i].quality_factor = Q8_UNITY; |
| 478 | } |
Jitendra Naruka | 1b6513f | 2014-11-22 19:34:13 -0800 | [diff] [blame] | 479 | |
| 480 | #ifdef DTS_EAGLE |
| 481 | update_effects_node(PCM_DEV_ID, EFFECT_TYPE_EQ, EFFECT_SET_PARAM, EFFECT_NO_OP, EFFECT_NO_OP, i, band_gain_list[i] * 100); |
| 482 | #endif |
Subhash Chandra Bose Naripeddy | 3eedc00 | 2013-11-12 20:45:15 -0800 | [diff] [blame] | 483 | } |
| 484 | |
Subhash Chandra Bose Naripeddy | e40a7cd | 2014-06-03 19:42:41 -0700 | [diff] [blame] | 485 | static int eq_send_params(eff_mode_t mode, void *ctl, struct eq_params *eq, |
| 486 | unsigned param_send_flags) |
Subhash Chandra Bose Naripeddy | 3eedc00 | 2013-11-12 20:45:15 -0800 | [diff] [blame] | 487 | { |
| 488 | int param_values[128] = {0}; |
| 489 | int *p_param_values = param_values; |
| 490 | uint32_t i; |
| 491 | |
Dhananjay Kumar | 574f392 | 2014-03-25 17:41:44 +0530 | [diff] [blame] | 492 | ALOGV("%s: flags 0x%x", __func__, param_send_flags); |
Subhash Chandra Bose Naripeddy | e40a7cd | 2014-06-03 19:42:41 -0700 | [diff] [blame] | 493 | if ((eq->config.preset_id < -1) || |
| 494 | ((param_send_flags & OFFLOAD_SEND_EQ_PRESET) && (eq->config.preset_id == -1))) { |
Subhash Chandra Bose Naripeddy | 3eedc00 | 2013-11-12 20:45:15 -0800 | [diff] [blame] | 495 | ALOGV("No Valid preset to set"); |
| 496 | return 0; |
| 497 | } |
| 498 | *p_param_values++ = EQ_MODULE; |
Subhash Chandra Bose Naripeddy | e40a7cd | 2014-06-03 19:42:41 -0700 | [diff] [blame] | 499 | *p_param_values++ = eq->device; |
Subhash Chandra Bose Naripeddy | 3eedc00 | 2013-11-12 20:45:15 -0800 | [diff] [blame] | 500 | *p_param_values++ = 0; /* num of commands*/ |
| 501 | if (param_send_flags & OFFLOAD_SEND_EQ_ENABLE_FLAG) { |
| 502 | *p_param_values++ = EQ_ENABLE; |
| 503 | *p_param_values++ = CONFIG_SET; |
| 504 | *p_param_values++ = 0; /* start offset if param size if greater than 128 */ |
| 505 | *p_param_values++ = EQ_ENABLE_PARAM_LEN; |
Subhash Chandra Bose Naripeddy | e40a7cd | 2014-06-03 19:42:41 -0700 | [diff] [blame] | 506 | *p_param_values++ = eq->enable_flag; |
Subhash Chandra Bose Naripeddy | 3eedc00 | 2013-11-12 20:45:15 -0800 | [diff] [blame] | 507 | param_values[2] += 1; |
| 508 | } |
| 509 | if (param_send_flags & OFFLOAD_SEND_EQ_PRESET) { |
| 510 | *p_param_values++ = EQ_CONFIG; |
| 511 | *p_param_values++ = CONFIG_SET; |
| 512 | *p_param_values++ = 0; /* start offset if param size if greater than 128 */ |
| 513 | *p_param_values++ = EQ_CONFIG_PARAM_LEN; |
Subhash Chandra Bose Naripeddy | e40a7cd | 2014-06-03 19:42:41 -0700 | [diff] [blame] | 514 | *p_param_values++ = eq->config.eq_pregain; |
Subhash Chandra Bose Naripeddy | 3eedc00 | 2013-11-12 20:45:15 -0800 | [diff] [blame] | 515 | *p_param_values++ = |
Subhash Chandra Bose Naripeddy | e40a7cd | 2014-06-03 19:42:41 -0700 | [diff] [blame] | 516 | map_eq_opensl_preset_2_offload_preset[eq->config.preset_id]; |
Subhash Chandra Bose Naripeddy | 3eedc00 | 2013-11-12 20:45:15 -0800 | [diff] [blame] | 517 | *p_param_values++ = 0; |
| 518 | param_values[2] += 1; |
| 519 | } |
| 520 | if (param_send_flags & OFFLOAD_SEND_EQ_BANDS_LEVEL) { |
| 521 | *p_param_values++ = EQ_CONFIG; |
| 522 | *p_param_values++ = CONFIG_SET; |
| 523 | *p_param_values++ = 0; /* start offset if param size if greater than 128 */ |
| 524 | *p_param_values++ = EQ_CONFIG_PARAM_LEN + |
Subhash Chandra Bose Naripeddy | e40a7cd | 2014-06-03 19:42:41 -0700 | [diff] [blame] | 525 | eq->config.num_bands * EQ_CONFIG_PER_BAND_PARAM_LEN; |
| 526 | *p_param_values++ = eq->config.eq_pregain; |
Subhash Chandra Bose Naripeddy | 3eedc00 | 2013-11-12 20:45:15 -0800 | [diff] [blame] | 527 | *p_param_values++ = CUSTOM_OPENSL_PRESET; |
Subhash Chandra Bose Naripeddy | e40a7cd | 2014-06-03 19:42:41 -0700 | [diff] [blame] | 528 | *p_param_values++ = eq->config.num_bands; |
| 529 | for (i=0; i<eq->config.num_bands; i++) { |
| 530 | *p_param_values++ = eq->per_band_cfg[i].band_idx; |
| 531 | *p_param_values++ = eq->per_band_cfg[i].filter_type; |
| 532 | *p_param_values++ = eq->per_band_cfg[i].freq_millihertz; |
| 533 | *p_param_values++ = eq->per_band_cfg[i].gain_millibels; |
| 534 | *p_param_values++ = eq->per_band_cfg[i].quality_factor; |
Subhash Chandra Bose Naripeddy | 3eedc00 | 2013-11-12 20:45:15 -0800 | [diff] [blame] | 535 | } |
| 536 | param_values[2] += 1; |
| 537 | } |
| 538 | |
Subhash Chandra Bose Naripeddy | e40a7cd | 2014-06-03 19:42:41 -0700 | [diff] [blame] | 539 | if ((mode == OFFLOAD) && param_values[2] && ctl) { |
| 540 | mixer_ctl_set_array((struct mixer_ctl *)ctl, param_values, |
| 541 | ARRAY_SIZE(param_values)); |
| 542 | } else if ((mode == HW_ACCELERATOR) && param_values[2] && |
| 543 | ctl && *(int *)ctl) { |
| 544 | if (ioctl(*(int *)ctl, AUDIO_EFFECTS_SET_PP_PARAMS, param_values) < 0) |
| 545 | ALOGE("%s: sending h/w acc effects params fail[%d]", __func__, errno); |
| 546 | } |
Subhash Chandra Bose Naripeddy | 3eedc00 | 2013-11-12 20:45:15 -0800 | [diff] [blame] | 547 | |
| 548 | return 0; |
| 549 | } |
| 550 | |
Subhash Chandra Bose Naripeddy | e40a7cd | 2014-06-03 19:42:41 -0700 | [diff] [blame] | 551 | int offload_eq_send_params(struct mixer_ctl *ctl, struct eq_params *eq, |
| 552 | unsigned param_send_flags) |
| 553 | { |
| 554 | return eq_send_params(OFFLOAD, (void *)ctl, eq, param_send_flags); |
| 555 | } |
| 556 | |
| 557 | int hw_acc_eq_send_params(int fd, struct eq_params *eq, |
| 558 | unsigned param_send_flags) |
| 559 | { |
| 560 | return eq_send_params(HW_ACCELERATOR, (void *)&fd, eq, |
| 561 | param_send_flags); |
| 562 | } |
| 563 | |
Subhash Chandra Bose Naripeddy | 3eedc00 | 2013-11-12 20:45:15 -0800 | [diff] [blame] | 564 | void offload_reverb_set_device(struct reverb_params *reverb, uint32_t device) |
| 565 | { |
Dhananjay Kumar | 574f392 | 2014-03-25 17:41:44 +0530 | [diff] [blame] | 566 | ALOGVV("%s: device 0x%x", __func__, device); |
Subhash Chandra Bose Naripeddy | 3eedc00 | 2013-11-12 20:45:15 -0800 | [diff] [blame] | 567 | reverb->device = device; |
| 568 | } |
| 569 | |
| 570 | void offload_reverb_set_enable_flag(struct reverb_params *reverb, bool enable) |
| 571 | { |
Dhananjay Kumar | 574f392 | 2014-03-25 17:41:44 +0530 | [diff] [blame] | 572 | ALOGVV("%s: enable=%d", __func__, (int)enable); |
Subhash Chandra Bose Naripeddy | 3eedc00 | 2013-11-12 20:45:15 -0800 | [diff] [blame] | 573 | reverb->enable_flag = enable; |
| 574 | } |
| 575 | |
| 576 | int offload_reverb_get_enable_flag(struct reverb_params *reverb) |
| 577 | { |
Dhananjay Kumar | 574f392 | 2014-03-25 17:41:44 +0530 | [diff] [blame] | 578 | ALOGVV("%s: enabled=%d", __func__, reverb->enable_flag); |
Subhash Chandra Bose Naripeddy | 3eedc00 | 2013-11-12 20:45:15 -0800 | [diff] [blame] | 579 | return reverb->enable_flag; |
| 580 | } |
| 581 | |
| 582 | void offload_reverb_set_mode(struct reverb_params *reverb, int mode) |
| 583 | { |
Dhananjay Kumar | 574f392 | 2014-03-25 17:41:44 +0530 | [diff] [blame] | 584 | ALOGVV("%s", __func__); |
Subhash Chandra Bose Naripeddy | 3eedc00 | 2013-11-12 20:45:15 -0800 | [diff] [blame] | 585 | reverb->mode = mode; |
| 586 | } |
| 587 | |
| 588 | void offload_reverb_set_preset(struct reverb_params *reverb, int preset) |
| 589 | { |
Dhananjay Kumar | 574f392 | 2014-03-25 17:41:44 +0530 | [diff] [blame] | 590 | ALOGVV("%s: preset %d", __func__, preset); |
Subhash Chandra Bose Naripeddy | 3eedc00 | 2013-11-12 20:45:15 -0800 | [diff] [blame] | 591 | if (preset && (preset <= NUM_OSL_REVERB_PRESETS_SUPPORTED)) |
wjiang | ca2685b | 2014-03-18 06:43:48 +0800 | [diff] [blame] | 592 | reverb->preset = map_reverb_opensl_preset_2_offload_preset[preset-1][1]; |
Subhash Chandra Bose Naripeddy | 3eedc00 | 2013-11-12 20:45:15 -0800 | [diff] [blame] | 593 | } |
| 594 | |
| 595 | void offload_reverb_set_wet_mix(struct reverb_params *reverb, int wet_mix) |
| 596 | { |
Dhananjay Kumar | 574f392 | 2014-03-25 17:41:44 +0530 | [diff] [blame] | 597 | ALOGVV("%s: wet_mix %d", __func__, wet_mix); |
Subhash Chandra Bose Naripeddy | 3eedc00 | 2013-11-12 20:45:15 -0800 | [diff] [blame] | 598 | reverb->wet_mix = wet_mix; |
| 599 | } |
| 600 | |
| 601 | void offload_reverb_set_gain_adjust(struct reverb_params *reverb, |
| 602 | int gain_adjust) |
| 603 | { |
Dhananjay Kumar | 574f392 | 2014-03-25 17:41:44 +0530 | [diff] [blame] | 604 | ALOGVV("%s: gain %d", __func__, gain_adjust); |
Subhash Chandra Bose Naripeddy | 3eedc00 | 2013-11-12 20:45:15 -0800 | [diff] [blame] | 605 | reverb->gain_adjust = gain_adjust; |
| 606 | } |
| 607 | |
| 608 | void offload_reverb_set_room_level(struct reverb_params *reverb, int room_level) |
| 609 | { |
Dhananjay Kumar | 574f392 | 2014-03-25 17:41:44 +0530 | [diff] [blame] | 610 | ALOGVV("%s: level %d", __func__, room_level); |
Subhash Chandra Bose Naripeddy | 3eedc00 | 2013-11-12 20:45:15 -0800 | [diff] [blame] | 611 | reverb->room_level = room_level; |
| 612 | } |
| 613 | |
| 614 | void offload_reverb_set_room_hf_level(struct reverb_params *reverb, |
| 615 | int room_hf_level) |
| 616 | { |
Dhananjay Kumar | 574f392 | 2014-03-25 17:41:44 +0530 | [diff] [blame] | 617 | ALOGVV("%s: level %d", __func__, room_hf_level); |
Subhash Chandra Bose Naripeddy | 3eedc00 | 2013-11-12 20:45:15 -0800 | [diff] [blame] | 618 | reverb->room_hf_level = room_hf_level; |
| 619 | } |
| 620 | |
| 621 | void offload_reverb_set_decay_time(struct reverb_params *reverb, int decay_time) |
| 622 | { |
Dhananjay Kumar | 574f392 | 2014-03-25 17:41:44 +0530 | [diff] [blame] | 623 | ALOGVV("%s: decay time %d", __func__, decay_time); |
Subhash Chandra Bose Naripeddy | 3eedc00 | 2013-11-12 20:45:15 -0800 | [diff] [blame] | 624 | reverb->decay_time = decay_time; |
| 625 | } |
| 626 | |
| 627 | void offload_reverb_set_decay_hf_ratio(struct reverb_params *reverb, |
| 628 | int decay_hf_ratio) |
| 629 | { |
Dhananjay Kumar | 574f392 | 2014-03-25 17:41:44 +0530 | [diff] [blame] | 630 | ALOGVV("%s: decay_hf_ratio %d", __func__, decay_hf_ratio); |
Subhash Chandra Bose Naripeddy | 3eedc00 | 2013-11-12 20:45:15 -0800 | [diff] [blame] | 631 | reverb->decay_hf_ratio = decay_hf_ratio; |
| 632 | } |
| 633 | |
| 634 | void offload_reverb_set_reflections_level(struct reverb_params *reverb, |
| 635 | int reflections_level) |
| 636 | { |
Dhananjay Kumar | 574f392 | 2014-03-25 17:41:44 +0530 | [diff] [blame] | 637 | ALOGVV("%s: ref level %d", __func__, reflections_level); |
Subhash Chandra Bose Naripeddy | 3eedc00 | 2013-11-12 20:45:15 -0800 | [diff] [blame] | 638 | reverb->reflections_level = reflections_level; |
| 639 | } |
| 640 | |
| 641 | void offload_reverb_set_reflections_delay(struct reverb_params *reverb, |
| 642 | int reflections_delay) |
| 643 | { |
Dhananjay Kumar | 574f392 | 2014-03-25 17:41:44 +0530 | [diff] [blame] | 644 | ALOGVV("%s: ref delay", __func__, reflections_delay); |
Subhash Chandra Bose Naripeddy | 3eedc00 | 2013-11-12 20:45:15 -0800 | [diff] [blame] | 645 | reverb->reflections_delay = reflections_delay; |
| 646 | } |
| 647 | |
| 648 | void offload_reverb_set_reverb_level(struct reverb_params *reverb, |
| 649 | int reverb_level) |
| 650 | { |
Dhananjay Kumar | 574f392 | 2014-03-25 17:41:44 +0530 | [diff] [blame] | 651 | ALOGD("%s: reverb level %d", __func__, reverb_level); |
Subhash Chandra Bose Naripeddy | 3eedc00 | 2013-11-12 20:45:15 -0800 | [diff] [blame] | 652 | reverb->level = reverb_level; |
| 653 | } |
| 654 | |
| 655 | void offload_reverb_set_delay(struct reverb_params *reverb, int delay) |
| 656 | { |
Dhananjay Kumar | 574f392 | 2014-03-25 17:41:44 +0530 | [diff] [blame] | 657 | ALOGVV("%s: delay %d", __func__, delay); |
Subhash Chandra Bose Naripeddy | 3eedc00 | 2013-11-12 20:45:15 -0800 | [diff] [blame] | 658 | reverb->delay = delay; |
| 659 | } |
| 660 | |
| 661 | void offload_reverb_set_diffusion(struct reverb_params *reverb, int diffusion) |
| 662 | { |
Dhananjay Kumar | 574f392 | 2014-03-25 17:41:44 +0530 | [diff] [blame] | 663 | ALOGVV("%s: diffusion %d", __func__, diffusion); |
Subhash Chandra Bose Naripeddy | 3eedc00 | 2013-11-12 20:45:15 -0800 | [diff] [blame] | 664 | reverb->diffusion = diffusion; |
| 665 | } |
| 666 | |
| 667 | void offload_reverb_set_density(struct reverb_params *reverb, int density) |
| 668 | { |
Dhananjay Kumar | 574f392 | 2014-03-25 17:41:44 +0530 | [diff] [blame] | 669 | ALOGVV("%s: density %d", __func__, density); |
Subhash Chandra Bose Naripeddy | 3eedc00 | 2013-11-12 20:45:15 -0800 | [diff] [blame] | 670 | reverb->density = density; |
| 671 | } |
| 672 | |
Subhash Chandra Bose Naripeddy | e40a7cd | 2014-06-03 19:42:41 -0700 | [diff] [blame] | 673 | static int reverb_send_params(eff_mode_t mode, void *ctl, |
| 674 | struct reverb_params *reverb, |
| 675 | unsigned param_send_flags) |
Subhash Chandra Bose Naripeddy | 3eedc00 | 2013-11-12 20:45:15 -0800 | [diff] [blame] | 676 | { |
| 677 | int param_values[128] = {0}; |
| 678 | int *p_param_values = param_values; |
| 679 | |
Dhananjay Kumar | 574f392 | 2014-03-25 17:41:44 +0530 | [diff] [blame] | 680 | ALOGV("%s: flags 0x%x", __func__, param_send_flags); |
Subhash Chandra Bose Naripeddy | 3eedc00 | 2013-11-12 20:45:15 -0800 | [diff] [blame] | 681 | *p_param_values++ = REVERB_MODULE; |
Subhash Chandra Bose Naripeddy | e40a7cd | 2014-06-03 19:42:41 -0700 | [diff] [blame] | 682 | *p_param_values++ = reverb->device; |
Subhash Chandra Bose Naripeddy | 3eedc00 | 2013-11-12 20:45:15 -0800 | [diff] [blame] | 683 | *p_param_values++ = 0; /* num of commands*/ |
| 684 | |
| 685 | if (param_send_flags & OFFLOAD_SEND_REVERB_ENABLE_FLAG) { |
| 686 | *p_param_values++ = REVERB_ENABLE; |
| 687 | *p_param_values++ = CONFIG_SET; |
| 688 | *p_param_values++ = 0; /* start offset if param size if greater than 128 */ |
| 689 | *p_param_values++ = REVERB_ENABLE_PARAM_LEN; |
Subhash Chandra Bose Naripeddy | e40a7cd | 2014-06-03 19:42:41 -0700 | [diff] [blame] | 690 | *p_param_values++ = reverb->enable_flag; |
Subhash Chandra Bose Naripeddy | 3eedc00 | 2013-11-12 20:45:15 -0800 | [diff] [blame] | 691 | param_values[2] += 1; |
| 692 | } |
| 693 | if (param_send_flags & OFFLOAD_SEND_REVERB_MODE) { |
| 694 | *p_param_values++ = REVERB_MODE; |
| 695 | *p_param_values++ = CONFIG_SET; |
| 696 | *p_param_values++ = 0; /* start offset if param size if greater than 128 */ |
| 697 | *p_param_values++ = REVERB_MODE_PARAM_LEN; |
Subhash Chandra Bose Naripeddy | e40a7cd | 2014-06-03 19:42:41 -0700 | [diff] [blame] | 698 | *p_param_values++ = reverb->mode; |
Subhash Chandra Bose Naripeddy | 3eedc00 | 2013-11-12 20:45:15 -0800 | [diff] [blame] | 699 | param_values[2] += 1; |
| 700 | } |
| 701 | if (param_send_flags & OFFLOAD_SEND_REVERB_PRESET) { |
| 702 | *p_param_values++ = REVERB_PRESET; |
| 703 | *p_param_values++ = CONFIG_SET; |
| 704 | *p_param_values++ = 0; /* start offset if param size if greater than 128 */ |
| 705 | *p_param_values++ = REVERB_PRESET_PARAM_LEN; |
Subhash Chandra Bose Naripeddy | e40a7cd | 2014-06-03 19:42:41 -0700 | [diff] [blame] | 706 | *p_param_values++ = reverb->preset; |
Subhash Chandra Bose Naripeddy | 3eedc00 | 2013-11-12 20:45:15 -0800 | [diff] [blame] | 707 | param_values[2] += 1; |
| 708 | } |
| 709 | if (param_send_flags & OFFLOAD_SEND_REVERB_WET_MIX) { |
| 710 | *p_param_values++ = REVERB_WET_MIX; |
| 711 | *p_param_values++ = CONFIG_SET; |
| 712 | *p_param_values++ = 0; /* start offset if param size if greater than 128 */ |
| 713 | *p_param_values++ = REVERB_WET_MIX_PARAM_LEN; |
Subhash Chandra Bose Naripeddy | e40a7cd | 2014-06-03 19:42:41 -0700 | [diff] [blame] | 714 | *p_param_values++ = reverb->wet_mix; |
Subhash Chandra Bose Naripeddy | 3eedc00 | 2013-11-12 20:45:15 -0800 | [diff] [blame] | 715 | param_values[2] += 1; |
| 716 | } |
| 717 | if (param_send_flags & OFFLOAD_SEND_REVERB_GAIN_ADJUST) { |
| 718 | *p_param_values++ = REVERB_GAIN_ADJUST; |
| 719 | *p_param_values++ = CONFIG_SET; |
| 720 | *p_param_values++ = 0; /* start offset if param size if greater than 128 */ |
| 721 | *p_param_values++ = REVERB_GAIN_ADJUST_PARAM_LEN; |
Subhash Chandra Bose Naripeddy | e40a7cd | 2014-06-03 19:42:41 -0700 | [diff] [blame] | 722 | *p_param_values++ = reverb->gain_adjust; |
Subhash Chandra Bose Naripeddy | 3eedc00 | 2013-11-12 20:45:15 -0800 | [diff] [blame] | 723 | param_values[2] += 1; |
| 724 | } |
| 725 | if (param_send_flags & OFFLOAD_SEND_REVERB_ROOM_LEVEL) { |
| 726 | *p_param_values++ = REVERB_ROOM_LEVEL; |
| 727 | *p_param_values++ = CONFIG_SET; |
| 728 | *p_param_values++ = 0; /* start offset if param size if greater than 128 */ |
| 729 | *p_param_values++ = REVERB_ROOM_LEVEL_PARAM_LEN; |
Subhash Chandra Bose Naripeddy | e40a7cd | 2014-06-03 19:42:41 -0700 | [diff] [blame] | 730 | *p_param_values++ = reverb->room_level; |
Subhash Chandra Bose Naripeddy | 3eedc00 | 2013-11-12 20:45:15 -0800 | [diff] [blame] | 731 | param_values[2] += 1; |
| 732 | } |
| 733 | if (param_send_flags & OFFLOAD_SEND_REVERB_ROOM_HF_LEVEL) { |
| 734 | *p_param_values++ = REVERB_ROOM_HF_LEVEL; |
| 735 | *p_param_values++ = CONFIG_SET; |
| 736 | *p_param_values++ = 0; /* start offset if param size if greater than 128 */ |
| 737 | *p_param_values++ = REVERB_ROOM_HF_LEVEL_PARAM_LEN; |
Subhash Chandra Bose Naripeddy | e40a7cd | 2014-06-03 19:42:41 -0700 | [diff] [blame] | 738 | *p_param_values++ = reverb->room_hf_level; |
Subhash Chandra Bose Naripeddy | 3eedc00 | 2013-11-12 20:45:15 -0800 | [diff] [blame] | 739 | param_values[2] += 1; |
| 740 | } |
| 741 | if (param_send_flags & OFFLOAD_SEND_REVERB_DECAY_TIME) { |
| 742 | *p_param_values++ = REVERB_DECAY_TIME; |
| 743 | *p_param_values++ = CONFIG_SET; |
| 744 | *p_param_values++ = 0; /* start offset if param size if greater than 128 */ |
| 745 | *p_param_values++ = REVERB_DECAY_TIME_PARAM_LEN; |
Subhash Chandra Bose Naripeddy | e40a7cd | 2014-06-03 19:42:41 -0700 | [diff] [blame] | 746 | *p_param_values++ = reverb->decay_time; |
Subhash Chandra Bose Naripeddy | 3eedc00 | 2013-11-12 20:45:15 -0800 | [diff] [blame] | 747 | param_values[2] += 1; |
| 748 | } |
| 749 | if (param_send_flags & OFFLOAD_SEND_REVERB_DECAY_HF_RATIO) { |
| 750 | *p_param_values++ = REVERB_DECAY_HF_RATIO; |
| 751 | *p_param_values++ = CONFIG_SET; |
| 752 | *p_param_values++ = 0; /* start offset if param size if greater than 128 */ |
| 753 | *p_param_values++ = REVERB_DECAY_HF_RATIO_PARAM_LEN; |
Subhash Chandra Bose Naripeddy | e40a7cd | 2014-06-03 19:42:41 -0700 | [diff] [blame] | 754 | *p_param_values++ = reverb->decay_hf_ratio; |
Subhash Chandra Bose Naripeddy | 3eedc00 | 2013-11-12 20:45:15 -0800 | [diff] [blame] | 755 | param_values[2] += 1; |
| 756 | } |
| 757 | if (param_send_flags & OFFLOAD_SEND_REVERB_REFLECTIONS_LEVEL) { |
| 758 | *p_param_values++ = REVERB_REFLECTIONS_LEVEL; |
| 759 | *p_param_values++ = CONFIG_SET; |
| 760 | *p_param_values++ = 0; /* start offset if param size if greater than 128 */ |
| 761 | *p_param_values++ = REVERB_REFLECTIONS_LEVEL_PARAM_LEN; |
Subhash Chandra Bose Naripeddy | e40a7cd | 2014-06-03 19:42:41 -0700 | [diff] [blame] | 762 | *p_param_values++ = reverb->reflections_level; |
Subhash Chandra Bose Naripeddy | 3eedc00 | 2013-11-12 20:45:15 -0800 | [diff] [blame] | 763 | param_values[2] += 1; |
| 764 | } |
| 765 | if (param_send_flags & OFFLOAD_SEND_REVERB_REFLECTIONS_DELAY) { |
| 766 | *p_param_values++ = REVERB_REFLECTIONS_DELAY; |
| 767 | *p_param_values++ = CONFIG_SET; |
| 768 | *p_param_values++ = 0; /* start offset if param size if greater than 128 */ |
| 769 | *p_param_values++ = REVERB_REFLECTIONS_DELAY_PARAM_LEN; |
Subhash Chandra Bose Naripeddy | e40a7cd | 2014-06-03 19:42:41 -0700 | [diff] [blame] | 770 | *p_param_values++ = reverb->reflections_delay; |
Subhash Chandra Bose Naripeddy | 3eedc00 | 2013-11-12 20:45:15 -0800 | [diff] [blame] | 771 | param_values[2] += 1; |
| 772 | } |
| 773 | if (param_send_flags & OFFLOAD_SEND_REVERB_LEVEL) { |
| 774 | *p_param_values++ = REVERB_LEVEL; |
| 775 | *p_param_values++ = CONFIG_SET; |
| 776 | *p_param_values++ = 0; /* start offset if param size if greater than 128 */ |
| 777 | *p_param_values++ = REVERB_LEVEL_PARAM_LEN; |
Subhash Chandra Bose Naripeddy | e40a7cd | 2014-06-03 19:42:41 -0700 | [diff] [blame] | 778 | *p_param_values++ = reverb->level; |
Subhash Chandra Bose Naripeddy | 3eedc00 | 2013-11-12 20:45:15 -0800 | [diff] [blame] | 779 | param_values[2] += 1; |
| 780 | } |
| 781 | if (param_send_flags & OFFLOAD_SEND_REVERB_DELAY) { |
| 782 | *p_param_values++ = REVERB_DELAY; |
| 783 | *p_param_values++ = CONFIG_SET; |
| 784 | *p_param_values++ = 0; /* start offset if param size if greater than 128 */ |
| 785 | *p_param_values++ = REVERB_DELAY_PARAM_LEN; |
Subhash Chandra Bose Naripeddy | e40a7cd | 2014-06-03 19:42:41 -0700 | [diff] [blame] | 786 | *p_param_values++ = reverb->delay; |
Subhash Chandra Bose Naripeddy | 3eedc00 | 2013-11-12 20:45:15 -0800 | [diff] [blame] | 787 | param_values[2] += 1; |
| 788 | } |
| 789 | if (param_send_flags & OFFLOAD_SEND_REVERB_DIFFUSION) { |
| 790 | *p_param_values++ = REVERB_DIFFUSION; |
| 791 | *p_param_values++ = CONFIG_SET; |
| 792 | *p_param_values++ = 0; /* start offset if param size if greater than 128 */ |
| 793 | *p_param_values++ = REVERB_DIFFUSION_PARAM_LEN; |
Subhash Chandra Bose Naripeddy | e40a7cd | 2014-06-03 19:42:41 -0700 | [diff] [blame] | 794 | *p_param_values++ = reverb->diffusion; |
Subhash Chandra Bose Naripeddy | 3eedc00 | 2013-11-12 20:45:15 -0800 | [diff] [blame] | 795 | param_values[2] += 1; |
| 796 | } |
| 797 | if (param_send_flags & OFFLOAD_SEND_REVERB_DENSITY) { |
| 798 | *p_param_values++ = REVERB_DENSITY; |
| 799 | *p_param_values++ = CONFIG_SET; |
| 800 | *p_param_values++ = 0; /* start offset if param size if greater than 128 */ |
| 801 | *p_param_values++ = REVERB_DENSITY_PARAM_LEN; |
Subhash Chandra Bose Naripeddy | e40a7cd | 2014-06-03 19:42:41 -0700 | [diff] [blame] | 802 | *p_param_values++ = reverb->density; |
| 803 | param_values[2] += 1; |
| 804 | } |
| 805 | |
| 806 | if ((mode == OFFLOAD) && param_values[2] && ctl) { |
| 807 | mixer_ctl_set_array((struct mixer_ctl *)ctl, param_values, |
| 808 | ARRAY_SIZE(param_values)); |
| 809 | } else if ((mode == HW_ACCELERATOR) && param_values[2] && |
| 810 | ctl && *(int *)ctl) { |
| 811 | if (ioctl(*(int *)ctl, AUDIO_EFFECTS_SET_PP_PARAMS, param_values) < 0) |
| 812 | ALOGE("%s: sending h/w acc effects params fail[%d]", __func__, errno); |
| 813 | } |
| 814 | |
| 815 | return 0; |
| 816 | } |
| 817 | |
| 818 | int offload_reverb_send_params(struct mixer_ctl *ctl, |
| 819 | struct reverb_params *reverb, |
| 820 | unsigned param_send_flags) |
| 821 | { |
| 822 | return reverb_send_params(OFFLOAD, (void *)ctl, reverb, |
| 823 | param_send_flags); |
| 824 | } |
| 825 | |
| 826 | int hw_acc_reverb_send_params(int fd, struct reverb_params *reverb, |
| 827 | unsigned param_send_flags) |
| 828 | { |
| 829 | return reverb_send_params(HW_ACCELERATOR, (void *)&fd, |
| 830 | reverb, param_send_flags); |
| 831 | } |
| 832 | |
| 833 | void offload_soft_volume_set_enable(struct soft_volume_params *vol, bool enable) |
| 834 | { |
| 835 | ALOGV("%s", __func__); |
| 836 | vol->enable_flag = enable; |
| 837 | } |
| 838 | |
| 839 | void offload_soft_volume_set_gain_master(struct soft_volume_params *vol, int gain) |
| 840 | { |
| 841 | ALOGV("%s", __func__); |
| 842 | vol->master_gain = gain; |
| 843 | } |
| 844 | |
| 845 | void offload_soft_volume_set_gain_2ch(struct soft_volume_params *vol, |
| 846 | int l_gain, int r_gain) |
| 847 | { |
| 848 | ALOGV("%s", __func__); |
| 849 | vol->left_gain = l_gain; |
| 850 | vol->right_gain = r_gain; |
| 851 | } |
| 852 | |
| 853 | int offload_soft_volume_send_params(struct mixer_ctl *ctl, |
| 854 | struct soft_volume_params vol, |
| 855 | unsigned param_send_flags) |
| 856 | { |
| 857 | int param_values[128] = {0}; |
| 858 | int *p_param_values = param_values; |
| 859 | uint32_t i; |
| 860 | |
| 861 | ALOGV("%s", __func__); |
| 862 | *p_param_values++ = SOFT_VOLUME_MODULE; |
| 863 | *p_param_values++ = 0; |
| 864 | *p_param_values++ = 0; /* num of commands*/ |
| 865 | if (param_send_flags & OFFLOAD_SEND_SOFT_VOLUME_ENABLE_FLAG) { |
| 866 | *p_param_values++ = SOFT_VOLUME_ENABLE; |
| 867 | *p_param_values++ = CONFIG_SET; |
| 868 | *p_param_values++ = 0; /* start offset if param size if greater than 128 */ |
| 869 | *p_param_values++ = SOFT_VOLUME_ENABLE_PARAM_LEN; |
| 870 | *p_param_values++ = vol.enable_flag; |
| 871 | param_values[2] += 1; |
| 872 | } |
| 873 | if (param_send_flags & OFFLOAD_SEND_SOFT_VOLUME_GAIN_MASTER) { |
| 874 | *p_param_values++ = SOFT_VOLUME_GAIN_MASTER; |
| 875 | *p_param_values++ = CONFIG_SET; |
| 876 | *p_param_values++ = 0; /* start offset if param size if greater than 128 */ |
| 877 | *p_param_values++ = SOFT_VOLUME_GAIN_MASTER_PARAM_LEN; |
| 878 | *p_param_values++ = vol.master_gain; |
| 879 | param_values[2] += 1; |
| 880 | } |
| 881 | if (param_send_flags & OFFLOAD_SEND_SOFT_VOLUME_GAIN_2CH) { |
| 882 | *p_param_values++ = SOFT_VOLUME_GAIN_2CH; |
| 883 | *p_param_values++ = CONFIG_SET; |
| 884 | *p_param_values++ = 0; /* start offset if param size if greater than 128 */ |
| 885 | *p_param_values++ = SOFT_VOLUME_GAIN_2CH_PARAM_LEN; |
| 886 | *p_param_values++ = vol.left_gain; |
| 887 | *p_param_values++ = vol.right_gain; |
| 888 | param_values[2] += 1; |
| 889 | } |
| 890 | |
| 891 | if (param_values[2] && ctl) |
| 892 | mixer_ctl_set_array(ctl, param_values, ARRAY_SIZE(param_values)); |
| 893 | |
| 894 | return 0; |
| 895 | } |
| 896 | |
| 897 | void offload_transition_soft_volume_set_enable(struct soft_volume_params *vol, |
| 898 | bool enable) |
| 899 | { |
| 900 | ALOGV("%s", __func__); |
| 901 | vol->enable_flag = enable; |
| 902 | } |
| 903 | |
| 904 | void offload_transition_soft_volume_set_gain_master(struct soft_volume_params *vol, |
| 905 | int gain) |
| 906 | { |
| 907 | ALOGV("%s", __func__); |
| 908 | vol->master_gain = gain; |
| 909 | } |
| 910 | |
| 911 | void offload_transition_soft_volume_set_gain_2ch(struct soft_volume_params *vol, |
| 912 | int l_gain, int r_gain) |
| 913 | { |
| 914 | ALOGV("%s", __func__); |
| 915 | vol->left_gain = l_gain; |
| 916 | vol->right_gain = r_gain; |
| 917 | } |
| 918 | |
| 919 | int offload_transition_soft_volume_send_params(struct mixer_ctl *ctl, |
| 920 | struct soft_volume_params vol, |
| 921 | unsigned param_send_flags) |
| 922 | { |
| 923 | int param_values[128] = {0}; |
| 924 | int *p_param_values = param_values; |
| 925 | uint32_t i; |
| 926 | |
| 927 | ALOGV("%s", __func__); |
| 928 | *p_param_values++ = SOFT_VOLUME2_MODULE; |
| 929 | *p_param_values++ = 0; |
| 930 | *p_param_values++ = 0; /* num of commands*/ |
| 931 | if (param_send_flags & OFFLOAD_SEND_TRANSITION_SOFT_VOLUME_ENABLE_FLAG) { |
| 932 | *p_param_values++ = SOFT_VOLUME2_ENABLE; |
| 933 | *p_param_values++ = CONFIG_SET; |
| 934 | *p_param_values++ = 0; /* start offset if param size if greater than 128 */ |
| 935 | *p_param_values++ = SOFT_VOLUME2_ENABLE_PARAM_LEN; |
| 936 | *p_param_values++ = vol.enable_flag; |
| 937 | param_values[2] += 1; |
| 938 | } |
| 939 | if (param_send_flags & OFFLOAD_SEND_TRANSITION_SOFT_VOLUME_GAIN_MASTER) { |
| 940 | *p_param_values++ = SOFT_VOLUME2_GAIN_MASTER; |
| 941 | *p_param_values++ = CONFIG_SET; |
| 942 | *p_param_values++ = 0; /* start offset if param size if greater than 128 */ |
| 943 | *p_param_values++ = SOFT_VOLUME2_GAIN_MASTER_PARAM_LEN; |
| 944 | *p_param_values++ = vol.master_gain; |
| 945 | param_values[2] += 1; |
| 946 | } |
| 947 | if (param_send_flags & OFFLOAD_SEND_TRANSITION_SOFT_VOLUME_GAIN_2CH) { |
| 948 | *p_param_values++ = SOFT_VOLUME2_GAIN_2CH; |
| 949 | *p_param_values++ = CONFIG_SET; |
| 950 | *p_param_values++ = 0; /* start offset if param size if greater than 128 */ |
| 951 | *p_param_values++ = SOFT_VOLUME2_GAIN_2CH_PARAM_LEN; |
| 952 | *p_param_values++ = vol.left_gain; |
| 953 | *p_param_values++ = vol.right_gain; |
Subhash Chandra Bose Naripeddy | 3eedc00 | 2013-11-12 20:45:15 -0800 | [diff] [blame] | 954 | param_values[2] += 1; |
| 955 | } |
| 956 | |
| 957 | if (param_values[2] && ctl) |
| 958 | mixer_ctl_set_array(ctl, param_values, ARRAY_SIZE(param_values)); |
| 959 | |
| 960 | return 0; |
| 961 | } |
Alexy Joseph | d464f3b | 2014-11-18 16:14:41 -0800 | [diff] [blame] | 962 | |
| 963 | static int hpx_send_params(eff_mode_t mode, void *ctl, |
| 964 | unsigned param_send_flags) |
| 965 | { |
| 966 | int param_values[128] = {0}; |
| 967 | int *p_param_values = param_values; |
| 968 | uint32_t i; |
| 969 | |
| 970 | ALOGV("%s", __func__); |
Chaithanya Krishna Bacharaju | b9bf50f | 2015-04-09 16:26:36 +0530 | [diff] [blame] | 971 | if (!ctl) { |
| 972 | ALOGE("%s: ctl is NULL, return invalid", __func__); |
| 973 | return -EINVAL; |
| 974 | } |
| 975 | |
Alexy Joseph | d464f3b | 2014-11-18 16:14:41 -0800 | [diff] [blame] | 976 | if (param_send_flags & OFFLOAD_SEND_HPX_STATE_OFF) { |
| 977 | *p_param_values++ = DTS_EAGLE_MODULE_ENABLE; |
| 978 | *p_param_values++ = 0; /* hpx off*/ |
| 979 | } else if (param_send_flags & OFFLOAD_SEND_HPX_STATE_ON) { |
| 980 | *p_param_values++ = DTS_EAGLE_MODULE_ENABLE; |
| 981 | *p_param_values++ = 1; /* hpx on*/ |
| 982 | } |
| 983 | |
Chaithanya Krishna Bacharaju | b9bf50f | 2015-04-09 16:26:36 +0530 | [diff] [blame] | 984 | if (mode == OFFLOAD) |
Alexy Joseph | d464f3b | 2014-11-18 16:14:41 -0800 | [diff] [blame] | 985 | mixer_ctl_set_array(ctl, param_values, ARRAY_SIZE(param_values)); |
| 986 | else { |
| 987 | if (ioctl(*(int *)ctl, AUDIO_EFFECTS_SET_PP_PARAMS, param_values) < 0) |
| 988 | ALOGE("%s: sending h/w acc hpx state params fail[%d]", __func__, errno); |
| 989 | } |
| 990 | return 0; |
| 991 | } |
| 992 | |
| 993 | int offload_hpx_send_params(struct mixer_ctl *ctl, unsigned param_send_flags) |
| 994 | { |
| 995 | return hpx_send_params(OFFLOAD, (void *)ctl, param_send_flags); |
| 996 | } |
| 997 | |
| 998 | int hw_acc_hpx_send_params(int fd, unsigned param_send_flags) |
| 999 | { |
| 1000 | return hpx_send_params(HW_ACCELERATOR, (void *)&fd, param_send_flags); |
| 1001 | } |