hwc/overlay: Dynamic pipe tracking.
Remove state based pipe handling and make pipes tracked dynamically.
Add the configStart, configDone, nextPipe availablePipes APIs.
Remove setState API.
-configStart marks all pipes available.
-configDone garbage-collects unused pipe objects.
-nextPipe returns the index of next available pipe and create a corresponding
pipe object if not present
-availablePipes returns total of "unallocated" pipes. (Pipes could be allocated
but unused)
Changes in hwc adapt to the new overlay APIs.
Compile out MDP comp.
Remove unused files in overlay and hwc.
Update licenses.
Conflicts:
libhwcomposer/hwc.cpp
libhwcomposer/hwc_utils.cpp
Bug: 7626586
Change-Id: Id8e56901d34e5dc0fd088260d05e3e46f68ff090
Signed-off-by: Saurabh Shah <saurshah@codeaurora.org>
Signed-off-by: Iliyan Malchev <malchev@google.com>
diff --git a/libhwcomposer/hwc_fbupdate.cpp b/libhwcomposer/hwc_fbupdate.cpp
new file mode 100644
index 0000000..0d0787e
--- /dev/null
+++ b/libhwcomposer/hwc_fbupdate.cpp
@@ -0,0 +1,132 @@
+/*
+ * Copyright (C) 2010 The Android Open Source Project
+ * Copyright (C) 2012, 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
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#define HWC_FB_UPDATE 0
+#include <gralloc_priv.h>
+#include <fb_priv.h>
+#include "hwc_fbupdate.h"
+#include "external.h"
+
+namespace qhwc {
+
+namespace ovutils = overlay::utils;
+
+//Static Members
+bool FBUpdate::sModeOn[] = {false};
+ovutils::eDest FBUpdate::sDest[] = {ovutils::OV_INVALID};
+
+void FBUpdate::reset() {
+ sModeOn[HWC_DISPLAY_PRIMARY] = false;
+ sModeOn[HWC_DISPLAY_EXTERNAL] = false;
+ sDest[HWC_DISPLAY_PRIMARY] = ovutils::OV_INVALID;
+ sDest[HWC_DISPLAY_EXTERNAL] = ovutils::OV_INVALID;
+}
+
+bool FBUpdate::prepare(hwc_context_t *ctx, hwc_layer_1_t *fblayer, int dpy) {
+ if(!ctx->mMDP.hasOverlay) {
+ ALOGD_IF(HWC_FB_UPDATE, "%s, this hw doesnt support mirroring",
+ __FUNCTION__);
+ return false;
+ }
+
+ return (sModeOn[dpy] = configure(ctx, fblayer, dpy));
+
+}
+
+// Configure
+bool FBUpdate::configure(hwc_context_t *ctx, hwc_layer_1_t *layer, int dpy)
+{
+ bool ret = false;
+ if (LIKELY(ctx->mOverlay)) {
+ overlay::Overlay& ov = *(ctx->mOverlay);
+ private_handle_t *hnd = (private_handle_t *)layer->handle;
+ if (!hnd) {
+ ALOGE("%s:NULL private handle for layer!", __FUNCTION__);
+ return false;
+ }
+ ovutils::Whf info(hnd->width, hnd->height, hnd->format, hnd->size);
+
+ //Request an RGB pipe
+ ovutils::eDest dest = ov.nextPipe(ovutils::OV_MDP_PIPE_RGB, dpy);
+ if(dest == ovutils::OV_INVALID) { //None available
+ return false;
+ }
+
+ sDest[dpy] = dest;
+
+ ovutils::eMdpFlags mdpFlags = ovutils::OV_MDP_FLAGS_NONE;
+ if(ctx->mSecureMode) {
+ ovutils::setMdpFlags(mdpFlags,
+ ovutils::OV_MDP_SECURE_OVERLAY_SESSION);
+ }
+
+ ovutils::PipeArgs parg(mdpFlags,
+ info,
+ ovutils::ZORDER_0,
+ ovutils::IS_FG_SET,
+ ovutils::ROT_FLAG_DISABLED);
+ ov.setSource(parg, dest);
+
+ hwc_rect_t sourceCrop = layer->sourceCrop;
+ // x,y,w,h
+ ovutils::Dim dcrop(sourceCrop.left, sourceCrop.top,
+ sourceCrop.right - sourceCrop.left,
+ sourceCrop.bottom - sourceCrop.top);
+ ov.setCrop(dcrop, dest);
+
+ int transform = layer->transform;
+ ovutils::eTransform orient =
+ static_cast<ovutils::eTransform>(transform);
+ ov.setTransform(orient, dest);
+
+ hwc_rect_t displayFrame = layer->displayFrame;
+ ovutils::Dim dpos(displayFrame.left,
+ displayFrame.top,
+ displayFrame.right - displayFrame.left,
+ displayFrame.bottom - displayFrame.top);
+ ov.setPosition(dpos, dest);
+
+ ret = true;
+ if (!ov.commit(dest)) {
+ ALOGE("%s: commit fails", __FUNCTION__);
+ ret = false;
+ }
+ }
+ return ret;
+}
+
+bool FBUpdate::draw(hwc_context_t *ctx, hwc_layer_1_t *layer, int dpy)
+{
+ if(!sModeOn[dpy]) {
+ return true;
+ }
+ bool ret = true;
+ overlay::Overlay& ov = *(ctx->mOverlay);
+ ovutils::eDest dest = sDest[dpy];
+ private_handle_t *hnd = (private_handle_t *)layer->handle;
+ if (!ov.queueBuffer(hnd->fd, hnd->offset, dest)) {
+ ALOGE("%s: queueBuffer failed for external", __FUNCTION__);
+ ret = false;
+ }
+ return ret;
+}
+
+//---------------------------------------------------------------------
+}; //namespace qhwc