diff --git a/Android.mk b/Android.mk index 0f71bc43..c029d8b3 100644 --- a/Android.mk +++ b/Android.mk @@ -189,6 +189,12 @@ else LOCAL_SRC_FILES += utils/src/BTUtils.cpp endif +ifeq ($(TARGET_DISABLE_PAL_UVVOICECUE),true) +LOCAL_CFLAGS += -DUVVOICECUE_FEATURES_DISABLED +else +LOCAL_SRC_FILES += utils/src/UvVoiceCueUtils.cpp +endif + include $(BUILD_SHARED_LIBRARY) #------------------------------------------- diff --git a/Makefile.am b/Makefile.am index ed745a81..fd9ce911 100644 --- a/Makefile.am +++ b/Makefile.am @@ -80,8 +80,14 @@ pal_sources = $(top_srcdir)/stream/src/Stream.cpp \ $(top_srcdir)/utils/src/BTUtils.cpp endif + +if COMPILE_UVVOICECUE_FEATURES +pal_sources += $(top_srcdir)/utils/src/UvVoiceCueUtils.cpp +endif + AM_CPPFLAGS += -D__unused=__attribute__\(\(__unused__\)\) -DLINUX_ENABLED AM_CPPFLAGS += -DCONFIG_GSL +AM_CPPFLAGS += @UVVOICECUE_FEATURE_FLAGS@ library_includedir = $(includedir)/pal lib_LTLIBRARIES = libpal.la diff --git a/configs/qcom/IoT/shikra/mixer_paths_shikra_cpu.xml b/configs/qcom/IoT/shikra/mixer_paths_shikra_cpu.xml index e5ee5495..f34b994e 100644 --- a/configs/qcom/IoT/shikra/mixer_paths_shikra_cpu.xml +++ b/configs/qcom/IoT/shikra/mixer_paths_shikra_cpu.xml @@ -509,6 +509,31 @@ + + + + + + + + + + + + + + + + + + + + + + + + + @@ -533,7 +558,7 @@ - + @@ -550,7 +575,7 @@ - + @@ -561,14 +586,16 @@ - - - - + + + + - - + + + + diff --git a/configs/qcom/IoT/shikra/mixer_paths_shikra_dsp.xml b/configs/qcom/IoT/shikra/mixer_paths_shikra_dsp.xml index e5ee5495..ab255475 100644 --- a/configs/qcom/IoT/shikra/mixer_paths_shikra_dsp.xml +++ b/configs/qcom/IoT/shikra/mixer_paths_shikra_dsp.xml @@ -509,6 +509,31 @@ + + + + + + + + + + + + + + + + + + + + + + + + + @@ -533,7 +558,7 @@ - + @@ -550,7 +575,7 @@ - + @@ -560,15 +585,18 @@ + - - - - + + + + - - + + + + diff --git a/configs/qcom/IoT/shikra/resourcemanager_shikra_cpu.xml b/configs/qcom/IoT/shikra/resourcemanager_shikra_cpu.xml index 4fe7a102..9ca89269 100644 --- a/configs/qcom/IoT/shikra/resourcemanager_shikra_cpu.xml +++ b/configs/qcom/IoT/shikra/resourcemanager_shikra_cpu.xml @@ -127,7 +127,7 @@ PCM_RT_PROXY-TX-2 2 1 - headset-mic + headset-va-mic 0 PAL_STREAM_LOW_LATENCY @@ -150,7 +150,7 @@ PAL_DEVICE_NONE - QAIF-QAIF_AUD-RX-1 + PCM_RT_PROXY-RX-2 2 1 none diff --git a/configs/qcom/IoT/shikra/resourcemanager_shikra_dsp.xml b/configs/qcom/IoT/shikra/resourcemanager_shikra_dsp.xml index 77ebf26f..fdb16128 100644 --- a/configs/qcom/IoT/shikra/resourcemanager_shikra_dsp.xml +++ b/configs/qcom/IoT/shikra/resourcemanager_shikra_dsp.xml @@ -137,7 +137,7 @@ CODEC_DMA-QAIF-TX-0 2 1 - headset-mic + headset-va-mic 0 PAL_STREAM_LOW_LATENCY @@ -212,7 +212,7 @@ PAL_DEVICE_OUT_SPEAKER - QAIF-QAIF_AUD-RX-1 + QAIF-QAIF_AUD-RX-2 2 2 48000 @@ -256,7 +256,7 @@ PAL_DEVICE_OUT_HANDSET - QAIF-QAIF_AUD-RX-1 + QAIF-QAIF_AUD-RX-2 2 1 @@ -268,7 +268,7 @@ PAL_DEVICE_OUT_WIRED_HEADPHONE - CODEC_DMA-QAIF-RX-2 + CODEC_DMA-QAIF-RX-1 2 2 1 @@ -276,7 +276,7 @@ PAL_DEVICE_OUT_WIRED_HEADSET - CODEC_DMA-QAIF-RX-2 + CODEC_DMA-QAIF-RX-1 2 2 1 diff --git a/configs/qcom/compute/hamoa_la/mixer_paths_hamoa_x1e80100_crd_wsa884x.xml b/configs/qcom/compute/hamoa_la/mixer_paths_hamoa_x1e80100_crd_wsa884x.xml index dceb9ab7..2930ea73 100644 --- a/configs/qcom/compute/hamoa_la/mixer_paths_hamoa_x1e80100_crd_wsa884x.xml +++ b/configs/qcom/compute/hamoa_la/mixer_paths_hamoa_x1e80100_crd_wsa884x.xml @@ -27,7 +27,7 @@ * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * Changes from Qualcomm Technologies, Inc. are provided under the following license: -* Copyright (c) Qualcomm Technologies, Inc. and/or its subsidiaries. +* Copyright (c) Qualcomm Technologies, Inc. and/or its subsidiaries. * SPDX-License-Identifier: BSD-3-Clause-Clear * --> @@ -72,6 +72,8 @@ + + @@ -845,9 +847,9 @@ - + - + @@ -960,13 +962,13 @@ - + - + @@ -1161,12 +1163,36 @@ + + + + + + + + + + + + + + + + + + + + + + + + @@ -1254,12 +1280,16 @@ + + + + @@ -1273,8 +1303,12 @@ + + + + @@ -1290,6 +1324,11 @@ + + + + + diff --git a/configs/qcom/compute/hamoa_la/mixer_paths_hamoa_x1e80100_qcp_wsa884x.xml b/configs/qcom/compute/hamoa_la/mixer_paths_hamoa_x1e80100_qcp_wsa884x.xml index af2d9c12..28adb41c 100644 --- a/configs/qcom/compute/hamoa_la/mixer_paths_hamoa_x1e80100_qcp_wsa884x.xml +++ b/configs/qcom/compute/hamoa_la/mixer_paths_hamoa_x1e80100_qcp_wsa884x.xml @@ -1,5 +1,6 @@ + @@ -76,6 +80,7 @@ + @@ -97,6 +102,7 @@ + @@ -135,6 +141,7 @@ + @@ -175,6 +182,7 @@ + @@ -185,6 +193,7 @@ + @@ -193,24 +202,30 @@ + + + + + + @@ -220,220 +235,293 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -453,22 +541,28 @@ + + + + + + @@ -476,6 +570,7 @@ + @@ -483,6 +578,7 @@ + @@ -490,13 +586,16 @@ + + + @@ -512,14 +611,17 @@ + + + @@ -534,6 +636,7 @@ + @@ -549,55 +652,73 @@ + + + + + + + + + + + + + + + + + + @@ -606,6 +727,7 @@ + @@ -617,6 +739,7 @@ + @@ -631,14 +754,17 @@ + + + @@ -647,6 +773,7 @@ + @@ -658,6 +785,7 @@ + @@ -672,9 +800,11 @@ + + @@ -688,6 +818,7 @@ + @@ -701,9 +832,11 @@ + + @@ -711,76 +844,98 @@ + + + + + + + + + + + + + + + + + + + + + + @@ -789,6 +944,7 @@ + @@ -797,10 +953,13 @@ + + + @@ -811,20 +970,26 @@ + + + + + + @@ -835,6 +1000,7 @@ + @@ -845,6 +1011,7 @@ + @@ -852,6 +1019,7 @@ + @@ -859,6 +1027,7 @@ + @@ -869,6 +1038,7 @@ + @@ -876,6 +1046,7 @@ + @@ -883,16 +1054,21 @@ + + + + + @@ -901,23 +1077,30 @@ + + + + + + + @@ -931,27 +1114,35 @@ + + + + + + + + @@ -995,6 +1186,7 @@ + @@ -1002,9 +1194,11 @@ + + @@ -1014,15 +1208,18 @@ + + + @@ -1035,10 +1232,12 @@ + + @@ -1051,26 +1250,32 @@ + + + + + + @@ -1078,6 +1283,7 @@ + @@ -1085,6 +1291,7 @@ + @@ -1092,6 +1299,7 @@ + @@ -1102,26 +1310,33 @@ + + + + + + + @@ -1133,6 +1348,7 @@ + @@ -1144,6 +1360,7 @@ + diff --git a/configs/qcom/compute/hamoa_la/resourcemanager_hamoa_x1e80100_crd_wsa884x.xml b/configs/qcom/compute/hamoa_la/resourcemanager_hamoa_x1e80100_crd_wsa884x.xml index ac3b1770..60974bd2 100644 --- a/configs/qcom/compute/hamoa_la/resourcemanager_hamoa_x1e80100_crd_wsa884x.xml +++ b/configs/qcom/compute/hamoa_la/resourcemanager_hamoa_x1e80100_crd_wsa884x.xml @@ -40,7 +40,7 @@ - + @@ -132,8 +132,8 @@ - - + + @@ -477,7 +477,7 @@ PAL_DEVICE_IN_BLUETOOTH_SCO_HEADSET - BTFM_PROXY-TX-0 + SLIM-DEV1-TX-7 1 1 8000 @@ -620,8 +620,8 @@ PAL_DEVICE_IN_VI_FEEDBACK CODEC_DMA-LPAIF_WSA-TX-0 - 2 - 2 + 4 + 4 8000 32 vi-feedback @@ -645,9 +645,23 @@ cps-feedback-mono-2 + + PAL_DEVICE_IN_CPS2_FEEDBACK + CODEC_DMA-LPAIF_WSA2-TX-2 + 2 + 2 + 24000 + 32 + wsa2-cps-feedback + + PAL_STREAM_VOICE_CALL + 1 + cps-feedback-mono-2 + + PAL_DEVICE_IN_BLUETOOTH_A2DP - BTFM_PROXY-TX-0 + SLIM-DEV1-TX-7 1 1 bt-a2dp-mic @@ -656,7 +670,7 @@ PAL_DEVICE_IN_BLUETOOTH_BLE - BTFM_PROXY-TX-0 + SLIM-DEV1-TX-7 1 1 bt-ble-mic @@ -749,7 +763,7 @@ PAL_DEVICE_IN_BLUETOOTH_HFP - BTFM_PROXY-TX-1 + SLIM-DEV1-TX-7 1 1 8000 @@ -780,8 +794,8 @@ PAL_DEVICE_OUT_SPEAKER CODEC_DMA-LPAIF_WSA-RX-0 - 2 - 2 + 4 + 4 48000 speaker 1 @@ -808,7 +822,7 @@ - PAL_AUDIO_FMT_PCM_S24_LE + PAL_AUDIO_FMT_PCM_S16_LE 0 0 - 0 + 30 PAL_STREAM_VOICE_CALL 1 @@ -957,7 +971,7 @@ PAL_DEVICE_OUT_BLUETOOTH_A2DP - BTFM_PROXY-RX-0 + SLIM-DEV1-RX-7 1 1 bt-a2dp @@ -970,7 +984,7 @@ PAL_DEVICE_OUT_BLUETOOTH_BLE - BTFM_PROXY-RX-0 + SLIM-DEV1-RX-7 1 1 bt-ble @@ -983,7 +997,7 @@ PAL_DEVICE_OUT_BLUETOOTH_BLE_BROADCAST - BTFM_PROXY-RX-0 + SLIM-DEV1-RX-7 1 1 bt-ble @@ -992,7 +1006,7 @@ PAL_DEVICE_OUT_BLUETOOTH_SCO - BTFM_PROXY-RX-0 + SLIM-DEV1-RX-7 1 1 bt-sco @@ -1191,7 +1205,7 @@ PAL_DEVICE_OUT_BLUETOOTH_HFP - BTFM_PROXY-RX-1 + SLIM-DEV1-RX-7 1 1 bt-hfp diff --git a/configs/qcom/compute/hamoa_la/resourcemanager_hamoa_x1e80100_qcp_wsa884x.xml b/configs/qcom/compute/hamoa_la/resourcemanager_hamoa_x1e80100_qcp_wsa884x.xml index 5512e7e2..60974bd2 100644 --- a/configs/qcom/compute/hamoa_la/resourcemanager_hamoa_x1e80100_qcp_wsa884x.xml +++ b/configs/qcom/compute/hamoa_la/resourcemanager_hamoa_x1e80100_qcp_wsa884x.xml @@ -1,5 +1,6 @@ + 2.0 @@ -36,7 +40,7 @@ - + @@ -473,7 +477,7 @@ PAL_DEVICE_IN_BLUETOOTH_SCO_HEADSET - BTFM_PROXY-TX-0 + SLIM-DEV1-TX-7 1 1 8000 @@ -641,9 +645,23 @@ cps-feedback-mono-2 + + PAL_DEVICE_IN_CPS2_FEEDBACK + CODEC_DMA-LPAIF_WSA2-TX-2 + 2 + 2 + 24000 + 32 + wsa2-cps-feedback + + PAL_STREAM_VOICE_CALL + 1 + cps-feedback-mono-2 + + PAL_DEVICE_IN_BLUETOOTH_A2DP - BTFM_PROXY-TX-0 + SLIM-DEV1-TX-7 1 1 bt-a2dp-mic @@ -652,7 +670,7 @@ PAL_DEVICE_IN_BLUETOOTH_BLE - BTFM_PROXY-TX-0 + SLIM-DEV1-TX-7 1 1 bt-ble-mic @@ -745,7 +763,7 @@ PAL_DEVICE_IN_BLUETOOTH_HFP - BTFM_PROXY-TX-1 + SLIM-DEV1-TX-7 1 1 8000 @@ -953,7 +971,7 @@ PAL_DEVICE_OUT_BLUETOOTH_A2DP - BTFM_PROXY-RX-0 + SLIM-DEV1-RX-7 1 1 bt-a2dp @@ -966,7 +984,7 @@ PAL_DEVICE_OUT_BLUETOOTH_BLE - BTFM_PROXY-RX-0 + SLIM-DEV1-RX-7 1 1 bt-ble @@ -979,7 +997,7 @@ PAL_DEVICE_OUT_BLUETOOTH_BLE_BROADCAST - BTFM_PROXY-RX-0 + SLIM-DEV1-RX-7 1 1 bt-ble @@ -988,7 +1006,7 @@ PAL_DEVICE_OUT_BLUETOOTH_SCO - BTFM_PROXY-RX-0 + SLIM-DEV1-RX-7 1 1 bt-sco @@ -1187,7 +1205,7 @@ PAL_DEVICE_OUT_BLUETOOTH_HFP - BTFM_PROXY-RX-1 + SLIM-DEV1-RX-7 1 1 bt-hfp diff --git a/configs/qcom/compute/hamoa_la/usecaseKvManager.xml b/configs/qcom/compute/hamoa_la/usecaseKvManager.xml index b7e3513c..c52d71a9 100644 --- a/configs/qcom/compute/hamoa_la/usecaseKvManager.xml +++ b/configs/qcom/compute/hamoa_la/usecaseKvManager.xml @@ -26,6 +26,7 @@ * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * Changes from Qualcomm Technologies, Inc. are provided under the following license: * Copyright (c) Qualcomm Technologies, Inc. and/or its subsidiaries. * SPDX-License-Identifier: BSD-3-Clause-Clear @@ -665,6 +666,13 @@ + + + + + + + @@ -1322,8 +1330,6 @@ - - diff --git a/configs/qcom/mobile/art/mixer_paths_art_mtp_qmp.xml b/configs/qcom/mobile/art/mixer_paths_art_mtp_qmp.xml index 644bcb4c..cbe46dee 100644 --- a/configs/qcom/mobile/art/mixer_paths_art_mtp_qmp.xml +++ b/configs/qcom/mobile/art/mixer_paths_art_mtp_qmp.xml @@ -1222,7 +1222,14 @@ - + + + + + + + + diff --git a/configs/qcom/mobile/art/mixer_paths_art_qrd.xml b/configs/qcom/mobile/art/mixer_paths_art_qrd.xml index 5c649bbf..f687592c 100644 --- a/configs/qcom/mobile/art/mixer_paths_art_qrd.xml +++ b/configs/qcom/mobile/art/mixer_paths_art_qrd.xml @@ -479,8 +479,8 @@ - - + + @@ -747,13 +747,14 @@ - + - - - - - + + + + + + @@ -764,18 +765,18 @@ - + - + - + - + - + - + @@ -792,27 +793,27 @@ - + + - - - - + + - - + + - + + + - + - @@ -832,10 +833,10 @@ - + - + @@ -1222,17 +1223,17 @@ - + - + - - - - - - + + + + + + @@ -1393,8 +1394,8 @@ - - + + @@ -1405,8 +1406,8 @@ - - + + @@ -1424,18 +1425,18 @@ - + - + - - + + diff --git a/configs/qcom/mobile/art/mixer_paths_pebble_mtp_wcd9378.xml b/configs/qcom/mobile/art/mixer_paths_pebble_mtp_wcd9378.xml index fad166b5..5747b0bb 100644 --- a/configs/qcom/mobile/art/mixer_paths_pebble_mtp_wcd9378.xml +++ b/configs/qcom/mobile/art/mixer_paths_pebble_mtp_wcd9378.xml @@ -351,10 +351,10 @@ - - - - + + + + @@ -366,10 +366,10 @@ - - - - + + + + diff --git a/configs/qcom/mobile/art/mixer_paths_pebble_qrd.xml b/configs/qcom/mobile/art/mixer_paths_pebble_qrd.xml index 06222c41..c1576c77 100644 --- a/configs/qcom/mobile/art/mixer_paths_pebble_qrd.xml +++ b/configs/qcom/mobile/art/mixer_paths_pebble_qrd.xml @@ -477,8 +477,8 @@ - - + + diff --git a/configs/qcom/mobile/art/resourcemanager_art_cdp.xml b/configs/qcom/mobile/art/resourcemanager_art_cdp.xml index e38e429d..5653ea8f 100644 --- a/configs/qcom/mobile/art/resourcemanager_art_cdp.xml +++ b/configs/qcom/mobile/art/resourcemanager_art_cdp.xml @@ -206,6 +206,9 @@ PAL_STREAM_VOIP_TX 2 1 + + 0 + PAL_STREAM_VOICE_CALL @@ -233,6 +236,9 @@ 4 quad-mic + + OFF + PAL_STREAM_ULTRA_LOW_LATENCY @@ -333,6 +339,9 @@ PAL_STREAM_VOIP_TX 2 1 + + 0 + PAL_STREAM_VOICE_CALL @@ -364,6 +373,9 @@ 4 quad-mic + + OFF + PAL_STREAM_LOOPBACK @@ -422,6 +434,9 @@ 48000 16 1 + + 0 + PAL_STREAM_VOICE_CALL @@ -434,6 +449,9 @@ 1 headset-mic + + OFF + PAL_STREAM_ULTRA_LOW_LATENCY @@ -524,6 +542,9 @@ PAL_STREAM_VOIP_TX 1 + + 0 + PAL_STREAM_LOW_LATENCY @@ -549,6 +570,9 @@ 1 HW 1 + + OFF + PAL_STREAM_ULTRA_LOW_LATENCY @@ -1823,7 +1847,7 @@ - + @@ -1835,7 +1859,7 @@ - + diff --git a/configs/qcom/mobile/art/resourcemanager_art_mtp.xml b/configs/qcom/mobile/art/resourcemanager_art_mtp.xml index 16a345c6..e964dad5 100644 --- a/configs/qcom/mobile/art/resourcemanager_art_mtp.xml +++ b/configs/qcom/mobile/art/resourcemanager_art_mtp.xml @@ -235,6 +235,9 @@ PAL_STREAM_VOIP_TX 2 1 + + 0 + PAL_STREAM_VOICE_CALL @@ -262,6 +265,9 @@ 4 quad-mic + + OFF + PAL_STREAM_ULTRA_LOW_LATENCY @@ -362,6 +368,9 @@ PAL_STREAM_VOIP_TX 2 1 + + 0 + PAL_STREAM_VOICE_CALL @@ -393,6 +402,9 @@ 4 quad-mic + + OFF + PAL_STREAM_LOOPBACK @@ -452,6 +464,9 @@ 48000 16 1 + + 0 + PAL_STREAM_VOICE_CALL @@ -464,6 +479,9 @@ 1 headset-mic + + OFF + PAL_STREAM_ULTRA_LOW_LATENCY @@ -554,6 +572,9 @@ PAL_STREAM_VOIP_TX 1 + + 0 + PAL_STREAM_LOW_LATENCY @@ -579,6 +600,9 @@ 1 HW 1 + + OFF + PAL_STREAM_ULTRA_LOW_LATENCY @@ -1851,7 +1875,7 @@ - + @@ -1863,7 +1887,7 @@ - + diff --git a/configs/qcom/mobile/art/resourcemanager_art_mtp_qmp.xml b/configs/qcom/mobile/art/resourcemanager_art_mtp_qmp.xml index 42443d4b..c2052e14 100644 --- a/configs/qcom/mobile/art/resourcemanager_art_mtp_qmp.xml +++ b/configs/qcom/mobile/art/resourcemanager_art_mtp_qmp.xml @@ -235,6 +235,9 @@ PAL_STREAM_VOIP_TX 2 1 + + 0 + PAL_STREAM_VOICE_CALL @@ -262,6 +265,9 @@ 4 quad-mic + + OFF + PAL_STREAM_ULTRA_LOW_LATENCY @@ -362,6 +368,9 @@ PAL_STREAM_VOIP_TX 2 1 + + 0 + PAL_STREAM_VOICE_CALL @@ -393,6 +402,9 @@ 4 quad-mic + + OFF + PAL_STREAM_LOOPBACK @@ -452,6 +464,9 @@ 48000 16 1 + + 0 + PAL_STREAM_VOICE_CALL @@ -464,6 +479,9 @@ 1 headset-mic + + OFF + PAL_STREAM_ULTRA_LOW_LATENCY @@ -554,6 +572,9 @@ PAL_STREAM_VOIP_TX 1 + + 0 + PAL_STREAM_LOW_LATENCY @@ -579,6 +600,9 @@ 1 HW 1 + + OFF + PAL_STREAM_ULTRA_LOW_LATENCY @@ -1851,7 +1875,7 @@ - + @@ -1863,7 +1887,7 @@ - + diff --git a/configs/qcom/mobile/art/resourcemanager_art_qrd.xml b/configs/qcom/mobile/art/resourcemanager_art_qrd.xml index 9eb68856..b0a64be3 100644 --- a/configs/qcom/mobile/art/resourcemanager_art_qrd.xml +++ b/configs/qcom/mobile/art/resourcemanager_art_qrd.xml @@ -235,6 +235,9 @@ PAL_STREAM_VOIP_TX 2 1 + + 0 + PAL_STREAM_VOICE_CALL @@ -262,6 +265,9 @@ 4 quad-mic + + OFF + PAL_STREAM_ULTRA_LOW_LATENCY @@ -362,6 +368,9 @@ PAL_STREAM_VOIP_TX 2 1 + + 0 + PAL_STREAM_VOICE_CALL @@ -393,6 +402,9 @@ 4 quad-mic + + OFF + PAL_STREAM_LOOPBACK @@ -452,6 +464,9 @@ 48000 16 1 + + 0 + PAL_STREAM_VOICE_CALL @@ -464,6 +479,9 @@ 1 headset-mic + + OFF + PAL_STREAM_ULTRA_LOW_LATENCY @@ -554,6 +572,9 @@ PAL_STREAM_VOIP_TX 1 + + 0 + PAL_STREAM_LOW_LATENCY @@ -579,6 +600,9 @@ 1 HW 1 + + OFF + PAL_STREAM_ULTRA_LOW_LATENCY @@ -1852,7 +1876,7 @@ - + @@ -1864,7 +1888,7 @@ - + diff --git a/configs/qcom/mobile/art/resourcemanager_art_qrd_qmp.xml b/configs/qcom/mobile/art/resourcemanager_art_qrd_qmp.xml index 25d210cc..add8cd4d 100644 --- a/configs/qcom/mobile/art/resourcemanager_art_qrd_qmp.xml +++ b/configs/qcom/mobile/art/resourcemanager_art_qrd_qmp.xml @@ -243,6 +243,9 @@ PAL_STREAM_VOIP_TX 2 1 + + 0 + PAL_STREAM_VOICE_CALL @@ -270,6 +273,9 @@ 4 quad-mic + + OFF + PAL_STREAM_ULTRA_LOW_LATENCY @@ -382,6 +388,9 @@ PAL_STREAM_VOIP_TX 2 1 + + 0 + PAL_STREAM_VOICE_CALL @@ -413,6 +422,9 @@ 4 quad-mic + + OFF + PAL_STREAM_LOOPBACK @@ -464,6 +476,9 @@ 48000 16 1 + + 0 + PAL_STREAM_VOICE_CALL @@ -476,6 +491,9 @@ 1 headset-mic + + OFF + PAL_STREAM_ULTRA_LOW_LATENCY @@ -566,6 +584,9 @@ PAL_STREAM_VOIP_TX 1 + + 0 + PAL_STREAM_LOW_LATENCY @@ -591,6 +612,9 @@ 1 HW 1 + + OFF + PAL_STREAM_ULTRA_LOW_LATENCY @@ -1867,7 +1891,7 @@ - + @@ -1879,7 +1903,7 @@ - + diff --git a/configs/qcom/mobile/art/usecaseKvManager.xml b/configs/qcom/mobile/art/usecaseKvManager.xml index 78831bc7..0411cd34 100644 --- a/configs/qcom/mobile/art/usecaseKvManager.xml +++ b/configs/qcom/mobile/art/usecaseKvManager.xml @@ -60,6 +60,12 @@ + + + + + + @@ -1433,6 +1439,12 @@ + + + + + + @@ -1457,6 +1469,12 @@ + + + + + + @@ -1539,6 +1557,12 @@ + + + + + + @@ -1563,6 +1587,12 @@ + + + + + + @@ -1624,12 +1654,24 @@ + + + + + + + + + + + + @@ -1670,12 +1712,24 @@ + + + + + + + + + + + + diff --git a/configs/qcom/mobile/chora/resourcemanager_chora_atp.xml b/configs/qcom/mobile/chora/resourcemanager_chora_atp.xml index e9756bd1..1ba12626 100644 --- a/configs/qcom/mobile/chora/resourcemanager_chora_atp.xml +++ b/configs/qcom/mobile/chora/resourcemanager_chora_atp.xml @@ -2045,6 +2045,9 @@ + + + diff --git a/configs/qcom/mobile/chora/resourcemanager_chora_cdp.xml b/configs/qcom/mobile/chora/resourcemanager_chora_cdp.xml index 410c817f..330a6763 100644 --- a/configs/qcom/mobile/chora/resourcemanager_chora_cdp.xml +++ b/configs/qcom/mobile/chora/resourcemanager_chora_cdp.xml @@ -2031,6 +2031,9 @@ + + + diff --git a/configs/qcom/mobile/chora/resourcemanager_chora_mtp.xml b/configs/qcom/mobile/chora/resourcemanager_chora_mtp.xml index e9756bd1..1ba12626 100644 --- a/configs/qcom/mobile/chora/resourcemanager_chora_mtp.xml +++ b/configs/qcom/mobile/chora/resourcemanager_chora_mtp.xml @@ -2045,6 +2045,9 @@ + + + diff --git a/configs/qcom/mobile/chora/resourcemanager_chora_mtp_qmp.xml b/configs/qcom/mobile/chora/resourcemanager_chora_mtp_qmp.xml index e9756bd1..1ba12626 100644 --- a/configs/qcom/mobile/chora/resourcemanager_chora_mtp_qmp.xml +++ b/configs/qcom/mobile/chora/resourcemanager_chora_mtp_qmp.xml @@ -2045,6 +2045,9 @@ + + + diff --git a/configs/qcom/mobile/chora/resourcemanager_chora_qrd.xml b/configs/qcom/mobile/chora/resourcemanager_chora_qrd.xml index 92c7e363..7a589644 100644 --- a/configs/qcom/mobile/chora/resourcemanager_chora_qrd.xml +++ b/configs/qcom/mobile/chora/resourcemanager_chora_qrd.xml @@ -2029,6 +2029,9 @@ + + + diff --git a/configure.ac b/configure.ac index 96c380e5..0eed43b4 100644 --- a/configure.ac +++ b/configure.ac @@ -141,6 +141,18 @@ AC_ARG_WITH([streamSoundTrigger], [with_streamSoundTrigger=no]) AM_CONDITIONAL([COMPILE_STREAMSOUNDTRIGGER], [test "x${with_streamSoundTrigger}" = "xyes"]) +AC_ARG_WITH([UvVoiceCueFeature], + AS_HELP_STRING([use UvVoiceCueFeature (default is no)]), + [with_UvVoiceCueFeature=$withval], + [with_UvVoiceCueFeature=no]) +AM_CONDITIONAL([COMPILE_UVVOICECUE_FEATURES], [test "x${with_UvVoiceCueFeature}" = "xyes"]) + +AS_IF([test "x${with_UvVoiceCueFeature}" = "xno"], + [UVVOICECUE_FEATURE_FLAGS="-DUVVOICECUE_FEATURES_DISABLED"], + [UVVOICECUE_FEATURE_FLAGS=""]) + +AC_SUBST([UVVOICECUE_FEATURE_FLAGS]) + AC_CONFIG_FILES([ Makefile \ pal.pc \ stream/Makefile \ @@ -248,10 +260,4 @@ plugins/PluginManager/plugin_manager.pc \ plugins/codecs/Makefile \ plugins/codecs/codecs.pc ]) -AC_ARG_WITH([adsprpcd], - AS_HELP_STRING([compile adsprpcd (default is no)]), - [with_adsprpcd=$withval], - [with_adsprpcd=no]) -AM_CONDITIONAL([COMPILE_ADSPRPCD], [test "x${with_adsprpcd}" = "xyes"]) - AC_OUTPUT diff --git a/context_manager/src/ContextManager.cpp b/context_manager/src/ContextManager.cpp index 56ba31af..7a6c4667 100644 --- a/context_manager/src/ContextManager.cpp +++ b/context_manager/src/ContextManager.cpp @@ -195,7 +195,7 @@ int32_t ContextManager::build_and_send_register_ack(Usecase *uc, uint32_t see_id pal_param->payload_size = payload_size; - rc = send_asps_response(PAL_CUSTOM_PARAM_AR_TAG_MODULE_CONFIG, pal_param); + rc = send_asps_response(std::string(PAL_CUSTOM_PARAM_AR_TAG_MODULE_CONFIG), pal_param); if (rc) { PAL_ERR(LOG_TAG, "Error:%d sending register ack opcode %x", rc, PARAM_ID_ASPS_SENSOR_REGISTER_ACK); @@ -313,7 +313,7 @@ int32_t ContextManager::send_asps_basic_response(int32_t status, uint32_t event_ pal_param->payload_size = PAL_ALIGN_8BYTE(sizeof(struct param_id_asps_basic_ack_t) + sizeof(struct apm_module_param_data_t)); - rc = s->setCustomParam(nullptr, PAL_CUSTOM_PARAM_AR_TAG_MODULE_CONFIG, (void*)pal_param->payload, pal_param->payload_size); + rc = s->setCustomParam(nullptr, std::string(PAL_CUSTOM_PARAM_AR_TAG_MODULE_CONFIG), (void*)pal_param->payload, pal_param->payload_size); if (rc) { PAL_ERR(LOG_TAG, "Error:%d setting params on proxy stream for basick ack", rc); } @@ -1080,12 +1080,12 @@ int32_t Usecase::GetModuleIIDs(std::vector tags, PAL_VERBOSE(LOG_TAG, "Enter usecase:0x%x", this->usecase_id); rc = pal_stream_get_custom_param(this->pal_stream, - PAL_CUSTOM_PARAM_AR_TAG_MODULE_INFO, + (char *)PAL_CUSTOM_PARAM_AR_TAG_MODULE_INFO, data, &tag_module_size); if (rc == ENODATA) { tag_module_info.resize(tag_module_size); rc = pal_stream_get_custom_param(this->pal_stream, - PAL_CUSTOM_PARAM_AR_TAG_MODULE_INFO, + (char *)PAL_CUSTOM_PARAM_AR_TAG_MODULE_INFO, data, &tag_module_size); @@ -1170,7 +1170,7 @@ int32_t Usecase::GetAckDataOnSuccessfullStart(uint32_t *size, void *data) *size = (no_of_miid * sizeof(uint32_t)); exit: - PAL_DBG(LOG_TAG, "Exit %d, number of MIID %d", rc, no_of_miid); + PAL_DBG(LOG_TAG, "Exit %d, number of MIID %zu", rc, no_of_miid); return rc; } @@ -1273,7 +1273,7 @@ int32_t UsecaseACD::GetAckDataOnSuccessfullStart(uint32_t *size, void *data) sizeof(uint32_t) * requested_context_list->num_contexts); } else { rc = -ENODATA; - PAL_ERR(LOG_TAG, "size %d too small for ack data in UsecaseACD, need %d", + PAL_ERR(LOG_TAG, "size %d too small for ack data in UsecaseACD, need %lu", (int)(*size), sizeof(asps_acd_usecase_register_ack_payload_t) + sizeof(uint32_t) * requested_context_list->num_contexts); } diff --git a/device/Bluetooth/inc/Bluetooth.h b/device/Bluetooth/inc/Bluetooth.h index 41732b08..f7272d89 100644 --- a/device/Bluetooth/inc/Bluetooth.h +++ b/device/Bluetooth/inc/Bluetooth.h @@ -296,9 +296,11 @@ class BtSco : public Bluetooth static std::shared_ptr sObjTx; static std::shared_ptr sObjHfpRx; static std::shared_ptr sObjHfpTx; - BtSco(struct pal_device *device, std::shared_ptr Rm); + BtSco(struct pal_device* device, std::shared_ptr Rm, + const bool isActAsHFPDevice = false); bool mIsScoOn = false; bool mIsHfpOn = false; + bool mIsActAsHFPDevice = false; static bool sIsWbSpeechEnabled; static int sSwbSpeechMode; static bool sIsSwbLc3Enabled; diff --git a/device/Bluetooth/internal/HFPProfile.cpp b/device/Bluetooth/internal/HFPProfile.cpp index 346a6de4..7d8f24dd 100644 --- a/device/Bluetooth/internal/HFPProfile.cpp +++ b/device/Bluetooth/internal/HFPProfile.cpp @@ -72,18 +72,16 @@ Status HFPProfile::open() noexcept { std::lock_guard lock(mLock); PAL_INFO(LOG_TAG, "current state: %s, start count: %d", toString(mState).c_str(), mStreamCounter); - if (mState == State::OPENED) { - return Status::OK; - } - // CHECK(mState == State::CLOSED); if (mState == State::CLOSED) { auto ret = TIME_LOG(sBTHostAPI->audio_stream_open_api(HFP_HARDWARE_OFFLOAD_DATAPATH)); // CHECK(ret == 0); mState = State::OPENED; mStreamCounter = 0; return Status::OK; + } else { + PAL_INFO(LOG_TAG, ": already opened"); + return Status::OK; } - return Status::FAILED; } Status HFPProfile::start() noexcept { @@ -144,8 +142,10 @@ Status HFPProfile::close() noexcept { mState = State::CLOSED; mStreamCounter = 0; return Status::OK; + } else { + PAL_ERR(LOG_TAG, ":HFP is still used"); + return Status::FAILED; } - return Status::FAILED; } std::optional HFPProfile::getCodec() noexcept { diff --git a/device/Bluetooth/src/Bluetooth.cpp b/device/Bluetooth/src/Bluetooth.cpp index 4187f7ce..81630a71 100644 --- a/device/Bluetooth/src/Bluetooth.cpp +++ b/device/Bluetooth/src/Bluetooth.cpp @@ -77,6 +77,8 @@ extern "C" void CreateBtDevice(struct pal_device *device, break; case PAL_DEVICE_IN_BLUETOOTH_SCO_HEADSET: case PAL_DEVICE_OUT_BLUETOOTH_SCO: + *dev = BtSco::getInstance(device, rm); + break; case PAL_DEVICE_IN_BLUETOOTH_HFP: case PAL_DEVICE_OUT_BLUETOOTH_HFP: *dev = BtSco::getInstance(device, rm); @@ -2666,9 +2668,8 @@ std::shared_ptr BtSco::sObjHfpRx = nullptr; std::shared_ptr BtSco::sObjHfpTx = nullptr; bool BtSco::sIsHFPSyncEnabled = true; -BtSco::BtSco(struct pal_device *device, std::shared_ptr Rm) - : Bluetooth(device, Rm) -{ +BtSco::BtSco(struct pal_device* device, std::shared_ptr Rm, const bool isActAsHFPDevice) + : Bluetooth(device, Rm), mIsActAsHFPDevice(isActAsHFPDevice) { sHFPProfile = device::bt::HFPProfile::getInstance(); mCodecType = (device->id == PAL_DEVICE_OUT_BLUETOOTH_SCO) ? ENC : DEC; mPluginHandler = NULL; @@ -2713,6 +2714,9 @@ int32_t BtSco::checkAndUpdateSampleRate(uint32_t *sampleRate) } int BtSco::openBTHost() { + if(mIsActAsHFPDevice) { + return 0; + } if(!sIsHFPSyncEnabled) { /* HFP sync disabled. Hence, return success.*/ return 0; @@ -2725,6 +2729,9 @@ int BtSco::openBTHost() { } int BtSco::closeBTHost() { + if(mIsActAsHFPDevice) { + return 0; + } if (!sIsHFPSyncEnabled) { /* HFP sync disabled. Hence, return success.*/ return 0; @@ -2773,7 +2780,11 @@ int32_t BtSco::setDeviceParameter(uint32_t param_id, void *param) status = openBTHost(); } else { // close BTHost with HFP - status = closeBTHost(); + /* ignore status; + * disconnection for OUTPUT may arrive later where a INPUT + * stream is still active or vice versa. + */ + closeBTHost(); } break; } @@ -2973,6 +2984,9 @@ int BtSco::getCodecConfigFromBTHost() { } int BtSco::startBTHost() { + if(mIsActAsHFPDevice) { + return 0; + } if (!sIsHFPSyncEnabled) { /* HFP sync disabled. Hence, return success.*/ return 0; @@ -3069,6 +3083,9 @@ int BtSco::start() } int BtSco::stopBTHost() { + if(mIsActAsHFPDevice) { + return 0; + } if (!sIsHFPSyncEnabled) { /* HFP sync disabled. Hence, return success.*/ return 0; @@ -3146,7 +3163,7 @@ std::shared_ptr BtSco::getInstance(struct pal_device *device, std::lock_guard lock(Device::mInstMutex); if (!sObjHfpRx) { PAL_DBG(LOG_TAG, "creating instance for %d", device->id); - std::shared_ptr sp(new BtSco(device, Rm)); + std::shared_ptr sp(new BtSco(device, Rm, true)); sObjHfpRx = sp; } } @@ -3156,7 +3173,7 @@ std::shared_ptr BtSco::getInstance(struct pal_device *device, std::lock_guard lock(Device::mInstMutex); if (!sObjHfpTx) { PAL_DBG(LOG_TAG, "creating instance for %d", device->id); - std::shared_ptr sp(new BtSco(device, Rm)); + std::shared_ptr sp(new BtSco(device, Rm, true)); sObjHfpTx = sp; } } diff --git a/device/RTProxy/src/RTProxy.cpp b/device/RTProxy/src/RTProxy.cpp index 7e93b125..b469ea78 100644 --- a/device/RTProxy/src/RTProxy.cpp +++ b/device/RTProxy/src/RTProxy.cpp @@ -208,6 +208,8 @@ int32_t RTProxyIn::getDeviceConfig(struct pal_device *deviceattr, } struct pal_media_config *candidateConfig = &sAttr->in_media_config; + struct pal_device proxyOut_dattr = {}; + PAL_DBG(LOG_TAG, "sattr chn=0x%x fmt id=0x%x rate = 0x%x width=0x%x", sAttr->in_media_config.ch_info.channels, sAttr->in_media_config.aud_fmt_id, @@ -217,7 +219,6 @@ int32_t RTProxyIn::getDeviceConfig(struct pal_device *deviceattr, if (!rm->ifVoiceorVoipCall(sAttr->type) && rm->isDeviceAvailable(PAL_DEVICE_OUT_PROXY)) { PAL_DBG(LOG_TAG, "This is NOT voice call. out proxy is available"); std::shared_ptr devOut = nullptr; - struct pal_device proxyOut_dattr; proxyOut_dattr.id = PAL_DEVICE_OUT_PROXY; devOut = Device::getInstance(&proxyOut_dattr, rm); if (devOut) { diff --git a/device/Speaker/inc/SpeakerProtection.h b/device/Speaker/inc/SpeakerProtection.h index a60c136b..bf4a6fc3 100644 --- a/device/Speaker/inc/SpeakerProtection.h +++ b/device/Speaker/inc/SpeakerProtection.h @@ -88,12 +88,18 @@ #define SPKR_RIGHT_WSA_TEMP "SpkrRight WSA Temp" #define SPKR_LEFT_WSA_TEMP "SpkrLeft WSA Temp" +#define SPKR2_RIGHT_WSA_TEMP "Spkr2Right WSA Temp" +#define SPKR2_LEFT_WSA_TEMP "Spkr2Left WSA Temp" #define SPKR_RIGHT_WSA_DEV_NUM "SpkrRight WSA Get DevNum" #define SPKR_LEFT_WSA_DEV_NUM "SpkrLeft WSA Get DevNum" +#define SPKR2_RIGHT_WSA_DEV_NUM "Spkr2Right WSA Get DevNum" +#define SPKR2_LEFT_WSA_DEV_NUM "Spkr2Left WSA Get DevNum" #define SPKR_RIGHT_WSA_DC_DET "SpkrRight WSA PA Disable" #define SPKR_LEFT_WSA_DC_DET "SpkrLeft WSA PA Disable" +#define SPKR2_RIGHT_WSA_DC_DET "Spkr2Right WSA PA Disable" +#define SPKR2_LEFT_WSA_DC_DET "Spkr2Left WSA PA Disable" #define TZ_TEMP_MIN_THRESHOLD (-30) #define TZ_TEMP_MAX_THRESHOLD (80) diff --git a/device/Speaker/inc/SpeakerProtectionwsa88xx.h b/device/Speaker/inc/SpeakerProtectionwsa88xx.h index 61dd836e..938d1d71 100644 --- a/device/Speaker/inc/SpeakerProtectionwsa88xx.h +++ b/device/Speaker/inc/SpeakerProtectionwsa88xx.h @@ -34,6 +34,9 @@ class SpeakerProtectionwsa884x : public SpeakerProtection { protected : static bool viTxSetupThrdCreated; + static struct pcm *cps2Pcm; + struct param_id_sp_th_vi_calib_res_cfg_t *callback_res_data; + std::vector pcmDevIdCPS2; private : diff --git a/device/Speaker/src/SpeakerProtectionwsa884x.cpp b/device/Speaker/src/SpeakerProtectionwsa884x.cpp index ceddb89c..c677f014 100644 --- a/device/Speaker/src/SpeakerProtectionwsa884x.cpp +++ b/device/Speaker/src/SpeakerProtectionwsa884x.cpp @@ -15,9 +15,9 @@ #include #include "SessionAR.h" - std::thread SpeakerProtectionwsa884x::viTxSetupThread; std::mutex SpeakerProtectionwsa884x::calibrationMutex; +struct pcm * SpeakerProtectionwsa884x::cps2Pcm = NULL; bool SpeakerProtectionwsa884x::viTxSetupThrdCreated; SpeakerProtectionwsa884x::SpeakerProtectionwsa884x(struct pal_device *device, @@ -112,6 +112,9 @@ int SpeakerProtectionwsa884x::spkrStartCalibration() case 2 : ch_info.channels = CHANNELS_2; break; + case 4 : + ch_info.channels = CHANNELS_4; + break; default: PAL_DBG(LOG_TAG, "Unsupported channel. Set default as 2"); ch_info.channels = CHANNELS_2; @@ -148,14 +151,21 @@ int SpeakerProtectionwsa884x::spkrStartCalibration() // Enable VI module switch(numberOfChannels) { - case 1 : + case 1: // TODO: check it from RM.xml for left or right configuration calVector.push_back(std::make_pair(SPK_PRO_VI_MAP, RIGHT_SPKR)); - break; - case 2 : + calVector.push_back(std::make_pair(CHANNELS, CHANNELS_1)); + break; + case 2: calVector.push_back(std::make_pair(SPK_PRO_VI_MAP, STEREO_SPKR)); - break; - default : + calVector.push_back(std::make_pair(CHANNELS, CHANNELS_2)); + break; + case 4: + //QUAD_SPKR needs to be added in kvh2xml.h + calVector.push_back(std::make_pair(SPK_PRO_VI_MAP, QUAD_SPKR)); + calVector.push_back(std::make_pair(CHANNELS, CHANNELS_4)); + break; + default: PAL_ERR(LOG_TAG, "Unsupported channel"); goto exit; } @@ -244,6 +254,9 @@ int SpeakerProtectionwsa884x::spkrStartCalibration() case 2 : config.channels = CHANNELS_2; break; + case 4 : + config.channels = CHANNELS_4; + break; default: PAL_DBG(LOG_TAG, "Unsupported channel. Set default as 2"); config.channels = CHANNELS_2; @@ -269,9 +282,9 @@ int SpeakerProtectionwsa884x::spkrStartCalibration() ret = SessionAlsaUtils::getModuleInstanceId(virtMixer, pcmDevIdsTx.at(0), backEndNameTx.c_str(), - MODULE_VI, &miid); + MODULE_VI, &miid); if (0 != ret) { - PAL_ERR(LOG_TAG, "Failed to get tag info %x, status = %d", MODULE_VI, ret); + PAL_ERR(LOG_TAG, "Failed to get tag info status = %d", ret); goto free_fe; } @@ -349,7 +362,7 @@ int SpeakerProtectionwsa884x::spkrStartCalibration() event_cfg.is_register = 1; ret = SessionAlsaUtils::registerMixerEvent(virtMixer, pcmDevIdsTx.at(0), - backEndNameTx.c_str(), MODULE_VI, (void *)&event_cfg, + backEndNameTx.c_str(), MODULE_VI, (void *)&event_cfg, payload_size); if (ret) { PAL_ERR(LOG_TAG, "Unable to register event to DSP"); @@ -388,6 +401,9 @@ int SpeakerProtectionwsa884x::spkrStartCalibration() case 2 : deviceRx.config.ch_info.channels = CHANNELS_2; break; + case 4 : + deviceRx.config.ch_info.channels = CHANNELS_4; + break; default: PAL_DBG(LOG_TAG, "Unsupported channel. Set default as 2"); deviceRx.config.ch_info.channels = CHANNELS_2; @@ -418,9 +434,16 @@ int SpeakerProtectionwsa884x::spkrStartCalibration() case 1 : // TODO: Fetch the configuration from RM.xml calVector.push_back(std::make_pair(SPK_PRO_DEV_MAP, RIGHT_MONO)); + calVector.push_back(std::make_pair(CHANNELS, CHANNELS_1)); break; case 2 : calVector.push_back(std::make_pair(SPK_PRO_DEV_MAP, LEFT_RIGHT)); + calVector.push_back(std::make_pair(CHANNELS, CHANNELS_2)); + break; + case 4 : + //LEFT_RIGHT_QUAD needs to be added in kvh2xml.h + calVector.push_back(std::make_pair(SPK_PRO_DEV_MAP, LEFT_RIGHT_QUAD)); + calVector.push_back(std::make_pair(CHANNELS, CHANNELS_4)); break; default : PAL_ERR(LOG_TAG, "Unsupported channels for speaker"); @@ -491,10 +514,21 @@ int SpeakerProtectionwsa884x::spkrStartCalibration() config.rate = SAMPLINGRATE_48K; config.format = PCM_FORMAT_S16_LE; - if (numberOfChannels > 1) - config.channels = CHANNELS_2; - else - config.channels = CHANNELS_1; + switch (numberOfChannels) { + case 1: + config.channels = CHANNELS_1; + break; + case 2: + config.channels = CHANNELS_2; + break; + case 4: + config.channels = CHANNELS_4; + break; + default: + PAL_INFO(LOG_ERR, "Unsupported channels %d, setting to 1", numberOfChannels); + config.channels = CHANNELS_1; + } + config.period_size = DEFAULT_PERIOD_SIZE; config.period_count = DEFAULT_PERIOD_COUNT; config.start_threshold = 0; @@ -505,6 +539,12 @@ int SpeakerProtectionwsa884x::spkrStartCalibration() // Set the operation mode for SP module spModeConfg.operation_mode = CALIBRATION_MODE; + if (customPayloadSize) { + free(customPayload); + customPayloadSize = 0; + customPayload = NULL; + } + ret = SessionAlsaUtils::getModuleInstanceId(virtMixer, pcmDevIdsRx.at(0), backEndNameRx.c_str(), MODULE_SP, &miid); @@ -595,8 +635,9 @@ err_pcm_open : if (txPcm) { event_cfg.is_register = 0; + //Register for VI module callback status = SessionAlsaUtils::registerMixerEvent(virtMixer, pcmDevIdsTx.at(0), - backEndNameTx.c_str(), MODULE_VI, (void *)&event_cfg, + backEndNameTx.c_str(), MODULE_VI, (void *)&event_cfg, payload_size); if (status) { PAL_ERR(LOG_TAG, "Unable to deregister event to DSP"); @@ -790,8 +831,16 @@ int SpeakerProtectionwsa884x::viTxSetupThreadLoop() ch_info.ch_map[1] = PAL_CHMAP_CHANNEL_FR; config.channels = CHANNELS_2; break; + case 4: + ch_info.channels = CHANNELS_4; + ch_info.ch_map[0] = PAL_CHMAP_CHANNEL_FL; + ch_info.ch_map[1] = PAL_CHMAP_CHANNEL_FR; + ch_info.ch_map[2] = PAL_CHMAP_CHANNEL_LB; + ch_info.ch_map[3] = PAL_CHMAP_CHANNEL_RB; + config.channels = CHANNELS_4; + break; default: - PAL_DBG(LOG_TAG, "Unsupported channel. Set defauly as 2"); + PAL_DBG(LOG_TAG, "Unsupported channel. Set default as 2"); ch_info.channels = CHANNELS_2; config.channels = CHANNELS_2; } @@ -850,6 +899,10 @@ int SpeakerProtectionwsa884x::viTxSetupThreadLoop() case 2 : calVector.push_back(std::make_pair(SPK_PRO_VI_MAP, STEREO_SPKR)); break; + case 4 : + //QUAD_SPKR needs to be added in kvh2xml.h + calVector.push_back(std::make_pair(SPK_PRO_VI_MAP, QUAD_SPKR)); + break; default : PAL_ERR(LOG_TAG, "Unsupported channel"); goto exit; @@ -1226,7 +1279,7 @@ int32_t SpeakerProtectionwsa884x::spkrProtProcessingMode(bool flag) char mSndDeviceName_SP[128] = {0}; uint8_t* payload = NULL; uint32_t devicePropId[] = {0x08000010, 1, 0x2}; - uint32_t miid = 0; + uint32_t miid = 0, deviceid = 0; uint32_t param_sp_op_mode = 0; uint32_t param_cps_ch_map = 0; bool isTxFeandBeConnected = true; @@ -1244,7 +1297,7 @@ int32_t SpeakerProtectionwsa884x::spkrProtProcessingMode(bool flag) struct agmMetaData deviceMetaData(nullptr, 0); struct mixer_ctl *beMetaDataMixerCtrl = nullptr; FILE *fp; - std::string backEndName, backEndNameRx, backEndNameCPS; + std::string backEndName, backEndNameRx, backEndNameCPS, backEndNameCPS2; std::vector > keyVector; std::vector > calVector; std::shared_ptr rm; @@ -1270,7 +1323,7 @@ int32_t SpeakerProtectionwsa884x::spkrProtProcessingMode(bool flag) struct agm_event_reg_cfg event_cfg; session_callback sessionCb; pal_spkr_prot_payload spkrProtPayload; - int id; + int id, id2; PAL_DBG(LOG_TAG, "Flag %d", flag); deviceMutex.lock(); @@ -1286,6 +1339,7 @@ int32_t SpeakerProtectionwsa884x::spkrProtProcessingMode(bool flag) txPcm = NULL; rxPcm = NULL; cpsPcm = NULL; + cps2Pcm = NULL; PAL_DBG(LOG_TAG, "Stopped calibration mode"); } numberOfRequest++; @@ -1442,216 +1496,292 @@ int32_t SpeakerProtectionwsa884x::spkrProtProcessingMode(bool flag) dev = Device::getInstance(&mDeviceAttr, rm); dev->getCurrentSndDevName(mSndDeviceName_SP); - if (mDeviceAttr.id == PAL_DEVICE_OUT_SPEAKER && strstr(mSndDeviceName_SP, "mono")) - rm->getDeviceInfo(PAL_DEVICE_IN_CPS_FEEDBACK, PAL_STREAM_VOICE_CALL, "", &cps_device); - else if (mDeviceAttr.id == PAL_DEVICE_OUT_SPEAKER) - rm->getDeviceInfo(PAL_DEVICE_IN_CPS_FEEDBACK, PAL_STREAM_PROXY, "", &cps_device); - - // Configure device attribute - if (cps_device.channels > 1) { - ch_info.channels = CHANNELS_2; - ch_info.ch_map[0] = PAL_CHMAP_CHANNEL_FL; - ch_info.ch_map[1] = PAL_CHMAP_CHANNEL_FR; - } - else { - ch_info.channels = CHANNELS_1; - if (mDeviceAttr.id == PAL_DEVICE_OUT_HANDSET) - ch_info.ch_map[0] = PAL_CHMAP_CHANNEL_FL; - else - ch_info.ch_map[0] = PAL_CHMAP_CHANNEL_FR; + if(numberOfChannels != CHANNELS_4) { + if (mDeviceAttr.id == PAL_DEVICE_OUT_SPEAKER && strstr(mSndDeviceName_SP, "mono")) + rm->getDeviceInfo(PAL_DEVICE_IN_CPS_FEEDBACK, PAL_STREAM_VOICE_CALL, "", &cps_device); + else if (mDeviceAttr.id == PAL_DEVICE_OUT_SPEAKER) + rm->getDeviceInfo(PAL_DEVICE_IN_CPS_FEEDBACK, PAL_STREAM_PROXY, "", &cps_device); } - deviceCPS.config.ch_info = ch_info; - deviceCPS.config.sample_rate = cps_device.samplerate; - deviceCPS.config.bit_width = cps_device.bit_width; - deviceCPS.config.aud_fmt_id = rm->getAudioFmt(cps_device.bit_width); - // Setup CPS path - deviceCPS.id = PAL_DEVICE_IN_CPS_FEEDBACK; + // Configure device attribute + for (int ch = numberOfChannels; ch != 0; ch = ch >> 2) { + PAL_DBG(LOG_TAG, "Opening CPS for ch: %d \n", ch); + bool isFirstDevice = (ch == numberOfChannels); + if(numberOfChannels == CHANNELS_4) { + if(!isFirstDevice) { + if (mDeviceAttr.id == PAL_DEVICE_OUT_SPEAKER && strstr(mSndDeviceName_SP, "mono")) { + rm->getDeviceInfo(PAL_DEVICE_IN_CPS_FEEDBACK,PAL_STREAM_VOICE_CALL,"",&cps_device); + } + else if (mDeviceAttr.id == PAL_DEVICE_OUT_SPEAKER) { + rm->getDeviceInfo(PAL_DEVICE_IN_CPS_FEEDBACK,PAL_STREAM_PROXY,"",&cps_device); + } + }else { + if (mDeviceAttr.id == PAL_DEVICE_OUT_SPEAKER && strstr(mSndDeviceName_SP, "mono")) { + rm->getDeviceInfo(PAL_DEVICE_IN_CPS2_FEEDBACK,PAL_STREAM_VOICE_CALL,"",&cps_device); + } + else if (mDeviceAttr.id == PAL_DEVICE_OUT_SPEAKER) { + rm->getDeviceInfo(PAL_DEVICE_IN_CPS2_FEEDBACK,PAL_STREAM_PROXY,"",&cps_device); + } + } + } + // Configure device attribute + if (cps_device.channels > 1) { + ch_info.channels = CHANNELS_2; + ch_info.ch_map[0] = PAL_CHMAP_CHANNEL_FL; + ch_info.ch_map[1] = PAL_CHMAP_CHANNEL_FR; + } + else { + ch_info.channels = CHANNELS_1; + if (mDeviceAttr.id == PAL_DEVICE_OUT_HANDSET) + ch_info.ch_map[0] = PAL_CHMAP_CHANNEL_FL; + else + ch_info.ch_map[0] = PAL_CHMAP_CHANNEL_FR; + } - ret = rm->getAudioRoute(&audioRoute); - if (0 != ret) { - PAL_ERR(LOG_TAG, "Failed to get the audio_route address status %d", ret); - goto err_pcm_open; - } - strlcpy(mSndDeviceName_cps, cps_device.sndDevName.c_str(), DEVICE_NAME_MAX_SIZE); + deviceCPS.config.ch_info = ch_info; + deviceCPS.config.sample_rate = cps_device.samplerate; + deviceCPS.config.bit_width = cps_device.bit_width; + deviceCPS.config.aud_fmt_id = rm->getAudioFmt(cps_device.bit_width); - if (mDeviceAttr.id == PAL_DEVICE_OUT_HANDSET) { - strlcat(mSndDeviceName_cps, FEEDBACK_MONO_1, DEVICE_NAME_MAX_SIZE); - } + if (ch != CHANNELS_4) + deviceCPS.id = PAL_DEVICE_IN_CPS_FEEDBACK; + else + deviceCPS.id = PAL_DEVICE_IN_CPS2_FEEDBACK; - PAL_DBG(LOG_TAG, "get the audio route %s", mSndDeviceName_cps); + ret = rm->getAudioRoute(&audioRoute); + if (0 != ret) { + PAL_ERR(LOG_TAG, "Failed to get the audio_route address status %d", ret); + goto err_pcm_open; + } + strlcpy(mSndDeviceName_cps, cps_device.sndDevName.c_str(), DEVICE_NAME_MAX_SIZE); - rm->getBackendName(deviceCPS.id, backEndNameCPS); - if (!strlen(backEndNameCPS.c_str())) { - PAL_ERR(LOG_TAG, "Failed to obtain CPS backend name for %d", deviceCPS.id); - goto err_pcm_open; - } + if (mDeviceAttr.id == PAL_DEVICE_OUT_HANDSET) { + strlcat(mSndDeviceName_cps, FEEDBACK_MONO_1, DEVICE_NAME_MAX_SIZE); + } - PayloadBuilder::getDeviceKV(deviceCPS.id, keyVector); - if (0 != ret) { - PAL_ERR(LOG_TAG, "Failed to obtain device KV for %d", device.id); - goto err_pcm_open; - } + PAL_DBG(LOG_TAG, "get the audio route %s", mSndDeviceName_cps); - // Enable the CPS module - switch (cps_device.channels) { - case 1 : - if (mDeviceAttr.id == PAL_DEVICE_OUT_HANDSET) - calVector.push_back(std::make_pair(SPK_PRO_CPS_MAP, L_SPKR)); - else - calVector.push_back(std::make_pair(SPK_PRO_CPS_MAP, R_SPKR)); - break; - case 2 : - calVector.push_back(std::make_pair(SPK_PRO_CPS_MAP, ST_SPKR)); - break; - default : - PAL_ERR(LOG_TAG, "Unsupported channel"); + rm->getBackendName(deviceCPS.id, backEndNameCPS); + if (!strlen(backEndNameCPS.c_str())) { + PAL_ERR(LOG_TAG, "Failed to obtain CPS backend name for %d", deviceCPS.id); goto err_pcm_open; - } + } - SessionAlsaUtils::getAgmMetaData(keyVector, calVector, - (struct prop_data *)devicePropId, deviceMetaData); - if (!deviceMetaData.size) { - PAL_ERR(LOG_TAG, "CPS device metadata is zero"); - ret = -ENOMEM; - goto err_pcm_open; - } - connectCtrlNameBeCPS<< backEndNameCPS << " metadata"; - beMetaDataMixerCtrl = mixer_get_ctl_by_name(virtMixer, - connectCtrlNameBeCPS.str().data()); - if (!beMetaDataMixerCtrl) { - PAL_ERR(LOG_TAG, "invalid mixer control for CPS : %s", backEndNameCPS.c_str()); - ret = -EINVAL; - goto err_pcm_open; - } + PayloadBuilder::getDeviceKV(deviceCPS.id, keyVector); + if (0 != ret) { + PAL_ERR(LOG_TAG, "Failed to obtain device KV for %d", device.id); + goto err_pcm_open; + } - if (deviceMetaData.size) { - ret = mixer_ctl_set_array(beMetaDataMixerCtrl, (void *)deviceMetaData.buf, - deviceMetaData.size); - free(deviceMetaData.buf); - deviceMetaData.buf = nullptr; - } - else { - PAL_ERR(LOG_TAG, "Device Metadata not set for CPS path"); - ret = -EINVAL; - goto err_pcm_open; - } + // Enable the CPS module + switch (cps_device.channels) { + case 1 : + if (mDeviceAttr.id == PAL_DEVICE_OUT_HANDSET) + calVector.push_back(std::make_pair(SPK_PRO_CPS_MAP, L_SPKR)); + else + calVector.push_back(std::make_pair(SPK_PRO_CPS_MAP, R_SPKR)); + break; + case 2 : + calVector.push_back(std::make_pair(SPK_PRO_CPS_MAP, ST_SPKR)); + break; + case 4 : + calVector.push_back(std::make_pair(SPK_PRO_CPS_MAP, ST_SPKR)); // Nothing changes between any of these KVs + break; + default : + PAL_ERR(LOG_TAG, "Unsupported channel"); + goto err_pcm_open; + } - ret = Device::setMediaConfig(rm, backEndNameCPS, &deviceCPS); - if (ret) { - PAL_ERR(LOG_TAG, "setMediaConfig for feedback device failed"); - goto err_pcm_open; - } + SessionAlsaUtils::getAgmMetaData(keyVector, calVector, + (struct prop_data *)devicePropId, deviceMetaData); + if (!deviceMetaData.size) { + PAL_ERR(LOG_TAG, "CPS device metadata is zero"); + ret = -ENOMEM; + goto err_pcm_open; + } - /* Retrieve Hostless PCM device id */ - sAttr.type = PAL_STREAM_LOW_LATENCY; - sAttr.direction = PAL_AUDIO_INPUT_OUTPUT; - dir = TX_HOSTLESS; - id = rm->allocateFrontEndIds(PCM_RECORD_HOSTLESS); - if (id < 0) { - PAL_ERR(LOG_TAG, "allocateFrontEndIds failed"); - ret = -ENOSYS; - goto err_pcm_open; - } - pcmDevIdCPS.push_back(id); + // Reset stream before using it again + connectCtrlNameBeCPS.str(""); + connectCtrlNameBeCPS.clear(); - connectCtrlNameCPS << "PCM" << pcmDevIdCPS.at(0) << " connect"; - connectCtrl2 = mixer_get_ctl_by_name(virtMixer, connectCtrlNameCPS.str().data()); + connectCtrlNameBeCPS<< backEndNameCPS << " metadata"; - if (!connectCtrl2) { - PAL_ERR(LOG_TAG, "invalid mixer control: %s", connectCtrlNameCPS.str().data()); - goto free_fe; - } + beMetaDataMixerCtrl = mixer_get_ctl_by_name(virtMixer, + connectCtrlNameBeCPS.str().data()); + if (!beMetaDataMixerCtrl) { + PAL_ERR(LOG_TAG, "invalid mixer control for CPS : %s", backEndNameCPS.c_str()); + ret = -EINVAL; + goto err_pcm_open; + } - ret = mixer_ctl_set_enum_by_string(connectCtrl2, backEndNameCPS.c_str()); - if (ret) { - PAL_ERR(LOG_TAG, "Mixer control %s set with %s failed: %d", - connectCtrlNameCPS.str().data(), backEndNameCPS.c_str(), ret); - goto free_fe; - } + if (deviceMetaData.size) { + ret = mixer_ctl_set_array(beMetaDataMixerCtrl, (void *)deviceMetaData.buf, + deviceMetaData.size); + free(deviceMetaData.buf); + deviceMetaData.buf = nullptr; + } + else { + PAL_ERR(LOG_TAG, "Device Metadata not set for CPS path"); + ret = -EINVAL; + goto err_pcm_open; + } - isCPSFeandBeConnected = true; + ret = Device::setMediaConfig(rm, backEndNameCPS, &deviceCPS); + if (ret) { + PAL_ERR(LOG_TAG, "setMediaConfig for feedback device failed"); + goto err_pcm_open; + } - config.rate = cps_device.samplerate; - switch (cps_device.bit_width) { - case 32 : - config.format = PCM_FORMAT_S32_LE; - break; - default: - PAL_DBG(LOG_TAG, "Unsupported bit width. Set default as 16"); - config.format = PCM_FORMAT_S16_LE; - break; - } + /* Retrieve Hostless PCM device id */ + sAttr.type = PAL_STREAM_LOW_LATENCY; + sAttr.direction = PAL_AUDIO_INPUT_OUTPUT; + dir = TX_HOSTLESS; + + // Reset stream before using it again + connectCtrlNameCPS.str(""); + connectCtrlNameCPS.clear(); + + if (ch != CHANNELS_4) { + id = rm->allocateFrontEndIds(PCM_RECORD_HOSTLESS); + if (pcmDevIdCPS.size() == 0) { + PAL_ERR(LOG_TAG, "allocateFrontEndIds failed"); + ret = -ENOSYS; + goto err_pcm_open; + } + pcmDevIdCPS.push_back(id); + connectCtrlNameCPS << "PCM" << pcmDevIdCPS.at(0) << " connect"; + } else { + id2 = rm->allocateFrontEndIds(PCM_RECORD_HOSTLESS); + + if (pcmDevIdCPS2.size() == 0) { + PAL_ERR(LOG_TAG, "allocateFrontEndIds failed"); + ret = -ENOSYS; + goto err_pcm_open; + } + pcmDevIdCPS.push_back(id2); + connectCtrlNameCPS << "PCM" << pcmDevIdCPS2.at(0) << " connect"; + } + connectCtrl2 = mixer_get_ctl_by_name(virtMixer, connectCtrlNameCPS.str().data()); - switch (cps_device.channels) { - case 1 : - config.channels = CHANNELS_1; - break; - case 2 : - config.channels = CHANNELS_2; - break; - default : - PAL_DBG(LOG_TAG, "Unsupported channel. Set default as 2"); - config.channels = CHANNELS_2; - break; - } - config.period_size = DEFAULT_PERIOD_SIZE; - config.period_count = DEFAULT_PERIOD_COUNT; - config.start_threshold = 0; - config.stop_threshold = INT_MAX; - config.silence_threshold = 0; + if (!connectCtrl2) { + PAL_ERR(LOG_TAG, "invalid mixer control: %s", connectCtrlNameCPS.str().data()); + goto free_fe; + } - flags = PCM_IN; + ret = mixer_ctl_set_enum_by_string(connectCtrl2, backEndNameCPS.c_str()); + if (ret) { + PAL_ERR(LOG_TAG, "Mixer control %s set with %s failed: %d", + connectCtrlNameCPS.str().data(), backEndNameCPS.c_str(), ret); + goto free_fe; + } - ret = SessionAlsaUtils::getModuleInstanceId(virtMixer, pcmDevIdCPS.at(0), - backEndNameCPS.c_str(), TAG_MODULE_CPS, &miid); - if (0 != ret) { - PAL_ERR(LOG_TAG, "Failed to get tag info %x, status = %d", TAG_MODULE_CPS, ret); - goto free_fe; - } + isCPSFeandBeConnected = true; - // Setting Channel Map configuration for CPS module - // TODO: Move this to ACDB file - cpsChannelMapConfg.num_ch = cps_device.channels; - payloadSize = 0; - if (rm->GetSpeakerProtectionVersion() == SPV5) - param_cps_ch_map = PARAM_ID_CPS_CHANNEL_MAP_V5; - else - param_cps_ch_map = PARAM_ID_CPS_CHANNEL_MAP; + config.rate = cps_device.samplerate; + switch (cps_device.bit_width) { + case 32 : + config.format = PCM_FORMAT_S32_LE; + break; + default: + PAL_DBG(LOG_TAG, "Unsupported bit width. Set default as 16"); + config.format = PCM_FORMAT_S16_LE; + break; + } - builder->payloadSPConfig(&payload, &payloadSize, miid, - param_cps_ch_map,(void *)&cpsChannelMapConfg); - if (payloadSize) { - ret = updateCustomPayload(payload, payloadSize); - free(payload); + switch (cps_device.channels) { + case 1 : + config.channels = CHANNELS_1; + break; + case 2 : + config.channels = CHANNELS_2; + break; + case 4 : + config.channels = CHANNELS_4; + break; + default : + PAL_DBG(LOG_TAG, "Unsupported channel. Set default as 2"); + config.channels = CHANNELS_2; + break; + } + config.period_size = DEFAULT_PERIOD_SIZE; + config.period_count = DEFAULT_PERIOD_COUNT; + config.start_threshold = 0; + config.stop_threshold = INT_MAX; + config.silence_threshold = 0; + + flags = PCM_IN; + if (ch != CHANNELS_4) { + deviceid = pcmDevIdCPS.at(0); + } else { + deviceid = pcmDevIdCPS2.at(0); + } + ret = SessionAlsaUtils::getModuleInstanceId(virtMixer, deviceid, + backEndNameCPS.c_str(), TAG_MODULE_CPS, &miid); if (0 != ret) { - PAL_ERR(LOG_TAG," updateCustomPayload Failed for CPS CHANNEL_MAP_CFG\n"); + PAL_ERR(LOG_TAG, "Failed to get tag info %x, status = %d", TAG_MODULE_CPS, ret); + goto free_fe; } - } - cpsPcm = pcm_open(rm->getVirtualSndCard(), pcmDevIdCPS.at(0), flags, &config); - if (!cpsPcm) { - PAL_ERR(LOG_TAG, "cpsPcm open failed"); - goto free_fe; - } + cpsChannelMapConfg.num_ch = cps_device.channels * 2; + payloadSize = 0; - if (!pcm_is_ready(cpsPcm)) { - PAL_ERR(LOG_TAG, "cpsPcm open not ready"); - goto err_pcm_open; - } + if (rm->GetSpeakerProtectionVersion() == SPV5) + param_cps_ch_map = PARAM_ID_CPS_CHANNEL_MAP_V5; + else + param_cps_ch_map = PARAM_ID_CPS_CHANNEL_MAP; - enableDevice(audioRoute, mSndDeviceName_cps); - PAL_DBG(LOG_TAG, "pcm start for CPS"); - if (pcm_start(cpsPcm) < 0) { - PAL_ERR(LOG_TAG, "pcm start failed for CPS path"); - goto err_pcm_open; - } + if(isFirstDevice) { + builder->payloadSPConfig(&payload, &payloadSize, miid, + param_cps_ch_map,(void *)&cpsChannelMapConfg); + if (payloadSize) { + ret = updateCustomPayload(payload, payloadSize); + free(payload); + if (0 != ret) { + PAL_ERR(LOG_TAG," updateCustomPayload Failed for CPS CHANNEL_MAP_CFG\n"); + } + } + } - // Free up the local variables - goto exit; - } - else { + if (ch != CHANNELS_4) { + cpsPcm = pcm_open(rm->getVirtualSndCard(), pcmDevIdCPS.at(0), flags, &config); + if (!cpsPcm) { + PAL_ERR(LOG_TAG, "cpsPcm open failed"); + goto free_fe; + } + if (!pcm_is_ready(cpsPcm)) { + PAL_ERR(LOG_TAG, "cpsPcm open not ready"); + goto err_pcm_open; + } + enableDevice(audioRoute, mSndDeviceName_cps); + PAL_DBG(LOG_TAG, " pcm start for CPS"); + if (pcm_start(cpsPcm) < 0) { + PAL_ERR(LOG_TAG, "pcm start failed for CPS path"); + goto err_pcm_open; + } + } else { + cps2Pcm = pcm_open(rm->getVirtualSndCard(), pcmDevIdCPS2.at(0), flags, &config); + if (!cps2Pcm) { + PAL_ERR(LOG_TAG, "cps2Pcm open failed"); + goto free_fe; + } + if (!pcm_is_ready(cps2Pcm)) { + PAL_ERR(LOG_TAG, "cps2Pcm open not ready"); + goto err_pcm_open; + } + enableDevice(audioRoute, mSndDeviceName_cps); + PAL_DBG(LOG_TAG, "pcm start for CPS2"); + if (pcm_start(cps2Pcm) < 0) { + PAL_ERR(LOG_TAG, "pcm start failed for CPS path"); + goto err_pcm_open; + } + } + keyVector.clear(); + calVector.clear(); + } + // Free up the local variables + goto exit; + } else { if (numberOfRequest == 0) { PAL_ERR(LOG_TAG, "Device not started yet, Stop not expected"); goto exit; @@ -1703,9 +1833,13 @@ int32_t SpeakerProtectionwsa884x::spkrProtProcessingMode(bool flag) txPcm = NULL; } PAL_DBG(LOG_TAG, "Closing CPS path"); - if (cpsPcm) { + if(cpsPcm || cps2Pcm) { rm = ResourceManager::getInstance(); - deviceCPS.id = PAL_DEVICE_IN_CPS_FEEDBACK; + for (int ch = numberOfChannels; ch != 0; ch = ch >> 2) { + if (ch != CHANNELS_4) + deviceCPS.id = PAL_DEVICE_IN_CPS_FEEDBACK; + else + deviceCPS.id = PAL_DEVICE_IN_CPS2_FEEDBACK; ret = rm->getAudioRoute(&audioRoute); if (0 != ret) { @@ -1713,25 +1847,42 @@ int32_t SpeakerProtectionwsa884x::spkrProtProcessingMode(bool flag) goto exit; } - strlcpy(mSndDeviceName_cps, cps_device.sndDevName.c_str(), DEVICE_NAME_MAX_SIZE); - rm->getBackendName(deviceCPS.id, backEndNameCPS); - if (!strlen(backEndNameCPS.c_str())) { - PAL_ERR(LOG_TAG, "Failed to obtain CPS backend name for %d", deviceCPS.id); - goto exit; - } - pcm_stop(cpsPcm); - if (pcmDevIdCPS.size() != 0) { - if (isCPSFeandBeConnected) { - disconnectFeandBe(pcmDevIdCPS, backEndNameCPS); + strlcpy(mSndDeviceName_cps, cps_device.sndDevName.c_str(), DEVICE_NAME_MAX_SIZE); + rm->getBackendName(deviceCPS.id, backEndNameCPS); + if (!strlen(backEndNameCPS.c_str())) { + PAL_ERR(LOG_TAG, "Failed to obtain CPS backend name for %d", deviceCPS.id); + goto exit; + } + if (ch != CHANNELS_4) { + pcm_stop(cpsPcm); + if (pcmDevIdCPS.size() != 0) { + if (isCPSFeandBeConnected) { + disconnectFeandBe(pcmDevIdCPS, backEndNameCPS); + } + sAttr.type = PAL_STREAM_LOW_LATENCY; + sAttr.direction = PAL_AUDIO_INPUT_OUTPUT; + rm->freeFrontEndIds(PCM_RECORD_HOSTLESS, pcmDevIdCPS); + pcmDevIdCPS.clear(); + } + pcm_close(cpsPcm); + disableDevice(audioRoute, mSndDeviceName_cps); + cpsPcm = NULL; + } else { + pcm_stop(cps2Pcm); + if (pcmDevIdCPS2.size() != 0) { + if (isCPSFeandBeConnected) { + disconnectFeandBe(pcmDevIdCPS2, backEndNameCPS); + } + sAttr.type = PAL_STREAM_LOW_LATENCY; + sAttr.direction = PAL_AUDIO_INPUT_OUTPUT; + rm->freeFrontEndIds(PCM_RECORD_HOSTLESS, pcmDevIdCPS2); + pcmDevIdCPS2.clear(); + } + pcm_close(cps2Pcm); + disableDevice(audioRoute, mSndDeviceName_cps); + cps2Pcm = NULL; } - sAttr.type = PAL_STREAM_LOW_LATENCY; - sAttr.direction = PAL_AUDIO_INPUT_OUTPUT; - rm->freeFrontEndIds(PCM_RECORD_HOSTLESS, pcmDevIdCPS); - pcmDevIdCPS.clear(); } - pcm_close(cpsPcm); - disableDevice(audioRoute, mSndDeviceName_cps); - cpsPcm = NULL; goto exit; } } @@ -1743,14 +1894,35 @@ err_pcm_open : cpsPcm = NULL; } + if (cps2Pcm) { + pcm_close(cps2Pcm); + disableDevice(audioRoute, mSndDeviceName_cps); + cps2Pcm = NULL; + } + free_fe: + if (pcmDevIdCPS.size() != 0) { if (isCPSFeandBeConnected) { + deviceCPS.id = PAL_DEVICE_IN_CPS_FEEDBACK; + ret = rm->getSndDeviceName(deviceCPS.id , mSndDeviceName_cps); + rm->getBackendName(deviceCPS.id, backEndNameCPS); disconnectFeandBe(pcmDevIdCPS, backEndNameCPS); } rm->freeFrontEndIds(PCM_RECORD_HOSTLESS, pcmDevIdCPS); pcmDevIdCPS.clear(); } + if (pcmDevIdCPS2.size() != 0) { + if (isCPSFeandBeConnected) { + deviceCPS.id = PAL_DEVICE_IN_CPS2_FEEDBACK; + ret = rm->getSndDeviceName(deviceCPS.id , mSndDeviceName_cps); + rm->getBackendName(deviceCPS.id, backEndNameCPS2); + disconnectFeandBe(pcmDevIdCPS2, backEndNameCPS2); + } + rm->freeFrontEndIds(PCM_RECORD_HOSTLESS, pcmDevIdCPS2); + pcmDevIdCPS2.clear(); + } + exit: deviceMutex.unlock(); if(builder) { diff --git a/inc/PalDefs.h b/inc/PalDefs.h index f5fd83af..7705ea63 100644 --- a/inc/PalDefs.h +++ b/inc/PalDefs.h @@ -60,7 +60,7 @@ extern "C" { #define PAL_MAX_LATENCY_MODES 8 #define PAL_CUSTOM_PARAM_MAX_STRING_LENGTH 64 -#define PAL_VERSION "2.1" +#define PAL_VERSION "2.2" #define PAL_MAX_SOUND_DOSE_VALUES 10 #define SEND_MSG_PARAM "sendMsg" @@ -903,6 +903,8 @@ typedef enum { PAL_PARAM_ID_MULTI_CLIENT_ASR_OUTPUT = 107, PAL_PARAM_ID_MULTI_CLIENT_SDZ_OUTPUT = 108, PAL_PARAM_ID_VOICE_NS_RX_CFG = 109, + PAL_PARAM_ID_UV_VOICE_CUE_ENABLE = 110, + PAL_PARAM_ID_UV_VOICE_CUE_DATA_BYTE = 111, } pal_param_id_type_t; /** HDMI/DP */ @@ -1541,10 +1543,29 @@ struct call_translation_config { bool enable; pal_call_translation_direction call_translation_dir; /** Direction for the call_translation usecase */ struct pal_tts_config tts_module_config; /** TTS module config */ - struct pal_nmt_config nmt_module_config; /** NMT module config */ + struct pal_nmt_config nmt_module_config; /** NMT module config */ struct pal_asr_config asr_module_config; /** ASR module config */ }; +enum { + UV_FLUENCE_TELEPHONY_BIT = 0x1, // (1 << 0) = 1 -> voice + UV_FLUENCE_AUDIO_BIT = 0x1 << 1, // (1 << 1) = 2 -> audio + UV_FLUENCE_VOIP_BIT = 0x1 << 2, // (1 << 2) = 4 -> voip + UV_FLUENCE_SVA_BIT = 0x1 << 3, // (1 << 3) = 8 -> sva + + // Union of all defined bits + UV_FLUENCE_BIT_ALL = UV_FLUENCE_TELEPHONY_BIT | + UV_FLUENCE_AUDIO_BIT | + UV_FLUENCE_VOIP_BIT | + UV_FLUENCE_SVA_BIT, +}; + +typedef struct uv_fluence_config { + uint32_t usecase_mask; /**< Bit mask indicating which use case(s) are to be updated. */ + size_t param_size; /**< Size of voice cue payload in bytes. */ + uint8_t *voice_cue_param; /**< Pointer to voice cue payload. */ +} uv_fluence_config_t; + #define MAX_TRANSCRIPTION_CHAR_SIZE 1024 #define MAX_JSON_CHAR_SIZE 4096 #define MAX_NUM_WORDS 200 diff --git a/inc/PalMappings.h b/inc/PalMappings.h index 647c72a8..f660d8f1 100644 --- a/inc/PalMappings.h +++ b/inc/PalMappings.h @@ -137,6 +137,7 @@ static const std::map deviceIdLUT { {std::string{ "PAL_DEVICE_IN_ECHO_REF" }, PAL_DEVICE_IN_ECHO_REF}, {std::string{ "PAL_DEVICE_IN_HAPTICS_VI_FEEDBACK" }, PAL_DEVICE_IN_HAPTICS_VI_FEEDBACK}, {std::string{ "PAL_DEVICE_IN_CPS_FEEDBACK" }, PAL_DEVICE_IN_CPS_FEEDBACK}, + {std::string{ "PAL_DEVICE_IN_CPS2_FEEDBACK" }, PAL_DEVICE_IN_CPS2_FEEDBACK}, {std::string{ "PAL_DEVICE_IN_DUMMY" }, PAL_DEVICE_IN_DUMMY}, {std::string{ "PAL_DEVICE_IN_BLUETOOTH_HFP" }, PAL_DEVICE_IN_BLUETOOTH_HFP}, {std::string{ "PAL_DEVICE_IN_SPEAKER_MIC2" }, PAL_DEVICE_IN_SPEAKER_MIC2}, @@ -201,6 +202,7 @@ static const std::map deviceNameLUT { {PAL_DEVICE_IN_ECHO_REF, std::string{"PAL_DEVICE_IN_ECHO_REF"}}, {PAL_DEVICE_IN_HAPTICS_VI_FEEDBACK, std::string{"PAL_DEVICE_IN_HAPTICS_VI_FEEDBACK"}}, {PAL_DEVICE_IN_CPS_FEEDBACK, std::string{"PAL_DEVICE_IN_CPS_FEEDBACK"}}, + {PAL_DEVICE_IN_CPS2_FEEDBACK, std::string{"PAL_DEVICE_IN_CPS2_FEEDBACK"}}, {PAL_DEVICE_IN_DUMMY, std::string{"PAL_DEVICE_IN_DUMMY"}}, {PAL_DEVICE_IN_BLUETOOTH_HFP, std::string{"PAL_DEVICE_IN_BLUETOOTH_HFP"}}, {PAL_DEVICE_IN_SPEAKER_MIC2, std::string{"PAL_DEVICE_IN_SPEAKER_MIC2"}}, diff --git a/ipc/aidl/client/PalClientWrapper.cpp b/ipc/aidl/client/PalClientWrapper.cpp index 7dfc968b..e8a18345 100644 --- a/ipc/aidl/client/PalClientWrapper.cpp +++ b/ipc/aidl/client/PalClientWrapper.cpp @@ -415,7 +415,8 @@ int32_t pal_stream_set_param(pal_stream_handle_t *stream_handle, uint32_t param_ if (memPayload) { PalParamPayloadShmem payload; memcpy(memPayload, param_payload->payload, param_payload->payload_size); - payload.fd = ScopedFileDescriptor(sharedFd); + int parcelFd = dup(sharedFd); + payload.fd = ScopedFileDescriptor(parcelFd); payload.payloadSize = param_payload->payload_size; auto aidlStreamHandle = convertLegacyHandleToAidlHandle(stream_handle); status = statusTFromBinderStatus( @@ -753,4 +754,4 @@ int32_t pal_cshm_dealloc(pal_cshm_id_t memID) { RETURN_IF_PAL_SERVICE_NOT_REGISTERED(client); return statusTFromBinderStatus(client->ipc_pal_cshm_dealloc(memID)); -} \ No newline at end of file +} diff --git a/plugins/PluginManager/src/PluginManagerStatic.cpp b/plugins/PluginManager/src/PluginManagerStatic.cpp index e27437eb..199f7a72 100644 --- a/plugins/PluginManager/src/PluginManagerStatic.cpp +++ b/plugins/PluginManager/src/PluginManagerStatic.cpp @@ -189,6 +189,10 @@ int32_t getDeviceFunc(void** func, std::string name) { PAL_VERBOSE(LOG_TAG, "speaker feedback device CPS"); *reinterpret_cast(func) = &CreateSpeakerDevice; break; + case PAL_DEVICE_IN_CPS2_FEEDBACK: + PAL_VERBOSE(LOG_TAG, "speaker feedback device CPS2"); + *reinterpret_cast(func) = &CreateSpeakerDevice; + break; case PAL_DEVICE_OUT_WIRED_HEADSET: case PAL_DEVICE_OUT_WIRED_HEADPHONE: PAL_VERBOSE(LOG_TAG, "headphone device"); diff --git a/plugins/configs/qcom/mobile/default/ConfigSessionAlsaPcm/src/ConfigSessionAlsaPcm.cpp b/plugins/configs/qcom/mobile/default/ConfigSessionAlsaPcm/src/ConfigSessionAlsaPcm.cpp index 9a29fa88..c470c6ba 100644 --- a/plugins/configs/qcom/mobile/default/ConfigSessionAlsaPcm/src/ConfigSessionAlsaPcm.cpp +++ b/plugins/configs/qcom/mobile/default/ConfigSessionAlsaPcm/src/ConfigSessionAlsaPcm.cpp @@ -75,6 +75,10 @@ #include "ConfigSessionAlsaPcm.h" #include "ConfigSessionUtils.h" +#ifndef UVVOICECUE_FEATURES_DISABLED +#include "UvVoiceCueUtils.h" +#endif + // ASR handlecb def supports #include "asr_module_calibration_api.h" #include "sdz_api.h" @@ -83,6 +87,8 @@ #include #include /* Definition of SYSLOG_* constants */ #include +#include "sh_mem_pull_push_mode_api.h" +#include "history_buffer_api.h" /*interface implementation*/ extern "C" int pcmPluginConfig(Stream* stream, plugin_config_name_t config, @@ -150,19 +156,21 @@ uint32_t getMiid(SessionAlsaPcm* session, uint64_t eventId, mixer* mxr, case EVENT_ID_SH_MEM_PUSH_MODE_EOS_MARKER: tagId = SHMEM_ENDPOINT; break; - case EVENT_ID_ACD_DETECTION_EVENT : + case EVENT_ID_ACD_DETECTION_EVENT: tagId = CONTEXT_DETECTION_ENGINE; break; - case EVENT_ID_ASR_OUTPUT : + case EVENT_ID_ASR_OUTPUT: + case EVENT_ID_ASR_OUTPUT_V2: tagId = TAG_MODULE_ASR; break; case EVENT_ID_SDZ_OUTPUT: + case EVENT_ID_SDZ_OUTPUT_V2: tagId = TAG_MODULE_SDZ; break; case EVENT_ID_SH_MEM_PULL_PUSH_MODE_WATERMARK: tagId = SHMEM_ENDPOINT; break; - default : + default: PAL_ERR(LOG_TAG, "Event id %x not handled!!!", eventId); } @@ -244,6 +252,9 @@ int32_t pcmPluginConfigSetConfigStart(Stream* s, void* pluginPayload) int payload_size = 0; uint32_t tag = 0; std::vector MIIDs; + #ifndef UVVOICECUE_FEATURES_DISABLED + uint32_t currentValues; + #endif PAL_DBG(LOG_TAG, "Enter"); memset(&streamData, 0, sizeof(struct sessionToPayloadParam)); @@ -281,6 +292,81 @@ int32_t pcmPluginConfigSetConfigStart(Stream* s, void* pluginPayload) sAttr.type == PAL_STREAM_ASR || sAttr.type == PAL_STREAM_CALL_TRANSLATION) { handleEventRegistration(session, 1, mxr, txAifBackEnds, pcmDevIds); + } else if (sAttr.type == PAL_STREAM_DEEP_BUFFER && + (sAttr.flags & PAL_STREAM_FLAG_MMAP_MASK)) { + struct agm_event_reg_cfg *watermark_event_cfg = nullptr; + struct event_cfg_sh_mem_pull_push_mode_watermark_t *watermark_payload = nullptr; + struct event_cfg_sh_mem_pull_push_mode_watermark_level_t *levels = nullptr; + size_t in_buf_size = 0, in_buf_count = 0, out_buf_size = 0, out_buf_count = 0; + uint32_t period_size = 0; + uint32_t period_count = 0; + constexpr uint32_t kWatermarkNumLevels = 10; + size_t watermark_payload_size = 0; + + /* Total shared buffer with DSP = period_size * period_count. + * Register watermark at 10 equal levels + */ + s->getBufInfo(&in_buf_size, &in_buf_count, &out_buf_size, &out_buf_count); + period_size = static_cast(out_buf_size); + period_count = static_cast(out_buf_count); + const uint32_t watermarkStepBytes = + (period_size * period_count) / kWatermarkNumLevels; + + watermark_payload_size = sizeof(uint32_t) + + (kWatermarkNumLevels * sizeof(struct event_cfg_sh_mem_pull_push_mode_watermark_level_t)); + + watermark_payload = (struct event_cfg_sh_mem_pull_push_mode_watermark_t *)calloc(1, watermark_payload_size); + if (!watermark_payload) { + PAL_ERR(LOG_TAG, "Failed to allocate memory for watermark payload"); + status = -ENOMEM; + goto exit; + } + + watermark_payload->num_water_mark_levels = kWatermarkNumLevels; + levels = (struct event_cfg_sh_mem_pull_push_mode_watermark_level_t *) + ((uint8_t *)watermark_payload + sizeof(uint32_t)); + + for (uint32_t i = 0; i < kWatermarkNumLevels; ++i) { + levels[i].watermark_level_bytes = (i + 1) * watermarkStepBytes; + PAL_DBG(LOG_TAG, "watermark registered at byte %d",levels[i].watermark_level_bytes); + } + + tagId = SHMEM_ENDPOINT; + if (miid == 0 && tagId != 0) { + status = SessionAlsaUtils::getModuleInstanceId(mxr, pcmDevIds.at(0), + rxAifBackEnds[0].second.data(), tagId, &miid); + if (status) { + PAL_ERR(LOG_TAG, "Failed to get tag info %x, status = %d", tagId, status); + free(watermark_payload); + goto exit; + } + } + + payload_size = sizeof(struct agm_event_reg_cfg) + watermark_payload_size; + watermark_event_cfg = (struct agm_event_reg_cfg *)calloc(1, payload_size); + if (!watermark_event_cfg) { + PAL_ERR(LOG_TAG, "Failed to allocate memory for watermark event config"); + status = -ENOMEM; + free(watermark_payload); + goto exit; + } + + watermark_event_cfg->event_config_payload_size = watermark_payload_size; + watermark_event_cfg->is_register = 1; + watermark_event_cfg->event_id = EVENT_ID_SH_MEM_PULL_PUSH_MODE_WATERMARK; + watermark_event_cfg->module_instance_id = miid; + + memcpy(watermark_event_cfg->event_config_payload, + watermark_payload, + watermark_payload_size); + + SessionAlsaUtils::registerMixerEvent(mxr, pcmDevIds.at(0), + (void *)watermark_event_cfg, payload_size); + + free(watermark_event_cfg); + free(watermark_payload); + miid = 0; + tagId = 0; } else if (sAttr.type == PAL_STREAM_ULTRASOUND && session->getRegisterForEvents()) { payload_size = sizeof(struct agm_event_reg_cfg); std::vector pcmDevTxIds; @@ -518,6 +604,26 @@ int32_t pcmPluginConfigSetConfigStart(Stream* s, void* pluginPayload) PAL_ERR(LOG_TAG, "build MFC payload failed"); } } + #ifndef UVVOICECUE_FEATURES_DISABLED + if (sAttr.type == PAL_STREAM_VOIP_TX) { + currentValues = getUvMaskUseCaseValues(); + if ((currentValues & UV_FLUENCE_VOIP_BIT) && + (getVoiceCueDataPtr() != nullptr && getVoiceCueDataSize() > 0)) { + status = SessionAlsaUtils::getModuleInstanceId(mxr, pcmDevIds.at(0), + txAifBackEnds[0].second.data(), TAG_UVCALL_VOICECUE, &miid); + if (status != 0) { + PAL_ERR(LOG_TAG,"getModuleInstanceId failed\n"); + } else { + PAL_DBG(LOG_TAG, "Setting audio cue data update to SPF for miid : %x and id = %d\n", miid, pcmDevIds.at(0)); + status = SessionAlsaUtils::checkAndSetUvVoiceCue(s, mxr, pcmDevIds.at(0), miid, rm, builder, UV_FLUENCE_VOIP_BIT); + if (0 != status) { + PAL_ERR(LOG_TAG, "failed to initialize UV Voice feature with status :%d", status); + } + goto exit; + } + } + } + #endif set_mixer: builder->getCustomPayload(&payload, &payloadSize); status = SessionAlsaUtils::setMixerParameter(mxr, pcmDevIds.at(0), @@ -593,6 +699,22 @@ int32_t pcmPluginConfigSetConfigStart(Stream* s, void* pluginPayload) SessionAlsaUtils::setMixerParameter(mxr, pcmDevIds.at(0), payload, payloadSize); builder->freeCustomPayload(); + #ifndef UVVOICECUE_FEATURES_DISABLED + currentValues = getUvMaskUseCaseValues(); + if ((currentValues & UV_FLUENCE_SVA_BIT) && + (getVoiceCueDataPtr() != nullptr && getVoiceCueDataSize() > 0)) { + status = SessionAlsaUtils::getModuleInstanceId(mxr, pcmDevIds.at(0), txAifBackEnds[0].second.data(), TAG_UVCALL_VOICECUE, &miid); + if (status != 0) { + PAL_ERR(LOG_TAG,"getModuleInstanceId failed\n"); + } else { + PAL_DBG(LOG_TAG, "Setting audio cue data update to SPF for miid : %x and id = %d\n", miid, pcmDevIds.at(0)); + status = SessionAlsaUtils::checkAndSetUvVoiceCue(s, mxr, pcmDevIds.at(0), miid, rm, builder, UV_FLUENCE_SVA_BIT); + if (0 != status) { + PAL_ERR(LOG_TAG, "failed to initialize UV Voice feature with status :%d", status); + } + } + } + #endif } else if (sAttr.type == PAL_STREAM_ULTRA_LOW_LATENCY) { status = SessionAlsaUtils::getModuleInstanceId(mxr, pcmDevIds.at(0), txAifBackEnds[0].second.data(), @@ -697,6 +819,23 @@ int32_t pcmPluginConfigSetConfigStart(Stream* s, void* pluginPayload) status = 0; } } + #ifndef UVVOICECUE_FEATURES_DISABLED + currentValues = getUvMaskUseCaseValues(); + if ((currentValues & UV_FLUENCE_AUDIO_BIT) && + (getVoiceCueDataPtr() != nullptr && getVoiceCueDataSize() > 0)) { + status = SessionAlsaUtils::getModuleInstanceId(mxr, pcmDevIds.at(0), + txAifBackEnds[0].second.data(), TAG_UVCALL_VOICECUE, &miid); + if (status != 0) { + PAL_ERR(LOG_TAG,"getModuleInstanceId failed\n"); + } else { + PAL_DBG(LOG_TAG, "Setting audio cue data update to SPF for miid : %x and id = %d\n", miid, pcmDevIds.at(0)); + status = SessionAlsaUtils::checkAndSetUvVoiceCue(s, mxr, pcmDevIds.at(0), miid, rm, builder, UV_FLUENCE_AUDIO_BIT); + if (0 != status) { + PAL_ERR(LOG_TAG, "failed to initialize UV Voice feature with status :%d", status); + } + } + } + #endif } if (sAttr.type == PAL_STREAM_CALL_TRANSLATION) { status = configureCallTranslationModules(s, builder, mxr, session, rm); diff --git a/plugins/configs/qcom/mobile/default/ConfigSessionAlsaVoice/src/ConfigSessionAlsaVoice.cpp b/plugins/configs/qcom/mobile/default/ConfigSessionAlsaVoice/src/ConfigSessionAlsaVoice.cpp index 5aeac613..eef13163 100644 --- a/plugins/configs/qcom/mobile/default/ConfigSessionAlsaVoice/src/ConfigSessionAlsaVoice.cpp +++ b/plugins/configs/qcom/mobile/default/ConfigSessionAlsaVoice/src/ConfigSessionAlsaVoice.cpp @@ -61,6 +61,10 @@ SPDX-License-Identifier: BSD-3-Clause-Clear #include "ConfigSessionUtils.h" #include "ConfigSessionAlsaVoice.h" +#ifndef UVVOICECUE_FEATURES_DISABLED +#include "UvVoiceCueUtils.h" +#endif + #define POP_SUPPRESSOR_RAMP_DELAY (1*1000) /*interface implementation*/ @@ -219,9 +223,38 @@ int32_t voicePostReconfig(Stream* s, void* pluginPayload) { struct ReconfigPluginPayload* reconfigPld = nullptr; reconfigPld = reinterpret_cast(pluginPayload); std::shared_ptr rm = nullptr; - PAL_DBG(LOG_TAG,"Enter"); rm = ResourceManager::getInstance(); + +#ifndef UVVOICECUE_FEATURES_DISABLED + uint32_t miid = 0; + struct mixer* mxr = nullptr; + uint32_t currentValues; + PayloadBuilder* builder = nullptr; + Session* sess = nullptr; + SessionAlsaVoice* session = nullptr; + std::vector pcmDevIds; + std::vector> txAifBackEnds; + status = rm->getVirtualAudioMixer(&mxr); + if (status) { + PAL_ERR(LOG_TAG, "mixer error"); + goto exit; + } + status = s->getAssociatedSession(&sess); + if (0 != status) { + PAL_ERR(LOG_TAG, "getAssociatedSession Failed \n"); + goto exit; + } + session = static_cast(sess); + status = session->getFrontEndIds(pcmDevIds, TX_HOSTLESS); + if (status) { + PAL_ERR(LOG_TAG, "getFrontEndIds failed %d", status); + goto exit; + } + txAifBackEnds = session->getTxBEVecRef(); + builder = new PayloadBuilder(); +#endif + if (!reconfigPld->config_ctrl.compare("silence_detection")) { status = voiceSilenceDetectionConfig(SD_CONNECT, &reconfigPld->dAttr, pluginPayload); if (status) { @@ -231,7 +264,29 @@ int32_t voicePostReconfig(Stream* s, void* pluginPayload) { status = rxMFCCoeffConfig(s, pluginPayload); } +#ifndef UVVOICECUE_FEATURES_DISABLED + currentValues = getUvMaskUseCaseValues(); + if ((currentValues & UV_FLUENCE_TELEPHONY_BIT) && + (getVoiceCueDataPtr() != nullptr && getVoiceCueDataSize() > 0)) { + PAL_DBG(LOG_TAG,"Enter UV post config : 2"); + status = SessionAlsaUtils::getModuleInstanceId(mxr, pcmDevIds.at(0), + txAifBackEnds[0].second.data(), TAG_UVCALL_VOICECUE, &miid); + if (status != 0) { + PAL_ERR(LOG_TAG,"getModuleInstanceId failed\n"); + goto exit; + } else { + PAL_DBG(LOG_TAG, "Setting audio cue data update to SPF for miid : %x and id = %d\n", miid, pcmDevIds.at(0)); + status = SessionAlsaUtils::checkAndSetUvVoiceCue(s, mxr, pcmDevIds.at(0), miid, rm, builder, UV_FLUENCE_TELEPHONY_BIT); + if (0 != status) { + PAL_ERR(LOG_TAG, "failed to initialize UV Voice feature with status :%d", status); + } + } + } +#endif + exit: + if (builder) + delete builder; PAL_DBG(LOG_TAG,"Exit ret: %d", status); return status; } @@ -318,6 +373,10 @@ int32_t voicePluginConfigSetConfigStart(Stream* s, void* pluginPayload) std::vector> associatedDevices; std::vector> txAifBackEnds; ReconfigPluginPayload ppld; +#ifndef UVVOICECUE_FEATURES_DISABLED + uint32_t miid = 0; + uint32_t currentValues; +#endif PAL_DBG(LOG_TAG,"Enter"); rm = ResourceManager::getInstance(); @@ -416,6 +475,24 @@ int32_t voicePluginConfigSetConfigStart(Stream* s, void* pluginPayload) silence_det_setup_done: status = 0; } +#ifndef UVVOICECUE_FEATURES_DISABLED + currentValues = getUvMaskUseCaseValues(); + if ((currentValues & UV_FLUENCE_TELEPHONY_BIT) && + (getVoiceCueDataPtr() != nullptr && getVoiceCueDataSize() > 0)) { + status = SessionAlsaUtils::getModuleInstanceId(mxr, pcmDevIds.at(0), + txAifBackEnds[0].second.data(), TAG_UVCALL_VOICECUE, &miid); + if (status != 0) { + PAL_ERR(LOG_TAG,"getModuleInstanceId failed\n"); + goto exit; + } else { + PAL_DBG(LOG_TAG, "Setting audio cue data update to SPF for miid : %x and id = %d\n", miid, pcmDevIds.at(0)); + status = SessionAlsaUtils::checkAndSetUvVoiceCue(s, mxr, pcmDevIds.at(0), miid, rm, builder, UV_FLUENCE_TELEPHONY_BIT); + if (0 != status) { + PAL_ERR(LOG_TAG, "failed to initialize UV Voice feature with status :%d", status); + } + } + } +#endif exit: if (builder) delete builder; diff --git a/plugins/configs/qcom/mobile/default/ConfigSessionUtils/inc/ConfigSessionUtils.h b/plugins/configs/qcom/mobile/default/ConfigSessionUtils/inc/ConfigSessionUtils.h index b3cd3b8b..17b70dc3 100644 --- a/plugins/configs/qcom/mobile/default/ConfigSessionUtils/inc/ConfigSessionUtils.h +++ b/plugins/configs/qcom/mobile/default/ConfigSessionUtils/inc/ConfigSessionUtils.h @@ -37,4 +37,10 @@ int disableSilenceDetection(const std::shared_ptr rm, /* Forward Declaration for Silence Detection Callback */ void handleSilenceDetectionCb(uint64_t hdl __unused, uint32_t event_id, void *event_data, uint32_t event_size); +#ifndef UVVOICECUE_FEATURES_DISABLED +int32_t pcmPostReconfigSetUvVoiceCue(Stream *streamHandle, + Session *sess, + struct mixer *mixerHandle, + const std::vector &pcmDevIds); +#endif #endif diff --git a/plugins/configs/qcom/mobile/default/ConfigSessionUtils/src/ConfigSessionUtils.cpp b/plugins/configs/qcom/mobile/default/ConfigSessionUtils/src/ConfigSessionUtils.cpp index 38f73be0..1a5266cc 100644 --- a/plugins/configs/qcom/mobile/default/ConfigSessionUtils/src/ConfigSessionUtils.cpp +++ b/plugins/configs/qcom/mobile/default/ConfigSessionUtils/src/ConfigSessionUtils.cpp @@ -58,6 +58,9 @@ #include "SessionAlsaPcm.h" #include "SessionAlsaUtils.h" #include "ConfigSessionUtils.h" +#ifndef UVVOICECUE_FEATURES_DISABLED +#include "UvVoiceCueUtils.h" +#endif #include "apm_api.h" #include #include @@ -260,6 +263,13 @@ int reconfigCommon(Stream* streamHandle, void* pluginPayload) PAL_ERR(LOG_TAG, "setMixerParameter failed"); goto exit; } + #ifndef UVVOICECUE_FEATURES_DISABLED + status = pcmPostReconfigSetUvVoiceCue(streamHandle, sess, mixerHandle, pcmDevIds); + if (status != 0) { + PAL_ERR(LOG_TAG, "pcm post reconfig UV cue update failed %d", status); + goto exit; + } + #endif exit: if (builder) { @@ -1137,3 +1147,94 @@ void handleSilenceDetectionCb(uint64_t hdl __unused, uint32_t event_id, void *ev return; } +#ifndef UVVOICECUE_FEATURES_DISABLED +int32_t pcmPostReconfigSetUvVoiceCue(Stream *streamHandle, + Session *sess, + struct mixer *mixerHandle, + const std::vector &pcmDevIds) +{ + int32_t status = 0; + uint32_t miid = 0; + uint32_t currentValues = 0; + uint32_t uvBit = 0; + pal_stream_attributes sAttr = {}; + SessionAlsaPcm *session = nullptr; + std::shared_ptr rm = nullptr; + std::vector> txAifBackEnds; + PayloadBuilder *builder = nullptr; + + if (!streamHandle || !sess || !mixerHandle) { + PAL_ERR(LOG_TAG, "Invalid input"); + return -EINVAL; + } + if (pcmDevIds.empty()) { + PAL_ERR(LOG_TAG, "pcmDevIds is empty"); + return -EINVAL; + } + if (getVoiceCueDataPtr() == nullptr || getVoiceCueDataSize() == 0) { + PAL_DBG(LOG_TAG, "No voice cue data present, skipping"); + return 0; + } + status = streamHandle->getStreamAttributes(&sAttr); + if (status) { + PAL_ERR(LOG_TAG, "getStreamAttributes failed %d", status); + return status; + } + switch (sAttr.type) { + case PAL_STREAM_VOIP_TX: + uvBit = UV_FLUENCE_VOIP_BIT; + break; + case PAL_STREAM_VOICE_UI: + case PAL_STREAM_ASR: + case PAL_STREAM_ACD: + uvBit = UV_FLUENCE_SVA_BIT; + break; + case PAL_STREAM_DEEP_BUFFER: + uvBit = UV_FLUENCE_AUDIO_BIT; + break; + default: + PAL_DBG(LOG_TAG, "UV cue not needed for stream type %d", sAttr.type); + return 0; + } + currentValues = getUvMaskUseCaseValues(); + if (!(currentValues & uvBit)) { + PAL_DBG(LOG_TAG, "UV mask not enabled for stream type %d", sAttr.type); + return 0; + } + + rm = ResourceManager::getInstance(); + session = static_cast(sess); + txAifBackEnds = session->getTxBEVecRef(); + + if (txAifBackEnds.empty()) { + PAL_ERR(LOG_TAG, "txAifBackEnds is empty"); + return -EINVAL; + } + builder = new PayloadBuilder(); + status = SessionAlsaUtils::getModuleInstanceId(mixerHandle, + pcmDevIds.at(0), + txAifBackEnds[0].second.data(), + TAG_UVCALL_VOICECUE, + &miid); + if (status != 0) { + PAL_ERR(LOG_TAG, "getModuleInstanceId failed"); + goto exit; + } + PAL_DBG(LOG_TAG, "Setting audio cue data update to SPF for miid : %x and id = %d", + miid, pcmDevIds.at(0)); + status = SessionAlsaUtils::checkAndSetUvVoiceCue(streamHandle, + mixerHandle, + pcmDevIds.at(0), + miid, + rm, + builder, + uvBit); + if (status != 0) { + PAL_ERR(LOG_TAG, "failed to initialize UV Voice feature with status :%d", status); + } +exit: + if (builder) + delete builder; + return status; +} +#endif \ No newline at end of file diff --git a/plugins/vui_interface/api/vui-interface/SoundTriggerUtils.h b/plugins/vui_interface/api/vui-interface/SoundTriggerUtils.h index 6350c695..6994280d 100644 --- a/plugins/vui_interface/api/vui-interface/SoundTriggerUtils.h +++ b/plugins/vui_interface/api/vui-interface/SoundTriggerUtils.h @@ -433,6 +433,7 @@ typedef enum mma_mode_bit_type { CAMERA_FACE = 4, CAMERA_GAZE = 5, ONOFFBODY_DETECTION = 6, + AMD = 7, } mma_mode_bit_type_t; typedef struct tiuv_threshold_config { diff --git a/resource_manager/src/ResourceManager.cpp b/resource_manager/src/ResourceManager.cpp index 85047703..5937be28 100644 --- a/resource_manager/src/ResourceManager.cpp +++ b/resource_manager/src/ResourceManager.cpp @@ -64,6 +64,10 @@ #include "BTUtils.h" #endif +#ifndef UVVOICECUE_FEATURES_DISABLED +#include "UvVoiceCueUtils.h" +#endif + #ifdef PAL_CUTILS_SUPPORTED @@ -985,6 +989,10 @@ ResourceManager::ResourceManager() throw std::runtime_error("Failed to allocate ContextManager"); } + #ifndef UVVOICECUE_FEATURES_DISABLED + PAL_DBG(LOG_TAG, "Retrieve the Cue Data from bin file if it already exists."); + retrieveVoiceCueFromFile(); + #endif #ifdef SOC_PERIPHERAL_PROT socPerithread = std::thread(loadSocPeripheralLib); @@ -2632,7 +2640,7 @@ bool ResourceManager::isStreamSupported(Stream *s, struct pal_device *devices, i } if (cur_sessions - 1 == max_sessions) { - PAL_DBG(LOG_TAG, "current sessions is %d, maximum sessions is %d", cur_sessions, max_sessions); + PAL_DBG(LOG_TAG, "current sessions is %zu, maximum sessions is %zu", cur_sessions, max_sessions); PAL_ERR(LOG_TAG, "no new session allowed for stream %d", attributes.type); goto exit; } @@ -5547,7 +5555,7 @@ int ResourceManager::findActiveStreamsNotInDisconnectList( rm->getActiveStream_l(activeStreams, devObj); - PAL_DBG(LOG_TAG, "activeStreams size = %d, device: %s", activeStreams.size(), + PAL_DBG(LOG_TAG, "activeStreams size = %zu, device: %s", activeStreams.size(), deviceNameLUT.at((pal_device_id_t)devObj->getSndDeviceId()).c_str()); for (sIter = activeStreams.begin(); sIter != activeStreams.end(); sIter++) { @@ -7693,6 +7701,24 @@ int ResourceManager::setParameter(uint32_t param_id, void *param_payload, PAL_DBG(LOG_TAG, "wnr module enable state updated to %d", rm->wnrEnableStatus); } break; + case PAL_PARAM_ID_UV_VOICE_CUE_ENABLE: + { + #ifndef UVVOICECUE_FEATURES_DISABLED + status = handleUvVoiceCueEnable(param_payload, payload_size); + if (status) + PAL_ERR(LOG_TAG, "handleUvVoiceCueEnable failed, status %d", status); + #endif + break; + } + case PAL_PARAM_ID_UV_VOICE_CUE_DATA_BYTE: + { + #ifndef UVVOICECUE_FEATURES_DISABLED + status = handleUvVoiceCueData(param_payload, payload_size); + if (status) + PAL_ERR(LOG_TAG, "handleUvVoiceCueData failed, status %d", status); + #endif + break; + } default: #ifndef SOUND_TRIGGER_FEATURES_DISABLED mResourceManagerMutex.unlock(); @@ -10005,7 +10031,7 @@ void ResourceManager::WbSpeechConfig(pal_device_id_t devId, dev->getDeviceAttributes(&curDevAttr); status = dev->setDeviceParameter(param_id, param_payload); if (status) - PAL_ERR(LOG_TAG, "set device param %d, status: ", param_id, status); + PAL_ERR(LOG_TAG, "set device param %d, status: %d", param_id, status); // check and force device switch if SCO is connected. if (!dev->isDeviceReady(devId)) return; @@ -10298,7 +10324,7 @@ int ResourceManager::setUltrasoundGain(pal_ultrasound_gain_t gain, Stream *s) } else { status = getActiveStream_l(activeStreams, NULL); if ((0 != status) || (activeStreams.size() == 0)) { - PAL_DBG(LOG_TAG, "No active stream available, status = %d, nStream = %d", + PAL_DBG(LOG_TAG, "No active stream available, status = %d, nStream = %zu", status, activeStreams.size()); return -ENOENT; } @@ -10388,4 +10414,4 @@ int ResourceManager::setUltrasoundGain(pal_ultrasound_gain_t gain, Stream *s) } return status; -} +} \ No newline at end of file diff --git a/session/SessionAR/Makefile.am b/session/SessionAR/Makefile.am index 6c18fb44..9cab0d11 100644 --- a/session/SessionAR/Makefile.am +++ b/session/SessionAR/Makefile.am @@ -52,6 +52,7 @@ libsession_ar_la_LDFLAGS = -shared -avoid-version libsession_ar_la_CPPFLAGS += @GLIB_CFLAGS@ -include glib.h libsession_ar_la_CPPFLAGS += -DACD_SM_FILEPATH=\"/etc/models/acd/\" libsession_ar_la_CPPFLAGS += -D__unused=__attribute__\(\(__unused__\)\) -DLINUX_ENABLED +libsession_ar_la_CPPFLAGS += @UVVOICECUE_FEATURE_FLAGS@ if USE_SYSLOG libsession_ar_la_CPPFLAGS += -DPAL_USE_SYSLOG diff --git a/session/SessionAR/inc/PayloadBuilder.h b/session/SessionAR/inc/PayloadBuilder.h index 688fd9af..7064f457 100644 --- a/session/SessionAR/inc/PayloadBuilder.h +++ b/session/SessionAR/inc/PayloadBuilder.h @@ -293,7 +293,10 @@ class PayloadBuilder pal_param_dtmf_gen_tone_cfg_t *dtmf_payload); int payloadSoundDoseInfo(uint8_t **payload, size_t *size, uint32_t moduleId); - +#ifndef UVVOICECUE_FEATURES_DISABLED + void payloadUvVoiceCueData(uint8_t** payload, size_t* size, + uint32_t miid, void *cueData, uint32_t usecaseMask); +#endif int populateStreamKV(Stream* s, std::vector > &keyVector); int populateStreamKV(Stream* s, std::vector > &keyVectorRx, std::vector > &keyVectorTx ,struct vsid_info vsidinfo); diff --git a/session/SessionAR/inc/SessionAR.h b/session/SessionAR/inc/SessionAR.h index 30a4c2a8..c741c97d 100644 --- a/session/SessionAR/inc/SessionAR.h +++ b/session/SessionAR/inc/SessionAR.h @@ -138,7 +138,7 @@ class SessionAR : public Session int setEffectParameters(Stream *s, effect_pal_payload_t *effectPayload); public: SessionAR(); - static void handleSoftPauseCallBack(uint64_t hdl, uint32_t event_id, void *data, uint32_t event_size); + static void handleSessionCallback(uint64_t hdl, uint32_t event_id, void *data, uint32_t event_size); int HDRConfigKeyToDevOrientation(const char* hdr_custom_key); void setPmQosMixerCtl(pmQosVote vote); virtual int32_t getParameters(Stream *s, uint32_t param_id, void **payload) override; diff --git a/session/SessionAR/inc/SessionAlsaUtils.h b/session/SessionAR/inc/SessionAlsaUtils.h index 48335e11..22f3a326 100644 --- a/session/SessionAR/inc/SessionAlsaUtils.h +++ b/session/SessionAR/inc/SessionAlsaUtils.h @@ -26,9 +26,9 @@ * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * - * Changes from Qualcomm Innovation Center, Inc. are provided under the following license: - * Copyright (c) 2023-2025 Qualcomm Innovation Center, Inc. All rights reserved. - * SPDX-License-Identifier: BSD-3-Clause-Clear + * Changes from Qualcomm Technologies, Inc. are provided under the following license: + * Copyright (c) Qualcomm Technologies, Inc. and/or its subsidiaries. + * SPDX-License-Identifier: BSD-3-Clause-Clear */ #ifndef SESSION_ALSAUTILS_H @@ -190,7 +190,9 @@ class SessionAlsaUtils void *payload, int size); static int flush(std::shared_ptr rm, uint32_t id); static int getScoDevCount(void); - +#ifndef UVVOICECUE_FEATURES_DISABLED + static int checkAndSetUvVoiceCue(Stream *s, struct mixer *mixer, int device, uint32_t miid, const std::shared_ptr& rm, PayloadBuilder* builder, uint32_t usecaseMask); +#endif }; #endif //SESSION_ALSA_UTILS diff --git a/session/SessionAR/src/PayloadBuilder.cpp b/session/SessionAR/src/PayloadBuilder.cpp index 248297bd..3f0800cd 100644 --- a/session/SessionAR/src/PayloadBuilder.cpp +++ b/session/SessionAR/src/PayloadBuilder.cpp @@ -92,6 +92,11 @@ #define PARAM_ID_MODULE_ENABLE 0x08001026 +#ifndef UVVOICECUE_FEATURES_DISABLED +#define PARAM_ID_FFECNS_VOICECUE 0x08001BB2 +#define PARAM_ID_FLUENCE_NN_VOICECUE 0x08001AD3 +#endif + /* ID of the Master Gain parameter used by MODULE_ID_VOL_CTRL. */ #define PARAM_ID_VOL_CTRL_MASTER_GAIN 0x08001035 /* ID of the channel mixer coeff for MODULE_ID_MFC */ @@ -3237,6 +3242,12 @@ int PayloadBuilder::populateStreamKV(Stream* s, "bit_perfect")); PAL_INFO(LOG_TAG, "BitPerfect Playback, hence select PCM_IMMUTABLE KV"); } + } else if (sattr->type == PAL_STREAM_DEEP_BUFFER && + (sattr->flags & PAL_STREAM_FLAG_MMAP_MASK)) { + filled_selector_pairs.push_back( + std::make_pair(CUSTOM_CONFIG_SEL, + "deep_buffer_mmap")); + PAL_INFO(LOG_TAG, "Deep buffer playback in mmap mode"); } retrieveKVs(filled_selector_pairs ,sattr->type, all_streams, keyVector); @@ -3850,15 +3861,23 @@ int PayloadBuilder::populateCalKeyVector(Stream *s, std::vector 1) { - PAL_DBG(LOG_TAG, "Multi channel speaker"); - ckv.push_back(std::make_pair(SPK_PRO_DEV_MAP, LEFT_RIGHT)); - } - else { - PAL_DBG(LOG_TAG, "Mono channel speaker"); - ckv.push_back(std::make_pair(SPK_PRO_DEV_MAP, RIGHT_MONO)); - } - break; + switch (dAttr.config.ch_info.channels) { + case 1: + PAL_DBG(LOG_TAG, "Mono channel speaker"); + ckv.push_back(std::make_pair(SPK_PRO_DEV_MAP, RIGHT_MONO)); + break; + case 2: + PAL_DBG(LOG_TAG, "Stereo channel speaker"); + ckv.push_back(std::make_pair(SPK_PRO_DEV_MAP, LEFT_RIGHT)); + break; + case 4: + PAL_DBG(LOG_TAG, "QUAD channel speaker"); + ckv.push_back(std::make_pair(SPK_PRO_DEV_MAP, LEFT_RIGHT_QUAD)); + break; + default: + PAL_DBG(LOG_TAG, "Unsupport number of channels %d", dAttr.config.ch_info.channels); + } + break; } } break; @@ -5803,3 +5822,54 @@ void PayloadBuilder::payloadVoiceNsRxConfigEnableDisable(uint8_t** payload, size PAL_DBG(LOG_TAG, "customPayload address %p and size %zu", payloadInfo, *size); } + +#ifndef UVVOICECUE_FEATURES_DISABLED +void PayloadBuilder::payloadUvVoiceCueData(uint8_t** payload, size_t* size, + uint32_t miid, void *cueData, uint32_t usecaseMask) +{ + struct apm_module_param_data_t* header = NULL; + uint8_t* payloadInfo = NULL; + size_t payloadSize = 0, padBytes = 0; + pal_param_payload *palPayload = (pal_param_payload *)cueData; + + payloadSize = sizeof(struct apm_module_param_data_t) + palPayload->payload_size; + padBytes = PAL_PADDING_8BYTE_ALIGN(payloadSize); + + payloadInfo = (uint8_t*) calloc(1, payloadSize + padBytes); + if (!payloadInfo) { + PAL_ERR(LOG_TAG, "payloadInfo malloc failed %s", strerror(errno)); + return; + } + header = (struct apm_module_param_data_t *)payloadInfo; + header->module_instance_id = miid; + + switch (usecaseMask) { + case UV_FLUENCE_TELEPHONY_BIT: + case UV_FLUENCE_VOIP_BIT: + header->param_id = PARAM_ID_FLUENCE_NN_VOICECUE; + break; + case UV_FLUENCE_AUDIO_BIT: + case UV_FLUENCE_SVA_BIT: + header->param_id = PARAM_ID_FFECNS_VOICECUE; + break; + default: + PAL_ERR(LOG_TAG, "Invalid UV usecaseMask 0x%x", usecaseMask); + free(payloadInfo); + return; + } + + header->error_code = 0x0; + header->param_size = payloadSize - sizeof(struct apm_module_param_data_t); + PAL_DBG(LOG_TAG, "header params \n IID:%x param_id:%x error_code:%d param_size:%d", + header->module_instance_id, header->param_id, + header->error_code, header->param_size); + + uint8_t *dataPayload = (uint8_t *)(payloadInfo + sizeof(struct apm_module_param_data_t)); + memcpy(dataPayload, palPayload->payload, palPayload->payload_size); + + *size = payloadSize + padBytes; + *payload = payloadInfo; + PAL_DBG(LOG_TAG, "customPayload address %pK and size %zu", payloadInfo, + *size); +} +#endif \ No newline at end of file diff --git a/session/SessionAR/src/SessionAR.cpp b/session/SessionAR/src/SessionAR.cpp index 988f8db9..c31d262a 100644 --- a/session/SessionAR/src/SessionAR.cpp +++ b/session/SessionAR/src/SessionAR.cpp @@ -42,6 +42,7 @@ #include #include "apm_api.h" #include +#include "sh_mem_pull_push_mode_api.h" struct pcm *SessionAR::pcmEcTx = NULL; std::vector SessionAR::pcmDevEcTxIds = {0}; @@ -59,16 +60,27 @@ SessionAR::SessionAR() { } } -void SessionAR::handleSoftPauseCallBack(uint64_t hdl, uint32_t event_id, - void *data __unused, - uint32_t event_size __unused) +void SessionAR::handleSessionCallback(uint64_t hdl, uint32_t event_id, + void *data, + uint32_t event_size) { + Stream *s = NULL; + pal_stream_callback cb; + PAL_DBG(LOG_TAG,"Event id %x ", event_id); if (event_id == EVENT_ID_SOFT_PAUSE_PAUSE_COMPLETE) { PAL_DBG(LOG_TAG, "Pause done"); pauseCV.notify_all(); } + if (event_id == EVENT_ID_SH_MEM_PULL_PUSH_MODE_WATERMARK) { + PAL_DBG(LOG_TAG, "Watermark event received, notifying client"); + s = reinterpret_cast(hdl); + if (s->getCallBack(&cb) == 0) { + cb(reinterpret_cast(s), event_id, (uint32_t *)data, + event_size, s->cookie); + } + } } void SessionAR::setPmQosMixerCtl(pmQosVote vote) diff --git a/session/SessionAR/src/SessionAlsaUtils.cpp b/session/SessionAR/src/SessionAlsaUtils.cpp index 2b6e1af5..810b9cc5 100644 --- a/session/SessionAR/src/SessionAlsaUtils.cpp +++ b/session/SessionAR/src/SessionAlsaUtils.cpp @@ -48,6 +48,10 @@ #include #include "gsl_intf.h" +#ifndef UVVOICECUE_FEATURES_DISABLED +#include "UvVoiceCueUtils.h" +#endif + static constexpr const char* const COMPRESS_SND_DEV_NAME_PREFIX = "COMPRESS"; static constexpr const char* const PCM_SND_DEV_NAME_PREFIX = "PCM"; static constexpr const char* const PCM_SND_VOICE_DEV_NAME_PREFIX = "VOICEMMODE"; @@ -279,13 +283,16 @@ int SessionAlsaUtils::getCalMetadata(std::vector > &ckv, stru } bool SessionAlsaUtils::isMmapUsecase(struct pal_stream_attributes &sAttr) -{ - return ((sAttr.type == PAL_STREAM_ULTRA_LOW_LATENCY) && - ((sAttr.flags & PAL_STREAM_FLAG_MMAP_MASK) - ||(sAttr.flags & PAL_STREAM_FLAG_MMAP_NO_IRQ_MASK)) - ); + { + bool isUllWithMmap = (sAttr.type == PAL_STREAM_ULTRA_LOW_LATENCY) && + ((sAttr.flags & PAL_STREAM_FLAG_MMAP_MASK) || + (sAttr.flags & PAL_STREAM_FLAG_MMAP_NO_IRQ_MASK)); -} + bool isDeepBufferWithMmap = (sAttr.type == PAL_STREAM_DEEP_BUFFER) && + (sAttr.flags & PAL_STREAM_FLAG_MMAP_MASK); + + return isUllWithMmap || isDeepBufferWithMmap; + } struct mixer_ctl *SessionAlsaUtils::getStaticMixerControl(struct mixer *am, std::string name) { @@ -2792,3 +2799,47 @@ int32_t SessionAlsaUtils::pauseInCallMusic() { PAL_DBG(LOG_TAG,"Exit ret: %d", status); return status; } + +#ifndef UVVOICECUE_FEATURES_DISABLED +int SessionAlsaUtils::checkAndSetUvVoiceCue(Stream *s, struct mixer *mixer, int device, uint32_t miid, const std::shared_ptr& rm, PayloadBuilder* builder, uint32_t usecaseMask) +{ + int status = 0; + uint8_t* payload = NULL; + size_t payloadSize = 0; + + PAL_DBG(LOG_TAG, "%s: Enter", __func__); + if(getVoiceCueDataPtr() != nullptr && getVoiceCueDataSize() > 0) { + size_t byteSize = sizeof(pal_param_payload) + getVoiceCueDataSize(); + std::unique_ptr bytes = std::make_unique(byteSize); + pal_param_payload *palParamPayload = reinterpret_cast(bytes.get()); + palParamPayload->payload_size = getVoiceCueDataSize(); + memcpy(palParamPayload->payload, getVoiceCueDataPtr(), getVoiceCueDataSize()); + + PAL_DBG(LOG_TAG,"%s: setting cached voice cue", __func__); + builder->payloadUvVoiceCueData(&payload, &payloadSize, miid, palParamPayload, usecaseMask); + if (payload && payloadSize) { + status = builder->updateCustomPayload(payload, payloadSize); + builder->freeCustomPayload(&payload, &payloadSize); + if (status != 0) + PAL_ERR(LOG_TAG,"updateCustomPayload Failed\n"); + } + if (status != 0) { + PAL_ERR(LOG_TAG,"Configuring blob data for UV Voice Call failed with status %d", status); + goto exit; + } + builder->getCustomPayload(&payload, &payloadSize); + status = SessionAlsaUtils::setMixerParameter(mixer, device, + payload, payloadSize); + builder->freeCustomPayload(); + if (status != 0) { + PAL_ERR(LOG_TAG,"setMixerParameter failed"); + goto exit; + } + } else { + PAL_DBG(LOG_TAG,"%s: voice cue is not set", __func__); + } +exit: + PAL_DBG(LOG_TAG, "%s: Exit", __func__); + return status; +} +#endif \ No newline at end of file diff --git a/session/SessionAlsaPcm/src/SessionAlsaPcm.cpp b/session/SessionAlsaPcm/src/SessionAlsaPcm.cpp index 2d94d938..cd69258a 100644 --- a/session/SessionAlsaPcm/src/SessionAlsaPcm.cpp +++ b/session/SessionAlsaPcm/src/SessionAlsaPcm.cpp @@ -168,11 +168,11 @@ int SessionAlsaPcm::open(Stream * s) goto exit; } - // Register for Soft pause events + // Register for events if (sAttr.direction == PAL_AUDIO_OUTPUT && sAttr.type != PAL_STREAM_HAPTICS && sAttr.type != PAL_STREAM_CALL_TRANSLATION) - registerCallBack(handleSoftPauseCallBack, (uint64_t)s); + registerCallBack(handleSessionCallback, (uint64_t)s); // enable dual mono if (rm->IsDualMonoEnabled() == true) { @@ -1537,7 +1537,6 @@ int SessionAlsaPcm::close(Stream * s) sAttr.type == PAL_STREAM_SENSOR_PCM_DATA) ldir = TX_HOSTLESS; - freeFrontEndIds(sAttr, ldir); pcm = NULL; break; case PAL_AUDIO_OUTPUT: @@ -1608,7 +1607,6 @@ int SessionAlsaPcm::close(Stream * s) (sAttr.type == PAL_STREAM_SENSOR_PCM_RENDERER)) ldir = RX_HOSTLESS; - freeFrontEndIds(sAttr, ldir); pcm = NULL; break; case PAL_AUDIO_INPUT | PAL_AUDIO_OUTPUT: @@ -1658,23 +1656,17 @@ int SessionAlsaPcm::close(Stream * s) PAL_ERR(LOG_TAG, "pcm_close - tx failed %d", status); } - if (pcmDevRxIds.size()) - freeFrontEndIds(sAttr, RX_HOSTLESS); - if (pcmDevTxIds.size()) - freeFrontEndIds(sAttr, TX_HOSTLESS); pcmRx = NULL; pcmTx = NULL; break; } - frontEndIdAllocated = false; - mState = SESSION_IDLE; if (sAttr.type == PAL_STREAM_VOICE_UI || sAttr.type == PAL_STREAM_ACD || sAttr.type == PAL_STREAM_ASR || sAttr.type == PAL_STREAM_CONTEXT_PROXY || sAttr.type == PAL_STREAM_ULTRASOUND || - sAttr.type ==PAL_STREAM_CALL_TRANSLATION || + sAttr.type == PAL_STREAM_CALL_TRANSLATION || (sAttr.type == PAL_STREAM_HAPTICS && sAttr.info.opt_stream_info.haptics_type == PAL_STREAM_HAPTICS_TOUCH)) { switch (sAttr.type) { @@ -1699,6 +1691,18 @@ int SessionAlsaPcm::close(Stream * s) } } + if (sAttr.direction == PAL_AUDIO_INPUT || + sAttr.direction == PAL_AUDIO_OUTPUT) { + freeFrontEndIds(sAttr, ldir); + } else { + if (pcmDevRxIds.size()) + freeFrontEndIds(sAttr, RX_HOSTLESS); + if (pcmDevTxIds.size()) + freeFrontEndIds(sAttr, TX_HOSTLESS); + } + frontEndIdAllocated = false; + mState = SESSION_IDLE; + builder->freeCustomPayload(); if (eventPayloadList.size() > 0) clearEventPayloadList(); @@ -3323,7 +3327,11 @@ int SessionAlsaPcm::getTagsWithModuleInfo(custom_payload_uc_info_t* uc_info, } - if (uc_info->direction == PAL_AUDIO_INPUT) { + if (uc_info->pal_stream_type == PAL_STREAM_SENSOR_PCM_RENDERER){ + status = SessionAlsaUtils::getTagsWithModuleInfo(mixer, DeviceId, + rxAifBackEnds[0].second.data(), payload); + } else if (uc_info->direction == PAL_AUDIO_INPUT || + uc_info->direction == PAL_AUDIO_INPUT_OUTPUT ) { status = SessionAlsaUtils::getTagsWithModuleInfo(mixer, DeviceId, txAifBackEnds[0].second.data(), payload); } else if (uc_info->direction == PAL_AUDIO_OUTPUT) { diff --git a/stream/StreamSoundTrigger/src/SoundTriggerEngineGsl.cpp b/stream/StreamSoundTrigger/src/SoundTriggerEngineGsl.cpp index 7de81826..6b7f9a65 100644 --- a/stream/StreamSoundTrigger/src/SoundTriggerEngineGsl.cpp +++ b/stream/StreamSoundTrigger/src/SoundTriggerEngineGsl.cpp @@ -222,6 +222,7 @@ int32_t SoundTriggerEngineGsl::ReadMmapBufWriteToRingBuf(size_t& offset, size_t size_t size = 0; PAL_DBG(LOG_TAG, "Bytes to read and write in ring buffer is : %d", size_to_read); + PAL_DBG(LOG_TAG, "Offset : %d, mmap write position : %d", offset, mmap_write_position_); if (offset + size_to_read <= mmap_buffer_size_) { size = buffer_->write((void *)((uint8_t *)mmap_buffer_.buffer + offset), size_to_read); if (vui_ptfm_info_->GetEnableDebugDumps()) { @@ -234,7 +235,7 @@ int32_t SoundTriggerEngineGsl::ReadMmapBufWriteToRingBuf(size_t& offset, size_t mmap_buffer_size_ - offset); if (vui_ptfm_info_->GetEnableDebugDumps()) { ST_DBG_FILE_WRITE(dsp_output_fd, (void *)((uint8_t *)mmap_buffer_.buffer + offset), - size_to_read); + mmap_buffer_size_ - offset); } size += buffer_->write((void *)mmap_buffer_.buffer, size_to_read + offset - mmap_buffer_size_); @@ -245,7 +246,8 @@ int32_t SoundTriggerEngineGsl::ReadMmapBufWriteToRingBuf(size_t& offset, size_t offset = size_to_read + offset - mmap_buffer_size_; } mmap_write_position_ += BytesToFrames(size_to_read); - PAL_DBG(LOG_TAG, "%d written to ring buffer", size); + PAL_DBG(LOG_TAG, "Bytes written to ring buffer : %d, mmap write position : %d", + size, mmap_write_position_); return 0; } @@ -410,11 +412,17 @@ int32_t SoundTriggerEngineGsl::StartBuffering(StreamSoundTrigger *s) { ATRACE_ASYNC_BEGIN("stEngine: lab read", (int32_t)module_type_); #endif if (mmap_buffer_size_ != 0) { - status = BytesToRead(s, size_to_read); - if (status) { - PAL_ERR(LOG_TAG, "Failed to get bytes to read"); - status = -EINVAL; - goto exit; + if (batch_mode_) { + param.data = &size_to_read; + vui_intf_->GetParameter(PARAM_MMAP_BYTES_TO_READ, ¶m); + PAL_INFO(LOG_TAG, "Bytes to read : %d", size_to_read); + } else { + status = BytesToRead(s, size_to_read); + if (status) { + PAL_ERR(LOG_TAG, "Failed to get bytes to read"); + status = -EINVAL; + goto exit; + } } if (size_to_read == 0) { retry_cnt++; @@ -2145,6 +2153,20 @@ int32_t SoundTriggerEngineGsl::UpdateSessionPayload(StreamSoundTrigger *s, st_pa mode_bit &= ~(1 << NVD); mode_bit |= (1 << SPEECH); } + /* + * Platforms not supporting TILT_TO_WAKE/INTENT2SPEAK_ACCEL + * need to replace sensor modality with Any Motion Detect(AMD) + */ + if (sm_cfg_ && sm_cfg_->GetEnableAMD()) { + if (mode_bit & (1 << TILT_TO_WAKE)) { + mode_bit &= ~(1 << TILT_TO_WAKE); + mode_bit |= (1 << AMD); + } + if (mode_bit & (1 << INTENT2SPEAK_ACCEL)) { + mode_bit &= ~(1 << INTENT2SPEAK_ACCEL); + mode_bit |= (1 << AMD); + } + } intf_param.data = (void *)&mode_bit; intf_param.size = sizeof(uint32_t); } diff --git a/stream/src/Stream.cpp b/stream/src/Stream.cpp index 2f3333bd..06743e76 100644 --- a/stream/src/Stream.cpp +++ b/stream/src/Stream.cpp @@ -52,12 +52,7 @@ std::mutex Stream::mBaseStreamMutex; std::mutex Stream::pauseMutex; Stream::Stream() { - rm = ResourceManager::getInstance(); - if (PAL_CARD_STATUS_DOWN(rm->getSoundCardState())) { - PAL_ERR(LOG_TAG, "Error:Sound card offline/standby, can not create stream"); - usleep(SSR_RECOVERY); - throw std::runtime_error("Sound card offline/standby"); - } + } Stream::~Stream(){ @@ -112,6 +107,13 @@ Stream* Stream::create(struct pal_stream_attributes *sAttr, struct pal_device *d } PAL_VERBOSE(LOG_TAG,"get RM instance success and noOfDevices %d \n", noOfDevices); + /* check sound card status */ + if (PAL_CARD_STATUS_DOWN(rm->getSoundCardState())) { + PAL_ERR(LOG_TAG, "Error:Sound card offline/standby, can not create stream"); + usleep(SSR_RECOVERY); + goto exit; + } + palDevsAttr = (pal_device *)calloc(noOfDevices, sizeof(struct pal_device)); if (!palDevsAttr) { PAL_ERR(LOG_TAG, "palDevsAttr not created"); @@ -163,7 +165,7 @@ Stream* Stream::create(struct pal_stream_attributes *sAttr, struct pal_device *d rm->isBtDevice(palDevsAttr[count].id)) { palDevsAttr[count].address = dAttr[i].address; } - PAL_VERBOSE(LOG_TAG, "count: %d, i: %d, length of dAttr custom_config: %d", count, i, strlen(dAttr[i].custom_config.custom_key)); + PAL_VERBOSE(LOG_TAG, "count: %d, i: %d, length of dAttr custom_config: %zu", count, i, strlen(dAttr[i].custom_config.custom_key)); if (strlen(dAttr[i].custom_config.custom_key)) { strlcpy(palDevsAttr[count].custom_config.custom_key, dAttr[i].custom_config.custom_key, PAL_MAX_CUSTOM_KEY_SIZE); PAL_DBG(LOG_TAG, "found custom key %s", dAttr[i].custom_config.custom_key); diff --git a/utils/inc/ASRPlatformInfo.h b/utils/inc/ASRPlatformInfo.h index cb9590e7..7e1e1c3f 100644 --- a/utils/inc/ASRPlatformInfo.h +++ b/utils/inc/ASRPlatformInfo.h @@ -97,9 +97,6 @@ class ASRDefaultConfig : public SoundTriggerXml void HandleEndTag(struct xml_userdata *data, const std::string& tag); int32_t GetDefaultASRConfig(struct pal_asr_config *config); - -private: - struct pal_asr_config asr_config_; }; class ASRStreamConfig : public SoundTriggerXml diff --git a/utils/inc/UvVoiceCueUtils.h b/utils/inc/UvVoiceCueUtils.h new file mode 100644 index 00000000..8e5caa17 --- /dev/null +++ b/utils/inc/UvVoiceCueUtils.h @@ -0,0 +1,30 @@ +/* + * Copyright (c) Qualcomm Technologies, Inc. and/or its subsidiaries. + * SPDX-License-Identifier: BSD-3-Clause-Clear + */ + +#ifndef UVVOICECUE_UTILS_H +#define UVVOICECUE_UTILS_H + +#include +#include + +#define VOICE_CUE_FILE_NAME "/data/vendor/audio/voice_cue.bin" + +int32_t writeBufferToFile(const char *filePath, const uint8_t *data, size_t size); +int32_t readBufferFromFile(const char *filePath, uint8_t **data, size_t *size); + +uint8_t *getVoiceCueDataPtr(); +size_t getVoiceCueDataSize(); +uint32_t getUvMaskUseCaseValues(); + +int32_t storeVoiceCueToFile(uint8_t *data, uint32_t size); +int32_t retrieveVoiceCueFromFile(); + +void cacheUvUseCaseMask(uint32_t usecaseMask); + +/* New helper APIs to reduce ResourceManager switch-case code */ +int32_t handleUvVoiceCueEnable(void *param_payload, size_t payload_size); +int32_t handleUvVoiceCueData(void *param_payload, size_t payload_size); + +#endif // UVVOICECUE_UTILS_H \ No newline at end of file diff --git a/utils/inc/VoiceUIPlatformInfo.h b/utils/inc/VoiceUIPlatformInfo.h index bbdcfbef..caca5db3 100644 --- a/utils/inc/VoiceUIPlatformInfo.h +++ b/utils/inc/VoiceUIPlatformInfo.h @@ -150,6 +150,7 @@ class VUIStreamConfig : public SoundTriggerXml uint32_t GetBatchSizeInMs() const { return batch_size_in_ms_; } bool IsClientHandleSSR() const { return client_handling_ssr_; } bool GetEnableLPILabEC(st_module_type_t type); + bool GetEnableAMD() const { return enable_amd_; } private: std::string name_; @@ -182,6 +183,7 @@ class VUIStreamConfig : public SoundTriggerXml std::map> vui_uuid_1st_stage_cfg_list_; std::vector ext_det_prop_list_; bool client_handling_ssr_; + bool enable_amd_; }; class VoiceUIPlatformInfo : public SoundTriggerPlatformInfo diff --git a/utils/src/ACDPlatformInfo.cpp b/utils/src/ACDPlatformInfo.cpp index e347f411..285fabb1 100644 --- a/utils/src/ACDPlatformInfo.cpp +++ b/utils/src/ACDPlatformInfo.cpp @@ -107,9 +107,9 @@ void ACDSoundModelInfo::HandleEndTag(struct xml_userdata *data, const std::strin } ACDStreamConfig::ACDStreamConfig() : + lpi_enable_(true), curr_child_(nullptr), - sound_model_cnt(0), - lpi_enable_(true) + sound_model_cnt(0) { } diff --git a/utils/src/ASRPlatformInfo.cpp b/utils/src/ASRPlatformInfo.cpp index 86feaee5..968cfebd 100644 --- a/utils/src/ASRPlatformInfo.cpp +++ b/utils/src/ASRPlatformInfo.cpp @@ -37,6 +37,7 @@ #define LOG_TAG "PAL: ASRPlatformInfo" +static struct pal_asr_config default_asr_config = {0}; void ASRCommonConfig::HandleStartTag(const std::string& tag, const char** attribs) { @@ -108,31 +109,31 @@ void ASRDefaultConfig::HandleStartTag(const std::string& tag, const char** attri if (tag == "param") { if (key == "input_language_code") { - asr_config_.input_language_code = std::stoi(value); + default_asr_config.input_language_code = std::stoi(value); } else if (key == "output_language_code") { - asr_config_.output_language_code = std::stoi(value); + default_asr_config.output_language_code = std::stoi(value); } else if (key == "enable_language_detection") { - asr_config_.enable_language_detection = (value == "true"); + default_asr_config.enable_language_detection = (value == "true"); } else if (key == "enable_translation") { - asr_config_.enable_translation = (value == "true"); + default_asr_config.enable_translation = (value == "true"); } else if (key == "enable_continuous_mode") { - asr_config_.enable_continuous_mode = (value == "true"); + default_asr_config.enable_continuous_mode = (value == "true"); } else if (key == "enable_partial_transcription") { - asr_config_.enable_partial_transcription = (value == "true"); + default_asr_config.enable_partial_transcription = (value == "true"); } else if (key == "enable_logger_mode") { - asr_config_.enable_logger_mode = (value == "true"); + default_asr_config.enable_logger_mode = (value == "true"); } else if (key == "enable_timestamp") { - asr_config_.enable_timestamp = (value == "true"); + default_asr_config.enable_timestamp = (value == "true"); } else if (key == "enable_speaker_diarization") { - asr_config_.enable_speaker_diarization = (value == "true"); + default_asr_config.enable_speaker_diarization = (value == "true"); } else if (key == "threshold") { - asr_config_.threshold = std::stoi(value); + default_asr_config.threshold = std::stoi(value); } else if (key == "timeout_duration") { - asr_config_.timeout_duration = std::stoi(value); + default_asr_config.timeout_duration = std::stoi(value); } else if (key == "silence_detection_duration") { - asr_config_.silence_detection_duration = std::stoi(value); + default_asr_config.silence_detection_duration = std::stoi(value); } else if (key == "outputBufferMode") { - asr_config_.outputBufferMode = (value == "true"); + default_asr_config.outputBufferMode = (value == "true"); } else { PAL_ERR(LOG_TAG, "Invalid attribute %s", key.c_str()); } @@ -148,7 +149,6 @@ void ASRDefaultConfig::HandleEndTag(struct xml_userdata *data, const std::string ASRDefaultConfig::ASRDefaultConfig() { - memset(&asr_config_, 0, sizeof(asr_config_)); } int32_t ASRDefaultConfig::GetDefaultASRConfig(struct pal_asr_config *config) @@ -158,7 +158,7 @@ int32_t ASRDefaultConfig::GetDefaultASRConfig(struct pal_asr_config *config) return -EINVAL; } - memcpy(config, &asr_config_, sizeof(asr_config_)); + memcpy(config, &default_asr_config, sizeof(default_asr_config)); return 0; } @@ -268,8 +268,8 @@ void ASRStreamConfig::HandleEndTag(struct xml_userdata *data, const std::string& std::shared_ptr ASRPlatformInfo::me_ = nullptr; ASRStreamConfig::ASRStreamConfig() : - curr_child_(nullptr), - lpi_enable_(true) + lpi_enable_(true), + curr_child_(nullptr) { for (int i = 0; i < ASR_MAX_PARAM_IDS; i++) { module_tag_ids_[i] = 0; diff --git a/utils/src/BTUtils.cpp b/utils/src/BTUtils.cpp index 4118ba6c..2fc76de2 100644 --- a/utils/src/BTUtils.cpp +++ b/utils/src/BTUtils.cpp @@ -434,7 +434,6 @@ int32_t BTUtilsDeviceNotReady(Stream *s, bool& a2dpSuspend) dattr.id = spkrDattr.id; dev = spkrDev; - rm->lockActiveStream(); rm->getActiveStream_l(activeStreams, spkrDev); if (activeStreams.empty()) { rm->getActiveStream_l(activeStreams, handsetDev); @@ -456,7 +455,6 @@ int32_t BTUtilsDeviceNotReady(Stream *s, bool& a2dpSuspend) dev->setDeviceAttributes(dattr); } } - rm->unlockActiveStream(); PAL_INFO(LOG_TAG, "mute stream and route to device %d", dattr.id); @@ -527,9 +525,7 @@ void handleA2dpBleConcurrency(std::shared_ptr *inDev, PAL_ERR(LOG_TAG, "getting a2dp/ble device instance failed"); return; } - rm->lockActiveStream(); rm->getActiveStream_l(streams, dev); - rm->unlockActiveStream(); if (streams.size() == 0) { return; } @@ -545,9 +541,7 @@ void handleA2dpBleConcurrency(std::shared_ptr *inDev, } else if (inDevAttr->id == PAL_DEVICE_OUT_BLUETOOTH_A2DP) { devAttr.id = PAL_DEVICE_IN_BLUETOOTH_BLE; dev = Device::getInstance(&devAttr, rm); - rm->lockActiveStream(); rm->getActiveStream_l(streams, dev); - rm->unlockActiveStream(); if (streams.size() > 0) { inDevAttr->id = PAL_DEVICE_OUT_DUMMY; if (rm->getDeviceConfig(inDevAttr, NULL)) { @@ -2126,7 +2120,7 @@ void reconfigureScoStreams() { dattr = nullptr; } - PAL_DBG(LOG_TAG, "streamDevDisconnect size=%d and streamDevConnect size=%d", + PAL_DBG(LOG_TAG, "streamDevDisconnect size=%zu and streamDevConnect size=%zu", streamDevDisconnect.size(), streamDevConnect.size()); status = rm->streamDevSwitch(streamDevDisconnect, streamDevConnect); if (status) { diff --git a/utils/src/MemLogBuilder.cpp b/utils/src/MemLogBuilder.cpp index 69b1ed1e..0b015f9a 100644 --- a/utils/src/MemLogBuilder.cpp +++ b/utils/src/MemLogBuilder.cpp @@ -56,7 +56,7 @@ int palStateQueueBuilder(pal_state_queue &que, Stream *s, pal_state_queue_state que.state = state; que.error = error; - PAL_DBG(LOG_TAG, "Stream handle = " "%" PRId64 "\n", s); + PAL_DBG(LOG_TAG, "Stream handle = %p\n", s); memset(que.device_attr, 0, sizeof(que.device_attr)); diff --git a/utils/src/MetadataParser.cpp b/utils/src/MetadataParser.cpp index 99464c18..e39bf6b1 100644 --- a/utils/src/MetadataParser.cpp +++ b/utils/src/MetadataParser.cpp @@ -20,7 +20,7 @@ int MetadataParser::parseMetadata(uint8_t* metadata, size_t metadataSize, if (!metadata || metadataSize < std::min(START_METADATA_SIZE(), END_METADATA_SIZE())) { //TODO: may not work for multiple frames/buffer - ALOGE("%s: Metadata payload smaller than expected, bytes 0x%x, expected 0x%x", + ALOGE("%s: Metadata payload smaller than expected, bytes 0x%zx, expected 0x%lx", __func__, mdBytesRead, std::min(START_METADATA_SIZE(), END_METADATA_SIZE())); return -EINVAL; } @@ -39,21 +39,21 @@ int MetadataParser::parseMetadata(uint8_t* metadata, size_t metadataSize, size_t startMetadataPayloadSize = metadataItem->payload_size; if (mdBytesRead + startMetadataPayloadSize > metadataSize) { ALOGE("%s: Metadata item payload size larger than advertized metadata size" - " metadata id 0x%x, mdBytesRead = 0x%x, item payload size 0x%x," - " metadata size = 0x%x ", __func__, metadataItem->metadata_id, + " metadata id 0x%x, mdBytesRead = 0x%zx, item payload size 0x%zx," + " metadata size = 0x%zx ", __func__, metadataItem->metadata_id, mdBytesRead, startMetadataPayloadSize, metadataSize); return -EINVAL; } module_cmn_md_buffer_start_t* startMetadata = reinterpret_cast(metadata + mdBytesRead); if (!startMetadata) { - ALOGE("%s: Metadata start payload not found at offset 0x%x", + ALOGE("%s: Metadata start payload not found at offset 0x%zx", __func__, mdBytesRead); return -EINVAL; } bufferInfo->frame_index = static_cast((static_cast( startMetadata->buffer_index_msw) << 32) | startMetadata->buffer_index_lsw); - ALOGV("%s: startMetadata frame_index %llu", __func__, bufferInfo->frame_index); + ALOGV("%s: startMetadata frame_index %lu", __func__, bufferInfo->frame_index); mdBytesRead += sizeof(module_cmn_md_buffer_start_t); break; } @@ -61,7 +61,7 @@ int MetadataParser::parseMetadata(uint8_t* metadata, size_t metadataSize, size_t endMetadataPayloadSize = metadataItem->payload_size; if (mdBytesRead + endMetadataPayloadSize > metadataSize) { ALOGE("%s: Metadata item payload size larger than advertized metadata size," - " metadata id 0x%x, mdBytesRead = 0x%x, item payload size 0x%x," + " metadata id 0x%x, mdBytesRead = 0x%zx, item payload size 0x%zx," " metadata size = 0x%x ", __func__, metadataItem->metadata_id, mdBytesRead, endMetadataPayloadSize, static_cast(metadataSize)); return -EINVAL; @@ -69,7 +69,7 @@ int MetadataParser::parseMetadata(uint8_t* metadata, size_t metadataSize, module_cmn_md_buffer_end_t* endMetadata = reinterpret_cast(metadata + mdBytesRead); if (!endMetadata) { - ALOGE("%s: Metadata end payload not found at offset 0x%x", + ALOGE("%s: Metadata end payload not found at offset 0x%zx", __func__, mdBytesRead); return -EINVAL; } @@ -96,8 +96,8 @@ int MetadataParser::parseMetadata(uint8_t* metadata, size_t metadataSize, size_t mfMetadataPayloadSize = metadataItem->payload_size; if (mdBytesRead + mfMetadataPayloadSize > metadataSize){ ALOGE("%s: Metadata item payload size larger than advertized metadata size," - " metadata id 0x%x, mdBytesRead = 0x%x, item payload size 0x%x," - " metadata size = 0x%x ", __func__, metadataItem->metadata_id, + " metadata id 0x%x, mdBytesRead = 0x%zx, item payload size 0x%zx," + " metadata size = 0x%zx ", __func__, metadataItem->metadata_id, mdBytesRead, mfMetadataPayloadSize, metadataSize); return -EINVAL; } @@ -106,7 +106,7 @@ int MetadataParser::parseMetadata(uint8_t* metadata, size_t metadataSize, mdBytesRead += sizeof(media_format_t); if (!mfPayload) { - ALOGE("%s: Media metadata payload not found at offset 0x%x", + ALOGE("%s: Media metadata payload not found at offset 0x%zx", __func__, mdBytesRead); return -EINVAL; } @@ -128,7 +128,7 @@ int MetadataParser::parseMetadata(uint8_t* metadata, size_t metadataSize, break; } default: { - ALOGE("%s: Unknown Metadata marker found at offset 0x%x, Metadata ID=0x%x", + ALOGE("%s: Unknown Metadata marker found at offset 0x%zx, Metadata ID=0x%x", __func__, mdBytesRead, metadataItem->metadata_id); // increment bytes read mdBytesRead += metadataItem->payload_size; diff --git a/utils/src/STUtils.cpp b/utils/src/STUtils.cpp index 3afda84c..fba45789 100644 --- a/utils/src/STUtils.cpp +++ b/utils/src/STUtils.cpp @@ -143,7 +143,7 @@ int32_t voiceuiDmgrRestartUseCases(vui_dmgr_param_restart_usecases_t *uc_info) getMatchingStreams(activeStreams, streams, uc_info->usecases[i].vendor_uuid); } // Reuse SSR mechanism for stream teardown and bring up. - PAL_INFO(LOG_TAG, "restart %d streams", streams.size()); + PAL_INFO(LOG_TAG, "restart %zu streams", streams.size()); for (auto &s : streams) { s->getStreamType(&type); status = s->ssrDownHandler(); @@ -1386,8 +1386,8 @@ int setSTParameter(uint32_t param_id, void *param_payload, if (std::find(onResourceAvailCbList.begin(), onResourceAvailCbList.end(), cb) == onResourceAvailCbList.end()) { onResourceAvailCbList.push_back(cb); - PAL_VERBOSE(LOG_TAG, "setParameter onResourceAvailCb %pk" - " onResourceAvailCookie %pk", resources_avail->callback, + PAL_VERBOSE(LOG_TAG, "setParameter onResourceAvailCb %p" + " onResourceAvailCookie %lu", resources_avail->callback, resources_avail->cookie); } else { PAL_DBG(LOG_TAG, "Resource available callback is already registered"); diff --git a/utils/src/UvVoiceCueUtils.cpp b/utils/src/UvVoiceCueUtils.cpp new file mode 100644 index 00000000..71bb5218 --- /dev/null +++ b/utils/src/UvVoiceCueUtils.cpp @@ -0,0 +1,334 @@ +/* + * Copyright (c) Qualcomm Technologies, Inc. and/or its subsidiaries. + * SPDX-License-Identifier: BSD-3-Clause-Clear + */ + +#define LOG_TAG "PAL: UVVoiceCueUtils" + +#include +#include +#include +#include +#include +#include +#include + +#include "ResourceManager.h" +#include "UvVoiceCueUtils.h" + +namespace { +std::mutex gVoiceCueMutex; +uv_fluence_config_t cachedRmUvConfig = {}; +} + +uint8_t *getVoiceCueDataPtr() +{ + std::lock_guard lock(gVoiceCueMutex); + return cachedRmUvConfig.voice_cue_param; +} + +size_t getVoiceCueDataSize() +{ + std::lock_guard lock(gVoiceCueMutex); + return cachedRmUvConfig.param_size; +} + +uint32_t getUvMaskUseCaseValues() +{ + std::lock_guard lock(gVoiceCueMutex); + return cachedRmUvConfig.usecase_mask; +} + +void cacheUvUseCaseMask(uint32_t usecaseMask) +{ + std::lock_guard lock(gVoiceCueMutex); + cachedRmUvConfig.usecase_mask = usecaseMask; +} + +int32_t handleUvVoiceCueEnable(void *param_payload, size_t payload_size) +{ + pal_param_payload *palPayload = nullptr; + uv_fluence_config_t *incoming = nullptr; + + if (!param_payload) { + PAL_ERR(LOG_TAG, "param_payload is null"); + return -EINVAL; + } + + if (payload_size < sizeof(pal_param_payload)) { + PAL_ERR(LOG_TAG, "payload_size %zu is too small", payload_size); + return -EINVAL; + } + + palPayload = reinterpret_cast(param_payload); + + if (palPayload->payload_size < sizeof(uv_fluence_config_t)) { + PAL_ERR(LOG_TAG, "Invalid UV fluence payload size %u", + palPayload->payload_size); + return -EINVAL; + } + + incoming = reinterpret_cast(palPayload->payload); + + PAL_DBG(LOG_TAG, "Enable Cmd -> usecase_mask: 0x%x", + incoming->usecase_mask); + + { + std::lock_guard lock(gVoiceCueMutex); + cachedRmUvConfig.usecase_mask = incoming->usecase_mask; + } + + PAL_INFO(LOG_TAG, "Decoded UV config: audio=%d voice=%d voip=%d sva=%d", + !!(incoming->usecase_mask & UV_FLUENCE_AUDIO_BIT), + !!(incoming->usecase_mask & UV_FLUENCE_TELEPHONY_BIT), + !!(incoming->usecase_mask & UV_FLUENCE_VOIP_BIT), + !!(incoming->usecase_mask & UV_FLUENCE_SVA_BIT)); + + return 0; +} + +int32_t handleUvVoiceCueData(void *param_payload, size_t payload_size) +{ + pal_param_payload *palPayload = nullptr; + uint8_t *incomingData = nullptr; + size_t incomingSize = 0; + uint8_t *newVoiceCue = nullptr; + int32_t fileStatus = 0; + + if (!param_payload || payload_size < sizeof(pal_param_payload)) { + PAL_ERR(LOG_TAG, "Invalid param payload for UV_VOICE_CUE_DATA_BYTE"); + return -EINVAL; + } + + palPayload = reinterpret_cast(param_payload); + incomingData = reinterpret_cast(palPayload->payload); + incomingSize = palPayload->payload_size; + + PAL_DBG(LOG_TAG, "Received Voice Cue Data. Size: %zu bytes", incomingSize); + + if (!incomingData || incomingSize == 0) { + PAL_ERR(LOG_TAG, "Invalid Voice Cue data received. data: %p size: %zu", + incomingData, incomingSize); + return -EINVAL; + } + + newVoiceCue = static_cast(calloc(1, incomingSize)); + if (!newVoiceCue) { + PAL_ERR(LOG_TAG, "Failed to allocate memory for Voice Cue Data"); + return -ENOMEM; + } + + memcpy(newVoiceCue, incomingData, incomingSize); + + { + std::lock_guard lock(gVoiceCueMutex); + + if (cachedRmUvConfig.voice_cue_param != nullptr) { + free(cachedRmUvConfig.voice_cue_param); + cachedRmUvConfig.voice_cue_param = nullptr; + cachedRmUvConfig.param_size = 0; + } + + cachedRmUvConfig.voice_cue_param = newVoiceCue; + cachedRmUvConfig.param_size = incomingSize; + } + + newVoiceCue = nullptr; // ownership moved to cache + + PAL_DBG(LOG_TAG, "Cached %zu bytes of cue data successfully", incomingSize); + + fileStatus = storeVoiceCueToFile(getVoiceCueDataPtr(), + static_cast(incomingSize)); + if (fileStatus != 0) { + PAL_ERR(LOG_TAG, "Failed to persist cue data to file! Status: %d", + fileStatus); + } else { + PAL_DBG(LOG_TAG, "Successfully saved cue data to file."); + } + + return 0; +} + +int32_t storeVoiceCueToFile(uint8_t *data, uint32_t size) +{ + int32_t status = 0; + + PAL_INFO(LOG_TAG, "Enter, size %u", size); + + if (!data || size == 0) { + PAL_ERR(LOG_TAG, "Invalid data pointer or size is 0"); + return -EINVAL; + } + + status = writeBufferToFile(VOICE_CUE_FILE_NAME, data, size); + if (status) { + PAL_ERR(LOG_TAG, "Failed to store voice cue to file %s, status %d", + VOICE_CUE_FILE_NAME, status); + return status; + } + + PAL_INFO(LOG_TAG, "Successfully stored %u bytes to %s", + size, VOICE_CUE_FILE_NAME); + return 0; +} + +int32_t retrieveVoiceCueFromFile() +{ + uint8_t *tmpData = nullptr; + size_t tmpSize = 0; + int32_t status = 0; + + status = readBufferFromFile(VOICE_CUE_FILE_NAME, &tmpData, &tmpSize); + if (status) { + PAL_ERR(LOG_TAG, "Failed to retrieve voice cue from file %s, status %d", + VOICE_CUE_FILE_NAME, status); + return status; + } + + if (!tmpData || tmpSize == 0) { + PAL_DBG(LOG_TAG, "No valid voice cue data found in file"); + return 0; + } + + { + std::lock_guard lock(gVoiceCueMutex); + + if (cachedRmUvConfig.voice_cue_param) { + free(cachedRmUvConfig.voice_cue_param); + cachedRmUvConfig.voice_cue_param = nullptr; + cachedRmUvConfig.param_size = 0; + } + + cachedRmUvConfig.voice_cue_param = tmpData; + cachedRmUvConfig.param_size = tmpSize; + } + + PAL_INFO(LOG_TAG, "Successfully restored %zu bytes of cue data", tmpSize); + return 0; +} + +int32_t writeBufferToFile(const char *filePath, const uint8_t *data, size_t size) +{ + int fd = -1; + size_t totalWritten = 0; + + if (!filePath || !data || size == 0) { + PAL_ERR(LOG_TAG, "Invalid input. filePath %p, data %p, size %zu", + filePath, data, size); + return -EINVAL; + } + + fd = open(filePath, O_WRONLY | O_CREAT | O_TRUNC, 0644); + if (fd < 0) { + PAL_ERR(LOG_TAG, "Failed to open file %s for write, errno %d (%s)", + filePath, errno, strerror(errno)); + return -errno; + } + + while (totalWritten < size) { + ssize_t written = write(fd, data + totalWritten, size - totalWritten); + if (written < 0) { + if (errno == EINTR) + continue; + + PAL_ERR(LOG_TAG, "Write failed for file %s, errno %d (%s)", + filePath, errno, strerror(errno)); + close(fd); + return -errno; + } + + if (written == 0) { + PAL_ERR(LOG_TAG, "Write returned 0 for file %s", filePath); + close(fd); + return -EIO; + } + + totalWritten += static_cast(written); + } + + close(fd); + PAL_DBG(LOG_TAG, "Successfully wrote %zu bytes to %s", + totalWritten, filePath); + + return 0; +} + +int32_t readBufferFromFile(const char *filePath, uint8_t **data, size_t *size) +{ + int fd = -1; + struct stat st; + uint8_t *buffer = nullptr; + size_t totalRead = 0; + + if (!filePath || !data || !size) { + PAL_ERR(LOG_TAG, "Invalid input. filePath %p, data %p, size %p", + filePath, data, size); + return -EINVAL; + } + + *data = nullptr; + *size = 0; + + if (stat(filePath, &st) != 0) { + PAL_ERR(LOG_TAG, "stat failed for %s, errno %d (%s)", + filePath, errno, strerror(errno)); + return -errno; + } + + if (st.st_size <= 0) { + PAL_ERR(LOG_TAG, "File %s is empty or invalid, size %lld", + filePath, static_cast(st.st_size)); + return -EINVAL; + } + + fd = open(filePath, O_RDONLY); + if (fd < 0) { + PAL_ERR(LOG_TAG, "Failed to open file %s for read, errno %d (%s)", + filePath, errno, strerror(errno)); + return -errno; + } + + buffer = static_cast(calloc(1, static_cast(st.st_size))); + if (!buffer) { + PAL_ERR(LOG_TAG, "Failed to allocate %lld bytes for file read", + static_cast(st.st_size)); + close(fd); + return -ENOMEM; + } + + while (totalRead < static_cast(st.st_size)) { + ssize_t bytesRead = read(fd, buffer + totalRead, + static_cast(st.st_size) - totalRead); + if (bytesRead < 0) { + if (errno == EINTR) + continue; + + PAL_ERR(LOG_TAG, "Read failed for file %s, errno %d (%s)", + filePath, errno, strerror(errno)); + free(buffer); + close(fd); + return -errno; + } + + if (bytesRead == 0) { + break; + } + + totalRead += static_cast(bytesRead); + } + + close(fd); + + if (totalRead != static_cast(st.st_size)) { + PAL_ERR(LOG_TAG, "Partial read from %s. expected %zu actual %zu", + filePath, static_cast(st.st_size), totalRead); + free(buffer); + return -EIO; + } + + *data = buffer; + *size = totalRead; + + PAL_DBG(LOG_TAG, "Successfully read %zu bytes from %s", totalRead, filePath); + return 0; +} \ No newline at end of file diff --git a/utils/src/VoiceUIPlatformInfo.cpp b/utils/src/VoiceUIPlatformInfo.cpp index 164c923a..a899cae3 100644 --- a/utils/src/VoiceUIPlatformInfo.cpp +++ b/utils/src/VoiceUIPlatformInfo.cpp @@ -104,9 +104,9 @@ void VUISecondStageConfig::HandleStartTag(const std::string& tag, const char **a } VUIFirstStageConfig::VUIFirstStageConfig() : + lpi_supported_(true), module_type_(ST_MODULE_TYPE_GMM), module_name_("GMM"), - lpi_supported_(true), enable_lpi_lab_ec_(false) { for (int i = 0; i < MAX_PARAM_IDS; i++) { @@ -217,13 +217,14 @@ VUIStreamConfig::VUIStreamConfig() : pre_roll_duration_(0), supported_first_stage_engine_count_(1), enable_intra_concurrent_detection_(false), - curr_child_(nullptr), lpi_enable_(true), batch_size_in_ms_(0), + curr_child_(nullptr), client_handling_ssr_(false), mmap_buffer_duration_(0), mmap_frame_length_(0), - mmap_enable_(false) + mmap_enable_(false), + enable_amd_(false) { ext_det_prop_list_.clear(); } @@ -304,7 +305,7 @@ void VUIStreamConfig::ReadDetectionPropertyList(const char *prop_string) { int ret = 0; char *token = nullptr; - char *delims = ","; + const char *delims = ","; char *save = nullptr; PAL_VERBOSE(LOG_TAG, "Detection property list %s", prop_string); @@ -434,6 +435,8 @@ void VUIStreamConfig::HandleStartTag(const std::string& tag, const char** attrib mmap_buffer_duration_ = std::stoi(value); } else if (key == "mmap_frame_length") { mmap_frame_length_ = std::stoi(value); + } else if (key == "enable_amd") { + enable_amd_ = (value == "true"); } else { PAL_ERR(LOG_TAG, "Invalid attribute %s", key.c_str()); }