Patch Detail
Show a patch.
GET /api/patches/20661/?format=api
{ "id": 20661, "url": "https://patchwork.libcamera.org/api/patches/20661/?format=api", "web_url": "https://patchwork.libcamera.org/patch/20661/", "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": "<20240713184327.23013-1-hdegoede@redhat.com>", "date": "2024-07-13T18:43:27", "name": "libcamera: v4l2_videodevice: Use bufferType_ in [get|try|set]Format()", "commit_ref": null, "pull_url": null, "state": "accepted", "archived": false, "hash": "7b6b021cbe544f03dc7968e12d4fdca85c600025", "submitter": { "id": 102, "url": "https://patchwork.libcamera.org/api/people/102/?format=api", "name": "Hans de Goede", "email": "hdegoede@redhat.com" }, "delegate": null, "mbox": "https://patchwork.libcamera.org/patch/20661/mbox/", "series": [ { "id": 4453, "url": "https://patchwork.libcamera.org/api/series/4453/?format=api", "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=4453", "date": "2024-07-13T18:43:27", "name": "libcamera: v4l2_videodevice: Use bufferType_ in [get|try|set]Format()", "version": 1, "mbox": "https://patchwork.libcamera.org/series/4453/mbox/" } ], "comments": "https://patchwork.libcamera.org/api/patches/20661/comments/", "check": "pending", "checks": "https://patchwork.libcamera.org/api/patches/20661/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 997EBBD87C\n\tfor <parsemail@patchwork.libcamera.org>;\n\tSat, 13 Jul 2024 18:43:41 +0000 (UTC)", "from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 950516336F;\n\tSat, 13 Jul 2024 20:43:40 +0200 (CEST)", "from us-smtp-delivery-124.mimecast.com\n\t(us-smtp-delivery-124.mimecast.com [170.10.133.124])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id BA3D963365\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tSat, 13 Jul 2024 20:43:38 +0200 (CEST)", "from mx-prod-mc-05.mail-002.prod.us-west-2.aws.redhat.com\n\t(ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63])\n\tby relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3,\n\tcipher=TLS_AES_256_GCM_SHA384) id us-mta-154-3tAdkfo4NSecDAlS8-ftQA-1;\n\tSat, 13 Jul 2024 14:43:36 -0400", "from mx-prod-int-02.mail-002.prod.us-west-2.aws.redhat.com\n\t(mx-prod-int-02.mail-002.prod.us-west-2.aws.redhat.com\n\t[10.30.177.15])\n\t(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)\n\tkey-exchange X25519 server-signature RSA-PSS (2048 bits)\n\tserver-digest SHA256) (No client certificate requested)\n\tby mx-prod-mc-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix)\n\twith ESMTPS\n\tid 5CA811956080 for <libcamera-devel@lists.libcamera.org>;\n\tSat, 13 Jul 2024 18:43:35 +0000 (UTC)", "from localhost.localdomain (unknown [10.39.192.9])\n\tby mx-prod-int-02.mail-002.prod.us-west-2.aws.redhat.com (Postfix)\n\twith ESMTP id 5D9E51955F3B; Sat, 13 Jul 2024 18:43:33 +0000 (UTC)" ], "Authentication-Results": "lancelot.ideasonboard.com; dkim=pass (1024-bit key;\n\tunprotected) header.d=redhat.com header.i=@redhat.com\n\theader.b=\"XVBfQZ3+\"; dkim-atps=neutral", "DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com;\n\ts=mimecast20190719; t=1720896217;\n\th=from:from:reply-to:subject:subject:date:date:message-id:message-id:\n\tto:to:cc:cc:mime-version:mime-version:content-type:content-type:\n\tcontent-transfer-encoding:content-transfer-encoding;\n\tbh=c7VNpKahXaH+jwhamyR3OLo1s8lt64WVPJeIdYp9BiU=;\n\tb=XVBfQZ3+yYAicC0melbYjSH90MmokTvor/ah3Hk8X5zpMgmN9i5ZeGz43M0DV1uNYpTXF3\n\tlDGq+sKDOoBQkkC7w1ROSJxURGhfI4U4gy2BGT+cKqEvTn4onot62WYEGHVrhXRXpenied\n\tkCKpualKpVPtKazl+xqXDkjAeHWfAkI=", "X-MC-Unique": "3tAdkfo4NSecDAlS8-ftQA-1", "From": "Hans de Goede <hdegoede@redhat.com>", "To": "libcamera-devel@lists.libcamera.org", "Cc": "Milan Zamazal <mzamazal@redhat.com>, Maxime Ripard <mripard@redhat.com>, \n\tHans de Goede <hdegoede@redhat.com>", "Subject": "[PATCH] libcamera: v4l2_videodevice: Use bufferType_ in\n\t[get|try|set]Format()", "Date": "Sat, 13 Jul 2024 20:43:27 +0200", "Message-ID": "<20240713184327.23013-1-hdegoede@redhat.com>", "MIME-Version": "1.0", "X-Scanned-By": "MIMEDefang 3.0 on 10.30.177.15", "X-Mimecast-Spam-Score": "0", "X-Mimecast-Originator": "redhat.com", "Content-Transfer-Encoding": "8bit", "Content-Type": "text/plain; charset=\"US-ASCII\"; x-default=true", "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>", "Errors-To": "libcamera-devel-bounces@lists.libcamera.org", "Sender": "\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>" }, "content": "V4L2VideoDevice is using the caps to determine which kind of buffers to\nuse with the video-device in 2 different cases:\n\n1. V4L2VideoDevice::open()\n2. V4L2VideoDevice::[get|try|set]Format()\n\nAnd the order in which the caps are checked is different between\nthese 2 cases. This is a problem for /dev/video# nodes which support\nboth video-capture and metadata buffers. open() sets bufferType_ to\nV4L2_BUF_TYPE_VIDEO_CAPTURE[_MPLANE] in this case, where as\n[get|try|set]Format() will call [get|set]FormatMeta() which does not\nwork with V4L2_BUF_TYPE_VIDEO_CAPTURE[_MPLANE] buffers.\n\nSwitch [get|try|set]Format() to use the bufferType_ to determine on what\nsort of buffers they should be operating, leaving the V4L2VideoDevice\ncode with only a single place where the decision is made what sort\nof buffers it should operate on for a specific /dev/video# node.\n\nThis will also allow to modify open() in the future to take a bufferType\nargument to allow overriding the default bufferType it selects for\n/dev/video# nodes which are capable of supporting more then 1 buffer type.\n\nSigned-off-by: Hans de Goede <hdegoede@redhat.com>\n---\n src/libcamera/v4l2_videodevice.cpp | 56 ++++++++++++++++++++++--------\n 1 file changed, 41 insertions(+), 15 deletions(-)", "diff": "diff --git a/src/libcamera/v4l2_videodevice.cpp b/src/libcamera/v4l2_videodevice.cpp\nindex 4947aa3d..a8dc5355 100644\n--- a/src/libcamera/v4l2_videodevice.cpp\n+++ b/src/libcamera/v4l2_videodevice.cpp\n@@ -803,12 +803,19 @@ std::string V4L2VideoDevice::logPrefix() const\n */\n int V4L2VideoDevice::getFormat(V4L2DeviceFormat *format)\n {\n-\tif (caps_.isMeta())\n-\t\treturn getFormatMeta(format);\n-\telse if (caps_.isMultiplanar())\n-\t\treturn getFormatMultiplane(format);\n-\telse\n+\tswitch (bufferType_) {\n+\tcase V4L2_BUF_TYPE_VIDEO_CAPTURE:\n+\tcase V4L2_BUF_TYPE_VIDEO_OUTPUT:\n \t\treturn getFormatSingleplane(format);\n+\tcase V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE:\n+\tcase V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE:\n+\t\treturn getFormatMultiplane(format);\n+\tcase V4L2_BUF_TYPE_META_CAPTURE:\n+\tcase V4L2_BUF_TYPE_META_OUTPUT:\n+\t\treturn getFormatMeta(format);\n+\tdefault:\n+\t\treturn -EINVAL;\n+\t}\n }\n \n /**\n@@ -823,12 +830,19 @@ int V4L2VideoDevice::getFormat(V4L2DeviceFormat *format)\n */\n int V4L2VideoDevice::tryFormat(V4L2DeviceFormat *format)\n {\n-\tif (caps_.isMeta())\n-\t\treturn trySetFormatMeta(format, false);\n-\telse if (caps_.isMultiplanar())\n-\t\treturn trySetFormatMultiplane(format, false);\n-\telse\n+\tswitch (bufferType_) {\n+\tcase V4L2_BUF_TYPE_VIDEO_CAPTURE:\n+\tcase V4L2_BUF_TYPE_VIDEO_OUTPUT:\n \t\treturn trySetFormatSingleplane(format, false);\n+\tcase V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE:\n+\tcase V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE:\n+\t\treturn trySetFormatMultiplane(format, false);\n+\tcase V4L2_BUF_TYPE_META_CAPTURE:\n+\tcase V4L2_BUF_TYPE_META_OUTPUT:\n+\t\treturn trySetFormatMeta(format, false);\n+\tdefault:\n+\t\treturn -EINVAL;\n+\t}\n }\n \n /**\n@@ -843,12 +857,24 @@ int V4L2VideoDevice::tryFormat(V4L2DeviceFormat *format)\n int V4L2VideoDevice::setFormat(V4L2DeviceFormat *format)\n {\n \tint ret = 0;\n-\tif (caps_.isMeta())\n-\t\tret = trySetFormatMeta(format, true);\n-\telse if (caps_.isMultiplanar())\n-\t\tret = trySetFormatMultiplane(format, true);\n-\telse\n+\n+\tswitch (bufferType_) {\n+\tcase V4L2_BUF_TYPE_VIDEO_CAPTURE:\n+\tcase V4L2_BUF_TYPE_VIDEO_OUTPUT:\n \t\tret = trySetFormatSingleplane(format, true);\n+\t\tbreak;\n+\tcase V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE:\n+\tcase V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE:\n+\t\tret = trySetFormatMultiplane(format, true);\n+\t\tbreak;\n+\tcase V4L2_BUF_TYPE_META_CAPTURE:\n+\tcase V4L2_BUF_TYPE_META_OUTPUT:\n+\t\tret = trySetFormatMeta(format, true);\n+\t\tbreak;\n+\tdefault:\n+\t\tret = -EINVAL;\n+\t\tbreak;\n+\t}\n \n \t/* Cache the set format on success. */\n \tif (ret)\n", "prefixes": [] }