Sean Paul | da6270d | 2015-06-01 14:11:52 -0400 | [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 | 5d8acfc | 2016-04-21 16:26:27 -0400 | [diff] [blame] | 17 | #ifndef ANDROID_PLATFORM_NV_H_ |
| 18 | #define ANDROID_PLATFORM_NV_H_ |
Sean Paul | da6270d | 2015-06-01 14:11:52 -0400 | [diff] [blame] | 19 | |
| 20 | #include "drmresources.h" |
Sean Paul | 6376996 | 2016-04-21 16:25:06 -0400 | [diff] [blame] | 21 | #include "platform.h" |
Sean Paul | 4c4646e | 2016-05-10 04:19:24 -0400 | [diff] [blame] | 22 | #include "platformdrmgeneric.h" |
Sean Paul | da6270d | 2015-06-01 14:11:52 -0400 | [diff] [blame] | 23 | |
Sean Paul | 419b5e0 | 2015-06-10 14:30:47 -0400 | [diff] [blame] | 24 | #include <stdatomic.h> |
| 25 | |
Sean Paul | da6270d | 2015-06-01 14:11:52 -0400 | [diff] [blame] | 26 | #include <hardware/gralloc.h> |
| 27 | |
| 28 | namespace android { |
| 29 | |
| 30 | class NvImporter : public Importer { |
| 31 | public: |
| 32 | NvImporter(DrmResources *drm); |
Haixia Shi | 479412c | 2015-10-27 10:40:48 -0700 | [diff] [blame] | 33 | ~NvImporter() override; |
Sean Paul | da6270d | 2015-06-01 14:11:52 -0400 | [diff] [blame] | 34 | |
| 35 | int Init(); |
| 36 | |
Haixia Shi | 479412c | 2015-10-27 10:40:48 -0700 | [diff] [blame] | 37 | int ImportBuffer(buffer_handle_t handle, hwc_drm_bo_t *bo) override; |
| 38 | int ReleaseBuffer(hwc_drm_bo_t *bo) override; |
Sean Paul | da6270d | 2015-06-01 14:11:52 -0400 | [diff] [blame] | 39 | |
| 40 | private: |
| 41 | typedef struct NvBuffer { |
| 42 | NvImporter *importer; |
| 43 | hwc_drm_bo_t bo; |
Sean Paul | 419b5e0 | 2015-06-10 14:30:47 -0400 | [diff] [blame] | 44 | atomic_int ref; |
Sean Paul | da6270d | 2015-06-01 14:11:52 -0400 | [diff] [blame] | 45 | } NvBuffer_t; |
| 46 | |
Sean Paul | 419b5e0 | 2015-06-10 14:30:47 -0400 | [diff] [blame] | 47 | static void NvGrallocRelease(void *nv_buffer); |
Sean Paul | da6270d | 2015-06-01 14:11:52 -0400 | [diff] [blame] | 48 | void ReleaseBufferImpl(hwc_drm_bo_t *bo); |
| 49 | |
| 50 | NvBuffer_t *GrallocGetNvBuffer(buffer_handle_t handle); |
| 51 | int GrallocSetNvBuffer(buffer_handle_t handle, NvBuffer_t *buf); |
| 52 | |
| 53 | DrmResources *drm_; |
| 54 | |
| 55 | const gralloc_module_t *gralloc_; |
| 56 | }; |
Sean Paul | 4c4646e | 2016-05-10 04:19:24 -0400 | [diff] [blame] | 57 | |
| 58 | // This stage looks for any layers that contain transformed protected content |
| 59 | // and puts it in the primary plane since Tegra doesn't support planar rotation |
| 60 | // on the overlay planes. |
| 61 | // |
| 62 | // There are two caveats to this approach: 1- Protected content isn't |
| 63 | // necessarily planar, but it's usually a safe bet, and 2- This doesn't catch |
| 64 | // non-protected planar content. If we wanted to fix this, we'd need to import |
| 65 | // the buffer in this stage and peek at it's format. The overhead of doing this |
| 66 | // doesn't seem worth it since we'll end up displaying the right thing in both |
| 67 | // cases anyways. |
| 68 | class PlanStageProtectedRotated : public Planner::PlanStage { |
| 69 | public: |
| 70 | int ProvisionPlanes(std::vector<DrmCompositionPlane> *composition, |
| 71 | std::map<size_t, DrmHwcLayer *> &layers, DrmCrtc *crtc, |
| 72 | std::vector<DrmPlane *> *planes); |
| 73 | }; |
Adrian Salido | ee24aca | 2017-07-17 17:58:50 -0700 | [diff] [blame] | 74 | |
| 75 | // This stage looks for layers that would not be supported by Tegra driver due |
| 76 | // to limitations such as downscaling. If the layer is unprotected it will be |
| 77 | // punted for precomp to handle, other wise if protected it will be dropped as |
| 78 | // it cannot be supported by any means. |
| 79 | class PlanStageNvLimits : public Planner::PlanStage { |
| 80 | public: |
| 81 | int ProvisionPlanes(std::vector<DrmCompositionPlane> *composition, |
| 82 | std::map<size_t, DrmHwcLayer *> &layers, DrmCrtc *crtc, |
| 83 | std::vector<DrmPlane *> *planes); |
| 84 | protected: |
Adrian Salido | a791258 | 2017-08-21 17:07:18 -0700 | [diff] [blame] | 85 | bool CheckLayer(size_t zorder, DrmHwcLayer *layer); |
Adrian Salido | ee24aca | 2017-07-17 17:58:50 -0700 | [diff] [blame] | 86 | }; |
Sean Paul | da6270d | 2015-06-01 14:11:52 -0400 | [diff] [blame] | 87 | } |
| 88 | |
| 89 | #endif |