Skip to content
This repository has been archived by the owner on Oct 8, 2024. It is now read-only.

add libva support #678

Open
wants to merge 2 commits into
base: android10-release
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
112 changes: 0 additions & 112 deletions Android.bp

This file was deleted.

100 changes: 100 additions & 0 deletions Android.mk
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
# Copyright (c) 2017 Intel Corporation
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

LOCAL_PATH:= $(call my-dir)

include $(CLEAR_VARS)

LOCAL_SHARED_LIBRARIES := \
libcutils \
libdrm_pri \
libhardware \
liblog \
libsync \
libui \
libutils \
libva \
libva-android

LOCAL_C_INCLUDES := \
$(LOCAL_PATH)/include \
system/core/include/utils \
system/core/libcutils/include \
external/minigbm/cros_gralloc \
hardware/intel/external/libva \
hardware/intel/external/drm-intel/android
#external/libdrm/android

LOCAL_SRC_FILES := \
drmhwctwo.cpp \
drmdisplaycomposition.cpp \
drmdisplaycompositor.cpp \
drmconnector.cpp \
drmcrtc.cpp \
drmdevice.cpp \
drmencoder.cpp \
drmeventlistener.cpp \
drmmode.cpp \
drmplane.cpp \
drmproperty.cpp \
resourcemanager.cpp \
vsyncworker.cpp \
platform.cpp \
autolock.cpp \
hwcutils.cpp \
worker.cpp \
platformdrmgeneric.cpp \
platformminigbm.cpp \
varenderer.cpp \
vautils.cpp \
gralloc1bufferhandler.cpp



LOCAL_C_INCLUDES += \
system/core/libsync \
system/core/libsync/include


LOCAL_CPPFLAGS += -DENABLE_DOUBLE_BUFFERING
LOCAL_CPPFLAGS += -DUSE_GRALLOC1
LOCAL_CPPFLAGS += -DMODIFICATOR_WA
LOCAL_CPPFLAGS += -DENABLE_RBC

LOCAL_CPPFLAGS += \
-DHWC2_INCLUDE_STRINGIFICATION \
-DHWC2_USE_CPP11 \
-Wno-date-time \
-DUSE_ANDROID_SHIM \
-D_FORTIFY_SOURCE=2 \
-fstack-protector-strong \
-Wformat -Wformat-security \
-std=c++14 -D_GNU_SOURCE=1 -D_FILE_OFFSET_BITS=64 \
-Wall -Wsign-compare -Wpointer-arith \
-D_GNU_SOURCE=1 -D_FILE_OFFSET_BITS=64 \
-Wno-unused-parameter \
-O3 \
-Werror





