From patchwork Fri May 3 19:54:57 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ismael Luceno X-Patchwork-Id: 2519091 Return-Path: X-Original-To: patchwork-linux-media@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork2.kernel.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by patchwork2.kernel.org (Postfix) with ESMTP id B7C49DF2E5 for ; Fri, 3 May 2013 19:55:35 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S934240Ab3ECTzd (ORCPT ); Fri, 3 May 2013 15:55:33 -0400 Received: from mail-gh0-f176.google.com ([209.85.160.176]:62662 "EHLO mail-gh0-f176.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S934217Ab3ECTzc (ORCPT ); Fri, 3 May 2013 15:55:32 -0400 Received: by mail-gh0-f176.google.com with SMTP id z17so342852ghb.21 for ; Fri, 03 May 2013 12:55:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=x-received:sender:from:to:cc:subject:date:message-id:x-mailer; bh=SRX4OhDouwCmM/+ZiPAqQfM9zf5fjD+VPKAVXBD2Cs0=; b=pXaR77rNH9W4Z52Fc3WwlefJiRddJ0pENAYKzxOw2ml0Ue3CsJuXu27wIH9ZCcpwE9 RFFDB5nTfaz4jzIc2LYf4z5bu/wAlf+Qw0Gv3uHWSpM8HL2+CwK/NY/bUi6TawbcMzfr EyCzlR8DLVXAgW5vSRijjEdIc/x79VvG1Ujdb+QKBen9ICfWwGhh0r2YgCJarmFGGJng /47RiL77hNILitE1NM0V5dUpwh8iuE/E97qKUDr6YWVG4vLHrqMSJwgcc/KyCpbck2Gk Vh53/Lq85lyV28nwitc/celxAEEImW9tz2M5IVmHkBkLXVZnUQCUo1R1ViK5FcohF4iy H3Hw== X-Received: by 10.236.16.202 with SMTP id h50mr10647559yhh.39.1367610932265; Fri, 03 May 2013 12:55:32 -0700 (PDT) Received: from localhost.localdomain ([170.51.69.64]) by mx.google.com with ESMTPSA id v27sm23311452yhj.12.2013.05.03.12.55.23 for (version=TLSv1 cipher=RC4-SHA bits=128/128); Fri, 03 May 2013 12:55:31 -0700 (PDT) From: Ismael Luceno To: linux-media@vger.kernel.org Cc: Hans Verkuil , Ismael Luceno Subject: [PATCH v2] solo6x10: Approximate frame intervals with non-standard denominator Date: Fri, 3 May 2013 16:54:57 -0300 Message-Id: <1367610897-29942-1-git-send-email-ismael.luceno@corp.bluecherry.net> X-Mailer: git-send-email 1.8.2.1 Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org Instead of falling back to 1/25 (PAL) or 1/30 (NTSC). Signed-off-by: Ismael Luceno --- drivers/staging/media/solo6x10/solo6x10-v4l2-enc.c | 38 +++++++++------------- 1 file changed, 15 insertions(+), 23 deletions(-) diff --git a/drivers/staging/media/solo6x10/solo6x10-v4l2-enc.c b/drivers/staging/media/solo6x10/solo6x10-v4l2-enc.c index 98e2902..a4c5896 100644 --- a/drivers/staging/media/solo6x10/solo6x10-v4l2-enc.c +++ b/drivers/staging/media/solo6x10/solo6x10-v4l2-enc.c @@ -996,12 +996,11 @@ static int solo_g_parm(struct file *file, void *priv, struct v4l2_streamparm *sp) { struct solo_enc_dev *solo_enc = video_drvdata(file); - struct solo_dev *solo_dev = solo_enc->solo_dev; struct v4l2_captureparm *cp = &sp->parm.capture; cp->capability = V4L2_CAP_TIMEPERFRAME; cp->timeperframe.numerator = solo_enc->interval; - cp->timeperframe.denominator = solo_dev->fps; + cp->timeperframe.denominator = solo_enc->solo_dev->fps; cp->capturemode = 0; /* XXX: Shouldn't we be able to get/set this from videobuf? */ cp->readbuffers = 2; @@ -1009,36 +1008,29 @@ static int solo_g_parm(struct file *file, void *priv, return 0; } +static inline int calc_interval(u8 fps, u32 n, u32 d) +{ + if (!n || !d) + return 1; + if (d == fps) + return n; + n *= fps; + return min(15U, n / d + (n % d >= (fps >> 1))); +} + static int solo_s_parm(struct file *file, void *priv, struct v4l2_streamparm *sp) { struct solo_enc_dev *solo_enc = video_drvdata(file); - struct solo_dev *solo_dev = solo_enc->solo_dev; - struct v4l2_captureparm *cp = &sp->parm.capture; + struct v4l2_fract *t = &sp->parm.capture.timeperframe; + u8 fps = solo_enc->solo_dev->fps; if (vb2_is_streaming(&solo_enc->vidq)) return -EBUSY; - if ((cp->timeperframe.numerator == 0) || - (cp->timeperframe.denominator == 0)) { - /* reset framerate */ - cp->timeperframe.numerator = 1; - cp->timeperframe.denominator = solo_dev->fps; - } - - if (cp->timeperframe.denominator != solo_dev->fps) - cp->timeperframe.denominator = solo_dev->fps; - - if (cp->timeperframe.numerator > 15) - cp->timeperframe.numerator = 15; - - solo_enc->interval = cp->timeperframe.numerator; - - cp->capability = V4L2_CAP_TIMEPERFRAME; - cp->readbuffers = 2; - + solo_enc->interval = calc_interval(fps, t->numerator, t->denominator); solo_update_mode(solo_enc); - return 0; + return solo_g_parm(file, priv, sp); } static long solo_enc_default(struct file *file, void *fh,