New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Seine][pdx201][AOSP10] Echo cancellation doesn't work in loud speaker mode #684
Comments
|
Fyi HFP is Bluetooth's Otherwise it makes little sense for the |
|
Well... this means that this investigation was for nothing. Though problem with lack of echo cancellation is still there. |
|
@AngryGami By the way thanks for using As for the issue itself echo cancellation has always been a tough problem with Sony using their own "audio devices" inside the HAL, ACDB being a black box and generally not enough time/resources/knowledge to properly dig into these :/ |
|
Does this mean that this won't be fixed anytime soon? |
|
@AngryGami the implementation used in the official SW and the OSS implementation are different. We can not estimate when it will be fixed or if it is even possible to fix it for this usecase on this specific device. |
|
@AngryGami if you want to help with the investigation you can compare which out device and which microphone are used on stock and with what is used on the OSS implementation if they are the same it can not be fixed otherwise it may be fixable |
|
@jerpelea This is not good news :( I've tried to compare stock and oss implementations regarding this. and OSS do this: So here is what <path name="dmic1">
<ctl name="TX_CDC_DMA_TX_3 Channels" value="One" />
<ctl name="TX_AIF1_CAP Mixer DEC0" value="1" />
<ctl name="TX DMIC MUX0" value="DMIC0" />
</path>
<path name="dmic1-adj-gain">
<ctl name="TX_DEC1 Volume" value="88" />
</path>
<path name="speaker-mic">
<path name="dmic1" />
<path name="dmic3-adj-gain" />
</path>
<path name="voice-speaker-mic">
<path name="speaker-mic" />
</path>and this is what oss have for mic: <path name="speaker-dmic-endfire">
<ctl name="TX_CDC_DMA_TX_3 Channels" value="Two" />
<ctl name="TX_AIF1_CAP Mixer DEC0" value="1" />
<ctl name="TX DMIC MUX0" value="DMIC2" />
<ctl name="TX_AIF1_CAP Mixer DEC1" value="1" />
<ctl name="TX DMIC MUX1" value="DMIC3" />
</path>
<path name="voice-speaker-dmic-ef">
<path name="speaker-dmic-endfire" />
</path>It is hard for me to make a lot of sense out of that but as far as I can understand - OSS version tries to use two microphones while stock only uses one. Though DMIC2 and DMIC3 are both "bottom" microphones while DMIC0 is "top" one (I've played with values a bit and figured this out). I also tried to match OSS configuration with what stock does and this didn't help either. Configuration that worked best for me (in terms of microphone gain and sound volume) is following: <path name="dmic1">
<ctl name="TX_CDC_DMA_TX_3 Channels" value="One" />
<ctl name="TX_AIF1_CAP Mixer DEC0" value="1" />
<ctl name="TX DMIC MUX0" value="DMIC0" />
</path>
<path name="speaker-mic">
<path name="dmic1" />
</path>
<path name="voice-speaker-dmic-ef">
<path name="speaker-mic" />
<ctl name="TX_DEC1 Volume" value="88" />
<ctl name="TX_DEC0 Volume" value="120" />
</path>
...
<path name="handset-as-speaker">
<ctl name="RX_MACRO RX0 MUX" value="AIF1_PB" />
<ctl name="RX_CDC_DMA_RX_0 Channels" value="One" />
<ctl name="RX INT0_1 MIX1 INP0" value="RX0" />
<ctl name="RX INT0 DEM MUX" value="CLSH_DSM_OUT" />
<ctl name="EAR_RDAC Switch" value="1" />
<ctl name="RDAC3_MUX" value="RX1" />
<ctl name="RX_RX0 Digital Volume" value="112" />
</path>
<path name="speaker">
<ctl name="PCM Source" value="DSP" />
<path name="handset-as-speaker" />
</path>
<path name="speaker-mono">
<path name="speaker" />
</path>
<path name="voice-speaker">
<path name="speaker-mono" />
<ctl name="ASP TX1 Source" value="VMON" />
</path>So I've made phone use top microphone and bottom speaker in loudspeaker mode. This kinda mitigated lack of echo cancellation a bit (because speaker and microphone are further apart) but I'm not sure that was a step in proper direction.
and mixer path with this name look like this (identical to stock): <path name="voicemmode1-call">
<ctl name="PRI_MI2S_RX_Voice Mixer VoiceMMode1" value="1" />
<ctl name="VoiceMMode1_Tx Mixer TX_CDC_DMA_TX_3_MMode1" value="1" />
</path>
<path name="voicemmode1-call voice-speaker-stereo">
<ctl name="VOC_EXT_EC MUX" value="PRI_MI2S_TX" />
<path name="voicemmode1-call" />
</path>it doesn't have any references to neither |
|
Speaker config for stock is: <path name="speaker">
<ctl name="PCM Source" value="DSP" />
</path>
<path name="voice-speaker-stereo">
<path name="speaker" />
<ctl name="ASP TX1 Source" value="VMON" />
</path>and for AOSP it is: <path name="handset-as-speaker">
<ctl name="RX_MACRO RX0 MUX" value="AIF1_PB" />
<ctl name="RX_CDC_DMA_RX_0 Channels" value="One" />
<ctl name="RX INT0_1 MIX1 INP0" value="RX0" />
<ctl name="RX INT0 DEM MUX" value="CLSH_DSM_OUT" />
<ctl name="EAR_RDAC Switch" value="1" />
<ctl name="RDAC3_MUX" value="RX1" />
<ctl name="RX_RX0 Digital Volume" value="92" />
</path>
<path name="speaker">
<ctl name="PCM Source" value="DSP" />
<path name="handset-as-speaker" />
</path>
<path name="speaker-mono">
<path name="speaker" />
</path>
<path name="voice-speaker">
<path name="speaker-mono" />
<ctl name="ASP TX1 Source" value="VMON" />
</path>Which again, doesn't make a lot of sense to me. Though without this "handset-as-speaker" part (which apparently the only major difference between these two) - sound in general (i.e. ringing sound and music) disappears. |
Note that acdb ids for speaker and microphones are different between OSS and stock - is this fine? Especially considering |
|
@AngryGami please set the same device ID on AOSP as on stock and check if the issue is solved |
|
How? |
|
@MarijnS95 do you have time to explain ? |
|
I see that in // device names table
[SND_DEVICE_IN_VOICE_SPEAKER_DMIC] = "voice-speaker-dmic-ef",
[SND_DEVICE_OUT_VOICE_SPEAKER] = "voice-speaker",
...
// acdb_ids table
[SND_DEVICE_IN_VOICE_SPEAKER_DMIC] = 43,
[SND_DEVICE_OUT_VOICE_SPEAKER] = 14,i.e. |
|
It seems that ./device/sony/common/common-prop.mk:198: vendor.audio.feature.spkr_prot.enable=true \So I've disabled it :) and it made problem much much much worse :) |
|
Wow, that's a lot of unrelated to noise to wade through... @AngryGami how about this: https://github.com/search?q=user%3Asonyxperiadev+acdb&type=commits In case you want to override the acdb id from qcom's defaults (stemming from But the issue seems to be with the selected usecase. I hope you can find out for yourself how to change the usecase instead of bugging poor Marijn who is overworked already. Related: #683 |
|
Sorry for making you "wade through" my "unrelated noise".
or this:
I have very poor understanding of what this system is for and what tasks it performs and why. What chain you are talking about? Chain in the code somewhere? Or chain of nested I know how to override acdb ids in |
|
@ix5 please relax and lets try to help people learn |
|
@AngryGami did you try changing that line to e.g. edo routes pretty much all speaker-related channels to the same id |
|
@ix5 Yep, that what I was doing entire day today (trying different variants). And yes, it looks like this helped with echo cancellation, though I had to tinker with microphone gain and speaker volume because sound is very distorted and there is a noticeable feedback (though this might be because of how I test stuff). |
|
That's good to know. If your changes indeed restore phone-speaker functionality during calls, you should make a pull request ASAP. |
|
@ix5 I don't know if this is a problem for Android 11. Maybe acdb files for Android 11 are different and values that are currently in |
|
In any case, I cannot reproduce any echo issues on calls on Android 11 on my pdx201. Please submit the updated acdb id(s) for Android 10. It would be great of you to upload a build of Android 10 somewhere (with verity disabled) so that I can reproduce your issue. BOARD_AVB_MAKE_VBMETA_IMAGE_ARGS += --flag 2 |
I will, as soon I done with all the tests I want to do. So far it looks very promising, though feedback is bothering me a bit still.
I'm not sure which issue you are talking about? Lack of echo cancellation? This seems to be fixed by changing acdb ids in |
I'd still like to take a look at an Android 10 build. Just |
|
@ix5 you keep throwing things at me that I either don't understand or don't know how to do. Image that I have now doesn't have this issue anymore and the only thing that I've changed was these acdb ids. I don't have any shared hosting to put several GB of these files and my image contain some custom signatures and applications that I can't distribute. You are asking me to change my build config to exclude everything that I've added/changed, make a build with additional flags that I don't understand and don't know where to put only because you can't reproduce echo cancellation problem? This is kinda over top of my head currently. |
|
I am asking you to provide a ready-made build so that I don't have to set up my own A10 build environment. Simply overriding the acdb ids might "solve" your issue, but the root cause is still interesting to us. And I have a looming suspicion this won't be the last "bug" you open issues for. If you don't want to go to that (comparatively very minimal imo) effort, I don't know what to tell you. |
|
Ok, here is ota zip. |
|
So I can conclude that after these changes in |
|
@AngryGami please push the needed changes |
|
@jerpelea What is wrong with pull request above? |
|
cherry-picked |
Platform: Seine
Device: pdx201
Kernel version: 4.14 (be667ecc267b81)
Android version: 10
Software binaries version: SW_binaries_for_Xperia_Android_10.0.7.1_r1_v12b_seine.img
Previously working on
Stock image doesn't have this issue.
Description
When in regular (GSM/LTE) phone call and enable loud speaker microphone on the device starts picking sound from the speaker creating annoying echo on the other side of the call.
How to reproduce
Make a call, enable loud speaker and hear echo on the other end of the call.
Additional context
I made some investigation of this problem but eventually get out of ideas what might be the reason for this. So here what I've found so far:
mixer_paths.xmlfile and noticed paths like these:These paths looks related to echo cancellation :)
platform_set_echo_referencefunction invendor/qcom/opensource/audio-hal/primary-hal/hal/msm8974/platform.cfile (well one that is relevant for this platform at least). This method is called from several places, but it looks like one that is relevant to loud speaker mode is this:These are additional log statements I've added to track it down.
audio_extn_hfp_is_activeis defined invendor/qcom/opensource/audio-hal/primary-hal/hal/audio_extn/audio_extn.cand it checks ifhfp_is_activefunction is defined and call it for answer. This function only get defined ifvendor.audio.feature.hfp.enableproperty istrueand it is set to true indevice/sony/common/common-prop.mk. I see followint log messages in both stock and aosp logs:But but aosp version cannot enable this properly because it can't find
libhfp.solibrary, so I have to include it into my mk file like this:After had done that I got following messages in aosp image log:
Though this was not enough to make
hfp_is_activeto return true during call because even feature is enabled it was not initialized properly.hfp_is_activeis defined invendor/qcom/opensource/audio-hal/primary-hal/hal/audio_extn/hfp.c" file and call intofp_get_usecase_from_list`:Again, additional logging added by me. This
fp_get_usecase_from_listfunction comes fromaudio_extn.cfile in form of reference toget_usecase_from_listfromvendor/qcom/opensource/audio-hal/primary-hal/hal/audio_hw.c. This function just goes through list of all usecases that are assigned toadevstruct and looking forUSECASE_AUDIO_HFP_SCO, which is added bystart_hfpfunction like this:I'm not very familiar with C and this took me a while to understand that this is basically "append" operation, especially confusing is
uc_info->listsince this is not actually "list" but rather a "listnode".Anyway I started looking what is calling this
start_hfpfunction.hfp.cfile fromhfp_set_parametersfunction, but there is a condition around it:I.e. it will only get invoked if
AUDIO_PARAMETER_HFP_ENABLEconfiguration parameter is set to "true". This parameter could be set viaaudio_platform_info.xml<config_params>section, so I did that and now my device refused to boot because of following error:Looking at this error closely I saw that this is merely an NPE (Null pointer exception) somewhere in
platform_set_mic_mutefunction, so I've looked into it and eventually found that it was invoked withplatformparameter being null and this happens because at the moment whenstart_hfpget calledadev->platformis not yet initialized. Actually it is called from inside function that right now initializes this field inaudio_hw.c:I.e. it calls it prematurely and this
start_hfphave to be delayed. I've fixed this error by addingis_hfp_enabled_by_configintohfp_modulestruct and by adding some sanity checks inhfp_set_parametersfunction.hfp_set_parametersget called multiple times and if platform is not initialized at first call - I just store flag that it need to be initialized next time.hfpstarts and I gotusecase for hfp foundmessage in the logs and I assumed that this is enough to enable echo cancellation.... though it isn't. Even that I gotstart_hfpinvoked it immediately stops because devices it tries to open/use are either do not exist or do not respond properly. This happens here instart_hfpfunction:Related logs looks like this:
Initially it failed at attempt to call
pcm_openand bark something like/dev/snd/pcmC0D39p does't existsand it ideed does not exist on device (only 'c' ending one does):I know that
pstands for "playback" andcfor capture, and I also know that devices it will try to use controlled by eitherhfp_pcm_dev_idparameter in<config_params>section ofaudio_platform.xmlor by definitions of usecases inpcm_idssection of the same file. So I've tried to assign them to some values that will match existing sound devices, though this didn't work either. This time it failed atpcm_startcall with error like this:I can assume that I choose devices for this poorly (I was basically guessing) and if someone knows what values should be - I would very much appreciate your advice.
And one last note... I don't know if all of the above make any sense (i.e. at all related to lack of echo cancellation) because
HFPstands forHands free profileand apparently have something to do with bluetooth. Though I do see that it get mentioned in code path for enabling speaker. If someone knows if this is at all a correct goal to pursue for solving this issue - please tell me.The text was updated successfully, but these errors were encountered: