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