2 // Copyright (c) 2017 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_MOSAICDISPLAY_H_
18 #define WSI_MOSAICDISPLAY_H_
25 #include <nativedisplay.h>
28 namespace hwcomposer {
30 class MosaicDisplay : public NativeDisplay {
32 MosaicDisplay(const std::vector<NativeDisplay *> &displays);
33 ~MosaicDisplay() override;
35 bool Initialize(NativeBufferHandler *buffer_handler,
36 FrameBufferManager * /*frame_buffer_manager*/) override;
38 DisplayType Type() const override {
39 return DisplayType::kMosaic;
42 uint32_t Width() const override;
44 uint32_t Height() const override;
46 uint32_t PowerMode() const override;
48 int GetDisplayPipe() override;
49 bool SetActiveConfig(uint32_t config) override;
50 bool GetActiveConfig(uint32_t *config) override;
52 bool SetPowerMode(uint32_t power_mode) override;
54 bool Present(std::vector<HwcLayer *> &source_layers, int32_t *retire_fence,
55 PixelUploaderCallback *call_back = NULL,
56 bool handle_constraints = false) override;
58 int RegisterVsyncCallback(std::shared_ptr<VsyncCallback> callback,
59 uint32_t display_id) override;
61 void RegisterRefreshCallback(std::shared_ptr<RefreshCallback> callback,
62 uint32_t display_id) override;
64 void RegisterHotPlugCallback(std::shared_ptr<HotPlugCallback> callback,
65 uint32_t display_id) override;
67 void VSyncControl(bool enabled) override;
68 bool CheckPlaneFormat(uint32_t format) override;
69 void SetGamma(float red, float green, float blue) override;
70 void SetContrast(uint32_t red, uint32_t green, uint32_t blue) override;
71 void SetBrightness(uint32_t red, uint32_t green, uint32_t blue) override;
72 void SetDisableExplicitSync(bool disable_explicit_sync) override;
73 void SetVideoScalingMode(uint32_t mode) override;
74 void SetVideoColor(HWCColorControl color, float value) override;
75 void GetVideoColor(HWCColorControl color, float *value, float *start,
77 void RestoreVideoDefaultColor(HWCColorControl color) override;
78 void SetVideoDeinterlace(HWCDeinterlaceFlag flag,
79 HWCDeinterlaceControl mode) override;
80 void RestoreVideoDefaultDeinterlace() override;
82 bool IsConnected() const override;
84 void UpdateScalingRatio(uint32_t primary_width, uint32_t primary_height,
85 uint32_t display_width,
86 uint32_t display_height) override;
88 void CloneDisplay(NativeDisplay *source_display) override;
90 bool PresentClone(NativeDisplay * /*display*/) override;
92 bool GetDisplayAttribute(uint32_t /*config*/, HWCDisplayAttribute attribute,
93 int32_t *value) override;
95 bool GetDisplayConfigs(uint32_t *num_configs, uint32_t *configs) override;
96 bool GetDisplayName(uint32_t *size, char *name) override;
98 uint32_t GetXTranslation() override {
102 bool EnableVSync() const {
103 return enable_vsync_;
106 void VSyncUpdate(int64_t timestamp);
108 void RefreshUpdate();
110 void HotPlugUpdate(bool connected);
112 void SetHDCPState(HWCContentProtection state,
113 HWCContentType content_type) override;
114 void SetHDCPSRM(const int8_t *SRM, uint32_t SRMLength) override;
116 bool ContainConnector(const uint32_t connector_id) override;
119 std::vector<NativeDisplay *> physical_displays_;
120 std::vector<NativeDisplay *> connected_displays_;
121 std::shared_ptr<RefreshCallback> refresh_callback_ = NULL;
122 std::shared_ptr<VsyncCallback> vsync_callback_ = NULL;
123 std::shared_ptr<HotPlugCallback> hotplug_callback_ = NULL;
126 uint32_t refresh_ = 0;
127 uint32_t power_mode_ = kOff;
128 uint32_t display_id_ = 0;
130 uint32_t height_ = 0;
131 uint32_t config_ = 0;
132 uint32_t vsync_counter_ = 0;
133 uint32_t vsync_divisor_ = 0;
134 int64_t vsync_timestamp_ = 0;
135 bool enable_vsync_ = false;
136 bool connected_ = false;
137 bool pending_vsync_ = false;
138 bool update_connected_displays_ = true;
142 } // namespace hwcomposer
143 #endif // WSI_MosaicDisplay_H_