Patch Detail
Show a patch.
GET /api/patches/16208/?format=api
{ "id": 16208, "url": "https://patchwork.libcamera.org/api/patches/16208/?format=api", "web_url": "https://patchwork.libcamera.org/patch/16208/", "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": "<20220613103528.226610-1-kieran.bingham@ideasonboard.com>", "date": "2022-06-13T10:35:28", "name": "[libcamera-devel] libcamera: v4l2_videodevice: Identify non-zero stream starts", "commit_ref": "1c9dc0fd89cfb32d31e25c4d14501c891d329307", "pull_url": null, "state": "accepted", "archived": false, "hash": "a5b15c2d6ce98d86cf4b421ba89c646c238e2aa4", "submitter": { "id": 4, "url": "https://patchwork.libcamera.org/api/people/4/?format=api", "name": "Kieran Bingham", "email": "kieran.bingham@ideasonboard.com" }, "delegate": null, "mbox": "https://patchwork.libcamera.org/patch/16208/mbox/", "series": [ { "id": 3173, "url": "https://patchwork.libcamera.org/api/series/3173/?format=api", "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=3173", "date": "2022-06-13T10:35:28", "name": "[libcamera-devel] libcamera: v4l2_videodevice: Identify non-zero stream starts", "version": 1, "mbox": "https://patchwork.libcamera.org/series/3173/mbox/" } ], "comments": "https://patchwork.libcamera.org/api/patches/16208/comments/", "check": "pending", "checks": "https://patchwork.libcamera.org/api/patches/16208/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 68D98BD808\n\tfor <parsemail@patchwork.libcamera.org>;\n\tMon, 13 Jun 2022 10:34:57 +0000 (UTC)", "from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 9CDE565635;\n\tMon, 13 Jun 2022 12:34:56 +0200 (CEST)", "from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[213.167.242.64])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 75BBE600F1\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tMon, 13 Jun 2022 12:34:55 +0200 (CEST)", "from Q.ksquared.org.uk.beta.tailscale.net (unknown\n\t[178.237.134.231])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id DCBDD268;\n\tMon, 13 Jun 2022 12:34:54 +0200 (CEST)" ], "DKIM-Signature": [ "v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org;\n\ts=mail; t=1655116496;\n\tbh=fmZJoXDqVd5bKTQXCh6+VNo1JQNhRaCOaS2yJkt2K0Q=;\n\th=To:Date:Subject:List-Id:List-Unsubscribe:List-Archive:List-Post:\n\tList-Help:List-Subscribe:From:Reply-To:From;\n\tb=m2pak3cjxKCSmEUOBuK0+ET7h63NzKBJT2Mvn/0VCju1gR6jeeUy5h0yA9xM15P8V\n\tvZXo0E8nqwdTNB/HPRh7KtsNT+FjmDVevoH6RJIKNDBckpdBeYFTUba1IL/FNpHhFR\n\tnFtxv2GPz3S1kRHFz1OJManfh9OV0Hy4a6NiIGTiuupAL4BMB9YqmTTavBXv68+JHV\n\teTmBva1w0J1rBfbWsRQ9qDT+nxREmpdAudxNGFoMT44LI9R9EC5q5IMZpvikKA/Ece\n\t77krCoLHyCbdi2xQVWtAMS7okXVBYnx8OSp/p2+KLPnERVwIFmhz01gO76XSItwoOS\n\t/7c3/6lpmNXKQ==", "v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1655116495;\n\tbh=fmZJoXDqVd5bKTQXCh6+VNo1JQNhRaCOaS2yJkt2K0Q=;\n\th=From:To:Cc:Subject:Date:From;\n\tb=emAQoGXZya9LlIliCJChewuq77UdlfYNBg/C477npzTj/fpz7BJGCg+CqPYWmEg2p\n\t0y0/QhFQk30CFPcEMm5o7HV+oXFuKODmsuJ+eVa72hwIki7Zl60tA97ZdsoSr44+KN\n\te6NBNXD1OaniNZ2e2x8rbvRLP6cdfTgx9uAQA74Y=" ], "Authentication-Results": "lancelot.ideasonboard.com; dkim=pass (1024-bit key; \n\tunprotected) header.d=ideasonboard.com\n\theader.i=@ideasonboard.com\n\theader.b=\"emAQoGXZ\"; dkim-atps=neutral", "To": "libcamera devel <libcamera-devel@lists.libcamera.org>", "Date": "Mon, 13 Jun 2022 12:35:28 +0200", "Message-Id": "<20220613103528.226610-1-kieran.bingham@ideasonboard.com>", "X-Mailer": "git-send-email 2.25.1", "MIME-Version": "1.0", "Content-Transfer-Encoding": "8bit", "Subject": "[libcamera-devel] [PATCH] libcamera: v4l2_videodevice: Identify\n\tnon-zero stream starts", "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>", "From": "Kieran Bingham via libcamera-devel\n\t<libcamera-devel@lists.libcamera.org>", "Reply-To": "Kieran Bingham <kieran.bingham@ideasonboard.com>", "Errors-To": "libcamera-devel-bounces@lists.libcamera.org", "Sender": "\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>" }, "content": "V4L2 Video devices should always start streaming from index zero.\nIdentify and report a warning if they don't, and correct for any offset.\n\nSigned-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>\n---\n\nI'm not yet sure if the Warning print is perhaps just unhelpful.\nIt doesn't really affect us if we have this work around in - so we can\nbe silent, and I'm not yet sure if V4L2 has any 'requirement' that it\nshould start at 0 at every stream on.\n\n include/libcamera/internal/v4l2_videodevice.h | 1 +\n src/libcamera/v4l2_videodevice.cpp | 15 +++++++++++++++\n 2 files changed, 16 insertions(+)", "diff": "diff --git a/include/libcamera/internal/v4l2_videodevice.h b/include/libcamera/internal/v4l2_videodevice.h\nindex 23f37f83f8e2..8525acbc558d 100644\n--- a/include/libcamera/internal/v4l2_videodevice.h\n+++ b/include/libcamera/internal/v4l2_videodevice.h\n@@ -276,6 +276,7 @@ private:\n \tEventNotifier *fdBufferNotifier_;\n \n \tState state_;\n+\tstd::optional<unsigned int> firstFrame_;\n \n \tTimer watchdog_;\n \tutils::Duration watchdogDuration_;\ndiff --git a/src/libcamera/v4l2_videodevice.cpp b/src/libcamera/v4l2_videodevice.cpp\nindex 430715afd554..63911339f96e 100644\n--- a/src/libcamera/v4l2_videodevice.cpp\n+++ b/src/libcamera/v4l2_videodevice.cpp\n@@ -1771,6 +1771,19 @@ FrameBuffer *V4L2VideoDevice::dequeueBuffer()\n \tif (V4L2_TYPE_IS_OUTPUT(buf.type))\n \t\treturn buffer;\n \n+\t/*\n+\t * Detect kernel drivers which do not reset the sequence number to zero\n+\t * on stream start.\n+\t */\n+\tif (!firstFrame_) {\n+\t\tif (buf.sequence)\n+\t\t\tLOG(V4L2, Warning)\n+\t\t\t\t<< \"Zero sequence expected for first frame (got \"\n+\t\t\t\t<< buf.sequence << \")\";\n+\t\tfirstFrame_ = buf.sequence;\n+\t}\n+\tbuffer->metadata_.sequence -= firstFrame_.value();\n+\n \tunsigned int numV4l2Planes = multiPlanar ? buf.length : 1;\n \tFrameMetadata &metadata = buffer->metadata_;\n \n@@ -1847,6 +1860,8 @@ int V4L2VideoDevice::streamOn()\n {\n \tint ret;\n \n+\tfirstFrame_.reset();\n+\n \tret = ioctl(VIDIOC_STREAMON, &bufferType_);\n \tif (ret < 0) {\n \t\tLOG(V4L2, Error)\n", "prefixes": [ "libcamera-devel" ] }