blob: ad05f88f2db50e6101d8f0af98b74e817dd7f29c [file] [log] [blame]
Sean Paul6a55e9f2015-04-30 15:31:06 -04001/*
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
Roman Stratiienko13cc3662020-08-29 21:35:39 +030017#include "DrmEncoder.h"
Sean Paul6a55e9f2015-04-30 15:31:06 -040018
Sean Paul6a55e9f2015-04-30 15:31:06 -040019#include <xf86drmMode.h>
20
Roman Stratiienkoe2f2c922021-02-13 10:57:47 +020021#include <cstdint>
22
Roman Stratiienko13cc3662020-08-29 21:35:39 +030023#include "DrmDevice.h"
24
Sean Paul6a55e9f2015-04-30 15:31:06 -040025namespace android {
26
27DrmEncoder::DrmEncoder(drmModeEncoderPtr e, DrmCrtc *current_crtc,
Roman Stratiienkoe2f2c922021-02-13 10:57:47 +020028 std::vector<DrmCrtc *> possible_crtcs)
Sean Paul6a55e9f2015-04-30 15:31:06 -040029 : id_(e->encoder_id),
30 crtc_(current_crtc),
Alexandru Gheorgheae4324c2018-03-21 12:06:20 +000031 display_(-1),
Roman Stratiienkoe2f2c922021-02-13 10:57:47 +020032 possible_crtcs_(std::move(possible_crtcs)) {
Sean Paul6a55e9f2015-04-30 15:31:06 -040033}
34
Sean Paul6a55e9f2015-04-30 15:31:06 -040035uint32_t DrmEncoder::id() const {
36 return id_;
37}
38
39DrmCrtc *DrmEncoder::crtc() const {
40 return crtc_;
41}
42
Roman Stratiienkoe2f2c922021-02-13 10:57:47 +020043bool DrmEncoder::CanClone(DrmEncoder *encoder) {
44 return possible_clones_.find(encoder) != possible_clones_.end();
Alexandru Gheorghee8b668c2018-03-22 11:31:29 +000045}
46
47void DrmEncoder::AddPossibleClone(DrmEncoder *possible_clone) {
48 possible_clones_.insert(possible_clone);
49}
50
Sean Paul6a55e9f2015-04-30 15:31:06 -040051void DrmEncoder::set_crtc(DrmCrtc *crtc) {
52 crtc_ = crtc;
Alexandru Gheorgheae4324c2018-03-21 12:06:20 +000053 display_ = crtc->display();
54}
55
56int DrmEncoder::display() const {
57 return display_;
58}
59
60bool DrmEncoder::can_bind(int display) const {
61 return display_ == -1 || display_ == display;
Sean Paul6a55e9f2015-04-30 15:31:06 -040062}
Sean Paulf72cccd2018-08-27 13:59:08 -040063} // namespace android