Jan Altensen | 53afa33 | 2019-07-09 22:43:47 +0200 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2019 The LineageOS Project |
| 3 | * |
| 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | * you may not use this file except in compliance with the License. |
| 6 | * You may obtain a copy of the License at |
| 7 | * |
| 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | * |
| 10 | * Unless required by applicable law or agreed to in writing, software |
| 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | * See the License for the specific language governing permissions and |
| 14 | * limitations under the License. |
| 15 | */ |
| 16 | |
| 17 | #ifndef ANDROID_HARDWARE_LIGHT_V2_0_LIGHT_H |
| 18 | #define ANDROID_HARDWARE_LIGHT_V2_0_LIGHT_H |
| 19 | |
| 20 | #include <android/hardware/light/2.0/ILight.h> |
| 21 | #include <hidl/MQDescriptor.h> |
| 22 | #include <hidl/Status.h> |
| 23 | #include <fstream> |
| 24 | #include <unordered_map> |
| 25 | #include "samsung_lights.h" |
| 26 | |
| 27 | namespace android { |
| 28 | namespace hardware { |
| 29 | namespace light { |
| 30 | namespace V2_0 { |
| 31 | namespace implementation { |
| 32 | |
| 33 | using ::android::sp; |
| 34 | using ::android::hardware::hidl_array; |
| 35 | using ::android::hardware::hidl_memory; |
| 36 | using ::android::hardware::hidl_string; |
| 37 | using ::android::hardware::hidl_vec; |
| 38 | using ::android::hardware::Return; |
| 39 | using ::android::hardware::Void; |
| 40 | |
| 41 | struct Light : public ILight { |
| 42 | Light(); |
| 43 | |
| 44 | Return<Status> setLight(Type type, const LightState& state) override; |
| 45 | Return<void> getSupportedTypes(getSupportedTypes_cb _hidl_cb) override; |
| 46 | |
| 47 | private: |
| 48 | void handleBacklight(const LightState& state); |
| 49 | #ifdef BUTTON_BRIGHTNESS_NODE |
| 50 | void handleButtons(const LightState& state); |
Andreas Schneider | eeb666c | 2020-03-13 20:26:02 +0100 | [diff] [blame] | 51 | #endif /* BUTTON_BRIGHTNESS_NODE */ |
| 52 | #ifdef LED_BLINK_NODE |
Jan Altensen | 53afa33 | 2019-07-09 22:43:47 +0200 | [diff] [blame] | 53 | void handleBattery(const LightState& state); |
| 54 | void handleNotifications(const LightState& state); |
| 55 | void handleAttention(const LightState& state); |
| 56 | void setNotificationLED(); |
Jan Altensen | 53afa33 | 2019-07-09 22:43:47 +0200 | [diff] [blame] | 57 | uint32_t calibrateColor(uint32_t color, int32_t brightness); |
| 58 | |
| 59 | LightState mAttentionState; |
| 60 | LightState mBatteryState; |
| 61 | LightState mNotificationState; |
Andreas Schneider | eeb666c | 2020-03-13 20:26:02 +0100 | [diff] [blame] | 62 | #endif /* LED_BLINK_NODE */ |
| 63 | |
| 64 | uint32_t rgbToBrightness(const LightState& state); |
Jan Altensen | 53afa33 | 2019-07-09 22:43:47 +0200 | [diff] [blame] | 65 | |
| 66 | std::mutex mLock; |
| 67 | std::unordered_map<Type, std::function<void(const LightState&)>> mLights; |
| 68 | }; |
| 69 | |
| 70 | } // namespace implementation |
| 71 | } // namespace V2_0 |
| 72 | } // namespace light |
| 73 | } // namespace hardware |
| 74 | } // namespace android |
| 75 | |
| 76 | #endif // ANDROID_HARDWARE_LIGHT_V2_0_LIGHT_H |