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