From patchwork Sun Sep 29 18:59:27 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Grzeschik X-Patchwork-Id: 831830 Received: from metis.whiteo.stw.pengutronix.de (metis.whiteo.stw.pengutronix.de [185.203.201.7]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id A42DE6E2AE for ; Sun, 29 Sep 2024 18:59:37 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=185.203.201.7 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727636382; cv=none; b=cNvp00Nnn5VRXQKk3PSMDHR9Vt48JtG1Z8tOmqC7bglIU6/xWGUAYEr7qTc4qt+dNpfDJUF7hgaBpjh+HWtCVftVdAg4E3vhs2agukD5hhE2VBm4C3sUS+qygse6lnDCRTEyFqNbi0l1gOv/pIykEeDf8CfcMKSR9xCCPr5cYpg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727636382; c=relaxed/simple; bh=vDOpCLv2CodGLKEpn/CIA0Ki8MmgeH3jN/oYwO6TfJ4=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=mNOTE6BZemernjO+qZdaX5/HLJ+xNseDPC1EHWw3UlwNq4U2pH9Ganavxz4vzVKT+U/0pZp6DuJU+oTgk/La7E0rnAo58WanjVwNvR1v8ccOnQYyzM7h3YOZxkroXm1Ae03D4JaLotrwABxVO6k8w7pO332jzoDRlCdQds3zIkU= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=pengutronix.de; spf=pass smtp.mailfrom=pengutronix.de; arc=none smtp.client-ip=185.203.201.7 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=pengutronix.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=pengutronix.de Received: from drehscheibe.grey.stw.pengutronix.de ([2a0a:edc0:0:c01:1d::a2]) by metis.whiteo.stw.pengutronix.de with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1suz8l-00053q-KM; Sun, 29 Sep 2024 20:59:31 +0200 Received: from [2a0a:edc0:0:1101:1d::ac] (helo=dude04.red.stw.pengutronix.de) by drehscheibe.grey.stw.pengutronix.de with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1suz8l-002Ro9-0s; Sun, 29 Sep 2024 20:59:31 +0200 Received: from localhost ([::1] helo=dude04.red.stw.pengutronix.de) by dude04.red.stw.pengutronix.de with esmtp (Exim 4.96) (envelope-from ) id 1suz8k-0029Vj-31; Sun, 29 Sep 2024 20:59:30 +0200 From: Michael Grzeschik Date: Sun, 29 Sep 2024 20:59:27 +0200 Subject: [PATCH v6 7/9] usb: gadget: uvc: set nbuffers to minimum STREAMING_MIN_BUFFERS in uvc_queue_setup Precedence: bulk X-Mailing-List: linux-usb@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20240403-uvc_request_length_by_interval-v6-7-08c05522e1f5@pengutronix.de> References: <20240403-uvc_request_length_by_interval-v6-0-08c05522e1f5@pengutronix.de> In-Reply-To: <20240403-uvc_request_length_by_interval-v6-0-08c05522e1f5@pengutronix.de> To: Laurent Pinchart , Daniel Scally , Greg Kroah-Hartman , Avichal Rakesh , Jayant Chowdhary Cc: linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org, kernel@pengutronix.de, Michael Grzeschik X-Mailer: b4 0.12.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=1928; i=m.grzeschik@pengutronix.de; h=from:subject:message-id; bh=vDOpCLv2CodGLKEpn/CIA0Ki8MmgeH3jN/oYwO6TfJ4=; b=owEBbQKS/ZANAwAKAb9pWET5cfSrAcsmYgBm+aORsM89Bni7vKaUD/qPI80rRYmZGWy9Rh52m 4mCe1TQJLqJAjMEAAEKAB0WIQQV2+2Fpbqd6fvv0Gi/aVhE+XH0qwUCZvmjkQAKCRC/aVhE+XH0 qwgSD/wPcPsDKNVphESBHZPbJMp4JgvWOw37Xa9EBmM+e3SDYuEmcZWVOI/cZSwEEBww7klDLFP AqjPzXtJGCqxaCn33AMtp5e0bJNhr83bonSn1epfwrc67u4BslyR9ZM4CkdLHp1ZrZaodeG7l1L 0kpJGFjbmCLIXMSDLhfcPxcB7i8jZQWKH+YWTno1C42bNh7Ui0VfcOfhubTq6n54LdCLTPlmcwW M6c7EkczeCCARyOJrGhepZl/ijLw/hS+4SU2ef5ldoJts9D89ws7+JiVIFRrCXwukpcVXCa0Pfc nanbrgS6L4i8MSzIkQ3axtvgPtEXLy02hfOCp19lOHMlhV2D0tQIjPiGuTMKpkE1UWI0ijnT+yV xIRKAvdpl6/80OSXihT6n2UdsIuw87RRx5oN83WldDPL/oSWUIJEiyekwI/akmiEF0y+e1ydMxG WG5VcxMuIx7kfuLGNXjnbaoBBMx59d620ve+IEPvDSDD9WBlDJYQ/15A/2M/WLB+iSxAT6UWQN5 l+ETST3KIB4tVtQ0pAxCQqH3WLwSjJ8DmuQBPl78CB/bz6dJtezuoETSNk12UbcdHisYvMJvrZd Ru4ZtsXn8nzf1P5sRv/2vfcaTl+YJyCl+j2PKv/CPpRaf1Jcd1qjcaCsxRsLQqsmS3V7sNe17R+ n32ZctIf26wLSEA== X-Developer-Key: i=m.grzeschik@pengutronix.de; a=openpgp; fpr=957BC452CE953D7EA60CF4FC0BE9E3157A1E2C64 X-SA-Exim-Connect-IP: 2a0a:edc0:0:c01:1d::a2 X-SA-Exim-Mail-From: m.grzeschik@pengutronix.de X-SA-Exim-Scanned: No (on metis.whiteo.stw.pengutronix.de); SAEximRunCond expanded to false X-PTX-Original-Recipient: linux-usb@vger.kernel.org We set the minimum amount of v4l2 buffers that is possibly be pending to UVCG_STREAMING_MIN_BUFFERS which is two. This way the driver will always have at least one frame pending to be encoded while the other is being enqueued in the hardware. Signed-off-by: Michael Grzeschik --- v5 -> v6: - v4 -> v5: - using STREAMING_MIN_BUFFERS set the min nbuffers - renamed the patch since the function changed - removed the g_ctrl function - reordered this patch in the series v1 -> v4: - --- drivers/usb/gadget/function/uvc.h | 2 ++ drivers/usb/gadget/function/uvc_queue.c | 3 +++ 2 files changed, 5 insertions(+) diff --git a/drivers/usb/gadget/function/uvc.h b/drivers/usb/gadget/function/uvc.h index bedb4ef42864f..6f44dd7323150 100644 --- a/drivers/usb/gadget/function/uvc.h +++ b/drivers/usb/gadget/function/uvc.h @@ -74,6 +74,8 @@ extern unsigned int uvc_gadget_trace_param; #define UVCG_REQ_MAX_INT_COUNT 16 #define UVCG_REQ_MAX_ZERO_COUNT (2 * UVCG_REQ_MAX_INT_COUNT) +#define UVCG_STREAMING_MIN_BUFFERS 2 + /* ------------------------------------------------------------------------ * Structures */ diff --git a/drivers/usb/gadget/function/uvc_queue.c b/drivers/usb/gadget/function/uvc_queue.c index 6757a4e25a743..5eaeae3e2441c 100644 --- a/drivers/usb/gadget/function/uvc_queue.c +++ b/drivers/usb/gadget/function/uvc_queue.c @@ -21,6 +21,7 @@ #include #include "uvc.h" +#include "uvc_video.h" /* ------------------------------------------------------------------------ * Video buffers queue management. @@ -47,6 +48,8 @@ static int uvc_queue_setup(struct vb2_queue *vq, if (*nbuffers > UVC_MAX_VIDEO_BUFFERS) *nbuffers = UVC_MAX_VIDEO_BUFFERS; + if (*nbuffers < UVCG_STREAMING_MIN_BUFFERS) + *nbuffers = UVCG_STREAMING_MIN_BUFFERS; *nplanes = 1;