From patchwork Mon Aug 20 01:23:45 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ezequiel Garcia X-Patchwork-Id: 1345441 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 999E73FC33 for ; Mon, 20 Aug 2012 01:24:33 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752776Ab2HTBYb (ORCPT ); Sun, 19 Aug 2012 21:24:31 -0400 Received: from mail-gh0-f174.google.com ([209.85.160.174]:47453 "EHLO mail-gh0-f174.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752336Ab2HTBYa (ORCPT ); Sun, 19 Aug 2012 21:24:30 -0400 Received: by mail-gh0-f174.google.com with SMTP id r11so4807916ghr.19 for ; Sun, 19 Aug 2012 18:24:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id:x-mailer:in-reply-to:references; bh=c+Pe/tCx+TbPT1fk6ThJKta6R6JNAwH506erP5ZzyWY=; b=PbAnGU/9MIcdjTMyQ0RXXBWLgJPd7/7vz3hlmW1Y85Q70rmjmeKwYNu+6rOzzn2UJh wJIkfjUIyMtnNf8gQYoIZMjD+HcfYnYDQTEBOcr5arIxNtixrE9Z5PPtLaZfQbWZgiu2 kVG8VALhgQ+5qRyk7o+TZSurLVd6Q7a+XxdvwTkQ3UbeFU00kl3wK8uzRp+laibNSg4b gYnypqq5TPmqpwEA22WFvpvcPt/OOIWA7j2rB3RBissFOtfHCi3DGwHA7wADJ7XYLvKq j7+F7/xwQ7C/3gE9Zf1LdPEaJCOrNNiUm7LPsdvonu1prbLVEBXfDxxRr9gWvt39DQhA PdYg== Received: by 10.236.139.233 with SMTP id c69mr19457429yhj.9.1345425870446; Sun, 19 Aug 2012 18:24:30 -0700 (PDT) Received: from localhost.cpe.express.com.ar ([200.81.126.15]) by mx.google.com with ESMTPS id b46sm26820855yhm.3.2012.08.19.18.24.22 (version=TLSv1/SSLv3 cipher=OTHER); Sun, 19 Aug 2012 18:24:30 -0700 (PDT) From: Ezequiel Garcia To: , Mauro Carvalho Chehab Cc: Ezequiel Garcia Subject: [PATCH 3/4] stk1160: Fix s_fmt and try_fmt implementation Date: Sun, 19 Aug 2012 22:23:45 -0300 Message-Id: <1345425826-13429-3-git-send-email-elezegarcia@gmail.com> X-Mailer: git-send-email 1.7.8.6 In-Reply-To: <1345425826-13429-1-git-send-email-elezegarcia@gmail.com> References: <1345425826-13429-1-git-send-email-elezegarcia@gmail.com> Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org The driver was expecting to get a valid pixelformat on s_fmt and try_fmt. This is wrong, since the user may pass a bitmask and expect the driver to change it, returning a valid (fourcc) pixelformat. This problem was spotted by v4l2-compliance. Signed-off-by: Ezequiel Garcia --- drivers/media/usb/stk1160/stk1160-v4l.c | 12 ++---------- 1 files changed, 2 insertions(+), 10 deletions(-) diff --git a/drivers/media/usb/stk1160/stk1160-v4l.c b/drivers/media/usb/stk1160/stk1160-v4l.c index 1ad4ac1..63c5832 100644 --- a/drivers/media/usb/stk1160/stk1160-v4l.c +++ b/drivers/media/usb/stk1160/stk1160-v4l.c @@ -318,12 +318,6 @@ static int vidioc_try_fmt_vid_cap(struct file *file, void *priv, { struct stk1160 *dev = video_drvdata(file); - if (f->fmt.pix.pixelformat != format[0].fourcc) { - stk1160_err("fourcc format 0x%08x invalid\n", - f->fmt.pix.pixelformat); - return -EINVAL; - } - /* * User can't choose size at his own will, * so we just return him the current size chosen @@ -331,6 +325,7 @@ static int vidioc_try_fmt_vid_cap(struct file *file, void *priv, * TODO: Implement frame scaling? */ + f->fmt.pix.pixelformat = dev->fmt->fourcc; f->fmt.pix.width = dev->width; f->fmt.pix.height = dev->height; f->fmt.pix.field = V4L2_FIELD_INTERLACED; @@ -346,14 +341,11 @@ static int vidioc_s_fmt_vid_cap(struct file *file, void *priv, { struct stk1160 *dev = video_drvdata(file); struct vb2_queue *q = &dev->vb_vidq; - int rc; if (vb2_is_busy(q)) return -EBUSY; - rc = vidioc_try_fmt_vid_cap(file, priv, f); - if (rc < 0) - return rc; + vidioc_try_fmt_vid_cap(file, priv, f); /* We don't support any format changes */