2 // Copyright (c) 2016 Intel Corporation
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
8 // http://www.apache.org/licenses/LICENSE-2.0
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.
17 #ifndef PUBLIC_GPUDEVICE_H_
18 #define PUBLIC_GPUDEVICE_H_
21 #define HWC_LOCK_FILE "/vendor/hwc.lock"
29 #include "displaymanager.h"
30 #include "framebuffermanager.h"
31 #include "hwcthread.h"
32 #include "logicaldisplaymanager.h"
33 #include "nativedisplay.h"
35 namespace hwcomposer {
39 class GpuDevice : public HWCThread {
41 static GpuDevice& getInstance();
49 FrameBufferManager* GetFrameBufferManager();
51 uint32_t GetFD() const;
53 NativeDisplay* GetDisplay(uint32_t display);
55 NativeDisplay* CreateVirtualDisplay(uint32_t display_index);
56 void DestroyVirtualDisplay(uint32_t display_index);
58 // This display can be a client preparing
59 // content which will eventually shown by
60 // another parent display.
62 void GetConnectedPhysicalDisplays(std::vector<NativeDisplay*>& displays);
64 const std::vector<NativeDisplay*>& GetAllDisplays();
66 void RegisterHotPlugEventCallback(
67 std::shared_ptr<DisplayHotPlugEventCallback> callback);
69 // Enables the usage of HDCP for all planes supporting this feature
70 // on display. Some displays can support latest HDCP specification and also
71 // have ability to fallback to older specifications i.e. HDCP 2.2 and 1.4
72 // in case latest speicification cannot be supported for some reason.
73 // Content type is defined by content_type.
74 void EnableHDCPSessionForDisplay(uint32_t connector,
75 HWCContentType content_type);
77 // Enables the usage of HDCP for all planes supporting this feature
78 // on all connected displays. Some displays can support latest HDCP
79 // specification and also have ability to fallback to older
80 // specifications i.e. HDCP 2.2 and 1.4 in case latest speicification
81 // cannot be supported for some reason. Content type is defined by
83 void EnableHDCPSessionForAllDisplays(HWCContentType content_type);
85 // The control disables the usage of HDCP for all planes supporting this
86 // feature on display.
87 void DisableHDCPSessionForDisplay(uint32_t connector);
89 // The control disables the usage of HDCP for all planes supporting this
90 // feature on all connected displays.
91 void DisableHDCPSessionForAllDisplays();
93 void SetPAVPSessionStatus(bool enabled, uint32_t pavp_session_id,
94 uint32_t pavp_instance_id);
95 void SetHDCPSRMForAllDisplays(const int8_t* SRM, uint32_t SRMLength);
96 void SetHDCPSRMForDisplay(uint32_t connector, const int8_t* SRM,
98 uint32_t GetDisplayIDFromConnectorID(const uint32_t connector_id);
100 bool IsReservedDrmPlane();
102 bool EnableDRMCommit(bool enable, uint32_t display_id);
104 bool ResetDrmMaster(bool drop_master);
106 std::vector<uint32_t> GetDisplayReservedPlanes(uint32_t display_id);
111 void ResetAllDisplayCommit(bool enable);
113 enum InitializationType {
114 kUnInitialized = 0, // Nothing Initialized.
115 kInitialized = 1 << 1 // Everything Initialized
118 void HandleHWCSettings();
120 void HandleRoutine() override;
121 void HandleWait() override;
122 void ParsePlaneReserveSettings(std::string& value);
123 std::unique_ptr<DisplayManager> display_manager_;
124 std::vector<std::unique_ptr<LogicalDisplayManager>> logical_display_manager_;
125 std::vector<std::unique_ptr<NativeDisplay>> mosaic_displays_;
126 #ifdef ENABLE_PANORAMA
127 std::vector<std::unique_ptr<NativeDisplay>> panorama_displays_;
128 void ParsePanoramaDisplayConfig(
130 std::vector<std::vector<uint32_t>>& panorama_displays);
131 void ParsePanoramaSOSDisplayConfig(
133 std::vector<std::vector<uint32_t>>& panorama_sos_displays);
134 void InitializePanorama(
135 std::vector<NativeDisplay*>& total_displays_,
136 std::vector<NativeDisplay*>& temp_displays,
137 std::vector<std::vector<uint32_t>>& panorama_displays,
138 std::vector<std::vector<uint32_t>>& panorama_sos_displays,
139 std::vector<bool>& available_displays);
141 void ParseLogicalDisplaySetting(std::string& value,
142 std::vector<uint32_t>& logical_displays);
143 void ParseMosaicDisplaySetting(
144 std::string& value, std::vector<std::vector<uint32_t>>& mosaic_displays);
145 void ParsePhysicalDisplaySetting(std::string& value,
146 std::vector<uint32_t>& physical_displays);
147 void ParseCloneDisplaySetting(
148 std::string& value, std::vector<std::vector<uint32_t>>& cloned_displays);
149 void ParsePhysicalDisplayRotation(
150 std::string& value, std::vector<uint32_t>& display_rotation,
151 std::vector<uint32_t>& rotation_display_index);
152 void ParseFloatDisplaySetting(std::string& value,
153 std::vector<HwcRect<int32_t>>& float_displays,
154 std::vector<uint32_t>& float_display_indices);
156 void InitializeDisplayIndex(std::vector<uint32_t>& physical_displays,
157 std::vector<NativeDisplay*>& displays);
158 void InitializeLogicalDisplay(std::vector<uint32_t>& logical_displays,
159 std::vector<NativeDisplay*>& displays,
160 std::vector<NativeDisplay*>& temp_displays,
162 void InitializeDisplayRotation(std::vector<uint32_t>& display_rotation,
163 std::vector<uint32_t>& rotation_display_index,
164 std::vector<NativeDisplay*>& displays);
165 void InitializeMosaicDisplay(
166 std::vector<NativeDisplay*>& total_displays_,
167 std::vector<std::vector<uint32_t>>& mosaic_displays,
168 std::vector<NativeDisplay*>& temp_displays,
169 std::vector<bool>& available_displays);
170 void InitializeCloneDisplay(
171 std::vector<NativeDisplay*>& total_displays_,
172 std::vector<std::vector<uint32_t>>& cloned_displays);
173 void InitializeFloatDisplay(std::vector<NativeDisplay*>& total_displays_,
174 std::vector<HwcRect<int32_t>>& float_displays,
175 std::vector<uint32_t>& float_display_indices);
176 std::vector<NativeDisplay*> total_displays_;
178 bool reserve_plane_ = false;
179 bool enable_all_display_ = true;
180 std::map<uint8_t, std::vector<uint32_t>> reserved_drm_display_planes_map_;
181 uint32_t initialization_state_ = kUnInitialized;
182 SpinLock initialization_state_lock_;
183 SpinLock drm_master_lock_;
185 friend class DrmDisplayManager;
188 } // namespace hwcomposer
189 #endif // PUBLIC_GPUDEVICE_H_