drm_hwcomposer: Reorganize modifiers handling logic
Reasons for this change:
1. Remove redundant code lines.
2. Workaround for cases when DRM_FORMAT_MOD_INVALID is set by gralloc.
Signed-off-by: Roman Stratiienko <r.stratiienko@gmail.com>
diff --git a/drm/DrmGenericImporter.cpp b/drm/DrmGenericImporter.cpp
index 8ab4fe5..7fbbdc6 100644
--- a/drm/DrmGenericImporter.cpp
+++ b/drm/DrmGenericImporter.cpp
@@ -59,13 +59,16 @@
}
}
- if (!has_modifier_support_ && bo->modifiers[0]) {
+ bool has_modifiers = bo->modifiers[0] != DRM_FORMAT_MOD_NONE &&
+ bo->modifiers[0] != DRM_FORMAT_MOD_INVALID;
+
+ if (!has_modifier_support_ && has_modifiers) {
ALOGE("No ADDFB2 with modifier support. Can't import modifier %" PRIu64,
bo->modifiers[0]);
return -EINVAL;
}
- if (!bo->with_modifiers)
+ if (!has_modifiers)
ret = drmModeAddFB2(drm_->fd(), bo->width, bo->height, bo->format,
bo->gem_handles, bo->pitches, bo->offsets, &bo->fb_id,
0);
@@ -73,8 +76,7 @@
ret = drmModeAddFB2WithModifiers(drm_->fd(), bo->width, bo->height,
bo->format, bo->gem_handles, bo->pitches,
bo->offsets, bo->modifiers, &bo->fb_id,
- bo->modifiers[0] ? DRM_MODE_FB_MODIFIERS
- : 0);
+ DRM_MODE_FB_MODIFIERS);
if (ret) {
ALOGE("could not create drm fb %d", ret);