blob: 3c1f49ec6eefd4341ab14e95ad955e4589610132 [file] [log] [blame]
Sean Paulda6270d2015-06-01 14:11:52 -04001/*
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 Paul5d8acfc2016-04-21 16:26:27 -040017#ifndef ANDROID_PLATFORM_NV_H_
18#define ANDROID_PLATFORM_NV_H_
Sean Paulda6270d2015-06-01 14:11:52 -040019
20#include "drmresources.h"
Sean Paul63769962016-04-21 16:25:06 -040021#include "platform.h"
Sean Paul4c4646e2016-05-10 04:19:24 -040022#include "platformdrmgeneric.h"
Sean Paulda6270d2015-06-01 14:11:52 -040023
Sean Paul419b5e02015-06-10 14:30:47 -040024#include <stdatomic.h>
25
Sean Paulda6270d2015-06-01 14:11:52 -040026#include <hardware/gralloc.h>
27
28namespace android {
29
30class NvImporter : public Importer {
31 public:
32 NvImporter(DrmResources *drm);
Haixia Shi479412c2015-10-27 10:40:48 -070033 ~NvImporter() override;
Sean Paulda6270d2015-06-01 14:11:52 -040034
35 int Init();
36
Rob Clark90f92d82016-10-19 10:48:14 -040037 EGLImageKHR ImportImage(EGLDisplay egl_display, buffer_handle_t handle) override;
Haixia Shi479412c2015-10-27 10:40:48 -070038 int ImportBuffer(buffer_handle_t handle, hwc_drm_bo_t *bo) override;
39 int ReleaseBuffer(hwc_drm_bo_t *bo) override;
Sean Paulda6270d2015-06-01 14:11:52 -040040
41 private:
42 typedef struct NvBuffer {
43 NvImporter *importer;
44 hwc_drm_bo_t bo;
Sean Paul419b5e02015-06-10 14:30:47 -040045 atomic_int ref;
Sean Paulda6270d2015-06-01 14:11:52 -040046 } NvBuffer_t;
47
Sean Paul419b5e02015-06-10 14:30:47 -040048 static void NvGrallocRelease(void *nv_buffer);
Sean Paulda6270d2015-06-01 14:11:52 -040049 void ReleaseBufferImpl(hwc_drm_bo_t *bo);
50
51 NvBuffer_t *GrallocGetNvBuffer(buffer_handle_t handle);
52 int GrallocSetNvBuffer(buffer_handle_t handle, NvBuffer_t *buf);
53
54 DrmResources *drm_;
55
56 const gralloc_module_t *gralloc_;
57};
Sean Paul4c4646e2016-05-10 04:19:24 -040058
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.
62//
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
68// cases anyways.
69class PlanStageProtectedRotated : public Planner::PlanStage {
70 public:
71 int ProvisionPlanes(std::vector<DrmCompositionPlane> *composition,
72 std::map<size_t, DrmHwcLayer *> &layers, DrmCrtc *crtc,
73 std::vector<DrmPlane *> *planes);
74};
Adrian Salidoee24aca2017-07-17 17:58:50 -070075
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.
80class PlanStageNvLimits : public Planner::PlanStage {
81 public:
82 int ProvisionPlanes(std::vector<DrmCompositionPlane> *composition,
83 std::map<size_t, DrmHwcLayer *> &layers, DrmCrtc *crtc,
84 std::vector<DrmPlane *> *planes);
85 protected:
86 bool CheckLayer(DrmHwcLayer *layer);
87};
Sean Paulda6270d2015-06-01 14:11:52 -040088}
89
90#endif