mm-video: vidc: Notify driver about FPS

If component notices that FPS has changed, the info needs to be
propagated to the driver for clock scaling purposes.

Change-Id: Ic3659b0e1093172a6732f7cdb7799400b7bbbd92
diff --git a/mm-video/vidc/vdec/src/omx_vdec_msm8974.cpp b/mm-video/vidc/vdec/src/omx_vdec_msm8974.cpp
index 8e10470..6c68e30 100644
--- a/mm-video/vidc/vdec/src/omx_vdec_msm8974.cpp
+++ b/mm-video/vidc/vdec/src/omx_vdec_msm8974.cpp
@@ -6719,21 +6719,23 @@
   {
     /* This is the error check for non-recoverable errros */
     bool is_duplicate_ts_valid = true;
+    bool is_interlaced = (drv_ctx.interlace != VDEC_InterlaceFrameProgressive);
+
     if (output_capability == V4L2_PIX_FMT_MPEG4 ||
       output_capability == V4L2_PIX_FMT_DIVX ||
       output_capability == V4L2_PIX_FMT_DIVX_311)
       is_duplicate_ts_valid = false;
-    if (buffer->nFilledLen > 0)
+
+    if (buffer->nFilledLen > 0) {
       time_stamp_dts.get_next_timestamp(buffer,
-      ((drv_ctx.interlace != VDEC_InterlaceFrameProgressive)
-        ?true:false) && is_duplicate_ts_valid);
-    else {
+        is_interlaced && is_duplicate_ts_valid);
+    } else {
       m_inp_err_count++;
       time_stamp_dts.remove_time_stamp(
               buffer->nTimeStamp,
-              ((drv_ctx.interlace != VDEC_InterlaceFrameProgressive)
-                ?true:false) && is_duplicate_ts_valid);
+                is_interlaced && is_duplicate_ts_valid);
     }
+
     if (m_debug_timestamp)
     {
       {
@@ -6755,7 +6757,6 @@
     {
       handle_extradata(buffer);
       if (client_extradata & OMX_TIMEINFO_EXTRADATA)
-        // Keep min timestamp interval to handle corrupted bit stream scenario
         set_frame_rate(buffer->nTimeStamp);
       else if (arbitrary_bytes)
         adjust_timestamp(buffer->nTimeStamp);
@@ -8379,7 +8380,25 @@
         DEBUG_PRINT_LOW("set_frame_rate: frm_int(%lu) fps(%f)",
                          frm_int, drv_ctx.frame_rate.fps_numerator /
                          (float)drv_ctx.frame_rate.fps_denominator);
+
         enableAdditionalCores(frm_int);
+        /* We need to report the difference between this FBD and the previous FBD
+         * back to the driver for clock scaling purposes. */
+        struct v4l2_outputparm oparm;
+        /*XXX: we're providing timing info as seconds per frame rather than frames
+         * per second.*/
+        oparm.timeperframe.numerator = drv_ctx.frame_rate.fps_denominator;
+        oparm.timeperframe.denominator = drv_ctx.frame_rate.fps_numerator;
+
+        struct v4l2_streamparm sparm;
+        sparm.type = V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE;
+        sparm.parm.output = oparm;
+        if (ioctl(drv_ctx.video_driver_fd, VIDIOC_S_PARM, &sparm))
+        {
+            DEBUG_PRINT_ERROR("Unable to convey fps info to driver, \
+                    performance might be affected");
+        }
+
       }
     }
   }