2 * Copyright (C) 2015 The Android Open Source Project
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
8 * http://www.apache.org/licenses/LICENSE-2.0
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.
17 #ifndef ANDROID_PLATFORM_NV_H_
18 #define ANDROID_PLATFORM_NV_H_
20 #include "drmresources.h"
22 #include "platformdrmgeneric.h"
24 #include <stdatomic.h>
26 #include <hardware/gralloc.h>
30 class NvImporter : public Importer {
32 NvImporter(DrmResources *drm);
33 ~NvImporter() override;
37 EGLImageKHR ImportImage(EGLDisplay egl_display, buffer_handle_t handle) override;
38 int ImportBuffer(buffer_handle_t handle, hwc_drm_bo_t *bo) override;
39 int ReleaseBuffer(hwc_drm_bo_t *bo) override;
42 typedef struct NvBuffer {
48 static void NvGrallocRelease(void *nv_buffer);
49 void ReleaseBufferImpl(hwc_drm_bo_t *bo);
51 NvBuffer_t *GrallocGetNvBuffer(buffer_handle_t handle);
52 int GrallocSetNvBuffer(buffer_handle_t handle, NvBuffer_t *buf);
56 const gralloc_module_t *gralloc_;
59 // This stage looks for any layers that contain transformed protected content
60 // and puts it in the primary plane since Tegra doesn't support planar rotation
61 // on the overlay planes.
63 // There are two caveats to this approach: 1- Protected content isn't
64 // necessarily planar, but it's usually a safe bet, and 2- This doesn't catch
65 // non-protected planar content. If we wanted to fix this, we'd need to import
66 // the buffer in this stage and peek at it's format. The overhead of doing this
67 // doesn't seem worth it since we'll end up displaying the right thing in both
69 class PlanStageProtectedRotated : public Planner::PlanStage {
71 int ProvisionPlanes(std::vector<DrmCompositionPlane> *composition,
72 std::map<size_t, DrmHwcLayer *> &layers, DrmCrtc *crtc,
73 std::vector<DrmPlane *> *planes);
76 // This stage looks for layers that would not be supported by Tegra driver due
77 // to limitations such as downscaling. If the layer is unprotected it will be
78 // punted for precomp to handle, other wise if protected it will be dropped as
79 // it cannot be supported by any means.
80 class PlanStageNvLimits : public Planner::PlanStage {
82 int ProvisionPlanes(std::vector<DrmCompositionPlane> *composition,
83 std::map<size_t, DrmHwcLayer *> &layers, DrmCrtc *crtc,
84 std::vector<DrmPlane *> *planes);
86 bool CheckLayer(size_t zorder, DrmHwcLayer *layer);