From patchwork Mon Oct 22 13:54:44 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kirill Smelkov X-Patchwork-Id: 1626071 Return-Path: X-Original-To: patchwork-linux-media@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork1.kernel.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by patchwork1.kernel.org (Postfix) with ESMTP id 16EA4400E8 for ; Mon, 22 Oct 2012 14:06:00 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754662Ab2JVOF5 (ORCPT ); Mon, 22 Oct 2012 10:05:57 -0400 Received: from mail.mnsspb.ru ([84.204.75.2]:39124 "EHLO mail.mnsspb.ru" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754286Ab2JVOF4 (ORCPT ); Mon, 22 Oct 2012 10:05:56 -0400 Received: from [192.168.0.127] (helo=tugrik.mns.mnsspb.ru) by mail.mnsspb.ru with esmtps id 1TQISA-0004vg-MX; Mon, 22 Oct 2012 17:54:02 +0400 Received: from kirr by tugrik.mns.mnsspb.ru with local (Exim 4.72) (envelope-from ) id 1TQIT4-0008F1-G0; Mon, 22 Oct 2012 17:54:58 +0400 From: Kirill Smelkov To: Mauro Carvalho Chehab Cc: linux-media@vger.kernel.org, Kirill Smelkov Subject: [PATCH 2/2] [media] vivi: Teach it to tune FPS Date: Mon, 22 Oct 2012 17:54:44 +0400 Message-Id: <1350914084-31618-2-git-send-email-kirr@mns.spb.ru> X-Mailer: git-send-email 1.8.0.rc3.331.g5b9a629 In-Reply-To: <1350914084-31618-1-git-send-email-kirr@mns.spb.ru> References: <1350914084-31618-1-git-send-email-kirr@mns.spb.ru> Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org I was testing my video-over-ethernet subsystem today, and vivi seemed to be perfect video source for testing when one don't have lots of capture boards and cameras. Only its framerate was hardcoded to NTSC's 30fps, while in my country we usually use PAL (25 fps). That's why the patch. Thanks. Signed-off-by: Kirill Smelkov --- drivers/media/platform/vivi.c | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/drivers/media/platform/vivi.c b/drivers/media/platform/vivi.c index 3e6902a..48325f4 100644 --- a/drivers/media/platform/vivi.c +++ b/drivers/media/platform/vivi.c @@ -36,10 +36,6 @@ #define VIVI_MODULE_NAME "vivi" -/* Wake up at about 30 fps */ -#define WAKE_NUMERATOR 30 -#define WAKE_DENOMINATOR 1001 - #define MAX_WIDTH 1920 #define MAX_HEIGHT 1200 @@ -58,6 +54,11 @@ static unsigned n_devs = 1; module_param(n_devs, uint, 0644); MODULE_PARM_DESC(n_devs, "number of video devices to create"); +static struct v4l2_fract fps = { 30000, 1001 }; /* ~ 30 fps by default */ +static unsigned __fps[2], __nfps; +module_param_array_named(fps, __fps, uint, &__nfps, 0644); +MODULE_PARM_DESC(fps, "frames per second as ratio (e.g. 30000,1001 or 25,1)"); + static unsigned debug; module_param(debug, uint, 0644); MODULE_PARM_DESC(debug, "activates debug info"); @@ -661,7 +662,7 @@ static void vivi_thread_tick(struct vivi_dev *dev) } #define frames_to_ms(frames) \ - ((frames * WAKE_NUMERATOR * 1000) / WAKE_DENOMINATOR) + ((frames * fps.denominator * 1000) / fps.numerator) static void vivi_sleep(struct vivi_dev *dev) { @@ -1376,6 +1377,13 @@ static int __init vivi_init(void) if (n_devs <= 0) n_devs = 1; + if (__nfps > 0) { + fps.numerator = __fps[0]; + fps.denominator = (__nfps > 1) ? __fps[1] : 1; + } + if (fps.numerator <= 0) + fps.numerator = 1; + for (i = 0; i < n_devs; i++) { ret = vivi_create_instance(i); if (ret) {