Merge bedd66c173241084dfef0329a81b00c2fe4e505c on remote branch
Change-Id: Ie1514e58219c1252adb6ffa66cac0507ed816678
diff --git a/ipc/HwBinders/agm_ipc_client/src/agm_client_wrapper.cpp b/ipc/HwBinders/agm_ipc_client/src/agm_client_wrapper.cpp
index a808846..8570662 100644
--- a/ipc/HwBinders/agm_ipc_client/src/agm_client_wrapper.cpp
+++ b/ipc/HwBinders/agm_ipc_client/src/agm_client_wrapper.cpp
@@ -25,6 +25,39 @@
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
* 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 are provided under the following license:
+ * Copyright (c) 2022 Qualcomm Innovation Center, Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted (subject to the limitations in the
+ * disclaimer below) provided that the following conditions are met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials provided
+ * with the distribution.
+ *
+ * * Neither the name of Qualcomm Innovation Center, Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * NO EXPRESS OR IMPLIED LICENSES TO ANY PARTY'S PATENT RIGHTS ARE
+ * GRANTED BY THIS LICENSE. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT
+ * HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
+ * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
+ * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
+ * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#define LOG_TAG "agm_client_wrapper"
@@ -44,6 +77,7 @@
using vendor::qti::hardware::AGMIPC::V1_0::IAGMCallback;
using vendor::qti::hardware::AGMIPC::V1_0::implementation::AGMCallback;
using vendor::qti::hardware::AGMIPC::V1_0::MmapBufInfo;
+using vendor::qti::hardware::AGMIPC::V1_0::AgmDumpInfo;
using android::hardware::defaultPassthroughServiceImplementation;
using android::hardware::configureRpcThreadpool;
using android::hardware::joinRpcThreadpool;
@@ -1072,3 +1106,17 @@
}
return -EINVAL;
}
+
+int agm_dump(struct agm_dump_info *dump_info) {
+ if (agm_server_died) {
+ ALOGE("%s: Cannot perform dump, AGM service has died", __func__);
+ return -EINVAL;
+ }
+ android::sp<IAGM> agm_client = get_agm_server();
+ hidl_vec<AgmDumpInfo> dump_info_hidl;
+ dump_info_hidl.resize(1);
+ memcpy(dump_info_hidl.data(),
+ dump_info,
+ sizeof(struct agm_dump_info));
+ return agm_client->ipc_agm_dump(dump_info_hidl);
+}
diff --git a/ipc/HwBinders/agm_ipc_service/inc/agm_server_wrapper.h b/ipc/HwBinders/agm_ipc_service/inc/agm_server_wrapper.h
index 4df852b..f1592ec 100644
--- a/ipc/HwBinders/agm_ipc_service/inc/agm_server_wrapper.h
+++ b/ipc/HwBinders/agm_ipc_service/inc/agm_server_wrapper.h
@@ -25,6 +25,39 @@
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
* 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 are provided under the following license:
+ * Copyright (c) 2022 Qualcomm Innovation Center, Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted (subject to the limitations in the
+ * disclaimer below) provided that the following conditions are met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials provided
+ * with the distribution.
+ *
+ * * Neither the name of Qualcomm Innovation Center, Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * NO EXPRESS OR IMPLIED LICENSES TO ANY PARTY'S PATENT RIGHTS ARE
+ * GRANTED BY THIS LICENSE. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT
+ * HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
+ * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
+ * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
+ * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef ANDROID_SYSTEM_AGMIPC_V1_0_AGM_H
#define ANDROID_SYSTEM_AGMIPC_V1_0_AGM_H
@@ -101,6 +134,7 @@
}
Return<int32_t> ipc_agm_init() override;
Return<int32_t> ipc_agm_deinit() override;
+ Return<int32_t> ipc_agm_dump(const hidl_vec<AgmDumpInfo>& dump_info) override;
Return<int32_t> ipc_agm_aif_set_media_config(uint32_t aif_id,
const hidl_vec<AgmMediaConfig>& media_config) override;
Return<int32_t> ipc_agm_aif_set_metadata(uint32_t aif_id,
diff --git a/ipc/HwBinders/agm_ipc_service/src/agm_server_wrapper.cpp b/ipc/HwBinders/agm_ipc_service/src/agm_server_wrapper.cpp
index a0b41b6..f859d47 100644
--- a/ipc/HwBinders/agm_ipc_service/src/agm_server_wrapper.cpp
+++ b/ipc/HwBinders/agm_ipc_service/src/agm_server_wrapper.cpp
@@ -25,21 +25,62 @@
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
* 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 are provided under the following license:
+ * Copyright (c) 2022 Qualcomm Innovation Center, Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted (subject to the limitations in the
+ * disclaimer below) provided that the following conditions are met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials provided
+ * with the distribution.
+ *
+ * * Neither the name of Qualcomm Innovation Center, Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * NO EXPRESS OR IMPLIED LICENSES TO ANY PARTY'S PATENT RIGHTS ARE
+ * GRANTED BY THIS LICENSE. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT
+ * HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
+ * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
+ * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
+ * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#define LOG_TAG "agm_server_wrapper"
#include "inc/agm_server_wrapper.h"
#include <log/log.h>
#include <cutils/list.h>
+#include <cutils/android_filesystem_config.h>
#include <pthread.h>
+#include <signal.h>
#include "gsl_intf.h"
#include <hwbinder/IPCThreadState.h>
#define MAX_CACHE_SIZE 64
#define NUM_GKV(x) (*((uint32_t *) x))
+#ifndef __SIGRTMIN
+#define __SIGRTMIN 32
+#endif
+static const constexpr int DEBUGGER_SIGNAL = (__SIGRTMIN + 3);
+
using AgmCallbackData = ::vendor::qti::hardware::AGMIPC::V1_0::implementation::clbk_data;
using AgmServerCallback = ::vendor::qti::hardware::AGMIPC::V1_0::implementation::SrvrClbk;
+using ::vendor::qti::hardware::AGMIPC::V1_0::AgmDumpInfo;
static list_declare(client_list);
static pthread_mutex_t client_list_lock = PTHREAD_MUTEX_INITIALIZER;
@@ -63,10 +104,20 @@
struct listnode agm_client_hndl_list;
} client_info;
+void dumpAgmStackTrace(uid_t uid, int signal) {
+ if (uid == AID_AUDIOSERVER && signal > 0) {
+ if (raise(DEBUGGER_SIGNAL)) {
+ ALOGW("%s: Sending signal %u failed with error %d",
+ __func__, signal, errno);
+ }
+ }
+}
+
void client_death_notifier::serviceDied(uint64_t cookie,
const android::wp<::android::hidl::base::V1_0::IBase>& who __unused)
{
ALOGI("Client died (pid): %llu",(unsigned long long) cookie);
+
struct listnode *node = NULL;
struct listnode *tempnode = NULL;
agm_client_session_handle *session_handle = NULL;
@@ -1478,6 +1529,17 @@
return ret;
}
+Return<int32_t> AGM::ipc_agm_dump(const hidl_vec<AgmDumpInfo>& dump_info) {
+ struct agm_dump_info *d_info =
+ (struct agm_dump_info *)dump_info.data();
+ if (d_info->signal) {
+ ALOGD("%s: client with pid %d received signal %d",
+ __func__, d_info->pid, d_info->signal);
+ dumpAgmStackTrace(d_info->uid, d_info->signal);
+ }
+ return agm_dump(d_info);
+}
+
} // namespace implementation
} // namespace V1_0
} // namespace AGMIPC
diff --git a/ipc/HwBinders/interfaces/AGMIPC/1.0/IAGM.hal b/ipc/HwBinders/interfaces/AGMIPC/1.0/IAGM.hal
index 33b4b7e..4389f90 100644
--- a/ipc/HwBinders/interfaces/AGMIPC/1.0/IAGM.hal
+++ b/ipc/HwBinders/interfaces/AGMIPC/1.0/IAGM.hal
@@ -25,6 +25,39 @@
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
* 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 are provided under the following license:
+ * Copyright (c) 2022 Qualcomm Innovation Center, Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted (subject to the limitations in the
+ * disclaimer below) provided that the following conditions are met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials provided
+ * with the distribution.
+ *
+ * * Neither the name of Qualcomm Innovation Center, Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * NO EXPRESS OR IMPLIED LICENSES TO ANY PARTY'S PATENT RIGHTS ARE
+ * GRANTED BY THIS LICENSE. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT
+ * HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
+ * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
+ * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
+ * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package vendor.qti.hardware.AGMIPC@1.0;
@@ -35,6 +68,7 @@
{
ipc_agm_init() generates (int32_t ret);
ipc_agm_deinit() generates (int32_t ret);
+ ipc_agm_dump(vec<AgmDumpInfo> dump_info) generates (int32_t ret);
ipc_agm_aif_set_media_config(uint32_t aif_id,
vec<AgmMediaConfig> media_config) generates (int32_t ret);
ipc_agm_aif_set_metadata(uint32_t aif_id, uint32_t size, vec<uint8_t> metadata)
diff --git a/ipc/HwBinders/interfaces/AGMIPC/1.0/types.hal b/ipc/HwBinders/interfaces/AGMIPC/1.0/types.hal
index 397db11..262a1bf 100644
--- a/ipc/HwBinders/interfaces/AGMIPC/1.0/types.hal
+++ b/ipc/HwBinders/interfaces/AGMIPC/1.0/types.hal
@@ -25,6 +25,39 @@
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
* 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 are provided under the following license:
+ * Copyright (c) 2022 Qualcomm Innovation Center, Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted (subject to the limitations in the
+ * disclaimer below) provided that the following conditions are met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials provided
+ * with the distribution.
+ *
+ * * Neither the name of Qualcomm Innovation Center, Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * NO EXPRESS OR IMPLIED LICENSES TO ANY PARTY'S PATENT RIGHTS ARE
+ * GRANTED BY THIS LICENSE. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT
+ * HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
+ * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
+ * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
+ * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package vendor.qti.hardware.AGMIPC@1.0;
@@ -406,3 +439,9 @@
vec<AgmEventReadWriteDonePayload> rw_payload;
};
+/** Dump info shared by client */
+struct AgmDumpInfo {
+ int32_t signal;
+ uint32_t pid;
+ uint32_t uid;
+};
diff --git a/ipc/HwBinders/interfaces/AGMIPC/current.txt b/ipc/HwBinders/interfaces/AGMIPC/current.txt
index a94c6fe..7b0e356 100644
--- a/ipc/HwBinders/interfaces/AGMIPC/current.txt
+++ b/ipc/HwBinders/interfaces/AGMIPC/current.txt
@@ -1,4 +1,4 @@
# Hash for vendor.qti.hardware.AGMIPC@1.0 package
-14e9644e8ff286a5d00825c97d46056b12af94c103f81976a4c3b71fc681909d vendor.qti.hardware.AGMIPC@1.0::types
-32e7f754d1ba81fe46307c2ccd8848f69d763cd707d5397a1013c78b17d44a1f vendor.qti.hardware.AGMIPC@1.0::IAGM
+1846dac975898187405fcd011ea43c98415334e187a74a2e4fcaea123e0064b7 vendor.qti.hardware.AGMIPC@1.0::types
+ebe001f8ed01031e9ff3899b00f7e527346e89b271070064e55c4b3e70492d90 vendor.qti.hardware.AGMIPC@1.0::IAGM
e8d1ca223a57cfacc7373f6418555330bb545c43a1e9d2c3a1fdd984fcec4a14 vendor.qti.hardware.AGMIPC@1.0::IAGMCallback
diff --git a/plugins/tinyalsa/src/agm_mixer_plugin.c b/plugins/tinyalsa/src/agm_mixer_plugin.c
index 1d95750..2c69c27 100644
--- a/plugins/tinyalsa/src/agm_mixer_plugin.c
+++ b/plugins/tinyalsa/src/agm_mixer_plugin.c
@@ -1,5 +1,6 @@
/*
** Copyright (c) 2019-2021, The Linux Foundation. All rights reserved.
+** Copyright (c) 2022 Qualcomm Innovation Center, Inc. All rights reserved.
**
** Redistribution and use in source and binary forms, with or without
** modification, are permitted provided that the following conditions are
@@ -146,6 +147,11 @@
"datapathParams",
};
+struct amp_get_param_info {
+ void *get_param_payload;
+ int get_param_payload_size;
+};
+
struct amp_dev_info {
char **names;
int *idx_arr;
@@ -165,8 +171,7 @@
* "pcm<id> getParam"
* Unused for BE devs
*/
- void *get_param_payload;
- int get_param_payload_size;
+ struct amp_get_param_info *get_param_info;
};
struct amp_be_group_info {
@@ -264,9 +269,9 @@
adi->pcm_mtd_ctl = NULL;
}
- if (adi->get_param_payload) {
- free(adi->get_param_payload);
- adi->get_param_payload = NULL;
+ if (adi->get_param_info) {
+ free(adi->get_param_info);
+ adi->get_param_info = NULL;
}
adi->count = 0;
@@ -1289,9 +1294,9 @@
struct snd_control *ctl, struct snd_ctl_tlv *tlv)
{
struct amp_dev_info *pcm_adi = ctl->private_data;
-
void *payload;
- int pcm_idx = ctl->private_value;
+ int pcm_idx;
+ int idx = ctl->private_value;
int ret = 0;
size_t tlv_size;
@@ -1299,18 +1304,20 @@
payload = &tlv->tlv[0];
tlv_size = tlv->length;
+ pcm_idx = pcm_adi->idx_arr[idx];
- if (!pcm_adi->get_param_payload) {
+ if (!pcm_adi->get_param_info[idx].get_param_payload) {
AGM_LOGE("%s: put() for getParam not called\n", __func__);
return -EINVAL;
}
- if (tlv_size < pcm_adi->get_param_payload_size) {
+ if (tlv_size < pcm_adi->get_param_info[idx].get_param_payload_size) {
AGM_LOGE("%s: Buffer size less than expected\n", __func__);
return -EINVAL;
}
- memcpy(payload, pcm_adi->get_param_payload, pcm_adi->get_param_payload_size);
+ memcpy(payload, pcm_adi->get_param_info[idx].get_param_payload,
+ pcm_adi->get_param_info[idx].get_param_payload_size);
ret = agm_session_get_params(pcm_idx, payload, tlv_size);
if (ret == -EALREADY)
@@ -1319,9 +1326,9 @@
if (ret)
AGM_LOGE("%s: failed err %d for %s\n", __func__, ret, ctl->name);
- free(pcm_adi->get_param_payload);
- pcm_adi->get_param_payload = NULL;
- pcm_adi->get_param_payload_size = 0;
+ free(pcm_adi->get_param_info[idx].get_param_payload);
+ pcm_adi->get_param_info[idx].get_param_payload = NULL;
+ pcm_adi->get_param_info[idx].get_param_payload_size = 0;
return ret;
}
@@ -1329,22 +1336,25 @@
struct snd_control *ctl, struct snd_ctl_tlv *tlv)
{
struct amp_dev_info *pcm_adi = ctl->private_data;
+ int idx = ctl->private_value;
void *payload;
AGM_LOGV("%s: enter\n", __func__);
- if (pcm_adi->get_param_payload) {
- free(pcm_adi->get_param_payload);
- pcm_adi->get_param_payload = NULL;
+ if (pcm_adi->get_param_info[idx].get_param_payload) {
+ free(pcm_adi->get_param_info[idx].get_param_payload);
+ pcm_adi->get_param_info[idx].get_param_payload = NULL;
}
payload = &tlv->tlv[0];
- pcm_adi->get_param_payload_size = tlv->length;
+ pcm_adi->get_param_info[idx].get_param_payload_size = tlv->length;
- pcm_adi->get_param_payload = calloc(1, pcm_adi->get_param_payload_size);
- if (!pcm_adi->get_param_payload)
+ pcm_adi->get_param_info[idx].get_param_payload = calloc(1,
+ pcm_adi->get_param_info[idx].get_param_payload_size);
+ if (!pcm_adi->get_param_info[idx].get_param_payload)
return -ENOMEM;
- memcpy(pcm_adi->get_param_payload, payload, pcm_adi->get_param_payload_size);
+ memcpy(pcm_adi->get_param_info[idx].get_param_payload, payload,
+ pcm_adi->get_param_info[idx].get_param_payload_size);
return 0;
}
@@ -1873,6 +1883,12 @@
if (!pcm_adi->pcm_mtd_ctl)
return -ENOMEM;
+ pcm_adi->get_param_info = (struct amp_get_param_info *)calloc(pcm_adi->count, sizeof(struct amp_get_param_info));
+ if (!pcm_adi->get_param_info) {
+ free(pcm_adi->pcm_mtd_ctl);
+ return -ENOMEM;
+ }
+
for (i = 1; i < pcm_adi->count; i++) {
char *name = pcm_adi->names[i];
int idx = pcm_adi->idx_arr[i];
@@ -1897,7 +1913,7 @@
amp_create_pcm_calibration_ctl(amp_priv, name, (*ctl_idx)++,
idx, pcm_adi);
amp_create_pcm_get_param_ctl(amp_priv, name, (*ctl_idx)++,
- idx, pcm_adi);
+ i, pcm_adi);
amp_create_pcm_bufinfo_ctl(amp_priv, name, (*ctl_idx)++,
idx, pcm_adi);
}
diff --git a/plugins/tinyalsa/src/agm_pcm_plugin.c b/plugins/tinyalsa/src/agm_pcm_plugin.c
index 39fbfab..fd9fa02 100644
--- a/plugins/tinyalsa/src/agm_pcm_plugin.c
+++ b/plugins/tinyalsa/src/agm_pcm_plugin.c
@@ -1,5 +1,6 @@
/*
** Copyright (c) 2019, 2021 The Linux Foundation. All rights reserved.
+** Copyright (c) 2022 Qualcomm Innovation Center, Inc. All rights reserved.
**
** Redistribution and use in source and binary forms, with or without
** modification, are permitted provided that the following conditions are
@@ -73,6 +74,8 @@
struct timespec tstamp;
snd_pcm_uframes_t appl_ptr; /* RW: appl ptr (0...boundary-1) */
snd_pcm_uframes_t avail_min; /* RW: min available frames for wakeup */
+ uint32_t wall_clk_msw;
+ uint32_t wall_clk_lsw;
};
struct agm_mmap_buffer_port {
@@ -307,8 +310,11 @@
snd_pcm_sframes_t circ_buf_pos;
snd_pcm_uframes_t pos, old_hw_ptr, new_hw_ptr, hw_base;
uint32_t read_index, wall_clk_msw, wall_clk_lsw;
+ uint64_t delta_wall_clk_us = 0;
+ uint32_t delta_wall_clk_frames = 0;
int ret = 0;
uint32_t period_size = priv->period_size; /** in frames */
+ uint32_t crossed_boundary = 0;
do {
ret = agm_pcm_plugin_get_shared_pos(priv->pos_buf,
@@ -321,14 +327,51 @@
old_hw_ptr = agm_pcm_plugin_get_hw_ptr(priv);
hw_base = priv->pos_buf->hw_ptr_base;
new_hw_ptr = hw_base + pos;
- if (new_hw_ptr < old_hw_ptr) {
- hw_base += priv->total_size_frames;
+
+ // Set delta_wall_clk_us only if cached wall clk is non-zero
+ if (priv->pos_buf->wall_clk_msw || priv->pos_buf->wall_clk_lsw) {
+ delta_wall_clk_us = (((uint64_t)wall_clk_msw) << 32 | wall_clk_lsw) -
+ (((uint64_t)priv->pos_buf->wall_clk_msw) << 32 |
+ priv->pos_buf->wall_clk_lsw);
+ }
+ // Identify the number of times of shared buffer length that the
+ // hw ptr has jumped through by checking wall clock time delta
+ // and assuming read ptr moved at a constant rate
+ if (delta_wall_clk_us > 0 ) {
+ delta_wall_clk_frames = ((delta_wall_clk_us / 1000000)
+ * (priv->media_config->rate)
+ * priv->media_config->channels);
+ crossed_boundary = delta_wall_clk_frames / priv->total_size_frames;
+ }
+
+ // More than 1 loop of shared buffer completed by hw_ptr
+ // No need to check if new_hw_ptr < old_hw_ptr, as new_hw_ptr
+ // has crossed old_hw_ptr atleast once if not more
+ if (crossed_boundary > 0) {
+ hw_base += (crossed_boundary * priv->total_size_frames);
if (hw_base >= priv->pos_buf->boundary)
hw_base = 0;
new_hw_ptr = hw_base + pos;
priv->pos_buf->hw_ptr_base = hw_base;
+ AGM_LOGD("%s: crossed_boundary = %u, new_hw_ptr=%ld \n",
+ __func__, crossed_boundary, new_hw_ptr);
+ AGM_LOGD("%s: delta_wall_clk_frames = %lx, delta_wall_clk_us=%ld \n",
+ __func__, delta_wall_clk_frames, delta_wall_clk_us);
+ AGM_LOGD("%s: shared buffer length = %lx \n",
+ __func__, priv->total_size_frames);
+ } else {
+ if (new_hw_ptr < old_hw_ptr) {
+ hw_base += priv->total_size_frames;
+ if (hw_base >= priv->pos_buf->boundary)
+ hw_base = 0;
+ new_hw_ptr = hw_base + pos;
+ priv->pos_buf->hw_ptr_base = hw_base;
+ }
}
+
priv->pos_buf->hw_ptr = new_hw_ptr;
+ priv->pos_buf->wall_clk_lsw = wall_clk_lsw;
+ priv->pos_buf->wall_clk_msw = wall_clk_msw;
clock_gettime(CLOCK_MONOTONIC, &priv->pos_buf->tstamp);
}
@@ -374,6 +417,8 @@
agm_pcm_plugin_update_hw_ptr(priv);
priv->pos_buf->hw_ptr = (snd_pcm_uframes_t)(priv->pos_buf->hw_ptr % priv->total_size_frames);
priv->pos_buf->hw_ptr_base = 0;
+ priv->pos_buf->wall_clk_msw = 0;
+ priv->pos_buf->wall_clk_lsw = 0;
AGM_LOGD("%s: reset hw_ptr to %d \n", __func__, priv->pos_buf->hw_ptr);
return ret;
}
@@ -552,6 +597,11 @@
struct agm_pcm_priv *priv = plugin->priv;
int ret = 0;
+ if (priv->pos_buf) {
+ priv->pos_buf->wall_clk_msw = 0;
+ priv->pos_buf->wall_clk_lsw = 0;
+ }
+
ret = agm_get_session_handle(priv, &handle);
if (ret)
return ret;
diff --git a/plugins/tinyalsa/test/agmmixer.c b/plugins/tinyalsa/test/agmmixer.c
index 1bdf538..40714be 100644
--- a/plugins/tinyalsa/test/agmmixer.c
+++ b/plugins/tinyalsa/test/agmmixer.c
@@ -245,10 +245,12 @@
}
if (type == DEVICE) {
dev_cfg = (struct device_config *)config;
+ memset(dev_cfg, 0, sizeof(*dev_cfg));
strlcpy(dev_cfg->name, intf_name, sizeof(dev_cfg->name));
XML_SetElementHandler(parser, start_tag, NULL);
} else {
grp_cfg = (struct group_config *)config;
+ memset(grp_cfg, 0, sizeof(*grp_cfg));
strlcpy(grp_cfg->name, intf_name, sizeof(grp_cfg->name));
XML_SetElementHandler(parser, start_group_tag, NULL);
}
diff --git a/service/inc/public/agm/agm_api.h b/service/inc/public/agm/agm_api.h
index 99fb5f3..2906e8b 100644
--- a/service/inc/public/agm/agm_api.h
+++ b/service/inc/public/agm/agm_api.h
@@ -25,6 +25,39 @@
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
* 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 are provided under the following license:
+ * Copyright (c) 2022 Qualcomm Innovation Center, Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted (subject to the limitations in the
+ * disclaimer below) provided that the following conditions are met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials provided
+ * with the distribution.
+ *
+ * * Neither the name of Qualcomm Innovation Center, Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * NO EXPRESS OR IMPLIED LICENSES TO ANY PARTY'S PATENT RIGHTS ARE
+ * GRANTED BY THIS LICENSE. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT
+ * HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
+ * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
+ * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
+ * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef _AGM_INTF_H_
@@ -485,6 +518,16 @@
uint8_t event_payload[];
};
+/** Data passed by the client when requesting dump */
+struct agm_dump_info {
+ /**< identifies the signal received by client */
+ int32_t signal;
+ /**< identifies client pid */
+ uint32_t pid;
+ /**< identifies client uid */
+ uint32_t uid;
+};
+
/**
* \brief Callback function signature for events to client
*
@@ -1107,6 +1150,16 @@
*/
int agm_session_write_datapath_params(uint32_t session_id, struct agm_buff *buff);
+/**
+ * \brief Dump AGM information based on client
+ *
+ * \param[in] dump_info - dump information populated by
+ * the client to facilitate dump
+ *
+ * \return 0 on success, error code on failure.
+ */
+int agm_dump(struct agm_dump_info *dump_info);
+
#ifdef __cplusplus
} /* extern "C" */
#endif
diff --git a/service/src/agm.c b/service/src/agm.c
index fe4d491..ad2a773 100644
--- a/service/src/agm.c
+++ b/service/src/agm.c
@@ -25,6 +25,39 @@
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
* 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 are provided under the following license:
+ * Copyright (c) 2022 Qualcomm Innovation Center, Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted (subject to the limitations in the
+ * disclaimer below) provided that the following conditions are met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials provided
+ * with the distribution.
+ *
+ * * Neither the name of Qualcomm Innovation Center, Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * NO EXPRESS OR IMPLIED LICENSES TO ANY PARTY'S PATENT RIGHTS ARE
+ * GRANTED BY THIS LICENSE. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT
+ * HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
+ * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
+ * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
+ * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#define LOG_TAG "AGM: API"
#include <agm/agm_api.h>
@@ -867,3 +900,9 @@
return session_obj_write_with_metadata(obj, buff, &consumed_size);
}
+
+int agm_dump(struct agm_dump_info *dump_info __unused)
+{
+ // Placeholder for future enhancements
+ return 0;
+}
diff --git a/service/src/graph_module.c b/service/src/graph_module.c
index 1dcbb0b..4af4273 100644
--- a/service/src/graph_module.c
+++ b/service/src/graph_module.c
@@ -1171,16 +1171,15 @@
int ret = 0;
struct gsl_key_vector tkv;
struct session_obj *sess_obj = NULL;
-
size_t payload_size = 0, real_fmt_id = 0;
AGM_LOGE("enter");
+ memset(&tkv, 0, sizeof(struct gsl_key_vector));
if (graph_obj == NULL) {
AGM_LOGE("invalid graph object");
goto done;
}
sess_obj = graph_obj->sess_obj;
- memset(&tkv, 0, sizeof(struct gsl_key_vector));
/* 1. Configure placeholder decoder with Real ID */
ret = get_media_fmt_id_and_size(sess_obj->out_media_config.format,
&payload_size, &real_fmt_id);
diff --git a/service/src/session_obj.c b/service/src/session_obj.c
index 5164976..6bcf1cb 100644
--- a/service/src/session_obj.c
+++ b/service/src/session_obj.c
@@ -1,5 +1,6 @@
/*
* Copyright (c) 2019-2021, The Linux Foundation. All rights reserved.
+ * Copyright (c) 2022 Qualcomm Innovation Center, Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
@@ -1249,6 +1250,7 @@
}
sess_obj->graph = NULL;
sess_obj->ec_ref_state = false;
+ sess_obj->loopback_state = false;
if (sess_mode != AGM_SESSION_NON_TUNNEL && sess_mode != AGM_SESSION_NO_CONFIG) {
list_for_each(node, &sess_obj->aif_pool) {
@@ -2062,7 +2064,9 @@
ret = session_set_loopback(sess_obj, sess_obj->loopback_sess_id,
sess_obj->loopback_state);
if (ret) {
- goto done;
+ sess_obj->loopback_state = false;
+ sess_obj->loopback_sess_id = 0;
+ goto unwind;
}
}
diff --git a/snd_parser/configs/sxr2130/card-defs.xml b/snd_parser/configs/sxr2130/card-defs.xml
index f4ab036..41e835b 100644
--- a/snd_parser/configs/sxr2130/card-defs.xml
+++ b/snd_parser/configs/sxr2130/card-defs.xml
@@ -26,14 +26,14 @@
<!-- IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -->
<defs>
<card>
- <id>0</id>
- <name>konamtpsndcard</name>
+ <id>100</id>
+ <name>konavirtualsndcard</name>
<pcm-device>
<id>100</id>
<name>PCM100</name>
<pcm_plugin>
- <so-name>libagm_pcm_plugin.so</so-name>
+ <so-name>libagm_pcm_passthrough_plugin.so</so-name>
</pcm_plugin>
<props>
<playback>1</playback>
@@ -45,7 +45,7 @@
<id>101</id>
<name>PCM101</name>
<pcm_plugin>
- <so-name>libagm_pcm_plugin.so</so-name>
+ <so-name>libagm_pcm_passthrough_plugin.so</so-name>
</pcm_plugin>
<props>
<playback>0</playback>
@@ -57,7 +57,7 @@
<id>103</id>
<name>PCM103</name>
<pcm_plugin>
- <so-name>libagm_pcm_plugin.so</so-name>
+ <so-name>libagm_pcm_passthrough_plugin.so</so-name>
</pcm_plugin>
<props>
<playback>1</playback>
@@ -70,7 +70,7 @@
<id>104</id>
<name>PCM104</name>
<pcm_plugin>
- <so-name>libagm_pcm_plugin.so</so-name>
+ <so-name>libagm_pcm_passthrough_plugin.so</so-name>
</pcm_plugin>
<props>
<playback>0</playback>
@@ -83,7 +83,7 @@
<id>105</id>
<name>COMPRESS105</name>
<compress_plugin>
- <so-name>libagm_compress_plugin.so</so-name>
+ <so-name>libagm_compress_passthrough_plugin.so</so-name>
</compress_plugin>
<props>
<playback>1</playback>
@@ -96,7 +96,7 @@
<id>1</id>
<name>agm_mixer</name>
<mixer_plugin>
- <so-name>libagm_mixer_plugin.so</so-name>
+ <so-name>libagm_mixer_passthrough_plugin.so</so-name>
</mixer_plugin>
</mixer>