Received: by 2002:a05:7412:8d10:b0:f3:1519:9f41 with SMTP id bj16csp5801540rdb; Wed, 13 Dec 2023 22:51:49 -0800 (PST) X-Google-Smtp-Source: AGHT+IHgR5jnWZT27Wxip6+4OJJQf8qq7QZvjORAoJlStiAylfZOAoCmMf72biw60Oy2zaKAmMwQ X-Received: by 2002:a17:90a:b306:b0:28a:a89d:4e85 with SMTP id d6-20020a17090ab30600b0028aa89d4e85mr3054412pjr.63.1702536708774; Wed, 13 Dec 2023 22:51:48 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1702536708; cv=none; d=google.com; s=arc-20160816; b=0kpy9zU3XGEivbQyCOngZTQ5rzT5hNMVKJNgy7rG8WhzxSB7LKD+bB1B3mAQZibdwp JCauPZqp37qfv6VRWqBoGjMq4pQQDc5Suol8A3/GnDJLCM2qWa7jFYG/pIWI+B7L0hJV Vf4ctjToXgDmt1ePyA/VDwkItM5Nr5pSpaXQEy+aMJcijFADH0cHrerczoPNmNpmqV1A 84ruG07Gf588S5jJ9W6ZQM5p23Ve7hI/FgXLYrilq92PTZxRaZuWVplD946cTIx6yhY1 D6OommaPtAoEG4w+gmVIYRDVyA9pFnHXIv6iteR1yszWhpjXCuAtIXDcN8qqnFo98GJO eSOw== 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; bh=c1w73+f1OIAfSxPDuNazWJkYQzhg04en9+K+IPEsf0Q=; fh=XQ3Ja9wKcqhsASYYLMElzkCFsrajr0VCo6/O7Hk5SL4=; b=Jbu0EH/zD12WOBzSsC5lz8Fdthz6nmJpBOROS7qRLZpDkGUdsBTRLxwNJeX0ld7YMS DBV3H9TgTIsBcY6RkDwKyCxZfhSEue1pQ+2ffuFqUg2UcI1go3Qbua1AtGtvHTOL41kW lfrUlNuCNsDIcz9cortsSnqTxnCg+simKlP9Oh+RR3oTG+anSwF36G7cehm3W0fJ/rBH Nv4QOneBzAcTJr+orldSP82BTqnFR5iUlQOOB3epemtgIf404i4Iurekyeo3z3WVDJo4 Cep676c4j7JSzVzyB106vH9k0HKKfpDuiIbvqQ9k1OjR0F/wzOgzg25x/HiB9TDOSijq 3LMg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.31 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from morse.vger.email (morse.vger.email. [23.128.96.31]) by mx.google.com with ESMTPS id g8-20020a17090a708800b002839be230b2si12058785pjk.44.2023.12.13.22.51.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 13 Dec 2023 22:51:48 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.31 as permitted sender) client-ip=23.128.96.31; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.31 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 morse.vger.email (Postfix) with ESMTP id 59F4382F2C65; Wed, 13 Dec 2023 22:51:43 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at morse.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1443328AbjLNGvH convert rfc822-to-8bit (ORCPT + 99 others); Thu, 14 Dec 2023 01:51:07 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57400 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1443250AbjLNGuo (ORCPT ); Thu, 14 Dec 2023 01:50:44 -0500 Received: from fd01.gateway.ufhost.com (fd01.gateway.ufhost.com [61.152.239.71]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A464EB9; Wed, 13 Dec 2023 22:50:50 -0800 (PST) Received: from EXMBX166.cuchost.com (unknown [175.102.18.54]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client CN "EXMBX166", Issuer "EXMBX166" (not verified)) by fd01.gateway.ufhost.com (Postfix) with ESMTP id 6EE82819B; Thu, 14 Dec 2023 14:50:49 +0800 (CST) Received: from EXMBX062.cuchost.com (172.16.6.62) by EXMBX166.cuchost.com (172.16.6.76) with Microsoft SMTP Server (TLS) id 15.0.1497.42; Thu, 14 Dec 2023 14:50:49 +0800 Received: from ubuntu.mshome.net (113.72.145.168) by EXMBX062.cuchost.com (172.16.6.62) with Microsoft SMTP Server (TLS) id 15.0.1497.42; Thu, 14 Dec 2023 14:50:46 +0800 From: Changhuang Liang To: Mauro Carvalho Chehab , Greg Kroah-Hartman , Hans Verkuil , "Marvin Lin" , Bryan O'Donoghue , "Ming Qian" , Laurent Pinchart , Nicolas Dufresne , Benjamin Gaignard , Tomi Valkeinen , Mingjia Zhang , Geert Uytterhoeven , Sakari Ailus , Dan Carpenter CC: Jack Zhu , Changhuang Liang , , , Subject: [PATCH v1 8/9] staging: media: starfive: Add frame sync event for video capture device Date: Wed, 13 Dec 2023 22:50:26 -0800 Message-ID: <20231214065027.28564-9-changhuang.liang@starfivetech.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20231214065027.28564-1-changhuang.liang@starfivetech.com> References: <20231214065027.28564-1-changhuang.liang@starfivetech.com> MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [113.72.145.168] X-ClientProxiedBy: EXCAS061.cuchost.com (172.16.6.21) To EXMBX062.cuchost.com (172.16.6.62) X-YovoleRuleAgent: yovoleflag Content-Transfer-Encoding: 8BIT 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 morse.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 (morse.vger.email [0.0.0.0]); Wed, 13 Dec 2023 22:51:43 -0800 (PST) Add frame sync event for video capture device. 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); struct stfcamss_buffer *ready_buf; struct stfcamss *stfcamss = cap->video.stfcamss; 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); + 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, }; 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, }; /* ----------------------------------------------------------------------------- -- 2.25.1