summaryrefslogtreecommitdiffstats
path: root/exynos4
diff options
context:
space:
mode:
authorDominggoes Isakh <drjisakh@gmail.com>2019-02-02 00:29:19 +0100
committerShilin Victor <chrono.monochrome@gmail.com>2019-02-23 16:52:03 +0300
commit7fadabc96496c92a50a616b0f8a3aa9285dd79ea (patch)
treee1e1f4cb9d332ca83b58783dff4124e73e8b1f0b /exynos4
parent33b21658f39d7338cef9cbeda30645b3e3ff0b36 (diff)
downloadhardware_samsung-7fadabc96496c92a50a616b0f8a3aa9285dd79ea.tar.gz
hardware_samsung-7fadabc96496c92a50a616b0f8a3aa9285dd79ea.tar.bz2
hardware_samsung-7fadabc96496c92a50a616b0f8a3aa9285dd79ea.zip
Exynos4: Initial implementation of LiveDisplay 1.0
Change-Id: Ic42ac877b5bbd437b07616c0bcaedd7d846d07c2
Diffstat (limited to 'exynos4')
-rw-r--r--exynos4/interfaces/livedisplay/1.0/.clang-format13
-rw-r--r--exynos4/interfaces/livedisplay/1.0/Android.bp45
-rw-r--r--exynos4/interfaces/livedisplay/1.0/Exynos4.cpp148
-rw-r--r--exynos4/interfaces/livedisplay/1.0/include/Color.h99
-rw-r--r--exynos4/interfaces/livedisplay/1.0/include/ColorBackend.h64
-rw-r--r--exynos4/interfaces/livedisplay/1.0/include/Exynos4.h102
-rw-r--r--exynos4/interfaces/livedisplay/1.0/include/Types.h79
-rw-r--r--exynos4/interfaces/livedisplay/1.0/include/Utils.h41
-rw-r--r--exynos4/interfaces/livedisplay/1.0/include/controller/Exynos4Controller.h73
-rw-r--r--exynos4/interfaces/livedisplay/1.0/service.cpp69
-rw-r--r--exynos4/interfaces/livedisplay/1.0/src/Color.cpp378
-rw-r--r--exynos4/interfaces/livedisplay/1.0/src/Utils.cpp74
-rw-r--r--exynos4/interfaces/livedisplay/1.0/vendor.lineage.livedisplay@1.0-service-exynos4.rc4
13 files changed, 1189 insertions, 0 deletions
diff --git a/exynos4/interfaces/livedisplay/1.0/.clang-format b/exynos4/interfaces/livedisplay/1.0/.clang-format
new file mode 100644
index 0000000..fc4eb1b
--- /dev/null
+++ b/exynos4/interfaces/livedisplay/1.0/.clang-format
@@ -0,0 +1,13 @@
+BasedOnStyle: Google
+AllowShortBlocksOnASingleLine: false
+AllowShortFunctionsOnASingleLine: false
+
+AccessModifierOffset: -2
+ColumnLimit: 100
+CommentPragmas: NOLINT:.*
+DerivePointerAlignment: false
+IndentWidth: 4
+PointerAlignment: Left
+TabWidth: 4
+UseTab: Never
+PenaltyExcessCharacter: 32
diff --git a/exynos4/interfaces/livedisplay/1.0/Android.bp b/exynos4/interfaces/livedisplay/1.0/Android.bp
new file mode 100644
index 0000000..0867fdb
--- /dev/null
+++ b/exynos4/interfaces/livedisplay/1.0/Android.bp
@@ -0,0 +1,45 @@
+// Copyright (C) 2017-2018 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_defaults {
+ name: "livedisplay_exynos4_defaults",
+ relative_install_path: "hw",
+ defaults: ["hidl_defaults"],
+ local_include_dirs: ["include"],
+ srcs: [
+ "service.cpp",
+ "src/Color.cpp",
+ "src/Utils.cpp"
+ ],
+ shared_libs: [
+ "libbase",
+ "libbinder",
+ "libcutils",
+ "libhardware",
+ "libhidlbase",
+ "libhidltransport",
+ "libutils",
+ "vendor.lineage.livedisplay@1.0",
+ ],
+}
+
+cc_binary {
+ name: "vendor.lineage.livedisplay@1.0-service-exynos4",
+ init_rc: ["vendor.lineage.livedisplay@1.0-service-exynos4.rc"],
+ defaults: ["livedisplay_exynos4_defaults"],
+ proprietary: true,
+ srcs: [
+ "Exynos4.cpp",
+ ],
+}
diff --git a/exynos4/interfaces/livedisplay/1.0/Exynos4.cpp b/exynos4/interfaces/livedisplay/1.0/Exynos4.cpp
new file mode 100644
index 0000000..8b8b61b
--- /dev/null
+++ b/exynos4/interfaces/livedisplay/1.0/Exynos4.cpp
@@ -0,0 +1,148 @@
+/*
+** Copyright 2016, The CyanogenMod Project
+** Copyright (C) 2017-2018 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_NDEBUG 0
+
+#define LOG_TAG "LiveDisplay-Exynos4"
+
+#include "Exynos4.h"
+#include "Utils.h"
+
+#include <android-base/logging.h>
+#include <errno.h>
+#include <fcntl.h>
+
+namespace vendor {
+namespace lineage {
+namespace livedisplay {
+namespace V1_0 {
+namespace implementation {
+
+using android::BAD_VALUE;
+using android::NO_INIT;
+using android::OK;
+using android::sp;
+using android::status_t;
+
+Exynos4::Exynos4() {
+ memset(&mDefaultPictureAdjustment, 0, sizeof(HSIC));
+
+ if (hasFeature(Feature::DISPLAY_MODES)) {
+ int32_t id;
+ status_t rc = Utils::readInt(DISPLAY_MODE_DEFAULT, &id);
+ if (rc != OK || id < 0) {
+ Utils::writeInt(DISPLAY_MODE_DEFAULT, DEFAULT_DISPLAY_MODE);
+ }
+
+ auto mode = getDefaultDisplayMode();
+ if (mode != nullptr) {
+ setDisplayMode(mode->id, false);
+ }
+ }
+}
+
+Exynos4::~Exynos4() {
+}
+
+status_t Exynos4::getDisplayModes(std::vector<sp<disp_mode>>& profiles) {
+ struct d_mode {
+ int id;
+ char name[10];
+ };
+
+ struct d_mode d_mode_profiles[6] = {
+ { 0, "Dynamic" },
+ { 1, "Standard" },
+ { 2, "Natural" },
+ { 3, "Cinema" },
+ { 4, "Adaptive" },
+ { 5, "Reading" },
+ };
+
+ for (uint32_t i = 0; i < getNumDisplayModes(); i++) {
+ const sp<disp_mode> m = new disp_mode;
+ m->id = d_mode_profiles[i].id;
+ m->name = d_mode_profiles[i].name;
+ m->privFlags = 0;
+ profiles.push_back(m);
+ }
+
+ return OK;
+}
+
+status_t Exynos4::setDisplayMode(int32_t modeID, bool makeDefault) {
+ if (makeDefault) {
+ Utils::writeInt(DISPLAY_MODE_DEFAULT, modeID);
+ }
+ return Utils::writeInt(DISPLAY_MODE, modeID);
+}
+
+sp<disp_mode> Exynos4::getCurrentDisplayMode() {
+ int32_t id = 0;
+
+ status_t rc = Utils::readInt(DISPLAY_MODE, &id);
+ if (rc != OK || id < 0) {
+ return nullptr;
+ }
+ return getDisplayModeById(id);
+}
+
+sp<disp_mode> Exynos4::getDefaultDisplayMode() {
+ int32_t id = 0;
+ status_t rc = Utils::readInt(DISPLAY_MODE_DEFAULT, &id);
+ if (rc != OK || id < 0) {
+ return getDisplayModeById(1);
+ }
+ return getDisplayModeById(id);
+}
+
+bool Exynos4::hasFeature(Feature feature) {
+ return feature == Feature::DISPLAY_MODES;
+}
+
+uint32_t Exynos4::getNumDisplayModes() {
+ int32_t num = 0;
+ status_t rc = Utils::readInt(DISPLAY_MODE_MAX, &num);
+ if (rc != OK) {
+ return 0;
+ }
+ return num;
+}
+
+sp<disp_mode> Exynos4::getDisplayModeById(int32_t id) {
+ std::vector<sp<disp_mode>> profiles;
+ status_t rc = getDisplayModes(profiles);
+ if (rc == OK) {
+ for (const auto& mode : profiles) {
+ if (id == mode->id) {
+ return mode;
+ }
+ }
+ }
+
+ return nullptr;
+}
+
+HSIC Exynos4::getDefaultPictureAdjustment() {
+ return mDefaultPictureAdjustment;
+}
+
+} // namespace implementation
+} // namespace V1_0
+} // namespace livedisplay
+} // namespace lineage
+} // namespace vendor
diff --git a/exynos4/interfaces/livedisplay/1.0/include/Color.h b/exynos4/interfaces/livedisplay/1.0/include/Color.h
new file mode 100644
index 0000000..58b6bbf
--- /dev/null
+++ b/exynos4/interfaces/livedisplay/1.0/include/Color.h
@@ -0,0 +1,99 @@
+/*
+ * Copyright (C) 2016 The CyanogenMod Project
+ * Copyright (C) 2017-2018 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_V1_0_COLOR_H
+#define VENDOR_LINEAGE_LIVEDISPLAY_V1_0_COLOR_H
+
+#include <vendor/lineage/livedisplay/1.0/IColor.h>
+
+#include <utils/Mutex.h>
+
+#include <memory>
+
+namespace vendor {
+namespace lineage {
+namespace livedisplay {
+namespace V1_0 {
+namespace implementation {
+
+using ::android::hardware::Return;
+using ::android::hardware::Void;
+using ::android::hardware::hidl_vec;
+
+using ::vendor::lineage::livedisplay::V1_0::IColor;
+
+class ColorBackend;
+
+class Color : public IColor {
+ public:
+ Color();
+
+ Return<Features> getSupportedFeatures() override;
+
+ Return<void> getDisplayModes(getDisplayModes_cb _hidl_cb) override;
+ Return<void> getCurrentDisplayMode(getCurrentDisplayMode_cb _hidl_cb) override;
+ Return<void> getDefaultDisplayMode(getDefaultDisplayMode_cb _hidl_cb) override;
+ Return<bool> setDisplayMode(int32_t modeID, bool makeDefault) override;
+
+ Return<bool> setAdaptiveBacklightEnabled(bool enabled) override;
+ Return<bool> isAdaptiveBacklightEnabled() override;
+
+ Return<bool> setOutdoorModeEnabled(bool enabled) override;
+ Return<bool> isOutdoorModeEnabled() override;
+
+ Return<void> getColorBalanceRange(getColorBalanceRange_cb _hidl_cb) override;
+ Return<int32_t> getColorBalance() override;
+ Return<bool> setColorBalance(int32_t value) override;
+
+ Return<bool> setPictureAdjustment(const HSIC& hsic) override;
+ Return<void> getPictureAdjustment(getPictureAdjustment_cb _hidl_cb) override;
+ Return<void> getDefaultPictureAdjustment(getDefaultPictureAdjustment_cb _hidl_cb) override;
+
+ Return<void> getHueRange(getHueRange_cb _hidl_cb) override;
+ Return<void> getSaturationRange(getSaturationRange_cb _hidl_cb) override;
+ Return<void> getIntensityRange(getIntensityRange_cb _hidl_cb) override;
+ Return<void> getContrastRange(getContrastRange_cb _hidl_cb) override;
+ Return<void> getSaturationThresholdRange(getSaturationThresholdRange_cb _hidl_cb) override;
+
+ ~Color();
+
+ private:
+ bool connect();
+ void reset();
+
+ uint32_t mFeatures;
+ bool mConnected;
+
+ bool check(Feature f);
+
+ void error(const char* msg = NULL);
+
+ void addFeature(Feature f) {
+ mFeatures |= (uint32_t)f;
+ };
+
+ std::unique_ptr<ColorBackend> mBackend;
+ android::Mutex mLock;
+};
+
+} // namespace implementation
+} // namespace V1_0
+} // namespace livedisplay
+} // namespace lineage
+} // namespace vendor
+
+#endif // VENDOR_LINEAGE_LIVEDISPLAY_V1_0_COLOR_H
diff --git a/exynos4/interfaces/livedisplay/1.0/include/ColorBackend.h b/exynos4/interfaces/livedisplay/1.0/include/ColorBackend.h
new file mode 100644
index 0000000..c5d06fa
--- /dev/null
+++ b/exynos4/interfaces/livedisplay/1.0/include/ColorBackend.h
@@ -0,0 +1,64 @@
+/*
+ * Copyright (C) 2018 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_V1_0_COLORBACKEND_H
+#define VENDOR_LINEAGE_LIVEDISPLAY_V1_0_COLORBACKEND_H
+
+#include "Types.h"
+
+#include <vector>
+
+namespace vendor {
+namespace lineage {
+namespace livedisplay {
+namespace V1_0 {
+namespace implementation {
+
+class ColorBackend {
+ public:
+ virtual android::status_t setAdaptiveBacklightEnabled(bool enabled) = 0;
+ virtual bool isAdaptiveBacklightEnabled() = 0;
+
+ virtual android::status_t setOutdoorModeEnabled(bool enabled) = 0;
+ virtual bool isOutdoorModeEnabled() = 0;
+
+ virtual android::status_t getColorBalanceRange(Range& range) = 0;
+ virtual android::status_t setColorBalance(int32_t balance) = 0;
+ virtual int32_t getColorBalance() = 0;
+
+ virtual android::status_t getDisplayModes(std::vector<android::sp<disp_mode>>& profiles) = 0;
+ virtual android::status_t setDisplayMode(int32_t modeID, bool makeDefault) = 0;
+ virtual android::sp<disp_mode> getCurrentDisplayMode() = 0;
+ virtual android::sp<disp_mode> getDefaultDisplayMode() = 0;
+
+ virtual android::status_t getPictureAdjustmentRanges(HSICRanges& ranges) = 0;
+ virtual android::status_t getPictureAdjustment(HSIC& hsic) = 0;
+ virtual HSIC getDefaultPictureAdjustment() = 0;
+ virtual android::status_t setPictureAdjustment(const HSIC& hsic) = 0;
+
+ virtual bool hasFeature(Feature feature) = 0;
+
+ virtual ~ColorBackend() {
+ }
+};
+
+} // namespace implementation
+} // namespace V1_0
+} // namespace livedisplay
+} // namespace lineage
+} // namespace vendor
+
+#endif // VENDOR_LINEAGE_LIVEDISPLAY_V1_0_COLORBACKEND_H
diff --git a/exynos4/interfaces/livedisplay/1.0/include/Exynos4.h b/exynos4/interfaces/livedisplay/1.0/include/Exynos4.h
new file mode 100644
index 0000000..d15b707
--- /dev/null
+++ b/exynos4/interfaces/livedisplay/1.0/include/Exynos4.h
@@ -0,0 +1,102 @@
+/*
+** Copyright 2016, The CyanogenMod 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_V1_0_Exynos4_H
+#define VENDOR_LINEAGE_LIVEDISPLAY_V1_0_Exynos4_H
+
+#include "ColorBackend.h"
+
+#define DEFAULT_DISPLAY_MODE 1 // Standard
+namespace vendor {
+namespace lineage {
+namespace livedisplay {
+namespace V1_0 {
+namespace implementation {
+
+constexpr char DISPLAY_MODE[] = "/sys/class/mdnie/mdnie/mode";
+constexpr char DISPLAY_MODE_MAX[] = "/sys/class/mdnie/mdnie/mode_max";
+constexpr char DISPLAY_MODE_DEFAULT[] = "/data/misc/.displaymodedefault";
+
+class Exynos4 : public ColorBackend {
+ public:
+ Exynos4();
+ ~Exynos4();
+
+ virtual android::status_t setAdaptiveBacklightEnabled(bool /* enabled */) override {
+ return android::NO_INIT;
+ }
+
+ virtual bool isAdaptiveBacklightEnabled() override {
+ return false;
+ }
+
+ virtual android::status_t setOutdoorModeEnabled(bool /* enabled */) override {
+ return android::NO_INIT;
+ }
+
+ virtual bool isOutdoorModeEnabled() override {
+ return false;
+ }
+
+ virtual android::status_t getColorBalanceRange(Range& /* range */) override {
+ return android::NO_INIT;
+ }
+
+ virtual android::status_t setColorBalance(int32_t /* balance */) override {
+ return android::NO_INIT;
+ }
+
+ virtual int32_t getColorBalance() override {
+ return 0;
+ }
+
+ virtual android::status_t getPictureAdjustmentRanges(HSICRanges& /* ranges */) override {
+ return android::NO_INIT;
+ }
+
+ virtual android::status_t getPictureAdjustment(HSIC& /* hsic */) override {
+ return android::NO_INIT;
+ }
+
+ virtual HSIC getDefaultPictureAdjustment() override;
+
+ virtual android::status_t setPictureAdjustment(const HSIC& /* hsic */) override {
+ return android::NO_INIT;
+ }
+
+
+
+ virtual android::status_t getDisplayModes(std::vector<android::sp<disp_mode>>& profiles) override;
+ virtual android::status_t setDisplayMode(int32_t modeID, bool makeDefault) override;
+ virtual android::sp<disp_mode> getCurrentDisplayMode() override;
+ virtual android::sp<disp_mode> getDefaultDisplayMode() override;
+
+ virtual bool hasFeature(Feature feature) override;
+
+ private:
+ uint32_t getNumDisplayModes();
+ android::sp<disp_mode> getDisplayModeById(int32_t id);
+
+ HSIC mDefaultPictureAdjustment;
+};
+
+} // namespace implementation
+} // namespace V1_0
+} // namespace livedisplay
+} // namespace lineage
+} // namespace vendor
+
+#endif // VENDOR_LINEAGE_LIVEDISPLAY_V1_0_Exynos4_H
diff --git a/exynos4/interfaces/livedisplay/1.0/include/Types.h b/exynos4/interfaces/livedisplay/1.0/include/Types.h
new file mode 100644
index 0000000..4a6f39d
--- /dev/null
+++ b/exynos4/interfaces/livedisplay/1.0/include/Types.h
@@ -0,0 +1,79 @@
+/*
+ * Copyright (C) 2018 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_V1_0_TYPES_H
+#define VENDOR_LINEAGE_LIVEDISPLAY_V1_0_TYPES_H
+
+#include <utils/RefBase.h>
+#include <vendor/lineage/livedisplay/1.0/IColor.h>
+#include <string>
+
+namespace vendor {
+namespace lineage {
+namespace livedisplay {
+namespace V1_0 {
+namespace implementation {
+
+struct disp_mode : public android::RefBase {
+ int32_t id;
+ std::string name;
+
+ uint32_t privFlags;
+ std::string privData;
+
+ disp_mode() : id(-1) {
+ }
+};
+
+inline bool isNonZero(Range r) {
+ return r.min != 0 || r.max != 0;
+}
+
+inline bool isNonZero(FloatRange r) {
+ return r.min != 0.f || r.max != 0.f;
+}
+
+struct HSICRanges {
+ HSICRanges() {
+ }
+ HSICRanges(Range _hue, FloatRange _saturation, FloatRange _intensity, FloatRange _contrast,
+ FloatRange _saturationThreshold)
+ : hue(_hue),
+ saturation(_saturation),
+ intensity(_intensity),
+ contrast(_contrast),
+ saturationThreshold(_saturationThreshold) {
+ }
+
+ Range hue;
+ FloatRange saturation;
+ FloatRange intensity;
+ FloatRange contrast;
+ FloatRange saturationThreshold;
+
+ bool isValid() {
+ return isNonZero(hue) && isNonZero(saturation) && isNonZero(intensity) &&
+ isNonZero(contrast);
+ }
+};
+
+} // namespace implementation
+} // namespace V1_0
+} // namespace livedisplay
+} // namespace lineage
+} // namespace vendor
+
+#endif // VENDOR_LINEAGE_LIVEDISPLAY_V1_0_TYPES_H
diff --git a/exynos4/interfaces/livedisplay/1.0/include/Utils.h b/exynos4/interfaces/livedisplay/1.0/include/Utils.h
new file mode 100644
index 0000000..5aa9f8a
--- /dev/null
+++ b/exynos4/interfaces/livedisplay/1.0/include/Utils.h
@@ -0,0 +1,41 @@
+/*
+** Copyright 2016, The CyanogenMod Project
+** 2017-2018, 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_V1_0_UTILS_H
+#define VENDOR_LINEAGE_LIVEDISPLAY_V1_0_UTILS_H
+
+#include <utils/Errors.h>
+
+namespace vendor {
+namespace lineage {
+namespace livedisplay {
+namespace V1_0 {
+namespace implementation {
+
+class Utils {
+ public:
+ static android::status_t readInt(const char* node, int32_t* value);
+ static android::status_t writeInt(const char* node, int32_t value);
+};
+
+} // namespace implementation
+} // namespace V1_0
+} // namespace livedisplay
+} // namespace lineage
+} // namespace vendor
+
+#endif // VENDOR_LINEAGE_LIVEDISPLAY_V1_0_UTILS_H
diff --git a/exynos4/interfaces/livedisplay/1.0/include/controller/Exynos4Controller.h b/exynos4/interfaces/livedisplay/1.0/include/controller/Exynos4Controller.h
new file mode 100644
index 0000000..24b3fab
--- /dev/null
+++ b/exynos4/interfaces/livedisplay/1.0/include/controller/Exynos4Controller.h
@@ -0,0 +1,73 @@
+/*
+ * Copyright (C) 2018 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_V1_0_EXYNOS4CONTROLLER_H
+#define VENDOR_LINEAGE_LIVEDISPLAY_V1_0_EXYNOS4CONTROLLER_H
+
+#include <memory>
+
+#include <stdint.h>
+
+namespace vendor {
+namespace lineage {
+namespace livedisplay {
+namespace V1_0 {
+namespace implementation {
+
+class Exynos4Controller {
+ public:
+ Exynos4Controller();
+
+ int32_t init(int32_t init);
+ int32_t get_color_balance_range(int32_t disp_id, void* range);
+ int32_t set_color_balance(int32_t disp_id, int32_t warmness);
+ int32_t get_color_balance(int32_t disp_id, int32_t* warmness);
+ int32_t get_num_display_modes(int32_t disp_id, int32_t mode_type, uint32_t* mode_cnt);
+ int32_t get_display_modes(int32_t disp_id, int32_t mode_type, void* modes, int32_t mode_cnt);
+ int32_t get_active_display_mode(int32_t disp_id, int32_t* mode_id, uint32_t* mask);
+ int32_t set_active_display_mode(int32_t disp_id, int32_t mode_id);
+ int32_t set_default_display_mode(int32_t disp_id, int32_t mode_id);
+ int32_t get_default_display_mode(int32_t disp_id, int32_t* mode_id);
+ int32_t get_pa_range(int32_t disp_id, void* range);
+ int32_t get_pa_config(int32_t disp_id, void* cfg);
+ int32_t set_pa_config(int32_t disp_id, void* cfg);
+ int32_t supported(int32_t disp_id, uint32_t feature_id);
+
+ private:
+ typedef int32_t (*disp_api_init)(int32_t);
+ typedef int32_t (*disp_api_get_color_balance_range)(int32_t, void*);
+ typedef int32_t (*disp_api_set_color_balance)(int32_t, int32_t);
+ typedef int32_t (*disp_api_get_color_balance)(int32_t, int32_t*);
+ typedef int32_t (*disp_api_get_num_display_modes)(int32_t, int32_t, uint32_t*);
+ typedef int32_t (*disp_api_get_display_modes)(int32_t, int32_t, void*, int32_t);
+ typedef int32_t (*disp_api_get_active_display_mode)(int32_t, int32_t*, uint32_t*);
+ typedef int32_t (*disp_api_set_active_display_mode)(int32_t, int32_t);
+ typedef int32_t (*disp_api_set_default_display_mode)(int32_t, int32_t);
+ typedef int32_t (*disp_api_get_default_display_mode)(int32_t, int32_t*);
+ typedef int32_t (*disp_api_get_pa_range)(int32_t, void*);
+ typedef int32_t (*disp_api_get_pa_config)(int32_t, void*);
+ typedef int32_t (*disp_api_set_pa_config)(int32_t, void*);
+ typedef int32_t (*disp_api_supported)(int32_t, uint32_t);
+
+};
+
+} // namespace implementation
+} // namespace V1_0
+} // namespace livedisplay
+} // namespace lineage
+} // namespace vendor
+
+#endif // VENDOR_LINEAGE_LIVEDISPLAY_V1_0_EXYNOS4CONTROLLER_H
diff --git a/exynos4/interfaces/livedisplay/1.0/service.cpp b/exynos4/interfaces/livedisplay/1.0/service.cpp
new file mode 100644
index 0000000..87ea7fe
--- /dev/null
+++ b/exynos4/interfaces/livedisplay/1.0/service.cpp
@@ -0,0 +1,69 @@
+/*
+ * Copyright (C) 2017-2018 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@1.0-service-exynos4"
+
+#include <android-base/logging.h>
+#include <binder/ProcessState.h>
+#include <hidl/HidlTransportSupport.h>
+
+#include "Color.h"
+
+using android::hardware::configureRpcThreadpool;
+using android::hardware::joinRpcThreadpool;
+using android::OK;
+using android::sp;
+using android::status_t;
+
+using ::vendor::lineage::livedisplay::V1_0::IColor;
+using ::vendor::lineage::livedisplay::V1_0::implementation::Color;
+
+int main() {
+ status_t status;
+
+ LOG(ERROR) << "LiveDisplay HAL service is starting.";
+
+#ifdef LIVES_IN_SYSTEM
+ // The LiveDisplay HAL may communicate to other components via /dev/binder
+ android::ProcessState::initWithDriver("/dev/binder");
+#else
+ // The LiveDisplay HAL may communicate to other vendor components via /dev/vndbinder
+ android::ProcessState::initWithDriver("/dev/vndbinder");
+#endif
+
+ android::sp<IColor> service = new Color();
+ if (service == nullptr) {
+ LOG(ERROR) << "Can not create an instance of LiveDisplay HAL Iface, exiting.";
+ goto shutdown;
+ }
+
+ configureRpcThreadpool(1, true /*callerWillJoin*/);
+
+ status = service->registerAsService();
+ if (status != OK) {
+ LOG(ERROR) << "Could not register service for LiveDisplay HAL Iface (" << status << ")";
+ goto shutdown;
+ }
+
+ LOG(INFO) << "LiveDisplay HAL service is ready.";
+ joinRpcThreadpool();
+// Should not pass this line
+
+shutdown:
+ // In normal operation, we don't expect the thread pool to exit
+ LOG(ERROR) << "LiveDisplay HAL service is shutting down.";
+ return 1;
+}
diff --git a/exynos4/interfaces/livedisplay/1.0/src/Color.cpp b/exynos4/interfaces/livedisplay/1.0/src/Color.cpp
new file mode 100644
index 0000000..dd54cac
--- /dev/null
+++ b/exynos4/interfaces/livedisplay/1.0/src/Color.cpp
@@ -0,0 +1,378 @@
+/*
+ * Copyright (C) 2017-2018 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_NDEBUG 0
+
+#define LOG_TAG "LiveDisplay-HIDL"
+
+#include "Color.h"
+
+#include "ColorBackend.h"
+#include "Exynos4.h"
+
+#include <android-base/logging.h>
+
+namespace {
+
+using vendor::lineage::livedisplay::V1_0::DisplayMode;
+using vendor::lineage::livedisplay::V1_0::implementation::disp_mode;
+
+DisplayMode modePointerToObj(android::sp<disp_mode> mode) {
+ DisplayMode m;
+ m.id = mode->id;
+ m.name = mode->name;
+ return m;
+}
+
+DisplayMode invalidDisplayMode() {
+ DisplayMode mode;
+ mode.id = -1;
+ return mode;
+}
+} // anonymous namespace
+
+namespace vendor {
+namespace lineage {
+namespace livedisplay {
+namespace V1_0 {
+namespace implementation {
+
+using ::android::Mutex;
+using ::android::NO_INIT;
+using ::android::OK;
+using ::android::sp;
+using ::android::status_t;
+
+Color::Color() : mConnected(false), mBackend(nullptr) {
+}
+
+Color::~Color() {
+ reset();
+}
+
+void Color::reset() {
+ if (mConnected) {
+ mBackend = nullptr;
+ }
+ mFeatures = 0;
+ mConnected = false;
+}
+
+bool Color::check(Feature f) {
+ return connect() && (mFeatures & (uint32_t)f);
+}
+
+void Color::error(const char* msg) {
+ if (msg != NULL) {
+ LOG(ERROR) << msg;
+ }
+
+ reset();
+}
+
+bool Color::connect() {
+ if (mConnected) {
+ return true;
+ }
+
+ mFeatures = 0;
+
+ mBackend.reset(new Exynos4());
+ if (mBackend == nullptr) {
+ LOG(ERROR) << "Failed to initialize backend!";
+ return false;
+ }
+
+ for (uint32_t i = 1; i <= (uint32_t)Feature::MAX; i <<= 1) {
+ Feature f = static_cast<Feature>(i);
+ if (mBackend->hasFeature(f)) {
+ addFeature(f);
+ }
+ }
+ mConnected = true;
+
+ return mFeatures > 0;
+}
+
+Return<Features> Color::getSupportedFeatures() {
+ connect();
+ return mFeatures;
+}
+
+Return<void> Color::getDisplayModes(getDisplayModes_cb _hidl_cb) {
+ hidl_vec<DisplayMode> profiles;
+ status_t rc = NO_INIT;
+ Mutex::Autolock _l(mLock);
+
+ if (check(Feature::DISPLAY_MODES)) {
+ std::vector<sp<disp_mode>> spProfiles;
+ rc = mBackend->getDisplayModes(spProfiles);
+ if (rc != OK) {
+ error("Unable to fetch display modes!");
+ } else {
+ profiles.resize(spProfiles.size());
+ for (size_t i = 0; i < spProfiles.size(); i++) {
+ profiles[i].id = spProfiles[i]->id;
+ profiles[i].name = spProfiles[i]->name;
+ }
+ }
+ }
+
+ _hidl_cb(profiles);
+ return Void();
+}
+
+Return<void> Color::getCurrentDisplayMode(getCurrentDisplayMode_cb _hidl_cb) {
+ DisplayMode mode;
+ Mutex::Autolock _l(mLock);
+
+ if (check(Feature::DISPLAY_MODES)) {
+ sp<disp_mode> m = mBackend->getCurrentDisplayMode();
+ if (m != nullptr) {
+ mode = modePointerToObj(m);
+ } else {
+ mode = invalidDisplayMode();
+ }
+ }
+ _hidl_cb(mode);
+ return Void();
+}
+
+Return<void> Color::getDefaultDisplayMode(getDefaultDisplayMode_cb _hidl_cb) {
+ DisplayMode mode;
+ Mutex::Autolock _l(mLock);
+
+ if (check(Feature::DISPLAY_MODES)) {
+ sp<disp_mode> m = mBackend->getDefaultDisplayMode();
+ if (m != nullptr) {
+ mode = modePointerToObj(m);
+ } else {
+ mode = invalidDisplayMode();
+ }
+ }
+ _hidl_cb(mode);
+ return Void();
+}
+
+Return<bool> Color::setDisplayMode(int32_t modeID, bool makeDefault) {
+ status_t rc = NO_INIT;
+ Mutex::Autolock _l(mLock);
+
+ if (check(Feature::DISPLAY_MODES)) {
+ rc = mBackend->setDisplayMode(modeID, makeDefault);
+ if (rc != OK) {
+ error("Unable to set display mode!");
+ }
+ }
+ return rc == OK;
+}
+
+Return<bool> Color::setAdaptiveBacklightEnabled(bool enabled) {
+ status_t rc = NO_INIT;
+ Mutex::Autolock _l(mLock);
+
+ if (check(Feature::ADAPTIVE_BACKLIGHT)) {
+ rc = mBackend->setAdaptiveBacklightEnabled(enabled);
+ if (rc != OK) {
+ error("Unable to set adaptive backlight state!");
+ }
+ }
+ return rc == OK;
+}
+
+Return<bool> Color::isAdaptiveBacklightEnabled() {
+ Mutex::Autolock _l(mLock);
+
+ if (check(Feature::ADAPTIVE_BACKLIGHT)) {
+ return mBackend->isAdaptiveBacklightEnabled();
+ }
+ return false;
+}
+
+Return<bool> Color::setOutdoorModeEnabled(bool enabled) {
+ status_t rc = NO_INIT;
+ Mutex::Autolock _l(mLock);
+
+ if (check(Feature::OUTDOOR_MODE)) {
+ rc = mBackend->setOutdoorModeEnabled(enabled);
+ if (rc != OK) {
+ error("Unable to toggle outdoor mode!");
+ }
+ }
+ return rc == OK;
+}
+
+Return<bool> Color::isOutdoorModeEnabled() {
+ Mutex::Autolock _l(mLock);
+
+ if (check(Feature::OUTDOOR_MODE)) {
+ return mBackend->isOutdoorModeEnabled();
+ }
+ return false;
+}
+
+Return<void> Color::getColorBalanceRange(getColorBalanceRange_cb _hidl_cb) {
+ Range range;
+ Mutex::Autolock _l(mLock);
+
+ if (check(Feature::COLOR_BALANCE)) {
+ status_t rc = mBackend->getColorBalanceRange(range);
+ if (rc != OK) {
+ error("Unable to fetch color balance range!");
+ range.max = range.min = 0;
+ }
+ }
+
+ _hidl_cb(range);
+ return Void();
+}
+
+Return<int32_t> Color::getColorBalance() {
+ Mutex::Autolock _l(mLock);
+
+ if (check(Feature::COLOR_BALANCE)) {
+ return mBackend->getColorBalance();
+ }
+
+ return 0;
+}
+
+Return<bool> Color::setColorBalance(int32_t value) {
+ status_t rc = NO_INIT;
+ Mutex::Autolock _l(mLock);
+
+ if (check(Feature::COLOR_BALANCE)) {
+ rc = mBackend->setColorBalance(value);
+ if (rc != OK) {
+ error("Unable to set color balance!");
+ }
+ }
+ return rc == OK;
+}
+
+Return<bool> Color::setPictureAdjustment(const HSIC& hsic) {
+ status_t rc = NO_INIT;
+ Mutex::Autolock _l(mLock);
+
+ if (check(Feature::PICTURE_ADJUSTMENT)) {
+ rc = mBackend->setPictureAdjustment(hsic);
+ if (rc != OK) {
+ error("Unable to set picture adjustment!");
+ }
+ }
+ return rc == OK;
+}
+
+Return<void> Color::getPictureAdjustment(getPictureAdjustment_cb _hidl_cb) {
+ HSIC hsic;
+ Mutex::Autolock _l(mLock);
+
+ if (check(Feature::PICTURE_ADJUSTMENT)) {
+ status_t rc = mBackend->getPictureAdjustment(hsic);
+ if (rc != OK) {
+ error("Unable to get picture adjustment!");
+ }
+ }
+ _hidl_cb(hsic);
+ return Void();
+}
+
+Return<void> Color::getDefaultPictureAdjustment(getDefaultPictureAdjustment_cb _hidl_cb) {
+ HSIC hsic;
+ Mutex::Autolock _l(mLock);
+
+ if (check(Feature::PICTURE_ADJUSTMENT)) {
+ hsic = mBackend->getDefaultPictureAdjustment();
+ }
+ _hidl_cb(hsic);
+ return Void();
+}
+
+Return<void> Color::getHueRange(getHueRange_cb _hidl_cb) {
+ HSICRanges ranges;
+ Mutex::Autolock _l(mLock);
+
+ if (check(Feature::PICTURE_ADJUSTMENT)) {
+ status_t rc = mBackend->getPictureAdjustmentRanges(ranges);
+ if (rc != OK) {
+ error("Unable to get hue range!");
+ }
+ }
+ _hidl_cb(ranges.hue);
+ return Void();
+}
+
+Return<void> Color::getSaturationRange(getSaturationRange_cb _hidl_cb) {
+ HSICRanges ranges;
+ Mutex::Autolock _l(mLock);
+
+ if (check(Feature::PICTURE_ADJUSTMENT)) {
+ status_t rc = mBackend->getPictureAdjustmentRanges(ranges);
+ if (rc != OK) {
+ error("Unable to get saturation range!");
+ }
+ }
+ _hidl_cb(ranges.saturation);
+ return Void();
+}
+
+Return<void> Color::getIntensityRange(getIntensityRange_cb _hidl_cb) {
+ HSICRanges ranges;
+ Mutex::Autolock _l(mLock);
+
+ if (check(Feature::PICTURE_ADJUSTMENT)) {
+ status_t rc = mBackend->getPictureAdjustmentRanges(ranges);
+ if (rc != OK) {
+ error("Unable to get intensity range!");
+ }
+ }
+ _hidl_cb(ranges.intensity);
+ return Void();
+}
+
+Return<void> Color::getContrastRange(getContrastRange_cb _hidl_cb) {
+ HSICRanges ranges;
+ Mutex::Autolock _l(mLock);
+
+ if (check(Feature::PICTURE_ADJUSTMENT)) {
+ status_t rc = mBackend->getPictureAdjustmentRanges(ranges);
+ if (rc != OK) {
+ error("Unable to get contrast range!");
+ }
+ }
+ _hidl_cb(ranges.contrast);
+ return Void();
+}
+
+Return<void> Color::getSaturationThresholdRange(getSaturationThresholdRange_cb _hidl_cb) {
+ HSICRanges ranges;
+ Mutex::Autolock _l(mLock);
+
+ if (check(Feature::PICTURE_ADJUSTMENT)) {
+ status_t rc = mBackend->getPictureAdjustmentRanges(ranges);
+ if (rc != OK) {
+ error("Unable to get saturation threshold range!");
+ }
+ }
+ _hidl_cb(ranges.saturationThreshold);
+ return Void();
+}
+
+} // namespace implementation
+} // namespace V1_0
+} // namespace livedisplay
+} // namespace lineage
+} // namespace vendor
diff --git a/exynos4/interfaces/livedisplay/1.0/src/Utils.cpp b/exynos4/interfaces/livedisplay/1.0/src/Utils.cpp
new file mode 100644
index 0000000..8215172
--- /dev/null
+++ b/exynos4/interfaces/livedisplay/1.0/src/Utils.cpp
@@ -0,0 +1,74 @@
+/*
+** Copyright 2016, The CyanogenMod Project
+** 2017-2018, 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.
+*/
+
+#include "Utils.h"
+
+#include <fcntl.h>
+#include <poll.h>
+#include <signal.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <sys/stat.h>
+#include <unistd.h>
+#include <fstream>
+#include <string>
+
+#include <cutils/sockets.h>
+
+namespace vendor {
+namespace lineage {
+namespace livedisplay {
+namespace V1_0 {
+namespace implementation {
+
+using ::android::NO_INIT;
+using ::android::OK;
+using ::android::status_t;
+
+status_t Utils::readInt(const char* node, int32_t* value) {
+ std::string buf;
+ status_t ret = OK;
+ std::ifstream fin(node);
+ if (!fin.good()) {
+ return errno;
+ }
+ fin >> *value;
+ if (fin.fail()) {
+ ret = errno;
+ }
+ fin.close();
+ return ret;
+}
+
+status_t Utils::writeInt(const char* node, int32_t value) {
+ status_t ret = OK;
+ std::ofstream fout(node);
+ if (!fout.good()) {
+ return errno;
+ }
+ fout << value << std::endl;
+ if (fout.fail()) {
+ ret = errno;
+ }
+ fout.close();
+ return ret;
+}
+} // namespace implementation
+} // namespace V1_0
+} // namespace livedisplay
+} // namespace lineage
+} // namespace vendor
diff --git a/exynos4/interfaces/livedisplay/1.0/vendor.lineage.livedisplay@1.0-service-exynos4.rc b/exynos4/interfaces/livedisplay/1.0/vendor.lineage.livedisplay@1.0-service-exynos4.rc
new file mode 100644
index 0000000..6642fc7
--- /dev/null
+++ b/exynos4/interfaces/livedisplay/1.0/vendor.lineage.livedisplay@1.0-service-exynos4.rc
@@ -0,0 +1,4 @@
+service vendor.livedisplay-hal-1-0 /vendor/bin/hw/vendor.lineage.livedisplay@1.0-service-exynos4
+ class hal
+ user system
+ group system