• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2018 The Android Open Source 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 #ifndef HARDWARE_GOOGLE_LIGHT_V1_0_LIGHT_H
17 #define HARDWARE_GOOGLE_LIGHT_V1_0_LIGHT_H
18 
19 #include <hidl/Status.h>
20 #include <string>
21 
22 #include <hidl/MQDescriptor.h>
23 #include <hardware/google/light/1.0/ILight.h>
24 #include "Light.h"
25 
26 namespace hardware {
27 namespace google {
28 namespace light {
29 namespace V1_0 {
30 namespace implementation {
31 
32 using ::android::hardware::Return;
33 using ::android::hardware::light::V2_0::LightState;
34 using ::android::hardware::light::V2_0::Status;
35 using ::android::hardware::light::V2_0::Type;
36 using HwILight = ::android::hardware::light::V2_0::ILight;
37 
38 constexpr const char kHighBrightnessModeNode[] =
39     "/sys/class/backlight/panel0-backlight/hbm_mode";
40 
41 struct LightExt : public ::hardware::google::light::V1_0::ILight {
LightExtLightExt42   LightExt(HwILight*&& light) : mLight(light) {
43     mHasHbmNode = !access(kHighBrightnessModeNode, F_OK);
44   };
45   // Methods from ::android::hardware::light::V2_0::ILight follow.
46   Return<Status> setLight(Type type, const LightState& state) override;
getSupportedTypesLightExt47   Return<void> getSupportedTypes(getSupportedTypes_cb _hidl_cb) override {
48     return mLight->getSupportedTypes(_hidl_cb);
49   }
50 
51   // Methods from ::hardware::google::light::V1_0::ILight follow.
52   Return<Status> setHbm(bool on) override;
53 
54  private:
55   std::unique_ptr<HwILight> mLight;
56   Return<Status> applyHBM(bool on);
57   bool mVRMode = 0;
58   bool mRegHBM = 0;
59   bool mCurHBM = 0;
60   bool mHasHbmNode = false;
61 };
62 }  // namespace implementation
63 }  // namespace V1_0
64 }  // namespace light
65 }  // namespace google
66 }  // namespace hardware
67 
68 #endif  // HARDWARD_GOOGLE_LIGHT_V1_0_LIGHT_H
69