summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Fabien Sanglard <sanglardf@google.com> 2016-11-11 09:40:27 -0800
committer Fabien Sanglard <sanglardf@google.com> 2016-11-16 16:49:57 -0800
commitb7432cc57cd957fb18f68d7976c5829b3a3a7751 (patch)
tree5ec848fc3a328bdf23786ac6d1e30ac4a0e8a23b
parente52d9e2acec131484588a2eb184d1d4b34eebeb3 (diff)
Fix HWC2to1Adapter crashing dragon at startup
Some devices such a dragon(ryu) do not start with a valid active configuration id (e.g: -1). This is unexpected from HWC2to1Adapter and resulted in crash at startup when switching the device from HWC1 to HWC2 with adapter. This patch detects this at startup and put the device in an expected configutation using the first configuration index (0). Test: Tested on ryu Change-Id: If2bb258d12636f1b2ebe8c7b167708dbf572fbe8
-rw-r--r--services/surfaceflinger/Android.mk4
-rw-r--r--services/surfaceflinger/DisplayHardware/HWC2.cpp2
-rw-r--r--services/surfaceflinger/DisplayHardware/HWC2.h4
-rw-r--r--services/surfaceflinger/DisplayHardware/HWC2On1Adapter.cpp50
-rw-r--r--services/surfaceflinger/DisplayHardware/HWComposer.cpp4
5 files changed, 38 insertions, 26 deletions
diff --git a/services/surfaceflinger/Android.mk b/services/surfaceflinger/Android.mk
index 7135ed3bd1..3800ce811c 100644
--- a/services/surfaceflinger/Android.mk
+++ b/services/surfaceflinger/Android.mk
@@ -52,7 +52,11 @@ ifeq ($(TARGET_USES_HWC2),true)
LOCAL_SRC_FILES += \
SurfaceFlinger.cpp \
DisplayHardware/HWComposer.cpp
+ ifeq ($(TARGET_USES_HWC2ON1ADAPTER), true)
+ LOCAL_CFLAGS += -DBYPASS_IHWC
+ endif
else
+ LOCAL_CFLAGS += -DBYPASS_IHWC
LOCAL_SRC_FILES += \
SurfaceFlinger_hwc1.cpp \
DisplayHardware/HWComposer_hwc1.cpp
diff --git a/services/surfaceflinger/DisplayHardware/HWC2.cpp b/services/surfaceflinger/DisplayHardware/HWC2.cpp
index c79caf4807..31af8a15f1 100644
--- a/services/surfaceflinger/DisplayHardware/HWC2.cpp
+++ b/services/surfaceflinger/DisplayHardware/HWC2.cpp
@@ -614,6 +614,8 @@ Error Display::getActiveConfig(
auto error = static_cast<Error>(intError);
if (error != Error::None) {
+ ALOGE("Unable to get active config for mId:[%" PRIu64 "]", mId);
+ *outConfig = nullptr;
return error;
}
diff --git a/services/surfaceflinger/DisplayHardware/HWC2.h b/services/surfaceflinger/DisplayHardware/HWC2.h
index 1145ba1fdd..1c709b2c5f 100644
--- a/services/surfaceflinger/DisplayHardware/HWC2.h
+++ b/services/surfaceflinger/DisplayHardware/HWC2.h
@@ -17,10 +17,6 @@
#ifndef ANDROID_SF_HWC2_H
#define ANDROID_SF_HWC2_H
-#ifndef USE_HWC2
-#define BYPASS_IHWC
-#endif
-
#define HWC2_INCLUDE_STRINGIFICATION
#define HWC2_USE_CPP11
#include <hardware/hwcomposer2.h>
diff --git a/services/surfaceflinger/DisplayHardware/HWC2On1Adapter.cpp b/services/surfaceflinger/DisplayHardware/HWC2On1Adapter.cpp
index b699b2cad0..1107c994ec 100644
--- a/services/surfaceflinger/DisplayHardware/HWC2On1Adapter.cpp
+++ b/services/surfaceflinger/DisplayHardware/HWC2On1Adapter.cpp
@@ -1841,29 +1841,39 @@ void HWC2On1Adapter::Display::initializeActiveConfig()
auto activeConfig = mDevice.mHwc1Device->getActiveConfig(
mDevice.mHwc1Device, mHwc1Id);
- if (activeConfig >= 0) {
- for (const auto& config : mConfigs) {
- if (config->hasHwc1Id(activeConfig)) {
- ALOGV("Setting active config to %d for HWC1 config %u",
- config->getId(), activeConfig);
- mActiveConfig = config;
- if (config->getColorModeForHwc1Id(activeConfig, &mActiveColorMode) != Error::None) {
- // This should never happen since we checked for the config's presence before
- // setting it as active.
- ALOGE("Unable to find color mode for active HWC1 config %d",
- config->getId());
- mActiveColorMode = HAL_COLOR_MODE_NATIVE;
- }
- break;
+
+ // Some devices startup without an activeConfig:
+ // We need to set one ourselves.
+ if (activeConfig == HWC_ERROR) {
+ ALOGV("There is no active configuration: Picking the first one: 0.");
+ const int defaultIndex = 0;
+ mDevice.mHwc1Device->setActiveConfig(mDevice.mHwc1Device, mHwc1Id, defaultIndex);
+ activeConfig = defaultIndex;
+ }
+
+ for (const auto& config : mConfigs) {
+ if (config->hasHwc1Id(activeConfig)) {
+ ALOGE("Setting active config to %d for HWC1 config %u", config->getId(), activeConfig);
+ mActiveConfig = config;
+ if (config->getColorModeForHwc1Id(activeConfig, &mActiveColorMode) != Error::None) {
+ // This should never happen since we checked for the config's presence before
+ // setting it as active.
+ ALOGE("Unable to find color mode for active HWC1 config %d", config->getId());
+ mActiveColorMode = HAL_COLOR_MODE_NATIVE;
}
- }
- if (!mActiveConfig) {
- ALOGV("Unable to find active HWC1 config %u, defaulting to "
- "config 0", activeConfig);
- mActiveConfig = mConfigs[0];
- mActiveColorMode = HAL_COLOR_MODE_NATIVE;
+ break;
}
}
+ if (!mActiveConfig) {
+ ALOGV("Unable to find active HWC1 config %u, defaulting to "
+ "config 0", activeConfig);
+ mActiveConfig = mConfigs[0];
+ mActiveColorMode = HAL_COLOR_MODE_NATIVE;
+ }
+
+
+
+
}
void HWC2On1Adapter::Display::reallocateHwc1Contents()
diff --git a/services/surfaceflinger/DisplayHardware/HWComposer.cpp b/services/surfaceflinger/DisplayHardware/HWComposer.cpp
index bb2e45a2ab..82a900c06d 100644
--- a/services/surfaceflinger/DisplayHardware/HWComposer.cpp
+++ b/services/surfaceflinger/DisplayHardware/HWComposer.cpp
@@ -346,14 +346,14 @@ std::vector<std::shared_ptr<const HWC2::Display::Config>>
std::shared_ptr<const HWC2::Display::Config>
HWComposer::getActiveConfig(int32_t displayId) const {
if (!isValidDisplay(displayId)) {
- ALOGE("getActiveConfigs: Attempted to access invalid display %d",
+ ALOGV("getActiveConfigs: Attempted to access invalid display %d",
displayId);
return nullptr;
}
std::shared_ptr<const HWC2::Display::Config> config;
auto error = mDisplayData[displayId].hwcDisplay->getActiveConfig(&config);
if (error == HWC2::Error::BadConfig) {
- ALOGV("getActiveConfig: No config active, returning null");
+ ALOGE("getActiveConfig: No config active, returning null");
return nullptr;
} else if (error != HWC2::Error::None) {
ALOGE("getActiveConfig failed for display %d: %s (%d)", displayId,