LOCAL_CPPFLAGS += -DENABLE_ANDROID_WA -DVA_SUPPORT_COLOR_RANGE
#LOCAL_CPPFLAGS += -DENABLE_DUMP_YUV_DATA
LOCAL_VENDOR_MODULE := true
LOCAL_MODULE := hwcomposer.drm_minigbm
LOCAL_CFLAGS += -fvisibility=default
LOCAL_PROPRIETARY_MODULE := true
include $(BUILD_SHARED_LIBRARY)
28 changes: 20 additions & 8 deletions drmdisplaycompositor.cpp
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -381,15 +381,27 @@ int DrmDisplayCompositor::CommitFrame(DrmDisplayComposition *display_comp,
rotation |= DRM_MODE_REFLECT_X;
if (layer.transform & DrmHwcTransform::kFlipV)
rotation |= DRM_MODE_REFLECT_Y;
if (layer.transform & DrmHwcTransform::kRotate90)
rotation |= DRM_MODE_ROTATE_90;
else if (layer.transform & DrmHwcTransform::kRotate180)
rotation |= DRM_MODE_ROTATE_180;
else if (layer.transform & DrmHwcTransform::kRotate270)
rotation |= DRM_MODE_ROTATE_270;
else
if (layer.IsVideoLayer()) {
rotation |= DRM_MODE_ROTATE_0;

source_crop.left = layer.source_crop.left;
source_crop.top = layer.source_crop.top;
source_crop.bottom = layer.source_crop.bottom;
source_crop.right = layer.source_crop.right;

display_frame.left = layer.display_frame.left;
display_frame.top = layer.display_frame.top;
display_frame.bottom = layer.display_frame.bottom;
display_frame.right = layer.display_frame.right;
}else{
if (layer.transform & DrmHwcTransform::kRotate90)
rotation |= DRM_MODE_ROTATE_90;
else if (layer.transform & DrmHwcTransform::kRotate180)
rotation |= DRM_MODE_ROTATE_180;
else if (layer.transform & DrmHwcTransform::kRotate270)
rotation |= DRM_MODE_ROTATE_270;
else
rotation |= DRM_MODE_ROTATE_0;
}
if (fence_fd >= 0) {
int prop_id = plane->in_fence_fd_property().id();
if (prop_id == 0) {
Expand Down
38 changes: 36 additions & 2 deletions drmhwcomposer.h
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@
#include <hardware/hwcomposer.h>
#include "autofd.h"
#include "drmhwcgralloc.h"
#include <map>
#include <log/log.h>

struct hwc_import_context;

Expand All @@ -41,6 +43,8 @@ namespace android {

class Importer;

struct DrmHwcLayer;

class DrmHwcBuffer {
public:
DrmHwcBuffer() = default;
Expand Down Expand Up @@ -71,7 +75,7 @@ class DrmHwcBuffer {

void Clear();

int ImportBuffer(buffer_handle_t handle, Importer *importer);
int ImportBuffer(DrmHwcLayer* layer, Importer *importer);

private:
hwc_drm_bo bo_;
Expand Down Expand Up @@ -121,6 +125,14 @@ enum DrmHwcTransform {
kRotate270 = 1 << 4,
};

enum DrmHwcLayerType {
kLayerNormal = 0,
kLayerCursor = 1,
kLayerProtected = 2,
kLayerVideo = 3,
kLayerSolidColor = 4,
};

enum class DrmHwcBlending : int32_t {
kNone = HWC_BLENDING_NONE,
kPreMult = HWC_BLENDING_PREMULT,
Expand All @@ -137,17 +149,29 @@ struct DrmHwcLayer {
uint16_t alpha = 0xffff;
hwc_frect_t source_crop;
hwc_rect_t display_frame;
DrmHwcLayerType type_ = kLayerNormal;

android_dataspace_t dataspace = HAL_DATASPACE_UNKNOWN;
UniqueFd acquire_fence;
OutputFd release_fence;

int ImportBuffer(Importer *importer);
int InitFromDrmHwcLayer(DrmHwcLayer *layer, Importer *importer);

void SetTransform(int32_t sf_transform);
void SetSourceCrop(hwc_frect_t const &crop);
void SetDisplayFrame(hwc_rect_t const &frame);

void SetVideoLayer(bool isVideo) {
if (isVideo)
type_ = kLayerVideo;
else
type_ = kLayerNormal;
}

bool IsVideoLayer() const {
return type_ == kLayerVideo;
}

buffer_handle_t get_usable_handle() const {
return handle.get() != NULL ? handle.get() : sf_handle;
}
Expand All @@ -158,6 +182,16 @@ struct DrmHwcLayer {
}
};

struct DrmVaComposeHwcLayer : DrmHwcLayer{
std::map<uint32_t, DrmHwcLayer *, std::greater<int>> va_z_map;
void addVaLayerMapData(int zorder, DrmHwcLayer* layer){
va_z_map.emplace(std::make_pair(zorder, layer));
}
std::map<uint32_t, DrmHwcLayer *, std::greater<int>> getVaLayerMapData(){
return va_z_map;
}
};

struct DrmHwcDisplayContents {
OutputFd retire_fence;
std::vector<DrmHwcLayer> layers;
Expand Down
Loading