2 * Copyright (C) 2016 The Android Open Source Project
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 ANDROID_DRM_HWC_TWO_H_
18 #define ANDROID_DRM_HWC_TWO_H_
20 #include <hardware/hwcomposer2.h>
22 #include "drm/ResourceManager.h"
23 #include "hwc2_device/HwcDisplay.h"
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_{};
38 std::pair<HWC2_PFN_REFRESH, hwc2_callback_data_t> refresh_callback_{};
40 std::mutex callback_lock_;
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())
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);
61 void HandleDisplayHotplug(hwc2_display_t displayid, int state);
62 void HandleInitialHotplugState(DrmDevice *drmDevice);
64 void HandleHotplugUEvent();
66 ResourceManager resource_manager_;
67 std::map<hwc2_display_t, HwcDisplay> displays_;
69 std::string mDumpString;
71 } // namespace android