From a3c821bf72659796dfeb1c78c7f86457146511c2 Mon Sep 17 00:00:00 2001 From: Lucchetto Date: Thu, 21 Dec 2023 08:47:30 +0100 Subject: [PATCH 1/6] common: Create dummy libqti-perfd-client * proprietary perfd blobs can finally be nuked without breaking goodix * we could even map the functions to use libperfmgr powerhints in the future [SebaUbuntu]: Cleanup Android.bp and add copyright header Change-Id: I124652f3041761966a3e3bd97c757fecc39cc5fb --- libqti-perfd-client/Android.bp | 14 ++++++++++++++ libqti-perfd-client/client.cpp | 16 ++++++++++++++++ 2 files changed, 30 insertions(+) create mode 100644 libqti-perfd-client/Android.bp create mode 100644 libqti-perfd-client/client.cpp diff --git a/libqti-perfd-client/Android.bp b/libqti-perfd-client/Android.bp new file mode 100644 index 0000000..1227532 --- /dev/null +++ b/libqti-perfd-client/Android.bp @@ -0,0 +1,14 @@ +// +// Copyright (C) 2021 The LineageOS Project +// +// SPDX-License-Identifier: Apache-2.0 +// + +cc_library_shared { + name: "libqti-perfd-client", + srcs: ["client.cpp"], + shared_libs: [ + "libutils", + ], + vendor: true, +} diff --git a/libqti-perfd-client/client.cpp b/libqti-perfd-client/client.cpp new file mode 100644 index 0000000..542a8b6 --- /dev/null +++ b/libqti-perfd-client/client.cpp @@ -0,0 +1,16 @@ +/* + * Copyright (C) 2021 The LineageOS Project + * + * SPDX-License-Identifier: Apache-2.0 + */ + +#include + +namespace android { + extern "C" void perf_get_feedback() {} + extern "C" void perf_hint() {} + extern "C" void perf_lock_acq() {} + extern "C" void perf_lock_cmd() {} + extern "C" void perf_lock_rel() {} + extern "C" void perf_lock_use_profile() {} +} From 469b15132c8cbb54fe1b29ebe0642fe4af6bdb5e Mon Sep 17 00:00:00 2001 From: Bruno Martins Date: Thu, 21 Dec 2023 08:49:19 +0100 Subject: [PATCH 2/6] libqti-perfd-client: Remove namespace declaration It's pointless when using extern "C". Change-Id: Ibdf9f06a70aa3a75687b33781c78cf2172bb334d --- libqti-perfd-client/client.cpp | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/libqti-perfd-client/client.cpp b/libqti-perfd-client/client.cpp index 542a8b6..bb6f812 100644 --- a/libqti-perfd-client/client.cpp +++ b/libqti-perfd-client/client.cpp @@ -6,11 +6,9 @@ #include -namespace android { - extern "C" void perf_get_feedback() {} - extern "C" void perf_hint() {} - extern "C" void perf_lock_acq() {} - extern "C" void perf_lock_cmd() {} - extern "C" void perf_lock_rel() {} - extern "C" void perf_lock_use_profile() {} -} +extern "C" void perf_get_feedback() {} +extern "C" void perf_hint() {} +extern "C" void perf_lock_acq() {} +extern "C" void perf_lock_cmd() {} +extern "C" void perf_lock_rel() {} +extern "C" void perf_lock_use_profile() {} From 9c2bef509602ddd73dae91477524713831b30e59 Mon Sep 17 00:00:00 2001 From: Chenyang Zhong Date: Thu, 21 Dec 2023 08:50:32 +0100 Subject: [PATCH 3/6] libqti-perfd-client: return a dummy value Return a positive integer for perf lock acquire and release so that Goodix/FPC fingerprint sensor blobs will not complain. Goodix: E [goodixHAL][gf_hal_milan_f_series]: goodix_perf_lock_acquire: Failed to acquire perf lock, err: 0 E [goodixHAL][gf_hal_milan_f_series]: goodix_perf_lock_release: Perf lock release error 0 FPC: E fpc_tac : fpc_perf_lock_acquire: Incorrect params, Failed to acquire perf lock, err E fpc_tac : fpc_perf_lock_release: Perf lock release error 0 Signed-off-by: Chenyang Zhong Change-Id: I861672e9a738c2204755d802670f4b28b662f286 --- libqti-perfd-client/Android.bp | 1 + libqti-perfd-client/client.cpp | 20 ++++++++++++++++++-- 2 files changed, 19 insertions(+), 2 deletions(-) diff --git a/libqti-perfd-client/Android.bp b/libqti-perfd-client/Android.bp index 1227532..a809a7c 100644 --- a/libqti-perfd-client/Android.bp +++ b/libqti-perfd-client/Android.bp @@ -8,6 +8,7 @@ cc_library_shared { name: "libqti-perfd-client", srcs: ["client.cpp"], shared_libs: [ + "liblog", "libutils", ], vendor: true, diff --git a/libqti-perfd-client/client.cpp b/libqti-perfd-client/client.cpp index bb6f812..9f92fa8 100644 --- a/libqti-perfd-client/client.cpp +++ b/libqti-perfd-client/client.cpp @@ -4,11 +4,27 @@ * SPDX-License-Identifier: Apache-2.0 */ +#define LOG_TAG "libqti-perfd-client" + #include +#include extern "C" void perf_get_feedback() {} extern "C" void perf_hint() {} -extern "C" void perf_lock_acq() {} +extern "C" int perf_lock_acq(int handle, int duration, int arg3[], int arg4) { + ALOGI("perf_lock_acq: handle: %d, duration: %d, arg3[0]: %d, arg4: %d", + handle, duration, arg3[0], arg4); + if (handle > 0) + return handle; + + return 233; +} extern "C" void perf_lock_cmd() {} -extern "C" void perf_lock_rel() {} +extern "C" int perf_lock_rel(int handle) { + ALOGI("perf_lock_rel: handle: %d", handle); + if (handle > 0) + return handle; + + return 233; +} extern "C" void perf_lock_use_profile() {} From 5779574c68e130a7a8b98cc67b4aa1f2003463a7 Mon Sep 17 00:00:00 2001 From: Sebastiano Barezzi Date: Sun, 20 Jun 2021 02:49:03 +0200 Subject: [PATCH 4/6] libqti-perfd-client: Move to C * Why bothering with C++ mangling when we can just build it as a standard C library? Change-Id: I45ea977edf7ea7fab6fece76f3049654a8d24c5d --- libqti-perfd-client/Android.bp | 2 +- libqti-perfd-client/{client.cpp => client.c} | 12 ++++++------ 2 files changed, 7 insertions(+), 7 deletions(-) rename libqti-perfd-client/{client.cpp => client.c} (63%) diff --git a/libqti-perfd-client/Android.bp b/libqti-perfd-client/Android.bp index a809a7c..2189074 100644 --- a/libqti-perfd-client/Android.bp +++ b/libqti-perfd-client/Android.bp @@ -6,7 +6,7 @@ cc_library_shared { name: "libqti-perfd-client", - srcs: ["client.cpp"], + srcs: ["client.c"], shared_libs: [ "liblog", "libutils", diff --git a/libqti-perfd-client/client.cpp b/libqti-perfd-client/client.c similarity index 63% rename from libqti-perfd-client/client.cpp rename to libqti-perfd-client/client.c index 9f92fa8..66e75b4 100644 --- a/libqti-perfd-client/client.cpp +++ b/libqti-perfd-client/client.c @@ -9,9 +9,9 @@ #include #include -extern "C" void perf_get_feedback() {} -extern "C" void perf_hint() {} -extern "C" int perf_lock_acq(int handle, int duration, int arg3[], int arg4) { +void perf_get_feedback() {} +void perf_hint() {} +int perf_lock_acq(int handle, int duration, int arg3[], int arg4) { ALOGI("perf_lock_acq: handle: %d, duration: %d, arg3[0]: %d, arg4: %d", handle, duration, arg3[0], arg4); if (handle > 0) @@ -19,12 +19,12 @@ extern "C" int perf_lock_acq(int handle, int duration, int arg3[], int arg4) { return 233; } -extern "C" void perf_lock_cmd() {} -extern "C" int perf_lock_rel(int handle) { +void perf_lock_cmd() {} +int perf_lock_rel(int handle) { ALOGI("perf_lock_rel: handle: %d", handle); if (handle > 0) return handle; return 233; } -extern "C" void perf_lock_use_profile() {} +void perf_lock_use_profile() {} From 99b280670177ceffe61e420cc39938d81ebc017d Mon Sep 17 00:00:00 2001 From: Han Sol Jin Date: Fri, 26 Apr 2024 16:09:10 -0700 Subject: [PATCH 5/6] libqti-perfd-client: Add Soong namespace This avoids conflicts with QCOM devices that are using the QTI perf implementation, which wouldn't want this library anyway as this one is a stub. Change-Id: I6258b7503bc45b8dced2022e6ff143fbe97e7c82 --- libqti-perfd-client/Android.bp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/libqti-perfd-client/Android.bp b/libqti-perfd-client/Android.bp index 2189074..9b445d6 100644 --- a/libqti-perfd-client/Android.bp +++ b/libqti-perfd-client/Android.bp @@ -1,9 +1,12 @@ // -// Copyright (C) 2021 The LineageOS Project +// Copyright (C) 2021-2024 The LineageOS Project // // SPDX-License-Identifier: Apache-2.0 // +soong_namespace { +} + cc_library_shared { name: "libqti-perfd-client", srcs: ["client.c"], From 23cd78f8e430f160e72ed8b2a34be4f8c7718913 Mon Sep 17 00:00:00 2001 From: LuK1337 Date: Fri, 26 Jan 2024 12:52:09 +0100 Subject: [PATCH 6/6] libqti-perfd-client: Clean up * Add and run clang-format * Add newlines between functions * Use elvis operator `?:` for return value Change-Id: I920044df12c99d32ddd2ef3fb5edf24bcd0c7360 --- libqti-perfd-client/.clang-format | 1 + libqti-perfd-client/client.c | 23 +++++++++++------------ 2 files changed, 12 insertions(+), 12 deletions(-) create mode 120000 libqti-perfd-client/.clang-format diff --git a/libqti-perfd-client/.clang-format b/libqti-perfd-client/.clang-format new file mode 120000 index 0000000..0457b53 --- /dev/null +++ b/libqti-perfd-client/.clang-format @@ -0,0 +1 @@ +../../../../build/soong/scripts/system-clang-format \ No newline at end of file diff --git a/libqti-perfd-client/client.c b/libqti-perfd-client/client.c index 66e75b4..547ebcd 100644 --- a/libqti-perfd-client/client.c +++ b/libqti-perfd-client/client.c @@ -1,30 +1,29 @@ /* - * Copyright (C) 2021 The LineageOS Project + * Copyright (C) 2021-2024 The LineageOS Project * * SPDX-License-Identifier: Apache-2.0 */ #define LOG_TAG "libqti-perfd-client" -#include #include +#include void perf_get_feedback() {} + void perf_hint() {} -int perf_lock_acq(int handle, int duration, int arg3[], int arg4) { - ALOGI("perf_lock_acq: handle: %d, duration: %d, arg3[0]: %d, arg4: %d", - handle, duration, arg3[0], arg4); - if (handle > 0) - return handle; - return 233; +int perf_lock_acq(int handle, int duration, int arg3[], int arg4) { + ALOGI("perf_lock_acq: handle: %d, duration: %d, arg3[0]: %d, arg4: %d", handle, duration, + arg3[0], arg4); + return handle ?: 233; } + void perf_lock_cmd() {} + int perf_lock_rel(int handle) { ALOGI("perf_lock_rel: handle: %d", handle); - if (handle > 0) - return handle; - - return 233; + return handle ?: 233; } + void perf_lock_use_profile() {}