aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorandroid-build-team Robot <android-build-team-robot@google.com>2020-04-28 20:22:47 +0000
committerandroid-build-team Robot <android-build-team-robot@google.com>2020-04-28 20:22:47 +0000
commite78adfd50b1435848511978bddedf19c2725bbb0 (patch)
tree73261c611fa5ffbb9b4ed0db8878606e12ae7058
parent803aa2beba0fb823eec2e8a8576c0ac7ce5e2ec0 (diff)
parent482ad9a71e6667bc291a7900bf174a92cfab775d (diff)
downloaddrm_hwcomposer-android10-mainline-tzdata-release.tar.gz
Change-Id: I09fd1bc72f2c6b45b5f82cd1dd9e84416359c9c2
-rw-r--r--Android.bp59
-rw-r--r--OWNERS3
-rw-r--r--autofd.h (renamed from include/autofd.h)0
-rw-r--r--autolock.cpp (renamed from utils/autolock.cpp)0
-rw-r--r--autolock.h (renamed from include/autolock.h)0
-rw-r--r--drmconnector.cpp (renamed from drm/drmconnector.cpp)9
-rw-r--r--drmconnector.h (renamed from include/drmconnector.h)0
-rw-r--r--drmcrtc.cpp (renamed from drm/drmcrtc.cpp)0
-rw-r--r--drmcrtc.h (renamed from include/drmcrtc.h)0
-rw-r--r--drmdevice.cpp (renamed from drm/drmdevice.cpp)0
-rw-r--r--drmdevice.h (renamed from include/drmdevice.h)0
-rw-r--r--drmdisplaycomposition.cpp (renamed from compositor/drmdisplaycomposition.cpp)0
-rw-r--r--drmdisplaycomposition.h (renamed from include/drmdisplaycomposition.h)0
-rw-r--r--drmdisplaycompositor.cpp (renamed from compositor/drmdisplaycompositor.cpp)0
-rw-r--r--drmdisplaycompositor.h (renamed from include/drmdisplaycompositor.h)0
-rw-r--r--drmencoder.cpp (renamed from drm/drmencoder.cpp)0
-rw-r--r--drmencoder.h (renamed from include/drmencoder.h)0
-rw-r--r--drmeventlistener.cpp (renamed from drm/drmeventlistener.cpp)0
-rw-r--r--drmeventlistener.h (renamed from include/drmeventlistener.h)0
-rw-r--r--drmframebuffer.h (renamed from include/drmframebuffer.h)0
-rw-r--r--drmhwcgralloc.h (renamed from include/drmhwcgralloc.h)0
-rw-r--r--drmhwcomposer.h (renamed from include/drmhwcomposer.h)0
-rw-r--r--drmhwctwo.cpp73
-rw-r--r--drmhwctwo.h (renamed from include/drmhwctwo.h)36
-rw-r--r--drmmode.cpp (renamed from drm/drmmode.cpp)4
-rw-r--r--drmmode.h (renamed from include/drmmode.h)0
-rw-r--r--drmplane.cpp (renamed from drm/drmplane.cpp)0
-rw-r--r--drmplane.h (renamed from include/drmplane.h)0
-rw-r--r--drmproperty.cpp (renamed from drm/drmproperty.cpp)0
-rw-r--r--drmproperty.h (renamed from include/drmproperty.h)0
-rw-r--r--hwcutils.cpp (renamed from utils/hwcutils.cpp)0
-rw-r--r--platform.cpp (renamed from platform/platform.cpp)0
-rw-r--r--platform.h (renamed from include/platform.h)0
-rw-r--r--platform/platformmeson.cpp141
-rw-r--r--platform/platformmeson.h42
-rw-r--r--platformdrmgeneric.cpp (renamed from platform/platformdrmgeneric.cpp)18
-rw-r--r--platformdrmgeneric.h (renamed from platform/platformdrmgeneric.h)4
-rw-r--r--platformhisi.cpp (renamed from platform/platformhisi.cpp)25
-rw-r--r--platformhisi.h (renamed from platform/platformhisi.h)10
-rw-r--r--platformminigbm.cpp (renamed from platform/platformminigbm.cpp)22
-rw-r--r--platformminigbm.h (renamed from platform/platformminigbm.h)11
-rw-r--r--resourcemanager.cpp (renamed from drm/resourcemanager.cpp)0
-rw-r--r--resourcemanager.h (renamed from include/resourcemanager.h)0
-rw-r--r--tests/Android.bp2
-rw-r--r--vsyncworker.cpp (renamed from drm/vsyncworker.cpp)0
-rw-r--r--vsyncworker.h (renamed from include/vsyncworker.h)0
-rw-r--r--worker.cpp (renamed from utils/worker.cpp)0
-rw-r--r--worker.h (renamed from include/worker.h)0
48 files changed, 107 insertions, 352 deletions
diff --git a/Android.bp b/Android.bp
index 5681cb7..2af4548 100644
--- a/Android.bp
+++ b/Android.bp
@@ -18,9 +18,7 @@
cc_library_static {
name: "libdrmhwc_utils",
- srcs: ["utils/worker.cpp"],
-
- include_dirs: ["external/drm_hwcomposer/include"],
+ srcs: ["worker.cpp"],
cflags: [
"-Wall",
@@ -47,8 +45,6 @@ cc_defaults {
"libutils",
],
- include_dirs: ["external/drm_hwcomposer/include"],
-
static_libs: ["libdrmhwc_utils"],
cflags: [
@@ -68,26 +64,22 @@ 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",
-
- "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",
+ "drmmode.cpp",
+ "drmplane.cpp",
+ "drmproperty.cpp",
+ "hwcutils.cpp",
+ "platform.cpp",
+ "vsyncworker.cpp",
],
}
@@ -95,7 +87,7 @@ cc_library_shared {
name: "hwcomposer.drm",
defaults: ["hwcomposer.drm_defaults"],
whole_static_libs: ["drm_hwcomposer"],
- srcs: ["platform/platformdrmgeneric.cpp"],
+ srcs: ["platformdrmgeneric.cpp"],
cppflags: ["-DUSE_DRM_GENERIC_IMPORTER"],
}
@@ -104,8 +96,8 @@ cc_library_shared {
defaults: ["hwcomposer.drm_defaults"],
whole_static_libs: ["drm_hwcomposer"],
srcs: [
- "platform/platformdrmgeneric.cpp",
- "platform/platformminigbm.cpp",
+ "platformdrmgeneric.cpp",
+ "platformminigbm.cpp",
],
include_dirs: ["external/minigbm/cros_gralloc"],
}
@@ -114,16 +106,7 @@ cc_library_shared {
filegroup {
name: "drm_hwcomposer_platformhisi",
srcs: [
- "platform/platformdrmgeneric.cpp",
- "platform/platformhisi.cpp",
- ],
-}
-
-// Used by hwcomposer.drm_meson
-filegroup {
- name: "drm_hwcomposer_platformmeson",
- srcs: [
- "platform/platformdrmgeneric.cpp",
- "platform/platformmeson.cpp",
+ "platformdrmgeneric.cpp",
+ "platformhisi.cpp",
],
}
diff --git a/OWNERS b/OWNERS
index 9991fd8..0a442be 100644
--- a/OWNERS
+++ b/OWNERS
@@ -1,5 +1,4 @@
-adelva@google.com
-john.stultz@linaro.org
+astrachan@google.com
marcheu@google.com
marissaw@google.com
seanpaul@google.com
diff --git a/include/autofd.h b/autofd.h
index 9af6c22..9af6c22 100644
--- a/include/autofd.h
+++ b/autofd.h
diff --git a/utils/autolock.cpp b/autolock.cpp
index 4e9552a..4e9552a 100644
--- a/utils/autolock.cpp
+++ b/autolock.cpp
diff --git a/include/autolock.h b/autolock.h
index 006406a..006406a 100644
--- a/include/autolock.h
+++ b/autolock.h
diff --git a/drm/drmconnector.cpp b/drmconnector.cpp
index 543827d..f272024 100644
--- a/drm/drmconnector.cpp
+++ b/drmconnector.cpp
@@ -89,8 +89,7 @@ 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_DPI;
+ type_ == DRM_MODE_CONNECTOR_DSI || type_ == DRM_MODE_CONNECTOR_VIRTUAL;
}
bool DrmConnector::external() const {
@@ -139,15 +138,13 @@ int DrmConnector::UpdateModes() {
m.set_id(drm_->next_mode_id());
new_modes.push_back(m);
}
- // Use only the first DRM_MODE_TYPE_PREFERRED mode found
- if (!preferred_mode_found &&
- (new_modes.back().type() & DRM_MODE_TYPE_PREFERRED)) {
+ if (new_modes.back().type() & DRM_MODE_TYPE_PREFERRED) {
preferred_mode_id_ = new_modes.back().id();
preferred_mode_found = true;
}
}
modes_.swap(new_modes);
- if (!preferred_mode_found && modes_.size() != 0) {
+ if ((!preferred_mode_found) && (modes_.size() != 0)) {
preferred_mode_id_ = modes_[0].id();
}
return 0;
diff --git a/include/drmconnector.h b/drmconnector.h
index 9c526c8..9c526c8 100644
--- a/include/drmconnector.h
+++ b/drmconnector.h
diff --git a/drm/drmcrtc.cpp b/drmcrtc.cpp
index b627291..b627291 100644
--- a/drm/drmcrtc.cpp
+++ b/drmcrtc.cpp
diff --git a/include/drmcrtc.h b/drmcrtc.h
index 3075f9b..3075f9b 100644
--- a/include/drmcrtc.h
+++ b/drmcrtc.h
diff --git a/drm/drmdevice.cpp b/drmdevice.cpp
index 2007fdd..2007fdd 100644
--- a/drm/drmdevice.cpp
+++ b/drmdevice.cpp
diff --git a/include/drmdevice.h b/drmdevice.h
index 91dd38b..91dd38b 100644
--- a/include/drmdevice.h
+++ b/drmdevice.h
diff --git a/compositor/drmdisplaycomposition.cpp b/drmdisplaycomposition.cpp
index b710fe1..b710fe1 100644
--- a/compositor/drmdisplaycomposition.cpp
+++ b/drmdisplaycomposition.cpp
diff --git a/include/drmdisplaycomposition.h b/drmdisplaycomposition.h
index 2a5b1a4..2a5b1a4 100644
--- a/include/drmdisplaycomposition.h
+++ b/drmdisplaycomposition.h
diff --git a/compositor/drmdisplaycompositor.cpp b/drmdisplaycompositor.cpp
index e6f6922..e6f6922 100644
--- a/compositor/drmdisplaycompositor.cpp
+++ b/drmdisplaycompositor.cpp
diff --git a/include/drmdisplaycompositor.h b/drmdisplaycompositor.h
index 1005598..1005598 100644
--- a/include/drmdisplaycompositor.h
+++ b/drmdisplaycompositor.h
diff --git a/drm/drmencoder.cpp b/drmencoder.cpp
index c36fca1..c36fca1 100644
--- a/drm/drmencoder.cpp
+++ b/drmencoder.cpp
diff --git a/include/drmencoder.h b/drmencoder.h
index 8a7f682..8a7f682 100644
--- a/include/drmencoder.h
+++ b/drmencoder.h
diff --git a/drm/drmeventlistener.cpp b/drmeventlistener.cpp
index 8f655a7..8f655a7 100644
--- a/drm/drmeventlistener.cpp
+++ b/drmeventlistener.cpp
diff --git a/include/drmeventlistener.h b/drmeventlistener.h
index 95672ee..95672ee 100644
--- a/include/drmeventlistener.h
+++ b/drmeventlistener.h
diff --git a/include/drmframebuffer.h b/drmframebuffer.h
index 9032d3a..9032d3a 100644
--- a/include/drmframebuffer.h
+++ b/drmframebuffer.h
diff --git a/include/drmhwcgralloc.h b/drmhwcgralloc.h
index 65a4007..65a4007 100644
--- a/include/drmhwcgralloc.h
+++ b/drmhwcgralloc.h
diff --git a/include/drmhwcomposer.h b/drmhwcomposer.h
index 2af7e6e..2af7e6e 100644
--- a/include/drmhwcomposer.h
+++ b/drmhwcomposer.h
diff --git a/drmhwctwo.cpp b/drmhwctwo.cpp
index 814d8f7..3123b29 100644
--- a/drmhwctwo.cpp
+++ b/drmhwctwo.cpp
@@ -273,9 +273,6 @@ HWC2::Error DrmHwcTwo::HwcDisplay::CreateLayer(hwc2_layer_t *layer) {
HWC2::Error DrmHwcTwo::HwcDisplay::DestroyLayer(hwc2_layer_t layer) {
supported(__func__);
- if (!get_layer(layer))
- return HWC2::Error::BadLayer;
-
layers_.erase(layer);
return HWC2::Error::None;
}
@@ -402,73 +399,14 @@ HWC2::Error DrmHwcTwo::HwcDisplay::GetDisplayConfigs(uint32_t *num_configs,
}
}
- // 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());
+ auto num_modes = static_cast<uint32_t>(connector_->modes().size());
if (!configs) {
*num_configs = num_modes;
return HWC2::Error::None;
}
uint32_t idx = 0;
- for (const DrmMode &mode : sel_modes) {
+ for (const DrmMode &mode : connector_->modes()) {
if (idx >= *num_configs)
break;
configs[idx++] = mode.id();
@@ -735,7 +673,7 @@ HWC2::Error DrmHwcTwo::HwcDisplay::SetColorMode(int32_t mode) {
supported(__func__);
if (mode != HAL_COLOR_MODE_NATIVE)
- return HWC2::Error::BadParameter;
+ return HWC2::Error::Unsupported;
color_mode_ = mode;
return HWC2::Error::None;
@@ -766,12 +704,9 @@ HWC2::Error DrmHwcTwo::HwcDisplay::SetPowerMode(int32_t mode_in) {
case HWC2::PowerMode::On:
dpms_value = DRM_MODE_DPMS_ON;
break;
- case HWC2::PowerMode::Doze:
- case HWC2::PowerMode::DozeSuspend:
- return HWC2::Error::Unsupported;
default:
ALOGI("Power mode %d is unsupported\n", mode);
- return HWC2::Error::BadParameter;
+ return HWC2::Error::Unsupported;
};
std::unique_ptr<DrmDisplayComposition> composition = compositor_
diff --git a/include/drmhwctwo.h b/drmhwctwo.h
index 8c75fc0..a71d7cc 100644
--- a/include/drmhwctwo.h
+++ b/drmhwctwo.h
@@ -183,11 +183,8 @@ class DrmHwcTwo : public hwc2_device_t {
HWC2::Error SetPowerMode(int32_t mode);
HWC2::Error SetVsyncEnabled(int32_t enabled);
HWC2::Error ValidateDisplay(uint32_t *num_types, uint32_t *num_requests);
- HwcLayer *get_layer(hwc2_layer_t layer) {
- auto it = layers_.find(layer);
- if (it == layers_.end())
- return nullptr;
- return &it->second;
+ HwcLayer &get_layer(hwc2_layer_t layer) {
+ return layers_.at(layer);
}
private:
@@ -246,36 +243,21 @@ class DrmHwcTwo : public hwc2_device_t {
return static_cast<T>(((*hwc).*func)(std::forward<Args>(args)...));
}
- static HwcDisplay *GetDisplay(DrmHwcTwo *hwc, hwc2_display_t display_handle) {
- auto it = hwc->displays_.find(display_handle);
- if (it == hwc->displays_.end())
- return nullptr;
-
- return &it->second;
- }
-
template <typename HookType, HookType func, typename... Args>
static int32_t DisplayHook(hwc2_device_t *dev, hwc2_display_t display_handle,
Args... args) {
- HwcDisplay *display = GetDisplay(toDrmHwcTwo(dev), display_handle);
- if (!display)
- return static_cast<int32_t>(HWC2::Error::BadDisplay);
-
- return static_cast<int32_t>((display->*func)(std::forward<Args>(args)...));
+ DrmHwcTwo *hwc = toDrmHwcTwo(dev);
+ HwcDisplay &display = hwc->displays_.at(display_handle);
+ return static_cast<int32_t>((display.*func)(std::forward<Args>(args)...));
}
template <typename HookType, HookType func, typename... Args>
static int32_t LayerHook(hwc2_device_t *dev, hwc2_display_t display_handle,
hwc2_layer_t layer_handle, Args... args) {
- HwcDisplay *display = GetDisplay(toDrmHwcTwo(dev), display_handle);
- if (!display)
- return static_cast<int32_t>(HWC2::Error::BadDisplay);
-
- HwcLayer *layer = display->get_layer(layer_handle);
- if (!layer)
- return static_cast<int32_t>(HWC2::Error::BadLayer);
-
- return static_cast<int32_t>((layer->*func)(std::forward<Args>(args)...));
+ DrmHwcTwo *hwc = toDrmHwcTwo(dev);
+ HwcDisplay &display = hwc->displays_.at(display_handle);
+ HwcLayer &layer = display.get_layer(layer_handle);
+ return static_cast<int32_t>((layer.*func)(std::forward<Args>(args)...));
}
// hwc2_device_t hooks
diff --git a/drm/drmmode.cpp b/drmmode.cpp
index c3ab385..5f2e7c2 100644
--- a/drm/drmmode.cpp
+++ b/drmmode.cpp
@@ -122,8 +122,8 @@ uint32_t DrmMode::v_scan() const {
}
float DrmMode::v_refresh() const {
- // Always recalculate refresh to report correct float rate
- return clock_ / (float)(v_total_ * h_total_) * 1000.0f;
+ return v_refresh_ ? v_refresh_ * 1.0f
+ : clock_ / (float)(v_total_ * h_total_) * 1000.0f;
}
uint32_t DrmMode::flags() const {
diff --git a/include/drmmode.h b/drmmode.h
index 4cc06b1..4cc06b1 100644
--- a/include/drmmode.h
+++ b/drmmode.h
diff --git a/drm/drmplane.cpp b/drmplane.cpp
index 6f1bf9b..6f1bf9b 100644
--- a/drm/drmplane.cpp
+++ b/drmplane.cpp
diff --git a/include/drmplane.h b/drmplane.h
index 43e0e8a..43e0e8a 100644
--- a/include/drmplane.h
+++ b/drmplane.h
diff --git a/drm/drmproperty.cpp b/drmproperty.cpp
index 3aeed13..3aeed13 100644
--- a/drm/drmproperty.cpp
+++ b/drmproperty.cpp
diff --git a/include/drmproperty.h b/drmproperty.h
index 2d92ca1..2d92ca1 100644
--- a/include/drmproperty.h
+++ b/drmproperty.h
diff --git a/utils/hwcutils.cpp b/hwcutils.cpp
index 87e3c42..87e3c42 100644
--- a/utils/hwcutils.cpp
+++ b/hwcutils.cpp
diff --git a/platform/platform.cpp b/platform.cpp
index b7a47c7..b7a47c7 100644
--- a/platform/platform.cpp
+++ b/platform.cpp
diff --git a/include/platform.h b/platform.h
index 6fdece2..6fdece2 100644
--- a/include/platform.h
+++ b/platform.h
diff --git a/platform/platformmeson.cpp b/platform/platformmeson.cpp
deleted file mode 100644
index 7bde5cd..0000000
--- a/platform/platformmeson.cpp
+++ /dev/null
@@ -1,141 +0,0 @@
-/*
- * 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) {
- if (flags & MALI_GRALLOC_INTFMT_AFBC_WIDEBLK)
- features |= AFBC_FORMAT_MOD_BLOCK_SIZE_32x8;
- else
- 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_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
deleted file mode 100644
index 7be7702..0000000
--- a/platform/platformmeson.h
+++ /dev/null
@@ -1,42 +0,0 @@
-/*
- * 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/platform/platformdrmgeneric.cpp b/platformdrmgeneric.cpp
index 9ac601f..503c04a 100644
--- a/platform/platformdrmgeneric.cpp
+++ b/platformdrmgeneric.cpp
@@ -24,7 +24,6 @@
#include <xf86drm.h>
#include <xf86drmMode.h>
-#include <cutils/properties.h>
#include <gralloc_handle.h>
#include <hardware/gralloc.h>
#include <log/log.h>
@@ -48,8 +47,7 @@ Importer *Importer::CreateInstance(DrmDevice *drm) {
}
#endif
-DrmGenericImporter::DrmGenericImporter(DrmDevice *drm)
- : drm_(drm), exclude_non_hwfb_(false) {
+DrmGenericImporter::DrmGenericImporter(DrmDevice *drm) : drm_(drm) {
}
DrmGenericImporter::~DrmGenericImporter() {
@@ -62,14 +60,6 @@ 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;
}
@@ -174,12 +164,6 @@ 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/platform/platformdrmgeneric.h b/platformdrmgeneric.h
index 88bff5f..233ba55 100644
--- a/platform/platformdrmgeneric.h
+++ b/platformdrmgeneric.h
@@ -38,12 +38,10 @@ class DrmGenericImporter : public Importer {
uint32_t ConvertHalFormatToDrm(uint32_t hal_format);
uint32_t DrmFormatToBitsPerPixel(uint32_t drm_format);
- protected:
+ private:
DrmDevice *drm_;
- private:
const gralloc_module_t *gralloc_;
- bool exclude_non_hwfb_;
};
} // namespace android
diff --git a/platform/platformhisi.cpp b/platformhisi.cpp
index 64b410b..d4002f1 100644
--- a/platform/platformhisi.cpp
+++ b/platformhisi.cpp
@@ -48,8 +48,29 @@ Importer *Importer::CreateInstance(DrmDevice *drm) {
return importer;
}
-#if defined(MALI_GRALLOC_INTFMT_AFBC_BASIC) && \
- defined(AFBC_FORMAT_MOD_BLOCK_SIZE_16x16)
+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;
+}
+
+#ifdef MALI_GRALLOC_INTFMT_AFBC_BASIC
uint64_t HisiImporter::ConvertGrallocFormatToDrmModifiers(uint64_t flags,
bool is_rgb) {
uint64_t features = 0UL;
diff --git a/platform/platformhisi.h b/platformhisi.h
index 9dfea89..14a58b9 100644
--- a/platform/platformhisi.h
+++ b/platformhisi.h
@@ -29,15 +29,23 @@ namespace android {
class HisiImporter : public DrmGenericImporter {
public:
- using DrmGenericImporter::DrmGenericImporter;
+ HisiImporter(DrmDevice *drm);
+ ~HisiImporter() override;
+
+ int Init();
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/platformminigbm.cpp b/platformminigbm.cpp
index ad0a373..dce1d11 100644
--- a/platform/platformminigbm.cpp
+++ b/platformminigbm.cpp
@@ -45,6 +45,28 @@ 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/platform/platformminigbm.h b/platformminigbm.h
index ff69f14..25f8404 100644
--- a/platform/platformminigbm.h
+++ b/platformminigbm.h
@@ -27,8 +27,17 @@ namespace android {
class DrmMinigbmImporter : public DrmGenericImporter {
public:
- using DrmGenericImporter::DrmGenericImporter;
+ DrmMinigbmImporter(DrmDevice *drm);
+ ~DrmMinigbmImporter() override;
+
+ int Init();
+
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/drm/resourcemanager.cpp b/resourcemanager.cpp
index 6e23561..6e23561 100644
--- a/drm/resourcemanager.cpp
+++ b/resourcemanager.cpp
diff --git a/include/resourcemanager.h b/resourcemanager.h
index f10af45..f10af45 100644
--- a/include/resourcemanager.h
+++ b/resourcemanager.h
diff --git a/tests/Android.bp b/tests/Android.bp
index 7e550ff..058faa0 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"],
+ include_dirs: ["external/drm_hwcomposer"],
}
diff --git a/drm/vsyncworker.cpp b/vsyncworker.cpp
index d022887..d022887 100644
--- a/drm/vsyncworker.cpp
+++ b/vsyncworker.cpp
diff --git a/include/vsyncworker.h b/vsyncworker.h
index b2bca9d..b2bca9d 100644
--- a/include/vsyncworker.h
+++ b/vsyncworker.h
diff --git a/utils/worker.cpp b/worker.cpp
index 0dceb16..0dceb16 100644
--- a/utils/worker.cpp
+++ b/worker.cpp
diff --git a/include/worker.h b/worker.h
index 7909038..7909038 100644
--- a/include/worker.h
+++ b/worker.h