Subhash Chandra Bose Naripeddy | 7690c56 | 2013-12-14 00:34:53 -0800 | [diff] [blame] | 1 | /* |
Leena Winterrowd | f98e42f | 2016-01-26 13:47:36 -0800 | [diff] [blame^] | 2 | * Copyright (c) 2011-2016, The Linux Foundation. All rights reserved. |
Subhash Chandra Bose Naripeddy | 7690c56 | 2013-12-14 00:34:53 -0800 | [diff] [blame] | 3 | * Not a Contribution. |
| 4 | * |
| 5 | * Copyright (C) 2010 The Android Open Source Project |
| 6 | * |
| 7 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 8 | * you may not use this file except in compliance with the License. |
| 9 | * You may obtain a copy of the License at |
| 10 | * |
| 11 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 12 | * |
| 13 | * Unless required by applicable law or agreed to in writing, software |
| 14 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 15 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 16 | * See the License for the specific language governing permissions and |
| 17 | * limitations under the License. |
| 18 | */ |
| 19 | |
| 20 | #define LOG_TAG "audio_hw_dolby" |
Ashish Jain | 8ec5047 | 2014-10-16 13:56:28 +0530 | [diff] [blame] | 21 | //#define LOG_NDEBUG 0 |
| 22 | //#define LOG_NDDEBUG 0 |
Subhash Chandra Bose Naripeddy | 7690c56 | 2013-12-14 00:34:53 -0800 | [diff] [blame] | 23 | #include <errno.h> |
| 24 | #include <cutils/properties.h> |
| 25 | #include <stdlib.h> |
| 26 | #include <dlfcn.h> |
| 27 | #include <cutils/str_parms.h> |
| 28 | #include <cutils/log.h> |
| 29 | |
| 30 | #include "audio_hw.h" |
| 31 | #include "platform.h" |
| 32 | #include "platform_api.h" |
| 33 | #include "audio_extn.h" |
| 34 | #include "sound/compress_params.h" |
Ashish Jain | edb6a91 | 2014-10-16 13:56:28 +0530 | [diff] [blame] | 35 | #include "sound/devdep_params.h" |
Subhash Chandra Bose Naripeddy | 7690c56 | 2013-12-14 00:34:53 -0800 | [diff] [blame] | 36 | |
| 37 | #ifdef DS1_DOLBY_DDP_ENABLED |
| 38 | |
| 39 | #define AUDIO_PARAMETER_DDP_DEV "ddp_device" |
| 40 | #define AUDIO_PARAMETER_DDP_CH_CAP "ddp_chancap" |
| 41 | #define AUDIO_PARAMETER_DDP_MAX_OUT_CHAN "ddp_maxoutchan" |
| 42 | #define AUDIO_PARAMETER_DDP_OUT_MODE "ddp_outmode" |
| 43 | #define AUDIO_PARAMETER_DDP_OUT_LFE_ON "ddp_outlfeon" |
| 44 | #define AUDIO_PARAMETER_DDP_COMP_MODE "ddp_compmode" |
| 45 | #define AUDIO_PARAMETER_DDP_STEREO_MODE "ddp_stereomode" |
| 46 | |
| 47 | #define PARAM_ID_MAX_OUTPUT_CHANNELS 0x00010DE2 |
| 48 | #define PARAM_ID_CTL_RUNNING_MODE 0x0 |
| 49 | #define PARAM_ID_CTL_ERROR_CONCEAL 0x00010DE3 |
| 50 | #define PARAM_ID_CTL_ERROR_MAX_RPTS 0x00010DE4 |
| 51 | #define PARAM_ID_CNV_ERROR_CONCEAL 0x00010DE5 |
| 52 | #define PARAM_ID_CTL_SUBSTREAM_SELECT 0x00010DE6 |
| 53 | #define PARAM_ID_CTL_INPUT_MODE 0x0 |
| 54 | #define PARAM_ID_OUT_CTL_OUTMODE 0x00010DE0 |
| 55 | #define PARAM_ID_OUT_CTL_OUTLFE_ON 0x00010DE1 |
| 56 | #define PARAM_ID_OUT_CTL_COMPMODE 0x00010D74 |
| 57 | #define PARAM_ID_OUT_CTL_STEREO_MODE 0x00010D76 |
| 58 | #define PARAM_ID_OUT_CTL_DUAL_MODE 0x00010D75 |
| 59 | #define PARAM_ID_OUT_CTL_DRCSCALE_HIGH 0x00010D7A |
| 60 | #define PARAM_ID_OUT_CTL_DRCSCALE_LOW 0x00010D79 |
| 61 | #define PARAM_ID_OUT_CTL_OUT_PCMSCALE 0x00010D78 |
| 62 | #define PARAM_ID_OUT_CTL_MDCT_BANDLIMIT 0x00010DE7 |
| 63 | #define PARAM_ID_OUT_CTL_DRC_SUPPRESS 0x00010DE8 |
| 64 | |
| 65 | /* DS1-DDP Endp Params */ |
| 66 | #define DDP_ENDP_NUM_PARAMS 17 |
Mingming Yin | 0acba99 | 2014-06-02 22:38:35 -0700 | [diff] [blame] | 67 | #define DDP_ENDP_NUM_DEVICES 21 |
Subhash Chandra Bose Naripeddy | 7690c56 | 2013-12-14 00:34:53 -0800 | [diff] [blame] | 68 | static int ddp_endp_params_id[DDP_ENDP_NUM_PARAMS] = { |
| 69 | PARAM_ID_MAX_OUTPUT_CHANNELS, PARAM_ID_CTL_RUNNING_MODE, |
| 70 | PARAM_ID_CTL_ERROR_CONCEAL, PARAM_ID_CTL_ERROR_MAX_RPTS, |
| 71 | PARAM_ID_CNV_ERROR_CONCEAL, PARAM_ID_CTL_SUBSTREAM_SELECT, |
| 72 | PARAM_ID_CTL_INPUT_MODE, PARAM_ID_OUT_CTL_OUTMODE, |
| 73 | PARAM_ID_OUT_CTL_OUTLFE_ON, PARAM_ID_OUT_CTL_COMPMODE, |
| 74 | PARAM_ID_OUT_CTL_STEREO_MODE, PARAM_ID_OUT_CTL_DUAL_MODE, |
| 75 | PARAM_ID_OUT_CTL_DRCSCALE_HIGH, PARAM_ID_OUT_CTL_DRCSCALE_LOW, |
| 76 | PARAM_ID_OUT_CTL_OUT_PCMSCALE, PARAM_ID_OUT_CTL_MDCT_BANDLIMIT, |
| 77 | PARAM_ID_OUT_CTL_DRC_SUPPRESS |
| 78 | }; |
| 79 | |
| 80 | static struct ddp_endp_params { |
| 81 | int device; |
| 82 | int dev_ch_cap; |
| 83 | int param_val[DDP_ENDP_NUM_PARAMS]; |
| 84 | bool is_param_valid[DDP_ENDP_NUM_PARAMS]; |
| 85 | } ddp_endp_params[DDP_ENDP_NUM_DEVICES] = { |
| 86 | {AUDIO_DEVICE_OUT_EARPIECE, 2, |
| 87 | {8, 0, 0, 0, 0, 0, 0, 21, 1, 6, 0, 0, 0, 0, 0, 0, 0}, |
| 88 | {1, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0 } }, |
| 89 | {AUDIO_DEVICE_OUT_SPEAKER, 2, |
| 90 | {8, 0, 0, 0, 0, 0, 0, 21, 1, 6, 0, 0, 0, 0, 0, 0, 0}, |
| 91 | {1, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0} }, |
| 92 | {AUDIO_DEVICE_OUT_WIRED_HEADSET, 2, |
| 93 | {8, 0, 0, 0, 0, 0, 0, 21, 1, 6, 0, 0, 0, 0, 0, 0, 0}, |
| 94 | {1, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0} }, |
| 95 | {AUDIO_DEVICE_OUT_WIRED_HEADPHONE, 2, |
| 96 | {8, 0, 0, 0, 0, 0, 0, 21, 1, 6, 0, 0, 0, 0, 0, 0, 0}, |
| 97 | {1, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0} }, |
| 98 | {AUDIO_DEVICE_OUT_BLUETOOTH_SCO, 2, |
| 99 | {8, 0, 0, 0, 0, 0, 0, 21, 1, 6, 0, 0, 0, 0, 0, 0, 0}, |
| 100 | {1, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0} }, |
| 101 | {AUDIO_DEVICE_OUT_BLUETOOTH_SCO_HEADSET, 2, |
| 102 | {8, 0, 0, 0, 0, 0, 0, 21, 1, 6, 0, 0, 0, 0, 0, 0, 0}, |
| 103 | {1, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0} }, |
| 104 | {AUDIO_DEVICE_OUT_BLUETOOTH_SCO_CARKIT, 2, |
| 105 | {8, 0, 0, 0, 0, 0, 0, 21, 1, 6, 0, 0, 0, 0, 0, 0, 0}, |
| 106 | {1, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0} }, |
| 107 | {AUDIO_DEVICE_OUT_BLUETOOTH_A2DP, 2, |
| 108 | {8, 0, 0, 0, 0, 0, 0, 21, 1, 6, 0, 0, 0, 0, 0, 0, 0}, |
| 109 | {1, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0} }, |
| 110 | {AUDIO_DEVICE_OUT_BLUETOOTH_A2DP_HEADPHONES, 2, |
| 111 | {8, 0, 0, 0, 0, 0, 0, 21, 1, 6, 0, 0, 0, 0, 0, 0, 0}, |
| 112 | {1, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0} }, |
| 113 | {AUDIO_DEVICE_OUT_BLUETOOTH_A2DP_SPEAKER, 2, |
| 114 | {8, 0, 0, 0, 0, 0, 0, 21, 1, 6, 0, 0, 0, 0, 0, 0, 0}, |
| 115 | {1, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0} }, |
| 116 | {AUDIO_DEVICE_OUT_AUX_DIGITAL, 2, |
| 117 | {8, 0, 0, 0, 0, 0, 0, 21, 1, 2, 0, 0, 0, 0, 0, 0, 0}, |
| 118 | {1, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0} }, |
| 119 | {AUDIO_DEVICE_OUT_AUX_DIGITAL, 6, |
| 120 | {8, 0, 0, 0, 0, 0, 0, 21, 1, 2, 0, 0, 0, 0, 0, 0, 0}, |
| 121 | {1, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0} }, |
| 122 | {AUDIO_DEVICE_OUT_AUX_DIGITAL, 8, |
| 123 | {8, 0, 0, 0, 0, 0, 0, 21, 1, 2, 0, 0, 0, 0, 0, 0, 0}, |
| 124 | {1, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0} }, |
| 125 | {AUDIO_DEVICE_OUT_ANLG_DOCK_HEADSET, 2, |
| 126 | {8, 0, 0, 0, 0, 0, 0, 21, 1, 6, 0, 0, 0, 0, 0, 0, 0}, |
| 127 | {1, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0} }, |
| 128 | {AUDIO_DEVICE_OUT_DGTL_DOCK_HEADSET, 2, |
| 129 | {8, 0, 0, 0, 0, 0, 0, 21, 1, 6, 0, 0, 0, 0, 0, 0, 0}, |
| 130 | {1, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0} }, |
| 131 | {AUDIO_DEVICE_OUT_USB_ACCESSORY, 2, |
| 132 | {8, 0, 0, 0, 0, 0, 0, 21, 1, 6, 0, 0, 0, 0, 0, 0, 0}, |
| 133 | {1, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0} }, |
| 134 | {AUDIO_DEVICE_OUT_USB_DEVICE, 2, |
| 135 | {8, 0, 0, 0, 0, 0, 0, 21, 1, 6, 0, 0, 0, 0, 0, 0, 0}, |
| 136 | {1, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0} }, |
| 137 | {AUDIO_DEVICE_OUT_FM, 2, |
| 138 | {8, 0, 0, 0, 0, 0, 0, 21, 1, 6, 0, 0, 0, 0, 0, 0, 0}, |
| 139 | {1, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0} }, |
| 140 | {AUDIO_DEVICE_OUT_FM_TX, 2, |
| 141 | {8, 0, 0, 0, 0, 0, 0, 21, 1, 6, 0, 0, 0, 0, 0, 0, 0}, |
| 142 | {1, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0} }, |
Subhash Chandra Bose Naripeddy | 7690c56 | 2013-12-14 00:34:53 -0800 | [diff] [blame] | 143 | {AUDIO_DEVICE_OUT_PROXY, 2, |
Krishnankutty Kolathappilly | 0b2de1c | 2014-02-14 14:45:49 -0800 | [diff] [blame] | 144 | {8, 0, 0, 0, 0, 0, 0, 21, 1, 2, 0, 0, 0, 0, 0, 0, 0}, |
| 145 | {1, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0} }, |
| 146 | {AUDIO_DEVICE_OUT_PROXY, 6, |
| 147 | {8, 0, 0, 0, 0, 0, 0, 21, 1, 2, 0, 0, 0, 0, 0, 0, 0}, |
Subhash Chandra Bose Naripeddy | 7690c56 | 2013-12-14 00:34:53 -0800 | [diff] [blame] | 148 | {1, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0} }, |
| 149 | }; |
| 150 | |
| 151 | int update_ddp_endp_table(int device, int dev_ch_cap, int param_id, |
| 152 | int param_val) |
| 153 | { |
| 154 | int idx = 0; |
| 155 | int param_idx = 0; |
| 156 | ALOGV("%s: dev 0x%x dev_ch_cap %d param_id 0x%x param_val %d", |
| 157 | __func__, device, dev_ch_cap , param_id, param_val); |
| 158 | |
| 159 | for(idx=0; idx<DDP_ENDP_NUM_DEVICES; idx++) { |
| 160 | if(ddp_endp_params[idx].device == device) { |
| 161 | if(ddp_endp_params[idx].dev_ch_cap == dev_ch_cap) { |
| 162 | break; |
| 163 | } |
| 164 | } |
| 165 | } |
| 166 | |
| 167 | if(idx>=DDP_ENDP_NUM_DEVICES) { |
| 168 | ALOGE("%s: device not available in DDP endp config table", __func__); |
| 169 | return -EINVAL; |
| 170 | } |
| 171 | |
| 172 | for(param_idx=0; param_idx<DDP_ENDP_NUM_PARAMS; param_idx++) { |
| 173 | if (ddp_endp_params_id[param_idx] == param_id) { |
| 174 | break; |
| 175 | } |
| 176 | } |
| 177 | |
| 178 | if(param_idx>=DDP_ENDP_NUM_PARAMS) { |
| 179 | ALOGE("param not available in DDP endp config table"); |
| 180 | return -EINVAL; |
| 181 | } |
| 182 | |
| 183 | ALOGV("ddp_endp_params[%d].param_val[%d] = %d", idx, param_idx, param_val); |
| 184 | ddp_endp_params[idx].param_val[param_idx] = param_val; |
| 185 | return 0; |
| 186 | } |
| 187 | |
| 188 | void send_ddp_endp_params_stream(struct stream_out *out, |
| 189 | int device, int dev_ch_cap, |
Ravi Kumar Alamanda | bdf1416 | 2014-09-05 16:14:17 -0700 | [diff] [blame] | 190 | bool set_cache __unused) |
Subhash Chandra Bose Naripeddy | 7690c56 | 2013-12-14 00:34:53 -0800 | [diff] [blame] | 191 | { |
| 192 | int idx, i; |
| 193 | int ddp_endp_params_data[2*DDP_ENDP_NUM_PARAMS + 1]; |
| 194 | int length = 0; |
| 195 | for(idx=0; idx<DDP_ENDP_NUM_DEVICES; idx++) { |
| 196 | if(ddp_endp_params[idx].device & device) { |
| 197 | if(ddp_endp_params[idx].dev_ch_cap == dev_ch_cap) { |
| 198 | break; |
| 199 | } |
| 200 | } |
| 201 | } |
| 202 | if(idx>=DDP_ENDP_NUM_DEVICES) { |
| 203 | ALOGE("device not available in DDP endp config table"); |
| 204 | return; |
| 205 | } |
| 206 | |
| 207 | length += 1; /* offset 0 is for num of parameter. increase offset by 1 */ |
| 208 | for (i=0; i<DDP_ENDP_NUM_PARAMS; i++) { |
| 209 | if(ddp_endp_params[idx].is_param_valid[i]) { |
| 210 | ddp_endp_params_data[length++] = ddp_endp_params_id[i]; |
| 211 | ddp_endp_params_data[length++] = ddp_endp_params[idx].param_val[i]; |
| 212 | } |
| 213 | } |
| 214 | ddp_endp_params_data[0] = (length-1)/2; |
| 215 | if(length) { |
| 216 | char mixer_ctl_name[128]; |
| 217 | struct audio_device *adev = out->dev; |
| 218 | struct mixer_ctl *ctl; |
| 219 | int pcm_device_id = platform_get_pcm_device_id(out->usecase, |
| 220 | PCM_PLAYBACK); |
| 221 | snprintf(mixer_ctl_name, sizeof(mixer_ctl_name), |
| 222 | "Audio Stream %d Dec Params", pcm_device_id); |
| 223 | ctl = mixer_get_ctl_by_name(adev->mixer, mixer_ctl_name); |
| 224 | if (!ctl) { |
| 225 | ALOGE("%s: Could not get ctl for mixer cmd - %s", |
| 226 | __func__, mixer_ctl_name); |
| 227 | return; |
| 228 | } |
| 229 | mixer_ctl_set_array(ctl, ddp_endp_params_data, length); |
| 230 | } |
| 231 | return; |
| 232 | } |
| 233 | |
| 234 | void send_ddp_endp_params(struct audio_device *adev, |
| 235 | int ddp_dev, int dev_ch_cap) |
| 236 | { |
| 237 | struct listnode *node; |
| 238 | struct audio_usecase *usecase; |
| 239 | |
| 240 | list_for_each(node, &adev->usecase_list) { |
| 241 | usecase = node_to_item(node, struct audio_usecase, list); |
| 242 | if ((usecase->type == PCM_PLAYBACK) && |
| 243 | (usecase->devices & ddp_dev) && |
| 244 | (usecase->stream.out->flags & AUDIO_OUTPUT_FLAG_COMPRESS_OFFLOAD) && |
| 245 | ((usecase->stream.out->format == AUDIO_FORMAT_AC3) || |
Pradnya Chaphekar | 659affa | 2014-09-09 09:49:10 -0700 | [diff] [blame] | 246 | (usecase->stream.out->format == AUDIO_FORMAT_E_AC3) || |
| 247 | (usecase->stream.out->format == AUDIO_FORMAT_E_AC3_JOC))) { |
Subhash Chandra Bose Naripeddy | 7690c56 | 2013-12-14 00:34:53 -0800 | [diff] [blame] | 248 | send_ddp_endp_params_stream(usecase->stream.out, ddp_dev, |
| 249 | dev_ch_cap, false /* set cache */); |
| 250 | } |
| 251 | } |
| 252 | } |
| 253 | |
| 254 | void audio_extn_dolby_send_ddp_endp_params(struct audio_device *adev) |
| 255 | { |
| 256 | struct listnode *node; |
| 257 | struct audio_usecase *usecase; |
| 258 | list_for_each(node, &adev->usecase_list) { |
| 259 | usecase = node_to_item(node, struct audio_usecase, list); |
| 260 | if ((usecase->type == PCM_PLAYBACK) && |
| 261 | (usecase->devices & AUDIO_DEVICE_OUT_ALL) && |
| 262 | (usecase->stream.out->flags & AUDIO_OUTPUT_FLAG_COMPRESS_OFFLOAD) && |
| 263 | ((usecase->stream.out->format == AUDIO_FORMAT_AC3) || |
Pradnya Chaphekar | 659affa | 2014-09-09 09:49:10 -0700 | [diff] [blame] | 264 | (usecase->stream.out->format == AUDIO_FORMAT_E_AC3) || |
| 265 | (usecase->stream.out->format == AUDIO_FORMAT_E_AC3_JOC))) { |
Krishnankutty Kolathappilly | 0b2de1c | 2014-02-14 14:45:49 -0800 | [diff] [blame] | 266 | /* |
| 267 | * Use wfd /hdmi sink channel cap for dolby params if device is wfd |
| 268 | * or hdmi. Otherwise use stereo configuration |
| 269 | */ |
| 270 | int channel_cap = usecase->devices & AUDIO_DEVICE_OUT_AUX_DIGITAL ? |
| 271 | adev->cur_hdmi_channels : |
| 272 | usecase->devices & AUDIO_DEVICE_OUT_PROXY ? |
| 273 | adev->cur_wfd_channels : 2; |
Subhash Chandra Bose Naripeddy | 7690c56 | 2013-12-14 00:34:53 -0800 | [diff] [blame] | 274 | send_ddp_endp_params_stream(usecase->stream.out, usecase->devices, |
Krishnankutty Kolathappilly | 0b2de1c | 2014-02-14 14:45:49 -0800 | [diff] [blame] | 275 | channel_cap, false /* set cache */); |
Subhash Chandra Bose Naripeddy | 7690c56 | 2013-12-14 00:34:53 -0800 | [diff] [blame] | 276 | } |
| 277 | } |
| 278 | } |
| 279 | |
| 280 | void audio_extn_ddp_set_parameters(struct audio_device *adev, |
| 281 | struct str_parms *parms) |
| 282 | { |
| 283 | int ddp_dev, dev_ch_cap; |
| 284 | int val, ret; |
| 285 | char value[32]={0}; |
Dhananjay Kumar | 89ea3bd | 2014-04-29 15:45:57 +0530 | [diff] [blame] | 286 | |
| 287 | ret = str_parms_get_str(parms, AUDIO_PARAMETER_KEY_SND_CARD_STATUS, value, |
| 288 | sizeof(value)); |
| 289 | if (ret >= 0) { |
| 290 | char *snd_card_status = value + 2; |
| 291 | if (strncmp(snd_card_status, "ONLINE", sizeof("ONLINE")) == 0) |
| 292 | audio_extn_dolby_set_license(adev); |
| 293 | } |
| 294 | |
Subhash Chandra Bose Naripeddy | 7690c56 | 2013-12-14 00:34:53 -0800 | [diff] [blame] | 295 | ret = str_parms_get_str(parms, AUDIO_PARAMETER_DDP_DEV, value, |
| 296 | sizeof(value)); |
| 297 | if (ret >= 0) { |
| 298 | ddp_dev = atoi(value); |
| 299 | if (!(AUDIO_DEVICE_OUT_ALL & ddp_dev)) |
| 300 | return; |
| 301 | } else |
| 302 | return; |
| 303 | |
| 304 | ret = str_parms_get_str(parms, AUDIO_PARAMETER_DDP_CH_CAP, value, |
| 305 | sizeof(value)); |
| 306 | if (ret >= 0) { |
| 307 | dev_ch_cap = atoi(value); |
| 308 | if ((dev_ch_cap != 2) && (dev_ch_cap != 6) && (dev_ch_cap != 8)) |
| 309 | return; |
| 310 | } else |
| 311 | return; |
| 312 | |
| 313 | ret = str_parms_get_str(parms, AUDIO_PARAMETER_DDP_MAX_OUT_CHAN, value, |
| 314 | sizeof(value)); |
| 315 | if (ret >= 0) { |
| 316 | val = atoi(value); |
| 317 | update_ddp_endp_table(ddp_dev, dev_ch_cap, |
| 318 | PARAM_ID_MAX_OUTPUT_CHANNELS, val); |
| 319 | } |
| 320 | |
| 321 | ret = str_parms_get_str(parms, AUDIO_PARAMETER_DDP_OUT_MODE, value, |
| 322 | sizeof(value)); |
| 323 | if (ret >= 0) { |
| 324 | val = atoi(value); |
| 325 | update_ddp_endp_table(ddp_dev, dev_ch_cap, |
| 326 | PARAM_ID_OUT_CTL_OUTMODE, val); |
| 327 | } |
| 328 | |
| 329 | ret = str_parms_get_str(parms, AUDIO_PARAMETER_DDP_OUT_LFE_ON, value, |
| 330 | sizeof(value)); |
| 331 | if (ret >= 0) { |
| 332 | val = atoi(value); |
| 333 | update_ddp_endp_table(ddp_dev, dev_ch_cap, |
| 334 | PARAM_ID_OUT_CTL_OUTLFE_ON, val); |
| 335 | } |
| 336 | |
| 337 | ret = str_parms_get_str(parms, AUDIO_PARAMETER_DDP_COMP_MODE, value, |
| 338 | sizeof(value)); |
| 339 | if (ret >= 0) { |
| 340 | val = atoi(value); |
| 341 | update_ddp_endp_table(ddp_dev, dev_ch_cap, |
| 342 | PARAM_ID_OUT_CTL_COMPMODE, val); |
| 343 | } |
| 344 | |
| 345 | ret = str_parms_get_str(parms, AUDIO_PARAMETER_DDP_STEREO_MODE, value, |
| 346 | sizeof(value)); |
| 347 | if (ret >= 0) { |
| 348 | val = atoi(value); |
| 349 | update_ddp_endp_table(ddp_dev, dev_ch_cap, |
| 350 | PARAM_ID_OUT_CTL_STEREO_MODE, val); |
| 351 | } |
Krishnankutty Kolathappilly | 0b2de1c | 2014-02-14 14:45:49 -0800 | [diff] [blame] | 352 | /* TODO: Do we need device channel caps here? |
| 353 | * We dont have that information as this is from dolby modules |
| 354 | */ |
Subhash Chandra Bose Naripeddy | 7690c56 | 2013-12-14 00:34:53 -0800 | [diff] [blame] | 355 | send_ddp_endp_params(adev, ddp_dev, dev_ch_cap); |
| 356 | } |
Pradnya Chaphekar | 659affa | 2014-09-09 09:49:10 -0700 | [diff] [blame] | 357 | #endif /* DS1_DOLBY_DDP_ENABLED */ |
Subhash Chandra Bose Naripeddy | 7690c56 | 2013-12-14 00:34:53 -0800 | [diff] [blame] | 358 | |
Pradnya Chaphekar | 659affa | 2014-09-09 09:49:10 -0700 | [diff] [blame] | 359 | #if defined(DS1_DOLBY_DDP_ENABLED) || defined(DS2_DOLBY_DAP_ENABLED) |
Subhash Chandra Bose Naripeddy | 7690c56 | 2013-12-14 00:34:53 -0800 | [diff] [blame] | 360 | int audio_extn_dolby_get_snd_codec_id(struct audio_device *adev, |
| 361 | struct stream_out *out, |
| 362 | audio_format_t format) |
| 363 | { |
| 364 | int id = 0; |
Krishnankutty Kolathappilly | 0b2de1c | 2014-02-14 14:45:49 -0800 | [diff] [blame] | 365 | /* |
| 366 | * Use wfd /hdmi sink channel cap for dolby params if device is wfd |
| 367 | * or hdmi. Otherwise use stereo configuration |
| 368 | */ |
| 369 | int channel_cap = out->devices & AUDIO_DEVICE_OUT_AUX_DIGITAL ? |
| 370 | adev->cur_hdmi_channels : |
| 371 | out->devices & AUDIO_DEVICE_OUT_PROXY ? |
| 372 | adev->cur_wfd_channels : 2; |
Subhash Chandra Bose Naripeddy | 7690c56 | 2013-12-14 00:34:53 -0800 | [diff] [blame] | 373 | |
| 374 | switch (format) { |
| 375 | case AUDIO_FORMAT_AC3: |
| 376 | id = SND_AUDIOCODEC_AC3; |
Pradnya Chaphekar | 659affa | 2014-09-09 09:49:10 -0700 | [diff] [blame] | 377 | #ifdef DS1_DOLBY_DDP_ENABLED |
Subhash Chandra Bose Naripeddy | 7690c56 | 2013-12-14 00:34:53 -0800 | [diff] [blame] | 378 | send_ddp_endp_params_stream(out, out->devices, |
Krishnankutty Kolathappilly | 0b2de1c | 2014-02-14 14:45:49 -0800 | [diff] [blame] | 379 | channel_cap, true /* set_cache */); |
Subhash Chandra Bose Naripeddy | 7690c56 | 2013-12-14 00:34:53 -0800 | [diff] [blame] | 380 | #endif |
Pradnya Chaphekar | 659affa | 2014-09-09 09:49:10 -0700 | [diff] [blame] | 381 | audio_extn_dolby_set_dmid(adev); |
Subhash Chandra Bose Naripeddy | 7690c56 | 2013-12-14 00:34:53 -0800 | [diff] [blame] | 382 | break; |
Mingming Yin | ae3530f | 2014-07-03 16:50:18 -0700 | [diff] [blame] | 383 | case AUDIO_FORMAT_E_AC3: |
Pradnya Chaphekar | 659affa | 2014-09-09 09:49:10 -0700 | [diff] [blame] | 384 | case AUDIO_FORMAT_E_AC3_JOC: |
Subhash Chandra Bose Naripeddy | 7690c56 | 2013-12-14 00:34:53 -0800 | [diff] [blame] | 385 | id = SND_AUDIOCODEC_EAC3; |
Pradnya Chaphekar | 659affa | 2014-09-09 09:49:10 -0700 | [diff] [blame] | 386 | #ifdef DS1_DOLBY_DDP_ENABLED |
Subhash Chandra Bose Naripeddy | 7690c56 | 2013-12-14 00:34:53 -0800 | [diff] [blame] | 387 | send_ddp_endp_params_stream(out, out->devices, |
Krishnankutty Kolathappilly | 0b2de1c | 2014-02-14 14:45:49 -0800 | [diff] [blame] | 388 | channel_cap, true /* set_cache */); |
Subhash Chandra Bose Naripeddy | 7690c56 | 2013-12-14 00:34:53 -0800 | [diff] [blame] | 389 | #endif |
Pradnya Chaphekar | 659affa | 2014-09-09 09:49:10 -0700 | [diff] [blame] | 390 | audio_extn_dolby_set_dmid(adev); |
Subhash Chandra Bose Naripeddy | 7690c56 | 2013-12-14 00:34:53 -0800 | [diff] [blame] | 391 | break; |
| 392 | default: |
| 393 | ALOGE("%s: Unsupported audio format :%x", __func__, format); |
| 394 | } |
| 395 | |
| 396 | return id; |
| 397 | } |
| 398 | |
| 399 | bool audio_extn_is_dolby_format(audio_format_t format) |
| 400 | { |
| 401 | if (format == AUDIO_FORMAT_AC3 || |
Pradnya Chaphekar | 659affa | 2014-09-09 09:49:10 -0700 | [diff] [blame] | 402 | format == AUDIO_FORMAT_E_AC3 || |
| 403 | format == AUDIO_FORMAT_E_AC3_JOC) |
Subhash Chandra Bose Naripeddy | 7690c56 | 2013-12-14 00:34:53 -0800 | [diff] [blame] | 404 | return true; |
| 405 | else |
| 406 | return false; |
| 407 | } |
Pradnya Chaphekar | 659affa | 2014-09-09 09:49:10 -0700 | [diff] [blame] | 408 | #endif /* DS1_DOLBY_DDP_ENABLED || DS2_DOLBY_DAP_ENABLED */ |
Subhash Chandra Bose Naripeddy | 7690c56 | 2013-12-14 00:34:53 -0800 | [diff] [blame] | 409 | |
Pradnya Chaphekar | 80a8cfb | 2014-10-20 16:17:01 -0700 | [diff] [blame] | 410 | #ifdef HDMI_PASSTHROUGH_ENABLED |
| 411 | int audio_extn_dolby_update_passt_formats(struct audio_device *adev, |
| 412 | struct stream_out *out) { |
| 413 | int32_t i = 0, ret = -ENOSYS; |
| 414 | |
| 415 | if (platform_is_edid_supported_format(adev->platform, AUDIO_FORMAT_AC3) || |
| 416 | platform_is_edid_supported_format(adev->platform, AUDIO_FORMAT_E_AC3)) { |
| 417 | out->supported_formats[i++] = AUDIO_FORMAT_AC3; |
| 418 | out->supported_formats[i++] = AUDIO_FORMAT_E_AC3; |
| 419 | /* Reciever must support JOC and advertise, otherwise JOC is treated as DDP */ |
| 420 | out->supported_formats[i++] = AUDIO_FORMAT_E_AC3_JOC; |
| 421 | ret = 0; |
| 422 | } |
| 423 | ALOGV("%s: ret = %d", __func__, ret); |
| 424 | return ret; |
| 425 | } |
| 426 | |
| 427 | bool audio_extn_dolby_is_passt_convert_supported(struct audio_device *adev, |
| 428 | struct stream_out *out) { |
| 429 | |
| 430 | bool convert = false; |
| 431 | switch (out->format) { |
| 432 | case AUDIO_FORMAT_E_AC3: |
| 433 | case AUDIO_FORMAT_E_AC3_JOC: |
| 434 | if (!platform_is_edid_supported_format(adev->platform, |
| 435 | AUDIO_FORMAT_E_AC3)) { |
| 436 | ALOGV("%s:PASSTHROUGH_CONVERT supported", __func__); |
| 437 | convert = true; |
| 438 | } |
| 439 | break; |
| 440 | default: |
| 441 | ALOGE("%s: PASSTHROUGH_CONVERT not supported for format 0x%x", |
| 442 | __func__, out->format); |
| 443 | break; |
| 444 | } |
| 445 | ALOGE("%s: convert %d", __func__, convert); |
| 446 | return convert; |
| 447 | } |
| 448 | |
| 449 | bool audio_extn_dolby_is_passt_supported(struct audio_device *adev, |
| 450 | struct stream_out *out) { |
| 451 | bool passt = false; |
| 452 | switch (out->format) { |
| 453 | case AUDIO_FORMAT_E_AC3: |
| 454 | if (platform_is_edid_supported_format(adev->platform, out->format)) { |
| 455 | ALOGV("%s:PASSTHROUGH supported for format %x", |
| 456 | __func__, out->format); |
| 457 | passt = true; |
| 458 | } |
| 459 | break; |
| 460 | case AUDIO_FORMAT_AC3: |
| 461 | if (platform_is_edid_supported_format(adev->platform, AUDIO_FORMAT_AC3) |
| 462 | || platform_is_edid_supported_format(adev->platform, |
| 463 | AUDIO_FORMAT_E_AC3)) { |
| 464 | ALOGV("%s:PASSTHROUGH supported for format %x", |
| 465 | __func__, out->format); |
| 466 | passt = true; |
| 467 | } |
| 468 | break; |
| 469 | case AUDIO_FORMAT_E_AC3_JOC: |
| 470 | /* Check for DDP capability in edid for JOC contents.*/ |
| 471 | if (platform_is_edid_supported_format(adev->platform, |
| 472 | AUDIO_FORMAT_E_AC3)) { |
| 473 | ALOGV("%s:PASSTHROUGH supported for format %x", |
| 474 | __func__, out->format); |
| 475 | passt = true; |
| 476 | } |
| 477 | default: |
| 478 | ALOGV("%s:Passthrough not supported", __func__); |
| 479 | } |
| 480 | return passt; |
| 481 | } |
| 482 | |
| 483 | void audio_extn_dolby_update_passt_stream_configuration( |
| 484 | struct audio_device *adev, struct stream_out *out) { |
| 485 | if (audio_extn_dolby_is_passt_supported(adev, out)) { |
| 486 | ALOGV("%s:PASSTHROUGH", __func__); |
| 487 | out->compr_config.codec->compr_passthr = PASSTHROUGH; |
| 488 | } else if (audio_extn_dolby_is_passt_convert_supported(adev, out)){ |
| 489 | ALOGV("%s:PASSTHROUGH CONVERT", __func__); |
| 490 | out->compr_config.codec->compr_passthr = PASSTHROUGH_CONVERT; |
| 491 | } else { |
| 492 | ALOGV("%s:NO PASSTHROUGH", __func__); |
| 493 | out->compr_config.codec->compr_passthr = LEGACY_PCM; |
| 494 | } |
| 495 | } |
| 496 | |
| 497 | bool audio_extn_dolby_is_passthrough_stream(int flags) { |
| 498 | |
| 499 | if (flags & AUDIO_OUTPUT_FLAG_COMPRESS_PASSTHROUGH) |
| 500 | return true; |
| 501 | return false; |
| 502 | } |
| 503 | |
| 504 | int audio_extn_dolby_set_hdmi_config(struct audio_device *adev, |
| 505 | struct stream_out *out) { |
| 506 | return platform_set_hdmi_config(out); |
| 507 | } |
| 508 | |
| 509 | int audio_extn_dolby_get_passt_buffer_size(audio_offload_info_t* info) { |
| 510 | return platform_get_compress_passthrough_buffer_size(info); |
| 511 | } |
| 512 | |
| 513 | int audio_extn_dolby_set_passt_volume(struct stream_out *out, int mute) { |
| 514 | return platform_set_device_params(out, DEVICE_PARAM_MUTE_ID, mute); |
| 515 | } |
| 516 | |
| 517 | int audio_extn_dolby_set_passt_latency(struct stream_out *out, int latency) { |
| 518 | return platform_set_device_params(out, DEVICE_PARAM_LATENCY_ID, latency); |
| 519 | } |
| 520 | #endif /* HDMI_PASSTHROUGH_ENABLED */ |
| 521 | |
Subhash Chandra Bose Naripeddy | 7690c56 | 2013-12-14 00:34:53 -0800 | [diff] [blame] | 522 | #ifdef DS1_DOLBY_DAP_ENABLED |
| 523 | void audio_extn_dolby_set_endpoint(struct audio_device *adev) |
| 524 | { |
| 525 | struct listnode *node; |
| 526 | struct audio_usecase *usecase; |
| 527 | struct mixer_ctl *ctl; |
| 528 | const char *mixer_ctl_name = "DS1 DAP Endpoint"; |
| 529 | int endpoint = 0, ret; |
| 530 | bool send = false; |
| 531 | |
| 532 | list_for_each(node, &adev->usecase_list) { |
| 533 | usecase = node_to_item(node, struct audio_usecase, list); |
| 534 | if ((usecase->type == PCM_PLAYBACK) && |
| 535 | (usecase->id != USECASE_AUDIO_PLAYBACK_LOW_LATENCY)) { |
| 536 | endpoint |= usecase->devices & AUDIO_DEVICE_OUT_ALL; |
| 537 | send = true; |
| 538 | } |
| 539 | } |
| 540 | if (!send) |
| 541 | return; |
| 542 | |
| 543 | ctl = mixer_get_ctl_by_name(adev->mixer, mixer_ctl_name); |
| 544 | if (!ctl) { |
| 545 | ALOGE("%s: Could not get ctl for mixer cmd - %s", |
| 546 | __func__, mixer_ctl_name); |
| 547 | return; |
| 548 | } |
| 549 | ret = mixer_ctl_set_value(ctl, 0, endpoint); |
| 550 | if (ret) |
| 551 | ALOGE("%s: Dolby set endpint cannot be set error:%d",__func__, ret); |
| 552 | |
| 553 | return; |
| 554 | } |
| 555 | #endif /* DS1_DOLBY_DAP_ENABLED */ |
| 556 | |
| 557 | |
| 558 | #if defined(DS1_DOLBY_DDP_ENABLED) || defined(DS1_DOLBY_DAP_ENABLED) |
| 559 | void audio_extn_dolby_set_dmid(struct audio_device *adev) |
| 560 | { |
| 561 | struct listnode *node; |
| 562 | struct audio_usecase *usecase; |
| 563 | struct mixer_ctl *ctl; |
| 564 | const char *mixer_ctl_name = "DS1 Security"; |
| 565 | char c_dmid[128] = {0}; |
| 566 | int i_dmid, ret; |
| 567 | bool send = false; |
| 568 | |
| 569 | list_for_each(node, &adev->usecase_list) { |
| 570 | usecase = node_to_item(node, struct audio_usecase, list); |
Mingming Yin | c7d048a | 2014-02-25 13:34:07 -0800 | [diff] [blame] | 571 | if (usecase->type == PCM_PLAYBACK) |
Subhash Chandra Bose Naripeddy | 7690c56 | 2013-12-14 00:34:53 -0800 | [diff] [blame] | 572 | send = true; |
| 573 | } |
| 574 | if (!send) |
| 575 | return; |
| 576 | |
| 577 | property_get("dmid",c_dmid,"0"); |
Ashish Jain | 1dff321 | 2015-02-10 12:16:48 +0530 | [diff] [blame] | 578 | i_dmid = atoll(c_dmid); |
Subhash Chandra Bose Naripeddy | 7690c56 | 2013-12-14 00:34:53 -0800 | [diff] [blame] | 579 | |
| 580 | ctl = mixer_get_ctl_by_name(adev->mixer, mixer_ctl_name); |
| 581 | if (!ctl) { |
| 582 | ALOGE("%s: Could not get ctl for mixer cmd - %s", |
| 583 | __func__, mixer_ctl_name); |
| 584 | return; |
| 585 | } |
| 586 | ALOGV("%s Dolby device manufacturer id is:%d",__func__,i_dmid); |
| 587 | ret = mixer_ctl_set_value(ctl, 0, i_dmid); |
| 588 | if (ret) |
| 589 | ALOGE("%s: Dolby DMID cannot be set error:%d",__func__, ret); |
| 590 | |
| 591 | return; |
| 592 | } |
Dhananjay Kumar | 89ea3bd | 2014-04-29 15:45:57 +0530 | [diff] [blame] | 593 | |
Ashish Jain | edb6a91 | 2014-10-16 13:56:28 +0530 | [diff] [blame] | 594 | #ifndef DS2_DOLBY_DAP_ENABLED |
Dhananjay Kumar | 89ea3bd | 2014-04-29 15:45:57 +0530 | [diff] [blame] | 595 | void audio_extn_dolby_set_license(struct audio_device *adev) |
| 596 | { |
| 597 | int ret, key=0; |
| 598 | char value[128] = {0}; |
| 599 | struct mixer_ctl *ctl; |
| 600 | const char *mixer_ctl_name = "DS1 License"; |
| 601 | |
| 602 | ctl = mixer_get_ctl_by_name(adev->mixer, mixer_ctl_name); |
| 603 | if (!ctl) { |
| 604 | ALOGE("%s: Could not get ctl for mixer cmd - %s", |
| 605 | __func__, mixer_ctl_name); |
| 606 | return; |
| 607 | } |
| 608 | |
| 609 | property_get("audio.ds1.metainfo.key",value,"0"); |
Ashish Jain | edb6a91 | 2014-10-16 13:56:28 +0530 | [diff] [blame] | 610 | #ifdef DOLBY_ACDB_LICENSE |
Dhananjay Kumar | 89ea3bd | 2014-04-29 15:45:57 +0530 | [diff] [blame] | 611 | key = atoi(value); |
Ashish Jain | edb6a91 | 2014-10-16 13:56:28 +0530 | [diff] [blame] | 612 | #else |
| 613 | key = 0; |
| 614 | #endif |
Dhananjay Kumar | 89ea3bd | 2014-04-29 15:45:57 +0530 | [diff] [blame] | 615 | ALOGV("%s Setting DS1 License, key:0x%x",__func__, key); |
| 616 | ret = mixer_ctl_set_value(ctl, 0, key); |
| 617 | if (ret) |
| 618 | ALOGE("%s: cannot set license, error:%d",__func__, ret); |
| 619 | |
| 620 | return; |
| 621 | } |
Ashish Jain | edb6a91 | 2014-10-16 13:56:28 +0530 | [diff] [blame] | 622 | #endif |
Subhash Chandra Bose Naripeddy | 7690c56 | 2013-12-14 00:34:53 -0800 | [diff] [blame] | 623 | #endif /* DS1_DOLBY_DDP_ENABLED || DS1_DOLBY_DAP_ENABLED */ |
Pradnya Chaphekar | 659affa | 2014-09-09 09:49:10 -0700 | [diff] [blame] | 624 | |
| 625 | #ifdef DS2_DOLBY_DAP_ENABLED |
| 626 | struct ds2_extn_module { |
| 627 | void *ds2_handle; |
| 628 | dap_hal_set_hw_info_t dap_hal_set_hw_info; |
| 629 | }; |
| 630 | |
| 631 | static struct ds2_extn_module ds2extnmod = { |
| 632 | .ds2_handle = NULL, |
| 633 | .dap_hal_set_hw_info = NULL, |
| 634 | }; |
| 635 | |
| 636 | int audio_extn_dap_hal_init(int snd_card) { |
| 637 | char c_dmid[128] = {0}; |
| 638 | void *handle = NULL; |
| 639 | int i_dmid, ret = -EINVAL; |
| 640 | dap_hal_device_be_id_map_t device_be_id_map; |
| 641 | |
| 642 | ALOGV("%s: opening DAP HAL lib\n", __func__); |
| 643 | ds2extnmod.ds2_handle = dlopen(LIB_DS2_DAP_HAL, RTLD_NOW); |
| 644 | if (ds2extnmod.ds2_handle == NULL) { |
| 645 | ALOGE("%s: DLOPEN failed for %s error %s", __func__, LIB_DS2_DAP_HAL, |
| 646 | dlerror()); |
| 647 | goto ret; |
| 648 | } |
| 649 | ds2extnmod.dap_hal_set_hw_info = (dap_hal_set_hw_info_t)dlsym(ds2extnmod.ds2_handle, SET_HW_INFO_FUNC); |
| 650 | if (ds2extnmod.dap_hal_set_hw_info == NULL) { |
| 651 | ALOGE("%s: dlsym error %s for %s", __func__, SET_HW_INFO_FUNC, |
| 652 | dlerror()); |
| 653 | goto close; |
| 654 | } |
| 655 | ds2extnmod.dap_hal_set_hw_info(SND_CARD, (void*)(&snd_card)); |
| 656 | ALOGV("%s Sound card number is:%d",__func__,snd_card); |
| 657 | |
Pradnya Chaphekar | 659affa | 2014-09-09 09:49:10 -0700 | [diff] [blame] | 658 | platform_get_device_to_be_id_map(&device_be_id_map.device_id_to_be_id, &device_be_id_map.len); |
| 659 | ds2extnmod.dap_hal_set_hw_info(DEVICE_BE_ID_MAP, (void*)(&device_be_id_map)); |
| 660 | ALOGV("%s Set be id map len:%d",__func__,device_be_id_map.len); |
| 661 | ret = 0; |
| 662 | goto ret; |
| 663 | |
| 664 | close: |
| 665 | dlclose(ds2extnmod.ds2_handle); |
| 666 | ds2extnmod.ds2_handle = NULL; |
| 667 | ds2extnmod.dap_hal_set_hw_info = NULL; |
| 668 | ret: |
| 669 | return ret; |
| 670 | } |
| 671 | |
| 672 | int audio_extn_dap_hal_deinit() { |
| 673 | if (ds2extnmod.ds2_handle != NULL) { |
| 674 | dlclose(ds2extnmod.ds2_handle); |
| 675 | ds2extnmod.ds2_handle = NULL; |
| 676 | } |
| 677 | ds2extnmod.dap_hal_set_hw_info = NULL; |
| 678 | return 0; |
| 679 | } |
| 680 | |
| 681 | void audio_extn_dolby_ds2_set_endpoint(struct audio_device *adev) { |
| 682 | struct listnode *node; |
| 683 | struct audio_usecase *usecase; |
| 684 | struct mixer_ctl *ctl; |
| 685 | const char *mixer_ctl_name = "DS1 DAP Endpoint"; |
| 686 | int endpoint = 0, ret; |
| 687 | bool send = false; |
| 688 | |
| 689 | list_for_each(node, &adev->usecase_list) { |
| 690 | usecase = node_to_item(node, struct audio_usecase, list); |
| 691 | if ((usecase->type == PCM_PLAYBACK) && |
| 692 | (usecase->id != USECASE_AUDIO_PLAYBACK_LOW_LATENCY)) { |
| 693 | endpoint |= usecase->devices & AUDIO_DEVICE_OUT_ALL; |
| 694 | send = true; |
| 695 | } |
| 696 | } |
| 697 | if (!send) |
| 698 | return; |
| 699 | |
| 700 | if (ds2extnmod.dap_hal_set_hw_info) { |
| 701 | ds2extnmod.dap_hal_set_hw_info(HW_ENDPOINT, (void*)(&endpoint)); |
| 702 | ALOGE("%s: Dolby set endpint :0x%x",__func__, endpoint); |
| 703 | } else { |
| 704 | ALOGE("%s: dap_hal_set_hw_info is NULL",__func__); |
| 705 | } |
| 706 | |
| 707 | return; |
| 708 | } |
| 709 | |
| 710 | int audio_extn_ds2_enable(struct audio_device *adev) { |
| 711 | |
| 712 | char value[PROPERTY_VALUE_MAX] = {0}; |
| 713 | bool ds2_enabled = false; |
| 714 | const char *mixer_ctl_name = "DS2 OnOff"; |
| 715 | struct mixer_ctl *ctl; |
| 716 | |
| 717 | property_get("audio.dolby.ds2.enabled", value, NULL); |
| 718 | ds2_enabled = atoi(value) || !strncmp("true", value, 4); |
| 719 | |
| 720 | ALOGV("%s:", __func__); |
| 721 | if(ds2_enabled) { |
| 722 | ALOGD("%s:ds2_enabled %d", __func__, ds2_enabled); |
| 723 | ctl = mixer_get_ctl_by_name(adev->mixer, mixer_ctl_name); |
| 724 | if (!ctl) { |
| 725 | ALOGE("%s: Could not get ctl for mixer cmd - %s", |
| 726 | __func__, mixer_ctl_name); |
| 727 | return -EINVAL; |
| 728 | } |
| 729 | |
| 730 | if (mixer_ctl_set_value(ctl, 0, ds2_enabled) < 0) { |
| 731 | ALOGE("%s: Could not set ds2 enable %d", |
| 732 | __func__, ds2_enabled); |
| 733 | return -EINVAL; |
| 734 | } |
| 735 | } |
| 736 | return 0; |
| 737 | } |
| 738 | |
| 739 | int audio_extn_dolby_set_dap_bypass(struct audio_device *adev, int state) { |
| 740 | |
| 741 | ALOGV("%s: state %d", __func__, state); |
| 742 | if (ds2extnmod.dap_hal_set_hw_info) { |
| 743 | ds2extnmod.dap_hal_set_hw_info(DAP_BYPASS, (void*)(&state)); |
| 744 | ALOGV("%s: Dolby set bypas :0x%x", __func__, state); |
| 745 | } else { |
| 746 | ALOGV("%s: dap_hal_set_hw_info is NULL", __func__); |
| 747 | } |
| 748 | return 0; |
| 749 | } |
Ashish Jain | edb6a91 | 2014-10-16 13:56:28 +0530 | [diff] [blame] | 750 | |
| 751 | void audio_extn_dolby_set_license(struct audio_device *adev) |
| 752 | { |
| 753 | int i_key=0; |
| 754 | char c_key[128] = {0}; |
| 755 | char c_dmid[128] = {0}; |
| 756 | int i_dmid, ret = -EINVAL; |
| 757 | struct dolby_param_license dolby_license; |
| 758 | |
| 759 | #ifdef DOLBY_ACDB_LICENSE |
| 760 | property_get("audio.ds1.metainfo.key",c_key,"0"); |
| 761 | i_key = atoi(c_key); |
| 762 | #else |
| 763 | /* As ACDB based license mechanism is disabled, force set the license key to 0*/ |
| 764 | i_key = 0; |
| 765 | #endif |
| 766 | property_get("dmid",c_dmid,"0"); |
Ashish Jain | 1dff321 | 2015-02-10 12:16:48 +0530 | [diff] [blame] | 767 | i_dmid = atoll(c_dmid); |
Ashish Jain | edb6a91 | 2014-10-16 13:56:28 +0530 | [diff] [blame] | 768 | ALOGV("%s Setting DS1 License, key:0x%x dmid %d",__func__, i_key,i_dmid); |
| 769 | dolby_license.dmid = i_dmid; |
| 770 | dolby_license.license_key = i_key; |
| 771 | if (ds2extnmod.dap_hal_set_hw_info) { |
| 772 | ds2extnmod.dap_hal_set_hw_info(DMID, (void*)(&dolby_license.dmid)); |
| 773 | } else { |
| 774 | ALOGV("%s: dap_hal_set_hw_info is NULL", __func__); |
Ashish Jain | edb6a91 | 2014-10-16 13:56:28 +0530 | [diff] [blame] | 775 | } |
Ashish Jain | edb6a91 | 2014-10-16 13:56:28 +0530 | [diff] [blame] | 776 | } |
| 777 | |
| 778 | |
| 779 | void audio_extn_ds2_set_parameters(struct audio_device *adev, |
| 780 | struct str_parms *parms) |
| 781 | { |
| 782 | int val, ret; |
| 783 | char value[32]={0}; |
| 784 | |
| 785 | ret = str_parms_get_str(parms, AUDIO_PARAMETER_KEY_SND_CARD_STATUS, value, |
| 786 | sizeof(value)); |
| 787 | if (ret >= 0) { |
| 788 | char *snd_card_status = value + 2; |
| 789 | if (strncmp(snd_card_status, "ONLINE", sizeof("ONLINE")) == 0){ |
| 790 | audio_extn_dolby_set_license(adev); |
| 791 | } |
| 792 | } |
| 793 | } |
Pradnya Chaphekar | 659affa | 2014-09-09 09:49:10 -0700 | [diff] [blame] | 794 | #endif |