davinci: Implement SunlightEnhancement LiveDisplay HAL

Change-Id: I17b0215ad78d86989c146291552c5e6e7b6a689d
This commit is contained in:
Bruno Martins 2019-01-23 10:25:44 +00:00 committed by Arian
parent 5de047f6e9
commit bcc47bc18f
No known key found for this signature in database
GPG Key ID: 48029380598CE3B9
10 changed files with 212 additions and 10 deletions

View File

@ -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>

View File

@ -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
View 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",
],
}

View 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

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_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
View 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;
}

View File

@ -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

View File

@ -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>

View File

@ -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

View File

@ -0,0 +1,3 @@
type sysfs_hbm, sysfs_type, fs_type;
allow hal_lineage_livedisplay_qti sysfs_hbm:file rw_file_perms;