hwc: Common Display HAL to support VDS & V4L2 WFD solutions
1. Define classes for VDS and V4L2 based WFD solutions.
2. Overload the functionalities for VDS and V4L2 WFD solutions.
3. Instantiate VDS object or V4L2 object during hwc init based on the
property persist.hwc.enable_vds set by the user.
4. VDS solution is not verified as it requires some dependent changes.
Change-Id: I74bf944d532da138c850d4ec0c20b4a881489efa
diff --git a/libhwcomposer/hwc.cpp b/libhwcomposer/hwc.cpp
index eb999f7..dcad00b 100644
--- a/libhwcomposer/hwc.cpp
+++ b/libhwcomposer/hwc.cpp
@@ -39,6 +39,7 @@
#include "hwc_ad.h"
#include "profiler.h"
#include "hwc_vpuclient.h"
+#include "hwc_virtual.h"
using namespace qhwc;
using namespace overlay;
@@ -127,15 +128,8 @@
ctx->mAD->reset();
MDPComp::reset();
-}
-
-//clear prev layer prop flags and realloc for current frame
-static void reset_layer_prop(hwc_context_t* ctx, int dpy, int numAppLayers) {
- if(ctx->layerProp[dpy]) {
- delete[] ctx->layerProp[dpy];
- ctx->layerProp[dpy] = NULL;
- }
- ctx->layerProp[dpy] = new LayerProp[numAppLayers];
+ if(ctx->mHWCVirtual)
+ ctx->mHWCVirtual->destroy(ctx, numDisplays, displays);
}
static int hwc_prepare_primary(hwc_composer_device_1 *dev,
@@ -193,39 +187,6 @@
return 0;
}
-static int hwc_prepare_virtual(hwc_composer_device_1 *dev,
- hwc_display_contents_1_t *list) {
- ATRACE_CALL();
-
- hwc_context_t* ctx = (hwc_context_t*)(dev);
- const int dpy = HWC_DISPLAY_VIRTUAL;
-
- if (LIKELY(list && list->numHwLayers > 1) &&
- ctx->dpyAttr[dpy].isActive &&
- ctx->dpyAttr[dpy].connected) {
- reset_layer_prop(ctx, dpy, list->numHwLayers - 1);
- if(!ctx->dpyAttr[dpy].isPause) {
- ctx->dpyAttr[dpy].isConfiguring = false;
- setListStats(ctx, list, dpy);
- if(ctx->mMDPComp[dpy]->prepare(ctx, list) < 0) {
- const int fbZ = 0;
- ctx->mFBUpdate[dpy]->prepare(ctx, list, fbZ);
- }
- } else {
- /* Virtual Display is in Pause state.
- * Mark all application layers as OVERLAY so that
- * GPU will not compose.
- */
- for(size_t i = 0 ;i < (size_t)(list->numHwLayers - 1); i++) {
- hwc_layer_1_t *layer = &list->hwLayers[i];
- layer->compositionType = HWC_OVERLAY;
- }
- }
- }
- return 0;
-}
-
-
static int hwc_prepare(hwc_composer_device_1 *dev, size_t numDisplays,
hwc_display_contents_1_t** displays)
{
@@ -256,7 +217,8 @@
ret = hwc_prepare_external(dev, list);
break;
case HWC_DISPLAY_VIRTUAL:
- ret = hwc_prepare_virtual(dev, list);
+ if(ctx->mHWCVirtual)
+ ret = ctx->mHWCVirtual->prepare(dev, list);
break;
default:
ret = -EINVAL;
@@ -439,8 +401,11 @@
value[0] = 0;
break;
case HWC_DISPLAY_TYPES_SUPPORTED:
- if(ctx->mMDP.hasOverlay)
- supported |= HWC_DISPLAY_EXTERNAL_BIT;
+ if(ctx->mMDP.hasOverlay) {
+ supported |= HWC_DISPLAY_VIRTUAL_BIT;
+ if(!qdutils::MDPVersion::getInstance().is8x26())
+ supported |= HWC_DISPLAY_EXTERNAL_BIT;
+ }
value[0] = supported;
break;
case HWC_FORMAT_RB_SWAP:
@@ -567,75 +532,6 @@
return ret;
}
-static int hwc_set_virtual(hwc_context_t *ctx,
- hwc_display_contents_1_t* list)
-{
- ATRACE_CALL();
- int ret = 0;
-
- const int dpy = HWC_DISPLAY_VIRTUAL;
-
-
- if (LIKELY(list) && ctx->dpyAttr[dpy].isActive &&
- ctx->dpyAttr[dpy].connected &&
- !ctx->dpyAttr[dpy].isPause) {
- uint32_t last = list->numHwLayers - 1;
- hwc_layer_1_t *fbLayer = &list->hwLayers[last];
- int fd = -1; //FenceFD from the Copybit(valid in async mode)
- bool copybitDone = false;
- if(ctx->mCopyBit[dpy])
- copybitDone = ctx->mCopyBit[dpy]->draw(ctx, list, dpy, &fd);
-
- if(list->numHwLayers > 1)
- hwc_sync(ctx, list, dpy, fd);
-
- // Dump the layers for virtual
- if(ctx->mHwcDebug[dpy])
- ctx->mHwcDebug[dpy]->dumpLayers(list);
-
- if (!ctx->mMDPComp[dpy]->draw(ctx, list)) {
- ALOGE("%s: MDPComp draw failed", __FUNCTION__);
- ret = -1;
- }
-
- int extOnlyLayerIndex =
- ctx->listStats[dpy].extOnlyLayerIndex;
-
- private_handle_t *hnd = (private_handle_t *)fbLayer->handle;
- if(extOnlyLayerIndex!= -1) {
- hwc_layer_1_t *extLayer = &list->hwLayers[extOnlyLayerIndex];
- hnd = (private_handle_t *)extLayer->handle;
- } else if(copybitDone) {
- hnd = ctx->mCopyBit[dpy]->getCurrentRenderBuffer();
- }
-
- if(hnd && !isYuvBuffer(hnd)) {
- if (!ctx->mFBUpdate[dpy]->draw(ctx, hnd)) {
- ALOGE("%s: FBUpdate::draw fail!", __FUNCTION__);
- ret = -1;
- }
- }
-
- if(!Overlay::displayCommit(ctx->dpyAttr[dpy].fd)) {
- ALOGE("%s: display commit fail for %d dpy!", __FUNCTION__, dpy);
- ret = -1;
- }
- }
-
- closeAcquireFds(list);
-
- if (list && !ctx->mVirtualonExtActive && (list->retireFenceFd < 0) ) {
- // SF assumes HWC waits for the acquire fence and returns a new fence
- // that signals when we're done. Since we don't wait, and also don't
- // touch the buffer, we can just handle the acquire fence back to SF
- // as the retire fence.
- list->retireFenceFd = list->outbufAcquireFenceFd;
- }
-
- return ret;
-}
-
-
static int hwc_set(hwc_composer_device_1 *dev,
size_t numDisplays,
hwc_display_contents_1_t** displays)
@@ -653,7 +549,8 @@
ret = hwc_set_external(ctx, list);
break;
case HWC_DISPLAY_VIRTUAL:
- ret = hwc_set_virtual(ctx, list);
+ if(ctx->mHWCVirtual)
+ ret = ctx->mHWCVirtual->set(ctx, list);
break;
default:
ret = -EINVAL;