Subhash Chandra Bose Naripeddy | 3eedc00 | 2013-11-12 20:45:15 -0800 | [diff] [blame] | 1 | /* |
wjiang | ca2685b | 2014-03-18 06:43:48 +0800 | [diff] [blame] | 2 | * Copyright (c) 2013-2014, The Linux Foundation. All rights reserved. |
Subhash Chandra Bose Naripeddy | 3eedc00 | 2013-11-12 20:45:15 -0800 | [diff] [blame] | 3 | |
| 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"); |
| 113 | ctl = NULL; |
| 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); |
Subhash Chandra Bose Naripeddy | 3eedc00 | 2013-11-12 20:45:15 -0800 | [diff] [blame] | 117 | if (!ctl) { |
| 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 | |
Subhash Chandra Bose Naripeddy | 3eedc00 | 2013-11-12 20:45:15 -0800 | [diff] [blame] | 238 | void offload_virtualizer_set_device(struct virtualizer_params *virtualizer, |
| 239 | uint32_t device) |
| 240 | { |
Dhananjay Kumar | 574f392 | 2014-03-25 17:41:44 +0530 | [diff] [blame] | 241 | ALOGVV("%s: device=0x%x", __func__, device); |
Subhash Chandra Bose Naripeddy | 3eedc00 | 2013-11-12 20:45:15 -0800 | [diff] [blame] | 242 | virtualizer->device = device; |
| 243 | } |
| 244 | |
| 245 | void offload_virtualizer_set_enable_flag(struct virtualizer_params *virtualizer, |
| 246 | bool enable) |
| 247 | { |
Dhananjay Kumar | 574f392 | 2014-03-25 17:41:44 +0530 | [diff] [blame] | 248 | ALOGVV("%s: enable=%d", __func__, (int)enable); |
Subhash Chandra Bose Naripeddy | 3eedc00 | 2013-11-12 20:45:15 -0800 | [diff] [blame] | 249 | virtualizer->enable_flag = enable; |
Jitendra Naruka | 1b6513f | 2014-11-22 19:34:13 -0800 | [diff] [blame] | 250 | |
| 251 | #ifdef DTS_EAGLE |
| 252 | update_effects_node(PCM_DEV_ID, EFFECT_TYPE_VIRT, EFFECT_ENABLE_PARAM, enable, EFFECT_NO_OP, EFFECT_NO_OP, EFFECT_NO_OP); |
| 253 | #endif |
Subhash Chandra Bose Naripeddy | 3eedc00 | 2013-11-12 20:45:15 -0800 | [diff] [blame] | 254 | } |
| 255 | |
| 256 | int offload_virtualizer_get_enable_flag(struct virtualizer_params *virtualizer) |
| 257 | { |
Dhananjay Kumar | 574f392 | 2014-03-25 17:41:44 +0530 | [diff] [blame] | 258 | ALOGVV("%s: enabled %d", __func__, (int)virtualizer->enable_flag); |
Subhash Chandra Bose Naripeddy | 3eedc00 | 2013-11-12 20:45:15 -0800 | [diff] [blame] | 259 | return virtualizer->enable_flag; |
| 260 | } |
| 261 | |
| 262 | void offload_virtualizer_set_strength(struct virtualizer_params *virtualizer, |
| 263 | int strength) |
| 264 | { |
Dhananjay Kumar | 574f392 | 2014-03-25 17:41:44 +0530 | [diff] [blame] | 265 | ALOGVV("%s: strength %d", __func__, strength); |
Subhash Chandra Bose Naripeddy | 3eedc00 | 2013-11-12 20:45:15 -0800 | [diff] [blame] | 266 | virtualizer->strength = strength; |
Jitendra Naruka | 1b6513f | 2014-11-22 19:34:13 -0800 | [diff] [blame] | 267 | |
| 268 | #ifdef DTS_EAGLE |
| 269 | update_effects_node(PCM_DEV_ID, EFFECT_TYPE_VIRT, EFFECT_SET_PARAM, EFFECT_NO_OP, strength, EFFECT_NO_OP, EFFECT_NO_OP); |
| 270 | #endif |
Subhash Chandra Bose Naripeddy | 3eedc00 | 2013-11-12 20:45:15 -0800 | [diff] [blame] | 271 | } |
| 272 | |
| 273 | void offload_virtualizer_set_out_type(struct virtualizer_params *virtualizer, |
| 274 | int out_type) |
| 275 | { |
Dhananjay Kumar | 574f392 | 2014-03-25 17:41:44 +0530 | [diff] [blame] | 276 | ALOGVV("%s: out_type %d", __func__, out_type); |
Subhash Chandra Bose Naripeddy | 3eedc00 | 2013-11-12 20:45:15 -0800 | [diff] [blame] | 277 | virtualizer->out_type = out_type; |
| 278 | } |
| 279 | |
| 280 | void offload_virtualizer_set_gain_adjust(struct virtualizer_params *virtualizer, |
| 281 | int gain_adjust) |
| 282 | { |
Dhananjay Kumar | 574f392 | 2014-03-25 17:41:44 +0530 | [diff] [blame] | 283 | ALOGVV("%s: gain %d", __func__, gain_adjust); |
Subhash Chandra Bose Naripeddy | 3eedc00 | 2013-11-12 20:45:15 -0800 | [diff] [blame] | 284 | virtualizer->gain_adjust = gain_adjust; |
| 285 | } |
| 286 | |
Subhash Chandra Bose Naripeddy | e40a7cd | 2014-06-03 19:42:41 -0700 | [diff] [blame] | 287 | static int virtualizer_send_params(eff_mode_t mode, void *ctl, |
| 288 | struct virtualizer_params *virtualizer, |
| 289 | unsigned param_send_flags) |
Subhash Chandra Bose Naripeddy | 3eedc00 | 2013-11-12 20:45:15 -0800 | [diff] [blame] | 290 | { |
| 291 | int param_values[128] = {0}; |
| 292 | int *p_param_values = param_values; |
| 293 | |
Dhananjay Kumar | 574f392 | 2014-03-25 17:41:44 +0530 | [diff] [blame] | 294 | ALOGV("%s: flags 0x%x", __func__, param_send_flags); |
Subhash Chandra Bose Naripeddy | 3eedc00 | 2013-11-12 20:45:15 -0800 | [diff] [blame] | 295 | *p_param_values++ = VIRTUALIZER_MODULE; |
Subhash Chandra Bose Naripeddy | e40a7cd | 2014-06-03 19:42:41 -0700 | [diff] [blame] | 296 | *p_param_values++ = virtualizer->device; |
Subhash Chandra Bose Naripeddy | 3eedc00 | 2013-11-12 20:45:15 -0800 | [diff] [blame] | 297 | *p_param_values++ = 0; /* num of commands*/ |
| 298 | if (param_send_flags & OFFLOAD_SEND_VIRTUALIZER_ENABLE_FLAG) { |
| 299 | *p_param_values++ = VIRTUALIZER_ENABLE; |
| 300 | *p_param_values++ = CONFIG_SET; |
| 301 | *p_param_values++ = 0; /* start offset if param size if greater than 128 */ |
| 302 | *p_param_values++ = VIRTUALIZER_ENABLE_PARAM_LEN; |
Subhash Chandra Bose Naripeddy | e40a7cd | 2014-06-03 19:42:41 -0700 | [diff] [blame] | 303 | *p_param_values++ = virtualizer->enable_flag; |
Subhash Chandra Bose Naripeddy | 3eedc00 | 2013-11-12 20:45:15 -0800 | [diff] [blame] | 304 | param_values[2] += 1; |
| 305 | } |
| 306 | if (param_send_flags & OFFLOAD_SEND_VIRTUALIZER_STRENGTH) { |
| 307 | *p_param_values++ = VIRTUALIZER_STRENGTH; |
| 308 | *p_param_values++ = CONFIG_SET; |
| 309 | *p_param_values++ = 0; /* start offset if param size if greater than 128 */ |
| 310 | *p_param_values++ = VIRTUALIZER_STRENGTH_PARAM_LEN; |
Subhash Chandra Bose Naripeddy | e40a7cd | 2014-06-03 19:42:41 -0700 | [diff] [blame] | 311 | *p_param_values++ = virtualizer->strength; |
Subhash Chandra Bose Naripeddy | 3eedc00 | 2013-11-12 20:45:15 -0800 | [diff] [blame] | 312 | param_values[2] += 1; |
| 313 | } |
| 314 | if (param_send_flags & OFFLOAD_SEND_VIRTUALIZER_OUT_TYPE) { |
| 315 | *p_param_values++ = VIRTUALIZER_OUT_TYPE; |
| 316 | *p_param_values++ = CONFIG_SET; |
| 317 | *p_param_values++ = 0; /* start offset if param size if greater than 128 */ |
| 318 | *p_param_values++ = VIRTUALIZER_OUT_TYPE_PARAM_LEN; |
Subhash Chandra Bose Naripeddy | e40a7cd | 2014-06-03 19:42:41 -0700 | [diff] [blame] | 319 | *p_param_values++ = virtualizer->out_type; |
Subhash Chandra Bose Naripeddy | 3eedc00 | 2013-11-12 20:45:15 -0800 | [diff] [blame] | 320 | param_values[2] += 1; |
| 321 | } |
| 322 | if (param_send_flags & OFFLOAD_SEND_VIRTUALIZER_GAIN_ADJUST) { |
| 323 | *p_param_values++ = VIRTUALIZER_GAIN_ADJUST; |
| 324 | *p_param_values++ = CONFIG_SET; |
| 325 | *p_param_values++ = 0; /* start offset if param size if greater than 128 */ |
| 326 | *p_param_values++ = VIRTUALIZER_GAIN_ADJUST_PARAM_LEN; |
Subhash Chandra Bose Naripeddy | e40a7cd | 2014-06-03 19:42:41 -0700 | [diff] [blame] | 327 | *p_param_values++ = virtualizer->gain_adjust; |
Subhash Chandra Bose Naripeddy | 3eedc00 | 2013-11-12 20:45:15 -0800 | [diff] [blame] | 328 | param_values[2] += 1; |
| 329 | } |
| 330 | |
Subhash Chandra Bose Naripeddy | e40a7cd | 2014-06-03 19:42:41 -0700 | [diff] [blame] | 331 | if ((mode == OFFLOAD) && param_values[2] && ctl) { |
| 332 | mixer_ctl_set_array((struct mixer_ctl *)ctl, param_values, |
| 333 | ARRAY_SIZE(param_values)); |
| 334 | } else if ((mode == HW_ACCELERATOR) && param_values[2] && |
| 335 | ctl && *(int *)ctl) { |
| 336 | if (ioctl(*(int *)ctl, AUDIO_EFFECTS_SET_PP_PARAMS, param_values) < 0) |
| 337 | ALOGE("%s: sending h/w acc effects params fail[%d]", __func__, errno); |
| 338 | } |
Subhash Chandra Bose Naripeddy | 3eedc00 | 2013-11-12 20:45:15 -0800 | [diff] [blame] | 339 | |
| 340 | return 0; |
| 341 | } |
| 342 | |
Subhash Chandra Bose Naripeddy | e40a7cd | 2014-06-03 19:42:41 -0700 | [diff] [blame] | 343 | int offload_virtualizer_send_params(struct mixer_ctl *ctl, |
| 344 | struct virtualizer_params *virtualizer, |
| 345 | unsigned param_send_flags) |
| 346 | { |
| 347 | return virtualizer_send_params(OFFLOAD, (void *)ctl, virtualizer, |
| 348 | param_send_flags); |
| 349 | } |
| 350 | |
| 351 | int hw_acc_virtualizer_send_params(int fd, |
| 352 | struct virtualizer_params *virtualizer, |
| 353 | unsigned param_send_flags) |
| 354 | { |
| 355 | return virtualizer_send_params(HW_ACCELERATOR, (void *)&fd, |
| 356 | virtualizer, param_send_flags); |
| 357 | } |
| 358 | |
Subhash Chandra Bose Naripeddy | 3eedc00 | 2013-11-12 20:45:15 -0800 | [diff] [blame] | 359 | void offload_eq_set_device(struct eq_params *eq, uint32_t device) |
| 360 | { |
Dhananjay Kumar | 574f392 | 2014-03-25 17:41:44 +0530 | [diff] [blame] | 361 | ALOGVV("%s: device 0x%x", __func__, device); |
Subhash Chandra Bose Naripeddy | 3eedc00 | 2013-11-12 20:45:15 -0800 | [diff] [blame] | 362 | eq->device = device; |
| 363 | } |
| 364 | |
| 365 | void offload_eq_set_enable_flag(struct eq_params *eq, bool enable) |
| 366 | { |
Dhananjay Kumar | 574f392 | 2014-03-25 17:41:44 +0530 | [diff] [blame] | 367 | ALOGVV("%s: enable=%d", __func__, (int)enable); |
Subhash Chandra Bose Naripeddy | 3eedc00 | 2013-11-12 20:45:15 -0800 | [diff] [blame] | 368 | eq->enable_flag = enable; |
Jitendra Naruka | 1b6513f | 2014-11-22 19:34:13 -0800 | [diff] [blame] | 369 | |
| 370 | #ifdef DTS_EAGLE |
| 371 | update_effects_node(PCM_DEV_ID, EFFECT_TYPE_EQ, EFFECT_ENABLE_PARAM, enable, EFFECT_NO_OP, EFFECT_NO_OP, EFFECT_NO_OP); |
| 372 | #endif |
Subhash Chandra Bose Naripeddy | 3eedc00 | 2013-11-12 20:45:15 -0800 | [diff] [blame] | 373 | } |
| 374 | |
| 375 | int offload_eq_get_enable_flag(struct eq_params *eq) |
| 376 | { |
Dhananjay Kumar | 574f392 | 2014-03-25 17:41:44 +0530 | [diff] [blame] | 377 | ALOGVV("%s: enabled=%d", __func__, (int)eq->enable_flag); |
Subhash Chandra Bose Naripeddy | 3eedc00 | 2013-11-12 20:45:15 -0800 | [diff] [blame] | 378 | return eq->enable_flag; |
| 379 | } |
| 380 | |
| 381 | void offload_eq_set_preset(struct eq_params *eq, int preset) |
| 382 | { |
Dhananjay Kumar | 574f392 | 2014-03-25 17:41:44 +0530 | [diff] [blame] | 383 | ALOGVV("%s: preset %d", __func__, preset); |
Subhash Chandra Bose Naripeddy | 3eedc00 | 2013-11-12 20:45:15 -0800 | [diff] [blame] | 384 | eq->config.preset_id = preset; |
| 385 | eq->config.eq_pregain = Q27_UNITY; |
| 386 | } |
| 387 | |
| 388 | void offload_eq_set_bands_level(struct eq_params *eq, int num_bands, |
| 389 | const uint16_t *band_freq_list, |
| 390 | int *band_gain_list) |
| 391 | { |
| 392 | int i; |
Dhananjay Kumar | 574f392 | 2014-03-25 17:41:44 +0530 | [diff] [blame] | 393 | ALOGVV("%s", __func__); |
Subhash Chandra Bose Naripeddy | 3eedc00 | 2013-11-12 20:45:15 -0800 | [diff] [blame] | 394 | eq->config.num_bands = num_bands; |
| 395 | for (i=0; i<num_bands; i++) { |
| 396 | eq->per_band_cfg[i].band_idx = i; |
| 397 | eq->per_band_cfg[i].filter_type = EQ_BAND_BOOST; |
| 398 | eq->per_band_cfg[i].freq_millihertz = band_freq_list[i] * 1000; |
| 399 | eq->per_band_cfg[i].gain_millibels = band_gain_list[i] * 100; |
| 400 | eq->per_band_cfg[i].quality_factor = Q8_UNITY; |
| 401 | } |
Jitendra Naruka | 1b6513f | 2014-11-22 19:34:13 -0800 | [diff] [blame] | 402 | |
| 403 | #ifdef DTS_EAGLE |
| 404 | update_effects_node(PCM_DEV_ID, EFFECT_TYPE_EQ, EFFECT_SET_PARAM, EFFECT_NO_OP, EFFECT_NO_OP, i, band_gain_list[i] * 100); |
| 405 | #endif |
Subhash Chandra Bose Naripeddy | 3eedc00 | 2013-11-12 20:45:15 -0800 | [diff] [blame] | 406 | } |
| 407 | |
Subhash Chandra Bose Naripeddy | e40a7cd | 2014-06-03 19:42:41 -0700 | [diff] [blame] | 408 | static int eq_send_params(eff_mode_t mode, void *ctl, struct eq_params *eq, |
| 409 | unsigned param_send_flags) |
Subhash Chandra Bose Naripeddy | 3eedc00 | 2013-11-12 20:45:15 -0800 | [diff] [blame] | 410 | { |
| 411 | int param_values[128] = {0}; |
| 412 | int *p_param_values = param_values; |
| 413 | uint32_t i; |
| 414 | |
Dhananjay Kumar | 574f392 | 2014-03-25 17:41:44 +0530 | [diff] [blame] | 415 | ALOGV("%s: flags 0x%x", __func__, param_send_flags); |
Subhash Chandra Bose Naripeddy | e40a7cd | 2014-06-03 19:42:41 -0700 | [diff] [blame] | 416 | if ((eq->config.preset_id < -1) || |
| 417 | ((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] | 418 | ALOGV("No Valid preset to set"); |
| 419 | return 0; |
| 420 | } |
| 421 | *p_param_values++ = EQ_MODULE; |
Subhash Chandra Bose Naripeddy | e40a7cd | 2014-06-03 19:42:41 -0700 | [diff] [blame] | 422 | *p_param_values++ = eq->device; |
Subhash Chandra Bose Naripeddy | 3eedc00 | 2013-11-12 20:45:15 -0800 | [diff] [blame] | 423 | *p_param_values++ = 0; /* num of commands*/ |
| 424 | if (param_send_flags & OFFLOAD_SEND_EQ_ENABLE_FLAG) { |
| 425 | *p_param_values++ = EQ_ENABLE; |
| 426 | *p_param_values++ = CONFIG_SET; |
| 427 | *p_param_values++ = 0; /* start offset if param size if greater than 128 */ |
| 428 | *p_param_values++ = EQ_ENABLE_PARAM_LEN; |
Subhash Chandra Bose Naripeddy | e40a7cd | 2014-06-03 19:42:41 -0700 | [diff] [blame] | 429 | *p_param_values++ = eq->enable_flag; |
Subhash Chandra Bose Naripeddy | 3eedc00 | 2013-11-12 20:45:15 -0800 | [diff] [blame] | 430 | param_values[2] += 1; |
| 431 | } |
| 432 | if (param_send_flags & OFFLOAD_SEND_EQ_PRESET) { |
| 433 | *p_param_values++ = EQ_CONFIG; |
| 434 | *p_param_values++ = CONFIG_SET; |
| 435 | *p_param_values++ = 0; /* start offset if param size if greater than 128 */ |
| 436 | *p_param_values++ = EQ_CONFIG_PARAM_LEN; |
Subhash Chandra Bose Naripeddy | e40a7cd | 2014-06-03 19:42:41 -0700 | [diff] [blame] | 437 | *p_param_values++ = eq->config.eq_pregain; |
Subhash Chandra Bose Naripeddy | 3eedc00 | 2013-11-12 20:45:15 -0800 | [diff] [blame] | 438 | *p_param_values++ = |
Subhash Chandra Bose Naripeddy | e40a7cd | 2014-06-03 19:42:41 -0700 | [diff] [blame] | 439 | 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] | 440 | *p_param_values++ = 0; |
| 441 | param_values[2] += 1; |
| 442 | } |
| 443 | if (param_send_flags & OFFLOAD_SEND_EQ_BANDS_LEVEL) { |
| 444 | *p_param_values++ = EQ_CONFIG; |
| 445 | *p_param_values++ = CONFIG_SET; |
| 446 | *p_param_values++ = 0; /* start offset if param size if greater than 128 */ |
| 447 | *p_param_values++ = EQ_CONFIG_PARAM_LEN + |
Subhash Chandra Bose Naripeddy | e40a7cd | 2014-06-03 19:42:41 -0700 | [diff] [blame] | 448 | eq->config.num_bands * EQ_CONFIG_PER_BAND_PARAM_LEN; |
| 449 | *p_param_values++ = eq->config.eq_pregain; |
Subhash Chandra Bose Naripeddy | 3eedc00 | 2013-11-12 20:45:15 -0800 | [diff] [blame] | 450 | *p_param_values++ = CUSTOM_OPENSL_PRESET; |
Subhash Chandra Bose Naripeddy | e40a7cd | 2014-06-03 19:42:41 -0700 | [diff] [blame] | 451 | *p_param_values++ = eq->config.num_bands; |
| 452 | for (i=0; i<eq->config.num_bands; i++) { |
| 453 | *p_param_values++ = eq->per_band_cfg[i].band_idx; |
| 454 | *p_param_values++ = eq->per_band_cfg[i].filter_type; |
| 455 | *p_param_values++ = eq->per_band_cfg[i].freq_millihertz; |
| 456 | *p_param_values++ = eq->per_band_cfg[i].gain_millibels; |
| 457 | *p_param_values++ = eq->per_band_cfg[i].quality_factor; |
Subhash Chandra Bose Naripeddy | 3eedc00 | 2013-11-12 20:45:15 -0800 | [diff] [blame] | 458 | } |
| 459 | param_values[2] += 1; |
| 460 | } |
| 461 | |
Subhash Chandra Bose Naripeddy | e40a7cd | 2014-06-03 19:42:41 -0700 | [diff] [blame] | 462 | if ((mode == OFFLOAD) && param_values[2] && ctl) { |
| 463 | mixer_ctl_set_array((struct mixer_ctl *)ctl, param_values, |
| 464 | ARRAY_SIZE(param_values)); |
| 465 | } else if ((mode == HW_ACCELERATOR) && param_values[2] && |
| 466 | ctl && *(int *)ctl) { |
| 467 | if (ioctl(*(int *)ctl, AUDIO_EFFECTS_SET_PP_PARAMS, param_values) < 0) |
| 468 | ALOGE("%s: sending h/w acc effects params fail[%d]", __func__, errno); |
| 469 | } |
Subhash Chandra Bose Naripeddy | 3eedc00 | 2013-11-12 20:45:15 -0800 | [diff] [blame] | 470 | |
| 471 | return 0; |
| 472 | } |
| 473 | |
Subhash Chandra Bose Naripeddy | e40a7cd | 2014-06-03 19:42:41 -0700 | [diff] [blame] | 474 | int offload_eq_send_params(struct mixer_ctl *ctl, struct eq_params *eq, |
| 475 | unsigned param_send_flags) |
| 476 | { |
| 477 | return eq_send_params(OFFLOAD, (void *)ctl, eq, param_send_flags); |
| 478 | } |
| 479 | |
| 480 | int hw_acc_eq_send_params(int fd, struct eq_params *eq, |
| 481 | unsigned param_send_flags) |
| 482 | { |
| 483 | return eq_send_params(HW_ACCELERATOR, (void *)&fd, eq, |
| 484 | param_send_flags); |
| 485 | } |
| 486 | |
Subhash Chandra Bose Naripeddy | 3eedc00 | 2013-11-12 20:45:15 -0800 | [diff] [blame] | 487 | void offload_reverb_set_device(struct reverb_params *reverb, uint32_t device) |
| 488 | { |
Dhananjay Kumar | 574f392 | 2014-03-25 17:41:44 +0530 | [diff] [blame] | 489 | ALOGVV("%s: device 0x%x", __func__, device); |
Subhash Chandra Bose Naripeddy | 3eedc00 | 2013-11-12 20:45:15 -0800 | [diff] [blame] | 490 | reverb->device = device; |
| 491 | } |
| 492 | |
| 493 | void offload_reverb_set_enable_flag(struct reverb_params *reverb, bool enable) |
| 494 | { |
Dhananjay Kumar | 574f392 | 2014-03-25 17:41:44 +0530 | [diff] [blame] | 495 | ALOGVV("%s: enable=%d", __func__, (int)enable); |
Subhash Chandra Bose Naripeddy | 3eedc00 | 2013-11-12 20:45:15 -0800 | [diff] [blame] | 496 | reverb->enable_flag = enable; |
| 497 | } |
| 498 | |
| 499 | int offload_reverb_get_enable_flag(struct reverb_params *reverb) |
| 500 | { |
Dhananjay Kumar | 574f392 | 2014-03-25 17:41:44 +0530 | [diff] [blame] | 501 | ALOGVV("%s: enabled=%d", __func__, reverb->enable_flag); |
Subhash Chandra Bose Naripeddy | 3eedc00 | 2013-11-12 20:45:15 -0800 | [diff] [blame] | 502 | return reverb->enable_flag; |
| 503 | } |
| 504 | |
| 505 | void offload_reverb_set_mode(struct reverb_params *reverb, int mode) |
| 506 | { |
Dhananjay Kumar | 574f392 | 2014-03-25 17:41:44 +0530 | [diff] [blame] | 507 | ALOGVV("%s", __func__); |
Subhash Chandra Bose Naripeddy | 3eedc00 | 2013-11-12 20:45:15 -0800 | [diff] [blame] | 508 | reverb->mode = mode; |
| 509 | } |
| 510 | |
| 511 | void offload_reverb_set_preset(struct reverb_params *reverb, int preset) |
| 512 | { |
Dhananjay Kumar | 574f392 | 2014-03-25 17:41:44 +0530 | [diff] [blame] | 513 | ALOGVV("%s: preset %d", __func__, preset); |
Subhash Chandra Bose Naripeddy | 3eedc00 | 2013-11-12 20:45:15 -0800 | [diff] [blame] | 514 | if (preset && (preset <= NUM_OSL_REVERB_PRESETS_SUPPORTED)) |
wjiang | ca2685b | 2014-03-18 06:43:48 +0800 | [diff] [blame] | 515 | 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] | 516 | } |
| 517 | |
| 518 | void offload_reverb_set_wet_mix(struct reverb_params *reverb, int wet_mix) |
| 519 | { |
Dhananjay Kumar | 574f392 | 2014-03-25 17:41:44 +0530 | [diff] [blame] | 520 | ALOGVV("%s: wet_mix %d", __func__, wet_mix); |
Subhash Chandra Bose Naripeddy | 3eedc00 | 2013-11-12 20:45:15 -0800 | [diff] [blame] | 521 | reverb->wet_mix = wet_mix; |
| 522 | } |
| 523 | |
| 524 | void offload_reverb_set_gain_adjust(struct reverb_params *reverb, |
| 525 | int gain_adjust) |
| 526 | { |
Dhananjay Kumar | 574f392 | 2014-03-25 17:41:44 +0530 | [diff] [blame] | 527 | ALOGVV("%s: gain %d", __func__, gain_adjust); |
Subhash Chandra Bose Naripeddy | 3eedc00 | 2013-11-12 20:45:15 -0800 | [diff] [blame] | 528 | reverb->gain_adjust = gain_adjust; |
| 529 | } |
| 530 | |
| 531 | void offload_reverb_set_room_level(struct reverb_params *reverb, int room_level) |
| 532 | { |
Dhananjay Kumar | 574f392 | 2014-03-25 17:41:44 +0530 | [diff] [blame] | 533 | ALOGVV("%s: level %d", __func__, room_level); |
Subhash Chandra Bose Naripeddy | 3eedc00 | 2013-11-12 20:45:15 -0800 | [diff] [blame] | 534 | reverb->room_level = room_level; |
| 535 | } |
| 536 | |
| 537 | void offload_reverb_set_room_hf_level(struct reverb_params *reverb, |
| 538 | int room_hf_level) |
| 539 | { |
Dhananjay Kumar | 574f392 | 2014-03-25 17:41:44 +0530 | [diff] [blame] | 540 | ALOGVV("%s: level %d", __func__, room_hf_level); |
Subhash Chandra Bose Naripeddy | 3eedc00 | 2013-11-12 20:45:15 -0800 | [diff] [blame] | 541 | reverb->room_hf_level = room_hf_level; |
| 542 | } |
| 543 | |
| 544 | void offload_reverb_set_decay_time(struct reverb_params *reverb, int decay_time) |
| 545 | { |
Dhananjay Kumar | 574f392 | 2014-03-25 17:41:44 +0530 | [diff] [blame] | 546 | ALOGVV("%s: decay time %d", __func__, decay_time); |
Subhash Chandra Bose Naripeddy | 3eedc00 | 2013-11-12 20:45:15 -0800 | [diff] [blame] | 547 | reverb->decay_time = decay_time; |
| 548 | } |
| 549 | |
| 550 | void offload_reverb_set_decay_hf_ratio(struct reverb_params *reverb, |
| 551 | int decay_hf_ratio) |
| 552 | { |
Dhananjay Kumar | 574f392 | 2014-03-25 17:41:44 +0530 | [diff] [blame] | 553 | ALOGVV("%s: decay_hf_ratio %d", __func__, decay_hf_ratio); |
Subhash Chandra Bose Naripeddy | 3eedc00 | 2013-11-12 20:45:15 -0800 | [diff] [blame] | 554 | reverb->decay_hf_ratio = decay_hf_ratio; |
| 555 | } |
| 556 | |
| 557 | void offload_reverb_set_reflections_level(struct reverb_params *reverb, |
| 558 | int reflections_level) |
| 559 | { |
Dhananjay Kumar | 574f392 | 2014-03-25 17:41:44 +0530 | [diff] [blame] | 560 | ALOGVV("%s: ref level %d", __func__, reflections_level); |
Subhash Chandra Bose Naripeddy | 3eedc00 | 2013-11-12 20:45:15 -0800 | [diff] [blame] | 561 | reverb->reflections_level = reflections_level; |
| 562 | } |
| 563 | |
| 564 | void offload_reverb_set_reflections_delay(struct reverb_params *reverb, |
| 565 | int reflections_delay) |
| 566 | { |
Dhananjay Kumar | 574f392 | 2014-03-25 17:41:44 +0530 | [diff] [blame] | 567 | ALOGVV("%s: ref delay", __func__, reflections_delay); |
Subhash Chandra Bose Naripeddy | 3eedc00 | 2013-11-12 20:45:15 -0800 | [diff] [blame] | 568 | reverb->reflections_delay = reflections_delay; |
| 569 | } |
| 570 | |
| 571 | void offload_reverb_set_reverb_level(struct reverb_params *reverb, |
| 572 | int reverb_level) |
| 573 | { |
Dhananjay Kumar | 574f392 | 2014-03-25 17:41:44 +0530 | [diff] [blame] | 574 | ALOGD("%s: reverb level %d", __func__, reverb_level); |
Subhash Chandra Bose Naripeddy | 3eedc00 | 2013-11-12 20:45:15 -0800 | [diff] [blame] | 575 | reverb->level = reverb_level; |
| 576 | } |
| 577 | |
| 578 | void offload_reverb_set_delay(struct reverb_params *reverb, int delay) |
| 579 | { |
Dhananjay Kumar | 574f392 | 2014-03-25 17:41:44 +0530 | [diff] [blame] | 580 | ALOGVV("%s: delay %d", __func__, delay); |
Subhash Chandra Bose Naripeddy | 3eedc00 | 2013-11-12 20:45:15 -0800 | [diff] [blame] | 581 | reverb->delay = delay; |
| 582 | } |
| 583 | |
| 584 | void offload_reverb_set_diffusion(struct reverb_params *reverb, int diffusion) |
| 585 | { |
Dhananjay Kumar | 574f392 | 2014-03-25 17:41:44 +0530 | [diff] [blame] | 586 | ALOGVV("%s: diffusion %d", __func__, diffusion); |
Subhash Chandra Bose Naripeddy | 3eedc00 | 2013-11-12 20:45:15 -0800 | [diff] [blame] | 587 | reverb->diffusion = diffusion; |
| 588 | } |
| 589 | |
| 590 | void offload_reverb_set_density(struct reverb_params *reverb, int density) |
| 591 | { |
Dhananjay Kumar | 574f392 | 2014-03-25 17:41:44 +0530 | [diff] [blame] | 592 | ALOGVV("%s: density %d", __func__, density); |
Subhash Chandra Bose Naripeddy | 3eedc00 | 2013-11-12 20:45:15 -0800 | [diff] [blame] | 593 | reverb->density = density; |
| 594 | } |
| 595 | |
Subhash Chandra Bose Naripeddy | e40a7cd | 2014-06-03 19:42:41 -0700 | [diff] [blame] | 596 | static int reverb_send_params(eff_mode_t mode, void *ctl, |
| 597 | struct reverb_params *reverb, |
| 598 | unsigned param_send_flags) |
Subhash Chandra Bose Naripeddy | 3eedc00 | 2013-11-12 20:45:15 -0800 | [diff] [blame] | 599 | { |
| 600 | int param_values[128] = {0}; |
| 601 | int *p_param_values = param_values; |
| 602 | |
Dhananjay Kumar | 574f392 | 2014-03-25 17:41:44 +0530 | [diff] [blame] | 603 | ALOGV("%s: flags 0x%x", __func__, param_send_flags); |
Subhash Chandra Bose Naripeddy | 3eedc00 | 2013-11-12 20:45:15 -0800 | [diff] [blame] | 604 | *p_param_values++ = REVERB_MODULE; |
Subhash Chandra Bose Naripeddy | e40a7cd | 2014-06-03 19:42:41 -0700 | [diff] [blame] | 605 | *p_param_values++ = reverb->device; |
Subhash Chandra Bose Naripeddy | 3eedc00 | 2013-11-12 20:45:15 -0800 | [diff] [blame] | 606 | *p_param_values++ = 0; /* num of commands*/ |
| 607 | |
| 608 | if (param_send_flags & OFFLOAD_SEND_REVERB_ENABLE_FLAG) { |
| 609 | *p_param_values++ = REVERB_ENABLE; |
| 610 | *p_param_values++ = CONFIG_SET; |
| 611 | *p_param_values++ = 0; /* start offset if param size if greater than 128 */ |
| 612 | *p_param_values++ = REVERB_ENABLE_PARAM_LEN; |
Subhash Chandra Bose Naripeddy | e40a7cd | 2014-06-03 19:42:41 -0700 | [diff] [blame] | 613 | *p_param_values++ = reverb->enable_flag; |
Subhash Chandra Bose Naripeddy | 3eedc00 | 2013-11-12 20:45:15 -0800 | [diff] [blame] | 614 | param_values[2] += 1; |
| 615 | } |
| 616 | if (param_send_flags & OFFLOAD_SEND_REVERB_MODE) { |
| 617 | *p_param_values++ = REVERB_MODE; |
| 618 | *p_param_values++ = CONFIG_SET; |
| 619 | *p_param_values++ = 0; /* start offset if param size if greater than 128 */ |
| 620 | *p_param_values++ = REVERB_MODE_PARAM_LEN; |
Subhash Chandra Bose Naripeddy | e40a7cd | 2014-06-03 19:42:41 -0700 | [diff] [blame] | 621 | *p_param_values++ = reverb->mode; |
Subhash Chandra Bose Naripeddy | 3eedc00 | 2013-11-12 20:45:15 -0800 | [diff] [blame] | 622 | param_values[2] += 1; |
| 623 | } |
| 624 | if (param_send_flags & OFFLOAD_SEND_REVERB_PRESET) { |
| 625 | *p_param_values++ = REVERB_PRESET; |
| 626 | *p_param_values++ = CONFIG_SET; |
| 627 | *p_param_values++ = 0; /* start offset if param size if greater than 128 */ |
| 628 | *p_param_values++ = REVERB_PRESET_PARAM_LEN; |
Subhash Chandra Bose Naripeddy | e40a7cd | 2014-06-03 19:42:41 -0700 | [diff] [blame] | 629 | *p_param_values++ = reverb->preset; |
Subhash Chandra Bose Naripeddy | 3eedc00 | 2013-11-12 20:45:15 -0800 | [diff] [blame] | 630 | param_values[2] += 1; |
| 631 | } |
| 632 | if (param_send_flags & OFFLOAD_SEND_REVERB_WET_MIX) { |
| 633 | *p_param_values++ = REVERB_WET_MIX; |
| 634 | *p_param_values++ = CONFIG_SET; |
| 635 | *p_param_values++ = 0; /* start offset if param size if greater than 128 */ |
| 636 | *p_param_values++ = REVERB_WET_MIX_PARAM_LEN; |
Subhash Chandra Bose Naripeddy | e40a7cd | 2014-06-03 19:42:41 -0700 | [diff] [blame] | 637 | *p_param_values++ = reverb->wet_mix; |
Subhash Chandra Bose Naripeddy | 3eedc00 | 2013-11-12 20:45:15 -0800 | [diff] [blame] | 638 | param_values[2] += 1; |
| 639 | } |
| 640 | if (param_send_flags & OFFLOAD_SEND_REVERB_GAIN_ADJUST) { |
| 641 | *p_param_values++ = REVERB_GAIN_ADJUST; |
| 642 | *p_param_values++ = CONFIG_SET; |
| 643 | *p_param_values++ = 0; /* start offset if param size if greater than 128 */ |
| 644 | *p_param_values++ = REVERB_GAIN_ADJUST_PARAM_LEN; |
Subhash Chandra Bose Naripeddy | e40a7cd | 2014-06-03 19:42:41 -0700 | [diff] [blame] | 645 | *p_param_values++ = reverb->gain_adjust; |
Subhash Chandra Bose Naripeddy | 3eedc00 | 2013-11-12 20:45:15 -0800 | [diff] [blame] | 646 | param_values[2] += 1; |
| 647 | } |
| 648 | if (param_send_flags & OFFLOAD_SEND_REVERB_ROOM_LEVEL) { |
| 649 | *p_param_values++ = REVERB_ROOM_LEVEL; |
| 650 | *p_param_values++ = CONFIG_SET; |
| 651 | *p_param_values++ = 0; /* start offset if param size if greater than 128 */ |
| 652 | *p_param_values++ = REVERB_ROOM_LEVEL_PARAM_LEN; |
Subhash Chandra Bose Naripeddy | e40a7cd | 2014-06-03 19:42:41 -0700 | [diff] [blame] | 653 | *p_param_values++ = reverb->room_level; |
Subhash Chandra Bose Naripeddy | 3eedc00 | 2013-11-12 20:45:15 -0800 | [diff] [blame] | 654 | param_values[2] += 1; |
| 655 | } |
| 656 | if (param_send_flags & OFFLOAD_SEND_REVERB_ROOM_HF_LEVEL) { |
| 657 | *p_param_values++ = REVERB_ROOM_HF_LEVEL; |
| 658 | *p_param_values++ = CONFIG_SET; |
| 659 | *p_param_values++ = 0; /* start offset if param size if greater than 128 */ |
| 660 | *p_param_values++ = REVERB_ROOM_HF_LEVEL_PARAM_LEN; |
Subhash Chandra Bose Naripeddy | e40a7cd | 2014-06-03 19:42:41 -0700 | [diff] [blame] | 661 | *p_param_values++ = reverb->room_hf_level; |
Subhash Chandra Bose Naripeddy | 3eedc00 | 2013-11-12 20:45:15 -0800 | [diff] [blame] | 662 | param_values[2] += 1; |
| 663 | } |
| 664 | if (param_send_flags & OFFLOAD_SEND_REVERB_DECAY_TIME) { |
| 665 | *p_param_values++ = REVERB_DECAY_TIME; |
| 666 | *p_param_values++ = CONFIG_SET; |
| 667 | *p_param_values++ = 0; /* start offset if param size if greater than 128 */ |
| 668 | *p_param_values++ = REVERB_DECAY_TIME_PARAM_LEN; |
Subhash Chandra Bose Naripeddy | e40a7cd | 2014-06-03 19:42:41 -0700 | [diff] [blame] | 669 | *p_param_values++ = reverb->decay_time; |
Subhash Chandra Bose Naripeddy | 3eedc00 | 2013-11-12 20:45:15 -0800 | [diff] [blame] | 670 | param_values[2] += 1; |
| 671 | } |
| 672 | if (param_send_flags & OFFLOAD_SEND_REVERB_DECAY_HF_RATIO) { |
| 673 | *p_param_values++ = REVERB_DECAY_HF_RATIO; |
| 674 | *p_param_values++ = CONFIG_SET; |
| 675 | *p_param_values++ = 0; /* start offset if param size if greater than 128 */ |
| 676 | *p_param_values++ = REVERB_DECAY_HF_RATIO_PARAM_LEN; |
Subhash Chandra Bose Naripeddy | e40a7cd | 2014-06-03 19:42:41 -0700 | [diff] [blame] | 677 | *p_param_values++ = reverb->decay_hf_ratio; |
Subhash Chandra Bose Naripeddy | 3eedc00 | 2013-11-12 20:45:15 -0800 | [diff] [blame] | 678 | param_values[2] += 1; |
| 679 | } |
| 680 | if (param_send_flags & OFFLOAD_SEND_REVERB_REFLECTIONS_LEVEL) { |
| 681 | *p_param_values++ = REVERB_REFLECTIONS_LEVEL; |
| 682 | *p_param_values++ = CONFIG_SET; |
| 683 | *p_param_values++ = 0; /* start offset if param size if greater than 128 */ |
| 684 | *p_param_values++ = REVERB_REFLECTIONS_LEVEL_PARAM_LEN; |
Subhash Chandra Bose Naripeddy | e40a7cd | 2014-06-03 19:42:41 -0700 | [diff] [blame] | 685 | *p_param_values++ = reverb->reflections_level; |
Subhash Chandra Bose Naripeddy | 3eedc00 | 2013-11-12 20:45:15 -0800 | [diff] [blame] | 686 | param_values[2] += 1; |
| 687 | } |
| 688 | if (param_send_flags & OFFLOAD_SEND_REVERB_REFLECTIONS_DELAY) { |
| 689 | *p_param_values++ = REVERB_REFLECTIONS_DELAY; |
| 690 | *p_param_values++ = CONFIG_SET; |
| 691 | *p_param_values++ = 0; /* start offset if param size if greater than 128 */ |
| 692 | *p_param_values++ = REVERB_REFLECTIONS_DELAY_PARAM_LEN; |
Subhash Chandra Bose Naripeddy | e40a7cd | 2014-06-03 19:42:41 -0700 | [diff] [blame] | 693 | *p_param_values++ = reverb->reflections_delay; |
Subhash Chandra Bose Naripeddy | 3eedc00 | 2013-11-12 20:45:15 -0800 | [diff] [blame] | 694 | param_values[2] += 1; |
| 695 | } |
| 696 | if (param_send_flags & OFFLOAD_SEND_REVERB_LEVEL) { |
| 697 | *p_param_values++ = REVERB_LEVEL; |
| 698 | *p_param_values++ = CONFIG_SET; |
| 699 | *p_param_values++ = 0; /* start offset if param size if greater than 128 */ |
| 700 | *p_param_values++ = REVERB_LEVEL_PARAM_LEN; |
Subhash Chandra Bose Naripeddy | e40a7cd | 2014-06-03 19:42:41 -0700 | [diff] [blame] | 701 | *p_param_values++ = reverb->level; |
Subhash Chandra Bose Naripeddy | 3eedc00 | 2013-11-12 20:45:15 -0800 | [diff] [blame] | 702 | param_values[2] += 1; |
| 703 | } |
| 704 | if (param_send_flags & OFFLOAD_SEND_REVERB_DELAY) { |
| 705 | *p_param_values++ = REVERB_DELAY; |
| 706 | *p_param_values++ = CONFIG_SET; |
| 707 | *p_param_values++ = 0; /* start offset if param size if greater than 128 */ |
| 708 | *p_param_values++ = REVERB_DELAY_PARAM_LEN; |
Subhash Chandra Bose Naripeddy | e40a7cd | 2014-06-03 19:42:41 -0700 | [diff] [blame] | 709 | *p_param_values++ = reverb->delay; |
Subhash Chandra Bose Naripeddy | 3eedc00 | 2013-11-12 20:45:15 -0800 | [diff] [blame] | 710 | param_values[2] += 1; |
| 711 | } |
| 712 | if (param_send_flags & OFFLOAD_SEND_REVERB_DIFFUSION) { |
| 713 | *p_param_values++ = REVERB_DIFFUSION; |
| 714 | *p_param_values++ = CONFIG_SET; |
| 715 | *p_param_values++ = 0; /* start offset if param size if greater than 128 */ |
| 716 | *p_param_values++ = REVERB_DIFFUSION_PARAM_LEN; |
Subhash Chandra Bose Naripeddy | e40a7cd | 2014-06-03 19:42:41 -0700 | [diff] [blame] | 717 | *p_param_values++ = reverb->diffusion; |
Subhash Chandra Bose Naripeddy | 3eedc00 | 2013-11-12 20:45:15 -0800 | [diff] [blame] | 718 | param_values[2] += 1; |
| 719 | } |
| 720 | if (param_send_flags & OFFLOAD_SEND_REVERB_DENSITY) { |
| 721 | *p_param_values++ = REVERB_DENSITY; |
| 722 | *p_param_values++ = CONFIG_SET; |
| 723 | *p_param_values++ = 0; /* start offset if param size if greater than 128 */ |
| 724 | *p_param_values++ = REVERB_DENSITY_PARAM_LEN; |
Subhash Chandra Bose Naripeddy | e40a7cd | 2014-06-03 19:42:41 -0700 | [diff] [blame] | 725 | *p_param_values++ = reverb->density; |
| 726 | param_values[2] += 1; |
| 727 | } |
| 728 | |
| 729 | if ((mode == OFFLOAD) && param_values[2] && ctl) { |
| 730 | mixer_ctl_set_array((struct mixer_ctl *)ctl, param_values, |
| 731 | ARRAY_SIZE(param_values)); |
| 732 | } else if ((mode == HW_ACCELERATOR) && param_values[2] && |
| 733 | ctl && *(int *)ctl) { |
| 734 | if (ioctl(*(int *)ctl, AUDIO_EFFECTS_SET_PP_PARAMS, param_values) < 0) |
| 735 | ALOGE("%s: sending h/w acc effects params fail[%d]", __func__, errno); |
| 736 | } |
| 737 | |
| 738 | return 0; |
| 739 | } |
| 740 | |
| 741 | int offload_reverb_send_params(struct mixer_ctl *ctl, |
| 742 | struct reverb_params *reverb, |
| 743 | unsigned param_send_flags) |
| 744 | { |
| 745 | return reverb_send_params(OFFLOAD, (void *)ctl, reverb, |
| 746 | param_send_flags); |
| 747 | } |
| 748 | |
| 749 | int hw_acc_reverb_send_params(int fd, struct reverb_params *reverb, |
| 750 | unsigned param_send_flags) |
| 751 | { |
| 752 | return reverb_send_params(HW_ACCELERATOR, (void *)&fd, |
| 753 | reverb, param_send_flags); |
| 754 | } |
| 755 | |
| 756 | void offload_soft_volume_set_enable(struct soft_volume_params *vol, bool enable) |
| 757 | { |
| 758 | ALOGV("%s", __func__); |
| 759 | vol->enable_flag = enable; |
| 760 | } |
| 761 | |
| 762 | void offload_soft_volume_set_gain_master(struct soft_volume_params *vol, int gain) |
| 763 | { |
| 764 | ALOGV("%s", __func__); |
| 765 | vol->master_gain = gain; |
| 766 | } |
| 767 | |
| 768 | void offload_soft_volume_set_gain_2ch(struct soft_volume_params *vol, |
| 769 | int l_gain, int r_gain) |
| 770 | { |
| 771 | ALOGV("%s", __func__); |
| 772 | vol->left_gain = l_gain; |
| 773 | vol->right_gain = r_gain; |
| 774 | } |
| 775 | |
| 776 | int offload_soft_volume_send_params(struct mixer_ctl *ctl, |
| 777 | struct soft_volume_params vol, |
| 778 | unsigned param_send_flags) |
| 779 | { |
| 780 | int param_values[128] = {0}; |
| 781 | int *p_param_values = param_values; |
| 782 | uint32_t i; |
| 783 | |
| 784 | ALOGV("%s", __func__); |
| 785 | *p_param_values++ = SOFT_VOLUME_MODULE; |
| 786 | *p_param_values++ = 0; |
| 787 | *p_param_values++ = 0; /* num of commands*/ |
| 788 | if (param_send_flags & OFFLOAD_SEND_SOFT_VOLUME_ENABLE_FLAG) { |
| 789 | *p_param_values++ = SOFT_VOLUME_ENABLE; |
| 790 | *p_param_values++ = CONFIG_SET; |
| 791 | *p_param_values++ = 0; /* start offset if param size if greater than 128 */ |
| 792 | *p_param_values++ = SOFT_VOLUME_ENABLE_PARAM_LEN; |
| 793 | *p_param_values++ = vol.enable_flag; |
| 794 | param_values[2] += 1; |
| 795 | } |
| 796 | if (param_send_flags & OFFLOAD_SEND_SOFT_VOLUME_GAIN_MASTER) { |
| 797 | *p_param_values++ = SOFT_VOLUME_GAIN_MASTER; |
| 798 | *p_param_values++ = CONFIG_SET; |
| 799 | *p_param_values++ = 0; /* start offset if param size if greater than 128 */ |
| 800 | *p_param_values++ = SOFT_VOLUME_GAIN_MASTER_PARAM_LEN; |
| 801 | *p_param_values++ = vol.master_gain; |
| 802 | param_values[2] += 1; |
| 803 | } |
| 804 | if (param_send_flags & OFFLOAD_SEND_SOFT_VOLUME_GAIN_2CH) { |
| 805 | *p_param_values++ = SOFT_VOLUME_GAIN_2CH; |
| 806 | *p_param_values++ = CONFIG_SET; |
| 807 | *p_param_values++ = 0; /* start offset if param size if greater than 128 */ |
| 808 | *p_param_values++ = SOFT_VOLUME_GAIN_2CH_PARAM_LEN; |
| 809 | *p_param_values++ = vol.left_gain; |
| 810 | *p_param_values++ = vol.right_gain; |
| 811 | param_values[2] += 1; |
| 812 | } |
| 813 | |
| 814 | if (param_values[2] && ctl) |
| 815 | mixer_ctl_set_array(ctl, param_values, ARRAY_SIZE(param_values)); |
| 816 | |
| 817 | return 0; |
| 818 | } |
| 819 | |
| 820 | void offload_transition_soft_volume_set_enable(struct soft_volume_params *vol, |
| 821 | bool enable) |
| 822 | { |
| 823 | ALOGV("%s", __func__); |
| 824 | vol->enable_flag = enable; |
| 825 | } |
| 826 | |
| 827 | void offload_transition_soft_volume_set_gain_master(struct soft_volume_params *vol, |
| 828 | int gain) |
| 829 | { |
| 830 | ALOGV("%s", __func__); |
| 831 | vol->master_gain = gain; |
| 832 | } |
| 833 | |
| 834 | void offload_transition_soft_volume_set_gain_2ch(struct soft_volume_params *vol, |
| 835 | int l_gain, int r_gain) |
| 836 | { |
| 837 | ALOGV("%s", __func__); |
| 838 | vol->left_gain = l_gain; |
| 839 | vol->right_gain = r_gain; |
| 840 | } |
| 841 | |
| 842 | int offload_transition_soft_volume_send_params(struct mixer_ctl *ctl, |
| 843 | struct soft_volume_params vol, |
| 844 | unsigned param_send_flags) |
| 845 | { |
| 846 | int param_values[128] = {0}; |
| 847 | int *p_param_values = param_values; |
| 848 | uint32_t i; |
| 849 | |
| 850 | ALOGV("%s", __func__); |
| 851 | *p_param_values++ = SOFT_VOLUME2_MODULE; |
| 852 | *p_param_values++ = 0; |
| 853 | *p_param_values++ = 0; /* num of commands*/ |
| 854 | if (param_send_flags & OFFLOAD_SEND_TRANSITION_SOFT_VOLUME_ENABLE_FLAG) { |
| 855 | *p_param_values++ = SOFT_VOLUME2_ENABLE; |
| 856 | *p_param_values++ = CONFIG_SET; |
| 857 | *p_param_values++ = 0; /* start offset if param size if greater than 128 */ |
| 858 | *p_param_values++ = SOFT_VOLUME2_ENABLE_PARAM_LEN; |
| 859 | *p_param_values++ = vol.enable_flag; |
| 860 | param_values[2] += 1; |
| 861 | } |
| 862 | if (param_send_flags & OFFLOAD_SEND_TRANSITION_SOFT_VOLUME_GAIN_MASTER) { |
| 863 | *p_param_values++ = SOFT_VOLUME2_GAIN_MASTER; |
| 864 | *p_param_values++ = CONFIG_SET; |
| 865 | *p_param_values++ = 0; /* start offset if param size if greater than 128 */ |
| 866 | *p_param_values++ = SOFT_VOLUME2_GAIN_MASTER_PARAM_LEN; |
| 867 | *p_param_values++ = vol.master_gain; |
| 868 | param_values[2] += 1; |
| 869 | } |
| 870 | if (param_send_flags & OFFLOAD_SEND_TRANSITION_SOFT_VOLUME_GAIN_2CH) { |
| 871 | *p_param_values++ = SOFT_VOLUME2_GAIN_2CH; |
| 872 | *p_param_values++ = CONFIG_SET; |
| 873 | *p_param_values++ = 0; /* start offset if param size if greater than 128 */ |
| 874 | *p_param_values++ = SOFT_VOLUME2_GAIN_2CH_PARAM_LEN; |
| 875 | *p_param_values++ = vol.left_gain; |
| 876 | *p_param_values++ = vol.right_gain; |
Subhash Chandra Bose Naripeddy | 3eedc00 | 2013-11-12 20:45:15 -0800 | [diff] [blame] | 877 | param_values[2] += 1; |
| 878 | } |
| 879 | |
| 880 | if (param_values[2] && ctl) |
| 881 | mixer_ctl_set_array(ctl, param_values, ARRAY_SIZE(param_values)); |
| 882 | |
| 883 | return 0; |
| 884 | } |
Alexy Joseph | d464f3b | 2014-11-18 16:14:41 -0800 | [diff] [blame^] | 885 | |
| 886 | static int hpx_send_params(eff_mode_t mode, void *ctl, |
| 887 | unsigned param_send_flags) |
| 888 | { |
| 889 | int param_values[128] = {0}; |
| 890 | int *p_param_values = param_values; |
| 891 | uint32_t i; |
| 892 | |
| 893 | ALOGV("%s", __func__); |
| 894 | if (param_send_flags & OFFLOAD_SEND_HPX_STATE_OFF) { |
| 895 | *p_param_values++ = DTS_EAGLE_MODULE_ENABLE; |
| 896 | *p_param_values++ = 0; /* hpx off*/ |
| 897 | } else if (param_send_flags & OFFLOAD_SEND_HPX_STATE_ON) { |
| 898 | *p_param_values++ = DTS_EAGLE_MODULE_ENABLE; |
| 899 | *p_param_values++ = 1; /* hpx on*/ |
| 900 | } |
| 901 | |
| 902 | if ((mode == OFFLOAD) && ctl) |
| 903 | mixer_ctl_set_array(ctl, param_values, ARRAY_SIZE(param_values)); |
| 904 | else { |
| 905 | if (ioctl(*(int *)ctl, AUDIO_EFFECTS_SET_PP_PARAMS, param_values) < 0) |
| 906 | ALOGE("%s: sending h/w acc hpx state params fail[%d]", __func__, errno); |
| 907 | } |
| 908 | return 0; |
| 909 | } |
| 910 | |
| 911 | int offload_hpx_send_params(struct mixer_ctl *ctl, unsigned param_send_flags) |
| 912 | { |
| 913 | return hpx_send_params(OFFLOAD, (void *)ctl, param_send_flags); |
| 914 | } |
| 915 | |
| 916 | int hw_acc_hpx_send_params(int fd, unsigned param_send_flags) |
| 917 | { |
| 918 | return hpx_send_params(HW_ACCELERATOR, (void *)&fd, param_send_flags); |
| 919 | } |