drm_hwcomposer: implement Gralloc 4 BufferInfoMapperMetadata
Implements the BufferInfoMapperMetadata that uses the
GraphicBufferMapper to set the fields of the hwc_drm_bo_t struct.
New class function GetFds created to obtain the file descriptors from
the native_handle_t. Function is marked weak so that vendors can
override it to match their system if required.
Change-Id: I74445487dec6bda2915b21f4b63804832bfead23
Signed-off-by: Dennis Tsiang <dennis.tsiang@arm.com>
Reviewed-by: Roman Stratiienko <r.stratiienko@gmail.com>
diff --git a/drm/DrmGenericImporter.cpp b/drm/DrmGenericImporter.cpp
index b4dc063..8ab4fe5 100644
--- a/drm/DrmGenericImporter.cpp
+++ b/drm/DrmGenericImporter.cpp
@@ -21,6 +21,7 @@
#include <cutils/properties.h>
#include <gralloc_handle.h>
#include <hardware/gralloc.h>
+#include <inttypes.h>
#include <log/log.h>
#include <xf86drm.h>
#include <xf86drmMode.h>
@@ -28,6 +29,12 @@
namespace android {
DrmGenericImporter::DrmGenericImporter(DrmDevice *drm) : drm_(drm) {
+ uint64_t cap_value = 0;
+ if (drmGetCap(drm_->fd(), DRM_CAP_ADDFB2_MODIFIERS, &cap_value)) {
+ ALOGE("drmGetCap failed. Fallback to no modifier support.");
+ cap_value = 0;
+ }
+ has_modifier_support_ = cap_value;
}
DrmGenericImporter::~DrmGenericImporter() {
@@ -52,6 +59,12 @@
}
}
+ if (!has_modifier_support_ && bo->modifiers[0]) {
+ ALOGE("No ADDFB2 with modifier support. Can't import modifier %" PRIu64,
+ bo->modifiers[0]);
+ return -EINVAL;
+ }
+
if (!bo->with_modifiers)
ret = drmModeAddFB2(drm_->fd(), bo->width, bo->height, bo->format,
bo->gem_handles, bo->pitches, bo->offsets, &bo->fb_id,