The attached patch introduces a simple way of measuring the current framerate 
by putting the value out via dmesg.

Note: I think the values are valid (they are betwwen 10 and 40 which fits) but 
I didn't do extensive tests or anything. The function is called by 
v4l_sn9c20x_read(). I don't know if mplayer just performs a v4l read very 1/30 
of a second or if the function is really called for each new frame. Also I am 
sure the fps calculation can be more precise.

Have fun,
GWater
From 79eb402574ee99edd430756dfe5cb039dba74f4f Mon Sep 17 00:00:00 2001
From: Josua Grawitter <[email protected]>
Date: Sun, 22 Feb 2009 23:22:31 +0100
Subject: [PATCH] TEST: Put out fps via dmesg

Signed-off-by: Josua Grawitter <[email protected]>
---
 sn9c20x-dev.c |   17 ++++++++++++++++-
 sn9c20x.h     |    1 +
 2 files changed, 17 insertions(+), 1 deletions(-)

diff --git a/sn9c20x-dev.c b/sn9c20x-dev.c
index 96964df..2229cc7 100644
--- a/sn9c20x-dev.c
+++ b/sn9c20x-dev.c
@@ -26,6 +26,7 @@
 
 #include <linux/errno.h>
 #include <linux/string.h>
+#include <linux/time.h>
 #include <stdarg.h>
 
 #include "sn9c20x.h"
@@ -231,7 +232,6 @@ int sn9c20x_initialize_sensor(struct usb_sn9c20x *dev)
 	return ret;
 }
 
-
 /**
  * @brief Wrapper function to detect hardware states
  *
@@ -245,6 +245,7 @@ int dev_sn9c20x_call_constantly(struct usb_sn9c20x *dev)
 	/* Know to be broken, temporarely disabled */
 	/*dev_sn9c20x_flip_detection(dev);*/
 	dev_sn9c20x_button_detection(dev);
+	dev_sn9c20x_measure_fps(dev);
 	if (!dev->camera.set_auto_exposure &&
 		dev->vsettings.auto_exposure) {
 		dev_sn9c20x_perform_soft_ae(dev);
@@ -253,6 +254,20 @@ int dev_sn9c20x_call_constantly(struct usb_sn9c20x *dev)
 	return 0;
 }
 
+int dev_sn9c20x_measure_fps(struct usb_sn9c20x *dev)
+{
+	int fps;
+	long microsec;
+	static long oldtime = 0;
+
+	microsec = (current_kernel_time().tv_nsec / 1000) - oldtime;
+	fps = 1000000 / microsec;
+
+	oldtime = current_kernel_time().tv_nsec / 1000;
+	UDIA_INFO("FPS: %d\n", fps);
+	return fps;
+}
+
 /**
  * @brief Wrapper function to detect a flipped sensor
  *
diff --git a/sn9c20x.h b/sn9c20x.h
index 27bab4a..6cbe442 100644
--- a/sn9c20x.h
+++ b/sn9c20x.h
@@ -389,6 +389,7 @@ int sn9c20x_initialize_sensor(struct usb_sn9c20x *dev);
 int sn9c20x_enable_video(struct usb_sn9c20x *dev, int enable);
 
 int dev_sn9c20x_call_constantly(struct usb_sn9c20x *dev);
+int dev_sn9c20x_measure_fps(struct usb_sn9c20x *dev);
 int dev_sn9c20x_flip_detection(struct usb_sn9c20x *dev);
 int dev_sn9c20x_button_detection(struct usb_sn9c20x *dev);
 int dev_sn9c20x_camera_set_exposure(struct usb_sn9c20x *);
-- 
1.6.0.6

Attachment: signature.asc
Description: This is a digitally signed message part.

Reply via email to