summaryrefslogtreecommitdiffstats
path: root/services
diff options
context:
space:
mode:
Diffstat (limited to 'services')
-rw-r--r--services/surfaceflinger/DisplayHardware/HWComposer.cpp27
-rw-r--r--services/surfaceflinger/DisplayHardware/HWComposer.h3
-rw-r--r--services/surfaceflinger/SurfaceFlinger.cpp23
3 files changed, 48 insertions, 5 deletions
diff --git a/services/surfaceflinger/DisplayHardware/HWComposer.cpp b/services/surfaceflinger/DisplayHardware/HWComposer.cpp
index 2dad005..84c6af9 100644
--- a/services/surfaceflinger/DisplayHardware/HWComposer.cpp
+++ b/services/surfaceflinger/DisplayHardware/HWComposer.cpp
@@ -358,7 +358,12 @@ status_t HWComposer::queryDisplayProperties(int disp) {
return err;
}
- mDisplayData[disp].currentConfig = 0;
+ int currentConfig = getActiveConfig(disp);
+ if (currentConfig < 0 || currentConfig > static_cast<int>((numConfigs-1))) {
+ ALOGE("%s: Invalid display config! %d", __FUNCTION__, currentConfig);
+ currentConfig = 0;
+ }
+ mDisplayData[disp].currentConfig = currentConfig;
for (size_t c = 0; c < numConfigs; ++c) {
err = mHwc->getDisplayAttributes(mHwc, disp, configs[c],
DISPLAY_ATTRIBUTES, values);
@@ -797,15 +802,31 @@ status_t HWComposer::setPowerMode(int disp, int mode) {
status_t HWComposer::setActiveConfig(int disp, int mode) {
LOG_FATAL_IF(disp >= VIRTUAL_DISPLAY_ID_BASE);
DisplayData& dd(mDisplayData[disp]);
- dd.currentConfig = mode;
if (mHwc && hwcHasApiVersion(mHwc, HWC_DEVICE_API_VERSION_1_4)) {
- return (status_t)mHwc->setActiveConfig(mHwc, disp, mode);
+ status_t status = static_cast<status_t>(
+ mHwc->setActiveConfig(mHwc, disp, mode));
+ if (status == NO_ERROR) {
+ dd.currentConfig = mode;
+ } else {
+ ALOGE("%s Failed to set new config (%d) for display (%d)",
+ __FUNCTION__, mode, disp);
+ }
+ return status;
} else {
LOG_FATAL_IF(mode != 0);
}
return NO_ERROR;
}
+int HWComposer::getActiveConfig(int disp) const {
+ LOG_FATAL_IF(disp >= VIRTUAL_DISPLAY_ID_BASE);
+ if (mHwc && hwcHasApiVersion(mHwc, HWC_DEVICE_API_VERSION_1_4)) {
+ return mHwc->getActiveConfig(mHwc, disp);
+ } else {
+ return 0;
+ }
+}
+
void HWComposer::disconnectDisplay(int disp) {
LOG_ALWAYS_FATAL_IF(disp < 0 || disp == HWC_DISPLAY_PRIMARY);
DisplayData& dd(mDisplayData[disp]);
diff --git a/services/surfaceflinger/DisplayHardware/HWComposer.h b/services/surfaceflinger/DisplayHardware/HWComposer.h
index cc98b4c..814f6a3 100644
--- a/services/surfaceflinger/DisplayHardware/HWComposer.h
+++ b/services/surfaceflinger/DisplayHardware/HWComposer.h
@@ -103,6 +103,9 @@ public:
// set active config
status_t setActiveConfig(int disp, int mode);
+ // get active config
+ int getActiveConfig(int disp) const;
+
// reset state when an external, non-virtual display is disconnected
void disconnectDisplay(int disp);
diff --git a/services/surfaceflinger/SurfaceFlinger.cpp b/services/surfaceflinger/SurfaceFlinger.cpp
index de0f921..2b5982e 100644
--- a/services/surfaceflinger/SurfaceFlinger.cpp
+++ b/services/surfaceflinger/SurfaceFlinger.cpp
@@ -485,6 +485,13 @@ void SurfaceFlinger::init() {
ALOGD("marking display %zu as acquired/unblanked", i);
hw->setPowerMode(HWC_POWER_MODE_NORMAL);
}
+ // When a non-virtual display device is added at boot time,
+ // update the active config by querying HWC otherwise the
+ // default config (config 0) will be used.
+ int activeConfig = mHwc->getActiveConfig(hwcId);
+ if (activeConfig >= 0) {
+ hw->setActiveConfig(activeConfig);
+ }
mDisplays.add(token, hw);
}
}
@@ -691,8 +698,10 @@ void SurfaceFlinger::setActiveConfigInternal(const sp<DisplayDevice>& hw, int mo
return;
}
- hw->setActiveConfig(mode);
- getHwComposer().setActiveConfig(type, mode);
+ status_t status = getHwComposer().setActiveConfig(type, mode);
+ if (status == NO_ERROR) {
+ hw->setActiveConfig(mode);
+ }
}
status_t SurfaceFlinger::setActiveConfig(const sp<IBinder>& display, int mode) {
@@ -1462,6 +1471,16 @@ void SurfaceFlinger::handleTransactionLocked(uint32_t transactionFlags)
hw->setProjection(state.orientation,
state.viewport, state.frame);
hw->setDisplayName(state.displayName);
+ // When a new display device is added update the active
+ // config by querying HWC otherwise the default config
+ // (config 0) will be used.
+ if (hwcDisplayId >= DisplayDevice::DISPLAY_PRIMARY &&
+ hwcDisplayId < DisplayDevice::NUM_BUILTIN_DISPLAY_TYPES) {
+ int activeConfig = mHwc->getActiveConfig(hwcDisplayId);
+ if (activeConfig >= 0) {
+ hw->setActiveConfig(activeConfig);
+ }
+ }
mDisplays.add(display, hw);
if (state.isVirtualDisplay()) {
if (hwcDisplayId >= 0) {