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 WSI_DRM_DISPLAY_MANAGER_H_
18 #define WSI_DRM_DISPLAY_MANAGER_H_
28 #include "displaymanager.h"
29 #include "displayplanemanager.h"
30 #include "drmdisplay.h"
31 #include "drmscopedtypes.h"
32 #include "framebuffermanager.h"
33 #include "hwcthread.h"
34 #include "vblankeventhandler.h"
35 #include "virtualdisplay.h"
37 namespace hwcomposer {
39 #define DRM_HOTPLUG_EVENT_SIZE 256
43 class DrmDisplayManager : public HWCThread, public DisplayManager {
45 DrmDisplayManager(GpuDevice *device);
46 ~DrmDisplayManager() override;
48 bool Initialize() override;
50 void InitializeDisplayResources() override;
52 void StartHotPlugMonitor() override;
54 NativeDisplay *CreateVirtualDisplay(uint32_t display_index) override;
55 void DestroyVirtualDisplay(uint32_t display_index) override;
57 std::vector<NativeDisplay *> GetAllDisplays() override;
59 void RegisterHotPlugEventCallback(
60 std::shared_ptr<DisplayHotPlugEventCallback> callback) override;
62 void ForceRefresh() override;
64 void IgnoreUpdates() override;
66 void setDrmMaster() override;
68 uint32_t GetFD() const override {
72 void NotifyClientsOfDisplayChangeStatus();
74 void HandleLazyInitialization();
76 uint32_t GetConnectedPhysicalDisplayCount();
78 void EnableHDCPSessionForDisplay(uint32_t connector,
79 HWCContentType content_type) override;
80 void EnableHDCPSessionForAllDisplays(HWCContentType content_type) override;
81 void DisableHDCPSessionForDisplay(uint32_t connector) override;
82 void DisableHDCPSessionForAllDisplays() override;
83 void SetHDCPSRMForAllDisplays(const int8_t *SRM, uint32_t SRMLength) override;
84 void SetHDCPSRMForDisplay(uint32_t connector, const int8_t *SRM,
85 uint32_t SRMLength) override;
86 void RemoveUnreservedPlanes() override;
89 void HandleWait() override;
90 void HandleRoutine() override;
93 void HotPlugEventHandler();
94 bool UpdateDisplayState();
95 std::vector<std::unique_ptr<NativeDisplay>> virtual_displays_;
96 std::unique_ptr<FrameBufferManager> frame_buffer_manager_;
97 std::vector<std::unique_ptr<DrmDisplay>> displays_;
98 std::shared_ptr<DisplayHotPlugEventCallback> callback_ = NULL;
99 std::unique_ptr<NativeBufferHandler> buffer_handler_;
100 GpuDevice *device_ = NULL;
101 bool ignore_updates_ = false;
103 int hotplug_fd_ = -1;
104 bool notify_client_ = false;
105 bool release_lock_ = false;
107 int connected_display_count_ = 0;
110 } // namespace hwcomposer
111 #endif // WSI_DRM_DISPLAY_MANAGER_H_