From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 3C99FC54E67 for ; Thu, 14 Mar 2024 10:11:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:References: Message-ID:Subject:Cc:To:From:Date:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=M26rZHYfy4aGgMFR698TbSwYYS7ZAiQW7SKtkYYSt/s=; b=y0l5T2dFPbnQLi eu16QagYRczW+Kz2AKGGmUl77nMQz+gExuxPpftm3pYK7jUZOVhZASUnNc/9RuQTDzmbWDonOxThz EbBed9ZG9cE2bFU9giY/MrOcnaSzhICe0fxG4QG3v5Ctd1oHrbfn6uMg0pU4IwZ0x+ZAY1XVPVvls 7M75r74MKUP3a3XjMqIeg00d88t67wz72ZHdOR13h3PBIZGAzw4cp2u88IEzC+QV+afe71ytQdAHc UFvpuJB5ncRnpHP/XJy5vfY3bePW7jS3aGbrDP0xhIYAfVnVH5epaXir2INVi4UizFUKzv25w8EZM mcfBFMRDKPngW5MnZRSw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1rki36-0000000Dr6h-2W8L; Thu, 14 Mar 2024 10:10:56 +0000 Received: from perceval.ideasonboard.com ([213.167.242.64]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1rki32-0000000Dr5E-3pje for linux-arm-kernel@lists.infradead.org; Thu, 14 Mar 2024 10:10:54 +0000 Received: from pendragon.ideasonboard.com (81-175-209-231.bb.dnainternet.fi [81.175.209.231]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id D8F67675; Thu, 14 Mar 2024 11:10:27 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1710411028; bh=NHtfGxhYFnBpkY/V0r9ZDvAGH7uhabLvklqAYXuLw/E=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=tGbbHdKFkvq56hha5BqkMYN0VaMpIa9uUJrn6y6GIsj6aHuxwTjv1HttRVoL5iuMi IJUGiqMmd+4rbohBKegGxujb8qV9rIPtVdLGQmstIWbd+DaRqUV20mAHdFXg6W1NDd oRM0iHIfSPA8dUbbYPLJKddPO1nad8ND4ENdMD/I= Date: Thu, 14 Mar 2024 12:10:49 +0200 From: Laurent Pinchart To: Stefan Klug Cc: libcamera-devel@lists.libcamera.org, linux-media@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, Jacopo Mondi , Umang Jain , Rui Miguel Silva , Martin Kepplinger , Purism Kernel Team , Mauro Carvalho Chehab , Shawn Guo , Sascha Hauer , Pengutronix Kernel Team , Fabio Estevam , NXP Linux Team Subject: Re: [PATCH v2] media: mipi-csis: Emit V4L2_EVENT_FRAME_SYNC events Message-ID: <20240314101049.GC4372@pendragon.ideasonboard.com> References: <20240314093652.56923-1-stefan.klug@ideasonboard.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20240314093652.56923-1-stefan.klug@ideasonboard.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240314_031053_195598_C53E3194 X-CRM114-Status: GOOD ( 30.19 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Hi Stefan, Thank you for the patch. On Thu, Mar 14, 2024 at 10:36:50AM +0100, Stefan Klug wrote: > The Samsung CSIS MIPI receiver provides a start-of-frame interrupt and > a framecount register. As the CSI receiver is the hardware unit that lies > closest to the sensor, the frame counter is the best we can get on these > devices. In case of the ISI available on the i.MX8 M Plus it is also the > only native start-of-frame signal available. You still have either an extra line break or a missing blank line :-) > This patch exposes the sof interrupt and the framecount as > V4L2_EVENT_FRAME_SYNC event on the subdevice. > > It was tested on a Debix-Som-A with a 6.8-rc4 kernel. > > Reviewed-by: Laurent Pinchart > Reviewed-by: Jacopo Mondi > Reviewed-by: Umang Jain > Signed-off-by: Stefan Klug > --- > Changes v1 -> v2: > - fixed formatting issues from review > - moved frame variable declaration to top of subscribe_event() > > Thanks all for the review! > > drivers/media/platform/nxp/imx-mipi-csis.c | 34 +++++++++++++++++++++- > 1 file changed, 33 insertions(+), 1 deletion(-) > > diff --git a/drivers/media/platform/nxp/imx-mipi-csis.c b/drivers/media/platform/nxp/imx-mipi-csis.c > index db8ff5f5c4d3..664be27c4224 100644 > --- a/drivers/media/platform/nxp/imx-mipi-csis.c > +++ b/drivers/media/platform/nxp/imx-mipi-csis.c > @@ -30,6 +30,7 @@ > > #include > #include > +#include > #include > #include > #include > @@ -742,6 +743,18 @@ static void mipi_csis_stop_stream(struct mipi_csis_device *csis) > mipi_csis_system_enable(csis, false); > } > > +static void mipi_csis_queue_event_sof(struct mipi_csis_device *csis) > +{ > + u32 frame; > + struct v4l2_event event = { > + .type = V4L2_EVENT_FRAME_SYNC, > + }; Nitpicking, we usually sort declarations by decreasing length. No need for a v3. > + > + frame = mipi_csis_read(csis, MIPI_CSIS_FRAME_COUNTER_CH(0)); > + event.u.frame_sync.frame_sequence = frame; > + v4l2_event_queue(csis->sd.devnode, &event); > +} > + > static irqreturn_t mipi_csis_irq_handler(int irq, void *dev_id) > { > struct mipi_csis_device *csis = dev_id; > @@ -765,6 +778,10 @@ static irqreturn_t mipi_csis_irq_handler(int irq, void *dev_id) > event->counter++; > } > } > + > + if (status & MIPI_CSIS_INT_SRC_FRAME_START) > + mipi_csis_queue_event_sof(csis); > + > spin_unlock_irqrestore(&csis->slock, flags); > > mipi_csis_write(csis, MIPI_CSIS_INT_SRC, status); > @@ -1154,8 +1171,23 @@ static int mipi_csis_log_status(struct v4l2_subdev *sd) > return 0; > } > > +static int mipi_csis_subscribe_event(struct v4l2_subdev *sd, struct v4l2_fh *fh, > + struct v4l2_event_subscription *sub) > +{ > + if (sub->type != V4L2_EVENT_FRAME_SYNC) > + return -EINVAL; > + > + /* V4L2_EVENT_FRAME_SYNC doesn't require an id, so zero should be set */ > + if (sub->id != 0) > + return -EINVAL; > + > + return v4l2_event_subscribe(fh, sub, 0, NULL); > +} > + > static const struct v4l2_subdev_core_ops mipi_csis_core_ops = { > .log_status = mipi_csis_log_status, > + .subscribe_event = mipi_csis_subscribe_event, > + .unsubscribe_event = v4l2_event_subdev_unsubscribe, > }; > > static const struct v4l2_subdev_video_ops mipi_csis_video_ops = { > @@ -1358,7 +1390,7 @@ static int mipi_csis_subdev_init(struct mipi_csis_device *csis) > snprintf(sd->name, sizeof(sd->name), "csis-%s", > dev_name(csis->dev)); > > - sd->flags |= V4L2_SUBDEV_FL_HAS_DEVNODE; > + sd->flags |= V4L2_SUBDEV_FL_HAS_DEVNODE | V4L2_SUBDEV_FL_HAS_EVENTS; > sd->ctrl_handler = NULL; > > sd->entity.function = MEDIA_ENT_F_VID_IF_BRIDGE; -- Regards, Laurent Pinchart _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel