diff --git a/libgralloc/framebuffer.cpp b/libgralloc/framebuffer.cpp index 78fc144..0e7a43e 100644 --- a/libgralloc/framebuffer.cpp +++ b/libgralloc/framebuffer.cpp @@ -1,6 +1,6 @@ /* * Copyright (C) 2008 The Android Open Source Project - * Copyright (c) 2010-2011 Code Aurora Forum. All rights reserved. +* Copyright (c) 2010-2012 Code Aurora Forum. All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -255,8 +255,9 @@ static void *hdmi_ui_loop(void *ptr) if (m->trueMirrorSupport) waitForVsync = false; - - if (pTemp->startChannel(info, FRAMEBUFFER_1, + // start the overlay Channel for mirroring + // m->enableHDMIOutput corresponds to the fbnum + if (pTemp->startChannel(info, m->enableHDMIOutput, false, true, 0, VG0_PIPE, waitForVsync)) { pTemp->setFd(m->framebuffer->fd); pTemp->setCrop(0, 0, m->info.xres, m->info.yres); @@ -400,21 +401,22 @@ static int fb_videoOverlayStarted(struct framebuffer_device_t* dev, int started) return 0; } -static int fb_enableHDMIOutput(struct framebuffer_device_t* dev, int enable) +static int fb_enableHDMIOutput(struct framebuffer_device_t* dev, int externaltype) { private_module_t* m = reinterpret_cast( dev->common.module); pthread_mutex_lock(&m->overlayLock); Overlay* pTemp = m->pobjOverlay; - m->enableHDMIOutput = enable; - if(enable) { + m->enableHDMIOutput = externaltype; + LOGE("In fb_enableHDMIOutput: externaltype = %d", m->enableHDMIOutput); + if(externaltype) { if (m->trueMirrorSupport) { m->hdmiMirroringState = HDMI_UI_MIRRORING; } else { if(!m->videoOverlay) m->hdmiMirroringState = HDMI_UI_MIRRORING; } - } else if (!enable && pTemp) { + } else if (!externaltype && pTemp) { m->hdmiMirroringState = HDMI_NO_MIRRORING; closeHDMIChannel(m); } diff --git a/libgralloc/gralloc_priv.h b/libgralloc/gralloc_priv.h index d7f67f9..233a24e 100644 --- a/libgralloc/gralloc_priv.h +++ b/libgralloc/gralloc_priv.h @@ -1,6 +1,6 @@ /* * Copyright (C) 2008 The Android Open Source Project - * Copyright (c) 2011, Code Aurora Forum. All rights reserved. + * Copyright (c) 2011-2012, Code Aurora Forum. All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -284,7 +284,7 @@ struct private_module_t { int orientation; bool videoOverlay; uint32_t currentOffset; - bool enableHDMIOutput; + int enableHDMIOutput; // holds the type of external display bool trueMirrorSupport; bool exitHDMIUILoop; float actionsafeWidthRatio; diff --git a/libhwcomposer/hwcomposer.cpp b/libhwcomposer/hwcomposer.cpp index 4bc7e70..50cb9be 100644 --- a/libhwcomposer/hwcomposer.cpp +++ b/libhwcomposer/hwcomposer.cpp @@ -90,7 +90,7 @@ struct hwc_context_t { BypassState bypassState; #endif #if defined HDMI_DUAL_DISPLAY - bool mHDMIEnabled; + external_display mHDMIEnabled; // Type of external display bool pendingHDMI; #endif int previousLayerCount; @@ -285,8 +285,13 @@ static int prepareOverlay(hwc_context_t *ctx, hwc_layer_t *layer, const bool wai info.secure = (hnd->flags & private_handle_t::PRIV_FLAGS_SECURE_BUFFER)? true:false; + int hdmiConnected = 0; + +#if defined HDMI_DUAL_DISPLAY + hdmiConnected = (int)ctx->mHDMIEnabled; +#endif ret = ovLibObject->setSource(info, layer->transform, - (ovLibObject->getHDMIStatus()?true:false), waitForVsync); + hdmiConnected, waitForVsync); if (!ret) { LOGE("prepareOverlay setSource failed"); return -1; @@ -661,20 +666,20 @@ void storeLockedBypassHandle(hwc_layer_list_t* list, hwc_context_t* ctx) { #endif //COMPOSITION_BYPASS -static void handleHDMIStateChange(hwc_composer_device_t *dev) { +static void handleHDMIStateChange(hwc_composer_device_t *dev, int externaltype) { #if defined HDMI_DUAL_DISPLAY hwc_context_t* ctx = (hwc_context_t*)(dev); private_hwc_module_t* hwcModule = reinterpret_cast( dev->common.module); framebuffer_device_t *fbDev = hwcModule->fbDevice; if (fbDev) { - fbDev->enableHDMIOutput(fbDev, ctx->mHDMIEnabled); + fbDev->enableHDMIOutput(fbDev, externaltype); } if(ctx && ctx->mOverlayLibObject) { overlay::Overlay *ovLibObject = ctx->mOverlayLibObject; - ovLibObject->setHDMIStatus(ctx->mHDMIEnabled); - if (!(ctx->mHDMIEnabled)) { + ovLibObject->setHDMIStatus(externaltype); + if (!externaltype) { // Close the overlay channels if HDMI is disconnected ovLibObject->closeChannel(); } @@ -683,15 +688,29 @@ static void handleHDMIStateChange(hwc_composer_device_t *dev) { } -/* Just mark flags and do stuff after eglSwapBuffers */ -static void hwc_enableHDMIOutput(hwc_composer_device_t *dev, bool enable) { +/* + * function to set the status of external display in hwc + * Just mark flags and do stuff after eglSwapBuffers + * externaltype - can be HDMI, WIFI or OFF + */ +static void hwc_enableHDMIOutput(hwc_composer_device_t *dev, int externaltype) { #if defined HDMI_DUAL_DISPLAY hwc_context_t* ctx = (hwc_context_t*)(dev); - ctx->mHDMIEnabled = enable; - if(enable) { //On connect, allow bypass to draw once to FB + private_hwc_module_t* hwcModule = reinterpret_cast( + dev->common.module); + framebuffer_device_t *fbDev = hwcModule->fbDevice; + overlay::Overlay *ovLibObject = ctx->mOverlayLibObject; + if(externaltype && (externaltype != ctx->mHDMIEnabled)) { + // Close the current external display - as the SF will + // prioritize and send the correct external display + handleHDMIStateChange(dev, 0); + } + // Store the external display + ctx->mHDMIEnabled = (external_display)externaltype; + if(ctx->mHDMIEnabled) { //On connect, allow bypass to draw once to FB ctx->pendingHDMI = true; } else { //On disconnect, close immediately (there will be no bypass) - handleHDMIStateChange(dev); + handleHDMIStateChange(dev, ctx->mHDMIEnabled); } #endif } @@ -1323,7 +1342,7 @@ static int hwc_set(hwc_composer_device_t *dev, #endif #if defined HDMI_DUAL_DISPLAY if(ctx->pendingHDMI) { - handleHDMIStateChange(dev); + handleHDMIStateChange(dev, ctx->mHDMIEnabled); ctx->pendingHDMI = false; } #endif @@ -1452,7 +1471,7 @@ static int hwc_device_open(const struct hw_module_t* module, const char* name, #endif #if defined HDMI_DUAL_DISPLAY - dev->mHDMIEnabled = false; + dev->mHDMIEnabled = EXT_DISPLAY_OFF; dev->pendingHDMI = false; #endif dev->previousOverlayHandle = NULL; diff --git a/liboverlay/overlayLib.cpp b/liboverlay/overlayLib.cpp index c742856..99fee1c 100755 --- a/liboverlay/overlayLib.cpp +++ b/liboverlay/overlayLib.cpp @@ -1,6 +1,6 @@ /* * Copyright (C) 2008 The Android Open Source Project - * Copyright (c) 2010-2011, Code Aurora Forum. All rights reserved. + * Copyright (c) 2010-2012, Code Aurora Forum. All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -211,6 +211,7 @@ int ZOrderManager::getZ(int fbnum){ } break; case FRAMEBUFFER_1: + case FRAMEBUFFER_2: for (int i = 0;i < mMaxPipes; i++) { if(mFB1Pipes[i] == false) { mFB1Pipes[i]= true; @@ -238,6 +239,7 @@ void ZOrderManager::decZ(int fbnum, int zorder){ mFB0Pipes[zorder] = false; break; case FRAMEBUFFER_1: + case FRAMEBUFFER_2: LOG_ASSERT(!mFB1Pipes[zorder],"channel with ZOrder does not exist"); LOGE("decZ: freeing the pipe with zorder = %d for fbdev = %d", zorder, fbnum); mFB1Pipes[zorder] = false; @@ -636,7 +638,7 @@ int Overlay::getS3DFormat(int format) { } bool Overlay::setSource(const overlay_buffer_info& info, int orientation, - bool hdmiConnected, bool waitForVsync, int num_buffers) { + int hdmiConnected, bool waitForVsync, int num_buffers) { // Separate the color format from the 3D format. // If there is 3D content; the effective format passed by the client is: // effectiveFormat = 3D_IN | 3D_OUT | ColorFormat @@ -661,6 +663,7 @@ bool Overlay::setSource(const overlay_buffer_info& info, int orientation, // We always enable the rotator for the primary. bool noRot = false; bool uiChannel = false; + int fbnum = 0; switch(mState) { case OV_2D_VIDEO_ON_PANEL: case OV_3D_VIDEO_2D_PANEL: @@ -684,12 +687,16 @@ bool Overlay::setSource(const overlay_buffer_info& info, int orientation, case OV_2D_VIDEO_ON_TV: case OV_3D_VIDEO_2D_TV: for (int i=0; i