From c6d65076b3fed02565ffc110896a16a631a76507 Mon Sep 17 00:00:00 2001 From: Sachin Mohan Gadag Date: Thu, 30 May 2019 12:44:30 +0530 Subject: [PATCH] qap: test: Enable ecref path - For ec-ref path, add new device i.e audio-out- proxy and pass over to wrapper. In callback function data is written to ecref dump file. Change-Id: I32b35ccf5caf708b73e213b891195db31a497a44 --- qahw_api/test/qahw_playback_test.c | 6 +++++- qahw_api/test/qahw_playback_test.h | 1 + qahw_api/test/qap_wrapper_extn.c | 34 +++++++++++++++++++++++++++++- 3 files changed, 39 insertions(+), 2 deletions(-) diff --git a/qahw_api/test/qahw_playback_test.c b/qahw_api/test/qahw_playback_test.c index 9f1489ca..c2390101 100644 --- a/qahw_api/test/qahw_playback_test.c +++ b/qahw_api/test/qahw_playback_test.c @@ -2111,6 +2111,7 @@ int main(int argc, char* argv[]) { {"intr-strm", required_argument, 0, 'i'}, {"device-config", required_argument, 0, 'C'}, {"play-list", required_argument, 0, 'g'}, + {"ec-ref", no_argument, 0, 'L'}, {"help", no_argument, 0, 'h'}, {"bt-wbs", no_argument, 0, 'z'}, {0, 0, 0, 0} @@ -2135,7 +2136,7 @@ int main(int argc, char* argv[]) { while ((opt = getopt_long(argc, argv, - "-f:r:c:b:d:s:v:V:l:t:a:w:k:PD:KF:Ee:A:u:m:S:C:p::x:y:qQzh:i:h:g:O:", + "-f:r:c:b:d:s:v:V:l:t:a:w:k:PD:KF:Ee:A:u:m:S:C:p::x:y:qQzLh:i:h:g:O:", long_options, &option_index)) != -1) { @@ -2335,6 +2336,9 @@ int main(int argc, char* argv[]) { case 'x': render_format = atoi(optarg); break; + case 'L': + ec_ref = true; + break; case 'y': stream_param[i].timestamp_filename = optarg; break; diff --git a/qahw_api/test/qahw_playback_test.h b/qahw_api/test/qahw_playback_test.h index 6f333388..4c788131 100644 --- a/qahw_api/test/qahw_playback_test.h +++ b/qahw_api/test/qahw_playback_test.h @@ -41,6 +41,7 @@ bool kpi_mode; bool enable_dump; float vol_level; uint8_t render_format; +bool ec_ref; enum { diff --git a/qahw_api/test/qap_wrapper_extn.c b/qahw_api/test/qap_wrapper_extn.c index de954bfc..b3da21ab 100644 --- a/qahw_api/test/qap_wrapper_extn.c +++ b/qahw_api/test/qap_wrapper_extn.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016-2017, The Linux Foundation. All rights reserved. + * Copyright (c) 2016-2017,2019 The Linux Foundation. All rights reserved. * Not a Contribution. * * Copyright (C) 2015 The Android Open Source Project * @@ -88,6 +88,7 @@ FILE *fp_output_writer_spk = NULL; FILE *fp_output_writer_hp = NULL; FILE *fp_output_writer_hdmi = NULL; FILE *fp_output_timestamp_file = NULL; +FILE *fp_ecref = NULL; unsigned char data_buf[MAX_BUFFER_SIZE]; uint32_t output_device_id = 0; uint16_t input_streams_count = 0; @@ -207,6 +208,7 @@ static void update_session_outputs_config(int hdmi_render_format, int in_channel bool enable_hdmi = false; bool combo_enabled = false; char dev_kv_pair[16] = {0}; + bool enable_ecref = false; ALOGV("%s:%d output device id %d render format = %d", __func__, __LINE__, output_device_id, hdmi_render_format); @@ -217,6 +219,8 @@ static void update_session_outputs_config(int hdmi_render_format, int in_channel enable_hp = true; if (output_device_id & AUDIO_DEVICE_OUT_SPEAKER) enable_spk = true; + if (ec_ref) + enable_ecref = true; if (enable_hdmi) { session_output_config.output_config[session_output_config.num_output].id = AUDIO_DEVICE_OUT_HDMI; @@ -270,6 +274,20 @@ static void update_session_outputs_config(int hdmi_render_format, int in_channel session_output_config.num_output++; } + if (enable_ecref) { + session_output_config.output_config[session_output_config.num_output].channels = popcount(AUDIO_CHANNEL_OUT_STEREO); + session_output_config.output_config[session_output_config.num_output].id = AUDIO_DEVICE_OUT_PROXY; + session_output_config.output_config[session_output_config.num_output].sample_rate = smpl_rate; + if (bitwidth == PCM_24_BITWIDTH) { + session_output_config.output_config[session_output_config.num_output].format = QAP_AUDIO_FORMAT_PCM_24_BIT_PACKED; + session_output_config.output_config[session_output_config.num_output].bit_width = PCM_24_BITWIDTH; + } else { + session_output_config.output_config[session_output_config.num_output].format = QAP_AUDIO_FORMAT_PCM_16_BIT; + session_output_config.output_config[session_output_config.num_output].bit_width = PCM_16_BITWIDTH; + } + session_output_config.num_output++; + } + ALOGV("%s:%d num_output = %d", __func__, __LINE__, session_output_config.num_output); return; } @@ -1235,6 +1253,20 @@ void qap_wrapper_session_callback(qap_session_handle_t session_handle __unused, ALOGD("%s::%d Measuring Kpi cold stop %lf", __func__, __LINE__, cold_stop); } } + if (buffer->buffer_parms.output_buf_params.output_id == AUDIO_DEVICE_OUT_PROXY) { + + if (fp_ecref == NULL) { + fp_ecref = fopen("/data/vendor/misc/audio/ecref", "w+"); + } + + if (fp_ecref) { + ALOGD("%s: write %d bytes to ecref dump",__func__,buffer->common_params.size); + fwrite((unsigned char *)buffer->common_params.data, 1, buffer->common_params.size, fp_ecref); + } else { + ALOGE("%s: failed to open ecref dump file",__func__); + } + + } } } break;