51 lines
1.5 KiB
C++
51 lines
1.5 KiB
C++
/*
|
|
* Copyright (C) 2015 The Android Open Source Project
|
|
*
|
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
* you may not use this file except in compliance with the License.
|
|
* You may obtain a copy of the License at
|
|
*
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
|
*
|
|
* Unless required by applicable law or agreed to in writing, software
|
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
* See the License for the specific language governing permissions and
|
|
* limitations under the License.
|
|
*/
|
|
|
|
#define LOG_TAG "drmhwc"
|
|
|
|
#include "DrmEncoder.h"
|
|
|
|
#include <xf86drmMode.h>
|
|
|
|
#include <cstdint>
|
|
|
|
#include "drm/DrmCrtc.h"
|
|
#include "drm/DrmDevice.h"
|
|
#include "drm/DrmUnique.h"
|
|
#include "utils/log.h"
|
|
|
|
namespace android::drm_hwcomposer {
|
|
|
|
auto DrmEncoder::CreateInstance(DrmDevice &dev, uint32_t encoder_id,
|
|
uint32_t index) -> std::unique_ptr<DrmEncoder> {
|
|
auto e = MakeDrmModeEncoderUnique(*dev.GetFd(), encoder_id);
|
|
if (!e) {
|
|
ALOGE("Failed to get encoder %d", encoder_id);
|
|
return {};
|
|
}
|
|
|
|
return std::unique_ptr<DrmEncoder>(new DrmEncoder(std::move(e), index));
|
|
}
|
|
|
|
bool DrmEncoder::CanClone(DrmEncoder &encoder) {
|
|
return (enc_->possible_clones & (1 << encoder.GetIndexInResArray())) != 0;
|
|
}
|
|
|
|
bool DrmEncoder::SupportsCrtc(DrmCrtc &crtc) {
|
|
return (enc_->possible_crtcs & (1 << crtc.GetIndexInResArray())) != 0;
|
|
}
|
|
|
|
} // namespace android::drm_hwcomposer
|