blob: 39decab44d1d023c740bb3f55ca6ee25285ceffd [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"
Alistair Strachan71edaca2018-05-02 17:01:49 -070020
Alistair Strachan71edaca2018-05-02 17:01:49 -070021#include <xf86drm.h>
22#include <xf86drmMode.h>
23
Sean Paulf72cccd2018-08-27 13:59:08 -040024#include <log/log.h>
Alistair Strachan71edaca2018-05-02 17:01:49 -070025
26#include "cros_gralloc_handle.h"
27
28namespace android {
29
Jorge E. Moreira5047b222018-09-19 15:34:07 -070030Importer *Importer::CreateInstance(DrmDevice *drm) {
Alistair Strachan71edaca2018-05-02 17:01:49 -070031 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 Stratiienko4163efc2019-12-06 12:30:28 +020044int DrmMinigbmImporter::ConvertBoInfo(buffer_handle_t handle,
45 hwc_drm_bo_t *bo) {
Alistair Strachan71edaca2018-05-02 17:01:49 -070046 cros_gralloc_handle *gr_handle = (cros_gralloc_handle *)handle;
47 if (!gr_handle)
48 return -EINVAL;
49
Alistair Strachan71edaca2018-05-02 17:01:49 -070050 bo->width = gr_handle->width;
51 bo->height = gr_handle->height;
John Stultz616fb222018-08-24 16:08:57 -070052 bo->hal_format = gr_handle->droid_format;
Alistair Strachan71edaca2018-05-02 17:01:49 -070053 bo->format = gr_handle->format;
54 bo->usage = gr_handle->usage;
John Stultza4514832018-08-24 16:27:36 -070055 bo->pixel_stride = gr_handle->pixel_stride;
Roman Stratiienko4163efc2019-12-06 12:30:28 +020056 bo->prime_fds[0] = gr_handle->fds[0];
Alistair Strachan71edaca2018-05-02 17:01:49 -070057 bo->pitches[0] = gr_handle->strides[0];
58 bo->offsets[0] = gr_handle->offsets[0];
Alistair Strachan71edaca2018-05-02 17:01:49 -070059
Roman Stratiienko4163efc2019-12-06 12:30:28 +020060 return 0;
Alistair Strachan71edaca2018-05-02 17:01:49 -070061}
62
Jorge E. Moreira5047b222018-09-19 15:34:07 -070063std::unique_ptr<Planner> Planner::CreateInstance(DrmDevice *) {
Alistair Strachan71edaca2018-05-02 17:01:49 -070064 std::unique_ptr<Planner> planner(new Planner);
65 planner->AddStage<PlanStageGreedy>();
66 return planner;
67}
68
Sean Paulf72cccd2018-08-27 13:59:08 -040069} // namespace android