Mingming Yin | 2185465 | 2016-04-13 11:54:02 -0700 | [diff] [blame] | 1 | /* |
Meng Wang | 4c32fb4 | 2020-01-16 17:57:11 +0800 | [diff] [blame] | 2 | * Copyright (c) 2014-2020, The Linux Foundation. All rights reserved. |
Mingming Yin | 2185465 | 2016-04-13 11:54:02 -0700 | [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. |
| 28 | */ |
| 29 | |
| 30 | #define LOG_TAG "passthru" |
| 31 | /*#define LOG_NDEBUG 0*/ |
| 32 | #include <stdlib.h> |
| 33 | #include <cutils/atomic.h> |
Weiyin Jiang | 2995f66 | 2019-04-17 14:25:12 +0800 | [diff] [blame] | 34 | #include <cutils/properties.h> |
Mingming Yin | 2185465 | 2016-04-13 11:54:02 -0700 | [diff] [blame] | 35 | #include <cutils/str_parms.h> |
Weiyin Jiang | 2995f66 | 2019-04-17 14:25:12 +0800 | [diff] [blame] | 36 | #include <log/log.h> |
Vinay Verma | addfa4a | 2018-04-29 14:03:38 +0530 | [diff] [blame] | 37 | #include <unistd.h> |
Arun Mirpuri | e008ed2 | 2019-03-21 11:21:04 -0700 | [diff] [blame] | 38 | #include <pthread.h> |
Mingming Yin | 2185465 | 2016-04-13 11:54:02 -0700 | [diff] [blame] | 39 | #include "audio_hw.h" |
| 40 | #include "audio_extn.h" |
| 41 | #include "platform_api.h" |
| 42 | #include <platform.h> |
Satish Babu Patakokila | 1caa1b7 | 2016-05-24 13:47:08 +0530 | [diff] [blame] | 43 | |
| 44 | #include "sound/compress_params.h" |
Manish Dewangan | 37864bc | 2017-06-09 12:28:37 +0530 | [diff] [blame] | 45 | |
Revathi Uddaraju | 1eac8b0 | 2017-05-18 17:13:33 +0530 | [diff] [blame] | 46 | #ifdef DYNAMIC_LOG_ENABLED |
| 47 | #include <log_xml_parser.h> |
| 48 | #define LOG_MASK HAL_MOD_FILE_PASSTH |
| 49 | #include <log_utils.h> |
| 50 | #endif |
Manish Dewangan | 37864bc | 2017-06-09 12:28:37 +0530 | [diff] [blame] | 51 | /* |
| 52 | * Offload buffer size for compress passthrough |
| 53 | */ |
| 54 | |
| 55 | #ifdef DTSHD_PARSER_ENABLED |
| 56 | #include "audio_parsers.h" |
| 57 | |
| 58 | /* list of all supported DTS transmission sample rates */ |
| 59 | static const int dts_transmission_sample_rates[] = { |
| 60 | 44100, 48000, 88200, 96000, 176400, 192000 |
| 61 | }; |
| 62 | |
| 63 | /* |
| 64 | * for DTSHD stream one frame size can be upto 36kb and to extract iec61937 |
| 65 | * info for parsing usecase minimum one frame needs to be sent to dts parser |
| 66 | */ |
| 67 | #define MAX_COMPRESS_PASSTHROUGH_FRAGMENT_SIZE (36 * 1024) |
| 68 | #else |
| 69 | #define MAX_COMPRESS_PASSTHROUGH_FRAGMENT_SIZE (8 * 1024) |
| 70 | #endif |
| 71 | |
| 72 | #define MIN_COMPRESS_PASSTHROUGH_FRAGMENT_SIZE (2 * 1024) |
Mingming Yin | 2185465 | 2016-04-13 11:54:02 -0700 | [diff] [blame] | 73 | |
Harsh Bansal | c83207c | 2017-09-01 16:04:36 +0530 | [diff] [blame] | 74 | #define DDP_COMPRESS_PASSTHROUGH_FRAGMENT_SIZE (10 * 1024) |
| 75 | |
Mingming Yin | 2185465 | 2016-04-13 11:54:02 -0700 | [diff] [blame] | 76 | static const audio_format_t audio_passthru_formats[] = { |
| 77 | AUDIO_FORMAT_AC3, |
| 78 | AUDIO_FORMAT_E_AC3, |
Satish Babu Patakokila | 1caa1b7 | 2016-05-24 13:47:08 +0530 | [diff] [blame] | 79 | AUDIO_FORMAT_E_AC3_JOC, |
Mingming Yin | 2185465 | 2016-04-13 11:54:02 -0700 | [diff] [blame] | 80 | AUDIO_FORMAT_DTS, |
Ben Romberger | 1aaaf86 | 2017-04-06 17:49:46 -0700 | [diff] [blame] | 81 | AUDIO_FORMAT_DTS_HD, |
Naresh Tanniru | 928f086 | 2017-04-07 16:44:23 -0700 | [diff] [blame] | 82 | AUDIO_FORMAT_DOLBY_TRUEHD, |
| 83 | AUDIO_FORMAT_IEC61937 |
Mingming Yin | 2185465 | 2016-04-13 11:54:02 -0700 | [diff] [blame] | 84 | }; |
| 85 | |
Arun Mirpuri | e008ed2 | 2019-03-21 11:21:04 -0700 | [diff] [blame] | 86 | //external function depedency |
| 87 | static fp_platform_is_edid_supported_format_t fp_platform_is_edid_supported_format; |
| 88 | static fp_platform_set_device_params_t fp_platform_set_device_params; |
| 89 | static fp_platform_edid_get_max_channels_t fp_platform_edid_get_max_channels; |
| 90 | static fp_platform_get_output_snd_device_t fp_platform_get_output_snd_device; |
| 91 | static fp_platform_get_codec_backend_cfg_t fp_platform_get_codec_backend_cfg; |
| 92 | static fp_platform_get_snd_device_name_t fp_platform_get_snd_device_name; |
| 93 | static fp_platform_is_edid_supported_sample_rate_t fp_platform_is_edid_supported_sample_rate; |
| 94 | static fp_audio_extn_keep_alive_start_t fp_audio_extn_keep_alive_start; |
| 95 | static fp_audio_extn_keep_alive_stop_t fp_audio_extn_keep_alive_stop; |
| 96 | static fp_audio_extn_utils_is_dolby_format_t fp_audio_extn_utils_is_dolby_format; |
| 97 | |
Mingming Yin | 2185465 | 2016-04-13 11:54:02 -0700 | [diff] [blame] | 98 | /* |
| 99 | * This atomic var is incremented/decremented by the offload stream to notify |
| 100 | * other pcm playback streams that a pass thru session is about to start or has |
| 101 | * finished. This hint can be used by the other streams to move to standby or |
| 102 | * start calling pcm_write respectively. |
| 103 | * This behavior is necessary as the DSP backend can only be configured to one |
| 104 | * of PCM or compressed. |
| 105 | */ |
| 106 | static volatile int32_t compress_passthru_active; |
| 107 | |
Arun Mirpuri | e008ed2 | 2019-03-21 11:21:04 -0700 | [diff] [blame] | 108 | int passthru_update_dts_stream_configuration(struct stream_out *out, |
Manish Dewangan | 37864bc | 2017-06-09 12:28:37 +0530 | [diff] [blame] | 109 | const void *buffer, size_t bytes) |
| 110 | { |
| 111 | struct audio_parser_codec_info codec_info; |
| 112 | struct dtshd_iec61937_info dtshd_tr_info; |
| 113 | int i; |
| 114 | int ret; |
| 115 | bool is_valid_transmission_rate = false; |
| 116 | bool is_valid_transmission_channels = false; |
| 117 | |
Manish Dewangan | 671a420 | 2017-08-18 17:30:46 +0530 | [diff] [blame] | 118 | if (!out) { |
| 119 | ALOGE("Invalid session"); |
| 120 | return -EINVAL; |
| 121 | } |
| 122 | |
| 123 | if ((out->format != AUDIO_FORMAT_DTS) && |
| 124 | (out->format != AUDIO_FORMAT_DTS_HD)) { |
| 125 | ALOGE("Non DTS format %d", out->format); |
| 126 | return -EINVAL; |
| 127 | } |
| 128 | |
| 129 | if (!buffer || bytes <= 0) { |
Arun Mirpuri | e008ed2 | 2019-03-21 11:21:04 -0700 | [diff] [blame] | 130 | ALOGD("Invalid buffer %p size %lu skipping dts stream conf update", |
| 131 | buffer, (unsigned long)bytes); |
Manish Dewangan | 671a420 | 2017-08-18 17:30:46 +0530 | [diff] [blame] | 132 | out->sample_rate = 48000; |
| 133 | out->compr_config.codec->sample_rate = out->sample_rate; |
| 134 | out->compr_config.codec->ch_in = 2; |
| 135 | out->channel_mask = audio_channel_out_mask_from_count(2); |
| 136 | return -EINVAL; |
| 137 | } |
| 138 | |
Manish Dewangan | 37864bc | 2017-06-09 12:28:37 +0530 | [diff] [blame] | 139 | /* codec format is AUDIO_PARSER_CODEC_DTSHD for both DTS and DTSHD as |
| 140 | * DTSHD parser can support both DTS and DTSHD |
| 141 | */ |
| 142 | memset(&codec_info, 0, sizeof(struct audio_parser_codec_info)); |
| 143 | memset(&dtshd_tr_info, 0, sizeof(struct dtshd_iec61937_info)); |
| 144 | |
| 145 | init_audio_parser((unsigned char *)buffer, bytes, AUDIO_PARSER_CODEC_DTSHD); |
| 146 | codec_info.codec_type = AUDIO_PARSER_CODEC_DTSHD; |
| 147 | if (!(ret = get_iec61937_info(&codec_info))) { |
| 148 | dtshd_tr_info = codec_info.codec_config.dtshd_tr_info; |
| 149 | ALOGD("dts new sample rate %d and channels %d\n", |
| 150 | dtshd_tr_info.sample_rate, |
| 151 | dtshd_tr_info.num_channels); |
Arun Mirpuri | e008ed2 | 2019-03-21 11:21:04 -0700 | [diff] [blame] | 152 | for (i = 0; i < (sizeof(dts_transmission_sample_rates)/sizeof(int)); i++) { |
Manish Dewangan | 37864bc | 2017-06-09 12:28:37 +0530 | [diff] [blame] | 153 | if (dts_transmission_sample_rates[i] == |
| 154 | dtshd_tr_info.sample_rate) { |
| 155 | out->sample_rate = dtshd_tr_info.sample_rate; |
| 156 | out->compr_config.codec->sample_rate = out->sample_rate; |
| 157 | is_valid_transmission_rate = true; |
| 158 | break; |
| 159 | } |
| 160 | } |
| 161 | /* DTS transmission channels should be 2 or 8*/ |
| 162 | if ((dtshd_tr_info.num_channels == 2) || |
| 163 | (dtshd_tr_info.num_channels == 8)) { |
| 164 | out->compr_config.codec->ch_in = dtshd_tr_info.num_channels; |
| 165 | out->channel_mask = audio_channel_out_mask_from_count |
| 166 | (dtshd_tr_info.num_channels); |
| 167 | is_valid_transmission_channels = true; |
| 168 | } |
| 169 | } else { |
| 170 | ALOGE("%s:: get_iec61937_info failed %d", __func__, ret); |
| 171 | } |
| 172 | |
| 173 | if (!is_valid_transmission_rate) { |
Harsh Bansal | 0ab6b18 | 2017-08-14 11:49:43 +0530 | [diff] [blame] | 174 | ALOGE("%s:: Invalid dts transmission rate %d\n using default sample rate 48000", |
Arun Mirpuri | e008ed2 | 2019-03-21 11:21:04 -0700 | [diff] [blame] | 175 | __func__, dtshd_tr_info.sample_rate); |
Harsh Bansal | 0ab6b18 | 2017-08-14 11:49:43 +0530 | [diff] [blame] | 176 | out->sample_rate = 48000; |
Manish Dewangan | 37864bc | 2017-06-09 12:28:37 +0530 | [diff] [blame] | 177 | out->compr_config.codec->sample_rate = out->sample_rate; |
| 178 | } |
| 179 | |
| 180 | if (!is_valid_transmission_channels) { |
| 181 | ALOGE("%s:: Invalid transmission channels %d using default transmission" |
| 182 | " channels as 2", __func__, dtshd_tr_info.num_channels); |
| 183 | out->compr_config.codec->ch_in = 2; |
| 184 | out->channel_mask = audio_channel_out_mask_from_count(2); |
| 185 | } |
Manish Dewangan | 671a420 | 2017-08-18 17:30:46 +0530 | [diff] [blame] | 186 | return 0; |
Manish Dewangan | 37864bc | 2017-06-09 12:28:37 +0530 | [diff] [blame] | 187 | } |
Manish Dewangan | 37864bc | 2017-06-09 12:28:37 +0530 | [diff] [blame] | 188 | |
Arun Mirpuri | e008ed2 | 2019-03-21 11:21:04 -0700 | [diff] [blame] | 189 | bool passthru_is_supported_format(audio_format_t format) |
| 190 | { |
| 191 | int32_t num_passthru_formats = sizeof(audio_passthru_formats) / |
| 192 | sizeof(audio_passthru_formats[0]); |
| 193 | int32_t i; |
| 194 | |
| 195 | for (i = 0; i < num_passthru_formats; i++) { |
| 196 | if (format == audio_passthru_formats[i]) { |
| 197 | ALOGD("%s : pass through format is true", __func__); |
| 198 | return true; |
| 199 | } |
| 200 | } |
| 201 | ALOGD("%s : pass through format is false", __func__); |
| 202 | return false; |
| 203 | } |
| 204 | |
| 205 | int passthru_get_channel_count(struct stream_out *out) |
Manish Dewangan | 37864bc | 2017-06-09 12:28:37 +0530 | [diff] [blame] | 206 | { |
| 207 | int channel_count = DEFAULT_HDMI_OUT_CHANNELS; |
| 208 | |
| 209 | if (!out) { |
| 210 | ALOGE("%s:: Invalid param out %p", __func__, out); |
| 211 | return -EINVAL; |
| 212 | } |
| 213 | |
Arun Mirpuri | e008ed2 | 2019-03-21 11:21:04 -0700 | [diff] [blame] | 214 | if (!passthru_is_supported_format(out->format)) { |
Manish Dewangan | 37864bc | 2017-06-09 12:28:37 +0530 | [diff] [blame] | 215 | ALOGE("%s:: not a passthrough format %d", __func__, out->format); |
| 216 | return -EINVAL; |
| 217 | } |
| 218 | |
| 219 | switch(out->format) { |
| 220 | case AUDIO_FORMAT_DOLBY_TRUEHD: |
| 221 | channel_count = 8; |
| 222 | break; |
| 223 | case AUDIO_FORMAT_DTS: |
| 224 | case AUDIO_FORMAT_DTS_HD: |
| 225 | #ifdef DTSHD_PARSER_ENABLED |
| 226 | /* taken channel count from parser*/ |
| 227 | channel_count = audio_channel_count_from_out_mask(out->channel_mask); |
| 228 | #endif |
| 229 | break; |
Harsh Bansal | 14d4726 | 2018-01-31 13:32:37 +0530 | [diff] [blame] | 230 | case AUDIO_FORMAT_IEC61937: |
| 231 | channel_count = audio_channel_count_from_out_mask(out->channel_mask); |
Manish Dewangan | 37864bc | 2017-06-09 12:28:37 +0530 | [diff] [blame] | 232 | default: |
| 233 | break; |
| 234 | } |
| 235 | |
| 236 | ALOGE("%s: pass through channel count %d\n", __func__, channel_count); |
| 237 | return channel_count; |
| 238 | } |
| 239 | |
Mingming Yin | 2185465 | 2016-04-13 11:54:02 -0700 | [diff] [blame] | 240 | /* |
| 241 | * must be called with stream lock held |
| 242 | * This function decides based on some rules whether the data |
| 243 | * coming on stream out must be rendered or dropped. |
| 244 | */ |
Arun Mirpuri | e008ed2 | 2019-03-21 11:21:04 -0700 | [diff] [blame] | 245 | bool passthru_should_drop_data(struct stream_out * out) |
Mingming Yin | 2185465 | 2016-04-13 11:54:02 -0700 | [diff] [blame] | 246 | { |
Meng Wang | 4c32fb4 | 2020-01-16 17:57:11 +0800 | [diff] [blame] | 247 | uint32_t compr_passthr = 0; |
Ashish Jain | d84fd6a | 2016-07-27 12:33:25 +0530 | [diff] [blame] | 248 | /*Drop data only |
| 249 | *stream is routed to HDMI and |
| 250 | *stream has PCM format or |
| 251 | *if a compress offload (DSP decode) session |
| 252 | */ |
Vignesh Kulothungan | 431207d | 2020-02-27 17:35:20 -0800 | [diff] [blame] | 253 | |
| 254 | if(out->compr_config.codec != NULL) { |
Vignesh Kulothungan | 4fa89d1 | 2020-01-27 11:24:13 -0800 | [diff] [blame] | 255 | #ifdef AUDIO_GKI_ENABLED |
Vignesh Kulothungan | 431207d | 2020-02-27 17:35:20 -0800 | [diff] [blame] | 256 | /* out->compr_config.codec->reserved[0] is for compr_passthr */ |
| 257 | compr_passthr = out->compr_config.codec->reserved[0]; |
Meng Wang | 4c32fb4 | 2020-01-16 17:57:11 +0800 | [diff] [blame] | 258 | #else |
Vignesh Kulothungan | 431207d | 2020-02-27 17:35:20 -0800 | [diff] [blame] | 259 | compr_passthr = out->compr_config.codec->compr_passthr; |
Meng Wang | 4c32fb4 | 2020-01-16 17:57:11 +0800 | [diff] [blame] | 260 | #endif |
Vignesh Kulothungan | 431207d | 2020-02-27 17:35:20 -0800 | [diff] [blame] | 261 | } |
| 262 | |
Aniket Kumar Lata | 0e6e1e5 | 2019-11-14 21:43:55 -0800 | [diff] [blame] | 263 | if (compare_device_type(&out->device_list, AUDIO_DEVICE_OUT_AUX_DIGITAL) && |
Ashish Jain | d84fd6a | 2016-07-27 12:33:25 +0530 | [diff] [blame] | 264 | (((out->format & AUDIO_FORMAT_MAIN_MASK) == AUDIO_FORMAT_PCM) || |
Vignesh Kulothungan | 431207d | 2020-02-27 17:35:20 -0800 | [diff] [blame] | 265 | (compr_passthr == LEGACY_PCM))) { |
Mingming Yin | 2185465 | 2016-04-13 11:54:02 -0700 | [diff] [blame] | 266 | if (android_atomic_acquire_load(&compress_passthru_active) > 0) { |
| 267 | ALOGI("drop data as pass thru is active"); |
| 268 | return true; |
| 269 | } |
| 270 | } |
| 271 | |
| 272 | return false; |
| 273 | } |
| 274 | |
| 275 | /* called with adev lock held */ |
Arun Mirpuri | e008ed2 | 2019-03-21 11:21:04 -0700 | [diff] [blame] | 276 | void passthru_on_start(struct stream_out * out) |
Mingming Yin | 2185465 | 2016-04-13 11:54:02 -0700 | [diff] [blame] | 277 | { |
| 278 | |
| 279 | uint64_t max_period_us = 0; |
| 280 | uint64_t temp; |
| 281 | struct audio_usecase * usecase; |
| 282 | struct listnode *node; |
| 283 | struct stream_out * o; |
| 284 | struct audio_device *adev = out->dev; |
| 285 | |
| 286 | if (android_atomic_acquire_load(&compress_passthru_active) > 0) { |
| 287 | ALOGI("pass thru is already active"); |
| 288 | return; |
| 289 | } |
| 290 | |
| 291 | ALOGV("inc pass thru count to notify other streams"); |
| 292 | android_atomic_inc(&compress_passthru_active); |
| 293 | |
Mingming Yin | 2185465 | 2016-04-13 11:54:02 -0700 | [diff] [blame] | 294 | while (true) { |
| 295 | /* find max period time among active playback use cases */ |
| 296 | list_for_each(node, &adev->usecase_list) { |
| 297 | usecase = node_to_item(node, struct audio_usecase, list); |
Sujin Panicker | 390724d | 2019-04-26 10:43:36 +0530 | [diff] [blame] | 298 | if (usecase->stream.out && usecase->type == PCM_PLAYBACK && |
Aniket Kumar Lata | 0e6e1e5 | 2019-11-14 21:43:55 -0800 | [diff] [blame] | 299 | compare_device_type(&usecase->device_list, AUDIO_DEVICE_OUT_AUX_DIGITAL)) { |
Mingming Yin | 2185465 | 2016-04-13 11:54:02 -0700 | [diff] [blame] | 300 | o = usecase->stream.out; |
| 301 | temp = o->config.period_size * 1000000LL / o->sample_rate; |
| 302 | if (temp > max_period_us) |
| 303 | max_period_us = temp; |
| 304 | } |
| 305 | } |
| 306 | |
| 307 | if (max_period_us) { |
| 308 | pthread_mutex_unlock(&adev->lock); |
| 309 | usleep(2*max_period_us); |
| 310 | max_period_us = 0; |
| 311 | pthread_mutex_lock(&adev->lock); |
| 312 | } else |
| 313 | break; |
| 314 | } |
| 315 | } |
| 316 | |
| 317 | /* called with adev lock held */ |
Arun Mirpuri | e008ed2 | 2019-03-21 11:21:04 -0700 | [diff] [blame] | 318 | void passthru_on_stop(struct stream_out * out) |
Mingming Yin | 2185465 | 2016-04-13 11:54:02 -0700 | [diff] [blame] | 319 | { |
Mingming Yin | 2185465 | 2016-04-13 11:54:02 -0700 | [diff] [blame] | 320 | if (android_atomic_acquire_load(&compress_passthru_active) > 0) { |
| 321 | /* |
| 322 | * its possible the count is already zero if pause was called before |
| 323 | * stop output stream |
| 324 | */ |
| 325 | android_atomic_dec(&compress_passthru_active); |
| 326 | } |
| 327 | |
Aniket Kumar Lata | 0e6e1e5 | 2019-11-14 21:43:55 -0800 | [diff] [blame] | 328 | if (compare_device_type(&out->device_list, AUDIO_DEVICE_OUT_AUX_DIGITAL)) { |
Md Mansoor Ahmed | db1b4f9 | 2018-01-25 18:56:31 +0530 | [diff] [blame] | 329 | ALOGD("%s: passthru on aux digital, start keep alive", __func__); |
Arun Mirpuri | e008ed2 | 2019-03-21 11:21:04 -0700 | [diff] [blame] | 330 | fp_audio_extn_keep_alive_start(KEEP_ALIVE_OUT_HDMI); |
Mingming Yin | 2185465 | 2016-04-13 11:54:02 -0700 | [diff] [blame] | 331 | } |
| 332 | } |
| 333 | |
Arun Mirpuri | e008ed2 | 2019-03-21 11:21:04 -0700 | [diff] [blame] | 334 | void passthru_on_pause(struct stream_out * out __unused) |
Mingming Yin | 2185465 | 2016-04-13 11:54:02 -0700 | [diff] [blame] | 335 | { |
| 336 | if (android_atomic_acquire_load(&compress_passthru_active) == 0) |
| 337 | return; |
Mingming Yin | 2185465 | 2016-04-13 11:54:02 -0700 | [diff] [blame] | 338 | } |
| 339 | |
Arun Mirpuri | e008ed2 | 2019-03-21 11:21:04 -0700 | [diff] [blame] | 340 | bool passthru_is_active() |
| 341 | { |
| 342 | return android_atomic_acquire_load(&compress_passthru_active) > 0; |
| 343 | } |
| 344 | |
| 345 | int passthru_set_parameters(struct audio_device *adev __unused, |
Md Mansoor Ahmed | db1b4f9 | 2018-01-25 18:56:31 +0530 | [diff] [blame] | 346 | struct str_parms *parms) |
Mingming Yin | 2185465 | 2016-04-13 11:54:02 -0700 | [diff] [blame] | 347 | { |
Md Mansoor Ahmed | db1b4f9 | 2018-01-25 18:56:31 +0530 | [diff] [blame] | 348 | char value[32]; |
| 349 | int ret; |
| 350 | ret = str_parms_get_str(parms, AUDIO_PARAMETER_DEVICE_CONNECT, value, sizeof(value)); |
| 351 | if (ret >= 0) { |
| 352 | int val = atoi(value); |
| 353 | if (val & AUDIO_DEVICE_OUT_AUX_DIGITAL) { |
Arun Mirpuri | e008ed2 | 2019-03-21 11:21:04 -0700 | [diff] [blame] | 354 | if (!passthru_is_active()) { |
Md Mansoor Ahmed | db1b4f9 | 2018-01-25 18:56:31 +0530 | [diff] [blame] | 355 | ALOGV("%s: start keep alive on aux digital", __func__); |
Arun Mirpuri | e008ed2 | 2019-03-21 11:21:04 -0700 | [diff] [blame] | 356 | fp_audio_extn_keep_alive_start(KEEP_ALIVE_OUT_HDMI); |
Md Mansoor Ahmed | db1b4f9 | 2018-01-25 18:56:31 +0530 | [diff] [blame] | 357 | } |
| 358 | } |
| 359 | } |
| 360 | |
| 361 | ret = str_parms_get_str(parms, AUDIO_PARAMETER_DEVICE_DISCONNECT, value, |
| 362 | sizeof(value)); |
| 363 | if (ret >= 0) { |
| 364 | int val = atoi(value); |
| 365 | if (val & AUDIO_DEVICE_OUT_AUX_DIGITAL) { |
| 366 | ALOGV("%s: stop keep_alive on aux digital on device", __func__); |
Arun Mirpuri | e008ed2 | 2019-03-21 11:21:04 -0700 | [diff] [blame] | 367 | fp_audio_extn_keep_alive_stop(KEEP_ALIVE_OUT_HDMI); |
Md Mansoor Ahmed | db1b4f9 | 2018-01-25 18:56:31 +0530 | [diff] [blame] | 368 | } |
| 369 | } |
Mingming Yin | 2185465 | 2016-04-13 11:54:02 -0700 | [diff] [blame] | 370 | return 0; |
| 371 | } |
| 372 | |
Arun Mirpuri | e008ed2 | 2019-03-21 11:21:04 -0700 | [diff] [blame] | 373 | bool passthru_is_enabled() { return true; } |
| 374 | |
| 375 | void passthru_init(passthru_init_config_t init_config) |
Mingming Yin | 2185465 | 2016-04-13 11:54:02 -0700 | [diff] [blame] | 376 | { |
Arun Mirpuri | e008ed2 | 2019-03-21 11:21:04 -0700 | [diff] [blame] | 377 | fp_platform_is_edid_supported_format = |
| 378 | init_config.fp_platform_is_edid_supported_format; |
| 379 | fp_platform_set_device_params = init_config.fp_platform_set_device_params; |
| 380 | fp_platform_edid_get_max_channels = |
| 381 | init_config.fp_platform_edid_get_max_channels; |
| 382 | fp_platform_get_output_snd_device = init_config.fp_platform_get_output_snd_device; |
| 383 | fp_platform_get_codec_backend_cfg = |
| 384 | init_config.fp_platform_get_codec_backend_cfg; |
| 385 | fp_platform_get_snd_device_name = init_config.fp_platform_get_snd_device_name; |
| 386 | fp_platform_is_edid_supported_sample_rate = |
| 387 | init_config.fp_platform_is_edid_supported_sample_rate; |
| 388 | fp_audio_extn_keep_alive_start = init_config.fp_audio_extn_keep_alive_start; |
| 389 | fp_audio_extn_keep_alive_stop = init_config.fp_audio_extn_keep_alive_stop; |
| 390 | fp_audio_extn_utils_is_dolby_format = init_config.fp_audio_extn_utils_is_dolby_format; |
Mingming Yin | 2185465 | 2016-04-13 11:54:02 -0700 | [diff] [blame] | 391 | } |
| 392 | |
Arun Mirpuri | e008ed2 | 2019-03-21 11:21:04 -0700 | [diff] [blame] | 393 | bool passthru_should_standby(struct stream_out * out __unused) |
Mingming Yin | 2185465 | 2016-04-13 11:54:02 -0700 | [diff] [blame] | 394 | { |
| 395 | return true; |
| 396 | } |
Satish Babu Patakokila | 1caa1b7 | 2016-05-24 13:47:08 +0530 | [diff] [blame] | 397 | |
Arun Mirpuri | e008ed2 | 2019-03-21 11:21:04 -0700 | [diff] [blame] | 398 | bool passthru_is_convert_supported(struct audio_device *adev, |
Satish Babu Patakokila | 1caa1b7 | 2016-05-24 13:47:08 +0530 | [diff] [blame] | 399 | struct stream_out *out) |
| 400 | { |
| 401 | |
| 402 | bool convert = false; |
| 403 | switch (out->format) { |
| 404 | case AUDIO_FORMAT_E_AC3: |
| 405 | case AUDIO_FORMAT_E_AC3_JOC: |
Arun Mirpuri | e008ed2 | 2019-03-21 11:21:04 -0700 | [diff] [blame] | 406 | if (!fp_platform_is_edid_supported_format(adev->platform, |
Satish Babu Patakokila | 5933e97 | 2017-08-24 12:22:08 +0530 | [diff] [blame] | 407 | out->format)) { |
Arun Mirpuri | e008ed2 | 2019-03-21 11:21:04 -0700 | [diff] [blame] | 408 | if (fp_platform_is_edid_supported_format(adev->platform, |
Satish Babu Patakokila | 5933e97 | 2017-08-24 12:22:08 +0530 | [diff] [blame] | 409 | AUDIO_FORMAT_AC3)) { |
| 410 | ALOGD("%s:PASSTHROUGH_CONVERT supported", __func__); |
| 411 | convert = true; |
| 412 | } |
Satish Babu Patakokila | 1caa1b7 | 2016-05-24 13:47:08 +0530 | [diff] [blame] | 413 | } |
| 414 | break; |
| 415 | default: |
| 416 | ALOGD("%s: PASSTHROUGH_CONVERT not supported for format 0x%x", |
| 417 | __func__, out->format); |
| 418 | break; |
| 419 | } |
| 420 | ALOGD("%s: convert %d", __func__, convert); |
| 421 | return convert; |
| 422 | } |
| 423 | |
Arun Mirpuri | e008ed2 | 2019-03-21 11:21:04 -0700 | [diff] [blame] | 424 | bool passthru_is_passt_supported(struct audio_device *adev, |
Satish Babu Patakokila | 1caa1b7 | 2016-05-24 13:47:08 +0530 | [diff] [blame] | 425 | struct stream_out *out) |
| 426 | { |
| 427 | bool passt = false; |
| 428 | switch (out->format) { |
| 429 | case AUDIO_FORMAT_E_AC3: |
Ben Romberger | 1aaaf86 | 2017-04-06 17:49:46 -0700 | [diff] [blame] | 430 | case AUDIO_FORMAT_DTS_HD: |
| 431 | case AUDIO_FORMAT_DOLBY_TRUEHD: |
Arun Mirpuri | e008ed2 | 2019-03-21 11:21:04 -0700 | [diff] [blame] | 432 | if (fp_platform_is_edid_supported_format(adev->platform, out->format)) { |
Satish Babu Patakokila | 1caa1b7 | 2016-05-24 13:47:08 +0530 | [diff] [blame] | 433 | ALOGV("%s:PASSTHROUGH supported for format %x", |
| 434 | __func__, out->format); |
| 435 | passt = true; |
| 436 | } |
| 437 | break; |
| 438 | case AUDIO_FORMAT_AC3: |
Arun Mirpuri | e008ed2 | 2019-03-21 11:21:04 -0700 | [diff] [blame] | 439 | if (fp_platform_is_edid_supported_format(adev->platform, AUDIO_FORMAT_AC3) |
| 440 | || fp_platform_is_edid_supported_format(adev->platform, |
Satish Babu Patakokila | 1caa1b7 | 2016-05-24 13:47:08 +0530 | [diff] [blame] | 441 | AUDIO_FORMAT_E_AC3)) { |
| 442 | ALOGV("%s:PASSTHROUGH supported for format %x", |
| 443 | __func__, out->format); |
| 444 | passt = true; |
| 445 | } |
| 446 | break; |
| 447 | case AUDIO_FORMAT_E_AC3_JOC: |
| 448 | /* Check for DDP capability in edid for JOC contents.*/ |
Arun Mirpuri | e008ed2 | 2019-03-21 11:21:04 -0700 | [diff] [blame] | 449 | if (fp_platform_is_edid_supported_format(adev->platform, |
Satish Babu Patakokila | 1caa1b7 | 2016-05-24 13:47:08 +0530 | [diff] [blame] | 450 | AUDIO_FORMAT_E_AC3)) { |
| 451 | ALOGV("%s:PASSTHROUGH supported for format %x", |
| 452 | __func__, out->format); |
| 453 | passt = true; |
| 454 | } |
| 455 | break; |
| 456 | case AUDIO_FORMAT_DTS: |
Arun Mirpuri | e008ed2 | 2019-03-21 11:21:04 -0700 | [diff] [blame] | 457 | if (fp_platform_is_edid_supported_format(adev->platform, AUDIO_FORMAT_DTS) |
| 458 | || fp_platform_is_edid_supported_format(adev->platform, |
Satish Babu Patakokila | 1caa1b7 | 2016-05-24 13:47:08 +0530 | [diff] [blame] | 459 | AUDIO_FORMAT_DTS_HD)) { |
| 460 | ALOGV("%s:PASSTHROUGH supported for format %x", |
| 461 | __func__, out->format); |
| 462 | passt = true; |
| 463 | } |
| 464 | break; |
Satish Babu Patakokila | 1caa1b7 | 2016-05-24 13:47:08 +0530 | [diff] [blame] | 465 | default: |
| 466 | ALOGV("%s:Passthrough not supported", __func__); |
| 467 | } |
| 468 | return passt; |
| 469 | } |
| 470 | |
Arun Mirpuri | e008ed2 | 2019-03-21 11:21:04 -0700 | [diff] [blame] | 471 | void passthru_update_stream_configuration( |
Manish Dewangan | 37864bc | 2017-06-09 12:28:37 +0530 | [diff] [blame] | 472 | struct audio_device *adev, struct stream_out *out, |
Garmond Leung | 317cbf1 | 2017-09-13 16:20:50 -0700 | [diff] [blame] | 473 | const void *buffer __unused, size_t bytes __unused) |
Satish Babu Patakokila | 1caa1b7 | 2016-05-24 13:47:08 +0530 | [diff] [blame] | 474 | { |
Meng Wang | 4c32fb4 | 2020-01-16 17:57:11 +0800 | [diff] [blame] | 475 | uint32_t compr_passthr = 0; |
| 476 | |
Naresh Tanniru | ccd9f38 | 2018-01-17 16:02:19 +0530 | [diff] [blame] | 477 | if(out->compr_config.codec != NULL) { |
Arun Mirpuri | e008ed2 | 2019-03-21 11:21:04 -0700 | [diff] [blame] | 478 | if (passthru_is_passt_supported(adev, out)) { |
Naresh Tanniru | ccd9f38 | 2018-01-17 16:02:19 +0530 | [diff] [blame] | 479 | ALOGV("%s:PASSTHROUGH", __func__); |
Meng Wang | 4c32fb4 | 2020-01-16 17:57:11 +0800 | [diff] [blame] | 480 | compr_passthr = PASSTHROUGH; |
Arun Mirpuri | e008ed2 | 2019-03-21 11:21:04 -0700 | [diff] [blame] | 481 | } else if (passthru_is_convert_supported(adev, out)) { |
Naresh Tanniru | ccd9f38 | 2018-01-17 16:02:19 +0530 | [diff] [blame] | 482 | ALOGV("%s:PASSTHROUGH CONVERT", __func__); |
Meng Wang | 4c32fb4 | 2020-01-16 17:57:11 +0800 | [diff] [blame] | 483 | compr_passthr = PASSTHROUGH_CONVERT; |
Naresh Tanniru | ccd9f38 | 2018-01-17 16:02:19 +0530 | [diff] [blame] | 484 | } else if (out->format == AUDIO_FORMAT_IEC61937) { |
| 485 | ALOGV("%s:PASSTHROUGH IEC61937", __func__); |
Meng Wang | 4c32fb4 | 2020-01-16 17:57:11 +0800 | [diff] [blame] | 486 | compr_passthr = PASSTHROUGH_IEC61937; |
Naresh Tanniru | ccd9f38 | 2018-01-17 16:02:19 +0530 | [diff] [blame] | 487 | } else { |
| 488 | ALOGV("%s:NO PASSTHROUGH", __func__); |
Meng Wang | 4c32fb4 | 2020-01-16 17:57:11 +0800 | [diff] [blame] | 489 | compr_passthr = LEGACY_PCM; |
Naresh Tanniru | ccd9f38 | 2018-01-17 16:02:19 +0530 | [diff] [blame] | 490 | } |
Vignesh Kulothungan | 431207d | 2020-02-27 17:35:20 -0800 | [diff] [blame] | 491 | #ifdef AUDIO_GKI_ENABLED |
| 492 | /* out->compr_config.codec->reserved[0] is for compr_passthr */ |
| 493 | out->compr_config.codec->reserved[0] = compr_passthr; |
| 494 | #else |
| 495 | out->compr_config.codec->compr_passthr = compr_passthr; |
| 496 | #endif |
Satish Babu Patakokila | 1caa1b7 | 2016-05-24 13:47:08 +0530 | [diff] [blame] | 497 | } |
Meng Wang | 4c32fb4 | 2020-01-16 17:57:11 +0800 | [diff] [blame] | 498 | |
Satish Babu Patakokila | 1caa1b7 | 2016-05-24 13:47:08 +0530 | [diff] [blame] | 499 | } |
| 500 | |
Arun Mirpuri | e008ed2 | 2019-03-21 11:21:04 -0700 | [diff] [blame] | 501 | bool passthru_is_passthrough_stream(struct stream_out *out) |
Satish Babu Patakokila | 1caa1b7 | 2016-05-24 13:47:08 +0530 | [diff] [blame] | 502 | { |
| 503 | //check passthrough system property |
Aniket Kumar Lata | 8fc67e6 | 2017-05-02 12:33:46 -0700 | [diff] [blame] | 504 | if (!property_get_bool("vendor.audio.offload.passthrough", false)) { |
Satish Babu Patakokila | 1caa1b7 | 2016-05-24 13:47:08 +0530 | [diff] [blame] | 505 | return false; |
| 506 | } |
| 507 | |
| 508 | //check supported device, currently only on HDMI. |
Aniket Kumar Lata | 0e6e1e5 | 2019-11-14 21:43:55 -0800 | [diff] [blame] | 509 | if (compare_device_type(&out->device_list, AUDIO_DEVICE_OUT_AUX_DIGITAL)) { |
Satish Babu Patakokila | 1caa1b7 | 2016-05-24 13:47:08 +0530 | [diff] [blame] | 510 | //passthrough flag |
| 511 | if (out->flags & AUDIO_OUTPUT_FLAG_COMPRESS_PASSTHROUGH) |
| 512 | return true; |
| 513 | //direct flag, check supported formats. |
| 514 | if (out->flags & AUDIO_OUTPUT_FLAG_DIRECT) { |
Arun Mirpuri | e008ed2 | 2019-03-21 11:21:04 -0700 | [diff] [blame] | 515 | if (passthru_is_supported_format(out->format)) { |
| 516 | if (fp_platform_is_edid_supported_format(out->dev->platform, |
Satish Babu Patakokila | 1caa1b7 | 2016-05-24 13:47:08 +0530 | [diff] [blame] | 517 | out->format)) { |
| 518 | ALOGV("%s : return true",__func__); |
| 519 | return true; |
Arun Mirpuri | e008ed2 | 2019-03-21 11:21:04 -0700 | [diff] [blame] | 520 | } else if (fp_audio_extn_utils_is_dolby_format(out->format) && |
| 521 | fp_platform_is_edid_supported_format(out->dev->platform, |
Satish Babu Patakokila | 1caa1b7 | 2016-05-24 13:47:08 +0530 | [diff] [blame] | 522 | AUDIO_FORMAT_AC3)){ |
| 523 | //return true for EAC3/EAC3_JOC formats |
| 524 | //if sink supports only AC3 |
| 525 | ALOGV("%s : return true",__func__); |
| 526 | return true; |
| 527 | } |
| 528 | } |
| 529 | } |
| 530 | } |
| 531 | ALOGV("%s : return false",__func__); |
| 532 | return false; |
| 533 | } |
| 534 | |
Arun Mirpuri | e008ed2 | 2019-03-21 11:21:04 -0700 | [diff] [blame] | 535 | bool passthru_is_direct_passthrough(struct stream_out *out) |
Manish Dewangan | 672001f | 2017-08-16 13:44:07 +0530 | [diff] [blame] | 536 | { |
Arun Mirpuri | e008ed2 | 2019-03-21 11:21:04 -0700 | [diff] [blame] | 537 | if (((out != NULL) && passthru_is_passthrough_stream(out)) && |
| 538 | !passthru_is_convert_supported(out->dev, out)) |
Manish Dewangan | 672001f | 2017-08-16 13:44:07 +0530 | [diff] [blame] | 539 | return true; |
| 540 | else |
| 541 | return false; |
| 542 | } |
| 543 | |
Arun Mirpuri | e008ed2 | 2019-03-21 11:21:04 -0700 | [diff] [blame] | 544 | int passthru_get_buffer_size(audio_offload_info_t* info) |
Satish Babu Patakokila | 1caa1b7 | 2016-05-24 13:47:08 +0530 | [diff] [blame] | 545 | { |
Manish Dewangan | 37864bc | 2017-06-09 12:28:37 +0530 | [diff] [blame] | 546 | uint32_t fragment_size = MIN_COMPRESS_PASSTHROUGH_FRAGMENT_SIZE; |
| 547 | char value[PROPERTY_VALUE_MAX] = {0}; |
| 548 | |
| 549 | if (((info->format == AUDIO_FORMAT_DOLBY_TRUEHD) || |
| 550 | (info->format == AUDIO_FORMAT_IEC61937)) && |
Satish Babu Patakokila | 37e7c48 | 2018-02-02 11:50:06 +0530 | [diff] [blame] | 551 | property_get("vendor.audio.truehd.buffer.size.kb", value, "") && |
Manish Dewangan | 37864bc | 2017-06-09 12:28:37 +0530 | [diff] [blame] | 552 | atoi(value)) { |
| 553 | fragment_size = atoi(value) * 1024; |
| 554 | goto done; |
| 555 | } else if ((info->format == AUDIO_FORMAT_DTS) || |
| 556 | (info->format == AUDIO_FORMAT_DTS_HD)) { |
| 557 | fragment_size = MAX_COMPRESS_PASSTHROUGH_FRAGMENT_SIZE; |
| 558 | goto done; |
Harsh Bansal | c83207c | 2017-09-01 16:04:36 +0530 | [diff] [blame] | 559 | } else if (info->format == AUDIO_FORMAT_E_AC3) { |
| 560 | fragment_size = DDP_COMPRESS_PASSTHROUGH_FRAGMENT_SIZE; |
Satish Babu Patakokila | 37e7c48 | 2018-02-02 11:50:06 +0530 | [diff] [blame] | 561 | if(property_get("vendor.audio.ddp.buffer.size.kb", value, "") && |
Harsh Bansal | c83207c | 2017-09-01 16:04:36 +0530 | [diff] [blame] | 562 | atoi(value)) { |
| 563 | fragment_size = atoi(value) * 1024; |
| 564 | } |
| 565 | goto done; |
Manish Dewangan | 37864bc | 2017-06-09 12:28:37 +0530 | [diff] [blame] | 566 | } |
Manish Dewangan | 37864bc | 2017-06-09 12:28:37 +0530 | [diff] [blame] | 567 | done: |
| 568 | return fragment_size; |
| 569 | |
Satish Babu Patakokila | 1caa1b7 | 2016-05-24 13:47:08 +0530 | [diff] [blame] | 570 | } |
| 571 | |
Arun Mirpuri | e008ed2 | 2019-03-21 11:21:04 -0700 | [diff] [blame] | 572 | int passthru_set_volume(struct stream_out *out, int mute) |
Satish Babu Patakokila | 1caa1b7 | 2016-05-24 13:47:08 +0530 | [diff] [blame] | 573 | { |
Arun Mirpuri | e008ed2 | 2019-03-21 11:21:04 -0700 | [diff] [blame] | 574 | return fp_platform_set_device_params(out, DEVICE_PARAM_MUTE_ID, mute); |
Satish Babu Patakokila | 1caa1b7 | 2016-05-24 13:47:08 +0530 | [diff] [blame] | 575 | } |
| 576 | |
Arun Mirpuri | e008ed2 | 2019-03-21 11:21:04 -0700 | [diff] [blame] | 577 | int passthru_set_latency(struct stream_out *out, int latency) |
Satish Babu Patakokila | 1caa1b7 | 2016-05-24 13:47:08 +0530 | [diff] [blame] | 578 | { |
Arun Mirpuri | e008ed2 | 2019-03-21 11:21:04 -0700 | [diff] [blame] | 579 | return fp_platform_set_device_params(out, DEVICE_PARAM_LATENCY_ID, latency); |
Satish Babu Patakokila | 1caa1b7 | 2016-05-24 13:47:08 +0530 | [diff] [blame] | 580 | } |
Satish Babu Patakokila | 5933e97 | 2017-08-24 12:22:08 +0530 | [diff] [blame] | 581 | |
Arun Mirpuri | e008ed2 | 2019-03-21 11:21:04 -0700 | [diff] [blame] | 582 | bool passthru_is_supported_backend_edid_cfg(struct audio_device *adev, |
Satish Babu Patakokila | 5933e97 | 2017-08-24 12:22:08 +0530 | [diff] [blame] | 583 | struct stream_out *out) |
| 584 | { |
| 585 | struct audio_backend_cfg backend_cfg; |
mpang | 787a6aa | 2018-11-29 11:25:58 +0800 | [diff] [blame] | 586 | backend_cfg.sample_rate = CODEC_BACKEND_DEFAULT_SAMPLE_RATE; |
| 587 | backend_cfg.channels = CODEC_BACKEND_DEFAULT_CHANNELS; |
| 588 | backend_cfg.bit_width = CODEC_BACKEND_DEFAULT_BIT_WIDTH; |
| 589 | backend_cfg.format = AUDIO_FORMAT_PCM_16_BIT; |
| 590 | backend_cfg.passthrough_enabled = false; |
| 591 | |
Satish Babu Patakokila | 5933e97 | 2017-08-24 12:22:08 +0530 | [diff] [blame] | 592 | snd_device_t out_snd_device = SND_DEVICE_NONE; |
Arun Mirpuri | e008ed2 | 2019-03-21 11:21:04 -0700 | [diff] [blame] | 593 | int max_edid_channels = fp_platform_edid_get_max_channels(out->dev->platform); |
Satish Babu Patakokila | 5933e97 | 2017-08-24 12:22:08 +0530 | [diff] [blame] | 594 | |
Jaideep Sharma | 477917f | 2020-03-13 18:13:33 +0530 | [diff] [blame] | 595 | out_snd_device = fp_platform_get_output_snd_device(adev->platform, out, USECASE_TYPE_MAX); |
Satish Babu Patakokila | 5933e97 | 2017-08-24 12:22:08 +0530 | [diff] [blame] | 596 | |
Arun Mirpuri | e008ed2 | 2019-03-21 11:21:04 -0700 | [diff] [blame] | 597 | if (fp_platform_get_codec_backend_cfg(adev, out_snd_device, &backend_cfg)) { |
Satish Babu Patakokila | 5933e97 | 2017-08-24 12:22:08 +0530 | [diff] [blame] | 598 | ALOGE("%s: ERROR: Unable to get current backend config!!!", __func__); |
| 599 | return false; |
| 600 | } |
| 601 | |
| 602 | ALOGV("%s:becf: afe: bitwidth %d, samplerate %d channels %d format %d" |
| 603 | ", device (%s)", __func__, backend_cfg.bit_width, |
| 604 | backend_cfg.sample_rate, backend_cfg.channels, backend_cfg.format, |
Arun Mirpuri | e008ed2 | 2019-03-21 11:21:04 -0700 | [diff] [blame] | 605 | fp_platform_get_snd_device_name(out_snd_device)); |
Satish Babu Patakokila | 5933e97 | 2017-08-24 12:22:08 +0530 | [diff] [blame] | 606 | |
| 607 | /* Check if the channels are supported */ |
Garmond Leung | 438932f | 2017-10-04 19:35:18 -0700 | [diff] [blame] | 608 | if (max_edid_channels < (int)backend_cfg.channels) { |
Satish Babu Patakokila | 5933e97 | 2017-08-24 12:22:08 +0530 | [diff] [blame] | 609 | |
| 610 | ALOGE("%s: ERROR: Unsupported channels in passthru mode!!!" |
| 611 | " max_edid_channels - %d backend_channels - %d", |
| 612 | __func__, max_edid_channels, backend_cfg.channels); |
| 613 | return false; |
| 614 | } |
| 615 | |
| 616 | /* Check if the sample rate supported */ |
Arun Mirpuri | e008ed2 | 2019-03-21 11:21:04 -0700 | [diff] [blame] | 617 | if (!fp_platform_is_edid_supported_sample_rate(adev->platform, |
Satish Babu Patakokila | 5933e97 | 2017-08-24 12:22:08 +0530 | [diff] [blame] | 618 | backend_cfg.sample_rate)) { |
| 619 | |
| 620 | ALOGE("%s: ERROR: Unsupported sample rate in passthru mode!!!" |
| 621 | " backend_samplerate - %d", |
| 622 | __func__, backend_cfg.sample_rate); |
| 623 | return false; |
| 624 | } |
| 625 | |
| 626 | return true; |
| 627 | } |