$(COMMON_PATH)/configs/init/vendor.mmi.carrier.rc:$(TARGET_COPY_OUT_VENDOR)/etc/init/vendor.mmi.carrier.rc \
$(COMMON_PATH)/configs/fstab.exynos9610:$(TARGET_COPY_OUT_VENDOR)/etc/fstab.exynos9610
+# Lights
+PRODUCT_PACKAGES += \
+ android.hardware.light@2.0-service.exynos9610
+
# Media
PRODUCT_COPY_FILES += \
$(COMMON_PATH)/configs/media/media_codecs.xml:$(TARGET_COPY_OUT_VENDOR)/etc/media_codecs.xml \
--- /dev/null
+// Copyright (C) 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: "android.hardware.light@2.0-service.exynos9610",
+ defaults: ["hidl_defaults"],
+ vendor: true,
+ relative_install_path: "hw",
+ init_rc: ["android.hardware.light@2.0-service.exynos9610.rc"],
+
+ srcs: [
+ "Light.cpp",
+ "service.cpp",
+ ],
+
+ shared_libs: [
+ "libbase",
+ "libhardware",
+ "libhidlbase",
+ "liblog",
+ "libutils",
+ "android.hardware.light@2.0",
+ ],
+}
--- /dev/null
+#
+# 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.
+#
+
+LOCAL_PATH := $(call my-dir)
+
+include $(CLEAR_VARS)
+
+LOCAL_SRC_FILES := \
+ Light.cpp \
+ service.cpp
+
+LOCAL_C_INCLUDES := $(LOCAL_PATH)/include
+
+LOCAL_SHARED_LIBRARIES := \
+ libbase \
+ libbinder \
+ libhidlbase \
+ libhidltransport \
+ libutils \
+ android.hardware.light@2.0
+
+LOCAL_MODULE := android.hardware.light@2.0-service.samsung
+LOCAL_INIT_RC := android.hardware.light@2.0-service.samsung.rc
+LOCAL_MODULE_RELATIVE_PATH := hw
+LOCAL_MODULE_TAGS := optional
+LOCAL_MODULE_OWNER := samsung
+LOCAL_VENDOR_MODULE := true
+
+include $(BUILD_EXECUTABLE)
--- /dev/null
+/*
+ * Copyright (C) 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 "android.hardware.light@2.0-service.exynos9610"
+
+#include <android-base/stringprintf.h>
+#include <iomanip>
+
+#include "Light.h"
+
+#define COLOR_MASK 0x00ffffff
+#define MAX_INPUT_BRIGHTNESS 255
+#define PANEL_BRIGHTNESS_NODE "/sys/class/backlight/backlight_0/brightness"
+#define PANEL_MAX_BRIGHTNESS_NODE "/sys/class/backlight/backlight_0/max_brightness"
+
+using android::hardware::light::V2_0::LightState;
+using android::hardware::light::V2_0::Status;
+using android::hardware::light::V2_0::Type;
+
+namespace android {
+namespace hardware {
+namespace light {
+namespace V2_0 {
+namespace implementation {
+
+/*
+ * Write value to path and close file.
+ */
+template <typename T>
+static void set(const std::string& path, const T& value) {
+ std::ofstream file(path);
+ file << value << std::endl;
+}
+
+template <typename T>
+static T get(const std::string& path, const T& def) {
+ std::ifstream file(path);
+ T result;
+
+ file >> result;
+ return file.fail() ? def : result;
+}
+
+Light::Light() {
+ mLights.emplace(Type::BACKLIGHT,
+ std::bind(&Light::handleBacklight, this, std::placeholders::_1));
+}
+
+Return<Status> Light::setLight(Type type, const LightState& state) {
+ auto it = mLights.find(type);
+
+ if (it == mLights.end()) {
+ return Status::LIGHT_NOT_SUPPORTED;
+ }
+
+ /*
+ * Lock global mutex until light state is updated.
+ */
+ std::lock_guard<std::mutex> lock(mLock);
+
+ it->second(state);
+
+ return Status::SUCCESS;
+}
+
+void Light::handleBacklight(const LightState& state) {
+ uint32_t max_brightness = get(PANEL_MAX_BRIGHTNESS_NODE, MAX_INPUT_BRIGHTNESS);
+ uint32_t brightness = rgbToBrightness(state);
+
+ if (max_brightness != MAX_INPUT_BRIGHTNESS) {
+ brightness = brightness * max_brightness / MAX_INPUT_BRIGHTNESS;
+ }
+
+ set(PANEL_BRIGHTNESS_NODE, brightness);
+}
+
+Return<void> Light::getSupportedTypes(getSupportedTypes_cb _hidl_cb) {
+ std::vector<Type> types;
+
+ for (auto const& light : mLights) {
+ types.push_back(light.first);
+ }
+
+ _hidl_cb(types);
+
+ return Void();
+}
+
+uint32_t Light::rgbToBrightness(const LightState& state) {
+ uint32_t color = state.color & COLOR_MASK;
+
+ return ((77 * ((color >> 16) & 0xff)) + (150 * ((color >> 8) & 0xff)) + (29 * (color & 0xff))) >>
+ 8;
+}
+
+} // namespace implementation
+} // namespace V2_0
+} // namespace light
+} // namespace hardware
+} // namespace android
--- /dev/null
+/*
+ * Copyright (C) 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 ANDROID_HARDWARE_LIGHT_V2_0_LIGHT_H
+#define ANDROID_HARDWARE_LIGHT_V2_0_LIGHT_H
+
+#include <android/hardware/light/2.0/ILight.h>
+#include <hidl/MQDescriptor.h>
+#include <hidl/Status.h>
+#include <fstream>
+#include <unordered_map>
+
+namespace android {
+namespace hardware {
+namespace light {
+namespace V2_0 {
+namespace implementation {
+
+using ::android::sp;
+using ::android::hardware::hidl_array;
+using ::android::hardware::hidl_memory;
+using ::android::hardware::hidl_string;
+using ::android::hardware::hidl_vec;
+using ::android::hardware::Return;
+using ::android::hardware::Void;
+
+struct Light : public ILight {
+ Light();
+
+ Return<Status> setLight(Type type, const LightState& state) override;
+ Return<void> getSupportedTypes(getSupportedTypes_cb _hidl_cb) override;
+
+ private:
+ void handleBacklight(const LightState& state);
+ uint32_t rgbToBrightness(const LightState& state);
+
+ std::mutex mLock;
+ std::unordered_map<Type, std::function<void(const LightState&)>> mLights;
+};
+
+} // namespace implementation
+} // namespace V2_0
+} // namespace light
+} // namespace hardware
+} // namespace android
+
+#endif // ANDROID_HARDWARE_LIGHT_V2_0_LIGHT_H
--- /dev/null
+service vendor.light-hal-2-0 /vendor/bin/hw/android.hardware.light@2.0-service.exynos9610
+ interface android.hardware.light@2.0::ILight default
+ class hal
+ user system
+ group system
+ # shutting off lights while powering-off
+ shutdown critical
--- /dev/null
+/*
+ * Copyright (C) 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 "android.hardware.light@2.0-service.exynos9610"
+
+#include <android-base/logging.h>
+#include <hidl/HidlTransportSupport.h>
+#include <utils/Errors.h>
+
+#include "Light.h"
+
+using android::hardware::configureRpcThreadpool;
+using android::hardware::joinRpcThreadpool;
+
+using android::hardware::light::V2_0::ILight;
+using android::hardware::light::V2_0::implementation::Light;
+
+using android::OK;
+using android::sp;
+using android::status_t;
+
+int main() {
+ sp<ILight> light = new Light();
+
+ configureRpcThreadpool(1, true);
+
+ status_t status = light->registerAsService();
+
+ if (status != OK) {
+ LOG(ERROR) << "Could not register service for Light HAL";
+ goto shutdown;
+ }
+
+ LOG(INFO) << "Light HAL service is Ready.";
+ joinRpcThreadpool();
+
+shutdown:
+ // In normal operation, we don't expect the thread pool to shutdown
+ LOG(ERROR) << "Light HAL failed to join thread pool.";
+ return 1;
+}
vendor/lib/hw/keystore.exynos9610.so
vendor/lib64/hw/keystore.exynos9610.so
-# lights
-vendor/lib/hw/lights.exynos9610.so
-vendor/lib64/hw/lights.exynos9610.so
-
# mobicore
vendor/app/mcRegistry/00060308060501020000000000000000.tlbin
vendor/app/mcRegistry/07010000000000000000000000000000.tlbin