| 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 |  | 
| Roman Stratiienko | fc014f5 | 2021-12-23 19:04:29 +0200 | [diff] [blame] | 20 | #include <utils/log.h> | 
|  | 21 |  | 
|  | 22 | #include <cerrno> | 
| 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 |  | 
| Sean Paul | 80b1a5d | 2016-03-10 15:35:13 -0500 | [diff] [blame] | 28 | namespace android { | 
|  | 29 |  | 
| Roman Stratiienko | fc014f5 | 2021-12-23 19:04:29 +0200 | [diff] [blame] | 30 | int DrmHwcLayer::ImportBuffer(DrmDevice *drm_device) { | 
| Roman Stratiienko | 5128715 | 2021-02-10 14:59:52 +0200 | [diff] [blame] | 31 | buffer_info = hwc_drm_bo_t{}; | 
| Sean Paul | 80b1a5d | 2016-03-10 15:35:13 -0500 | [diff] [blame] | 32 |  | 
| Roman Stratiienko | 5128715 | 2021-02-10 14:59:52 +0200 | [diff] [blame] | 33 | int ret = BufferInfoGetter::GetInstance()->ConvertBoInfo(sf_handle, | 
|  | 34 | &buffer_info); | 
| Roman Stratiienko | fc014f5 | 2021-12-23 19:04:29 +0200 | [diff] [blame] | 35 | if (ret != 0) { | 
| Jason Macnak | f2e03b7 | 2020-11-02 07:04:11 -0800 | [diff] [blame] | 36 | ALOGE("Failed to convert buffer info %d", ret); | 
| Sean Paul | 80b1a5d | 2016-03-10 15:35:13 -0500 | [diff] [blame] | 37 | return ret; | 
| Jason Macnak | f2e03b7 | 2020-11-02 07:04:11 -0800 | [diff] [blame] | 38 | } | 
|  | 39 |  | 
| Roman Stratiienko | fc014f5 | 2021-12-23 19:04:29 +0200 | [diff] [blame] | 40 | fb_id_handle = drm_device->GetDrmFbImporter().GetOrCreateFbId(&buffer_info); | 
|  | 41 | if (!fb_id_handle) { | 
| Roman Stratiienko | 8666dc9 | 2021-02-09 17:49:55 +0200 | [diff] [blame] | 42 | ALOGE("Failed to import buffer"); | 
|  | 43 | return -EINVAL; | 
| Jason Macnak | f2e03b7 | 2020-11-02 07:04:11 -0800 | [diff] [blame] | 44 | } | 
| Sean Paul | 80b1a5d | 2016-03-10 15:35:13 -0500 | [diff] [blame] | 45 |  | 
| Sean Paul | 80b1a5d | 2016-03-10 15:35:13 -0500 | [diff] [blame] | 46 | return 0; | 
|  | 47 | } | 
|  | 48 |  | 
| Sean Paul | f72cccd | 2018-08-27 13:59:08 -0400 | [diff] [blame] | 49 | }  // namespace android |