OSDN Git Service

drm_hwcomposer: Move HwcDisplay out of DrmHwcTwo class
[android-x86/external-drm_hwcomposer.git] / DrmHwcTwo.h
1 /*
2  * Copyright (C) 2016 The Android Open Source Project
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 ANDROID_DRM_HWC_TWO_H_
18 #define ANDROID_DRM_HWC_TWO_H_
19
20 #include <hardware/hwcomposer2.h>
21
22 #include "drm/ResourceManager.h"
23 #include "hwc2_device/HwcDisplay.h"
24
25 namespace android {
26
27 class DrmHwcTwo {
28  public:
29   DrmHwcTwo();
30
31   HWC2::Error Init();
32
33   std::pair<HWC2_PFN_HOTPLUG, hwc2_callback_data_t> hotplug_callback_{};
34   std::pair<HWC2_PFN_VSYNC, hwc2_callback_data_t> vsync_callback_{};
35 #if PLATFORM_SDK_VERSION > 29
36   std::pair<HWC2_PFN_VSYNC_2_4, hwc2_callback_data_t> vsync_2_4_callback_{};
37 #endif
38   std::pair<HWC2_PFN_REFRESH, hwc2_callback_data_t> refresh_callback_{};
39
40   std::mutex callback_lock_;
41
42   static HwcDisplay *GetDisplay(DrmHwcTwo *hwc, hwc2_display_t display_handle) {
43     auto it = hwc->displays_.find(display_handle);
44     if (it == hwc->displays_.end())
45       return nullptr;
46
47     return &it->second;
48   }
49
50   // Device functions
51   HWC2::Error CreateVirtualDisplay(uint32_t width, uint32_t height,
52                                    int32_t *format, hwc2_display_t *display);
53   HWC2::Error DestroyVirtualDisplay(hwc2_display_t display);
54   void Dump(uint32_t *outSize, char *outBuffer);
55   uint32_t GetMaxVirtualDisplayCount();
56   HWC2::Error RegisterCallback(int32_t descriptor, hwc2_callback_data_t data,
57                                hwc2_function_pointer_t function);
58   HWC2::Error CreateDisplay(hwc2_display_t displ, HWC2::DisplayType type);
59
60  private:
61   void HandleDisplayHotplug(hwc2_display_t displayid, int state);
62   void HandleInitialHotplugState(DrmDevice *drmDevice);
63
64   void HandleHotplugUEvent();
65
66   ResourceManager resource_manager_;
67   std::map<hwc2_display_t, HwcDisplay> displays_;
68
69   std::string mDumpString;
70 };
71 }  // namespace android
72
73 #endif