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 20 #include <utils/log.h> 21 22 #include <cerrno> 23 24 #include "bufferinfo/BufferInfoGetter.h" 25 #include "drm/DrmFbImporter.h" 26 #include "drmhwcomposer.h" 27 28 namespace android { 29 ImportBuffer(DrmDevice * drm_device)30int DrmHwcLayer::ImportBuffer(DrmDevice *drm_device) { 31 buffer_info = hwc_drm_bo_t{}; 32 33 int ret = BufferInfoGetter::GetInstance()->ConvertBoInfo(sf_handle, 34 &buffer_info); 35 if (ret != 0) { 36 ALOGE("Failed to convert buffer info %d", ret); 37 return ret; 38 } 39 40 fb_id_handle = drm_device->GetDrmFbImporter().GetOrCreateFbId(&buffer_info); 41 if (!fb_id_handle) { 42 ALOGE("Failed to import buffer"); 43 return -EINVAL; 44 } 45 46 return 0; 47 } 48 49 } // namespace android 50