Received: by 2002:a05:6a10:9848:0:0:0:0 with SMTP id x8csp4463816pxf; Tue, 16 Mar 2021 14:18:43 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzmVPgLOGtWdWIKIAu+81XOY/XZ5pjCRxj+WT8fFCaZje2v33mbE2br+f4K3W+/nHwpdkL9 X-Received: by 2002:a50:ec96:: with SMTP id e22mr38425939edr.385.1615929523024; Tue, 16 Mar 2021 14:18:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1615929523; cv=none; d=google.com; s=arc-20160816; b=Ebyj1paYDa9MkZ1TPFV7jLHSMdD1kXRzjo7Z8COD8LB6pzcCny62I3rEgIhNU8X6sa r2qZ1W/UM0gk8eYzqBbntxx0oSly/OqCy2yvjzC7O4NCuOwfkMDTbe8bwtpb78qrxW70 364sLqXMLsMAjRioU7Fq7EiDuCMjsBKJjmRhAFUFG5mdNjhvDMW6f3GXXNmR/+qwYpK2 A9VMM/Ib0AcsDJ/ZoXyV05DOTKWjMJWfF5yrE8zsxIXEKBHsAAXcJ5I888Cye2kcZ3Mc 2w5QDRBIWrIHFDSZeR8+LE6rIG+Knk/6ytcH1tVTfzXe1SMwOhH1QFAzhbcqqaA15frE 1iVg== 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=uql5w77wLpnV2YOZ1se1wNR76Twqh2llNjdWzvordg8=; b=vh+51dD407wFkD/9Ra+eVmpBNtt16mhcjDgj8zMDyRjGkTcvYy6FvkF60kz8Gpoidz XPfZ9ZeKrJ0yDSbD+CP2xbwJKMSzjL+L17rFpmENEI+dJlsuhqG66NylkwqoxJGz7BhA ZIBfsqsx8H1a9LsSN/oY3Alu/RJVZ2HO8b+KaBFDqz2sw+SINuWnCLwR1b+WasuXlLnv FSS5oUdXwzevPiaKHC5ALvbaAqFCgksdUt4mp8+ihEKRGiEbj6U9JuUki80zIsCiPP1q DeI5lGJev4jVTA8dShjdnlKkn4zN7bLsYnivuq0+GOD86sWI+wrChv2INCgNrz6rAwVT V6Hw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=cz1g4tJe; 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 ay5si15363612ejb.692.2021.03.16.14.18.20; Tue, 16 Mar 2021 14:18:43 -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=cz1g4tJe; 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 S232593AbhCPSDS (ORCPT + 99 others); Tue, 16 Mar 2021 14:03:18 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41324 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239593AbhCPSAb (ORCPT ); Tue, 16 Mar 2021 14:00:31 -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 E1DC1C0613E6 for ; Tue, 16 Mar 2021 11:00:18 -0700 (PDT) Received: by mail-ed1-x533.google.com with SMTP id z1so22636593edb.8 for ; Tue, 16 Mar 2021 11:00:18 -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=uql5w77wLpnV2YOZ1se1wNR76Twqh2llNjdWzvordg8=; b=cz1g4tJeNKq5CcfCkKPZiM4VI6PSB2mfgUlu/60S4qm1s+5wSwL6Is7oJ2SUBf/uLZ DnxT01IqNNiahMNiiPyI3K51ybwsRmT4TeYlcp9CIhpjIm8se8BR2lQoI+Mw7DNCvFyV Ubw1ODrdxtCEagRXcvzVEbTP0TSe8lT7uSHmI= 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=uql5w77wLpnV2YOZ1se1wNR76Twqh2llNjdWzvordg8=; b=CFkm4vVQuATaZyDFKjYliW2TXuQGfSupeSSvAJAwn3N5GJojG4d0x8DOyvTGcO6boi MPzQ6L90JoX6L6CnBEYzVgbOQCgC/+3DZYsxBDSWTpQBs6FOV/Z/UykqQtcYIPISGqk8 1HNah4A7OVlOffdSeEDaeTkszgRBuQ5nh2PVvO9AT0uxuk7KQCxg2tFi15delX3hd6Se /lSRAprenRFz5E8peBmMWbQWR8G/kWX1FmeG0Or8Sut7RhC7G8kWTmc8EiTiiHHf0J+3 AcBcQdKuc50NG9BWO/jIIdVPd4MbJwqIuZuq79e/sBR8GEshSkBihKTx6CKWCLQZ+1za QFyg== X-Gm-Message-State: AOAM530U1yDlNwDMocoQFBq/m33lwUrQX434wH2kfEkbsvDqLMcrpyU4 EvVAQyQZMd7oFTs1w0Qc/dawxA== X-Received: by 2002:a50:fa92:: with SMTP id w18mr37217544edr.172.1615917612789; Tue, 16 Mar 2021 11:00:12 -0700 (PDT) Received: from alco.lan ([80.71.134.83]) by smtp.gmail.com with ESMTPSA id c19sm10953182edu.20.2021.03.16.11.00.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 16 Mar 2021 11:00:12 -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 v5 09/13] media: uvcvideo: Increase the size of UVC_METADATA_BUF_SIZE Date: Tue, 16 Mar 2021 18:59:59 +0100 Message-Id: <20210316180004.1605727-10-ribalda@chromium.org> X-Mailer: git-send-email 2.31.0.rc2.261.g7f71774620-goog In-Reply-To: <20210316180004.1605727-1-ribalda@chromium.org> References: <20210316180004.1605727-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 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