sm8250-common: livedisplay: uprev to 2.1

This commit is contained in:
SGCMarkus 2022-03-06 23:02:20 +01:00
parent 969edb23b4
commit 3c0cba0748
14 changed files with 193 additions and 35 deletions

View File

@ -164,7 +164,7 @@ DEVICE_FRAMEWORK_COMPATIBILITY_MATRIX_FILE := \
$(COMMON_PATH)/device_framework_matrix.xml \
vendor/lineage/config/device_framework_matrix.xml
DEVICE_MATRIX_FILE := $(COMMON_PATH)/compatibility_matrix.xml
DEVICE_MANIFEST_FILE := $(COMMON_PATH)/manifest.xml
DEVICE_MANIFEST_FILE += $(COMMON_PATH)/manifest.xml
# Metadata
BOARD_USES_METADATA_PARTITION := true

View File

@ -1,5 +1,5 @@
/*
* Copyright (C) 2019-2020 The LineageOS Project
* 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.
@ -34,8 +34,8 @@ namespace {
namespace vendor {
namespace lineage {
namespace livedisplay {
namespace V2_0 {
namespace sysfs {
namespace V2_1 {
namespace implementation {
AdaptiveBacklight::AdaptiveBacklight() {
if (!access(kFileAcl, R_OK | W_OK)) {
@ -54,7 +54,7 @@ bool AdaptiveBacklight::isSupported() {
return true;
}
// Methods from ::vendor::lineage::livedisplay::V2_0::IAdaptiveBacklight follow.
// Methods from ::vendor::lineage::livedisplay::V2_1::IAdaptiveBacklight follow.
Return<bool> AdaptiveBacklight::isEnabled() {
std::string tmp;
int32_t contents = 0;
@ -70,8 +70,8 @@ Return<bool> AdaptiveBacklight::setEnabled(bool enabled) {
return WriteStringToFile(std::to_string(enabled), file_, true);
}
} // namespace sysfs
} // namespace V2_0
} // namespace implementation
} // namespace V2_1
} // namespace livedisplay
} // namespace lineage
} // namespace vendor

View File

@ -1,5 +1,5 @@
/*
* Copyright (C) 2019-2020 The LineageOS Project
* 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.
@ -16,13 +16,13 @@
#pragma once
#include <vendor/lineage/livedisplay/2.0/IAdaptiveBacklight.h>
#include <vendor/lineage/livedisplay/2.1/IAdaptiveBacklight.h>
namespace vendor {
namespace lineage {
namespace livedisplay {
namespace V2_0 {
namespace sysfs {
namespace V2_1 {
namespace implementation {
using ::android::hardware::Return;
@ -31,7 +31,7 @@ class AdaptiveBacklight : public IAdaptiveBacklight {
AdaptiveBacklight();
bool isSupported();
// Methods from ::vendor::lineage::livedisplay::V2_0::IAdaptiveBacklight follow.
// Methods from ::vendor::lineage::livedisplay::V2_1::IAdaptiveBacklight follow.
Return<bool> isEnabled() override;
Return<bool> setEnabled(bool enabled) override;
@ -39,8 +39,8 @@ class AdaptiveBacklight : public IAdaptiveBacklight {
const char* file_;
};
} // namespace sysfs
} // namespace V2_0
} // namespace implementation
} // namespace V2_1
} // namespace livedisplay
} // namespace lineage
} // namespace vendor

View File

@ -20,6 +20,7 @@ cc_defaults {
":vendor.lineage.livedisplay@2.0-sdm-pa",
":vendor.lineage.livedisplay@2.0-sdm-utils",
"AdaptiveBacklight.cpp",
"AntiFlicker.cpp",
"SunlightEnhancement.cpp",
"service.cpp",
],
@ -31,6 +32,7 @@ cc_defaults {
"libhidlbase",
"libutils",
"vendor.lineage.livedisplay@2.0",
"vendor.lineage.livedisplay@2.1",
],
header_libs: [
"vendor.lineage.livedisplay@2.0-sdm-headers",
@ -38,8 +40,8 @@ cc_defaults {
}
cc_binary {
name: "vendor.lineage.livedisplay@2.0-service-sysfs.motorola_kona",
init_rc: ["vendor.lineage.livedisplay@2.0-service-sysfs.motorola_kona.rc"],
name: "vendor.lineage.livedisplay@2.1-service.motorola_kona",
init_rc: ["vendor.lineage.livedisplay@2.1-service.motorola_kona.rc"],
defaults: ["livedisplay_motorola_kona"],
vendor: true,
}

View File

@ -0,0 +1,69 @@
/*
* 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.
*/
#include "AntiFlicker.h"
#include <android-base/file.h>
#include <android-base/strings.h>
namespace {
constexpr const char *kFileDc = "/sys/devices/platform/soc/soc:qcom,dsi-display-primary/dsi_display_dc";
}; // anonymous namespace
using ::android::base::ReadFileToString;
using ::android::base::Trim;
using ::android::base::WriteStringToFile;
namespace vendor {
namespace lineage {
namespace livedisplay {
namespace V2_1 {
namespace implementation {
AntiFlicker::AntiFlicker() {
if (!access(kFileDc, R_OK | W_OK)) {
file_ = kFileDc;
enabled_mode_ = 1;
} else {
file_ = nullptr;
}
}
bool AntiFlicker::isSupported() {
return file_ != nullptr;
}
// Methods from ::vendor::lineage::livedisplay::V2_1::IAntiFlicker follow.
Return<bool> AntiFlicker::isEnabled() {
std::string tmp;
int32_t contents = 0;
if (ReadFileToString(file_, &tmp)) {
contents = std::stoi(Trim(tmp));
}
return contents > 0;
}
Return<bool> AntiFlicker::setEnabled(bool enabled) {
return WriteStringToFile(enabled ? std::to_string(enabled_mode_) : "0", file_, true);
}
} // namespace implementation
} // namespace V2_1
} // namespace livedisplay
} // namespace lineage
} // namespace vendor

