sonyxperiadev / bug_tracker

Empty repository that is used as a bugtracker for Open Devices project
52 stars 13 forks source link

[LENA][11][4.19] Echo cancellation is not enabled for voice calls #771

Open sledges opened 2 years ago

sledges commented 2 years ago

Platform: lena Device: pdx213 xqbt52 (Xperia 10 III) Kernel version: 4.19.188-gadf298fa3900 Android version: AOSP11 android-11.0.0_r46 Software binaries version: SW_binaries_for_Xperia_Android_11_4.19_v9a_lena.img

Previously working on stock Sony Android 62.0.A.3.70 (also when reflashed via Emma to 62.0.A.3.109).

Description Echo cancellation does not work during phone call.

Symptoms Caller can hear their own voice when they make a call to Xperia 10 III (lena).

How to reproduce Make a phone call and ask the 3rd party to speak. They should not hear their own voice echoing back, but they do.

jerpelea commented 2 years ago

please compare the acdb ID used in stock with the ones used by AOSP

sledges commented 2 years ago

Logs during phonecall:

Stock:

$ adb logcat | grep ACDB | grep acdb_id -w
...
04-13 14:01:19.652   961  8581 D ACDB-LOADER: ACDB -> send_audio_cal, acdb_id = 14, path = 0, app id = 0x11131, sample rate = 48000, afe_sample_rate = 48000
04-13 14:01:19.652   961  8581 D ACDB-LOADER: ACDB -> AUDIO_SET_AUDPROC_CAL cal_type[11] acdb_id[14] app_type[69937]
04-13 14:01:19.652   961  8581 D ACDB-LOADER: ACDB -> AUDIO_SET_AFE_CAL cal_type[16] acdb_id[14]
04-13 14:01:19.652   961  8581 D ACDB-LOADER: ACDB -> send_hw_delay : acdb_id = 14 path = 0
04-13 14:01:23.650   961  1023 D ACDB-LOADER: ACDB -> AUDIO_SET_AFE_CAL cal_type[17] acdb_id[41]
04-13 14:01:23.650   961  1023 D ACDB-LOADER: ACDB -> AUDIO_SET_AFE_CAL cal_type[16] acdb_id[7]
04-13 14:01:23.650   961  1023 D ACDB-LOADER: ACDB -> send_hw_delay : acdb_id = 41 path = 1
04-13 14:01:23.650   961  1023 D ACDB-LOADER: ACDB -> send_hw_delay : acdb_id = 7 path = 0
04-13 14:01:23.820   961  1023 D ACDB-LOADER: ACDB -> send_audio_cal, acdb_id = 7, path = 0, app id = 0x11131, sample rate = 48000, afe_sample_rate = 48000
04-13 14:01:23.821   961  1023 D ACDB-LOADER: ACDB -> AUDIO_SET_AUDPROC_CAL cal_type[11] acdb_id[7] app_type[69937]

AOSP:

$ adb logcat | grep ACDB | grep acdb_id -w
...
01-19 18:30:42.398   739  2562 D ACDB-LOADER: ACDB -> AUDIO_SET_AUDPROC_CAL cal_type[11] acdb_id[124] app_type[69937]
01-19 18:30:42.398   739  2562 D ACDB-LOADER: ACDB -> AUDIO_SET_AFE_CAL cal_type[16] acdb_id[124]
01-19 18:30:42.399   739  2562 D ACDB-LOADER: ACDB -> send_hw_delay : acdb_id = 124 path = 0
01-19 18:30:46.303   739   739 D ACDB-LOADER: ACDB -> AUDIO_SET_AFE_CAL cal_type[17] acdb_id[41]
01-19 18:30:46.303   739   739 D ACDB-LOADER: ACDB -> AUDIO_SET_AFE_CAL cal_type[16] acdb_id[7]
01-19 18:30:46.303   739   739 D ACDB-LOADER: ACDB -> send_hw_delay : acdb_id = 41 path = 1
01-19 18:30:46.303   739   739 D ACDB-LOADER: ACDB -> send_hw_delay : acdb_id = 7 path = 0
01-19 18:30:46.465   739   739 D ACDB-LOADER: ACDB -> send_audio_cal, acdb_id = 7, path = 0, app id = 0x11131, sample rate = 48000, afe_sample_rate = 48000
01-19 18:30:46.465   739   739 D ACDB-LOADER: ACDB -> AUDIO_SET_AUDPROC_CAL cal_type[11] acdb_id[7] app_type[69937]
sledges commented 2 years ago

While following https://github.com/sonyxperiadev/device-sony-seine/commit/44f723ef9939be755e49c611a9dd32d0d048850f, here are more relevant acdb logs, that happen when switching on loudspeaker mode during phone call: AOSP:

audio_hw_primary: select_devices: changing use case voicemmode2-call output device from(20: voice-handset, acdb 7) to (21: voice-speaker, acdb 101)
audio_hw_primary: select_devices: changing use case voicemmode2-call input device from(171: voice-dmic-ef, acdb 41) to (174: voice-speaker-dmic-ef, acdb 43)

Stock:

audio_hw_primary: select_devices: changing use case voicemmode2-call output device from(27: voice-handset, acdb 7) to (31: voice-speaker-stereo, acdb 15)
audio_hw_primary: select_devices: changing use case voicemmode2-call input device from(195: voice-dmic-ef, acdb 41) to (178: voice-speaker-mic, acdb 11)

