Alistair Strachan | 71edaca | 2018-05-02 17:01:49 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2018 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 LOG_TAG "hwc-platform-drm-minigbm" |
| 18 | |
Sean Paul | f72cccd | 2018-08-27 13:59:08 -0400 | [diff] [blame] | 19 | #include "platformminigbm.h" |
Alistair Strachan | 71edaca | 2018-05-02 17:01:49 -0700 | [diff] [blame] | 20 | |
Alistair Strachan | 71edaca | 2018-05-02 17:01:49 -0700 | [diff] [blame] | 21 | #include <xf86drm.h> |
| 22 | #include <xf86drmMode.h> |
| 23 | |
Sean Paul | f72cccd | 2018-08-27 13:59:08 -0400 | [diff] [blame] | 24 | #include <log/log.h> |
Alistair Strachan | 71edaca | 2018-05-02 17:01:49 -0700 | [diff] [blame] | 25 | |
| 26 | #include "cros_gralloc_handle.h" |
| 27 | |
| 28 | namespace android { |
| 29 | |
Jorge E. Moreira | 5047b22 | 2018-09-19 15:34:07 -0700 | [diff] [blame] | 30 | Importer *Importer::CreateInstance(DrmDevice *drm) { |
Alistair Strachan | 71edaca | 2018-05-02 17:01:49 -0700 | [diff] [blame] | 31 | DrmMinigbmImporter *importer = new DrmMinigbmImporter(drm); |
| 32 | if (!importer) |
| 33 | return NULL; |
| 34 | |
| 35 | int ret = importer->Init(); |
| 36 | if (ret) { |
| 37 | ALOGE("Failed to initialize the minigbm importer %d", ret); |
| 38 | delete importer; |
| 39 | return NULL; |
| 40 | } |
| 41 | return importer; |
| 42 | } |
| 43 | |
Roman Stratiienko | 4163efc | 2019-12-06 12:30:28 +0200 | [diff] [blame] | 44 | int DrmMinigbmImporter::ConvertBoInfo(buffer_handle_t handle, |
| 45 | hwc_drm_bo_t *bo) { |
Alistair Strachan | 71edaca | 2018-05-02 17:01:49 -0700 | [diff] [blame] | 46 | cros_gralloc_handle *gr_handle = (cros_gralloc_handle *)handle; |
| 47 | if (!gr_handle) |
| 48 | return -EINVAL; |
| 49 | |
Alistair Strachan | 71edaca | 2018-05-02 17:01:49 -0700 | [diff] [blame] | 50 | bo->width = gr_handle->width; |
| 51 | bo->height = gr_handle->height; |
John Stultz | 616fb22 | 2018-08-24 16:08:57 -0700 | [diff] [blame] | 52 | bo->hal_format = gr_handle->droid_format; |
Alistair Strachan | 71edaca | 2018-05-02 17:01:49 -0700 | [diff] [blame] | 53 | bo->format = gr_handle->format; |
| 54 | bo->usage = gr_handle->usage; |
John Stultz | a451483 | 2018-08-24 16:27:36 -0700 | [diff] [blame] | 55 | bo->pixel_stride = gr_handle->pixel_stride; |
Roman Stratiienko | 4163efc | 2019-12-06 12:30:28 +0200 | [diff] [blame] | 56 | bo->prime_fds[0] = gr_handle->fds[0]; |
Alistair Strachan | 71edaca | 2018-05-02 17:01:49 -0700 | [diff] [blame] | 57 | bo->pitches[0] = gr_handle->strides[0]; |
| 58 | bo->offsets[0] = gr_handle->offsets[0]; |
Alistair Strachan | 71edaca | 2018-05-02 17:01:49 -0700 | [diff] [blame] | 59 | |
Roman Stratiienko | 4163efc | 2019-12-06 12:30:28 +0200 | [diff] [blame] | 60 | return 0; |
Alistair Strachan | 71edaca | 2018-05-02 17:01:49 -0700 | [diff] [blame] | 61 | } |
| 62 | |
Jorge E. Moreira | 5047b22 | 2018-09-19 15:34:07 -0700 | [diff] [blame] | 63 | std::unique_ptr<Planner> Planner::CreateInstance(DrmDevice *) { |
Alistair Strachan | 71edaca | 2018-05-02 17:01:49 -0700 | [diff] [blame] | 64 | std::unique_ptr<Planner> planner(new Planner); |
| 65 | planner->AddStage<PlanStageGreedy>(); |
| 66 | return planner; |
| 67 | } |
| 68 | |
Sean Paul | f72cccd | 2018-08-27 13:59:08 -0400 | [diff] [blame] | 69 | } // namespace android |