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