Skip to content
This repository has been archived by the owner on Apr 10, 2024. It is now read-only.

Commit

Permalink
sm8250-common: Implement HighTouchPollingRate for supported devices
Browse files Browse the repository at this point in the history
Signed-off-by: electimon <[email protected]>
Change-Id: I2c6623f18e0b5dbbe165c699b826fce68f9050eb
  • Loading branch information
electimon authored and moetayuko committed Aug 19, 2022
1 parent b1e5637 commit 0b5c476
Show file tree
Hide file tree
Showing 8 changed files with 99 additions and 23 deletions.
6 changes: 5 additions & 1 deletion lineagehw/touch/Android.bp
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ soong_config_module_type {
name: "moto_kona_touch_hal",
module_type: "cc_defaults",
config_namespace: "MOTO_KONA_TOUCH",
bool_variables: ["USE_TOUCH_POLLING_RATE"],
value_variables: ["SINGLE_TAP_PATH"],
properties: [
"cppflags",
Expand All @@ -27,6 +28,10 @@ soong_config_module_type {
moto_kona_touch_hal {
name: "moto_kona_touch_hal_cc_defaults",
soong_config_variables: {
USE_TOUCH_POLLING_RATE: {
cppflags: ["-DUSE_TOUCH_POLLING_RATE"],
srcs: ["HighTouchPollingRate.cpp"],
},
SINGLE_TAP_PATH: {
cppflags: ["-DSINGLE_TAP_PATH=\"%s\""],
srcs: ["TouchscreenGesture.cpp"],
Expand All @@ -41,7 +46,6 @@ cc_binary {
"hidl_defaults",
"moto_kona_touch_hal_cc_defaults"
],
vintf_fragments: ["[email protected]_kona.xml"],
relative_install_path: "hw",
vendor: true,
srcs: [
Expand Down
44 changes: 44 additions & 0 deletions lineagehw/touch/HighTouchPollingRate.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
/*
* Copyright (C) 2022 The LineageOS Project
*
* SPDX-License-Identifier: Apache-2.0
*/

#define LOG_TAG "HighTouchPollingRateService"

#include "HighTouchPollingRate.h"

#include <android-base/file.h>
#include <android-base/logging.h>
#include <android-base/strings.h>

namespace vendor {
namespace lineage {
namespace touch {
namespace V1_0 {
namespace implementation {

const std::string kInterpolationPath = "/sys/class/touchscreen/primary/interpolation";

Return<bool> HighTouchPollingRate::isEnabled() {
std::string buf;
if (!android::base::ReadFileToString(kInterpolationPath, &buf)) {
LOG(ERROR) << "Failed to read " << kInterpolationPath;
return false;
}
return std::stoi(android::base::Trim(buf)) == 1;
}

Return<bool> HighTouchPollingRate::setEnabled(bool enabled) {
if (!android::base::WriteStringToFile(std::to_string(enabled), kInterpolationPath)) {
LOG(ERROR) << "Failed to write " << kInterpolationPath;
return false;
}
return true;
}

} // namespace implementation
} // namespace V1_0
} // namespace touch
} // namespace lineage
} // namespace vendor
30 changes: 30 additions & 0 deletions lineagehw/touch/HighTouchPollingRate.h
Original file line number Diff line number Diff line change
@@ -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
12 changes: 1 addition & 11 deletions lineagehw/touch/TouchscreenGesture.cpp
Original file line number Diff line number Diff line change
@@ -1,17 +1,7 @@
/*
* Copyright (C) 2022 The LineageOS Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* SPDX-License-Identifier: Apache-2.0
*/

#define LOG_TAG "TouchscreenGestureService"
Expand Down
12 changes: 1 addition & 11 deletions lineagehw/touch/TouchscreenGesture.h
Original file line number Diff line number Diff line change
@@ -1,17 +1,7 @@
/*
* Copyright (C) 2022 The LineageOS Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* SPDX-License-Identifier: Apache-2.0
*/

#pragma once
Expand Down
11 changes: 11 additions & 0 deletions lineagehw/touch/service.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,15 @@
#include <android-base/logging.h>
#include <hidl/HidlTransportSupport.h>

#include "HighTouchPollingRate.h"
#include "TouchscreenGesture.h"

using ::android::OK;
using ::android::sp;

using ::vendor::lineage::touch::V1_0::IHighTouchPollingRate;
using ::vendor::lineage::touch::V1_0::ITouchscreenGesture;
using ::vendor::lineage::touch::V1_0::implementation::HighTouchPollingRate;
using ::vendor::lineage::touch::V1_0::implementation::TouchscreenGesture;

int main() {
Expand All @@ -38,6 +41,14 @@ int main() {
}
#endif

#ifdef USE_TOUCH_POLLING_RATE
sp<IHighTouchPollingRate> hpl_service = new HighTouchPollingRate();
if (hpl_service->registerAsService() != OK) {
LOG(ERROR) << "Cannot register touchscreen high polling rate HAL service.";
return 1;
}
#endif

LOG(DEBUG) << "Touchscreen HAL service ready.";

android::hardware::joinRpcThreadpool();
Expand Down
3 changes: 3 additions & 0 deletions lineagehw/touch/[email protected]_kona.rc
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
on early-boot
chown system system /sys/class/touchscreen/primary/interpolation

service touch-hal-1-0 /vendor/bin/hw/[email protected]_kona
class hal
user system
Expand Down
4 changes: 4 additions & 0 deletions vendor_framework_compatibility_matrix.xml
Original file line number Diff line number Diff line change
Expand Up @@ -1037,6 +1037,10 @@ IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
<hal format="hidl" optional="true">
<name>vendor.lineage.touch</name>
<version>1.0</version>
<interface>
<name>IHighTouchPollingRate</name>
<instance>default</instance>
</interface>
<interface>
<name>ITouchscreenGesture</name>
<instance>default</instance>
Expand Down

0 comments on commit 0b5c476

Please sign in to comment.