livedisplay: Migrate to AIDL

Change-Id: I8dbe9ed99549aff3e7fcff553482a4c45aae67ef
This commit is contained in:
LuK1337
2025-08-15 10:12:25 +02:00
parent 55dd4cee89
commit 622f8070f3
23 changed files with 386 additions and 482 deletions

View File

@@ -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,
}

View File

@@ -0,0 +1,47 @@
/*
* SPDX-FileCopyrightText: 2022-2025 The LineageOS Project
* SPDX-License-Identifier: Apache-2.0
*/
#define LOG_TAG "AntiFlickerService"
#include <android-base/logging.h>
#include <fcntl.h>
#include <livedisplay/oplus/AntiFlicker.h>
#include <oplus/oplus_display_panel.h>
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

View File

@@ -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 <oplus/oplus_display_panel.h>
#include <fstream>
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<int32_t, DisplayModes::ModeInfo> DisplayModes::kModeMap = {
{3, {"Brilliant", 4, 0}},
};
DisplayModes::DisplayModes(std::shared_ptr<V2_0::sdm::SDMController> controller)
: mController(std::move(controller)),
DisplayModes::DisplayModes(std::shared_ptr<sdm::SDMController> controller)
: mController(controller),
mOplusDisplayFd(open("/dev/oplus_display", O_RDWR)),
mCurrentModeId(0),
mDefaultModeId(0) {
@@ -43,31 +41,31 @@ DisplayModes::DisplayModes(std::shared_ptr<V2_0::sdm::SDMController> controller)
setDisplayMode(mDefaultModeId, false);
}
// Methods from ::vendor::lineage::livedisplay::V2_1::IDisplayModes follow.
Return<void> DisplayModes::getDisplayModes(getDisplayModes_cb resultCb) {
std::vector<V2_0::DisplayMode> modes;
// Methods from ::aidl::vendor::lineage::livedisplay::BnDisplayModes follow.
ndk::ScopedAStatus DisplayModes::getDisplayModes(std::vector<DisplayMode>* _aidl_return) {
std::vector<DisplayMode> 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<void> 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<void> 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<bool> 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<bool> 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

View File

@@ -0,0 +1,46 @@
/*
* SPDX-FileCopyrightText: 2022-2025 The LineageOS Project
* SPDX-License-Identifier: Apache-2.0
*/
#define LOG_TAG "SunlightEnhancementService"
#include <android-base/logging.h>
#include <fcntl.h>
#include <livedisplay/oplus/SunlightEnhancement.h>
#include <oplus/oplus_display_panel.h>
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

View File

@@ -0,0 +1,30 @@
/*
* SPDX-FileCopyrightText: 2021-2025 The LineageOS Project
* SPDX-License-Identifier: Apache-2.0
*/
#pragma once
#include <aidl/vendor/lineage/livedisplay/BnAntiFlicker.h>
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

View File

@@ -0,0 +1,49 @@
/*
* SPDX-FileCopyrightText: 2019-2025 The LineageOS Project
* SPDX-License-Identifier: Apache-2.0
*/
#pragma once
#include <aidl/vendor/lineage/livedisplay/BnDisplayModes.h>
#include <livedisplay/sdm/SDMController.h>
#include <map>
namespace aidl {
namespace vendor {
namespace lineage {
namespace livedisplay {
class DisplayModes : public BnDisplayModes {
public:
DisplayModes(std::shared_ptr<sdm::SDMController> controller);
using DisplayModeSetCallback = std::function<void()>;
inline void registerDisplayModeSetCallback(DisplayModeSetCallback callback) {
mOnDisplayModeSet = callback;
}
// Methods from ::aidl::vendor::lineage::livedisplay::BnDisplayModes follow.
ndk::ScopedAStatus getDisplayModes(std::vector<DisplayMode>* _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<int32_t, ModeInfo> kModeMap;
std::shared_ptr<sdm::SDMController> mController;
int32_t mOplusDisplayFd;
int32_t mCurrentModeId;
int32_t mDefaultModeId;
DisplayModeSetCallback mOnDisplayModeSet;
};
} // namespace livedisplay
} // namespace lineage
} // namespace vendor
} // namespace aidl

View File

@@ -0,0 +1,30 @@
/*
* SPDX-FileCopyrightText: 2019-2025 The LineageOS Project
* SPDX-License-Identifier: Apache-2.0
*/
#pragma once
#include <aidl/vendor/lineage/livedisplay/BnSunlightEnhancement.h>
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

View File

@@ -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 <android-base/logging.h>
#include <android/binder_manager.h>
#include <android/binder_process.h>
#include <binder/ProcessState.h>
#include <livedisplay/oplus/AntiFlicker.h>
#include <livedisplay/oplus/DisplayModes.h>
#include <livedisplay/oplus/SunlightEnhancement.h>
#include <livedisplay/sdm/PictureAdjustment.h>
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<SDMController> controller =
ENABLE_DM || ENABLE_PA ? std::make_shared<SDMController>() : nullptr;
std::shared_ptr<AntiFlicker> af = ENABLE_AF ? ndk::SharedRefBase::make<AntiFlicker>() : nullptr;
std::shared_ptr<DisplayModes> dm =
ENABLE_DM ? ndk::SharedRefBase::make<DisplayModes>(controller) : nullptr;
std::shared_ptr<PictureAdjustment> pa =
ENABLE_PA ? ndk::SharedRefBase::make<PictureAdjustment>(controller) : nullptr;
std::shared_ptr<SunlightEnhancement> se =
ENABLE_SE ? ndk::SharedRefBase::make<SunlightEnhancement>() : 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
}

View File

@@ -1,8 +1,7 @@
<manifest version="1.0" type="device">
<hal format="hidl">
<hal format="aidl">
<name>vendor.lineage.livedisplay</name>
<transport>hwbinder</transport>
<version>2.1</version>
<version>1</version>
<interface>
<name>IAntiFlicker</name>
<instance>default</instance>

View File

@@ -1,8 +1,7 @@
<manifest version="1.0" type="device">
<hal format="hidl">
<hal format="aidl">
<name>vendor.lineage.livedisplay</name>
<transport>hwbinder</transport>
<version>2.1</version>
<version>1</version>
<interface>
<name>IDisplayModes</name>
<instance>default</instance>

View File

@@ -0,0 +1,10 @@
<manifest version="1.0" type="device">
<hal format="aidl">
<name>vendor.lineage.livedisplay</name>
<version>1</version>
<interface>
<name>IPictureAdjustment</name>
<instance>default</instance>
</interface>
</hal>
</manifest>

View File

@@ -1,8 +1,7 @@
<manifest version="1.0" type="device">
<hal format="hidl">
<hal format="aidl">
<name>vendor.lineage.livedisplay</name>
<transport>hwbinder</transport>
<version>2.1</version>
<version>1</version>
<interface>
<name>ISunlightEnhancement</name>
<instance>default</instance>

View File

@@ -0,0 +1,4 @@
service vendor.livedisplay-hal /vendor/bin/hw/vendor.lineage.livedisplay-service.oplus
class late_start
user system
group system

View File

@@ -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,
}

View File

@@ -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 <fcntl.h>
#include <livedisplay/oplus/AntiFlicker.h>
#include <oplus/oplus_display_panel.h>
namespace vendor {
namespace lineage {
namespace livedisplay {
namespace V2_1 {
namespace implementation {
AntiFlicker::AntiFlicker() : mOplusDisplayFd(open("/dev/oplus_display", O_RDWR)) {}
Return<bool> AntiFlicker::isEnabled() {
unsigned int value;
return ioctl(mOplusDisplayFd, PANEL_IOCTL_GET_DIMLAYER_BL_EN, &value) == 0 && value > 0;
}
Return<bool> 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

View File

@@ -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 <fcntl.h>
#include <livedisplay/oplus/SunlightEnhancement.h>
#include <oplus/oplus_display_panel.h>
namespace vendor {
namespace lineage {
namespace livedisplay {
namespace V2_1 {
namespace implementation {
SunlightEnhancement::SunlightEnhancement() : mOplusDisplayFd(open("/dev/oplus_display", O_RDWR)) {}
Return<bool> SunlightEnhancement::isEnabled() {
unsigned int value;
return ioctl(mOplusDisplayFd, PANEL_IOCTL_GET_HBM, &value) == 0 && value > 0;
}
Return<bool> 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

View File

@@ -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 <hidl/MQDescriptor.h>
#include <hidl/Status.h>
#include <vendor/lineage/livedisplay/2.1/IAntiFlicker.h>
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<bool> isEnabled() override;
Return<bool> setEnabled(bool enabled) override;
private:
int mOplusDisplayFd;
};
} // namespace implementation
} // namespace V2_1
} // namespace livedisplay
} // namespace lineage
} // namespace vendor

View File

@@ -1,58 +0,0 @@
/*
* Copyright (C) 2019 The LineageOS Project
*
* SPDX-License-Identifier: Apache-2.0
*/
#pragma once
#include <hidl/MQDescriptor.h>
#include <hidl/Status.h>
#include <livedisplay/sdm/SDMController.h>
#include <vendor/lineage/livedisplay/2.1/IDisplayModes.h>
#include <map>
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<V2_0::sdm::SDMController> controller);
using DisplayModeSetCallback = std::function<void()>;
inline void registerDisplayModeSetCallback(DisplayModeSetCallback callback) {
mOnDisplayModeSet = callback;
}
// Methods from ::vendor::lineage::livedisplay::V2_1::IDisplayModes follow.
Return<void> getDisplayModes(getDisplayModes_cb resultCb) override;
Return<void> getCurrentDisplayMode(getCurrentDisplayMode_cb resultCb) override;
Return<void> getDefaultDisplayMode(getDefaultDisplayMode_cb ResultCb) override;
Return<bool> setDisplayMode(int32_t modeID, bool makeDefault) override;
private:
struct ModeInfo {
std::string name;
int32_t displayModeId;
uint32_t seedMode;
};
static const std::map<int32_t, ModeInfo> kModeMap;
std::shared_ptr<V2_0::sdm::SDMController> mController;
int32_t mOplusDisplayFd;
int32_t mCurrentModeId;
int32_t mDefaultModeId;
DisplayModeSetCallback mOnDisplayModeSet;
};
} // namespace implementation
} // namespace V2_1
} // namespace livedisplay
} // namespace lineage
} // namespace vendor

