Sean Paul | 6a55e9f | 2015-04-30 15:31:06 -0400 | [diff] [blame] | 1 | /* |
| 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 Paul | b386f1b | 2015-05-13 06:33:23 -0700 | [diff] [blame] | 20 | #include "drmcompositor.h" |
Sean Paul | 6a55e9f | 2015-04-30 15:31:06 -0400 | [diff] [blame] | 21 | #include "drmconnector.h" |
| 22 | #include "drmcrtc.h" |
| 23 | #include "drmencoder.h" |
Sean Paul | 047b9b2 | 2015-07-28 14:15:42 -0400 | [diff] [blame^] | 24 | #include "drmeventlistener.h" |
Sean Paul | 6a55e9f | 2015-04-30 15:31:06 -0400 | [diff] [blame] | 25 | #include "drmplane.h" |
| 26 | |
| 27 | #include <stdint.h> |
| 28 | |
| 29 | namespace android { |
| 30 | |
| 31 | class DrmResources { |
| 32 | public: |
Sean Paul | 6a55e9f | 2015-04-30 15:31:06 -0400 | [diff] [blame] | 33 | DrmResources(); |
Sean Paul | 047b9b2 | 2015-07-28 14:15:42 -0400 | [diff] [blame^] | 34 | ~DrmResources(); |
Sean Paul | 6a55e9f | 2015-04-30 15:31:06 -0400 | [diff] [blame] | 35 | |
| 36 | int Init(); |
| 37 | |
Zach Reizner | ff30b52 | 2015-10-28 19:08:45 -0700 | [diff] [blame] | 38 | int fd() const { |
| 39 | return fd_.get(); |
| 40 | } |
Sean Paul | 6a55e9f | 2015-04-30 15:31:06 -0400 | [diff] [blame] | 41 | |
Zach Reizner | ff30b52 | 2015-10-28 19:08:45 -0700 | [diff] [blame] | 42 | 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 Paul | 6a55e9f | 2015-04-30 15:31:06 -0400 | [diff] [blame] | 49 | |
| 50 | DrmConnector *GetConnectorForDisplay(int display) const; |
| 51 | DrmCrtc *GetCrtcForDisplay(int display) const; |
| 52 | DrmPlane *GetPlane(uint32_t id) const; |
Sean Paul | b386f1b | 2015-05-13 06:33:23 -0700 | [diff] [blame] | 53 | DrmCompositor *compositor(); |
Sean Paul | 047b9b2 | 2015-07-28 14:15:42 -0400 | [diff] [blame^] | 54 | DrmEventListener *event_listener(); |
Sean Paul | 6a55e9f | 2015-04-30 15:31:06 -0400 | [diff] [blame] | 55 | |
| 56 | int GetPlaneProperty(const DrmPlane &plane, const char *prop_name, |
| 57 | DrmProperty *property); |
Sean Paul | 877be97 | 2015-06-03 14:08:27 -0400 | [diff] [blame] | 58 | int GetCrtcProperty(const DrmCrtc &crtc, const char *prop_name, |
| 59 | DrmProperty *property); |
Sean Paul | 6a55e9f | 2015-04-30 15:31:06 -0400 | [diff] [blame] | 60 | int GetConnectorProperty(const DrmConnector &connector, const char *prop_name, |
| 61 | DrmProperty *property); |
| 62 | |
| 63 | uint32_t next_mode_id(); |
Sean Paul | 877be97 | 2015-06-03 14:08:27 -0400 | [diff] [blame] | 64 | int SetDisplayActiveMode(int display, const DrmMode &mode); |
Sean Paul | 6a55e9f | 2015-04-30 15:31:06 -0400 | [diff] [blame] | 65 | int SetDpmsMode(int display, uint64_t mode); |
| 66 | |
Sean Paul | 5735541 | 2015-09-19 09:14:34 -0400 | [diff] [blame] | 67 | int CreatePropertyBlob(void *data, size_t length, uint32_t *blob_id); |
| 68 | int DestroyPropertyBlob(uint32_t blob_id); |
| 69 | |
Sean Paul | 6a55e9f | 2015-04-30 15:31:06 -0400 | [diff] [blame] | 70 | private: |
| 71 | int TryEncoderForDisplay(int display, DrmEncoder *enc); |
| 72 | int GetProperty(uint32_t obj_id, uint32_t obj_type, const char *prop_name, |
| 73 | DrmProperty *property); |
| 74 | |
Sean Paul | 877be97 | 2015-06-03 14:08:27 -0400 | [diff] [blame] | 75 | int CreateDisplayPipe(DrmConnector *connector); |
| 76 | |
Zach Reizner | ff30b52 | 2015-10-28 19:08:45 -0700 | [diff] [blame] | 77 | UniqueFd fd_; |
| 78 | uint32_t mode_id_ = 0; |
Sean Paul | 6a55e9f | 2015-04-30 15:31:06 -0400 | [diff] [blame] | 79 | |
Zach Reizner | ff30b52 | 2015-10-28 19:08:45 -0700 | [diff] [blame] | 80 | std::vector<std::unique_ptr<DrmConnector>> connectors_; |
| 81 | std::vector<std::unique_ptr<DrmEncoder>> encoders_; |
| 82 | std::vector<std::unique_ptr<DrmCrtc>> crtcs_; |
| 83 | std::vector<std::unique_ptr<DrmPlane>> planes_; |
Sean Paul | b386f1b | 2015-05-13 06:33:23 -0700 | [diff] [blame] | 84 | DrmCompositor compositor_; |
Sean Paul | 047b9b2 | 2015-07-28 14:15:42 -0400 | [diff] [blame^] | 85 | DrmEventListener event_listener_; |
Sean Paul | 6a55e9f | 2015-04-30 15:31:06 -0400 | [diff] [blame] | 86 | }; |
| 87 | } |
| 88 | |
| 89 | #endif // ANDROID_DRM_H_ |