Sean Paul | cd36a9e | 2015-01-22 18:01:18 -0500 | [diff] [blame] | 1 | /* |
| 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 Paul | ef8f1f9 | 2015-04-29 16:05:23 -0400 | [diff] [blame] | 17 | #ifndef ANDROID_DRM_HWCOMPOSER_H_ |
| 18 | #define ANDROID_DRM_HWCOMPOSER_H_ |
| 19 | |
Roman Stratiienko | 8666dc9 | 2021-02-09 17:49:55 +0200 | [diff] [blame] | 20 | #include <hardware/hardware.h> |
| 21 | #include <hardware/hwcomposer.h> |
Lauri Peltonen | 902c894 | 2015-03-02 19:10:04 +0200 | [diff] [blame] | 22 | #include <stdbool.h> |
| 23 | #include <stdint.h> |
| 24 | |
Rob Herring | cff7b1e | 2018-05-09 15:18:36 -0500 | [diff] [blame] | 25 | #include <vector> |
| 26 | |
Roman Stratiienko | 8666dc9 | 2021-02-09 17:49:55 +0200 | [diff] [blame] | 27 | #include "drm/DrmFbImporter.h" |
Zach Reizner | 766518e | 2015-10-22 16:34:49 -0700 | [diff] [blame] | 28 | #include "drmhwcgralloc.h" |
Roman Stratiienko | 0fade37 | 2021-02-20 13:59:55 +0200 | [diff] [blame] | 29 | #include "utils/UniqueFd.h" |
Zach Reizner | 766518e | 2015-10-22 16:34:49 -0700 | [diff] [blame] | 30 | |
Zach Reizner | 4a25365 | 2015-09-10 18:30:54 -0700 | [diff] [blame] | 31 | namespace android { |
| 32 | |
Roman Stratiienko | 5128715 | 2021-02-10 14:59:52 +0200 | [diff] [blame] | 33 | class DrmFbIdHandle; |
Zach Reizner | 4a25365 | 2015-09-10 18:30:54 -0700 | [diff] [blame] | 34 | |
Roman Stratiienko | 515da8f | 2021-09-29 12:47:21 +0300 | [diff] [blame^] | 35 | enum class DrmHwcColorSpace : int32_t { |
| 36 | kUndefined, |
| 37 | kItuRec601, |
| 38 | kItuRec709, |
| 39 | kItuRec2020, |
| 40 | }; |
| 41 | |
| 42 | enum class DrmHwcSampleRange : int32_t { |
| 43 | kUndefined, |
| 44 | kFullRange, |
| 45 | kLimitedRange, |
| 46 | }; |
| 47 | |
Sean Paul | 04b47ea | 2015-11-19 21:46:11 -0500 | [diff] [blame] | 48 | enum DrmHwcTransform { |
Zach Reizner | 4a25365 | 2015-09-10 18:30:54 -0700 | [diff] [blame] | 49 | kIdentity = 0, |
Sean Paul | 04b47ea | 2015-11-19 21:46:11 -0500 | [diff] [blame] | 50 | kFlipH = 1 << 0, |
| 51 | kFlipV = 1 << 1, |
| 52 | kRotate90 = 1 << 2, |
| 53 | kRotate180 = 1 << 3, |
| 54 | kRotate270 = 1 << 4, |
Zach Reizner | 4a25365 | 2015-09-10 18:30:54 -0700 | [diff] [blame] | 55 | }; |
| 56 | |
| 57 | enum class DrmHwcBlending : int32_t { |
| 58 | kNone = HWC_BLENDING_NONE, |
| 59 | kPreMult = HWC_BLENDING_PREMULT, |
| 60 | kCoverage = HWC_BLENDING_COVERAGE, |
| 61 | }; |
| 62 | |
| 63 | struct DrmHwcLayer { |
| 64 | buffer_handle_t sf_handle = NULL; |
Roman Stratiienko | 5128715 | 2021-02-10 14:59:52 +0200 | [diff] [blame] | 65 | hwc_drm_bo_t buffer_info{}; |
| 66 | std::shared_ptr<DrmFbIdHandle> FbIdHandle; |
| 67 | |
Zach Reizner | 36d7c6e | 2015-10-20 10:58:19 -0700 | [diff] [blame] | 68 | int gralloc_buffer_usage = 0; |
Sean Paul | 04b47ea | 2015-11-19 21:46:11 -0500 | [diff] [blame] | 69 | uint32_t transform; |
Zach Reizner | 4a25365 | 2015-09-10 18:30:54 -0700 | [diff] [blame] | 70 | DrmHwcBlending blending = DrmHwcBlending::kNone; |
Stefan Schake | 025d0a6 | 2018-05-04 18:03:00 +0200 | [diff] [blame] | 71 | uint16_t alpha = 0xffff; |
Rob Herring | cff7b1e | 2018-05-09 15:18:36 -0500 | [diff] [blame] | 72 | hwc_frect_t source_crop; |
| 73 | hwc_rect_t display_frame; |
Roman Stratiienko | 515da8f | 2021-09-29 12:47:21 +0300 | [diff] [blame^] | 74 | DrmHwcColorSpace color_space; |
| 75 | DrmHwcSampleRange sample_range; |
Zach Reizner | 4a25365 | 2015-09-10 18:30:54 -0700 | [diff] [blame] | 76 | |
| 77 | UniqueFd acquire_fence; |
Zach Reizner | 4a25365 | 2015-09-10 18:30:54 -0700 | [diff] [blame] | 78 | |
Roman Stratiienko | 8666dc9 | 2021-02-09 17:49:55 +0200 | [diff] [blame] | 79 | int ImportBuffer(DrmDevice *drmDevice); |
Sean Paul | 80b1a5d | 2016-03-10 15:35:13 -0500 | [diff] [blame] | 80 | |
| 81 | void SetTransform(int32_t sf_transform); |
Zach Reizner | f99d53f | 2015-10-09 13:02:55 -0700 | [diff] [blame] | 82 | |
Zach Reizner | db81fce | 2015-10-27 16:18:06 -0700 | [diff] [blame] | 83 | bool protected_usage() const { |
| 84 | return (gralloc_buffer_usage & GRALLOC_USAGE_PROTECTED) == |
| 85 | GRALLOC_USAGE_PROTECTED; |
| 86 | } |
Zach Reizner | 4a25365 | 2015-09-10 18:30:54 -0700 | [diff] [blame] | 87 | }; |
| 88 | |
Sean Paul | f72cccd | 2018-08-27 13:59:08 -0400 | [diff] [blame] | 89 | } // namespace android |
Zach Reizner | 4a25365 | 2015-09-10 18:30:54 -0700 | [diff] [blame] | 90 | |
Sean Paul | ef8f1f9 | 2015-04-29 16:05:23 -0400 | [diff] [blame] | 91 | #endif |