xref: /aosp_15_r20/external/drm_hwcomposer/hwc2_device/HwcDisplayConfigs.h (revision 0a9764fe0a15e71ebbeb85e87e10990c23aab47f)
1*0a9764feSAndroid Build Coastguard Worker /*
2*0a9764feSAndroid Build Coastguard Worker  * Copyright (C) 2022 The Android Open Source Project
3*0a9764feSAndroid Build Coastguard Worker  *
4*0a9764feSAndroid Build Coastguard Worker  * Licensed under the Apache License, Version 2.0 (the "License");
5*0a9764feSAndroid Build Coastguard Worker  * you may not use this file except in compliance with the License.
6*0a9764feSAndroid Build Coastguard Worker  * You may obtain a copy of the License at
7*0a9764feSAndroid Build Coastguard Worker  *
8*0a9764feSAndroid Build Coastguard Worker  *      http://www.apache.org/licenses/LICENSE-2.0
9*0a9764feSAndroid Build Coastguard Worker  *
10*0a9764feSAndroid Build Coastguard Worker  * Unless required by applicable law or agreed to in writing, software
11*0a9764feSAndroid Build Coastguard Worker  * distributed under the License is distributed on an "AS IS" BASIS,
12*0a9764feSAndroid Build Coastguard Worker  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13*0a9764feSAndroid Build Coastguard Worker  * See the License for the specific language governing permissions and
14*0a9764feSAndroid Build Coastguard Worker  * limitations under the License.
15*0a9764feSAndroid Build Coastguard Worker  */
16*0a9764feSAndroid Build Coastguard Worker 
17*0a9764feSAndroid Build Coastguard Worker #pragma once
18*0a9764feSAndroid Build Coastguard Worker 
19*0a9764feSAndroid Build Coastguard Worker #include <hardware/hwcomposer2.h>
20*0a9764feSAndroid Build Coastguard Worker 
21*0a9764feSAndroid Build Coastguard Worker #include <map>
22*0a9764feSAndroid Build Coastguard Worker 
23*0a9764feSAndroid Build Coastguard Worker #include "drm/DrmMode.h"
24*0a9764feSAndroid Build Coastguard Worker 
25*0a9764feSAndroid Build Coastguard Worker namespace android {
26*0a9764feSAndroid Build Coastguard Worker 
27*0a9764feSAndroid Build Coastguard Worker class DrmConnector;
28*0a9764feSAndroid Build Coastguard Worker 
29*0a9764feSAndroid Build Coastguard Worker struct HwcDisplayConfig {
30*0a9764feSAndroid Build Coastguard Worker   uint32_t id{};
31*0a9764feSAndroid Build Coastguard Worker   uint32_t group_id{};
32*0a9764feSAndroid Build Coastguard Worker   DrmMode mode{};
33*0a9764feSAndroid Build Coastguard Worker   bool disabled{};
34*0a9764feSAndroid Build Coastguard Worker 
IsInterlacedHwcDisplayConfig35*0a9764feSAndroid Build Coastguard Worker   bool IsInterlaced() const {
36*0a9764feSAndroid Build Coastguard Worker     return (mode.GetRawMode().flags & DRM_MODE_FLAG_INTERLACE) != 0;
37*0a9764feSAndroid Build Coastguard Worker   }
38*0a9764feSAndroid Build Coastguard Worker };
39*0a9764feSAndroid Build Coastguard Worker 
40*0a9764feSAndroid Build Coastguard Worker struct HwcDisplayConfigs {
41*0a9764feSAndroid Build Coastguard Worker   HWC2::Error Update(DrmConnector &conn);
42*0a9764feSAndroid Build Coastguard Worker   void GenFakeMode(uint16_t width, uint16_t height);
43*0a9764feSAndroid Build Coastguard Worker 
44*0a9764feSAndroid Build Coastguard Worker   std::map<uint32_t /*config_id*/, struct HwcDisplayConfig> hwc_configs;
45*0a9764feSAndroid Build Coastguard Worker 
46*0a9764feSAndroid Build Coastguard Worker   uint32_t active_config_id = 0;
47*0a9764feSAndroid Build Coastguard Worker   uint32_t preferred_config_id = 0;
48*0a9764feSAndroid Build Coastguard Worker 
49*0a9764feSAndroid Build Coastguard Worker   // NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
50*0a9764feSAndroid Build Coastguard Worker   static uint32_t last_config_id;
51*0a9764feSAndroid Build Coastguard Worker 
52*0a9764feSAndroid Build Coastguard Worker   uint32_t mm_width = 0;
53*0a9764feSAndroid Build Coastguard Worker   uint32_t mm_height = 0;
54*0a9764feSAndroid Build Coastguard Worker };
55*0a9764feSAndroid Build Coastguard Worker 
56*0a9764feSAndroid Build Coastguard Worker }  // namespace android
57