1 /*
2  * Copyright (C) 2022 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 
17 #ifndef GOOGLE_TANGOTRON_LIGHTS_LED_LUT_CALIBRATOR_H_
18 #define GOOGLE_TANGOTRON_LIGHTS_LED_LUT_CALIBRATOR_H_
19 
20 #include <string>
21 #include <unordered_map>
22 #include <vector>
23 #include <aidl/com/google/hardware/pixel/display/IDisplay.h>
24 
25 using PanelCalibrationStatus = aidl::com::google::hardware::pixel::display::PanelCalibrationStatus;
26 
27 class LedLutCalibrator {
28   public:
29     LedLutCalibrator(PanelCalibrationStatus status);
30     LedLutCalibrator &operator=(const LedLutCalibrator &) = delete;
31     ~LedLutCalibrator() = default;
32     int GetByColorIntensity(const std::string &color, int intensity) const;
33 
34   private:
35     bool ReadCalibrationTable();
36     bool ParseBlock(const std::vector<uint8_t> *table);
37     std::string MakeLutKey(const std::string &color, int intensity) const;
38 
39     std::unordered_map<std::string, int> cal_table_;
40     PanelCalibrationStatus cal_status_;
41 };
42 
43 #endif  // GOOGLE_TANGOTRON_LIGHTS_LED_LUT_CALIBRATOR_H_
44