From: Jan Altensen Date: Mon, 27 Jan 2020 23:06:47 +0000 (+0100) Subject: samsung: move livedisplay and touch from lineagehw to hidl folder X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=c939b63c5d110a347705ce4a59c363b697e68619;p=GitHub%2FLineageOS%2Fandroid_hardware_samsung.git samsung: move livedisplay and touch from lineagehw to hidl folder * to keep all hidl things in one place Change-Id: I91e4918191781e697b0c6c6e5cfe5dbe72ea5e59 --- diff --git a/hidl/livedisplay/.clang-format b/hidl/livedisplay/.clang-format new file mode 100644 index 0000000..ae4a451 --- /dev/null +++ b/hidl/livedisplay/.clang-format @@ -0,0 +1,11 @@ +BasedOnStyle: Google +AccessModifierOffset: -2 +AllowShortFunctionsOnASingleLine: Inline +ColumnLimit: 100 +CommentPragmas: NOLINT:.* +DerivePointerAlignment: false +IndentWidth: 4 +PointerAlignment: Left +TabWidth: 4 +UseTab: Never +PenaltyExcessCharacter: 32 diff --git a/hidl/livedisplay/AdaptiveBacklight.cpp b/hidl/livedisplay/AdaptiveBacklight.cpp new file mode 100644 index 0000000..986ab12 --- /dev/null +++ b/hidl/livedisplay/AdaptiveBacklight.cpp @@ -0,0 +1,61 @@ +/* + * Copyright (C) 2019 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. + */ + +#include +#include + +#include + +#include "AdaptiveBacklight.h" + +using android::base::ReadFileToString; +using android::base::Trim; +using android::base::WriteStringToFile; + +namespace vendor { +namespace lineage { +namespace livedisplay { +namespace V2_0 { +namespace samsung { + +static constexpr const char* kBacklightPath = "/sys/class/lcd/panel/power_reduce"; + +bool AdaptiveBacklight::isSupported() { + std::fstream backlight(kBacklightPath, backlight.in | backlight.out); + return backlight.good(); +} + +// Methods from ::vendor::lineage::livedisplay::V2_0::IAdaptiveBacklight follow. +Return AdaptiveBacklight::isEnabled() { + std::string tmp; + int32_t contents = 0; + + if (ReadFileToString(kBacklightPath, &tmp)) { + contents = std::stoi(Trim(tmp)); + } + + return contents > 0; +} + +Return AdaptiveBacklight::setEnabled(bool enabled) { + return WriteStringToFile(enabled ? "1" : "0", kBacklightPath, true); +} + +} // namespace samsung +} // namespace V2_0 +} // namespace livedisplay +} // namespace lineage +} // namespace vendor diff --git a/hidl/livedisplay/AdaptiveBacklight.h b/hidl/livedisplay/AdaptiveBacklight.h new file mode 100644 index 0000000..793f101 --- /dev/null +++ b/hidl/livedisplay/AdaptiveBacklight.h @@ -0,0 +1,55 @@ +/* + * Copyright (C) 2019 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. + */ + +#ifndef VENDOR_LINEAGE_LIVEDISPLAY_V2_0_ADAPTIVEBACKLIGHT_H +#define VENDOR_LINEAGE_LIVEDISPLAY_V2_0_ADAPTIVEBACKLIGHT_H + +#include +#include +#include + +namespace vendor { +namespace lineage { +namespace livedisplay { +namespace V2_0 { +namespace samsung { + +using ::android::hardware::hidl_array; +using ::android::hardware::hidl_memory; +using ::android::hardware::hidl_string; +using ::android::hardware::hidl_vec; +using ::android::hardware::Return; +using ::android::hardware::Void; +using ::android::sp; + +class AdaptiveBacklight : public IAdaptiveBacklight { + public: + bool isSupported(); + + // Methods from ::vendor::lineage::livedisplay::V2_0::IAdaptiveBacklight follow. + Return isEnabled() override; + Return setEnabled(bool enabled) override; + + // Methods from ::android::hidl::base::V1_0::IBase follow. +}; + +} // namespace samsung +} // namespace V2_0 +} // namespace livedisplay +} // namespace lineage +} // namespace vendor + +#endif // VENDOR_LINEAGE_LIVEDISPLAY_V2_0_ADAPTIVEBACKLIGHT_H diff --git a/hidl/livedisplay/Android.bp b/hidl/livedisplay/Android.bp new file mode 100644 index 0000000..1dc9ae8 --- /dev/null +++ b/hidl/livedisplay/Android.bp @@ -0,0 +1,85 @@ +// Copyright (C) 2019 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. + +cc_defaults { + name: "livedisplay_samsung_exynos_defaults", + defaults: ["hidl_defaults"], + relative_install_path: "hw", + srcs: [ + "AdaptiveBacklight.cpp", + "DisplayColorCalibrationExynos.cpp", + "DisplayModes.cpp", + "ReadingEnhancement.cpp", + "SunlightEnhancementExynos.cpp", + "serviceExynos.cpp", + ], + shared_libs: [ + "libbase", + "libbinder", + "libhidlbase", + "libhidltransport", + "libutils", + "vendor.lineage.livedisplay@2.0", + ], +} + +cc_defaults { + name: "livedisplay_samsung_qcom_defaults", + defaults: ["hidl_defaults"], + relative_install_path: "hw", + srcs: [ + "AdaptiveBacklight.cpp", + "DisplayColorCalibration.cpp", + "DisplayModes.cpp", + "ReadingEnhancement.cpp", + "SunlightEnhancement.cpp", + "service.cpp", + ], + shared_libs: [ + "libbase", + "libbinder", + "libhidlbase", + "libhidltransport", + "libutils", + "vendor.lineage.livedisplay@2.0", + ], +} + +cc_binary { + name: "lineage.livedisplay@2.0-service.samsung-exynos", + init_rc: ["lineage.livedisplay@2.0-service.samsung-exynos.rc"], + defaults: ["livedisplay_samsung_exynos_defaults"], + cflags: ["-DLIVES_IN_SYSTEM"], +} + +cc_binary { + name: "vendor.lineage.livedisplay@2.0-service.samsung-exynos", + init_rc: ["vendor.lineage.livedisplay@2.0-service.samsung-exynos.rc"], + defaults: ["livedisplay_samsung_exynos_defaults"], + vendor: true, +} + +cc_binary { + name: "lineage.livedisplay@2.0-service.samsung-qcom", + init_rc: ["lineage.livedisplay@2.0-service.samsung-qcom.rc"], + defaults: ["livedisplay_samsung_qcom_defaults"], + cflags: ["-DLIVES_IN_SYSTEM"], +} + +cc_binary { + name: "vendor.lineage.livedisplay@2.0-service.samsung-qcom", + init_rc: ["vendor.lineage.livedisplay@2.0-service.samsung-qcom.rc"], + defaults: ["livedisplay_samsung_qcom_defaults"], + vendor: true, +} diff --git a/hidl/livedisplay/DisplayColorCalibration.cpp b/hidl/livedisplay/DisplayColorCalibration.cpp new file mode 100644 index 0000000..be34d17 --- /dev/null +++ b/hidl/livedisplay/DisplayColorCalibration.cpp @@ -0,0 +1,79 @@ +/* + * Copyright (C) 2019 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. + */ + +#include +#include + +#include + +#include "DisplayColorCalibration.h" + +using android::base::ReadFileToString; +using android::base::Split; +using android::base::Trim; +using android::base::WriteStringToFile; + +namespace vendor { +namespace lineage { +namespace livedisplay { +namespace V2_0 { +namespace samsung { + +bool DisplayColorCalibration::isSupported() { + std::fstream rgb(FILE_RGB, rgb.in | rgb.out); + + return rgb.good(); +} + +// Methods from ::vendor::lineage::livedisplay::V2_0::IDisplayColorCalibration follow. +Return DisplayColorCalibration::getMaxValue() { + return 32768; +} + +Return DisplayColorCalibration::getMinValue() { + return 255; +} + +Return DisplayColorCalibration::getCalibration(getCalibration_cb _hidl_cb) { + std::vector rgb; + std::string tmp; + + if (ReadFileToString(FILE_RGB, &tmp)) { + std::vector colors = Split(Trim(tmp), " "); + for (const std::string& color : colors) { + rgb.push_back(std::stoi(color)); + } + } + + _hidl_cb(rgb); + return Void(); +} + +Return DisplayColorCalibration::setCalibration(const hidl_vec& rgb) { + std::string contents; + + for (const int32_t& color : rgb) { + contents += std::to_string(color) + " "; + } + + return WriteStringToFile(Trim(contents), FILE_RGB, true); +} + +} // namespace samsung +} // namespace V2_0 +} // namespace livedisplay +} // namespace lineage +} // namespace vendor diff --git a/hidl/livedisplay/DisplayColorCalibration.h b/hidl/livedisplay/DisplayColorCalibration.h new file mode 100644 index 0000000..b22f988 --- /dev/null +++ b/hidl/livedisplay/DisplayColorCalibration.h @@ -0,0 +1,51 @@ +/* + * Copyright (C) 2019 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. + */ + +#ifndef VENDOR_LINEAGE_LIVEDISPLAY_V2_0_DISPLAYCOLORCALIBRATION_H +#define VENDOR_LINEAGE_LIVEDISPLAY_V2_0_DISPLAYCOLORCALIBRATION_H + +#include + +namespace vendor { +namespace lineage { +namespace livedisplay { +namespace V2_0 { +namespace samsung { + +using ::android::hardware::hidl_vec; +using ::android::hardware::Return; +using ::android::hardware::Void; + +#define FILE_RGB "/sys/class/graphics/fb0/rgb" + +class DisplayColorCalibration : public IDisplayColorCalibration { + public: + bool isSupported(); + + // Methods from ::vendor::lineage::livedisplay::V2_0::IDisplayColorCalibration follow. + Return getMaxValue() override; + Return getMinValue() override; + Return getCalibration(getCalibration_cb _hidl_cb) override; + Return setCalibration(const hidl_vec& rgb) override; +}; + +} // namespace samsung +} // namespace V2_0 +} // namespace livedisplay +} // namespace lineage +} // namespace vendor + +#endif // VENDOR_LINEAGE_LIVEDISPLAY_V2_0_DISPLAYCOLORCALIBRATION_H diff --git a/hidl/livedisplay/DisplayColorCalibrationExynos.cpp b/hidl/livedisplay/DisplayColorCalibrationExynos.cpp new file mode 100644 index 0000000..d791ed7 --- /dev/null +++ b/hidl/livedisplay/DisplayColorCalibrationExynos.cpp @@ -0,0 +1,77 @@ +/* + * Copyright (C) 2019 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. + */ + +#include +#include + +#include + +#include "DisplayColorCalibrationExynos.h" + +using android::base::ReadFileToString; +using android::base::Split; +using android::base::Trim; +using android::base::WriteStringToFile; + +namespace vendor { +namespace lineage { +namespace livedisplay { +namespace V2_0 { +namespace samsung { + +static constexpr const char* kColorPath = "/sys/class/mdnie/mdnie/sensorRGB"; + +bool DisplayColorCalibrationExynos::isSupported() { + std::fstream rgb(kColorPath, rgb.in | rgb.out); + return rgb.good(); +} + +Return DisplayColorCalibrationExynos::getMaxValue() { + return 255; +} + +Return DisplayColorCalibrationExynos::getMinValue() { + return 1; +} + +Return DisplayColorCalibrationExynos::getCalibration(getCalibration_cb resultCb) { + std::vector rgb; + std::string tmp; + + if (ReadFileToString(kColorPath, &tmp)) { + std::vector colors = Split(Trim(tmp), " "); + for (const std::string& color : colors) { + rgb.push_back(std::stoi(color)); + } + } + + resultCb(rgb); + return Void(); +} + +Return DisplayColorCalibrationExynos::setCalibration(const hidl_vec& rgb) { + std::string contents; + for (const int32_t& color : rgb) { + contents += std::to_string(color) + " "; + } + return WriteStringToFile(Trim(contents), kColorPath, true); +} + +} // namespace samsung +} // namespace V2_0 +} // namespace livedisplay +} // namespace lineage +} // namespace vendor diff --git a/hidl/livedisplay/DisplayColorCalibrationExynos.h b/hidl/livedisplay/DisplayColorCalibrationExynos.h new file mode 100644 index 0000000..81c1827 --- /dev/null +++ b/hidl/livedisplay/DisplayColorCalibrationExynos.h @@ -0,0 +1,57 @@ +/* + * Copyright (C) 2019 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. + */ + +#ifndef VENDOR_LINEAGE_LIVEDISPLAY_V2_0_DISPLAYCOLORCALIBRATIONEXYNOS_H +#define VENDOR_LINEAGE_LIVEDISPLAY_V2_0_DISPLAYCOLORCALIBRATIONEXYNOS_H + +#include +#include +#include + +namespace vendor { +namespace lineage { +namespace livedisplay { +namespace V2_0 { +namespace samsung { + +using ::android::hardware::hidl_array; +using ::android::hardware::hidl_memory; +using ::android::hardware::hidl_string; +using ::android::hardware::hidl_vec; +using ::android::hardware::Return; +using ::android::hardware::Void; +using ::android::sp; + +class DisplayColorCalibrationExynos : public IDisplayColorCalibration { + public: + bool isSupported(); + + // Methods from ::vendor::lineage::livedisplay::V2_0::IDisplayColorCalibration follow. + Return getMaxValue() override; + Return getMinValue() override; + Return getCalibration(getCalibration_cb resultCb) override; + Return setCalibration(const hidl_vec& rgb) override; + + // Methods from ::android::hidl::base::V1_0::IBase follow. +}; + +} // namespace samsung +} // namespace V2_0 +} // namespace livedisplay +} // namespace lineage +} // namespace vendor + +#endif // VENDOR_LINEAGE_LIVEDISPLAY_V2_0_DISPLAYCOLORCALIBRATIONEXYNOS_H diff --git a/hidl/livedisplay/DisplayModes.cpp b/hidl/livedisplay/DisplayModes.cpp new file mode 100644 index 0000000..3a2b902 --- /dev/null +++ b/hidl/livedisplay/DisplayModes.cpp @@ -0,0 +1,136 @@ +/* + * Copyright (C) 2019 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. + */ + +#define LOG_TAG "DisplayModesService" + +#include "DisplayModes.h" +#include +#include + +namespace vendor { +namespace lineage { +namespace livedisplay { +namespace V2_0 { +namespace samsung { + +static constexpr const char* kModePath = "/sys/class/mdnie/mdnie/mode"; +static constexpr const char* kModeMaxPath = "/sys/class/mdnie/mdnie/mode_max"; +static constexpr const char* kDefaultPath = "/data/vendor/display/.displaymodedefault"; + +const std::map DisplayModes::kModeMap = { + // clang-format off + {0, "Dynamic"}, + {1, "Standard"}, + {2, "Natural"}, + {3, "Cinema"}, + {4, "Adaptive"}, + {5, "Reading"}, + // clang-format on +}; + +DisplayModes::DisplayModes() : mDefaultModeId(0) { + std::ifstream defaultFile(kDefaultPath); + int value; + + defaultFile >> value; + LOG(DEBUG) << "Default file read result " << value << " fail " << defaultFile.fail(); + if (defaultFile.fail()) { + return; + } + + for (const auto& entry : kModeMap) { + if (value == entry.first) { + mDefaultModeId = entry.first; + break; + } + } + + setDisplayMode(mDefaultModeId, false); +} + +bool DisplayModes::isSupported() { + std::ofstream modeFile(kModePath); + return modeFile.good(); +} + +// Methods from ::vendor::lineage::livedisplay::V2_0::IDisplayModes follow. +Return DisplayModes::getDisplayModes(getDisplayModes_cb resultCb) { + std::ifstream maxModeFile(kModeMaxPath); + int value; + std::vector modes; + if (!maxModeFile.fail()) { + maxModeFile >> value; + } else { + value = kModeMap.size(); + } + for (const auto& entry : kModeMap) { + if (entry.first < value) modes.push_back({entry.first, entry.second}); + } + resultCb(modes); + return Void(); +} + +Return DisplayModes::getCurrentDisplayMode(getCurrentDisplayMode_cb resultCb) { + int32_t currentModeId = mDefaultModeId; + std::ifstream modeFile(kModePath); + int value; + modeFile >> value; + if (!modeFile.fail()) { + for (const auto& entry : kModeMap) { + if (value == entry.first) { + currentModeId = entry.first; + break; + } + } + } + resultCb({currentModeId, kModeMap.at(currentModeId)}); + return Void(); +} + +Return DisplayModes::getDefaultDisplayMode(getDefaultDisplayMode_cb resultCb) { + resultCb({mDefaultModeId, kModeMap.at(mDefaultModeId)}); + return Void(); +} + +Return DisplayModes::setDisplayMode(int32_t modeID, bool makeDefault) { + const auto iter = kModeMap.find(modeID); + if (iter == kModeMap.end()) { + return false; + } + std::ofstream modeFile(kModePath); + modeFile << iter->first; + if (modeFile.fail()) { + return false; + } + + if (makeDefault) { + std::ofstream defaultFile(kDefaultPath); + defaultFile << iter->first; + if (defaultFile.fail()) { + return false; + } + mDefaultModeId = iter->first; + } + return true; +} + +// Methods from ::android::hidl::base::V1_0::IBase follow. + +} // namespace samsung +} // namespace V2_0 +} // namespace livedisplay +} // namespace lineage +} // namespace vendor diff --git a/hidl/livedisplay/DisplayModes.h b/hidl/livedisplay/DisplayModes.h new file mode 100644 index 0000000..149edf3 --- /dev/null +++ b/hidl/livedisplay/DisplayModes.h @@ -0,0 +1,61 @@ +/* + * Copyright (C) 2019 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. + */ + +#ifndef VENDOR_LINEAGE_LIVEDISPLAY_V2_0_DISPLAYMODES_H +#define VENDOR_LINEAGE_LIVEDISPLAY_V2_0_DISPLAYMODES_H + +#include +#include +#include + +namespace vendor { +namespace lineage { +namespace livedisplay { +namespace V2_0 { +namespace samsung { + +using ::android::hardware::hidl_array; +using ::android::hardware::hidl_memory; +using ::android::hardware::hidl_string; +using ::android::hardware::hidl_vec; +using ::android::hardware::Return; +using ::android::hardware::Void; +using ::android::sp; + +class DisplayModes : public IDisplayModes { + public: + DisplayModes(); + bool isSupported(); + + // Methods from ::vendor::lineage::livedisplay::V2_0::IDisplayModes follow. + Return getDisplayModes(getDisplayModes_cb resultCb) override; + Return getCurrentDisplayMode(getCurrentDisplayMode_cb resultCb) override; + Return getDefaultDisplayMode(getDefaultDisplayMode_cb resultCb) override; + Return setDisplayMode(int32_t modeID, bool makeDefault) override; + + // Methods from ::android::hidl::base::V1_0::IBase follow. + private: + static const std::map kModeMap; + int32_t mDefaultModeId; +}; + +} // namespace samsung +} // namespace V2_0 +} // namespace livedisplay +} // namespace lineage +} // namespace vendor + +#endif // VENDOR_LINEAGE_LIVEDISPLAY_V2_0_DISPLAYMODES_H diff --git a/hidl/livedisplay/ReadingEnhancement.cpp b/hidl/livedisplay/ReadingEnhancement.cpp new file mode 100644 index 0000000..3880c43 --- /dev/null +++ b/hidl/livedisplay/ReadingEnhancement.cpp @@ -0,0 +1,63 @@ +/* + * Copyright (C) 2019 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. + */ + +#include +#include + +#include + +#include "ReadingEnhancement.h" + +using android::base::ReadFileToString; +using android::base::Trim; +using android::base::WriteStringToFile; + +namespace vendor { +namespace lineage { +namespace livedisplay { +namespace V2_0 { +namespace samsung { + +static constexpr const char* kREPath = "/sys/class/mdnie/mdnie/accessibility"; + +// Methods from ::vendor::lineage::livedisplay::V2_0::ISunlightEnhancement follow. +bool ReadingEnhancement::isSupported() { + std::fstream re(kREPath, re.in | re.out); + return re.good(); +} + +// Methods from ::vendor::lineage::livedisplay::V2_0::IReadingEnhancement follow. +Return ReadingEnhancement::isEnabled() { + std::string contents; + + if (ReadFileToString(kREPath, &contents)) { + contents = Trim(contents); + } + + return !contents.compare("Current accessibility : DSI0 : GRAYSCALE") || !contents.compare("4"); +} + +Return ReadingEnhancement::setEnabled(bool enabled) { + return WriteStringToFile(enabled ? "4" : "0", kREPath, true); +} + +// Methods from ::android::hidl::base::V1_0::IBase follow. + +} // namespace samsung +} // namespace V2_0 +} // namespace livedisplay +} // namespace lineage +} // namespace vendor diff --git a/hidl/livedisplay/ReadingEnhancement.h b/hidl/livedisplay/ReadingEnhancement.h new file mode 100644 index 0000000..5b71669 --- /dev/null +++ b/hidl/livedisplay/ReadingEnhancement.h @@ -0,0 +1,55 @@ +/* + * Copyright (C) 2019 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. + */ + +#ifndef VENDOR_LINEAGE_LIVEDISPLAY_V2_0_READINGENHANCEMENT_H +#define VENDOR_LINEAGE_LIVEDISPLAY_V2_0_READINGENHANCEMENT_H + +#include +#include +#include + +namespace vendor { +namespace lineage { +namespace livedisplay { +namespace V2_0 { +namespace samsung { + +using ::android::hardware::hidl_array; +using ::android::hardware::hidl_memory; +using ::android::hardware::hidl_string; +using ::android::hardware::hidl_vec; +using ::android::hardware::Return; +using ::android::hardware::Void; +using ::android::sp; + +class ReadingEnhancement : public IReadingEnhancement { + public: + bool isSupported(); + + // Methods from ::vendor::lineage::livedisplay::V2_0::IReadingEnhancement follow. + Return isEnabled() override; + Return setEnabled(bool) override; + + // Methods from ::android::hidl::base::V1_0::IBase follow. +}; + +} // namespace samsung +} // namespace V2_0 +} // namespace livedisplay +} // namespace lineage +} // namespace vendor + +#endif // VENDOR_LINEAGE_LIVEDISPLAY_V2_0_READINGENHANCEMENT_H diff --git a/hidl/livedisplay/SunlightEnhancement.cpp b/hidl/livedisplay/SunlightEnhancement.cpp new file mode 100644 index 0000000..077672e --- /dev/null +++ b/hidl/livedisplay/SunlightEnhancement.cpp @@ -0,0 +1,77 @@ +/* + * Copyright (C) 2019 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. + */ + +#include +#include + +#include + +#include "SunlightEnhancement.h" + +using android::base::ReadFileToString; +using android::base::Trim; +using android::base::WriteStringToFile; + +namespace vendor { +namespace lineage { +namespace livedisplay { +namespace V2_0 { +namespace samsung { + +static constexpr const char* kHBMPath = "/sys/class/lcd/panel/panel/auto_brightness"; +static constexpr const char* kSREPath = "/sys/class/mdnie/mdnie/outdoor"; + +// Methods from ::vendor::lineage::livedisplay::V2_0::ISunlightEnhancement follow. +bool SunlightEnhancement::isSupported() { + std::fstream sre(kSREPath, sre.in | sre.out); + std::fstream hbm(kHBMPath, hbm.in | hbm.out); + + if (hbm.good()) { + mHasHBM = true; + } + + return sre.good(); +} + +// Methods from ::vendor::lineage::livedisplay::V2_0::IAdaptiveBacklight follow. +Return SunlightEnhancement::isEnabled() { + std::string tmp; + int32_t statusSRE = 0; + int32_t statusHBM = 0; + if (ReadFileToString(kSREPath, &tmp)) { + statusSRE = std::stoi(Trim(tmp)); + } + + if (mHasHBM && ReadFileToString(kHBMPath, &tmp)) { + statusHBM = std::stoi(Trim(tmp)); + } + + return ((statusSRE == 1 && statusHBM == 6) || statusSRE == 1); +} + +Return SunlightEnhancement::setEnabled(bool enabled) { + if (mHasHBM) { + WriteStringToFile(enabled ? "6" : "0", kHBMPath, true); + } + + return WriteStringToFile(enabled ? "1" : "0", kSREPath, true); +} + +} // namespace samsung +} // namespace V2_0 +} // namespace livedisplay +} // namespace lineage +} // namespace vendor diff --git a/hidl/livedisplay/SunlightEnhancement.h b/hidl/livedisplay/SunlightEnhancement.h new file mode 100644 index 0000000..44b34b9 --- /dev/null +++ b/hidl/livedisplay/SunlightEnhancement.h @@ -0,0 +1,57 @@ +/* + * Copyright (C) 2019 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. + */ + +#ifndef VENDOR_LINEAGE_LIVEDISPLAY_V2_0_SUNLIGHTENHANCEMENT_H +#define VENDOR_LINEAGE_LIVEDISPLAY_V2_0_SUNLIGHTENHANCEMENT_H + +#include +#include +#include + +namespace vendor { +namespace lineage { +namespace livedisplay { +namespace V2_0 { +namespace samsung { + +using ::android::hardware::hidl_array; +using ::android::hardware::hidl_memory; +using ::android::hardware::hidl_string; +using ::android::hardware::hidl_vec; +using ::android::hardware::Return; +using ::android::hardware::Void; +using ::android::sp; + +class SunlightEnhancement : public ISunlightEnhancement { + public: + bool isSupported(); + + // Methods from ::vendor::lineage::livedisplay::V2_0::ISunlightEnhancement follow. + Return isEnabled() override; + Return setEnabled(bool enabled) override; + + // Methods from ::android::hidl::base::V1_0::IBase follow. + private: + bool mHasHBM = false; +}; + +} // namespace samsung +} // namespace V2_0 +} // namespace livedisplay +} // namespace lineage +} // namespace vendor + +#endif // VENDOR_LINEAGE_LIVEDISPLAY_V2_0_SUNLIGHTENHANCEMENT_H diff --git a/hidl/livedisplay/SunlightEnhancementExynos.cpp b/hidl/livedisplay/SunlightEnhancementExynos.cpp new file mode 100644 index 0000000..950342a --- /dev/null +++ b/hidl/livedisplay/SunlightEnhancementExynos.cpp @@ -0,0 +1,63 @@ +/* + * Copyright (C) 2019 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. + */ + +#include +#include + +#include + +#include "SunlightEnhancementExynos.h" + +using android::base::ReadFileToString; +using android::base::Trim; +using android::base::WriteStringToFile; + +namespace vendor { +namespace lineage { +namespace livedisplay { +namespace V2_0 { +namespace samsung { + +static constexpr const char* kLUXPath = "/sys/class/mdnie/mdnie/lux"; + +// Methods from ::vendor::lineage::livedisplay::V2_0::ISunlightEnhancement follow. +bool SunlightEnhancementExynos::isSupported() { + std::fstream file(kLUXPath, file.in | file.out); + return file.good(); +} + +// Methods from ::vendor::lineage::livedisplay::V2_0::IAdaptiveBacklight follow. +Return SunlightEnhancementExynos::isEnabled() { + std::string tmp; + int32_t contents = 0; + + if (ReadFileToString(kLUXPath, &tmp)) { + contents = std::stoi(Trim(tmp)); + } + + return contents > 0; +} + +Return SunlightEnhancementExynos::setEnabled(bool enabled) { + /* see drivers/video/fbdev/exynos/decon_7880/panels/mdnie_lite_table*, get_hbm_index */ + return WriteStringToFile(enabled ? "40000" : "0", kLUXPath, true); +} + +} // namespace samsung +} // namespace V2_0 +} // namespace livedisplay +} // namespace lineage +} // namespace vendor diff --git a/hidl/livedisplay/SunlightEnhancementExynos.h b/hidl/livedisplay/SunlightEnhancementExynos.h new file mode 100644 index 0000000..4b34861 --- /dev/null +++ b/hidl/livedisplay/SunlightEnhancementExynos.h @@ -0,0 +1,55 @@ +/* + * Copyright (C) 2019 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. + */ + +#ifndef VENDOR_LINEAGE_LIVEDISPLAY_V2_0_SUNLIGHTENHANCEMENTEXYNOS_H +#define VENDOR_LINEAGE_LIVEDISPLAY_V2_0_SUNLIGHTENHANCEMENTEXYNOS_H + +#include +#include +#include + +namespace vendor { +namespace lineage { +namespace livedisplay { +namespace V2_0 { +namespace samsung { + +using ::android::hardware::hidl_array; +using ::android::hardware::hidl_memory; +using ::android::hardware::hidl_string; +using ::android::hardware::hidl_vec; +using ::android::hardware::Return; +using ::android::hardware::Void; +using ::android::sp; + +class SunlightEnhancementExynos : public ISunlightEnhancement { + public: + bool isSupported(); + + // Methods from ::vendor::lineage::livedisplay::V2_0::ISunlightEnhancement follow. + Return isEnabled() override; + Return setEnabled(bool enabled) override; + + // Methods from ::android::hidl::base::V1_0::IBase follow. +}; + +} // namespace samsung +} // namespace V2_0 +} // namespace livedisplay +} // namespace lineage +} // namespace vendor + +#endif // VENDOR_LINEAGE_LIVEDISPLAY_V2_0_SUNLIGHTENHANCEMENTEXYNOS_H diff --git a/hidl/livedisplay/lineage.livedisplay@2.0-service.samsung-exynos.rc b/hidl/livedisplay/lineage.livedisplay@2.0-service.samsung-exynos.rc new file mode 100644 index 0000000..3fd15b5 --- /dev/null +++ b/hidl/livedisplay/lineage.livedisplay@2.0-service.samsung-exynos.rc @@ -0,0 +1,7 @@ +on post-fs-data + mkdir /data/vendor/display 0770 system system + +service livedisplay-hal-2-0-samsung-exynos /system/bin/hw/lineage.livedisplay@2.0-service.samsung-exynos + class hal + user system + group system \ No newline at end of file diff --git a/hidl/livedisplay/lineage.livedisplay@2.0-service.samsung-qcom.rc b/hidl/livedisplay/lineage.livedisplay@2.0-service.samsung-qcom.rc new file mode 100644 index 0000000..48ebd94 --- /dev/null +++ b/hidl/livedisplay/lineage.livedisplay@2.0-service.samsung-qcom.rc @@ -0,0 +1,7 @@ +on post-fs-data + mkdir /data/vendor/display 0770 system system + +service livedisplay-hal-2-0-samsung-qcom /system/bin/hw/lineage.livedisplay@2.0-service.samsung-qcom + class late_start + user system + group system diff --git a/hidl/livedisplay/service.cpp b/hidl/livedisplay/service.cpp new file mode 100644 index 0000000..1e97aee --- /dev/null +++ b/hidl/livedisplay/service.cpp @@ -0,0 +1,147 @@ +/* + * Copyright (C) 2019 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. + */ + +#ifdef LIVES_IN_SYSTEM +#define LOG_TAG "lineage.livedisplay@2.0-service.samsung-qcom" +#else +#define LOG_TAG "vendor.lineage.livedisplay@2.0-service.samsung-qcom" +#endif + +#include +#include +#include + +#include "AdaptiveBacklight.h" +#include "DisplayColorCalibration.h" +#include "DisplayModes.h" +#include "ReadingEnhancement.h" +#include "SunlightEnhancement.h" + +using android::hardware::configureRpcThreadpool; +using android::hardware::joinRpcThreadpool; +using android::sp; +using android::status_t; +using android::OK; + +using vendor::lineage::livedisplay::V2_0::samsung::AdaptiveBacklight; +using vendor::lineage::livedisplay::V2_0::samsung::DisplayColorCalibration; +using vendor::lineage::livedisplay::V2_0::samsung::DisplayModes; +using vendor::lineage::livedisplay::V2_0::samsung::ReadingEnhancement; +using vendor::lineage::livedisplay::V2_0::samsung::SunlightEnhancement; + +int main() { + sp adaptiveBacklight; + sp displayColorCalibration; + sp displayModes; + sp readingEnhancement; + sp sunlightEnhancement; + status_t status; + + LOG(INFO) << "LiveDisplay HAL service is starting."; + + adaptiveBacklight = new AdaptiveBacklight(); + if (adaptiveBacklight == nullptr) { + LOG(ERROR) + << "Can not create an instance of LiveDisplay HAL AdaptiveBacklight Iface, exiting."; + goto shutdown; + } + + displayColorCalibration = new DisplayColorCalibration(); + if (displayColorCalibration == nullptr) { + LOG(ERROR) << "Can not create an instance of LiveDisplay HAL DisplayColorCalibration " + "Iface, exiting."; + goto shutdown; + } + + displayModes = new DisplayModes(); + if (displayModes == nullptr) { + LOG(ERROR) << "Can not create an instance of LiveDisplay HAL DisplayModes Iface, exiting."; + goto shutdown; + } + + readingEnhancement = new ReadingEnhancement(); + if (readingEnhancement == nullptr) { + LOG(ERROR) + << "Can not create an instance of LiveDisplay HAL ReadingEnhancement Iface, exiting."; + goto shutdown; + } + + sunlightEnhancement = new SunlightEnhancement(); + if (sunlightEnhancement == nullptr) { + LOG(ERROR) + << "Can not create an instance of LiveDisplay HAL SunlightEnhancement Iface, exiting."; + goto shutdown; + } + + configureRpcThreadpool(1, true /*callerWillJoin*/); + + if (adaptiveBacklight->isSupported()) { + status = adaptiveBacklight->registerAsService(); + if (status != OK) { + LOG(ERROR) << "Could not register service for LiveDisplay HAL AdaptiveBacklight Iface (" + << status << ")"; + goto shutdown; + } + } + + if (displayColorCalibration->isSupported()) { + status = displayColorCalibration->registerAsService(); + if (status != OK) { + LOG(ERROR) + << "Could not register service for LiveDisplay HAL DisplayColorCalibration Iface (" + << status << ")"; + goto shutdown; + } + } + + if (displayModes->isSupported()) { + status = displayModes->registerAsService(); + if (status != OK) { + LOG(ERROR) << "Could not register service for LiveDisplay HAL DisplayModes Iface (" + << status << ")"; + goto shutdown; + } + } + + if (readingEnhancement->isSupported()) { + status = readingEnhancement->registerAsService(); + if (status != OK) { + LOG(ERROR) + << "Could not register service for LiveDisplay HAL ReadingEnhancement Iface (" + << status << ")"; + goto shutdown; + } + } + + if (sunlightEnhancement->isSupported()) { + status = sunlightEnhancement->registerAsService(); + if (status != OK) { + LOG(ERROR) + << "Could not register service for LiveDisplay HAL SunlightEnhancement Iface (" + << status << ")"; + goto shutdown; + } + } + + LOG(INFO) << "LiveDisplay HAL service is ready."; + joinRpcThreadpool(); +// Should not pass this line + +shutdown: + // In normal operation, we don't expect the thread pool to shutdown + LOG(ERROR) << "LiveDisplay HAL service is shutting down."; + return 1; +} diff --git a/hidl/livedisplay/serviceExynos.cpp b/hidl/livedisplay/serviceExynos.cpp new file mode 100644 index 0000000..c7395b8 --- /dev/null +++ b/hidl/livedisplay/serviceExynos.cpp @@ -0,0 +1,147 @@ +/* + * Copyright (C) 2019 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. + */ + +#ifdef LIVES_IN_SYSTEM +#define LOG_TAG "lineage.livedisplay@2.0-service.samsung-exynos" +#else +#define LOG_TAG "vendor.lineage.livedisplay@2.0-service.samsung-exynos" +#endif + +#include +#include +#include + +#include "AdaptiveBacklight.h" +#include "DisplayColorCalibrationExynos.h" +#include "DisplayModes.h" +#include "ReadingEnhancement.h" +#include "SunlightEnhancementExynos.h" + +using android::hardware::configureRpcThreadpool; +using android::hardware::joinRpcThreadpool; +using android::sp; +using android::status_t; +using android::OK; + +using vendor::lineage::livedisplay::V2_0::samsung::AdaptiveBacklight; +using vendor::lineage::livedisplay::V2_0::samsung::DisplayColorCalibrationExynos; +using vendor::lineage::livedisplay::V2_0::samsung::DisplayModes; +using vendor::lineage::livedisplay::V2_0::samsung::ReadingEnhancement; +using vendor::lineage::livedisplay::V2_0::samsung::SunlightEnhancementExynos; + +int main() { + sp adaptiveBacklight; + sp displayColorCalibrationExynos; + sp displayModes; + sp readingEnhancement; + sp sunlightEnhancementExynos; + status_t status; + + LOG(INFO) << "LiveDisplay HAL service is starting."; + + adaptiveBacklight = new AdaptiveBacklight(); + if (adaptiveBacklight == nullptr) { + LOG(ERROR) + << "Can not create an instance of LiveDisplay HAL AdaptiveBacklight Iface, exiting."; + goto shutdown; + } + + displayColorCalibrationExynos = new DisplayColorCalibrationExynos(); + if (displayColorCalibrationExynos == nullptr) { + LOG(ERROR) << "Can not create an instance of LiveDisplay HAL DisplayColorCalibration " + "Iface, exiting."; + goto shutdown; + } + + displayModes = new DisplayModes(); + if (displayModes == nullptr) { + LOG(ERROR) << "Can not create an instance of LiveDisplay HAL DisplayModes Iface, exiting."; + goto shutdown; + } + + readingEnhancement = new ReadingEnhancement(); + if (readingEnhancement == nullptr) { + LOG(ERROR) + << "Can not create an instance of LiveDisplay HAL ReadingEnhancement Iface, exiting."; + goto shutdown; + } + + sunlightEnhancementExynos = new SunlightEnhancementExynos(); + if (sunlightEnhancementExynos == nullptr) { + LOG(ERROR) + << "Can not create an instance of LiveDisplay HAL SunlightEnhancement Iface, exiting."; + goto shutdown; + } + + configureRpcThreadpool(1, true /*callerWillJoin*/); + + if (adaptiveBacklight->isSupported()) { + status = adaptiveBacklight->registerAsService(); + if (status != OK) { + LOG(ERROR) << "Could not register service for LiveDisplay HAL AdaptiveBacklight Iface (" + << status << ")"; + goto shutdown; + } + } + + if (displayColorCalibrationExynos->isSupported()) { + status = displayColorCalibrationExynos->registerAsService(); + if (status != OK) { + LOG(ERROR) + << "Could not register service for LiveDisplay HAL DisplayColorCalibration Iface (" + << status << ")"; + goto shutdown; + } + } + + if (displayModes->isSupported()) { + status = displayModes->registerAsService(); + if (status != OK) { + LOG(ERROR) << "Could not register service for LiveDisplay HAL DisplayModes Iface (" + << status << ")"; + goto shutdown; + } + } + + if (readingEnhancement->isSupported()) { + status = readingEnhancement->registerAsService(); + if (status != OK) { + LOG(ERROR) + << "Could not register service for LiveDisplay HAL ReadingEnhancement Iface (" + << status << ")"; + goto shutdown; + } + } + + if (sunlightEnhancementExynos->isSupported()) { + status = sunlightEnhancementExynos->registerAsService(); + if (status != OK) { + LOG(ERROR) + << "Could not register service for LiveDisplay HAL SunlightEnhancement Iface (" + << status << ")"; + goto shutdown; + } + } + + LOG(INFO) << "LiveDisplay HAL service is ready."; + joinRpcThreadpool(); +// Should not pass this line + +shutdown: + // In normal operation, we don't expect the thread pool to shutdown + LOG(ERROR) << "LiveDisplay HAL service is shutting down."; + return 1; +} diff --git a/hidl/livedisplay/vendor.lineage.livedisplay@2.0-service.samsung-exynos.rc b/hidl/livedisplay/vendor.lineage.livedisplay@2.0-service.samsung-exynos.rc new file mode 100644 index 0000000..2faab1b --- /dev/null +++ b/hidl/livedisplay/vendor.lineage.livedisplay@2.0-service.samsung-exynos.rc @@ -0,0 +1,7 @@ +on post-fs-data + mkdir /data/vendor/display 0770 system system + +service vendor.livedisplay-hal-2-0-samsung-exynos /vendor/bin/hw/vendor.lineage.livedisplay@2.0-service.samsung-exynos + class hal + user system + group system \ No newline at end of file diff --git a/hidl/livedisplay/vendor.lineage.livedisplay@2.0-service.samsung-qcom.rc b/hidl/livedisplay/vendor.lineage.livedisplay@2.0-service.samsung-qcom.rc new file mode 100644 index 0000000..8698601 --- /dev/null +++ b/hidl/livedisplay/vendor.lineage.livedisplay@2.0-service.samsung-qcom.rc @@ -0,0 +1,7 @@ +on post-fs-data + mkdir /data/vendor/display 0770 system system + +service vendor.livedisplay-hal-2-0-samsung-qcom /vendor/bin/hw/vendor.lineage.livedisplay@2.0-service.samsung-qcom + class late_start + user system + group system diff --git a/hidl/touch/.clang-format b/hidl/touch/.clang-format new file mode 100644 index 0000000..ae4a451 --- /dev/null +++ b/hidl/touch/.clang-format @@ -0,0 +1,11 @@ +BasedOnStyle: Google +AccessModifierOffset: -2 +AllowShortFunctionsOnASingleLine: Inline +ColumnLimit: 100 +CommentPragmas: NOLINT:.* +DerivePointerAlignment: false +IndentWidth: 4 +PointerAlignment: Left +TabWidth: 4 +UseTab: Never +PenaltyExcessCharacter: 32 diff --git a/hidl/touch/Android.bp b/hidl/touch/Android.bp new file mode 100644 index 0000000..0197b6c --- /dev/null +++ b/hidl/touch/Android.bp @@ -0,0 +1,38 @@ +// Copyright (C) 2019 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. + +cc_binary { + name: "vendor.lineage.touch@1.0-service.samsung", + init_rc: ["vendor.lineage.touch@1.0-service.samsung.rc"], + defaults: ["hidl_defaults"], + relative_install_path: "hw", + // FIXME: this should be 'vendor: true' for modules that will eventually be + // on AOSP. + proprietary: true, + srcs: [ + "GloveMode.cpp", + "KeyDisabler.cpp", + "StylusMode.cpp", + "TouchscreenGesture.cpp", + "service.cpp" + ], + shared_libs: [ + "libbase", + "libbinder", + "libhidlbase", + "libhidltransport", + "libutils", + "vendor.lineage.touch@1.0", + ], +} diff --git a/hidl/touch/GloveMode.cpp b/hidl/touch/GloveMode.cpp new file mode 100644 index 0000000..f059b61 --- /dev/null +++ b/hidl/touch/GloveMode.cpp @@ -0,0 +1,61 @@ +/* + * Copyright (C) 2019 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. + */ + +#include + +#include "GloveMode.h" + +namespace vendor { +namespace lineage { +namespace touch { +namespace V1_0 { +namespace samsung { + +bool GloveMode::isSupported() { + std::ifstream file("/sys/class/sec/tsp/cmd_list"); + if (file.is_open()) { + std::string line; + while (getline(file, line)) { + if (!line.compare("glove_mode")) return true; + } + file.close(); + } + return false; +} + +// Methods from ::vendor::lineage::touch::V1_0::IGloveMode follow. +Return GloveMode::isEnabled() { + std::ifstream file("/sys/class/sec/tsp/cmd_result"); + if (file.is_open()) { + std::string line; + getline(file, line); + if (!line.compare("glove_mode,1:OK")) return true; + file.close(); + } + return false; +} + +Return GloveMode::setEnabled(bool enabled) { + std::ofstream file("/sys/class/sec/tsp/cmd"); + file << "glove_mode," << (enabled ? "1" : "0"); + return true; +} + +} // namespace samsung +} // namespace V1_0 +} // namespace touch +} // namespace lineage +} // namespace vendor diff --git a/hidl/touch/GloveMode.h b/hidl/touch/GloveMode.h new file mode 100644 index 0000000..25489bc --- /dev/null +++ b/hidl/touch/GloveMode.h @@ -0,0 +1,57 @@ +/* + * Copyright (C) 2019 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. + */ + +#ifndef VENDOR_LINEAGE_TOUCH_V1_0_GLOVEMODE_H +#define VENDOR_LINEAGE_TOUCH_V1_0_GLOVEMODE_H + +#include +#include +#include + +namespace vendor { +namespace lineage { +namespace touch { +namespace V1_0 { +namespace samsung { + +using ::android::hardware::hidl_array; +using ::android::hardware::hidl_memory; +using ::android::hardware::hidl_string; +using ::android::hardware::hidl_vec; +using ::android::hardware::Return; +using ::android::hardware::Void; +using ::android::sp; + +class GloveMode : public IGloveMode { + public: + GloveMode() = default; + + bool isSupported(); + + // Methods from ::vendor::lineage::touch::V1_0::IGloveMode follow. + Return isEnabled() override; + Return setEnabled(bool enabled) override; + + // Methods from ::android::hidl::base::V1_0::IBase follow. +}; + +} // namespace samsung +} // namespace V1_0 +} // namespace touch +} // namespace lineage +} // namespace vendor + +#endif // VENDOR_LINEAGE_TOUCH_V1_0_GLOVEMODE_H diff --git a/hidl/touch/KeyDisabler.cpp b/hidl/touch/KeyDisabler.cpp new file mode 100644 index 0000000..54691a0 --- /dev/null +++ b/hidl/touch/KeyDisabler.cpp @@ -0,0 +1,54 @@ +/* + * Copyright (C) 2019 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. + */ + +#include + +#include "KeyDisabler.h" + +namespace vendor { +namespace lineage { +namespace touch { +namespace V1_0 { +namespace samsung { + +bool KeyDisabler::isSupported() { + std::ofstream file("/sys/class/sec/sec_touchkey/input/enabled"); + return file.good(); +} + +// Methods from ::vendor::lineage::touch::V1_0::IKeyDisabler follow. +Return KeyDisabler::isEnabled() { + std::ifstream file("/sys/class/sec/sec_touchkey/input/enabled"); + int status = -1; + + if (file.is_open()) { + file >> status; + } + + return file.good() && status == 0; +} + +Return KeyDisabler::setEnabled(bool enabled) { + std::ofstream file("/sys/class/sec/sec_touchkey/input/enabled"); + file << (enabled ? "0" : "1"); + return true; +} + +} // namespace samsung +} // namespace V1_0 +} // namespace touch +} // namespace lineage +} // namespace vendor diff --git a/hidl/touch/KeyDisabler.h b/hidl/touch/KeyDisabler.h new file mode 100644 index 0000000..9cab414 --- /dev/null +++ b/hidl/touch/KeyDisabler.h @@ -0,0 +1,57 @@ +/* + * Copyright (C) 2019 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. + */ + +#ifndef VENDOR_LINEAGE_TOUCH_V1_0_KEYDISABLER_H +#define VENDOR_LINEAGE_TOUCH_V1_0_KEYDISABLER_H + +#include +#include +#include + +namespace vendor { +namespace lineage { +namespace touch { +namespace V1_0 { +namespace samsung { + +using ::android::hardware::hidl_array; +using ::android::hardware::hidl_memory; +using ::android::hardware::hidl_string; +using ::android::hardware::hidl_vec; +using ::android::hardware::Return; +using ::android::hardware::Void; +using ::android::sp; + +class KeyDisabler : public IKeyDisabler { + public: + KeyDisabler() = default; + + bool isSupported(); + + // Methods from ::vendor::lineage::touch::V1_0::IKeyDisabler follow. + Return isEnabled() override; + Return setEnabled(bool enabled) override; + + // Methods from ::android::hidl::base::V1_0::IBase follow. +}; + +} // namespace samsung +} // namespace V1_0 +} // namespace touch +} // namespace lineage +} // namespace vendor + +#endif // VENDOR_LINEAGE_TOUCH_V1_0_KEYDISABLER_H diff --git a/hidl/touch/StylusMode.cpp b/hidl/touch/StylusMode.cpp new file mode 100644 index 0000000..e3190db --- /dev/null +++ b/hidl/touch/StylusMode.cpp @@ -0,0 +1,61 @@ +/* + * Copyright (C) 2019 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. + */ + +#include + +#include "StylusMode.h" + +namespace vendor { +namespace lineage { +namespace touch { +namespace V1_0 { +namespace samsung { + +bool StylusMode::isSupported() { + std::ifstream file("/sys/class/sec/tsp/cmd_list"); + if (file.is_open()) { + std::string line; + while (getline(file, line)) { + if (!line.compare("hover_enable")) return true; + } + file.close(); + } + return false; +} + +// Methods from ::vendor::lineage::touch::V1_0::IStylusMode follow. +Return StylusMode::isEnabled() { + std::ifstream file("/sys/class/sec/tsp/cmd_result"); + if (file.is_open()) { + std::string line; + getline(file, line); + if (!line.compare("hover_enable,1:OK")) return true; + file.close(); + } + return false; +} + +Return StylusMode::setEnabled(bool enabled) { + std::ofstream file("/sys/class/sec/tsp/cmd"); + file << "hover_enable," << (enabled ? "1" : "0"); + return true; +} + +} // namespace samsung +} // namespace V1_0 +} // namespace touch +} // namespace lineage +} // namespace vendor diff --git a/hidl/touch/StylusMode.h b/hidl/touch/StylusMode.h new file mode 100644 index 0000000..6226ca5 --- /dev/null +++ b/hidl/touch/StylusMode.h @@ -0,0 +1,57 @@ +/* + * Copyright (C) 2019 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. + */ + +#ifndef VENDOR_LINEAGE_TOUCH_V1_0_STYLUSMODE_H +#define VENDOR_LINEAGE_TOUCH_V1_0_STYLUSMODE_H + +#include +#include +#include + +namespace vendor { +namespace lineage { +namespace touch { +namespace V1_0 { +namespace samsung { + +using ::android::hardware::hidl_array; +using ::android::hardware::hidl_memory; +using ::android::hardware::hidl_string; +using ::android::hardware::hidl_vec; +using ::android::hardware::Return; +using ::android::hardware::Void; +using ::android::sp; + +class StylusMode : public IStylusMode { + public: + StylusMode() = default; + + bool isSupported(); + + // Methods from ::vendor::lineage::touch::V1_0::IStylusMode follow. + Return isEnabled() override; + Return setEnabled(bool enabled) override; + + // Methods from ::android::hidl::base::V1_0::IBase follow. +}; + +} // namespace samsung +} // namespace V1_0 +} // namespace touch +} // namespace lineage +} // namespace vendor + +#endif // VENDOR_LINEAGE_TOUCH_V1_0_STYLUSMODE_H diff --git a/hidl/touch/TouchscreenGesture.cpp b/hidl/touch/TouchscreenGesture.cpp new file mode 100644 index 0000000..c0091a6 --- /dev/null +++ b/hidl/touch/TouchscreenGesture.cpp @@ -0,0 +1,80 @@ +/* + * Copyright (C) 2019 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. + */ + +#include + +#include "TouchscreenGesture.h" + +namespace vendor { +namespace lineage { +namespace touch { +namespace V1_0 { +namespace samsung { + +static constexpr const char* kGeasturePath = "/sys/class/sec/sec_epen/epen_gestures"; + +const std::map TouchscreenGesture::kGestureInfoMap = { + // clang-format off + {0, {0x2f1, "Swipe up stylus"}}, + {1, {0x2f2, "Swipe down stylus"}}, + {2, {0x2f3, "Swipe left stylus"}}, + {3, {0x2f4, "Swipe right stylus"}}, + {4, {0x2f5, "Long press stylus"}}, + // clang-format on +}; + +bool TouchscreenGesture::isSupported() { + std::ifstream file(kGeasturePath); + return file.good(); +} + +// Methods from ::vendor::lineage::touch::V1_0::ITouchscreenGesture follow. +Return TouchscreenGesture::getSupportedGestures(getSupportedGestures_cb resultCb) { + std::vector gestures; + + for (const auto& entry : kGestureInfoMap) { + gestures.push_back({entry.first, entry.second.name, entry.second.keycode}); + } + resultCb(gestures); + + return Void(); +} + +Return TouchscreenGesture::setGestureEnabled( + const ::vendor::lineage::touch::V1_0::Gesture& gesture, bool enabled) { + std::fstream file(kGeasturePath); + int gestureMode; + int mask = 1 << gesture.id; + + file >> gestureMode; + + if (enabled) + gestureMode |= mask; + else + gestureMode &= ~mask; + + file << gestureMode; + + return !file.fail(); +} + +// Methods from ::android::hidl::base::V1_0::IBase follow. + +} // namespace samsung +} // namespace V1_0 +} // namespace touch +} // namespace lineage +} // namespace vendor diff --git a/hidl/touch/TouchscreenGesture.h b/hidl/touch/TouchscreenGesture.h new file mode 100644 index 0000000..35517f1 --- /dev/null +++ b/hidl/touch/TouchscreenGesture.h @@ -0,0 +1,64 @@ +/* + * Copyright (C) 2019 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. + */ + +#ifndef VENDOR_LINEAGE_TOUCH_V1_0_TOUCHSCREENGESTURE_H +#define VENDOR_LINEAGE_TOUCH_V1_0_TOUCHSCREENGESTURE_H + +#include +#include +#include + +namespace vendor { +namespace lineage { +namespace touch { +namespace V1_0 { +namespace samsung { + +using ::android::hardware::hidl_array; +using ::android::hardware::hidl_memory; +using ::android::hardware::hidl_string; +using ::android::hardware::hidl_vec; +using ::android::hardware::Return; +using ::android::hardware::Void; +using ::android::sp; + +class TouchscreenGesture : public ITouchscreenGesture { + public: + bool isSupported(); + + // Methods from ::vendor::lineage::touch::V1_0::ITouchscreenGesture follow. + Return getSupportedGestures(getSupportedGestures_cb resultCb) override; + Return setGestureEnabled(const ::vendor::lineage::touch::V1_0::Gesture& gesture, + bool enabled) override; + + private: + typedef struct { + int32_t keycode; + const char* name; + } GestureInfo; + static const std::map kGestureInfoMap; // id -> info +}; + +// FIXME: most likely delete, this is only for passthrough implementations +// extern "C" ITouchscreenGesture* HIDL_FETCH_ITouchscreenGesture(const char* name); + +} // namespace samsung +} // namespace V1_0 +} // namespace touch +} // namespace lineage +} // namespace vendor + +#endif // VENDOR_LINEAGE_TOUCH_V1_0_TOUCHSCREENGESTURE_H diff --git a/hidl/touch/service.cpp b/hidl/touch/service.cpp new file mode 100644 index 0000000..e12326c --- /dev/null +++ b/hidl/touch/service.cpp @@ -0,0 +1,118 @@ +/* + * Copyright (C) 2019 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. + */ + +#define LOG_TAG "vendor.lineage.touch@1.0-service.samsung" + +#include +#include +#include + +#include "GloveMode.h" +#include "KeyDisabler.h" +#include "StylusMode.h" +#include "TouchscreenGesture.h" + +using android::hardware::configureRpcThreadpool; +using android::hardware::joinRpcThreadpool; +using android::sp; +using android::status_t; +using android::OK; + +using ::vendor::lineage::touch::V1_0::samsung::GloveMode; +using ::vendor::lineage::touch::V1_0::samsung::KeyDisabler; +using ::vendor::lineage::touch::V1_0::samsung::StylusMode; +using ::vendor::lineage::touch::V1_0::samsung::TouchscreenGesture; + +int main() { + sp gloveMode; + sp keyDisabler; + sp stylusMode; + sp touchscreenGesture; + status_t status; + + LOG(INFO) << "Touch HAL service is starting."; + + gloveMode = new GloveMode(); + if (gloveMode == nullptr) { + LOG(ERROR) << "Can not create an instance of Touch HAL GloveMode Iface, exiting."; + goto shutdown; + } + + keyDisabler = new KeyDisabler(); + if (keyDisabler == nullptr) { + LOG(ERROR) << "Can not create an instance of Touch HAL KeyDisabler Iface, exiting."; + goto shutdown; + } + + stylusMode = new StylusMode(); + if (stylusMode == nullptr) { + LOG(ERROR) << "Can not create an instance of Touch HAL StylusMode Iface, exiting."; + goto shutdown; + } + + touchscreenGesture = new TouchscreenGesture(); + if (touchscreenGesture == nullptr) { + LOG(ERROR) << "Can not create an instance of Touch HAL TouchscreenGesture Iface, exiting."; + goto shutdown; + } + + configureRpcThreadpool(1, true /*callerWillJoin*/); + + if (gloveMode->isSupported()) { + status = gloveMode->registerAsService(); + if (status != OK) { + LOG(ERROR) << "Could not register service for Touch HAL GloveMode Iface (" << status + << ")"; + goto shutdown; + } + } + + if (keyDisabler->isSupported()) { + status = keyDisabler->registerAsService(); + if (status != OK) { + LOG(ERROR) << "Could not register service for Touch HAL KeyDisabler Iface (" << status + << ")"; + goto shutdown; + } + } + + if (stylusMode->isSupported()) { + status = stylusMode->registerAsService(); + if (status != OK) { + LOG(ERROR) << "Could not register service for Touch HAL StylusMode Iface (" << status + << ")"; + goto shutdown; + } + } + + if (touchscreenGesture->isSupported()) { + status = touchscreenGesture->registerAsService(); + if (status != OK) { + LOG(ERROR) << "Could not register service for Touch HAL TouchscreenGesture Iface (" + << status << ")"; + goto shutdown; + } + } + + LOG(INFO) << "Touch HAL service is ready."; + joinRpcThreadpool(); +// Should not pass this line + +shutdown: + // In normal operation, we don't expect the thread pool to shutdown + LOG(ERROR) << "Touch HAL service is shutting down."; + return 1; +} diff --git a/hidl/touch/vendor.lineage.touch@1.0-service.samsung.rc b/hidl/touch/vendor.lineage.touch@1.0-service.samsung.rc new file mode 100644 index 0000000..2f0d14f --- /dev/null +++ b/hidl/touch/vendor.lineage.touch@1.0-service.samsung.rc @@ -0,0 +1,4 @@ +service vendor.touch-hal-1-0-samsung /vendor/bin/hw/vendor.lineage.touch@1.0-service.samsung + class hal + user system + group system diff --git a/lineagehw/hidl/livedisplay/.clang-format b/lineagehw/hidl/livedisplay/.clang-format deleted file mode 100644 index ae4a451..0000000 --- a/lineagehw/hidl/livedisplay/.clang-format +++ /dev/null @@ -1,11 +0,0 @@ -BasedOnStyle: Google -AccessModifierOffset: -2 -AllowShortFunctionsOnASingleLine: Inline -ColumnLimit: 100 -CommentPragmas: NOLINT:.* -DerivePointerAlignment: false -IndentWidth: 4 -PointerAlignment: Left -TabWidth: 4 -UseTab: Never -PenaltyExcessCharacter: 32 diff --git a/lineagehw/hidl/livedisplay/AdaptiveBacklight.cpp b/lineagehw/hidl/livedisplay/AdaptiveBacklight.cpp deleted file mode 100644 index 986ab12..0000000 --- a/lineagehw/hidl/livedisplay/AdaptiveBacklight.cpp +++ /dev/null @@ -1,61 +0,0 @@ -/* - * Copyright (C) 2019 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. - */ - -#include -#include - -#include - -#include "AdaptiveBacklight.h" - -using android::base::ReadFileToString; -using android::base::Trim; -using android::base::WriteStringToFile; - -namespace vendor { -namespace lineage { -namespace livedisplay { -namespace V2_0 { -namespace samsung { - -static constexpr const char* kBacklightPath = "/sys/class/lcd/panel/power_reduce"; - -bool AdaptiveBacklight::isSupported() { - std::fstream backlight(kBacklightPath, backlight.in | backlight.out); - return backlight.good(); -} - -// Methods from ::vendor::lineage::livedisplay::V2_0::IAdaptiveBacklight follow. -Return AdaptiveBacklight::isEnabled() { - std::string tmp; - int32_t contents = 0; - - if (ReadFileToString(kBacklightPath, &tmp)) { - contents = std::stoi(Trim(tmp)); - } - - return contents > 0; -} - -Return AdaptiveBacklight::setEnabled(bool enabled) { - return WriteStringToFile(enabled ? "1" : "0", kBacklightPath, true); -} - -} // namespace samsung -} // namespace V2_0 -} // namespace livedisplay -} // namespace lineage -} // namespace vendor diff --git a/lineagehw/hidl/livedisplay/AdaptiveBacklight.h b/lineagehw/hidl/livedisplay/AdaptiveBacklight.h deleted file mode 100644 index 793f101..0000000 --- a/lineagehw/hidl/livedisplay/AdaptiveBacklight.h +++ /dev/null @@ -1,55 +0,0 @@ -/* - * Copyright (C) 2019 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. - */ - -#ifndef VENDOR_LINEAGE_LIVEDISPLAY_V2_0_ADAPTIVEBACKLIGHT_H -#define VENDOR_LINEAGE_LIVEDISPLAY_V2_0_ADAPTIVEBACKLIGHT_H - -#include -#include -#include - -namespace vendor { -namespace lineage { -namespace livedisplay { -namespace V2_0 { -namespace samsung { - -using ::android::hardware::hidl_array; -using ::android::hardware::hidl_memory; -using ::android::hardware::hidl_string; -using ::android::hardware::hidl_vec; -using ::android::hardware::Return; -using ::android::hardware::Void; -using ::android::sp; - -class AdaptiveBacklight : public IAdaptiveBacklight { - public: - bool isSupported(); - - // Methods from ::vendor::lineage::livedisplay::V2_0::IAdaptiveBacklight follow. - Return isEnabled() override; - Return setEnabled(bool enabled) override; - - // Methods from ::android::hidl::base::V1_0::IBase follow. -}; - -} // namespace samsung -} // namespace V2_0 -} // namespace livedisplay -} // namespace lineage -} // namespace vendor - -#endif // VENDOR_LINEAGE_LIVEDISPLAY_V2_0_ADAPTIVEBACKLIGHT_H diff --git a/lineagehw/hidl/livedisplay/Android.bp b/lineagehw/hidl/livedisplay/Android.bp deleted file mode 100644 index 1dc9ae8..0000000 --- a/lineagehw/hidl/livedisplay/Android.bp +++ /dev/null @@ -1,85 +0,0 @@ -// Copyright (C) 2019 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. - -cc_defaults { - name: "livedisplay_samsung_exynos_defaults", - defaults: ["hidl_defaults"], - relative_install_path: "hw", - srcs: [ - "AdaptiveBacklight.cpp", - "DisplayColorCalibrationExynos.cpp", - "DisplayModes.cpp", - "ReadingEnhancement.cpp", - "SunlightEnhancementExynos.cpp", - "serviceExynos.cpp", - ], - shared_libs: [ - "libbase", - "libbinder", - "libhidlbase", - "libhidltransport", - "libutils", - "vendor.lineage.livedisplay@2.0", - ], -} - -cc_defaults { - name: "livedisplay_samsung_qcom_defaults", - defaults: ["hidl_defaults"], - relative_install_path: "hw", - srcs: [ - "AdaptiveBacklight.cpp", - "DisplayColorCalibration.cpp", - "DisplayModes.cpp", - "ReadingEnhancement.cpp", - "SunlightEnhancement.cpp", - "service.cpp", - ], - shared_libs: [ - "libbase", - "libbinder", - "libhidlbase", - "libhidltransport", - "libutils", - "vendor.lineage.livedisplay@2.0", - ], -} - -cc_binary { - name: "lineage.livedisplay@2.0-service.samsung-exynos", - init_rc: ["lineage.livedisplay@2.0-service.samsung-exynos.rc"], - defaults: ["livedisplay_samsung_exynos_defaults"], - cflags: ["-DLIVES_IN_SYSTEM"], -} - -cc_binary { - name: "vendor.lineage.livedisplay@2.0-service.samsung-exynos", - init_rc: ["vendor.lineage.livedisplay@2.0-service.samsung-exynos.rc"], - defaults: ["livedisplay_samsung_exynos_defaults"], - vendor: true, -} - -cc_binary { - name: "lineage.livedisplay@2.0-service.samsung-qcom", - init_rc: ["lineage.livedisplay@2.0-service.samsung-qcom.rc"], - defaults: ["livedisplay_samsung_qcom_defaults"], - cflags: ["-DLIVES_IN_SYSTEM"], -} - -cc_binary { - name: "vendor.lineage.livedisplay@2.0-service.samsung-qcom", - init_rc: ["vendor.lineage.livedisplay@2.0-service.samsung-qcom.rc"], - defaults: ["livedisplay_samsung_qcom_defaults"], - vendor: true, -} diff --git a/lineagehw/hidl/livedisplay/DisplayColorCalibration.cpp b/lineagehw/hidl/livedisplay/DisplayColorCalibration.cpp deleted file mode 100644 index be34d17..0000000 --- a/lineagehw/hidl/livedisplay/DisplayColorCalibration.cpp +++ /dev/null @@ -1,79 +0,0 @@ -/* - * Copyright (C) 2019 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. - */ - -#include -#include - -#include - -#include "DisplayColorCalibration.h" - -using android::base::ReadFileToString; -using android::base::Split; -using android::base::Trim; -using android::base::WriteStringToFile; - -namespace vendor { -namespace lineage { -namespace livedisplay { -namespace V2_0 { -namespace samsung { - -bool DisplayColorCalibration::isSupported() { - std::fstream rgb(FILE_RGB, rgb.in | rgb.out); - - return rgb.good(); -} - -// Methods from ::vendor::lineage::livedisplay::V2_0::IDisplayColorCalibration follow. -Return DisplayColorCalibration::getMaxValue() { - return 32768; -} - -Return DisplayColorCalibration::getMinValue() { - return 255; -} - -Return DisplayColorCalibration::getCalibration(getCalibration_cb _hidl_cb) { - std::vector rgb; - std::string tmp; - - if (ReadFileToString(FILE_RGB, &tmp)) { - std::vector colors = Split(Trim(tmp), " "); - for (const std::string& color : colors) { - rgb.push_back(std::stoi(color)); - } - } - - _hidl_cb(rgb); - return Void(); -} - -Return DisplayColorCalibration::setCalibration(const hidl_vec& rgb) { - std::string contents; - - for (const int32_t& color : rgb) { - contents += std::to_string(color) + " "; - } - - return WriteStringToFile(Trim(contents), FILE_RGB, true); -} - -} // namespace samsung -} // namespace V2_0 -} // namespace livedisplay -} // namespace lineage -} // namespace vendor diff --git a/lineagehw/hidl/livedisplay/DisplayColorCalibration.h b/lineagehw/hidl/livedisplay/DisplayColorCalibration.h deleted file mode 100644 index b22f988..0000000 --- a/lineagehw/hidl/livedisplay/DisplayColorCalibration.h +++ /dev/null @@ -1,51 +0,0 @@ -/* - * Copyright (C) 2019 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. - */ - -#ifndef VENDOR_LINEAGE_LIVEDISPLAY_V2_0_DISPLAYCOLORCALIBRATION_H -#define VENDOR_LINEAGE_LIVEDISPLAY_V2_0_DISPLAYCOLORCALIBRATION_H - -#include - -namespace vendor { -namespace lineage { -namespace livedisplay { -namespace V2_0 { -namespace samsung { - -using ::android::hardware::hidl_vec; -using ::android::hardware::Return; -using ::android::hardware::Void; - -#define FILE_RGB "/sys/class/graphics/fb0/rgb" - -class DisplayColorCalibration : public IDisplayColorCalibration { - public: - bool isSupported(); - - // Methods from ::vendor::lineage::livedisplay::V2_0::IDisplayColorCalibration follow. - Return getMaxValue() override; - Return getMinValue() override; - Return getCalibration(getCalibration_cb _hidl_cb) override; - Return setCalibration(const hidl_vec& rgb) override; -}; - -} // namespace samsung -} // namespace V2_0 -} // namespace livedisplay -} // namespace lineage -} // namespace vendor - -#endif // VENDOR_LINEAGE_LIVEDISPLAY_V2_0_DISPLAYCOLORCALIBRATION_H diff --git a/lineagehw/hidl/livedisplay/DisplayColorCalibrationExynos.cpp b/lineagehw/hidl/livedisplay/DisplayColorCalibrationExynos.cpp deleted file mode 100644 index d791ed7..0000000 --- a/lineagehw/hidl/livedisplay/DisplayColorCalibrationExynos.cpp +++ /dev/null @@ -1,77 +0,0 @@ -/* - * Copyright (C) 2019 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. - */ - -#include -#include - -#include - -#include "DisplayColorCalibrationExynos.h" - -using android::base::ReadFileToString; -using android::base::Split; -using android::base::Trim; -using android::base::WriteStringToFile; - -namespace vendor { -namespace lineage { -namespace livedisplay { -namespace V2_0 { -namespace samsung { - -static constexpr const char* kColorPath = "/sys/class/mdnie/mdnie/sensorRGB"; - -bool DisplayColorCalibrationExynos::isSupported() { - std::fstream rgb(kColorPath, rgb.in | rgb.out); - return rgb.good(); -} - -Return DisplayColorCalibrationExynos::getMaxValue() { - return 255; -} - -Return DisplayColorCalibrationExynos::getMinValue() { - return 1; -} - -Return DisplayColorCalibrationExynos::getCalibration(getCalibration_cb resultCb) { - std::vector rgb; - std::string tmp; - - if (ReadFileToString(kColorPath, &tmp)) { - std::vector colors = Split(Trim(tmp), " "); - for (const std::string& color : colors) { - rgb.push_back(std::stoi(color)); - } - } - - resultCb(rgb); - return Void(); -} - -Return DisplayColorCalibrationExynos::setCalibration(const hidl_vec& rgb) { - std::string contents; - for (const int32_t& color : rgb) { - contents += std::to_string(color) + " "; - } - return WriteStringToFile(Trim(contents), kColorPath, true); -} - -} // namespace samsung -} // namespace V2_0 -} // namespace livedisplay -} // namespace lineage -} // namespace vendor diff --git a/lineagehw/hidl/livedisplay/DisplayColorCalibrationExynos.h b/lineagehw/hidl/livedisplay/DisplayColorCalibrationExynos.h deleted file mode 100644 index 81c1827..0000000 --- a/lineagehw/hidl/livedisplay/DisplayColorCalibrationExynos.h +++ /dev/null @@ -1,57 +0,0 @@ -/* - * Copyright (C) 2019 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. - */ - -#ifndef VENDOR_LINEAGE_LIVEDISPLAY_V2_0_DISPLAYCOLORCALIBRATIONEXYNOS_H -#define VENDOR_LINEAGE_LIVEDISPLAY_V2_0_DISPLAYCOLORCALIBRATIONEXYNOS_H - -#include -#include -#include - -namespace vendor { -namespace lineage { -namespace livedisplay { -namespace V2_0 { -namespace samsung { - -using ::android::hardware::hidl_array; -using ::android::hardware::hidl_memory; -using ::android::hardware::hidl_string; -using ::android::hardware::hidl_vec; -using ::android::hardware::Return; -using ::android::hardware::Void; -using ::android::sp; - -class DisplayColorCalibrationExynos : public IDisplayColorCalibration { - public: - bool isSupported(); - - // Methods from ::vendor::lineage::livedisplay::V2_0::IDisplayColorCalibration follow. - Return getMaxValue() override; - Return getMinValue() override; - Return getCalibration(getCalibration_cb resultCb) override; - Return setCalibration(const hidl_vec& rgb) override; - - // Methods from ::android::hidl::base::V1_0::IBase follow. -}; - -} // namespace samsung -} // namespace V2_0 -} // namespace livedisplay -} // namespace lineage -} // namespace vendor - -#endif // VENDOR_LINEAGE_LIVEDISPLAY_V2_0_DISPLAYCOLORCALIBRATIONEXYNOS_H diff --git a/lineagehw/hidl/livedisplay/DisplayModes.cpp b/lineagehw/hidl/livedisplay/DisplayModes.cpp deleted file mode 100644 index 3a2b902..0000000 --- a/lineagehw/hidl/livedisplay/DisplayModes.cpp +++ /dev/null @@ -1,136 +0,0 @@ -/* - * Copyright (C) 2019 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. - */ - -#define LOG_TAG "DisplayModesService" - -#include "DisplayModes.h" -#include -#include - -namespace vendor { -namespace lineage { -namespace livedisplay { -namespace V2_0 { -namespace samsung { - -static constexpr const char* kModePath = "/sys/class/mdnie/mdnie/mode"; -static constexpr const char* kModeMaxPath = "/sys/class/mdnie/mdnie/mode_max"; -static constexpr const char* kDefaultPath = "/data/vendor/display/.displaymodedefault"; - -const std::map DisplayModes::kModeMap = { - // clang-format off - {0, "Dynamic"}, - {1, "Standard"}, - {2, "Natural"}, - {3, "Cinema"}, - {4, "Adaptive"}, - {5, "Reading"}, - // clang-format on -}; - -DisplayModes::DisplayModes() : mDefaultModeId(0) { - std::ifstream defaultFile(kDefaultPath); - int value; - - defaultFile >> value; - LOG(DEBUG) << "Default file read result " << value << " fail " << defaultFile.fail(); - if (defaultFile.fail()) { - return; - } - - for (const auto& entry : kModeMap) { - if (value == entry.first) { - mDefaultModeId = entry.first; - break; - } - } - - setDisplayMode(mDefaultModeId, false); -} - -bool DisplayModes::isSupported() { - std::ofstream modeFile(kModePath); - return modeFile.good(); -} - -// Methods from ::vendor::lineage::livedisplay::V2_0::IDisplayModes follow. -Return DisplayModes::getDisplayModes(getDisplayModes_cb resultCb) { - std::ifstream maxModeFile(kModeMaxPath); - int value; - std::vector modes; - if (!maxModeFile.fail()) { - maxModeFile >> value; - } else { - value = kModeMap.size(); - } - for (const auto& entry : kModeMap) { - if (entry.first < value) modes.push_back({entry.first, entry.second}); - } - resultCb(modes); - return Void(); -} - -Return DisplayModes::getCurrentDisplayMode(getCurrentDisplayMode_cb resultCb) { - int32_t currentModeId = mDefaultModeId; - std::ifstream modeFile(kModePath); - int value; - modeFile >> value; - if (!modeFile.fail()) { - for (const auto& entry : kModeMap) { - if (value == entry.first) { - currentModeId = entry.first; - break; - } - } - } - resultCb({currentModeId, kModeMap.at(currentModeId)}); - return Void(); -} - -Return DisplayModes::getDefaultDisplayMode(getDefaultDisplayMode_cb resultCb) { - resultCb({mDefaultModeId, kModeMap.at(mDefaultModeId)}); - return Void(); -} - -Return DisplayModes::setDisplayMode(int32_t modeID, bool makeDefault) { - const auto iter = kModeMap.find(modeID); - if (iter == kModeMap.end()) { - return false; - } - std::ofstream modeFile(kModePath); - modeFile << iter->first; - if (modeFile.fail()) { - return false; - } - - if (makeDefault) { - std::ofstream defaultFile(kDefaultPath); - defaultFile << iter->first; - if (defaultFile.fail()) { - return false; - } - mDefaultModeId = iter->first; - } - return true; -} - -// Methods from ::android::hidl::base::V1_0::IBase follow. - -} // namespace samsung -} // namespace V2_0 -} // namespace livedisplay -} // namespace lineage -} // namespace vendor diff --git a/lineagehw/hidl/livedisplay/DisplayModes.h b/lineagehw/hidl/livedisplay/DisplayModes.h deleted file mode 100644 index 149edf3..0000000 --- a/lineagehw/hidl/livedisplay/DisplayModes.h +++ /dev/null @@ -1,61 +0,0 @@ -/* - * Copyright (C) 2019 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. - */ - -#ifndef VENDOR_LINEAGE_LIVEDISPLAY_V2_0_DISPLAYMODES_H -#define VENDOR_LINEAGE_LIVEDISPLAY_V2_0_DISPLAYMODES_H - -#include -#include -#include - -namespace vendor { -namespace lineage { -namespace livedisplay { -namespace V2_0 { -namespace samsung { - -using ::android::hardware::hidl_array; -using ::android::hardware::hidl_memory; -using ::android::hardware::hidl_string; -using ::android::hardware::hidl_vec; -using ::android::hardware::Return; -using ::android::hardware::Void; -using ::android::sp; - -class DisplayModes : public IDisplayModes { - public: - DisplayModes(); - bool isSupported(); - - // Methods from ::vendor::lineage::livedisplay::V2_0::IDisplayModes follow. - Return getDisplayModes(getDisplayModes_cb resultCb) override; - Return getCurrentDisplayMode(getCurrentDisplayMode_cb resultCb) override; - Return getDefaultDisplayMode(getDefaultDisplayMode_cb resultCb) override; - Return setDisplayMode(int32_t modeID, bool makeDefault) override; - - // Methods from ::android::hidl::base::V1_0::IBase follow. - private: - static const std::map kModeMap; - int32_t mDefaultModeId; -}; - -} // namespace samsung -} // namespace V2_0 -} // namespace livedisplay -} // namespace lineage -} // namespace vendor - -#endif // VENDOR_LINEAGE_LIVEDISPLAY_V2_0_DISPLAYMODES_H diff --git a/lineagehw/hidl/livedisplay/ReadingEnhancement.cpp b/lineagehw/hidl/livedisplay/ReadingEnhancement.cpp deleted file mode 100644 index 3880c43..0000000 --- a/lineagehw/hidl/livedisplay/ReadingEnhancement.cpp +++ /dev/null @@ -1,63 +0,0 @@ -/* - * Copyright (C) 2019 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. - */ - -#include -#include - -#include - -#include "ReadingEnhancement.h" - -using android::base::ReadFileToString; -using android::base::Trim; -using android::base::WriteStringToFile; - -namespace vendor { -namespace lineage { -namespace livedisplay { -namespace V2_0 { -namespace samsung { - -static constexpr const char* kREPath = "/sys/class/mdnie/mdnie/accessibility"; - -// Methods from ::vendor::lineage::livedisplay::V2_0::ISunlightEnhancement follow. -bool ReadingEnhancement::isSupported() { - std::fstream re(kREPath, re.in | re.out); - return re.good(); -} - -// Methods from ::vendor::lineage::livedisplay::V2_0::IReadingEnhancement follow. -Return ReadingEnhancement::isEnabled() { - std::string contents; - - if (ReadFileToString(kREPath, &contents)) { - contents = Trim(contents); - } - - return !contents.compare("Current accessibility : DSI0 : GRAYSCALE") || !contents.compare("4"); -} - -Return ReadingEnhancement::setEnabled(bool enabled) { - return WriteStringToFile(enabled ? "4" : "0", kREPath, true); -} - -// Methods from ::android::hidl::base::V1_0::IBase follow. - -} // namespace samsung -} // namespace V2_0 -} // namespace livedisplay -} // namespace lineage -} // namespace vendor diff --git a/lineagehw/hidl/livedisplay/ReadingEnhancement.h b/lineagehw/hidl/livedisplay/ReadingEnhancement.h deleted file mode 100644 index 5b71669..0000000 --- a/lineagehw/hidl/livedisplay/ReadingEnhancement.h +++ /dev/null @@ -1,55 +0,0 @@ -/* - * Copyright (C) 2019 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. - */ - -#ifndef VENDOR_LINEAGE_LIVEDISPLAY_V2_0_READINGENHANCEMENT_H -#define VENDOR_LINEAGE_LIVEDISPLAY_V2_0_READINGENHANCEMENT_H - -#include -#include -#include - -namespace vendor { -namespace lineage { -namespace livedisplay { -namespace V2_0 { -namespace samsung { - -using ::android::hardware::hidl_array; -using ::android::hardware::hidl_memory; -using ::android::hardware::hidl_string; -using ::android::hardware::hidl_vec; -using ::android::hardware::Return; -using ::android::hardware::Void; -using ::android::sp; - -class ReadingEnhancement : public IReadingEnhancement { - public: - bool isSupported(); - - // Methods from ::vendor::lineage::livedisplay::V2_0::IReadingEnhancement follow. - Return isEnabled() override; - Return setEnabled(bool) override; - - // Methods from ::android::hidl::base::V1_0::IBase follow. -}; - -} // namespace samsung -} // namespace V2_0 -} // namespace livedisplay -} // namespace lineage -} // namespace vendor - -#endif // VENDOR_LINEAGE_LIVEDISPLAY_V2_0_READINGENHANCEMENT_H diff --git a/lineagehw/hidl/livedisplay/SunlightEnhancement.cpp b/lineagehw/hidl/livedisplay/SunlightEnhancement.cpp deleted file mode 100644 index 077672e..0000000 --- a/lineagehw/hidl/livedisplay/SunlightEnhancement.cpp +++ /dev/null @@ -1,77 +0,0 @@ -/* - * Copyright (C) 2019 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. - */ - -#include -#include - -#include - -#include "SunlightEnhancement.h" - -using android::base::ReadFileToString; -using android::base::Trim; -using android::base::WriteStringToFile; - -namespace vendor { -namespace lineage { -namespace livedisplay { -namespace V2_0 { -namespace samsung { - -static constexpr const char* kHBMPath = "/sys/class/lcd/panel/panel/auto_brightness"; -static constexpr const char* kSREPath = "/sys/class/mdnie/mdnie/outdoor"; - -// Methods from ::vendor::lineage::livedisplay::V2_0::ISunlightEnhancement follow. -bool SunlightEnhancement::isSupported() { - std::fstream sre(kSREPath, sre.in | sre.out); - std::fstream hbm(kHBMPath, hbm.in | hbm.out); - - if (hbm.good()) { - mHasHBM = true; - } - - return sre.good(); -} - -// Methods from ::vendor::lineage::livedisplay::V2_0::IAdaptiveBacklight follow. -Return SunlightEnhancement::isEnabled() { - std::string tmp; - int32_t statusSRE = 0; - int32_t statusHBM = 0; - if (ReadFileToString(kSREPath, &tmp)) { - statusSRE = std::stoi(Trim(tmp)); - } - - if (mHasHBM && ReadFileToString(kHBMPath, &tmp)) { - statusHBM = std::stoi(Trim(tmp)); - } - - return ((statusSRE == 1 && statusHBM == 6) || statusSRE == 1); -} - -Return SunlightEnhancement::setEnabled(bool enabled) { - if (mHasHBM) { - WriteStringToFile(enabled ? "6" : "0", kHBMPath, true); - } - - return WriteStringToFile(enabled ? "1" : "0", kSREPath, true); -} - -} // namespace samsung -} // namespace V2_0 -} // namespace livedisplay -} // namespace lineage -} // namespace vendor diff --git a/lineagehw/hidl/livedisplay/SunlightEnhancement.h b/lineagehw/hidl/livedisplay/SunlightEnhancement.h deleted file mode 100644 index 44b34b9..0000000 --- a/lineagehw/hidl/livedisplay/SunlightEnhancement.h +++ /dev/null @@ -1,57 +0,0 @@ -/* - * Copyright (C) 2019 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. - */ - -#ifndef VENDOR_LINEAGE_LIVEDISPLAY_V2_0_SUNLIGHTENHANCEMENT_H -#define VENDOR_LINEAGE_LIVEDISPLAY_V2_0_SUNLIGHTENHANCEMENT_H - -#include -#include -#include - -namespace vendor { -namespace lineage { -namespace livedisplay { -namespace V2_0 { -namespace samsung { - -using ::android::hardware::hidl_array; -using ::android::hardware::hidl_memory; -using ::android::hardware::hidl_string; -using ::android::hardware::hidl_vec; -using ::android::hardware::Return; -using ::android::hardware::Void; -using ::android::sp; - -class SunlightEnhancement : public ISunlightEnhancement { - public: - bool isSupported(); - - // Methods from ::vendor::lineage::livedisplay::V2_0::ISunlightEnhancement follow. - Return isEnabled() override; - Return setEnabled(bool enabled) override; - - // Methods from ::android::hidl::base::V1_0::IBase follow. - private: - bool mHasHBM = false; -}; - -} // namespace samsung -} // namespace V2_0 -} // namespace livedisplay -} // namespace lineage -} // namespace vendor - -#endif // VENDOR_LINEAGE_LIVEDISPLAY_V2_0_SUNLIGHTENHANCEMENT_H diff --git a/lineagehw/hidl/livedisplay/SunlightEnhancementExynos.cpp b/lineagehw/hidl/livedisplay/SunlightEnhancementExynos.cpp deleted file mode 100644 index 950342a..0000000 --- a/lineagehw/hidl/livedisplay/SunlightEnhancementExynos.cpp +++ /dev/null @@ -1,63 +0,0 @@ -/* - * Copyright (C) 2019 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. - */ - -#include -#include - -#include - -#include "SunlightEnhancementExynos.h" - -using android::base::ReadFileToString; -using android::base::Trim; -using android::base::WriteStringToFile; - -namespace vendor { -namespace lineage { -namespace livedisplay { -namespace V2_0 { -namespace samsung { - -static constexpr const char* kLUXPath = "/sys/class/mdnie/mdnie/lux"; - -// Methods from ::vendor::lineage::livedisplay::V2_0::ISunlightEnhancement follow. -bool SunlightEnhancementExynos::isSupported() { - std::fstream file(kLUXPath, file.in | file.out); - return file.good(); -} - -// Methods from ::vendor::lineage::livedisplay::V2_0::IAdaptiveBacklight follow. -Return SunlightEnhancementExynos::isEnabled() { - std::string tmp; - int32_t contents = 0; - - if (ReadFileToString(kLUXPath, &tmp)) { - contents = std::stoi(Trim(tmp)); - } - - return contents > 0; -} - -Return SunlightEnhancementExynos::setEnabled(bool enabled) { - /* see drivers/video/fbdev/exynos/decon_7880/panels/mdnie_lite_table*, get_hbm_index */ - return WriteStringToFile(enabled ? "40000" : "0", kLUXPath, true); -} - -} // namespace samsung -} // namespace V2_0 -} // namespace livedisplay -} // namespace lineage -} // namespace vendor diff --git a/lineagehw/hidl/livedisplay/SunlightEnhancementExynos.h b/lineagehw/hidl/livedisplay/SunlightEnhancementExynos.h deleted file mode 100644 index 4b34861..0000000 --- a/lineagehw/hidl/livedisplay/SunlightEnhancementExynos.h +++ /dev/null @@ -1,55 +0,0 @@ -/* - * Copyright (C) 2019 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. - */ - -#ifndef VENDOR_LINEAGE_LIVEDISPLAY_V2_0_SUNLIGHTENHANCEMENTEXYNOS_H -#define VENDOR_LINEAGE_LIVEDISPLAY_V2_0_SUNLIGHTENHANCEMENTEXYNOS_H - -#include -#include -#include - -namespace vendor { -namespace lineage { -namespace livedisplay { -namespace V2_0 { -namespace samsung { - -using ::android::hardware::hidl_array; -using ::android::hardware::hidl_memory; -using ::android::hardware::hidl_string; -using ::android::hardware::hidl_vec; -using ::android::hardware::Return; -using ::android::hardware::Void; -using ::android::sp; - -class SunlightEnhancementExynos : public ISunlightEnhancement { - public: - bool isSupported(); - - // Methods from ::vendor::lineage::livedisplay::V2_0::ISunlightEnhancement follow. - Return isEnabled() override; - Return setEnabled(bool enabled) override; - - // Methods from ::android::hidl::base::V1_0::IBase follow. -}; - -} // namespace samsung -} // namespace V2_0 -} // namespace livedisplay -} // namespace lineage -} // namespace vendor - -#endif // VENDOR_LINEAGE_LIVEDISPLAY_V2_0_SUNLIGHTENHANCEMENTEXYNOS_H diff --git a/lineagehw/hidl/livedisplay/lineage.livedisplay@2.0-service.samsung-exynos.rc b/lineagehw/hidl/livedisplay/lineage.livedisplay@2.0-service.samsung-exynos.rc deleted file mode 100644 index 3fd15b5..0000000 --- a/lineagehw/hidl/livedisplay/lineage.livedisplay@2.0-service.samsung-exynos.rc +++ /dev/null @@ -1,7 +0,0 @@ -on post-fs-data - mkdir /data/vendor/display 0770 system system - -service livedisplay-hal-2-0-samsung-exynos /system/bin/hw/lineage.livedisplay@2.0-service.samsung-exynos - class hal - user system - group system \ No newline at end of file diff --git a/lineagehw/hidl/livedisplay/lineage.livedisplay@2.0-service.samsung-qcom.rc b/lineagehw/hidl/livedisplay/lineage.livedisplay@2.0-service.samsung-qcom.rc deleted file mode 100644 index 48ebd94..0000000 --- a/lineagehw/hidl/livedisplay/lineage.livedisplay@2.0-service.samsung-qcom.rc +++ /dev/null @@ -1,7 +0,0 @@ -on post-fs-data - mkdir /data/vendor/display 0770 system system - -service livedisplay-hal-2-0-samsung-qcom /system/bin/hw/lineage.livedisplay@2.0-service.samsung-qcom - class late_start - user system - group system diff --git a/lineagehw/hidl/livedisplay/service.cpp b/lineagehw/hidl/livedisplay/service.cpp deleted file mode 100644 index 1e97aee..0000000 --- a/lineagehw/hidl/livedisplay/service.cpp +++ /dev/null @@ -1,147 +0,0 @@ -/* - * Copyright (C) 2019 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. - */ - -#ifdef LIVES_IN_SYSTEM -#define LOG_TAG "lineage.livedisplay@2.0-service.samsung-qcom" -#else -#define LOG_TAG "vendor.lineage.livedisplay@2.0-service.samsung-qcom" -#endif - -#include -#include -#include - -#include "AdaptiveBacklight.h" -#include "DisplayColorCalibration.h" -#include "DisplayModes.h" -#include "ReadingEnhancement.h" -#include "SunlightEnhancement.h" - -using android::hardware::configureRpcThreadpool; -using android::hardware::joinRpcThreadpool; -using android::sp; -using android::status_t; -using android::OK; - -using vendor::lineage::livedisplay::V2_0::samsung::AdaptiveBacklight; -using vendor::lineage::livedisplay::V2_0::samsung::DisplayColorCalibration; -using vendor::lineage::livedisplay::V2_0::samsung::DisplayModes; -using vendor::lineage::livedisplay::V2_0::samsung::ReadingEnhancement; -using vendor::lineage::livedisplay::V2_0::samsung::SunlightEnhancement; - -int main() { - sp adaptiveBacklight; - sp displayColorCalibration; - sp displayModes; - sp readingEnhancement; - sp sunlightEnhancement; - status_t status; - - LOG(INFO) << "LiveDisplay HAL service is starting."; - - adaptiveBacklight = new AdaptiveBacklight(); - if (adaptiveBacklight == nullptr) { - LOG(ERROR) - << "Can not create an instance of LiveDisplay HAL AdaptiveBacklight Iface, exiting."; - goto shutdown; - } - - displayColorCalibration = new DisplayColorCalibration(); - if (displayColorCalibration == nullptr) { - LOG(ERROR) << "Can not create an instance of LiveDisplay HAL DisplayColorCalibration " - "Iface, exiting."; - goto shutdown; - } - - displayModes = new DisplayModes(); - if (displayModes == nullptr) { - LOG(ERROR) << "Can not create an instance of LiveDisplay HAL DisplayModes Iface, exiting."; - goto shutdown; - } - - readingEnhancement = new ReadingEnhancement(); - if (readingEnhancement == nullptr) { - LOG(ERROR) - << "Can not create an instance of LiveDisplay HAL ReadingEnhancement Iface, exiting."; - goto shutdown; - } - - sunlightEnhancement = new SunlightEnhancement(); - if (sunlightEnhancement == nullptr) { - LOG(ERROR) - << "Can not create an instance of LiveDisplay HAL SunlightEnhancement Iface, exiting."; - goto shutdown; - } - - configureRpcThreadpool(1, true /*callerWillJoin*/); - - if (adaptiveBacklight->isSupported()) { - status = adaptiveBacklight->registerAsService(); - if (status != OK) { - LOG(ERROR) << "Could not register service for LiveDisplay HAL AdaptiveBacklight Iface (" - << status << ")"; - goto shutdown; - } - } - - if (displayColorCalibration->isSupported()) { - status = displayColorCalibration->registerAsService(); - if (status != OK) { - LOG(ERROR) - << "Could not register service for LiveDisplay HAL DisplayColorCalibration Iface (" - << status << ")"; - goto shutdown; - } - } - - if (displayModes->isSupported()) { - status = displayModes->registerAsService(); - if (status != OK) { - LOG(ERROR) << "Could not register service for LiveDisplay HAL DisplayModes Iface (" - << status << ")"; - goto shutdown; - } - } - - if (readingEnhancement->isSupported()) { - status = readingEnhancement->registerAsService(); - if (status != OK) { - LOG(ERROR) - << "Could not register service for LiveDisplay HAL ReadingEnhancement Iface (" - << status << ")"; - goto shutdown; - } - } - - if (sunlightEnhancement->isSupported()) { - status = sunlightEnhancement->registerAsService(); - if (status != OK) { - LOG(ERROR) - << "Could not register service for LiveDisplay HAL SunlightEnhancement Iface (" - << status << ")"; - goto shutdown; - } - } - - LOG(INFO) << "LiveDisplay HAL service is ready."; - joinRpcThreadpool(); -// Should not pass this line - -shutdown: - // In normal operation, we don't expect the thread pool to shutdown - LOG(ERROR) << "LiveDisplay HAL service is shutting down."; - return 1; -} diff --git a/lineagehw/hidl/livedisplay/serviceExynos.cpp b/lineagehw/hidl/livedisplay/serviceExynos.cpp deleted file mode 100644 index c7395b8..0000000 --- a/lineagehw/hidl/livedisplay/serviceExynos.cpp +++ /dev/null @@ -1,147 +0,0 @@ -/* - * Copyright (C) 2019 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. - */ - -#ifdef LIVES_IN_SYSTEM -#define LOG_TAG "lineage.livedisplay@2.0-service.samsung-exynos" -#else -#define LOG_TAG "vendor.lineage.livedisplay@2.0-service.samsung-exynos" -#endif - -#include -#include -#include - -#include "AdaptiveBacklight.h" -#include "DisplayColorCalibrationExynos.h" -#include "DisplayModes.h" -#include "ReadingEnhancement.h" -#include "SunlightEnhancementExynos.h" - -using android::hardware::configureRpcThreadpool; -using android::hardware::joinRpcThreadpool; -using android::sp; -using android::status_t; -using android::OK; - -using vendor::lineage::livedisplay::V2_0::samsung::AdaptiveBacklight; -using vendor::lineage::livedisplay::V2_0::samsung::DisplayColorCalibrationExynos; -using vendor::lineage::livedisplay::V2_0::samsung::DisplayModes; -using vendor::lineage::livedisplay::V2_0::samsung::ReadingEnhancement; -using vendor::lineage::livedisplay::V2_0::samsung::SunlightEnhancementExynos; - -int main() { - sp adaptiveBacklight; - sp displayColorCalibrationExynos; - sp displayModes; - sp readingEnhancement; - sp sunlightEnhancementExynos; - status_t status; - - LOG(INFO) << "LiveDisplay HAL service is starting."; - - adaptiveBacklight = new AdaptiveBacklight(); - if (adaptiveBacklight == nullptr) { - LOG(ERROR) - << "Can not create an instance of LiveDisplay HAL AdaptiveBacklight Iface, exiting."; - goto shutdown; - } - - displayColorCalibrationExynos = new DisplayColorCalibrationExynos(); - if (displayColorCalibrationExynos == nullptr) { - LOG(ERROR) << "Can not create an instance of LiveDisplay HAL DisplayColorCalibration " - "Iface, exiting."; - goto shutdown; - } - - displayModes = new DisplayModes(); - if (displayModes == nullptr) { - LOG(ERROR) << "Can not create an instance of LiveDisplay HAL DisplayModes Iface, exiting."; - goto shutdown; - } - - readingEnhancement = new ReadingEnhancement(); - if (readingEnhancement == nullptr) { - LOG(ERROR) - << "Can not create an instance of LiveDisplay HAL ReadingEnhancement Iface, exiting."; - goto shutdown; - } - - sunlightEnhancementExynos = new SunlightEnhancementExynos(); - if (sunlightEnhancementExynos == nullptr) { - LOG(ERROR) - << "Can not create an instance of LiveDisplay HAL SunlightEnhancement Iface, exiting."; - goto shutdown; - } - - configureRpcThreadpool(1, true /*callerWillJoin*/); - - if (adaptiveBacklight->isSupported()) { - status = adaptiveBacklight->registerAsService(); - if (status != OK) { - LOG(ERROR) << "Could not register service for LiveDisplay HAL AdaptiveBacklight Iface (" - << status << ")"; - goto shutdown; - } - } - - if (displayColorCalibrationExynos->isSupported()) { - status = displayColorCalibrationExynos->registerAsService(); - if (status != OK) { - LOG(ERROR) - << "Could not register service for LiveDisplay HAL DisplayColorCalibration Iface (" - << status << ")"; - goto shutdown; - } - } - - if (displayModes->isSupported()) { - status = displayModes->registerAsService(); - if (status != OK) { - LOG(ERROR) << "Could not register service for LiveDisplay HAL DisplayModes Iface (" - << status << ")"; - goto shutdown; - } - } - - if (readingEnhancement->isSupported()) { - status = readingEnhancement->registerAsService(); - if (status != OK) { - LOG(ERROR) - << "Could not register service for LiveDisplay HAL ReadingEnhancement Iface (" - << status << ")"; - goto shutdown; - } - } - - if (sunlightEnhancementExynos->isSupported()) { - status = sunlightEnhancementExynos->registerAsService(); - if (status != OK) { - LOG(ERROR) - << "Could not register service for LiveDisplay HAL SunlightEnhancement Iface (" - << status << ")"; - goto shutdown; - } - } - - LOG(INFO) << "LiveDisplay HAL service is ready."; - joinRpcThreadpool(); -// Should not pass this line - -shutdown: - // In normal operation, we don't expect the thread pool to shutdown - LOG(ERROR) << "LiveDisplay HAL service is shutting down."; - return 1; -} diff --git a/lineagehw/hidl/livedisplay/vendor.lineage.livedisplay@2.0-service.samsung-exynos.rc b/lineagehw/hidl/livedisplay/vendor.lineage.livedisplay@2.0-service.samsung-exynos.rc deleted file mode 100644 index 2faab1b..0000000 --- a/lineagehw/hidl/livedisplay/vendor.lineage.livedisplay@2.0-service.samsung-exynos.rc +++ /dev/null @@ -1,7 +0,0 @@ -on post-fs-data - mkdir /data/vendor/display 0770 system system - -service vendor.livedisplay-hal-2-0-samsung-exynos /vendor/bin/hw/vendor.lineage.livedisplay@2.0-service.samsung-exynos - class hal - user system - group system \ No newline at end of file diff --git a/lineagehw/hidl/livedisplay/vendor.lineage.livedisplay@2.0-service.samsung-qcom.rc b/lineagehw/hidl/livedisplay/vendor.lineage.livedisplay@2.0-service.samsung-qcom.rc deleted file mode 100644 index 8698601..0000000 --- a/lineagehw/hidl/livedisplay/vendor.lineage.livedisplay@2.0-service.samsung-qcom.rc +++ /dev/null @@ -1,7 +0,0 @@ -on post-fs-data - mkdir /data/vendor/display 0770 system system - -service vendor.livedisplay-hal-2-0-samsung-qcom /vendor/bin/hw/vendor.lineage.livedisplay@2.0-service.samsung-qcom - class late_start - user system - group system diff --git a/lineagehw/hidl/touch/.clang-format b/lineagehw/hidl/touch/.clang-format deleted file mode 100644 index ae4a451..0000000 --- a/lineagehw/hidl/touch/.clang-format +++ /dev/null @@ -1,11 +0,0 @@ -BasedOnStyle: Google -AccessModifierOffset: -2 -AllowShortFunctionsOnASingleLine: Inline -ColumnLimit: 100 -CommentPragmas: NOLINT:.* -DerivePointerAlignment: false -IndentWidth: 4 -PointerAlignment: Left -TabWidth: 4 -UseTab: Never -PenaltyExcessCharacter: 32 diff --git a/lineagehw/hidl/touch/Android.bp b/lineagehw/hidl/touch/Android.bp deleted file mode 100644 index 0197b6c..0000000 --- a/lineagehw/hidl/touch/Android.bp +++ /dev/null @@ -1,38 +0,0 @@ -// Copyright (C) 2019 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. - -cc_binary { - name: "vendor.lineage.touch@1.0-service.samsung", - init_rc: ["vendor.lineage.touch@1.0-service.samsung.rc"], - defaults: ["hidl_defaults"], - relative_install_path: "hw", - // FIXME: this should be 'vendor: true' for modules that will eventually be - // on AOSP. - proprietary: true, - srcs: [ - "GloveMode.cpp", - "KeyDisabler.cpp", - "StylusMode.cpp", - "TouchscreenGesture.cpp", - "service.cpp" - ], - shared_libs: [ - "libbase", - "libbinder", - "libhidlbase", - "libhidltransport", - "libutils", - "vendor.lineage.touch@1.0", - ], -} diff --git a/lineagehw/hidl/touch/GloveMode.cpp b/lineagehw/hidl/touch/GloveMode.cpp deleted file mode 100644 index f059b61..0000000 --- a/lineagehw/hidl/touch/GloveMode.cpp +++ /dev/null @@ -1,61 +0,0 @@ -/* - * Copyright (C) 2019 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. - */ - -#include - -#include "GloveMode.h" - -namespace vendor { -namespace lineage { -namespace touch { -namespace V1_0 { -namespace samsung { - -bool GloveMode::isSupported() { - std::ifstream file("/sys/class/sec/tsp/cmd_list"); - if (file.is_open()) { - std::string line; - while (getline(file, line)) { - if (!line.compare("glove_mode")) return true; - } - file.close(); - } - return false; -} - -// Methods from ::vendor::lineage::touch::V1_0::IGloveMode follow. -Return GloveMode::isEnabled() { - std::ifstream file("/sys/class/sec/tsp/cmd_result"); - if (file.is_open()) { - std::string line; - getline(file, line); - if (!line.compare("glove_mode,1:OK")) return true; - file.close(); - } - return false; -} - -Return GloveMode::setEnabled(bool enabled) { - std::ofstream file("/sys/class/sec/tsp/cmd"); - file << "glove_mode," << (enabled ? "1" : "0"); - return true; -} - -} // namespace samsung -} // namespace V1_0 -} // namespace touch -} // namespace lineage -} // namespace vendor diff --git a/lineagehw/hidl/touch/GloveMode.h b/lineagehw/hidl/touch/GloveMode.h deleted file mode 100644 index 25489bc..0000000 --- a/lineagehw/hidl/touch/GloveMode.h +++ /dev/null @@ -1,57 +0,0 @@ -/* - * Copyright (C) 2019 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. - */ - -#ifndef VENDOR_LINEAGE_TOUCH_V1_0_GLOVEMODE_H -#define VENDOR_LINEAGE_TOUCH_V1_0_GLOVEMODE_H - -#include -#include -#include - -namespace vendor { -namespace lineage { -namespace touch { -namespace V1_0 { -namespace samsung { - -using ::android::hardware::hidl_array; -using ::android::hardware::hidl_memory; -using ::android::hardware::hidl_string; -using ::android::hardware::hidl_vec; -using ::android::hardware::Return; -using ::android::hardware::Void; -using ::android::sp; - -class GloveMode : public IGloveMode { - public: - GloveMode() = default; - - bool isSupported(); - - // Methods from ::vendor::lineage::touch::V1_0::IGloveMode follow. - Return isEnabled() override; - Return setEnabled(bool enabled) override; - - // Methods from ::android::hidl::base::V1_0::IBase follow. -}; - -} // namespace samsung -} // namespace V1_0 -} // namespace touch -} // namespace lineage -} // namespace vendor - -#endif // VENDOR_LINEAGE_TOUCH_V1_0_GLOVEMODE_H diff --git a/lineagehw/hidl/touch/KeyDisabler.cpp b/lineagehw/hidl/touch/KeyDisabler.cpp deleted file mode 100644 index 54691a0..0000000 --- a/lineagehw/hidl/touch/KeyDisabler.cpp +++ /dev/null @@ -1,54 +0,0 @@ -/* - * Copyright (C) 2019 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. - */ - -#include - -#include "KeyDisabler.h" - -namespace vendor { -namespace lineage { -namespace touch { -namespace V1_0 { -namespace samsung { - -bool KeyDisabler::isSupported() { - std::ofstream file("/sys/class/sec/sec_touchkey/input/enabled"); - return file.good(); -} - -// Methods from ::vendor::lineage::touch::V1_0::IKeyDisabler follow. -Return KeyDisabler::isEnabled() { - std::ifstream file("/sys/class/sec/sec_touchkey/input/enabled"); - int status = -1; - - if (file.is_open()) { - file >> status; - } - - return file.good() && status == 0; -} - -Return KeyDisabler::setEnabled(bool enabled) { - std::ofstream file("/sys/class/sec/sec_touchkey/input/enabled"); - file << (enabled ? "0" : "1"); - return true; -} - -} // namespace samsung -} // namespace V1_0 -} // namespace touch -} // namespace lineage -} // namespace vendor diff --git a/lineagehw/hidl/touch/KeyDisabler.h b/lineagehw/hidl/touch/KeyDisabler.h deleted file mode 100644 index 9cab414..0000000 --- a/lineagehw/hidl/touch/KeyDisabler.h +++ /dev/null @@ -1,57 +0,0 @@ -/* - * Copyright (C) 2019 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. - */ - -#ifndef VENDOR_LINEAGE_TOUCH_V1_0_KEYDISABLER_H -#define VENDOR_LINEAGE_TOUCH_V1_0_KEYDISABLER_H - -#include -#include -#include - -namespace vendor { -namespace lineage { -namespace touch { -namespace V1_0 { -namespace samsung { - -using ::android::hardware::hidl_array; -using ::android::hardware::hidl_memory; -using ::android::hardware::hidl_string; -using ::android::hardware::hidl_vec; -using ::android::hardware::Return; -using ::android::hardware::Void; -using ::android::sp; - -class KeyDisabler : public IKeyDisabler { - public: - KeyDisabler() = default; - - bool isSupported(); - - // Methods from ::vendor::lineage::touch::V1_0::IKeyDisabler follow. - Return isEnabled() override; - Return setEnabled(bool enabled) override; - - // Methods from ::android::hidl::base::V1_0::IBase follow. -}; - -} // namespace samsung -} // namespace V1_0 -} // namespace touch -} // namespace lineage -} // namespace vendor - -#endif // VENDOR_LINEAGE_TOUCH_V1_0_KEYDISABLER_H diff --git a/lineagehw/hidl/touch/StylusMode.cpp b/lineagehw/hidl/touch/StylusMode.cpp deleted file mode 100644 index e3190db..0000000 --- a/lineagehw/hidl/touch/StylusMode.cpp +++ /dev/null @@ -1,61 +0,0 @@ -/* - * Copyright (C) 2019 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. - */ - -#include - -#include "StylusMode.h" - -namespace vendor { -namespace lineage { -namespace touch { -namespace V1_0 { -namespace samsung { - -bool StylusMode::isSupported() { - std::ifstream file("/sys/class/sec/tsp/cmd_list"); - if (file.is_open()) { - std::string line; - while (getline(file, line)) { - if (!line.compare("hover_enable")) return true; - } - file.close(); - } - return false; -} - -// Methods from ::vendor::lineage::touch::V1_0::IStylusMode follow. -Return StylusMode::isEnabled() { - std::ifstream file("/sys/class/sec/tsp/cmd_result"); - if (file.is_open()) { - std::string line; - getline(file, line); - if (!line.compare("hover_enable,1:OK")) return true; - file.close(); - } - return false; -} - -Return StylusMode::setEnabled(bool enabled) { - std::ofstream file("/sys/class/sec/tsp/cmd"); - file << "hover_enable," << (enabled ? "1" : "0"); - return true; -} - -} // namespace samsung -} // namespace V1_0 -} // namespace touch -} // namespace lineage -} // namespace vendor diff --git a/lineagehw/hidl/touch/StylusMode.h b/lineagehw/hidl/touch/StylusMode.h deleted file mode 100644 index 6226ca5..0000000 --- a/lineagehw/hidl/touch/StylusMode.h +++ /dev/null @@ -1,57 +0,0 @@ -/* - * Copyright (C) 2019 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. - */ - -#ifndef VENDOR_LINEAGE_TOUCH_V1_0_STYLUSMODE_H -#define VENDOR_LINEAGE_TOUCH_V1_0_STYLUSMODE_H - -#include -#include -#include - -namespace vendor { -namespace lineage { -namespace touch { -namespace V1_0 { -namespace samsung { - -using ::android::hardware::hidl_array; -using ::android::hardware::hidl_memory; -using ::android::hardware::hidl_string; -using ::android::hardware::hidl_vec; -using ::android::hardware::Return; -using ::android::hardware::Void; -using ::android::sp; - -class StylusMode : public IStylusMode { - public: - StylusMode() = default; - - bool isSupported(); - - // Methods from ::vendor::lineage::touch::V1_0::IStylusMode follow. - Return isEnabled() override; - Return setEnabled(bool enabled) override; - - // Methods from ::android::hidl::base::V1_0::IBase follow. -}; - -} // namespace samsung -} // namespace V1_0 -} // namespace touch -} // namespace lineage -} // namespace vendor - -#endif // VENDOR_LINEAGE_TOUCH_V1_0_STYLUSMODE_H diff --git a/lineagehw/hidl/touch/TouchscreenGesture.cpp b/lineagehw/hidl/touch/TouchscreenGesture.cpp deleted file mode 100644 index c0091a6..0000000 --- a/lineagehw/hidl/touch/TouchscreenGesture.cpp +++ /dev/null @@ -1,80 +0,0 @@ -/* - * Copyright (C) 2019 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. - */ - -#include - -#include "TouchscreenGesture.h" - -namespace vendor { -namespace lineage { -namespace touch { -namespace V1_0 { -namespace samsung { - -static constexpr const char* kGeasturePath = "/sys/class/sec/sec_epen/epen_gestures"; - -const std::map TouchscreenGesture::kGestureInfoMap = { - // clang-format off - {0, {0x2f1, "Swipe up stylus"}}, - {1, {0x2f2, "Swipe down stylus"}}, - {2, {0x2f3, "Swipe left stylus"}}, - {3, {0x2f4, "Swipe right stylus"}}, - {4, {0x2f5, "Long press stylus"}}, - // clang-format on -}; - -bool TouchscreenGesture::isSupported() { - std::ifstream file(kGeasturePath); - return file.good(); -} - -// Methods from ::vendor::lineage::touch::V1_0::ITouchscreenGesture follow. -Return TouchscreenGesture::getSupportedGestures(getSupportedGestures_cb resultCb) { - std::vector gestures; - - for (const auto& entry : kGestureInfoMap) { - gestures.push_back({entry.first, entry.second.name, entry.second.keycode}); - } - resultCb(gestures); - - return Void(); -} - -Return TouchscreenGesture::setGestureEnabled( - const ::vendor::lineage::touch::V1_0::Gesture& gesture, bool enabled) { - std::fstream file(kGeasturePath); - int gestureMode; - int mask = 1 << gesture.id; - - file >> gestureMode; - - if (enabled) - gestureMode |= mask; - else - gestureMode &= ~mask; - - file << gestureMode; - - return !file.fail(); -} - -// Methods from ::android::hidl::base::V1_0::IBase follow. - -} // namespace samsung -} // namespace V1_0 -} // namespace touch -} // namespace lineage -} // namespace vendor diff --git a/lineagehw/hidl/touch/TouchscreenGesture.h b/lineagehw/hidl/touch/TouchscreenGesture.h deleted file mode 100644 index 35517f1..0000000 --- a/lineagehw/hidl/touch/TouchscreenGesture.h +++ /dev/null @@ -1,64 +0,0 @@ -/* - * Copyright (C) 2019 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. - */ - -#ifndef VENDOR_LINEAGE_TOUCH_V1_0_TOUCHSCREENGESTURE_H -#define VENDOR_LINEAGE_TOUCH_V1_0_TOUCHSCREENGESTURE_H - -#include -#include -#include - -namespace vendor { -namespace lineage { -namespace touch { -namespace V1_0 { -namespace samsung { - -using ::android::hardware::hidl_array; -using ::android::hardware::hidl_memory; -using ::android::hardware::hidl_string; -using ::android::hardware::hidl_vec; -using ::android::hardware::Return; -using ::android::hardware::Void; -using ::android::sp; - -class TouchscreenGesture : public ITouchscreenGesture { - public: - bool isSupported(); - - // Methods from ::vendor::lineage::touch::V1_0::ITouchscreenGesture follow. - Return getSupportedGestures(getSupportedGestures_cb resultCb) override; - Return setGestureEnabled(const ::vendor::lineage::touch::V1_0::Gesture& gesture, - bool enabled) override; - - private: - typedef struct { - int32_t keycode; - const char* name; - } GestureInfo; - static const std::map kGestureInfoMap; // id -> info -}; - -// FIXME: most likely delete, this is only for passthrough implementations -// extern "C" ITouchscreenGesture* HIDL_FETCH_ITouchscreenGesture(const char* name); - -} // namespace samsung -} // namespace V1_0 -} // namespace touch -} // namespace lineage -} // namespace vendor - -#endif // VENDOR_LINEAGE_TOUCH_V1_0_TOUCHSCREENGESTURE_H diff --git a/lineagehw/hidl/touch/service.cpp b/lineagehw/hidl/touch/service.cpp deleted file mode 100644 index e12326c..0000000 --- a/lineagehw/hidl/touch/service.cpp +++ /dev/null @@ -1,118 +0,0 @@ -/* - * Copyright (C) 2019 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. - */ - -#define LOG_TAG "vendor.lineage.touch@1.0-service.samsung" - -#include -#include -#include - -#include "GloveMode.h" -#include "KeyDisabler.h" -#include "StylusMode.h" -#include "TouchscreenGesture.h" - -using android::hardware::configureRpcThreadpool; -using android::hardware::joinRpcThreadpool; -using android::sp; -using android::status_t; -using android::OK; - -using ::vendor::lineage::touch::V1_0::samsung::GloveMode; -using ::vendor::lineage::touch::V1_0::samsung::KeyDisabler; -using ::vendor::lineage::touch::V1_0::samsung::StylusMode; -using ::vendor::lineage::touch::V1_0::samsung::TouchscreenGesture; - -int main() { - sp gloveMode; - sp keyDisabler; - sp stylusMode; - sp touchscreenGesture; - status_t status; - - LOG(INFO) << "Touch HAL service is starting."; - - gloveMode = new GloveMode(); - if (gloveMode == nullptr) { - LOG(ERROR) << "Can not create an instance of Touch HAL GloveMode Iface, exiting."; - goto shutdown; - } - - keyDisabler = new KeyDisabler(); - if (keyDisabler == nullptr) { - LOG(ERROR) << "Can not create an instance of Touch HAL KeyDisabler Iface, exiting."; - goto shutdown; - } - - stylusMode = new StylusMode(); - if (stylusMode == nullptr) { - LOG(ERROR) << "Can not create an instance of Touch HAL StylusMode Iface, exiting."; - goto shutdown; - } - - touchscreenGesture = new TouchscreenGesture(); - if (touchscreenGesture == nullptr) { - LOG(ERROR) << "Can not create an instance of Touch HAL TouchscreenGesture Iface, exiting."; - goto shutdown; - } - - configureRpcThreadpool(1, true /*callerWillJoin*/); - - if (gloveMode->isSupported()) { - status = gloveMode->registerAsService(); - if (status != OK) { - LOG(ERROR) << "Could not register service for Touch HAL GloveMode Iface (" << status - << ")"; - goto shutdown; - } - } - - if (keyDisabler->isSupported()) { - status = keyDisabler->registerAsService(); - if (status != OK) { - LOG(ERROR) << "Could not register service for Touch HAL KeyDisabler Iface (" << status - << ")"; - goto shutdown; - } - } - - if (stylusMode->isSupported()) { - status = stylusMode->registerAsService(); - if (status != OK) { - LOG(ERROR) << "Could not register service for Touch HAL StylusMode Iface (" << status - << ")"; - goto shutdown; - } - } - - if (touchscreenGesture->isSupported()) { - status = touchscreenGesture->registerAsService(); - if (status != OK) { - LOG(ERROR) << "Could not register service for Touch HAL TouchscreenGesture Iface (" - << status << ")"; - goto shutdown; - } - } - - LOG(INFO) << "Touch HAL service is ready."; - joinRpcThreadpool(); -// Should not pass this line - -shutdown: - // In normal operation, we don't expect the thread pool to shutdown - LOG(ERROR) << "Touch HAL service is shutting down."; - return 1; -} diff --git a/lineagehw/hidl/touch/vendor.lineage.touch@1.0-service.samsung.rc b/lineagehw/hidl/touch/vendor.lineage.touch@1.0-service.samsung.rc deleted file mode 100644 index 2f0d14f..0000000 --- a/lineagehw/hidl/touch/vendor.lineage.touch@1.0-service.samsung.rc +++ /dev/null @@ -1,4 +0,0 @@ -service vendor.touch-hal-1-0-samsung /vendor/bin/hw/vendor.lineage.touch@1.0-service.samsung - class hal - user system - group system