• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 HISTOGRAMINFO_H_
18 #define HISTOGRAMINFO_H_
19 #include <aidl/com/google/hardware/pixel/display/HistogramPos.h>
20 #include <drm/samsung_drm.h>
21 
22 #include <mutex>
23 
24 using HistogramPos = ::aidl::com::google::hardware::pixel::display::HistogramPos;
25 
26 class HistogramInfo {
27 public:
28     enum class HistogramType { HISTOGRAM_SAMPLING = 0, HISTOGRAM_HIDL, HISTOGRAM_TYPE_NUM };
setHistogramROI(uint16_t x,uint16_t y,uint16_t h,uint16_t v)29     void setHistogramROI(uint16_t x, uint16_t y, uint16_t h, uint16_t v) {
30         std::unique_lock<std::mutex> lk(mSetHistInfoMutex);
31         mHistogramROI.start_x = x;
32         mHistogramROI.start_y = y;
33         mHistogramROI.hsize = h;
34         mHistogramROI.vsize = v;
35     };
getHistogramROI()36     const struct histogram_roi& getHistogramROI() { return mHistogramROI; }
37 
setHistogramWeights(uint16_t r,uint16_t g,uint16_t b)38     void setHistogramWeights(uint16_t r, uint16_t g, uint16_t b) {
39         std::unique_lock<std::mutex> lk(mSetHistInfoMutex);
40         mHistogramWeights.weight_r = r;
41         mHistogramWeights.weight_g = g;
42         mHistogramWeights.weight_b = b;
43     };
getHistogramWeights()44     const struct histogram_weights& getHistogramWeights() { return mHistogramWeights; }
45 
setHistogramThreshold(uint32_t t)46     void setHistogramThreshold(uint32_t t) {
47         std::unique_lock<std::mutex> lk(mSetHistInfoMutex);
48         mHistogramThreshold = t;
49     }
50 
getHistogramThreshold()51     uint32_t getHistogramThreshold() {
52         std::unique_lock<std::mutex> lk(mSetHistInfoMutex);
53         return mHistogramThreshold;
54     }
55 
getHistogramType()56     HistogramType getHistogramType() { return mHistogramType; }
57 
HistogramInfo(HistogramType type)58     HistogramInfo(HistogramType type) { mHistogramType = type; }
~HistogramInfo()59     virtual ~HistogramInfo() {}
60     virtual void setHistogramPos(const HistogramPos& pos) = 0;
61     virtual void callbackHistogram(char16_t* bin) = 0;
62     std::mutex mSetHistInfoMutex;
63 
64 private:
65     HistogramType mHistogramType = HistogramType::HISTOGRAM_TYPE_NUM;
66     struct histogram_roi mHistogramROI;
67     struct histogram_weights mHistogramWeights;
68     uint32_t mHistogramThreshold = 0;
69 };
70 
71 #endif // HISTOGRAM_H_
72