blob: 5a82f904f16437edb0936e6b282627dd45700d62 [file] [log] [blame]
Sean Paul6a55e9f2015-04-30 15:31:06 -04001/*
2 * Copyright (C) 2015 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 ANDROID_DRM_H_
18#define ANDROID_DRM_H_
19
20#include "drmconnector.h"
21#include "drmcrtc.h"
22#include "drmencoder.h"
Sean Paul047b9b22015-07-28 14:15:42 -040023#include "drmeventlistener.h"
Sean Paul6a55e9f2015-04-30 15:31:06 -040024#include "drmplane.h"
25
26#include <stdint.h>
27
28namespace android {
29
Alexandru Gheorghe0f5abd72018-05-01 14:37:10 +010030class DrmDevice {
Sean Paul6a55e9f2015-04-30 15:31:06 -040031 public:
Alexandru Gheorghe0f5abd72018-05-01 14:37:10 +010032 DrmDevice();
33 ~DrmDevice();
Sean Paul6a55e9f2015-04-30 15:31:06 -040034
35 int Init();
36
Zach Reiznerff30b522015-10-28 19:08:45 -070037 int fd() const {
38 return fd_.get();
39 }
Sean Paul6a55e9f2015-04-30 15:31:06 -040040
Zach Reiznerff30b522015-10-28 19:08:45 -070041 const std::vector<std::unique_ptr<DrmConnector>> &connectors() const {
42 return connectors_;
43 }
44
45 const std::vector<std::unique_ptr<DrmPlane>> &planes() const {
46 return planes_;
47 }
Sean Paul6a55e9f2015-04-30 15:31:06 -040048
Sean Paul406dbfc2016-02-10 15:35:17 -080049 std::pair<uint32_t, uint32_t> min_resolution() const {
50 return min_resolution_;
51 }
52
53 std::pair<uint32_t, uint32_t> max_resolution() const {
54 return max_resolution_;
55 }
56
Sean Paul6a55e9f2015-04-30 15:31:06 -040057 DrmConnector *GetConnectorForDisplay(int display) const;
58 DrmCrtc *GetCrtcForDisplay(int display) const;
59 DrmPlane *GetPlane(uint32_t id) const;
Sean Paul047b9b22015-07-28 14:15:42 -040060 DrmEventListener *event_listener();
Sean Paul6a55e9f2015-04-30 15:31:06 -040061
62 int GetPlaneProperty(const DrmPlane &plane, const char *prop_name,
63 DrmProperty *property);
Sean Paul877be972015-06-03 14:08:27 -040064 int GetCrtcProperty(const DrmCrtc &crtc, const char *prop_name,
65 DrmProperty *property);
Sean Paul6a55e9f2015-04-30 15:31:06 -040066 int GetConnectorProperty(const DrmConnector &connector, const char *prop_name,
67 DrmProperty *property);
68
Robert Foss0690c1c2016-10-20 11:07:57 -040069 const std::vector<std::unique_ptr<DrmCrtc>> &crtcs() const;
Sean Paul6a55e9f2015-04-30 15:31:06 -040070 uint32_t next_mode_id();
Sean Paul6a55e9f2015-04-30 15:31:06 -040071
Sean Paul57355412015-09-19 09:14:34 -040072 int CreatePropertyBlob(void *data, size_t length, uint32_t *blob_id);
73 int DestroyPropertyBlob(uint32_t blob_id);
74
Sean Paul6a55e9f2015-04-30 15:31:06 -040075 private:
76 int TryEncoderForDisplay(int display, DrmEncoder *enc);
77 int GetProperty(uint32_t obj_id, uint32_t obj_type, const char *prop_name,
78 DrmProperty *property);
79
Sean Paul877be972015-06-03 14:08:27 -040080 int CreateDisplayPipe(DrmConnector *connector);
81
Zach Reiznerff30b522015-10-28 19:08:45 -070082 UniqueFd fd_;
83 uint32_t mode_id_ = 0;
Sean Paul6a55e9f2015-04-30 15:31:06 -040084
Zach Reiznerff30b522015-10-28 19:08:45 -070085 std::vector<std::unique_ptr<DrmConnector>> connectors_;
86 std::vector<std::unique_ptr<DrmEncoder>> encoders_;
87 std::vector<std::unique_ptr<DrmCrtc>> crtcs_;
88 std::vector<std::unique_ptr<DrmPlane>> planes_;
Sean Paul047b9b22015-07-28 14:15:42 -040089 DrmEventListener event_listener_;
Sean Paul406dbfc2016-02-10 15:35:17 -080090
91 std::pair<uint32_t, uint32_t> min_resolution_;
92 std::pair<uint32_t, uint32_t> max_resolution_;
Sean Paul6a55e9f2015-04-30 15:31:06 -040093};
94}
95
96#endif // ANDROID_DRM_H_