• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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_PLANE_H_
18 #define ANDROID_DRM_PLANE_H_
19 
20 #include <xf86drmMode.h>
21 
22 #include <cstdint>
23 #include <vector>
24 
25 #include "DrmCrtc.h"
26 #include "DrmProperty.h"
27 #include "drmhwcomposer.h"
28 
29 namespace android {
30 
31 class DrmDevice;
32 struct DrmHwcLayer;
33 
34 class DrmPlane : public PipelineBindable<DrmPlane> {
35  public:
36   DrmPlane(const DrmPlane &) = delete;
37   DrmPlane &operator=(const DrmPlane &) = delete;
38 
39   static auto CreateInstance(DrmDevice &dev, uint32_t plane_id)
40       -> std::unique_ptr<DrmPlane>;
41 
42   bool IsCrtcSupported(const DrmCrtc &crtc) const;
43   bool IsValidForLayer(DrmHwcLayer *layer);
44 
GetType()45   auto GetType() const {
46     return type_;
47   }
48 
49   bool IsFormatSupported(uint32_t format) const;
50   bool HasNonRgbFormat() const;
51 
52   auto AtomicSetState(drmModeAtomicReq &pset, DrmHwcLayer &layer, uint32_t zpos,
53                       uint32_t crtc_id) -> int;
54   auto AtomicDisablePlane(drmModeAtomicReq &pset) -> int;
GetZPosProperty()55   auto &GetZPosProperty() const {
56     return zpos_property_;
57   }
58 
GetId()59   auto GetId() const {
60     return plane_->plane_id;
61   }
62 
63  private:
DrmPlane(DrmDevice & dev,DrmModePlaneUnique plane)64   DrmPlane(DrmDevice &dev, DrmModePlaneUnique plane)
65       : drm_(&dev), plane_(std::move(plane)){};
66   DrmDevice *const drm_;
67   DrmModePlaneUnique plane_;
68 
69   enum class Presence { kOptional, kMandatory };
70 
71   auto Init() -> int;
72   auto GetPlaneProperty(const char *prop_name, DrmProperty &property,
73                         Presence presence = Presence::kMandatory) -> bool;
74 
75   uint32_t type_{};
76 
77   std::vector<uint32_t> formats_;
78 
79   DrmProperty crtc_property_;
80   DrmProperty fb_property_;
81   DrmProperty crtc_x_property_;
82   DrmProperty crtc_y_property_;
83   DrmProperty crtc_w_property_;
84   DrmProperty crtc_h_property_;
85   DrmProperty src_x_property_;
86   DrmProperty src_y_property_;
87   DrmProperty src_w_property_;
88   DrmProperty src_h_property_;
89   DrmProperty zpos_property_;
90   DrmProperty rotation_property_;
91   DrmProperty alpha_property_;
92   DrmProperty blend_property_;
93   DrmProperty in_fence_fd_property_;
94   DrmProperty color_encoding_propery_;
95   DrmProperty color_range_property_;
96 
97   std::map<DrmHwcBlending, uint64_t> blending_enum_map_;
98   std::map<DrmHwcColorSpace, uint64_t> color_encoding_enum_map_;
99   std::map<DrmHwcSampleRange, uint64_t> color_range_enum_map_;
100   std::map<DrmHwcTransform, uint64_t> transform_enum_map_;
101 };
102 }  // namespace android
103 
104 #endif  // ANDROID_DRM_PLANE_H_
105