1*0a9764feSAndroid Build Coastguard Worker /* 2*0a9764feSAndroid Build Coastguard Worker * Copyright (C) 2015 The Android Open Source Project 3*0a9764feSAndroid Build Coastguard Worker * 4*0a9764feSAndroid Build Coastguard Worker * Licensed under the Apache License, Version 2.0 (the "License"); 5*0a9764feSAndroid Build Coastguard Worker * you may not use this file except in compliance with the License. 6*0a9764feSAndroid Build Coastguard Worker * You may obtain a copy of the License at 7*0a9764feSAndroid Build Coastguard Worker * 8*0a9764feSAndroid Build Coastguard Worker * http://www.apache.org/licenses/LICENSE-2.0 9*0a9764feSAndroid Build Coastguard Worker * 10*0a9764feSAndroid Build Coastguard Worker * Unless required by applicable law or agreed to in writing, software 11*0a9764feSAndroid Build Coastguard Worker * distributed under the License is distributed on an "AS IS" BASIS, 12*0a9764feSAndroid Build Coastguard Worker * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13*0a9764feSAndroid Build Coastguard Worker * See the License for the specific language governing permissions and 14*0a9764feSAndroid Build Coastguard Worker * limitations under the License. 15*0a9764feSAndroid Build Coastguard Worker */ 16*0a9764feSAndroid Build Coastguard Worker 17*0a9764feSAndroid Build Coastguard Worker #pragma once 18*0a9764feSAndroid Build Coastguard Worker 19*0a9764feSAndroid Build Coastguard Worker #include <xf86drmMode.h> 20*0a9764feSAndroid Build Coastguard Worker 21*0a9764feSAndroid Build Coastguard Worker #include <cstdint> 22*0a9764feSAndroid Build Coastguard Worker #include <vector> 23*0a9764feSAndroid Build Coastguard Worker 24*0a9764feSAndroid Build Coastguard Worker #include "DrmCrtc.h" 25*0a9764feSAndroid Build Coastguard Worker #include "DrmProperty.h" 26*0a9764feSAndroid Build Coastguard Worker #include "compositor/LayerData.h" 27*0a9764feSAndroid Build Coastguard Worker 28*0a9764feSAndroid Build Coastguard Worker namespace android { 29*0a9764feSAndroid Build Coastguard Worker 30*0a9764feSAndroid Build Coastguard Worker class DrmDevice; 31*0a9764feSAndroid Build Coastguard Worker struct LayerData; 32*0a9764feSAndroid Build Coastguard Worker 33*0a9764feSAndroid Build Coastguard Worker class DrmPlane : public PipelineBindable<DrmPlane> { 34*0a9764feSAndroid Build Coastguard Worker public: 35*0a9764feSAndroid Build Coastguard Worker DrmPlane(const DrmPlane &) = delete; 36*0a9764feSAndroid Build Coastguard Worker DrmPlane &operator=(const DrmPlane &) = delete; 37*0a9764feSAndroid Build Coastguard Worker 38*0a9764feSAndroid Build Coastguard Worker static auto CreateInstance(DrmDevice &dev, uint32_t plane_id) 39*0a9764feSAndroid Build Coastguard Worker -> std::unique_ptr<DrmPlane>; 40*0a9764feSAndroid Build Coastguard Worker 41*0a9764feSAndroid Build Coastguard Worker bool IsCrtcSupported(const DrmCrtc &crtc) const; 42*0a9764feSAndroid Build Coastguard Worker bool IsValidForLayer(LayerData *layer); 43*0a9764feSAndroid Build Coastguard Worker GetType()44*0a9764feSAndroid Build Coastguard Worker auto GetType() const { 45*0a9764feSAndroid Build Coastguard Worker return type_; 46*0a9764feSAndroid Build Coastguard Worker } 47*0a9764feSAndroid Build Coastguard Worker 48*0a9764feSAndroid Build Coastguard Worker bool IsFormatSupported(uint32_t format) const; 49*0a9764feSAndroid Build Coastguard Worker bool HasNonRgbFormat() const; 50*0a9764feSAndroid Build Coastguard Worker 51*0a9764feSAndroid Build Coastguard Worker auto AtomicSetState(drmModeAtomicReq &pset, LayerData &layer, uint32_t zpos, 52*0a9764feSAndroid Build Coastguard Worker uint32_t crtc_id) -> int; 53*0a9764feSAndroid Build Coastguard Worker auto AtomicDisablePlane(drmModeAtomicReq &pset) -> int; GetZPosProperty()54*0a9764feSAndroid Build Coastguard Worker auto &GetZPosProperty() const { 55*0a9764feSAndroid Build Coastguard Worker return zpos_property_; 56*0a9764feSAndroid Build Coastguard Worker } 57*0a9764feSAndroid Build Coastguard Worker GetId()58*0a9764feSAndroid Build Coastguard Worker auto GetId() const { 59*0a9764feSAndroid Build Coastguard Worker return plane_->plane_id; 60*0a9764feSAndroid Build Coastguard Worker } 61*0a9764feSAndroid Build Coastguard Worker 62*0a9764feSAndroid Build Coastguard Worker private: DrmPlane(DrmDevice & dev,DrmModePlaneUnique plane)63*0a9764feSAndroid Build Coastguard Worker DrmPlane(DrmDevice &dev, DrmModePlaneUnique plane) 64*0a9764feSAndroid Build Coastguard Worker : drm_(&dev), plane_(std::move(plane)){}; 65*0a9764feSAndroid Build Coastguard Worker DrmDevice *const drm_; 66*0a9764feSAndroid Build Coastguard Worker DrmModePlaneUnique plane_; 67*0a9764feSAndroid Build Coastguard Worker 68*0a9764feSAndroid Build Coastguard Worker enum class Presence { kOptional, kMandatory }; 69*0a9764feSAndroid Build Coastguard Worker 70*0a9764feSAndroid Build Coastguard Worker auto Init() -> int; 71*0a9764feSAndroid Build Coastguard Worker auto GetPlaneProperty(const char *prop_name, DrmProperty &property, 72*0a9764feSAndroid Build Coastguard Worker Presence presence = Presence::kMandatory) -> bool; 73*0a9764feSAndroid Build Coastguard Worker 74*0a9764feSAndroid Build Coastguard Worker uint32_t type_{}; 75*0a9764feSAndroid Build Coastguard Worker 76*0a9764feSAndroid Build Coastguard Worker std::vector<uint32_t> formats_; 77*0a9764feSAndroid Build Coastguard Worker 78*0a9764feSAndroid Build Coastguard Worker DrmProperty crtc_property_; 79*0a9764feSAndroid Build Coastguard Worker DrmProperty fb_property_; 80*0a9764feSAndroid Build Coastguard Worker DrmProperty crtc_x_property_; 81*0a9764feSAndroid Build Coastguard Worker DrmProperty crtc_y_property_; 82*0a9764feSAndroid Build Coastguard Worker DrmProperty crtc_w_property_; 83*0a9764feSAndroid Build Coastguard Worker DrmProperty crtc_h_property_; 84*0a9764feSAndroid Build Coastguard Worker DrmProperty src_x_property_; 85*0a9764feSAndroid Build Coastguard Worker DrmProperty src_y_property_; 86*0a9764feSAndroid Build Coastguard Worker DrmProperty src_w_property_; 87*0a9764feSAndroid Build Coastguard Worker DrmProperty src_h_property_; 88*0a9764feSAndroid Build Coastguard Worker DrmProperty zpos_property_; 89*0a9764feSAndroid Build Coastguard Worker DrmProperty rotation_property_; 90*0a9764feSAndroid Build Coastguard Worker DrmProperty alpha_property_; 91*0a9764feSAndroid Build Coastguard Worker DrmProperty blend_property_; 92*0a9764feSAndroid Build Coastguard Worker DrmProperty in_fence_fd_property_; 93*0a9764feSAndroid Build Coastguard Worker DrmProperty color_encoding_propery_; 94*0a9764feSAndroid Build Coastguard Worker DrmProperty color_range_property_; 95*0a9764feSAndroid Build Coastguard Worker 96*0a9764feSAndroid Build Coastguard Worker std::map<BufferBlendMode, uint64_t> blending_enum_map_; 97*0a9764feSAndroid Build Coastguard Worker std::map<BufferColorSpace, uint64_t> color_encoding_enum_map_; 98*0a9764feSAndroid Build Coastguard Worker std::map<BufferSampleRange, uint64_t> color_range_enum_map_; 99*0a9764feSAndroid Build Coastguard Worker std::map<LayerTransform, uint64_t> transform_enum_map_; 100*0a9764feSAndroid Build Coastguard Worker }; 101*0a9764feSAndroid Build Coastguard Worker } // namespace android 102