blob: 9b4155b520c0c1a42a6b99ba634056f5a7706e20 [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 Stratiienko13cc3662020-08-29 21:35:39 +030022#include "DrmDevice.h"
Roman Stratiienko8666dc92021-02-09 17:49:55 +020023#include "DrmFbImporter.h"
Roman Stratiienkoaa3cd542020-08-29 11:26:16 +030024
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);
Alexandru Gheorghec5463582018-03-27 15:52:02 +010034 const gralloc_module_t *gralloc();
Alexandru Gheorgheb6a675e2018-03-27 16:10:55 +010035 DrmConnector *AvailableWritebackConnector(int display);
Andrii Chepurnyi495e4cc2018-08-01 17:42:56 +030036 const std::vector<std::unique_ptr<DrmDevice>> &getDrmDevices() const {
37 return drms_;
38 }
39 int getDisplayCount() const {
40 return num_displays_;
41 }
Roman Stratiienko65f2ba82019-12-20 17:04:01 +020042 bool ForcedScalingWithGpu() {
43 return scale_with_gpu_;
44 }
Alexandru Gheorghec5463582018-03-27 15:52:02 +010045
46 private:
Roman Stratiienkoe2f2c922021-02-13 10:57:47 +020047 int AddDrmDevice(std::string const &path);
Matvii Zorinec75ccd2020-07-17 12:08:45 +030048 static bool IsKMSDev(const char *path);
Alexandru Gheorghec5463582018-03-27 15:52:02 +010049
50 int num_displays_;
51 std::vector<std::unique_ptr<DrmDevice>> drms_;
Alexandru Gheorghec5463582018-03-27 15:52:02 +010052 const gralloc_module_t *gralloc_;
Roman Stratiienko65f2ba82019-12-20 17:04:01 +020053
Roman Stratiienkob3b5c1e2021-02-15 13:44:19 +020054 bool scale_with_gpu_{};
Alexandru Gheorghec5463582018-03-27 15:52:02 +010055};
Sean Paulf72cccd2018-08-27 13:59:08 -040056} // namespace android
Alexandru Gheorghec5463582018-03-27 15:52:02 +010057
58#endif // RESOURCEMANAGER_H