davinci: Implement SunlightEnhancement LiveDisplay HAL
Change-Id: I17b0215ad78d86989c146291552c5e6e7b6a689d
This commit is contained in:
parent
5de047f6e9
commit
bcc47bc18f
@ -431,15 +431,6 @@
|
||||
</interface>
|
||||
<fqname>@2.1::IGoodixFingerprintDaemon/default</fqname>
|
||||
</hal>
|
||||
<hal format="hidl">
|
||||
<name>vendor.lineage.livedisplay</name>
|
||||
<transport>hwbinder</transport>
|
||||
<version>2.0</version>
|
||||
<interface>
|
||||
<name>IPictureAdjustment</name>
|
||||
<instance>default</instance>
|
||||
</interface>
|
||||
</hal>
|
||||
<hal format="hidl">
|
||||
<name>vendor.lineage.power</name>
|
||||
<transport>hwbinder</transport>
|
||||
|
@ -197,7 +197,8 @@ PRODUCT_PACKAGES += \
|
||||
|
||||
# LiveDisplay
|
||||
PRODUCT_PACKAGES += \
|
||||
vendor.lineage.livedisplay@2.0-service-sdm
|
||||
vendor.lineage.livedisplay@2.0-service-sdm \
|
||||
vendor.lineage.livedisplay@2.0-service.davinci
|
||||
|
||||
# Media
|
||||
PRODUCT_PACKAGES += \
|
||||
|
35
livedisplay/Android.bp
Normal file
35
livedisplay/Android.bp
Normal file
@ -0,0 +1,35 @@
|
||||
//
|
||||
// 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.0-service.davinci",
|
||||
defaults: ["hidl_defaults"],
|
||||
vintf_fragments: ["vendor.lineage.livedisplay@2.0-service.davinci.xml"],
|
||||
init_rc: ["vendor.lineage.livedisplay@2.0-service.davinci.rc"],
|
||||
relative_install_path: "hw",
|
||||
srcs: [
|
||||
"SunlightEnhancement.cpp",
|
||||
"service.cpp",
|
||||
],
|
||||
vendor: true,
|
||||
shared_libs: [
|
||||
"libbase",
|
||||
"libbinder",
|
||||
"libhidlbase",
|
||||
"libhidltransport",
|
||||
"libutils",
|
||||
"vendor.lineage.livedisplay@2.0",
|
||||
],
|
||||
}
|
54
livedisplay/SunlightEnhancement.cpp
Normal file
54
livedisplay/SunlightEnhancement.cpp
Normal file
@ -0,0 +1,54 @@
|
||||
/*
|
||||
* 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_0 {
|
||||
namespace implementation {
|
||||
|
||||
static constexpr const char* kHbmStatusPath = "/sys/devices/platform/soc/soc:qcom,dsi-display/hbm";
|
||||
|
||||
Return<bool> SunlightEnhancement::isEnabled() {
|
||||
std::string buf;
|
||||
if (!android::base::ReadFileToString(kHbmStatusPath, &buf)) {
|
||||
LOG(ERROR) << "Failed to read " << kHbmStatusPath;
|
||||
return false;
|
||||
}
|
||||
return std::stoi(android::base::Trim(buf)) == 1;
|
||||
}
|
||||
|
||||
Return<bool> SunlightEnhancement::setEnabled(bool enabled) {
|
||||
if (!android::base::WriteStringToFile((enabled ? "1" : "0"), kHbmStatusPath)) {
|
||||
LOG(ERROR) << "Failed to write " << kHbmStatusPath;
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
} // namespace implementation
|
||||
} // 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.
|
||||
*/
|
||||
|
||||
#ifndef VENDOR_LINEAGE_LIVEDISPLAY_V2_0_SUNLIGHTENHANCEMENT_H
|
||||
#define VENDOR_LINEAGE_LIVEDISPLAY_V2_0_SUNLIGHTENHANCEMENT_H
|
||||
|
||||
#include <hidl/MQDescriptor.h>
|
||||
#include <hidl/Status.h>
|
||||
#include <vendor/lineage/livedisplay/2.0/ISunlightEnhancement.h>
|
||||
|
||||
namespace vendor {
|
||||
namespace lineage {
|
||||
namespace livedisplay {
|
||||
namespace V2_0 {
|
||||
namespace implementation {
|
||||
|
||||
using ::android::sp;
|
||||
using ::android::hardware::Return;
|
||||
using ::android::hardware::Void;
|
||||
|
||||
class SunlightEnhancement : public ISunlightEnhancement {
|
||||
public:
|
||||
// Methods from ::vendor::lineage::livedisplay::V2_0::ISunlightEnhancement 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_SUNLIGHTENHANCEMENT_H
|
44
livedisplay/service.cpp
Normal file
44
livedisplay/service.cpp
Normal file
@ -0,0 +1,44 @@
|
||||
/*
|
||||
* 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.davinci"
|
||||
|
||||
#include <android-base/logging.h>
|
||||
#include <binder/ProcessState.h>
|
||||
#include <hidl/HidlTransportSupport.h>
|
||||
|
||||
#include "SunlightEnhancement.h"
|
||||
|
||||
using ::vendor::lineage::livedisplay::V2_0::ISunlightEnhancement;
|
||||
using ::vendor::lineage::livedisplay::V2_0::implementation::SunlightEnhancement;
|
||||
|
||||
int main() {
|
||||
android::sp<ISunlightEnhancement> sunlightEnhancement = new SunlightEnhancement();
|
||||
|
||||
android::hardware::configureRpcThreadpool(1, true /*callerWillJoin*/);
|
||||
|
||||
if (sunlightEnhancement->registerAsService() != android::OK) {
|
||||
LOG(ERROR) << "Cannot register sunlight enhancement HAL service.";
|
||||
return 1;
|
||||
}
|
||||
|
||||
LOG(INFO) << "LiveDisplay HAL service is ready.";
|
||||
|
||||
android::hardware::joinRpcThreadpool();
|
||||
|
||||
LOG(ERROR) << "LiveDisplay HAL service failed to join thread pool.";
|
||||
return 1;
|
||||
}
|
@ -0,0 +1,8 @@
|
||||
on boot
|
||||
chown system system /sys/devices/platform/soc/soc:qcom,dsi-display/hbm
|
||||
chmod 0660 /sys/devices/platform/soc/soc:qcom,dsi-display/hbm
|
||||
|
||||
service vendor.livedisplay-hal-2-0 /vendor/bin/hw/vendor.lineage.livedisplay@2.0-service.davinci
|
||||
class hal
|
||||
user system
|
||||
group system
|
@ -0,0 +1,15 @@
|
||||
<manifest version="1.0" type="device">
|
||||
<hal format="hidl">
|
||||
<name>vendor.lineage.livedisplay</name>
|
||||
<transport>hwbinder</transport>
|
||||
<version>2.0</version>
|
||||
<interface>
|
||||
<name>IPictureAdjustment</name>
|
||||
<instance>default</instance>
|
||||
</interface>
|
||||
<interface>
|
||||
<name>ISunlightEnhancement</name>
|
||||
<instance>default</instance>
|
||||
</interface>
|
||||
</hal>
|
||||
</manifest>
|
4
sepolicy/vendor/file_contexts
vendored
4
sepolicy/vendor/file_contexts
vendored
@ -15,8 +15,12 @@
|
||||
# HALs
|
||||
/vendor/bin/hw/android\.hardware\.light@2\.0-service\.davinci u:object_r:hal_light_default_exec:s0
|
||||
/vendor/bin/hw/vendor\.lineage\.biometrics\.fingerprint\.inscreen@1\.0-service\.davinci u:object_r:hal_lineage_fod_default_exec:s0
|
||||
/vendor/bin/hw/vendor\.lineage\.livedisplay@2\.0-service\.davinci u:object_r:hal_lineage_livedisplay_qti_exec:s0
|
||||
/vendor/bin/hw/vendor\.xiaomi\.hardware\.motor@1\.0-service u:object_r:hal_motor_default_exec:s0
|
||||
|
||||
# HBM
|
||||
/sys/devices/platform/soc/soc:qcom,dsi-display/hbm u:object_r:sysfs_hbm:s0
|
||||
|
||||
# Motor
|
||||
/dev/akm09970 u:object_r:hall_device:s0
|
||||
/dev/drv8846_dev u:object_r:motor_device:s0
|
||||
|
3
sepolicy/vendor/hal_lineage_livedisplay_qti.te
vendored
Normal file
3
sepolicy/vendor/hal_lineage_livedisplay_qti.te
vendored
Normal file
@ -0,0 +1,3 @@
|
||||
type sysfs_hbm, sysfs_type, fs_type;
|
||||
|
||||
allow hal_lineage_livedisplay_qti sysfs_hbm:file rw_file_perms;
|
Loading…
Reference in New Issue
Block a user