sm8250-common: livedisplay: Implement IAntiFlicker interface

Change-Id: I1dbc6d8989a80fe7b06d4356aeb717417997a793
This commit is contained in:
LuK1337 2021-03-14 11:29:05 +01:00 committed by Łukasz Patron
parent 335e820c4c
commit 7432867822
8 changed files with 121 additions and 0 deletions

View file

@ -196,6 +196,10 @@
<hal format="hidl" optional="true">
<name>vendor.lineage.livedisplay</name>
<version>2.1</version>
<interface>
<name>IAntiFlicker</name>
<instance>default</instance>
</interface>
<interface>
<name>IDisplayModes</name>
<instance>default</instance>

View file

@ -22,6 +22,7 @@ cc_binary {
srcs: [
":vendor.lineage.livedisplay@2.0-sdm-pa",
":vendor.lineage.livedisplay@2.0-sdm-utils",
"AntiFlicker.cpp",
"DisplayModes.cpp",
"SunlightEnhancement.cpp",
"service.cpp",

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/ae00000.qcom,mdss_mdp/drm/card0/card0-DSI-1/dimlayer_bl_en";
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

@ -22,6 +22,7 @@
#include <livedisplay/sdm/PictureAdjustment.h>
#include <vendor/lineage/livedisplay/2.1/IPictureAdjustment.h>
#include "AntiFlicker.h"
#include "DisplayModes.h"
#include "SunlightEnhancement.h"
@ -33,9 +34,11 @@ 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;
@ -47,12 +50,20 @@ int main() {
LOG(INFO) << "LiveDisplay HAL service is starting.";
std::shared_ptr<SDMController> controller = std::make_shared<SDMController>();
sp<AntiFlicker> af = new AntiFlicker();
sp<DisplayModes> dm = new DisplayModes();
sp<PictureAdjustment> pa = new PictureAdjustment(controller);
sp<SunlightEnhancement> se = new SunlightEnhancement();
configureRpcThreadpool(1, true /*callerWillJoin*/);
status = af->registerAsService();
if (status != OK) {
LOG(ERROR) << "Could not register service for LiveDisplay HAL AntiFlicker Iface ("
<< status << ")";
goto shutdown;
}
status = dm->registerAsService();
if (status != OK) {
LOG(ERROR) << "Could not register service for LiveDisplay HAL DisplayModes Iface ("

View file

@ -1,5 +1,6 @@
on init
chown system graphics /sys/class/drm/card0-DSI-1/DCI_P3
chown system graphics /sys/class/drm/card0-DSI-1/dimlayer_bl_en
chown system graphics /sys/class/drm/card0-DSI-1/hbm
chown system graphics /sys/class/drm/card0-DSI-1/night_mode
chown system graphics /sys/class/drm/card0-DSI-1/native_display_loading_effect_mode
@ -7,6 +8,7 @@ on init
chown system graphics /sys/class/drm/card0-DSI-1/native_display_srgb_color_mode
chown system graphics /sys/class/drm/card0-DSI-1/native_display_wide_color_mode
chmod 0666 /sys/class/drm/card0-DSI-1/DCI_P3
chmod 0666 /sys/class/drm/card0-DSI-1/dimlayer_bl_en
chmod 0666 /sys/class/drm/card0-DSI-1/hbm
chmod 0666 /sys/class/drm/card0-DSI-1/night_mode
chmod 0666 /sys/class/drm/card0-DSI-1/native_display_loading_effect_mode

View file

@ -3,6 +3,10 @@
<name>vendor.lineage.livedisplay</name>
<transport>hwbinder</transport>
<version>2.1</version>
<interface>
<name>IAntiFlicker</name>
<instance>default</instance>
</interface>
<interface>
<name>IDisplayModes</name>
<instance>default</instance>

View file

@ -29,6 +29,7 @@ genfscon proc /wireless/rx_voltage u:object_r:procfs_oem_wirele
genfscon sysfs /devices/platform/soc/a8c000.i2c/i2c-3/3-005a/leds/vibrator u:object_r:sysfs_leds:s0
genfscon sysfs /devices/platform/soc/ae00000.qcom,mdss_mdp/drm/card0/card0-DSI-1/DCI_P3 u:object_r:sysfs_livedisplay_tuneable:s0
genfscon sysfs /devices/platform/soc/ae00000.qcom,mdss_mdp/drm/card0/card0-DSI-1/dim_alpha u:object_r:sysfs_fod:s0
genfscon sysfs /devices/platform/soc/ae00000.qcom,mdss_mdp/drm/card0/card0-DSI-1/dimlayer_bl_en u:object_r:sysfs_livedisplay_tuneable:s0
genfscon sysfs /devices/platform/soc/ae00000.qcom,mdss_mdp/drm/card0/card0-DSI-1/hbm u:object_r:sysfs_livedisplay_tuneable:s0
genfscon sysfs /devices/platform/soc/ae00000.qcom,mdss_mdp/drm/card0/card0-DSI-1/native_display_loading_effect_mode u:object_r:sysfs_livedisplay_tuneable:s0
genfscon sysfs /devices/platform/soc/ae00000.qcom,mdss_mdp/drm/card0/card0-DSI-1/native_display_p3_mode u:object_r:sysfs_livedisplay_tuneable:s0