sm8250-common: Import custom livedisplay
This commit is contained in:
parent
3b67381779
commit
b2b124d14a
77
livedisplay/AdaptiveBacklight.cpp
Normal file
77
livedisplay/AdaptiveBacklight.cpp
Normal file
@ -0,0 +1,77 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 2019-2020 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 "AdaptiveBacklight.h"
|
||||||
|
|
||||||
|
#include <android-base/file.h>
|
||||||
|
#include <android-base/properties.h>
|
||||||
|
#include <android-base/strings.h>
|
||||||
|
|
||||||
|
using ::android::base::GetBoolProperty;
|
||||||
|
using ::android::base::ReadFileToString;
|
||||||
|
using ::android::base::Trim;
|
||||||
|
using ::android::base::WriteStringToFile;
|
||||||
|
|
||||||
|
namespace {
|
||||||
|
constexpr const char *kFileAcl = "/sys/devices/platform/soc/soc:qcom,dsi-display-primary/dsi_display_acl";
|
||||||
|
constexpr const char *kFileCabc = "/sys/devices/platform/soc/soc:qcom,dsi-display-primary/dsi_display_cabc";
|
||||||
|
constexpr const char *kFossProperty = "ro.vendor.display.foss";
|
||||||
|
} // anonymous namespace
|
||||||
|
|
||||||
|
namespace vendor {
|
||||||
|
namespace lineage {
|
||||||
|
namespace livedisplay {
|
||||||
|
namespace V2_0 {
|
||||||
|
namespace sysfs {
|
||||||
|
|
||||||
|
AdaptiveBacklight::AdaptiveBacklight() {
|
||||||
|
if (!access(kFileAcl, R_OK | W_OK)) {
|
||||||
|
file_ = kFileAcl;
|
||||||
|
} else if (!access(kFileCabc, R_OK | W_OK)) {
|
||||||
|
file_ = kFileCabc;
|
||||||
|
} else {
|
||||||
|
file_ = nullptr;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
bool AdaptiveBacklight::isSupported() {
|
||||||
|
if (GetBoolProperty(kFossProperty, false) || file_ == nullptr) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Methods from ::vendor::lineage::livedisplay::V2_0::IAdaptiveBacklight follow.
|
||||||
|
Return<bool> AdaptiveBacklight::isEnabled() {
|
||||||
|
std::string tmp;
|
||||||
|
int32_t contents = 0;
|
||||||
|
|
||||||
|
if (ReadFileToString(file_, &tmp)) {
|
||||||
|
contents = std::stoi(Trim(tmp));
|
||||||
|
}
|
||||||
|
|
||||||
|
return contents > 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
Return<bool> AdaptiveBacklight::setEnabled(bool enabled) {
|
||||||
|
return WriteStringToFile(std::to_string(enabled), file_, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
} // namespace sysfs
|
||||||
|
} // namespace V2_0
|
||||||
|
} // namespace livedisplay
|
||||||
|
} // namespace lineage
|
||||||
|
} // namespace vendor
|
46
livedisplay/AdaptiveBacklight.h
Normal file
46
livedisplay/AdaptiveBacklight.h
Normal file
@ -0,0 +1,46 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 2019-2020 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.0/IAdaptiveBacklight.h>
|
||||||
|
|
||||||
|
namespace vendor {
|
||||||
|
namespace lineage {
|
||||||
|
namespace livedisplay {
|
||||||
|
namespace V2_0 {
|
||||||
|
namespace sysfs {
|
||||||
|
|
||||||
|
using ::android::hardware::Return;
|
||||||
|
|
||||||
|
class AdaptiveBacklight : public IAdaptiveBacklight {
|
||||||
|
public:
|
||||||
|
AdaptiveBacklight();
|
||||||
|
bool isSupported();
|
||||||
|
|
||||||
|
// Methods from ::vendor::lineage::livedisplay::V2_0::IAdaptiveBacklight follow.
|
||||||
|
Return<bool> isEnabled() override;
|
||||||
|
Return<bool> setEnabled(bool enabled) override;
|
||||||
|
|
||||||
|
private:
|
||||||
|
const char* file_;
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace sysfs
|
||||||
|
} // namespace V2_0
|
||||||
|
} // namespace livedisplay
|
||||||
|
} // namespace lineage
|
||||||
|
} // namespace vendor
|
46
livedisplay/Android.bp
Normal file
46
livedisplay/Android.bp
Normal file
@ -0,0 +1,46 @@
|
|||||||
|
// Copyright (C) 2019-2020 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_motorola_lito",
|
||||||
|
defaults: ["hidl_defaults"],
|
||||||
|
relative_install_path: "hw",
|
||||||
|
srcs: [
|
||||||
|
":vendor.lineage.livedisplay@2.0-sdm-pa",
|
||||||
|
":vendor.lineage.livedisplay@2.0-sdm-utils",
|
||||||
|
"AdaptiveBacklight.cpp",
|
||||||
|
"SunlightEnhancement.cpp",
|
||||||
|
"service.cpp",
|
||||||
|
],
|
||||||
|
shared_libs: [
|
||||||
|
"libbase",
|
||||||
|
"libbinder",
|
||||||
|
"libcutils",
|
||||||
|
"libdl",
|
||||||
|
"libhidlbase",
|
||||||
|
"libhidltransport",
|
||||||
|
"libutils",
|
||||||
|
"vendor.lineage.livedisplay@2.0",
|
||||||
|
],
|
||||||
|
header_libs: [
|
||||||
|
"vendor.lineage.livedisplay@2.0-sdm-headers",
|
||||||
|
],
|
||||||
|
}
|
||||||
|
|
||||||
|
cc_binary {
|
||||||
|
name: "vendor.lineage.livedisplay@2.0-service-sysfs.motorola_lito",
|
||||||
|
init_rc: ["vendor.lineage.livedisplay@2.0-service-sysfs.motorola_lito.rc"],
|
||||||
|
defaults: ["livedisplay_motorola_lito"],
|
||||||
|
vendor: true,
|
||||||
|
}
|
69
livedisplay/SunlightEnhancement.cpp
Normal file
69
livedisplay/SunlightEnhancement.cpp
Normal file
@ -0,0 +1,69 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 2019-2020 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 "SunlightEnhancement.h"
|
||||||
|
|
||||||
|
#include <android-base/file.h>
|
||||||
|
#include <android-base/strings.h>
|
||||||
|
|
||||||
|
namespace {
|
||||||
|
constexpr const char *kFileHbm = "/sys/devices/platform/soc/soc:qcom,dsi-display-primary/dsi_display_hbm";
|
||||||
|
}; // anonymous namespace
|
||||||
|
|
||||||
|
using ::android::base::ReadFileToString;
|
||||||
|
using ::android::base::Trim;
|
||||||
|
using ::android::base::WriteStringToFile;
|
||||||
|
|
||||||
|
namespace vendor {
|
||||||
|
namespace lineage {
|
||||||
|
namespace livedisplay {
|
||||||
|
namespace V2_0 {
|
||||||
|
namespace sysfs {
|
||||||
|
|
||||||
|
SunlightEnhancement::SunlightEnhancement() {
|
||||||
|
if (!access(kFileHbm, R_OK | W_OK)) {
|
||||||
|
file_ = kFileHbm;
|
||||||
|
enabled_mode_ = 1;
|
||||||
|
} else {
|
||||||
|
file_ = nullptr;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
bool SunlightEnhancement::isSupported() {
|
||||||
|
return file_ != nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Methods from ::vendor::lineage::livedisplay::V2_0::ISunlightEnhancement follow.
|
||||||
|
Return<bool> SunlightEnhancement::isEnabled() {
|
||||||
|
std::string tmp;
|
||||||
|
int32_t contents = 0;
|
||||||
|
|
||||||
|
if (ReadFileToString(file_, &tmp)) {
|
||||||
|
contents = std::stoi(Trim(tmp));
|
||||||
|
}
|
||||||
|
|
||||||
|
return contents > 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
Return<bool> SunlightEnhancement::setEnabled(bool enabled) {
|
||||||
|
return WriteStringToFile(enabled ? std::to_string(enabled_mode_) : "0", file_, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
} // namespace sysfs
|
||||||
|
} // namespace V2_0
|
||||||
|
} // namespace livedisplay
|
||||||
|
} // namespace lineage
|
||||||
|
} // namespace vendor
|
47
livedisplay/SunlightEnhancement.h
Normal file
47
livedisplay/SunlightEnhancement.h
Normal file
@ -0,0 +1,47 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 2019-2020 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.0/ISunlightEnhancement.h>
|
||||||
|
|
||||||
|
namespace vendor {
|
||||||
|
namespace lineage {
|
||||||
|
namespace livedisplay {
|
||||||
|
namespace V2_0 {
|
||||||
|
namespace sysfs {
|
||||||
|
|
||||||
|
using ::android::hardware::Return;
|
||||||
|
|
||||||
|
class SunlightEnhancement : public ISunlightEnhancement {
|
||||||
|
public:
|
||||||
|
SunlightEnhancement();
|
||||||
|
bool isSupported();
|
||||||
|
|
||||||
|
// Methods from ::vendor::lineage::livedisplay::V2_0::ISunlightEnhancement follow.
|
||||||
|
Return<bool> isEnabled() override;
|
||||||
|
Return<bool> setEnabled(bool enabled) override;
|
||||||
|
|
||||||
|
private:
|
||||||
|
const char* file_;
|
||||||
|
int32_t enabled_mode_;
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace sysfs
|
||||||
|
} // namespace V2_0
|
||||||
|
} // namespace livedisplay
|
||||||
|
} // namespace lineage
|
||||||
|
} // namespace vendor
|
74
livedisplay/service.cpp
Normal file
74
livedisplay/service.cpp
Normal file
@ -0,0 +1,74 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 2019-2020 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.0-service-sysfs.motorola_lito"
|
||||||
|
|
||||||
|
#include <android-base/logging.h>
|
||||||
|
#include <hidl/HidlTransportSupport.h>
|
||||||
|
#include "AdaptiveBacklight.h"
|
||||||
|
#include "SunlightEnhancement.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::sysfs::AdaptiveBacklight;
|
||||||
|
using ::vendor::lineage::livedisplay::V2_0::sysfs::SunlightEnhancement;
|
||||||
|
|
||||||
|
status_t RegisterAsServices() {
|
||||||
|
status_t status = OK;
|
||||||
|
|
||||||
|
sp<AdaptiveBacklight> ab = new AdaptiveBacklight();
|
||||||
|
if (ab->isSupported()) {
|
||||||
|
status = ab->registerAsService();
|
||||||
|
if (status != OK) {
|
||||||
|
LOG(ERROR) << "Could not register service for LiveDisplay HAL AdaptiveBacklight Iface ("
|
||||||
|
<< status << ")";
|
||||||
|
return status;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
sp<SunlightEnhancement> se = new SunlightEnhancement();
|
||||||
|
if (se->isSupported()) {
|
||||||
|
status = se->registerAsService();
|
||||||
|
if (status != OK) {
|
||||||
|
LOG(ERROR) << "Could not register service for LiveDisplay HAL SunlightEnhancement Iface"
|
||||||
|
<< " (" << status << ")";
|
||||||
|
return status;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
int main() {
|
||||||
|
LOG(DEBUG) << "LiveDisplay HAL service is starting.";
|
||||||
|
|
||||||
|
configureRpcThreadpool(1, true /*callerWillJoin*/);
|
||||||
|
|
||||||
|
if (RegisterAsServices() == OK) {
|
||||||
|
LOG(DEBUG) << "LiveDisplay HAL service is ready.";
|
||||||
|
joinRpcThreadpool();
|
||||||
|
} else {
|
||||||
|
LOG(ERROR) << "Could not register service for LiveDisplay HAL";
|
||||||
|
}
|
||||||
|
|
||||||
|
// In normal operation, we don't expect the thread pool to shutdown
|
||||||
|
LOG(ERROR) << "LiveDisplay HAL service is shutting down.";
|
||||||
|
return 1;
|
||||||
|
}
|
@ -0,0 +1,13 @@
|
|||||||
|
on init
|
||||||
|
# LiveDisplay sysfs
|
||||||
|
chown system system /sys/devices/platform/soc/soc:qcom,dsi-display-primary/dsi_display_acl
|
||||||
|
chmod 0660 /sys/devices/platform/soc/soc:qcom,dsi-display-primary/dsi_display_acl
|
||||||
|
chown system system /sys/devices/platform/soc/soc:qcom,dsi-display-primary/dsi_display_cabc
|
||||||
|
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
|
||||||
|
|
||||||
|
service vendor.livedisplay-hal-2-0-sysfs /vendor/bin/hw/vendor.lineage.livedisplay@2.0-service-sysfs.motorola_lito
|
||||||
|
class hal
|
||||||
|
user system
|
||||||
|
group system
|
@ -230,6 +230,14 @@
|
|||||||
<name>IPictureAdjustment</name>
|
<name>IPictureAdjustment</name>
|
||||||
<instance>default</instance>
|
<instance>default</instance>
|
||||||
</interface>
|
</interface>
|
||||||
|
<interface>
|
||||||
|
<name>ISunlightEnhancement</name>
|
||||||
|
<instance>default</instance>
|
||||||
|
</interface>
|
||||||
|
<interface>
|
||||||
|
<name>IAdaptiveBacklight</name>
|
||||||
|
<instance>default</instance>
|
||||||
|
</interface>
|
||||||
</hal>
|
</hal>
|
||||||
<hal format="hidl">
|
<hal format="hidl">
|
||||||
<name>vendor.qti.data.factory</name>
|
<name>vendor.qti.data.factory</name>
|
||||||
|
@ -250,7 +250,8 @@ PRODUCT_PACKAGES += \
|
|||||||
|
|
||||||
# LiveDisplay
|
# LiveDisplay
|
||||||
PRODUCT_PACKAGES += \
|
PRODUCT_PACKAGES += \
|
||||||
vendor.lineage.livedisplay@2.0-service-sdm
|
vendor.lineage.livedisplay@2.0-service-sdm \
|
||||||
|
vendor.lineage.livedisplay@2.0-service-sysfs.motorola_lito
|
||||||
|
|
||||||
# Media
|
# Media
|
||||||
PRODUCT_COPY_FILES += \
|
PRODUCT_COPY_FILES += \
|
||||||
|
Loading…
x
Reference in New Issue
Block a user