blob: f54d6822dc903e418fbfb2da9e715c01a47aaca5 [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
17#ifndef RESOURCEMANAGER_H
18#define RESOURCEMANAGER_H
19
Roman Stratiienkoe78235c2021-12-23 17:36:12 +020020#include <cstring>
Alexandru Gheorghec5463582018-03-27 15:52:02 +010021
Roman Stratiienko13cc3662020-08-29 21:35:39 +030022#include "DrmDevice.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
28class ResourceManager {
29 public:
30 ResourceManager();
31 ResourceManager(const ResourceManager &) = delete;
32 ResourceManager &operator=(const ResourceManager &) = delete;
Roman Stratiienko24a7fc42021-12-23 16:25:20 +020033 ~ResourceManager();
Roman Stratiienko1e053b42021-10-25 22:54:20 +030034
Alexandru Gheorghec5463582018-03-27 15:52:02 +010035 int Init();
36 DrmDevice *GetDrmDevice(int display);
Roman Stratiienkofc014f52021-12-23 19:04:29 +020037 const std::vector<std::unique_ptr<DrmDevice>> &GetDrmDevices() const {
Andrii Chepurnyi495e4cc2018-08-01 17:42:56 +030038 return drms_;
39 }
Roman Stratiienkofc014f52021-12-23 19:04:29 +020040 int GetDisplayCount() const {
Andrii Chepurnyi495e4cc2018-08-01 17:42:56 +030041 return num_displays_;
42 }
Roman Stratiienkoe78235c2021-12-23 17:36:12 +020043 bool ForcedScalingWithGpu() const {
Roman Stratiienko65f2ba82019-12-20 17:04:01 +020044 return scale_with_gpu_;
45 }
Alexandru Gheorghec5463582018-03-27 15:52:02 +010046
Roman Stratiienko1e053b42021-10-25 22:54:20 +030047 UEventListener *GetUEventListener() {
48 return &uevent_listener_;
49 }
50
Roman Stratiienko74923582022-01-17 11:24:21 +020051 auto &GetMainLock() {
52 return main_lock_;
53 }
54
Alexandru Gheorghec5463582018-03-27 15:52:02 +010055 private:
Roman Stratiienkoe2f2c922021-02-13 10:57:47 +020056 int AddDrmDevice(std::string const &path);
Alexandru Gheorghec5463582018-03-27 15:52:02 +010057
58 int num_displays_;
59 std::vector<std::unique_ptr<DrmDevice>> drms_;
Roman Stratiienko65f2ba82019-12-20 17:04:01 +020060
Roman Stratiienkob3b5c1e2021-02-15 13:44:19 +020061 bool scale_with_gpu_{};
Roman Stratiienko1e053b42021-10-25 22:54:20 +030062
63 UEventListener uevent_listener_;
Roman Stratiienko74923582022-01-17 11:24:21 +020064
65 std::mutex main_lock_;
Alexandru Gheorghec5463582018-03-27 15:52:02 +010066};
Sean Paulf72cccd2018-08-27 13:59:08 -040067} // namespace android
Alexandru Gheorghec5463582018-03-27 15:52:02 +010068
69#endif // RESOURCEMANAGER_H