Show a patch.

GET /api/patches/19715/?format=api
HTTP 200 OK
Allow: GET, PUT, PATCH, HEAD, OPTIONS
Content-Type: application/json
Vary: Accept

{
    "id": 19715,
    "url": "https://patchwork.libcamera.org/api/patches/19715/?format=api",
    "web_url": "https://patchwork.libcamera.org/patch/19715/",
    "project": {
        "id": 1,
        "url": "https://patchwork.libcamera.org/api/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": "<20240313153058.189684-1-stefan.klug@ideasonboard.com>",
    "date": "2024-03-13T15:30:58",
    "name": "mipi-csis: Emit V4L2_EVENT_FRAME_SYNC events",
    "commit_ref": null,
    "pull_url": null,
    "state": "not-applicable",
    "archived": false,
    "hash": "30e03d9edc797a26b03623b2f8f69918df711cad",
    "submitter": {
        "id": 184,
        "url": "https://patchwork.libcamera.org/api/people/184/?format=api",
        "name": "Stefan Klug",
        "email": "stefan.klug@ideasonboard.com"
    },
    "delegate": null,
    "mbox": "https://patchwork.libcamera.org/patch/19715/mbox/",
    "series": [
        {
            "id": 4222,
            "url": "https://patchwork.libcamera.org/api/series/4222/?format=api",
            "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=4222",
            "date": "2024-03-13T15:30:58",
            "name": "mipi-csis: Emit V4L2_EVENT_FRAME_SYNC events",
            "version": 1,
            "mbox": "https://patchwork.libcamera.org/series/4222/mbox/"
        }
    ],
    "comments": "https://patchwork.libcamera.org/api/patches/19715/comments/",
    "check": "pending",
    "checks": "https://patchwork.libcamera.org/api/patches/19715/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 9B362BD160\n\tfor <parsemail@patchwork.libcamera.org>;\n\tWed, 13 Mar 2024 15:32:23 +0000 (UTC)",
            "from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 2BD8262C8B;\n\tWed, 13 Mar 2024 16:32:22 +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 3C91162C85\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tWed, 13 Mar 2024 16:32:20 +0100 (CET)",
            "from jasper.fritz.box (unknown\n\t[IPv6:2a00:6020:448c:6c00:9b07:31b5:38e1:e957])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id BBF51A8F;\n\tWed, 13 Mar 2024 16:31:56 +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=\"vKEYO3rz\"; dkim-atps=neutral",
        "DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1710343917;\n\tbh=RYj/hTGFeOICAffBo+IOFSfUokMceJPXN3Xwefp5Ee4=;\n\th=From:To:Cc:Subject:Date:From;\n\tb=vKEYO3rzSe33FG42cJPkl0ClUEYxkAfR9ZnW4wrdK56dAsnXCEpeOmIf5k6JImSk3\n\tTK06yhx3ScUjKFrsHZJbiFV6CVzHVTbE4018kKNoISnJ48nxMgojTL2BIqVuLZTQsn\n\tQTxPOhHeCmU29xv7PCtcW3CjuD7uSYnaol0JUHXg=",
        "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] mipi-csis: Emit V4L2_EVENT_FRAME_SYNC events",
        "Date": "Wed, 13 Mar 2024 16:30:58 +0100",
        "Message-Id": "<20240313153058.189684-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\tPurism Kernel Team <kernel@puri.sm>, Fabio Estevam <festevam@gmail.com>,\n\tSascha Hauer <s.hauer@pengutronix.de>, \n\tRui Miguel Silva <rmfrfs@gmail.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>, NXP Linux Team <linux-imx@nxp.com>",
        "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\nthat lies closest to the sensor, the frame counter is the best we can\nget on these devices.\nIn case of the ISI available on the i.MX8 M Plus it is also the only\nnative start-of-frame signal available.\n\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\nSigned-off-by: Stefan Klug <stefan.klug@ideasonboard.com>\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..caeb1622f741 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+\tstruct v4l2_event event = {\n+\t\t.type = V4L2_EVENT_FRAME_SYNC,\n+\t};\n+\n+\tu32 frame = mipi_csis_read(csis, MIPI_CSIS_FRAME_COUNTER_CH(0));\n+\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       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": []
}