From patchwork Wed Jun 29 02:17:35 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ezequiel Garcia X-Patchwork-Id: 9204221 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id EBE2960752 for ; Wed, 29 Jun 2016 02:17:57 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id DB06125819 for ; Wed, 29 Jun 2016 02:17:57 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id CDFCA2862F; Wed, 29 Jun 2016 02:17:57 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 71A1925819 for ; Wed, 29 Jun 2016 02:17:57 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752548AbcF2CRz (ORCPT ); Tue, 28 Jun 2016 22:17:55 -0400 Received: from mail-qt0-f182.google.com ([209.85.216.182]:35255 "EHLO mail-qt0-f182.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752449AbcF2CRy (ORCPT ); Tue, 28 Jun 2016 22:17:54 -0400 Received: by mail-qt0-f182.google.com with SMTP id f89so17855921qtd.2 for ; Tue, 28 Jun 2016 19:17:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=vanguardiasur-com-ar.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=p7pbSZMKPeVjZz8CIuw/eqS100EbRhXayLT85UwAolU=; b=ishel8rrDgAnKgyjCzJ/M6tA3rZgvlRdvcuov8FVItptHPs70sVNgoXP427kuSwvUt XBJpeCXkv6BKnviZQIJKpNgM7DhQRUoxagNyjROzwW2fLRhcCoozyiqE8Q885sJNUj+1 XLgbQuswv5Cl0PlzJwWXbvLIug8BgQBC2wm8txPI9IXBhwAh3OE1DjiiNXk1G7z5NvwG 3xxWbXQIe/Lj5m5s12S9G1nyqanF3m7B3eyJpNtP1Kxbk8b200lfCajnaOX7Ktx74vAD O4qlbR7Z4nejqNXDAyNb9Qb/qy1dK4ljZemXYoUAiSfVPCanxuSodTbqOj0ozYQxs09q 7ECQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=p7pbSZMKPeVjZz8CIuw/eqS100EbRhXayLT85UwAolU=; b=c6Z3lW8HQpqxJomhsAvPMHCT++SnziWkXvK2IvjoALf+EUtlirsU8LanfgAatqRbn/ iG2hMSTMswtmuvBtBmcjkh4voq7nwbpa/AN4ADnQ3BHtJSEXhRLqE4gGn9xa12+Mcjn1 Rrnb4fksCFfNtoB2YkqRkTcHXT3znh9NWmnwPYqZMtZmbwyDjZ0rhjOQabevoj/XSvmc Zz5Yq14oXQu2GpR1QvP4rTf6CHGk92zFXZFTkavE1l9KtFNomX3TmqGKDPm6J1k9D34S DFtvN12KNsT4wXJPFeAGN7BpmvINRRLuSdonjIDviOs6N1WQIPn1bHgSHjkMDdBPQAnI APYA== X-Gm-Message-State: ALyK8tIhMiAht+naDOjqK3jb91YQczZANF6FcaX8gnXzzhIRBst88C97DX/YPk/nYDVNSw== X-Received: by 10.200.45.28 with SMTP id n28mr8304844qta.79.1467166673593; Tue, 28 Jun 2016 19:17:53 -0700 (PDT) Received: from localhost.localdomain ([190.2.108.156]) by smtp.gmail.com with ESMTPSA id f137sm713460qka.43.2016.06.28.19.17.50 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 28 Jun 2016 19:17:52 -0700 (PDT) From: Ezequiel Garcia To: linux-media@vger.kernel.org Cc: mchehab@osg.samsung.com, Hans Verkuil , Ezequiel Garcia Subject: [PATCH 2/2] tw686x: Support VIDIOC_{S,G}_PARM ioctls Date: Tue, 28 Jun 2016 23:17:35 -0300 Message-Id: <20160629021735.24463-2-ezequiel@vanguardiasur.com.ar> X-Mailer: git-send-email 2.9.0 In-Reply-To: <20160629021735.24463-1-ezequiel@vanguardiasur.com.ar> References: <20160629021735.24463-1-ezequiel@vanguardiasur.com.ar> Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Now that the frame rate can be properly set, this commit adds support for S_PARM and G_PARM. Signed-off-by: Ezequiel Garcia --- drivers/media/pci/tw686x/tw686x-video.c | 46 ++++++++++++++++++++++++++++++--- 1 file changed, 43 insertions(+), 3 deletions(-) diff --git a/drivers/media/pci/tw686x/tw686x-video.c b/drivers/media/pci/tw686x/tw686x-video.c index 3131f9305313..40b5b835d452 100644 --- a/drivers/media/pci/tw686x/tw686x-video.c +++ b/drivers/media/pci/tw686x/tw686x-video.c @@ -437,9 +437,6 @@ static void tw686x_set_framerate(struct tw686x_video_channel *vc, { unsigned int i; - if (vc->fps == fps) - return; - i = tw686x_fps_idx(fps, TW686X_MAX_FPS(vc->video_standard)); reg_write(vc->dev, VIDEO_FIELD_CTRL[vc->ch], fps_map[i]); vc->fps = tw686x_real_fps(i, TW686X_MAX_FPS(vc->video_standard)); @@ -843,6 +840,12 @@ static int tw686x_s_std(struct file *file, void *priv, v4l2_std_id id) ret = tw686x_g_fmt_vid_cap(file, priv, &f); if (!ret) tw686x_s_fmt_vid_cap(file, priv, &f); + + /* + * Frame decimation depends on the chosen standard, + * so reset it to the current value. + */ + tw686x_set_framerate(vc, vc->fps); return 0; } @@ -912,6 +915,40 @@ static int tw686x_g_std(struct file *file, void *priv, v4l2_std_id *id) return 0; } +static int tw686x_g_parm(struct file *file, void *priv, + struct v4l2_streamparm *sp) +{ + struct tw686x_video_channel *vc = video_drvdata(file); + struct v4l2_captureparm *cp = &sp->parm.capture; + + if (sp->type != V4L2_BUF_TYPE_VIDEO_CAPTURE) + return -EINVAL; + sp->parm.capture.readbuffers = 3; + + cp->capability = V4L2_CAP_TIMEPERFRAME; + cp->timeperframe.numerator = 1; + cp->timeperframe.denominator = vc->fps; + return 0; +} + +static int tw686x_s_parm(struct file *file, void *priv, + struct v4l2_streamparm *sp) +{ + struct tw686x_video_channel *vc = video_drvdata(file); + struct v4l2_captureparm *cp = &sp->parm.capture; + unsigned int denominator = cp->timeperframe.denominator; + unsigned int numerator = cp->timeperframe.numerator; + unsigned int fps; + + if (vb2_is_busy(&vc->vidq)) + return -EBUSY; + + fps = (!numerator || !denominator) ? 0 : denominator / numerator; + if (vc->fps != fps) + tw686x_set_framerate(vc, fps); + return tw686x_g_parm(file, priv, sp); +} + static int tw686x_enum_fmt_vid_cap(struct file *file, void *priv, struct v4l2_fmtdesc *f) { @@ -998,6 +1035,9 @@ static const struct v4l2_ioctl_ops tw686x_video_ioctl_ops = { .vidioc_g_std = tw686x_g_std, .vidioc_s_std = tw686x_s_std, + .vidioc_g_parm = tw686x_g_parm, + .vidioc_s_parm = tw686x_s_parm, + .vidioc_enum_input = tw686x_enum_input, .vidioc_g_input = tw686x_g_input, .vidioc_s_input = tw686x_s_input,