blob: fb91627b8f739c0564871970c001e0924cb45d0d [file] [log] [blame]
Alexandru Gheorghec5463582018-03-27 15:52:02 +01001/*
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 Stratiienkobde95662022-12-10 20:27:58 +020017#pragma once
Alexandru Gheorghec5463582018-03-27 15:52:02 +010018
Roman Stratiienkoe78235c2021-12-23 17:36:12 +020019#include <cstring>
Alexandru Gheorghec5463582018-03-27 15:52:02 +010020
Roman Stratiienko13cc3662020-08-29 21:35:39 +030021#include "DrmDevice.h"
Roman Stratiienko3dacd472022-01-11 19:18:34 +020022#include "DrmDisplayPipeline.h"
Roman Stratiienko8666dc92021-02-09 17:49:55 +020023#include "DrmFbImporter.h"
Roman Stratiienko24a7fc42021-12-23 16:25:20 +020024#include "UEventListener.h"
Roman Stratiienkoaa3cd542020-08-29 11:26:16 +030025
Alexandru Gheorghec5463582018-03-27 15:52:02 +010026namespace android {
27
Roman Stratiienko3dacd472022-01-11 19:18:34 +020028class PipelineToFrontendBindingInterface {
29 public:
30 virtual ~PipelineToFrontendBindingInterface() = default;
31 virtual bool BindDisplay(DrmDisplayPipeline *);
32 virtual bool UnbindDisplay(DrmDisplayPipeline *);
33 virtual void FinalizeDisplayBinding();
34};
35
Alexandru Gheorghec5463582018-03-27 15:52:02 +010036class ResourceManager {
37 public:
Roman Stratiienko3dacd472022-01-11 19:18:34 +020038 explicit ResourceManager(
39 PipelineToFrontendBindingInterface *p2f_bind_interface);
Alexandru Gheorghec5463582018-03-27 15:52:02 +010040 ResourceManager(const ResourceManager &) = delete;
41 ResourceManager &operator=(const ResourceManager &) = delete;
Roman Stratiienko3dacd472022-01-11 19:18:34 +020042 ResourceManager(const ResourceManager &&) = delete;
43 ResourceManager &&operator=(const ResourceManager &&) = delete;
Roman Stratiienko24a7fc42021-12-23 16:25:20 +020044 ~ResourceManager();
Roman Stratiienko1e053b42021-10-25 22:54:20 +030045
Roman Stratiienko3dacd472022-01-11 19:18:34 +020046 void Init();
47
48 void DeInit();
49
Roman Stratiienkoe78235c2021-12-23 17:36:12 +020050 bool ForcedScalingWithGpu() const {
Roman Stratiienko65f2ba82019-12-20 17:04:01 +020051 return scale_with_gpu_;
52 }
Alexandru Gheorghec5463582018-03-27 15:52:02 +010053
Roman Stratiienko74923582022-01-17 11:24:21 +020054 auto &GetMainLock() {
55 return main_lock_;
56 }
57
Roman Stratiienkod0c035b2022-01-21 15:12:56 +020058 static auto GetTimeMonotonicNs() -> int64_t;
59
Alexandru Gheorghec5463582018-03-27 15:52:02 +010060 private:
Roman Stratiienko3dacd472022-01-11 19:18:34 +020061 auto GetOrderedConnectors() -> std::vector<DrmConnector *>;
62 void UpdateFrontendDisplays();
63 void DetachAllFrontendDisplays();
Alexandru Gheorghec5463582018-03-27 15:52:02 +010064
Alexandru Gheorghec5463582018-03-27 15:52:02 +010065 std::vector<std::unique_ptr<DrmDevice>> drms_;
Roman Stratiienko65f2ba82019-12-20 17:04:01 +020066
Roman Stratiienkob3b5c1e2021-02-15 13:44:19 +020067 bool scale_with_gpu_{};
Roman Stratiienko1e053b42021-10-25 22:54:20 +030068
69 UEventListener uevent_listener_;
Roman Stratiienko74923582022-01-17 11:24:21 +020070
71 std::mutex main_lock_;
Roman Stratiienko3dacd472022-01-11 19:18:34 +020072
73 std::map<DrmConnector *, std::unique_ptr<DrmDisplayPipeline>>
74 attached_pipelines_;
75
76 PipelineToFrontendBindingInterface *const frontend_interface_;
77
78 bool initialized_{};
Alexandru Gheorghec5463582018-03-27 15:52:02 +010079};
Sean Paulf72cccd2018-08-27 13:59:08 -040080} // namespace android