blob: c537b99e3b22d254e68d71adad954f2ba50fab80 [file] [log] [blame]
Sean Paul80b1a5d2016-03-10 15:35:13 -05001/*
2 * Copyright (C) 2016 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 ATRACE_TAG ATRACE_TAG_GRAPHICS
18#define LOG_TAG "hwc-drm-utils"
19
Roman Stratiienkofc014f52021-12-23 19:04:29 +020020#include <utils/log.h>
21
22#include <cerrno>
Sean Paul80b1a5d2016-03-10 15:35:13 -050023
Roman Stratiienkob2e9fe22020-10-03 10:52:36 +030024#include "bufferinfo/BufferInfoGetter.h"
Roman Stratiienko8666dc92021-02-09 17:49:55 +020025#include "drm/DrmFbImporter.h"
Roman Stratiienkoaa3cd542020-08-29 11:26:16 +030026#include "drmhwcomposer.h"
Roman Stratiienkoaa3cd542020-08-29 11:26:16 +030027
Sean Paul80b1a5d2016-03-10 15:35:13 -050028namespace android {
29
Roman Stratiienkofc014f52021-12-23 19:04:29 +020030int DrmHwcLayer::ImportBuffer(DrmDevice *drm_device) {
Roman Stratiienko51287152021-02-10 14:59:52 +020031 buffer_info = hwc_drm_bo_t{};
Sean Paul80b1a5d2016-03-10 15:35:13 -050032
Roman Stratiienko51287152021-02-10 14:59:52 +020033 int ret = BufferInfoGetter::GetInstance()->ConvertBoInfo(sf_handle,
34 &buffer_info);
Roman Stratiienkofc014f52021-12-23 19:04:29 +020035 if (ret != 0) {
Jason Macnakf2e03b72020-11-02 07:04:11 -080036 ALOGE("Failed to convert buffer info %d", ret);
Sean Paul80b1a5d2016-03-10 15:35:13 -050037 return ret;
Jason Macnakf2e03b72020-11-02 07:04:11 -080038 }
39
Roman Stratiienkofc014f52021-12-23 19:04:29 +020040 fb_id_handle = drm_device->GetDrmFbImporter().GetOrCreateFbId(&buffer_info);
41 if (!fb_id_handle) {
Roman Stratiienko8666dc92021-02-09 17:49:55 +020042 ALOGE("Failed to import buffer");
43 return -EINVAL;
Jason Macnakf2e03b72020-11-02 07:04:11 -080044 }
Sean Paul80b1a5d2016-03-10 15:35:13 -050045
Sean Paul80b1a5d2016-03-10 15:35:13 -050046 return 0;
47}
48
Sean Paulf72cccd2018-08-27 13:59:08 -040049} // namespace android