• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2023 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 #pragma once
18 
19 #include "HistogramDevice.h"
20 
21 class HistogramController : public HistogramDevice {
22 public:
23     HistogramController(ExynosDisplay* display);
24     virtual void initPlatformHistogramCapability()
25             EXCLUDES(mHistogramMutex, mBlobIdDataMutex) override;
26     virtual ndk::ScopedAStatus queryOPR(std::array<double, kOPRConfigsCount>& oprVals)
27             EXCLUDES(mInitDrmDoneMutex, mHistogramMutex, mBlobIdDataMutex) override;
28 
29 private:
30     struct PreemptConfigInfo {
31         const char* name;
32         const HistogramConfig config;
33     };
34 
35     const std::array<PreemptConfigInfo, kOPRConfigsCount> mPreemptConfigs{
36         {{
37              .name = "Linear space OPR(RED)",
38              .config =
39                      {
40                          .roi = DISABLED_ROI,
41                          .weights = {WEIGHT_SUM, 0, 0},
42                          .samplePos = HistogramSamplePos::POST_POSTPROC,
43                      },
44          },
45          {
46              .name = "Linear space OPR(GREEN)",
47              .config =
48                      {
49                          .roi = DISABLED_ROI,
50                          .weights = {0, WEIGHT_SUM, 0},
51                          .samplePos = HistogramSamplePos::POST_POSTPROC,
52                      },
53          },
54          {
55              .name = "Linear space OPR(BLUE)",
56              .config =
57                      {
58                          .roi = DISABLED_ROI,
59                          .weights = {0, 0, WEIGHT_SUM},
60                          .samplePos = HistogramSamplePos::POST_POSTPROC,
61                      },
62          }}};
63     std::array<std::shared_ptr<ConfigInfo>, kOPRConfigsCount> mConfigInfos
64             GUARDED_BY(mHistogramMutex);
65 
66     HistogramErrorCode getOPRVals(const std::array<uint32_t, kOPRConfigsCount>& blobIds,
67                                   const std::array<int, kOPRConfigsCount>& channelIds,
68                                   std::array<double, kOPRConfigsCount>& oprVals)
69             EXCLUDES(mInitDrmDoneMutex, mHistogramMutex, mBlobIdDataMutex);
70 
71     HistogramErrorCode calculateOPRVal(const char* configName,
72                                        const std::vector<char16_t>& histogramBuffer,
73                                        const uint32_t blobId, const int channelId,
74                                        double& oprVal) const
75             EXCLUDES(mInitDrmDoneMutex, mHistogramMutex, mBlobIdDataMutex);
76 
77     HistogramErrorCode getOPRBlobs(std::array<uint32_t, kOPRConfigsCount>& blobIds,
78                                    const int displayActiveH, const int displayActiveV)
79             REQUIRES(mHistogramMutex) EXCLUDES(mInitDrmDoneMutex, mBlobIdDataMutex);
80 
81     void getOPRChannels(std::array<int, kOPRConfigsCount>& channelIds) const
82             REQUIRES(mHistogramMutex) EXCLUDES(mInitDrmDoneMutex, mBlobIdDataMutex);
83 
84     HistogramErrorCode preemptOPRChannels() REQUIRES(mHistogramMutex)
85             EXCLUDES(mInitDrmDoneMutex, mBlobIdDataMutex);
86 
87     void postAtomicCommitCleanup() override
88             EXCLUDES(mHistogramMutex, mInitDrmDoneMutex, mBlobIdDataMutex);
89 
90     void dumpInternalConfigs(String8& result) const override REQUIRES(mHistogramMutex)
91             EXCLUDES(mInitDrmDoneMutex, mBlobIdDataMutex);
92 };
93