blob: 5a46e9b8306f936f58a8081ffd51f2a8d0ba243a [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
John Stultz9057a6f2018-04-26 12:05:55 -070020#include <log/log.h>
Roman Stratiienkoadd24cb2020-10-23 22:28:38 +030021#include <ui/Gralloc.h>
Andrii Chepurnyidc1278c2018-03-20 19:41:18 +020022#include <ui/GraphicBufferMapper.h>
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
John Stultzfb3599c2018-08-21 11:21:56 -070028#define UNUSED(x) (void)(x)
29
Sean Paul80b1a5d2016-03-10 15:35:13 -050030namespace android {
31
Roman Stratiienko51287152021-02-10 14:59:52 +020032int DrmHwcLayer::ImportBuffer(DrmDevice *drmDevice) {
33 buffer_info = hwc_drm_bo_t{};
Sean Paul80b1a5d2016-03-10 15:35:13 -050034
Roman Stratiienko51287152021-02-10 14:59:52 +020035 int ret = BufferInfoGetter::GetInstance()->ConvertBoInfo(sf_handle,
36 &buffer_info);
Jason Macnakf2e03b72020-11-02 07:04:11 -080037 if (ret) {
38 ALOGE("Failed to convert buffer info %d", ret);
Sean Paul80b1a5d2016-03-10 15:35:13 -050039 return ret;
Jason Macnakf2e03b72020-11-02 07:04:11 -080040 }
41
Roman Stratiienko51287152021-02-10 14:59:52 +020042 FbIdHandle = drmDevice->GetDrmFbImporter().GetOrCreateFbId(&buffer_info);
Roman Stratiienko8666dc92021-02-09 17:49:55 +020043 if (!FbIdHandle) {
44 ALOGE("Failed to import buffer");
45 return -EINVAL;
Jason Macnakf2e03b72020-11-02 07:04:11 -080046 }
Sean Paul80b1a5d2016-03-10 15:35:13 -050047
Sean Paul80b1a5d2016-03-10 15:35:13 -050048 return 0;
49}
50
Sean Paulf72cccd2018-08-27 13:59:08 -040051} // namespace android