From 0347fbb1e5cf8535da83ff6519790d177a824d09 Mon Sep 17 00:00:00 2001 From: padmashree mandri Date: Fri, 17 Jan 2025 08:51:51 +0000 Subject: [PATCH] [NOt To Merge] HFP enable Signed-off-by: padmashree mandri --- .../interfaces/0006-hfp-patch-2.patch | 116 ++++++++++++++++++ .../interfaces/0007-enable-dump.patch | 88 +++++++++++++ 2 files changed, 204 insertions(+) create mode 100644 bsp_diff/caas/hardware/interfaces/0006-hfp-patch-2.patch create mode 100644 bsp_diff/caas/hardware/interfaces/0007-enable-dump.patch diff --git a/bsp_diff/caas/hardware/interfaces/0006-hfp-patch-2.patch b/bsp_diff/caas/hardware/interfaces/0006-hfp-patch-2.patch new file mode 100644 index 0000000000..c8177b383d --- /dev/null +++ b/bsp_diff/caas/hardware/interfaces/0006-hfp-patch-2.patch @@ -0,0 +1,116 @@ +From 9ec2f646d7d4e1778b2b5dbfee4c78d5e059cbd4 Mon Sep 17 00:00:00 2001 +From: padmashree mandri +Date: Wed, 15 Jan 2025 11:30:07 +0000 +Subject: [PATCH] hfp patch-2 + +Signed-off-by: padmashree mandri +--- + audio/aidl/default/alsa/StreamAlsa.cpp | 40 ++++++++++++++++++++--- + audio/aidl/default/primary/PrimaryMixer.h | 4 +-- + 2 files changed, 37 insertions(+), 7 deletions(-) + +diff --git a/audio/aidl/default/alsa/StreamAlsa.cpp b/audio/aidl/default/alsa/StreamAlsa.cpp +index 87667b41c5..cc8093c28e 100644 +--- a/audio/aidl/default/alsa/StreamAlsa.cpp ++++ b/audio/aidl/default/alsa/StreamAlsa.cpp +@@ -160,16 +160,31 @@ StreamAlsa::~StreamAlsa() { + mReadWriteRetries); + maxLatency = proxy_get_latency(mAlsaDeviceProxies[0].get()); + FILE *in_read_dump = fopen("/data/bt_call_in_before.pcm", "a"); +- fwrite(buf_in, 1, buf_size_in, in_read_dump); ++ if(in_read_dump != NULL) { ++ ALOGE("writing to bt_call_in_before"); ++ fwrite(buf_in, 1, buf_size_in, in_read_dump); ++ } else ++ ALOGE("Failed to write to bt_call_in_before"); + //resample from 8k -> 48k + //adjust chanel 1 -> 2 + adjust_channels(buf_in, HFP_CHANNEL_COUNT, buf_remapped, PRIMARY_CHANNEL_COUNT, + SAMPLE_SIZE_IN_BYTES, buf_size_in); + FILE *in_read_dump_1 = fopen("/data/bt_call_in_remapped.pcm", "a"); ++ if(in_read_dump_1 != NULL) { ++ ALOGE("writing to bt_call_in_remapped"); + fwrite(buf_in, 1, buf_size_in, in_read_dump_1); ++ } else ++ ALOGE("failed to write to bt_call_in_remapped"); + if(voip_in_resampler != NULL) { + voip_in_resampler->resample_from_input(voip_in_resampler, (int16_t *)buf_remapped, (size_t *)&frames_in, (int16_t *) buf_out, (size_t *)&frames_out); + } ++ ++ FILE *in_read_dump_2 = fopen("/data/bt_call_in_after.pcm", "a"); ++ if(in_read_dump_2 != NULL) { ++ ALOGE("writing to bt_call_in_afterd"); ++ fwrite(buf_in, 1, buf_size_in, in_read_dump_2); ++ } else ++ ALOGE("failed to write to bt_call_in_after"); + buf_size_out = PRIMARY_CHANNEL_COUNT * frames_out * SAMPLE_SIZE_IN_BYTES; + memcpy(buffer, buf_out, buf_size_out); + free(buf_in); +@@ -188,7 +203,11 @@ StreamAlsa::~StreamAlsa() { + int16_t *buf_in = (int16_t *) malloc (buf_size_in); + int16_t *buf_remapped = (int16_t *) malloc (buf_size_remapped); + FILE *out_write_dump = fopen("/data/bt_call_before.pcm", "a"); +- fwrite(buffer, 1, bytesToTransfer, out_write_dump); ++ if (out_write_dump != NULL) { ++ LOG(ERROR) << "Writing to bt_call_before.pcm"; ++ fwrite(buffer, 1, bytesToTransfer, out_write_dump); ++ } else ++ LOG(ERROR) << "Failed to Write to bt_call_before.pcm"; + //resample from 48 to 8k + //adjust channel from 2 to 1 channel + if (voip_out_resampler == NULL) { +@@ -207,13 +226,21 @@ StreamAlsa::~StreamAlsa() { + adjust_channels(buf_in, PRIMARY_CHANNEL_COUNT , buf_remapped, HFP_CHANNEL_COUNT, + SAMPLE_SIZE_IN_BYTES, buf_size_in); + FILE *out_write_dump_1 = fopen("/data/bt_call_remapped.pcm", "a"); +- fwrite(buf_remapped, 1, bytesToTransfer, out_write_dump_1); ++ if (out_write_dump_1 != NULL) { ++ LOG(ERROR) << "Writing to bt_call_reamapped.pcm"; ++ fwrite(buf_remapped, 1, bytesToTransfer, out_write_dump_1); ++ } else ++ LOG(ERROR) << "Failed to write to bt_call_reamapped.pcm"; + + if(voip_out_resampler != NULL) + voip_out_resampler->resample_from_input(voip_out_resampler, (int16_t *)buf_remapped, (size_t *)&frames_in, (int16_t *) buf_out, (size_t *)&frames_out); + + FILE *out_write_dump_2 = fopen("/data/bt_call_after.pcm", "a"); +- fwrite(buf_out, 1, bytesToTransfer, out_write_dump_2); ++ if (out_write_dump_2 != NULL) { ++ LOG(ERROR) << "Writing to bt_call_after.pcm"; ++ fwrite(buf_out, 1, bytesToTransfer, out_write_dump_2); ++ } else ++ LOG(ERROR) << "Failed to Write to bt_call_after.pcm"; + + + proxy_write_with_retries(proxy.get(), buf_out, bytesToTransfer, mReadWriteRetries); +@@ -267,8 +294,11 @@ void StreamAlsa::shutdown() { + LOG(ERROR) << " In Func : " << __func__; + if(voip_out_resampler != NULL) { + release_resampler(voip_out_resampler); +- release_resampler(voip_in_resampler); + voip_out_resampler = NULL; ++ } ++ if(voip_out_resampler != NULL) { ++ release_resampler(voip_in_resampler); ++ voip_in_resampler = NULL; + } + mAlsaDeviceProxies.clear(); + } +diff --git a/audio/aidl/default/primary/PrimaryMixer.h b/audio/aidl/default/primary/PrimaryMixer.h +index 323a081011..06beb4065d 100644 +--- a/audio/aidl/default/primary/PrimaryMixer.h ++++ b/audio/aidl/default/primary/PrimaryMixer.h +@@ -37,8 +37,8 @@ class PrimaryMixer : public alsa::Mixer { + static PrimaryMixer& getInstance(); + static int get_pcm_card(const char* name) + { +- char id_filepath[30] = {0}; +- char number_filepath[30] = {0}; ++ char id_filepath[40] = {0}; ++ char number_filepath[40] = {0}; + ssize_t written; + + snprintf(id_filepath, sizeof(id_filepath), "/proc/asound/%s", name); +-- +2.34.1 + diff --git a/bsp_diff/caas/hardware/interfaces/0007-enable-dump.patch b/bsp_diff/caas/hardware/interfaces/0007-enable-dump.patch new file mode 100644 index 0000000000..9b2347c9b9 --- /dev/null +++ b/bsp_diff/caas/hardware/interfaces/0007-enable-dump.patch @@ -0,0 +1,88 @@ +From 35cecc8f3b9995d61529acb8c0c23caefe684824 Mon Sep 17 00:00:00 2001 +From: padmashree mandri +Date: Thu, 16 Jan 2025 16:48:27 +0000 +Subject: [PATCH] enable dump + +Signed-off-by: padmashree mandri +--- + audio/aidl/default/alsa/StreamAlsa.cpp | 43 +++++++++++++++++++++----- + 1 file changed, 36 insertions(+), 7 deletions(-) + +diff --git a/audio/aidl/default/alsa/StreamAlsa.cpp b/audio/aidl/default/alsa/StreamAlsa.cpp +index cc8093c28e..479933500e 100644 +--- a/audio/aidl/default/alsa/StreamAlsa.cpp ++++ b/audio/aidl/default/alsa/StreamAlsa.cpp +@@ -35,7 +35,13 @@ + #define PRIMARY_CHANNEL_COUNT 2 + #define HFP_CHANNEL_COUNT 1 + #define PRIMARY_SAMPLE_RATE 48000 +-#define HFP_SAMPLE_RATE 8000 ++#define HFP_SAMPLE_RATE 800i0 ++FILE *sco_call_write = NULL; ++FILE *sco_call_write_remapped = NULL; ++FILE *sco_call_write_bt = NULL; ++FILE *sco_call_read = NULL; ++FILE *sco_call_read_remapped = NULL; ++FILE *sco_call_read_bt = NULL; + struct resampler_itfe *voip_out_resampler; + struct resampler_itfe *voip_in_resampler; + namespace aidl::android::hardware::audio::core { +@@ -56,6 +62,17 @@ StreamAlsa::~StreamAlsa() { + ::android::status_t StreamAlsa::init() { + voip_out_resampler = NULL; + voip_in_resampler = NULL; ++ sco_call_write = fopen("/data/dump/sco_call_write.pcm", "a"); ++ sco_call_write_remapped = fopen("/data/dump/sco_call_write_remapped.pcm", "a"); ++ sco_call_write_bt = fopen("/data/dump/sco_call_write_bt.pcm", "a"); ++ sco_call_read = fopen("/data/dump/sco_call_read.pcm", "a"); ++ sco_call_read_remapped = fopen("/data/dump/sco_call_read_remapped.pcm", "a"); ++ sco_call_read_bt = fopen("/data/dump/sco_call_read_bt.pcm", "a"); ++ if(sco_call_write == NULL || sco_call_write_remapped == NULL || sco_call_write_bt == NULL || sco_call_read == NULL || ++ sco_call_read_bt == NULL || sco_call_read_remapped == NULL || out_write_dump == NULL || in_read_dump == NULL) ++ LOG(ERROR) << __func__ << "failed to open dump files"; ++ else ++ LOG(ERROR) << __func__ << "success in opening dump files"; + return mConfig.has_value() ? ::android::OK : ::android::NO_INIT; + } + +@@ -202,12 +219,6 @@ StreamAlsa::~StreamAlsa() { + int16_t *buf_out = (int16_t *) malloc (buf_size_out); + int16_t *buf_in = (int16_t *) malloc (buf_size_in); + int16_t *buf_remapped = (int16_t *) malloc (buf_size_remapped); +- FILE *out_write_dump = fopen("/data/bt_call_before.pcm", "a"); +- if (out_write_dump != NULL) { +- LOG(ERROR) << "Writing to bt_call_before.pcm"; +- fwrite(buffer, 1, bytesToTransfer, out_write_dump); +- } else +- LOG(ERROR) << "Failed to Write to bt_call_before.pcm"; + //resample from 48 to 8k + //adjust channel from 2 to 1 channel + if (voip_out_resampler == NULL) { +@@ -299,6 +310,24 @@ void StreamAlsa::shutdown() { + if(voip_out_resampler != NULL) { + release_resampler(voip_in_resampler); + voip_in_resampler = NULL; ++ } ++ if(sco_call_write != NULL) { ++ fclose(sco_call_write); ++ } ++ if(sco_call_write_remapped != NULL) { ++ fclose(sco_call_write_remapped); ++ } ++ if(sco_call_write_bt != NULL) { ++ fclose(sco_call_write_bt); ++ } ++ if(sco_call_read != NULL) { ++ fclose(sco_call_read); ++ } ++ if(sco_call_read_remapped != NULL) { ++ fclose(sco_call_read_remapped); ++ } ++ if(sco_call_read_bt != NULL) { ++ fclose(sco_call_read_bt); + } + mAlsaDeviceProxies.clear(); + } +-- +2.34.1 +