47
livedisplay/AntiFlicker.h Normal file
View File

@ -0,0 +1,47 @@
/*
* 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 <vendor/lineage/livedisplay/2.1/IAntiFlicker.h>
namespace vendor {
namespace lineage {
namespace livedisplay {
namespace V2_1 {
namespace implementation {
using ::android::hardware::Return;
class AntiFlicker : public IAntiFlicker {
public:
AntiFlicker();
bool isSupported();
// Methods from ::vendor::lineage::livedisplay::V2_1::IAntiFlicker follow.
Return<bool> isEnabled() override;
Return<bool> setEnabled(bool enabled) override;
private:
const char* file_;
int32_t enabled_mode_;
};
} // namespace implementation
} // namespace V2_1
} // namespace livedisplay
} // namespace lineage
} // namespace vendor

View File

@ -1,5 +1,5 @@
/*
* Copyright (C) 2019-2020 The LineageOS Project
* 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.
@ -30,8 +30,8 @@ using ::android::base::WriteStringToFile;
namespace vendor {
namespace lineage {
namespace livedisplay {
namespace V2_0 {
namespace sysfs {
namespace V2_1 {
namespace implementation {
SunlightEnhancement::SunlightEnhancement() {
if (!access(kFileHbm, R_OK | W_OK)) {
@ -46,7 +46,7 @@ bool SunlightEnhancement::isSupported() {
return file_ != nullptr;
}
// Methods from ::vendor::lineage::livedisplay::V2_0::ISunlightEnhancement follow.
// Methods from ::vendor::lineage::livedisplay::V2_1::ISunlightEnhancement follow.
Return<bool> SunlightEnhancement::isEnabled() {
std::string tmp;
int32_t contents = 0;
@ -62,8 +62,8 @@ Return<bool> SunlightEnhancement::setEnabled(bool enabled) {
return WriteStringToFile(enabled ? std::to_string(enabled_mode_) : "0", file_, true);
}
} // namespace sysfs
} // namespace V2_0
} // namespace implementation
} // namespace V2_1
} // namespace livedisplay
} // namespace lineage
} // namespace vendor

View File

@ -1,5 +1,5 @@
/*
* Copyright (C) 2019-2020 The LineageOS Project
* 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.
@ -16,13 +16,13 @@
#pragma once
#include <vendor/lineage/livedisplay/2.0/ISunlightEnhancement.h>
#include <vendor/lineage/livedisplay/2.1/ISunlightEnhancement.h>
namespace vendor {
namespace lineage {
namespace livedisplay {
namespace V2_0 {
namespace sysfs {
namespace V2_1 {
namespace implementation {
using ::android::hardware::Return;
@ -31,7 +31,7 @@ class SunlightEnhancement : public ISunlightEnhancement {
SunlightEnhancement();
bool isSupported();
// Methods from ::vendor::lineage::livedisplay::V2_0::ISunlightEnhancement follow.
// Methods from ::vendor::lineage::livedisplay::V2_1::ISunlightEnhancement follow.
Return<bool> isEnabled() override;
Return<bool> setEnabled(bool enabled) override;
@ -40,8 +40,8 @@ class SunlightEnhancement : public ISunlightEnhancement {
int32_t enabled_mode_;
};
} // namespace sysfs
} // namespace V2_0
} // namespace implementation
} // namespace V2_1
} // namespace livedisplay
} // namespace lineage
} // namespace vendor

View File

@ -14,11 +14,15 @@
* limitations under the License.
*/
#define LOG_TAG "vendor.lineage.livedisplay@2.0-service-sysfs.motorola_kona"
#define LOG_TAG "vendor.lineage.livedisplay@2.1-service.motorola_kona"
#include <android-base/logging.h>
#include <binder/ProcessState.h>
#include <hidl/HidlTransportSupport.h>
#include <livedisplay/sdm/PictureAdjustment.h>
#include <vendor/lineage/livedisplay/2.1/IPictureAdjustment.h>
#include "AdaptiveBacklight.h"
#include "AntiFlicker.h"
#include "SunlightEnhancement.h"
using ::android::OK;
@ -27,8 +31,12 @@ using ::android::status_t;
using ::android::hardware::configureRpcThreadpool;
using ::android::hardware::joinRpcThreadpool;
using ::vendor::lineage::livedisplay::V2_0::sysfs::AdaptiveBacklight;
using ::vendor::lineage::livedisplay::V2_0::sysfs::SunlightEnhancement;
using ::vendor::lineage::livedisplay::V2_0::sdm::PictureAdjustment;
using ::vendor::lineage::livedisplay::V2_0::sdm::SDMController;
using ::vendor::lineage::livedisplay::V2_1::IPictureAdjustment;
using ::vendor::lineage::livedisplay::V2_1::implementation::AdaptiveBacklight;
using ::vendor::lineage::livedisplay::V2_1::implementation::AntiFlicker;
using ::vendor::lineage::livedisplay::V2_1::implementation::SunlightEnhancement;
status_t RegisterAsServices() {
status_t status = OK;
@ -52,11 +60,32 @@ status_t RegisterAsServices() {
return status;
}
}
sp<AntiFlicker> af = new AntiFlicker();
if (af->isSupported()) {
status = af->registerAsService();
if (status != OK) {
LOG(ERROR) << "Could not register service for LiveDisplay HAL AntiFlicker Iface"
<< " (" << status << ")";
return status;
}
}
std::shared_ptr<SDMController> controller = std::make_shared<SDMController>();
sp<PictureAdjustment> pa = new PictureAdjustment(controller);
status = pa->registerAsService();
if (status != OK) {
LOG(ERROR) << "Could not register service for LiveDisplay HAL PictureAdjustment Iface ("
<< status << ")";
return status;
}
return OK;
}
int main() {
android::ProcessState::initWithDriver("/dev/vndbinder");
LOG(DEBUG) << "LiveDisplay HAL service is starting.";
configureRpcThreadpool(1, true /*callerWillJoin*/);

View File

@ -6,8 +6,10 @@ on init
chmod 0660 /sys/devices/platform/soc/soc:qcom,dsi-display-primary/dsi_display_cabc
chown system system /sys/devices/platform/soc/soc:qcom,dsi-display-primary/dsi_display_hbm
chmod 0660 /sys/devices/platform/soc/soc:qcom,dsi-display-primary/dsi_display_hbm
chown system system /sys/devices/platform/soc/soc:qcom,dsi-display-primary/dsi_display_dc
chmod 0660 /sys/devices/platform/soc/soc:qcom,dsi-display-primary/dsi_display_dc
service vendor.livedisplay-hal-2-0-sysfs /vendor/bin/hw/vendor.lineage.livedisplay@2.0-service-sysfs.motorola_kona
service vendor.livedisplay-hal-2-1 /vendor/bin/hw/vendor.lineage.livedisplay@2.1-service.motorola_kona
class hal
user system
group system

View File

@ -56,6 +56,9 @@
# Lights
/(vendor|system/vendor)/bin/hw/android\.hardware\.lights-service\.motokona u:object_r:hal_light_default_exec:s0
# LiveDisplay
/(vendor|system/vendor)/bin/hw/vendor\.lineage\.livedisplay@2\.1-service\.motorola_kona u:object_r:hal_lineage_livedisplay_qti_exec:s0
# Motobox
/(vendor|system/vendor)/bin/motobox u:object_r:vendor_motobox_exec:s0

View File

@ -18,6 +18,12 @@ genfscon sysfs /devices/virtual/input
# Lights
genfscon sysfs /devices/platform/soc/c440000.qcom,spmi/spmi-0/spmi0-05/c440000.qcom,spmi:qcom,pm8150l@5:qcom,leds@d000/leds/charging u:object_r:sysfs_leds:s0
# LiveDisplay
genfscon sysfs /devices/platform/soc/soc:qcom,dsi-display-primary/dsi_display_acl u:object_r:sysfs_livedisplay_tuneable:s0
genfscon sysfs /devices/platform/soc/soc:qcom,dsi-display-primary/dsi_display_cabc u:object_r:sysfs_livedisplay_tuneable:s0
genfscon sysfs /devices/platform/soc/soc:qcom,dsi-display-primary/dsi_display_hbm u:object_r:sysfs_livedisplay_tuneable:s0
genfscon sysfs /devices/platform/soc/soc:qcom,dsi-display-primary/dsi_display_dc u:object_r:sysfs_livedisplay_tuneable:s0
# Motorola
genfscon proc /bootinfo u:object_r:proc_moto_boot:s0
genfscon proc /config u:object_r:vendor_proc_hw:s0

View File

@ -0,0 +1 @@
allow hal_lineage_livedisplay_qti sysfs_livedisplay_tuneable:file rw_file_perms;

View File

@ -250,8 +250,7 @@ PRODUCT_PACKAGES += \
# LiveDisplay
PRODUCT_PACKAGES += \
vendor.lineage.livedisplay@2.0-service-sdm \
vendor.lineage.livedisplay@2.0-service-sysfs.motorola_kona
vendor.lineage.livedisplay@2.1-service.motorola_kona
# Media
PRODUCT_COPY_FILES += \