hwc: Add support for copybit(C2D) composition
- Add CopybitEngine to hwc_context
- draw the layer on the HWC_FRAMEBUFFER_TARGET using
copybit(c2d) if it qualifies for C2D composition.
- use fence returned from the copybit during c2d
composition
Change-Id: I052da015cd031f7abd6411d83d7944c335caeff7
diff --git a/libhwcomposer/hwc.cpp b/libhwcomposer/hwc.cpp
index ac1be19..ba84580 100644
--- a/libhwcomposer/hwc.cpp
+++ b/libhwcomposer/hwc.cpp
@@ -2,6 +2,9 @@
* Copyright (C) 2010 The Android Open Source Project
* Copyright (C) 2012-2013, The Linux Foundation. All rights reserved.
*
+ * Not a Contribution, Apache license notifications and license are retained
+ * for attribution purposes only.
+ *
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
@@ -30,6 +33,7 @@
#include "hwc_fbupdate.h"
#include "hwc_mdpcomp.h"
#include "external.h"
+#include "hwc_copybit.h"
using namespace qhwc;
#define VSYNC_DEBUG 0
@@ -96,6 +100,9 @@
if(ctx->mFBUpdate[i])
ctx->mFBUpdate[i]->reset();
+
+ if(ctx->mCopyBit[i])
+ ctx->mCopyBit[i]->reset();
}
VideoOverlay::reset();
}
@@ -127,11 +134,16 @@
if(fbLayer->handle) {
setListStats(ctx, list, dpy);
reset_layer_prop(ctx, dpy);
- if(!ctx->mMDPComp->prepare(ctx, list)) {
+ int ret = ctx->mMDPComp->prepare(ctx, list);
+ if(!ret) {
+ // IF MDPcomp fails use this route
VideoOverlay::prepare(ctx, list, dpy);
ctx->mFBUpdate[dpy]->prepare(ctx, fbLayer);
}
ctx->mLayerCache[dpy]->updateLayerCache(list);
+ // Use Copybit, when MDP comp fails
+ if(!ret && ctx->mCopyBit[dpy])
+ ctx->mCopyBit[dpy]->prepare(ctx, list, dpy);
}
}
return 0;
@@ -154,6 +166,8 @@
VideoOverlay::prepare(ctx, list, dpy);
ctx->mFBUpdate[dpy]->prepare(ctx, fbLayer);
ctx->mLayerCache[dpy]->updateLayerCache(list);
+ if(ctx->mCopyBit[dpy])
+ ctx->mCopyBit[dpy]->prepare(ctx, list, dpy);
ctx->mExtDispConfiguring = false;
}
}
@@ -296,8 +310,10 @@
ctx->dpyAttr[dpy].isActive) {
uint32_t last = list->numHwLayers - 1;
hwc_layer_1_t *fbLayer = &list->hwLayers[last];
-
- hwc_sync(ctx, list, dpy);
+ int fd = -1; //FenceFD from the Copybit(valid in async mode)
+ if(ctx->mCopyBit[dpy])
+ ctx->mCopyBit[dpy]->draw(ctx, list, dpy, &fd);
+ hwc_sync(ctx, list, dpy, fd);
if (!VideoOverlay::draw(ctx, list, dpy)) {
ALOGE("%s: VideoOverlay::draw fail!", __FUNCTION__);
ret = -1;
@@ -338,8 +354,11 @@
ctx->dpyAttr[dpy].connected) {
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)
+ if(ctx->mCopyBit[dpy])
+ ctx->mCopyBit[dpy]->draw(ctx, list, dpy, &fd);
- hwc_sync(ctx, list, dpy);
+ hwc_sync(ctx, list, dpy, fd);
if (!VideoOverlay::draw(ctx, list, dpy)) {
ALOGE("%s: VideoOverlay::draw fail!", __FUNCTION__);
@@ -369,7 +388,6 @@
int ret = 0;
hwc_context_t* ctx = (hwc_context_t*)(dev);
Locker::Autolock _l(ctx->mBlankLock);
-
for (uint32_t i = 0; i < numDisplays; i++) {
hwc_display_contents_1_t* list = displays[i];
switch(i) {