display: Add support for dynamic refresh rate

- The primary panels refresh rate can be change by clients
- Required refresh rate will be set by client using metadata
- If there are multiple clients requesting, it will be used only
  when the refresh rates are equal, else it resets to default
- Set the new refresh rate only when there are only YUV layers
  updating or when the list has only one RGB layer updating
- MdpVersion gets the dyn fps capabilities from panelInfo

Change-Id: If3e7e6b2f028eb301399c4d32c748eed8a97c41f
diff --git a/libqdutils/mdp_version.cpp b/libqdutils/mdp_version.cpp
index 575a97c..b0a8d7d 100644
--- a/libqdutils/mdp_version.cpp
+++ b/libqdutils/mdp_version.cpp
@@ -226,6 +226,19 @@
                     mPanelInfo.mNeedsROIMerge = atoi(tokens[1]);
                     ALOGI("Needs ROI Merge: %d", mPanelInfo.mNeedsROIMerge);
                 }
+                if(!strncmp(tokens[0], "dyn_fps_en", strlen("dyn_fps_en"))) {
+                    mPanelInfo.mDynFpsSupported = atoi(tokens[1]);
+                    ALOGI("Dynamic Fps: %s", mPanelInfo.mDynFpsSupported ?
+                                            "Enabled" : "Disabled");
+                }
+                if(!strncmp(tokens[0], "min_fps", strlen("min_fps"))) {
+                    mPanelInfo.mMinFps = atoi(tokens[1]);
+                    ALOGI("Min Panel fps: %d", mPanelInfo.mMinFps);
+                }
+                if(!strncmp(tokens[0], "max_fps", strlen("max_fps"))) {
+                    mPanelInfo.mMaxFps = atoi(tokens[1]);
+                    ALOGI("Max Panel fps: %d", mPanelInfo.mMaxFps);
+                }
             }
         }
         if((property_get("persist.hwc.pubypass", property, 0) > 0) &&
diff --git a/libqdutils/mdp_version.h b/libqdutils/mdp_version.h
index 1ddad70..dd1aa3d 100644
--- a/libqdutils/mdp_version.h
+++ b/libqdutils/mdp_version.h
@@ -92,9 +92,13 @@
     int mMinROIWidth;            // Min width needed for ROI
     int mMinROIHeight;           // Min height needed for ROI
     bool mNeedsROIMerge;         // Merge ROI's of both the DSI's
+    bool mDynFpsSupported;       // Panel Supports dyn fps
+    uint32_t mMinFps;            // Min fps supported by panel
+    uint32_t mMaxFps;            // Max fps supported by panel
     PanelInfo() : mType(NO_PANEL), mPartialUpdateEnable(0),
     mLeftAlign(0), mWidthAlign(0), mTopAlign(0), mHeightAlign(0),
-    mMinROIWidth(0), mMinROIHeight(0), mNeedsROIMerge(false){}
+    mMinROIWidth(0), mMinROIHeight(0), mNeedsROIMerge(false),
+    mDynFpsSupported(0), mMinFps(0), mMaxFps(0) {}
     friend class MDPVersion;
 };
 
@@ -130,6 +134,9 @@
     unsigned long getLowBw() { return mLowBw; }
     unsigned long getHighBw() { return mHighBw; }
     bool isRotDownscaleEnabled() { return mRotDownscale; }
+    bool isDynFpsSupported() { return mPanelInfo.mDynFpsSupported; }
+    uint32_t getMinFpsSupported() { return mPanelInfo.mMinFps; }
+    uint32_t getMaxFpsSupported() { return mPanelInfo.mMaxFps; }
     int getMaxMixerWidth() const { return mMaxMixerWidth; }
     bool isSrcSplit() const;
     bool isSrcSplitAlways() const;
diff --git a/libqdutils/qdMetaData.cpp b/libqdutils/qdMetaData.cpp
index dbd6f10..de94591 100644
--- a/libqdutils/qdMetaData.cpp
+++ b/libqdutils/qdMetaData.cpp
@@ -83,7 +83,10 @@
             break;
         case UPDATE_BUFFER_GEOMETRY:
             memcpy((void *)&data->bufferDim, param, sizeof(BufferDim_t));
-        break;
+            break;
+        case UPDATE_REFRESH_RATE:
+            data->refreshrate = *((uint32_t *)param);
+            break;
         case UPDATE_COLOR_SPACE:
             data->colorSpace = *((ColorSpace_t *)param);
             break;
diff --git a/libqdutils/qdMetaData.h b/libqdutils/qdMetaData.h
index 3ebe782..a71ee8b 100644
--- a/libqdutils/qdMetaData.h
+++ b/libqdutils/qdMetaData.h
@@ -77,6 +77,7 @@
     struct IGCData_t igcData;
     struct Sharp2Data_t Sharp2Data;
     int64_t timestamp;
+    uint32_t refreshrate;
     enum ColorSpace_t colorSpace;
 };
 
@@ -89,6 +90,7 @@
     PP_PARAM_SHARP2     = 0x0020,
     PP_PARAM_TIMESTAMP  = 0x0040,
     UPDATE_BUFFER_GEOMETRY = 0x0080,
+    UPDATE_REFRESH_RATE = 0x0100,
     UPDATE_COLOR_SPACE = 0x0200,
 };