OSDN Git Service

Added the support of panorama view mode in AaaG HWC.
[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 #ifdef ENABLE_PANORAMA
37 #include "virtualpanoramadisplay.h"
38 #endif
39
40 namespace hwcomposer {
41
42 #define DRM_HOTPLUG_EVENT_SIZE 256
43
44 class NativeDisplay;
45
46 class DrmDisplayManager : public HWCThread, public DisplayManager {
47  public:
48   DrmDisplayManager(GpuDevice *device);
49   ~DrmDisplayManager() override;
50
51   bool Initialize() override;
52
53   void InitializeDisplayResources() override;
54
55   void StartHotPlugMonitor() override;
56
57   NativeDisplay *CreateVirtualDisplay(uint32_t display_index) override;
58   void DestroyVirtualDisplay(uint32_t display_index) override;
59
60 #ifdef ENABLE_PANORAMA
61   NativeDisplay *CreateVirtualPanoramaDisplay(uint32_t display_index) override;
62 #endif
63
64   std::vector<NativeDisplay *> GetAllDisplays() override;
65
66   void RegisterHotPlugEventCallback(
67       std::shared_ptr<DisplayHotPlugEventCallback> callback) override;
68
69   void ForceRefresh() override;
70
71   void IgnoreUpdates() override;
72
73   void setDrmMaster() override;
74
75   uint32_t GetFD() const override {
76     return fd_;
77   }
78
79   void NotifyClientsOfDisplayChangeStatus();
80
81   void HandleLazyInitialization();
82
83   uint32_t GetConnectedPhysicalDisplayCount();
84
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;
94
95  protected:
96   void HandleWait() override;
97   void HandleRoutine() override;
98
99  private:
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;
109   int fd_ = -1;
110   int hotplug_fd_ = -1;
111   bool notify_client_ = false;
112   bool release_lock_ = false;
113   SpinLock spin_lock_;
114   int connected_display_count_ = 0;
115 };
116
117 }  // namespace hwcomposer
118 #endif  // WSI_DRM_DISPLAY_MANAGER_H_