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 #define LOG_TAG "drmhwc"
18
19 #include "DrmEncoder.h"
20
21 #include <xf86drmMode.h>
22
23 #include <cstdint>
24
25 #include "DrmDevice.h"
26 #include "utils/log.h"
27
28 namespace android {
29
CreateInstance(DrmDevice & dev,uint32_t encoder_id,uint32_t index)30 auto DrmEncoder::CreateInstance(DrmDevice &dev, uint32_t encoder_id,
31 uint32_t index) -> std::unique_ptr<DrmEncoder> {
32 auto e = MakeDrmModeEncoderUnique(*dev.GetFd(), 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));
39 }
40
41 } // namespace android
42