blob: 67a85cbbeeb207b8932b4fe2a1a425fabc5b6d83 [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
Roman Stratiienkob2e9fe22020-10-03 10:52:36 +030017#define LOG_TAG "hwc-bufferinfo-minigbm"
Alistair Strachan71edaca2018-05-02 17:01:49 -070018
Roman Stratiienkob2e9fe22020-10-03 10:52:36 +030019#include "BufferInfoMinigbm.h"
Alistair Strachan71edaca2018-05-02 17:01:49 -070020
Sean Paulf72cccd2018-08-27 13:59:08 -040021#include <log/log.h>
Roman Stratiienkob2e9fe22020-10-03 10:52:36 +030022#include <xf86drm.h>
23#include <xf86drmMode.h>
Alistair Strachan71edaca2018-05-02 17:01:49 -070024
25#include "cros_gralloc_handle.h"
26
27namespace android {
28
Roman Stratiienkob2e9fe22020-10-03 10:52:36 +030029LEGACY_BUFFER_INFO_GETTER(BufferInfoMinigbm);
Alistair Strachan71edaca2018-05-02 17:01:49 -070030
Roman Stratiienkob2e9fe22020-10-03 10:52:36 +030031int BufferInfoMinigbm::ConvertBoInfo(buffer_handle_t handle, hwc_drm_bo_t *bo) {
Alistair Strachan71edaca2018-05-02 17:01:49 -070032 cros_gralloc_handle *gr_handle = (cros_gralloc_handle *)handle;
33 if (!gr_handle)
34 return -EINVAL;
35
Alistair Strachan71edaca2018-05-02 17:01:49 -070036 bo->width = gr_handle->width;
37 bo->height = gr_handle->height;
John Stultz616fb222018-08-24 16:08:57 -070038 bo->hal_format = gr_handle->droid_format;
Alistair Strachan71edaca2018-05-02 17:01:49 -070039 bo->format = gr_handle->format;
40 bo->usage = gr_handle->usage;
John Stultza4514832018-08-24 16:27:36 -070041 bo->pixel_stride = gr_handle->pixel_stride;
Roman Stratiienko4163efc2019-12-06 12:30:28 +020042 bo->prime_fds[0] = gr_handle->fds[0];
Alistair Strachan71edaca2018-05-02 17:01:49 -070043 bo->pitches[0] = gr_handle->strides[0];
44 bo->offsets[0] = gr_handle->offsets[0];
Alistair Strachan71edaca2018-05-02 17:01:49 -070045
Roman Stratiienko4163efc2019-12-06 12:30:28 +020046 return 0;
Alistair Strachan71edaca2018-05-02 17:01:49 -070047}
48
Sean Paulf72cccd2018-08-27 13:59:08 -040049} // namespace android