OSDN Git Service

Added the support of panorama view mode in AaaG HWC.
[android-x86/external-IA-Hardware-Composer.git] / common / display / virtualpanoramadisplay.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 COMMON_DISPLAY_VIRTUALPANORAMADISPLAY_H_
18 #define COMMON_DISPLAY_VIRTUALPANORAMADISPLAY_H_
19
20 #include <nativedisplay.h>
21
22 #include <memory>
23 #include <vector>
24
25 #include "compositor.h"
26 #include "resourcemanager.h"
27 #ifdef HYPER_DMABUF_SHARING
28 #include "hyperdmadisplay.h"
29 #endif
30
31 namespace hwcomposer {
32 struct HwcLayer;
33 class FrameBufferManager;
34 class NativeBufferHandler;
35
36 class VirtualPanoramaDisplay : public NativeDisplay {
37  public:
38   VirtualPanoramaDisplay(uint32_t gpu_fd, NativeBufferHandler *buffer_handler,
39                          FrameBufferManager *framebuffermanager,
40                          uint32_t pipe_id, uint32_t crtc_id);
41   VirtualPanoramaDisplay(const VirtualPanoramaDisplay &) = delete;
42   VirtualPanoramaDisplay &operator=(const VirtualPanoramaDisplay &) = delete;
43   ~VirtualPanoramaDisplay() override;
44
45   void InitVirtualDisplay(uint32_t width, uint32_t height) override;
46
47   bool GetActiveConfig(uint32_t *config) override;
48
49   bool SetActiveConfig(uint32_t config) override;
50
51   bool Present(std::vector<HwcLayer *> &source_layers, int32_t *retire_fence,
52                PixelUploaderCallback *call_back = NULL,
53                bool handle_constraints = false) override;
54
55   void SetOutputBuffer(HWCNativeHandle buffer, int32_t acquire_fence) override;
56
57   bool Initialize(NativeBufferHandler *buffer_handler,
58                   FrameBufferManager *frame_buffer_manager) override;
59
60   bool IsConnected() const override {
61     return true;
62   }
63
64   void CreateOutBuffer();
65
66   void HyperDmaExport();
67
68   DisplayType Type() const override {
69     return DisplayType::kVirtual;
70   }
71
72   uint32_t Width() const override {
73     return width_;
74   }
75
76   uint32_t Height() const override {
77     return height_;
78   }
79
80   uint32_t PowerMode() const override {
81     return 0;
82   }
83
84   bool GetDisplayAttribute(uint32_t config, HWCDisplayAttribute attribute,
85                            int32_t *value) override;
86
87   bool GetDisplayConfigs(uint32_t *num_configs, uint32_t *configs) override;
88   bool GetDisplayName(uint32_t *size, char *name) override;
89   int GetDisplayPipe() override;
90
91   bool SetPowerMode(uint32_t power_mode) override;
92
93   int RegisterVsyncCallback(std::shared_ptr<VsyncCallback> callback,
94                             uint32_t display_id) override;
95
96   void VSyncControl(bool enabled) override;
97   bool CheckPlaneFormat(uint32_t format) override;
98   void SetPAVPSessionStatus(bool enabled, uint32_t pavp_session_id,
99                             uint32_t pavp_instance_id) override {
100     if (enabled) {
101       discard_protected_video_ = false;
102     } else {
103       discard_protected_video_ = true;
104     }
105   }
106
107  private:
108   void InitHyperDmaBuf();
109   HWCNativeHandle output_handle_;
110   int32_t acquire_fence_ = -1;
111   Compositor compositor_;
112   uint32_t width_ = 1;
113   uint32_t height_ = 1;
114   std::vector<OverlayLayer> in_flight_layers_;
115   HWCNativeHandle handle_ = 0;
116   std::unique_ptr<ResourceManager> resource_manager_;
117   FrameBufferManager *fb_manager_ = NULL;
118   uint32_t display_index_ = 0;
119   bool discard_protected_video_ = false;
120   bool hyper_dmabuf_initialized = false;
121
122 #ifdef HYPER_DMABUF_SHARING
123   int mHyperDmaBuf_Fd = -1;
124   std::map<uint32_t, vm_buffer_info>
125       mHyperDmaExportedBuffers;  // Track the hyper dmabuf metadata info mapping
126   uint32_t frame_count_ = 0;
127 #endif
128 };
129
130 }  // namespace hwcomposer
131 #endif  // COMMON_DISPLAY_VIRTUALMOSAICDISPLAY_H_