View File

@@ -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 <hidl/MQDescriptor.h>
#include <hidl/Status.h>
#include <vendor/lineage/livedisplay/2.1/ISunlightEnhancement.h>
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<bool> isEnabled() override;
Return<bool> setEnabled(bool enabled) override;
private:
int mOplusDisplayFd;
};
} // namespace implementation
} // namespace V2_1
} // namespace livedisplay
} // namespace lineage
} // namespace vendor

View File

@@ -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 <android-base/logging.h>
#include <binder/ProcessState.h>
#include <hidl/HidlTransportSupport.h>
#include <livedisplay/oplus/AntiFlicker.h>
#include <livedisplay/oplus/DisplayModes.h>
#include <livedisplay/oplus/SunlightEnhancement.h>
#include <livedisplay/sdm/PictureAdjustment.h>
#include <vendor/lineage/livedisplay/2.1/IPictureAdjustment.h>
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<SDMController> controller =
ENABLE_DM || ENABLE_PA ? std::make_shared<SDMController>() : nullptr;
sp<AntiFlicker> af = ENABLE_AF ? new AntiFlicker() : nullptr;
sp<DisplayModes> dm = ENABLE_DM ? new DisplayModes(controller) : nullptr;
sp<PictureAdjustment> pa = ENABLE_PA ? new PictureAdjustment(controller) : nullptr;
sp<SunlightEnhancement> 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;
}

View File

@@ -1,8 +0,0 @@
<manifest version="1.0" type="device">
<hal format="hidl">
<name>vendor.lineage.livedisplay</name>
<transport>hwbinder</transport>
<version>2.1</version>
<fqname>@2.0::IPictureAdjustment/default</fqname>
</hal>
</manifest>

View File

@@ -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

View File

@@ -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