Alexandru Gheorghe | c546358 | 2018-03-27 15:52:02 +0100 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2018 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 | |
Roman Stratiienko | bde9566 | 2022-12-10 20:27:58 +0200 | [diff] [blame] | 17 | #pragma once |
Alexandru Gheorghe | c546358 | 2018-03-27 15:52:02 +0100 | [diff] [blame] | 18 | |
Roman Stratiienko | e78235c | 2021-12-23 17:36:12 +0200 | [diff] [blame] | 19 | #include <cstring> |
Alexandru Gheorghe | c546358 | 2018-03-27 15:52:02 +0100 | [diff] [blame] | 20 | |
Roman Stratiienko | 13cc366 | 2020-08-29 21:35:39 +0300 | [diff] [blame] | 21 | #include "DrmDevice.h" |
Roman Stratiienko | 3dacd47 | 2022-01-11 19:18:34 +0200 | [diff] [blame] | 22 | #include "DrmDisplayPipeline.h" |
Roman Stratiienko | 8666dc9 | 2021-02-09 17:49:55 +0200 | [diff] [blame] | 23 | #include "DrmFbImporter.h" |
Roman Stratiienko | 24a7fc4 | 2021-12-23 16:25:20 +0200 | [diff] [blame] | 24 | #include "UEventListener.h" |
Roman Stratiienko | aa3cd54 | 2020-08-29 11:26:16 +0300 | [diff] [blame] | 25 | |
Alexandru Gheorghe | c546358 | 2018-03-27 15:52:02 +0100 | [diff] [blame] | 26 | namespace android { |
| 27 | |
Roman Stratiienko | 3dacd47 | 2022-01-11 19:18:34 +0200 | [diff] [blame] | 28 | class PipelineToFrontendBindingInterface { |
| 29 | public: |
| 30 | virtual ~PipelineToFrontendBindingInterface() = default; |
| 31 | virtual bool BindDisplay(DrmDisplayPipeline *); |
| 32 | virtual bool UnbindDisplay(DrmDisplayPipeline *); |
| 33 | virtual void FinalizeDisplayBinding(); |
| 34 | }; |
| 35 | |
Alexandru Gheorghe | c546358 | 2018-03-27 15:52:02 +0100 | [diff] [blame] | 36 | class ResourceManager { |
| 37 | public: |
Roman Stratiienko | 3dacd47 | 2022-01-11 19:18:34 +0200 | [diff] [blame] | 38 | explicit ResourceManager( |
| 39 | PipelineToFrontendBindingInterface *p2f_bind_interface); |
Alexandru Gheorghe | c546358 | 2018-03-27 15:52:02 +0100 | [diff] [blame] | 40 | ResourceManager(const ResourceManager &) = delete; |
| 41 | ResourceManager &operator=(const ResourceManager &) = delete; |
Roman Stratiienko | 3dacd47 | 2022-01-11 19:18:34 +0200 | [diff] [blame] | 42 | ResourceManager(const ResourceManager &&) = delete; |
| 43 | ResourceManager &&operator=(const ResourceManager &&) = delete; |
Roman Stratiienko | 24a7fc4 | 2021-12-23 16:25:20 +0200 | [diff] [blame] | 44 | ~ResourceManager(); |
Roman Stratiienko | 1e053b4 | 2021-10-25 22:54:20 +0300 | [diff] [blame] | 45 | |
Roman Stratiienko | 3dacd47 | 2022-01-11 19:18:34 +0200 | [diff] [blame] | 46 | void Init(); |
| 47 | |
| 48 | void DeInit(); |
| 49 | |
Roman Stratiienko | e78235c | 2021-12-23 17:36:12 +0200 | [diff] [blame] | 50 | bool ForcedScalingWithGpu() const { |
Roman Stratiienko | 65f2ba8 | 2019-12-20 17:04:01 +0200 | [diff] [blame] | 51 | return scale_with_gpu_; |
| 52 | } |
Alexandru Gheorghe | c546358 | 2018-03-27 15:52:02 +0100 | [diff] [blame] | 53 | |
Roman Stratiienko | 7492358 | 2022-01-17 11:24:21 +0200 | [diff] [blame] | 54 | auto &GetMainLock() { |
| 55 | return main_lock_; |
| 56 | } |
| 57 | |
Roman Stratiienko | d0c035b | 2022-01-21 15:12:56 +0200 | [diff] [blame] | 58 | static auto GetTimeMonotonicNs() -> int64_t; |
| 59 | |
Alexandru Gheorghe | c546358 | 2018-03-27 15:52:02 +0100 | [diff] [blame] | 60 | private: |
Roman Stratiienko | 3dacd47 | 2022-01-11 19:18:34 +0200 | [diff] [blame] | 61 | auto GetOrderedConnectors() -> std::vector<DrmConnector *>; |
| 62 | void UpdateFrontendDisplays(); |
| 63 | void DetachAllFrontendDisplays(); |
Alexandru Gheorghe | c546358 | 2018-03-27 15:52:02 +0100 | [diff] [blame] | 64 | |
Alexandru Gheorghe | c546358 | 2018-03-27 15:52:02 +0100 | [diff] [blame] | 65 | std::vector<std::unique_ptr<DrmDevice>> drms_; |
Roman Stratiienko | 65f2ba8 | 2019-12-20 17:04:01 +0200 | [diff] [blame] | 66 | |
Roman Stratiienko | b3b5c1e | 2021-02-15 13:44:19 +0200 | [diff] [blame] | 67 | bool scale_with_gpu_{}; |
Roman Stratiienko | 1e053b4 | 2021-10-25 22:54:20 +0300 | [diff] [blame] | 68 | |
| 69 | UEventListener uevent_listener_; |
Roman Stratiienko | 7492358 | 2022-01-17 11:24:21 +0200 | [diff] [blame] | 70 | |
| 71 | std::mutex main_lock_; |
Roman Stratiienko | 3dacd47 | 2022-01-11 19:18:34 +0200 | [diff] [blame] | 72 | |
| 73 | std::map<DrmConnector *, std::unique_ptr<DrmDisplayPipeline>> |
| 74 | attached_pipelines_; |
| 75 | |
| 76 | PipelineToFrontendBindingInterface *const frontend_interface_; |
| 77 | |
| 78 | bool initialized_{}; |
Alexandru Gheorghe | c546358 | 2018-03-27 15:52:02 +0100 | [diff] [blame] | 79 | }; |
Sean Paul | f72cccd | 2018-08-27 13:59:08 -0400 | [diff] [blame] | 80 | } // namespace android |