stepwise: Add ceiling type

Add a stepwise ceiling type, this is used as a
upper clipping curve to limit the max output based
on a temperature sensor. This is commonly used for
quiet fan mode where CPU throttling is allowed to
preserve a max fan noise.

Change-Id: I181d5913c92e5498a34e6d3f67cf99b67471479c
Signed-off-by: James Feist <james.feist@linux.intel.com>
diff --git a/pid/zone.cpp b/pid/zone.cpp
index fc0b40b..065e6d7 100644
--- a/pid/zone.cpp
+++ b/pid/zone.cpp
@@ -65,6 +65,16 @@
     _RPMSetPoints.push_back(setpoint);
 }
 
+void PIDZone::addRPMCeiling(double ceiling)
+{
+    _RPMCeilings.push_back(ceiling);
+}
+
+void PIDZone::clearRPMCeilings(void)
+{
+    _RPMCeilings.clear();
+}
+
 void PIDZone::clearRPMSetPoints(void)
 {
     _RPMSetPoints.clear();
@@ -116,6 +126,12 @@
         max = *result;
     }
 
+    if (_RPMCeilings.size() > 0)
+    {
+        result = std::min_element(_RPMCeilings.begin(), _RPMCeilings.end());
+        max = std::min(max, *result);
+    }
+
     /*
      * If the maximum RPM setpoint output is below the minimum RPM
      * setpoint, set it to the minimum.