blob: 7480ce6f65446a7174f0aa2e21514146bbc2b9a4 [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
Sean Paul468a7542024-07-16 19:50:58 +000017#define LOG_TAG "drmhwc"
Roman Stratiienko027987b2022-01-30 21:06:35 +020018
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> {
Roman Stratiienko76892782023-01-16 17:15:53 +020032 auto e = MakeDrmModeEncoderUnique(*dev.GetFd(), encoder_id);
Roman Stratiienko027987b2022-01-30 21:06:35 +020033 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