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