blob: 8049a5c39b1d3df2729a097a12c2901367f2ef8f [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 Stratiienko027987b2022-01-30 21:06:35 +020017#define LOG_TAG "hwc-drm-encoder"
18
Roman Stratiienko13cc3662020-08-29 21:35:39 +030019#include "DrmEncoder.h"
Sean Paul6a55e9f2015-04-30 15:31:06 -040020
Sean Paul6a55e9f2015-04-30 15:31:06 -040021#include <xf86drmMode.h>
22
Roman Stratiienkoe2f2c922021-02-13 10:57:47 +020023#include <cstdint>
24
Roman Stratiienko13cc3662020-08-29 21:35:39 +030025#include "DrmDevice.h"
Roman Stratiienko027987b2022-01-30 21:06:35 +020026#include "utils/log.h"
Roman Stratiienko13cc3662020-08-29 21:35:39 +030027
Sean Paul6a55e9f2015-04-30 15:31:06 -040028namespace android {
29
Roman Stratiienko027987b2022-01-30 21:06:35 +020030auto DrmEncoder::CreateInstance(DrmDevice &dev, uint32_t encoder_id,
31 uint32_t index) -> std::unique_ptr<DrmEncoder> {
32 auto e = MakeDrmModeEncoderUnique(dev.fd(), encoder_id);
33 if (!e) {
34 ALOGE("Failed to get encoder %d", encoder_id);
35 return {};
36 }
37
38 return std::unique_ptr<DrmEncoder>(new DrmEncoder(std::move(e), index));
Sean Paul6a55e9f2015-04-30 15:31:06 -040039}
40
Sean Paulf72cccd2018-08-27 13:59:08 -040041} // namespace android