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