blob: 4afa842aa59867fefa0ef508c2025b831b1cf567 [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
Alexandru Gheorghec5463582018-03-27 15:52:02 +010020#include <string.h>
21
Roman Stratiienkoaa3cd542020-08-29 11:26:16 +030022#include "drmdevice.h"
23#include "platform/platform.h"
24
Alexandru Gheorghec5463582018-03-27 15:52:02 +010025namespace android {
26
27class ResourceManager {
28 public:
29 ResourceManager();
30 ResourceManager(const ResourceManager &) = delete;
31 ResourceManager &operator=(const ResourceManager &) = delete;
32 int Init();
33 DrmDevice *GetDrmDevice(int display);
34 std::shared_ptr<Importer> GetImporter(int display);
35 const gralloc_module_t *gralloc();
Alexandru Gheorgheb6a675e2018-03-27 16:10:55 +010036 DrmConnector *AvailableWritebackConnector(int display);
Andrii Chepurnyi495e4cc2018-08-01 17:42:56 +030037 const std::vector<std::unique_ptr<DrmDevice>> &getDrmDevices() const {
38 return drms_;
39 }
40 int getDisplayCount() const {
41 return num_displays_;
42 }
Roman Stratiienko65f2ba82019-12-20 17:04:01 +020043 bool ForcedScalingWithGpu() {
44 return scale_with_gpu_;
45 }
Alexandru Gheorghec5463582018-03-27 15:52:02 +010046
47 private:
48 int AddDrmDevice(std::string path);
Matvii Zorinec75ccd2020-07-17 12:08:45 +030049 static bool IsKMSDev(const char *path);
Alexandru Gheorghec5463582018-03-27 15:52:02 +010050
51 int num_displays_;
52 std::vector<std::unique_ptr<DrmDevice>> drms_;
53 std::vector<std::shared_ptr<Importer>> importers_;
54 const gralloc_module_t *gralloc_;
Roman Stratiienko65f2ba82019-12-20 17:04:01 +020055
56 bool scale_with_gpu_;
Alexandru Gheorghec5463582018-03-27 15:52:02 +010057};
Sean Paulf72cccd2018-08-27 13:59:08 -040058} // namespace android
Alexandru Gheorghec5463582018-03-27 15:52:02 +010059
60#endif // RESOURCEMANAGER_H