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"
36 #ifdef ENABLE_PANORAMA
37 #include "virtualpanoramadisplay.h"
40 namespace hwcomposer {
42 #define DRM_HOTPLUG_EVENT_SIZE 256
46 class DrmDisplayManager : public HWCThread, public DisplayManager {
48 DrmDisplayManager(GpuDevice *device);
49 ~DrmDisplayManager() override;
51 bool Initialize() override;
53 void InitializeDisplayResources() override;
55 void StartHotPlugMonitor() override;
57 NativeDisplay *CreateVirtualDisplay(uint32_t display_index) override;
58 void DestroyVirtualDisplay(uint32_t display_index) override;
60 #ifdef ENABLE_PANORAMA
61 NativeDisplay *CreateVirtualPanoramaDisplay(uint32_t display_index) override;
64 std::vector<NativeDisplay *> GetAllDisplays() override;
66 void RegisterHotPlugEventCallback(
67 std::shared_ptr<DisplayHotPlugEventCallback> callback) override;
69 void ForceRefresh() override;
71 void IgnoreUpdates() override;
73 void setDrmMaster() override;
75 uint32_t GetFD() const override {
79 void NotifyClientsOfDisplayChangeStatus();
81 void HandleLazyInitialization();
83 uint32_t GetConnectedPhysicalDisplayCount();
85 void EnableHDCPSessionForDisplay(uint32_t connector,
86 HWCContentType content_type) override;
87 void EnableHDCPSessionForAllDisplays(HWCContentType content_type) override;
88 void DisableHDCPSessionForDisplay(uint32_t connector) override;
89 void DisableHDCPSessionForAllDisplays() override;
90 void SetHDCPSRMForAllDisplays(const int8_t *SRM, uint32_t SRMLength) override;
91 void SetHDCPSRMForDisplay(uint32_t connector, const int8_t *SRM,
92 uint32_t SRMLength) override;
93 void RemoveUnreservedPlanes() override;
96 void HandleWait() override;
97 void HandleRoutine() override;
100 void HotPlugEventHandler();
101 bool UpdateDisplayState();
102 std::vector<std::unique_ptr<NativeDisplay>> virtual_displays_;
103 std::unique_ptr<FrameBufferManager> frame_buffer_manager_;
104 std::vector<std::unique_ptr<DrmDisplay>> displays_;
105 std::shared_ptr<DisplayHotPlugEventCallback> callback_ = NULL;
106 std::unique_ptr<NativeBufferHandler> buffer_handler_;
107 GpuDevice *device_ = NULL;
108 bool ignore_updates_ = false;
110 int hotplug_fd_ = -1;
111 bool notify_client_ = false;
112 bool release_lock_ = false;
114 int connected_display_count_ = 0;
117 } // namespace hwcomposer
118 #endif // WSI_DRM_DISPLAY_MANAGER_H_