blob: 67168076e553ec098f32f3cebebb9de3d656dfaf [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:
Sean Paul6a55e9f2015-04-30 15:31:06 -040032 DrmResources();
Sean Paul6a55e9f2015-04-30 15:31:06 -040033
34 int Init();
35
Zach Reiznerff30b522015-10-28 19:08:45 -070036 int fd() const {
37 return fd_.get();
38 }
Sean Paul6a55e9f2015-04-30 15:31:06 -040039
Zach Reiznerff30b522015-10-28 19:08:45 -070040 const std::vector<std::unique_ptr<DrmConnector>> &connectors() const {
41 return connectors_;
42 }
43
44 const std::vector<std::unique_ptr<DrmPlane>> &planes() const {
45 return planes_;
46 }
Sean Paul6a55e9f2015-04-30 15:31:06 -040047
48 DrmConnector *GetConnectorForDisplay(int display) const;
49 DrmCrtc *GetCrtcForDisplay(int display) const;
50 DrmPlane *GetPlane(uint32_t id) const;
Sean Paulb386f1b2015-05-13 06:33:23 -070051 DrmCompositor *compositor();
Sean Paul6a55e9f2015-04-30 15:31:06 -040052
53 int GetPlaneProperty(const DrmPlane &plane, const char *prop_name,
54 DrmProperty *property);
Sean Paul877be972015-06-03 14:08:27 -040055 int GetCrtcProperty(const DrmCrtc &crtc, const char *prop_name,
56 DrmProperty *property);
Sean Paul6a55e9f2015-04-30 15:31:06 -040057 int GetConnectorProperty(const DrmConnector &connector, const char *prop_name,
58 DrmProperty *property);
59
60 uint32_t next_mode_id();
Sean Paul877be972015-06-03 14:08:27 -040061 int SetDisplayActiveMode(int display, const DrmMode &mode);
Sean Paul6a55e9f2015-04-30 15:31:06 -040062 int SetDpmsMode(int display, uint64_t mode);
63
Sean Paul57355412015-09-19 09:14:34 -040064 int CreatePropertyBlob(void *data, size_t length, uint32_t *blob_id);
65 int DestroyPropertyBlob(uint32_t blob_id);
66
Sean Paul6a55e9f2015-04-30 15:31:06 -040067 private:
68 int TryEncoderForDisplay(int display, DrmEncoder *enc);
69 int GetProperty(uint32_t obj_id, uint32_t obj_type, const char *prop_name,
70 DrmProperty *property);
71
Sean Paul877be972015-06-03 14:08:27 -040072 int CreateDisplayPipe(DrmConnector *connector);
73
Zach Reiznerff30b522015-10-28 19:08:45 -070074 UniqueFd fd_;
75 uint32_t mode_id_ = 0;
Sean Paul6a55e9f2015-04-30 15:31:06 -040076
Zach Reiznerff30b522015-10-28 19:08:45 -070077 std::vector<std::unique_ptr<DrmConnector>> connectors_;
78 std::vector<std::unique_ptr<DrmEncoder>> encoders_;
79 std::vector<std::unique_ptr<DrmCrtc>> crtcs_;
80 std::vector<std::unique_ptr<DrmPlane>> planes_;
Sean Paulb386f1b2015-05-13 06:33:23 -070081 DrmCompositor compositor_;
Sean Paul6a55e9f2015-04-30 15:31:06 -040082};
83}
84
85#endif // ANDROID_DRM_H_