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 <set> 23 #include <vector> 24 25 #include "DrmCrtc.h" 26 #include "DrmDisplayPipeline.h" 27 28 namespace android { 29 30 class DrmEncoder : public PipelineBindable<DrmEncoder> { 31 public: 32 static auto CreateInstance(DrmDevice &dev, uint32_t encoder_id, 33 uint32_t index) -> std::unique_ptr<DrmEncoder>; 34 35 DrmEncoder(const DrmEncoder &) = delete; 36 DrmEncoder &operator=(const DrmEncoder &) = delete; 37 GetId()38 auto GetId() const { 39 return enc_->encoder_id; 40 }; 41 GetIndexInResArray()42 auto GetIndexInResArray() const { 43 return index_in_res_array_; 44 } 45 CanClone(DrmEncoder & encoder)46 auto CanClone(DrmEncoder &encoder) { 47 return (enc_->possible_clones & (1 << encoder.GetIndexInResArray())) != 0; 48 } 49 SupportsCrtc(DrmCrtc & crtc)50 auto SupportsCrtc(DrmCrtc &crtc) { 51 return (enc_->possible_crtcs & (1 << crtc.GetIndexInResArray())) != 0; 52 } 53 GetCurrentCrtcId()54 auto GetCurrentCrtcId() { 55 return enc_->crtc_id; 56 } 57 58 private: DrmEncoder(DrmModeEncoderUnique enc,uint32_t index)59 DrmEncoder(DrmModeEncoderUnique enc, uint32_t index) 60 : enc_(std::move(enc)), index_in_res_array_(index){}; 61 62 DrmModeEncoderUnique enc_; 63 64 const uint32_t index_in_res_array_; 65 }; 66 } // namespace android 67