aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorandroid-build-prod (mdb) <android-build-team-robot@google.com>2019-07-17 19:40:24 +0000
committerandroid-build-prod (mdb) <android-build-team-robot@google.com>2019-07-17 19:40:24 +0000
commit2b406a48da46b3d0a7716522ee32dcd938fdaa99 (patch)
treeb9baf41caae9abbf6451594ea8233fb2ab4e7799
parent4fcbea600b8bb6bc8eb1715a3877ec64d2d3d12c (diff)
parentf7ec9f65d471caa05d6abb8691925a25bb1f9e85 (diff)
downloaddrm_hwcomposer-2b406a48da46b3d0a7716522ee32dcd938fdaa99.tar.gz
Snap for 5735642 from f7ec9f65d471caa05d6abb8691925a25bb1f9e85 to sdk-releaseplatform-tools-29.0.4platform-tools-29.0.3platform-tools-29.0.2
Change-Id: I3d73dd2b38fb7122e8b8dd3894d99548c6fd954d
-rw-r--r--Android.bp59
-rw-r--r--OWNERS3
-rw-r--r--compositor/drmdisplaycomposition.cpp (renamed from drmdisplaycomposition.cpp)0
-rw-r--r--compositor/drmdisplaycompositor.cpp (renamed from drmdisplaycompositor.cpp)0
-rw-r--r--drm/drmconnector.cpp (renamed from drmconnector.cpp)3
-rw-r--r--drm/drmcrtc.cpp (renamed from drmcrtc.cpp)0
-rw-r--r--drm/drmdevice.cpp (renamed from drmdevice.cpp)0
-rw-r--r--drm/drmencoder.cpp (renamed from drmencoder.cpp)0
-rw-r--r--drm/drmeventlistener.cpp (renamed from drmeventlistener.cpp)0
-rw-r--r--drm/drmmode.cpp (renamed from drmmode.cpp)4
-rw-r--r--drm/drmplane.cpp (renamed from drmplane.cpp)0
-rw-r--r--drm/drmproperty.cpp (renamed from drmproperty.cpp)0
-rw-r--r--drm/resourcemanager.cpp (renamed from resourcemanager.cpp)0
-rw-r--r--drm/vsyncworker.cpp (renamed from vsyncworker.cpp)0
-rw-r--r--drmhwctwo.cpp63
-rw-r--r--include/autofd.h (renamed from autofd.h)0
-rw-r--r--include/autolock.h (renamed from autolock.h)0
-rw-r--r--include/drmconnector.h (renamed from drmconnector.h)0
-rw-r--r--include/drmcrtc.h (renamed from drmcrtc.h)0
-rw-r--r--include/drmdevice.h (renamed from drmdevice.h)0
-rw-r--r--include/drmdisplaycomposition.h (renamed from drmdisplaycomposition.h)0
-rw-r--r--include/drmdisplaycompositor.h (renamed from drmdisplaycompositor.h)0
-rw-r--r--include/drmencoder.h (renamed from drmencoder.h)0
-rw-r--r--include/drmeventlistener.h (renamed from drmeventlistener.h)0
-rw-r--r--include/drmframebuffer.h (renamed from drmframebuffer.h)0
-rw-r--r--include/drmhwcgralloc.h (renamed from drmhwcgralloc.h)0
-rw-r--r--include/drmhwcomposer.h (renamed from drmhwcomposer.h)0
-rw-r--r--include/drmhwctwo.h (renamed from drmhwctwo.h)0
-rw-r--r--include/drmmode.h (renamed from drmmode.h)0
-rw-r--r--include/drmplane.h (renamed from drmplane.h)0
-rw-r--r--include/drmproperty.h (renamed from drmproperty.h)0
-rw-r--r--include/platform.h (renamed from platform.h)0
-rw-r--r--include/resourcemanager.h (renamed from resourcemanager.h)0
-rw-r--r--include/vsyncworker.h (renamed from vsyncworker.h)0
-rw-r--r--include/worker.h (renamed from worker.h)0
-rw-r--r--platform/platform.cpp (renamed from platform.cpp)0
-rw-r--r--platform/platformdrmgeneric.cpp (renamed from platformdrmgeneric.cpp)18
-rw-r--r--platform/platformdrmgeneric.h (renamed from platformdrmgeneric.h)4
-rw-r--r--platform/platformhisi.cpp (renamed from platformhisi.cpp)22
-rw-r--r--platform/platformhisi.h (renamed from platformhisi.h)10
-rw-r--r--platform/platformmeson.cpp140
-rw-r--r--platform/platformmeson.h42
-rw-r--r--platform/platformminigbm.cpp (renamed from platformminigbm.cpp)22
-rw-r--r--platform/platformminigbm.h (renamed from platformminigbm.h)11
-rw-r--r--tests/Android.bp2
-rw-r--r--utils/autolock.cpp (renamed from autolock.cpp)0
-rw-r--r--utils/hwcutils.cpp (renamed from hwcutils.cpp)0
-rw-r--r--utils/worker.cpp (renamed from worker.cpp)0
48 files changed, 310 insertions, 93 deletions
diff --git a/Android.bp b/Android.bp
index 2af4548..5681cb7 100644
--- a/Android.bp
+++ b/Android.bp
@@ -18,7 +18,9 @@
cc_library_static {
name: "libdrmhwc_utils",
- srcs: ["worker.cpp"],
+ srcs: ["utils/worker.cpp"],
+
+ include_dirs: ["external/drm_hwcomposer/include"],
cflags: [
"-Wall",
@@ -45,6 +47,8 @@ cc_defaults {
"libutils",
],
+ include_dirs: ["external/drm_hwcomposer/include"],
+
static_libs: ["libdrmhwc_utils"],
cflags: [
@@ -64,22 +68,26 @@ cc_library_static {
name: "drm_hwcomposer",
defaults: ["hwcomposer.drm_defaults"],
srcs: [
- "autolock.cpp",
- "resourcemanager.cpp",
- "drmdevice.cpp",
- "drmconnector.cpp",
- "drmcrtc.cpp",
- "drmdisplaycomposition.cpp",
- "drmdisplaycompositor.cpp",
- "drmencoder.cpp",
- "drmeventlistener.cpp",
"drmhwctwo.cpp",
- "drmmode.cpp",
- "drmplane.cpp",
- "drmproperty.cpp",
- "hwcutils.cpp",
- "platform.cpp",
- "vsyncworker.cpp",
+
+ "compositor/drmdisplaycomposition.cpp",
+ "compositor/drmdisplaycompositor.cpp",
+
+ "drm/drmconnector.cpp",
+ "drm/drmcrtc.cpp",
+ "drm/drmdevice.cpp",
+ "drm/drmencoder.cpp",
+ "drm/drmeventlistener.cpp",
+ "drm/drmmode.cpp",
+ "drm/drmplane.cpp",
+ "drm/drmproperty.cpp",
+ "drm/resourcemanager.cpp",
+ "drm/vsyncworker.cpp",
+
+ "platform/platform.cpp",
+
+ "utils/autolock.cpp",
+ "utils/hwcutils.cpp",
],
}
@@ -87,7 +95,7 @@ cc_library_shared {
name: "hwcomposer.drm",
defaults: ["hwcomposer.drm_defaults"],
whole_static_libs: ["drm_hwcomposer"],
- srcs: ["platformdrmgeneric.cpp"],
+ srcs: ["platform/platformdrmgeneric.cpp"],
cppflags: ["-DUSE_DRM_GENERIC_IMPORTER"],
}
@@ -96,8 +104,8 @@ cc_library_shared {
defaults: ["hwcomposer.drm_defaults"],
whole_static_libs: ["drm_hwcomposer"],
srcs: [
- "platformdrmgeneric.cpp",
- "platformminigbm.cpp",
+ "platform/platformdrmgeneric.cpp",
+ "platform/platformminigbm.cpp",
],
include_dirs: ["external/minigbm/cros_gralloc"],
}
@@ -106,7 +114,16 @@ cc_library_shared {
filegroup {
name: "drm_hwcomposer_platformhisi",
srcs: [
- "platformdrmgeneric.cpp",
- "platformhisi.cpp",
+ "platform/platformdrmgeneric.cpp",
+ "platform/platformhisi.cpp",
+ ],
+}
+
+// Used by hwcomposer.drm_meson
+filegroup {
+ name: "drm_hwcomposer_platformmeson",
+ srcs: [
+ "platform/platformdrmgeneric.cpp",
+ "platform/platformmeson.cpp",
],
}
diff --git a/OWNERS b/OWNERS
index 0a442be..9991fd8 100644
--- a/OWNERS
+++ b/OWNERS
@@ -1,4 +1,5 @@
-astrachan@google.com
+adelva@google.com
+john.stultz@linaro.org
marcheu@google.com
marissaw@google.com
seanpaul@google.com
diff --git a/drmdisplaycomposition.cpp b/compositor/drmdisplaycomposition.cpp
index b710fe1..b710fe1 100644
--- a/drmdisplaycomposition.cpp
+++ b/compositor/drmdisplaycomposition.cpp
diff --git a/drmdisplaycompositor.cpp b/compositor/drmdisplaycompositor.cpp
index e6f6922..e6f6922 100644
--- a/drmdisplaycompositor.cpp
+++ b/compositor/drmdisplaycompositor.cpp
diff --git a/drmconnector.cpp b/drm/drmconnector.cpp
index ead9312..543827d 100644
--- a/drmconnector.cpp
+++ b/drm/drmconnector.cpp
@@ -89,7 +89,8 @@ void DrmConnector::set_display(int display) {
bool DrmConnector::internal() const {
return type_ == DRM_MODE_CONNECTOR_LVDS || type_ == DRM_MODE_CONNECTOR_eDP ||
- type_ == DRM_MODE_CONNECTOR_DSI || type_ == DRM_MODE_CONNECTOR_VIRTUAL;
+ type_ == DRM_MODE_CONNECTOR_DSI ||
+ type_ == DRM_MODE_CONNECTOR_VIRTUAL || type_ == DRM_MODE_CONNECTOR_DPI;
}
bool DrmConnector::external() const {
diff --git a/drmcrtc.cpp b/drm/drmcrtc.cpp
index b627291..b627291 100644
--- a/drmcrtc.cpp
+++ b/drm/drmcrtc.cpp
diff --git a/drmdevice.cpp b/drm/drmdevice.cpp
index 2007fdd..2007fdd 100644
--- a/drmdevice.cpp
+++ b/drm/drmdevice.cpp
diff --git a/drmencoder.cpp b/drm/drmencoder.cpp
index c36fca1..c36fca1 100644
--- a/drmencoder.cpp
+++ b/drm/drmencoder.cpp
diff --git a/drmeventlistener.cpp b/drm/drmeventlistener.cpp
index 8f655a7..8f655a7 100644
--- a/drmeventlistener.cpp
+++ b/drm/drmeventlistener.cpp
diff --git a/drmmode.cpp b/drm/drmmode.cpp
index 5f2e7c2..c3ab385 100644
--- a/drmmode.cpp
+++ b/drm/drmmode.cpp
@@ -122,8 +122,8 @@ uint32_t DrmMode::v_scan() const {
}
float DrmMode::v_refresh() const {
- return v_refresh_ ? v_refresh_ * 1.0f
- : clock_ / (float)(v_total_ * h_total_) * 1000.0f;
+ // Always recalculate refresh to report correct float rate
+ return clock_ / (float)(v_total_ * h_total_) * 1000.0f;
}
uint32_t DrmMode::flags() const {
diff --git a/drmplane.cpp b/drm/drmplane.cpp
index 6f1bf9b..6f1bf9b 100644
--- a/drmplane.cpp
+++ b/drm/drmplane.cpp
diff --git a/drmproperty.cpp b/drm/drmproperty.cpp
index 3aeed13..3aeed13 100644
--- a/drmproperty.cpp
+++ b/drm/drmproperty.cpp
diff --git a/resourcemanager.cpp b/drm/resourcemanager.cpp
index 6e23561..6e23561 100644
--- a/resourcemanager.cpp
+++ b/drm/resourcemanager.cpp
diff --git a/vsyncworker.cpp b/drm/vsyncworker.cpp
index d022887..d022887 100644
--- a/vsyncworker.cpp
+++ b/drm/vsyncworker.cpp
diff --git a/drmhwctwo.cpp b/drmhwctwo.cpp
index 3123b29..9268cdc 100644
--- a/drmhwctwo.cpp
+++ b/drmhwctwo.cpp
@@ -399,14 +399,73 @@ HWC2::Error DrmHwcTwo::HwcDisplay::GetDisplayConfigs(uint32_t *num_configs,
}
}
- auto num_modes = static_cast<uint32_t>(connector_->modes().size());
+ // Since the upper layers only look at vactive/hactive/refresh, height and
+ // width, it doesn't differentiate interlaced from progressive and other
+ // similar modes. Depending on the order of modes we return to SF, it could
+ // end up choosing a suboptimal configuration and dropping the preferred
+ // mode. To workaround this, don't offer interlaced modes to SF if there is
+ // at least one non-interlaced alternative and only offer a single WxH@R
+ // mode with at least the prefered mode from in DrmConnector::UpdateModes()
+
+ // TODO: Remove the following block of code until AOSP handles all modes
+ std::vector<DrmMode> sel_modes;
+
+ // Add the preferred mode first to be sure it's not dropped
+ auto mode = std::find_if(connector_->modes().begin(),
+ connector_->modes().end(), [&](DrmMode const &m) {
+ return m.id() ==
+ connector_->get_preferred_mode_id();
+ });
+ if (mode != connector_->modes().end())
+ sel_modes.push_back(*mode);
+
+ // Add the active mode if different from preferred mode
+ if (connector_->active_mode().id() != connector_->get_preferred_mode_id())
+ sel_modes.push_back(connector_->active_mode());
+
+ // Cycle over the modes and filter out "similar" modes, keeping only the
+ // first ones in the order given by DRM (from CEA ids and timings order)
+ for (const DrmMode &mode : connector_->modes()) {
+ // TODO: Remove this when 3D Attributes are in AOSP
+ if (mode.flags() & DRM_MODE_FLAG_3D_MASK)
+ continue;
+
+ // TODO: Remove this when the Interlaced attribute is in AOSP
+ if (mode.flags() & DRM_MODE_FLAG_INTERLACE) {
+ auto m = std::find_if(connector_->modes().begin(),
+ connector_->modes().end(),
+ [&mode](DrmMode const &m) {
+ return !(m.flags() & DRM_MODE_FLAG_INTERLACE) &&
+ m.h_display() == mode.h_display() &&
+ m.v_display() == mode.v_display();
+ });
+ if (m == connector_->modes().end())
+ sel_modes.push_back(mode);
+
+ continue;
+ }
+
+ // Search for a similar WxH@R mode in the filtered list and drop it if
+ // another mode with the same WxH@R has already been selected
+ // TODO: Remove this when AOSP handles duplicates modes
+ auto m = std::find_if(sel_modes.begin(), sel_modes.end(),
+ [&mode](DrmMode const &m) {
+ return m.h_display() == mode.h_display() &&
+ m.v_display() == mode.v_display() &&
+ m.v_refresh() == mode.v_refresh();
+ });
+ if (m == sel_modes.end())
+ sel_modes.push_back(mode);
+ }
+
+ auto num_modes = static_cast<uint32_t>(sel_modes.size());
if (!configs) {
*num_configs = num_modes;
return HWC2::Error::None;
}
uint32_t idx = 0;
- for (const DrmMode &mode : connector_->modes()) {
+ for (const DrmMode &mode : sel_modes) {
if (idx >= *num_configs)
break;
configs[idx++] = mode.id();
diff --git a/autofd.h b/include/autofd.h
index 9af6c22..9af6c22 100644
--- a/autofd.h
+++ b/include/autofd.h
diff --git a/autolock.h b/include/autolock.h
index 006406a..006406a 100644
--- a/autolock.h
+++ b/include/autolock.h
diff --git a/drmconnector.h b/include/drmconnector.h
index 9c526c8..9c526c8 100644
--- a/drmconnector.h
+++ b/include/drmconnector.h
diff --git a/drmcrtc.h b/include/drmcrtc.h
index 3075f9b..3075f9b 100644
--- a/drmcrtc.h
+++ b/include/drmcrtc.h
diff --git a/drmdevice.h b/include/drmdevice.h
index 91dd38b..91dd38b 100644
--- a/drmdevice.h
+++ b/include/drmdevice.h
diff --git a/drmdisplaycomposition.h b/include/drmdisplaycomposition.h
index 2a5b1a4..2a5b1a4 100644
--- a/drmdisplaycomposition.h
+++ b/include/drmdisplaycomposition.h
diff --git a/drmdisplaycompositor.h b/include/drmdisplaycompositor.h
index 1005598..1005598 100644
--- a/drmdisplaycompositor.h
+++ b/include/drmdisplaycompositor.h
diff --git a/drmencoder.h b/include/drmencoder.h
index 8a7f682..8a7f682 100644
--- a/drmencoder.h
+++ b/include/drmencoder.h
diff --git a/drmeventlistener.h b/include/drmeventlistener.h
index 95672ee..95672ee 100644
--- a/drmeventlistener.h
+++ b/include/drmeventlistener.h
diff --git a/drmframebuffer.h b/include/drmframebuffer.h
index 9032d3a..9032d3a 100644
--- a/drmframebuffer.h
+++ b/include/drmframebuffer.h
diff --git a/drmhwcgralloc.h b/include/drmhwcgralloc.h
index 65a4007..65a4007 100644
--- a/drmhwcgralloc.h
+++ b/include/drmhwcgralloc.h
diff --git a/drmhwcomposer.h b/include/drmhwcomposer.h
index 2af7e6e..2af7e6e 100644
--- a/drmhwcomposer.h
+++ b/include/drmhwcomposer.h
diff --git a/drmhwctwo.h b/include/drmhwctwo.h
index a71d7cc..a71d7cc 100644
--- a/drmhwctwo.h
+++ b/include/drmhwctwo.h
diff --git a/drmmode.h b/include/drmmode.h
index 4cc06b1..4cc06b1 100644
--- a/drmmode.h
+++ b/include/drmmode.h
diff --git a/drmplane.h b/include/drmplane.h
index 43e0e8a..43e0e8a 100644
--- a/drmplane.h
+++ b/include/drmplane.h
diff --git a/drmproperty.h b/include/drmproperty.h
index 2d92ca1..2d92ca1 100644
--- a/drmproperty.h
+++ b/include/drmproperty.h
diff --git a/platform.h b/include/platform.h
index 6fdece2..6fdece2 100644
--- a/platform.h
+++ b/include/platform.h
diff --git a/resourcemanager.h b/include/resourcemanager.h
index f10af45..f10af45 100644
--- a/resourcemanager.h
+++ b/include/resourcemanager.h
diff --git a/vsyncworker.h b/include/vsyncworker.h
index b2bca9d..b2bca9d 100644
--- a/vsyncworker.h
+++ b/include/vsyncworker.h
diff --git a/worker.h b/include/worker.h
index 7909038..7909038 100644
--- a/worker.h
+++ b/include/worker.h
diff --git a/platform.cpp b/platform/platform.cpp
index b7a47c7..b7a47c7 100644
--- a/platform.cpp
+++ b/platform/platform.cpp
diff --git a/platformdrmgeneric.cpp b/platform/platformdrmgeneric.cpp
index 503c04a..9ac601f 100644
--- a/platformdrmgeneric.cpp
+++ b/platform/platformdrmgeneric.cpp
@@ -24,6 +24,7 @@
#include <xf86drm.h>
#include <xf86drmMode.h>
+#include <cutils/properties.h>
#include <gralloc_handle.h>
#include <hardware/gralloc.h>
#include <log/log.h>
@@ -47,7 +48,8 @@ Importer *Importer::CreateInstance(DrmDevice *drm) {
}
#endif
-DrmGenericImporter::DrmGenericImporter(DrmDevice *drm) : drm_(drm) {
+DrmGenericImporter::DrmGenericImporter(DrmDevice *drm)
+ : drm_(drm), exclude_non_hwfb_(false) {
}
DrmGenericImporter::~DrmGenericImporter() {
@@ -60,6 +62,14 @@ int DrmGenericImporter::Init() {
ALOGE("Failed to open gralloc module");
return ret;
}
+
+ ALOGI("Using %s gralloc module: %s\n", gralloc_->common.name,
+ gralloc_->common.author);
+
+ char exclude_non_hwfb_prop[PROPERTY_VALUE_MAX];
+ property_get("hwc.drm.exclude_non_hwfb_imports", exclude_non_hwfb_prop, "0");
+ exclude_non_hwfb_ = static_cast<bool>(strncmp(exclude_non_hwfb_prop, "0", 1));
+
return 0;
}
@@ -164,6 +174,12 @@ int DrmGenericImporter::ReleaseBuffer(hwc_drm_bo_t *bo) {
bool DrmGenericImporter::CanImportBuffer(buffer_handle_t handle) {
if (handle == NULL)
return false;
+
+ if (exclude_non_hwfb_) {
+ gralloc_handle_t *hnd = gralloc_handle(handle);
+ return hnd->usage & GRALLOC_USAGE_HW_FB;
+ }
+
return true;
}
diff --git a/platformdrmgeneric.h b/platform/platformdrmgeneric.h
index 233ba55..88bff5f 100644
--- a/platformdrmgeneric.h
+++ b/platform/platformdrmgeneric.h
@@ -38,10 +38,12 @@ class DrmGenericImporter : public Importer {
uint32_t ConvertHalFormatToDrm(uint32_t hal_format);
uint32_t DrmFormatToBitsPerPixel(uint32_t drm_format);
- private:
+ protected:
DrmDevice *drm_;
+ private:
const gralloc_module_t *gralloc_;
+ bool exclude_non_hwfb_;
};
} // namespace android
diff --git a/platformhisi.cpp b/platform/platformhisi.cpp
index e022010..64b410b 100644
--- a/platformhisi.cpp
+++ b/platform/platformhisi.cpp
@@ -48,28 +48,6 @@ Importer *Importer::CreateInstance(DrmDevice *drm) {
return importer;
}
-HisiImporter::HisiImporter(DrmDevice *drm)
- : DrmGenericImporter(drm), drm_(drm) {
-}
-
-HisiImporter::~HisiImporter() {
-}
-
-int HisiImporter::Init() {
- int ret = hw_get_module(GRALLOC_HARDWARE_MODULE_ID,
- (const hw_module_t **)&gralloc_);
- if (ret) {
- ALOGE("Failed to open gralloc module %d", ret);
- return ret;
- }
-
- if (strcasecmp(gralloc_->common.author, "ARM Ltd."))
- ALOGW("Using non-ARM gralloc module: %s/%s\n", gralloc_->common.name,
- gralloc_->common.author);
-
- return 0;
-}
-
#if defined(MALI_GRALLOC_INTFMT_AFBC_BASIC) && \
defined(AFBC_FORMAT_MOD_BLOCK_SIZE_16x16)
uint64_t HisiImporter::ConvertGrallocFormatToDrmModifiers(uint64_t flags,
diff --git a/platformhisi.h b/platform/platformhisi.h
index 14a58b9..9dfea89 100644
--- a/platformhisi.h
+++ b/platform/platformhisi.h
@@ -29,23 +29,15 @@ namespace android {
class HisiImporter : public DrmGenericImporter {
public:
- HisiImporter(DrmDevice *drm);
- ~HisiImporter() override;
-
- int Init();
+ using DrmGenericImporter::DrmGenericImporter;
int ImportBuffer(buffer_handle_t handle, hwc_drm_bo_t *bo) override;
-
bool CanImportBuffer(buffer_handle_t handle) override;
private:
uint64_t ConvertGrallocFormatToDrmModifiers(uint64_t flags, bool is_rgb);
bool IsDrmFormatRgb(uint32_t drm_format);
-
- DrmDevice *drm_;
-
- const gralloc_module_t *gralloc_;
};
} // namespace android
diff --git a/platform/platformmeson.cpp b/platform/platformmeson.cpp
new file mode 100644
index 0000000..58ec5c0
--- /dev/null
+++ b/platform/platformmeson.cpp
@@ -0,0 +1,140 @@
+/*
+ * Copyright (C) 2019 The Android Open Source Project
+ *
+ * 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.
+ */
+
+#define LOG_TAG "hwc-platform-meson"
+
+#include "platformmeson.h"
+#include "drmdevice.h"
+#include "platform.h"
+
+#include <drm/drm_fourcc.h>
+#include <stdatomic.h>
+#include <xf86drm.h>
+#include <xf86drmMode.h>
+#include <cinttypes>
+
+#include <hardware/gralloc.h>
+#include <log/log.h>
+#include "gralloc_priv.h"
+
+namespace android {
+
+Importer *Importer::CreateInstance(DrmDevice *drm) {
+ MesonImporter *importer = new MesonImporter(drm);
+ if (!importer)
+ return NULL;
+
+ int ret = importer->Init();
+ if (ret) {
+ ALOGE("Failed to initialize the meson importer %d", ret);
+ delete importer;
+ return NULL;
+ }
+ return importer;
+}
+
+#if defined(MALI_GRALLOC_INTFMT_AFBC_BASIC) && \
+ defined(AFBC_FORMAT_MOD_BLOCK_SIZE_16x16)
+uint64_t MesonImporter::ConvertGrallocFormatToDrmModifiers(uint64_t flags) {
+ uint64_t features = 0UL;
+
+ if (flags & MALI_GRALLOC_INTFMT_AFBC_BASIC)
+ features |= AFBC_FORMAT_MOD_BLOCK_SIZE_16x16;
+
+ if (flags & MALI_GRALLOC_INTFMT_AFBC_SPLITBLK)
+ features |= (AFBC_FORMAT_MOD_SPLIT | AFBC_FORMAT_MOD_SPARSE);
+
+ if (flags & MALI_GRALLOC_INTFMT_AFBC_WIDEBLK)
+ features |= AFBC_FORMAT_MOD_BLOCK_SIZE_32x8;
+
+ if (flags & MALI_GRALLOC_INTFMT_AFBC_TILED_HEADERS)
+ features |= AFBC_FORMAT_MOD_TILED;
+
+ if (features)
+ return DRM_FORMAT_MOD_ARM_AFBC(features | AFBC_FORMAT_MOD_YTR);
+
+ return 0;
+}
+#else
+uint64_t MesonImporter::ConvertGrallocFormatToDrmModifiers(
+ uint64_t /* flags */) {
+ return 0;
+}
+#endif
+
+int MesonImporter::ImportBuffer(buffer_handle_t handle, hwc_drm_bo_t *bo) {
+ uint64_t modifiers[4] = {0};
+
+ memset(bo, 0, sizeof(hwc_drm_bo_t));
+
+ private_handle_t const *hnd = reinterpret_cast<private_handle_t const *>(
+ handle);
+ if (!hnd)
+ return -EINVAL;
+
+ // We can't import these types of buffers.
+ // These buffers should have been filtered out with CanImportBuffer()
+ if (!(hnd->usage & GRALLOC_USAGE_HW_FB))
+ return -EINVAL;
+
+ uint32_t gem_handle;
+ int ret = drmPrimeFDToHandle(drm_->fd(), hnd->share_fd, &gem_handle);
+ if (ret) {
+ ALOGE("failed to import prime fd %d ret=%d", hnd->share_fd, ret);
+ return ret;
+ }
+
+ int32_t fmt = ConvertHalFormatToDrm(hnd->req_format);
+ if (fmt < 0)
+ return fmt;
+
+ modifiers[0] = ConvertGrallocFormatToDrmModifiers(hnd->internal_format);
+
+ bo->width = hnd->width;
+ bo->height = hnd->height;
+ bo->hal_format = hnd->req_format;
+ bo->format = fmt;
+ bo->usage = hnd->usage;
+ bo->pixel_stride = hnd->stride;
+ bo->pitches[0] = hnd->byte_stride;
+ bo->gem_handles[0] = gem_handle;
+ bo->offsets[0] = 0;
+
+ ret = drmModeAddFB2WithModifiers(drm_->fd(), bo->width, bo->height,
+ bo->format, bo->gem_handles, bo->pitches,
+ bo->offsets, modifiers, &bo->fb_id,
+ modifiers[0] ? DRM_MODE_FB_MODIFIERS : 0);
+
+ if (ret) {
+ ALOGE("could not create drm fb %d", ret);
+ return ret;
+ }
+
+ return ret;
+}
+
+bool MesonImporter::CanImportBuffer(buffer_handle_t handle) {
+ private_handle_t const *hnd = reinterpret_cast<private_handle_t const *>(
+ handle);
+ return hnd && (hnd->usage & GRALLOC_USAGE_HW_FB);
+}
+
+std::unique_ptr<Planner> Planner::CreateInstance(DrmDevice *) {
+ std::unique_ptr<Planner> planner(new Planner);
+ planner->AddStage<PlanStageGreedy>();
+ return planner;
+}
+} // namespace android
diff --git a/platform/platformmeson.h b/platform/platformmeson.h
new file mode 100644
index 0000000..7be7702
--- /dev/null
+++ b/platform/platformmeson.h
@@ -0,0 +1,42 @@
+/*
+ * Copyright (C) 2019 The Android Open Source Project
+ *
+ * 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.
+ */
+
+#ifndef ANDROID_PLATFORM_HISI_H_
+#define ANDROID_PLATFORM_HISI_H_
+
+#include "drmdevice.h"
+#include "platform.h"
+#include "platformdrmgeneric.h"
+
+#include <stdatomic.h>
+
+#include <hardware/gralloc.h>
+
+namespace android {
+
+class MesonImporter : public DrmGenericImporter {
+ public:
+ using DrmGenericImporter::DrmGenericImporter;
+
+ int ImportBuffer(buffer_handle_t handle, hwc_drm_bo_t *bo) override;
+ bool CanImportBuffer(buffer_handle_t handle) override;
+
+ private:
+ uint64_t ConvertGrallocFormatToDrmModifiers(uint64_t flags);
+};
+} // namespace android
+
+#endif
diff --git a/platformminigbm.cpp b/platform/platformminigbm.cpp
index dce1d11..ad0a373 100644
--- a/platformminigbm.cpp
+++ b/platform/platformminigbm.cpp
@@ -45,28 +45,6 @@ Importer *Importer::CreateInstance(DrmDevice *drm) {
return importer;
}
-DrmMinigbmImporter::DrmMinigbmImporter(DrmDevice *drm)
- : DrmGenericImporter(drm), drm_(drm) {
-}
-
-DrmMinigbmImporter::~DrmMinigbmImporter() {
-}
-
-int DrmMinigbmImporter::Init() {
- int ret = hw_get_module(GRALLOC_HARDWARE_MODULE_ID,
- (const hw_module_t **)&gralloc_);
- if (ret) {
- ALOGE("Failed to open gralloc module %d", ret);
- return ret;
- }
-
- if (strcasecmp(gralloc_->common.author, "Chrome OS"))
- ALOGW("Using non-minigbm gralloc module: %s/%s\n", gralloc_->common.name,
- gralloc_->common.author);
-
- return 0;
-}
-
int DrmMinigbmImporter::ImportBuffer(buffer_handle_t handle, hwc_drm_bo_t *bo) {
cros_gralloc_handle *gr_handle = (cros_gralloc_handle *)handle;
if (!gr_handle)
diff --git a/platformminigbm.h b/platform/platformminigbm.h
index 25f8404..ff69f14 100644
--- a/platformminigbm.h
+++ b/platform/platformminigbm.h
@@ -27,17 +27,8 @@ namespace android {
class DrmMinigbmImporter : public DrmGenericImporter {
public:
- DrmMinigbmImporter(DrmDevice *drm);
- ~DrmMinigbmImporter() override;
-
- int Init();
-
+ using DrmGenericImporter::DrmGenericImporter;
int ImportBuffer(buffer_handle_t handle, hwc_drm_bo_t *bo) override;
-
- private:
- DrmDevice *drm_;
-
- const gralloc_module_t *gralloc_;
};
} // namespace android
diff --git a/tests/Android.bp b/tests/Android.bp
index 058faa0..7e550ff 100644
--- a/tests/Android.bp
+++ b/tests/Android.bp
@@ -9,5 +9,5 @@ cc_test {
header_libs: ["libhardware_headers"],
static_libs: ["libdrmhwc_utils"],
shared_libs: ["hwcomposer.drm"],
- include_dirs: ["external/drm_hwcomposer"],
+ include_dirs: ["external/drm_hwcomposer/include"],
}
diff --git a/autolock.cpp b/utils/autolock.cpp
index 4e9552a..4e9552a 100644
--- a/autolock.cpp
+++ b/utils/autolock.cpp
diff --git a/hwcutils.cpp b/utils/hwcutils.cpp
index 87e3c42..87e3c42 100644
--- a/hwcutils.cpp
+++ b/utils/hwcutils.cpp
diff --git a/worker.cpp b/utils/worker.cpp
index 0dceb16..0dceb16 100644
--- a/worker.cpp
+++ b/utils/worker.cpp