blob: 011f87eb4ae01f455a84c8c3212be3a6e4770107 [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
Sean Paulb386f1b2015-05-13 06:33:23 -070020#include "drmcompositor.h"
Sean Paul6a55e9f2015-04-30 15:31:06 -040021#include "drmconnector.h"
22#include "drmcrtc.h"
23#include "drmencoder.h"
Sean Paul047b9b22015-07-28 14:15:42 -040024#include "drmeventlistener.h"
Sean Paul6a55e9f2015-04-30 15:31:06 -040025#include "drmplane.h"
26
27#include <stdint.h>
28
29namespace android {
30
31class DrmResources {
32 public:
Sean Paul6a55e9f2015-04-30 15:31:06 -040033 DrmResources();
Sean Paul047b9b22015-07-28 14:15:42 -040034 ~DrmResources();
Sean Paul6a55e9f2015-04-30 15:31:06 -040035
36 int Init();
37
Zach Reiznerff30b522015-10-28 19:08:45 -070038 int fd() const {
39 return fd_.get();
40 }
Sean Paul6a55e9f2015-04-30 15:31:06 -040041
Zach Reiznerff30b522015-10-28 19:08:45 -070042 const std::vector<std::unique_ptr<DrmConnector>> &connectors() const {
43 return connectors_;
44 }
45
46 const std::vector<std::unique_ptr<DrmPlane>> &planes() const {
47 return planes_;
48 }
Sean Paul6a55e9f2015-04-30 15:31:06 -040049
Sean Paul406dbfc2016-02-10 15:35:17 -080050 std::pair<uint32_t, uint32_t> min_resolution() const {
51 return min_resolution_;
52 }
53
54 std::pair<uint32_t, uint32_t> max_resolution() const {
55 return max_resolution_;
56 }
57
Sean Paul6a55e9f2015-04-30 15:31:06 -040058 DrmConnector *GetConnectorForDisplay(int display) const;
59 DrmCrtc *GetCrtcForDisplay(int display) const;
60 DrmPlane *GetPlane(uint32_t id) const;
Sean Paulb386f1b2015-05-13 06:33:23 -070061 DrmCompositor *compositor();
Sean Paul047b9b22015-07-28 14:15:42 -040062 DrmEventListener *event_listener();
Sean Paul6a55e9f2015-04-30 15:31:06 -040063
64 int GetPlaneProperty(const DrmPlane &plane, const char *prop_name,
65 DrmProperty *property);
Sean Paul877be972015-06-03 14:08:27 -040066 int GetCrtcProperty(const DrmCrtc &crtc, const char *prop_name,
67 DrmProperty *property);
Sean Paul6a55e9f2015-04-30 15:31:06 -040068 int GetConnectorProperty(const DrmConnector &connector, const char *prop_name,
69 DrmProperty *property);
70
71 uint32_t next_mode_id();
Sean Paul877be972015-06-03 14:08:27 -040072 int SetDisplayActiveMode(int display, const DrmMode &mode);
Sean Paul6a55e9f2015-04-30 15:31:06 -040073 int SetDpmsMode(int display, uint64_t mode);
74
Sean Paul57355412015-09-19 09:14:34 -040075 int CreatePropertyBlob(void *data, size_t length, uint32_t *blob_id);
76 int DestroyPropertyBlob(uint32_t blob_id);
77
Sean Paul6a55e9f2015-04-30 15:31:06 -040078 private:
79 int TryEncoderForDisplay(int display, DrmEncoder *enc);
80 int GetProperty(uint32_t obj_id, uint32_t obj_type, const char *prop_name,
81 DrmProperty *property);
82
Sean Paul877be972015-06-03 14:08:27 -040083 int CreateDisplayPipe(DrmConnector *connector);
84
Zach Reiznerff30b522015-10-28 19:08:45 -070085 UniqueFd fd_;
86 uint32_t mode_id_ = 0;
Sean Paul6a55e9f2015-04-30 15:31:06 -040087
Zach Reiznerff30b522015-10-28 19:08:45 -070088 std::vector<std::unique_ptr<DrmConnector>> connectors_;
89 std::vector<std::unique_ptr<DrmEncoder>> encoders_;
90 std::vector<std::unique_ptr<DrmCrtc>> crtcs_;
91 std::vector<std::unique_ptr<DrmPlane>> planes_;
Sean Paulb386f1b2015-05-13 06:33:23 -070092 DrmCompositor compositor_;
Sean Paul047b9b22015-07-28 14:15:42 -040093 DrmEventListener event_listener_;
Sean Paul406dbfc2016-02-10 15:35:17 -080094
95 std::pair<uint32_t, uint32_t> min_resolution_;
96 std::pair<uint32_t, uint32_t> max_resolution_;
Sean Paul6a55e9f2015-04-30 15:31:06 -040097};
98}
99
100#endif // ANDROID_DRM_H_