display: Enable copybit on msm8610

This change is the hwc and copybit changes need to enable
composition to go through mdp on msm8610.

Change-Id: If0df3a247c5f4f4310966d14fe8fd839bf84b9d5
diff --git a/libcopybit/Android.mk b/libcopybit/Android.mk
index 73bfa86..b125f11 100644
--- a/libcopybit/Android.mk
+++ b/libcopybit/Android.mk
@@ -35,5 +35,9 @@
             LOCAL_SRC_FILES := software_converter.cpp copybit.cpp
             include $(BUILD_SHARED_LIBRARY)
         endif
+        ifeq ($(call is-board-platform-in-list,msm8610),true)
+            LOCAL_SRC_FILES := software_converter.cpp copybit.cpp
+            include $(BUILD_SHARED_LIBRARY)
+        endif
     endif
 endif
diff --git a/libcopybit/copybit.cpp b/libcopybit/copybit.cpp
index ed302f1..43b90d1 100644
--- a/libcopybit/copybit.cpp
+++ b/libcopybit/copybit.cpp
@@ -42,15 +42,8 @@
 
 /******************************************************************************/
 
-#if defined(COPYBIT_MSM7K)
 #define MAX_SCALE_FACTOR    (4)
 #define MAX_DIMENSION       (4096)
-#elif defined(COPYBIT_QSD8K)
-#define MAX_SCALE_FACTOR    (8)
-#define MAX_DIMENSION       (2048)
-#else
-#error "Unsupported MDP version"
-#endif
 
 /******************************************************************************/
 
@@ -394,6 +387,7 @@
             struct mdp_blit_req req[12];
         } list;
 
+        memset(&list, 0, sizeof(list));
         if (ctx->mAlpha < 255) {
             switch (src->format) {
                 // we don't support plane alpha with RGBA formats
@@ -428,7 +422,7 @@
 
         if(src->format ==  HAL_PIXEL_FORMAT_YV12) {
             int usage =
-            GRALLOC_USAGE_PRIVATE_CAMERA_HEAP|GRALLOC_USAGE_PRIVATE_UNCACHED;
+            GRALLOC_USAGE_PRIVATE_IOMMU_HEAP | GRALLOC_USAGE_PRIVATE_UNCACHED;
             if (0 == alloc_buffer(&yv12_handle,src->w,src->h,
                                   src->format, usage)){
                 if(0 == convertYV12toYCrCb420SP(src,yv12_handle)){
@@ -509,6 +503,7 @@
 static int finish_copybit(struct copybit_device_t *dev)
 {
     // NOP for MDP copybit
+    return 0;
 }
 
 /*****************************************************************************/
@@ -524,6 +519,11 @@
     return 0;
 }
 
+static int flush_get_fence(struct copybit_device_t *dev, int* fd)
+{
+    return -1;
+}
+
 /** Open a new instance of a copybit device using name */
 static int open_copybit(const struct hw_module_t* module, const char* name,
                         struct hw_device_t** device)
@@ -542,6 +542,7 @@
     ctx->device.blit = blit_copybit;
     ctx->device.stretch = stretch_copybit;
     ctx->device.finish = finish_copybit;
+    ctx->device.flush_get_fence = flush_get_fence;
     ctx->mAlpha = MDP_ALPHA_NOP;
     ctx->mFlags = 0;
     ctx->mFD = open("/dev/graphics/fb0", O_RDWR, 0);
@@ -551,25 +552,8 @@
               status, strerror(status));
         status = -status;
     } else {
-        struct fb_fix_screeninfo finfo;
-        if (ioctl(ctx->mFD, FBIOGET_FSCREENINFO, &finfo) == 0) {
-            if (strncmp(finfo.id, "msmfb", 5) == 0) {
-                /* Success */
-                status = 0;
-            } else {
-                ALOGE("Error not msm frame buffer");
-                status = -EINVAL;
-            }
-        } else {
-            ALOGE("Error executing ioctl for screen info");
-            status = -errno;
-        }
-    }
-
-    if (status == 0) {
+        status = 0;
         *device = &ctx->device.common;
-    } else {
-        close_copybit(&ctx->device.common);
     }
     return status;
 }
diff --git a/libhwcomposer/hwc.cpp b/libhwcomposer/hwc.cpp
index 9bf0c45..be3d21f 100644
--- a/libhwcomposer/hwc.cpp
+++ b/libhwcomposer/hwc.cpp
@@ -144,13 +144,10 @@
             if(fbZOrder >= 0)
                 ctx->mFBUpdate[dpy]->prepare(ctx, list, fbZOrder);
 
-            /* Temporarily commenting out C2D until we support partial
-               copybit composition for mixed mode MDP
-
-            // Use Copybit, when MDP comp fails
-            if((fbZOrder >= 0) && ctx->mCopyBit[dpy])
-                ctx->mCopyBit[dpy]->prepare(ctx, list, dpy);
-            */
+            if (ctx->mMDP.version < qdutils::MDP_V4_0) {
+                if((fbZOrder >= 0) && ctx->mCopyBit[dpy])
+                    ctx->mCopyBit[dpy]->prepare(ctx, list, dpy);
+            }
         }
     }
     return 0;
diff --git a/libhwcomposer/hwc_copybit.cpp b/libhwcomposer/hwc_copybit.cpp
index 3f40753..8cdf467 100644
--- a/libhwcomposer/hwc_copybit.cpp
+++ b/libhwcomposer/hwc_copybit.cpp
@@ -21,6 +21,7 @@
 #define DEBUG_COPYBIT 0
 #include <copybit.h>
 #include <utils/Timers.h>
+#include <mdp_version.h>
 #include "hwc_copybit.h"
 #include "comptype.h"
 #include "gr.h"
@@ -244,11 +245,13 @@
         mRelFd[0] = -1;
     }
 
-    //Clear the visible region on the render buffer
-    //XXX: Do this only when needed.
-    hwc_rect_t clearRegion;
-    getNonWormholeRegion(list, clearRegion);
-    clear(renderBuffer, clearRegion);
+    if (ctx->mMDP.version >= qdutils::MDP_V4_0) {
+        //Clear the visible region on the render buffer
+        //XXX: Do this only when needed.
+        hwc_rect_t clearRegion;
+        getNonWormholeRegion(list, clearRegion);
+        clear(renderBuffer, clearRegion);
+    }
     // numAppLayers-1, as we iterate from 0th layer index with HWC_COPYBIT flag
     for (int i = 0; i <= (ctx->listStats[dpy].numAppLayers-1); i++) {
         hwc_layer_1_t *layer = &list->hwLayers[i];