Received: by 2002:a05:7412:8d10:b0:f3:1519:9f41 with SMTP id bj16csp5941448rdb; Thu, 14 Dec 2023 04:19:56 -0800 (PST) X-Google-Smtp-Source: AGHT+IFNIeXAKMloly4erQQrLOza8CEnYEIY6PmEylo8l4GQ1PCv9FxJ98tESNpPYI3cMGvUMW4B X-Received: by 2002:aa7:9214:0:b0:6ce:f6f2:2ac5 with SMTP id 20-20020aa79214000000b006cef6f22ac5mr3731607pfo.16.1702556395863; Thu, 14 Dec 2023 04:19:55 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1702556395; cv=none; d=google.com; s=arc-20160816; b=nSc2AAlozem9srK3fDBD1n0y+oiU9izBpk/ZWN9tgnpNEaukxMbbsfGCyfLQW4bwBs 75vjFO9ldM0OmURj57AzcZEI+7+K9u78/TNLOYyvyvnNDat/bSIHV0u5feXGp02wmn6Z 58FYr19Dtzs8Si5GOjI9rpId0pP5OdQmCSbUMUxNRVg2V0MoAiIhc5axf7B182hF5RB9 jXESJbqu+05PuPyS/Hv8z83DZDBO4l5A8BATtkYSbbL7jPucTQhF6mz+TykGHOcJEMyH gGZW08/8rdfFt3OxgeoTbwq9cM+daiuE8ksgIK5oGxUq0AED4A6WiD2qygiqaKm4V6GP sOkQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=aTSbCR8DrX59iueMhz957L4taDCBqGjDKojE+3Ibegc=; fh=+6idaF9tN93DblnnrPNbHS0IFiXWr5tjOM2XxXspHfo=; b=dfRDvUlQTnn1DPT18yX0aJxbwhyL1P9oR7akVH+cZk+4IYaYPPINiNnLhjdM8B//I5 R/IgKt9s8t+orMb7MqX9CmFfFGUWF/QIbEHFu1F0/2bEh3+g4kF1NbjpcqD0cfJn5iW3 Y5RvIWHIGnYIjRkaV+OKu6HsL8JyDSdq2ZaZhF4qA/Sh8nibgewopWh8lK6J33LIMUK+ +x8Q/O9xy+6hnM4gnbCpKZBEMQjbg4g3kHvsMBvJqGgW8xM6e4I7qojySUGHBa854qAd 2B5PAlADMmCBng2XyCsoJ8jUwmcaJAUgb1cmqEppcZPsurIFaoZ8EuqLLkEy8VJbqWHJ imTA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass (test mode) header.i=@ideasonboard.com header.s=mail header.b=GfoOR2Nt; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from lipwig.vger.email (lipwig.vger.email. [23.128.96.33]) by mx.google.com with ESMTPS id k129-20020a632487000000b005c627018c32si11045554pgk.431.2023.12.14.04.19.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 14 Dec 2023 04:19:55 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 as permitted sender) client-ip=23.128.96.33; Authentication-Results: mx.google.com; dkim=pass (test mode) header.i=@ideasonboard.com header.s=mail header.b=GfoOR2Nt; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by lipwig.vger.email (Postfix) with ESMTP id 8A1F3814C692; Thu, 14 Dec 2023 04:19:52 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at lipwig.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1572968AbjLNMTh (ORCPT + 99 others); Thu, 14 Dec 2023 07:19:37 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50054 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1572923AbjLNMTg (ORCPT ); Thu, 14 Dec 2023 07:19:36 -0500 Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [IPv6:2001:4b98:dc2:55:216:3eff:fef7:d647]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id F0D0CBD; Thu, 14 Dec 2023 04:19:42 -0800 (PST) Received: from pendragon.ideasonboard.com (213-243-189-158.bb.dnainternet.fi [213.243.189.158]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id E1C5F4A9; Thu, 14 Dec 2023 13:18:54 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1702556335; bh=YiTF6JHTIBaYstNwMrE+QdjSiz7s49VYWh8YMsvV9Ds=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=GfoOR2NtgGHS+ihYhAAIWAG/jedCD6LOU4Gt7x45cgWD06wzRgmednBtbUQaIXXSa K3KSkv5lHg0ru+ptfrVtmXhWrv7cJjKB9FruXklyXPh+HMKMkLih5GQXo05qSZYYqD qdBRddludmHkUg/lWPIL3hx9vAwu8GUjPkxaEn6k= Date: Thu, 14 Dec 2023 14:19:48 +0200 From: Laurent Pinchart To: Changhuang Liang Cc: Mauro Carvalho Chehab , Greg Kroah-Hartman , Hans Verkuil , Marvin Lin , Bryan O'Donoghue , Ming Qian , Nicolas Dufresne , Benjamin Gaignard , Tomi Valkeinen , Mingjia Zhang , Geert Uytterhoeven , Sakari Ailus , Dan Carpenter , Jack Zhu , linux-media@vger.kernel.org, linux-kernel@vger.kernel.org, linux-staging@lists.linux.dev Subject: Re: [PATCH v1 8/9] staging: media: starfive: Add frame sync event for video capture device Message-ID: <20231214121948.GC21146@pendragon.ideasonboard.com> References: <20231214065027.28564-1-changhuang.liang@starfivetech.com> <20231214065027.28564-9-changhuang.liang@starfivetech.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <20231214065027.28564-9-changhuang.liang@starfivetech.com> X-Spam-Status: No, score=-0.9 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,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 lipwig.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 (lipwig.vger.email [0.0.0.0]); Thu, 14 Dec 2023 04:19:52 -0800 (PST) Hi Changhuang, Thank you for the patch. On Wed, Dec 13, 2023 at 10:50:26PM -0800, Changhuang Liang wrote: > Add frame sync event for video capture device. Here too the commit message needs to explain why. > Signed-off-by: Changhuang Liang > --- > .../staging/media/starfive/camss/stf-capture.c | 9 +++++++++ > drivers/staging/media/starfive/camss/stf-video.c | 15 +++++++++++++++ > 2 files changed, 24 insertions(+) > > diff --git a/drivers/staging/media/starfive/camss/stf-capture.c b/drivers/staging/media/starfive/camss/stf-capture.c > index 6a137a273c8a..d0be769da11b 100644 > --- a/drivers/staging/media/starfive/camss/stf-capture.c > +++ b/drivers/staging/media/starfive/camss/stf-capture.c > @@ -7,6 +7,7 @@ > * Copyright (C) 2021-2023 StarFive Technology Co., Ltd. > */ > > +#include > #include "stf-camss.h" > > static const char * const stf_cap_names[] = { > @@ -430,10 +431,15 @@ static void stf_buf_flush(struct stf_v_buf *output, enum vb2_buffer_state state) > > static void stf_buf_done(struct stf_v_buf *output) > { > + struct stf_capture *cap = container_of(output, struct stf_capture, > + buffers); This looks like it belongs to a previous patch, because ... > struct stfcamss_buffer *ready_buf; > struct stfcamss *stfcamss = cap->video.stfcamss; ... cap is already used there. Please compile each commit, not just the end result. Compilation must not break at any point in the middle of the series, or it would make git bisection impossible. > u64 ts = ktime_get_ns(); > unsigned long flags; > + struct v4l2_event event = { > + .type = V4L2_EVENT_FRAME_SYNC, > + }; > > if (output->state == STF_OUTPUT_OFF || > output->state == STF_OUTPUT_RESERVED) > @@ -445,6 +451,9 @@ static void stf_buf_done(struct stf_v_buf *output) > if (cap->type == STF_CAPTURE_SCD) > stf_isp_fill_yhist(stfcamss, ready_buf->vaddr_sc); > > + event.u.frame_sync.frame_sequence = output->sequence; > + v4l2_event_queue(&cap->video.vdev, &event); This doesn't like to be the right place to generate the V4L2_EVENT_FRAME_SYNC event. V4L2_EVENT_FRAME_SYNC is defined as - Triggered immediately when the reception of a frame has begun. This event has a struct :c:type:`v4l2_event_frame_sync` associated with it. It would be best to generate V4L2_EVENT_FRAME_SYNC in response to a CSI-2 RX interrupt that signals the beginning of the frame, if the hardware provides that. If not, an ISP interrupt that signals the beginning of the frame would work too. > + > ready_buf->vb.vb2_buf.timestamp = ts; > ready_buf->vb.sequence = output->sequence++; > > diff --git a/drivers/staging/media/starfive/camss/stf-video.c b/drivers/staging/media/starfive/camss/stf-video.c > index 54d855ba0b57..32381e9ad049 100644 > --- a/drivers/staging/media/starfive/camss/stf-video.c > +++ b/drivers/staging/media/starfive/camss/stf-video.c > @@ -507,6 +507,17 @@ static int video_try_fmt(struct file *file, void *fh, struct v4l2_format *f) > return __video_try_fmt(video, f); > } > > +static int video_subscribe_event(struct v4l2_fh *fh, > + const struct v4l2_event_subscription *sub) > +{ > + switch (sub->type) { > + case V4L2_EVENT_FRAME_SYNC: > + return v4l2_event_subscribe(fh, sub, 0, NULL); > + default: > + return -EINVAL; > + } > +} > + > static const struct v4l2_ioctl_ops stf_vid_ioctl_ops = { > .vidioc_querycap = video_querycap, > .vidioc_enum_fmt_vid_cap = video_enum_fmt, > @@ -523,6 +534,8 @@ static const struct v4l2_ioctl_ops stf_vid_ioctl_ops = { > .vidioc_prepare_buf = vb2_ioctl_prepare_buf, > .vidioc_streamon = vb2_ioctl_streamon, > .vidioc_streamoff = vb2_ioctl_streamoff, > + .vidioc_subscribe_event = video_subscribe_event, > + .vidioc_unsubscribe_event = v4l2_event_unsubscribe, Don't implement the event on the video device, implement it on the CSI-2 RX or ISP subdev, depending on whether you get it from the CSI-2 RX or the ISP. > }; > > static int video_scd_g_fmt(struct file *file, void *fh, struct v4l2_format *f) > @@ -554,6 +567,8 @@ static const struct v4l2_ioctl_ops stf_vid_scd_ioctl_ops = { > .vidioc_prepare_buf = vb2_ioctl_prepare_buf, > .vidioc_streamon = vb2_ioctl_streamon, > .vidioc_streamoff = vb2_ioctl_streamoff, > + .vidioc_subscribe_event = video_subscribe_event, > + .vidioc_unsubscribe_event = v4l2_event_unsubscribe, > }; > > /* ----------------------------------------------------------------------------- -- Regards, Laurent Pinchart