a71-common: Move to Samsung common Touch HAL

Change-Id: I5c4de6e4956e316600e327b725b863ddf9e63fc1
This commit is contained in:
Bruno Martins
2025-08-31 00:28:47 +01:00
parent 71270c3e5d
commit 651dde32ef
15 changed files with 19 additions and 365 deletions

View File

@@ -1,5 +1,5 @@
//
// Copyright (C) 2024 The LineageOS Project
// Copyright (C) 2024-2025 The LineageOS Project
//
// SPDX-License-Identifier: Apache-2.0
//
@@ -7,7 +7,6 @@
soong_namespace {
imports: [
"hardware/qcom-caf/common/libqti-perfd-client",
"hardware/samsung",
],
}

View File

@@ -393,7 +393,7 @@ PRODUCT_BOOT_JARS += \
# Touch
PRODUCT_PACKAGES += \
vendor.lineage.touch-service.samsung_sm6150 \
vendor.lineage.touch-service.samsung \
# USB
PRODUCT_PACKAGES += \

View File

@@ -1,19 +0,0 @@
/*
* SPDX-FileCopyrightText: 2024-2025 The LineageOS Project
* SPDX-License-Identifier: Apache-2.0
*/
#pragma once
/*
* Board specific nodes
*
* If your kernel exposes these controls in another place, you can either
* symlink to the locations given here, or override this header in your
* device tree.
*/
// For GloveMode
#define TSP_CMD_LIST_NODE "/sys/class/sec/tsp/cmd_list"
#define TSP_CMD_RESULT_NODE "/sys/class/sec/tsp/cmd_result"
#define TSP_CMD_NODE "/sys/class/sec/tsp/cmd"

View File

@@ -158,6 +158,22 @@
<name>com.qualcomm.qti.uceservice</name>
<transport>hwbinder</transport>
</hal>
<hal format="aidl">
<name>vendor.lineage.touch</name>
<version>1</version>
<interface>
<name>IGloveMode</name>
<instance>default</instance>
</interface>
<interface>
<name>IHighTouchPollingRate</name>
<instance>default</instance>
</interface>
<interface>
<name>ITouchscreenGesture</name>
<instance>default</instance>
</interface>
</hal>
<hal format="hidl">
<name>vendor.display.color</name>
<transport>hwbinder</transport>

View File

@@ -188,7 +188,7 @@
/(vendor|system/vendor)/bin/hw/macloader u:object_r:macloader_exec:s0
/(vendor|system/vendor)/bin/hw/sehradiomanager u:object_r:sehradiomanager_exec:s0
/(vendor|system/vendor)/bin/hw/vendor\.lineage\.livedisplay@2\.0-service.samsung-qcom\.sm6150 u:object_r:hal_lineage_livedisplay_sysfs_exec:s0
/(vendor|system/vendor)/bin/hw/vendor\.lineage\.touch-service\.samsung_sm6150 u:object_r:hal_lineage_touch_default_exec:s0
/(vendor|system/vendor)/bin/hw/vendor\.lineage\.touch-service\.samsung u:object_r:hal_lineage_touch_default_exec:s0
/(vendor|system/vendor)/bin/factory\.ssc u:object_r:factory_ssc_exec:s0
/(vendor|system/vendor)/bin/secril_config_svc u:object_r:secril_config_svc_exec:s0
/vendor/lib(/.*)? u:object_r:same_process_hal_file:s0

View File

@@ -1,27 +0,0 @@
//
// Copyright (C) 2024-2025 The LineageOS Project
//
// SPDX-License-Identifier: Apache-2.0
//
cc_binary {
name: "vendor.lineage.touch-service.samsung_sm6150",
init_rc: ["vendor.lineage.touch-service.samsung_sm6150.rc"],
vintf_fragments: ["vendor.lineage.touch-service.samsung_sm6150.xml"],
defaults: ["samsung_header_path_defaults"],
relative_install_path: "hw",
proprietary: true,
srcs: [
"GloveMode.cpp",
"HighTouchPollingRate.cpp",
"TouchscreenGesture.cpp",
"service.cpp"
],
shared_libs: [
"libbase",
"liblog",
"libbinder_ndk",
"libutils",
"vendor.lineage.touch-V1-ndk",
],
}

View File

