1 /*
2  * Copyright (C) 2024 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 namespace android::hardware::graphics::composer {
20 
21 // Definition of panel refresh control.
22 const std::string kFrameRateNodeName = "frame_rate";
23 const std::string kRefreshControlNodeName = "refresh_ctrl";
24 const std::string kRefreshControlNodeEnabled = "Enabled";
25 
26 static constexpr uint32_t kPanelRefreshCtrlFrameInsertionFrameCountOffset = 0;
27 static constexpr uint32_t kPanelRefreshCtrlFrameInsertionFrameCountBits = 7;
28 static constexpr uint32_t kPanelRefreshCtrlFrameInsertionFrameCountMax =
29         (1U << kPanelRefreshCtrlFrameInsertionFrameCountBits) - 1;
30 static constexpr uint32_t kPanelRefreshCtrlFrameInsertionFrameCountMask =
31         kPanelRefreshCtrlFrameInsertionFrameCountMax
32         << kPanelRefreshCtrlFrameInsertionFrameCountOffset;
33 
34 static constexpr uint32_t kPanelRefreshCtrlMinimumRefreshRateOffset =
35         kPanelRefreshCtrlFrameInsertionFrameCountOffset +
36         kPanelRefreshCtrlFrameInsertionFrameCountBits;
37 static constexpr uint32_t kPanelRefreshCtrlMinimumRefreshRateBits = 8;
38 static constexpr uint32_t kPanelRefreshCtrlMinimumRefreshRateMax =
39         (1U << kPanelRefreshCtrlMinimumRefreshRateBits) - 1;
40 static constexpr uint32_t kPanelRefreshCtrlMinimumRefreshRateMask =
41         (kPanelRefreshCtrlMinimumRefreshRateMax << kPanelRefreshCtrlMinimumRefreshRateOffset);
42 
43 static constexpr uint32_t kPanelRefreshCtrlMrrV1OverV2Offset = 30;
44 static constexpr uint32_t kPanelRefreshCtrlMrrV1OverV2 = (1U << kPanelRefreshCtrlMrrV1OverV2Offset);
45 static constexpr uint32_t kPanelRefreshCtrlFrameInsertionAutoModeOffset = 31;
46 static constexpr uint32_t kPanelRefreshCtrlFrameInsertionAutoMode =
47         (1U << kPanelRefreshCtrlFrameInsertionAutoModeOffset);
48 
49 static constexpr uint32_t kPanelRefreshCtrlStateBitsMask = kPanelRefreshCtrlMrrV1OverV2 |
50         kPanelRefreshCtrlFrameInsertionAutoMode | kPanelRefreshCtrlMinimumRefreshRateMask;
51 
52 // Definition of protobuf path
53 static constexpr char kDefaultConfigPathPrefix[] = "/vendor/etc/panel_ctrl_";
54 static constexpr char kDefaultConfigPathSuffix[] = "_cal0.pb";
55 
56 } // namespace android::hardware::graphics::composer
57