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