Patch Detail
Show a patch.
GET /api/1.1/patches/19716/?format=api
{ "id": 19716, "url": "https://patchwork.libcamera.org/api/1.1/patches/19716/?format=api", "web_url": "https://patchwork.libcamera.org/patch/19716/", "project": { "id": 1, "url": "https://patchwork.libcamera.org/api/1.1/projects/1/?format=api", "name": "libcamera", "link_name": "libcamera", "list_id": "libcamera_core", "list_email": "libcamera-devel@lists.libcamera.org", "web_url": "", "scm_url": "", "webscm_url": "" }, "msgid": "<20240314093652.56923-1-stefan.klug@ideasonboard.com>", "date": "2024-03-14T09:36:50", "name": "[v2] media: mipi-csis: Emit V4L2_EVENT_FRAME_SYNC events", "commit_ref": null, "pull_url": null, "state": "not-applicable", "archived": false, "hash": "c8fdf4efc1636f12057a017325afbd6ee005ceb4", "submitter": { "id": 184, "url": "https://patchwork.libcamera.org/api/1.1/people/184/?format=api", "name": "Stefan Klug", "email": "stefan.klug@ideasonboard.com" }, "delegate": null, "mbox": "https://patchwork.libcamera.org/patch/19716/mbox/", "series": [ { "id": 4223, "url": "https://patchwork.libcamera.org/api/1.1/series/4223/?format=api", "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=4223", "date": "2024-03-14T09:36:50", "name": "[v2] media: mipi-csis: Emit V4L2_EVENT_FRAME_SYNC events", "version": 2, "mbox": "https://patchwork.libcamera.org/series/4223/mbox/" } ], "comments": "https://patchwork.libcamera.org/api/patches/19716/comments/", "check": "pending", "checks": "https://patchwork.libcamera.org/api/patches/19716/checks/", "tags": {}, "headers": { "Return-Path": "<libcamera-devel-bounces@lists.libcamera.org>", "X-Original-To": "parsemail@patchwork.libcamera.org", "Delivered-To": "parsemail@patchwork.libcamera.org", "Received": [ "from lancelot.ideasonboard.com (lancelot.ideasonboard.com\n\t[92.243.16.209])\n\tby patchwork.libcamera.org (Postfix) with ESMTPS id C392DBD808\n\tfor <parsemail@patchwork.libcamera.org>;\n\tThu, 14 Mar 2024 09:37:50 +0000 (UTC)", "from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id AACE662C95;\n\tThu, 14 Mar 2024 10:37:49 +0100 (CET)", "from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[IPv6:2001:4b98:dc2:55:216:3eff:fef7:d647])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id F13CD6286F\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tThu, 14 Mar 2024 10:37:46 +0100 (CET)", "from jasper.fritz.box (unknown\n\t[IPv6:2a00:6020:448c:6c00:c467:7cd1:67a9:bc4c])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 76F4F675;\n\tThu, 14 Mar 2024 10:37:22 +0100 (CET)" ], "Authentication-Results": "lancelot.ideasonboard.com;\n\tdkim=fail reason=\"signature verification failed\" (1024-bit key;\n\tunprotected) header.d=ideasonboard.com header.i=@ideasonboard.com\n\theader.b=\"RurdlDfh\"; dkim-atps=neutral", "DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1710409043;\n\tbh=EwMvKgGe1CCgKNeMgTrUggt9oO1B36dsyMycZ7GH2ww=;\n\th=From:To:Cc:Subject:Date:From;\n\tb=RurdlDfhJHS1P8CFseVq5+ZP+KzX5fJZfDMgeKSOTEdwpLjLLcaic/CZ1gWSx31XM\n\tPCYIjoQw9ijd425qDTYhfXltbaHFV8otQp27Xel1nn/5pY52lMBfOvU2guwfNYLDAf\n\tMu1QwnQDmTYt+CauGrnvW09bc40LCoAnqkdgjMt0=", "From": "Stefan Klug <stefan.klug@ideasonboard.com>", "To": "libcamera-devel@lists.libcamera.org, linux-media@vger.kernel.org,\n\tlinux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org", "Subject": "[PATCH v2] media: mipi-csis: Emit V4L2_EVENT_FRAME_SYNC events", "Date": "Thu, 14 Mar 2024 10:36:50 +0100", "Message-Id": "<20240314093652.56923-1-stefan.klug@ideasonboard.com>", "X-Mailer": "git-send-email 2.40.1", "MIME-Version": "1.0", "Content-Transfer-Encoding": "8bit", "X-BeenThere": "libcamera-devel@lists.libcamera.org", "X-Mailman-Version": "2.1.29", "Precedence": "list", "List-Id": "<libcamera-devel.lists.libcamera.org>", "List-Unsubscribe": "<https://lists.libcamera.org/options/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=unsubscribe>", "List-Archive": "<https://lists.libcamera.org/pipermail/libcamera-devel/>", "List-Post": "<mailto:libcamera-devel@lists.libcamera.org>", "List-Help": "<mailto:libcamera-devel-request@lists.libcamera.org?subject=help>", "List-Subscribe": "<https://lists.libcamera.org/listinfo/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=subscribe>", "Cc": "Martin Kepplinger <martink@posteo.de>,\n\tRui Miguel Silva <rmfrfs@gmail.com>, Fabio Estevam <festevam@gmail.com>,\n\tSascha Hauer <s.hauer@pengutronix.de>, \n\tNXP Linux Team <linux-imx@nxp.com>,\n\tJacopo Mondi <jacopo.mondi@ideasonboard.com>,\n\tPengutronix Kernel Team <kernel@pengutronix.de>,\n\tStefan Klug <stefan.klug@ideasonboard.com>,\n\tMauro Carvalho Chehab <mchehab@kernel.org>,\n\tShawn Guo <shawnguo@kernel.org>, Purism Kernel Team <kernel@puri.sm>", "Errors-To": "libcamera-devel-bounces@lists.libcamera.org", "Sender": "\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>" }, "content": "The Samsung CSIS MIPI receiver provides a start-of-frame interrupt and\na framecount register. As the CSI receiver is the hardware unit that lies\nclosest to the sensor, the frame counter is the best we can get on these\ndevices. In case of the ISI available on the i.MX8 M Plus it is also the\nonly native start-of-frame signal available.\nThis patch exposes the sof interrupt and the framecount as\nV4L2_EVENT_FRAME_SYNC event on the subdevice.\n\nIt was tested on a Debix-Som-A with a 6.8-rc4 kernel.\n\nReviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\nReviewed-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com>\nReviewed-by: Umang Jain <umang.jain@ideasonboard.com>\nSigned-off-by: Stefan Klug <stefan.klug@ideasonboard.com>\n---\nChanges v1 -> v2:\n - fixed formatting issues from review\n - moved frame variable declaration to top of subscribe_event()\n\nThanks all for the review!\n\n drivers/media/platform/nxp/imx-mipi-csis.c | 34 +++++++++++++++++++++-\n 1 file changed, 33 insertions(+), 1 deletion(-)", "diff": "diff --git a/drivers/media/platform/nxp/imx-mipi-csis.c b/drivers/media/platform/nxp/imx-mipi-csis.c\nindex db8ff5f5c4d3..664be27c4224 100644\n--- a/drivers/media/platform/nxp/imx-mipi-csis.c\n+++ b/drivers/media/platform/nxp/imx-mipi-csis.c\n@@ -30,6 +30,7 @@\n \n #include <media/v4l2-common.h>\n #include <media/v4l2-device.h>\n+#include <media/v4l2-event.h>\n #include <media/v4l2-fwnode.h>\n #include <media/v4l2-mc.h>\n #include <media/v4l2-subdev.h>\n@@ -742,6 +743,18 @@ static void mipi_csis_stop_stream(struct mipi_csis_device *csis)\n \tmipi_csis_system_enable(csis, false);\n }\n \n+static void mipi_csis_queue_event_sof(struct mipi_csis_device *csis)\n+{\n+\tu32 frame;\n+\tstruct v4l2_event event = {\n+\t\t.type = V4L2_EVENT_FRAME_SYNC,\n+\t};\n+\n+\tframe = mipi_csis_read(csis, MIPI_CSIS_FRAME_COUNTER_CH(0));\n+\tevent.u.frame_sync.frame_sequence = frame;\n+\tv4l2_event_queue(csis->sd.devnode, &event);\n+}\n+\n static irqreturn_t mipi_csis_irq_handler(int irq, void *dev_id)\n {\n \tstruct mipi_csis_device *csis = dev_id;\n@@ -765,6 +778,10 @@ static irqreturn_t mipi_csis_irq_handler(int irq, void *dev_id)\n \t\t\t\tevent->counter++;\n \t\t}\n \t}\n+\n+\tif (status & MIPI_CSIS_INT_SRC_FRAME_START)\n+\t\tmipi_csis_queue_event_sof(csis);\n+\n \tspin_unlock_irqrestore(&csis->slock, flags);\n \n \tmipi_csis_write(csis, MIPI_CSIS_INT_SRC, status);\n@@ -1154,8 +1171,23 @@ static int mipi_csis_log_status(struct v4l2_subdev *sd)\n \treturn 0;\n }\n \n+static int mipi_csis_subscribe_event(struct v4l2_subdev *sd, struct v4l2_fh *fh,\n+\t\t\t\t struct v4l2_event_subscription *sub)\n+{\n+\tif (sub->type != V4L2_EVENT_FRAME_SYNC)\n+\t\treturn -EINVAL;\n+\n+\t/* V4L2_EVENT_FRAME_SYNC doesn't require an id, so zero should be set */\n+\tif (sub->id != 0)\n+\t\treturn -EINVAL;\n+\n+\treturn v4l2_event_subscribe(fh, sub, 0, NULL);\n+}\n+\n static const struct v4l2_subdev_core_ops mipi_csis_core_ops = {\n \t.log_status\t= mipi_csis_log_status,\n+\t.subscribe_event = mipi_csis_subscribe_event,\n+\t.unsubscribe_event = v4l2_event_subdev_unsubscribe,\n };\n \n static const struct v4l2_subdev_video_ops mipi_csis_video_ops = {\n@@ -1358,7 +1390,7 @@ static int mipi_csis_subdev_init(struct mipi_csis_device *csis)\n \tsnprintf(sd->name, sizeof(sd->name), \"csis-%s\",\n \t\t dev_name(csis->dev));\n \n-\tsd->flags |= V4L2_SUBDEV_FL_HAS_DEVNODE;\n+\tsd->flags |= V4L2_SUBDEV_FL_HAS_DEVNODE | V4L2_SUBDEV_FL_HAS_EVENTS;\n \tsd->ctrl_handler = NULL;\n \n \tsd->entity.function = MEDIA_ENT_F_VID_IF_BRIDGE;\n", "prefixes": [ "v2" ] }