ION support in libwsbm.

When creat surface from user pointer, it will also
pass down buffer fd to kernel, which help to find
physical pages if ION is enabled.

Orig-Author:     Randy Xu <randy.xu@intel.com>

Bug: 18731042
BZ: 230505
Change-Id: I523cfd4542c00285957494c9a65b66b277308913
Signed-off-by: mahongpe <hongpeng.ma@intel.com>
diff --git a/src/wsbm_manager.c b/src/wsbm_manager.c
index e7c8f5d..0cbf9de 100644
--- a/src/wsbm_manager.c
+++ b/src/wsbm_manager.c
@@ -613,7 +613,7 @@
 int
 wsbmBODataUB(struct _WsbmBufferObject *buf,
         unsigned size, const void *data, struct _WsbmBufferPool *newPool,
-        uint32_t placement, const unsigned long *user_ptr)
+        uint32_t placement, const unsigned long *user_ptr, int fd)
 {
     int newBuffer;
     int retval = 0;
@@ -624,7 +624,7 @@
     extern struct _WsbmBufStorage *
     ttm_pool_ub_create(struct _WsbmBufferPool *pool,
         unsigned long size, uint32_t placement, unsigned alignment,
-        const unsigned long *user_ptr);
+        const unsigned long *user_ptr, int fd);
 
     if (buf->bufferType == WSBM_BUFFER_SIMPLE)
         return -EINVAL;
@@ -659,7 +659,7 @@
         }
 
         buf->storage =
-            ttm_pool_ub_create(newPool, size, placement, buf->alignment, user_ptr);
+            ttm_pool_ub_create(newPool, size, placement, buf->alignment, user_ptr, fd);
         if (!buf->storage) {
             retval = -ENOMEM;
             goto out;
@@ -681,7 +681,7 @@
         curPool = storage->pool;
 
         tmp_storage =
-            ttm_pool_ub_create(curPool, size, placement, buf->alignment, user_ptr);
+            ttm_pool_ub_create(curPool, size, placement, buf->alignment, user_ptr, fd);
 
         if (tmp_storage) {
             wsbmBufStorageUnref(&buf->storage);
diff --git a/src/wsbm_manager.h b/src/wsbm_manager.h
index aa2eb5f..1fd5e39 100644
--- a/src/wsbm_manager.h
+++ b/src/wsbm_manager.h
@@ -95,7 +95,7 @@
 
 extern int wsbmBODataUB(struct _WsbmBufferObject *buf,
             unsigned size, const void *data, struct _WsbmBufferPool *newPool,
-            uint32_t placement, const unsigned long *user_ptr);
+            uint32_t placement, const unsigned long *user_ptr, int fd);
 
 extern int wsbmBOSetStatus(struct _WsbmBufferObject *buf,
 			   uint32_t setPlacement, uint32_t clrPlacement);
diff --git a/src/wsbm_ttmpool.c b/src/wsbm_ttmpool.c
index 0ea32bd..3b594b3 100644
--- a/src/wsbm_ttmpool.c
+++ b/src/wsbm_ttmpool.c
@@ -529,7 +529,7 @@
 }
 
 struct _WsbmBufStorage *
-ttm_pool_ub_create(struct _WsbmBufferPool *pool, unsigned long size, uint32_t placement, unsigned alignment, const unsigned long *user_ptr)
+ttm_pool_ub_create(struct _WsbmBufferPool *pool, unsigned long size, uint32_t placement, unsigned alignment, const unsigned long *user_ptr, int fd)
 {
     struct _TTMBuffer *dBuf = (struct _TTMBuffer *)
 	    calloc(1, sizeof(*dBuf));
@@ -556,6 +556,7 @@
     arg.req.placement = placement;
     arg.req.page_alignment = alignment / pageSize;
     arg.req.user_address = (unsigned long)user_ptr;
+    arg.req.fd = fd;
 
     DRMRESTARTCOMMANDWRITEREAD(pool->fd, ttmPool->devOffset + TTM_PL_CREATE_UB,
 			       arg, ret);