sm8250-common: livedisplay: Rip out IDisplayModes

We are now using AOSP-ish display modes implementation.

Change-Id: Iba9d570dd7cef116e18f3e327c8ab5f5e63f2697
This commit is contained in:
LuK1337 2021-04-27 02:55:38 +02:00
parent 4c76d02e85
commit de5498efab
8 changed files with 0 additions and 247 deletions

View file

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

View file

@ -1,144 +0,0 @@
/*
* Copyright (C) 2019 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 "DisplayModesService"
#include "DisplayModes.h"
#include <android-base/logging.h>
#include <android-base/properties.h>
#include <fstream>
namespace vendor {
namespace lineage {
namespace livedisplay {
namespace V2_1 {
namespace implementation {
static constexpr const char* kDisplayModeProp = "vendor.display.mode";
static const std::string kModeBasePath = "/sys/class/drm/card0-DSI-1/";
static const std::string kDefaultPath = "/data/vendor/display/default_display_mode";
const std::map<int32_t, DisplayModes::ModeInfo> DisplayModes::kModeMap = {
{0, {"Standard", "default"}},
{1, {"DCI P3", "native_display_p3_mode"}},
{2, {"Wide Color", "native_display_wide_color_mode"}},
{3, {"sRGB", "native_display_srgb_color_mode"}},
};
DisplayModes::DisplayModes() : mDefaultModeId(0) {
std::ifstream defaultFile(kDefaultPath);
std::string value;
defaultFile >> value;
LOG(DEBUG) << "Default file read result " << value << " fail " << defaultFile.fail();
if (defaultFile.fail()) {
return;
}
for (const auto& entry : kModeMap) {
// Check if default mode is a valid mode
if (value == std::to_string(entry.first)) {
mDefaultModeId = entry.first;
android::base::SetProperty(kDisplayModeProp, entry.second.node);
break;
}
}
}
// Methods from ::vendor::lineage::livedisplay::V2_1::IDisplayModes follow.
Return<void> DisplayModes::getDisplayModes(getDisplayModes_cb resultCb) {
std::vector<V2_0::DisplayMode> modes;
for (const auto& entry : kModeMap) {
modes.push_back({entry.first, entry.second.name});
}
resultCb(modes);
return Void();
}
Return<void> DisplayModes::getCurrentDisplayMode(getCurrentDisplayMode_cb resultCb) {
int32_t currentModeId = mDefaultModeId;
std::string value;
for (const auto& entry : kModeMap) {
if (entry.first == 0) {
continue;
}
std::ifstream modeFile(kModeBasePath + entry.second.node);
if (!modeFile.fail()) {
modeFile >> value;
if (value == "1") {
currentModeId = entry.first;
break;
}
}
}
resultCb({currentModeId, kModeMap.at(currentModeId).name});
return Void();
}
Return<void> DisplayModes::getDefaultDisplayMode(getDefaultDisplayMode_cb resultCb) {
resultCb({mDefaultModeId, kModeMap.at(mDefaultModeId).name});
return Void();
}
Return<bool> DisplayModes::setDisplayMode(int32_t modeID, bool makeDefault) {
// Disable all modes
for (const auto& entry : kModeMap) {
if (entry.first == 0) {
continue;
}
std::ofstream modeFile(kModeBasePath + entry.second.node);
if (!modeFile.fail()) {
modeFile << 0;
}
}
const auto iter = kModeMap.find(modeID);
if (iter == kModeMap.end()) {
return false;
}
if (modeID != 0) {
std::ofstream modeFile(kModeBasePath + iter->second.node);
modeFile << 1;
if (modeFile.fail()) {
return false;
}
android::base::SetProperty(kDisplayModeProp, iter->second.node);
} else {
android::base::SetProperty(kDisplayModeProp, "");
}
if (makeDefault) {
std::ofstream defaultFile(kDefaultPath);
defaultFile << iter->first;
if (defaultFile.fail()) {
return false;
}
mDefaultModeId = iter->first;
}
return true;
}
} // namespace implementation
} // namespace V2_1
} // namespace livedisplay
} // namespace lineage
} // namespace vendor

View file

@ -1,60 +0,0 @@
/*
* Copyright (C) 2019 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_DISPLAYMODES_H
#define VENDOR_LINEAGE_LIVEDISPLAY_V2_1_DISPLAYMODES_H
#include <hidl/MQDescriptor.h>
#include <hidl/Status.h>
#include <vendor/lineage/livedisplay/2.1/IDisplayModes.h>
#include <map>
namespace vendor {
namespace lineage {
namespace livedisplay {
namespace V2_1 {
namespace implementation {
using ::android::hardware::Return;
using ::android::hardware::Void;
using ::android::sp;
class DisplayModes : public IDisplayModes {
public:
DisplayModes();
// Methods from ::vendor::lineage::livedisplay::V2_1::IDisplayModes follow.
Return<void> getDisplayModes(getDisplayModes_cb resultCb) override;
Return<void> getCurrentDisplayMode(getCurrentDisplayMode_cb resultCb) override;
Return<void> getDefaultDisplayMode(getDefaultDisplayMode_cb ResultCb) override;
Return<bool> setDisplayMode(int32_t modeID, bool makeDefault) override;
private:
struct ModeInfo {
std::string name;
std::string node;
};
static const std::map<int32_t, ModeInfo> kModeMap;
int32_t mDefaultModeId;
};
} // namespace implementation
} // namespace V2_1
} // namespace livedisplay
} // namespace lineage
} // namespace vendor
#endif // VENDOR_LINEAGE_LIVEDISPLAY_V2_1_DISPLAYMODES_H

View file

@ -23,7 +23,6 @@
#include <vendor/lineage/livedisplay/2.1/IPictureAdjustment.h>
#include "AntiFlicker.h"
#include "DisplayModes.h"
#include "SunlightEnhancement.h"
using android::OK;
@ -35,11 +34,9 @@ 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;
int main() {
@ -51,7 +48,6 @@ int main() {
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();
@ -64,13 +60,6 @@ int main() {
goto shutdown;
}
status = dm->registerAsService();
if (status != OK) {
LOG(ERROR) << "Could not register service for LiveDisplay HAL DisplayModes Iface ("
<< status << ")";
goto shutdown;
}
status = pa->registerAsService();
if (status != OK) {
LOG(ERROR) << "Could not register service for LiveDisplay HAL PictureAdjustment Iface ("

View file

@ -1,29 +1,10 @@
on init
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
chown system graphics /sys/class/drm/card0-DSI-1/native_display_p3_mode
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/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
chmod 0666 /sys/class/drm/card0-DSI-1/native_display_p3_mode
chmod 0666 /sys/class/drm/card0-DSI-1/native_display_srgb_color_mode
chmod 0666 /sys/class/drm/card0-DSI-1/native_display_wide_color_mode
service vendor.livedisplay-hal-2-1 /vendor/bin/hw/vendor.lineage.livedisplay@2.1-service.oneplus_kona
class hal
user system
group system
on property:sys.boot_completed=1
write /sys/class/drm/card0-DSI-1/hbm 0
write /sys/class/drm/card0-DSI-1/night_mode 0
write /sys/class/drm/card0-DSI-1/native_display_loading_effect_mode 0
write /sys/class/drm/card0-DSI-1/native_display_p3_mode 0
write /sys/class/drm/card0-DSI-1/native_display_srgb_color_mode 0
write /sys/class/drm/card0-DSI-1/native_display_wide_color_mode 0
write /sys/class/drm/card0-DSI-1/${vendor.display.mode} 1

View file

@ -7,10 +7,6 @@
<name>IAntiFlicker</name>
<instance>default</instance>
</interface>
<interface>
<name>IDisplayModes</name>
<instance>default</instance>
</interface>
<interface>
<name>ISunlightEnhancement</name>
<instance>default</instance>

View file

@ -27,15 +27,9 @@ genfscon proc /wireless/rx_voltage u:object_r:procfs_oem_wirele
# sysfs
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
genfscon sysfs /devices/platform/soc/ae00000.qcom,mdss_mdp/drm/card0/card0-DSI-1/native_display_srgb_color_mode u:object_r:sysfs_livedisplay_tuneable:s0
genfscon sysfs /devices/platform/soc/ae00000.qcom,mdss_mdp/drm/card0/card0-DSI-1/native_display_wide_color_mode u:object_r:sysfs_livedisplay_tuneable:s0
genfscon sysfs /devices/platform/soc/ae00000.qcom,mdss_mdp/drm/card0/card0-DSI-1/night_mode u:object_r:sysfs_livedisplay_tuneable:s0
genfscon sysfs /devices/platform/soc/ae00000.qcom,mdss_mdp/drm/card0/card0-DSI-1/notify_dim u:object_r:sysfs_fod:s0
genfscon sysfs /devices/platform/soc/ae00000.qcom,mdss_mdp/drm/card0/card0-DSI-1/notify_fppress u:object_r:sysfs_fod:s0
genfscon sysfs /devices/platform/soc/ae00000.qcom,mdss_mdp/drm/card0/card0-DSI-1/op_friginer_print_hbm u:object_r:sysfs_fod:s0

View file

@ -4,5 +4,3 @@ allow hal_lineage_livedisplay_qti vendor_display_vendor_data_file:file create_fi
allow hal_lineage_livedisplay_qti sysfs_graphics:dir r_dir_perms;
allow hal_lineage_livedisplay_qti sysfs_fod:file rw_file_perms;
allow hal_lineage_livedisplay_qti sysfs_livedisplay_tuneable:file rw_file_perms;
set_prop(hal_lineage_livedisplay_qti, vendor_display_prop)