Sean Paul | b386f1b | 2015-05-13 06:33:23 -0700 | [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_COMPOSITION_H_ |
| 18 | #define ANDROID_DRM_COMPOSITION_H_ |
| 19 | |
Sean Paul | b386f1b | 2015-05-13 06:33:23 -0700 | [diff] [blame] | 20 | #include "drm_hwcomposer.h" |
Sean Paul | 98e73c8 | 2015-06-24 14:38:49 -0700 | [diff] [blame] | 21 | #include "drmdisplaycomposition.h" |
Sean Paul | b386f1b | 2015-05-13 06:33:23 -0700 | [diff] [blame] | 22 | #include "drmplane.h" |
| 23 | #include "importer.h" |
| 24 | |
Sean Paul | b386f1b | 2015-05-13 06:33:23 -0700 | [diff] [blame] | 25 | #include <map> |
| 26 | #include <vector> |
| 27 | |
| 28 | #include <hardware/hardware.h> |
| 29 | #include <hardware/hwcomposer.h> |
| 30 | |
| 31 | namespace android { |
| 32 | |
Zach Reizner | 0980705 | 2015-08-13 14:53:41 -0700 | [diff] [blame] | 33 | struct DrmCompositionDisplayLayersMap { |
| 34 | int display; |
Zach Reizner | 4a25365 | 2015-09-10 18:30:54 -0700 | [diff] [blame] | 35 | std::vector<DrmHwcLayer> layers; |
| 36 | |
| 37 | DrmCompositionDisplayLayersMap() = default; |
| 38 | DrmCompositionDisplayLayersMap(DrmCompositionDisplayLayersMap &&rhs) = |
| 39 | default; |
Zach Reizner | 0980705 | 2015-08-13 14:53:41 -0700 | [diff] [blame] | 40 | }; |
| 41 | |
Zach Reizner | 459a5a9 | 2015-07-31 15:12:49 -0700 | [diff] [blame] | 42 | class DrmComposition { |
Sean Paul | b386f1b | 2015-05-13 06:33:23 -0700 | [diff] [blame] | 43 | public: |
Sean Paul | 98e73c8 | 2015-06-24 14:38:49 -0700 | [diff] [blame] | 44 | DrmComposition(DrmResources *drm, Importer *importer); |
Sean Paul | b386f1b | 2015-05-13 06:33:23 -0700 | [diff] [blame] | 45 | |
Sean Paul | bdc67bf | 2015-09-21 10:04:02 -0400 | [diff] [blame] | 46 | int Init(uint64_t frame_no); |
Sean Paul | b386f1b | 2015-05-13 06:33:23 -0700 | [diff] [blame] | 47 | |
Zach Reizner | 4a25365 | 2015-09-10 18:30:54 -0700 | [diff] [blame] | 48 | int SetLayers(size_t num_displays, DrmCompositionDisplayLayersMap *maps); |
Zach Reizner | 0980705 | 2015-08-13 14:53:41 -0700 | [diff] [blame] | 49 | int SetDpmsMode(int display, uint32_t dpms_mode); |
Sean Paul | 5735541 | 2015-09-19 09:14:34 -0400 | [diff] [blame] | 50 | int SetDisplayMode(int display, const DrmMode &display_mode); |
Sean Paul | 2e46fbd | 2015-07-09 17:22:22 -0400 | [diff] [blame] | 51 | |
Sean Paul | 98e73c8 | 2015-06-24 14:38:49 -0700 | [diff] [blame] | 52 | std::unique_ptr<DrmDisplayComposition> TakeDisplayComposition(int display); |
Sean Paul | 2e46fbd | 2015-07-09 17:22:22 -0400 | [diff] [blame] | 53 | DrmDisplayComposition *GetDisplayComposition(int display); |
Zach Reizner | 0980705 | 2015-08-13 14:53:41 -0700 | [diff] [blame] | 54 | int DisableUnusedPlanes(); |
Sean Paul | b386f1b | 2015-05-13 06:33:23 -0700 | [diff] [blame] | 55 | |
| 56 | private: |
Sean Paul | 98e73c8 | 2015-06-24 14:38:49 -0700 | [diff] [blame] | 57 | DrmComposition(const DrmComposition &) = delete; |
| 58 | |
Sean Paul | b386f1b | 2015-05-13 06:33:23 -0700 | [diff] [blame] | 59 | DrmResources *drm_; |
| 60 | Importer *importer_; |
| 61 | |
Sean Paul | b386f1b | 2015-05-13 06:33:23 -0700 | [diff] [blame] | 62 | std::vector<DrmPlane *> primary_planes_; |
Sean Paul | 9099aa5 | 2015-07-09 17:51:50 -0400 | [diff] [blame] | 63 | std::vector<DrmPlane *> overlay_planes_; |
Sean Paul | 98e73c8 | 2015-06-24 14:38:49 -0700 | [diff] [blame] | 64 | |
| 65 | /* |
| 66 | * This _must_ be read-only after it's passed to QueueComposition. Otherwise |
| 67 | * locking is required to maintain consistency across the compositor threads. |
| 68 | */ |
| 69 | std::map<int, std::unique_ptr<DrmDisplayComposition>> composition_map_; |
Sean Paul | b386f1b | 2015-05-13 06:33:23 -0700 | [diff] [blame] | 70 | }; |
Sean Paul | b386f1b | 2015-05-13 06:33:23 -0700 | [diff] [blame] | 71 | } |
| 72 | |
| 73 | #endif // ANDROID_DRM_COMPOSITION_H_ |