libqdutils: Add generic metadata structure for VFM

Defines generic metadata structure for VFM. An array of VFM metadata
structures is used to keep the libqdutils agnostic of the internal
details of VFM metadata.

Change-Id: I5513b5f88b0f18687c0f563f2fe25eb9481887bf
diff --git a/libqdutils/qdMetaData.cpp b/libqdutils/qdMetaData.cpp
index 89ca92e..f39eef9 100644
--- a/libqdutils/qdMetaData.cpp
+++ b/libqdutils/qdMetaData.cpp
@@ -81,6 +81,26 @@
         case UPDATE_BUFFER_GEOMETRY:
             memcpy((void *)&data->bufferDim, param, sizeof(BufferDim_t));
             break;
+        case PP_PARAM_VFM_DATA:
+        {
+            int32_t     indx = 0;
+            VfmData_t*  pVfmData = reinterpret_cast <VfmData_t *>(param);
+            int32_t     dataType = pVfmData->dataType;
+
+            if(dataType > 0){
+                indx = getVfmDataIdx(dataType);
+                if(indx < MAX_VFM_DATA_COUNT){
+                    data->vfmDataBitMap |= dataType;
+                    memcpy((void *)&data->vfmData[indx], param,
+                        sizeof(VfmData_t));
+                }else{
+                    ALOGE("unknown dataType %d", dataType);
+                }
+            }else{
+                ALOGE("invalid dataType in PP_PARAM_VFM_DATA %d", dataType);
+            }
+        }
+        break;
         default:
             ALOGE("Unknown paramType %d", paramType);
             break;
diff --git a/libqdutils/qdMetaData.h b/libqdutils/qdMetaData.h
index d5354a4..4b6e678 100644
--- a/libqdutils/qdMetaData.h
+++ b/libqdutils/qdMetaData.h
@@ -31,6 +31,19 @@
 #define _QDMETADATA_H
 
 #define MAX_IGC_LUT_ENTRIES 256
+#define MAX_VFM_DATA_SIZE   64 //bytes per data buffer
+#define MAX_VFM_DATA_COUNT  16 //number of data buffers
+
+/* This macro finds the index corresponding to a type */
+/* This is equivalent to indx = LOG_2(type) */
+inline int32_t getVfmDataIdx(int32_t type){
+    int32_t indx = 0, x = type;
+    while( x >> 1) {
+        x = (x >> 1);
+        indx++;
+    }
+    return indx;
+}
 
 struct HSICData_t {
     int32_t hue;
@@ -57,6 +70,11 @@
     int32_t sliceHeight;
 };
 
+struct VfmData_t {
+    int32_t dataType;
+    char    data[MAX_VFM_DATA_SIZE];
+};
+
 struct MetaData_t {
     int32_t operation;
     int32_t interlaced;
@@ -67,6 +85,8 @@
     IGCData_t igcData;
     Sharp2Data_t Sharp2Data;
     int64_t timestamp;
+    int32_t vfmDataBitMap;
+    VfmData_t vfmData[MAX_VFM_DATA_COUNT];
 };
 
 typedef enum {
@@ -78,6 +98,7 @@
     PP_PARAM_SHARP2     = 0x0020,
     PP_PARAM_TIMESTAMP  = 0x0040,
     UPDATE_BUFFER_GEOMETRY = 0x0080,
+    PP_PARAM_VFM_DATA   = 0x0100,
 } DispParamType;
 
 int setMetaData(private_handle_t *handle, DispParamType paramType, void *param);