am 9e2463e7: add/remove displays properly on hotplug events

* commit '9e2463e71796964cfaa06bf09a880875ac3537bc':
  add/remove displays properly on hotplug events
This commit is contained in:
Mathias Agopian 2012-09-24 09:26:02 -07:00 committed by Android Git Automerger
commit 511572b465
4 changed files with 26 additions and 6 deletions

View File

@ -167,6 +167,13 @@ void DisplayDevice::init(EGLConfig config)
setProjection(DisplayState::eOrientationDefault, mViewport, mFrame);
}
void DisplayDevice::setDisplayName(const String8& displayName) {
if (!displayName.isEmpty()) {
// never override the name with an empty name
mDisplayName = displayName;
}
}
uint32_t DisplayDevice::getPageFlipCount() const {
return mPageFlipCount;
}

View File

@ -119,9 +119,7 @@ public:
}
inline Rect bounds() const { return getBounds(); }
void setDisplayName(const String8& displayName) {
mDisplayName = displayName;
}
void setDisplayName(const String8& displayName);
const String8& getDisplayName() const { return mDisplayName; }
static EGLBoolean makeCurrent(EGLDisplay dpy,

View File

@ -337,7 +337,12 @@ status_t HWComposer::queryDisplayProperties(int disp) {
return err;
}
mHwc->getDisplayAttributes(mHwc, disp, config, DISPLAY_ATTRIBUTES, values);
err = mHwc->getDisplayAttributes(mHwc, disp, config, DISPLAY_ATTRIBUTES, values);
if (err != NO_ERROR) {
// we can't get this display's info. turn it off.
mDisplayData[disp].connected = false;
return err;
}
int32_t w = 0, h = 0;
for (size_t i = 0; i < NUM_DISPLAY_ATTRIBUTES - 1; i++) {

View File

@ -408,10 +408,10 @@ status_t SurfaceFlinger::readyToRun()
DisplayDevice::DisplayType type((DisplayDevice::DisplayType)i);
mDefaultDisplays[i] = new BBinder();
wp<IBinder> token = mDefaultDisplays[i];
mCurrentState.displays.add(token, DisplayDeviceState(type));
// set-up the displays that are already connected
if (mHwc->isConnected(i)) {
if (mHwc->isConnected(i) || type==DisplayDevice::DISPLAY_PRIMARY) {
mCurrentState.displays.add(token, DisplayDeviceState(type));
sp<FramebufferSurface> fbs = new FramebufferSurface(*mHwc, i);
sp<SurfaceTextureClient> stc = new SurfaceTextureClient(
static_cast< sp<ISurfaceTexture> >(fbs->getBufferQueue()));
@ -688,7 +688,17 @@ void SurfaceFlinger::onHotplugReceived(int type, bool connected) {
ALOGW("WARNING: EventThread not started, ignoring hotplug");
return;
}
if (uint32_t(type) < DisplayDevice::NUM_DISPLAY_TYPES) {
Mutex::Autolock _l(mStateLock);
if (connected == false) {
mCurrentState.displays.removeItem(mDefaultDisplays[type]);
} else {
DisplayDeviceState info((DisplayDevice::DisplayType)type);
mCurrentState.displays.add(mDefaultDisplays[type], info);
}
setTransactionFlags(eDisplayTransactionNeeded);
// we should only receive DisplayDevice::DisplayType from the vsync callback
mEventThread->onHotplugReceived(type, connected);
}