Received: by 2002:ab2:710b:0:b0:1ef:a325:1205 with SMTP id z11csp1897561lql; Wed, 13 Mar 2024 11:09:43 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCUX/iB44QpBA4EV8vQTAn3hEnmbccmFEFznjoBpwGO8b3cD8zmSxkl6fBqZxLXwxqg0c2xxIH+74dwBzDfS1mPGs4BFJoISNorjrSKuDw== X-Google-Smtp-Source: AGHT+IFPmfUUx+oYfo6FXUWLoK6Obd4aCPUgP2niqvsgkWBw8ZeBjGZxhwKeOrorIKjWku/IplEu X-Received: by 2002:a05:6358:7e52:b0:17b:f51d:c280 with SMTP id p18-20020a0563587e5200b0017bf51dc280mr785590rwm.32.1710353383226; Wed, 13 Mar 2024 11:09:43 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1710353383; cv=pass; d=google.com; s=arc-20160816; b=XC59E7hNG5QDJUzW33SQ/IL41APk2mBLeRb5pp2509C4PL931v31plbUWdbV2hZbxO Fge2MfCwQP+2/98p46PZhS2/QEc3BUkKabEqGNDp7kHbpPgVPMlYtq8XTnvDG/30/3uW Ic/c/UWq/6WI9uAuZPQVGRc+Q0eL6+ZBKEprSe/l2KgXAI0hV56m+Jksjquz7QTeIBAF 0SQvSXFr8kwzIYEowJqH79RwrsHUL41aw3TeOrn+7x2buKBkGol7JdlLJAWZ4OuloHOw ahZpSgpfF0DelFWzXdysabGJ5OFh5vl5IhvxrCL90lwGdD9TowHMTQqEq+wseN+rw1HG fmmA== 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=TOCmemHdv48MuuWZetkc9xJGXEK0RNLvz2TQcftaz7E=; fh=zlWVCUYLTLs7n4+E9dPW7NbFL2Q83Qs+g2STnwgVutg=; b=LVNN2wabhGiKn0TbH8hqaX1BLTY98jvHC/7AgKHqUIHeF15h0Ah/Lhh2X19STAS0eb /OhduKSQ7URCZwRG2qrBiutkBz+1tBDMd4WCKP+LGZTTTEDvceAsU9GT12LA99SoZouY 3gBvX1UJNSH91Kt6KK+e+vNF+p7ws9JsEKxIwK/7W/TfjyzkPxG1Kt1hajYUibo6qwMe h+5/mX+X++tqCEuxII6E3ncixvBXMAQQ88vLh4tcJ5fR1+CP1FFIcAwYvqTX48COHcVy 9qpD3q6dFq3IdwuqXC5jFhwmyMlt/8ZrDcQzAWHWHiHV4OlfwFQzqhNp7jG1EIQHIp7Y 4qfA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass (test mode) header.i=@ideasonboard.com header.s=mail header.b=LW4Hr5WQ; arc=pass (i=1 spf=pass spfdomain=ideasonboard.com dkim=pass dkdomain=ideasonboard.com); spf=pass (google.com: domain of linux-kernel+bounces-102101-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-102101-linux.lists.archive=gmail.com@vger.kernel.org" Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [2604:1380:40f1:3f00::1]) by mx.google.com with ESMTPS id w4-20020a631604000000b005dc55690b2bsi9542633pgl.324.2024.03.13.11.09.42 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 13 Mar 2024 11:09:43 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-102101-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) client-ip=2604:1380:40f1:3f00::1; Authentication-Results: mx.google.com; dkim=pass (test mode) header.i=@ideasonboard.com header.s=mail header.b=LW4Hr5WQ; arc=pass (i=1 spf=pass spfdomain=ideasonboard.com dkim=pass dkdomain=ideasonboard.com); spf=pass (google.com: domain of linux-kernel+bounces-102101-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-102101-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 sy.mirrors.kernel.org (Postfix) with ESMTPS id F14C4B2512D for ; Wed, 13 Mar 2024 17:57:53 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 8A08C59B4B; Wed, 13 Mar 2024 16:49:21 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="LW4Hr5WQ" 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 C19E818F36B; Wed, 13 Mar 2024 16:49:18 +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=1710348560; cv=none; b=hboicDR0A8CBycdh2kkGeGD39MH7kyPnk4d7tYx7omeUQpX0nKakOtkg1+UsTRBUvk5m1x8mKUg7kc1vSCSsqS05in6l2EMW6aoV4YB3Ukyjx983nk576iYMrsmwxclkNsOC2asDQ82TahViANv1AEG4BjrmvsvQm5NfQOt9lUs= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710348560; c=relaxed/simple; bh=2hQ6pSoQbMrt0XkGRzDOdvfmCtR4p2HXgr8RQCNnWOg=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=pz5HCCkAxhkHd4mMGL3JhWSPYEQ+PC3TI7bHodLfJOKF/eqPGtU9jzU47hlaBQQJ0SnL7It359GP1tp0VxOfwcbf1C0sggx8oG2xYlY0xXbEmK3tdeXOSSmD3jZtLApZ3HOdP7IPnsNWETl5TOx+tDuyjzWetsri057rpGteXLs= 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=LW4Hr5WQ; 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 ideasonboard.com (93-61-96-190.ip145.fastwebnet.it [93.61.96.190]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id C5D10B1; Wed, 13 Mar 2024 17:48:53 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1710348533; bh=2hQ6pSoQbMrt0XkGRzDOdvfmCtR4p2HXgr8RQCNnWOg=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=LW4Hr5WQRELGatP+Rx39XsVdhYqzrluTYRPkZJc07OnmW1sIBdWdkjt8RYM0RfQEc 9VvaLcJpVR9oRFhFrL6chX79fG46ZcWKNoaWgUgpx6LTuGkuSLbjFfqqSI3yHoJYvP xIG4xlhTnNQHgEYlL2gXycDR6GQT+n6jN9bZMz/M= Date: Wed, 13 Mar 2024 17:49:12 +0100 From: Jacopo Mondi 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, Rui Miguel Silva , Laurent Pinchart , 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: 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: <20240313153058.189684-1-stefan.klug@ideasonboard.com> 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. > 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, > + }; > + > + 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 Thanks j > +{ > + 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; > -- > 2.40.1 > >