@@ -1,49 +0,0 @@
/*
* SPDX-FileCopyrightText: 2025 The LineageOS Project
* SPDX-License-Identifier: Apache-2.0
*/
#include <fstream>
#include "GloveMode.h"
namespace aidl {
namespace vendor {
namespace lineage {
namespace touch {
bool GloveMode::isSupported() {
std::ifstream file(TSP_CMD_LIST_NODE);
if (file.is_open()) {
std::string line;
while (getline(file, line)) {
if (!line.compare("glove_mode")) return true;
}
file.close();
}
return false;
}
ndk::ScopedAStatus GloveMode::getEnabled(bool* _aidl_return) {
std::ifstream file(TSP_CMD_RESULT_NODE);
if (file.is_open()) {
std::string line;
getline(file, line);
*_aidl_return = !line.compare("glove_mode,1:OK");
file.close();
}
return ndk::ScopedAStatus::ok();
}
ndk::ScopedAStatus GloveMode::setEnabled(bool enabled) {
std::ofstream file(TSP_CMD_NODE);
file << "glove_mode," << (enabled ? "1" : "0");
return ndk::ScopedAStatus::ok();
}
} // namespace touch
} // namespace lineage
} // namespace vendor
} // namespace aidl

View File

@@ -1,27 +0,0 @@
/*
* SPDX-FileCopyrightText: 2025 The LineageOS Project
* SPDX-License-Identifier: Apache-2.0
*/
#pragma once
#include <aidl/vendor/lineage/touch/BnGloveMode.h>
#include <samsung_touch.h>
namespace aidl {
namespace vendor {
namespace lineage {
namespace touch {
class GloveMode : public BnGloveMode {
public:
bool isSupported();
ndk::ScopedAStatus getEnabled(bool* _aidl_return) override;
ndk::ScopedAStatus setEnabled(bool enabled) override;
};
} // namespace touch
} // namespace lineage
} // namespace vendor
} // namespace aidl

View File

@@ -1,49 +0,0 @@
/*
* SPDX-FileCopyrightText: 2025 The LineageOS Project
* SPDX-License-Identifier: Apache-2.0
*/
#include <fstream>
#include "HighTouchPollingRate.h"
namespace aidl {
namespace vendor {
namespace lineage {
namespace touch {
bool HighTouchPollingRate::isSupported() {
std::ifstream file(TSP_CMD_LIST_NODE);
if (file.is_open()) {
std::string line;
while (getline(file, line)) {
if (!line.compare("set_game_mode")) return true;
}
file.close();
}
return false;
}
ndk::ScopedAStatus HighTouchPollingRate::getEnabled(bool* _aidl_return) {
std::ifstream file(TSP_CMD_RESULT_NODE);
if (file.is_open()) {
std::string line;
getline(file, line);
*_aidl_return = !line.compare("set_game_mode,1:OK");
file.close();
}
return ndk::ScopedAStatus::ok();
}
ndk::ScopedAStatus HighTouchPollingRate::setEnabled(bool enabled) {
std::ofstream file(TSP_CMD_NODE);
file << "set_game_mode," << (enabled ? "1" : "0");
return ndk::ScopedAStatus::ok();
}
} // namespace touch
} // namespace lineage
} // namespace vendor
} // namespace aidl

View File

@@ -1,27 +0,0 @@
/*
* SPDX-FileCopyrightText: 2025 The LineageOS Project
* SPDX-License-Identifier: Apache-2.0
*/
#pragma once
#include <aidl/vendor/lineage/touch/BnHighTouchPollingRate.h>
#include <samsung_touch.h>
namespace aidl {
namespace vendor {
namespace lineage {
namespace touch {
class HighTouchPollingRate : public BnHighTouchPollingRate {
public:
bool isSupported();
ndk::ScopedAStatus getEnabled(bool* _aidl_return) override;
ndk::ScopedAStatus setEnabled(bool enabled) override;
};
} // namespace touch
} // namespace lineage
} // namespace vendor
} // namespace aidl

View File

@@ -1,54 +0,0 @@
/*
* SPDX-FileCopyrightText: 2025 The LineageOS Project
* SPDX-License-Identifier: Apache-2.0
*/
#include <fstream>
#include "TouchscreenGesture.h"
namespace aidl {
namespace vendor {
namespace lineage {
namespace touch {
const std::map<int32_t, TouchscreenGesture::GestureInfo> TouchscreenGesture::kGestureInfoMap = {
// clang-format off
{0, {0x1c7, "Single Tap"}},
// clang-format on
};
bool TouchscreenGesture::isSupported() {
std::ifstream file(TSP_CMD_LIST_NODE);
if (file.is_open()) {
std::string line;
while (getline(file, line)) {
if (!line.compare("singletap_enable")) return true;
}
file.close();
}
return false;
}
ndk::ScopedAStatus TouchscreenGesture::getSupportedGestures(std::vector<Gesture>* _aidl_return) {
std::vector<Gesture> gestures;
for (const auto& entry : kGestureInfoMap) {
gestures.push_back({entry.first, entry.second.name, entry.second.keycode});
}
*_aidl_return = gestures;
return ndk::ScopedAStatus::ok();
}
ndk::ScopedAStatus TouchscreenGesture::setGestureEnabled(const Gesture& gesture, bool enabled) {
std::ofstream file(TSP_CMD_NODE);
file << "singletap_enable," << (enabled ? "1" : "0");
return ndk::ScopedAStatus::ok();
}
} // namespace touch
} // namespace lineage
} // namespace vendor
} // namespace aidl

