Sean Paul | 80b1a5d | 2016-03-10 15:35:13 -0500 | [diff] [blame] | 1 | /* |
| 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 Stultz | 9057a6f | 2018-04-26 12:05:55 -0700 | [diff] [blame] | 20 | #include <log/log.h> |
Roman Stratiienko | add24cb | 2020-10-23 22:28:38 +0300 | [diff] [blame] | 21 | #include <ui/Gralloc.h> |
Andrii Chepurnyi | dc1278c | 2018-03-20 19:41:18 +0200 | [diff] [blame] | 22 | #include <ui/GraphicBufferMapper.h> |
Sean Paul | 80b1a5d | 2016-03-10 15:35:13 -0500 | [diff] [blame] | 23 | |
Roman Stratiienko | b2e9fe2 | 2020-10-03 10:52:36 +0300 | [diff] [blame] | 24 | #include "bufferinfo/BufferInfoGetter.h" |
Roman Stratiienko | 8666dc9 | 2021-02-09 17:49:55 +0200 | [diff] [blame] | 25 | #include "drm/DrmFbImporter.h" |
Roman Stratiienko | aa3cd54 | 2020-08-29 11:26:16 +0300 | [diff] [blame] | 26 | #include "drmhwcomposer.h" |
Roman Stratiienko | aa3cd54 | 2020-08-29 11:26:16 +0300 | [diff] [blame] | 27 | |
John Stultz | fb3599c | 2018-08-21 11:21:56 -0700 | [diff] [blame] | 28 | #define UNUSED(x) (void)(x) |
| 29 | |
Sean Paul | 80b1a5d | 2016-03-10 15:35:13 -0500 | [diff] [blame] | 30 | namespace android { |
| 31 | |
Roman Stratiienko | 5128715 | 2021-02-10 14:59:52 +0200 | [diff] [blame] | 32 | int DrmHwcLayer::ImportBuffer(DrmDevice *drmDevice) { |
| 33 | buffer_info = hwc_drm_bo_t{}; |
Sean Paul | 80b1a5d | 2016-03-10 15:35:13 -0500 | [diff] [blame] | 34 | |
Roman Stratiienko | 5128715 | 2021-02-10 14:59:52 +0200 | [diff] [blame] | 35 | int ret = BufferInfoGetter::GetInstance()->ConvertBoInfo(sf_handle, |
| 36 | &buffer_info); |
Jason Macnak | f2e03b7 | 2020-11-02 07:04:11 -0800 | [diff] [blame] | 37 | if (ret) { |
| 38 | ALOGE("Failed to convert buffer info %d", ret); |
Sean Paul | 80b1a5d | 2016-03-10 15:35:13 -0500 | [diff] [blame] | 39 | return ret; |
Jason Macnak | f2e03b7 | 2020-11-02 07:04:11 -0800 | [diff] [blame] | 40 | } |
| 41 | |
Roman Stratiienko | 5128715 | 2021-02-10 14:59:52 +0200 | [diff] [blame] | 42 | FbIdHandle = drmDevice->GetDrmFbImporter().GetOrCreateFbId(&buffer_info); |
Roman Stratiienko | 8666dc9 | 2021-02-09 17:49:55 +0200 | [diff] [blame] | 43 | if (!FbIdHandle) { |
| 44 | ALOGE("Failed to import buffer"); |
| 45 | return -EINVAL; |
Jason Macnak | f2e03b7 | 2020-11-02 07:04:11 -0800 | [diff] [blame] | 46 | } |
Sean Paul | 80b1a5d | 2016-03-10 15:35:13 -0500 | [diff] [blame] | 47 | |
Sean Paul | 80b1a5d | 2016-03-10 15:35:13 -0500 | [diff] [blame] | 48 | return 0; |
| 49 | } |
| 50 | |
Sean Paul | f72cccd | 2018-08-27 13:59:08 -0400 | [diff] [blame] | 51 | } // namespace android |