sdm: Add support for multiple tone map sessions

Add support for multiple tone map sessions for HDR feature.

CRs-Fixed: 1104823
Change-Id: I6039cf4fac85195c75bcc8762bcbcd0ede8b196a
diff --git a/sdm/libs/utils/utils.cpp b/sdm/libs/utils/utils.cpp
index 5d5ee19..2ca9039 100644
--- a/sdm/libs/utils/utils.cpp
+++ b/sdm/libs/utils/utils.cpp
@@ -1,5 +1,5 @@
 /*
-* Copyright (c) 2016, The Linux Foundation. All rights reserved.
+* Copyright (c) 2016 - 2017, The Linux Foundation. All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions are
@@ -27,6 +27,7 @@
 * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 */
 
+#include <utils/sys.h>
 #include <math.h>
 #include <algorithm>
 
@@ -52,4 +53,11 @@
   return (a * b) / gcd(a, b);
 }
 
+void CloseFd(int *fd) {
+  if (*fd >= 0) {
+    Sys::close_(*fd);
+    *fd = -1;
+  }
+}
+
 }  // namespace sdm