Merge changes I7ad0d7c2,Iccc7a5dd
am: e198250e00

Change-Id: Icb41e406f075655801e5d2653628791406ff512a
diff --git a/gralloc/alloc_device.cpp b/gralloc/alloc_device.cpp
index 6773405..cef5851 100644
--- a/gralloc/alloc_device.cpp
+++ b/gralloc/alloc_device.cpp
@@ -333,6 +333,12 @@
 
 #endif
 	}
+
+	// correct numFds/numInts when there is no dmabuf fd
+	if (hnd->share_fd < 0) {
+		hnd->numFds--;
+		hnd->numInts++;
+	}
 #endif
 
 	*pHandle = hnd;
diff --git a/gralloc/gralloc_module.cpp b/gralloc/gralloc_module.cpp
index cdcbc5b..70d2c69 100644
--- a/gralloc/gralloc_module.cpp
+++ b/gralloc/gralloc_module.cpp
@@ -96,7 +96,9 @@
 
 	if (hnd->flags & private_handle_t::PRIV_FLAGS_FRAMEBUFFER)
 	{
-		AERR("Can't register buffer 0x%p as it is a framebuffer", handle);
+		AINF("Register framebuffer 0x%p is no-op", handle);
+		retval = 0;
+
 	}
 	else if (hnd->flags & private_handle_t::PRIV_FLAGS_USES_UMP)
 	{
diff --git a/gralloc/gralloc_priv.h b/gralloc/gralloc_priv.h
index 547027e..3615960 100644
--- a/gralloc/gralloc_priv.h
+++ b/gralloc/gralloc_priv.h
@@ -313,9 +313,21 @@
 	{
 		const private_handle_t *hnd = (const private_handle_t *)h;
 
-		if (!h || h->version != sizeof(native_handle) || h->numFds != sNumFds ||
-		        h->numInts != (sizeof(private_handle_t) - sizeof(native_handle)) / sizeof(int) - sNumFds ||
-		        hnd->magic != sMagic)
+		if (!h || h->version != sizeof(native_handle) || hnd->magic != sMagic)
+		{
+			return -EINVAL;
+		}
+
+		int numFds = sNumFds;
+		int numInts = (sizeof(private_handle_t) - sizeof(native_handle)) / sizeof(int) - sNumFds;
+#if GRALLOC_ARM_DMA_BUF_MODULE
+		if (hnd->share_fd < 0) {
+			numFds--;
+			numInts++;
+		}
+#endif
+
+		if (h->numFds != numFds || h->numInts != numInts)
 		{
 			return -EINVAL;
 		}