sm7250-common: Add Livedisplay 2.1

This commit is contained in:
kondors1995 2021-11-07 06:37:21 +00:00 committed by mikairyuu
parent 2284ac6ad5
commit 0d8b31cf3e
13 changed files with 336 additions and 5 deletions

View File

@ -79,9 +79,8 @@ endif
BOARD_HAVE_QCOM_FM := true
# HIDL
DEVICE_FRAMEWORK_COMPATIBILITY_MATRIX_FILE := \
$(COMMON_PATH)/framework_compatibility_matrix.xml \
vendor/lineage/config/device_framework_matrix.xml
DEVICE_FRAMEWORK_COMPATIBILITY_MATRIX_FILE := $(COMMON_PATH)/framework_compatibility_matrix.xml \
vendor/evolution/config/device_framework_matrix.xml
DEVICE_MATRIX_FILE += $(COMMON_PATH)/compatibility_matrix.xml
DEVICE_MANIFEST_FILE += $(COMMON_PATH)/manifest.xml

View File

@ -259,9 +259,10 @@ PRODUCT_PACKAGES += \
PRODUCT_PACKAGES += \
android.hardware.light-service.xiaomi
# LiveDisplay
# Livedisplay
PRODUCT_PACKAGES += \
vendor.lineage.livedisplay@2.0-service-sdm
vendor.lineage.livedisplay@2.0-service-sdm \
vendor.lineage.livedisplay@2.1-service.monet
# Media
PRODUCT_PACKAGES += \

40
livedisplay/Android.bp Normal file
View File

@ -0,0 +1,40 @@
//
// 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_binary {
name: "vendor.lineage.livedisplay@2.1-service.monet",
defaults: ["hidl_defaults"],
vintf_fragments: ["vendor.lineage.livedisplay@2.1-service.monet.xml"],
init_rc: ["vendor.lineage.livedisplay@2.1-service.monet.rc"],
relative_install_path: "hw",
srcs: [
":vendor.lineage.livedisplay@2.0-sdm-utils",
"AntiFlicker.cpp",
"SunlightEnhancement.cpp",
"service.cpp",
],
vendor: true,
shared_libs: [
"libbase",
"libbinder",
"libhidlbase",
"libutils",
"vendor.lineage.livedisplay@2.0",
"vendor.lineage.livedisplay@2.1",
],
header_libs: [
"vendor.lineage.livedisplay@2.0-sdm-headers",
],
}

View File

@ -0,0 +1,51 @@
/*
* Copyright (C) 2021 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 "AntiFlickerService"
#include "AntiFlicker.h"
#include <android-base/logging.h>
#include <fstream>
namespace vendor {
namespace lineage {
namespace livedisplay {
namespace V2_1 {
namespace implementation {
static constexpr const char* kDcDimmingPath =
"/sys/devices/platform/soc/soc:qcom,dsi-display-primary/dimlayer_exposure";
Return<bool> AntiFlicker::isEnabled() {
std::ifstream file(kDcDimmingPath);
int result = -1;
file >> result;
LOG(DEBUG) << "Got result " << result << " fail " << file.fail();
return !file.fail() && result > 0;
}
Return<bool> AntiFlicker::setEnabled(bool enabled) {
std::ofstream file(kDcDimmingPath);
file << (enabled ? "1" : "0");
LOG(DEBUG) << "setEnabled fail " << file.fail();
return !file.fail();
}
} // 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) 2021 The LineageOS Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef VENDOR_LINEAGE_LIVEDISPLAY_V2_1_ANTIFLICKER_H
#define VENDOR_LINEAGE_LIVEDISPLAY_V2_1_ANTIFLICKER_H
#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::hardware::Return;
using ::android::hardware::Void;
using ::android::sp;
class AntiFlicker : public IAntiFlicker {
public:
// Methods from ::vendor::lineage::livedisplay::V2_1::IAntiFlicker follow.
Return<bool> isEnabled() override;
Return<bool> setEnabled(bool enabled) override;
};
} // namespace implementation
} // namespace V2_1
} // namespace livedisplay
} // namespace lineage
} // namespace vendor
#endif // VENDOR_LINEAGE_LIVEDISPLAY_V2_1_ANTIFLICKER_H

View File

@ -0,0 +1,55 @@
/*
* 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 "SunlightEnhancementService"
#include <android-base/file.h>
#include <android-base/logging.h>
#include <android-base/strings.h>
#include "SunlightEnhancement.h"
namespace vendor {
namespace lineage {
namespace livedisplay {
namespace V2_1 {
namespace implementation {
static constexpr const char* kHbmStatusPath =
"/sys/class/drm/card0-DSI-1/disp_param";
Return<bool> SunlightEnhancement::isEnabled() {
std::string buf;
if (!android::base::ReadFileToString(kHbmStatusPath, &buf)) {
LOG(ERROR) << "Failed to read " << kHbmStatusPath;
return false;
}
return buf == "0x10000";
}
Return<bool> SunlightEnhancement::setEnabled(bool enabled) {
if (!android::base::WriteStringToFile((enabled ? "0x10000" : "0xF0000"), kHbmStatusPath)) {
LOG(ERROR) << "Failed to write " << kHbmStatusPath;
return false;
}
return true;
}
} // namespace implementation
} // namespace V2_1
} // namespace livedisplay
} // namespace lineage
} // namespace vendor

View 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.
*/
#ifndef VENDOR_LINEAGE_LIVEDISPLAY_V2_1_SUNLIGHTENHANCEMENT_H
#define VENDOR_LINEAGE_LIVEDISPLAY_V2_1_SUNLIGHTENHANCEMENT_H
#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:
// Methods from ::vendor::lineage::livedisplay::V2_1::ISunlightEnhancement follow.
Return<bool> isEnabled() override;
Return<bool> setEnabled(bool enabled) override;
};
} // namespace implementation
} // namespace V2_1
} // namespace livedisplay
} // namespace lineage
} // namespace vendor
#endif // VENDOR_LINEAGE_LIVEDISPLAY_V2_1_SUNLIGHTENHANCEMENT_H

