OSDN Git Service

b1c471696116670ce75dcd0288a1c06193d7a227
[android-x86/external-IA-Hardware-Composer.git] / common / core / mosaicdisplay.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_MOSAICDISPLAY_H_
18 #define WSI_MOSAICDISPLAY_H_
19
20 #include <stdint.h>
21 #include <stdlib.h>
22
23 #include <memory>
24
25 #include <nativedisplay.h>
26 #include <spinlock.h>
27
28 namespace hwcomposer {
29
30 class MosaicDisplay : public NativeDisplay {
31  public:
32   MosaicDisplay(const std::vector<NativeDisplay *> &displays);
33   ~MosaicDisplay() override;
34
35   bool Initialize(NativeBufferHandler *buffer_handler,
36                   FrameBufferManager * /*frame_buffer_manager*/) override;
37
38   DisplayType Type() const override {
39     return DisplayType::kMosaic;
40   }
41
42   uint32_t Width() const override;
43
44   uint32_t Height() const override;
45
46   uint32_t PowerMode() const override;
47
48   int GetDisplayPipe() override;
49   bool SetActiveConfig(uint32_t config) override;
50   bool GetActiveConfig(uint32_t *config) override;
51
52   bool SetPowerMode(uint32_t power_mode) override;
53
54   bool Present(std::vector<HwcLayer *> &source_layers, int32_t *retire_fence,
55                PixelUploaderCallback *call_back = NULL,
56                bool handle_constraints = false) override;
57
58   int RegisterVsyncCallback(std::shared_ptr<VsyncCallback> callback,
59                             uint32_t display_id) override;
60
61   void RegisterRefreshCallback(std::shared_ptr<RefreshCallback> callback,
62                                uint32_t display_id) override;
63
64   void RegisterHotPlugCallback(std::shared_ptr<HotPlugCallback> callback,
65                                uint32_t display_id) override;
66
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,
76                      float *end) override;
77   void RestoreVideoDefaultColor(HWCColorControl color) override;
78   void SetVideoDeinterlace(HWCDeinterlaceFlag flag,
79                            HWCDeinterlaceControl mode) override;
80   void RestoreVideoDefaultDeinterlace() override;
81
82   bool IsConnected() const override;
83
84   void UpdateScalingRatio(uint32_t primary_width, uint32_t primary_height,
85                           uint32_t display_width,
86                           uint32_t display_height) override;
87
88   void CloneDisplay(NativeDisplay *source_display) override;
89
90   bool PresentClone(NativeDisplay * /*display*/) override;
91
92   bool GetDisplayAttribute(uint32_t /*config*/, HWCDisplayAttribute attribute,
93                            int32_t *value) override;
94
95   bool GetDisplayConfigs(uint32_t *num_configs, uint32_t *configs) override;
96   bool GetDisplayName(uint32_t *size, char *name) override;
97
98   uint32_t GetXTranslation() override {
99     return 0;
100   }
101
102   bool EnableVSync() const {
103     return enable_vsync_;
104   }
105
106   void VSyncUpdate(int64_t timestamp);
107
108   void RefreshUpdate();
109
110   void HotPlugUpdate(bool connected);
111
112   void SetHDCPState(HWCContentProtection state,
113                     HWCContentType content_type) override;
114   void SetHDCPSRM(const int8_t *SRM, uint32_t SRMLength) override;
115
116   bool ContainConnector(const uint32_t connector_id) override;
117
118  private:
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;
124   int32_t dpix_;
125   int32_t dpiy_;
126   uint32_t refresh_ = 0;
127   uint32_t power_mode_ = kOff;
128   uint32_t display_id_ = 0;
129   uint32_t width_ = 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;
139   SpinLock lock_;
140 };
141
142 }  // namespace hwcomposer
143 #endif  // WSI_MosaicDisplay_H_