[Xiaomi Mi MIX 4] 0201m:
Thanks for the input. I did reflash the firmware, no change. I downlaoded a sensor test app and noticed a pattern. As long as there is no audio playing the test in the app works perfectly. But as soon as there is audio coming thourgh the top speaker, the ultrasound proximity sensors works 1/25 times and is really unresponsive. So i guess it has something to do with an audio route issue. Also i have to restart the test app so it reinitializes the seonsor, so definitely sounds like a audio route thing

I went through the logcat when starting the test in the working and non working usecase. The only two things different are the sensor initializations:

Working	Non working
05-09 23:39:43.658 790 2511 D ultrasound_extn: dump_usecase_list: start ======================================

05-09 23:39:43.659 790 2511 D ultrasound_extn: dump_usecase_list: enter state: 1[start] suspended: 0 cnt: 1 pre_cnt 0

05-09 23:39:43.661 790 2511 D ultrasound_extn: dump_usecase_list: RX_CDC_DMA_RX_0 SampleRate KHZ_48

05-09 23:39:43.662 790 2511 D ultrasound_extn: dump_usecase_list: RX_CDC_DMA_RX_0 Format S16_LE

05-09 23:39:43.662 790 2511 D ultrasound_extn: dump_usecase_list: RX_CDC_DMA_RX_0 Channels One

05-09 23:39:43.663 790 2511 D ultrasound_extn: dump_usecase_list: RX_CDC_DMA_RX_1 SampleRate KHZ_48

05-09 23:39:43.663 790 2511 D ultrasound_extn: dump_usecase_list: RX_CDC_DMA_RX_1 Format S16_LE

05-09 23:39:43.664 790 2511 D ultrasound_extn: dump_usecase_list: RX_CDC_DMA_RX_1 Channels Two

05-09 23:39:43.664 790 2511 D ultrasound_extn: dump_usecase_list: end ======================================	05-09 23:41:42.211 790 2511 D ultrasound_extn: dump_usecase_list: start ======================================

05-09 23:41:42.211 790 2511 D ultrasound_extn: dump_usecase_list: enter state: 1[start] suspended: 0 cnt: 1 pre_cnt 0

05-09 23:41:42.211 790 2511 D ultrasound_extn: dump_usecase_list: ultrasound_start usecase[#0]:(0, deep-buffer-playback) in_dev:(0, ) out_dv:(2, speaker)

05-09 23:41:42.213 790 2511 D ultrasound_extn: dump_usecase_list: RX_CDC_DMA_RX_0 SampleRate KHZ_48

05-09 23:41:42.214 790 2511 D ultrasound_extn: dump_usecase_list: RX_CDC_DMA_RX_0 Format S16_LE

05-09 23:41:42.215 790 2511 D ultrasound_extn: dump_usecase_list: RX_CDC_DMA_RX_0 Channels One

05-09 23:41:42.215 790 2511 D ultrasound_extn: dump_usecase_list: RX_CDC_DMA_RX_1 SampleRate KHZ_48

05-09 23:41:42.216 790 2511 D ultrasound_extn: dump_usecase_list: RX_CDC_DMA_RX_1 Format S16_LE

05-09 23:41:42.216 790 2511 D ultrasound_extn: dump_usecase_list: RX_CDC_DMA_RX_1 Channels Two

05-09 23:41:42.216 790 2511 D ultrasound_extn: dump_usecase_list: end =====================================
05-09 23:39:43.751 790 2511 D ultrasound_extn: dump_usecase_list: start ======================================

05-09 23:39:43.751 790 2511 D ultrasound_extn: dump_usecase_list: enter state: 1[start] suspended: 0 cnt: 1 pre_cnt 0

05-09 23:39:43.751 790 2511 D ultrasound_extn: dump_usecase_list: ultrasound_start usecase[#0]:(72, ultrasound-proximity-input) in_dev:(300, ultrasound-input) out_dv:(0, )

05-09 23:39:43.751 790 2511 D ultrasound_extn: dump_usecase_list: ultrasound_start usecase[#1]:(71, ultrasound-proximity-output) in_dev:(0, ) out_dv:(132, ultrasound-output)

05-09 23:39:43.752 790 2511 D ultrasound_extn: dump_usecase_list: RX_CDC_DMA_RX_0 SampleRate KHZ_48

05-09 23:39:43.753 790 2511 D ultrasound_extn: dump_usecase_list: RX_CDC_DMA_RX_0 Format S16_LE

05-09 23:39:43.754 790 2511 D ultrasound_extn: dump_usecase_list: RX_CDC_DMA_RX_0 Channels One

05-09 23:39:43.755 790 2511 D ultrasound_extn: dump_usecase_list: RX_CDC_DMA_RX_1 SampleRate KHZ_48

05-09 23:39:43.756 790 2511 D ultrasound_extn: dump_usecase_list: RX_CDC_DMA_RX_1 Format S16_LE

05-09 23:39:43.756 790 2511 D ultrasound_extn: dump_usecase_list: RX_CDC_DMA_RX_1 Channels Two

05-09 23:39:43.756 790 2511 D ultrasound_extn: dump_usecase_list: end ======================================	05-09 23:41:42.279 790 2511 D ultrasound_extn: dump_usecase_list: start ======================================

05-09 23:41:42.279 790 2511 D ultrasound_extn: dump_usecase_list: enter state: 1[start] suspended: 0 cnt: 1 pre_cnt 0

05-09 23:41:42.279 790 2511 D ultrasound_extn: dump_usecase_list: ultrasound_start usecase[#0]:(0, deep-buffer-playback) in_dev:(0, ) out_dv:(2, speaker)

05-09 23:41:42.279 790 2511 D ultrasound_extn: dump_usecase_list: ultrasound_start usecase[#1]:(72, ultrasound-proximity-input) in_dev:(300, ultrasound-input) out_dv:(0, )

05-09 23:41:42.279 790 2511 D ultrasound_extn: dump_usecase_list: ultrasound_start usecase[#2]:(71, ultrasound-proximity-output) in_dev:(0, ) out_dv:(2, speaker)

05-09 23:41:42.281 790 2511 D ultrasound_extn: dump_usecase_list: RX_CDC_DMA_RX_0 SampleRate KHZ_48

05-09 23:41:42.283 790 2511 D ultrasound_extn: dump_usecase_list: RX_CDC_DMA_RX_0 Format S16_LE

05-09 23:41:42.283 790 2511 D ultrasound_extn: dump_usecase_list: RX_CDC_DMA_RX_0 Channels One

05-09 23:41:42.284 790 2511 D ultrasound_extn: dump_usecase_list: RX_CDC_DMA_RX_1 SampleRate KHZ_48

05-09 23:41:42.285 790 2511 D ultrasound_extn: dump_usecase_list: RX_CDC_DMA_RX_1 Format S16_LE

05-09 23:41:42.285 790 2511 D ultrasound_extn: dump_usecase_list: RX_CDC_DMA_RX_1 Channels Two

05-09 23:41:42.285 790 2511 D ultrasound_extn: dump_usecase_list: end ======================================