Received: by 2002:a05:6a10:9848:0:0:0:0 with SMTP id x8csp867897pxf; Thu, 18 Mar 2021 13:33:32 -0700 (PDT) X-Google-Smtp-Source: ABdhPJz40iy7PFkz9zssznolp7RI3G05xU08P2ZssXw85wifRbdDyhmQcIAcO2J8O8WJXA4FZ2J2 X-Received: by 2002:aa7:c3c1:: with SMTP id l1mr5945644edr.208.1616099612734; Thu, 18 Mar 2021 13:33:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1616099612; cv=none; d=google.com; s=arc-20160816; b=jDGWTHSmltyH/Gmt88p3dcJ5Zl41YHRP3qN2sLSRIn0pGvdW0TkFON+OokI7TsvFYH O5+hhn1gjJo55gy2FjLfu/p+JsocESbhuSSa5PT8hzgKL4zrvUHeQIk/wpmTRzxkgWbH Jbzh0Yr/xbW4TidfTxkUyEw/GcLFHHkvNNlYVaj85KoupM2iLjIJ8+9qQXwy35EXkCjt dZK7i6u1NH2DLSqGM3QZZPZyFd+CQtWoPk+sBEtaRQWXrpY3uy6eFfjZxsHKVRbaHZwi WXalsA/GD8m8Th+l365a/0p71X2OgNSC929owDYPjSBjQP137d2bwueM+5UsuYRU3ps/ xCvQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=LCfiO2M8eBv1nSfw6SX3LELyYme5LYmWED/jUeSNqLo=; b=mx9vae5IIkWe9PgHasuvNE9ut4Kwo0zHchiUtpiBqK8ePiaS7QS4GWXO/U1cn+wnOH M7t2TmUiAyh7WJHhw+JvGu7rCU67qtofpVT2cYg8sOreeiKvwdKQJx9HesuDP8P8FV1C nVVwZoCcM1ebxmQv+5RZYjqaRDyaiiK6KwypmNnxa6KWptsYfug2SqntWJhnIsgG1fO0 uv3nbpAKODTIEJmkXK7h9z0cmVMZlKWpFBczTbcW3W5K1k84Bl9vc0258w/Dy+pdlNLT 9wUFMqFz+9MaOApmZWqSWDb8NW3D1Nn2M8z2EqbkAad4P47sPEtVfUtYfXYPMLrLqGKG iqAg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=aOIHn6w8; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id dj7si2298224edb.378.2021.03.18.13.33.10; Thu, 18 Mar 2021 13:33:32 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=aOIHn6w8; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233150AbhCRUaT (ORCPT + 99 others); Thu, 18 Mar 2021 16:30:19 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48776 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233060AbhCRU3h (ORCPT ); Thu, 18 Mar 2021 16:29:37 -0400 Received: from mail-ed1-x533.google.com (mail-ed1-x533.google.com [IPv6:2a00:1450:4864:20::533]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6F9C8C061761 for ; Thu, 18 Mar 2021 13:29:37 -0700 (PDT) Received: by mail-ed1-x533.google.com with SMTP id z1so8303633edb.8 for ; Thu, 18 Mar 2021 13:29:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=LCfiO2M8eBv1nSfw6SX3LELyYme5LYmWED/jUeSNqLo=; b=aOIHn6w8I7Ce+5Zit+a6016P4K1j5BkH/IPWiDjGhBYNmy/sOAYVgqc4ppQxKjtgac dWBpYndGA7o8jC5sNw47W382yb1vINxptENpQpqvHq+bozYexflcqZ6lLy+4htl46fEZ TAukQQYZdjieafGPqZ01cg8dahNmfda1nIarA= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=LCfiO2M8eBv1nSfw6SX3LELyYme5LYmWED/jUeSNqLo=; b=NmfkYuhSnMBRUFR0KqwV89gE0VosvRR8n40hyBm5dNgbAYW7kNfpjeU/Ds0UtSJNn2 /WkirIX1vd/qMQLVAa/rfrESVnNOw5FgSXMSxyQgiQoZeArsCEXSHWzBuYN9x9x1X77b ZPSQgbWcxR7cX+cIbEdm+lvqYU99WAjrcqyhKSI0rF1Yl0QH7Pn5EF7mzNaC4Xz6bB84 u6TJQEWhJ9QorsruDLXq74YqX83TZfQbP1EBkxQ568BT7SkEiiv5S4izDpU1xanpUfn3 UX1HTbGVrRHH3IgclDwoYVPNAonRoAuEgUm7zdkrUVszbePQnlXgK2wAp8GERNisoMSF Uvgg== X-Gm-Message-State: AOAM5332gfCc2387skIrSUyUg9HxsN4EZODk1zm82+TRcpqPevJTlSue g6BNwtXGqDEfDmhFJvdPQFNI3w== X-Received: by 2002:aa7:c0cd:: with SMTP id j13mr6066463edp.41.1616099376253; Thu, 18 Mar 2021 13:29:36 -0700 (PDT) Received: from alco.lan ([80.71.134.83]) by smtp.gmail.com with ESMTPSA id a22sm2533767ejr.89.2021.03.18.13.29.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 18 Mar 2021 13:29:36 -0700 (PDT) From: Ricardo Ribalda To: Laurent Pinchart , Mauro Carvalho Chehab , Hans Verkuil , Sergey Senozhatsky , linux-media@vger.kernel.org, linux-kernel@vger.kernel.org, tfiga@chromium.org Cc: Ricardo Ribalda Subject: [PATCH v7 10/17] media: uvcvideo: Increase the size of UVC_METADATA_BUF_SIZE Date: Thu, 18 Mar 2021 21:29:21 +0100 Message-Id: <20210318202928.166955-11-ribalda@chromium.org> X-Mailer: git-send-email 2.31.0.rc2.261.g7f71774620-goog In-Reply-To: <20210318202928.166955-1-ribalda@chromium.org> References: <20210318202928.166955-1-ribalda@chromium.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hans has discovered that in his test device, for the H264 format bytesused goes up to about 570, for YUYV it will actually go up to a bit over 5000 bytes, and for MJPG up to about 2706 bytes. We should also, according to V4L2_META_FMT_UVC docs, drop headers when the buffer is full. Credit-to: Hans Verkuil Reviewed-by: Hans Verkuil Signed-off-by: Ricardo Ribalda --- drivers/media/usb/uvc/uvc_video.c | 8 +++++--- drivers/media/usb/uvc/uvcvideo.h | 2 +- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/drivers/media/usb/uvc/uvc_video.c b/drivers/media/usb/uvc/uvc_video.c index 25fd8aa23529..ea2903dc3252 100644 --- a/drivers/media/usb/uvc/uvc_video.c +++ b/drivers/media/usb/uvc/uvc_video.c @@ -1244,11 +1244,13 @@ static void uvc_video_decode_meta(struct uvc_streaming *stream, if (!meta_buf || length == 2) return; + /* + * According to V4L2_META_FMT_UVC docs, we should drop headers when + * the buffer is full. + */ if (meta_buf->length - meta_buf->bytesused < - length + sizeof(meta->ns) + sizeof(meta->sof)) { - meta_buf->error = 1; + length + sizeof(meta->ns) + sizeof(meta->sof)) return; - } has_pts = mem[1] & UVC_STREAM_PTS; has_scr = mem[1] & UVC_STREAM_SCR; diff --git a/drivers/media/usb/uvc/uvcvideo.h b/drivers/media/usb/uvc/uvcvideo.h index b81d3f65e52e..a26bbec8d37b 100644 --- a/drivers/media/usb/uvc/uvcvideo.h +++ b/drivers/media/usb/uvc/uvcvideo.h @@ -527,7 +527,7 @@ struct uvc_stats_stream { unsigned int max_sof; /* Maximum STC.SOF value */ }; -#define UVC_METADATA_BUF_SIZE 1024 +#define UVC_METADATA_BUF_SIZE 10240 /** * struct uvc_copy_op: Context structure to schedule asynchronous memcpy -- 2.31.0.rc2.261.g7f71774620-goog