Received: by 2002:a05:6a10:9848:0:0:0:0 with SMTP id x8csp525156pxf; Wed, 17 Mar 2021 09:46:56 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxlewplwgPBI/RTxIh6d7pIQLOiTM9kSco8DAQSA+DYE4G7fxQdGVroDEzcjXtirHtgZCrL X-Received: by 2002:a05:6402:34c8:: with SMTP id w8mr44896476edc.235.1615999616414; Wed, 17 Mar 2021 09:46:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1615999616; cv=none; d=google.com; s=arc-20160816; b=NzC0Pskuo2+DhnmHw8qYZElZCiriWuPfXnNCwVJ+VzjpvwsDXfRcQoQPmhtb+96FO/ ywOK1ukEVDSgHlRFOLtRau1HR/TqhmZjHeyfqN1yHzSA2LxDU2BkR1yDnWZOxL/uEZvL q13YXZmOZ2VsQvlWD+apKc9dlhpIOP6nWvK20pAF5OF+5/kzGsne3Qbra3eqEsDX16kV vF/wdA0Zbtwupuxi/pTvo1TiFUlJMGILODdCf846M0+PRDL6xreTN5cf3pnXYr1yHmS3 o2NYdhFQ7cbpCOg4F1uHDrAwm/sMlKc57u98C/UvLhlet7s2TJMoF/9lWeoIZg7tOh/i BNbQ== 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=vwrTDh1gsHJ0b6DMKEGg13ylb0YvlSG0z9ssm2dyJzrxpEsL9xnMQ/wHyZ9qY/jm+Q n69WN/8RBWh1Jy2YQo1wZ1i2EfeIVG7FJdY1hbzOFnDtw7gMM3ii+tZz7rMdFybIgKSR frtF9GxK2V5vfY5rUTwVlsrZwXxsYViVdH8uvAaqrGsAyn3jUAypnToSxmDhWjlugWfb ygbKimN177TkZ8kZmDkU/I1drz9rbcVGEJ4tMSVLmIf8LUBRFan8PZwi28BVAoFUdOtL HR8mdakP0Z51jdNnM/w5W37nEew0ZgkZ57NwyqhZS6O+99JW9uxpv/iHxFXkDKd30i83 /M6g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=XiofJ4gO; 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 r11si15838747eja.563.2021.03.17.09.46.32; Wed, 17 Mar 2021 09:46: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=@chromium.org header.s=google header.b=XiofJ4gO; 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 S232810AbhCQQpu (ORCPT + 99 others); Wed, 17 Mar 2021 12:45:50 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56338 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232666AbhCQQpX (ORCPT ); Wed, 17 Mar 2021 12:45:23 -0400 Received: from mail-ed1-x531.google.com (mail-ed1-x531.google.com [IPv6:2a00:1450:4864:20::531]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 37DDAC061762 for ; Wed, 17 Mar 2021 09:45:23 -0700 (PDT) Received: by mail-ed1-x531.google.com with SMTP id h13so3087022eds.5 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=FesAkNB0jSJaqxheeiANMRVIaBQJWNMkP0ghDoH1sqy1DFY+66DtO9SQ6i5/RajuKy OZJoqcTJDAqiY9KzP6GKDTc8zhbqrw4c7Nrkgik9ua+7wRpUC18fmfi0FMnTJCU3qv/n agCOIcVT8PHJwJR60em9/UOwzmxeU/JrlCbM5t9ssr4k8dwJTvY5eZIXuZnCEMw9Bap8 VgNIMMhNI/K7Rnx4zPWlJO0aKeZ78jSCucT1eEs5BHiK7dAE1o5XFmQXqUuYdPcll0S+ dnZr72MfUoXGdxoVVX2KWweuHBcySm2ZmGHwa7wQw1wp+OJ4ogo3Fqd8HXqmad0nRwri LF+g== X-Gm-Message-State: AOAM532BuspKugdnxwUU4lnv41Of6dIEfEP6UyZMk+qz3TI450uVu/+I RtUWLMHOn3GdWtc+G+16ANgD1w== 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 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