OSDN Git Service

3590827301c1837ab9541c8c58bc6c41a70e1b3e
[android-x86/external-IA-Hardware-Composer.git] / wsi / drm / drmdisplaymanager.h
1 /*
2 // Copyright (c) 2016 Intel Corporation
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 #ifndef WSI_DRM_DISPLAY_MANAGER_H_
18 #define WSI_DRM_DISPLAY_MANAGER_H_
19
20 #include <stdint.h>
21
22 #include <memory>
23 #include <utility>
24 #include <vector>
25
26 #include "spinlock.h"
27
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
37 namespace hwcomposer {
38
39 #define DRM_HOTPLUG_EVENT_SIZE 256
40
41 class NativeDisplay;
42
43 class DrmDisplayManager : public HWCThread, public DisplayManager {
44  public:
45   DrmDisplayManager(GpuDevice *device);
46   ~DrmDisplayManager() override;
47
48   bool Initialize() override;
49
50   void InitializeDisplayResources() override;
51
52   void StartHotPlugMonitor() override;
53
54   NativeDisplay *CreateVirtualDisplay(uint32_t display_index) override;
55   void DestroyVirtualDisplay(uint32_t display_index) override;
56
57   std::vector<NativeDisplay *> GetAllDisplays() override;
58
59   void RegisterHotPlugEventCallback(
60       std::shared_ptr<DisplayHotPlugEventCallback> callback) override;
61
62   void ForceRefresh() override;
63
64   void IgnoreUpdates() override;
65
66   void setDrmMaster() override;
67
68   uint32_t GetFD() const override {
69     return fd_;
70   }
71
72   void NotifyClientsOfDisplayChangeStatus();
73
74   void HandleLazyInitialization();
75
76   uint32_t GetConnectedPhysicalDisplayCount();
77
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;
87
88  protected:
89   void HandleWait() override;
90   void HandleRoutine() override;
91
92  private:
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;
102   int fd_ = -1;
103   int hotplug_fd_ = -1;
104   bool notify_client_ = false;
105   bool release_lock_ = false;
106   SpinLock spin_lock_;
107   int connected_display_count_ = 0;
108 };
109
110 }  // namespace hwcomposer
111 #endif  // WSI_DRM_DISPLAY_MANAGER_H_