sm6150-common: livedisplay: Add anti flicker support
Change-Id: Ieb91a3efe0fc124e120f95f5ec197aa3c5cecb14
This commit is contained in:
parent
72944d2612
commit
83f9791ee2
@ -20,6 +20,7 @@ cc_binary {
|
||||
init_rc: ["vendor.lineage.livedisplay@2.0-service.xiaomi_sm6150.rc"],
|
||||
relative_install_path: "hw",
|
||||
srcs: [
|
||||
"AntiFlicker.cpp",
|
||||
"SunlightEnhancement.cpp",
|
||||
"service.cpp",
|
||||
],
|
||||
|
55
livedisplay/AntiFlicker.cpp
Normal file
55
livedisplay/AntiFlicker.cpp
Normal file
@ -0,0 +1,55 @@
|
||||
/*
|
||||
* Copyright (C) 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 "AntiFlickerService"
|
||||
|
||||
#include <android-base/file.h>
|
||||
#include <android-base/logging.h>
|
||||
#include <android-base/strings.h>
|
||||
|
||||
#include "AntiFlicker.h"
|
||||
|
||||
namespace vendor {
|
||||
namespace lineage {
|
||||
namespace livedisplay {
|
||||
namespace V2_0 {
|
||||
namespace implementation {
|
||||
|
||||
static constexpr const char* kAntiFlickerStatusPath =
|
||||
"/sys/devices/platform/soc/soc:qcom,dsi-display/msm_fb_ea_enable";
|
||||
|
||||
Return<bool> AntiFlicker::isEnabled() {
|
||||
std::string buf;
|
||||
if (!android::base::ReadFileToString(kAntiFlickerStatusPath, &buf)) {
|
||||
LOG(ERROR) << "Failed to read " << kAntiFlickerStatusPath;
|
||||
return false;
|
||||
}
|
||||
return std::stoi(android::base::Trim(buf)) == 1;
|
||||
}
|
||||
|
||||
Return<bool> AntiFlicker::setEnabled(bool enabled) {
|
||||
if (!android::base::WriteStringToFile((enabled ? "1" : "0"), kAntiFlickerStatusPath)) {
|
||||
LOG(ERROR) << "Failed to write " << kAntiFlickerStatusPath;
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
} // namespace implementation
|
||||
} // namespace V2_0
|
||||
} // namespace livedisplay
|
||||
} // namespace lineage
|
||||
} // namespace vendor
|
47
livedisplay/AntiFlicker.h
Normal file
47
livedisplay/AntiFlicker.h
Normal file
@ -0,0 +1,47 @@
|
||||
/*
|
||||
* Copyright (C) 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_0_ANTIFLICKER_H
|
||||
#define VENDOR_LINEAGE_LIVEDISPLAY_V2_0_ANTIFLICKER_H
|
||||
|
||||
#include <hidl/MQDescriptor.h>
|
||||
#include <hidl/Status.h>
|
||||
#include <vendor/lineage/livedisplay/2.0/IAntiFlicker.h>
|
||||
|
||||
namespace vendor {
|
||||
namespace lineage {
|
||||
namespace livedisplay {
|
||||
namespace V2_0 {
|
||||
namespace implementation {
|
||||
|
||||
using ::android::sp;
|
||||
using ::android::hardware::Return;
|
||||
using ::android::hardware::Void;
|
||||
|
||||
class AntiFlicker : public IAntiFlicker {
|
||||
public:
|
||||
// Methods from ::vendor::lineage::livedisplay::V2_0::IAntiFlicker follow.
|
||||
Return<bool> isEnabled() override;
|
||||
Return<bool> setEnabled(bool enabled) override;
|
||||
};
|
||||
|
||||
} // namespace implementation
|
||||
} // namespace V2_0
|
||||
} // namespace livedisplay
|
||||
} // namespace lineage
|
||||
} // namespace vendor
|
||||
|
||||
#endif // VENDOR_LINEAGE_LIVEDISPLAY_V2_0_ANTIFLICKER_H
|
@ -20,16 +20,24 @@
|
||||
#include <binder/ProcessState.h>
|
||||
#include <hidl/HidlTransportSupport.h>
|
||||
|
||||
#include "AntiFlicker.h"
|
||||
#include "SunlightEnhancement.h"
|
||||
|
||||
using ::vendor::lineage::livedisplay::V2_0::IAntiFlicker;
|
||||
using ::vendor::lineage::livedisplay::V2_0::ISunlightEnhancement;
|
||||
using ::vendor::lineage::livedisplay::V2_0::implementation::AntiFlicker;
|
||||
using ::vendor::lineage::livedisplay::V2_0::implementation::SunlightEnhancement;
|
||||
|
||||
int main() {
|
||||
android::sp<IAntiFlicker> antiFlicker = new AntiFlicker();
|
||||
android::sp<ISunlightEnhancement> sunlightEnhancement = new SunlightEnhancement();
|
||||
|
||||
android::hardware::configureRpcThreadpool(1, true /*callerWillJoin*/);
|
||||
|
||||
if (antiFlicker->registerAsService() != android::OK) {
|
||||
LOG(ERROR) << "Cannot register anti flicker HAL service.";
|
||||
return 1;
|
||||
}
|
||||
if (sunlightEnhancement->registerAsService() != android::OK) {
|
||||
LOG(ERROR) << "Cannot register sunlight enhancement HAL service.";
|
||||
return 1;
|
||||
|
@ -1,6 +1,9 @@
|
||||
on boot
|
||||
chown system system /sys/devices/platform/soc/soc:qcom,dsi-display/hbm
|
||||
chown system system /sys/devices/platform/soc/soc:qcom,dsi-display/msm_fb_ea_enable
|
||||
|
||||
chmod 0660 /sys/devices/platform/soc/soc:qcom,dsi-display/hbm
|
||||
chmod 0660 /sys/devices/platform/soc/soc:qcom,dsi-display/msm_fb_ea_enable
|
||||
|
||||
service vendor.livedisplay-hal-2-0 /vendor/bin/hw/vendor.lineage.livedisplay@2.0-service.xiaomi_sm6150
|
||||
class hal
|
||||
|
@ -3,6 +3,10 @@
|
||||
<name>vendor.lineage.livedisplay</name>
|
||||
<transport>hwbinder</transport>
|
||||
<version>2.0</version>
|
||||
<interface>
|
||||
<name>IAntiFlicker</name>
|
||||
<instance>default</instance>
|
||||
</interface>
|
||||
<interface>
|
||||
<name>IPictureAdjustment</name>
|
||||
<instance>default</instance>
|
||||
|
1
sepolicy/vendor/file_contexts
vendored
1
sepolicy/vendor/file_contexts
vendored
@ -4,6 +4,7 @@
|
||||
# Display
|
||||
/sys/devices/platform/soc/[a-f0-9]+.qcom,mdss_mdp/drm/card([0-3])+/card([0-3])+-DSI-1/panel_info u:object_r:vendor_sysfs_graphics:s0
|
||||
/sys/devices/platform/soc/soc:qcom,dsi-display/hbm u:object_r:sysfs_hbm:s0
|
||||
/sys/devices/platform/soc/soc:qcom,dsi-display/msm_fb_ea_enable u:object_r:sysfs_anti_flicker:s0
|
||||
|
||||
# Fingerprint
|
||||
/dev/goodix_fp u:object_r:fingerprint_device:s0
|
||||
|
@ -1,3 +1,5 @@
|
||||
type sysfs_anti_flicker, sysfs_type, fs_type;
|
||||
type sysfs_hbm, sysfs_type, fs_type;
|
||||
|
||||
allow hal_lineage_livedisplay_qti sysfs_anti_flicker:file rw_file_perms;
|
||||
allow hal_lineage_livedisplay_qti sysfs_hbm:file rw_file_perms;
|
||||
|
Loading…
Reference in New Issue
Block a user