From patchwork Tue Mar 16 17:59:59 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ricardo Ribalda X-Patchwork-Id: 403574 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-19.0 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER, INCLUDES_PATCH, MAILING_LIST_MULTI, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 30A39C43333 for ; Tue, 16 Mar 2021 18:01:14 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 11BA96513E for ; Tue, 16 Mar 2021 18:01:14 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231201AbhCPSBB (ORCPT ); Tue, 16 Mar 2021 14:01:01 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41330 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239553AbhCPSAS (ORCPT ); Tue, 16 Mar 2021 14:00:18 -0400 Received: from mail-ed1-x52d.google.com (mail-ed1-x52d.google.com [IPv6:2a00:1450:4864:20::52d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 50273C061756 for ; Tue, 16 Mar 2021 11:00:14 -0700 (PDT) Received: by mail-ed1-x52d.google.com with SMTP id bf3so22601845edb.6 for ; Tue, 16 Mar 2021 11:00:14 -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=gYcqtWKMtZJLdgQvmpvZydGXptgz+RLdUhBj7PmBM+VVMcC9mNJr9yC0Is0fmUwgrn U+qBgXrqkKRC2dz0ytPSbt+ugi5nBV9SZNnJWdEwsSOnssz+eNZJhVZI5Q3J8p3qFS2l kRYWXckn8pAXaIBixVbTAi+Bm4LMS5hk3abAa7W/oXi3EWLLTEFdrKN6QSt6UIxKiQJQ njfTPcQW813dB1Pk5ih0t3vva387GzSdNs9JvP04sgtoQQoz+ovti2e8rxrMwsEHtflX lKHRMPae7gD4pZIZJS2WRF4le0a4SJkpp/G1kZEw9sthPHCMmzIsI+nUGEyFhWd6Uo4f A2WA== X-Gm-Message-State: AOAM531Ovj23QxidXGtM1SIgoWvhyR16Cj/nNp7KcAtb1seprFzmvvrt xRjiUw3UnFpP+GWUqkqqz7XuQA== X-Google-Smtp-Source: ABdhPJyidFqGAtsSRIhb5eeZ2zyKtBnuaJ/1pdfjxhkunYfFNLYn7PsgoQPGWU+GTlxfhqyk3opEGg== 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 Precedence: bulk List-ID: X-Mailing-List: linux-media@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 Reviewed-by: Hans Verkuil --- 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