From patchwork Fri Jan 4 20:59:40 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Devin Heitmueller X-Patchwork-Id: 1934701 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 EFE2F3FF0F for ; Fri, 4 Jan 2013 21:00:09 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755110Ab3ADVAI (ORCPT ); Fri, 4 Jan 2013 16:00:08 -0500 Received: from mail-vb0-f46.google.com ([209.85.212.46]:61742 "EHLO mail-vb0-f46.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754944Ab3ADVAD (ORCPT ); Fri, 4 Jan 2013 16:00:03 -0500 Received: by mail-vb0-f46.google.com with SMTP id b13so16727205vby.5 for ; Fri, 04 Jan 2013 13:00:02 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=x-received:from:to:cc:subject:date:message-id:x-mailer:in-reply-to :references:x-gm-message-state; bh=y24+Nw1ecGh6nU49RK1EQR3ca06hARFjtCgeKspgkvQ=; b=i0U1QxDFTQ3nm6tjz+rnjS8lXU5gZwdGKsMxYhb4JVjXzqS76pSJkGw5DVymHiZ2ZA lcSYxoTkYhIDxCv9DlxEvIAskP/i/j4WpglIEwqI3eaUv+J8Zqt6BB6aaS9tm691DA4e Kj9tbN4N82QmZR2IMHxHTARsPE4KPQz2VcXFWsCNBAuT3nRmLWXEH9FOFlkAqAT0yYIH 45ma9v9xD9QRfgRYs77AASSeg4Eg/ZYEEpYprVTQhgUCwMGAtuh5a3/spPblAjo2boAG inHCY6Ph/tisKFolJ5L50UEQjVYId2F1d2o3OJAtrwNvxrMn0hhH8lmRdpGKjJhe8cWp RNjA== X-Received: by 10.220.209.74 with SMTP id gf10mr76509739vcb.10.1357333202177; Fri, 04 Jan 2013 13:00:02 -0800 (PST) Received: from devin-ubuntu2.home (pool-108-54-72-165.nycmny.fios.verizon.net. [108.54.72.165]) by mx.google.com with ESMTPS id z20sm47278440vds.12.2013.01.04.13.00.01 (version=TLSv1/SSLv3 cipher=OTHER); Fri, 04 Jan 2013 13:00:01 -0800 (PST) From: Devin Heitmueller To: linux-media@vger.kernel.org Cc: Devin Heitmueller , Hans Verkuil Subject: [PATCH 10/15] em28xx: fix broken TRY_FMT. Date: Fri, 4 Jan 2013 15:59:40 -0500 Message-Id: <1357333186-8466-11-git-send-email-dheitmueller@kernellabs.com> X-Mailer: git-send-email 1.7.9.5 In-Reply-To: <1357333186-8466-1-git-send-email-dheitmueller@kernellabs.com> References: <1357333186-8466-1-git-send-email-dheitmueller@kernellabs.com> X-Gm-Message-State: ALoCoQlx2F1Tbwb5v4dVE5TC+L6mGqjP/9+5oNI1DAWDZFq84erqgcnMJ+qlFXw+zaCh7rk3AiRR Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org TRY_FMT should not return an error if a pixelformat is unsupported. Instead just pick a common pixelformat. Also the bytesperline calculation was incorrect: it used the old width instead of the provided with, and it miscalculated the bytesperline value for the depth == 12 case. Signed-off-by: Hans Verkuil Signed-off-by: Devin Heitmueller --- drivers/media/usb/em28xx/em28xx-video.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/media/usb/em28xx/em28xx-video.c b/drivers/media/usb/em28xx/em28xx-video.c index a91a248..7c09b55 100644 --- a/drivers/media/usb/em28xx/em28xx-video.c +++ b/drivers/media/usb/em28xx/em28xx-video.c @@ -821,7 +821,7 @@ static int vidioc_try_fmt_vid_cap(struct file *file, void *priv, if (!fmt) { em28xx_videodbg("Fourcc format (%08x) invalid.\n", f->fmt.pix.pixelformat); - return -EINVAL; + fmt = format_by_fourcc(V4L2_PIX_FMT_YUYV); } if (dev->board.is_em2800) { @@ -847,7 +847,7 @@ static int vidioc_try_fmt_vid_cap(struct file *file, void *priv, f->fmt.pix.width = width; f->fmt.pix.height = height; f->fmt.pix.pixelformat = fmt->fourcc; - f->fmt.pix.bytesperline = (dev->width * fmt->depth + 7) >> 3; + f->fmt.pix.bytesperline = width * ((fmt->depth + 7) >> 3); f->fmt.pix.sizeimage = f->fmt.pix.bytesperline * height; f->fmt.pix.colorspace = V4L2_COLORSPACE_SMPTE170M; if (dev->progressive)