aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Android.mk6
-rw-r--r--drmhwcomposer.h3
-rw-r--r--hwcutils.cpp34
3 files changed, 37 insertions, 6 deletions
diff --git a/Android.mk b/Android.mk
index 65c0f3a..d5ee200 100644
--- a/Android.mk
+++ b/Android.mk
@@ -14,6 +14,8 @@
ifeq ($(strip $(BOARD_USES_DRM_HWCOMPOSER)),true)
+DRM_HWC_ANDROID_MAJOR_VERSION := $(word 1, $(subst ., , $(PLATFORM_VERSION)))
+
LOCAL_PATH := $(call my-dir)
common_drm_hwcomposer_cflags := \
@@ -79,6 +81,10 @@ LOCAL_CPPFLAGS += \
-DHWC2_USE_CPP11 \
-DHWC2_INCLUDE_STRINGIFICATION
+ifneq ($(filter 2 3 4 5 6 7 8, $(DRM_HWC_ANDROID_MAJOR_VERSION)),)
+LOCAL_CPPFLAGS += -DHWC2_USE_OLD_GB_IMPORT
+endif
+
ifeq ($(TARGET_PRODUCT),hikey960)
LOCAL_CPPFLAGS += -DUSE_HISI_IMPORTER
diff --git a/drmhwcomposer.h b/drmhwcomposer.h
index 1d6da2f..2af7e6e 100644
--- a/drmhwcomposer.h
+++ b/drmhwcomposer.h
@@ -99,7 +99,8 @@ class DrmHwcNativeHandle {
return *this;
}
- int CopyBufferHandle(buffer_handle_t handle);
+ int CopyBufferHandle(buffer_handle_t handle, int width, int height,
+ int layerCount, int format, int usage, int stride);
void Clear();
diff --git a/hwcutils.cpp b/hwcutils.cpp
index b778b93..87e3c42 100644
--- a/hwcutils.cpp
+++ b/hwcutils.cpp
@@ -23,6 +23,8 @@
#include <log/log.h>
#include <ui/GraphicBufferMapper.h>
+#define UNUSED(x) (void)(x)
+
namespace android {
const hwc_drm_bo *DrmHwcBuffer::operator->() const {
@@ -59,11 +61,25 @@ int DrmHwcBuffer::ImportBuffer(buffer_handle_t handle, Importer *importer) {
return 0;
}
-int DrmHwcNativeHandle::CopyBufferHandle(buffer_handle_t handle) {
+int DrmHwcNativeHandle::CopyBufferHandle(buffer_handle_t handle, int width,
+ int height, int layerCount, int format,
+ int usage, int stride) {
native_handle_t *handle_copy;
GraphicBufferMapper &gm(GraphicBufferMapper::get());
- int ret = gm.importBuffer(handle,
- const_cast<buffer_handle_t *>(&handle_copy));
+ int ret;
+
+#ifdef HWC2_USE_OLD_GB_IMPORT
+ UNUSED(width);
+ UNUSED(height);
+ UNUSED(layerCount);
+ UNUSED(format);
+ UNUSED(usage);
+ UNUSED(stride);
+ ret = gm.importBuffer(handle, const_cast<buffer_handle_t *>(&handle_copy));
+#else
+ ret = gm.importBuffer(handle, width, height, layerCount, format, usage,
+ stride, const_cast<buffer_handle_t *>(&handle_copy));
+#endif
if (ret) {
ALOGE("Failed to import buffer handle %d", ret);
return ret;
@@ -96,11 +112,19 @@ int DrmHwcLayer::ImportBuffer(Importer *importer) {
if (ret)
return ret;
- ret = handle.CopyBufferHandle(sf_handle);
+ const hwc_drm_bo *bo = buffer.operator->();
+
+ unsigned int layer_count;
+ for (layer_count = 0; layer_count < HWC_DRM_BO_MAX_PLANES; ++layer_count)
+ if (bo->gem_handles[layer_count] == 0)
+ break;
+
+ ret = handle.CopyBufferHandle(sf_handle, bo->width, bo->height, layer_count,
+ bo->hal_format, bo->usage, bo->pixel_stride);
if (ret)
return ret;
- gralloc_buffer_usage = buffer.operator->()->usage;
+ gralloc_buffer_usage = bo->usage;
return 0;
}