66
livedisplay/service.cpp Normal file
View File

@ -0,0 +1,66 @@
/*
* 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.1-service.monet"
#include <android-base/logging.h>
#include <binder/ProcessState.h>
#include <hidl/HidlTransportSupport.h>
#include "AntiFlicker.h"
#include "SunlightEnhancement.h"
#include "livedisplay/sdm/SDMController.h"
using android::OK;
using android::sp;
using android::status_t;
using ::vendor::lineage::livedisplay::V2_0::sdm::SDMController;
using ::vendor::lineage::livedisplay::V2_1::IAntiFlicker;
using ::vendor::lineage::livedisplay::V2_1::ISunlightEnhancement;
using ::vendor::lineage::livedisplay::V2_1::implementation::AntiFlicker;
using ::vendor::lineage::livedisplay::V2_1::implementation::SunlightEnhancement;
int main() {
status_t status = OK;
std::shared_ptr<SDMController> controller = std::make_shared<SDMController>();
sp<AntiFlicker> af = new AntiFlicker();
sp<SunlightEnhancement> se = new SunlightEnhancement();
android::hardware::configureRpcThreadpool(1, true /*callerWillJoin*/);
// AntiFlicker service
status = af->registerAsService();
if (status != OK) {
LOG(ERROR) << "Could not register service for LiveDisplay HAL AntiFlicker Iface ("
<< status << ")";
return 1;
}
// SunlightEnhancement service
status = se->registerAsService();
if (status != OK) {
LOG(ERROR) << "Could not register service for LiveDisplay HAL SunlightEnhancement Iface ("
<< status << ")";
return 1;
}
LOG(INFO) << "LiveDisplay HAL service is ready.";
android::hardware::joinRpcThreadpool();
LOG(ERROR) << "LiveDisplay HAL service failed to join thread pool.";
return 1;
}

View File

@ -0,0 +1,10 @@
on boot
chown system system /sys/class/drm/card0-DSI-1/disp_param
chown system system /sys/devices/platform/soc/soc:qcom,dsi-display-primary/dimlayer_exposure
chmod 0660 /sys/class/drm/card0-DSI-1/disp_param
chmod 0660 /sys/devices/platform/soc/soc:qcom,dsi-display-primary/dimlayer_exposure
service vendor.livedisplay-hal-2-1 /vendor/bin/hw/vendor.lineage.livedisplay@2.1-service.monet
class hal
user system
group system

View File

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

View File

@ -47,6 +47,9 @@
# Health
/sys/devices/platform/soc/c440000.qcom,spmi/spmi-0/spmi0-02/c440000.qcom,spmi:qcom,pm8150b@2:qcom,qpnp-smb5/power_supply/wireless(/.*)? u:object_r:sysfs_wireless_supply:s0
# Livedisplay
/vendor/bin/hw/vendor\.lineage\.livedisplay@2\.1-service\.monet u:object_r:hal_lineage_livedisplay_qti_exec:s0
# IR
/dev/ir_spi u:object_r:lirc_device:s0
/dev/lirc[0-9] u:object_r:lirc_device:s0

View File

@ -10,6 +10,7 @@ genfscon sysfs /devices/platform/soc/soc:qcom,cpu-llcc-ddr-bw
genfscon sysfs /devices/platform/soc/soc:qcom,cpu0-cpu-l3-lat u:object_r:sysfs_msm_subsys:s0
genfscon sysfs /devices/platform/soc/soc:qcom,cpu6-cpu-l3-lat u:object_r:sysfs_msm_subsys:s0
genfscon sysfs /devices/platform/soc/soc:qcom,dsi-display u:object_r:vendor_sysfs_graphics:s0
genfscon sysfs /devices/platform/soc/soc:qcom,dsi-display-primary u:object_r:vendor_sysfs_graphics:s0
genfscon sysfs /devices/platform/soc/soc:qcom,gpubw u:object_r:sysfs_msm_subsys:s0
genfscon sysfs /devices/platform/soc/soc:qcom,gpubw/devfreq u:object_r:sysfs_msm_subsys:s0

View File

@ -0,0 +1,2 @@
allow hal_lineage_livedisplay_qti vendor_sysfs_graphics:dir r_dir_perms;
allow hal_lineage_livedisplay_qti vendor_sysfs_graphics:file rw_file_perms;