Received: by 2002:ab2:710b:0:b0:1ef:a325:1205 with SMTP id z11csp1992024lql; Wed, 13 Mar 2024 14:10:14 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCWKGgokqoHTueOh7HhS7BL84A/FId8qCUiL1nB8GnYMzy03CwsguEHZUqhzMcmImnbOjrNVpnwlu7xOMCmRv0ipW2uD2DmOJtRbRfaRBg== X-Google-Smtp-Source: AGHT+IHjn7rJ18TS02p/tYHoyPaZ5NGe0aADjxF8z/tSnPRcUWUqIaJn5WUUP0cTP9pFM9TNgSGy X-Received: by 2002:ac2:4ac1:0:b0:513:a2c3:f785 with SMTP id m1-20020ac24ac1000000b00513a2c3f785mr7261634lfp.25.1710364213950; Wed, 13 Mar 2024 14:10:13 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1710364213; cv=pass; d=google.com; s=arc-20160816; b=DhOaZHnWf/paPvCHGG0oDST365NntBtH5vohQybwDsmwEsrNixWfk/zI9tqAoTDWvF faY/KJVVtD/5CMDpd81Fb8/tX270LZj70egttflFAUFhmV2YFVoPKM3nSIq97QUqASAl QP17vt2stHWafpNeEmu7uFb3IQH0hTgmO39mJmTA7+ufeVKBYzXiS8MO7WK6UI8EcJ+0 PDOpEK5Px9JKP6N5ElbOf0DnnHvEHPiyvO9TSb4cIVODxfIdmOFx79rW+gF5IFbIsIlB JBI4CLmDUBmuSMumzZKTlMh1rQgNDBuQ0aw4eFSaefd5tu4Vswjlwz+Gb5boRlD+JDFu PXkg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=in-reply-to:content-disposition:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:message-id:subject:cc :to:from:date:dkim-signature; bh=F3un4RTWnSI7F7jEi0D5naw0fM6n/5WehPCuGU02/kI=; fh=JM7UTvsRifU/CV+yyq96jY/ZWBKYD0qOGkCVHVhb4L4=; b=jxD3ciFIJxHRyJoYq0UDHZW+o8TIguCTKbco/kTIhT7ElEdlU98iP+d3/jXVmoKBoL kSBq73n8nTuSxQka40on3rTBE/YyY1dvopNxM/WzXk19FEeVbkd5xEc/9zOT6cwSx0LO o3lBxXPgnjZ7lUAUeGKrnbY5kmNgER6TGfG1678Kc5pz0E23coydNAbJMgkDbs6R7cIb 7aLj73h3+FJTOnUAzFS6XdyJ3roh9PGhSPBWMeqYYgE7vXCrKgAfWC82g7X3rQ1zOiVe qLpJITDspk4pr69mq/oobUqvWLvz90TPMPiXU0jRdtatAdFXd6Jkt/Cv2SN+nVPEhllw 2ZFw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass (test mode) header.i=@ideasonboard.com header.s=mail header.b=a09Y27gV; arc=pass (i=1 spf=pass spfdomain=ideasonboard.com dkim=pass dkdomain=ideasonboard.com); spf=pass (google.com: domain of linux-kernel+bounces-102519-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-102519-linux.lists.archive=gmail.com@vger.kernel.org" Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id bw9-20020a170906c1c900b00a46651f8e97si19565ejb.333.2024.03.13.14.10.13 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 13 Mar 2024 14:10:13 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-102519-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; dkim=pass (test mode) header.i=@ideasonboard.com header.s=mail header.b=a09Y27gV; arc=pass (i=1 spf=pass spfdomain=ideasonboard.com dkim=pass dkdomain=ideasonboard.com); spf=pass (google.com: domain of linux-kernel+bounces-102519-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-102519-linux.lists.archive=gmail.com@vger.kernel.org" Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id A51B41F23C25 for ; Wed, 13 Mar 2024 21:10:13 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 2D689537F0; Wed, 13 Mar 2024 21:10:07 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="a09Y27gV" Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) (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 9D99012E6C; Wed, 13 Mar 2024 21:10:04 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=213.167.242.64 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710364206; cv=none; b=OfK3+6eX5LTbM5BeaGMkD7BWKdaleGpXqIiMtNjcZKYVDeTaaB4OVsBT1NaZeXFxFfnjhldoPUuULB6Sz1ncD9nH22k1MIJ0UE89DAv+g7qIsRHjOsQhxVFfRpQEkuBMLw87DeVAsISGj2/JGAwtUs6NQ3+CGoVmxkM2+IQOV90= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710364206; c=relaxed/simple; bh=dSNdEew0TvY2dz+P/qyS2VqxJ+0O8XNKI5IRxLVgvAw=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=pQpKI7DQGIYRXhsuTrdxSrnGFxL8HWk8XTbdmHNy45tL5A7Pjm+Kuwx8oKBIH95vGz0pQ7Cyb4U7ssFPCGe25lujT5avdwsqX8kDAWpSQgaGbe06UhSMgVHBUxrN0/f5CmQDMzt9ukwWzNylY0WVFVYrNDlssZdVi2bp30K82K4= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=ideasonboard.com; spf=pass smtp.mailfrom=ideasonboard.com; dkim=pass (1024-bit key) header.d=ideasonboard.com header.i=@ideasonboard.com header.b=a09Y27gV; arc=none smtp.client-ip=213.167.242.64 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=ideasonboard.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=ideasonboard.com Received: from pendragon.ideasonboard.com (unknown [95.214.66.65]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 11FAF2D6B; Wed, 13 Mar 2024 22:09:40 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1710364180; bh=dSNdEew0TvY2dz+P/qyS2VqxJ+0O8XNKI5IRxLVgvAw=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=a09Y27gVrIRYTRA/ANWkT5LNwoF+Z/ehp6m0hnglld9EHUurCsmKRkkQloDG0OZR1 CM4IZ5JrSPCEBjNkEgEGUOwfFAGmPEZsywumIDibfzMqAHtplx+p67LJQF6ui2vGk6 uRfK0X9vR5UIWopJnp40Bzz8ONxFGt+JhKjJuJFk= Date: Wed, 13 Mar 2024 23:10:10 +0200 From: Laurent Pinchart To: Jacopo Mondi Cc: Stefan Klug , libcamera-devel@lists.libcamera.org, linux-media@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, 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] mipi-csis: Emit V4L2_EVENT_FRAME_SYNC events Message-ID: <20240313195408.GE8399@pendragon.ideasonboard.com> References: <20240313153058.189684-1-stefan.klug@ideasonboard.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: On Wed, Mar 13, 2024 at 05:49:12PM +0100, Jacopo Mondi wrote: > Hi Stefan > > In Subject: missing the 'media:' prefix > > On Wed, Mar 13, 2024 at 04:30:58PM +0100, Stefan Klug wrote: > > The Samsung CSIS Mipi receiver provides a start-of-frame interrupt and > > s/Mipi/MIPI/ > > > 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. Nitpicking: if you intended to start a new paragraph, add a blank line. If not, don't add a line break between sentences. > > In case of the ISI available on the i.MX8 M Plus it is also the only > > native start-of-frame signal available. > > > > 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. > > > > Signed-off-by: Stefan Klug > > --- > > 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..caeb1622f741 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) > > +{ > > + struct v4l2_event event = { > > + .type = V4L2_EVENT_FRAME_SYNC, > > + }; > > + No need for a blank line. > > + u32 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) > > Please align to open ( on the previous line > > All minors, with the above fixed > Reviewed-by: Jacopo Mondi Reviewed-by: Laurent Pinchart If you don't want to send a v2, I can address the minor comments when applying this to my tree. Please let me know what you prefer. > > +{ > > + 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