hidl: Implement vendor.lineage.touch@1.0 HAL for Xiaomi
* This can be used by any Xiaomi device that has a touch display that supports multiple sample rates and Xiaomi touch. * Most newer Xiaomi phones with high screen refresh rates fit this category: * e.g. Mi 10/Pro/Ultra/T/T Pro, Xiaomi SM8350 platform phones & Xiaomi SM6375 phones Change-Id: Iaf956420157bbc978690fac9053d507ccaea847a
This commit is contained in:
parent
9291711cb7
commit
b1f26c0899
1
hidl/touch/.clang-format
Symbolic link
1
hidl/touch/.clang-format
Symbolic link
@ -0,0 +1 @@
|
|||||||
|
../../../../build/soong/scripts/system-clang-format
|
25
hidl/touch/Android.bp
Normal file
25
hidl/touch/Android.bp
Normal file
@ -0,0 +1,25 @@
|
|||||||
|
//
|
||||||
|
// Copyright (C) 2022 The LineageOS Project
|
||||||
|
//
|
||||||
|
// SPDX-License-Identifier: Apache-2.0
|
||||||
|
//
|
||||||
|
|
||||||
|
cc_binary {
|
||||||
|
name: "vendor.lineage.touch@1.0-service.xiaomi",
|
||||||
|
vintf_fragments: ["vendor.lineage.touch@1.0-service.xiaomi.xml"],
|
||||||
|
init_rc: ["vendor.lineage.touch@1.0-service.xiaomi.rc"],
|
||||||
|
defaults: ["hidl_defaults"],
|
||||||
|
relative_install_path: "hw",
|
||||||
|
proprietary: true,
|
||||||
|
srcs: [
|
||||||
|
"HighTouchPollingRate.cpp",
|
||||||
|
"service.cpp",
|
||||||
|
],
|
||||||
|
shared_libs: [
|
||||||
|
"libbase",
|
||||||
|
"libbinder",
|
||||||
|
"libhidlbase",
|
||||||
|
"libutils",
|
||||||
|
"vendor.lineage.touch@1.0",
|
||||||
|
],
|
||||||
|
}
|
39
hidl/touch/HighTouchPollingRate.cpp
Normal file
39
hidl/touch/HighTouchPollingRate.cpp
Normal file
@ -0,0 +1,39 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 2022 The LineageOS Project
|
||||||
|
*
|
||||||
|
* SPDX-License-Identifier: Apache-2.0
|
||||||
|
*/
|
||||||
|
|
||||||
|
#define LOG_TAG "HighTouchPollingRateService"
|
||||||
|
|
||||||
|
#include "HighTouchPollingRate.h"
|
||||||
|
|
||||||
|
#include <fstream>
|
||||||
|
|
||||||
|
namespace vendor {
|
||||||
|
namespace lineage {
|
||||||
|
namespace touch {
|
||||||
|
namespace V1_0 {
|
||||||
|
namespace implementation {
|
||||||
|
|
||||||
|
#define HIGH_TOUCH_POLLING_PATH = "/sys/devices/virtual/touch/touch_dev/bump_sample_rate"
|
||||||
|
|
||||||
|
Return<bool> HighTouchPollingRate::isEnabled() {
|
||||||
|
std::ifstream file(HIGH_TOUCH_POLLING_PATH);
|
||||||
|
int enabled;
|
||||||
|
file >> enabled;
|
||||||
|
|
||||||
|
return enabled == 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
Return<bool> HighTouchPollingRate::setEnabled(bool enabled) {
|
||||||
|
std::ofstream file(HIGH_TOUCH_POLLING_PATH);
|
||||||
|
file << (enabled ? "1" : "0");
|
||||||
|
return !file.fail();
|
||||||
|
}
|
||||||
|
|
||||||
|
} // namespace implementation
|
||||||
|
} // namespace V1_0
|
||||||
|
} // namespace touch
|
||||||
|
} // namespace lineage
|
||||||
|
} // namespace vendor
|
30
hidl/touch/HighTouchPollingRate.h
Normal file
30
hidl/touch/HighTouchPollingRate.h
Normal file
@ -0,0 +1,30 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 2022 The LineageOS Project
|
||||||
|
*
|
||||||
|
* SPDX-License-Identifier: Apache-2.0
|
||||||
|
*/
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include <vendor/lineage/touch/1.0/IHighTouchPollingRate.h>
|
||||||
|
|
||||||
|
namespace vendor {
|
||||||
|
namespace lineage {
|
||||||
|
namespace touch {
|
||||||
|
namespace V1_0 {
|
||||||
|
namespace implementation {
|
||||||
|
|
||||||
|
using ::android::hardware::Return;
|
||||||
|
|
||||||
|
class HighTouchPollingRate : public IHighTouchPollingRate {
|
||||||
|
public:
|
||||||
|
// Methods from ::vendor::lineage::touch::V1_0::IHighTouchPollingRate follow.
|
||||||
|
Return<bool> isEnabled() override;
|
||||||
|
Return<bool> setEnabled(bool enabled) override;
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace implementation
|
||||||
|
} // namespace V1_0
|
||||||
|
} // namespace touch
|
||||||
|
} // namespace lineage
|
||||||
|
} // namespace vendor
|
33
hidl/touch/service.cpp
Normal file
33
hidl/touch/service.cpp
Normal file
@ -0,0 +1,33 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 2022 The LineageOS Project
|
||||||
|
*
|
||||||
|
* SPDX-License-Identifier: Apache-2.0
|
||||||
|
*/
|
||||||
|
|
||||||
|
#define LOG_TAG "lineage.touch@1.0-service.xiaomi"
|
||||||
|
|
||||||
|
#include <android-base/logging.h>
|
||||||
|
#include <hidl/HidlTransportSupport.h>
|
||||||
|
|
||||||
|
#include "HighTouchPollingRate.h"
|
||||||
|
|
||||||
|
using ::vendor::lineage::touch::V1_0::IHighTouchPollingRate;
|
||||||
|
using ::vendor::lineage::touch::V1_0::implementation::HighTouchPollingRate;
|
||||||
|
|
||||||
|
int main() {
|
||||||
|
android::sp<IHighTouchPollingRate> highTouchPollingRate = new HighTouchPollingRate();
|
||||||
|
|
||||||
|
android::hardware::configureRpcThreadpool(1, true);
|
||||||
|
|
||||||
|
if (highTouchPollingRate->registerAsService() != android::OK) {
|
||||||
|
LOG(ERROR) << "Cannot register touchscreen high polling rate HAL service.";
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
LOG(INFO) << "Touchscreen HAL service ready.";
|
||||||
|
|
||||||
|
android::hardware::joinRpcThreadpool();
|
||||||
|
|
||||||
|
LOG(ERROR) << "Touchscreen HAL service failed to join thread pool.";
|
||||||
|
return 1;
|
||||||
|
}
|
5
hidl/touch/vendor.lineage.touch@1.0-service.xiaomi.rc
Normal file
5
hidl/touch/vendor.lineage.touch@1.0-service.xiaomi.rc
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
service vendor.touch-hal-1-0 /vendor/bin/hw/vendor.lineage.touch@1.0-service.xiaomi
|
||||||
|
interface vendor.lineage.touch@1.0::IHighTouchPollingRate default
|
||||||
|
class hal
|
||||||
|
user system
|
||||||
|
group system
|
11
hidl/touch/vendor.lineage.touch@1.0-service.xiaomi.xml
Normal file
11
hidl/touch/vendor.lineage.touch@1.0-service.xiaomi.xml
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
<manifest version="1.0" type="device">
|
||||||
|
<hal format="hidl">
|
||||||
|
<name>vendor.lineage.touch</name>
|
||||||
|
<transport>hwbinder</transport>
|
||||||
|
<version>1.0</version>
|
||||||
|
<interface>
|
||||||
|
<name>IHighTouchPollingRate</name>
|
||||||
|
<instance>default</instance>
|
||||||
|
</interface>
|
||||||
|
</hal>
|
||||||
|
</manifest>
|
Loading…
Reference in New Issue
Block a user