View File

@@ -1,35 +0,0 @@
/*
* SPDX-FileCopyrightText: 2025 The LineageOS Project
* SPDX-License-Identifier: Apache-2.0
*/
#pragma once
#include <aidl/vendor/lineage/touch/BnTouchscreenGesture.h>
#include <map>
#include <samsung_touch.h>
namespace aidl {
namespace vendor {
namespace lineage {
namespace touch {
class TouchscreenGesture : public BnTouchscreenGesture {
public:
bool isSupported();
ndk::ScopedAStatus getSupportedGestures(std::vector<Gesture>* _aidl_return) override;
ndk::ScopedAStatus setGestureEnabled(const Gesture& gesture, bool enabled) override;
private:
typedef struct {
int32_t keycode;
const char* name;
} GestureInfo;
static const std::map<int32_t, GestureInfo> kGestureInfoMap; // id -> info
};
} // namespace touch
} // namespace lineage
} // namespace vendor
} // namespace aidl

View File

@@ -1,48 +0,0 @@
/*
* SPDX-FileCopyrightText: 2025 The LineageOS Project
* SPDX-License-Identifier: Apache-2.0
*/
#define LOG_TAG "vendor.lineage.touch-service.samsung_sm6150"
#include "GloveMode.h"
#include "HighTouchPollingRate.h"
#include "TouchscreenGesture.h"
#include <android-base/logging.h>
#include <android/binder_manager.h>
#include <android/binder_process.h>
using aidl::vendor::lineage::touch::GloveMode;
using aidl::vendor::lineage::touch::HighTouchPollingRate;
using aidl::vendor::lineage::touch::TouchscreenGesture;
int main() {
binder_status_t status = STATUS_OK;
ABinderProcess_setThreadPoolMaxThreadCount(0);
std::shared_ptr<GloveMode> gm = ndk::SharedRefBase::make<GloveMode>();
if (gm->isSupported()) {
const std::string gm_instance = std::string(GloveMode::descriptor) + "/default";
status = AServiceManager_addService(gm->asBinder().get(), gm_instance.c_str());
CHECK_EQ(status, STATUS_OK) << "Failed to add service " << gm_instance << " " << status;
}
std::shared_ptr<HighTouchPollingRate> htpr = ndk::SharedRefBase::make<HighTouchPollingRate>();
if (htpr->isSupported()) {
const std::string htpr_instance = std::string(HighTouchPollingRate::descriptor) + "/default";
status = AServiceManager_addService(htpr->asBinder().get(), htpr_instance.c_str());
CHECK_EQ(status, STATUS_OK) << "Failed to add service " << htpr_instance << " " << status;
}
std::shared_ptr<TouchscreenGesture> tg = ndk::SharedRefBase::make<TouchscreenGesture>();
if (tg->isSupported()) {
const std::string tg_instance = std::string(TouchscreenGesture::descriptor) + "/default";
status = AServiceManager_addService(tg->asBinder().get(), tg_instance.c_str());
CHECK_EQ(status, STATUS_OK) << "Failed to add service " << tg_instance << " " << status;
}
ABinderProcess_joinThreadPool();
return EXIT_FAILURE; // should not reach
}

View File

@@ -1,8 +0,0 @@
on early-init
chown system radio /sys/class/sec/tsp/cmd
chmod 0664 /sys/class/sec/tsp/cmd
service vendor.touch-hal /vendor/bin/hw/vendor.lineage.touch-service.samsung_sm6150
class hal
user system
group system

View File

@@ -1,18 +0,0 @@
<manifest version="1.0" type="device">
<hal format="aidl">
<name>vendor.lineage.touch</name>
<version>1</version>
<interface>
<name>IGloveMode</name>
<instance>default</instance>
</interface>
<interface>
<name>IHighTouchPollingRate</name>
<instance>default</instance>
</interface>
<interface>
<name>ITouchscreenGesture</name>
<instance>default</instance>
</interface>
</hal>
</manifest>