OSDN Git Service

Update GPUDevice thread for DRM-master setting/dropping
[android-x86/external-IA-Hardware-Composer.git] / common / core / logicaldisplay.h
1 /*
2 // Copyright (c) 2017 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_LOGICALDISPLAY_H_
18 #define WSI_LOGICALDISPLAY_H_
19
20 #include <stdint.h>
21 #include <stdlib.h>
22
23 #include <memory>
24
25 #include <nativedisplay.h>
26
27 namespace hwcomposer {
28
29 class LogicalDisplayManager;
30
31 class LogicalDisplay : public NativeDisplay {
32  public:
33   LogicalDisplay(LogicalDisplayManager *display_manager,
34                  NativeDisplay *physical_display, uint32_t total_divisions,
35                  uint32_t index);
36   ~LogicalDisplay() override;
37
38   bool Initialize(NativeBufferHandler *buffer_handler) override;
39
40   DisplayType Type() const override {
41     return DisplayType::kLogical;
42   }
43
44   uint32_t Width() const override {
45     return width_;
46   }
47
48   uint32_t Height() const override {
49     return physical_display_->Height();
50   }
51
52   uint32_t PowerMode() const override;
53
54   int GetDisplayPipe() override;
55   bool SetActiveConfig(uint32_t config) override;
56   bool GetActiveConfig(uint32_t *config) override;
57
58   bool SetPowerMode(uint32_t power_mode) override;
59
60   bool Present(std::vector<HwcLayer *> &source_layers, int32_t *retire_fence,
61                PixelUploaderCallback *call_back = NULL,
62                bool handle_constraints = false) override;
63
64   int RegisterVsyncCallback(std::shared_ptr<VsyncCallback> callback,
65                             uint32_t display_id) override;
66
67   void RegisterRefreshCallback(std::shared_ptr<RefreshCallback> callback,
68                                uint32_t display_id) override;
69
70   void RegisterHotPlugCallback(std::shared_ptr<HotPlugCallback> callback,
71                                uint32_t display_id) override;
72
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,
82                      float *end) override;
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;
89
90   bool IsConnected() const override;
91
92   void UpdateScalingRatio(uint32_t primary_width, uint32_t primary_height,
93                           uint32_t display_width,
94                           uint32_t display_height) override;
95
96   void CloneDisplay(NativeDisplay *source_display) override;
97
98   bool PresentClone(NativeDisplay * /*display*/) override;
99
100   bool GetDisplayAttribute(uint32_t /*config*/, HWCDisplayAttribute attribute,
101                            int32_t *value) override;
102
103   bool GetDisplayConfigs(uint32_t *num_configs, uint32_t *configs) override;
104   bool GetDisplayName(uint32_t *size, char *name) override;
105
106   bool EnableDRMCommit(bool enable) override;
107
108   uint32_t GetXTranslation() override {
109     return (((physical_display_->Width()) / total_divisions_) * index_);
110   }
111
112   uint32_t GetLogicalIndex() const override {
113     return index_;
114   }
115
116   bool EnableVSync() const {
117     return enable_vsync_;
118   }
119
120   void VSyncUpdate(int64_t timestamp);
121
122   void RefreshUpdate();
123
124   void HotPlugUpdate(bool connected) override;
125
126   void SetHDCPState(HWCContentProtection state,
127                     HWCContentType content_type) override;
128   void SetHDCPSRM(const int8_t *SRM, uint32_t SRMLength) override;
129
130   bool ContainConnector(const uint32_t connector_id) override;
131
132  private:
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;
140   uint32_t index_ = 0;
141   uint32_t width_ = 0;
142   uint32_t total_divisions_ = 1;
143   bool enable_vsync_ = false;
144 };
145
146 }  // namespace hwcomposer
147 #endif  // WSI_LOGICALDISPLAY_H_