Received: by 2002:a05:7412:40d:b0:e2:908c:2ebd with SMTP id 13csp283042rdf; Tue, 21 Nov 2023 02:37:54 -0800 (PST) X-Google-Smtp-Source: AGHT+IFNHNA48Jy9pJUdqG6JN/aZYo44xmNApUj/ZMQGogxFzV7oBrm61V5rYy6qFyVhUeOp5Xnj X-Received: by 2002:a05:6a21:612:b0:187:858b:8c17 with SMTP id ll18-20020a056a21061200b00187858b8c17mr6645505pzb.2.1700563074537; Tue, 21 Nov 2023 02:37:54 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1700563074; cv=none; d=google.com; s=arc-20160816; b=zTmvUSkVJQs3vRX1tKbpRwSFD3DA9Ot2MaF8YQaHl4e24KlR/rwIPP9CFTIVE4j6s+ Meeb13A0Fh17rgfP+heaPdl/8ASVrUFGsNIGLfpe5A6tQHTkMES3OB1GbxsQfG9yAsO3 DLdUUjb77MYLxpl1nQnTOLGEcJKRmCLAMFR3Xm4xghIcibDV2GGFceOCXXQMr4yuSATl hbjw4IWUZah8jGOVKv2xzhGj46IO85Pnhqzq4cUWAAdhpsaTQvwcuJvEY4SEa7Cp8Gp5 gO9uiO2JSfR1Dlj1pBzSs+aW3Cp4Qta0GJxy+2K9hZWDlrz5Bif4qqSNtCPoFdHLCKzK 9oPw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :references:cc:to:content-language:subject:user-agent:mime-version :date:message-id; bh=xSF+WGCs0CfHNAeHqqQiPOjKYkAbxv8gf/yTa2zXW6k=; fh=xrmAatfEtOcvL1kG+A4sluQLY5/rf2CRPrXKlaucZ7U=; b=ttpX22MHgwQ4Tm/zGOSx0y2xZZP6n+IHHEcCXf8TuFj9OMsSDn+vGOqSeyuRj/f5zR O1eekVIrIpsA4nP3hmU/38TnFUYxaE8pjS7rrMmgeJSuyMWli2lm4lnRl9Gw88c9CNDz yXAsnfEKRdh6JdVQuHsPhD7HY8TjJCsZzP60PrqiHX9UYGruyTXZ4T3ZRUZiMfuOaRsn zdZTtxhKQVzBqHLilEATNJvAyeCfg7dWzdmLz8gPlzCzPJyqg/J68UFeaC3xlt1cwII6 WCe3z4KTs3oSs640fRiuCSu3O5kCNLkZ72YF+atb9ECeIJAQx0NsVIxluS3JbQIt3jVX GQhg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.35 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=xs4all.nl Return-Path: Received: from groat.vger.email (groat.vger.email. [23.128.96.35]) by mx.google.com with ESMTPS id gp1-20020a17090adf0100b002803e634e13si12559002pjb.151.2023.11.21.02.37.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 21 Nov 2023 02:37:54 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.35 as permitted sender) client-ip=23.128.96.35; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.35 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=xs4all.nl Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by groat.vger.email (Postfix) with ESMTP id DBAD18044419; Tue, 21 Nov 2023 02:37:47 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at groat.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234079AbjKUKh2 (ORCPT + 99 others); Tue, 21 Nov 2023 05:37:28 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45718 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233923AbjKUKhN (ORCPT ); Tue, 21 Nov 2023 05:37:13 -0500 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8CB6B10EB for ; Tue, 21 Nov 2023 02:36:56 -0800 (PST) Received: by smtp.kernel.org (Postfix) with ESMTPSA id CA44CC433C7; Tue, 21 Nov 2023 10:36:54 +0000 (UTC) Message-ID: <995f8f26-ed20-44d2-a76a-e354fc68d65e@xs4all.nl> Date: Tue, 21 Nov 2023 11:36:53 +0100 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v3] media: uvcvideo: Implement V4L2_EVENT_FRAME_SYNC Content-Language: en-US To: Ricardo Ribalda , Laurent Pinchart , Mauro Carvalho Chehab Cc: linux-media@vger.kernel.org, linux-kernel@vger.kernel.org, Esker Wong References: <20231106-uvc-event-v3-1-c2d2fdaa2e2c@chromium.org> From: Hans Verkuil In-Reply-To: <20231106-uvc-event-v3-1-c2d2fdaa2e2c@chromium.org> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-0.8 required=5.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on groat.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (groat.vger.email [0.0.0.0]); Tue, 21 Nov 2023 02:37:48 -0800 (PST) Hi Ricardo, Sorry, I missed the whole discussion for the v2 patch. I've now read it and will reply here. On 11/6/23 12:00, Ricardo Ribalda wrote: > Add support for the frame_sync event, so user-space can become aware > earlier of new frames. I don't think this describes why you want this. Specifically, you want to use this to measure latency inside the driver between the arrival of the first USB packet and the time the buffer is dequeued. And this is presumably meant for debugging/measuring, but not for normal capturing. Right? Based on the discussion it looks like everyone is OK with this for the BULK case, and V4L2_EVENT_FRAME_SYNC makes sense to me there. You want to see the sequence number in the event, and the description of the event matches what happens. The problem is the ISOC case where it is debatable if this adds anything. Perhaps in the ISOC case this event shouldn't be supported? Unless you can show that it does provide useful information in the ISOC case. I didn't see that in the v2 discussion, but I might have missed it. Regards, Hans > > Suggested-by: Esker Wong > Tested-by: Esker Wong > Signed-off-by: Ricardo Ribalda > --- > We have measured a latency of around 30msecs between frame sync > and dqbuf. > --- > Changes in v3: > - Sent wrong patch as v2 sorry :S > - Link to v2: https://lore.kernel.org/r/20231106-uvc-event-v2-1-7d8e36f0df16@chromium.org > > Changes in v2: > - Suggested by Laurent. Split sequence++ and event init. > - Link to v1: https://lore.kernel.org/r/20231020-uvc-event-v1-1-3baa0e9f6952@chromium.org > --- > drivers/media/usb/uvc/uvc_v4l2.c | 2 ++ > drivers/media/usb/uvc/uvc_video.c | 7 +++++++ > 2 files changed, 9 insertions(+) > > diff --git a/drivers/media/usb/uvc/uvc_v4l2.c b/drivers/media/usb/uvc/uvc_v4l2.c > index f4988f03640a..9f3fb5fd2375 100644 > --- a/drivers/media/usb/uvc/uvc_v4l2.c > +++ b/drivers/media/usb/uvc/uvc_v4l2.c > @@ -1352,6 +1352,8 @@ static int uvc_ioctl_subscribe_event(struct v4l2_fh *fh, > switch (sub->type) { > case V4L2_EVENT_CTRL: > return v4l2_event_subscribe(fh, sub, 0, &uvc_ctrl_sub_ev_ops); > + case V4L2_EVENT_FRAME_SYNC: > + return v4l2_event_subscribe(fh, sub, 0, NULL); > default: > return -EINVAL; > } > diff --git a/drivers/media/usb/uvc/uvc_video.c b/drivers/media/usb/uvc/uvc_video.c > index 28dde08ec6c5..6a9410133908 100644 > --- a/drivers/media/usb/uvc/uvc_video.c > +++ b/drivers/media/usb/uvc/uvc_video.c > @@ -1073,9 +1073,16 @@ static int uvc_video_decode_start(struct uvc_streaming *stream, > * that discontinuous sequence numbers always indicate lost frames. > */ > if (stream->last_fid != fid) { > + struct v4l2_event event = { > + .type = V4L2_EVENT_FRAME_SYNC, > + }; > + > stream->sequence++; > if (stream->sequence) > uvc_video_stats_update(stream); > + > + event.u.frame_sync.frame_sequence = stream->sequence; > + v4l2_event_queue(&stream->vdev, &event); > } > > uvc_video_clock_decode(stream, buf, data, len); > > --- > base-commit: ce55c22ec8b223a90ff3e084d842f73cfba35588 > change-id: 20231020-uvc-event-d3d1bbbdcb2f > > Best regards,