Merge "hwc: Change default app buffers count for ferrum."
diff --git a/libhwcomposer/hwc_utils.cpp b/libhwcomposer/hwc_utils.cpp
index d67a7a1..7cf390e 100644
--- a/libhwcomposer/hwc_utils.cpp
+++ b/libhwcomposer/hwc_utils.cpp
@@ -43,6 +43,7 @@
 #include "comptype.h"
 #include "hwc_virtual.h"
 #include "qd_utils.h"
+#include <sys/sysinfo.h>
 
 using namespace qClient;
 using namespace qService;
@@ -73,6 +74,11 @@
 #endif
 #endif
 
+#define PROP_DEFAULT_APPBUFFER  "ro.sf.default_app_buffer"
+#define MAX_RAM_SIZE  512*1024*1024
+#define qHD_WIDTH 540
+
+
 namespace qhwc {
 
 //Std refresh rates for digital videos- 24p, 30p and 48p
@@ -232,6 +238,25 @@
     return 0;
 }
 
+static void changeDefaultAppBufferCount() {
+    struct sysinfo info;
+    unsigned long int ramSize = 0;
+    if (!sysinfo(&info)) {
+           ramSize = info.totalram ;
+    }
+    int fb_fd = -1;
+    struct fb_var_screeninfo sInfo ={0};
+    fb_fd = open("/dev/graphics/fb0", O_RDONLY);
+    if (fb_fd >=0) {
+        ioctl(fb_fd, FBIOGET_VSCREENINFO, &sInfo);
+        close(fb_fd);
+    }
+    if ((ramSize && ramSize < MAX_RAM_SIZE) &&
+         (sInfo.xres &&  sInfo.xres <= qHD_WIDTH )) {
+                  property_set(PROP_DEFAULT_APPBUFFER, "2");
+    }
+}
+
 void initContext(hwc_context_t *ctx)
 {
     openFramebufferDevice(ctx);
@@ -243,6 +268,10 @@
     ctx->mOverlay = overlay::Overlay::getInstance();
     ctx->mRotMgr = RotMgr::getInstance();
 
+    //default_app_buffer for ferrum
+    if (ctx->mMDP.version ==  qdutils::MDP_V3_0_5) {
+       changeDefaultAppBufferCount();
+    }
     // Initialize composition objects for the primary display
     initCompositionResources(ctx, HWC_DISPLAY_PRIMARY);