From patchwork Wed Mar 17 16:45:07 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ricardo Ribalda X-Patchwork-Id: 404377 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, 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 C66DBC433E9 for ; Wed, 17 Mar 2021 16:46:10 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 97D3E64F6C for ; Wed, 17 Mar 2021 16:46:10 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232647AbhCQQpk (ORCPT ); Wed, 17 Mar 2021 12:45:40 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56336 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232665AbhCQQpX (ORCPT ); Wed, 17 Mar 2021 12:45:23 -0400 Received: from mail-ed1-x536.google.com (mail-ed1-x536.google.com [IPv6:2a00:1450:4864:20::536]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 36C94C061760 for ; Wed, 17 Mar 2021 09:45:23 -0700 (PDT) Received: by mail-ed1-x536.google.com with SMTP id u4so3075539edv.9 for ; Wed, 17 Mar 2021 09:45:23 -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=XiofJ4gOsO7WAp+jv8oHLjsQ8od5HRXQfPGgLrEunER+Bt1XtcgiH1nM+oUWKvYWS9 049HI5zEij5AS8++RWPc160JBbLeHoamnw0YJx43WQkUr0v6x8guSq4dItZvNGP7EIXe XySuQwiBx+9e6CqnMsib+HQHE17noLBFTUIQM= 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=D1Gajamb5afz1lHcFU7Gj9vgceydDPJ38lMVWxqsnq/DwKTs30on7AlX5FVH9r2VKb hmdeih2jBygS0I65OSd5he1eDgDxVGXdt4SIjK3ihurljA5awl7AedMR4qGgpN8YJqWR +74+MEQrwv9ZjFrOOX9WbCvS7ZSi9N8pnhfjjssEajSa+UyT08P7UeV4SGNr6oUq+xis 5J7w4d2b/xkGlPagj6hDigD3oAtPwnRsT7cprzBkFJYFBWjBRxXPWjMFHbNl8PAEM57v drtd4AixsNvMea83IU2+KgPkDPHV5TVByjoB+hg7nMQ4KWZ17NB4ZH9CrrOK5LVSY8Dx AzIg== X-Gm-Message-State: AOAM5336q9IsTrrDti7Bqoioi642Q5pkp14omuxPXcOjui8ASEfA5pfz bL+ATbcSIYDPe3hCRhsZvlTnAg== X-Google-Smtp-Source: ABdhPJyr4+FDQhdh89BUmzSIjsRGqspGifOq9EFk98mTWNY5QzdbOWU/MzX74WAMHruIcCQ1orU0Hg== X-Received: by 2002:a05:6402:142:: with SMTP id s2mr42955620edu.2.1615999522029; Wed, 17 Mar 2021 09:45:22 -0700 (PDT) Received: from alco.lan ([80.71.134.83]) by smtp.gmail.com with ESMTPSA id hy25sm12088128ejc.119.2021.03.17.09.45.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 17 Mar 2021 09:45:21 -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 v6 13/17] media: uvcvideo: Increase the size of UVC_METADATA_BUF_SIZE Date: Wed, 17 Mar 2021 17:45:07 +0100 Message-Id: <20210317164511.39967-14-ribalda@chromium.org> X-Mailer: git-send-email 2.31.0.rc2.261.g7f71774620-goog In-Reply-To: <20210317164511.39967-1-ribalda@chromium.org> References: <20210317164511.39967-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 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