blob: df195d3ff888ac7d01b46f1b8ab7d16e2ace5928 [file] [log] [blame]
Alistair Strachan71edaca2018-05-02 17:01:49 -07001/*
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 Paulf72cccd2018-08-27 13:59:08 -040019#include "platformminigbm.h"
Jorge E. Moreira5047b222018-09-19 15:34:07 -070020#include "drmdevice.h"
Alistair Strachan71edaca2018-05-02 17:01:49 -070021#include "platform.h"
Alistair Strachan71edaca2018-05-02 17:01:49 -070022
Alistair Strachan71edaca2018-05-02 17:01:49 -070023#include <xf86drm.h>
24#include <xf86drmMode.h>
25
Alistair Strachan71edaca2018-05-02 17:01:49 -070026#include <hardware/gralloc.h>
Sean Paulf72cccd2018-08-27 13:59:08 -040027#include <log/log.h>
Alistair Strachan71edaca2018-05-02 17:01:49 -070028
29#include "cros_gralloc_handle.h"
30
31namespace android {
32
Jorge E. Moreira5047b222018-09-19 15:34:07 -070033Importer *Importer::CreateInstance(DrmDevice *drm) {
Alistair Strachan71edaca2018-05-02 17:01:49 -070034 DrmMinigbmImporter *importer = new DrmMinigbmImporter(drm);
35 if (!importer)
36 return NULL;
37
38 int ret = importer->Init();
39 if (ret) {
40 ALOGE("Failed to initialize the minigbm importer %d", ret);
41 delete importer;
42 return NULL;
43 }
44 return importer;
45}
46
Roman Stratiienko4163efc2019-12-06 12:30:28 +020047int DrmMinigbmImporter::ConvertBoInfo(buffer_handle_t handle,
48 hwc_drm_bo_t *bo) {
Alistair Strachan71edaca2018-05-02 17:01:49 -070049 cros_gralloc_handle *gr_handle = (cros_gralloc_handle *)handle;
50 if (!gr_handle)
51 return -EINVAL;
52
Alistair Strachan71edaca2018-05-02 17:01:49 -070053 bo->width = gr_handle->width;
54 bo->height = gr_handle->height;
John Stultz616fb222018-08-24 16:08:57 -070055 bo->hal_format = gr_handle->droid_format;
Alistair Strachan71edaca2018-05-02 17:01:49 -070056 bo->format = gr_handle->format;
57 bo->usage = gr_handle->usage;
John Stultza4514832018-08-24 16:27:36 -070058 bo->pixel_stride = gr_handle->pixel_stride;
Roman Stratiienko4163efc2019-12-06 12:30:28 +020059 bo->prime_fds[0] = gr_handle->fds[0];
Alistair Strachan71edaca2018-05-02 17:01:49 -070060 bo->pitches[0] = gr_handle->strides[0];
61 bo->offsets[0] = gr_handle->offsets[0];
Alistair Strachan71edaca2018-05-02 17:01:49 -070062
Roman Stratiienko4163efc2019-12-06 12:30:28 +020063 return 0;
Alistair Strachan71edaca2018-05-02 17:01:49 -070064}
65
Jorge E. Moreira5047b222018-09-19 15:34:07 -070066std::unique_ptr<Planner> Planner::CreateInstance(DrmDevice *) {
Alistair Strachan71edaca2018-05-02 17:01:49 -070067 std::unique_ptr<Planner> planner(new Planner);
68 planner->AddStage<PlanStageGreedy>();
69 return planner;
70}
71
Sean Paulf72cccd2018-08-27 13:59:08 -040072} // namespace android