PR created to enable loudspeaker echo cancellation: https://github.com/sonyxperiadev/device-sony-lena/pull/14. To make sense, will have to be merged also with enabling mic for the loudspeaker: https://github.com/sonyxperiadev/device-sony-pdx213/pull/7.

sledges commented 2 years ago

I have however failed to enable echo cancellation for the ordinary phone call (via built-in speaker), even after reverting portions of acdb_ids from https://github.com/sonyxperiadev/device-sony-lena/commit/ec26526eb64d145e089180157b810033fadf202d which appeared seemingly relevant to an untrained eye (i.e. myself).

Namely because there is no difference in acdb IDs between AOSP and Stock when phone call is initiated (you can see them both being switched away from voice-handset, acdb 7 output and voice-dmic-ef, acdb 41 input in the logs of previous comment), thus I would not know where else to look.. Pointers always appreciated:)

sledges commented 2 years ago

Namely because there is no difference in acdb IDs between AOSP and Stock when phone call is initiated

Due to above reading this comment it seems that it won't be possible to fix this for phone calls..

mjun commented 1 year ago

@sonyxperiadev this looks like one of those bug we, the community, will not be able to fix easily without Sony help. As this bug does not exist in stock sony ROM can you please provide a fix for this? Thanks

Thaodan commented 1 year ago

The Edo Platform PDX203/PDX206 is also affected by this issue. Is one issue enough for all affected platforms?

pasikarkkainen commented 1 year ago

I'm curious if there are any updates to getting this issue fixed? Thanks!

jerpelea commented 1 year ago

unfortunately not yet

Segment0895 commented 1 year ago

If anyone else avoided buying the device because of this bug, place a thumbs up here.

Segment0895 commented 1 year ago

If anyone else avoided buying the device because of this bug, place a thumbs up here.

sledges commented 8 months ago

Here is a terrible workaround, which introduces a bigger bug, which at least can be avoided by never turning loudspeaker on:

So to be able to live life with your Xperia 10 III and make phone-calls without caller hearing the echo, do not use the loudspeaker feature altogether.

P.S. If you believe you did something wrong during the above steps, please just reflash the oem_a and oem_b partitions, and it will revert any changes you've made.

Background story (long read):

I could not live with this bug, because callers would hear their echo even through my headphones. So I dug deep into experiments with binary blobs, and after some divide'n'conquer, discovered it was the calibration library that was at fault with AOSP 11, that I was able to fix by taking the file from AOSP 12 binaries. It worked and I was about to post my solution, unfortunately, sometimes I would get complaints from callers that they can hear their voice echoing super loudly, making them extra angry :/ Spent even more months trying to call myself from another phone and testing, until realised that the 100-times worse echo (than originally in this bug) is caused by triggering loudspeaker during the "ringing" phase of the phone call (that's the 100% way to recreate this bug). Thus I avoided the use-case of tapping on loudspeaker during early seconds of making the call, but I did occasionally enable it during the call (as we do). I was still getting complaints (albeit rarely, e.g. once a week), that people still start hearing their extra loud voice echoing back. I then had to reboot the device to get rid of that state. I have since stopped using loudspeaker function completely, and not had an issue since, thus after many weeks of testing, I'm happy to share this with you, however at a price of sacrificing the loudspeaker ability.

I have also tried to extract the binary blobs from Sony's stock Android 11 and 12 (with greater difficulties), but replacing libaudcal.so from there was not enough, perhaps other files need to be included, but this goes way beyond my bandwidth to blindly poke at closed bits.

If anyone has more patience/braveness, it might be possible to re-test with Android 13 SW binaries for lena (v1 and v2), and share your findings here. I'm not sure that when (or if) we find a bug-free combo of those binaries, Sony could back-port them into AOSP 11 binary image, but until then it will remain just as a scriptlet above.

lkraav commented 8 months ago

At https://forum.sailfishos.org/t/android-13-and-sailfishos-on-xperia-10-iii/17431 user Wetab73 is reporting great successes of "everything bug free: no echo, no tint, etc" just flashing Android 13 AOSP under SFOS. Not sure if he's tested the loudspeaker like this :thinking:

I am on A11 AOSP and for whatever reason not experiencing the echo bug. But same, not sure if I've tested the loudspeaker like you describe. Will report back with data at one point.

Thaodan commented 6 months ago

I noticed on Xperia 1/5 II (Edo) calling with headphones works much better, I'm not sure if echo cancellation is involved here.

LouisDK1 commented 2 months ago

Here is a terrible workaround, which introduces a bigger bug, which at least can be avoided by never turning loudspeaker on:

If anyone has more patience/braveness, it might be possible to re-test with Android 13 SW binaries for lena (v1 and v2), and share your findings here. I'm not sure that when (or if) we find a bug-free combo of those binaries, Sony could back-port them into AOSP 11 binary image, but until then it will remain just as a scriptlet above.

Just tried with the 13 V4a binaries which resulted in no sound since pulseaudio refused to start after reboot. Luckily I was able to use your tutorial to get the 11 binaries back and sound has now been restored.

Will try flashing with another version later using this guide: https://forum.sailfishos.org/t/android-13-and-sailfishos-on-xperia-10-iii/17431/79