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 COMMON_DISPLAY_VIRTUALPANORAMADISPLAY_H_
18 #define COMMON_DISPLAY_VIRTUALPANORAMADISPLAY_H_
20 #include <nativedisplay.h>
25 #include "compositor.h"
26 #include "resourcemanager.h"
27 #ifdef HYPER_DMABUF_SHARING
28 #include "hyperdmadisplay.h"
31 namespace hwcomposer {
33 class FrameBufferManager;
34 class NativeBufferHandler;
36 class VirtualPanoramaDisplay : public NativeDisplay {
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;
45 void InitVirtualDisplay(uint32_t width, uint32_t height) override;
47 bool GetActiveConfig(uint32_t *config) override;
49 bool SetActiveConfig(uint32_t config) override;
51 bool Present(std::vector<HwcLayer *> &source_layers, int32_t *retire_fence,
52 PixelUploaderCallback *call_back = NULL,
53 bool handle_constraints = false) override;
55 void SetOutputBuffer(HWCNativeHandle buffer, int32_t acquire_fence) override;
57 bool Initialize(NativeBufferHandler *buffer_handler,
58 FrameBufferManager *frame_buffer_manager) override;
60 bool IsConnected() const override {
64 void CreateOutBuffer();
66 void HyperDmaExport();
68 DisplayType Type() const override {
69 return DisplayType::kVirtual;
72 uint32_t Width() const override {
76 uint32_t Height() const override {
80 uint32_t PowerMode() const override {
84 bool GetDisplayAttribute(uint32_t config, HWCDisplayAttribute attribute,
85 int32_t *value) override;
87 bool GetDisplayConfigs(uint32_t *num_configs, uint32_t *configs) override;
88 bool GetDisplayName(uint32_t *size, char *name) override;
89 int GetDisplayPipe() override;
91 bool SetPowerMode(uint32_t power_mode) override;
93 int RegisterVsyncCallback(std::shared_ptr<VsyncCallback> callback,
94 uint32_t display_id) override;
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 {
101 discard_protected_video_ = false;
103 discard_protected_video_ = true;
108 void InitHyperDmaBuf();
109 HWCNativeHandle output_handle_;
110 int32_t acquire_fence_ = -1;
111 Compositor compositor_;
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;
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;
130 } // namespace hwcomposer
131 #endif // COMMON_DISPLAY_VIRTUALMOSAICDISPLAY_H_