1 /*
2  * Copyright (c) 2022 Huawei Device Co., Ltd.
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at
6  *
7  *     http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  */
15 
16 #ifndef FB_DISPLAY_H
17 #define FB_DISPLAY_H
18 #include <unordered_map>
19 #include <memory>
20 #include <vector>
21 #include "hdi_display.h"
22 #include "hdi_composer.h"
23 #include "fb_composition.h"
24 
25 namespace OHOS {
26 namespace HDI {
27 namespace DISPLAY {
28 class FbDisplay : public HdiDisplay {
29 public:
30     explicit FbDisplay(const std::vector<int> &fds);
31     virtual ~FbDisplay();
32     int32_t Init() override;
33     int32_t GetDisplayCapability(DisplayCapability *info) override;
34     int32_t GetDisplaySupportedModes(uint32_t *num, DisplayModeInfo *modes) override;
35     int32_t GetDisplayMode(uint32_t *modeId) override;
36     int32_t SetDisplayMode(uint32_t modeId) override;
37     int32_t GetDisplayPowerStatus(DispPowerStatus *status) override;
38     int32_t SetDisplayPowerStatus(DispPowerStatus status) override;
39     int32_t GetDisplayBacklight(uint32_t *value) override;
40     int32_t SetDisplayBacklight(uint32_t value) override;
41     virtual int32_t RegDisplayVBlankCallback(VBlankCallback cb, void *data) override;
42     virtual bool IsConnected() override;
43     virtual int32_t SetDisplayVsyncEnabled(bool enabled) override;
44 protected:
45     std::unique_ptr<HdiLayer> CreateHdiLayer(LayerType type) override;
46 private:
47     // the first fd is the master device fd
48     std::vector<int> deviceFds_;
49     std::vector<DisplayModeInfo> modes_;
50     uint32_t mActiveModeId = INVALID_MODE_ID;
51     DisplayCapability displayCapability_;
52     DispPowerStatus mPowerstatus = POWER_STATUS_ON;
53 };
54 } // namespace OHOS
55 } // namespace HDI
56 } // namespace DISPLAY
57 
58 #endif // HDI_DISPLAY_H