blob: 1261956a767b078a2de7bae194685214117dffb5 [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"
24#include "drmplane.h"
25
26#include <stdint.h>
27
28namespace android {
29
30class DrmResources {
31 public:
32 typedef std::vector<DrmConnector *>::const_iterator ConnectorIter;
33 typedef std::vector<DrmPlane *>::const_iterator PlaneIter;
34
35 DrmResources();
36 ~DrmResources();
37
38 int Init();
39
40 int fd() const;
41
42 ConnectorIter begin_connectors() const;
43 ConnectorIter end_connectors() const;
44 PlaneIter begin_planes() const;
45 PlaneIter end_planes() const;
46
47 DrmConnector *GetConnectorForDisplay(int display) const;
48 DrmCrtc *GetCrtcForDisplay(int display) const;
49 DrmPlane *GetPlane(uint32_t id) const;
Sean Paulb386f1b2015-05-13 06:33:23 -070050 DrmCompositor *compositor();
Sean Paul6a55e9f2015-04-30 15:31:06 -040051
52 int GetPlaneProperty(const DrmPlane &plane, const char *prop_name,
53 DrmProperty *property);
54 int GetConnectorProperty(const DrmConnector &connector, const char *prop_name,
55 DrmProperty *property);
56
57 uint32_t next_mode_id();
58 int SetDisplayActiveMode(int display, uint32_t mode_id);
59 int SetDpmsMode(int display, uint64_t mode);
60
61 private:
62 int TryEncoderForDisplay(int display, DrmEncoder *enc);
63 int GetProperty(uint32_t obj_id, uint32_t obj_type, const char *prop_name,
64 DrmProperty *property);
65
66 int fd_;
67 uint32_t mode_id_;
68
69 std::vector<DrmConnector *> connectors_;
70 std::vector<DrmEncoder *> encoders_;
71 std::vector<DrmCrtc *> crtcs_;
72 std::vector<DrmPlane *> planes_;
Sean Paulb386f1b2015-05-13 06:33:23 -070073 DrmCompositor compositor_;
Sean Paul6a55e9f2015-04-30 15:31:06 -040074};
75}
76
77#endif // ANDROID_DRM_H_