Received: by 2002:a05:6a10:9848:0:0:0:0 with SMTP id x8csp230456pxf; Wed, 17 Mar 2021 04:03:56 -0700 (PDT) X-Google-Smtp-Source: ABdhPJz1qMRMk++5QRI/owxDzOB3Q563RUcJ38F1LFKMsghdL79uJpRESuLIYV00vLATgtcITK5e X-Received: by 2002:a17:906:5949:: with SMTP id g9mr2856985ejr.518.1615979036358; Wed, 17 Mar 2021 04:03:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1615979036; cv=none; d=google.com; s=arc-20160816; b=lm9pfPJAVyoYCrHrY3V98gj9r7oBvi2NarmREhP+vD2NtmxpPrf/V1a19bxZKlXkTV 4QVpxSagkkREC2hSqbInf52e4etw9ShdCxV/3Qo2b3TFGJJIPd61EVSIeAERgHIkyG/w hXjNNaK0TpUiOUqYxRT/qZ6w3Q42DQZCG1zHhyvVFDi/u1lJDclf5F7dLS6YBK62DDZx OWFf+vScZY6tt0+bbnk7eHa6y/wsCFtunQbNBEwBrSGWSEhPUIJlzHzfRcMoM6fvSWuR 17qRob9MXuz1UmoqD59NMfey8p3Bf63YBSM8yj9+6yKygFFNgIRbIM7JtrMIl0cHjxxL iyCw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:content-language :in-reply-to:mime-version:user-agent:date:message-id:from:references :to:subject:dkim-signature; bh=Ml7yWiRnEU9Qi8mrPLCFfRMAvMoeAP/r67JD0AsEGao=; b=dCnvpMhwvt/KaONvddBFnRfEKZz7IXC43nZA/M8f8nx6AXKimfM8SCjzpRAoV+IbIL Z4NtogyiEXg8XvdX6oBecxuomvoWqBiQhgiARBdD8uc/7ROm9zEPVkQqf6PGIO6PQhUd 5yFRvH9uT5bEW1WBWzdAPtEujMfdQdqv46s5QukSSnW1rPjMGQPC0e3q6FGCyLjYZI/8 Ma9Ru4gQMY6P6EaPibgCX2bNJcRO7sCyulUFlzaQvKSHJwr14xur7C726fOiU9Hd0VAm d+n0vLT2sOV//Cwl57kGBZaJimmCco7HMiQR8ub5VD0VAoHX0sfpckXkhoZ3p2w+mCxD jtyQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@xs4all.nl header.s=s2 header.b=M0nxtMh0; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id v2si15018329ejg.251.2021.03.17.04.03.32; Wed, 17 Mar 2021 04:03:56 -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=@xs4all.nl header.s=s2 header.b=M0nxtMh0; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231167AbhCQLCL (ORCPT + 99 others); Wed, 17 Mar 2021 07:02:11 -0400 Received: from lb2-smtp-cloud9.xs4all.net ([194.109.24.26]:60465 "EHLO lb2-smtp-cloud9.xs4all.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231182AbhCQLBo (ORCPT ); Wed, 17 Mar 2021 07:01:44 -0400 Received: from cust-b5b5937f ([IPv6:fc0c:c16d:66b8:757f:c639:739b:9d66:799d]) by smtp-cloud9.xs4all.net with ESMTPA id MTvnlAI5vGEYcMTvqlNDOV; Wed, 17 Mar 2021 12:01:42 +0100 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=xs4all.nl; s=s2; t=1615978902; bh=Ml7yWiRnEU9Qi8mrPLCFfRMAvMoeAP/r67JD0AsEGao=; h=Subject:To:From:Message-ID:Date:MIME-Version:Content-Type:From: Subject; b=M0nxtMh07R/KPRfkp0WfG3gd74jFKUquRDuw7n+qjvxh8mwO92Wmvyoh6ftxAHPX0 vOQ0m0Y0tHUs3nPv/bC2Q9vHr1rQkH8A8ADdN/XSAkKUZFexlaUbuvusr/xfs22rj7 t2In7AFzdm/48jgxAH79VtLA0EqD6pCrp5108gIrOystq/t8l2LrexouU1ck2D4zlx Pxfru/9K8sUVIM9ZUm3K0f9DlRQYtNJsZwq+Tl2XX0vV6fMbwCi6ioFxDWfz+Ppteh sCJc0tmIWw0BuXoP92HsQEIJGP/0EyX6NY9tbVRfBsaEGUVwR/0Gs6XvSBZhFhBZ/P Un5xz/hOpY3kw== Subject: Re: [PATCH v5 09/13] media: uvcvideo: Increase the size of UVC_METADATA_BUF_SIZE To: Ricardo Ribalda , Laurent Pinchart , Mauro Carvalho Chehab , Sergey Senozhatsky , linux-media@vger.kernel.org, linux-kernel@vger.kernel.org, tfiga@chromium.org References: <20210316180004.1605727-1-ribalda@chromium.org> <20210316180004.1605727-10-ribalda@chromium.org> From: Hans Verkuil Message-ID: <944ff35a-799d-63f4-46f3-458d69863830@xs4all.nl> Date: Wed, 17 Mar 2021 12:01:39 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Firefox/78.0 Thunderbird/78.7.1 MIME-Version: 1.0 In-Reply-To: <20210316180004.1605727-10-ribalda@chromium.org> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit X-CMAE-Envelope: MS4xfG72MBNiJ29w33XLXDH2CDm9sfkLjlbOFI9cFdh7FC32V26NR6XTfv63yxY3PdWwlGKhipVnKbIVTliOsJGtrzZqivY/MetHxStHqRwAUNbU8gqm/QBI W8pxZGmJuR9ge729V+KWzgKiilFpI3R41pVOySWduoY65kJxcmGik4yrzPWz6AEjCKuLevCgFRZ/kOvuYFrkzt4LiC6KEqLnNBRA/75/URdVKcjLKCM98FyP QnANXdCuu571dkbeupL9rx8QBgwPwVIQ7X7bBbL7xgOYieooy6SHCeZHGvVD0OlI8FtM8r6IDl+hlknxe/n3q2bKWt6+ATuj7TfEbWV0yc1Z3gDE7XUzDZGm BlyCovRTsfZ12zLXZGZIaTjut3UHMZjxYqBSArwPa/XRfI8EVAEbZ2XoA9h+WnTeuG6PdK/e Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 16/03/2021 18:59, Ricardo Ribalda wrote: > 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 > Reviewed-by: Hans Verkuil Thanks! Hans