Sean Paul | 98e73c8 | 2015-06-24 14:38:49 -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_DISPLAY_COMPOSITION_H_ |
| 18 | #define ANDROID_DRM_DISPLAY_COMPOSITION_H_ |
| 19 | |
Roman Stratiienko | aa3cd54 | 2020-08-29 11:26:16 +0300 | [diff] [blame] | 20 | #include <hardware/hardware.h> |
| 21 | #include <hardware/hwcomposer.h> |
Sean Paul | 98e73c8 | 2015-06-24 14:38:49 -0700 | [diff] [blame] | 22 | |
Zach Reizner | fd6dc33 | 2015-10-13 21:12:48 -0700 | [diff] [blame] | 23 | #include <sstream> |
Sean Paul | 98e73c8 | 2015-06-24 14:38:49 -0700 | [diff] [blame] | 24 | #include <vector> |
| 25 | |
Roman Stratiienko | 13cc366 | 2020-08-29 21:35:39 +0300 | [diff] [blame] | 26 | #include "drm/DrmCrtc.h" |
| 27 | #include "drm/DrmPlane.h" |
Roman Stratiienko | aa3cd54 | 2020-08-29 11:26:16 +0300 | [diff] [blame] | 28 | #include "drmhwcomposer.h" |
Sean Paul | 98e73c8 | 2015-06-24 14:38:49 -0700 | [diff] [blame] | 29 | |
| 30 | namespace android { |
| 31 | |
Sean Paul | 4c4646e | 2016-05-10 04:19:24 -0400 | [diff] [blame] | 32 | class Importer; |
Sean Paul | aa18d91 | 2016-05-12 14:28:05 -0400 | [diff] [blame] | 33 | class Planner; |
Zach Reizner | 92f8e63 | 2015-10-12 17:47:13 -0700 | [diff] [blame] | 34 | |
Sean Paul | ca699be | 2016-05-11 16:29:45 -0400 | [diff] [blame] | 35 | class DrmCompositionPlane { |
| 36 | public: |
Sean Paul | bbe39db | 2016-05-11 16:57:26 -0400 | [diff] [blame] | 37 | enum class Type : int32_t { |
| 38 | kDisable, |
| 39 | kLayer, |
Sean Paul | bbe39db | 2016-05-11 16:57:26 -0400 | [diff] [blame] | 40 | }; |
| 41 | |
Sean Paul | ca699be | 2016-05-11 16:29:45 -0400 | [diff] [blame] | 42 | DrmCompositionPlane() = default; |
| 43 | DrmCompositionPlane(DrmCompositionPlane &&rhs) = default; |
| 44 | DrmCompositionPlane &operator=(DrmCompositionPlane &&other) = default; |
Matvii Zorin | f0757c2 | 2021-01-18 15:54:22 +0200 | [diff] [blame] | 45 | DrmCompositionPlane(Type type, DrmPlane *plane) : type_(type), plane_(plane) { |
Sean Paul | ca699be | 2016-05-11 16:29:45 -0400 | [diff] [blame] | 46 | } |
Matvii Zorin | f0757c2 | 2021-01-18 15:54:22 +0200 | [diff] [blame] | 47 | DrmCompositionPlane(Type type, DrmPlane *plane, size_t source_layer) |
| 48 | : type_(type), plane_(plane), source_layers_(1, source_layer) { |
Sean Paul | ca699be | 2016-05-11 16:29:45 -0400 | [diff] [blame] | 49 | } |
| 50 | |
Sean Paul | bbe39db | 2016-05-11 16:57:26 -0400 | [diff] [blame] | 51 | Type type() const { |
Sean Paul | ca699be | 2016-05-11 16:29:45 -0400 | [diff] [blame] | 52 | return type_; |
| 53 | } |
| 54 | |
| 55 | DrmPlane *plane() const { |
| 56 | return plane_; |
| 57 | } |
| 58 | void set_plane(DrmPlane *plane) { |
| 59 | plane_ = plane; |
| 60 | } |
| 61 | |
Sean Paul | ca699be | 2016-05-11 16:29:45 -0400 | [diff] [blame] | 62 | std::vector<size_t> &source_layers() { |
| 63 | return source_layers_; |
| 64 | } |
| 65 | |
| 66 | const std::vector<size_t> &source_layers() const { |
| 67 | return source_layers_; |
| 68 | } |
| 69 | |
| 70 | private: |
Sean Paul | bbe39db | 2016-05-11 16:57:26 -0400 | [diff] [blame] | 71 | Type type_ = Type::kDisable; |
Sean Paul | ca699be | 2016-05-11 16:29:45 -0400 | [diff] [blame] | 72 | DrmPlane *plane_ = NULL; |
Sean Paul | ca699be | 2016-05-11 16:29:45 -0400 | [diff] [blame] | 73 | std::vector<size_t> source_layers_; |
Zach Reizner | 4a25365 | 2015-09-10 18:30:54 -0700 | [diff] [blame] | 74 | }; |
Sean Paul | 98e73c8 | 2015-06-24 14:38:49 -0700 | [diff] [blame] | 75 | |
| 76 | class DrmDisplayComposition { |
| 77 | public: |
Zach Reizner | 92f8e63 | 2015-10-12 17:47:13 -0700 | [diff] [blame] | 78 | DrmDisplayComposition(const DrmDisplayComposition &) = delete; |
Matvii Zorin | 704ea0e | 2021-01-08 12:55:45 +0200 | [diff] [blame] | 79 | DrmDisplayComposition(DrmCrtc *crtc, Planner *planner); |
Roman Stratiienko | e2f2c92 | 2021-02-13 10:57:47 +0200 | [diff] [blame] | 80 | ~DrmDisplayComposition() = default; |
Sean Paul | 98e73c8 | 2015-06-24 14:38:49 -0700 | [diff] [blame] | 81 | |
Roman Stratiienko | 36a7f28 | 2021-10-05 18:17:53 +0300 | [diff] [blame] | 82 | int SetLayers(DrmHwcLayer *layers, size_t num_layers); |
Sean Paul | 4f4ef69 | 2016-05-03 16:40:59 -0700 | [diff] [blame] | 83 | int AddPlaneComposition(DrmCompositionPlane plane); |
Sean Paul | 2e46fbd | 2015-07-09 17:22:22 -0400 | [diff] [blame] | 84 | int AddPlaneDisable(DrmPlane *plane); |
Sean Paul | 98e73c8 | 2015-06-24 14:38:49 -0700 | [diff] [blame] | 85 | |
Rob Herring | af0d975 | 2018-05-04 16:34:19 -0500 | [diff] [blame] | 86 | int Plan(std::vector<DrmPlane *> *primary_planes, |
Zach Reizner | 92f8e63 | 2015-10-12 17:47:13 -0700 | [diff] [blame] | 87 | std::vector<DrmPlane *> *overlay_planes); |
Sean Paul | acb2a44 | 2015-06-24 18:43:01 -0700 | [diff] [blame] | 88 | |
Zach Reizner | 92f8e63 | 2015-10-12 17:47:13 -0700 | [diff] [blame] | 89 | std::vector<DrmHwcLayer> &layers() { |
| 90 | return layers_; |
| 91 | } |
| 92 | |
Zach Reizner | 92f8e63 | 2015-10-12 17:47:13 -0700 | [diff] [blame] | 93 | std::vector<DrmCompositionPlane> &composition_planes() { |
| 94 | return composition_planes_; |
| 95 | } |
| 96 | |
Zach Reizner | 92f8e63 | 2015-10-12 17:47:13 -0700 | [diff] [blame] | 97 | DrmCrtc *crtc() const { |
| 98 | return crtc_; |
| 99 | } |
| 100 | |
Sean Paul | aa18d91 | 2016-05-12 14:28:05 -0400 | [diff] [blame] | 101 | Planner *planner() const { |
| 102 | return planner_; |
| 103 | } |
| 104 | |
Zach Reizner | 92f8e63 | 2015-10-12 17:47:13 -0700 | [diff] [blame] | 105 | private: |
Zach Reizner | 92f8e63 | 2015-10-12 17:47:13 -0700 | [diff] [blame] | 106 | DrmCrtc *crtc_ = NULL; |
Sean Paul | aa18d91 | 2016-05-12 14:28:05 -0400 | [diff] [blame] | 107 | Planner *planner_ = NULL; |
Sean Paul | 98e73c8 | 2015-06-24 14:38:49 -0700 | [diff] [blame] | 108 | |
Zach Reizner | 92f8e63 | 2015-10-12 17:47:13 -0700 | [diff] [blame] | 109 | std::vector<DrmHwcLayer> layers_; |
Zach Reizner | 92f8e63 | 2015-10-12 17:47:13 -0700 | [diff] [blame] | 110 | std::vector<DrmCompositionPlane> composition_planes_; |
Sean Paul | 98e73c8 | 2015-06-24 14:38:49 -0700 | [diff] [blame] | 111 | }; |
Sean Paul | f72cccd | 2018-08-27 13:59:08 -0400 | [diff] [blame] | 112 | } // namespace android |
Sean Paul | 98e73c8 | 2015-06-24 14:38:49 -0700 | [diff] [blame] | 113 | |
| 114 | #endif // ANDROID_DRM_DISPLAY_COMPOSITION_H_ |