blob: 22af12b15b9367888b87ec63880e699628011b55 [file] [log] [blame]
Sean Paulcd36a9e2015-01-22 18:01:18 -05001/*
2 * Copyright (C) 2015 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
Sean Paulef8f1f92015-04-29 16:05:23 -040017#ifndef ANDROID_DRM_HWCOMPOSER_H_
18#define ANDROID_DRM_HWCOMPOSER_H_
19
Roman Stratiienko8666dc92021-02-09 17:49:55 +020020#include <hardware/hardware.h>
21#include <hardware/hwcomposer.h>
Lauri Peltonen902c8942015-03-02 19:10:04 +020022#include <stdbool.h>
23#include <stdint.h>
24
Rob Herringcff7b1e2018-05-09 15:18:36 -050025#include <vector>
26
Roman Stratiienko8666dc92021-02-09 17:49:55 +020027#include "drm/DrmFbImporter.h"
Zach Reizner766518e2015-10-22 16:34:49 -070028#include "drmhwcgralloc.h"
Roman Stratiienko0fade372021-02-20 13:59:55 +020029#include "utils/UniqueFd.h"
Zach Reizner766518e2015-10-22 16:34:49 -070030
Zach Reizner4a253652015-09-10 18:30:54 -070031namespace android {
32
Roman Stratiienko51287152021-02-10 14:59:52 +020033class DrmFbIdHandle;
Zach Reizner4a253652015-09-10 18:30:54 -070034
Sean Paul04b47ea2015-11-19 21:46:11 -050035enum DrmHwcTransform {
Zach Reizner4a253652015-09-10 18:30:54 -070036 kIdentity = 0,
Sean Paul04b47ea2015-11-19 21:46:11 -050037 kFlipH = 1 << 0,
38 kFlipV = 1 << 1,
39 kRotate90 = 1 << 2,
40 kRotate180 = 1 << 3,
41 kRotate270 = 1 << 4,
Zach Reizner4a253652015-09-10 18:30:54 -070042};
43
44enum class DrmHwcBlending : int32_t {
45 kNone = HWC_BLENDING_NONE,
46 kPreMult = HWC_BLENDING_PREMULT,
47 kCoverage = HWC_BLENDING_COVERAGE,
48};
49
50struct DrmHwcLayer {
51 buffer_handle_t sf_handle = NULL;
Roman Stratiienko51287152021-02-10 14:59:52 +020052 hwc_drm_bo_t buffer_info{};
53 std::shared_ptr<DrmFbIdHandle> FbIdHandle;
54
Zach Reizner36d7c6e2015-10-20 10:58:19 -070055 int gralloc_buffer_usage = 0;
Sean Paul04b47ea2015-11-19 21:46:11 -050056 uint32_t transform;
Zach Reizner4a253652015-09-10 18:30:54 -070057 DrmHwcBlending blending = DrmHwcBlending::kNone;
Stefan Schake025d0a62018-05-04 18:03:00 +020058 uint16_t alpha = 0xffff;
Rob Herringcff7b1e2018-05-09 15:18:36 -050059 hwc_frect_t source_crop;
60 hwc_rect_t display_frame;
Matvii Zorin8338c342020-09-08 16:12:51 +030061 android_dataspace_t dataspace;
Zach Reizner4a253652015-09-10 18:30:54 -070062
63 UniqueFd acquire_fence;
Zach Reizner4a253652015-09-10 18:30:54 -070064
Roman Stratiienko8666dc92021-02-09 17:49:55 +020065 int ImportBuffer(DrmDevice *drmDevice);
Sean Paul80b1a5d2016-03-10 15:35:13 -050066
67 void SetTransform(int32_t sf_transform);
Zach Reiznerf99d53f2015-10-09 13:02:55 -070068
Zach Reiznerdb81fce2015-10-27 16:18:06 -070069 bool protected_usage() const {
70 return (gralloc_buffer_usage & GRALLOC_USAGE_PROTECTED) ==
71 GRALLOC_USAGE_PROTECTED;
72 }
Zach Reizner4a253652015-09-10 18:30:54 -070073};
74
Sean Paulf72cccd2018-08-27 13:59:08 -040075} // namespace android
Zach Reizner4a253652015-09-10 18:30:54 -070076
Sean Paulef8f1f92015-04-29 16:05:23 -040077#endif