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_LOGICALDISPLAY_H_
18 #define WSI_LOGICALDISPLAY_H_
25 #include <nativedisplay.h>
27 namespace hwcomposer {
29 class LogicalDisplayManager;
31 class LogicalDisplay : public NativeDisplay {
33 LogicalDisplay(LogicalDisplayManager *display_manager,
34 NativeDisplay *physical_display, uint32_t total_divisions,
36 ~LogicalDisplay() override;
38 bool Initialize(NativeBufferHandler *buffer_handler) override;
40 DisplayType Type() const override {
41 return DisplayType::kLogical;
44 uint32_t Width() const override {
48 uint32_t Height() const override {
49 return physical_display_->Height();
52 uint32_t PowerMode() const override;
54 int GetDisplayPipe() override;
55 bool SetActiveConfig(uint32_t config) override;
56 bool GetActiveConfig(uint32_t *config) override;
58 bool SetPowerMode(uint32_t power_mode) override;
60 bool Present(std::vector<HwcLayer *> &source_layers, int32_t *retire_fence,
61 PixelUploaderCallback *call_back = NULL,
62 bool handle_constraints = false) override;
64 int RegisterVsyncCallback(std::shared_ptr<VsyncCallback> callback,
65 uint32_t display_id) override;
67 void RegisterRefreshCallback(std::shared_ptr<RefreshCallback> callback,
68 uint32_t display_id) override;
70 void RegisterHotPlugCallback(std::shared_ptr<HotPlugCallback> callback,
71 uint32_t display_id) override;
73 void VSyncControl(bool enabled) override;
74 bool CheckPlaneFormat(uint32_t format) override;
75 void SetGamma(float red, float green, float blue) override;
76 void SetContrast(uint32_t red, uint32_t green, uint32_t blue) override;
77 void SetBrightness(uint32_t red, uint32_t green, uint32_t blue) override;
78 void SetDisableExplicitSync(bool disable_explicit_sync) override;
79 void SetVideoScalingMode(uint32_t mode) override;
80 void SetVideoColor(HWCColorControl color, float value) override;
81 void GetVideoColor(HWCColorControl color, float *value, float *start,
83 void SetCanvasColor(uint16_t bpc, uint16_t red, uint16_t green, uint16_t blue,
84 uint16_t alpha) override;
85 void RestoreVideoDefaultColor(HWCColorControl color) override;
86 void SetVideoDeinterlace(HWCDeinterlaceFlag flag,
87 HWCDeinterlaceControl mode) override;
88 void RestoreVideoDefaultDeinterlace() override;
90 bool IsConnected() const override;
92 void UpdateScalingRatio(uint32_t primary_width, uint32_t primary_height,
93 uint32_t display_width,
94 uint32_t display_height) override;
96 void CloneDisplay(NativeDisplay *source_display) override;
98 bool PresentClone(NativeDisplay * /*display*/) override;
100 bool GetDisplayAttribute(uint32_t /*config*/, HWCDisplayAttribute attribute,
101 int32_t *value) override;
103 bool GetDisplayConfigs(uint32_t *num_configs, uint32_t *configs) override;
104 bool GetDisplayName(uint32_t *size, char *name) override;
106 bool EnableDRMCommit(bool enable) override;
108 uint32_t GetXTranslation() override {
109 return (((physical_display_->Width()) / total_divisions_) * index_);
112 uint32_t GetLogicalIndex() const override {
116 bool EnableVSync() const {
117 return enable_vsync_;
120 void VSyncUpdate(int64_t timestamp);
122 void RefreshUpdate();
124 void HotPlugUpdate(bool connected) override;
126 void SetHDCPState(HWCContentProtection state,
127 HWCContentType content_type) override;
128 void SetHDCPSRM(const int8_t *SRM, uint32_t SRMLength) override;
130 bool ContainConnector(const uint32_t connector_id) override;
133 LogicalDisplayManager *logical_display_manager_;
134 NativeDisplay *physical_display_;
135 std::shared_ptr<RefreshCallback> refresh_callback_ = NULL;
136 std::shared_ptr<VsyncCallback> vsync_callback_ = NULL;
137 std::shared_ptr<HotPlugCallback> hotplug_callback_ = NULL;
138 uint32_t power_mode_ = kOff;
139 uint32_t display_id_ = 0;
142 uint32_t total_divisions_ = 1;
143 bool enable_vsync_ = false;
146 } // namespace hwcomposer
147 #endif // WSI_LOGICALDISPLAY_H_