From 622f8070f3baa39b48db8abf9a88c2042ebcae59 Mon Sep 17 00:00:00 2001 From: LuK1337 Date: Fri, 15 Aug 2025 10:12:25 +0200 Subject: [PATCH] livedisplay: Migrate to AIDL Change-Id: I8dbe9ed99549aff3e7fcff553482a4c45aae67ef --- aidl/livedisplay/Android.bp | 78 +++++++++++++ aidl/livedisplay/AntiFlicker.cpp | 47 ++++++++ {hidl => aidl}/livedisplay/DisplayModes.cpp | 41 ++++--- aidl/livedisplay/SunlightEnhancement.cpp | 46 ++++++++ .../include/livedisplay/oplus/AntiFlicker.h | 30 +++++ .../include/livedisplay/oplus/DisplayModes.h | 49 ++++++++ .../livedisplay/oplus/SunlightEnhancement.h | 30 +++++ aidl/livedisplay/service.cpp | 66 +++++++++++ ...r.lineage.livedisplay-service.oplus-af.xml | 5 +- ...r.lineage.livedisplay-service.oplus-dm.xml | 5 +- ...r.lineage.livedisplay-service.oplus-pa.xml | 10 ++ ...r.lineage.livedisplay-service.oplus-se.xml | 5 +- ...endor.lineage.livedisplay-service.oplus.rc | 4 + hidl/livedisplay/Android.bp | 89 --------------- hidl/livedisplay/AntiFlicker.cpp | 44 -------- hidl/livedisplay/SunlightEnhancement.cpp | 43 ------- .../include/livedisplay/oplus/AntiFlicker.h | 49 -------- .../include/livedisplay/oplus/DisplayModes.h | 58 ---------- .../livedisplay/oplus/SunlightEnhancement.h | 49 -------- hidl/livedisplay/service.cpp | 106 ------------------ ...neage.livedisplay@2.1-service.oplus-pa.xml | 8 -- ...r.lineage.livedisplay@2.1-service.oplus.rc | 4 - sepolicy/qti/vendor/file_contexts | 2 +- 23 files changed, 386 insertions(+), 482 deletions(-) create mode 100644 aidl/livedisplay/Android.bp create mode 100644 aidl/livedisplay/AntiFlicker.cpp rename {hidl => aidl}/livedisplay/DisplayModes.cpp (64%) create mode 100644 aidl/livedisplay/SunlightEnhancement.cpp create mode 100644 aidl/livedisplay/include/livedisplay/oplus/AntiFlicker.h create mode 100644 aidl/livedisplay/include/livedisplay/oplus/DisplayModes.h create mode 100644 aidl/livedisplay/include/livedisplay/oplus/SunlightEnhancement.h create mode 100644 aidl/livedisplay/service.cpp rename hidl/livedisplay/vendor.lineage.livedisplay@2.1-service.oplus-af.xml => aidl/livedisplay/vendor.lineage.livedisplay-service.oplus-af.xml (70%) rename hidl/livedisplay/vendor.lineage.livedisplay@2.1-service.oplus-dm.xml => aidl/livedisplay/vendor.lineage.livedisplay-service.oplus-dm.xml (70%) create mode 100644 aidl/livedisplay/vendor.lineage.livedisplay-service.oplus-pa.xml rename hidl/livedisplay/vendor.lineage.livedisplay@2.1-service.oplus-se.xml => aidl/livedisplay/vendor.lineage.livedisplay-service.oplus-se.xml (71%) create mode 100644 aidl/livedisplay/vendor.lineage.livedisplay-service.oplus.rc delete mode 100644 hidl/livedisplay/Android.bp delete mode 100644 hidl/livedisplay/AntiFlicker.cpp delete mode 100644 hidl/livedisplay/SunlightEnhancement.cpp delete mode 100644 hidl/livedisplay/include/livedisplay/oplus/AntiFlicker.h delete mode 100644 hidl/livedisplay/include/livedisplay/oplus/DisplayModes.h delete mode 100644 hidl/livedisplay/include/livedisplay/oplus/SunlightEnhancement.h delete mode 100644 hidl/livedisplay/service.cpp delete mode 100644 hidl/livedisplay/vendor.lineage.livedisplay@2.1-service.oplus-pa.xml delete mode 100644 hidl/livedisplay/vendor.lineage.livedisplay@2.1-service.oplus.rc diff --git a/aidl/livedisplay/Android.bp b/aidl/livedisplay/Android.bp new file mode 100644 index 0000000..58d3fc2 --- /dev/null +++ b/aidl/livedisplay/Android.bp @@ -0,0 +1,78 @@ +// +// SPDX-FileCopyrightText: 2019-2025 The LineageOS Project +// SPDX-License-Identifier: Apache-2.0 +// + +filegroup { + name: "vendor.lineage.livedisplay-oplus-af", + srcs: ["AntiFlicker.cpp"], +} + +filegroup { + name: "vendor.lineage.livedisplay-oplus-dm", + srcs: ["DisplayModes.cpp"], +} + +filegroup { + name: "vendor.lineage.livedisplay-oplus-se", + srcs: ["SunlightEnhancement.cpp"], +} + +cc_library_headers { + name: "vendor.lineage.livedisplay-oplus-headers", + vendor_available: true, + export_include_dirs: ["include"], +} + +cc_binary { + name: "vendor.lineage.livedisplay-service.oplus", + init_rc: ["vendor.lineage.livedisplay-service.oplus.rc"], + vintf_fragments: select(soong_config_variable("OPLUS_LINEAGE_LIVEDISPLAY_HAL", "ENABLE_AF"), { + "true": ["vendor.lineage.livedisplay-service.oplus-af.xml"], + default: [], + }) + select(soong_config_variable("OPLUS_LINEAGE_LIVEDISPLAY_HAL", "ENABLE_DM"), { + "true": ["vendor.lineage.livedisplay-service.oplus-dm.xml"], + default: [], + }) + select(soong_config_variable("OPLUS_LINEAGE_LIVEDISPLAY_HAL", "ENABLE_PA"), { + "false": [], + default: ["vendor.lineage.livedisplay-service.oplus-pa.xml"], + }) + select(soong_config_variable("OPLUS_LINEAGE_LIVEDISPLAY_HAL", "ENABLE_SE"), { + "false": [], + default: ["vendor.lineage.livedisplay-service.oplus-se.xml"], + }), + relative_install_path: "hw", + srcs: [ + ":vendor.lineage.livedisplay-sdm-pa", + ":vendor.lineage.livedisplay-sdm-utils", + ":vendor.lineage.livedisplay-oplus-af", + ":vendor.lineage.livedisplay-oplus-dm", + ":vendor.lineage.livedisplay-oplus-se", + "service.cpp", + ], + shared_libs: [ + "libbase", + "libbinder_ndk", + "libbinder", + "libutils", + "vendor.lineage.livedisplay-V1-ndk", + ], + header_libs: [ + "kernel_headers.oplus", + "vendor.lineage.livedisplay-sdm-headers", + "vendor.lineage.livedisplay-oplus-headers", + ], + cflags: select(soong_config_variable("OPLUS_LINEAGE_LIVEDISPLAY_HAL", "ENABLE_AF"), { + "true": ["-DENABLE_AF=true"], + default: ["-DENABLE_AF=false"], + }) + select(soong_config_variable("OPLUS_LINEAGE_LIVEDISPLAY_HAL", "ENABLE_DM"), { + "true": ["-DENABLE_DM=true"], + default: ["-DENABLE_DM=false"], + }) + select(soong_config_variable("OPLUS_LINEAGE_LIVEDISPLAY_HAL", "ENABLE_PA"), { + "false": ["-DENABLE_PA=false"], + default: ["-DENABLE_PA=true"], + }) + select(soong_config_variable("OPLUS_LINEAGE_LIVEDISPLAY_HAL", "ENABLE_SE"), { + "false": ["-DENABLE_SE=false"], + default: ["-DENABLE_SE=true"], + }), + proprietary: true, +} diff --git a/aidl/livedisplay/AntiFlicker.cpp b/aidl/livedisplay/AntiFlicker.cpp new file mode 100644 index 0000000..5743691 --- /dev/null +++ b/aidl/livedisplay/AntiFlicker.cpp @@ -0,0 +1,47 @@ +/* + * SPDX-FileCopyrightText: 2022-2025 The LineageOS Project + * SPDX-License-Identifier: Apache-2.0 + */ + +#define LOG_TAG "AntiFlickerService" + +#include +#include +#include +#include + +namespace aidl { +namespace vendor { +namespace lineage { +namespace livedisplay { + +AntiFlicker::AntiFlicker() : mOplusDisplayFd(open("/dev/oplus_display", O_RDWR)) {} + +ndk::ScopedAStatus AntiFlicker::getEnabled(bool* _aidl_return) { + unsigned int value; + if (ioctl(mOplusDisplayFd, PANEL_IOCTL_GET_DIMLAYER_BL_EN, &value) != 0) { + LOG(ERROR) << "Failed to read current AntiFlicker state"; + return ndk::ScopedAStatus::fromExceptionCode(EX_UNSUPPORTED_OPERATION); + } + *_aidl_return = value > 0; + return ndk::ScopedAStatus::ok(); +} + +ndk::ScopedAStatus AntiFlicker::setEnabled(bool enabled) { + bool isEnabled; + if (auto status = getEnabled(&isEnabled); !status.isOk()) { + return status; + } + unsigned int value = enabled; + if (isEnabled != enabled && + ioctl(mOplusDisplayFd, PANEL_IOCTL_SET_DIMLAYER_BL_EN, &value) != 0) { + LOG(ERROR) << "Failed to set AntiFlicker state"; + return ndk::ScopedAStatus::fromExceptionCode(EX_UNSUPPORTED_OPERATION); + } + return ndk::ScopedAStatus::ok(); +} + +} // namespace livedisplay +} // namespace lineage +} // namespace vendor +} // namespace aidl diff --git a/hidl/livedisplay/DisplayModes.cpp b/aidl/livedisplay/DisplayModes.cpp similarity index 64% rename from hidl/livedisplay/DisplayModes.cpp rename to aidl/livedisplay/DisplayModes.cpp index 7c85dbc..b947db6 100644 --- a/hidl/livedisplay/DisplayModes.cpp +++ b/aidl/livedisplay/DisplayModes.cpp @@ -1,6 +1,5 @@ /* - * Copyright (C) 2019 The LineageOS Project - * + * SPDX-FileCopyrightText: 2019-2025 The LineageOS Project * SPDX-License-Identifier: Apache-2.0 */ @@ -13,11 +12,10 @@ #include #include +namespace aidl { namespace vendor { namespace lineage { namespace livedisplay { -namespace V2_1 { -namespace implementation { static const std::string kModeBasePath = "/sys/class/drm/card0-DSI-1/"; static const std::string kDefaultPath = "/data/vendor/display/default_display_mode"; @@ -30,8 +28,8 @@ const std::map DisplayModes::kModeMap = { {3, {"Brilliant", 4, 0}}, }; -DisplayModes::DisplayModes(std::shared_ptr controller) - : mController(std::move(controller)), +DisplayModes::DisplayModes(std::shared_ptr controller) + : mController(controller), mOplusDisplayFd(open("/dev/oplus_display", O_RDWR)), mCurrentModeId(0), mDefaultModeId(0) { @@ -43,31 +41,31 @@ DisplayModes::DisplayModes(std::shared_ptr controller) setDisplayMode(mDefaultModeId, false); } -// Methods from ::vendor::lineage::livedisplay::V2_1::IDisplayModes follow. -Return DisplayModes::getDisplayModes(getDisplayModes_cb resultCb) { - std::vector modes; +// Methods from ::aidl::vendor::lineage::livedisplay::BnDisplayModes follow. +ndk::ScopedAStatus DisplayModes::getDisplayModes(std::vector* _aidl_return) { + std::vector modes; for (const auto& entry : kModeMap) { modes.push_back({entry.first, entry.second.name}); } - resultCb(modes); - return Void(); + *_aidl_return = modes; + return ndk::ScopedAStatus::ok(); } -Return DisplayModes::getCurrentDisplayMode(getCurrentDisplayMode_cb resultCb) { - resultCb({mCurrentModeId, kModeMap.at(mCurrentModeId).name}); - return Void(); +ndk::ScopedAStatus DisplayModes::getCurrentDisplayMode(DisplayMode* _aidl_return) { + *_aidl_return = {mCurrentModeId, kModeMap.at(mCurrentModeId).name}; + return ndk::ScopedAStatus::ok(); } -Return DisplayModes::getDefaultDisplayMode(getDefaultDisplayMode_cb resultCb) { - resultCb({mDefaultModeId, kModeMap.at(mDefaultModeId).name}); - return Void(); +ndk::ScopedAStatus DisplayModes::getDefaultDisplayMode(DisplayMode* _aidl_return) { + *_aidl_return = {mDefaultModeId, kModeMap.at(mDefaultModeId).name}; + return ndk::ScopedAStatus::ok(); } -Return DisplayModes::setDisplayMode(int32_t modeID, bool makeDefault) { +ndk::ScopedAStatus DisplayModes::setDisplayMode(int32_t modeID, bool makeDefault) { const auto iter = kModeMap.find(modeID); if (iter == kModeMap.end()) { - return false; + return ndk::ScopedAStatus::fromExceptionCode(EX_UNSUPPORTED_OPERATION); } if (mOplusDisplayFd >= 0) { ioctl(mOplusDisplayFd, PANEL_IOCTL_SET_SEED, &iter->second.seedMode); @@ -85,11 +83,10 @@ Return DisplayModes::setDisplayMode(int32_t modeID, bool makeDefault) { if (mOnDisplayModeSet) { mOnDisplayModeSet(); } - return true; + return ndk::ScopedAStatus::ok(); } -} // namespace implementation -} // namespace V2_1 } // namespace livedisplay } // namespace lineage } // namespace vendor +} // namespace aidl diff --git a/aidl/livedisplay/SunlightEnhancement.cpp b/aidl/livedisplay/SunlightEnhancement.cpp new file mode 100644 index 0000000..22a3325 --- /dev/null +++ b/aidl/livedisplay/SunlightEnhancement.cpp @@ -0,0 +1,46 @@ +/* + * SPDX-FileCopyrightText: 2022-2025 The LineageOS Project + * SPDX-License-Identifier: Apache-2.0 + */ + +#define LOG_TAG "SunlightEnhancementService" + +#include +#include +#include +#include + +namespace aidl { +namespace vendor { +namespace lineage { +namespace livedisplay { + +SunlightEnhancement::SunlightEnhancement() : mOplusDisplayFd(open("/dev/oplus_display", O_RDWR)) {} + +ndk::ScopedAStatus SunlightEnhancement::getEnabled(bool* _aidl_return) { + unsigned int value; + if (ioctl(mOplusDisplayFd, PANEL_IOCTL_GET_HBM, &value) != 0) { + LOG(ERROR) << "Failed to read current SunlightEnhancement state"; + return ndk::ScopedAStatus::fromExceptionCode(EX_UNSUPPORTED_OPERATION); + } + *_aidl_return = value > 0; + return ndk::ScopedAStatus::ok(); +} + +ndk::ScopedAStatus SunlightEnhancement::setEnabled(bool enabled) { + bool isEnabled; + if (auto status = getEnabled(&isEnabled); !status.isOk()) { + return status; + } + unsigned int value = enabled; + if (isEnabled != enabled && ioctl(mOplusDisplayFd, PANEL_IOCTL_SET_HBM, &value) != 0) { + LOG(ERROR) << "Failed to set SunlightEnhancement state"; + return ndk::ScopedAStatus::fromExceptionCode(EX_UNSUPPORTED_OPERATION); + } + return ndk::ScopedAStatus::ok(); +} + +} // namespace livedisplay +} // namespace lineage +} // namespace vendor +} // namespace aidl diff --git a/aidl/livedisplay/include/livedisplay/oplus/AntiFlicker.h b/aidl/livedisplay/include/livedisplay/oplus/AntiFlicker.h new file mode 100644 index 0000000..431b9a0 --- /dev/null +++ b/aidl/livedisplay/include/livedisplay/oplus/AntiFlicker.h @@ -0,0 +1,30 @@ +/* + * SPDX-FileCopyrightText: 2021-2025 The LineageOS Project + * SPDX-License-Identifier: Apache-2.0 + */ + +#pragma once + +#include + +namespace aidl { +namespace vendor { +namespace lineage { +namespace livedisplay { + +class AntiFlicker : public BnAntiFlicker { + public: + AntiFlicker(); + + // Methods from ::aidl::vendor::lineage::livedisplay::BnAntiFlicker follow. + ndk::ScopedAStatus getEnabled(bool* _aidl_return) override; + ndk::ScopedAStatus setEnabled(bool enabled) override; + + private: + int mOplusDisplayFd; +}; + +} // namespace livedisplay +} // namespace lineage +} // namespace vendor +} // namespace aidl diff --git a/aidl/livedisplay/include/livedisplay/oplus/DisplayModes.h b/aidl/livedisplay/include/livedisplay/oplus/DisplayModes.h new file mode 100644 index 0000000..5ac77b9 --- /dev/null +++ b/aidl/livedisplay/include/livedisplay/oplus/DisplayModes.h @@ -0,0 +1,49 @@ +/* + * SPDX-FileCopyrightText: 2019-2025 The LineageOS Project + * SPDX-License-Identifier: Apache-2.0 + */ + +#pragma once + +#include +#include +#include + +namespace aidl { +namespace vendor { +namespace lineage { +namespace livedisplay { + +class DisplayModes : public BnDisplayModes { + public: + DisplayModes(std::shared_ptr controller); + + using DisplayModeSetCallback = std::function; + inline void registerDisplayModeSetCallback(DisplayModeSetCallback callback) { + mOnDisplayModeSet = callback; + } + + // Methods from ::aidl::vendor::lineage::livedisplay::BnDisplayModes follow. + ndk::ScopedAStatus getDisplayModes(std::vector* _aidl_return) override; + ndk::ScopedAStatus getCurrentDisplayMode(DisplayMode* _aidl_return) override; + ndk::ScopedAStatus getDefaultDisplayMode(DisplayMode* _aidl_return) override; + ndk::ScopedAStatus setDisplayMode(int32_t modeID, bool makeDefault) override; + + private: + struct ModeInfo { + std::string name; + int32_t displayModeId; + uint32_t seedMode; + }; + static const std::map kModeMap; + std::shared_ptr mController; + int32_t mOplusDisplayFd; + int32_t mCurrentModeId; + int32_t mDefaultModeId; + DisplayModeSetCallback mOnDisplayModeSet; +}; + +} // namespace livedisplay +} // namespace lineage +} // namespace vendor +} // namespace aidl diff --git a/aidl/livedisplay/include/livedisplay/oplus/SunlightEnhancement.h b/aidl/livedisplay/include/livedisplay/oplus/SunlightEnhancement.h new file mode 100644 index 0000000..a167e28 --- /dev/null +++ b/aidl/livedisplay/include/livedisplay/oplus/SunlightEnhancement.h @@ -0,0 +1,30 @@ +/* + * SPDX-FileCopyrightText: 2019-2025 The LineageOS Project + * SPDX-License-Identifier: Apache-2.0 + */ + +#pragma once + +#include + +namespace aidl { +namespace vendor { +namespace lineage { +namespace livedisplay { + +class SunlightEnhancement : public BnSunlightEnhancement { + public: + SunlightEnhancement(); + + // Methods from ::aidl::vendor::lineage::livedisplay::BnSunlightEnhancement follow. + ndk::ScopedAStatus getEnabled(bool* _aidl_return) override; + ndk::ScopedAStatus setEnabled(bool enabled) override; + + private: + int mOplusDisplayFd; +}; + +} // namespace livedisplay +} // namespace lineage +} // namespace vendor +} // namespace aidl diff --git a/aidl/livedisplay/service.cpp b/aidl/livedisplay/service.cpp new file mode 100644 index 0000000..17813c1 --- /dev/null +++ b/aidl/livedisplay/service.cpp @@ -0,0 +1,66 @@ +/* + * SPDX-FileCopyrightText: 2019-2025 The LineageOS Project + * SPDX-License-Identifier: Apache-2.0 + */ + +#define LOG_TAG "vendor.lineage.livedisplay-service-oplus" + +#include +#include +#include +#include +#include +#include +#include +#include + +using ::aidl::vendor::lineage::livedisplay::AntiFlicker; +using ::aidl::vendor::lineage::livedisplay::DisplayModes; +using ::aidl::vendor::lineage::livedisplay::SunlightEnhancement; +using ::aidl::vendor::lineage::livedisplay::sdm::PictureAdjustment; +using ::aidl::vendor::lineage::livedisplay::sdm::SDMController; + +int main() { + android::ProcessState::self()->setThreadPoolMaxThreadCount(1); + android::ProcessState::self()->startThreadPool(); + + LOG(INFO) << "LiveDisplay HAL service is starting."; + + std::shared_ptr controller = + ENABLE_DM || ENABLE_PA ? std::make_shared() : nullptr; + + std::shared_ptr af = ENABLE_AF ? ndk::SharedRefBase::make() : nullptr; + std::shared_ptr dm = + ENABLE_DM ? ndk::SharedRefBase::make(controller) : nullptr; + std::shared_ptr pa = + ENABLE_PA ? ndk::SharedRefBase::make(controller) : nullptr; + std::shared_ptr se = + ENABLE_SE ? ndk::SharedRefBase::make() : nullptr; + + if (af) { + std::string instance = std::string() + AntiFlicker::descriptor + "/default"; + binder_status_t status = AServiceManager_addService(af->asBinder().get(), instance.c_str()); + CHECK_EQ(status, STATUS_OK); + } + + if (dm) { + std::string instance = std::string() + DisplayModes::descriptor + "/default"; + binder_status_t status = AServiceManager_addService(dm->asBinder().get(), instance.c_str()); + CHECK_EQ(status, STATUS_OK); + } + + if (pa) { + std::string instance = std::string() + PictureAdjustment::descriptor + "/default"; + binder_status_t status = AServiceManager_addService(pa->asBinder().get(), instance.c_str()); + CHECK_EQ(status, STATUS_OK); + } + + if (se) { + std::string instance = std::string() + SunlightEnhancement::descriptor + "/default"; + binder_status_t status = AServiceManager_addService(se->asBinder().get(), instance.c_str()); + CHECK_EQ(status, STATUS_OK); + } + + ABinderProcess_joinThreadPool(); + return EXIT_FAILURE; // should not reach +} diff --git a/hidl/livedisplay/vendor.lineage.livedisplay@2.1-service.oplus-af.xml b/aidl/livedisplay/vendor.lineage.livedisplay-service.oplus-af.xml similarity index 70% rename from hidl/livedisplay/vendor.lineage.livedisplay@2.1-service.oplus-af.xml rename to aidl/livedisplay/vendor.lineage.livedisplay-service.oplus-af.xml index cb707dd..518cb5d 100644 --- a/hidl/livedisplay/vendor.lineage.livedisplay@2.1-service.oplus-af.xml +++ b/aidl/livedisplay/vendor.lineage.livedisplay-service.oplus-af.xml @@ -1,8 +1,7 @@ - + vendor.lineage.livedisplay - hwbinder - 2.1 + 1 IAntiFlicker default diff --git a/hidl/livedisplay/vendor.lineage.livedisplay@2.1-service.oplus-dm.xml b/aidl/livedisplay/vendor.lineage.livedisplay-service.oplus-dm.xml similarity index 70% rename from hidl/livedisplay/vendor.lineage.livedisplay@2.1-service.oplus-dm.xml rename to aidl/livedisplay/vendor.lineage.livedisplay-service.oplus-dm.xml index 126028f..91b4d45 100644 --- a/hidl/livedisplay/vendor.lineage.livedisplay@2.1-service.oplus-dm.xml +++ b/aidl/livedisplay/vendor.lineage.livedisplay-service.oplus-dm.xml @@ -1,8 +1,7 @@ - + vendor.lineage.livedisplay - hwbinder - 2.1 + 1 IDisplayModes default diff --git a/aidl/livedisplay/vendor.lineage.livedisplay-service.oplus-pa.xml b/aidl/livedisplay/vendor.lineage.livedisplay-service.oplus-pa.xml new file mode 100644 index 0000000..4df9bc8 --- /dev/null +++ b/aidl/livedisplay/vendor.lineage.livedisplay-service.oplus-pa.xml @@ -0,0 +1,10 @@ + + + vendor.lineage.livedisplay + 1 + + IPictureAdjustment + default + + + diff --git a/hidl/livedisplay/vendor.lineage.livedisplay@2.1-service.oplus-se.xml b/aidl/livedisplay/vendor.lineage.livedisplay-service.oplus-se.xml similarity index 71% rename from hidl/livedisplay/vendor.lineage.livedisplay@2.1-service.oplus-se.xml rename to aidl/livedisplay/vendor.lineage.livedisplay-service.oplus-se.xml index b4b1670..372f7e6 100644 --- a/hidl/livedisplay/vendor.lineage.livedisplay@2.1-service.oplus-se.xml +++ b/aidl/livedisplay/vendor.lineage.livedisplay-service.oplus-se.xml @@ -1,8 +1,7 @@ - + vendor.lineage.livedisplay - hwbinder - 2.1 + 1 ISunlightEnhancement default diff --git a/aidl/livedisplay/vendor.lineage.livedisplay-service.oplus.rc b/aidl/livedisplay/vendor.lineage.livedisplay-service.oplus.rc new file mode 100644 index 0000000..8855b76 --- /dev/null +++ b/aidl/livedisplay/vendor.lineage.livedisplay-service.oplus.rc @@ -0,0 +1,4 @@ +service vendor.livedisplay-hal /vendor/bin/hw/vendor.lineage.livedisplay-service.oplus + class late_start + user system + group system diff --git a/hidl/livedisplay/Android.bp b/hidl/livedisplay/Android.bp deleted file mode 100644 index 74627d7..0000000 --- a/hidl/livedisplay/Android.bp +++ /dev/null @@ -1,89 +0,0 @@ -// Copyright (C) 2019-2024 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. - -filegroup { - name: "vendor.lineage.livedisplay@2.1-oplus-af", - srcs: ["AntiFlicker.cpp"], -} - -filegroup { - name: "vendor.lineage.livedisplay@2.1-oplus-dm", - srcs: ["DisplayModes.cpp"], -} - -filegroup { - name: "vendor.lineage.livedisplay@2.1-oplus-se", - srcs: ["SunlightEnhancement.cpp"], -} - -cc_library_headers { - name: "vendor.lineage.livedisplay@2.1-oplus-headers", - vendor_available: true, - export_include_dirs: ["include"], -} - -cc_binary { - name: "vendor.lineage.livedisplay@2.1-service.oplus", - defaults: ["hidl_defaults"], - init_rc: ["vendor.lineage.livedisplay@2.1-service.oplus.rc"], - vintf_fragments: select(soong_config_variable("OPLUS_LINEAGE_LIVEDISPLAY_HAL", "ENABLE_AF"), { - "true": ["vendor.lineage.livedisplay@2.1-service.oplus-af.xml"], - default: [], - }) + select(soong_config_variable("OPLUS_LINEAGE_LIVEDISPLAY_HAL", "ENABLE_DM"), { - "true": ["vendor.lineage.livedisplay@2.1-service.oplus-dm.xml"], - default: [], - }) + select(soong_config_variable("OPLUS_LINEAGE_LIVEDISPLAY_HAL", "ENABLE_PA"), { - "false": [], - default: ["vendor.lineage.livedisplay@2.1-service.oplus-pa.xml"], - }) + select(soong_config_variable("OPLUS_LINEAGE_LIVEDISPLAY_HAL", "ENABLE_SE"), { - "false": [], - default: ["vendor.lineage.livedisplay@2.1-service.oplus-se.xml"], - }), - relative_install_path: "hw", - srcs: [ - ":vendor.lineage.livedisplay@2.0-sdm-pa", - ":vendor.lineage.livedisplay@2.0-sdm-utils", - ":vendor.lineage.livedisplay@2.1-oplus-af", - ":vendor.lineage.livedisplay@2.1-oplus-dm", - ":vendor.lineage.livedisplay@2.1-oplus-se", - "service.cpp", - ], - shared_libs: [ - "libbase", - "libbinder", - "libhidlbase", - "libutils", - "vendor.lineage.livedisplay@2.0", - "vendor.lineage.livedisplay@2.1", - ], - header_libs: [ - "kernel_headers.oplus", - "vendor.lineage.livedisplay@2.0-sdm-headers", - "vendor.lineage.livedisplay@2.1-oplus-headers", - ], - cflags: select(soong_config_variable("OPLUS_LINEAGE_LIVEDISPLAY_HAL", "ENABLE_AF"), { - "true": ["-DENABLE_AF=true"], - default: ["-DENABLE_AF=false"], - }) + select(soong_config_variable("OPLUS_LINEAGE_LIVEDISPLAY_HAL", "ENABLE_DM"), { - "true": ["-DENABLE_DM=true"], - default: ["-DENABLE_DM=false"], - }) + select(soong_config_variable("OPLUS_LINEAGE_LIVEDISPLAY_HAL", "ENABLE_PA"), { - "false": ["-DENABLE_PA=false"], - default: ["-DENABLE_PA=true"], - }) + select(soong_config_variable("OPLUS_LINEAGE_LIVEDISPLAY_HAL", "ENABLE_SE"), { - "false": ["-DENABLE_SE=false"], - default: ["-DENABLE_SE=true"], - }), - proprietary: true, -} diff --git a/hidl/livedisplay/AntiFlicker.cpp b/hidl/livedisplay/AntiFlicker.cpp deleted file mode 100644 index ab29c51..0000000 --- a/hidl/livedisplay/AntiFlicker.cpp +++ /dev/null @@ -1,44 +0,0 @@ -/* - * Copyright (C) 2022 The LineageOS Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include -#include -#include - -namespace vendor { -namespace lineage { -namespace livedisplay { -namespace V2_1 { -namespace implementation { - -AntiFlicker::AntiFlicker() : mOplusDisplayFd(open("/dev/oplus_display", O_RDWR)) {} - -Return AntiFlicker::isEnabled() { - unsigned int value; - return ioctl(mOplusDisplayFd, PANEL_IOCTL_GET_DIMLAYER_BL_EN, &value) == 0 && value > 0; -} - -Return AntiFlicker::setEnabled(bool enabled) { - unsigned int value = enabled; - return isEnabled() == enabled || - ioctl(mOplusDisplayFd, PANEL_IOCTL_SET_DIMLAYER_BL_EN, &value) == 0; -} - -} // namespace implementation -} // namespace V2_1 -} // namespace livedisplay -} // namespace lineage -} // namespace vendor diff --git a/hidl/livedisplay/SunlightEnhancement.cpp b/hidl/livedisplay/SunlightEnhancement.cpp deleted file mode 100644 index d1b6262..0000000 --- a/hidl/livedisplay/SunlightEnhancement.cpp +++ /dev/null @@ -1,43 +0,0 @@ -/* - * Copyright (C) 2022 The LineageOS Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include -#include -#include - -namespace vendor { -namespace lineage { -namespace livedisplay { -namespace V2_1 { -namespace implementation { - -SunlightEnhancement::SunlightEnhancement() : mOplusDisplayFd(open("/dev/oplus_display", O_RDWR)) {} - -Return SunlightEnhancement::isEnabled() { - unsigned int value; - return ioctl(mOplusDisplayFd, PANEL_IOCTL_GET_HBM, &value) == 0 && value > 0; -} - -Return SunlightEnhancement::setEnabled(bool enabled) { - unsigned int value = enabled; - return isEnabled() == enabled || ioctl(mOplusDisplayFd, PANEL_IOCTL_SET_HBM, &value) == 0; -} - -} // namespace implementation -} // namespace V2_1 -} // namespace livedisplay -} // namespace lineage -} // namespace vendor diff --git a/hidl/livedisplay/include/livedisplay/oplus/AntiFlicker.h b/hidl/livedisplay/include/livedisplay/oplus/AntiFlicker.h deleted file mode 100644 index 7ae910e..0000000 --- a/hidl/livedisplay/include/livedisplay/oplus/AntiFlicker.h +++ /dev/null @@ -1,49 +0,0 @@ -/* - * Copyright (C) 2021-2022 The LineageOS Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#pragma once - -#include -#include -#include - -namespace vendor { -namespace lineage { -namespace livedisplay { -namespace V2_1 { -namespace implementation { - -using ::android::sp; -using ::android::hardware::Return; -using ::android::hardware::Void; - -class AntiFlicker : public IAntiFlicker { - public: - AntiFlicker(); - - // Methods from ::vendor::lineage::livedisplay::V2_1::IAntiFlicker follow. - Return isEnabled() override; - Return setEnabled(bool enabled) override; - - private: - int mOplusDisplayFd; -}; - -} // namespace implementation -} // namespace V2_1 -} // namespace livedisplay -} // namespace lineage -} // namespace vendor diff --git a/hidl/livedisplay/include/livedisplay/oplus/DisplayModes.h b/hidl/livedisplay/include/livedisplay/oplus/DisplayModes.h deleted file mode 100644 index b102bf9..0000000 --- a/hidl/livedisplay/include/livedisplay/oplus/DisplayModes.h +++ /dev/null @@ -1,58 +0,0 @@ -/* - * Copyright (C) 2019 The LineageOS Project - * - * SPDX-License-Identifier: Apache-2.0 - */ - -#pragma once - -#include -#include -#include -#include -#include - -namespace vendor { -namespace lineage { -namespace livedisplay { -namespace V2_1 { -namespace implementation { - -using ::android::sp; -using ::android::hardware::Return; -using ::android::hardware::Void; - -class DisplayModes : public IDisplayModes { - public: - DisplayModes(std::shared_ptr controller); - - using DisplayModeSetCallback = std::function; - inline void registerDisplayModeSetCallback(DisplayModeSetCallback callback) { - mOnDisplayModeSet = callback; - } - - // Methods from ::vendor::lineage::livedisplay::V2_1::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; - - private: - struct ModeInfo { - std::string name; - int32_t displayModeId; - uint32_t seedMode; - }; - static const std::map kModeMap; - std::shared_ptr mController; - int32_t mOplusDisplayFd; - int32_t mCurrentModeId; - int32_t mDefaultModeId; - DisplayModeSetCallback mOnDisplayModeSet; -}; - -} // namespace implementation -} // namespace V2_1 -} // namespace livedisplay -} // namespace lineage -} // namespace vendor diff --git a/hidl/livedisplay/include/livedisplay/oplus/SunlightEnhancement.h b/hidl/livedisplay/include/livedisplay/oplus/SunlightEnhancement.h deleted file mode 100644 index 6cbc0f8..0000000 --- a/hidl/livedisplay/include/livedisplay/oplus/SunlightEnhancement.h +++ /dev/null @@ -1,49 +0,0 @@ -/* - * Copyright (C) 2019-2022 The LineageOS Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#pragma once - -#include -#include -#include - -namespace vendor { -namespace lineage { -namespace livedisplay { -namespace V2_1 { -namespace implementation { - -using ::android::sp; -using ::android::hardware::Return; -using ::android::hardware::Void; - -class SunlightEnhancement : public ISunlightEnhancement { - public: - SunlightEnhancement(); - - // Methods from ::vendor::lineage::livedisplay::V2_0::ISunlightEnhancement follow. - Return isEnabled() override; - Return setEnabled(bool enabled) override; - - private: - int mOplusDisplayFd; -}; - -} // namespace implementation -} // namespace V2_1 -} // namespace livedisplay -} // namespace lineage -} // namespace vendor diff --git a/hidl/livedisplay/service.cpp b/hidl/livedisplay/service.cpp deleted file mode 100644 index 6ab1584..0000000 --- a/hidl/livedisplay/service.cpp +++ /dev/null @@ -1,106 +0,0 @@ -/* - * Copyright (C) 2019-2024 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.livedisplay@2.1-service-oplus" - -#include -#include -#include -#include -#include -#include -#include -#include - -using ::android::OK; -using ::android::sp; -using ::android::status_t; -using ::android::hardware::configureRpcThreadpool; -using ::android::hardware::joinRpcThreadpool; - -using ::vendor::lineage::livedisplay::V2_0::sdm::PictureAdjustment; -using ::vendor::lineage::livedisplay::V2_0::sdm::SDMController; -using ::vendor::lineage::livedisplay::V2_1::IAntiFlicker; -using ::vendor::lineage::livedisplay::V2_1::IDisplayModes; -using ::vendor::lineage::livedisplay::V2_1::IPictureAdjustment; -using ::vendor::lineage::livedisplay::V2_1::ISunlightEnhancement; -using ::vendor::lineage::livedisplay::V2_1::implementation::AntiFlicker; -using ::vendor::lineage::livedisplay::V2_1::implementation::DisplayModes; -using ::vendor::lineage::livedisplay::V2_1::implementation::SunlightEnhancement; - -int main() { - status_t status = OK; - - android::ProcessState::initWithDriver("/dev/vndbinder"); - - LOG(INFO) << "LiveDisplay HAL service is starting."; - - std::shared_ptr controller = - ENABLE_DM || ENABLE_PA ? std::make_shared() : nullptr; - - sp af = ENABLE_AF ? new AntiFlicker() : nullptr; - sp dm = ENABLE_DM ? new DisplayModes(controller) : nullptr; - sp pa = ENABLE_PA ? new PictureAdjustment(controller) : nullptr; - sp se = ENABLE_SE ? new SunlightEnhancement() : nullptr; - - configureRpcThreadpool(1, true /*callerWillJoin*/); - - if (af) { - status = af->registerAsService(); - if (status != OK) { - LOG(ERROR) << "Could not register service for LiveDisplay HAL AntiFlicker Iface (" - << status << ")"; - goto shutdown; - } - } - - if (dm) { - status = dm->registerAsService(); - if (status != OK) { - LOG(ERROR) << "Could not register service for LiveDisplay HAL DisplayModes Iface (" - << status << ")"; - goto shutdown; - } - } - - if (pa) { - status = pa->registerAsService(); - if (status != OK) { - LOG(ERROR) << "Could not register service for LiveDisplay HAL PictureAdjustment Iface (" - << status << ")"; - goto shutdown; - } - } - - if (se) { - status = se->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.1-service.oplus-pa.xml b/hidl/livedisplay/vendor.lineage.livedisplay@2.1-service.oplus-pa.xml deleted file mode 100644 index 2b31f97..0000000 --- a/hidl/livedisplay/vendor.lineage.livedisplay@2.1-service.oplus-pa.xml +++ /dev/null @@ -1,8 +0,0 @@ - - - vendor.lineage.livedisplay - hwbinder - 2.1 - @2.0::IPictureAdjustment/default - - diff --git a/hidl/livedisplay/vendor.lineage.livedisplay@2.1-service.oplus.rc b/hidl/livedisplay/vendor.lineage.livedisplay@2.1-service.oplus.rc deleted file mode 100644 index 7abdf92..0000000 --- a/hidl/livedisplay/vendor.lineage.livedisplay@2.1-service.oplus.rc +++ /dev/null @@ -1,4 +0,0 @@ -service vendor.livedisplay-hal-2-1 /vendor/bin/hw/vendor.lineage.livedisplay@2.1-service.oplus - class late_start - user system - group system diff --git a/sepolicy/qti/vendor/file_contexts b/sepolicy/qti/vendor/file_contexts index 9d665ec..99553cb 100644 --- a/sepolicy/qti/vendor/file_contexts +++ b/sepolicy/qti/vendor/file_contexts @@ -25,7 +25,7 @@ /vendor/bin/hw/vendor\.oplus\.hardware\.commondcs-service u:object_r:hal_oplus_commondcs_aidl_exec:s0 # Display -/vendor/bin/hw/vendor\.lineage\.livedisplay@2\.1-service\.oplus u:object_r:hal_lineage_livedisplay_qti_exec:s0 +/vendor/bin/hw/vendor\.lineage\.livedisplay-service\.oplus u:object_r:hal_lineage_livedisplay_qti_exec:s0 /odm/bin/hw/vendor\.oplus\.hardware\.displaypanelfeature-service u:object_r:hal_oplus_displaypanelfeature_aidl_exec:s0 /dev/oplus_display u:object_r:graphics_device:s0